@indigoai-us/hq-cli 5.345.218 → 5.345.220

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 (138) hide show
  1. package/CHANGELOG.md +130 -0
  2. package/dist/command-catalog.generated.d.ts +94 -1
  3. package/dist/command-catalog.generated.js +114 -1
  4. package/dist/commands/agents.d.ts +22 -0
  5. package/dist/commands/agents.js +92 -1
  6. package/dist/commands/bot.d.ts +48 -0
  7. package/dist/commands/bot.js +108 -8
  8. package/dist/commands/cloud.d.ts +16 -0
  9. package/dist/commands/cloud.js +112 -102
  10. package/dist/commands/core-checkpoint-native.d.ts +13 -0
  11. package/dist/commands/core-checkpoint-native.js +167 -52
  12. package/dist/commands/core-hook-registration-plan.d.ts +8 -0
  13. package/dist/commands/core-hook-registration-plan.js +22 -0
  14. package/dist/commands/core.js +9 -0
  15. package/dist/commands/daemon.js +21 -2
  16. package/dist/commands/doctor.js +4 -0
  17. package/dist/commands/integrations.js +84 -3
  18. package/dist/commands/lanes-shared.d.ts +2 -0
  19. package/dist/commands/lanes-watch.js +28 -1
  20. package/dist/commands/lanes.d.ts +2 -0
  21. package/dist/commands/lanes.js +99 -9
  22. package/dist/commands/packs.js +23 -0
  23. package/dist/commands/pkg-update.d.ts +6 -0
  24. package/dist/commands/pkg-update.js +15 -7
  25. package/dist/commands/reindex.js +6 -0
  26. package/dist/commands/run.js +55 -45
  27. package/dist/commands/sources.js +3 -2
  28. package/dist/index.js +8 -0
  29. package/dist/lib/anywhere-person-setting.d.ts +2 -2
  30. package/dist/lib/anywhere-person-setting.js +2 -2
  31. package/dist/lib/bot/fleet-cron.js +5 -2
  32. package/dist/lib/bot/inflight.d.ts +9 -0
  33. package/dist/lib/bot/jobs/hot-signal-sync.d.ts +51 -0
  34. package/dist/lib/bot/jobs/hot-signal-sync.js +90 -9
  35. package/dist/lib/bot/run.d.ts +29 -5
  36. package/dist/lib/bot/run.js +203 -1
  37. package/dist/lib/bot/signals-try-now.d.ts +76 -0
  38. package/dist/lib/bot/signals-try-now.js +111 -0
  39. package/dist/lib/capacity/collectors/claude-oauth.d.ts +22 -3
  40. package/dist/lib/capacity/collectors/claude-oauth.js +78 -22
  41. package/dist/lib/capacity/scheduler.d.ts +8 -0
  42. package/dist/lib/capacity/scheduler.js +5 -2
  43. package/dist/lib/daemon/anywhere-listener.d.ts +33 -1
  44. package/dist/lib/daemon/anywhere-listener.js +86 -4
  45. package/dist/lib/daemon/machine-check-owner.d.ts +21 -0
  46. package/dist/lib/daemon/machine-check-owner.js +95 -0
  47. package/dist/lib/daemon/machine-check-registration.d.ts +4 -0
  48. package/dist/lib/daemon/machine-check-registration.js +64 -0
  49. package/dist/lib/daemon/machine-checks.d.ts +144 -0
  50. package/dist/lib/daemon/machine-checks.js +412 -0
  51. package/dist/lib/daemon/run.js +35 -4
  52. package/dist/lib/daemon/runtime-notifications.d.ts +7 -0
  53. package/dist/lib/daemon/runtime-notifications.js +50 -0
  54. package/dist/lib/daemon/server.d.ts +2 -0
  55. package/dist/lib/daemon/server.js +6 -0
  56. package/dist/lib/daemon/state-file.d.ts +12 -1
  57. package/dist/lib/daemon/state-file.js +23 -1
  58. package/dist/lib/doctor/checks/fleet-hook-core.d.ts +12 -0
  59. package/dist/lib/doctor/checks/fleet-hook-core.js +127 -0
  60. package/dist/lib/doctor/checks/host-core.js +3 -1
  61. package/dist/lib/doctor/checks/machine-checks.d.ts +16 -0
  62. package/dist/lib/doctor/checks/machine-checks.js +103 -0
  63. package/dist/lib/doctor/registry.js +4 -0
  64. package/dist/lib/doctor/types.d.ts +4 -0
  65. package/dist/lib/hook-engine/canary-gate.d.ts +64 -0
  66. package/dist/lib/hook-engine/canary-gate.js +147 -0
  67. package/dist/lib/hook-engine/coverage.d.ts +3 -1
  68. package/dist/lib/hook-engine/coverage.js +8 -2
  69. package/dist/lib/hook-engine/fleet-registration.d.ts +42 -0
  70. package/dist/lib/hook-engine/fleet-registration.js +168 -0
  71. package/dist/lib/hook-engine/reconcile.js +3 -2
  72. package/dist/lib/hook-engine/registration-identity.d.ts +33 -0
  73. package/dist/lib/hook-engine/registration-identity.js +97 -0
  74. package/dist/lib/hook-engine/registration.d.ts +1 -30
  75. package/dist/lib/hook-engine/registration.js +1 -88
  76. package/dist/lib/hook-engine/resolve.d.ts +2 -0
  77. package/dist/lib/hook-engine/resolve.js +7 -3
  78. package/dist/lib/hot-channels/alert.d.ts +10 -1
  79. package/dist/lib/hot-channels/alert.js +34 -7
  80. package/dist/lib/hot-channels/signals-claude-login.d.ts +53 -0
  81. package/dist/lib/hot-channels/signals-claude-login.js +96 -0
  82. package/dist/lib/hot-channels/signals-pass.d.ts +17 -0
  83. package/dist/lib/hot-channels/signals-pass.js +31 -3
  84. package/dist/lib/lanes/canonical-host.d.ts +8 -1
  85. package/dist/lib/lanes/canonical-host.js +9 -3
  86. package/dist/lib/lanes/machine-identity.d.ts +15 -0
  87. package/dist/lib/lanes/machine-identity.js +26 -0
  88. package/dist/lib/lanes/spawn.js +17 -3
  89. package/dist/lib/search-index/index.js +11 -1
  90. package/dist/lib/signals/engine.d.ts +1 -0
  91. package/dist/lib/signals/engine.js +7 -0
  92. package/dist/lib/signals/reply.d.ts +48 -0
  93. package/dist/lib/signals/reply.js +72 -11
  94. package/dist/lib/signals/steps/adapters.js +6 -0
  95. package/dist/lib/signals/steps/extract.d.ts +50 -3
  96. package/dist/lib/signals/steps/extract.js +100 -17
  97. package/dist/lib/signals/steps/types.d.ts +19 -0
  98. package/dist/lib/sync-core/engine-home.d.ts +6 -1
  99. package/dist/lib/sync-core/engine-home.js +13 -3
  100. package/dist/lib/sync-core/reconcile.js +1 -1
  101. package/dist/lib/sync-core/release-compare.d.ts +7 -0
  102. package/dist/lib/sync-core/release-compare.js +16 -0
  103. package/dist/lib/sync-core/release.d.ts +2 -1
  104. package/dist/lib/sync-core/release.js +2 -10
  105. package/dist/run/schema-env-overrides.d.ts +24 -0
  106. package/dist/run/schema-env-overrides.js +72 -0
  107. package/dist/utils/core-next-flag.d.ts +4 -0
  108. package/dist/utils/core-next-flag.js +22 -0
  109. package/dist/utils/core-next-kill.d.ts +16 -0
  110. package/dist/utils/core-next-kill.js +35 -0
  111. package/dist/utils/host-registration.d.ts +33 -23
  112. package/dist/utils/host-registration.js +90 -66
  113. package/package.json +14 -10
  114. package/scripts/check-function-manifest.mjs +5 -4
  115. package/dist/commands/__fixtures__/access-vault.d.ts +0 -95
  116. package/dist/commands/__fixtures__/access-vault.js +0 -166
  117. package/dist/commands/__fixtures__/make-tar.d.ts +0 -38
  118. package/dist/commands/__fixtures__/make-tar.js +0 -102
  119. package/dist/commands/secrets-public-types.test-d.d.ts +0 -2
  120. package/dist/commands/secrets-public-types.test-d.js +0 -18
  121. package/dist/lib/decisions/fixtures/us001.d.ts +0 -137
  122. package/dist/lib/decisions/fixtures/us001.js +0 -21
  123. package/dist/lib/doctor/__testing__/fake-hq-tree.d.ts +0 -226
  124. package/dist/lib/doctor/__testing__/fake-hq-tree.js +0 -408
  125. package/dist/lib/doctor/__testing__/run-doctor.d.ts +0 -8
  126. package/dist/lib/doctor/__testing__/run-doctor.js +0 -69
  127. package/dist/lib/fingerprint/fixtures.d.ts +0 -19
  128. package/dist/lib/fingerprint/fixtures.js +0 -61
  129. package/dist/lib/hot-channels/adapters/__fixtures__/dummy.d.ts +0 -33
  130. package/dist/lib/hot-channels/adapters/__fixtures__/dummy.js +0 -53
  131. package/dist/lib/hot-channels/adapters/__fixtures__/meeting-providers.d.ts +0 -38
  132. package/dist/lib/hot-channels/adapters/__fixtures__/meeting-providers.js +0 -64
  133. package/dist/lib/mesh/live/daemon/mqtt-events.test-d.d.ts +0 -2
  134. package/dist/lib/mesh/live/daemon/mqtt-events.test-d.js +0 -10
  135. package/dist/lib/test-utils/isolated-flag-company-context.d.ts +0 -3
  136. package/dist/lib/test-utils/isolated-flag-company-context.js +0 -18
  137. package/scripts/hook-engine-manifest.mjs +0 -22
  138. package/scripts/mesh-daemon-if-stale.mjs +0 -20
@@ -44,7 +44,7 @@ import { ensureSessionHome } from "./session-relink.js";
44
44
  import { emitDispatchAdvisory } from "../capacity/read.js";
45
45
  import { MESSAGE_REPLAY_STATE_NAME } from "./message-replay.js";
46
46
  import { markAnsweredQuestionsDelivered } from "./questions.js";
47
- import { hasEarlierEligibleQueuedLane, laneAdmissionCapReason, withLaneAdmissionLock, } from "./admission.js";
47
+ import { hasEarlierEligibleQueuedLane, laneAdmissionCapReason, laneRunsOnHost, withLaneAdmissionLock, } from "./admission.js";
48
48
  import { resolveAdmissionHost } from "./admission-host.js";
49
49
  import { offlineFingerprint } from "../fingerprint/offline.js";
50
50
  import { SESSION_ID_ENV_VARS } from "../fingerprint/self-core.js";
@@ -244,7 +244,7 @@ function spawnModelFailure(provider, accountId, config, pinnedModel, profileMode
244
244
  }
245
245
  }
246
246
  function selectSpawnAccount(input) {
247
- const { hqRoot, lane, config, existsSync, accountDeps, modelDeps, pinnedModel, profileModel, currentModelValidated, hostname, repairRecordedAccount, recordedModel, now } = input;
247
+ const { hqRoot, lane, config, existsSync, accountDeps, modelDeps, pinnedModel, profileModel, currentModelValidated, hostname, admissionHost, repairRecordedAccount, recordedModel, now } = input;
248
248
  const context = {
249
249
  hqRoot,
250
250
  existsSync,
@@ -356,11 +356,24 @@ function selectSpawnAccount(input) {
356
356
  (reason === "recorded_account_logged_out" ||
357
357
  (reason === "account_unavailable" && repairRecordedAccount && recordedModel !== undefined));
358
358
  if (recoverRecordedClaudeModel) {
359
+ // A local lane that admission runs on this machine shares its accounts
360
+ // with every other local lane admission runs here, whichever of the
361
+ // machine's ids each record carries. Without a resolved admission host,
362
+ // or for any other lane, only records with the same host id count.
363
+ const localMatch = lane.host.kind === "local" && admissionHost !== undefined && laneRunsOnHost(lane, { ...admissionHost, outpostId: null })
364
+ ? {
365
+ hostname: admissionHost.hostname,
366
+ ...(admissionHost.machineId !== undefined ? { machineId: admissionHost.machineId } : {}),
367
+ ...(admissionHost.aliases !== undefined ? { aliases: admissionHost.aliases } : {}),
368
+ }
369
+ : undefined;
359
370
  const lanes = listLaneIds(hqRoot)
360
371
  .map((laneId) => readLane(hqRoot, laneId))
361
- .filter((record) => record.host.kind === lane.host.kind && record.host.id === lane.host.id);
372
+ .filter((record) => (record.host.kind === lane.host.kind && record.host.id === lane.host.id) ||
373
+ (localMatch !== undefined && laneRunsOnHost(record, { ...localMatch, outpostId: null })));
362
374
  const capacity = buildHostCapacitySnapshot({
363
375
  host: lane.host,
376
+ ...(localMatch !== undefined ? { localMatch } : {}),
364
377
  lanes,
365
378
  config,
366
379
  existsSync,
@@ -2504,6 +2517,7 @@ export function spawnLaneWorker(hqRoot, lane, deps = {}, launch = {}) {
2504
2517
  profileModel,
2505
2518
  currentModelValidated: deps.currentModelValidated === true,
2506
2519
  hostname,
2520
+ ...(deps.admissionHost !== undefined ? { admissionHost: deps.admissionHost } : {}),
2507
2521
  repairRecordedAccount,
2508
2522
  ...(recordedModel !== undefined ? { recordedModel } : {}),
2509
2523
  now: (deps.now ?? (() => new Date()))(),
@@ -567,6 +567,10 @@ function invocationBin(invocation) {
567
567
  function invocationKey(invocation) {
568
568
  return [invocation.command, ...invocation.prefixArgs].join('');
569
569
  }
570
+ /** Output cap for captured qmd stdout/stderr. Node's spawnSync default is 1 MiB,
571
+ * which overflowed as ENOBUFS on a ~189k-document index (`hq index status` /
572
+ * `hq index sync`, feedback_48c6252c). */
573
+ const QMD_SPAWN_MAX_BUFFER = 64 * 1024 * 1024;
570
574
  /** Default low-level spawn: `spawnSync` with captured utf8 output. */
571
575
  const defaultSpawn = (cmd, args, options) => {
572
576
  const result = spawnSync(cmd, args, {
@@ -576,6 +580,7 @@ const defaultSpawn = (cmd, args, options) => {
576
580
  timeout: options.timeout,
577
581
  killSignal: options.killSignal,
578
582
  shell: options.shell,
583
+ maxBuffer: QMD_SPAWN_MAX_BUFFER,
579
584
  });
580
585
  return {
581
586
  status: result.status,
@@ -1096,7 +1101,12 @@ function finishRunQmd(result, bin, args, attribution) {
1096
1101
  commandExists === false) {
1097
1102
  throw new QmdBinaryMissingError(`Unable to execute qmd: its Node interpreter (${attribution.command}) could not be executed: ${normalized.error.message}`, diagnostics);
1098
1103
  }
1099
- // (c) RESIDUAL: an ENOENT the fix cannot attribute (a genuinely missing
1104
+ // (c) OUTPUT BUFFER. spawnSync raises ENOBUFS when captured stdout/stderr
1105
+ // exceeds maxBuffer. That is not a missing qmd binary — the process ran.
1106
+ if (errnoCode === 'ENOBUFS') {
1107
+ throw new QmdBinaryMissingError(`qmd produced more output than hq index can buffer (${QMD_SPAWN_MAX_BUFFER} bytes, ENOBUFS). The search index is large; this is not a missing qmd binary.`, diagnostics);
1108
+ }
1109
+ // (d) RESIDUAL: an ENOENT the fix cannot attribute (a genuinely missing
1100
1110
  // qmd, or a race where the directory/interpreter reappeared) or any other
1101
1111
  // spawn errno (EACCES/EINVAL/…). Keep today's class and message byte-for-
1102
1112
  // byte, and attach the bounded diagnostics so the next occurrence carries
@@ -30,6 +30,7 @@ export interface StepRecord {
30
30
  itemsInByAdapter?: Record<string, number>;
31
31
  tokenLevels?: Record<string, string>;
32
32
  adapterSkips?: Record<string, string>;
33
+ adapterOutcomes?: Record<string, string>;
33
34
  uploaded?: {
34
35
  count: number;
35
36
  bytes: number;
@@ -441,6 +441,13 @@ export async function runSignals(opts) {
441
441
  ...(opts.isFlagOn ? { isFlagOn: opts.isFlagOn } : {}),
442
442
  ...(opts.registeredAdapterIds ? { registeredAdapterIds: opts.registeredAdapterIds } : {}),
443
443
  ...(redo.length > 0 ? { redo } : {}),
444
+ priorSteps: record.steps.map((s) => ({
445
+ name: s.name,
446
+ status: s.status,
447
+ ...(s.skippedReason !== undefined ? { skippedReason: s.skippedReason } : {}),
448
+ ...(s.adapterSkips ? { adapterSkips: { ...s.adapterSkips } } : {}),
449
+ ...(s.adapterOutcomes ? { adapterOutcomes: { ...s.adapterOutcomes } } : {}),
450
+ })),
444
451
  };
445
452
  let stepRec;
446
453
  const planner = stepImpls[name].dryRun;
@@ -69,7 +69,55 @@ export interface RunReplyOptions {
69
69
  retryScheduled?: boolean;
70
70
  /** This run was the automatic retry; a failure says no further retry follows. */
71
71
  wasRetry?: boolean;
72
+ /**
73
+ * The reply goes to the HQ desktop app (a local bot's owner DM), which opens
74
+ * `hq-desktop://brief` in place (hot-signal-sync US-023). The reply then
75
+ * links to today's brief instead of offering the "Create today's brief"
76
+ * decision. Unset (Fleet DMs, Slack, the terminal) keeps the decision and
77
+ * never writes an hq-desktop:// link.
78
+ */
79
+ desktopLinks?: boolean;
80
+ /**
81
+ * This bot has a scheduled brief job (a jobs.json entry that runs
82
+ * /daily-brief on a schedule). hq-cli never starts the brief itself, so only
83
+ * then does a desktop reply say the brief builds next; otherwise it says to
84
+ * open the page to create it.
85
+ */
86
+ briefJobScheduled?: boolean;
72
87
  }
88
+ /** The in-app deep link the desktop app opens as the Daily Brief page (US-023). */
89
+ export declare const BRIEF_DEEP_LINK = "hq-desktop://brief";
90
+ /**
91
+ * The brief link line for desktop replies when a brief job is scheduled. The
92
+ * words after the link are the plain-text fallback for a client that shows
93
+ * the label without opening it.
94
+ */
95
+ export declare const OPEN_BRIEF_LINK_LINE = "[Open today's brief](hq-desktop://brief), or find it on the Daily Brief page.";
96
+ /** The same line when no brief job is scheduled: the member creates the brief on that page. */
97
+ export declare const CREATE_BRIEF_LINK_LINE = "[Open today's brief](hq-desktop://brief) to create it, or find it on the Daily Brief page.";
98
+ /** Said before the link on a finished run, only when a brief job is scheduled. */
99
+ export declare const BRIEF_BUILDS_NEXT_LINE = "Your brief builds next.";
100
+ /** The retry decision's option id, and its label (the text a click sends back). */
101
+ export declare const TRY_NOW_OPTION_ID = "try-now";
102
+ export declare const TRY_NOW_LABEL = "Try now";
103
+ /**
104
+ * What a failed run means for today's brief, true on every channel: a failed
105
+ * signals run never blocks the Daily Brief. It does not promise that a brief
106
+ * runs (hq-cli never starts one, and many bots have no brief job), nor the
107
+ * brief's stale-signals notice (hq-core #1987, only in v16.0.48 betas so far).
108
+ */
109
+ export declare const FAILED_RUN_BRIEF_LINE = "This does not stop your brief from building.";
110
+ /** The same for a finished-with-problems run, whose new signals the brief can use. */
111
+ export declare const PARTIAL_RUN_BRIEF_LINE = "This does not stop your brief from building with what came in.";
112
+ /** The open-brief decision's question when no brief job is known to be scheduled. */
113
+ export declare const CREATE_BRIEF_QUESTION = "Create today's brief now?";
114
+ /** The line a finished-with-problems reply ends with. */
115
+ export declare const SAY_TRY_NOW_LINE = "Say \"Try now\" to run signals again.";
116
+ /**
117
+ * True when the reply asks the member for "Try now": a decision with the
118
+ * try-now option (run failed), or the finished-with-problems line.
119
+ */
120
+ export declare function replyOffersTryNow(reply: Pick<FormattedReply, "blocks">): boolean;
73
121
  /** One fence, JSON on one line, not indented. */
74
122
  export declare function hqBlockFence(blocks: ReplyBlock[]): string;
75
123
  /** "6:02 AM" in the given zone. */
@@ -10,6 +10,46 @@
10
10
  export const REPLY_BLOCK_KINDS = ["keyValue", "callout", "badge", "progress", "decision"];
11
11
  export const REPLY_TONES = ["neutral", "info", "success", "warning", "danger"];
12
12
  export const REPLY_ICONS = ["check", "clock", "folder", "calendar"];
13
+ /** The in-app deep link the desktop app opens as the Daily Brief page (US-023). */
14
+ export const BRIEF_DEEP_LINK = "hq-desktop://brief";
15
+ /**
16
+ * The brief link line for desktop replies when a brief job is scheduled. The
17
+ * words after the link are the plain-text fallback for a client that shows
18
+ * the label without opening it.
19
+ */
20
+ export const OPEN_BRIEF_LINK_LINE = `[Open today's brief](${BRIEF_DEEP_LINK}), or find it on the Daily Brief page.`;
21
+ /** The same line when no brief job is scheduled: the member creates the brief on that page. */
22
+ export const CREATE_BRIEF_LINK_LINE = `[Open today's brief](${BRIEF_DEEP_LINK}) to create it, or find it on the Daily Brief page.`;
23
+ /** Said before the link on a finished run, only when a brief job is scheduled. */
24
+ export const BRIEF_BUILDS_NEXT_LINE = "Your brief builds next.";
25
+ function briefLinkLine(opts) {
26
+ return opts.briefJobScheduled ? OPEN_BRIEF_LINK_LINE : CREATE_BRIEF_LINK_LINE;
27
+ }
28
+ /** The retry decision's option id, and its label (the text a click sends back). */
29
+ export const TRY_NOW_OPTION_ID = "try-now";
30
+ export const TRY_NOW_LABEL = "Try now";
31
+ /**
32
+ * What a failed run means for today's brief, true on every channel: a failed
33
+ * signals run never blocks the Daily Brief. It does not promise that a brief
34
+ * runs (hq-cli never starts one, and many bots have no brief job), nor the
35
+ * brief's stale-signals notice (hq-core #1987, only in v16.0.48 betas so far).
36
+ */
37
+ export const FAILED_RUN_BRIEF_LINE = "This does not stop your brief from building.";
38
+ /** The same for a finished-with-problems run, whose new signals the brief can use. */
39
+ export const PARTIAL_RUN_BRIEF_LINE = "This does not stop your brief from building with what came in.";
40
+ /** The open-brief decision's question when no brief job is known to be scheduled. */
41
+ export const CREATE_BRIEF_QUESTION = "Create today's brief now?";
42
+ /** The line a finished-with-problems reply ends with. */
43
+ export const SAY_TRY_NOW_LINE = `Say "${TRY_NOW_LABEL}" to run signals again.`;
44
+ /**
45
+ * True when the reply asks the member for "Try now": a decision with the
46
+ * try-now option (run failed), or the finished-with-problems line.
47
+ */
48
+ export function replyOffersTryNow(reply) {
49
+ return reply.blocks.some((block) => block.kind === "decision"
50
+ ? block.options.some((option) => option.id === TRY_NOW_OPTION_ID)
51
+ : block.kind === "callout" && block.body.includes(SAY_TRY_NOW_LINE));
52
+ }
13
53
  /** One fence, JSON on one line, not indented. */
14
54
  export function hqBlockFence(blocks) {
15
55
  return "```hq-block\n" + JSON.stringify({ v: 1, blocks }) + "\n```";
@@ -136,15 +176,31 @@ function spendBlock(record) {
136
176
  tone: "neutral",
137
177
  };
138
178
  }
139
- function openBriefDecision(date) {
179
+ /**
180
+ * The non-desktop brief decision. It says the brief builds next only when a
181
+ * brief job is known to be scheduled; otherwise it asks.
182
+ */
183
+ function openBriefDecision(date, opts) {
140
184
  return {
141
185
  kind: "decision",
142
186
  questionId: `signals-run-${date}-open-brief`,
143
- question: "Your brief builds next.",
187
+ question: opts.briefJobScheduled ? BRIEF_BUILDS_NEXT_LINE : CREATE_BRIEF_QUESTION,
144
188
  options: [{ id: "open-brief", label: "Create today's brief", recommended: true }],
145
189
  allowOther: false,
146
190
  };
147
191
  }
192
+ /**
193
+ * How a finished run points at today's brief. Desktop: a second prose
194
+ * paragraph with the deep link and no decision; with `buildsNext` and a
195
+ * scheduled brief job it starts "Your brief builds next.". Elsewhere: the
196
+ * prose as it is and the "Create today's brief" decision.
197
+ */
198
+ function briefPointer(prose, date, opts, buildsNext) {
199
+ if (!opts.desktopLinks)
200
+ return { prose, blocks: [openBriefDecision(date, opts)] };
201
+ const lead = buildsNext && opts.briefJobScheduled ? `${BRIEF_BUILDS_NEXT_LINE} ` : "";
202
+ return { prose: `${prose}\n\n${lead}${briefLinkLine(opts)}`, blocks: [] };
203
+ }
148
204
  /** "a, b and c". */
149
205
  function listInWords(parts) {
150
206
  if (parts.length <= 1)
@@ -282,7 +338,7 @@ export function formatRunReply(record, summary, opts) {
282
338
  : record.failureReason
283
339
  ? oneSentence(record.failureReason)
284
340
  : `Signals for ${company} failed.`;
285
- const brief = "Your brief is not built until signals finish, so you never read a brief without fresh signals.";
341
+ const brief = FAILED_RUN_BRIEF_LINE;
286
342
  const retryLine = retry
287
343
  ? `I try again at ${retry}.`
288
344
  : opts.wasRetry
@@ -314,7 +370,7 @@ export function formatRunReply(record, summary, opts) {
314
370
  questionId: `signals-run-${summary.date}-retry`,
315
371
  question: "Try again now, or wait for the retry?",
316
372
  options: [
317
- { id: "try-now", label: "Try now", recommended: true },
373
+ { id: TRY_NOW_OPTION_ID, label: TRY_NOW_LABEL, recommended: true },
318
374
  { id: "wait", label: `Wait for ${retry}` },
319
375
  ],
320
376
  allowOther: false,
@@ -323,10 +379,12 @@ export function formatRunReply(record, summary, opts) {
323
379
  kind: "decision",
324
380
  questionId: `signals-run-${summary.date}-retry`,
325
381
  question: "Try again now?",
326
- options: [{ id: "try-now", label: "Try now", recommended: true }],
382
+ options: [{ id: TRY_NOW_OPTION_ID, label: TRY_NOW_LABEL, recommended: true }],
327
383
  allowOther: false,
328
384
  });
329
- return build(`${job} stopped at ${finished}.`, blocks, "failed");
385
+ // The Try now decision stays; on desktop the prose also links today's brief.
386
+ const stoppedProse = `${job} stopped at ${finished}.`;
387
+ return build(opts.desktopLinks ? `${stoppedProse}\n\n${briefLinkLine(opts)}` : stoppedProse, blocks, "failed");
330
388
  }
331
389
  const counts = runCountItems(record, summary, opts);
332
390
  const spend = spendBlock(record);
@@ -358,22 +416,25 @@ export function formatRunReply(record, summary, opts) {
358
416
  ? partialReasonInWords(partialReason)
359
417
  : null;
360
418
  const guidance = failureGuidance(record, failedStep, company);
361
- const body = [guidance.main, ...(guidance.note ? [guidance.note] : []), 'Your brief builds with what came in. Say "Try now" to run signals again.'].join(" ");
362
- return build(`${job} finished with problems at ${finished}.`, [
419
+ const body = [guidance.main, ...(guidance.note ? [guidance.note] : []), `${PARTIAL_RUN_BRIEF_LINE} ${SAY_TRY_NOW_LINE}`].join(" ");
420
+ const brief = briefPointer(`${job} finished with problems at ${finished}.`, summary.date, opts, false);
421
+ return build(brief.prose, [
363
422
  { kind: "badge", label: "Finished with problems", tone: "warning" },
364
423
  ...(record.catchUp ? [catchUpBadge] : []),
365
424
  title ? { kind: "callout", tone: "warning", title, body } : { kind: "callout", tone: "warning", body },
366
425
  ...tail,
367
- openBriefDecision(summary.date),
426
+ ...brief.blocks,
368
427
  ], "partial");
369
428
  }
370
429
  if (record.catchUp) {
371
430
  const prose = due
372
431
  ? `${job} finished at ${finished} instead of ${due}. Your Mac was asleep at ${due}, so I ran it when it woke.`
373
432
  : `${job} finished at ${finished}, later than scheduled. Your Mac was asleep, so I ran it when it woke.`;
374
- return build(prose, [catchUpBadge, ...tail, openBriefDecision(summary.date)], "catch-up");
433
+ const brief = briefPointer(prose, summary.date, opts, true);
434
+ return build(brief.prose, [catchUpBadge, ...tail, ...brief.blocks], "catch-up");
375
435
  }
376
- return build(`${job} finished at ${finished}.`, [{ kind: "badge", label: "Complete", tone: "success", icon: "check" }, ...tail, openBriefDecision(summary.date)], "complete");
436
+ const brief = briefPointer(`${job} finished at ${finished}.`, summary.date, opts, true);
437
+ return build(brief.prose, [{ kind: "badge", label: "Complete", tone: "success", icon: "check" }, ...tail, ...brief.blocks], "complete");
377
438
  }
378
439
  /** Another run holds the company's lock (engine exit 3): nothing was started. */
379
440
  export function formatLockedReply(locked, opts) {
@@ -31,6 +31,7 @@ export function mapSyncReport(report) {
31
31
  const byAdapter = {};
32
32
  const itemsInByAdapter = {};
33
33
  const tokenLevels = {};
34
+ const adapterOutcomes = {};
34
35
  let itemsIn = 0;
35
36
  let itemsOut = 0;
36
37
  let ok = 0;
@@ -44,6 +45,9 @@ export function mapSyncReport(report) {
44
45
  if (o.tokenLevel && TOKEN_LEVEL_ADAPTERS.has(o.adapter) && tokenLevels[o.adapter] !== "workspace") {
45
46
  tokenLevels[o.adapter] = o.tokenLevel;
46
47
  }
48
+ const seen = adapterOutcomes[o.adapter];
49
+ if (seen === undefined || o.status === "failed" || (o.status === "ok" && seen !== "failed"))
50
+ adapterOutcomes[o.adapter] = o.status;
47
51
  itemsIn += o.landed + o.duplicates;
48
52
  itemsOut += o.landed;
49
53
  if (o.status === "ok")
@@ -58,6 +62,8 @@ export function mapSyncReport(report) {
58
62
  result.itemsInByAdapter = itemsInByAdapter;
59
63
  if (Object.keys(tokenLevels).length > 0)
60
64
  result.tokenLevels = tokenLevels;
65
+ if (Object.keys(adapterOutcomes).length > 0)
66
+ result.adapterOutcomes = adapterOutcomes;
61
67
  if (report.outcomes.length === 0) {
62
68
  result.status = "skipped";
63
69
  result.skippedReason = "no-channels";
@@ -1,6 +1,6 @@
1
1
  import { type StoredPriorSignal } from "../prior-signals.js";
2
2
  import { type BotRuntimeId } from "../../bot/config.js";
3
- import type { SignalsStep, SpawnSyncFn, StepContext, StepResult } from "./types.js";
3
+ import type { PriorStep, SignalsStep, SpawnSyncFn, StepContext, StepResult } from "./types.js";
4
4
  export declare const EXTRACT_SIGNAL_TYPES: readonly ["action_item", "commitment", "decision", "risk", "question", "key_point", "participant_contribution", "summary"];
5
5
  export declare const DEFAULT_WORKLIST_LIMIT = 20;
6
6
  export declare const DEFAULT_TURN_TIMEOUT_MS: number;
@@ -75,8 +75,55 @@ export declare function defaultResolveBotRuntime(root?: string): BotRuntimeId |
75
75
  * or null when it is not in that form.
76
76
  */
77
77
  export declare function redoItemChannel(item: string): string | null;
78
- /** Declared source channels with run: local (or any run: when forced). */
79
- export declare function listSourceChannels(hqRoot: string, company: string, force?: boolean): SourceChannel[];
78
+ /**
79
+ * The batch channel that holds meeting transcripts. The meetings hot channel
80
+ * (adapters/meetings.ts) reads the same folder in the adapters step and
81
+ * extracts each transcript the signed-in person attended as `meeting:<id>`.
82
+ */
83
+ export declare const MEETINGS_BATCH_CHANNEL: string;
84
+ /** What the meetings hot channel covers when it runs (adapters/meetings.ts, MAX_CATCH_UP_WINDOW_MS). */
85
+ export declare const MEETINGS_HOT_CHANNEL_COVERAGE = "attended-last-30d";
86
+ /** A channel folder the step does not run, and why. */
87
+ export interface SkippedSourceChannel {
88
+ channel: string;
89
+ /**
90
+ * covered-by-hot-channel: the meetings folder has no source.yaml and the
91
+ * meetings hot channel ran ok in this run's adapters step. It extracts only
92
+ * the meetings the signed-in person attended, from the last 30 days.
93
+ * no-source-yaml: a folder with no source.yaml that nothing extracted this
94
+ * run (for meetings, `hotChannel` says why the hot channel did not run).
95
+ * source-yaml-invalid: run is neither local nor cloud.
96
+ * run-cloud: run: cloud without --force.
97
+ */
98
+ reason: "covered-by-hot-channel" | "no-source-yaml" | "source-yaml-invalid" | "run-cloud";
99
+ error?: string;
100
+ /** Meetings only: `not-run:<why>` when the hot channel did not cover this run. */
101
+ hotChannel?: string;
102
+ /** With covered-by-hot-channel: what the hot channel takes. */
103
+ coverage?: string;
104
+ }
105
+ /**
106
+ * Whether the meetings hot channel ran ok in this run, from the adapters step
107
+ * record: null when it did, else `not-run:<why>`.
108
+ */
109
+ export declare function meetingsHotChannelGap(priorSteps: readonly PriorStep[] | undefined): string | null;
110
+ export interface SourceChannelListing {
111
+ channels: SourceChannel[];
112
+ skipped: SkippedSourceChannel[];
113
+ /** Channels whose source.yaml exists but could not be read: a config failure, not a skip. */
114
+ unreadable: {
115
+ channel: string;
116
+ error: string;
117
+ }[];
118
+ }
119
+ /**
120
+ * Declared source channels with run: local (or any run: when forced), and the
121
+ * folders the step does not run with the reason for each. A folder with no
122
+ * source.yaml is never given one: for the meetings folder the hot channel is
123
+ * the extraction path, and the batch path would key the same transcript a
124
+ * second way (`meetings:<file>`).
125
+ */
126
+ export declare function listSourceChannels(hqRoot: string, company: string, force?: boolean, priorSteps?: readonly PriorStep[]): SourceChannelListing;
80
127
  /** Shell single-quote a value so a generated script carries it as data. */
81
128
  export declare function shellQuote(value: string): string;
82
129
  /**
@@ -111,6 +111,7 @@ import yaml from "js-yaml";
111
111
  import { findPriorSignals, normalizeSignalTitle, priorSignalPath } from "../prior-signals.js";
112
112
  import { splitFrontmatter } from "../../hot-channels/signals-pass.js";
113
113
  import { audienceKey } from "../../hot-channels/audience.js";
114
+ import { MEETINGS_ADAPTER_ID, MEETINGS_TRANSCRIPT_DIR } from "../../hot-channels/adapters/meetings.js";
114
115
  import { isBotRuntimeId } from "../../bot/config.js";
115
116
  import { resolveExecutiveBot } from "../../bot/executive.js";
116
117
  import { botsRoot } from "../../bot/paths.js";
@@ -217,25 +218,91 @@ export function redoItemChannel(item) {
217
218
  const m = REDO_ITEM_RE.exec(item);
218
219
  return m && !m[2].includes("\0") ? m[1] : null;
219
220
  }
220
- /** Declared source channels with run: local (or any run: when forced). */
221
- export function listSourceChannels(hqRoot, company, force = false) {
221
+ /**
222
+ * The batch channel that holds meeting transcripts. The meetings hot channel
223
+ * (adapters/meetings.ts) reads the same folder in the adapters step and
224
+ * extracts each transcript the signed-in person attended as `meeting:<id>`.
225
+ */
226
+ export const MEETINGS_BATCH_CHANNEL = path.posix.basename(MEETINGS_TRANSCRIPT_DIR);
227
+ /** What the meetings hot channel covers when it runs (adapters/meetings.ts, MAX_CATCH_UP_WINDOW_MS). */
228
+ export const MEETINGS_HOT_CHANNEL_COVERAGE = "attended-last-30d";
229
+ /**
230
+ * Whether the meetings hot channel ran ok in this run, from the adapters step
231
+ * record: null when it did, else `not-run:<why>`.
232
+ */
233
+ export function meetingsHotChannelGap(priorSteps) {
234
+ const adapters = [...(priorSteps ?? [])].reverse().find((s) => s.name === "adapters");
235
+ if (!adapters)
236
+ return "not-run:adapters-step-not-in-plan";
237
+ const skip = adapters.adapterSkips?.[MEETINGS_ADAPTER_ID];
238
+ if (skip)
239
+ return `not-run:${skip}`;
240
+ if (adapters.status === "skipped")
241
+ return `not-run:${adapters.skippedReason ?? "adapters-skipped"}`;
242
+ const outcome = adapters.adapterOutcomes?.[MEETINGS_ADAPTER_ID];
243
+ if (outcome === "ok")
244
+ return null;
245
+ if (outcome !== undefined)
246
+ return `not-run:meetings-${outcome}`;
247
+ if (adapters.status === "failed")
248
+ return "not-run:adapters-failed";
249
+ return "not-run:meetings-not-in-sync";
250
+ }
251
+ /**
252
+ * Declared source channels with run: local (or any run: when forced), and the
253
+ * folders the step does not run with the reason for each. A folder with no
254
+ * source.yaml is never given one: for the meetings folder the hot channel is
255
+ * the extraction path, and the batch path would key the same transcript a
256
+ * second way (`meetings:<file>`).
257
+ */
258
+ export function listSourceChannels(hqRoot, company, force = false, priorSteps) {
222
259
  const dir = path.join(hqRoot, "companies", company, "sources");
260
+ const listing = { channels: [], skipped: [], unreadable: [] };
223
261
  if (!fs.existsSync(dir))
224
- return [];
225
- const out = [];
262
+ return listing;
226
263
  for (const e of fs.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
227
264
  if (!e.isDirectory())
228
265
  continue;
229
266
  const y = path.join(dir, e.name, "source.yaml");
230
- if (!fs.existsSync(y))
267
+ const missing = () => {
268
+ if (e.name !== MEETINGS_BATCH_CHANNEL) {
269
+ listing.skipped.push({ channel: e.name, reason: "no-source-yaml" });
270
+ return;
271
+ }
272
+ const gap = meetingsHotChannelGap(priorSteps);
273
+ listing.skipped.push(gap === null
274
+ ? { channel: e.name, reason: "covered-by-hot-channel", coverage: MEETINGS_HOT_CHANNEL_COVERAGE }
275
+ : { channel: e.name, reason: "no-source-yaml", hotChannel: gap });
276
+ };
277
+ if (!fs.existsSync(y)) {
278
+ missing();
279
+ continue;
280
+ }
281
+ let text;
282
+ try {
283
+ text = fs.readFileSync(y, "utf8");
284
+ }
285
+ catch (err) {
286
+ // Removed between the check and the read: the same as no file.
287
+ if (err.code === "ENOENT") {
288
+ missing();
289
+ continue;
290
+ }
291
+ listing.unreadable.push({ channel: e.name, error: err.message.slice(0, 200) });
231
292
  continue;
232
- const run = yamlField(fs.readFileSync(y, "utf8"), "run");
293
+ }
294
+ const run = yamlField(text, "run");
233
295
  if (run === "local")
234
- out.push({ channel: e.name, force: false });
296
+ listing.channels.push({ channel: e.name, force: false });
297
+ // As before: a forced run hands every other channel to the worklist, which validates it.
235
298
  else if (force)
236
- out.push({ channel: e.name, force: true });
299
+ listing.channels.push({ channel: e.name, force: true });
300
+ else if (run === "cloud")
301
+ listing.skipped.push({ channel: e.name, reason: "run-cloud" });
302
+ else
303
+ listing.skipped.push({ channel: e.name, reason: "source-yaml-invalid", error: `run must be local or cloud (got '${run || "<missing>"}')` });
237
304
  }
238
- return out;
305
+ return listing;
239
306
  }
240
307
  /** Shell single-quote a value so a generated script carries it as data. */
241
308
  export function shellQuote(value) {
@@ -1218,11 +1285,22 @@ export function createExtractStep(options = {}) {
1218
1285
  return extractPartialDocument(ctx, options.documentOverride, options.priorSignals ?? []);
1219
1286
  }
1220
1287
  const empty = { modelTurns: 0, estimatedSpendUsd: 0 };
1221
- const channels = listSourceChannels(ctx.hqRoot, ctx.company, options.force === true);
1288
+ const listing = listSourceChannels(ctx.hqRoot, ctx.company, options.force === true, ctx.priorSteps);
1289
+ const channels = listing.channels;
1290
+ // Folders this step does not run, with the reason for each, kept in the run record.
1291
+ const listingDetail = listing.skipped.length ? { skippedChannels: listing.skipped } : {};
1292
+ // A source.yaml that exists but cannot be read is a config failure the alert can see.
1293
+ const unreadable = listing.unreadable.map((u) => ({
1294
+ file: `sources/${u.channel}/source.yaml`,
1295
+ error: `source.yaml could not be read: ${u.error}`,
1296
+ }));
1222
1297
  // A --redo item whose channel this step does not run cannot be re-queued here.
1223
1298
  const unrunRedo = (ctx.redo ?? []).filter((f) => !channels.some((c) => c.channel === redoItemChannel(f)));
1224
1299
  if (channels.length === 0 && unrunRedo.length === 0) {
1225
- return { status: "skipped", itemsIn: 0, itemsOut: 0, skippedReason: "no-sources", ...empty };
1300
+ if (unreadable.length > 0) {
1301
+ return { status: "failed", itemsIn: 0, itemsOut: 0, error: unreadable[0].error, errorKind: "config", failures: unreadable, ...empty, detail: { ...listingDetail } };
1302
+ }
1303
+ return { status: "skipped", itemsIn: 0, itemsOut: 0, skippedReason: "no-sources", ...empty, ...(listing.skipped.length ? { detail: { ...listingDetail } } : {}) };
1226
1304
  }
1227
1305
  const turnOpts = {
1228
1306
  claudeBin: options.claudeBin ?? "claude",
@@ -1281,11 +1359,16 @@ export function createExtractStep(options = {}) {
1281
1359
  let uncitedCandidates = 0;
1282
1360
  const uncitedSources = [];
1283
1361
  let errorKind;
1284
- const failures = unrunRedo.map((file) => ({
1285
- file,
1286
- error: "redo: not a source channel this run processes (needs a source.yaml with run: local, or --force for run: cloud)",
1287
- }));
1288
- if (unrunRedo.length > 0)
1362
+ const failures = [
1363
+ ...unreadable,
1364
+ ...unrunRedo.map((file) => ({
1365
+ file,
1366
+ error: "redo: not a source channel this run processes (needs a source.yaml with run: local, or --force for run: cloud)",
1367
+ })),
1368
+ ];
1369
+ if (unreadable.length > 0)
1370
+ errorKind = "config";
1371
+ else if (unrunRedo.length > 0)
1289
1372
  errorKind = "other";
1290
1373
  const skippedItems = [];
1291
1374
  const sourcesReal = fs.realpathSync(path.join(ctx.hqRoot, "companies", ctx.company, "sources"));
@@ -1499,7 +1582,7 @@ export function createExtractStep(options = {}) {
1499
1582
  ...(failures.length ? { failures } : {}),
1500
1583
  ...(skippedItems.length ? { skippedItems } : {}),
1501
1584
  ...(rejected ? { rejectedCandidates: rejected } : {}),
1502
- detail: { new: itemsOut, updated, skipped, runtime, ...(choice.fallback ? { fallback: choice.fallback } : {}), ...(budgetStoppedAt ? { budgetStoppedAt } : {}), ...(uncitedCandidates ? { uncitedCandidates, uncitedSources } : {}) },
1585
+ detail: { new: itemsOut, updated, skipped, runtime, ...(choice.fallback ? { fallback: choice.fallback } : {}), ...(budgetStoppedAt ? { budgetStoppedAt } : {}), ...(uncitedCandidates ? { uncitedCandidates, uncitedSources } : {}), ...listingDetail },
1503
1586
  };
1504
1587
  if (budgetStop) {
1505
1588
  result.status = "partial";
@@ -62,6 +62,19 @@ export interface StepContext {
62
62
  * with the worklist's `--redo` before it lists that channel.
63
63
  */
64
64
  redo?: readonly string[];
65
+ /**
66
+ * The steps this run already finished, in order. Extract reads the adapters
67
+ * step to tell whether the meetings hot channel ran.
68
+ */
69
+ priorSteps?: readonly PriorStep[];
70
+ }
71
+ /** What a later step may read of an earlier step in the same run. */
72
+ export interface PriorStep {
73
+ name: StepName;
74
+ status: StepStatus;
75
+ skippedReason?: string;
76
+ adapterSkips?: Record<string, string>;
77
+ adapterOutcomes?: Record<string, string>;
65
78
  }
66
79
  export interface StepResult {
67
80
  status: StepStatus;
@@ -78,6 +91,12 @@ export interface StepResult {
78
91
  tokenLevels?: Record<string, string>;
79
92
  /** Adapter id -> reason it did not run (`flag-off`). */
80
93
  adapterSkips?: Record<string, string>;
94
+ /**
95
+ * Adapter id -> how its sync ended this run (`ok`, `failed`, `unavailable`,
96
+ * `no-connection`, `gated`). An adapter with several connections is `failed`
97
+ * when any failed, else `ok` when any was ok.
98
+ */
99
+ adapterOutcomes?: Record<string, string>;
81
100
  uploaded?: {
82
101
  count: number;
83
102
  bytes: number;
@@ -14,10 +14,13 @@ export interface SyncCoreVaultPlan extends SyncCoreVault {
14
14
  blockedReason?: string;
15
15
  }
16
16
  export declare const SYNC_CORE_REQUESTS_PER_DAY = 20000;
17
+ export declare const SYNC_CORE_REQUEST_COUNT_REMOVED_IN = "v0.1.29";
17
18
  export declare function syncCoreEngineHome(home: string, vaultUid: string): string;
18
19
  export declare function syncCoreUnitId(vaultUid: string): string;
19
20
  export declare function isSyncCoreVaultUid(value: unknown): value is string;
20
- export declare function engineConfigToml(vault: SyncCoreVault, hqRoot: string, phase: SyncCoreVaultPhase, tokenPath?: string): string;
21
+ export declare function engineConfigToml(vault: SyncCoreVault, hqRoot: string, phase: SyncCoreVaultPhase, tokenPath?: string,
22
+ /** The engine release this vault runs. Not given: treated as an engine that still counts requests. */
23
+ release?: string): string;
21
24
  export interface WriteEngineHomeOptions {
22
25
  home: string;
23
26
  hqRoot: string;
@@ -25,6 +28,8 @@ export interface WriteEngineHomeOptions {
25
28
  phase: SyncCoreVaultPhase;
26
29
  tokenFile: string;
27
30
  platform?: NodeJS.Platform;
31
+ /** The engine release this vault runs; decides whether the config carries `requests_per_day`. */
32
+ release?: string;
28
33
  }
29
34
  export declare function writeEngineHome(opts: WriteEngineHomeOptions): {
30
35
  engineHome: string;