@indigoai-us/hq-cli 5.345.206 → 5.345.208

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/assets/scaffold/core/scripts/checkpoint-stop-gate.sh +111 -15
  3. package/dist/command-catalog.generated.d.ts +14 -2
  4. package/dist/command-catalog.generated.js +17 -2
  5. package/dist/commands/bot.d.ts +6 -0
  6. package/dist/commands/bot.js +88 -12
  7. package/dist/commands/core-checkpoint-stop-gate-native.js +130 -25
  8. package/dist/commands/files.d.ts +36 -0
  9. package/dist/commands/files.js +80 -1
  10. package/dist/commands/lanes-shared.d.ts +13 -0
  11. package/dist/commands/lanes.d.ts +2 -0
  12. package/dist/commands/lanes.js +44 -4
  13. package/dist/commands/sources.js +1 -1
  14. package/dist/commands/storage-offload.d.ts +11 -3
  15. package/dist/commands/storage-offload.js +32 -13
  16. package/dist/commands/storage.js +6 -1
  17. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +260 -250
  18. package/dist/hq-cloud-sync-runner/package.json +1 -1
  19. package/dist/lib/bot/fleet-cron.js +4 -1
  20. package/dist/lib/bot/fleet-owner-companies.d.ts +7 -0
  21. package/dist/lib/bot/fleet-owner-companies.js +16 -4
  22. package/dist/lib/bot/jobs/hot-signal-sync.d.ts +2 -0
  23. package/dist/lib/bot/jobs/hot-signal-sync.js +18 -1
  24. package/dist/lib/bot/jobs/meeting-detect.d.ts +41 -2
  25. package/dist/lib/bot/jobs/meeting-detect.js +280 -16
  26. package/dist/lib/bot/run.d.ts +1 -0
  27. package/dist/lib/bot/run.js +4 -2
  28. package/dist/lib/bot/runtime-failure.js +4 -2
  29. package/dist/lib/capacity/collect.d.ts +7 -0
  30. package/dist/lib/capacity/collect.js +22 -16
  31. package/dist/lib/capacity/route.d.ts +23 -0
  32. package/dist/lib/capacity/route.js +41 -2
  33. package/dist/lib/company-skill-wrapper.js +33 -4
  34. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  35. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  36. package/dist/lib/hot-channels/alert.d.ts +4 -1
  37. package/dist/lib/hot-channels/alert.js +10 -4
  38. package/dist/lib/hot-channels/ledger.d.ts +4 -4
  39. package/dist/lib/hot-channels/ledger.js +2 -0
  40. package/dist/lib/hot-channels/run.d.ts +6 -0
  41. package/dist/lib/hot-channels/run.js +7 -2
  42. package/dist/lib/hot-channels/signals-pass.d.ts +11 -2
  43. package/dist/lib/hot-channels/signals-pass.js +129 -15
  44. package/dist/lib/live-meetings.js +1 -1
  45. package/dist/lib/sync-core/release.d.ts +1 -1
  46. package/dist/lib/sync-core/release.js +1 -1
  47. package/dist/utils/redact-error-text.js +1 -0
  48. package/dist/utils/resident-package-preload.js +32 -4
  49. package/package.json +8 -8
@@ -5,7 +5,8 @@
5
5
  * for files over the sync limit approved 2026-10-15.
6
6
  *
7
7
  * Two kinds of big file:
8
- * - History copies (old versions inside the HQ root git history). The CLI
8
+ * - Personal-only history copies (old versions inside HQ root git history).
9
+ * Blobs with any company path are excluded, including shared blobs. The CLI
9
10
  * uploads each blob to the caller's PERSONAL vault, verifies size + sha256
10
11
  * + git blob id, then hands only verified blobs to core `hq-storage.sh
11
12
  * strip-large`, which rewrites history to the pointer text. Working-tree
@@ -520,7 +521,7 @@ export function s3VaultObjectStore(bucket, s3, opts = {}) {
520
521
  */
521
522
  export function resolveOffloadTarget(rel) {
522
523
  const posix = toPosix(rel);
523
- const m = /^companies\/([^/]+)\/(.+)$/.exec(posix);
524
+ const m = /^companies\/([^/]+)\/(.+)$/i.exec(posix);
524
525
  if (m)
525
526
  return { vault: "company", slug: m[1], key: m[2] };
526
527
  return { vault: "personal", key: posix };
@@ -592,11 +593,14 @@ export function worktreeHoldsAllCopy(held) {
592
593
  }
593
594
  /**
594
595
  * History blobs eligible for offload: at least `minBytes`, and not part of the
595
- * current checkout. Blobs in HEAD are current files; stripping them would
596
+ * current checkout, with no company path. Blobs in HEAD are current files; stripping them would
596
597
  * leave the working tree out of step with HEAD.
597
598
  */
598
599
  export function selectHistoryBlobs(blobs, minBytes) {
599
- return blobs.filter((b) => !b.in_head && b.bytes >= minBytes && b.paths.length > 0);
600
+ // A blob may have both personal and company names. Never send any such
601
+ // content to the personal store; historical paths need no longer exist.
602
+ return blobs.filter((b) => !b.in_head && b.bytes >= minBytes && b.paths.length > 0 &&
603
+ b.paths.every((p) => !/^companies(?:\/|$)/i.test(toPosix(path.posix.normalize(toPosix(p))))));
600
604
  }
601
605
  // ── Upload + verify ─────────────────────────────────────────────────────────
602
606
  export function matchesDigest(obj, digest) {
@@ -672,11 +676,12 @@ export const durablePlaceholderFs = {
672
676
  export async function offloadCurrentFile(rel, store, deps, fsOps = durablePlaceholderFs) {
673
677
  if (store.vault !== "personal")
674
678
  throw new Error("Offload only writes to your personal vault.");
679
+ const abs = containedPath(deps.hqRoot, rel);
680
+ rel = toPosix(path.relative(fs.realpathSync.native(deps.hqRoot), abs));
675
681
  if (resolveOffloadTarget(rel).vault === "company") {
676
682
  throw new Error(`'${rel}' is a company file. Company files are never uploaded to your personal vault.`);
677
683
  }
678
684
  assertRestorable(rel);
679
- const abs = containedPath(deps.hqRoot, rel);
680
685
  const before = await fs.promises.stat(abs);
681
686
  if (!before.isFile())
682
687
  throw new Error(`'${rel}' is not a regular file.`);
@@ -985,6 +990,9 @@ async function uploadCompanyFile(file, uploader, vault, deps, fsOps) {
985
990
  }
986
991
  /** Plain name of an HQ sync ignore layer, for skip reasons. */
987
992
  function exclusionReason(ex) {
993
+ if (ex.layer === "server-owned") {
994
+ return "HQ sync never uploads this path: the server owns this company folder and replaces local copies with the cloud copy.";
995
+ }
988
996
  if (ex.layer === ".hqinclude allowlist") {
989
997
  const add = ex.includeLine ? ` To sync and offload it, add this line to .hqinclude: ${ex.includeLine}` : "";
990
998
  return `HQ sync skips this path because the .hqinclude allowlist does not list it.${add}`;
@@ -1013,7 +1021,7 @@ function skippedByName(rel) {
1013
1021
  * Symlinks are not followed, and a path outside HQ throws.
1014
1022
  */
1015
1023
  function walkCurrentPaths(hqRoot, args) {
1016
- const realRoot = fs.realpathSync(path.resolve(hqRoot));
1024
+ const realRoot = fs.realpathSync.native(path.resolve(hqRoot));
1017
1025
  const out = [];
1018
1026
  const seen = new Set();
1019
1027
  const visit = (abs) => {
@@ -1052,10 +1060,12 @@ async function planCurrentFiles(rels, opts, deps, openVault) {
1052
1060
  let active;
1053
1061
  const planned = [];
1054
1062
  const now = deps.now().getTime();
1055
- for (const rel of rels) {
1063
+ for (const candidate of rels) {
1064
+ const abs = containedPath(deps.hqRoot, candidate);
1065
+ // Canonicalise discovery output too, not just explicit path arguments.
1066
+ const rel = toPosix(path.relative(fs.realpathSync.native(deps.hqRoot), abs));
1056
1067
  if (skippedByName(rel))
1057
1068
  continue;
1058
- const abs = containedPath(deps.hqRoot, rel);
1059
1069
  let st;
1060
1070
  try {
1061
1071
  st = fs.lstatSync(abs);
@@ -1090,6 +1100,15 @@ async function planCurrentFiles(rels, opts, deps, openVault) {
1090
1100
  };
1091
1101
  if (target.vault === "company") {
1092
1102
  plan.company = target.slug;
1103
+ // Decide this before any journal or vault access. A synced or
1104
+ // library-matching file would otherwise be replaced by a placeholder, and
1105
+ // a vault that cannot open would abort every other file in the run.
1106
+ if (deps.serverOwned?.(rel.toLowerCase())) {
1107
+ plan.excluded_by = "server-owned";
1108
+ plan.reason = exclusionReason({ excluded: true, layer: "server-owned" });
1109
+ planned.push({ plan, target });
1110
+ continue;
1111
+ }
1093
1112
  active ??= deps.activeCompanySlugs ? await deps.activeCompanySlugs() : [];
1094
1113
  if (!active.includes(target.slug)) {
1095
1114
  plan.reason = `You are not an active member of '${target.slug}'.`;
@@ -1468,14 +1487,14 @@ export function containedPath(hqRoot, rel) {
1468
1487
  if (abs !== root && !abs.startsWith(root + path.sep)) {
1469
1488
  throw new Error(`Path '${rel}' is outside HQ.`);
1470
1489
  }
1471
- const realRoot = fs.realpathSync(root);
1490
+ const realRoot = fs.realpathSync.native(root);
1472
1491
  let existing = abs;
1473
1492
  const rest = [];
1474
1493
  while (!fs.existsSync(existing)) {
1475
1494
  rest.unshift(path.basename(existing));
1476
1495
  existing = path.dirname(existing);
1477
1496
  }
1478
- const real = path.join(fs.realpathSync(existing), ...rest);
1497
+ const real = path.join(fs.realpathSync.native(existing), ...rest);
1479
1498
  if (real !== realRoot && !real.startsWith(realRoot + path.sep)) {
1480
1499
  throw new Error(`Path '${rel}' is outside HQ.`);
1481
1500
  }
@@ -1556,10 +1575,10 @@ async function fetchOrphan(pointer, opts, deps) {
1556
1575
  throw new Error(`${ORPHANED_MESSAGE} You have no personal copy of it to restore.`);
1557
1576
  }
1558
1577
  const dest = path.resolve(opts.out);
1559
- const realRoot = fs.realpathSync(path.resolve(deps.hqRoot));
1578
+ const realRoot = fs.realpathSync.native(path.resolve(deps.hqRoot));
1560
1579
  let realParent;
1561
1580
  try {
1562
- realParent = fs.realpathSync(path.dirname(dest));
1581
+ realParent = fs.realpathSync.native(path.dirname(dest));
1563
1582
  }
1564
1583
  catch {
1565
1584
  throw new Error(`The folder for '${opts.out}' does not exist.`);
@@ -1586,7 +1605,7 @@ async function fetchPlaceholder(arg, deps, opts) {
1586
1605
  if (opts.forceOrphan)
1587
1606
  throw new Error("--force-orphan is only for files a teammate deleted.");
1588
1607
  const target = containedPath(deps.hqRoot, pointer.path);
1589
- const realRoot = fs.realpathSync(path.resolve(deps.hqRoot));
1608
+ const realRoot = fs.realpathSync.native(path.resolve(deps.hqRoot));
1590
1609
  const placeholderRel = toPosix(path.relative(realRoot, placeholder));
1591
1610
  if (`${toPosix(path.relative(realRoot, target))}${PLACEHOLDER_SUFFIX}` !== placeholderRel) {
1592
1611
  throw new Error(`Placeholder '${placeholderRel}' names '${pointer.path}', which is not its own location. Nothing was changed.`);
@@ -845,7 +845,8 @@ const CURRENT_ACTION_LABEL = {
845
845
  /** One `--current` plan line: path, size, owning vault, sync state, action. */
846
846
  function formatCurrentFile(f) {
847
847
  const vault = f.vault === "company" ? `company ${f.company ?? "?"}` : "personal vault";
848
- const parts = [f.path, formatBytes(f.bytes), vault, f.synced ? "synced" : "not synced", CURRENT_ACTION_LABEL[f.action]];
848
+ const syncState = f.excluded_by === "server-owned" ? "sync not checked" : f.synced ? "synced" : "not synced";
849
+ const parts = [f.path, formatBytes(f.bytes), vault, syncState, CURRENT_ACTION_LABEL[f.action]];
849
850
  if (f.action === "upload+offload") {
850
851
  parts.push(`(${f.bytes} bytes to the company ${f.company ?? "?"} vault at ${f.vault_key ?? f.path})`);
851
852
  }
@@ -1110,6 +1111,10 @@ export async function buildOffloadDeps() {
1110
1111
  return s3VaultObjectStore(bucket, client, { where: `company vault '${company.slug}'`, revend });
1111
1112
  },
1112
1113
  syncMaxFileBytes: typeof cloud.SYNC_MAX_FILE_BYTES === "number" ? cloud.SYNC_MAX_FILE_BYTES : undefined,
1114
+ // Server-owned company paths sync only from the cloud. Called directly so
1115
+ // that an hq-cloud without this export fails the build, where an optional
1116
+ // lookup would turn the refusal off.
1117
+ serverOwned: (rel) => hqCloud.isLocallyIneligibleForPush(rel),
1113
1118
  syncExclusion: explainIgnore
1114
1119
  ? (rel) => {
1115
1120
  explainer ??= explainIgnore(hqRoot);