hyperframes 0.9.9 → 0.9.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/{add-FQX5F6PC.js → add-IAFJH5RC.js} +6 -6
- package/dist/{agentPromptGenerator-XNGPKVEX.js → agentPromptGenerator-S3GWYMVC.js} +1 -1
- package/dist/{animatedGifPrep-E3PYKFJ3.js → animatedGifPrep-YU7IOD5D.js} +1 -1
- package/dist/api.js +10 -10
- package/dist/{asset-X5GG5TTP.js → asset-UR4PH6KJ.js} +2 -2
- package/dist/{assetCataloger-SDFP4DWL.js → assetCataloger-VKJIQCYP.js} +1 -1
- package/dist/{audio-DDTYFS23.js → audio-HZJ7QZQR.js} +9 -9
- package/dist/{auth-OAWLDT3A.js → auth-UBNAW62X.js} +2 -2
- package/dist/{autoUpdate-BWIPXW2W.js → autoUpdate-DDFTFHRP.js} +3 -3
- package/dist/{backgroundChecks-YJ5NRMBA.js → backgroundChecks-H3TNVYJV.js} +4 -4
- package/dist/backgroundChecksWorker.js +4 -4
- package/dist/{beats-Q2TIAA7S.js → beats-HOIQSFFP.js} +6 -6
- package/dist/{benchmark-I3GRHFIN.js → benchmark-ZYOQV7DK.js} +7 -7
- package/dist/billing-5YSYJJ2V.js +142 -0
- package/dist/{browser-F24WMZ52.js → browser-PLFK53IZ.js} +4 -4
- package/dist/{bundleWithLocalizedFonts-K5CQPNIZ.js → bundleWithLocalizedFonts-TH5SLG6O.js} +2 -2
- package/dist/{capture-UKWY3SZQ.js → capture-MICLAF6V.js} +13 -13
- package/dist/{capture-HLC6I4RE.js → capture-R77HOGLQ.js} +3 -3
- package/dist/{captureCompositionFrame-YMB3CKSP.js → captureCompositionFrame-WBMFZHEF.js} +4 -4
- package/dist/{catalog-H7SOITD6.js → catalog-CGT32566.js} +6 -6
- package/dist/{catch-up-YRGPVEM6.js → catch-up-TMYPXRKC.js} +5 -5
- package/dist/{check-BPQZZ2MO.js → check-4O5J4OWS.js} +23 -23
- package/dist/{checkAudio-4NRQ3WGS.js → checkAudio-AAVDZFIQ.js} +3 -3
- package/dist/{checkBrowser-S66AHKW3.js → checkBrowser-3OCZBJC7.js} +19 -17
- package/dist/{chunk-BYC4C4YY.js → chunk-2VYAX3ZD.js} +2 -2
- package/dist/{chunk-GIYZMGYT.js → chunk-2VZVMCV6.js} +1 -1
- package/dist/{chunk-322AG75G.js → chunk-33K2UZBX.js} +2 -2
- package/dist/{chunk-5YIZRU2L.js → chunk-37537KOL.js} +4 -4
- package/dist/{chunk-NX2X326Z.js → chunk-4ILKN2MX.js} +8 -8
- package/dist/{chunk-NCP3JQ6S.js → chunk-4J4EGANW.js} +2 -2
- package/dist/{chunk-TZBJEKKU.js → chunk-4YCNVKJX.js} +194 -17
- package/dist/{chunk-2ROPUTCS.js → chunk-6DHC3MVK.js} +2 -2
- package/dist/{chunk-BX2JB24X.js → chunk-6JDNEQV5.js} +1 -1
- package/dist/{chunk-6HO6QKYG.js → chunk-6R2PED3X.js} +6 -6
- package/dist/{chunk-DIKIN4BA.js → chunk-6Y7WZTHJ.js} +54 -38
- package/dist/{chunk-HBHLCMOQ.js → chunk-7ZBMUKHY.js} +2 -2
- package/dist/chunk-AHLDGEH5.js +158 -0
- package/dist/{chunk-6DKWOG7L.js → chunk-BBMMVLA3.js} +1 -1
- package/dist/{chunk-BLBMPEBX.js → chunk-BONBJJ35.js} +1 -0
- package/dist/{chunk-63GTSNMY.js → chunk-CD65TPHT.js} +1 -1
- package/dist/{chunk-HUJMTTKR.js → chunk-CN3Q4CDK.js} +43 -27
- package/dist/{chunk-2Y575PWJ.js → chunk-DI3ZFBZ3.js} +1 -1
- package/dist/{chunk-NNF6G2UH.js → chunk-EL2DMHA5.js} +1 -1
- package/dist/{chunk-B5GWDPUO.js → chunk-EPCVE3OX.js} +2 -2
- package/dist/{chunk-6UZLHLFP.js → chunk-FC4WF2VQ.js} +1 -1
- package/dist/{chunk-4W5X4S47.js → chunk-H7H7XNYY.js} +88 -28
- package/dist/{chunk-JZPUXDQE.js → chunk-HY64QA63.js} +1 -1
- package/dist/{chunk-AH6MUQQC.js → chunk-I4XTKG2B.js} +2 -2
- package/dist/{skills-EBVQSIK4.js → chunk-IMK55N3Z.js} +46 -38
- package/dist/{chunk-VNR7LSN4.js → chunk-IQ5OMRLK.js} +39 -41
- package/dist/{chunk-PPMCILED.js → chunk-JS6ZTPYC.js} +4 -4
- package/dist/{chunk-V74HSKGY.js → chunk-JT2ZGKKB.js} +2 -2
- package/dist/{chunk-2NGBIAUF.js → chunk-KNOIX2U5.js} +220 -177
- package/dist/{chunk-MY4PAH7C.js → chunk-LWFXO732.js} +1 -1
- package/dist/{upgrade-ZUWFB2QM.js → chunk-MZHCA5KY.js} +65 -27
- package/dist/{chunk-EN6MPNZT.js → chunk-NQYW4IYN.js} +2 -2
- package/dist/{chunk-H534266X.js → chunk-OKD2LP73.js} +1 -1
- package/dist/{chunk-A2NFFVWH.js → chunk-OQGA4QBD.js} +18 -6
- package/dist/{chunk-UWYHZCEQ.js → chunk-OQHC5YIB.js} +2 -2
- package/dist/{chunk-BHL4KN3H.js → chunk-PKLZ5PV2.js} +1 -1
- package/dist/{chunk-OYAZODSP.js → chunk-QM4OL5MZ.js} +16 -11
- package/dist/{chunk-BBP5KGYS.js → chunk-SUM3VFPQ.js} +2 -2
- package/dist/{chunk-CNX3WKQ5.js → chunk-T4ELNOK6.js} +1 -1
- package/dist/{chunk-VZ5O7A77.js → chunk-V6HV2IDT.js} +5 -2
- package/dist/{chunk-BXYB5NGT.js → chunk-VWUUNGSV.js} +1 -1
- package/dist/{chunk-CBPBTQBH.js → chunk-WJ7E5J77.js} +11 -10
- package/dist/{chunk-62ATHBDS.js → chunk-YJZYUXHQ.js} +1 -1
- package/dist/{chunk-TJ2USKCK.js → chunk-ZUACTOAB.js} +1 -1
- package/dist/{clean-RCXKQNFM.js → clean-2FWZPS4J.js} +9 -9
- package/dist/cli.js +61 -60
- package/dist/{cloud-TQPQZRC5.js → cloud-2UFI7NLD.js} +4 -4
- package/dist/cloud-Z3FNCC4T.js +1 -1
- package/dist/{compare-EO32AASM.js → compare-HKRLSFTU.js} +15 -15
- package/dist/{compiler-NAIDMQFU.js → compiler-KKIYPREA.js} +1 -1
- package/dist/{component-S3TYNVCR.js → component-F43F3363.js} +3 -3
- package/dist/{compositions-4TXRLZ3M.js → compositions-FFXCISLD.js} +7 -7
- package/dist/{curve-HGLOP2GY.js → curve-RHSJUG5P.js} +5 -5
- package/dist/{cuts-VNFIISLL.js → cuts-KVFY3U6C.js} +5 -5
- package/dist/{delete-TIWI3G7X.js → delete-O7IZKKUN.js} +4 -4
- package/dist/{deploy-EHPNOGSY.js → deploy-PZAAUW75.js} +8 -8
- package/dist/{describeProject-DN6YQU3X.js → describeProject-E44RWBJL.js} +1 -1
- package/dist/{diff-46JK5ZCL.js → diff-OMNILRNN.js} +21 -19
- package/dist/{dist-CCPYPKOC.js → dist-PUHEYGA5.js} +3 -3
- package/dist/{doctor-LD23DW4N.js → doctor-4HZN7ZVI.js} +10 -6
- package/dist/{energy-YZ3DB6AI.js → energy-N3ZIPHTP.js} +5 -5
- package/dist/{events-3OWNDNJX.js → events-56A5D6DK.js} +4 -4
- package/dist/{events-MQIKCKA5.js → events-TUTAERAN.js} +6 -6
- package/dist/{events-DRTMYSQ6.js → events-VAJ4Y6XF.js} +3 -3
- package/dist/{extract-F3NBE3X5.js → extract-NJMZEOLG.js} +6 -6
- package/dist/{face-ZU7ZDYGO.js → face-KLV4W6CP.js} +5 -5
- package/dist/{feedback-37M37Y4F.js → feedback-4VEKGVLN.js} +5 -5
- package/dist/{ffmpeg-PERZ6YHQ.js → ffmpeg-A2O4HSRD.js} +1 -1
- package/dist/{figma-55AG42NN.js → figma-6XDKKOA6.js} +3 -3
- package/dist/fontLocalizeCli.js +3 -3
- package/dist/{frames-DJA3CFSY.js → frames-IAMGMNCA.js} +5 -5
- package/dist/{generate-BVJ5XNWP.js → generate-FMATRA3L.js} +11 -9
- package/dist/{get-PGLCWEBG.js → get-JKA3APWR.js} +4 -4
- package/dist/{gpuPolicy-DUNSQM6M.js → gpuPolicy-TKHFDEH2.js} +2 -2
- package/dist/{grade-compare-R6Q6G6WP.js → grade-compare-TCLCDUG5.js} +14 -14
- package/dist/{heifImagePrep-YNPHFR6W.js → heifImagePrep-L2EY67F2.js} +1 -1
- package/dist/{help-4SNDXHWQ.js → help-TWDOQJDN.js} +3 -2
- package/dist/{history-NKRHKIE2.js → history-SOWVZUAB.js} +7 -7
- package/dist/hyperframes-player.global.js +1 -1
- package/dist/{info-U4VDKU2Y.js → info-JDINBZLH.js} +6 -6
- package/dist/{init-2RUVBHQO.js → init-ACNL6AFC.js} +15 -15
- package/dist/{ink-TX3USU7X.js → ink-WNEJROFH.js} +5 -5
- package/dist/{inspect-MAGHXEWS.js → inspect-37AMWUW3.js} +15 -15
- package/dist/{keyframes-2TDECIQZ.js → keyframes-LMUFQW4Z.js} +7 -7
- package/dist/{lambda-CRVYDETX.js → lambda-DRGDNEW6.js} +3 -3
- package/dist/{layout-I3VNHWJH.js → layout-E63HPSXW.js} +15 -15
- package/dist/{lint-MCVWXDJX.js → lint-HNZPRCXH.js} +7 -7
- package/dist/{list-FJJNWPM6.js → list-UMR5VN2M.js} +4 -4
- package/dist/{localPage-6MQ6YFER.js → localPage-KIFKMB2B.js} +1 -1
- package/dist/{login-YAZZWYFK.js → login-OXOPCSUY.js} +4 -4
- package/dist/{look-U5UHXPUQ.js → look-DFQJP2LY.js} +5 -5
- package/dist/{manager-ARXEX6OP.js → manager-T633Z2L4.js} +1 -1
- package/dist/{measure-JAPDVQ5X.js → measure-Y2VXF6LJ.js} +11 -11
- package/dist/{media-treatment-A4Z32NGP.js → media-treatment-U2PDH4P3.js} +8 -8
- package/dist/{media-use-6HX7JHRD.js → media-use-KGNGAQQP.js} +2 -1
- package/dist/{models-GMJODMZ5.js → models-HATSG3VK.js} +5 -5
- package/dist/{motionShot-Z63I3GO7.js → motionShot-45M7MSFQ.js} +7 -7
- package/dist/{normalize-audio-45CHOWKY.js → normalize-audio-SOXEVIKM.js} +5 -5
- package/dist/{open-RSTNLDYI.js → open-LRPNBFRW.js} +5 -5
- package/dist/{parakeetRunner-K4EGDDVH.js → parakeetRunner-A7Z6CQOT.js} +1 -1
- package/dist/{pipeline-EKLTELWF.js → pipeline-N3M6VXBC.js} +4 -4
- package/dist/{play-BYIEIRQQ.js → play-HTHDFMOU.js} +10 -10
- package/dist/{preflight-TC6ZW3GB.js → preflight-XZZXHV42.js} +2 -2
- package/dist/{present-5B5VQKT5.js → present-LQ4PJTP4.js} +10 -10
- package/dist/{preview-5O2HT2WF.js → preview-CTEDNFN3.js} +9 -9
- package/dist/{probe-ZGK6DBAR.js → probe-6IZD5TPR.js} +6 -6
- package/dist/{producer-RFTB2APL.js → producer-4CR46ON4.js} +1 -1
- package/dist/{remove-background-LURZDSDJ.js → remove-background-SYHNGASQ.js} +5 -5
- package/dist/{render-ETZ3WAJO.js → render-JHSMAWED.js} +9 -9
- package/dist/{render-7HIEI7QP.js → render-VZLEKSHR.js} +19 -19
- package/dist/{reverse-VPBNBP2Q.js → reverse-SCXEQVRH.js} +1 -1
- package/dist/{run-XER4YJY5.js → run-GRCZ6JO5.js} +2 -2
- package/dist/{sherpa-D6FQ3CHN.js → sherpa-EENLR3RM.js} +1 -1
- package/dist/skills/hyperframes-cli/SKILL.md +2 -0
- package/dist/skills/media-use/SKILL.md +1 -1
- package/dist/skills/media-use/audio/scripts/lib/heygen.mjs +1 -1
- package/dist/skills/media-use/audio/scripts/lib/heygen.test.mjs +1 -1
- package/dist/skills/media-use/audio/scripts/lib/tts.mjs +2 -0
- package/dist/skills/media-use/audio/scripts/lib/tts.test.mjs +14 -0
- package/dist/skills/media-use/references/heygen.md +2 -2
- package/dist/skills/media-use/scripts/lib/credit-limit.d.mts +3 -0
- package/dist/skills/media-use/scripts/lib/credit-limit.mjs +41 -0
- package/dist/skills/media-use/scripts/lib/credit-limit.test.mjs +39 -0
- package/dist/skills/media-use/scripts/lib/heygen-video-provider.mjs +2 -0
- package/dist/skills/media-use/scripts/lib/voice-provider.mjs +2 -0
- package/dist/skills-4TSYBAGW.js +49 -0
- package/dist/{skillsUpdateCheck-7VXK4R4J.js → skillsUpdateCheck-MGXL5VXL.js} +6 -4
- package/dist/{snapshot-PJUNSMDS.js → snapshot-P27Y3NJE.js} +18 -18
- package/dist/{src-RL6YEPTD.js → src-L7UBHHKB.js} +1 -1
- package/dist/{src-SMIMKSHZ.js → src-MWO2XBSA.js} +2 -2
- package/dist/{start-5ZDH643Z.js → start-L5M26YD5.js} +31 -19
- package/dist/{staticProjectServer-BX4RWEY5.js → staticProjectServer-2JYB7RLI.js} +5 -5
- package/dist/{status-4LLUW5YT.js → status-SUK4I7TS.js} +8 -5
- package/dist/studio/assets/{hyperframes-player-CcNGHTev.js → hyperframes-player-BbRz52ui.js} +1 -1
- package/dist/studio/assets/{index-D9uDed3x.js → index-CCSgOq2L.js} +1 -1
- package/dist/studio/assets/{index-DSRgrCDX.js → index-D3y5mWmH.js} +22 -22
- package/dist/studio/index.html +1 -1
- package/dist/{studio-api-PEUXVD7P.js → studio-api-MEZKFJBY.js} +3 -3
- package/dist/{studioServer-2WIQBEQC.js → studioServer-J5RPUMHP.js} +25 -25
- package/dist/{sync-P3O3WZWT.js → sync-FHT2CHKU.js} +5 -5
- package/dist/{telemetry-267LV4SC.js → telemetry-JWEOBK3Q.js} +4 -4
- package/dist/{telemetry-T73TKZOL.js → telemetry-WGNNQUSF.js} +1 -1
- package/dist/{templates-MQ742KVZ.js → templates-7DIQ52Y4.js} +40 -11
- package/dist/{timeline-WP7AZAQC.js → timeline-ZO3PNIET.js} +9 -9
- package/dist/{tokens-ROFKR7AE.js → tokens-X6OTCQCV.js} +2 -2
- package/dist/{transcribe-WS2STSCJ.js → transcribe-KNO3BK5S.js} +9 -9
- package/dist/{transcribe-N66QUYCS.js → transcribe-QIZGXMR5.js} +1 -1
- package/dist/{tts-HIQMJU6O.js → tts-JHGGL7GL.js} +1 -1
- package/dist/update-WXGSPMEG.js +280 -0
- package/dist/{updateCheck-M2SMSDIO.js → updateCheck-OBYSCTWV.js} +7 -3
- package/dist/upgrade-YCCIVSI6.js +40 -0
- package/dist/{urlDownloader-YNI3Y3IE.js → urlDownloader-FOXK4FYP.js} +1 -1
- package/dist/{validate-M2M37G47.js → validate-TDVQ2B6Y.js} +13 -13
- package/dist/{video-2OEOTSPQ.js → video-AVEGMBDM.js} +1 -1
- package/dist/voices-2LIY4CYK.js +97 -0
- package/dist/warmCheck.js +23 -23
- package/package.json +1 -1
- package/dist/billing-W224NIAM.js +0 -96
- package/dist/chunk-ASGRVFQ3.js +0 -59
- package/dist/{chunk-QUBVGS27.js → chunk-LNTUFRZD.js} +3 -3
- package/dist/{destroy-C5GQLZVZ.js → destroy-IQLGADZM.js} +4 -4
- package/dist/{synthesize-YK3WLOEQ.js → synthesize-YYT7UON6.js} +5 -5
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { createRequire as __hf_createRequire } from "node:module";
|
|
2
|
+
import { fileURLToPath as __hf_fileURLToPath } from "node:url";
|
|
3
|
+
import { dirname as __hf_dirname } from "node:path";
|
|
4
|
+
var require = __hf_createRequire(import.meta.url);
|
|
5
|
+
var __filename = __hf_fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __hf_dirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
resolveCloudAuthHeaders,
|
|
9
|
+
resolveCloudBaseUrl
|
|
10
|
+
} from "./chunk-TSQZ3DSC.js";
|
|
11
|
+
|
|
12
|
+
// src/heygen/plan.ts
|
|
13
|
+
import { randomUUID } from "crypto";
|
|
14
|
+
var UNPAID = /* @__PURE__ */ new Set(["incomplete", "incomplete_expired"]);
|
|
15
|
+
var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
16
|
+
function mockPlan() {
|
|
17
|
+
const raw = process.env["HYPERFRAMES_MOCK_PLAN"]?.trim();
|
|
18
|
+
if (!raw) return null;
|
|
19
|
+
const [plan = "none", credits = "0"] = raw.split(":");
|
|
20
|
+
return { plan, credits: Number(credits) || 0, mock: true };
|
|
21
|
+
}
|
|
22
|
+
var billingBaseUrl = () => resolveCloudBaseUrl().replace("://api.", "://api2.");
|
|
23
|
+
async function readPlan() {
|
|
24
|
+
try {
|
|
25
|
+
const res = await fetch(`${billingBaseUrl()}/v1/payment/hyperframes/subscription`, {
|
|
26
|
+
headers: { ...await resolveCloudAuthHeaders(), accept: "application/json" },
|
|
27
|
+
signal: AbortSignal.timeout(15e3)
|
|
28
|
+
});
|
|
29
|
+
const body = await res.json().catch(() => null);
|
|
30
|
+
const data = isRecord(body) && isRecord(body.data) ? body.data : body;
|
|
31
|
+
if (!res.ok || !isRecord(data)) return mockPlan();
|
|
32
|
+
const usage = isRecord(data.usage) ? data.usage : {};
|
|
33
|
+
const sub = isRecord(data.subscription) ? data.subscription : null;
|
|
34
|
+
const paid = !!sub && !UNPAID.has(String(sub.status));
|
|
35
|
+
return {
|
|
36
|
+
plan: paid ? String(sub.plan_name ?? "paid") : "none",
|
|
37
|
+
credits: Number(usage.remaining_units ?? 0) || 0
|
|
38
|
+
};
|
|
39
|
+
} catch {
|
|
40
|
+
return mockPlan();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
var webBase = () => "https://hyperframes.studio";
|
|
44
|
+
var plansUrl = () => process.env["HYPERFRAMES_PLANS_URL"] || `${webBase()}/pricing`;
|
|
45
|
+
var creditsUrl = () => process.env["HYPERFRAMES_CREDITS_URL"] || `${webBase()}/pricing`;
|
|
46
|
+
async function signedInSpace() {
|
|
47
|
+
try {
|
|
48
|
+
const res = await fetch(`${billingBaseUrl()}/v1/pacific/account.get`, {
|
|
49
|
+
headers: { ...await resolveCloudAuthHeaders(), accept: "application/json" },
|
|
50
|
+
signal: AbortSignal.timeout(5e3)
|
|
51
|
+
});
|
|
52
|
+
const body = await res.json().catch(() => null);
|
|
53
|
+
const data = isRecord(body) && isRecord(body.data) ? body.data : null;
|
|
54
|
+
const id = data && isRecord(data.space_info) ? data.space_info.space_id : void 0;
|
|
55
|
+
return typeof id === "string" && /^[a-zA-Z0-9-]{1,64}$/.test(id) ? id : void 0;
|
|
56
|
+
} catch {
|
|
57
|
+
return void 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async function pageUrl(kind, fields = {}) {
|
|
61
|
+
const url = new URL(fields.base ?? (kind === "plans" ? plansUrl() : creditsUrl()));
|
|
62
|
+
url.searchParams.set("from", "cli");
|
|
63
|
+
if (fields.needed) url.searchParams.set("needed_credits", String(fields.needed));
|
|
64
|
+
if (fields.tool) url.searchParams.set("tool", fields.tool);
|
|
65
|
+
if (fields.feature) url.searchParams.set("feature", fields.feature);
|
|
66
|
+
if (fields.rs) url.searchParams.set("rs", fields.rs);
|
|
67
|
+
if (kind === "credits" && !fields.base) url.hash = "packs";
|
|
68
|
+
const space = await signedInSpace();
|
|
69
|
+
if (space) url.searchParams.set("workspace_hint", space);
|
|
70
|
+
return url.toString();
|
|
71
|
+
}
|
|
72
|
+
var int = (v) => Number.isSafeInteger(v) && v > 0 ? v : void 0;
|
|
73
|
+
async function readOffer() {
|
|
74
|
+
try {
|
|
75
|
+
const res = await fetch(`${billingBaseUrl()}/v1/payment/hyperframes/plans`, {
|
|
76
|
+
headers: { ...await resolveCloudAuthHeaders(), accept: "application/json" },
|
|
77
|
+
signal: AbortSignal.timeout(15e3)
|
|
78
|
+
});
|
|
79
|
+
const body = await res.json().catch(() => null);
|
|
80
|
+
const data = isRecord(body) && isRecord(body.data) ? body.data : body;
|
|
81
|
+
if (!res.ok || !isRecord(data)) return {};
|
|
82
|
+
const plans = Array.isArray(data.plans) ? data.plans.filter(isRecord) : [];
|
|
83
|
+
const pro = plans.find((p) => p.plan_name === "pro" && p.period === "month");
|
|
84
|
+
const a = isRecord(data.addon) && data.addons_enabled === true ? data.addon : null;
|
|
85
|
+
const offer = {};
|
|
86
|
+
if (pro && int(pro.amount) && typeof pro.currency === "string")
|
|
87
|
+
offer.pro = { amount: int(pro.amount), currency: pro.currency };
|
|
88
|
+
const [unitsPerBlock, unitAmount, min, max] = [
|
|
89
|
+
"units_per_block",
|
|
90
|
+
"unit_amount",
|
|
91
|
+
"min_quantity",
|
|
92
|
+
"max_quantity"
|
|
93
|
+
].map((k) => int(a?.[k]));
|
|
94
|
+
if (a && unitsPerBlock && unitAmount && min && max && typeof a.currency === "string")
|
|
95
|
+
offer.addon = {
|
|
96
|
+
unitsPerBlock,
|
|
97
|
+
unitAmount,
|
|
98
|
+
currency: a.currency,
|
|
99
|
+
min,
|
|
100
|
+
max,
|
|
101
|
+
recommended: int(a.recommended) ?? min
|
|
102
|
+
};
|
|
103
|
+
return offer;
|
|
104
|
+
} catch {
|
|
105
|
+
return {};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function addonBlocks(offer, missing) {
|
|
109
|
+
const blocks = missing && missing > 0 ? Math.ceil(missing / offer.unitsPerBlock) : offer.recommended;
|
|
110
|
+
return Math.min(offer.max, Math.max(offer.min, blocks));
|
|
111
|
+
}
|
|
112
|
+
var money = (cents, currency) => new Intl.NumberFormat("en-US", { style: "currency", currency: currency.toUpperCase() }).format(
|
|
113
|
+
cents / 100
|
|
114
|
+
);
|
|
115
|
+
function stripeCheckoutUrl(value) {
|
|
116
|
+
if (typeof value !== "string" || !URL.canParse(value)) return void 0;
|
|
117
|
+
const url = new URL(value);
|
|
118
|
+
return url.protocol === "https:" && url.hostname === "checkout.stripe.com" ? url.toString() : void 0;
|
|
119
|
+
}
|
|
120
|
+
async function createCheckout(kind, offer, missing) {
|
|
121
|
+
const addon = kind === "credits" ? offer.addon : void 0;
|
|
122
|
+
if (kind === "credits" && !addon)
|
|
123
|
+
throw new Error("Credits are not on sale for this account right now.");
|
|
124
|
+
const body = addon ? {
|
|
125
|
+
quantity: addonBlocks(addon, missing),
|
|
126
|
+
currency: addon.currency,
|
|
127
|
+
unit_amount: addon.unitAmount
|
|
128
|
+
} : { plan_name: "pro", period: "month", request_id: randomUUID() };
|
|
129
|
+
const res = await fetch(
|
|
130
|
+
`${billingBaseUrl()}/v1/payment/hyperframes/${addon ? "addon.checkout" : "checkout"}`,
|
|
131
|
+
{
|
|
132
|
+
method: "POST",
|
|
133
|
+
headers: {
|
|
134
|
+
...await resolveCloudAuthHeaders(),
|
|
135
|
+
accept: "application/json",
|
|
136
|
+
"content-type": "application/json"
|
|
137
|
+
},
|
|
138
|
+
body: JSON.stringify(body),
|
|
139
|
+
signal: AbortSignal.timeout(2e4)
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
const reply = await res.json().catch(() => null);
|
|
143
|
+
const data = isRecord(reply) && isRecord(reply.data) ? reply.data : reply;
|
|
144
|
+
const url = res.ok && isRecord(data) ? stripeCheckoutUrl(data.url) : void 0;
|
|
145
|
+
if (url) return url;
|
|
146
|
+
const why = isRecord(reply) && typeof reply.message === "string" ? reply.message.slice(0, 200) : `HTTP ${res.status}`;
|
|
147
|
+
throw new Error(`HeyGen would not open a checkout: ${why}`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export {
|
|
151
|
+
billingBaseUrl,
|
|
152
|
+
readPlan,
|
|
153
|
+
pageUrl,
|
|
154
|
+
readOffer,
|
|
155
|
+
addonBlocks,
|
|
156
|
+
money,
|
|
157
|
+
createCheckout
|
|
158
|
+
};
|
|
@@ -341,6 +341,7 @@ function passthroughFields(parsed) {
|
|
|
341
341
|
pendingUpdate: parsed.pendingUpdate,
|
|
342
342
|
completedUpdate: parsed.completedUpdate,
|
|
343
343
|
lastSkillsCheck: parsed.lastSkillsCheck,
|
|
344
|
+
skillsCheckedVersion: parsed.skillsCheckedVersion,
|
|
344
345
|
skillsUpdateAvailable: parsed.skillsUpdateAvailable,
|
|
345
346
|
skillsOutdatedCount: parsed.skillsOutdatedCount,
|
|
346
347
|
skillsMissingCount: parsed.skillsMissingCount,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
jsonArg,
|
|
13
13
|
num,
|
|
14
14
|
runMeasure
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-VWUUNGSV.js";
|
|
16
16
|
import {
|
|
17
17
|
idempotencyKey,
|
|
18
18
|
keepVoice,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
publicVoices,
|
|
21
21
|
runJob,
|
|
22
22
|
senderScope
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-H7H7XNYY.js";
|
|
24
24
|
import {
|
|
25
25
|
Fix,
|
|
26
26
|
probeSeconds,
|
|
@@ -30,6 +30,9 @@ import {
|
|
|
30
30
|
runFfmpeg,
|
|
31
31
|
videoClip
|
|
32
32
|
} from "./chunk-A33GFLPY.js";
|
|
33
|
+
import {
|
|
34
|
+
loadSharp
|
|
35
|
+
} from "./chunk-5UT3R43E.js";
|
|
33
36
|
import {
|
|
34
37
|
defineCommand
|
|
35
38
|
} from "./chunk-DL4OD7IA.js";
|
|
@@ -256,29 +259,41 @@ function needFile(path) {
|
|
|
256
259
|
if (!existsSync(path))
|
|
257
260
|
throw new Fix(`no file at ${path}`, "pass a picture or sound from the project");
|
|
258
261
|
}
|
|
259
|
-
var
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
path,
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
262
|
+
var FIT_2048 = "scale='min(2048,iw)':'min(2048,ih)':force_original_aspect_ratio=decrease";
|
|
263
|
+
function picturesOf(route, r) {
|
|
264
|
+
const paths = [];
|
|
265
|
+
route.body(r, (path, kind) => {
|
|
266
|
+
if (kind === "image") paths.push(path);
|
|
267
|
+
return {};
|
|
268
|
+
});
|
|
269
|
+
return paths;
|
|
270
|
+
}
|
|
271
|
+
var sharpOrNone = () => loadSharp("media-use pictures").catch(() => null);
|
|
272
|
+
async function shrunk(paths, work) {
|
|
273
|
+
const out = /* @__PURE__ */ new Map();
|
|
274
|
+
if (!paths.length) return out;
|
|
275
|
+
const sharp = await sharpOrNone();
|
|
276
|
+
for (const path of new Set(paths)) {
|
|
277
|
+
needFile(path);
|
|
278
|
+
const to = join(work, `picture-${out.size}.jpg`);
|
|
279
|
+
const viaFfmpeg = () => runFfmpeg(["-y", "-i", path, "-vf", FIT_2048, "-q:v", "3", "-frames:v", "1", to]);
|
|
280
|
+
if (!sharp) viaFfmpeg();
|
|
281
|
+
else
|
|
282
|
+
await sharp(path).rotate().resize(2048, 2048, { fit: "inside", withoutEnlargement: true }).jpeg({ quality: 90 }).toFile(to).catch(viaFfmpeg);
|
|
283
|
+
out.set(path, to);
|
|
284
|
+
}
|
|
285
|
+
return out;
|
|
286
|
+
}
|
|
287
|
+
function inline(work, pictures, masks = []) {
|
|
272
288
|
return (path, kind) => {
|
|
273
289
|
needFile(path);
|
|
274
|
-
const out = join(
|
|
290
|
+
const out = kind === "image" ? pictures.get(path) : join(
|
|
275
291
|
work,
|
|
276
|
-
`in-${Math.random().toString(36).slice(2)}.${{
|
|
292
|
+
`in-${Math.random().toString(36).slice(2)}.${{ audio: "mp3", video: "mp4" }[kind]}`
|
|
277
293
|
);
|
|
278
|
-
if (kind === "
|
|
279
|
-
else if (kind === "audio")
|
|
294
|
+
if (kind === "audio")
|
|
280
295
|
runFfmpeg(["-y", "-i", path, "-vn", "-ac", "1", "-c:a", "libmp3lame", "-b:a", "128k", out]);
|
|
281
|
-
else {
|
|
296
|
+
else if (kind === "video") {
|
|
282
297
|
const guide = masks.length ? fillMasks(path, masks, work) : path;
|
|
283
298
|
const scale = "scale='if(gt(iw,ih),min(720,iw),-2)':'if(gt(iw,ih),-2,min(720,ih))'";
|
|
284
299
|
runFfmpeg([
|
|
@@ -303,7 +318,7 @@ async function uploaded(paths) {
|
|
|
303
318
|
if (!paths.length) return ids;
|
|
304
319
|
const { createCloudClient } = await import("./cloud-Z3FNCC4T.js");
|
|
305
320
|
const { uploadAssetViaDirectUpload } = await import("./upload-L5TSWWIU.js");
|
|
306
|
-
const { getMimeType } = await import("./dist-
|
|
321
|
+
const { getMimeType } = await import("./dist-PUHEYGA5.js");
|
|
307
322
|
const client = await createCloudClient();
|
|
308
323
|
for (const path of paths) {
|
|
309
324
|
const asset = await uploadAssetViaDirectUpload({
|
|
@@ -405,11 +420,11 @@ function fitAspect(out, aspect) {
|
|
|
405
420
|
renameSync(fitted, out);
|
|
406
421
|
return `HeyGen returned ${width}x${height} for ${aspect}; cropped to ${w}x${h} (centre), not stretched`;
|
|
407
422
|
}
|
|
408
|
-
function aspectOf(r,
|
|
423
|
+
async function aspectOf(r, pictures) {
|
|
409
424
|
if (r.aspect || !r.firstFrame) return r.aspect ?? "16:9";
|
|
410
|
-
const sent =
|
|
411
|
-
|
|
412
|
-
const { width, height } = probeVideo(sent);
|
|
425
|
+
const sent = pictures.get(r.firstFrame);
|
|
426
|
+
const sharp = await sharpOrNone();
|
|
427
|
+
const { width, height } = sharp ? await sharp(sent).metadata() : probeVideo(sent);
|
|
413
428
|
return `${width}:${height}`;
|
|
414
429
|
}
|
|
415
430
|
var MIN_SHOT_S = 0.15;
|
|
@@ -492,7 +507,8 @@ async function generate(r, onWait, credits) {
|
|
|
492
507
|
try {
|
|
493
508
|
const sources = assetsOf(r);
|
|
494
509
|
const ids = await uploaded(sources);
|
|
495
|
-
const
|
|
510
|
+
const pictures = await shrunk(picturesOf(route, r), work);
|
|
511
|
+
const local = inline(work, pictures, r.masks);
|
|
496
512
|
const body = route.body(
|
|
497
513
|
r,
|
|
498
514
|
(path, kind) => ids.has(path) ? { type: "asset_id", asset_id: ids.get(path) } : local(path, kind)
|
|
@@ -531,7 +547,7 @@ async function generate(r, onWait, credits) {
|
|
|
531
547
|
const notes = [];
|
|
532
548
|
if (r.type === "video")
|
|
533
549
|
try {
|
|
534
|
-
const note = fitAspect(out, aspectOf(r,
|
|
550
|
+
const note = fitAspect(out, await aspectOf(r, pictures));
|
|
535
551
|
if (note) notes.push(note);
|
|
536
552
|
} catch (e) {
|
|
537
553
|
notes.push(`kept HeyGen's size, could not crop: ${e instanceof Error ? e.message : e}`);
|
|
@@ -6,7 +6,7 @@ var __filename = __hf_fileURLToPath(import.meta.url);
|
|
|
6
6
|
var __dirname = __hf_dirname(__filename);
|
|
7
7
|
import {
|
|
8
8
|
VERSION
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-I4XTKG2B.js";
|
|
10
10
|
|
|
11
11
|
// src/registry/compatibility.ts
|
|
12
12
|
import { compareVersions } from "compare-versions";
|
|
@@ -6,13 +6,13 @@ var __filename = __hf_fileURLToPath(import.meta.url);
|
|
|
6
6
|
var __dirname = __hf_dirname(__filename);
|
|
7
7
|
import {
|
|
8
8
|
getMimeType
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4J4EGANW.js";
|
|
10
10
|
import {
|
|
11
11
|
openRangeEnd
|
|
12
12
|
} from "./chunk-VEIGTKYZ.js";
|
|
13
13
|
import {
|
|
14
14
|
stripSdrPngColourTags
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-JS6ZTPYC.js";
|
|
16
16
|
import {
|
|
17
17
|
injectTagsAtHeadStart
|
|
18
18
|
} from "./chunk-Y3ICFPFK.js";
|
|
@@ -17,7 +17,7 @@ function resolveLocalBrowserGpuMode(browserGpuArg, envMode = process.env.PRODUCE
|
|
|
17
17
|
return "auto";
|
|
18
18
|
}
|
|
19
19
|
async function resolveCaptureBrowserGpuMode(requestedMode, chromePath, probeLifecycle) {
|
|
20
|
-
const { resolveBrowserGpuMode } = await import("./src-
|
|
20
|
+
const { resolveBrowserGpuMode } = await import("./src-L7UBHHKB.js");
|
|
21
21
|
return resolveBrowserGpuMode(requestedMode, { chromePath, probeLifecycle });
|
|
22
22
|
}
|
|
23
23
|
function resolveLocalWebGpu(browserGpuMode, requiresWebGpu) {
|
|
@@ -6,7 +6,7 @@ var __filename = __hf_fileURLToPath(import.meta.url);
|
|
|
6
6
|
var __dirname = __hf_dirname(__filename);
|
|
7
7
|
import {
|
|
8
8
|
pageUrl
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-AHLDGEH5.js";
|
|
10
10
|
import {
|
|
11
11
|
Fix
|
|
12
12
|
} from "./chunk-A33GFLPY.js";
|
|
@@ -15,23 +15,50 @@ import {
|
|
|
15
15
|
resolveCloudAuthHeaders,
|
|
16
16
|
resolveCloudBaseUrl
|
|
17
17
|
} from "./chunk-TSQZ3DSC.js";
|
|
18
|
-
import {
|
|
19
|
-
HyperframesApiError,
|
|
20
|
-
HyperframesCloudClient
|
|
21
|
-
} from "./chunk-3XJM7XZN.js";
|
|
22
18
|
import {
|
|
23
19
|
AuthClient,
|
|
24
20
|
buildAuthHeaders,
|
|
25
21
|
resolveCredential
|
|
26
22
|
} from "./chunk-ETYQYG6Q.js";
|
|
23
|
+
import {
|
|
24
|
+
HyperframesApiError,
|
|
25
|
+
HyperframesCloudClient
|
|
26
|
+
} from "./chunk-3XJM7XZN.js";
|
|
27
27
|
import {
|
|
28
28
|
configDir
|
|
29
29
|
} from "./chunk-BVAPHHMQ.js";
|
|
30
30
|
|
|
31
31
|
// src/heygen/v3.ts
|
|
32
32
|
import { createHash } from "crypto";
|
|
33
|
-
import { appendFileSync, existsSync, mkdirSync, readFileSync } from "fs";
|
|
34
|
-
import { dirname, join } from "path";
|
|
33
|
+
import { appendFileSync, existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2 } from "fs";
|
|
34
|
+
import { dirname, join as join2 } from "path";
|
|
35
|
+
|
|
36
|
+
// src/media-use/lib/credit-limit.mjs
|
|
37
|
+
import { existsSync, readFileSync } from "fs";
|
|
38
|
+
import { join } from "path";
|
|
39
|
+
var read = (file) => existsSync(file) ? readFileSync(file, "utf8") : "";
|
|
40
|
+
function creditLimit(projectDir) {
|
|
41
|
+
const text = read(join(projectDir, ".hyperframes", "credit-limit.json"));
|
|
42
|
+
if (!text) return void 0;
|
|
43
|
+
const credits = Number(JSON.parse(text)?.credits);
|
|
44
|
+
if (!Number.isFinite(credits) || credits < 0)
|
|
45
|
+
throw new Error(`${projectDir}/.hyperframes/credit-limit.json needs {"credits": <number>}`);
|
|
46
|
+
return credits;
|
|
47
|
+
}
|
|
48
|
+
function creditsSpent(projectDir) {
|
|
49
|
+
const charged = /* @__PURE__ */ new Map();
|
|
50
|
+
for (const row of read(join(projectDir, ".hyperframes", "heygen-jobs.jsonl")).split("\n")) {
|
|
51
|
+
if (!row) continue;
|
|
52
|
+
const { key, credits } = JSON.parse(row);
|
|
53
|
+
if (key && typeof credits === "number") charged.set(key, credits);
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
total: [...charged.values()].reduce((a, b) => a + b, 0),
|
|
57
|
+
keys: new Set([...charged].filter(([, c]) => c > 0).map(([k]) => k))
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/heygen/v3.ts
|
|
35
62
|
var RUNNING = /* @__PURE__ */ new Set(["pending", "processing", "queued", "running", "waiting", "in_progress"]);
|
|
36
63
|
var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
37
64
|
function idempotencyKey(route, parts) {
|
|
@@ -43,7 +70,7 @@ var Refused = class extends Fix {
|
|
|
43
70
|
status = 0;
|
|
44
71
|
};
|
|
45
72
|
var KEEPS_KEY = /* @__PURE__ */ new Set([401, 403, 408, 409, 425, 429]);
|
|
46
|
-
var failedKeysFile = () =>
|
|
73
|
+
var failedKeysFile = () => join2(configDir(), "heygen-failed-keys");
|
|
47
74
|
var noSignIn = () => {
|
|
48
75
|
throw new Fix("no HeyGen sign-in on this machine", "npx hyperframes auth login");
|
|
49
76
|
};
|
|
@@ -58,7 +85,7 @@ async function jobSender() {
|
|
|
58
85
|
}
|
|
59
86
|
function failedKeys(scope) {
|
|
60
87
|
const file = failedKeysFile();
|
|
61
|
-
const lines =
|
|
88
|
+
const lines = existsSync2(file) ? readFileSync2(file, "utf8").split("\n") : [];
|
|
62
89
|
return new Set(
|
|
63
90
|
lines.filter((l) => l.startsWith(`${scope} `)).map((l) => l.slice(scope.length + 1))
|
|
64
91
|
);
|
|
@@ -75,7 +102,7 @@ function liveKey(key, scope) {
|
|
|
75
102
|
for (let n = 1; failed.has(sent); n++) sent = `${key}-${n}`;
|
|
76
103
|
return sent;
|
|
77
104
|
}
|
|
78
|
-
function refusal(status, body, estimate) {
|
|
105
|
+
async function refusal(status, body, estimate) {
|
|
79
106
|
const err = isRecord(body) && isRecord(body.error) ? body.error : isRecord(body) ? body : {};
|
|
80
107
|
const code = String(err.code ?? err.failure_code ?? "");
|
|
81
108
|
const message = String(err.message ?? err.failure_message ?? "").slice(0, 300);
|
|
@@ -87,12 +114,12 @@ function refusal(status, body, estimate) {
|
|
|
87
114
|
if (/hf_subscription_required/i.test(code))
|
|
88
115
|
return new Refused(
|
|
89
116
|
`this is a HyperFrames Pro feature; nothing was charged. Run \`npx hyperframes billing subscribe\`: it opens the page and waits`,
|
|
90
|
-
`Subscribe: ${url ?? pageUrl("plans", { needed })}`
|
|
117
|
+
`Subscribe: ${url ?? await pageUrl("plans", { needed })}`
|
|
91
118
|
);
|
|
92
119
|
if (/hf_usage_exhausted/i.test(code))
|
|
93
120
|
return new Refused(
|
|
94
|
-
`out of HyperFrames credits (this step needs ${needs}${balance}); nothing was charged. Run \`npx hyperframes billing
|
|
95
|
-
`
|
|
121
|
+
`out of HyperFrames credits (this step needs ${needs}${balance}); nothing was charged. Run \`npx hyperframes billing add-credits${needed ? ` --needed ${needed}` : ""}\`: it opens the page and waits`,
|
|
122
|
+
`Buy add-on credits: ${url ?? await pageUrl("credits", { needed })}`
|
|
96
123
|
);
|
|
97
124
|
if (/api_key_required/i.test(code))
|
|
98
125
|
return new Refused(
|
|
@@ -107,7 +134,7 @@ function refusal(status, body, estimate) {
|
|
|
107
134
|
if (status === 402 || /insufficient|credit|usage_exhausted|quota/i.test(code))
|
|
108
135
|
return new Refused(
|
|
109
136
|
`HeyGen says there is not enough credit (${code || status})`,
|
|
110
|
-
"
|
|
137
|
+
"buy add-on credits at https://app.heygen.com, or sign in with npx hyperframes auth login to use the plan's allowance"
|
|
111
138
|
);
|
|
112
139
|
if (/content_policy/i.test(code))
|
|
113
140
|
return new Refused(
|
|
@@ -134,7 +161,7 @@ async function call(route, send, timeoutMs, estimate, auth) {
|
|
|
134
161
|
);
|
|
135
162
|
if (err.status >= 500 || err.status < 300 || err.raw == null)
|
|
136
163
|
throw new Fix(`HeyGen ${err.status} for ${route} with no readable answer`, resume);
|
|
137
|
-
const refused = refusal(err.status, err.raw, estimate);
|
|
164
|
+
const refused = await refusal(err.status, err.raw, estimate);
|
|
138
165
|
refused.status = err.status;
|
|
139
166
|
throw refused;
|
|
140
167
|
}
|
|
@@ -150,19 +177,41 @@ async function call(route, send, timeoutMs, estimate, auth) {
|
|
|
150
177
|
}
|
|
151
178
|
function log(entry, record) {
|
|
152
179
|
if (!entry.projectDir) return;
|
|
153
|
-
const dir =
|
|
180
|
+
const dir = join2(entry.projectDir, ".hyperframes");
|
|
154
181
|
mkdirSync(dir, { recursive: true });
|
|
155
182
|
appendFileSync(
|
|
156
|
-
|
|
183
|
+
join2(dir, "heygen-jobs.jsonl"),
|
|
157
184
|
`${JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), what: entry.what, ...record })}
|
|
158
185
|
`
|
|
159
186
|
);
|
|
160
187
|
}
|
|
188
|
+
function withinLimit(limitLog, sent, credits) {
|
|
189
|
+
if (!limitLog?.projectDir) return false;
|
|
190
|
+
const limit = creditLimit(limitLog.projectDir);
|
|
191
|
+
if (limit === void 0) return false;
|
|
192
|
+
const spent = creditsSpent(limitLog.projectDir);
|
|
193
|
+
if (spent.keys.has(sent)) return false;
|
|
194
|
+
const left = limit - spent.total;
|
|
195
|
+
const fix = "tell the person what their limit leaves out, then ask whether to raise it or make the video without this piece";
|
|
196
|
+
if (credits === void 0)
|
|
197
|
+
throw new Fix(
|
|
198
|
+
`this call cannot be priced ahead, so it cannot be kept under the run's credit limit of ${limit}; nothing was made`,
|
|
199
|
+
fix
|
|
200
|
+
);
|
|
201
|
+
if (credits > left)
|
|
202
|
+
throw new Fix(
|
|
203
|
+
`this call is about ${credits} credits and the run's credit limit of ${limit} leaves ${Math.max(0, left)}; nothing was made or charged`,
|
|
204
|
+
fix
|
|
205
|
+
);
|
|
206
|
+
log(limitLog, { key: sent, status: "reserved", credits });
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
161
209
|
async function runJob(jobRoute, body, key, opts = {}) {
|
|
162
210
|
const started = Date.now();
|
|
163
211
|
const route = jobRoute.path;
|
|
164
212
|
const { auth, scope } = await jobSender();
|
|
165
213
|
const sent = liveKey(key, scope);
|
|
214
|
+
const reserved = withinLimit(opts.log, sent, opts.credits);
|
|
166
215
|
let job;
|
|
167
216
|
try {
|
|
168
217
|
job = await call(
|
|
@@ -173,11 +222,15 @@ async function runJob(jobRoute, body, key, opts = {}) {
|
|
|
173
222
|
auth
|
|
174
223
|
);
|
|
175
224
|
} catch (err) {
|
|
176
|
-
if (err instanceof Refused && !KEEPS_KEY.has(err.status))
|
|
225
|
+
if (err instanceof Refused && !KEEPS_KEY.has(err.status)) {
|
|
226
|
+
markFailed(sent, scope);
|
|
227
|
+
if (reserved && opts.log) log(opts.log, { key: sent, status: "refused", credits: 0 });
|
|
228
|
+
}
|
|
177
229
|
throw err;
|
|
178
230
|
}
|
|
179
231
|
const waits = RUNNING.has(job.status.toLowerCase());
|
|
180
|
-
if (opts.log && waits)
|
|
232
|
+
if (opts.log && waits)
|
|
233
|
+
log(opts.log, { route, id: job.id, key: sent, status: job.status, credits: opts.credits });
|
|
181
234
|
const status = jobRoute.status;
|
|
182
235
|
while (status && RUNNING.has(job.status.toLowerCase())) {
|
|
183
236
|
if (Date.now() - started > (opts.timeoutMs ?? 15 * 6e4))
|
|
@@ -194,21 +247,25 @@ async function runJob(jobRoute, body, key, opts = {}) {
|
|
|
194
247
|
3e4
|
|
195
248
|
);
|
|
196
249
|
}
|
|
197
|
-
if (opts.log)
|
|
250
|
+
if (opts.log)
|
|
251
|
+
log(opts.log, { route, id: job.id, key: sent, status: job.status, credits: opts.credits });
|
|
198
252
|
if (!/^(completed|succeeded|success|done)$/i.test(job.status)) {
|
|
199
253
|
markFailed(sent, scope);
|
|
200
|
-
throw refusal(422, {
|
|
254
|
+
throw await refusal(422, {
|
|
201
255
|
error: { code: job.failure_code ?? job.status, message: job.failure_message ?? "" }
|
|
202
256
|
});
|
|
203
257
|
}
|
|
204
258
|
return job;
|
|
205
259
|
}
|
|
206
260
|
var isVoice = (v) => isRecord(v) && typeof v.voice_id === "string" && typeof v.name === "string";
|
|
207
|
-
async function
|
|
261
|
+
async function listVoices(query, limit) {
|
|
208
262
|
const client = clientFor(await resolveCloudAuthHeaders().catch(noSignIn));
|
|
209
|
-
const value = await client.listVoicesV3({
|
|
263
|
+
const value = await client.listVoicesV3({ ...query, limit, signal: AbortSignal.timeout(3e4) }).catch((err) => {
|
|
210
264
|
if (err instanceof HyperframesApiError)
|
|
211
|
-
throw new Fix(
|
|
265
|
+
throw new Fix(
|
|
266
|
+
`HeyGen ${err.status} listing its voices`,
|
|
267
|
+
err.status === 401 || err.status === 403 ? "npx hyperframes auth login" : "run the same command again"
|
|
268
|
+
);
|
|
212
269
|
throw new Fix(
|
|
213
270
|
`no answer from HeyGen for its voices (${err instanceof Error ? err.message : String(err)})`,
|
|
214
271
|
"run the same command again"
|
|
@@ -216,16 +273,18 @@ async function publicVoices(language, limit) {
|
|
|
216
273
|
});
|
|
217
274
|
if (!isRecord(value) || !Array.isArray(value.data))
|
|
218
275
|
throw new Fix("HeyGen answered its voices with no list", "run the same command again");
|
|
219
|
-
return value.data.filter(isVoice).map(({ voice_id, name, language
|
|
276
|
+
return value.data.filter(isVoice).map(({ voice_id, name, language, gender }) => ({ voice_id, name, language, gender }));
|
|
220
277
|
}
|
|
278
|
+
var publicVoices = (language, limit) => listVoices({ type: "public", language }, limit);
|
|
279
|
+
var ownVoices = (limit) => listVoices({ type: "private" }, limit);
|
|
221
280
|
async function senderScope() {
|
|
222
281
|
return (await jobSender()).scope;
|
|
223
282
|
}
|
|
224
|
-
var picksFile = (projectDir) => projectDir ?
|
|
283
|
+
var picksFile = (projectDir) => projectDir ? join2(projectDir, ".hyperframes", "heygen-jobs.jsonl") : join2(configDir(), "heygen-voice-picks.jsonl");
|
|
225
284
|
function keptVoice(projectDir, request) {
|
|
226
285
|
const file = picksFile(projectDir);
|
|
227
|
-
if (!
|
|
228
|
-
for (const line of
|
|
286
|
+
if (!existsSync2(file)) return void 0;
|
|
287
|
+
for (const line of readFileSync2(file, "utf8").split("\n")) {
|
|
229
288
|
const entry = line ? JSON.parse(line) : null;
|
|
230
289
|
if (isRecord(entry) && entry.voice_pick === request && isVoice(entry.voice)) return entry.voice;
|
|
231
290
|
}
|
|
@@ -245,6 +304,7 @@ export {
|
|
|
245
304
|
idempotencyKey,
|
|
246
305
|
runJob,
|
|
247
306
|
publicVoices,
|
|
307
|
+
ownVoices,
|
|
248
308
|
senderScope,
|
|
249
309
|
keptVoice,
|
|
250
310
|
keepVoice
|
|
@@ -6,8 +6,8 @@ var __filename = __hf_fileURLToPath(import.meta.url);
|
|
|
6
6
|
var __dirname = __hf_dirname(__filename);
|
|
7
7
|
|
|
8
8
|
// src/version.ts
|
|
9
|
-
var VERSION = true ? "0.9.
|
|
10
|
-
var PRODUCER_VERSION = true ? "0.9.
|
|
9
|
+
var VERSION = true ? "0.9.11" : "0.0.0-dev";
|
|
10
|
+
var PRODUCER_VERSION = true ? "0.9.11" : "0.0.0-dev";
|
|
11
11
|
|
|
12
12
|
export {
|
|
13
13
|
VERSION,
|