@indigoai-us/hq-cli 5.345.212-beta.0 → 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 +20 -1
- 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/daemon.js +57 -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/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/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/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
package/CHANGELOG.md
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
-
## [5.345.212
|
|
5
|
+
## [5.345.212] — 2026-11-10
|
|
6
6
|
- `hq whoami --company <slug> --json` no longer prints the cached sign-in ID token. Since v5.276.0 the JSON carried it as `planLimits.idToken`, so a hook or agent that captured the output also captured the token. `planLimits` is now `{ status }` or `null`; nothing else in the output changed.
|
|
7
|
+
- Billing copy for usage pricing now quotes the pricing feed. The agent box refusal adds the agent-run price ("plus $0.05 per agent run"). `hq billing status` with no card on usage pricing says HQ asks for a card once usage this month passes the included amount; a member is told to ask an owner or admin to add a card. A usage-pricing company whose box is blocked for lack of a card is told "A card is needed before HQ creates this box." Legacy flat-plan companies see the same text as before. The unused legacy `AGENT_PRICE_CENTS` and `OUTPOST_PRICE_CENTS` constants are removed.
|
|
7
8
|
- Report whether a local bot is ready to chat: `hq bot list --json` and `hq bot status --json` add `readiness` (creating, installing, starting, ready, offline), `ready` and `readyAt`, read from the gateway's `gateway_state.json`, and `hq bot list` shows "starting" until the bot is ready. `hq bot create` reports its four setup steps (as JSON lines with `--json --progress`) and returns at Ready to chat or after `--ready-timeout` seconds (default 300) with a clear message. `hq bot runtime status --json` adds `installed` and the setup estimate ("about 5 minutes" without the runtime, "about a minute" with it). The `hq bot run` heartbeat carries `ready` and `readyAt`. `hq bot runtime install` and the daemon's Fleet bot update read a local release pointer from `HQ_FLEET_RELEASE_POINTER_FILE`, with `file://` asset links, for testing a locally built release.
|
|
8
9
|
- A Fleet bot installed from a prerelease, such as a locally built release, no longer reads back as a legacy bot. Before this fix, hq daemon ran it under the legacy runner, which stopped its gateway seconds into setup, and `hq bot start` registered the runtime's own login item. `hq bot create` now reports a bot whose gateway stopped before it was ready as `offline`. On a Mac with hq daemon, moving a legacy bot to the HQ Fleet Runtime goes through the daemon instead of the runtime's login item.
|
|
9
10
|
- On a Mac with hq daemon, a restarted HQ Fleet bot no longer reads as ready for the seconds before its new gateway writes its own state: the daemon clears the `ready` signal the previous gateway left in `gateway_state.json` before it starts the new gateway.
|
|
@@ -21,6 +22,24 @@
|
|
|
21
22
|
second device-code sign-in, and `hq bot auth --json` prints the device-code line
|
|
22
23
|
when one is still needed. Installed bots move to 0.4.31 at the daemon's next
|
|
23
24
|
update pass.
|
|
25
|
+
- `hq capacity` no longer shows a provider as `ok` when it has no limit rows. After `hq capacity login grok --account <label>`, a Grok billing response the parser could not map (or an HTTP error) was recorded against that account only, so Grok read `ok` with an empty limits table and the error was dropped (feedback_601a961f). A provider or account with no mapped limits now reads `unknown`. Each account carries its newest parse or HTTP error until its next good read clears it, and the provider's last error shows it only for an account that is in the table.
|
|
26
|
+
- Codex: the `hq install --global --runtime codex` entries in `~/.codex/hooks.json` now claim each hook event once, so inside an HQ root the HQ hooks run once per event instead of twice once the hq-core Codex adapter claims too (hq-core-staging companion change). Both registrations stay. Each run claims the event with an atomic directory under `~/.hq/state/codex-hook-claims`, keyed on the real HQ root, the Codex process and the exact payload. The first run does the full work. A second run of the same event within 10 seconds exits 0 with no output. Markers are pruned after 2 minutes. When anything is missing (`HOME`, the hook target, a writable claim directory), the entry runs without claiming, so an event never ends up with no hook. Windows (`commandWindows`) still runs both. Re-run `hq install --global --runtime codex` to update an existing install (feedback_bf4df70e, feedback_d69d01c0).
|
|
27
|
+
- `hq daemon install` now takes over the older Work Mesh unit (`ai.getindigo.hq-mesh-daemon` on macOS, `hq-mesh-daemon.service` or the mesh scheduled task elsewhere) once a running daemon holds its lock. It stops the old unit and moves its definition aside, the same way `hq daemon migrate --apply` does, so the two no longer run side by side. On macOS and Linux the install waits up to 10 seconds for that lock, because launchd and systemd report the unit loaded even when the daemon crash-loops. If no live daemon appears, the old unit keeps running and the install prints a warning. A takeover that fails also leaves the old unit running with a warning. `hq daemon uninstall --restore-legacy` gives the old unit back, and plain `hq daemon uninstall` now says so when it leaves taken-over units behind. A second takeover of the same unit keeps the first saved definition and its single record entry, and moves the new definition to a timestamped file next to it. Other older units are still only listed until `hq daemon migrate --apply` (feedback_c85ad51b).
|
|
28
|
+
- Added (doctor, install): `hq doctor` now checks that jq is on PATH and prints its version, and reports a missing jq as a failure with an install command for the platform. On Windows, `npm install -g @indigoai-us/hq-cli` prints one warning when jq is not on PATH: "Install jq (Windows: winget install jqlang.jq) and open a new terminal; HQ hooks block tool calls until jq is on PATH." The install never fails over it and does not install jq. HQ hooks need jq to parse every hook call.
|
|
29
|
+
- The local flag snapshot can now store the mode strings `"off"`, `"shadow"` and `"on"` for `hook-engine-port-<hook-id>` flags, and the CLI still reads such a snapshot. Before, the writer kept only true and false. This is groundwork with no visible change yet: the flag service and `@indigoai-us/hq-flags-client` 0.2.0 still accept only boolean values, so a mode string cannot arrive until they do. Other flags keep booleans only, and CLI flag checks still see only boolean values.
|
|
30
|
+
- `hq lanes create --account auto` no longer refuses when there is no capacity reading to route on (feedback_9e444a9f, feedback_86552798). With no capacity ledger yet it failed with `capacity_unavailable` ("run hq capacity enable"), and with a fresh ledger that had no reading for any lane account it failed with `no_account_with_room`, while the same command without `--account` worked. In both cases it now chooses the account as if `--account` were omitted and records why in `account_pick`. A refusal still stands when any lane account has a reading that shows it used up, signed out, usage-only or a day old, and the one-time refresh from feedback_94446741 still runs first.
|
|
31
|
+
- A lane waiting on a long nested run no longer looks silent (feedback_86552798). `hq lanes watch`, the command a senior session keeps under Monitor, now prints a line when the lane watcher marks a running lane stalled (with the time and reason), when it starts progressing again, and for each progress event the watcher records, so a run longer than a Monitor window reads as progress or as a plain stall. The lane brief rule that forbids ending a turn while a background process runs now covers subagents and nested runs too: wait for them before writing the envelope, wait in windows shorter than the 30-minute Monitor limit with one progress line per window, and write a blocked envelope naming a nested run that cannot finish.
|
|
32
|
+
- `hq lanes ...` no longer fails with "No registration plan for 'lanes'" when hq-cli updates itself while the command starts (seen on an Outpost moving from 5.345.208 to a release with `hq runners`). The command registration plan now resolves every top-level alias (`lanes`, `master-sync`) to the command it belongs to, and a test checks that every command name and alias in the command catalog has a plan. A "No registration plan" error during command registration is now treated as a torn install: hq waits for the install to settle and re-runs the command once from the updated install, the same recovery used when a module fails to load mid-update, so a root that a newer release removed no longer reaches the user or Sentry as a raw error. Sentry HQ-CLI-GM, feedback 05f34e58.
|
|
33
|
+
- `hq lanes monitor-check` now counts a Monitor armed as `HQ_ROOT=<hq root> hq lanes watch <lane-id>...` (or `hq runners watch`). A senior session whose cwd is a repo outside the HQ tree could not use bare `hq lanes watch`, which cannot find the HQ root from there, and the gate rejected every other command shape, so the Stop hook kept blocking. One leading `HQ_ROOT=` assignment (bare, single- or double-quoted) is accepted. Its value may hold only path characters (letters, digits, `/ . _ - ~`, and spaces inside quotes), so a value with `$`, backticks, `\`, `;`, `|`, `&`, `<`, `>` or `#` is not counted, and any other prefix still is not either. The gate splits words only on spaces and tabs, as a shell does, and does not count a command that contains any character outside printable ASCII and tab (such as a no-break space, vertical tab, form feed, carriage return or an inner newline). The reminder text names the form. (feedback_b6b59676)
|
|
34
|
+
- Work Mesh project decisions now offer only the session's own project. The server lists the company's most active projects with no repo or folder match, so a session with no project context was asked to bind to an unrelated project's stories. Bind options are now limited to the session's bound project, project hint and local project candidates; a session with none gets only "Create new project" and "Leave untracked" (feedback_f81b23c2).
|
|
35
|
+
- `hq onboard resume` no longer accepts an invite that another sign-in left on this machine. A join run now saves its invite token only after the person step, together with the person it was saved for, and marks the checkpoint with a format version. Resume only accepts a token saved for the caller's own person. An unbound token in a current checkpoint is never used. In a checkpoint from an older CLI, an unbound token counts only when its saved person belongs to the caller. Any other saved token is dropped, and resume asks you to run `hq onboard join <token>` with your own invite. A join that stops before the person step leaves the earlier token and its binding unchanged. When the person step replaces the saved person, it drops the saved token in the same write, so the new person's resume never inherits it. A token you pass to `hq onboard join` yourself is still accepted (feedback_a169f6dc, follow-up to the review of #2516).
|
|
36
|
+
- A company Outpost job that gets HTTP 401 from HQ no longer tells it to "Run `hq login`", which an Outpost cannot do. It now says HQ rejected the Outpost's identity, shows the server's code (for example `OUTPOST_PRINCIPAL_INVALID`) and the Outpost uid, and gives the recovery: re-run the job, then a company owner or admin runs `hq outposts status` and `hq outposts refresh-config`. Agent boxes and other machine identities get a matching message that points at their machine credentials. People on a laptop still see the `hq login` message. (feedback_dfc0bb49)
|
|
37
|
+
- `hq integrations reconnect --connection <id>` re-keys the connection you
|
|
38
|
+
named, for a pasted key and for a browser sign-in. A legacy shared
|
|
39
|
+
connection reconnects as a company connection, so a new key no longer lands
|
|
40
|
+
on a personal connection while the shared one stays expired. Full pinning to
|
|
41
|
+
the named connection needs hq-pro #5460; older servers still place a legacy
|
|
42
|
+
row by company scope. (feedback_a79e0c89)
|
|
24
43
|
|
|
25
44
|
## [5.345.211] — 2026-11-10
|
|
26
45
|
- `hq integrations connect` now cleans a pasted API key before sending it: it trims the ends and joins a key wrapped across lines. A key with a smart quote or another character that can't be sent stops with a plain message instead of failing on the server.
|
|
@@ -590,5 +590,20 @@ export declare const REGISTRATION_PLAN: readonly [{
|
|
|
590
590
|
readonly exportName: "registerListingsCommand";
|
|
591
591
|
}];
|
|
592
592
|
export declare function registerAllCommands(program: Command): Promise<void>;
|
|
593
|
+
/**
|
|
594
|
+
* Every top-level alias in the generated command catalog, mapped to the plan
|
|
595
|
+
* root that registers it. registerCommandRoot resolves through this map so a
|
|
596
|
+
* caller that passes an alias still finds the plan.
|
|
597
|
+
*
|
|
598
|
+
* This matters when an install is replaced while `hq` starts (self-update on an
|
|
599
|
+
* Outpost): the running process has already loaded the OLD command catalog, so
|
|
600
|
+
* its lazy loader asks for the old root name, but this module is imported from
|
|
601
|
+
* the NEW tree. When a root is renamed and its old name kept as an alias (hq
|
|
602
|
+
* lanes -> hq runners, hq-cli #2490), the old name must still reach the new
|
|
603
|
+
* plan (Sentry HQ-CLI-GM). The map lives here, not in the catalog, because the
|
|
604
|
+
* catalog module is already cached from the old tree in that case.
|
|
605
|
+
* lazy-registration-parity.test.ts keeps this map equal to the catalog.
|
|
606
|
+
*/
|
|
607
|
+
export declare const ROOT_ALIASES: ReadonlyMap<string, string>;
|
|
593
608
|
export declare function registerCommandRoot(program: Command, root: string): Promise<boolean>;
|
|
594
609
|
//# sourceMappingURL=command-registration-plan.d.ts.map
|
|
@@ -147,8 +147,27 @@ async function executePlan(program, steps) {
|
|
|
147
147
|
export async function registerAllCommands(program) {
|
|
148
148
|
await executePlan(program, REGISTRATION_PLAN);
|
|
149
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Every top-level alias in the generated command catalog, mapped to the plan
|
|
152
|
+
* root that registers it. registerCommandRoot resolves through this map so a
|
|
153
|
+
* caller that passes an alias still finds the plan.
|
|
154
|
+
*
|
|
155
|
+
* This matters when an install is replaced while `hq` starts (self-update on an
|
|
156
|
+
* Outpost): the running process has already loaded the OLD command catalog, so
|
|
157
|
+
* its lazy loader asks for the old root name, but this module is imported from
|
|
158
|
+
* the NEW tree. When a root is renamed and its old name kept as an alias (hq
|
|
159
|
+
* lanes -> hq runners, hq-cli #2490), the old name must still reach the new
|
|
160
|
+
* plan (Sentry HQ-CLI-GM). The map lives here, not in the catalog, because the
|
|
161
|
+
* catalog module is already cached from the old tree in that case.
|
|
162
|
+
* lazy-registration-parity.test.ts keeps this map equal to the catalog.
|
|
163
|
+
*/
|
|
164
|
+
export const ROOT_ALIASES = new Map([
|
|
165
|
+
["master-sync", "reindex"],
|
|
166
|
+
["lanes", "runners"],
|
|
167
|
+
]);
|
|
150
168
|
export async function registerCommandRoot(program, root) {
|
|
151
|
-
const
|
|
169
|
+
const planRoot = ROOT_ALIASES.get(root) ?? root;
|
|
170
|
+
const steps = REGISTRATION_PLAN.filter((step) => step.root === planRoot);
|
|
152
171
|
if (steps.length === 0)
|
|
153
172
|
return false;
|
|
154
173
|
await executePlan(program, steps);
|
package/dist/commands/agents.js
CHANGED
|
@@ -1694,7 +1694,12 @@ export function registerAgentsCommand(program) {
|
|
|
1694
1694
|
if (err instanceof AgentsHttpError &&
|
|
1695
1695
|
err.status === 402 &&
|
|
1696
1696
|
err.billing) {
|
|
1697
|
-
|
|
1697
|
+
// US-034: the plan picks the sentence. Asked after the link is
|
|
1698
|
+
// minted and bounded like the 403 path: at most 3 s, then legacy copy.
|
|
1699
|
+
await surfaceBillingBlocked(token, err.billing, err.message, async () => isUsageOnly(await fetchCompanyPricingPlan(token, companyUid, {
|
|
1700
|
+
timeoutMs: 2000,
|
|
1701
|
+
deadlineMs: 3000,
|
|
1702
|
+
}).catch(() => null)));
|
|
1698
1703
|
process.exit(1);
|
|
1699
1704
|
}
|
|
1700
1705
|
throw err;
|
package/dist/commands/billing.js
CHANGED
|
@@ -31,7 +31,7 @@ import { mintPaymentLink } from "../utils/billing-gate.js";
|
|
|
31
31
|
import { openUsageSwitch } from "../utils/team-upgrade.js";
|
|
32
32
|
import { registerBillingSponsorCommands } from "./billing-sponsor.js";
|
|
33
33
|
import { fetchCompanyPricingPlan, isUsageOnly, pricingPlanFromBody, readBillingState, usageOnlyUpgradeLines, } from "../lib/billing/usage-only.js";
|
|
34
|
-
import { fetchUsageCard } from "../lib/billing/usage-card.js";
|
|
34
|
+
import { fetchUsageCard, formatCardUsd } from "../lib/billing/usage-card.js";
|
|
35
35
|
import { accountStatusLines } from "../lib/billing/billing-status-lines.js";
|
|
36
36
|
import { registerBillingUsageCommand } from "./billing-usage.js";
|
|
37
37
|
const CHARGED_ON = {
|
|
@@ -202,18 +202,31 @@ export function registerBillingCommand(program) {
|
|
|
202
202
|
(scheduled.phase === "preview" ? " (preview window open)." : "."));
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
+
const state = readBillingState(summary);
|
|
206
|
+
const onUsage = !!state && (state.kind === "usage" || state.kind === "usage-trial");
|
|
207
|
+
const card = onUsage ? (await fetchUsageCard()).card : null;
|
|
205
208
|
const pm = summary.defaultPaymentMethod;
|
|
206
209
|
if (pm?.present) {
|
|
207
210
|
const detail = pm.brand && pm.last4 ? `${pm.brand} ••••${pm.last4}` : "on file";
|
|
208
211
|
console.log(`${chalk.bold("Card")}: ${detail}`);
|
|
209
212
|
}
|
|
213
|
+
else if (state && card && state.view !== "full") {
|
|
214
|
+
// US-034: a member cannot add the company card (hq-pro's org card
|
|
215
|
+
// capture is owner or admin only), and the member view carries no
|
|
216
|
+
// money figures.
|
|
217
|
+
console.log(`${chalk.bold("Card")}: ${chalk.yellow("no card on file")} — ask an owner or admin to add a card.`);
|
|
218
|
+
}
|
|
219
|
+
else if (state && card) {
|
|
220
|
+
// US-034: usage pricing asks for a card past the included usage.
|
|
221
|
+
console.log(`${chalk.bold("Card")}: ${chalk.yellow("no card on file")} — ` +
|
|
222
|
+
`HQ asks for a card once usage this month passes ${formatCardUsd(card.includedUsd)}. ` +
|
|
223
|
+
"Hosted boxes bill to a card; add one with `hq billing checkout`.");
|
|
224
|
+
}
|
|
210
225
|
else {
|
|
211
226
|
console.log(`${chalk.bold("Card")}: ${chalk.yellow("no card on file")} — ` +
|
|
212
227
|
`run \`hq billing checkout\` to add one before provisioning paid resources.`);
|
|
213
228
|
}
|
|
214
|
-
|
|
215
|
-
if (state && (state.kind === "usage" || state.kind === "usage-trial")) {
|
|
216
|
-
const { card } = await fetchUsageCard();
|
|
229
|
+
if (state && card) {
|
|
217
230
|
for (const line of accountStatusLines(state, card))
|
|
218
231
|
console.log(line);
|
|
219
232
|
}
|
package/dist/commands/daemon.js
CHANGED
|
@@ -25,7 +25,7 @@ import { DEFAULT_SERVICES, SERVICE_DESCRIPTIONS, enabledServices, hqCloudUnits }
|
|
|
25
25
|
import { applyServiceToggle, effectiveSyncOwner, readDaemonConfig, writeDaemonConfig } from "../lib/daemon/config.js";
|
|
26
26
|
import { daemonUnitInstalled } from "../lib/daemon/handoff.js";
|
|
27
27
|
import { adoptLegacyUnits, readAdoptedUnits, restoreLegacyUnits } from "../lib/daemon/migrate.js";
|
|
28
|
-
import { ROOT_REFUSAL, SYSTEM_UNIT_DIR, WINDOWS_START_WAIT_MS, daemonRootRefusal, installDaemonUnit, installScopeFor, classifyWindowsTask, daemonServiceStatus, describeSupervision, legacyWindowsTask, startDaemonUnit, readWindowsSid, uninstallDaemonUnit, windowsInteractiveSession, windowsTaskName, } from "../lib/daemon/install.js";
|
|
28
|
+
import { DAEMON_ALIVE_WAIT_MS, ROOT_REFUSAL, SYSTEM_UNIT_DIR, WINDOWS_START_WAIT_MS, waitForLiveDaemon, daemonRootRefusal, installDaemonUnit, installScopeFor, classifyWindowsTask, daemonServiceStatus, describeSupervision, legacyWindowsTask, startDaemonUnit, readWindowsSid, uninstallDaemonUnit, windowsInteractiveSession, windowsTaskName, } from "../lib/daemon/install.js";
|
|
29
29
|
import { PLIST_REFRESH_MARKER } from "../lib/daemon/plist-refresh.js";
|
|
30
30
|
import { describeLegacyUnit, findLegacyUnits } from "../lib/daemon/legacy.js";
|
|
31
31
|
import { isDaemonProcess, liveDaemonLock, runningDaemonPid } from "../lib/daemon/lock.js";
|
|
@@ -300,9 +300,16 @@ async function runInstall(d, opts) {
|
|
|
300
300
|
for (const line of describeServices(detected.type, config))
|
|
301
301
|
d.out(line);
|
|
302
302
|
const migratable = d.legacyUnits().filter((u) => u.migratable);
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
303
|
+
// The older Work Mesh unit is taken over by the install itself once the
|
|
304
|
+
// daemon is running (feedback_c85ad51b): left alone, it kept running beside
|
|
305
|
+
// the daemon until someone ran `hq daemon migrate --apply` by hand.
|
|
306
|
+
const meshTakeover = scope === "user" && enabledServices(detected.type, config).includes("mesh")
|
|
307
|
+
? migratable.filter((u) => u.service === "mesh" && u.kind !== "systemd-system")
|
|
308
|
+
: [];
|
|
309
|
+
const noteLegacy = (u) => d.out(`Note: ${describeLegacyUnit(u)} still runs ${u.unitId}. The daemon leaves it alone until \`hq daemon migrate\` takes it over.`);
|
|
310
|
+
for (const u of migratable)
|
|
311
|
+
if (!meshTakeover.includes(u))
|
|
312
|
+
noteLegacy(u);
|
|
306
313
|
// A box worked out from its runner unit, --user or sudo gets the marker file
|
|
307
314
|
// provisioning would have written: `migrate --apply` moves the runner unit
|
|
308
315
|
// aside, and later root commands (uninstall) must still find the box's type
|
|
@@ -311,10 +318,13 @@ async function runInstall(d, opts) {
|
|
|
311
318
|
d.writeFile(MACHINE_TYPE_MARKER_PATH, `type=${detected.type}\nuser=${runAsUser}\n`);
|
|
312
319
|
}
|
|
313
320
|
const runAsHome = runAsUser ? d.userHome(runAsUser) : undefined;
|
|
321
|
+
const runningDaemon = () => liveDaemonLock(paths.lockPath, d.daemonAlive);
|
|
322
|
+
// The daemon from before this install, so the takeover can tell it from a new one.
|
|
323
|
+
const daemonBefore = meshTakeover.length > 0 ? runningDaemon() : null;
|
|
314
324
|
const result = installDaemonUnit(hostFor(d, paths, scope === "user"), { scope, runAsUser, runAsHome }, {
|
|
315
325
|
run: d.run,
|
|
316
326
|
sleep: d.sleep,
|
|
317
|
-
runningDaemon
|
|
327
|
+
runningDaemon,
|
|
318
328
|
});
|
|
319
329
|
handOver(d, { paths, detected, runAsUser });
|
|
320
330
|
if (result.notice)
|
|
@@ -323,6 +333,7 @@ async function runInstall(d, opts) {
|
|
|
323
333
|
d.err(result.warning);
|
|
324
334
|
if (result.kind === "manual") {
|
|
325
335
|
d.out(`This platform has no supported service manager. Start the daemon yourself with:\n ${result.manualCommand}`);
|
|
336
|
+
meshTakeover.forEach(noteLegacy);
|
|
326
337
|
return;
|
|
327
338
|
}
|
|
328
339
|
if (result.startPending) {
|
|
@@ -338,6 +349,7 @@ async function runInstall(d, opts) {
|
|
|
338
349
|
}
|
|
339
350
|
d.out("The daemon starts at your next sign-in to Windows. It is not running yet.");
|
|
340
351
|
d.out("Check it with: hq daemon status");
|
|
352
|
+
meshTakeover.forEach(noteLegacy);
|
|
341
353
|
return;
|
|
342
354
|
}
|
|
343
355
|
const seconds = WINDOWS_START_WAIT_MS / 1000;
|
|
@@ -353,6 +365,39 @@ async function runInstall(d, opts) {
|
|
|
353
365
|
throw new DaemonCommandError(`Installed ${result.unitPath}, but it did not start: ${result.error ?? "unknown error"}`);
|
|
354
366
|
}
|
|
355
367
|
d.out(`Installed and started: ${result.unitPath}`);
|
|
368
|
+
if (meshTakeover.length === 0)
|
|
369
|
+
return;
|
|
370
|
+
// launchd and systemd report "loaded" even when the daemon exits at once and
|
|
371
|
+
// crash-loops, so wait (bounded) for a live daemon to hold the lock before
|
|
372
|
+
// stopping the working mesh agent. schtasks already waited for that above.
|
|
373
|
+
const live = result.kind === "schtasks" ? runningDaemon() : waitForLiveDaemon(runningDaemon, daemonBefore, d.sleep);
|
|
374
|
+
if (!live) {
|
|
375
|
+
const seconds = DAEMON_ALIVE_WAIT_MS / 1000;
|
|
376
|
+
for (const u of meshTakeover) {
|
|
377
|
+
d.err(`warning: the daemon's service is loaded, but no running daemon held its lock within ${seconds} seconds, ` +
|
|
378
|
+
`so ${describeLegacyUnit(u)} keeps running ${u.unitId}. Check \`hq daemon status\` and \`hq daemon logs\`, then run \`hq daemon migrate --apply\`.`);
|
|
379
|
+
}
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
takeOverLegacyMesh(d, paths, meshTakeover);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Stop the older Work Mesh unit and move its definition aside now that the
|
|
386
|
+
* daemon runs mesh, the same takeover `hq daemon migrate --apply` does (so
|
|
387
|
+
* `hq daemon uninstall --restore-legacy` gives it back). A failed takeover
|
|
388
|
+
* leaves the old unit running as before and does not fail the install.
|
|
389
|
+
*/
|
|
390
|
+
function takeOverLegacyMesh(d, paths, units) {
|
|
391
|
+
const result = adoptLegacyUnits(units, { ...migrateDeps(d, paths), sleep: d.sleep });
|
|
392
|
+
for (const a of result.adopted)
|
|
393
|
+
d.out(`Took over ${a.unitId} from ${describeLegacyUnit(a)}; the daemon starts it within a minute.`);
|
|
394
|
+
for (const s of result.skipped)
|
|
395
|
+
d.out(`Left ${s.unit.unitId} to ${describeLegacyUnit(s.unit)}: ${s.reason}`);
|
|
396
|
+
for (const f of result.failed) {
|
|
397
|
+
d.err(`warning: could not take over ${f.unit.unitId} from ${describeLegacyUnit(f.unit)}: ${f.error}. It keeps running; retry with \`hq daemon migrate --apply\`.`);
|
|
398
|
+
}
|
|
399
|
+
if (result.adopted.length > 0)
|
|
400
|
+
d.out("`hq daemon uninstall --restore-legacy` puts the old unit back.");
|
|
356
401
|
}
|
|
357
402
|
/** Root acting for a box's login user needs that user's uid to reach their systemd manager. */
|
|
358
403
|
function loginUid(d, user) {
|
|
@@ -416,6 +461,13 @@ async function runUninstall(d, opts) {
|
|
|
416
461
|
throw new DaemonCommandError(`Some units were not restored; they are still listed in ${migrate.recordPath}.`);
|
|
417
462
|
}
|
|
418
463
|
}
|
|
464
|
+
if (!opts.restoreLegacy && adopted.length > 0) {
|
|
465
|
+
// `hq daemon install` takes over the older mesh unit by itself, so users
|
|
466
|
+
// reach this state without ever running migrate. Nothing runs those
|
|
467
|
+
// services once the daemon is gone; say how to give them back.
|
|
468
|
+
d.out(`hq daemon had taken over ${adopted.map((u) => u.unitId).join(", ")}; nothing runs ${adopted.length === 1 ? "it" : "them"} now. ` +
|
|
469
|
+
"Run `hq daemon uninstall --restore-legacy` to give the older units back.");
|
|
470
|
+
}
|
|
419
471
|
if (opts.purge) {
|
|
420
472
|
fs.rmSync(paths.root, { recursive: true, force: true });
|
|
421
473
|
d.out(`Deleted ${paths.root}`);
|
package/dist/commands/files.js
CHANGED
|
@@ -7,7 +7,7 @@ import { gateApiKeyCapabilities } from "../utils/api-key-command-gate.js";
|
|
|
7
7
|
import { vaultApiFetch, getCompanyUid } from "./secrets.js";
|
|
8
8
|
import { GROUP_ID_PATTERN, EMAIL_PATTERN, isPrivateFolderPattern, normalizeFilePrefix, OUTPOST_UID_PATTERN, toSharedFolderGlob, } from "./_patterns.js";
|
|
9
9
|
import { looksLikeCompanyUid } from "../utils/vault-api.js";
|
|
10
|
-
import {
|
|
10
|
+
import { unauthorizedError } from "../utils/unauthorized-error.js";
|
|
11
11
|
import { formatAccessDenied, offerAccessLadder, } from "../utils/access-denied-hint.js";
|
|
12
12
|
import { fetchChannels, matchChannelsByName } from "./dm.js";
|
|
13
13
|
import { suggestChannels, withChannelSuggestions } from "./channel-suggest.js";
|
|
@@ -1496,7 +1496,7 @@ async function resolveCompanyUidForAnchoredPath(token, opts) {
|
|
|
1496
1496
|
signal: AbortSignal.timeout(15_000),
|
|
1497
1497
|
});
|
|
1498
1498
|
if (response.status === 401)
|
|
1499
|
-
throw
|
|
1499
|
+
throw unauthorizedError();
|
|
1500
1500
|
if (!response.ok) {
|
|
1501
1501
|
throw new Error(`Failed to resolve company '${opts.explicit}' (HTTP ${response.status})`);
|
|
1502
1502
|
}
|
|
@@ -162,6 +162,12 @@ export interface InstallInput {
|
|
|
162
162
|
header: string;
|
|
163
163
|
};
|
|
164
164
|
scope?: ConnectScope;
|
|
165
|
+
/**
|
|
166
|
+
* Reconnect: re-key exactly this existing connection and keep its owner.
|
|
167
|
+
* Without it hq-pro places the install by `scope`, which sent a legacy
|
|
168
|
+
* shared connection's new key to a personal row (feedback_a79e0c89).
|
|
169
|
+
*/
|
|
170
|
+
connectionId?: string;
|
|
165
171
|
}
|
|
166
172
|
export type ConnectScope = "personal" | "company";
|
|
167
173
|
export declare function scopeUnavailableMessage(scope: ConnectScope): string;
|
|
@@ -231,6 +237,11 @@ export interface OAuthStartInput {
|
|
|
231
237
|
*/
|
|
232
238
|
scopes?: string[];
|
|
233
239
|
scope?: ConnectScope;
|
|
240
|
+
/**
|
|
241
|
+
* Reconnect: sign in for exactly this existing connection and keep its
|
|
242
|
+
* owner, as on install (feedback_a79e0c89).
|
|
243
|
+
*/
|
|
244
|
+
connectionId?: string;
|
|
234
245
|
}
|
|
235
246
|
export declare function startOAuth(token: string, companyUid: string, input: OAuthStartInput): Promise<OAuthStartResult>;
|
|
236
247
|
export declare function completeOAuth(token: string, companyUid: string, input: {
|
|
@@ -93,6 +93,8 @@ interface ConnectTarget {
|
|
|
93
93
|
authClass?: "none" | "key" | "oauth";
|
|
94
94
|
/** Human label for prompts and success lines. */
|
|
95
95
|
label: string;
|
|
96
|
+
/** Reconnect only: the existing connection the install must re-key. */
|
|
97
|
+
connectionId?: string;
|
|
96
98
|
}
|
|
97
99
|
/**
|
|
98
100
|
* Run the browser sign-in and finish the install.
|
|
@@ -350,6 +350,13 @@ async function resolveKey(opts, appLabel) {
|
|
|
350
350
|
}
|
|
351
351
|
throw new IntegrationsCliError(`${appLabel} needs an API key. Pass it with --token-stdin (recommended, keeps it out of shell history) or --token <key>.`, { expected: true });
|
|
352
352
|
}
|
|
353
|
+
/**
|
|
354
|
+
* Install or OAuth-start fields for a target, pinned to the reconnected
|
|
355
|
+
* connection when set, so a browser reconnect re-keys that row too.
|
|
356
|
+
*/
|
|
357
|
+
function installRefOf(target) {
|
|
358
|
+
return target.connectionId ? { ...target.ref, connectionId: target.connectionId } : target.ref;
|
|
359
|
+
}
|
|
353
360
|
/**
|
|
354
361
|
* Remote MCP endpoints the integrations.sh catalog lists as MCP without a URL.
|
|
355
362
|
*
|
|
@@ -623,7 +630,7 @@ async function connectViaOAuth(token, companyUid, target, opts) {
|
|
|
623
630
|
}
|
|
624
631
|
const requestedScopes = parseRequestedScopes(opts.scopes);
|
|
625
632
|
const startInput = {
|
|
626
|
-
...target
|
|
633
|
+
...installRefOf(target),
|
|
627
634
|
...(requestedScopes ? { scopes: requestedScopes } : {}),
|
|
628
635
|
};
|
|
629
636
|
const userClient = await resolveUserOAuthClient(opts, target.label);
|
|
@@ -1021,7 +1028,7 @@ async function linkOnlySignIn(token, companyUid, target, opts, startInput) {
|
|
|
1021
1028
|
*/
|
|
1022
1029
|
async function userClientSignIn(token, companyUid, target, opts, client, requestedScopes) {
|
|
1023
1030
|
const started = await startOAuth(token, companyUid, {
|
|
1024
|
-
...target
|
|
1031
|
+
...installRefOf(target),
|
|
1025
1032
|
clientId: client.clientId,
|
|
1026
1033
|
...(client.clientSecret ? { clientSecret: client.clientSecret } : {}),
|
|
1027
1034
|
// A caller who registered the app themselves is the one who knows which
|
|
@@ -1083,7 +1090,7 @@ async function completeCredentialIfNeeded(token, companyUid, target, opts, resul
|
|
|
1083
1090
|
console.error(chalk.dim(`${target.label} needs an API key to finish connecting.`));
|
|
1084
1091
|
const bearerToken = await resolveKey(opts, target.label);
|
|
1085
1092
|
return await installIntegration(token, companyUid, {
|
|
1086
|
-
...target
|
|
1093
|
+
...installRefOf(target),
|
|
1087
1094
|
authMode: "bearer",
|
|
1088
1095
|
bearerToken,
|
|
1089
1096
|
});
|
|
@@ -1650,7 +1657,11 @@ export function registerConnectCommands(integrations) {
|
|
|
1650
1657
|
...(connection.installation?.displayName
|
|
1651
1658
|
? { displayName: connection.installation.displayName }
|
|
1652
1659
|
: {}),
|
|
1653
|
-
|
|
1660
|
+
// A legacy row is a shared one (hq-pro reports a creator-only
|
|
1661
|
+
// legacy row as person-owned), so it reconnects as a company
|
|
1662
|
+
// connection. Sending no scope defaulted to personal and wrote the
|
|
1663
|
+
// new key to a personal row (feedback_a79e0c89).
|
|
1664
|
+
...(connection.ownerType === "company" || connection.ownerType === "legacy"
|
|
1654
1665
|
? { scope: "company" }
|
|
1655
1666
|
: connection.ownerType === "person"
|
|
1656
1667
|
? { scope: "personal" }
|
|
@@ -1658,6 +1669,7 @@ export function registerConnectCommands(integrations) {
|
|
|
1658
1669
|
},
|
|
1659
1670
|
...(opts.auth ? { authClass: opts.auth } : {}),
|
|
1660
1671
|
label: connection.installation?.displayName ?? bareProvider(connection.provider),
|
|
1672
|
+
connectionId: connection.id,
|
|
1661
1673
|
};
|
|
1662
1674
|
// Same gate `connectApp` applies. This path does not go through it —
|
|
1663
1675
|
// it resolves the endpoint off the existing connection and branches
|
|
@@ -1677,7 +1689,7 @@ export function registerConnectCommands(integrations) {
|
|
|
1677
1689
|
const bearerToken = wantsKey ? await resolveKey(opts, target.label) : undefined;
|
|
1678
1690
|
try {
|
|
1679
1691
|
const result = await installIntegration(token, companyUid, {
|
|
1680
|
-
...target
|
|
1692
|
+
...installRefOf(target),
|
|
1681
1693
|
...(bearerToken ? { authMode: "bearer", bearerToken } : {}),
|
|
1682
1694
|
});
|
|
1683
1695
|
reportInstall(await completeCredentialIfNeeded(token, companyUid, target, opts, result), opts);
|
|
@@ -230,7 +230,7 @@ export declare function upstreamUnavailableMessage(status: number): string;
|
|
|
230
230
|
* status-specific message and `expected` classification unchanged.
|
|
231
231
|
*/
|
|
232
232
|
export declare function raiseIfUpstreamUnavailable(res: Response): void;
|
|
233
|
-
export declare function raiseIfUnauthorized(res: Response): void;
|
|
233
|
+
export declare function raiseIfUnauthorized(res: Response, body?: unknown): void;
|
|
234
234
|
/**
|
|
235
235
|
* A member connected, reinstalled, or signed in to an app that someone else
|
|
236
236
|
* already connected for the company. Members may add apps and reconnect their
|
|
@@ -13,7 +13,7 @@ import { delegatedMachineSessionFilePath, loadDelegatedMachineSession, getValidM
|
|
|
13
13
|
import { DEFAULT_COGNITO, ensureCognitoIdToken } from "../utils/cognito-session.js";
|
|
14
14
|
import chalk from "chalk";
|
|
15
15
|
import { vaultApiFetch } from "../utils/vault-api.js";
|
|
16
|
-
import {
|
|
16
|
+
import { unauthorizedError } from "../utils/unauthorized-error.js";
|
|
17
17
|
import { planGateErrorFromPayload } from "../utils/plan-gate-error.js";
|
|
18
18
|
import { redactErrorText } from "../utils/redact-error-text.js";
|
|
19
19
|
import { redactSensitiveUrls, redactUrlsInText } from "../utils/redact-url.js";
|
|
@@ -286,16 +286,21 @@ function gatewayErrorDetails(error) {
|
|
|
286
286
|
return { message, ...(rpcCode === undefined ? {} : { rpcCode }), shape };
|
|
287
287
|
}
|
|
288
288
|
// A 401 from ANY integration-gateway vault call means the caller's HQ session
|
|
289
|
-
// is expired or
|
|
290
|
-
//
|
|
291
|
-
//
|
|
292
|
-
//
|
|
289
|
+
// is expired, missing or rejected — an expected auth state, not an hq-cli
|
|
290
|
+
// defect. Raise the same typed AuthError the vault company-resolution paths
|
|
291
|
+
// use (HQ-CLI-8) so the top-level handler prints one actionable message and
|
|
292
|
+
// skips Sentry, instead of surfacing the opaque, unactionable
|
|
293
293
|
// "Integration gateway request failed (HTTP 401)" that shipped as a fatal from
|
|
294
294
|
// `callGateway` (HQ-CLI-9). Non-401 statuses keep their existing behavior:
|
|
295
295
|
// other 4xx stay expected client errors, 5xx still report.
|
|
296
|
-
|
|
296
|
+
//
|
|
297
|
+
// The message fits the caller (feedback_dfc0bb49): a person runs `hq login`,
|
|
298
|
+
// but a company Outpost job has no login to run, so it is told the server
|
|
299
|
+
// rejected the Outpost identity, with the server's code from `body` when the
|
|
300
|
+
// response carried one (OUTPOST_PRINCIPAL_INVALID), and the Outpost recovery.
|
|
301
|
+
export function raiseIfUnauthorized(res, body) {
|
|
297
302
|
if (res.status === 401)
|
|
298
|
-
throw
|
|
303
|
+
throw unauthorizedError({ body });
|
|
299
304
|
}
|
|
300
305
|
/**
|
|
301
306
|
* A member connected, reinstalled, or signed in to an app that someone else
|
|
@@ -322,7 +327,10 @@ const CLI_ERROR_MESSAGES = new Map([
|
|
|
322
327
|
* one route cannot quietly drift into reporting its 4xx as crashes.
|
|
323
328
|
*/
|
|
324
329
|
export async function raiseForResponse(res, fallback) {
|
|
325
|
-
|
|
330
|
+
// Read the 401 body for its server code (feedback_dfc0bb49); no other
|
|
331
|
+
// status reads the body before the guards below.
|
|
332
|
+
if (res.status === 401)
|
|
333
|
+
raiseIfUnauthorized(res, await res.json().catch(() => undefined));
|
|
326
334
|
raiseIfUpstreamUnavailable(res);
|
|
327
335
|
const body = (await res.json().catch(() => ({})));
|
|
328
336
|
// A plan-limit 402 is normally decoded by vaultApiFetch before it gets here.
|
|
@@ -704,7 +712,7 @@ export async function callGateway(token, params, idempotencyKey, method = "tools
|
|
|
704
712
|
terminalStatus = terminal.status;
|
|
705
713
|
}
|
|
706
714
|
if (res.status !== 202 && (!res.ok || !terminalMessage)) {
|
|
707
|
-
raiseIfUnauthorized(res);
|
|
715
|
+
raiseIfUnauthorized(res, message);
|
|
708
716
|
if (method === "tools/call" &&
|
|
709
717
|
params.acceptAsync === true &&
|
|
710
718
|
isInlineTimeoutStatus(res.status)) {
|
|
@@ -787,7 +795,7 @@ async function pollAsyncGatewayJob(token, companyUid, jobId, idempotencyKey, dea
|
|
|
787
795
|
clearTimeout(requestTimeout);
|
|
788
796
|
}
|
|
789
797
|
if (!res.ok) {
|
|
790
|
-
raiseIfUnauthorized(res);
|
|
798
|
+
raiseIfUnauthorized(res, poll);
|
|
791
799
|
raiseIfUpstreamUnavailable(res);
|
|
792
800
|
if (res.status === 404) {
|
|
793
801
|
throw new IntegrationsCliError(`Integration job ${jobId} was not found or is no longer available.`, { expected: true, status: 404 });
|
|
@@ -616,7 +616,7 @@ export function registerIntegrationsCommand(program) {
|
|
|
616
616
|
});
|
|
617
617
|
const body = (await res.json().catch(() => ({})));
|
|
618
618
|
if (!res.ok) {
|
|
619
|
-
raiseIfUnauthorized(res);
|
|
619
|
+
raiseIfUnauthorized(res, body);
|
|
620
620
|
raiseIfUpstreamUnavailable(res);
|
|
621
621
|
throw new IntegrationsCliError(body.error ?? `${decision} failed (HTTP ${res.status})`, { expected: isClientError(res.status) });
|
|
622
622
|
}
|
package/dist/commands/lanes.js
CHANGED
|
@@ -94,8 +94,8 @@ import { writeQuestionBody } from "../lib/lanes/questions.js";
|
|
|
94
94
|
import { compactionAfterUsage, } from "../lib/lanes/compaction.js";
|
|
95
95
|
import { parseCliEffort, resolveLaneEffort, } from "../lib/lanes/effort.js";
|
|
96
96
|
import { LanesError } from "../lib/lanes/errors.js";
|
|
97
|
-
import { LedgerCorrupt, capacityOptionsFromEnv, readCollectorMark, readNow, rebuildNow, } from "../lib/capacity/ledger.js";
|
|
98
|
-
import { pickAccount, refusalHasStaleReading, staleReadingTargets, } from "../lib/capacity/route.js";
|
|
97
|
+
import { LedgerCorrupt, LedgerMissing, capacityOptionsFromEnv, readCollectorMark, readNow, rebuildNow, } from "../lib/capacity/ledger.js";
|
|
98
|
+
import { pickAccount, refusalHasNoReadings, refusalHasStaleReading, staleReadingTargets, UNKNOWN_USAGE_SCORE, } from "../lib/capacity/route.js";
|
|
99
99
|
import { capacityViewAge } from "../lib/capacity/freshness.js";
|
|
100
100
|
import { applyTerminalToLane, classifyLaneExit, readLatestEnvelopeRecord } from "../lib/lanes/watcher.js";
|
|
101
101
|
import { isSubagentLane, parseLaneEnvelope, parseLaneRunner } from "../lib/lanes/types.js";
|
|
@@ -3596,7 +3596,20 @@ async function runCreate(ctx, opts) {
|
|
|
3596
3596
|
let autoChosenAccount;
|
|
3597
3597
|
if (opts.account !== undefined && opts.account.trim() === "auto") {
|
|
3598
3598
|
const ledgerOptions = capacityOptionsFromEnv(ctx.env);
|
|
3599
|
-
|
|
3599
|
+
// feedback_9e444a9f / feedback_86552798: with no ledger yet (capacity was
|
|
3600
|
+
// never enabled), or a ledger with no reading for any lane account, there
|
|
3601
|
+
// is no evidence any account is full. Route as if the flag were omitted
|
|
3602
|
+
// (balanced admission over the enabled lane accounts) instead of refusing
|
|
3603
|
+
// with capacity_unavailable or no_account_with_room.
|
|
3604
|
+
const noReadingsFallback = () => {
|
|
3605
|
+
autoAccountPick = {
|
|
3606
|
+
why: "no capacity reading for any lane account yet, so the account is chosen as if --account were omitted",
|
|
3607
|
+
headroom: 0,
|
|
3608
|
+
score: UNKNOWN_USAGE_SCORE,
|
|
3609
|
+
};
|
|
3610
|
+
opts = { ...opts, account: undefined };
|
|
3611
|
+
};
|
|
3612
|
+
let view = null;
|
|
3600
3613
|
try {
|
|
3601
3614
|
view = readNow(ledgerOptions);
|
|
3602
3615
|
}
|
|
@@ -3604,7 +3617,7 @@ async function runCreate(ctx, opts) {
|
|
|
3604
3617
|
if (err instanceof LedgerCorrupt) {
|
|
3605
3618
|
view = rebuildNow(ledgerOptions);
|
|
3606
3619
|
}
|
|
3607
|
-
else {
|
|
3620
|
+
else if (!(err instanceof LedgerMissing)) {
|
|
3608
3621
|
throw new LanesError("capacity_unavailable", `Cannot route --account auto: ${err instanceof Error ? err.message : String(err)}`, {});
|
|
3609
3622
|
}
|
|
3610
3623
|
}
|
|
@@ -3629,11 +3642,11 @@ async function runCreate(ctx, opts) {
|
|
|
3629
3642
|
lanesError: routeLanesError,
|
|
3630
3643
|
allowExtraUsage: opts.allowExtraUsage === true,
|
|
3631
3644
|
});
|
|
3632
|
-
let result = routeOn(view);
|
|
3645
|
+
let result = view === null ? null : routeOn(view);
|
|
3633
3646
|
// feedback_94446741: a refusal that rests on a missing or day-old reading
|
|
3634
3647
|
// is not evidence that the account is full. Take one fresh reading and
|
|
3635
3648
|
// route again; refuse only if there is still no room.
|
|
3636
|
-
if (refusalHasStaleReading(result) && ctx.refreshCapacity) {
|
|
3649
|
+
if (result !== null && refusalHasStaleReading(result) && ctx.refreshCapacity) {
|
|
3637
3650
|
try {
|
|
3638
3651
|
const refreshed = await ctx.refreshCapacity({
|
|
3639
3652
|
env: ctx.env,
|
|
@@ -3649,7 +3662,10 @@ async function runCreate(ctx, opts) {
|
|
|
3649
3662
|
// A failed refresh leaves the original refusal in place.
|
|
3650
3663
|
}
|
|
3651
3664
|
}
|
|
3652
|
-
if (
|
|
3665
|
+
if (result === null || refusalHasNoReadings(result)) {
|
|
3666
|
+
noReadingsFallback();
|
|
3667
|
+
}
|
|
3668
|
+
else if (!result.ok || !result.pick) {
|
|
3653
3669
|
const resetSuffix = result.next_reset ? `; next reset ${result.next_reset}` : "";
|
|
3654
3670
|
throw new LanesError("no_account_with_room", `No account has room${resetSuffix}`, {
|
|
3655
3671
|
next_reset: result.next_reset,
|
|
@@ -3657,15 +3673,17 @@ async function runCreate(ctx, opts) {
|
|
|
3657
3673
|
skipped: result.skipped,
|
|
3658
3674
|
});
|
|
3659
3675
|
}
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3676
|
+
else {
|
|
3677
|
+
autoChosenProvider = parseLaneProvider(result.pick.provider);
|
|
3678
|
+
autoChosenAccount = result.pick.account;
|
|
3679
|
+
autoAccountPick = {
|
|
3680
|
+
why: result.pick.why,
|
|
3681
|
+
headroom: result.pick.headroom,
|
|
3682
|
+
score: result.pick.score,
|
|
3683
|
+
};
|
|
3684
|
+
opts = { ...opts, account: autoChosenAccount, provider: autoChosenProvider };
|
|
3685
|
+
explicitProvider = autoChosenProvider;
|
|
3686
|
+
}
|
|
3669
3687
|
}
|
|
3670
3688
|
if (opts.outpost !== undefined && opts.outpost !== "") {
|
|
3671
3689
|
const requested = opts.outpost.trim();
|
package/dist/lazy-commands.js
CHANGED
|
@@ -4,6 +4,7 @@ import { homedir } from "node:os";
|
|
|
4
4
|
import { dirname, join, resolve } from "node:path";
|
|
5
5
|
import { COMMAND_CATALOG } from "./command-catalog.generated.js";
|
|
6
6
|
import { installUnknownCommandSuggestions } from "./unknown-command.js";
|
|
7
|
+
import { MissingRegistrationPlanError } from "./utils/registration-plan-error.js";
|
|
7
8
|
const commandCatalog = COMMAND_CATALOG;
|
|
8
9
|
/**
|
|
9
10
|
* One entry for every root, including groups that are assembled by several
|
|
@@ -14,8 +15,10 @@ const LAZY_COMMANDS = commandCatalog.map((command) => ({
|
|
|
14
15
|
name: command.name,
|
|
15
16
|
register: async (program) => {
|
|
16
17
|
const registered = await registerCommandRoot(program, command.name);
|
|
18
|
+
// A missing plan means the catalog and the plan came from different installs
|
|
19
|
+
// (an update landed mid-start); the typed error routes it to torn-install recovery.
|
|
17
20
|
if (!registered)
|
|
18
|
-
throw new
|
|
21
|
+
throw new MissingRegistrationPlanError(command.name);
|
|
19
22
|
},
|
|
20
23
|
}));
|
|
21
24
|
/**
|
|
@@ -127,7 +127,10 @@ export declare function usageIncludedSentence(card?: UsageCard): string;
|
|
|
127
127
|
export declare function usageOnlyUpgradeLines(card?: UsageCard): string[];
|
|
128
128
|
/** The `Plan:` orientation line (`hq whoami --plan`) for a usage-only company. */
|
|
129
129
|
export declare function usageOnlyPlanLine(card?: UsageCard): string;
|
|
130
|
-
/**
|
|
130
|
+
/**
|
|
131
|
+
* Agent boxes on usage pricing, priced by size from the card, plus the
|
|
132
|
+
* agent-run meter when the card lists one.
|
|
133
|
+
*/
|
|
131
134
|
export declare function usageOnlyBoxSentence(card?: UsageCard): string;
|
|
132
135
|
/**
|
|
133
136
|
* A refusal that a legacy account answers by upgrading its plan. On usage
|