@indigoai-us/hq-cli 5.345.238 → 5.345.241
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 +25 -0
- 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/dist/command-catalog.generated.d.ts +185 -3
- package/dist/command-catalog.generated.js +228 -3
- 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 +2 -1
- package/dist/commands/cloud-off-gate.js +17 -4
- package/dist/commands/cloud.d.ts +17 -2
- package/dist/commands/cloud.js +126 -24
- package/dist/commands/core-delegate-w1b.js +35 -10
- package/dist/commands/core-delegate.d.ts +2 -1
- package/dist/commands/core-delegate.js +207 -48
- 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/keyed-sync-pull.d.ts +12 -0
- package/dist/commands/keyed-sync-pull.js +151 -0
- 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/secrets.d.ts +3 -4
- package/dist/commands/secrets.js +3 -20
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +307 -232
- 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/collectors/claude-oauth.d.ts +0 -2
- package/dist/lib/capacity/collectors/claude-oauth.js +0 -5
- 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/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 +1 -0
- 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/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/jq/install.d.ts +27 -0
- package/dist/lib/jq/install.js +156 -0
- 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/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/sync-core/rollout-state.d.ts +9 -1
- package/dist/lib/sync-core/rollout-state.js +34 -4
- package/dist/lib/windows/jq.d.ts +4 -0
- package/dist/lib/windows/jq.js +10 -39
- package/dist/lib/workers-registry/index.js +7 -11
- 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/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/docs/anywhere-runtime.md +8 -0
- package/package.json +9 -9
|
@@ -1127,6 +1127,11 @@ export const COMMAND_CATALOG = [
|
|
|
1127
1127
|
"helpText": [],
|
|
1128
1128
|
"arguments": [],
|
|
1129
1129
|
"options": [
|
|
1130
|
+
{
|
|
1131
|
+
"flags": "--company-slug <slug>",
|
|
1132
|
+
"description": "Trusted local layout slug; required with HQ_API_KEY and --company cmp_…",
|
|
1133
|
+
"hidden": false
|
|
1134
|
+
},
|
|
1130
1135
|
{
|
|
1131
1136
|
"flags": "--hq-root <path>",
|
|
1132
1137
|
"description": "Local HQ tree root (default: <runtime-path>)",
|
|
@@ -10534,7 +10539,7 @@ export const COMMAND_CATALOG = [
|
|
|
10534
10539
|
"options": [
|
|
10535
10540
|
{
|
|
10536
10541
|
"flags": "--size <size>",
|
|
10537
|
-
"description": "Outpost size: small | medium | large | xlarge. Without it, a terminal shows a menu with prices and
|
|
10542
|
+
"description": "Outpost size: small | medium | large | xlarge. Without it, a terminal shows a menu with prices and small ($100/month) preselected; a script sends no size and is billed the small price",
|
|
10538
10543
|
"hidden": false
|
|
10539
10544
|
},
|
|
10540
10545
|
{
|
|
@@ -10627,7 +10632,7 @@ export const COMMAND_CATALOG = [
|
|
|
10627
10632
|
},
|
|
10628
10633
|
{
|
|
10629
10634
|
"flags": "--size <size>",
|
|
10630
|
-
"description": "small, medium, large or xlarge (the
|
|
10635
|
+
"description": "small, medium, large or xlarge (without it, the Outpost is billed the small price, $100/month)",
|
|
10631
10636
|
"hidden": false
|
|
10632
10637
|
},
|
|
10633
10638
|
{
|
|
@@ -26384,7 +26389,7 @@ export const COMMAND_CATALOG = [
|
|
|
26384
26389
|
"subcommands": [
|
|
26385
26390
|
{
|
|
26386
26391
|
"name": "list",
|
|
26387
|
-
"description": "List comments on an app in your org",
|
|
26392
|
+
"description": "List comments on an app in your org, or on a personal app with --personal",
|
|
26388
26393
|
"aliases": [],
|
|
26389
26394
|
"hidden": false,
|
|
26390
26395
|
"helpOption": true,
|
|
@@ -26405,6 +26410,11 @@ export const COMMAND_CATALOG = [
|
|
|
26405
26410
|
"description": "use this company instead of the active company",
|
|
26406
26411
|
"hidden": false
|
|
26407
26412
|
},
|
|
26413
|
+
{
|
|
26414
|
+
"flags": "--personal",
|
|
26415
|
+
"description": "read a personal app (personal deploy scope) instead of a company app",
|
|
26416
|
+
"hidden": false
|
|
26417
|
+
},
|
|
26408
26418
|
{
|
|
26409
26419
|
"flags": "--json",
|
|
26410
26420
|
"description": "print the API comment array as JSON",
|
|
@@ -26495,6 +26505,221 @@ export const COMMAND_CATALOG = [
|
|
|
26495
26505
|
}
|
|
26496
26506
|
]
|
|
26497
26507
|
},
|
|
26508
|
+
{
|
|
26509
|
+
"name": "events",
|
|
26510
|
+
"description": "Read and answer site events that visitors send from your deployed apps",
|
|
26511
|
+
"aliases": [],
|
|
26512
|
+
"hidden": false,
|
|
26513
|
+
"helpOption": true,
|
|
26514
|
+
"helpCommand": true,
|
|
26515
|
+
"usage": "[options] [command]",
|
|
26516
|
+
"helpText": [],
|
|
26517
|
+
"arguments": [],
|
|
26518
|
+
"options": [],
|
|
26519
|
+
"subcommands": [
|
|
26520
|
+
{
|
|
26521
|
+
"name": "enable",
|
|
26522
|
+
"description": "Turn site events on (or off with --off) for an app",
|
|
26523
|
+
"aliases": [],
|
|
26524
|
+
"hidden": false,
|
|
26525
|
+
"helpOption": true,
|
|
26526
|
+
"helpCommand": false,
|
|
26527
|
+
"usage": "[options] <app-id>",
|
|
26528
|
+
"helpText": [],
|
|
26529
|
+
"arguments": [
|
|
26530
|
+
{
|
|
26531
|
+
"name": "app-id",
|
|
26532
|
+
"required": true,
|
|
26533
|
+
"variadic": false,
|
|
26534
|
+
"description": ""
|
|
26535
|
+
}
|
|
26536
|
+
],
|
|
26537
|
+
"options": [
|
|
26538
|
+
{
|
|
26539
|
+
"flags": "--company <slug>",
|
|
26540
|
+
"description": "company owning the app",
|
|
26541
|
+
"hidden": false
|
|
26542
|
+
},
|
|
26543
|
+
{
|
|
26544
|
+
"flags": "--personal",
|
|
26545
|
+
"description": "use personal scope",
|
|
26546
|
+
"hidden": false
|
|
26547
|
+
},
|
|
26548
|
+
{
|
|
26549
|
+
"flags": "--off",
|
|
26550
|
+
"description": "turn site events off; stored events are kept",
|
|
26551
|
+
"hidden": false
|
|
26552
|
+
},
|
|
26553
|
+
{
|
|
26554
|
+
"flags": "--json",
|
|
26555
|
+
"description": "print {ok, appId, eventsEnabled} as JSON",
|
|
26556
|
+
"hidden": false
|
|
26557
|
+
}
|
|
26558
|
+
],
|
|
26559
|
+
"subcommands": []
|
|
26560
|
+
},
|
|
26561
|
+
{
|
|
26562
|
+
"name": "list",
|
|
26563
|
+
"description": "List site events on an app",
|
|
26564
|
+
"aliases": [],
|
|
26565
|
+
"hidden": false,
|
|
26566
|
+
"helpOption": true,
|
|
26567
|
+
"helpCommand": false,
|
|
26568
|
+
"usage": "[options] <app-id>",
|
|
26569
|
+
"helpText": [],
|
|
26570
|
+
"arguments": [
|
|
26571
|
+
{
|
|
26572
|
+
"name": "app-id",
|
|
26573
|
+
"required": true,
|
|
26574
|
+
"variadic": false,
|
|
26575
|
+
"description": ""
|
|
26576
|
+
}
|
|
26577
|
+
],
|
|
26578
|
+
"options": [
|
|
26579
|
+
{
|
|
26580
|
+
"flags": "--company <slug>",
|
|
26581
|
+
"description": "company owning the app",
|
|
26582
|
+
"hidden": false
|
|
26583
|
+
},
|
|
26584
|
+
{
|
|
26585
|
+
"flags": "--personal",
|
|
26586
|
+
"description": "use personal scope",
|
|
26587
|
+
"hidden": false
|
|
26588
|
+
},
|
|
26589
|
+
{
|
|
26590
|
+
"flags": "--after <event-id>",
|
|
26591
|
+
"description": "only events after this event id",
|
|
26592
|
+
"hidden": false
|
|
26593
|
+
},
|
|
26594
|
+
{
|
|
26595
|
+
"flags": "--status <status>",
|
|
26596
|
+
"description": "new or handled",
|
|
26597
|
+
"hidden": false
|
|
26598
|
+
},
|
|
26599
|
+
{
|
|
26600
|
+
"flags": "--limit <n>",
|
|
26601
|
+
"description": "maximum number of events",
|
|
26602
|
+
"hidden": false
|
|
26603
|
+
},
|
|
26604
|
+
{
|
|
26605
|
+
"flags": "--json",
|
|
26606
|
+
"description": "print the API response ({events, nextAfter}) as JSON",
|
|
26607
|
+
"hidden": false
|
|
26608
|
+
}
|
|
26609
|
+
],
|
|
26610
|
+
"subcommands": []
|
|
26611
|
+
},
|
|
26612
|
+
{
|
|
26613
|
+
"name": "reply",
|
|
26614
|
+
"description": "Reply to a site event and/or set its status",
|
|
26615
|
+
"aliases": [],
|
|
26616
|
+
"hidden": false,
|
|
26617
|
+
"helpOption": true,
|
|
26618
|
+
"helpCommand": false,
|
|
26619
|
+
"usage": "[options] <app-id> <event-id>",
|
|
26620
|
+
"helpText": [],
|
|
26621
|
+
"arguments": [
|
|
26622
|
+
{
|
|
26623
|
+
"name": "app-id",
|
|
26624
|
+
"required": true,
|
|
26625
|
+
"variadic": false,
|
|
26626
|
+
"description": ""
|
|
26627
|
+
},
|
|
26628
|
+
{
|
|
26629
|
+
"name": "event-id",
|
|
26630
|
+
"required": true,
|
|
26631
|
+
"variadic": false,
|
|
26632
|
+
"description": ""
|
|
26633
|
+
}
|
|
26634
|
+
],
|
|
26635
|
+
"options": [
|
|
26636
|
+
{
|
|
26637
|
+
"flags": "--company <slug>",
|
|
26638
|
+
"description": "company owning the app",
|
|
26639
|
+
"hidden": false
|
|
26640
|
+
},
|
|
26641
|
+
{
|
|
26642
|
+
"flags": "--personal",
|
|
26643
|
+
"description": "use personal scope",
|
|
26644
|
+
"hidden": false
|
|
26645
|
+
},
|
|
26646
|
+
{
|
|
26647
|
+
"flags": "--text <reply>",
|
|
26648
|
+
"description": "reply text the page shows",
|
|
26649
|
+
"hidden": false
|
|
26650
|
+
},
|
|
26651
|
+
{
|
|
26652
|
+
"flags": "--status <status>",
|
|
26653
|
+
"description": "new or handled",
|
|
26654
|
+
"hidden": false
|
|
26655
|
+
},
|
|
26656
|
+
{
|
|
26657
|
+
"flags": "--json",
|
|
26658
|
+
"description": "print {ok, id, status, reply} as JSON",
|
|
26659
|
+
"hidden": false
|
|
26660
|
+
}
|
|
26661
|
+
],
|
|
26662
|
+
"subcommands": []
|
|
26663
|
+
},
|
|
26664
|
+
{
|
|
26665
|
+
"name": "watch",
|
|
26666
|
+
"description": "Poll for new site events and print one JSON line per event",
|
|
26667
|
+
"aliases": [],
|
|
26668
|
+
"hidden": false,
|
|
26669
|
+
"helpOption": true,
|
|
26670
|
+
"helpCommand": false,
|
|
26671
|
+
"usage": "[options] <app-id>",
|
|
26672
|
+
"helpText": [],
|
|
26673
|
+
"arguments": [
|
|
26674
|
+
{
|
|
26675
|
+
"name": "app-id",
|
|
26676
|
+
"required": true,
|
|
26677
|
+
"variadic": false,
|
|
26678
|
+
"description": ""
|
|
26679
|
+
}
|
|
26680
|
+
],
|
|
26681
|
+
"options": [
|
|
26682
|
+
{
|
|
26683
|
+
"flags": "--company <slug>",
|
|
26684
|
+
"description": "company owning the app",
|
|
26685
|
+
"hidden": false
|
|
26686
|
+
},
|
|
26687
|
+
{
|
|
26688
|
+
"flags": "--personal",
|
|
26689
|
+
"description": "use personal scope",
|
|
26690
|
+
"hidden": false
|
|
26691
|
+
},
|
|
26692
|
+
{
|
|
26693
|
+
"flags": "--cursor-file <path>",
|
|
26694
|
+
"description": "file that stores the last reported event id",
|
|
26695
|
+
"hidden": false
|
|
26696
|
+
},
|
|
26697
|
+
{
|
|
26698
|
+
"flags": "--label <name>",
|
|
26699
|
+
"description": "name used in the output lines (default: the app id)",
|
|
26700
|
+
"hidden": false
|
|
26701
|
+
},
|
|
26702
|
+
{
|
|
26703
|
+
"flags": "--interval <seconds>",
|
|
26704
|
+
"description": "seconds between polls, at least 30",
|
|
26705
|
+
"hidden": false,
|
|
26706
|
+
"defaultValue": "30"
|
|
26707
|
+
},
|
|
26708
|
+
{
|
|
26709
|
+
"flags": "--status <status>",
|
|
26710
|
+
"description": "new or handled (default: new)",
|
|
26711
|
+
"hidden": false
|
|
26712
|
+
},
|
|
26713
|
+
{
|
|
26714
|
+
"flags": "--once",
|
|
26715
|
+
"description": "poll once and exit",
|
|
26716
|
+
"hidden": false
|
|
26717
|
+
}
|
|
26718
|
+
],
|
|
26719
|
+
"subcommands": []
|
|
26720
|
+
}
|
|
26721
|
+
]
|
|
26722
|
+
},
|
|
26498
26723
|
{
|
|
26499
26724
|
"name": "list",
|
|
26500
26725
|
"description": "List deploy apps in your company, optionally filtered by name or subdomain",
|
|
@@ -558,6 +558,12 @@ export declare const REGISTRATION_PLAN: readonly [{
|
|
|
558
558
|
readonly parent: "deploy";
|
|
559
559
|
readonly module: "./commands/deploy-comments.js";
|
|
560
560
|
readonly exportName: "registerDeployCommentsCommand";
|
|
561
|
+
}, {
|
|
562
|
+
readonly type: "registrar";
|
|
563
|
+
readonly root: "deploy";
|
|
564
|
+
readonly parent: "deploy";
|
|
565
|
+
readonly module: "./commands/deploy-events.js";
|
|
566
|
+
readonly exportName: "registerDeployEventsCommand";
|
|
561
567
|
}, {
|
|
562
568
|
readonly type: "registrar";
|
|
563
569
|
readonly root: "deploy";
|
|
@@ -95,6 +95,7 @@ export const REGISTRATION_PLAN = [
|
|
|
95
95
|
{ type: "registrar", root: "report", parent: "program", module: "./commands/report.js", exportName: "registerReportCommand" },
|
|
96
96
|
{ type: "group", root: "deploy", id: "deploy", name: "deploy", description: "Manage deployments in hq-deploy" },
|
|
97
97
|
{ type: "registrar", root: "deploy", parent: "deploy", module: "./commands/deploy-comments.js", exportName: "registerDeployCommentsCommand" },
|
|
98
|
+
{ type: "registrar", root: "deploy", parent: "deploy", module: "./commands/deploy-events.js", exportName: "registerDeployEventsCommand" },
|
|
98
99
|
{ type: "registrar", root: "deploy", parent: "deploy", module: "./commands/deploy-list.js", exportName: "registerDeployListCommand" },
|
|
99
100
|
{ type: "registrar", root: "deploy", parent: "deploy", module: "./commands/deploy-mutations.js", exportName: "registerDeployMutationsCommand" },
|
|
100
101
|
{ type: "registrar", root: "deploy", parent: "deploy", module: "./commands/deploy-access.js", exportName: "registerDeployAccessCommand" },
|
|
@@ -131,7 +131,8 @@ export declare function writeVaultRefusal(refusal: VaultRefusal, deps?: Pick<Clo
|
|
|
131
131
|
* targets an off vault (or every vault is off); otherwise return what an
|
|
132
132
|
* `--all` run must skip. Runs before any login, lock or network work, and
|
|
133
133
|
* outside the client-health report, so a refusal is not counted as a failed
|
|
134
|
-
* sync. Warns
|
|
134
|
+
* sync. Warns about unreadable switch settings and exits 1 if the rollout
|
|
135
|
+
* state cannot establish which engine owns the vaults.
|
|
135
136
|
*/
|
|
136
137
|
export declare function refuseSyncForOffVaults(command: GatedSyncCommand, selection: SyncSelection, deps?: CloudOffGateDeps): VaultSkips;
|
|
137
138
|
/**
|
|
@@ -28,7 +28,7 @@ import * as fs from "node:fs";
|
|
|
28
28
|
import * as os from "node:os";
|
|
29
29
|
import * as path from "node:path";
|
|
30
30
|
import { readCompaniesManifestMap } from "../lib/work-context/repo-remote.js";
|
|
31
|
-
import { readSyncCoreRolloutState } from "../lib/sync-core/rollout-state.js";
|
|
31
|
+
import { readSyncCoreRolloutState, SyncCoreRolloutStateError } from "../lib/sync-core/rollout-state.js";
|
|
32
32
|
import { readVaultSyncSwitches, unreadableSwitchesWarning, vaultSkipEnv, } from "../lib/vault-sync-switches.js";
|
|
33
33
|
export { readVaultSyncSwitches, vaultSkipEnv };
|
|
34
34
|
/**
|
|
@@ -51,7 +51,7 @@ export const NO_ENGINE_VAULTS = {
|
|
|
51
51
|
uidSlugs: new Map(),
|
|
52
52
|
};
|
|
53
53
|
export function readEngineOwnedVaults(home = os.homedir()) {
|
|
54
|
-
const state = readSyncCoreRolloutState(home);
|
|
54
|
+
const state = readSyncCoreRolloutState(home, { strict: true });
|
|
55
55
|
if (!state)
|
|
56
56
|
return NO_ENGINE_VAULTS;
|
|
57
57
|
const held = new Set((state.held ?? []).map((h) => h.uid.toLowerCase()));
|
|
@@ -246,12 +246,25 @@ function warnIfUnreadable(switches, deps) {
|
|
|
246
246
|
* targets an off vault (or every vault is off); otherwise return what an
|
|
247
247
|
* `--all` run must skip. Runs before any login, lock or network work, and
|
|
248
248
|
* outside the client-health report, so a refusal is not counted as a failed
|
|
249
|
-
* sync. Warns
|
|
249
|
+
* sync. Warns about unreadable switch settings and exits 1 if the rollout
|
|
250
|
+
* state cannot establish which engine owns the vaults.
|
|
250
251
|
*/
|
|
251
252
|
export function refuseSyncForOffVaults(command, selection, deps = {}) {
|
|
252
253
|
const switches = readVaultSyncSwitches(deps.home);
|
|
253
254
|
warnIfUnreadable(switches, deps);
|
|
254
|
-
|
|
255
|
+
let engine;
|
|
256
|
+
try {
|
|
257
|
+
engine = readEngineOwnedVaults(deps.home);
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
if (!(error instanceof SyncCoreRolloutStateError))
|
|
261
|
+
throw error;
|
|
262
|
+
const writeErr = deps.writeErr ?? ((text) => process.stderr.write(text));
|
|
263
|
+
const message = error.message;
|
|
264
|
+
writeErr(deps.json ? `${JSON.stringify({ type: "fatal", message })}\n` : `${message}\n`);
|
|
265
|
+
return (deps.exit ?? ((code) => process.exit(code)))(1);
|
|
266
|
+
}
|
|
267
|
+
const refusal = refusalFor(command, selection, switches, engine);
|
|
255
268
|
if (refusal) {
|
|
256
269
|
writeVaultRefusal(refusal, deps);
|
|
257
270
|
(deps.exit ?? ((code) => process.exit(code)))(CLOUD_OFF_EXIT_CODE);
|
package/dist/commands/cloud.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* (also `hq daemon sync status --local`)
|
|
15
15
|
*/
|
|
16
16
|
import { Command } from "commander";
|
|
17
|
-
import { type ConflictStrategy, type EntityContext, type MembershipSyncConfig, type SyncMode, type PullScope, type ExplicitGrant, type ShareOptions, type VaultServiceConfig } from "@indigoai-us/hq-cloud";
|
|
17
|
+
import { VaultClient, scopeLookupSkipMessage, SyncScopeLookupError, type ConflictStrategy, type EntityContext, type MembershipSyncConfig, type SyncMode, type PullScope, type ExplicitGrant, type ShareOptions, type VaultServiceConfig } from "@indigoai-us/hq-cloud";
|
|
18
18
|
import { withSyncWatchdog, type SyncWatchdogLimits } from "../utils/sync-watchdog.js";
|
|
19
19
|
import { type BannerLevel } from "../lib/narrow-hint-banner.js";
|
|
20
20
|
import { type PlanLimitRefusalSummary } from "../lib/billing/plan-limit-refusals.js";
|
|
@@ -576,6 +576,7 @@ export interface PullAllResult {
|
|
|
576
576
|
}>;
|
|
577
577
|
perCompany: PullAllRow[];
|
|
578
578
|
}
|
|
579
|
+
export { scopeLookupSkipMessage, SyncScopeLookupError };
|
|
579
580
|
export declare function pullAll(options: PullAllOptions, deps: PullAllDeps): Promise<PullAllResult>;
|
|
580
581
|
/**
|
|
581
582
|
* Drives `hq sync push --all`: same membership + canonical-person fanout as
|
|
@@ -661,6 +662,21 @@ export interface PerCompanyPullResolveResult {
|
|
|
661
662
|
resolvedMode: MembershipSyncConfig["syncMode"] | undefined;
|
|
662
663
|
}
|
|
663
664
|
export declare function resolvePerCompanyPullPlan(client: PerCompanyPullResolveClient, targetCompany: string | undefined): Promise<PerCompanyPullResolveResult>;
|
|
665
|
+
/**
|
|
666
|
+
* Resolve the effective PULL scope (DEV-1768) for a single foreground pull
|
|
667
|
+
* (`hq sync pull` / `hq sync now`), so the membership's REAL syncMode +
|
|
668
|
+
* prefixSet are threaded into `sync()`. Without this the CLI ran `syncMode:
|
|
669
|
+
* "all"` and stamped an all-mode PullRecord that wedged the next menubar sync.
|
|
670
|
+
*
|
|
671
|
+
* Delegates to the shared `resolvePullScope` (same resolver the runner uses),
|
|
672
|
+
* which fails closed since hq-cloud 6.18.117. Returns `undefined` only when no
|
|
673
|
+
* company is named or active (then `sync()` resolves the active company itself
|
|
674
|
+
* and pulls `all`, as before). When the lookup fails it throws (audit item 4):
|
|
675
|
+
* an auth refusal is rethrown as-is so the sign-in message survives, and any
|
|
676
|
+
* other failure is a bounded {@link SyncScopeLookupError}. The command then
|
|
677
|
+
* stops for this company rather than syncing unscoped. Exported for tests.
|
|
678
|
+
*/
|
|
679
|
+
export declare function resolveCliPullScope(client: VaultClient, companyRef: string | undefined, hqRoot: string, onResolvedCompanyUid?: (companyUid: string) => void): Promise<PullScope | undefined>;
|
|
664
680
|
export declare function registerCloudCommands(program: Command): void;
|
|
665
681
|
/**
|
|
666
682
|
* `hq sync doctor --reconcile-conflicts [--yes]`.
|
|
@@ -825,5 +841,4 @@ export declare function describePushSkips(result: {
|
|
|
825
841
|
text: string;
|
|
826
842
|
warn: boolean;
|
|
827
843
|
};
|
|
828
|
-
export {};
|
|
829
844
|
//# sourceMappingURL=cloud.d.ts.map
|
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);
|