@morshoto/framekit 0.1.17 → 0.2.2
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 +25 -14
- package/dist-package/adapters/final-cut/typescript/src/background-materialization.js +8 -2
- package/dist-package/adapters/final-cut/typescript/src/canonical-recovery-guard.js +275 -0
- package/dist-package/adapters/final-cut/typescript/src/canonical.js +557 -84
- package/dist-package/adapters/final-cut/typescript/src/connection.js +10 -3
- package/dist-package/adapters/final-cut/typescript/src/disposable-native.js +6 -0
- package/dist-package/adapters/final-cut/typescript/src/experimental.js +8 -0
- package/dist-package/adapters/final-cut/typescript/src/fcpxml.js +150 -37
- package/dist-package/adapters/final-cut/typescript/src/index.js +2 -7
- package/dist-package/adapters/final-cut/typescript/src/library-inspection.js +60 -1
- package/dist-package/adapters/final-cut/typescript/src/live.js +29 -4
- package/dist-package/adapters/final-cut/typescript/src/native-recovery-inspection.js +175 -0
- package/dist-package/adapters/final-cut/typescript/src/native-session.js +11 -6
- package/dist-package/adapters/final-cut/typescript/src/native.js +201 -82
- package/dist-package/adapters/final-cut/typescript/src/publish-readback.js +214 -0
- package/dist-package/adapters/final-cut/typescript/src/publisher.js +1008 -243
- package/dist-package/adapters/final-cut/typescript/src/session.js +49 -14
- package/dist-package/adapters/final-cut/typescript/src/timeline-ir-fcpxml.js +203 -49
- package/dist-package/adapters/headless/typescript/src/audio-output.js +3 -0
- package/dist-package/adapters/headless/typescript/src/ffmpeg-renderer.js +48 -20
- package/dist-package/adapters/headless/typescript/src/ffmpeg-verifier.js +9 -4
- package/dist-package/apps/cli/src/dev-doctor.js +198 -0
- package/dist-package/apps/cli/src/headless-projects.js +5 -0
- package/dist-package/apps/cli/src/main.js +76 -19
- package/dist-package/apps/mcp-server/runtime/speech-analyzer-wrapper.mjs +54 -0
- package/dist-package/apps/mcp-server/runtime/whisper-speech-backend.py +181 -0
- package/dist-package/apps/mcp-server/src/build-alignment.js +59 -0
- package/dist-package/apps/mcp-server/src/build-identity.js +30 -0
- package/dist-package/apps/mcp-server/src/build-identity.json +5 -0
- package/dist-package/apps/mcp-server/src/canonical-native-snapshot.js +18 -0
- package/dist-package/apps/mcp-server/src/final-cut-runtime-config.js +3 -0
- package/dist-package/apps/mcp-server/src/headless-project-snapshot.js +101 -0
- package/dist-package/apps/mcp-server/src/main.js +50 -21
- package/dist-package/apps/mcp-server/src/materialization-jobs.js +143 -10
- package/dist-package/apps/mcp-server/src/routing.js +2 -0
- package/dist-package/apps/mcp-server/src/server.js +986 -180
- package/dist-package/apps/mcp-server/src/tools/skills/catalog.js +142 -0
- package/dist-package/apps/mcp-server/src/tools/skills/metadata.js +71 -0
- package/dist-package/apps/mcp-server/src/tools/skills/register.js +101 -0
- package/dist-package/apps/mcp-server/src/version.js +21 -2
- package/dist-package/packages/headless-application/src/headless-projects.js +942 -0
- package/dist-package/packages/headless-application/src/index.js +1 -0
- package/dist-package/packages/runtime/src/application/media-analysis-service.js +15 -5
- package/dist-package/packages/runtime/src/application/project-service.js +5 -1
- package/dist-package/packages/runtime/src/application/project-store.js +13 -36
- package/dist-package/packages/runtime/src/application/transaction-store.js +1 -1
- package/dist-package/packages/runtime/src/capabilities.js +1 -1
- package/dist-package/packages/runtime/src/context/context-engine.js +22 -16
- package/dist-package/packages/runtime/src/context/context-service.js +2 -2
- package/dist-package/packages/runtime/src/editing/edit-service.js +76 -10
- package/dist-package/packages/runtime/src/index.js +1 -0
- package/dist-package/packages/runtime/src/runtime.js +22 -7
- package/dist-package/packages/runtime/src/timeline/editing-session.js +23 -2
- package/dist-package/packages/testkit/src/in-memory-editor.js +3 -3
- package/dist-package/packages/testkit/src/index.js +1 -0
- package/dist-package/packages/testkit/src/sender-lifecycle-fixture.js +192 -0
- package/package.json +36 -14
- package/dist-package/apps/mcp-server/src/headless-projects.js +0 -370
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Experimental subprocess fixture. This is not a production coordinator,
|
|
3
|
+
* authenticated journal, native receiver, or reservation recovery mechanism.
|
|
4
|
+
* Callers must supply a disposable, isolated directory and synthetic identity.
|
|
5
|
+
*/
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import { constants } from "node:fs";
|
|
9
|
+
import { open } from "node:fs/promises";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
12
|
+
const hash = /^[a-f0-9]{64}$/;
|
|
13
|
+
const unknown = () => ({ status: "unknown", evidenceTrust: "unverified-fixture-marker", nativeQuiescence: "unproven", recoveryEligibility: "unavailable" });
|
|
14
|
+
function valid(b) {
|
|
15
|
+
try {
|
|
16
|
+
if (!b || typeof b.reservationBytes !== "string" || Buffer.byteLength(b.reservationBytes) > 16384
|
|
17
|
+
|| !hash.test(b.reservationId) || createHash("sha256").update(b.reservationBytes).digest("hex") !== b.reservationId
|
|
18
|
+
|| (b.reservationVersion !== 3 && b.reservationVersion !== 4)
|
|
19
|
+
|| (b.route !== "publish" && b.route !== "materialization") || !uuid.test(b.owner) || !uuid.test(b.executionId))
|
|
20
|
+
return false;
|
|
21
|
+
const intent = JSON.parse(b.reservationBytes);
|
|
22
|
+
return !!intent && intent.version === b.reservationVersion && intent.kind === "native-operation" && intent.senderTracked === true
|
|
23
|
+
&& typeof intent.owner === "string" && uuid.test(intent.owner) && intent.owner === b.owner && intent.operation === `fixture.${b.route}`;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function pathFor(directory, b, kind) {
|
|
30
|
+
return join(directory, `${b.reservationId}.sender-${kind}`);
|
|
31
|
+
}
|
|
32
|
+
function record(b, phase) {
|
|
33
|
+
return { schemaVersion: 1, reservationId: b.reservationId, reservationVersion: b.reservationVersion, route: b.route, owner: b.owner, executionId: b.executionId, phase };
|
|
34
|
+
}
|
|
35
|
+
async function readRecord(path) {
|
|
36
|
+
let handle;
|
|
37
|
+
try {
|
|
38
|
+
handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
39
|
+
const stat = await handle.stat();
|
|
40
|
+
if (!stat.isFile() || stat.size > 4096)
|
|
41
|
+
throw new Error("invalid fixture marker");
|
|
42
|
+
const raw = await handle.readFile("utf8");
|
|
43
|
+
return { raw, value: JSON.parse(raw) };
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (error.code === "ENOENT")
|
|
47
|
+
return undefined;
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
await handle?.close();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function matches(snapshot, b, phase) {
|
|
55
|
+
const value = snapshot?.value;
|
|
56
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
57
|
+
return false;
|
|
58
|
+
const obj = value;
|
|
59
|
+
const keys = ["schemaVersion", "reservationId", "reservationVersion", "route", "owner", "executionId", "phase"];
|
|
60
|
+
return Object.keys(obj).length === keys.length && keys.every(key => Object.hasOwn(obj, key))
|
|
61
|
+
&& obj.schemaVersion === 1 && obj.phase === phase && obj.reservationId === b.reservationId
|
|
62
|
+
&& obj.reservationVersion === b.reservationVersion && obj.route === b.route && obj.owner === b.owner && obj.executionId === b.executionId;
|
|
63
|
+
}
|
|
64
|
+
async function writeMarker(directory, b, phase) {
|
|
65
|
+
const handle = await open(pathFor(directory, b, phase), "wx", 0o600);
|
|
66
|
+
try {
|
|
67
|
+
await handle.writeFile(JSON.stringify(record(b, phase)) + "\n");
|
|
68
|
+
await handle.sync();
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
await handle.close();
|
|
72
|
+
}
|
|
73
|
+
const parent = await open(directory, "r");
|
|
74
|
+
try {
|
|
75
|
+
await parent.sync();
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
await parent.close();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** Read untrusted fixture markers; sender settlement never proves receiver state. */
|
|
82
|
+
export async function inspectSenderFixture(directory, b, hooks) {
|
|
83
|
+
try {
|
|
84
|
+
if (!valid(b))
|
|
85
|
+
return unknown();
|
|
86
|
+
const start = await readRecord(pathFor(directory, b, "start"));
|
|
87
|
+
const abort = await readRecord(pathFor(directory, b, "abort"));
|
|
88
|
+
const settled = await readRecord(pathFor(directory, b, "settled"));
|
|
89
|
+
if (!matches(start, b, "start") || (abort !== undefined && !matches(abort, b, "abort"))
|
|
90
|
+
|| (settled !== undefined && !matches(settled, b, "settled")))
|
|
91
|
+
return unknown();
|
|
92
|
+
await hooks?.beforeRecheck?.();
|
|
93
|
+
const again = await Promise.all(["start", "abort", "settled"].map(phase => readRecord(pathFor(directory, b, phase))));
|
|
94
|
+
if (JSON.stringify([start, abort, settled]) !== JSON.stringify(again))
|
|
95
|
+
return unknown();
|
|
96
|
+
return { status: settled !== undefined ? "sender-settled" : abort !== undefined ? "abort-requested" : "active-or-interrupted",
|
|
97
|
+
evidenceTrust: "unverified-fixture-marker", nativeQuiescence: "unproven", recoveryEligibility: "unavailable" };
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return unknown();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Start a disposable fixture child only after an exclusive, durable marker.
|
|
105
|
+
* It deliberately has no production callers and never changes a reservation.
|
|
106
|
+
* PID is not persisted or used as evidence; markers are not authenticated.
|
|
107
|
+
* Callers must consume child.stdout and child.stderr, or bound the process with
|
|
108
|
+
* timeoutMs or abort(); unread output can fill the pipes and block the child.
|
|
109
|
+
* After direct-child exit, inherited local pipes are bounded and may be closed;
|
|
110
|
+
* this neither proves descendant termination nor native receiver quiescence.
|
|
111
|
+
* Descendant writes to a closed pipe may observe EPIPE or SIGPIPE.
|
|
112
|
+
*/
|
|
113
|
+
export async function startSenderFixture(directory, input, options) {
|
|
114
|
+
const b = structuredClone(input);
|
|
115
|
+
if (!valid(b))
|
|
116
|
+
throw new Error("SENDER_FIXTURE_INVALID_BINDING");
|
|
117
|
+
const killAfterMs = options.killAfterMs === undefined ? 1000 : options.killAfterMs;
|
|
118
|
+
const validDelay = (value) => Number.isFinite(value) && value >= 1 && value <= 2147483647;
|
|
119
|
+
if (!validDelay(killAfterMs) || (options.timeoutMs !== undefined && !validDelay(options.timeoutMs))) {
|
|
120
|
+
throw new Error("SENDER_FIXTURE_INVALID_OPTIONS: timer delay must be between 1 and 2147483647 milliseconds");
|
|
121
|
+
}
|
|
122
|
+
await writeMarker(directory, b, "start");
|
|
123
|
+
const child = spawn(options.command, options.args, { stdio: ["pipe", "pipe", "pipe"] });
|
|
124
|
+
let closed = false;
|
|
125
|
+
let localState = "unknown";
|
|
126
|
+
let exited = false;
|
|
127
|
+
let drainTimeout;
|
|
128
|
+
child.once("spawn", () => { if (!closed && !exited)
|
|
129
|
+
localState = "active"; });
|
|
130
|
+
child.once("exit", () => {
|
|
131
|
+
exited = true;
|
|
132
|
+
localState = "unknown";
|
|
133
|
+
// Descendants can inherit pipes after the direct child has exited. Allow a
|
|
134
|
+
// bounded drain, then close only our local ends; never signal descendants.
|
|
135
|
+
drainTimeout = setTimeout(() => {
|
|
136
|
+
child.stdin.destroy();
|
|
137
|
+
child.stdout.destroy();
|
|
138
|
+
child.stderr.destroy();
|
|
139
|
+
}, 250);
|
|
140
|
+
});
|
|
141
|
+
let abortPromise;
|
|
142
|
+
let timeout;
|
|
143
|
+
let forceKill;
|
|
144
|
+
const abort = () => {
|
|
145
|
+
if (closed || exited || child.pid === undefined)
|
|
146
|
+
return Promise.resolve();
|
|
147
|
+
if (!abortPromise)
|
|
148
|
+
abortPromise = (async () => {
|
|
149
|
+
try {
|
|
150
|
+
if (!matches(await readRecord(pathFor(directory, b, "start")), b, "start"))
|
|
151
|
+
throw new Error("SENDER_FIXTURE_OWNER_MISMATCH");
|
|
152
|
+
await writeMarker(directory, b, "abort");
|
|
153
|
+
localState = "abort-requested";
|
|
154
|
+
}
|
|
155
|
+
finally {
|
|
156
|
+
if (!closed && !exited) {
|
|
157
|
+
child.kill("SIGTERM");
|
|
158
|
+
forceKill = setTimeout(() => { if (!closed && !exited)
|
|
159
|
+
child.kill("SIGKILL"); }, killAfterMs);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
})();
|
|
163
|
+
return abortPromise;
|
|
164
|
+
};
|
|
165
|
+
const completion = new Promise((resolve) => {
|
|
166
|
+
child.once("error", () => { });
|
|
167
|
+
child.once("close", () => {
|
|
168
|
+
closed = true;
|
|
169
|
+
localState = "unknown";
|
|
170
|
+
if (timeout)
|
|
171
|
+
clearTimeout(timeout);
|
|
172
|
+
if (drainTimeout)
|
|
173
|
+
clearTimeout(drainTimeout);
|
|
174
|
+
if (forceKill)
|
|
175
|
+
clearTimeout(forceKill);
|
|
176
|
+
void (async () => {
|
|
177
|
+
try {
|
|
178
|
+
if (abortPromise)
|
|
179
|
+
await abortPromise;
|
|
180
|
+
if (child.pid !== undefined && matches(await readRecord(pathFor(directory, b, "start")), b, "start")) {
|
|
181
|
+
await writeMarker(directory, b, "settled");
|
|
182
|
+
localState = "sender-settled";
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
catch { /* Partial or conflicting fixture evidence remains unresolved. */ }
|
|
186
|
+
})().finally(resolve);
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
if (options.timeoutMs !== undefined)
|
|
190
|
+
timeout = setTimeout(() => { void abort().catch(() => { }); }, options.timeoutMs);
|
|
191
|
+
return { child, abort, closed: completion, localStatus: () => localState };
|
|
192
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morshoto/framekit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"packageManager": "pnpm@12.
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"packageManager": "pnpm@12.18.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"description": "Agentic video editing runtime and MCP server for Final Cut Pro",
|
|
@@ -16,23 +16,40 @@
|
|
|
16
16
|
"bin": {
|
|
17
17
|
"framekit": "./bin/framekit.mjs"
|
|
18
18
|
},
|
|
19
|
+
"exports": {
|
|
20
|
+
"./bin/framekit.mjs": "./bin/framekit.mjs"
|
|
21
|
+
},
|
|
19
22
|
"publishConfig": {
|
|
20
23
|
"access": "public"
|
|
21
24
|
},
|
|
22
25
|
"scripts": {
|
|
23
26
|
"build": "tsc -p tsconfig.json",
|
|
24
|
-
"build:package": "tsc -p tsconfig.package.json && tsc-alias -p tsconfig.package.json",
|
|
25
|
-
"test": "
|
|
27
|
+
"build:package": "tsc -p tsconfig.package.json && tsc-alias -p tsconfig.package.json && node scripts/build/copy-package-runtime-assets.mjs && tsx scripts/write-package-build-identity.ts",
|
|
28
|
+
"test": "node scripts/run-tests-with-isolated-home.mjs",
|
|
29
|
+
"test:fast": "node scripts/run-tests-with-isolated-home.mjs fast",
|
|
30
|
+
"test:unit": "node scripts/run-tests-with-isolated-home.mjs unit",
|
|
31
|
+
"test:contracts": "node scripts/run-tests-with-isolated-home.mjs contract",
|
|
32
|
+
"test:fixtures": "node scripts/run-tests-with-isolated-home.mjs fixture",
|
|
33
|
+
"test:integration": "node scripts/run-tests-with-isolated-home.mjs integration",
|
|
34
|
+
"test:headless": "node scripts/run-tests-with-isolated-home.mjs headless",
|
|
35
|
+
"test:native": "node scripts/run-tests-with-isolated-home.mjs native",
|
|
36
|
+
"test:package": "node scripts/run-tests-with-isolated-home.mjs package --check-only && pnpm run build:package && node scripts/run-tests-with-isolated-home.mjs package",
|
|
37
|
+
"test:inventory:update": "node scripts/test-suites.mjs --update-inventory",
|
|
38
|
+
"test:documentation": "node --test tests/documentation/*.test.mjs",
|
|
39
|
+
"check:workflows": "bash scripts/ci/check-workflows.sh",
|
|
40
|
+
"check:docs": "node scripts/check-docs.mjs",
|
|
41
|
+
|
|
26
42
|
"test:coverage": "c8 --reporter=json-summary --reporter=text --reports-dir=\"${C8_REPORTS_DIR:-coverage}\" pnpm test",
|
|
27
43
|
"test:filler-removal": "tsx --test tests/filler-removal/*.test.ts",
|
|
28
44
|
"benchmark:filler-removal": "tsx scripts/run-filler-removal-benchmark.ts",
|
|
29
45
|
"test:golden": "tsx --test tests/golden/*.test.ts",
|
|
30
|
-
"test:release-gate": "
|
|
31
|
-
"release-gate": "tsx scripts/run-release-gate.ts",
|
|
46
|
+
"test:release-gate": "node scripts/run-tests-with-isolated-home.mjs release-gate",
|
|
47
|
+
"release-gate": "tsx scripts/release/run-release-gate.ts",
|
|
32
48
|
"acceptance:v0112": "tsx scripts/run-v0112-acceptance.ts",
|
|
33
49
|
"release-report": "tsx scripts/generate-release-report.ts",
|
|
34
50
|
"verify-release-provenance": "tsx scripts/verify-release-provenance.ts",
|
|
35
51
|
"test:codex-plugin": "node scripts/codex-plugin-smoke.mjs",
|
|
52
|
+
"smoke:fixture-mcp": "node scripts/fixture-mcp-smoke.mjs",
|
|
36
53
|
"test:clean-mcp-clients": "node scripts/clean-mcp-client-smoke.mjs",
|
|
37
54
|
"evaluate": "tsx scripts/run-mcp-evaluation.ts",
|
|
38
55
|
"test:final-cut-headless": "tsx --test tests/integration/connection.test.ts tests/integration/finalcut-mcp.test.ts tests/integration/native.test.ts",
|
|
@@ -40,12 +57,12 @@
|
|
|
40
57
|
"test:final-cut-overlay-headed": "node scripts/final-cut-overlay-headed-e2e.mjs",
|
|
41
58
|
"test:final-cut-canonical-read-headed": "node scripts/final-cut-canonical-read-headed-e2e.mjs",
|
|
42
59
|
"test:final-cut-incremental-sync-headed": "node --import tsx scripts/final-cut-incremental-sync-headed-e2e.mjs",
|
|
43
|
-
"test:final-cut-publisher-headed": "node scripts/final-cut-publisher-headed-e2e.mjs",
|
|
60
|
+
"test:final-cut-publisher-headed": "node --import tsx scripts/final-cut-publisher-headed-e2e.mjs",
|
|
44
61
|
"test:final-cut-project-selection-headed": "node scripts/final-cut-project-selection-headed-e2e.mjs",
|
|
45
62
|
"test:final-cut-canonical-headed": "node scripts/final-cut-canonical-headed-e2e.mjs",
|
|
46
63
|
"test:final-cut-filler-headed": "node scripts/final-cut-filler-removal-headed-e2e.mjs",
|
|
47
64
|
"test:final-cut-dialogue-headed": "node scripts/final-cut-dialogue-normalization-headed-e2e.mjs",
|
|
48
|
-
"test:watch": "tsx --test --watch tests/integration/*.test.ts tests/evaluation/*.test.ts tests/filler-removal/*.test.ts tests/golden/*.test.ts",
|
|
65
|
+
"test:watch": "tsx --test --watch packages/runtime/test/*.test.ts tests/integration/*.test.ts tests/evaluation/*.test.ts tests/filler-removal/*.test.ts tests/golden/*.test.ts",
|
|
49
66
|
"test:final-cut-disposable-headed": "node scripts/final-cut-disposable-native-headed-e2e.mjs",
|
|
50
67
|
"test:final-cut-transition-headed": "node scripts/final-cut-transition-headed-e2e.mjs",
|
|
51
68
|
"test:final-cut-pip-headed": "node scripts/final-cut-picture-in-picture-headed-e2e.mjs",
|
|
@@ -57,9 +74,12 @@
|
|
|
57
74
|
"hooks:install": "node scripts/install-git-hooks.mjs",
|
|
58
75
|
"check:git-config": "node scripts/check-git-config.mjs",
|
|
59
76
|
"mcp": "tsx apps/mcp-server/src/main.ts",
|
|
77
|
+
"mcp:skill-catalog": "tsx scripts/skill-tool-catalog.ts",
|
|
78
|
+
"check:skill-tools": "tsx scripts/skill-tool-catalog.ts --check",
|
|
60
79
|
"framekit": "node ./bin/framekit.mjs",
|
|
80
|
+
"check:scripts": "node scripts/check-script-references.mjs",
|
|
61
81
|
"package:final-cut-release": "bash scripts/package-final-cut-release.sh",
|
|
62
|
-
"prepack": "
|
|
82
|
+
"prepack": "pnpm run build:package",
|
|
63
83
|
"xcode:check": "bash nix/check-xcode.sh",
|
|
64
84
|
"check:boundaries": "node scripts/check-boundaries.mjs"
|
|
65
85
|
},
|
|
@@ -76,14 +96,16 @@
|
|
|
76
96
|
"commitizen": "^4.3.1",
|
|
77
97
|
"fast-xml-parser": "^5.10.1",
|
|
78
98
|
"git-cz": "^4.9.0",
|
|
79
|
-
"zod": "^
|
|
99
|
+
"zod": "^4.6.7"
|
|
80
100
|
},
|
|
81
101
|
"devDependencies": {
|
|
82
|
-
"@
|
|
83
|
-
"@
|
|
102
|
+
"@babel/parser": "7.29.13",
|
|
103
|
+
"@openai/codex": "0.166.0",
|
|
104
|
+
"@types/node": "24.19.2",
|
|
84
105
|
"c8": "12.0.0",
|
|
85
|
-
"
|
|
86
|
-
"
|
|
106
|
+
"esbuild": "0.28.2",
|
|
107
|
+
"tsc-alias": "1.9.10",
|
|
108
|
+
"tsx": "4.23.15",
|
|
87
109
|
"typescript": "7.0.2"
|
|
88
110
|
}
|
|
89
111
|
}
|
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
-
import { readdir, readFile, rename, writeFile, mkdir } from "node:fs/promises";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
4
|
-
import { FramekitProjectStore, LocalMediaRegistrar, ProjectTransactionService, createFramekitRenderRequest, renderAndVerifyFramekitProject, } from "../../../packages/runtime/src/index.js";
|
|
5
|
-
import { compileTimelineIrToFcpxml, } from "../../../adapters/final-cut/typescript/src/index.js";
|
|
6
|
-
export class HeadlessProjectService {
|
|
7
|
-
directory;
|
|
8
|
-
mediaProbe;
|
|
9
|
-
renderer;
|
|
10
|
-
verifier;
|
|
11
|
-
clock;
|
|
12
|
-
constructor(options) {
|
|
13
|
-
this.directory = options.directory;
|
|
14
|
-
this.mediaProbe = options.mediaProbe;
|
|
15
|
-
this.renderer = options.renderer;
|
|
16
|
-
this.verifier = options.verifier;
|
|
17
|
-
this.clock = options.clock ?? (() => new Date().toISOString());
|
|
18
|
-
}
|
|
19
|
-
async create(timeline) {
|
|
20
|
-
const store = this.store(timeline.project.id);
|
|
21
|
-
const timestamp = this.clock();
|
|
22
|
-
return store.create({
|
|
23
|
-
schemaVersion: 1,
|
|
24
|
-
metadata: { createdAt: timestamp, updatedAt: timestamp },
|
|
25
|
-
timeline,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
async list() {
|
|
29
|
-
await mkdir(this.directory, { recursive: true });
|
|
30
|
-
const entries = await readdir(this.directory, { withFileTypes: true });
|
|
31
|
-
const summaries = [];
|
|
32
|
-
for (const entry of entries.filter((candidate) => candidate.isFile() && candidate.name.endsWith(".json") && !candidate.name.startsWith("render-"))) {
|
|
33
|
-
const projectId = entry.name.slice(0, -".json".length);
|
|
34
|
-
const project = await this.store(projectId).load();
|
|
35
|
-
summaries.push(toSummary(project, this.projectPath(projectId)));
|
|
36
|
-
}
|
|
37
|
-
return summaries.sort((left, right) => left.projectId.localeCompare(right.projectId));
|
|
38
|
-
}
|
|
39
|
-
async open(projectId) {
|
|
40
|
-
const project = await this.store(projectId).load();
|
|
41
|
-
const hasLocalMedia = project.timeline.resources.some((resource) => resource.sourceKind === "local-file");
|
|
42
|
-
if (hasLocalMedia && !this.mediaProbe) {
|
|
43
|
-
throw new Error("HEADLESS_MEDIA_PROBE_UNAVAILABLE: local-file resources require a configured media probe");
|
|
44
|
-
}
|
|
45
|
-
if (this.mediaProbe)
|
|
46
|
-
await new LocalMediaRegistrar(this.store(projectId), this.mediaProbe).reopen();
|
|
47
|
-
return project;
|
|
48
|
-
}
|
|
49
|
-
async inspect(projectId) {
|
|
50
|
-
return this.open(projectId);
|
|
51
|
-
}
|
|
52
|
-
async registerMedia(projectId, sourcePath, expectedRevision) {
|
|
53
|
-
if (!this.mediaProbe)
|
|
54
|
-
throw new Error("HEADLESS_MEDIA_PROBE_UNAVAILABLE: no local media metadata probe is configured");
|
|
55
|
-
return new LocalMediaRegistrar(this.store(projectId), this.mediaProbe, { clock: this.clock }).register(sourcePath, expectedRevision);
|
|
56
|
-
}
|
|
57
|
-
async previewEdit(projectId, command, sequenceId) {
|
|
58
|
-
await this.open(projectId);
|
|
59
|
-
const transaction = new ProjectTransactionService(this.store(projectId), { clock: this.clock });
|
|
60
|
-
return transaction.preview({
|
|
61
|
-
...command,
|
|
62
|
-
target: command.target ?? { projectId, sequenceId },
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
async executeEdit(projectId, command, sequenceId) {
|
|
66
|
-
await this.open(projectId);
|
|
67
|
-
const transaction = new ProjectTransactionService(this.store(projectId), { clock: this.clock });
|
|
68
|
-
return transaction.execute({
|
|
69
|
-
...command,
|
|
70
|
-
target: command.target ?? { projectId, sequenceId },
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
async previewRoughCut(request) {
|
|
74
|
-
const prepared = await this.prepareRoughCut(request);
|
|
75
|
-
const transaction = new ProjectTransactionService(this.store(request.projectId), { clock: this.clock });
|
|
76
|
-
const preview = await transaction.preview(prepared.command);
|
|
77
|
-
const fcpxml = compileTimelineIrToFcpxml(preview.after.timeline, { target: request.fcpxml.target });
|
|
78
|
-
return {
|
|
79
|
-
...preview,
|
|
80
|
-
plan: structuredClone(request.plan),
|
|
81
|
-
planDigest: prepared.planDigest,
|
|
82
|
-
provenance: prepared.provenance,
|
|
83
|
-
outputIntent: prepared.outputIntent,
|
|
84
|
-
fcpxml: selectFcpxmlMetadata(fcpxml),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
async executeRoughCut(request) {
|
|
88
|
-
if (request.approved !== true) {
|
|
89
|
-
throw new Error("HEADLESS_ROUGH_CUT_APPROVAL_REQUIRED: set approved=true after reviewing the preview");
|
|
90
|
-
}
|
|
91
|
-
const prepared = await this.prepareRoughCut(request);
|
|
92
|
-
if (request.planDigest !== prepared.planDigest) {
|
|
93
|
-
throw new Error("HEADLESS_ROUGH_CUT_PLAN_MISMATCH: planDigest does not match the submitted rough-cut plan");
|
|
94
|
-
}
|
|
95
|
-
const transaction = new ProjectTransactionService(this.store(request.projectId), { clock: this.clock });
|
|
96
|
-
const preview = await transaction.preview(prepared.command);
|
|
97
|
-
const fcpxml = compileTimelineIrToFcpxml(preview.after.timeline, { target: request.fcpxml.target });
|
|
98
|
-
const renderRequest = createFramekitRenderRequest({
|
|
99
|
-
timeline: preview.after.timeline,
|
|
100
|
-
target: { projectId: request.projectId, sequenceId: request.sequenceId },
|
|
101
|
-
revision: preview.after.timeline.revision,
|
|
102
|
-
parameters: request.render,
|
|
103
|
-
});
|
|
104
|
-
if (!this.renderer || !this.verifier) {
|
|
105
|
-
throw new Error("HEADLESS_ROUGH_CUT_RENDER_UNAVAILABLE: renderer and verifier are not configured");
|
|
106
|
-
}
|
|
107
|
-
const outcome = await renderAndVerifyFramekitProject(renderRequest, this.renderer, this.verifier);
|
|
108
|
-
const renderId = `render-${randomUUID()}`;
|
|
109
|
-
const renderRecord = {
|
|
110
|
-
renderId,
|
|
111
|
-
projectId: request.projectId,
|
|
112
|
-
sequenceId: request.sequenceId,
|
|
113
|
-
requestedRevision: renderRequest.projectRevision,
|
|
114
|
-
createdAt: this.clock(),
|
|
115
|
-
status: outcome.status,
|
|
116
|
-
outcome,
|
|
117
|
-
};
|
|
118
|
-
await this.saveRender(renderRecord);
|
|
119
|
-
if (outcome.status !== "passed") {
|
|
120
|
-
throw new Error(`HEADLESS_ROUGH_CUT_RENDER_FAILED: render verification status was ${outcome.status}; inspect ${renderId}`);
|
|
121
|
-
}
|
|
122
|
-
const fcpxmlArtifact = await writeVerifiedFcpxml(request.fcpxml.path, fcpxml.xml, fcpxml.digest, request.fcpxml.overwrite === true);
|
|
123
|
-
const committed = await transaction.execute(prepared.command);
|
|
124
|
-
return {
|
|
125
|
-
...preview,
|
|
126
|
-
plan: structuredClone(request.plan),
|
|
127
|
-
planDigest: prepared.planDigest,
|
|
128
|
-
provenance: prepared.provenance,
|
|
129
|
-
outputIntent: prepared.outputIntent,
|
|
130
|
-
fcpxml: selectFcpxmlMetadata(fcpxml),
|
|
131
|
-
committed: true,
|
|
132
|
-
render: { renderId, status: "passed", outcome },
|
|
133
|
-
fcpxmlArtifact,
|
|
134
|
-
transaction: committed,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
async render(projectId, sequenceId, parameters, expectedRevision) {
|
|
138
|
-
if (!this.renderer || !this.verifier)
|
|
139
|
-
throw new Error("HEADLESS_RENDER_UNAVAILABLE: renderer and verifier are not configured");
|
|
140
|
-
const project = await this.open(projectId);
|
|
141
|
-
const request = createFramekitRenderRequest({
|
|
142
|
-
timeline: project.timeline,
|
|
143
|
-
target: { projectId, sequenceId },
|
|
144
|
-
...(expectedRevision ? { revision: expectedRevision } : {}),
|
|
145
|
-
parameters,
|
|
146
|
-
});
|
|
147
|
-
const outcome = await renderAndVerifyFramekitProject(request, this.renderer, this.verifier);
|
|
148
|
-
const renderId = `render-${randomUUID()}`;
|
|
149
|
-
const record = {
|
|
150
|
-
renderId,
|
|
151
|
-
projectId,
|
|
152
|
-
sequenceId,
|
|
153
|
-
requestedRevision: request.projectRevision,
|
|
154
|
-
createdAt: this.clock(),
|
|
155
|
-
status: outcome.status,
|
|
156
|
-
outcome,
|
|
157
|
-
};
|
|
158
|
-
await this.saveRender(record);
|
|
159
|
-
return record;
|
|
160
|
-
}
|
|
161
|
-
async inspectRender(renderId) {
|
|
162
|
-
validateRenderId(renderId);
|
|
163
|
-
try {
|
|
164
|
-
return JSON.parse(await readFile(join(this.directory, `${renderId}.json`), "utf8"));
|
|
165
|
-
}
|
|
166
|
-
catch (error) {
|
|
167
|
-
if (error.code === "ENOENT")
|
|
168
|
-
throw new Error(`HEADLESS_RENDER_NOT_FOUND: render record does not exist: ${renderId}`);
|
|
169
|
-
throw error;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
store(projectId) {
|
|
173
|
-
return new FramekitProjectStore(this.projectPath(projectId));
|
|
174
|
-
}
|
|
175
|
-
projectPath(projectId) {
|
|
176
|
-
validateProjectId(projectId);
|
|
177
|
-
return join(this.directory, `${projectId}.json`);
|
|
178
|
-
}
|
|
179
|
-
async saveRender(record) {
|
|
180
|
-
await mkdir(this.directory, { recursive: true });
|
|
181
|
-
const path = join(this.directory, `${record.renderId}.json`);
|
|
182
|
-
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
183
|
-
await writeFile(temporary, `${JSON.stringify(record)}\n`, { encoding: "utf8", flag: "wx" });
|
|
184
|
-
await rename(temporary, path);
|
|
185
|
-
}
|
|
186
|
-
async prepareRoughCut(request) {
|
|
187
|
-
await this.open(request.projectId);
|
|
188
|
-
const project = await this.store(request.projectId).load();
|
|
189
|
-
if (project.timeline.sequence.id !== request.sequenceId) {
|
|
190
|
-
throw new Error("HEADLESS_ROUGH_CUT_TARGET_MISMATCH: sequenceId does not match the persisted project");
|
|
191
|
-
}
|
|
192
|
-
if (!sameRevision(project.timeline.revision, request.plan.revision)) {
|
|
193
|
-
throw new Error("HEADLESS_ROUGH_CUT_STALE_REVISION: rough-cut plan revision does not match the persisted project");
|
|
194
|
-
}
|
|
195
|
-
if (!request.plan.shots.length)
|
|
196
|
-
throw new Error("HEADLESS_ROUGH_CUT_EMPTY_PLAN: rough-cut plan must contain at least one shot");
|
|
197
|
-
const operations = structuredClone(request.operations ?? []);
|
|
198
|
-
const sourceAudioPolicy = request.sourceAudioPolicy ?? "preserve-and-mix";
|
|
199
|
-
const outputIntent = {
|
|
200
|
-
sourceAudioPolicy,
|
|
201
|
-
render: structuredClone(request.render),
|
|
202
|
-
fcpxml: {
|
|
203
|
-
path: request.fcpxml.path,
|
|
204
|
-
target: structuredClone(request.fcpxml.target),
|
|
205
|
-
overwrite: request.fcpxml.overwrite === true,
|
|
206
|
-
},
|
|
207
|
-
};
|
|
208
|
-
const planDigest = digestRoughCutPlan(request.plan, operations, outputIntent);
|
|
209
|
-
const existingOccurrenceIds = new Set(project.timeline.sequence.occurrences.map(({ id }) => id));
|
|
210
|
-
const resourceByMediaId = new Map(project.timeline.resources.map((resource) => [resource.id, resource]));
|
|
211
|
-
const provenance = [];
|
|
212
|
-
const planOperations = [];
|
|
213
|
-
for (const shot of request.plan.shots) {
|
|
214
|
-
const shotWithEvidence = shot;
|
|
215
|
-
const occurrenceId = `rough-cut-${shot.order}`;
|
|
216
|
-
if (existingOccurrenceIds.has(occurrenceId)) {
|
|
217
|
-
throw new Error(`HEADLESS_ROUGH_CUT_OCCURRENCE_COLLISION: ${occurrenceId} already exists`);
|
|
218
|
-
}
|
|
219
|
-
existingOccurrenceIds.add(occurrenceId);
|
|
220
|
-
const resource = resourceByMediaId.get(shot.sourceIdentity.mediaId);
|
|
221
|
-
if (!resource)
|
|
222
|
-
throw new Error(`HEADLESS_ROUGH_CUT_SOURCE_NOT_FOUND: ${shot.sourceIdentity.mediaId}`);
|
|
223
|
-
assertSourceIdentity(resource, shot.sourceIdentity);
|
|
224
|
-
const sourceStartTime = shot.range.startTime ?? secondsToRational(shot.range.start);
|
|
225
|
-
const durationTime = shot.range.durationTime ?? secondsToRational(shot.range.end - shot.range.start);
|
|
226
|
-
assertSourceRange(resource, shot.range, sourceStartTime, durationTime);
|
|
227
|
-
planOperations.push({
|
|
228
|
-
type: "insert-occurrence",
|
|
229
|
-
placement: "append",
|
|
230
|
-
occurrence: {
|
|
231
|
-
id: occurrenceId,
|
|
232
|
-
name: `Rough cut ${shot.order}: ${shot.rationale}`,
|
|
233
|
-
startTime: { value: "0", timescale: "1" },
|
|
234
|
-
durationTime,
|
|
235
|
-
sourceStartTime,
|
|
236
|
-
track: 0,
|
|
237
|
-
role: "video",
|
|
238
|
-
mediaId: resource.id,
|
|
239
|
-
binding: { provider: "framekit.rough-cut", kind: "occurrence", identity: `${planDigest}:${shot.order}` },
|
|
240
|
-
},
|
|
241
|
-
});
|
|
242
|
-
provenance.push({
|
|
243
|
-
order: shot.order,
|
|
244
|
-
occurrenceId,
|
|
245
|
-
mediaId: resource.id,
|
|
246
|
-
sourceIdentity: structuredClone(shot.sourceIdentity),
|
|
247
|
-
sourceRange: structuredClone(shot.range),
|
|
248
|
-
confidence: shot.confidence,
|
|
249
|
-
matchedProperties: [...shot.matchedProperties],
|
|
250
|
-
rationale: shot.rationale,
|
|
251
|
-
...(shotWithEvidence.evidence ? { evidence: structuredClone(shotWithEvidence.evidence) } : {}),
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
const editOperations = [...planOperations, ...operations];
|
|
255
|
-
const command = {
|
|
256
|
-
schemaVersion: 1,
|
|
257
|
-
target: { projectId: request.projectId, sequenceId: request.sequenceId },
|
|
258
|
-
expectedRevision: structuredClone(request.plan.revision),
|
|
259
|
-
operations: editOperations,
|
|
260
|
-
};
|
|
261
|
-
return { command, planDigest, provenance, outputIntent };
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
function digestRoughCutPlan(plan, operations, outputIntent) {
|
|
265
|
-
return createHash("sha256").update(stableJson({ plan, operations, outputIntent })).digest("hex");
|
|
266
|
-
}
|
|
267
|
-
function stableJson(value) {
|
|
268
|
-
if (value === null || typeof value !== "object")
|
|
269
|
-
return JSON.stringify(value);
|
|
270
|
-
if (Array.isArray(value))
|
|
271
|
-
return `[${value.map(stableJson).join(",")}]`;
|
|
272
|
-
return `{${Object.entries(value).filter(([, child]) => child !== undefined).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => `${JSON.stringify(key)}:${stableJson(child)}`).join(",")}}`;
|
|
273
|
-
}
|
|
274
|
-
function assertSourceIdentity(resource, source) {
|
|
275
|
-
if (resource.source !== source.source)
|
|
276
|
-
throw new Error(`HEADLESS_ROUGH_CUT_SOURCE_MISMATCH: source path differs for ${source.mediaId}`);
|
|
277
|
-
if (source.sourceDigest !== undefined && resource.sourceDigest !== source.sourceDigest) {
|
|
278
|
-
throw new Error(`HEADLESS_ROUGH_CUT_SOURCE_MISMATCH: source digest differs for ${source.mediaId}`);
|
|
279
|
-
}
|
|
280
|
-
if (source.mediaKind !== undefined && resource.mediaKind !== source.mediaKind) {
|
|
281
|
-
throw new Error(`HEADLESS_ROUGH_CUT_SOURCE_MISMATCH: media kind differs for ${source.mediaId}`);
|
|
282
|
-
}
|
|
283
|
-
if (resource.mediaKind !== "video")
|
|
284
|
-
throw new Error(`HEADLESS_ROUGH_CUT_VIDEO_REQUIRED: ${source.mediaId}`);
|
|
285
|
-
if (source.duration !== undefined && resource.metadata?.durationTime !== undefined
|
|
286
|
-
&& Math.abs(source.duration - rationalSeconds(resource.metadata.durationTime)) > 0.01) {
|
|
287
|
-
throw new Error(`HEADLESS_ROUGH_CUT_SOURCE_MISMATCH: source duration differs for ${source.mediaId}`);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
function assertSourceRange(resource, range, sourceStartTime, durationTime) {
|
|
291
|
-
if (!Number.isFinite(range.start) || !Number.isFinite(range.end) || range.start < 0 || range.end <= range.start) {
|
|
292
|
-
throw new Error("HEADLESS_ROUGH_CUT_RANGE_INVALID: source range must be finite and non-empty");
|
|
293
|
-
}
|
|
294
|
-
if (resource.metadata?.durationTime !== undefined && range.end > rationalSeconds(resource.metadata.durationTime) + 0.001) {
|
|
295
|
-
throw new Error(`HEADLESS_ROUGH_CUT_RANGE_INVALID: source range exceeds ${resource.id}`);
|
|
296
|
-
}
|
|
297
|
-
if (rationalSeconds(sourceStartTime) < 0 || rationalSeconds(durationTime) <= 0
|
|
298
|
-
|| Math.abs(rationalSeconds(sourceStartTime) - range.start) > 0.001
|
|
299
|
-
|| Math.abs(rationalSeconds(durationTime) - (range.end - range.start)) > 0.001) {
|
|
300
|
-
throw new Error("HEADLESS_ROUGH_CUT_RANGE_INVALID: rational source range must be non-negative and non-empty");
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
function secondsToRational(seconds) {
|
|
304
|
-
const timescale = 1_000_000;
|
|
305
|
-
const value = Math.round(seconds * timescale);
|
|
306
|
-
const divisor = greatestCommonDivisor(Math.abs(value), timescale);
|
|
307
|
-
return { value: String(value / divisor), timescale: String(timescale / divisor) };
|
|
308
|
-
}
|
|
309
|
-
function rationalSeconds(time) {
|
|
310
|
-
return Number(time.value) / Number(time.timescale);
|
|
311
|
-
}
|
|
312
|
-
function greatestCommonDivisor(left, right) {
|
|
313
|
-
while (right !== 0) {
|
|
314
|
-
const remainder = left % right;
|
|
315
|
-
left = right;
|
|
316
|
-
right = remainder;
|
|
317
|
-
}
|
|
318
|
-
return left || 1;
|
|
319
|
-
}
|
|
320
|
-
function sameRevision(left, right) {
|
|
321
|
-
return left.id === right.id && left.sequence === right.sequence && left.timestamp === right.timestamp;
|
|
322
|
-
}
|
|
323
|
-
function selectFcpxmlMetadata(result) {
|
|
324
|
-
return {
|
|
325
|
-
digest: result.digest,
|
|
326
|
-
target: structuredClone(result.target),
|
|
327
|
-
destination: structuredClone(result.destination),
|
|
328
|
-
coverage: structuredClone(result.coverage),
|
|
329
|
-
provenance: structuredClone(result.provenance),
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
async function writeVerifiedFcpxml(path, xml, digest, overwrite) {
|
|
333
|
-
await mkdir(dirname(path), { recursive: true });
|
|
334
|
-
if (!overwrite) {
|
|
335
|
-
try {
|
|
336
|
-
await readFile(path);
|
|
337
|
-
throw new Error(`HEADLESS_ROUGH_CUT_FCPXML_EXISTS: refusing to overwrite ${path}`);
|
|
338
|
-
}
|
|
339
|
-
catch (error) {
|
|
340
|
-
if (error.code !== "ENOENT")
|
|
341
|
-
throw error;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
345
|
-
await writeFile(temporary, xml, { encoding: "utf8", flag: "wx" });
|
|
346
|
-
await rename(temporary, path);
|
|
347
|
-
const persisted = await readFile(path, "utf8");
|
|
348
|
-
const persistedDigest = createHash("sha256").update(persisted).digest("hex");
|
|
349
|
-
if (persistedDigest !== digest)
|
|
350
|
-
throw new Error("HEADLESS_ROUGH_CUT_FCPXML_VERIFY_FAILED: persisted XML digest differs from the compiled artifact");
|
|
351
|
-
return { path, digest, bytes: Buffer.byteLength(persisted), verified: true };
|
|
352
|
-
}
|
|
353
|
-
function toSummary(project, path) {
|
|
354
|
-
return {
|
|
355
|
-
projectId: project.timeline.project.id,
|
|
356
|
-
projectName: project.timeline.project.name,
|
|
357
|
-
sequenceId: project.timeline.sequence.id,
|
|
358
|
-
sequenceName: project.timeline.sequence.name,
|
|
359
|
-
revision: project.timeline.revision,
|
|
360
|
-
path,
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
function validateProjectId(projectId) {
|
|
364
|
-
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(projectId))
|
|
365
|
-
throw new Error("HEADLESS_PROJECT_INVALID: projectId must be a safe logical identifier");
|
|
366
|
-
}
|
|
367
|
-
function validateRenderId(renderId) {
|
|
368
|
-
if (!/^render-[0-9a-f-]{36}$/.test(renderId))
|
|
369
|
-
throw new Error("HEADLESS_RENDER_INVALID: renderId is invalid");
|
|
370
|
-
}
|