@indigoai-us/hq-cli 5.345.238 → 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 +74 -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/hq-delegate-repo.sh +7 -1
- package/assets/scaffold/core/scripts/hq-delegate-secrets.sh +95 -20
- package/assets/scaffold/core/scripts/hq-delegate-transfer.sh +57 -9
- package/assets/scaffold/core/scripts/lib/delegate-engine.sh +77 -0
- package/dist/command-catalog.generated.d.ts +212 -10
- package/dist/command-catalog.generated.js +260 -10
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/cloud-off-gate.d.ts +9 -8
- package/dist/commands/cloud-off-gate.js +41 -40
- package/dist/commands/cloud.d.ts +17 -2
- package/dist/commands/cloud.js +126 -24
- package/dist/commands/core-delegate-w1b.js +333 -27
- package/dist/commands/core-delegate.d.ts +2 -1
- package/dist/commands/core-delegate.js +209 -48
- 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/deploy-comments.js +8 -2
- package/dist/commands/deploy-events.d.ts +40 -0
- package/dist/commands/deploy-events.js +300 -0
- package/dist/commands/doctor.d.ts +4 -4
- package/dist/commands/doctor.js +2 -2
- package/dist/commands/feedback.js +2 -3
- 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/keyed-sync-pull.d.ts +12 -0
- package/dist/commands/keyed-sync-pull.js +151 -0
- 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/library-add.d.ts +5 -2
- package/dist/commands/library-add.js +22 -9
- package/dist/commands/mcp-registration.d.ts +4 -18
- package/dist/commands/mcp-registration.js +9 -29
- package/dist/commands/mesh.d.ts +4 -0
- package/dist/commands/mesh.js +25 -5
- package/dist/commands/pack-install.d.ts +2 -3
- package/dist/commands/pack-install.js +6 -8
- 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/secrets.d.ts +3 -4
- package/dist/commands/secrets.js +3 -20
- 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 +1830 -1468
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/bot/api.d.ts +2 -1
- package/dist/lib/bot/api.js +2 -15
- package/dist/lib/capacity/accounts.d.ts +1 -1
- package/dist/lib/capacity/accounts.js +1 -1
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +0 -2
- package/dist/lib/capacity/collectors/claude-oauth.js +0 -5
- 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/core-utils/delegate-helper-paths.d.ts +26 -0
- package/dist/lib/core-utils/delegate-helper-paths.js +33 -0
- 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/jq-provision.d.ts +63 -0
- package/dist/lib/daemon/jq-provision.js +155 -0
- package/dist/lib/daemon/lanes-reconcile-guard.d.ts +4 -3
- package/dist/lib/daemon/lanes-reconcile-guard.js +4 -4
- package/dist/lib/daemon/mesh-owner.d.ts +4 -0
- package/dist/lib/daemon/mesh-owner.js +20 -0
- package/dist/lib/daemon/ops/policy.d.ts +3 -0
- package/dist/lib/daemon/ops/policy.js +32 -4
- package/dist/lib/daemon/run.js +17 -22
- package/dist/lib/daemon/server.d.ts +6 -0
- package/dist/lib/daemon/server.js +5 -0
- package/dist/lib/daemon/verified-jq.d.ts +96 -0
- package/dist/lib/daemon/verified-jq.js +337 -0
- package/dist/lib/doctor/checks/jq.js +16 -0
- package/dist/lib/doctor/deep/executor.d.ts +7 -0
- package/dist/lib/doctor/deep/executor.js +1 -1
- package/dist/lib/doctor/deep/parity.js +1 -27
- package/dist/lib/doctor/deep/sandbox.d.ts +2 -2
- package/dist/lib/doctor/deep/sandbox.js +3 -19
- package/dist/lib/doctor/fix/refresh-sync-handoff.js +52 -21
- package/dist/lib/doctor/fixtures/discover.d.ts +2 -0
- package/dist/lib/doctor/fixtures/discover.js +1 -1
- package/dist/lib/doctor/json-output.d.ts +1 -1
- package/dist/lib/doctor/registry.d.ts +6 -7
- package/dist/lib/doctor/registry.js +6 -7
- package/dist/lib/doctor/report.d.ts +9 -10
- package/dist/lib/doctor/report.js +4 -4
- 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/jq/install.d.ts +27 -0
- package/dist/lib/jq/install.js +156 -0
- 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/outpost-dispatch.d.ts +1 -1
- package/dist/lib/lanes/outpost-dispatch.js +13 -13
- package/dist/lib/lanes/outpost-pruner-install.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/mesh/live/daemon/doctor.js +7 -1
- package/dist/lib/mesh/live/daemon/install.d.ts +4 -0
- package/dist/lib/mesh/live/daemon/install.js +10 -0
- package/dist/lib/mesh/live/daemon/run.js +17 -0
- package/dist/lib/mesh/live/emit-retry.d.ts +20 -2
- package/dist/lib/mesh/live/emit-retry.js +57 -4
- package/dist/lib/mesh/live/emit.js +25 -4
- package/dist/lib/mesh/live/flush.d.ts +2 -0
- package/dist/lib/mesh/live/flush.js +21 -8
- package/dist/lib/mesh/live/spool.d.ts +9 -1
- package/dist/lib/mesh/live/spool.js +41 -29
- 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 +11 -1
- package/dist/lib/sync-core/rollout-state.js +40 -4
- package/dist/lib/vault-sync-switches.d.ts +14 -0
- package/dist/lib/vault-sync-switches.js +22 -0
- package/dist/lib/windows/jq.d.ts +4 -0
- package/dist/lib/windows/jq.js +10 -39
- package/dist/lib/workers-registry/index.d.ts +1 -1
- package/dist/lib/workers-registry/index.js +8 -12
- package/dist/utils/callback-port-busy.d.ts +2 -2
- package/dist/utils/callback-port-busy.js +2 -2
- package/dist/utils/cli-network-lifecycle.js +1 -0
- package/dist/utils/client-health-contract.d.ts +2 -0
- package/dist/utils/client-health-contract.js +1 -1
- package/dist/utils/client-health.js +1 -9
- package/dist/utils/cognito-config.js +5 -0
- package/dist/utils/cognito-session.d.ts +4 -6
- package/dist/utils/cognito-session.js +4 -24
- package/dist/utils/github-tag-fallback.d.ts +16 -0
- package/dist/utils/github-tag-fallback.js +126 -0
- package/dist/utils/incomplete-install-error.js +1 -11
- package/dist/utils/install-tree-torn.d.ts +11 -0
- package/dist/utils/install-tree-torn.js +1 -1
- package/dist/utils/resident-package-preload.js +2 -1
- package/dist/utils/version-report.d.ts +2 -1
- package/dist/utils/version-report.js +40 -27
- package/docs/anywhere-runtime.md +8 -0
- package/package.json +9 -9
|
@@ -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;
|
|
@@ -29,8 +31,16 @@ export interface SyncCoreRolloutState {
|
|
|
29
31
|
error?: string;
|
|
30
32
|
}
|
|
31
33
|
export declare function syncCoreRolloutStatePath(home: string): string;
|
|
32
|
-
|
|
34
|
+
type RolloutStateFailure = "is unreadable" | "contains invalid JSON" | "has an invalid format" | "has an unsupported version";
|
|
35
|
+
export declare class SyncCoreRolloutStateError extends Error {
|
|
36
|
+
constructor(reason: RolloutStateFailure);
|
|
37
|
+
}
|
|
38
|
+
/** Manual sync needs to distinguish an absent state from one it cannot trust. */
|
|
39
|
+
export declare function readSyncCoreRolloutState(home: string, { strict }?: {
|
|
40
|
+
strict?: boolean;
|
|
41
|
+
}): SyncCoreRolloutState | null;
|
|
33
42
|
export declare function engineVaultCount(home: string): number;
|
|
34
43
|
export declare function readSyncCoreRolloutStateFile(file: string): SyncCoreRolloutState | null;
|
|
35
44
|
export declare function writeSyncCoreRolloutState(home: string, state: SyncCoreRolloutState): void;
|
|
45
|
+
export {};
|
|
36
46
|
//# sourceMappingURL=rollout-state.d.ts.map
|
|
@@ -81,20 +81,50 @@ function vault(value) {
|
|
|
81
81
|
...(streams !== undefined ? { downloadStreams: streams } : {}),
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
export
|
|
85
|
-
|
|
84
|
+
export class SyncCoreRolloutStateError extends Error {
|
|
85
|
+
constructor(reason) {
|
|
86
|
+
super(`Manual sync stopped: sync rollout.json ${reason}. Restore a valid rollout state before retrying.`);
|
|
87
|
+
this.name = "SyncCoreRolloutStateError";
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** Manual sync needs to distinguish an absent state from one it cannot trust. */
|
|
91
|
+
export function readSyncCoreRolloutState(home, { strict = false } = {}) {
|
|
92
|
+
return readRolloutStateFile(syncCoreRolloutStatePath(home), strict);
|
|
86
93
|
}
|
|
87
94
|
export function engineVaultCount(home) {
|
|
88
95
|
return readSyncCoreRolloutState(home)?.vaults.filter((vault) => vault.phase === "full").length ?? 0;
|
|
89
96
|
}
|
|
90
97
|
export function readSyncCoreRolloutStateFile(file) {
|
|
98
|
+
return readRolloutStateFile(file, false);
|
|
99
|
+
}
|
|
100
|
+
function readRolloutStateFile(file, strict) {
|
|
101
|
+
function fail(reason) {
|
|
102
|
+
if (strict)
|
|
103
|
+
throw new SyncCoreRolloutStateError(reason);
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
let contents;
|
|
107
|
+
try {
|
|
108
|
+
contents = fs.readFileSync(file, "utf8");
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
if (error.code === "ENOENT")
|
|
112
|
+
return null;
|
|
113
|
+
return fail("is unreadable");
|
|
114
|
+
}
|
|
91
115
|
let raw;
|
|
92
116
|
try {
|
|
93
|
-
raw = JSON.parse(
|
|
117
|
+
raw = JSON.parse(contents);
|
|
94
118
|
}
|
|
95
119
|
catch {
|
|
96
|
-
return
|
|
120
|
+
return fail("contains invalid JSON");
|
|
121
|
+
}
|
|
122
|
+
if (raw && typeof raw === "object" && "version" in raw && raw.version !== 1) {
|
|
123
|
+
return fail("has an unsupported version");
|
|
97
124
|
}
|
|
125
|
+
return parseRolloutState(raw) ?? fail("has an invalid format");
|
|
126
|
+
}
|
|
127
|
+
function parseRolloutState(raw) {
|
|
98
128
|
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
99
129
|
return null;
|
|
100
130
|
const obj = raw;
|
|
@@ -105,6 +135,11 @@ export function readSyncCoreRolloutStateFile(file) {
|
|
|
105
135
|
const vaults = obj.vaults.map(vault);
|
|
106
136
|
if (vaults.some((v) => v === null))
|
|
107
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;
|
|
108
143
|
const skipped = skippedEntries(obj.skipped);
|
|
109
144
|
if (skipped === null)
|
|
110
145
|
return null;
|
|
@@ -118,6 +153,7 @@ export function readSyncCoreRolloutStateFile(file) {
|
|
|
118
153
|
release: obj.release,
|
|
119
154
|
binaryPath: obj.binaryPath,
|
|
120
155
|
vaults: vaults,
|
|
156
|
+
...(handingBack.length > 0 ? { handingBack: handingBack } : {}),
|
|
121
157
|
...(skipped.length > 0 ? { skipped } : {}),
|
|
122
158
|
...(held.length > 0 ? { held } : {}),
|
|
123
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 = {};
|
package/dist/lib/windows/jq.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ interface JqAsset {
|
|
|
3
3
|
name: string;
|
|
4
4
|
sha256: string;
|
|
5
5
|
}
|
|
6
|
+
export declare function windowsJqAsset(arch: string): {
|
|
7
|
+
url: string;
|
|
8
|
+
sha256: string;
|
|
9
|
+
} | null;
|
|
6
10
|
export declare function windowsJqPath(home?: string): string;
|
|
7
11
|
interface InstallOptions {
|
|
8
12
|
platform?: NodeJS.Platform;
|
package/dist/lib/windows/jq.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { mkdir, mkdtemp, rename, rm, writeFile } from "node:fs/promises";
|
|
4
1
|
import { homedir } from "node:os";
|
|
5
|
-
import {
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { installPinnedJq } from "../jq/install.js";
|
|
6
4
|
const version = "1.8.2";
|
|
7
5
|
const release = `https://github.com/jqlang/jq/releases/download/jq-${version}`;
|
|
8
6
|
export const WINDOWS_JQ_REPAIR = "hq doctor --fix-jq";
|
|
@@ -21,23 +19,14 @@ const assets = {
|
|
|
21
19
|
sha256: "a99cb668f95bdd788d9ee20529613b115e5d2a0d7f9127ee6976607e878558ba",
|
|
22
20
|
},
|
|
23
21
|
};
|
|
22
|
+
export function windowsJqAsset(arch) {
|
|
23
|
+
const asset = assets[arch];
|
|
24
|
+
return asset ? { url: `${release}/${asset.name}`, sha256: asset.sha256 } : null;
|
|
25
|
+
}
|
|
24
26
|
export function windowsJqPath(home = homedir()) {
|
|
25
27
|
// hq-core-staging #2047 adds this directory to hook PATH when it holds jq.exe.
|
|
26
28
|
return join(home, ".local", "bin", "jq.exe");
|
|
27
29
|
}
|
|
28
|
-
function digest(bytes) {
|
|
29
|
-
return createHash("sha256").update(bytes).digest("hex");
|
|
30
|
-
}
|
|
31
|
-
function matchesAsset(file, asset) {
|
|
32
|
-
try {
|
|
33
|
-
return digest(readFileSync(file)) === asset.sha256;
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
if (error.code === "ENOENT")
|
|
37
|
-
return false;
|
|
38
|
-
throw error;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
30
|
/** The npm lifecycle, global hook setup and doctor use the same Windows installer. */
|
|
42
31
|
export async function installWindowsJq({ platform = process.platform, arch = process.arch, home, fetch: download = fetch, asset = assets[arch], } = {}) {
|
|
43
32
|
if (platform !== "win32")
|
|
@@ -45,28 +34,10 @@ export async function installWindowsJq({ platform = process.platform, arch = pro
|
|
|
45
34
|
if (!asset)
|
|
46
35
|
throw new Error(`jq has no official Windows build for ${arch}.`);
|
|
47
36
|
const target = windowsJqPath(home);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
37
|
+
return installPinnedJq({
|
|
38
|
+
home: home ?? homedir(), target,
|
|
39
|
+
asset: { url: `${release}/${asset.name}`, sha256: asset.sha256 },
|
|
40
|
+
fetch: download,
|
|
52
41
|
});
|
|
53
|
-
if (!response.ok)
|
|
54
|
-
throw new Error(`jq download failed (HTTP ${response.status}).`);
|
|
55
|
-
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
56
|
-
if (digest(bytes) !== asset.sha256) {
|
|
57
|
-
throw new Error(`The SHA-256 of ${asset.name} did not match the pinned release checksum.`);
|
|
58
|
-
}
|
|
59
|
-
const dir = dirname(target);
|
|
60
|
-
await mkdir(dir, { recursive: true });
|
|
61
|
-
const staged = await mkdtemp(join(dir, ".hq-jq-"));
|
|
62
|
-
try {
|
|
63
|
-
const file = join(staged, "jq.exe");
|
|
64
|
-
await writeFile(file, bytes, { flag: "wx", mode: 0o755 });
|
|
65
|
-
await rename(file, target);
|
|
66
|
-
}
|
|
67
|
-
finally {
|
|
68
|
-
await rm(staged, { recursive: true, force: true });
|
|
69
|
-
}
|
|
70
|
-
return target;
|
|
71
42
|
}
|
|
72
43
|
//# sourceMappingURL=jq.js.map
|
|
@@ -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
|
|
@@ -117,10 +117,6 @@ function packAttribution(root, relativeDirectory) {
|
|
|
117
117
|
return '';
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
function quote(value) {
|
|
121
|
-
// Deliberately mirrors `${value//\"/\\\"}` in the source shell script.
|
|
122
|
-
return value.replace(/"/g, '\\"');
|
|
123
|
-
}
|
|
124
120
|
function isoSeconds(now) {
|
|
125
121
|
return now.toISOString().replace(/\.\d{3}Z$/, 'Z');
|
|
126
122
|
}
|
|
@@ -133,16 +129,16 @@ function registryText(now, entries) {
|
|
|
133
129
|
'', 'version: "5.0"', `generated_at: "${isoSeconds(now)}"`, '', 'workers:',
|
|
134
130
|
];
|
|
135
131
|
for (const entry of entries) {
|
|
136
|
-
lines.push(` - id:
|
|
137
|
-
lines.push(` path:
|
|
138
|
-
lines.push(` type:
|
|
132
|
+
lines.push(` - id: ${JSON.stringify(entry.id)}`);
|
|
133
|
+
lines.push(` path: ${JSON.stringify(entry.path)}`);
|
|
134
|
+
lines.push(` type: ${JSON.stringify(entry.type)}`);
|
|
139
135
|
lines.push(` visibility: "${entry.visibility}"`);
|
|
140
136
|
if (entry.team)
|
|
141
|
-
lines.push(` team:
|
|
137
|
+
lines.push(` team: ${JSON.stringify(entry.team)}`);
|
|
142
138
|
if (entry.company)
|
|
143
|
-
lines.push(` company:
|
|
144
|
-
lines.push(` status:
|
|
145
|
-
lines.push(` description:
|
|
139
|
+
lines.push(` company: ${JSON.stringify(entry.company)}`);
|
|
140
|
+
lines.push(` status: ${JSON.stringify(entry.status)}`);
|
|
141
|
+
lines.push(` description: ${JSON.stringify(entry.description)}`);
|
|
146
142
|
}
|
|
147
143
|
return `${lines.join('\n')}\n`;
|
|
148
144
|
}
|
|
@@ -168,7 +164,7 @@ function withoutTimestamp(content) {
|
|
|
168
164
|
* (`.codex/worktrees/<name>/`) are the same trap in a different folder: a
|
|
169
165
|
* nested HQ root under a company project. Those copies land in the registry as
|
|
170
166
|
* `companies/<slug>/…/.claude/worktrees/…` or `.codex/worktrees/…` paths, so
|
|
171
|
-
* `hq
|
|
167
|
+
* `hq runners create` then fails with `worker_tenancy_unresolved`. HQ's own
|
|
172
168
|
* `workspace/worktrees/<name>/` is the same shape.
|
|
173
169
|
*
|
|
174
170
|
* `node_modules` and `.git` never hold workers and are large, so they are
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** Fixed callback port for the loopback OAuth server when unset
|
|
2
|
-
export
|
|
1
|
+
/** Fixed callback port for the loopback OAuth server when unset. */
|
|
2
|
+
export { DEFAULT_COGNITO_CALLBACK_PORT as DEFAULT_CALLBACK_PORT } from "./cognito-callback-port.js";
|
|
3
3
|
/**
|
|
4
4
|
* The fixed, actionable remedy. Interpolates ONLY the numeric callback port (a
|
|
5
5
|
* bounded value drawn from config, never caller input or upstream error text),
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
// ONLY when err.code === 'EADDRINUSE' AND err.port equals the configured
|
|
37
37
|
// callback port, so an EADDRINUSE raised by any OTHER listener stays
|
|
38
38
|
// reportable (the boundary must never swallow a genuine listener defect).
|
|
39
|
-
/** Fixed callback port for the loopback OAuth server when unset
|
|
40
|
-
export
|
|
39
|
+
/** Fixed callback port for the loopback OAuth server when unset. */
|
|
40
|
+
export { DEFAULT_COGNITO_CALLBACK_PORT as DEFAULT_CALLBACK_PORT } from "./cognito-callback-port.js";
|
|
41
41
|
/** Node's errno code for a `listen()` against an address already in use. */
|
|
42
42
|
const EADDRINUSE = "EADDRINUSE";
|
|
43
43
|
/**
|
|
@@ -52,6 +52,7 @@ const SCHEDULED_SHORT_RUN_COMMANDS = [
|
|
|
52
52
|
["daemon", "service", "sync-core-manifest"],
|
|
53
53
|
["runners", "reconcile"],
|
|
54
54
|
["lanes", "reconcile"],
|
|
55
|
+
["runners", "outpost-pruner", "run"],
|
|
55
56
|
["lanes", "outpost-pruner", "run"],
|
|
56
57
|
["index", "sync"],
|
|
57
58
|
["core", "jobs", "reconcile"],
|
|
@@ -189,6 +189,8 @@ export declare class ClientHealthContractError extends Error {
|
|
|
189
189
|
readonly field: string;
|
|
190
190
|
constructor(code: ClientHealthContractErrorCode, field: string, detail?: string);
|
|
191
191
|
}
|
|
192
|
+
/** Same shape sync-auth-middleware.ts enforces on x-hq-*-version headers. */
|
|
193
|
+
export declare const SEMVER: RegExp;
|
|
192
194
|
/**
|
|
193
195
|
* Parse + validate one heartbeat. Unknown extra fields are ignored (additive
|
|
194
196
|
* tolerance); every consumed value fails closed on unsafe content.
|
|
@@ -166,7 +166,7 @@ export class ClientHealthContractError extends Error {
|
|
|
166
166
|
const INSTALLATION_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{7,63}$/;
|
|
167
167
|
const COMMAND_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{7,63}$/;
|
|
168
168
|
/** Same shape sync-auth-middleware.ts enforces on x-hq-*-version headers. */
|
|
169
|
-
const SEMVER = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
169
|
+
export const SEMVER = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
170
170
|
const ISO_UTC = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/;
|
|
171
171
|
/**
|
|
172
172
|
* Secret-shaped prefixes rejected outright even when the charset is otherwise
|
|
@@ -42,7 +42,7 @@ import { vaultApiFetch } from "./vault-api.js";
|
|
|
42
42
|
import { collectVersions } from "./feedback-versions.js";
|
|
43
43
|
import { resolveDaemonCliVersion } from "./daemon-cli-version.js";
|
|
44
44
|
import { isAuthError } from "./auth-error.js";
|
|
45
|
-
import { CLIENT_HEALTH_CONTRACT_VERSION, CLIENT_HEALTH_MAX_SYNC_ENGINE_VAULTS, parseClientHealthHeartbeat, } from "./client-health-contract.js";
|
|
45
|
+
import { CLIENT_HEALTH_CONTRACT_VERSION, CLIENT_HEALTH_MAX_SYNC_ENGINE_VAULTS, parseClientHealthHeartbeat, SEMVER, } from "./client-health-contract.js";
|
|
46
46
|
import { collectLocalFilesOverview } from "./local-files-overview.js";
|
|
47
47
|
import { readSyncCoreRolloutStateFile } from "../lib/sync-core/rollout-state.js";
|
|
48
48
|
/** Same bound as CLI telemetry: a heartbeat may never stall a command. */
|
|
@@ -91,14 +91,6 @@ export const JOURNAL_OBSERVER_HEAP_MB = 512;
|
|
|
91
91
|
export const JOURNAL_OBSERVER_TIMEOUT_MS = 20_000;
|
|
92
92
|
/** An observation lock older than this is treated as abandoned. */
|
|
93
93
|
const JOURNAL_OBSERVATION_LOCK_STALE_MS = 5 * 60_000;
|
|
94
|
-
/**
|
|
95
|
-
* Pre-filter mirror of the contract's SemVer shape (the contract keeps its
|
|
96
|
-
* validators private). A version failing this is DROPPED individually so one
|
|
97
|
-
* malformed component version (e.g. a hand-edited core.yaml) never suppresses
|
|
98
|
-
* the whole heartbeat; `parseClientHealthHeartbeat` remains the final
|
|
99
|
-
* fail-closed gate before anything crosses the wire.
|
|
100
|
-
*/
|
|
101
|
-
const SEMVER = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
102
94
|
const INSTALLATION_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{7,63}$/;
|
|
103
95
|
export function newInstallationId() {
|
|
104
96
|
// 32 lowercase hex chars: always starts alphanumeric, always in-charset,
|
|
@@ -10,6 +10,11 @@ export const DEFAULT_COGNITO = {
|
|
|
10
10
|
get port() {
|
|
11
11
|
return resolveCognitoCallbackPort(process.env.HQ_COGNITO_CALLBACK_PORT);
|
|
12
12
|
},
|
|
13
|
+
// Skip Cognito's Hosted UI — go straight to Google OAuth. The Cognito
|
|
14
|
+
// /oauth2/authorize endpoint honors `identity_provider` and performs an
|
|
15
|
+
// internal redirect, so the user never sees the (un-styleable) Hosted UI.
|
|
16
|
+
// Set HQ_COGNITO_IDENTITY_PROVIDER="" to fall back to the IdP picker for
|
|
17
|
+
// accounts that use email+password (admin-created users without Google).
|
|
13
18
|
identityProvider: process.env.HQ_COGNITO_IDENTITY_PROVIDER !== undefined
|
|
14
19
|
? process.env.HQ_COGNITO_IDENTITY_PROVIDER || undefined
|
|
15
20
|
: "Google",
|
|
@@ -8,9 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Defaults point at the shared vault-indigo-hq-prod Cognito pool (canonical
|
|
10
10
|
* post-2026-04-25 cutover; hq-dev remains the staging fallback via env
|
|
11
|
-
* overrides)
|
|
12
|
-
* CLI and the in-tree demo script stay drift-free. Override any of them via
|
|
13
|
-
* env:
|
|
11
|
+
* overrides), defined in cognito-config.ts. Override any of them via env:
|
|
14
12
|
*
|
|
15
13
|
* AWS_REGION — e.g. us-east-1
|
|
16
14
|
* HQ_COGNITO_DOMAIN — Cognito User Pool domain prefix
|
|
@@ -18,11 +16,12 @@
|
|
|
18
16
|
* HQ_COGNITO_CALLBACK_PORT — Loopback OAuth callback port
|
|
19
17
|
* HQ_VAULT_API_URL — vault-service API Gateway URL
|
|
20
18
|
*/
|
|
21
|
-
import { isExpiring, isMachineIdentity, type
|
|
19
|
+
import { isExpiring, isMachineIdentity, type CognitoTokens, type ClientInfo, type VaultServiceConfig } from "@indigoai-us/hq-cloud";
|
|
22
20
|
import { hasPersonCachedSession, isMachineCredsFileEnvSet, wantsMachineCognitoTokens, type CognitoTokenSource } from "./machine-principal-state.js";
|
|
23
21
|
import { HQ_MACHINE_TOKEN_STATE_DIR_ENV, loadMachineCachedTokens, machineTokenCacheFile, machineTokenStateDir } from "./machine-token-cache.js";
|
|
24
22
|
export { HQ_MACHINE_TOKEN_STATE_DIR_ENV, loadMachineCachedTokens, machineTokenCacheFile, machineTokenStateDir };
|
|
25
23
|
import { resolveDefaultHqRoot } from "./hq-root-resolver.js";
|
|
24
|
+
import { DEFAULT_COGNITO, DEFAULT_VAULT_API_URL } from "./cognito-config.js";
|
|
26
25
|
import { HQ_NO_BROWSER_LOGIN_ENV, type InteractiveCallerInput } from "./interactive-caller.js";
|
|
27
26
|
import { loadCachedTokens, personTokenCacheFile, readPersonTokenFile } from "./person-token-cache.js";
|
|
28
27
|
export { loadCachedTokens, personTokenCacheFile, readPersonTokenFile };
|
|
@@ -36,8 +35,7 @@ export type CognitoActorKind = "human" | "agent" | "unknown";
|
|
|
36
35
|
* Default: the work-mesh daemon state dir (`~/.hq/work-mesh/daemon`), so a
|
|
37
36
|
* machine mint never overwrites a person's `~/.hq/cognito-tokens.json`.
|
|
38
37
|
*/
|
|
39
|
-
export
|
|
40
|
-
export declare const DEFAULT_VAULT_API_URL: string;
|
|
38
|
+
export { DEFAULT_COGNITO, DEFAULT_VAULT_API_URL };
|
|
41
39
|
export { resolveDefaultHqRoot };
|
|
42
40
|
export declare const DEFAULT_HQ_ROOT: string;
|
|
43
41
|
/** Default machine-creds path hq-cloud also checks when the env is unset. */
|