@indigoai-us/hq-cli 5.345.219 → 5.345.221

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 (199) hide show
  1. package/CHANGELOG.md +170 -0
  2. package/dist/command-catalog.generated.d.ts +169 -3
  3. package/dist/command-catalog.generated.js +206 -3
  4. package/dist/commands/auth.js +4 -1
  5. package/dist/commands/bot-runtime.d.ts +18 -5
  6. package/dist/commands/bot-runtime.js +29 -12
  7. package/dist/commands/bot.d.ts +85 -0
  8. package/dist/commands/bot.js +245 -16
  9. package/dist/commands/cloud.d.ts +16 -0
  10. package/dist/commands/cloud.js +112 -102
  11. package/dist/commands/core-checkpoint-native.d.ts +13 -0
  12. package/dist/commands/core-checkpoint-native.js +167 -52
  13. package/dist/commands/core-hook-registration-plan.js +5 -4
  14. package/dist/commands/core-stop-autosave.d.ts +21 -0
  15. package/dist/commands/core-stop-autosave.js +300 -0
  16. package/dist/commands/core.js +2 -0
  17. package/dist/commands/daemon.d.ts +5 -0
  18. package/dist/commands/daemon.js +52 -9
  19. package/dist/commands/doctor-usage.d.ts +5 -0
  20. package/dist/commands/doctor-usage.js +25 -0
  21. package/dist/commands/env.d.ts +49 -4
  22. package/dist/commands/env.js +355 -5
  23. package/dist/commands/integrations.js +84 -3
  24. package/dist/commands/lanes-shared.d.ts +3 -0
  25. package/dist/commands/lanes.d.ts +3 -0
  26. package/dist/commands/lanes.js +87 -3
  27. package/dist/commands/packs.js +23 -0
  28. package/dist/commands/pkg-update.d.ts +6 -0
  29. package/dist/commands/pkg-update.js +15 -7
  30. package/dist/commands/run.js +55 -45
  31. package/dist/commands/sources.js +4 -3
  32. package/dist/commands/sync-core.d.ts +1 -0
  33. package/dist/commands/sync-core.js +77 -3
  34. package/dist/commands/whoami.js +96 -80
  35. package/dist/lib/bot/config.d.ts +17 -0
  36. package/dist/lib/bot/config.js +13 -0
  37. package/dist/lib/bot/fleet-cron.js +29 -4
  38. package/dist/lib/bot/fleet-local.d.ts +30 -2
  39. package/dist/lib/bot/fleet-local.js +60 -1
  40. package/dist/lib/bot/grok-login-scope.d.ts +36 -0
  41. package/dist/lib/bot/grok-login-scope.js +93 -0
  42. package/dist/lib/bot/inflight.d.ts +9 -0
  43. package/dist/lib/bot/jobs/hot-signal-sync.d.ts +51 -0
  44. package/dist/lib/bot/jobs/hot-signal-sync.js +90 -9
  45. package/dist/lib/bot/legacy-provider-login.d.ts +32 -9
  46. package/dist/lib/bot/legacy-provider-login.js +28 -22
  47. package/dist/lib/bot/run.d.ts +29 -5
  48. package/dist/lib/bot/run.js +203 -1
  49. package/dist/lib/bot/runtime-sign-in-check.js +6 -1
  50. package/dist/lib/bot/runtime-sign-in.d.ts +2 -0
  51. package/dist/lib/bot/signals-try-now.d.ts +76 -0
  52. package/dist/lib/bot/signals-try-now.js +111 -0
  53. package/dist/lib/capacity/collectors/claude-oauth.d.ts +22 -3
  54. package/dist/lib/capacity/collectors/claude-oauth.js +78 -22
  55. package/dist/lib/capacity/scheduler.d.ts +8 -0
  56. package/dist/lib/capacity/scheduler.js +5 -2
  57. package/dist/lib/core-utils/sentry-report.js +2 -0
  58. package/dist/lib/daemon/machine-checks.d.ts +22 -1
  59. package/dist/lib/daemon/machine-checks.js +54 -12
  60. package/dist/lib/daemon/run.js +71 -8
  61. package/dist/lib/daemon/runtime-notifications.d.ts +7 -0
  62. package/dist/lib/daemon/runtime-notifications.js +50 -0
  63. package/dist/lib/daemon/stop-autosave-lock.d.ts +19 -0
  64. package/dist/lib/daemon/stop-autosave-lock.js +166 -0
  65. package/dist/lib/daemon/stop-autosave.d.ts +28 -0
  66. package/dist/lib/daemon/stop-autosave.js +111 -0
  67. package/dist/lib/daemon/stop-diagnostics.d.ts +11 -0
  68. package/dist/lib/daemon/stop-diagnostics.js +136 -0
  69. package/dist/lib/daemon/stop-job-executor.d.ts +19 -0
  70. package/dist/lib/daemon/stop-job-executor.js +126 -0
  71. package/dist/lib/daemon/stop-jobs.d.ts +93 -0
  72. package/dist/lib/daemon/stop-jobs.js +599 -0
  73. package/dist/lib/doctor/checks/fleet-hook-core.d.ts +9 -1
  74. package/dist/lib/doctor/checks/fleet-hook-core.js +39 -15
  75. package/dist/lib/doctor/checks/host-core.js +1 -1
  76. package/dist/lib/environment/access-probes.d.ts +234 -0
  77. package/dist/lib/environment/access-probes.js +918 -0
  78. package/dist/lib/environment/profile.d.ts +15 -2
  79. package/dist/lib/environment/profile.js +55 -20
  80. package/dist/lib/environment/rfc3339.d.ts +8 -0
  81. package/dist/lib/environment/rfc3339.js +26 -0
  82. package/dist/lib/environment/work-requirements.d.ts +169 -0
  83. package/dist/lib/environment/work-requirements.js +389 -0
  84. package/dist/lib/hook-engine/coverage.d.ts +137 -7
  85. package/dist/lib/hook-engine/coverage.js +1424 -4
  86. package/dist/lib/hook-engine/fleet-registration.d.ts +17 -5
  87. package/dist/lib/hook-engine/fleet-registration.js +53 -17
  88. package/dist/lib/hook-engine/git-stop-config.json +513 -0
  89. package/dist/lib/hook-engine/native-stop-compatibility.json +311 -0
  90. package/dist/lib/hook-engine/reconcile.js +2 -2
  91. package/dist/lib/hot-channels/alert.d.ts +10 -1
  92. package/dist/lib/hot-channels/alert.js +38 -8
  93. package/dist/lib/hot-channels/signals-claude-login.d.ts +53 -0
  94. package/dist/lib/hot-channels/signals-claude-login.js +96 -0
  95. package/dist/lib/hot-channels/signals-pass.d.ts +143 -17
  96. package/dist/lib/hot-channels/signals-pass.js +324 -17
  97. package/dist/lib/hot-channels/signals-runtime.d.ts +30 -0
  98. package/dist/lib/hot-channels/signals-runtime.js +82 -0
  99. package/dist/lib/install/hook-target.js +1 -1
  100. package/dist/lib/lanes/host-capacity.d.ts +26 -2
  101. package/dist/lib/lanes/host-capacity.js +17 -2
  102. package/dist/lib/lanes/host-compute.d.ts +90 -0
  103. package/dist/lib/lanes/host-compute.js +185 -0
  104. package/dist/lib/lanes/index.d.ts +2 -0
  105. package/dist/lib/lanes/index.js +1 -0
  106. package/dist/lib/lanes/reconcile.js +22 -1
  107. package/dist/lib/lanes/resource-usage.d.ts +155 -0
  108. package/dist/lib/lanes/resource-usage.js +589 -0
  109. package/dist/lib/lanes/run-size.d.ts +46 -0
  110. package/dist/lib/lanes/run-size.js +197 -0
  111. package/dist/lib/lanes/store.js +27 -0
  112. package/dist/lib/lanes/throttle.d.ts +36 -1
  113. package/dist/lib/lanes/throttle.js +47 -10
  114. package/dist/lib/lanes/types.d.ts +40 -0
  115. package/dist/lib/lanes/types.js +2 -2
  116. package/dist/lib/lanes/watcher.js +13 -4
  117. package/dist/lib/lanes/worker-process.d.ts +25 -2
  118. package/dist/lib/lanes/worker-process.js +71 -19
  119. package/dist/lib/placement/match.d.ts +192 -0
  120. package/dist/lib/placement/match.js +667 -0
  121. package/dist/lib/safe-store.d.ts +14 -0
  122. package/dist/lib/safe-store.js +77 -4
  123. package/dist/lib/search-index/index.d.ts +88 -4
  124. package/dist/lib/search-index/index.js +299 -25
  125. package/dist/lib/search-index/max-doc-bytes.d.ts +17 -6
  126. package/dist/lib/search-index/max-doc-bytes.js +48 -23
  127. package/dist/lib/signals/codex-lockdown.d.ts +79 -0
  128. package/dist/lib/signals/codex-lockdown.js +271 -0
  129. package/dist/lib/signals/codex-login.d.ts +37 -0
  130. package/dist/lib/signals/codex-login.js +83 -0
  131. package/dist/lib/signals/engine.d.ts +28 -0
  132. package/dist/lib/signals/engine.js +77 -0
  133. package/dist/lib/signals/reply.d.ts +48 -0
  134. package/dist/lib/signals/reply.js +94 -12
  135. package/dist/lib/signals/run-record.js +6 -1
  136. package/dist/lib/signals/settings.d.ts +5 -0
  137. package/dist/lib/signals/settings.js +2 -0
  138. package/dist/lib/signals/steps/adapters.js +6 -0
  139. package/dist/lib/signals/steps/extract.d.ts +135 -12
  140. package/dist/lib/signals/steps/extract.js +416 -84
  141. package/dist/lib/signals/steps/types.d.ts +21 -0
  142. package/dist/lib/sync-core/engine-home.d.ts +41 -2
  143. package/dist/lib/sync-core/engine-home.js +132 -19
  144. package/dist/lib/sync-core/reconcile.js +1 -1
  145. package/dist/lib/sync-core/release-compare.d.ts +7 -0
  146. package/dist/lib/sync-core/release-compare.js +16 -0
  147. package/dist/lib/sync-core/release.d.ts +2 -1
  148. package/dist/lib/sync-core/release.js +2 -10
  149. package/dist/lib/sync-core/rollout-state.d.ts +2 -1
  150. package/dist/lib/sync-core/rollout-state.js +5 -2
  151. package/dist/lib/sync-core/vault-uid.d.ts +2 -0
  152. package/dist/lib/sync-core/vault-uid.js +4 -0
  153. package/dist/run/schema-env-overrides.d.ts +24 -0
  154. package/dist/run/schema-env-overrides.js +72 -0
  155. package/dist/schemas/hq-work-requirements.v1.schema.json +145 -0
  156. package/dist/utils/auth-session-check.d.ts +16 -0
  157. package/dist/utils/auth-session-check.js +16 -0
  158. package/dist/utils/client-health-contract.d.ts +6 -0
  159. package/dist/utils/client-health-contract.js +13 -0
  160. package/dist/utils/client-health.d.ts +7 -0
  161. package/dist/utils/client-health.js +22 -1
  162. package/dist/utils/command-usage.d.ts +40 -0
  163. package/dist/utils/command-usage.js +61 -0
  164. package/dist/utils/duplicate-command-usage.d.ts +72 -0
  165. package/dist/utils/duplicate-command-usage.js +125 -0
  166. package/dist/utils/host-registration.d.ts +1 -1
  167. package/dist/utils/host-registration.js +6 -1
  168. package/dist/utils/resident-package-preload.js +4 -0
  169. package/dist/utils/sentry-fingerprint.js +9 -0
  170. package/dist/utils/windows-bash.d.ts +2 -0
  171. package/dist/utils/windows-bash.js +2 -1
  172. package/package.json +15 -10
  173. package/scripts/bench-core-compare.mjs +313 -0
  174. package/scripts/bench-core.mjs +399 -12
  175. package/scripts/check-function-manifest.mjs +121 -7
  176. package/dist/commands/__fixtures__/access-vault.d.ts +0 -95
  177. package/dist/commands/__fixtures__/access-vault.js +0 -166
  178. package/dist/commands/__fixtures__/make-tar.d.ts +0 -38
  179. package/dist/commands/__fixtures__/make-tar.js +0 -102
  180. package/dist/commands/secrets-public-types.test-d.d.ts +0 -2
  181. package/dist/commands/secrets-public-types.test-d.js +0 -18
  182. package/dist/lib/decisions/fixtures/us001.d.ts +0 -137
  183. package/dist/lib/decisions/fixtures/us001.js +0 -21
  184. package/dist/lib/doctor/__testing__/fake-hq-tree.d.ts +0 -226
  185. package/dist/lib/doctor/__testing__/fake-hq-tree.js +0 -408
  186. package/dist/lib/doctor/__testing__/run-doctor.d.ts +0 -8
  187. package/dist/lib/doctor/__testing__/run-doctor.js +0 -69
  188. package/dist/lib/fingerprint/fixtures.d.ts +0 -19
  189. package/dist/lib/fingerprint/fixtures.js +0 -61
  190. package/dist/lib/hot-channels/adapters/__fixtures__/dummy.d.ts +0 -33
  191. package/dist/lib/hot-channels/adapters/__fixtures__/dummy.js +0 -53
  192. package/dist/lib/hot-channels/adapters/__fixtures__/meeting-providers.d.ts +0 -38
  193. package/dist/lib/hot-channels/adapters/__fixtures__/meeting-providers.js +0 -64
  194. package/dist/lib/mesh/live/daemon/mqtt-events.test-d.d.ts +0 -2
  195. package/dist/lib/mesh/live/daemon/mqtt-events.test-d.js +0 -10
  196. package/dist/lib/test-utils/isolated-flag-company-context.d.ts +0 -3
  197. package/dist/lib/test-utils/isolated-flag-company-context.js +0 -18
  198. package/scripts/hook-engine-manifest.mjs +0 -22
  199. package/scripts/mesh-daemon-if-stale.mjs +0 -20
@@ -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```";
@@ -129,22 +169,54 @@ function spendBlock(record) {
129
169
  return null;
130
170
  const spend = spendUsd(record);
131
171
  const value = Math.max(0, Math.min(100, Math.round((spend / record.maxBudgetUsd) * 100)));
172
+ // Some coding tools report no cost; the step then counts a flat amount per source. Say it is an estimate.
173
+ const estimated = record.steps.some((s) => s.detail?.spendEstimated === true);
132
174
  return {
133
175
  kind: "progress",
134
176
  value,
135
- label: `Spend $${spend.toFixed(2)} of the $${record.maxBudgetUsd.toFixed(2)} cap`,
177
+ label: `${estimated ? "Estimated spend" : "Spend"} $${spend.toFixed(2)} of the $${record.maxBudgetUsd.toFixed(2)} cap`,
136
178
  tone: "neutral",
137
179
  };
138
180
  }
139
- function openBriefDecision(date) {
181
+ /**
182
+ * A run that stopped at the spend cap on estimated spend, in plain words:
183
+ * how many sources were processed, how many are left, and what controls it.
184
+ * Null for any other outcome.
185
+ */
186
+ function estimatedBudgetStop(record) {
187
+ const step = record.steps.find((s) => s.error === "budget-exceeded" && s.detail?.spendEstimated === true && typeof s.detail.sourcesProcessed === "number");
188
+ const d = step?.detail;
189
+ if (!d)
190
+ return null;
191
+ const each = typeof d.unpricedSourceEstimateUsd === "number" ? `$${d.unpricedSourceEstimateUsd.toFixed(2)}` : "a set amount";
192
+ const left = typeof d.sourcesLeft === "number" && d.sourcesLeft > 0 ? `, with at least ${plural(d.sourcesLeft, "source")} left for the next run` : "";
193
+ return `Signals stopped at the $${record.maxBudgetUsd.toFixed(2)} spend cap after ${plural(d.sourcesProcessed, "source")}${left}. The spend is an estimate: this coding tool does not report its cost, so each source counts as ${each}. To process more in one run, raise the cap with --max-budget-usd.`;
194
+ }
195
+ /**
196
+ * The non-desktop brief decision. It says the brief builds next only when a
197
+ * brief job is known to be scheduled; otherwise it asks.
198
+ */
199
+ function openBriefDecision(date, opts) {
140
200
  return {
141
201
  kind: "decision",
142
202
  questionId: `signals-run-${date}-open-brief`,
143
- question: "Your brief builds next.",
203
+ question: opts.briefJobScheduled ? BRIEF_BUILDS_NEXT_LINE : CREATE_BRIEF_QUESTION,
144
204
  options: [{ id: "open-brief", label: "Create today's brief", recommended: true }],
145
205
  allowOther: false,
146
206
  };
147
207
  }
208
+ /**
209
+ * How a finished run points at today's brief. Desktop: a second prose
210
+ * paragraph with the deep link and no decision; with `buildsNext` and a
211
+ * scheduled brief job it starts "Your brief builds next.". Elsewhere: the
212
+ * prose as it is and the "Create today's brief" decision.
213
+ */
214
+ function briefPointer(prose, date, opts, buildsNext) {
215
+ if (!opts.desktopLinks)
216
+ return { prose, blocks: [openBriefDecision(date, opts)] };
217
+ const lead = buildsNext && opts.briefJobScheduled ? `${BRIEF_BUILDS_NEXT_LINE} ` : "";
218
+ return { prose: `${prose}\n\n${lead}${briefLinkLine(opts)}`, blocks: [] };
219
+ }
148
220
  /** "a, b and c". */
149
221
  function listInWords(parts) {
150
222
  if (parts.length <= 1)
@@ -181,6 +253,11 @@ function raiseCapLine(record) {
181
253
  * that the rest waits for the next run, and how to raise the cap for a run.
182
254
  */
183
255
  function budgetGuidance(record, stopped) {
256
+ // Estimated spend has its own sentence (counts and the per-source amount).
257
+ // A metered stop still names the source it stopped at.
258
+ const estimated = estimatedBudgetStop(record);
259
+ if (estimated)
260
+ return estimated;
184
261
  const raw = stopped.detail?.budgetStoppedAt;
185
262
  const at = typeof raw === "string" && raw.trim() ? raw.trim() : null;
186
263
  const cap = capInWords(record);
@@ -282,7 +359,7 @@ export function formatRunReply(record, summary, opts) {
282
359
  : record.failureReason
283
360
  ? oneSentence(record.failureReason)
284
361
  : `Signals for ${company} failed.`;
285
- const brief = "Your brief is not built until signals finish, so you never read a brief without fresh signals.";
362
+ const brief = FAILED_RUN_BRIEF_LINE;
286
363
  const retryLine = retry
287
364
  ? `I try again at ${retry}.`
288
365
  : opts.wasRetry
@@ -314,7 +391,7 @@ export function formatRunReply(record, summary, opts) {
314
391
  questionId: `signals-run-${summary.date}-retry`,
315
392
  question: "Try again now, or wait for the retry?",
316
393
  options: [
317
- { id: "try-now", label: "Try now", recommended: true },
394
+ { id: TRY_NOW_OPTION_ID, label: TRY_NOW_LABEL, recommended: true },
318
395
  { id: "wait", label: `Wait for ${retry}` },
319
396
  ],
320
397
  allowOther: false,
@@ -323,10 +400,12 @@ export function formatRunReply(record, summary, opts) {
323
400
  kind: "decision",
324
401
  questionId: `signals-run-${summary.date}-retry`,
325
402
  question: "Try again now?",
326
- options: [{ id: "try-now", label: "Try now", recommended: true }],
403
+ options: [{ id: TRY_NOW_OPTION_ID, label: TRY_NOW_LABEL, recommended: true }],
327
404
  allowOther: false,
328
405
  });
329
- return build(`${job} stopped at ${finished}.`, blocks, "failed");
406
+ // The Try now decision stays; on desktop the prose also links today's brief.
407
+ const stoppedProse = `${job} stopped at ${finished}.`;
408
+ return build(opts.desktopLinks ? `${stoppedProse}\n\n${briefLinkLine(opts)}` : stoppedProse, blocks, "failed");
330
409
  }
331
410
  const counts = runCountItems(record, summary, opts);
332
411
  const spend = spendBlock(record);
@@ -358,22 +437,25 @@ export function formatRunReply(record, summary, opts) {
358
437
  ? partialReasonInWords(partialReason)
359
438
  : null;
360
439
  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}.`, [
440
+ const body = [guidance.main, ...(guidance.note ? [guidance.note] : []), `${PARTIAL_RUN_BRIEF_LINE} ${SAY_TRY_NOW_LINE}`].join(" ");
441
+ const brief = briefPointer(`${job} finished with problems at ${finished}.`, summary.date, opts, false);
442
+ return build(brief.prose, [
363
443
  { kind: "badge", label: "Finished with problems", tone: "warning" },
364
444
  ...(record.catchUp ? [catchUpBadge] : []),
365
445
  title ? { kind: "callout", tone: "warning", title, body } : { kind: "callout", tone: "warning", body },
366
446
  ...tail,
367
- openBriefDecision(summary.date),
447
+ ...brief.blocks,
368
448
  ], "partial");
369
449
  }
370
450
  if (record.catchUp) {
371
451
  const prose = due
372
452
  ? `${job} finished at ${finished} instead of ${due}. Your Mac was asleep at ${due}, so I ran it when it woke.`
373
453
  : `${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");
454
+ const brief = briefPointer(prose, summary.date, opts, true);
455
+ return build(brief.prose, [catchUpBadge, ...tail, ...brief.blocks], "catch-up");
375
456
  }
376
- return build(`${job} finished at ${finished}.`, [{ kind: "badge", label: "Complete", tone: "success", icon: "check" }, ...tail, openBriefDecision(summary.date)], "complete");
457
+ const brief = briefPointer(`${job} finished at ${finished}.`, summary.date, opts, true);
458
+ return build(brief.prose, [{ kind: "badge", label: "Complete", tone: "success", icon: "check" }, ...tail, ...brief.blocks], "complete");
377
459
  }
378
460
  /** Another run holds the company's lock (engine exit 3): nothing was started. */
379
461
  export function formatLockedReply(locked, opts) {
@@ -68,7 +68,12 @@ export function isRunRecord(v) {
68
68
  strOrNull(v.partial) &&
69
69
  typeof v.alreadyRanToday === "boolean" &&
70
70
  isCounts(v.counts) &&
71
- optional(v.lockTakeover, isObj);
71
+ optional(v.lockTakeover, isObj) &&
72
+ // PS-011 placement facts: absent on older records.
73
+ optional(v.host_id, strOrNull) &&
74
+ optional(v.engine, strOrNull) &&
75
+ optional(v.account, strOrNull) &&
76
+ optional(v.duration_seconds, (x) => x === null || (isNum(x) && x >= 0));
72
77
  if (!shape)
73
78
  return false;
74
79
  // Contract invariants: finishedAt is null exactly while running, and the
@@ -3,6 +3,11 @@ export interface SignalsSettings {
3
3
  maxBudgetUsd: number;
4
4
  lateStartHour: number;
5
5
  briefWaitMinutes: number;
6
+ /**
7
+ * What one source counts as against maxBudgetUsd when the coding tool reports
8
+ * no cost for it (Codex always, Grok sometimes). 0 turns the charge off.
9
+ */
10
+ unpricedSourceEstimateUsd: number;
6
11
  }
7
12
  export declare const DEFAULT_SIGNALS_SETTINGS: SignalsSettings;
8
13
  export declare const SIGNALS_SETTINGS_REL: string;
@@ -7,6 +7,7 @@ export const DEFAULT_SIGNALS_SETTINGS = {
7
7
  maxBudgetUsd: 2.0,
8
8
  lateStartHour: 22,
9
9
  briefWaitMinutes: 20,
10
+ unpricedSourceEstimateUsd: 0.1,
10
11
  };
11
12
  /** maxTurns: whole number >= 1. lateStartHour: whole hour 1-24 (0 would make every job late; 24 turns it off). */
12
13
  const VALID = {
@@ -14,6 +15,7 @@ const VALID = {
14
15
  maxBudgetUsd: (v) => Number.isFinite(v) && v >= 0,
15
16
  lateStartHour: (v) => Number.isInteger(v) && v >= 1 && v <= 24,
16
17
  briefWaitMinutes: (v) => Number.isFinite(v) && v >= 0,
18
+ unpricedSourceEstimateUsd: (v) => Number.isFinite(v) && v >= 0,
17
19
  };
18
20
  export const SIGNALS_SETTINGS_REL = path.join("core", "settings", "signals.yaml");
19
21
  export function loadSignalsSettings(hqRoot) {
@@ -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,7 @@
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 SignalsCodexLogin } from "../codex-login.js";
4
+ import type { PriorStep, SignalsStep, SpawnSyncFn, StepContext, StepResult } from "./types.js";
4
5
  export declare const EXTRACT_SIGNAL_TYPES: readonly ["action_item", "commitment", "decision", "risk", "question", "key_point", "participant_contribution", "summary"];
5
6
  export declare const DEFAULT_WORKLIST_LIMIT = 20;
6
7
  export declare const DEFAULT_TURN_TIMEOUT_MS: number;
@@ -42,6 +43,8 @@ export interface PartialDocument {
42
43
  audience: string[];
43
44
  }
44
45
  export interface ExtractStepOptions {
46
+ /** Charge per source when the runtime reports no cost. Default UNPRICED_SOURCE_ESTIMATE_USD. */
47
+ unpricedSourceEstimateUsd?: number;
45
48
  documentOverride?: PartialDocument;
46
49
  priorSignals?: readonly PriorSignal[];
47
50
  /** Runtime when no main local bot config is found. Default claude. */
@@ -57,6 +60,10 @@ export interface ExtractStepOptions {
57
60
  force?: boolean;
58
61
  /** OS used to decide whether grok's child-process network block exists. Default: this process. */
59
62
  platform?: NodeJS.Platform;
63
+ /** The Codex login a codex turn uses. Default: the Executive bot's own (defaultResolveCodexLogin). */
64
+ resolveCodexLogin?: () => SignalsCodexLogin;
65
+ /** The account's passwd home, checked as well as $HOME. Default: os.userInfo().homedir. */
66
+ passwdHome?: string;
60
67
  }
61
68
  interface SourceChannel {
62
69
  channel: string;
@@ -68,6 +75,21 @@ interface WorkItem {
68
75
  audience?: string[];
69
76
  skip?: string;
70
77
  }
78
+ /**
79
+ * What one source is charged against the run budget when the runtime reports
80
+ * no cost for it. `codex exec` has no turn or budget option and its event
81
+ * stream carries no cost, and a grok end event can omit total_cost_usd. Without
82
+ * a charge the run's spend stays 0 and the budget stop never fires.
83
+ *
84
+ * 0.10 USD (owner decision, 2026-11-16) is an assumption, not a measurement:
85
+ * no priced codex or grok extract run exists to derive it from. With the
86
+ * default 2.00 USD run budget it lets at most 20 such sources run. A codex turn
87
+ * that fails or is refused is not charged. The run record marks the spend as
88
+ * estimated.
89
+ * Set `unpricedSourceEstimateUsd` in core/settings/signals.yaml to change it;
90
+ * 0 turns the charge off.
91
+ */
92
+ export declare const UNPRICED_SOURCE_ESTIMATE_USD = 0.1;
71
93
  /** The Executive bot's runtime (lib/bot/executive.ts), or null when there is no personal bot. */
72
94
  export declare function defaultResolveBotRuntime(root?: string): BotRuntimeId | null;
73
95
  /**
@@ -75,8 +97,55 @@ export declare function defaultResolveBotRuntime(root?: string): BotRuntimeId |
75
97
  * or null when it is not in that form.
76
98
  */
77
99
  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[];
100
+ /**
101
+ * The batch channel that holds meeting transcripts. The meetings hot channel
102
+ * (adapters/meetings.ts) reads the same folder in the adapters step and
103
+ * extracts each transcript the signed-in person attended as `meeting:<id>`.
104
+ */
105
+ export declare const MEETINGS_BATCH_CHANNEL: string;
106
+ /** What the meetings hot channel covers when it runs (adapters/meetings.ts, MAX_CATCH_UP_WINDOW_MS). */
107
+ export declare const MEETINGS_HOT_CHANNEL_COVERAGE = "attended-last-30d";
108
+ /** A channel folder the step does not run, and why. */
109
+ export interface SkippedSourceChannel {
110
+ channel: string;
111
+ /**
112
+ * covered-by-hot-channel: the meetings folder has no source.yaml and the
113
+ * meetings hot channel ran ok in this run's adapters step. It extracts only
114
+ * the meetings the signed-in person attended, from the last 30 days.
115
+ * no-source-yaml: a folder with no source.yaml that nothing extracted this
116
+ * run (for meetings, `hotChannel` says why the hot channel did not run).
117
+ * source-yaml-invalid: run is neither local nor cloud.
118
+ * run-cloud: run: cloud without --force.
119
+ */
120
+ reason: "covered-by-hot-channel" | "no-source-yaml" | "source-yaml-invalid" | "run-cloud";
121
+ error?: string;
122
+ /** Meetings only: `not-run:<why>` when the hot channel did not cover this run. */
123
+ hotChannel?: string;
124
+ /** With covered-by-hot-channel: what the hot channel takes. */
125
+ coverage?: string;
126
+ }
127
+ /**
128
+ * Whether the meetings hot channel ran ok in this run, from the adapters step
129
+ * record: null when it did, else `not-run:<why>`.
130
+ */
131
+ export declare function meetingsHotChannelGap(priorSteps: readonly PriorStep[] | undefined): string | null;
132
+ export interface SourceChannelListing {
133
+ channels: SourceChannel[];
134
+ skipped: SkippedSourceChannel[];
135
+ /** Channels whose source.yaml exists but could not be read: a config failure, not a skip. */
136
+ unreadable: {
137
+ channel: string;
138
+ error: string;
139
+ }[];
140
+ }
141
+ /**
142
+ * Declared source channels with run: local (or any run: when forced), and the
143
+ * folders the step does not run with the reason for each. A folder with no
144
+ * source.yaml is never given one: for the meetings folder the hot channel is
145
+ * the extraction path, and the batch path would key the same transcript a
146
+ * second way (`meetings:<file>`).
147
+ */
148
+ export declare function listSourceChannels(hqRoot: string, company: string, force?: boolean, priorSteps?: readonly PriorStep[]): SourceChannelListing;
80
149
  /** Shell single-quote a value so a generated script carries it as data. */
81
150
  export declare function shellQuote(value: string): string;
82
151
  /**
@@ -95,10 +164,13 @@ export declare function buildExtractPrompt(input: {
95
164
  itemPath: string;
96
165
  wrapperPath: string;
97
166
  /**
98
- * codex has no Read tool; it reads with shell commands inside its sandbox.
99
- * grok reads with read_file and returns candidate commands as JSON data.
167
+ * codex has no tools: the item's text comes in the prompt (itemText) and it
168
+ * returns candidate commands as JSON data. grok reads with read_file and
169
+ * returns candidate commands as JSON data.
100
170
  */
101
171
  runtime?: "claude" | "codex" | "grok";
172
+ /** codex only: the item's text, read by the host. */
173
+ itemText?: string;
102
174
  }): string;
103
175
  /**
104
176
  * The per-item candidate command. It pins --company, --audience and
@@ -125,6 +197,7 @@ export declare function parseTurnOutput(stdout: string): {
125
197
  result: Record<string, unknown> | null;
126
198
  turns: number;
127
199
  costUsd: number;
200
+ costReported: boolean;
128
201
  };
129
202
  /**
130
203
  * How many of this item's new signal candidates in this company carry no
@@ -182,8 +255,13 @@ export interface TurnScope {
182
255
  */
183
256
  wrapperBody?: string;
184
257
  }
185
- /** TOML inline table for the codex permission profile's filesystem entries. */
186
- export declare function codexFilesystemProfile(scope: TurnScope, codexBin: string, envPath: string | undefined): string;
258
+ /**
259
+ * TOML inline table for the codex permission profile's filesystem entries:
260
+ * the platform minimum, the codex install dir and the turn's empty work dir,
261
+ * all read-only. No HQ path is granted; the host reads the item and writes
262
+ * the candidates.
263
+ */
264
+ export declare function codexFilesystemProfile(installDir: string, workDir: string): string;
187
265
  /**
188
266
  * The sandbox profile for a grok turn, written to <turn dir>/.grok/sandbox.toml.
189
267
  * grok's `strict` already covers the turn dir (cwd), system paths and ~/.grok;
@@ -202,7 +280,7 @@ export declare function grokCandidateArgv(command: string, wrapperPath: string):
202
280
  * immediately before each exec. Strict can write the turn directory, so a
203
281
  * writer that no longer matches is not run.
204
282
  */
205
- export declare function executeGrokCandidates(text: string, wrapperPath: string, spawn: SpawnSyncFn, opts: Parameters<SpawnSyncFn>[2], expectedWrapper?: string): string | undefined;
283
+ export declare function executeGrokCandidates(text: string, wrapperPath: string, spawn: SpawnSyncFn, opts: Parameters<SpawnSyncFn>[2], expectedWrapper?: string, runtime?: "grok" | "codex"): string | undefined;
206
284
  /**
207
285
  * Read denies for the grok login. Grok matches a `~` tool path literally and
208
286
  * expands `~` only after that check, so the absolute temp home is not enough.
@@ -248,16 +326,61 @@ export type ExtractRuntimeChoice = {
248
326
  /**
249
327
  * Which runtime runs the turns. The main bot's runtime, except that a grok
250
328
  * that is missing or cannot be locked down is never run: the step uses
251
- * claude, then codex, when that tool is installed and signed in, and
252
- * otherwise fails. The claude and codex checks run only when needed.
329
+ * claude when it is installed and signed in, and otherwise fails. It does
330
+ * not fall back to codex: a Codex turn needs a bot that runs on Codex with
331
+ * its own login (signalsCodexLogin), which a grok main bot never is. The
332
+ * claude check runs only when needed.
253
333
  */
254
334
  export declare function chooseExtractRuntime(main: BotRuntimeId, avail: {
255
335
  grok: () => GrokAvailability;
256
336
  claude: () => ToolAvailability;
257
- codex: () => ToolAvailability;
258
337
  }, platform?: NodeJS.Platform): ExtractRuntimeChoice;
259
338
  export declare function claudeTurnArgs(prompt: string, scope: TurnScope, maxTurns: number, budgetUsd: number): string[];
260
- export declare function codexTurnArgs(prompt: string, scope: TurnScope, codexBin: string, envPath: string | undefined): string[];
339
+ /**
340
+ * argv for one codex turn. The prompt goes on stdin (`-`), which keeps a long
341
+ * transcript off argv; the reply comes back in `outputFile`.
342
+ */
343
+ export declare function codexTurnArgs(input: {
344
+ workDir: string;
345
+ outputFile: string;
346
+ installDir: string;
347
+ }): string[];
348
+ /**
349
+ * The first codex item that is not a plain message, reasoning or error:
350
+ * evidence that a tool ran despite the lockdown. Null when there is none.
351
+ */
352
+ export declare function codexToolItem(stdout: string): string | null;
353
+ /** The real codex binary a turn runs, its install dir (the only install path the turn reads), and the bot's login dir (CODEX_HOME). */
354
+ export interface CodexTurnTarget {
355
+ binary: string;
356
+ installDir: string;
357
+ codexHome: string;
358
+ }
359
+ /** The Executive bot's own Codex login (signalsCodexLogin), or why extract may not use one. */
360
+ export declare function defaultResolveCodexLogin(root?: string, base?: NodeJS.ProcessEnv): SignalsCodexLogin;
361
+ /**
362
+ * The Codex login an extract turn may use, or why not: signalsCodexLogin's
363
+ * answer, also refused when its dir is the personal ~/.codex of any home,
364
+ * the passwd home included (os.homedir() follows $HOME and can hide it).
365
+ */
366
+ export declare function extractCodexLogin(login: SignalsCodexLogin, homes: readonly string[]): {
367
+ ok: true;
368
+ codexHome: string;
369
+ } | {
370
+ ok: false;
371
+ error: string;
372
+ };
373
+ /**
374
+ * Files in CODEX_HOME that codex loads into the model's context on its own:
375
+ * AGENTS.md, AGENTS.override.md and user skills (skills/<name>, not the
376
+ * skills/.system folder codex writes for its bundled skills, which
377
+ * skills.bundled.enabled=false keeps out). No codex 0.169.0 flag or config
378
+ * key turns these off (`codex debug prompt-input` still showed both with
379
+ * project_doc_max_bytes=0, include_skills_usage_instructions=false and
380
+ * skills.user.enabled=false), so a login folder holding any of them is
381
+ * refused instead. Rules files there are dropped by --ignore-rules.
382
+ */
383
+ export declare function codexHomeInstructions(codexHome: string): string[];
261
384
  export declare function extractPartialDocument(ctx: StepContext, doc: PartialDocument, prior: readonly PriorSignal[]): Promise<StepResult>;
262
385
  export declare function createExtractStep(options?: ExtractStepOptions): SignalsStep;
263
386
  export declare const extractStep: SignalsStep;