@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
package/dist/commands/cloud.js
CHANGED
|
@@ -20,8 +20,9 @@ import { SERVER_OWNED_FOLDERS, findServerOwnedLocalOnly, } from "../lib/sync/ser
|
|
|
20
20
|
import chalk from "chalk";
|
|
21
21
|
import * as fs from "fs";
|
|
22
22
|
import * as path from "path";
|
|
23
|
-
import { share, getStateDir, listJournals, createIgnoreFilter, VaultClient, computePersonalVaultPaths, PERSONAL_VAULT_JOURNAL_SLUG, resolvePullScope, readSyncProgress, syncDoctor, } from "@indigoai-us/hq-cloud";
|
|
24
|
-
import { syncLeg } from "../utils/sync-operation-lock.js";
|
|
23
|
+
import { share, getStateDir, listJournals, createIgnoreFilter, VaultClient, computePersonalVaultPaths, PERSONAL_VAULT_JOURNAL_SLUG, resolvePullScope, readSyncProgress, syncDoctor, isTerminalIdentityRefusal, scopeLookupSkipMessage, SyncScopeLookupError, } from "@indigoai-us/hq-cloud";
|
|
24
|
+
import { syncLeg, syncUnderOperationLock } from "../utils/sync-operation-lock.js";
|
|
25
|
+
import { keyedSyncPull } from "./keyed-sync-pull.js";
|
|
25
26
|
import { SYNC_WATCHDOG_EXIT_CODE, SYNC_WATCHDOG_REPORT_GRACE_MS, SyncWatchdogTimeoutError, createSnapshotProgressProbe, resolveSyncWatchdogLimits, withSyncWatchdog, } from "../utils/sync-watchdog.js";
|
|
26
27
|
import { DEFAULT_HQ_ROOT, ensureCognitoToken, buildVaultConfig, IdentitySwapRefusal, cognitoCachePrincipalUid, isDefinitivePersonAuthRejection, isIdentitySwapRefusal, loadCachedTokens, refreshCachedSession, } from "../utils/cognito-session.js";
|
|
27
28
|
import { resolveUploadAuthor } from "../utils/upload-author.js";
|
|
@@ -258,6 +259,15 @@ export function formatSyncFailure(err, ctx = {}) {
|
|
|
258
259
|
isIdentitySwapRefusal(err)) {
|
|
259
260
|
return err.message;
|
|
260
261
|
}
|
|
262
|
+
if (err instanceof SyncScopeLookupError) {
|
|
263
|
+
// A session refusal on the lookup's first request reaches us wrapped and
|
|
264
|
+
// without its cause; the run's vault config recorded the refusal, which
|
|
265
|
+
// carries the sign-in fix. Otherwise the bounded skip line stands.
|
|
266
|
+
const recorded = SCOPE_LOOKUP_SESSION_REFUSAL_CLASSES.has(err.errorClass)
|
|
267
|
+
? syncAuthFailureFor(ctx.vaultConfig)
|
|
268
|
+
: null;
|
|
269
|
+
return recorded ? recorded.message : err.message;
|
|
270
|
+
}
|
|
261
271
|
if (isVaultAuthRejection(err)) {
|
|
262
272
|
// hq-cloud's 401 retry swallowed the token-function error; report it.
|
|
263
273
|
const recorded = syncAuthFailureFor(ctx.vaultConfig);
|
|
@@ -822,6 +832,49 @@ function isSkippedCompany(skip, slug, companyUid) {
|
|
|
822
832
|
return false;
|
|
823
833
|
return skip.has(slug.toLowerCase()) || skip.has(companyUid.toLowerCase());
|
|
824
834
|
}
|
|
835
|
+
// The skip message and error class come from hq-cloud (>= 6.18.117), whose
|
|
836
|
+
// resolvePullScope throws SyncScopeLookupError when a lookup fails. Re-exported
|
|
837
|
+
// so callers and tests match on the one class hq-cloud throws.
|
|
838
|
+
export { scopeLookupSkipMessage, SyncScopeLookupError };
|
|
839
|
+
/** An error's class name, or "UnknownError". hq-cloud bounds it further. */
|
|
840
|
+
function errorClassOf(err) {
|
|
841
|
+
return err instanceof Error ? err.name : "UnknownError";
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Auth refusals during a scope lookup. hq-cloud rethrows VaultAuthError and a
|
|
845
|
+
* terminal Cognito refusal unchanged; the CLI's own token getter throws the
|
|
846
|
+
* session and identity-swap refusals. These keep their sign-in message.
|
|
847
|
+
*/
|
|
848
|
+
function isScopeLookupAuthRefusal(err) {
|
|
849
|
+
return (err instanceof SyncSessionExpiredError ||
|
|
850
|
+
err instanceof SyncSessionRejectedError ||
|
|
851
|
+
isIdentitySwapRefusal(err) ||
|
|
852
|
+
isVaultAuthRejection(err) ||
|
|
853
|
+
isTerminalIdentityRefusal(err));
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* Session refusals from the CLI's token getter. When one is thrown on the
|
|
857
|
+
* lookup's first request, hq-cloud's resolver wraps it in a
|
|
858
|
+
* SyncScopeLookupError with no cause; the run's vault config still records
|
|
859
|
+
* the refusal itself.
|
|
860
|
+
*/
|
|
861
|
+
const SCOPE_LOOKUP_SESSION_REFUSAL_CLASSES = new Set([
|
|
862
|
+
"SyncSessionExpiredError",
|
|
863
|
+
"SyncSessionRejectedError",
|
|
864
|
+
"IdentitySwapRefusal",
|
|
865
|
+
]);
|
|
866
|
+
/**
|
|
867
|
+
* The per-company line for a failed scope lookup in `--all` runs. The company
|
|
868
|
+
* is skipped either way. A SyncScopeLookupError or an auth refusal goes
|
|
869
|
+
* through the run's failure formatter (the bounded skip line, or the sign-in
|
|
870
|
+
* fix); anything else gets the bounded skip line built here.
|
|
871
|
+
*/
|
|
872
|
+
function scopeLookupFailureMessage(company, err, formatFailure = formatSyncFailure) {
|
|
873
|
+
if (err instanceof SyncScopeLookupError || isScopeLookupAuthRefusal(err)) {
|
|
874
|
+
return formatFailure(err);
|
|
875
|
+
}
|
|
876
|
+
return scopeLookupSkipMessage(company, errorClassOf(err));
|
|
877
|
+
}
|
|
825
878
|
export async function pullAll(options, deps) {
|
|
826
879
|
const memberships = await deps.vaultClient.listMyMemberships();
|
|
827
880
|
const persons = await deps.vaultClient.listPersonEntities();
|
|
@@ -884,8 +937,10 @@ export async function pullAll(options, deps) {
|
|
|
884
937
|
// old code resolved the mode for the banner and then called sync() with NO
|
|
885
938
|
// scope, so every CLI pull ran `syncMode: "all"` and stamped an all-mode
|
|
886
939
|
// PullRecord that wedged the next menubar sync (all→shared scope-shrink).
|
|
887
|
-
// The shared `resolvePullScope` (via deps.resolveScope)
|
|
888
|
-
//
|
|
940
|
+
// The shared `resolvePullScope` (via deps.resolveScope) fails closed since
|
|
941
|
+
// hq-cloud 6.18.117: a failed or denied lookup throws (SyncScopeLookupError,
|
|
942
|
+
// or the auth refusal itself) instead of answering `all`. The company is
|
|
943
|
+
// then skipped (audit item 4): its leg never runs without a scope.
|
|
889
944
|
let resolvedMode;
|
|
890
945
|
if (entry.companyUid && deps.resolveScope) {
|
|
891
946
|
try {
|
|
@@ -902,8 +957,11 @@ export async function pullAll(options, deps) {
|
|
|
902
957
|
entry.syncOptions.excludePrefixes = excludePrefixes;
|
|
903
958
|
}
|
|
904
959
|
}
|
|
905
|
-
catch {
|
|
906
|
-
|
|
960
|
+
catch (err) {
|
|
961
|
+
const message = scopeLookupFailureMessage(entry.slug, err, deps.formatFailure);
|
|
962
|
+
result.errors.push({ company: entry.slug, message });
|
|
963
|
+
result.perCompany.push({ slug: entry.slug, error: message });
|
|
964
|
+
continue;
|
|
907
965
|
}
|
|
908
966
|
}
|
|
909
967
|
else if (entry.membershipKey && getSyncConfig) {
|
|
@@ -1048,8 +1106,13 @@ export async function pushAll(options, deps) {
|
|
|
1048
1106
|
entry.shareOptions.prefixSet = scope.prefixSet;
|
|
1049
1107
|
}
|
|
1050
1108
|
}
|
|
1051
|
-
catch {
|
|
1052
|
-
//
|
|
1109
|
+
catch (err) {
|
|
1110
|
+
// Audit item 4: skip this company. share() treats a missing prefixSet
|
|
1111
|
+
// as full access, so pushing on would widen the upload.
|
|
1112
|
+
const message = scopeLookupFailureMessage(entry.slug, err, deps.formatFailure);
|
|
1113
|
+
result.errors.push({ company: entry.slug, message });
|
|
1114
|
+
result.perCompany.push({ slug: entry.slug, error: message });
|
|
1115
|
+
continue;
|
|
1053
1116
|
}
|
|
1054
1117
|
}
|
|
1055
1118
|
try {
|
|
@@ -1237,11 +1300,14 @@ function readActiveCompany(hqRoot) {
|
|
|
1237
1300
|
* "all"` and stamped an all-mode PullRecord that wedged the next menubar sync.
|
|
1238
1301
|
*
|
|
1239
1302
|
* Delegates to the shared `resolvePullScope` (same resolver the runner uses),
|
|
1240
|
-
* which
|
|
1241
|
-
*
|
|
1242
|
-
* `
|
|
1303
|
+
* which fails closed since hq-cloud 6.18.117. Returns `undefined` only when no
|
|
1304
|
+
* company is named or active (then `sync()` resolves the active company itself
|
|
1305
|
+
* and pulls `all`, as before). When the lookup fails it throws (audit item 4):
|
|
1306
|
+
* an auth refusal is rethrown as-is so the sign-in message survives, and any
|
|
1307
|
+
* other failure is a bounded {@link SyncScopeLookupError}. The command then
|
|
1308
|
+
* stops for this company rather than syncing unscoped. Exported for tests.
|
|
1243
1309
|
*/
|
|
1244
|
-
async function resolveCliPullScope(client, companyRef, hqRoot, onResolvedCompanyUid) {
|
|
1310
|
+
export async function resolveCliPullScope(client, companyRef, hqRoot, onResolvedCompanyUid) {
|
|
1245
1311
|
const ref = companyRef ?? readActiveCompany(hqRoot);
|
|
1246
1312
|
if (!ref)
|
|
1247
1313
|
return undefined;
|
|
@@ -1271,11 +1337,29 @@ async function resolveCliPullScope(client, companyRef, hqRoot, onResolvedCompany
|
|
|
1271
1337
|
}
|
|
1272
1338
|
}
|
|
1273
1339
|
}
|
|
1274
|
-
catch {
|
|
1275
|
-
|
|
1276
|
-
|
|
1340
|
+
catch (err) {
|
|
1341
|
+
throw scopeLookupFailure(ref, err);
|
|
1342
|
+
}
|
|
1343
|
+
try {
|
|
1344
|
+
return await resolvePullScope(client, companyUid, slug, hqRoot);
|
|
1345
|
+
}
|
|
1346
|
+
catch (err) {
|
|
1347
|
+
throw scopeLookupFailure(slug, err);
|
|
1277
1348
|
}
|
|
1278
|
-
|
|
1349
|
+
}
|
|
1350
|
+
/**
|
|
1351
|
+
* The error a failed single-company scope lookup throws. Auth refusals keep
|
|
1352
|
+
* their own curated message (formatSyncFailure renders the sign-in fix);
|
|
1353
|
+
* everything else becomes a bounded SyncScopeLookupError.
|
|
1354
|
+
*/
|
|
1355
|
+
function scopeLookupFailure(company, err) {
|
|
1356
|
+
if (err instanceof SyncScopeLookupError)
|
|
1357
|
+
return err;
|
|
1358
|
+
if (isScopeLookupAuthRefusal(err))
|
|
1359
|
+
return err;
|
|
1360
|
+
// `retryable` only drives the sync runner's transient-blip reporting, which
|
|
1361
|
+
// the CLI does not use.
|
|
1362
|
+
return new SyncScopeLookupError(company, errorClassOf(err), false);
|
|
1279
1363
|
}
|
|
1280
1364
|
/**
|
|
1281
1365
|
* The progress-snapshot label share()'s default recorder would use: the
|
|
@@ -1304,6 +1388,11 @@ function printPlanLimitRefusal(summary, indent = " ") {
|
|
|
1304
1388
|
}
|
|
1305
1389
|
}
|
|
1306
1390
|
export function registerCloudCommands(program) {
|
|
1391
|
+
program.hook("preAction", (_group, action) => {
|
|
1392
|
+
if (process.env.HQ_API_KEY !== undefined && ["push", "now"].includes(action.name())) {
|
|
1393
|
+
throw Object.assign(new Error("HQ_API_KEY sync is read-only; push and now are refused. Use sync pull with an explicit company UID and --company-slug."), { expected: true });
|
|
1394
|
+
}
|
|
1395
|
+
});
|
|
1307
1396
|
program
|
|
1308
1397
|
.command("push")
|
|
1309
1398
|
.description("Push local file(s) to the company vault on S3")
|
|
@@ -1740,6 +1829,7 @@ export function registerCloudCommands(program) {
|
|
|
1740
1829
|
program
|
|
1741
1830
|
.command("pull")
|
|
1742
1831
|
.description("Pull permitted files from the company vault to local HQ")
|
|
1832
|
+
.option("--company-slug <slug>", "Trusted local layout slug; required with HQ_API_KEY and --company cmp_…")
|
|
1743
1833
|
.option("--hq-root <path>", `Local HQ tree root (default: ${DEFAULT_HQ_ROOT})`, DEFAULT_HQ_ROOT)
|
|
1744
1834
|
.option("--company <slug>", "Company slug or UID (defaults to active company in .hq/config.json)")
|
|
1745
1835
|
.option("--lock-timeout <seconds>", "Maximum wait for another active HQ operation (default: 300; 0 = refuse immediately)")
|
|
@@ -1765,6 +1855,20 @@ export function registerCloudCommands(program) {
|
|
|
1765
1855
|
"disk and only un-tracked from sync; clean out-of-scope files are " +
|
|
1766
1856
|
"quarantined under .hq/scope-quarantine/ (recoverable).")
|
|
1767
1857
|
.action(async (options) => {
|
|
1858
|
+
if (process.env.HQ_API_KEY !== undefined) {
|
|
1859
|
+
if (options.all || options.personal !== undefined || options.forceScopeShrink || options.onConflict || options.modeAll) {
|
|
1860
|
+
throw Object.assign(new Error("Keyed pull requires one company; fanout, personal, scope-shrink and conflict options are unsupported."), { expected: true });
|
|
1861
|
+
}
|
|
1862
|
+
configureSyncLockTimeout(options.lockTimeout);
|
|
1863
|
+
const result = await syncUnderOperationLock({
|
|
1864
|
+
hqRoot: options.hqRoot,
|
|
1865
|
+
company: options.company,
|
|
1866
|
+
companySlug: options.companySlug,
|
|
1867
|
+
token: process.env.HQ_API_KEY.trim(),
|
|
1868
|
+
}, { sync: keyedSyncPull });
|
|
1869
|
+
console.log(`Keyed pull: ${result.filesDownloaded} files downloaded; unlisted local files preserved.`);
|
|
1870
|
+
return;
|
|
1871
|
+
}
|
|
1768
1872
|
const skips = refuseSyncForOffVaults("pull", {
|
|
1769
1873
|
all: options.all,
|
|
1770
1874
|
personal: options.personal,
|
|
@@ -1814,8 +1918,9 @@ export function registerCloudCommands(program) {
|
|
|
1814
1918
|
const pullClient = new VaultClient(vaultConfig);
|
|
1815
1919
|
const { resolvedCompanyUid, resolvedMode } = await resolvePerCompanyPullPlan(pullClient, options.company);
|
|
1816
1920
|
// DEV-1768: resolve the REAL effective scope (mode + prefixSet) and
|
|
1817
|
-
// thread it into the pull below — not just the banner.
|
|
1818
|
-
//
|
|
1921
|
+
// thread it into the pull below — not just the banner. A failed
|
|
1922
|
+
// lookup throws and stops the pull (audit item 4); it never falls
|
|
1923
|
+
// back to an unscoped "all" pull.
|
|
1819
1924
|
const pullScope = await resolveCliPullScope(pullClient, options.company, options.hqRoot);
|
|
1820
1925
|
// Size gate: only a large local folder is nudged / strict-refused.
|
|
1821
1926
|
const nudgeExceedsSize = resolvedMode === "all" &&
|
|
@@ -2627,14 +2732,11 @@ async function runNowSingle(hqRoot, company, personal, message, onConflict, mode
|
|
|
2627
2732
|
// DEV-1768: resolve the membership's real scope and thread it into the
|
|
2628
2733
|
// pull leg, so `hq sync now` stops seeding all-mode PullRecords. Personal
|
|
2629
2734
|
// targets have no membership scope — they stay full ("all").
|
|
2735
|
+
// A failed lookup throws (audit item 4) and stops this run through the
|
|
2736
|
+
// outer catch; it never falls back to an unscoped pull.
|
|
2630
2737
|
let pullScope;
|
|
2631
2738
|
if (!personalMode) {
|
|
2632
|
-
|
|
2633
|
-
pullScope = await resolveCliPullScope(new VaultClient(vaultConfig), targetCompany, hqRoot);
|
|
2634
|
-
}
|
|
2635
|
-
catch {
|
|
2636
|
-
pullScope = undefined;
|
|
2637
|
-
}
|
|
2739
|
+
pullScope = await resolveCliPullScope(new VaultClient(vaultConfig), targetCompany, hqRoot);
|
|
2638
2740
|
}
|
|
2639
2741
|
console.log(chalk.dim(" → pull leg"));
|
|
2640
2742
|
const excludePrefixes = readScopeExcludePrefixes(pullScope);
|