@morshoto/framekit 0.1.11 → 0.1.13

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.
Files changed (29) hide show
  1. package/README.md +1 -0
  2. package/dist-package/adapters/final-cut/typescript/src/analyzers.js +68 -5
  3. package/dist-package/adapters/final-cut/typescript/src/canonical-recovery.js +31 -0
  4. package/dist-package/adapters/final-cut/typescript/src/canonical-verification.js +16 -0
  5. package/dist-package/adapters/final-cut/typescript/src/canonical.js +978 -98
  6. package/dist-package/adapters/final-cut/typescript/src/fcpxml.js +26 -7
  7. package/dist-package/adapters/final-cut/typescript/src/index.js +3 -0
  8. package/dist-package/adapters/final-cut/typescript/src/library-inspection.js +2 -0
  9. package/dist-package/adapters/final-cut/typescript/src/native.js +321 -19
  10. package/dist-package/adapters/final-cut/typescript/src/shadow-mutation.js +71 -17
  11. package/dist-package/adapters/final-cut/typescript/src/sqlite-experiment.js +472 -0
  12. package/dist-package/adapters/final-cut/typescript/src/sqlite-materialization.js +230 -0
  13. package/dist-package/apps/mcp-server/src/headless-sessions.js +47 -4
  14. package/dist-package/apps/mcp-server/src/main.js +33 -1
  15. package/dist-package/apps/mcp-server/src/routing.js +17 -0
  16. package/dist-package/apps/mcp-server/src/server.js +87 -28
  17. package/dist-package/packages/runtime/src/application/media-analysis-service.js +52 -6
  18. package/dist-package/packages/runtime/src/context/context-engine.js +313 -8
  19. package/dist-package/packages/runtime/src/context/context-service.js +5 -2
  20. package/dist-package/packages/runtime/src/context/project-catalog.js +58 -2
  21. package/dist-package/packages/runtime/src/domain/incremental-sync.js +153 -0
  22. package/dist-package/packages/runtime/src/domain/index.js +1 -0
  23. package/dist-package/packages/runtime/src/editing/edit-service.js +8 -2
  24. package/dist-package/packages/runtime/src/runtime.js +5 -2
  25. package/dist-package/packages/runtime/src/skills/builtin.js +99 -8
  26. package/dist-package/packages/runtime/src/skills/runtime.js +1 -0
  27. package/dist-package/packages/runtime/src/timeline/editing-session.js +13 -0
  28. package/dist-package/packages/runtime/src/timeline/snapshot-diff.js +169 -10
  29. package/package.json +9 -5
@@ -21,6 +21,7 @@ const TIMELINE_KINDS = new Set([
21
21
  */
22
22
  export class FcpxmlDocumentAdapter {
23
23
  filePath;
24
+ target;
24
25
  parser = new XMLParser({
25
26
  preserveOrder: true,
26
27
  ignoreAttributes: false,
@@ -37,8 +38,9 @@ export class FcpxmlDocumentAdapter {
37
38
  sequence = 0;
38
39
  fileSignature;
39
40
  history = new Map();
40
- constructor(filePath) {
41
+ constructor(filePath, target) {
41
42
  this.filePath = filePath;
43
+ this.target = target;
42
44
  }
43
45
  async getIdentity() {
44
46
  return { name: "Final Cut Pro", version: "FCPXML", backend: "fcpxml-document" };
@@ -125,9 +127,10 @@ export class FcpxmlDocumentAdapter {
125
127
  const sequence = sequenceNode ?? {};
126
128
  const spine = findElement(sequence, "spine") ?? {};
127
129
  const projectName = String(attribute(project, "name") ?? "Final Cut Project");
128
- const projectId = stableProjectId(project);
130
+ const identity = this.identity(project, sequenceNode);
131
+ const projectId = identity.projectId;
129
132
  const sequenceName = String(attribute(sequenceNode ?? {}, "name") ?? projectName);
130
- const timelineId = stableTimelineId(project, sequenceNode);
133
+ const timelineId = identity.sequenceId;
131
134
  const elements = timelineEntries(spine);
132
135
  const storyElements = elements
133
136
  .map((entry) => ({ kind: entry.kind, element: this.storyElementFromXml(entry, timelineId) }))
@@ -162,10 +165,11 @@ export class FcpxmlDocumentAdapter {
162
165
  await this.ensureLoaded();
163
166
  const project = this.projectNode();
164
167
  const projectName = String(attribute(project, "name") ?? "Final Cut Project");
165
- const projectId = stableProjectId(project);
166
168
  const sequence = findElement(project, "sequence");
169
+ const identity = this.identity(project, sequence);
170
+ const projectId = identity.projectId;
167
171
  const sequenceName = String(attribute(sequence ?? {}, "name") ?? projectName);
168
- const sequenceId = stableSequenceId(sequence);
172
+ const sequenceId = identity.sequenceId;
169
173
  return {
170
174
  projects: [{
171
175
  id: projectId,
@@ -279,6 +283,20 @@ export class FcpxmlDocumentAdapter {
279
283
  throw new Error(`CAPABILITY_UNAVAILABLE: FCPXML ${phase} does not support ${operation.type}`);
280
284
  }
281
285
  }
286
+ identity(project, sequence) {
287
+ const projectUid = immutableUid(project, "PROJECT");
288
+ if (this.target && projectUid !== this.target.projectUid) {
289
+ throw new Error(`TARGET_MISMATCH: exported project UID ${projectUid} does not match live project UID ${this.target.projectUid}`);
290
+ }
291
+ const exportedSequenceUid = sequence ? attribute(sequence, "uid") : undefined;
292
+ if (this.target && exportedSequenceUid !== undefined && String(exportedSequenceUid) !== this.target.sequenceId) {
293
+ throw new Error(`TARGET_MISMATCH: exported sequence UID ${String(exportedSequenceUid)} does not match live sequence UID ${this.target.sequenceId}`);
294
+ }
295
+ return {
296
+ projectId: this.target?.projectId ?? `fcpxml:project:${projectUid}`,
297
+ sequenceId: this.target?.sequenceId ?? stableSequenceId(sequence),
298
+ };
299
+ }
282
300
  applyOperation(operation) {
283
301
  const project = this.projectNode();
284
302
  const sequenceNode = findElement(project, "sequence");
@@ -288,7 +306,7 @@ export class FcpxmlDocumentAdapter {
288
306
  if (!spine)
289
307
  throw new Error("FCPXML_SCHEMA_UNSUPPORTED: sequence spine is required");
290
308
  const sequence = sequenceNode;
291
- const timelineId = stableTimelineId(project, sequenceNode);
309
+ const timelineId = this.identity(project, sequenceNode).sequenceId;
292
310
  if (operation.type === "timeline.picture-in-picture.add") {
293
311
  this.applyPictureInPicture(spine, timelineId, operation);
294
312
  this.updateSequenceDuration(sequence, spine);
@@ -901,9 +919,10 @@ export class FcpxmlDocumentAdapter {
901
919
  .map(({ node }) => {
902
920
  const durationValue = attribute(node, "duration");
903
921
  const mediaKind = mediaKindFromResource(node);
922
+ const originalMedia = storyEntries(node).find(({ kind, node: representation }) => kind === "media-rep" && attribute(representation, "kind") === "original-media")?.node;
904
923
  return {
905
924
  mediaId: String(attribute(node, "id") ?? ""),
906
- source: resolveMediaSource(String(attribute(node, "src") ?? attribute(node, "name") ?? attribute(node, "id") ?? ""), this.filePath),
925
+ source: resolveMediaSource(String(attribute(node, "src") ?? (originalMedia && attribute(originalMedia, "src")) ?? attribute(node, "name") ?? attribute(node, "id") ?? ""), this.filePath),
907
926
  ...(mediaKind ? { mediaKind } : {}),
908
927
  ...(durationValue !== undefined ? { duration: parseSeconds(durationValue) } : {}),
909
928
  };
@@ -2,6 +2,8 @@ export * from "./fcpxml.js";
2
2
  export * from "./live.js";
3
3
  export * from "./connection.js";
4
4
  export * from "./canonical.js";
5
+ export * from "./canonical-recovery.js";
6
+ export * from "./canonical-verification.js";
5
7
  export * from "./session.js";
6
8
  export * from "./analyzers.js";
7
9
  export * from "./assets.js";
@@ -14,6 +16,7 @@ export * from "./background-export.js";
14
16
  export * from "./background-materialization.js";
15
17
  export * from "./library-inspection.js";
16
18
  export * from "./sqlite-inspection.js";
19
+ export * from "./sqlite-experiment.js";
17
20
  export * from "./shadow-mutation.js";
18
21
  export * from "./native-operation.js";
19
22
  export * from "./native-session.js";
@@ -174,6 +174,8 @@ function isTimeoutFailure(error) {
174
174
  const candidate = error;
175
175
  if (candidate.code === "ETIMEDOUT")
176
176
  return true;
177
+ if (candidate.killed === true && candidate.signal === "SIGTERM")
178
+ return true;
177
179
  if (typeof candidate.message === "string" && /timed out/i.test(candidate.message))
178
180
  return true;
179
181
  }