feat(media-use): use CLI free HeyGen usage (#2027)

* feat(media-use): use CLI free HeyGen usage

* fix(media-use): address #2027 R1 nits — gate cli-source header to OAuth, export origin constant

- X-HeyGen-Source is now sent only on OAuth (Bearer) requests, not API-key ones —
  the backend ignores it for API-key traffic (normal billing), so it was dead
  metadata there. buildAuthHeaders + heygenAuthHeaders + tests updated.
- Export HEYGEN_CLI_ORIGIN_HEADER ("X-HeyGen-Client-Origin") for future cli:<origin>
  consumers.
- Document the deliberate paid/X4 confirm-before-call decision on heygen.tts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H5k87mPZ4d6yiFwcWSb8Vv

* refactor(cli): drop unused origin-header export, dedup auth-client tests

Fallow flagged 5 findings on this PR:
- major: HEYGEN_CLI_ORIGIN_HEADER was exported but never emitted or
  imported — speculative dead code ("future consumers"). Remove it; a
  real consumer can add the constant when one exists.
- 4x minor duplication in client.test.ts: fold the repeated
  `.rejects.toSatisfy(auth-code)` assertion into expectAuthCode(), and the
  repeated try/catch scrubbed-message assertion into expectRejectionMessage().

No behavior change; auth/client tests still 17/17.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H5k87mPZ4d6yiFwcWSb8Vv

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Miguel Ángel
2026-07-09 18:28:26 -04:00
committed by GitHub
co-authored by Claude Opus 4.8
parent 1614dd3e5a
commit 3b93f516b4
12 changed files with 173 additions and 69 deletions
@@ -42,14 +42,14 @@ test("image cascade: heygen catalog, then local mflux, then the codex upsell", (
assert.ok(codex.network, "codex is network (skipped under --local-only)");
});
test("voice cascade: local Kokoro first (free), HeyGen TTS as the paid upsell", () => {
test("voice cascade: HeyGen TTS first, Kokoro remains the local fallback", () => {
const ps = getProviders("voice");
assert.equal(ps[0].name, "kokoro.local", "local Kokoro comes first now (HeyGen TTS is paid)");
assert.ok(!ps[0].network, "local Kokoro kept under --local-only");
assert.ok(!ps[0].paid, "local Kokoro is free");
const heygen = ps.find((p) => p.name === "heygen.tts");
assert.ok(heygen && heygen.paid, "HeyGen TTS is the paid upsell");
assert.ok(heygen.network, "HeyGen TTS is network (skipped under --local-only)");
assert.equal(ps[0].name, "heygen.tts", "HeyGen TTS is first when credentials exist");
assert.ok(ps[0].network, "HeyGen TTS is network (skipped under --local-only)");
assert.ok(ps[0].paid, "HeyGen TTS may bill after the OAuth free allowance");
assert.equal(ps[1].name, "kokoro.local", "local Kokoro is the offline fallback");
assert.ok(!ps[1].network, "local Kokoro kept under --local-only");
assert.ok(!ps[1].paid, "local Kokoro is free");
});
test("ctx.provider forces one generator (e.g. 'make an image WITH codex')", async () => {