@morshoto/framekit 0.1.18 → 0.2.3
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 +17 -12
- package/dist-package/adapters/final-cut/typescript/src/analyzers.d.ts +58 -0
- package/dist-package/adapters/final-cut/typescript/src/analyzers.js +52 -13
- package/dist-package/adapters/final-cut/typescript/src/assets.d.ts +24 -0
- package/dist-package/adapters/final-cut/typescript/src/background-export.d.ts +98 -0
- package/dist-package/adapters/final-cut/typescript/src/background-materialization.d.ts +47 -0
- package/dist-package/adapters/final-cut/typescript/src/background-materialization.js +8 -2
- package/dist-package/adapters/final-cut/typescript/src/canonical-recovery-guard.d.ts +32 -0
- package/dist-package/adapters/final-cut/typescript/src/canonical-recovery-guard.js +275 -0
- package/dist-package/adapters/final-cut/typescript/src/canonical-recovery.d.ts +22 -0
- package/dist-package/adapters/final-cut/typescript/src/canonical-verification.d.ts +11 -0
- package/dist-package/adapters/final-cut/typescript/src/canonical.d.ts +184 -0
- package/dist-package/adapters/final-cut/typescript/src/canonical.js +571 -78
- package/dist-package/adapters/final-cut/typescript/src/connection.d.ts +103 -0
- package/dist-package/adapters/final-cut/typescript/src/connection.js +6 -1
- package/dist-package/adapters/final-cut/typescript/src/disposable-native.d.ts +90 -0
- package/dist-package/adapters/final-cut/typescript/src/disposable-native.js +6 -0
- package/dist-package/adapters/final-cut/typescript/src/documents.d.ts +3 -0
- package/dist-package/adapters/final-cut/typescript/src/documents.js +3 -0
- package/dist-package/adapters/final-cut/typescript/src/experimental.d.ts +8 -0
- package/dist-package/adapters/final-cut/typescript/src/experimental.js +8 -0
- package/dist-package/adapters/final-cut/typescript/src/export.d.ts +125 -0
- package/dist-package/adapters/final-cut/typescript/src/fcpxml-console-experiment.d.ts +54 -0
- package/dist-package/adapters/final-cut/typescript/src/fcpxml.d.ts +75 -0
- package/dist-package/adapters/final-cut/typescript/src/fcpxml.js +28 -9
- package/dist-package/adapters/final-cut/typescript/src/index.d.ts +22 -0
- package/dist-package/adapters/final-cut/typescript/src/index.js +1 -7
- package/dist-package/adapters/final-cut/typescript/src/library-inspection.d.ts +101 -0
- package/dist-package/adapters/final-cut/typescript/src/live.d.ts +101 -0
- package/dist-package/adapters/final-cut/typescript/src/live.js +35 -2
- package/dist-package/adapters/final-cut/typescript/src/media.d.ts +12 -0
- package/dist-package/adapters/final-cut/typescript/src/native-operation.d.ts +6 -0
- package/dist-package/adapters/final-cut/typescript/src/native-recovery-inspection.d.ts +77 -0
- package/dist-package/adapters/final-cut/typescript/src/native-recovery-inspection.js +175 -0
- package/dist-package/adapters/final-cut/typescript/src/native-session.d.ts +130 -0
- package/dist-package/adapters/final-cut/typescript/src/native-session.js +11 -6
- package/dist-package/adapters/final-cut/typescript/src/native.d.ts +828 -0
- package/dist-package/adapters/final-cut/typescript/src/native.js +475 -189
- package/dist-package/adapters/final-cut/typescript/src/pasteboard-snapshot.d.ts +114 -0
- package/dist-package/adapters/final-cut/typescript/src/publish-readback.d.ts +26 -0
- package/dist-package/adapters/final-cut/typescript/src/publish-readback.js +19 -2
- package/dist-package/adapters/final-cut/typescript/src/publisher.d.ts +215 -0
- package/dist-package/adapters/final-cut/typescript/src/publisher.js +255 -14
- package/dist-package/adapters/final-cut/typescript/src/session.d.ts +43 -0
- package/dist-package/adapters/final-cut/typescript/src/session.js +43 -13
- package/dist-package/adapters/final-cut/typescript/src/shadow-mutation.d.ts +51 -0
- package/dist-package/adapters/final-cut/typescript/src/sqlite-experiment.d.ts +156 -0
- package/dist-package/adapters/final-cut/typescript/src/sqlite-inspection.d.ts +134 -0
- package/dist-package/adapters/final-cut/typescript/src/sqlite-materialization.d.ts +110 -0
- package/dist-package/adapters/final-cut/typescript/src/sqlite-wal-observation.d.ts +132 -0
- package/dist-package/adapters/final-cut/typescript/src/timeline-ir-fcpxml.d.ts +61 -0
- package/dist-package/adapters/final-cut/typescript/src/timeline-ir-fcpxml.js +31 -5
- package/dist-package/adapters/final-cut/typescript/src/unattended-editing.d.ts +54 -0
- package/dist-package/adapters/headless/typescript/src/audio-output.d.ts +3 -0
- package/dist-package/adapters/headless/typescript/src/audio-output.js +3 -0
- package/dist-package/adapters/headless/typescript/src/ffmpeg-media-probe.d.ts +11 -0
- package/dist-package/adapters/headless/typescript/src/ffmpeg-media-probe.js +26 -2
- package/dist-package/adapters/headless/typescript/src/ffmpeg-renderer.d.ts +25 -0
- package/dist-package/adapters/headless/typescript/src/ffmpeg-renderer.js +37 -14
- package/dist-package/adapters/headless/typescript/src/ffmpeg-verifier.d.ts +15 -0
- package/dist-package/adapters/headless/typescript/src/ffmpeg-verifier.js +9 -4
- package/dist-package/adapters/headless/typescript/src/index.d.ts +3 -0
- package/dist-package/apps/cli/src/dev-doctor.d.ts +25 -0
- package/dist-package/apps/cli/src/dev-doctor.js +198 -0
- package/dist-package/apps/cli/src/headless-projects.d.ts +3 -0
- package/dist-package/apps/cli/src/headless-projects.js +5 -0
- package/dist-package/apps/cli/src/main.d.ts +10 -0
- package/dist-package/apps/cli/src/main.js +42 -0
- package/dist-package/apps/mcp-server/runtime/ffmpeg-audio-backend.py +129 -0
- package/dist-package/apps/mcp-server/runtime/speech-analyzer-wrapper.mjs +54 -0
- package/dist-package/apps/mcp-server/runtime/whisper-speech-backend.py +271 -0
- package/dist-package/apps/mcp-server/src/build-alignment.d.ts +10 -0
- package/dist-package/apps/mcp-server/src/build-identity.d.ts +7 -0
- package/dist-package/apps/mcp-server/src/build-identity.json +2 -2
- package/dist-package/apps/mcp-server/src/canonical-native-snapshot.d.ts +8 -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.d.ts +5 -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.d.ts +3 -0
- package/dist-package/apps/mcp-server/src/headless-sessions.d.ts +89 -0
- package/dist-package/apps/mcp-server/src/main.d.ts +1 -0
- package/dist-package/apps/mcp-server/src/main.js +24 -19
- package/dist-package/apps/mcp-server/src/materialization-jobs.d.ts +204 -0
- package/dist-package/apps/mcp-server/src/materialization-jobs.js +143 -10
- package/dist-package/apps/mcp-server/src/readback-policy.d.ts +18 -0
- package/dist-package/apps/mcp-server/src/routing.d.ts +90 -0
- package/dist-package/apps/mcp-server/src/routing.js +2 -0
- package/dist-package/apps/mcp-server/src/server.d.ts +75 -0
- package/dist-package/apps/mcp-server/src/server.js +813 -158
- package/dist-package/apps/mcp-server/src/tools/skills/catalog.d.ts +19 -0
- package/dist-package/apps/mcp-server/src/tools/skills/catalog.js +142 -0
- package/dist-package/apps/mcp-server/src/tools/skills/metadata.d.ts +37 -0
- package/dist-package/apps/mcp-server/src/tools/skills/metadata.js +71 -0
- package/dist-package/apps/mcp-server/src/tools/skills/register.d.ts +11 -0
- package/dist-package/apps/mcp-server/src/tools/skills/register.js +101 -0
- package/dist-package/apps/mcp-server/src/version.d.ts +4 -0
- package/dist-package/packages/headless-application/src/external-edit.d.ts +30 -0
- package/dist-package/packages/headless-application/src/external-edit.js +72 -0
- package/dist-package/packages/headless-application/src/headless-projects.d.ts +233 -0
- package/dist-package/{apps/mcp-server → packages/headless-application}/src/headless-projects.js +392 -59
- package/dist-package/packages/headless-application/src/index.d.ts +2 -0
- package/dist-package/packages/headless-application/src/index.js +2 -0
- package/dist-package/packages/runtime/src/application/duration-policy-service.d.ts +4 -0
- package/dist-package/packages/runtime/src/application/local-media.d.ts +46 -0
- package/dist-package/packages/runtime/src/application/media-analysis-service.d.ts +40 -0
- package/dist-package/packages/runtime/src/application/media-analysis-service.js +105 -15
- package/dist-package/packages/runtime/src/application/project-service.d.ts +35 -0
- package/dist-package/packages/runtime/src/application/project-service.js +5 -1
- package/dist-package/packages/runtime/src/application/project-store.d.ts +56 -0
- package/dist-package/packages/runtime/src/application/project-store.js +13 -36
- package/dist-package/packages/runtime/src/application/project-transactions.d.ts +51 -0
- package/dist-package/packages/runtime/src/application/runtime-options.d.ts +15 -0
- package/dist-package/packages/runtime/src/application/semantic-media-index-store.d.ts +28 -0
- package/dist-package/packages/runtime/src/application/transaction-store.d.ts +10 -0
- package/dist-package/packages/runtime/src/application/transaction-store.js +1 -1
- package/dist-package/packages/runtime/src/audio/analysis.d.ts +3 -0
- package/dist-package/packages/runtime/src/audio/analysis.js +95 -0
- package/dist-package/packages/runtime/src/audio/dialogue-normalization.d.ts +47 -0
- package/dist-package/packages/runtime/src/audio/noise-reduction.d.ts +34 -0
- package/dist-package/packages/runtime/src/capabilities.d.ts +45 -0
- package/dist-package/packages/runtime/src/capabilities.js +1 -1
- package/dist-package/packages/runtime/src/color-correction.d.ts +33 -0
- package/dist-package/packages/runtime/src/context/context-engine.d.ts +28 -0
- package/dist-package/packages/runtime/src/context/context-engine.js +22 -16
- package/dist-package/packages/runtime/src/context/context-service.d.ts +20 -0
- package/dist-package/packages/runtime/src/context/context-service.js +2 -2
- package/dist-package/packages/runtime/src/context/project-catalog.d.ts +12 -0
- package/dist-package/packages/runtime/src/context/revision.d.ts +2 -0
- package/dist-package/packages/runtime/src/domain/capabilities.d.ts +170 -0
- package/dist-package/packages/runtime/src/domain/context.d.ts +179 -0
- package/dist-package/packages/runtime/src/domain/diff.d.ts +104 -0
- package/dist-package/packages/runtime/src/domain/duration.d.ts +63 -0
- package/dist-package/packages/runtime/src/domain/editing.d.ts +227 -0
- package/dist-package/packages/runtime/src/domain/incremental-sync.d.ts +67 -0
- package/dist-package/packages/runtime/src/domain/index.d.ts +14 -0
- package/dist-package/packages/runtime/src/domain/media.d.ts +406 -0
- package/dist-package/packages/runtime/src/domain/ports.d.ts +62 -0
- package/dist-package/packages/runtime/src/domain/primitives.d.ts +21 -0
- package/dist-package/packages/runtime/src/domain/project.d.ts +119 -0
- package/dist-package/packages/runtime/src/domain/rough-cut.d.ts +27 -0
- package/dist-package/packages/runtime/src/domain/skills.d.ts +145 -0
- package/dist-package/packages/runtime/src/domain/timeline-target.d.ts +57 -0
- package/dist-package/packages/runtime/src/domain/timeline-target.js +19 -1
- package/dist-package/packages/runtime/src/domain/types.d.ts +5 -0
- package/dist-package/packages/runtime/src/domain/verification.d.ts +92 -0
- package/dist-package/packages/runtime/src/editing/dialogue-normalization-service.d.ts +18 -0
- package/dist-package/packages/runtime/src/editing/duration-policy.d.ts +3 -0
- package/dist-package/packages/runtime/src/editing/edit-service.d.ts +44 -0
- package/dist-package/packages/runtime/src/editing/edit-service.js +76 -10
- package/dist-package/packages/runtime/src/editing/filler-removal-service.d.ts +23 -0
- package/dist-package/packages/runtime/src/editing/intent.d.ts +97 -0
- package/dist-package/packages/runtime/src/editing/music-service.d.ts +9 -0
- package/dist-package/packages/runtime/src/index.d.ts +32 -0
- package/dist-package/packages/runtime/src/index.js +2 -0
- package/dist-package/packages/runtime/src/planning/rough-cut.d.ts +3 -0
- package/dist-package/packages/runtime/src/render/render-and-verify.d.ts +71 -0
- package/dist-package/packages/runtime/src/render/render-contract.d.ts +96 -0
- package/dist-package/packages/runtime/src/runtime.d.ts +85 -0
- package/dist-package/packages/runtime/src/runtime.js +16 -7
- package/dist-package/packages/runtime/src/skills/builtin.d.ts +2 -0
- package/dist-package/packages/runtime/src/skills/index.d.ts +3 -0
- package/dist-package/packages/runtime/src/skills/registry.d.ts +10 -0
- package/dist-package/packages/runtime/src/skills/requirements.d.ts +38 -0
- package/dist-package/packages/runtime/src/skills/runtime.d.ts +38 -0
- package/dist-package/packages/runtime/src/speech/analysis.d.ts +18 -0
- package/dist-package/packages/runtime/src/speech/analysis.js +67 -0
- package/dist-package/packages/runtime/src/speech/filler-detector.d.ts +49 -0
- package/dist-package/packages/runtime/src/speech/filler-removal.d.ts +37 -0
- package/dist-package/packages/runtime/src/speech/mapping.d.ts +56 -0
- package/dist-package/packages/runtime/src/speech/mapping.js +27 -4
- package/dist-package/packages/runtime/src/speech/safe-cut-resolver.d.ts +52 -0
- package/dist-package/packages/runtime/src/timeline/drift-reconciliation.d.ts +42 -0
- package/dist-package/packages/runtime/src/timeline/editing-session.d.ts +271 -0
- package/dist-package/packages/runtime/src/timeline/editing-session.js +48 -2
- package/dist-package/packages/runtime/src/timeline/fast-observation.d.ts +77 -0
- package/dist-package/packages/runtime/src/timeline/rational-time.d.ts +11 -0
- package/dist-package/packages/runtime/src/timeline/reorder-preview.d.ts +32 -0
- package/dist-package/packages/runtime/src/timeline/reorder-preview.js +202 -0
- package/dist-package/packages/runtime/src/timeline/snapshot-diff.d.ts +3 -0
- package/dist-package/packages/runtime/src/timeline/snapshot-diff.js +1 -0
- package/dist-package/packages/runtime/src/timeline/snapshot-digest.d.ts +3 -0
- package/dist-package/packages/runtime/src/timeline/snapshot-digest.js +1 -1
- package/dist-package/packages/runtime/src/verification/verification.d.ts +6 -0
- package/dist-package/packages/testkit/src/fixture-analyzers.d.ts +37 -0
- package/dist-package/packages/testkit/src/in-memory-editor.d.ts +55 -0
- package/dist-package/packages/testkit/src/in-memory-editor.js +3 -3
- package/dist-package/packages/testkit/src/index.d.ts +4 -0
- package/dist-package/packages/testkit/src/index.js +1 -0
- package/dist-package/packages/testkit/src/sender-lifecycle-fixture.d.ts +47 -0
- package/dist-package/packages/testkit/src/sender-lifecycle-fixture.js +192 -0
- package/dist-package/packages/testkit/src/skill-fixtures.d.ts +3 -0
- package/package.json +41 -14
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SkillToolMetadata } from "./metadata.js";
|
|
2
|
+
export interface ListedSkillTool {
|
|
3
|
+
name: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
inputSchema: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface SkillToolCatalogEntry extends Omit<SkillToolMetadata, "inputSchema"> {
|
|
8
|
+
inputSchema: Readonly<Record<string, unknown>>;
|
|
9
|
+
}
|
|
10
|
+
export interface SkillToolCatalog {
|
|
11
|
+
schemaVersion: 1;
|
|
12
|
+
tools: SkillToolCatalogEntry[];
|
|
13
|
+
}
|
|
14
|
+
export interface SkillToolCatalogResult {
|
|
15
|
+
catalog: SkillToolCatalog;
|
|
16
|
+
errors: string[];
|
|
17
|
+
}
|
|
18
|
+
/** Combine the public tools/list contract with its explicitly declared family metadata. */
|
|
19
|
+
export declare function buildSkillToolCatalog(metadata: readonly unknown[], listedTools: readonly ListedSkillTool[]): SkillToolCatalogResult;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/** Combine the public tools/list contract with its explicitly declared family metadata. */
|
|
2
|
+
export function buildSkillToolCatalog(metadata, listedTools) {
|
|
3
|
+
const errors = validateMetadata(metadata);
|
|
4
|
+
const skillTools = listedTools.filter(({ name }) => name.startsWith("skill."));
|
|
5
|
+
const listedByName = new Map();
|
|
6
|
+
for (const tool of skillTools) {
|
|
7
|
+
if (listedByName.has(tool.name))
|
|
8
|
+
errors.push(`duplicate tools/list name ${tool.name}`);
|
|
9
|
+
else
|
|
10
|
+
listedByName.set(tool.name, tool);
|
|
11
|
+
}
|
|
12
|
+
const metadataByName = new Map();
|
|
13
|
+
for (const entry of metadata) {
|
|
14
|
+
if (!isSkillToolMetadata(entry))
|
|
15
|
+
continue;
|
|
16
|
+
metadataByName.set(entry.name, entry);
|
|
17
|
+
const listed = listedByName.get(entry.name);
|
|
18
|
+
if (!listed) {
|
|
19
|
+
errors.push(`${entry.name} missing from tools/list`);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (listed.description !== entry.description) {
|
|
23
|
+
errors.push(`${entry.name} description drift from tools/list`);
|
|
24
|
+
}
|
|
25
|
+
compareInputContract(entry, listed, errors);
|
|
26
|
+
}
|
|
27
|
+
for (const name of listedByName.keys()) {
|
|
28
|
+
if (!metadataByName.has(name))
|
|
29
|
+
errors.push(`${name} missing typed metadata`);
|
|
30
|
+
}
|
|
31
|
+
const catalogTools = metadata.flatMap((entry) => {
|
|
32
|
+
if (!isSkillToolMetadata(entry))
|
|
33
|
+
return [];
|
|
34
|
+
const listed = listedByName.get(entry.name);
|
|
35
|
+
if (!listed || !isRecord(listed.inputSchema))
|
|
36
|
+
return [];
|
|
37
|
+
const { inputSchema: _schema, ...declaredMetadata } = entry;
|
|
38
|
+
return [{ ...declaredMetadata, inputSchema: structuredClone(listed.inputSchema) }];
|
|
39
|
+
});
|
|
40
|
+
return { catalog: { schemaVersion: 1, tools: catalogTools }, errors };
|
|
41
|
+
}
|
|
42
|
+
function validateMetadata(metadata) {
|
|
43
|
+
const errors = [];
|
|
44
|
+
const names = new Set();
|
|
45
|
+
for (const entry of metadata) {
|
|
46
|
+
if (!isRecord(entry)) {
|
|
47
|
+
errors.push("metadata entry must be an object");
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const name = typeof entry.name === "string" ? entry.name : undefined;
|
|
51
|
+
if (!name) {
|
|
52
|
+
errors.push("metadata entry missing required field name");
|
|
53
|
+
}
|
|
54
|
+
else if (names.has(name)) {
|
|
55
|
+
errors.push(`duplicate metadata name ${name}`);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
names.add(name);
|
|
59
|
+
}
|
|
60
|
+
if (name && !name.startsWith("skill."))
|
|
61
|
+
errors.push(`${name} must use the skill. tool family prefix`);
|
|
62
|
+
if (name && (typeof entry.description !== "string" || !entry.description.trim())) {
|
|
63
|
+
errors.push(`${name} missing required metadata field description`);
|
|
64
|
+
}
|
|
65
|
+
if (name && !isZodRawShape(entry.inputSchema))
|
|
66
|
+
errors.push(`${name} missing required metadata field inputSchema`);
|
|
67
|
+
if (name && (typeof entry.outputContract !== "string" || !entry.outputContract.trim())) {
|
|
68
|
+
errors.push(`${name} missing required metadata field outputContract`);
|
|
69
|
+
}
|
|
70
|
+
if (name && !validModes(entry.capabilityModes))
|
|
71
|
+
errors.push(`${name} missing required metadata field capabilityModes`);
|
|
72
|
+
if (name && !nonEmptyStringArray(entry.capabilities))
|
|
73
|
+
errors.push(`${name} missing required metadata field capabilities`);
|
|
74
|
+
if (name && !["read", "preview", "write"].includes(String(entry.effect))) {
|
|
75
|
+
errors.push(`${name} missing required metadata field effect`);
|
|
76
|
+
}
|
|
77
|
+
if (name && !validApproval(entry.approval))
|
|
78
|
+
errors.push(`${name} missing required metadata field approval`);
|
|
79
|
+
if (name && !stringArray(entry.errorCodes))
|
|
80
|
+
errors.push(`${name} missing required metadata field errorCodes`);
|
|
81
|
+
if (name && !Array.isArray(entry.examples))
|
|
82
|
+
errors.push(`${name} missing required metadata field examples`);
|
|
83
|
+
}
|
|
84
|
+
return errors;
|
|
85
|
+
}
|
|
86
|
+
function compareInputContract(metadata, listed, errors) {
|
|
87
|
+
const actualSchema = isRecord(listed.inputSchema) ? listed.inputSchema : {};
|
|
88
|
+
const actualProperties = isRecord(actualSchema.properties) ? Object.keys(actualSchema.properties).sort() : [];
|
|
89
|
+
const expectedProperties = Object.keys(metadata.inputSchema).sort();
|
|
90
|
+
if (!sameStrings(expectedProperties, actualProperties)) {
|
|
91
|
+
errors.push(`${metadata.name} input property drift from tools/list`);
|
|
92
|
+
}
|
|
93
|
+
const expectedRequired = Object.entries(metadata.inputSchema)
|
|
94
|
+
.filter(([, schema]) => !schema.isOptional())
|
|
95
|
+
.map(([name]) => name)
|
|
96
|
+
.sort();
|
|
97
|
+
const actualRequired = Array.isArray(actualSchema.required)
|
|
98
|
+
? actualSchema.required.filter((item) => typeof item === "string").sort()
|
|
99
|
+
: [];
|
|
100
|
+
if (!sameStrings(expectedRequired, actualRequired)) {
|
|
101
|
+
errors.push(`${metadata.name} required input drift from tools/list`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function isSkillToolMetadata(value) {
|
|
105
|
+
return isRecord(value)
|
|
106
|
+
&& typeof value.name === "string"
|
|
107
|
+
&& typeof value.description === "string"
|
|
108
|
+
&& isZodRawShape(value.inputSchema)
|
|
109
|
+
&& typeof value.outputContract === "string"
|
|
110
|
+
&& validModes(value.capabilityModes)
|
|
111
|
+
&& nonEmptyStringArray(value.capabilities)
|
|
112
|
+
&& ["read", "preview", "write"].includes(String(value.effect))
|
|
113
|
+
&& validApproval(value.approval)
|
|
114
|
+
&& stringArray(value.errorCodes)
|
|
115
|
+
&& Array.isArray(value.examples);
|
|
116
|
+
}
|
|
117
|
+
function isZodRawShape(value) {
|
|
118
|
+
return isRecord(value) && Object.values(value).every((schema) => (isRecord(schema) && typeof schema.isOptional === "function"));
|
|
119
|
+
}
|
|
120
|
+
function validModes(value) {
|
|
121
|
+
return Array.isArray(value)
|
|
122
|
+
&& value.length > 0
|
|
123
|
+
&& value.every((mode) => ["fixture", "headless", "editor"].includes(String(mode)));
|
|
124
|
+
}
|
|
125
|
+
function validApproval(value) {
|
|
126
|
+
if (!isRecord(value))
|
|
127
|
+
return false;
|
|
128
|
+
return value.kind === "none" && value.required === false
|
|
129
|
+
|| value.kind === "runtime-preview-token" && value.required === true;
|
|
130
|
+
}
|
|
131
|
+
function nonEmptyStringArray(value) {
|
|
132
|
+
return Array.isArray(value) && value.length > 0 && value.every((item) => typeof item === "string" && item.trim().length > 0);
|
|
133
|
+
}
|
|
134
|
+
function stringArray(value) {
|
|
135
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string" && item.trim().length > 0);
|
|
136
|
+
}
|
|
137
|
+
function sameStrings(left, right) {
|
|
138
|
+
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
139
|
+
}
|
|
140
|
+
function isRecord(value) {
|
|
141
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
142
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod/v3";
|
|
2
|
+
export type SkillToolName = "skill.list" | "skill.inspect" | "skill.preview" | "skill.execute";
|
|
3
|
+
export type SkillToolMode = "fixture" | "headless" | "editor";
|
|
4
|
+
export type SkillToolEffect = "read" | "preview" | "write";
|
|
5
|
+
export type SkillToolOutputContract = "SkillInspection[]" | "SkillInspection" | "SkillPreview" | "SkillExecution";
|
|
6
|
+
export interface SkillToolMetadata {
|
|
7
|
+
name: SkillToolName;
|
|
8
|
+
description: string;
|
|
9
|
+
inputSchema: z.ZodRawShape;
|
|
10
|
+
outputContract: SkillToolOutputContract;
|
|
11
|
+
capabilityModes: readonly SkillToolMode[];
|
|
12
|
+
capabilities: readonly string[];
|
|
13
|
+
effect: SkillToolEffect;
|
|
14
|
+
approval: {
|
|
15
|
+
kind: "none";
|
|
16
|
+
required: false;
|
|
17
|
+
} | {
|
|
18
|
+
kind: "runtime-preview-token";
|
|
19
|
+
required: true;
|
|
20
|
+
};
|
|
21
|
+
errorCodes: readonly string[];
|
|
22
|
+
examples: readonly Readonly<Record<string, unknown>>[];
|
|
23
|
+
}
|
|
24
|
+
export declare const skillRevisionValueSchema: z.ZodObject<{
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
sequence: z.ZodNumber;
|
|
27
|
+
timestamp: z.ZodString;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
id: string;
|
|
30
|
+
sequence: number;
|
|
31
|
+
timestamp: string;
|
|
32
|
+
}, {
|
|
33
|
+
id: string;
|
|
34
|
+
sequence: number;
|
|
35
|
+
timestamp: string;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const SKILL_TOOL_METADATA: readonly SkillToolMetadata[];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from "zod/v3";
|
|
2
|
+
export const skillRevisionValueSchema = z.object({
|
|
3
|
+
id: z.string(),
|
|
4
|
+
sequence: z.number().int().nonnegative(),
|
|
5
|
+
timestamp: z.string(),
|
|
6
|
+
});
|
|
7
|
+
const allSkillToolModes = ["fixture", "headless", "editor"];
|
|
8
|
+
export const SKILL_TOOL_METADATA = [
|
|
9
|
+
{
|
|
10
|
+
name: "skill.list",
|
|
11
|
+
description: "List registered versioned Framekit Skills with current capability availability.",
|
|
12
|
+
inputSchema: {},
|
|
13
|
+
outputContract: "SkillInspection[]",
|
|
14
|
+
capabilityModes: allSkillToolModes,
|
|
15
|
+
capabilities: ["skill-availability"],
|
|
16
|
+
effect: "read",
|
|
17
|
+
approval: { kind: "none", required: false },
|
|
18
|
+
errorCodes: ["SKILL_ERROR"],
|
|
19
|
+
examples: [{ input: {} }],
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "skill.inspect",
|
|
23
|
+
description: "Inspect one registered Framekit Skill version and its current capability availability.",
|
|
24
|
+
inputSchema: {
|
|
25
|
+
skill: z.string().min(1),
|
|
26
|
+
version: z.string().min(1).optional(),
|
|
27
|
+
},
|
|
28
|
+
outputContract: "SkillInspection",
|
|
29
|
+
capabilityModes: allSkillToolModes,
|
|
30
|
+
capabilities: ["skill-availability"],
|
|
31
|
+
effect: "read",
|
|
32
|
+
approval: { kind: "none", required: false },
|
|
33
|
+
errorCodes: ["SKILL_NOT_FOUND", "SKILL_VERSION_NOT_FOUND", "SKILL_ERROR"],
|
|
34
|
+
examples: [{ input: { skill: "color-correction" } }],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "skill.preview",
|
|
38
|
+
description: "Validate and preview a registered Skill without mutating the editor.",
|
|
39
|
+
inputSchema: {
|
|
40
|
+
skill: z.string().min(1),
|
|
41
|
+
version: z.string().min(1).optional(),
|
|
42
|
+
arguments: z.record(z.unknown()),
|
|
43
|
+
},
|
|
44
|
+
outputContract: "SkillPreview",
|
|
45
|
+
capabilityModes: allSkillToolModes,
|
|
46
|
+
capabilities: ["runtime-skill-requirements", "revision-bound-preview"],
|
|
47
|
+
effect: "preview",
|
|
48
|
+
approval: { kind: "none", required: false },
|
|
49
|
+
errorCodes: ["SKILL_INPUT_INVALID", "SKILL_REQUIREMENTS_UNMET", "STALE_CONTEXT", "SKILL_ERROR"],
|
|
50
|
+
examples: [{
|
|
51
|
+
input: {
|
|
52
|
+
skill: "color-correction",
|
|
53
|
+
arguments: { baseRevision: { id: "revision-1", sequence: 1, timestamp: "2026-10-01T00:00:00.000Z" }, clipId: "clip-1", preset: "warm" },
|
|
54
|
+
},
|
|
55
|
+
}],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "skill.execute",
|
|
59
|
+
description: "Execute only a runtime-issued Skill preview token and return verification/rollback evidence.",
|
|
60
|
+
inputSchema: {
|
|
61
|
+
previewToken: z.string().min(1),
|
|
62
|
+
},
|
|
63
|
+
outputContract: "SkillExecution",
|
|
64
|
+
capabilityModes: allSkillToolModes,
|
|
65
|
+
capabilities: ["runtime-issued-preview-token", "revision-check", "verification", "rollback"],
|
|
66
|
+
effect: "write",
|
|
67
|
+
approval: { kind: "runtime-preview-token", required: true },
|
|
68
|
+
errorCodes: ["SKILL_PREVIEW_TOKEN_INVALID", "SKILL_PREVIEW_TOKEN_EXPIRED", "SKILL_REQUIREMENTS_UNMET", "STALE_CONTEXT", "SKILL_ERROR"],
|
|
69
|
+
examples: [{ input: { previewToken: "skill-preview-issued-by-runtime" } }],
|
|
70
|
+
},
|
|
71
|
+
];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { AgentVideoRuntime, SkillPreview } from "../../../../../packages/runtime/src/index.js";
|
|
3
|
+
/** Runtime capability and availability resolution stays behind this injected port. */
|
|
4
|
+
export type SkillToolsRuntime = Pick<AgentVideoRuntime, "listSkillAvailability" | "inspectSkillAvailability" | "previewSkill" | "executeSkill">;
|
|
5
|
+
export declare function registerSkillTools(server: McpServer, runtime: SkillToolsRuntime): void;
|
|
6
|
+
export declare function skillPreviewResult(preview: SkillPreview): {
|
|
7
|
+
content: {
|
|
8
|
+
type: "text";
|
|
9
|
+
text: string;
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { z } from "zod/v3";
|
|
2
|
+
import { SKILL_TOOL_METADATA, skillRevisionValueSchema } from "./metadata.js";
|
|
3
|
+
const metadataByName = new Map(SKILL_TOOL_METADATA.map((metadata) => [metadata.name, metadata]));
|
|
4
|
+
export function registerSkillTools(server, runtime) {
|
|
5
|
+
const list = toolMetadata("skill.list");
|
|
6
|
+
server.registerTool(list.name, {
|
|
7
|
+
description: list.description,
|
|
8
|
+
inputSchema: list.inputSchema,
|
|
9
|
+
}, async () => {
|
|
10
|
+
try {
|
|
11
|
+
return jsonResult((await runtime.listSkillAvailability()).map(({ manifest, availability }) => ({
|
|
12
|
+
...manifest,
|
|
13
|
+
availability,
|
|
14
|
+
})));
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return skillErrorResult(error);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const inspect = toolMetadata("skill.inspect");
|
|
21
|
+
server.registerTool(inspect.name, {
|
|
22
|
+
description: inspect.description,
|
|
23
|
+
inputSchema: inspect.inputSchema,
|
|
24
|
+
}, async ({ skill, version }) => {
|
|
25
|
+
try {
|
|
26
|
+
const { manifest, availability } = await runtime.inspectSkillAvailability(skill, version);
|
|
27
|
+
return jsonResult({ ...manifest, availability });
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
return skillErrorResult(error);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const preview = toolMetadata("skill.preview");
|
|
34
|
+
server.registerTool(preview.name, {
|
|
35
|
+
description: preview.description,
|
|
36
|
+
inputSchema: preview.inputSchema,
|
|
37
|
+
}, async ({ skill, version, arguments: skillArguments }) => {
|
|
38
|
+
try {
|
|
39
|
+
const baseRevision = skillRevisionValueSchema.parse(skillArguments.baseRevision);
|
|
40
|
+
const { baseRevision: _baseRevision, ...input } = skillArguments;
|
|
41
|
+
return skillPreviewResult(await runtime.previewSkill({
|
|
42
|
+
skillId: skill,
|
|
43
|
+
...(version ? { version } : {}),
|
|
44
|
+
baseRevision,
|
|
45
|
+
input,
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return skillErrorResult(error);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const execute = toolMetadata("skill.execute");
|
|
53
|
+
server.registerTool(execute.name, {
|
|
54
|
+
description: execute.description,
|
|
55
|
+
inputSchema: execute.inputSchema,
|
|
56
|
+
}, async ({ previewToken }) => {
|
|
57
|
+
try {
|
|
58
|
+
return jsonResult(await runtime.executeSkill(previewToken));
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
return skillErrorResult(error);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function toolMetadata(name) {
|
|
66
|
+
const metadata = metadataByName.get(name);
|
|
67
|
+
if (!metadata)
|
|
68
|
+
throw new Error(`SKILL_TOOL_METADATA_MISSING: ${name}`);
|
|
69
|
+
return metadata;
|
|
70
|
+
}
|
|
71
|
+
function jsonResult(value) {
|
|
72
|
+
return {
|
|
73
|
+
content: [{ type: "text", text: JSON.stringify(value) }],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function skillErrorResult(error) {
|
|
77
|
+
const value = error && typeof error === "object" ? error : {};
|
|
78
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
79
|
+
const code = error instanceof z.ZodError
|
|
80
|
+
? "SKILL_INPUT_INVALID"
|
|
81
|
+
: typeof value.code === "string" ? value.code : message.split(":", 1)[0] || "SKILL_ERROR";
|
|
82
|
+
return {
|
|
83
|
+
isError: true,
|
|
84
|
+
content: [{
|
|
85
|
+
type: "text",
|
|
86
|
+
text: JSON.stringify({
|
|
87
|
+
code,
|
|
88
|
+
message,
|
|
89
|
+
...(value.availability ? { availability: value.availability } : {}),
|
|
90
|
+
}),
|
|
91
|
+
}],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export function skillPreviewResult(preview) {
|
|
95
|
+
const details = preview.plan.details ?? {};
|
|
96
|
+
return jsonResult({
|
|
97
|
+
...preview,
|
|
98
|
+
...details,
|
|
99
|
+
plan: { ...preview.plan, ...details },
|
|
100
|
+
});
|
|
101
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ContextRevision, ProjectEditCommand, RationalTime, TimelineIr, TimelineIrEditOperation } from "../../runtime/src/index.js";
|
|
2
|
+
export interface ExternalEdit {
|
|
3
|
+
schemaVersion: 1;
|
|
4
|
+
clips: Array<{
|
|
5
|
+
id: string;
|
|
6
|
+
mediaId: string;
|
|
7
|
+
sourceStartTime: RationalTime;
|
|
8
|
+
durationTime: RationalTime;
|
|
9
|
+
}>;
|
|
10
|
+
title: {
|
|
11
|
+
id: string;
|
|
12
|
+
text: string;
|
|
13
|
+
startTime: RationalTime;
|
|
14
|
+
durationTime: RationalTime;
|
|
15
|
+
};
|
|
16
|
+
music: {
|
|
17
|
+
id: string;
|
|
18
|
+
mediaId: string;
|
|
19
|
+
sourceStartTime: RationalTime;
|
|
20
|
+
startTime: RationalTime;
|
|
21
|
+
durationTime: RationalTime;
|
|
22
|
+
gainDb: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** Convert the bounded interchange format to the existing project transaction operations. */
|
|
26
|
+
export declare function externalEditOperations(edit: ExternalEdit, timeline: TimelineIr, expectedRevision: ContextRevision): TimelineIrEditOperation[];
|
|
27
|
+
/** Check the actual compiler before a JSON edit can be committed. No artifact is written. */
|
|
28
|
+
export declare function verifyExternalEditExportable(timeline: TimelineIr): void;
|
|
29
|
+
/** Bind an approved preview to its target, base revision and translated operations. */
|
|
30
|
+
export declare function externalEditPlanDigest(command: ProjectEditCommand): string;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { compileTimelineIrToFcpxml } from "../../../adapters/final-cut/typescript/src/documents.js";
|
|
3
|
+
import { ProjectTransactionError } from "../../runtime/src/index.js";
|
|
4
|
+
/** Convert the bounded interchange format to the existing project transaction operations. */
|
|
5
|
+
export function externalEditOperations(edit, timeline, expectedRevision) {
|
|
6
|
+
if (timeline.revision.id !== expectedRevision.id || timeline.revision.sequence !== expectedRevision.sequence) {
|
|
7
|
+
throw new ProjectTransactionError("PROJECT_EDIT_STALE_REVISION", "expected project revision does not match the inspected project", {
|
|
8
|
+
expectedRevision, actualRevision: timeline.revision,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
const sequence = timeline.sequence;
|
|
12
|
+
if (BigInt(sequence.durationTime.value) !== 0n || sequence.occurrences.length || sequence.storyElements.length
|
|
13
|
+
|| sequence.markers.length || sequence.captions.length || sequence.titles?.length || sequence.transitions?.length) {
|
|
14
|
+
throw new Error("EXTERNAL_EDIT_INVALID: a new external edit requires an empty timeline");
|
|
15
|
+
}
|
|
16
|
+
const assertSource = (id, kind) => {
|
|
17
|
+
const resource = timeline.resources.find((item) => item.id === id);
|
|
18
|
+
if (!resource || resource.mediaKind !== kind || resource.sourceKind !== "local-file" || !resource.sourceDigest) {
|
|
19
|
+
throw new Error(`EXTERNAL_EDIT_INVALID: ${id} is not a registered ${kind} source`);
|
|
20
|
+
}
|
|
21
|
+
return resource;
|
|
22
|
+
};
|
|
23
|
+
const frame = timeline.sequence.frameDuration;
|
|
24
|
+
const aligned = (time, grid = frame, label = "sequence") => {
|
|
25
|
+
const numerator = BigInt(time.value) * BigInt(grid.timescale);
|
|
26
|
+
const denominator = BigInt(time.timescale) * BigInt(grid.value);
|
|
27
|
+
if (denominator <= 0n || numerator % denominator !== 0n)
|
|
28
|
+
throw new Error(`EXTERNAL_EDIT_INVALID: timing must align to the ${label} frame grid`);
|
|
29
|
+
};
|
|
30
|
+
for (const clip of edit.clips) {
|
|
31
|
+
const resource = assertSource(clip.mediaId, "video");
|
|
32
|
+
const stream = resource.metadata?.streams.find((item) => item.kind === "video");
|
|
33
|
+
const rate = stream?.frameRate;
|
|
34
|
+
if (!rate || BigInt(rate.value) <= 0n || BigInt(rate.timescale) <= 0n) {
|
|
35
|
+
throw new Error(`EXTERNAL_EDIT_INVALID: ${clip.mediaId} has no supported source frame rate`);
|
|
36
|
+
}
|
|
37
|
+
if (!stream?.sourceRange)
|
|
38
|
+
throw new Error(`EXTERNAL_EDIT_INVALID: ${clip.mediaId} has no verified video stream bounds; register the source in a new project`);
|
|
39
|
+
const addRationalTimes = (a, b) => ({ value: String(BigInt(a.value) * BigInt(b.timescale) + BigInt(b.value) * BigInt(a.timescale)), timescale: String(BigInt(a.timescale) * BigInt(b.timescale)) });
|
|
40
|
+
const compare = (a, b) => BigInt(a.value) * BigInt(b.timescale) - BigInt(b.value) * BigInt(a.timescale);
|
|
41
|
+
if (compare(clip.sourceStartTime, stream.sourceRange.start) < 0n || compare(addRationalTimes(clip.sourceStartTime, clip.durationTime), addRationalTimes(stream.sourceRange.start, stream.sourceRange.duration)) > 0n) {
|
|
42
|
+
throw new Error(`EXTERNAL_EDIT_INVALID: ${clip.mediaId} range exceeds video stream bounds`);
|
|
43
|
+
}
|
|
44
|
+
const sourceFrame = { value: rate.timescale, timescale: rate.value };
|
|
45
|
+
aligned(clip.sourceStartTime);
|
|
46
|
+
const sourceOffset = { value: String(BigInt(clip.sourceStartTime.value) * BigInt(stream.sourceRange.start.timescale) - BigInt(stream.sourceRange.start.value) * BigInt(clip.sourceStartTime.timescale)), timescale: String(BigInt(clip.sourceStartTime.timescale) * BigInt(stream.sourceRange.start.timescale)) };
|
|
47
|
+
aligned(sourceOffset, sourceFrame, "source");
|
|
48
|
+
aligned(clip.durationTime);
|
|
49
|
+
aligned(clip.durationTime, sourceFrame, "source");
|
|
50
|
+
}
|
|
51
|
+
assertSource(edit.music.mediaId, "audio");
|
|
52
|
+
for (const time of [edit.music.sourceStartTime, edit.music.startTime, edit.music.durationTime, edit.title.startTime, edit.title.durationTime])
|
|
53
|
+
aligned(time);
|
|
54
|
+
return [
|
|
55
|
+
...edit.clips.map((clip) => ({ type: "insert-occurrence", placement: "append", occurrence: {
|
|
56
|
+
...clip, name: clip.id, startTime: { value: "0", timescale: "1" }, track: 0, role: "video",
|
|
57
|
+
} })),
|
|
58
|
+
{ type: "insert-occurrence", occurrence: { ...edit.music, name: edit.music.id, track: 1, role: "music" } },
|
|
59
|
+
{ type: "add-title", title: { ...edit.title, lane: 1 } },
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
/** Check the actual compiler before a JSON edit can be committed. No artifact is written. */
|
|
63
|
+
export function verifyExternalEditExportable(timeline) {
|
|
64
|
+
compileTimelineIrToFcpxml(timeline, { target: {
|
|
65
|
+
provider: "final-cut", libraryUid: "preview-library", eventUid: "preview-event",
|
|
66
|
+
projectUid: "preview-project", sequenceUid: "preview-sequence", materialization: "versioned",
|
|
67
|
+
} });
|
|
68
|
+
}
|
|
69
|
+
/** Bind an approved preview to its target, base revision and translated operations. */
|
|
70
|
+
export function externalEditPlanDigest(command) {
|
|
71
|
+
return createHash("sha256").update(JSON.stringify(command)).digest("hex");
|
|
72
|
+
}
|