mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
* fix(cli): an interrupted templates pull leaves no partial folder Unpacking now runs tar asynchronously and removes its .part folder on SIGINT/SIGTERM/SIGHUP before re-raising the signal. Part folders carry the owning pid, and the next pull clears any whose process is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): auth status and templates pull say when HeyGen cannot be reached Offline, both commands waited on unbounded requests and then printed only undici's 'fetch failed'. A new networkFailure helper names the host, the reason (DNS lookup, no route, refused, no answer in time, dropped) and the next step. The account and token-refresh requests now time out after 15 s, the template link after 15 s, and auth status reports an offline refresh at once instead of retrying with the stale token. describeCauseChain moves into the helper so the registry and auth share it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): preview leaves the project's HTML files as they are Opening a project in preview stamped data-hf-id into every composition on disk. The preview route and every source mutation already mint the same content-keyed ids in memory, so the startup pass is dropped: files gain ids only when an edit to them is saved. The .hyperframes folder is still made before the watcher starts, so the preview cache creating it is not reported to Studio as a manifest change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): check runs the browser audits past a lint error A lint error made check skip runtime, layout, motion and contrast, so one known lint error hid every browser finding. The browser pass now runs whenever there is a composition to load, and the lint error still fails the check. Only a root with no data-composition-id skips it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): no desktop-app line for CI or a script reading render output The 'Keep editing by chatting with Framey' line printed on every render and preview, including CI and piped runs where nobody can open the app. It now prints for a person at a terminal, and for a coding agent, which the hyperframes skill tells to pass the line on; CI and other non-TTY runs get nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): cloud render takes a composition at any aspect ratio A 1920x960 composition got 'server will default aspect_ratio to 16:9' although the render kept 1920x960: at 1080p the cloud renders at the composition's own size and aspect_ratio only picks a 4K preset. The CLI now names the detected ratio (2:1) and says the size is kept, takes --aspect-ratio as any W:H checked against the composition, sends only the 16:9, 9:16 and 1:1 the API accepts, and refuses a 4K render of any other ratio before upload, where no preset fits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(media-use): a weak sound-effect match says so instead of passing silently resolve --type sfx returned a HeyGen sound at any score down to 0.4, and a project file that shared one word of its name with the intent, with nothing to tell them from a real match. Such a result now carries a match object in the JSON ({score, min_score, low_confidence} or the matched words and the intent the file was resolved for) and a low-confidence line on stderr. A HeyGen search with no hit says so with the min score it used, and a sound effect nothing matches fails with 'no sound effect matched'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(cli): media-use avatars lists the film account's avatar looks Templates had to reach for 'heygen avatar list', a separate sign-in that can be another account. 'media-use avatars' lists the private looks on the HyperFrames account making the film (GET /v3/avatars/looks?ownership=private, following next_token up to --limit) as {avatars: [{avatar_id, name, ...}]}, the id that 'generate --type avatar --avatar' takes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(skills): leave style-sampling's avatar line to #7164, which owns that skill Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): templates pull removes only the part folders it marked as its own The abandoned-part cleanup deleted any sibling named '<slug>.part-*' whose next token was not a live pid, so a person's own 'sample.part-notes/', 'sample.part-reference.txt' or a symlink went with it. A pull now writes an ownership marker (owner tag + pid) into its part folder, and the cleanup removes only a real directory with the generated '<slug>.part-<pid>-XXXXXX' name whose marker names a dead pid. Files, symlinks, unmarked folders and older unmarked parts are left alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): media-use avatars says it is offline when the login refresh cannot reach HeyGen A network failure while refreshing the stored login was reported as 'no HeyGen sign-in' with 'auth login' as the fix, though the login was still there. It now keeps the network failure's message and next step. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(media-use): a reused weak sound keeps its low-confidence advisory The first resolve of a weak HeyGen sound or a name-matched project file flagged it, but an identical second resolve hit the project manifest and returned it with no match object. The advisory is now rebuilt from the record's provenance (the stored score, or the adopted file's name) on reuse. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(cli): keep the comment share of files this branch touched from rising Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): no check-then-use on pull markers, and the download is never written to disk CodeQL flagged the downloaded bundle written to a file before tar read it, and a stat-then-read in the preview test. The verified archive now streams into tar's stdin, so no network bytes reach a file the CLI writes. The abandoned-part scan takes the entry type from readdir instead of an lstat, reads the ownership marker through one O_NOFOLLOW descriptor it fstats, and the preview test reads each file once instead of stat-checking it first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(ci): raise the CLI's unpacked size budget to 5% over its measured size main's @hyperframes/cli was already about 0.99% over its 23722874-byte unpacked budget, so this branch's additions (networkFailure, the avatars command, the larger skill references) tip it past the 1% tolerance. This is the same value #7169 sets, 25159107 bytes (5% headroom over the measured size), so the two PRs merge cleanly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(cli): split the pull-marker check and share the token-endpoint POST Fallow flagged pullOwner (CRAP 49.5, cyclomatic 13) and a 28-line clone between refreshOnce and exchangeCodeForTokens. pullOwner is now the name match, the O_NOFOLLOW marker read and the marker check as three small functions, with the same behaviour. Both token requests go through one postToTokenEndpoint, which keeps the 15 s timeout and the named network failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): a 4k cloud render checks the exact size against its preset before upload The aspect detector matches a ratio within ±0.05, so at 4k a 1920x1055 composition was sent as 16:9 and 1000x980 as 1:1, and the producer then refused both as an aspect mismatch. At 4k the matched ratio's preset (landscape-4k, portrait-4k, square-4k, the ones the API maps it to) now goes through the producer's own checkOutputResolutionCompatibility, and a composition it does not fit is refused locally with the producer's reason and the 1080p alternative. 1080p, where the render keeps the composition's own size, is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
97 lines
3.5 KiB
TypeScript
97 lines
3.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { describeCauseChain, explainNetworkFailure, NetworkFailure } from "./networkFailure.js";
|
|
|
|
const URL_ = "https://api.heygen.com/v3/users/me";
|
|
|
|
function undiciFailure(cause: Error): TypeError {
|
|
return new TypeError("fetch failed", { cause });
|
|
}
|
|
|
|
function errno(message: string, code: string): Error {
|
|
return Object.assign(new Error(message), { code });
|
|
}
|
|
|
|
describe("explainNetworkFailure", () => {
|
|
it("names the host, a lookup failure as offline, and the next step", () => {
|
|
const error = explainNetworkFailure(
|
|
undiciFailure(errno("getaddrinfo ENOTFOUND api.heygen.com", "ENOTFOUND")),
|
|
URL_,
|
|
);
|
|
expect(error).toBeInstanceOf(NetworkFailure);
|
|
expect((error as NetworkFailure).message).toBe(
|
|
"Could not reach api.heygen.com: its address could not be looked up (DNS); this machine looks offline.",
|
|
);
|
|
expect((error as NetworkFailure).hint).toContain("internet connection");
|
|
});
|
|
|
|
it("tells a missing route, a timeout and a refusal apart", () => {
|
|
const reason = (cause: Error) =>
|
|
(explainNetworkFailure(undiciFailure(cause), URL_) as Error).message;
|
|
expect(reason(errno("connect ENETUNREACH 1.2.3.4:443", "ENETUNREACH"))).toContain(
|
|
"no network route",
|
|
);
|
|
expect(reason(errno("Connect Timeout Error", "UND_ERR_CONNECT_TIMEOUT"))).toContain(
|
|
"did not answer in time",
|
|
);
|
|
expect(reason(errno("connect ECONNREFUSED 1.2.3.4:443", "ECONNREFUSED"))).toContain(
|
|
"refused the connection",
|
|
);
|
|
});
|
|
|
|
it("reads an AbortSignal timeout as no answer in time", () => {
|
|
const timeout = new DOMException("The operation was aborted due to timeout", "TimeoutError");
|
|
expect((explainNetworkFailure(timeout, URL_) as Error).message).toBe(
|
|
"Could not reach api.heygen.com: it did not answer in time.",
|
|
);
|
|
});
|
|
|
|
it("leaves an error that is not a transport failure alone", () => {
|
|
const other = new Error("HeyGen API error (500)");
|
|
expect(explainNetworkFailure(other, URL_)).toBe(other);
|
|
});
|
|
});
|
|
|
|
describe("describeCauseChain", () => {
|
|
it("surfaces the reason undici hides under cause", () => {
|
|
// The reported failure. `fetch failed` alone describes every network
|
|
// problem equally badly; the sentence that tells you what to do is one
|
|
// level down, and it was being dropped.
|
|
const err = new Error("fetch failed", {
|
|
cause: new Error("self-signed certificate in certificate chain"),
|
|
});
|
|
|
|
expect(describeCauseChain(err)).toBe(
|
|
"fetch failed (self-signed certificate in certificate chain)",
|
|
);
|
|
});
|
|
|
|
it("includes an errno code when the message does not already carry it", () => {
|
|
const inner = Object.assign(new Error("getaddrinfo ENOTFOUND example.invalid"), {
|
|
code: "ENOTFOUND",
|
|
});
|
|
|
|
// The code is already in the text, so repeating it would be noise.
|
|
expect(describeCauseChain(new Error("fetch failed", { cause: inner }))).toBe(
|
|
"fetch failed (getaddrinfo ENOTFOUND example.invalid)",
|
|
);
|
|
});
|
|
|
|
it("walks more than one level", () => {
|
|
const deep = new Error("a", { cause: new Error("b", { cause: new Error("c") }) });
|
|
|
|
expect(describeCauseChain(deep)).toBe("a (b; c)");
|
|
});
|
|
|
|
it("survives a cause cycle rather than hanging", () => {
|
|
const a = new Error("a");
|
|
const b = new Error("b", { cause: a });
|
|
(a as { cause?: unknown }).cause = b;
|
|
|
|
expect(describeCauseChain(a)).toBe("a (b)");
|
|
});
|
|
|
|
it("returns the plain message when there is no cause", () => {
|
|
expect(describeCauseChain(new Error("HTTP 404"))).toBe("HTTP 404");
|
|
});
|
|
});
|