davinci-resolve-mcp 5.2.14 → 5.3.1
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/CHANGELOG.md +32 -0
- package/README.md +1 -1
- package/README.zh-CN.md +2 -2
- package/README.zh-TW.md +2 -2
- package/docs/SKILL.md +19 -0
- package/install.py +1 -1
- package/package.json +1 -1
- package/resolve-advanced/package.json +1 -1
- package/src/granular/common.py +1 -1
- package/src/server.py +226 -32
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
Release history for the DaVinci Resolve MCP Server. The latest release is summarized in the root README; older entries live here to keep the README focused.
|
|
4
4
|
|
|
5
|
+
## What's New in v5.3.1 — prettier dev-dependency update
|
|
6
|
+
|
|
7
|
+
From #375 (Dependabot).
|
|
8
|
+
|
|
9
|
+
### Dependencies
|
|
10
|
+
|
|
11
|
+
- **`prettier` 3.9.10 → 3.10.1** in `resolve-advanced` (dev dependency only). No runtime or tool behaviour changes.
|
|
12
|
+
|
|
13
|
+
## What's New in v5.3.0 — Writes no longer follow the current timeline to another client's
|
|
14
|
+
|
|
15
|
+
Fixes #382, reported by @willturner-maker.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- **A write could land on a different client's timeline.** A pin makes its timeline current once, at the start of a call. `MediaPool.AppendToTimeline` writes to whatever timeline is current *when it runs*, and `ripple_insert`, `move_clips`, `replace_source_range` and `edit_engine` swaps rebuild items with it. If a second client (another MCP server, a script, the user) switched timelines in between, the deletes went to the right timeline, the re-appends went to the other one, and the call reported success. Unpinned calls had the same window. Every append now checks first that the current timeline is still the one the call resolved. If it isn't, the append is refused with `TIMELINE_PIN_LOST` (pinned call) or `TIMELINE_CHANGED` (unpinned), and `state` names `expected_timeline` and `current_timeline`. Nothing reaches the other timeline.
|
|
20
|
+
- **`ripple_insert` stops cleanly if the timeline moves mid-rebuild.** It checks before its delete, so a switch caught there changes nothing. A switch caught during the re-appends stops every further append, and `state` reports how many tail items were deleted and re-appended and how many inserts were placed. The archive taken before the edit is the way back. These refusals are `retryable: false`, because a blind retry could repeat steps that already ran.
|
|
21
|
+
- **A pinned call refuses if its timeline is no longer current when the action reads it**, rather than acting on the new current timeline.
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- **`media_pool(action="append_to_timeline")` takes a pin** (`timeline_id` / `timeline_name`). The rest of `media_pool` does not: `create_timeline*` reads `timeline_name` as the new timeline's name.
|
|
26
|
+
- `docs/SKILL.md` lists which actions take a pin, describes the re-check, and adds the two error codes to the recovery table.
|
|
27
|
+
|
|
28
|
+
### Limits
|
|
29
|
+
|
|
30
|
+
- This catches a switch; it does not lock clients out of each other. The check and the append are two separate bridge calls, so a narrow window remains. For concurrent agents, pin every call and give each agent its own timeline.
|
|
31
|
+
- An unreadable current timeline counts as "not measured", never as "different", so offline stubs and edge cases are not refused.
|
|
32
|
+
|
|
33
|
+
### Not verified here
|
|
34
|
+
|
|
35
|
+
- Offline tests only. The switch was simulated in tests (`tests/test_timeline_pin_concurrency.py`), not raced between two live clients.
|
|
36
|
+
|
|
5
37
|
## What's New in v5.2.14 — `ripple_insert` blockers say what they are and what to do
|
|
6
38
|
|
|
7
39
|
From #381 by @boomesh11, fixing #376 reported by @willturner-maker. Adapted on landing.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
English | [简体中文](README.zh-CN.md) | [繁體中文](README.zh-TW.md)
|
|
4
4
|
|
|
5
|
-
[](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
|
|
6
6
|
[](https://www.npmjs.com/package/davinci-resolve-mcp)
|
|
7
7
|
[](docs/reference/api-coverage.md)
|
|
8
8
|
[-blue.svg)](#server-modes)
|
package/README.zh-CN.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | 简体中文 | [繁體中文](README.zh-TW.md)
|
|
4
4
|
|
|
5
|
-
[](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
|
|
6
6
|
[](https://www.npmjs.com/package/davinci-resolve-mcp)
|
|
7
7
|
[](docs/reference/api-coverage.md)
|
|
8
8
|
[-blue.svg)](#服务器模式)
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
[](https://www.python.org/downloads/)
|
|
13
13
|
[](https://opensource.org/licenses/MIT)
|
|
14
14
|
|
|
15
|
-
> 本翻译对应 v5.
|
|
15
|
+
> 本翻译对应 v5.3.1 版 README。如与英文原版有出入,以 [英文原版](README.md) 为准。
|
|
16
16
|
|
|
17
17
|
一个 Model Context Protocol (MCP) 服务器,让 AI 助手通过官方脚本 API 控制 DaVinci Resolve Studio(达芬奇)。它提供完整的 API 覆盖,外加带护栏的工作流助手,涵盖剪辑、媒体池整理、渲染设置、审阅标记、调色、Fusion、Fairlight、项目生命周期任务、扩展开发,以及不碰源媒体的媒体分析。
|
|
18
18
|
|
package/README.zh-TW.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | [简体中文](README.zh-CN.md) | 繁體中文
|
|
4
4
|
|
|
5
|
-
[](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
|
|
6
6
|
[](https://www.npmjs.com/package/davinci-resolve-mcp)
|
|
7
7
|
[](docs/reference/api-coverage.md)
|
|
8
8
|
[-blue.svg)](#伺服器模式)
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
[](https://www.python.org/downloads/)
|
|
13
13
|
[](https://opensource.org/licenses/MIT)
|
|
14
14
|
|
|
15
|
-
> 本翻譯對應 v5.
|
|
15
|
+
> 本翻譯對應 v5.3.1 版 README。如與英文原版有出入,以[英文原版](README.md)為準。
|
|
16
16
|
|
|
17
17
|
一個 Model Context Protocol(MCP)伺服器,讓 AI 助理透過官方腳本 API 控制 DaVinci Resolve Studio。它提供完整的 API 覆蓋,並附上有防護機制的工作流程輔助工具,涵蓋剪輯、媒體池整理、算圖輸出設定、審閱標記、調色、Fusion、Fairlight、專案生命週期作業、擴充功能開發,以及不更動原始素材的媒體分析。
|
|
18
18
|
|
package/docs/SKILL.md
CHANGED
|
@@ -239,6 +239,24 @@ cannot redirect your write. An unknown id, an ambiguous name or an id/name
|
|
|
239
239
|
pair that disagree is refused before anything runs. Exceptions, where these
|
|
240
240
|
keys keep their own meaning: `timeline.set_current` (selects by
|
|
241
241
|
`timeline_id`) and the imports (`timeline_name` names the new timeline).
|
|
242
|
+
`media_pool(action="append_to_timeline")` takes a pin too; the rest of
|
|
243
|
+
`media_pool` does not (`create_timeline*` reads `timeline_name` as the new
|
|
244
|
+
timeline's name).
|
|
245
|
+
|
|
246
|
+
**A pin is checked again before every write to the current timeline** (#382).
|
|
247
|
+
Some writes go to whatever timeline is current when they run, not to the
|
|
248
|
+
timeline the call resolved: above all `AppendToTimeline`, which `ripple_insert`,
|
|
249
|
+
`move_clips`, `replace_source_range` and `edit_engine` swaps use to rebuild
|
|
250
|
+
items. If another client (a second MCP server, a script, the user) makes a
|
|
251
|
+
different timeline current mid-call, the write is refused with
|
|
252
|
+
`TIMELINE_PIN_LOST` (pinned call) or `TIMELINE_CHANGED` (unpinned), and
|
|
253
|
+
`state` names `expected_timeline` and `current_timeline`. Nothing reaches the
|
|
254
|
+
other timeline. If the refusal comes after part of the edit ran (a
|
|
255
|
+
`ripple_insert` whose tail was already deleted), `state` says how much, and
|
|
256
|
+
the fix is the archive taken before the edit. These refusals are
|
|
257
|
+
`retryable: false` because a blind retry could repeat the steps that already
|
|
258
|
+
ran. This guard catches the switch; it does not lock clients out of each other.
|
|
259
|
+
For concurrent agents, pin every call and give each agent its own timeline.
|
|
242
260
|
|
|
243
261
|
The envelope is namespaced under `_operation` rather than merged into the top
|
|
244
262
|
level because `status`, `operation`, `warnings`, `result` and `changes` are all
|
|
@@ -2532,6 +2550,7 @@ reports, deletes the project, and removes generated media. See
|
|
|
2532
2550
|
| `"No item at index N"` | `item_index` out of range for the track | Call `timeline(action="get_items", ...)` first to find valid indices |
|
|
2533
2551
|
| `ITEM_NOT_FOUND` | No item with that `timeline_item_id` on the target timeline | Re-read ids; pass `timeline_id` if the item is on another timeline |
|
|
2534
2552
|
| `TIMELINE_NOT_FOUND` / `TIMELINE_NAME_AMBIGUOUS` | The pin names no timeline, or several share the name | `timeline(action="list")` and pin by `timeline_id` |
|
|
2553
|
+
| `TIMELINE_PIN_LOST` / `TIMELINE_CHANGED` | Another client made a different timeline current mid-call; the write was refused | Check `state` for what already ran, restore from the archive if needed, re-run pinned with `timeline_id` |
|
|
2535
2554
|
| `"Clip not found"` | Stale or wrong `clip_id` | Re-fetch IDs via `media_pool(action="get_selected")` or `folder(action="get_clips")` |
|
|
2536
2555
|
| `"Gallery not available"` | Not on Color page | `resolve_control(action="open_page", params={"page": "color"})` |
|
|
2537
2556
|
| `"GrabStill failed"` | Not on Color page or no clip under playhead | Switch to Color page, move playhead over a clip |
|
package/install.py
CHANGED
|
@@ -37,7 +37,7 @@ from src.utils.update_check import (
|
|
|
37
37
|
|
|
38
38
|
# ─── Version ──────────────────────────────────────────────────────────────────
|
|
39
39
|
|
|
40
|
-
VERSION = "5.
|
|
40
|
+
VERSION = "5.3.1"
|
|
41
41
|
# Only hard floor: mcp[cli] requires Python 3.10+. There is no upper bound —
|
|
42
42
|
# Resolve's scripting bridge loads into newer interpreters on recent builds
|
|
43
43
|
# (Python 3.14 verified against Resolve Studio 20.3.2). Older Resolve builds
|
package/package.json
CHANGED
package/src/granular/common.py
CHANGED
|
@@ -94,7 +94,7 @@ if not logging.getLogger().handlers:
|
|
|
94
94
|
handlers=[logging.StreamHandler()],
|
|
95
95
|
)
|
|
96
96
|
|
|
97
|
-
VERSION = "5.
|
|
97
|
+
VERSION = "5.3.1"
|
|
98
98
|
logger = logging.getLogger("davinci-resolve-mcp")
|
|
99
99
|
logger.info(f"Starting DaVinci Resolve MCP Server v{VERSION}")
|
|
100
100
|
logger.info(f"Detected platform: {get_platform()}")
|
package/src/server.py
CHANGED
|
@@ -11,7 +11,7 @@ Usage:
|
|
|
11
11
|
python src/server.py --full # Start the 377-tool granular server instead
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
-
VERSION = "5.
|
|
14
|
+
VERSION = "5.3.1"
|
|
15
15
|
|
|
16
16
|
import base64
|
|
17
17
|
import os
|
|
@@ -1797,6 +1797,21 @@ _TIMELINE_PIN_EXEMPT = frozenset({
|
|
|
1797
1797
|
("timeline", "list"), ("timeline", "set_current"),
|
|
1798
1798
|
("timeline", "import_timeline_checked"), ("timeline", "import_from_drp"),
|
|
1799
1799
|
})
|
|
1800
|
+
#: Actions of other tools that write to the current timeline and so take a pin
|
|
1801
|
+
#: too (#382). Only named actions: media_pool's create_timeline* and imports
|
|
1802
|
+
#: read `timeline_name` as the name of the timeline they make.
|
|
1803
|
+
_TIMELINE_PIN_EXTRA = frozenset({
|
|
1804
|
+
("media_pool", "append_to_timeline"),
|
|
1805
|
+
})
|
|
1806
|
+
|
|
1807
|
+
|
|
1808
|
+
def _pin_aware(tool_name: str, action: str) -> bool:
|
|
1809
|
+
"""Whether timeline_id / timeline_name pin this call to a timeline."""
|
|
1810
|
+
if (tool_name, action) in _TIMELINE_PIN_EXTRA:
|
|
1811
|
+
return True
|
|
1812
|
+
return tool_name in _TIMELINE_SCOPED_TOOLS and (tool_name, action) not in _TIMELINE_PIN_EXEMPT
|
|
1813
|
+
|
|
1814
|
+
|
|
1800
1815
|
_PIN_ID_KEYS = ("timeline_id", "timelineId")
|
|
1801
1816
|
_PIN_NAME_KEYS = ("timeline_name", "timelineName")
|
|
1802
1817
|
#: Keys the wrapper and the envelope read, never the action.
|
|
@@ -1804,6 +1819,8 @@ _ENVELOPE_PARAM_KEYS = frozenset({"envelope", "_envelope", "execution_id", "_exe
|
|
|
1804
1819
|
|
|
1805
1820
|
_call_depth = contextvars.ContextVar("resolve_mcp_call_depth", default=0)
|
|
1806
1821
|
_acted_timeline = contextvars.ContextVar("resolve_mcp_acted_timeline", default=None)
|
|
1822
|
+
#: The timeline a pinned call targets, for the length of that call (#382).
|
|
1823
|
+
_pinned_timeline = contextvars.ContextVar("resolve_mcp_pinned_timeline", default=None)
|
|
1807
1824
|
|
|
1808
1825
|
|
|
1809
1826
|
def _note_timeline(tl):
|
|
@@ -1812,6 +1829,121 @@ def _note_timeline(tl):
|
|
|
1812
1829
|
_acted_timeline.set(tl)
|
|
1813
1830
|
|
|
1814
1831
|
|
|
1832
|
+
# ── The current timeline can move under a call (#382) ────────────────────────
|
|
1833
|
+
#
|
|
1834
|
+
# A pin makes its timeline current once, at the start of the call. Several
|
|
1835
|
+
# Resolve calls act on whatever is current *when they run*, not on a Timeline
|
|
1836
|
+
# object: above all MediaPool.AppendToTimeline, which ripple_insert, move and
|
|
1837
|
+
# slip use to rebuild items. Another client (a second MCP server, a script,
|
|
1838
|
+
# the user clicking a timeline tab) can make a different timeline current
|
|
1839
|
+
# between the pin and that call, and the rebuilt items then land on the other
|
|
1840
|
+
# timeline while the deletes landed on ours. Unpinned calls have the same
|
|
1841
|
+
# window: `tl` is read once, the appends follow later.
|
|
1842
|
+
#
|
|
1843
|
+
# So every current-only write checks first that the current timeline is still
|
|
1844
|
+
# the one this call resolved, and refuses with both timelines named if not.
|
|
1845
|
+
# Nothing here serialises clients against each other: the check and the call
|
|
1846
|
+
# are two bridge round trips, so a narrow window remains. What it removes is
|
|
1847
|
+
# the silent case, where the write lands elsewhere and the call says success.
|
|
1848
|
+
|
|
1849
|
+
|
|
1850
|
+
def _current_timeline_of(proj=None):
|
|
1851
|
+
"""The current timeline, or None when it cannot be read.
|
|
1852
|
+
|
|
1853
|
+
None means "not measured", never "different": the guards below refuse only
|
|
1854
|
+
on an observed mismatch. With nothing current Resolve refuses the append on
|
|
1855
|
+
its own, and a reading that fails must not turn into a refusal it cannot
|
|
1856
|
+
justify.
|
|
1857
|
+
"""
|
|
1858
|
+
try:
|
|
1859
|
+
if proj is None:
|
|
1860
|
+
resolve = get_resolve()
|
|
1861
|
+
pm = resolve.GetProjectManager() if resolve else None
|
|
1862
|
+
proj = pm.GetCurrentProject() if pm else None
|
|
1863
|
+
return proj.GetCurrentTimeline() if proj else None
|
|
1864
|
+
except Exception as exc:
|
|
1865
|
+
logger.debug("Could not read the current timeline: %s", exc)
|
|
1866
|
+
return None
|
|
1867
|
+
|
|
1868
|
+
|
|
1869
|
+
def _moved_away(current, expected) -> bool:
|
|
1870
|
+
"""True only when a different timeline is measurably current."""
|
|
1871
|
+
if current is None or expected is None:
|
|
1872
|
+
return False
|
|
1873
|
+
try:
|
|
1874
|
+
return str(current.GetUniqueId()) != str(expected.GetUniqueId())
|
|
1875
|
+
except Exception:
|
|
1876
|
+
return False
|
|
1877
|
+
|
|
1878
|
+
|
|
1879
|
+
def _same_timeline(a, b) -> bool:
|
|
1880
|
+
try:
|
|
1881
|
+
return a is not None and b is not None and str(a.GetUniqueId()) == str(b.GetUniqueId())
|
|
1882
|
+
except Exception:
|
|
1883
|
+
return False
|
|
1884
|
+
|
|
1885
|
+
|
|
1886
|
+
def _timeline_changed_error(expected, current, *, stage: str, pinned: bool,
|
|
1887
|
+
partial: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
|
1888
|
+
exp, cur = _timeline_ref(expected), (_timeline_ref(current) if current is not None else None)
|
|
1889
|
+
exp_name = exp["name"] if exp else "?"
|
|
1890
|
+
cur_name = cur["name"] if cur else "no timeline"
|
|
1891
|
+
if pinned:
|
|
1892
|
+
code = "TIMELINE_PIN_LOST"
|
|
1893
|
+
message = (f"This call is pinned to timeline {exp_name!r}, but {cur_name!r} became "
|
|
1894
|
+
f"current before {stage}; refusing rather than writing to {cur_name!r}")
|
|
1895
|
+
else:
|
|
1896
|
+
code = "TIMELINE_CHANGED"
|
|
1897
|
+
message = (f"This call started on timeline {exp_name!r}, but {cur_name!r} became "
|
|
1898
|
+
f"current before {stage}; refusing rather than writing to {cur_name!r}")
|
|
1899
|
+
state: Dict[str, Any] = {"expected_timeline": exp, "current_timeline": cur, "stage": stage}
|
|
1900
|
+
if partial:
|
|
1901
|
+
state.update(partial)
|
|
1902
|
+
remediation = ("Part of this edit already ran on the expected timeline (see state). "
|
|
1903
|
+
"Restore it from the archive timeline_versioning made before the edit, "
|
|
1904
|
+
"then re-run with timeline_id so the call is pinned.")
|
|
1905
|
+
else:
|
|
1906
|
+
remediation = ("Another client or the user made a different timeline current during this "
|
|
1907
|
+
"call. The refused write reached neither timeline. If this action had already "
|
|
1908
|
+
"changed the expected timeline (a delete before its re-append), restore it from "
|
|
1909
|
+
"the archive timeline_versioning made before the edit. Then re-run with "
|
|
1910
|
+
"timeline_id so the call is pinned to the timeline you mean.")
|
|
1911
|
+
# Not retryable by default: a blind retry can repeat steps that already ran.
|
|
1912
|
+
return _err(message, code=code, category="busy", retryable=False,
|
|
1913
|
+
remediation=remediation, state=state)
|
|
1914
|
+
|
|
1915
|
+
|
|
1916
|
+
def _pin_lost_error(proj, tl):
|
|
1917
|
+
"""A pinned call whose timeline is no longer current gets this, not the other one."""
|
|
1918
|
+
target = _pinned_timeline.get()
|
|
1919
|
+
if not _moved_away(tl, target):
|
|
1920
|
+
return None
|
|
1921
|
+
return _timeline_changed_error(target, tl, stage="the action read its timeline", pinned=True)
|
|
1922
|
+
|
|
1923
|
+
|
|
1924
|
+
class _TimelineChanged(Exception):
|
|
1925
|
+
"""Raised by `_guarded_append` so a write never reaches the wrong timeline.
|
|
1926
|
+
|
|
1927
|
+
Sites that catch `Exception` around an append record it as that row's
|
|
1928
|
+
failure, which is the outcome wanted: nothing further is appended anywhere.
|
|
1929
|
+
The tool wrapper turns an uncaught one into the structured error.
|
|
1930
|
+
"""
|
|
1931
|
+
|
|
1932
|
+
def __init__(self, error: Dict[str, Any]):
|
|
1933
|
+
super().__init__(error.get("error") if isinstance(error, dict) else str(error))
|
|
1934
|
+
self.error = error
|
|
1935
|
+
|
|
1936
|
+
|
|
1937
|
+
def _guarded_append(mp, tl, infos, *, proj=None, stage: str = "AppendToTimeline"):
|
|
1938
|
+
"""`mp.AppendToTimeline(infos)`, refused if `tl` is no longer the current timeline."""
|
|
1939
|
+
current = _current_timeline_of(proj)
|
|
1940
|
+
if _moved_away(current, tl):
|
|
1941
|
+
pinned = _pinned_timeline.get()
|
|
1942
|
+
raise _TimelineChanged(_timeline_changed_error(
|
|
1943
|
+
tl, current, stage=stage, pinned=pinned is not None and _same_timeline(pinned, tl)))
|
|
1944
|
+
return mp.AppendToTimeline(infos)
|
|
1945
|
+
|
|
1946
|
+
|
|
1815
1947
|
def _timeline_ref(tl) -> Optional[Dict[str, Any]]:
|
|
1816
1948
|
try:
|
|
1817
1949
|
return {"name": str(tl.GetName()), "id": str(tl.GetUniqueId())}
|
|
@@ -1846,9 +1978,11 @@ class _CallScope:
|
|
|
1846
1978
|
self.kwargs = {**kwargs, "params": self.params}
|
|
1847
1979
|
else:
|
|
1848
1980
|
self.args = (args[0], self.params, *args[2:])
|
|
1849
|
-
|
|
1850
|
-
|
|
1981
|
+
self._pinned_token = None
|
|
1982
|
+
if (self.params and _pin_aware(tool_name, action)):
|
|
1851
1983
|
self.error = self._pin()
|
|
1984
|
+
if self.pin:
|
|
1985
|
+
self._pinned_token = _pinned_timeline.set(self.pin[2])
|
|
1852
1986
|
|
|
1853
1987
|
def _pin(self):
|
|
1854
1988
|
p = self.params
|
|
@@ -1970,7 +2104,9 @@ class _CallScope:
|
|
|
1970
2104
|
|
|
1971
2105
|
def annotate(self, enveloped):
|
|
1972
2106
|
"""Name the timeline acted on in the envelope (#320)."""
|
|
1973
|
-
if not self.outer or
|
|
2107
|
+
if (not self.outer or not isinstance(enveloped, dict)
|
|
2108
|
+
or (self.tool_name not in _TIMELINE_SCOPED_TOOLS
|
|
2109
|
+
and (self.tool_name, self.action) not in _TIMELINE_PIN_EXTRA)):
|
|
1974
2110
|
return enveloped
|
|
1975
2111
|
acted = self.pin[2] if self.pin else _acted_timeline.get()
|
|
1976
2112
|
ref = _timeline_ref(acted) if acted is not None else None
|
|
@@ -1991,6 +2127,8 @@ class _CallScope:
|
|
|
1991
2127
|
return enveloped
|
|
1992
2128
|
|
|
1993
2129
|
def close(self):
|
|
2130
|
+
if getattr(self, "_pinned_token", None) is not None:
|
|
2131
|
+
_pinned_timeline.reset(self._pinned_token)
|
|
1994
2132
|
if self._timeline_token is not None:
|
|
1995
2133
|
_acted_timeline.reset(self._timeline_token)
|
|
1996
2134
|
_call_depth.reset(self._depth_token)
|
|
@@ -2047,6 +2185,8 @@ def _guard_missing_params(fn):
|
|
|
2047
2185
|
result = await fn(*args, **kwargs)
|
|
2048
2186
|
except _MissingParam as exc:
|
|
2049
2187
|
result = _missing_param_error(exc, action)
|
|
2188
|
+
except _TimelineChanged as exc:
|
|
2189
|
+
result = exc.error
|
|
2050
2190
|
except Exception as exc:
|
|
2051
2191
|
duration_ms = max(0, int((time.perf_counter() - t0) * 1000))
|
|
2052
2192
|
lifecycle.run_on_error(ctx, exc, duration_ms)
|
|
@@ -2088,6 +2228,8 @@ def _guard_missing_params(fn):
|
|
|
2088
2228
|
result = fn(*args, **kwargs)
|
|
2089
2229
|
except _MissingParam as exc:
|
|
2090
2230
|
result = _missing_param_error(exc, action)
|
|
2231
|
+
except _TimelineChanged as exc:
|
|
2232
|
+
result = exc.error
|
|
2091
2233
|
except Exception as exc:
|
|
2092
2234
|
duration_ms = max(0, int((time.perf_counter() - t0) * 1000))
|
|
2093
2235
|
lifecycle.run_on_error(ctx, exc, duration_ms)
|
|
@@ -3395,6 +3537,9 @@ def _get_tl():
|
|
|
3395
3537
|
code="NO_CURRENT_TIMELINE", category="precondition",
|
|
3396
3538
|
remediation="Open a timeline via timeline(action='set_current', params={'index': N}) or in the Resolve UI.",
|
|
3397
3539
|
)
|
|
3540
|
+
lost = _pin_lost_error(proj, tl)
|
|
3541
|
+
if lost:
|
|
3542
|
+
return proj, None, lost
|
|
3398
3543
|
_note_timeline(tl)
|
|
3399
3544
|
return proj, tl, None
|
|
3400
3545
|
|
|
@@ -5626,7 +5771,9 @@ def _append_and_recover_timeline_item(
|
|
|
5626
5771
|
if ierr:
|
|
5627
5772
|
return None, None, ierr
|
|
5628
5773
|
try:
|
|
5629
|
-
out = mp
|
|
5774
|
+
out = _guarded_append(mp, tl, [info])
|
|
5775
|
+
except _TimelineChanged as exc:
|
|
5776
|
+
return None, None, exc.error
|
|
5630
5777
|
except Exception as exc:
|
|
5631
5778
|
return None, None, _err(str(exc))
|
|
5632
5779
|
if not out or len(out) < 1:
|
|
@@ -6064,7 +6211,9 @@ def _slip_append(mp, tl, info: Dict[str, Any], *, duration: int, ratio: float,
|
|
|
6064
6211
|
# (null-id timeline items)'), so the track is read back for the item;
|
|
6065
6212
|
# the return is kept only as evidence in the attempt log.
|
|
6066
6213
|
try:
|
|
6067
|
-
returned = mp
|
|
6214
|
+
returned = _guarded_append(mp, tl, [dict(info)])
|
|
6215
|
+
except _TimelineChanged:
|
|
6216
|
+
raise
|
|
6068
6217
|
except Exception as exc:
|
|
6069
6218
|
attempts.append({"endFrame": info["endFrame"], "error": f"AppendToTimeline raised: {exc}"})
|
|
6070
6219
|
return None, info, attempts
|
|
@@ -6626,6 +6775,14 @@ def _timeline_ripple_insert_impl(proj, tl, p: Dict[str, Any], *, resolve=None) -
|
|
|
6626
6775
|
# nests harmlessly inside, and the appends/restores run without a page
|
|
6627
6776
|
# flip per call.
|
|
6628
6777
|
tail_items = [row["item"] for row in tail_rows]
|
|
6778
|
+
# The delete acts on `tl`; the re-appends act on whatever is current. If
|
|
6779
|
+
# another client has moved the current timeline, the tail would vanish
|
|
6780
|
+
# here and reappear on theirs (#382), so check before touching anything.
|
|
6781
|
+
current = _current_timeline_of(proj)
|
|
6782
|
+
if _moved_away(current, tl):
|
|
6783
|
+
return _timeline_changed_error(
|
|
6784
|
+
tl, current, stage="the ripple delete",
|
|
6785
|
+
pinned=_same_timeline(_pinned_timeline.get(), tl))
|
|
6629
6786
|
with _edit_page_for_timeline_edits(resolve):
|
|
6630
6787
|
if tail_items and not _timeline_delete_clips_verified(tl, tail_items, False, resolve=resolve):
|
|
6631
6788
|
return _err(
|
|
@@ -6636,25 +6793,47 @@ def _timeline_ripple_insert_impl(proj, tl, p: Dict[str, Any], *, resolve=None) -
|
|
|
6636
6793
|
remediation="Check track locks and retry; the timeline is unchanged.",
|
|
6637
6794
|
)
|
|
6638
6795
|
failures: List[Dict[str, Any]] = []
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6796
|
+
reappended = 0
|
|
6797
|
+
inserted = 0
|
|
6798
|
+
try:
|
|
6799
|
+
for row in tail_rows:
|
|
6800
|
+
try:
|
|
6801
|
+
out_items = _guarded_append(mp, tl, [row["info"]], proj=proj, stage="a tail re-append")
|
|
6802
|
+
except _TimelineChanged:
|
|
6803
|
+
raise
|
|
6804
|
+
except Exception as exc:
|
|
6805
|
+
out_items = None
|
|
6806
|
+
row["append_error"] = str(exc)
|
|
6807
|
+
if out_items:
|
|
6808
|
+
reappended += 1
|
|
6809
|
+
else:
|
|
6810
|
+
failures.append({**_ripple_public_row(row),
|
|
6811
|
+
"stage": "tail_reappend",
|
|
6812
|
+
"expected_start": row["start"] + shift,
|
|
6813
|
+
"error": row.get("append_error", "AppendToTimeline returned no item")})
|
|
6814
|
+
for idx, info in enumerate(built_inserts):
|
|
6815
|
+
try:
|
|
6816
|
+
out_items = _guarded_append(mp, tl, [info], proj=proj, stage="an insert append")
|
|
6817
|
+
except _TimelineChanged:
|
|
6818
|
+
raise
|
|
6819
|
+
except Exception as exc:
|
|
6820
|
+
out_items = None
|
|
6821
|
+
insert_summaries[idx]["append_error"] = str(exc)
|
|
6822
|
+
if out_items:
|
|
6823
|
+
inserted += 1
|
|
6824
|
+
else:
|
|
6825
|
+
failures.append({**insert_summaries[idx], "stage": "insert"})
|
|
6826
|
+
except _TimelineChanged as exc:
|
|
6827
|
+
# The tail is already off `tl`. Stop: every further append would
|
|
6828
|
+
# land on the other client's timeline. Say exactly what ran.
|
|
6829
|
+
state = exc.error.get("state") or {}
|
|
6830
|
+
return _timeline_changed_error(
|
|
6831
|
+
tl, _current_timeline_of(proj), stage=state.get("stage", "an append"),
|
|
6832
|
+
pinned=_same_timeline(_pinned_timeline.get(), tl),
|
|
6833
|
+
partial={"tail_items_deleted": len(tail_items),
|
|
6834
|
+
"tail_items_reappended": reappended,
|
|
6835
|
+
"inserts_placed": inserted,
|
|
6836
|
+
"inserts_requested": len(built_inserts)})
|
|
6658
6837
|
|
|
6659
6838
|
# Restore captured transform/crop/composite/retime properties on shifted items.
|
|
6660
6839
|
restored = 0
|
|
@@ -8153,7 +8332,7 @@ def _timeline_create_variant_from_ranges(proj, source_tl, p: Dict[str, Any]) ->
|
|
|
8153
8332
|
while int(new_tl.GetTrackCount(track_type) or 0) < needed:
|
|
8154
8333
|
if not new_tl.AddTrack(track_type):
|
|
8155
8334
|
break
|
|
8156
|
-
appended = mp
|
|
8335
|
+
appended = _guarded_append(mp, new_tl, append_infos, proj=proj)
|
|
8157
8336
|
if not appended:
|
|
8158
8337
|
return _err("AppendToTimeline returned no items for variant")
|
|
8159
8338
|
items_out = []
|
|
@@ -11108,7 +11287,7 @@ def _setup_multicam_timeline(proj, mp, p: Dict[str, Any]):
|
|
|
11108
11287
|
if clip_err:
|
|
11109
11288
|
return clip_err
|
|
11110
11289
|
append_infos.append(clip_info)
|
|
11111
|
-
appended = mp
|
|
11290
|
+
appended = _guarded_append(mp, new_tl, append_infos, proj=proj)
|
|
11112
11291
|
if not appended:
|
|
11113
11292
|
return _err("AppendToTimeline returned no items for multicam setup")
|
|
11114
11293
|
|
|
@@ -15999,10 +16178,14 @@ def _append_to_timeline_with_verification(proj, mp, append_payload, requested: D
|
|
|
15999
16178
|
if blocked:
|
|
16000
16179
|
return None, None, None, blocked
|
|
16001
16180
|
raw_result = {"value": None}
|
|
16181
|
+
expected_tl = _pinned_timeline.get() or proj.GetCurrentTimeline()
|
|
16002
16182
|
before = _timeline_append_readback_snapshot(proj)
|
|
16003
16183
|
|
|
16004
16184
|
def mutate():
|
|
16005
|
-
|
|
16185
|
+
if expected_tl is None: # nothing current: Resolve refuses on its own
|
|
16186
|
+
raw_result["value"] = mp.AppendToTimeline(append_payload)
|
|
16187
|
+
else:
|
|
16188
|
+
raw_result["value"] = _guarded_append(mp, expected_tl, append_payload, proj=proj)
|
|
16006
16189
|
return bool(raw_result["value"])
|
|
16007
16190
|
|
|
16008
16191
|
verification = verify_by_readback(
|
|
@@ -23721,6 +23904,8 @@ def media_pool(action: str, params: Optional[Dict[str, Any]] = None) -> Dict[str
|
|
|
23721
23904
|
CATASTROPHIC. Deletes timelines outright.
|
|
23722
23905
|
append_to_timeline(clip_ids) -> {success, count}
|
|
23723
23906
|
— legacy: params.clip_ids only (appends at end / default placement)
|
|
23907
|
+
— both forms take timeline_id / timeline_name to pin the target timeline;
|
|
23908
|
+
a different timeline made current mid-call is refused (TIMELINE_PIN_LOST).
|
|
23724
23909
|
append_to_timeline(clip_infos) -> {success, count, items}
|
|
23725
23910
|
— positioned: params.clip_infos is a list of {clip_id or media_pool_item_id,
|
|
23726
23911
|
start_frame & end_frame (or startFrame/endFrame), record_frame/recordFrame,
|
|
@@ -23911,7 +24096,7 @@ def media_pool(action: str, params: Optional[Dict[str, Any]] = None) -> Dict[str
|
|
|
23911
24096
|
if row_err:
|
|
23912
24097
|
return row_err
|
|
23913
24098
|
built.append(row)
|
|
23914
|
-
appended = mp
|
|
24099
|
+
appended = _guarded_append(mp, tl, built, proj=proj)
|
|
23915
24100
|
if not appended:
|
|
23916
24101
|
return _err("Failed to append clip_infos to created timeline")
|
|
23917
24102
|
return _ok(
|
|
@@ -24013,13 +24198,19 @@ def media_pool(action: str, params: Optional[Dict[str, Any]] = None) -> Dict[str
|
|
|
24013
24198
|
return {"success": raw, "verified": after_n < before_n,
|
|
24014
24199
|
"timelines_before": before_n, "timelines_after": after_n}
|
|
24015
24200
|
elif action == "append_to_timeline":
|
|
24201
|
+
# AppendToTimeline writes to the current timeline; a pin (#382) has
|
|
24202
|
+
# made its timeline current, and the append re-checks right before.
|
|
24203
|
+
current_tl = proj.GetCurrentTimeline()
|
|
24204
|
+
lost = _pin_lost_error(proj, current_tl)
|
|
24205
|
+
if lost:
|
|
24206
|
+
return lost
|
|
24207
|
+
_note_timeline(current_tl)
|
|
24016
24208
|
if p.get("clip_infos") is not None:
|
|
24017
24209
|
raw = _rows_with_default_record_frame_mode(p["clip_infos"], p)
|
|
24018
24210
|
if not isinstance(raw, list):
|
|
24019
24211
|
return _err("clip_infos must be a list")
|
|
24020
24212
|
if not raw:
|
|
24021
24213
|
return _err("clip_infos must be a non-empty list")
|
|
24022
|
-
current_tl = proj.GetCurrentTimeline()
|
|
24023
24214
|
timeline_start = _timeline_start_frame(current_tl)
|
|
24024
24215
|
built = []
|
|
24025
24216
|
for i, ci in enumerate(raw):
|
|
@@ -27513,7 +27704,7 @@ def edit_engine(action: str, params: Optional[Dict[str, Any]] = None) -> Dict[st
|
|
|
27513
27704
|
# (end - start) frames. Advancing by +1 more leaves a 1-frame gap
|
|
27514
27705
|
# (black flash) between consecutive selects. See api_truth endFrame entry.
|
|
27515
27706
|
record_cursor += int(append_ci.get("end_frame", 0)) - int(append_ci.get("start_frame", 0))
|
|
27516
|
-
appended = mp
|
|
27707
|
+
appended = _guarded_append(mp, tl, built) if built else None
|
|
27517
27708
|
readback = _edit_engine_capture(tl)
|
|
27518
27709
|
# A diff against a source timeline is meaningless for a fresh assembly;
|
|
27519
27710
|
# a usage-snapshot summary is the structural readback that fits.
|
|
@@ -27916,7 +28107,7 @@ def edit_engine(action: str, params: Optional[Dict[str, Any]] = None) -> Dict[st
|
|
|
27916
28107
|
return {"success": False, "error": f"swap append failed: {row_err.get('error')}", "lifted": lift}
|
|
27917
28108
|
# No mediaType on the clip info: the replacement appends video+audio
|
|
27918
28109
|
# linked, mirroring the video + linked-audio lift above.
|
|
27919
|
-
appended = mp
|
|
28110
|
+
appended = _guarded_append(mp, tl, [row])
|
|
27920
28111
|
after = _edit_engine_capture(tl)
|
|
27921
28112
|
after["track_counts"] = _edit_engine_track_counts(tl)
|
|
27922
28113
|
run_id = _analysis_runs.current_run_id()
|
|
@@ -28422,6 +28613,9 @@ def timeline(action: str, params: Optional[Dict[str, Any]] = None) -> Dict[str,
|
|
|
28422
28613
|
tl = proj.GetCurrentTimeline()
|
|
28423
28614
|
if not tl:
|
|
28424
28615
|
return _err("No current timeline")
|
|
28616
|
+
lost = _pin_lost_error(proj, tl)
|
|
28617
|
+
if lost:
|
|
28618
|
+
return lost
|
|
28425
28619
|
_note_timeline(tl)
|
|
28426
28620
|
|
|
28427
28621
|
if action == "auto_align_clips":
|