@indigoai-us/hq-cli 5.345.241 → 5.345.242

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 (116) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/assets/scaffold/core/scripts/hq-delegate-grant.sh +170 -8
  3. package/assets/scaffold/core/scripts/hq-delegate-publish.sh +21 -1
  4. package/assets/scaffold/core/scripts/lib/delegate-engine.sh +77 -0
  5. package/dist/command-catalog.generated.d.ts +28 -8
  6. package/dist/command-catalog.generated.js +33 -8
  7. package/dist/commands/cloud-off-gate.d.ts +7 -7
  8. package/dist/commands/cloud-off-gate.js +26 -38
  9. package/dist/commands/core-delegate-w1b.js +307 -26
  10. package/dist/commands/core-delegate.js +2 -0
  11. package/dist/commands/core-handoff.js +1 -1
  12. package/dist/commands/core-job-model-auth.d.ts +95 -0
  13. package/dist/commands/core-job-model-auth.js +247 -0
  14. package/dist/commands/core-job-run-native.js +280 -12
  15. package/dist/commands/core.js +1 -0
  16. package/dist/commands/files-browse.js +2 -0
  17. package/dist/commands/files.js +4 -0
  18. package/dist/commands/integrations-core.d.ts +11 -0
  19. package/dist/commands/integrations-core.js +15 -1
  20. package/dist/commands/lanes-link.js +2 -2
  21. package/dist/commands/lanes-loop.d.ts +2 -2
  22. package/dist/commands/lanes-loop.js +5 -5
  23. package/dist/commands/lanes-questions.js +1 -1
  24. package/dist/commands/lanes-stories.js +1 -1
  25. package/dist/commands/lanes.js +80 -14
  26. package/dist/commands/rescue.d.ts +3 -2
  27. package/dist/commands/rescue.js +48 -34
  28. package/dist/commands/search.d.ts +6 -0
  29. package/dist/commands/search.js +24 -4
  30. package/dist/commands/sources.js +6 -2
  31. package/dist/commands/sync-core.d.ts +8 -0
  32. package/dist/commands/sync-core.js +43 -0
  33. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +1737 -1450
  34. package/dist/hq-cloud-sync-runner/package.json +1 -1
  35. package/dist/lib/capacity/accounts.d.ts +1 -1
  36. package/dist/lib/capacity/accounts.js +1 -1
  37. package/dist/lib/capacity/freshness.d.ts +1 -1
  38. package/dist/lib/capacity/freshness.js +1 -1
  39. package/dist/lib/capacity/route.js +1 -1
  40. package/dist/lib/daemon/catalog.d.ts +3 -0
  41. package/dist/lib/daemon/hook-requests.d.ts +1 -1
  42. package/dist/lib/daemon/hook-requests.js +4 -2
  43. package/dist/lib/daemon/run.js +16 -22
  44. package/dist/lib/environment/work-requirements.d.ts +1 -1
  45. package/dist/lib/environment/work-requirements.js +1 -1
  46. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  47. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  48. package/dist/lib/hook-engine/coverage.js +11 -3
  49. package/dist/lib/hook-engine/git-stop-config.json +510 -510
  50. package/dist/lib/hook-engine/native-precompact-compatibility.json +443 -443
  51. package/dist/lib/hook-engine/native-stop-compatibility.json +359 -359
  52. package/dist/lib/hot-channels/adapters/meetings.d.ts +1 -16
  53. package/dist/lib/hot-channels/adapters/meetings.js +3 -28
  54. package/dist/lib/hot-channels/adapters/slack.d.ts +3 -1
  55. package/dist/lib/hot-channels/adapters/slack.js +4 -1
  56. package/dist/lib/hot-channels/contract.d.ts +14 -0
  57. package/dist/lib/hot-channels/fleet-complete.d.ts +18 -2
  58. package/dist/lib/hot-channels/fleet-complete.js +29 -4
  59. package/dist/lib/hot-channels/meeting-source-ref.d.ts +17 -0
  60. package/dist/lib/hot-channels/meeting-source-ref.js +32 -0
  61. package/dist/lib/hot-channels/prompts/signals-pass.md +6 -1
  62. package/dist/lib/hot-channels/run.d.ts +10 -0
  63. package/dist/lib/hot-channels/run.js +34 -0
  64. package/dist/lib/hot-channels/signals-pass.d.ts +27 -0
  65. package/dist/lib/hot-channels/signals-pass.js +57 -2
  66. package/dist/lib/hot-channels/signals-runtime.js +3 -2
  67. package/dist/lib/lanes/accounts.js +2 -2
  68. package/dist/lib/lanes/claude-balance.d.ts +6 -0
  69. package/dist/lib/lanes/claude-balance.js +124 -0
  70. package/dist/lib/lanes/grants.js +15 -2
  71. package/dist/lib/lanes/hq-root.d.ts +1 -1
  72. package/dist/lib/lanes/hq-root.js +1 -1
  73. package/dist/lib/lanes/links.d.ts +1 -1
  74. package/dist/lib/lanes/liveness.d.ts +3 -0
  75. package/dist/lib/lanes/liveness.js +61 -7
  76. package/dist/lib/lanes/models.d.ts +1 -1
  77. package/dist/lib/lanes/models.js +1 -1
  78. package/dist/lib/lanes/questions.d.ts +1 -1
  79. package/dist/lib/lanes/questions.js +2 -2
  80. package/dist/lib/lanes/spawn.js +4 -6
  81. package/dist/lib/lanes/store.d.ts +13 -2
  82. package/dist/lib/lanes/store.js +13 -5
  83. package/dist/lib/lanes/types.d.ts +7 -7
  84. package/dist/lib/lanes/types.js +1 -1
  85. package/dist/lib/lanes/watcher-main.js +1 -1
  86. package/dist/lib/lanes/watcher.d.ts +1 -1
  87. package/dist/lib/lanes/watcher.js +1 -1
  88. package/dist/lib/onboarding/cli/onboard.js +5 -0
  89. package/dist/lib/signals/sanitize.d.ts +19 -0
  90. package/dist/lib/signals/sanitize.js +103 -7
  91. package/dist/lib/signals/steps/upload.d.ts +40 -1
  92. package/dist/lib/signals/steps/upload.js +122 -6
  93. package/dist/lib/sync-core/access-refresh.d.ts +29 -0
  94. package/dist/lib/sync-core/access-refresh.js +97 -0
  95. package/dist/lib/sync-core/company-adoption.d.ts +33 -0
  96. package/dist/lib/sync-core/company-adoption.js +223 -0
  97. package/dist/lib/sync-core/engine-home.d.ts +1 -0
  98. package/dist/lib/sync-core/engine-owned.d.ts +13 -0
  99. package/dist/lib/sync-core/engine-owned.js +38 -0
  100. package/dist/lib/sync-core/hand-back.d.ts +17 -0
  101. package/dist/lib/sync-core/hand-back.js +23 -0
  102. package/dist/lib/sync-core/post-apply-reindex.d.ts +33 -0
  103. package/dist/lib/sync-core/post-apply-reindex.js +149 -0
  104. package/dist/lib/sync-core/reconcile.d.ts +10 -0
  105. package/dist/lib/sync-core/reconcile.js +117 -12
  106. package/dist/lib/sync-core/rollout-state.d.ts +2 -0
  107. package/dist/lib/sync-core/rollout-state.js +6 -0
  108. package/dist/lib/vault-sync-switches.d.ts +14 -0
  109. package/dist/lib/vault-sync-switches.js +22 -0
  110. package/dist/lib/workers-registry/index.d.ts +1 -1
  111. package/dist/lib/workers-registry/index.js +1 -1
  112. package/dist/utils/github-tag-fallback.d.ts +16 -0
  113. package/dist/utils/github-tag-fallback.js +126 -0
  114. package/dist/utils/version-report.d.ts +2 -1
  115. package/dist/utils/version-report.js +40 -27
  116. package/package.json +8 -8
@@ -263,6 +263,130 @@ export function selectClaudeAccount(input) {
263
263
  unavailable_hosts: [...(input.unavailableHosts ?? [])],
264
264
  };
265
265
  }
266
+ function companyOutpostIneligibility(status) {
267
+ if (!status.enabled)
268
+ return "disabled";
269
+ if (status.auth_state === "home_missing")
270
+ return "home_missing";
271
+ if (status.logged_in === false)
272
+ return "not_logged_in";
273
+ if (status.logged_in === null)
274
+ return "login_status_unknown";
275
+ if (status.quota_held === true)
276
+ return "quota_held";
277
+ return undefined;
278
+ }
279
+ /**
280
+ * Picks the Claude login for a lane on a company Outpost. The box runs the
281
+ * lane with its own company sign-in, so the candidates are the accounts the
282
+ * box reports, not this machine's lanes config, and loads on personal hosts
283
+ * do not count.
284
+ */
285
+ function companyOutpostSignInSteps(slug, outpostId) {
286
+ const company = slug ?? "<slug>";
287
+ const owner = slug ? `An owner or admin of ${slug}` : "An owner or admin of the company";
288
+ return `${owner} runs: hq outposts login --company ${company} --outpost ${outpostId}, opens the link, then runs: hq outposts login-code --company ${company} --outpost ${outpostId} <code>`;
289
+ }
290
+ export function selectCompanyOutpostClaudeAccount(input) {
291
+ const targetHost = input.target.capacity.host;
292
+ const placementDetails = {
293
+ requested_placement: input.requestedPlacement ?? null,
294
+ target_host: targetHost,
295
+ };
296
+ const reported = input.target.capacity.providers.claude.accounts;
297
+ const skipped = [];
298
+ const loads = Object.keys(reported).sort().map((account) => {
299
+ const status = reported[account];
300
+ const load = accountHostLoad(input.target, account);
301
+ const ineligible = companyOutpostIneligibility(status);
302
+ if (ineligible !== undefined)
303
+ skipped.push({ account, host: targetHost, reason: ineligible });
304
+ return {
305
+ account,
306
+ target_enabled: status.enabled,
307
+ target_logged_in: status.logged_in,
308
+ eligible: ineligible === undefined,
309
+ ...(ineligible !== undefined ? { ineligible_reason: ineligible } : {}),
310
+ ...(status.quota_held === true && status.quota_reset_at !== undefined ? { quota_reset_at: status.quota_reset_at } : {}),
311
+ live_lanes: load.live_lanes ?? 0,
312
+ counts_complete: load.live_lanes !== null && load.count_source !== "capacity_partial",
313
+ usage: status.usage ?? null,
314
+ recent_usage_at: null,
315
+ hosts: [load],
316
+ };
317
+ });
318
+ const outpostLabel = `company Outpost ${targetHost.id}`;
319
+ const signIn = companyOutpostSignInSteps(input.company?.slug, targetHost.id);
320
+ if (input.explicitAccount !== undefined) {
321
+ const selected = loads.find((load) => load.account === input.explicitAccount);
322
+ if (!selected || !selected.eligible) {
323
+ const reason = selected?.ineligible_reason ?? "unknown_account";
324
+ const name = `Claude account ${JSON.stringify(input.explicitAccount)}`;
325
+ const known = `Accounts on that Outpost: ${loads.map((load) => load.account).join(", ") || "(none)"}`;
326
+ const message = reason === "quota_held"
327
+ ? `${name} on ${outpostLabel} is out of quota${selected?.quota_reset_at ? ` until ${selected.quota_reset_at}` : ""}. ${known}`
328
+ : reason === "unknown_account"
329
+ ? `${outpostLabel} has no ${name}. ${known}`
330
+ : reason === "disabled"
331
+ ? `${name} is disabled on ${outpostLabel}. ${known}`
332
+ : `${name} is not signed in on ${outpostLabel}. ${signIn}`;
333
+ throw new LanesError("claude_account_balance_account_unavailable", message, {
334
+ account: input.explicitAccount,
335
+ reason,
336
+ ...(selected?.quota_reset_at !== undefined ? { quota_reset_at: selected.quota_reset_at } : {}),
337
+ ...placementDetails,
338
+ account_reasons: skipped,
339
+ unavailable_hosts: [],
340
+ });
341
+ }
342
+ return {
343
+ account: input.explicitAccount,
344
+ signal: "explicit",
345
+ reason: "explicit",
346
+ target_host: targetHost,
347
+ considered: loads,
348
+ skipped_accounts: skipped,
349
+ unavailable_hosts: [],
350
+ };
351
+ }
352
+ const eligible = loads.filter((load) => load.eligible);
353
+ if (eligible.length === 0) {
354
+ const quotaHeld = loads.length > 0 && loads.every((load) => load.ineligible_reason === "quota_held");
355
+ const resets = loads.flatMap((load) => load.quota_reset_at !== undefined ? [load.quota_reset_at] : []).sort();
356
+ const message = quotaHeld
357
+ ? `Every Claude account on ${outpostLabel} is out of quota${resets.length > 0 ? `; the first resets at ${resets[0]}` : ""}.`
358
+ : `No signed-in Claude account is available on ${outpostLabel}. ${signIn}`;
359
+ throw new LanesError("claude_account_balance_no_eligible_account", message, {
360
+ provider: "claude",
361
+ ...placementDetails,
362
+ ...(quotaHeld && resets.length > 0 ? { quota_reset_at: resets[0] } : {}),
363
+ account_reasons: loads.map((load) => ({
364
+ account: load.account,
365
+ reason: load.ineligible_reason ?? "unavailable",
366
+ ...(load.quota_reset_at !== undefined ? { quota_reset_at: load.quota_reset_at } : {}),
367
+ })),
368
+ unavailable_hosts: [],
369
+ });
370
+ }
371
+ const signal = eligible.every((load) => usageScore(load.usage) !== null) ? "usage" : "lane_count";
372
+ eligible.sort((a, b) => {
373
+ if (signal === "usage") {
374
+ const byUsage = usageScore(a.usage) - usageScore(b.usage);
375
+ if (byUsage !== 0)
376
+ return byUsage;
377
+ }
378
+ return a.live_lanes - b.live_lanes || a.account.localeCompare(b.account);
379
+ });
380
+ return {
381
+ account: eligible[0].account,
382
+ signal,
383
+ reason: "least_loaded",
384
+ target_host: targetHost,
385
+ considered: loads,
386
+ skipped_accounts: skipped,
387
+ unavailable_hosts: [],
388
+ };
389
+ }
266
390
  export function accountLoadsForReport(input) {
267
391
  const first = input.hosts[0];
268
392
  if (!first)
@@ -1,5 +1,5 @@
1
1
  import { isTerminalLaneState } from "./types.js";
2
- import { listLaneIds, readLane, withLaneHireLocks } from "./store.js";
2
+ import { readAllLanes, readLane, withLaneHireLocks } from "./store.js";
3
3
  import { LanesError } from "./errors.js";
4
4
  export function isFinishedResumableHireChild(state) {
5
5
  return state === "awaiting_input" || state === "blocked" || state === "done";
@@ -83,7 +83,10 @@ export function hireGrantCapacityError(parent, children) {
83
83
  /** Keep the occupancy snapshot and the resulting lane write in one parent-lock scope. */
84
84
  export function withHireGrantAdmission(hqRoot, parentLaneId, fn, suppliedHierarchy, preferSuppliedLaneIds = new Set(), finishedChildrenDoNotCount = false) {
85
85
  return withLaneHireLocks(hqRoot, [parentLaneId], () => {
86
- const ownerLanes = listLaneIds(hqRoot).map((id) => readLane(hqRoot, id));
86
+ // readAllLanes skips (with a warning) a record this CLI cannot parse, such as
87
+ // a host kind it does not know, so an unrelated lane cannot block a hire.
88
+ const skipped = [];
89
+ const ownerLanes = readAllLanes(hqRoot, undefined, (row) => skipped.push(row));
87
90
  let allLanes;
88
91
  let parent;
89
92
  if (suppliedHierarchy === undefined) {
@@ -105,6 +108,16 @@ export function withHireGrantAdmission(hqRoot, parentLaneId, fn, suppliedHierarc
105
108
  }
106
109
  parent = suppliedParent;
107
110
  }
111
+ // A skipped child of this parent may still hold part of its grant. Counting
112
+ // without it would let the parent hire past the grant, so fail closed unless
113
+ // the raw record says the child is finished or a readable copy is known.
114
+ const knownIds = new Set(allLanes.map((lane) => lane.lane_id));
115
+ const unreadableChild = skipped.find((row) => row.senior_id === parentLaneId &&
116
+ !knownIds.has(row.lane_id) &&
117
+ !isTerminalLaneState(row.state));
118
+ if (unreadableChild) {
119
+ throw new LanesError("hire_grant_context_invalid", `Lane ${unreadableChild.lane_id} under senior lane ${parentLaneId} could not be read, so its hire grant use is unknown. Repair or remove that lane record before hiring.`, { senior_lane_id: parentLaneId, unreadable_lane_id: unreadableChild.lane_id });
120
+ }
108
121
  const children = childrenHoldingHireGrantCarve(allLanes, parentLaneId, finishedChildrenDoNotCount);
109
122
  const parentGrant = parent.hire_grant ?? 0;
110
123
  const availableChildGrant = Math.max(0, parentGrant - assignedChildHireGrants(children));
@@ -1,5 +1,5 @@
1
1
  /**
2
- * HQ-root resolution for `hq lanes` only (not a global findHqRoot change).
2
+ * HQ-root resolution for `hq runners` only (not a global findHqRoot change).
3
3
  *
4
4
  * `findHqRoot` walks for `.claude` or `workers` and ignores `$HQ_ROOT`. Every
5
5
  * git worktree under `workspace/worktrees/` has its own `.claude`, so a
@@ -1,5 +1,5 @@
1
1
  /**
2
- * HQ-root resolution for `hq lanes` only (not a global findHqRoot change).
2
+ * HQ-root resolution for `hq runners` only (not a global findHqRoot change).
3
3
  *
4
4
  * `findHqRoot` walks for `.claude` or `workers` and ignores `$HQ_ROOT`. Every
5
5
  * git worktree under `workspace/worktrees/` has its own `.claude`, so a
@@ -22,7 +22,7 @@ export interface LinkOptions {
22
22
  input?: string;
23
23
  ackMode?: string;
24
24
  claims?: string;
25
- /** One-time handover token from `hq lanes link handover`, consumed by `adopt`. */
25
+ /** One-time handover token from `hq runners link handover`, consumed by `adopt`. */
26
26
  token?: string;
27
27
  /** File holding the handover token; keeps it out of argv. */
28
28
  tokenFile?: string;
@@ -50,6 +50,9 @@ export interface LivenessDeps {
50
50
  readdirSync: (dir: string, options: {
51
51
  withFileTypes: true;
52
52
  }) => fs.Dirent[];
53
+ openSync?: typeof fs.openSync;
54
+ readSync?: typeof fs.readSync;
55
+ closeSync?: typeof fs.closeSync;
53
56
  hostname?: () => string;
54
57
  }
55
58
  export declare function defaultLivenessDeps(): LivenessDeps;
@@ -41,6 +41,9 @@ export function defaultLivenessDeps() {
41
41
  statSync: (file) => fs.statSync(file),
42
42
  lstatSync: (file) => fs.lstatSync(file),
43
43
  readdirSync: fs.readdirSync.bind(fs),
44
+ openSync: fs.openSync.bind(fs),
45
+ readSync: fs.readSync.bind(fs),
46
+ closeSync: fs.closeSync.bind(fs),
44
47
  hostname: () => os.hostname(),
45
48
  };
46
49
  }
@@ -186,6 +189,55 @@ export function ingestSpoolLine(line, sessions, lineNo) {
186
189
  entry.lastSeq = seq;
187
190
  sessions[sessionId] = entry;
188
191
  }
192
+ /** 64 KiB. Keeps leftover bounded to one jsonl line, never the whole spool. */
193
+ const SPOOL_READ_CHUNK = 64 * 1024;
194
+ /** Drop a truncated leftover bigger than this; liveness events are small JSON. */
195
+ const SPOOL_MAX_LINE = 1_048_576;
196
+ function ingestSpoolFile(spoolPath, sessions, deps) {
197
+ const openSync = deps.openSync ?? fs.openSync;
198
+ const readSync = deps.readSync ?? fs.readSync;
199
+ const closeSync = deps.closeSync ?? fs.closeSync;
200
+ const fd = openSync(spoolPath, "r");
201
+ try {
202
+ const buf = Buffer.alloc(SPOOL_READ_CHUNK);
203
+ let leftover = "";
204
+ let lineNo = 0;
205
+ for (;;) {
206
+ const n = readSync(fd, buf, 0, buf.length, null);
207
+ if (n === 0)
208
+ break;
209
+ leftover += buf.toString("utf8", 0, n);
210
+ let nl = leftover.indexOf("\n");
211
+ while (nl !== -1) {
212
+ lineNo += 1;
213
+ ingestSpoolLine(leftover.slice(0, nl), sessions, lineNo);
214
+ leftover = leftover.slice(nl + 1);
215
+ nl = leftover.indexOf("\n");
216
+ }
217
+ if (leftover.length > SPOOL_MAX_LINE)
218
+ leftover = "";
219
+ }
220
+ if (leftover) {
221
+ lineNo += 1;
222
+ ingestSpoolLine(leftover, sessions, lineNo);
223
+ }
224
+ }
225
+ finally {
226
+ closeSync(fd);
227
+ }
228
+ }
229
+ function buildLivenessIndexFromSpoolFile(spoolPath, meta, deps) {
230
+ const sessions = {};
231
+ ingestSpoolFile(spoolPath, sessions, deps);
232
+ return {
233
+ schema_version: "hq-lane-liveness-index.v1",
234
+ built_at: meta.built_at,
235
+ spool_path: meta.spool_path,
236
+ spool_bytes: meta.spool_bytes,
237
+ spool_mtime_ms: meta.spool_mtime_ms,
238
+ sessions,
239
+ };
240
+ }
189
241
  export function buildLivenessIndexFromSpool(spoolContents, meta) {
190
242
  const sessions = {};
191
243
  const lines = spoolContents.split("\n");
@@ -256,11 +308,9 @@ function mergeLivenessCarry(index, carry) {
256
308
  }
257
309
  export function rebuildLivenessIndex(hqRoot, spoolPath, deps = defaultLivenessDeps()) {
258
310
  const carry = readLivenessCarryFor(spoolPath, deps);
259
- let contents;
260
311
  let st;
261
312
  try {
262
313
  st = deps.statSync(spoolPath);
263
- contents = deps.readFileSync(spoolPath, "utf8");
264
314
  }
265
315
  catch (err) {
266
316
  const code = err.code;
@@ -278,12 +328,12 @@ export function rebuildLivenessIndex(hqRoot, spoolPath, deps = defaultLivenessDe
278
328
  }
279
329
  throw err;
280
330
  }
281
- const index = mergeLivenessCarry(buildLivenessIndexFromSpool(contents, {
331
+ const index = mergeLivenessCarry(buildLivenessIndexFromSpoolFile(spoolPath, {
282
332
  spool_path: spoolPath,
283
333
  spool_bytes: st.size,
284
334
  spool_mtime_ms: Math.floor(st.mtimeMs),
285
335
  built_at: new Date(deps.now()).toISOString(),
286
- }), carry);
336
+ }, deps), carry);
287
337
  atomicWriteJson(livenessIndexPath(hqRoot), index, deps);
288
338
  return index;
289
339
  }
@@ -354,21 +404,25 @@ export function loadLivenessIndex(hqRoot, spoolPath, deps = defaultLivenessDeps(
354
404
  }
355
405
  }
356
406
  if (!persist) {
357
- let contents = "";
358
407
  let stSize = 0;
359
408
  let stMtime = 0;
360
409
  try {
361
410
  const st = deps.statSync(spool);
362
411
  stSize = st.size;
363
412
  stMtime = Math.floor(st.mtimeMs);
364
- contents = deps.readFileSync(spool, "utf8");
413
+ return mergeLivenessCarry(buildLivenessIndexFromSpoolFile(spool, {
414
+ spool_path: spool,
415
+ spool_bytes: stSize,
416
+ spool_mtime_ms: stMtime,
417
+ built_at: new Date(deps.now()).toISOString(),
418
+ }, deps), carry);
365
419
  }
366
420
  catch (err) {
367
421
  const code = err.code;
368
422
  if (code !== "ENOENT")
369
423
  throw err;
370
424
  }
371
- return mergeLivenessCarry(buildLivenessIndexFromSpool(contents, {
425
+ return mergeLivenessCarry(buildLivenessIndexFromSpool("", {
372
426
  spool_path: spool,
373
427
  spool_bytes: stSize,
374
428
  spool_mtime_ms: stMtime,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Per-provider known model ids, for validating `hq lanes create --model`.
2
+ * Per-provider known model ids, for validating `hq runners create --model`.
3
3
  *
4
4
  * No provider adapter in this package carries a model list, so each id set
5
5
  * is read from where the provider itself keeps it, the way the accounts
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Per-provider known model ids, for validating `hq lanes create --model`.
2
+ * Per-provider known model ids, for validating `hq runners create --model`.
3
3
  *
4
4
  * No provider adapter in this package carries a model list, so each id set
5
5
  * is read from where the provider itself keeps it, the way the accounts
@@ -46,7 +46,7 @@ export interface RaiseLaneQuestionInput {
46
46
  priority?: QuestionPriority;
47
47
  }
48
48
  /**
49
- * Persist one question the way `hq lanes ask` does: createQuestion, write the
49
+ * Persist one question the way `hq runners ask` does: createQuestion, write the
50
50
  * tenant body, then CAS routing_history with reason `asked`.
51
51
  */
52
52
  export declare function raiseLaneQuestion(input: RaiseLaneQuestionInput): QuestionRecord;
@@ -1,6 +1,6 @@
1
1
  import { assertQuestionNotImported } from "./imported-question.js";
2
2
  /**
3
- * Raise a lane question (spec §6.1). One function for the CLI `hq lanes ask`
3
+ * Raise a lane question (spec §6.1). One function for the CLI `hq runners ask`
4
4
  * path and for envelope `decision: "ask"` ingestion. Two writers here would
5
5
  * drift on hop, origin, raised_via, body store, and routing_history.
6
6
  */
@@ -158,7 +158,7 @@ export function writeQuestionBody(hqRoot, question, body) {
158
158
  };
159
159
  }
160
160
  /**
161
- * Persist one question the way `hq lanes ask` does: createQuestion, write the
161
+ * Persist one question the way `hq runners ask` does: createQuestion, write the
162
162
  * tenant body, then CAS routing_history with reason `asked`.
163
163
  */
164
164
  export function raiseLaneQuestion(input) {
@@ -32,7 +32,7 @@ import { AccountResolutionError, LanesError } from "./errors.js";
32
32
  import { ignoredWorkerProfileFields, loadWorkerProfile, loadWorkerProfileWithRegistry, materializeWorkerProfile, workerProfilePrompt, } from "./profile.js";
33
33
  import { registryWorkerRecord } from "./registry-persona.js";
34
34
  import { resolveMachineIdentity, } from "./machine-identity.js";
35
- import { appendCappedHistory, listLaneIds, readLane, retryUpdateLane } from "./store.js";
35
+ import { appendCappedHistory, readAllLanes, readLane, retryUpdateLane } from "./store.js";
36
36
  import { managerStatusGateHeartbeat } from "./manager-status-gate.js";
37
37
  import { LANE_QUOTA_ACCOUNT_FAILOVER_FLAG } from "./flag-keys.js";
38
38
  import { readLanesRegistryFlagFailOff } from "./registry-flag.js";
@@ -374,8 +374,7 @@ function selectSpawnAccount(input) {
374
374
  ...(admissionHost.aliases !== undefined ? { aliases: admissionHost.aliases } : {}),
375
375
  }
376
376
  : undefined;
377
- const lanes = listLaneIds(hqRoot)
378
- .map((laneId) => readLane(hqRoot, laneId))
377
+ const lanes = readAllLanes(hqRoot)
379
378
  .filter((record) => (record.host.kind === lane.host.kind && record.host.id === lane.host.id) ||
380
379
  (localMatch !== undefined && laneRunsOnHost(record, { ...localMatch, outpostId: null })));
381
380
  const capacity = buildHostCapacitySnapshot({
@@ -821,9 +820,8 @@ export async function retryLaneOnAlternateAccount(hqRoot, lane, reason, writer =
821
820
  };
822
821
  };
823
822
  const candidate = moveToRetryQueue(current);
824
- const admissionLanes = listLaneIds(hqRoot)
825
- .filter((id) => id !== current.lane_id)
826
- .map((id) => readLane(hqRoot, id));
823
+ const admissionLanes = readAllLanes(hqRoot)
824
+ .filter((row) => row.lane_id !== current.lane_id);
827
825
  admissionLanes.push(candidate);
828
826
  const profileMaxFor = (row) => row.worker_profile === undefined
829
827
  ? undefined
@@ -61,8 +61,19 @@ export declare function mergeLaneRecords(live: LaneRecord, sidecars: readonly La
61
61
  export declare function mergeQuestionRecords(live: QuestionRecord, sidecars: readonly QuestionRecord[]): QuestionRecord;
62
62
  export declare function tryReadLane(hqRoot: string, laneId: string, deps?: StoreDeps): LaneRecord | null;
63
63
  export declare function readLane(hqRoot: string, laneId: string, deps?: StoreDeps): LaneRecord;
64
- /** Reads all lanes, indexing sidecars once and sorting by creation time then id. */
65
- export declare function readAllLanes(hqRoot: string, deps?: StoreDeps): LaneRecord[];
64
+ /** A lane record readAllLanes skipped, with fields read best-effort from its raw JSON. */
65
+ export interface SkippedLaneRecord {
66
+ lane_id: string;
67
+ /** Raw `senior.id`, when the record's JSON has one. */
68
+ senior_id: string | undefined;
69
+ /** Raw `state`, unvalidated; undefined when the record has none. */
70
+ state: unknown;
71
+ }
72
+ /**
73
+ * Reads all lanes, indexing sidecars once and sorting by creation time then id.
74
+ * A record that fails to parse is skipped with a warning and reported to `onSkip`.
75
+ */
76
+ export declare function readAllLanes(hqRoot: string, deps?: StoreDeps, onSkip?: (skipped: SkippedLaneRecord) => void): LaneRecord[];
66
77
  export declare function tryReadQuestion(hqRoot: string, questionId: string, deps?: StoreDeps): QuestionRecord | null;
67
78
  export declare function readQuestion(hqRoot: string, questionId: string, deps?: StoreDeps): QuestionRecord;
68
79
  /** Semver precedence includes prerelease identifiers (for example, rc.2 > rc.1). */
@@ -1602,8 +1602,11 @@ export function readLane(hqRoot, laneId, deps = defaultStoreDeps()) {
1602
1602
  throw new LaneNotFoundError("lane", laneId);
1603
1603
  return record;
1604
1604
  }
1605
- /** Reads all lanes, indexing sidecars once and sorting by creation time then id. */
1606
- export function readAllLanes(hqRoot, deps = defaultStoreDeps()) {
1605
+ /**
1606
+ * Reads all lanes, indexing sidecars once and sorting by creation time then id.
1607
+ * A record that fails to parse is skipped with a warning and reported to `onSkip`.
1608
+ */
1609
+ export function readAllLanes(hqRoot, deps = defaultStoreDeps(), onSkip) {
1607
1610
  const laneIds = listLaneIds(hqRoot, deps);
1608
1611
  if (laneIds.length === 0)
1609
1612
  return [];
@@ -1646,9 +1649,14 @@ export function readAllLanes(hqRoot, deps = defaultStoreDeps()) {
1646
1649
  throw err;
1647
1650
  const filePath = laneRecordPath(hqRoot, laneId);
1648
1651
  const raw = readJsonFile(filePath, indexedDeps);
1649
- const host = raw !== null && typeof raw === "object" && !Array.isArray(raw)
1650
- ? raw.host
1651
- : undefined;
1652
+ const rawRecord = isPlainObject(raw) ? raw : undefined;
1653
+ const rawSenior = isPlainObject(rawRecord?.senior) ? rawRecord.senior : undefined;
1654
+ onSkip?.({
1655
+ lane_id: laneId,
1656
+ senior_id: typeof rawSenior?.id === "string" ? rawSenior.id : undefined,
1657
+ state: rawRecord?.state,
1658
+ });
1659
+ const host = rawRecord?.host;
1652
1660
  const hostRecord = host !== null && typeof host === "object" && !Array.isArray(host)
1653
1661
  ? host
1654
1662
  : undefined;
@@ -331,7 +331,7 @@ export type LaneProvider = (typeof LANE_PROVIDERS)[number];
331
331
  * Who runs a lane's work. A process lane (the default, recorded by absence)
332
332
  * is a provider process HQ spawned and watches. A subagent lane is a record
333
333
  * only: an in-session Claude subagent does the work and reports through
334
- * `hq lanes progress`, so admission, watchers, reapers and keep-alive skip it.
334
+ * `hq runners progress`, so admission, watchers, reapers and keep-alive skip it.
335
335
  */
336
336
  export declare const LANE_RUNNERS: readonly ["process", "subagent"];
337
337
  export type LaneRunner = (typeof LANE_RUNNERS)[number];
@@ -481,7 +481,7 @@ interface LaneStopHistoryEntry {
481
481
  at: string;
482
482
  reason: string;
483
483
  }
484
- /** One `hq lanes set` change; it takes effect when the lane next resumes. */
484
+ /** One `hq runners set` change; it takes effect when the lane next resumes. */
485
485
  export interface LaneSettingsHistoryEntry {
486
486
  at: string;
487
487
  actor: string;
@@ -728,7 +728,7 @@ export interface LaneRecord {
728
728
  /** Short-lived slot reservation between create persistence and worker spawn. */
729
729
  admission_reserved_at?: string;
730
730
  /**
731
- * Set by `hq lanes pickup` when it stores an outpost lane and cleared by
731
+ * Set by `hq runners pickup` when it stores an outpost lane and cleared by
732
732
  * the account bind once the model probe has finished. While set, the
733
733
  * reconcile pass does not admit the lane: a spawn during the probe would
734
734
  * leave a running worker behind a record the probe result then rewrites.
@@ -918,10 +918,10 @@ export interface LaneRecord {
918
918
  terminal_reason?: string;
919
919
  /** Reasons supplied to explicit stop commands, retained independently of optional project ledgers. */
920
920
  stop_history?: LaneStopHistoryEntry[];
921
- /** Model and effort changes made with `hq lanes set`. */
921
+ /** Model and effort changes made with `hq runners set`. */
922
922
  settings_history?: LaneSettingsHistoryEntry[];
923
923
  /**
924
- * Model or effort from `hq lanes set` on a running lane. The running turn
924
+ * Model or effort from `hq runners set` on a running lane. The running turn
925
925
  * keeps its launched values (quota classification reads `model`); the next
926
926
  * spawn applies these and clears them.
927
927
  */
@@ -1087,7 +1087,7 @@ export interface LaneResumeRecord {
1087
1087
  message_id?: string;
1088
1088
  monitor_event?: true;
1089
1089
  /**
1090
- * `hq lanes resume` only: the state the lane was in when the operator
1090
+ * `hq runners resume` only: the state the lane was in when the operator
1091
1091
  * resumed it (`interrupted`, `done`, `blocked`, `failed` or `awaiting_input`)
1092
1092
  * and the text they sent.
1093
1093
  */
@@ -1293,7 +1293,7 @@ export interface LivenessWindows {
1293
1293
  /** No event at all for this window (and no `session_end`) → lost. Default 12 hours. */
1294
1294
  silent_lost_ms: number;
1295
1295
  }
1296
- /** Age limits used by `hq lanes checks`; each value is a positive millisecond count. */
1296
+ /** Age limits used by `hq runners checks`; each value is a positive millisecond count. */
1297
1297
  export interface TrackerChecksConfig {
1298
1298
  owner_question_surface_ms: number;
1299
1299
  open_question_age_ms: number;
@@ -117,7 +117,7 @@ export const LANE_PROVIDERS = ["claude", "codex", "grok"];
117
117
  * Who runs a lane's work. A process lane (the default, recorded by absence)
118
118
  * is a provider process HQ spawned and watches. A subagent lane is a record
119
119
  * only: an in-session Claude subagent does the work and reports through
120
- * `hq lanes progress`, so admission, watchers, reapers and keep-alive skip it.
120
+ * `hq runners progress`, so admission, watchers, reapers and keep-alive skip it.
121
121
  */
122
122
  export const LANE_RUNNERS = ["process", "subagent"];
123
123
  export function parseLaneRunner(value) {
@@ -93,7 +93,7 @@ function main() {
93
93
  const laneId = process.argv[2]?.trim();
94
94
  const hqRoot = process.env.HQ_ROOT?.trim();
95
95
  if (!laneId || !hqRoot) {
96
- process.stderr.write("hq lanes watcher: requires lane id argv and HQ_ROOT in the environment\n");
96
+ process.stderr.write("hq runners watcher: requires lane id argv and HQ_ROOT in the environment\n");
97
97
  process.exit(1);
98
98
  }
99
99
  void runWatcherLoop(hqRoot, laneId, watcherMainDeps(hqRoot, laneId, process.env)).catch((err) => {
@@ -115,7 +115,7 @@ export interface ApplyTerminalOpts {
115
115
  export declare function stalledReason(silenceMs: number): string;
116
116
  /**
117
117
  * The consumer of the silence signal. A silence emit on a running lane sets
118
- * `stalled` on the record so `hq lanes list` and `show` surface it; the next
118
+ * `stalled` on the record so `hq runners list` and `show` surface it; the next
119
119
  * progress emit clears it. Nothing here changes `state`.
120
120
  */
121
121
  export declare function markLaneStalled(hqRoot: string, laneId: string, at: string, reason: string): LaneRecord;
@@ -341,7 +341,7 @@ export function stalledReason(silenceMs) {
341
341
  }
342
342
  /**
343
343
  * The consumer of the silence signal. A silence emit on a running lane sets
344
- * `stalled` on the record so `hq lanes list` and `show` surface it; the next
344
+ * `stalled` on the record so `hq runners list` and `show` surface it; the next
345
345
  * progress emit clears it. Nothing here changes `state`.
346
346
  */
347
347
  export function markLaneStalled(hqRoot, laneId, at, reason) {
@@ -8,6 +8,7 @@ import { VaultClient, VaultConflictError, VaultNotFoundError } from "@indigoai-u
8
8
  import { createCompanyFlow, joinCompanyFlow, resumeOnboarding, } from "../orchestrator.js";
9
9
  import { readCheckpoint, getCheckpointPath } from "../checkpoint.js";
10
10
  import { formatProgress, formatSummary, formatError } from "./prompts.js";
11
+ import { raiseAccessRefresh } from "../../sync-core/access-refresh.js";
11
12
  const CREATE_STEPS = 6;
12
13
  const JOIN_STEPS = 6;
13
14
  /**
@@ -63,6 +64,9 @@ export async function runOnboardCli(options) {
63
64
  }
64
65
  log(`Resuming ${checkpoint.mode} flow from step ${checkpoint.completedSteps.length + 1}...`);
65
66
  const result = await resumeOnboarding(config, onProgress);
67
+ if (checkpoint.mode === "join-company") {
68
+ raiseAccessRefresh({ companyUid: result.companyUid, companySlug: result.companySlug });
69
+ }
66
70
  log("");
67
71
  log(formatSummary(result));
68
72
  return { success: true, result };
@@ -118,6 +122,7 @@ export async function runOnboardCli(options) {
118
122
  log("Joining company via invite...");
119
123
  log("");
120
124
  const result = await joinCompanyFlow(input, config, onProgress);
125
+ raiseAccessRefresh({ companyUid: result.companyUid, companySlug: result.companySlug });
121
126
  log("");
122
127
  log(formatSummary(result));
123
128
  return { success: true, result };
@@ -9,6 +9,13 @@ export declare const MAX_CONTENT_CHARS = 600;
9
9
  export declare const MAX_CITATIONS = 8;
10
10
  export declare const MAX_ENTITIES = 16;
11
11
  export declare const MAX_FIELD_CHARS = 256;
12
+ /**
13
+ * A meeting signal's `source_ref`: the transcript path
14
+ * `sources/meetings/<file>.md`, or the hot-channel alias `meeting:<id>` the
15
+ * signals pass writes (same character set as the pass accepts). The alias id
16
+ * is a bot or transcript id, not a file name: `resolveMeetingAlias` finds the
17
+ * transcript that carries it.
18
+ */
12
19
  export declare const MEETING_SOURCE_RE: RegExp;
13
20
  export interface SanitizedContributionV1 {
14
21
  schema: string;
@@ -81,6 +88,16 @@ export interface AudienceReceiptLocal {
81
88
  }
82
89
  /** Highest-version audience receipt for a meeting, read from the local company tree. */
83
90
  export declare function readAudienceReceipt(companyRoot: string, meetingId: string): AudienceReceiptLocal | null;
91
+ /** `meeting:<id>` alias -> the transcript file names (without `.md`) in `sources/meetings/` that carry it. */
92
+ export type MeetingAliasIndex = ReadonlyMap<string, readonly string[]>;
93
+ /**
94
+ * Index the company's meeting transcripts by the `meeting:<id>` alias the
95
+ * meetings hot channel gives each one (`transcriptSignalSourceRef`: the
96
+ * `recall_bot_id`, else the transcript id) and by any `signal_source_ref` the
97
+ * file itself records. Built once per upload run. Landed hot-signal pointers
98
+ * are skipped, the same as the meetings adapter skips them.
99
+ */
100
+ export declare function buildMeetingAliasIndex(companyRoot: string): MeetingAliasIndex;
84
101
  export interface SanitizeInput {
85
102
  /** Absolute path of `companies/{co}`. */
86
103
  companyRoot: string;
@@ -90,6 +107,8 @@ export interface SanitizeInput {
90
107
  companyUid: string;
91
108
  projectionState: string;
92
109
  projectionWatermark: string;
110
+ /** The run's transcript alias index, built on first use; built from `companyRoot` when absent. */
111
+ meetingIndex?: () => MeetingAliasIndex;
93
112
  }
94
113
  export type SanitizeResult = {
95
114
  ok: true;