mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 19:36:04 +00:00
* 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. * feat(skills): creator templates on the HyperFrames plan A Pro account asks for a video in a creator's format and the agent pulls that template on demand. The packs sit in the private bucket behind the plan-gated bundle route, so a Free account gets a 402 and the upgrade step. A pull costs no credits; making the film spends them as Reverse does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(skills): make creator-remix the one template skill SKILL.md holds the catalog, the Pro openings, the pull and the credit rules. references/remix.md is how to make the episode, from Desktop's creator-remix with only what the app alone has swapped for the CLI. The packs now hold only the template, so their hashes change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(skills): the creator-remix skill and its packs SKILL.md holds the catalog, the Pro openings, the pull and the credit rules. references/remix.md is how to make the episode, from Desktop's creator-remix with only what the app alone has swapped for the CLI. The packs now hold only the template, so their hashes change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(skills): word creator-remix's sign-in steps the way media-use does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(skills): a creator-remix presenter runs on the plan by default The person's own HeyGen avatar is recommended, not required: without one, 小Lin's presenter is made with HeyGen Video 1 from their photo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(cli): pin template packs whose voice bills the plan first Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): offload media named inside template tags References in a composition's <template> were never rewritten, because the DOM query stops at the tag and template.content does not serialize, so the file stayed in the zip. A stem matched as a plain word and a same-named file elsewhere counted as a mention too. A 5-minute presented film went from 196 MB to 71 MB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(cli): lipsync, and avatars that speak a finished voice Video 1 takes audio as a reference and re-paces it, so a shot's lips follow its own track and drift up to a second from the voice. generate --type lipsync redoes the mouth to the exact voice. generate --type avatar takes --audio, and --avatar for the person's own look, so the lips land on the voice from one job. Also moves the plan rows to the 2026-10-30 price book, estimates a voice's credits so --max-credits can hold it, logs jobs from a folder with no project, and describes the resolve flags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(skills): presenters go avatar first, and a voice can be stock The person's own avatar, then Avatar IV from their photo, then Video 1 with lipsync. With no clone or recording, a stock voice named in the credits. Pins the five rebuilt packs. The archive test keeps its ../ under GNU tar with -P. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(cli): fix avatar price and sfx provider tests, trim comments A wav gives the avatar price test an exact length on every platform. The sfx tests now expect HeyGen first. Comment share is back under the base. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(core): read a font shorthand whose size nests parentheses `font: calc(var(--size) * 1px)/1 "X"` cut at the first closing parenthesis, so a bad family name failed the render. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): one ledger row per job, and search skips a template's own pictures A job done at once logs one row, transcribe logs to the project, and resolve no longer offers a component's file for a search. --reuse and --provider get help text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(skills): pin the tested template packs, and a board needs no voice Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(cli): read the transcribe ledger row as JSON, for Windows paths Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(cli): pin the Big Questions pack without the film length check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(skills): call them style templates, and the docs example pulls a real slug Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(cli): pin the cleaned template packs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(skills): drop the stock-presenter ban and the no-spend-before-storyboard rule Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(cli): pin the Paper Trail and Long Story Short packs without the stock-presenter ban Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(skills): rename creator-remix to style-remix, and the five templates to names that say the look Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(skills): style-remix lists the five templates when none is named Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(cli): pin the Finance Explainer pack that varies its motion graphics Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(cli): media-use generate --type cutout takes a shot out of its background on the plan Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(cli): pin the Finance Explainer pack without the provisional variety rule Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(cli): pin the five style packs with variety rules measured on real films Animated Science gets a worlds-and-boards budget, 3D True Crime a main board and a brief corner note, 3D Brand caps by measured rate, Finance and Collage set pieces and more than one look. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(skills): media-use names the on-plan cutout and lipsync commands, not the heygen CLI ones Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): cutout retries dedupe on request_id, uploads carry their real type; style-remix is public The background-removal route dedupes on the body's request_id and ignores the Idempotency-Key header, so a retry after a lost answer started a second job: runJob now also sends the key in the body for such a route. Uploads typed every non-MP4 file as audio, so WebM and MOV inputs were refused: they now take their type from the extension. Fails without the fix: the new cutout test in generate.test.ts sees audio/mpeg for WebM and MOV. style-remix drops metadata.internal and is listed with the other published skills. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(cli): keep the comment share of the touched files at main's Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: count style-remix in the README and CLAUDE.md skill lists Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(skills): rename style-remix to style-sampling Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
149 lines
5.9 KiB
TypeScript
149 lines
5.9 KiB
TypeScript
// Prices before a paid call, from the HyperFrames app's creation pricing. HeyGen charges in units of $1/60, rounded
|
|
// up; the label rounds up to the cent. Routes HeyGen does not price ahead say so instead of guessing.
|
|
import { Fix, probeSeconds, probeVideo, round } from "../measure/media.js";
|
|
import { GUIDE_MAX_S, type GenerateRequest } from "./generate.js";
|
|
|
|
export interface Price {
|
|
usd: number | null;
|
|
/** The list price before HeyGen's unit rounding. */
|
|
list: number | null;
|
|
/** What a HyperFrames plan charges, before rounding up to a whole credit. */
|
|
credits: number | null;
|
|
basis: string;
|
|
}
|
|
|
|
const UNIT = 1 / 60;
|
|
const charged = (usd: number) => Math.ceil(usd / UNIT - 1e-9) * UNIT;
|
|
const cents = (usd: number) => Math.ceil(charged(usd) * 100 - 1e-9) / 100;
|
|
const HF_CREDITS_PER_USD = 1000;
|
|
const at = (list: number, basis: string, credits = list * HF_CREDITS_PER_USD): Price => ({
|
|
usd: cents(list),
|
|
list,
|
|
credits,
|
|
basis,
|
|
});
|
|
|
|
const GPT_IMAGE: Record<string, number> = {
|
|
"1:1": 0.05268,
|
|
"16:9": 0.0396,
|
|
"9:16": 0.0396,
|
|
"4:3": 0.03612,
|
|
"3:4": 0.03612,
|
|
};
|
|
const NANO_IMAGE = 0.067;
|
|
const VIDEO_768P_PER_S = 0.018;
|
|
// A reference shot (pictures, voice or guide clip) bills more, and its guide clip's seconds bill too: measured
|
|
// 2026-10-23 from the wallet, 5 s with a picture $0.25, 10 s $0.50, 5 s with a 1 s guide $0.30, with a 3 s guide $0.40.
|
|
const VIDEO_REF_768P_PER_S = 0.05;
|
|
// A reference shot's first two pictures are included; each one after them bills on its own line.
|
|
const VIDEO_INCLUDED_IMAGES = 2;
|
|
const VIDEO_EXTRA_IMAGE = 0.02;
|
|
// The price book's HyperFrames rows (experiment-framework price_book rules.json, 2026-10-30).
|
|
const HF_VIDEO_768P_PER_S = 18;
|
|
const HF_VIDEO_REF_768P_PER_S = 50;
|
|
const HF_VIDEO_EXTRA_IMAGE = 20;
|
|
const HF_AVATAR_IV_PHOTO_PER_S = 1155 / 60;
|
|
const HF_AVATAR_IV_TWIN_PER_S = 2415 / 60;
|
|
// Billed on the whole video, not the voice: measured 2026-11-01, a 13.75 s shot took 97 credits.
|
|
const HF_LIPSYNC_SPEED_PER_S = 7;
|
|
const MUSIC_PER_TRACK = 0.08;
|
|
const AVATAR_IV_PER_MIN = 4.83;
|
|
const SCRIPT_WORDS_PER_S = 2;
|
|
const HF_TTS_PER_S = 1;
|
|
const SPEECH_CHARS_PER_S = { zh: 5, en: 15 };
|
|
|
|
// fallow-ignore-next-line complexity
|
|
export function priceOf(r: GenerateRequest): Price {
|
|
switch (r.type) {
|
|
case "image": {
|
|
const refs = r.references?.length ?? 0;
|
|
if ((r.model ?? "nano-banana-2") === "nano-banana-2")
|
|
return at(NANO_IMAGE, "nano-banana-2, $0.067 an image");
|
|
const each = GPT_IMAGE[r.aspect ?? "16:9"] ?? GPT_IMAGE["16:9"]!;
|
|
return at(
|
|
each + Math.max(0, refs - 1) * 0.0082,
|
|
`gpt-image-2.5 at ${r.aspect ?? "16:9"}, $0.0082 a reference after the first`,
|
|
);
|
|
}
|
|
case "video": {
|
|
const seconds = Math.min(15, Math.max(5, Math.round(r.seconds ?? 5)));
|
|
if (r.audio || r.references?.length || r.motion) {
|
|
const guide = r.motion ? Math.min(GUIDE_MAX_S, probeVideo(r.motion).pictureDuration) : 0;
|
|
const extra = Math.max(0, (r.references?.length ?? 0) - VIDEO_INCLUDED_IMAGES);
|
|
const billed = seconds + guide;
|
|
return at(
|
|
billed * VIDEO_REF_768P_PER_S + extra * VIDEO_EXTRA_IMAGE,
|
|
`heygen-video-1 reference shot at 768p, ${seconds} s${guide ? ` and the ${round(guide, 2)} s guide` : ""} at $0.05 a second${extra ? `, ${extra} extra pictures at $0.02` : ""}`,
|
|
billed * HF_VIDEO_REF_768P_PER_S + extra * HF_VIDEO_EXTRA_IMAGE,
|
|
);
|
|
}
|
|
return at(
|
|
seconds * VIDEO_768P_PER_S,
|
|
`heygen-video-1 at 768p, ${seconds} s at $0.018 a second`,
|
|
seconds * HF_VIDEO_768P_PER_S,
|
|
);
|
|
}
|
|
case "lipsync": {
|
|
const seconds = r.video ? probeVideo(r.video).pictureDuration : 0;
|
|
return {
|
|
usd: null,
|
|
list: null,
|
|
credits: seconds * HF_LIPSYNC_SPEED_PER_S,
|
|
basis: `lipsync at speed, ${round(seconds, 2)} s at ${HF_LIPSYNC_SPEED_PER_S} credits a second`,
|
|
};
|
|
}
|
|
case "avatar": {
|
|
const words = (r.script ?? "").split(/\s+/).filter(Boolean).length;
|
|
const seconds = r.audio
|
|
? probeSeconds(r.audio)
|
|
: Math.max(1, Math.floor(words / SCRIPT_WORDS_PER_S));
|
|
return at(
|
|
Math.ceil(seconds * AVATAR_IV_PER_MIN) / 60,
|
|
`avatar video, about ${round(seconds, 1)} s${r.audio ? "" : ` from ${words} words`} at $4.83 a minute`,
|
|
seconds * (r.avatar ? HF_AVATAR_IV_TWIN_PER_S : HF_AVATAR_IV_PHOTO_PER_S),
|
|
);
|
|
}
|
|
case "cutout":
|
|
return {
|
|
usd: null,
|
|
list: null,
|
|
credits: null,
|
|
basis: "background removal, not priced ahead",
|
|
};
|
|
case "music":
|
|
return at(MUSIC_PER_TRACK, "lyria-3-pro, $0.08 a track");
|
|
case "voice": {
|
|
const text = r.script ?? "";
|
|
const cjk = (text.match(/\p{Script=Han}/gu) ?? []).length;
|
|
const seconds = cjk / SPEECH_CHARS_PER_S.zh + (text.length - cjk) / SPEECH_CHARS_PER_S.en;
|
|
return {
|
|
usd: null,
|
|
list: null,
|
|
credits: seconds * HF_TTS_PER_S,
|
|
basis: `about ${round(seconds, 1)} s of speech at ${HF_TTS_PER_S} credit a second, an estimate: it is charged per character`,
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
// No HeyGen unit rounding here: a $0.067 image is charged 67 credits, measured on dev 2026-10-29. Still an estimate.
|
|
export const creditsOf = (p: Price): number | null =>
|
|
p.credits === null ? null : Math.ceil(p.credits - 1e-9);
|
|
|
|
/** Refuses, before anything is sent, a call that would not fit what is left of the person's credit limit. */
|
|
export function checkLimit(credits: number | null, limit: number | undefined): void {
|
|
if (limit === undefined) return;
|
|
const fix =
|
|
"tell the person what their limit leaves out, then ask whether to raise it or make the video without this piece";
|
|
if (credits === null)
|
|
throw new Fix(
|
|
`this call cannot be priced ahead, so it cannot be kept under --max-credits ${limit}; nothing was made`,
|
|
fix,
|
|
);
|
|
if (credits > limit)
|
|
throw new Fix(
|
|
`this call is about ${credits} credits, over --max-credits ${limit}; nothing was made or charged`,
|
|
fix,
|
|
);
|
|
}
|