@indigoai-us/hq-cli 5.108.18 → 5.108.20
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 +15 -0
- package/dist/commands/sync-manifest.d.ts +213 -0
- package/dist/commands/sync-manifest.js +384 -0
- package/dist/lib/doctor/checks/sync-health.d.ts +46 -1
- package/dist/lib/doctor/checks/sync-health.js +212 -5
- package/dist/lib/hq-cloud-manifest.d.ts +62 -0
- package/dist/lib/hq-cloud-manifest.js +83 -0
- package/dist/lib/mesh/live/session-event.schema.json +144 -0
- package/dist/lib/work-context/contract.schema.json +107 -0
- package/dist/register-all.js +2 -0
- package/dist/schemas/hq-package.schema.json +155 -0
- package/package.json +3 -3
|
@@ -50,16 +50,61 @@ export interface SyncVersionInfo {
|
|
|
50
50
|
core: string | null;
|
|
51
51
|
desktop: string | null;
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Per-scope manifest upload state, as `hq doctor` reads it. Structurally the
|
|
55
|
+
* subset of hq-cloud's `ManifestUploadStatus` this family reports, restated so
|
|
56
|
+
* the check is injectable without a state dir.
|
|
57
|
+
*/
|
|
58
|
+
export interface SyncManifestUploadStatus {
|
|
59
|
+
scopeKey: string;
|
|
60
|
+
lastUploadAt: string | null;
|
|
61
|
+
snapshotId: string | null;
|
|
62
|
+
sequence: number;
|
|
63
|
+
baseUsable: boolean;
|
|
64
|
+
}
|
|
53
65
|
/** Injectable dependencies — defaults are the real collectors. */
|
|
54
66
|
export interface SyncHealthDeps {
|
|
55
67
|
versions: (hqRoot: string) => SyncVersionInfo;
|
|
56
68
|
journals: () => readonly SyncJournalSummary[];
|
|
57
69
|
now: () => Date;
|
|
70
|
+
/**
|
|
71
|
+
* Per-scope manifest upload state (sync-reconciliation-audit US-004).
|
|
72
|
+
*
|
|
73
|
+
* Takes the ALREADY-ENUMERATED journals so the scope list the manifest check
|
|
74
|
+
* reports is exactly the scope list the staleness checks report — deriving it
|
|
75
|
+
* a second way is how the two halves of this family would end up disagreeing
|
|
76
|
+
* about which companies exist on the machine.
|
|
77
|
+
*/
|
|
78
|
+
manifestStatuses?: (journals: readonly SyncJournalSummary[]) => readonly SyncManifestUploadStatus[];
|
|
79
|
+
/**
|
|
80
|
+
* Whether the installed hq-cloud exposes the manifest exports at all.
|
|
81
|
+
* Optional; defaults to feature detection. When false the family emits a
|
|
82
|
+
* single NA row instead of failing — an older hq-cloud is a missing
|
|
83
|
+
* capability, not a broken install.
|
|
84
|
+
*/
|
|
85
|
+
manifestAvailable?: () => boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Scopes that appear as journal shards but cannot be turned into a manifest
|
|
88
|
+
* scope key locally (company shards, whose `companyUid` the journal listing
|
|
89
|
+
* does not carry). Reported explicitly as UNTESTED rather than silently
|
|
90
|
+
* dropped — a scope missing from the output is indistinguishable from a
|
|
91
|
+
* scope that is fine.
|
|
92
|
+
*/
|
|
93
|
+
unresolvedScopes?: (journals: readonly SyncJournalSummary[]) => readonly string[];
|
|
58
94
|
}
|
|
59
95
|
/** The versions/sync check family. Registered in `createDefaultRegistry`. */
|
|
60
96
|
export declare const syncHealthFamily: CheckFamily;
|
|
61
97
|
/** Run every versions/sync check. A thrown check degrades to UNKNOWN. */
|
|
62
|
-
export declare function checkSyncHealth(context: CheckContext,
|
|
98
|
+
export declare function checkSyncHealth(context: CheckContext, rawDeps?: SyncHealthDeps): CheckResult[];
|
|
63
99
|
/** True when `a` > `b` for plain X.Y.Z versions. Non-numeric parts compare 0. */
|
|
64
100
|
export declare function semverGt(a: string, b: string): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* A scope whose last manifest upload is older than this is reported stale.
|
|
103
|
+
*
|
|
104
|
+
* The upload pass throttles itself to one pass per scope per 24h, so anything
|
|
105
|
+
* under two days is simply "the throttle is working". Three days means at
|
|
106
|
+
* least two scheduled passes were missed, which is a corroborated signal that
|
|
107
|
+
* something — the daemon, the network, the kill switch — is not running.
|
|
108
|
+
*/
|
|
109
|
+
export declare const STALE_MANIFEST_THRESHOLD_MS: number;
|
|
65
110
|
//# sourceMappingURL=sync-health.d.ts.map
|
|
@@ -25,7 +25,12 @@
|
|
|
25
25
|
*/
|
|
26
26
|
import * as fs from "node:fs";
|
|
27
27
|
import * as path from "node:path";
|
|
28
|
-
|
|
28
|
+
// Namespace import, deliberately: hq-cloud is an ESM package, so a static
|
|
29
|
+
// NAMED import of an export the installed version lacks is a link-time
|
|
30
|
+
// SyntaxError that would stop `hq doctor` from starting at all. See
|
|
31
|
+
// ../../hq-cloud-manifest.js.
|
|
32
|
+
import * as hqCloud from "@indigoai-us/hq-cloud";
|
|
33
|
+
import { loadManifestExports, MANIFEST_UNAVAILABLE_REASON, } from "../../hq-cloud-manifest.js";
|
|
29
34
|
import { CLI_VERSION } from "../../../cli-version.js";
|
|
30
35
|
import { readSyncVersion } from "../../../utils/feedback-versions.js";
|
|
31
36
|
import { readHqVersion } from "../../../utils/pack-contributions.js";
|
|
@@ -41,6 +46,25 @@ export const SYNC_FAMILY_TITLE = "Versions & sync";
|
|
|
41
46
|
export const STALE_JOURNAL_THRESHOLD_MS = 7 * 24 * 60 * 60 * 1000;
|
|
42
47
|
/** The offline update cache written by the check-hq-update SessionStart hook. */
|
|
43
48
|
export const UPDATE_CACHE_RELPATH = path.join("workspace", ".hq-update-check", "last-check.json");
|
|
49
|
+
/** Fill in the optional dependencies so call sites never branch on undefined. */
|
|
50
|
+
function withDefaults(deps) {
|
|
51
|
+
return {
|
|
52
|
+
...deps,
|
|
53
|
+
manifestStatuses: deps.manifestStatuses ?? defaultManifestStatuses,
|
|
54
|
+
manifestAvailable: deps.manifestAvailable ?? (() => loadManifestExports() !== null),
|
|
55
|
+
unresolvedScopes: deps.unresolvedScopes ?? defaultUnresolvedScopes,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Company journal shards are unresolvable by the default collector: the
|
|
60
|
+
* snapshot store keys company scopes by `companyUid`, which `listJournals()`
|
|
61
|
+
* does not carry. Naming them here keeps them visible.
|
|
62
|
+
*/
|
|
63
|
+
function defaultUnresolvedScopes(journals) {
|
|
64
|
+
return journals
|
|
65
|
+
.filter((entry) => !NON_COMPANY_JOURNAL_SLUGS.has(entry.slug))
|
|
66
|
+
.map((entry) => entry.slug);
|
|
67
|
+
}
|
|
44
68
|
function defaultVersions(hqRoot) {
|
|
45
69
|
return {
|
|
46
70
|
cli: CLI_VERSION,
|
|
@@ -70,9 +94,58 @@ const DEFAULT_DEPS = {
|
|
|
70
94
|
// surface as UNKNOWN in `journalResults`, never be collapsed into the
|
|
71
95
|
// empty-list (NA, "cloud sync not in use") case. False healthy is worse
|
|
72
96
|
// than no check.
|
|
73
|
-
journals: () => listJournals(),
|
|
97
|
+
journals: () => hqCloud.listJournals(),
|
|
74
98
|
now: () => new Date(),
|
|
99
|
+
manifestStatuses: defaultManifestStatuses,
|
|
75
100
|
};
|
|
101
|
+
/**
|
|
102
|
+
* Map the machine's journal shards onto the manifest scopes hq-cloud keys its
|
|
103
|
+
* snapshot store by, then read each one's last upload.
|
|
104
|
+
*
|
|
105
|
+
* The journal slug `personal` is the personal tree; every other slug is a
|
|
106
|
+
* company. Note the snapshot store keys company scopes by `companyUid`, which
|
|
107
|
+
* the journal listing does not carry — so a company whose uid we cannot name
|
|
108
|
+
* is simply not reported here rather than reported wrongly. That is the honest
|
|
109
|
+
* outcome: this check exists to tell an operator when a manifest STOPPED being
|
|
110
|
+
* uploaded, and inventing a scope key would make it lie in both directions.
|
|
111
|
+
*/
|
|
112
|
+
function defaultManifestStatuses(journals) {
|
|
113
|
+
// Both the legacy `personal` shard and the current personal-vault
|
|
114
|
+
// pseudo-slug name the SAME personal tree; a machine mid-migration has both
|
|
115
|
+
// on disk, so collapse them to a single personal scope rather than asking
|
|
116
|
+
// hq-cloud for the same scope twice.
|
|
117
|
+
const scopes = journals.some((entry) => NON_COMPANY_JOURNAL_SLUGS.has(entry.slug))
|
|
118
|
+
? [{ kind: "personal" }]
|
|
119
|
+
: [];
|
|
120
|
+
if (scopes.length === 0)
|
|
121
|
+
return [];
|
|
122
|
+
// Absent on an older hq-cloud; the NA row is emitted by `manifestResults`
|
|
123
|
+
// before this ever runs, so returning empty here is belt-and-braces.
|
|
124
|
+
const exports = loadManifestExports();
|
|
125
|
+
if (!exports)
|
|
126
|
+
return [];
|
|
127
|
+
return exports.readManifestUploadStatus(exports.getStateDir(), scopes);
|
|
128
|
+
}
|
|
129
|
+
/** The legacy journal slug that named the personal (non-company) tree. */
|
|
130
|
+
const PERSONAL_SCOPE_SLUG = "personal";
|
|
131
|
+
/**
|
|
132
|
+
* hq-cloud's personal-vault pseudo-slug (`PERSONAL_VAULT_JOURNAL_SLUG`). It is
|
|
133
|
+
* a sentinel, not a company: the entity service never mints a slug with
|
|
134
|
+
* leading underscores. Inlined rather than imported so this module keeps its
|
|
135
|
+
* link-safety story (see `hq-cloud-manifest.ts`).
|
|
136
|
+
*/
|
|
137
|
+
const PERSONAL_VAULT_SCOPE_SLUG = "__hq_personal_vault__";
|
|
138
|
+
/**
|
|
139
|
+
* Journal slugs that do NOT name a company. Every one of these is already
|
|
140
|
+
* covered by the `sync.manifest.personal` row, so listing them as unresolved
|
|
141
|
+
* company scopes would be doubly wrong: it invents a company that does not
|
|
142
|
+
* exist and tells the operator to run `hq sync manifest --scope
|
|
143
|
+
* __hq_personal_vault__`, which is not a scope the CLI accepts.
|
|
144
|
+
*/
|
|
145
|
+
const NON_COMPANY_JOURNAL_SLUGS = new Set([
|
|
146
|
+
PERSONAL_SCOPE_SLUG,
|
|
147
|
+
PERSONAL_VAULT_SCOPE_SLUG,
|
|
148
|
+
]);
|
|
76
149
|
/** The versions/sync check family. Registered in `createDefaultRegistry`. */
|
|
77
150
|
export const syncHealthFamily = {
|
|
78
151
|
id: SYNC_FAMILY_ID,
|
|
@@ -80,12 +153,13 @@ export const syncHealthFamily = {
|
|
|
80
153
|
run: (context) => Promise.resolve(checkSyncHealth(context)),
|
|
81
154
|
};
|
|
82
155
|
/** Run every versions/sync check. A thrown check degrades to UNKNOWN. */
|
|
83
|
-
export function checkSyncHealth(context,
|
|
156
|
+
export function checkSyncHealth(context, rawDeps = DEFAULT_DEPS) {
|
|
157
|
+
const deps = withDefaults(rawDeps);
|
|
84
158
|
try {
|
|
85
159
|
return [
|
|
86
160
|
...versionResults(context, deps),
|
|
87
161
|
...updateAvailabilityResult(context, deps),
|
|
88
|
-
...
|
|
162
|
+
...journalAndManifestResults(deps),
|
|
89
163
|
];
|
|
90
164
|
}
|
|
91
165
|
catch (error) {
|
|
@@ -204,7 +278,16 @@ export function semverGt(a, b) {
|
|
|
204
278
|
return false;
|
|
205
279
|
}
|
|
206
280
|
// ─── Per-journal staleness ───────────────────────────────────────────────────
|
|
207
|
-
|
|
281
|
+
/**
|
|
282
|
+
* Enumerate the journals ONCE, then run both the staleness checks and the
|
|
283
|
+
* manifest-upload checks off that single list.
|
|
284
|
+
*
|
|
285
|
+
* Sharing the enumeration is not just an optimisation: an enumeration failure
|
|
286
|
+
* must produce exactly one UNKNOWN, and the two checks must never disagree
|
|
287
|
+
* about which scopes exist because they asked the store at two different
|
|
288
|
+
* moments.
|
|
289
|
+
*/
|
|
290
|
+
function journalAndManifestResults(deps) {
|
|
208
291
|
// Enumeration failure (throw / IO error) is UNKNOWN — which FAILS per the
|
|
209
292
|
// doctor's exit-code contract — never NA: a broken or unreadable journal
|
|
210
293
|
// store must not read as "cloud sync not in use" (a false healthy). Only a
|
|
@@ -235,6 +318,9 @@ function journalResults(deps) {
|
|
|
235
318
|
},
|
|
236
319
|
];
|
|
237
320
|
}
|
|
321
|
+
return [...journalResults(deps, journals), ...manifestResults(deps, journals)];
|
|
322
|
+
}
|
|
323
|
+
function journalResults(deps, journals) {
|
|
238
324
|
const nowMs = deps.now().getTime();
|
|
239
325
|
return journals.map((entry) => {
|
|
240
326
|
const lastSync = entry.journal?.lastSync;
|
|
@@ -276,4 +362,125 @@ function journalResults(deps) {
|
|
|
276
362
|
};
|
|
277
363
|
});
|
|
278
364
|
}
|
|
365
|
+
// ─── Manifest upload freshness (sync-reconciliation-audit US-004) ────────────
|
|
366
|
+
/**
|
|
367
|
+
* A scope whose last manifest upload is older than this is reported stale.
|
|
368
|
+
*
|
|
369
|
+
* The upload pass throttles itself to one pass per scope per 24h, so anything
|
|
370
|
+
* under two days is simply "the throttle is working". Three days means at
|
|
371
|
+
* least two scheduled passes were missed, which is a corroborated signal that
|
|
372
|
+
* something — the daemon, the network, the kill switch — is not running.
|
|
373
|
+
*/
|
|
374
|
+
export const STALE_MANIFEST_THRESHOLD_MS = 3 * 24 * 60 * 60 * 1000;
|
|
375
|
+
/**
|
|
376
|
+
* Report the last manifest upload per scope.
|
|
377
|
+
*
|
|
378
|
+
* NEVER-UPLOADED IS INFORMATIONAL, NOT A FAILURE. The audit rolls out to a
|
|
379
|
+
* fleet that has never run a pass, and every one of those machines is working
|
|
380
|
+
* exactly as designed until the first pass is due. Reporting UNTESTED (wired
|
|
381
|
+
* but not yet exercised) rather than WARN is the whole reason the doctor's
|
|
382
|
+
* status vocabulary has that value — collapsing it into WARN would turn the
|
|
383
|
+
* first day of the rollout into a fleet-wide false alarm.
|
|
384
|
+
*/
|
|
385
|
+
function manifestResults(deps, journals) {
|
|
386
|
+
// An hq-cloud that predates the manifest exports is a MISSING CAPABILITY,
|
|
387
|
+
// not a fault: one NA row, and the rest of `hq doctor` runs untouched.
|
|
388
|
+
if (!deps.manifestAvailable()) {
|
|
389
|
+
return [
|
|
390
|
+
{
|
|
391
|
+
status: "NA",
|
|
392
|
+
checkId: "sync.manifest",
|
|
393
|
+
message: `${MANIFEST_UNAVAILABLE_REASON} — upgrade hq-cloud to audit manifest uploads.`,
|
|
394
|
+
},
|
|
395
|
+
];
|
|
396
|
+
}
|
|
397
|
+
let statuses;
|
|
398
|
+
try {
|
|
399
|
+
statuses = deps.manifestStatuses(journals);
|
|
400
|
+
}
|
|
401
|
+
catch (error) {
|
|
402
|
+
return [
|
|
403
|
+
{
|
|
404
|
+
status: "UNKNOWN",
|
|
405
|
+
checkId: "sync.manifest",
|
|
406
|
+
message: `Manifest upload state could not be read: ${error instanceof Error ? error.message : String(error)}`,
|
|
407
|
+
remediation: "Check that the HQ state directory is readable, then re-run `hq doctor`.",
|
|
408
|
+
},
|
|
409
|
+
];
|
|
410
|
+
}
|
|
411
|
+
const unresolved = unresolvedResults(deps, journals);
|
|
412
|
+
if (statuses.length === 0) {
|
|
413
|
+
if (unresolved.length > 0)
|
|
414
|
+
return unresolved;
|
|
415
|
+
return [
|
|
416
|
+
{
|
|
417
|
+
status: "NA",
|
|
418
|
+
checkId: "sync.manifest",
|
|
419
|
+
message: "No manifest-auditable sync scopes on this machine — nothing to reconcile.",
|
|
420
|
+
},
|
|
421
|
+
];
|
|
422
|
+
}
|
|
423
|
+
const nowMs = deps.now().getTime();
|
|
424
|
+
const reported = statuses.map((entry) => {
|
|
425
|
+
const checkId = `sync.manifest.${entry.scopeKey}`;
|
|
426
|
+
if (!entry.lastUploadAt) {
|
|
427
|
+
return {
|
|
428
|
+
status: "UNTESTED",
|
|
429
|
+
checkId,
|
|
430
|
+
message: `Scope '${entry.scopeKey}' has never uploaded a sync manifest — expected until the first pass runs.`,
|
|
431
|
+
remediation: "Run `hq sync manifest` to upload one now.",
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
const parsed = Date.parse(entry.lastUploadAt);
|
|
435
|
+
if (!Number.isFinite(parsed)) {
|
|
436
|
+
return {
|
|
437
|
+
status: "UNKNOWN",
|
|
438
|
+
checkId,
|
|
439
|
+
message: `Scope '${entry.scopeKey}' has an unparseable last manifest upload time (${entry.lastUploadAt}).`,
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
const ageMs = nowMs - parsed;
|
|
443
|
+
const baseNote = entry.baseUsable
|
|
444
|
+
? `delta base ${entry.snapshotId ?? "?"}`
|
|
445
|
+
: "next pass will send a full manifest";
|
|
446
|
+
if (ageMs > STALE_MANIFEST_THRESHOLD_MS) {
|
|
447
|
+
const days = Math.floor(ageMs / 86_400_000);
|
|
448
|
+
return {
|
|
449
|
+
status: "WARN",
|
|
450
|
+
checkId,
|
|
451
|
+
message: `Scope '${entry.scopeKey}' last uploaded a sync manifest ${days} day${days === 1 ? "" : "s"} ago (${entry.lastUploadAt}) — the daily audit pass is not running.`,
|
|
452
|
+
remediation: "Run `hq sync manifest` and check HQ_SYNC_MANIFEST_DISABLED and the sync runner.",
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
return {
|
|
456
|
+
status: "PASS",
|
|
457
|
+
checkId,
|
|
458
|
+
message: `Scope '${entry.scopeKey}' uploaded a sync manifest at ${entry.lastUploadAt} (sequence ${entry.sequence}, ${baseNote}).`,
|
|
459
|
+
};
|
|
460
|
+
});
|
|
461
|
+
return [...reported, ...unresolved];
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* One explicit row per scope we could NOT resolve to a manifest scope key.
|
|
465
|
+
*
|
|
466
|
+
* UNTESTED, not NA and certainly not silence: the scope exists on this machine
|
|
467
|
+
* and is genuinely un-audited, so an operator must be able to see that the
|
|
468
|
+
* doctor did not check it. Silently skipping is how a company stops being
|
|
469
|
+
* reconciled without anyone noticing.
|
|
470
|
+
*/
|
|
471
|
+
function unresolvedResults(deps, journals) {
|
|
472
|
+
let slugs;
|
|
473
|
+
try {
|
|
474
|
+
slugs = deps.unresolvedScopes(journals);
|
|
475
|
+
}
|
|
476
|
+
catch {
|
|
477
|
+
return [];
|
|
478
|
+
}
|
|
479
|
+
return slugs.map((slug) => ({
|
|
480
|
+
status: "UNTESTED",
|
|
481
|
+
checkId: `sync.manifest.unresolved.${slug}`,
|
|
482
|
+
message: `Company scope '${slug}' has a sync journal but its companyUid could not be resolved locally — its manifest uploads were not checked.`,
|
|
483
|
+
remediation: `Run \`hq sync manifest --scope ${slug}\` to audit it explicitly.`,
|
|
484
|
+
}));
|
|
485
|
+
}
|
|
279
486
|
//# sourceMappingURL=sync-health.js.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature detection for the hq-cloud manifest exports.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS FILE EXISTS
|
|
5
|
+
* --------------------
|
|
6
|
+
* `runManifestUploadPass` / `readManifestUploadStatus` were added in the
|
|
7
|
+
* hq-cloud sync-reconciliation-audit branch and are NOT in the currently
|
|
8
|
+
* published `~6.16.6` line that this CLI pins. hq-cloud is an ES module, so a
|
|
9
|
+
* static named import of an export that does not exist is a LINK-TIME
|
|
10
|
+
* SyntaxError: the importing module never evaluates, and every command that
|
|
11
|
+
* transitively imports it dies at startup. `hq doctor` is one of those
|
|
12
|
+
* commands, and it is one of the most widely used in the CLI — a doctor that
|
|
13
|
+
* cannot start is strictly worse than a doctor missing one row.
|
|
14
|
+
*
|
|
15
|
+
* So nothing imports those symbols by name. We import the module NAMESPACE
|
|
16
|
+
* (always link-safe, regardless of which exports exist) and feature-detect the
|
|
17
|
+
* functions on it. Callers that need them ask for them and degrade when they
|
|
18
|
+
* are absent:
|
|
19
|
+
* - `hq doctor` emits a single NA row ("manifest status unavailable");
|
|
20
|
+
* - `hq sync manifest` prints the version requirement and exits non-zero.
|
|
21
|
+
*
|
|
22
|
+
* Once the hq-cloud release carrying these exports lands and the pin is bumped,
|
|
23
|
+
* this module keeps working unchanged — detection simply always succeeds.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* The first hq-cloud release that carries the manifest upload exports.
|
|
27
|
+
*
|
|
28
|
+
* 6.16.23 is the release that actually ships `runManifestUploadPass` /
|
|
29
|
+
* `readManifestUploadStatus`, and is the version this package pins.
|
|
30
|
+
*
|
|
31
|
+
* Used only for the human-facing "you need at least X" message; the actual
|
|
32
|
+
* gate is capability detection, never a version comparison — a version string
|
|
33
|
+
* can lie about what a build contains, a function reference cannot. So a stale
|
|
34
|
+
* value here misinforms, but never misgates.
|
|
35
|
+
*/
|
|
36
|
+
export declare const MANIFEST_MIN_HQ_CLOUD_VERSION = "6.16.23";
|
|
37
|
+
/** One-line explanation shared by every degradation path. */
|
|
38
|
+
export declare const MANIFEST_UNAVAILABLE_REASON: string;
|
|
39
|
+
/** The subset of hq-cloud the manifest paths need, once proven present. */
|
|
40
|
+
export interface ManifestExports {
|
|
41
|
+
runManifestUploadPass: (options: never) => unknown;
|
|
42
|
+
readManifestUploadStatus: (...args: never[]) => unknown;
|
|
43
|
+
getStateDir: () => string;
|
|
44
|
+
}
|
|
45
|
+
/** Thrown by {@link requireManifestExports}. Carries a user-ready message. */
|
|
46
|
+
export declare class ManifestUnsupportedError extends Error {
|
|
47
|
+
constructor(message?: string);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Resolve the manifest exports, or null when the installed hq-cloud predates
|
|
51
|
+
* them.
|
|
52
|
+
*
|
|
53
|
+
* The module object is injectable so the absent-export path is testable
|
|
54
|
+
* without mocking the package (and so the test cannot accidentally pass merely
|
|
55
|
+
* because the local `link:` override happens to be new enough).
|
|
56
|
+
*/
|
|
57
|
+
export declare function loadManifestExports(mod?: Record<string, unknown>): ManifestExports | null;
|
|
58
|
+
/** True when the installed hq-cloud can do manifest passes at all. */
|
|
59
|
+
export declare function manifestExportsAvailable(mod?: Record<string, unknown>): boolean;
|
|
60
|
+
/** Like {@link loadManifestExports}, but throws instead of returning null. */
|
|
61
|
+
export declare function requireManifestExports(mod?: Record<string, unknown>): ManifestExports;
|
|
62
|
+
//# sourceMappingURL=hq-cloud-manifest.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature detection for the hq-cloud manifest exports.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS FILE EXISTS
|
|
5
|
+
* --------------------
|
|
6
|
+
* `runManifestUploadPass` / `readManifestUploadStatus` were added in the
|
|
7
|
+
* hq-cloud sync-reconciliation-audit branch and are NOT in the currently
|
|
8
|
+
* published `~6.16.6` line that this CLI pins. hq-cloud is an ES module, so a
|
|
9
|
+
* static named import of an export that does not exist is a LINK-TIME
|
|
10
|
+
* SyntaxError: the importing module never evaluates, and every command that
|
|
11
|
+
* transitively imports it dies at startup. `hq doctor` is one of those
|
|
12
|
+
* commands, and it is one of the most widely used in the CLI — a doctor that
|
|
13
|
+
* cannot start is strictly worse than a doctor missing one row.
|
|
14
|
+
*
|
|
15
|
+
* So nothing imports those symbols by name. We import the module NAMESPACE
|
|
16
|
+
* (always link-safe, regardless of which exports exist) and feature-detect the
|
|
17
|
+
* functions on it. Callers that need them ask for them and degrade when they
|
|
18
|
+
* are absent:
|
|
19
|
+
* - `hq doctor` emits a single NA row ("manifest status unavailable");
|
|
20
|
+
* - `hq sync manifest` prints the version requirement and exits non-zero.
|
|
21
|
+
*
|
|
22
|
+
* Once the hq-cloud release carrying these exports lands and the pin is bumped,
|
|
23
|
+
* this module keeps working unchanged — detection simply always succeeds.
|
|
24
|
+
*/
|
|
25
|
+
import * as hqCloud from "@indigoai-us/hq-cloud";
|
|
26
|
+
/**
|
|
27
|
+
* The first hq-cloud release that carries the manifest upload exports.
|
|
28
|
+
*
|
|
29
|
+
* 6.16.23 is the release that actually ships `runManifestUploadPass` /
|
|
30
|
+
* `readManifestUploadStatus`, and is the version this package pins.
|
|
31
|
+
*
|
|
32
|
+
* Used only for the human-facing "you need at least X" message; the actual
|
|
33
|
+
* gate is capability detection, never a version comparison — a version string
|
|
34
|
+
* can lie about what a build contains, a function reference cannot. So a stale
|
|
35
|
+
* value here misinforms, but never misgates.
|
|
36
|
+
*/
|
|
37
|
+
export const MANIFEST_MIN_HQ_CLOUD_VERSION = "6.16.23";
|
|
38
|
+
/** One-line explanation shared by every degradation path. */
|
|
39
|
+
export const MANIFEST_UNAVAILABLE_REASON = `manifest status unavailable: hq-cloud too old ` +
|
|
40
|
+
`(requires an hq-cloud release with manifest support ` +
|
|
41
|
+
`(>= ${MANIFEST_MIN_HQ_CLOUD_VERSION}))`;
|
|
42
|
+
/** Thrown by {@link requireManifestExports}. Carries a user-ready message. */
|
|
43
|
+
export class ManifestUnsupportedError extends Error {
|
|
44
|
+
constructor(message = MANIFEST_UNAVAILABLE_REASON) {
|
|
45
|
+
super(message);
|
|
46
|
+
this.name = "ManifestUnsupportedError";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Resolve the manifest exports, or null when the installed hq-cloud predates
|
|
51
|
+
* them.
|
|
52
|
+
*
|
|
53
|
+
* The module object is injectable so the absent-export path is testable
|
|
54
|
+
* without mocking the package (and so the test cannot accidentally pass merely
|
|
55
|
+
* because the local `link:` override happens to be new enough).
|
|
56
|
+
*/
|
|
57
|
+
export function loadManifestExports(mod = hqCloud) {
|
|
58
|
+
const runManifestUploadPass = mod.runManifestUploadPass;
|
|
59
|
+
const readManifestUploadStatus = mod.readManifestUploadStatus;
|
|
60
|
+
const getStateDir = mod.getStateDir;
|
|
61
|
+
if (typeof runManifestUploadPass !== "function" ||
|
|
62
|
+
typeof readManifestUploadStatus !== "function" ||
|
|
63
|
+
typeof getStateDir !== "function") {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
runManifestUploadPass,
|
|
68
|
+
readManifestUploadStatus,
|
|
69
|
+
getStateDir,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** True when the installed hq-cloud can do manifest passes at all. */
|
|
73
|
+
export function manifestExportsAvailable(mod) {
|
|
74
|
+
return loadManifestExports(mod) !== null;
|
|
75
|
+
}
|
|
76
|
+
/** Like {@link loadManifestExports}, but throws instead of returning null. */
|
|
77
|
+
export function requireManifestExports(mod) {
|
|
78
|
+
const exports = loadManifestExports(mod);
|
|
79
|
+
if (!exports)
|
|
80
|
+
throw new ManifestUnsupportedError();
|
|
81
|
+
return exports;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=hq-cloud-manifest.js.map
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://hq.getindigo.ai/schemas/work-mesh-live/session-event.schema.json",
|
|
4
|
+
"title": "Work Mesh Live Session Event",
|
|
5
|
+
"description": "Metadata-only spool / batch-ingest session event (contractVersion 1). Local-only fields are permitted on the spool line and MUST be stripped by the daemon before any network call. There is no free-text intent field and no prompt-derived content.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"v",
|
|
10
|
+
"eventId",
|
|
11
|
+
"kind",
|
|
12
|
+
"sessionId",
|
|
13
|
+
"harness",
|
|
14
|
+
"adapterVersion",
|
|
15
|
+
"at",
|
|
16
|
+
"seq"
|
|
17
|
+
],
|
|
18
|
+
"properties": {
|
|
19
|
+
"v": {
|
|
20
|
+
"type": "integer",
|
|
21
|
+
"const": 1,
|
|
22
|
+
"description": "Schema version. Always 1 for this contract."
|
|
23
|
+
},
|
|
24
|
+
"eventId": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"pattern": "^[0-9A-HJKMNP-TV-Z]{26}$",
|
|
27
|
+
"description": "ULID (Crockford base32, 26 chars). Idempotency key for batch ingest."
|
|
28
|
+
},
|
|
29
|
+
"kind": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"enum": [
|
|
32
|
+
"session_start",
|
|
33
|
+
"turn_start",
|
|
34
|
+
"turn_end",
|
|
35
|
+
"session_end",
|
|
36
|
+
"task_status",
|
|
37
|
+
"blocked",
|
|
38
|
+
"note"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"sessionId": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"minLength": 1,
|
|
44
|
+
"maxLength": 128,
|
|
45
|
+
"description": "Stable runtime session identifier."
|
|
46
|
+
},
|
|
47
|
+
"harness": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"enum": [
|
|
50
|
+
"claude-code",
|
|
51
|
+
"claude-desktop",
|
|
52
|
+
"codex",
|
|
53
|
+
"grok",
|
|
54
|
+
"hq-sessions",
|
|
55
|
+
"agent-box"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
"adapterVersion": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"minLength": 1,
|
|
61
|
+
"maxLength": 64,
|
|
62
|
+
"description": "Hook / adapter package version that emitted the event."
|
|
63
|
+
},
|
|
64
|
+
"runtimeVersion": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"minLength": 1,
|
|
67
|
+
"maxLength": 64,
|
|
68
|
+
"description": "Optional host runtime version (claude, codex, etc.)."
|
|
69
|
+
},
|
|
70
|
+
"source": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"enum": ["hooks", "transcript"],
|
|
73
|
+
"description": "Origin of the event stream: hooks (default) or the transcript-watch fallback (US-018)."
|
|
74
|
+
},
|
|
75
|
+
"at": {
|
|
76
|
+
"type": "string",
|
|
77
|
+
"pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})$",
|
|
78
|
+
"description": "ISO-8601 timestamp when the event occurred."
|
|
79
|
+
},
|
|
80
|
+
"seq": {
|
|
81
|
+
"type": "integer",
|
|
82
|
+
"minimum": 1,
|
|
83
|
+
"description": "Monotonic per-session sequence number, starting at 1."
|
|
84
|
+
},
|
|
85
|
+
"taskId": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"minLength": 1,
|
|
88
|
+
"maxLength": 128,
|
|
89
|
+
"description": "Canonical task identifier. storyId is an ingress alias normalized to taskId by the resolver; it is never a field on this schema."
|
|
90
|
+
},
|
|
91
|
+
"status": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"enum": [
|
|
94
|
+
"queued",
|
|
95
|
+
"in_progress",
|
|
96
|
+
"review",
|
|
97
|
+
"done"
|
|
98
|
+
],
|
|
99
|
+
"description": "Task status; used with kind=task_status."
|
|
100
|
+
},
|
|
101
|
+
"reason": {
|
|
102
|
+
"type": "string",
|
|
103
|
+
"minLength": 1,
|
|
104
|
+
"maxLength": 500,
|
|
105
|
+
"description": "Blocked reason or similar short machine-safe note. Never prompt text."
|
|
106
|
+
},
|
|
107
|
+
"summary": {
|
|
108
|
+
"type": "string",
|
|
109
|
+
"minLength": 1,
|
|
110
|
+
"maxLength": 280,
|
|
111
|
+
"description": "Optional short summary allowed only on note, blocked, and task_status. Never prompt-derived content."
|
|
112
|
+
},
|
|
113
|
+
"cwd": {
|
|
114
|
+
"type": "string",
|
|
115
|
+
"maxLength": 1024,
|
|
116
|
+
"description": "LOCAL-ONLY. Working directory at emit time. Stripped by the daemon before any network call."
|
|
117
|
+
},
|
|
118
|
+
"hqRoot": {
|
|
119
|
+
"type": "string",
|
|
120
|
+
"maxLength": 1024,
|
|
121
|
+
"description": "LOCAL-ONLY. Absolute path to the HQ tree root. Stripped before network."
|
|
122
|
+
},
|
|
123
|
+
"companySlug": {
|
|
124
|
+
"type": "string",
|
|
125
|
+
"maxLength": 128,
|
|
126
|
+
"description": "LOCAL-ONLY. Hint slug from local context. Never used as tenant authority. Stripped before network."
|
|
127
|
+
},
|
|
128
|
+
"project": {
|
|
129
|
+
"type": "string",
|
|
130
|
+
"maxLength": 256,
|
|
131
|
+
"description": "LOCAL-ONLY. Local project name/path hint. Stripped before network."
|
|
132
|
+
},
|
|
133
|
+
"task": {
|
|
134
|
+
"type": "string",
|
|
135
|
+
"maxLength": 256,
|
|
136
|
+
"description": "LOCAL-ONLY. Local task label hint. Stripped before network. Distinct from canonical taskId."
|
|
137
|
+
},
|
|
138
|
+
"toolWrites": {
|
|
139
|
+
"type": "integer",
|
|
140
|
+
"minimum": 0,
|
|
141
|
+
"description": "LOCAL-ONLY. Count of tool file writes observed this session. Stripped before network."
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|