mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +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>
72 lines
3.0 KiB
TypeScript
72 lines
3.0 KiB
TypeScript
/** An error and its `cause` chain as one line: undici's reason, such as a self-signed certificate, sits a level or two down. */
|
|
export function describeCauseChain(err: unknown): string {
|
|
const parts: string[] = [];
|
|
let current: unknown = err;
|
|
const seen = new Set<unknown>();
|
|
while (current instanceof Error && !seen.has(current)) {
|
|
seen.add(current);
|
|
const code = "code" in current ? current.code : undefined;
|
|
const text =
|
|
code && !current.message.includes(String(code))
|
|
? `${current.message} [${String(code)}]`
|
|
: current.message;
|
|
if (text && !parts.includes(text)) parts.push(text);
|
|
current = current.cause;
|
|
}
|
|
if (parts.length === 0) return String(err);
|
|
const [head, ...rest] = parts;
|
|
return rest.length ? `${head} (${rest.join("; ")})` : head!;
|
|
}
|
|
|
|
const OFFLINE = "this machine looks offline";
|
|
const REASONS: [RegExp, string][] = [
|
|
[/certificate|self[- ]signed|unable to verify|altname/i, "the secure connection was refused"],
|
|
[
|
|
/ENOTFOUND|EAI_AGAIN|EAI_NONAME|getaddrinfo/,
|
|
`its address could not be looked up (DNS); ${OFFLINE}`,
|
|
],
|
|
[/ENETUNREACH|EHOSTUNREACH|ENETDOWN/, `there is no network route to it; ${OFFLINE}`],
|
|
[/ECONNREFUSED/, "it refused the connection"],
|
|
[/UND_ERR_CONNECT_TIMEOUT|ETIMEDOUT|TimeoutError|timed? ?out/i, "it did not answer in time"],
|
|
[/ECONNRESET|socket hang up|UND_ERR_SOCKET|other side closed/i, "the connection dropped"],
|
|
];
|
|
|
|
const NEXT_STEP =
|
|
"Check the internet connection (behind a proxy, set HTTPS_PROXY) and run the command again.";
|
|
|
|
/** A request that never got an HTTP answer, worded with the host, the reason and what to do next. */
|
|
export class NetworkFailure extends Error {
|
|
readonly hint = NEXT_STEP;
|
|
constructor(host: string, reason: string, options: { cause: unknown }) {
|
|
super(`Could not reach ${host}: ${reason}.`, options);
|
|
this.name = "NetworkFailure";
|
|
}
|
|
}
|
|
|
|
function isTransportFailure(error: unknown): error is Error {
|
|
if (!(error instanceof Error)) return false;
|
|
if (error.name === "TimeoutError") return true;
|
|
return error instanceof TypeError && /fetch failed/i.test(error.message);
|
|
}
|
|
|
|
/**
|
|
* Names what went wrong when `fetch(url)` threw before any response, so the person sees the host and a next step
|
|
* instead of undici's bare `fetch failed`. Any other error comes back unchanged.
|
|
*/
|
|
export function explainNetworkFailure(error: unknown, url: string): unknown {
|
|
if (error instanceof NetworkFailure || !isTransportFailure(error)) return error;
|
|
const chain = describeCauseChain(error);
|
|
const reason =
|
|
REASONS.find(([pattern]) => pattern.test(chain))?.[1] ?? `the request failed (${chain})`;
|
|
return new NetworkFailure(new URL(url).host, reason, { cause: error });
|
|
}
|
|
|
|
/** `fetch`, with a transport failure rethrown as a {@link NetworkFailure}. */
|
|
export async function fetchExplained(url: string, init?: RequestInit): Promise<Response> {
|
|
try {
|
|
return await fetch(url, init);
|
|
} catch (error) {
|
|
throw explainNetworkFailure(error, url);
|
|
}
|
|
}
|