@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.
- package/README.md +1 -0
- package/dist-package/adapters/final-cut/typescript/src/analyzers.js +68 -5
- package/dist-package/adapters/final-cut/typescript/src/canonical-recovery.js +31 -0
- package/dist-package/adapters/final-cut/typescript/src/canonical-verification.js +16 -0
- package/dist-package/adapters/final-cut/typescript/src/canonical.js +978 -98
- package/dist-package/adapters/final-cut/typescript/src/fcpxml.js +26 -7
- package/dist-package/adapters/final-cut/typescript/src/index.js +3 -0
- package/dist-package/adapters/final-cut/typescript/src/library-inspection.js +2 -0
- package/dist-package/adapters/final-cut/typescript/src/native.js +321 -19
- package/dist-package/adapters/final-cut/typescript/src/shadow-mutation.js +71 -17
- package/dist-package/adapters/final-cut/typescript/src/sqlite-experiment.js +472 -0
- package/dist-package/adapters/final-cut/typescript/src/sqlite-materialization.js +230 -0
- package/dist-package/apps/mcp-server/src/headless-sessions.js +47 -4
- package/dist-package/apps/mcp-server/src/main.js +33 -1
- package/dist-package/apps/mcp-server/src/routing.js +17 -0
- package/dist-package/apps/mcp-server/src/server.js +87 -28
- package/dist-package/packages/runtime/src/application/media-analysis-service.js +52 -6
- package/dist-package/packages/runtime/src/context/context-engine.js +313 -8
- package/dist-package/packages/runtime/src/context/context-service.js +5 -2
- package/dist-package/packages/runtime/src/context/project-catalog.js +58 -2
- package/dist-package/packages/runtime/src/domain/incremental-sync.js +153 -0
- package/dist-package/packages/runtime/src/domain/index.js +1 -0
- package/dist-package/packages/runtime/src/editing/edit-service.js +8 -2
- package/dist-package/packages/runtime/src/runtime.js +5 -2
- package/dist-package/packages/runtime/src/skills/builtin.js +99 -8
- package/dist-package/packages/runtime/src/skills/runtime.js +1 -0
- package/dist-package/packages/runtime/src/timeline/editing-session.js +13 -0
- package/dist-package/packages/runtime/src/timeline/snapshot-diff.js +169 -10
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { access } from "node:fs/promises";
|
|
3
|
-
import { bindSpeechAnalysis } from "../../../../packages/runtime/src/index.js";
|
|
3
|
+
import { bindSpeechAnalysis, sameMediaSourceIdentity } from "../../../../packages/runtime/src/index.js";
|
|
4
4
|
export function createCommandAnalyzers(options) {
|
|
5
5
|
return {
|
|
6
|
-
...(options.speechCommand ? {
|
|
6
|
+
...(options.speechCommand ? {
|
|
7
|
+
speechAnalyzer: new CommandSpeechAnalyzer({
|
|
8
|
+
command: options.speechCommand,
|
|
9
|
+
timeoutMs: options.timeoutMs,
|
|
10
|
+
...(options.speechProviderVersion ? { providerVersion: options.speechProviderVersion } : {}),
|
|
11
|
+
...(options.speechRequireVad ? { requireVad: true } : {}),
|
|
12
|
+
}),
|
|
13
|
+
} : {}),
|
|
7
14
|
...(options.audioCommand ? { audioAnalyzer: new CommandAudioAnalyzer({ command: options.audioCommand, timeoutMs: options.timeoutMs }) } : {}),
|
|
8
15
|
...(options.visualCommand ? { visualAnalyzer: new CommandVisualAnalyzer({ command: options.visualCommand, timeoutMs: options.timeoutMs }) } : {}),
|
|
9
16
|
...(options.metadataCommand ? { metadataAnalyzer: new CommandMetadataAnalyzer({ command: options.metadataCommand, timeoutMs: options.timeoutMs }) } : {}),
|
|
@@ -11,15 +18,31 @@ export function createCommandAnalyzers(options) {
|
|
|
11
18
|
}
|
|
12
19
|
export class CommandSpeechAnalyzer {
|
|
13
20
|
options;
|
|
14
|
-
descriptor
|
|
15
|
-
capabilities
|
|
21
|
+
descriptor;
|
|
22
|
+
capabilities;
|
|
16
23
|
constructor(options) {
|
|
17
24
|
this.options = options;
|
|
25
|
+
if (options.requireVad === true && !options.providerVersion?.trim()) {
|
|
26
|
+
throw new Error("ANALYZER_SETUP_REQUIRED: speech provider version is required when VAD is required");
|
|
27
|
+
}
|
|
28
|
+
this.descriptor = {
|
|
29
|
+
id: "command.speech",
|
|
30
|
+
provider: "command",
|
|
31
|
+
...(options.providerVersion ? { version: options.providerVersion } : {}),
|
|
32
|
+
};
|
|
33
|
+
this.capabilities = { transcription: true, vad: options.requireVad === true };
|
|
18
34
|
}
|
|
19
35
|
async analyze(input, range) {
|
|
20
36
|
const result = await runCommand(this.options, { ...input, range }, "speech");
|
|
21
37
|
try {
|
|
22
|
-
|
|
38
|
+
if (this.options.requireVad) {
|
|
39
|
+
requireStrictSpeechProvenance(result, input, range, this.descriptor);
|
|
40
|
+
}
|
|
41
|
+
const analysis = bindSpeechAnalysis(result, { input, range, provider: this.descriptor });
|
|
42
|
+
if (this.options.requireVad && analysis.capability !== "transcription-plus-vad") {
|
|
43
|
+
throw new Error("ANALYZER_INVALID_OUTPUT: configured speech provider must return VAD evidence");
|
|
44
|
+
}
|
|
45
|
+
return analysis;
|
|
23
46
|
}
|
|
24
47
|
catch (error) {
|
|
25
48
|
throw new Error(`ANALYZER_INVALID_OUTPUT: speech analyzer returned invalid JSON or schema: ${String(error)}`);
|
|
@@ -127,6 +150,46 @@ function sourceIdentityOf(media) {
|
|
|
127
150
|
...(media.duration !== undefined ? { duration: media.duration } : {}),
|
|
128
151
|
};
|
|
129
152
|
}
|
|
153
|
+
function requireStrictSpeechProvenance(value, input, range, provider) {
|
|
154
|
+
if (!value || typeof value !== "object") {
|
|
155
|
+
throw new Error("ANALYZER_INVALID_OUTPUT: speech response must include complete trusted provenance");
|
|
156
|
+
}
|
|
157
|
+
const record = value;
|
|
158
|
+
const required = ["schemaVersion", "mediaId", "sourceIdentity", "requestedRange", "revision", "provider"];
|
|
159
|
+
const missing = required.filter((field) => record[field] === undefined);
|
|
160
|
+
if (missing.length > 0) {
|
|
161
|
+
throw new Error(`ANALYZER_INVALID_OUTPUT: speech response is missing provenance: ${missing.join(", ")}`);
|
|
162
|
+
}
|
|
163
|
+
if (!sameAnalyzerDescriptor(record.provider, provider)) {
|
|
164
|
+
throw new Error("ANALYZER_INVALID_OUTPUT: speech response provider provenance does not match the configured provider");
|
|
165
|
+
}
|
|
166
|
+
const sourceIdentity = sourceIdentityOf(input.media);
|
|
167
|
+
if (record.mediaId !== sourceIdentity.mediaId
|
|
168
|
+
|| !sameMediaSourceIdentity(record.sourceIdentity, sourceIdentity)) {
|
|
169
|
+
throw new Error("ANALYZER_INVALID_OUTPUT: speech response source identity does not match the requested media");
|
|
170
|
+
}
|
|
171
|
+
if (record.schemaVersion !== 1) {
|
|
172
|
+
throw new Error("ANALYZER_INVALID_OUTPUT: speech response schema version is not supported");
|
|
173
|
+
}
|
|
174
|
+
const expectedRange = range ?? (input.media.duration === undefined ? undefined : { start: 0, end: input.media.duration });
|
|
175
|
+
if (expectedRange && !sameRange(record.requestedRange, expectedRange)) {
|
|
176
|
+
throw new Error("ANALYZER_INVALID_OUTPUT: speech response range does not match the runtime request");
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function sameAnalyzerDescriptor(value, expected) {
|
|
180
|
+
if (!value || typeof value !== "object")
|
|
181
|
+
return false;
|
|
182
|
+
const descriptor = value;
|
|
183
|
+
return descriptor.id === expected.id
|
|
184
|
+
&& descriptor.provider === expected.provider
|
|
185
|
+
&& descriptor.version === expected.version;
|
|
186
|
+
}
|
|
187
|
+
function sameRange(value, expected) {
|
|
188
|
+
if (!value || typeof value !== "object")
|
|
189
|
+
return false;
|
|
190
|
+
const range = value;
|
|
191
|
+
return range.start === expected.start && range.end === expected.end;
|
|
192
|
+
}
|
|
130
193
|
function validateResult(value, kind) {
|
|
131
194
|
if (!value || typeof value !== "object")
|
|
132
195
|
throw new Error("result must be an object");
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { assertTimelineTargetReadAfterWrite, canonicalSnapshotDigest, } from "../../../../packages/runtime/src/index.js";
|
|
2
|
+
/** Recover one verified native mutation and prove the original target digest. */
|
|
3
|
+
export async function recoverCanonicalNativeMutation(request) {
|
|
4
|
+
if (!request.operationId.trim()) {
|
|
5
|
+
throw new Error("FINAL_CUT_CANONICAL_ROLLBACK_FAILED: native operation handle is missing");
|
|
6
|
+
}
|
|
7
|
+
let undone;
|
|
8
|
+
try {
|
|
9
|
+
undone = await request.undo(request.operationId);
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
throw new Error(`FINAL_CUT_CANONICAL_ROLLBACK_FAILED: native Undo failed: ${String(error)}`);
|
|
13
|
+
}
|
|
14
|
+
if (!undone.undone || undone.verification?.verified !== true) {
|
|
15
|
+
throw new Error("FINAL_CUT_CANONICAL_ROLLBACK_FAILED: native Undo did not verify restoration");
|
|
16
|
+
}
|
|
17
|
+
const restored = await request.readSnapshot();
|
|
18
|
+
assertTimelineTargetReadAfterWrite(request.target, request.before, restored);
|
|
19
|
+
const beforeDigest = canonicalSnapshotDigest(request.before);
|
|
20
|
+
const restoredDigest = canonicalSnapshotDigest(restored);
|
|
21
|
+
if (restoredDigest !== beforeDigest) {
|
|
22
|
+
throw new Error("FINAL_CUT_CANONICAL_ROLLBACK_FAILED: restored canonical digest does not match the pre-edit state");
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
attempted: true,
|
|
26
|
+
succeeded: true,
|
|
27
|
+
operationId: request.operationId,
|
|
28
|
+
beforeDigest,
|
|
29
|
+
restoredDigest,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { assertTimelineTargetReadAfterWrite, canonicalSnapshotDigest, diffSnapshots, } from "../../../../packages/runtime/src/index.js";
|
|
2
|
+
/** Validate one canonical before/after pair and return its durable evidence. */
|
|
3
|
+
export function verifyCanonicalReadback(before, after, target, options = {}) {
|
|
4
|
+
const beforeDigest = canonicalSnapshotDigest(before);
|
|
5
|
+
const afterDigest = canonicalSnapshotDigest(after);
|
|
6
|
+
if (beforeDigest === afterDigest) {
|
|
7
|
+
throw new Error("FINAL_CUT_CANONICAL_READBACK_FAILED: native edit did not change the canonical digest");
|
|
8
|
+
}
|
|
9
|
+
if (after.revision.id === before.revision.id || after.revision.sequence <= before.revision.sequence) {
|
|
10
|
+
throw new Error("FINAL_CUT_CANONICAL_READBACK_FAILED: revision did not advance after native mutation");
|
|
11
|
+
}
|
|
12
|
+
assertTimelineTargetReadAfterWrite(target, before, after);
|
|
13
|
+
const diff = diffSnapshots(before, after);
|
|
14
|
+
options.validateDiff?.(diff);
|
|
15
|
+
return { beforeDigest, afterDigest, diff };
|
|
16
|
+
}
|