@indigoai-us/hq-cli 5.345.208 → 5.345.210

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 (126) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/assets/scaffold/core/scripts/derive-trigger-facts.sh +22 -3
  3. package/dist/command-catalog.generated.d.ts +33 -8
  4. package/dist/command-catalog.generated.js +40 -8
  5. package/dist/command-registration-plan.d.ts +2 -2
  6. package/dist/command-registration-plan.js +1 -1
  7. package/dist/commands/access.js +11 -5
  8. package/dist/commands/agents.d.ts +8 -0
  9. package/dist/commands/agents.js +5 -0
  10. package/dist/commands/bot.d.ts +8 -0
  11. package/dist/commands/bot.js +67 -7
  12. package/dist/commands/channels.js +4 -0
  13. package/dist/commands/cloud.d.ts +83 -2
  14. package/dist/commands/cloud.js +161 -31
  15. package/dist/commands/company.d.ts +9 -0
  16. package/dist/commands/company.js +44 -14
  17. package/dist/commands/core-checkpoint-native.js +21 -0
  18. package/dist/commands/core-derive-trigger-facts-native.js +14 -3
  19. package/dist/commands/core-generate-workers-registry-fast.d.ts +1 -1
  20. package/dist/commands/core-generate-workers-registry-fast.js +7 -1
  21. package/dist/commands/core-job-run-native.d.ts +8 -0
  22. package/dist/commands/core-job-run-native.js +11 -3
  23. package/dist/commands/core-jobs-native.js +1 -1
  24. package/dist/commands/core-register-project-native.js +31 -1
  25. package/dist/commands/core-scan-packages-fast.d.ts +1 -1
  26. package/dist/commands/core-scan-packages-fast.js +8 -1
  27. package/dist/commands/core.js +12 -3
  28. package/dist/commands/dm-attach.d.ts +10 -0
  29. package/dist/commands/dm-attach.js +33 -5
  30. package/dist/commands/integrations-connect.js +47 -2
  31. package/dist/commands/lanes-session-start.d.ts +17 -0
  32. package/dist/commands/lanes-session-start.js +281 -13
  33. package/dist/commands/lanes-watch.js +11 -3
  34. package/dist/commands/lanes.d.ts +4 -0
  35. package/dist/commands/lanes.js +95 -22
  36. package/dist/commands/library.d.ts +10 -0
  37. package/dist/commands/library.js +30 -3
  38. package/dist/commands/meetings.d.ts +42 -0
  39. package/dist/commands/meetings.js +157 -12
  40. package/dist/commands/mesh.js +3 -0
  41. package/dist/commands/monitor.d.ts +6 -0
  42. package/dist/commands/monitor.js +29 -19
  43. package/dist/commands/onboard.js +8 -1
  44. package/dist/commands/sources.js +7 -3
  45. package/dist/index.js +9 -0
  46. package/dist/lanes-monitor-check-argv.d.ts +1 -1
  47. package/dist/lanes-monitor-check-argv.js +2 -2
  48. package/dist/lanes-session-start-argv.d.ts +4 -1
  49. package/dist/lanes-session-start-argv.js +5 -2
  50. package/dist/lib/bot/fleet-daemon.d.ts +101 -0
  51. package/dist/lib/bot/fleet-daemon.js +227 -0
  52. package/dist/lib/bot/fleet-local.d.ts +26 -0
  53. package/dist/lib/bot/fleet-local.js +51 -2
  54. package/dist/lib/bot/index.d.ts +1 -0
  55. package/dist/lib/bot/index.js +1 -0
  56. package/dist/lib/bot/jobs/hot-signal-sync.d.ts +4 -0
  57. package/dist/lib/bot/jobs/hot-signal-sync.js +8 -1
  58. package/dist/lib/bot/log.js +3 -1
  59. package/dist/lib/bot/probe.js +2 -0
  60. package/dist/lib/bot/run.js +28 -3
  61. package/dist/lib/bot/runtime-failure.d.ts +4 -2
  62. package/dist/lib/bot/runtime-failure.js +9 -1
  63. package/dist/lib/bot/status.d.ts +17 -0
  64. package/dist/lib/bot/status.js +53 -2
  65. package/dist/lib/capacity/collectors/claude-oauth.d.ts +5 -5
  66. package/dist/lib/capacity/collectors/claude-oauth.js +6 -6
  67. package/dist/lib/core-utils/native-scaffold-help.d.ts +16 -0
  68. package/dist/lib/core-utils/native-scaffold-help.js +26 -0
  69. package/dist/lib/core-utils/session-company.d.ts +25 -8
  70. package/dist/lib/core-utils/session-company.js +59 -17
  71. package/dist/lib/daemon/catalog.d.ts +25 -1
  72. package/dist/lib/daemon/catalog.js +29 -2
  73. package/dist/lib/daemon/run.d.ts +0 -1
  74. package/dist/lib/daemon/run.js +3 -11
  75. package/dist/lib/daemon/server.js +26 -7
  76. package/dist/lib/daemon/supervisor.js +1 -1
  77. package/dist/lib/daemon/tools.js +17 -1
  78. package/dist/lib/db/sqlite-binding.js +2 -1
  79. package/dist/lib/doctor/checks/bots.d.ts +2 -0
  80. package/dist/lib/doctor/checks/bots.js +11 -0
  81. package/dist/lib/doctor/checks/runtime-health.js +3 -2
  82. package/dist/lib/doctor/checks/work-context.js +5 -2
  83. package/dist/lib/hook-engine/resolve.d.ts +1 -1
  84. package/dist/lib/hook-engine/resolve.js +4 -1
  85. package/dist/lib/hot-channels/adapters/meeting-providers.d.ts +2 -0
  86. package/dist/lib/hot-channels/adapters/meeting-providers.js +13 -2
  87. package/dist/lib/lanes/index.d.ts +1 -1
  88. package/dist/lib/lanes/index.js +1 -1
  89. package/dist/lib/lanes/monitor.d.ts +14 -0
  90. package/dist/lib/lanes/monitor.js +51 -10
  91. package/dist/lib/lanes/outpost-dispatch.d.ts +3 -0
  92. package/dist/lib/lanes/outpost-dispatch.js +1 -0
  93. package/dist/lib/lanes/store.d.ts +1 -1
  94. package/dist/lib/lanes/store.js +2 -1
  95. package/dist/lib/mesh/client.js +7 -1
  96. package/dist/lib/mesh/live/backfill-held.d.ts +3 -0
  97. package/dist/lib/mesh/live/backfill-held.js +167 -7
  98. package/dist/lib/mesh/live/flush.d.ts +7 -0
  99. package/dist/lib/mesh/live/flush.js +10 -1
  100. package/dist/lib/monitor.d.ts +9 -0
  101. package/dist/lib/monitor.js +33 -7
  102. package/dist/lib/onboarding/orchestrator.js +269 -132
  103. package/dist/lib/onboarding/types.d.ts +2 -0
  104. package/dist/lib/scaffold-cli-floor.js +2 -1
  105. package/dist/lib/signals/failure-alert.js +3 -1
  106. package/dist/lib/work-context/organize.d.ts +6 -0
  107. package/dist/lib/work-context/organize.js +28 -0
  108. package/dist/lib/work-context/paths.d.ts +9 -0
  109. package/dist/lib/work-context/paths.js +15 -0
  110. package/dist/lib/work-context/prd-sync.js +2 -1
  111. package/dist/runners-alias.d.ts +54 -0
  112. package/dist/runners-alias.js +86 -0
  113. package/dist/utils/install-tree-torn.js +5 -3
  114. package/dist/utils/npm-install-flags.d.ts +27 -0
  115. package/dist/utils/npm-install-flags.js +68 -0
  116. package/dist/utils/package-use-lease.js +1 -1
  117. package/dist/utils/qmd-native-binding-error.js +2 -1
  118. package/dist/utils/self-update.js +2 -1
  119. package/dist/utils/staged-install.js +2 -1
  120. package/dist/utils/staged-npm-install.js +2 -1
  121. package/dist/utils/upload-author.d.ts +2 -1
  122. package/dist/utils/upload-author.js +9 -5
  123. package/dist/utils/version-check.js +2 -1
  124. package/dist/utils/version-gate.js +7 -6
  125. package/package.json +7 -7
  126. package/scripts/install-hook-engine.mjs +7 -3
@@ -16,7 +16,7 @@ import { createResolver } from "./resolver.js";
16
16
  export { createResolver };
17
17
  import { createLineSplitter, encodeMessage, HQD_DEFAULT_REQUEST_TIMEOUT_MS, HQD_MAX_LINE_BYTES, parseRequestLine } from "./protocol.js";
18
18
  import { SessionRegistry } from "./session-registry.js";
19
- import { sessionMetaCompany } from "../core-utils/session-company.js";
19
+ import { sessionMetaCompanies } from "../core-utils/session-company.js";
20
20
  import { journalAppend, JournalOpError } from "./ops/journal.js";
21
21
  import { memoryGet, memoryPut, MemoryOpError } from "./ops/memory.js";
22
22
  import { meshPresence, MeshOpError } from "./ops/mesh.js";
@@ -322,7 +322,19 @@ export async function startHqdServer(opts) {
322
322
  throw new OpError("company_mismatch", `explicit company ${explicit} conflicts with bound company ${bound}`);
323
323
  }
324
324
  };
325
- /** Resolve a call's company while keeping any session or cwd binding authoritative. */
325
+ /** The companies a session's own meta.yaml locks it to; [] when it has no usable persisted bind. */
326
+ const persistedCompanies = (sessionId) => opts.hqRoot && sessionId ? sessionMetaCompanies(opts.hqRoot, sessionId, env) : [];
327
+ /**
328
+ * A session that persisted a company bind may act only for the companies it
329
+ * locked. An explicit company, a cwd-linked company or a session.open company
330
+ * outside that lock is a conflict, not an override (feedback_76cb8dc3).
331
+ */
332
+ const assertCompanyMatchesPersisted = (company, source, persisted) => {
333
+ if (company && persisted.length > 0 && !persisted.includes(company)) {
334
+ throw new OpError("company_mismatch", `${source} company ${company} conflicts with the session's persisted company ${persisted.join(",")}`);
335
+ }
336
+ };
337
+ /** Resolve a call's company while keeping any session, cwd or persisted binding authoritative. */
326
338
  const companyFor = (args) => {
327
339
  const explicit = stringArg(args, "company", false);
328
340
  const runtime = stringArg(args, "runtime", false);
@@ -335,15 +347,19 @@ export async function startHqdServer(opts) {
335
347
  }
336
348
  const boundCompany = session?.company ?? cwdCompany;
337
349
  assertCompanyMatchesBinding(explicit, boundCompany);
350
+ const persisted = persistedCompanies(sessionId);
351
+ assertCompanyMatchesPersisted(explicit, "explicit", persisted);
352
+ assertCompanyMatchesPersisted(session?.company ?? undefined, "session", persisted);
353
+ assertCompanyMatchesPersisted(cwdCompany, "cwd-bound", persisted);
338
354
  if (explicit ?? boundCompany)
339
355
  return explicit ?? boundCompany;
340
356
  // Neither the call, the in-memory session nor the cwd names a company:
341
- // fall back to the session's own persisted bind (meta.yaml company_slug),
342
- // which a company bot's runner writes for every turn and which survives a
343
- // daemon restart. A bot at the unlinked HQ root then resolves its own
344
- // company, and the policy check still scopes it to that one company
357
+ // use the session's own persisted bind (meta.yaml company_slug), which a
358
+ // company bot's runner writes for every turn and which survives a daemon
359
+ // restart. A bot at the unlinked HQ root then resolves its own company,
360
+ // and the policy check still scopes it to that one company
345
361
  // (feedback_578dd8ff).
346
- return opts.hqRoot && sessionId ? sessionMetaCompany(opts.hqRoot, sessionId) : undefined;
362
+ return persisted[0];
347
363
  };
348
364
  let hqMcp = opts.mcpBridge;
349
365
  if (!isPipe) {
@@ -507,6 +523,9 @@ export async function startHqdServer(opts) {
507
523
  const boundCompany = resolve(cwd).company;
508
524
  assertCompanyMatchesBinding(explicit, boundCompany ?? undefined);
509
525
  const company = explicit ?? boundCompany;
526
+ // Opening must not give the session a company its own persisted bind
527
+ // does not lock (feedback_76cb8dc3).
528
+ assertCompanyMatchesPersisted(company ?? undefined, explicit ? "explicit" : "cwd-bound", persistedCompanies(sessionId));
510
529
  return sessions.open({ runtime, sessionId, cwd: canonicalDir(cwd), company });
511
530
  }
512
531
  case "session.get": {
@@ -505,7 +505,7 @@ export function createSupervisor(deps) {
505
505
  * `drain`, a unit that has a drain signal gets it first and SIGTERM only
506
506
  * after HANDOFF_DRAIN_MAX_MS; SIGKILL follows SIGTERM after STOP_ESCALATION_MS.
507
507
  */
508
- const terminate = (slot, then, drain = false, killGraceMs = STOP_ESCALATION_MS) => {
508
+ const terminate = (slot, then, drain = false, killGraceMs = slot.plan.stopGraceMs ?? STOP_ESCALATION_MS) => {
509
509
  clearPendingSyncCommandRestart(slot);
510
510
  clearTimer(slot);
511
511
  clearHeartbeatTimer(slot);
@@ -8,6 +8,7 @@
8
8
  * it can update) and never updates a copy it cannot write.
9
9
  */
10
10
  import * as path from "node:path";
11
+ import { npmGlobalInstallArgv } from "../../utils/npm-install-flags.js";
11
12
  export const TOOL_NAMES = ["claude", "codex", "grok"];
12
13
  /** npm package for tools that can be installed with npm. */
13
14
  const NPM_PACKAGES = {
@@ -15,6 +16,17 @@ const NPM_PACKAGES = {
15
16
  codex: "@openai/codex",
16
17
  grok: "@vibe-kit/grok-cli",
17
18
  };
19
+ /**
20
+ * Packages in each tool's npm install tree whose install scripts must run
21
+ * (npm 12 blocks unlisted ones). Claude Code's postinstall links its native
22
+ * binary; Codex ships its binary only as an optional dependency, which
23
+ * `--include=optional` keeps. Matches the HQ desktop app's allow-list.
24
+ */
25
+ const NPM_ALLOW_SCRIPTS = {
26
+ claude: ["@anthropic-ai/claude-code"],
27
+ codex: [],
28
+ grok: [],
29
+ };
18
30
  /** Environment each tool's own `update` command needs to run unattended. */
19
31
  const UPDATE_ENV = {
20
32
  codex: { CODEX_NON_INTERACTIVE: "1" },
@@ -88,7 +100,11 @@ export function toolUpdateCommand(name, install, platform = process.platform) {
88
100
  const pkg = NPM_PACKAGES[name];
89
101
  const prefix = pkg ? npmPrefixOf(install.realPath, pkg, platform) : null;
90
102
  if (pkg && prefix) {
91
- return { file: "npm", args: ["install", "-g", "--prefix", prefix, `${pkg}@latest`], env: {} };
103
+ return {
104
+ file: "npm",
105
+ args: npmGlobalInstallArgv(`${pkg}@latest`, { prefix, allowScripts: NPM_ALLOW_SCRIPTS[name] ?? [] }),
106
+ env: {},
107
+ };
92
108
  }
93
109
  return { file: install.path, args: ["update"], env: { ...(UPDATE_ENV[name] ?? {}) } };
94
110
  }
@@ -9,12 +9,13 @@ import fs from "node:fs";
9
9
  import { createRequire } from "node:module";
10
10
  import path from "node:path";
11
11
  import { planResolvedCommandSpawn } from "../../utils/windows-spawn.js";
12
+ import { HQ_CLI_NPM_REPAIR_COMMAND } from "../../utils/npm-install-flags.js";
12
13
  const require = createRequire(import.meta.url);
13
14
  export class SqliteBindingError extends Error {
14
15
  constructor(cause) {
15
16
  super("better-sqlite3 did not load. npm 11.16 and later skip its install script unless scripts are allowed, so the prebuilt binary was not downloaded. " +
16
17
  "HQ tried to download the prebuild and it still failed. " +
17
- "Fix: npm install -g @indigoai-us/hq-cli --allow-scripts=better-sqlite3");
18
+ `Fix: ${HQ_CLI_NPM_REPAIR_COMMAND}`);
18
19
  this.name = "SqliteBindingError";
19
20
  if (cause !== undefined)
20
21
  this.cause = cause;
@@ -15,6 +15,8 @@ export interface BotsDoctorDeps {
15
15
  claudeLogin?: () => ClaudeLoginCheck;
16
16
  /** Whether and why a legacy bot moves to the HQ Fleet Runtime at its next start (tests). */
17
17
  legacyMove?: (dir: string, config: BotConfig) => LegacyMoveState;
18
+ /** Whether hq daemon runs this Mac's HQ Fleet bots (tests). */
19
+ fleetDaemon?: () => boolean;
18
20
  }
19
21
  /** The last reported failure, unless a later turn worked. */
20
22
  export declare function unresolvedLastFailure(status: BotStatusFile | null): BotStatusFile["lastFailure"] | null;
@@ -8,6 +8,8 @@ import * as os from "node:os";
8
8
  import * as path from "node:path";
9
9
  import { botsRoot, botDir, launchdLabel } from "../../bot/paths.js";
10
10
  import { HQ_FLEET_RUNTIME_ENGINE_ID, readBotConfig } from "../../bot/config.js";
11
+ import { fleetBotsManagedByDaemon } from "../../bot/fleet-daemon.js";
12
+ import { fleetLocalLaunchAgentLabel, fleetLocalLaunchAgentPlist } from "../../bot/fleet-local.js";
11
13
  import { checkClaudeCodeLogin, claudeLoginFix, describeClaudeLoginSources, } from "../../bot/claude-login.js";
12
14
  import { isPidAlive, readBotStatus } from "../../bot/status.js";
13
15
  import { legacyMoveState } from "../../bot/legacy-convert.js";
@@ -142,6 +144,15 @@ function runChecks(deps) {
142
144
  });
143
145
  }
144
146
  }
147
+ if (!isLegacyBot(config) && (deps.fleetDaemon ?? (() => fleetBotsManagedByDaemon({ home })))() && fs.existsSync(fleetLocalLaunchAgentPlist(config.agentUid, home))) {
148
+ results.push({
149
+ status: "WARN",
150
+ checkId: `bots.${name}.own-login-item`,
151
+ target: fleetLocalLaunchAgentPlist(config.agentUid, home),
152
+ message: `${name} still has its own login item (${fleetLocalLaunchAgentLabel(config.agentUid)}), which macOS reports as "python" running in the background. hq daemon runs HQ Fleet bots on this Mac.`,
153
+ remediation: `hq bot start ${name}`,
154
+ });
155
+ }
145
156
  const lastFailure = unresolvedLastFailure(status);
146
157
  if (lastFailure) {
147
158
  results.push({
@@ -30,6 +30,7 @@ import * as fs from "node:fs";
30
30
  import * as os from "node:os";
31
31
  import * as path from "node:path";
32
32
  import { planCommandSpawn } from "../../../utils/windows-spawn.js";
33
+ import { npmGlobalInstallArgv } from "../../../utils/npm-install-flags.js";
33
34
  /** The id of the AI-runtime-health family. */
34
35
  export const RUNTIMES_FAMILY_ID = "runtimes";
35
36
  /** Common id prefix for every result this family emits. */
@@ -54,7 +55,7 @@ export const AI_RUNTIMES = [
54
55
  binary: "claude",
55
56
  versionArgs: ["--version"],
56
57
  probeArgs: ["-p", PROBE_PROMPT],
57
- installHint: "npm install -g @anthropic-ai/claude-code",
58
+ installHint: `npm ${npmGlobalInstallArgv("@anthropic-ai/claude-code", { allowScripts: ["@anthropic-ai/claude-code"] }).join(" ")}`,
58
59
  },
59
60
  {
60
61
  key: "codex",
@@ -68,7 +69,7 @@ export const AI_RUNTIMES = [
68
69
  "read-only",
69
70
  PROBE_PROMPT,
70
71
  ],
71
- installHint: "npm install -g @openai/codex",
72
+ installHint: `npm ${npmGlobalInstallArgv("@openai/codex", { allowScripts: [] }).join(" ")}`,
72
73
  },
73
74
  {
74
75
  key: "grok",
@@ -9,7 +9,7 @@ import * as path from "node:path";
9
9
  import { readDeviceConfig, } from "../../work-context/config.js";
10
10
  import { outboxStats, listOutboxOperations } from "../../work-context/outbox.js";
11
11
  import { outboxQuarantineStatusEnabled } from "../../work-context/outbox-quarantine-status-flag.js";
12
- import { workContextRoot, workContextSessionsDir } from "../../work-context/paths.js";
12
+ import { isWorkContextSessionStateFileName, workContextRoot, workContextSessionsDir, } from "../../work-context/paths.js";
13
13
  import { countDistinctHeldEvents, countJsonlLines, deadLetterNonEmpty, } from "../../mesh/live/spool.js";
14
14
  import { workMeshDeadLetterPath, workMeshHeldPath, workMeshRoot, workMeshSpoolPath, } from "../../mesh/live/paths.js";
15
15
  import { collectDaemonDoctor, formatDaemonDoctor, } from "../../mesh/live/daemon/doctor.js";
@@ -54,7 +54,10 @@ function runChecks(deps) {
54
54
  });
55
55
  }
56
56
  else {
57
- const files = fs.readdirSync(sessionsDir).filter((n) => n.endsWith(".json"));
57
+ // Only `<sessionId>.json` is session state. Sidecars such as
58
+ // `<sessionId>.prd-snapshot.json` have their own shape and were counted
59
+ // as corrupt (feedback_e99bf6b5).
60
+ const files = fs.readdirSync(sessionsDir).filter(isWorkContextSessionStateFileName);
58
61
  let corrupt = 0;
59
62
  let healthy = 0;
60
63
  for (const name of files) {
@@ -1,5 +1,5 @@
1
1
  import { type SpawnSyncReturns } from 'node:child_process';
2
- export declare const HOOK_ENGINE_REPAIR = "npm install -g @indigoai-us/hq-cli --include=optional";
2
+ export declare const HOOK_ENGINE_REPAIR = "npm install -g @indigoai-us/hq-cli --allow-scripts=@indigoai-us/hq-cli --allow-scripts=better-sqlite3 --allow-scripts=node-llama-cpp --allow-scripts=tree-sitter-go --allow-scripts=tree-sitter-python --allow-scripts=tree-sitter-rust --allow-scripts=tree-sitter-typescript --allow-scripts=tree-sitter-javascript --include=optional";
3
3
  export declare const HOOK_ENGINE_REPAIR_PIN = "hq core hook-engine-path --repair";
4
4
  export interface EngineOptions {
5
5
  home?: string;
@@ -7,7 +7,10 @@ const require = createRequire(import.meta.url);
7
7
  // Capture metadata while the package-use lease protects this install tree.
8
8
  // Resident commands may call doctor after an update removes the old manifest.
9
9
  const cliManifest = JSON.parse(readFileSync(new URL('../../../package.json', import.meta.url), 'utf8'));
10
- export const HOOK_ENGINE_REPAIR = 'npm install -g @indigoai-us/hq-cli --include=optional';
10
+ // Inlined so this file keeps importing only node builtins (it must load from a
11
+ // resident process after an update replaced the tree, and from postinstall).
12
+ // Equal to HQ_CLI_NPM_REPAIR_COMMAND; npm-install-flags.test.ts checks parity.
13
+ export const HOOK_ENGINE_REPAIR = 'npm install -g @indigoai-us/hq-cli --allow-scripts=@indigoai-us/hq-cli --allow-scripts=better-sqlite3 --allow-scripts=node-llama-cpp --allow-scripts=tree-sitter-go --allow-scripts=tree-sitter-python --allow-scripts=tree-sitter-rust --allow-scripts=tree-sitter-typescript --allow-scripts=tree-sitter-javascript --include=optional';
11
14
  export const HOOK_ENGINE_REPAIR_PIN = 'hq core hook-engine-path --repair';
12
15
  const platforms = new Set(['win32-x64', 'win32-arm64', 'darwin-x64', 'darwin-arm64', 'linux-x64', 'linux-arm64']);
13
16
  /** US-020 must set this package capability when the replaced bash hooks retire. */
@@ -77,6 +77,8 @@ export interface MeetingIdentity {
77
77
  }
78
78
  /** Recordings that start this close together may be the same meeting. */
79
79
  export declare const SAME_MEETING_WINDOW_MS: number;
80
+ /** A real calendar event id, or undefined for missing / Fireflies placeholder. */
81
+ export declare function usableCalendarEventId(id: string | undefined): string | undefined;
80
82
  /**
81
83
  * Whether two recordings are the same meeting: the same calendar event, or
82
84
  * starts within 30 minutes plus the same call link, a matching title, or at
@@ -119,7 +119,7 @@ export const firefliesProvider = {
119
119
  async read(gateway, meeting) {
120
120
  const transcript = resultText(await gateway.call(FIREFLIES_TRANSCRIPT_TOOL, { transcriptId: meeting.id }));
121
121
  const summary = resultText(await gateway.call(FIREFLIES_SUMMARY_TOOL, { transcriptId: meeting.id }));
122
- const calId = firefliesField(transcript, "Cal Id");
122
+ const calId = usableCalendarEventId(firefliesField(transcript, "Cal Id"));
123
123
  if (calId && !meeting.calendarEventId)
124
124
  meeting.calendarEventId = calId;
125
125
  const noSentences = /^Sentences:\s*No sentences\s*$/m.test(transcript) || transcript.trim() === "";
@@ -227,13 +227,24 @@ function urlKey(url) {
227
227
  }
228
228
  /** Recordings that start this close together may be the same meeting. */
229
229
  export const SAME_MEETING_WINDOW_MS = 30 * 60 * 1000;
230
+ /** Fireflies writes this when a recording has no calendar invite. */
231
+ const NO_CALENDAR_EVENT = /^(no cal id|null|none|n\/a)$/i;
232
+ /** A real calendar event id, or undefined for missing / Fireflies placeholder. */
233
+ export function usableCalendarEventId(id) {
234
+ const v = id?.trim();
235
+ if (!v || NO_CALENDAR_EVENT.test(v))
236
+ return undefined;
237
+ return v;
238
+ }
230
239
  /**
231
240
  * Whether two recordings are the same meeting: the same calendar event, or
232
241
  * starts within 30 minutes plus the same call link, a matching title, or at
233
242
  * least two participants and more than half of the smaller list in common.
234
243
  */
235
244
  export function sameMeeting(a, b) {
236
- if (a.calendarEventId && b.calendarEventId && a.calendarEventId === b.calendarEventId)
245
+ const calA = usableCalendarEventId(a.calendarEventId);
246
+ const calB = usableCalendarEventId(b.calendarEventId);
247
+ if (calA && calB && calA === calB)
237
248
  return true;
238
249
  if (Math.abs(a.startMs - b.startMs) > SAME_MEETING_WINDOW_MS)
239
250
  return false;
@@ -24,7 +24,7 @@ export { LANES_STORE_REL, LANE_RECORDS_DIR, PENDING_INDEX_DIR, QUESTION_RECORDS_
24
24
  export type { StoreDeps } from "./store.js";
25
25
  export { DEFAULT_LANE_WATCH_INTERVAL_MS, MAX_LANE_WATCH_INTERVAL_MS, MAX_WATCHED_LANES, MAX_WATCH_OUTPUT_LINES, runLaneWatch, } from "./watch.js";
26
26
  export type { LaneWatchDeps, LaneWatchResult } from "./watch.js";
27
- export { MONITOR_ERROR_EXIT_CODE, MONITOR_ENGINES, MONITOR_MAX_TIMEOUT_MS, MONITOR_TASK_OUTPUT_MAX_BYTES, MONITOR_TRANSCRIPT_MAX_BYTES, MONITOR_UNCOVERED_EXIT_CODE, coveredLaneIds, isMonitorTaskLive, monitorReminderText, parseCanonicalWatchCommand, parseMonitorTranscript, readLiveMonitorEvidence, } from "./monitor.js";
27
+ export { MONITOR_ERROR_EXIT_CODE, MONITOR_ENGINES, MONITOR_MAX_TIMEOUT_MS, MONITOR_TASK_OUTPUT_MAX_BYTES, MONITOR_TRANSCRIPT_MAX_BYTES, MONITOR_UNCOVERED_EXIT_CODE, coveredLaneIds, expiredLaneIds, isMonitorTaskLive, monitorReminderText, parseCanonicalWatchCommand, parseMonitorTranscript, readLiveMonitorEvidence, } from "./monitor.js";
28
28
  export type { LiveMonitorEvidenceOptions, MonitorEngine, MonitorEvidence, MonitorEvidenceReader, MonitorTaskEvidence, } from "./monitor.js";
29
29
  export { IMDS_HOST, IMDS_INSTANCE_ID_URL, IMDS_TIMEOUT_MS, IMDS_TOKEN_URL, defaultReadImdsInstanceId, resolveMachineIdentity, } from "./machine-identity.js";
30
30
  export type { MachineIdentity, MachineIdentityDeps } from "./machine-identity.js";
@@ -14,7 +14,7 @@ export { LANE_STORY_LEDGER_FLAG, buildLaneStatusSnapshot, formatLaneStatusHuman,
14
14
  export { buildOutpostPickupCommand, parseOutpostPickupPayload, } from "./outpost-dispatch.js";
15
15
  export { LANES_STORE_REL, LANE_RECORDS_DIR, PENDING_INDEX_DIR, QUESTION_RECORDS_DIR, appendCappedHistory, appendLaneAttribution, appendLaneSeniorHistory, appendQuestionRouting, createLane, createQuestion, isConflictSidecarName, laneRecordPath, lanesStoreRoot, listLaneIds, expandLocalLaneIdPrefix, LANE_ID_PREFIX_MIN, listQuestionIds, mergeLaneRecords, mergeQuestionRecords, mintLaneId, mintQuestionId, parseLaneRecord, parseQuestionRecord, pendingMarkerPath, questionRecordPath, readAllLanes, readLane, readQuestion, resolveStoreHqRoot, sanitizeHostComponent, tryReadLane, tryReadQuestion, retryUpdateLane, retryUpdateQuestion, syncLaneRecordFromOwner, updateLane, updateQuestion, withLaneHireLocks, } from "./store.js";
16
16
  export { DEFAULT_LANE_WATCH_INTERVAL_MS, MAX_LANE_WATCH_INTERVAL_MS, MAX_WATCHED_LANES, MAX_WATCH_OUTPUT_LINES, runLaneWatch, } from "./watch.js";
17
- export { MONITOR_ERROR_EXIT_CODE, MONITOR_ENGINES, MONITOR_MAX_TIMEOUT_MS, MONITOR_TASK_OUTPUT_MAX_BYTES, MONITOR_TRANSCRIPT_MAX_BYTES, MONITOR_UNCOVERED_EXIT_CODE, coveredLaneIds, isMonitorTaskLive, monitorReminderText, parseCanonicalWatchCommand, parseMonitorTranscript, readLiveMonitorEvidence, } from "./monitor.js";
17
+ export { MONITOR_ERROR_EXIT_CODE, MONITOR_ENGINES, MONITOR_MAX_TIMEOUT_MS, MONITOR_TASK_OUTPUT_MAX_BYTES, MONITOR_TRANSCRIPT_MAX_BYTES, MONITOR_UNCOVERED_EXIT_CODE, coveredLaneIds, expiredLaneIds, isMonitorTaskLive, monitorReminderText, parseCanonicalWatchCommand, parseMonitorTranscript, readLiveMonitorEvidence, } from "./monitor.js";
18
18
  export { IMDS_HOST, IMDS_INSTANCE_ID_URL, IMDS_TIMEOUT_MS, IMDS_TOKEN_URL, defaultReadImdsInstanceId, resolveMachineIdentity, } from "./machine-identity.js";
19
19
  export { PID_LIVENESS_DECISIONS, PROVIDER_COMMAND, PROVIDER_MODEL_FLAG, SPAWN_TERMINAL_REASONS, ANSWERED_QUESTIONS_FILE, appendModelFlag, armLaneWatcher, buildProviderCommand, parseCliModel, resolveLaneModel, defaultProveDetached, isPidRecordAlive, laneRunDir, missingPidProbe, nextEnvelopePath, markSpawnFailure, parsePidRecord, parseProcStat, parseSpawnTerminalReason, probePidRecord, readPidRecord, readProcStarttime, readProcStarttimeDetailed, readSpawnManifest, resumePrompt, envelopeInstruction, spawnLaneWorker, stopLaneProcesses, watcherMainPath, workerEnv, } from "./spawn.js";
20
20
  export { SILENCE_MS, WATCHER_DECISION_EVENTS, WATCHER_OUT_MAX_BYTES, WATCHER_POLL_MS, WATCHER_SIGNAL_KINDS, appendCappedLog, appendWatcherSignal, applyTerminalToLane, classifyLaneExit, clearLaneStalled, isPidAlive, laneIdentityFromRecord, markLaneStalled, notifySlotFreed, parseWatcherSignalKind, readLatestEnvelope, runWatcherLoop, stalledReason, tickWatcher, watcherEventsPath, watcherLastSignalPath, watcherOutLogPath, writeWatcherDecision, } from "./watcher.js";
@@ -40,7 +40,21 @@ export interface LiveMonitorEvidenceOptions {
40
40
  export declare function parseMonitorTranscript(text: string): MonitorTaskEvidence[];
41
41
  /** Return argv only for the exact command form the gate arms. */
42
42
  export declare function parseCanonicalWatchCommand(command: string): string[] | null;
43
+ /**
44
+ * A Monitor covers its lanes only inside the 30-minute cap. `persistent` is
45
+ * deliberately ignored: current Claude Code builds stop every Monitor at 30
46
+ * minutes whatever it was armed with, so the only way a lane stays covered is
47
+ * a Monitor re-armed within the last 30 minutes (feedback 208fd2ea).
48
+ */
43
49
  export declare function isMonitorTaskLive(task: MonitorTaskEvidence, now: Date): boolean;
50
+ /**
51
+ * Lanes that HAD a watch Monitor in this session which has since ended on its
52
+ * own (the 30-minute cap passed, or its output shows it stopped or expired)
53
+ * and was not stopped with TaskStop. These lanes are uncovered because the
54
+ * Monitor needs re-arming, not because none was ever armed; the gate says so.
55
+ * A lane another live Monitor still covers is not included.
56
+ */
57
+ export declare function expiredLaneIds(evidence: MonitorEvidence, now: Date): Set<string>;
44
58
  export declare function coveredLaneIds(evidence: MonitorEvidence, now: Date): Set<string>;
45
59
  export declare function readLiveMonitorEvidence(sessionId: string, options?: LiveMonitorEvidenceOptions): MonitorEvidence;
46
60
  export type MonitorEvidenceReader = (sessionId: string) => MonitorEvidence | Promise<MonitorEvidence>;
@@ -193,7 +193,7 @@ export function parseCanonicalWatchCommand(command) {
193
193
  if (tokens.length < 4)
194
194
  return null;
195
195
  const executable = path.basename(tokens[0]);
196
- if (executable !== "hq" || tokens[1] !== "lanes" || tokens[2] !== "watch") {
196
+ if (executable !== "hq" || (tokens[1] !== "runners" && tokens[1] !== "lanes") || tokens[2] !== "watch") {
197
197
  return null;
198
198
  }
199
199
  const laneIds = tokens.slice(3);
@@ -204,17 +204,55 @@ export function parseCanonicalWatchCommand(command) {
204
204
  function taskOutputIsTerminal(outputText) {
205
205
  return outputText ? TERMINAL_TASK_OUTPUT.test(outputText) : false;
206
206
  }
207
+ function monitorDeadlineMs(task) {
208
+ const startedAt = Date.parse(task.startedAt);
209
+ if (!Number.isFinite(startedAt) || !Number.isFinite(task.timeoutMs) || task.timeoutMs <= 0) {
210
+ return null;
211
+ }
212
+ return startedAt + Math.min(task.timeoutMs, MONITOR_MAX_TIMEOUT_MS);
213
+ }
214
+ /**
215
+ * A Monitor covers its lanes only inside the 30-minute cap. `persistent` is
216
+ * deliberately ignored: current Claude Code builds stop every Monitor at 30
217
+ * minutes whatever it was armed with, so the only way a lane stays covered is
218
+ * a Monitor re-armed within the last 30 minutes (feedback 208fd2ea).
219
+ */
207
220
  export function isMonitorTaskLive(task, now) {
208
221
  if (task.stopped || task.processAlive !== true)
209
222
  return false;
210
223
  if (taskOutputIsTerminal(task.outputText))
211
224
  return false;
212
- const startedAt = Date.parse(task.startedAt);
213
- if (!Number.isFinite(startedAt) || !Number.isFinite(task.timeoutMs) || task.timeoutMs <= 0) {
214
- return false;
225
+ const deadline = monitorDeadlineMs(task);
226
+ return deadline !== null && now.getTime() < deadline;
227
+ }
228
+ /**
229
+ * Lanes that HAD a watch Monitor in this session which has since ended on its
230
+ * own (the 30-minute cap passed, or its output shows it stopped or expired)
231
+ * and was not stopped with TaskStop. These lanes are uncovered because the
232
+ * Monitor needs re-arming, not because none was ever armed; the gate says so.
233
+ * A lane another live Monitor still covers is not included.
234
+ */
235
+ export function expiredLaneIds(evidence, now) {
236
+ const covered = coveredLaneIds(evidence, now);
237
+ const expired = new Set();
238
+ for (const task of evidence.tasks) {
239
+ if (task.stopped)
240
+ continue;
241
+ const laneIds = parseCanonicalWatchCommand(task.command);
242
+ if (!laneIds)
243
+ continue;
244
+ const deadline = monitorDeadlineMs(task);
245
+ if (deadline === null)
246
+ continue;
247
+ const ended = now.getTime() >= deadline || taskOutputIsTerminal(task.outputText);
248
+ if (!ended)
249
+ continue;
250
+ for (const laneId of laneIds) {
251
+ if (!covered.has(laneId))
252
+ expired.add(laneId);
253
+ }
215
254
  }
216
- const deadline = startedAt + Math.min(task.timeoutMs, MONITOR_MAX_TIMEOUT_MS);
217
- return now.getTime() < deadline;
255
+ return expired;
218
256
  }
219
257
  export function coveredLaneIds(evidence, now) {
220
258
  const covered = new Set();
@@ -350,7 +388,7 @@ function defaultProcessCommands() {
350
388
  const WATCH_RUNTIME_EXECUTABLES = ["bun", "deno", "node", "nodejs", "ts-node", "tsx"];
351
389
  // The hq executable path may contain spaces (the desktop toolchain installs
352
390
  // under "~/Library/Application Support/Indigo HQ/..."), so the ps line cannot
353
- // be split on whitespace to find it. Match the fixed "lanes watch <ids>" suffix
391
+ // be split on whitespace to find it. Match the fixed "<group> watch <ids>" suffix
354
392
  // on the raw line, then validate whatever precedes it as an hq invocation.
355
393
  // A path form (absolute or ./, ../) is required so an unrelated leading
356
394
  // command such as "vim /tmp/hq" is not absorbed into the path.
@@ -388,7 +426,10 @@ function processHasExactCommand(processCommands, command) {
388
426
  const laneIds = parseCanonicalWatchCommand(command);
389
427
  if (!laneIds)
390
428
  return false;
391
- const expectedSuffix = ` lanes watch ${laneIds.join(" ")}`;
429
+ // Match the group name the Monitor used: `hq runners watch` or the
430
+ // `hq lanes watch` alias produce different process lines.
431
+ const groupToken = command.trim().split(/\s+/u)[1];
432
+ const expectedSuffix = ` ${groupToken} watch ${laneIds.join(" ")}`;
392
433
  return processCommands.some((rawLine) => {
393
434
  const line = rawLine.trim().replace(/\s+/gu, " ");
394
435
  if (!line.endsWith(expectedSuffix))
@@ -447,8 +488,8 @@ export function readLiveMonitorEvidence(sessionId, options = {}) {
447
488
  export function monitorReminderText() {
448
489
  return [
449
490
  "For active Claude senior lanes, arm one live Claude Code Monitor task per uncovered lane:",
450
- 'Monitor(command="hq lanes watch <lane-id>...", timeout_ms=1800000, persistent=true)',
451
- "Use `hq lanes monitor-check --session <id>` to verify coverage. `persistent=true` is requested where the installed Monitor tool honors it; Claude Code caps Monitor tasks at 30 minutes, so re-arm after expiry.",
491
+ 'Monitor(command="hq lanes watch <lane-id>...", timeout_ms=1800000)',
492
+ "Claude Code stops every Monitor after 30 minutes, so a lane stays covered only while a Monitor armed in the last 30 minutes watches it. Re-arm the same call when `hq lanes monitor-check --session <id>` reports the lane as expired.",
452
493
  "The caller must pass `--engine codex` or `--engine grok` (or set HQ_LANE_ENGINE; deprecated alias HQ_CONDUCT_ENGINE) for sessions whose engine has no Claude Monitor tool; those engines are never required to provide one.",
453
494
  ].join("\n");
454
495
  }
@@ -25,6 +25,8 @@ export interface OutpostDispatchResult {
25
25
  exitCode: number | null;
26
26
  stdout: string;
27
27
  stderr: string;
28
+ /** True when the Outpost exec transport clipped stdout/stderr at its inline output limit. */
29
+ truncated?: boolean;
28
30
  }
29
31
  export interface OutpostLaneCommand {
30
32
  action: "message" | "resume" | "stop" | "show" | "logs" | "grant" | "grant-target" | "reparent-target" | "approve-target" | "repair-company-target" | "set-target" | "blocked-escalation-target";
@@ -81,6 +83,7 @@ export interface OutpostExecPort {
81
83
  exitCode?: number | null;
82
84
  stdout?: string;
83
85
  stderr?: string;
86
+ truncated?: boolean;
84
87
  }>;
85
88
  }
86
89
  export declare function parseOutpostPickupPayload(raw: unknown): OutpostPickupPayload;
@@ -284,6 +284,7 @@ export async function dispatchOutpostPickup(port, input) {
284
284
  exitCode: result.exitCode ?? null,
285
285
  stdout: result.stdout ?? "",
286
286
  stderr: result.stderr ?? "",
287
+ ...(result.truncated === true ? { truncated: true } : {}),
287
288
  };
288
289
  }
289
290
  catch (err) {
@@ -67,7 +67,7 @@ export declare function tryReadQuestion(hqRoot: string, questionId: string, deps
67
67
  export declare function readQuestion(hqRoot: string, questionId: string, deps?: StoreDeps): QuestionRecord;
68
68
  /** Semver precedence includes prerelease identifiers (for example, rc.2 > rc.1). */
69
69
  export declare function isLaneStoreVersionNewer(storedVersion: string, runningVersion: string): boolean;
70
- export declare const LANE_STORE_UPGRADE_COMMAND = "npm install -g @indigoai-us/hq-cli@latest";
70
+ export declare const LANE_STORE_UPGRADE_COMMAND: string;
71
71
  export declare function createLane(hqRoot: string, init: Omit<LaneRecord, "schema_version" | "lane_id" | "version" | "created_at" | "updated_at"> & Partial<Pick<LaneRecord, "schema_version" | "lane_id" | "version" | "created_at" | "updated_at">>, deps?: StoreDeps): LaneRecord;
72
72
  /** Hierarchy lock: separate from record writes so callers can CAS-write while holding it. */
73
73
  export declare function withLaneHireLocks<T>(hqRoot: string, laneIds: readonly string[], fn: () => T, deps?: StoreDeps): T;
@@ -22,6 +22,7 @@ import { laneStories } from "./stories.js";
22
22
  import { parseLaneOutcomeShape } from "./outcome.js";
23
23
  import { laneStoryLedgerEnabled, syncLaneToProjectStoryLedger, validateProjectStories, } from "./story-ledger.js";
24
24
  import { liveOwnerMaxMs, reclaimStaleLock } from "./stale-lock.js";
25
+ import { HQ_CLI_NPM_UPDATE_COMMAND } from "../../utils/npm-install-flags.js";
25
26
  /** Signal identity is company-scoped and survives terminal lane states. */
26
27
  export function findLaneBySignal(company, signalId, hqRoot = resolveStoreHqRoot()) {
27
28
  return readAllLanes(hqRoot).find(lane => lane.company?.slug === company && lane.signal?.signal_id === signalId);
@@ -1671,7 +1672,7 @@ export function isLaneStoreVersionNewer(storedVersion, runningVersion) {
1671
1672
  return semver.gt(storedVersion, runningVersion);
1672
1673
  }
1673
1674
  const OLDER_LANE_STORE_WRITE_OVERRIDE = "HQ_LANES_ALLOW_OLDER_WRITE";
1674
- export const LANE_STORE_UPGRADE_COMMAND = "npm install -g @indigoai-us/hq-cli@latest";
1675
+ export const LANE_STORE_UPGRADE_COMMAND = HQ_CLI_NPM_UPDATE_COMMAND;
1675
1676
  const warnedBackgroundWriterLaneIds = new Set();
1676
1677
  function assertLaneStoreWriteAllowed(lane, laneId, writer) {
1677
1678
  const storedVersion = lane.written_by_version;
@@ -30,7 +30,13 @@ export function createWorkSessionDeliverer(opts) {
30
30
  clientOperationId: op.clientOperationId,
31
31
  operationId: op.operationId,
32
32
  digest: op.digest,
33
- contextStatus: op.projectId && op.taskId ? "bound" : op.projectId ? "needs_task" : "unresolved",
33
+ // Company-bound sessions with no project are needs_project, not unresolved.
34
+ // Recomputing from ids only used to collapse that case (feedback_802ad6cf).
35
+ contextStatus: op.projectId && op.taskId
36
+ ? "bound"
37
+ : op.projectId
38
+ ? "needs_task"
39
+ : "needs_project",
34
40
  };
35
41
  if (op.projectId)
36
42
  body.projectId = op.projectId;
@@ -71,6 +71,9 @@ export interface BackfillHeldResult {
71
71
  /**
72
72
  * A recovered company binding was persisted locally (would-recover in
73
73
  * dry-run). A reconcile attempt that ends in needs_company is unresolved.
74
+ * It means "released now or on the daemon's next held retry": a slug-only
75
+ * binding counts, and flush keeps holding it until that retry resolves its
76
+ * companyUid.
74
77
  */
75
78
  reconciled: number;
76
79
  /** Reconcile ran but resolver found no company. */