@indigoai-us/hq-cli 5.111.2 → 5.113.0

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 (34) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/bin/hq-auth-refresh.d.ts +2 -0
  3. package/dist/bin/hq-auth-refresh.js +12 -6
  4. package/dist/command-catalog.generated.d.ts +6399 -0
  5. package/dist/command-catalog.generated.js +8275 -0
  6. package/dist/command-registration-plan.d.ts +394 -0
  7. package/dist/command-registration-plan.js +103 -0
  8. package/dist/commands/core.js +18 -0
  9. package/dist/commands/index-cmd.d.ts +2 -0
  10. package/dist/commands/index-cmd.js +15 -0
  11. package/dist/lazy-commands.d.ts +20 -44
  12. package/dist/lazy-commands.js +57 -58
  13. package/dist/lib/core-utils/qmd-reindex-after-sync.d.ts +1 -0
  14. package/dist/lib/core-utils/qmd-reindex-after-sync.js +12 -0
  15. package/dist/lib/core-utils/sentry-report.d.ts +76 -0
  16. package/dist/lib/core-utils/sentry-report.js +255 -0
  17. package/dist/lib/search-index/background.d.ts +2 -0
  18. package/dist/lib/search-index/background.js +28 -0
  19. package/dist/lib/search-index/max-doc-bytes.d.ts +220 -0
  20. package/dist/lib/search-index/max-doc-bytes.js +463 -0
  21. package/dist/main.d.ts +6 -0
  22. package/dist/main.js +87 -29
  23. package/dist/register-all.d.ts +4 -29
  24. package/dist/register-all.js +4 -235
  25. package/dist/sentry.d.ts +8 -2
  26. package/dist/sentry.js +17 -1
  27. package/dist/utils/cli-telemetry.d.ts +2 -1
  28. package/dist/utils/cli-telemetry.js +5 -5
  29. package/dist/utils/contribution-table.d.ts +1 -1
  30. package/dist/utils/version-check.d.ts +4 -1
  31. package/dist/utils/version-check.js +2 -2
  32. package/dist/utils/version-gate.d.ts +5 -1
  33. package/dist/utils/version-gate.js +4 -4
  34. package/package.json +3 -2
package/dist/main.d.ts CHANGED
@@ -5,6 +5,12 @@
5
5
  import "./node-preflight.js";
6
6
  import "./node-network-compat.js";
7
7
  import { Sentry } from "./sentry.js";
8
+ /**
9
+ * Total time one CLI invocation may await foreground network work. This spans
10
+ * the hard version decision, pre-action observability, and release-health
11
+ * finalization; command execution itself does not consume this allowance.
12
+ */
13
+ export declare const FOREGROUND_NETWORK_BUDGET_MS = 1500;
8
14
  export type StreamErrorDependencies = {
9
15
  stderr: Pick<typeof process.stderr, "write">;
10
16
  exit: (code: number) => void;
package/dist/main.js CHANGED
@@ -9,7 +9,7 @@ import "./node-network-compat.js";
9
9
  import path from "node:path";
10
10
  import { fileURLToPath } from "node:url";
11
11
  import { Command } from "commander";
12
- import { initSentry, Sentry } from "./sentry.js";
12
+ import { finishSentrySession, initSentry, Sentry } from "./sentry.js";
13
13
  import { sanitizeArgv } from "./utils/feedback-diagnostics.js";
14
14
  import { environmentalFsErrorMessage } from "./utils/environmental-error.js";
15
15
  import { syncStateLockMessage } from "./utils/sync-state-lock-error.js";
@@ -41,7 +41,7 @@ import { refreshVersionCache, staleAgainstCachedLatest, } from "./utils/version-
41
41
  import { enforceVersionGate, shouldSkipGate, } from "./utils/version-gate.js";
42
42
  import { autoUpdateAndReexec } from "./utils/self-update.js";
43
43
  import { CLI_VERSION } from "./cli-version.js";
44
- import { findLazyCommand } from "./lazy-commands.js";
44
+ import { findLazyCommand, registerCommandCatalog } from "./lazy-commands.js";
45
45
  import { emitCliSessionStarted } from "./utils/cli-telemetry.js";
46
46
  import { reportCliClientHealthInvocation } from "./utils/client-health.js";
47
47
  import { settleWithin } from "./utils/settle-with-timeout.js";
@@ -52,8 +52,57 @@ import { registerCommandsWithRecovery } from "./startup-registration.js";
52
52
  import { installTreeTornCaptureContext, installTreeTornStderrLine, isInstallTreeTornError, } from "./utils/install-tree-torn.js";
53
53
  import { isVaultAccessDeniedError, vaultAccessDeniedMessage, } from "./utils/vault-access-denied-error.js";
54
54
  import { fallbackOperatorMessage, unexpectedCliErrorMessage } from "./utils/unexpected-cli-error.js";
55
- /** Hard upper bound for non-user-visible release-health finalization. */
56
- const RELEASE_HEALTH_SETTLE_TIMEOUT_MS = 3_000;
55
+ /**
56
+ * Total time one CLI invocation may await foreground network work. This spans
57
+ * the hard version decision, pre-action observability, and release-health
58
+ * finalization; command execution itself does not consume this allowance.
59
+ */
60
+ export const FOREGROUND_NETWORK_BUDGET_MS = 1_500;
61
+ /**
62
+ * Release health must always have a chance to flush an already-captured error
63
+ * and refresh the cache after a command. Reserve this before earlier work.
64
+ */
65
+ const FINALIZATION_FOREGROUND_WAIT_MS = 500;
66
+ /**
67
+ * A stalled version endpoint must leave the invocation heartbeat a chance to
68
+ * send. A timely blocked response is still enforced exactly as before.
69
+ */
70
+ const VERSION_GATE_FOREGROUND_WAIT_MS = 750;
71
+ /** Existing telemetry/health cap, now also bounded by the shared deadline. */
72
+ const OBSERVABILITY_FOREGROUND_WAIT_MS = 1_200;
73
+ /**
74
+ * Shared accounting for awaited foreground network work. Each lifecycle phase
75
+ * debits only the bounded await it performs; ordinary command runtime leaves
76
+ * the allowance untouched. Earlier phases reserve the finalization floor, so
77
+ * error flushing cannot disappear after a long command.
78
+ */
79
+ class ForegroundNetworkBudget {
80
+ budgetMs;
81
+ now;
82
+ consumedMs = 0;
83
+ constructor(budgetMs = FOREGROUND_NETWORK_BUDGET_MS, now = () => performance.now()) {
84
+ this.budgetMs = budgetMs;
85
+ this.now = now;
86
+ }
87
+ timeoutFor(phaseMaximumMs, reservedMs = 0) {
88
+ return Math.max(0, Math.min(phaseMaximumMs, Math.floor(this.budgetMs - reservedMs - this.consumedMs)));
89
+ }
90
+ async waitFor(phaseMaximumMs, reservedMs, work) {
91
+ const timeoutMs = this.timeoutFor(phaseMaximumMs, reservedMs);
92
+ if (timeoutMs === 0)
93
+ return undefined;
94
+ const startedAt = this.now();
95
+ try {
96
+ return await work(timeoutMs);
97
+ }
98
+ finally {
99
+ // A timer cannot interrupt synchronous work. Do not let a blocked event
100
+ // loop consume the finalization reserve as though it were network wait.
101
+ this.consumedMs += Math.min(timeoutMs, Math.max(0, this.now() - startedAt));
102
+ }
103
+ }
104
+ }
105
+ let activeForegroundNetworkBudget;
57
106
  /**
58
107
  * The RUNNING install's own entrypoint (`<pkg>/dist/index.js`), used as the
59
108
  * torn-install recovery re-exec target. It must be this resolved path — never
@@ -110,17 +159,23 @@ program
110
159
  .version(CLI_VERSION);
111
160
  program.hook("preAction", async () => {
112
161
  // Both are best-effort and fully swallowed: neither can change the command's
113
- // result or exit code. The 1.2s bound they carry is a TIMER, so it only
114
- // preempts asynchronous work synchronous work inside them runs to
115
- // completion regardless, because the timer cannot be serviced while the
116
- // event loop is blocked. Keep anything added here asynchronous, or
117
- // separately cheap: this hook is on the path of EVERY hq command.
118
- await Promise.all([
119
- emitCliSessionStarted(),
120
- reportCliClientHealthInvocation(),
121
- ]);
162
+ // result or exit code. They receive only the shared pre-finalization
163
+ // allowance (up to 1.2s), and that bound is a TIMER, so it only preempts
164
+ // asynchronous work synchronous work inside them runs to completion
165
+ // regardless, because the timer cannot be serviced while the event loop is
166
+ // blocked. Keep anything added here asynchronous, or separately cheap: this
167
+ // hook is on the path of EVERY hq command.
168
+ const budget = activeForegroundNetworkBudget;
169
+ if (!budget)
170
+ return;
171
+ await budget.waitFor(OBSERVABILITY_FOREGROUND_WAIT_MS, FINALIZATION_FOREGROUND_WAIT_MS, (timeoutMs) => Promise.all([
172
+ emitCliSessionStarted(timeoutMs),
173
+ reportCliClientHealthInvocation({ timeoutMs }),
174
+ ]));
122
175
  });
123
176
  export async function runCli() {
177
+ const foregroundNetworkBudget = new ForegroundNetworkBudget();
178
+ activeForegroundNetworkBudget = foregroundNetworkBudget;
124
179
  // Begin one registry refresh without awaiting it. Every command gate reads
125
180
  // only the client's held snapshot and falls back locally, so an offline or
126
181
  // slow registry cannot delay command parsing or alter a command failure.
@@ -149,12 +204,12 @@ export async function runCli() {
149
204
  // `version-check.ts`); whichever fires first re-execs, and the child
150
205
  // carries a guard env so it can never update again.
151
206
  if (!shouldSkipGate(process.argv)) {
152
- const gate = await enforceVersionGate(async (decision) => {
207
+ const gate = (await foregroundNetworkBudget.waitFor(VERSION_GATE_FOREGROUND_WAIT_MS, FINALIZATION_FOREGROUND_WAIT_MS, (timeoutMs) => enforceVersionGate(async (decision) => {
153
208
  const outcome = await autoUpdateAndReexec(process.argv, decision.latestVersion);
154
209
  if (outcome.action === "reexec")
155
210
  reexecStatus = outcome.reexecStatus ?? 0;
156
211
  return outcome.action === "reexec";
157
- });
212
+ }, { timeoutMs }))) ?? "continue";
158
213
  if (gate === "reexec")
159
214
  return;
160
215
  const cachedLatest = staleAgainstCachedLatest();
@@ -166,15 +221,11 @@ export async function runCli() {
166
221
  }
167
222
  }
168
223
  }
169
- // Register only what this invocation needs. A hot command named in the
170
- // lazy manifest imports its own module and nothing else; everything else —
171
- // `--help`, a bare `hq`, an unknown command, any command not on the
172
- // manifest falls back to the complete graph, so its behaviour is
173
- // unchanged. See register-all.ts for the measurements that motivated this.
174
- // The same lazy/full registration as before, wrapped so it recovers ONCE if
175
- // a global reinstall is tearing the install tree out from under these
176
- // deferred imports (Sentry HQ-CLI-1G/1H/1J/1K). Which modules are imported,
177
- // and in what order, is unchanged — only the failure handling is added.
224
+ // Register every contributor for the selected root only. Root help and
225
+ // unknown-command recovery use generated metadata, so they keep the full
226
+ // Commander surface without evaluating every command implementation.
227
+ // Registration remains inside the torn-install recovery boundary: deferred
228
+ // import failures still receive the same one-shot settled-tree re-exec.
178
229
  const registration = await registerCommandsWithRecovery({
179
230
  register: async () => {
180
231
  const lazy = findLazyCommand(process.argv);
@@ -182,8 +233,7 @@ export async function runCli() {
182
233
  await lazy.register(program);
183
234
  }
184
235
  else {
185
- const { registerAllCommands } = await import("./register-all.js");
186
- registerAllCommands(program);
236
+ registerCommandCatalog(program);
187
237
  }
188
238
  },
189
239
  argv: process.argv,
@@ -207,16 +257,24 @@ export async function runCli() {
207
257
  // process.exitCode — safe to run after exit codes have been set.
208
258
  emitPlanLimitNag();
209
259
  // Release health: finalize the per-run session before the flush.
210
- Sentry.endSession();
260
+ finishSentrySession();
211
261
  // Neither task may turn a successful command into Node's
212
262
  // `unsettled top-level await` exit. They are observability-only after the
213
263
  // command has completed, so a bounded best-effort wait is the terminal
214
- // lifecycle boundary for this invocation.
215
- await settleWithin([refreshVersionCache(), Sentry.flush(2000)], RELEASE_HEALTH_SETTLE_TIMEOUT_MS);
264
+ // lifecycle boundary for this invocation. The budget reserves this 500 ms
265
+ // slice even when the command itself was long-running.
266
+ const releaseHealthTimeoutMs = foregroundNetworkBudget.timeoutFor(FINALIZATION_FOREGROUND_WAIT_MS);
267
+ await settleWithin([
268
+ refreshVersionCache({ timeoutMs: releaseHealthTimeoutMs }),
269
+ Sentry.flush(releaseHealthTimeoutMs),
270
+ ], releaseHealthTimeoutMs);
216
271
  // Last, so it wins over anything the (skipped) command path would have
217
272
  // set: the re-exec'd child's status IS this invocation's result.
218
273
  if (reexecStatus !== null)
219
274
  process.exitCode = reexecStatus;
275
+ if (activeForegroundNetworkBudget === foregroundNetworkBudget) {
276
+ activeForegroundNetworkBudget = undefined;
277
+ }
220
278
  }
221
279
  }
222
280
  const defaultTopLevelErrorDependencies = {
@@ -1,32 +1,7 @@
1
1
  /**
2
- * The full hq command graph every `register*Command` call, moved here verbatim
3
- * from main.ts.
4
- *
5
- * WHY IT IS ITS OWN MODULE: these 54 imports pull ~60 command modules and their
6
- * dependency subtrees, and main.ts used to load all of them at module scope. On
7
- * an outpost that cost real CPU, because the agent fleet calls `hq secrets`
8
- * about 39 times a minute and each invocation paid for the entire graph before
9
- * running one command. Measured on Outpost 2 (i-09424eff61920a4ac), CPU-seconds
10
- * per process:
11
- *
12
- * node -e "" 0.03
13
- * dist/commands/secrets.js 1.13 <- what `hq secrets` actually needs
14
- * dist/main.js (full graph) 1.88 <- what it used to pay
15
- *
16
- * So ~0.75 CPU-seconds of every `hq secrets` was spent importing commands it
17
- * never ran. At 39 invocations/minute that is ~0.5 of a core, continuously.
18
- *
19
- * Splitting the graph out lets the entrypoint import ONE command module for the
20
- * hot paths named in lazy-commands.ts, and fall back to this module — the
21
- * complete, unchanged registration — for everything else: `--help`, a bare
22
- * `hq`, an unknown command, and every command not in that manifest. Anything
23
- * not on the manifest therefore behaves exactly as before.
24
- *
25
- * Keep this list and lazy-commands.ts in sync through the parity test in
26
- * lazy-commands.test.ts, which registers both ways and compares the resulting
27
- * command shapes. Same discipline as commands/scaffold-fast.ts and core.ts.
2
+ * Complete command registration, retained as the eager reference used by the
3
+ * generated-catalog check and parity tests. Runtime dispatch uses the same
4
+ * plan one root at a time through lazy-commands.ts.
28
5
  */
29
- import type { Command } from "commander";
30
- /** Register the complete hq command graph onto `program`. */
31
- export declare function registerAllCommands(program: Command): void;
6
+ export { registerAllCommands, registerCommandRoot } from "./command-registration-plan.js";
32
7
  //# sourceMappingURL=register-all.d.ts.map
@@ -1,238 +1,7 @@
1
1
  /**
2
- * The full hq command graph every `register*Command` call, moved here verbatim
3
- * from main.ts.
4
- *
5
- * WHY IT IS ITS OWN MODULE: these 54 imports pull ~60 command modules and their
6
- * dependency subtrees, and main.ts used to load all of them at module scope. On
7
- * an outpost that cost real CPU, because the agent fleet calls `hq secrets`
8
- * about 39 times a minute and each invocation paid for the entire graph before
9
- * running one command. Measured on Outpost 2 (i-09424eff61920a4ac), CPU-seconds
10
- * per process:
11
- *
12
- * node -e "" 0.03
13
- * dist/commands/secrets.js 1.13 <- what `hq secrets` actually needs
14
- * dist/main.js (full graph) 1.88 <- what it used to pay
15
- *
16
- * So ~0.75 CPU-seconds of every `hq secrets` was spent importing commands it
17
- * never ran. At 39 invocations/minute that is ~0.5 of a core, continuously.
18
- *
19
- * Splitting the graph out lets the entrypoint import ONE command module for the
20
- * hot paths named in lazy-commands.ts, and fall back to this module — the
21
- * complete, unchanged registration — for everything else: `--help`, a bare
22
- * `hq`, an unknown command, and every command not in that manifest. Anything
23
- * not on the manifest therefore behaves exactly as before.
24
- *
25
- * Keep this list and lazy-commands.ts in sync through the parity test in
26
- * lazy-commands.test.ts, which registers both ways and compares the resulting
27
- * command shapes. Same discipline as commands/scaffold-fast.ts and core.ts.
2
+ * Complete command registration, retained as the eager reference used by the
3
+ * generated-catalog check and parity tests. Runtime dispatch uses the same
4
+ * plan one root at a time through lazy-commands.ts.
28
5
  */
29
- import { registerAddCommand } from "./commands/add.js";
30
- import { registerSyncCommand } from "./commands/sync.js";
31
- import { registerListCommand } from "./commands/list.js";
32
- import { registerUpdateCommand } from "./commands/update.js";
33
- import { registerCloudCommands } from "./commands/cloud.js";
34
- import { registerSyncModeCommand } from "./commands/sync-mode.js";
35
- import { registerSyncNarrowCommand } from "./commands/sync-narrow.js";
36
- import { registerSyncManifestCommand } from "./commands/sync-manifest.js";
37
- import { registerCloudProvisionCommands } from "./commands/cloud-provision.js";
38
- import { registerCloudDemoteCommands } from "./commands/cloud-demote.js";
39
- import { registerLoginCommand } from "./commands/login.js";
40
- import { registerLogoutCommand } from "./commands/logout.js";
41
- import { registerWhoamiCommand } from "./commands/whoami.js";
42
- import { registerOnboardCommand } from "./commands/onboard.js";
43
- import { registerPackageInstallCommand } from "./commands/pkg-install.js";
44
- import { registerPackageRemoveCommand } from "./commands/pkg-remove.js";
45
- import { registerPackageUpdateCommand } from "./commands/pkg-update.js";
46
- import { registerPackageListCommand } from "./commands/pkg-list.js";
47
- import { registerPacksCommand } from "./commands/packs.js";
48
- import { registerPublishCommand } from "./commands/publish.js";
49
- import { registerCreatorsCommand } from "./commands/creators.js";
50
- import { registerTeamSyncCommand } from "./commands/team-sync.js";
51
- import { registerAuthCommands } from "./commands/auth.js";
52
- import { registerApiKeysCommand } from "./commands/api-keys.js";
53
- import { registerSecretsCommand } from "./commands/secrets.js";
54
- import { registerRunCommand } from "./commands/run.js";
55
- import { registerGroupsCommand } from "./commands/groups.js";
56
- import { registerWorkersCommand } from "./commands/workers.js";
57
- import { registerGroupGrantsCommand } from "./commands/group-grants.js";
58
- import { registerFilesCommand } from "./commands/files.js";
59
- import { registerFilesBrowseCommands } from "./commands/files-browse.js";
60
- import { registerAccessCommand } from "./commands/access.js";
61
- import { registerSkillCommand } from "./commands/skill.js";
62
- import { registerMembersCommand } from "./commands/members.js";
63
- import { registerPeopleCommand } from "./commands/people.js";
64
- import { registerDmCommand } from "./commands/dm.js";
65
- import { registerChannelsCommand } from "./commands/channels.js";
66
- import { registerFeedbackCommand } from "./commands/feedback.js";
67
- import { registerMeetingsCommand } from "./commands/meetings.js";
68
- import { registerSourcesCommand } from "./commands/sources.js";
69
- import { registerSignalsCommand } from "./commands/signals.js";
70
- import { registerIntegrationsCommand } from "./commands/integrations.js";
71
- import { registerReindexCommand } from "./commands/reindex.js";
72
- import { registerRescueCommand } from "./commands/rescue.js";
73
- import { registerMcpCommand } from "./commands/mcp-status.js";
74
- import { registerCrmCommand } from "./commands/crm.js";
75
- import { registerCompanyCommand } from "./commands/company.js";
76
- import { registerAgentsCommand } from "./commands/agents.js";
77
- import { registerOutpostsCommand } from "./commands/outposts.js";
78
- import { registerBillingCommand } from "./commands/billing.js";
79
- import { registerDbCommand } from "./commands/db.js";
80
- import { registerCoreCommands } from "./commands/core.js";
81
- import { registerSearchCommand } from "./commands/search.js";
82
- import { registerIndexCommand } from "./commands/index-cmd.js";
83
- import { registerDoctorCommand } from "./commands/doctor.js";
84
- import { registerMeshCommand } from "./commands/mesh.js";
85
- import { registerBotCommand } from "./commands/bot.js";
86
- /** Register the complete hq command graph onto `program`. */
87
- export function registerAllCommands(program) {
88
- // Module management subcommand group
89
- const modulesCmd = program
90
- .command("modules")
91
- .description("Module management commands");
92
- registerAddCommand(modulesCmd);
93
- registerSyncCommand(modulesCmd);
94
- registerListCommand(modulesCmd);
95
- registerUpdateCommand(modulesCmd);
96
- // Package management subcommand group
97
- const packagesCmd = program
98
- .command("packages")
99
- .description("Package management commands");
100
- registerPackageInstallCommand(packagesCmd);
101
- registerPackageRemoveCommand(packagesCmd);
102
- registerPackageUpdateCommand(packagesCmd);
103
- registerPackageListCommand(packagesCmd);
104
- // Content-pack lifecycle (core/packages/hq-pack-*). Distinct from the registry
105
- // `packages` system above. Available as both `hq packages packs …` (grouped)
106
- // and `hq packs …` (top-level convenience).
107
- registerPacksCommand(packagesCmd);
108
- registerPacksCommand(program);
109
- // Top-level shortcuts for package commands
110
- // "hq install <slug>" = "hq packages install <slug>"
111
- // "hq remove <slug>" = "hq packages remove <slug>"
112
- registerPackageInstallCommand(program);
113
- registerPackageRemoveCommand(program);
114
- // Marketplace publish (top-level — packer + authenticated upload, US-004)
115
- // "hq publish <skill-or-worker-path>" packages and submits a pack to the
116
- // marketplace via POST /v1/listings.
117
- registerPublishCommand(program);
118
- // `hq creators apply` — request verified-creator access (required to publish).
119
- registerCreatorsCommand(program);
120
- // Cloud sync subcommand group
121
- const syncCmd = program
122
- .command("sync")
123
- .description("Cloud sync commands — sync HQ to S3 for mobile access");
124
- registerCloudCommands(syncCmd);
125
- registerSyncModeCommand(syncCmd);
126
- registerSyncNarrowCommand(syncCmd);
127
- registerSyncManifestCommand(syncCmd);
128
- // Cloud provisioning subcommand group (entity + bucket + initial sync)
129
- // Distinct from `hq sync` which assumes provisioning has already happened.
130
- const cloudCmd = program
131
- .command("cloud")
132
- .description("Cloud commands — provision entities and manage cloud-backed companies");
133
- registerCloudProvisionCommands(cloudCmd);
134
- registerCloudDemoteCommands(cloudCmd);
135
- // Team commands (top-level)
136
- registerTeamSyncCommand(program);
137
- // Auth commands (top-level — Cognito OAuth)
138
- registerLoginCommand(program);
139
- registerLogoutCommand(program);
140
- registerWhoamiCommand(program);
141
- registerAuthCommands(program);
142
- // Secrets management (subcommand group — hq secrets set|get|list|delete|exec|generate-link|cache)
143
- registerSecretsCommand(program);
144
- // Vault databases (subcommand group — hq db status|sql|migrate|provision)
145
- registerDbCommand(program);
146
- // API key management (subcommand group — hq api-keys create|list|revoke)
147
- registerApiKeysCommand(program);
148
- // Schema-driven dev runner — hq run [options] -- <cmd>
149
- registerRunCommand(program);
150
- // Groups management (subcommand group — hq groups create|delete|add|remove|list|members)
151
- registerGroupsCommand(program);
152
- // Worker discovery + sharing (subcommand group — hq workers list|share)
153
- registerWorkersCommand(program);
154
- // Cross-company group grants (subcommand group —
155
- // hq group-grants grant|revoke|outbound|inbound)
156
- registerGroupGrantsCommand(program);
157
- // Files ACL management (subcommand group — hq files share|unshare|acl)
158
- // `registerFilesCommand` returns the `files` group so we can attach the
159
- // browse-vs-sync subcommands (`hq files browse`/`cat`) onto the same group.
160
- const filesCmd = registerFilesCommand(program);
161
- registerFilesBrowseCommands(filesCmd);
162
- // Top-level `hq access` — vault existence + ACL probe (self-healing ladder).
163
- registerAccessCommand(program);
164
- // Comment-only skill improvement loop. Structured suggestion/review commands are
165
- // intentionally absent; live content changes remain governed by FILE_ACL sync.
166
- registerSkillCommand(program);
167
- // Membership management (subcommand group — hq members invite|list|revoke)
168
- registerMembersCommand(program);
169
- // People directory (subcommand group — hq people list|search|resolve), reading
170
- // the local companies/<co>/people store scoped to one company.
171
- registerPeopleCommand(program);
172
- registerDmCommand(program);
173
- registerChannelsCommand(program);
174
- // Onboarding (top-level — Cognito + vault-service provisioning)
175
- registerOnboardCommand(program);
176
- // Feedback (subcommand group — hq feedback bug|feature)
177
- registerFeedbackCommand(program);
178
- // Meetings (subcommand group — hq meetings list|get|search|transcript|notes)
179
- registerMeetingsCommand(program);
180
- // Sources read surface (subcommand group — hq sources list|get|channels|entities)
181
- registerSourcesCommand(program);
182
- // Signals read surface (subcommand group — hq signals list|get|types|entities)
183
- registerSignalsCommand(program);
184
- // Company-connected apps via the governed integration gateway
185
- // (subcommand group — hq integrations list|tools|call|approve|reject)
186
- registerIntegrationsCommand(program);
187
- // Skill/personal-overlay mirroring + workers-registry regen. Invoked by the
188
- // hq-core reindex hook shim (Stop / PostToolUse) and by sync()/rescue() after
189
- // they change on-disk sources. Keeps a `master-sync` alias for one release.
190
- // Implementation lives in @indigoai-us/hq-cloud.
191
- registerReindexCommand(program);
192
- // Drift-preserving HQ-core re-sync (top-level — `hq rescue`). CLI sibling of
193
- // the HQ Sync app's "Update / Restore" pill; drives the same replace-rescue.sh
194
- // shipped from @indigoai-us/hq-cloud.
195
- registerRescueCommand(program);
196
- // MCP pack observability (subcommand group — `hq mcp status`). Read-only
197
- // provenance-based status across BOTH Claude + Codex runtimes (reads `_hqPack`
198
- // off the configs, NOT linkStatus), with secret-redacted output + `--json`.
199
- registerMcpCommand(program);
200
- // Native CRM entity upsert (subcommand group — `hq crm entity upsert`). Wraps
201
- // POST /crm/entities (the ontology write gate) so an authenticated company
202
- // member can create/update canonical CRM entities in the company vault.
203
- registerCrmCommand(program);
204
- // Company settings (subcommand group — `hq company settings set`). Owner-only
205
- // toggles for crmEnabled / ontologyEnabled via PUT /company-settings.
206
- registerCompanyCommand(program);
207
- // Cloud agent management (subcommand group — `hq agents …`). Rename, reconfigure,
208
- // start/stop, and tear down a company's fleet agents via the hq-pro /v1/agents
209
- // control plane — the same routes the web console's agents panel calls.
210
- registerAgentsCommand(program);
211
- // Personal Outpost management (subcommand group — `hq outposts …`). List, inspect,
212
- // enable Codex on, refresh login for, and destroy your EC2 boxes via the hq-pro
213
- // /outpost/* control plane.
214
- registerOutpostsCommand(program);
215
- // Billing (subcommand group — `hq billing …`). Check subscription/card state and
216
- // mint a shareable Stripe card-capture link — the client side of the paid-
217
- // provisioning gate for agents & Outposts.
218
- registerBillingCommand(program);
219
- // HQ scaffold scripts hosted by the CLI (hidden group — `hq core …`). Not a
220
- // public surface: every entry is invoked by an HQ skill, hook, or forwarder, and
221
- // the source-root entries are maintainer tools that must never touch a live
222
- // install. Registered from a manifest in the module, not wired per script here.
223
- registerCoreCommands(program);
224
- // Local qmd search and index management. Kept distinct from `hq reindex`,
225
- // which converges scaffold-owned files and hooks rather than search data.
226
- registerSearchCommand(program);
227
- registerIndexCommand(program);
228
- // Hook guardrail diagnostics (top-level — `hq doctor`). Read-only, offline
229
- // verification that HQ's hooks are wired and firing, backed by an extensible
230
- // check registry so later check families (vault, sync, MCP, …) plug in without
231
- // engine changes.
232
- registerDoctorCommand(program);
233
- // Work mesh (subcommand group — `hq mesh …`). Native REST + cache. Distinct
234
- // from `hq doctor` (hook guardrails). Does not start MQTT listen.
235
- registerMeshCommand(program);
236
- registerBotCommand(program);
237
- }
6
+ export { registerAllCommands, registerCommandRoot } from "./command-registration-plan.js";
238
7
  //# sourceMappingURL=register-all.js.map
package/dist/sentry.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as Sentry from "@sentry/node";
2
- import type { ErrorEvent, EventHint } from "@sentry/node";
2
+ import type { ErrorEvent, EventHint, NodeOptions } from "@sentry/node";
3
3
  /**
4
4
  * Drop broken-pipe (EPIPE) crashes before scrubbing/send. A closed downstream
5
5
  * reader (`hq … | head`, `source <(hq …)`, a parent that exited) is normal
@@ -11,6 +11,12 @@ import type { ErrorEvent, EventHint } from "@sentry/node";
11
11
  * Consistent with the swallow-EPIPE posture established in #138.
12
12
  */
13
13
  export declare function epipeAwareBeforeSend(event: ErrorEvent, hint: EventHint): ErrorEvent | null;
14
- export declare function initSentry(): void;
14
+ /**
15
+ * Tests substitute only the transport so the real SDK lifecycle can be
16
+ * exercised without an ingest request. Production callers pass nothing.
17
+ */
18
+ export declare function initSentry(overrides?: Partial<Pick<NodeOptions, "transport">>): void;
19
+ /** Finish HQ's one per-invocation release-health session. */
20
+ export declare function finishSentrySession(): void;
15
21
  export { Sentry };
16
22
  //# sourceMappingURL=sentry.d.ts.map
package/dist/sentry.js CHANGED
@@ -78,12 +78,20 @@ export function epipeAwareBeforeSend(event, hint) {
78
78
  event.fingerprint = fingerprint;
79
79
  return beforeSend(event, hint);
80
80
  }
81
- export function initSentry() {
81
+ /**
82
+ * Tests substitute only the transport so the real SDK lifecycle can be
83
+ * exercised without an ingest request. Production callers pass nothing.
84
+ */
85
+ export function initSentry(overrides = {}) {
82
86
  const dsn = BUNDLED_DSN || process.env.SENTRY_DSN;
83
87
  if (!dsn)
84
88
  return;
85
89
  Sentry.init({
86
90
  dsn,
91
+ // import-in-the-middle's async ESM loader makes every later CLI import
92
+ // substantially slower. Keep HQ's explicit breadcrumbs, but give up
93
+ // automatic ESM third-party instrumentation (its spans/breadcrumbs).
94
+ registerEsmLoaderHooks: false,
87
95
  // CLI_VERSION reads package.json at runtime; npm_package_version is only
88
96
  // set under `npm run`, so an installed `hq` binary would always report
89
97
  // 0.0.0 and never match the uploaded source maps.
@@ -94,6 +102,10 @@ export function initSentry() {
94
102
  },
95
103
  beforeSend: epipeAwareBeforeSend,
96
104
  beforeBreadcrumb,
105
+ // HQ owns this short-lived CLI session explicitly below and closes it from
106
+ // main.ts. Leaving the SDK default enabled starts a competing session.
107
+ integrations: (defaults) => defaults.filter((integration) => integration.name !== "ProcessSession"),
108
+ ...overrides,
97
109
  });
98
110
  // Attribute events to the logged-in HQ identity (best-effort; null when not
99
111
  // logged in). A CLI process is one user, so global setUser is correct here.
@@ -105,5 +117,9 @@ export function initSentry() {
105
117
  // "errored", so crash-free numbers per release stay accurate.
106
118
  Sentry.startSession();
107
119
  }
120
+ /** Finish HQ's one per-invocation release-health session. */
121
+ export function finishSentrySession() {
122
+ Sentry.endSession();
123
+ }
108
124
  export { Sentry };
109
125
  //# sourceMappingURL=sentry.js.map
@@ -1,6 +1,7 @@
1
+ export declare const TELEMETRY_TIMEOUT_MS = 1200;
1
2
  /**
2
3
  * Emit the authenticated CLI session signal using an already-cached token.
3
4
  * This deliberately never refreshes a session or opens a browser.
4
5
  */
5
- export declare function emitCliSessionStarted(): Promise<void>;
6
+ export declare function emitCliSessionStarted(timeoutMs?: number): Promise<void>;
6
7
  //# sourceMappingURL=cli-telemetry.d.ts.map
@@ -1,17 +1,17 @@
1
1
  import { CLI_VERSION } from "../cli-version.js";
2
2
  import { isExpiring, isMachineIdentity, loadCachedTokens, } from "./cognito-session.js";
3
3
  import { vaultApiFetch } from "./vault-api.js";
4
- const TELEMETRY_TIMEOUT_MS = 1_200;
4
+ export const TELEMETRY_TIMEOUT_MS = 1_200;
5
5
  let cliSessionStartedPromise;
6
6
  /**
7
7
  * Emit the authenticated CLI session signal using an already-cached token.
8
8
  * This deliberately never refreshes a session or opens a browser.
9
9
  */
10
- export function emitCliSessionStarted() {
11
- cliSessionStartedPromise ??= emitCachedCliSessionStarted();
10
+ export function emitCliSessionStarted(timeoutMs = TELEMETRY_TIMEOUT_MS) {
11
+ cliSessionStartedPromise ??= emitCachedCliSessionStarted(timeoutMs);
12
12
  return cliSessionStartedPromise;
13
13
  }
14
- async function emitCachedCliSessionStarted() {
14
+ async function emitCachedCliSessionStarted(timeoutMs) {
15
15
  try {
16
16
  const cached = loadCachedTokens();
17
17
  if (!cached || isExpiring(cached, 120))
@@ -20,7 +20,7 @@ async function emitCachedCliSessionStarted() {
20
20
  if (!token)
21
21
  return;
22
22
  const controller = new AbortController();
23
- const timeout = setTimeout(() => controller.abort(), TELEMETRY_TIMEOUT_MS);
23
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
24
24
  try {
25
25
  const response = await vaultApiFetch({
26
26
  token,
@@ -99,5 +99,5 @@ export declare const CONTRIBUTION_KEYS: ContributionKey[];
99
99
  */
100
100
  export declare function payloadFor(key: ContributionKey, item: string): string;
101
101
  /** Keys whose contributions are wired by a host symlink (skip `merge` rows). */
102
- export declare const SYMLINK_KEYS: ("workers" | "knowledge" | "skills" | "commands" | "hooks" | "policies" | "scripts" | "mcp")[];
102
+ export declare const SYMLINK_KEYS: ("workers" | "mcp" | "knowledge" | "skills" | "commands" | "hooks" | "policies" | "scripts")[];
103
103
  //# sourceMappingURL=contribution-table.d.ts.map
@@ -17,7 +17,10 @@ export declare function staleAgainstCachedLatest(now?: number): string | null;
17
17
  * means the loop guard is skipped this once, never a broken CLI.
18
18
  */
19
19
  export declare function markLatestIneffective(version: string, now?: number): void;
20
- export declare function refreshVersionCache(): Promise<void>;
20
+ export interface RefreshVersionCacheOptions {
21
+ timeoutMs?: number;
22
+ }
23
+ export declare function refreshVersionCache(options?: RefreshVersionCacheOptions): Promise<void>;
21
24
  export declare const __test__: {
22
25
  CACHE_TTL_MS: number;
23
26
  isKnownNoninteractiveStatusProbe: typeof isKnownNoninteractiveStatusProbe;
@@ -166,7 +166,7 @@ export function markLatestIneffective(version, now = Date.now()) {
166
166
  ineffectiveAt: now,
167
167
  });
168
168
  }
169
- export async function refreshVersionCache() {
169
+ export async function refreshVersionCache(options = {}) {
170
170
  if (isOptedOut())
171
171
  return;
172
172
  if (isKnownNoninteractiveStatusProbe())
@@ -183,7 +183,7 @@ export async function refreshVersionCache() {
183
183
  return;
184
184
  const res = await fetch(REGISTRY_URL, {
185
185
  headers: { Accept: "application/json" },
186
- signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
186
+ signal: AbortSignal.timeout(options.timeoutMs ?? FETCH_TIMEOUT_MS),
187
187
  });
188
188
  if (!res.ok)
189
189
  return;
@@ -404,7 +404,11 @@ declare function enforceUpdateRequired(decision: VersionCheckResponse, deps?: En
404
404
  * must exit rather than running the command a second time.
405
405
  */
406
406
  export type VersionGateOutcome = "continue" | "reexec";
407
- export declare function enforceVersionGate(onUpdateRecommended?: (decision: VersionCheckResponse, install: RunningInstall) => Promise<boolean>): Promise<VersionGateOutcome>;
407
+ /** Optional caller-owned bound for the network-only version decision. */
408
+ export interface VersionGateOptions {
409
+ timeoutMs?: number;
410
+ }
411
+ export declare function enforceVersionGate(onUpdateRecommended?: (decision: VersionCheckResponse, install: RunningInstall) => Promise<boolean>, options?: VersionGateOptions): Promise<VersionGateOutcome>;
408
412
  /**
409
413
  * Cheap argv pre-check: skip the gate for `--version` / `-V` so users
410
414
  * inspecting a broken install can still see what they have without being