@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,214 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { basename, resolve } from "node:path";
|
|
3
|
+
export const FINAL_CUT_PUBLISH_READBACK_CHECKS = [
|
|
4
|
+
"project-and-sequence-names",
|
|
5
|
+
"timeline-duration-and-frame-rate",
|
|
6
|
+
"clip-order-and-source-ranges",
|
|
7
|
+
"editable-title-content-and-timing",
|
|
8
|
+
"connected-audio-source-role-gain-and-timing",
|
|
9
|
+
"other-timeline-elements",
|
|
10
|
+
"markers-and-captions",
|
|
11
|
+
"source-media-bindings",
|
|
12
|
+
];
|
|
13
|
+
export class FinalCutPublishSemanticMismatchError extends Error {
|
|
14
|
+
expectedDigest;
|
|
15
|
+
observedDigest;
|
|
16
|
+
mismatchedChecks;
|
|
17
|
+
code = "FINAL_CUT_PUBLISH_SEMANTIC_MISMATCH";
|
|
18
|
+
constructor(expectedDigest, observedDigest, mismatchedChecks) {
|
|
19
|
+
super(`FINAL_CUT_PUBLISH_SEMANTIC_MISMATCH: native Final Cut readback differs from the approved FCPXML (${mismatchedChecks.join(", ")})`);
|
|
20
|
+
this.expectedDigest = expectedDigest;
|
|
21
|
+
this.observedDigest = observedDigest;
|
|
22
|
+
this.mismatchedChecks = mismatchedChecks;
|
|
23
|
+
this.name = "FinalCutPublishSemanticMismatchError";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** Compare supported native timeline semantics while ignoring generated native IDs and revisions. */
|
|
27
|
+
export function verifyFinalCutPublishReadback(expected, actual, options) {
|
|
28
|
+
const expectedSignature = publishTimelineSignature(expected, options?.expectedSourceMediaDigests);
|
|
29
|
+
const actualSignature = publishTimelineSignature(actual, options?.actualSourceMediaDigests);
|
|
30
|
+
const expectedJson = stableJson(expectedSignature);
|
|
31
|
+
const actualJson = stableJson(actualSignature);
|
|
32
|
+
const expectedDigest = digest(expectedJson);
|
|
33
|
+
const observedDigest = digest(actualJson);
|
|
34
|
+
if (expectedJson !== actualJson) {
|
|
35
|
+
const mismatchedChecks = FINAL_CUT_PUBLISH_READBACK_CHECKS.filter((check) => stableJson(expectedSignature[check]) !== stableJson(actualSignature[check]));
|
|
36
|
+
throw new FinalCutPublishSemanticMismatchError(expectedDigest, observedDigest, [...mismatchedChecks]);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
verified: true,
|
|
40
|
+
expectedDigest,
|
|
41
|
+
observedDigest,
|
|
42
|
+
checked: [...FINAL_CUT_PUBLISH_READBACK_CHECKS],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function publishTimelineSignature(snapshot, sourceMediaDigests) {
|
|
46
|
+
const referencedMediaIds = new Set([
|
|
47
|
+
...snapshot.timeline.clips.map(({ mediaId }) => mediaId),
|
|
48
|
+
...snapshot.timeline.storyElements.map(({ mediaId }) => mediaId),
|
|
49
|
+
].filter((mediaId) => mediaId !== undefined));
|
|
50
|
+
const referencedMedia = snapshot.media.filter(({ mediaId }) => referencedMediaIds.has(mediaId));
|
|
51
|
+
const digestBySource = sourceMediaDigests === undefined
|
|
52
|
+
? undefined
|
|
53
|
+
: new Map(sourceMediaDigests.map(({ source, sha256 }) => [resolve(source), sha256]));
|
|
54
|
+
const sourceIdentity = (source) => {
|
|
55
|
+
if (digestBySource === undefined)
|
|
56
|
+
return normalizeSource(source);
|
|
57
|
+
const sha256 = digestBySource.get(resolve(source));
|
|
58
|
+
if (sha256 === undefined) {
|
|
59
|
+
throw new Error(`FINAL_CUT_PUBLISH_SOURCE_MEDIA_BINDING_MISMATCH: no verified digest for ${source}`);
|
|
60
|
+
}
|
|
61
|
+
return `sha256:${sha256}`;
|
|
62
|
+
};
|
|
63
|
+
const sourceByMediaId = new Map(referencedMedia.map(({ mediaId, source }) => [mediaId, sourceIdentity(source)]));
|
|
64
|
+
const audioMediaIds = new Set(referencedMedia.filter(({ mediaKind }) => mediaKind === "audio").map(({ mediaId }) => mediaId));
|
|
65
|
+
const mediaSource = (mediaId) => {
|
|
66
|
+
if (mediaId === undefined)
|
|
67
|
+
return undefined;
|
|
68
|
+
return sourceByMediaId.get(mediaId) ?? `unresolved-media:${mediaId}`;
|
|
69
|
+
};
|
|
70
|
+
const clips = snapshot.timeline.clips;
|
|
71
|
+
const titles = snapshot.timeline.storyElements.filter(({ kind }) => kind === "title");
|
|
72
|
+
const audioClips = clips.filter((clip) => isAudioClip(clip, audioMediaIds));
|
|
73
|
+
const mediaBindings = referencedMedia
|
|
74
|
+
.map(({ source, mediaKind, duration }) => ({ source: sourceIdentity(source), mediaKind, duration }))
|
|
75
|
+
.sort((left, right) => compareText(stableJson(left), stableJson(right)));
|
|
76
|
+
const representedStoryKinds = new Set(["asset-clip", "audio", "clip", "mc-clip", "ref-clip", "sync-clip", "title", "video"]);
|
|
77
|
+
return {
|
|
78
|
+
"project-and-sequence-names": {
|
|
79
|
+
projectName: snapshot.projectName,
|
|
80
|
+
sequenceName: snapshot.timeline.name,
|
|
81
|
+
},
|
|
82
|
+
"timeline-duration-and-frame-rate": {
|
|
83
|
+
durationTime: frameRoundedSignature(snapshot.timeline.durationTime, snapshot.timeline.frameDuration),
|
|
84
|
+
frameDuration: rationalSignature(snapshot.timeline.frameDuration),
|
|
85
|
+
},
|
|
86
|
+
"clip-order-and-source-ranges": clips
|
|
87
|
+
.filter((clip) => !isAudioClip(clip, audioMediaIds))
|
|
88
|
+
.map((clip) => clipSignature(clip, mediaSource, audioMediaIds)),
|
|
89
|
+
"editable-title-content-and-timing": titles.map((title) => storyElementSignature(title, mediaSource, audioMediaIds)),
|
|
90
|
+
"connected-audio-source-role-gain-and-timing": {
|
|
91
|
+
clips: audioClips.map((clip) => clipSignature(clip, mediaSource, audioMediaIds)),
|
|
92
|
+
elements: snapshot.timeline.storyElements
|
|
93
|
+
.filter((element) => element.kind === "audio" || audioMediaIds.has(element.mediaId ?? ""))
|
|
94
|
+
.map((element) => storyElementSignature(element, mediaSource, audioMediaIds)),
|
|
95
|
+
},
|
|
96
|
+
"other-timeline-elements": snapshot.timeline.storyElements
|
|
97
|
+
.filter((element) => !representedStoryKinds.has(element.kind))
|
|
98
|
+
.map((element) => storyElementSignature(element, mediaSource, audioMediaIds)),
|
|
99
|
+
"markers-and-captions": {
|
|
100
|
+
markers: snapshot.timeline.markers.map((marker) => ({
|
|
101
|
+
name: marker.name,
|
|
102
|
+
startTime: rationalSignature(marker.startTime),
|
|
103
|
+
durationTime: rationalSignature(marker.durationTime),
|
|
104
|
+
})),
|
|
105
|
+
captions: snapshot.timeline.captions.map((caption) => ({
|
|
106
|
+
text: caption.text,
|
|
107
|
+
startTime: rationalSignature(caption.startTime),
|
|
108
|
+
durationTime: rationalSignature(caption.durationTime),
|
|
109
|
+
})),
|
|
110
|
+
},
|
|
111
|
+
"source-media-bindings": mediaBindings,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function clipSignature(clip, mediaSource, audioMediaIds) {
|
|
115
|
+
return {
|
|
116
|
+
source: mediaSource(clip.mediaId),
|
|
117
|
+
name: clip.name,
|
|
118
|
+
startTime: rationalSignature(clip.startTime),
|
|
119
|
+
durationTime: rationalSignature(clip.durationTime),
|
|
120
|
+
sourceStartTime: rationalSignature(clip.sourceStartTime ?? zeroRational()),
|
|
121
|
+
track: isAudioClip(clip, audioMediaIds) ? Math.abs(clip.track) : clip.track,
|
|
122
|
+
gainDb: clip.gainDb,
|
|
123
|
+
noiseReductionDb: clip.noiseReductionDb,
|
|
124
|
+
colorCorrection: clip.colorCorrection,
|
|
125
|
+
role: clip.role,
|
|
126
|
+
nativeAudioRole: clip.nativeAudioRole,
|
|
127
|
+
enabled: clip.enabled,
|
|
128
|
+
position: clip.position,
|
|
129
|
+
scale: clip.scale,
|
|
130
|
+
crop: clip.crop,
|
|
131
|
+
frame: clip.frame,
|
|
132
|
+
mask: clip.mask,
|
|
133
|
+
fadeIn: clip.fadeIn,
|
|
134
|
+
fadeOut: clip.fadeOut,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function storyElementSignature(element, mediaSource, audioMediaIds) {
|
|
138
|
+
const audio = element.kind === "audio" || audioMediaIds.has(element.mediaId ?? "");
|
|
139
|
+
return {
|
|
140
|
+
kind: element.kind,
|
|
141
|
+
startTime: rationalSignature(element.startTime),
|
|
142
|
+
durationTime: rationalSignature(element.durationTime),
|
|
143
|
+
lane: element.lane === undefined ? undefined : audio ? Math.abs(element.lane) : element.lane,
|
|
144
|
+
source: mediaSource(element.mediaId),
|
|
145
|
+
text: element.text,
|
|
146
|
+
assetId: element.assetId,
|
|
147
|
+
position: element.position,
|
|
148
|
+
scale: element.scale,
|
|
149
|
+
crop: element.crop,
|
|
150
|
+
frame: element.frame,
|
|
151
|
+
mask: element.mask,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function isAudioClip(clip, audioMediaIds) {
|
|
155
|
+
return clip.role === "audio" || clip.role === "music"
|
|
156
|
+
|| (clip.mediaId !== undefined && audioMediaIds.has(clip.mediaId));
|
|
157
|
+
}
|
|
158
|
+
function normalizeSource(source) {
|
|
159
|
+
return basename(resolve(source)).normalize("NFC");
|
|
160
|
+
}
|
|
161
|
+
function frameRoundedSignature(duration, frameDuration) {
|
|
162
|
+
if (!duration || !frameDuration)
|
|
163
|
+
return rationalSignature(duration);
|
|
164
|
+
const frameNumerator = BigInt(frameDuration.value);
|
|
165
|
+
const frameDenominator = BigInt(frameDuration.timescale);
|
|
166
|
+
const durationNumerator = BigInt(duration.value);
|
|
167
|
+
const durationDenominator = BigInt(duration.timescale);
|
|
168
|
+
const denominator = durationDenominator * frameNumerator;
|
|
169
|
+
const numerator = durationNumerator * frameDenominator;
|
|
170
|
+
if (denominator <= 0n || frameNumerator <= 0n || numerator < 0n) {
|
|
171
|
+
throw new Error("FINAL_CUT_PUBLISH_READBACK_INVALID: timeline duration or frame duration is invalid");
|
|
172
|
+
}
|
|
173
|
+
const roundedFrames = (numerator * 2n + denominator) / (denominator * 2n);
|
|
174
|
+
return `${roundedFrames} frames`;
|
|
175
|
+
}
|
|
176
|
+
function rationalSignature(value) {
|
|
177
|
+
if (!value)
|
|
178
|
+
return undefined;
|
|
179
|
+
const numerator = BigInt(value.value);
|
|
180
|
+
const denominator = BigInt(value.timescale);
|
|
181
|
+
if (denominator === 0n)
|
|
182
|
+
throw new Error("FINAL_CUT_PUBLISH_READBACK_INVALID: rational time has a zero timescale");
|
|
183
|
+
const sign = denominator < 0n ? -1n : 1n;
|
|
184
|
+
const signedNumerator = numerator * sign;
|
|
185
|
+
const positiveDenominator = denominator * sign;
|
|
186
|
+
const divisor = greatestCommonDivisor(signedNumerator, positiveDenominator);
|
|
187
|
+
return `${signedNumerator / divisor}/${positiveDenominator / divisor}`;
|
|
188
|
+
}
|
|
189
|
+
function zeroRational() {
|
|
190
|
+
return { value: "0", timescale: "1" };
|
|
191
|
+
}
|
|
192
|
+
function greatestCommonDivisor(left, right) {
|
|
193
|
+
let a = left < 0n ? -left : left;
|
|
194
|
+
let b = right < 0n ? -right : right;
|
|
195
|
+
while (b !== 0n)
|
|
196
|
+
[a, b] = [b, a % b];
|
|
197
|
+
return a === 0n ? 1n : a;
|
|
198
|
+
}
|
|
199
|
+
function stableJson(value) {
|
|
200
|
+
if (value === null || typeof value !== "object")
|
|
201
|
+
return JSON.stringify(value);
|
|
202
|
+
if (Array.isArray(value))
|
|
203
|
+
return `[${value.map(stableJson).join(",")}]`;
|
|
204
|
+
const entries = Object.entries(value)
|
|
205
|
+
.filter(([, child]) => child !== undefined)
|
|
206
|
+
.sort(([left], [right]) => left.localeCompare(right));
|
|
207
|
+
return `{${entries.map(([key, child]) => `${JSON.stringify(key)}:${stableJson(child)}`).join(",")}}`;
|
|
208
|
+
}
|
|
209
|
+
function digest(value) {
|
|
210
|
+
return createHash("sha256").update(value).digest("hex");
|
|
211
|
+
}
|
|
212
|
+
function compareText(left, right) {
|
|
213
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
214
|
+
}
|