davinci-resolve-mcp 2.23.0

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 (92) hide show
  1. package/AGENTS.md +85 -0
  2. package/CHANGELOG.md +802 -0
  3. package/CLAUDE.md +15 -0
  4. package/LICENSE +21 -0
  5. package/README.md +159 -0
  6. package/SECURITY.md +53 -0
  7. package/bin/davinci-resolve-mcp.mjs +376 -0
  8. package/docs/README.md +56 -0
  9. package/docs/SKILL.md +1145 -0
  10. package/docs/authoring/fuse-dctl-authoring.md +242 -0
  11. package/docs/authoring/script-plugin-authoring.md +195 -0
  12. package/docs/contributing.md +82 -0
  13. package/docs/guides/color-decision-guide.md +387 -0
  14. package/docs/guides/editorial-decision-guide.md +136 -0
  15. package/docs/guides/media-analysis-guide.md +615 -0
  16. package/docs/guides/multicam-setup-guide.md +138 -0
  17. package/docs/install.md +198 -0
  18. package/docs/integrations/workflow-integrations.md +120 -0
  19. package/docs/kernels/README.md +28 -0
  20. package/docs/kernels/audio-fairlight-kernel.md +86 -0
  21. package/docs/kernels/color-grade-kernel.md +103 -0
  22. package/docs/kernels/extension-authoring-kernel.md +101 -0
  23. package/docs/kernels/fusion-composition-kernel.md +91 -0
  24. package/docs/kernels/media-pool-ingest-kernel.md +147 -0
  25. package/docs/kernels/project-lifecycle-kernel.md +120 -0
  26. package/docs/kernels/render-deliver-kernel.md +92 -0
  27. package/docs/kernels/review-annotation-kernel.md +110 -0
  28. package/docs/kernels/timeline-conform-interchange-kernel.md +99 -0
  29. package/docs/kernels/timeline-edit-kernel.md +189 -0
  30. package/docs/notes/codec-plugin-notes.md +136 -0
  31. package/docs/notes/dctl-notes.md +234 -0
  32. package/docs/notes/fusion-template-notes.md +136 -0
  33. package/docs/notes/lut-notes.md +136 -0
  34. package/docs/notes/openfx-notes.md +120 -0
  35. package/docs/process/release-process.md +152 -0
  36. package/docs/reference/api-coverage.md +488 -0
  37. package/docs/reference/resolve_scripting_api.txt +1012 -0
  38. package/examples/README.md +53 -0
  39. package/examples/markers/README.md +81 -0
  40. package/examples/media/README.md +94 -0
  41. package/examples/timeline/README.md +98 -0
  42. package/install.py +1196 -0
  43. package/package.json +52 -0
  44. package/scripts/audit_api_parity.py +275 -0
  45. package/scripts/live_media_analysis_polish_probe.py +65 -0
  46. package/src/__init__.py +3 -0
  47. package/src/analysis_dashboard.py +4936 -0
  48. package/src/control_panel.py +13 -0
  49. package/src/granular/__init__.py +17 -0
  50. package/src/granular/common.py +727 -0
  51. package/src/granular/folder.py +287 -0
  52. package/src/granular/gallery.py +306 -0
  53. package/src/granular/graph.py +309 -0
  54. package/src/granular/media_pool.py +679 -0
  55. package/src/granular/media_pool_item.py +852 -0
  56. package/src/granular/media_storage.py +179 -0
  57. package/src/granular/project.py +1594 -0
  58. package/src/granular/resolve_control.py +521 -0
  59. package/src/granular/timeline.py +1074 -0
  60. package/src/granular/timeline_item.py +2251 -0
  61. package/src/resolve_mcp_server.py +43 -0
  62. package/src/server.py +15691 -0
  63. package/src/utils/__init__.py +3 -0
  64. package/src/utils/app_control.py +319 -0
  65. package/src/utils/audio_fairlight_live_probe.py +263 -0
  66. package/src/utils/cdl.py +20 -0
  67. package/src/utils/cloud_operations.py +192 -0
  68. package/src/utils/color_grade_live_probe.py +444 -0
  69. package/src/utils/dctl_templates.py +368 -0
  70. package/src/utils/extension_authoring_live_probe.py +292 -0
  71. package/src/utils/fuse_templates.py +1968 -0
  72. package/src/utils/fusion_composition_live_probe.py +284 -0
  73. package/src/utils/layout_presets.py +333 -0
  74. package/src/utils/mcp_stdio.py +32 -0
  75. package/src/utils/media_analysis.py +3618 -0
  76. package/src/utils/media_analysis_jobs.py +796 -0
  77. package/src/utils/media_pool_ingest_live_probe.py +592 -0
  78. package/src/utils/multicam.py +393 -0
  79. package/src/utils/object_inspection.py +287 -0
  80. package/src/utils/platform.py +157 -0
  81. package/src/utils/project_lifecycle_live_probe.py +376 -0
  82. package/src/utils/project_properties.py +601 -0
  83. package/src/utils/render_deliver_live_probe.py +384 -0
  84. package/src/utils/resolve_connection.py +77 -0
  85. package/src/utils/review_annotation_live_probe.py +352 -0
  86. package/src/utils/script_templates.py +1193 -0
  87. package/src/utils/sync_detection.py +887 -0
  88. package/src/utils/timeline_conform_live_probe.py +280 -0
  89. package/src/utils/timeline_kernel_live_probe.py +1091 -0
  90. package/src/utils/timeline_kernel_probe.py +185 -0
  91. package/src/utils/timeline_title_text.py +87 -0
  92. package/src/utils/update_check.py +610 -0
@@ -0,0 +1,3 @@
1
+ """
2
+ DaVinci Resolve MCP Utilities Package
3
+ """
@@ -0,0 +1,319 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ DaVinci Resolve MCP Server - Application Control Utilities
4
+
5
+ This module provides functions for controlling DaVinci Resolve application:
6
+ - Quitting the application
7
+ - Checking application state
8
+ - Handling basic application functions
9
+ """
10
+
11
+ import os
12
+ import logging
13
+ import time
14
+ import sys
15
+ import platform
16
+ import subprocess
17
+ from typing import Dict, Any, Optional, Union, List
18
+
19
+ # Configure logging
20
+ logger = logging.getLogger("davinci-resolve-mcp.app_control")
21
+ APP_CONTROL_TIMEOUT_SECONDS = 10
22
+
23
+
24
+ def _run_app_command(
25
+ cmd: List[str],
26
+ description: str,
27
+ timeout: int = APP_CONTROL_TIMEOUT_SECONDS,
28
+ ) -> bool:
29
+ """Run a platform app-control command with a bounded wait."""
30
+ try:
31
+ result = subprocess.run(
32
+ cmd,
33
+ check=False,
34
+ capture_output=True,
35
+ text=True,
36
+ timeout=timeout,
37
+ )
38
+ except subprocess.TimeoutExpired:
39
+ logger.error("%s timed out after %ss: %s", description, timeout, cmd)
40
+ return False
41
+ except OSError as exc:
42
+ logger.error("%s failed to launch: %s", description, exc)
43
+ return False
44
+
45
+ if result.returncode != 0:
46
+ stderr = (result.stderr or "").strip()
47
+ logger.warning(
48
+ "%s exited with code %s%s",
49
+ description,
50
+ result.returncode,
51
+ f": {stderr}" if stderr else "",
52
+ )
53
+ return False
54
+ return True
55
+
56
+
57
+ def quit_resolve_app(resolve_obj, force: bool = False, save_project: bool = True) -> bool:
58
+ """
59
+ Quit DaVinci Resolve application.
60
+
61
+ Args:
62
+ resolve_obj: DaVinci Resolve API object
63
+ force: Whether to force quit even if unsaved changes (potentially dangerous)
64
+ save_project: Whether to save the project before quitting
65
+
66
+ Returns:
67
+ True if the quit command was sent successfully
68
+ """
69
+ try:
70
+ logger.info("Attempting to quit DaVinci Resolve")
71
+
72
+ # Check if a project is open
73
+ pm = resolve_obj.GetProjectManager()
74
+ if pm:
75
+ project = pm.GetCurrentProject()
76
+ if project and save_project:
77
+ logger.info("Saving project before quitting")
78
+ # Try to save the project
79
+ try:
80
+ project.SaveProject()
81
+ except Exception as e:
82
+ logger.error(f"Failed to save project: {str(e)}")
83
+ if not force:
84
+ logger.error("Aborting quit due to save failure")
85
+ return False
86
+
87
+ # Attempt to quit using the API
88
+ if hasattr(resolve_obj, 'Quit') and callable(getattr(resolve_obj, 'Quit')):
89
+ logger.info("Using Resolve.Quit() API")
90
+ resolve_obj.Quit()
91
+ return True
92
+
93
+ # If Quit method isn't available or fails, use platform-specific methods
94
+ sys_platform = platform.system().lower()
95
+
96
+ if sys_platform == 'darwin':
97
+ # macOS - use AppleScript
98
+ logger.info("Using AppleScript to quit Resolve on macOS")
99
+ cmd = [
100
+ 'osascript',
101
+ '-e', 'tell application "DaVinci Resolve" to quit'
102
+ ]
103
+ if force:
104
+ # Add force option if requested
105
+ cmd = [
106
+ 'osascript',
107
+ '-e', 'tell application "DaVinci Resolve" to quit with saving'
108
+ ]
109
+
110
+ return _run_app_command(cmd, "macOS Resolve quit command")
111
+
112
+ elif sys_platform == 'windows':
113
+ # Windows - use taskkill
114
+ logger.info("Using taskkill to quit Resolve on Windows")
115
+ if force:
116
+ return _run_app_command(
117
+ ['taskkill', '/F', '/IM', 'Resolve.exe'],
118
+ "Windows Resolve force-quit command",
119
+ )
120
+ else:
121
+ return _run_app_command(
122
+ ['taskkill', '/IM', 'Resolve.exe'],
123
+ "Windows Resolve quit command",
124
+ )
125
+
126
+ elif sys_platform == 'linux':
127
+ # Linux - use pkill
128
+ logger.info("Using pkill to quit Resolve on Linux")
129
+ if force:
130
+ return _run_app_command(
131
+ ['pkill', '-9', 'resolve'],
132
+ "Linux Resolve force-quit command",
133
+ )
134
+ else:
135
+ return _run_app_command(
136
+ ['pkill', 'resolve'],
137
+ "Linux Resolve quit command",
138
+ )
139
+
140
+ # If all methods fail, return False
141
+ logger.error("Failed to quit Resolve via any method")
142
+ return False
143
+
144
+ except Exception as e:
145
+ logger.error(f"Error quitting DaVinci Resolve: {str(e)}")
146
+ return False
147
+
148
+ def get_app_state(resolve_obj) -> Dict[str, Any]:
149
+ """
150
+ Get DaVinci Resolve application state information.
151
+
152
+ Args:
153
+ resolve_obj: DaVinci Resolve API object
154
+
155
+ Returns:
156
+ Dictionary with application state information
157
+ """
158
+ state = {
159
+ "connected": resolve_obj is not None,
160
+ "version": "Unknown",
161
+ "product_name": "Unknown",
162
+ "platform": platform.system(),
163
+ "python_version": sys.version,
164
+ }
165
+
166
+ if resolve_obj:
167
+ try:
168
+ state["version"] = resolve_obj.GetVersionString()
169
+ except Exception:
170
+ logger.debug("Could not read Resolve version string", exc_info=True)
171
+
172
+ try:
173
+ state["product_name"] = resolve_obj.GetProductName()
174
+ except Exception:
175
+ logger.debug("Could not read Resolve product name", exc_info=True)
176
+
177
+ try:
178
+ state["current_page"] = resolve_obj.GetCurrentPage()
179
+ except Exception:
180
+ logger.debug("Could not read Resolve current page", exc_info=True)
181
+ state["current_page"] = "Unknown"
182
+
183
+ # Get project manager and project information
184
+ try:
185
+ pm = resolve_obj.GetProjectManager()
186
+ if pm:
187
+ state["project_manager_available"] = True
188
+
189
+ current_project = pm.GetCurrentProject()
190
+ if current_project:
191
+ state["project_open"] = True
192
+ state["project_name"] = current_project.GetName()
193
+
194
+ # Check if timeline is open
195
+ current_timeline = current_project.GetCurrentTimeline()
196
+ if current_timeline:
197
+ state["timeline_open"] = True
198
+ state["timeline_name"] = current_timeline.GetName()
199
+ else:
200
+ state["timeline_open"] = False
201
+ else:
202
+ state["project_open"] = False
203
+ else:
204
+ state["project_manager_available"] = False
205
+ except Exception as e:
206
+ state["project_error"] = str(e)
207
+
208
+ return state
209
+
210
+ def restart_resolve_app(resolve_obj, wait_seconds: int = 5) -> bool:
211
+ """
212
+ Restart DaVinci Resolve application.
213
+
214
+ Args:
215
+ resolve_obj: DaVinci Resolve API object
216
+ wait_seconds: Seconds to wait between quit and restart
217
+
218
+ Returns:
219
+ True if restart was initiated successfully
220
+ """
221
+ try:
222
+ # Get Resolve executable path for restart
223
+ if platform.system().lower() == 'darwin':
224
+ resolve_path = '/Applications/DaVinci Resolve/DaVinci Resolve.app'
225
+ elif platform.system().lower() == 'windows':
226
+ # Default path, may need to be customized
227
+ resolve_path = r'C:\Program Files\Blackmagic Design\DaVinci Resolve\Resolve.exe'
228
+ elif platform.system().lower() == 'linux':
229
+ # Default path, may need to be customized
230
+ resolve_path = '/opt/resolve/bin/resolve'
231
+ else:
232
+ return False
233
+
234
+ # Quit Resolve
235
+ if not quit_resolve_app(resolve_obj, force=False, save_project=True):
236
+ logger.error("Failed to quit Resolve for restart")
237
+ return False
238
+
239
+ # Wait for the app to close
240
+ logger.info(f"Waiting {wait_seconds} seconds for Resolve to close")
241
+ time.sleep(wait_seconds)
242
+
243
+ # Start Resolve again
244
+ logger.info("Attempting to start Resolve")
245
+
246
+ if platform.system().lower() == 'darwin':
247
+ subprocess.Popen(['open', resolve_path])
248
+ elif platform.system().lower() == 'windows':
249
+ subprocess.Popen([resolve_path])
250
+ elif platform.system().lower() == 'linux':
251
+ subprocess.Popen([resolve_path])
252
+
253
+ return True
254
+ except Exception as e:
255
+ logger.error(f"Error restarting DaVinci Resolve: {str(e)}")
256
+ return False
257
+
258
+ def open_project_settings(resolve_obj) -> bool:
259
+ """
260
+ Open the Project Settings dialog in DaVinci Resolve.
261
+
262
+ Args:
263
+ resolve_obj: DaVinci Resolve API object
264
+
265
+ Returns:
266
+ True if successful, False otherwise
267
+ """
268
+ try:
269
+ # Check if UI Manager is available
270
+ ui_manager = resolve_obj.GetUIManager()
271
+ if not ui_manager:
272
+ logger.error("Failed to get UI Manager")
273
+ return False
274
+
275
+ # Open Project Settings dialog
276
+ if hasattr(ui_manager, 'OpenProjectSettings') and callable(getattr(ui_manager, 'OpenProjectSettings')):
277
+ ui_manager.OpenProjectSettings()
278
+ return True
279
+
280
+ # Alternative method - send keyboard shortcut based on platform
281
+ current_page = resolve_obj.GetCurrentPage()
282
+
283
+ # Ensure we're on a page that supports project settings
284
+ if current_page not in ['media', 'cut', 'edit', 'fusion', 'color', 'fairlight', 'deliver']:
285
+ logger.error(f"Can't open settings from page: {current_page}")
286
+ return False
287
+
288
+ return False # Keyboard shortcuts not implemented yet
289
+ except Exception as e:
290
+ logger.error(f"Error opening project settings: {str(e)}")
291
+ return False
292
+
293
+ def open_preferences(resolve_obj) -> bool:
294
+ """
295
+ Open the Preferences dialog in DaVinci Resolve.
296
+
297
+ Args:
298
+ resolve_obj: DaVinci Resolve API object
299
+
300
+ Returns:
301
+ True if successful, False otherwise
302
+ """
303
+ try:
304
+ # Check if UI Manager is available
305
+ ui_manager = resolve_obj.GetUIManager()
306
+ if not ui_manager:
307
+ logger.error("Failed to get UI Manager")
308
+ return False
309
+
310
+ # Open Preferences dialog
311
+ if hasattr(ui_manager, 'OpenPreferences') and callable(getattr(ui_manager, 'OpenPreferences')):
312
+ ui_manager.OpenPreferences()
313
+ return True
314
+
315
+ # Alternative method - send keyboard shortcut based on platform
316
+ return False # Keyboard shortcuts not implemented yet
317
+ except Exception as e:
318
+ logger.error(f"Error opening preferences: {str(e)}")
319
+ return False
@@ -0,0 +1,263 @@
1
+ #!/usr/bin/env python3
2
+ """Live Audio / Fairlight boundary probe."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import json
7
+ import platform
8
+ import shutil
9
+ import subprocess
10
+ import sys
11
+ import tempfile
12
+ import time
13
+ from pathlib import Path
14
+ from typing import Any, Dict, Optional
15
+
16
+ from src.utils.timeline_kernel_probe import ProbeRecorder, render_markdown_report, utc_timestamp
17
+
18
+
19
+ def _require_success(label: str, result: Dict[str, Any]) -> Dict[str, Any]:
20
+ if not isinstance(result, dict):
21
+ raise AssertionError(f"{label}: expected dict, got {result!r}")
22
+ if result.get("error"):
23
+ raise AssertionError(f"{label}: {result['error']}")
24
+ if "success" in result and result["success"] is not True:
25
+ raise AssertionError(f"{label}: expected success=True, got {result!r}")
26
+ return result
27
+
28
+
29
+ def _record_tool_result(
30
+ recorder: ProbeRecorder,
31
+ category: str,
32
+ name: str,
33
+ result: Dict[str, Any],
34
+ *,
35
+ expected_status: Optional[str] = None,
36
+ ) -> None:
37
+ if not isinstance(result, dict):
38
+ recorder.record(category, name, "error", details={"reason": "non-dict result", "result": repr(result)})
39
+ return
40
+ if result.get("error"):
41
+ recorder.record(category, name, expected_status or "error", details={"reason": result.get("error")}, evidence=result)
42
+ return
43
+ if "success" in result and result["success"] is not True:
44
+ recorder.record(category, name, expected_status or "partially_supported", details={"reason": "success returned false"}, evidence=result)
45
+ return
46
+ recorder.record(category, name, expected_status or "supported", evidence=result)
47
+
48
+
49
+ def _run_ffmpeg(args: list[str]) -> None:
50
+ subprocess.run(["ffmpeg", "-hide_banner", "-loglevel", "error", *args], check=True)
51
+
52
+
53
+ def _make_synthetic_media(work_dir: Path) -> Dict[str, Path]:
54
+ video = work_dir / "audio_fairlight_video.mov"
55
+ audio = work_dir / "audio_fairlight_audio.wav"
56
+ _run_ffmpeg(
57
+ [
58
+ "-f",
59
+ "lavfi",
60
+ "-i",
61
+ "testsrc2=size=640x360:rate=24:duration=3",
62
+ "-f",
63
+ "lavfi",
64
+ "-i",
65
+ "sine=frequency=440:sample_rate=48000:duration=3",
66
+ "-shortest",
67
+ "-pix_fmt",
68
+ "yuv420p",
69
+ "-c:v",
70
+ "libx264",
71
+ "-c:a",
72
+ "aac",
73
+ "-y",
74
+ str(video),
75
+ ]
76
+ )
77
+ _run_ffmpeg(["-f", "lavfi", "-i", "sine=frequency=440:sample_rate=48000:duration=3", "-y", str(audio)])
78
+ return {"video": video, "audio": audio}
79
+
80
+
81
+ def _first_imported(imported_items):
82
+ for item in imported_items or []:
83
+ try:
84
+ if item.GetUniqueId():
85
+ return item
86
+ except Exception:
87
+ pass
88
+ return None
89
+
90
+
91
+ def _clip_id(clip) -> Optional[str]:
92
+ try:
93
+ return str(clip.GetUniqueId())
94
+ except Exception:
95
+ return None
96
+
97
+
98
+ def run_probe(server, output_dir: Path, keep_open: bool = False) -> Dict[str, Any]:
99
+ output_dir.mkdir(parents=True, exist_ok=True)
100
+ work_dir = Path(tempfile.mkdtemp(prefix="mcp_audio_fairlight_probe_"))
101
+ project_name = f"_mcp_audio_fairlight_probe_{int(time.time())}"
102
+ timeline_name = "Audio Fairlight Probe"
103
+ recorder = ProbeRecorder()
104
+ created_project = False
105
+ delete_result: Optional[Dict[str, Any]] = None
106
+
107
+ metadata: Dict[str, Any] = {
108
+ "title": "Audio / Fairlight Kernel Capability Probe",
109
+ "timestamp_utc": utc_timestamp(),
110
+ "python": sys.version,
111
+ "platform": platform.platform(),
112
+ "output_dir": str(output_dir),
113
+ "project_name": project_name,
114
+ }
115
+
116
+ try:
117
+ version = _require_success("resolve_control.get_version", server.resolve_control("get_version"))
118
+ metadata.update(
119
+ {
120
+ "product": version.get("product"),
121
+ "version": version.get("version"),
122
+ "version_string": version.get("version_string"),
123
+ }
124
+ )
125
+ print(f"Connected to {metadata['product']} {metadata['version_string']}")
126
+
127
+ _require_success("project_manager.create", server.project_manager("create", {"name": project_name}))
128
+ created_project = True
129
+ print(f"Created disposable project: {project_name}")
130
+ server.resolve_control("open_page", {"page": "edit"})
131
+
132
+ assets = _make_synthetic_media(work_dir)
133
+ metadata["synthetic_media"] = {key: str(value) for key, value in assets.items()}
134
+ print(f"Generated synthetic media under: {work_dir}")
135
+
136
+ resolve = server.get_resolve()
137
+ project = resolve.GetProjectManager().GetCurrentProject()
138
+ media_pool = project.GetMediaPool()
139
+ imported = media_pool.ImportMedia([str(assets["video"]), str(assets["audio"])]) or []
140
+ if len(imported) < 2:
141
+ raise AssertionError("Failed to import synthetic audio media")
142
+ video_clip = _first_imported([imported[0]])
143
+ audio_clip = _first_imported([imported[1]])
144
+ if not video_clip or not audio_clip:
145
+ raise AssertionError("Failed to resolve imported audio MediaPoolItems")
146
+ timeline = media_pool.CreateTimelineFromClips(timeline_name, [video_clip])
147
+ if not timeline:
148
+ raise AssertionError("Failed to create audio timeline")
149
+ project.SetCurrentTimeline(timeline)
150
+ print(f"Created timeline: {timeline_name}")
151
+
152
+ video_clip_id = _clip_id(video_clip)
153
+ audio_clip_id = _clip_id(audio_clip)
154
+ clip_ids = [clip_id for clip_id in (video_clip_id, audio_clip_id) if clip_id]
155
+
156
+ _record_tool_result(recorder, "capabilities", "audio_capabilities", server.timeline("audio_capabilities"))
157
+ _record_tool_result(recorder, "track", "probe_audio_track", server.timeline("probe_audio_track", {"track_index": 1}))
158
+ _record_tool_result(recorder, "item", "probe_audio_item", server.timeline("probe_audio_item", {"track_type": "audio", "track_index": 1, "item_index": 0}))
159
+ _record_tool_result(
160
+ recorder,
161
+ "item",
162
+ "safe_set_audio_properties_dry_run",
163
+ server.timeline("safe_set_audio_properties", {"track_type": "audio", "track_index": 1, "item_index": 0, "properties": {"Volume": -3}, "dry_run": True}),
164
+ )
165
+ _record_tool_result(
166
+ recorder,
167
+ "item",
168
+ "safe_set_audio_properties_restore",
169
+ server.timeline("safe_set_audio_properties", {"track_type": "audio", "track_index": 1, "item_index": 0, "properties": {"Volume": -3}, "restore": True}),
170
+ )
171
+ _record_tool_result(recorder, "voice", "voice_isolation_capabilities", server.timeline("voice_isolation_capabilities", {"track_index": 1, "track_type": "audio"}))
172
+ _record_tool_result(recorder, "mapping", "audio_mapping_report", server.timeline("audio_mapping_report", {"clip_ids": clip_ids}))
173
+ _record_tool_result(
174
+ recorder,
175
+ "sync",
176
+ "safe_auto_sync_audio_dry_run",
177
+ server.timeline("safe_auto_sync_audio", {"clip_ids": clip_ids, "settings": {"syncBy": "waveform", "channel": "auto"}, "dry_run": True}),
178
+ )
179
+ auto_sync = server.timeline("safe_auto_sync_audio", {"clip_ids": clip_ids, "settings": {"syncBy": "waveform", "channel": "auto"}, "dry_run": False})
180
+ _record_tool_result(
181
+ recorder,
182
+ "sync",
183
+ "safe_auto_sync_audio_execute",
184
+ auto_sync,
185
+ expected_status=None if auto_sync.get("success") else "partially_supported",
186
+ )
187
+ _record_tool_result(recorder, "transcription", "transcription_capabilities", server.timeline("transcription_capabilities", {"clip_ids": clip_ids}))
188
+
189
+ if video_clip_id:
190
+ transcribe = server.media_pool_item("transcribe_audio", {"clip_id": video_clip_id})
191
+ _record_tool_result(
192
+ recorder,
193
+ "transcription",
194
+ "media_pool_item_transcribe_audio",
195
+ transcribe,
196
+ expected_status=None if transcribe.get("success") else "version_or_page_dependent",
197
+ )
198
+ clear = server.media_pool_item("clear_transcription", {"clip_id": video_clip_id})
199
+ _record_tool_result(
200
+ recorder,
201
+ "transcription",
202
+ "media_pool_item_clear_transcription",
203
+ clear,
204
+ expected_status=None if clear.get("success") else "version_or_page_dependent",
205
+ )
206
+
207
+ subtitles = server.timeline("subtitle_generation_probe", {"settings": {}, "allow_generate": True})
208
+ _record_tool_result(
209
+ recorder,
210
+ "subtitles",
211
+ "subtitle_generation_probe_execute",
212
+ subtitles,
213
+ expected_status=None if subtitles.get("success") else "version_or_page_dependent",
214
+ )
215
+
216
+ _record_tool_result(
217
+ recorder,
218
+ "fairlight",
219
+ "get_fairlight_presets",
220
+ server.resolve_control("get_fairlight_presets"),
221
+ expected_status=None,
222
+ )
223
+ _record_tool_result(
224
+ recorder,
225
+ "fairlight",
226
+ "insert_audio",
227
+ server.project_settings("insert_audio", {"media_path": str(assets["audio"]), "start_offset": 0, "duration": 24}),
228
+ )
229
+ _record_tool_result(recorder, "report", "fairlight_boundary_report", server.timeline("fairlight_boundary_report", {"clip_ids": clip_ids}))
230
+
231
+ if keep_open:
232
+ server.project_manager("save")
233
+ print(f"LEFT PROJECT OPEN FOR INSPECTION: {project_name}")
234
+ created_project = False
235
+
236
+ finally:
237
+ if created_project:
238
+ server.project_manager("save")
239
+ server.project_manager("close")
240
+ delete_result = server.project_manager("delete", {"name": project_name})
241
+ print(f"Deleted disposable project: {delete_result}")
242
+
243
+ report = recorder.to_report(
244
+ metadata,
245
+ {
246
+ "json": str(output_dir / "audio-fairlight-probe.json"),
247
+ "markdown": str(output_dir / "audio-fairlight-probe.md"),
248
+ },
249
+ )
250
+ json_path = output_dir / "audio-fairlight-probe.json"
251
+ markdown_path = output_dir / "audio-fairlight-probe.md"
252
+ json_path.write_text(json.dumps(report, indent=2, sort_keys=True), encoding="utf-8")
253
+ markdown_path.write_text(render_markdown_report(report), encoding="utf-8")
254
+ print(f"Wrote JSON report: {json_path}")
255
+ print(f"Wrote Markdown report: {markdown_path}")
256
+ print(f"Counts: {json.dumps(report['counts'], sort_keys=True)}")
257
+ if not keep_open:
258
+ shutil.rmtree(work_dir, ignore_errors=True)
259
+ print(f"Removed synthetic media directory: {work_dir}")
260
+
261
+ if delete_result and delete_result.get("success") is not True:
262
+ raise AssertionError(f"Cleanup failed for {project_name}: {delete_result!r}")
263
+ return report
@@ -0,0 +1,20 @@
1
+ """CDL normalization helpers shared by compound and granular servers."""
2
+
3
+ from typing import Any, Dict
4
+
5
+
6
+ def normalize_cdl_payload(cdl: Any) -> Any:
7
+ """Resolve's SetCDL expects strings like ``"1.0 1.0 1.0"`` instead of arrays."""
8
+ if not isinstance(cdl, dict):
9
+ return cdl
10
+ out: Dict[str, Any] = {}
11
+ for key, value in cdl.items():
12
+ if isinstance(value, (list, tuple)):
13
+ out[key] = " ".join(str(item) for item in value)
14
+ elif isinstance(value, bool):
15
+ out[key] = str(value)
16
+ elif isinstance(value, (int, float)):
17
+ out[key] = str(value)
18
+ else:
19
+ out[key] = value
20
+ return out