Files
hyperframes/packages/cli/src/auth/browser.ts
T
WaterrrForeverandMiguel Angel Simon Sierra f2358315e5 feat(skills): re-land reverse any video on the HyperFrames plan, with clearer credit wording (#6833)
* fix(cli,skills): say a step's credits are its total, and keep cost out of retries

An out-of-credits refusal named what the step needs, and an agent read
that as the shortfall. It now says the number is the step's total.

After its last try, an agent told the person what was spent and what
another try would cost. The HeyGen reference now says not to.

* fix(cli): plan avatar credits from the HyperFrames price rows

An avatar's credits came from its old API price, about five times what
the plan charges, so --max-credits refused calls that fit and a top-up
asked for too much. They now use the Avatar IV photo row plus the
general avatar video row, 950 credits a minute.

* fix(cli): pin the avatar price test and keep pricing under the comment share

* fix(cli): plan avatar seconds on the Avatar IV row alone

The general avatar row is only checked at admission and billed on
seconds left after Avatar IV, so adding it to every second made a 15 s
script plan at 238 instead of 200 and a 220 limit refuse a call that fits.

* fix(cli): the credits link opens the web plan page, which is live

* test(cli): pin the production credits link too

* chore(skills): regenerate the skills manifest after merging main

* docs(cli): keep the person measure's doc comments to four lines

* docs(cli): keep the measure doc comments to four lines

* docs(cli): keep the measure comment lines to 120 characters

---------

Co-authored-by: Miguel Angel Simon Sierra <miguel.sierra@heygen.com>
2026-10-31 00:47:54 +00:00

44 lines
1.5 KiB
TypeScript

/**
* Open a URL in the user's default browser. Falls back to printing the URL when no browser is openable
* (SSH session, CI, `BROWSER=none`, or `open` rejects). ponytail: `HF_BROWSER_LOG` is a test seam for
* scripted journeys: the URL goes to that file, and a harness plays the person in its own browser.
*/
import { appendFileSync } from "node:fs";
import { c } from "../ui/colors.js";
import { normalizeErrorMessage } from "../utils/errorMessage.js";
export interface OpenBrowserResult {
/** True when we successfully invoked the platform "open" command. */
opened: boolean;
}
export async function openBrowser(url: string): Promise<OpenBrowserResult> {
const log = process.env["HF_BROWSER_LOG"];
if (log) {
appendFileSync(log, `${url}\n`);
return { opened: true };
}
if (process.env["BROWSER"] === "none" || process.env["HF_NO_BROWSER"] === "1") {
printManualInstructions(url);
return { opened: false };
}
try {
const open = (await import("open")).default;
await open(url);
return { opened: true };
} catch (err) {
printManualInstructions(url, normalizeErrorMessage(err));
return { opened: false };
}
}
function printManualInstructions(url: string, detail?: string): void {
if (detail) {
console.error(c.warn(`Could not open browser automatically (${detail}).`));
} else {
console.error(c.warn("Browser auto-open is disabled."));
}
console.error(`Open this URL manually to continue:\n ${c.accent(url)}`);
}