@koda-sl/baker-cli 0.353.0-dev.afbf521d7 → 0.353.0-dev.f5f2d3146
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 +4 -5
- package/dist/{chunk-RZWMHH4X.js → chunk-B7MLH3K6.js} +109 -190
- package/dist/chunk-B7MLH3K6.js.map +1 -0
- package/dist/cli.js +23 -5
- package/dist/cli.js.map +1 -1
- package/dist/engine/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-RZWMHH4X.js.map +0 -1
|
@@ -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,74 +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
|
-
const spec = typeof model === "string" ? MODEL_REGISTRY[n.type][model] : void 0;
|
|
3683
|
-
if (!spec || typeof model !== "string") return [];
|
|
3684
|
-
return Object.entries(spec.params).flatMap(
|
|
3685
|
-
([key, schema]) => schema.kind === "string" && schema.maxLength !== void 0 ? [{ key, max: schema.maxLength, model }] : []
|
|
3686
|
-
);
|
|
3687
|
-
}
|
|
3688
|
-
async function filledParam(n, raw, nodes) {
|
|
3689
|
-
const template = await staticTextOf(raw, nodes);
|
|
3690
|
-
if (template === void 0) return void 0;
|
|
3691
|
-
const names = extractSlots(template);
|
|
3692
|
-
if (names.length === 0 && template === raw) return void 0;
|
|
3693
|
-
const inputs = n.inputs ?? {};
|
|
3694
|
-
const slots = {};
|
|
3695
|
-
for (const name of names) {
|
|
3696
|
-
const text = await staticTextOf(inputs[name], nodes);
|
|
3697
|
-
if (text !== void 0) slots[name] = text;
|
|
3698
|
-
}
|
|
3699
|
-
return { length: renderTemplate(template, slots).length, slots };
|
|
3700
|
-
}
|
|
3701
|
-
function largestSlotNote(slots) {
|
|
3702
|
-
const largest = Object.entries(slots).sort((a, b) => b[1].length - a[1].length)[0];
|
|
3703
|
-
return largest ? `; {{${largest[0]}}} alone is ${largest[1].length}` : "";
|
|
3704
|
-
}
|
|
3705
|
-
async function filledPromptLimitIssues(canvas) {
|
|
3706
|
-
const nodes = new Map(canvas.nodes.map((n) => [n.id, n]));
|
|
3707
|
-
const issues = [];
|
|
3708
|
-
for (const [i, n] of canvas.nodes.entries()) {
|
|
3709
|
-
for (const { key, max, model } of cappedParamsOf(n)) {
|
|
3710
|
-
const filled = await filledParam(n, n.params?.[key], nodes);
|
|
3711
|
-
if (!filled || filled.length <= max) continue;
|
|
3712
|
-
issues.push({
|
|
3713
|
-
path: `nodes[${i}].params.${key}`,
|
|
3714
|
-
code: PROMPT_OVER_MODEL_LIMIT,
|
|
3715
|
-
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.`,
|
|
3716
|
-
received: filled.length,
|
|
3717
|
-
expected: `<= ${max} characters`,
|
|
3718
|
-
node_id: n.id,
|
|
3719
|
-
node_type: n.type
|
|
3720
|
-
});
|
|
3721
|
-
}
|
|
3722
|
-
}
|
|
3723
|
-
return issues;
|
|
3724
|
-
}
|
|
3725
|
-
|
|
3726
3649
|
// src/engine/engine/validator.ts
|
|
3727
3650
|
var MODEL_INPUT_KINDS = /* @__PURE__ */ new Set(["image", "video", "audio"]);
|
|
3728
3651
|
var STAGE_CODES = {
|
|
@@ -3878,7 +3801,6 @@ async function validateCanvasDeep(input, registry) {
|
|
|
3878
3801
|
}
|
|
3879
3802
|
}
|
|
3880
3803
|
await checkOverlayTimingBounds(canvas, issues);
|
|
3881
|
-
issues.push(...await filledPromptLimitIssues(canvas));
|
|
3882
3804
|
const hasBlocking = issues.some(isBlocking);
|
|
3883
3805
|
if (hasBlocking) return { ok: false, issues };
|
|
3884
3806
|
const warnings = [...shallow.warnings ?? [], ...issues.filter((i) => !isBlocking(i))];
|
|
@@ -4166,8 +4088,8 @@ async function checkOverlayTimingBounds(canvas, issues) {
|
|
|
4166
4088
|
const n = canvas.nodes[i];
|
|
4167
4089
|
if (n?.type !== "hyperframe_render") continue;
|
|
4168
4090
|
const composition = n.params?.composition;
|
|
4169
|
-
if (typeof composition !== "string" || !
|
|
4170
|
-
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);
|
|
4171
4093
|
if (!html) continue;
|
|
4172
4094
|
for (const w of overlayTimingIssues(html, durationS)) {
|
|
4173
4095
|
issues.push({
|
|
@@ -4176,7 +4098,7 @@ async function checkOverlayTimingBounds(canvas, issues) {
|
|
|
4176
4098
|
severity: "warning",
|
|
4177
4099
|
node_id: n.id,
|
|
4178
4100
|
node_type: n.type,
|
|
4179
|
-
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`
|
|
4180
4102
|
});
|
|
4181
4103
|
}
|
|
4182
4104
|
}
|
|
@@ -4978,9 +4900,9 @@ function checkOutputRef(ctx) {
|
|
|
4978
4900
|
function pushZodIssues(issues, err, pathPrefix, code, nodeId, nodeType) {
|
|
4979
4901
|
for (const issue of err.issues) {
|
|
4980
4902
|
const tail2 = pathToString(issue.path);
|
|
4981
|
-
const
|
|
4903
|
+
const path19 = pathPrefix ? tail2 ? `${pathPrefix}.${tail2}` : pathPrefix : tail2;
|
|
4982
4904
|
issues.push({
|
|
4983
|
-
path:
|
|
4905
|
+
path: path19,
|
|
4984
4906
|
code,
|
|
4985
4907
|
message: issue.message,
|
|
4986
4908
|
received: issue.code === "invalid_type" ? issue.received : void 0,
|
|
@@ -4989,8 +4911,8 @@ function pushZodIssues(issues, err, pathPrefix, code, nodeId, nodeType) {
|
|
|
4989
4911
|
});
|
|
4990
4912
|
}
|
|
4991
4913
|
}
|
|
4992
|
-
function pathToString(
|
|
4993
|
-
return
|
|
4914
|
+
function pathToString(path19) {
|
|
4915
|
+
return path19.map((p) => typeof p === "number" ? `[${p}]` : `.${String(p)}`).join("").replace(/^\./, "");
|
|
4994
4916
|
}
|
|
4995
4917
|
function buildDepGraph(canvas) {
|
|
4996
4918
|
const graph = /* @__PURE__ */ new Map();
|
|
@@ -5628,9 +5550,9 @@ var NodeRegistry = class {
|
|
|
5628
5550
|
|
|
5629
5551
|
// src/engine/nodes/ingest.ts
|
|
5630
5552
|
import { execFile as execFileCb } from "child_process";
|
|
5631
|
-
import { mkdtemp, readFile as
|
|
5553
|
+
import { mkdtemp, readFile as readFile4, rm, stat as stat2 } from "fs/promises";
|
|
5632
5554
|
import { tmpdir } from "os";
|
|
5633
|
-
import
|
|
5555
|
+
import path6 from "path";
|
|
5634
5556
|
import { promisify } from "util";
|
|
5635
5557
|
import { z as z5 } from "zod";
|
|
5636
5558
|
|
|
@@ -5950,12 +5872,12 @@ async function fetchExternalBytes(url, options) {
|
|
|
5950
5872
|
|
|
5951
5873
|
// src/lib/ytDlp.ts
|
|
5952
5874
|
import { spawn } from "child_process";
|
|
5953
|
-
import { readdir, readFile as
|
|
5954
|
-
import
|
|
5875
|
+
import { readdir, readFile as readFile3 } from "fs/promises";
|
|
5876
|
+
import path5 from "path";
|
|
5955
5877
|
|
|
5956
5878
|
// src/lib/vimeoCookie.ts
|
|
5957
5879
|
import { writeFile as writeFile3 } from "fs/promises";
|
|
5958
|
-
import
|
|
5880
|
+
import path4 from "path";
|
|
5959
5881
|
var COOKIE_NAME = "vimeo";
|
|
5960
5882
|
async function writeVimeoCookieFile(cookie, workDir) {
|
|
5961
5883
|
const value = cookie?.trim();
|
|
@@ -5966,7 +5888,7 @@ async function writeVimeoCookieFile(cookie, workDir) {
|
|
|
5966
5888
|
[".vimeo.com", "TRUE", "/", "TRUE", String(expires), COOKIE_NAME, value].join(" "),
|
|
5967
5889
|
""
|
|
5968
5890
|
].join("\n");
|
|
5969
|
-
const filePath =
|
|
5891
|
+
const filePath = path4.join(workDir, "vimeo-cookies.txt");
|
|
5970
5892
|
await writeFile3(filePath, jar, { mode: 384 });
|
|
5971
5893
|
return filePath;
|
|
5972
5894
|
}
|
|
@@ -6030,8 +5952,8 @@ function tail(text, maxLines) {
|
|
|
6030
5952
|
return text.split("\n").slice(-maxLines).join("\n");
|
|
6031
5953
|
}
|
|
6032
5954
|
async function runYtDlp(args) {
|
|
6033
|
-
const outTemplate =
|
|
6034
|
-
const infoPath =
|
|
5955
|
+
const outTemplate = path5.join(args.workDir, "out.%(ext)s");
|
|
5956
|
+
const infoPath = path5.join(args.workDir, "out.info.json");
|
|
6035
5957
|
const argv = [
|
|
6036
5958
|
args.url,
|
|
6037
5959
|
"--no-playlist",
|
|
@@ -6069,10 +5991,10 @@ async function runYtDlp(args) {
|
|
|
6069
5991
|
}
|
|
6070
5992
|
let info = {};
|
|
6071
5993
|
try {
|
|
6072
|
-
info = JSON.parse(await
|
|
5994
|
+
info = JSON.parse(await readFile3(infoPath, "utf-8"));
|
|
6073
5995
|
} catch {
|
|
6074
5996
|
}
|
|
6075
|
-
return { filePath:
|
|
5997
|
+
return { filePath: path5.join(args.workDir, downloaded), info, tier, reducedQuality };
|
|
6076
5998
|
}
|
|
6077
5999
|
async function probeYtDlp(args) {
|
|
6078
6000
|
const argv = [
|
|
@@ -6386,9 +6308,7 @@ function mapClientError(ctx, e) {
|
|
|
6386
6308
|
kind: "remote",
|
|
6387
6309
|
status: d.status,
|
|
6388
6310
|
code: "invalid_params",
|
|
6389
|
-
message: d.message
|
|
6390
|
-
// The request itself was refused; it fails the same way until the input changes.
|
|
6391
|
-
retryable: false
|
|
6311
|
+
message: d.message
|
|
6392
6312
|
});
|
|
6393
6313
|
}
|
|
6394
6314
|
if (d.kind === "unauthorized") {
|
|
@@ -6583,8 +6503,8 @@ function resolveLocalPath(input) {
|
|
|
6583
6503
|
`ingest: ~ path expansion is not supported (got "${input}"). Use an absolute path or a cwd-relative path.`
|
|
6584
6504
|
);
|
|
6585
6505
|
}
|
|
6586
|
-
if (
|
|
6587
|
-
return
|
|
6506
|
+
if (path6.isAbsolute(input)) return input;
|
|
6507
|
+
return path6.resolve(process.cwd(), input);
|
|
6588
6508
|
}
|
|
6589
6509
|
var EXT_TO_MIME = {
|
|
6590
6510
|
png: "image/png",
|
|
@@ -6632,7 +6552,7 @@ function sniffSvg(buf) {
|
|
|
6632
6552
|
return head.startsWith("<?xml") ? head.includes("<svg") : head.startsWith("<svg");
|
|
6633
6553
|
}
|
|
6634
6554
|
function inferMimeFromPath(absPath, sniffBytes) {
|
|
6635
|
-
const ext =
|
|
6555
|
+
const ext = path6.extname(absPath).slice(1).toLowerCase();
|
|
6636
6556
|
const fromExt = EXT_TO_MIME[ext];
|
|
6637
6557
|
if (fromExt) return fromExt;
|
|
6638
6558
|
const fromBytes = sniffImageMime(sniffBytes);
|
|
@@ -6817,7 +6737,7 @@ async function execLocalFile(params, ctx) {
|
|
|
6817
6737
|
}
|
|
6818
6738
|
let bytes;
|
|
6819
6739
|
try {
|
|
6820
|
-
bytes = await
|
|
6740
|
+
bytes = await readFile4(absPath);
|
|
6821
6741
|
} catch (e) {
|
|
6822
6742
|
if (e.code === "EACCES") {
|
|
6823
6743
|
throw localExecError(ctx, `permission_denied: ${absPath}`);
|
|
@@ -6869,7 +6789,7 @@ function localFileMetadata(args) {
|
|
|
6869
6789
|
strategy: "local_file",
|
|
6870
6790
|
ingested_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6871
6791
|
file_size: args.fileSize,
|
|
6872
|
-
original_filename:
|
|
6792
|
+
original_filename: path6.basename(args.absPath),
|
|
6873
6793
|
...args.rasterizedFrom ? { rasterized_from: args.rasterizedFrom } : {},
|
|
6874
6794
|
...args.durationMs !== void 0 ? { duration_ms: args.durationMs } : {}
|
|
6875
6795
|
};
|
|
@@ -6891,7 +6811,7 @@ async function execYtDlp(params, ctx) {
|
|
|
6891
6811
|
if (params.expect !== "video" && params.expect !== "audio") {
|
|
6892
6812
|
throw new Error(`ingest: yt_dlp only handles video/audio, got expect=${params.expect}`);
|
|
6893
6813
|
}
|
|
6894
|
-
const workDir = await mkdtemp(
|
|
6814
|
+
const workDir = await mkdtemp(path6.join(tmpdir(), "ingest-yt-"));
|
|
6895
6815
|
try {
|
|
6896
6816
|
const { filePath, info, reducedQuality } = await runYtDlpForNode({
|
|
6897
6817
|
url: params.url,
|
|
@@ -6906,7 +6826,7 @@ async function execYtDlp(params, ctx) {
|
|
|
6906
6826
|
`file_too_large: yt-dlp output for ${params.url} is ${downloadedStats.size} bytes (limit ${MAX_ASSET_BYTES})`
|
|
6907
6827
|
);
|
|
6908
6828
|
}
|
|
6909
|
-
const bytes = await
|
|
6829
|
+
const bytes = await readFile4(filePath);
|
|
6910
6830
|
const kind = params.expect;
|
|
6911
6831
|
const mime = YT_DLP_MIME[kind];
|
|
6912
6832
|
const metadata = buildYtDlpMetadata(params.url, info);
|
|
@@ -6995,9 +6915,9 @@ import { z as z6 } from "zod";
|
|
|
6995
6915
|
|
|
6996
6916
|
// src/engine/nodes/local/lib/cli-runner.ts
|
|
6997
6917
|
import { execFile as execFileCb2, spawn as spawn2 } from "child_process";
|
|
6998
|
-
import { copyFile as copyFile2, mkdtemp as mkdtemp2, readFile as
|
|
6918
|
+
import { copyFile as copyFile2, mkdtemp as mkdtemp2, readFile as readFile5, rm as rm2, stat as stat3 } from "fs/promises";
|
|
6999
6919
|
import { tmpdir as tmpdir2 } from "os";
|
|
7000
|
-
import
|
|
6920
|
+
import path7 from "path";
|
|
7001
6921
|
import { promisify as promisify2 } from "util";
|
|
7002
6922
|
var execFile2 = promisify2(execFileCb2);
|
|
7003
6923
|
var DEFAULT_TIMEOUT_MS2 = 10 * 60 * 1e3;
|
|
@@ -7024,7 +6944,7 @@ function mimeForExt(ext) {
|
|
|
7024
6944
|
}
|
|
7025
6945
|
function extForAssetRef(ref) {
|
|
7026
6946
|
if (ref.path) {
|
|
7027
|
-
const e =
|
|
6947
|
+
const e = path7.extname(ref.path);
|
|
7028
6948
|
if (e) return e;
|
|
7029
6949
|
}
|
|
7030
6950
|
const reverse = {
|
|
@@ -7046,14 +6966,14 @@ function planArrayInputSlot(tmpDir, slot, values, lookup, stagedInputs) {
|
|
|
7046
6966
|
const ref = values[i];
|
|
7047
6967
|
if (!ref) continue;
|
|
7048
6968
|
if (!ref.path) throw new Error(`cli-runner: inputs.${slot}[${i}] has no local path`);
|
|
7049
|
-
const dest =
|
|
6969
|
+
const dest = path7.join(tmpDir, `in_${slot}_${i}${extForAssetRef(ref)}`);
|
|
7050
6970
|
stagedInputs.push({ srcPath: ref.path, destPath: dest });
|
|
7051
6971
|
lookup.set(`in.${slot}.${i}`, dest);
|
|
7052
6972
|
}
|
|
7053
6973
|
}
|
|
7054
6974
|
function planSingleInputSlot(tmpDir, slot, ref, lookup, stagedInputs) {
|
|
7055
6975
|
if (!ref.path) throw new Error(`cli-runner: inputs.${slot} has no local path`);
|
|
7056
|
-
const dest =
|
|
6976
|
+
const dest = path7.join(tmpDir, `in_${slot}${extForAssetRef(ref)}`);
|
|
7057
6977
|
stagedInputs.push({ srcPath: ref.path, destPath: dest });
|
|
7058
6978
|
lookup.set(`in.${slot}`, dest);
|
|
7059
6979
|
}
|
|
@@ -7061,7 +6981,7 @@ function planOutputs(tmpDir, outputs, lookup) {
|
|
|
7061
6981
|
const outputPaths = [];
|
|
7062
6982
|
for (const [name, spec] of Object.entries(outputs)) {
|
|
7063
6983
|
const ext = spec.ext.startsWith(".") ? spec.ext : `.${spec.ext}`;
|
|
7064
|
-
const absPath =
|
|
6984
|
+
const absPath = path7.join(tmpDir, `out_${name}${ext}`);
|
|
7065
6985
|
outputPaths.push({ name, absPath, spec });
|
|
7066
6986
|
lookup.set(`out.${name}`, absPath);
|
|
7067
6987
|
}
|
|
@@ -7102,8 +7022,8 @@ function rejectRawPaths(substituted, original, stagingDir) {
|
|
|
7102
7022
|
throw new Error(`cli-runner: home-relative path "${original}" not allowed in args.`);
|
|
7103
7023
|
}
|
|
7104
7024
|
if (substituted.startsWith("/")) {
|
|
7105
|
-
const resolved =
|
|
7106
|
-
if (!resolved.startsWith(`${stagingDir}${
|
|
7025
|
+
const resolved = path7.resolve(substituted);
|
|
7026
|
+
if (!resolved.startsWith(`${stagingDir}${path7.sep}`) && resolved !== stagingDir) {
|
|
7107
7027
|
throw new Error(
|
|
7108
7028
|
`cli-runner: raw filesystem path "${original}" not allowed \u2014 declare an input slot and use {{in.<slot>}} instead.`
|
|
7109
7029
|
);
|
|
@@ -7153,7 +7073,7 @@ function tailLines(text, maxLines) {
|
|
|
7153
7073
|
}
|
|
7154
7074
|
async function runCli(opts) {
|
|
7155
7075
|
const { bin, args, inputs, outputs, ctx, timeoutMs = DEFAULT_TIMEOUT_MS2 } = opts;
|
|
7156
|
-
const tmpDir = await mkdtemp2(
|
|
7076
|
+
const tmpDir = await mkdtemp2(path7.join(tmpdir2(), `cli-${bin.replace(/[^a-z0-9]/gi, "")}-`));
|
|
7157
7077
|
try {
|
|
7158
7078
|
const { lookup, stagedInputs, outputPaths } = planPlaceholders(tmpDir, inputs, outputs);
|
|
7159
7079
|
await stageInputs(stagedInputs);
|
|
@@ -7175,7 +7095,7 @@ ${tailLines(stderr, 40)}`);
|
|
|
7175
7095
|
if (!s?.isFile() || s.size === 0) {
|
|
7176
7096
|
throw new Error(`cli-runner: declared output "${name}" missing or empty at ${absPath}`);
|
|
7177
7097
|
}
|
|
7178
|
-
const bytes = await
|
|
7098
|
+
const bytes = await readFile5(absPath);
|
|
7179
7099
|
const ref = await ctx.assets.ingestBytes({
|
|
7180
7100
|
bytes: Buffer.from(bytes),
|
|
7181
7101
|
kind: spec.kind,
|
|
@@ -7445,17 +7365,17 @@ var ffmpegNode = defineNode({
|
|
|
7445
7365
|
import { mkdtemp as mkdtemp3, rm as rm3, writeFile as writeFile4 } from "fs/promises";
|
|
7446
7366
|
import { createRequire } from "module";
|
|
7447
7367
|
import { tmpdir as tmpdir3 } from "os";
|
|
7448
|
-
import
|
|
7368
|
+
import path9 from "path";
|
|
7449
7369
|
import { z as z9 } from "zod";
|
|
7450
7370
|
|
|
7451
7371
|
// src/engine/nodes/local/lib/assets.ts
|
|
7452
|
-
import { copyFile as copyFile3, readFile as
|
|
7453
|
-
import
|
|
7372
|
+
import { copyFile as copyFile3, readFile as readFile6 } from "fs/promises";
|
|
7373
|
+
import path8 from "path";
|
|
7454
7374
|
async function stageAsset(ref, destDir, filename) {
|
|
7455
7375
|
if (!ref.path) {
|
|
7456
7376
|
throw new Error(`stageAsset: ref (${ref.kind}/${ref.mime}) has no local path`);
|
|
7457
7377
|
}
|
|
7458
|
-
const dest =
|
|
7378
|
+
const dest = path8.join(destDir, filename);
|
|
7459
7379
|
await copyFile3(ref.path, dest);
|
|
7460
7380
|
return dest;
|
|
7461
7381
|
}
|
|
@@ -7464,7 +7384,7 @@ async function refToUrl(ref) {
|
|
|
7464
7384
|
if (!ref.path) {
|
|
7465
7385
|
throw new Error("refToUrl: AssetRef has neither url nor path");
|
|
7466
7386
|
}
|
|
7467
|
-
const bytes = await
|
|
7387
|
+
const bytes = await readFile6(ref.path);
|
|
7468
7388
|
return `data:${ref.mime};base64,${bytes.toString("base64")}`;
|
|
7469
7389
|
}
|
|
7470
7390
|
var ASSET_KINDS = /* @__PURE__ */ new Set(["image", "video", "audio", "json", "text", "font"]);
|
|
@@ -7538,11 +7458,11 @@ var fontSpecimenNode = defineNode({
|
|
|
7538
7458
|
outputKinds: { image: "image" },
|
|
7539
7459
|
cost: () => ({ credits: 0, seconds_estimate: 5 }),
|
|
7540
7460
|
async execute({ inputs, params, ctx }) {
|
|
7541
|
-
const tmp = await mkdtemp3(
|
|
7461
|
+
const tmp = await mkdtemp3(path9.join(tmpdir3(), "font-specimen-"));
|
|
7542
7462
|
try {
|
|
7543
7463
|
const fontFilename = `font.${extForMime(inputs.font.mime)}`;
|
|
7544
7464
|
await stageAsset(inputs.font, tmp, fontFilename);
|
|
7545
|
-
const entryPath =
|
|
7465
|
+
const entryPath = path9.join(tmp, "index.html");
|
|
7546
7466
|
await writeFile4(entryPath, buildSpecimenHtml(params, fontFilename), "utf-8");
|
|
7547
7467
|
ctx.log(`rendering specimen (${params.font_size}px, ${params.text.split("\n").length} lines)`);
|
|
7548
7468
|
const pwSpecifier = ["play", "wright"].join("");
|
|
@@ -7626,16 +7546,16 @@ var fontSpecimenNode = defineNode({
|
|
|
7626
7546
|
|
|
7627
7547
|
// src/engine/nodes/local/hyperframe.ts
|
|
7628
7548
|
import { execFile as execFile4 } from "child_process";
|
|
7629
|
-
import { copyFile as copyFile4, mkdtemp as mkdtemp4, readFile as
|
|
7549
|
+
import { copyFile as copyFile4, mkdtemp as mkdtemp4, readFile as readFile10, rm as rm4, stat as stat5, writeFile as writeFile6 } from "fs/promises";
|
|
7630
7550
|
import { createRequire as createRequire2 } from "module";
|
|
7631
7551
|
import { cpus, tmpdir as tmpdir4 } from "os";
|
|
7632
|
-
import
|
|
7552
|
+
import path14 from "path";
|
|
7633
7553
|
import { promisify as promisify4 } from "util";
|
|
7634
7554
|
import { z as z11 } from "zod";
|
|
7635
7555
|
|
|
7636
7556
|
// src/engine/engine/composition-hash.ts
|
|
7637
|
-
import { readdir as readdir2, readFile as
|
|
7638
|
-
import
|
|
7557
|
+
import { readdir as readdir2, readFile as readFile7, stat as stat4 } from "fs/promises";
|
|
7558
|
+
import path10 from "path";
|
|
7639
7559
|
var SKIP_DIRS = /* @__PURE__ */ new Set([".cache", ".git", "node_modules", "dist", "build", ".next", ".turbo"]);
|
|
7640
7560
|
function isSkippedName(name) {
|
|
7641
7561
|
if (name.startsWith(".")) return true;
|
|
@@ -7652,23 +7572,23 @@ async function collectFiles(root, current) {
|
|
|
7652
7572
|
const names = await readdir2(current);
|
|
7653
7573
|
for (const name of names) {
|
|
7654
7574
|
if (isSkippedName(name)) continue;
|
|
7655
|
-
const abs =
|
|
7575
|
+
const abs = path10.join(current, name);
|
|
7656
7576
|
const s = await stat4(abs);
|
|
7657
7577
|
if (s.isDirectory()) {
|
|
7658
7578
|
out.push(...await collectFiles(root, abs));
|
|
7659
7579
|
continue;
|
|
7660
7580
|
}
|
|
7661
7581
|
if (!s.isFile()) continue;
|
|
7662
|
-
const bytes = await
|
|
7663
|
-
const relPath =
|
|
7582
|
+
const bytes = await readFile7(abs);
|
|
7583
|
+
const relPath = path10.relative(root, abs).split(path10.sep).join("/");
|
|
7664
7584
|
out.push({ relPath, contentSha: sha256Hex(bytes) });
|
|
7665
7585
|
}
|
|
7666
7586
|
return out;
|
|
7667
7587
|
}
|
|
7668
7588
|
|
|
7669
7589
|
// src/engine/engine/composition-meta.ts
|
|
7670
|
-
import { readFile as
|
|
7671
|
-
import
|
|
7590
|
+
import { readFile as readFile8 } from "fs/promises";
|
|
7591
|
+
import path11 from "path";
|
|
7672
7592
|
import { z as z10 } from "zod";
|
|
7673
7593
|
var InputKind = z10.enum(["video", "image", "audio", "json"]);
|
|
7674
7594
|
var InputSpec = z10.object({
|
|
@@ -7745,10 +7665,10 @@ var CompositionMetaSchema = z10.object({
|
|
|
7745
7665
|
params: z10.record(z10.string(), ParamSpec).default({})
|
|
7746
7666
|
}).strict();
|
|
7747
7667
|
async function loadCompositionMeta(compositionDir) {
|
|
7748
|
-
const metaPath =
|
|
7668
|
+
const metaPath = path11.join(compositionDir, "meta.json");
|
|
7749
7669
|
let raw;
|
|
7750
7670
|
try {
|
|
7751
|
-
raw = await
|
|
7671
|
+
raw = await readFile8(metaPath, "utf-8");
|
|
7752
7672
|
} catch (e) {
|
|
7753
7673
|
throw new Error(`composition meta: cannot read ${metaPath} (${e.message})`);
|
|
7754
7674
|
}
|
|
@@ -7826,8 +7746,8 @@ function defaultFilenameForInput(key, kind) {
|
|
|
7826
7746
|
|
|
7827
7747
|
// src/engine/nodes/local/lib/hyperframe-check.ts
|
|
7828
7748
|
import { execFile as execFile3 } from "child_process";
|
|
7829
|
-
import { readFile as
|
|
7830
|
-
import
|
|
7749
|
+
import { readFile as readFile9 } from "fs/promises";
|
|
7750
|
+
import path12 from "path";
|
|
7831
7751
|
import { promisify as promisify3 } from "util";
|
|
7832
7752
|
|
|
7833
7753
|
// src/engine/nodes/local/lib/caption-style.ts
|
|
@@ -8051,7 +7971,7 @@ async function runSnapshotSmoke(args, timeoutMs) {
|
|
|
8051
7971
|
}
|
|
8052
7972
|
async function runNestedCompositionSmoke(opts) {
|
|
8053
7973
|
const { dir, nodeId, ctx, timeoutMs, samples } = opts;
|
|
8054
|
-
const indexHtml = await
|
|
7974
|
+
const indexHtml = await readFile9(path12.join(dir, "index.html"), "utf-8").catch(() => "");
|
|
8055
7975
|
if (!indexHtml || !usesNestedCompositions(indexHtml)) return;
|
|
8056
7976
|
const snap = await runSnapshotSmoke(
|
|
8057
7977
|
buildSnapshotArgs(dir, Math.min(samples, 3), hasFrameVisionKey()),
|
|
@@ -8067,7 +7987,7 @@ async function runNestedCompositionSmoke(opts) {
|
|
|
8067
7987
|
${snap.message}`
|
|
8068
7988
|
);
|
|
8069
7989
|
}
|
|
8070
|
-
const described = await
|
|
7990
|
+
const described = await readFile9(path12.join(dir, "snapshots", "descriptions.md"), "utf-8").catch(() => "");
|
|
8071
7991
|
for (const line of condenseFrameDescriptions(described)) {
|
|
8072
7992
|
ctx.log(`${nodeId}: frame check \u2014 ${line}`);
|
|
8073
7993
|
}
|
|
@@ -8103,7 +8023,7 @@ async function runHyperframesCheck(opts) {
|
|
|
8103
8023
|
${detail}`
|
|
8104
8024
|
);
|
|
8105
8025
|
}
|
|
8106
|
-
const composition = await
|
|
8026
|
+
const composition = await readFile9(path12.join(dir, "index.html"), "utf-8").catch(() => "");
|
|
8107
8027
|
const captionComplaint = fragmentedCaptions(captionTextsFrom(composition));
|
|
8108
8028
|
if (captionComplaint) {
|
|
8109
8029
|
ctx.log(`${nodeId}: caption style \u2014 ${captionComplaint}`);
|
|
@@ -8157,9 +8077,9 @@ ${stderr.slice(0, 1500)}`;
|
|
|
8157
8077
|
|
|
8158
8078
|
// src/engine/nodes/local/lib/hyperframe-meta.ts
|
|
8159
8079
|
import { writeFile as writeFile5 } from "fs/promises";
|
|
8160
|
-
import
|
|
8080
|
+
import path13 from "path";
|
|
8161
8081
|
async function ensureHyperframesMetaJson(tmp, nodeId, meta, duration) {
|
|
8162
|
-
const metaPath =
|
|
8082
|
+
const metaPath = path13.join(tmp, "meta.json");
|
|
8163
8083
|
await writeFile5(
|
|
8164
8084
|
metaPath,
|
|
8165
8085
|
JSON.stringify(
|
|
@@ -8259,7 +8179,7 @@ var hyperframeRenderNode = defineNode({
|
|
|
8259
8179
|
const compositionDir = await resolveCompositionDir(params.composition);
|
|
8260
8180
|
const meta = await loadCompositionMeta(compositionDir);
|
|
8261
8181
|
const compositionParams = validateAndParseDynamicParams(meta, params);
|
|
8262
|
-
const tmp = await mkdtemp4(
|
|
8182
|
+
const tmp = await mkdtemp4(path14.join(tmpdir4(), "hf-render-"));
|
|
8263
8183
|
try {
|
|
8264
8184
|
await copyComposition(compositionDir, tmp);
|
|
8265
8185
|
await vendorGsap(tmp, ctx);
|
|
@@ -8269,9 +8189,9 @@ var hyperframeRenderNode = defineNode({
|
|
|
8269
8189
|
await substituteCompositionFiles(tmp, substitutionValues);
|
|
8270
8190
|
await ensureHyperframesMetaJson(tmp, ctx.nodeId, meta, duration);
|
|
8271
8191
|
await runHyperframesCheck({ dir: tmp, nodeId: "hyperframe_render", ctx, timeoutMs: params.timeout_ms });
|
|
8272
|
-
const outputPath =
|
|
8192
|
+
const outputPath = path14.join(tmp, `output.${params.format}`);
|
|
8273
8193
|
await runRender({ tmp, outputPath, params, meta, ctx });
|
|
8274
|
-
const bytes = await
|
|
8194
|
+
const bytes = await readFile10(outputPath);
|
|
8275
8195
|
ctx.log(`rendered ${bytes.length} bytes`);
|
|
8276
8196
|
const ref = await ctx.assets.ingestBytes({
|
|
8277
8197
|
bytes: Buffer.from(bytes),
|
|
@@ -8293,10 +8213,10 @@ var hyperframeRenderNode = defineNode({
|
|
|
8293
8213
|
}
|
|
8294
8214
|
});
|
|
8295
8215
|
async function resolveCompositionDir(composition) {
|
|
8296
|
-
const compositionPath =
|
|
8216
|
+
const compositionPath = path14.isAbsolute(composition) ? composition : path14.resolve(process.cwd(), composition);
|
|
8297
8217
|
const s = await stat5(compositionPath);
|
|
8298
8218
|
if (s.isDirectory()) return compositionPath;
|
|
8299
|
-
return
|
|
8219
|
+
return path14.dirname(compositionPath);
|
|
8300
8220
|
}
|
|
8301
8221
|
async function validateComposition(rawParams) {
|
|
8302
8222
|
const issues = await validateCompositionParams(rawParams);
|
|
@@ -8378,7 +8298,7 @@ async function copyComposition(srcDir, destDir) {
|
|
|
8378
8298
|
await cp(srcDir, destDir, {
|
|
8379
8299
|
recursive: true,
|
|
8380
8300
|
filter: (src) => {
|
|
8381
|
-
const name =
|
|
8301
|
+
const name = path14.basename(src);
|
|
8382
8302
|
if (name === ".cache" || name === "node_modules" || name === ".git") return false;
|
|
8383
8303
|
return true;
|
|
8384
8304
|
}
|
|
@@ -8387,7 +8307,7 @@ async function copyComposition(srcDir, destDir) {
|
|
|
8387
8307
|
async function vendorGsap(tmp, ctx) {
|
|
8388
8308
|
try {
|
|
8389
8309
|
const gsapMin = require_2.resolve("gsap/dist/gsap.min.js");
|
|
8390
|
-
await copyFile4(gsapMin,
|
|
8310
|
+
await copyFile4(gsapMin, path14.join(tmp, "gsap.min.js"));
|
|
8391
8311
|
} catch (e) {
|
|
8392
8312
|
ctx.log(`warning: could not vendor gsap.min.js (${e.message}); compositions must self-supply`);
|
|
8393
8313
|
}
|
|
@@ -8402,7 +8322,7 @@ async function stageInputs2(tmp, inputs, meta, ctx) {
|
|
|
8402
8322
|
await stageAsset(ref, tmp, filename);
|
|
8403
8323
|
ctx.log(`staged ${spec.kind} \u2192 ${filename}`);
|
|
8404
8324
|
if (spec.kind === "video" && primaryDuration === null) {
|
|
8405
|
-
primaryDuration = await probeDurationSeconds(
|
|
8325
|
+
primaryDuration = await probeDurationSeconds(path14.join(tmp, filename));
|
|
8406
8326
|
}
|
|
8407
8327
|
}
|
|
8408
8328
|
return primaryDuration;
|
|
@@ -8448,8 +8368,8 @@ function coerceImageParam(value) {
|
|
|
8448
8368
|
throw new Error("hyperframe_render: image param must be a URL string or AssetRef");
|
|
8449
8369
|
}
|
|
8450
8370
|
async function substituteCompositionFiles(tmp, values) {
|
|
8451
|
-
const entryPath =
|
|
8452
|
-
const original = await
|
|
8371
|
+
const entryPath = path14.join(tmp, "index.html");
|
|
8372
|
+
const original = await readFile10(entryPath, "utf-8");
|
|
8453
8373
|
const { output, missing } = substituteVariables(original, values);
|
|
8454
8374
|
if (missing.length > 0) {
|
|
8455
8375
|
throw new Error(
|
|
@@ -8465,7 +8385,7 @@ function workerCount() {
|
|
|
8465
8385
|
async function runRender(opts) {
|
|
8466
8386
|
const { tmp, outputPath, params, meta, ctx } = opts;
|
|
8467
8387
|
const args = buildRenderArgs(tmp, outputPath, meta, params.format);
|
|
8468
|
-
ctx.log(`rendering ${meta.width}x${meta.height}@${meta.fps}fps ${params.format} from ${
|
|
8388
|
+
ctx.log(`rendering ${meta.width}x${meta.height}@${meta.fps}fps ${params.format} from ${path14.basename(tmp)}`);
|
|
8469
8389
|
try {
|
|
8470
8390
|
await execFileAsync2("npx", args, { timeout: params.timeout_ms, maxBuffer: 64 * 1024 * 1024 });
|
|
8471
8391
|
} catch (e) {
|
|
@@ -8509,10 +8429,10 @@ async function probeDurationSeconds(filePath) {
|
|
|
8509
8429
|
|
|
8510
8430
|
// src/engine/nodes/local/hyperframe-snapshot.ts
|
|
8511
8431
|
import { execFile as execFile5 } from "child_process";
|
|
8512
|
-
import { copyFile as copyFile5, mkdtemp as mkdtemp5, readFile as
|
|
8432
|
+
import { copyFile as copyFile5, mkdtemp as mkdtemp5, readFile as readFile11, rm as rm5, writeFile as writeFile7 } from "fs/promises";
|
|
8513
8433
|
import { createRequire as createRequire3 } from "module";
|
|
8514
8434
|
import { tmpdir as tmpdir5 } from "os";
|
|
8515
|
-
import
|
|
8435
|
+
import path15 from "path";
|
|
8516
8436
|
import { promisify as promisify5 } from "util";
|
|
8517
8437
|
import { z as z12 } from "zod";
|
|
8518
8438
|
var _execFileAsync = promisify5(execFile5);
|
|
@@ -8559,7 +8479,7 @@ var hyperframeSnapshotNode = defineNode({
|
|
|
8559
8479
|
const compositionDir = await resolveCompositionDir(params.composition);
|
|
8560
8480
|
const meta = await loadCompositionMeta(compositionDir);
|
|
8561
8481
|
const compositionParams = validateAndParseDynamicParams2(meta, params);
|
|
8562
|
-
const tmp = await mkdtemp5(
|
|
8482
|
+
const tmp = await mkdtemp5(path15.join(tmpdir5(), "hf-snap-"));
|
|
8563
8483
|
try {
|
|
8564
8484
|
await copyComposition2(compositionDir, tmp);
|
|
8565
8485
|
await vendorGsap2(tmp, ctx);
|
|
@@ -8574,7 +8494,7 @@ var hyperframeSnapshotNode = defineNode({
|
|
|
8574
8494
|
timeoutMs: params.timeout_ms,
|
|
8575
8495
|
samples: 1
|
|
8576
8496
|
});
|
|
8577
|
-
const entryPath =
|
|
8497
|
+
const entryPath = path15.join(tmp, "index.html");
|
|
8578
8498
|
const entryUrl = `file://${entryPath}`;
|
|
8579
8499
|
ctx.log(`snapshotting ${meta.width}x${meta.height}@${DEVICE_SCALE_FACTOR2}x wait=${params.wait_for.kind}`);
|
|
8580
8500
|
const pwSpecifier = ["play", "wright"].join("");
|
|
@@ -8635,7 +8555,7 @@ async function copyComposition2(srcDir, destDir) {
|
|
|
8635
8555
|
await cp(srcDir, destDir, {
|
|
8636
8556
|
recursive: true,
|
|
8637
8557
|
filter: (src) => {
|
|
8638
|
-
const name =
|
|
8558
|
+
const name = path15.basename(src);
|
|
8639
8559
|
if (name === ".cache" || name === "node_modules" || name === ".git") return false;
|
|
8640
8560
|
return true;
|
|
8641
8561
|
}
|
|
@@ -8644,7 +8564,7 @@ async function copyComposition2(srcDir, destDir) {
|
|
|
8644
8564
|
async function vendorGsap2(tmp, ctx) {
|
|
8645
8565
|
try {
|
|
8646
8566
|
const gsapMin = require_3.resolve("gsap/dist/gsap.min.js");
|
|
8647
|
-
await copyFile5(gsapMin,
|
|
8567
|
+
await copyFile5(gsapMin, path15.join(tmp, "gsap.min.js"));
|
|
8648
8568
|
} catch (e) {
|
|
8649
8569
|
ctx.log(`warning: could not vendor gsap.min.js (${e.message}); compositions must self-supply`);
|
|
8650
8570
|
}
|
|
@@ -8678,8 +8598,8 @@ function coerceImageParam2(value) {
|
|
|
8678
8598
|
throw new Error("hyperframe_snapshot: image param must be a URL string or AssetRef");
|
|
8679
8599
|
}
|
|
8680
8600
|
async function substituteCompositionFiles2(tmp, values) {
|
|
8681
|
-
const entryPath =
|
|
8682
|
-
const original = await
|
|
8601
|
+
const entryPath = path15.join(tmp, "index.html");
|
|
8602
|
+
const original = await readFile11(entryPath, "utf-8");
|
|
8683
8603
|
const { output, missing } = substituteVariables(original, values);
|
|
8684
8604
|
if (missing.length > 0) {
|
|
8685
8605
|
throw new Error(
|
|
@@ -9446,9 +9366,9 @@ var videoLipsyncNode = delegated({
|
|
|
9446
9366
|
});
|
|
9447
9367
|
|
|
9448
9368
|
// src/engine/nodes/remote/videoTranscribe.ts
|
|
9449
|
-
import { mkdtemp as mkdtemp6, readFile as
|
|
9369
|
+
import { mkdtemp as mkdtemp6, readFile as readFile12, rm as rm6 } from "fs/promises";
|
|
9450
9370
|
import { tmpdir as tmpdir6 } from "os";
|
|
9451
|
-
import
|
|
9371
|
+
import path16 from "path";
|
|
9452
9372
|
import { z as z33 } from "zod";
|
|
9453
9373
|
|
|
9454
9374
|
// src/engine/nodes/local/lib/ffmpeg.ts
|
|
@@ -9586,14 +9506,14 @@ async function tryExtractAudio(inputs, ctx) {
|
|
|
9586
9506
|
ctx.log("video_transcribe: no audio track detected, sending full video");
|
|
9587
9507
|
return null;
|
|
9588
9508
|
}
|
|
9589
|
-
tmpDir = await mkdtemp6(
|
|
9590
|
-
const audioPath =
|
|
9509
|
+
tmpDir = await mkdtemp6(path16.join(tmpdir6(), "vtx-"));
|
|
9510
|
+
const audioPath = path16.join(tmpDir, "audio.mp3");
|
|
9591
9511
|
ctx.log("video_transcribe: extracting audio (mono 16kHz mp3)");
|
|
9592
9512
|
await runFfmpeg(
|
|
9593
9513
|
["-i", video.path, "-vn", "-ac", "1", "-ar", "16000", "-b:a", "64k", "-f", "mp3", "-y", audioPath],
|
|
9594
9514
|
{ timeout_ms: AUDIO_EXTRACT_TIMEOUT_MS }
|
|
9595
9515
|
);
|
|
9596
|
-
const bytes = await
|
|
9516
|
+
const bytes = await readFile12(audioPath);
|
|
9597
9517
|
if (bytes.byteLength === 0) {
|
|
9598
9518
|
ctx.log("video_transcribe: extracted audio is empty, sending full video");
|
|
9599
9519
|
return null;
|
|
@@ -9784,19 +9704,19 @@ function safeCost(def) {
|
|
|
9784
9704
|
|
|
9785
9705
|
// src/engine/storage/cache-store.ts
|
|
9786
9706
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
9787
|
-
import { mkdir as mkdir3, readFile as
|
|
9788
|
-
import
|
|
9707
|
+
import { mkdir as mkdir3, readFile as readFile13, rename as rename2, writeFile as writeFile8 } from "fs/promises";
|
|
9708
|
+
import path17 from "path";
|
|
9789
9709
|
var LocalCacheStore = class {
|
|
9790
9710
|
rootDir;
|
|
9791
9711
|
constructor(rootDir) {
|
|
9792
9712
|
this.rootDir = rootDir;
|
|
9793
9713
|
}
|
|
9794
9714
|
filePath(cacheKey) {
|
|
9795
|
-
return
|
|
9715
|
+
return path17.join(this.rootDir, `${cacheKey}.json`);
|
|
9796
9716
|
}
|
|
9797
9717
|
async get(cacheKey) {
|
|
9798
9718
|
try {
|
|
9799
|
-
const buf = await
|
|
9719
|
+
const buf = await readFile13(this.filePath(cacheKey), "utf8");
|
|
9800
9720
|
return JSON.parse(buf);
|
|
9801
9721
|
} catch (e) {
|
|
9802
9722
|
if (e.code === "ENOENT") return null;
|
|
@@ -9805,7 +9725,7 @@ var LocalCacheStore = class {
|
|
|
9805
9725
|
}
|
|
9806
9726
|
async put(entry) {
|
|
9807
9727
|
const dest = this.filePath(entry.cacheKey);
|
|
9808
|
-
await mkdir3(
|
|
9728
|
+
await mkdir3(path17.dirname(dest), { recursive: true });
|
|
9809
9729
|
const tmp = `${dest}.tmp-${process.pid}-${randomUUID2()}`;
|
|
9810
9730
|
await writeFile8(tmp, JSON.stringify(entry, null, 0));
|
|
9811
9731
|
await rename2(tmp, dest);
|
|
@@ -9861,12 +9781,12 @@ function defaultRegistry() {
|
|
|
9861
9781
|
}
|
|
9862
9782
|
function createEngineFromEnv(opts = {}) {
|
|
9863
9783
|
const cwd = opts.cwd ?? process.cwd();
|
|
9864
|
-
const cacheDir = opts.cacheDir ??
|
|
9865
|
-
const outputsDir = opts.outputsDir ??
|
|
9784
|
+
const cacheDir = opts.cacheDir ?? path18.join(cwd, "canvas", ".cache");
|
|
9785
|
+
const outputsDir = opts.outputsDir ?? path18.join(cwd, "canvas");
|
|
9866
9786
|
const connection = requireConnection();
|
|
9867
9787
|
const client = new BackendClient({ baseUrl: connection.BAKER_API_URL, apiKey: connection.BAKER_API_KEY });
|
|
9868
|
-
const assets = new LocalAssetStore(
|
|
9869
|
-
const localCache = new LocalCacheStore(
|
|
9788
|
+
const assets = new LocalAssetStore(path18.join(cacheDir, "assets"));
|
|
9789
|
+
const localCache = new LocalCacheStore(path18.join(cacheDir, "index"));
|
|
9870
9790
|
const remoteCacheEnabled = opts.remoteCache ?? remoteCacheEnabledFromEnv();
|
|
9871
9791
|
const cache = remoteCacheEnabled ? new LayeredCacheStore({
|
|
9872
9792
|
local: localCache,
|
|
@@ -9891,7 +9811,6 @@ export {
|
|
|
9891
9811
|
RunAbortedError,
|
|
9892
9812
|
LayerExecutionError,
|
|
9893
9813
|
describeFailureReason,
|
|
9894
|
-
runFailureCode,
|
|
9895
9814
|
AD_FORMAT_PLATFORMS,
|
|
9896
9815
|
platformFormats,
|
|
9897
9816
|
withoutCastName,
|
|
@@ -9959,4 +9878,4 @@ export {
|
|
|
9959
9878
|
defaultRegistry,
|
|
9960
9879
|
createEngineFromEnv
|
|
9961
9880
|
};
|
|
9962
|
-
//# sourceMappingURL=chunk-
|
|
9881
|
+
//# sourceMappingURL=chunk-B7MLH3K6.js.map
|