@indigoai-us/hq-cli 5.345.241 → 5.345.242
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 +49 -0
- package/assets/scaffold/core/scripts/hq-delegate-grant.sh +170 -8
- package/assets/scaffold/core/scripts/hq-delegate-publish.sh +21 -1
- package/assets/scaffold/core/scripts/lib/delegate-engine.sh +77 -0
- package/dist/command-catalog.generated.d.ts +28 -8
- package/dist/command-catalog.generated.js +33 -8
- package/dist/commands/cloud-off-gate.d.ts +7 -7
- package/dist/commands/cloud-off-gate.js +26 -38
- package/dist/commands/core-delegate-w1b.js +307 -26
- package/dist/commands/core-delegate.js +2 -0
- package/dist/commands/core-handoff.js +1 -1
- package/dist/commands/core-job-model-auth.d.ts +95 -0
- package/dist/commands/core-job-model-auth.js +247 -0
- package/dist/commands/core-job-run-native.js +280 -12
- package/dist/commands/core.js +1 -0
- package/dist/commands/files-browse.js +2 -0
- package/dist/commands/files.js +4 -0
- package/dist/commands/integrations-core.d.ts +11 -0
- package/dist/commands/integrations-core.js +15 -1
- package/dist/commands/lanes-link.js +2 -2
- package/dist/commands/lanes-loop.d.ts +2 -2
- package/dist/commands/lanes-loop.js +5 -5
- package/dist/commands/lanes-questions.js +1 -1
- package/dist/commands/lanes-stories.js +1 -1
- package/dist/commands/lanes.js +80 -14
- package/dist/commands/rescue.d.ts +3 -2
- package/dist/commands/rescue.js +48 -34
- package/dist/commands/search.d.ts +6 -0
- package/dist/commands/search.js +24 -4
- package/dist/commands/sources.js +6 -2
- package/dist/commands/sync-core.d.ts +8 -0
- package/dist/commands/sync-core.js +43 -0
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +1737 -1450
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/capacity/accounts.d.ts +1 -1
- package/dist/lib/capacity/accounts.js +1 -1
- package/dist/lib/capacity/freshness.d.ts +1 -1
- package/dist/lib/capacity/freshness.js +1 -1
- package/dist/lib/capacity/route.js +1 -1
- package/dist/lib/daemon/catalog.d.ts +3 -0
- package/dist/lib/daemon/hook-requests.d.ts +1 -1
- package/dist/lib/daemon/hook-requests.js +4 -2
- package/dist/lib/daemon/run.js +16 -22
- package/dist/lib/environment/work-requirements.d.ts +1 -1
- package/dist/lib/environment/work-requirements.js +1 -1
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/hook-engine/coverage.js +11 -3
- package/dist/lib/hook-engine/git-stop-config.json +510 -510
- package/dist/lib/hook-engine/native-precompact-compatibility.json +443 -443
- package/dist/lib/hook-engine/native-stop-compatibility.json +359 -359
- package/dist/lib/hot-channels/adapters/meetings.d.ts +1 -16
- package/dist/lib/hot-channels/adapters/meetings.js +3 -28
- package/dist/lib/hot-channels/adapters/slack.d.ts +3 -1
- package/dist/lib/hot-channels/adapters/slack.js +4 -1
- package/dist/lib/hot-channels/contract.d.ts +14 -0
- package/dist/lib/hot-channels/fleet-complete.d.ts +18 -2
- package/dist/lib/hot-channels/fleet-complete.js +29 -4
- package/dist/lib/hot-channels/meeting-source-ref.d.ts +17 -0
- package/dist/lib/hot-channels/meeting-source-ref.js +32 -0
- package/dist/lib/hot-channels/prompts/signals-pass.md +6 -1
- package/dist/lib/hot-channels/run.d.ts +10 -0
- package/dist/lib/hot-channels/run.js +34 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +27 -0
- package/dist/lib/hot-channels/signals-pass.js +57 -2
- package/dist/lib/hot-channels/signals-runtime.js +3 -2
- package/dist/lib/lanes/accounts.js +2 -2
- package/dist/lib/lanes/claude-balance.d.ts +6 -0
- package/dist/lib/lanes/claude-balance.js +124 -0
- package/dist/lib/lanes/grants.js +15 -2
- package/dist/lib/lanes/hq-root.d.ts +1 -1
- package/dist/lib/lanes/hq-root.js +1 -1
- package/dist/lib/lanes/links.d.ts +1 -1
- package/dist/lib/lanes/liveness.d.ts +3 -0
- package/dist/lib/lanes/liveness.js +61 -7
- package/dist/lib/lanes/models.d.ts +1 -1
- package/dist/lib/lanes/models.js +1 -1
- package/dist/lib/lanes/questions.d.ts +1 -1
- package/dist/lib/lanes/questions.js +2 -2
- package/dist/lib/lanes/spawn.js +4 -6
- package/dist/lib/lanes/store.d.ts +13 -2
- package/dist/lib/lanes/store.js +13 -5
- package/dist/lib/lanes/types.d.ts +7 -7
- package/dist/lib/lanes/types.js +1 -1
- package/dist/lib/lanes/watcher-main.js +1 -1
- package/dist/lib/lanes/watcher.d.ts +1 -1
- package/dist/lib/lanes/watcher.js +1 -1
- package/dist/lib/onboarding/cli/onboard.js +5 -0
- package/dist/lib/signals/sanitize.d.ts +19 -0
- package/dist/lib/signals/sanitize.js +103 -7
- package/dist/lib/signals/steps/upload.d.ts +40 -1
- package/dist/lib/signals/steps/upload.js +122 -6
- package/dist/lib/sync-core/access-refresh.d.ts +29 -0
- package/dist/lib/sync-core/access-refresh.js +97 -0
- package/dist/lib/sync-core/company-adoption.d.ts +33 -0
- package/dist/lib/sync-core/company-adoption.js +223 -0
- package/dist/lib/sync-core/engine-home.d.ts +1 -0
- package/dist/lib/sync-core/engine-owned.d.ts +13 -0
- package/dist/lib/sync-core/engine-owned.js +38 -0
- package/dist/lib/sync-core/hand-back.d.ts +17 -0
- package/dist/lib/sync-core/hand-back.js +23 -0
- package/dist/lib/sync-core/post-apply-reindex.d.ts +33 -0
- package/dist/lib/sync-core/post-apply-reindex.js +149 -0
- package/dist/lib/sync-core/reconcile.d.ts +10 -0
- package/dist/lib/sync-core/reconcile.js +117 -12
- package/dist/lib/sync-core/rollout-state.d.ts +2 -0
- package/dist/lib/sync-core/rollout-state.js +6 -0
- package/dist/lib/vault-sync-switches.d.ts +14 -0
- package/dist/lib/vault-sync-switches.js +22 -0
- package/dist/lib/workers-registry/index.d.ts +1 -1
- package/dist/lib/workers-registry/index.js +1 -1
- package/dist/utils/github-tag-fallback.d.ts +16 -0
- package/dist/utils/github-tag-fallback.js +126 -0
- package/dist/utils/version-report.d.ts +2 -1
- package/dist/utils/version-report.js +40 -27
- package/package.json +8 -8
|
@@ -2,15 +2,19 @@ import * as fs from "node:fs";
|
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { readCompaniesManifestMap } from "../work-context/repo-remote.js";
|
|
4
4
|
import { readVaultSyncSwitches, writeVaultSyncSwitches } from "../vault-sync-switches.js";
|
|
5
|
+
import { engineOwnsVault } from "./hand-back.js";
|
|
5
6
|
import { clearEngineStatus, engineFirstCycle, isSyncCoreVaultUid, removeEngineOwnership, syncCoreEngineHome, writeEngineHome, } from "./engine-home.js";
|
|
6
7
|
import { SYNC_CORE_FULL_RELEASE, SYNC_CORE_RELEASE, compareSyncCoreReleases, fullModeAllowed, installedSyncCoreRelease, syncCoreBinaryPath, windowsFullRelease, } from "./release.js";
|
|
7
8
|
import { readSyncCoreSkips } from "./skip.js";
|
|
9
|
+
import { isLiveCompanyEntity, joinedCompanySlug, setUpJoinedCompany } from "./company-adoption.js";
|
|
8
10
|
import { heldDeletesHandoverLine, readEngineHeldDeletes } from "./engine-holds.js";
|
|
9
11
|
import { SYNC_RUST_ENGINE_ROLLOUT_FLAG } from "./flag.js";
|
|
10
12
|
import { readSyncCoreRolloutState, syncCoreRolloutStatePath, writeSyncCoreRolloutState, } from "./rollout-state.js";
|
|
11
13
|
function message(error) {
|
|
12
14
|
return error instanceof Error ? error.message : String(error);
|
|
13
15
|
}
|
|
16
|
+
/** The old sync reads a `.hqinclude` allowlist at the HQ root; the engine does not, so it would upload everything in scope. */
|
|
17
|
+
const HQINCLUDE_HOLD = "hqinclude-unsupported: this HQ folder has a .hqinclude allowlist, which the new sync engine does not support yet; staying on the current sync";
|
|
14
18
|
export function fullModeHold(vault, release, platform = process.platform, env = process.env) {
|
|
15
19
|
if (fullModeAllowed(release, platform, env))
|
|
16
20
|
return undefined;
|
|
@@ -68,6 +72,85 @@ function ownedVaultsWithoutState(home, hqRoot) {
|
|
|
68
72
|
}
|
|
69
73
|
return vaults;
|
|
70
74
|
}
|
|
75
|
+
const JOIN_SETUP_MACHINE_TYPES = ["desktop", "self-hosted"];
|
|
76
|
+
/** The current sync's journal for a company folder (hq-cloud getJournalPath), in ~/.hq or HQ_STATE_DIR. */
|
|
77
|
+
function legacyJournalFor(home, env, slug) {
|
|
78
|
+
const dirs = new Set([path.join(home, ".hq"), ...(env.HQ_STATE_DIR?.trim() ? [path.resolve(env.HQ_STATE_DIR.trim())] : [])]);
|
|
79
|
+
return [...dirs].map((dir) => path.join(dir, `sync-journal.${slug}.json`)).find((file) => fs.existsSync(file));
|
|
80
|
+
}
|
|
81
|
+
async function setUpJoinedCompanies(deps, memberships, ctx) {
|
|
82
|
+
if (!deps.resolveCompany || !deps.machineType || !JOIN_SETUP_MACHINE_TYPES.includes(deps.machineType))
|
|
83
|
+
return;
|
|
84
|
+
if (ctx.platform === "win32")
|
|
85
|
+
return;
|
|
86
|
+
const switches = readVaultSyncSwitches(deps.home);
|
|
87
|
+
if (switches.allOff)
|
|
88
|
+
return;
|
|
89
|
+
let skips;
|
|
90
|
+
try {
|
|
91
|
+
skips = readSyncCoreSkips(deps.home);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const slugByUid = new Map();
|
|
97
|
+
for (const [slug, entry] of Object.entries(readCompaniesManifestMap(deps.hqRoot) ?? {})) {
|
|
98
|
+
if (typeof entry?.cloud_uid === "string" && /^[a-z0-9][a-z0-9_-]*$/.test(slug))
|
|
99
|
+
slugByUid.set(entry.cloud_uid, slug);
|
|
100
|
+
}
|
|
101
|
+
for (const { companyUid: uid } of memberships) {
|
|
102
|
+
if (!isSyncCoreVaultUid(uid) || !uid.startsWith("cmp_"))
|
|
103
|
+
continue;
|
|
104
|
+
const bound = slugByUid.get(uid);
|
|
105
|
+
const hadEngine = ctx.previousByUid.has(uid) || fs.existsSync(syncCoreEngineHome(deps.home, uid));
|
|
106
|
+
if (bound && (hadEngine || fs.existsSync(path.join(deps.hqRoot, "companies", bound))))
|
|
107
|
+
continue;
|
|
108
|
+
if (skips.some((skip) => skip.uid === uid))
|
|
109
|
+
continue;
|
|
110
|
+
if (bound && switches.offCompanies.has(bound))
|
|
111
|
+
continue;
|
|
112
|
+
let on;
|
|
113
|
+
try {
|
|
114
|
+
on = await deps.readRolloutFlag(uid);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
ctx.warnings.push(`${message(error)}; not setting up ${bound ?? uid} on this computer this run`);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
ctx.flagReads.set(uid, on);
|
|
121
|
+
if (!on)
|
|
122
|
+
continue;
|
|
123
|
+
try {
|
|
124
|
+
const entity = await deps.resolveCompany(uid);
|
|
125
|
+
if (!isLiveCompanyEntity(entity, uid))
|
|
126
|
+
continue;
|
|
127
|
+
const slug = bound ?? joinedCompanySlug(entity);
|
|
128
|
+
if (!slug) {
|
|
129
|
+
ctx.warnings.push(`${uid}: its name "${entity.slug ?? ""}" cannot be used as a folder name; not set up on this computer`);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (switches.offCompanies.has(slug))
|
|
133
|
+
continue;
|
|
134
|
+
const journal = legacyJournalFor(deps.home, ctx.env, slug);
|
|
135
|
+
const keepFolderMissing = hadEngine
|
|
136
|
+
? "the new sync engine synced it on this computer before"
|
|
137
|
+
: journal
|
|
138
|
+
? `the current sync has a journal for it (${journal})`
|
|
139
|
+
: undefined;
|
|
140
|
+
const setup = setUpJoinedCompany(deps.hqRoot, slug, entity, keepFolderMissing ? { keepFolderMissing } : {});
|
|
141
|
+
if (setup.status === "refused") {
|
|
142
|
+
ctx.warnings.push(`${uid}: ${setup.reason}; not set up on this computer`);
|
|
143
|
+
}
|
|
144
|
+
else if (setup.createdFolder || setup.wroteEntry) {
|
|
145
|
+
const did = [setup.createdFolder ? `created companies/${slug}` : "", setup.wroteEntry ? "added it to companies/manifest.yaml" : ""];
|
|
146
|
+
ctx.log(`${uid}: ${did.filter(Boolean).join(" and ")} (joined company; the new sync engine downloads its files)`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
ctx.warnings.push(`could not set up company ${uid} on this computer: ${message(error)}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
71
154
|
export async function reconcileSyncCore(deps) {
|
|
72
155
|
const now = deps.now ?? (() => new Date());
|
|
73
156
|
const log = deps.log ?? (() => { });
|
|
@@ -78,13 +161,16 @@ export async function reconcileSyncCore(deps) {
|
|
|
78
161
|
const previous = readSyncCoreRolloutState(deps.home);
|
|
79
162
|
const previousVaults = previous?.vaults ?? ownedVaultsWithoutState(deps.home, deps.hqRoot);
|
|
80
163
|
const previousByUid = new Map(previousVaults.map((vault) => [vault.uid, vault]));
|
|
164
|
+
const pendingByUid = new Map((previous?.handingBack ?? []).map((vault) => [vault.uid, vault]));
|
|
81
165
|
const memberships = await deps.listMemberships();
|
|
166
|
+
const flagReads = new Map();
|
|
167
|
+
await setUpJoinedCompanies(deps, memberships, { platform, env, previousByUid, flagReads, warnings, log });
|
|
82
168
|
const desired = [];
|
|
83
169
|
let anyCompanyOn = false;
|
|
84
170
|
for (const company of localCompanies(deps.hqRoot, memberships)) {
|
|
85
171
|
let on;
|
|
86
172
|
try {
|
|
87
|
-
on = await deps.readRolloutFlag(company.uid);
|
|
173
|
+
on = flagReads.get(company.uid) ?? await deps.readRolloutFlag(company.uid);
|
|
88
174
|
}
|
|
89
175
|
catch (error) {
|
|
90
176
|
on = previous?.rolloutFlagKey === SYNC_RUST_ENGINE_ROLLOUT_FLAG && previousByUid.has(company.uid);
|
|
@@ -135,6 +221,11 @@ export async function reconcileSyncCore(deps) {
|
|
|
135
221
|
held.push({ uid: vault.uid, reason: fullModeHold(vault, best, platform, env) });
|
|
136
222
|
desired.length = 0;
|
|
137
223
|
}
|
|
224
|
+
if (desired.length > 0 && fs.existsSync(path.join(deps.hqRoot, ".hqinclude"))) {
|
|
225
|
+
for (const vault of desired)
|
|
226
|
+
held.push({ uid: vault.uid, reason: HQINCLUDE_HOLD });
|
|
227
|
+
desired.length = 0;
|
|
228
|
+
}
|
|
138
229
|
if (desired.length > 0) {
|
|
139
230
|
if (deps.release === undefined && deps.readPin) {
|
|
140
231
|
const pin = await deps.readPin();
|
|
@@ -177,6 +268,7 @@ export async function reconcileSyncCore(deps) {
|
|
|
177
268
|
let personalOff = false;
|
|
178
269
|
for (const vault of desired) {
|
|
179
270
|
const before = previousByUid.get(vault.uid);
|
|
271
|
+
const pending = before ? undefined : pendingByUid.get(vault.uid);
|
|
180
272
|
const engineHome = syncCoreEngineHome(deps.home, vault.uid);
|
|
181
273
|
if (!before)
|
|
182
274
|
clearEngineStatus(deps.home, vault.uid);
|
|
@@ -185,7 +277,11 @@ export async function reconcileSyncCore(deps) {
|
|
|
185
277
|
const alreadyOff = vault.kind === "personal"
|
|
186
278
|
? switchesBefore.personalOff
|
|
187
279
|
: switchesBefore.offCompanies.has(vault.slug ?? "");
|
|
188
|
-
const legacyAlreadyOff = wasFull
|
|
280
|
+
const legacyAlreadyOff = wasFull
|
|
281
|
+
? before.legacyAlreadyOff === true && (alreadyOff || switchesBefore.unreadable !== undefined)
|
|
282
|
+
: pending
|
|
283
|
+
? pending.legacyAlreadyOff === true && (alreadyOff || switchesBefore.unreadable !== undefined)
|
|
284
|
+
: alreadyOff || switchesBefore.unreadable !== undefined;
|
|
189
285
|
const legacyOffSince = (wasFull && alreadyOff ? before.legacyOffSince : undefined) ?? at;
|
|
190
286
|
let downloadStreams;
|
|
191
287
|
if (vault.kind === "company" && deps.readDownloadStreams) {
|
|
@@ -231,7 +327,7 @@ export async function reconcileSyncCore(deps) {
|
|
|
231
327
|
}
|
|
232
328
|
const stopped = [];
|
|
233
329
|
const handover = [];
|
|
234
|
-
|
|
330
|
+
const handedBack = [];
|
|
235
331
|
for (const vault of previousByUid.values()) {
|
|
236
332
|
if (desired.some((candidate) => candidate.uid === vault.uid))
|
|
237
333
|
continue;
|
|
@@ -242,11 +338,14 @@ export async function reconcileSyncCore(deps) {
|
|
|
242
338
|
const heldDeletes = readEngineHeldDeletes(engineHome, vault.uid);
|
|
243
339
|
if (heldDeletes)
|
|
244
340
|
handover.push(heldDeletesHandoverLine(vault.uid, heldDeletes, engineHome));
|
|
245
|
-
|
|
246
|
-
companies[vault.slug] = true;
|
|
247
|
-
else
|
|
248
|
-
personalBackOn = true;
|
|
341
|
+
handedBack.push(vault);
|
|
249
342
|
}
|
|
343
|
+
const handingBack = [
|
|
344
|
+
...handedBack,
|
|
345
|
+
...[...pendingByUid.values()].filter((vault) => !desired.some((candidate) => candidate.uid === vault.uid)
|
|
346
|
+
&& !handedBack.some((back) => back.uid === vault.uid)
|
|
347
|
+
&& engineOwnsVault(deps.home, vault.uid)),
|
|
348
|
+
];
|
|
250
349
|
const state = {
|
|
251
350
|
version: 1,
|
|
252
351
|
rolloutFlagKey: SYNC_RUST_ENGINE_ROLLOUT_FLAG,
|
|
@@ -254,15 +353,18 @@ export async function reconcileSyncCore(deps) {
|
|
|
254
353
|
release: installedRelease ?? release,
|
|
255
354
|
binaryPath,
|
|
256
355
|
vaults,
|
|
356
|
+
...(handingBack.length > 0 ? { handingBack } : {}),
|
|
257
357
|
...(skipped.length > 0 ? { skipped } : {}),
|
|
258
358
|
...(held.length > 0 ? { held } : {}),
|
|
259
359
|
...(warnings.length > 0 ? { error: warnings.join("; ") } : {}),
|
|
260
360
|
};
|
|
261
361
|
writeSyncCoreRolloutState(deps.home, state);
|
|
262
|
-
for (const uid of stopped)
|
|
263
|
-
|
|
362
|
+
for (const uid of stopped) {
|
|
363
|
+
if (!handedBack.some((vault) => vault.uid === uid))
|
|
364
|
+
removeEngineOwnership(deps.home, uid);
|
|
365
|
+
}
|
|
264
366
|
const patch = {
|
|
265
|
-
...(personalOff ? { personal: false } :
|
|
367
|
+
...(personalOff ? { personal: false } : {}),
|
|
266
368
|
companies,
|
|
267
369
|
};
|
|
268
370
|
try {
|
|
@@ -278,8 +380,11 @@ export async function reconcileSyncCore(deps) {
|
|
|
278
380
|
log(`${uid}: moving to the new sync engine in full mode (home ${syncCoreEngineHome(deps.home, uid)})`);
|
|
279
381
|
for (const uid of promoted)
|
|
280
382
|
log(`${uid}: moving from the read-only index to full mode on the new sync engine`);
|
|
281
|
-
for (const uid of stopped)
|
|
282
|
-
log(
|
|
383
|
+
for (const uid of stopped) {
|
|
384
|
+
log(handedBack.some((vault) => vault.uid === uid)
|
|
385
|
+
? `${uid}: back on the current sync once its engine has stopped`
|
|
386
|
+
: `${uid}: back on the current sync`);
|
|
387
|
+
}
|
|
283
388
|
for (const line of handover)
|
|
284
389
|
log(line);
|
|
285
390
|
for (const skip of skipped)
|
|
@@ -18,6 +18,8 @@ export interface SyncCoreRolloutState {
|
|
|
18
18
|
release: string;
|
|
19
19
|
binaryPath: string;
|
|
20
20
|
vaults: RolloutVault[];
|
|
21
|
+
/** Full vaults leaving the engine. The daemon returns each to the current sync once its engine has stopped. */
|
|
22
|
+
handingBack?: RolloutVault[];
|
|
21
23
|
skipped?: {
|
|
22
24
|
uid: string;
|
|
23
25
|
reason: string;
|
|
@@ -135,6 +135,11 @@ function parseRolloutState(raw) {
|
|
|
135
135
|
const vaults = obj.vaults.map(vault);
|
|
136
136
|
if (vaults.some((v) => v === null))
|
|
137
137
|
return null;
|
|
138
|
+
if (obj.handingBack !== undefined && !Array.isArray(obj.handingBack))
|
|
139
|
+
return null;
|
|
140
|
+
const handingBack = (obj.handingBack ?? []).map(vault);
|
|
141
|
+
if (handingBack.some((v) => v === null))
|
|
142
|
+
return null;
|
|
138
143
|
const skipped = skippedEntries(obj.skipped);
|
|
139
144
|
if (skipped === null)
|
|
140
145
|
return null;
|
|
@@ -148,6 +153,7 @@ function parseRolloutState(raw) {
|
|
|
148
153
|
release: obj.release,
|
|
149
154
|
binaryPath: obj.binaryPath,
|
|
150
155
|
vaults: vaults,
|
|
156
|
+
...(handingBack.length > 0 ? { handingBack: handingBack } : {}),
|
|
151
157
|
...(skipped.length > 0 ? { skipped } : {}),
|
|
152
158
|
...(held.length > 0 ? { held } : {}),
|
|
153
159
|
...(typeof obj.error === "string" ? { error: obj.error } : {}),
|
|
@@ -49,5 +49,19 @@ export interface VaultSyncSwitchPatch {
|
|
|
49
49
|
personal?: boolean;
|
|
50
50
|
companies?: Record<string, boolean>;
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* The patch that turns the old-sync switch back on for vaults leaving the new
|
|
54
|
+
* sync engine. A vault whose switch was already off before HQ moved it
|
|
55
|
+
* (`legacyAlreadyOff`) stays off. With `switches`, only switches that read off
|
|
56
|
+
* are included.
|
|
57
|
+
*/
|
|
58
|
+
export declare function legacySwitchRestorePatch(vaults: readonly {
|
|
59
|
+
kind: "personal" | "company";
|
|
60
|
+
slug?: string;
|
|
61
|
+
legacyAlreadyOff?: boolean;
|
|
62
|
+
}[], switches?: Pick<VaultSyncSwitches, "personalOff" | "offCompanies">): {
|
|
63
|
+
personal?: true;
|
|
64
|
+
companies: Record<string, boolean>;
|
|
65
|
+
};
|
|
52
66
|
export declare function writeVaultSyncSwitches(home: string, patch: VaultSyncSwitchPatch): boolean;
|
|
53
67
|
//# sourceMappingURL=vault-sync-switches.d.ts.map
|
|
@@ -122,6 +122,28 @@ function recordSwitchOnTimes(home, turnedOn, turnedOff, at) {
|
|
|
122
122
|
fs.writeFileSync(tmp, `${JSON.stringify(times)}\n`, { mode: 0o600 });
|
|
123
123
|
fs.renameSync(tmp, file);
|
|
124
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* The patch that turns the old-sync switch back on for vaults leaving the new
|
|
127
|
+
* sync engine. A vault whose switch was already off before HQ moved it
|
|
128
|
+
* (`legacyAlreadyOff`) stays off. With `switches`, only switches that read off
|
|
129
|
+
* are included.
|
|
130
|
+
*/
|
|
131
|
+
export function legacySwitchRestorePatch(vaults, switches) {
|
|
132
|
+
let personal = false;
|
|
133
|
+
const companies = {};
|
|
134
|
+
for (const vault of vaults) {
|
|
135
|
+
if (vault.legacyAlreadyOff)
|
|
136
|
+
continue;
|
|
137
|
+
if (vault.kind === "company" && vault.slug) {
|
|
138
|
+
if (!switches || switches.offCompanies.has(vault.slug))
|
|
139
|
+
companies[vault.slug] = true;
|
|
140
|
+
}
|
|
141
|
+
else if (vault.kind === "personal" && (!switches || switches.personalOff)) {
|
|
142
|
+
personal = true;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return { ...(personal ? { personal: true } : {}), companies };
|
|
146
|
+
}
|
|
125
147
|
export function writeVaultSyncSwitches(home, patch) {
|
|
126
148
|
const file = vaultSyncSettingsPath(home);
|
|
127
149
|
let prefs = {};
|
|
@@ -28,7 +28,7 @@ export interface GenerateWorkersRegistryResult {
|
|
|
28
28
|
* (`.codex/worktrees/<name>/`) are the same trap in a different folder: a
|
|
29
29
|
* nested HQ root under a company project. Those copies land in the registry as
|
|
30
30
|
* `companies/<slug>/…/.claude/worktrees/…` or `.codex/worktrees/…` paths, so
|
|
31
|
-
* `hq
|
|
31
|
+
* `hq runners create` then fails with `worker_tenancy_unresolved`. HQ's own
|
|
32
32
|
* `workspace/worktrees/<name>/` is the same shape.
|
|
33
33
|
*
|
|
34
34
|
* `node_modules` and `.git` never hold workers and are large, so they are
|
|
@@ -164,7 +164,7 @@ function withoutTimestamp(content) {
|
|
|
164
164
|
* (`.codex/worktrees/<name>/`) are the same trap in a different folder: a
|
|
165
165
|
* nested HQ root under a company project. Those copies land in the registry as
|
|
166
166
|
* `companies/<slug>/…/.claude/worktrees/…` or `.codex/worktrees/…` paths, so
|
|
167
|
-
* `hq
|
|
167
|
+
* `hq runners create` then fails with `worker_tenancy_unresolved`. HQ's own
|
|
168
168
|
* `workspace/worktrees/<name>/` is the same shape.
|
|
169
169
|
*
|
|
170
170
|
* `node_modules` and `.git` never hold workers and are large, so they are
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface GitHubLookupDeps {
|
|
2
|
+
fetchImpl?: typeof fetch;
|
|
3
|
+
lsRemote?: (repo: string, refsOnly: boolean) => Promise<string>;
|
|
4
|
+
warn?: (message: string) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare class GitHubApiUnavailable extends Error {
|
|
7
|
+
}
|
|
8
|
+
export declare function isTransientGitHubStatus(status: number): boolean;
|
|
9
|
+
/** No shell: git.exe is resolved from PATH on Windows, just as git is on Unix. */
|
|
10
|
+
export declare function readRemoteTags(repo: string, refsOnly: boolean): Promise<string>;
|
|
11
|
+
export declare function highestReleaseTag(output: string): string;
|
|
12
|
+
/** One scope per command; latest and floor lookups must share this callback. */
|
|
13
|
+
export declare function onceWarning(warn?: (message: string) => void): (message: string) => void;
|
|
14
|
+
export declare function remoteTagSha(output: string, tag: string): string;
|
|
15
|
+
export declare function withGitTagFallback<T>(api: () => Promise<T>, repo: string, tag: string | undefined, select: (output: string) => T, deps: GitHubLookupDeps): Promise<T>;
|
|
16
|
+
//# sourceMappingURL=github-tag-fallback.d.ts.map
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
export class GitHubApiUnavailable extends Error {
|
|
3
|
+
}
|
|
4
|
+
export function isTransientGitHubStatus(status) {
|
|
5
|
+
return status === 403 || status === 429 || (status >= 500 && status <= 599);
|
|
6
|
+
}
|
|
7
|
+
/** No shell: git.exe is resolved from PATH on Windows, just as git is on Unix. */
|
|
8
|
+
export function readRemoteTags(repo, refsOnly) {
|
|
9
|
+
if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repo)) {
|
|
10
|
+
return Promise.reject(new Error('expected a GitHub owner/repository'));
|
|
11
|
+
}
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
execFile('git', ['ls-remote', '--tags', ...(refsOnly ? ['--refs'] : []),
|
|
14
|
+
'https://github.com/' + repo + '.git'], {
|
|
15
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0', GCM_INTERACTIVE: 'Never' },
|
|
16
|
+
timeout: 30_000, maxBuffer: 16 * 1024 * 1024, windowsHide: true,
|
|
17
|
+
encoding: 'utf8',
|
|
18
|
+
}, (error, stdout) => {
|
|
19
|
+
// Credential helpers can include sensitive values in stderr.
|
|
20
|
+
if (error)
|
|
21
|
+
reject(new Error('git could not read remote tags (exit ' + String(error.code ?? 'unknown') + ')'));
|
|
22
|
+
else
|
|
23
|
+
resolve(stdout);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function parseRefs(output) {
|
|
28
|
+
const refs = new Map();
|
|
29
|
+
for (const line of output.split(/\r?\n/)) {
|
|
30
|
+
const match = /^([0-9a-f]{40})\s+refs\/tags\/(\S+)$/.exec(line.trim());
|
|
31
|
+
if (match)
|
|
32
|
+
refs.set(match[2], match[1]);
|
|
33
|
+
}
|
|
34
|
+
return refs;
|
|
35
|
+
}
|
|
36
|
+
const STRICT_RELEASE_TAG = /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
|
|
37
|
+
function sortedReleaseTags(output) {
|
|
38
|
+
const tags = [...parseRefs(output).keys()].filter(tag => STRICT_RELEASE_TAG.test(tag));
|
|
39
|
+
tags.sort((a, b) => {
|
|
40
|
+
const left = a.slice(1).split('.').map(BigInt);
|
|
41
|
+
const right = b.slice(1).split('.').map(BigInt);
|
|
42
|
+
for (let i = 0; i < 3; i++) {
|
|
43
|
+
if (left[i] !== right[i])
|
|
44
|
+
return left[i] > right[i] ? -1 : 1;
|
|
45
|
+
}
|
|
46
|
+
return 0;
|
|
47
|
+
});
|
|
48
|
+
return tags;
|
|
49
|
+
}
|
|
50
|
+
export function highestReleaseTag(output) {
|
|
51
|
+
const tag = sortedReleaseTags(output)[0];
|
|
52
|
+
if (!tag)
|
|
53
|
+
throw new Error('no strict vMAJOR.MINOR.PATCH tags found');
|
|
54
|
+
return tag;
|
|
55
|
+
}
|
|
56
|
+
/** One scope per command; latest and floor lookups must share this callback. */
|
|
57
|
+
export function onceWarning(warn = console.warn) {
|
|
58
|
+
let warned = false;
|
|
59
|
+
return message => {
|
|
60
|
+
if (!warned) {
|
|
61
|
+
warned = true;
|
|
62
|
+
warn(message);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async function publishedReleaseTag(repo, deps) {
|
|
67
|
+
if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repo))
|
|
68
|
+
throw new Error('expected a GitHub owner/repository');
|
|
69
|
+
const base = `https://github.com/${repo}`;
|
|
70
|
+
const request = (url, method) => (deps.fetchImpl ?? fetch)(url, {
|
|
71
|
+
method, redirect: 'manual', signal: AbortSignal.timeout(3_000),
|
|
72
|
+
});
|
|
73
|
+
try {
|
|
74
|
+
const response = await request(`${base}/releases/latest`, 'GET');
|
|
75
|
+
const location = response.headers.get('location');
|
|
76
|
+
if (response.status === 302 && location) {
|
|
77
|
+
const target = new URL(location, base);
|
|
78
|
+
const prefix = `/${repo}/releases/tag/`;
|
|
79
|
+
const tag = target.pathname.slice(prefix.length);
|
|
80
|
+
if (target.origin === 'https://github.com' && target.pathname.startsWith(prefix)
|
|
81
|
+
&& !target.search && !target.hash && STRICT_RELEASE_TAG.test(tag))
|
|
82
|
+
return tag;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch { /* Try bounded publication checks when the web pointer is unavailable. */ }
|
|
86
|
+
const tags = sortedReleaseTags(await (deps.lsRemote ?? readRemoteTags)(repo, true));
|
|
87
|
+
// A tag alone is not evidence of publication: release validation runs after tagging.
|
|
88
|
+
for (const tag of tags.slice(0, 5)) {
|
|
89
|
+
try {
|
|
90
|
+
const response = await request(`${base}/releases/download/${tag}/hq-core-${tag}.tar.gz`, 'HEAD');
|
|
91
|
+
if (response.status === 200 || response.status === 302)
|
|
92
|
+
return tag;
|
|
93
|
+
}
|
|
94
|
+
catch { /* A timeout/network failure cannot establish publication. */ }
|
|
95
|
+
}
|
|
96
|
+
throw new Error('no published release found among the five newest stable tags');
|
|
97
|
+
}
|
|
98
|
+
export function remoteTagSha(output, tag) {
|
|
99
|
+
const refs = parseRefs(output);
|
|
100
|
+
const sha = refs.get(tag + '^{}') ?? refs.get(tag);
|
|
101
|
+
if (!sha)
|
|
102
|
+
throw new Error('tag ' + tag + ' not found in remote tags');
|
|
103
|
+
return sha;
|
|
104
|
+
}
|
|
105
|
+
export async function withGitTagFallback(api, repo, tag, select, deps) {
|
|
106
|
+
try {
|
|
107
|
+
return await api();
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
if (!(error instanceof GitHubApiUnavailable))
|
|
111
|
+
throw error;
|
|
112
|
+
let result;
|
|
113
|
+
try {
|
|
114
|
+
result = select(tag === undefined
|
|
115
|
+
? await publishedReleaseTag(repo, deps)
|
|
116
|
+
: await (deps.lsRemote ?? readRemoteTags)(repo, false));
|
|
117
|
+
}
|
|
118
|
+
catch (gitError) {
|
|
119
|
+
throw new Error(error.message + '; git ls-remote fallback failed: ' +
|
|
120
|
+
(gitError instanceof Error ? gitError.message : 'unknown error'));
|
|
121
|
+
}
|
|
122
|
+
(deps.warn ?? console.warn)('GitHub API is unavailable; using the published release fallback.');
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=github-tag-fallback.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type GitHubLookupDeps } from "./github-tag-fallback.js";
|
|
1
2
|
export declare const HQ_CORE_LATEST_URL = "https://api.github.com/repos/indigoai-us/hq-core/releases/latest";
|
|
2
3
|
export declare const LATEST_FETCH_TIMEOUT_MS = 3000;
|
|
3
4
|
export type LatestLookup = "ok" | "network-error";
|
|
@@ -16,7 +17,7 @@ export interface VersionReportDeps {
|
|
|
16
17
|
printUpdateNudge?: (stderr: Pick<NodeJS.WriteStream, "write">) => Promise<void>;
|
|
17
18
|
}
|
|
18
19
|
export declare function normalizeHqCoreTag(tag: string): string | null;
|
|
19
|
-
export declare function fetchLatestHqCoreRelease(fetchImpl?: typeof fetch, timeoutMs?: number, token?: string | undefined): Promise<string | null>;
|
|
20
|
+
export declare function fetchLatestHqCoreRelease(fetchImpl?: typeof fetch, timeoutMs?: number, token?: string | undefined, deps?: GitHubLookupDeps): Promise<string | null>;
|
|
20
21
|
export declare function collectVersionReport(deps?: VersionReportDeps): Promise<VersionReport>;
|
|
21
22
|
export declare function formatVersionReport(report: VersionReport): string;
|
|
22
23
|
export declare function versionReportJson(report: VersionReport): string;
|
|
@@ -14,40 +14,53 @@ import { wantsJson } from "../version-request.js";
|
|
|
14
14
|
import { findHqRoot } from "./manifest.js";
|
|
15
15
|
import { readHqVersion } from "./hq-core-yaml.js";
|
|
16
16
|
import { resolveGhToken } from "./shipped-codex-hooks.js";
|
|
17
|
+
import { GitHubApiUnavailable, isTransientGitHubStatus, withGitTagFallback } from "./github-tag-fallback.js";
|
|
17
18
|
export const HQ_CORE_LATEST_URL = "https://api.github.com/repos/indigoai-us/hq-core/releases/latest";
|
|
18
19
|
export const LATEST_FETCH_TIMEOUT_MS = 3_000;
|
|
19
20
|
export function normalizeHqCoreTag(tag) {
|
|
20
21
|
const version = tag.trim().replace(/^v/i, "");
|
|
21
22
|
return semver.valid(version) ? version : null;
|
|
22
23
|
}
|
|
23
|
-
export async function fetchLatestHqCoreRelease(fetchImpl = fetch, timeoutMs = LATEST_FETCH_TIMEOUT_MS, token = resolveGhToken()) {
|
|
24
|
+
export async function fetchLatestHqCoreRelease(fetchImpl = fetch, timeoutMs = LATEST_FETCH_TIMEOUT_MS, token = resolveGhToken(), deps = {}) {
|
|
24
25
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
26
|
+
return await withGitTagFallback(async () => {
|
|
27
|
+
try {
|
|
28
|
+
const headers = {
|
|
29
|
+
Accept: "application/vnd.github+json",
|
|
30
|
+
"User-Agent": "hq-cli-version",
|
|
31
|
+
"X-GitHub-Api-Version": "2022-11-28",
|
|
32
|
+
};
|
|
33
|
+
if (token)
|
|
34
|
+
headers.Authorization = `Bearer ${token}`;
|
|
35
|
+
let res = await fetchImpl(HQ_CORE_LATEST_URL, {
|
|
36
|
+
headers,
|
|
37
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
38
|
+
});
|
|
39
|
+
// hq-core is public. A stale GH_TOKEN 401/403 should not hide the anonymous
|
|
40
|
+
// lookup that used to work.
|
|
41
|
+
if (token && (res.status === 401 || res.status === 403)) {
|
|
42
|
+
const { Authorization: _drop, ...anonHeaders } = headers;
|
|
43
|
+
res = await fetchImpl(HQ_CORE_LATEST_URL, {
|
|
44
|
+
headers: anonHeaders,
|
|
45
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (isTransientGitHubStatus(res.status)) {
|
|
49
|
+
throw new GitHubApiUnavailable(`GitHub releases/latest for indigoai-us/hq-core: HTTP ${res.status}`);
|
|
50
|
+
}
|
|
51
|
+
if (!res.ok)
|
|
52
|
+
return null;
|
|
53
|
+
const body = (await res.json());
|
|
54
|
+
if (typeof body.tag_name !== "string")
|
|
55
|
+
return null;
|
|
56
|
+
return normalizeHqCoreTag(body.tag_name);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (error instanceof GitHubApiUnavailable)
|
|
60
|
+
throw error;
|
|
61
|
+
throw new GitHubApiUnavailable('GitHub release request failed on the network or timed out', { cause: error });
|
|
62
|
+
}
|
|
63
|
+
}, 'indigoai-us/hq-core', undefined, normalizeHqCoreTag, { ...deps, fetchImpl });
|
|
51
64
|
}
|
|
52
65
|
catch {
|
|
53
66
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indigoai-us/hq-cli",
|
|
3
|
-
"version": "5.345.
|
|
3
|
+
"version": "5.345.242",
|
|
4
4
|
"description": "HQ by Indigo management CLI — modules and cloud sync",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@aws-sdk/client-iot-data-plane": "^3.1096.0",
|
|
64
64
|
"@aws-sdk/client-s3": "^3.1049.0",
|
|
65
65
|
"@aws-sdk/dsql-signer": "^3.1146.0",
|
|
66
|
-
"@indigoai-us/hq-cloud": "6.18.
|
|
66
|
+
"@indigoai-us/hq-cloud": "6.18.118",
|
|
67
67
|
"@indigoai-us/hq-flags-client": "^0.2.0",
|
|
68
68
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
69
69
|
"@sentry/node": "^10.49.0",
|
|
@@ -126,11 +126,11 @@
|
|
|
126
126
|
"*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}": "eslint --cache --no-error-on-unmatched-pattern"
|
|
127
127
|
},
|
|
128
128
|
"optionalDependencies": {
|
|
129
|
-
"@indigoai-us/hq-hook-win32-x64": "5.345.
|
|
130
|
-
"@indigoai-us/hq-hook-win32-arm64": "5.345.
|
|
131
|
-
"@indigoai-us/hq-hook-darwin-x64": "5.345.
|
|
132
|
-
"@indigoai-us/hq-hook-darwin-arm64": "5.345.
|
|
133
|
-
"@indigoai-us/hq-hook-linux-x64": "5.345.
|
|
134
|
-
"@indigoai-us/hq-hook-linux-arm64": "5.345.
|
|
129
|
+
"@indigoai-us/hq-hook-win32-x64": "5.345.242",
|
|
130
|
+
"@indigoai-us/hq-hook-win32-arm64": "5.345.242",
|
|
131
|
+
"@indigoai-us/hq-hook-darwin-x64": "5.345.242",
|
|
132
|
+
"@indigoai-us/hq-hook-darwin-arm64": "5.345.242",
|
|
133
|
+
"@indigoai-us/hq-hook-linux-x64": "5.345.242",
|
|
134
|
+
"@indigoai-us/hq-hook-linux-arm64": "5.345.242"
|
|
135
135
|
}
|
|
136
136
|
}
|