@indigoai-us/hq-cli 5.345.263 → 5.345.267
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 +116 -0
- package/assets/scaffold/core/scripts/hq-delegate-grant.sh +4 -48
- package/assets/scaffold/core/scripts/hq-delegate-secrets.sh +16 -10
- package/assets/scaffold/core/scripts/hq-delegate-send.sh +17 -1
- package/contracts/host-canary-release.json +7 -7
- package/dist/command-catalog.generated.d.ts +67 -1
- package/dist/command-catalog.generated.js +83 -1
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/bot.d.ts +2 -0
- package/dist/commands/bot.js +4 -3
- package/dist/commands/core-delegate-w1b.js +21 -40
- package/dist/commands/core-delegate.js +11 -8
- package/dist/commands/files-browse.d.ts +83 -4
- package/dist/commands/files-browse.js +404 -54
- package/dist/commands/groups.js +2 -2
- package/dist/commands/skill.js +15 -0
- package/dist/commands/sync-held.d.ts +11 -0
- package/dist/commands/sync-held.js +65 -1
- package/dist/commands/sync-telemetry-report.d.ts +5 -0
- package/dist/commands/sync-telemetry-report.js +239 -0
- package/dist/commands/sync-telemetry.d.ts +47 -0
- package/dist/commands/sync-telemetry.js +309 -0
- package/dist/index.js +107 -43
- package/dist/lib/agent-kit/mcp/tools.js +2 -2
- package/dist/lib/agent-kit/skills.js +12 -6
- package/dist/lib/bot/runnable.d.ts +17 -7
- package/dist/lib/bot/runnable.js +17 -10
- package/dist/lib/capacity/available.js +6 -2
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +10 -256
- package/dist/lib/capacity/collectors/claude-oauth.js +19 -1078
- package/dist/lib/capacity/ledger.d.ts +12 -1
- package/dist/lib/capacity/ledger.js +15 -5
- package/dist/lib/capacity/route.d.ts +2 -0
- package/dist/lib/capacity/route.js +21 -4
- package/dist/lib/capacity/scheduler.js +2 -3
- package/dist/lib/capacity/sign-in.js +4 -4
- package/dist/lib/daemon/merge-sections.d.ts +44 -9
- package/dist/lib/daemon/merge-sections.js +234 -37
- package/dist/lib/daemon/ops/skill-command.d.ts +2 -0
- package/dist/lib/daemon/ops/skill-command.js +7 -1
- package/dist/lib/daemon/run.js +1 -0
- package/dist/lib/doctor/checks/antigravity-wiring.d.ts +2 -1
- package/dist/lib/doctor/checks/antigravity-wiring.js +75 -3
- package/dist/lib/doctor/checks/hook-engine.d.ts +2 -0
- package/dist/lib/doctor/checks/hook-engine.js +100 -1
- package/dist/lib/doctor/checks/host-core.d.ts +1 -1
- package/dist/lib/doctor/checks/host-core.js +19 -7
- package/dist/lib/doctor/fix/process-identity.d.ts +2 -0
- package/dist/lib/doctor/fix/process-identity.js +5 -2
- package/dist/lib/hook-engine/coverage.d.ts +19 -10
- package/dist/lib/hook-engine/coverage.js +116 -25
- package/dist/lib/hook-engine/native-precompact-compatibility.json +8 -1
- package/dist/lib/hook-engine/native-stop-compatibility.json +8 -4
- package/dist/lib/hook-engine/reconcile.js +60 -2
- package/dist/lib/install/antigravity-targets.d.ts +22 -0
- package/dist/lib/install/antigravity-targets.js +82 -0
- package/dist/lib/signals/reply.js +25 -5
- package/dist/lib/signals/steps/extract.d.ts +28 -4
- package/dist/lib/signals/steps/extract.js +124 -10
- package/dist/lib/sync-core/release.d.ts +1 -1
- package/dist/lib/sync-core/release.js +2 -2
- package/dist/main.js +8 -3
- package/dist/sentry-init.d.ts +7 -1
- package/dist/sentry-init.js +6 -2
- package/dist/sentry.d.ts +7 -0
- package/dist/sentry.js +16 -1
- package/dist/started-version.d.ts +13 -0
- package/dist/started-version.js +34 -0
- package/dist/startup-registration.d.ts +9 -9
- package/dist/startup-registration.js +42 -18
- package/dist/utils/client-health.d.ts +1 -0
- package/dist/utils/client-health.js +54 -11
- package/dist/utils/core-next-kill.d.ts +9 -0
- package/dist/utils/core-next-kill.js +22 -0
- package/dist/utils/host-registration.d.ts +4 -2
- package/dist/utils/host-registration.js +55 -7
- package/dist/utils/install-tree-recovery-markers.d.ts +45 -0
- package/dist/utils/install-tree-recovery-markers.js +70 -0
- package/dist/utils/install-tree-torn.d.ts +102 -5
- package/dist/utils/install-tree-torn.js +199 -2
- package/dist/utils/sentry-fingerprint.js +3 -0
- package/package.json +7 -7
|
@@ -29,12 +29,16 @@ export function fenceExports(mod = hqCloud) {
|
|
|
29
29
|
const corrupt = mod.corruptPushIdentityHold;
|
|
30
30
|
const recover = mod.recoverCorruptPushIdentity;
|
|
31
31
|
const readOwner = mod.readPersonalVaultOwnerUid;
|
|
32
|
+
const noOriginMarker = mod.noOriginIdentityMarker;
|
|
33
|
+
const confirmUnproven = mod.confirmUnprovenIdentityHold;
|
|
32
34
|
return {
|
|
33
35
|
listPushIdentityFences: list,
|
|
34
36
|
releasePushIdentityFences: release,
|
|
35
37
|
...(typeof corrupt === "function" ? { corruptPushIdentityHold: corrupt } : {}),
|
|
36
38
|
...(typeof recover === "function" ? { recoverCorruptPushIdentity: recover } : {}),
|
|
37
39
|
...(typeof readOwner === "function" ? { readPersonalVaultOwnerUid: readOwner } : {}),
|
|
40
|
+
...(typeof noOriginMarker === "function" ? { noOriginIdentityMarker: noOriginMarker } : {}),
|
|
41
|
+
...(typeof confirmUnproven === "function" ? { confirmUnprovenIdentityHold: confirmUnproven } : {}),
|
|
38
42
|
};
|
|
39
43
|
}
|
|
40
44
|
export function scopeLabel(slug) {
|
|
@@ -116,11 +120,14 @@ export async function runReleaseHeld(deps, options) {
|
|
|
116
120
|
if (options.company)
|
|
117
121
|
scopes = scopes.filter((scope) => scope.slug === options.company);
|
|
118
122
|
const corrupt = corruptHoldRequested(deps, options);
|
|
123
|
+
const unprovenHold = unprovenHoldRequested(deps, options);
|
|
119
124
|
if (scopes.length === 0 && !corrupt) {
|
|
125
|
+
if (unprovenHold)
|
|
126
|
+
return clearUnprovenHoldOnly(deps, options, unprovenHold);
|
|
120
127
|
deps.log(options.json ? JSON.stringify({ released: [] }) : "No held uploads match.");
|
|
121
128
|
return 0;
|
|
122
129
|
}
|
|
123
|
-
const needPersonal = corrupt || scopes.some((scope) => scope.slug === PERSONAL_VAULT_JOURNAL_SLUG || scope.slug === "personal");
|
|
130
|
+
const needPersonal = corrupt || unprovenHold !== undefined || scopes.some((scope) => scope.slug === PERSONAL_VAULT_JOURNAL_SLUG || scope.slug === "personal");
|
|
124
131
|
const snapshot = await deps.identity({ needPersonal, interactive: true });
|
|
125
132
|
const identities = [snapshot.sub, ...(snapshot.personalUid ? [snapshot.personalUid] : [])];
|
|
126
133
|
const mine = scopes.filter((scope) => identities.includes(scope.uid));
|
|
@@ -197,6 +204,12 @@ export async function runReleaseHeld(deps, options) {
|
|
|
197
204
|
: corruptRefusal(recovery.reason, released.length > 0));
|
|
198
205
|
return 1;
|
|
199
206
|
}
|
|
207
|
+
const clearedHold = unprovenHold && !withheldListed
|
|
208
|
+
? deps.exports.confirmUnprovenIdentityHold?.({
|
|
209
|
+
sub: current.sub,
|
|
210
|
+
...(current.personalUid ? { personalUid: current.personalUid } : {}),
|
|
211
|
+
})
|
|
212
|
+
: undefined;
|
|
200
213
|
const restored = recovery?.recovered === true;
|
|
201
214
|
const heldScopeFiles = recovery?.heldScopeFiles ?? 0;
|
|
202
215
|
const stayHeld = heldScopeFiles > 0 || recovery?.uploadsStayHeld === true || withheldListed;
|
|
@@ -208,6 +221,7 @@ export async function runReleaseHeld(deps, options) {
|
|
|
208
221
|
...(reportCorrupt ? { identityRestored: restored } : {}),
|
|
209
222
|
...(recovery?.uploadsStayHeld === true || withheldListed ? { uploadsStayHeld: true } : {}),
|
|
210
223
|
...(needsSync ? { needsSync, ...(released.length === 0 && !withheldListed ? { reason: "no-file-list" } : {}) } : {}),
|
|
224
|
+
...(clearedHold ? unprovenHoldJson(clearedHold, unprovenHold) : {}),
|
|
211
225
|
}));
|
|
212
226
|
}
|
|
213
227
|
else if (restored && stayHeld && released.length === 0) {
|
|
@@ -233,8 +247,58 @@ export async function runReleaseHeld(deps, options) {
|
|
|
233
247
|
else {
|
|
234
248
|
deps.log(`Released ${released.map(scopeLabel).join(", ")}. The next sync uploads these files.`);
|
|
235
249
|
}
|
|
250
|
+
if (!options.json && clearedHold && unprovenHold)
|
|
251
|
+
deps.log(unprovenHoldLine(clearedHold, unprovenHold));
|
|
236
252
|
return 0;
|
|
237
253
|
}
|
|
254
|
+
function unprovenHoldRequested(deps, options) {
|
|
255
|
+
if (options.company || options.personal || options.confirmUnproven)
|
|
256
|
+
return undefined;
|
|
257
|
+
if (!deps.exports?.confirmUnprovenIdentityHold)
|
|
258
|
+
return undefined;
|
|
259
|
+
return deps.exports.noOriginIdentityMarker?.(deps.stateDir);
|
|
260
|
+
}
|
|
261
|
+
function holdDay(sinceMs) {
|
|
262
|
+
return new Date(sinceMs).toISOString().slice(0, 10);
|
|
263
|
+
}
|
|
264
|
+
function unprovenHoldJson(result, marker) {
|
|
265
|
+
const sinceMs = result.sinceMs ?? marker?.sinceMs;
|
|
266
|
+
return {
|
|
267
|
+
clearedIdentityHold: result.cleared,
|
|
268
|
+
...(sinceMs !== undefined ? { identityHoldSince: new Date(sinceMs).toISOString() } : {}),
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
function unprovenHoldLine(result, marker) {
|
|
272
|
+
const day = holdDay(result.sinceMs ?? marker.sinceMs);
|
|
273
|
+
return result.cleared
|
|
274
|
+
? `Cleared the upload hold recorded on ${day}. The identity history on this computer could not be proven then. The sign-in records, the personal vault owner and every sync scope on this computer now name the signed-in account, so new companies sync without a hold.`
|
|
275
|
+
: `The upload hold recorded on ${day} stays, so new companies are still held. It clears when every held upload on this computer is released and the sign-in records, the personal vault owner and every sync scope name the signed-in account.`;
|
|
276
|
+
}
|
|
277
|
+
async function clearUnprovenHoldOnly(deps, options, marker) {
|
|
278
|
+
const snapshot = await deps.identity({ needPersonal: true, interactive: true });
|
|
279
|
+
if (!options.yes) {
|
|
280
|
+
const ok = await deps.confirm(`No uploads are waiting. This computer has an upload hold recorded on ${holdDay(marker.sinceMs)} because its identity history could not be proven. Clear it for the signed-in account? [y/N] `);
|
|
281
|
+
if (!ok) {
|
|
282
|
+
deps.log(options.json ? JSON.stringify({ released: [] }) : "Nothing released.");
|
|
283
|
+
return 1;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
const current = await deps.identity({ needPersonal: true, interactive: false });
|
|
287
|
+
if (current.sub !== snapshot.sub || current.personalUid !== snapshot.personalUid) {
|
|
288
|
+
deps.log(options.json
|
|
289
|
+
? JSON.stringify({ released: [], reason: "identity-changed" })
|
|
290
|
+
: "The signed-in account changed while releasing. Nothing was released; run the command again.");
|
|
291
|
+
return 1;
|
|
292
|
+
}
|
|
293
|
+
const result = deps.exports?.confirmUnprovenIdentityHold?.({
|
|
294
|
+
sub: current.sub,
|
|
295
|
+
...(current.personalUid ? { personalUid: current.personalUid } : {}),
|
|
296
|
+
}) ?? { cleared: false };
|
|
297
|
+
deps.log(options.json
|
|
298
|
+
? JSON.stringify({ released: [], ...unprovenHoldJson(result, marker) })
|
|
299
|
+
: unprovenHoldLine(result, marker));
|
|
300
|
+
return result.cleared ? 0 : 1;
|
|
301
|
+
}
|
|
238
302
|
function corruptHoldRequested(deps, options) {
|
|
239
303
|
const probe = deps.exports?.corruptPushIdentityHold;
|
|
240
304
|
if (!probe || !deps.exports?.recoverCorruptPushIdentity)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const SUPPORTED_SCHEMA_VERSION = 1;
|
|
2
|
+
export declare const TELEMETRY_VIEWS: readonly ["summary", "machines", "errors", "people", "folders", "loops", "ranking"];
|
|
3
|
+
export type TelemetryView = (typeof TELEMETRY_VIEWS)[number];
|
|
4
|
+
export declare function renderTelemetryReport(body: unknown, view: TelemetryView): string[];
|
|
5
|
+
//# sourceMappingURL=sync-telemetry-report.d.ts.map
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
export const SUPPORTED_SCHEMA_VERSION = 1;
|
|
2
|
+
export const TELEMETRY_VIEWS = [
|
|
3
|
+
"summary",
|
|
4
|
+
"machines",
|
|
5
|
+
"errors",
|
|
6
|
+
"people",
|
|
7
|
+
"folders",
|
|
8
|
+
"loops",
|
|
9
|
+
"ranking",
|
|
10
|
+
];
|
|
11
|
+
const VIEW_TITLES = {
|
|
12
|
+
summary: "Sync health summary",
|
|
13
|
+
machines: "Sync by machine",
|
|
14
|
+
errors: "Recent sync errors",
|
|
15
|
+
people: "Sync use by person",
|
|
16
|
+
folders: "Uploads and downloads by folder",
|
|
17
|
+
loops: "Paths rewritten in a loop",
|
|
18
|
+
ranking: "Companies ranked by sync use",
|
|
19
|
+
};
|
|
20
|
+
const NOT_RECORDED_YET = "not_recorded_yet";
|
|
21
|
+
const NO_DATA = "no data";
|
|
22
|
+
const MAX_DEPTH = 6;
|
|
23
|
+
const FAILING_STATUSES = new Set(["failing", "failed", "error", "stalled", "unhealthy"]);
|
|
24
|
+
const HEALTHY_STATUSES = new Set(["ok", "healthy"]);
|
|
25
|
+
const NO_DATA_SINCE_KEYS = ["noDataSince", "no_data_since", "asOf", "lastSeenAt"];
|
|
26
|
+
const MACHINE_NAME_KEYS = ["hostname", "label", "name"];
|
|
27
|
+
const VALUE_WRAPPER_KEYS = new Set(["value", "reason", "asOf", "unit"]);
|
|
28
|
+
function isRecord(value) {
|
|
29
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
30
|
+
}
|
|
31
|
+
function clean(text) {
|
|
32
|
+
let result = "";
|
|
33
|
+
for (const char of text) {
|
|
34
|
+
const code = char.codePointAt(0) ?? 0;
|
|
35
|
+
result += code <= 0x1f || (code >= 0x7f && code <= 0x9f) ? " " : char;
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
function label(key) {
|
|
40
|
+
return clean(key)
|
|
41
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
42
|
+
.replace(/[_-]+/g, " ")
|
|
43
|
+
.toLowerCase();
|
|
44
|
+
}
|
|
45
|
+
function capitalize(text) {
|
|
46
|
+
return text.length === 0 ? text : text[0].toUpperCase() + text.slice(1);
|
|
47
|
+
}
|
|
48
|
+
function isScalar(value) {
|
|
49
|
+
return value === null || value === undefined || typeof value !== "object";
|
|
50
|
+
}
|
|
51
|
+
function scalarText(value) {
|
|
52
|
+
if (value === null || value === undefined)
|
|
53
|
+
return NO_DATA;
|
|
54
|
+
if (typeof value === "boolean")
|
|
55
|
+
return value ? "yes" : "no";
|
|
56
|
+
if (typeof value === "string")
|
|
57
|
+
return value.length === 0 ? NO_DATA : clean(value);
|
|
58
|
+
return clean(String(value));
|
|
59
|
+
}
|
|
60
|
+
function isValueWrapper(value) {
|
|
61
|
+
if (!isRecord(value) || !("value" in value) || !isScalar(value.value))
|
|
62
|
+
return false;
|
|
63
|
+
return Object.keys(value).every((key) => VALUE_WRAPPER_KEYS.has(key));
|
|
64
|
+
}
|
|
65
|
+
function valueWrapperText(wrapper) {
|
|
66
|
+
if (wrapper.value === null || wrapper.value === undefined) {
|
|
67
|
+
return typeof wrapper.reason === "string" && wrapper.reason.length > 0
|
|
68
|
+
? `${NO_DATA} (${clean(wrapper.reason)})`
|
|
69
|
+
: NO_DATA;
|
|
70
|
+
}
|
|
71
|
+
const unit = typeof wrapper.unit === "string" ? ` ${clean(wrapper.unit)}` : "";
|
|
72
|
+
return `${scalarText(wrapper.value)}${unit}`;
|
|
73
|
+
}
|
|
74
|
+
function inlineText(value) {
|
|
75
|
+
if (isScalar(value))
|
|
76
|
+
return scalarText(value);
|
|
77
|
+
if (isValueWrapper(value))
|
|
78
|
+
return valueWrapperText(value);
|
|
79
|
+
if (Array.isArray(value)) {
|
|
80
|
+
if (value.length === 0)
|
|
81
|
+
return "none";
|
|
82
|
+
if (value.every(isScalar))
|
|
83
|
+
return value.map(scalarText).join(", ");
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
function isMachine(value) {
|
|
88
|
+
return isRecord(value) && typeof value.installId === "string" && typeof value.status === "string";
|
|
89
|
+
}
|
|
90
|
+
function machineRank(machine) {
|
|
91
|
+
const status = typeof machine.status === "string" ? machine.status.toLowerCase() : "";
|
|
92
|
+
if (FAILING_STATUSES.has(status) || machine.lastCycleSuccess === false)
|
|
93
|
+
return 0;
|
|
94
|
+
if (HEALTHY_STATUSES.has(status))
|
|
95
|
+
return 2;
|
|
96
|
+
return 1;
|
|
97
|
+
}
|
|
98
|
+
function failingFirst(items) {
|
|
99
|
+
if (!items.some(isMachine))
|
|
100
|
+
return [...items];
|
|
101
|
+
return items
|
|
102
|
+
.map((item, index) => ({ item, index, rank: isMachine(item) ? machineRank(item) : 1 }))
|
|
103
|
+
.sort((a, b) => a.rank - b.rank || a.index - b.index)
|
|
104
|
+
.map((entry) => entry.item);
|
|
105
|
+
}
|
|
106
|
+
function machineName(machine) {
|
|
107
|
+
const id = clean(String(machine.installId));
|
|
108
|
+
for (const key of MACHINE_NAME_KEYS) {
|
|
109
|
+
const name = machine[key];
|
|
110
|
+
if (typeof name === "string" && name.length > 0)
|
|
111
|
+
return `${id} (${clean(name)})`;
|
|
112
|
+
}
|
|
113
|
+
return id;
|
|
114
|
+
}
|
|
115
|
+
function truncatedLine(indent) {
|
|
116
|
+
return `${indent}List cut short by the server (truncated). Narrow it with --machine or a shorter --window.`;
|
|
117
|
+
}
|
|
118
|
+
function renderItem(item, indent, depth) {
|
|
119
|
+
if (!isRecord(item)) {
|
|
120
|
+
const inline = inlineText(item);
|
|
121
|
+
return inline !== null ? [`${indent}- ${inline}`] : [`${indent}-`, ...renderValue(item, `${indent} `, depth + 1)];
|
|
122
|
+
}
|
|
123
|
+
const skipped = new Set(["truncated"]);
|
|
124
|
+
let head = null;
|
|
125
|
+
if (isMachine(item)) {
|
|
126
|
+
skipped.add("installId");
|
|
127
|
+
for (const key of MACHINE_NAME_KEYS)
|
|
128
|
+
skipped.add(key);
|
|
129
|
+
skipped.add("status");
|
|
130
|
+
if (item.status === "no_data") {
|
|
131
|
+
const since = NO_DATA_SINCE_KEYS.map((key) => item[key]).find((value) => typeof value === "string" && value.length > 0);
|
|
132
|
+
return [`${indent}- ${machineName(item)}: no data since ${since ? clean(String(since)) : "an unknown time"}`];
|
|
133
|
+
}
|
|
134
|
+
const status = typeof item.status === "string" && item.status.length > 0 ? clean(item.status) : "status not reported";
|
|
135
|
+
head = `${machineName(item)}: ${status}`;
|
|
136
|
+
}
|
|
137
|
+
const inlineParts = [];
|
|
138
|
+
const nested = [];
|
|
139
|
+
for (const [key, value] of Object.entries(item)) {
|
|
140
|
+
if (skipped.has(key))
|
|
141
|
+
continue;
|
|
142
|
+
const inline = inlineText(value);
|
|
143
|
+
if (inline !== null) {
|
|
144
|
+
inlineParts.push(`${label(key)} ${inline}`);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
nested.push(`${indent} ${label(key)}:`, ...renderValue(value, `${indent} `, depth + 1));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const first = [head, inlineParts.join(", ")].filter((part) => part !== null && part.length > 0).join(", ");
|
|
151
|
+
const lines = [`${indent}- ${first.length > 0 ? first : "(no fields)"}`, ...nested];
|
|
152
|
+
if (item.truncated === true)
|
|
153
|
+
lines.push(truncatedLine(`${indent} `));
|
|
154
|
+
return lines;
|
|
155
|
+
}
|
|
156
|
+
function renderValue(value, indent, depth) {
|
|
157
|
+
if (depth > MAX_DEPTH)
|
|
158
|
+
return [`${indent}(more detail than this report shows; use --json)`];
|
|
159
|
+
const inline = inlineText(value);
|
|
160
|
+
if (inline !== null)
|
|
161
|
+
return [`${indent}${inline}`];
|
|
162
|
+
if (Array.isArray(value)) {
|
|
163
|
+
return failingFirst(value).flatMap((item) => renderItem(item, indent, depth));
|
|
164
|
+
}
|
|
165
|
+
const record = value;
|
|
166
|
+
const lines = [];
|
|
167
|
+
for (const [key, entry] of Object.entries(record)) {
|
|
168
|
+
if (key === "truncated")
|
|
169
|
+
continue;
|
|
170
|
+
const entryInline = inlineText(entry);
|
|
171
|
+
if (entryInline !== null) {
|
|
172
|
+
lines.push(`${indent}${label(key)}: ${entryInline}`);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
lines.push(`${indent}${label(key)}:`, ...renderValue(entry, `${indent} `, depth + 1));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (lines.length === 0)
|
|
179
|
+
lines.push(`${indent}${NO_DATA}`);
|
|
180
|
+
if (record.truncated === true)
|
|
181
|
+
lines.push(truncatedLine(indent));
|
|
182
|
+
return lines;
|
|
183
|
+
}
|
|
184
|
+
function renderSection(name, section) {
|
|
185
|
+
const title = capitalize(label(name));
|
|
186
|
+
if (!isRecord(section))
|
|
187
|
+
return [`${title}: ${NO_DATA}`];
|
|
188
|
+
if (section.available === false) {
|
|
189
|
+
const reason = typeof section.reason === "string" ? section.reason : "";
|
|
190
|
+
if (reason.length === 0 || reason === NOT_RECORDED_YET)
|
|
191
|
+
return [`${title}: not recorded yet`];
|
|
192
|
+
return [`${title}: not available (${clean(reason)})`];
|
|
193
|
+
}
|
|
194
|
+
const asOf = typeof section.asOf === "string" && section.asOf.length > 0 ? ` (as of ${clean(section.asOf)})` : "";
|
|
195
|
+
const lines = [];
|
|
196
|
+
const inline = inlineText(section.data);
|
|
197
|
+
if (inline !== null) {
|
|
198
|
+
lines.push(`${title}${asOf}: ${inline}`);
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
lines.push(`${title}${asOf}:`, ...renderValue(section.data, " ", 1));
|
|
202
|
+
}
|
|
203
|
+
if (section.truncated === true)
|
|
204
|
+
lines.push(truncatedLine(" "));
|
|
205
|
+
return lines;
|
|
206
|
+
}
|
|
207
|
+
export function renderTelemetryReport(body, view) {
|
|
208
|
+
const lines = [VIEW_TITLES[view]];
|
|
209
|
+
if (!isRecord(body)) {
|
|
210
|
+
lines.push("The server sent no report for this view.");
|
|
211
|
+
return lines;
|
|
212
|
+
}
|
|
213
|
+
const facts = [];
|
|
214
|
+
if (typeof body.companyUid === "string" && body.companyUid.length > 0)
|
|
215
|
+
facts.push(`company ${clean(body.companyUid)}`);
|
|
216
|
+
if (typeof body.window === "string" && body.window.length > 0)
|
|
217
|
+
facts.push(`window ${clean(body.window)}`);
|
|
218
|
+
if (typeof body.scope === "string" && body.scope.length > 0)
|
|
219
|
+
facts.push(`scope ${clean(body.scope)}`);
|
|
220
|
+
if (typeof body.generatedAt === "string" && body.generatedAt.length > 0) {
|
|
221
|
+
facts.push(`generated ${clean(body.generatedAt)}`);
|
|
222
|
+
}
|
|
223
|
+
if (facts.length > 0)
|
|
224
|
+
lines.push(capitalize(facts.join(", ")));
|
|
225
|
+
if (typeof body.schemaVersion === "number" && body.schemaVersion > SUPPORTED_SCHEMA_VERSION) {
|
|
226
|
+
lines.push(`This HQ CLI is older than the server (response schema ${body.schemaVersion}, this CLI reads ${SUPPORTED_SCHEMA_VERSION}). It shows the fields it understands; update HQ to see the rest.`);
|
|
227
|
+
}
|
|
228
|
+
lines.push("");
|
|
229
|
+
const sections = isRecord(body.sections) ? Object.entries(body.sections) : [];
|
|
230
|
+
if (sections.length === 0) {
|
|
231
|
+
lines.push("The server sent no sections for this view.");
|
|
232
|
+
}
|
|
233
|
+
for (const [name, section] of sections)
|
|
234
|
+
lines.push(...renderSection(name, section));
|
|
235
|
+
if (body.truncated === true)
|
|
236
|
+
lines.push(truncatedLine(""));
|
|
237
|
+
return lines;
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=sync-telemetry-report.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { type VaultApiOptions } from "../utils/vault-api.js";
|
|
3
|
+
export declare const TELEMETRY_WINDOWS: readonly ["1h", "24h", "7d", "30d"];
|
|
4
|
+
export type TelemetryWindow = (typeof TELEMETRY_WINDOWS)[number];
|
|
5
|
+
export declare const SYNC_TELEMETRY_PATH = "/v1/sync-telemetry";
|
|
6
|
+
export declare const SYNC_TELEMETRY_COMMAND = "hq sync telemetry";
|
|
7
|
+
export declare const SYNC_TELEMETRY_TIMEOUT_MS = 20000;
|
|
8
|
+
export declare const SYNC_TELEMETRY_MAX_RETRIES = 2;
|
|
9
|
+
export declare const SYNC_TELEMETRY_BACKOFF_MS: readonly [500, 1500];
|
|
10
|
+
export declare const SYNC_TELEMETRY_EXIT: {
|
|
11
|
+
readonly ok: 0;
|
|
12
|
+
readonly badArguments: 2;
|
|
13
|
+
readonly notSignedIn: 3;
|
|
14
|
+
readonly refused: 4;
|
|
15
|
+
readonly rateLimited: 5;
|
|
16
|
+
readonly unavailable: 6;
|
|
17
|
+
};
|
|
18
|
+
export interface SyncTelemetryOptions {
|
|
19
|
+
company?: string;
|
|
20
|
+
view?: string;
|
|
21
|
+
window?: string;
|
|
22
|
+
machine?: string;
|
|
23
|
+
json?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface SyncTelemetryFailure {
|
|
26
|
+
ok: false;
|
|
27
|
+
code: string;
|
|
28
|
+
message: string;
|
|
29
|
+
status: number | null;
|
|
30
|
+
}
|
|
31
|
+
export interface SyncTelemetryDeps {
|
|
32
|
+
token: () => Promise<string>;
|
|
33
|
+
activeCompany: () => string | undefined;
|
|
34
|
+
companyUid: (token: string, company: string | undefined) => Promise<string>;
|
|
35
|
+
request: (options: VaultApiOptions) => Promise<Response>;
|
|
36
|
+
sleep: (ms: number) => Promise<void>;
|
|
37
|
+
timeoutMs: number;
|
|
38
|
+
out: (text: string) => void;
|
|
39
|
+
err: (text: string) => void;
|
|
40
|
+
}
|
|
41
|
+
export declare class PersonLoginRequiredError extends Error {
|
|
42
|
+
constructor();
|
|
43
|
+
}
|
|
44
|
+
export declare function runSyncTelemetry(options: SyncTelemetryOptions, deps: SyncTelemetryDeps): Promise<number>;
|
|
45
|
+
export declare function createDefaultSyncTelemetryDeps(): SyncTelemetryDeps;
|
|
46
|
+
export declare function registerSyncTelemetryCommand(syncCmd: Command): void;
|
|
47
|
+
//# sourceMappingURL=sync-telemetry.d.ts.map
|