@indigoai-us/hq-cloud 6.14.0 → 6.14.2

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 (167) hide show
  1. package/dist/bin/sync-runner-company.d.ts +4 -0
  2. package/dist/bin/sync-runner-company.d.ts.map +1 -1
  3. package/dist/bin/sync-runner-company.js +50 -1
  4. package/dist/bin/sync-runner-company.js.map +1 -1
  5. package/dist/bin/sync-runner-watch-loop.d.ts +3 -2
  6. package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
  7. package/dist/bin/sync-runner-watch-loop.js +21 -7
  8. package/dist/bin/sync-runner-watch-loop.js.map +1 -1
  9. package/dist/bin/sync-runner.d.ts +6 -2
  10. package/dist/bin/sync-runner.d.ts.map +1 -1
  11. package/dist/bin/sync-runner.js +162 -11
  12. package/dist/bin/sync-runner.js.map +1 -1
  13. package/dist/bin/sync-runner.test.js +155 -17
  14. package/dist/bin/sync-runner.test.js.map +1 -1
  15. package/dist/cli/accept.d.ts.map +1 -1
  16. package/dist/cli/accept.js +29 -0
  17. package/dist/cli/accept.js.map +1 -1
  18. package/dist/cli/invite.d.ts.map +1 -1
  19. package/dist/cli/invite.js +33 -0
  20. package/dist/cli/invite.js.map +1 -1
  21. package/dist/cli/promote.d.ts.map +1 -1
  22. package/dist/cli/promote.js +33 -0
  23. package/dist/cli/promote.js.map +1 -1
  24. package/dist/cli/reindex.d.ts +23 -11
  25. package/dist/cli/reindex.d.ts.map +1 -1
  26. package/dist/cli/reindex.js +39 -10
  27. package/dist/cli/reindex.js.map +1 -1
  28. package/dist/cli/reindex.test.js +40 -13
  29. package/dist/cli/reindex.test.js.map +1 -1
  30. package/dist/cli/share.js +47 -4
  31. package/dist/cli/share.js.map +1 -1
  32. package/dist/cli/share.test.js +123 -2
  33. package/dist/cli/share.test.js.map +1 -1
  34. package/dist/cli/sync-scope.test.js +84 -0
  35. package/dist/cli/sync-scope.test.js.map +1 -1
  36. package/dist/cli/sync.d.ts +44 -3
  37. package/dist/cli/sync.d.ts.map +1 -1
  38. package/dist/cli/sync.js +156 -7
  39. package/dist/cli/sync.js.map +1 -1
  40. package/dist/cli/sync.test.js +133 -0
  41. package/dist/cli/sync.test.js.map +1 -1
  42. package/dist/company-resolver.d.ts +21 -0
  43. package/dist/company-resolver.d.ts.map +1 -1
  44. package/dist/company-resolver.js +31 -6
  45. package/dist/company-resolver.js.map +1 -1
  46. package/dist/company-resolver.test.js +44 -1
  47. package/dist/company-resolver.test.js.map +1 -1
  48. package/dist/ignore.d.ts +10 -0
  49. package/dist/ignore.d.ts.map +1 -1
  50. package/dist/ignore.js +23 -2
  51. package/dist/ignore.js.map +1 -1
  52. package/dist/ignore.test.js +13 -1
  53. package/dist/ignore.test.js.map +1 -1
  54. package/dist/index.d.ts +4 -2
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +4 -1
  57. package/dist/index.js.map +1 -1
  58. package/dist/journal.d.ts +12 -0
  59. package/dist/journal.d.ts.map +1 -1
  60. package/dist/journal.js +12 -0
  61. package/dist/journal.js.map +1 -1
  62. package/dist/lib/exit-codes.d.ts +25 -0
  63. package/dist/lib/exit-codes.d.ts.map +1 -0
  64. package/dist/lib/exit-codes.js +25 -0
  65. package/dist/lib/exit-codes.js.map +1 -0
  66. package/dist/object-io.d.ts.map +1 -1
  67. package/dist/object-io.js +45 -14
  68. package/dist/object-io.js.map +1 -1
  69. package/dist/object-io.test.js +61 -1
  70. package/dist/object-io.test.js.map +1 -1
  71. package/dist/operation-lock.d.ts +36 -6
  72. package/dist/operation-lock.d.ts.map +1 -1
  73. package/dist/operation-lock.js +34 -11
  74. package/dist/operation-lock.js.map +1 -1
  75. package/dist/operation-lock.test.js +30 -0
  76. package/dist/operation-lock.test.js.map +1 -1
  77. package/dist/s3.d.ts +1 -0
  78. package/dist/s3.d.ts.map +1 -1
  79. package/dist/s3.js +75 -2
  80. package/dist/s3.js.map +1 -1
  81. package/dist/s3.test.js +56 -1
  82. package/dist/s3.test.js.map +1 -1
  83. package/dist/scope-shrink.d.ts +12 -0
  84. package/dist/scope-shrink.d.ts.map +1 -1
  85. package/dist/scope-shrink.js +12 -0
  86. package/dist/scope-shrink.js.map +1 -1
  87. package/dist/scope-shrink.test.js +31 -0
  88. package/dist/scope-shrink.test.js.map +1 -1
  89. package/dist/skill-telemetry.d.ts +41 -0
  90. package/dist/skill-telemetry.d.ts.map +1 -1
  91. package/dist/skill-telemetry.js +111 -7
  92. package/dist/skill-telemetry.js.map +1 -1
  93. package/dist/skill-telemetry.test.js +187 -5
  94. package/dist/skill-telemetry.test.js.map +1 -1
  95. package/dist/sync/event-sync.d.ts +3 -0
  96. package/dist/sync/event-sync.d.ts.map +1 -1
  97. package/dist/sync/event-sync.js +23 -0
  98. package/dist/sync/event-sync.js.map +1 -1
  99. package/dist/sync/pull-scope.d.ts +21 -0
  100. package/dist/sync/pull-scope.d.ts.map +1 -1
  101. package/dist/sync/pull-scope.js +46 -13
  102. package/dist/sync/pull-scope.js.map +1 -1
  103. package/dist/telemetry-events.d.ts +31 -0
  104. package/dist/telemetry-events.d.ts.map +1 -0
  105. package/dist/telemetry-events.js +140 -0
  106. package/dist/telemetry-events.js.map +1 -0
  107. package/dist/telemetry-events.test.d.ts +2 -0
  108. package/dist/telemetry-events.test.d.ts.map +1 -0
  109. package/dist/telemetry-events.test.js +73 -0
  110. package/dist/telemetry-events.test.js.map +1 -0
  111. package/dist/telemetry.js +1 -1
  112. package/dist/telemetry.js.map +1 -1
  113. package/dist/vault-client.d.ts +38 -5
  114. package/dist/vault-client.d.ts.map +1 -1
  115. package/dist/vault-client.js +69 -6
  116. package/dist/vault-client.js.map +1 -1
  117. package/dist/vault-client.test.js +31 -1
  118. package/dist/vault-client.test.js.map +1 -1
  119. package/dist/watcher.d.ts +7 -0
  120. package/dist/watcher.d.ts.map +1 -1
  121. package/dist/watcher.js +53 -1
  122. package/dist/watcher.js.map +1 -1
  123. package/dist/watcher.test.js +57 -0
  124. package/dist/watcher.test.js.map +1 -1
  125. package/package.json +1 -1
  126. package/pnpm-workspace.yaml +2 -0
  127. package/scripts/presign-transport-e2e.mjs +2 -2
  128. package/src/bin/sync-runner-company.ts +65 -1
  129. package/src/bin/sync-runner-watch-loop.ts +24 -8
  130. package/src/bin/sync-runner.test.ts +194 -16
  131. package/src/bin/sync-runner.ts +209 -11
  132. package/src/cli/accept.ts +27 -0
  133. package/src/cli/invite.ts +31 -0
  134. package/src/cli/promote.ts +31 -0
  135. package/src/cli/reindex.test.ts +44 -13
  136. package/src/cli/reindex.ts +74 -21
  137. package/src/cli/share.test.ts +139 -2
  138. package/src/cli/share.ts +48 -2
  139. package/src/cli/sync-scope.test.ts +90 -0
  140. package/src/cli/sync.test.ts +154 -0
  141. package/src/cli/sync.ts +224 -5
  142. package/src/company-resolver.test.ts +51 -0
  143. package/src/company-resolver.ts +40 -5
  144. package/src/ignore.test.ts +18 -1
  145. package/src/ignore.ts +24 -2
  146. package/src/index.ts +22 -1
  147. package/src/journal.ts +12 -0
  148. package/src/lib/exit-codes.ts +24 -0
  149. package/src/object-io.test.ts +66 -1
  150. package/src/object-io.ts +51 -14
  151. package/src/operation-lock.test.ts +33 -0
  152. package/src/operation-lock.ts +46 -11
  153. package/src/s3.test.ts +87 -0
  154. package/src/s3.ts +93 -2
  155. package/src/scope-shrink.test.ts +32 -0
  156. package/src/scope-shrink.ts +12 -0
  157. package/src/skill-telemetry.test.ts +247 -4
  158. package/src/skill-telemetry.ts +134 -6
  159. package/src/sync/event-sync.ts +37 -0
  160. package/src/sync/pull-scope.ts +62 -13
  161. package/src/telemetry-events.test.ts +88 -0
  162. package/src/telemetry-events.ts +205 -0
  163. package/src/telemetry.ts +1 -1
  164. package/src/vault-client.test.ts +39 -1
  165. package/src/vault-client.ts +115 -14
  166. package/src/watcher.test.ts +82 -0
  167. package/src/watcher.ts +69 -0
package/src/watcher.ts CHANGED
@@ -14,12 +14,18 @@ import { watch } from "chokidar";
14
14
  import { createIgnoreFilter } from "./ignore.js";
15
15
  import { isPersonalVaultExcluded } from "./personal-vault-exclusions.js";
16
16
  import {
17
+ AGENCY_SYNC_REL,
17
18
  CONTINUITY_POINTER_REL,
18
19
  PERSONAL_VAULT_EXCLUDED_TOP_LEVEL,
19
20
  } from "./personal-vault.js";
20
21
  import type { PushEvent } from "./sync/push-event.js";
21
22
  import type { PushTransport } from "./sync/push-transport.js";
22
23
  import type { EventDrivenPushFlagProvider } from "./sync/feature-flags.js";
24
+ import {
25
+ emitCloudTelemetry,
26
+ type CloudTelemetryClient,
27
+ type TelemetryClaims,
28
+ } from "./telemetry-events.js";
23
29
 
24
30
  const DEBOUNCE_MS = 2000;
25
31
 
@@ -407,6 +413,24 @@ export function createWatchPathFilter(
407
413
  // createIgnoreFilter returns true = "sync this"; false = "ignored".
408
414
  if (!ignoreFilter(absolutePath, isDir)) return false;
409
415
 
416
+ // Never-synced heavy buckets — pruned in BOTH modes. The local git worktrees
417
+ // (`workspace/worktrees/`, where `/worktree` and agent coding runs check out
418
+ // repos — often 100k+ transient source/build files) and the on-box `repos/`
419
+ // checkout are never vault-synced in any mode. In personalMode the
420
+ // excluded-top-level layer below already drops them; in `--companies` mode
421
+ // that layer is skipped, so without this the watcher descends into every
422
+ // worktree source tree — tens of thousands of wasted inotify watches (the
423
+ // outpost sat at ~78% of the OS limit) plus CPU spent processing build churn
424
+ // it immediately discards, and enough backlog to trip the
425
+ // overflow → full-reconcile fallback. Returning false for the dir probe too
426
+ // prunes the whole subtree at descent instead of per-file. `companies/` and
427
+ // the synced `workspace/agency/` + continuity-pointer paths are untouched.
428
+ const topSegments = rel.split("/");
429
+ if (topSegments[0] === "repos") return false;
430
+ if (topSegments[0] === "workspace" && topSegments[1] === "worktrees") {
431
+ return false;
432
+ }
433
+
410
434
  if (personalMode) {
411
435
  // Continuity-pointer carve-out: the session pointer lives under the
412
436
  // otherwise-excluded `workspace/`, so it must re-include BEFORE the
@@ -428,6 +452,20 @@ export function createWatchPathFilter(
428
452
  if (rel === CONTINUITY_POINTER_REL && !isDir) return true;
429
453
  if (isDir && CONTINUITY_POINTER_REL.startsWith(rel + "/")) return true;
430
454
 
455
+ // Agency-workspace carve-out: `workspace/agency/` (the whole subtree) IS
456
+ // synced via computeAgencySyncPaths (mirrored on the push side), so it must
457
+ // re-include BEFORE the top-level `workspace/` rejection below — same
458
+ // reason as the continuity pointer above, but for an entire subtree rather
459
+ // than one file. Without this, a `--personal --watch` runner never emits
460
+ // agency changes and they wait for the 60s poll. Paths at/under agency
461
+ // emit (handleEvent always probes isDir=false); agency itself and its
462
+ // ancestor dir (`workspace`) return true for the dir probe so chokidar
463
+ // descends to reach them instead of pruning `workspace/`.
464
+ if (rel === AGENCY_SYNC_REL || rel.startsWith(AGENCY_SYNC_REL + "/")) {
465
+ return true;
466
+ }
467
+ if (isDir && AGENCY_SYNC_REL.startsWith(rel + "/")) return true;
468
+
431
469
  // Layer 3: excluded top-level buckets (.git/companies/repos/workspace).
432
470
  const topLevel = rel.split("/")[0];
433
471
  if (excludedTopLevel.has(topLevel)) return false;
@@ -792,6 +830,9 @@ export interface PushEventEmitterOptions {
792
830
  * no log (the daemon stays quiet unless wired with a logger).
793
831
  */
794
832
  logger?: EmitterLogger;
833
+ /** Optional hq-pro ACTION telemetry sink. Best-effort; never affects publish. */
834
+ telemetryClient?: CloudTelemetryClient | null;
835
+ telemetryClaims?: TelemetryClaims | null;
795
836
  }
796
837
 
797
838
  /**
@@ -816,6 +857,8 @@ export class PushEventEmitter {
816
857
  private readonly now: () => Date;
817
858
  private readonly onError: (err: Error, ctx: { relativePath?: string }) => void;
818
859
  private readonly logger: EmitterLogger | undefined;
860
+ private readonly telemetryClient: CloudTelemetryClient | null | undefined;
861
+ private readonly telemetryClaims: TelemetryClaims | null | undefined;
819
862
  private internalSeq = 0;
820
863
  private readonly nextSeq: () => number;
821
864
  private publishTail: Promise<void> = Promise.resolve();
@@ -827,6 +870,8 @@ export class PushEventEmitter {
827
870
  this.flagProvider = opts.flagProvider;
828
871
  this.now = opts.now ?? (() => new Date());
829
872
  this.logger = opts.logger;
873
+ this.telemetryClient = opts.telemetryClient;
874
+ this.telemetryClaims = opts.telemetryClaims;
830
875
  this.onError =
831
876
  opts.onError ??
832
877
  ((err, ctx) =>
@@ -927,6 +972,7 @@ export class PushEventEmitter {
927
972
  this.onError(err instanceof Error ? err : new Error(String(err)), {
928
973
  relativePath,
929
974
  });
975
+ this.emitPublishTelemetry("push_event_failed", "unknown", "capture");
930
976
  return;
931
977
  }
932
978
 
@@ -962,12 +1008,35 @@ export class PushEventEmitter {
962
1008
 
963
1009
  try {
964
1010
  await this.transport.publish(event);
1011
+ this.emitPublishTelemetry("push_event_published", event.kind, "publish");
965
1012
  } catch (err) {
966
1013
  // Push failure (network / non-2xx / timeout). The cadence poll is the
967
1014
  // safety net — log + continue, never throw.
968
1015
  this.onError(err instanceof Error ? err : new Error(String(err)), {
969
1016
  relativePath,
970
1017
  });
1018
+ this.emitPublishTelemetry("push_event_failed", event.kind, "publish");
971
1019
  }
972
1020
  }
1021
+
1022
+ private emitPublishTelemetry(
1023
+ eventName: "push_event_published" | "push_event_failed",
1024
+ kind: string,
1025
+ stage: string,
1026
+ ): void {
1027
+ void emitCloudTelemetry(
1028
+ this.telemetryClient,
1029
+ {
1030
+ eventName,
1031
+ source: "watcher",
1032
+ properties: {
1033
+ kind,
1034
+ count: 1,
1035
+ result: eventName === "push_event_published" ? "success" : "failure",
1036
+ stage,
1037
+ },
1038
+ },
1039
+ { claims: this.telemetryClaims },
1040
+ );
1041
+ }
973
1042
  }