@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
@@ -20,7 +20,8 @@
20
20
  * can be parsed for its asset metadata.
21
21
  *
22
22
  * Wire contract (hq-pro US-007):
23
- * body { query: string, kind: "asset", tags?: string[], company?: string }
23
+ * body { query: string, kind: "asset", tags?: string[], company?: string, limit?: number }
24
+ * `limit` is the page size; the server defaults to 10 and caps at 50.
24
25
  * 200 { results: [{ title, snippet, metadata: { asset: {
25
26
  * placeholderPath, originalPath, title, tags, mediaKind, vaultKey } } }] }
26
27
  * 400 { code: "INVALID_SEARCH_FILTER" }
@@ -28,6 +29,7 @@
28
29
  import fs from "node:fs";
29
30
  import path from "node:path";
30
31
  import { Readable } from "node:stream";
32
+ import { InvalidArgumentError } from "commander";
31
33
  import chalk from "chalk";
32
34
  import { cloudPlaceholderPathFor, isCloudPlaceholderName, parseCloudPlaceholder, } from "@indigoai-us/hq-cloud";
33
35
  import { buildSearchArgs } from "./search.js";
@@ -44,6 +46,20 @@ import { registerLibraryRemoveCommand } from "./library-remove.js";
44
46
  import { gatedInteractiveLogin } from "../utils/interactive-caller.js";
45
47
  /** Mirrors hq-pro's MAX_ASSET_SEARCH_TAGS / tag length bound. */
46
48
  export const MAX_LIBRARY_SEARCH_TAGS = 20;
49
+ /** Mirrors hq-pro's CONTENT_SEARCH_LIMIT_CAP: the largest page /v1/search returns. */
50
+ export const MAX_LIBRARY_SEARCH_COUNT = 50;
51
+ /**
52
+ * `-n, --count`: a whole number of 1 or more. The offline index has no cap, so
53
+ * the parser does not apply the cloud's; the cloud request is capped in
54
+ * runLibrarySearch, which says so in the result.
55
+ */
56
+ export function parseLibrarySearchCount(value) {
57
+ const count = Number(value);
58
+ if (!Number.isInteger(count) || count < 1) {
59
+ throw new InvalidArgumentError("Count must be a whole number of 1 or more.");
60
+ }
61
+ return count;
62
+ }
47
63
  const MAX_TAG_LENGTH = 100;
48
64
  /** Split repeatable / comma-listed `--tag` values into a validated tag list. */
49
65
  export function normalizeTags(values) {
@@ -106,6 +122,12 @@ export async function runLibrarySearch(query, options, deps) {
106
122
  body.tags = options.tags;
107
123
  if (options.company)
108
124
  body.company = options.company;
125
+ // Without `limit` the server returns its default page of 10, so `-n 35`
126
+ // could never show more than 10 results (feedback_903fdd80). The server
127
+ // caps a page at 50; the offline path below keeps the full count.
128
+ const capped = options.count !== undefined && options.count > MAX_LIBRARY_SEARCH_COUNT;
129
+ if (options.count !== undefined)
130
+ body.limit = Math.min(options.count, MAX_LIBRARY_SEARCH_COUNT);
109
131
  let res;
110
132
  try {
111
133
  const token = await deps.getToken();
@@ -126,7 +148,9 @@ export async function runLibrarySearch(query, options, deps) {
126
148
  let results = rows.map(hitFromCloudResult).filter((hit) => hit !== null);
127
149
  if (options.count !== undefined)
128
150
  results = results.slice(0, options.count);
129
- return { source: "cloud", results };
151
+ return capped
152
+ ? { source: "cloud", cappedAt: MAX_LIBRARY_SEARCH_COUNT, results }
153
+ : { source: "cloud", results };
130
154
  }
131
155
  /** A local hit, or null for a placeholder that is not a company library asset. */
132
156
  export function hitFromPlaceholder(placeholder, tags, snippet) {
@@ -266,6 +290,9 @@ export function formatLibraryResult(result) {
266
290
  if (result.source === "local") {
267
291
  lines.push(chalk.yellow(`HQ cloud unreachable (${result.fallbackReason}); showing local index results.`));
268
292
  }
293
+ if (result.cappedAt !== undefined) {
294
+ lines.push(chalk.dim(`HQ cloud returns at most ${result.cappedAt} results per search.`));
295
+ }
269
296
  if (result.results.length === 0) {
270
297
  lines.push("No library assets found.");
271
298
  return lines.join("\n");
@@ -435,7 +462,7 @@ export function registerLibraryCommand(program) {
435
462
  .argument("[query...]", "Query terms (joined with spaces)")
436
463
  .option("--tag <tag>", "Require a tag (repeatable or comma-separated)", collectTag, [])
437
464
  .option("--company <slug>", "Restrict to one company")
438
- .option("-n, --count <count>", "Maximum result count", (value) => Number(value))
465
+ .option("-n, --count <count>", `Maximum result count (default 10; HQ cloud returns at most ${MAX_LIBRARY_SEARCH_COUNT})`, parseLibrarySearchCount)
439
466
  .option("--json", "Print machine-readable JSON")
440
467
  .action(async (queryParts = [], options) => {
441
468
  try {
@@ -1,5 +1,6 @@
1
1
  import { Command } from "commander";
2
2
  import { type PricingPlan } from "../lib/billing/usage-only.js";
3
+ export declare function inviteConflictHint(status: number, body: Record<string, unknown>): string | undefined;
3
4
  /** Upper bound on list pages one short-id lookup reads (per cursor chain). */
4
5
  export declare const SHORT_ID_MAX_PAGES = 50;
5
6
  /**
@@ -20,5 +21,46 @@ export declare function meetingPaymentRequiredLines(body: Record<string, unknown
20
21
  * Feedback 04771691-fcbc-4847-899a-6c966c561b52.
21
22
  */
22
23
  export declare function sessionCompanySlug(env?: NodeJS.ProcessEnv): string | undefined;
24
+ /**
25
+ * The company a read (list, get, search, transcript, notes) is scoped to.
26
+ * `--personal` asks for the caller's own recordings that are not attributed to
27
+ * any company: hq-pro returns those only to a call with no `companyId`, which
28
+ * is what the app's Meetings tab adds to its company lists. Without the flag a
29
+ * bound session's company replaced that call, so such a recording was in the
30
+ * app and in no `hq meetings` view (feedback_abaa0a2e).
31
+ */
32
+ export declare function meetingsReadCompanySlug(opts: {
33
+ company?: string;
34
+ personal?: boolean;
35
+ }, env?: NodeJS.ProcessEnv): string | undefined;
36
+ /** Printed under a company-scoped list or search. */
37
+ export declare const UNATTRIBUTED_MEETINGS_HINT: string;
38
+ /** The subcommands `--personal` applies to. Any other subcommand refuses it. */
39
+ export declare const PERSONAL_READ_SUBCOMMANDS: ReadonlySet<string>;
40
+ /**
41
+ * True for a list or search row that no company owns. A call with no
42
+ * `companyId` reads the caller's personal vault, but hq-pro keeps the rows
43
+ * there that are attributed to the person's default company
44
+ * (`attributed: true`) and adds that company's HQ Meet calls
45
+ * (`sourceShape: "native-call"`). The default company need not be the one the
46
+ * session is bound to, so `--personal` drops those rows.
47
+ */
48
+ export declare function isUnattributedMeeting(m: {
49
+ attributed?: boolean;
50
+ sourceShape?: string;
51
+ companyId?: string;
52
+ }): boolean;
53
+ /** The same test for a meeting detail (get, transcript, notes). */
54
+ export declare function isUnattributedMeetingDetail(d: {
55
+ sourceShape?: string;
56
+ companyId?: string;
57
+ source?: {
58
+ frontmatter?: {
59
+ company_id?: string;
60
+ };
61
+ };
62
+ }): boolean;
63
+ /** Refused under `--personal`: the meeting belongs to a company. */
64
+ export declare const ATTRIBUTED_MEETING_UNDER_PERSONAL: string;
23
65
  export declare function registerMeetingsCommand(program: Command): void;
24
66
  //# sourceMappingURL=meetings.d.ts.map
@@ -8,6 +8,29 @@ import { isPlanGateError, planGateErrorFromPayload, } from "../utils/plan-gate-e
8
8
  import { mapWithConcurrency } from "./sync-manifest.js";
9
9
  import { fetchAttendedLiveBots } from "../lib/live-meetings.js";
10
10
  import { isUsageOnly, pricingPlanFromBody, resolveCompanyPricingPlan, usageOnlyCardRequiredLines, usagePauseFromBody, } from "../lib/billing/usage-only.js";
11
+ /**
12
+ * The remedy line for an invite the server refused because a bot already
13
+ * holds the meeting (`code: "bot-already-scheduled"`, with that bot's id).
14
+ * Before this, the 409 printed only "A bot is already scheduled for this
15
+ * meeting URL" and the CLI had no way to clear the stuck bot, so a bot that
16
+ * never left `scheduled` blocked the meeting for good. Feedback b6d23d19.
17
+ */
18
+ /**
19
+ * Bot states that mean the bot is live in the meeting. A 409 naming one of
20
+ * these gets no cancel hint, so nobody cancels a meeting that is really being
21
+ * joined or recorded.
22
+ */
23
+ const LIVE_BOT_STATES = new Set(["joining", "recording"]);
24
+ export function inviteConflictHint(status, body) {
25
+ if (status !== 409 || body.code !== "bot-already-scheduled")
26
+ return undefined;
27
+ if (typeof body.botId !== "string" || body.botId.length === 0)
28
+ return undefined;
29
+ if (typeof body.status === "string" && LIVE_BOT_STATES.has(body.status))
30
+ return undefined;
31
+ const state = typeof body.status === "string" ? ` (status: ${body.status})` : "";
32
+ return `Bot ${body.botId}${state} already holds this meeting. If it is stuck, run \`hq meetings cancel ${body.botId}\`, then invite again.`;
33
+ }
11
34
  const LIVE_SNAPSHOT_STATUSES = new Set([
12
35
  "joining",
13
36
  "recording",
@@ -247,9 +270,10 @@ export const SHORT_ID_MAX_PAGES = 50;
247
270
  * missed any meeting past it, so follow `nextToken` (and `nativeNextToken`
248
271
  * for HQ Meet calls) until the prefix is found or the list ends. A full
249
272
  * 8-character prefix stops at the first page with a match; a shorter prefix
250
- * reads every page so ambiguity is still reported.
273
+ * reads every page so ambiguity is still reported. `accept` limits which rows
274
+ * can match (`--personal` passes `isUnattributedMeeting`).
251
275
  */
252
- async function resolveShortId(token, prefix, query) {
276
+ async function resolveShortId(token, prefix, query, accept = () => true) {
253
277
  if (prefix.includes("-") && prefix.length > 8)
254
278
  return prefix;
255
279
  const stopOnFirstMatch = prefix.length >= 8;
@@ -266,7 +290,7 @@ async function resolveShortId(token, prefix, query) {
266
290
  }
267
291
  const data = (await res.json());
268
292
  for (const m of data.meetings ?? []) {
269
- if (typeof m.meetingId === "string" && m.meetingId.startsWith(prefix))
293
+ if (typeof m.meetingId === "string" && m.meetingId.startsWith(prefix) && accept(m))
270
294
  matches.set(m.meetingId, m);
271
295
  }
272
296
  return data;
@@ -296,7 +320,7 @@ async function resolveShortId(token, prefix, query) {
296
320
  }
297
321
  console.error(chalk.red(capped
298
322
  ? `No meeting matches ID "${prefix}" in the newest ${SHORT_ID_MAX_PAGES * Number(MEETINGS_PAGE_SIZE)} meetings. Pass the full meeting id (shown by \`hq meetings list --json\`).`
299
- : `No meeting matches ID "${prefix}". It may still be processing or attributed to a different company. Pass the full meeting id, or add --company <slug>.`));
323
+ : `No meeting matches ID "${prefix}". It may still be processing, attributed to a different company, or not attributed to any company. Pass the full meeting id, or add --company <slug> or --personal.`));
300
324
  process.exit(1);
301
325
  }
302
326
  /**
@@ -353,6 +377,9 @@ async function handleApiError(res, json = false) {
353
377
  }
354
378
  else {
355
379
  console.error(chalk.red(`API error (${res.status}): ${body.error ?? res.statusText}`));
380
+ const hint = inviteConflictHint(res.status, body);
381
+ if (hint)
382
+ console.error(chalk.dim(` ${hint}`));
356
383
  }
357
384
  process.exit(1);
358
385
  }
@@ -444,12 +471,81 @@ export function sessionCompanySlug(env = process.env) {
444
471
  const primary = lock?.companies[0];
445
472
  return primary && primary !== "personal" ? primary : undefined;
446
473
  }
474
+ /**
475
+ * The company a read (list, get, search, transcript, notes) is scoped to.
476
+ * `--personal` asks for the caller's own recordings that are not attributed to
477
+ * any company: hq-pro returns those only to a call with no `companyId`, which
478
+ * is what the app's Meetings tab adds to its company lists. Without the flag a
479
+ * bound session's company replaced that call, so such a recording was in the
480
+ * app and in no `hq meetings` view (feedback_abaa0a2e).
481
+ */
482
+ export function meetingsReadCompanySlug(opts, env = process.env) {
483
+ if (opts.personal && opts.company) {
484
+ throw new Error("Pass --company <slug> or --personal, not both.");
485
+ }
486
+ if (opts.personal)
487
+ return undefined;
488
+ return opts.company ?? sessionCompanySlug(env);
489
+ }
490
+ /** Printed under a company-scoped list or search. */
491
+ export const UNATTRIBUTED_MEETINGS_HINT = "Recordings not attributed to a company are not listed here. Add --personal to see them " +
492
+ "(for example `hq meetings list --personal`).";
493
+ /** The subcommands `--personal` applies to. Any other subcommand refuses it. */
494
+ export const PERSONAL_READ_SUBCOMMANDS = new Set([
495
+ "list",
496
+ "get",
497
+ "search",
498
+ "transcript",
499
+ "notes",
500
+ ]);
501
+ /**
502
+ * True for a list or search row that no company owns. A call with no
503
+ * `companyId` reads the caller's personal vault, but hq-pro keeps the rows
504
+ * there that are attributed to the person's default company
505
+ * (`attributed: true`) and adds that company's HQ Meet calls
506
+ * (`sourceShape: "native-call"`). The default company need not be the one the
507
+ * session is bound to, so `--personal` drops those rows.
508
+ */
509
+ export function isUnattributedMeeting(m) {
510
+ if (m.attributed === true || m.sourceShape === "native-call")
511
+ return false;
512
+ return !m.companyId || m.companyId === "unknown";
513
+ }
514
+ /** The same test for a meeting detail (get, transcript, notes). */
515
+ export function isUnattributedMeetingDetail(d) {
516
+ if (d.sourceShape === "native-call")
517
+ return false;
518
+ const attributedTo = (value) => !!value && value !== "unknown";
519
+ return !attributedTo(d.companyId) && !attributedTo(d.source?.frontmatter?.company_id);
520
+ }
521
+ /** Refused under `--personal`: the meeting belongs to a company. */
522
+ export const ATTRIBUTED_MEETING_UNDER_PERSONAL = "This meeting is attributed to a company, so --personal does not read it. " +
523
+ "Use --company <slug> for that company instead.";
447
524
  export function registerMeetingsCommand(program) {
448
525
  const meetings = program
449
526
  .command("meetings")
450
527
  .description("View and search meeting recordings, transcripts, and notes")
451
528
  .option("--company <slug>", "Company slug (defaults to the company this HQ session is bound to)")
529
+ .option("--personal", "Read your recordings that are not attributed to any company (list, get, search, transcript, notes)")
452
530
  .option("--json", "Output raw JSON instead of formatted text");
531
+ const personalRead = () => meetings.opts().personal === true;
532
+ // `--personal` is a group option, so every subcommand would accept it.
533
+ // Refuse it where it would be ignored (live, invite, import, set-company).
534
+ meetings.hook("preAction", (_group, action) => {
535
+ if (personalRead() && !PERSONAL_READ_SUBCOMMANDS.has(action.name())) {
536
+ console.error(chalk.red(`--personal applies only to ${[...PERSONAL_READ_SUBCOMMANDS].join(", ")}; it is not an option of \`hq meetings ${action.name()}\`.`));
537
+ process.exit(1);
538
+ }
539
+ });
540
+ // Under `--personal`, a get, transcript or notes read stops here when the
541
+ // meeting turns out to belong to a company (a full id skips the list filter).
542
+ const refuseAttributedUnderPersonal = (detail) => {
543
+ if (!personalRead() || isUnattributedMeetingDetail(detail))
544
+ return;
545
+ console.error(chalk.red(ATTRIBUTED_MEETING_UNDER_PERSONAL));
546
+ process.exit(1);
547
+ };
548
+ const shortIdFilter = () => personalRead() ? isUnattributedMeeting : () => true;
453
549
  // ── hq meetings list ──────────────────────────────────────────────
454
550
  meetings
455
551
  .command("list")
@@ -460,7 +556,7 @@ export function registerMeetingsCommand(program) {
460
556
  try {
461
557
  const token = await ensureCognitoToken();
462
558
  const query = {};
463
- const companySlug = meetings.opts().company ?? sessionCompanySlug();
559
+ const companySlug = meetingsReadCompanySlug(meetings.opts());
464
560
  if (opts.limit)
465
561
  query.limit = opts.limit;
466
562
  if (opts.next)
@@ -471,12 +567,21 @@ export function registerMeetingsCommand(program) {
471
567
  if (!res.ok)
472
568
  await handleApiError(res, meetings.opts().json);
473
569
  const data = (await res.json());
570
+ if (personalRead()) {
571
+ // Company rows and HQ Meet calls are dropped, so the HQ Meet cursor
572
+ // and pending-authorization ids (company calls) go too.
573
+ data.meetings = (data.meetings ?? []).filter(isUnattributedMeeting);
574
+ delete data.nativeNextToken;
575
+ delete data.nativeAuthorizationPending;
576
+ }
474
577
  if (meetings.opts().json) {
475
578
  console.log(JSON.stringify(data, null, 2));
476
579
  return;
477
580
  }
478
581
  console.log(chalk.bold(`\nMeetings (${data.meetings.length}):\n`));
479
582
  printMeetingTable(data.meetings);
583
+ if (companySlug)
584
+ console.log(chalk.dim(`\n ${UNATTRIBUTED_MEETINGS_HINT}`));
480
585
  if (data.nextToken) {
481
586
  console.log(chalk.dim(`\n More results available. Run with --next ${data.nextToken}`));
482
587
  }
@@ -709,6 +814,39 @@ export function registerMeetingsCommand(program) {
709
814
  handleMeetingsCommandError(err);
710
815
  }
711
816
  });
817
+ // ── hq meetings cancel <botId> ────────────────────────────────────
818
+ meetings
819
+ .command("cancel <botId>")
820
+ .description("Cancel a meeting bot (for example one stuck at scheduled) so the meeting can be invited again. " +
821
+ "A bot from a recurring calendar event cancels the series' upcoming bots too.")
822
+ .action(async (botId) => {
823
+ try {
824
+ const token = await ensureCognitoToken();
825
+ // Bots are owned by the caller; the cancel route needs no company.
826
+ const res = await vaultApiFetch({
827
+ token,
828
+ method: "POST",
829
+ path: `/v1/bot/${encodeURIComponent(botId)}/cancel`,
830
+ });
831
+ if (!res.ok)
832
+ await handleApiError(res, meetings.opts().json);
833
+ const data = (await res.json());
834
+ if (meetings.opts().json) {
835
+ console.log(JSON.stringify(data, null, 2));
836
+ return;
837
+ }
838
+ console.log(chalk.green(`\n✓ Meeting bot ${chalk.cyan(data.botId ?? botId)} cancelled.`));
839
+ if (data.scope === "series") {
840
+ console.log(chalk.dim(` Recurring meeting: cancelled ${data.cancelledCount ?? 1} bot(s) in the series` +
841
+ (data.failedCount ? `, ${data.failedCount} could not be cancelled.` : ".")));
842
+ }
843
+ console.log(chalk.dim(" Run `hq meetings invite <meetingUrl>` to send a new bot."));
844
+ console.log();
845
+ }
846
+ catch (err) {
847
+ handleMeetingsCommandError(err);
848
+ }
849
+ });
712
850
  // ── hq meetings get <id> ──────────────────────────────────────────
713
851
  meetings
714
852
  .command("get <meetingId>")
@@ -717,10 +855,10 @@ export function registerMeetingsCommand(program) {
717
855
  try {
718
856
  const token = await ensureCognitoToken();
719
857
  const query = {};
720
- const companySlug = meetings.opts().company ?? sessionCompanySlug();
858
+ const companySlug = meetingsReadCompanySlug(meetings.opts());
721
859
  if (companySlug)
722
860
  query.companyId = await getCompanyUid(token, companySlug);
723
- const meetingId = await resolveShortId(token, rawId, query);
861
+ const meetingId = await resolveShortId(token, rawId, query, shortIdFilter());
724
862
  const res = await vaultApiFetch({
725
863
  token,
726
864
  path: `/v1/meetings/${encodeURIComponent(meetingId)}`,
@@ -729,6 +867,7 @@ export function registerMeetingsCommand(program) {
729
867
  if (!res.ok)
730
868
  await handleApiError(res, meetings.opts().json);
731
869
  const detail = (await res.json());
870
+ refuseAttributedUnderPersonal(detail);
732
871
  if (meetings.opts().json) {
733
872
  console.log(JSON.stringify(detail, null, 2));
734
873
  return;
@@ -842,7 +981,7 @@ export function registerMeetingsCommand(program) {
842
981
  try {
843
982
  const token = await ensureCognitoToken();
844
983
  const params = { q: query };
845
- const companySlug = meetings.opts().company ?? sessionCompanySlug();
984
+ const companySlug = meetingsReadCompanySlug(meetings.opts());
846
985
  if (companySlug)
847
986
  params.companyId = await getCompanyUid(token, companySlug);
848
987
  const res = await vaultApiFetch({
@@ -853,12 +992,16 @@ export function registerMeetingsCommand(program) {
853
992
  if (!res.ok)
854
993
  await handleApiError(res, meetings.opts().json);
855
994
  const data = (await res.json());
995
+ if (personalRead())
996
+ data.results = (data.results ?? []).filter(isUnattributedMeeting);
856
997
  if (meetings.opts().json) {
857
998
  console.log(JSON.stringify(data, null, 2));
858
999
  return;
859
1000
  }
860
1001
  console.log(chalk.bold(`\nSearch results for "${data.query}" (${data.results.length}):\n`));
861
1002
  printMeetingTable(data.results);
1003
+ if (companySlug)
1004
+ console.log(chalk.dim(`\n ${UNATTRIBUTED_MEETINGS_HINT}`));
862
1005
  console.log();
863
1006
  }
864
1007
  catch (err) {
@@ -873,10 +1016,10 @@ export function registerMeetingsCommand(program) {
873
1016
  try {
874
1017
  const token = await ensureCognitoToken();
875
1018
  const query = {};
876
- const companySlug = meetings.opts().company ?? sessionCompanySlug();
1019
+ const companySlug = meetingsReadCompanySlug(meetings.opts());
877
1020
  if (companySlug)
878
1021
  query.companyId = await getCompanyUid(token, companySlug);
879
- const meetingId = await resolveShortId(token, rawId, query);
1022
+ const meetingId = await resolveShortId(token, rawId, query, shortIdFilter());
880
1023
  const res = await vaultApiFetch({
881
1024
  token,
882
1025
  path: `/v1/meetings/${encodeURIComponent(meetingId)}`,
@@ -885,6 +1028,7 @@ export function registerMeetingsCommand(program) {
885
1028
  if (!res.ok)
886
1029
  await handleApiError(res, meetings.opts().json);
887
1030
  const detail = (await res.json());
1031
+ refuseAttributedUnderPersonal(detail);
888
1032
  if (isMarkdownShape(detail)) {
889
1033
  const documentUrl = detail.source.presigned_url;
890
1034
  if (!documentUrl) {
@@ -942,10 +1086,10 @@ export function registerMeetingsCommand(program) {
942
1086
  try {
943
1087
  const token = await ensureCognitoToken();
944
1088
  const query = {};
945
- const companySlug = meetings.opts().company ?? sessionCompanySlug();
1089
+ const companySlug = meetingsReadCompanySlug(meetings.opts());
946
1090
  if (companySlug)
947
1091
  query.companyId = await getCompanyUid(token, companySlug);
948
- const meetingId = await resolveShortId(token, rawId, query);
1092
+ const meetingId = await resolveShortId(token, rawId, query, shortIdFilter());
949
1093
  const res = await vaultApiFetch({
950
1094
  token,
951
1095
  path: `/v1/meetings/${encodeURIComponent(meetingId)}`,
@@ -954,6 +1098,7 @@ export function registerMeetingsCommand(program) {
954
1098
  if (!res.ok)
955
1099
  await handleApiError(res, meetings.opts().json);
956
1100
  const detail = (await res.json());
1101
+ refuseAttributedUnderPersonal(detail);
957
1102
  if (isMarkdownShape(detail)) {
958
1103
  if (hasSignals(detail.signals)) {
959
1104
  if (meetings.opts().json) {
@@ -2104,10 +2104,12 @@ async function runContextOrganize(opts) {
2104
2104
  return;
2105
2105
  }
2106
2106
  let postOrganize;
2107
+ let submitFetchCandidates;
2107
2108
  if (!opts.untracked && !opts.offline) {
2108
2109
  try {
2109
2110
  const token = await requireToken();
2110
2111
  postOrganize = createOrganizePoster({ token });
2112
+ submitFetchCandidates = createCandidatesFetcher({ token });
2111
2113
  }
2112
2114
  catch {
2113
2115
  fail("Cognito session required to submit organize (server receipt only)");
@@ -2122,6 +2124,7 @@ async function runContextOrganize(opts) {
2122
2124
  createTaskTitle: opts.createTask,
2123
2125
  untracked: opts.untracked,
2124
2126
  postOrganize,
2127
+ fetchCandidates: submitFetchCandidates,
2125
2128
  });
2126
2129
  if (!submitted.ok) {
2127
2130
  console.error(chalk.red(`${submitted.errorCode ?? "ORGANIZE_FAILED"}: ${submitted.message ?? "organize failed"}`));
@@ -31,6 +31,12 @@ export declare function invokeLaneMonitorMessage(hqRoot: string, meta: MonitorMe
31
31
  outcome: string;
32
32
  }>;
33
33
  export declare function deliverNormalEvent(hqRoot: string, meta: MonitorMetadata, state: MonitorState, rawText: string, inProcess?: MonitorLaneMessageApi): Promise<MonitorState>;
34
+ /**
35
+ * One supervisor tick's check-in. Listing every monitor is only worth doing when
36
+ * this monitor's own check-in may be due; every tick still refreshes `state` from
37
+ * disk, because a check-in sent by a sibling's supervisor can advance it.
38
+ */
39
+ export declare function monitorCheckin(hqRoot: string, meta: MonitorMetadata, state: MonitorState, inProcess?: MonitorLaneMessageApi): Promise<MonitorState>;
34
40
  export interface RunSupervisorDeps {
35
41
  resolveRoot?: () => string;
36
42
  monitorEnabled?: typeof monitorEnabled;
@@ -8,7 +8,7 @@ import { LanesError } from "../lib/lanes/errors.js";
8
8
  import { readToolActivity, tryReadLane } from "../lib/lanes/index.js";
9
9
  import { appendDropboxMessageAtPath, drainDropboxAtPath, formatDropboxMessages } from "../lib/lanes/dropbox.js";
10
10
  import { dispatchLaneDelivery } from "../lib/lanes/delivery-core.js";
11
- import { MONITOR_FLAG, MONITOR_FLAG_DEFAULT, MONITOR_DEFAULT_CHECKIN_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_POLL_INTERVAL_MS, MONITOR_BATCH_WINDOW_MS, MONITOR_MAX_EVENTS_PER_WINDOW, MONITOR_MAX_FLOOD_WINDOWS, MONITOR_RATE_WINDOW_MS, MONITOR_SCHEMA_VERSION, monitorDir, monitorSessionDir, monitorSessionHasActiveMarkerForOwner, monitorSessionHasActiveMarkers, monitorSessionHasWork, monitorSessionInboxHasEvents, monitorTargetKey, assertMonitorTimeoutCompatibility, parseMonitorDuration, parseMonitorTarget, detectMonitorTarget, findNearestMonitorRuntime, makeMonitorId, recordMonitorTargetDelivery, recordMonitorTargetActivity, recordMonitorTargetDeliveryAtPath, runMonitorCheckinTick, readMonitorPidLiveness, recordHookSessionMapping, resolveMappedSessionId, parseHookSessionId, withMonitorTargetLock, nextMonitorEventSequence, recordMonitorEventState, requestMonitorStop, nextMonitorTimeoutDelay } from "../lib/monitor.js";
11
+ import { MONITOR_FLAG, MONITOR_FLAG_DEFAULT, MONITOR_DEFAULT_CHECKIN_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_POLL_INTERVAL_MS, MONITOR_BATCH_WINDOW_MS, MONITOR_MAX_EVENTS_PER_WINDOW, MONITOR_MAX_FLOOD_WINDOWS, MONITOR_RATE_WINDOW_MS, MONITOR_SCHEMA_VERSION, monitorDir, monitorSessionDir, monitorSessionHasActiveMarkerForOwner, monitorSessionHasActiveMarkers, monitorSessionHasWork, monitorSessionInboxHasEvents, monitorTargetKey, assertMonitorTimeoutCompatibility, parseMonitorDuration, parseMonitorTarget, detectMonitorTarget, findNearestMonitorRuntime, makeMonitorId, recordMonitorTargetDelivery, recordMonitorTargetActivity, recordMonitorTargetDeliveryAtPath, monitorCheckinMayBeDue, runMonitorCheckinTick, readMonitorPidLiveness, recordHookSessionMapping, resolveMappedSessionId, parseHookSessionId, withMonitorTargetLock, nextMonitorEventSequence, recordMonitorEventState, requestMonitorStop, nextMonitorTimeoutDelay } from "../lib/monitor.js";
12
12
  import { readProcStarttime } from "../lib/lanes/spawn.js";
13
13
  import { createMonitorLaneMessageApi } from "./lanes.js";
14
14
  import { releaseCurrentPackageUseLease, releasePackageUseLeaseAfterResidentPreload } from "../utils/package-use-lease.js";
@@ -533,28 +533,38 @@ function targetEnded(hqRoot, meta) {
533
533
  const lane = tryReadLane(hqRoot, meta.target.laneId);
534
534
  return !lane || ["killed", "cancelled", "failed"].includes(lane.state);
535
535
  }
536
- async function monitorCheckin(hqRoot, meta, state, inProcess) {
536
+ function targetCanWake(hqRoot, target) {
537
+ if (target.kind === "session")
538
+ return target.provider === "claude";
539
+ const lane = tryReadLane(hqRoot, target.laneId);
540
+ return lane !== null && (lane.state === "running" ||
541
+ ((lane.state === "done" || lane.state === "blocked") && Boolean(lane.provider_session_id)));
542
+ }
543
+ function laneToolActivityAt(hqRoot, target) {
544
+ if (target.kind !== "lane")
545
+ return null;
546
+ const activityAt = readToolActivity(hqRoot, target.laneId)?.at;
547
+ if (!activityAt)
548
+ return null;
549
+ const parsed = Date.parse(activityAt);
550
+ return Number.isFinite(parsed) ? parsed : null;
551
+ }
552
+ /**
553
+ * One supervisor tick's check-in. Listing every monitor is only worth doing when
554
+ * this monitor's own check-in may be due; every tick still refreshes `state` from
555
+ * disk, because a check-in sent by a sibling's supervisor can advance it.
556
+ */
557
+ export async function monitorCheckin(hqRoot, meta, state, inProcess) {
558
+ const mayBeDue = monitorCheckinMayBeDue(hqRoot, meta.target_key, meta.checkin_ms, Date.now(), laneToolActivityAt(hqRoot, meta.target));
559
+ if (!mayBeDue || !targetCanWake(hqRoot, meta.target))
560
+ return readJson(statePath(hqRoot, meta.monitor_id)) ?? state;
537
561
  await runMonitorCheckinTick(hqRoot, meta.target_key, {
538
562
  now: () => new Date(),
539
563
  isWakeable: async (targetKey) => {
540
564
  const monitor = activeTargetMeta(hqRoot, targetKey)[0];
541
- if (!monitor)
542
- return false;
543
- if (monitor.target.kind === "session")
544
- return monitor.target.provider === "claude";
545
- const lane = tryReadLane(hqRoot, monitor.target.laneId);
546
- return lane !== null && (lane.state === "running" ||
547
- ((lane.state === "done" || lane.state === "blocked") && Boolean(lane.provider_session_id)));
548
- },
549
- readTargetActivityAt: (targetKey) => {
550
- if (meta.target.kind !== "lane" || targetKey !== meta.target_key)
551
- return null;
552
- const activityAt = readToolActivity(hqRoot, meta.target.laneId)?.at;
553
- if (!activityAt)
554
- return null;
555
- const parsed = Date.parse(activityAt);
556
- return Number.isFinite(parsed) ? parsed : null;
565
+ return monitor !== undefined && targetCanWake(hqRoot, monitor.target);
557
566
  },
567
+ readTargetActivityAt: (targetKey) => (targetKey === meta.target_key ? laneToolActivityAt(hqRoot, meta.target) : null),
558
568
  deliver: async (text) => {
559
569
  const monitor = activeTargetMeta(hqRoot, meta.target_key)[0];
560
570
  if (!monitor)
@@ -933,7 +943,7 @@ export function registerMonitorCommand(parent) {
933
943
  .description("Start a detached monitor script")
934
944
  .requiredOption("--description <text>", "Why this monitor exists")
935
945
  .option("--command <sh>", "Run one shell command under bash -c")
936
- .option("--timeout <duration>", "Deadline; bare numbers are milliseconds")
946
+ .option("--timeout <duration>", "Deadline; default 30m; bare numbers are milliseconds")
937
947
  .option("--persistent", "Run until the script exits, the target ends, or stopped")
938
948
  .option("--target <target>", "lane:<id> or session:<provider>:<session-id>")
939
949
  .option("--checkin <duration|off>", "Per-target check-in interval; defaults to 55m")
@@ -168,7 +168,14 @@ export function registerOnboardCommand(program) {
168
168
  checkpoint,
169
169
  ownedPersonUids,
170
170
  });
171
- if (check.kind === "mismatch") {
171
+ if (check.kind === "mismatch" && ownedPersonUids.length > 0) {
172
+ // feedback_a169f6dc: the orchestrator now re-links the run to the
173
+ // person record this sign-in owns, so resume can finish instead
174
+ // of stopping at the membership step.
175
+ console.warn(chalk.yellow(` The saved onboarding checkpoint names person ${check.personUid}, which belongs to another sign-in. ` +
176
+ `Continuing with your current sign-in's person record; the company and membership steps run again under it.`));
177
+ }
178
+ else if (check.kind === "mismatch") {
172
179
  console.error(chalk.red(`\n✗ Resume blocked:\n\n${check.message}`));
173
180
  process.exit(1);
174
181
  }
@@ -451,9 +451,11 @@ async function meetingIdentities(input, session, email) {
451
451
  */
452
452
  export async function runCompanyHotChannelSync(input) {
453
453
  assertSafeSegment(input.company, "company");
454
+ // A sub-only upload author (machine token with no email) has no person key
455
+ // for the hot-channel audience, so it is treated as not signed in.
454
456
  const author = resolveUploadAuthor();
455
- const session = author ? await signedInSession(input.company) : null;
456
- if (!author || !session)
457
+ const session = author?.email ? await signedInSession(input.company) : null;
458
+ if (!author?.email || !session)
457
459
  return signInReport();
458
460
  const vaultRoot = path.join(input.hqRoot, "companies", input.company);
459
461
  const personKey = audienceKey([author.email]);
@@ -694,7 +696,9 @@ export async function runSignalsRedo(options, overrides = {}) {
694
696
  const channels = [...new Set([...selection.pending.keys(), ...selection.worklist.keys()])];
695
697
  if (!report.dryRun && channels.length > 0) {
696
698
  const author = overrides.author !== undefined ? overrides.author : resolveUploadAuthor();
697
- if (!author)
699
+ // A sub-only author (machine token with no email) has no person key for
700
+ // the hot-channel lock, so it is treated as not signed in.
701
+ if (!author?.email)
698
702
  return fail(`${SIGN_IN_PROMPT} (the run takes your hot-channel sync lock)`, 1);
699
703
  const lock = await acquireSyncLock(vaultRoot, audienceKey([author.email]), overrides.now ? { now: overrides.now } : {});
700
704
  if (!lock)
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ import { installWindowsHideDefault } from "./utils/windows-hide-default.js";
17
17
  import { fileURLToPath } from "node:url";
18
18
  import { parseMonitorCheckFastRequest } from "./lanes-monitor-check-argv.js";
19
19
  import { isLaneSessionStartFastRequest } from "./lanes-session-start-argv.js";
20
+ import { writeLanesAliasDeprecationForArgv } from "./runners-alias.js";
20
21
  import { createRequire } from "node:module";
21
22
  import { hookEnginePathArgs, runHookEnginePath } from "./hook-engine-path.js";
22
23
  function cygpathMixedPath(value) {
@@ -225,6 +226,14 @@ function dispatchCliRoutes() {
225
226
  process.argv = normalizeCorePathOperands(process.argv, "win32", cygpathMixedPath);
226
227
  }
227
228
  const versionRequest = isVersionRequest(process.argv);
229
+ // `hq lanes` is the deprecated alias of `hq runners`. Every route below
230
+ // (catalog help, the session-start and monitor-check fast routes, and the
231
+ // full command graph) shares this one stderr line; stdout is untouched. It
232
+ // prints only for a person at a terminal, never for hook-run subcommands,
233
+ // `--json`, or output that is not a terminal: HQ core's hooks fail on any
234
+ // stderr.
235
+ if (!versionRequest)
236
+ writeLanesAliasDeprecationForArgv(process.argv);
228
237
  const helpRequest = !versionRequest && isCommandHelpRequest(process.argv);
229
238
  const parsedFastCore = versionRequest || helpRequest ? null : parseFastCore(process.argv);
230
239
  const monitorRequest = versionRequest || helpRequest ? null : parseMonitorCheckFastRequest(process.argv);
@@ -7,6 +7,6 @@ export interface MonitorCheckFastRequest {
7
7
  engine?: string;
8
8
  json: boolean;
9
9
  }
10
- /** Exactly `hq lanes monitor-check --session <id> [--engine <e>] [--json]`. */
10
+ /** Exactly `hq runners|lanes monitor-check --session <id> [--engine <e>] [--json]`. */
11
11
  export declare function parseMonitorCheckFastRequest(argv: readonly string[]): MonitorCheckFastRequest | null;
12
12
  //# sourceMappingURL=lanes-monitor-check-argv.d.ts.map
@@ -3,9 +3,9 @@
3
3
  * Imported statically by src/index.ts, so it must not import anything.
4
4
  */
5
5
  const SAFE_SESSION_ID = /^[A-Za-z0-9._:-]{1,200}$/u;
6
- /** Exactly `hq lanes monitor-check --session <id> [--engine <e>] [--json]`. */
6
+ /** Exactly `hq runners|lanes monitor-check --session <id> [--engine <e>] [--json]`. */
7
7
  export function parseMonitorCheckFastRequest(argv) {
8
- if (argv[2] !== "lanes" || argv[3] !== "monitor-check")
8
+ if ((argv[2] !== "runners" && argv[2] !== "lanes") || argv[3] !== "monitor-check")
9
9
  return null;
10
10
  let sessionId;
11
11
  let engine;
@@ -2,6 +2,9 @@
2
2
  * Dependency-free argv matcher for the `hq lanes session-start` fast route.
3
3
  * Imported statically by src/index.ts, so it must not import anything.
4
4
  */
5
- /** Exactly `hq lanes session-start` with no options (the SessionStart hook form). */
5
+ /**
6
+ * Exactly `hq runners session-start` or the deprecated `hq lanes session-start`
7
+ * alias, with no options (the SessionStart hook form).
8
+ */
6
9
  export declare function isLaneSessionStartFastRequest(argv: readonly string[]): boolean;
7
10
  //# sourceMappingURL=lanes-session-start-argv.d.ts.map