@indigoai-us/hq-cli 5.345.234 → 5.345.236

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 (100) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/dist/command-catalog.generated.d.ts +311 -7
  3. package/dist/command-catalog.generated.js +383 -7
  4. package/dist/command-registration-plan.d.ts +30 -0
  5. package/dist/command-registration-plan.js +5 -0
  6. package/dist/commands/bot-companies.d.ts +4 -1
  7. package/dist/commands/bot-companies.js +5 -1
  8. package/dist/commands/bot.d.ts +10 -0
  9. package/dist/commands/bot.js +165 -36
  10. package/dist/commands/capacity.js +1 -1
  11. package/dist/commands/core-handoff.js +2 -2
  12. package/dist/commands/core-ontology-native.js +5 -4
  13. package/dist/commands/core-pipeline-workflow-runner-native.js +4 -9
  14. package/dist/commands/deploy-app-db.d.ts +3 -0
  15. package/dist/commands/deploy-app-db.js +79 -0
  16. package/dist/commands/deploy-app-upload.d.ts +3 -0
  17. package/dist/commands/deploy-app-upload.js +120 -0
  18. package/dist/commands/deploy-comments.js +46 -1
  19. package/dist/commands/deploy-mutations.js +71 -5
  20. package/dist/commands/deploy-runtime-bindings.d.ts +3 -0
  21. package/dist/commands/deploy-runtime-bindings.js +135 -0
  22. package/dist/commands/deploy-ssr.d.ts +3 -0
  23. package/dist/commands/deploy-ssr.js +74 -0
  24. package/dist/commands/dm.d.ts +7 -1
  25. package/dist/commands/dm.js +39 -9
  26. package/dist/commands/doctor.js +2 -10
  27. package/dist/commands/fingerprint.js +4 -9
  28. package/dist/commands/lanes-accounts.js +5 -5
  29. package/dist/commands/lanes-hold.js +1 -1
  30. package/dist/commands/lanes-message.js +3 -3
  31. package/dist/commands/lanes-move.js +1 -1
  32. package/dist/commands/lanes-resume.js +6 -6
  33. package/dist/commands/lanes-watch.js +2 -2
  34. package/dist/commands/lanes.js +21 -21
  35. package/dist/commands/work-env.d.ts +90 -0
  36. package/dist/commands/work-env.js +304 -0
  37. package/dist/lazy-commands.js +2 -10
  38. package/dist/lib/bot/api.d.ts +27 -0
  39. package/dist/lib/bot/api.js +28 -2
  40. package/dist/lib/bot/cloud-create.d.ts +46 -0
  41. package/dist/lib/bot/cloud-create.js +128 -0
  42. package/dist/lib/bot/fleet-daemon.js +4 -1
  43. package/dist/lib/bot/fleet-local.d.ts +7 -0
  44. package/dist/lib/bot/fleet-local.js +39 -3
  45. package/dist/lib/bot/fleet-owner-companies.js +2 -2
  46. package/dist/lib/bot/promote.d.ts +81 -2
  47. package/dist/lib/bot/promote.js +425 -51
  48. package/dist/lib/bot/promotion-hold.d.ts +9 -0
  49. package/dist/lib/bot/promotion-hold.js +29 -0
  50. package/dist/lib/bot/promotion-receipt.d.ts +10 -0
  51. package/dist/lib/bot/promotion-receipt.js +41 -1
  52. package/dist/lib/bot/promotion-upload.d.ts +6 -1
  53. package/dist/lib/bot/promotion-upload.js +3 -1
  54. package/dist/lib/bot/readiness.d.ts +9 -0
  55. package/dist/lib/bot/readiness.js +16 -0
  56. package/dist/lib/capacity/route.js +4 -4
  57. package/dist/lib/capacity/sign-in.js +1 -1
  58. package/dist/lib/checkpoint-ontology/entity-file.js +15 -17
  59. package/dist/lib/daemon/catalog.d.ts +2 -0
  60. package/dist/lib/daemon/catalog.js +2 -0
  61. package/dist/lib/daemon/hook-requests.js +23 -3
  62. package/dist/lib/daemon/run.d.ts +14 -0
  63. package/dist/lib/daemon/run.js +24 -14
  64. package/dist/lib/deploy-api.d.ts +3 -1
  65. package/dist/lib/deploy-api.js +11 -1
  66. package/dist/lib/environment/work-requirements.js +1 -1
  67. package/dist/lib/hot-channels/signals-pass.d.ts +0 -76
  68. package/dist/lib/hot-channels/signals-pass.js +81 -4
  69. package/dist/lib/lanes/account-company.js +1 -1
  70. package/dist/lib/lanes/account-ownership.js +1 -1
  71. package/dist/lib/lanes/accounts.js +1 -1
  72. package/dist/lib/lanes/delivery.js +7 -7
  73. package/dist/lib/lanes/dropbox.js +1 -1
  74. package/dist/lib/lanes/grants.js +3 -3
  75. package/dist/lib/lanes/hq-root.js +1 -1
  76. package/dist/lib/lanes/keep-alive-audit.js +2 -2
  77. package/dist/lib/lanes/links.js +4 -4
  78. package/dist/lib/lanes/monitor.js +3 -3
  79. package/dist/lib/lanes/quota-notice.js +1 -1
  80. package/dist/lib/lanes/reconcile.js +22 -12
  81. package/dist/lib/lanes/signal-brief-template.js +1 -1
  82. package/dist/lib/lanes/worker-continuity.js +1 -1
  83. package/dist/lib/mesh/live/direct-drain.d.ts +1 -0
  84. package/dist/lib/mesh/live/direct-drain.js +12 -1
  85. package/dist/lib/mesh/live/emit.d.ts +1 -1
  86. package/dist/lib/mesh/live/emit.js +10 -5
  87. package/dist/lib/mesh/live/flush.js +19 -4
  88. package/dist/lib/mesh/live/reporting-privacy.d.ts +9 -3
  89. package/dist/lib/mesh/live/reporting-privacy.js +27 -7
  90. package/dist/lib/mesh/live/spool.d.ts +2 -0
  91. package/dist/lib/mesh/live/spool.js +41 -0
  92. package/dist/lib/signals/sanitize.js +5 -4
  93. package/dist/lib/signals/steps/garden.js +5 -4
  94. package/dist/utils/frontmatter.d.ts +8 -0
  95. package/dist/utils/frontmatter.js +11 -2
  96. package/dist/utils/hq-roots-core.d.ts +5 -0
  97. package/dist/utils/hq-roots-core.js +18 -9
  98. package/dist/utils/owner-session.d.ts +13 -0
  99. package/dist/utils/owner-session.js +28 -0
  100. package/package.json +7 -7
@@ -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 { ensureCognitoToken } from "../../utils/cognito-session.js";
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 ?? (() => ensureCognitoToken({ tokenSource: "person", interactive: false })))();
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 ?? (() => ensureCognitoToken({ tokenSource: "person", interactive: false })))();
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 { ensureCognitoToken } from "../../utils/cognito-session.js";
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 ensureCognitoToken({ tokenSource: "person", interactive: false });
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 { BotApi, BotPromotionState } from "./api.js";
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