From 19be35a463a4b446ff5e60bf81d8d0da7aebe3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Wed, 4 Nov 2026 05:51:12 +0000 Subject: [PATCH] fix(cli): the voice a film uses is listed from the HyperFrames account, never the heygen sign-in (#7144) * fix(cli): the voice a film uses is listed from the HyperFrames account, never the heygen sign-in * fix(cli): drop a comment line and an unenforced range from the voices command --- docs/packages/cli.mdx | 4 +++ packages/cli/src/commands/media-use.ts | 1 + packages/cli/src/commands/media-use/voices.ts | 25 +++++++++++++++++ packages/cli/src/heygen/generate.test.ts | 2 +- packages/cli/src/heygen/v3.test.ts | 28 ++++++++++++++++++- packages/cli/src/heygen/v3.ts | 19 ++++++++++--- scripts/check-core-skills.test.mjs | 9 ++++++ skills-manifest.json | 2 +- skills/style-sampling/references/remix.md | 2 +- 9 files changed, 84 insertions(+), 8 deletions(-) create mode 100644 packages/cli/src/commands/media-use/voices.ts diff --git a/docs/packages/cli.mdx b/docs/packages/cli.mdx index 96a803bb57..8bdec2d8ba 100644 --- a/docs/packages/cli.mdx +++ b/docs/packages/cli.mdx @@ -628,6 +628,9 @@ npx hyperframes media-use resolve --type bgm --reuse 06e052c0 # Bring in a file you already have npx hyperframes media-use resolve --type image --from ./photo.jpg +# The voice clones on the account that makes the film +npx hyperframes media-use voices + # Check the setup, and see what has been used npx hyperframes media-use doctor npx hyperframes media-use stats --days 7 @@ -644,6 +647,7 @@ file yourself. | `candidates` | List assets already in the project and the global cache for `--type`, best match for `--intent` first. Downloads nothing and changes nothing. Same as `resolve --candidates` | | `adopt` | Record the files already in `assets/` so later requests find them, with duration and size read by `ffprobe` | | `analyze` | Measure an image or video and print suggested exposure and color corrections, saving nothing. Needs `--type grade --for ` | +| `voices` | List the voice clones on the HyperFrames account you are signed in with, for `--voice` in `generate`. Never lists the separate `heygen` CLI's account | | `doctor` | Check ffmpeg, ffprobe, Node.js, the bundled sound library, and the `heygen` CLI (installed, v0.3.0 or newer, signed in). Changes nothing | | `stats` | Count requests, misses, and reuse from the project's `.media/` and the global `~/.media/` | diff --git a/packages/cli/src/commands/media-use.ts b/packages/cli/src/commands/media-use.ts index 3ca20a38fe..548e4eeb0b 100644 --- a/packages/cli/src/commands/media-use.ts +++ b/packages/cli/src/commands/media-use.ts @@ -103,6 +103,7 @@ export function createMediaUseCommand(invoke: InvokeMediaUse = invokeEngine) { const subCommands = { ...Object.fromEntries(MEDIA_USE_VERBS.map((name) => [name, () => subcommand(name, invoke)])), generate: () => import("./media-use/generate.js").then((m) => m.default), + voices: () => import("./media-use/voices.js").then((m) => m.default), }; return defineCommand({ meta: { name: "media-use", description: "Resolve and operate on project media" }, diff --git a/packages/cli/src/commands/media-use/voices.ts b/packages/cli/src/commands/media-use/voices.ts new file mode 100644 index 0000000000..a443b75f63 --- /dev/null +++ b/packages/cli/src/commands/media-use/voices.ts @@ -0,0 +1,25 @@ +import { defineCommand } from "../../utils/defineCommand.js"; +import type { Example } from "../_examples.js"; +import { jsonArg, num, runMeasure } from "../../measure/command.js"; +import { ownVoices } from "../../heygen/v3.js"; + +export const examples: Example[] = [ + ["The voice clones the film's own account can speak with", "hyperframes media-use voices"], +]; + +export default defineCommand({ + meta: { + name: "voices", + description: + "List the voice clones on the HyperFrames account that makes the film. Never use `heygen voice list` for this: that is a separate sign-in and can be another account", + }, + args: { + limit: { type: "string", description: "How many to list (default 20)" }, + json: jsonArg, + }, + async run({ args }) { + await runMeasure(async () => ({ + voices: await ownVoices(num(args.limit, "--limit", 20)), + })); + }, +}); diff --git a/packages/cli/src/heygen/generate.test.ts b/packages/cli/src/heygen/generate.test.ts index 8c27d07749..7d83df19b1 100644 --- a/packages/cli/src/heygen/generate.test.ts +++ b/packages/cli/src/heygen/generate.test.ts @@ -1069,7 +1069,7 @@ describe("pickVoice", () => { ); await expect(pickVoice({ type: "voice", out: "vo.mp3" })).rejects.toMatchObject({ message: "HeyGen 401 listing its voices", - fix: "run the same command again", + fix: "npx hyperframes auth login", }); }); diff --git a/packages/cli/src/heygen/v3.test.ts b/packages/cli/src/heygen/v3.test.ts index c322dcd9d7..198fc52db0 100644 --- a/packages/cli/src/heygen/v3.test.ts +++ b/packages/cli/src/heygen/v3.test.ts @@ -14,7 +14,7 @@ vi.mock("../cloud/auth.js", () => ({ resolveCloudBaseUrl: () => "https://api.test", })); -const { idempotencyKey, runJob } = await import("./v3.js"); +const { idempotencyKey, ownVoices, runJob } = await import("./v3.js"); /** A job route through the generated client: the create and the status GET it polls. */ const X: JobRoute = { @@ -428,3 +428,29 @@ describe("runJob", () => { expect(idempotencyKey("/v3/x", ["a"])).not.toBe(idempotencyKey("/v3/y", ["a"])); }); }); + +describe("ownVoices", () => { + it("lists the clones of the HyperFrames sign-in's workspace only, never another account's", async () => { + const asked: { url: string; key: string | null }[] = []; + const clonesByKey: Record = { + k: "film-account-clone", + "heygen-cli-login": "other-account-clone", + }; + vi.stubGlobal("fetch", async (url: string, init: RequestInit) => { + const key = new Headers(init.headers).get("x-api-key"); + asked.push({ url, key }); + return reply(200, { data: [{ voice_id: "v1", name: clonesByKey[key ?? ""] }] }); + }); + expect(await ownVoices(5)).toEqual([ + { voice_id: "v1", name: "film-account-clone", language: undefined, gender: undefined }, + ]); + expect(asked).toHaveLength(1); + expect(new URL(asked[0]!.url).searchParams.get("type")).toBe("private"); + expect(asked[0]!.key).toBe("k"); + }); + + it("refuses with the sign-in fix when the HyperFrames account cannot be reached, instead of listing anything", async () => { + vi.stubGlobal("fetch", async () => reply(401, { message: "no" })); + await expect(ownVoices(5)).rejects.toMatchObject({ fix: "npx hyperframes auth login" }); + }); +}); diff --git a/packages/cli/src/heygen/v3.ts b/packages/cli/src/heygen/v3.ts index d29e23128d..502320312b 100644 --- a/packages/cli/src/heygen/v3.ts +++ b/packages/cli/src/heygen/v3.ts @@ -277,14 +277,18 @@ export interface Voice { const isVoice = (v: unknown): v is Voice => isRecord(v) && typeof v.voice_id === "string" && typeof v.name === "string"; -/** HeyGen's public voices for a language, best first; a language it does not know gets multilingual ones. */ -export async function publicVoices(language: string, limit: number): Promise { +async function listVoices(query: { type: "public" | "private"; language?: string }, limit: number) { const client = clientFor(await resolveCloudAuthHeaders().catch(noSignIn)); const value = await client - .listVoicesV3({ type: "public", language, limit, signal: AbortSignal.timeout(30_000) }) + .listVoicesV3({ ...query, limit, signal: AbortSignal.timeout(30_000) }) .catch((err: unknown) => { if (err instanceof HyperframesApiError) - throw new Fix(`HeyGen ${err.status} listing its voices`, "run the same command again"); + throw new Fix( + `HeyGen ${err.status} listing its voices`, + err.status === 401 || err.status === 403 + ? "npx hyperframes auth login" + : "run the same command again", + ); throw new Fix( `no answer from HeyGen for its voices (${err instanceof Error ? err.message : String(err)})`, "run the same command again", @@ -297,6 +301,13 @@ export async function publicVoices(language: string, limit: number): Promise ({ voice_id, name, language, gender })); } +/** HeyGen's public voices for a language, best first; a language it does not know gets multilingual ones. */ +export const publicVoices = (language: string, limit: number): Promise => + listVoices({ type: "public", language }, limit); + +export const ownVoices = (limit: number): Promise => + listVoices({ type: "private" }, limit); + /** Who a paid job bills: the same scope a job's failures and keys belong to. */ export async function senderScope(): Promise { return (await jobSender()).scope; diff --git a/scripts/check-core-skills.test.mjs b/scripts/check-core-skills.test.mjs index 7be8bd8891..601b0b8f46 100644 --- a/scripts/check-core-skills.test.mjs +++ b/scripts/check-core-skills.test.mjs @@ -77,3 +77,12 @@ test("flags a path the skill does not ship, and skips placeholders", () => { const content = "`references/a.md`, `references/b.md`, `references/routes/.md`"; assert.deepEqual(missingPaths(content, dir), ["references/b.md"]); }); + +test("style-sampling picks a voice from the HyperFrames account, never the separate heygen sign-in", () => { + const remix = readFileSync( + new URL("../skills/style-sampling/references/remix.md", import.meta.url), + "utf8", + ); + assert.match(remix, /`npx hyperframes media-use voices`/); + assert.doesNotMatch(remix.replace(/never `heygen voice list`/, ""), /heygen voice list/); +}); diff --git a/skills-manifest.json b/skills-manifest.json index 632cd9f061..680b399315 100644 --- a/skills-manifest.json +++ b/skills-manifest.json @@ -34,7 +34,7 @@ "files": 2 }, "style-sampling": { - "hash": "2c7a5d72f475437c", + "hash": "33f02d97fdf789c0", "files": 2 } } diff --git a/skills/style-sampling/references/remix.md b/skills/style-sampling/references/remix.md index 66a68a37f4..8a08b528ba 100644 --- a/skills/style-sampling/references/remix.md +++ b/skills/style-sampling/references/remix.md @@ -23,7 +23,7 @@ The person's message carries what it carries. Ask once, together, only what is s - **Never the creator's face, voice, footage, wordmark or show name.** - **A presenter runs on the plan.** Their own HeyGen avatar if they have one, otherwise Avatar IV from their photo, both through `npx hyperframes media-use generate --type avatar` with the finished voice, so the lips land on it. HeyGen Video 1 is the fallback when neither works. -- **Settle the voice before any research.** A HeyGen voice id the person gave is the voice: use it and ask nothing. Anything else: with `heygen` signed in, look in `heygen voice list`. One clone: use it. Several: ask which. None, or no `heygen`: ask once for their voice id, a clone they make in HeyGen from 30 s to 3 min of their own reading, or their own recorded narration; with none of these, say in one line that you'll use a HeyGen stock voice (`npx hyperframes media-use resolve --type voice`), name it in the credits as AI-generated, and go on. Nothing else starts until this is settled. +- **Settle the voice before any research.** A HeyGen voice id the person gave is the voice: use it and ask nothing. Anything else: run `npx hyperframes media-use voices`, which lists the clones on the HyperFrames account making the film; never `heygen voice list`, a separate sign-in that can be another account. One clone: use it. Several: ask which. None, or not signed in: ask once for their voice id, a clone they make in HeyGen from 30 s to 3 min of their own reading, or their own recorded narration; with none of these, say in one line that you'll use a HeyGen stock voice (`npx hyperframes media-use resolve --type voice`), name it in the credits as AI-generated, and go on. Nothing else starts until this is settled. - **Then say what's coming** in one short message that is not a question, and go on without waiting: the working title and hook, the length, and roughly how long it takes. No prices. - **The length is the person's, and it beats the template's runtime.** Offer about 1 minute first: the cold open, the title beat and one chapter, the end card short. 2 to 4 minutes: REMIX.md's short cut. A full episode: the series' own runtime. Their own words ("90 seconds", "5 min"): that length. No length answered and none in the topic: about 1 minute, and offer the longer cut in the reply. Scale everything to it: script words (the template's script stats at that runtime), facts, sections, music cues, review rounds (one for a minute, two for a full episode); never pad or trim to reach the series' runtime instead. - Everything else REMIX.md ยง0 asks (chapters, language) takes REMIX.md's default; write each one, and the length, with why, in the project's `CLAUDE.md`.