@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.
Files changed (206) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/assets/scaffold/core/scripts/hq-delegate-grant.sh +170 -8
  3. package/assets/scaffold/core/scripts/hq-delegate-publish.sh +21 -1
  4. package/assets/scaffold/core/scripts/hq-delegate-repo.sh +7 -1
  5. package/assets/scaffold/core/scripts/hq-delegate-secrets.sh +95 -20
  6. package/assets/scaffold/core/scripts/hq-delegate-transfer.sh +57 -9
  7. package/assets/scaffold/core/scripts/lib/delegate-engine.sh +77 -0
  8. package/dist/command-catalog.generated.d.ts +212 -10
  9. package/dist/command-catalog.generated.js +260 -10
  10. package/dist/command-registration-plan.d.ts +6 -0
  11. package/dist/command-registration-plan.js +1 -0
  12. package/dist/commands/cloud-off-gate.d.ts +9 -8
  13. package/dist/commands/cloud-off-gate.js +41 -40
  14. package/dist/commands/cloud.d.ts +17 -2
  15. package/dist/commands/cloud.js +126 -24
  16. package/dist/commands/core-delegate-w1b.js +333 -27
  17. package/dist/commands/core-delegate.d.ts +2 -1
  18. package/dist/commands/core-delegate.js +209 -48
  19. package/dist/commands/core-handoff.js +1 -1
  20. package/dist/commands/core-job-model-auth.d.ts +95 -0
  21. package/dist/commands/core-job-model-auth.js +247 -0
  22. package/dist/commands/core-job-run-native.js +280 -12
  23. package/dist/commands/core.js +1 -0
  24. package/dist/commands/deploy-comments.js +8 -2
  25. package/dist/commands/deploy-events.d.ts +40 -0
  26. package/dist/commands/deploy-events.js +300 -0
  27. package/dist/commands/doctor.d.ts +4 -4
  28. package/dist/commands/doctor.js +2 -2
  29. package/dist/commands/feedback.js +2 -3
  30. package/dist/commands/files-browse.js +2 -0
  31. package/dist/commands/files.js +4 -0
  32. package/dist/commands/integrations-core.d.ts +11 -0
  33. package/dist/commands/integrations-core.js +15 -1
  34. package/dist/commands/keyed-sync-pull.d.ts +12 -0
  35. package/dist/commands/keyed-sync-pull.js +151 -0
  36. package/dist/commands/lanes-link.js +2 -2
  37. package/dist/commands/lanes-loop.d.ts +2 -2
  38. package/dist/commands/lanes-loop.js +5 -5
  39. package/dist/commands/lanes-questions.js +1 -1
  40. package/dist/commands/lanes-stories.js +1 -1
  41. package/dist/commands/lanes.js +80 -14
  42. package/dist/commands/library-add.d.ts +5 -2
  43. package/dist/commands/library-add.js +22 -9
  44. package/dist/commands/mcp-registration.d.ts +4 -18
  45. package/dist/commands/mcp-registration.js +9 -29
  46. package/dist/commands/mesh.d.ts +4 -0
  47. package/dist/commands/mesh.js +25 -5
  48. package/dist/commands/pack-install.d.ts +2 -3
  49. package/dist/commands/pack-install.js +6 -8
  50. package/dist/commands/rescue.d.ts +3 -2
  51. package/dist/commands/rescue.js +48 -34
  52. package/dist/commands/search.d.ts +6 -0
  53. package/dist/commands/search.js +24 -4
  54. package/dist/commands/secrets.d.ts +3 -4
  55. package/dist/commands/secrets.js +3 -20
  56. package/dist/commands/sources.js +6 -2
  57. package/dist/commands/sync-core.d.ts +8 -0
  58. package/dist/commands/sync-core.js +43 -0
  59. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +1830 -1468
  60. package/dist/hq-cloud-sync-runner/package.json +1 -1
  61. package/dist/lib/bot/api.d.ts +2 -1
  62. package/dist/lib/bot/api.js +2 -15
  63. package/dist/lib/capacity/accounts.d.ts +1 -1
  64. package/dist/lib/capacity/accounts.js +1 -1
  65. package/dist/lib/capacity/collectors/claude-oauth.d.ts +0 -2
  66. package/dist/lib/capacity/collectors/claude-oauth.js +0 -5
  67. package/dist/lib/capacity/freshness.d.ts +1 -1
  68. package/dist/lib/capacity/freshness.js +1 -1
  69. package/dist/lib/capacity/route.js +1 -1
  70. package/dist/lib/core-utils/delegate-helper-paths.d.ts +26 -0
  71. package/dist/lib/core-utils/delegate-helper-paths.js +33 -0
  72. package/dist/lib/daemon/catalog.d.ts +3 -0
  73. package/dist/lib/daemon/hook-requests.d.ts +1 -1
  74. package/dist/lib/daemon/hook-requests.js +4 -2
  75. package/dist/lib/daemon/jq-provision.d.ts +63 -0
  76. package/dist/lib/daemon/jq-provision.js +155 -0
  77. package/dist/lib/daemon/lanes-reconcile-guard.d.ts +4 -3
  78. package/dist/lib/daemon/lanes-reconcile-guard.js +4 -4
  79. package/dist/lib/daemon/mesh-owner.d.ts +4 -0
  80. package/dist/lib/daemon/mesh-owner.js +20 -0
  81. package/dist/lib/daemon/ops/policy.d.ts +3 -0
  82. package/dist/lib/daemon/ops/policy.js +32 -4
  83. package/dist/lib/daemon/run.js +17 -22
  84. package/dist/lib/daemon/server.d.ts +6 -0
  85. package/dist/lib/daemon/server.js +5 -0
  86. package/dist/lib/daemon/verified-jq.d.ts +96 -0
  87. package/dist/lib/daemon/verified-jq.js +337 -0
  88. package/dist/lib/doctor/checks/jq.js +16 -0
  89. package/dist/lib/doctor/deep/executor.d.ts +7 -0
  90. package/dist/lib/doctor/deep/executor.js +1 -1
  91. package/dist/lib/doctor/deep/parity.js +1 -27
  92. package/dist/lib/doctor/deep/sandbox.d.ts +2 -2
  93. package/dist/lib/doctor/deep/sandbox.js +3 -19
  94. package/dist/lib/doctor/fix/refresh-sync-handoff.js +52 -21
  95. package/dist/lib/doctor/fixtures/discover.d.ts +2 -0
  96. package/dist/lib/doctor/fixtures/discover.js +1 -1
  97. package/dist/lib/doctor/json-output.d.ts +1 -1
  98. package/dist/lib/doctor/registry.d.ts +6 -7
  99. package/dist/lib/doctor/registry.js +6 -7
  100. package/dist/lib/doctor/report.d.ts +9 -10
  101. package/dist/lib/doctor/report.js +4 -4
  102. package/dist/lib/environment/work-requirements.d.ts +1 -1
  103. package/dist/lib/environment/work-requirements.js +1 -1
  104. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  105. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  106. package/dist/lib/hook-engine/coverage.js +11 -3
  107. package/dist/lib/hook-engine/git-stop-config.json +510 -510
  108. package/dist/lib/hook-engine/native-precompact-compatibility.json +443 -443
  109. package/dist/lib/hook-engine/native-stop-compatibility.json +359 -359
  110. package/dist/lib/hot-channels/adapters/meetings.d.ts +1 -16
  111. package/dist/lib/hot-channels/adapters/meetings.js +3 -28
  112. package/dist/lib/hot-channels/adapters/slack.d.ts +3 -1
  113. package/dist/lib/hot-channels/adapters/slack.js +4 -1
  114. package/dist/lib/hot-channels/contract.d.ts +14 -0
  115. package/dist/lib/hot-channels/fleet-complete.d.ts +18 -2
  116. package/dist/lib/hot-channels/fleet-complete.js +29 -4
  117. package/dist/lib/hot-channels/meeting-source-ref.d.ts +17 -0
  118. package/dist/lib/hot-channels/meeting-source-ref.js +32 -0
  119. package/dist/lib/hot-channels/prompts/signals-pass.md +6 -1
  120. package/dist/lib/hot-channels/run.d.ts +10 -0
  121. package/dist/lib/hot-channels/run.js +34 -0
  122. package/dist/lib/hot-channels/signals-pass.d.ts +27 -0
  123. package/dist/lib/hot-channels/signals-pass.js +57 -2
  124. package/dist/lib/hot-channels/signals-runtime.js +3 -2
  125. package/dist/lib/jq/install.d.ts +27 -0
  126. package/dist/lib/jq/install.js +156 -0
  127. package/dist/lib/lanes/accounts.js +2 -2
  128. package/dist/lib/lanes/claude-balance.d.ts +6 -0
  129. package/dist/lib/lanes/claude-balance.js +124 -0
  130. package/dist/lib/lanes/grants.js +15 -2
  131. package/dist/lib/lanes/hq-root.d.ts +1 -1
  132. package/dist/lib/lanes/hq-root.js +1 -1
  133. package/dist/lib/lanes/links.d.ts +1 -1
  134. package/dist/lib/lanes/liveness.d.ts +3 -0
  135. package/dist/lib/lanes/liveness.js +61 -7
  136. package/dist/lib/lanes/models.d.ts +1 -1
  137. package/dist/lib/lanes/models.js +1 -1
  138. package/dist/lib/lanes/outpost-dispatch.d.ts +1 -1
  139. package/dist/lib/lanes/outpost-dispatch.js +13 -13
  140. package/dist/lib/lanes/outpost-pruner-install.js +1 -1
  141. package/dist/lib/lanes/questions.d.ts +1 -1
  142. package/dist/lib/lanes/questions.js +2 -2
  143. package/dist/lib/lanes/spawn.js +4 -6
  144. package/dist/lib/lanes/store.d.ts +13 -2
  145. package/dist/lib/lanes/store.js +13 -5
  146. package/dist/lib/lanes/types.d.ts +7 -7
  147. package/dist/lib/lanes/types.js +1 -1
  148. package/dist/lib/lanes/watcher-main.js +1 -1
  149. package/dist/lib/lanes/watcher.d.ts +1 -1
  150. package/dist/lib/lanes/watcher.js +1 -1
  151. package/dist/lib/mesh/live/daemon/doctor.js +7 -1
  152. package/dist/lib/mesh/live/daemon/install.d.ts +4 -0
  153. package/dist/lib/mesh/live/daemon/install.js +10 -0
  154. package/dist/lib/mesh/live/daemon/run.js +17 -0
  155. package/dist/lib/mesh/live/emit-retry.d.ts +20 -2
  156. package/dist/lib/mesh/live/emit-retry.js +57 -4
  157. package/dist/lib/mesh/live/emit.js +25 -4
  158. package/dist/lib/mesh/live/flush.d.ts +2 -0
  159. package/dist/lib/mesh/live/flush.js +21 -8
  160. package/dist/lib/mesh/live/spool.d.ts +9 -1
  161. package/dist/lib/mesh/live/spool.js +41 -29
  162. package/dist/lib/onboarding/cli/onboard.js +5 -0
  163. package/dist/lib/signals/sanitize.d.ts +19 -0
  164. package/dist/lib/signals/sanitize.js +103 -7
  165. package/dist/lib/signals/steps/upload.d.ts +40 -1
  166. package/dist/lib/signals/steps/upload.js +122 -6
  167. package/dist/lib/sync-core/access-refresh.d.ts +29 -0
  168. package/dist/lib/sync-core/access-refresh.js +97 -0
  169. package/dist/lib/sync-core/company-adoption.d.ts +33 -0
  170. package/dist/lib/sync-core/company-adoption.js +223 -0
  171. package/dist/lib/sync-core/engine-home.d.ts +1 -0
  172. package/dist/lib/sync-core/engine-owned.d.ts +13 -0
  173. package/dist/lib/sync-core/engine-owned.js +38 -0
  174. package/dist/lib/sync-core/hand-back.d.ts +17 -0
  175. package/dist/lib/sync-core/hand-back.js +23 -0
  176. package/dist/lib/sync-core/post-apply-reindex.d.ts +33 -0
  177. package/dist/lib/sync-core/post-apply-reindex.js +149 -0
  178. package/dist/lib/sync-core/reconcile.d.ts +10 -0
  179. package/dist/lib/sync-core/reconcile.js +117 -12
  180. package/dist/lib/sync-core/rollout-state.d.ts +11 -1
  181. package/dist/lib/sync-core/rollout-state.js +40 -4
  182. package/dist/lib/vault-sync-switches.d.ts +14 -0
  183. package/dist/lib/vault-sync-switches.js +22 -0
  184. package/dist/lib/windows/jq.d.ts +4 -0
  185. package/dist/lib/windows/jq.js +10 -39
  186. package/dist/lib/workers-registry/index.d.ts +1 -1
  187. package/dist/lib/workers-registry/index.js +8 -12
  188. package/dist/utils/callback-port-busy.d.ts +2 -2
  189. package/dist/utils/callback-port-busy.js +2 -2
  190. package/dist/utils/cli-network-lifecycle.js +1 -0
  191. package/dist/utils/client-health-contract.d.ts +2 -0
  192. package/dist/utils/client-health-contract.js +1 -1
  193. package/dist/utils/client-health.js +1 -9
  194. package/dist/utils/cognito-config.js +5 -0
  195. package/dist/utils/cognito-session.d.ts +4 -6
  196. package/dist/utils/cognito-session.js +4 -24
  197. package/dist/utils/github-tag-fallback.d.ts +16 -0
  198. package/dist/utils/github-tag-fallback.js +126 -0
  199. package/dist/utils/incomplete-install-error.js +1 -11
  200. package/dist/utils/install-tree-torn.d.ts +11 -0
  201. package/dist/utils/install-tree-torn.js +1 -1
  202. package/dist/utils/resident-package-preload.js +2 -1
  203. package/dist/utils/version-report.d.ts +2 -1
  204. package/dist/utils/version-report.js +40 -27
  205. package/docs/anywhere-runtime.md +8 -0
  206. package/package.json +9 -9
@@ -8,6 +8,7 @@ import { selfUpdateAndReexec } from '../utils/self-update.js';
8
8
  import { retrustCodexHooksAfterRescue } from '../utils/hook-trust.js';
9
9
  import { repairDanglingReleaseLinks } from '../lib/doctor/checks/release-links.js';
10
10
  import { PROD_SOURCE, STAGING_SOURCE, resolveGhToken } from '../utils/shipped-codex-hooks.js';
11
+ import { GitHubApiUnavailable, onceWarning, isTransientGitHubStatus, remoteTagSha, withGitTagFallback } from '../utils/github-tag-fallback.js';
11
12
  /**
12
13
  * Resolve the source repo + ref from the user's flags. Pure + exported for
13
14
  * tests. `latestTag` is the resolved latest release tag (prod only); ignored
@@ -104,48 +105,57 @@ function ghHeaders(token) {
104
105
  }
105
106
  // Thirty seconds gives GitHub time to respond while keeping the recovery command bounded.
106
107
  const GITHUB_REQUEST_TIMEOUT_MS = 30_000;
107
- async function githubJsonRequest(url, token) {
108
+ async function githubJsonRequest(url, token, fetchImpl = fetch) {
108
109
  const signal = AbortSignal.timeout(GITHUB_REQUEST_TIMEOUT_MS);
109
110
  try {
110
- const response = await fetch(url, { headers: ghHeaders(token), signal });
111
+ const response = await fetchImpl(url, { headers: ghHeaders(token), signal });
112
+ if (isTransientGitHubStatus(response.status)) {
113
+ throw new GitHubApiUnavailable(`GitHub API for ${url}: HTTP ${response.status}`);
114
+ }
111
115
  if (!response.ok)
112
116
  return { response };
113
117
  const body = (await response.json());
114
118
  return { response, body };
115
119
  }
116
120
  catch (error) {
121
+ if (error instanceof GitHubApiUnavailable)
122
+ throw error;
117
123
  if (signal.aborted)
118
- throw new Error('GitHub request timed out', { cause: error });
119
- throw error;
124
+ throw new GitHubApiUnavailable('GitHub request timed out', { cause: error });
125
+ throw new GitHubApiUnavailable('GitHub request failed on the network', { cause: error });
120
126
  }
121
127
  }
122
128
  /** Latest release tag for a repo, e.g. `v12.3.0`. Throws on failure. */
123
- export async function getLatestReleaseTag(repo, token) {
124
- const { response, body } = await githubJsonRequest(`https://api.github.com/repos/${repo}/releases/latest`, token);
125
- if (!response.ok) {
126
- throw new Error(`GitHub releases/latest for ${repo}: HTTP ${response.status}`);
127
- }
128
- if (!body?.tag_name)
129
- throw new Error(`no tag_name in latest release for ${repo}`);
130
- return body.tag_name;
129
+ export async function getLatestReleaseTag(repo, token, deps = {}) {
130
+ return withGitTagFallback(async () => {
131
+ const { response, body } = await githubJsonRequest(`https://api.github.com/repos/${repo}/releases/latest`, token, deps.fetchImpl);
132
+ if (!response.ok) {
133
+ throw new Error(`GitHub releases/latest for ${repo}: HTTP ${response.status}`);
134
+ }
135
+ if (!body?.tag_name)
136
+ throw new Error(`no tag_name in latest release for ${repo}`);
137
+ return body.tag_name;
138
+ }, repo, undefined, tag => tag, deps);
131
139
  }
132
140
  /** Resolve a tag to its commit SHA, dereferencing annotated tags. */
133
- export async function resolveTagSha(repo, tag, token) {
134
- const { response: refRes, body: ref } = await githubJsonRequest(`https://api.github.com/repos/${repo}/git/ref/tags/${encodeURIComponent(tag)}`, token);
135
- if (!refRes.ok)
136
- throw new Error(`git/ref/tags/${tag} for ${repo}: HTTP ${refRes.status}`);
137
- const obj = ref?.object;
138
- if (!obj?.sha)
139
- throw new Error(`no object.sha for tag ${tag} in ${repo}`);
140
- if (obj.type !== 'tag')
141
- return obj.sha; // lightweight tag → already a commit
142
- // Annotated tag → dereference to the commit it points at.
143
- const { response: tagRes, body: annotated } = await githubJsonRequest(`https://api.github.com/repos/${repo}/git/tags/${obj.sha}`, token);
144
- if (!tagRes.ok)
145
- throw new Error(`git/tags/${obj.sha} for ${repo}: HTTP ${tagRes.status}`);
146
- if (!annotated?.object?.sha)
147
- throw new Error(`annotated tag ${tag} has no target sha`);
148
- return annotated.object.sha;
141
+ export async function resolveTagSha(repo, tag, token, deps = {}) {
142
+ return withGitTagFallback(async () => {
143
+ const { response: refRes, body: ref } = await githubJsonRequest(`https://api.github.com/repos/${repo}/git/ref/tags/${encodeURIComponent(tag)}`, token, deps.fetchImpl);
144
+ if (!refRes.ok)
145
+ throw new Error(`git/ref/tags/${tag} for ${repo}: HTTP ${refRes.status}`);
146
+ const obj = ref?.object;
147
+ if (!obj?.sha)
148
+ throw new Error(`no object.sha for tag ${tag} in ${repo}`);
149
+ if (obj.type !== 'tag')
150
+ return obj.sha; // lightweight tag → already a commit
151
+ // Annotated tag → dereference to the commit it points at.
152
+ const { response: tagRes, body: annotated } = await githubJsonRequest(`https://api.github.com/repos/${repo}/git/tags/${obj.sha}`, token, deps.fetchImpl);
153
+ if (!tagRes.ok)
154
+ throw new Error(`git/tags/${obj.sha} for ${repo}: HTTP ${tagRes.status}`);
155
+ if (!annotated?.object?.sha)
156
+ throw new Error(`annotated tag ${tag} has no target sha`);
157
+ return annotated.object.sha;
158
+ }, repo, tag, output => remoteTagSha(output, tag), deps);
149
159
  }
150
160
  /** Read the installed HQ core version from `{hqRoot}/core/core.yaml`. */
151
161
  function readInstalledVersion(hqRoot) {
@@ -176,6 +186,7 @@ export function registerRescueCommand(program) {
176
186
  .option('--no-backup', 'Skip the pre-op safety snapshot under ~/.hq/backups')
177
187
  .option('--no-self-update', 'Skip updating hq-cli itself to the latest version first')
178
188
  .option('--cloud-update', 'Cloud-update mode')
189
+ .option('--verbose', 'Show diagnostic details when recovery fails')
179
190
  .action(async (opts) => {
180
191
  try {
181
192
  // Bring the CLI itself to latest first: the rescue script is bundled
@@ -190,24 +201,25 @@ export function registerRescueCommand(program) {
190
201
  }
191
202
  const hqRoot = opts.hqRoot ?? findHqRoot();
192
203
  const token = resolveGhToken();
204
+ const lookupDeps = { warn: onceWarning() };
193
205
  let { source, ref } = resolveRescueTarget(opts);
194
206
  let floorSha = opts.floorSha;
195
207
  if (!opts.staging) {
196
208
  // Prod: resolve the latest release tag when no explicit ref, and
197
209
  // pin the floor to the installed version's commit when possible.
198
210
  if (!ref) {
199
- ref = await getLatestReleaseTag(source, token);
211
+ ref = await getLatestReleaseTag(source, token, lookupDeps);
200
212
  }
201
213
  if (!floorSha) {
202
214
  const installed = readInstalledVersion(hqRoot);
203
215
  if (installed) {
204
216
  try {
205
- floorSha = await resolveTagSha(source, `v${installed}`, token);
217
+ floorSha = await resolveTagSha(source, `v${installed}`, token, lookupDeps);
206
218
  }
207
219
  catch (err) {
208
- console.warn(chalk.yellow(`Warning: couldn't resolve the floor commit for v${installed} ` +
209
- `(${err instanceof Error ? err.message : 'unknown error'}); ` +
210
- `falling back to the on-disk sync stamp.`));
220
+ if (opts.verbose)
221
+ console.error(err);
222
+ console.warn(chalk.yellow('Could not check the installed version; using the saved sync history.'));
211
223
  }
212
224
  }
213
225
  }
@@ -234,7 +246,9 @@ export function registerRescueCommand(program) {
234
246
  process.exit(status);
235
247
  }
236
248
  catch (error) {
237
- console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
249
+ if (opts.verbose)
250
+ console.error(error);
251
+ console.error('Could not complete HQ recovery; check your connection and try again.');
238
252
  process.exit(1);
239
253
  }
240
254
  });
@@ -30,6 +30,12 @@ export type SearchOptions = {
30
30
  */
31
31
  export declare function normalizeQueryForQmd(query: string): string;
32
32
  export declare function buildSearchArgs(query: string, options?: SearchOptions): string[];
33
+ /**
34
+ * Resolve a `--mode` value to a canonical mode, or throw a usage error. Matching
35
+ * ignores case and surrounding whitespace. Aliases live in a Map so inherited
36
+ * object keys such as `constructor` or `__proto__` are never treated as modes.
37
+ */
38
+ export declare function resolveSearchMode(mode: string | undefined): SearchMode;
33
39
  export declare function buildGetArgs(document: string, options?: Pick<SearchOptions, 'collection'>): string[];
34
40
  export declare function registerSearchCommand(program: Command): void;
35
41
  export {};
@@ -51,6 +51,28 @@ export function buildSearchArgs(query, options = {}) {
51
51
  args.push('--json');
52
52
  return args;
53
53
  }
54
+ const SEARCH_MODES = ['keyword', 'semantic', 'hybrid'];
55
+ /**
56
+ * Accepted spellings that are not canonical mode names. qmd describes its BM25
57
+ * pass as "lexical" (and its query documents use a `lex:` prefix), so callers
58
+ * that learned the vocabulary from qmd ask for `--mode lexical`. That is the
59
+ * keyword (BM25) search, so it maps there instead of failing (Sentry HQ-CLI-J2).
60
+ */
61
+ const SEARCH_MODE_ALIASES = new Map([['lexical', 'keyword']]);
62
+ /**
63
+ * Resolve a `--mode` value to a canonical mode, or throw a usage error. Matching
64
+ * ignores case and surrounding whitespace. Aliases live in a Map so inherited
65
+ * object keys such as `constructor` or `__proto__` are never treated as modes.
66
+ */
67
+ export function resolveSearchMode(mode) {
68
+ const value = (mode ?? 'keyword').trim().toLowerCase();
69
+ if (SEARCH_MODES.includes(value))
70
+ return value;
71
+ const alias = SEARCH_MODE_ALIASES.get(value);
72
+ if (alias)
73
+ return alias;
74
+ throw new Error(`Unknown search mode '${mode}'. Expected keyword, semantic, or hybrid.`);
75
+ }
54
76
  export function buildGetArgs(document, options = {}) {
55
77
  const args = ['get', document];
56
78
  if (options.collection)
@@ -85,10 +107,8 @@ export function registerSearchCommand(program) {
85
107
  process.exitCode = 1;
86
108
  return;
87
109
  }
88
- if (!['keyword', 'semantic', 'hybrid'].includes(options.mode ?? 'keyword')) {
89
- throw new Error(`Unknown search mode '${options.mode}'. Expected keyword, semantic, or hybrid.`);
90
- }
91
- relay(runQmd(buildSearchArgs(query, options)));
110
+ const mode = resolveSearchMode(options.mode);
111
+ relay(runQmd(buildSearchArgs(query, { ...options, mode })));
92
112
  });
93
113
  search
94
114
  .command('get <document>')
@@ -25,11 +25,10 @@ import { vaultApiFetch, getCompanyUid, getEntityUid } from "../utils/vault-api.j
25
25
  export type { VaultApiOptions } from "../utils/vault-api.js";
26
26
  export { vaultApiFetch, getCompanyUid, getEntityUid };
27
27
  /**
28
- * Mirrors `RESOURCE_SURFACES` in hq-pro
29
- * `src/journey/limited-resource-telemetry.ts`. Keep this list in sync with
30
- * the server so CLI telemetry cannot silently fall back to `api`.
28
+ * Telemetry surface sent with `hq secrets set`. hq-pro accepts it because it is
29
+ * listed in `RESOURCE_SURFACES` in `src/journey/limited-resource-telemetry.ts`;
30
+ * an unlisted surface falls back to the server default.
31
31
  */
32
- export declare const HQ_PRO_RESOURCE_SURFACES: readonly ["api", "bot_invite", "bot_join_now", "calendar_auto_schedule", "calendar_preferences", "cli_secrets_set", "console_secrets_form", "deploy_precheck", "external_connection", "factory_install", "integrations_connect", "oauth_callback", "plan_limit_check", "secrets_input_link", "web"];
33
32
  export declare const CLI_SECRETS_SET_SURFACE = "cli_secrets_set";
34
33
  /**
35
34
  * Shown when `secrets share` / `unshare` gets a 403. Changing a secret's
@@ -107,27 +107,10 @@ import { runSandboxJobAfterSubmission } from "../utils/secrets-sandbox-resident.
107
107
  import { renderSecretInputLink, SECRET_LINK_FORMATS, } from "../lib/secret-input-link.js";
108
108
  export { vaultApiFetch, getCompanyUid, getEntityUid };
109
109
  /**
110
- * Mirrors `RESOURCE_SURFACES` in hq-pro
111
- * `src/journey/limited-resource-telemetry.ts`. Keep this list in sync with
112
- * the server so CLI telemetry cannot silently fall back to `api`.
110
+ * Telemetry surface sent with `hq secrets set`. hq-pro accepts it because it is
111
+ * listed in `RESOURCE_SURFACES` in `src/journey/limited-resource-telemetry.ts`;
112
+ * an unlisted surface falls back to the server default.
113
113
  */
114
- export const HQ_PRO_RESOURCE_SURFACES = [
115
- "api",
116
- "bot_invite",
117
- "bot_join_now",
118
- "calendar_auto_schedule",
119
- "calendar_preferences",
120
- "cli_secrets_set",
121
- "console_secrets_form",
122
- "deploy_precheck",
123
- "external_connection",
124
- "factory_install",
125
- "integrations_connect",
126
- "oauth_callback",
127
- "plan_limit_check",
128
- "secrets_input_link",
129
- "web",
130
- ];
131
114
  export const CLI_SECRETS_SET_SURFACE = "cli_secrets_set";
132
115
  /**
133
116
  * Cognito session for secrets surfaces hq-pro serves on the JWT routes only —
@@ -30,7 +30,7 @@ import { SOURCE_CHANNELS, assertSourceChannel, resolveEntity, listAvailableEntit
30
30
  import { ensureCognitoToken, ensureCognitoIdToken, buildVaultConfig, DEFAULT_COGNITO, DEFAULT_HQ_ROOT, } from "../utils/cognito-session.js";
31
31
  import { getCompanyUid, vaultApiFetch } from "../utils/vault-api.js";
32
32
  import { isAuthError } from "../utils/auth-error.js";
33
- import { IntegrationsCliError, callGateway, fetchUsableApps, gatewayResultIsError, isBuiltInGatewayProvider, raiseForResponse, toolPrefixForProvider, unwrapGatewayResult, } from "./integrations-core.js";
33
+ import { IntegrationsCliError, callGateway, fetchIntegrationsSummary, gatewayResultIsError, isBuiltInGatewayProvider, raiseForResponse, toolPrefixForProvider, unwrapGatewayResult, } from "./integrations-core.js";
34
34
  import { Sentry } from "../sentry.js";
35
35
  import { resolveUploadAuthor } from "../utils/upload-author.js";
36
36
  import { createSignalsAlertChannelPoster, raiseSignalsFailureAlerts } from "../lib/hot-channels/alert.js";
@@ -342,9 +342,13 @@ async function fetchHotChannels(token, companyUid) {
342
342
  * the gateway routes each call by connection id.
343
343
  */
344
344
  export function gatewaySyncDeps(token, companyUid) {
345
+ // One summary read per sync serves both the usable apps and the known connections.
346
+ let summary;
347
+ const readSummary = () => (summary ??= fetchIntegrationsSummary(token, companyUid));
345
348
  return {
346
349
  fetchHotChannels: () => fetchHotChannels(token, companyUid),
347
- fetchUsableApps: async () => (await fetchUsableApps(token, companyUid)).apps,
350
+ fetchUsableApps: async () => (await readSummary()).apps,
351
+ fetchKnownConnections: async () => (await readSummary()).knownConnections,
348
352
  async callTool(app, tool, args) {
349
353
  const idempotencyKey = `hq-sources-sync-${randomUUID()}`;
350
354
  const params = isBuiltInGatewayProvider(app.provider)
@@ -1,6 +1,7 @@
1
1
  import type { Command } from "commander";
2
2
  import { type SyncCoreReconcileResult } from "../lib/sync-core/reconcile.js";
3
3
  import { type EngineManifestScope } from "../lib/sync-core/manifest-scopes.js";
4
+ import { type RolloutVault } from "../lib/sync-core/rollout-state.js";
4
5
  import type { RunSyncManifestOptions, RunSyncManifestOutcome, SyncManifestDeps } from "./sync-manifest.js";
5
6
  export interface SyncCoreReconcileCommandOptions {
6
7
  hqRoot?: string;
@@ -23,7 +24,14 @@ export interface SyncCoreCommandDeps {
23
24
  out: (line: string) => void;
24
25
  err: (line: string) => void;
25
26
  now?: () => Date;
27
+ /** Runs the hq-cloud reindex against the HQ folder (tests replace it). */
28
+ reindex?: (hqRoot: string) => {
29
+ status: number;
30
+ } | Promise<{
31
+ status: number;
32
+ }>;
26
33
  }
34
+ export declare function runPostApplyReindex(hqRoot: string, vaults: readonly RolloutVault[], d: SyncCoreCommandDeps, log: (line: string) => void): Promise<void>;
27
35
  export declare function runSyncCoreReconcile(opts: SyncCoreReconcileCommandOptions, d?: SyncCoreCommandDeps): Promise<SyncCoreReconcileResult>;
28
36
  export interface SyncCoreManifestCommandOptions {
29
37
  hqRoot?: string;
@@ -10,9 +10,35 @@ import { readCompanyDownloadStreams, readCompanyRolloutFlag } from "../lib/sync-
10
10
  import { reconcileSyncCore } from "../lib/sync-core/reconcile.js";
11
11
  import { engineOwnedManifestScopes, manifestScopeArg } from "../lib/sync-core/manifest-scopes.js";
12
12
  import { readSyncCoreRolloutState, syncCoreRolloutStatePath } from "../lib/sync-core/rollout-state.js";
13
+ import { reindexAfterEngineChanges } from "../lib/sync-core/post-apply-reindex.js";
13
14
  import { readVaultSyncSwitches } from "../lib/vault-sync-switches.js";
14
15
  import { isSyncCoreVaultUid } from "../lib/sync-core/vault-uid.js";
15
16
  import { effectiveEngineSettings, readSyncCoreVaultSettings, setSyncCoreVaultSetting, SyncCoreVaultSettingError, } from "../lib/sync-core/vault-settings.js";
17
+ const SESSION_LOG_CAPTURE_QUIET_FOR_MS = 10 * 60_000;
18
+ const SESSION_LOG_CAPTURE_MAX_STALENESS_MS = 60 * 60_000;
19
+ export async function runPostApplyReindex(hqRoot, vaults, d, log) {
20
+ try {
21
+ await reindexAfterEngineChanges({
22
+ home: d.home,
23
+ hqRoot,
24
+ vaults,
25
+ reindex: d.reindex ?? (async (root) => {
26
+ const { reindex } = await import("@indigoai-us/hq-cloud");
27
+ return reindex({
28
+ repoRoot: root,
29
+ lockTimeoutSec: 0,
30
+ sessionLogQuietForMs: SESSION_LOG_CAPTURE_QUIET_FOR_MS,
31
+ sessionLogMaxStalenessMs: SESSION_LOG_CAPTURE_MAX_STALENESS_MS,
32
+ });
33
+ }),
34
+ now: d.now,
35
+ log,
36
+ });
37
+ }
38
+ catch (error) {
39
+ d.err(`warning: could not check whether the new sync engine changed skills or workers: ${error instanceof Error ? error.message : String(error)}`);
40
+ }
41
+ }
16
42
  function defaultDeps() {
17
43
  return {
18
44
  home: os.homedir(),
@@ -42,6 +68,20 @@ async function resolveHqRoot(flag, env) {
42
68
  return fallback;
43
69
  throw new Error("no HQ folder found; pass --hq-root <path>");
44
70
  }
71
+ async function machineTypeHere(d) {
72
+ const [{ detectMachineType }, { readDaemonConfig }] = await Promise.all([
73
+ import("../lib/daemon/machine-type.js"),
74
+ import("../lib/daemon/config.js"),
75
+ ]);
76
+ return detectMachineType(undefined, {
77
+ platform: d.platform,
78
+ env: d.env,
79
+ home: d.home,
80
+ savedType: readDaemonConfig(daemonPaths(d.home, d.env).configPath).machineType,
81
+ existsSync: fs.existsSync,
82
+ readFileSync: (p) => fs.readFileSync(p, "utf8"),
83
+ }).type;
84
+ }
45
85
  export async function runSyncCoreReconcile(opts, d = defaultDeps()) {
46
86
  const hqRoot = await resolveHqRoot(opts.hqRoot, d.env);
47
87
  const [{ VaultClient }, { buildVaultConfig, ensureCognitoIdToken, machineTokenCacheFile, wantsMachineCognitoTokens }] = await Promise.all([import("@indigoai-us/hq-cloud"), import("../utils/cognito-session.js")]);
@@ -64,6 +104,8 @@ export async function runSyncCoreReconcile(opts, d = defaultDeps()) {
64
104
  getEntity: async () => null,
65
105
  }),
66
106
  readRolloutFlag: (companyUid) => readCompanyRolloutFlag(companyUid, token, { env: d.env }),
107
+ resolveCompany: (companyUid) => client.entity.get(companyUid),
108
+ machineType: await machineTypeHere(d),
67
109
  readDownloadStreams: (companyUid) => readCompanyDownloadStreams(companyUid, token, { env: d.env }),
68
110
  ensureBinary: (release) => ensureSyncCoreBinary({ home: d.home, platform: d.platform, arch: d.arch, release, env: d.env }),
69
111
  platform: d.platform,
@@ -71,6 +113,7 @@ export async function runSyncCoreReconcile(opts, d = defaultDeps()) {
71
113
  readPin: () => readSyncCorePin({ env: d.env }),
72
114
  log: opts.json ? () => { } : d.out,
73
115
  });
116
+ await runPostApplyReindex(hqRoot, result.state.vaults, d, opts.json ? () => { } : d.out);
74
117
  if (opts.json)
75
118
  d.out(JSON.stringify(result.state, null, 2));
76
119
  else if (result.state.vaults.length === 0)