@indigoai-us/hq-cli 5.345.244 → 5.345.246
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.
- package/CHANGELOG.md +87 -0
- package/dist/command-catalog.generated.d.ts +93 -6
- package/dist/command-catalog.generated.js +114 -6
- package/dist/commands/bot.js +1 -1
- package/dist/commands/core-checkpoint-native.d.ts +5 -1
- package/dist/commands/core-checkpoint-native.js +13 -5
- package/dist/commands/deploy-comments.js +139 -0
- package/dist/commands/deploy-list.d.ts +5 -0
- package/dist/commands/deploy-list.js +8 -0
- package/dist/commands/dm.d.ts +4 -1
- package/dist/commands/dm.js +11 -2
- package/dist/commands/files.d.ts +11 -2
- package/dist/commands/files.js +48 -3
- package/dist/commands/lanes-loop.js +4 -1
- package/dist/commands/lanes.js +16 -5
- package/dist/commands/mesh.d.ts +2 -0
- package/dist/commands/mesh.js +26 -6
- package/dist/commands/reindex.js +2 -1
- package/dist/commands/rescue.d.ts +22 -1
- package/dist/commands/rescue.js +56 -9
- package/dist/commands/sources.d.ts +1 -1
- package/dist/commands/sources.js +1 -1
- package/dist/commands/storage.d.ts +15 -2
- package/dist/commands/storage.js +74 -7
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +2033 -1829
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/agent-kit/mcp/tools.js +22 -0
- package/dist/lib/bot/jobs/hot-signal-sync.js +4 -1
- package/dist/lib/daemon/fleet-members-cache.d.ts +55 -0
- package/dist/lib/daemon/fleet-members-cache.js +266 -0
- package/dist/lib/daemon/handoff.d.ts +4 -0
- package/dist/lib/daemon/handoff.js +2 -1
- package/dist/lib/daemon/hook-requests.d.ts +2 -1
- package/dist/lib/daemon/hook-requests.js +19 -2
- package/dist/lib/daemon/install.d.ts +9 -1
- package/dist/lib/daemon/install.js +11 -2
- package/dist/lib/daemon/ops/policy.d.ts +23 -3
- package/dist/lib/daemon/ops/policy.js +62 -15
- package/dist/lib/daemon/run.js +12 -0
- package/dist/lib/daemon/server.d.ts +5 -0
- package/dist/lib/daemon/server.js +1 -1
- package/dist/lib/daemon/supervisor.d.ts +6 -0
- package/dist/lib/daemon/supervisor.js +31 -2
- package/dist/lib/doctor/checks/sync-runtime.js +8 -1
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/hook-engine/coverage.d.ts +68 -0
- package/dist/lib/hook-engine/coverage.js +163 -0
- package/dist/lib/hook-engine/native-precompact-compatibility.json +1 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +52 -2
- package/dist/lib/hot-channels/signals-pass.js +65 -3
- package/dist/lib/install/claude-targets.d.ts +6 -0
- package/dist/lib/install/claude-targets.js +9 -1
- package/dist/lib/lanes/reconcile-result.d.ts +1 -1
- package/dist/lib/lanes/reconcile.js +19 -4
- package/dist/lib/lanes/remote-control-lane.d.ts +6 -0
- package/dist/lib/lanes/remote-control-lane.js +10 -1
- package/dist/lib/lanes/spawn.d.ts +2 -0
- package/dist/lib/lanes/spawn.js +19 -3
- package/dist/lib/lanes/worker-env-scrub.d.ts +48 -0
- package/dist/lib/lanes/worker-env-scrub.js +146 -0
- package/dist/lib/lanes/worker-process.js +4 -1
- package/dist/lib/mesh/client.js +5 -1
- package/dist/lib/mesh/live/daemon/doctor.d.ts +9 -0
- package/dist/lib/mesh/live/daemon/doctor.js +51 -6
- package/dist/lib/mesh/live/daemon/install.d.ts +39 -0
- package/dist/lib/mesh/live/daemon/install.js +70 -0
- package/dist/lib/mesh/live/daemon/outbox-company.d.ts +47 -0
- package/dist/lib/mesh/live/daemon/outbox-company.js +77 -0
- package/dist/lib/mesh/live/daemon/run.d.ts +2 -0
- package/dist/lib/mesh/live/daemon/run.js +48 -3
- package/dist/lib/mesh/live/daemon/state.d.ts +5 -0
- package/dist/lib/mesh/live/daemon/system-unit.d.ts +21 -0
- package/dist/lib/mesh/live/daemon/system-unit.js +80 -0
- package/dist/lib/mesh/live/daemon/transcript-watch.d.ts +4 -1
- package/dist/lib/mesh/live/daemon/transcript-watch.js +42 -38
- package/dist/lib/mesh/live/direct-drain.js +3 -1
- package/dist/lib/mesh/live/emit.js +4 -2
- package/dist/lib/mesh/live/flush.d.ts +61 -0
- package/dist/lib/mesh/live/flush.js +434 -114
- package/dist/lib/mesh/live/paths.d.ts +10 -0
- package/dist/lib/mesh/live/paths.js +14 -0
- package/dist/lib/mesh/live/reporting-privacy.d.ts +41 -1
- package/dist/lib/mesh/live/reporting-privacy.js +81 -7
- package/dist/lib/mesh/live/spool.d.ts +171 -17
- package/dist/lib/mesh/live/spool.js +777 -62
- package/dist/lib/signals/engine.d.ts +82 -2
- package/dist/lib/signals/engine.js +389 -53
- package/dist/lib/signals/steps/extract.js +5 -0
- package/dist/lib/sync-core/engine-holds.d.ts +17 -1
- package/dist/lib/sync-core/engine-holds.js +73 -3
- package/dist/lib/sync-core/reconcile.js +10 -2
- package/dist/lib/work-context/organize.d.ts +22 -4
- package/dist/lib/work-context/organize.js +50 -21
- package/dist/lib/work-context/paths.d.ts +6 -0
- package/dist/lib/work-context/paths.js +9 -0
- package/dist/lib/work-context/reconcile.d.ts +1 -1
- package/dist/lib/work-context/reconcile.js +1 -1
- package/dist/startup-registration.d.ts +14 -0
- package/dist/startup-registration.js +26 -0
- package/dist/utils/cli-telemetry.d.ts +6 -0
- package/dist/utils/cli-telemetry.js +154 -9
- package/dist/utils/github-tag-fallback.d.ts +7 -2
- package/dist/utils/github-tag-fallback.js +17 -8
- package/dist/utils/hq-core-source.d.ts +31 -0
- package/dist/utils/hq-core-source.js +144 -0
- package/dist/utils/interactive-caller.d.ts +6 -0
- package/dist/utils/interactive-caller.js +8 -0
- package/dist/utils/shipped-codex-hooks.d.ts +6 -4
- package/dist/utils/shipped-codex-hooks.js +22 -10
- package/dist/utils/vault-api.js +1 -0
- package/dist/utils/version-report.d.ts +3 -1
- package/dist/utils/version-report.js +13 -5
- package/docs/anywhere-runtime.md +2 -2
- package/package.json +8 -8
- package/scripts/check-function-manifest.mjs +99 -18
|
@@ -168,6 +168,74 @@ export declare function coversKey(key: string): {
|
|
|
168
168
|
export declare function coveredOn(covers: Readonly<Record<string, readonly string[]>> | undefined, event: string, host: CoreNextHost): string[];
|
|
169
169
|
/** The old dispatcher's hooks for `event` on `host` that the engine does not cover. */
|
|
170
170
|
export declare function uncoveredHooks(root: string, host: CoreNextHost, event: string, covers: Readonly<Record<string, readonly string[]>> | undefined, env?: NodeJS.ProcessEnv): string[];
|
|
171
|
+
/**
|
|
172
|
+
* The script revisions the native SessionStart master rebuilds (hq-core v16.0.48 through v16.0.50):
|
|
173
|
+
* `hqd_open.rs` (the daemon shim and its flag-cache library), `session_set/mod.rs` `SCRIPTS`,
|
|
174
|
+
* `ID_LIBS` and `CAPABILITY_LIBS` (hq-session.sh and the two libraries it sources) and
|
|
175
|
+
* `foreign_bind.rs` `RESOLVE_REVISIONS` (resolve-company.sh). The native port
|
|
176
|
+
* refuses a SessionStart that reaches any other revision, and Claude Code drops a SessionStart
|
|
177
|
+
* refusal, so the session would start with no SessionStart hook at all.
|
|
178
|
+
*/
|
|
179
|
+
export declare const SESSION_START_PINS: ReadonlyArray<readonly [string, string]>;
|
|
180
|
+
/**
|
|
181
|
+
* Why SessionStart must stay on the shell registration in `root`: one of [`SESSION_START_PINS`] is
|
|
182
|
+
* missing, cannot be read, or is not the pinned revision. A registration-time hold, as for Codex
|
|
183
|
+
* SubagentStop: `hq reindex` keeps master-hook for SessionStart, and the native port still refuses
|
|
184
|
+
* any revision it does not rebuild. Null when every file matches.
|
|
185
|
+
*/
|
|
186
|
+
export declare function sessionStartHold(root: string): string | null;
|
|
187
|
+
/**
|
|
188
|
+
* The one Codex adapter pair the native Codex SubagentStop is modelled on (hq-core v16.0.47):
|
|
189
|
+
* `ADAPTER_RELEASES` and `ADAPTER_CORE_RELEASES` in crates/hq-hook/src/post_hooks/codex.rs.
|
|
190
|
+
* crates/hq-hook/src/lifecycle_dispatch.rs has a test that these values match those.
|
|
191
|
+
*/
|
|
192
|
+
export declare const CODEX_SUBAGENT_STOP_PAIR: ReadonlyArray<readonly [string, string]>;
|
|
193
|
+
/**
|
|
194
|
+
* Why Codex SubagentStop must stay on the shell adapter in `root`: the root's Codex adapter or its
|
|
195
|
+
* library is not the pair the native port models, or cannot be read. The native first member,
|
|
196
|
+
* `lifecycle-dispatch`, refuses every Codex SubagentStop on such a root, so without this hold
|
|
197
|
+
* `hq reindex` would switch the event onto a refusal (hq-cli #3404 R12). Null when the pair matches.
|
|
198
|
+
*/
|
|
199
|
+
export declare function codexSubagentStopHold(root: string): string | null;
|
|
200
|
+
/**
|
|
201
|
+
* [`codexSubagentStopHold`] for the sha256 of the root's adapter and its library, in
|
|
202
|
+
* `CODEX_SUBAGENT_STOP_PAIR` order (null for a file that cannot be read).
|
|
203
|
+
*/
|
|
204
|
+
export declare function codexSubagentStopPairHold(hashes: ReadonlyArray<string | null>): string | null;
|
|
205
|
+
/** One script a native port reads by sha256 before it does an event's work. */
|
|
206
|
+
export interface PinnedFile {
|
|
207
|
+
/** The file, relative to the HQ root. */
|
|
208
|
+
relative: string;
|
|
209
|
+
/** The sha256 of each revision the native port accepts. */
|
|
210
|
+
accepted: readonly string[];
|
|
211
|
+
/** `allowed` where the native port goes on without the file: a root that lacks it is not held. */
|
|
212
|
+
missing?: 'allowed';
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The shared pin check of the registration holds: why `event` must stay on the shell registration
|
|
216
|
+
* in `root`, or null when the native port accepts every file. A file that is not a regular file is
|
|
217
|
+
* skipped when its entry says `missing: 'allowed'` and held otherwise; one that cannot be read, or
|
|
218
|
+
* whose sha256 is not in its `accepted` list, is held. `generations` lists the revisions that
|
|
219
|
+
* belong together, one sha256 per file in `files` order: the files found must all come from one
|
|
220
|
+
* listed generation (a file skipped as missing matches any).
|
|
221
|
+
*/
|
|
222
|
+
export declare function pinnedFilesHold(root: string, event: string, files: readonly PinnedFile[], generations?: ReadonlyArray<readonly string[]>): string | null;
|
|
223
|
+
/**
|
|
224
|
+
* The scripts the native first-prompt company bind rebuilds, each at one revision:
|
|
225
|
+
* `MENTION_LIBS` in crates/hq-hook/src/prompt_company_mention/bind.rs, then `SCRIPTS`, `ID_LIBS` and
|
|
226
|
+
* `CAPABILITY_LIBS` in crates/hq-hook/src/session_set/mod.rs.
|
|
227
|
+
*/
|
|
228
|
+
export declare const PROMPT_COMPANY_BIND_PINS: readonly PinnedFile[];
|
|
229
|
+
/**
|
|
230
|
+
* Why UserPromptSubmit must stay on the shell registration in `root`: the native
|
|
231
|
+
* natural-language-router (crates/hq-hook/src/prompt_up7/nl_router.rs) would refuse the first prompt
|
|
232
|
+
* of a session whose company it rebinds, because a script of that bind is not the revision it
|
|
233
|
+
* rebuilds. As there, the bind is skipped (no hold) without the router script, without
|
|
234
|
+
* core/scripts/hook-lib.sh, or without prompt-company-mention.sh or hq-session.sh; with both of
|
|
235
|
+
* those on disk a missing session-id.sh or session-scope-capability.sh is refused, so it holds.
|
|
236
|
+
* Whether a prompt reaches the bind is decided per prompt, so the hold does not wait for one.
|
|
237
|
+
*/
|
|
238
|
+
export declare function promptCompanyBindHold(root: string): string | null;
|
|
171
239
|
/** Records the environment `target` was resolved under; returns `target`. */
|
|
172
240
|
export declare function resolvedUnder<T extends CoreNextTarget | null>(target: T, env: NodeJS.ProcessEnv): T;
|
|
173
241
|
export declare function forHost(target: CoreNextTarget | null, root: string, host: CoreNextHost, env?: NodeJS.ProcessEnv): CoreNextTarget | null;
|
|
@@ -1695,8 +1695,171 @@ export function uncoveredHooks(root, host, event, covers, env = process.env) {
|
|
|
1695
1695
|
if (!missing.includes(hook))
|
|
1696
1696
|
missing.push(hook);
|
|
1697
1697
|
}
|
|
1698
|
+
if (host === 'codex' && event === 'SubagentStop' && covered.includes('codex-adapter:SubagentStop')) {
|
|
1699
|
+
const hold = codexSubagentStopHold(root);
|
|
1700
|
+
if (hold)
|
|
1701
|
+
missing.push(`(native SubagentStop compatibility: ${hold})`);
|
|
1702
|
+
}
|
|
1703
|
+
if (event === 'SessionStart' && covered.includes('master-hook:SessionStart')) {
|
|
1704
|
+
const hold = sessionStartHold(root);
|
|
1705
|
+
if (hold)
|
|
1706
|
+
missing.push(`(native SessionStart compatibility: ${hold})`);
|
|
1707
|
+
}
|
|
1708
|
+
// The native natural-language-router runs where the registry lists it; its claim and master-hook's switch the event.
|
|
1709
|
+
if (event === 'UserPromptSubmit' && covered.includes('master-hook:UserPromptSubmit') && covered.includes('natural-language-router') && hooks.includes('natural-language-router')) {
|
|
1710
|
+
const hold = promptCompanyBindHold(root);
|
|
1711
|
+
if (hold)
|
|
1712
|
+
missing.push(`(native UserPromptSubmit compatibility: ${hold})`);
|
|
1713
|
+
}
|
|
1698
1714
|
return missing;
|
|
1699
1715
|
}
|
|
1716
|
+
/**
|
|
1717
|
+
* The script revisions the native SessionStart master rebuilds (hq-core v16.0.48 through v16.0.50):
|
|
1718
|
+
* `hqd_open.rs` (the daemon shim and its flag-cache library), `session_set/mod.rs` `SCRIPTS`,
|
|
1719
|
+
* `ID_LIBS` and `CAPABILITY_LIBS` (hq-session.sh and the two libraries it sources) and
|
|
1720
|
+
* `foreign_bind.rs` `RESOLVE_REVISIONS` (resolve-company.sh). The native port
|
|
1721
|
+
* refuses a SessionStart that reaches any other revision, and Claude Code drops a SessionStart
|
|
1722
|
+
* refusal, so the session would start with no SessionStart hook at all.
|
|
1723
|
+
*/
|
|
1724
|
+
export const SESSION_START_PINS = [
|
|
1725
|
+
['core/scripts/hqd-hook-shim.sh', 'ab289ac0af680fe3bcacb110302ca8b998bdc33c6f94321d42bd04a344163eed'],
|
|
1726
|
+
['core/scripts/hqd-hook-flag-cache-lib.sh', '061d264460408e9eaf43fdf0fdde662c906a9a7dacb4e7a591e684bca28c138a'],
|
|
1727
|
+
['core/scripts/hq-session.sh', 'db701162f71b53fd2188974d2f46c58250593dde1252d65b36e6d02b9a765fe7'],
|
|
1728
|
+
['core/scripts/lib/session-id.sh', '2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d'],
|
|
1729
|
+
['core/scripts/lib/session-scope-capability.sh', '388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead'],
|
|
1730
|
+
['core/scripts/resolve-company.sh', '00d6fa069f574a86087c77daa44887a2617446d4300d5daebecc9bfb5d81abe7'],
|
|
1731
|
+
];
|
|
1732
|
+
/**
|
|
1733
|
+
* Why SessionStart must stay on the shell registration in `root`: one of [`SESSION_START_PINS`] is
|
|
1734
|
+
* missing, cannot be read, or is not the pinned revision. A registration-time hold, as for Codex
|
|
1735
|
+
* SubagentStop: `hq reindex` keeps master-hook for SessionStart, and the native port still refuses
|
|
1736
|
+
* any revision it does not rebuild. Null when every file matches.
|
|
1737
|
+
*/
|
|
1738
|
+
export function sessionStartHold(root) {
|
|
1739
|
+
for (const [relative, sha] of SESSION_START_PINS) {
|
|
1740
|
+
let bytes;
|
|
1741
|
+
try {
|
|
1742
|
+
const file = path.join(root, relative);
|
|
1743
|
+
if (!fs.statSync(file).isFile())
|
|
1744
|
+
return `unreadable SessionStart file ${relative}`;
|
|
1745
|
+
bytes = fs.readFileSync(file);
|
|
1746
|
+
}
|
|
1747
|
+
catch {
|
|
1748
|
+
return `unreadable SessionStart file ${relative}`;
|
|
1749
|
+
}
|
|
1750
|
+
if (createHash('sha256').update(bytes).digest('hex') !== sha)
|
|
1751
|
+
return `unmodeled SessionStart file ${relative}`;
|
|
1752
|
+
}
|
|
1753
|
+
return null;
|
|
1754
|
+
}
|
|
1755
|
+
/**
|
|
1756
|
+
* The one Codex adapter pair the native Codex SubagentStop is modelled on (hq-core v16.0.47):
|
|
1757
|
+
* `ADAPTER_RELEASES` and `ADAPTER_CORE_RELEASES` in crates/hq-hook/src/post_hooks/codex.rs.
|
|
1758
|
+
* crates/hq-hook/src/lifecycle_dispatch.rs has a test that these values match those.
|
|
1759
|
+
*/
|
|
1760
|
+
export const CODEX_SUBAGENT_STOP_PAIR = [
|
|
1761
|
+
['.codex/hooks/hq-codex-hook-adapter.sh', '3c3196254614df7b14dccad507dcee3299fa8cf9c163a6903eac2d86fb2159c5'],
|
|
1762
|
+
['core/scripts/lib/hook-adapter-core.sh', '98da450068af022eb1eee5420a4eca98867b91690e57316ee565eb7788fb6e7a'],
|
|
1763
|
+
];
|
|
1764
|
+
/**
|
|
1765
|
+
* Why Codex SubagentStop must stay on the shell adapter in `root`: the root's Codex adapter or its
|
|
1766
|
+
* library is not the pair the native port models, or cannot be read. The native first member,
|
|
1767
|
+
* `lifecycle-dispatch`, refuses every Codex SubagentStop on such a root, so without this hold
|
|
1768
|
+
* `hq reindex` would switch the event onto a refusal (hq-cli #3404 R12). Null when the pair matches.
|
|
1769
|
+
*/
|
|
1770
|
+
export function codexSubagentStopHold(root) {
|
|
1771
|
+
return codexSubagentStopPairHold(CODEX_SUBAGENT_STOP_PAIR.map(([relative]) => {
|
|
1772
|
+
try {
|
|
1773
|
+
return createHash('sha256').update(fs.readFileSync(path.join(root, relative))).digest('hex');
|
|
1774
|
+
}
|
|
1775
|
+
catch {
|
|
1776
|
+
return null;
|
|
1777
|
+
}
|
|
1778
|
+
}));
|
|
1779
|
+
}
|
|
1780
|
+
/**
|
|
1781
|
+
* [`codexSubagentStopHold`] for the sha256 of the root's adapter and its library, in
|
|
1782
|
+
* `CODEX_SUBAGENT_STOP_PAIR` order (null for a file that cannot be read).
|
|
1783
|
+
*/
|
|
1784
|
+
export function codexSubagentStopPairHold(hashes) {
|
|
1785
|
+
for (const [index, [relative, sha]] of CODEX_SUBAGENT_STOP_PAIR.entries()) {
|
|
1786
|
+
const found = hashes[index];
|
|
1787
|
+
if (found == null)
|
|
1788
|
+
return `unreadable Codex SubagentStop file ${relative}`;
|
|
1789
|
+
if (found !== sha)
|
|
1790
|
+
return `unmodeled Codex SubagentStop file ${relative}`;
|
|
1791
|
+
}
|
|
1792
|
+
return null;
|
|
1793
|
+
}
|
|
1794
|
+
/** Rust's `Path::is_file`: a regular file, symlinks followed; false for anything that cannot be read. */
|
|
1795
|
+
const regularFile = (file) => { try {
|
|
1796
|
+
return fs.statSync(file).isFile();
|
|
1797
|
+
}
|
|
1798
|
+
catch {
|
|
1799
|
+
return false;
|
|
1800
|
+
} };
|
|
1801
|
+
/**
|
|
1802
|
+
* The shared pin check of the registration holds: why `event` must stay on the shell registration
|
|
1803
|
+
* in `root`, or null when the native port accepts every file. A file that is not a regular file is
|
|
1804
|
+
* skipped when its entry says `missing: 'allowed'` and held otherwise; one that cannot be read, or
|
|
1805
|
+
* whose sha256 is not in its `accepted` list, is held. `generations` lists the revisions that
|
|
1806
|
+
* belong together, one sha256 per file in `files` order: the files found must all come from one
|
|
1807
|
+
* listed generation (a file skipped as missing matches any).
|
|
1808
|
+
*/
|
|
1809
|
+
export function pinnedFilesHold(root, event, files, generations = []) {
|
|
1810
|
+
const found = [];
|
|
1811
|
+
for (const { relative, accepted, missing } of files) {
|
|
1812
|
+
const file = path.join(root, relative);
|
|
1813
|
+
if (!regularFile(file)) {
|
|
1814
|
+
if (missing !== 'allowed')
|
|
1815
|
+
return `unreadable ${event} file ${relative}`;
|
|
1816
|
+
found.push(null);
|
|
1817
|
+
continue;
|
|
1818
|
+
}
|
|
1819
|
+
let bytes;
|
|
1820
|
+
try {
|
|
1821
|
+
bytes = fs.readFileSync(file);
|
|
1822
|
+
}
|
|
1823
|
+
catch {
|
|
1824
|
+
return `unreadable ${event} file ${relative}`;
|
|
1825
|
+
}
|
|
1826
|
+
const hash = createHash('sha256').update(bytes).digest('hex');
|
|
1827
|
+
if (!accepted.includes(hash))
|
|
1828
|
+
return `unmodeled ${event} file ${relative}`;
|
|
1829
|
+
found.push(hash);
|
|
1830
|
+
}
|
|
1831
|
+
if (generations.length && !generations.some((generation) => found.every((hash, index) => hash === null || hash === generation[index]))) {
|
|
1832
|
+
return `mixed ${event} file generation ${files.filter((_, index) => found[index] !== null).map(({ relative }) => relative).join(' and ')}`;
|
|
1833
|
+
}
|
|
1834
|
+
return null;
|
|
1835
|
+
}
|
|
1836
|
+
/**
|
|
1837
|
+
* The scripts the native first-prompt company bind rebuilds, each at one revision:
|
|
1838
|
+
* `MENTION_LIBS` in crates/hq-hook/src/prompt_company_mention/bind.rs, then `SCRIPTS`, `ID_LIBS` and
|
|
1839
|
+
* `CAPABILITY_LIBS` in crates/hq-hook/src/session_set/mod.rs.
|
|
1840
|
+
*/
|
|
1841
|
+
export const PROMPT_COMPANY_BIND_PINS = [
|
|
1842
|
+
{ relative: 'core/scripts/lib/prompt-company-mention.sh', accepted: ['6c68e31d0605db272a6b922e361d1e7659ab77e96faaf613c62afa192aef4ee0'] },
|
|
1843
|
+
{ relative: 'core/scripts/hq-session.sh', accepted: ['db701162f71b53fd2188974d2f46c58250593dde1252d65b36e6d02b9a765fe7'] },
|
|
1844
|
+
{ relative: 'core/scripts/lib/session-id.sh', accepted: ['2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d'] },
|
|
1845
|
+
{ relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead'] },
|
|
1846
|
+
];
|
|
1847
|
+
/**
|
|
1848
|
+
* Why UserPromptSubmit must stay on the shell registration in `root`: the native
|
|
1849
|
+
* natural-language-router (crates/hq-hook/src/prompt_up7/nl_router.rs) would refuse the first prompt
|
|
1850
|
+
* of a session whose company it rebinds, because a script of that bind is not the revision it
|
|
1851
|
+
* rebuilds. As there, the bind is skipped (no hold) without the router script, without
|
|
1852
|
+
* core/scripts/hook-lib.sh, or without prompt-company-mention.sh or hq-session.sh; with both of
|
|
1853
|
+
* those on disk a missing session-id.sh or session-scope-capability.sh is refused, so it holds.
|
|
1854
|
+
* Whether a prompt reaches the bind is decided per prompt, so the hold does not wait for one.
|
|
1855
|
+
*/
|
|
1856
|
+
export function promptCompanyBindHold(root) {
|
|
1857
|
+
for (const needed of ['.claude/hooks/natural-language-router.sh', 'core/scripts/hook-lib.sh', PROMPT_COMPANY_BIND_PINS[0].relative, PROMPT_COMPANY_BIND_PINS[1].relative]) {
|
|
1858
|
+
if (!regularFile(path.join(root, needed)))
|
|
1859
|
+
return null;
|
|
1860
|
+
}
|
|
1861
|
+
return pinnedFilesHold(root, 'UserPromptSubmit', PROMPT_COMPANY_BIND_PINS);
|
|
1862
|
+
}
|
|
1700
1863
|
/** Grok events the adapter dispatched as its settings.json `Stop` entries (lifecycle_master.rs `dispatched`). */
|
|
1701
1864
|
const GROK_STOP_OBSERVE = new Set(['StopCancelled', 'StopFailure']);
|
|
1702
1865
|
/**
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"17247cbd11597181dbe374579ac5c3ab65cbd04d546c4cd416d65d70cc9c71ae",
|
|
21
21
|
"1b082635f2166ca668fe8f8ad180e1c8dc6e3517f5657beece68056200219350",
|
|
22
22
|
"5a74d090475b7112f1013f1f11b777dd9cff9032608030d3ab004e56567b5b3d",
|
|
23
|
+
"7ac8365fa95474b2003caa1ff8bed07c88e18abc4d4cbae041f0249dd826a70c",
|
|
23
24
|
"afdc525b83ad443ca3cbafd650746599f702748b9d01e1e6c34f747fb5e098ae",
|
|
24
25
|
"bc8ddf7a648832db6314a989a7c26355f59909cbbcb001c553c6150f072623e8",
|
|
25
26
|
"ca4f0c5cf4c1de34e90f8e3e3114a025958fa78905c569b3a780cca0506e71f8",
|
|
@@ -109,8 +109,40 @@ export declare const DEFAULT_SIGNALS_TIMEOUT_MS = 120000;
|
|
|
109
109
|
export declare const AUTH_PREFLIGHT_TIMEOUT_MS = 10000;
|
|
110
110
|
/** Budget for one worklist script call. */
|
|
111
111
|
export declare const WORKLIST_TIMEOUT_MS = 60000;
|
|
112
|
-
/**
|
|
113
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Documents one pass sends to claude across all adapters of a run.
|
|
114
|
+
*
|
|
115
|
+
* 40, raised from 20 on 2026-11-22 (owner decision: raise the limit rather
|
|
116
|
+
* than reword the warning). The 2026-11-21 06:30 PT indigo job had 31
|
|
117
|
+
* documents waiting after four days of signed-out runs: 20 were read in about
|
|
118
|
+
* 2m45s for the whole job (about 8s a document) and 11 were left for the next
|
|
119
|
+
* day, so a run with nothing wrong was reported as partial. 40 covers that
|
|
120
|
+
* backlog, and a 24-meeting re-run, in one pass.
|
|
121
|
+
*
|
|
122
|
+
* The cap still bounds the run. Calls stay subscription-only (an API-key or
|
|
123
|
+
* third-party login is refused before the first document), a usage-limit reply
|
|
124
|
+
* stops the pass at once, and BAD_OUTPUT_STOP_AFTER stops a run of unusable
|
|
125
|
+
* replies, so raising the cap adds no per-token spend. At the observed rate 40
|
|
126
|
+
* documents take about 5-6 minutes; each call keeps its own
|
|
127
|
+
* DEFAULT_SIGNALS_TIMEOUT_MS budget, and the sync lock is heartbeated, so a
|
|
128
|
+
* longer pass is not taken over as stale.
|
|
129
|
+
*
|
|
130
|
+
* Worst-case duration (not expected; it needs nearly every call to run to its
|
|
131
|
+
* full 120 s budget without BAD_OUTPUT_STOP_AFTER documents failing in a row):
|
|
132
|
+
* - Unusable replies: 40 documents x BAD_OUTPUT_ATTEMPTS (3) calls x 120 s =
|
|
133
|
+
* 4 hours (2 hours at the old cap of 20). That is longer than the 3 hours
|
|
134
|
+
* after which the engine's company run lock can be taken over (LOCK_STALE_MS
|
|
135
|
+
* in src/lib/signals/run-lock.ts, counted from the lock's start, with no
|
|
136
|
+
* heartbeat).
|
|
137
|
+
* - Once a timed-out document is skipped instead of sent again (PR 3438, not
|
|
138
|
+
* merged when this was written): 40 x 120 s = 80 minutes (40 minutes at the
|
|
139
|
+
* old cap). That is longer than the 60 minutes after which the bot releases
|
|
140
|
+
* an in-flight job (IN_FLIGHT_RELEASE_MS in src/lib/bot/local-jobs.ts).
|
|
141
|
+
* The worklist listing keeps its fixed WORKLIST_TIMEOUT_MS (60 s) at
|
|
142
|
+
* `--limit 40`; it does not grow with the limit the way the extract step's
|
|
143
|
+
* listing budget does (src/lib/signals/steps/extract.ts).
|
|
144
|
+
*/
|
|
145
|
+
export declare const DEFAULT_MAX_SIGNAL_DOCS = 40;
|
|
114
146
|
/**
|
|
115
147
|
* Claude calls per document when the reply is unusable (`claude-bad-output`).
|
|
116
148
|
* The reply differs from call to call, so a document whose first reply has a
|
|
@@ -262,6 +294,24 @@ export declare function signalCitation(at: string | undefined, segments: Readonl
|
|
|
262
294
|
start_ms: number;
|
|
263
295
|
end_ms: number;
|
|
264
296
|
} | undefined;
|
|
297
|
+
/**
|
|
298
|
+
* A meeting recap cites the span of the segments it is given: the earliest
|
|
299
|
+
* segment start and the latest segment end, whatever order the markers come
|
|
300
|
+
* in, so an out-of-order or overlapping marker cannot give a start after the
|
|
301
|
+
* end or a span shorter than one segment. `segments` comes from the payload
|
|
302
|
+
* text the pass read, which is capped at MAX_PAYLOAD_BYTES, so a longer
|
|
303
|
+
* transcript is cited up to the last marker inside that cap, not to its end.
|
|
304
|
+
* Undefined when there are no segments. Nothing is inferred beyond the
|
|
305
|
+
* markers already in `segments`.
|
|
306
|
+
*/
|
|
307
|
+
export declare function summaryTranscriptCitation(segments: ReadonlyMap<number, {
|
|
308
|
+
startMs: number;
|
|
309
|
+
endMs: number;
|
|
310
|
+
}>, sourceRef: string): {
|
|
311
|
+
source_ref: string;
|
|
312
|
+
start_ms: number;
|
|
313
|
+
end_ms: number;
|
|
314
|
+
} | undefined;
|
|
265
315
|
export interface IndexRow {
|
|
266
316
|
signal_id: string;
|
|
267
317
|
type: string;
|
|
@@ -266,8 +266,40 @@ export const DEFAULT_SIGNALS_TIMEOUT_MS = 120_000;
|
|
|
266
266
|
export const AUTH_PREFLIGHT_TIMEOUT_MS = 10_000;
|
|
267
267
|
/** Budget for one worklist script call. */
|
|
268
268
|
export const WORKLIST_TIMEOUT_MS = 60_000;
|
|
269
|
-
/**
|
|
270
|
-
|
|
269
|
+
/**
|
|
270
|
+
* Documents one pass sends to claude across all adapters of a run.
|
|
271
|
+
*
|
|
272
|
+
* 40, raised from 20 on 2026-11-22 (owner decision: raise the limit rather
|
|
273
|
+
* than reword the warning). The 2026-11-21 06:30 PT indigo job had 31
|
|
274
|
+
* documents waiting after four days of signed-out runs: 20 were read in about
|
|
275
|
+
* 2m45s for the whole job (about 8s a document) and 11 were left for the next
|
|
276
|
+
* day, so a run with nothing wrong was reported as partial. 40 covers that
|
|
277
|
+
* backlog, and a 24-meeting re-run, in one pass.
|
|
278
|
+
*
|
|
279
|
+
* The cap still bounds the run. Calls stay subscription-only (an API-key or
|
|
280
|
+
* third-party login is refused before the first document), a usage-limit reply
|
|
281
|
+
* stops the pass at once, and BAD_OUTPUT_STOP_AFTER stops a run of unusable
|
|
282
|
+
* replies, so raising the cap adds no per-token spend. At the observed rate 40
|
|
283
|
+
* documents take about 5-6 minutes; each call keeps its own
|
|
284
|
+
* DEFAULT_SIGNALS_TIMEOUT_MS budget, and the sync lock is heartbeated, so a
|
|
285
|
+
* longer pass is not taken over as stale.
|
|
286
|
+
*
|
|
287
|
+
* Worst-case duration (not expected; it needs nearly every call to run to its
|
|
288
|
+
* full 120 s budget without BAD_OUTPUT_STOP_AFTER documents failing in a row):
|
|
289
|
+
* - Unusable replies: 40 documents x BAD_OUTPUT_ATTEMPTS (3) calls x 120 s =
|
|
290
|
+
* 4 hours (2 hours at the old cap of 20). That is longer than the 3 hours
|
|
291
|
+
* after which the engine's company run lock can be taken over (LOCK_STALE_MS
|
|
292
|
+
* in src/lib/signals/run-lock.ts, counted from the lock's start, with no
|
|
293
|
+
* heartbeat).
|
|
294
|
+
* - Once a timed-out document is skipped instead of sent again (PR 3438, not
|
|
295
|
+
* merged when this was written): 40 x 120 s = 80 minutes (40 minutes at the
|
|
296
|
+
* old cap). That is longer than the 60 minutes after which the bot releases
|
|
297
|
+
* an in-flight job (IN_FLIGHT_RELEASE_MS in src/lib/bot/local-jobs.ts).
|
|
298
|
+
* The worklist listing keeps its fixed WORKLIST_TIMEOUT_MS (60 s) at
|
|
299
|
+
* `--limit 40`; it does not grow with the limit the way the extract step's
|
|
300
|
+
* listing budget does (src/lib/signals/steps/extract.ts).
|
|
301
|
+
*/
|
|
302
|
+
export const DEFAULT_MAX_SIGNAL_DOCS = 40;
|
|
271
303
|
/**
|
|
272
304
|
* Claude calls per document when the reply is unusable (`claude-bad-output`).
|
|
273
305
|
* The reply differs from call to call, so a document whose first reply has a
|
|
@@ -412,6 +444,29 @@ export function signalCitation(at, segments, sourceRef) {
|
|
|
412
444
|
const seg = startMs === null ? undefined : segments.get(startMs);
|
|
413
445
|
return seg ? { source_ref: sourceRef, start_ms: seg.startMs, end_ms: seg.endMs } : undefined;
|
|
414
446
|
}
|
|
447
|
+
/**
|
|
448
|
+
* A meeting recap cites the span of the segments it is given: the earliest
|
|
449
|
+
* segment start and the latest segment end, whatever order the markers come
|
|
450
|
+
* in, so an out-of-order or overlapping marker cannot give a start after the
|
|
451
|
+
* end or a span shorter than one segment. `segments` comes from the payload
|
|
452
|
+
* text the pass read, which is capped at MAX_PAYLOAD_BYTES, so a longer
|
|
453
|
+
* transcript is cited up to the last marker inside that cap, not to its end.
|
|
454
|
+
* Undefined when there are no segments. Nothing is inferred beyond the
|
|
455
|
+
* markers already in `segments`.
|
|
456
|
+
*/
|
|
457
|
+
export function summaryTranscriptCitation(segments, sourceRef) {
|
|
458
|
+
let startMs;
|
|
459
|
+
let endMs;
|
|
460
|
+
for (const seg of segments.values()) {
|
|
461
|
+
if (startMs === undefined || seg.startMs < startMs)
|
|
462
|
+
startMs = seg.startMs;
|
|
463
|
+
if (endMs === undefined || seg.endMs > endMs)
|
|
464
|
+
endMs = seg.endMs;
|
|
465
|
+
}
|
|
466
|
+
if (startMs === undefined || endMs === undefined)
|
|
467
|
+
return undefined;
|
|
468
|
+
return { source_ref: sourceRef, start_ms: startMs, end_ms: endMs };
|
|
469
|
+
}
|
|
415
470
|
export function defaultPromptFile() {
|
|
416
471
|
return path.join(path.dirname(fileURLToPath(import.meta.url)), "prompts", "signals-pass.md");
|
|
417
472
|
}
|
|
@@ -1348,7 +1403,14 @@ export function createClaudeSignalsPass(options) {
|
|
|
1348
1403
|
origin: SIGNAL_ORIGIN,
|
|
1349
1404
|
written_at: at,
|
|
1350
1405
|
};
|
|
1351
|
-
|
|
1406
|
+
let citation = signalCitation(signal.at, segments, sourceRef);
|
|
1407
|
+
// A recap has no single `at`. Cite the span of the segments read (the
|
|
1408
|
+
// payload is capped at MAX_PAYLOAD_BYTES) so upload can keep it. Only a
|
|
1409
|
+
// signal written by this run gets one: a signal file already on disk is
|
|
1410
|
+
// skipped above and is not rewritten.
|
|
1411
|
+
if (citation === undefined && signal.type === "summary") {
|
|
1412
|
+
citation = summaryTranscriptCitation(segments, sourceRef);
|
|
1413
|
+
}
|
|
1352
1414
|
if (citation !== undefined)
|
|
1353
1415
|
frontmatter.citations = [citation];
|
|
1354
1416
|
if (input.payloadRef !== undefined)
|
|
@@ -25,6 +25,12 @@ export declare function shimPath(hqRoot: string): string;
|
|
|
25
25
|
/** Which HQ hook script the user-scope install registers. */
|
|
26
26
|
export type HookTarget = 'master' | 'shim' | NativeTarget | CoreNextTarget;
|
|
27
27
|
export declare function charterPath(hqRoot: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Claude Code @imports do not load when the path contains backslashes.
|
|
30
|
+
* `path.join` on Windows writes `\`; convert those (and any `\` already in
|
|
31
|
+
* hqRoot) so the managed CLAUDE.md block uses forward slashes on every OS.
|
|
32
|
+
*/
|
|
33
|
+
export declare function claudeMdImportPath(hqRoot: string): string;
|
|
28
34
|
export declare function hqSkillsSource(hqRoot: string): string;
|
|
29
35
|
/** The exact hook command registered for one event (absolute path, quoted). */
|
|
30
36
|
export declare function hookCommand(hqRoot: string, event: string, target?: HookTarget): string;
|
|
@@ -46,6 +46,14 @@ export function shimPath(hqRoot) {
|
|
|
46
46
|
export function charterPath(hqRoot) {
|
|
47
47
|
return path.join(hqRoot, '.claude', 'CLAUDE.md');
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Claude Code @imports do not load when the path contains backslashes.
|
|
51
|
+
* `path.join` on Windows writes `\`; convert those (and any `\` already in
|
|
52
|
+
* hqRoot) so the managed CLAUDE.md block uses forward slashes on every OS.
|
|
53
|
+
*/
|
|
54
|
+
export function claudeMdImportPath(hqRoot) {
|
|
55
|
+
return charterPath(hqRoot).split('\\').join('/');
|
|
56
|
+
}
|
|
49
57
|
export function hqSkillsSource(hqRoot) {
|
|
50
58
|
return path.join(hqRoot, '.claude', 'skills');
|
|
51
59
|
}
|
|
@@ -69,7 +77,7 @@ function shellQuote(value) {
|
|
|
69
77
|
// CLAUDE.md block.
|
|
70
78
|
// ---------------------------------------------------------------------------
|
|
71
79
|
function claudeMdBlock(hqRoot) {
|
|
72
|
-
return `${CLAUDE_MD_BEGIN}\n@${
|
|
80
|
+
return `${CLAUDE_MD_BEGIN}\n@${claudeMdImportPath(hqRoot)}\n${CLAUDE_MD_END}\n`;
|
|
73
81
|
}
|
|
74
82
|
/** Append the block (replacing any prior HQ block). `null` input = file absent. */
|
|
75
83
|
export function addClaudeMdBlock(current, hqRoot) {
|
|
@@ -5,7 +5,7 @@ export interface ReconcilePassResult {
|
|
|
5
5
|
message: string;
|
|
6
6
|
}[];
|
|
7
7
|
}
|
|
8
|
-
type ReconcileFailureCode = "reconcile_step_failed" | "
|
|
8
|
+
type ReconcileFailureCode = "reconcile_step_failed" | "story_close_ledger_read_failed";
|
|
9
9
|
export declare function recordReconcileFailure(result: ReconcilePassResult, code: ReconcileFailureCode): void;
|
|
10
10
|
/** Only this module constructs a diagnostic from a closed set of codes. */
|
|
11
11
|
export declare function reconcileFailureText(error: unknown): string;
|
|
@@ -147,6 +147,17 @@ function isMissingPathError(error) {
|
|
|
147
147
|
const code = error?.code;
|
|
148
148
|
return code === "ENOENT" || code === "ENOTDIR";
|
|
149
149
|
}
|
|
150
|
+
const MISSING_STORY_LEDGER_NOTE_PREFIX = "Story close skipped for lane ";
|
|
151
|
+
function recordMissingStoryLedgerNote(summary, laneId) {
|
|
152
|
+
summary.notes ??= [];
|
|
153
|
+
// One stderr line per pass, however many lanes are affected: the daemon runs
|
|
154
|
+
// a pass every 15 s, and the per-lane detail is in the summary notes.
|
|
155
|
+
const firstThisPass = !summary.notes.some((note) => note.startsWith(MISSING_STORY_LEDGER_NOTE_PREFIX));
|
|
156
|
+
summary.notes.push(`${MISSING_STORY_LEDGER_NOTE_PREFIX}${laneId}: its story ledger is absent on this host`);
|
|
157
|
+
if (firstThisPass) {
|
|
158
|
+
process.stderr.write("hq runners reconcile: note: story close skipped, story ledger absent on this host\n");
|
|
159
|
+
}
|
|
160
|
+
}
|
|
150
161
|
function recordMissingCodexHomeNote(summary, home) {
|
|
151
162
|
const note = `Codex rollout retention skipped home absent on this host: ${home}`;
|
|
152
163
|
summary.notes ??= [];
|
|
@@ -633,14 +644,18 @@ async function closeInterruptedDoneStoryWorkers(hqRoot, lanes, questions, summar
|
|
|
633
644
|
ledger = laneStoryLedgerIsClosed(hqRoot, lane);
|
|
634
645
|
}
|
|
635
646
|
catch (err) {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
:
|
|
647
|
+
if (err instanceof LanesError && err.error === "story_ledger_missing") {
|
|
648
|
+
// An absent ledger is an expected state (a project removed or not
|
|
649
|
+
// synced to this host), not a failed pass: the lane cannot be proven
|
|
650
|
+
// done, so it stays interrupted and the pass stays healthy.
|
|
651
|
+
recordMissingStoryLedgerNote(summary, lane.lane_id);
|
|
652
|
+
continue;
|
|
653
|
+
}
|
|
639
654
|
markDirty(summary, {
|
|
640
655
|
kind: "lane",
|
|
641
656
|
id: lane.lane_id,
|
|
642
657
|
why: `story close ledger read failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
643
|
-
},
|
|
658
|
+
}, "story_close_ledger_read_failed");
|
|
644
659
|
continue;
|
|
645
660
|
}
|
|
646
661
|
if (!ledger.closed)
|
|
@@ -29,5 +29,11 @@ declare function tmux(socket: string, args: string[]): {
|
|
|
29
29
|
stderr: string;
|
|
30
30
|
};
|
|
31
31
|
export declare function remoteControlFailureText(socket: string, session: string, capture?: typeof tmux): string;
|
|
32
|
+
/**
|
|
33
|
+
* The env for the namespace that runs the Remote Control terminal. The tmux
|
|
34
|
+
* server and Claude inside it inherit this, so it carries no secret-bearing
|
|
35
|
+
* variables (worker-env-scrub.ts).
|
|
36
|
+
*/
|
|
37
|
+
export declare function remoteControlNamespaceEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
32
38
|
export {};
|
|
33
39
|
//# sourceMappingURL=remote-control-lane.d.ts.map
|
|
@@ -18,6 +18,7 @@ import { LanesError } from "./errors.js";
|
|
|
18
18
|
import { readLaneClaudeCredential } from "./claude-credential.js";
|
|
19
19
|
import { defaultProbe } from "./models.js";
|
|
20
20
|
import { encodeClaudeProjectDir } from "./move-account.js";
|
|
21
|
+
import { laneWorkerEnv } from "./worker-env-scrub.js";
|
|
21
22
|
/** Keep every credential and network route tied to the selected pool. */
|
|
22
23
|
export function configureRemoteControlChildEnv(env, launch) {
|
|
23
24
|
// The default home runs with CLAUDE_CONFIG_DIR unset so it reads the same
|
|
@@ -237,6 +238,14 @@ async function runInside(args) {
|
|
|
237
238
|
fs.rmSync(exitFile, { force: true });
|
|
238
239
|
}
|
|
239
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* The env for the namespace that runs the Remote Control terminal. The tmux
|
|
243
|
+
* server and Claude inside it inherit this, so it carries no secret-bearing
|
|
244
|
+
* variables (worker-env-scrub.ts).
|
|
245
|
+
*/
|
|
246
|
+
export function remoteControlNamespaceEnv(env) {
|
|
247
|
+
return laneWorkerEnv(env);
|
|
248
|
+
}
|
|
240
249
|
async function runOuter(args) {
|
|
241
250
|
const [daemonRoot, laneId, accountId, address] = args;
|
|
242
251
|
if (!daemonRoot || !laneId || !accountId || !address)
|
|
@@ -254,7 +263,7 @@ async function runOuter(args) {
|
|
|
254
263
|
"--map-root-user", "--mount", "--fork", "--kill-child=TERM",
|
|
255
264
|
"sh", "-c", script, "hq-lane-rc", overlay,
|
|
256
265
|
process.execPath, fileURLToPath(import.meta.url), "inside", ...args,
|
|
257
|
-
], { cwd: process.cwd(), env: process.env, stdio: "inherit" });
|
|
266
|
+
], { cwd: process.cwd(), env: remoteControlNamespaceEnv(process.env), stdio: "inherit" });
|
|
258
267
|
let settled = false;
|
|
259
268
|
const forward = () => child.kill("SIGTERM");
|
|
260
269
|
const finish = (code) => {
|
|
@@ -164,6 +164,8 @@ export declare function stopLaneProcesses(hqRoot: string, laneId: string, deps?:
|
|
|
164
164
|
export interface ProveDetachedDeps {
|
|
165
165
|
/** Test seam: throw ENOENT to exercise the no-/proc fallback. */
|
|
166
166
|
readProcStatText?: (pid: number) => string;
|
|
167
|
+
/** Test seam: Windows has no session-leader proof. */
|
|
168
|
+
platform?: NodeJS.Platform;
|
|
167
169
|
}
|
|
168
170
|
export declare function defaultProveDetached(pid: number, deps?: ProveDetachedDeps): DetachProof;
|
|
169
171
|
export declare function nextEnvelopePath(runDir: string): string;
|
package/dist/lib/lanes/spawn.js
CHANGED
|
@@ -15,6 +15,7 @@ import * as fs from "node:fs";
|
|
|
15
15
|
import * as path from "node:path";
|
|
16
16
|
import { fileURLToPath } from "node:url";
|
|
17
17
|
import { configureRemoteControlChildEnv, prepareRemoteControlLane, remoteControlSelectionConfig } from "./remote-control-lane.js";
|
|
18
|
+
import { laneWorkerEnv } from "./worker-env-scrub.js";
|
|
18
19
|
import { PROVIDER_HOME_ENV, accountStatus, isDefaultProviderHome, isLoggedOut, isSignInExpired, resolveAccount, selectBalancedAccount, } from "./accounts.js";
|
|
19
20
|
import { readLaneClaudeCredential } from "./claude-credential.js";
|
|
20
21
|
import { effectiveAccountHome } from "./account-home.js";
|
|
@@ -1279,6 +1280,14 @@ export function defaultProveDetached(pid, deps = {}) {
|
|
|
1279
1280
|
throw err;
|
|
1280
1281
|
}
|
|
1281
1282
|
}
|
|
1283
|
+
// Windows Node spawn({ detached: true, windowsHide: true }) already made an
|
|
1284
|
+
// independent process. There is no /proc session-leader, and Git Bash `ps`
|
|
1285
|
+
// either is missing or reports pgid != pid, so requiring Unix session
|
|
1286
|
+
// leadership fails every live worker (feedback_5f4676f9).
|
|
1287
|
+
const platform = deps.platform ?? process.platform;
|
|
1288
|
+
if (platform === "win32") {
|
|
1289
|
+
return { detached: true, pid, method: "pid_alive_without_proc" };
|
|
1290
|
+
}
|
|
1282
1291
|
const psProof = proveDetachedViaPs(pid);
|
|
1283
1292
|
if (psProof)
|
|
1284
1293
|
return psProof;
|
|
@@ -1831,7 +1840,8 @@ export function workerEnv(base, resolved, laneId, hqRoot, autoCompactTokens, mes
|
|
|
1831
1840
|
if (!accepted.includes(resolved.envVar)) {
|
|
1832
1841
|
throw new LanesError("unknown_provider_home_env", `Unknown provider home variable ${JSON.stringify(resolved.envVar)}. Accepted: ${accepted.join(", ")}`, { accepted, value: resolved.envVar });
|
|
1833
1842
|
}
|
|
1834
|
-
|
|
1843
|
+
// Lane workers start without secret-bearing variables (worker-env-scrub.ts).
|
|
1844
|
+
const env = laneWorkerEnv(base);
|
|
1835
1845
|
delete env.HQ_PROJECT_ID;
|
|
1836
1846
|
delete env.HQ_STORY_ID;
|
|
1837
1847
|
delete env.HQ_POLICY_WORKER_DIR;
|
|
@@ -2095,7 +2105,10 @@ function spawnTrackedWorker(spawnProcess, command, args, env, cwd, stdoutPath, s
|
|
|
2095
2105
|
throw error;
|
|
2096
2106
|
}
|
|
2097
2107
|
const runnerPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../../dist/lib/lanes/worker-process.js");
|
|
2098
|
-
return spawnDetached(spawnProcess, liveNodeBinary(), [runnerPath, command, ...args],
|
|
2108
|
+
return spawnDetached(spawnProcess, liveNodeBinary(), [runnerPath, command, ...args],
|
|
2109
|
+
// workerEnv already scrubbed this env; filtering again here keeps every
|
|
2110
|
+
// worker spawn safe even for a caller that did not build it with workerEnv.
|
|
2111
|
+
{ ...laneWorkerEnv(env), [LANE_WORKER_EXIT_PATH_ENV]: exitPath }, cwd, stdoutPath, stderrPath);
|
|
2099
2112
|
}
|
|
2100
2113
|
function requireDetached(proveDetached, pid, kind) {
|
|
2101
2114
|
const proof = proveDetached(pid);
|
|
@@ -2231,7 +2244,10 @@ export function armLaneWatcher(hqRoot, laneId, deps = {}) {
|
|
|
2231
2244
|
throw new LanesError("watcher_cli_entry_unavailable", "Cannot arm the lane watcher without the current hq CLI entrypoint", { lane_id: laneId });
|
|
2232
2245
|
}
|
|
2233
2246
|
const watcherPid = spawnDetached(spawnProcess, liveNodeBinary(), [watcherMainPath(), laneId], {
|
|
2234
|
-
|
|
2247
|
+
// The watcher lives as long as the lane and runs as the same user, so a
|
|
2248
|
+
// worker could read its process environment. It only runs `hq`, which
|
|
2249
|
+
// needs none of the removed variables (worker-env-scrub.ts).
|
|
2250
|
+
...laneWorkerEnv(env),
|
|
2235
2251
|
HQ_ROOT: hqRoot,
|
|
2236
2252
|
HQ_LANE_ID: laneId,
|
|
2237
2253
|
HQ_LANE_CLI_ENTRY: path.resolve(cliEntry),
|