@indigoai-us/hq-cli 5.126.0 → 5.127.0

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 (76) hide show
  1. package/CHANGELOG.md +211 -0
  2. package/assets/lanes-hooks/hq-lanes-drain.json +15 -0
  3. package/assets/lanes-hooks/hq-lanes-drain.mjs +254 -0
  4. package/assets/lanes-hooks/hq-lanes-drain.sh +21 -0
  5. package/assets/lanes-reconcile/hq-lanes-reconcile.service +11 -0
  6. package/assets/lanes-reconcile/hq-lanes-reconcile.timer +12 -0
  7. package/dist/command-catalog.generated.d.ts +245 -11
  8. package/dist/command-catalog.generated.js +323 -11
  9. package/dist/command-registration-plan.d.ts +1 -0
  10. package/dist/command-registration-plan.js +11 -2
  11. package/dist/commands/agents.d.ts +12 -0
  12. package/dist/commands/agents.js +46 -2
  13. package/dist/commands/lanes.d.ts +55 -16
  14. package/dist/commands/lanes.js +1187 -250
  15. package/dist/commands/mesh.js +254 -19
  16. package/dist/lib/lanes/accounts.d.ts +67 -7
  17. package/dist/lib/lanes/accounts.js +233 -43
  18. package/dist/lib/lanes/compaction.d.ts +96 -0
  19. package/dist/lib/lanes/compaction.js +197 -0
  20. package/dist/lib/lanes/config.d.ts +15 -0
  21. package/dist/lib/lanes/config.js +65 -8
  22. package/dist/lib/lanes/delivery.d.ts +151 -0
  23. package/dist/lib/lanes/delivery.js +354 -0
  24. package/dist/lib/lanes/dropbox.d.ts +96 -0
  25. package/dist/lib/lanes/dropbox.js +408 -0
  26. package/dist/lib/lanes/effort.d.ts +50 -0
  27. package/dist/lib/lanes/effort.js +109 -0
  28. package/dist/lib/lanes/errors.d.ts +2 -2
  29. package/dist/lib/lanes/hooks-install.d.ts +81 -0
  30. package/dist/lib/lanes/hooks-install.js +326 -0
  31. package/dist/lib/lanes/hq-root.d.ts +19 -0
  32. package/dist/lib/lanes/hq-root.js +28 -0
  33. package/dist/lib/lanes/index.d.ts +35 -5
  34. package/dist/lib/lanes/index.js +19 -4
  35. package/dist/lib/lanes/liveness.d.ts +7 -1
  36. package/dist/lib/lanes/liveness.js +64 -5
  37. package/dist/lib/lanes/machine-identity.d.ts +34 -0
  38. package/dist/lib/lanes/machine-identity.js +92 -0
  39. package/dist/lib/lanes/mesh-events.d.ts +109 -0
  40. package/dist/lib/lanes/mesh-events.js +275 -0
  41. package/dist/lib/lanes/outpost-dispatch.d.ts +65 -0
  42. package/dist/lib/lanes/outpost-dispatch.js +90 -0
  43. package/dist/lib/lanes/questions.d.ts +75 -0
  44. package/dist/lib/lanes/questions.js +243 -0
  45. package/dist/lib/lanes/quota.d.ts +95 -0
  46. package/dist/lib/lanes/quota.js +320 -0
  47. package/dist/lib/lanes/reconcile-install.d.ts +69 -0
  48. package/dist/lib/lanes/reconcile-install.js +221 -0
  49. package/dist/lib/lanes/reconcile.d.ts +102 -0
  50. package/dist/lib/lanes/reconcile.js +985 -0
  51. package/dist/lib/lanes/registry.d.ts +18 -5
  52. package/dist/lib/lanes/registry.js +293 -19
  53. package/dist/lib/lanes/spawn.d.ts +274 -0
  54. package/dist/lib/lanes/spawn.js +1363 -0
  55. package/dist/lib/lanes/store.d.ts +7 -3
  56. package/dist/lib/lanes/store.js +150 -32
  57. package/dist/lib/lanes/types.d.ts +346 -4
  58. package/dist/lib/lanes/types.js +138 -5
  59. package/dist/lib/lanes/watcher-main.d.ts +9 -0
  60. package/dist/lib/lanes/watcher-main.js +22 -0
  61. package/dist/lib/lanes/watcher.d.ts +216 -0
  62. package/dist/lib/lanes/watcher.js +859 -0
  63. package/dist/lib/mesh/api.d.ts +71 -7
  64. package/dist/lib/mesh/api.js +167 -28
  65. package/dist/lib/mesh/live/backfill-held.d.ts +18 -7
  66. package/dist/lib/mesh/live/backfill-held.js +66 -21
  67. package/dist/lib/mesh/live/daemon/run.d.ts +2 -0
  68. package/dist/lib/mesh/live/daemon/run.js +111 -54
  69. package/dist/lib/mesh/live/daemon/state.d.ts +2 -0
  70. package/dist/lib/mesh/live/daemon/transcript-watch.d.ts +3 -0
  71. package/dist/lib/mesh/live/daemon/transcript-watch.js +31 -8
  72. package/dist/lib/scan-packages/index.d.ts +2 -0
  73. package/dist/lib/scan-packages/index.js +1 -1
  74. package/dist/lib/work-context/state.d.ts +12 -0
  75. package/dist/lib/work-context/state.js +131 -3
  76. package/package.json +3 -1
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Install and register the lane-resolving drain hook in a provider home.
3
+ *
4
+ * Copying the hook files into `<home>/hooks/` is only half of an install. Each
5
+ * provider discovers hooks differently, and a file the provider never reads
6
+ * registers nothing:
7
+ *
8
+ * - grok reads every `*.json` under `$GROK_HOME/hooks/`, so the registration
9
+ * file in that directory is the registration.
10
+ * - claude reads `$CLAUDE_CONFIG_DIR/settings.json` and nothing under
11
+ * `hooks/`. The registration is merged into the `hooks.PreToolUse` array of
12
+ * that file.
13
+ * - codex reads `$CODEX_HOME/config.toml` (`[[hooks.PreToolUse]]`, gated by
14
+ * `[features] hooks = true`). The registration is appended to that file.
15
+ *
16
+ * Every registration merge keeps what the operator already has and is a
17
+ * no-op when the entry is present, because this runs on every spawn.
18
+ * Never merges into hq-hq-bridge.json / hq-hq-bridge.sh.
19
+ */
20
+ import type { LaneProvider } from "./types.js";
21
+ export declare const DRAIN_HOOK_BASENAME = "hq-lanes-drain";
22
+ export declare const DRAIN_HOOK_TIMEOUT_SECONDS = 30;
23
+ export declare function lanesHookAssetsDir(): string;
24
+ export declare const DRAIN_HOOK_REGISTRATION_KINDS: readonly ["hooks_dir", "settings_json", "config_toml"];
25
+ export type DrainHookRegistrationKind = (typeof DRAIN_HOOK_REGISTRATION_KINDS)[number];
26
+ export declare const PROVIDER_REGISTRATION_KIND: Record<LaneProvider, DrainHookRegistrationKind>;
27
+ export interface DrainHookRegistration {
28
+ kind: DrainHookRegistrationKind;
29
+ /** The file the provider CLI reads the registration from. */
30
+ path: string;
31
+ /** The exact command string registered, as the provider will execute it. */
32
+ command: string;
33
+ /** True when this call wrote the registration; false when it was already present. */
34
+ changed: boolean;
35
+ }
36
+ export interface DrainHookInstallResult {
37
+ provider: LaneProvider;
38
+ home: string;
39
+ hooksDir: string;
40
+ files: string[];
41
+ registration: DrainHookRegistration;
42
+ }
43
+ export declare function drainHookCommand(shPath: string): string;
44
+ export declare function drainHookShPath(providerHome: string): string;
45
+ export declare function renderDrainHookJson(shPath: string): string;
46
+ export interface MergeResult {
47
+ text: string;
48
+ changed: boolean;
49
+ }
50
+ /**
51
+ * Claude Code: `settings.json` is the one file it reads hooks from. Merge the
52
+ * drain into `hooks.PreToolUse`, keep every other key and every other hook,
53
+ * and do nothing when a command hook with this exact command string is
54
+ * already in the list. No `matcher` means every tool call.
55
+ */
56
+ export declare function mergeClaudeSettingsHook(existingText: string | null, command: string, settingsPath: string): MergeResult;
57
+ /**
58
+ * Codex: hooks come from `config.toml` in the codex home. The drain is
59
+ * appended as one `[[hooks.PreToolUse]]` table and `[features] hooks = true`
60
+ * is ensured. Edits are textual so comments and unrelated tables are kept
61
+ * byte for byte; the result is re-parsed and must contain the registration,
62
+ * otherwise nothing is written.
63
+ */
64
+ export declare function mergeCodexConfigHook(existingText: string | null, command: string, configPath: string): MergeResult;
65
+ export declare function drainHookRegistrationPath(provider: LaneProvider, providerHome: string): string;
66
+ export interface DrainHookRegistrationProbe {
67
+ kind: DrainHookRegistrationKind;
68
+ path: string;
69
+ command: string;
70
+ /** True when the provider's own registration file carries the drain command. */
71
+ registered: boolean;
72
+ /** For claude and codex: whether the registration file exists at all. */
73
+ file_present: boolean;
74
+ }
75
+ /**
76
+ * Read the registration back the way the provider CLI would find it. Reports
77
+ * the state of the file only; it does not prove the provider honours it.
78
+ */
79
+ export declare function probeDrainHookRegistration(provider: LaneProvider, providerHome: string): DrainHookRegistrationProbe;
80
+ export declare function installDrainHook(provider: LaneProvider, providerHome: string, assetsDir?: string): DrainHookInstallResult;
81
+ //# sourceMappingURL=hooks-install.d.ts.map
@@ -0,0 +1,326 @@
1
+ /**
2
+ * Install and register the lane-resolving drain hook in a provider home.
3
+ *
4
+ * Copying the hook files into `<home>/hooks/` is only half of an install. Each
5
+ * provider discovers hooks differently, and a file the provider never reads
6
+ * registers nothing:
7
+ *
8
+ * - grok reads every `*.json` under `$GROK_HOME/hooks/`, so the registration
9
+ * file in that directory is the registration.
10
+ * - claude reads `$CLAUDE_CONFIG_DIR/settings.json` and nothing under
11
+ * `hooks/`. The registration is merged into the `hooks.PreToolUse` array of
12
+ * that file.
13
+ * - codex reads `$CODEX_HOME/config.toml` (`[[hooks.PreToolUse]]`, gated by
14
+ * `[features] hooks = true`). The registration is appended to that file.
15
+ *
16
+ * Every registration merge keeps what the operator already has and is a
17
+ * no-op when the entry is present, because this runs on every spawn.
18
+ * Never merges into hq-hq-bridge.json / hq-hq-bridge.sh.
19
+ */
20
+ import * as fs from "node:fs";
21
+ import * as path from "node:path";
22
+ import { fileURLToPath } from "node:url";
23
+ import { parse as parseToml, TomlError } from "smol-toml";
24
+ import { LanesError } from "./errors.js";
25
+ import { parseLaneProvider } from "./types.js";
26
+ export const DRAIN_HOOK_BASENAME = "hq-lanes-drain";
27
+ export const DRAIN_HOOK_TIMEOUT_SECONDS = 30;
28
+ export function lanesHookAssetsDir() {
29
+ return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../../assets/lanes-hooks");
30
+ }
31
+ export const DRAIN_HOOK_REGISTRATION_KINDS = [
32
+ "hooks_dir",
33
+ "settings_json",
34
+ "config_toml",
35
+ ];
36
+ export const PROVIDER_REGISTRATION_KIND = {
37
+ claude: "settings_json",
38
+ codex: "config_toml",
39
+ grok: "hooks_dir",
40
+ };
41
+ export function drainHookCommand(shPath) {
42
+ return `bash ${shPath}`;
43
+ }
44
+ export function drainHookShPath(providerHome) {
45
+ return path.join(providerHome, "hooks", `${DRAIN_HOOK_BASENAME}.sh`);
46
+ }
47
+ function writeIfChanged(dest, contents, mode) {
48
+ try {
49
+ const existing = fs.readFileSync(dest);
50
+ const next = Buffer.isBuffer(contents) ? contents : Buffer.from(contents);
51
+ if (existing.equals(next))
52
+ return false;
53
+ }
54
+ catch (err) {
55
+ const code = err.code;
56
+ if (code !== "ENOENT")
57
+ throw err;
58
+ }
59
+ const tmp = `${dest}.${process.pid}.${Date.now()}.tmp`;
60
+ fs.writeFileSync(tmp, contents);
61
+ if (mode !== undefined)
62
+ fs.chmodSync(tmp, mode);
63
+ fs.renameSync(tmp, dest);
64
+ return true;
65
+ }
66
+ function readTextIfExists(filePath) {
67
+ try {
68
+ return fs.readFileSync(filePath, "utf8");
69
+ }
70
+ catch (err) {
71
+ const code = err.code;
72
+ if (code === "ENOENT")
73
+ return null;
74
+ throw err;
75
+ }
76
+ }
77
+ function isPlainObject(value) {
78
+ return typeof value === "object" && value !== null && !Array.isArray(value);
79
+ }
80
+ /** One `{ hooks: [{ type: "command", command }] }` group carries the drain command. */
81
+ function groupsContainCommand(groups, command) {
82
+ if (!Array.isArray(groups))
83
+ return false;
84
+ return groups.some((group) => {
85
+ if (!isPlainObject(group) || !Array.isArray(group.hooks))
86
+ return false;
87
+ return group.hooks.some((hook) => isPlainObject(hook) && hook.type === "command" && hook.command === command);
88
+ });
89
+ }
90
+ export function renderDrainHookJson(shPath) {
91
+ return `${JSON.stringify({
92
+ hooks: {
93
+ PreToolUse: [
94
+ {
95
+ hooks: [
96
+ {
97
+ type: "command",
98
+ command: drainHookCommand(shPath),
99
+ timeout: DRAIN_HOOK_TIMEOUT_SECONDS,
100
+ },
101
+ ],
102
+ },
103
+ ],
104
+ },
105
+ }, null, 2)}\n`;
106
+ }
107
+ /**
108
+ * Claude Code: `settings.json` is the one file it reads hooks from. Merge the
109
+ * drain into `hooks.PreToolUse`, keep every other key and every other hook,
110
+ * and do nothing when a command hook with this exact command string is
111
+ * already in the list. No `matcher` means every tool call.
112
+ */
113
+ export function mergeClaudeSettingsHook(existingText, command, settingsPath) {
114
+ let root = {};
115
+ if (existingText !== null && existingText.trim() !== "") {
116
+ try {
117
+ root = JSON.parse(existingText);
118
+ }
119
+ catch (err) {
120
+ throw new LanesError("settings_unparseable", `${settingsPath} is not valid JSON; refusing to rewrite it: ${err instanceof Error ? err.message : String(err)}`, { path: settingsPath });
121
+ }
122
+ }
123
+ if (!isPlainObject(root)) {
124
+ throw new LanesError("settings_unparseable", `${settingsPath} must hold a JSON object; refusing to rewrite it`, { path: settingsPath });
125
+ }
126
+ const hooks = root.hooks === undefined ? {} : root.hooks;
127
+ if (!isPlainObject(hooks)) {
128
+ throw new LanesError("settings_unparseable", `${settingsPath} has a non-object "hooks" key; refusing to rewrite it`, { path: settingsPath });
129
+ }
130
+ const pre = hooks.PreToolUse === undefined ? [] : hooks.PreToolUse;
131
+ if (!Array.isArray(pre)) {
132
+ throw new LanesError("settings_unparseable", `${settingsPath} has a non-array "hooks.PreToolUse"; refusing to rewrite it`, { path: settingsPath });
133
+ }
134
+ if (groupsContainCommand(pre, command)) {
135
+ return { text: existingText ?? "", changed: false };
136
+ }
137
+ const nextPre = [
138
+ ...pre,
139
+ {
140
+ hooks: [
141
+ { type: "command", command, timeout: DRAIN_HOOK_TIMEOUT_SECONDS },
142
+ ],
143
+ },
144
+ ];
145
+ const nextRoot = { ...root, hooks: { ...hooks, PreToolUse: nextPre } };
146
+ return { text: `${JSON.stringify(nextRoot, null, 2)}\n`, changed: true };
147
+ }
148
+ function tomlBasicString(value) {
149
+ // JSON string escapes are a subset of TOML basic-string escapes for the
150
+ // characters a filesystem path can contain.
151
+ return JSON.stringify(value);
152
+ }
153
+ function tomlHooksFeatureEnabled(parsed) {
154
+ return isPlainObject(parsed.features) && parsed.features.hooks === true;
155
+ }
156
+ function tomlHasCommand(parsed, command) {
157
+ return isPlainObject(parsed.hooks) && groupsContainCommand(parsed.hooks.PreToolUse, command);
158
+ }
159
+ function parseTomlOrThrow(text, configPath, stage) {
160
+ let parsed;
161
+ try {
162
+ parsed = parseToml(text);
163
+ }
164
+ catch (err) {
165
+ const detail = err instanceof TomlError || err instanceof Error ? err.message : String(err);
166
+ throw new LanesError("config_toml_unparseable", `${configPath} is not valid TOML (${stage}); refusing to rewrite it: ${detail}`, { path: configPath, stage });
167
+ }
168
+ if (!isPlainObject(parsed)) {
169
+ throw new LanesError("config_toml_unparseable", `${configPath} did not parse to a table (${stage}); refusing to rewrite it`, { path: configPath, stage });
170
+ }
171
+ return parsed;
172
+ }
173
+ /**
174
+ * Set `hooks = true` inside `[features]` by editing lines, so the operator's
175
+ * comments and layout survive. A `[features]` header that exists gets the
176
+ * key inserted (or an existing `hooks =` line replaced); a missing header is
177
+ * appended. An inline `features = { ... }` table cannot be edited this way;
178
+ * the re-parse post-condition in the caller reports that case.
179
+ */
180
+ function enableTomlHooksFeature(text) {
181
+ const lines = text.split("\n");
182
+ const header = lines.findIndex((line) => /^\s*\[features\]\s*(#.*)?$/.test(line));
183
+ if (header === -1) {
184
+ const sep = text === "" || text.endsWith("\n") ? "" : "\n";
185
+ return `${text}${sep}\n[features]\nhooks = true\n`;
186
+ }
187
+ for (let i = header + 1; i < lines.length; i += 1) {
188
+ const line = lines[i];
189
+ if (/^\s*\[/.test(line))
190
+ break;
191
+ if (/^\s*hooks\s*=/.test(line)) {
192
+ lines[i] = "hooks = true";
193
+ return lines.join("\n");
194
+ }
195
+ }
196
+ lines.splice(header + 1, 0, "hooks = true");
197
+ return lines.join("\n");
198
+ }
199
+ /**
200
+ * Codex: hooks come from `config.toml` in the codex home. The drain is
201
+ * appended as one `[[hooks.PreToolUse]]` table and `[features] hooks = true`
202
+ * is ensured. Edits are textual so comments and unrelated tables are kept
203
+ * byte for byte; the result is re-parsed and must contain the registration,
204
+ * otherwise nothing is written.
205
+ */
206
+ export function mergeCodexConfigHook(existingText, command, configPath) {
207
+ const original = existingText ?? "";
208
+ const parsed = parseTomlOrThrow(original, configPath, "before merge");
209
+ const hasCommand = tomlHasCommand(parsed, command);
210
+ const featureOn = tomlHooksFeatureEnabled(parsed);
211
+ if (hasCommand && featureOn) {
212
+ return { text: original, changed: false };
213
+ }
214
+ let text = original;
215
+ if (!featureOn)
216
+ text = enableTomlHooksFeature(text);
217
+ if (!hasCommand) {
218
+ const sep = text === "" || text.endsWith("\n") ? "" : "\n";
219
+ text =
220
+ `${text}${sep}\n` +
221
+ `# hq lanes: drop-box drain for lane workers (no-op unless HQ_LANE_ID is set)\n` +
222
+ `[[hooks.PreToolUse]]\n` +
223
+ `matcher = ".*"\n\n` +
224
+ `[[hooks.PreToolUse.hooks]]\n` +
225
+ `type = "command"\n` +
226
+ `command = ${tomlBasicString(command)}\n` +
227
+ `timeout = ${DRAIN_HOOK_TIMEOUT_SECONDS}\n`;
228
+ }
229
+ const check = parseTomlOrThrow(text, configPath, "after merge");
230
+ if (!tomlHasCommand(check, command) || !tomlHooksFeatureEnabled(check)) {
231
+ throw new LanesError("config_toml_merge_failed", `Merged ${configPath} does not carry the drain registration; refusing to write it`, { path: configPath, command });
232
+ }
233
+ return { text, changed: true };
234
+ }
235
+ export function drainHookRegistrationPath(provider, providerHome) {
236
+ switch (PROVIDER_REGISTRATION_KIND[provider]) {
237
+ case "hooks_dir":
238
+ return path.join(providerHome, "hooks", `${DRAIN_HOOK_BASENAME}.json`);
239
+ case "settings_json":
240
+ return path.join(providerHome, "settings.json");
241
+ case "config_toml":
242
+ return path.join(providerHome, "config.toml");
243
+ }
244
+ }
245
+ /**
246
+ * Read the registration back the way the provider CLI would find it. Reports
247
+ * the state of the file only; it does not prove the provider honours it.
248
+ */
249
+ export function probeDrainHookRegistration(provider, providerHome) {
250
+ const parsed = parseLaneProvider(provider);
251
+ const kind = PROVIDER_REGISTRATION_KIND[parsed];
252
+ const regPath = drainHookRegistrationPath(parsed, providerHome);
253
+ const command = drainHookCommand(drainHookShPath(providerHome));
254
+ const text = readTextIfExists(regPath);
255
+ const base = { kind, path: regPath, command, file_present: text !== null };
256
+ if (text === null)
257
+ return { ...base, registered: false };
258
+ try {
259
+ if (kind === "config_toml") {
260
+ const toml = parseToml(text);
261
+ return {
262
+ ...base,
263
+ registered: isPlainObject(toml) && tomlHasCommand(toml, command) && tomlHooksFeatureEnabled(toml),
264
+ };
265
+ }
266
+ const json = JSON.parse(text);
267
+ return {
268
+ ...base,
269
+ registered: isPlainObject(json) &&
270
+ isPlainObject(json.hooks) &&
271
+ groupsContainCommand(json.hooks.PreToolUse, command),
272
+ };
273
+ }
274
+ catch (err) {
275
+ process.stderr.write(`hq lanes: registration file ${regPath} is unreadable as ${kind}: ${err instanceof Error ? err.message : String(err)}\n`);
276
+ return { ...base, registered: false };
277
+ }
278
+ }
279
+ function registerDrainHook(provider, providerHome, shPath) {
280
+ const kind = PROVIDER_REGISTRATION_KIND[provider];
281
+ const regPath = drainHookRegistrationPath(provider, providerHome);
282
+ const command = drainHookCommand(shPath);
283
+ if (kind === "hooks_dir") {
284
+ const changed = writeIfChanged(regPath, renderDrainHookJson(shPath), 0o644);
285
+ return { kind, path: regPath, command, changed };
286
+ }
287
+ const existing = readTextIfExists(regPath);
288
+ const merged = kind === "settings_json"
289
+ ? mergeClaudeSettingsHook(existing, command, regPath)
290
+ : mergeCodexConfigHook(existing, command, regPath);
291
+ if (!merged.changed) {
292
+ return { kind, path: regPath, command, changed: false };
293
+ }
294
+ const tmp = `${regPath}.${process.pid}.${Date.now()}.tmp`;
295
+ fs.writeFileSync(tmp, merged.text, { mode: 0o600 });
296
+ try {
297
+ if (existing !== null)
298
+ fs.chmodSync(tmp, fs.statSync(regPath).mode & 0o777);
299
+ fs.renameSync(tmp, regPath);
300
+ }
301
+ catch (err) {
302
+ fs.rmSync(tmp, { force: true });
303
+ throw err;
304
+ }
305
+ return { kind, path: regPath, command, changed: true };
306
+ }
307
+ export function installDrainHook(provider, providerHome, assetsDir = lanesHookAssetsDir()) {
308
+ const parsed = parseLaneProvider(provider);
309
+ const hooksDir = path.join(providerHome, "hooks");
310
+ fs.mkdirSync(hooksDir, { recursive: true });
311
+ const shDest = drainHookShPath(providerHome);
312
+ const mjsDest = path.join(hooksDir, `${DRAIN_HOOK_BASENAME}.mjs`);
313
+ writeIfChanged(shDest, fs.readFileSync(path.join(assetsDir, `${DRAIN_HOOK_BASENAME}.sh`)), 0o755);
314
+ writeIfChanged(mjsDest, fs.readFileSync(path.join(assetsDir, `${DRAIN_HOOK_BASENAME}.mjs`)), 0o755);
315
+ const registration = registerDrainHook(parsed, providerHome, shDest);
316
+ const files = [shDest, mjsDest];
317
+ if (registration.kind === "hooks_dir") {
318
+ files.push(registration.path);
319
+ }
320
+ else {
321
+ // A registration-shaped file the provider never reads is how this bug hid.
322
+ fs.rmSync(path.join(hooksDir, `${DRAIN_HOOK_BASENAME}.json`), { force: true });
323
+ }
324
+ return { provider: parsed, home: providerHome, hooksDir, files, registration };
325
+ }
326
+ //# sourceMappingURL=hooks-install.js.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * HQ-root resolution for `hq lanes` only (not a global findHqRoot change).
3
+ *
4
+ * `findHqRoot` walks for `.claude` or `workers` and ignores `$HQ_ROOT`. Every
5
+ * git worktree under `workspace/worktrees/` has its own `.claude`, so a
6
+ * `lanes` command run from a worktree silently operates on an empty store.
7
+ * The drain hook, watcher, and reconcile timer already read `$HQ_ROOT`.
8
+ *
9
+ * Precedence: `$HQ_ROOT` → `$CLAUDE_PROJECT_DIR` → walk up with `isHqRoot`
10
+ * (`companies/` plus `.claude`|`core`|`personal`). A `.claude`-only worktree
11
+ * is never a match. Missing both an explicit root and a real HQ tree is an
12
+ * error — never an empty successful list against the wrong directory.
13
+ */
14
+ export interface LanesHqRootOpts {
15
+ env?: NodeJS.ProcessEnv;
16
+ cwd?: string;
17
+ }
18
+ export declare function resolveLanesHqRoot(opts?: LanesHqRootOpts): string;
19
+ //# sourceMappingURL=hq-root.d.ts.map
@@ -0,0 +1,28 @@
1
+ /**
2
+ * HQ-root resolution for `hq lanes` only (not a global findHqRoot change).
3
+ *
4
+ * `findHqRoot` walks for `.claude` or `workers` and ignores `$HQ_ROOT`. Every
5
+ * git worktree under `workspace/worktrees/` has its own `.claude`, so a
6
+ * `lanes` command run from a worktree silently operates on an empty store.
7
+ * The drain hook, watcher, and reconcile timer already read `$HQ_ROOT`.
8
+ *
9
+ * Precedence: `$HQ_ROOT` → `$CLAUDE_PROJECT_DIR` → walk up with `isHqRoot`
10
+ * (`companies/` plus `.claude`|`core`|`personal`). A `.claude`-only worktree
11
+ * is never a match. Missing both an explicit root and a real HQ tree is an
12
+ * error — never an empty successful list against the wrong directory.
13
+ */
14
+ import { resolveLiveRoot } from "../../utils/hq-roots.js";
15
+ import { LanesError } from "./errors.js";
16
+ export function resolveLanesHqRoot(opts = {}) {
17
+ try {
18
+ return resolveLiveRoot({
19
+ env: opts.env ?? process.env,
20
+ cwd: opts.cwd,
21
+ });
22
+ }
23
+ catch (err) {
24
+ const message = err instanceof Error ? err.message : String(err);
25
+ throw new LanesError("hq_root_unresolved", message, {});
26
+ }
27
+ }
28
+ //# sourceMappingURL=hq-root.js.map
@@ -4,16 +4,46 @@
4
4
  export { AccountResolutionError, LaneNotFoundError, LaneSchemaError, LaneVersionConflict, LanesConfigError, LanesError, WorkerResolutionError, isLaneVersionConflict, isLanesError, } from "./errors.js";
5
5
  export { CONFIG_SCHEMA_VERSION, ENVELOPE_DECISIONS, ENVELOPE_SCHEMA_VERSION, HISTORY_CAP, HOST_KINDS, LANE_PROVIDERS, LANE_SCHEMA_VERSION, LANE_STATES, LIVENESS_STATES, QUESTION_BODY_STORES, QUESTION_SCHEMA_VERSION, QUESTION_STATUSES, QUEUED_REASONS, RAISED_VIA, ROUTING_REASONS, SENIOR_KINDS, STORY_STATUSES, TERMINAL_LANE_STATES, isEnvelopeDecision, isHostKind, isLaneProvider, isLaneState, isLivenessState, isQuestionStatus, isSeniorKind, isTerminalLaneState, parseLaneEnvelope, parseLaneProvider, parseLaneState, parseLivenessState, parseMajorSchema, parseQuestionStatus, parseSeniorKind, } from "./types.js";
6
6
  export type { AccountConfig, AttributionHistoryEntry, EnvelopeDecision, EnvelopeQuestion, HostKind, LaneCompanyRef, LaneEnvelope, LaneHost, LaneProvider, LaneRecord, LaneState, LanesConfig, LastEnvelopeRef, LivenessState, LivenessWindows, ProviderConfig, QuestionAnswer, QuestionBodyRef, QuestionRecord, QuestionStatus, QueuedReason, RaisedVia, RoutingHistoryEntry, RoutingReason, SeniorHistoryEntry, SeniorKind, SeniorRef, StoryStatus, TerminalLaneState, ThrottleConfig, } from "./types.js";
7
- export { DEFAULT_ACCOUNT_HOMES, DEFAULT_CPU_BUSY_PAUSE, DEFAULT_CPU_BUSY_RESUME, DEFAULT_LIVE_WITHIN_MS, DEFAULT_LIVENESS_WINDOWS, DEFAULT_MAX_QUEUED, DEFAULT_MIN_AVAILABLE_MEM_MB, DEFAULT_PROVIDER_MAX_RUNNING, DEFAULT_SILENT_LOST_MS, DEFAULT_TURN_START_LOST_MS, LANES_CONFIG_REL, accountMaxRunning, canonicalizeHome, documentedDefaultConfig, expandHome, lanesConfigPath, loadLanesConfig, parseLanesConfig, writeLanesConfig, } from "./config.js";
7
+ export { DEFAULT_ACCOUNT_HOMES, DEFAULT_COMPACT_AFTER_MS, DEFAULT_CPU_BUSY_PAUSE, DEFAULT_CPU_BUSY_RESUME, DEFAULT_LIVE_WITHIN_MS, DEFAULT_LIVENESS_WINDOWS, DEFAULT_MAX_QUEUED, DEFAULT_MIN_AVAILABLE_MEM_MB, DEFAULT_PROVIDER_MAX_RUNNING, DEFAULT_SILENT_LOST_MS, DEFAULT_TURN_START_LOST_MS, LANES_CONFIG_REL, accountMaxRunning, canonicalizeHome, documentedDefaultConfig, expandHome, lanesConfigPath, loadLanesConfig, parseLanesConfig, providerCompactAfterMs, writeLanesConfig, } from "./config.js";
8
8
  export type { ConfigLoadDeps, ConfigWriteDeps } from "./config.js";
9
- export { LANES_STORE_REL, LANE_RECORDS_DIR, PENDING_INDEX_DIR, QUESTION_RECORDS_DIR, appendCappedHistory, appendLaneAttribution, appendLaneSeniorHistory, appendQuestionRouting, createLane, createQuestion, isConflictSidecarName, laneRecordPath, lanesStoreRoot, listLaneIds, listQuestionIds, mergeLaneRecords, mergeQuestionRecords, mintLaneId, mintQuestionId, parseLaneRecord, parseQuestionRecord, pendingMarkerPath, questionRecordPath, readLane, readQuestion, resolveStoreHqRoot, sanitizeHostComponent, tryReadLane, tryReadQuestion, updateLane, updateQuestion, } from "./store.js";
9
+ export { resolveLanesHqRoot } from "./hq-root.js";
10
+ export type { LanesHqRootOpts } from "./hq-root.js";
11
+ export { buildOutpostPickupCommand, parseOutpostPickupPayload, } from "./outpost-dispatch.js";
12
+ export type { OutpostDispatchResult, OutpostPickupPayload, } from "./outpost-dispatch.js";
13
+ export { LANES_STORE_REL, LANE_RECORDS_DIR, PENDING_INDEX_DIR, QUESTION_RECORDS_DIR, appendCappedHistory, appendLaneAttribution, appendLaneSeniorHistory, appendQuestionRouting, createLane, createQuestion, isConflictSidecarName, laneRecordPath, lanesStoreRoot, listLaneIds, listQuestionIds, mergeLaneRecords, mergeQuestionRecords, mintLaneId, mintQuestionId, parseLaneRecord, parseQuestionRecord, pendingMarkerPath, questionRecordPath, readLane, readQuestion, resolveStoreHqRoot, sanitizeHostComponent, tryReadLane, tryReadQuestion, retryUpdateLane, retryUpdateQuestion, updateLane, updateQuestion, } from "./store.js";
10
14
  export type { StoreDeps } from "./store.js";
15
+ export { IMDS_HOST, IMDS_INSTANCE_ID_URL, IMDS_TIMEOUT_MS, IMDS_TOKEN_URL, defaultReadImdsInstanceId, resolveMachineIdentity, } from "./machine-identity.js";
16
+ export type { MachineIdentity, MachineIdentityDeps } from "./machine-identity.js";
17
+ export { LANES_RUNS_REL as SPAWN_LANES_RUNS_REL, PID_LIVENESS_DECISIONS, PROVIDER_COMMAND, PROVIDER_MODEL_FLAG, SPAWN_TERMINAL_REASONS, ANSWERED_QUESTIONS_FILE, appendModelFlag, armLaneWatcher, buildProviderCommand, parseCliModel, resolveLaneModel, defaultProveDetached, isPidRecordAlive, laneRunDir, missingPidProbe, nextEnvelopePath, markSpawnFailure, parsePidRecord, parseProcStat, parseSpawnTerminalReason, probePidRecord, readPidRecord, readProcStarttime, readProcStarttimeDetailed, readSpawnManifest, resumePrompt, envelopeInstruction, spawnLaneWorker, stopLaneProcesses, watcherMainPath, workerEnv, } from "./spawn.js";
18
+ export type { DetachProof, DetachedSpawnOptions, KillProcessFn, PidLivenessDecision, PidLivenessProbe, PidRecord, ProveDetachedDeps, ProveDetachedFn, SpawnLaneDeps, SpawnProcessFn, SpawnTerminalReason, StopLaneDeps, StopLaneResult, } from "./spawn.js";
19
+ export { SILENCE_MS, WATCHER_DECISION_EVENTS, WATCHER_OUT_MAX_BYTES, WATCHER_POLL_MS, WATCHER_SIGNAL_KINDS, appendCappedLog, appendWatcherSignal, applyTerminalToLane, classifyLaneExit, clearLaneStalled, isPidAlive, laneIdentityFromRecord, markLaneStalled, notifySlotFreed, parseWatcherSignalKind, readLatestEnvelope, runWatcherLoop, stalledReason, tickWatcher, watcherEventsPath, watcherLastSignalPath, watcherOutLogPath, writeWatcherDecision, } from "./watcher.js";
20
+ export type { TerminalClassification, WatcherDecisionEvent, WatcherLoopDeps, WatcherSignal, WatcherSignalKind, WatcherTickInput, WatcherTickResult, } from "./watcher.js";
21
+ export { ENVELOPE_INVALID_REASON, decideEnvelopeRepair, emitMeshSoft, envelopeQuestionIds, readLatestEnvelopeFile, readLatestEnvelopeRecord, } from "./watcher.js";
22
+ export type { EnvelopeRepairDecision, LatestEnvelopeFile } from "./watcher.js";
23
+ export { LANE_MESH_EVENTS, WIRE_EVENT_KINDS, createLaneMesh, emitLaneDecisionEvents, emitLaneProgressEvent, laneCanEmit, parseLaneMeshEvent, progressEventDue, toWireThreadEvent, } from "./mesh-events.js";
24
+ export type { CreateLaneMeshOptions, LaneMesh, LaneMeshEvent, WireEventKind, WireThreadEvent, } from "./mesh-events.js";
11
25
  export { CPU_SAMPLE_MS, LANES_CPU_BUSY_OVERRIDE, LANES_CPU_CHECK, PROC_MEMINFO, STARVATION_MAX_DEFERRALS, STARVATION_MAX_MS, applyThrottleDecision, busyFractionFromDeltas, cpuTimesSnapshot, decideAdmission, defaultThrottleDeps, emptyThrottleState, evaluateThrottle, isCpuCheckEnabled, parseMemAvailableKb, readAvailableMemMb, readThrottleState, resolveCpuBusyFraction, sampleCpuBusyFraction, starvationBoundReached, throttleStatePath, writeThrottleState, } from "./throttle.js";
12
26
  export type { CpuTimes, ThrottleAdmitReason, ThrottleDecision, ThrottleDeferReason, ThrottleDeps, ThrottleState, } from "./throttle.js";
13
- export { AUTH_JSON_NAME, PROVIDER_HOME_ENV, accountEnv, accountStatus, authJsonPath, listAccountStatuses, resolveAccount, } from "./accounts.js";
14
- export type { AccountStatus, ResolvedAccount } from "./accounts.js";
15
- export { LIVE_WITHIN_MS, LIVENESS_EVENT_KINDS, SILENT_LOST_MS, TURN_START_LOST_MS, buildLivenessIndexFromSpool, classifySessionLiveness, defaultLivenessDeps, defaultSpoolPath, ingestSpoolLine, listSessionLiveness, livenessIndexPath, loadLivenessIndex, readLivenessIndex, rebuildLivenessIndex, sessionLiveness, } from "./liveness.js";
27
+ export { AUTH_JSON_NAME, CLAUDE_CREDENTIALS_NAME, PROVIDER_CREDENTIAL_FILES, PROVIDER_HOME_ENV, accountEnv, accountStatus, authJsonPath, authStateFor, credentialPaths, hasCredentialFile, isCredentialProven, isLoggedOut, isOccupyingLaneState, lastStartedAt, listAccountStatuses, occupyingLaneCount, resolveAccount, runningLaneCount, selectBalancedAccount, } from "./accounts.js";
28
+ export type { AccountResolveContext, AccountStatus, AuthState, ResolvedAccount, } from "./accounts.js";
29
+ export { LIVE_WITHIN_MS, LIVENESS_EVENT_KINDS, SILENT_LOST_MS, TURN_START_LOST_MS, buildLivenessIndexFromSpool, classifySessionLiveness, defaultLivenessDeps, defaultSpoolPath, ingestSpoolLine, listSessionLiveness, livenessIndexPath, loadLivenessIndex, readDaemonPresenceConnected, readLivenessIndex, rebuildLivenessIndex, sessionLiveness, } from "./liveness.js";
16
30
  export type { LivenessDeps, LivenessEventKind, LivenessIndex, SessionIndexEntry, } from "./liveness.js";
31
+ export { DEAD_HOST_MS, MAX_AGED_ADVANCES, QUESTION_AGE_MS, RECONCILE_TIMER_NAME, RECONCILE_UNIT_NAME, agedAdvanceCount, currentHopStartedAtMs, isDeadlinePassed, laneRunsHere, readTimeoutDeadline, reconcileHeartbeatPath, resolveQuestionAudience, runReconcilePass, shouldAdvanceAudienceEnded, shouldAgeQuestion, timeoutPath, } from "./reconcile.js";
32
+ export type { ReconcileChange, ReconcileDeps, ReconcileHost, ReconcileSkip, ReconcileSummary, } from "./reconcile.js";
33
+ export { RECONCILE_TIMER_INTERVAL, defaultSystemdUserDir, installReconcileTimer, providerPathEnv, renderReconcileService, renderReconcileTimer, uninstallReconcileTimer, } from "./reconcile-install.js";
34
+ export type { ReconcileInstallOpts, ReconcileInstallResult, RunCommand, RunCommandResult, } from "./reconcile-install.js";
17
35
  export { WORKER_REGISTRY_REL, personalWorkerDir, personalWorkerExists, readWorkerRegistryFile, registryPath, resolveContextBasePaths, resolveLaneWorker, resolveSkillFiles, tenancyFromRegistryPath, } from "./registry.js";
18
36
  export type { RegistryWorkerEntry, ResolvedLaneWorker, WorkerTenancy, WorkerYaml, } from "./registry.js";
37
+ export { bodyStoreForLane, envelopeQuestionId, parseQuestionBodyStore, questionBodyAbsPath, questionBodyRef, raiseEnvelopeQuestions, raiseLaneQuestion, sha256Text, writeQuestionBody, } from "./questions.js";
38
+ export type { QuestionBody, RaiseLaneQuestionInput } from "./questions.js";
39
+ export { LANE_DELIVERY_MECHANISMS, LAUNCH_TRIGGERS, PROVIDER_SESSION_RESUME, RESUMABLE_LANE_STATES, RESUME_COMMAND_STATES, SESSION_ID_ABSENT_REASONS, claimableStatesFor, deliveryRefusalReason, hasRecordedSessionId, isResumableLaneState, isResumeCommandState, laneDeliveryMechanism, parseClaudeResultOutput, parseCodexEventOutput, parseWorkerRunOutput, planLaneLaunch, providerSupportsSessionResume, readWorkerRunResult, resumeCommandRefusal, } from "./delivery.js";
40
+ export type { DeliveryLane, LaneDeliveryMechanism, LaunchPlan, LaunchTrigger, LaunchTriggerKind, ResumableLaneState, ResumeCommandState, SessionIdAbsentReason, WorkerRunResult, } from "./delivery.js";
41
+ export { DROPBOX_DIR, INBOX_NAME, appendDropboxMessage, answerDropboxMessage, drainDropbox, dropboxDir, dropboxInboxPath, formatOperatorInstruction, hookAdditionalContextJson, laneAcceptsDropboxDelivery, laneAcceptsOperatorMessage, laneIdForAnswerDelivery, operatorMessageRefusalReason, readToolActivity, recordToolActivity, runDrainHook, toolActivityPath, TOOL_ACTIVITY_NAME, } from "./dropbox.js";
42
+ export type { DrainDeps, DrainHookResult, DropboxMessage, ToolActivityRecord, } from "./dropbox.js";
43
+ export { DRAIN_HOOK_BASENAME, DRAIN_HOOK_REGISTRATION_KINDS, DRAIN_HOOK_TIMEOUT_SECONDS, PROVIDER_REGISTRATION_KIND, drainHookCommand, drainHookRegistrationPath, drainHookShPath, installDrainHook, lanesHookAssetsDir, mergeClaudeSettingsHook, mergeCodexConfigHook, probeDrainHookRegistration, renderDrainHookJson, } from "./hooks-install.js";
44
+ export type { DrainHookInstallResult, DrainHookRegistration, DrainHookRegistrationKind, DrainHookRegistrationProbe, MergeResult, } from "./hooks-install.js";
45
+ export { EFFORT_SOURCES, PROVIDER_EFFORT_LEVELS, appendEffortFlag, defaultEffortForModel, parseCliEffort, parseConfigEffort, resolveLaneEffort, } from "./effort.js";
46
+ export type { EffortSource, ResolvedEffort } from "./effort.js";
47
+ export { COMPACTION_MECHANISM, COMPACTION_PROMPT, COMPACTION_TIMEOUT_MS, compactLaneSession, compactionAfterUsage, compactionDue, defaultRunCompaction, findSessionTranscript, probeCompactBoundaries, } from "./compaction.js";
48
+ export type { CompactBoundaryProbe, CompactionDecision, CompactLaneSessionInput, RunCompactionFn, } from "./compaction.js";
19
49
  //# sourceMappingURL=index.d.ts.map
@@ -3,10 +3,25 @@
3
3
  */
4
4
  export { AccountResolutionError, LaneNotFoundError, LaneSchemaError, LaneVersionConflict, LanesConfigError, LanesError, WorkerResolutionError, isLaneVersionConflict, isLanesError, } from "./errors.js";
5
5
  export { CONFIG_SCHEMA_VERSION, ENVELOPE_DECISIONS, ENVELOPE_SCHEMA_VERSION, HISTORY_CAP, HOST_KINDS, LANE_PROVIDERS, LANE_SCHEMA_VERSION, LANE_STATES, LIVENESS_STATES, QUESTION_BODY_STORES, QUESTION_SCHEMA_VERSION, QUESTION_STATUSES, QUEUED_REASONS, RAISED_VIA, ROUTING_REASONS, SENIOR_KINDS, STORY_STATUSES, TERMINAL_LANE_STATES, isEnvelopeDecision, isHostKind, isLaneProvider, isLaneState, isLivenessState, isQuestionStatus, isSeniorKind, isTerminalLaneState, parseLaneEnvelope, parseLaneProvider, parseLaneState, parseLivenessState, parseMajorSchema, parseQuestionStatus, parseSeniorKind, } from "./types.js";
6
- export { DEFAULT_ACCOUNT_HOMES, DEFAULT_CPU_BUSY_PAUSE, DEFAULT_CPU_BUSY_RESUME, DEFAULT_LIVE_WITHIN_MS, DEFAULT_LIVENESS_WINDOWS, DEFAULT_MAX_QUEUED, DEFAULT_MIN_AVAILABLE_MEM_MB, DEFAULT_PROVIDER_MAX_RUNNING, DEFAULT_SILENT_LOST_MS, DEFAULT_TURN_START_LOST_MS, LANES_CONFIG_REL, accountMaxRunning, canonicalizeHome, documentedDefaultConfig, expandHome, lanesConfigPath, loadLanesConfig, parseLanesConfig, writeLanesConfig, } from "./config.js";
7
- export { LANES_STORE_REL, LANE_RECORDS_DIR, PENDING_INDEX_DIR, QUESTION_RECORDS_DIR, appendCappedHistory, appendLaneAttribution, appendLaneSeniorHistory, appendQuestionRouting, createLane, createQuestion, isConflictSidecarName, laneRecordPath, lanesStoreRoot, listLaneIds, listQuestionIds, mergeLaneRecords, mergeQuestionRecords, mintLaneId, mintQuestionId, parseLaneRecord, parseQuestionRecord, pendingMarkerPath, questionRecordPath, readLane, readQuestion, resolveStoreHqRoot, sanitizeHostComponent, tryReadLane, tryReadQuestion, updateLane, updateQuestion, } from "./store.js";
6
+ export { DEFAULT_ACCOUNT_HOMES, DEFAULT_COMPACT_AFTER_MS, DEFAULT_CPU_BUSY_PAUSE, DEFAULT_CPU_BUSY_RESUME, DEFAULT_LIVE_WITHIN_MS, DEFAULT_LIVENESS_WINDOWS, DEFAULT_MAX_QUEUED, DEFAULT_MIN_AVAILABLE_MEM_MB, DEFAULT_PROVIDER_MAX_RUNNING, DEFAULT_SILENT_LOST_MS, DEFAULT_TURN_START_LOST_MS, LANES_CONFIG_REL, accountMaxRunning, canonicalizeHome, documentedDefaultConfig, expandHome, lanesConfigPath, loadLanesConfig, parseLanesConfig, providerCompactAfterMs, writeLanesConfig, } from "./config.js";
7
+ export { resolveLanesHqRoot } from "./hq-root.js";
8
+ export { buildOutpostPickupCommand, parseOutpostPickupPayload, } from "./outpost-dispatch.js";
9
+ export { LANES_STORE_REL, LANE_RECORDS_DIR, PENDING_INDEX_DIR, QUESTION_RECORDS_DIR, appendCappedHistory, appendLaneAttribution, appendLaneSeniorHistory, appendQuestionRouting, createLane, createQuestion, isConflictSidecarName, laneRecordPath, lanesStoreRoot, listLaneIds, listQuestionIds, mergeLaneRecords, mergeQuestionRecords, mintLaneId, mintQuestionId, parseLaneRecord, parseQuestionRecord, pendingMarkerPath, questionRecordPath, readLane, readQuestion, resolveStoreHqRoot, sanitizeHostComponent, tryReadLane, tryReadQuestion, retryUpdateLane, retryUpdateQuestion, updateLane, updateQuestion, } from "./store.js";
10
+ export { IMDS_HOST, IMDS_INSTANCE_ID_URL, IMDS_TIMEOUT_MS, IMDS_TOKEN_URL, defaultReadImdsInstanceId, resolveMachineIdentity, } from "./machine-identity.js";
11
+ export { LANES_RUNS_REL as SPAWN_LANES_RUNS_REL, PID_LIVENESS_DECISIONS, PROVIDER_COMMAND, PROVIDER_MODEL_FLAG, SPAWN_TERMINAL_REASONS, ANSWERED_QUESTIONS_FILE, appendModelFlag, armLaneWatcher, buildProviderCommand, parseCliModel, resolveLaneModel, defaultProveDetached, isPidRecordAlive, laneRunDir, missingPidProbe, nextEnvelopePath, markSpawnFailure, parsePidRecord, parseProcStat, parseSpawnTerminalReason, probePidRecord, readPidRecord, readProcStarttime, readProcStarttimeDetailed, readSpawnManifest, resumePrompt, envelopeInstruction, spawnLaneWorker, stopLaneProcesses, watcherMainPath, workerEnv, } from "./spawn.js";
12
+ export { SILENCE_MS, WATCHER_DECISION_EVENTS, WATCHER_OUT_MAX_BYTES, WATCHER_POLL_MS, WATCHER_SIGNAL_KINDS, appendCappedLog, appendWatcherSignal, applyTerminalToLane, classifyLaneExit, clearLaneStalled, isPidAlive, laneIdentityFromRecord, markLaneStalled, notifySlotFreed, parseWatcherSignalKind, readLatestEnvelope, runWatcherLoop, stalledReason, tickWatcher, watcherEventsPath, watcherLastSignalPath, watcherOutLogPath, writeWatcherDecision, } from "./watcher.js";
13
+ export { ENVELOPE_INVALID_REASON, decideEnvelopeRepair, emitMeshSoft, envelopeQuestionIds, readLatestEnvelopeFile, readLatestEnvelopeRecord, } from "./watcher.js";
14
+ export { LANE_MESH_EVENTS, WIRE_EVENT_KINDS, createLaneMesh, emitLaneDecisionEvents, emitLaneProgressEvent, laneCanEmit, parseLaneMeshEvent, progressEventDue, toWireThreadEvent, } from "./mesh-events.js";
8
15
  export { CPU_SAMPLE_MS, LANES_CPU_BUSY_OVERRIDE, LANES_CPU_CHECK, PROC_MEMINFO, STARVATION_MAX_DEFERRALS, STARVATION_MAX_MS, applyThrottleDecision, busyFractionFromDeltas, cpuTimesSnapshot, decideAdmission, defaultThrottleDeps, emptyThrottleState, evaluateThrottle, isCpuCheckEnabled, parseMemAvailableKb, readAvailableMemMb, readThrottleState, resolveCpuBusyFraction, sampleCpuBusyFraction, starvationBoundReached, throttleStatePath, writeThrottleState, } from "./throttle.js";
9
- export { AUTH_JSON_NAME, PROVIDER_HOME_ENV, accountEnv, accountStatus, authJsonPath, listAccountStatuses, resolveAccount, } from "./accounts.js";
10
- export { LIVE_WITHIN_MS, LIVENESS_EVENT_KINDS, SILENT_LOST_MS, TURN_START_LOST_MS, buildLivenessIndexFromSpool, classifySessionLiveness, defaultLivenessDeps, defaultSpoolPath, ingestSpoolLine, listSessionLiveness, livenessIndexPath, loadLivenessIndex, readLivenessIndex, rebuildLivenessIndex, sessionLiveness, } from "./liveness.js";
16
+ export { AUTH_JSON_NAME, CLAUDE_CREDENTIALS_NAME, PROVIDER_CREDENTIAL_FILES, PROVIDER_HOME_ENV, accountEnv, accountStatus, authJsonPath, authStateFor, credentialPaths, hasCredentialFile, isCredentialProven, isLoggedOut, isOccupyingLaneState, lastStartedAt, listAccountStatuses, occupyingLaneCount, resolveAccount, runningLaneCount, selectBalancedAccount, } from "./accounts.js";
17
+ export { LIVE_WITHIN_MS, LIVENESS_EVENT_KINDS, SILENT_LOST_MS, TURN_START_LOST_MS, buildLivenessIndexFromSpool, classifySessionLiveness, defaultLivenessDeps, defaultSpoolPath, ingestSpoolLine, listSessionLiveness, livenessIndexPath, loadLivenessIndex, readDaemonPresenceConnected, readLivenessIndex, rebuildLivenessIndex, sessionLiveness, } from "./liveness.js";
18
+ export { DEAD_HOST_MS, MAX_AGED_ADVANCES, QUESTION_AGE_MS, RECONCILE_TIMER_NAME, RECONCILE_UNIT_NAME, agedAdvanceCount, currentHopStartedAtMs, isDeadlinePassed, laneRunsHere, readTimeoutDeadline, reconcileHeartbeatPath, resolveQuestionAudience, runReconcilePass, shouldAdvanceAudienceEnded, shouldAgeQuestion, timeoutPath, } from "./reconcile.js";
19
+ export { RECONCILE_TIMER_INTERVAL, defaultSystemdUserDir, installReconcileTimer, providerPathEnv, renderReconcileService, renderReconcileTimer, uninstallReconcileTimer, } from "./reconcile-install.js";
11
20
  export { WORKER_REGISTRY_REL, personalWorkerDir, personalWorkerExists, readWorkerRegistryFile, registryPath, resolveContextBasePaths, resolveLaneWorker, resolveSkillFiles, tenancyFromRegistryPath, } from "./registry.js";
21
+ export { bodyStoreForLane, envelopeQuestionId, parseQuestionBodyStore, questionBodyAbsPath, questionBodyRef, raiseEnvelopeQuestions, raiseLaneQuestion, sha256Text, writeQuestionBody, } from "./questions.js";
22
+ export { LANE_DELIVERY_MECHANISMS, LAUNCH_TRIGGERS, PROVIDER_SESSION_RESUME, RESUMABLE_LANE_STATES, RESUME_COMMAND_STATES, SESSION_ID_ABSENT_REASONS, claimableStatesFor, deliveryRefusalReason, hasRecordedSessionId, isResumableLaneState, isResumeCommandState, laneDeliveryMechanism, parseClaudeResultOutput, parseCodexEventOutput, parseWorkerRunOutput, planLaneLaunch, providerSupportsSessionResume, readWorkerRunResult, resumeCommandRefusal, } from "./delivery.js";
23
+ export { DROPBOX_DIR, INBOX_NAME, appendDropboxMessage, answerDropboxMessage, drainDropbox, dropboxDir, dropboxInboxPath, formatOperatorInstruction, hookAdditionalContextJson, laneAcceptsDropboxDelivery, laneAcceptsOperatorMessage, laneIdForAnswerDelivery, operatorMessageRefusalReason, readToolActivity, recordToolActivity, runDrainHook, toolActivityPath, TOOL_ACTIVITY_NAME, } from "./dropbox.js";
24
+ export { DRAIN_HOOK_BASENAME, DRAIN_HOOK_REGISTRATION_KINDS, DRAIN_HOOK_TIMEOUT_SECONDS, PROVIDER_REGISTRATION_KIND, drainHookCommand, drainHookRegistrationPath, drainHookShPath, installDrainHook, lanesHookAssetsDir, mergeClaudeSettingsHook, mergeCodexConfigHook, probeDrainHookRegistration, renderDrainHookJson, } from "./hooks-install.js";
25
+ export { EFFORT_SOURCES, PROVIDER_EFFORT_LEVELS, appendEffortFlag, defaultEffortForModel, parseCliEffort, parseConfigEffort, resolveLaneEffort, } from "./effort.js";
26
+ export { COMPACTION_MECHANISM, COMPACTION_PROMPT, COMPACTION_TIMEOUT_MS, compactLaneSession, compactionAfterUsage, compactionDue, defaultRunCompaction, findSessionTranscript, probeCompactBoundaries, } from "./compaction.js";
12
27
  //# sourceMappingURL=index.js.map
@@ -66,7 +66,13 @@ export declare function readLivenessIndex(hqRoot: string, deps?: LivenessDeps):
66
66
  * Return the compact index, rebuilding from the spool when missing or stale.
67
67
  * Never walks workspace/sessions/.
68
68
  */
69
- export declare function loadLivenessIndex(hqRoot: string, spoolPath?: string, deps?: LivenessDeps): LivenessIndex;
69
+ export declare function loadLivenessIndex(hqRoot: string, spoolPath?: string, deps?: LivenessDeps, persist?: boolean): LivenessIndex;
70
+ /**
71
+ * Spec §9: a session is also `live` when the mesh daemon reports presence
72
+ * connected, not only from the spool. Missing state file → not connected.
73
+ * Unreadable or corrupt state is an error (unknown must not resolve to healthy).
74
+ */
75
+ export declare function readDaemonPresenceConnected(deps?: LivenessDeps): boolean;
70
76
  export declare function sessionLiveness(hqRoot: string, sessionId: string, opts?: {
71
77
  spoolPath?: string;
72
78
  nowMs?: number;