@indigoai-us/hq-cli 5.345.7 → 5.345.9

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 (50) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/commands/__fixtures__/make-tar.d.ts +2 -10
  3. package/dist/commands/__fixtures__/make-tar.js +2 -2
  4. package/dist/commands/agent-enroll.d.ts +2 -3
  5. package/dist/commands/agent-enroll.js +2 -2
  6. package/dist/commands/lanes-message.js +100 -75
  7. package/dist/commands/mcp-status.d.ts +4 -3
  8. package/dist/commands/reindex.d.ts +0 -6
  9. package/dist/commands/reindex.js +1 -1
  10. package/dist/commands/safe-extract.d.ts +2 -17
  11. package/dist/commands/safe-extract.js +2 -2
  12. package/dist/commands/search.d.ts +2 -1
  13. package/dist/lazy-commands.d.ts +0 -6
  14. package/dist/lazy-commands.js +1 -1
  15. package/dist/lib/daemon/heartbeat.d.ts +0 -4
  16. package/dist/lib/daemon/heartbeat.js +3 -3
  17. package/dist/lib/daemon/run.d.ts +1 -1
  18. package/dist/lib/daemon/run.js +11 -2
  19. package/dist/lib/daemon/supervisor.js +2 -1
  20. package/dist/lib/doctor/__testing__/fake-hq-tree.d.ts +8 -9
  21. package/dist/lib/doctor/__testing__/fake-hq-tree.js +1 -1
  22. package/dist/lib/doctor/checks/anywhere.d.ts +3 -4
  23. package/dist/lib/doctor/checks/anywhere.js +2 -2
  24. package/dist/lib/doctor/checks/runtime-probe.d.ts +0 -21
  25. package/dist/lib/doctor/checks/runtime-probe.js +4 -4
  26. package/dist/lib/doctor/checks/sync-health.d.ts +2 -3
  27. package/dist/lib/doctor/checks/sync-health.js +1 -1
  28. package/dist/lib/doctor/compat.d.ts +2 -1
  29. package/dist/lib/doctor/deep/classify.d.ts +2 -1
  30. package/dist/lib/doctor/fix/backup.d.ts +0 -8
  31. package/dist/lib/doctor/fix/backup.js +2 -2
  32. package/dist/lib/doctor/fixtures/discover.d.ts +2 -10
  33. package/dist/lib/doctor/fixtures/discover.js +1 -1
  34. package/dist/lib/install/claude-targets.d.ts +0 -4
  35. package/dist/lib/install/claude-targets.js +3 -3
  36. package/dist/lib/install/codex-targets.d.ts +0 -9
  37. package/dist/lib/install/codex-targets.js +4 -4
  38. package/dist/lib/lanes/autopilot.d.ts +2 -17
  39. package/dist/lib/lanes/autopilot.js +8 -8
  40. package/dist/lib/lanes/flag-keys.d.ts +2 -0
  41. package/dist/lib/lanes/flag-keys.js +2 -0
  42. package/dist/lib/lanes/keep-alive.d.ts +2 -0
  43. package/dist/lib/lanes/keep-alive.js +9 -0
  44. package/dist/lib/lanes/reconcile.js +44 -27
  45. package/dist/lib/lanes/tracker-report.d.ts +16 -15
  46. package/dist/lib/lanes/wait.d.ts +2 -5
  47. package/dist/lib/lanes/wait.js +3 -3
  48. package/dist/lib/mesh/live/report-summary.d.ts +0 -10
  49. package/dist/lib/mesh/live/report-summary.js +5 -5
  50. package/package.json +1 -1
@@ -39,7 +39,7 @@ const EXECUTABLE_MODE = 0o755;
39
39
  const NON_EXECUTABLE_MODE = 0o644;
40
40
  const DEFAULT_PREFIX = "hq-doctor-fake-";
41
41
  /** The lifecycle events the shipped `.codex/config.toml` wires. */
42
- export const ADAPTER_DEFAULT_EVENTS = [
42
+ const ADAPTER_DEFAULT_EVENTS = [
43
43
  "SessionStart",
44
44
  "UserPromptSubmit",
45
45
  "PreToolUse",
@@ -9,8 +9,7 @@
9
9
  * on this machine the family reports a single NA line.
10
10
  */
11
11
  import { type HqdHealthResult } from "../../daemon/protocol.js";
12
- import type { CheckContext, CheckFamily, CheckResult } from "../types.js";
13
- export declare const ANYWHERE_FAMILY_ID = "anywhere";
12
+ import type { CheckFamily } from "../types.js";
14
13
  export declare const REMEDIATION: {
15
14
  readonly installClaude: "hq install --global --runtime claude";
16
15
  readonly installCodex: "hq install --global --runtime codex";
@@ -18,7 +17,7 @@ export declare const REMEDIATION: {
18
17
  readonly daemonRestart: "hq daemon restart --daemon";
19
18
  readonly link: "hq link <repo-dir> <company>";
20
19
  };
21
- export interface DaemonServiceState {
20
+ interface DaemonServiceState {
22
21
  installed: boolean;
23
22
  loaded: boolean;
24
23
  detail: string;
@@ -39,5 +38,5 @@ export interface AnywhereDeps {
39
38
  }
40
39
  export declare function createAnywhereFamily(deps?: AnywhereDeps): CheckFamily;
41
40
  export declare const anywhereFamily: CheckFamily;
42
- export declare function runAnywhereChecks(context: CheckContext, deps?: AnywhereDeps): Promise<CheckResult[]>;
41
+ export {};
43
42
  //# sourceMappingURL=anywhere.d.ts.map
@@ -24,7 +24,7 @@ import { DAEMON_LAUNCHD_LABEL, DAEMON_SYSTEMD_UNIT, DAEMON_WINDOWS_TASK } from "
24
24
  import { hqdSocketPath } from "../../daemon/protocol.js";
25
25
  import { readRegistry, registryDir, registryFile } from "../../registry/registry.js";
26
26
  import { anywhereRuntimeEnabled } from "../../../commands/anywhere-runtime-flag.js";
27
- export const ANYWHERE_FAMILY_ID = "anywhere";
27
+ const ANYWHERE_FAMILY_ID = "anywhere";
28
28
  export const REMEDIATION = {
29
29
  installClaude: "hq install --global --runtime claude",
30
30
  installCodex: "hq install --global --runtime codex",
@@ -39,7 +39,7 @@ export const anywhereFamily = createAnywhereFamily();
39
39
  function result(status, checkId, message, remediation, target) {
40
40
  return { status, checkId: `anywhere.${checkId}`, message, ...(remediation ? { remediation } : {}), ...(target ? { target } : {}) };
41
41
  }
42
- export async function runAnywhereChecks(context, deps = {}) {
42
+ async function runAnywhereChecks(context, deps = {}) {
43
43
  const home = deps.home ?? os.homedir();
44
44
  const env = deps.env ?? process.env;
45
45
  const socketPath = hqdSocketPath(home, env);
@@ -47,27 +47,6 @@ export declare const RUNTIME_PROBE_PREFIX = "hooks.runtime";
47
47
  * `check-hq-hooks.sh` (`LEDGER_DIR="$HQ_ROOT/workspace/orchestrator/policy-trigger-state"`).
48
48
  */
49
49
  export declare const POLICY_TRIGGER_LEDGER_RELPATH = "workspace/orchestrator/policy-trigger-state";
50
- /** The two lifecycle events `check-hq-hooks.sh` requires a command hook on. */
51
- export declare const REQUIRED_HOOK_EVENTS: readonly ["SessionStart", "PreToolUse"];
52
- /**
53
- * Default runtime marker path an agents-v2 (hq-fleet) box writes its runtime mode
54
- * to. Overridable via `HQ_RUNTIME_MARKER_FILE`, exactly as the shell reads
55
- * `${HQ_RUNTIME_MARKER_FILE:-/var/lib/hq-agent/runtime.json}`.
56
- */
57
- export declare const HQ_RUNTIME_MARKER_DEFAULT = "/var/lib/hq-agent/runtime.json";
58
- /**
59
- * Path (relative to the HQ root) of the on-box agents-v2 hook adapter. Its
60
- * presence under the tree is one of the two signals that the runtime is
61
- * agents-v2, mirroring `hq_runtime_mode` in `check-hq-hooks.sh`.
62
- */
63
- export declare const AGENTS_V2_ADAPTER_RELPATH = ".agents-v2-hooks/hq-agents-v2-hook-adapter.sh";
64
- /**
65
- * Default hours a policy-trigger ledger may age and still evidence a live
66
- * agents-v2 turn when no exact session id is given. Overridable via
67
- * `HQ_V2_LEDGER_MAX_AGE_HOURS`, matching the shell's
68
- * `HQ_V2_LEDGER_MAX_AGE_HOURS="${HQ_V2_LEDGER_MAX_AGE_HOURS:-24}"`.
69
- */
70
- export declare const HQ_V2_LEDGER_MAX_AGE_HOURS_DEFAULT = 24;
71
50
  /** Whether the ledger was found. Mirrors the script's `present`/`missing`. */
72
51
  export type LedgerState = "present" | "missing";
73
52
  /** Options for {@link reproduceCheckHqHooks}. */
@@ -51,26 +51,26 @@ export const RUNTIME_PROBE_PREFIX = "hooks.runtime";
51
51
  */
52
52
  export const POLICY_TRIGGER_LEDGER_RELPATH = "workspace/orchestrator/policy-trigger-state";
53
53
  /** The two lifecycle events `check-hq-hooks.sh` requires a command hook on. */
54
- export const REQUIRED_HOOK_EVENTS = ["SessionStart", "PreToolUse"];
54
+ const REQUIRED_HOOK_EVENTS = ["SessionStart", "PreToolUse"];
55
55
  /**
56
56
  * Default runtime marker path an agents-v2 (hq-fleet) box writes its runtime mode
57
57
  * to. Overridable via `HQ_RUNTIME_MARKER_FILE`, exactly as the shell reads
58
58
  * `${HQ_RUNTIME_MARKER_FILE:-/var/lib/hq-agent/runtime.json}`.
59
59
  */
60
- export const HQ_RUNTIME_MARKER_DEFAULT = "/var/lib/hq-agent/runtime.json";
60
+ const HQ_RUNTIME_MARKER_DEFAULT = "/var/lib/hq-agent/runtime.json";
61
61
  /**
62
62
  * Path (relative to the HQ root) of the on-box agents-v2 hook adapter. Its
63
63
  * presence under the tree is one of the two signals that the runtime is
64
64
  * agents-v2, mirroring `hq_runtime_mode` in `check-hq-hooks.sh`.
65
65
  */
66
- export const AGENTS_V2_ADAPTER_RELPATH = ".agents-v2-hooks/hq-agents-v2-hook-adapter.sh";
66
+ const AGENTS_V2_ADAPTER_RELPATH = ".agents-v2-hooks/hq-agents-v2-hook-adapter.sh";
67
67
  /**
68
68
  * Default hours a policy-trigger ledger may age and still evidence a live
69
69
  * agents-v2 turn when no exact session id is given. Overridable via
70
70
  * `HQ_V2_LEDGER_MAX_AGE_HOURS`, matching the shell's
71
71
  * `HQ_V2_LEDGER_MAX_AGE_HOURS="${HQ_V2_LEDGER_MAX_AGE_HOURS:-24}"`.
72
72
  */
73
- export const HQ_V2_LEDGER_MAX_AGE_HOURS_DEFAULT = 24;
73
+ const HQ_V2_LEDGER_MAX_AGE_HOURS_DEFAULT = 24;
74
74
  /**
75
75
  * Faithfully reproduce `core/scripts/check-hq-hooks.sh --require-ledger` in
76
76
  * TypeScript. The checks, in the script's order:
@@ -26,8 +26,6 @@
26
26
  import type { CheckContext, CheckFamily, CheckResult } from "../types.js";
27
27
  /** The id of the versions/sync family. */
28
28
  export declare const SYNC_FAMILY_ID = "sync";
29
- /** Human title for grouped output. */
30
- export declare const SYNC_FAMILY_TITLE = "Versions & sync";
31
29
  /**
32
30
  * A journal shard older than this is reported stale. Seven days: long enough
33
31
  * that a laptop shut over a weekend never warns, short enough that a silently
@@ -45,7 +43,7 @@ export interface SyncJournalSummary {
45
43
  };
46
44
  }
47
45
  /** The component versions this family reports. */
48
- export interface SyncVersionInfo {
46
+ interface SyncVersionInfo {
49
47
  cli: string;
50
48
  core: string | null;
51
49
  desktop: string | null;
@@ -128,4 +126,5 @@ export declare function semverGt(a: string, b: string): boolean;
128
126
  * something — the daemon, the network, the kill switch — is not running.
129
127
  */
130
128
  export declare const STALE_MANIFEST_THRESHOLD_MS: number;
129
+ export {};
131
130
  //# sourceMappingURL=sync-health.d.ts.map
@@ -38,7 +38,7 @@ import { readHqVersion } from "../../../utils/pack-contributions.js";
38
38
  /** The id of the versions/sync family. */
39
39
  export const SYNC_FAMILY_ID = "sync";
40
40
  /** Human title for grouped output. */
41
- export const SYNC_FAMILY_TITLE = "Versions & sync";
41
+ const SYNC_FAMILY_TITLE = "Versions & sync";
42
42
  /**
43
43
  * A journal shard older than this is reported stale. Seven days: long enough
44
44
  * that a laptop shut over a weekend never warns, short enough that a silently
@@ -36,7 +36,7 @@ export declare const CHECK_HQ_HOOKS_FAIL_EXIT = 2;
36
36
  * `HQ runtime enforcement: …` line. `NOT CHECKED` is the default when
37
37
  * `--require-ledger` was not passed (the wrapper prints "ledger: not checked").
38
38
  */
39
- export type RuntimeObservation = "OBSERVED" | "NOT OBSERVED" | "NOT CHECKED";
39
+ type RuntimeObservation = "OBSERVED" | "NOT OBSERVED" | "NOT CHECKED";
40
40
  /** The verdict the wrapper renders, derived from a scoped `hq doctor` run. */
41
41
  export interface CheckHqHooksVerdict {
42
42
  /** True iff the wrapper exits 0 (no in-scope failure, ledger observed when required). */
@@ -82,4 +82,5 @@ export interface DeriveVerdictOptions {
82
82
  * what lets `compat.test.ts` prove the wrapper and `hq doctor` agree.
83
83
  */
84
84
  export declare function deriveCheckHqHooksVerdict(doc: DoctorJsonDocument, options?: DeriveVerdictOptions): CheckHqHooksVerdict;
85
+ export {};
85
86
  //# sourceMappingURL=compat.d.ts.map
@@ -25,7 +25,7 @@
25
25
  */
26
26
  import type { HookFixture } from "../fixtures/schema.js";
27
27
  /** A hook's deep-test class: verifiable by verdict, or effect-bearing. */
28
- export type HookClass = "pure-guard" | "side-effecting";
28
+ type HookClass = "pure-guard" | "side-effecting";
29
29
  /**
30
30
  * Substrings that mark a hook id as belonging to a side-effecting family. This
31
31
  * is the seed set US-009 names — autocommit, checkpoint, journal, reindex — and
@@ -58,4 +58,5 @@ export declare function classifyFixture(fixture: HookFixture): Classification;
58
58
  export declare function isPureGuard(fixture: HookFixture): boolean;
59
59
  /** Whether a hook id names a side-effecting hook (US-009's execution surface). */
60
60
  export declare function isSideEffectingHookId(hookId: string): boolean;
61
+ export {};
61
62
  //# sourceMappingURL=classify.d.ts.map
@@ -11,8 +11,6 @@
11
11
  * The module is pure filesystem work with an injectable clock, so the applier's
12
12
  * tests get a deterministic backup directory name without racing the wall clock.
13
13
  */
14
- /** Where backups live under the resolved HQ root. */
15
- export declare const BACKUP_RELDIR: string;
16
14
  /** The result of a backup pass. */
17
15
  export interface BackupResult {
18
16
  /** Absolute path of the timestamped backup directory. */
@@ -22,12 +20,6 @@ export interface BackupResult {
22
20
  /** A single shell command that restores every backed-up file in place. */
23
21
  restoreCommand: string;
24
22
  }
25
- /**
26
- * A filesystem-safe backup directory name derived from an instant, e.g.
27
- * `2026-08-11T08-30-00-000Z`. Colons and dots — illegal or awkward in paths —
28
- * are replaced with dashes; the value stays sortable and unique per millisecond.
29
- */
30
- export declare function backupTimestamp(now?: Date): string;
31
23
  /**
32
24
  * Copy each of `relpaths` (relative to `hqRoot`) into a fresh timestamped backup
33
25
  * directory, preserving both the relative path structure and the file mode.
@@ -14,13 +14,13 @@
14
14
  import * as fs from "node:fs";
15
15
  import * as path from "node:path";
16
16
  /** Where backups live under the resolved HQ root. */
17
- export const BACKUP_RELDIR = path.join("workspace", "doctor", "backups");
17
+ const BACKUP_RELDIR = path.join("workspace", "doctor", "backups");
18
18
  /**
19
19
  * A filesystem-safe backup directory name derived from an instant, e.g.
20
20
  * `2026-08-11T08-30-00-000Z`. Colons and dots — illegal or awkward in paths —
21
21
  * are replaced with dashes; the value stays sortable and unique per millisecond.
22
22
  */
23
- export function backupTimestamp(now = new Date()) {
23
+ function backupTimestamp(now = new Date()) {
24
24
  return now.toISOString().replace(/[:.]/g, "-");
25
25
  }
26
26
  /**
@@ -28,8 +28,6 @@ import type { CheckContext, CheckFamily, CheckResult } from "../types.js";
28
28
  import { type ParsedFixture } from "./schema.js";
29
29
  /** Directory, relative to the HQ root, fixtures are discovered from. */
30
30
  export declare const HOOK_TESTS_RELDIR: string;
31
- /** The id of the fixture-coverage family. */
32
- export declare const FIXTURES_FAMILY_ID = "fixtures";
33
31
  /** checkId of the single coverage-ratio result the report surfaces in its summary. */
34
32
  export declare const FIXTURE_COVERAGE_CHECK_ID = "hooks.fixtures.coverage";
35
33
  /**
@@ -45,7 +43,7 @@ export declare const FIXTURE_COVERAGE_CHECK_ID = "hooks.fixtures.coverage";
45
43
  */
46
44
  export declare function registeredHookIds(hqRoot: string): string[];
47
45
  /** A fixture file located on disk and validated (or a YAML-load failure). */
48
- export interface DiscoveredFixture {
46
+ interface DiscoveredFixture {
49
47
  /** Path relative to the HQ root, e.g. `core/hook-tests/block-core-writes.yaml`. */
50
48
  relpath: string;
51
49
  /** Absolute path on disk. */
@@ -74,13 +72,6 @@ export interface FixtureDiscovery {
74
72
  * looksLikeFixture} are validated and reported.
75
73
  */
76
74
  export declare function discoverFixtures(hqRoot: string): FixtureDiscovery;
77
- /** The coverage tally: how many registered hooks have a usable fixture. */
78
- export interface FixtureCoverage {
79
- /** Registered hooks with a valid, recognised-version fixture. */
80
- tested: number;
81
- /** Registered hooks in total. */
82
- total: number;
83
- }
84
75
  /**
85
76
  * Run the fixture-coverage tier against the resolved tree: enumerate registered
86
77
  * hooks, discover fixtures, and emit UNTESTED / WARN / UNKNOWN results plus the
@@ -93,4 +84,5 @@ export declare function checkFixtureCoverage(context: CheckContext): CheckResult
93
84
  * registry contract).
94
85
  */
95
86
  export declare const fixtureCoverageFamily: CheckFamily;
87
+ export {};
96
88
  //# sourceMappingURL=discover.d.ts.map
@@ -32,7 +32,7 @@ import { looksLikeFixture, parseFixture, SUPPORTED_FIXTURE_SCHEMA_VERSIONS, } fr
32
32
  /** Directory, relative to the HQ root, fixtures are discovered from. */
33
33
  export const HOOK_TESTS_RELDIR = path.join("core", "hook-tests");
34
34
  /** The id of the fixture-coverage family. */
35
- export const FIXTURES_FAMILY_ID = "fixtures";
35
+ const FIXTURES_FAMILY_ID = "fixtures";
36
36
  /** checkId of the single coverage-ratio result the report surfaces in its summary. */
37
37
  export const FIXTURE_COVERAGE_CHECK_ID = "hooks.fixtures.coverage";
38
38
  /** A `*.yaml` file in `core/hook-tests/` that is not a fixture and must be skipped. */
@@ -1,5 +1,3 @@
1
- /** Events master-hook.sh is registered for at user scope. */
2
- export declare const GLOBAL_HOOK_EVENTS: readonly ["SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse", "Stop"];
3
1
  /** Name of the HQ MCP server entry in ~/.claude.json. */
4
2
  export declare const HQ_MCP_SERVER_NAME = "hq";
5
3
  /** `_hqPack` provenance stamped on the HQ MCP server entry. */
@@ -9,7 +7,6 @@ export declare const MCP_SUBPROCESS_PATH = "/opt/homebrew/bin:/usr/local/bin:/us
9
7
  /** Prefix for skill symlinks under ~/.claude/skills. */
10
8
  export declare const SKILL_LINK_PREFIX = "hq-";
11
9
  export declare const CLAUDE_MD_BEGIN = "<!-- hq-anywhere:begin (managed by `hq install --global`; remove with `hq uninstall --global`) -->";
12
- export declare const CLAUDE_MD_END = "<!-- hq-anywhere:end -->";
13
10
  export interface ClaudeTargets {
14
11
  hqPointer: string;
15
12
  claudeMd: string;
@@ -29,7 +26,6 @@ export declare function charterPath(hqRoot: string): string;
29
26
  export declare function hqSkillsSource(hqRoot: string): string;
30
27
  /** The exact hook command registered for one event (absolute path, quoted). */
31
28
  export declare function hookCommand(hqRoot: string, event: string, target?: HookTarget): string;
32
- export declare function claudeMdBlock(hqRoot: string): string;
33
29
  /** Append the block (replacing any prior HQ block). `null` input = file absent. */
34
30
  export declare function addClaudeMdBlock(current: string | null, hqRoot: string): string;
35
31
  /** Strip the HQ block, plus the separator `addClaudeMdBlock` put before it. */
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import * as path from 'path';
8
8
  /** Events master-hook.sh is registered for at user scope. */
9
- export const GLOBAL_HOOK_EVENTS = [
9
+ const GLOBAL_HOOK_EVENTS = [
10
10
  'SessionStart',
11
11
  'UserPromptSubmit',
12
12
  'PreToolUse',
@@ -22,7 +22,7 @@ export const MCP_SUBPROCESS_PATH = '/opt/homebrew/bin:/usr/local/bin:/usr/bin:/b
22
22
  /** Prefix for skill symlinks under ~/.claude/skills. */
23
23
  export const SKILL_LINK_PREFIX = 'hq-';
24
24
  export const CLAUDE_MD_BEGIN = '<!-- hq-anywhere:begin (managed by `hq install --global`; remove with `hq uninstall --global`) -->';
25
- export const CLAUDE_MD_END = '<!-- hq-anywhere:end -->';
25
+ const CLAUDE_MD_END = '<!-- hq-anywhere:end -->';
26
26
  export function claudeTargets(home) {
27
27
  return {
28
28
  hqPointer: path.join(home, '.hq', 'root'),
@@ -61,7 +61,7 @@ function shellQuote(value) {
61
61
  // ---------------------------------------------------------------------------
62
62
  // CLAUDE.md block.
63
63
  // ---------------------------------------------------------------------------
64
- export function claudeMdBlock(hqRoot) {
64
+ function claudeMdBlock(hqRoot) {
65
65
  return `${CLAUDE_MD_BEGIN}\n@${charterPath(hqRoot)}\n${CLAUDE_MD_END}\n`;
66
66
  }
67
67
  /** Append the block (replacing any prior HQ block). `null` input = file absent. */
@@ -1,8 +1,5 @@
1
1
  import { type HookTarget } from './claude-targets.js';
2
- /** Events the Codex hook adapter is registered for at user scope. */
3
- export declare const CODEX_HOOK_EVENTS: readonly ["SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse", "Stop", "SessionEnd"];
4
2
  export declare const AGENTS_MD_BEGIN = "<!-- hq-anywhere:begin (managed by `hq install --global --runtime codex`; remove with `hq uninstall --global --runtime codex`) -->";
5
- export declare const AGENTS_MD_END = "<!-- hq-anywhere:end -->";
6
3
  /** Name of the legacy ad-hoc skills mirror (~/.codex/skills/hq). */
7
4
  export declare const LEGACY_SKILLS_NAME = "hq";
8
5
  /** A directory carrying this file is HQ-owned and may be replaced. */
@@ -21,12 +18,6 @@ export declare function codexTargets(home: string): CodexTargets;
21
18
  export declare function codexAdapterPath(hqRoot: string): string;
22
19
  /** HQ's Codex charter: AGENTS.md at the HQ root, else the Claude charter. */
23
20
  export declare function codexCharterSource(hqRoot: string): string;
24
- /**
25
- * Hook command for every event. The adapter reads the event from
26
- * `hook_event_name` and falls back to its own $PWD when Codex sends no `cwd`.
27
- */
28
- export declare function codexHookCommand(hqRoot: string, target?: HookTarget): string;
29
- export declare function agentsMdBlock(charter: string): string;
30
21
  /** Append the block (replacing any prior HQ block). `null` input = file absent. */
31
22
  export declare function addAgentsMdBlock(current: string | null, charter: string): string;
32
23
  /** Strip the HQ block, plus the separator `addAgentsMdBlock` put before it. */
@@ -13,7 +13,7 @@ import * as fs from 'fs';
13
13
  import * as path from 'path';
14
14
  import { shimPath } from './claude-targets.js';
15
15
  /** Events the Codex hook adapter is registered for at user scope. */
16
- export const CODEX_HOOK_EVENTS = [
16
+ const CODEX_HOOK_EVENTS = [
17
17
  'SessionStart',
18
18
  'UserPromptSubmit',
19
19
  'PreToolUse',
@@ -22,7 +22,7 @@ export const CODEX_HOOK_EVENTS = [
22
22
  'SessionEnd',
23
23
  ];
24
24
  export const AGENTS_MD_BEGIN = '<!-- hq-anywhere:begin (managed by `hq install --global --runtime codex`; remove with `hq uninstall --global --runtime codex`) -->';
25
- export const AGENTS_MD_END = '<!-- hq-anywhere:end -->';
25
+ const AGENTS_MD_END = '<!-- hq-anywhere:end -->';
26
26
  /** Name of the legacy ad-hoc skills mirror (~/.codex/skills/hq). */
27
27
  export const LEGACY_SKILLS_NAME = 'hq';
28
28
  /** A directory carrying this file is HQ-owned and may be replaced. */
@@ -52,7 +52,7 @@ export function codexCharterSource(hqRoot) {
52
52
  * Hook command for every event. The adapter reads the event from
53
53
  * `hook_event_name` and falls back to its own $PWD when Codex sends no `cwd`.
54
54
  */
55
- export function codexHookCommand(hqRoot, target = 'master') {
55
+ function codexHookCommand(hqRoot, target = 'master') {
56
56
  if (target === 'shim')
57
57
  return `/bin/sh ${JSON.stringify(shimPath(hqRoot))} --runtime codex`;
58
58
  return `/bin/bash ${JSON.stringify(codexAdapterPath(hqRoot))}`;
@@ -60,7 +60,7 @@ export function codexHookCommand(hqRoot, target = 'master') {
60
60
  // ---------------------------------------------------------------------------
61
61
  // AGENTS.md block.
62
62
  // ---------------------------------------------------------------------------
63
- export function agentsMdBlock(charter) {
63
+ function agentsMdBlock(charter) {
64
64
  const body = charter.endsWith('\n') ? charter : `${charter}\n`;
65
65
  return `${AGENTS_MD_BEGIN}\n${body}${AGENTS_MD_END}\n`;
66
66
  }
@@ -2,22 +2,7 @@ import { readLanesRegistryFlag } from "./registry-flag.js";
2
2
  import type { LaneRecord } from "./types.js";
3
3
  export declare const LEAD_AUTOPILOT_FLAG = "lanes.lead-autopilot";
4
4
  export declare const LEAD_AUTOPILOT_MISSED_DEADLINE_ESCALATION_FLAG = "lanes.autopilot-missed-deadline-escalation";
5
- export declare const LEAD_AUTOPILOT_MISSED_DEADLINE_ESCALATION_DELAY_MS: number;
6
- export declare const LEAD_AUTOPILOT_NUDGE_REDELIVERY_DELAY_MS: number;
7
- export declare const LEAD_AUTOPILOT_NUDGE_STATE_RETENTION_MS: number;
8
- export declare const LEAD_AUTOPILOT_REVIEW_DELAY_MS: number;
9
- export declare const LEAD_AUTOPILOT_FILL_DELAY_MS: number;
10
- export declare const LEAD_AUTOPILOT_PROMPT_LOOP = "personal/knowledge/team-lead-operating-loop.md";
11
- export declare const LEAD_AUTOPILOT_KPI_STALE_AFTER_MINUTES = 55;
12
- export declare const LEAD_AUTOPILOT_HEADLINE_STALE_AFTER_MINUTES = 55;
13
- export interface RegisteredLead {
14
- team: string;
15
- lane: string;
16
- host: string;
17
- status: string;
18
- prd: string;
19
- }
20
- export type AutopilotCondition = "review_finished_worker" | "fill_grant" | "plan_free_slots" | "flat_kpi" | "stale_kpi" | "stale_headline" | "blocker_record_needs_update" | "project_ready_to_close" | "stale_worker_ledger" | "story_without_live_lane" | "missed_deadline";
5
+ type AutopilotCondition = "review_finished_worker" | "fill_grant" | "plan_free_slots" | "flat_kpi" | "stale_kpi" | "stale_headline" | "blocker_record_needs_update" | "project_ready_to_close" | "stale_worker_ledger" | "story_without_live_lane" | "missed_deadline";
21
6
  export interface AutopilotWake {
22
7
  condition: AutopilotCondition;
23
8
  lead_lane: string;
@@ -29,7 +14,7 @@ export interface AutopilotWake {
29
14
  /** Headline episode represented inside the KPI batch notice, if any. */
30
15
  headline_fingerprint?: string;
31
16
  }
32
- export interface AutopilotKpiStatus {
17
+ interface AutopilotKpiStatus {
33
18
  lead_lane: string;
34
19
  team: string;
35
20
  kpi: string;
@@ -12,15 +12,15 @@ import { readLanesRegistryFlag } from "./registry-flag.js";
12
12
  import { readAllLanes } from "./store.js";
13
13
  export const LEAD_AUTOPILOT_FLAG = "lanes.lead-autopilot";
14
14
  export const LEAD_AUTOPILOT_MISSED_DEADLINE_ESCALATION_FLAG = LANE_AUTOPILOT_MISSED_DEADLINE_ESCALATION_FLAG;
15
- export const LEAD_AUTOPILOT_MISSED_DEADLINE_ESCALATION_DELAY_MS = 60 * 60_000;
16
- export const LEAD_AUTOPILOT_NUDGE_REDELIVERY_DELAY_MS = 30 * 60_000;
17
- export const LEAD_AUTOPILOT_NUDGE_STATE_RETENTION_MS = 24 * 60 * 60_000;
15
+ const LEAD_AUTOPILOT_MISSED_DEADLINE_ESCALATION_DELAY_MS = 60 * 60_000;
16
+ const LEAD_AUTOPILOT_NUDGE_REDELIVERY_DELAY_MS = 30 * 60_000;
17
+ const LEAD_AUTOPILOT_NUDGE_STATE_RETENTION_MS = 24 * 60 * 60_000;
18
18
  const LEAD_AUTOPILOT_DELIVERED_ID_RETENTION_MS = 7 * 24 * 60 * 60_000;
19
- export const LEAD_AUTOPILOT_REVIEW_DELAY_MS = 15 * 60_000;
20
- export const LEAD_AUTOPILOT_FILL_DELAY_MS = 15 * 60_000;
21
- export const LEAD_AUTOPILOT_PROMPT_LOOP = "personal/knowledge/team-lead-operating-loop.md";
22
- export const LEAD_AUTOPILOT_KPI_STALE_AFTER_MINUTES = 55;
23
- export const LEAD_AUTOPILOT_HEADLINE_STALE_AFTER_MINUTES = 55;
19
+ const LEAD_AUTOPILOT_REVIEW_DELAY_MS = 15 * 60_000;
20
+ const LEAD_AUTOPILOT_FILL_DELAY_MS = 15 * 60_000;
21
+ const LEAD_AUTOPILOT_PROMPT_LOOP = "personal/knowledge/team-lead-operating-loop.md";
22
+ const LEAD_AUTOPILOT_KPI_STALE_AFTER_MINUTES = 55;
23
+ const LEAD_AUTOPILOT_HEADLINE_STALE_AFTER_MINUTES = 55;
24
24
  const LIVE_STATES = new Set(["running", "queued", "awaiting_input", "blocked"]);
25
25
  const OPEN_STORY_STATES = new Set(["todo", "queued", "in_progress", "review", "blocked"]);
26
26
  function isOpenProjectStory(story) {
@@ -16,6 +16,8 @@ export declare const LANE_AUTOPILOT_MISSED_DEADLINE_ESCALATION_FLAG = "lanes.aut
16
16
  export declare const LANE_MESSAGE_ROUTE_OWNER_HOST_FLAG = "lanes.message-route-owner-host";
17
17
  /** Enables stale manager-status KPI reporting and one-time lead nudges. */
18
18
  export declare const LEAD_AUTOPILOT_KPI_STALENESS_FLAG = "lanes.autopilot-kpi-staleness";
19
+ /** Enables precise scheduling and priority admission for due lead keep-alive wakes. */
20
+ export declare const LANE_KEEP_ALIVE_DUE_WAKE_PRECISE_FLAG = "lanes.keep-alive-due-wake-precise";
19
21
  /** Enables staleness notices for a registered lead's dashboard headline. */
20
22
  export declare const LEAD_AUTOPILOT_HEADLINE_STALENESS_FLAG = "lanes.autopilot-headline-staleness";
21
23
  /** Lets an Outpost's autopilot wake leads created on that Outpost, which record a local host. */
@@ -16,6 +16,8 @@ export const LANE_AUTOPILOT_MISSED_DEADLINE_ESCALATION_FLAG = "lanes.autopilot-m
16
16
  export const LANE_MESSAGE_ROUTE_OWNER_HOST_FLAG = "lanes.message-route-owner-host";
17
17
  /** Enables stale manager-status KPI reporting and one-time lead nudges. */
18
18
  export const LEAD_AUTOPILOT_KPI_STALENESS_FLAG = "lanes.autopilot-kpi-staleness";
19
+ /** Enables precise scheduling and priority admission for due lead keep-alive wakes. */
20
+ export const LANE_KEEP_ALIVE_DUE_WAKE_PRECISE_FLAG = "lanes.keep-alive-due-wake-precise";
19
21
  /** Enables staleness notices for a registered lead's dashboard headline. */
20
22
  export const LEAD_AUTOPILOT_HEADLINE_STALENESS_FLAG = "lanes.autopilot-headline-staleness";
21
23
  /** Lets an Outpost's autopilot wake leads created on that Outpost, which record a local host. */
@@ -44,6 +44,8 @@ export interface KeepAliveDoneEnvelope {
44
44
  }
45
45
  export type DoneKeepAliveVerdict = "eligible" | "standing_idle" | "story_complete" | "next_check_at";
46
46
  export declare function keepAliveNextCheckAtMs(value: unknown, nowMs: number, anchorMs?: number): number | undefined;
47
+ /** Shared due-time decision for pre-admission ordering and the resume path. */
48
+ export declare function dueKeepAliveNextCheckMs(nextCheckMs: number, nowMs: number, anchorMs: number, preciseDueWakeEnabled: boolean): number | undefined;
47
49
  /** Shared done-state policy used by watch, reconcile, and the show command. */
48
50
  export declare function doneKeepAliveVerdict(lane: Pick<LaneRecord, "keep_alive_standing">, envelope: KeepAliveDoneEnvelope, hasQueuedWork: boolean, options?: {
49
51
  hasPendingWork?: boolean;
@@ -113,6 +113,15 @@ export function keepAliveNextCheckAtMs(value, nowMs, anchorMs = nowMs) {
113
113
  const capped = Math.min(parsed, stableAnchorMs + LEAD_LANE_KEEP_ALIVE_NEXT_CHECK_MAX_DELAY_MS);
114
114
  return capped > nowMs ? capped : undefined;
115
115
  }
116
+ /** Shared due-time decision for pre-admission ordering and the resume path. */
117
+ export function dueKeepAliveNextCheckMs(nextCheckMs, nowMs, anchorMs, preciseDueWakeEnabled) {
118
+ if (!Number.isFinite(nextCheckMs) || !Number.isFinite(nowMs) || !Number.isFinite(anchorMs))
119
+ return undefined;
120
+ const capped = Math.min(nextCheckMs, anchorMs + LEAD_LANE_KEEP_ALIVE_NEXT_CHECK_MAX_DELAY_MS);
121
+ if (capped > nowMs || (preciseDueWakeEnabled && capped <= anchorMs))
122
+ return undefined;
123
+ return capped;
124
+ }
116
125
  /** Shared done-state policy used by watch, reconcile, and the show command. */
117
126
  export function doneKeepAliveVerdict(lane, envelope, hasQueuedWork, options = {}) {
118
127
  if (envelope.decision !== "done")