@koda-sl/baker-cli 0.380.0-dev.824ccf426 → 0.380.0-dev.d26778d3f
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 +112 -85
- package/dist/{chunk-XHC4LMK4.js → chunk-2QXMPTHG.js} +18 -19
- package/dist/chunk-2QXMPTHG.js.map +1 -0
- package/dist/{chunk-HJEMOSPH.js → chunk-7YNOGIWQ.js} +2 -439
- package/dist/chunk-7YNOGIWQ.js.map +1 -0
- package/dist/{chunk-VZEDAFAR.js → chunk-IZOAYU2G.js} +2 -2
- package/dist/{chunk-VLUGGVJL.js → chunk-PGYWZEAW.js} +4 -9
- package/dist/{chunk-VLUGGVJL.js.map → chunk-PGYWZEAW.js.map} +1 -1
- package/dist/{chunk-HOMVJ2D3.js → chunk-RK44ZR7L.js} +112 -200
- package/dist/chunk-RK44ZR7L.js.map +1 -0
- package/dist/{chunk-MF7YA62W.js → chunk-UMIALY2G.js} +3 -3
- package/dist/cli.js +7869 -5119
- package/dist/cli.js.map +1 -1
- package/dist/{client-GR6YL3YX.js → client-OTWPBCHC.js} +4 -4
- package/dist/engine/index.js +3 -3
- package/dist/{env-4P5HOGNA.js → env-P7YVNPZ6.js} +2 -2
- package/dist/{output-NMQXZF3Z.js → output-WCDFLOHZ.js} +5 -5
- package/dist/{shared-J7DQZ2ED.js → shared-JZJ6PVJ7.js} +6 -8
- package/package.json +1 -2
- package/dist/chunk-HJEMOSPH.js.map +0 -1
- package/dist/chunk-HOMVJ2D3.js.map +0 -1
- package/dist/chunk-XHC4LMK4.js.map +0 -1
- /package/dist/{chunk-VZEDAFAR.js.map → chunk-IZOAYU2G.js.map} +0 -0
- /package/dist/{chunk-MF7YA62W.js.map → chunk-UMIALY2G.js.map} +0 -0
- /package/dist/{client-GR6YL3YX.js.map → client-OTWPBCHC.js.map} +0 -0
- /package/dist/{env-4P5HOGNA.js.map → env-P7YVNPZ6.js.map} +0 -0
- /package/dist/{output-NMQXZF3Z.js.map → output-WCDFLOHZ.js.map} +0 -0
- /package/dist/{shared-J7DQZ2ED.js.map → shared-JZJ6PVJ7.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
debugLogHttp,
|
|
3
3
|
readBodyForLog
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-IZOAYU2G.js";
|
|
5
5
|
import {
|
|
6
6
|
API_KEY_FORMAT_MESSAGE,
|
|
7
7
|
DIRECT_ROUTE,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
refuseNonPublicUrl,
|
|
19
19
|
requireConnection,
|
|
20
20
|
shouldEscalate
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-7YNOGIWQ.js";
|
|
22
22
|
|
|
23
23
|
// ../../.pnpm-store/v10/links/@/safe-stable-stringify/2.5.0/766ad107c42df28eeadaf0ac2f9089c8a9e200f6ba0b2b1a817b8d536cbdcc49/node_modules/safe-stable-stringify/index.js
|
|
24
24
|
var require_safe_stable_stringify = __commonJS({
|
|
@@ -617,7 +617,7 @@ ${originalIndentation}`;
|
|
|
617
617
|
});
|
|
618
618
|
|
|
619
619
|
// src/engine/index.ts
|
|
620
|
-
import
|
|
620
|
+
import path18 from "path";
|
|
621
621
|
|
|
622
622
|
// src/engine/client/http.ts
|
|
623
623
|
var CONTENT_POLICY_CODE = "content_policy_blocked";
|
|
@@ -666,17 +666,17 @@ var HttpClient = class {
|
|
|
666
666
|
this.fetchFn = opts.fetchFn ?? fetch;
|
|
667
667
|
this.sleepFn = opts.sleepFn ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
668
668
|
}
|
|
669
|
-
async postJson(
|
|
670
|
-
return await this.requestJson("POST",
|
|
669
|
+
async postJson(path19, body, signal) {
|
|
670
|
+
return await this.requestJson("POST", path19, body, signal);
|
|
671
671
|
}
|
|
672
|
-
async putJson(
|
|
673
|
-
return await this.requestJson("PUT",
|
|
672
|
+
async putJson(path19, body, signal) {
|
|
673
|
+
return await this.requestJson("PUT", path19, body, signal);
|
|
674
674
|
}
|
|
675
|
-
async getJson(
|
|
676
|
-
return await this.requestJson("GET",
|
|
675
|
+
async getJson(path19, signal) {
|
|
676
|
+
return await this.requestJson("GET", path19, void 0, signal);
|
|
677
677
|
}
|
|
678
|
-
async requestJson(method,
|
|
679
|
-
const url = `${this.baseUrl}${
|
|
678
|
+
async requestJson(method, path19, body, signal) {
|
|
679
|
+
const url = `${this.baseUrl}${path19.startsWith("/") ? path19 : `/${path19}`}`;
|
|
680
680
|
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
681
681
|
const outcome = await this.attempt(method, url, body, attempt, signal);
|
|
682
682
|
if (outcome.kind === "value") return outcome.value;
|
|
@@ -852,12 +852,12 @@ var BackendClient = class {
|
|
|
852
852
|
}
|
|
853
853
|
async pollJob(jobId, signal) {
|
|
854
854
|
const deadline = Date.now() + JOB_POLL_MAX_MS;
|
|
855
|
-
const
|
|
855
|
+
const path19 = `/api/canvas/jobs/${encodeURIComponent(jobId)}`;
|
|
856
856
|
for (let attempt = 0; ; attempt++) {
|
|
857
857
|
if (signal?.aborted) {
|
|
858
858
|
throw new BackendHttpError({ kind: "network", cause: signal.reason ?? new Error("aborted") });
|
|
859
859
|
}
|
|
860
|
-
const job = await this.http.getJson(
|
|
860
|
+
const job = await this.http.getJson(path19, signal);
|
|
861
861
|
if (job.status === "completed") return job.result;
|
|
862
862
|
if (job.status === "failed") throw failedJobError(job.error);
|
|
863
863
|
if (Date.now() > deadline) {
|
|
@@ -936,8 +936,8 @@ var BackendClient = class {
|
|
|
936
936
|
await this.http.postJson("/api/creatives/definition", payload, signal);
|
|
937
937
|
}
|
|
938
938
|
getArtifact(kind, name, version, signal) {
|
|
939
|
-
const
|
|
940
|
-
return this.http.getJson(
|
|
939
|
+
const path19 = version ? `/api/canvas/artifacts/${encodeURIComponent(kind)}/${encodeURIComponent(name)}/${encodeURIComponent(version)}` : `/api/canvas/artifacts/${encodeURIComponent(kind)}/${encodeURIComponent(name)}`;
|
|
940
|
+
return this.http.getJson(path19, signal);
|
|
941
941
|
}
|
|
942
942
|
};
|
|
943
943
|
|
|
@@ -1014,15 +1014,6 @@ var LayerExecutionError = class extends CanvasError {
|
|
|
1014
1014
|
function describeFailureReason(reason) {
|
|
1015
1015
|
return reason instanceof Error ? reason.message : String(reason);
|
|
1016
1016
|
}
|
|
1017
|
-
function isInputRejection(reason) {
|
|
1018
|
-
if (!(reason instanceof NodeExecutionError) || reason.cause.kind !== "remote") return false;
|
|
1019
|
-
const { status, provider } = reason.cause;
|
|
1020
|
-
return (status === 400 || status === 422) && provider === void 0;
|
|
1021
|
-
}
|
|
1022
|
-
function runFailureCode(e) {
|
|
1023
|
-
const reasons = e instanceof LayerExecutionError ? e.failures.map((f) => f.reason) : [e];
|
|
1024
|
-
return reasons.length > 0 && reasons.every(isInputRejection) ? "input_invalid" : "runtime";
|
|
1025
|
-
}
|
|
1026
1017
|
function failureDetail(reason) {
|
|
1027
1018
|
if (reason instanceof NodeExecutionError) {
|
|
1028
1019
|
const c = reason.cause;
|
|
@@ -3414,8 +3405,8 @@ function nodesBeforeCheckpoint(graph, types, stopKinds) {
|
|
|
3414
3405
|
}
|
|
3415
3406
|
|
|
3416
3407
|
// src/engine/engine/validator.ts
|
|
3417
|
-
import { readFile as
|
|
3418
|
-
import
|
|
3408
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
3409
|
+
import path3 from "path";
|
|
3419
3410
|
import { z as z2 } from "zod";
|
|
3420
3411
|
|
|
3421
3412
|
// src/engine/lib/url.ts
|
|
@@ -3655,75 +3646,6 @@ function didYouMean(query, candidates, max = 3) {
|
|
|
3655
3646
|
return scored.slice(0, max).map((s) => s.c);
|
|
3656
3647
|
}
|
|
3657
3648
|
|
|
3658
|
-
// src/engine/engine/prompt-limit.ts
|
|
3659
|
-
import { readFile as readFile2 } from "fs/promises";
|
|
3660
|
-
import path3 from "path";
|
|
3661
|
-
var PROMPT_OVER_MODEL_LIMIT = "PROMPT_OVER_MODEL_LIMIT";
|
|
3662
|
-
async function staticTextOf(value, nodes) {
|
|
3663
|
-
if (typeof value !== "string") return void 0;
|
|
3664
|
-
if (!value.startsWith(REF_PREFIX)) return value;
|
|
3665
|
-
const expr = parseRefExpr(value);
|
|
3666
|
-
if (!expr || expr.kind !== "ref" || expr.index !== void 0) return void 0;
|
|
3667
|
-
const target = nodes.get(expr.nodeId);
|
|
3668
|
-
const params = target?.params ?? {};
|
|
3669
|
-
if (target?.type === "text" && expr.output === "text" && typeof params.value === "string") return params.value;
|
|
3670
|
-
if (target?.type === "ingest" && expr.output === "asset" && params.source === "path" && (params.expect === "json" || params.expect === "text") && typeof params.path === "string" && path3.isAbsolute(params.path)) {
|
|
3671
|
-
try {
|
|
3672
|
-
return await readFile2(params.path, "utf8");
|
|
3673
|
-
} catch {
|
|
3674
|
-
return void 0;
|
|
3675
|
-
}
|
|
3676
|
-
}
|
|
3677
|
-
return void 0;
|
|
3678
|
-
}
|
|
3679
|
-
function cappedParamsOf(n) {
|
|
3680
|
-
if (!isManagedNodeKind(n.type)) return [];
|
|
3681
|
-
const model = n.params?.model;
|
|
3682
|
-
if (typeof model !== "string") return [];
|
|
3683
|
-
const spec = MODEL_REGISTRY[n.type][model];
|
|
3684
|
-
if (!spec) return [];
|
|
3685
|
-
return Object.entries(spec.params).flatMap(
|
|
3686
|
-
([key, schema]) => schema.kind === "string" && schema.maxLength !== void 0 ? [{ key, max: schema.maxLength, model }] : []
|
|
3687
|
-
);
|
|
3688
|
-
}
|
|
3689
|
-
async function filledParam(n, raw, nodes) {
|
|
3690
|
-
const template = await staticTextOf(raw, nodes);
|
|
3691
|
-
if (template === void 0) return void 0;
|
|
3692
|
-
const names = extractSlots(template);
|
|
3693
|
-
if (names.length === 0 && template === raw) return void 0;
|
|
3694
|
-
const inputs = n.inputs ?? {};
|
|
3695
|
-
const slots = {};
|
|
3696
|
-
for (const name of names) {
|
|
3697
|
-
const text = await staticTextOf(inputs[name], nodes);
|
|
3698
|
-
if (text !== void 0) slots[name] = text;
|
|
3699
|
-
}
|
|
3700
|
-
return { length: renderTemplate(template, slots).length, slots };
|
|
3701
|
-
}
|
|
3702
|
-
function largestSlotNote(slots) {
|
|
3703
|
-
const largest = Object.entries(slots).sort((a, b) => b[1].length - a[1].length)[0];
|
|
3704
|
-
return largest ? `; {{${largest[0]}}} alone is ${largest[1].length}` : "";
|
|
3705
|
-
}
|
|
3706
|
-
async function filledPromptLimitIssues(canvas) {
|
|
3707
|
-
const nodes = new Map(canvas.nodes.map((n) => [n.id, n]));
|
|
3708
|
-
const issues = [];
|
|
3709
|
-
for (const [i, n] of canvas.nodes.entries()) {
|
|
3710
|
-
for (const { key, max, model } of cappedParamsOf(n)) {
|
|
3711
|
-
const filled = await filledParam(n, n.params?.[key], nodes);
|
|
3712
|
-
if (!filled || filled.length <= max) continue;
|
|
3713
|
-
issues.push({
|
|
3714
|
-
path: `nodes[${i}].params.${key}`,
|
|
3715
|
-
code: PROMPT_OVER_MODEL_LIMIT,
|
|
3716
|
-
message: `"${n.id}" ${key} is ${filled.length} characters once its slots are filled \u2014 ${filled.length - max} over the ${max} that "${model}" accepts` + largestSlotNote(filled.slots) + `. Shorten it before running: the model refuses it, after every node before "${n.id}" has already been paid for.`,
|
|
3717
|
-
received: filled.length,
|
|
3718
|
-
expected: `<= ${max} characters`,
|
|
3719
|
-
node_id: n.id,
|
|
3720
|
-
node_type: n.type
|
|
3721
|
-
});
|
|
3722
|
-
}
|
|
3723
|
-
}
|
|
3724
|
-
return issues;
|
|
3725
|
-
}
|
|
3726
|
-
|
|
3727
3649
|
// src/engine/engine/validator.ts
|
|
3728
3650
|
var MODEL_INPUT_KINDS = /* @__PURE__ */ new Set(["image", "video", "audio"]);
|
|
3729
3651
|
var STAGE_CODES = {
|
|
@@ -3879,7 +3801,6 @@ async function validateCanvasDeep(input, registry) {
|
|
|
3879
3801
|
}
|
|
3880
3802
|
}
|
|
3881
3803
|
await checkOverlayTimingBounds(canvas, issues);
|
|
3882
|
-
issues.push(...await filledPromptLimitIssues(canvas));
|
|
3883
3804
|
const hasBlocking = issues.some(isBlocking);
|
|
3884
3805
|
if (hasBlocking) return { ok: false, issues };
|
|
3885
3806
|
const warnings = [...shallow.warnings ?? [], ...issues.filter((i) => !isBlocking(i))];
|
|
@@ -4167,8 +4088,8 @@ async function checkOverlayTimingBounds(canvas, issues) {
|
|
|
4167
4088
|
const n = canvas.nodes[i];
|
|
4168
4089
|
if (n?.type !== "hyperframe_render") continue;
|
|
4169
4090
|
const composition = n.params?.composition;
|
|
4170
|
-
if (typeof composition !== "string" || !
|
|
4171
|
-
const html = await
|
|
4091
|
+
if (typeof composition !== "string" || !path3.isAbsolute(composition)) continue;
|
|
4092
|
+
const html = await readFile2(path3.join(composition, "index.html"), "utf8").catch(() => null);
|
|
4172
4093
|
if (!html) continue;
|
|
4173
4094
|
for (const w of overlayTimingIssues(html, durationS)) {
|
|
4174
4095
|
issues.push({
|
|
@@ -4177,7 +4098,7 @@ async function checkOverlayTimingBounds(canvas, issues) {
|
|
|
4177
4098
|
severity: "warning",
|
|
4178
4099
|
node_id: n.id,
|
|
4179
4100
|
node_type: n.type,
|
|
4180
|
-
message: `an overlay in ${
|
|
4101
|
+
message: `an overlay in ${path3.basename(composition)}/index.html runs [${w.start}s, ${w.start + w.dur}s] but the video ends at ${durationS}s \u2014 it never hides on screen. Re-time its data-start/data-dur to fit the video`
|
|
4181
4102
|
});
|
|
4182
4103
|
}
|
|
4183
4104
|
}
|
|
@@ -4979,9 +4900,9 @@ function checkOutputRef(ctx) {
|
|
|
4979
4900
|
function pushZodIssues(issues, err, pathPrefix, code, nodeId, nodeType) {
|
|
4980
4901
|
for (const issue of err.issues) {
|
|
4981
4902
|
const tail2 = pathToString(issue.path);
|
|
4982
|
-
const
|
|
4903
|
+
const path19 = pathPrefix ? tail2 ? `${pathPrefix}.${tail2}` : pathPrefix : tail2;
|
|
4983
4904
|
issues.push({
|
|
4984
|
-
path:
|
|
4905
|
+
path: path19,
|
|
4985
4906
|
code,
|
|
4986
4907
|
message: issue.message,
|
|
4987
4908
|
received: issue.code === "invalid_type" ? issue.received : void 0,
|
|
@@ -4990,8 +4911,8 @@ function pushZodIssues(issues, err, pathPrefix, code, nodeId, nodeType) {
|
|
|
4990
4911
|
});
|
|
4991
4912
|
}
|
|
4992
4913
|
}
|
|
4993
|
-
function pathToString(
|
|
4994
|
-
return
|
|
4914
|
+
function pathToString(path19) {
|
|
4915
|
+
return path19.map((p) => typeof p === "number" ? `[${p}]` : `.${String(p)}`).join("").replace(/^\./, "");
|
|
4995
4916
|
}
|
|
4996
4917
|
function buildDepGraph(canvas) {
|
|
4997
4918
|
const graph = /* @__PURE__ */ new Map();
|
|
@@ -5650,9 +5571,9 @@ var NodeRegistry = class {
|
|
|
5650
5571
|
|
|
5651
5572
|
// src/engine/nodes/ingest.ts
|
|
5652
5573
|
import { execFile as execFileCb } from "child_process";
|
|
5653
|
-
import { mkdtemp, readFile as
|
|
5574
|
+
import { mkdtemp, readFile as readFile4, rm, stat as stat2 } from "fs/promises";
|
|
5654
5575
|
import { tmpdir } from "os";
|
|
5655
|
-
import
|
|
5576
|
+
import path6 from "path";
|
|
5656
5577
|
import { promisify } from "util";
|
|
5657
5578
|
import { z as z5 } from "zod";
|
|
5658
5579
|
|
|
@@ -5972,12 +5893,12 @@ async function fetchExternalBytes(url, options) {
|
|
|
5972
5893
|
|
|
5973
5894
|
// src/lib/ytDlp.ts
|
|
5974
5895
|
import { spawn } from "child_process";
|
|
5975
|
-
import { readdir, readFile as
|
|
5976
|
-
import
|
|
5896
|
+
import { readdir, readFile as readFile3 } from "fs/promises";
|
|
5897
|
+
import path5 from "path";
|
|
5977
5898
|
|
|
5978
5899
|
// src/lib/vimeoCookie.ts
|
|
5979
5900
|
import { writeFile as writeFile3 } from "fs/promises";
|
|
5980
|
-
import
|
|
5901
|
+
import path4 from "path";
|
|
5981
5902
|
var COOKIE_NAME = "vimeo";
|
|
5982
5903
|
async function writeVimeoCookieFile(cookie, workDir) {
|
|
5983
5904
|
const value = cookie?.trim();
|
|
@@ -5988,7 +5909,7 @@ async function writeVimeoCookieFile(cookie, workDir) {
|
|
|
5988
5909
|
[".vimeo.com", "TRUE", "/", "TRUE", String(expires), COOKIE_NAME, value].join(" "),
|
|
5989
5910
|
""
|
|
5990
5911
|
].join("\n");
|
|
5991
|
-
const filePath =
|
|
5912
|
+
const filePath = path4.join(workDir, "vimeo-cookies.txt");
|
|
5992
5913
|
await writeFile3(filePath, jar, { mode: 384 });
|
|
5993
5914
|
return filePath;
|
|
5994
5915
|
}
|
|
@@ -5999,12 +5920,6 @@ function isVimeoAuthFailure(detail) {
|
|
|
5999
5920
|
return VIMEO_AUTH_SIGNATURES.some((signature) => haystack.includes(signature));
|
|
6000
5921
|
}
|
|
6001
5922
|
|
|
6002
|
-
// src/lib/ytDlpFormat.ts
|
|
6003
|
-
function videoFormatArgs(maxHeight) {
|
|
6004
|
-
const format = maxHeight ? `bv*[height<=${maxHeight}]+ba/b[height<=${maxHeight}]/bv*+ba/b` : "bv*+ba/b";
|
|
6005
|
-
return ["--format", format, "--merge-output-format", "mp4"];
|
|
6006
|
-
}
|
|
6007
|
-
|
|
6008
5923
|
// src/lib/ytDlpPlayerClient.ts
|
|
6009
5924
|
var YOUTUBE_FALLBACK_CLIENT_ARGS = ["--extractor-args", "youtube:player_client=android"];
|
|
6010
5925
|
var MEDIA_FETCH_REFUSED = "unable to download video data";
|
|
@@ -6058,8 +5973,8 @@ function tail(text, maxLines) {
|
|
|
6058
5973
|
return text.split("\n").slice(-maxLines).join("\n");
|
|
6059
5974
|
}
|
|
6060
5975
|
async function runYtDlp(args) {
|
|
6061
|
-
const outTemplate =
|
|
6062
|
-
const infoPath =
|
|
5976
|
+
const outTemplate = path5.join(args.workDir, "out.%(ext)s");
|
|
5977
|
+
const infoPath = path5.join(args.workDir, "out.info.json");
|
|
6063
5978
|
const argv = [
|
|
6064
5979
|
args.url,
|
|
6065
5980
|
"--no-playlist",
|
|
@@ -6073,7 +5988,7 @@ async function runYtDlp(args) {
|
|
|
6073
5988
|
if (args.audioOnly) {
|
|
6074
5989
|
argv.push("-x", "--audio-format", "m4a");
|
|
6075
5990
|
} else {
|
|
6076
|
-
argv.push(
|
|
5991
|
+
argv.push("--format", "bv*+ba/b", "--merge-output-format", "mp4");
|
|
6077
5992
|
}
|
|
6078
5993
|
const cookieFile = await writeVimeoCookieFile(args.vimeoCookie, args.workDir);
|
|
6079
5994
|
if (cookieFile) argv.push("--cookies", cookieFile);
|
|
@@ -6097,10 +6012,10 @@ async function runYtDlp(args) {
|
|
|
6097
6012
|
}
|
|
6098
6013
|
let info = {};
|
|
6099
6014
|
try {
|
|
6100
|
-
info = JSON.parse(await
|
|
6015
|
+
info = JSON.parse(await readFile3(infoPath, "utf-8"));
|
|
6101
6016
|
} catch {
|
|
6102
6017
|
}
|
|
6103
|
-
return { filePath:
|
|
6018
|
+
return { filePath: path5.join(args.workDir, downloaded), info, tier, reducedQuality };
|
|
6104
6019
|
}
|
|
6105
6020
|
async function probeYtDlp(args) {
|
|
6106
6021
|
const argv = [
|
|
@@ -6414,9 +6329,7 @@ function mapClientError(ctx, e) {
|
|
|
6414
6329
|
kind: "remote",
|
|
6415
6330
|
status: d.status,
|
|
6416
6331
|
code: "invalid_params",
|
|
6417
|
-
message: d.message
|
|
6418
|
-
// The request itself was refused; it fails the same way until the input changes.
|
|
6419
|
-
retryable: false
|
|
6332
|
+
message: d.message
|
|
6420
6333
|
});
|
|
6421
6334
|
}
|
|
6422
6335
|
if (d.kind === "unauthorized") {
|
|
@@ -6611,8 +6524,8 @@ function resolveLocalPath(input) {
|
|
|
6611
6524
|
`ingest: ~ path expansion is not supported (got "${input}"). Use an absolute path or a cwd-relative path.`
|
|
6612
6525
|
);
|
|
6613
6526
|
}
|
|
6614
|
-
if (
|
|
6615
|
-
return
|
|
6527
|
+
if (path6.isAbsolute(input)) return input;
|
|
6528
|
+
return path6.resolve(process.cwd(), input);
|
|
6616
6529
|
}
|
|
6617
6530
|
var EXT_TO_MIME = {
|
|
6618
6531
|
png: "image/png",
|
|
@@ -6660,7 +6573,7 @@ function sniffSvg(buf) {
|
|
|
6660
6573
|
return head.startsWith("<?xml") ? head.includes("<svg") : head.startsWith("<svg");
|
|
6661
6574
|
}
|
|
6662
6575
|
function inferMimeFromPath(absPath, sniffBytes) {
|
|
6663
|
-
const ext =
|
|
6576
|
+
const ext = path6.extname(absPath).slice(1).toLowerCase();
|
|
6664
6577
|
const fromExt = EXT_TO_MIME[ext];
|
|
6665
6578
|
if (fromExt) return fromExt;
|
|
6666
6579
|
const fromBytes = sniffImageMime(sniffBytes);
|
|
@@ -6845,7 +6758,7 @@ async function execLocalFile(params, ctx) {
|
|
|
6845
6758
|
}
|
|
6846
6759
|
let bytes;
|
|
6847
6760
|
try {
|
|
6848
|
-
bytes = await
|
|
6761
|
+
bytes = await readFile4(absPath);
|
|
6849
6762
|
} catch (e) {
|
|
6850
6763
|
if (e.code === "EACCES") {
|
|
6851
6764
|
throw localExecError(ctx, `permission_denied: ${absPath}`);
|
|
@@ -6897,7 +6810,7 @@ function localFileMetadata(args) {
|
|
|
6897
6810
|
strategy: "local_file",
|
|
6898
6811
|
ingested_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6899
6812
|
file_size: args.fileSize,
|
|
6900
|
-
original_filename:
|
|
6813
|
+
original_filename: path6.basename(args.absPath),
|
|
6901
6814
|
...args.rasterizedFrom ? { rasterized_from: args.rasterizedFrom } : {},
|
|
6902
6815
|
...args.durationMs !== void 0 ? { duration_ms: args.durationMs } : {}
|
|
6903
6816
|
};
|
|
@@ -6919,7 +6832,7 @@ async function execYtDlp(params, ctx) {
|
|
|
6919
6832
|
if (params.expect !== "video" && params.expect !== "audio") {
|
|
6920
6833
|
throw new Error(`ingest: yt_dlp only handles video/audio, got expect=${params.expect}`);
|
|
6921
6834
|
}
|
|
6922
|
-
const workDir = await mkdtemp(
|
|
6835
|
+
const workDir = await mkdtemp(path6.join(tmpdir(), "ingest-yt-"));
|
|
6923
6836
|
try {
|
|
6924
6837
|
const { filePath, info, reducedQuality } = await runYtDlpForNode({
|
|
6925
6838
|
url: params.url,
|
|
@@ -6934,7 +6847,7 @@ async function execYtDlp(params, ctx) {
|
|
|
6934
6847
|
`file_too_large: yt-dlp output for ${params.url} is ${downloadedStats.size} bytes (limit ${MAX_ASSET_BYTES})`
|
|
6935
6848
|
);
|
|
6936
6849
|
}
|
|
6937
|
-
const bytes = await
|
|
6850
|
+
const bytes = await readFile4(filePath);
|
|
6938
6851
|
const kind = params.expect;
|
|
6939
6852
|
const mime = YT_DLP_MIME[kind];
|
|
6940
6853
|
const metadata = buildYtDlpMetadata(params.url, info);
|
|
@@ -7023,9 +6936,9 @@ import { z as z6 } from "zod";
|
|
|
7023
6936
|
|
|
7024
6937
|
// src/engine/nodes/local/lib/cli-runner.ts
|
|
7025
6938
|
import { execFile as execFileCb2, spawn as spawn2 } from "child_process";
|
|
7026
|
-
import { copyFile as copyFile2, mkdtemp as mkdtemp2, readFile as
|
|
6939
|
+
import { copyFile as copyFile2, mkdtemp as mkdtemp2, readFile as readFile5, rm as rm2, stat as stat3 } from "fs/promises";
|
|
7027
6940
|
import { tmpdir as tmpdir2 } from "os";
|
|
7028
|
-
import
|
|
6941
|
+
import path7 from "path";
|
|
7029
6942
|
import { promisify as promisify2 } from "util";
|
|
7030
6943
|
var execFile2 = promisify2(execFileCb2);
|
|
7031
6944
|
var DEFAULT_TIMEOUT_MS2 = 10 * 60 * 1e3;
|
|
@@ -7052,7 +6965,7 @@ function mimeForExt(ext) {
|
|
|
7052
6965
|
}
|
|
7053
6966
|
function extForAssetRef(ref) {
|
|
7054
6967
|
if (ref.path) {
|
|
7055
|
-
const e =
|
|
6968
|
+
const e = path7.extname(ref.path);
|
|
7056
6969
|
if (e) return e;
|
|
7057
6970
|
}
|
|
7058
6971
|
const reverse = {
|
|
@@ -7074,14 +6987,14 @@ function planArrayInputSlot(tmpDir, slot, values, lookup, stagedInputs) {
|
|
|
7074
6987
|
const ref = values[i];
|
|
7075
6988
|
if (!ref) continue;
|
|
7076
6989
|
if (!ref.path) throw new Error(`cli-runner: inputs.${slot}[${i}] has no local path`);
|
|
7077
|
-
const dest =
|
|
6990
|
+
const dest = path7.join(tmpDir, `in_${slot}_${i}${extForAssetRef(ref)}`);
|
|
7078
6991
|
stagedInputs.push({ srcPath: ref.path, destPath: dest });
|
|
7079
6992
|
lookup.set(`in.${slot}.${i}`, dest);
|
|
7080
6993
|
}
|
|
7081
6994
|
}
|
|
7082
6995
|
function planSingleInputSlot(tmpDir, slot, ref, lookup, stagedInputs) {
|
|
7083
6996
|
if (!ref.path) throw new Error(`cli-runner: inputs.${slot} has no local path`);
|
|
7084
|
-
const dest =
|
|
6997
|
+
const dest = path7.join(tmpDir, `in_${slot}${extForAssetRef(ref)}`);
|
|
7085
6998
|
stagedInputs.push({ srcPath: ref.path, destPath: dest });
|
|
7086
6999
|
lookup.set(`in.${slot}`, dest);
|
|
7087
7000
|
}
|
|
@@ -7089,7 +7002,7 @@ function planOutputs(tmpDir, outputs, lookup) {
|
|
|
7089
7002
|
const outputPaths = [];
|
|
7090
7003
|
for (const [name, spec] of Object.entries(outputs)) {
|
|
7091
7004
|
const ext = spec.ext.startsWith(".") ? spec.ext : `.${spec.ext}`;
|
|
7092
|
-
const absPath =
|
|
7005
|
+
const absPath = path7.join(tmpDir, `out_${name}${ext}`);
|
|
7093
7006
|
outputPaths.push({ name, absPath, spec });
|
|
7094
7007
|
lookup.set(`out.${name}`, absPath);
|
|
7095
7008
|
}
|
|
@@ -7130,8 +7043,8 @@ function rejectRawPaths(substituted, original, stagingDir) {
|
|
|
7130
7043
|
throw new Error(`cli-runner: home-relative path "${original}" not allowed in args.`);
|
|
7131
7044
|
}
|
|
7132
7045
|
if (substituted.startsWith("/")) {
|
|
7133
|
-
const resolved =
|
|
7134
|
-
if (!resolved.startsWith(`${stagingDir}${
|
|
7046
|
+
const resolved = path7.resolve(substituted);
|
|
7047
|
+
if (!resolved.startsWith(`${stagingDir}${path7.sep}`) && resolved !== stagingDir) {
|
|
7135
7048
|
throw new Error(
|
|
7136
7049
|
`cli-runner: raw filesystem path "${original}" not allowed \u2014 declare an input slot and use {{in.<slot>}} instead.`
|
|
7137
7050
|
);
|
|
@@ -7181,7 +7094,7 @@ function tailLines(text, maxLines) {
|
|
|
7181
7094
|
}
|
|
7182
7095
|
async function runCli(opts) {
|
|
7183
7096
|
const { bin, args, inputs, outputs, ctx, timeoutMs = DEFAULT_TIMEOUT_MS2 } = opts;
|
|
7184
|
-
const tmpDir = await mkdtemp2(
|
|
7097
|
+
const tmpDir = await mkdtemp2(path7.join(tmpdir2(), `cli-${bin.replace(/[^a-z0-9]/gi, "")}-`));
|
|
7185
7098
|
try {
|
|
7186
7099
|
const { lookup, stagedInputs, outputPaths } = planPlaceholders(tmpDir, inputs, outputs);
|
|
7187
7100
|
await stageInputs(stagedInputs);
|
|
@@ -7203,7 +7116,7 @@ ${tailLines(stderr, 40)}`);
|
|
|
7203
7116
|
if (!s?.isFile() || s.size === 0) {
|
|
7204
7117
|
throw new Error(`cli-runner: declared output "${name}" missing or empty at ${absPath}`);
|
|
7205
7118
|
}
|
|
7206
|
-
const bytes = await
|
|
7119
|
+
const bytes = await readFile5(absPath);
|
|
7207
7120
|
const ref = await ctx.assets.ingestBytes({
|
|
7208
7121
|
bytes: Buffer.from(bytes),
|
|
7209
7122
|
kind: spec.kind,
|
|
@@ -7473,17 +7386,17 @@ var ffmpegNode = defineNode({
|
|
|
7473
7386
|
import { mkdtemp as mkdtemp3, rm as rm3, writeFile as writeFile4 } from "fs/promises";
|
|
7474
7387
|
import { createRequire } from "module";
|
|
7475
7388
|
import { tmpdir as tmpdir3 } from "os";
|
|
7476
|
-
import
|
|
7389
|
+
import path9 from "path";
|
|
7477
7390
|
import { z as z9 } from "zod";
|
|
7478
7391
|
|
|
7479
7392
|
// src/engine/nodes/local/lib/assets.ts
|
|
7480
|
-
import { copyFile as copyFile3, readFile as
|
|
7481
|
-
import
|
|
7393
|
+
import { copyFile as copyFile3, readFile as readFile6 } from "fs/promises";
|
|
7394
|
+
import path8 from "path";
|
|
7482
7395
|
async function stageAsset(ref, destDir, filename) {
|
|
7483
7396
|
if (!ref.path) {
|
|
7484
7397
|
throw new Error(`stageAsset: ref (${ref.kind}/${ref.mime}) has no local path`);
|
|
7485
7398
|
}
|
|
7486
|
-
const dest =
|
|
7399
|
+
const dest = path8.join(destDir, filename);
|
|
7487
7400
|
await copyFile3(ref.path, dest);
|
|
7488
7401
|
return dest;
|
|
7489
7402
|
}
|
|
@@ -7492,7 +7405,7 @@ async function refToUrl(ref) {
|
|
|
7492
7405
|
if (!ref.path) {
|
|
7493
7406
|
throw new Error("refToUrl: AssetRef has neither url nor path");
|
|
7494
7407
|
}
|
|
7495
|
-
const bytes = await
|
|
7408
|
+
const bytes = await readFile6(ref.path);
|
|
7496
7409
|
return `data:${ref.mime};base64,${bytes.toString("base64")}`;
|
|
7497
7410
|
}
|
|
7498
7411
|
var ASSET_KINDS = /* @__PURE__ */ new Set(["image", "video", "audio", "json", "text", "font"]);
|
|
@@ -7566,11 +7479,11 @@ var fontSpecimenNode = defineNode({
|
|
|
7566
7479
|
outputKinds: { image: "image" },
|
|
7567
7480
|
cost: () => ({ credits: 0, seconds_estimate: 5 }),
|
|
7568
7481
|
async execute({ inputs, params, ctx }) {
|
|
7569
|
-
const tmp = await mkdtemp3(
|
|
7482
|
+
const tmp = await mkdtemp3(path9.join(tmpdir3(), "font-specimen-"));
|
|
7570
7483
|
try {
|
|
7571
7484
|
const fontFilename = `font.${extForMime(inputs.font.mime)}`;
|
|
7572
7485
|
await stageAsset(inputs.font, tmp, fontFilename);
|
|
7573
|
-
const entryPath =
|
|
7486
|
+
const entryPath = path9.join(tmp, "index.html");
|
|
7574
7487
|
await writeFile4(entryPath, buildSpecimenHtml(params, fontFilename), "utf-8");
|
|
7575
7488
|
ctx.log(`rendering specimen (${params.font_size}px, ${params.text.split("\n").length} lines)`);
|
|
7576
7489
|
const pwSpecifier = ["play", "wright"].join("");
|
|
@@ -7654,16 +7567,16 @@ var fontSpecimenNode = defineNode({
|
|
|
7654
7567
|
|
|
7655
7568
|
// src/engine/nodes/local/hyperframe.ts
|
|
7656
7569
|
import { execFile as execFile4 } from "child_process";
|
|
7657
|
-
import { copyFile as copyFile4, mkdtemp as mkdtemp4, readFile as
|
|
7570
|
+
import { copyFile as copyFile4, mkdtemp as mkdtemp4, readFile as readFile10, rm as rm4, stat as stat5, writeFile as writeFile6 } from "fs/promises";
|
|
7658
7571
|
import { createRequire as createRequire2 } from "module";
|
|
7659
7572
|
import { cpus, tmpdir as tmpdir4 } from "os";
|
|
7660
|
-
import
|
|
7573
|
+
import path14 from "path";
|
|
7661
7574
|
import { promisify as promisify4 } from "util";
|
|
7662
7575
|
import { z as z11 } from "zod";
|
|
7663
7576
|
|
|
7664
7577
|
// src/engine/engine/composition-hash.ts
|
|
7665
|
-
import { readdir as readdir2, readFile as
|
|
7666
|
-
import
|
|
7578
|
+
import { readdir as readdir2, readFile as readFile7, stat as stat4 } from "fs/promises";
|
|
7579
|
+
import path10 from "path";
|
|
7667
7580
|
var SKIP_DIRS = /* @__PURE__ */ new Set([".cache", ".git", "node_modules", "dist", "build", ".next", ".turbo"]);
|
|
7668
7581
|
function isSkippedName(name) {
|
|
7669
7582
|
if (name.startsWith(".")) return true;
|
|
@@ -7680,23 +7593,23 @@ async function collectFiles(root, current) {
|
|
|
7680
7593
|
const names = await readdir2(current);
|
|
7681
7594
|
for (const name of names) {
|
|
7682
7595
|
if (isSkippedName(name)) continue;
|
|
7683
|
-
const abs =
|
|
7596
|
+
const abs = path10.join(current, name);
|
|
7684
7597
|
const s = await stat4(abs);
|
|
7685
7598
|
if (s.isDirectory()) {
|
|
7686
7599
|
out.push(...await collectFiles(root, abs));
|
|
7687
7600
|
continue;
|
|
7688
7601
|
}
|
|
7689
7602
|
if (!s.isFile()) continue;
|
|
7690
|
-
const bytes = await
|
|
7691
|
-
const relPath =
|
|
7603
|
+
const bytes = await readFile7(abs);
|
|
7604
|
+
const relPath = path10.relative(root, abs).split(path10.sep).join("/");
|
|
7692
7605
|
out.push({ relPath, contentSha: sha256Hex(bytes) });
|
|
7693
7606
|
}
|
|
7694
7607
|
return out;
|
|
7695
7608
|
}
|
|
7696
7609
|
|
|
7697
7610
|
// src/engine/engine/composition-meta.ts
|
|
7698
|
-
import { readFile as
|
|
7699
|
-
import
|
|
7611
|
+
import { readFile as readFile8 } from "fs/promises";
|
|
7612
|
+
import path11 from "path";
|
|
7700
7613
|
import { z as z10 } from "zod";
|
|
7701
7614
|
var InputKind = z10.enum(["video", "image", "audio", "json"]);
|
|
7702
7615
|
var InputSpec = z10.object({
|
|
@@ -7773,10 +7686,10 @@ var CompositionMetaSchema = z10.object({
|
|
|
7773
7686
|
params: z10.record(z10.string(), ParamSpec).default({})
|
|
7774
7687
|
}).strict();
|
|
7775
7688
|
async function loadCompositionMeta(compositionDir) {
|
|
7776
|
-
const metaPath =
|
|
7689
|
+
const metaPath = path11.join(compositionDir, "meta.json");
|
|
7777
7690
|
let raw;
|
|
7778
7691
|
try {
|
|
7779
|
-
raw = await
|
|
7692
|
+
raw = await readFile8(metaPath, "utf-8");
|
|
7780
7693
|
} catch (e) {
|
|
7781
7694
|
throw new Error(`composition meta: cannot read ${metaPath} (${e.message})`);
|
|
7782
7695
|
}
|
|
@@ -7854,8 +7767,8 @@ function defaultFilenameForInput(key, kind) {
|
|
|
7854
7767
|
|
|
7855
7768
|
// src/engine/nodes/local/lib/hyperframe-check.ts
|
|
7856
7769
|
import { execFile as execFile3 } from "child_process";
|
|
7857
|
-
import { readFile as
|
|
7858
|
-
import
|
|
7770
|
+
import { readFile as readFile9 } from "fs/promises";
|
|
7771
|
+
import path12 from "path";
|
|
7859
7772
|
import { promisify as promisify3 } from "util";
|
|
7860
7773
|
|
|
7861
7774
|
// src/engine/nodes/local/lib/caption-style.ts
|
|
@@ -8079,7 +7992,7 @@ async function runSnapshotSmoke(args, timeoutMs) {
|
|
|
8079
7992
|
}
|
|
8080
7993
|
async function runNestedCompositionSmoke(opts) {
|
|
8081
7994
|
const { dir, nodeId, ctx, timeoutMs, samples } = opts;
|
|
8082
|
-
const indexHtml = await
|
|
7995
|
+
const indexHtml = await readFile9(path12.join(dir, "index.html"), "utf-8").catch(() => "");
|
|
8083
7996
|
if (!indexHtml || !usesNestedCompositions(indexHtml)) return;
|
|
8084
7997
|
const snap = await runSnapshotSmoke(
|
|
8085
7998
|
buildSnapshotArgs(dir, Math.min(samples, 3), hasFrameVisionKey()),
|
|
@@ -8095,7 +8008,7 @@ async function runNestedCompositionSmoke(opts) {
|
|
|
8095
8008
|
${snap.message}`
|
|
8096
8009
|
);
|
|
8097
8010
|
}
|
|
8098
|
-
const described = await
|
|
8011
|
+
const described = await readFile9(path12.join(dir, "snapshots", "descriptions.md"), "utf-8").catch(() => "");
|
|
8099
8012
|
for (const line of condenseFrameDescriptions(described)) {
|
|
8100
8013
|
ctx.log(`${nodeId}: frame check \u2014 ${line}`);
|
|
8101
8014
|
}
|
|
@@ -8131,7 +8044,7 @@ async function runHyperframesCheck(opts) {
|
|
|
8131
8044
|
${detail}`
|
|
8132
8045
|
);
|
|
8133
8046
|
}
|
|
8134
|
-
const composition = await
|
|
8047
|
+
const composition = await readFile9(path12.join(dir, "index.html"), "utf-8").catch(() => "");
|
|
8135
8048
|
const captionComplaint = fragmentedCaptions(captionTextsFrom(composition));
|
|
8136
8049
|
if (captionComplaint) {
|
|
8137
8050
|
ctx.log(`${nodeId}: caption style \u2014 ${captionComplaint}`);
|
|
@@ -8185,9 +8098,9 @@ ${stderr.slice(0, 1500)}`;
|
|
|
8185
8098
|
|
|
8186
8099
|
// src/engine/nodes/local/lib/hyperframe-meta.ts
|
|
8187
8100
|
import { writeFile as writeFile5 } from "fs/promises";
|
|
8188
|
-
import
|
|
8101
|
+
import path13 from "path";
|
|
8189
8102
|
async function ensureHyperframesMetaJson(tmp, nodeId, meta, duration) {
|
|
8190
|
-
const metaPath =
|
|
8103
|
+
const metaPath = path13.join(tmp, "meta.json");
|
|
8191
8104
|
await writeFile5(
|
|
8192
8105
|
metaPath,
|
|
8193
8106
|
JSON.stringify(
|
|
@@ -8287,7 +8200,7 @@ var hyperframeRenderNode = defineNode({
|
|
|
8287
8200
|
const compositionDir = await resolveCompositionDir(params.composition);
|
|
8288
8201
|
const meta = await loadCompositionMeta(compositionDir);
|
|
8289
8202
|
const compositionParams = validateAndParseDynamicParams(meta, params);
|
|
8290
|
-
const tmp = await mkdtemp4(
|
|
8203
|
+
const tmp = await mkdtemp4(path14.join(tmpdir4(), "hf-render-"));
|
|
8291
8204
|
try {
|
|
8292
8205
|
await copyComposition(compositionDir, tmp);
|
|
8293
8206
|
await vendorGsap(tmp, ctx);
|
|
@@ -8297,9 +8210,9 @@ var hyperframeRenderNode = defineNode({
|
|
|
8297
8210
|
await substituteCompositionFiles(tmp, substitutionValues);
|
|
8298
8211
|
await ensureHyperframesMetaJson(tmp, ctx.nodeId, meta, duration);
|
|
8299
8212
|
await runHyperframesCheck({ dir: tmp, nodeId: "hyperframe_render", ctx, timeoutMs: params.timeout_ms });
|
|
8300
|
-
const outputPath =
|
|
8213
|
+
const outputPath = path14.join(tmp, `output.${params.format}`);
|
|
8301
8214
|
await runRender({ tmp, outputPath, params, meta, ctx });
|
|
8302
|
-
const bytes = await
|
|
8215
|
+
const bytes = await readFile10(outputPath);
|
|
8303
8216
|
ctx.log(`rendered ${bytes.length} bytes`);
|
|
8304
8217
|
const ref = await ctx.assets.ingestBytes({
|
|
8305
8218
|
bytes: Buffer.from(bytes),
|
|
@@ -8321,10 +8234,10 @@ var hyperframeRenderNode = defineNode({
|
|
|
8321
8234
|
}
|
|
8322
8235
|
});
|
|
8323
8236
|
async function resolveCompositionDir(composition) {
|
|
8324
|
-
const compositionPath =
|
|
8237
|
+
const compositionPath = path14.isAbsolute(composition) ? composition : path14.resolve(process.cwd(), composition);
|
|
8325
8238
|
const s = await stat5(compositionPath);
|
|
8326
8239
|
if (s.isDirectory()) return compositionPath;
|
|
8327
|
-
return
|
|
8240
|
+
return path14.dirname(compositionPath);
|
|
8328
8241
|
}
|
|
8329
8242
|
async function validateComposition(rawParams) {
|
|
8330
8243
|
const issues = await validateCompositionParams(rawParams);
|
|
@@ -8406,7 +8319,7 @@ async function copyComposition(srcDir, destDir) {
|
|
|
8406
8319
|
await cp(srcDir, destDir, {
|
|
8407
8320
|
recursive: true,
|
|
8408
8321
|
filter: (src) => {
|
|
8409
|
-
const name =
|
|
8322
|
+
const name = path14.basename(src);
|
|
8410
8323
|
if (name === ".cache" || name === "node_modules" || name === ".git") return false;
|
|
8411
8324
|
return true;
|
|
8412
8325
|
}
|
|
@@ -8415,7 +8328,7 @@ async function copyComposition(srcDir, destDir) {
|
|
|
8415
8328
|
async function vendorGsap(tmp, ctx) {
|
|
8416
8329
|
try {
|
|
8417
8330
|
const gsapMin = require_2.resolve("gsap/dist/gsap.min.js");
|
|
8418
|
-
await copyFile4(gsapMin,
|
|
8331
|
+
await copyFile4(gsapMin, path14.join(tmp, "gsap.min.js"));
|
|
8419
8332
|
} catch (e) {
|
|
8420
8333
|
ctx.log(`warning: could not vendor gsap.min.js (${e.message}); compositions must self-supply`);
|
|
8421
8334
|
}
|
|
@@ -8430,7 +8343,7 @@ async function stageInputs2(tmp, inputs, meta, ctx) {
|
|
|
8430
8343
|
await stageAsset(ref, tmp, filename);
|
|
8431
8344
|
ctx.log(`staged ${spec.kind} \u2192 ${filename}`);
|
|
8432
8345
|
if (spec.kind === "video" && primaryDuration === null) {
|
|
8433
|
-
primaryDuration = await probeDurationSeconds(
|
|
8346
|
+
primaryDuration = await probeDurationSeconds(path14.join(tmp, filename));
|
|
8434
8347
|
}
|
|
8435
8348
|
}
|
|
8436
8349
|
return primaryDuration;
|
|
@@ -8476,8 +8389,8 @@ function coerceImageParam(value) {
|
|
|
8476
8389
|
throw new Error("hyperframe_render: image param must be a URL string or AssetRef");
|
|
8477
8390
|
}
|
|
8478
8391
|
async function substituteCompositionFiles(tmp, values) {
|
|
8479
|
-
const entryPath =
|
|
8480
|
-
const original = await
|
|
8392
|
+
const entryPath = path14.join(tmp, "index.html");
|
|
8393
|
+
const original = await readFile10(entryPath, "utf-8");
|
|
8481
8394
|
const { output, missing } = substituteVariables(original, values);
|
|
8482
8395
|
if (missing.length > 0) {
|
|
8483
8396
|
throw new Error(
|
|
@@ -8493,7 +8406,7 @@ function workerCount() {
|
|
|
8493
8406
|
async function runRender(opts) {
|
|
8494
8407
|
const { tmp, outputPath, params, meta, ctx } = opts;
|
|
8495
8408
|
const args = buildRenderArgs(tmp, outputPath, meta, params.format);
|
|
8496
|
-
ctx.log(`rendering ${meta.width}x${meta.height}@${meta.fps}fps ${params.format} from ${
|
|
8409
|
+
ctx.log(`rendering ${meta.width}x${meta.height}@${meta.fps}fps ${params.format} from ${path14.basename(tmp)}`);
|
|
8497
8410
|
try {
|
|
8498
8411
|
await execFileAsync2("npx", args, { timeout: params.timeout_ms, maxBuffer: 64 * 1024 * 1024 });
|
|
8499
8412
|
} catch (e) {
|
|
@@ -8537,10 +8450,10 @@ async function probeDurationSeconds(filePath) {
|
|
|
8537
8450
|
|
|
8538
8451
|
// src/engine/nodes/local/hyperframe-snapshot.ts
|
|
8539
8452
|
import { execFile as execFile5 } from "child_process";
|
|
8540
|
-
import { copyFile as copyFile5, mkdtemp as mkdtemp5, readFile as
|
|
8453
|
+
import { copyFile as copyFile5, mkdtemp as mkdtemp5, readFile as readFile11, rm as rm5, writeFile as writeFile7 } from "fs/promises";
|
|
8541
8454
|
import { createRequire as createRequire3 } from "module";
|
|
8542
8455
|
import { tmpdir as tmpdir5 } from "os";
|
|
8543
|
-
import
|
|
8456
|
+
import path15 from "path";
|
|
8544
8457
|
import { promisify as promisify5 } from "util";
|
|
8545
8458
|
import { z as z12 } from "zod";
|
|
8546
8459
|
var _execFileAsync = promisify5(execFile5);
|
|
@@ -8587,7 +8500,7 @@ var hyperframeSnapshotNode = defineNode({
|
|
|
8587
8500
|
const compositionDir = await resolveCompositionDir(params.composition);
|
|
8588
8501
|
const meta = await loadCompositionMeta(compositionDir);
|
|
8589
8502
|
const compositionParams = validateAndParseDynamicParams2(meta, params);
|
|
8590
|
-
const tmp = await mkdtemp5(
|
|
8503
|
+
const tmp = await mkdtemp5(path15.join(tmpdir5(), "hf-snap-"));
|
|
8591
8504
|
try {
|
|
8592
8505
|
await copyComposition2(compositionDir, tmp);
|
|
8593
8506
|
await vendorGsap2(tmp, ctx);
|
|
@@ -8602,7 +8515,7 @@ var hyperframeSnapshotNode = defineNode({
|
|
|
8602
8515
|
timeoutMs: params.timeout_ms,
|
|
8603
8516
|
samples: 1
|
|
8604
8517
|
});
|
|
8605
|
-
const entryPath =
|
|
8518
|
+
const entryPath = path15.join(tmp, "index.html");
|
|
8606
8519
|
const entryUrl = `file://${entryPath}`;
|
|
8607
8520
|
ctx.log(`snapshotting ${meta.width}x${meta.height}@${DEVICE_SCALE_FACTOR2}x wait=${params.wait_for.kind}`);
|
|
8608
8521
|
const pwSpecifier = ["play", "wright"].join("");
|
|
@@ -8663,7 +8576,7 @@ async function copyComposition2(srcDir, destDir) {
|
|
|
8663
8576
|
await cp(srcDir, destDir, {
|
|
8664
8577
|
recursive: true,
|
|
8665
8578
|
filter: (src) => {
|
|
8666
|
-
const name =
|
|
8579
|
+
const name = path15.basename(src);
|
|
8667
8580
|
if (name === ".cache" || name === "node_modules" || name === ".git") return false;
|
|
8668
8581
|
return true;
|
|
8669
8582
|
}
|
|
@@ -8672,7 +8585,7 @@ async function copyComposition2(srcDir, destDir) {
|
|
|
8672
8585
|
async function vendorGsap2(tmp, ctx) {
|
|
8673
8586
|
try {
|
|
8674
8587
|
const gsapMin = require_3.resolve("gsap/dist/gsap.min.js");
|
|
8675
|
-
await copyFile5(gsapMin,
|
|
8588
|
+
await copyFile5(gsapMin, path15.join(tmp, "gsap.min.js"));
|
|
8676
8589
|
} catch (e) {
|
|
8677
8590
|
ctx.log(`warning: could not vendor gsap.min.js (${e.message}); compositions must self-supply`);
|
|
8678
8591
|
}
|
|
@@ -8706,8 +8619,8 @@ function coerceImageParam2(value) {
|
|
|
8706
8619
|
throw new Error("hyperframe_snapshot: image param must be a URL string or AssetRef");
|
|
8707
8620
|
}
|
|
8708
8621
|
async function substituteCompositionFiles2(tmp, values) {
|
|
8709
|
-
const entryPath =
|
|
8710
|
-
const original = await
|
|
8622
|
+
const entryPath = path15.join(tmp, "index.html");
|
|
8623
|
+
const original = await readFile11(entryPath, "utf-8");
|
|
8711
8624
|
const { output, missing } = substituteVariables(original, values);
|
|
8712
8625
|
if (missing.length > 0) {
|
|
8713
8626
|
throw new Error(
|
|
@@ -9474,9 +9387,9 @@ var videoLipsyncNode = delegated({
|
|
|
9474
9387
|
});
|
|
9475
9388
|
|
|
9476
9389
|
// src/engine/nodes/remote/videoTranscribe.ts
|
|
9477
|
-
import { mkdtemp as mkdtemp6, readFile as
|
|
9390
|
+
import { mkdtemp as mkdtemp6, readFile as readFile12, rm as rm6 } from "fs/promises";
|
|
9478
9391
|
import { tmpdir as tmpdir6 } from "os";
|
|
9479
|
-
import
|
|
9392
|
+
import path16 from "path";
|
|
9480
9393
|
import { z as z33 } from "zod";
|
|
9481
9394
|
|
|
9482
9395
|
// src/engine/nodes/local/lib/ffmpeg.ts
|
|
@@ -9614,14 +9527,14 @@ async function tryExtractAudio(inputs, ctx) {
|
|
|
9614
9527
|
ctx.log("video_transcribe: no audio track detected, sending full video");
|
|
9615
9528
|
return null;
|
|
9616
9529
|
}
|
|
9617
|
-
tmpDir = await mkdtemp6(
|
|
9618
|
-
const audioPath =
|
|
9530
|
+
tmpDir = await mkdtemp6(path16.join(tmpdir6(), "vtx-"));
|
|
9531
|
+
const audioPath = path16.join(tmpDir, "audio.mp3");
|
|
9619
9532
|
ctx.log("video_transcribe: extracting audio (mono 16kHz mp3)");
|
|
9620
9533
|
await runFfmpeg(
|
|
9621
9534
|
["-i", video.path, "-vn", "-ac", "1", "-ar", "16000", "-b:a", "64k", "-f", "mp3", "-y", audioPath],
|
|
9622
9535
|
{ timeout_ms: AUDIO_EXTRACT_TIMEOUT_MS }
|
|
9623
9536
|
);
|
|
9624
|
-
const bytes = await
|
|
9537
|
+
const bytes = await readFile12(audioPath);
|
|
9625
9538
|
if (bytes.byteLength === 0) {
|
|
9626
9539
|
ctx.log("video_transcribe: extracted audio is empty, sending full video");
|
|
9627
9540
|
return null;
|
|
@@ -9816,19 +9729,19 @@ function safeCost(def) {
|
|
|
9816
9729
|
|
|
9817
9730
|
// src/engine/storage/cache-store.ts
|
|
9818
9731
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
9819
|
-
import { mkdir as mkdir3, readFile as
|
|
9820
|
-
import
|
|
9732
|
+
import { mkdir as mkdir3, readFile as readFile13, rename as rename2, writeFile as writeFile8 } from "fs/promises";
|
|
9733
|
+
import path17 from "path";
|
|
9821
9734
|
var LocalCacheStore = class {
|
|
9822
9735
|
rootDir;
|
|
9823
9736
|
constructor(rootDir) {
|
|
9824
9737
|
this.rootDir = rootDir;
|
|
9825
9738
|
}
|
|
9826
9739
|
filePath(cacheKey) {
|
|
9827
|
-
return
|
|
9740
|
+
return path17.join(this.rootDir, `${cacheKey}.json`);
|
|
9828
9741
|
}
|
|
9829
9742
|
async get(cacheKey) {
|
|
9830
9743
|
try {
|
|
9831
|
-
const buf = await
|
|
9744
|
+
const buf = await readFile13(this.filePath(cacheKey), "utf8");
|
|
9832
9745
|
return JSON.parse(buf);
|
|
9833
9746
|
} catch (e) {
|
|
9834
9747
|
if (e.code === "ENOENT") return null;
|
|
@@ -9837,7 +9750,7 @@ var LocalCacheStore = class {
|
|
|
9837
9750
|
}
|
|
9838
9751
|
async put(entry) {
|
|
9839
9752
|
const dest = this.filePath(entry.cacheKey);
|
|
9840
|
-
await mkdir3(
|
|
9753
|
+
await mkdir3(path17.dirname(dest), { recursive: true });
|
|
9841
9754
|
const tmp = `${dest}.tmp-${process.pid}-${randomUUID2()}`;
|
|
9842
9755
|
await writeFile8(tmp, JSON.stringify(entry, null, 0));
|
|
9843
9756
|
await rename2(tmp, dest);
|
|
@@ -9893,12 +9806,12 @@ function defaultRegistry() {
|
|
|
9893
9806
|
}
|
|
9894
9807
|
function createEngineFromEnv(opts = {}) {
|
|
9895
9808
|
const cwd = opts.cwd ?? process.cwd();
|
|
9896
|
-
const cacheDir = opts.cacheDir ??
|
|
9897
|
-
const outputsDir = opts.outputsDir ??
|
|
9809
|
+
const cacheDir = opts.cacheDir ?? path18.join(cwd, "canvas", ".cache");
|
|
9810
|
+
const outputsDir = opts.outputsDir ?? path18.join(cwd, "canvas");
|
|
9898
9811
|
const connection = requireConnection();
|
|
9899
9812
|
const client = new BackendClient({ baseUrl: connection.BAKER_API_URL, apiKey: connection.BAKER_API_KEY });
|
|
9900
|
-
const assets = new LocalAssetStore(
|
|
9901
|
-
const localCache = new LocalCacheStore(
|
|
9813
|
+
const assets = new LocalAssetStore(path18.join(cacheDir, "assets"));
|
|
9814
|
+
const localCache = new LocalCacheStore(path18.join(cacheDir, "index"));
|
|
9902
9815
|
const remoteCacheEnabled = opts.remoteCache ?? remoteCacheEnabledFromEnv();
|
|
9903
9816
|
const cache = remoteCacheEnabled ? new LayeredCacheStore({
|
|
9904
9817
|
local: localCache,
|
|
@@ -9923,7 +9836,6 @@ export {
|
|
|
9923
9836
|
RunAbortedError,
|
|
9924
9837
|
LayerExecutionError,
|
|
9925
9838
|
describeFailureReason,
|
|
9926
|
-
runFailureCode,
|
|
9927
9839
|
AD_FORMAT_PLATFORMS,
|
|
9928
9840
|
platformFormats,
|
|
9929
9841
|
withoutCastName,
|
|
@@ -9992,4 +9904,4 @@ export {
|
|
|
9992
9904
|
defaultRegistry,
|
|
9993
9905
|
createEngineFromEnv
|
|
9994
9906
|
};
|
|
9995
|
-
//# sourceMappingURL=chunk-
|
|
9907
|
+
//# sourceMappingURL=chunk-RK44ZR7L.js.map
|