@indigoai-us/hq-cli 5.345.233 → 5.345.235
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 +67 -0
- package/dist/command-catalog.generated.d.ts +240 -7
- package/dist/command-catalog.generated.js +296 -7
- package/dist/command-registration-plan.d.ts +24 -0
- package/dist/command-registration-plan.js +4 -0
- package/dist/commands/bot-companies.d.ts +4 -1
- package/dist/commands/bot-companies.js +5 -1
- package/dist/commands/bot.d.ts +10 -0
- package/dist/commands/bot.js +165 -36
- package/dist/commands/capacity.js +1 -1
- package/dist/commands/core-handoff.js +2 -2
- package/dist/commands/core-ontology-native.js +5 -4
- package/dist/commands/core-pipeline-workflow-runner-native.js +4 -9
- package/dist/commands/deploy-app-db.d.ts +3 -0
- package/dist/commands/deploy-app-db.js +79 -0
- package/dist/commands/deploy-app-upload.d.ts +3 -0
- package/dist/commands/deploy-app-upload.js +120 -0
- package/dist/commands/deploy-comments.js +46 -1
- package/dist/commands/deploy-mutations.js +71 -5
- package/dist/commands/deploy-ssr.d.ts +3 -0
- package/dist/commands/deploy-ssr.js +74 -0
- package/dist/commands/dm.d.ts +7 -1
- package/dist/commands/dm.js +39 -9
- package/dist/commands/doctor.d.ts +1 -0
- package/dist/commands/doctor.js +26 -10
- package/dist/commands/fingerprint.js +4 -9
- package/dist/commands/install-global.js +10 -0
- package/dist/commands/lanes-accounts.js +5 -5
- package/dist/commands/lanes-hold.js +1 -1
- package/dist/commands/lanes-message.js +3 -3
- package/dist/commands/lanes-move.js +1 -1
- package/dist/commands/lanes-resume.js +6 -6
- package/dist/commands/lanes-watch.js +2 -2
- package/dist/commands/lanes.js +21 -21
- package/dist/commands/work-env.d.ts +90 -0
- package/dist/commands/work-env.js +304 -0
- package/dist/lazy-commands.js +2 -10
- package/dist/lib/bot/api.d.ts +27 -0
- package/dist/lib/bot/api.js +28 -2
- package/dist/lib/bot/cloud-create.d.ts +46 -0
- package/dist/lib/bot/cloud-create.js +128 -0
- package/dist/lib/bot/fleet-daemon.js +4 -1
- package/dist/lib/bot/fleet-local.d.ts +7 -0
- package/dist/lib/bot/fleet-local.js +39 -3
- package/dist/lib/bot/fleet-owner-companies.js +2 -2
- package/dist/lib/bot/promote.d.ts +81 -2
- package/dist/lib/bot/promote.js +425 -51
- package/dist/lib/bot/promotion-hold.d.ts +9 -0
- package/dist/lib/bot/promotion-hold.js +29 -0
- package/dist/lib/bot/promotion-receipt.d.ts +10 -0
- package/dist/lib/bot/promotion-receipt.js +41 -1
- package/dist/lib/bot/promotion-upload.d.ts +6 -1
- package/dist/lib/bot/promotion-upload.js +3 -1
- package/dist/lib/bot/readiness.d.ts +9 -0
- package/dist/lib/bot/readiness.js +16 -0
- package/dist/lib/capacity/route.js +4 -4
- package/dist/lib/capacity/sign-in.js +1 -1
- package/dist/lib/checkpoint-ontology/entity-file.js +15 -17
- package/dist/lib/daemon/catalog.d.ts +2 -0
- package/dist/lib/daemon/catalog.js +2 -0
- package/dist/lib/daemon/hook-requests.js +23 -3
- package/dist/lib/daemon/run.d.ts +14 -0
- package/dist/lib/daemon/run.js +24 -14
- package/dist/lib/deploy-api.d.ts +2 -0
- package/dist/lib/deploy-api.js +9 -0
- package/dist/lib/environment/work-requirements.js +1 -1
- package/dist/lib/hook-engine/coverage.js +50 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +0 -76
- package/dist/lib/hot-channels/signals-pass.js +81 -4
- package/dist/lib/lanes/account-company.js +1 -1
- package/dist/lib/lanes/account-ownership.js +1 -1
- package/dist/lib/lanes/accounts.js +1 -1
- package/dist/lib/lanes/delivery.js +7 -7
- package/dist/lib/lanes/dropbox.js +1 -1
- package/dist/lib/lanes/grants.js +3 -3
- package/dist/lib/lanes/hq-root.js +1 -1
- package/dist/lib/lanes/keep-alive-audit.js +2 -2
- package/dist/lib/lanes/links.js +4 -4
- package/dist/lib/lanes/monitor.js +3 -3
- package/dist/lib/lanes/quota-notice.js +1 -1
- package/dist/lib/lanes/reconcile.js +22 -12
- package/dist/lib/lanes/signal-brief-template.js +1 -1
- package/dist/lib/lanes/worker-continuity.js +1 -1
- package/dist/lib/mesh/live/direct-drain.d.ts +1 -0
- package/dist/lib/mesh/live/direct-drain.js +12 -1
- package/dist/lib/mesh/live/emit.d.ts +1 -1
- package/dist/lib/mesh/live/emit.js +10 -5
- package/dist/lib/mesh/live/flush.js +19 -4
- package/dist/lib/mesh/live/reporting-privacy.d.ts +9 -3
- package/dist/lib/mesh/live/reporting-privacy.js +27 -7
- package/dist/lib/mesh/live/spool.d.ts +2 -0
- package/dist/lib/mesh/live/spool.js +41 -0
- package/dist/lib/signals/sanitize.js +5 -4
- package/dist/lib/signals/steps/garden.js +5 -4
- package/dist/lib/windows/jq.d.ts +17 -0
- package/dist/lib/windows/jq.js +72 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.js +11 -2
- package/dist/utils/hq-roots-core.d.ts +5 -0
- package/dist/utils/hq-roots-core.js +18 -9
- package/dist/utils/owner-session.d.ts +13 -0
- package/dist/utils/owner-session.js +28 -0
- package/package.json +7 -7
- package/scripts/install-hook-engine.mjs +8 -15
package/dist/lazy-commands.js
CHANGED
|
@@ -5,7 +5,7 @@ import { COMMAND_CATALOG } from "./command-catalog.generated.js";
|
|
|
5
5
|
import { installUnknownCommandSuggestions } from "./unknown-command.js";
|
|
6
6
|
import { restoreRuntimeText } from "./utils/catalog-runtime-paths.js";
|
|
7
7
|
import { STILL_USE_FLAG } from "./utils/command-usage.js";
|
|
8
|
-
import { isHqRoot } from "./utils/hq-roots-core.js";
|
|
8
|
+
import { findHqRootAncestor, isHqRoot } from "./utils/hq-roots-core.js";
|
|
9
9
|
import { MissingRegistrationPlanError } from "./utils/registration-plan-error.js";
|
|
10
10
|
const commandCatalog = COMMAND_CATALOG;
|
|
11
11
|
/**
|
|
@@ -92,15 +92,7 @@ function runtimeHqRoot() {
|
|
|
92
92
|
return findRuntimeHqRoot(resolve(process.cwd()));
|
|
93
93
|
}
|
|
94
94
|
export function findRuntimeHqRoot(start, parentOf = dirname, isRoot = isHqRoot) {
|
|
95
|
-
|
|
96
|
-
for (;;) {
|
|
97
|
-
if (isRoot(directory))
|
|
98
|
-
return directory;
|
|
99
|
-
const parent = parentOf(directory);
|
|
100
|
-
if (parent === directory)
|
|
101
|
-
return start;
|
|
102
|
-
directory = parent;
|
|
103
|
-
}
|
|
95
|
+
return findHqRootAncestor(start, isRoot, parentOf) ?? start;
|
|
104
96
|
}
|
|
105
97
|
/**
|
|
106
98
|
* Register only generated root metadata. This is enough for root help and
|
package/dist/lib/bot/api.d.ts
CHANGED
|
@@ -125,6 +125,9 @@ export interface AgentRecord {
|
|
|
125
125
|
};
|
|
126
126
|
/** "assistant" on HQ's setup assistant, null on other local bots; absent on older servers. */
|
|
127
127
|
agentRole?: string | null;
|
|
128
|
+
/** Cloud agents: "archived" once `hq agents rm` has torn the agent down. */
|
|
129
|
+
entityStatus?: string;
|
|
130
|
+
agentStatus?: string;
|
|
128
131
|
}
|
|
129
132
|
/**
|
|
130
133
|
* One of the caller's own local bots, as `GET /v1/agents/mine?local=1` lists
|
|
@@ -173,6 +176,14 @@ export interface BotApiOptions {
|
|
|
173
176
|
baseUrl?: string;
|
|
174
177
|
fetchImpl?: typeof vaultApiFetch;
|
|
175
178
|
}
|
|
179
|
+
/** The promotion protocol this client speaks; HQ refuses new moves from older ones. */
|
|
180
|
+
export declare const PROMOTION_CLIENT_VERSION = 2;
|
|
181
|
+
/** The local bot's model brain, sent at prepare so HQ can refuse what cloud bots cannot run. */
|
|
182
|
+
export interface BotPromotionBrain {
|
|
183
|
+
runtime: "codex" | "claude" | "grok";
|
|
184
|
+
model?: string;
|
|
185
|
+
effort?: string;
|
|
186
|
+
}
|
|
176
187
|
export interface BotPromotionState {
|
|
177
188
|
version: number;
|
|
178
189
|
operationId: string;
|
|
@@ -181,6 +192,8 @@ export interface BotPromotionState {
|
|
|
181
192
|
companyUid: string;
|
|
182
193
|
snapshotSha256: string;
|
|
183
194
|
phase: "preparing" | "local-stopped" | "imported" | "cloud-ready" | "active" | "cancelled";
|
|
195
|
+
/** True on a status read while a cancel is in progress. */
|
|
196
|
+
cancelRequested?: boolean;
|
|
184
197
|
updatedAt: string;
|
|
185
198
|
}
|
|
186
199
|
export interface BotPromotionUpload {
|
|
@@ -311,16 +324,19 @@ export declare class BotApi {
|
|
|
311
324
|
companyUid: string;
|
|
312
325
|
operationId: string;
|
|
313
326
|
snapshotSha256: string;
|
|
327
|
+
brain: BotPromotionBrain;
|
|
314
328
|
}): Promise<BotPromotionState>;
|
|
315
329
|
promotionDetails(agentUid: string, companyUid: string): Promise<{
|
|
316
330
|
promotion: BotPromotionState | null;
|
|
317
331
|
failure?: string;
|
|
332
|
+
failureCode?: string;
|
|
318
333
|
pairing: {
|
|
319
334
|
url: string;
|
|
320
335
|
code: string;
|
|
321
336
|
capturedAt?: string;
|
|
322
337
|
} | null;
|
|
323
338
|
}>;
|
|
339
|
+
/** Null only for an explicit `promotion: null`; any other body that is not a promotion throws. */
|
|
324
340
|
promotionStatus(agentUid: string, companyUid: string): Promise<BotPromotionState | null>;
|
|
325
341
|
resumePromotion(agentUid: string, input: {
|
|
326
342
|
companyUid: string;
|
|
@@ -329,6 +345,17 @@ export declare class BotApi {
|
|
|
329
345
|
promotion: BotPromotionState;
|
|
330
346
|
pending: boolean;
|
|
331
347
|
}>;
|
|
348
|
+
/** 200 once cancelled (idempotent); 202 while the cloud box is still shutting down or a cancel is in progress.
|
|
349
|
+
* `identityRestored: false` on a 200 means the bot's own sign-in could not be put back yet.
|
|
350
|
+
*/
|
|
351
|
+
cancelPromotion(agentUid: string, input: {
|
|
352
|
+
companyUid: string;
|
|
353
|
+
operationId: string;
|
|
354
|
+
}): Promise<{
|
|
355
|
+
promotion: BotPromotionState | null;
|
|
356
|
+
pending: boolean;
|
|
357
|
+
identityRestored?: boolean;
|
|
358
|
+
}>;
|
|
332
359
|
confirmPromotionStopped(agentUid: string, input: {
|
|
333
360
|
companyUid: string;
|
|
334
361
|
operationId: string;
|
package/dist/lib/bot/api.js
CHANGED
|
@@ -67,6 +67,8 @@ async function readError(res) {
|
|
|
67
67
|
return {};
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
+
/** The promotion protocol this client speaks; HQ refuses new moves from older ones. */
|
|
71
|
+
export const PROMOTION_CLIENT_VERSION = 2;
|
|
70
72
|
export class BotApi {
|
|
71
73
|
opts;
|
|
72
74
|
fetchImpl;
|
|
@@ -281,14 +283,38 @@ export class BotApi {
|
|
|
281
283
|
return (await this.call(`/v1/agents/${encodeURIComponent(agentUid)}/promote/prepare`, { method: "POST", body: input })).body.promotion;
|
|
282
284
|
}
|
|
283
285
|
async promotionDetails(agentUid, companyUid) {
|
|
284
|
-
return (await this.call(`/v1/agents/${encodeURIComponent(agentUid)}/promote?companyUid=${encodeURIComponent(companyUid)}`, { method: "GET" })).body;
|
|
286
|
+
return (await this.call(`/v1/agents/${encodeURIComponent(agentUid)}/promote?companyUid=${encodeURIComponent(companyUid)}&clientVersion=${PROMOTION_CLIENT_VERSION}`, { method: "GET" })).body;
|
|
285
287
|
}
|
|
288
|
+
/** Null only for an explicit `promotion: null`; any other body that is not a promotion throws. */
|
|
286
289
|
async promotionStatus(agentUid, companyUid) {
|
|
287
|
-
|
|
290
|
+
const body = (await this.call(`/v1/agents/${encodeURIComponent(agentUid)}/promote?companyUid=${encodeURIComponent(companyUid)}&clientVersion=${PROMOTION_CLIENT_VERSION}`, { method: "GET" })).body;
|
|
291
|
+
if (body && typeof body === "object" && "promotion" in body) {
|
|
292
|
+
const promotion = body.promotion;
|
|
293
|
+
if (promotion === null)
|
|
294
|
+
return null;
|
|
295
|
+
if (promotion && typeof promotion === "object") {
|
|
296
|
+
const state = promotion;
|
|
297
|
+
if (typeof state.operationId === "string" && typeof state.phase === "string" && typeof state.agentUid === "string")
|
|
298
|
+
return promotion;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
throw new Error("HQ answered the promotion status without a readable promotion. Nothing was changed; try again.");
|
|
288
302
|
}
|
|
289
303
|
async resumePromotion(agentUid, input) {
|
|
290
304
|
return (await this.call(`/v1/agents/${encodeURIComponent(agentUid)}/promote/resume`, { method: "POST", body: input })).body;
|
|
291
305
|
}
|
|
306
|
+
/** 200 once cancelled (idempotent); 202 while the cloud box is still shutting down or a cancel is in progress.
|
|
307
|
+
* `identityRestored: false` on a 200 means the bot's own sign-in could not be put back yet.
|
|
308
|
+
*/
|
|
309
|
+
async cancelPromotion(agentUid, input) {
|
|
310
|
+
const res = await this.call(`/v1/agents/${encodeURIComponent(agentUid)}/promote/cancel`, { method: "POST", body: input }, [200, 202]);
|
|
311
|
+
const body = res.body && typeof res.body === "object" ? res.body : {};
|
|
312
|
+
return {
|
|
313
|
+
promotion: body.promotion && typeof body.promotion === "object" ? body.promotion : null,
|
|
314
|
+
pending: res.status === 202 || body.pending === true,
|
|
315
|
+
...(typeof body.identityRestored === "boolean" ? { identityRestored: body.identityRestored } : {}),
|
|
316
|
+
};
|
|
317
|
+
}
|
|
292
318
|
async confirmPromotionStopped(agentUid, input) {
|
|
293
319
|
return (await this.call(`/v1/agents/${encodeURIComponent(agentUid)}/promote/local-stopped`, { method: "POST", body: input })).body.promotion;
|
|
294
320
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface CloudCreateOptions {
|
|
2
|
+
legacyRuntime?: boolean;
|
|
3
|
+
kind?: string;
|
|
4
|
+
company?: string[];
|
|
5
|
+
runtime?: string;
|
|
6
|
+
provider?: string;
|
|
7
|
+
model?: string;
|
|
8
|
+
autoApprove?: boolean;
|
|
9
|
+
worker?: string;
|
|
10
|
+
displayName?: string;
|
|
11
|
+
intro?: string;
|
|
12
|
+
kickoff?: string;
|
|
13
|
+
memory?: string;
|
|
14
|
+
start?: boolean;
|
|
15
|
+
readyTimeout?: string;
|
|
16
|
+
json?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface CloudOutpost {
|
|
19
|
+
outpostId: string;
|
|
20
|
+
state: string;
|
|
21
|
+
createdAt?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface CloudExecResult {
|
|
24
|
+
status: string;
|
|
25
|
+
done: boolean;
|
|
26
|
+
exitCode?: number | null;
|
|
27
|
+
stdout?: string;
|
|
28
|
+
stderr?: string;
|
|
29
|
+
truncated?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface CloudCreateDeps {
|
|
32
|
+
list: () => Promise<CloudOutpost[]>;
|
|
33
|
+
submitExec: (command: string, outpostId: string, timeoutSeconds: number) => Promise<{
|
|
34
|
+
commandId: string;
|
|
35
|
+
}>;
|
|
36
|
+
waitForExecResult: (commandId: string, outpostId: string, maxWaitMs: number) => Promise<CloudExecResult>;
|
|
37
|
+
print: (line: string) => void;
|
|
38
|
+
}
|
|
39
|
+
export declare const CLOUD_CREATE_SETUP_SECONDS = 900;
|
|
40
|
+
export declare function assertCloudCreateOptions(opts: CloudCreateOptions, name?: string): void;
|
|
41
|
+
export declare function cloudCreateRemoteArgs(name: string, opts: CloudCreateOptions): string[];
|
|
42
|
+
export declare function cloudCreateRemoteCommand(name: string, opts: CloudCreateOptions): string;
|
|
43
|
+
export declare function pickPersonalOutpost(outposts: readonly CloudOutpost[]): CloudOutpost;
|
|
44
|
+
export declare function parseRemoteCreateResult(stdout: string): Record<string, unknown> | null;
|
|
45
|
+
export declare function runBotCreateOnOutpost(name: string, opts: CloudCreateOptions, deps: CloudCreateDeps): Promise<void>;
|
|
46
|
+
//# sourceMappingURL=cloud-create.d.ts.map
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { withRemoteHqDir } from "@indigoai-us/hq-cloud/outposts";
|
|
2
|
+
import { DEFAULT_BOT_READY_TIMEOUT_SECONDS } from "./readiness.js";
|
|
3
|
+
export const CLOUD_CREATE_SETUP_SECONDS = 900;
|
|
4
|
+
const GONE_STATES = new Set(["destroyed", "destroying"]);
|
|
5
|
+
const RESERVED_ASSISTANT_NAME = "setup";
|
|
6
|
+
function expected(message) {
|
|
7
|
+
return Object.assign(new Error(message), { expected: true });
|
|
8
|
+
}
|
|
9
|
+
function shellQuote(value) {
|
|
10
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
11
|
+
}
|
|
12
|
+
export function assertCloudCreateOptions(opts, name) {
|
|
13
|
+
if (name === RESERVED_ASSISTANT_NAME) {
|
|
14
|
+
throw expected(`The name ${RESERVED_ASSISTANT_NAME} is reserved for HQ's assistant on your own computer. Choose another name for a cloud bot.`);
|
|
15
|
+
}
|
|
16
|
+
const kind = opts.kind?.trim().toLowerCase();
|
|
17
|
+
if ((kind !== undefined && kind !== "" && kind !== "personal") || (opts.company?.length ?? 0) > 0) {
|
|
18
|
+
throw expected("--cloud creates a personal bot that acts as you in every company you belong to. Drop --kind company and --company; to move a company bot to the cloud use hq bot promote <name>.");
|
|
19
|
+
}
|
|
20
|
+
if (opts.memory !== undefined && opts.memory !== "synced") {
|
|
21
|
+
throw expected("--cloud keeps the bot's memory in your HQ so you can read it from any computer. Drop --memory, or use --memory synced.");
|
|
22
|
+
}
|
|
23
|
+
if (opts.legacyRuntime === true) {
|
|
24
|
+
throw expected("--legacy-runtime is no longer supported: new bots run on the HQ Fleet Runtime. Drop --legacy-runtime.");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function cloudCreateRemoteArgs(name, opts) {
|
|
28
|
+
const args = ["bot", "create", name, "--kind", "personal", "--json"];
|
|
29
|
+
const valued = [
|
|
30
|
+
["--runtime", opts.runtime],
|
|
31
|
+
["--provider", opts.provider],
|
|
32
|
+
["--model", opts.model],
|
|
33
|
+
["--worker", opts.worker],
|
|
34
|
+
["--display-name", opts.displayName],
|
|
35
|
+
["--intro", opts.intro],
|
|
36
|
+
["--kickoff", opts.kickoff],
|
|
37
|
+
["--ready-timeout", opts.readyTimeout],
|
|
38
|
+
];
|
|
39
|
+
for (const [flag, value] of valued)
|
|
40
|
+
if (value !== undefined)
|
|
41
|
+
args.push(`${flag}=${value}`);
|
|
42
|
+
if (opts.autoApprove === true)
|
|
43
|
+
args.push("--auto-approve");
|
|
44
|
+
if (opts.start === false)
|
|
45
|
+
args.push("--no-start");
|
|
46
|
+
return args;
|
|
47
|
+
}
|
|
48
|
+
export function cloudCreateRemoteCommand(name, opts) {
|
|
49
|
+
const inner = ["hq", ...cloudCreateRemoteArgs(name, opts)].map(shellQuote).join(" ");
|
|
50
|
+
return withRemoteHqDir(`bash -lc ${shellQuote(inner)}`);
|
|
51
|
+
}
|
|
52
|
+
export function pickPersonalOutpost(outposts) {
|
|
53
|
+
const live = outposts
|
|
54
|
+
.filter((outpost) => !GONE_STATES.has(outpost.state))
|
|
55
|
+
.sort((a, b) => (a.createdAt ?? "").localeCompare(b.createdAt ?? ""));
|
|
56
|
+
const ready = live.find((outpost) => outpost.state === "ready");
|
|
57
|
+
if (ready)
|
|
58
|
+
return ready;
|
|
59
|
+
if (live.length === 0) {
|
|
60
|
+
throw expected("A cloud bot runs on your personal Outpost, and you do not have one yet. Create it with: hq outposts create --personal (it shows the monthly price first). Then run this command again.");
|
|
61
|
+
}
|
|
62
|
+
throw expected(`Your personal Outpost is not ready yet (${live[0].state}). Check it with hq outposts status, then run this command again.`);
|
|
63
|
+
}
|
|
64
|
+
export function parseRemoteCreateResult(stdout) {
|
|
65
|
+
const lines = stdout.trim().split("\n");
|
|
66
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
67
|
+
if (!lines[i].startsWith("{"))
|
|
68
|
+
continue;
|
|
69
|
+
try {
|
|
70
|
+
const parsed = JSON.parse(lines.slice(i).join("\n"));
|
|
71
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed))
|
|
72
|
+
return parsed;
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
function readySeconds(value) {
|
|
81
|
+
if (value === undefined)
|
|
82
|
+
return DEFAULT_BOT_READY_TIMEOUT_SECONDS;
|
|
83
|
+
const seconds = Number(value.trim());
|
|
84
|
+
if (!Number.isInteger(seconds) || seconds < 1 || seconds > 3600) {
|
|
85
|
+
throw expected("--ready-timeout must be a whole number of seconds from 1 to 3600.");
|
|
86
|
+
}
|
|
87
|
+
return seconds;
|
|
88
|
+
}
|
|
89
|
+
export async function runBotCreateOnOutpost(name, opts, deps) {
|
|
90
|
+
assertCloudCreateOptions(opts, name);
|
|
91
|
+
const budgetSeconds = CLOUD_CREATE_SETUP_SECONDS + readySeconds(opts.readyTimeout);
|
|
92
|
+
const outpost = pickPersonalOutpost(await deps.list());
|
|
93
|
+
if (!opts.json)
|
|
94
|
+
deps.print(`Creating ${name} on your personal Outpost (${outpost.outpostId}). This can take a few minutes.`);
|
|
95
|
+
const { commandId } = await deps.submitExec(cloudCreateRemoteCommand(name, opts), outpost.outpostId, budgetSeconds);
|
|
96
|
+
const checkLater = `It may still finish on your Outpost. Check with: hq outposts exec --id ${outpost.outpostId} -- hq bot status ${name}`;
|
|
97
|
+
let result;
|
|
98
|
+
try {
|
|
99
|
+
result = await deps.waitForExecResult(commandId, outpost.outpostId, (budgetSeconds + 60) * 1000);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
const message = `Stopped waiting for ${name} to be created. ${checkLater}`;
|
|
103
|
+
if (opts.json) {
|
|
104
|
+
deps.print(JSON.stringify({ ok: false, name, hosting: "cloud", outpostId: outpost.outpostId, commandId, reason: "cloud-create-pending", message }, null, 2));
|
|
105
|
+
}
|
|
106
|
+
throw Object.assign(expected(message), { jsonReported: opts.json === true });
|
|
107
|
+
}
|
|
108
|
+
const remote = parseRemoteCreateResult(result.stdout ?? "");
|
|
109
|
+
const ok = result.done && result.exitCode === 0 && remote?.ok === true;
|
|
110
|
+
if (!ok) {
|
|
111
|
+
const reason = (typeof remote?.message === "string" && remote.message) ||
|
|
112
|
+
(remote === null && result.done && result.exitCode === 0 && `the Outpost finished the command but its result could not be read. ${checkLater}`) ||
|
|
113
|
+
(result.stderr ?? "").trim().split("\n").filter(Boolean).pop() ||
|
|
114
|
+
`the Outpost command ended with status ${result.status}`;
|
|
115
|
+
if (opts.json) {
|
|
116
|
+
deps.print(JSON.stringify({ ok: false, name, hosting: "cloud", outpostId: outpost.outpostId, reason: "cloud-create-failed", message: reason }, null, 2));
|
|
117
|
+
}
|
|
118
|
+
throw Object.assign(expected(`Could not create ${name} on your Outpost: ${reason}`), { jsonReported: opts.json === true });
|
|
119
|
+
}
|
|
120
|
+
if (opts.json) {
|
|
121
|
+
deps.print(JSON.stringify({ ...remote, hosting: "cloud", outpostId: outpost.outpostId }, null, 2));
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const agentUid = typeof remote.agentUid === "string" ? ` (${remote.agentUid})` : "";
|
|
125
|
+
deps.print(`Created cloud bot ${name}${agentUid}. It runs on your Outpost and acts as you in every company you belong to.`);
|
|
126
|
+
deps.print(remote.running === true ? `${name} is running. Message it from HQ.` : `${name} is set up but has not reported running yet. Check it with: hq outposts exec --id ${outpost.outpostId} -- hq bot status ${name}`);
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=cloud-create.js.map
|
|
@@ -19,6 +19,7 @@ import { HQ_FLEET_RUNTIME_ENGINE_ID, patchBotConfig, readBotConfig } from "./con
|
|
|
19
19
|
import { defaultPathEntries } from "./daemon.js";
|
|
20
20
|
import { clearStaleFleetGatewayReady, controlFleetLocalBot, fleetLocalGatewayPid, fleetLocalGatewayProcess, fleetLocalLaunchAgentLabel, fleetLocalLaunchAgentPlist, removeFleetLocalEmbeddedRuntime, } from "./fleet-local.js";
|
|
21
21
|
import { botsRoot } from "./paths.js";
|
|
22
|
+
import { localPromotionState } from "./promotion-receipt.js";
|
|
22
23
|
import { isPidAlive } from "./status.js";
|
|
23
24
|
import { askDaemonToStart, askDaemonToStop, daemonUnitInstalled, hostedDaemonRunning } from "../daemon/handoff.js";
|
|
24
25
|
import { daemonPaths } from "../daemon/paths.js";
|
|
@@ -211,7 +212,8 @@ export function planFleetBots(deps = {}) {
|
|
|
211
212
|
const platform = deps.platform ?? process.platform;
|
|
212
213
|
const home = deps.home ?? os.homedir();
|
|
213
214
|
const env = deps.env ?? process.env;
|
|
214
|
-
return listFleetBots(deps.root ?? botsRoot(home, env)).map(({ name, config }) => {
|
|
215
|
+
return listFleetBots(deps.root ?? botsRoot(home, env)).map(({ name, dir, config }) => {
|
|
216
|
+
const promotion = localPromotionState(dir, config.agentUid, config.ownerUid);
|
|
215
217
|
let legacyAgent;
|
|
216
218
|
let outsideGateway;
|
|
217
219
|
if (platform === "darwin") {
|
|
@@ -246,6 +248,7 @@ export function planFleetBots(deps = {}) {
|
|
|
246
248
|
gateway,
|
|
247
249
|
authPending: config.fleetAuthPending === true,
|
|
248
250
|
installPending: config.fleetServiceInstallPending === true,
|
|
251
|
+
...(promotion ? { promotion } : {}),
|
|
249
252
|
...(legacyAgent ? { legacyAgent } : {}),
|
|
250
253
|
...(outsideGateway !== undefined ? { outsideGateway } : {}),
|
|
251
254
|
};
|
|
@@ -365,6 +365,13 @@ export declare function fleetLocalProfileNeedsAdoption(agentUid: string, deps?:
|
|
|
365
365
|
export declare function controlFleetLocalBot(agentUid: string, action: FleetLocalServiceAction, deps?: FleetLocalControlDeps): Record<string, unknown>;
|
|
366
366
|
export declare function exportFleetLocalMachineCredential(agentUid: string, deps?: FleetLocalControlDeps): BotMachineCreds;
|
|
367
367
|
export declare function fleetLocalPromotionRuntime(agentUid: string, deps?: FleetLocalControlDeps): LocalBotPromotionRuntime;
|
|
368
|
+
/** The model provider the bot's HQ Fleet profile names, or null when it cannot be read. */
|
|
369
|
+
export declare function fleetLocalProfileProvider(agentUid: string, deps?: Pick<FleetLocalControlDeps, "fleetHome">): Partial<FleetLocalProfile["provider"]> | null;
|
|
370
|
+
/**
|
|
371
|
+
* The model brain a Fleet profile provider runs, or null when it names none
|
|
372
|
+
* this hq knows. Any Anthropic sign of the provider means Claude.
|
|
373
|
+
*/
|
|
374
|
+
export declare function fleetProviderBrainRuntime(provider: Partial<FleetLocalProfile["provider"]>): BotRuntimeId | null;
|
|
368
375
|
export declare function removeFleetLocalBot(agentUid: string, deps?: FleetLocalControlDeps): FleetLocalRemovalResult;
|
|
369
376
|
export type FleetLocalStartControl = (agentUid: string, action: "install" | "restart") => {
|
|
370
377
|
ok?: unknown;
|
|
@@ -12,7 +12,7 @@ import { grokLoginFromScan, localBotLoginScopes } from "./grok-login-scope.js";
|
|
|
12
12
|
import { ensureFleetPython, fleetUvEnv } from "./fleet-python.js";
|
|
13
13
|
import semver from "semver";
|
|
14
14
|
import { CLI_VERSION } from "../../cli-version.js";
|
|
15
|
-
import {
|
|
15
|
+
import { ensureOwnerToken } from "../../utils/owner-session.js";
|
|
16
16
|
import { vaultApiFetch } from "../../utils/vault-api.js";
|
|
17
17
|
import { HQ_CLI_NPM_UPDATE_COMMAND } from "../../utils/npm-install-flags.js";
|
|
18
18
|
/** The model the HQ Fleet Runtime asks for when a Claude bot names none. */
|
|
@@ -401,7 +401,7 @@ export function resolveFleetReleaseToken(env = process.env, run = execFileSync)
|
|
|
401
401
|
export async function lookupHqFleetReleaseLinks(release, deps = {}) {
|
|
402
402
|
let token;
|
|
403
403
|
try {
|
|
404
|
-
token = await (deps.token ?? (() =>
|
|
404
|
+
token = await (deps.token ?? (() => ensureOwnerToken({ interactive: false })))();
|
|
405
405
|
}
|
|
406
406
|
catch {
|
|
407
407
|
return { links: null, reason: "signed_out" };
|
|
@@ -626,7 +626,7 @@ export function chooseFleetLocalTargetRelease(pointer, compiled = HQ_FLEET_LOCAL
|
|
|
626
626
|
return { release: pointer.release, source: "pointer", links: pointer.links, linksExpireAt: pointer.linksExpireAt };
|
|
627
627
|
}
|
|
628
628
|
export async function fetchFleetLocalReleasePointer(deps = {}) {
|
|
629
|
-
const token = await (deps.token ?? (() =>
|
|
629
|
+
const token = await (deps.token ?? (() => ensureOwnerToken({ interactive: false })))();
|
|
630
630
|
const response = await (deps.fetchApi ?? vaultApiFetch)({
|
|
631
631
|
token,
|
|
632
632
|
path: "/v1/fleet-local/releases/latest",
|
|
@@ -1446,8 +1446,44 @@ export function fleetLocalPromotionRuntime(agentUid, deps = {}) {
|
|
|
1446
1446
|
controlFleetLocalBot(agentUid, "stop", deps);
|
|
1447
1447
|
},
|
|
1448
1448
|
machineCredential: () => exportFleetLocalMachineCredential(agentUid, deps),
|
|
1449
|
+
brain: () => {
|
|
1450
|
+
const provider = fleetLocalProfileProvider(agentUid, deps);
|
|
1451
|
+
return provider ? { runtime: fleetProviderBrainRuntime(provider), ...(provider.model ? { model: provider.model } : {}) } : null;
|
|
1452
|
+
},
|
|
1449
1453
|
};
|
|
1450
1454
|
}
|
|
1455
|
+
/** The model provider the bot's HQ Fleet profile names, or null when it cannot be read. */
|
|
1456
|
+
export function fleetLocalProfileProvider(agentUid, deps = {}) {
|
|
1457
|
+
try {
|
|
1458
|
+
const raw = JSON.parse(fs.readFileSync(path.join(fleetLocalProfileDir(agentUid, deps), "profile.json"), "utf8"));
|
|
1459
|
+
const provider = raw?.provider;
|
|
1460
|
+
if (!provider || typeof provider !== "object")
|
|
1461
|
+
return null;
|
|
1462
|
+
const text = (value) => (typeof value === "string" && value.trim() ? value.trim() : undefined);
|
|
1463
|
+
const out = {};
|
|
1464
|
+
for (const key of ["id", "model", "credentialProvider", "transport"]) {
|
|
1465
|
+
const value = text(provider[key]);
|
|
1466
|
+
if (value)
|
|
1467
|
+
out[key] = value;
|
|
1468
|
+
}
|
|
1469
|
+
return out.id || out.credentialProvider || out.transport ? out : null;
|
|
1470
|
+
}
|
|
1471
|
+
catch {
|
|
1472
|
+
return null;
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* The model brain a Fleet profile provider runs, or null when it names none
|
|
1477
|
+
* this hq knows. Any Anthropic sign of the provider means Claude.
|
|
1478
|
+
*/
|
|
1479
|
+
export function fleetProviderBrainRuntime(provider) {
|
|
1480
|
+
const { id, credentialProvider, transport } = provider;
|
|
1481
|
+
if (id === "anthropic" || id === "custom:personal-anthropic" || credentialProvider === "anthropic" || transport === "anthropic_messages")
|
|
1482
|
+
return "claude";
|
|
1483
|
+
const preset = id ? (Object.hasOwn(providerProfiles, id) ? providerProfiles[id] : Object.values(providerProfiles).find((profile) => profile.provider === id)) : undefined;
|
|
1484
|
+
const runtimeProvider = credentialProvider ?? preset?.runtimeProvider ?? id ?? "";
|
|
1485
|
+
return Object.hasOwn(SIGN_IN_PROVIDER_RUNTIME, runtimeProvider) ? SIGN_IN_PROVIDER_RUNTIME[runtimeProvider] : null;
|
|
1486
|
+
}
|
|
1451
1487
|
export function removeFleetLocalBot(agentUid, deps = {}) {
|
|
1452
1488
|
const run = deps.run ?? execFileSync;
|
|
1453
1489
|
if (!/^agt_[A-Za-z0-9_-]+$/.test(agentUid)) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ensureOwnerToken } from "../../utils/owner-session.js";
|
|
2
2
|
import { vaultApiFetch } from "../../utils/vault-api.js";
|
|
3
3
|
const MEMBERSHIP_TIMEOUT_MS = 10_000;
|
|
4
4
|
const COMPANY_UID_RE = /^cmp_[A-Za-z0-9]{3,128}$/;
|
|
5
5
|
const COMPANY_SLUG_RE = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
6
6
|
async function signedInMemberships() {
|
|
7
|
-
const token = await
|
|
7
|
+
const token = await ensureOwnerToken({ interactive: false });
|
|
8
8
|
const res = await vaultApiFetch({ token, path: "/membership/me", signal: AbortSignal.timeout(MEMBERSHIP_TIMEOUT_MS) });
|
|
9
9
|
if (!res.ok)
|
|
10
10
|
throw new Error(`membership lookup returned ${res.status}`);
|
|
@@ -1,6 +1,37 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { BotConfig } from "./config.js";
|
|
1
|
+
import { type BotApi, type BotPromotionBrain, type BotPromotionState } from "./api.js";
|
|
2
|
+
import type { BotConfig, BotRuntimeId } from "./config.js";
|
|
3
3
|
import type { BotMachineCreds } from "./creds.js";
|
|
4
|
+
/** HQ's note on why a move is stuck, as the person should read it; HQ's own text goes to the bot log. */
|
|
5
|
+
export declare function promotionFailureText(dir: string, config: BotConfig, companyUid: string, failure: string, failureCode?: string): string;
|
|
6
|
+
/** Any error from reading a move's details, as a short reason; the raw text goes to the bot log. */
|
|
7
|
+
export declare function promotionDetailsError(dir: string, error: unknown): string;
|
|
8
|
+
export type CloudAgentPresence = "gone" | "present" | "unknown" | "not-owner";
|
|
9
|
+
/** The signed-in person's prs_ uid, by the lookup hq whoami uses. */
|
|
10
|
+
export type SignedInPerson = () => Promise<string | null>;
|
|
11
|
+
/** Whether HQ still has this bot's agent. Gone only when the bot's owner is
|
|
12
|
+
* signed in and HQ shows the agent archived. A 404 is never proof: HQ answers
|
|
13
|
+
* 404 to anyone who may not read the agent, and no other route the owner can
|
|
14
|
+
* read lists archived agents.
|
|
15
|
+
*/
|
|
16
|
+
export declare function cloudAgentPresence(input: {
|
|
17
|
+
api: BotApi;
|
|
18
|
+
config: BotConfig;
|
|
19
|
+
dir: string;
|
|
20
|
+
signedInPerson?: SignedInPerson;
|
|
21
|
+
}): Promise<CloudAgentPresence>;
|
|
22
|
+
/** `hq bot rm` of a bot held for, or moved by, a promotion. Allowed only when HQ
|
|
23
|
+
* shows the owner its cloud agent archived; otherwise the cloud copy is or may
|
|
24
|
+
* become the bot's active consumer, so this throws and nothing is removed.
|
|
25
|
+
* Returns the company the bot moved to: its seat there went with the agent.
|
|
26
|
+
*/
|
|
27
|
+
export declare function assertPromotedBotRemovable(input: {
|
|
28
|
+
dir: string;
|
|
29
|
+
config: BotConfig;
|
|
30
|
+
api: BotApi;
|
|
31
|
+
signedInPerson: SignedInPerson;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
companyUid: string | null;
|
|
34
|
+
}>;
|
|
4
35
|
/** A bot whose process and HQ machine credential live outside its state folder,
|
|
5
36
|
* such as an HQ Fleet Runtime bot: promotion stops its service through the
|
|
6
37
|
* runtime and reads the credential from the runtime's secure store.
|
|
@@ -8,9 +39,20 @@ import type { BotMachineCreds } from "./creds.js";
|
|
|
8
39
|
export interface LocalBotPromotionRuntime {
|
|
9
40
|
stop(): void;
|
|
10
41
|
machineCredential(): BotMachineCreds;
|
|
42
|
+
/** The brain the runtime profile names, or null when the profile cannot be read; runtime is null for a provider this hq does not know. */
|
|
43
|
+
brain?(): {
|
|
44
|
+
runtime: BotRuntimeId | null;
|
|
45
|
+
model?: string;
|
|
46
|
+
} | null;
|
|
11
47
|
}
|
|
48
|
+
/** The bot's brain as sent at prepare: a known runtime profile provider wins over bot.json. */
|
|
49
|
+
export declare function promotionBrain(config: BotConfig, runtime?: LocalBotPromotionRuntime): BotPromotionBrain;
|
|
50
|
+
/** Cloud bots run on Codex only for now. A bot already held names the cancel. */
|
|
51
|
+
export declare function promotionBrainRefusal(config: BotConfig, brain: BotPromotionBrain, dir: string): Error | null;
|
|
12
52
|
/** One recoverable local-to-cloud step, used by CLI and desktop. Never kills the
|
|
13
53
|
* local runtime, recopies provider login files, or changes another bot.
|
|
54
|
+
* When this call creates the hold and fails before the server records the
|
|
55
|
+
* operation, it releases the hold and starts the bot again if it was running.
|
|
14
56
|
*/
|
|
15
57
|
export declare function promoteLocalBot(input: {
|
|
16
58
|
dir: string;
|
|
@@ -19,8 +61,45 @@ export declare function promoteLocalBot(input: {
|
|
|
19
61
|
api: BotApi;
|
|
20
62
|
drainTimeoutMs?: number;
|
|
21
63
|
runtime?: LocalBotPromotionRuntime;
|
|
64
|
+
isRunning?: () => boolean;
|
|
65
|
+
restart?: () => Promise<unknown>;
|
|
22
66
|
}): Promise<{
|
|
23
67
|
promotion: BotPromotionState;
|
|
24
68
|
pending: boolean;
|
|
25
69
|
}>;
|
|
70
|
+
export type PromotionCancelOutcome = "canceled" | "pending" | "active" | "not-found";
|
|
71
|
+
export interface PromotionCancelResult {
|
|
72
|
+
outcome: PromotionCancelOutcome;
|
|
73
|
+
promotion: BotPromotionState | null;
|
|
74
|
+
pending: boolean;
|
|
75
|
+
/** The local hold was removed, so the bot can run on this computer again. */
|
|
76
|
+
localHoldReleased: boolean;
|
|
77
|
+
/** Whether the bot was running when the hold was first written; null when no record was left (an older hq). */
|
|
78
|
+
wasRunning: boolean | null;
|
|
79
|
+
/** From a confirmed cancel: false when HQ could not put the bot's own sign-in back. */
|
|
80
|
+
identityRestored: boolean | null;
|
|
81
|
+
}
|
|
82
|
+
export declare const PROMOTION_CANCEL_POLL_MS = 5000;
|
|
83
|
+
/** Below the bot lock's stale age, so no other command can take the lock mid-cancel. */
|
|
84
|
+
export declare const PROMOTION_CANCEL_TIMEOUT_MS: number;
|
|
85
|
+
export declare const PROMOTION_CANCEL_IDENTITY_RETRIES = 3;
|
|
86
|
+
/** Cancel on the server first. The local hold, its receipt and its frozen
|
|
87
|
+
* snapshots are released only on proof that nothing needs the bot held: a
|
|
88
|
+
* confirmed cancel for this operation, PROMOTION_NOT_FOUND, or no server
|
|
89
|
+
* promotion at all. Anything else keeps the hold. A damaged hold may name
|
|
90
|
+
* another company, so only a confirmed cancel releases it. When HQ will not
|
|
91
|
+
* show the move (403, or 404 without a code), a readable hold for this company
|
|
92
|
+
* still asks HQ to cancel its operation: cancel is authorized on the bot alone.
|
|
93
|
+
*/
|
|
94
|
+
export declare function cancelLocalBotPromotion(input: {
|
|
95
|
+
dir: string;
|
|
96
|
+
config: BotConfig;
|
|
97
|
+
companyUid: string;
|
|
98
|
+
api: BotApi;
|
|
99
|
+
pollMs?: number;
|
|
100
|
+
timeoutMs?: number;
|
|
101
|
+
sleep?: (ms: number) => Promise<void>;
|
|
102
|
+
onWaiting?: () => void;
|
|
103
|
+
signedInPerson?: SignedInPerson;
|
|
104
|
+
}): Promise<PromotionCancelResult>;
|
|
26
105
|
//# sourceMappingURL=promote.d.ts.map
|