@indigoai-us/hq-cli 5.345.222 → 5.345.225

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 (128) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/assets/bot-workers/setup/context/quick-reference.md +2 -2
  3. package/assets/mesh-daemon/README.md +11 -12
  4. package/dist/command-catalog.generated.d.ts +79 -5
  5. package/dist/command-catalog.generated.js +95 -5
  6. package/dist/commands/bot.d.ts +1 -1
  7. package/dist/commands/bot.js +34 -33
  8. package/dist/commands/cloud-provision.d.ts +4 -1
  9. package/dist/commands/cloud-provision.js +7 -3
  10. package/dist/commands/cloud-retire.js +1 -1
  11. package/dist/commands/core-delegate-w1b.js +210 -188
  12. package/dist/commands/core-delegate.d.ts +5 -0
  13. package/dist/commands/core-dm-bind-native.d.ts +5 -1
  14. package/dist/commands/core-dm-bind-native.js +4 -0
  15. package/dist/commands/core-job-notify-native.d.ts +5 -1
  16. package/dist/commands/core-job-notify-native.js +8 -2
  17. package/dist/commands/core-jobs-native.d.ts +27 -1
  18. package/dist/commands/core-jobs-native.js +49 -28
  19. package/dist/commands/core-pipeline-conductor-native.js +7 -7
  20. package/dist/commands/core-pipeline-driver-native.js +5 -5
  21. package/dist/commands/core-refresh-vault-access-native.d.ts +5 -0
  22. package/dist/commands/core-refresh-vault-access-native.js +3 -1
  23. package/dist/commands/core-work-mesh-bind-trusted-native.js +1 -1
  24. package/dist/commands/daemon.d.ts +2 -0
  25. package/dist/commands/daemon.js +67 -1
  26. package/dist/commands/lanes-hold.d.ts +2 -27
  27. package/dist/commands/lanes-hold.js +3 -75
  28. package/dist/commands/lanes-loop.js +1 -1
  29. package/dist/commands/lanes-session-start.js +2 -2
  30. package/dist/commands/mesh.d.ts +12 -0
  31. package/dist/commands/mesh.js +13 -4
  32. package/dist/commands/monitor.js +1 -1
  33. package/dist/commands/packs.js +14 -3
  34. package/dist/commands/sync-core.js +31 -12
  35. package/dist/commands/whoami.d.ts +10 -17
  36. package/dist/commands/whoami.js +7 -79
  37. package/dist/data/command-states.json +13 -0
  38. package/dist/index.js +1 -1
  39. package/dist/lib/bot/fleet-cron.d.ts +26 -3
  40. package/dist/lib/bot/fleet-cron.js +44 -4
  41. package/dist/lib/bot/run.d.ts +4 -4
  42. package/dist/lib/bot/run.js +5 -3
  43. package/dist/lib/bot/signals-engine-flag.d.ts +53 -13
  44. package/dist/lib/bot/signals-engine-flag.js +202 -9
  45. package/dist/lib/daemon/catalog.d.ts +8 -5
  46. package/dist/lib/daemon/catalog.js +13 -7
  47. package/dist/lib/daemon/config.d.ts +5 -0
  48. package/dist/lib/daemon/config.js +6 -0
  49. package/dist/lib/daemon/lanes-monitor-state.d.ts +55 -0
  50. package/dist/lib/daemon/lanes-monitor-state.js +129 -0
  51. package/dist/lib/daemon/lanes-reconcile-loader.d.ts +7 -0
  52. package/dist/lib/daemon/lanes-reconcile-loader.js +13 -0
  53. package/dist/lib/daemon/machine-checks.d.ts +45 -0
  54. package/dist/lib/daemon/machine-checks.js +95 -11
  55. package/dist/lib/daemon/merge-sections.d.ts +165 -0
  56. package/dist/lib/daemon/merge-sections.js +556 -0
  57. package/dist/lib/daemon/native-notice-ledger.d.ts +9 -0
  58. package/dist/lib/daemon/native-notice-ledger.js +43 -0
  59. package/dist/lib/daemon/ops/policy.d.ts +1 -1
  60. package/dist/lib/daemon/ops/policy.js +1 -1
  61. package/dist/lib/daemon/protocol.d.ts +1 -1
  62. package/dist/lib/daemon/protocol.js +0 -6
  63. package/dist/lib/daemon/run.js +76 -3
  64. package/dist/lib/daemon/selfcheck.js +2 -2
  65. package/dist/lib/daemon/server.d.ts +2 -4
  66. package/dist/lib/daemon/server.js +5 -48
  67. package/dist/lib/daemon/state-file.d.ts +74 -4
  68. package/dist/lib/daemon/state-file.js +159 -19
  69. package/dist/lib/daemon/supervisor.d.ts +11 -1
  70. package/dist/lib/daemon/supervisor.js +86 -0
  71. package/dist/lib/daemon/updater.d.ts +2 -6
  72. package/dist/lib/daemon/updater.js +4 -11
  73. package/dist/lib/daemon/whoami-cache.d.ts +96 -0
  74. package/dist/lib/daemon/whoami-cache.js +244 -0
  75. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  76. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  77. package/dist/lib/flag-registry-worker.js +33 -3
  78. package/dist/lib/flag-registry.js +13 -0
  79. package/dist/lib/hook-engine/coverage.d.ts +2 -0
  80. package/dist/lib/hook-engine/coverage.js +71 -0
  81. package/dist/lib/hook-engine/native-precompact-compatibility.json +449 -0
  82. package/dist/lib/hook-engine/reconcile.js +14 -8
  83. package/dist/lib/install/hook-target.d.ts +13 -3
  84. package/dist/lib/install/hook-target.js +14 -11
  85. package/dist/lib/lanes/envelope-repair-dispatch.js +1 -1
  86. package/dist/lib/lanes/monitor.d.ts +2 -0
  87. package/dist/lib/lanes/monitor.js +2 -1
  88. package/dist/lib/lanes/registry-flag.d.ts +6 -0
  89. package/dist/lib/lanes/registry-flag.js +3 -2
  90. package/dist/lib/lanes/repo-merge-hold.d.ts +39 -0
  91. package/dist/lib/lanes/repo-merge-hold.js +90 -0
  92. package/dist/lib/lanes/watcher-main.js +3 -3
  93. package/dist/lib/mesh/live/daemon/doctor.js +1 -1
  94. package/dist/lib/mesh/live/daemon/install.js +2 -2
  95. package/dist/lib/scan-packages/index.js +8 -9
  96. package/dist/lib/signals/engine.d.ts +8 -0
  97. package/dist/lib/signals/engine.js +15 -5
  98. package/dist/lib/sync-core/flag.d.ts +18 -0
  99. package/dist/lib/sync-core/flag.js +66 -0
  100. package/dist/lib/sync-core/reconcile.d.ts +6 -0
  101. package/dist/lib/sync-core/reconcile.js +15 -0
  102. package/dist/lib/sync-core/rollout-state.d.ts +2 -0
  103. package/dist/lib/sync-core/rollout-state.js +7 -0
  104. package/dist/lib/sync-core/vault-settings.d.ts +12 -1
  105. package/dist/lib/sync-core/vault-settings.js +23 -7
  106. package/dist/lib/windows/install-followup.js +1 -1
  107. package/dist/utils/client-health-contract.d.ts +1 -0
  108. package/dist/utils/client-health-contract.js +5 -0
  109. package/dist/utils/client-health.d.ts +2 -0
  110. package/dist/utils/client-health.js +40 -0
  111. package/dist/utils/cognito-session.d.ts +2 -14
  112. package/dist/utils/cognito-session.js +2 -40
  113. package/dist/utils/daemon-cli-version.d.ts +13 -0
  114. package/dist/utils/daemon-cli-version.js +47 -0
  115. package/dist/utils/duplicate-command-usage.js +1 -1
  116. package/dist/utils/machine-token-cache.d.ts +21 -0
  117. package/dist/utils/machine-token-cache.js +49 -0
  118. package/dist/utils/pack-contributions.d.ts +14 -2
  119. package/dist/utils/pack-contributions.js +31 -5
  120. package/dist/utils/resident-package-preload.js +4 -0
  121. package/dist/utils/whoami-identity.d.ts +54 -0
  122. package/dist/utils/whoami-identity.js +108 -0
  123. package/package.json +7 -7
  124. package/scripts/bench-core.mjs +34 -3
  125. package/dist/lib/daemon/ops/memory.d.ts +0 -18
  126. package/dist/lib/daemon/ops/memory.js +0 -65
  127. package/dist/lib/daemon/ops/mesh.d.ts +0 -38
  128. package/dist/lib/daemon/ops/mesh.js +0 -70
@@ -2,7 +2,7 @@ import { existsSync, lstatSync, readFileSync } from 'node:fs';
2
2
  import { writeConfigAtomic, jsonFormat } from '../../commands/mcp-registration.js';
3
3
  import { join } from 'node:path';
4
4
  import { homedir } from 'node:os';
5
- import { addHqHooks, removeHqHooks } from '../install/claude-targets.js';
5
+ import { addHqHooks, removeHqHooks, shimPath } from '../install/claude-targets.js';
6
6
  import { legacyHookTarget } from '../install/hook-target.js';
7
7
  import { addCodexHooks, removeCodexHooks, codexHookEntry, codexHookTrustKeys } from '../install/codex-targets.js';
8
8
  import { engineArgs, isCoreNextEntry, isNativeEntry, registrationEngine } from './registration.js';
@@ -139,14 +139,15 @@ export function reconcileHookRegistrations(root, home = homedir(), env = process
139
139
  const launcher = registrationEngine(home, env);
140
140
  const native = coreNext ?? (launcher ? { engine: launcher } : null);
141
141
  const ours = (entry) => isNativeEntry(entry, root) || isCoreNextEntry(entry, root);
142
- // The shell target install would choose (the hqd shim when the daemon serves
143
- // this root). Resolved only when a registration is rewritten, so the
144
- // default-off path reads no daemon state.
145
- let shell;
146
- const shellTarget = () => (shell ??= legacyHookTarget(root, home, daemonInstalled, env));
142
+ // The shell target install would choose for each host: master-hook for
143
+ // Claude, the adapter for Codex, or the pinned launcher.
144
+ // Resolved only when a registration is rewritten, so the default-off path
145
+ // reads no daemon state.
146
+ const shell = {};
147
+ const shellTarget = (host = 'codex') => (shell[host] ??= legacyHookTarget(root, home, daemonInstalled, env, host));
147
148
  const globalTarget = (host) => {
148
149
  const next = host === 'codex' ? codexNext : claudeNext;
149
- return next ? { ...next, fallback: shellTarget() } : shellTarget();
150
+ return next ? { ...next, fallback: shellTarget(host) } : shellTarget(host);
150
151
  };
151
152
  const codexBash = (event) => [codexHookEntry(root, event, 'master').command, codexHookEntry(root, event, 'shim').command];
152
153
  // Claude Code project files: settings.json and the settings.local.json
@@ -170,7 +171,12 @@ export function reconcileHookRegistrations(root, home = homedir(), env = process
170
171
  const merge = (doc) => {
171
172
  if (!hooksOf(doc))
172
173
  return doc;
173
- if (!native && !allEntries(doc).some(ours))
174
+ // An entry on the hqd shim is rewritten even with the switch off: the
175
+ // shim alone skips master-hook's PreToolUse guards. Codex quotes the
176
+ // path with JSON.stringify, Claude with single quotes.
177
+ const onShim = (entry) => typeof entry.command === 'string'
178
+ && (entry.command.includes(JSON.stringify(shimPath(root))) || entry.command.includes(`'${shimPath(root)}'`));
179
+ if (!native && !allEntries(doc).some((entry) => ours(entry) || onShim(entry)))
174
180
  return doc;
175
181
  if (global) {
176
182
  if ((runtime === 'codex' ? removeCodexHooks(doc, root) : removeHqHooks(doc, root)) === doc)
@@ -1,5 +1,5 @@
1
1
  import { type CoreNextHost, type FallbackTarget } from '../../utils/host-registration.js';
2
- import { type HookTarget } from './claude-targets.js';
2
+ import type { HookTarget } from './claude-targets.js';
3
3
  /**
4
4
  * True when this user's hq daemon unit (launchd plist, systemd unit, or the
5
5
  * per-user Windows Scheduled Task) exists. On Windows the shared task an older
@@ -11,6 +11,16 @@ export declare function isDaemonInstalled(home: string, platform?: NodeJS.Platfo
11
11
  * the hqd shim; otherwise to master-hook.sh / the Codex adapter.
12
12
  */
13
13
  export declare function hookTargetFor(hqRoot: string, home: string, daemonInstalled?: boolean, env?: NodeJS.ProcessEnv, host?: CoreNextHost): HookTarget;
14
- /** The target with `core.next` off: the pinned launcher, the hqd shim, or master-hook.sh. */
15
- export declare function legacyHookTarget(hqRoot: string, home: string, daemonInstalled?: boolean, env?: NodeJS.ProcessEnv): FallbackTarget;
14
+ /**
15
+ * The target with `core.next` off: the pinned launcher, or master-hook.sh
16
+ * (the Codex adapter on Codex).
17
+ *
18
+ * No user-scope entry gets the bare hqd shim. The shim only forwards to hqd's
19
+ * policy.check, which runs the scope authorizer but none of master-hook's
20
+ * other PreToolUse guards (the credential guards among them), and with no
21
+ * socket it allows the call. master-hook still asks hqd through the shim when
22
+ * the daemon is up. The root, daemon and host arguments stay for callers; they
23
+ * no longer change the answer.
24
+ */
25
+ export declare function legacyHookTarget(_hqRoot: string, home: string, _daemonInstalled?: boolean, env?: NodeJS.ProcessEnv, _host?: CoreNextHost): FallbackTarget;
16
26
  //# sourceMappingURL=hook-target.d.ts.map
@@ -6,15 +6,11 @@
6
6
  import * as fs from 'node:fs';
7
7
  import * as path from 'node:path';
8
8
  import { spawnSync } from 'node:child_process';
9
- import { realpathOrSelf } from '../../commands/mcp-registration.js';
10
9
  import { DAEMON_LAUNCHD_LABEL, DAEMON_SYSTEMD_UNIT, SYSTEM_UNIT_DIR, currentWindowsIdentity, legacyWindowsTask, windowsTaskName } from '../daemon/install.js';
11
10
  import { defaultRunCommand } from '../service-manager/launchd.js';
12
- import { readDaemonConfig } from '../daemon/config.js';
13
- import { daemonPaths } from '../daemon/paths.js';
14
11
  import { registrationEngine } from '../hook-engine/registration.js';
15
12
  import { coreNextTargetOrWarn } from '../../utils/host-registration.js';
16
13
  import { forHost } from '../hook-engine/coverage.js';
17
- import { shimPath } from './claude-targets.js';
18
14
  /**
19
15
  * True when this user's hq daemon unit (launchd plist, systemd unit, or the
20
16
  * per-user Windows Scheduled Task) exists. On Windows the shared task an older
@@ -41,17 +37,24 @@ export function hookTargetFor(hqRoot, home, daemonInstalled, env = process.env,
41
37
  // is one warning, and install goes on with the flag-off target for every
42
38
  // event.
43
39
  const coreNext = forHost(coreNextTargetOrWarn(home, env), hqRoot, host, env);
44
- const fallback = legacyHookTarget(hqRoot, home, daemonInstalled, env);
40
+ const fallback = legacyHookTarget(hqRoot, home, daemonInstalled, env, host);
45
41
  return coreNext ? { ...coreNext, fallback } : fallback;
46
42
  }
47
- /** The target with `core.next` off: the pinned launcher, the hqd shim, or master-hook.sh. */
48
- export function legacyHookTarget(hqRoot, home, daemonInstalled, env = process.env) {
43
+ /**
44
+ * The target with `core.next` off: the pinned launcher, or master-hook.sh
45
+ * (the Codex adapter on Codex).
46
+ *
47
+ * No user-scope entry gets the bare hqd shim. The shim only forwards to hqd's
48
+ * policy.check, which runs the scope authorizer but none of master-hook's
49
+ * other PreToolUse guards (the credential guards among them), and with no
50
+ * socket it allows the call. master-hook still asks hqd through the shim when
51
+ * the daemon is up. The root, daemon and host arguments stay for callers; they
52
+ * no longer change the answer.
53
+ */
54
+ export function legacyHookTarget(_hqRoot, home, _daemonInstalled, env = process.env, _host = 'claude') {
49
55
  const engine = registrationEngine(home, env);
50
56
  if (engine)
51
57
  return { engine };
52
- const installed = daemonInstalled ?? isDaemonInstalled(home);
53
- const configuredRoot = readDaemonConfig(daemonPaths(home, env).configPath).hqRoot;
54
- const daemonMatchesRoot = configuredRoot !== undefined && realpathOrSelf(configuredRoot) === realpathOrSelf(hqRoot);
55
- return installed && daemonMatchesRoot && fs.existsSync(shimPath(hqRoot)) ? 'shim' : 'master';
58
+ return 'master';
56
59
  }
57
60
  //# sourceMappingURL=hook-target.js.map
@@ -43,7 +43,7 @@ export function spawnEnvelopeRepairViaCurrentCli(hqRoot, lane, input, deps = {})
43
43
  isLaneRunnerEntry(cliEntry)) {
44
44
  throw new LanesError("repair_cli_entry_invalid", "Lane watcher has no valid absolute hq CLI entrypoint for envelope repair", { lane_id: lane.lane_id });
45
45
  }
46
- const result = run(liveNodeBinary(), [cliEntry, "lanes", "_spawn-envelope-repair"], {
46
+ const result = run(liveNodeBinary(), [cliEntry, "runners", "_spawn-envelope-repair"], {
47
47
  encoding: "utf8",
48
48
  timeout: 120_000,
49
49
  input: JSON.stringify(request),
@@ -59,6 +59,8 @@ export declare function isMonitorTaskLive(task: MonitorTaskEvidence, now: Date):
59
59
  */
60
60
  export declare function expiredLaneIds(evidence: MonitorEvidence, now: Date): Set<string>;
61
61
  export declare function coveredLaneIds(evidence: MonitorEvidence, now: Date): Set<string>;
62
+ /** Every process command line on this host (`ps -eww -o args=`); empty when ps fails. */
63
+ export declare function defaultProcessCommands(): readonly string[];
62
64
  export declare function readLiveMonitorEvidence(sessionId: string, options?: LiveMonitorEvidenceOptions): MonitorEvidence;
63
65
  export type MonitorEvidenceReader = (sessionId: string) => MonitorEvidence | Promise<MonitorEvidence>;
64
66
  export declare function monitorReminderText(): string;
@@ -406,7 +406,8 @@ function taskOutputCandidates(transcriptPath, sessionId, task) {
406
406
  }
407
407
  return [...new Set(candidates)];
408
408
  }
409
- function defaultProcessCommands() {
409
+ /** Every process command line on this host (`ps -eww -o args=`); empty when ps fails. */
410
+ export function defaultProcessCommands() {
410
411
  try {
411
412
  const output = execFileSync("ps", ["-eww", "-o", "args="], {
412
413
  encoding: "utf8",
@@ -28,6 +28,12 @@ export interface ReadLanesFlagOptions {
28
28
  cacheDir?: string | null;
29
29
  retryBackoffMs?: number;
30
30
  sleep?: (ms: number) => Promise<void>;
31
+ /**
32
+ * Share one read per flag and company for the life of this process (the
33
+ * default, right for a CLI command). A long-lived process (the daemon) passes
34
+ * false so every call asks the registry again.
35
+ */
36
+ shareProcessRead?: boolean;
31
37
  }
32
38
  export declare function readLanesFlagLocalOverride(flagKey: string, env?: NodeJS.ProcessEnv): boolean | null;
33
39
  export type LanesRegistryFlagResult = {
@@ -185,9 +185,10 @@ async function readRegistryFlagOutcome(flagKey, options, failOpen) {
185
185
  }
186
186
  const endpoint = resolveFlagRegistryEndpoint(undefined, env);
187
187
  const key = cacheKey(flagKey, options.company, endpoint);
188
- const cached = registryReads.get(key);
188
+ const share = options.shareProcessRead !== false;
189
+ const cached = share ? registryReads.get(key) : undefined;
189
190
  const pending = cached ?? readRegistryValue(flagKey, endpoint, key, options);
190
- if (!cached)
191
+ if (!cached && share)
191
192
  registryReads.set(key, pending);
192
193
  const outcome = await pending;
193
194
  reportRegistryFailure(flagKey, key, outcome, options, failOpen);
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Repository merge hold records (`hq lanes hold`, src/commands/lanes-hold.ts):
3
+ * their location, their format and the parser that accepts or refuses one.
4
+ * Kept apart from the command so the daemon (merge-sections.ts) can read hold
5
+ * records without loading the lanes runtime.
6
+ */
7
+ import type { LaneCompanyRef } from "./types.js";
8
+ export declare const LANES_REPO_MERGE_HOLD_FLAG = "lanes.repo-merge-hold";
9
+ export declare const LANES_REVIEW_BEFORE_MERGE_FLAG = "lanes.review-before-merge";
10
+ export declare const REPO_MERGE_HOLDS_REL: string;
11
+ export declare const HOLD_SCHEMA_VERSION = "hq-lanes-repo-merge-hold.v1";
12
+ export declare const HOLD_HISTORY_CAP = 50;
13
+ export interface HoldHistoryEntry {
14
+ set_at: string;
15
+ until: string;
16
+ reason: string;
17
+ set_by_lane: string | null;
18
+ set_by_session: string | null;
19
+ released_at?: string;
20
+ released_reason?: string;
21
+ }
22
+ export interface RepoMergeHold {
23
+ schema_version: typeof HOLD_SCHEMA_VERSION;
24
+ repo: string;
25
+ company: LaneCompanyRef;
26
+ reason: string;
27
+ set_at: string;
28
+ until: string;
29
+ set_by_lane: string | null;
30
+ set_by_session: string | null;
31
+ released_at?: string;
32
+ released_reason?: string;
33
+ history: HoldHistoryEntry[];
34
+ }
35
+ /** `<hqRoot>/workspace/lanes/holds/<owner>__<repo>.json`. */
36
+ export declare function holdFilePath(hqRoot: string, repo: string): string;
37
+ /** A hold record as `hq lanes hold` accepts it; throws LanesError for any other value. */
38
+ export declare function parseHold(raw: unknown, file: string): RepoMergeHold;
39
+ //# sourceMappingURL=repo-merge-hold.d.ts.map
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Repository merge hold records (`hq lanes hold`, src/commands/lanes-hold.ts):
3
+ * their location, their format and the parser that accepts or refuses one.
4
+ * Kept apart from the command so the daemon (merge-sections.ts) can read hold
5
+ * records without loading the lanes runtime.
6
+ */
7
+ import * as path from "node:path";
8
+ import { LanesError } from "./errors.js";
9
+ import { canonicalRepo } from "./merge-command.js";
10
+ import { assertNoSecretText } from "./text-scan.js";
11
+ export const LANES_REPO_MERGE_HOLD_FLAG = "lanes.repo-merge-hold";
12
+ export const LANES_REVIEW_BEFORE_MERGE_FLAG = "lanes.review-before-merge";
13
+ export const REPO_MERGE_HOLDS_REL = path.join("workspace", "lanes", "holds");
14
+ export const HOLD_SCHEMA_VERSION = "hq-lanes-repo-merge-hold.v1";
15
+ export const HOLD_HISTORY_CAP = 50;
16
+ function fail(error, message, details = {}) {
17
+ throw new LanesError(error, message, details);
18
+ }
19
+ /** `<hqRoot>/workspace/lanes/holds/<owner>__<repo>.json`. */
20
+ export function holdFilePath(hqRoot, repo) {
21
+ const [owner, repository] = canonicalRepo(repo).split("/");
22
+ return path.join(hqRoot, REPO_MERGE_HOLDS_REL, `${owner}__${repository}.json`);
23
+ }
24
+ function isObject(value) {
25
+ return value !== null && typeof value === "object" && !Array.isArray(value);
26
+ }
27
+ function isCanonicalTimestamp(value) {
28
+ if (typeof value !== "string")
29
+ return false;
30
+ const timestamp = Date.parse(value);
31
+ return Number.isFinite(timestamp) && new Date(timestamp).toISOString() === value;
32
+ }
33
+ /** A hold record as `hq lanes hold` accepts it; throws LanesError for any other value. */
34
+ export function parseHold(raw, file) {
35
+ if (!isObject(raw))
36
+ return fail("repo_hold_invalid", "Merge hold record must be an object", { path: file });
37
+ const company = raw.company;
38
+ const history = raw.history;
39
+ if (raw.schema_version !== HOLD_SCHEMA_VERSION || typeof raw.repo !== "string" ||
40
+ !isObject(company) || typeof company.slug !== "string" || !company.slug.trim() ||
41
+ typeof company.uid !== "string" || !company.uid.trim() ||
42
+ typeof raw.reason !== "string" || !raw.reason.trim() ||
43
+ !isCanonicalTimestamp(raw.set_at) || !isCanonicalTimestamp(raw.until) ||
44
+ !(raw.set_by_lane === null || typeof raw.set_by_lane === "string") ||
45
+ !(raw.set_by_session === null || typeof raw.set_by_session === "string") ||
46
+ !Array.isArray(history) || history.length > HOLD_HISTORY_CAP ||
47
+ (raw.released_at !== undefined && !isCanonicalTimestamp(raw.released_at)) ||
48
+ (raw.released_reason !== undefined && typeof raw.released_reason !== "string")) {
49
+ return fail("repo_hold_invalid", "Merge hold record has invalid fields", { path: file });
50
+ }
51
+ let repo;
52
+ try {
53
+ repo = canonicalRepo(raw.repo);
54
+ }
55
+ catch {
56
+ return fail("repo_hold_invalid", "Merge hold record has an invalid repository", { path: file });
57
+ }
58
+ if (repo !== raw.repo)
59
+ return fail("repo_hold_invalid", "Merge hold repository is not canonical", { path: file });
60
+ if ((raw.released_at === undefined) !== (raw.released_reason === undefined)) {
61
+ return fail("repo_hold_invalid", "Released merge hold must include both release fields", { path: file });
62
+ }
63
+ if (raw.released_at !== undefined && (!raw.released_reason || !raw.released_reason.trim())) {
64
+ return fail("repo_hold_invalid", "Released merge hold is missing its reason", { path: file });
65
+ }
66
+ assertNoSecretText("hold.reason", raw.reason);
67
+ if (typeof raw.released_reason === "string")
68
+ assertNoSecretText("hold.released_reason", raw.released_reason);
69
+ for (const entry of history) {
70
+ if (!isObject(entry) || !isCanonicalTimestamp(entry.set_at) || !isCanonicalTimestamp(entry.until) ||
71
+ typeof entry.reason !== "string" || !entry.reason.trim() ||
72
+ !(entry.set_by_lane === null || typeof entry.set_by_lane === "string") ||
73
+ !(entry.set_by_session === null || typeof entry.set_by_session === "string") ||
74
+ (entry.released_at !== undefined && !isCanonicalTimestamp(entry.released_at)) ||
75
+ (entry.released_reason !== undefined && typeof entry.released_reason !== "string")) {
76
+ return fail("repo_hold_invalid", "Merge hold history has invalid entries", { path: file });
77
+ }
78
+ if ((entry.released_at === undefined) !== (entry.released_reason === undefined)) {
79
+ return fail("repo_hold_invalid", "Merge hold history release fields are incomplete", { path: file });
80
+ }
81
+ if (entry.released_reason !== undefined && !entry.released_reason.trim()) {
82
+ return fail("repo_hold_invalid", "Merge hold history release reason is empty", { path: file });
83
+ }
84
+ assertNoSecretText("hold.history.reason", entry.reason);
85
+ if (typeof entry.released_reason === "string")
86
+ assertNoSecretText("hold.history.released_reason", entry.released_reason);
87
+ }
88
+ return raw;
89
+ }
90
+ //# sourceMappingURL=repo-merge-hold.js.map
@@ -22,7 +22,7 @@ export function watcherMainDeps(hqRoot, laneId, env = process.env, repairDispatc
22
22
  spawnRepair: (root, lane, input) => spawnEnvelopeRepairViaCurrentCli(root, lane, input, { ...repairDispatchDeps, env }),
23
23
  deliverLaneSeniorMessage: async (seniorLaneId, text) => deliverLaneSeniorMessage(cliEntry, seniorLaneId, text),
24
24
  recoverQueuedMessages: async () => {
25
- const result = spawnSync(liveNodeBinary(), [cliEntry, "lanes", "_recover-queued-messages", laneId], {
25
+ const result = spawnSync(liveNodeBinary(), [cliEntry, "runners", "_recover-queued-messages", laneId], {
26
26
  env,
27
27
  encoding: "utf8",
28
28
  timeout: 120_000,
@@ -37,7 +37,7 @@ export function watcherMainDeps(hqRoot, laneId, env = process.env, repairDispatc
37
37
  await new Promise((resolve, reject) => {
38
38
  const child = spawn(liveNodeBinary(), [
39
39
  cliEntry,
40
- "lanes",
40
+ "runners",
41
41
  "_keep-alive-terminal-trigger",
42
42
  scheduledLaneId,
43
43
  String(version),
@@ -55,7 +55,7 @@ export function watcherMainDeps(hqRoot, laneId, env = process.env, repairDispatc
55
55
  };
56
56
  }
57
57
  function deliverLaneSeniorMessage(cliEntry, laneId, text) {
58
- const result = spawnSync(liveNodeBinary(), [cliEntry, "lanes", "message", laneId, "--text", text], {
58
+ const result = spawnSync(liveNodeBinary(), [cliEntry, "runners", "message", laneId, "--text", text], {
59
59
  env: process.env,
60
60
  encoding: "utf8",
61
61
  timeout: 120_000,
@@ -106,7 +106,7 @@ export function formatCliMismatchLine(input) {
106
106
  const recordedAt = recordedEntry || "(none)";
107
107
  const currentAt = input.currentEntry || "(none)";
108
108
  return (`daemon hq ${recordedLabel} at ${recordedAt} does not match this CLI ` +
109
- `${input.currentVersion} at ${currentAt}. Run hq mesh daemon install to repoint it.`);
109
+ `${input.currentVersion} at ${currentAt}. Run hq daemon install to repoint it.`);
110
110
  }
111
111
  export function formatCliIdentityLines(report) {
112
112
  const lines = [];
@@ -350,7 +350,7 @@ export function repairMeshUnitFromOtherHome(opts = {}) {
350
350
  repaired: true,
351
351
  action: "removed",
352
352
  from: other.from,
353
- message: `${found} Stopped it. Start the real one with: hq mesh daemon install`,
353
+ message: `${found} Stopped it. Start the real one with: hq daemon install`,
354
354
  };
355
355
  }
356
356
  const env = opts.env ?? process.env;
@@ -374,7 +374,7 @@ export function repairMeshUnitFromOtherHome(opts = {}) {
374
374
  repaired: false,
375
375
  action: "removed",
376
376
  from: other.from,
377
- message: `${found} Stopped it, but starting the real one failed: ${error instanceof Error ? error.message : String(error)}. Run: hq mesh daemon install`,
377
+ message: `${found} Stopped it, but starting the real one failed: ${error instanceof Error ? error.message : String(error)}. Run: hq daemon install`,
378
378
  };
379
379
  }
380
380
  }
@@ -171,27 +171,26 @@ function targetLookup(target) {
171
171
  /**
172
172
  * Reindex keeps pack skills at `.claude/skills/<pack>:<item>`. Recreating the
173
173
  * unprefixed table dest next to that wrapper duplicates names like `hooks`.
174
+ * Only this pack's own `<pack>:<item>` counts: another pack's or a company's
175
+ * `*:<item>` says nothing about whether this pack's skill is reachable.
174
176
  */
175
- function namespacedSkillHostExists(hqRoot, item) {
176
- const dir = path.join(hqRoot, '.claude', 'skills');
177
- let names;
177
+ function namespacedSkillHostExists(hqRoot, packName, item) {
178
178
  try {
179
- names = fs.readdirSync(dir);
179
+ fs.lstatSync(path.join(hqRoot, '.claude', 'skills', `${packName}:${item}`));
180
+ return true;
180
181
  }
181
182
  catch {
182
183
  return false;
183
184
  }
184
- const suffix = `:${item}`;
185
- return names.some((name) => name.endsWith(suffix));
186
185
  }
187
- function ensureSymlink(link, hqRoot, info, warn) {
186
+ function ensureSymlink(link, hqRoot, packName, info, warn) {
188
187
  if (!existsOrSymlink(link.src)) {
189
188
  warn(`payload missing: ${link.src} (declared but not shipped)`);
190
189
  return;
191
190
  }
192
191
  if (link.key === 'skills' &&
193
192
  path.basename(link.dst) === link.item &&
194
- namespacedSkillHostExists(hqRoot, link.item)) {
193
+ namespacedSkillHostExists(hqRoot, packName, link.item)) {
195
194
  info(`skipped ${link.dst} (namespaced skill wrapper already present)`);
196
195
  return;
197
196
  }
@@ -394,7 +393,7 @@ export function scanPackages(hqRoot, options = {}) {
394
393
  continue;
395
394
  }
396
395
  }
397
- ensureSymlink(link, hqRoot, info, warn);
396
+ ensureSymlink(link, hqRoot, name, info, warn);
398
397
  }
399
398
  }
400
399
  }
@@ -220,6 +220,14 @@ export declare function summaryRel(date: string): string;
220
220
  export declare function listCompanies(hqRoot: string): string[];
221
221
  /** Reads one knowledge preference. Throws SignalsConfigError when the script is missing or fails. */
222
222
  export declare function readPref(hqRoot: string, company: string, field: string, spawn: SpawnSyncFn): boolean;
223
+ /**
224
+ * The prefs-off rule: whether a run skips `company` because signals_capture and
225
+ * ontology_capture are both off on this computer. `runSignals` decides its
226
+ * `prefs-off` skip with this, and the bot's hot-signal-sync job asks it before
227
+ * choosing the engine (lib/bot/signals-engine-flag.ts), so the two cannot
228
+ * disagree. Throws SignalsConfigError when the settings cannot be read.
229
+ */
230
+ export declare function capturePrefsOff(hqRoot: string, company: string, spawn?: SpawnSyncFn): boolean;
223
231
  /** Coarse v2 kind for a step's detailed kind. */
224
232
  export declare function toRunErrorKind(kind: ErrorKind | undefined): RunErrorKind;
225
233
  /** Fills the v2 outcome fields of a finished record from its steps. */
@@ -167,6 +167,18 @@ export function readPref(hqRoot, company, field, spawn) {
167
167
  }
168
168
  return TRUE_VALUES.has(r.stdout.trim().toLowerCase());
169
169
  }
170
+ /**
171
+ * The prefs-off rule: whether a run skips `company` because signals_capture and
172
+ * ontology_capture are both off on this computer. `runSignals` decides its
173
+ * `prefs-off` skip with this, and the bot's hot-signal-sync job asks it before
174
+ * choosing the engine (lib/bot/signals-engine-flag.ts), so the two cannot
175
+ * disagree. Throws SignalsConfigError when the settings cannot be read.
176
+ */
177
+ export function capturePrefsOff(hqRoot, company, spawn = defaultSpawn) {
178
+ const signalsOn = readPref(hqRoot, company, "signals_capture", spawn);
179
+ const ontologyOn = readPref(hqRoot, company, "ontology_capture", spawn);
180
+ return !signalsOn && !ontologyOn;
181
+ }
170
182
  function readJson(hqRoot, rel) {
171
183
  const abs = path.join(hqRoot, rel);
172
184
  if (!fs.existsSync(abs))
@@ -452,11 +464,9 @@ export async function runSignals(opts) {
452
464
  record.jobRanAt = priorJobRanAt;
453
465
  // 3. Mark the run as running before any step.
454
466
  persist();
455
- let signalsOn;
456
- let ontologyOn;
467
+ let prefsOff;
457
468
  try {
458
- signalsOn = readPref(hqRoot, company, "signals_capture", spawn);
459
- ontologyOn = readPref(hqRoot, company, "ontology_capture", spawn);
469
+ prefsOff = capturePrefsOff(hqRoot, company, spawn);
460
470
  }
461
471
  catch (err) {
462
472
  if (!(err instanceof SignalsConfigError))
@@ -475,7 +485,7 @@ export async function runSignals(opts) {
475
485
  records.push(record);
476
486
  continue;
477
487
  }
478
- if (!signalsOn && !ontologyOn) {
488
+ if (prefsOff) {
479
489
  record.skipReason = "prefs-off";
480
490
  finish();
481
491
  records.push(record);
@@ -14,4 +14,22 @@ export interface ReadCompanyRolloutFlagOptions {
14
14
  export declare class RolloutFlagReadError extends Error {
15
15
  }
16
16
  export declare function readCompanyRolloutFlag(companyUid: string, token: string, options?: ReadCompanyRolloutFlagOptions): Promise<boolean>;
17
+ /**
18
+ * Company-wide parallel downloads for the new sync engine. Registry flags are
19
+ * booleans, so two keys form a ladder: `sync.parallel-downloads` alone means
20
+ * 8 streams, `sync.parallel-downloads-16` means 16 and wins over the first.
21
+ * Neither on means no company value (the engine default, off).
22
+ */
23
+ export declare const SYNC_PARALLEL_DOWNLOADS_FLAG = "sync.parallel-downloads";
24
+ export declare const SYNC_PARALLEL_DOWNLOADS_16_FLAG = "sync.parallel-downloads-16";
25
+ export declare const SYNC_PARALLEL_DOWNLOADS_FLAG_STREAMS = 8;
26
+ export declare const SYNC_PARALLEL_DOWNLOADS_16_FLAG_STREAMS = 16;
27
+ export declare class DownloadStreamsFlagReadError extends Error {
28
+ }
29
+ /**
30
+ * The company's download stream count from the flag registry, or undefined when
31
+ * neither key is on. Throws DownloadStreamsFlagReadError when the registry
32
+ * cannot be read, so the caller can keep the value it had.
33
+ */
34
+ export declare function readCompanyDownloadStreams(companyUid: string, token: string, options?: ReadCompanyRolloutFlagOptions): Promise<number | undefined>;
17
35
  //# sourceMappingURL=flag.d.ts.map
@@ -44,4 +44,70 @@ export async function readCompanyRolloutFlag(companyUid, token, options = {}) {
44
44
  }
45
45
  }
46
46
  }
47
+ /**
48
+ * Company-wide parallel downloads for the new sync engine. Registry flags are
49
+ * booleans, so two keys form a ladder: `sync.parallel-downloads` alone means
50
+ * 8 streams, `sync.parallel-downloads-16` means 16 and wins over the first.
51
+ * Neither on means no company value (the engine default, off).
52
+ */
53
+ export const SYNC_PARALLEL_DOWNLOADS_FLAG = "sync.parallel-downloads";
54
+ export const SYNC_PARALLEL_DOWNLOADS_16_FLAG = "sync.parallel-downloads-16";
55
+ export const SYNC_PARALLEL_DOWNLOADS_FLAG_STREAMS = 8;
56
+ export const SYNC_PARALLEL_DOWNLOADS_16_FLAG_STREAMS = 16;
57
+ export class DownloadStreamsFlagReadError extends Error {
58
+ }
59
+ /**
60
+ * The company's download stream count from the flag registry, or undefined when
61
+ * neither key is on. Throws DownloadStreamsFlagReadError when the registry
62
+ * cannot be read, so the caller can keep the value it had.
63
+ */
64
+ export async function readCompanyDownloadStreams(companyUid, token, options = {}) {
65
+ const env = options.env ?? process.env;
66
+ const override16 = readLocalOverride(SYNC_PARALLEL_DOWNLOADS_16_FLAG, env);
67
+ const override8 = readLocalOverride(SYNC_PARALLEL_DOWNLOADS_FLAG, env);
68
+ const fromValues = (on16, on8) => on16 ? SYNC_PARALLEL_DOWNLOADS_16_FLAG_STREAMS : on8 ? SYNC_PARALLEL_DOWNLOADS_FLAG_STREAMS : undefined;
69
+ if (override16 !== null && override8 !== null)
70
+ return fromValues(override16, override8);
71
+ let failure;
72
+ const onError = (error) => {
73
+ failure ??= error;
74
+ };
75
+ const fail = (error) => new DownloadStreamsFlagReadError(`could not read ${SYNC_PARALLEL_DOWNLOADS_FLAG} for ${companyUid}: ${error instanceof Error ? error.message : String(error)}`);
76
+ const client = (options.createClient ?? createFlagClient)({
77
+ endpoint: resolveFlagRegistryEndpoint(undefined, env),
78
+ getToken: () => token,
79
+ env: {},
80
+ refreshIntervalMs: 0,
81
+ requestTimeoutMs: READ_TIMEOUT_MS,
82
+ companyUid,
83
+ onError,
84
+ });
85
+ try {
86
+ await client.ready();
87
+ const on = (key, override) => {
88
+ if (override !== null)
89
+ return override;
90
+ const resolution = client.explain(key, { fallback: false });
91
+ return resolution.source === "snapshot" && resolution.value === true;
92
+ };
93
+ const on16 = on(SYNC_PARALLEL_DOWNLOADS_16_FLAG, override16);
94
+ const on8 = on(SYNC_PARALLEL_DOWNLOADS_FLAG, override8);
95
+ if (failure !== undefined)
96
+ throw fail(failure);
97
+ return fromValues(on16, on8);
98
+ }
99
+ catch (error) {
100
+ if (error instanceof DownloadStreamsFlagReadError)
101
+ throw error;
102
+ throw fail(error);
103
+ }
104
+ finally {
105
+ try {
106
+ client.close();
107
+ }
108
+ catch {
109
+ failure ??= undefined;
110
+ }
111
+ }
112
+ }
47
113
  //# sourceMappingURL=flag.js.map
@@ -13,6 +13,12 @@ export interface SyncCoreReconcileDeps {
13
13
  listMemberships: () => Promise<SyncCoreMembership[]>;
14
14
  resolvePersonUid: () => Promise<string | null>;
15
15
  readRolloutFlag: (companyUid: string) => Promise<boolean>;
16
+ /**
17
+ * The company's parallel download stream count from the flag registry, or
18
+ * undefined when the company has none. Throws when the registry cannot be
19
+ * read; the vault then keeps the value it had. Omitted: no company value.
20
+ */
21
+ readDownloadStreams?: (companyUid: string) => Promise<number | undefined>;
16
22
  ensureBinary: (release: string) => Promise<SyncCoreBinaryInstall>;
17
23
  /** A fixed release (tests). Otherwise readPin decides, then SYNC_CORE_RELEASE. */
18
24
  release?: string;
@@ -187,6 +187,20 @@ export async function reconcileSyncCore(deps) {
187
187
  : switchesBefore.offCompanies.has(vault.slug ?? "");
188
188
  const legacyAlreadyOff = wasFull ? before.legacyAlreadyOff === true : alreadyOff;
189
189
  const legacyOffSince = (wasFull && alreadyOff ? before.legacyOffSince : undefined) ?? at;
190
+ let downloadStreams;
191
+ if (vault.kind === "company" && deps.readDownloadStreams) {
192
+ try {
193
+ downloadStreams = await deps.readDownloadStreams(vault.uid);
194
+ }
195
+ catch (error) {
196
+ downloadStreams = before?.downloadStreams;
197
+ const keptValue = downloadStreams === undefined ? "no company download streams" : `${downloadStreams} download streams`;
198
+ warnings.push(`${message(error)}; keeping ${vault.slug ?? vault.uid} at ${keptValue}`);
199
+ }
200
+ if (downloadStreams !== before?.downloadStreams) {
201
+ log(`${vault.uid}: company download streams ${before?.downloadStreams ?? "none"} -> ${downloadStreams ?? "none"}`);
202
+ }
203
+ }
190
204
  const recorded = wasFull ? before.firstCycle : undefined;
191
205
  const firstCycle = recorded && recorded.planned > 0
192
206
  ? recorded
@@ -200,6 +214,7 @@ export async function reconcileSyncCore(deps) {
200
214
  legacyOffSince,
201
215
  ...(legacyAlreadyOff ? { legacyAlreadyOff: true } : {}),
202
216
  ...(firstCycle ? { firstCycle } : {}),
217
+ ...(downloadStreams !== undefined ? { downloadStreams } : {}),
203
218
  });
204
219
  if (firstCycle && firstCycle !== recorded && (!recorded || firstCycle.planned > 0))
205
220
  log(`${vault.uid}: first full cycle ${firstCycle.at}: ${firstCycle.planned} planned, ${firstCycle.completed} completed, ${firstCycle.held} held`);
@@ -8,6 +8,8 @@ export interface RolloutVault {
8
8
  legacyOffSince?: string;
9
9
  legacyAlreadyOff?: true;
10
10
  firstCycle?: SyncCoreFirstCycle;
11
+ /** Download streams from the company flag (sync.parallel-downloads[-16]); absent means no company value. */
12
+ downloadStreams?: number;
11
13
  }
12
14
  export interface SyncCoreRolloutState {
13
15
  version: 1;