@morshoto/framekit 0.1.4 → 0.1.6
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 +2 -2
- package/dist-package/adapters/final-cut/typescript/src/analyzers.js +29 -2
- package/dist-package/adapters/final-cut/typescript/src/assets.js +89 -3
- package/dist-package/adapters/final-cut/typescript/src/canonical.js +431 -0
- package/dist-package/adapters/final-cut/typescript/src/connection.js +19 -4
- package/dist-package/adapters/final-cut/typescript/src/fcpxml.js +212 -13
- package/dist-package/adapters/final-cut/typescript/src/index.js +1 -0
- package/dist-package/adapters/final-cut/typescript/src/native.js +1026 -7
- package/dist-package/adapters/final-cut/typescript/src/publisher.js +207 -30
- package/dist-package/adapters/final-cut/typescript/src/session.js +69 -8
- package/dist-package/apps/mcp-server/src/main.js +49 -11
- package/dist-package/apps/mcp-server/src/routing.js +15 -0
- package/dist-package/apps/mcp-server/src/server.js +289 -68
- package/dist-package/apps/mcp-server/src/version.js +34 -0
- package/dist-package/packages/runtime/src/application/media-analysis-service.js +119 -15
- package/dist-package/packages/runtime/src/application/project-service.js +21 -2
- package/dist-package/packages/runtime/src/audio/dialogue-normalization.js +9 -0
- package/dist-package/packages/runtime/src/capabilities.js +90 -10
- package/dist-package/packages/runtime/src/context/context-engine.js +10 -1
- package/dist-package/packages/runtime/src/domain/editing.js +27 -1
- package/dist-package/packages/runtime/src/domain/media.js +1 -0
- package/dist-package/packages/runtime/src/domain/skills.js +2 -0
- package/dist-package/packages/runtime/src/editing/edit-service.js +82 -4
- package/dist-package/packages/runtime/src/editing/filler-removal-service.js +31 -7
- package/dist-package/packages/runtime/src/index.js +2 -0
- package/dist-package/packages/runtime/src/planning/rough-cut.js +9 -3
- package/dist-package/packages/runtime/src/runtime.js +2 -2
- package/dist-package/packages/runtime/src/skills/builtin.js +314 -39
- package/dist-package/packages/runtime/src/skills/requirements.js +1 -0
- package/dist-package/packages/runtime/src/skills/runtime.js +33 -8
- package/dist-package/packages/runtime/src/speech/analysis.js +301 -0
- package/dist-package/packages/runtime/src/speech/mapping.js +227 -0
- package/dist-package/packages/runtime/src/timeline/rational-time.js +5 -0
- package/dist-package/packages/runtime/src/verification/verification.js +81 -4
- package/dist-package/packages/testkit/src/fixture-analyzers.js +1 -0
- package/dist-package/packages/testkit/src/in-memory-editor.js +126 -0
- package/package.json +8 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
2
3
|
import { z } from "zod";
|
|
3
|
-
import { resolveEditingIntent, withCapabilityFamilies, } from "../../../packages/runtime/src/index.js";
|
|
4
|
+
import { createCapabilityPreflight, resolveEditingIntent, withCapabilityFamilies, } from "../../../packages/runtime/src/index.js";
|
|
4
5
|
import { EDITOR_FIRST_MCP_INSTRUCTIONS, resolveEditingRoute, } from "./routing.js";
|
|
6
|
+
import { FRAMEKIT_VERSION } from "./version.js";
|
|
5
7
|
const revisionValueSchema = z.object({
|
|
6
8
|
id: z.string(),
|
|
7
9
|
sequence: z.number().int().nonnegative(),
|
|
@@ -15,6 +17,9 @@ const rationalTimeSchema = z.object({
|
|
|
15
17
|
const rangeSchema = z.object({
|
|
16
18
|
start: z.number().nonnegative(),
|
|
17
19
|
end: z.number().positive(),
|
|
20
|
+
}).refine((range) => range.end > range.start, {
|
|
21
|
+
message: "end must be greater than start",
|
|
22
|
+
path: ["end"],
|
|
18
23
|
});
|
|
19
24
|
const mediaIndexQuerySchema = z.object({
|
|
20
25
|
query: z.string().optional(),
|
|
@@ -57,6 +62,39 @@ const markerSchema = z.object({
|
|
|
57
62
|
duration: z.number().nonnegative(),
|
|
58
63
|
name: z.string().min(1),
|
|
59
64
|
});
|
|
65
|
+
const maskBoundsSchema = z.object({
|
|
66
|
+
x: z.number().finite().min(0).max(1),
|
|
67
|
+
y: z.number().finite().min(0).max(1),
|
|
68
|
+
width: z.number().finite().positive().max(1),
|
|
69
|
+
height: z.number().finite().positive().max(1),
|
|
70
|
+
}).strict().superRefine((bounds, context) => {
|
|
71
|
+
if (bounds.x + bounds.width > 1) {
|
|
72
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["width"], message: "x plus width must fit within the frame" });
|
|
73
|
+
}
|
|
74
|
+
if (bounds.y + bounds.height > 1) {
|
|
75
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["height"], message: "y plus height must fit within the frame" });
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const maskSchema = z.discriminatedUnion("mode", [
|
|
79
|
+
z.object({
|
|
80
|
+
mode: z.literal("rectangle"),
|
|
81
|
+
bounds: maskBoundsSchema,
|
|
82
|
+
inverted: z.boolean().optional(),
|
|
83
|
+
}).strict(),
|
|
84
|
+
z.object({
|
|
85
|
+
mode: z.literal("supplied-alpha"),
|
|
86
|
+
alphaMediaId: z.string().trim().min(1),
|
|
87
|
+
bounds: maskBoundsSchema.optional(),
|
|
88
|
+
inverted: z.boolean().optional(),
|
|
89
|
+
}).strict(),
|
|
90
|
+
z.object({
|
|
91
|
+
mode: z.literal("person-cutout"),
|
|
92
|
+
}).strict(),
|
|
93
|
+
]);
|
|
94
|
+
const nativeMaskSchema = z.object({
|
|
95
|
+
mode: z.literal("rectangle"),
|
|
96
|
+
bounds: maskBoundsSchema,
|
|
97
|
+
}).strict();
|
|
60
98
|
const renameClipSchema = z.object({ type: z.literal("rename-clip"), clipId: z.string().min(1), name: z.string().min(1), baseRevision: revisionSchema });
|
|
61
99
|
const trimClipSchema = z.object({
|
|
62
100
|
type: z.literal("trim-clip"),
|
|
@@ -193,31 +231,68 @@ const verificationPolicySchema = z.object({
|
|
|
193
231
|
loudnessToleranceDb: z.number().finite().nonnegative().optional(),
|
|
194
232
|
assertions: z.array(verificationAssertionSchema).optional(),
|
|
195
233
|
}).strict();
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}).strict()
|
|
212
|
-
|
|
234
|
+
function mcpObjectSchema(schema) {
|
|
235
|
+
// The MCP SDK only serializes schemas it recognizes as object-shaped.
|
|
236
|
+
Object.defineProperty(schema, "shape", { value: {}, enumerable: false });
|
|
237
|
+
return schema;
|
|
238
|
+
}
|
|
239
|
+
function mcpDiscriminatedUnion(options) {
|
|
240
|
+
const schema = z.discriminatedUnion("type", options);
|
|
241
|
+
return mcpObjectSchema(schema);
|
|
242
|
+
}
|
|
243
|
+
function mcpUnion(options) {
|
|
244
|
+
const schema = z.union(options);
|
|
245
|
+
return mcpObjectSchema(schema);
|
|
246
|
+
}
|
|
247
|
+
function createEditToolInputSchema(target = {}, baseRevision = revisionSchema) {
|
|
248
|
+
const options = [
|
|
249
|
+
renameClipSchema.extend({ ...target, verification: verificationPolicySchema.optional(), baseRevision }).strict(),
|
|
250
|
+
trimClipSchema.extend({ ...target, verification: verificationPolicySchema.optional(), baseRevision }).strict(),
|
|
251
|
+
setGainSchema.extend({ ...target, verification: verificationPolicySchema.optional(), baseRevision }).strict(),
|
|
252
|
+
reduceNoiseSchema.extend({ ...target, verification: verificationPolicySchema.optional(), baseRevision }).strict(),
|
|
253
|
+
colorCorrectionSchema.extend({ ...target, verification: verificationPolicySchema.optional(), baseRevision }).strict(),
|
|
254
|
+
rippleDeleteSchema.extend({ ...target, verification: verificationPolicySchema.optional(), baseRevision }).strict(),
|
|
255
|
+
addMarkerSchema.extend({ ...target, verification: verificationPolicySchema.optional(), baseRevision }).strict(),
|
|
256
|
+
];
|
|
257
|
+
return mcpDiscriminatedUnion(options);
|
|
258
|
+
}
|
|
259
|
+
const editToolInputSchema = createEditToolInputSchema();
|
|
260
|
+
const artifactEditToolInputSchema = createEditToolInputSchema({
|
|
213
261
|
artifactPath: z.string().trim().min(1),
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const editorTimelineEditToolInputSchema = editToolInputSchema.extend({
|
|
262
|
+
}, revisionValueSchema);
|
|
263
|
+
const editorTimelineEditToolInputSchema = createEditToolInputSchema({
|
|
217
264
|
projectId: z.string().trim().min(1),
|
|
218
265
|
sequenceId: z.string().trim().min(1),
|
|
219
|
-
|
|
220
|
-
|
|
266
|
+
}, revisionValueSchema);
|
|
267
|
+
function exposeObjectRoot(schema) {
|
|
268
|
+
if (!isRecord(schema) || !Array.isArray(schema.anyOf))
|
|
269
|
+
return schema;
|
|
270
|
+
const properties = {};
|
|
271
|
+
for (const branch of schema.anyOf) {
|
|
272
|
+
for (const [key, value] of Object.entries(branch.properties ?? {})) {
|
|
273
|
+
if (key !== "type")
|
|
274
|
+
properties[key] = value;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return { ...schema, type: "object", properties };
|
|
278
|
+
}
|
|
279
|
+
function installMcpSchemaCompatibility(server) {
|
|
280
|
+
const handlers = server.server._requestHandlers;
|
|
281
|
+
const listToolsHandler = handlers?.get("tools/list");
|
|
282
|
+
if (!listToolsHandler)
|
|
283
|
+
throw new Error("MCP tools/list handler was not initialized");
|
|
284
|
+
server.server.removeRequestHandler("tools/list");
|
|
285
|
+
server.server.setRequestHandler(ListToolsRequestSchema, async (request, extra) => {
|
|
286
|
+
const response = await listToolsHandler(request, extra);
|
|
287
|
+
return {
|
|
288
|
+
...response,
|
|
289
|
+
tools: response.tools?.map((tool) => ({
|
|
290
|
+
...tool,
|
|
291
|
+
inputSchema: exposeObjectRoot(tool.inputSchema),
|
|
292
|
+
})) ?? [],
|
|
293
|
+
};
|
|
294
|
+
});
|
|
295
|
+
}
|
|
221
296
|
const artifactPublishInputSchema = z.object({
|
|
222
297
|
artifactPath: z.string().trim().min(1),
|
|
223
298
|
transactionId: z.string().min(1),
|
|
@@ -248,6 +323,28 @@ const workflowOperationSchema = z.discriminatedUnion("type", [
|
|
|
248
323
|
duration: z.number().positive(),
|
|
249
324
|
targetLane: z.union([z.literal("primary"), z.number().int()]).optional(),
|
|
250
325
|
}),
|
|
326
|
+
z.object({
|
|
327
|
+
type: z.literal("timeline.picture-in-picture.add"),
|
|
328
|
+
occurrenceId: z.string().min(1),
|
|
329
|
+
mediaId: z.string().min(1),
|
|
330
|
+
attachedTo: z.string().min(1),
|
|
331
|
+
start: z.number().finite().nonnegative(),
|
|
332
|
+
duration: z.number().finite().positive(),
|
|
333
|
+
targetLane: z.number().int().refine((lane) => lane !== 0, "PIP requires a connected non-primary lane"),
|
|
334
|
+
position: z.object({ x: z.number().finite(), y: z.number().finite() }),
|
|
335
|
+
scale: z.number().finite().positive(),
|
|
336
|
+
crop: z.object({
|
|
337
|
+
top: z.number().finite().min(0).lt(1),
|
|
338
|
+
right: z.number().finite().min(0).lt(1),
|
|
339
|
+
bottom: z.number().finite().min(0).lt(1),
|
|
340
|
+
left: z.number().finite().min(0).lt(1),
|
|
341
|
+
}).optional(),
|
|
342
|
+
frame: z.object({
|
|
343
|
+
style: z.literal("solid"),
|
|
344
|
+
color: z.string().regex(/^#[0-9a-f]{6}$/i),
|
|
345
|
+
width: z.number().finite().nonnegative(),
|
|
346
|
+
}).optional(),
|
|
347
|
+
}),
|
|
251
348
|
z.object({
|
|
252
349
|
type: z.literal("timeline.audio.fades"),
|
|
253
350
|
clipId: z.string().min(1),
|
|
@@ -302,6 +399,11 @@ const workflowOperationSchema = z.discriminatedUnion("type", [
|
|
|
302
399
|
fadeIn: z.number().nonnegative().optional(),
|
|
303
400
|
fadeOut: z.number().nonnegative().optional(),
|
|
304
401
|
}),
|
|
402
|
+
z.object({
|
|
403
|
+
type: z.literal("timeline.mask.add"),
|
|
404
|
+
occurrenceId: z.string().min(1),
|
|
405
|
+
mask: maskSchema,
|
|
406
|
+
}),
|
|
305
407
|
]);
|
|
306
408
|
const workflowOperationsSchema = z.array(workflowOperationSchema).min(1).superRefine((operations, context) => {
|
|
307
409
|
operations.forEach((operation, index) => {
|
|
@@ -317,6 +419,11 @@ const workflowOperationsSchema = z.array(workflowOperationSchema).min(1).superRe
|
|
|
317
419
|
&& (typeof operation.targetLane !== "number" || operation.targetLane === 0)) {
|
|
318
420
|
context.addIssue({ code: z.ZodIssueCode.custom, path: [index, "targetLane"], message: "audio requires an explicit non-primary lane" });
|
|
319
421
|
}
|
|
422
|
+
if (operation.type === "timeline.picture-in-picture.add"
|
|
423
|
+
&& operation.crop
|
|
424
|
+
&& (operation.crop.left + operation.crop.right >= 1 || operation.crop.top + operation.crop.bottom >= 1)) {
|
|
425
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: [index, "crop"], message: "PIP crop must leave a positive source rectangle" });
|
|
426
|
+
}
|
|
320
427
|
if (operation.type === "timeline.audio.mix"
|
|
321
428
|
&& operation.gainDb === undefined && operation.fadeIn === undefined && operation.fadeOut === undefined) {
|
|
322
429
|
context.addIssue({ code: z.ZodIssueCode.custom, path: [index], message: "audio mix requires a gain or fade change" });
|
|
@@ -334,13 +441,9 @@ const musicDuckingSchema = z.object({
|
|
|
334
441
|
dialogueClipIds: z.array(z.string().min(1)).optional(),
|
|
335
442
|
reductionDb: z.number().finite().optional(),
|
|
336
443
|
});
|
|
337
|
-
const
|
|
444
|
+
const musicAddCommonInputSchema = {
|
|
338
445
|
baseRevision: revisionValueSchema,
|
|
339
446
|
occurrenceId: z.string().min(1),
|
|
340
|
-
mediaId: z.string().min(1).optional(),
|
|
341
|
-
import: musicImportSchema.optional(),
|
|
342
|
-
placement: z.enum(["append", "insert"]),
|
|
343
|
-
start: z.number().nonnegative().optional(),
|
|
344
447
|
duration: z.number().positive().optional(),
|
|
345
448
|
targetLane: z.number().int().refine((lane) => lane !== 0, "music requires a non-primary lane"),
|
|
346
449
|
gainDb: z.number().finite().optional(),
|
|
@@ -349,6 +452,30 @@ const musicAddInputSchema = {
|
|
|
349
452
|
ducking: musicDuckingSchema.optional(),
|
|
350
453
|
verification: verificationPolicySchema.optional(),
|
|
351
454
|
};
|
|
455
|
+
const musicAddInputSchema = mcpUnion([
|
|
456
|
+
z.object({
|
|
457
|
+
...musicAddCommonInputSchema,
|
|
458
|
+
mediaId: z.string().min(1),
|
|
459
|
+
placement: z.literal("append"),
|
|
460
|
+
}).strict(),
|
|
461
|
+
z.object({
|
|
462
|
+
...musicAddCommonInputSchema,
|
|
463
|
+
import: musicImportSchema,
|
|
464
|
+
placement: z.literal("append"),
|
|
465
|
+
}).strict(),
|
|
466
|
+
z.object({
|
|
467
|
+
...musicAddCommonInputSchema,
|
|
468
|
+
mediaId: z.string().min(1),
|
|
469
|
+
placement: z.literal("insert"),
|
|
470
|
+
start: z.number().nonnegative(),
|
|
471
|
+
}).strict(),
|
|
472
|
+
z.object({
|
|
473
|
+
...musicAddCommonInputSchema,
|
|
474
|
+
import: musicImportSchema,
|
|
475
|
+
placement: z.literal("insert"),
|
|
476
|
+
start: z.number().nonnegative(),
|
|
477
|
+
}).strict(),
|
|
478
|
+
]);
|
|
352
479
|
const fillerRemovalInputSchema = {
|
|
353
480
|
baseRevision: revisionValueSchema,
|
|
354
481
|
range: rangeSchema,
|
|
@@ -408,6 +535,37 @@ const nativeTransitionPreviewSchema = {
|
|
|
408
535
|
afterOccurrenceHandle: z.string().min(1),
|
|
409
536
|
duration: rationalTimeSchema,
|
|
410
537
|
};
|
|
538
|
+
const nativePictureInPicturePreviewSchema = {
|
|
539
|
+
mediaHandle: z.string().min(1),
|
|
540
|
+
anchorOccurrenceHandle: z.string().min(1),
|
|
541
|
+
start: rationalTimeSchema,
|
|
542
|
+
duration: rationalTimeSchema,
|
|
543
|
+
position: z.object({ x: z.number().finite(), y: z.number().finite() }),
|
|
544
|
+
scale: z.number().finite().positive(),
|
|
545
|
+
crop: z.object({
|
|
546
|
+
top: z.number().finite().min(0).lt(1),
|
|
547
|
+
right: z.number().finite().min(0).lt(1),
|
|
548
|
+
bottom: z.number().finite().min(0).lt(1),
|
|
549
|
+
left: z.number().finite().min(0).lt(1),
|
|
550
|
+
}).optional(),
|
|
551
|
+
frame: z.object({
|
|
552
|
+
style: z.literal("solid"),
|
|
553
|
+
color: z.string().regex(/^#[0-9a-f]{6}$/i),
|
|
554
|
+
width: z.number().finite().nonnegative(),
|
|
555
|
+
}).optional(),
|
|
556
|
+
};
|
|
557
|
+
const nativeMaskPreviewSchema = {
|
|
558
|
+
occurrenceHandle: z.string().trim().min(1),
|
|
559
|
+
mask: nativeMaskSchema,
|
|
560
|
+
};
|
|
561
|
+
const timelineMaskInputSchema = {
|
|
562
|
+
projectId: z.string().trim().min(1),
|
|
563
|
+
sequenceId: z.string().trim().min(1),
|
|
564
|
+
baseRevision: revisionValueSchema,
|
|
565
|
+
occurrenceId: z.string().trim().min(1),
|
|
566
|
+
mask: maskSchema,
|
|
567
|
+
verification: verificationPolicySchema.optional(),
|
|
568
|
+
};
|
|
411
569
|
const exportAssertionSchema = z.discriminatedUnion("type", [
|
|
412
570
|
z.object({
|
|
413
571
|
type: z.literal("audio-audibility"),
|
|
@@ -539,7 +697,7 @@ function frameResult(value) {
|
|
|
539
697
|
}
|
|
540
698
|
export function createMcpServer(runtime, options = {}) {
|
|
541
699
|
runtime.registerBuiltinSkills();
|
|
542
|
-
const server = new McpServer({ name: "framekit", version:
|
|
700
|
+
const server = new McpServer({ name: "framekit", version: FRAMEKIT_VERSION }, { instructions: EDITOR_FIRST_MCP_INSTRUCTIONS });
|
|
543
701
|
const nativeTransitionAssets = new Map();
|
|
544
702
|
server.registerTool("connection.status", {
|
|
545
703
|
description: "Read Framekit's Final Cut connection state before editor-first capability discovery.",
|
|
@@ -649,7 +807,9 @@ export function createMcpServer(runtime, options = {}) {
|
|
|
649
807
|
inputSchema: {
|
|
650
808
|
operation: z.enum([
|
|
651
809
|
"timeline.edit",
|
|
810
|
+
"timeline.mask.add",
|
|
652
811
|
"editor.native.edit",
|
|
812
|
+
"editor.native.picture-in-picture",
|
|
653
813
|
"timeline.publish.new-project",
|
|
654
814
|
"timeline.export",
|
|
655
815
|
]),
|
|
@@ -733,6 +893,24 @@ export function createMcpServer(runtime, options = {}) {
|
|
|
733
893
|
throw new Error("CAPABILITY_UNAVAILABLE: Final Cut native title placement is not configured");
|
|
734
894
|
return jsonResult(await options.nativeEditor.executeTitleAdd(previewToken));
|
|
735
895
|
});
|
|
896
|
+
server.registerTool("editor.native.picture-in-picture.preview", {
|
|
897
|
+
description: "Preview connecting selected Final Cut Browser video to a stable timeline occurrence with verified transform properties.",
|
|
898
|
+
inputSchema: nativePictureInPicturePreviewSchema,
|
|
899
|
+
}, async (request) => {
|
|
900
|
+
if (!options.nativeEditor)
|
|
901
|
+
throw new Error("CAPABILITY_UNAVAILABLE: Final Cut native picture-in-picture placement is not configured");
|
|
902
|
+
await requireEditingRoute(runtime, options, "editor.native.picture-in-picture");
|
|
903
|
+
return jsonResult(await options.nativeEditor.previewPictureInPicture(request));
|
|
904
|
+
});
|
|
905
|
+
server.registerTool("editor.native.picture-in-picture.execute", {
|
|
906
|
+
description: "Execute a native Final Cut picture-in-picture preview and return transform readback, revision, and Undo verification.",
|
|
907
|
+
inputSchema: { previewToken: z.string().min(1) },
|
|
908
|
+
}, async ({ previewToken }) => {
|
|
909
|
+
if (!options.nativeEditor)
|
|
910
|
+
throw new Error("CAPABILITY_UNAVAILABLE: Final Cut native picture-in-picture placement is not configured");
|
|
911
|
+
await requireEditingRoute(runtime, options, "editor.native.picture-in-picture");
|
|
912
|
+
return jsonResult(await options.nativeEditor.executePictureInPicture(previewToken));
|
|
913
|
+
});
|
|
736
914
|
server.registerTool("editor.native.transition.search", {
|
|
737
915
|
description: "Search the visible Final Cut Transitions browser and return only transitions with stable native identities.",
|
|
738
916
|
inputSchema: { query: z.string().trim().min(1) },
|
|
@@ -768,6 +946,22 @@ export function createMcpServer(runtime, options = {}) {
|
|
|
768
946
|
throw new Error("CAPABILITY_UNAVAILABLE: Final Cut native transition placement is not configured");
|
|
769
947
|
return jsonResult(await options.nativeEditor.executeTransitionAdd(previewToken));
|
|
770
948
|
});
|
|
949
|
+
server.registerTool("editor.native.mask.preview", {
|
|
950
|
+
description: "Preview adding a bounded native Final Cut Draw Mask to one located occurrence without mutating the timeline.",
|
|
951
|
+
inputSchema: nativeMaskPreviewSchema,
|
|
952
|
+
}, async ({ occurrenceHandle, mask }) => {
|
|
953
|
+
if (!options.nativeEditor)
|
|
954
|
+
throw new Error("CAPABILITY_UNAVAILABLE: Final Cut native masking is not configured");
|
|
955
|
+
return jsonResult(await options.nativeEditor.previewMask({ occurrenceHandle, mask }));
|
|
956
|
+
});
|
|
957
|
+
server.registerTool("editor.native.mask.execute", {
|
|
958
|
+
description: "Execute a previously previewed native Draw Mask and return readback verification and native Undo state.",
|
|
959
|
+
inputSchema: { previewToken: z.string().trim().min(1) },
|
|
960
|
+
}, async ({ previewToken }) => {
|
|
961
|
+
if (!options.nativeEditor)
|
|
962
|
+
throw new Error("CAPABILITY_UNAVAILABLE: Final Cut native masking is not configured");
|
|
963
|
+
return jsonResult(await options.nativeEditor.executeMask(previewToken));
|
|
964
|
+
});
|
|
771
965
|
server.registerTool("editor.native.undo", {
|
|
772
966
|
description: "Undo a previously accepted native Final Cut UI edit using Final Cut's native Undo command.",
|
|
773
967
|
inputSchema: { operationId: z.string().min(1) },
|
|
@@ -1149,6 +1343,17 @@ export function createMcpServer(runtime, options = {}) {
|
|
|
1149
1343
|
await requireEditingRoute(runtime, options, "timeline.edit");
|
|
1150
1344
|
return jsonResult(await runtime.previewEdit(request));
|
|
1151
1345
|
});
|
|
1346
|
+
server.registerTool("timeline.mask.add.preview", {
|
|
1347
|
+
description: "Preview a bounded or supplied-alpha mask against an explicit project, sequence, revision, and occurrence without mutation.",
|
|
1348
|
+
inputSchema: timelineMaskInputSchema,
|
|
1349
|
+
}, async ({ projectId, sequenceId, baseRevision, occurrenceId, mask, verification }) => {
|
|
1350
|
+
await requireEditingRoute(runtime, options, "timeline.mask.add");
|
|
1351
|
+
return jsonResult(await runtime.previewTimelineEdit({ projectId, sequenceId }, {
|
|
1352
|
+
baseRevision,
|
|
1353
|
+
operations: [{ type: "timeline.mask.add", occurrenceId, mask }],
|
|
1354
|
+
...(verification ? { verification } : {}),
|
|
1355
|
+
}));
|
|
1356
|
+
});
|
|
1152
1357
|
server.registerTool("artifact.edit.preview", {
|
|
1153
1358
|
description: "Validate and preview an ordered artifact edit against the identified FCPXML artifact without mutating it.",
|
|
1154
1359
|
inputSchema: {
|
|
@@ -1183,10 +1388,17 @@ export function createMcpServer(runtime, options = {}) {
|
|
|
1183
1388
|
await requireEditingRoute(runtime, options, "timeline.edit");
|
|
1184
1389
|
return jsonResult(await runtime.executeEdit(previewToken));
|
|
1185
1390
|
});
|
|
1391
|
+
server.registerTool("timeline.mask.add.execute", {
|
|
1392
|
+
description: "Execute one short-lived mask preview token after capability and revision checks, then verify the mask state.",
|
|
1393
|
+
inputSchema: { previewToken: z.string().trim().min(1) },
|
|
1394
|
+
}, async ({ previewToken }) => {
|
|
1395
|
+
await requireEditingRoute(runtime, options, "timeline.mask.add");
|
|
1396
|
+
return jsonResult(await runtime.executeEdit(previewToken));
|
|
1397
|
+
});
|
|
1186
1398
|
server.registerTool("speech.analyze", {
|
|
1187
|
-
description: "Analyze speech words
|
|
1188
|
-
inputSchema: { mediaId: z.string().min(1) },
|
|
1189
|
-
}, async ({ mediaId }) => jsonResult(await runtime.analyzeSpeech(mediaId)));
|
|
1399
|
+
description: "Analyze speech words, filler markers, and optional VAD for one media item or source range.",
|
|
1400
|
+
inputSchema: { mediaId: z.string().min(1), range: rangeSchema.optional() },
|
|
1401
|
+
}, async ({ mediaId, range }) => jsonResult(await runtime.analyzeSpeech(mediaId, range)));
|
|
1190
1402
|
server.registerTool("speech.filler.remove.preview", {
|
|
1191
1403
|
description: "Analyze a selected canonical timeline range and preview removal of high-confidence filler words with safe rational delete ranges.",
|
|
1192
1404
|
inputSchema: fillerRemovalInputSchema,
|
|
@@ -1245,6 +1457,7 @@ export function createMcpServer(runtime, options = {}) {
|
|
|
1245
1457
|
description: "Restore the pre-edit snapshot for a completed transaction.",
|
|
1246
1458
|
inputSchema: { transactionId: z.string().min(1) },
|
|
1247
1459
|
}, async ({ transactionId }) => jsonResult(await runtime.undo(transactionId)));
|
|
1460
|
+
installMcpSchemaCompatibility(server);
|
|
1248
1461
|
return server;
|
|
1249
1462
|
}
|
|
1250
1463
|
async function resolveNativeTitleAsset(runtime, assetId) {
|
|
@@ -1299,44 +1512,52 @@ async function inspectMcpEditor(runtime, options) {
|
|
|
1299
1512
|
const native = options.nativeEditor?.capabilities();
|
|
1300
1513
|
const publishingAvailable = Boolean(options.projectPublisher && (typeof options.projectPublisher.isAvailable !== "function" || options.projectPublisher.isAvailable()));
|
|
1301
1514
|
const exportAvailable = Boolean(options.videoExporter?.isAvailable());
|
|
1515
|
+
const capabilities = withCapabilityFamilies({
|
|
1516
|
+
...inspected.capabilities,
|
|
1517
|
+
editor: {
|
|
1518
|
+
...inspected.capabilities.editor,
|
|
1519
|
+
artifactPublish: publishingAvailable,
|
|
1520
|
+
...(publishingAvailable ? {} : { timelinePublishNewProject: false }),
|
|
1521
|
+
videoExport: exportAvailable,
|
|
1522
|
+
},
|
|
1523
|
+
}, {
|
|
1524
|
+
backend: inspected.identity.backend,
|
|
1525
|
+
nativeBackend: "final-cut-accessibility",
|
|
1526
|
+
native: {
|
|
1527
|
+
selectionWrite: Boolean(native?.selectionEdit),
|
|
1528
|
+
undo: Boolean(native?.undo),
|
|
1529
|
+
mediaLibrarySearch: Boolean(native?.mediaLibrarySearch),
|
|
1530
|
+
mediaImport: Boolean(native?.mediaImport),
|
|
1531
|
+
mediaSelection: Boolean(native?.mediaSelection),
|
|
1532
|
+
mediaAppendSelected: Boolean(native?.mediaAppendSelected),
|
|
1533
|
+
timelineOccurrenceLocate: Boolean(native?.timelineOccurrenceLocate),
|
|
1534
|
+
bladeAtPlayhead: Boolean(native?.bladeAtPlayhead),
|
|
1535
|
+
deleteRange: Boolean(native?.deleteRange),
|
|
1536
|
+
trimToDuration: Boolean(native?.trimToDuration),
|
|
1537
|
+
mediaAppend: Boolean(native?.mediaAppend),
|
|
1538
|
+
mediaInsert: Boolean(native?.mediaInsert),
|
|
1539
|
+
titlePlacement: Boolean(native?.titlePlacement),
|
|
1540
|
+
titleDiscovery: Boolean(native?.titleDiscovery),
|
|
1541
|
+
pictureInPicture: Boolean(native?.pictureInPicture),
|
|
1542
|
+
transitionDiscovery: Boolean(native?.transitionDiscovery),
|
|
1543
|
+
transitionPlacement: Boolean(native?.transitionPlacement),
|
|
1544
|
+
masking: Boolean(native?.masking),
|
|
1545
|
+
timelineFocus: Boolean(native?.timelineFocus),
|
|
1546
|
+
projectCreation: false,
|
|
1547
|
+
clipInsertion: false,
|
|
1548
|
+
clipMovement: false,
|
|
1549
|
+
},
|
|
1550
|
+
publishing: publishingAvailable,
|
|
1551
|
+
publishingBackend: "fcpxml-publisher",
|
|
1552
|
+
export: exportAvailable,
|
|
1553
|
+
exportBackend: "final-cut-native-export",
|
|
1554
|
+
});
|
|
1302
1555
|
return {
|
|
1303
1556
|
...inspected,
|
|
1304
|
-
capabilities
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
artifactPublish: publishingAvailable,
|
|
1309
|
-
...(publishingAvailable ? {} : { timelinePublishNewProject: false }),
|
|
1310
|
-
videoExport: exportAvailable,
|
|
1311
|
-
},
|
|
1312
|
-
}, {
|
|
1313
|
-
backend: inspected.identity.backend,
|
|
1314
|
-
nativeBackend: "final-cut-accessibility",
|
|
1315
|
-
native: {
|
|
1316
|
-
selectionWrite: Boolean(native?.selectionEdit),
|
|
1317
|
-
undo: Boolean(native?.undo),
|
|
1318
|
-
mediaLibrarySearch: Boolean(native?.mediaLibrarySearch),
|
|
1319
|
-
mediaImport: Boolean(native?.mediaImport),
|
|
1320
|
-
mediaSelection: Boolean(native?.mediaSelection),
|
|
1321
|
-
mediaAppendSelected: Boolean(native?.mediaAppendSelected),
|
|
1322
|
-
timelineOccurrenceLocate: Boolean(native?.timelineOccurrenceLocate),
|
|
1323
|
-
bladeAtPlayhead: Boolean(native?.bladeAtPlayhead),
|
|
1324
|
-
deleteRange: Boolean(native?.deleteRange),
|
|
1325
|
-
trimToDuration: Boolean(native?.trimToDuration),
|
|
1326
|
-
mediaAppend: Boolean(native?.mediaAppend),
|
|
1327
|
-
mediaInsert: Boolean(native?.mediaInsert),
|
|
1328
|
-
titlePlacement: Boolean(native?.titlePlacement),
|
|
1329
|
-
transitionDiscovery: Boolean(native?.transitionDiscovery),
|
|
1330
|
-
transitionPlacement: Boolean(native?.transitionPlacement),
|
|
1331
|
-
timelineFocus: Boolean(native?.timelineFocus),
|
|
1332
|
-
projectCreation: false,
|
|
1333
|
-
clipInsertion: false,
|
|
1334
|
-
clipMovement: false,
|
|
1335
|
-
},
|
|
1336
|
-
publishing: publishingAvailable,
|
|
1337
|
-
publishingBackend: "fcpxml-publisher",
|
|
1338
|
-
export: exportAvailable,
|
|
1339
|
-
exportBackend: "final-cut-native-export",
|
|
1557
|
+
capabilities,
|
|
1558
|
+
preflight: createCapabilityPreflight(inspected.identity, capabilities, {
|
|
1559
|
+
processMode: options.processMode ?? (native ? "headed" : "headless"),
|
|
1560
|
+
nativeWrite: Boolean(native?.selectionEdit),
|
|
1340
1561
|
}),
|
|
1341
1562
|
...(native ? { native } : {}),
|
|
1342
1563
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
const FRAMEKIT_PACKAGE_NAME = "@morshoto/framekit";
|
|
5
|
+
export const FRAMEKIT_VERSION = readFramekitVersion();
|
|
6
|
+
function readFramekitVersion() {
|
|
7
|
+
let directory = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
while (true) {
|
|
9
|
+
const manifestPath = join(directory, "package.json");
|
|
10
|
+
try {
|
|
11
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
12
|
+
if (manifest.name === FRAMEKIT_PACKAGE_NAME) {
|
|
13
|
+
if (typeof manifest.version !== "string" || manifest.version.length === 0) {
|
|
14
|
+
throw new Error(`FRAMEKIT_PACKAGE_VERSION_INVALID: ${manifestPath}`);
|
|
15
|
+
}
|
|
16
|
+
return manifest.version;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (!isMissingFile(error))
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
const parent = dirname(directory);
|
|
24
|
+
if (parent === directory)
|
|
25
|
+
break;
|
|
26
|
+
directory = parent;
|
|
27
|
+
}
|
|
28
|
+
throw new Error(`FRAMEKIT_PACKAGE_VERSION_UNAVAILABLE: ${FRAMEKIT_PACKAGE_NAME}`);
|
|
29
|
+
}
|
|
30
|
+
function isMissingFile(error) {
|
|
31
|
+
if (!error || typeof error !== "object" || !("code" in error))
|
|
32
|
+
return false;
|
|
33
|
+
return error.code === "ENOENT";
|
|
34
|
+
}
|