@indigoai-us/hq-cli 5.345.203 → 5.345.205

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 (95) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/command-catalog.generated.d.ts +51 -1
  3. package/dist/command-catalog.generated.js +63 -1
  4. package/dist/commands/bot.d.ts +67 -0
  5. package/dist/commands/bot.js +308 -41
  6. package/dist/commands/cloud-off-gate.d.ts +9 -2
  7. package/dist/commands/cloud-off-gate.js +49 -13
  8. package/dist/commands/cloud.d.ts +14 -2
  9. package/dist/commands/cloud.js +25 -16
  10. package/dist/commands/feedback.d.ts +26 -0
  11. package/dist/commands/feedback.js +91 -5
  12. package/dist/commands/install-global.d.ts +3 -1
  13. package/dist/commands/install-global.js +15 -4
  14. package/dist/commands/lanes.d.ts +2 -0
  15. package/dist/commands/lanes.js +9 -3
  16. package/dist/commands/mcp-serve.d.ts +5 -2
  17. package/dist/commands/mcp-serve.js +45 -3
  18. package/dist/commands/mcp-status.d.ts +3 -1
  19. package/dist/commands/mcp-status.js +24 -14
  20. package/dist/commands/secrets.js +11 -1
  21. package/dist/commands/sources.js +10 -15
  22. package/dist/commands/sync-core.js +2 -0
  23. package/dist/index.js +7 -2
  24. package/dist/lib/bot/claude-login.d.ts +7 -1
  25. package/dist/lib/bot/claude-login.js +56 -16
  26. package/dist/lib/bot/executive-settings.d.ts +13 -0
  27. package/dist/lib/bot/executive-settings.js +20 -17
  28. package/dist/lib/bot/executive-sync.d.ts +12 -0
  29. package/dist/lib/bot/executive-sync.js +36 -0
  30. package/dist/lib/bot/executive.d.ts +51 -0
  31. package/dist/lib/bot/executive.js +144 -0
  32. package/dist/lib/bot/fleet-cron.d.ts +7 -0
  33. package/dist/lib/bot/fleet-cron.js +2 -1
  34. package/dist/lib/bot/jobs/executive-handover.d.ts +6 -0
  35. package/dist/lib/bot/jobs/executive-handover.js +33 -0
  36. package/dist/lib/bot/jobs/hot-signal-sync.d.ts +22 -0
  37. package/dist/lib/bot/jobs/hot-signal-sync.js +47 -0
  38. package/dist/lib/bot/listed-running.d.ts +16 -0
  39. package/dist/lib/bot/listed-running.js +16 -0
  40. package/dist/lib/bot/pending-switch.d.ts +51 -0
  41. package/dist/lib/bot/pending-switch.js +103 -0
  42. package/dist/lib/bot/run.js +27 -3
  43. package/dist/lib/bot/runtime-failure.js +19 -3
  44. package/dist/lib/bot/status.d.ts +20 -0
  45. package/dist/lib/capacity/collectors/claude-oauth.d.ts +53 -5
  46. package/dist/lib/capacity/collectors/claude-oauth.js +251 -71
  47. package/dist/lib/company-skill-wrapper.js +29 -0
  48. package/dist/lib/daemon/catalog.js +2 -2
  49. package/dist/lib/daemon/hq-child-bootstrap.mjs +197 -2
  50. package/dist/lib/daemon/resolver.d.ts +14 -0
  51. package/dist/lib/daemon/resolver.js +96 -0
  52. package/dist/lib/daemon/run.d.ts +11 -0
  53. package/dist/lib/daemon/run.js +60 -8
  54. package/dist/lib/daemon/server.d.ts +2 -9
  55. package/dist/lib/daemon/server.js +3 -89
  56. package/dist/lib/doctor/checks/claude-wiring.js +41 -0
  57. package/dist/lib/doctor/checks/sync-health.d.ts +8 -0
  58. package/dist/lib/doctor/checks/sync-health.js +34 -2
  59. package/dist/lib/doctor/duplicate-hook-registrations.d.ts +34 -0
  60. package/dist/lib/doctor/duplicate-hook-registrations.js +130 -0
  61. package/dist/lib/doctor/fix/apply.js +79 -3
  62. package/dist/lib/doctor/fix/remediation.d.ts +1 -1
  63. package/dist/lib/doctor/fix/remediation.js +15 -0
  64. package/dist/lib/doctor/types.d.ts +1 -1
  65. package/dist/lib/doctor/types.js +1 -0
  66. package/dist/lib/lanes/config.js +13 -0
  67. package/dist/lib/lanes/throttle.d.ts +12 -1
  68. package/dist/lib/lanes/throttle.js +27 -8
  69. package/dist/lib/lanes/types.d.ts +5 -0
  70. package/dist/lib/mcp/local-native-tools.d.ts +40 -0
  71. package/dist/lib/mcp/local-native-tools.js +111 -0
  72. package/dist/lib/mcp/tools.d.ts +2 -0
  73. package/dist/lib/mcp/tools.js +2 -0
  74. package/dist/lib/signals/steps/extract.d.ts +111 -5
  75. package/dist/lib/signals/steps/extract.js +524 -55
  76. package/dist/lib/sync-core/engine-home.d.ts +2 -1
  77. package/dist/lib/sync-core/engine-home.js +25 -8
  78. package/dist/lib/sync-core/reconcile.d.ts +3 -1
  79. package/dist/lib/sync-core/reconcile.js +21 -8
  80. package/dist/lib/sync-core/release.d.ts +14 -5
  81. package/dist/lib/sync-core/release.js +58 -14
  82. package/dist/sentry-init.js +6 -0
  83. package/dist/utils/cli-network-lifecycle.d.ts +11 -1
  84. package/dist/utils/cli-network-lifecycle.js +36 -2
  85. package/dist/utils/daemon-helper-lifetime.d.ts +39 -0
  86. package/dist/utils/daemon-helper-lifetime.js +209 -0
  87. package/dist/utils/daemon-helper-markers.d.ts +24 -0
  88. package/dist/utils/daemon-helper-markers.js +53 -0
  89. package/dist/utils/mcp-launcher.d.ts +28 -0
  90. package/dist/utils/mcp-launcher.js +117 -0
  91. package/dist/utils/package-use-lease.d.ts +10 -0
  92. package/dist/utils/package-use-lease.js +31 -0
  93. package/dist/utils/resident-package-preload.js +4 -1
  94. package/docs/anywhere-runtime.md +7 -0
  95. package/package.json +7 -7
@@ -25,8 +25,10 @@
25
25
  * background sync is paused is expected to run.
26
26
  */
27
27
  import * as fs from "node:fs";
28
+ import * as os from "node:os";
28
29
  import * as path from "node:path";
29
30
  import { readCompaniesManifestMap } from "../lib/work-context/repo-remote.js";
31
+ import { readSyncCoreRolloutState } from "../lib/sync-core/rollout-state.js";
30
32
  import { readVaultSyncSwitches, unreadableSwitchesWarning, vaultSkipEnv, } from "../lib/vault-sync-switches.js";
31
33
  export { readVaultSyncSwitches, vaultSkipEnv };
32
34
  /**
@@ -43,6 +45,34 @@ export function isCloudOff(home) {
43
45
  export function isCompanyVaultOff(switches, company) {
44
46
  return switches.offCompanies.has(company.trim().toLowerCase());
45
47
  }
48
+ export const NO_ENGINE_VAULTS = {
49
+ personal: false,
50
+ companies: new Set(),
51
+ uidSlugs: new Map(),
52
+ };
53
+ export function readEngineOwnedVaults(home = os.homedir()) {
54
+ const state = readSyncCoreRolloutState(home);
55
+ if (!state)
56
+ return NO_ENGINE_VAULTS;
57
+ const held = new Set((state.held ?? []).map((h) => h.uid.toLowerCase()));
58
+ let personal = false;
59
+ const companies = new Set();
60
+ const uidSlugs = new Map();
61
+ for (const vault of state.vaults) {
62
+ if (vault.phase !== "full" || held.has(vault.uid.toLowerCase()))
63
+ continue;
64
+ if (vault.kind === "personal") {
65
+ personal = true;
66
+ continue;
67
+ }
68
+ const slug = vault.slug?.trim().toLowerCase();
69
+ if (!slug)
70
+ continue;
71
+ companies.add(slug);
72
+ uidSlugs.set(vault.uid.toLowerCase(), slug);
73
+ }
74
+ return { personal, companies, uidSlugs };
75
+ }
46
76
  const HOW_TO_TURN_ON = "To turn it back on, open HQ and go to Settings > Sync.";
47
77
  const NOTHING_MOVED = "Nothing was uploaded or downloaded. Your local files are unchanged.";
48
78
  /**
@@ -112,21 +142,27 @@ export function resolveVaultRef(ref, hqRoot) {
112
142
  }
113
143
  return { kind: "unknown", ref: trimmed };
114
144
  }
115
- function refusalForVault(command, vault, switches) {
145
+ function refusalForVault(command, vault, switches, engine) {
146
+ const enginePush = command === "push";
116
147
  switch (vault.kind) {
117
148
  case "personal":
118
- return switches.personalOff
149
+ return switches.personalOff && !(enginePush && engine.personal)
119
150
  ? { message: vaultOffMessage(command, "your personal vault"), vault: "personal" }
120
151
  : null;
121
152
  case "company":
122
- return isCompanyVaultOff(switches, vault.slug)
153
+ return isCompanyVaultOff(switches, vault.slug) &&
154
+ !(enginePush && engine.companies.has(vault.slug.trim().toLowerCase()))
123
155
  ? { message: vaultOffMessage(command, vault.slug), vault: vault.slug }
124
156
  : null;
125
- case "unknown":
157
+ case "unknown": {
158
+ const engineSlug = engine.uidSlugs.get(vault.ref.toLowerCase());
159
+ if (engineSlug)
160
+ return refusalForVault(command, { kind: "company", slug: engineSlug }, switches, engine);
126
161
  // Fail closed: with any company vault off, an unmapped uid may be it.
127
162
  return switches.offCompanies.size > 0
128
163
  ? { message: unresolvedVaultMessage(command, vault.ref), vault: vault.ref }
129
164
  : null;
165
+ }
130
166
  }
131
167
  }
132
168
  /**
@@ -135,35 +171,35 @@ function refusalForVault(command, vault, switches) {
135
171
  * With `--creds-from-stdin` and no `--company`, the target is unknown until
136
172
  * stdin is parsed; {@link refusalForEntity} checks it then.
137
173
  */
138
- export function refusalFor(command, selection, switches) {
174
+ export function refusalFor(command, selection, switches, engine = NO_ENGINE_VAULTS) {
139
175
  if (switches.allOff)
140
176
  return { message: cloudOffMessage(command), vault: "all" };
141
177
  if (selection.all)
142
178
  return null;
143
179
  if (selection.personal === true) {
144
- return refusalForVault(command, { kind: "personal" }, switches);
180
+ return refusalForVault(command, { kind: "personal" }, switches, engine);
145
181
  }
146
182
  const ref = selection.company ?? (selection.credsFromStdin ? undefined : readActiveCompanyRef(selection.hqRoot));
147
183
  if (!ref)
148
184
  return null;
149
- return refusalForVault(command, resolveVaultRef(ref, selection.hqRoot), switches);
185
+ return refusalForVault(command, resolveVaultRef(ref, selection.hqRoot), switches, engine);
150
186
  }
151
187
  /**
152
188
  * The refusal for a pre-vended EntityContext read from stdin. A `prs_*` uid
153
189
  * is the personal vault; otherwise the slug (or the uid, through the
154
190
  * manifest) names the company.
155
191
  */
156
- export function refusalForEntity(command, entity, hqRoot, switches) {
192
+ export function refusalForEntity(command, entity, hqRoot, switches, engine = NO_ENGINE_VAULTS) {
157
193
  if (switches.allOff)
158
194
  return { message: cloudOffMessage(command), vault: "all" };
159
195
  const uid = typeof entity.uid === "string" ? entity.uid : "";
160
196
  const slug = typeof entity.slug === "string" ? entity.slug : "";
161
197
  if (PERSON_UID.test(uid))
162
- return refusalForVault(command, { kind: "personal" }, switches);
198
+ return refusalForVault(command, { kind: "personal" }, switches, engine);
163
199
  if (slug.trim())
164
- return refusalForVault(command, { kind: "company", slug }, switches);
200
+ return refusalForVault(command, { kind: "company", slug }, switches, engine);
165
201
  if (uid.trim())
166
- return refusalForVault(command, resolveVaultRef(uid, hqRoot), switches);
202
+ return refusalForVault(command, resolveVaultRef(uid, hqRoot), switches, engine);
167
203
  return null;
168
204
  }
169
205
  /** The vaults an `--all` run leaves out. */
@@ -215,7 +251,7 @@ function warnIfUnreadable(switches, deps) {
215
251
  export function refuseSyncForOffVaults(command, selection, deps = {}) {
216
252
  const switches = readVaultSyncSwitches(deps.home);
217
253
  warnIfUnreadable(switches, deps);
218
- const refusal = refusalFor(command, selection, switches);
254
+ const refusal = refusalFor(command, selection, switches, readEngineOwnedVaults(deps.home));
219
255
  if (refusal) {
220
256
  writeVaultRefusal(refusal, deps);
221
257
  (deps.exit ?? ((code) => process.exit(code)))(CLOUD_OFF_EXIT_CODE);
@@ -227,7 +263,7 @@ export function refuseSyncForOffVaults(command, selection, deps = {}) {
227
263
  * EntityContext targets an off vault. The caller writes it and exits 3.
228
264
  */
229
265
  export function assertEntityVaultSyncAllowed(command, entity, hqRoot, home) {
230
- const refusal = refusalForEntity(command, entity, hqRoot, readVaultSyncSwitches(home));
266
+ const refusal = refusalForEntity(command, entity, hqRoot, readVaultSyncSwitches(home), readEngineOwnedVaults(home));
231
267
  if (refusal)
232
268
  throw new VaultSyncOffError(refusal);
233
269
  }
@@ -210,15 +210,27 @@ export declare function scopeExcludedWarning(count: number): string | null;
210
210
  * largest count it sees instead of a sum: a repeated emit for the same hold
211
211
  * cannot inflate the total. A missing, non-numeric or negative count reads as 0.
212
212
  */
213
+ export interface IdentityHeldNotice {
214
+ count: number;
215
+ /** Plain-language hold from hq-cloud, when that build sends one. */
216
+ message?: string;
217
+ }
213
218
  export declare function createIdentityHeldTracker(): {
214
219
  observe: (event: {
215
220
  type: string;
216
221
  count?: unknown;
222
+ message?: unknown;
223
+ reason?: unknown;
217
224
  }) => void;
218
225
  count: () => number;
226
+ notice: () => IdentityHeldNotice;
219
227
  };
220
- /** Recovery lines for files held by the account-switch push fence. */
221
- export declare function identityHeldLines(count: number): string[];
228
+ /**
229
+ * Recovery lines for files held by the account-switch push fence.
230
+ * A newer hq-cloud sends `message` (file names and `hq sync release-held`).
231
+ * Older builds send a count only, and this keeps the previous sentence.
232
+ */
233
+ export declare function identityHeldLines(count: number, notice?: Pick<IdentityHeldNotice, "message">): string[];
222
234
  /** Actionable recovery for files refused because the vault baseline is stale. */
223
235
  export declare function staleUploadRefusalLines(count: number, paths?: readonly string[]): string[];
224
236
  /**
@@ -500,19 +500,9 @@ export function scopeExcludedWarning(count) {
500
500
  `They were skipped, not synced. Re-run with --json to list them, or ` +
501
501
  `ask an admin to grant you write on those paths.`);
502
502
  }
503
- /**
504
- * Counts the files share() held back because this sync scope is fenced after an account
505
- * switch on this computer (feedback_a69e12ba). share() reports the hold only as
506
- * an `identity-switch-push-held` event and leaves the files out of every
507
- * result counter, so without this the push printed "Pushed 0 file(s) (0 B,
508
- * 0 skipped)" as a success while the vault kept the old copy.
509
- *
510
- * Each event carries the size of one fenced hold, so the tracker keeps the
511
- * largest count it sees instead of a sum: a repeated emit for the same hold
512
- * cannot inflate the total. A missing, non-numeric or negative count reads as 0.
513
- */
514
503
  export function createIdentityHeldTracker() {
515
504
  let held = 0;
505
+ let message;
516
506
  return {
517
507
  observe(event) {
518
508
  if (event.type !== "identity-switch-push-held")
@@ -521,12 +511,24 @@ export function createIdentityHeldTracker() {
521
511
  ? Math.max(0, Math.trunc(event.count))
522
512
  : 0;
523
513
  held = Math.max(held, n);
514
+ // A company rebind uses the same event type and keeps its own warning.
515
+ if (event.reason === "company-rebind")
516
+ return;
517
+ if (typeof event.message === "string" && event.message.trim())
518
+ message = event.message.trim();
524
519
  },
525
520
  count: () => held,
521
+ notice: () => ({ count: held, ...(message ? { message } : {}) }),
526
522
  };
527
523
  }
528
- /** Recovery lines for files held by the account-switch push fence. */
529
- export function identityHeldLines(count) {
524
+ /**
525
+ * Recovery lines for files held by the account-switch push fence.
526
+ * A newer hq-cloud sends `message` (file names and `hq sync release-held`).
527
+ * Older builds send a count only, and this keeps the previous sentence.
528
+ */
529
+ export function identityHeldLines(count, notice) {
530
+ if (notice?.message)
531
+ return [`⚠ ${notice.message}`];
530
532
  if (count <= 0)
531
533
  return [];
532
534
  return [
@@ -1566,7 +1568,7 @@ export function registerCloudCommands(program) {
1566
1568
  for (const line of uploadFailedLines(uploadFailed.count, uploadFailed.paths)) {
1567
1569
  log(chalk.yellow(line));
1568
1570
  }
1569
- for (const line of identityHeldLines(identityHeldCount)) {
1571
+ for (const line of identityHeldLines(identityHeldCount, identityHeld.notice())) {
1570
1572
  log(chalk.yellow(line));
1571
1573
  }
1572
1574
  await syncHealth.succeeded();
@@ -1599,7 +1601,12 @@ export function registerCloudCommands(program) {
1599
1601
  for (const line of uploadFailedLines(uploadFailed.count, uploadFailed.paths)) {
1600
1602
  log(chalk.yellow(line));
1601
1603
  }
1602
- for (const line of identityHeldLines(identityHeldCount)) {
1604
+ for (const line of identityHeldLines(identityHeldCount, identityHeld.notice())) {
1605
+ log(chalk.yellow(line));
1606
+ }
1607
+ }
1608
+ else if (identityHeld.notice().message) {
1609
+ for (const line of identityHeldLines(identityHeldCount, identityHeld.notice())) {
1603
1610
  log(chalk.yellow(line));
1604
1611
  }
1605
1612
  }
@@ -2469,8 +2476,10 @@ async function runNowSingle(hqRoot, company, personal, message, onConflict, mode
2469
2476
  const pushRefused = planLimitTracker.summary();
2470
2477
  const pushUploadFailed = readUploadFailures(pushResult);
2471
2478
  const pushHeldCount = pushIdentityHeld.count();
2479
+ const pushHeldNotice = pushIdentityHeld.notice();
2472
2480
  const pushStatus = pushResult.aborted ||
2473
2481
  pushHeldCount > 0 ||
2482
+ Boolean(pushHeldNotice.message) ||
2474
2483
  pushResult.filesExcludedByScope > 0 ||
2475
2484
  (pushResult.filesRefusedStale ?? 0) > 0 ||
2476
2485
  pushUploadFailed.count > 0 ||
@@ -2498,7 +2507,7 @@ async function runNowSingle(hqRoot, company, personal, message, onConflict, mode
2498
2507
  for (const line of uploadFailedLines(pushUploadFailed.count, pushUploadFailed.paths)) {
2499
2508
  console.log(chalk.yellow(line));
2500
2509
  }
2501
- for (const line of identityHeldLines(pushHeldCount)) {
2510
+ for (const line of identityHeldLines(pushHeldCount, pushHeldNotice)) {
2502
2511
  console.log(chalk.yellow(line));
2503
2512
  }
2504
2513
  if (pushResult.aborted) {
@@ -50,6 +50,11 @@ export interface FeedbackSubmitOptions {
50
50
  logsEnabled?: boolean;
51
51
  /** Optional one-way override: callers can mark human sessions as agent. */
52
52
  reporterOverride?: "agent";
53
+ /**
54
+ * File the report even when the server would refuse an outdated install.
55
+ * Sent only when true, so existing request bodies stay byte-for-byte.
56
+ */
57
+ fileAnyway?: boolean;
53
58
  }
54
59
  export interface FeedbackReporterMark {
55
60
  reporter_kind: "agent" | "human";
@@ -57,6 +62,27 @@ export interface FeedbackReporterMark {
57
62
  }
58
63
  /** Resolve a safe reporter classification without returning any env values. */
59
64
  export declare function resolveFeedbackReporter(env?: NodeJS.ProcessEnv, isTTY?: boolean, override?: string): FeedbackReporterMark;
65
+ /** One install the server says is behind the latest release. */
66
+ export interface FeedbackOutdatedPiece {
67
+ piece: string;
68
+ label: string;
69
+ installed: string;
70
+ latest: string;
71
+ update: string;
72
+ }
73
+ /**
74
+ * HTTP 409 from POST /v1/feedback when a human bug report comes from an
75
+ * install behind the latest release. `message` is the server `error` string.
76
+ * `outdated` is the server list after dropping entries that are not objects
77
+ * with string fields; a missing or bad list is empty.
78
+ */
79
+ export declare class FeedbackClientOutdatedError extends Error {
80
+ readonly code = "CLIENT_OUTDATED";
81
+ readonly outdated: FeedbackOutdatedPiece[];
82
+ constructor(message: string, outdated: FeedbackOutdatedPiece[]);
83
+ }
84
+ /** Human text for a CLIENT_OUTDATED refusal. Empty `outdated` returns the server message. */
85
+ export declare function formatClientOutdatedError(err: FeedbackClientOutdatedError): string;
60
86
  export declare function readBodyFile(bodyFile: string, stdin?: NodeJS.ReadableStream): Promise<string>;
61
87
  /**
62
88
  * Attach redacted `~/.hq` log tails to `diagnostics` if, and only if, they fit
@@ -99,8 +99,78 @@ function buildFeedbackRequestBody(opts) {
99
99
  }
100
100
  if (opts.logBundle)
101
101
  requestBody.logBundle = opts.logBundle;
102
+ if (opts.fileAnyway === true)
103
+ requestBody.fileAnyway = true;
102
104
  return requestBody;
103
105
  }
106
+ const OUTDATED_PIECE_FIELDS = ["piece", "label", "installed", "latest", "update"];
107
+ /**
108
+ * HTTP 409 from POST /v1/feedback when a human bug report comes from an
109
+ * install behind the latest release. `message` is the server `error` string.
110
+ * `outdated` is the server list after dropping entries that are not objects
111
+ * with string fields; a missing or bad list is empty.
112
+ */
113
+ export class FeedbackClientOutdatedError extends Error {
114
+ code = "CLIENT_OUTDATED";
115
+ outdated;
116
+ constructor(message, outdated) {
117
+ super(message);
118
+ this.name = "FeedbackClientOutdatedError";
119
+ this.outdated = outdated;
120
+ Object.setPrototypeOf(this, new.target.prototype);
121
+ }
122
+ }
123
+ function isClientOutdatedResponse(status, data) {
124
+ if (status !== 409 || data === null || typeof data !== "object" || Array.isArray(data)) {
125
+ return false;
126
+ }
127
+ return data.code === "CLIENT_OUTDATED";
128
+ }
129
+ function parseOutdatedPieces(data) {
130
+ if (!data || typeof data !== "object" || Array.isArray(data))
131
+ return [];
132
+ const raw = data.outdated;
133
+ if (!Array.isArray(raw))
134
+ return [];
135
+ const pieces = [];
136
+ for (const entry of raw) {
137
+ if (!entry || typeof entry !== "object" || Array.isArray(entry))
138
+ continue;
139
+ const record = entry;
140
+ if (!OUTDATED_PIECE_FIELDS.every((key) => typeof record[key] === "string"))
141
+ continue;
142
+ pieces.push({
143
+ piece: record.piece,
144
+ label: record.label,
145
+ installed: record.installed,
146
+ latest: record.latest,
147
+ update: record.update,
148
+ });
149
+ }
150
+ return pieces;
151
+ }
152
+ /** Human text for a CLIENT_OUTDATED refusal. Empty `outdated` returns the server message. */
153
+ export function formatClientOutdatedError(err) {
154
+ if (err.outdated.length === 0)
155
+ return err.message;
156
+ const details = err.outdated.map((entry) => ` ${entry.label}: installed ${entry.installed}, latest ${entry.latest} -> ${entry.update}`);
157
+ return [
158
+ "Not filed: your HQ install is behind the latest release.",
159
+ ...details,
160
+ "Update, try the same steps again, and if the bug is still there re-run with --file-anyway.",
161
+ ].join("\n");
162
+ }
163
+ function writeClientOutdatedError(err) {
164
+ console.error("HQ_FEEDBACK_CLIENT_OUTDATED");
165
+ const text = formatClientOutdatedError(err);
166
+ const splitAt = text.indexOf("\n");
167
+ if (splitAt === -1) {
168
+ console.error(chalk.yellow(text));
169
+ return;
170
+ }
171
+ console.error(chalk.yellow(text.slice(0, splitAt)));
172
+ console.error(text.slice(splitAt + 1));
173
+ }
104
174
  export async function readBodyFile(bodyFile, stdin) {
105
175
  if (bodyFile === "-") {
106
176
  const stream = stdin ?? process.stdin;
@@ -179,6 +249,7 @@ export async function submitFeedback(opts) {
179
249
  screenshots: opts.screenshots,
180
250
  logBundle: opts.logBundle,
181
251
  reporterMark,
252
+ fileAnyway: opts.fileAnyway,
182
253
  });
183
254
  // Direct callers can supply attachment references; ensure the complete base
184
255
  // envelope still fits before adding optional inline logs or making a request.
@@ -207,6 +278,9 @@ export async function submitFeedback(opts) {
207
278
  typeof data.error === "string"
208
279
  ? data.error
209
280
  : res.statusText;
281
+ if (isClientOutdatedResponse(res.status, data)) {
282
+ throw new FeedbackClientOutdatedError(errMsg, parseOutdatedPieces(data));
283
+ }
210
284
  throw new Error(`Failed to submit feedback: ${errMsg}`);
211
285
  }
212
286
  const data = (await res.json());
@@ -608,7 +682,7 @@ function registerUpdateSubcommand(feedbackCmd) {
608
682
  });
609
683
  }
610
684
  function registerSubcommand(feedbackCmd, type) {
611
- feedbackCmd
685
+ const sub = feedbackCmd
612
686
  .command(type)
613
687
  .description(type === "bug" ? "Report a bug" : "Request a feature")
614
688
  .requiredOption("--title <text>", "Short title for the report")
@@ -618,8 +692,11 @@ function registerSubcommand(feedbackCmd, type) {
618
692
  .option("--screenshot <path>", `Attach a screenshot (repeatable, up to ${MAX_SCREENSHOTS}; .png/.jpg/.jpeg/.webp/.gif)`, (value, prev) => [...prev, value], [])
619
693
  // Commander turns `--no-logs` into a boolean `logs` that defaults to true,
620
694
  // so the default is "attach logs" and the flag is the opt-out.
621
- .option("--no-logs", "Do not attach redacted tails of your ~/.hq log files (also: HQ_FEEDBACK_LOGS=0)")
622
- .action(async (opts) => {
695
+ .option("--no-logs", "Do not attach redacted tails of your ~/.hq log files (also: HQ_FEEDBACK_LOGS=0)");
696
+ if (type === "bug") {
697
+ sub.option("--file-anyway", "File the report even if this HQ install is behind the latest release (the row is stamped as filed on an outdated client)");
698
+ }
699
+ sub.action(async (opts) => {
623
700
  try {
624
701
  if (opts.reporter !== undefined && (opts.reporter !== "agent" || type !== "bug")) {
625
702
  throw new Error("Invalid --reporter value: only bug reports may use 'agent'.");
@@ -641,6 +718,7 @@ function registerSubcommand(feedbackCmd, type) {
641
718
  const reporterMark = type === "bug" && resolveProcessFlagGate(FEEDBACK_REPORTER_KIND_FLAG, { fallback: FEEDBACK_REPORTER_KIND_FLAG_FALLBACK }, () => FEEDBACK_REPORTER_KIND_FLAG_FALLBACK)
642
719
  ? resolveFeedbackReporter(process.env, process.stdin.isTTY === true, opts.reporter)
643
720
  : undefined;
721
+ const fileAnyway = type === "bug" && opts.fileAnyway === true ? true : undefined;
644
722
  // Validate the serialized server request envelope before screenshots
645
723
  // or the log bundle can create remote objects. Attachment references
646
724
  // are added and checked again inside submitFeedback after upload.
@@ -651,6 +729,7 @@ function registerSubcommand(feedbackCmd, type) {
651
729
  company: opts.company,
652
730
  diagnostics,
653
731
  reporterMark,
732
+ fileAnyway,
654
733
  }));
655
734
  // vaultApiFetch can reject an hqk_ token or an invalid API base URL
656
735
  // locally before fetch. Check the mandatory POST, and the screenshot
@@ -688,14 +767,21 @@ function registerSubcommand(feedbackCmd, type) {
688
767
  diagnostics,
689
768
  reporterOverride: opts.reporter === "agent" ? "agent" : undefined,
690
769
  logsEnabled,
770
+ fileAnyway,
691
771
  });
692
772
  console.log(`Submitted: ${result.id}`);
693
773
  if (result.publicUrl)
694
774
  console.log(`Track: ${result.publicUrl}`);
695
775
  }
696
776
  catch (err) {
697
- console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
698
- process.exit(1);
777
+ if (type === "bug" && err instanceof FeedbackClientOutdatedError) {
778
+ writeClientOutdatedError(err);
779
+ process.exit(1);
780
+ }
781
+ else {
782
+ console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
783
+ process.exit(1);
784
+ }
699
785
  }
700
786
  });
701
787
  }
@@ -11,8 +11,10 @@ export interface GlobalInstallOptions {
11
11
  env?: NodeJS.ProcessEnv;
12
12
  /** Absolute node binary for the MCP server command (default process.execPath). */
13
13
  nodePath?: string;
14
- /** Absolute hq CLI entry script (default realpath of process.argv[1]). */
14
+ /** Absolute hq CLI entry script (default: stable unversioned path of the running CLI). */
15
15
  cliEntry?: string;
16
+ /** Running CLI script for stable-entry discovery (default process.argv[1]); test seam. */
17
+ argv1?: string;
16
18
  /** Registry file override (default ~/.hq/registry.json under `home`). */
17
19
  registryFile?: string;
18
20
  log?: (line: string) => void;
@@ -15,6 +15,7 @@ import * as path from 'path';
15
15
  import { spawnSync } from 'node:child_process';
16
16
  import { buildCodexServerDef, claudeConfigFormat, codexConfigFormat, codexRemovalFormat, isCodexInstalled, jsonFormat, mergeCodexServer, removeCodexServer, registerCodexServer, unregisterCodexServer, mergeClaudeServer, readConfigDoc, realpathOrSelf, registerClaudeServer, resolveEnv, unregisterClaudeServer, writeConfigAtomic, } from './mcp-registration.js';
17
17
  import { seedRegistryFromHqRoot } from './link.js';
18
+ import { resolveMcpLaunch } from '../utils/mcp-launcher.js';
18
19
  import { resolveHqRoot } from './doctor.js';
19
20
  import { anywhereRuntimeEnabled, AnywhereRuntimeDisabledError } from './anywhere-runtime-flag.js';
20
21
  import { resolveHqMcpEndpoint } from '../lib/daemon/mcp-endpoint.js';
@@ -30,7 +31,7 @@ import { assertProviderWrappersInstallable, installProviderWrappers, providerWra
30
31
  import { checkShimOnPath, ensureShimOnUserPath, npmShimDir, shimPathWarning } from '../lib/windows/user-path.js';
31
32
  import { removeHqCliPs1Shims } from '../lib/windows/ps1-shims.js';
32
33
  import { addAgentsMdBlock, addCodexHooks, classifyLegacySkills, codexAdapterPath, codexCharterSource, codexHookTrustKeys, codexTargets, hasAllCodexHooks, HQ_OWNED_MARKER, LEGACY_BACKUP_NAME, LEGACY_SKILLS_NAME, removeAgentsMdBlock, removeCodexHooks, } from '../lib/install/codex-targets.js';
33
- import { addClaudeMdBlock, addHqHooks, charterPath, claudeTargets, hasAllHqHooks, HQ_ANYWHERE_PACK, HQ_MCP_SERVER_NAME, hqSkillsSource, lineDiff, masterHookPath, shimPath, MCP_SUBPROCESS_PATH, removeClaudeMdBlock, removeHqHooks, SKILL_LINK_PREFIX, } from '../lib/install/claude-targets.js';
34
+ import { addClaudeMdBlock, addHqHooks, charterPath, claudeTargets, hasAllHqHooks, HQ_ANYWHERE_PACK, HQ_MCP_SERVER_NAME, hqSkillsSource, lineDiff, masterHookPath, shimPath, removeClaudeMdBlock, removeHqHooks, SKILL_LINK_PREFIX, } from '../lib/install/claude-targets.js';
34
35
  export { hookTargetFor, isDaemonInstalled } from '../lib/install/hook-target.js';
35
36
  const HQ_PACKAGES_MARKETPLACE_REPOSITORY = 'indigoai-us/hq-packages';
36
37
  /** Resolve local overrides first, then the published HQ marketplace. */
@@ -179,13 +180,23 @@ function restoringRemovalFormat(original, stillPresent) {
179
180
  };
180
181
  }
181
182
  function mcpManifest(opts) {
182
- const command = opts.nodePath ?? process.execPath;
183
- const entry = opts.cliEntry ?? fs.realpathSync(process.argv[1] ?? '');
183
+ // Absolute node + an unversioned entry path of the running CLI: a realpath'd
184
+ // entry points into a version-pinned store directory that runs an old CLI
185
+ // after the next update, and a bare/shim `hq` needs PATH and a shell.
186
+ const launch = resolveMcpLaunch({
187
+ execPath: opts.nodePath ?? process.execPath,
188
+ argv1: opts.argv1 ?? process.argv[1] ?? '',
189
+ env: opts.env ?? process.env,
190
+ platform: opts.platform ?? process.platform,
191
+ home: opts.home,
192
+ });
193
+ const command = opts.nodePath ?? launch.command;
194
+ const entry = opts.cliEntry ?? launch.entry;
184
195
  for (const p of [command, entry]) {
185
196
  if (!path.isAbsolute(p))
186
197
  throw new Error(`HQ MCP server path must be absolute: ${p}`);
187
198
  }
188
- return { type: 'stdio', command, args: [entry, 'mcp', 'serve'], env: { PATH: MCP_SUBPROCESS_PATH } };
199
+ return { type: 'stdio', command, args: [entry, 'mcp', 'serve'], env: { PATH: launch.path } };
189
200
  }
190
201
  /**
191
202
  * The folder an HQ skill entry stands for: a link's resolved target, or the
@@ -174,6 +174,8 @@ export declare function createLaneFromSignal(input: {
174
174
  lane_id: string;
175
175
  existing: boolean;
176
176
  }>;
177
+ /** Project label for lanes created with --no-story and no --project. */
178
+ export declare const NO_STORY_DEFAULT_PROJECT = "standing";
177
179
  /** @internal Exported for regression tests of the profile-refresh company check. */
178
180
  export declare function applyResumeProfileAndEffort(hqRoot: string, current: LaneRecord, next: LaneRecord, input: {
179
181
  profile?: ResolvedResumeProfile;
@@ -3478,6 +3478,8 @@ export async function createLaneFromSignal(input, deps = {}) {
3478
3478
  noStory: `signal:${input.signal_id}`, freshThread: true, quiet: true }));
3479
3479
  return { lane_id: result.lane.lane_id, existing: result.existing };
3480
3480
  }
3481
+ /** Project label for lanes created with --no-story and no --project. */
3482
+ export const NO_STORY_DEFAULT_PROJECT = "standing";
3481
3483
  async function runCreate(ctx, opts) {
3482
3484
  if (opts.signal !== undefined) {
3483
3485
  if (!opts.company?.trim())
@@ -3514,9 +3516,11 @@ async function runCreate(ctx, opts) {
3514
3516
  }
3515
3517
  const companyFlag = opts.company?.trim();
3516
3518
  const meshCompanyFlag = opts.meshCompany?.trim();
3517
- const project = opts.project?.trim();
3518
3519
  const story = opts.story?.trim();
3519
3520
  const noStoryReason = opts.noStory?.trim();
3521
+ // A story-less lane (conduct standing lanes) has no project to attribute
3522
+ // to, so it falls back to a shared project label instead of failing.
3523
+ const project = opts.project?.trim() || (!story && noStoryReason ? NO_STORY_DEFAULT_PROJECT : undefined);
3520
3524
  const additionalStories = (opts.additionalStory ?? []).map((value) => value.trim());
3521
3525
  const briefFile = opts.briefFile?.trim();
3522
3526
  if (!project) {
@@ -9152,9 +9156,11 @@ async function runCreateSubagent(ctx, opts) {
9152
9156
  }
9153
9157
  }
9154
9158
  const hqRoot = ctx.hqRoot();
9155
- const project = opts.project?.trim();
9156
9159
  const story = opts.story?.trim();
9157
9160
  const noStoryReason = opts.noStory?.trim();
9161
+ // A story-less lane (conduct standing lanes) has no project to attribute
9162
+ // to, so it falls back to a shared project label instead of failing.
9163
+ const project = opts.project?.trim() || (!story && noStoryReason ? NO_STORY_DEFAULT_PROJECT : undefined);
9158
9164
  const additionalStories = (opts.additionalStory ?? []).map((value) => value.trim());
9159
9165
  const briefFile = opts.briefFile?.trim();
9160
9166
  if (!project)
@@ -10527,7 +10533,7 @@ export function registerLanesCommand(parent, deps = {}) {
10527
10533
  .description("Register a lane, run admission, and return immediately")
10528
10534
  .option("--company <slug|uid>", "Company slug or cloud uid; omit for a core/personal lane")
10529
10535
  .option("--mesh-company <slug|uid>", "Explicit Work Mesh company for a personal lane; membership is verified")
10530
- .option("--project <slug>", "HQ project slug (executive-bot for --signal)")
10536
+ .option("--project <slug>", "HQ project slug (executive-bot for --signal; defaults to standing with --no-story)")
10531
10537
  .option("--signal <id>", "Create one lane for a company signal")
10532
10538
  .option("--rules-file <path>", "Standing rules for a signal lane")
10533
10539
  .option("--any-type", "Allow signal types other than action_item")
@@ -8,8 +8,11 @@
8
8
  * under 100ms. The MCP SDK is not loaded either: the stdio transport is
9
9
  * newline-delimited JSON-RPC 2.0 and is handled here directly.
10
10
  *
11
- * When hqd is unreachable every tool call returns an isError result naming
12
- * `hq daemon status`, and the server keeps running.
11
+ * When hqd is not running, hq_resolve_company, hq_policy_check and
12
+ * hq_journal_append are answered in process with the same checks
13
+ * (src/lib/mcp/local-native-tools.ts), provided an HQ root is known. Every
14
+ * other tool call returns an isError result naming `hq daemon status`, and
15
+ * the server keeps running.
13
16
  */
14
17
  export declare const MCP_PROTOCOL_VERSIONS: readonly ["2025-06-18", "2025-03-26", "2024-11-05"];
15
18
  export interface McpServeOptions {