mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-08 10:46:06 +00:00
* fix(media-use): tag HeyGen TTS generation with attribution header
Centralizes the X-HeyGen-Client-Source header into HEYGEN_CLIENT_SOURCE_ARGV
in heygen-cli.mjs and reuses it in heygen-search.mjs (dropping the duplicated
inline literal) so voice-provider's `voice speech create` call carries it too.
The generation call was previously untagged, making media-use TTS usage
invisible in HeyGen's billing/analytics warehouse; the read-only `voice list`
discovery call intentionally stays untagged.
* feat(media-use): add local LTX video generate provider
* feat(media-use): add HeyGen avatar-video generate provider
* feat(media-use): register video as a real provider type
* docs(media-use): document the wired video type and full HeyGen tagging coverage
resolve --type video is now the default path (HeyGen avatar video first,
local LTX fallback, sign-in nudge on auth failure) instead of a manual
recipe; correct the claim that only search requests are tagged now that
TTS and avatar-video generation carry the attribution header too.
* fix(media-use): wire --avatar-id/--voice-id CLI flags and close video-provider auth/cache gaps
- resolve.mjs never implemented the --avatar-id/--voice-id override that
operations.md documented, so following the docs crashed with
ERR_PARSE_ARGS_UNKNOWN_OPTION; wire the flags through to ctx.
- defaultAvatarId/defaultStarfishVoiceId cached a failed discovery lookup
as a permanent null, disabling heygen.video after one transient miss;
cache only a truthy id, matching the same fix in voice-provider.mjs's
defaultVoiceId.
- the avatar-video onboarding nudge only fired on a video-create failure,
never when avatar/voice discovery itself was unauthenticated (the
common unauthenticated case) -- propagate the discovery failure reason
so onboarding fires either way.
- dedupe the CLI-shelling JSON helper (heygen-cli.mjs's new runHeygenJson)
and the local-model argv-template builder (local-models.mjs's new
buildArgv) instead of leaving byte-identical copies in each provider.
* fix(media-use): address avatar-video PR review feedback
- heygenVideoGenerate short-circuits after the first discovery-call
failure instead of always attempting both avatar list and voice list,
so an unauthenticated caller gets one onboarding message and one
provider-error telemetry ping instead of a double-fire.
- runHeygenJson logs a diagnostic when a CLI call succeeds but returns
unparseable JSON, instead of silently returning null.
- dedupe the "avatar video is free" onboarding string into one constant
(was duplicated across three call sites).
* fix(media-use): match review-requested naming and message conventions
- export AVATAR_VIDEO_SIGNIN_MESSAGE from heygen-video-provider.mjs so
the test imports the canonical string instead of redeclaring it.
- runHeygenJson's non-JSON diagnostic now matches heygen-search.mjs's
existing wording ("returned non-JSON output").
46 lines
1.8 KiB
JavaScript
46 lines
1.8 KiB
JavaScript
import { execFileSync } from "node:child_process";
|
|
import { HEYGEN_CLIENT_SOURCE_ARGV, reportHeygenFailure } from "./heygen-cli.mjs";
|
|
|
|
export function heygenSearch(subcommand, query, { type, limit = 5, minScore } = {}) {
|
|
// execFileSync with an argv array (no shell), so query/type/etc. are passed as
|
|
// literal arguments — no quoting tricks, no command injection. subcommand is a
|
|
// hardcoded multi-word string (e.g. "audio sounds list"), split into tokens.
|
|
// Tag the caller via the CLI's allowlisted attribution header (heygen >= v0.3.0).
|
|
const args = [...HEYGEN_CLIENT_SOURCE_ARGV, ...subcommand.split(" "), "--query", query];
|
|
if (type) args.push("--type", type);
|
|
args.push("--limit", String(limit));
|
|
// Server-side score floor. Honored by `audio sounds list`; the `asset search`
|
|
// backend rejects it, so only audio providers pass minScore (see image-provider).
|
|
if (minScore != null) args.push("--min-score", String(minScore));
|
|
|
|
let out;
|
|
try {
|
|
out = execFileSync("heygen", args, {
|
|
encoding: "utf8",
|
|
timeout: 15000,
|
|
stdio: ["pipe", "pipe", "pipe"],
|
|
});
|
|
} catch (err) {
|
|
// Don't swallow a broken command / auth failure as "no results" — that turns
|
|
// a typo or expired key into a silent dead end. Surface it, then give up.
|
|
reportHeygenFailure(err, `heygen ${subcommand}`);
|
|
return null;
|
|
}
|
|
|
|
let parsed;
|
|
try {
|
|
parsed = JSON.parse(out);
|
|
} catch {
|
|
console.error(`media-use: \`heygen ${subcommand}\` returned non-JSON output`);
|
|
return null;
|
|
}
|
|
if (parsed?.error) {
|
|
const e = parsed.error;
|
|
console.error(`media-use: \`heygen ${subcommand}\` error: ${e.message ?? JSON.stringify(e)}`);
|
|
return null;
|
|
}
|
|
|
|
const data = parsed?.data;
|
|
return Array.isArray(data) && data.length > 0 ? data : null;
|
|
}
|