@koda-sl/baker-cli 0.384.0-dev.4699b7308 → 0.384.0-dev.8831a46bb
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 +77 -57
- 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-CHJOTJTZ.js → chunk-RK44ZR7L.js} +111 -193
- package/dist/chunk-RK44ZR7L.js.map +1 -0
- package/dist/{chunk-MF7YA62W.js → chunk-UMIALY2G.js} +3 -3
- package/dist/cli.js +6302 -4405
- 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-CHJOTJTZ.js.map +0 -1
- package/dist/chunk-HJEMOSPH.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
|
}
|
|
@@ -6052,8 +5973,8 @@ function tail(text, maxLines) {
|
|
|
6052
5973
|
return text.split("\n").slice(-maxLines).join("\n");
|
|
6053
5974
|
}
|
|
6054
5975
|
async function runYtDlp(args) {
|
|
6055
|
-
const outTemplate =
|
|
6056
|
-
const infoPath =
|
|
5976
|
+
const outTemplate = path5.join(args.workDir, "out.%(ext)s");
|
|
5977
|
+
const infoPath = path5.join(args.workDir, "out.info.json");
|
|
6057
5978
|
const argv = [
|
|
6058
5979
|
args.url,
|
|
6059
5980
|
"--no-playlist",
|
|
@@ -6091,10 +6012,10 @@ async function runYtDlp(args) {
|
|
|
6091
6012
|
}
|
|
6092
6013
|
let info = {};
|
|
6093
6014
|
try {
|
|
6094
|
-
info = JSON.parse(await
|
|
6015
|
+
info = JSON.parse(await readFile3(infoPath, "utf-8"));
|
|
6095
6016
|
} catch {
|
|
6096
6017
|
}
|
|
6097
|
-
return { filePath:
|
|
6018
|
+
return { filePath: path5.join(args.workDir, downloaded), info, tier, reducedQuality };
|
|
6098
6019
|
}
|
|
6099
6020
|
async function probeYtDlp(args) {
|
|
6100
6021
|
const argv = [
|
|
@@ -6408,9 +6329,7 @@ function mapClientError(ctx, e) {
|
|
|
6408
6329
|
kind: "remote",
|
|
6409
6330
|
status: d.status,
|
|
6410
6331
|
code: "invalid_params",
|
|
6411
|
-
message: d.message
|
|
6412
|
-
// The request itself was refused; it fails the same way until the input changes.
|
|
6413
|
-
retryable: false
|
|
6332
|
+
message: d.message
|
|
6414
6333
|
});
|
|
6415
6334
|
}
|
|
6416
6335
|
if (d.kind === "unauthorized") {
|
|
@@ -6605,8 +6524,8 @@ function resolveLocalPath(input) {
|
|
|
6605
6524
|
`ingest: ~ path expansion is not supported (got "${input}"). Use an absolute path or a cwd-relative path.`
|
|
6606
6525
|
);
|
|
6607
6526
|
}
|
|
6608
|
-
if (
|
|
6609
|
-
return
|
|
6527
|
+
if (path6.isAbsolute(input)) return input;
|
|
6528
|
+
return path6.resolve(process.cwd(), input);
|
|
6610
6529
|
}
|
|
6611
6530
|
var EXT_TO_MIME = {
|
|
6612
6531
|
png: "image/png",
|
|
@@ -6654,7 +6573,7 @@ function sniffSvg(buf) {
|
|
|
6654
6573
|
return head.startsWith("<?xml") ? head.includes("<svg") : head.startsWith("<svg");
|
|
6655
6574
|
}
|
|
6656
6575
|
function inferMimeFromPath(absPath, sniffBytes) {
|
|
6657
|
-
const ext =
|
|
6576
|
+
const ext = path6.extname(absPath).slice(1).toLowerCase();
|
|
6658
6577
|
const fromExt = EXT_TO_MIME[ext];
|
|
6659
6578
|
if (fromExt) return fromExt;
|
|
6660
6579
|
const fromBytes = sniffImageMime(sniffBytes);
|
|
@@ -6839,7 +6758,7 @@ async function execLocalFile(params, ctx) {
|
|
|
6839
6758
|
}
|
|
6840
6759
|
let bytes;
|
|
6841
6760
|
try {
|
|
6842
|
-
bytes = await
|
|
6761
|
+
bytes = await readFile4(absPath);
|
|
6843
6762
|
} catch (e) {
|
|
6844
6763
|
if (e.code === "EACCES") {
|
|
6845
6764
|
throw localExecError(ctx, `permission_denied: ${absPath}`);
|
|
@@ -6891,7 +6810,7 @@ function localFileMetadata(args) {
|
|
|
6891
6810
|
strategy: "local_file",
|
|
6892
6811
|
ingested_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6893
6812
|
file_size: args.fileSize,
|
|
6894
|
-
original_filename:
|
|
6813
|
+
original_filename: path6.basename(args.absPath),
|
|
6895
6814
|
...args.rasterizedFrom ? { rasterized_from: args.rasterizedFrom } : {},
|
|
6896
6815
|
...args.durationMs !== void 0 ? { duration_ms: args.durationMs } : {}
|
|
6897
6816
|
};
|
|
@@ -6913,7 +6832,7 @@ async function execYtDlp(params, ctx) {
|
|
|
6913
6832
|
if (params.expect !== "video" && params.expect !== "audio") {
|
|
6914
6833
|
throw new Error(`ingest: yt_dlp only handles video/audio, got expect=${params.expect}`);
|
|
6915
6834
|
}
|
|
6916
|
-
const workDir = await mkdtemp(
|
|
6835
|
+
const workDir = await mkdtemp(path6.join(tmpdir(), "ingest-yt-"));
|
|
6917
6836
|
try {
|
|
6918
6837
|
const { filePath, info, reducedQuality } = await runYtDlpForNode({
|
|
6919
6838
|
url: params.url,
|
|
@@ -6928,7 +6847,7 @@ async function execYtDlp(params, ctx) {
|
|
|
6928
6847
|
`file_too_large: yt-dlp output for ${params.url} is ${downloadedStats.size} bytes (limit ${MAX_ASSET_BYTES})`
|
|
6929
6848
|
);
|
|
6930
6849
|
}
|
|
6931
|
-
const bytes = await
|
|
6850
|
+
const bytes = await readFile4(filePath);
|
|
6932
6851
|
const kind = params.expect;
|
|
6933
6852
|
const mime = YT_DLP_MIME[kind];
|
|
6934
6853
|
const metadata = buildYtDlpMetadata(params.url, info);
|
|
@@ -7017,9 +6936,9 @@ import { z as z6 } from "zod";
|
|
|
7017
6936
|
|
|
7018
6937
|
// src/engine/nodes/local/lib/cli-runner.ts
|
|
7019
6938
|
import { execFile as execFileCb2, spawn as spawn2 } from "child_process";
|
|
7020
|
-
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";
|
|
7021
6940
|
import { tmpdir as tmpdir2 } from "os";
|
|
7022
|
-
import
|
|
6941
|
+
import path7 from "path";
|
|
7023
6942
|
import { promisify as promisify2 } from "util";
|
|
7024
6943
|
var execFile2 = promisify2(execFileCb2);
|
|
7025
6944
|
var DEFAULT_TIMEOUT_MS2 = 10 * 60 * 1e3;
|
|
@@ -7046,7 +6965,7 @@ function mimeForExt(ext) {
|
|
|
7046
6965
|
}
|
|
7047
6966
|
function extForAssetRef(ref) {
|
|
7048
6967
|
if (ref.path) {
|
|
7049
|
-
const e =
|
|
6968
|
+
const e = path7.extname(ref.path);
|
|
7050
6969
|
if (e) return e;
|
|
7051
6970
|
}
|
|
7052
6971
|
const reverse = {
|
|
@@ -7068,14 +6987,14 @@ function planArrayInputSlot(tmpDir, slot, values, lookup, stagedInputs) {
|
|
|
7068
6987
|
const ref = values[i];
|
|
7069
6988
|
if (!ref) continue;
|
|
7070
6989
|
if (!ref.path) throw new Error(`cli-runner: inputs.${slot}[${i}] has no local path`);
|
|
7071
|
-
const dest =
|
|
6990
|
+
const dest = path7.join(tmpDir, `in_${slot}_${i}${extForAssetRef(ref)}`);
|
|
7072
6991
|
stagedInputs.push({ srcPath: ref.path, destPath: dest });
|
|
7073
6992
|
lookup.set(`in.${slot}.${i}`, dest);
|
|
7074
6993
|
}
|
|
7075
6994
|
}
|
|
7076
6995
|
function planSingleInputSlot(tmpDir, slot, ref, lookup, stagedInputs) {
|
|
7077
6996
|
if (!ref.path) throw new Error(`cli-runner: inputs.${slot} has no local path`);
|
|
7078
|
-
const dest =
|
|
6997
|
+
const dest = path7.join(tmpDir, `in_${slot}${extForAssetRef(ref)}`);
|
|
7079
6998
|
stagedInputs.push({ srcPath: ref.path, destPath: dest });
|
|
7080
6999
|
lookup.set(`in.${slot}`, dest);
|
|
7081
7000
|
}
|
|
@@ -7083,7 +7002,7 @@ function planOutputs(tmpDir, outputs, lookup) {
|
|
|
7083
7002
|
const outputPaths = [];
|
|
7084
7003
|
for (const [name, spec] of Object.entries(outputs)) {
|
|
7085
7004
|
const ext = spec.ext.startsWith(".") ? spec.ext : `.${spec.ext}`;
|
|
7086
|
-
const absPath =
|
|
7005
|
+
const absPath = path7.join(tmpDir, `out_${name}${ext}`);
|
|
7087
7006
|
outputPaths.push({ name, absPath, spec });
|
|
7088
7007
|
lookup.set(`out.${name}`, absPath);
|
|
7089
7008
|
}
|
|
@@ -7124,8 +7043,8 @@ function rejectRawPaths(substituted, original, stagingDir) {
|
|
|
7124
7043
|
throw new Error(`cli-runner: home-relative path "${original}" not allowed in args.`);
|
|
7125
7044
|
}
|
|
7126
7045
|
if (substituted.startsWith("/")) {
|
|
7127
|
-
const resolved =
|
|
7128
|
-
if (!resolved.startsWith(`${stagingDir}${
|
|
7046
|
+
const resolved = path7.resolve(substituted);
|
|
7047
|
+
if (!resolved.startsWith(`${stagingDir}${path7.sep}`) && resolved !== stagingDir) {
|
|
7129
7048
|
throw new Error(
|
|
7130
7049
|
`cli-runner: raw filesystem path "${original}" not allowed \u2014 declare an input slot and use {{in.<slot>}} instead.`
|
|
7131
7050
|
);
|
|
@@ -7175,7 +7094,7 @@ function tailLines(text, maxLines) {
|
|
|
7175
7094
|
}
|
|
7176
7095
|
async function runCli(opts) {
|
|
7177
7096
|
const { bin, args, inputs, outputs, ctx, timeoutMs = DEFAULT_TIMEOUT_MS2 } = opts;
|
|
7178
|
-
const tmpDir = await mkdtemp2(
|
|
7097
|
+
const tmpDir = await mkdtemp2(path7.join(tmpdir2(), `cli-${bin.replace(/[^a-z0-9]/gi, "")}-`));
|
|
7179
7098
|
try {
|
|
7180
7099
|
const { lookup, stagedInputs, outputPaths } = planPlaceholders(tmpDir, inputs, outputs);
|
|
7181
7100
|
await stageInputs(stagedInputs);
|
|
@@ -7197,7 +7116,7 @@ ${tailLines(stderr, 40)}`);
|
|
|
7197
7116
|
if (!s?.isFile() || s.size === 0) {
|
|
7198
7117
|
throw new Error(`cli-runner: declared output "${name}" missing or empty at ${absPath}`);
|
|
7199
7118
|
}
|
|
7200
|
-
const bytes = await
|
|
7119
|
+
const bytes = await readFile5(absPath);
|
|
7201
7120
|
const ref = await ctx.assets.ingestBytes({
|
|
7202
7121
|
bytes: Buffer.from(bytes),
|
|
7203
7122
|
kind: spec.kind,
|
|
@@ -7467,17 +7386,17 @@ var ffmpegNode = defineNode({
|
|
|
7467
7386
|
import { mkdtemp as mkdtemp3, rm as rm3, writeFile as writeFile4 } from "fs/promises";
|
|
7468
7387
|
import { createRequire } from "module";
|
|
7469
7388
|
import { tmpdir as tmpdir3 } from "os";
|
|
7470
|
-
import
|
|
7389
|
+
import path9 from "path";
|
|
7471
7390
|
import { z as z9 } from "zod";
|
|
7472
7391
|
|
|
7473
7392
|
// src/engine/nodes/local/lib/assets.ts
|
|
7474
|
-
import { copyFile as copyFile3, readFile as
|
|
7475
|
-
import
|
|
7393
|
+
import { copyFile as copyFile3, readFile as readFile6 } from "fs/promises";
|
|
7394
|
+
import path8 from "path";
|
|
7476
7395
|
async function stageAsset(ref, destDir, filename) {
|
|
7477
7396
|
if (!ref.path) {
|
|
7478
7397
|
throw new Error(`stageAsset: ref (${ref.kind}/${ref.mime}) has no local path`);
|
|
7479
7398
|
}
|
|
7480
|
-
const dest =
|
|
7399
|
+
const dest = path8.join(destDir, filename);
|
|
7481
7400
|
await copyFile3(ref.path, dest);
|
|
7482
7401
|
return dest;
|
|
7483
7402
|
}
|
|
@@ -7486,7 +7405,7 @@ async function refToUrl(ref) {
|
|
|
7486
7405
|
if (!ref.path) {
|
|
7487
7406
|
throw new Error("refToUrl: AssetRef has neither url nor path");
|
|
7488
7407
|
}
|
|
7489
|
-
const bytes = await
|
|
7408
|
+
const bytes = await readFile6(ref.path);
|
|
7490
7409
|
return `data:${ref.mime};base64,${bytes.toString("base64")}`;
|
|
7491
7410
|
}
|
|
7492
7411
|
var ASSET_KINDS = /* @__PURE__ */ new Set(["image", "video", "audio", "json", "text", "font"]);
|
|
@@ -7560,11 +7479,11 @@ var fontSpecimenNode = defineNode({
|
|
|
7560
7479
|
outputKinds: { image: "image" },
|
|
7561
7480
|
cost: () => ({ credits: 0, seconds_estimate: 5 }),
|
|
7562
7481
|
async execute({ inputs, params, ctx }) {
|
|
7563
|
-
const tmp = await mkdtemp3(
|
|
7482
|
+
const tmp = await mkdtemp3(path9.join(tmpdir3(), "font-specimen-"));
|
|
7564
7483
|
try {
|
|
7565
7484
|
const fontFilename = `font.${extForMime(inputs.font.mime)}`;
|
|
7566
7485
|
await stageAsset(inputs.font, tmp, fontFilename);
|
|
7567
|
-
const entryPath =
|
|
7486
|
+
const entryPath = path9.join(tmp, "index.html");
|
|
7568
7487
|
await writeFile4(entryPath, buildSpecimenHtml(params, fontFilename), "utf-8");
|
|
7569
7488
|
ctx.log(`rendering specimen (${params.font_size}px, ${params.text.split("\n").length} lines)`);
|
|
7570
7489
|
const pwSpecifier = ["play", "wright"].join("");
|
|
@@ -7648,16 +7567,16 @@ var fontSpecimenNode = defineNode({
|
|
|
7648
7567
|
|
|
7649
7568
|
// src/engine/nodes/local/hyperframe.ts
|
|
7650
7569
|
import { execFile as execFile4 } from "child_process";
|
|
7651
|
-
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";
|
|
7652
7571
|
import { createRequire as createRequire2 } from "module";
|
|
7653
7572
|
import { cpus, tmpdir as tmpdir4 } from "os";
|
|
7654
|
-
import
|
|
7573
|
+
import path14 from "path";
|
|
7655
7574
|
import { promisify as promisify4 } from "util";
|
|
7656
7575
|
import { z as z11 } from "zod";
|
|
7657
7576
|
|
|
7658
7577
|
// src/engine/engine/composition-hash.ts
|
|
7659
|
-
import { readdir as readdir2, readFile as
|
|
7660
|
-
import
|
|
7578
|
+
import { readdir as readdir2, readFile as readFile7, stat as stat4 } from "fs/promises";
|
|
7579
|
+
import path10 from "path";
|
|
7661
7580
|
var SKIP_DIRS = /* @__PURE__ */ new Set([".cache", ".git", "node_modules", "dist", "build", ".next", ".turbo"]);
|
|
7662
7581
|
function isSkippedName(name) {
|
|
7663
7582
|
if (name.startsWith(".")) return true;
|
|
@@ -7674,23 +7593,23 @@ async function collectFiles(root, current) {
|
|
|
7674
7593
|
const names = await readdir2(current);
|
|
7675
7594
|
for (const name of names) {
|
|
7676
7595
|
if (isSkippedName(name)) continue;
|
|
7677
|
-
const abs =
|
|
7596
|
+
const abs = path10.join(current, name);
|
|
7678
7597
|
const s = await stat4(abs);
|
|
7679
7598
|
if (s.isDirectory()) {
|
|
7680
7599
|
out.push(...await collectFiles(root, abs));
|
|
7681
7600
|
continue;
|
|
7682
7601
|
}
|
|
7683
7602
|
if (!s.isFile()) continue;
|
|
7684
|
-
const bytes = await
|
|
7685
|
-
const relPath =
|
|
7603
|
+
const bytes = await readFile7(abs);
|
|
7604
|
+
const relPath = path10.relative(root, abs).split(path10.sep).join("/");
|
|
7686
7605
|
out.push({ relPath, contentSha: sha256Hex(bytes) });
|
|
7687
7606
|
}
|
|
7688
7607
|
return out;
|
|
7689
7608
|
}
|
|
7690
7609
|
|
|
7691
7610
|
// src/engine/engine/composition-meta.ts
|
|
7692
|
-
import { readFile as
|
|
7693
|
-
import
|
|
7611
|
+
import { readFile as readFile8 } from "fs/promises";
|
|
7612
|
+
import path11 from "path";
|
|
7694
7613
|
import { z as z10 } from "zod";
|
|
7695
7614
|
var InputKind = z10.enum(["video", "image", "audio", "json"]);
|
|
7696
7615
|
var InputSpec = z10.object({
|
|
@@ -7767,10 +7686,10 @@ var CompositionMetaSchema = z10.object({
|
|
|
7767
7686
|
params: z10.record(z10.string(), ParamSpec).default({})
|
|
7768
7687
|
}).strict();
|
|
7769
7688
|
async function loadCompositionMeta(compositionDir) {
|
|
7770
|
-
const metaPath =
|
|
7689
|
+
const metaPath = path11.join(compositionDir, "meta.json");
|
|
7771
7690
|
let raw;
|
|
7772
7691
|
try {
|
|
7773
|
-
raw = await
|
|
7692
|
+
raw = await readFile8(metaPath, "utf-8");
|
|
7774
7693
|
} catch (e) {
|
|
7775
7694
|
throw new Error(`composition meta: cannot read ${metaPath} (${e.message})`);
|
|
7776
7695
|
}
|
|
@@ -7848,8 +7767,8 @@ function defaultFilenameForInput(key, kind) {
|
|
|
7848
7767
|
|
|
7849
7768
|
// src/engine/nodes/local/lib/hyperframe-check.ts
|
|
7850
7769
|
import { execFile as execFile3 } from "child_process";
|
|
7851
|
-
import { readFile as
|
|
7852
|
-
import
|
|
7770
|
+
import { readFile as readFile9 } from "fs/promises";
|
|
7771
|
+
import path12 from "path";
|
|
7853
7772
|
import { promisify as promisify3 } from "util";
|
|
7854
7773
|
|
|
7855
7774
|
// src/engine/nodes/local/lib/caption-style.ts
|
|
@@ -8073,7 +7992,7 @@ async function runSnapshotSmoke(args, timeoutMs) {
|
|
|
8073
7992
|
}
|
|
8074
7993
|
async function runNestedCompositionSmoke(opts) {
|
|
8075
7994
|
const { dir, nodeId, ctx, timeoutMs, samples } = opts;
|
|
8076
|
-
const indexHtml = await
|
|
7995
|
+
const indexHtml = await readFile9(path12.join(dir, "index.html"), "utf-8").catch(() => "");
|
|
8077
7996
|
if (!indexHtml || !usesNestedCompositions(indexHtml)) return;
|
|
8078
7997
|
const snap = await runSnapshotSmoke(
|
|
8079
7998
|
buildSnapshotArgs(dir, Math.min(samples, 3), hasFrameVisionKey()),
|
|
@@ -8089,7 +8008,7 @@ async function runNestedCompositionSmoke(opts) {
|
|
|
8089
8008
|
${snap.message}`
|
|
8090
8009
|
);
|
|
8091
8010
|
}
|
|
8092
|
-
const described = await
|
|
8011
|
+
const described = await readFile9(path12.join(dir, "snapshots", "descriptions.md"), "utf-8").catch(() => "");
|
|
8093
8012
|
for (const line of condenseFrameDescriptions(described)) {
|
|
8094
8013
|
ctx.log(`${nodeId}: frame check \u2014 ${line}`);
|
|
8095
8014
|
}
|
|
@@ -8125,7 +8044,7 @@ async function runHyperframesCheck(opts) {
|
|
|
8125
8044
|
${detail}`
|
|
8126
8045
|
);
|
|
8127
8046
|
}
|
|
8128
|
-
const composition = await
|
|
8047
|
+
const composition = await readFile9(path12.join(dir, "index.html"), "utf-8").catch(() => "");
|
|
8129
8048
|
const captionComplaint = fragmentedCaptions(captionTextsFrom(composition));
|
|
8130
8049
|
if (captionComplaint) {
|
|
8131
8050
|
ctx.log(`${nodeId}: caption style \u2014 ${captionComplaint}`);
|
|
@@ -8179,9 +8098,9 @@ ${stderr.slice(0, 1500)}`;
|
|
|
8179
8098
|
|
|
8180
8099
|
// src/engine/nodes/local/lib/hyperframe-meta.ts
|
|
8181
8100
|
import { writeFile as writeFile5 } from "fs/promises";
|
|
8182
|
-
import
|
|
8101
|
+
import path13 from "path";
|
|
8183
8102
|
async function ensureHyperframesMetaJson(tmp, nodeId, meta, duration) {
|
|
8184
|
-
const metaPath =
|
|
8103
|
+
const metaPath = path13.join(tmp, "meta.json");
|
|
8185
8104
|
await writeFile5(
|
|
8186
8105
|
metaPath,
|
|
8187
8106
|
JSON.stringify(
|
|
@@ -8281,7 +8200,7 @@ var hyperframeRenderNode = defineNode({
|
|
|
8281
8200
|
const compositionDir = await resolveCompositionDir(params.composition);
|
|
8282
8201
|
const meta = await loadCompositionMeta(compositionDir);
|
|
8283
8202
|
const compositionParams = validateAndParseDynamicParams(meta, params);
|
|
8284
|
-
const tmp = await mkdtemp4(
|
|
8203
|
+
const tmp = await mkdtemp4(path14.join(tmpdir4(), "hf-render-"));
|
|
8285
8204
|
try {
|
|
8286
8205
|
await copyComposition(compositionDir, tmp);
|
|
8287
8206
|
await vendorGsap(tmp, ctx);
|
|
@@ -8291,9 +8210,9 @@ var hyperframeRenderNode = defineNode({
|
|
|
8291
8210
|
await substituteCompositionFiles(tmp, substitutionValues);
|
|
8292
8211
|
await ensureHyperframesMetaJson(tmp, ctx.nodeId, meta, duration);
|
|
8293
8212
|
await runHyperframesCheck({ dir: tmp, nodeId: "hyperframe_render", ctx, timeoutMs: params.timeout_ms });
|
|
8294
|
-
const outputPath =
|
|
8213
|
+
const outputPath = path14.join(tmp, `output.${params.format}`);
|
|
8295
8214
|
await runRender({ tmp, outputPath, params, meta, ctx });
|
|
8296
|
-
const bytes = await
|
|
8215
|
+
const bytes = await readFile10(outputPath);
|
|
8297
8216
|
ctx.log(`rendered ${bytes.length} bytes`);
|
|
8298
8217
|
const ref = await ctx.assets.ingestBytes({
|
|
8299
8218
|
bytes: Buffer.from(bytes),
|
|
@@ -8315,10 +8234,10 @@ var hyperframeRenderNode = defineNode({
|
|
|
8315
8234
|
}
|
|
8316
8235
|
});
|
|
8317
8236
|
async function resolveCompositionDir(composition) {
|
|
8318
|
-
const compositionPath =
|
|
8237
|
+
const compositionPath = path14.isAbsolute(composition) ? composition : path14.resolve(process.cwd(), composition);
|
|
8319
8238
|
const s = await stat5(compositionPath);
|
|
8320
8239
|
if (s.isDirectory()) return compositionPath;
|
|
8321
|
-
return
|
|
8240
|
+
return path14.dirname(compositionPath);
|
|
8322
8241
|
}
|
|
8323
8242
|
async function validateComposition(rawParams) {
|
|
8324
8243
|
const issues = await validateCompositionParams(rawParams);
|
|
@@ -8400,7 +8319,7 @@ async function copyComposition(srcDir, destDir) {
|
|
|
8400
8319
|
await cp(srcDir, destDir, {
|
|
8401
8320
|
recursive: true,
|
|
8402
8321
|
filter: (src) => {
|
|
8403
|
-
const name =
|
|
8322
|
+
const name = path14.basename(src);
|
|
8404
8323
|
if (name === ".cache" || name === "node_modules" || name === ".git") return false;
|
|
8405
8324
|
return true;
|
|
8406
8325
|
}
|
|
@@ -8409,7 +8328,7 @@ async function copyComposition(srcDir, destDir) {
|
|
|
8409
8328
|
async function vendorGsap(tmp, ctx) {
|
|
8410
8329
|
try {
|
|
8411
8330
|
const gsapMin = require_2.resolve("gsap/dist/gsap.min.js");
|
|
8412
|
-
await copyFile4(gsapMin,
|
|
8331
|
+
await copyFile4(gsapMin, path14.join(tmp, "gsap.min.js"));
|
|
8413
8332
|
} catch (e) {
|
|
8414
8333
|
ctx.log(`warning: could not vendor gsap.min.js (${e.message}); compositions must self-supply`);
|
|
8415
8334
|
}
|
|
@@ -8424,7 +8343,7 @@ async function stageInputs2(tmp, inputs, meta, ctx) {
|
|
|
8424
8343
|
await stageAsset(ref, tmp, filename);
|
|
8425
8344
|
ctx.log(`staged ${spec.kind} \u2192 ${filename}`);
|
|
8426
8345
|
if (spec.kind === "video" && primaryDuration === null) {
|
|
8427
|
-
primaryDuration = await probeDurationSeconds(
|
|
8346
|
+
primaryDuration = await probeDurationSeconds(path14.join(tmp, filename));
|
|
8428
8347
|
}
|
|
8429
8348
|
}
|
|
8430
8349
|
return primaryDuration;
|
|
@@ -8470,8 +8389,8 @@ function coerceImageParam(value) {
|
|
|
8470
8389
|
throw new Error("hyperframe_render: image param must be a URL string or AssetRef");
|
|
8471
8390
|
}
|
|
8472
8391
|
async function substituteCompositionFiles(tmp, values) {
|
|
8473
|
-
const entryPath =
|
|
8474
|
-
const original = await
|
|
8392
|
+
const entryPath = path14.join(tmp, "index.html");
|
|
8393
|
+
const original = await readFile10(entryPath, "utf-8");
|
|
8475
8394
|
const { output, missing } = substituteVariables(original, values);
|
|
8476
8395
|
if (missing.length > 0) {
|
|
8477
8396
|
throw new Error(
|
|
@@ -8487,7 +8406,7 @@ function workerCount() {
|
|
|
8487
8406
|
async function runRender(opts) {
|
|
8488
8407
|
const { tmp, outputPath, params, meta, ctx } = opts;
|
|
8489
8408
|
const args = buildRenderArgs(tmp, outputPath, meta, params.format);
|
|
8490
|
-
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)}`);
|
|
8491
8410
|
try {
|
|
8492
8411
|
await execFileAsync2("npx", args, { timeout: params.timeout_ms, maxBuffer: 64 * 1024 * 1024 });
|
|
8493
8412
|
} catch (e) {
|
|
@@ -8531,10 +8450,10 @@ async function probeDurationSeconds(filePath) {
|
|
|
8531
8450
|
|
|
8532
8451
|
// src/engine/nodes/local/hyperframe-snapshot.ts
|
|
8533
8452
|
import { execFile as execFile5 } from "child_process";
|
|
8534
|
-
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";
|
|
8535
8454
|
import { createRequire as createRequire3 } from "module";
|
|
8536
8455
|
import { tmpdir as tmpdir5 } from "os";
|
|
8537
|
-
import
|
|
8456
|
+
import path15 from "path";
|
|
8538
8457
|
import { promisify as promisify5 } from "util";
|
|
8539
8458
|
import { z as z12 } from "zod";
|
|
8540
8459
|
var _execFileAsync = promisify5(execFile5);
|
|
@@ -8581,7 +8500,7 @@ var hyperframeSnapshotNode = defineNode({
|
|
|
8581
8500
|
const compositionDir = await resolveCompositionDir(params.composition);
|
|
8582
8501
|
const meta = await loadCompositionMeta(compositionDir);
|
|
8583
8502
|
const compositionParams = validateAndParseDynamicParams2(meta, params);
|
|
8584
|
-
const tmp = await mkdtemp5(
|
|
8503
|
+
const tmp = await mkdtemp5(path15.join(tmpdir5(), "hf-snap-"));
|
|
8585
8504
|
try {
|
|
8586
8505
|
await copyComposition2(compositionDir, tmp);
|
|
8587
8506
|
await vendorGsap2(tmp, ctx);
|
|
@@ -8596,7 +8515,7 @@ var hyperframeSnapshotNode = defineNode({
|
|
|
8596
8515
|
timeoutMs: params.timeout_ms,
|
|
8597
8516
|
samples: 1
|
|
8598
8517
|
});
|
|
8599
|
-
const entryPath =
|
|
8518
|
+
const entryPath = path15.join(tmp, "index.html");
|
|
8600
8519
|
const entryUrl = `file://${entryPath}`;
|
|
8601
8520
|
ctx.log(`snapshotting ${meta.width}x${meta.height}@${DEVICE_SCALE_FACTOR2}x wait=${params.wait_for.kind}`);
|
|
8602
8521
|
const pwSpecifier = ["play", "wright"].join("");
|
|
@@ -8657,7 +8576,7 @@ async function copyComposition2(srcDir, destDir) {
|
|
|
8657
8576
|
await cp(srcDir, destDir, {
|
|
8658
8577
|
recursive: true,
|
|
8659
8578
|
filter: (src) => {
|
|
8660
|
-
const name =
|
|
8579
|
+
const name = path15.basename(src);
|
|
8661
8580
|
if (name === ".cache" || name === "node_modules" || name === ".git") return false;
|
|
8662
8581
|
return true;
|
|
8663
8582
|
}
|
|
@@ -8666,7 +8585,7 @@ async function copyComposition2(srcDir, destDir) {
|
|
|
8666
8585
|
async function vendorGsap2(tmp, ctx) {
|
|
8667
8586
|
try {
|
|
8668
8587
|
const gsapMin = require_3.resolve("gsap/dist/gsap.min.js");
|
|
8669
|
-
await copyFile5(gsapMin,
|
|
8588
|
+
await copyFile5(gsapMin, path15.join(tmp, "gsap.min.js"));
|
|
8670
8589
|
} catch (e) {
|
|
8671
8590
|
ctx.log(`warning: could not vendor gsap.min.js (${e.message}); compositions must self-supply`);
|
|
8672
8591
|
}
|
|
@@ -8700,8 +8619,8 @@ function coerceImageParam2(value) {
|
|
|
8700
8619
|
throw new Error("hyperframe_snapshot: image param must be a URL string or AssetRef");
|
|
8701
8620
|
}
|
|
8702
8621
|
async function substituteCompositionFiles2(tmp, values) {
|
|
8703
|
-
const entryPath =
|
|
8704
|
-
const original = await
|
|
8622
|
+
const entryPath = path15.join(tmp, "index.html");
|
|
8623
|
+
const original = await readFile11(entryPath, "utf-8");
|
|
8705
8624
|
const { output, missing } = substituteVariables(original, values);
|
|
8706
8625
|
if (missing.length > 0) {
|
|
8707
8626
|
throw new Error(
|
|
@@ -9468,9 +9387,9 @@ var videoLipsyncNode = delegated({
|
|
|
9468
9387
|
});
|
|
9469
9388
|
|
|
9470
9389
|
// src/engine/nodes/remote/videoTranscribe.ts
|
|
9471
|
-
import { mkdtemp as mkdtemp6, readFile as
|
|
9390
|
+
import { mkdtemp as mkdtemp6, readFile as readFile12, rm as rm6 } from "fs/promises";
|
|
9472
9391
|
import { tmpdir as tmpdir6 } from "os";
|
|
9473
|
-
import
|
|
9392
|
+
import path16 from "path";
|
|
9474
9393
|
import { z as z33 } from "zod";
|
|
9475
9394
|
|
|
9476
9395
|
// src/engine/nodes/local/lib/ffmpeg.ts
|
|
@@ -9608,14 +9527,14 @@ async function tryExtractAudio(inputs, ctx) {
|
|
|
9608
9527
|
ctx.log("video_transcribe: no audio track detected, sending full video");
|
|
9609
9528
|
return null;
|
|
9610
9529
|
}
|
|
9611
|
-
tmpDir = await mkdtemp6(
|
|
9612
|
-
const audioPath =
|
|
9530
|
+
tmpDir = await mkdtemp6(path16.join(tmpdir6(), "vtx-"));
|
|
9531
|
+
const audioPath = path16.join(tmpDir, "audio.mp3");
|
|
9613
9532
|
ctx.log("video_transcribe: extracting audio (mono 16kHz mp3)");
|
|
9614
9533
|
await runFfmpeg(
|
|
9615
9534
|
["-i", video.path, "-vn", "-ac", "1", "-ar", "16000", "-b:a", "64k", "-f", "mp3", "-y", audioPath],
|
|
9616
9535
|
{ timeout_ms: AUDIO_EXTRACT_TIMEOUT_MS }
|
|
9617
9536
|
);
|
|
9618
|
-
const bytes = await
|
|
9537
|
+
const bytes = await readFile12(audioPath);
|
|
9619
9538
|
if (bytes.byteLength === 0) {
|
|
9620
9539
|
ctx.log("video_transcribe: extracted audio is empty, sending full video");
|
|
9621
9540
|
return null;
|
|
@@ -9810,19 +9729,19 @@ function safeCost(def) {
|
|
|
9810
9729
|
|
|
9811
9730
|
// src/engine/storage/cache-store.ts
|
|
9812
9731
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
9813
|
-
import { mkdir as mkdir3, readFile as
|
|
9814
|
-
import
|
|
9732
|
+
import { mkdir as mkdir3, readFile as readFile13, rename as rename2, writeFile as writeFile8 } from "fs/promises";
|
|
9733
|
+
import path17 from "path";
|
|
9815
9734
|
var LocalCacheStore = class {
|
|
9816
9735
|
rootDir;
|
|
9817
9736
|
constructor(rootDir) {
|
|
9818
9737
|
this.rootDir = rootDir;
|
|
9819
9738
|
}
|
|
9820
9739
|
filePath(cacheKey) {
|
|
9821
|
-
return
|
|
9740
|
+
return path17.join(this.rootDir, `${cacheKey}.json`);
|
|
9822
9741
|
}
|
|
9823
9742
|
async get(cacheKey) {
|
|
9824
9743
|
try {
|
|
9825
|
-
const buf = await
|
|
9744
|
+
const buf = await readFile13(this.filePath(cacheKey), "utf8");
|
|
9826
9745
|
return JSON.parse(buf);
|
|
9827
9746
|
} catch (e) {
|
|
9828
9747
|
if (e.code === "ENOENT") return null;
|
|
@@ -9831,7 +9750,7 @@ var LocalCacheStore = class {
|
|
|
9831
9750
|
}
|
|
9832
9751
|
async put(entry) {
|
|
9833
9752
|
const dest = this.filePath(entry.cacheKey);
|
|
9834
|
-
await mkdir3(
|
|
9753
|
+
await mkdir3(path17.dirname(dest), { recursive: true });
|
|
9835
9754
|
const tmp = `${dest}.tmp-${process.pid}-${randomUUID2()}`;
|
|
9836
9755
|
await writeFile8(tmp, JSON.stringify(entry, null, 0));
|
|
9837
9756
|
await rename2(tmp, dest);
|
|
@@ -9887,12 +9806,12 @@ function defaultRegistry() {
|
|
|
9887
9806
|
}
|
|
9888
9807
|
function createEngineFromEnv(opts = {}) {
|
|
9889
9808
|
const cwd = opts.cwd ?? process.cwd();
|
|
9890
|
-
const cacheDir = opts.cacheDir ??
|
|
9891
|
-
const outputsDir = opts.outputsDir ??
|
|
9809
|
+
const cacheDir = opts.cacheDir ?? path18.join(cwd, "canvas", ".cache");
|
|
9810
|
+
const outputsDir = opts.outputsDir ?? path18.join(cwd, "canvas");
|
|
9892
9811
|
const connection = requireConnection();
|
|
9893
9812
|
const client = new BackendClient({ baseUrl: connection.BAKER_API_URL, apiKey: connection.BAKER_API_KEY });
|
|
9894
|
-
const assets = new LocalAssetStore(
|
|
9895
|
-
const localCache = new LocalCacheStore(
|
|
9813
|
+
const assets = new LocalAssetStore(path18.join(cacheDir, "assets"));
|
|
9814
|
+
const localCache = new LocalCacheStore(path18.join(cacheDir, "index"));
|
|
9896
9815
|
const remoteCacheEnabled = opts.remoteCache ?? remoteCacheEnabledFromEnv();
|
|
9897
9816
|
const cache = remoteCacheEnabled ? new LayeredCacheStore({
|
|
9898
9817
|
local: localCache,
|
|
@@ -9917,7 +9836,6 @@ export {
|
|
|
9917
9836
|
RunAbortedError,
|
|
9918
9837
|
LayerExecutionError,
|
|
9919
9838
|
describeFailureReason,
|
|
9920
|
-
runFailureCode,
|
|
9921
9839
|
AD_FORMAT_PLATFORMS,
|
|
9922
9840
|
platformFormats,
|
|
9923
9841
|
withoutCastName,
|
|
@@ -9986,4 +9904,4 @@ export {
|
|
|
9986
9904
|
defaultRegistry,
|
|
9987
9905
|
createEngineFromEnv
|
|
9988
9906
|
};
|
|
9989
|
-
//# sourceMappingURL=chunk-
|
|
9907
|
+
//# sourceMappingURL=chunk-RK44ZR7L.js.map
|