@morshoto/framekit 0.1.0 → 0.1.4
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 +42 -17
- package/dist-package/adapters/final-cut/typescript/src/analyzers.js +57 -0
- package/dist-package/adapters/final-cut/typescript/src/connection.js +5 -1
- package/dist-package/adapters/final-cut/typescript/src/export.js +231 -8
- package/dist-package/adapters/final-cut/typescript/src/fcpxml.js +55 -5
- package/dist-package/adapters/final-cut/typescript/src/live.js +2 -2
- package/dist-package/adapters/final-cut/typescript/src/native.js +1000 -100
- package/dist-package/adapters/final-cut/typescript/src/publisher.js +40 -5
- package/dist-package/adapters/final-cut/typescript/src/session.js +21 -5
- package/dist-package/apps/mcp-server/src/main.js +9 -1
- package/dist-package/apps/mcp-server/src/routing.js +172 -0
- package/dist-package/apps/mcp-server/src/server.js +780 -33
- package/dist-package/packages/runtime/src/application/duration-policy-service.js +6 -0
- package/dist-package/packages/runtime/src/application/media-analysis-service.js +370 -0
- package/dist-package/packages/runtime/src/application/project-service.js +127 -0
- package/dist-package/packages/runtime/src/application/runtime-options.js +1 -0
- package/dist-package/packages/runtime/src/application/transaction-store.js +12 -0
- package/dist-package/packages/runtime/src/audio/dialogue-normalization.js +64 -0
- package/dist-package/packages/runtime/src/audio/noise-reduction.js +46 -0
- package/dist-package/packages/runtime/src/capabilities.js +112 -1
- package/dist-package/packages/runtime/src/color-correction.js +48 -0
- package/dist-package/packages/runtime/src/context/context-engine.js +11 -6
- package/dist-package/packages/runtime/src/context/context-service.js +30 -0
- package/dist-package/packages/runtime/src/context/revision.js +3 -0
- package/dist-package/packages/runtime/src/domain/capabilities.js +1 -0
- package/dist-package/packages/runtime/src/domain/context.js +1 -0
- package/dist-package/packages/runtime/src/domain/diff.js +1 -0
- package/dist-package/packages/runtime/src/domain/duration.js +1 -0
- package/dist-package/packages/runtime/src/domain/editing.js +1 -0
- package/dist-package/packages/runtime/src/domain/index.js +12 -0
- package/dist-package/packages/runtime/src/domain/media.js +7 -0
- package/dist-package/packages/runtime/src/domain/ports.js +1 -0
- package/dist-package/packages/runtime/src/domain/primitives.js +1 -0
- package/dist-package/packages/runtime/src/domain/project.js +1 -0
- package/dist-package/packages/runtime/src/domain/rough-cut.js +69 -0
- package/dist-package/packages/runtime/src/domain/skills.js +33 -0
- package/dist-package/packages/runtime/src/domain/types.js +5 -1
- package/dist-package/packages/runtime/src/domain/verification.js +1 -0
- package/dist-package/packages/runtime/src/editing/dialogue-normalization-service.js +141 -0
- package/dist-package/packages/runtime/src/editing/duration-policy.js +187 -0
- package/dist-package/packages/runtime/src/editing/edit-service.js +413 -0
- package/dist-package/packages/runtime/src/editing/filler-removal-service.js +337 -0
- package/dist-package/packages/runtime/src/editing/music-service.js +85 -0
- package/dist-package/packages/runtime/src/index.js +12 -3
- package/dist-package/packages/runtime/src/planning/rough-cut.js +65 -0
- package/dist-package/packages/runtime/src/runtime.js +130 -825
- package/dist-package/packages/runtime/src/skills/builtin.js +339 -0
- package/dist-package/packages/runtime/src/skills/index.js +3 -0
- package/dist-package/packages/runtime/src/skills/registry.js +74 -0
- package/dist-package/packages/runtime/src/skills/requirements.js +170 -0
- package/dist-package/packages/runtime/src/skills/runtime.js +239 -0
- package/dist-package/packages/runtime/src/speech/filler-detector.js +132 -0
- package/dist-package/packages/runtime/src/speech/safe-cut-resolver.js +314 -0
- package/dist-package/packages/runtime/src/timeline/rational-time.js +58 -0
- package/dist-package/packages/runtime/src/verification/verification.js +712 -1
- package/dist-package/packages/testkit/src/fixture-analyzers.js +27 -0
- package/dist-package/packages/testkit/src/in-memory-editor.js +286 -3
- package/dist-package/packages/testkit/src/index.js +1 -0
- package/dist-package/packages/testkit/src/skill-fixtures.js +64 -0
- package/package.json +15 -7
- /package/dist-package/packages/runtime/src/{diff/diff.js → timeline/snapshot-diff.js} +0 -0
- /package/dist-package/packages/runtime/src/{snapshot-digest.js → timeline/snapshot-digest.js} +0 -0
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
export class FixtureSpeechAnalyzer {
|
|
2
|
+
descriptor = { id: "fixture.speech", provider: "fixture", version: "1" };
|
|
2
3
|
async analyze(input, range) {
|
|
3
4
|
const speech = input.media.speech;
|
|
4
5
|
if (!speech)
|
|
5
6
|
throw new Error(`ANALYSIS_FAILED: no speech fixture for ${input.media.mediaId}`);
|
|
6
7
|
return {
|
|
7
8
|
words: filterRange(speech.words, range),
|
|
9
|
+
...(speech.vadSegments ? { vadSegments: filterSegments(speech.vadSegments, range) } : {}),
|
|
10
|
+
...(speech.silenceSegments ? { silenceSegments: filterSegments(speech.silenceSegments, range) } : {}),
|
|
11
|
+
...(speech.protectedSegments ? { protectedSegments: filterSegments(speech.protectedSegments, range) } : {}),
|
|
8
12
|
};
|
|
9
13
|
}
|
|
10
14
|
}
|
|
11
15
|
export class FixtureAudioAnalyzer {
|
|
16
|
+
descriptor = { id: "fixture.audio", provider: "fixture", version: "1" };
|
|
12
17
|
async analyze(input, range) {
|
|
13
18
|
if (!input.media.audio)
|
|
14
19
|
throw new Error(`ANALYSIS_FAILED: no audio fixture for ${input.media.mediaId}`);
|
|
@@ -16,6 +21,7 @@ export class FixtureAudioAnalyzer {
|
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
23
|
export class FixtureVisualAnalyzer {
|
|
24
|
+
descriptor = { id: "fixture.visual", provider: "fixture", version: "1" };
|
|
19
25
|
async analyze(input, range) {
|
|
20
26
|
const visual = input.media.visual;
|
|
21
27
|
if (!visual)
|
|
@@ -30,6 +36,20 @@ export class FixtureVisualAnalyzer {
|
|
|
30
36
|
};
|
|
31
37
|
}
|
|
32
38
|
}
|
|
39
|
+
export class FixtureMetadataAnalyzer {
|
|
40
|
+
descriptor = { id: "fixture.metadata", provider: "fixture", version: "1" };
|
|
41
|
+
async analyze(input, range) {
|
|
42
|
+
if (!input.media.metadata)
|
|
43
|
+
throw new Error(`ANALYSIS_FAILED: no metadata fixture for ${input.media.mediaId}`);
|
|
44
|
+
const metadata = structuredClone(input.media.metadata);
|
|
45
|
+
if (!range || !metadata.usableRanges)
|
|
46
|
+
return metadata;
|
|
47
|
+
return {
|
|
48
|
+
...metadata,
|
|
49
|
+
usableRanges: metadata.usableRanges.filter((candidate) => candidate.end > range.start && candidate.start < range.end),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
33
53
|
function filterRange(words, range) {
|
|
34
54
|
if (!range)
|
|
35
55
|
return words.map((word) => ({ ...word }));
|
|
@@ -37,3 +57,10 @@ function filterRange(words, range) {
|
|
|
37
57
|
.filter((word) => word.end > range.start && word.start < range.end)
|
|
38
58
|
.map((word) => ({ ...word }));
|
|
39
59
|
}
|
|
60
|
+
function filterSegments(segments, range) {
|
|
61
|
+
if (!range)
|
|
62
|
+
return segments.map((segment) => ({ ...segment }));
|
|
63
|
+
return segments
|
|
64
|
+
.filter((segment) => segment.end > range.start && segment.start < range.end)
|
|
65
|
+
.map((segment) => ({ ...segment }));
|
|
66
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { diffSnapshots } from "../../runtime/src/index.js";
|
|
1
|
+
import { diffSnapshots, withCapabilityFamilies } from "../../runtime/src/index.js";
|
|
2
2
|
export class InMemoryEditorAdapter {
|
|
3
|
+
getManagedArtifact;
|
|
3
4
|
snapshot;
|
|
4
5
|
assets;
|
|
5
6
|
history = new Map();
|
|
@@ -43,7 +44,7 @@ export class InMemoryEditorAdapter {
|
|
|
43
44
|
return { name: "In-memory Editor", version: "phase-2-fixture", backend: "fixture" };
|
|
44
45
|
}
|
|
45
46
|
async getCapabilities() {
|
|
46
|
-
return {
|
|
47
|
+
return withCapabilityFamilies({
|
|
47
48
|
editor: {
|
|
48
49
|
projectRead: true,
|
|
49
50
|
timelineSnapshotRead: true,
|
|
@@ -62,6 +63,33 @@ export class InMemoryEditorAdapter {
|
|
|
62
63
|
mediaImport: true,
|
|
63
64
|
mediaPlacement: true,
|
|
64
65
|
titlePlacement: true,
|
|
66
|
+
clipMove: true,
|
|
67
|
+
clipReplace: true,
|
|
68
|
+
clipRemoval: true,
|
|
69
|
+
transitionPlacement: true,
|
|
70
|
+
audioAttachment: true,
|
|
71
|
+
audioMixing: true,
|
|
72
|
+
noiseReduction: true,
|
|
73
|
+
colorCorrection: true,
|
|
74
|
+
semanticOperations: {
|
|
75
|
+
"rename-clip": true,
|
|
76
|
+
"trim-clip": true,
|
|
77
|
+
"set-gain": true,
|
|
78
|
+
"reduce-noise": true,
|
|
79
|
+
"set-color-correction": true,
|
|
80
|
+
"ripple-delete": true,
|
|
81
|
+
"add-marker": true,
|
|
82
|
+
"media.import": true,
|
|
83
|
+
"timeline.media.add": true,
|
|
84
|
+
"timeline.audio.fades": true,
|
|
85
|
+
"timeline.title.add": true,
|
|
86
|
+
"timeline.media.move": true,
|
|
87
|
+
"timeline.media.replace": true,
|
|
88
|
+
"timeline.media.remove": true,
|
|
89
|
+
"timeline.transition.add": true,
|
|
90
|
+
"timeline.audio.attach": true,
|
|
91
|
+
"timeline.audio.mix": true,
|
|
92
|
+
},
|
|
65
93
|
},
|
|
66
94
|
analyzers: {
|
|
67
95
|
speechTranscribe: false,
|
|
@@ -69,7 +97,7 @@ export class InMemoryEditorAdapter {
|
|
|
69
97
|
audioLoudness: false,
|
|
70
98
|
visualTrack: false,
|
|
71
99
|
},
|
|
72
|
-
};
|
|
100
|
+
}, { backend: "fixture" });
|
|
73
101
|
}
|
|
74
102
|
async captureFrame(position, expectedRevision) {
|
|
75
103
|
if (this.snapshot.revision.id !== expectedRevision.id
|
|
@@ -204,6 +232,9 @@ export class InMemoryEditorAdapter {
|
|
|
204
232
|
const media = snapshot.media.find((candidate) => candidate.mediaId === operation.mediaId);
|
|
205
233
|
if (!media)
|
|
206
234
|
throw new Error(`MEDIA_NOT_FOUND: ${operation.mediaId}`);
|
|
235
|
+
if (!isMediaCompatible(operation.role, media.mediaKind)) {
|
|
236
|
+
throw new Error(`MEDIA_KIND_MISMATCH: ${operation.mediaId}`);
|
|
237
|
+
}
|
|
207
238
|
if (snapshot.timeline.clips.some((clip) => clip.id === operation.occurrenceId)) {
|
|
208
239
|
throw new Error(`OCCURRENCE_ALREADY_EXISTS: ${operation.occurrenceId}`);
|
|
209
240
|
}
|
|
@@ -240,6 +271,7 @@ export class InMemoryEditorAdapter {
|
|
|
240
271
|
durationTime: clip.durationTime,
|
|
241
272
|
lane: clip.track,
|
|
242
273
|
mediaId: clip.mediaId,
|
|
274
|
+
...(clip.attachedTo ? { attachedTo: clip.attachedTo } : {}),
|
|
243
275
|
}],
|
|
244
276
|
},
|
|
245
277
|
};
|
|
@@ -300,6 +332,226 @@ export class InMemoryEditorAdapter {
|
|
|
300
332
|
},
|
|
301
333
|
};
|
|
302
334
|
}
|
|
335
|
+
if (operation.type === "timeline.media.move") {
|
|
336
|
+
const clip = snapshot.timeline.clips.find(({ id }) => id === operation.occurrenceId);
|
|
337
|
+
if (!clip)
|
|
338
|
+
throw new Error(`CLIP_NOT_FOUND: ${operation.occurrenceId}`);
|
|
339
|
+
if (!Number.isFinite(operation.start) || operation.start < 0) {
|
|
340
|
+
throw new Error("INVALID_OPERATION: media move start must be non-negative");
|
|
341
|
+
}
|
|
342
|
+
const lane = operation.targetLane ?? (clip.track === 0 ? "primary" : clip.track);
|
|
343
|
+
if (lane === "primary") {
|
|
344
|
+
if (clip.role !== undefined && clip.role !== "video") {
|
|
345
|
+
throw new Error("INVALID_OPERATION: audio and title clips require a non-primary lane");
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
else if (!Number.isInteger(lane) || lane === 0) {
|
|
349
|
+
throw new Error("INVALID_OPERATION: media move requires a valid lane");
|
|
350
|
+
}
|
|
351
|
+
return this.updateClip(snapshot, withClipTime({
|
|
352
|
+
...clip,
|
|
353
|
+
start: operation.start,
|
|
354
|
+
track: lane === "primary" ? 0 : lane,
|
|
355
|
+
startTime: undefined,
|
|
356
|
+
durationTime: undefined,
|
|
357
|
+
}));
|
|
358
|
+
}
|
|
359
|
+
if (operation.type === "timeline.media.replace") {
|
|
360
|
+
const clip = snapshot.timeline.clips.find(({ id }) => id === operation.occurrenceId);
|
|
361
|
+
if (!clip)
|
|
362
|
+
throw new Error(`CLIP_NOT_FOUND: ${operation.occurrenceId}`);
|
|
363
|
+
const media = snapshot.media.find(({ mediaId }) => mediaId === operation.mediaId);
|
|
364
|
+
if (!media)
|
|
365
|
+
throw new Error(`MEDIA_NOT_FOUND: ${operation.mediaId}`);
|
|
366
|
+
const currentMedia = clip.mediaId
|
|
367
|
+
? snapshot.media.find(({ mediaId }) => mediaId === clip.mediaId)
|
|
368
|
+
: undefined;
|
|
369
|
+
const currentKind = clip.role === "audio" || clip.role === "music"
|
|
370
|
+
? "audio"
|
|
371
|
+
: clip.role === "video" ? "video" : currentMedia?.mediaKind;
|
|
372
|
+
if (!isMediaCompatible(clip.role, media.mediaKind)
|
|
373
|
+
|| (currentKind !== undefined && media.mediaKind !== undefined && currentKind !== media.mediaKind)) {
|
|
374
|
+
throw new Error(`MEDIA_KIND_MISMATCH: ${operation.mediaId}`);
|
|
375
|
+
}
|
|
376
|
+
const duration = operation.duration ?? clip.duration;
|
|
377
|
+
if (!Number.isFinite(duration) || duration <= 0 || (media.duration !== undefined && duration > media.duration)) {
|
|
378
|
+
throw new Error("INVALID_OPERATION: replacement duration must fit the source");
|
|
379
|
+
}
|
|
380
|
+
return this.updateClip(snapshot, withClipTime({
|
|
381
|
+
...clip,
|
|
382
|
+
mediaId: operation.mediaId,
|
|
383
|
+
name: media.source.split("/").pop() || media.mediaId,
|
|
384
|
+
duration,
|
|
385
|
+
startTime: undefined,
|
|
386
|
+
durationTime: undefined,
|
|
387
|
+
}));
|
|
388
|
+
}
|
|
389
|
+
if (operation.type === "timeline.media.remove") {
|
|
390
|
+
const clip = snapshot.timeline.clips.find(({ id }) => id === operation.occurrenceId);
|
|
391
|
+
if (!clip)
|
|
392
|
+
throw new Error(`CLIP_NOT_FOUND: ${operation.occurrenceId}`);
|
|
393
|
+
const removedIds = new Set([operation.occurrenceId]);
|
|
394
|
+
snapshot.timeline.clips.forEach((candidate) => {
|
|
395
|
+
if (candidate.attachedTo === operation.occurrenceId)
|
|
396
|
+
removedIds.add(candidate.id);
|
|
397
|
+
});
|
|
398
|
+
return {
|
|
399
|
+
...snapshot,
|
|
400
|
+
timeline: {
|
|
401
|
+
...snapshot.timeline,
|
|
402
|
+
clips: snapshot.timeline.clips.filter((candidate) => !removedIds.has(candidate.id)),
|
|
403
|
+
storyElements: snapshot.timeline.storyElements.filter((element) => !removedIds.has(element.id)
|
|
404
|
+
&& !removedIds.has(element.attachedTo ?? "")
|
|
405
|
+
&& !removedIds.has(element.beforeClipId ?? "")
|
|
406
|
+
&& !removedIds.has(element.afterClipId ?? "")),
|
|
407
|
+
},
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
if (operation.type === "timeline.transition.add") {
|
|
411
|
+
const asset = this.assets.find((candidate) => candidate.id === operation.assetId && candidate.kind === "transition");
|
|
412
|
+
if (!asset)
|
|
413
|
+
throw new Error(`TRANSITION_ASSET_NOT_FOUND: ${operation.assetId}`);
|
|
414
|
+
if (asset.compatibility?.timelineKinds?.includes("asset-clip") !== true) {
|
|
415
|
+
throw new Error(`TRANSITION_ASSET_INCOMPATIBLE: ${operation.assetId}`);
|
|
416
|
+
}
|
|
417
|
+
if (snapshot.timeline.storyElements.some(({ id }) => id === operation.transitionId)
|
|
418
|
+
|| snapshot.timeline.clips.some(({ id }) => id === operation.transitionId)) {
|
|
419
|
+
throw new Error(`OCCURRENCE_ALREADY_EXISTS: ${operation.transitionId}`);
|
|
420
|
+
}
|
|
421
|
+
const before = snapshot.timeline.clips.find(({ id }) => id === operation.beforeClipId);
|
|
422
|
+
const after = snapshot.timeline.clips.find(({ id }) => id === operation.afterClipId);
|
|
423
|
+
if (!before || !after)
|
|
424
|
+
throw new Error("EDIT_POINT_NOT_FOUND: transition clips are required");
|
|
425
|
+
if (before.track !== after.track || Math.abs((before.start + before.duration) - after.start) > 1e-6) {
|
|
426
|
+
throw new Error("EDIT_POINT_INVALID: transition clips must meet on one lane");
|
|
427
|
+
}
|
|
428
|
+
if (!Number.isFinite(operation.duration) || operation.duration <= 0
|
|
429
|
+
|| operation.duration > Math.min(before.duration, after.duration)) {
|
|
430
|
+
throw new Error("INVALID_OPERATION: transition duration must fit both clips");
|
|
431
|
+
}
|
|
432
|
+
const start = after.start - operation.duration / 2;
|
|
433
|
+
return {
|
|
434
|
+
...snapshot,
|
|
435
|
+
timeline: {
|
|
436
|
+
...snapshot.timeline,
|
|
437
|
+
storyElements: [...snapshot.timeline.storyElements, {
|
|
438
|
+
id: operation.transitionId,
|
|
439
|
+
kind: "transition",
|
|
440
|
+
start,
|
|
441
|
+
duration: operation.duration,
|
|
442
|
+
startTime: decimalToRational(start),
|
|
443
|
+
durationTime: decimalToRational(operation.duration),
|
|
444
|
+
lane: before.track,
|
|
445
|
+
assetId: operation.assetId,
|
|
446
|
+
beforeClipId: operation.beforeClipId,
|
|
447
|
+
afterClipId: operation.afterClipId,
|
|
448
|
+
}],
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
if (operation.type === "timeline.audio.attach") {
|
|
453
|
+
const target = snapshot.timeline.clips.find(({ id }) => id === operation.targetClipId);
|
|
454
|
+
if (!target)
|
|
455
|
+
throw new Error(`CLIP_NOT_FOUND: ${operation.targetClipId}`);
|
|
456
|
+
const media = snapshot.media.find(({ mediaId }) => mediaId === operation.mediaId);
|
|
457
|
+
if (!media)
|
|
458
|
+
throw new Error(`MEDIA_NOT_FOUND: ${operation.mediaId}`);
|
|
459
|
+
if (media.mediaKind !== "audio")
|
|
460
|
+
throw new Error(`AUDIO_MEDIA_REQUIRED: ${operation.mediaId}`);
|
|
461
|
+
if (snapshot.timeline.clips.some(({ id }) => id === operation.occurrenceId)
|
|
462
|
+
|| snapshot.timeline.storyElements.some(({ id }) => id === operation.occurrenceId)) {
|
|
463
|
+
throw new Error(`OCCURRENCE_ALREADY_EXISTS: ${operation.occurrenceId}`);
|
|
464
|
+
}
|
|
465
|
+
const startOffset = operation.startOffset ?? 0;
|
|
466
|
+
const duration = operation.duration ?? media.duration;
|
|
467
|
+
if (!Number.isFinite(startOffset) || startOffset < 0 || duration === undefined
|
|
468
|
+
|| !Number.isFinite(duration) || duration <= 0
|
|
469
|
+
|| (media.duration !== undefined && duration > media.duration)
|
|
470
|
+
|| startOffset + duration > target.duration) {
|
|
471
|
+
throw new Error("INVALID_OPERATION: attached audio must fit within the target clip");
|
|
472
|
+
}
|
|
473
|
+
const clip = withClipTime({
|
|
474
|
+
id: operation.occurrenceId,
|
|
475
|
+
mediaId: operation.mediaId,
|
|
476
|
+
name: media.source.split("/").pop() || media.mediaId,
|
|
477
|
+
start: target.start + startOffset,
|
|
478
|
+
duration,
|
|
479
|
+
track: -1,
|
|
480
|
+
role: "audio",
|
|
481
|
+
attachedTo: target.id,
|
|
482
|
+
});
|
|
483
|
+
return {
|
|
484
|
+
...snapshot,
|
|
485
|
+
timeline: {
|
|
486
|
+
...snapshot.timeline,
|
|
487
|
+
clips: [...snapshot.timeline.clips, clip],
|
|
488
|
+
storyElements: [...snapshot.timeline.storyElements, {
|
|
489
|
+
id: clip.id,
|
|
490
|
+
kind: "asset-clip",
|
|
491
|
+
start: clip.start,
|
|
492
|
+
duration: clip.duration,
|
|
493
|
+
startTime: clip.startTime,
|
|
494
|
+
durationTime: clip.durationTime,
|
|
495
|
+
lane: clip.track,
|
|
496
|
+
mediaId: clip.mediaId,
|
|
497
|
+
attachedTo: clip.attachedTo,
|
|
498
|
+
}],
|
|
499
|
+
},
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
if (operation.type === "timeline.audio.mix") {
|
|
503
|
+
const clip = snapshot.timeline.clips.find(({ id }) => id === operation.clipId);
|
|
504
|
+
if (!clip)
|
|
505
|
+
throw new Error(`CLIP_NOT_FOUND: ${operation.clipId}`);
|
|
506
|
+
const media = clip.mediaId ? snapshot.media.find(({ mediaId }) => mediaId === clip.mediaId) : undefined;
|
|
507
|
+
if (clip.role !== "audio" && clip.role !== "music" && media?.mediaKind !== "audio") {
|
|
508
|
+
throw new Error("INVALID_OPERATION: audio mix requires an audio clip");
|
|
509
|
+
}
|
|
510
|
+
if (operation.gainDb === undefined && operation.fadeIn === undefined && operation.fadeOut === undefined) {
|
|
511
|
+
throw new Error("INVALID_OPERATION: audio mix requires a gain or fade change");
|
|
512
|
+
}
|
|
513
|
+
const fadeIn = operation.fadeIn ?? clip.fadeIn ?? 0;
|
|
514
|
+
const fadeOut = operation.fadeOut ?? clip.fadeOut ?? 0;
|
|
515
|
+
if ((operation.gainDb !== undefined && !Number.isFinite(operation.gainDb))
|
|
516
|
+
|| !Number.isFinite(fadeIn) || !Number.isFinite(fadeOut)
|
|
517
|
+
|| fadeIn < 0 || fadeOut < 0 || fadeIn + fadeOut > clip.duration) {
|
|
518
|
+
throw new Error("INVALID_OPERATION: audio mix values must fit the clip");
|
|
519
|
+
}
|
|
520
|
+
return this.updateClip(snapshot, {
|
|
521
|
+
...clip,
|
|
522
|
+
...(operation.gainDb !== undefined ? { gainDb: operation.gainDb } : {}),
|
|
523
|
+
fadeIn,
|
|
524
|
+
fadeOut,
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
if (operation.type === "reduce-noise") {
|
|
528
|
+
const clip = snapshot.timeline.clips.find(({ id }) => id === operation.clipId);
|
|
529
|
+
if (!clip)
|
|
530
|
+
throw new Error(`CLIP_NOT_FOUND: ${operation.clipId}`);
|
|
531
|
+
const media = clip.mediaId ? snapshot.media.find(({ mediaId }) => mediaId === clip.mediaId) : undefined;
|
|
532
|
+
if (clip.role !== "audio" && clip.role !== "music" && media?.mediaKind !== "audio") {
|
|
533
|
+
throw new Error("INVALID_OPERATION: noise reduction requires an audio clip");
|
|
534
|
+
}
|
|
535
|
+
if (!Number.isFinite(operation.reductionDb) || operation.reductionDb <= 0
|
|
536
|
+
|| operation.range.start < clip.start
|
|
537
|
+
|| operation.range.end > clip.start + clip.duration
|
|
538
|
+
|| operation.range.end <= operation.range.start) {
|
|
539
|
+
throw new Error("INVALID_OPERATION: noise reduction range and adjustment must fit the clip");
|
|
540
|
+
}
|
|
541
|
+
return this.updateClip(snapshot, {
|
|
542
|
+
...clip,
|
|
543
|
+
noiseReductionDb: (clip.noiseReductionDb ?? 0) + operation.reductionDb,
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
if (operation.type === "set-color-correction") {
|
|
547
|
+
const clip = snapshot.timeline.clips.find(({ id }) => id === operation.clipId);
|
|
548
|
+
if (!clip)
|
|
549
|
+
throw new Error(`CLIP_NOT_FOUND: ${operation.clipId}`);
|
|
550
|
+
return this.updateClip(snapshot, {
|
|
551
|
+
...clip,
|
|
552
|
+
colorCorrection: structuredClone(operation.correction),
|
|
553
|
+
});
|
|
554
|
+
}
|
|
303
555
|
if (operation.type === "ripple-delete") {
|
|
304
556
|
return this.applyRippleDelete(snapshot, operation.timelineId, operation.range.start, operation.range.end);
|
|
305
557
|
}
|
|
@@ -353,6 +605,27 @@ export class InMemoryEditorAdapter {
|
|
|
353
605
|
},
|
|
354
606
|
};
|
|
355
607
|
}
|
|
608
|
+
updateClip(snapshot, updatedClip) {
|
|
609
|
+
return {
|
|
610
|
+
...snapshot,
|
|
611
|
+
timeline: {
|
|
612
|
+
...snapshot.timeline,
|
|
613
|
+
clips: snapshot.timeline.clips.map((candidate) => candidate.id === updatedClip.id ? updatedClip : candidate),
|
|
614
|
+
storyElements: snapshot.timeline.storyElements.map((element) => element.id === updatedClip.id
|
|
615
|
+
? {
|
|
616
|
+
...element,
|
|
617
|
+
start: updatedClip.start,
|
|
618
|
+
duration: updatedClip.duration,
|
|
619
|
+
startTime: updatedClip.startTime,
|
|
620
|
+
durationTime: updatedClip.durationTime,
|
|
621
|
+
lane: updatedClip.track,
|
|
622
|
+
...(updatedClip.mediaId ? { mediaId: updatedClip.mediaId } : {}),
|
|
623
|
+
...(updatedClip.attachedTo ? { attachedTo: updatedClip.attachedTo } : {}),
|
|
624
|
+
}
|
|
625
|
+
: element),
|
|
626
|
+
},
|
|
627
|
+
};
|
|
628
|
+
}
|
|
356
629
|
applyRippleDelete(snapshot, timelineId, start, end) {
|
|
357
630
|
if (timelineId !== snapshot.timeline.id)
|
|
358
631
|
throw new Error(`TIMELINE_NOT_FOUND: ${timelineId}`);
|
|
@@ -479,6 +752,7 @@ function createSnapshot(fixture) {
|
|
|
479
752
|
durationTime: clip.durationTime,
|
|
480
753
|
lane: clip.track,
|
|
481
754
|
mediaId: clip.mediaId,
|
|
755
|
+
...(clip.attachedTo ? { attachedTo: clip.attachedTo } : {}),
|
|
482
756
|
})),
|
|
483
757
|
markers: (fixture.markers ?? []).map((marker) => normalizeMarker(marker)),
|
|
484
758
|
captions: (fixture.captions ?? []).map((caption) => normalizeCaption(caption)),
|
|
@@ -518,3 +792,12 @@ function decimalToRational(value) {
|
|
|
518
792
|
const scale = 10 ** decimals;
|
|
519
793
|
return { value: String(Math.round(value * scale)), timescale: String(scale) };
|
|
520
794
|
}
|
|
795
|
+
function isMediaCompatible(role, mediaKind) {
|
|
796
|
+
if (role === "video")
|
|
797
|
+
return mediaKind === undefined || mediaKind === "video";
|
|
798
|
+
if (role === "audio" || role === "music")
|
|
799
|
+
return mediaKind === undefined || mediaKind === "audio";
|
|
800
|
+
if (role === "title")
|
|
801
|
+
return false;
|
|
802
|
+
return true;
|
|
803
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** Neutral Skill used to conformance-test runtime and adapter boundaries. */
|
|
2
|
+
export function createAddMarkerSkill() {
|
|
3
|
+
return {
|
|
4
|
+
manifest: {
|
|
5
|
+
contractVersion: 1,
|
|
6
|
+
id: "fixture.add-marker",
|
|
7
|
+
version: "0.0.2",
|
|
8
|
+
title: "Add marker",
|
|
9
|
+
description: "Add one deterministic review marker to the active timeline.",
|
|
10
|
+
inputSchema: {
|
|
11
|
+
type: "object",
|
|
12
|
+
properties: {
|
|
13
|
+
name: { type: "string", minLength: 1 },
|
|
14
|
+
start: { type: "number", minimum: 0 },
|
|
15
|
+
},
|
|
16
|
+
required: ["name", "start"],
|
|
17
|
+
additionalProperties: false,
|
|
18
|
+
},
|
|
19
|
+
requirements: {
|
|
20
|
+
type: "anyOf",
|
|
21
|
+
requirements: [
|
|
22
|
+
{
|
|
23
|
+
type: "allOf",
|
|
24
|
+
requirements: [
|
|
25
|
+
{ type: "editor", capability: "timelineSnapshotRead" },
|
|
26
|
+
{ type: "editor", capability: "timelineWrite" },
|
|
27
|
+
{ type: "editor", capability: "readAfterWrite" },
|
|
28
|
+
{ type: "editor", capability: "rollback" },
|
|
29
|
+
{ type: "operation", operation: "add-marker" },
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: "allOf",
|
|
34
|
+
requirements: [
|
|
35
|
+
{ type: "editor", capability: "timelineSnapshotRead" },
|
|
36
|
+
{ type: "editor", capability: "timelineArtifactWrite" },
|
|
37
|
+
{ type: "editor", capability: "readAfterWrite" },
|
|
38
|
+
{ type: "editor", capability: "rollback" },
|
|
39
|
+
{ type: "operation", operation: "add-marker" },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
verification: { requireExpectedChange: true },
|
|
45
|
+
},
|
|
46
|
+
handler: {
|
|
47
|
+
normalize: (input) => input,
|
|
48
|
+
plan: (context, input) => ({
|
|
49
|
+
operations: [{
|
|
50
|
+
type: "add-marker",
|
|
51
|
+
timelineId: context.project.timeline.id,
|
|
52
|
+
marker: {
|
|
53
|
+
id: `fixture-marker-${String(input.start)}`,
|
|
54
|
+
start: input.start,
|
|
55
|
+
duration: 0,
|
|
56
|
+
name: input.name,
|
|
57
|
+
},
|
|
58
|
+
}],
|
|
59
|
+
affectedRanges: [{ start: input.start, end: input.start }],
|
|
60
|
+
warnings: [],
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morshoto/framekit",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"packageManager": "pnpm@
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"packageManager": "pnpm@12.3.4",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"description": "Agentic video editing runtime and MCP server for Final Cut Pro",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/morshoto/framekit.git"
|
|
11
|
+
},
|
|
8
12
|
"files": [
|
|
9
13
|
"bin",
|
|
10
14
|
"dist-package"
|
|
@@ -18,20 +22,24 @@
|
|
|
18
22
|
"scripts": {
|
|
19
23
|
"build": "tsc -p tsconfig.json",
|
|
20
24
|
"build:package": "tsc -p tsconfig.package.json && tsc-alias -p tsconfig.package.json",
|
|
21
|
-
"test": "tsx --test tests/integration/*.test.ts tests/evaluation/*.test.ts tests/filler-removal/*.test.ts tests/golden/*.test.ts",
|
|
25
|
+
"test": "tsx --test tests/integration/*.test.ts tests/evaluation/*.test.ts tests/filler-removal/*.test.ts tests/speech/*.test.ts tests/golden/*.test.ts tests/release-gate/*.test.ts",
|
|
22
26
|
"test:filler-removal": "tsx --test tests/filler-removal/*.test.ts",
|
|
23
27
|
"benchmark:filler-removal": "tsx scripts/run-filler-removal-benchmark.ts",
|
|
24
28
|
"test:golden": "tsx --test tests/golden/*.test.ts",
|
|
29
|
+
"test:release-gate": "tsx --test tests/release-gate/*.test.ts",
|
|
30
|
+
"release-gate": "tsx scripts/run-release-gate.ts",
|
|
25
31
|
"test:codex-plugin": "node scripts/codex-plugin-smoke.mjs",
|
|
26
32
|
"test:clean-mcp-clients": "node scripts/clean-mcp-client-smoke.mjs",
|
|
27
33
|
"evaluate": "tsx scripts/run-mcp-evaluation.ts",
|
|
28
34
|
"test:final-cut-headless": "tsx --test tests/integration/connection.test.ts tests/integration/finalcut-mcp.test.ts tests/integration/native.test.ts",
|
|
29
35
|
"test:final-cut-overlay-headed": "node scripts/final-cut-overlay-headed-e2e.mjs",
|
|
30
36
|
"test:final-cut-canonical-read-headed": "node scripts/final-cut-canonical-read-headed-e2e.mjs",
|
|
37
|
+
"test:final-cut-project-selection-headed": "node scripts/final-cut-project-selection-headed-e2e.mjs",
|
|
31
38
|
"test:final-cut-canonical-headed": "node scripts/final-cut-canonical-headed-e2e.mjs",
|
|
32
39
|
"test:final-cut-filler-headed": "node scripts/final-cut-filler-removal-headed-e2e.mjs",
|
|
33
40
|
"test:watch": "tsx --test --watch tests/integration/*.test.ts tests/evaluation/*.test.ts tests/filler-removal/*.test.ts tests/golden/*.test.ts",
|
|
34
41
|
"test:final-cut-disposable-headed": "node scripts/final-cut-disposable-native-headed-e2e.mjs",
|
|
42
|
+
"test:final-cut-transition-headed": "node scripts/final-cut-transition-headed-e2e.mjs",
|
|
35
43
|
"hooks:install": "node scripts/install-git-hooks.mjs",
|
|
36
44
|
"mcp": "tsx apps/mcp-server/src/main.ts",
|
|
37
45
|
"framekit": "node ./bin/framekit.mjs",
|
|
@@ -56,9 +64,9 @@
|
|
|
56
64
|
"zod": "^3.25.76"
|
|
57
65
|
},
|
|
58
66
|
"devDependencies": {
|
|
59
|
-
"@types/node": "
|
|
60
|
-
"tsc-alias": "
|
|
61
|
-
"tsx": "
|
|
62
|
-
"typescript": "
|
|
67
|
+
"@types/node": "24.13.3",
|
|
68
|
+
"tsc-alias": "1.9.4",
|
|
69
|
+
"tsx": "4.23.13",
|
|
70
|
+
"typescript": "7.0.2"
|
|
63
71
|
}
|
|
64
72
|
}
|
|
File without changes
|
/package/dist-package/packages/runtime/src/{snapshot-digest.js → timeline/snapshot-digest.js}
RENAMED
|
File without changes
|