@indigoai-us/hq-cli 5.345.210 → 5.345.212-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.
Files changed (44) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/assets/scaffold/core/scripts/lib/trigger-fact-text.awk +152 -41
  3. package/dist/command-catalog.generated.d.ts +28 -0
  4. package/dist/command-catalog.generated.js +34 -0
  5. package/dist/commands/bot-runtime.d.ts +21 -2
  6. package/dist/commands/bot-runtime.js +54 -9
  7. package/dist/commands/bot.d.ts +13 -0
  8. package/dist/commands/bot.js +142 -12
  9. package/dist/commands/core-derive-trigger-facts-native.d.ts +1 -0
  10. package/dist/commands/core-derive-trigger-facts-native.js +61 -11
  11. package/dist/commands/core-work-mesh-bind-trusted-native.d.ts +14 -2
  12. package/dist/commands/core-work-mesh-bind-trusted-native.js +62 -8
  13. package/dist/commands/daemon.js +3 -0
  14. package/dist/commands/integrations-connect.d.ts +16 -0
  15. package/dist/commands/integrations-connect.js +23 -4
  16. package/dist/commands/whoami.js +7 -6
  17. package/dist/lib/bot/api.d.ts +1 -1
  18. package/dist/lib/bot/config.js +2 -1
  19. package/dist/lib/bot/fleet-daemon.d.ts +4 -0
  20. package/dist/lib/bot/fleet-daemon.js +12 -1
  21. package/dist/lib/bot/fleet-download.d.ts +6 -0
  22. package/dist/lib/bot/fleet-download.js +128 -3
  23. package/dist/lib/bot/fleet-local.d.ts +38 -1
  24. package/dist/lib/bot/fleet-local.js +239 -26
  25. package/dist/lib/bot/install-progress.d.ts +28 -0
  26. package/dist/lib/bot/install-progress.js +185 -0
  27. package/dist/lib/bot/legacy-provider-login.d.ts +22 -1
  28. package/dist/lib/bot/legacy-provider-login.js +67 -9
  29. package/dist/lib/bot/prompt.d.ts +1 -0
  30. package/dist/lib/bot/prompt.js +3 -2
  31. package/dist/lib/bot/readiness.d.ts +68 -0
  32. package/dist/lib/bot/readiness.js +145 -0
  33. package/dist/lib/bot/run.d.ts +2 -0
  34. package/dist/lib/bot/run.js +6 -3
  35. package/dist/lib/bot/scaffold.d.ts +6 -3
  36. package/dist/lib/bot/scaffold.js +18 -12
  37. package/dist/lib/daemon/catalog.d.ts +9 -0
  38. package/dist/lib/daemon/catalog.js +13 -1
  39. package/dist/lib/daemon/run.d.ts +6 -3
  40. package/dist/lib/daemon/run.js +43 -6
  41. package/dist/lib/daemon/supervisor.d.ts +3 -0
  42. package/dist/lib/daemon/supervisor.js +64 -3
  43. package/dist/lib/sync-core/reconcile.js +15 -11
  44. package/package.json +7 -7
@@ -194,6 +194,9 @@ function hostFor(d, paths, pathEnv) {
194
194
  env.PATH = d.env.PATH;
195
195
  if (d.env.HQ_DAEMON_DIR)
196
196
  env.HQ_DAEMON_DIR = d.env.HQ_DAEMON_DIR;
197
+ const pointerFile = d.env.HQ_FLEET_RELEASE_POINTER_FILE?.trim();
198
+ if (pointerFile)
199
+ env.HQ_FLEET_RELEASE_POINTER_FILE = path.resolve(pointerFile);
197
200
  return {
198
201
  platform: d.platform,
199
202
  home: d.home,
@@ -69,6 +69,22 @@ export declare function assertAuthMode(value: string | undefined): void;
69
69
  export declare function assertAuthHeader(value: string | undefined): void;
70
70
  /** Single-quote a value for a copy-pasteable shell command. */
71
71
  export declare function shellQuote(value: string): string;
72
+ /**
73
+ * Resolve the API key for a key-authenticated app, in descending order of how
74
+ * safe the source is: piped stdin, a hidden prompt, then the explicit
75
+ * `--token` flag. Refuses rather than connecting credential-less when there is
76
+ * nobody to ask.
77
+ */
78
+ /**
79
+ * HQ-PRO-5QF: a key pasted from a doc or chat often arrives wrapped across
80
+ * lines or with a tab, and sometimes with smart quotes. hq-pro sends the key
81
+ * in an HTTP header, which can't carry those characters. Trim the ends, drop
82
+ * inner line breaks and tabs, and refuse anything else outside visible ASCII
83
+ * (an inner space is left for hq-pro to judge, since HTTP Basic allows it).
84
+ * The message never echoes the key.
85
+ */
86
+ export declare const API_KEY_UNSENDABLE_MESSAGE = "The key contains a character that can't be sent. Copy it again and paste only the key.";
87
+ export declare function normalizePastedApiKey(raw: string): string;
72
88
  /** Everything the connect verbs need to name one app to hq-pro. */
73
89
  interface ConnectTarget {
74
90
  /** Install/OAuth identity fields, exactly as hq-pro expects them. */
@@ -308,9 +308,25 @@ function promptForKey(label) {
308
308
  * `--token` flag. Refuses rather than connecting credential-less when there is
309
309
  * nobody to ask.
310
310
  */
311
+ /**
312
+ * HQ-PRO-5QF: a key pasted from a doc or chat often arrives wrapped across
313
+ * lines or with a tab, and sometimes with smart quotes. hq-pro sends the key
314
+ * in an HTTP header, which can't carry those characters. Trim the ends, drop
315
+ * inner line breaks and tabs, and refuse anything else outside visible ASCII
316
+ * (an inner space is left for hq-pro to judge, since HTTP Basic allows it).
317
+ * The message never echoes the key.
318
+ */
319
+ export const API_KEY_UNSENDABLE_MESSAGE = "The key contains a character that can't be sent. Copy it again and paste only the key.";
320
+ export function normalizePastedApiKey(raw) {
321
+ const cleaned = raw.trim().replace(/[\r\n\t]+/g, "");
322
+ if (!/^[\x20-\x7e]*$/.test(cleaned)) {
323
+ throw new IntegrationsCliError(API_KEY_UNSENDABLE_MESSAGE, { expected: true });
324
+ }
325
+ return cleaned;
326
+ }
311
327
  async function resolveKey(opts, appLabel) {
312
328
  if (opts.tokenStdin) {
313
- const piped = (await readStdin()).trim();
329
+ const piped = normalizePastedApiKey(await readStdin());
314
330
  if (!piped) {
315
331
  throw new IntegrationsCliError("--token-stdin was set but stdin was empty.", {
316
332
  expected: true,
@@ -318,10 +334,13 @@ async function resolveKey(opts, appLabel) {
318
334
  }
319
335
  return piped;
320
336
  }
321
- if (opts.token)
322
- return opts.token;
337
+ if (opts.token) {
338
+ const flagged = normalizePastedApiKey(opts.token);
339
+ if (flagged)
340
+ return flagged;
341
+ }
323
342
  if (process.stdin.isTTY) {
324
- const value = (await promptForKey(`API key for ${appLabel}`)).trim();
343
+ const value = normalizePastedApiKey(await promptForKey(`API key for ${appLabel}`));
325
344
  if (!value) {
326
345
  throw new IntegrationsCliError("No API key entered — nothing was connected.", {
327
346
  expected: true,
@@ -99,10 +99,9 @@ async function readPlanLimits(company) {
99
99
  const status = await fetchPlanLimitStatus(token, slug);
100
100
  if (!status)
101
101
  return null;
102
- return {
103
- status,
104
- idToken: loadCachedTokens()?.idToken,
105
- };
102
+ // The result is printed verbatim by `--json`. It must never carry a
103
+ // token: hooks and agents capture that stdout into transcripts and logs.
104
+ return { status };
106
105
  }
107
106
  catch {
108
107
  return null;
@@ -139,8 +138,10 @@ async function printPlanBlock(company) {
139
138
  const planLimits = await readPlanLimits(company);
140
139
  if (!planLimits)
141
140
  return;
142
- const { status, idToken } = planLimits;
143
- const inviteTeammateEnabled = await inviteTeammateSuggestionEnabled(status, idToken);
141
+ const { status } = planLimits;
142
+ // The flag gate needs a bearer; read it here so it never travels in the
143
+ // plan-limit result that `--json` prints.
144
+ const inviteTeammateEnabled = await inviteTeammateSuggestionEnabled(status, loadCachedTokens()?.idToken);
144
145
  const block = renderWhoamiPlanBlock(status, { inviteTeammateEnabled });
145
146
  if (!block)
146
147
  return;
@@ -199,7 +199,7 @@ export declare class BotApi {
199
199
  /** GET /v1/agents/{uid} — owner-only local bot record (403/404 for others). */
200
200
  getAgent(agentUid: string): Promise<AgentRecord>;
201
201
  /** POST /v1/agents/{uid}/heartbeat — agent-JWT only. */
202
- heartbeat(agentUid: string, components: Record<string, "ok" | "degraded" | "failed" | "unknown">): Promise<{
202
+ heartbeat(agentUid: string, components: Record<string, "ok" | "degraded" | "failed" | "unknown" | boolean | string | null>): Promise<{
203
203
  ok: boolean;
204
204
  at?: string;
205
205
  local?: boolean;
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as fs from "node:fs";
5
5
  import * as path from "node:path";
6
+ import semver from "semver";
6
7
  import { botConfigPath } from "./paths.js";
7
8
  export const BOT_RUNTIMES = ["claude", "codex", "grok"];
8
9
  export const HQ_FLEET_RUNTIME_ENGINE_ID = "hq-fleet-runtime";
@@ -13,7 +14,7 @@ export function isBotEngineMetadata(value) {
13
14
  return (engine.id === HQ_FLEET_RUNTIME_ENGINE_ID &&
14
15
  engine.distribution === "hq-fleet-local" &&
15
16
  typeof engine.version === "string" &&
16
- /^\d+\.\d+\.\d+$/.test(engine.version) &&
17
+ semver.valid(engine.version) === engine.version &&
17
18
  typeof engine.artifactSha256 === "string" &&
18
19
  /^[a-f0-9]{64}$/.test(engine.artifactSha256) &&
19
20
  typeof engine.runtimeCommit === "string" &&
@@ -85,6 +85,10 @@ export declare function gatewayOutsideDaemon(agentUid: string, deps: {
85
85
  * unit waiting.
86
86
  */
87
87
  export declare function planFleetBots(deps?: PlanFleetBotsDeps): FleetBotPlan[];
88
+ export declare function clearStaleReadyBeforeGatewayStart(unit: {
89
+ id: string;
90
+ env: Record<string, string>;
91
+ }, alive?: (pid: number) => boolean): boolean;
88
92
  export interface ControlFleetBotDeps extends FleetLocalControlDeps, FleetDaemonHost {
89
93
  root?: string;
90
94
  uid?: number;
@@ -17,7 +17,7 @@ import * as os from "node:os";
17
17
  import * as path from "node:path";
18
18
  import { HQ_FLEET_RUNTIME_ENGINE_ID, patchBotConfig, readBotConfig } from "./config.js";
19
19
  import { defaultPathEntries } from "./daemon.js";
20
- import { controlFleetLocalBot, fleetLocalGatewayPid, fleetLocalGatewayProcess, fleetLocalLaunchAgentLabel, fleetLocalLaunchAgentPlist, removeFleetLocalEmbeddedRuntime, } from "./fleet-local.js";
20
+ import { clearStaleFleetGatewayReady, controlFleetLocalBot, fleetLocalGatewayPid, fleetLocalGatewayProcess, fleetLocalLaunchAgentLabel, fleetLocalLaunchAgentPlist, removeFleetLocalEmbeddedRuntime, } from "./fleet-local.js";
21
21
  import { botsRoot } from "./paths.js";
22
22
  import { isPidAlive } from "./status.js";
23
23
  import { askDaemonToStart, askDaemonToStop, daemonUnitInstalled, hostedDaemonRunning } from "../daemon/handoff.js";
@@ -158,6 +158,17 @@ export function planFleetBots(deps = {}) {
158
158
  };
159
159
  });
160
160
  }
161
+ export function clearStaleReadyBeforeGatewayStart(unit, alive) {
162
+ const profileDir = unit.env.HQ_FLEET_HOME;
163
+ if (!unit.id.startsWith(FLEET_BOT_UNIT_PREFIX) || !profileDir)
164
+ return false;
165
+ try {
166
+ return clearStaleFleetGatewayReady(profileDir, alive);
167
+ }
168
+ catch {
169
+ return false;
170
+ }
171
+ }
161
172
  function unitState(paths, unitId, alive) {
162
173
  try {
163
174
  const state = JSON.parse(fs.readFileSync(paths.statePath, "utf8"));
@@ -2,6 +2,10 @@
2
2
  export declare const FLEET_DOWNLOAD_STALL_MS = 90000;
3
3
  /** How many times a stalled or broken download is resumed before giving up. */
4
4
  export declare const FLEET_DOWNLOAD_MAX_RESUMES = 5;
5
+ /** A file at least this large is fetched as parallel byte ranges when the server accepts them. */
6
+ export declare const FLEET_DOWNLOAD_SEGMENT_MIN_BYTES: number;
7
+ /** How many byte ranges a large file is fetched in at the same time. */
8
+ export declare const FLEET_DOWNLOAD_SEGMENTS = 8;
5
9
  export interface FleetDownloadProgress {
6
10
  name: string;
7
11
  received: number;
@@ -12,6 +16,8 @@ export interface FleetDownloadOptions {
12
16
  headers?: Record<string, string>;
13
17
  stallMs?: number;
14
18
  maxResumes?: number;
19
+ segments?: number;
20
+ segmentMinBytes?: number;
15
21
  onProgress?: (progress: FleetDownloadProgress) => void;
16
22
  }
17
23
  /**
@@ -5,6 +5,10 @@ import * as path from "node:path";
5
5
  export const FLEET_DOWNLOAD_STALL_MS = 90_000;
6
6
  /** How many times a stalled or broken download is resumed before giving up. */
7
7
  export const FLEET_DOWNLOAD_MAX_RESUMES = 5;
8
+ /** A file at least this large is fetched as parallel byte ranges when the server accepts them. */
9
+ export const FLEET_DOWNLOAD_SEGMENT_MIN_BYTES = 8 * 1_048_576;
10
+ /** How many byte ranges a large file is fetched in at the same time. */
11
+ export const FLEET_DOWNLOAD_SEGMENTS = 8;
8
12
  function expectedError(message) {
9
13
  return Object.assign(new Error(message), { expected: true });
10
14
  }
@@ -31,7 +35,7 @@ function contentRangeTotal(response) {
31
35
  const value = Number.parseInt(match[1], 10);
32
36
  return Number.isFinite(value) ? value : null;
33
37
  }
34
- async function pumpBody(response, fd, offset, name, total, stallMs, onProgress) {
38
+ async function pumpBody(response, fd, offset, name, total, stallMs, onProgress, until = null) {
35
39
  if (!response.body) {
36
40
  const bytes = Buffer.from(await response.arrayBuffer());
37
41
  fs.writeSync(fd, bytes, 0, bytes.length, offset);
@@ -61,8 +65,13 @@ async function pumpBody(response, fd, offset, name, total, stallMs, onProgress)
61
65
  }
62
66
  if (chunk.done)
63
67
  break;
64
- fs.writeSync(fd, chunk.value, 0, chunk.value.length, received);
65
- received += chunk.value.length;
68
+ const length = until === null ? chunk.value.length : Math.min(chunk.value.length, until - received);
69
+ fs.writeSync(fd, chunk.value, 0, length, received);
70
+ received += length;
71
+ if (until !== null && received >= until) {
72
+ void reader.cancel().catch(() => undefined);
73
+ break;
74
+ }
66
75
  const now = Date.now();
67
76
  if (now - lastReport >= 250 || (total !== null && received >= total)) {
68
77
  lastReport = now;
@@ -72,6 +81,108 @@ async function pumpBody(response, fd, offset, name, total, stallMs, onProgress)
72
81
  onProgress?.({ name, received, total });
73
82
  return received;
74
83
  }
84
+ function segmentBounds(total, count) {
85
+ const size = Math.ceil(total / count);
86
+ const bounds = [];
87
+ for (let start = 0; start < total; start += size)
88
+ bounds.push([start, Math.min(total, start + size)]);
89
+ return bounds;
90
+ }
91
+ function readSegmentState(file, segmentFile) {
92
+ try {
93
+ const state = JSON.parse(fs.readFileSync(file, "utf8"));
94
+ if (typeof state.total !== "number" || !Array.isArray(state.done) || !state.done.every((n) => typeof n === "number" && n >= 0))
95
+ return null;
96
+ if (partFileSize(segmentFile) !== state.total)
97
+ return null;
98
+ return { total: state.total, done: state.done };
99
+ }
100
+ catch {
101
+ return null;
102
+ }
103
+ }
104
+ async function downloadSegments(url, destination, state, first, fetcher, options, stallMs, maxResumes) {
105
+ const name = path.basename(destination);
106
+ const segmentFile = `${destination}.seg`;
107
+ const stateFile = `${segmentFile}.json`;
108
+ const bounds = segmentBounds(state.total, state.done.length);
109
+ let lastSaved = 0;
110
+ const save = (force = false) => {
111
+ const now = Date.now();
112
+ if (!force && now - lastSaved < 1_000)
113
+ return;
114
+ lastSaved = now;
115
+ fs.writeFileSync(stateFile, JSON.stringify(state), { mode: 0o600 });
116
+ };
117
+ let lastReport = 0;
118
+ const report = () => {
119
+ const received = state.done.reduce((sum, n) => sum + n, 0);
120
+ const now = Date.now();
121
+ if (now - lastReport >= 250 || received >= state.total) {
122
+ lastReport = now;
123
+ options.onProgress?.({ name, received, total: state.total });
124
+ }
125
+ save();
126
+ };
127
+ save(true);
128
+ const fd = fs.openSync(segmentFile, "r+");
129
+ try {
130
+ const results = await Promise.allSettled(bounds.map(async ([start, end], index) => {
131
+ let response = index === 0 ? first : null;
132
+ let failure = null;
133
+ for (let attempt = 0; attempt <= maxResumes; attempt += 1) {
134
+ const from = start + state.done[index];
135
+ if (from >= end)
136
+ return;
137
+ if (!response || attempt > 0) {
138
+ try {
139
+ response = await fetcher(url, { headers: { ...options.headers, Range: `bytes=${from}-${end - 1}` } });
140
+ }
141
+ catch (error) {
142
+ failure = error;
143
+ response = null;
144
+ continue;
145
+ }
146
+ if (response.status !== 206) {
147
+ void response.body?.cancel().catch(() => undefined);
148
+ throw expectedError(`Could not download ${name}: HQ storage returned HTTP ${response.status} for part of the file.`);
149
+ }
150
+ }
151
+ try {
152
+ await pumpBody(response, fd, from, name, state.total, stallMs, (progress) => {
153
+ state.done[index] = progress.received - start;
154
+ report();
155
+ }, end);
156
+ }
157
+ catch (error) {
158
+ failure = error;
159
+ continue;
160
+ }
161
+ finally {
162
+ response = null;
163
+ }
164
+ if (start + state.done[index] >= end)
165
+ return;
166
+ failure = expectedError(`ended early at ${start + state.done[index]} of ${end} bytes`);
167
+ }
168
+ throw failure;
169
+ }));
170
+ const failed = results.find((result) => result.status === "rejected");
171
+ if (failed)
172
+ throw failed.reason;
173
+ }
174
+ catch (error) {
175
+ save(true);
176
+ const cause = error instanceof Error ? error.message : String(error);
177
+ throw expectedError(`Could not download ${name} after ${maxResumes + 1} attempts (${cause}). Check your internet connection and retry; the download continues where it stopped.`);
178
+ }
179
+ finally {
180
+ fs.closeSync(fd);
181
+ }
182
+ fs.renameSync(segmentFile, destination);
183
+ fs.rmSync(stateFile, { force: true });
184
+ return destination;
185
+ }
75
186
  /**
76
187
  * Download `url` into `destination`, writing through `<destination>.part` and
77
188
  * resuming from the bytes already there. Every attempt that receives nothing
@@ -85,7 +196,13 @@ export async function downloadFleetFile(url, destination, options = {}) {
85
196
  const maxResumes = options.maxResumes ?? FLEET_DOWNLOAD_MAX_RESUMES;
86
197
  const name = path.basename(destination);
87
198
  const part = `${destination}.part`;
199
+ const segments = Math.max(1, options.segments ?? FLEET_DOWNLOAD_SEGMENTS);
200
+ const segmentMinBytes = options.segmentMinBytes ?? FLEET_DOWNLOAD_SEGMENT_MIN_BYTES;
201
+ const segmentFile = `${destination}.seg`;
88
202
  fs.mkdirSync(path.dirname(destination), { recursive: true, mode: 0o700 });
203
+ const resumable = readSegmentState(`${segmentFile}.json`, segmentFile);
204
+ if (resumable)
205
+ return downloadSegments(url, destination, resumable, null, fetcher, options, stallMs, maxResumes);
89
206
  let lastFailure = null;
90
207
  for (let attempt = 0; attempt <= maxResumes; attempt += 1) {
91
208
  const have = partFileSize(part);
@@ -113,6 +230,14 @@ export async function downloadFleetFile(url, destination, options = {}) {
113
230
  else if (response.ok) {
114
231
  offset = 0;
115
232
  total = contentLength(response);
233
+ const ranges = (response.headers.get("accept-ranges") ?? "").toLowerCase().includes("bytes");
234
+ if (response.status === 200 && segments > 1 && ranges && total !== null && total >= segmentMinBytes) {
235
+ const created = fs.openSync(segmentFile, "w", 0o600);
236
+ fs.ftruncateSync(created, total);
237
+ fs.closeSync(created);
238
+ fs.rmSync(part, { force: true });
239
+ return downloadSegments(url, destination, { total, done: new Array(segments).fill(0) }, response, fetcher, options, stallMs, maxResumes);
240
+ }
116
241
  }
117
242
  else {
118
243
  void response.body?.cancel().catch(() => undefined);
@@ -68,6 +68,7 @@ export interface FleetLocalInstallDeps {
68
68
  onProgress?: FleetInstallProgressListener;
69
69
  /** How long a download may go without bytes before it is resumed (tests). */
70
70
  downloadStallMs?: number;
71
+ allowFileLinks?: boolean;
71
72
  }
72
73
  export interface FleetLocalProfileInput {
73
74
  agentUid: string;
@@ -161,6 +162,7 @@ export interface FleetLocalControlDeps {
161
162
  }
162
163
  export interface FleetLocalAuthInput {
163
164
  installService?: boolean;
165
+ onAuthEvent?: (event: Record<string, unknown>) => void;
164
166
  agentUid: string;
165
167
  provider: string;
166
168
  model?: string;
@@ -229,13 +231,18 @@ export interface FleetLocalReleasePointer {
229
231
  minimumHqCli: string | null;
230
232
  links: Map<string, string> | null;
231
233
  linksExpireAt: number | null;
234
+ localFile?: string;
232
235
  }
233
236
  export interface FleetLocalTargetRelease {
234
237
  release: FleetLocalReleasePin;
235
238
  source: "pointer" | "compiled";
236
239
  links: Map<string, string> | null;
237
240
  linksExpireAt: number | null;
241
+ localFile?: string;
238
242
  }
243
+ export declare const FLEET_RELEASE_POINTER_FILE_ENV = "HQ_FLEET_RELEASE_POINTER_FILE";
244
+ export declare function fleetReleasePointerFileOverride(env?: NodeJS.ProcessEnv): string | null;
245
+ export declare function readLocalFleetReleasePointer(file: string, now?: number): FleetLocalReleasePointer;
239
246
  export declare function parseFleetLocalReleasePin(value: unknown): FleetLocalReleasePin | null;
240
247
  export declare function parseFleetLocalReleasePointer(body: unknown, now?: number): FleetLocalReleasePointer | null;
241
248
  export declare function chooseFleetLocalTargetRelease(pointer: FleetLocalReleasePointer | null, compiled?: FleetLocalReleasePin, cliVersion?: string): FleetLocalTargetRelease;
@@ -249,11 +256,16 @@ interface FleetLocalPointerDeps {
249
256
  fleetHome?: string;
250
257
  now?: () => number;
251
258
  fetchPointer?: () => Promise<FleetLocalReleasePointer | null>;
259
+ env?: NodeJS.ProcessEnv;
252
260
  }
253
261
  export declare function resolveFleetLocalTargetRelease(deps?: FleetLocalPointerDeps & {
254
262
  compiled?: FleetLocalReleasePin;
255
263
  cliVersion?: string;
256
264
  }): Promise<FleetLocalTargetRelease>;
265
+ export declare function cachedFleetLocalTargetRelease(deps?: FleetLocalPointerDeps & {
266
+ compiled?: FleetLocalReleasePin;
267
+ cliVersion?: string;
268
+ }): FleetLocalTargetRelease;
257
269
  export declare function resolveFleetLocalPointerTarget(deps?: FleetLocalPointerDeps & {
258
270
  cliVersion?: string;
259
271
  }): Promise<FleetLocalTargetRelease | null>;
@@ -263,6 +275,9 @@ export declare function installTargetFleetLocalDistribution(deps?: Omit<FleetLoc
263
275
  }): Promise<FleetLocalInstallation>;
264
276
  /** What an install is doing right now, for a progress bar or a log line. */
265
277
  export type FleetInstallProgress = {
278
+ phase: "download-start";
279
+ files: number;
280
+ } | {
266
281
  phase: "download";
267
282
  file: string;
268
283
  received: number;
@@ -335,7 +350,22 @@ export declare function controlFleetLocalBot(agentUid: string, action: FleetLoca
335
350
  export declare function exportFleetLocalMachineCredential(agentUid: string, deps?: FleetLocalControlDeps): BotMachineCreds;
336
351
  export declare function fleetLocalPromotionRuntime(agentUid: string, deps?: FleetLocalControlDeps): LocalBotPromotionRuntime;
337
352
  export declare function removeFleetLocalBot(agentUid: string, deps?: FleetLocalControlDeps): FleetLocalRemovalResult;
338
- export declare function authenticateFleetLocalBot(input: FleetLocalAuthInput, deps?: FleetLocalControlDeps): FleetLocalAuthResult;
353
+ export type FleetLocalStartControl = (agentUid: string, action: "install" | "restart") => {
354
+ ok?: unknown;
355
+ };
356
+ export type FleetAuthSpawn = (executable: string, args: string[], onStderrLine: (line: string) => void) => Promise<{
357
+ code: number | null;
358
+ stdout: string;
359
+ }>;
360
+ export declare const spawnFleetAuth: FleetAuthSpawn;
361
+ export declare const FLEET_GROK_CLI_IMPORT_MIN_VERSION = "0.4.31-local.13";
362
+ export declare function fleetReleaseImportsGrokCli(version: string | null | undefined): boolean;
363
+ export declare function fleetLocalProfileEngineVersion(agentUid: string, deps?: Pick<FleetLocalControlDeps, "fleetHome">): string | null;
364
+ export declare function authenticateFleetLocalBot(input: FleetLocalAuthInput, deps?: FleetLocalControlDeps & {
365
+ control?: FleetLocalStartControl;
366
+ spawnAuth?: FleetAuthSpawn;
367
+ writeStderr?: (text: string) => void;
368
+ }): Promise<FleetLocalAuthResult>;
339
369
  export declare function writeFleetLocalProfile(input: FleetLocalProfileInput, deps?: FleetLocalProfileDeps): string;
340
370
  /** The runtime's inbox plugin sends the intro and runs the kickoff once, then stamps this file. */
341
371
  export declare function writeFleetLocalFirstStart(profileDir: string, firstStart: {
@@ -361,7 +391,14 @@ export interface FleetLocalGatewayState {
361
391
  gatewayState: string | null;
362
392
  activeAgents: number;
363
393
  platforms: Record<string, string>;
394
+ ready: boolean;
395
+ readyAt: string | null;
364
396
  }
397
+ export declare function parseGatewayReady(value: unknown): {
398
+ ready: boolean;
399
+ readyAt: string | null;
400
+ };
401
+ export declare function clearStaleFleetGatewayReady(profileDir: string, alive?: (pid: number) => boolean): boolean;
365
402
  export declare function readFleetLocalGatewayState(agentUid: string, deps?: Pick<FleetLocalControlDeps, "fleetHome">): FleetLocalGatewayState | null;
366
403
  export declare function fleetLocalChannels(state: FleetLocalGatewayState | null, gatewayAlive: boolean): {
367
404
  slack: string;