@morshoto/framekit 0.1.10 → 0.1.11
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/dist-package/adapters/final-cut/typescript/src/background-materialization.js +175 -0
- package/dist-package/adapters/final-cut/typescript/src/connection.js +52 -14
- package/dist-package/adapters/final-cut/typescript/src/fcpxml-console-experiment.js +74 -0
- package/dist-package/adapters/final-cut/typescript/src/index.js +6 -0
- package/dist-package/adapters/final-cut/typescript/src/live.js +11 -4
- package/dist-package/adapters/final-cut/typescript/src/session.js +19 -1
- package/dist-package/adapters/final-cut/typescript/src/shadow-mutation.js +120 -0
- package/dist-package/adapters/final-cut/typescript/src/sqlite-inspection.js +433 -0
- package/dist-package/adapters/final-cut/typescript/src/timeline-ir-fcpxml.js +372 -0
- package/dist-package/adapters/final-cut/typescript/src/unattended-editing.js +66 -0
- package/dist-package/apps/mcp-server/src/headless-sessions.js +112 -0
- package/dist-package/apps/mcp-server/src/main.js +16 -2
- package/dist-package/apps/mcp-server/src/materialization-jobs.js +326 -0
- package/dist-package/apps/mcp-server/src/server.js +110 -0
- package/dist-package/packages/runtime/src/index.js +2 -0
- package/dist-package/packages/runtime/src/timeline/drift-reconciliation.js +295 -0
- package/dist-package/packages/runtime/src/timeline/editing-session.js +490 -0
- package/package.json +6 -5
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { timelineIrDigest } from "../../../packages/runtime/src/index.js";
|
|
5
|
+
import { compileTimelineIrToFcpxml, } from "../../../adapters/final-cut/typescript/src/index.js";
|
|
6
|
+
export class SessionMaterializationJobs {
|
|
7
|
+
directory;
|
|
8
|
+
sessions;
|
|
9
|
+
publisher;
|
|
10
|
+
constructor(directory, sessions, publisher) {
|
|
11
|
+
this.directory = directory;
|
|
12
|
+
this.sessions = sessions;
|
|
13
|
+
this.publisher = publisher;
|
|
14
|
+
}
|
|
15
|
+
async preview(sessionId, target) {
|
|
16
|
+
const session = await this.sessions.loadForMaterialization(sessionId);
|
|
17
|
+
this.assertProvider(session.document().provider?.id, target.provider);
|
|
18
|
+
session.assertMaterializationReady(session.base().revision);
|
|
19
|
+
const artifact = compileTimelineIrToFcxmlVersioned(session.desired(), target);
|
|
20
|
+
return {
|
|
21
|
+
sessionId,
|
|
22
|
+
mutating: false,
|
|
23
|
+
sessionState: session.state(),
|
|
24
|
+
target: artifact.target,
|
|
25
|
+
destination: artifact.destination,
|
|
26
|
+
collisionPolicy: "create-only",
|
|
27
|
+
artifactDigest: artifact.digest,
|
|
28
|
+
evidence: { artifact: { verified: true, format: "fcpxml", digest: artifact.digest } },
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async execute(sessionId, target, confirm) {
|
|
32
|
+
if (!confirm)
|
|
33
|
+
throw new Error("MATERIALIZATION_CONFIRMATION_REQUIRED: set confirm=true to stage and publish a versioned project");
|
|
34
|
+
const session = await this.sessions.loadForMaterialization(sessionId);
|
|
35
|
+
this.assertProvider(session.document().provider?.id, target.provider);
|
|
36
|
+
session.assertMaterializationReady(session.base().revision);
|
|
37
|
+
const desired = session.desired();
|
|
38
|
+
const artifact = compileTimelineIrToFcxmlVersioned(desired, target);
|
|
39
|
+
const jobId = `materialization-${randomUUID()}`;
|
|
40
|
+
const artifactPath = join(this.directory, "artifacts", `${jobId}.fcpxml`);
|
|
41
|
+
await mkdir(dirname(artifactPath), { recursive: true });
|
|
42
|
+
await writeFile(artifactPath, artifact.xml, { encoding: "utf8", flag: "wx" });
|
|
43
|
+
session.markWaitingForMaterialization();
|
|
44
|
+
await this.sessions.checkpoint(sessionId, session);
|
|
45
|
+
let job = {
|
|
46
|
+
schemaVersion: 1,
|
|
47
|
+
jobId,
|
|
48
|
+
sessionId,
|
|
49
|
+
state: "blocked",
|
|
50
|
+
nextAction: "retry",
|
|
51
|
+
artifactPath,
|
|
52
|
+
artifactDigest: artifact.digest,
|
|
53
|
+
target: artifact.target,
|
|
54
|
+
destination: artifact.destination,
|
|
55
|
+
desired: structuredClone(desired),
|
|
56
|
+
desiredDigest: timelineIrDigest(desired),
|
|
57
|
+
sessionDigest: digestSession(session),
|
|
58
|
+
evidence: {
|
|
59
|
+
artifact: { verified: true, format: "fcpxml", digest: artifact.digest },
|
|
60
|
+
providerRequested: false,
|
|
61
|
+
canonicalReadback: false,
|
|
62
|
+
headedNative: false,
|
|
63
|
+
},
|
|
64
|
+
error: {
|
|
65
|
+
code: "MATERIALIZATION_PROVIDER_UNAVAILABLE",
|
|
66
|
+
message: "No Final Cut materialization publisher is configured; retry when a provider is available",
|
|
67
|
+
retryable: true,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
await this.save(job);
|
|
71
|
+
return this.attempt(job);
|
|
72
|
+
}
|
|
73
|
+
async status(jobId) {
|
|
74
|
+
try {
|
|
75
|
+
const job = JSON.parse(await readFile(this.jobPath(jobId), "utf8"));
|
|
76
|
+
if (job.schemaVersion !== 1 || job.jobId !== jobId)
|
|
77
|
+
throw new Error("MATERIALIZATION_JOB_INVALID: persisted job is invalid");
|
|
78
|
+
return structuredClone(job);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (error.code === "ENOENT") {
|
|
82
|
+
throw new Error(`MATERIALIZATION_JOB_NOT_FOUND: unknown materialization job ${jobId}`);
|
|
83
|
+
}
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async retry(jobId) {
|
|
88
|
+
const job = await this.status(jobId);
|
|
89
|
+
if (job.state === "publishing" || job.state === "completed" || job.state === "failed")
|
|
90
|
+
return job;
|
|
91
|
+
if (!job.error?.retryable)
|
|
92
|
+
throw new Error(`MATERIALIZATION_NOT_RETRYABLE: job ${jobId} cannot be retried`);
|
|
93
|
+
return this.attempt(job);
|
|
94
|
+
}
|
|
95
|
+
async attempt(job) {
|
|
96
|
+
if (!this.publisher || job.state === "publishing")
|
|
97
|
+
return job;
|
|
98
|
+
const initialFailure = await this.validateStagedJob(job);
|
|
99
|
+
if (initialFailure)
|
|
100
|
+
return this.fail(job, initialFailure);
|
|
101
|
+
const claim = await this.claim(job);
|
|
102
|
+
if (!claim.owned)
|
|
103
|
+
return claim.job;
|
|
104
|
+
const claimed = claim.job;
|
|
105
|
+
try {
|
|
106
|
+
const finalFailure = await this.validateStagedJob(claimed);
|
|
107
|
+
if (finalFailure)
|
|
108
|
+
return this.fail(claimed, finalFailure);
|
|
109
|
+
const result = await this.publisher.publish({
|
|
110
|
+
jobId: claimed.jobId,
|
|
111
|
+
artifactPath: claimed.artifactPath,
|
|
112
|
+
artifactDigest: claimed.artifactDigest,
|
|
113
|
+
target: claimed.target,
|
|
114
|
+
destination: claimed.destination,
|
|
115
|
+
collisionPolicy: "create-only",
|
|
116
|
+
desired: structuredClone(claimed.desired),
|
|
117
|
+
desiredDigest: claimed.desiredDigest,
|
|
118
|
+
});
|
|
119
|
+
if (result.state === "blocked") {
|
|
120
|
+
const blocked = {
|
|
121
|
+
...claimed,
|
|
122
|
+
state: "blocked",
|
|
123
|
+
nextAction: "retry",
|
|
124
|
+
claim: undefined,
|
|
125
|
+
evidence: { ...claimed.evidence, providerRequested: true },
|
|
126
|
+
error: { code: result.code, message: result.message, retryable: result.retryable },
|
|
127
|
+
};
|
|
128
|
+
await this.save(blocked);
|
|
129
|
+
return blocked;
|
|
130
|
+
}
|
|
131
|
+
if (timelineIrDigest(result.canonicalReadback) !== claimed.desiredDigest) {
|
|
132
|
+
return this.fail(claimed, {
|
|
133
|
+
code: "MATERIALIZATION_READBACK_MISMATCH",
|
|
134
|
+
message: "Canonical provider readback does not match the desired Timeline IR",
|
|
135
|
+
retryable: false,
|
|
136
|
+
providerRequested: true,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
const expectedTarget = {
|
|
140
|
+
libraryUid: claimed.target.libraryUid,
|
|
141
|
+
eventUid: claimed.target.eventUid,
|
|
142
|
+
projectUid: claimed.destination.projectUid,
|
|
143
|
+
sequenceUid: claimed.destination.sequenceUid,
|
|
144
|
+
};
|
|
145
|
+
if (!sameTarget(result.canonicalTarget, expectedTarget)) {
|
|
146
|
+
return this.fail(claimed, {
|
|
147
|
+
code: "MATERIALIZATION_TARGET_READBACK_MISMATCH",
|
|
148
|
+
message: "Canonical provider readback does not identify the staged versioned target",
|
|
149
|
+
retryable: false,
|
|
150
|
+
providerRequested: true,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
const completed = {
|
|
154
|
+
...claimed,
|
|
155
|
+
state: "completed",
|
|
156
|
+
nextAction: "none",
|
|
157
|
+
claim: undefined,
|
|
158
|
+
evidence: {
|
|
159
|
+
...claimed.evidence,
|
|
160
|
+
providerRequested: true,
|
|
161
|
+
canonicalReadback: true,
|
|
162
|
+
headedNative: result.headedNativeVerified,
|
|
163
|
+
},
|
|
164
|
+
error: undefined,
|
|
165
|
+
};
|
|
166
|
+
await this.save(completed);
|
|
167
|
+
return completed;
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
return this.fail(claimed, materializationFailure(error, true));
|
|
171
|
+
}
|
|
172
|
+
finally {
|
|
173
|
+
await this.release(claimed.jobId, claimed.claim.id);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async validateStagedJob(job) {
|
|
177
|
+
if (!job.desired || !job.desiredDigest || timelineIrDigest(job.desired) !== job.desiredDigest) {
|
|
178
|
+
return {
|
|
179
|
+
code: "MATERIALIZATION_DESIRED_SNAPSHOT_INVALID",
|
|
180
|
+
message: "The staged desired Timeline IR is unavailable or does not match its immutable digest",
|
|
181
|
+
retryable: false,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
if (!job.sessionDigest) {
|
|
185
|
+
return {
|
|
186
|
+
code: "MATERIALIZATION_SESSION_SNAPSHOT_INVALID",
|
|
187
|
+
message: "The materialization job has no immutable session snapshot digest",
|
|
188
|
+
retryable: false,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
try {
|
|
192
|
+
const session = await this.sessions.loadForMaterialization(job.sessionId);
|
|
193
|
+
if (digestSession(session) !== job.sessionDigest) {
|
|
194
|
+
return {
|
|
195
|
+
code: "MATERIALIZATION_SESSION_CHANGED",
|
|
196
|
+
message: "The editing session changed after materialization staging; reconcile before retrying",
|
|
197
|
+
retryable: false,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
const artifact = await readFile(job.artifactPath, "utf8");
|
|
201
|
+
if (createHash("sha256").update(artifact).digest("hex") !== job.artifactDigest) {
|
|
202
|
+
return {
|
|
203
|
+
code: "MATERIALIZATION_ARTIFACT_CHANGED",
|
|
204
|
+
message: "The staged FCPXML artifact no longer matches its immutable digest",
|
|
205
|
+
retryable: false,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
return materializationFailure(error, false);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
async claim(job) {
|
|
215
|
+
const claimPath = this.claimPath(job.jobId);
|
|
216
|
+
const claim = { id: randomUUID(), claimedAt: new Date().toISOString() };
|
|
217
|
+
try {
|
|
218
|
+
await writeFile(claimPath, `${JSON.stringify({ jobId: job.jobId, ...claim })}\n`, { encoding: "utf8", flag: "wx" });
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
if (error.code !== "EEXIST")
|
|
222
|
+
throw error;
|
|
223
|
+
const current = await this.status(job.jobId);
|
|
224
|
+
if (current.state !== "blocked")
|
|
225
|
+
return { job: current, owned: false };
|
|
226
|
+
try {
|
|
227
|
+
const existing = JSON.parse(await readFile(claimPath, "utf8"));
|
|
228
|
+
if (existing.id && existing.claimedAt) {
|
|
229
|
+
return {
|
|
230
|
+
job: { ...current, state: "publishing", nextAction: "status", claim: { id: existing.id, claimedAt: existing.claimedAt } },
|
|
231
|
+
owned: false,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
// The owner may be between creating the claim and persisting state.
|
|
237
|
+
}
|
|
238
|
+
return { job: { ...current, state: "publishing", nextAction: "status" }, owned: false };
|
|
239
|
+
}
|
|
240
|
+
const claimed = {
|
|
241
|
+
...job,
|
|
242
|
+
state: "publishing",
|
|
243
|
+
nextAction: "status",
|
|
244
|
+
claim,
|
|
245
|
+
};
|
|
246
|
+
try {
|
|
247
|
+
await this.save(claimed);
|
|
248
|
+
return { job: claimed, owned: true };
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
await unlink(claimPath).catch(() => undefined);
|
|
252
|
+
throw error;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
async release(jobId, claimId) {
|
|
256
|
+
const path = this.claimPath(jobId);
|
|
257
|
+
try {
|
|
258
|
+
const current = JSON.parse(await readFile(path, "utf8"));
|
|
259
|
+
if (current.id === claimId)
|
|
260
|
+
await unlink(path);
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
if (error.code !== "ENOENT")
|
|
264
|
+
throw error;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
async fail(job, failure) {
|
|
268
|
+
const failed = {
|
|
269
|
+
...job,
|
|
270
|
+
state: "failed",
|
|
271
|
+
nextAction: "none",
|
|
272
|
+
claim: undefined,
|
|
273
|
+
evidence: {
|
|
274
|
+
...job.evidence,
|
|
275
|
+
providerRequested: failure.providerRequested ?? job.evidence.providerRequested,
|
|
276
|
+
},
|
|
277
|
+
error: {
|
|
278
|
+
code: failure.code,
|
|
279
|
+
message: failure.message,
|
|
280
|
+
retryable: failure.retryable,
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
await this.save(failed);
|
|
284
|
+
return failed;
|
|
285
|
+
}
|
|
286
|
+
async save(job) {
|
|
287
|
+
const path = this.jobPath(job.jobId);
|
|
288
|
+
await mkdir(dirname(path), { recursive: true });
|
|
289
|
+
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
290
|
+
await writeFile(temporary, `${JSON.stringify(job)}\n`, { encoding: "utf8", flag: "wx" });
|
|
291
|
+
await rename(temporary, path);
|
|
292
|
+
}
|
|
293
|
+
jobPath(jobId) {
|
|
294
|
+
if (!/^materialization-[A-Za-z0-9-]+$/.test(jobId))
|
|
295
|
+
throw new Error("MATERIALIZATION_JOB_ID_INVALID: invalid jobId");
|
|
296
|
+
return join(this.directory, "jobs", `${jobId}.json`);
|
|
297
|
+
}
|
|
298
|
+
claimPath(jobId) {
|
|
299
|
+
return `${this.jobPath(jobId)}.claim`;
|
|
300
|
+
}
|
|
301
|
+
assertProvider(sessionProvider, targetProvider) {
|
|
302
|
+
if (sessionProvider && sessionProvider !== targetProvider) {
|
|
303
|
+
throw new Error(`SESSION_PROVIDER_MISMATCH: expected ${sessionProvider}, received ${targetProvider}`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function digestSession(session) {
|
|
308
|
+
return createHash("sha256").update(session.serialize()).digest("hex");
|
|
309
|
+
}
|
|
310
|
+
function compileTimelineIrToFcxmlVersioned(desired, target) {
|
|
311
|
+
if (target.materialization === "reuse-existing") {
|
|
312
|
+
throw new Error("FINAL_CUT_BACKGROUND_MATERIALIZATION_REUSE_FORBIDDEN: materialization jobs are create-only");
|
|
313
|
+
}
|
|
314
|
+
return compileTimelineIrToFcpxml(desired, { target: { ...target, materialization: "versioned" } });
|
|
315
|
+
}
|
|
316
|
+
function materializationFailure(error, providerRequested) {
|
|
317
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
318
|
+
const code = message.match(/^([A-Z][A-Z0-9_]*):/)?.[1] ?? "MATERIALIZATION_PUBLISH_FAILED";
|
|
319
|
+
return { code, message, retryable: false, providerRequested };
|
|
320
|
+
}
|
|
321
|
+
function sameTarget(actual, expected) {
|
|
322
|
+
return actual?.libraryUid === expected.libraryUid
|
|
323
|
+
&& actual.eventUid === expected.eventUid
|
|
324
|
+
&& actual.projectUid === expected.projectUid
|
|
325
|
+
&& actual.sequenceUid === expected.sequenceUid;
|
|
326
|
+
}
|
|
@@ -6,6 +6,8 @@ import { createCapabilityPreflight, resolveEditingIntent, serializeCapabilityUna
|
|
|
6
6
|
import { NATIVE_MEDIA_IMPORT_DIRECTORY_ERROR_CODE, serializeFinalCutLibraryInspectionError, serializeNativeFinalCutMediaImportError, } from "../../../adapters/final-cut/typescript/src/index.js";
|
|
7
7
|
import { BACKGROUND_ARTIFACT_WORKFLOW, EDITOR_FIRST_MCP_INSTRUCTIONS, resolveEditingRoute, } from "./routing.js";
|
|
8
8
|
import { FRAMEKIT_BUILD_FINGERPRINT, FRAMEKIT_VERSION, } from "./version.js";
|
|
9
|
+
import { EditingSessionRepository } from "./headless-sessions.js";
|
|
10
|
+
import { SessionMaterializationJobs, } from "./materialization-jobs.js";
|
|
9
11
|
const revisionValueSchema = z.object({
|
|
10
12
|
id: z.string(),
|
|
11
13
|
sequence: z.number().int().nonnegative(),
|
|
@@ -645,6 +647,21 @@ function jsonResult(value) {
|
|
|
645
647
|
content: [{ type: "text", text: JSON.stringify(value) }],
|
|
646
648
|
};
|
|
647
649
|
}
|
|
650
|
+
async function sessionResult(action) {
|
|
651
|
+
try {
|
|
652
|
+
return jsonResult(await action());
|
|
653
|
+
}
|
|
654
|
+
catch (error) {
|
|
655
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
656
|
+
return {
|
|
657
|
+
isError: true,
|
|
658
|
+
content: [{
|
|
659
|
+
type: "text",
|
|
660
|
+
text: JSON.stringify({ code: message.split(":", 1)[0] || "SESSION_ERROR", message }),
|
|
661
|
+
}],
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
}
|
|
648
665
|
function capabilityErrorResult(operation, capabilityName, capability) {
|
|
649
666
|
return {
|
|
650
667
|
isError: true,
|
|
@@ -787,6 +804,99 @@ export function createMcpServer(runtime, options = {}) {
|
|
|
787
804
|
runtime.registerBuiltinSkills();
|
|
788
805
|
const server = new McpServer({ name: "framekit", version: FRAMEKIT_VERSION }, { instructions: EDITOR_FIRST_MCP_INSTRUCTIONS });
|
|
789
806
|
const nativeTransitionAssets = new Map();
|
|
807
|
+
const sessions = options.sessionDirectory ? new EditingSessionRepository(options.sessionDirectory) : undefined;
|
|
808
|
+
const materializations = sessions && options.materializationDirectory
|
|
809
|
+
? new SessionMaterializationJobs(options.materializationDirectory, sessions, options.sessionMaterializationPublisher)
|
|
810
|
+
: undefined;
|
|
811
|
+
const requireSessions = () => {
|
|
812
|
+
if (!sessions)
|
|
813
|
+
throw new Error("SESSION_STORAGE_UNAVAILABLE: configure a session directory");
|
|
814
|
+
return sessions;
|
|
815
|
+
};
|
|
816
|
+
const requireMaterializations = () => {
|
|
817
|
+
if (!materializations)
|
|
818
|
+
throw new Error("MATERIALIZATION_STORAGE_UNAVAILABLE: configure a materialization directory");
|
|
819
|
+
return materializations;
|
|
820
|
+
};
|
|
821
|
+
const sessionOperationSchema = z.array(z.unknown());
|
|
822
|
+
server.registerTool("session.create", {
|
|
823
|
+
description: "Create and atomically persist a provider-neutral editing session without mutating Final Cut.",
|
|
824
|
+
inputSchema: {
|
|
825
|
+
sessionId: z.string().min(1).optional(),
|
|
826
|
+
provider: z.object({ id: z.string().min(1), version: z.string().min(1).optional() }).optional(),
|
|
827
|
+
base: z.unknown(),
|
|
828
|
+
},
|
|
829
|
+
}, async ({ sessionId, provider, base }) => sessionResult(async () => requireSessions().create({
|
|
830
|
+
...(sessionId ? { sessionId } : {}),
|
|
831
|
+
...(provider ? { provider } : {}),
|
|
832
|
+
base: base,
|
|
833
|
+
})));
|
|
834
|
+
server.registerTool("session.inspect", {
|
|
835
|
+
description: "Inspect a persisted editing session and its exact base and desired Timeline IR.",
|
|
836
|
+
inputSchema: { sessionId: z.string().min(1) },
|
|
837
|
+
}, async ({ sessionId }) => sessionResult(async () => requireSessions().inspect(sessionId)));
|
|
838
|
+
server.registerTool("session.edit.preview", {
|
|
839
|
+
description: "Preview provider-neutral session edits without persisting or mutating Final Cut.",
|
|
840
|
+
inputSchema: {
|
|
841
|
+
sessionId: z.string().min(1),
|
|
842
|
+
expectedRevision: revisionValueSchema.optional(),
|
|
843
|
+
operations: sessionOperationSchema,
|
|
844
|
+
},
|
|
845
|
+
}, async ({ sessionId, expectedRevision, operations }) => sessionResult(async () => requireSessions().preview(sessionId, operations, expectedRevision)));
|
|
846
|
+
server.registerTool("session.edit.execute", {
|
|
847
|
+
description: "Apply edits only to a persisted session's desired Timeline IR.",
|
|
848
|
+
inputSchema: {
|
|
849
|
+
sessionId: z.string().min(1),
|
|
850
|
+
expectedRevision: revisionValueSchema.optional(),
|
|
851
|
+
operations: sessionOperationSchema,
|
|
852
|
+
},
|
|
853
|
+
}, async ({ sessionId, expectedRevision, operations }) => sessionResult(async () => requireSessions().execute(sessionId, operations, expectedRevision)));
|
|
854
|
+
server.registerTool("session.status", {
|
|
855
|
+
description: "Read editing-session readiness, provider binding, and revisions.",
|
|
856
|
+
inputSchema: { sessionId: z.string().min(1) },
|
|
857
|
+
}, async ({ sessionId }) => sessionResult(async () => requireSessions().status(sessionId)));
|
|
858
|
+
server.registerTool("session.reconcile", {
|
|
859
|
+
description: "Reconcile a fresh provider Timeline IR with the session base and desired state.",
|
|
860
|
+
inputSchema: {
|
|
861
|
+
sessionId: z.string().min(1),
|
|
862
|
+
provider: z.object({ id: z.string().min(1), version: z.string().min(1).optional() }),
|
|
863
|
+
providerState: z.unknown(),
|
|
864
|
+
},
|
|
865
|
+
}, async ({ sessionId, provider, providerState }) => sessionResult(async () => requireSessions().reconcile(sessionId, provider, providerState)));
|
|
866
|
+
server.registerTool("session.observe", {
|
|
867
|
+
description: "Bind read-only non-canonical Final Cut SQLite evidence to session freshness.",
|
|
868
|
+
inputSchema: { sessionId: z.string().min(1), sourcePath: z.string().min(1) },
|
|
869
|
+
}, async ({ sessionId, sourcePath }) => sessionResult(async () => {
|
|
870
|
+
if (!options.sqliteObservationProvider) {
|
|
871
|
+
throw new Error("FINAL_CUT_SQLITE_INSPECTION_UNAVAILABLE: no read-only observation provider is configured");
|
|
872
|
+
}
|
|
873
|
+
return requireSessions().observe(sessionId, sourcePath, options.sqliteObservationProvider);
|
|
874
|
+
}));
|
|
875
|
+
const sessionMaterializationTargetSchema = z.object({
|
|
876
|
+
provider: z.literal("final-cut"),
|
|
877
|
+
libraryUid: z.string().min(1),
|
|
878
|
+
eventUid: z.string().min(1),
|
|
879
|
+
projectUid: z.string().min(1),
|
|
880
|
+
sequenceUid: z.string().min(1),
|
|
881
|
+
eventName: z.string().min(1).optional(),
|
|
882
|
+
materialization: z.literal("versioned").optional(),
|
|
883
|
+
}).strict();
|
|
884
|
+
server.registerTool("session.materialize.preview", {
|
|
885
|
+
description: "Preview deterministic versioned FCPXML materialization without staging or publishing it.",
|
|
886
|
+
inputSchema: { sessionId: z.string().min(1), target: sessionMaterializationTargetSchema },
|
|
887
|
+
}, async ({ sessionId, target }) => sessionResult(async () => requireMaterializations().preview(sessionId, target)));
|
|
888
|
+
server.registerTool("session.materialize.execute", {
|
|
889
|
+
description: "Confirm, stage, checkpoint, and request publication of a versioned FCPXML project.",
|
|
890
|
+
inputSchema: { sessionId: z.string().min(1), target: sessionMaterializationTargetSchema, confirm: z.boolean() },
|
|
891
|
+
}, async ({ sessionId, target, confirm }) => sessionResult(async () => requireMaterializations().execute(sessionId, target, confirm)));
|
|
892
|
+
server.registerTool("session.materialize.status", {
|
|
893
|
+
description: "Inspect a persisted materialization job after completion, blockage, or server restart.",
|
|
894
|
+
inputSchema: { jobId: z.string().min(1) },
|
|
895
|
+
}, async ({ jobId }) => sessionResult(async () => requireMaterializations().status(jobId)));
|
|
896
|
+
server.registerTool("session.materialize.retry", {
|
|
897
|
+
description: "Resume a retryable persisted materialization job with its verified immutable artifact.",
|
|
898
|
+
inputSchema: { jobId: z.string().min(1) },
|
|
899
|
+
}, async ({ jobId }) => sessionResult(async () => requireMaterializations().retry(jobId)));
|
|
790
900
|
server.registerTool("connection.status", {
|
|
791
901
|
description: "Read Framekit's Final Cut connection state before editor-first capability discovery.",
|
|
792
902
|
inputSchema: {},
|
|
@@ -6,6 +6,8 @@ export * from "./editing/intent.js";
|
|
|
6
6
|
export * from "./editing/duration-policy.js";
|
|
7
7
|
export * from "./capabilities.js";
|
|
8
8
|
export * from "./timeline/snapshot-digest.js";
|
|
9
|
+
export * from "./timeline/editing-session.js";
|
|
10
|
+
export * from "./timeline/drift-reconciliation.js";
|
|
9
11
|
export * from "./context/project-catalog.js";
|
|
10
12
|
export * from "./speech/filler-removal.js";
|
|
11
13
|
export * from "./audio/dialogue-normalization.js";
|