@indigoai-us/hq-cli 5.345.250 → 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 +214 -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 +316 -2
- package/dist/command-catalog.generated.js +389 -2
- package/dist/commands/bot.js +12 -3
- 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/lanes.d.ts +2 -0
- package/dist/commands/lanes.js +9 -4
- package/dist/commands/logout.js +4 -0
- package/dist/commands/ontology-graph.d.ts +11 -2
- package/dist/commands/ontology-graph.js +130 -4
- package/dist/commands/report.js +35 -2
- package/dist/commands/sources.js +26 -8
- 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 +37 -0
- package/dist/lib/bot/fleet-cron.js +59 -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 +68 -8
- package/dist/lib/hook-engine/coverage.js +167 -25
- package/dist/lib/hook-engine/native-stop-compatibility.json +9 -4
- package/dist/lib/hook-engine/reconcile.js +3 -2
- package/dist/lib/hot-channels/graph-context.d.ts +26 -1
- package/dist/lib/hot-channels/graph-context.js +76 -9
- package/dist/lib/hot-channels/prompts/signals-pass.md +20 -0
- package/dist/lib/hot-channels/run.d.ts +1 -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 +240 -15
- 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/files.d.ts +4 -0
- package/dist/lib/ontology-graph/model/files.js +23 -0
- package/dist/lib/ontology-graph/model/index.d.ts +65 -1
- package/dist/lib/ontology-graph/model/index.js +154 -18
- package/dist/lib/ontology-graph/model/pass-tasks.d.ts +84 -1
- package/dist/lib/ontology-graph/model/pass-tasks.js +173 -4
- package/dist/lib/ontology-graph/model/pass.d.ts +11 -0
- package/dist/lib/ontology-graph/model/pass.js +17 -10
- package/dist/lib/ontology-graph/model/pending-items.d.ts +39 -0
- package/dist/lib/ontology-graph/model/pending-items.js +136 -0
- package/dist/lib/ontology-graph/model/step.d.ts +47 -2
- package/dist/lib/ontology-graph/model/step.js +202 -36
- package/dist/lib/ontology-graph/model/tasks.d.ts +28 -4
- package/dist/lib/ontology-graph/model/tasks.js +48 -15
- package/dist/lib/ontology-graph/pages/render.d.ts +1 -1
- package/dist/lib/ontology-graph/pages/render.js +4 -3
- package/dist/lib/ontology-graph/read/brief.d.ts +13 -3
- package/dist/lib/ontology-graph/read/brief.js +349 -67
- package/dist/lib/ontology-graph/read/index.d.ts +5 -1
- package/dist/lib/ontology-graph/read/index.js +174 -30
- 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/read/reader-setting.d.ts +2 -0
- package/dist/lib/ontology-graph/read/reader-setting.js +4 -1
- package/dist/lib/ontology-graph/remodel/index.d.ts +174 -0
- package/dist/lib/ontology-graph/remodel/index.js +450 -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 +120 -8
- 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/authority.d.ts +14 -5
- package/dist/lib/ontology-graph/schema/authority.js +13 -3
- 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 +2 -1
- package/dist/lib/ontology-graph/schema/index.js +2 -1
- package/dist/lib/ontology-graph/setup/index.d.ts +88 -0
- package/dist/lib/ontology-graph/setup/index.js +499 -0
- package/dist/lib/ontology-graph/types.d.ts +21 -0
- package/dist/lib/ontology-graph/types.js +5 -0
- 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/signals/failure-alert.js +4 -5
- package/dist/lib/signals/steps/adapters.js +3 -0
- 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/dist/utils/sync-person.d.ts +15 -0
- package/dist/utils/sync-person.js +74 -0
- package/package.json +8 -8
- package/scripts/install-hook-engine.mjs +5 -3
|
@@ -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,7 +25,7 @@ import * as path from "node:path";
|
|
|
25
25
|
import { audienceKey } from "../hot-channels/audience.js";
|
|
26
26
|
import { SIGNED_OUT_SIGNALS_CODES, findSignalsFailures, formatSignalsFailureAlert, raiseSignalsFailureAlerts, signalsAlertKey, signalsAlertStatePath, } from "../hot-channels/alert.js";
|
|
27
27
|
import { assertAllowedPath } from "./write-guard.js";
|
|
28
|
-
import {
|
|
28
|
+
import { resolveSyncPerson } from "../../utils/sync-person.js";
|
|
29
29
|
import { readSignalsPassDetail } from "./steps/types.js";
|
|
30
30
|
/**
|
|
31
31
|
* Extract skips that are not a stall: no source channel to read, or the
|
|
@@ -37,11 +37,10 @@ export const EXTRACT_SKIPS_WITHOUT_ALERT = new Set(["no-sources", "ontology-work
|
|
|
37
37
|
export const SIGNALS_RUN_ALERT_ADAPTER = "signals-run";
|
|
38
38
|
/** The signed-in person, as `runCompanyHotChannelSync` resolves them; null when no one is signed in. */
|
|
39
39
|
export function resolveSignedInAlertPerson() {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
// this alert can address.
|
|
43
|
-
if (!author?.email)
|
|
40
|
+
const person = resolveSyncPerson();
|
|
41
|
+
if (person.kind !== "person")
|
|
44
42
|
return null;
|
|
43
|
+
const author = person.author;
|
|
45
44
|
return { personKey: audienceKey([author.email]), personName: author.email, personUid: author.userSub };
|
|
46
45
|
}
|
|
47
46
|
function firstStep(record, name) {
|
|
@@ -166,6 +166,9 @@ const TOKEN_LEVEL_ADAPTERS = new Set(["attio", "gmail"]);
|
|
|
166
166
|
* document cap left queued (`pass.deferred`) make the step `partial` too.
|
|
167
167
|
*/
|
|
168
168
|
export function mapSyncReport(report, pass) {
|
|
169
|
+
if (report.signInRequired && report.noPersonIdentity) {
|
|
170
|
+
return { status: "skipped", itemsIn: 0, itemsOut: 0, skippedReason: "no-person-identity", byAdapter: {}, errorKind: "config" };
|
|
171
|
+
}
|
|
169
172
|
if (report.signInRequired) {
|
|
170
173
|
return { status: "skipped", itemsIn: 0, itemsOut: 0, skippedReason: "no-login", byAdapter: {}, errorKind: "signed-out" };
|
|
171
174
|
}
|
|
@@ -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;
|
|
@@ -2,6 +2,7 @@ import * as fs from "node:fs";
|
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { parse as parseToml } from "smol-toml";
|
|
4
4
|
import { compareSyncCoreReleases } from "./release-compare.js";
|
|
5
|
+
import { CLIENT_HEALTH_MAX_SYNC_ENGINE_COUNT, } from "../../utils/client-health-contract.js";
|
|
5
6
|
export const SYNC_CORE_REQUESTS_PER_DAY = 20_000;
|
|
6
7
|
// The first engine release with no daily request count; it ignores `requests_per_day`.
|
|
7
8
|
export const SYNC_CORE_REQUEST_COUNT_REMOVED_IN = "v0.1.29";
|
|
@@ -94,9 +95,14 @@ export const SYNC_CORE_STATUS_WORK_LIMIT = 20;
|
|
|
94
95
|
function count(value) {
|
|
95
96
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : 0;
|
|
96
97
|
}
|
|
98
|
+
export const SYNC_CORE_STATUS_FILE_MAX_BYTES = 1024 * 1024;
|
|
97
99
|
function readStatusFile(engineHome) {
|
|
98
100
|
try {
|
|
99
|
-
|
|
101
|
+
const file = path.join(engineHome, ".hq", "sync-core", "status.json");
|
|
102
|
+
const stat = fs.lstatSync(file);
|
|
103
|
+
if (!stat.isFile() || stat.size > SYNC_CORE_STATUS_FILE_MAX_BYTES)
|
|
104
|
+
return undefined;
|
|
105
|
+
return record(JSON.parse(fs.readFileSync(file, "utf8")));
|
|
100
106
|
}
|
|
101
107
|
catch {
|
|
102
108
|
return undefined;
|
|
@@ -204,6 +210,38 @@ function vaultWakeChannel(value, vaultUid) {
|
|
|
204
210
|
const since = isoTime(channel.since_ms);
|
|
205
211
|
return { connected: channel.connected, ...(since ? { since } : {}) };
|
|
206
212
|
}
|
|
213
|
+
const SAFETY_COUNTER_NAMES = [
|
|
214
|
+
["vault_deletes", "vaultDeletes"],
|
|
215
|
+
["local_deletes", "localDeletes"],
|
|
216
|
+
["download_trashed", "downloadTrashed"],
|
|
217
|
+
["conflict_backups", "conflictBackups"],
|
|
218
|
+
["local_replaced", "localReplaced"],
|
|
219
|
+
["uploads_over", "uploadsOver"],
|
|
220
|
+
["refused_deletes", "refusedDeletes"],
|
|
221
|
+
["refused_uploads", "refusedUploads"],
|
|
222
|
+
["adoptions", "adoptions"],
|
|
223
|
+
];
|
|
224
|
+
function vaultSafety(value, vaultUid) {
|
|
225
|
+
if (!Array.isArray(value))
|
|
226
|
+
return undefined;
|
|
227
|
+
const counters = record(value.map(record).find((item) => item?.vault === vaultUid)?.counters);
|
|
228
|
+
if (!counters)
|
|
229
|
+
return undefined;
|
|
230
|
+
const safety = {};
|
|
231
|
+
for (const [engineName, name] of SAFETY_COUNTER_NAMES) {
|
|
232
|
+
const counter = record(counters[engineName]);
|
|
233
|
+
const total = Math.min(wholeCount(counter?.total), CLIENT_HEALTH_MAX_SYNC_ENGINE_COUNT);
|
|
234
|
+
if (!counter || total === 0)
|
|
235
|
+
continue;
|
|
236
|
+
const lastAtMs = Math.floor(timestampMs(counter.last_at_ms) ?? 0);
|
|
237
|
+
safety[name] = {
|
|
238
|
+
total,
|
|
239
|
+
last24h: Math.min(wholeCount(counter.last_24h), CLIENT_HEALTH_MAX_SYNC_ENGINE_COUNT),
|
|
240
|
+
...(lastAtMs > 0 ? { lastAtMs } : {}),
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
return safety;
|
|
244
|
+
}
|
|
207
245
|
export function readEngineStatus(engineHome, vaultUid, now = new Date()) {
|
|
208
246
|
const status = readStatusFile(engineHome);
|
|
209
247
|
if (!status)
|
|
@@ -218,6 +256,7 @@ export function readEngineStatus(engineHome, vaultUid, now = new Date()) {
|
|
|
218
256
|
const transfersQueued = cycle ? wholeCount(cycle.transfers_queued) : 0;
|
|
219
257
|
const running = runningCycle(status.cycle, vaultUid, now);
|
|
220
258
|
const wakeChannel = vaultWakeChannel(status.wakes, vaultUid);
|
|
259
|
+
const safety = vaultSafety(status.safety, vaultUid);
|
|
221
260
|
return {
|
|
222
261
|
...(typeof status.engine_version === "string" && status.engine_version ? { engineVersion: status.engine_version } : {}),
|
|
223
262
|
...(startedAt ? { startedAt } : {}),
|
|
@@ -226,6 +265,7 @@ export function readEngineStatus(engineHome, vaultUid, now = new Date()) {
|
|
|
226
265
|
: {}),
|
|
227
266
|
...(running ? { cycle: running } : {}),
|
|
228
267
|
...(wakeChannel ? { wakeChannel } : {}),
|
|
268
|
+
...(safety ? { safety } : {}),
|
|
229
269
|
...(cycle && atMs !== undefined
|
|
230
270
|
? {
|
|
231
271
|
lastCycle: {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readLocalOverride } from "@indigoai-us/hq-flags-client";
|
|
2
|
+
import { createHqFlagClient as createFlagClient } from "../flag-client-headers.js";
|
|
2
3
|
import { resolveFlagRegistryEndpoint } from "../flag-registry-endpoint.js";
|
|
3
4
|
export const SYNC_RUST_ENGINE_ROLLOUT_FLAG = "sync.rust-engine-rollout-v3";
|
|
4
5
|
const READ_TIMEOUT_MS = 5_000;
|
|
@@ -4,8 +4,10 @@ import { writeLegacyJournalExport } from "./legacy-journal-export.js";
|
|
|
4
4
|
import { loadLegacyJournalReader } from "./legacy-journal-reader.js";
|
|
5
5
|
const [home, uid, slug, offSince] = process.argv.slice(2);
|
|
6
6
|
try {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const cutoff = offSince ? Date.parse(offSince) : Number.NaN;
|
|
8
|
+
if (!home || !uid || !slug || !Number.isFinite(cutoff)) {
|
|
9
|
+
throw new Error("usage: legacy-journal-export-child <home> <vault uid> <slug> <time the current sync's switch was turned off>");
|
|
10
|
+
}
|
|
9
11
|
const loaded = await loadLegacyJournalReader([currentHqCloud(daemonPaths(home, process.env).root), bundledHqCloud()]);
|
|
10
12
|
if (!loaded.reader)
|
|
11
13
|
throw new Error(loaded.reason);
|
|
@@ -13,7 +15,7 @@ try {
|
|
|
13
15
|
home,
|
|
14
16
|
vault: { uid, kind: "company", slug },
|
|
15
17
|
readJournal: loaded.reader,
|
|
16
|
-
|
|
18
|
+
offSince: cutoff,
|
|
17
19
|
});
|
|
18
20
|
process.exit(0);
|
|
19
21
|
}
|
|
@@ -13,18 +13,30 @@ export type LegacyJournalExportResult = {
|
|
|
13
13
|
file: string;
|
|
14
14
|
replaced: boolean;
|
|
15
15
|
} | {
|
|
16
|
-
status: "present" | "consumed" | "not-company" | "no-journal";
|
|
16
|
+
status: "present" | "consumed" | "stale" | "not-company" | "no-journal" | "no-cutoff" | "nothing-to-export";
|
|
17
|
+
};
|
|
18
|
+
export type LegacyJournalExportState = "present" | "unusable" | "consumed" | "stale" | "missing" | "not-company";
|
|
19
|
+
export type StaleLegacyJournalDrop = {
|
|
20
|
+
status: "none" | "removed";
|
|
21
|
+
} | {
|
|
22
|
+
status: "failed";
|
|
23
|
+
reason: string;
|
|
17
24
|
};
|
|
18
|
-
export type LegacyJournalExportState = "present" | "unusable" | "consumed" | "missing" | "not-company";
|
|
19
25
|
export declare const LEGACY_JOURNAL_EXPORT_MAX_BYTES: number;
|
|
20
26
|
export declare const LEGACY_JOURNAL_EXPORT_MAX_AHEAD_MS: number;
|
|
21
27
|
export declare function legacyJournalExportPath(home: string, uid: string, slug: string): string;
|
|
22
28
|
export declare function legacyJournalConsumedPath(home: string, uid: string, slug: string): string;
|
|
23
29
|
export declare function legacyJournalUnprovenPath(home: string, uid: string, slug: string): string;
|
|
30
|
+
export declare function legacyJournalStalePath(home: string, uid: string, slug: string): string;
|
|
24
31
|
export declare function legacyJournalExportState(home: string, vault: LegacyJournalExportVault, now?: number): LegacyJournalExportState;
|
|
25
|
-
export declare function legacyStateDir(home: string, env: NodeJS.ProcessEnv): string;
|
|
26
32
|
export declare function legacyStateDirs(home: string, env: NodeJS.ProcessEnv): string[];
|
|
27
33
|
export declare function legacyJournalDirs(home: string, env: NodeJS.ProcessEnv, slug: string): string[];
|
|
34
|
+
export interface MergeLegacyJournalOptions {
|
|
35
|
+
offSince: number | undefined;
|
|
36
|
+
now: number;
|
|
37
|
+
platform?: NodeJS.Platform;
|
|
38
|
+
}
|
|
39
|
+
export declare function mergeLegacyJournalFiles(journals: readonly Record<string, unknown>[], opts: MergeLegacyJournalOptions): Record<string, unknown>;
|
|
28
40
|
export declare function removeLegacyJournalTemps(home: string, vault: LegacyJournalExportVault): void;
|
|
29
41
|
export interface WriteLegacyJournalExportOptions {
|
|
30
42
|
home: string;
|
|
@@ -33,7 +45,14 @@ export interface WriteLegacyJournalExportOptions {
|
|
|
33
45
|
env?: NodeJS.ProcessEnv;
|
|
34
46
|
now?: () => number;
|
|
35
47
|
offSince?: number;
|
|
48
|
+
platform?: NodeJS.Platform;
|
|
36
49
|
}
|
|
37
50
|
export declare function writeLegacyJournalExport(opts: WriteLegacyJournalExportOptions): LegacyJournalExportResult;
|
|
38
|
-
export declare function removeLegacyJournalExport(home: string, vault: LegacyJournalExportVault
|
|
51
|
+
export declare function removeLegacyJournalExport(home: string, vault: LegacyJournalExportVault, removeFiles?: (home: string, vault: LegacyJournalExportVault & {
|
|
52
|
+
slug: string;
|
|
53
|
+
}) => void): void;
|
|
54
|
+
export declare function markLegacyJournalExportStale(home: string, vault: LegacyJournalExportVault): void;
|
|
55
|
+
export declare function dropStaleLegacyJournalExport(home: string, vault: LegacyJournalExportVault, removeFiles?: (home: string, vault: LegacyJournalExportVault & {
|
|
56
|
+
slug: string;
|
|
57
|
+
}) => void): StaleLegacyJournalDrop;
|
|
39
58
|
//# sourceMappingURL=legacy-journal-export.d.ts.map
|