@indigoai-us/hq-cli 5.345.220 → 5.345.221
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 +118 -0
- package/dist/command-catalog.generated.d.ts +144 -2
- package/dist/command-catalog.generated.js +175 -2
- package/dist/commands/auth.js +4 -1
- package/dist/commands/bot-runtime.d.ts +18 -5
- package/dist/commands/bot-runtime.js +29 -12
- package/dist/commands/bot.d.ts +39 -2
- package/dist/commands/bot.js +140 -11
- package/dist/commands/core-stop-autosave.d.ts +21 -0
- package/dist/commands/core-stop-autosave.js +300 -0
- package/dist/commands/core.js +2 -0
- package/dist/commands/daemon.d.ts +5 -0
- package/dist/commands/daemon.js +31 -7
- package/dist/commands/doctor-usage.d.ts +5 -0
- package/dist/commands/doctor-usage.js +25 -0
- package/dist/commands/env.d.ts +49 -4
- package/dist/commands/env.js +355 -5
- package/dist/commands/lanes-shared.d.ts +3 -0
- package/dist/commands/lanes.d.ts +3 -0
- package/dist/commands/lanes.js +87 -3
- package/dist/commands/sources.js +3 -3
- package/dist/commands/sync-core.d.ts +1 -0
- package/dist/commands/sync-core.js +77 -3
- package/dist/commands/whoami.js +96 -80
- package/dist/lib/bot/config.d.ts +17 -0
- package/dist/lib/bot/config.js +13 -0
- package/dist/lib/bot/fleet-cron.js +24 -2
- package/dist/lib/bot/fleet-local.d.ts +30 -2
- package/dist/lib/bot/fleet-local.js +60 -1
- package/dist/lib/bot/grok-login-scope.d.ts +36 -0
- package/dist/lib/bot/grok-login-scope.js +93 -0
- package/dist/lib/bot/legacy-provider-login.d.ts +32 -9
- package/dist/lib/bot/legacy-provider-login.js +28 -22
- package/dist/lib/bot/runtime-sign-in-check.js +6 -1
- package/dist/lib/bot/runtime-sign-in.d.ts +2 -0
- package/dist/lib/core-utils/sentry-report.js +2 -0
- package/dist/lib/daemon/machine-checks.d.ts +22 -1
- package/dist/lib/daemon/machine-checks.js +54 -12
- package/dist/lib/daemon/run.js +66 -8
- package/dist/lib/daemon/stop-autosave-lock.d.ts +19 -0
- package/dist/lib/daemon/stop-autosave-lock.js +166 -0
- package/dist/lib/daemon/stop-autosave.d.ts +28 -0
- package/dist/lib/daemon/stop-autosave.js +111 -0
- package/dist/lib/daemon/stop-diagnostics.d.ts +11 -0
- package/dist/lib/daemon/stop-diagnostics.js +136 -0
- package/dist/lib/daemon/stop-job-executor.d.ts +19 -0
- package/dist/lib/daemon/stop-job-executor.js +126 -0
- package/dist/lib/daemon/stop-jobs.d.ts +93 -0
- package/dist/lib/daemon/stop-jobs.js +599 -0
- package/dist/lib/doctor/checks/fleet-hook-core.js +1 -1
- package/dist/lib/doctor/checks/host-core.js +1 -1
- package/dist/lib/environment/access-probes.d.ts +234 -0
- package/dist/lib/environment/access-probes.js +918 -0
- package/dist/lib/environment/profile.d.ts +15 -2
- package/dist/lib/environment/profile.js +55 -20
- package/dist/lib/environment/rfc3339.d.ts +8 -0
- package/dist/lib/environment/rfc3339.js +26 -0
- package/dist/lib/environment/work-requirements.d.ts +169 -0
- package/dist/lib/environment/work-requirements.js +389 -0
- package/dist/lib/hook-engine/coverage.d.ts +137 -7
- package/dist/lib/hook-engine/coverage.js +1424 -4
- package/dist/lib/hook-engine/fleet-registration.js +2 -2
- package/dist/lib/hook-engine/git-stop-config.json +513 -0
- package/dist/lib/hook-engine/native-stop-compatibility.json +311 -0
- package/dist/lib/hook-engine/reconcile.js +2 -2
- package/dist/lib/hot-channels/alert.d.ts +2 -2
- package/dist/lib/hot-channels/alert.js +8 -5
- package/dist/lib/hot-channels/signals-pass.d.ts +126 -17
- package/dist/lib/hot-channels/signals-pass.js +296 -17
- package/dist/lib/hot-channels/signals-runtime.d.ts +30 -0
- package/dist/lib/hot-channels/signals-runtime.js +82 -0
- package/dist/lib/install/hook-target.js +1 -1
- package/dist/lib/lanes/host-capacity.d.ts +26 -2
- package/dist/lib/lanes/host-capacity.js +17 -2
- package/dist/lib/lanes/host-compute.d.ts +90 -0
- package/dist/lib/lanes/host-compute.js +185 -0
- package/dist/lib/lanes/index.d.ts +2 -0
- package/dist/lib/lanes/index.js +1 -0
- package/dist/lib/lanes/reconcile.js +22 -1
- package/dist/lib/lanes/resource-usage.d.ts +155 -0
- package/dist/lib/lanes/resource-usage.js +589 -0
- package/dist/lib/lanes/run-size.d.ts +46 -0
- package/dist/lib/lanes/run-size.js +197 -0
- package/dist/lib/lanes/store.js +27 -0
- package/dist/lib/lanes/throttle.d.ts +36 -1
- package/dist/lib/lanes/throttle.js +47 -10
- package/dist/lib/lanes/types.d.ts +40 -0
- package/dist/lib/lanes/types.js +2 -2
- package/dist/lib/lanes/watcher.js +13 -4
- package/dist/lib/lanes/worker-process.d.ts +25 -2
- package/dist/lib/lanes/worker-process.js +71 -19
- package/dist/lib/placement/match.d.ts +192 -0
- package/dist/lib/placement/match.js +667 -0
- package/dist/lib/safe-store.d.ts +14 -0
- package/dist/lib/safe-store.js +77 -4
- package/dist/lib/search-index/index.d.ts +88 -4
- package/dist/lib/search-index/index.js +288 -24
- package/dist/lib/search-index/max-doc-bytes.d.ts +17 -6
- package/dist/lib/search-index/max-doc-bytes.js +48 -23
- package/dist/lib/signals/codex-lockdown.d.ts +79 -0
- package/dist/lib/signals/codex-lockdown.js +271 -0
- package/dist/lib/signals/codex-login.d.ts +37 -0
- package/dist/lib/signals/codex-login.js +83 -0
- package/dist/lib/signals/engine.d.ts +27 -0
- package/dist/lib/signals/engine.js +70 -0
- package/dist/lib/signals/reply.js +22 -1
- package/dist/lib/signals/run-record.js +6 -1
- package/dist/lib/signals/settings.d.ts +5 -0
- package/dist/lib/signals/settings.js +2 -0
- package/dist/lib/signals/steps/extract.d.ts +85 -9
- package/dist/lib/signals/steps/extract.js +317 -68
- package/dist/lib/signals/steps/types.d.ts +2 -0
- package/dist/lib/sync-core/engine-home.d.ts +35 -1
- package/dist/lib/sync-core/engine-home.js +119 -16
- package/dist/lib/sync-core/rollout-state.d.ts +2 -1
- package/dist/lib/sync-core/rollout-state.js +5 -2
- package/dist/lib/sync-core/vault-uid.d.ts +2 -0
- package/dist/lib/sync-core/vault-uid.js +4 -0
- package/dist/schemas/hq-work-requirements.v1.schema.json +145 -0
- package/dist/utils/auth-session-check.d.ts +16 -0
- package/dist/utils/auth-session-check.js +16 -0
- package/dist/utils/client-health-contract.d.ts +6 -0
- package/dist/utils/client-health-contract.js +13 -0
- package/dist/utils/client-health.d.ts +7 -0
- package/dist/utils/client-health.js +22 -1
- package/dist/utils/command-usage.d.ts +40 -0
- package/dist/utils/command-usage.js +61 -0
- package/dist/utils/duplicate-command-usage.d.ts +72 -0
- package/dist/utils/duplicate-command-usage.js +125 -0
- package/dist/utils/host-registration.js +2 -1
- package/dist/utils/resident-package-preload.js +4 -0
- package/dist/utils/sentry-fingerprint.js +9 -0
- package/dist/utils/windows-bash.d.ts +2 -0
- package/dist/utils/windows-bash.js +2 -1
- package/package.json +9 -8
- package/scripts/bench-core-compare.mjs +313 -0
- package/scripts/bench-core.mjs +399 -12
- package/scripts/check-function-manifest.mjs +116 -3
|
@@ -17,7 +17,7 @@ export declare const SYNC_CORE_REQUESTS_PER_DAY = 20000;
|
|
|
17
17
|
export declare const SYNC_CORE_REQUEST_COUNT_REMOVED_IN = "v0.1.29";
|
|
18
18
|
export declare function syncCoreEngineHome(home: string, vaultUid: string): string;
|
|
19
19
|
export declare function syncCoreUnitId(vaultUid: string): string;
|
|
20
|
-
export
|
|
20
|
+
export { isSyncCoreVaultUid } from "./vault-uid.js";
|
|
21
21
|
export declare function engineConfigToml(vault: SyncCoreVault, hqRoot: string, phase: SyncCoreVaultPhase, tokenPath?: string,
|
|
22
22
|
/** The engine release this vault runs. Not given: treated as an engine that still counts requests. */
|
|
23
23
|
release?: string): string;
|
|
@@ -52,6 +52,40 @@ export interface SyncCoreFirstCycle {
|
|
|
52
52
|
}
|
|
53
53
|
export declare const SYNC_CORE_STATUS_WORK_LIMIT = 20;
|
|
54
54
|
export declare function engineFirstCycle(engineHome: string, vaultUid: string, since: string): SyncCoreFirstCycle | null;
|
|
55
|
+
export interface SyncCoreLastCycle extends SyncCoreFirstCycle {
|
|
56
|
+
fullVault: boolean;
|
|
57
|
+
success: boolean;
|
|
58
|
+
unsupported: number;
|
|
59
|
+
skipped: number;
|
|
60
|
+
transferFailures: number;
|
|
61
|
+
snapshotWaitUntil?: string;
|
|
62
|
+
requestPauseUntil?: string;
|
|
63
|
+
requestBreakerUntil?: string;
|
|
64
|
+
transferWaitUntil?: string;
|
|
65
|
+
transfersQueued?: number;
|
|
66
|
+
}
|
|
67
|
+
export interface SyncCoreRunningCycle {
|
|
68
|
+
startedAt: string;
|
|
69
|
+
updatedAt?: string;
|
|
70
|
+
phase: string;
|
|
71
|
+
planned: number;
|
|
72
|
+
uploadsTotal: number;
|
|
73
|
+
uploadsDone: number;
|
|
74
|
+
downloadsTotal: number;
|
|
75
|
+
downloadsDone: number;
|
|
76
|
+
failed: number;
|
|
77
|
+
currentPath?: string;
|
|
78
|
+
stale: boolean;
|
|
79
|
+
}
|
|
80
|
+
export interface SyncCoreEngineStatus {
|
|
81
|
+
engineVersion?: string;
|
|
82
|
+
startedAt?: string;
|
|
83
|
+
requests24h?: number;
|
|
84
|
+
cycle?: SyncCoreRunningCycle;
|
|
85
|
+
lastCycle?: SyncCoreLastCycle;
|
|
86
|
+
}
|
|
87
|
+
export declare const SYNC_CORE_CYCLE_STALE_MS = 120000;
|
|
88
|
+
export declare function readEngineStatus(engineHome: string, vaultUid: string, now?: Date): SyncCoreEngineStatus | null;
|
|
55
89
|
export declare function clearEngineStatus(home: string, vaultUid: string): void;
|
|
56
90
|
export declare function removeEngineOwnership(home: string, vaultUid: string): void;
|
|
57
91
|
export declare function inspectEngineHome(home: string, hqRoot: string | undefined, plan: SyncCoreVaultPlan, platform: NodeJS.Platform): SyncCoreVaultPlan;
|
|
@@ -11,9 +11,7 @@ export function syncCoreEngineHome(home, vaultUid) {
|
|
|
11
11
|
export function syncCoreUnitId(vaultUid) {
|
|
12
12
|
return `sync-core:${vaultUid}`;
|
|
13
13
|
}
|
|
14
|
-
export
|
|
15
|
-
return typeof value === "string" && /^(prs|cmp)_[A-Za-z0-9][A-Za-z0-9_-]*$/.test(value);
|
|
16
|
-
}
|
|
14
|
+
export { isSyncCoreVaultUid } from "./vault-uid.js";
|
|
17
15
|
export function engineConfigToml(vault, hqRoot, phase, tokenPath,
|
|
18
16
|
/** The engine release this vault runs. Not given: treated as an engine that still counts requests. */
|
|
19
17
|
release) {
|
|
@@ -96,26 +94,19 @@ export const SYNC_CORE_STATUS_WORK_LIMIT = 20;
|
|
|
96
94
|
function count(value) {
|
|
97
95
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : 0;
|
|
98
96
|
}
|
|
99
|
-
|
|
100
|
-
let status;
|
|
97
|
+
function readStatusFile(engineHome) {
|
|
101
98
|
try {
|
|
102
|
-
|
|
99
|
+
return record(JSON.parse(fs.readFileSync(path.join(engineHome, ".hq", "sync-core", "status.json"), "utf8")));
|
|
103
100
|
}
|
|
104
101
|
catch {
|
|
105
|
-
return
|
|
102
|
+
return undefined;
|
|
106
103
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const cycle = record(status?.last_canary);
|
|
110
|
-
if (!cycle || cycle.vault !== vaultUid || cycle.full_vault !== true)
|
|
111
|
-
return null;
|
|
112
|
-
const sinceMs = Date.parse(since);
|
|
113
|
-
if (typeof cycle.at_ms !== "number" || cycle.at_ms <= 0 || !Number.isFinite(sinceMs) || cycle.at_ms < sinceMs)
|
|
114
|
-
return null;
|
|
104
|
+
}
|
|
105
|
+
function cycleSummary(cycle, atMs) {
|
|
115
106
|
const work = (Array.isArray(cycle.work) ? cycle.work : []).map(record).filter((item) => item !== undefined);
|
|
116
107
|
const actions = (...names) => work.filter((item) => names.includes(String(item.action))).length;
|
|
117
108
|
return {
|
|
118
|
-
at: new Date(
|
|
109
|
+
at: new Date(atMs).toISOString(),
|
|
119
110
|
planned: count(cycle.planned),
|
|
120
111
|
completed: count(cycle.completed),
|
|
121
112
|
pending: count(cycle.pending),
|
|
@@ -130,6 +121,118 @@ export function engineFirstCycle(engineHome, vaultUid, since) {
|
|
|
130
121
|
truncated: work.length >= SYNC_CORE_STATUS_WORK_LIMIT,
|
|
131
122
|
};
|
|
132
123
|
}
|
|
124
|
+
function timestampMs(value) {
|
|
125
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 && value <= 8.64e15 ? value : undefined;
|
|
126
|
+
}
|
|
127
|
+
function isoTime(value) {
|
|
128
|
+
const ms = timestampMs(value);
|
|
129
|
+
return ms === undefined ? undefined : new Date(ms).toISOString();
|
|
130
|
+
}
|
|
131
|
+
export function engineFirstCycle(engineHome, vaultUid, since) {
|
|
132
|
+
const status = readStatusFile(engineHome);
|
|
133
|
+
if (!status)
|
|
134
|
+
return null;
|
|
135
|
+
if (record(status?.mode)?.value !== "full")
|
|
136
|
+
return null;
|
|
137
|
+
const cycle = record(status?.last_canary);
|
|
138
|
+
if (!cycle || cycle.vault !== vaultUid || cycle.full_vault !== true)
|
|
139
|
+
return null;
|
|
140
|
+
const sinceMs = Date.parse(since);
|
|
141
|
+
if (typeof cycle.at_ms !== "number" || cycle.at_ms <= 0 || !Number.isFinite(sinceMs) || cycle.at_ms < sinceMs)
|
|
142
|
+
return null;
|
|
143
|
+
return cycleSummary(cycle, cycle.at_ms);
|
|
144
|
+
}
|
|
145
|
+
export const SYNC_CORE_CYCLE_STALE_MS = 120_000;
|
|
146
|
+
const CYCLE_PATH_LIMIT = 200;
|
|
147
|
+
function wholeCount(value) {
|
|
148
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : 0;
|
|
149
|
+
}
|
|
150
|
+
const UNPRINTED_CODE_POINTS = [
|
|
151
|
+
[0x00, 0x1f],
|
|
152
|
+
[0x7f, 0x9f],
|
|
153
|
+
[0xad, 0xad],
|
|
154
|
+
[0x61c, 0x61c],
|
|
155
|
+
[0x180e, 0x180e],
|
|
156
|
+
[0x200b, 0x200f],
|
|
157
|
+
[0x2028, 0x202e],
|
|
158
|
+
[0x2060, 0x206f],
|
|
159
|
+
[0xfeff, 0xfeff],
|
|
160
|
+
[0xfff9, 0xfffb],
|
|
161
|
+
[0xe0000, 0xe007f],
|
|
162
|
+
];
|
|
163
|
+
function printablePath(value) {
|
|
164
|
+
if (typeof value !== "string")
|
|
165
|
+
return "";
|
|
166
|
+
const points = Array.from(value).filter((char) => {
|
|
167
|
+
const code = char.codePointAt(0) ?? 0;
|
|
168
|
+
return !UNPRINTED_CODE_POINTS.some(([from, to]) => code >= from && code <= to);
|
|
169
|
+
});
|
|
170
|
+
return points.length > CYCLE_PATH_LIMIT ? `${points.slice(0, CYCLE_PATH_LIMIT - 1).join("")}…` : points.join("");
|
|
171
|
+
}
|
|
172
|
+
function runningCycle(value, vaultUid, now) {
|
|
173
|
+
const cycle = record(value);
|
|
174
|
+
if (!cycle || cycle.vault !== vaultUid)
|
|
175
|
+
return undefined;
|
|
176
|
+
const startedMs = timestampMs(cycle.started_at_ms);
|
|
177
|
+
if (startedMs === undefined)
|
|
178
|
+
return undefined;
|
|
179
|
+
const updatedMs = timestampMs(cycle.updated_at_ms);
|
|
180
|
+
const phase = typeof cycle.phase === "string" && /^[a-z][a-z_]{0,31}$/.test(cycle.phase) ? cycle.phase : "unknown";
|
|
181
|
+
const transferring = phase === "uploading" || phase === "downloading";
|
|
182
|
+
const currentPath = printablePath(cycle.current_path);
|
|
183
|
+
return {
|
|
184
|
+
startedAt: new Date(startedMs).toISOString(),
|
|
185
|
+
...(updatedMs !== undefined ? { updatedAt: new Date(updatedMs).toISOString() } : {}),
|
|
186
|
+
phase,
|
|
187
|
+
planned: wholeCount(cycle.planned),
|
|
188
|
+
uploadsTotal: wholeCount(cycle.uploads_total),
|
|
189
|
+
uploadsDone: wholeCount(cycle.uploads_done),
|
|
190
|
+
downloadsTotal: wholeCount(cycle.downloads_total),
|
|
191
|
+
downloadsDone: wholeCount(cycle.downloads_done),
|
|
192
|
+
failed: wholeCount(cycle.failed),
|
|
193
|
+
...(currentPath ? { currentPath } : {}),
|
|
194
|
+
stale: transferring && updatedMs !== undefined && now.getTime() - updatedMs > SYNC_CORE_CYCLE_STALE_MS,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export function readEngineStatus(engineHome, vaultUid, now = new Date()) {
|
|
198
|
+
const status = readStatusFile(engineHome);
|
|
199
|
+
if (!status)
|
|
200
|
+
return null;
|
|
201
|
+
const startedAt = isoTime(status.started_at_ms);
|
|
202
|
+
const cycle = record(status.last_canary);
|
|
203
|
+
const atMs = cycle && cycle.vault === vaultUid ? timestampMs(cycle.at_ms) : undefined;
|
|
204
|
+
const snapshotWaitUntil = cycle ? isoTime(cycle.snapshot_wait_until_ms) : undefined;
|
|
205
|
+
const requestPauseUntil = cycle ? isoTime(cycle.request_pause_until_ms) : undefined;
|
|
206
|
+
const requestBreakerUntil = cycle ? isoTime(cycle.request_breaker_until_ms) : undefined;
|
|
207
|
+
const transferWaitUntil = cycle ? isoTime(cycle.transfer_wait_until_ms) : undefined;
|
|
208
|
+
const transfersQueued = cycle ? wholeCount(cycle.transfers_queued) : 0;
|
|
209
|
+
const running = runningCycle(status.cycle, vaultUid, now);
|
|
210
|
+
return {
|
|
211
|
+
...(typeof status.engine_version === "string" && status.engine_version ? { engineVersion: status.engine_version } : {}),
|
|
212
|
+
...(startedAt ? { startedAt } : {}),
|
|
213
|
+
...(typeof status.requests_24h === "number" && Number.isFinite(status.requests_24h) && status.requests_24h >= 0
|
|
214
|
+
? { requests24h: status.requests_24h }
|
|
215
|
+
: {}),
|
|
216
|
+
...(running ? { cycle: running } : {}),
|
|
217
|
+
...(cycle && atMs !== undefined
|
|
218
|
+
? {
|
|
219
|
+
lastCycle: {
|
|
220
|
+
...cycleSummary(cycle, atMs),
|
|
221
|
+
fullVault: cycle.full_vault === true,
|
|
222
|
+
success: cycle.success === true,
|
|
223
|
+
unsupported: count(cycle.unsupported),
|
|
224
|
+
skipped: count(cycle.skipped),
|
|
225
|
+
transferFailures: Array.isArray(cycle.transfer_failures) ? cycle.transfer_failures.length : 0,
|
|
226
|
+
...(snapshotWaitUntil ? { snapshotWaitUntil } : {}),
|
|
227
|
+
...(requestPauseUntil ? { requestPauseUntil } : {}),
|
|
228
|
+
...(requestBreakerUntil ? { requestBreakerUntil } : {}),
|
|
229
|
+
...(transferWaitUntil ? { transferWaitUntil } : {}),
|
|
230
|
+
...(transfersQueued > 0 ? { transfersQueued } : {}),
|
|
231
|
+
},
|
|
232
|
+
}
|
|
233
|
+
: {}),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
133
236
|
export function clearEngineStatus(home, vaultUid) {
|
|
134
237
|
fs.rmSync(path.join(syncCoreEngineHome(home, vaultUid), ".hq", "sync-core", "status.json"), { force: true });
|
|
135
238
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SyncCoreFirstCycle, SyncCoreVaultKind, SyncCoreVaultPhase } from "./engine-home.js";
|
|
2
2
|
export interface RolloutVault {
|
|
3
3
|
uid: string;
|
|
4
4
|
kind: SyncCoreVaultKind;
|
|
@@ -28,5 +28,6 @@ export interface SyncCoreRolloutState {
|
|
|
28
28
|
}
|
|
29
29
|
export declare function syncCoreRolloutStatePath(home: string): string;
|
|
30
30
|
export declare function readSyncCoreRolloutState(home: string): SyncCoreRolloutState | null;
|
|
31
|
+
export declare function readSyncCoreRolloutStateFile(file: string): SyncCoreRolloutState | null;
|
|
31
32
|
export declare function writeSyncCoreRolloutState(home: string, state: SyncCoreRolloutState): void;
|
|
32
33
|
//# sourceMappingURL=rollout-state.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
-
import { isSyncCoreVaultUid } from "./
|
|
3
|
+
import { isSyncCoreVaultUid } from "./vault-uid.js";
|
|
4
4
|
const FIRST_CYCLE_COUNTS = [
|
|
5
5
|
"planned",
|
|
6
6
|
"completed",
|
|
@@ -75,9 +75,12 @@ function vault(value) {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
export function readSyncCoreRolloutState(home) {
|
|
78
|
+
return readSyncCoreRolloutStateFile(syncCoreRolloutStatePath(home));
|
|
79
|
+
}
|
|
80
|
+
export function readSyncCoreRolloutStateFile(file) {
|
|
78
81
|
let raw;
|
|
79
82
|
try {
|
|
80
|
-
raw = JSON.parse(fs.readFileSync(
|
|
83
|
+
raw = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
81
84
|
}
|
|
82
85
|
catch {
|
|
83
86
|
return null;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "urn:hq:schema:hq-work-requirements:v1",
|
|
4
|
+
"title": "hq-work-requirements.v1",
|
|
5
|
+
"description": "What one piece of work (lane, story, scheduled job or message to a bot) needs from an environment. Hard needs are filtered in pass 1; soft preferences are ranked in pass 2. Secret entries are names only. Work that declares nothing gets a derived document (src/lib/environment/work-requirements.ts) whose on_no_fit is conductor-harness (owner decision 3).",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": ["schema_version", "id", "origin", "company", "engines", "needs", "size", "continuity", "tolerates", "on_no_fit"],
|
|
9
|
+
"properties": {
|
|
10
|
+
"schema_version": { "const": "hq-work-requirements.v1" },
|
|
11
|
+
"id": { "type": "string", "minLength": 1 },
|
|
12
|
+
"title": { "type": "string" },
|
|
13
|
+
"origin": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"additionalProperties": false,
|
|
16
|
+
"required": ["kind", "ref"],
|
|
17
|
+
"properties": {
|
|
18
|
+
"kind": { "enum": ["lane", "story", "job", "message", "session-move"] },
|
|
19
|
+
"ref": { "type": "string", "description": "Lane id, project/story id, job name or message id this declaration is attached to." },
|
|
20
|
+
"derived_from": { "type": "array", "items": { "type": "string" }, "description": "Real records the values were taken from." }
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"company": { "$ref": "#/$defs/company_slug" },
|
|
24
|
+
"engines": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"additionalProperties": false,
|
|
27
|
+
"required": ["any_of"],
|
|
28
|
+
"properties": {
|
|
29
|
+
"any_of": {
|
|
30
|
+
"type": "array",
|
|
31
|
+
"minItems": 1,
|
|
32
|
+
"uniqueItems": true,
|
|
33
|
+
"items": { "enum": ["claude", "codex", "grok"] },
|
|
34
|
+
"description": "Acceptable engines in order of preference. Order is a pass 2 input; membership is a pass 1 filter."
|
|
35
|
+
},
|
|
36
|
+
"account_pin": {
|
|
37
|
+
"type": ["string", "null"],
|
|
38
|
+
"description": "Optional lane-config account id. When set, only that account is paired."
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"needs": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"additionalProperties": false,
|
|
45
|
+
"required": ["labels", "repos", "secrets", "integrations"],
|
|
46
|
+
"properties": {
|
|
47
|
+
"labels": { "type": "array", "uniqueItems": true, "items": { "$ref": "#/$defs/label" } },
|
|
48
|
+
"repos": {
|
|
49
|
+
"type": "array",
|
|
50
|
+
"uniqueItems": true,
|
|
51
|
+
"items": { "type": "string", "pattern": "^[A-Za-z0-9._-]+$" },
|
|
52
|
+
"description": "Matched against access probes repo:<name>."
|
|
53
|
+
},
|
|
54
|
+
"secrets": {
|
|
55
|
+
"type": "array",
|
|
56
|
+
"uniqueItems": true,
|
|
57
|
+
"items": { "type": "string", "pattern": "^[A-Z0-9_]+(/[A-Z0-9_]+)*$" },
|
|
58
|
+
"description": "Vault secret names only. Matched against access probes secret:<NAME>."
|
|
59
|
+
},
|
|
60
|
+
"integrations": {
|
|
61
|
+
"type": "array",
|
|
62
|
+
"uniqueItems": true,
|
|
63
|
+
"items": { "type": "string", "pattern": "^[a-z0-9-]+$" },
|
|
64
|
+
"description": "Matched against access probes integration:<name>."
|
|
65
|
+
},
|
|
66
|
+
"data": {
|
|
67
|
+
"type": "array",
|
|
68
|
+
"uniqueItems": true,
|
|
69
|
+
"items": { "type": "string", "pattern": "^[a-z0-9-]+(:[a-z0-9-]+)*$" },
|
|
70
|
+
"description": "Local data that must already be on the environment. Matched against access probes data:<name>."
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"prefers": {
|
|
75
|
+
"type": "object",
|
|
76
|
+
"additionalProperties": false,
|
|
77
|
+
"properties": {
|
|
78
|
+
"labels": { "type": "array", "uniqueItems": true, "items": { "$ref": "#/$defs/label" } }
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"size": {
|
|
82
|
+
"type": "object",
|
|
83
|
+
"additionalProperties": false,
|
|
84
|
+
"required": ["vcpu", "memory_mb", "disk_gb", "expected_run_seconds"],
|
|
85
|
+
"properties": {
|
|
86
|
+
"vcpu": { "type": "number", "exclusiveMinimum": 0 },
|
|
87
|
+
"memory_mb": { "type": "integer", "minimum": 1 },
|
|
88
|
+
"disk_gb": { "type": "number", "minimum": 0 },
|
|
89
|
+
"expected_run_seconds": { "type": "integer", "minimum": 1, "description": "Checked against the environment's max_run_seconds in pass 1." },
|
|
90
|
+
"provenance": {
|
|
91
|
+
"type": "object",
|
|
92
|
+
"additionalProperties": false,
|
|
93
|
+
"required": ["source", "verified"],
|
|
94
|
+
"properties": { "source": { "type": "string" }, "verified": { "type": "boolean" } }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"continuity": {
|
|
99
|
+
"type": "object",
|
|
100
|
+
"additionalProperties": false,
|
|
101
|
+
"required": ["mode"],
|
|
102
|
+
"properties": {
|
|
103
|
+
"mode": {
|
|
104
|
+
"enum": ["none", "workspace-must-survive", "session-move"],
|
|
105
|
+
"description": "workspace-must-survive and session-move both need workspace_survives true on the environment."
|
|
106
|
+
},
|
|
107
|
+
"checkpoint_ref": { "type": ["string", "null"] }
|
|
108
|
+
},
|
|
109
|
+
"allOf": [
|
|
110
|
+
{
|
|
111
|
+
"if": { "properties": { "mode": { "const": "session-move" } } },
|
|
112
|
+
"then": { "required": ["checkpoint_ref"], "properties": { "checkpoint_ref": { "type": "string" } } }
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
"tolerates": {
|
|
117
|
+
"type": "array",
|
|
118
|
+
"uniqueItems": true,
|
|
119
|
+
"items": { "$ref": "#/$defs/label" },
|
|
120
|
+
"description": "Taint keys (key:value) the work accepts. Exact string match."
|
|
121
|
+
},
|
|
122
|
+
"on_no_fit": {
|
|
123
|
+
"enum": ["ask", "queue", "start", "conductor-harness"],
|
|
124
|
+
"description": "ask: one owner decision listing each rejection and the cheapest fix. queue: wait and re-match on the next reading. start: start a feasible template within max_cost_usd. conductor-harness: run on the harness the conductor itself runs on; the default for work that declares nothing (owner decision 3)."
|
|
125
|
+
},
|
|
126
|
+
"max_cost_usd": { "type": ["number", "null"], "minimum": 0 },
|
|
127
|
+
"priority": { "type": "integer", "minimum": 0 },
|
|
128
|
+
"assumptions": {
|
|
129
|
+
"type": "array",
|
|
130
|
+
"items": { "type": "string" },
|
|
131
|
+
"description": "Values in this declaration that were not taken from a record."
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"allOf": [
|
|
135
|
+
{
|
|
136
|
+
"description": "Starting a paid environment needs a cost cap.",
|
|
137
|
+
"if": { "properties": { "on_no_fit": { "const": "start" } } },
|
|
138
|
+
"then": { "required": ["max_cost_usd"], "properties": { "max_cost_usd": { "type": "number" } } }
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
"$defs": {
|
|
142
|
+
"company_slug": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$" },
|
|
143
|
+
"label": { "type": "string", "pattern": "^[a-z][a-z0-9-]*:[A-Za-z0-9._/@*-]+$" }
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CognitoTokenSource } from "./cognito-session.js";
|
|
2
|
+
/**
|
|
3
|
+
* The exit status `hq auth status` gives for a session state, shared with
|
|
4
|
+
* `hq whoami --check` so the two cannot drift (hq-core-rust US-041).
|
|
5
|
+
*
|
|
6
|
+
* - Machine source: 0, cached session or not; machine creds mint one on demand.
|
|
7
|
+
* - Person source: 0 when a session is cached (valid or expiring), 1 when none
|
|
8
|
+
* is cached (signed out, or the cache file is missing or unreadable).
|
|
9
|
+
*
|
|
10
|
+
* Reads only whether a cache exists; never a token.
|
|
11
|
+
*/
|
|
12
|
+
export declare function authStatusExitCode(state: {
|
|
13
|
+
tokenSource: CognitoTokenSource;
|
|
14
|
+
cached: unknown;
|
|
15
|
+
}): 0 | 1;
|
|
16
|
+
//# sourceMappingURL=auth-session-check.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The exit status `hq auth status` gives for a session state, shared with
|
|
3
|
+
* `hq whoami --check` so the two cannot drift (hq-core-rust US-041).
|
|
4
|
+
*
|
|
5
|
+
* - Machine source: 0, cached session or not; machine creds mint one on demand.
|
|
6
|
+
* - Person source: 0 when a session is cached (valid or expiring), 1 when none
|
|
7
|
+
* is cached (signed out, or the cache file is missing or unreadable).
|
|
8
|
+
*
|
|
9
|
+
* Reads only whether a cache exists; never a token.
|
|
10
|
+
*/
|
|
11
|
+
export function authStatusExitCode(state) {
|
|
12
|
+
if (state.tokenSource === "machine")
|
|
13
|
+
return 0;
|
|
14
|
+
return state.cached ? 0 : 1;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=auth-session-check.js.map
|
|
@@ -57,6 +57,9 @@ export type ClientHealthUpdaterState = (typeof CLIENT_HEALTH_UPDATER_STATES)[num
|
|
|
57
57
|
export declare const CLIENT_HEALTH_SYNC_RUNNER_SOURCES: readonly ["npx", "daemon_managed", "daemon_staged", "daemon_bundled", "unknown"];
|
|
58
58
|
export type ClientHealthSyncRunnerSource = (typeof CLIENT_HEALTH_SYNC_RUNNER_SOURCES)[number];
|
|
59
59
|
export declare const CLIENT_HEALTH_DAEMON_HQ_CLOUD_UPDATE_OUTCOMES: readonly ["updated", "up_to_date", "pinned", "failed"];
|
|
60
|
+
export declare const CLIENT_HEALTH_SYNC_ENGINES: readonly ["hq-syncd"];
|
|
61
|
+
export type ClientHealthSyncEngine = (typeof CLIENT_HEALTH_SYNC_ENGINES)[number];
|
|
62
|
+
export declare const CLIENT_HEALTH_MAX_SYNC_ENGINE_VAULTS = 10000;
|
|
60
63
|
export type ClientHealthDaemonHqCloudUpdateOutcome = (typeof CLIENT_HEALTH_DAEMON_HQ_CLOUD_UPDATE_OUTCOMES)[number];
|
|
61
64
|
export declare const CLIENT_HEALTH_DAEMON_HQ_CLOUD_UPDATE_ERROR_CLASSES: readonly ["registry", "install", "convergence", "filesystem", "unknown"];
|
|
62
65
|
export type ClientHealthDaemonHqCloudUpdateErrorClass = (typeof CLIENT_HEALTH_DAEMON_HQ_CLOUD_UPDATE_ERROR_CLASSES)[number];
|
|
@@ -96,6 +99,7 @@ export interface ClientHealthVersions {
|
|
|
96
99
|
cli?: string;
|
|
97
100
|
core?: string;
|
|
98
101
|
syncRunner?: string;
|
|
102
|
+
syncEngine?: string;
|
|
99
103
|
}
|
|
100
104
|
/**
|
|
101
105
|
* Closed, bounded-fact summary of the user's local log/journal FILES —
|
|
@@ -147,6 +151,8 @@ export interface ClientHealthHeartbeat {
|
|
|
147
151
|
updaterState?: ClientHealthUpdaterState;
|
|
148
152
|
failureReason?: ClientHealthFailureReason;
|
|
149
153
|
syncRunnerSource?: ClientHealthSyncRunnerSource;
|
|
154
|
+
syncEngine?: ClientHealthSyncEngine;
|
|
155
|
+
syncEngineVaults?: number;
|
|
150
156
|
daemonHqCloudUpdateLastCheckAt?: string;
|
|
151
157
|
daemonHqCloudUpdateOutcome?: ClientHealthDaemonHqCloudUpdateOutcome;
|
|
152
158
|
daemonHqCloudUpdateTarget?: string;
|
|
@@ -79,6 +79,8 @@ export const CLIENT_HEALTH_DAEMON_HQ_CLOUD_UPDATE_OUTCOMES = [
|
|
|
79
79
|
"pinned",
|
|
80
80
|
"failed",
|
|
81
81
|
];
|
|
82
|
+
export const CLIENT_HEALTH_SYNC_ENGINES = ["hq-syncd"];
|
|
83
|
+
export const CLIENT_HEALTH_MAX_SYNC_ENGINE_VAULTS = 10_000;
|
|
82
84
|
export const CLIENT_HEALTH_DAEMON_HQ_CLOUD_UPDATE_ERROR_CLASSES = [
|
|
83
85
|
"registry",
|
|
84
86
|
"install",
|
|
@@ -275,6 +277,11 @@ export function parseClientHealthHeartbeat(input) {
|
|
|
275
277
|
if (rawVersions[key] !== undefined)
|
|
276
278
|
versions[key] = assertVersion(`versions.${key}`, rawVersions[key]);
|
|
277
279
|
}
|
|
280
|
+
if (rawVersions.syncEngine !== undefined) {
|
|
281
|
+
const engineVersion = copyValidOptionalDiagnostic("versions.syncEngine", rawVersions.syncEngine, assertVersion);
|
|
282
|
+
if (engineVersion !== undefined)
|
|
283
|
+
versions.syncEngine = engineVersion;
|
|
284
|
+
}
|
|
278
285
|
const heartbeat = {
|
|
279
286
|
contractVersion,
|
|
280
287
|
installationId,
|
|
@@ -303,6 +310,12 @@ export function parseClientHealthHeartbeat(input) {
|
|
|
303
310
|
heartbeat.failureReason = assertEnum("failureReason", raw.failureReason, CLIENT_HEALTH_FAILURE_REASONS);
|
|
304
311
|
}
|
|
305
312
|
copyKnownOptionalEnum(heartbeat, "syncRunnerSource", raw.syncRunnerSource, CLIENT_HEALTH_SYNC_RUNNER_SOURCES);
|
|
313
|
+
copyKnownOptionalEnum(heartbeat, "syncEngine", raw.syncEngine, CLIENT_HEALTH_SYNC_ENGINES);
|
|
314
|
+
if (raw.syncEngineVaults !== undefined) {
|
|
315
|
+
const vaults = copyValidOptionalDiagnostic("syncEngineVaults", raw.syncEngineVaults, (field, value) => assertBoundedInt(field, value, CLIENT_HEALTH_MAX_SYNC_ENGINE_VAULTS));
|
|
316
|
+
if (vaults !== undefined)
|
|
317
|
+
heartbeat.syncEngineVaults = vaults;
|
|
318
|
+
}
|
|
306
319
|
if (raw.daemonHqCloudUpdateLastCheckAt !== undefined) {
|
|
307
320
|
const lastCheckAt = copyValidOptionalDiagnostic("daemonHqCloudUpdateLastCheckAt", raw.daemonHqCloudUpdateLastCheckAt, assertIsoUtc);
|
|
308
321
|
if (lastCheckAt !== undefined)
|
|
@@ -178,7 +178,13 @@ export interface BuildCliHeartbeatInput {
|
|
|
178
178
|
* sync OUTCOME events, not on every invocation heartbeat.
|
|
179
179
|
*/
|
|
180
180
|
localFilesOverview?: ClientHealthLocalFilesOverview | null;
|
|
181
|
+
syncEngine?: CliSyncEngine | null;
|
|
181
182
|
}
|
|
183
|
+
export interface CliSyncEngine {
|
|
184
|
+
release: string;
|
|
185
|
+
vaults: number;
|
|
186
|
+
}
|
|
187
|
+
export declare function readCliSyncEngine(stateDir: string): CliSyncEngine | null;
|
|
182
188
|
/** Classify sync failures using typed error identity/code fields only. */
|
|
183
189
|
export declare function classifySyncFailure(err: unknown): ClientHealthFailureReason;
|
|
184
190
|
/**
|
|
@@ -205,6 +211,7 @@ export interface ClientHealthDeps {
|
|
|
205
211
|
timeoutMs?: number;
|
|
206
212
|
/** US-016: overridable for tests; defaults to {@link collectLocalFilesOverview}. */
|
|
207
213
|
localFilesOverview?: () => ClientHealthLocalFilesOverview;
|
|
214
|
+
syncEngine?: () => CliSyncEngine | null;
|
|
208
215
|
/** Override for {@link JOURNAL_OBSERVATION_TTL_MS}. */
|
|
209
216
|
journalObservationTtlMs?: number;
|
|
210
217
|
/** Override for {@link JOURNAL_OBSERVATION_LOCK_STALE_MS}. */
|
|
@@ -41,8 +41,9 @@ import { isExpiring, isMachineIdentity, loadCachedTokens, } from "./cognito-sess
|
|
|
41
41
|
import { vaultApiFetch } from "./vault-api.js";
|
|
42
42
|
import { collectVersions } from "./feedback-versions.js";
|
|
43
43
|
import { isAuthError } from "./auth-error.js";
|
|
44
|
-
import { CLIENT_HEALTH_CONTRACT_VERSION, parseClientHealthHeartbeat, } from "./client-health-contract.js";
|
|
44
|
+
import { CLIENT_HEALTH_CONTRACT_VERSION, CLIENT_HEALTH_MAX_SYNC_ENGINE_VAULTS, parseClientHealthHeartbeat, } from "./client-health-contract.js";
|
|
45
45
|
import { collectLocalFilesOverview } from "./local-files-overview.js";
|
|
46
|
+
import { readSyncCoreRolloutStateFile } from "../lib/sync-core/rollout-state.js";
|
|
46
47
|
/** Same bound as CLI telemetry: a heartbeat may never stall a command. */
|
|
47
48
|
const CLIENT_HEALTH_TIMEOUT_MS = 1_200;
|
|
48
49
|
export const CLIENT_HEALTH_STATE_FILE = "cli-client-health.json";
|
|
@@ -389,6 +390,11 @@ function acquireJournalObservationLock(stateDir, nowMs, staleMs) {
|
|
|
389
390
|
}
|
|
390
391
|
};
|
|
391
392
|
}
|
|
393
|
+
export function readCliSyncEngine(stateDir) {
|
|
394
|
+
const state = readSyncCoreRolloutStateFile(path.join(stateDir, "sync-core", "rollout.json"));
|
|
395
|
+
const vaults = state?.vaults.filter((vault) => vault.phase === "full").length ?? 0;
|
|
396
|
+
return state && vaults > 0 ? { release: state.release, vaults } : null;
|
|
397
|
+
}
|
|
392
398
|
/** Classify sync failures using typed error identity/code fields only. */
|
|
393
399
|
export function classifySyncFailure(err) {
|
|
394
400
|
if (isAuthError(err))
|
|
@@ -495,6 +501,13 @@ export function buildCliHeartbeat(input) {
|
|
|
495
501
|
input.localFilesOverview) {
|
|
496
502
|
heartbeat.localFilesOverview = input.localFilesOverview;
|
|
497
503
|
}
|
|
504
|
+
if (input.syncEngine && input.syncEngine.vaults > 0) {
|
|
505
|
+
heartbeat.syncEngine = "hq-syncd";
|
|
506
|
+
heartbeat.syncEngineVaults = Math.min(input.syncEngine.vaults, CLIENT_HEALTH_MAX_SYNC_ENGINE_VAULTS);
|
|
507
|
+
const engineVersion = input.syncEngine.release.replace(/^v/, "");
|
|
508
|
+
if (SEMVER.test(engineVersion))
|
|
509
|
+
versions.syncEngine = engineVersion;
|
|
510
|
+
}
|
|
498
511
|
return heartbeat;
|
|
499
512
|
}
|
|
500
513
|
const defaultPoster = (heartbeat, token, signal) => vaultApiFetch({
|
|
@@ -654,6 +667,13 @@ async function contributeClientHealthUnbounded(kind, deps, failureReason) {
|
|
|
654
667
|
localFilesOverview = null;
|
|
655
668
|
}
|
|
656
669
|
}
|
|
670
|
+
let syncEngine = null;
|
|
671
|
+
try {
|
|
672
|
+
syncEngine = (deps.syncEngine ?? (() => readCliSyncEngine(stateDir)))();
|
|
673
|
+
}
|
|
674
|
+
catch {
|
|
675
|
+
syncEngine = null;
|
|
676
|
+
}
|
|
657
677
|
const heartbeat = buildCliHeartbeat({
|
|
658
678
|
kind,
|
|
659
679
|
state,
|
|
@@ -663,6 +683,7 @@ async function contributeClientHealthUnbounded(kind, deps, failureReason) {
|
|
|
663
683
|
now,
|
|
664
684
|
localFilesOverview,
|
|
665
685
|
failureReason,
|
|
686
|
+
syncEngine,
|
|
666
687
|
});
|
|
667
688
|
if (!heartbeat)
|
|
668
689
|
return;
|
|
@@ -27,6 +27,13 @@
|
|
|
27
27
|
* is kept until the next one, so the folder holds about twice the compaction
|
|
28
28
|
* threshold at most (about 512 KiB).
|
|
29
29
|
*
|
|
30
|
+
* Time: each line carries its UTC date and nothing finer, so a window is
|
|
31
|
+
* answered in whole UTC dates. `hq doctor usage --duplicates --since <d>`
|
|
32
|
+
* (utils/duplicate-command-usage.ts) counts every date the window touches,
|
|
33
|
+
* which can only count more runs than the exact window holds, never fewer.
|
|
34
|
+
* The format is unchanged by that check; {@link readCommandUsageEntries}
|
|
35
|
+
* reads the same lines and tells an unreadable folder apart from a zero.
|
|
36
|
+
*
|
|
30
37
|
* Every read and write of the usage folder goes through the shared store
|
|
31
38
|
* helper (`src/lib/safe-store.ts`): the folder is held open and checked by its
|
|
32
39
|
* descriptor, files are opened without following a link and without blocking,
|
|
@@ -272,4 +279,37 @@ export interface CommandUsageReport {
|
|
|
272
279
|
export declare function readCommandUsage(options?: CommandUsageOptions): CommandUsageReport;
|
|
273
280
|
/** Plain-text report for `hq doctor usage`. */
|
|
274
281
|
export declare function renderCommandUsageText(report: CommandUsageReport): string;
|
|
282
|
+
/** One line of the usage store after merging: a date, a kind, a command path and its count. */
|
|
283
|
+
export interface CommandUsageEntry {
|
|
284
|
+
/** UTC date, `YYYY-MM-DD`. */
|
|
285
|
+
date: string;
|
|
286
|
+
kind: CommandUseKind;
|
|
287
|
+
command: string;
|
|
288
|
+
count: number;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* The usage store read for a check that must tell "no runs" from "cannot
|
|
292
|
+
* tell". `ok: false` is never a zero: the folder could not be held (missing,
|
|
293
|
+
* a link, another user's, writable by group or others), could not be listed,
|
|
294
|
+
* or holds a usage file that could not be read safely.
|
|
295
|
+
*/
|
|
296
|
+
export type CommandUsageEntriesRead = {
|
|
297
|
+
ok: true;
|
|
298
|
+
file: string;
|
|
299
|
+
entries: CommandUsageEntry[];
|
|
300
|
+
} | {
|
|
301
|
+
ok: false;
|
|
302
|
+
file: string | null;
|
|
303
|
+
reason: string;
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Every counted line the store still keeps (up to
|
|
307
|
+
* {@link COMMAND_USAGE_WINDOW_DAYS} UTC dates), merged across the live file
|
|
308
|
+
* and the not-yet-folded part of each rotated file, as {@link readCommandUsage}
|
|
309
|
+
* reads them. Unlike that report, a folder or file that cannot be read is
|
|
310
|
+
* returned as `ok: false` instead of as an empty count.
|
|
311
|
+
*/
|
|
312
|
+
export declare function readCommandUsageEntries(options?: CommandUsageOptions): CommandUsageEntriesRead;
|
|
313
|
+
/** The UTC date (`YYYY-MM-DD`) of an epoch-millisecond time, as the usage store writes it. */
|
|
314
|
+
export declare function usageDateOf(epochMs: number): string;
|
|
275
315
|
//# sourceMappingURL=command-usage.d.ts.map
|