@indigoai-us/hq-cli 5.345.212 → 5.345.215-beta.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.
- package/CHANGELOG.md +49 -0
- package/dist/bin/hq-auth-refresh.js +2 -1
- package/dist/command-catalog.generated.d.ts +442 -50
- package/dist/command-catalog.generated.js +541 -50
- 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.d.ts +51 -1
- package/dist/commands/agents.js +154 -2
- package/dist/commands/bot-jobs.d.ts +2 -15
- package/dist/commands/bot-jobs.js +2 -94
- package/dist/commands/bot-runtime.d.ts +46 -5
- package/dist/commands/bot-runtime.js +228 -18
- package/dist/commands/bot.d.ts +16 -9
- package/dist/commands/bot.js +169 -51
- package/dist/commands/cloud.d.ts +66 -13
- package/dist/commands/cloud.js +120 -39
- package/dist/commands/company-restore.d.ts +23 -0
- package/dist/commands/company-restore.js +128 -0
- package/dist/commands/company.js +2 -0
- 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 +11 -1
- package/dist/commands/integrations-connect.d.ts +17 -4
- package/dist/commands/integrations-connect.js +224 -26
- package/dist/commands/lanes-link.js +10 -5
- package/dist/commands/lanes.js +26 -9
- package/dist/commands/rescue.js +13 -0
- package/dist/commands/secrets.d.ts +11 -0
- package/dist/commands/secrets.js +41 -7
- package/dist/commands/sources.js +6 -0
- package/dist/commands/storage-offload.d.ts +12 -0
- package/dist/commands/storage-offload.js +41 -3
- package/dist/commands/sync-mode.js +5 -0
- package/dist/commands/whoami.js +4 -0
- package/dist/index.js +2 -0
- package/dist/lazy-commands.js +2 -0
- 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/bot/config.d.ts +1 -0
- package/dist/lib/bot/config.js +10 -0
- package/dist/lib/bot/eventbridge-cron.d.ts +22 -0
- package/dist/lib/bot/eventbridge-cron.js +104 -0
- 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 +34 -1
- package/dist/lib/bot/fleet-local.js +254 -37
- package/dist/lib/bot/fleet-python.d.ts +3 -0
- package/dist/lib/bot/fleet-python.js +34 -4
- package/dist/lib/bot/fleet-runtime-sources.d.ts +15 -0
- package/dist/lib/bot/fleet-runtime-sources.js +30 -0
- package/dist/lib/bot/legacy-provider-login.d.ts +8 -0
- package/dist/lib/bot/legacy-provider-login.js +19 -2
- package/dist/lib/bot/prompt.js +1 -1
- package/dist/lib/bot/readiness.d.ts +8 -0
- package/dist/lib/bot/readiness.js +17 -3
- package/dist/lib/bot/runtime-auth.d.ts +30 -0
- package/dist/lib/bot/runtime-auth.js +94 -3
- package/dist/lib/bot/status.d.ts +2 -0
- package/dist/lib/capacity/collectors/grok-refresh.d.ts +80 -0
- package/dist/lib/capacity/collectors/grok-refresh.js +189 -0
- package/dist/lib/capacity/collectors/grok.d.ts +5 -0
- package/dist/lib/capacity/collectors/grok.js +56 -5
- 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/catalog.js +11 -1
- 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/db/sqlite-binding.d.ts +1 -0
- package/dist/lib/db/sqlite-binding.js +1 -1
- package/dist/lib/delivery/artifacts.d.ts +99 -0
- package/dist/lib/delivery/artifacts.js +548 -0
- package/dist/lib/delivery/backup.d.ts +78 -0
- package/dist/lib/delivery/backup.js +343 -0
- package/dist/lib/delivery/cache.d.ts +29 -0
- package/dist/lib/delivery/cache.js +33 -0
- package/dist/lib/delivery/contracts.d.ts +142 -0
- package/dist/lib/delivery/contracts.js +289 -0
- package/dist/lib/delivery/credentials.d.ts +54 -0
- package/dist/lib/delivery/credentials.js +119 -0
- package/dist/lib/delivery/enrollment.d.ts +142 -0
- package/dist/lib/delivery/enrollment.js +382 -0
- package/dist/lib/delivery/identity.d.ts +25 -0
- package/dist/lib/delivery/identity.js +82 -0
- package/dist/lib/delivery/inbox.d.ts +116 -0
- package/dist/lib/delivery/inbox.js +260 -0
- package/dist/lib/delivery/migrations.d.ts +139 -0
- package/dist/lib/delivery/migrations.js +623 -0
- package/dist/lib/delivery/mqtt-adapter.d.ts +50 -0
- package/dist/lib/delivery/mqtt-adapter.js +242 -0
- package/dist/lib/delivery/mqtt.d.ts +61 -0
- package/dist/lib/delivery/mqtt.js +112 -0
- package/dist/lib/delivery/outbox.d.ts +95 -0
- package/dist/lib/delivery/outbox.js +187 -0
- package/dist/lib/delivery/provenance.d.ts +129 -0
- package/dist/lib/delivery/provenance.js +93 -0
- package/dist/lib/delivery/reconciler.d.ts +151 -0
- package/dist/lib/delivery/reconciler.js +492 -0
- package/dist/lib/delivery/restore.d.ts +35 -0
- package/dist/lib/delivery/restore.js +134 -0
- package/dist/lib/delivery/store.d.ts +161 -0
- package/dist/lib/delivery/store.js +940 -0
- package/dist/lib/delivery/workers/macos-job-helper.d.ts +103 -0
- package/dist/lib/delivery/workers/macos-job-helper.js +927 -0
- package/dist/lib/delivery/workers/macos.d.ts +176 -0
- package/dist/lib/delivery/workers/macos.js +901 -0
- package/dist/lib/delivery/workers/windows-boundary.d.ts +453 -0
- package/dist/lib/delivery/workers/windows-boundary.js +693 -0
- package/dist/lib/delivery/workers/windows-job-helper.d.ts +35 -0
- package/dist/lib/delivery/workers/windows-job-helper.js +264 -0
- package/dist/lib/delivery/workers/windows.d.ts +241 -0
- package/dist/lib/delivery/workers/windows.js +608 -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/install/provider-wrappers.d.ts +2 -0
- package/dist/lib/install/provider-wrappers.js +68 -3
- 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/outpost-pruner-install.d.ts +10 -0
- package/dist/lib/lanes/outpost-pruner-install.js +4 -3
- package/dist/main.js +3 -1
- 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/utils/cli-network-lifecycle.d.ts +9 -0
- package/dist/utils/cli-network-lifecycle.js +52 -0
- package/dist/utils/cognito-callback-port.d.ts +14 -0
- package/dist/utils/cognito-callback-port.js +24 -0
- package/dist/utils/cognito-session.js +3 -3
- package/dist/utils/deleted-company-notice.d.ts +59 -0
- package/dist/utils/deleted-company-notice.js +156 -0
- package/dist/utils/login-browser.d.ts +1 -1
- package/dist/utils/login-browser.js +7 -5
- package/dist/utils/resident-package-preload.js +30 -15
- package/dist/utils/safe-link.d.ts +63 -0
- package/dist/utils/safe-link.js +246 -0
- package/dist/utils/sentry-keepalive-transport.d.ts +28 -0
- package/dist/utils/sentry-keepalive-transport.js +70 -0
- package/dist/utils/vault-api.js +7 -0
- package/package.json +7 -7
|
@@ -35,6 +35,10 @@ export function providerWrapperInstallPaths(home) {
|
|
|
35
35
|
}
|
|
36
36
|
return paths;
|
|
37
37
|
}
|
|
38
|
+
/** Env var the installed wrapper sets when it hands a run to another wrapper script. */
|
|
39
|
+
export function providerWrapperGuardVar(provider) {
|
|
40
|
+
return `HQ_ANYWHERE_${provider.toUpperCase()}_WRAPPER_ACTIVE`;
|
|
41
|
+
}
|
|
38
42
|
function wrapperSource(provider) {
|
|
39
43
|
const pretty = provider === 'claude' ? 'Claude Code' : 'Codex';
|
|
40
44
|
const login = provider === 'claude' ? 'claude /login' : 'codex login';
|
|
@@ -45,6 +49,12 @@ function wrapperSource(provider) {
|
|
|
45
49
|
const runAuthFailure = provider === 'codex'
|
|
46
50
|
? 'HTTP error: *401|status 401|401 Unauthorized|websocket.*auth|not logged in|signed out|not authenticated|authentication required|unauthenticated'
|
|
47
51
|
: 'HTTP error: *401|status 401|401 Unauthorized|not logged in|signed out|not authenticated|authentication required|unauthenticated';
|
|
52
|
+
// Install locations of the real provider executable, checked when PATH holds no
|
|
53
|
+
// executable that is not a shell script.
|
|
54
|
+
const knownInstalls = provider === 'claude'
|
|
55
|
+
? ['"${HOME:-}/.local/bin/claude"', '"${HOME:-}/.claude/local/node_modules/.bin/claude"']
|
|
56
|
+
: [];
|
|
57
|
+
const guard = providerWrapperGuardVar(provider);
|
|
48
58
|
return [
|
|
49
59
|
'#!/bin/sh',
|
|
50
60
|
`${marker}: ${provider}`,
|
|
@@ -55,18 +65,73 @@ function wrapperSource(provider) {
|
|
|
55
65
|
`login='${login}'`,
|
|
56
66
|
`provider='${provider}'`,
|
|
57
67
|
'',
|
|
58
|
-
'#
|
|
68
|
+
'# Locate the provider. Other tools (cmux, for example) put their own provider',
|
|
69
|
+
'# wrapper on PATH, and that wrapper runs the next provider it finds on PATH. To',
|
|
70
|
+
'# keep those wrappers working without starting each other forever:',
|
|
71
|
+
'# - Without the guard, run the next provider on PATH after this wrapper (any',
|
|
72
|
+
`# kind except another HQ wrapper). When that is a shell script, set ${guard}`,
|
|
73
|
+
'# so a script that runs this wrapper again lands in the branch below.',
|
|
74
|
+
'# - With the guard set, never run another wrapper: run the real executable (the',
|
|
75
|
+
'# first provider on PATH that is not a shell script, then the known install',
|
|
76
|
+
'# locations) directly, or stop.',
|
|
77
|
+
'hq_shell_script() {',
|
|
78
|
+
" hq_first=$(LC_ALL=C head -c 256 \"$1\" 2>/dev/null | LC_ALL=C tr -d '\\000' | LC_ALL=C head -n 1)",
|
|
79
|
+
' case "$hq_first" in',
|
|
80
|
+
" '#!'*/sh|'#!'*/sh\\ *|'#!'*' sh'|'#!'*' sh '*|'#!'*bash*|'#!'*zsh*|'#!'*dash*|'#!'*ksh*) return 0 ;;",
|
|
81
|
+
' esac',
|
|
82
|
+
' return 1',
|
|
83
|
+
'}',
|
|
84
|
+
'hq_managed_wrapper() {',
|
|
85
|
+
` LC_ALL=C head -c 256 "$1" 2>/dev/null | LC_ALL=C tr -d '\\000' | grep -q '^${marker}'`,
|
|
86
|
+
'}',
|
|
87
|
+
'hq_known_install() {',
|
|
88
|
+
' known=',
|
|
89
|
+
...(knownInstalls.length > 0
|
|
90
|
+
? [
|
|
91
|
+
` for candidate in ${knownInstalls.join(' ')}; do`,
|
|
92
|
+
' if [ -f "$candidate" ] && [ -x "$candidate" ] && [ "$candidate" != "$self" ] && ! hq_shell_script "$candidate"; then known=$candidate; return 0; fi',
|
|
93
|
+
' done',
|
|
94
|
+
]
|
|
95
|
+
: []),
|
|
96
|
+
' return 1',
|
|
97
|
+
'}',
|
|
59
98
|
'self=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)/$(basename -- "$0")',
|
|
60
|
-
'
|
|
99
|
+
'next=',
|
|
100
|
+
'first=',
|
|
101
|
+
'binary=',
|
|
102
|
+
'seen_self=0',
|
|
61
103
|
'old_ifs=$IFS',
|
|
62
104
|
'IFS=:',
|
|
63
105
|
'for dir in $PATH; do',
|
|
64
106
|
' [ -n "$dir" ] || dir=.',
|
|
65
107
|
' candidate=$(CDPATH= cd -- "$dir" 2>/dev/null && pwd -P)/$name',
|
|
66
|
-
' if [
|
|
108
|
+
' if [ "$candidate" = "$self" ]; then seen_self=1; continue; fi',
|
|
109
|
+
' if [ ! -f "$candidate" ] || [ ! -x "$candidate" ] || hq_managed_wrapper "$candidate"; then continue; fi',
|
|
110
|
+
' if [ -z "$binary" ] && ! hq_shell_script "$candidate"; then binary=$candidate; fi',
|
|
111
|
+
' if [ "$seen_self" = 1 ]; then',
|
|
112
|
+
' [ -n "$next" ] || next=$candidate',
|
|
113
|
+
' if [ -n "$binary" ]; then break; fi',
|
|
114
|
+
' elif [ -z "$first" ]; then',
|
|
115
|
+
' first=$candidate',
|
|
116
|
+
' fi',
|
|
67
117
|
'done',
|
|
68
118
|
'IFS=$old_ifs',
|
|
119
|
+
'',
|
|
120
|
+
`if [ -n "\${${guard}:-}" ]; then`,
|
|
121
|
+
' # Another wrapper ran this one again. The real executable does not get the guard,',
|
|
122
|
+
' # so a session it starts treats its own nested provider calls as new runs.',
|
|
123
|
+
' if [ -z "$binary" ] && hq_known_install; then binary=$known; fi',
|
|
124
|
+
` if [ -n "$binary" ]; then unset ${guard}; exec "$binary" "$@"; fi`,
|
|
125
|
+
` printf '%s CLI was not found: every ${provider} on PATH is a wrapper script that runs this HQ wrapper (%s) again.\\nInstall %s, or put the directory that holds the real ${provider} executable on PATH.\\n' "$pretty" "$self" "$pretty" >&2`,
|
|
126
|
+
' exit 127',
|
|
127
|
+
'fi',
|
|
128
|
+
'# Invoked by a path that is not on PATH: the first provider on PATH is the next one.',
|
|
129
|
+
'if [ "$seen_self" = 0 ]; then next=$first; first=; fi',
|
|
130
|
+
'real=$next',
|
|
131
|
+
'if [ -z "$real" ] && hq_known_install; then real=$known; fi',
|
|
132
|
+
'[ -n "$real" ] || real=$first',
|
|
69
133
|
'if [ -z "$real" ]; then printf \'%s CLI was not found on PATH.\\n\' "$pretty" >&2; exit 127; fi',
|
|
134
|
+
`if hq_shell_script "$real"; then ${guard}=1; export ${guard}; fi`,
|
|
70
135
|
'',
|
|
71
136
|
'# The flag override is part of the existing hq-anywhere-runtime flag contract.',
|
|
72
137
|
'case "${HQ_FLAG_HQ_ANYWHERE_RUNTIME:-}" in false|0) exec "$real" "$@" ;; esac',
|
|
@@ -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;
|