@indigoai-us/hq-cli 5.345.211 → 5.345.212
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 +39 -0
- package/dist/command-catalog.generated.d.ts +28 -0
- package/dist/command-catalog.generated.js +34 -0
- package/dist/command-registration-plan.d.ts +15 -0
- package/dist/command-registration-plan.js +20 -1
- package/dist/commands/agents.js +6 -1
- package/dist/commands/billing.js +17 -4
- package/dist/commands/bot-runtime.d.ts +21 -2
- package/dist/commands/bot-runtime.js +54 -9
- package/dist/commands/bot.d.ts +13 -0
- package/dist/commands/bot.js +142 -12
- package/dist/commands/daemon.js +60 -5
- package/dist/commands/files.js +2 -2
- package/dist/commands/integrations-api.d.ts +11 -0
- package/dist/commands/integrations-connect.d.ts +2 -0
- package/dist/commands/integrations-connect.js +17 -5
- package/dist/commands/integrations-core.d.ts +1 -1
- package/dist/commands/integrations-core.js +18 -10
- package/dist/commands/integrations.js +1 -1
- package/dist/commands/lanes.js +34 -16
- package/dist/commands/whoami.js +7 -6
- package/dist/lazy-commands.js +4 -1
- package/dist/lib/billing/usage-only.d.ts +4 -1
- package/dist/lib/billing/usage-only.js +7 -2
- package/dist/lib/bot/api.d.ts +1 -1
- package/dist/lib/bot/config.js +2 -1
- package/dist/lib/bot/fleet-daemon.d.ts +4 -0
- package/dist/lib/bot/fleet-daemon.js +12 -1
- package/dist/lib/bot/fleet-download.d.ts +6 -0
- package/dist/lib/bot/fleet-download.js +128 -3
- package/dist/lib/bot/fleet-local.d.ts +38 -1
- package/dist/lib/bot/fleet-local.js +239 -26
- package/dist/lib/bot/install-progress.d.ts +28 -0
- package/dist/lib/bot/install-progress.js +185 -0
- package/dist/lib/bot/legacy-provider-login.d.ts +22 -1
- package/dist/lib/bot/legacy-provider-login.js +67 -9
- package/dist/lib/bot/prompt.d.ts +1 -0
- package/dist/lib/bot/prompt.js +3 -2
- package/dist/lib/bot/readiness.d.ts +68 -0
- package/dist/lib/bot/readiness.js +145 -0
- package/dist/lib/bot/run.d.ts +2 -0
- package/dist/lib/bot/run.js +6 -3
- package/dist/lib/bot/scaffold.d.ts +6 -3
- package/dist/lib/bot/scaffold.js +18 -12
- package/dist/lib/capacity/ledger.d.ts +7 -0
- package/dist/lib/capacity/ledger.js +31 -1
- package/dist/lib/capacity/project.d.ts +1 -1
- package/dist/lib/capacity/project.js +13 -4
- package/dist/lib/capacity/route.d.ts +10 -0
- package/dist/lib/capacity/route.js +16 -0
- package/dist/lib/daemon/install.d.ts +15 -0
- package/dist/lib/daemon/install.js +31 -0
- package/dist/lib/daemon/migrate.js +29 -4
- package/dist/lib/daemon/run.d.ts +1 -0
- package/dist/lib/daemon/run.js +6 -1
- package/dist/lib/daemon/supervisor.d.ts +1 -0
- package/dist/lib/daemon/supervisor.js +5 -3
- package/dist/lib/doctor/__testing__/run-doctor.js +4 -0
- package/dist/lib/doctor/checks/jq.d.ts +27 -0
- package/dist/lib/doctor/checks/jq.js +82 -0
- package/dist/lib/doctor/registry.js +4 -0
- package/dist/lib/flag-snapshot-file.js +36 -8
- package/dist/lib/install/codex-targets.d.ts +52 -1
- package/dist/lib/install/codex-targets.js +77 -2
- package/dist/lib/lanes/monitor.d.ts +4 -1
- package/dist/lib/lanes/monitor.js +47 -10
- package/dist/lib/lanes/spawn.js +8 -1
- package/dist/lib/lanes/watch.js +31 -0
- package/dist/lib/onboarding/checkpoint.d.ts +6 -0
- package/dist/lib/onboarding/checkpoint.js +6 -0
- package/dist/lib/onboarding/orchestrator.d.ts +3 -1
- package/dist/lib/onboarding/orchestrator.js +62 -9
- package/dist/lib/onboarding/types.d.ts +8 -0
- package/dist/lib/work-context/organize.d.ts +23 -1
- package/dist/lib/work-context/organize.js +25 -3
- package/dist/lib/work-context/reconcile.js +3 -2
- package/dist/secrets-env-action.js +7 -5
- package/dist/startup-registration.js +7 -2
- package/dist/utils/billing-gate.d.ts +12 -16
- package/dist/utils/billing-gate.js +17 -18
- package/dist/utils/install-tree-torn.d.ts +22 -4
- package/dist/utils/install-tree-torn.js +24 -0
- package/dist/utils/registration-plan-error.d.ts +22 -0
- package/dist/utils/registration-plan-error.js +27 -0
- package/dist/utils/sentry-fingerprint.js +3 -0
- package/dist/utils/unauthorized-error.d.ts +36 -0
- package/dist/utils/unauthorized-error.js +105 -0
- package/dist/utils/vault-api.js +7 -5
- package/package.json +7 -7
- package/scripts/install-hook-engine.mjs +17 -0
|
@@ -15,22 +15,14 @@
|
|
|
15
15
|
* 3. `hq billing checkout` (see commands/billing.ts) reuses `mintPaymentLink`
|
|
16
16
|
* to hand out the same link proactively.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
* (
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* (`src/lib/billing/usage-card.ts`, `GET /v1/pricing` with a bundled
|
|
25
|
-
* fallback): small t3.small, medium t3.medium, large t3.large, xlarge
|
|
26
|
-
* t3.xlarge. Use {@link usageBoxQuotes} / {@link usageBoxQuoteCents}, never
|
|
27
|
-
* the legacy constants, for a usage-only account.
|
|
18
|
+
* This module holds no list price. Usage pricing (US-012): boxes are quoted
|
|
19
|
+
* by size from the usage card (`src/lib/billing/usage-card.ts`,
|
|
20
|
+
* `GET /v1/pricing` with a bundled fallback): small t3.small, medium
|
|
21
|
+
* t3.medium, large t3.large, xlarge t3.xlarge. Use {@link usageBoxQuotes} /
|
|
22
|
+
* {@link usageBoxQuoteCents}. Callers pass the unit price to
|
|
23
|
+
* {@link confirmChargeOrExit}.
|
|
28
24
|
*/
|
|
29
25
|
import { type UsageCard } from "../lib/billing/usage-card.js";
|
|
30
|
-
/** Legacy per-Agent monthly list price, in cents ($100.00 / agent / month). */
|
|
31
|
-
export declare const AGENT_PRICE_CENTS = 10000;
|
|
32
|
-
/** Legacy per-Outpost monthly list price, in cents ($80.00 / Outpost / month). */
|
|
33
|
-
export declare const OUTPOST_PRICE_CENTS = 8000;
|
|
34
26
|
/** Usage-pricing box sizes, in card order ("small (t3.small) $100/month, ..."). */
|
|
35
27
|
export declare function usageBoxQuotes(card?: UsageCard): string;
|
|
36
28
|
/**
|
|
@@ -87,8 +79,12 @@ export declare function mintPaymentLink(token: string, setup: BillingSetupAction
|
|
|
87
79
|
* message so the user can add a card (or hand the link to whoever owns billing)
|
|
88
80
|
* and re-run. Returns the URL, or `null` when the server gave no `setup` action
|
|
89
81
|
* to act on. Never prints tokens or secrets.
|
|
82
|
+
*
|
|
83
|
+
* `isUsagePricing` (US-034) is asked only after the link is minted. A
|
|
84
|
+
* usage-pricing company is told a card is needed before HQ creates the box;
|
|
85
|
+
* every other company, and an unknown plan, keeps the legacy sentence.
|
|
90
86
|
*/
|
|
91
|
-
export declare function surfaceBillingRequired(token: string, billing: BillingErrorPayload): Promise<string | null>;
|
|
87
|
+
export declare function surfaceBillingRequired(token: string, billing: BillingErrorPayload, isUsagePricing?: () => Promise<boolean>): Promise<string | null>;
|
|
92
88
|
/**
|
|
93
89
|
* Status-aware surface for a 402 billing block. hq-pro's envelope carries two
|
|
94
90
|
* distinct remediations that must never be conflated (mirroring the server's
|
|
@@ -103,5 +99,5 @@ export declare function surfaceBillingRequired(token: string, billing: BillingEr
|
|
|
103
99
|
* - anything else (`billing_required`) — genuinely no usable card on
|
|
104
100
|
* file; the existing add-a-card copy is correct.
|
|
105
101
|
*/
|
|
106
|
-
export declare function surfaceBillingBlocked(token: string, billing: BillingErrorPayload, serverMessage?: string): Promise<string | null>;
|
|
102
|
+
export declare function surfaceBillingBlocked(token: string, billing: BillingErrorPayload, serverMessage?: string, isUsagePricing?: () => Promise<boolean>): Promise<string | null>;
|
|
107
103
|
//# sourceMappingURL=billing-gate.d.ts.map
|
|
@@ -15,24 +15,16 @@
|
|
|
15
15
|
* 3. `hq billing checkout` (see commands/billing.ts) reuses `mintPaymentLink`
|
|
16
16
|
* to hand out the same link proactively.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
* (
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* (`src/lib/billing/usage-card.ts`, `GET /v1/pricing` with a bundled
|
|
25
|
-
* fallback): small t3.small, medium t3.medium, large t3.large, xlarge
|
|
26
|
-
* t3.xlarge. Use {@link usageBoxQuotes} / {@link usageBoxQuoteCents}, never
|
|
27
|
-
* the legacy constants, for a usage-only account.
|
|
18
|
+
* This module holds no list price. Usage pricing (US-012): boxes are quoted
|
|
19
|
+
* by size from the usage card (`src/lib/billing/usage-card.ts`,
|
|
20
|
+
* `GET /v1/pricing` with a bundled fallback): small t3.small, medium
|
|
21
|
+
* t3.medium, large t3.large, xlarge t3.xlarge. Use {@link usageBoxQuotes} /
|
|
22
|
+
* {@link usageBoxQuoteCents}. Callers pass the unit price to
|
|
23
|
+
* {@link confirmChargeOrExit}.
|
|
28
24
|
*/
|
|
29
25
|
import chalk from "chalk";
|
|
30
26
|
import { vaultApiFetch } from "./vault-api.js";
|
|
31
27
|
import { BUNDLED_USAGE_CARD, formatBoxQuotes, } from "../lib/billing/usage-card.js";
|
|
32
|
-
/** Legacy per-Agent monthly list price, in cents ($100.00 / agent / month). */
|
|
33
|
-
export const AGENT_PRICE_CENTS = 10_000;
|
|
34
|
-
/** Legacy per-Outpost monthly list price, in cents ($80.00 / Outpost / month). */
|
|
35
|
-
export const OUTPOST_PRICE_CENTS = 8_000;
|
|
36
28
|
/** Usage-pricing box sizes, in card order ("small (t3.small) $100/month, ..."). */
|
|
37
29
|
export function usageBoxQuotes(card = BUNDLED_USAGE_CARD) {
|
|
38
30
|
return formatBoxQuotes(card);
|
|
@@ -128,15 +120,22 @@ export async function mintPaymentLink(token, setup) {
|
|
|
128
120
|
* message so the user can add a card (or hand the link to whoever owns billing)
|
|
129
121
|
* and re-run. Returns the URL, or `null` when the server gave no `setup` action
|
|
130
122
|
* to act on. Never prints tokens or secrets.
|
|
123
|
+
*
|
|
124
|
+
* `isUsagePricing` (US-034) is asked only after the link is minted. A
|
|
125
|
+
* usage-pricing company is told a card is needed before HQ creates the box;
|
|
126
|
+
* every other company, and an unknown plan, keeps the legacy sentence.
|
|
131
127
|
*/
|
|
132
|
-
export async function surfaceBillingRequired(token, billing) {
|
|
128
|
+
export async function surfaceBillingRequired(token, billing, isUsagePricing = async () => false) {
|
|
133
129
|
if (!billing.setup) {
|
|
134
130
|
console.error(chalk.yellow("Provisioning is blocked on billing, but the server didn't return a " +
|
|
135
131
|
"payment link. Add a card in the console billing page, then re-run."));
|
|
136
132
|
return null;
|
|
137
133
|
}
|
|
138
134
|
const url = await mintPaymentLink(token, billing.setup);
|
|
139
|
-
|
|
135
|
+
const usage = await isUsagePricing().catch(() => false);
|
|
136
|
+
console.log(chalk.yellow(usage
|
|
137
|
+
? "A card is needed before HQ creates this box. The box bills to the card each month."
|
|
138
|
+
: "No card on file — provisioning is blocked until one is added."));
|
|
140
139
|
console.log("Add a card here (safe to share with whoever owns billing):\n " +
|
|
141
140
|
chalk.cyan(url));
|
|
142
141
|
console.log(chalk.dim("Once a card is added, re-run the same command."));
|
|
@@ -156,9 +155,9 @@ export async function surfaceBillingRequired(token, billing) {
|
|
|
156
155
|
* - anything else (`billing_required`) — genuinely no usable card on
|
|
157
156
|
* file; the existing add-a-card copy is correct.
|
|
158
157
|
*/
|
|
159
|
-
export async function surfaceBillingBlocked(token, billing, serverMessage) {
|
|
158
|
+
export async function surfaceBillingBlocked(token, billing, serverMessage, isUsagePricing) {
|
|
160
159
|
if (billing.status !== "payment_failed") {
|
|
161
|
-
return surfaceBillingRequired(token, billing);
|
|
160
|
+
return surfaceBillingRequired(token, billing, isUsagePricing);
|
|
162
161
|
}
|
|
163
162
|
console.error(chalk.yellow(serverMessage?.trim() ||
|
|
164
163
|
"Your payment failed. Try a different card or contact your bank."));
|
|
@@ -29,15 +29,17 @@
|
|
|
29
29
|
* ../startup-registration.ts; version-gate.ts / self-update.ts / update-lock.ts
|
|
30
30
|
* are only READ (their exported symbols), never modified.
|
|
31
31
|
*/
|
|
32
|
+
import { MISSING_REGISTRATION_PLAN_CODE } from "./registration-plan-error.js";
|
|
32
33
|
/**
|
|
33
34
|
* The loader-error `code`s recovery classifies. The first two mean "a module
|
|
34
35
|
* could not be resolved"; `ENOENT` is the loader/resolver dialect where a module
|
|
35
36
|
* was present at one step and gone at the next (HQ-CLI-1M esm-load open, HQ-CLI-20
|
|
36
37
|
* cjs-load open, HQ-CLI-1S resolve-time lstat); `EVAL_THROW` is the synthetic code
|
|
37
38
|
* for a module-EVALUATION throw that carries NO real `code` (HQ-CLI-1T) — see
|
|
38
|
-
* {@link ModuleErrorDialect}.
|
|
39
|
+
* {@link ModuleErrorDialect}. `ERR_HQ_NO_REGISTRATION_PLAN` is hq-cli's own code
|
|
40
|
+
* for a catalog root the registration plan does not know (HQ-CLI-GM).
|
|
39
41
|
*/
|
|
40
|
-
type ModuleNotFoundCode = "ERR_MODULE_NOT_FOUND" | "MODULE_NOT_FOUND" | "ENOENT" | "EVAL_THROW";
|
|
42
|
+
type ModuleNotFoundCode = "ERR_MODULE_NOT_FOUND" | "MODULE_NOT_FOUND" | "ENOENT" | "EVAL_THROW" | typeof MISSING_REGISTRATION_PLAN_CODE;
|
|
41
43
|
/**
|
|
42
44
|
* The closed set of resolution-failure dialects, verified on Node v22.23.1 and
|
|
43
45
|
* the observed Node 24 synchronous ESM loader shape (the @sentry/node
|
|
@@ -75,10 +77,16 @@ type ModuleNotFoundCode = "ERR_MODULE_NOT_FOUND" | "MODULE_NOT_FOUND" | "ENOENT"
|
|
|
75
77
|
* module and its top-level code threw a code-LESS TypeError /
|
|
76
78
|
* ReferenceError / SyntaxError under Module._compile /
|
|
77
79
|
* esm/module_job. The specifier is the bounded throw-site path.
|
|
78
|
-
* - `
|
|
80
|
+
* - `missing-plan`: the startup command catalog named a root that the lazily
|
|
81
|
+
* imported registration plan has no entry for (HQ-CLI-GM): an
|
|
82
|
+
* update replaced the install between the two imports, so the
|
|
83
|
+
* catalog and the plan come from different releases. No file is
|
|
84
|
+
* missing, so the target is `unknown` and readiness rides the
|
|
85
|
+
* lock / retired-dir / quiet signals, like the loader races.
|
|
86
|
+
* - `unknown`: a module-not-found whose message did not parse; recovery
|
|
79
87
|
* still waits on the lock / retired-dir / quiet signals.
|
|
80
88
|
*/
|
|
81
|
-
type ModuleErrorDialect = "esm-path" | "esm-package" | "cjs-path" | "cjs-package" | "cjs-relative" | "esm-enoent" | "cjs-enoent" | "resolve-enoent" | "eval-throw" | "unknown";
|
|
89
|
+
type ModuleErrorDialect = "esm-path" | "esm-package" | "cjs-path" | "cjs-package" | "cjs-relative" | "esm-enoent" | "cjs-enoent" | "resolve-enoent" | "eval-throw" | "missing-plan" | "unknown";
|
|
82
90
|
/**
|
|
83
91
|
* The missing thing, re-resolvable by the readiness probe:
|
|
84
92
|
* - `path`: an absolute filesystem path (a `.js` file, or a package dir).
|
|
@@ -142,6 +150,16 @@ export declare function packageNameOf(specifier: string): string;
|
|
|
142
150
|
* `null` so it is rethrown to the existing boundary unchanged.
|
|
143
151
|
*/
|
|
144
152
|
export declare function classifyModuleNotFound(err: unknown): ClassifiedModuleError | null;
|
|
153
|
+
/**
|
|
154
|
+
* Classify a lazy root's "No registration plan" failure (HQ-CLI-GM) as a torn
|
|
155
|
+
* install. Matched by hq-cli's own error `code` plus a string `root`, never by
|
|
156
|
+
* message text, so it holds even when the error class came from a different
|
|
157
|
+
* install than this module. Like the loader-race dialects it needs no writer
|
|
158
|
+
* gate: the catalog and the plan disagreeing is itself the sign that the tree
|
|
159
|
+
* changed under this process. The parity test guarantees a single release has a
|
|
160
|
+
* plan for every catalog root, so a settled re-exec resolves it.
|
|
161
|
+
*/
|
|
162
|
+
export declare function classifyMissingRegistrationPlan(err: unknown): ClassifiedModuleError | null;
|
|
145
163
|
/** The structural fingerprint of a module-EVALUATION throw (HQ-CLI-1T). */
|
|
146
164
|
export interface EvalThrowShape {
|
|
147
165
|
/** The thrown error's `name`, in {@link EVAL_THROW_NAMES}. */
|
|
@@ -37,6 +37,7 @@ import { CLI_NAME } from "../cli-version.js";
|
|
|
37
37
|
import { boundedDiagnosticValue } from "./package-root-diagnostics.js";
|
|
38
38
|
import { isLockStale, UPDATE_LOCK_STALE_MS } from "./update-lock.js";
|
|
39
39
|
import { HQ_CLI_NPM_UPDATE_COMMAND } from "./npm-install-flags.js";
|
|
40
|
+
import { MISSING_REGISTRATION_PLAN_CODE } from "./registration-plan-error.js";
|
|
40
41
|
/** Byte caps for the (hq-derived, path-shaped) diagnostic strings. */
|
|
41
42
|
const SPECIFIER_BYTES = 256;
|
|
42
43
|
const IMPORTER_BYTES = 256;
|
|
@@ -410,6 +411,29 @@ export function classifyModuleNotFound(err) {
|
|
|
410
411
|
// the lock / retired-dir / quiet signals only.
|
|
411
412
|
return { code, dialect: "unknown", specifier: "", importer: "", target: { kind: "unknown" } };
|
|
412
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* Classify a lazy root's "No registration plan" failure (HQ-CLI-GM) as a torn
|
|
416
|
+
* install. Matched by hq-cli's own error `code` plus a string `root`, never by
|
|
417
|
+
* message text, so it holds even when the error class came from a different
|
|
418
|
+
* install than this module. Like the loader-race dialects it needs no writer
|
|
419
|
+
* gate: the catalog and the plan disagreeing is itself the sign that the tree
|
|
420
|
+
* changed under this process. The parity test guarantees a single release has a
|
|
421
|
+
* plan for every catalog root, so a settled re-exec resolves it.
|
|
422
|
+
*/
|
|
423
|
+
export function classifyMissingRegistrationPlan(err) {
|
|
424
|
+
if (err === null || typeof err !== "object")
|
|
425
|
+
return null;
|
|
426
|
+
const record = err;
|
|
427
|
+
if (record.code !== MISSING_REGISTRATION_PLAN_CODE || typeof record.root !== "string")
|
|
428
|
+
return null;
|
|
429
|
+
return {
|
|
430
|
+
code: MISSING_REGISTRATION_PLAN_CODE,
|
|
431
|
+
dialect: "missing-plan",
|
|
432
|
+
specifier: `registration plan for '${record.root}'`,
|
|
433
|
+
importer: "",
|
|
434
|
+
target: { kind: "unknown" },
|
|
435
|
+
};
|
|
436
|
+
}
|
|
413
437
|
/**
|
|
414
438
|
* Detect a module-EVALUATION throw STRUCTURALLY, WITHOUT the node_modules
|
|
415
439
|
* boundary gate: an error with NO `code`, a `name` in the closed set
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The error a lazy root throws when the registration plan has no entry for it
|
|
3
|
+
* (Sentry HQ-CLI-GM, feedback_05f34e58).
|
|
4
|
+
*
|
|
5
|
+
* `lazy-commands.ts` reads the command catalog at startup and imports the
|
|
6
|
+
* registration plan (`register-all.js`) later, when it registers the requested
|
|
7
|
+
* root. When hq-cli updates itself between those two steps, the old catalog can
|
|
8
|
+
* name a root that the new plan does not have. That is a torn install, so the
|
|
9
|
+
* torn-install recovery in startup-registration.ts classifies this error by its
|
|
10
|
+
* `code` (see classifyMissingRegistrationPlan) and re-execs the settled install.
|
|
11
|
+
*
|
|
12
|
+
* Kept in its own dependency-free module so the startup path that throws it does
|
|
13
|
+
* not import the torn-install classifier.
|
|
14
|
+
*/
|
|
15
|
+
export declare const MISSING_REGISTRATION_PLAN_CODE = "ERR_HQ_NO_REGISTRATION_PLAN";
|
|
16
|
+
export declare class MissingRegistrationPlanError extends Error {
|
|
17
|
+
readonly code = "ERR_HQ_NO_REGISTRATION_PLAN";
|
|
18
|
+
/** The catalog root name that had no plan (hq-derived, never argv). */
|
|
19
|
+
readonly root: string;
|
|
20
|
+
constructor(root: string);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=registration-plan-error.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The error a lazy root throws when the registration plan has no entry for it
|
|
3
|
+
* (Sentry HQ-CLI-GM, feedback_05f34e58).
|
|
4
|
+
*
|
|
5
|
+
* `lazy-commands.ts` reads the command catalog at startup and imports the
|
|
6
|
+
* registration plan (`register-all.js`) later, when it registers the requested
|
|
7
|
+
* root. When hq-cli updates itself between those two steps, the old catalog can
|
|
8
|
+
* name a root that the new plan does not have. That is a torn install, so the
|
|
9
|
+
* torn-install recovery in startup-registration.ts classifies this error by its
|
|
10
|
+
* `code` (see classifyMissingRegistrationPlan) and re-execs the settled install.
|
|
11
|
+
*
|
|
12
|
+
* Kept in its own dependency-free module so the startup path that throws it does
|
|
13
|
+
* not import the torn-install classifier.
|
|
14
|
+
*/
|
|
15
|
+
export const MISSING_REGISTRATION_PLAN_CODE = "ERR_HQ_NO_REGISTRATION_PLAN";
|
|
16
|
+
export class MissingRegistrationPlanError extends Error {
|
|
17
|
+
code = MISSING_REGISTRATION_PLAN_CODE;
|
|
18
|
+
/** The catalog root name that had no plan (hq-derived, never argv). */
|
|
19
|
+
root;
|
|
20
|
+
constructor(root) {
|
|
21
|
+
super(`No registration plan for '${root}'`);
|
|
22
|
+
this.name = "MissingRegistrationPlanError";
|
|
23
|
+
this.root = root;
|
|
24
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=registration-plan-error.js.map
|
|
@@ -174,6 +174,7 @@ const INSTALL_TREE_PHASES = new Set([
|
|
|
174
174
|
"esm-package",
|
|
175
175
|
"esm-path",
|
|
176
176
|
"eval-throw",
|
|
177
|
+
"missing-plan",
|
|
177
178
|
"resolve-enoent",
|
|
178
179
|
"unknown",
|
|
179
180
|
]);
|
|
@@ -207,6 +208,8 @@ function installTreePhaseTag(value) {
|
|
|
207
208
|
return "loader_read";
|
|
208
209
|
if (value === "eval-throw")
|
|
209
210
|
return "module_evaluation";
|
|
211
|
+
if (value === "missing-plan")
|
|
212
|
+
return "registration_plan";
|
|
210
213
|
if (value === "esm-package" || value === "cjs-package")
|
|
211
214
|
return "package_resolution";
|
|
212
215
|
if (value === "unknown")
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AuthError } from "./auth-error.js";
|
|
2
|
+
/** A machine identity this process signs in as, or null for a person. */
|
|
3
|
+
export interface MachineAuthCaller {
|
|
4
|
+
kind: "company-outpost" | "machine";
|
|
5
|
+
/** The machine's entity uid (out_… / agt_…) when the local state names one. */
|
|
6
|
+
entityUid?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Which machine identity, if any, this process authenticates as. Local state
|
|
10
|
+
* only (env and the machine credential files), no network. A delegated
|
|
11
|
+
* session file always means a machine caller, even when the file is
|
|
12
|
+
* unreadable: the parent that set it chose a machine identity, and a person
|
|
13
|
+
* login could never be the fix.
|
|
14
|
+
*/
|
|
15
|
+
export declare function machineAuthCaller(env?: NodeJS.ProcessEnv): MachineAuthCaller | null;
|
|
16
|
+
/**
|
|
17
|
+
* The machine-readable code from a 401 body, when it carries one. Reads the
|
|
18
|
+
* REST shape (`{ error, code }`) and the JSON-RPC shapes (`error.code`,
|
|
19
|
+
* `error.data.code`). Only an upper-snake-case code is returned.
|
|
20
|
+
*/
|
|
21
|
+
export declare function unauthorizedServerCode(body: unknown): string | undefined;
|
|
22
|
+
/** Message for a 401 a company Outpost job gets. */
|
|
23
|
+
export declare function companyOutpostUnauthorizedMessage(caller: MachineAuthCaller, code?: string): string;
|
|
24
|
+
/** Message for a 401 any other machine identity (agent box, external bot) gets. */
|
|
25
|
+
export declare function machineUnauthorizedMessage(caller: MachineAuthCaller, code?: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* The AuthError for an HTTP 401 from hq-pro. A person keeps the `hq login`
|
|
28
|
+
* message; a company Outpost or other machine identity gets its own recovery
|
|
29
|
+
* and the server's code. Still an AuthError, so the top-level handler prints
|
|
30
|
+
* it and exits non-zero without a Sentry crash report.
|
|
31
|
+
*/
|
|
32
|
+
export declare function unauthorizedError(opts?: {
|
|
33
|
+
body?: unknown;
|
|
34
|
+
env?: NodeJS.ProcessEnv;
|
|
35
|
+
}): AuthError;
|
|
36
|
+
//# sourceMappingURL=unauthorized-error.d.ts.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// src/utils/unauthorized-error.ts
|
|
2
|
+
//
|
|
3
|
+
// One place that turns an HTTP 401 from hq-pro into the right AuthError for
|
|
4
|
+
// the identity this process signs in as (feedback_dfc0bb49).
|
|
5
|
+
//
|
|
6
|
+
// A person on a laptop fixes an expired or missing session with `hq login`.
|
|
7
|
+
// A machine identity cannot: a company Outpost job signs in with the Outpost's
|
|
8
|
+
// own machine credentials (the job runner hands it HQ_MACHINE_SESSION_FILE),
|
|
9
|
+
// and an agent box signs in from its machine credentials file. Telling either
|
|
10
|
+
// to run `hq login` sent support chasing a sign-in problem for four days in
|
|
11
|
+
// the Ridge company Outpost incident, when hq-pro was rejecting the Outpost
|
|
12
|
+
// principal itself (OUTPOST_PRINCIPAL_INVALID). So a 401 for a machine caller
|
|
13
|
+
// says the server rejected the machine identity, names the server's code, and
|
|
14
|
+
// gives the recovery that exists for that identity.
|
|
15
|
+
import { DELEGATED_MACHINE_SESSION_ENV, delegatedMachineSessionFilePath, loadMachineCreds, } from "@indigoai-us/hq-cloud";
|
|
16
|
+
import { AuthError } from "./auth-error.js";
|
|
17
|
+
import { wantsMachineCognitoTokens } from "./machine-principal-state.js";
|
|
18
|
+
const ENTITY_UID_PATTERN = /^(out|agt)_[0-9A-Za-z]{10,40}$/;
|
|
19
|
+
// Server codes are upper snake case (OUTPOST_PRINCIPAL_INVALID). Anything else
|
|
20
|
+
// in the body is server text and is not echoed into the message.
|
|
21
|
+
const SERVER_CODE_PATTERN = /^[A-Z][A-Z0-9_]{2,63}$/;
|
|
22
|
+
/**
|
|
23
|
+
* Which machine identity, if any, this process authenticates as. Local state
|
|
24
|
+
* only (env and the machine credential files), no network. A delegated
|
|
25
|
+
* session file always means a machine caller, even when the file is
|
|
26
|
+
* unreadable: the parent that set it chose a machine identity, and a person
|
|
27
|
+
* login could never be the fix.
|
|
28
|
+
*/
|
|
29
|
+
export function machineAuthCaller(env = process.env) {
|
|
30
|
+
try {
|
|
31
|
+
const delegated = delegatedMachineSessionFilePath() !== null;
|
|
32
|
+
if (!delegated && !wantsMachineCognitoTokens({}, env))
|
|
33
|
+
return null;
|
|
34
|
+
const creds = loadMachineCreds();
|
|
35
|
+
const entityUid = typeof creds?.entityUid === "string" && ENTITY_UID_PATTERN.test(creds.entityUid)
|
|
36
|
+
? creds.entityUid
|
|
37
|
+
: undefined;
|
|
38
|
+
const kind = creds?.entityType === "company-outpost" || (delegated && creds === null)
|
|
39
|
+
? "company-outpost"
|
|
40
|
+
: "machine";
|
|
41
|
+
return entityUid ? { kind, entityUid } : { kind };
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The machine-readable code from a 401 body, when it carries one. Reads the
|
|
49
|
+
* REST shape (`{ error, code }`) and the JSON-RPC shapes (`error.code`,
|
|
50
|
+
* `error.data.code`). Only an upper-snake-case code is returned.
|
|
51
|
+
*/
|
|
52
|
+
export function unauthorizedServerCode(body) {
|
|
53
|
+
const record = (value) => value !== null && typeof value === "object" && !Array.isArray(value)
|
|
54
|
+
? value
|
|
55
|
+
: undefined;
|
|
56
|
+
const root = record(body);
|
|
57
|
+
const error = record(root?.error);
|
|
58
|
+
const data = record(error?.data);
|
|
59
|
+
for (const candidate of [root?.code, error?.code, data?.code]) {
|
|
60
|
+
if (typeof candidate === "string" && SERVER_CODE_PATTERN.test(candidate))
|
|
61
|
+
return candidate;
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
function rejectedLine(what, code) {
|
|
66
|
+
return `HQ rejected ${what} (HTTP 401${code ? `, ${code}` : ""}).`;
|
|
67
|
+
}
|
|
68
|
+
/** Message for a 401 a company Outpost job gets. */
|
|
69
|
+
export function companyOutpostUnauthorizedMessage(caller, code) {
|
|
70
|
+
const who = caller.entityUid ? `this company Outpost's identity (${caller.entityUid})` : "this company Outpost's identity";
|
|
71
|
+
return [
|
|
72
|
+
rejectedLine(who, code),
|
|
73
|
+
"This is not a sign-in problem: an Outpost signs in with its own machine credentials, and `hq login` does not apply here.",
|
|
74
|
+
`The job runner gives each run a fresh session through ${DELEGATED_MACHINE_SESSION_ENV}, so re-run the job first.`,
|
|
75
|
+
"If it keeps failing, a company owner or admin runs `hq outposts status --company <company>` and then " +
|
|
76
|
+
"`hq outposts refresh-config --company <company>` from their own machine. If it still fails, report it " +
|
|
77
|
+
`to HQ support${code ? ` with the code ${code}` : ""}.`,
|
|
78
|
+
].join(" ");
|
|
79
|
+
}
|
|
80
|
+
/** Message for a 401 any other machine identity (agent box, external bot) gets. */
|
|
81
|
+
export function machineUnauthorizedMessage(caller, code) {
|
|
82
|
+
const who = caller.entityUid ? `this machine identity (${caller.entityUid})` : "this machine identity";
|
|
83
|
+
return [
|
|
84
|
+
rejectedLine(who, code),
|
|
85
|
+
"It signs in with its machine credentials (HQ_MACHINE_CREDS_FILE), so `hq login` does not apply.",
|
|
86
|
+
"Check that its credentials are current, or ask the operator who provisioned it to re-issue them" +
|
|
87
|
+
`${code ? `, and quote the code ${code}` : ""}.`,
|
|
88
|
+
].join(" ");
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The AuthError for an HTTP 401 from hq-pro. A person keeps the `hq login`
|
|
92
|
+
* message; a company Outpost or other machine identity gets its own recovery
|
|
93
|
+
* and the server's code. Still an AuthError, so the top-level handler prints
|
|
94
|
+
* it and exits non-zero without a Sentry crash report.
|
|
95
|
+
*/
|
|
96
|
+
export function unauthorizedError(opts = {}) {
|
|
97
|
+
const caller = machineAuthCaller(opts.env);
|
|
98
|
+
if (!caller)
|
|
99
|
+
return new AuthError();
|
|
100
|
+
const code = unauthorizedServerCode(opts.body);
|
|
101
|
+
return new AuthError(caller.kind === "company-outpost"
|
|
102
|
+
? companyOutpostUnauthorizedMessage(caller, code)
|
|
103
|
+
: machineUnauthorizedMessage(caller, code));
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=unauthorized-error.js.map
|
package/dist/utils/vault-api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_VAULT_API_URL, cognitoCachePrincipalUid } from './cognito-session.js';
|
|
2
2
|
import { CLI_VERSION } from '../cli-version.js';
|
|
3
|
-
import {
|
|
3
|
+
import { unauthorizedError } from './unauthorized-error.js';
|
|
4
4
|
import { CompanySelectionError } from './company-selection-error.js';
|
|
5
5
|
import { networkTransportErrorCode } from './network-transport-error.js';
|
|
6
6
|
import { markExpectedUserError } from './expected-cli-error.js';
|
|
@@ -413,12 +413,14 @@ export function looksLikePersonVaultUid(ref) {
|
|
|
413
413
|
return ref.startsWith(PERSON_VAULT_UID_PREFIX);
|
|
414
414
|
}
|
|
415
415
|
// A 401 from ANY vault resolution call means the caller's HQ session is
|
|
416
|
-
// expired or
|
|
417
|
-
//
|
|
418
|
-
//
|
|
416
|
+
// expired, missing or rejected — an expected auth state, not a code defect.
|
|
417
|
+
// Raise a typed AuthError so the top-level handler prints an actionable
|
|
418
|
+
// message and skips Sentry capture (HQ-CLI-8). The message fits the caller: a
|
|
419
|
+
// person runs `hq login`; a company Outpost or other machine identity gets its
|
|
420
|
+
// own recovery (feedback_dfc0bb49).
|
|
419
421
|
function raiseIfUnauthorized(res) {
|
|
420
422
|
if (res.status === 401)
|
|
421
|
-
throw
|
|
423
|
+
throw unauthorizedError();
|
|
422
424
|
}
|
|
423
425
|
async function resolveCompanyByUid(token, uid, baseUrl) {
|
|
424
426
|
const res = await vaultApiFetch({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indigoai-us/hq-cli",
|
|
3
|
-
"version": "5.345.
|
|
3
|
+
"version": "5.345.212",
|
|
4
4
|
"description": "HQ by Indigo management CLI — modules and cloud sync",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -117,11 +117,11 @@
|
|
|
117
117
|
"*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}": "eslint --cache --no-error-on-unmatched-pattern"
|
|
118
118
|
},
|
|
119
119
|
"optionalDependencies": {
|
|
120
|
-
"@indigoai-us/hq-hook-win32-x64": "5.345.
|
|
121
|
-
"@indigoai-us/hq-hook-win32-arm64": "5.345.
|
|
122
|
-
"@indigoai-us/hq-hook-darwin-x64": "5.345.
|
|
123
|
-
"@indigoai-us/hq-hook-darwin-arm64": "5.345.
|
|
124
|
-
"@indigoai-us/hq-hook-linux-x64": "5.345.
|
|
125
|
-
"@indigoai-us/hq-hook-linux-arm64": "5.345.
|
|
120
|
+
"@indigoai-us/hq-hook-win32-x64": "5.345.212",
|
|
121
|
+
"@indigoai-us/hq-hook-win32-arm64": "5.345.212",
|
|
122
|
+
"@indigoai-us/hq-hook-darwin-x64": "5.345.212",
|
|
123
|
+
"@indigoai-us/hq-hook-darwin-arm64": "5.345.212",
|
|
124
|
+
"@indigoai-us/hq-hook-linux-x64": "5.345.212",
|
|
125
|
+
"@indigoai-us/hq-hook-linux-arm64": "5.345.212"
|
|
126
126
|
}
|
|
127
127
|
}
|
|
@@ -24,3 +24,20 @@ try {
|
|
|
24
24
|
} catch (error) {
|
|
25
25
|
console.warn(`HQ PowerShell launcher cleanup skipped: ${error instanceof Error ? error.message : String(error)}. If PowerShell blocks hq, run hq.cmd doctor --fix.`);
|
|
26
26
|
}
|
|
27
|
+
// Windows: hq-core's master-hook blocks every tool call when jq is missing
|
|
28
|
+
// (hq-core-staging PR 1882), and nothing installs jq on Windows. Warn only:
|
|
29
|
+
// never install jq here and never fail the install. Keep the hint equal to
|
|
30
|
+
// JQ_WINDOWS_INSTALL_HINT in src/lib/doctor/checks/jq.ts. Self-contained so it
|
|
31
|
+
// still runs when dist is missing.
|
|
32
|
+
try {
|
|
33
|
+
if (process.platform === 'win32') {
|
|
34
|
+
const { join } = await import('node:path');
|
|
35
|
+
const dirs = (process.env.PATH ?? '').split(';').map(dir => dir.trim().replace(/^"(.*)"$/, '$1')).filter(Boolean);
|
|
36
|
+
// Git Bash runs the hooks: it can run jq.exe but not a jq.cmd or jq.bat.
|
|
37
|
+
if (!dirs.some(dir => existsSync(join(dir, 'jq.exe')))) {
|
|
38
|
+
console.warn('jq not found on PATH. Install jq (Windows: winget install jqlang.jq) and open a new terminal; HQ hooks block tool calls until jq is on PATH.');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
} catch {
|
|
42
|
+
// A PATH scan failure must not fail the install.
|
|
43
|
+
}
|