@morshoto/framekit 0.1.16 → 0.1.17

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.
@@ -1,7 +1,8 @@
1
- import { randomUUID } from "node:crypto";
1
+ import { createHash, randomUUID } from "node:crypto";
2
2
  import { readdir, readFile, rename, writeFile, mkdir } from "node:fs/promises";
3
- import { join } from "node:path";
3
+ import { dirname, join } from "node:path";
4
4
  import { FramekitProjectStore, LocalMediaRegistrar, ProjectTransactionService, createFramekitRenderRequest, renderAndVerifyFramekitProject, } from "../../../packages/runtime/src/index.js";
5
+ import { compileTimelineIrToFcpxml, } from "../../../adapters/final-cut/typescript/src/index.js";
5
6
  export class HeadlessProjectService {
6
7
  directory;
7
8
  mediaProbe;
@@ -69,6 +70,70 @@ export class HeadlessProjectService {
69
70
  target: command.target ?? { projectId, sequenceId },
70
71
  });
71
72
  }
73
+ async previewRoughCut(request) {
74
+ const prepared = await this.prepareRoughCut(request);
75
+ const transaction = new ProjectTransactionService(this.store(request.projectId), { clock: this.clock });
76
+ const preview = await transaction.preview(prepared.command);
77
+ const fcpxml = compileTimelineIrToFcpxml(preview.after.timeline, { target: request.fcpxml.target });
78
+ return {
79
+ ...preview,
80
+ plan: structuredClone(request.plan),
81
+ planDigest: prepared.planDigest,
82
+ provenance: prepared.provenance,
83
+ outputIntent: prepared.outputIntent,
84
+ fcpxml: selectFcpxmlMetadata(fcpxml),
85
+ };
86
+ }
87
+ async executeRoughCut(request) {
88
+ if (request.approved !== true) {
89
+ throw new Error("HEADLESS_ROUGH_CUT_APPROVAL_REQUIRED: set approved=true after reviewing the preview");
90
+ }
91
+ const prepared = await this.prepareRoughCut(request);
92
+ if (request.planDigest !== prepared.planDigest) {
93
+ throw new Error("HEADLESS_ROUGH_CUT_PLAN_MISMATCH: planDigest does not match the submitted rough-cut plan");
94
+ }
95
+ const transaction = new ProjectTransactionService(this.store(request.projectId), { clock: this.clock });
96
+ const preview = await transaction.preview(prepared.command);
97
+ const fcpxml = compileTimelineIrToFcpxml(preview.after.timeline, { target: request.fcpxml.target });
98
+ const renderRequest = createFramekitRenderRequest({
99
+ timeline: preview.after.timeline,
100
+ target: { projectId: request.projectId, sequenceId: request.sequenceId },
101
+ revision: preview.after.timeline.revision,
102
+ parameters: request.render,
103
+ });
104
+ if (!this.renderer || !this.verifier) {
105
+ throw new Error("HEADLESS_ROUGH_CUT_RENDER_UNAVAILABLE: renderer and verifier are not configured");
106
+ }
107
+ const outcome = await renderAndVerifyFramekitProject(renderRequest, this.renderer, this.verifier);
108
+ const renderId = `render-${randomUUID()}`;
109
+ const renderRecord = {
110
+ renderId,
111
+ projectId: request.projectId,
112
+ sequenceId: request.sequenceId,
113
+ requestedRevision: renderRequest.projectRevision,
114
+ createdAt: this.clock(),
115
+ status: outcome.status,
116
+ outcome,
117
+ };
118
+ await this.saveRender(renderRecord);
119
+ if (outcome.status !== "passed") {
120
+ throw new Error(`HEADLESS_ROUGH_CUT_RENDER_FAILED: render verification status was ${outcome.status}; inspect ${renderId}`);
121
+ }
122
+ const fcpxmlArtifact = await writeVerifiedFcpxml(request.fcpxml.path, fcpxml.xml, fcpxml.digest, request.fcpxml.overwrite === true);
123
+ const committed = await transaction.execute(prepared.command);
124
+ return {
125
+ ...preview,
126
+ plan: structuredClone(request.plan),
127
+ planDigest: prepared.planDigest,
128
+ provenance: prepared.provenance,
129
+ outputIntent: prepared.outputIntent,
130
+ fcpxml: selectFcpxmlMetadata(fcpxml),
131
+ committed: true,
132
+ render: { renderId, status: "passed", outcome },
133
+ fcpxmlArtifact,
134
+ transaction: committed,
135
+ };
136
+ }
72
137
  async render(projectId, sequenceId, parameters, expectedRevision) {
73
138
  if (!this.renderer || !this.verifier)
74
139
  throw new Error("HEADLESS_RENDER_UNAVAILABLE: renderer and verifier are not configured");
@@ -118,6 +183,172 @@ export class HeadlessProjectService {
118
183
  await writeFile(temporary, `${JSON.stringify(record)}\n`, { encoding: "utf8", flag: "wx" });
119
184
  await rename(temporary, path);
120
185
  }
186
+ async prepareRoughCut(request) {
187
+ await this.open(request.projectId);
188
+ const project = await this.store(request.projectId).load();
189
+ if (project.timeline.sequence.id !== request.sequenceId) {
190
+ throw new Error("HEADLESS_ROUGH_CUT_TARGET_MISMATCH: sequenceId does not match the persisted project");
191
+ }
192
+ if (!sameRevision(project.timeline.revision, request.plan.revision)) {
193
+ throw new Error("HEADLESS_ROUGH_CUT_STALE_REVISION: rough-cut plan revision does not match the persisted project");
194
+ }
195
+ if (!request.plan.shots.length)
196
+ throw new Error("HEADLESS_ROUGH_CUT_EMPTY_PLAN: rough-cut plan must contain at least one shot");
197
+ const operations = structuredClone(request.operations ?? []);
198
+ const sourceAudioPolicy = request.sourceAudioPolicy ?? "preserve-and-mix";
199
+ const outputIntent = {
200
+ sourceAudioPolicy,
201
+ render: structuredClone(request.render),
202
+ fcpxml: {
203
+ path: request.fcpxml.path,
204
+ target: structuredClone(request.fcpxml.target),
205
+ overwrite: request.fcpxml.overwrite === true,
206
+ },
207
+ };
208
+ const planDigest = digestRoughCutPlan(request.plan, operations, outputIntent);
209
+ const existingOccurrenceIds = new Set(project.timeline.sequence.occurrences.map(({ id }) => id));
210
+ const resourceByMediaId = new Map(project.timeline.resources.map((resource) => [resource.id, resource]));
211
+ const provenance = [];
212
+ const planOperations = [];
213
+ for (const shot of request.plan.shots) {
214
+ const shotWithEvidence = shot;
215
+ const occurrenceId = `rough-cut-${shot.order}`;
216
+ if (existingOccurrenceIds.has(occurrenceId)) {
217
+ throw new Error(`HEADLESS_ROUGH_CUT_OCCURRENCE_COLLISION: ${occurrenceId} already exists`);
218
+ }
219
+ existingOccurrenceIds.add(occurrenceId);
220
+ const resource = resourceByMediaId.get(shot.sourceIdentity.mediaId);
221
+ if (!resource)
222
+ throw new Error(`HEADLESS_ROUGH_CUT_SOURCE_NOT_FOUND: ${shot.sourceIdentity.mediaId}`);
223
+ assertSourceIdentity(resource, shot.sourceIdentity);
224
+ const sourceStartTime = shot.range.startTime ?? secondsToRational(shot.range.start);
225
+ const durationTime = shot.range.durationTime ?? secondsToRational(shot.range.end - shot.range.start);
226
+ assertSourceRange(resource, shot.range, sourceStartTime, durationTime);
227
+ planOperations.push({
228
+ type: "insert-occurrence",
229
+ placement: "append",
230
+ occurrence: {
231
+ id: occurrenceId,
232
+ name: `Rough cut ${shot.order}: ${shot.rationale}`,
233
+ startTime: { value: "0", timescale: "1" },
234
+ durationTime,
235
+ sourceStartTime,
236
+ track: 0,
237
+ role: "video",
238
+ mediaId: resource.id,
239
+ binding: { provider: "framekit.rough-cut", kind: "occurrence", identity: `${planDigest}:${shot.order}` },
240
+ },
241
+ });
242
+ provenance.push({
243
+ order: shot.order,
244
+ occurrenceId,
245
+ mediaId: resource.id,
246
+ sourceIdentity: structuredClone(shot.sourceIdentity),
247
+ sourceRange: structuredClone(shot.range),
248
+ confidence: shot.confidence,
249
+ matchedProperties: [...shot.matchedProperties],
250
+ rationale: shot.rationale,
251
+ ...(shotWithEvidence.evidence ? { evidence: structuredClone(shotWithEvidence.evidence) } : {}),
252
+ });
253
+ }
254
+ const editOperations = [...planOperations, ...operations];
255
+ const command = {
256
+ schemaVersion: 1,
257
+ target: { projectId: request.projectId, sequenceId: request.sequenceId },
258
+ expectedRevision: structuredClone(request.plan.revision),
259
+ operations: editOperations,
260
+ };
261
+ return { command, planDigest, provenance, outputIntent };
262
+ }
263
+ }
264
+ function digestRoughCutPlan(plan, operations, outputIntent) {
265
+ return createHash("sha256").update(stableJson({ plan, operations, outputIntent })).digest("hex");
266
+ }
267
+ function stableJson(value) {
268
+ if (value === null || typeof value !== "object")
269
+ return JSON.stringify(value);
270
+ if (Array.isArray(value))
271
+ return `[${value.map(stableJson).join(",")}]`;
272
+ return `{${Object.entries(value).filter(([, child]) => child !== undefined).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => `${JSON.stringify(key)}:${stableJson(child)}`).join(",")}}`;
273
+ }
274
+ function assertSourceIdentity(resource, source) {
275
+ if (resource.source !== source.source)
276
+ throw new Error(`HEADLESS_ROUGH_CUT_SOURCE_MISMATCH: source path differs for ${source.mediaId}`);
277
+ if (source.sourceDigest !== undefined && resource.sourceDigest !== source.sourceDigest) {
278
+ throw new Error(`HEADLESS_ROUGH_CUT_SOURCE_MISMATCH: source digest differs for ${source.mediaId}`);
279
+ }
280
+ if (source.mediaKind !== undefined && resource.mediaKind !== source.mediaKind) {
281
+ throw new Error(`HEADLESS_ROUGH_CUT_SOURCE_MISMATCH: media kind differs for ${source.mediaId}`);
282
+ }
283
+ if (resource.mediaKind !== "video")
284
+ throw new Error(`HEADLESS_ROUGH_CUT_VIDEO_REQUIRED: ${source.mediaId}`);
285
+ if (source.duration !== undefined && resource.metadata?.durationTime !== undefined
286
+ && Math.abs(source.duration - rationalSeconds(resource.metadata.durationTime)) > 0.01) {
287
+ throw new Error(`HEADLESS_ROUGH_CUT_SOURCE_MISMATCH: source duration differs for ${source.mediaId}`);
288
+ }
289
+ }
290
+ function assertSourceRange(resource, range, sourceStartTime, durationTime) {
291
+ if (!Number.isFinite(range.start) || !Number.isFinite(range.end) || range.start < 0 || range.end <= range.start) {
292
+ throw new Error("HEADLESS_ROUGH_CUT_RANGE_INVALID: source range must be finite and non-empty");
293
+ }
294
+ if (resource.metadata?.durationTime !== undefined && range.end > rationalSeconds(resource.metadata.durationTime) + 0.001) {
295
+ throw new Error(`HEADLESS_ROUGH_CUT_RANGE_INVALID: source range exceeds ${resource.id}`);
296
+ }
297
+ if (rationalSeconds(sourceStartTime) < 0 || rationalSeconds(durationTime) <= 0
298
+ || Math.abs(rationalSeconds(sourceStartTime) - range.start) > 0.001
299
+ || Math.abs(rationalSeconds(durationTime) - (range.end - range.start)) > 0.001) {
300
+ throw new Error("HEADLESS_ROUGH_CUT_RANGE_INVALID: rational source range must be non-negative and non-empty");
301
+ }
302
+ }
303
+ function secondsToRational(seconds) {
304
+ const timescale = 1_000_000;
305
+ const value = Math.round(seconds * timescale);
306
+ const divisor = greatestCommonDivisor(Math.abs(value), timescale);
307
+ return { value: String(value / divisor), timescale: String(timescale / divisor) };
308
+ }
309
+ function rationalSeconds(time) {
310
+ return Number(time.value) / Number(time.timescale);
311
+ }
312
+ function greatestCommonDivisor(left, right) {
313
+ while (right !== 0) {
314
+ const remainder = left % right;
315
+ left = right;
316
+ right = remainder;
317
+ }
318
+ return left || 1;
319
+ }
320
+ function sameRevision(left, right) {
321
+ return left.id === right.id && left.sequence === right.sequence && left.timestamp === right.timestamp;
322
+ }
323
+ function selectFcpxmlMetadata(result) {
324
+ return {
325
+ digest: result.digest,
326
+ target: structuredClone(result.target),
327
+ destination: structuredClone(result.destination),
328
+ coverage: structuredClone(result.coverage),
329
+ provenance: structuredClone(result.provenance),
330
+ };
331
+ }
332
+ async function writeVerifiedFcpxml(path, xml, digest, overwrite) {
333
+ await mkdir(dirname(path), { recursive: true });
334
+ if (!overwrite) {
335
+ try {
336
+ await readFile(path);
337
+ throw new Error(`HEADLESS_ROUGH_CUT_FCPXML_EXISTS: refusing to overwrite ${path}`);
338
+ }
339
+ catch (error) {
340
+ if (error.code !== "ENOENT")
341
+ throw error;
342
+ }
343
+ }
344
+ const temporary = `${path}.${randomUUID()}.tmp`;
345
+ await writeFile(temporary, xml, { encoding: "utf8", flag: "wx" });
346
+ await rename(temporary, path);
347
+ const persisted = await readFile(path, "utf8");
348
+ const persistedDigest = createHash("sha256").update(persisted).digest("hex");
349
+ if (persistedDigest !== digest)
350
+ throw new Error("HEADLESS_ROUGH_CUT_FCPXML_VERIFY_FAILED: persisted XML digest differs from the compiled artifact");
351
+ return { path, digest, bytes: Buffer.byteLength(persisted), verified: true };
121
352
  }
122
353
  function toSummary(project, path) {
123
354
  return {
@@ -4,7 +4,7 @@ import { join } from "node:path";
4
4
  import { InMemoryEditorAdapter } from "../../../packages/testkit/src/index.js";
5
5
  import { createCommandAnalyzers, createFinalCutLiveAdapter, FcpxmlDocumentAdapter, FinalCutAssetRegistry, FinalCutMediaRegistry, FinalCutConnectionManager, assertCanonicalProviderConfiguration, FinalCutCanonicalNativeProvider, FinalCutCanonicalSnapshotSource, FinalCutLibraryInspectionProvider, FinalCutNativeAutomationAdapter, createFinalCutNativeTargetResolver, DisposableNativeEditWorkflow, FinalCutBackgroundMaterializationPublisher, FinalCutProjectPublisher, FinalCutSqliteInspectionProvider, FinalCutVideoExporter, FinalCutSessionAdapter, createNativeOperationLease, createDisposableNativeOperationSession, isFinalCutVideoProbeAvailable, } from "../../../adapters/final-cut/typescript/src/index.js";
6
6
  import { FixtureAudioAnalyzer, FixtureMetadataAnalyzer, FixtureSpeechAnalyzer, FixtureVisualAnalyzer } from "../../../packages/testkit/src/index.js";
7
- import { AgentVideoRuntime } from "../../../packages/runtime/src/index.js";
7
+ import { AgentVideoRuntime, JsonSemanticMediaIndexStore } from "../../../packages/runtime/src/index.js";
8
8
  import { createMcpServer } from "./server.js";
9
9
  import { createCanonicalSessionChangeSource } from "./headless-sessions.js";
10
10
  import { HeadlessProjectService } from "./headless-projects.js";
@@ -164,6 +164,7 @@ const editor = liveMode
164
164
  : {}),
165
165
  })
166
166
  : fixture;
167
+ const framekitStateDirectory = process.env.FRAMEKIT_STATE_DIR ?? join(homedir(), ".framekit");
167
168
  const analyzers = liveMode
168
169
  ? createCommandAnalyzers({
169
170
  speechCommand: process.env.FRAMEKIT_SPEECH_ANALYZER,
@@ -180,8 +181,10 @@ const analyzers = liveMode
180
181
  visualAnalyzer: new FixtureVisualAnalyzer(),
181
182
  metadataAnalyzer: new FixtureMetadataAnalyzer(),
182
183
  };
183
- const runtime = new AgentVideoRuntime(editor, analyzers);
184
- const framekitStateDirectory = process.env.FRAMEKIT_STATE_DIR ?? join(homedir(), ".framekit");
184
+ const runtime = new AgentVideoRuntime(editor, {
185
+ ...analyzers,
186
+ semanticMediaIndexStore: new JsonSemanticMediaIndexStore(join(framekitStateDirectory, "semantic-media-index.json")),
187
+ });
185
188
  const headlessProjects = new HeadlessProjectService({
186
189
  directory: join(framekitStateDirectory, "projects"),
187
190
  mediaProbe: new FfmpegMediaMetadataProbe(),
@@ -50,6 +50,10 @@ const mediaIndexQuerySchema = z.object({
50
50
  range: rangeSchema.optional(),
51
51
  capabilities: z.array(z.enum(["metadata", "speech", "audio", "noise", "visual"])).optional(),
52
52
  });
53
+ const timelineSemanticContextQuerySchema = z.object({
54
+ query: z.string().optional(),
55
+ occurrenceIds: z.array(z.string().min(1)).optional(),
56
+ }).strict();
53
57
  const roughCutPlanSchema = mediaIndexQuerySchema.extend({
54
58
  maxShots: z.number().int().positive().optional(),
55
59
  });
@@ -1152,6 +1156,68 @@ export function createMcpServer(runtime, options = {}) {
1152
1156
  frameRate: rationalTimeSchema,
1153
1157
  overwrite: z.boolean().optional(),
1154
1158
  }).strict();
1159
+ const roughCutExecutionPlanSchema = z.object({
1160
+ planner: z.object({ id: z.string().min(1), version: z.number().int().nonnegative() }).strict(),
1161
+ revision: revisionValueSchema,
1162
+ query: z.record(z.unknown()),
1163
+ shots: z.array(z.object({
1164
+ order: z.number().int().positive(),
1165
+ sourceIdentity: z.object({
1166
+ mediaId: z.string().min(1),
1167
+ source: z.string().min(1),
1168
+ sourceDigest: z.string().optional(),
1169
+ mediaKind: z.enum(["video", "audio"]).optional(),
1170
+ duration: z.number().finite().positive().optional(),
1171
+ }).strict(),
1172
+ range: z.object({
1173
+ start: z.number().finite().nonnegative(),
1174
+ end: z.number().finite().positive(),
1175
+ startTime: rationalTimeSchema.optional(),
1176
+ durationTime: rationalTimeSchema.optional(),
1177
+ }).strict(),
1178
+ confidence: z.number().finite().nonnegative(),
1179
+ matchedProperties: z.array(z.string()),
1180
+ rationale: z.string().min(1),
1181
+ evidence: z.object({
1182
+ kind: z.literal("speech"),
1183
+ transcript: z.string(),
1184
+ wordCount: z.number().int().nonnegative(),
1185
+ averageWordConfidence: z.number().finite().min(0).max(1),
1186
+ vad: z.object({
1187
+ kind: z.enum(["speech", "silence", "breath", "laughter", "noise"]),
1188
+ confidence: z.number().finite().min(0).max(1).optional(),
1189
+ }).strict().optional(),
1190
+ audio: z.object({
1191
+ integratedLufs: z.number().finite().optional(),
1192
+ truePeakDb: z.number().finite().optional(),
1193
+ silenceMs: z.number().finite().nonnegative().optional(),
1194
+ }).strict().optional(),
1195
+ }).strict().optional(),
1196
+ }).strict()),
1197
+ warnings: z.array(z.string()),
1198
+ }).strict();
1199
+ const headlessFcpxmlTargetSchema = z.object({
1200
+ provider: z.literal("final-cut"),
1201
+ libraryUid: z.string().min(1),
1202
+ eventUid: z.string().min(1),
1203
+ projectUid: z.string().min(1),
1204
+ sequenceUid: z.string().min(1),
1205
+ eventName: z.string().min(1).optional(),
1206
+ materialization: z.enum(["versioned", "reuse-existing"]).optional(),
1207
+ }).strict();
1208
+ const headlessRoughCutRequestSchema = z.object({
1209
+ projectId: z.string().min(1),
1210
+ sequenceId: z.string().min(1),
1211
+ plan: roughCutExecutionPlanSchema,
1212
+ operations: z.array(z.unknown()).optional().describe("Ordered Timeline IR edit operations included in the preview and bound into planDigest."),
1213
+ sourceAudioPolicy: z.literal("preserve-and-mix").optional().describe("Retain source audio and mix registered audio/music occurrences using their configured gain."),
1214
+ render: headlessRenderParametersSchema,
1215
+ fcpxml: z.object({
1216
+ path: z.string().min(1),
1217
+ target: headlessFcpxmlTargetSchema,
1218
+ overwrite: z.boolean().optional(),
1219
+ }).strict(),
1220
+ }).strict();
1155
1221
  server.registerTool("headless.render", {
1156
1222
  description: "Render and independently verify one immutable Framekit revision without launching an NLE.",
1157
1223
  inputSchema: {
@@ -1161,6 +1227,18 @@ export function createMcpServer(runtime, options = {}) {
1161
1227
  parameters: headlessRenderParametersSchema,
1162
1228
  },
1163
1229
  }, async ({ projectId, sequenceId, expectedRevision, parameters }) => sessionResult(() => requireHeadlessProjects().render(projectId, sequenceId, parameters, expectedRevision)));
1230
+ server.registerTool("headless.rough-cut.preview", {
1231
+ description: "Preview a semantic rough-cut plan with optional Timeline IR operations; the digest binds both, and preview returns provenance and FCPXML output intent without mutation.",
1232
+ inputSchema: headlessRoughCutRequestSchema.shape,
1233
+ }, async (request) => sessionResult(() => requireHeadlessProjects().previewRoughCut(request)));
1234
+ server.registerTool("headless.rough-cut.execute", {
1235
+ description: "Execute an explicitly approved semantic rough-cut plan and its digest-bound Timeline IR operations headlessly, verify MP4 output, and write equivalent editable FCPXML.",
1236
+ inputSchema: {
1237
+ ...headlessRoughCutRequestSchema.shape,
1238
+ approved: z.boolean(),
1239
+ planDigest: z.string().regex(/^[a-f0-9]{64}$/),
1240
+ },
1241
+ }, async (request) => sessionResult(() => requireHeadlessProjects().executeRoughCut(request)));
1164
1242
  server.registerTool("headless.render.inspect", {
1165
1243
  description: "Inspect a persisted headless render record, provenance, and independent verification evidence.",
1166
1244
  inputSchema: { renderId: z.string().min(1) },
@@ -1783,6 +1861,22 @@ export function createMcpServer(runtime, options = {}) {
1783
1861
  return capabilityUnavailableErrorResult(error);
1784
1862
  }
1785
1863
  });
1864
+ server.registerTool("timeline.semantic.inspect", {
1865
+ description: "Enrich timeline occurrences with source-range-bound semantic speech, visual, and metadata context without mutating the timeline.",
1866
+ inputSchema: timelineSemanticContextQuerySchema.shape,
1867
+ }, async (query) => {
1868
+ const inspected = await inspectMcpEditor(runtime, options);
1869
+ const capability = inspected.capabilities.families.canonicalDocument.read;
1870
+ if (!capability.available) {
1871
+ return capabilityErrorResult("timeline.semantic.inspect", "canonicalDocument.read", capability);
1872
+ }
1873
+ try {
1874
+ return jsonResult(await runtime.inspectTimelineSemanticContext(query));
1875
+ }
1876
+ catch (error) {
1877
+ return capabilityUnavailableErrorResult(error);
1878
+ }
1879
+ });
1786
1880
  server.registerTool("timeline.frame.capture", {
1787
1881
  description: "Capture an image at an exact timeline position with project, sequence, clip, and optional visual-analysis metadata.",
1788
1882
  inputSchema: {
@@ -2032,9 +2126,9 @@ export function createMcpServer(runtime, options = {}) {
2032
2126
  inputSchema: { previewToken: z.string().min(1) },
2033
2127
  }, async ({ previewToken }) => jsonResult(await runtime.executeFillerRemoval(previewToken)));
2034
2128
  server.registerTool("audio.analyze", {
2035
- description: "Analyze loudness, true peak, and silence for one media item.",
2036
- inputSchema: { mediaId: z.string().min(1) },
2037
- }, async ({ mediaId }) => jsonResult(await runtime.analyzeAudio(mediaId)));
2129
+ description: "Analyze loudness, true peak, and silence for one media item or source range.",
2130
+ inputSchema: { mediaId: z.string().min(1), range: rangeSchema.optional() },
2131
+ }, async ({ mediaId, range }) => jsonResult(await runtime.analyzeAudio(mediaId, range)));
2038
2132
  server.registerTool("audio.noise.analyze", {
2039
2133
  description: "Analyze unwanted background noise for one media item when a noise analyzer is configured.",
2040
2134
  inputSchema: { mediaId: z.string().min(1), range: rangeSchema.optional() },