@indigoai-us/hq-cli 5.345.212-beta.0 → 5.345.214
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 +40 -1
- package/dist/bin/hq-auth-refresh.js +2 -1
- package/dist/command-catalog.generated.d.ts +308 -43
- package/dist/command-catalog.generated.js +373 -43
- package/dist/command-registration-plan.d.ts +15 -0
- package/dist/command-registration-plan.js +20 -1
- package/dist/commands/agent-inbox.d.ts +11 -1
- package/dist/commands/agent-inbox.js +128 -38
- package/dist/commands/agent-kit.js +2 -2
- package/dist/commands/agents.js +6 -1
- package/dist/commands/billing.js +17 -4
- package/dist/commands/core-handoff.js +1 -0
- package/dist/commands/core-hq-session-native.js +2 -2
- package/dist/commands/core-pin-native.js +1 -1
- package/dist/commands/core-policy.js +1 -1
- package/dist/commands/core-resolve-company-native.js +1 -1
- package/dist/commands/core-sentry-report-fast.d.ts +2 -0
- package/dist/commands/core-sentry-report-fast.js +3 -1
- package/dist/commands/daemon.js +68 -6
- package/dist/commands/files.js +2 -2
- package/dist/commands/integrations-api.d.ts +11 -0
- package/dist/commands/integrations-connect.d.ts +9 -1
- package/dist/commands/integrations-connect.js +154 -18
- package/dist/commands/integrations-core.d.ts +1 -1
- package/dist/commands/integrations-core.js +18 -10
- package/dist/commands/integrations.js +1 -1
- package/dist/commands/lanes-link.js +10 -5
- package/dist/commands/lanes.js +34 -16
- package/dist/commands/rescue.js +13 -0
- package/dist/commands/secrets.d.ts +11 -0
- package/dist/commands/secrets.js +41 -7
- package/dist/index.js +2 -0
- package/dist/lazy-commands.js +6 -1
- package/dist/lib/agent-kit/inbox-fetch.d.ts +122 -1
- package/dist/lib/agent-kit/inbox-fetch.js +215 -3
- package/dist/lib/agent-kit/inbox-redact.js +1 -1
- package/dist/lib/agent-kit/inbox-state.d.ts +98 -1
- package/dist/lib/agent-kit/inbox-state.js +261 -4
- package/dist/lib/agent-kit/mcp/tools.d.ts +3 -3
- package/dist/lib/agent-kit/mcp/tools.js +68 -25
- package/dist/lib/agent-kit/run/inbox.js +4 -2
- package/dist/lib/agent-kit/skills.js +4 -1
- package/dist/lib/agent-kit/wake.d.ts +9 -1
- package/dist/lib/agent-kit/wake.js +10 -3
- package/dist/lib/billing/usage-only.d.ts +4 -1
- package/dist/lib/billing/usage-only.js +7 -2
- package/dist/lib/bot/fleet-cron.js +193 -14
- package/dist/lib/bot/fleet-download.d.ts +2 -0
- package/dist/lib/bot/fleet-download.js +23 -0
- package/dist/lib/bot/fleet-local.d.ts +1 -0
- package/dist/lib/bot/fleet-local.js +41 -8
- package/dist/lib/capacity/ledger.d.ts +7 -0
- package/dist/lib/capacity/ledger.js +31 -1
- package/dist/lib/capacity/project.d.ts +1 -1
- package/dist/lib/capacity/project.js +13 -4
- package/dist/lib/capacity/route.d.ts +10 -0
- package/dist/lib/capacity/route.js +16 -0
- package/dist/lib/core-utils/session-id.d.ts +1 -1
- package/dist/lib/core-utils/session-id.js +4 -0
- package/dist/lib/daemon/install.d.ts +15 -0
- package/dist/lib/daemon/install.js +31 -0
- package/dist/lib/daemon/migrate.js +29 -4
- package/dist/lib/daemon/run.js +9 -1
- package/dist/lib/daemon/updater.d.ts +34 -2
- package/dist/lib/daemon/updater.js +51 -2
- package/dist/lib/doctor/__testing__/run-doctor.js +4 -0
- package/dist/lib/doctor/checks/jq.d.ts +27 -0
- package/dist/lib/doctor/checks/jq.js +82 -0
- package/dist/lib/doctor/checks/release-links.d.ts +50 -8
- package/dist/lib/doctor/checks/release-links.js +260 -24
- package/dist/lib/doctor/fix/apply.js +24 -8
- package/dist/lib/doctor/fix/remediation.js +15 -5
- package/dist/lib/doctor/registry.js +4 -0
- package/dist/lib/flag-snapshot-file.js +36 -8
- package/dist/lib/install/codex-targets.d.ts +52 -1
- package/dist/lib/install/codex-targets.js +77 -2
- package/dist/lib/lanes/autopilot-registry.d.ts +14 -0
- package/dist/lib/lanes/autopilot-registry.js +59 -7
- package/dist/lib/lanes/links.d.ts +14 -0
- package/dist/lib/lanes/links.js +320 -25
- package/dist/lib/lanes/monitor.d.ts +4 -1
- package/dist/lib/lanes/monitor.js +47 -10
- package/dist/lib/lanes/outpost-pruner-install.d.ts +10 -0
- package/dist/lib/lanes/outpost-pruner-install.js +4 -3
- package/dist/lib/lanes/spawn.js +8 -1
- package/dist/lib/lanes/watch.js +31 -0
- package/dist/lib/onboarding/checkpoint.d.ts +6 -0
- package/dist/lib/onboarding/checkpoint.js +6 -0
- package/dist/lib/onboarding/orchestrator.d.ts +3 -1
- package/dist/lib/onboarding/orchestrator.js +62 -9
- package/dist/lib/onboarding/types.d.ts +8 -0
- package/dist/lib/work-context/organize.d.ts +23 -1
- package/dist/lib/work-context/organize.js +25 -3
- package/dist/lib/work-context/reconcile.js +3 -2
- package/dist/main.js +3 -1
- package/dist/secrets-env-action.js +7 -5
- package/dist/sentry-init.d.ts +2 -0
- package/dist/sentry-init.js +13 -2
- package/dist/sentry.d.ts +2 -0
- package/dist/sentry.js +5 -1
- package/dist/startup-registration.js +7 -2
- package/dist/utils/billing-gate.d.ts +12 -16
- package/dist/utils/billing-gate.js +17 -18
- package/dist/utils/cli-network-lifecycle.d.ts +9 -0
- package/dist/utils/cli-network-lifecycle.js +52 -0
- package/dist/utils/install-tree-torn.d.ts +22 -4
- package/dist/utils/install-tree-torn.js +24 -0
- package/dist/utils/registration-plan-error.d.ts +22 -0
- package/dist/utils/registration-plan-error.js +27 -0
- package/dist/utils/safe-link.d.ts +63 -0
- package/dist/utils/safe-link.js +246 -0
- package/dist/utils/sentry-fingerprint.js +3 -0
- package/dist/utils/sentry-keepalive-transport.d.ts +28 -0
- package/dist/utils/sentry-keepalive-transport.js +70 -0
- package/dist/utils/unauthorized-error.d.ts +36 -0
- package/dist/utils/unauthorized-error.js +105 -0
- package/dist/utils/vault-api.js +7 -5
- package/package.json +7 -7
- package/scripts/install-hook-engine.mjs +17 -0
|
@@ -100,6 +100,80 @@ export function isAdapterEntry(entry, hqRoot) {
|
|
|
100
100
|
cmd.includes(JSON.stringify(shimPath(hqRoot))) ||
|
|
101
101
|
cmd.includes(JSON.stringify(path.join(hqRoot, 'core', 'packages', 'hq-anywhere', 'hooks', 'codex.sh')))));
|
|
102
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Where Codex hook runs claim an event, under `$HOME` (feedback_bf4df70e,
|
|
105
|
+
* feedback_d69d01c0). Shared with the hq-core Codex hook adapter
|
|
106
|
+
* (`.codex/hooks/hq-codex-hook-adapter.sh`), which claims the same way, so the
|
|
107
|
+
* two must agree on this directory, the key and the window.
|
|
108
|
+
*/
|
|
109
|
+
export const CODEX_HOOK_CLAIM_DIR = '.hq/state/codex-hook-claims';
|
|
110
|
+
/** A claim younger than this many seconds makes a second run of the same event a no-op. */
|
|
111
|
+
export const CODEX_HOOK_CLAIM_WINDOW_SECONDS = 10;
|
|
112
|
+
/** Claim markers older than this many minutes are pruned on every successful claim. */
|
|
113
|
+
export const CODEX_HOOK_CLAIM_PRUNE_MINUTES = 2;
|
|
114
|
+
/** Set on the hook a wrapper claimed for, so the adapter it runs does not claim again. */
|
|
115
|
+
export const CODEX_HOOK_CLAIM_ENV = 'HQ_CODEX_HOOK_CLAIM';
|
|
116
|
+
/** The file a user-scope entry runs: the adapter, the hqd shim, or the native engine. */
|
|
117
|
+
function codexHookTargetPath(hqRoot, target) {
|
|
118
|
+
if (target === 'shim')
|
|
119
|
+
return shimPath(hqRoot);
|
|
120
|
+
if (typeof target === 'object')
|
|
121
|
+
return target.engine;
|
|
122
|
+
return codexAdapterPath(hqRoot);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Wrap a user-scope (~/.codex/hooks.json) command so one Codex event runs the
|
|
126
|
+
* HQ hooks once (feedback_bf4df70e, feedback_d69d01c0).
|
|
127
|
+
*
|
|
128
|
+
* Inside an HQ root, Codex runs this entry and the root's own
|
|
129
|
+
* `.codex/config.toml` hook for the same event, at the same time, with no
|
|
130
|
+
* dedupe. Predicting from a shell whether Codex will load and trust the project
|
|
131
|
+
* hook proved unreliable (project-root rules, per-hook trust by hash, path
|
|
132
|
+
* spellings), so both registrations stay and the second run of an event is a
|
|
133
|
+
* no-op at runtime instead. Each run claims the event once:
|
|
134
|
+
*
|
|
135
|
+
* - The key is `cksum` of the real HQ root, the Codex process (`$PPID`) and
|
|
136
|
+
* the exact stdin payload. Codex sends both hooks of one event the same
|
|
137
|
+
* payload from the same process; different events differ in their payload
|
|
138
|
+
* (event name, tool call, turn), and other Codex sessions differ in `$PPID`.
|
|
139
|
+
* - The claim is an atomic `mkdir` of `$HOME/.hq/state/codex-hook-claims/<key>`
|
|
140
|
+
* holding the claim time. The first run to create it does the full work. A
|
|
141
|
+
* run that finds a claim younger than {@link CODEX_HOOK_CLAIM_WINDOW_SECONDS}
|
|
142
|
+
* exits 0 with no output; an older claim is taken over, so two identical
|
|
143
|
+
* events further apart both run. Markers older than
|
|
144
|
+
* {@link CODEX_HOOK_CLAIM_PRUNE_MINUTES} minutes are pruned.
|
|
145
|
+
* - The claiming run passes {@link CODEX_HOOK_CLAIM_ENV} to the command it
|
|
146
|
+
* runs, so the HQ adapter does not claim a second time.
|
|
147
|
+
* - When anything needed is missing (`HOME`, the HQ root, the target file, a
|
|
148
|
+
* writable claim directory, `cksum`), the entry runs without claiming. Any
|
|
149
|
+
* failure therefore leads to the hook running twice, never to no hook.
|
|
150
|
+
*
|
|
151
|
+
* Until the hq-core adapter claims too, the project hook never claims, this
|
|
152
|
+
* entry always wins, and both still run, as before. `commandWindows` is not
|
|
153
|
+
* wrapped, so Windows keeps running both.
|
|
154
|
+
*/
|
|
155
|
+
export function codexUserHookClaimed(hqRoot, target, command) {
|
|
156
|
+
const root = quotePosix(hqRoot);
|
|
157
|
+
const file = quotePosix(codexHookTargetPath(hqRoot, target));
|
|
158
|
+
return (`p=$(cat); c=; d=\${HOME:+$HOME/${CODEX_HOOK_CLAIM_DIR}}; r=$(cd ${root} 2>/dev/null && pwd -P); ` +
|
|
159
|
+
`if [ -n "$d" ] && [ -n "$r" ] && [ -f ${file} ] && mkdir -p "$d" 2>/dev/null; then ` +
|
|
160
|
+
`k=$({ printf '%s\\n%s\\n' "$r" "$PPID"; printf '%s' "$p"; } | cksum 2>/dev/null); set -- $k; ` +
|
|
161
|
+
`if [ -n "$2" ] && n=$(date +%s 2>/dev/null) && case "$n" in ''|*[!0-9]*) false ;; esac; then c="$1-$2"; ` +
|
|
162
|
+
`if mkdir "$d/$c" 2>/dev/null; then printf '%s\\n' "$n" > "$d/$c/t"; ` +
|
|
163
|
+
`else t=$(cat "$d/$c/t" 2>/dev/null); case "$t" in '') t=$n ;; *[!0-9]*) t=0 ;; esac; ` +
|
|
164
|
+
`if [ $((n - t)) -lt ${CODEX_HOOK_CLAIM_WINDOW_SECONDS} ]; then exit 0; fi; ` +
|
|
165
|
+
`rm -rf "$d/$c"; if mkdir "$d/$c" 2>/dev/null; then printf '%s\\n' "$n" > "$d/$c/t"; else exit 0; fi; fi; ` +
|
|
166
|
+
`find "$d" -mindepth 1 -maxdepth 1 -mmin +${CODEX_HOOK_CLAIM_PRUNE_MINUTES} -exec rm -rf {} + 2>/dev/null; fi; fi; ` +
|
|
167
|
+
`printf '%s\\n' "$p" | ${CODEX_HOOK_CLAIM_ENV}="$c" ${command}`);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The user-scope hooks.json entry: {@link codexHookEntry} behind
|
|
171
|
+
* {@link codexUserHookClaimed}. `commandWindows` is unchanged.
|
|
172
|
+
*/
|
|
173
|
+
export function codexUserHookEntry(hqRoot, event, target = 'master') {
|
|
174
|
+
const entry = codexHookEntry(hqRoot, event, target);
|
|
175
|
+
return { ...entry, command: codexUserHookClaimed(hqRoot, target, entry.command) };
|
|
176
|
+
}
|
|
103
177
|
/** The HQ hooks.json entry for one event and target. */
|
|
104
178
|
export function codexHookEntry(hqRoot, event, target = 'master') {
|
|
105
179
|
const timeout = event === 'SessionEnd' ? 3 : 300;
|
|
@@ -110,13 +184,14 @@ export function codexHookEntry(hqRoot, event, target = 'master') {
|
|
|
110
184
|
}
|
|
111
185
|
/**
|
|
112
186
|
* Add one HQ hook group per event; idempotent. An HQ entry for the other
|
|
113
|
-
* target (adapter vs the hqd shim) is swapped out
|
|
187
|
+
* target (adapter vs the hqd shim) is swapped out, and so is an HQ entry
|
|
188
|
+
* written before the user-scope guard existed. Foreign hooks are untouched.
|
|
114
189
|
*/
|
|
115
190
|
export function addCodexHooks(doc, hqRoot, target = 'master') {
|
|
116
191
|
const hooks = { ...(doc.hooks ?? {}) };
|
|
117
192
|
let changed = false;
|
|
118
193
|
for (const event of CODEX_HOOK_EVENTS) {
|
|
119
|
-
const want =
|
|
194
|
+
const want = codexUserHookEntry(hqRoot, event, target);
|
|
120
195
|
let groups = Array.isArray(hooks[event]) ? [...hooks[event]] : [];
|
|
121
196
|
const present = groups.some((g) => Array.isArray(g?.hooks) && g.hooks.some((h) => h.command === want.command && h.commandWindows === ('commandWindows' in want ? want.commandWindows : undefined)));
|
|
122
197
|
if (present)
|
|
@@ -3,6 +3,10 @@ declare const OUTPOST_LEAD_REGISTRY_SCHEMA = "hq-lanes-outpost-lead-registry.v1"
|
|
|
3
3
|
export declare const LEAD_REGISTRY_REL: string;
|
|
4
4
|
export declare const OUTPOST_LEAD_REGISTRY_STATE_REL: string;
|
|
5
5
|
export declare const LEAD_AUTOPILOT_FLAG = "lanes.lead-autopilot";
|
|
6
|
+
/** First wait after a failed delivery to one Outpost; doubles per failure. */
|
|
7
|
+
export declare const LEAD_REGISTRY_RETRY_BASE_MS = 30000;
|
|
8
|
+
/** The wait between delivery attempts never grows past this. */
|
|
9
|
+
export declare const LEAD_REGISTRY_RETRY_MAX_MS: number;
|
|
6
10
|
export interface LeadRegistryRow {
|
|
7
11
|
team: string;
|
|
8
12
|
lane: string;
|
|
@@ -16,6 +20,12 @@ export interface OutpostLeadRegistry {
|
|
|
16
20
|
generated_at: string;
|
|
17
21
|
juniors: LeadRegistryRow[];
|
|
18
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Wait before the next delivery after `failures` consecutive failures:
|
|
25
|
+
* 30 s, 60 s, 2 min, ... capped at 30 min, then scaled by a jitter factor in
|
|
26
|
+
* [0.5, 1] so many machines do not retry in step.
|
|
27
|
+
*/
|
|
28
|
+
export declare function leadRegistryRetryDelayMs(failures: number, random?: () => number): number;
|
|
19
29
|
export declare function buildOutpostLeadRegistry(input: {
|
|
20
30
|
rows: readonly LeadRegistryRow[];
|
|
21
31
|
outpostId: string;
|
|
@@ -41,6 +51,8 @@ export declare function syncOutpostLeadRegistries(input: {
|
|
|
41
51
|
stdout: string;
|
|
42
52
|
stderr: string;
|
|
43
53
|
}>;
|
|
54
|
+
/** Jitter source for the retry backoff; tests pass a fixed value. */
|
|
55
|
+
random?: () => number;
|
|
44
56
|
}): Promise<Array<{
|
|
45
57
|
outpost_id: string;
|
|
46
58
|
row_count: number;
|
|
@@ -49,6 +61,8 @@ export declare function syncOutpostLeadRegistries(input: {
|
|
|
49
61
|
reason: string;
|
|
50
62
|
}>;
|
|
51
63
|
dispatched: boolean;
|
|
64
|
+
/** Set when an earlier failure holds this Outpost's delivery until then. */
|
|
65
|
+
retry_after?: string;
|
|
52
66
|
}>>;
|
|
53
67
|
export declare function validateOutpostLeadRegistry(input: {
|
|
54
68
|
registry: unknown;
|
|
@@ -10,6 +10,21 @@ const OUTPOST_LEAD_REGISTRY_REFRESH_MS = 6 * 60 * 60 * 1000;
|
|
|
10
10
|
export const LEAD_REGISTRY_REL = path.join("workspace", "lane-briefs", "juniors.json");
|
|
11
11
|
export const OUTPOST_LEAD_REGISTRY_STATE_REL = path.join("workspace", "lane-briefs", "autopilot-outpost-registry-state.json");
|
|
12
12
|
export const LEAD_AUTOPILOT_FLAG = "lanes.lead-autopilot";
|
|
13
|
+
/** First wait after a failed delivery to one Outpost; doubles per failure. */
|
|
14
|
+
export const LEAD_REGISTRY_RETRY_BASE_MS = 30_000;
|
|
15
|
+
/** The wait between delivery attempts never grows past this. */
|
|
16
|
+
export const LEAD_REGISTRY_RETRY_MAX_MS = 30 * 60 * 1000;
|
|
17
|
+
/**
|
|
18
|
+
* Wait before the next delivery after `failures` consecutive failures:
|
|
19
|
+
* 30 s, 60 s, 2 min, ... capped at 30 min, then scaled by a jitter factor in
|
|
20
|
+
* [0.5, 1] so many machines do not retry in step.
|
|
21
|
+
*/
|
|
22
|
+
export function leadRegistryRetryDelayMs(failures, random = Math.random) {
|
|
23
|
+
const exponent = Math.max(0, Math.min(failures - 1, 16));
|
|
24
|
+
const ceiling = Math.min(LEAD_REGISTRY_RETRY_MAX_MS, LEAD_REGISTRY_RETRY_BASE_MS * 2 ** exponent);
|
|
25
|
+
const jitter = Math.min(1, Math.max(0, random()));
|
|
26
|
+
return Math.round(ceiling * (0.5 + jitter / 2));
|
|
27
|
+
}
|
|
13
28
|
function isRecord(value) {
|
|
14
29
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
15
30
|
}
|
|
@@ -135,6 +150,14 @@ export async function syncOutpostLeadRegistries(input) {
|
|
|
135
150
|
const stateFile = path.join(input.hqRoot, OUTPOST_LEAD_REGISTRY_STATE_REL);
|
|
136
151
|
const state = readDeliveryState(stateFile);
|
|
137
152
|
const results = [];
|
|
153
|
+
const now = Date.parse(input.generatedAt);
|
|
154
|
+
const recordFailure = (outpostId) => {
|
|
155
|
+
const count = (state.failures?.[outpostId]?.count ?? 0) + 1;
|
|
156
|
+
const delay = leadRegistryRetryDelayMs(count, input.random);
|
|
157
|
+
const from = Number.isFinite(now) ? now : Date.now();
|
|
158
|
+
state.failures = { ...state.failures, [outpostId]: { count, next_at: new Date(from + delay).toISOString() } };
|
|
159
|
+
writeDeliveryState(stateFile, state);
|
|
160
|
+
};
|
|
138
161
|
const targets = [...new Set(input.outpostIds.map((id) => id.trim()))]
|
|
139
162
|
.filter((id) => id && !isControllerAliasOutpostId(id, input.localHost))
|
|
140
163
|
.sort();
|
|
@@ -149,23 +172,52 @@ export async function syncOutpostLeadRegistries(input) {
|
|
|
149
172
|
!Number.isFinite(age) ||
|
|
150
173
|
age < 0 ||
|
|
151
174
|
age >= OUTPOST_LEAD_REGISTRY_REFRESH_MS;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
175
|
+
const lanesSkipped = skipped.filter(({ lane }) => sourceRows.some((row) => row.lane === lane && row.host === outpostId));
|
|
176
|
+
// A failed delivery used to be retried on every reconcile pass (every
|
|
177
|
+
// 15 s) with no wait. Hold this Outpost until its backoff has passed.
|
|
178
|
+
const failure = state.failures?.[outpostId];
|
|
179
|
+
const retryAt = failure ? Date.parse(failure.next_at) : NaN;
|
|
180
|
+
// A stored time further ahead than the longest backoff (the clock moved
|
|
181
|
+
// back, or the file was edited) is ignored rather than holding for days.
|
|
182
|
+
const held = Number.isFinite(retryAt) && Number.isFinite(now) && now < retryAt &&
|
|
183
|
+
retryAt - now <= LEAD_REGISTRY_RETRY_MAX_MS;
|
|
184
|
+
if (shouldDispatch && held) {
|
|
185
|
+
results.push({
|
|
186
|
+
outpost_id: outpostId,
|
|
187
|
+
row_count: registry.juniors.length,
|
|
188
|
+
skipped: lanesSkipped,
|
|
189
|
+
dispatched: false,
|
|
190
|
+
retry_after: new Date(retryAt).toISOString(),
|
|
158
191
|
});
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
if (shouldDispatch) {
|
|
195
|
+
let result;
|
|
196
|
+
try {
|
|
197
|
+
result = await input.dispatch({
|
|
198
|
+
outpostId,
|
|
199
|
+
command: buildOutpostLeadRegistryInstallCommand(registry),
|
|
200
|
+
timeoutSeconds: 120,
|
|
201
|
+
waitMs: 120_000,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
recordFailure(outpostId);
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
159
208
|
if (result.done !== true || result.exitCode !== 0) {
|
|
209
|
+
recordFailure(outpostId);
|
|
160
210
|
throw new LanesError("lead_autopilot_registry_sync_failed", `Could not sync lead registry to Outpost ${outpostId}`, { outpost_id: outpostId, exit_code: result.exitCode, done: result.done === true });
|
|
161
211
|
}
|
|
162
212
|
state.delivered[outpostId] = { hash, at: new Date(input.generatedAt).toISOString() };
|
|
213
|
+
if (state.failures)
|
|
214
|
+
delete state.failures[outpostId];
|
|
163
215
|
writeDeliveryState(stateFile, state);
|
|
164
216
|
}
|
|
165
217
|
results.push({
|
|
166
218
|
outpost_id: outpostId,
|
|
167
219
|
row_count: registry.juniors.length,
|
|
168
|
-
skipped:
|
|
220
|
+
skipped: lanesSkipped,
|
|
169
221
|
dispatched: shouldDispatch,
|
|
170
222
|
});
|
|
171
223
|
}
|
|
@@ -22,6 +22,14 @@ export interface LinkOptions {
|
|
|
22
22
|
input?: string;
|
|
23
23
|
ackMode?: string;
|
|
24
24
|
claims?: string;
|
|
25
|
+
/** One-time handover token from `hq lanes link handover`, consumed by `adopt`. */
|
|
26
|
+
token?: string;
|
|
27
|
+
/** File holding the handover token; keeps it out of argv. */
|
|
28
|
+
tokenFile?: string;
|
|
29
|
+
/** Reads stdin for `--token -`. Injected in tests. */
|
|
30
|
+
readStdin?: () => string;
|
|
31
|
+
/** Test hook: runs after a conductor drain resolved its pointer and before it takes the queue lock. */
|
|
32
|
+
beforeConductorQueue?: () => Promise<void> | void;
|
|
25
33
|
now?: () => Date;
|
|
26
34
|
sleep?: (milliseconds: number) => Promise<void>;
|
|
27
35
|
/** Injected in tests; defaults to the real package-use lease drop/retake. */
|
|
@@ -40,6 +48,12 @@ export declare function resolveSignalConductor(root: string, env: NodeJS.Process
|
|
|
40
48
|
/** Cheap hook guard used before remote flag lookup or queue access. */
|
|
41
49
|
export declare function linkedSessionIdFromHookInput(input: string): string;
|
|
42
50
|
export declare function isLinkedSession(root: string, sid: string, env?: NodeJS.ProcessEnv): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Read all of stdin synchronously. `fs.readFileSync(0)` throws EAGAIN on a
|
|
53
|
+
* non-blocking stdin (some hosts hand one over) and EOF on a Windows console,
|
|
54
|
+
* so read in chunks: wait and retry on EAGAIN, and treat EOF as end of input.
|
|
55
|
+
*/
|
|
56
|
+
export declare function readStdinSync(read?: (fd: number, buffer: Buffer) => number, sleep?: (milliseconds: number) => void): string;
|
|
43
57
|
export declare function drainLinkQueue(inbox: string): string;
|
|
44
58
|
/** Called by the installed lane drain hook before core's pointer-file guard. */
|
|
45
59
|
export declare function bindSignalLaneHook(root: string, input: string, env: NodeJS.ProcessEnv): void;
|