mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 11:26:02 +00:00
* fix(cli): a credit limit the person names holds on every paid media call A limit was only a per-call --max-credits flag that each caller had to remember, so kit tools, voice resolve and transcribe could spend past it. The limit now lives in the project's credit-limit file and runJob, which every paid call goes through, refuses a new job past what is left (unpriced calls included). Voice and avatar video resolved through the heygen CLI are refused under a limit, since they cannot be priced there. * fix(cli): keep a lost job's reserved credits, and hold the limit on the audio engine's voice A resumed job refused with a status that says nothing about the job released its reservation while the job may still be running. Only the call that reserved releases, and only for a refusal that rules the job out. The audio engine's HeyGen speech call now refuses under a limit too. * fix(cli): type withinLimit as returning whether it reserved * chore: regenerate the skills manifest * fix(cli): a credit-limit file is a run-time project file, and a lighter runJob catch * chore(cli): mark runJob's complexity as accepted
83 lines
2.9 KiB
JavaScript
83 lines
2.9 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
import { join, resolve } from "node:path";
|
|
import { tmpdir } from "node:os";
|
|
import { describe, it } from "node:test";
|
|
import { generateSkillModuleCopies } from "./generate-skill-module-copies.mjs";
|
|
|
|
const skillLibDir = resolve("skills/media-use/scripts/lib");
|
|
const cliLibDir = resolve("packages/cli/src/media-use/lib");
|
|
|
|
export const MEDIA_USE_COPY_NAMES = [
|
|
"config-lock.mjs",
|
|
"credit-limit.mjs",
|
|
"cutlist.mjs",
|
|
"duck.mjs",
|
|
"error-diffusion.mjs",
|
|
"index-gen.mjs",
|
|
"manifest.mjs",
|
|
"media-fetch.mjs",
|
|
"media-home.mjs",
|
|
"npx-sync.mjs",
|
|
"parakeet-words.mjs",
|
|
"prefs-store.mjs",
|
|
"recipe-store.mjs",
|
|
"telemetry.mjs",
|
|
"transcriptCutFade.mjs",
|
|
"words.mjs",
|
|
];
|
|
|
|
export const INTENTIONAL_MEDIA_USE_DIVERGENCES = new Map([
|
|
[
|
|
"npx-sync.mjs",
|
|
"the standalone skill stays self-contained while the CLI copy uses the shared audio helper",
|
|
],
|
|
]);
|
|
|
|
function copyPaths(name, skillDir, cliDir) {
|
|
return { skillPath: join(skillDir, name), cliPath: join(cliDir, name) };
|
|
}
|
|
|
|
export function findMediaUseCopyParityIssues({ skillDir = skillLibDir, cliDir = cliLibDir } = {}) {
|
|
const missingNames = MEDIA_USE_COPY_NAMES.filter((name) => {
|
|
const { skillPath, cliPath } = copyPaths(name, skillDir, cliDir);
|
|
return !existsSync(skillPath) || !existsSync(cliPath);
|
|
});
|
|
const missing = missingNames.map((name) => `${name}: both media-use copies must exist`);
|
|
const drifted = MEDIA_USE_COPY_NAMES.filter(
|
|
(name) => !missingNames.includes(name) && !INTENTIONAL_MEDIA_USE_DIVERGENCES.has(name),
|
|
)
|
|
.filter((name) => {
|
|
const { skillPath, cliPath } = copyPaths(name, skillDir, cliDir);
|
|
return !readFileSync(skillPath).equals(readFileSync(cliPath));
|
|
})
|
|
.map((name) => `${name}: standalone and CLI copies differ without an allowlist reason`);
|
|
return [...missing, ...drifted];
|
|
}
|
|
|
|
describe("media-use source parity", () => {
|
|
it("keeps every standalone copy equal or explicitly allowlisted", () => {
|
|
assert.deepEqual(findMediaUseCopyParityIssues(), []);
|
|
});
|
|
|
|
it("reports a missing copy without reading it as drift", () => {
|
|
const root = mkdtempSync(join(tmpdir(), "media-use-parity-"));
|
|
const skillDir = join(root, "skill");
|
|
const cliDir = join(root, "cli");
|
|
try {
|
|
const name = MEDIA_USE_COPY_NAMES[0];
|
|
mkdirSync(skillDir, { recursive: true });
|
|
mkdirSync(cliDir, { recursive: true });
|
|
writeFileSync(join(skillDir, name), "same");
|
|
const issues = findMediaUseCopyParityIssues({ skillDir, cliDir });
|
|
assert.equal(issues[0], `${name}: both media-use copies must exist`);
|
|
} finally {
|
|
rmSync(root, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|
|
|
|
it("keeps generated standalone modules equal to their owners", () => {
|
|
assert.deepEqual(generateSkillModuleCopies({ check: true }), []);
|
|
});
|