@clipen/clipen-cli 1.0.0 → 1.0.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.
Files changed (127) hide show
  1. package/README.md +60 -50
  2. package/package.json +7 -4
  3. package/pyproject.toml +18 -2
  4. package/requirements/dev.txt +2 -0
  5. package/src/clipen/__init__.py +1 -1
  6. package/src/clipen/analysis/__init__.py +7 -7
  7. package/src/clipen/analysis/artifacts.py +4 -10
  8. package/src/clipen/analysis/audio.py +10 -8
  9. package/src/clipen/analysis/evidence_service.py +345 -167
  10. package/src/clipen/analysis/image_similarity.py +5 -14
  11. package/src/clipen/analysis/keyframes.py +5 -17
  12. package/src/clipen/analysis/models.py +5 -7
  13. package/src/clipen/analysis/qwen_worker.py +19 -54
  14. package/src/clipen/analysis/resources.py +2 -1
  15. package/src/clipen/analysis/runtime.py +1 -3
  16. package/src/clipen/analysis/service.py +16 -48
  17. package/src/clipen/analysis/setup.py +11 -25
  18. package/src/clipen/analysis/setup_cli.py +5 -15
  19. package/src/clipen/analysis/storage.py +96 -278
  20. package/src/clipen/analysis/transcription.py +40 -82
  21. package/src/clipen/analysis/visual.py +109 -48
  22. package/src/clipen/annotations/__init__.py +5 -2
  23. package/src/clipen/annotations/models.py +1 -1
  24. package/src/clipen/annotations/storage.py +132 -84
  25. package/src/clipen/annotations/suggestions.py +3 -8
  26. package/src/clipen/asr_release.py +4 -11
  27. package/src/clipen/bootstrap.py +65 -54
  28. package/src/clipen/{planning/models.py → candidates.py} +29 -47
  29. package/src/clipen/cli.py +2 -2
  30. package/src/clipen/controller/app.py +401 -214
  31. package/src/clipen/controller/server.py +28 -38
  32. package/src/clipen/domain/__init__.py +1 -1
  33. package/src/clipen/domain/media_time.py +3 -10
  34. package/src/clipen/domain/timeline.py +45 -47
  35. package/src/clipen/domain/validation.py +0 -1
  36. package/src/clipen/editing/__init__.py +1 -1
  37. package/src/clipen/editing/agent_models.py +4 -11
  38. package/src/clipen/editing/agent_repository.py +391 -170
  39. package/src/clipen/editing/agent_tools.py +180 -99
  40. package/src/clipen/editing/alignment.py +92 -52
  41. package/src/clipen/editing/alignment_setup.py +118 -70
  42. package/src/clipen/editing/alignment_worker.py +11 -9
  43. package/src/clipen/editing/change_report.py +95 -38
  44. package/src/clipen/editing/compiler.py +0 -1
  45. package/src/clipen/editing/component_looks.py +58 -34
  46. package/src/clipen/editing/component_review.py +34 -38
  47. package/src/clipen/editing/coordinator.py +213 -90
  48. package/src/clipen/editing/editorial_review.py +217 -95
  49. package/src/clipen/editing/evidence_jobs.py +457 -200
  50. package/src/clipen/editing/history_changes.py +129 -68
  51. package/src/clipen/editing/music_choices.py +8 -5
  52. package/src/clipen/editing/production_catalog.py +573 -136
  53. package/src/clipen/editing/production_limits.py +43 -17
  54. package/src/clipen/editing/production_media.py +376 -167
  55. package/src/clipen/editing/production_preview.py +322 -129
  56. package/src/clipen/editing/production_progress.py +164 -69
  57. package/src/clipen/editing/production_requirements.py +106 -39
  58. package/src/clipen/editing/production_tools.py +1064 -462
  59. package/src/clipen/editing/program_audio.py +211 -81
  60. package/src/clipen/editing/program_direction.py +59 -25
  61. package/src/clipen/editing/program_story.py +83 -45
  62. package/src/clipen/editing/program_subtitles.py +194 -96
  63. package/src/clipen/editing/programme_review.py +98 -50
  64. package/src/clipen/editing/prompt_history.py +64 -27
  65. package/src/clipen/editing/recut.py +65 -25
  66. package/src/clipen/editing/refinement_references.py +176 -86
  67. package/src/clipen/editing/resolve_export.py +449 -218
  68. package/src/clipen/editing/resolve_titles.py +162 -105
  69. package/src/clipen/editing/skill_tools.py +530 -154
  70. package/src/clipen/editing/source_dialogue.py +177 -67
  71. package/src/clipen/editing/speech_coverage.py +42 -22
  72. package/src/clipen/editing/speech_quality.py +6 -1
  73. package/src/clipen/editing/tool_receipts.py +78 -32
  74. package/src/clipen/editing/versions.py +122 -64
  75. package/src/clipen/editing/visual_preview.py +157 -61
  76. package/src/clipen/editing/workbench.py +104 -42
  77. package/src/clipen/finishing/audio.py +69 -30
  78. package/src/clipen/finishing/catalog.py +176 -93
  79. package/src/clipen/finishing/models.py +1 -1
  80. package/src/clipen/finishing/renderer.py +33 -14
  81. package/src/clipen/mcp_editing/__main__.py +3 -1
  82. package/src/clipen/mcp_editing/server.py +77 -34
  83. package/src/clipen/media/__init__.py +3 -3
  84. package/src/clipen/media/discovery.py +7 -20
  85. package/src/clipen/media/models.py +7 -18
  86. package/src/clipen/media/preview.py +14 -24
  87. package/src/clipen/media/probe.py +16 -44
  88. package/src/clipen/media/service.py +6 -19
  89. package/src/clipen/media/storage.py +33 -81
  90. package/src/clipen/music_vocabulary.py +33 -4
  91. package/src/clipen/power.py +8 -3
  92. package/src/clipen/projects/__init__.py +1 -1
  93. package/src/clipen/projects/deletion.py +19 -32
  94. package/src/clipen/projects/finishing_schema.py +3 -1
  95. package/src/clipen/projects/models.py +2 -5
  96. package/src/clipen/projects/picker.py +13 -37
  97. package/src/clipen/projects/service.py +8 -24
  98. package/src/clipen/projects/storage.py +226 -246
  99. package/src/clipen/provider_registry.py +4 -2
  100. package/src/clipen/providers/account.py +86 -35
  101. package/src/clipen/providers/claude.py +59 -25
  102. package/src/clipen/providers/claude_editing.py +14 -7
  103. package/src/clipen/providers/codex.py +73 -118
  104. package/src/clipen/providers/codex_editing.py +2 -2
  105. package/src/clipen/providers/editing_agent.py +19 -17
  106. package/src/clipen/providers/recovery.py +7 -8
  107. package/src/clipen/rendering/cover.py +18 -5
  108. package/src/clipen/rendering/custom_components.py +167 -79
  109. package/src/clipen/rendering/custom_render.py +62 -41
  110. package/src/clipen/rendering/production_effects.py +77 -45
  111. package/src/clipen/rendering/program_components.py +134 -73
  112. package/src/clipen/rendering/program_creator.py +432 -277
  113. package/src/clipen/rendering/program_identities.py +277 -182
  114. package/src/clipen/rendering/program_motion.py +140 -95
  115. package/src/clipen/rendering/program_studio.py +175 -116
  116. package/src/clipen/rendering/program_styles.py +231 -145
  117. package/src/clipen/rendering/program_subtitles.py +71 -34
  118. package/src/clipen/rendering/renderer.py +150 -121
  119. package/src/clipen/rendering/storage.py +9 -22
  120. package/src/clipen/rendering/titles.py +193 -86
  121. package/src/clipen/skills/__init__.py +1 -0
  122. package/src/clipen/skills/catalog.py +151 -55
  123. package/src/clipen/skills/library.py +13 -7
  124. package/src/clipen/skills/package.py +46 -23
  125. package/src/clipen/skills/visual_styles.py +29 -18
  126. package/src/clipen/workspace.py +15 -44
  127. package/src/clipen/planning/__init__.py +0 -9
@@ -1,106 +1,430 @@
1
1
  """Discoverable contracts for the agent's production tools, shared by MCP and dispatch."""
2
+
2
3
  import json
3
- from clipen.music_vocabulary import MUSIC_TAGS
4
+
4
5
  from jsonschema import Draft202012Validator
6
+
7
+ from clipen.music_vocabulary import MUSIC_TAGS
5
8
  from clipen.projects import ProjectError
6
9
 
7
10
 
8
11
  def schema(name, description, properties=None, required=None):
9
12
  properties = properties or {}
10
- return {'name': name, 'description': description, 'inputSchema': {
11
- 'type':'object', 'properties':properties, 'required':list(properties if required is None else required),
12
- 'additionalProperties':False}}
13
+ return {
14
+ "name": name,
15
+ "description": description,
16
+ "inputSchema": {
17
+ "type": "object",
18
+ "properties": properties,
19
+ "required": list(properties if required is None else required),
20
+ "additionalProperties": False,
21
+ },
22
+ }
13
23
 
14
24
 
15
- ID={'type':'string','minLength':1,'maxLength':160}
16
- TEXT={'type':'string','minLength':1,'maxLength':500}
17
- FRAME={'type':'integer','minimum':0,'maximum':108000}
18
- LENGTH={'type':'integer','minimum':1,'maximum':108000}
19
- UNIT={'type':'number','minimum':0,'maximum':1}
20
- GAIN={'type':'number','minimum':-60,'maximum':12}
21
- SPAN={'start_frame':FRAME,'duration_frames':LENGTH}
22
- SUMMARY={'summary':TEXT}
23
- RECT={**SPAN,'x':UNIT,'y':UNIT,'width':{'type':'number','exclusiveMinimum':0,'maximum':1},
24
- 'height':{'type':'number','exclusiveMinimum':0,'maximum':1},'block_size':{'type':'integer','minimum':4,'maximum':96}}
25
- EXTRA_TOOLS=(
26
- schema('list_editing_tools','Discover executable tools, limits and explicitly unsupported capabilities.'),
27
- schema('search_source_dialogue','Search all current source transcripts before choosing clips. Empty query browses complete utterances. Includes adjacent speech for context; inspect actual footage before inferring events.',
28
- {'query':{'type':'string','maxLength':120},'version_id':ID,'include_drafts':{'type':'boolean'},
29
- 'offset':{'type':'integer','minimum':0,'maximum':100000},'limit':{'type':'integer','minimum':1,'maximum':30}},[]),
30
- schema('list_source_media','Page through all currently inventoried source streams, including material absent from earlier candidate selection. Never copies reference footage.',
31
- {'offset':{'type':'integer','minimum':0,'maximum':100000},'limit':{'type':'integer','minimum':1,'maximum':50}},[]),
32
- schema('register_source_range','Create an executable candidate anywhere inside an inventoried source stream. Record observations as model-authored evidence, not verified transcript.',
33
- {'version_id':ID,'stream_index':{'type':'integer','minimum':0,'maximum':4096},'start_offset_seconds':{'type':'number','minimum':0},
34
- 'duration_seconds':{'type':'number','exclusiveMinimum':0,'maximum':3600},'description':TEXT}),
35
- schema('record_story_plan','Persist the agent-authored story plan and uncertainties against real candidates; this does not pretend the user confirmed the new treatment.',
36
- {'intent':TEXT,'sections':{'type':'array','minItems':1,'maxItems':30,'items':{'type':'object','properties':{'purpose':TEXT,'candidate_ids':{'type':'array','items':ID,'maxItems':30},'treatment':TEXT},'required':['purpose','candidate_ids','treatment'],'additionalProperties':False}},
37
- 'uncertainties':{'type':'array','items':TEXT,'maxItems':30}}),
38
- schema('read_story_plan','Read the last model-authored story plan for this run; the confirmed user intent remains separately available.'),
39
- schema('plan_episode','Plan a dialogue-led programme: audience question, real experience, response/payoff and a purpose for every selected shot. Optional start_frame/duration_frames mark beats within continuous shots without artificial cuts; beats must cover the timeline once in order. Link retained cue IDs when quoting speech. This is an authored treatment, not evidence that the story is entertaining.',
40
- {'premise':TEXT,'audience_question':TEXT,'payoff':TEXT,'beats':{'type':'array','minItems':1,'maxItems':30,'items':{'type':'object','properties':{
41
- 'beat_id':ID,'role':{'enum':['hook','setup','experience','response','payoff','bridge']},
25
+ ID = {"type": "string", "minLength": 1, "maxLength": 160}
26
+ TEXT = {"type": "string", "minLength": 1, "maxLength": 500}
27
+ FRAME = {"type": "integer", "minimum": 0, "maximum": 108000}
28
+ LENGTH = {"type": "integer", "minimum": 1, "maximum": 108000}
29
+ UNIT = {"type": "number", "minimum": 0, "maximum": 1}
30
+ GAIN = {"type": "number", "minimum": -60, "maximum": 12}
31
+ SPAN = {"start_frame": FRAME, "duration_frames": LENGTH}
32
+ SUMMARY = {"summary": TEXT}
33
+ RECT = {
34
+ **SPAN,
35
+ "x": UNIT,
36
+ "y": UNIT,
37
+ "width": {"type": "number", "exclusiveMinimum": 0, "maximum": 1},
38
+ "height": {"type": "number", "exclusiveMinimum": 0, "maximum": 1},
39
+ "block_size": {"type": "integer", "minimum": 4, "maximum": 96},
40
+ }
41
+ EXTRA_TOOLS = (
42
+ schema("list_editing_tools", "Discover executable tools, limits and explicitly unsupported capabilities."),
43
+ schema(
44
+ "search_source_dialogue",
45
+ "Search all current source transcripts before choosing clips. Empty query browses complete utterances. Includes adjacent speech for context; inspect actual footage before inferring events.",
46
+ {
47
+ "query": {"type": "string", "maxLength": 120},
48
+ "version_id": ID,
49
+ "include_drafts": {"type": "boolean"},
50
+ "offset": {"type": "integer", "minimum": 0, "maximum": 100000},
51
+ "limit": {"type": "integer", "minimum": 1, "maximum": 30},
52
+ },
53
+ [],
54
+ ),
55
+ schema(
56
+ "list_source_media",
57
+ "Page through all currently inventoried source streams, including material absent from earlier candidate selection. Never copies reference footage.",
58
+ {
59
+ "offset": {"type": "integer", "minimum": 0, "maximum": 100000},
60
+ "limit": {"type": "integer", "minimum": 1, "maximum": 50},
61
+ },
62
+ [],
63
+ ),
64
+ schema(
65
+ "register_source_range",
66
+ "Create an executable candidate anywhere inside an inventoried source stream. Record observations as model-authored evidence, not verified transcript.",
67
+ {
68
+ "version_id": ID,
69
+ "stream_index": {"type": "integer", "minimum": 0, "maximum": 4096},
70
+ "start_offset_seconds": {"type": "number", "minimum": 0},
71
+ "duration_seconds": {"type": "number", "exclusiveMinimum": 0, "maximum": 3600},
72
+ "description": TEXT,
73
+ },
74
+ ),
75
+ schema(
76
+ "record_story_plan",
77
+ "Persist the agent-authored story plan and uncertainties against real candidates; this does not pretend the user confirmed the new treatment.",
78
+ {
79
+ "intent": TEXT,
80
+ "sections": {
81
+ "type": "array",
82
+ "minItems": 1,
83
+ "maxItems": 30,
84
+ "items": {
85
+ "type": "object",
86
+ "properties": {
87
+ "purpose": TEXT,
88
+ "candidate_ids": {"type": "array", "items": ID, "maxItems": 30},
89
+ "treatment": TEXT,
90
+ },
91
+ "required": ["purpose", "candidate_ids", "treatment"],
92
+ "additionalProperties": False,
93
+ },
94
+ },
95
+ "uncertainties": {"type": "array", "items": TEXT, "maxItems": 30},
96
+ },
97
+ ),
98
+ schema(
99
+ "read_story_plan",
100
+ "Read the last model-authored story plan for this run; the confirmed user intent remains separately available.",
101
+ ),
102
+ schema(
103
+ "plan_episode",
104
+ "Plan a dialogue-led programme: audience question, real experience, response/payoff and a purpose for every selected shot. Optional start_frame/duration_frames mark beats within continuous shots without artificial cuts; beats must cover the timeline once in order. Link retained cue IDs when quoting speech. This is an authored treatment, not evidence that the story is entertaining.",
105
+ {
106
+ "premise": TEXT,
107
+ "audience_question": TEXT,
108
+ "payoff": TEXT,
109
+ "beats": {
110
+ "type": "array",
111
+ "minItems": 1,
112
+ "maxItems": 30,
113
+ "items": {
114
+ "type": "object",
115
+ "properties": {
116
+ "beat_id": ID,
117
+ "role": {"enum": ["hook", "setup", "experience", "response", "payoff", "bridge"]},
118
+ **SPAN,
119
+ "item_ids": {"type": "array", "items": ID, "minItems": 1, "maxItems": 30, "uniqueItems": True},
120
+ "dialogue_ids": {"type": "array", "items": ID, "maxItems": 30, "uniqueItems": True},
121
+ "source_evidence": TEXT,
122
+ "audience_takeaway": TEXT,
123
+ },
124
+ "required": ["beat_id", "role", "item_ids", "dialogue_ids", "source_evidence", "audience_takeaway"],
125
+ "additionalProperties": False,
126
+ },
127
+ },
128
+ },
129
+ ),
130
+ schema(
131
+ "set_canvas",
132
+ "Choose a bounded SDR preview canvas before styling. Changes the revision and invalidates previous render review; source media and timing remain intact.",
133
+ {"width": {"enum": [640, 1280, 1920]}, "height": {"enum": [360, 720, 1080]}, **SUMMARY},
134
+ ),
135
+ schema(
136
+ "set_target_duration",
137
+ "Update the production duration only when the latest user revision request changes the desired length (including matching selected music). Cite an exact request_excerpt and derive seconds from the request or measured music. Never lower the target just to pass delivery checks. Saves an audit event without changing shots, graphics, audio or render review.",
138
+ {
139
+ "target_duration_seconds": {"type": "integer", "minimum": 30, "maximum": 1200},
140
+ "request_excerpt": TEXT,
141
+ **SUMMARY,
142
+ },
143
+ ),
144
+ schema(
145
+ "sample_source",
146
+ "Choose exact sample offsets inside a candidate. Returns actual frames with source timestamps; does not infer unseen motion.",
147
+ {
148
+ "candidate_id": ID,
149
+ "offsets_seconds": {
150
+ "type": "array",
151
+ "items": {"type": "number", "minimum": 0},
152
+ "minItems": 1,
153
+ "maxItems": 8,
154
+ },
155
+ },
156
+ ),
157
+ schema(
158
+ "inspect_candidates",
159
+ "Audition up to three candidate source ranges before choosing shots. Returns start/middle/end images, transcripts and evidence limitations in one call. Prefer this to repeatedly requesting single cached stills; refine with sample_source when action is missed.",
160
+ {"candidate_ids": {"type": "array", "items": ID, "minItems": 1, "maxItems": 3, "uniqueItems": True}},
161
+ ),
162
+ schema(
163
+ "inspect_cut",
164
+ "Inspect start/middle/end of up to three current shots in one call, with exact source ranges, speech repair spans and overlapping text. Omit render_id to inspect sources before decorating; provide render_id for rendered review. All shots and text must be covered before finish.",
165
+ {
166
+ "item_ids": {"type": "array", "items": ID, "minItems": 1, "maxItems": 3, "uniqueItems": True},
167
+ "render_id": ID,
168
+ },
169
+ ["item_ids"],
170
+ ),
171
+ schema(
172
+ "inspect_pacing",
173
+ "Inspect actual source continuity across the current timeline. Adjacent pieces of the same take are grouped even when split; use this to find prolonged stretches to review. This does not decide whether a scene is interesting.",
174
+ ),
175
+ schema(
176
+ "review_cut",
177
+ "Save an editorial assessment of the exact current revision after inspecting every changed rendered shot (unchanged shots accepted earlier in this run are carried and may be omitted). Keep specific unresolved problems as revise/matches=false; these block finish. This is a model assessment, not human approval.",
178
+ {
179
+ "shots": {
180
+ "type": "array",
181
+ "maxItems": 180,
182
+ "items": {
183
+ "type": "object",
184
+ "properties": {"item_id": ID, "observation": TEXT, "decision": {"enum": ["keep", "revise"]}},
185
+ "required": ["item_id", "observation", "decision"],
186
+ "additionalProperties": False,
187
+ },
188
+ },
189
+ "text_checks": {
190
+ "type": "array",
191
+ "maxItems": 960,
192
+ "items": {
193
+ "type": "object",
194
+ "properties": {"item_id": ID, "evidence": TEXT, "matches": {"type": "boolean"}},
195
+ "required": ["item_id", "evidence", "matches"],
196
+ "additionalProperties": False,
197
+ },
198
+ },
199
+ "story_assessment": TEXT,
200
+ "audio_limitations": TEXT,
201
+ },
202
+ ),
203
+ schema(
204
+ "replace_clip_source",
205
+ "Replace one shot with an exact inventoried source span, including expansion to a complete utterance returned by list_transcripts. Reflows the timeline and invalidates overlays. Does not restrict selection to earlier candidate windows.",
206
+ {
207
+ "item_id": ID,
208
+ "source": {
209
+ "type": "object",
210
+ "properties": {
211
+ "version_id": ID,
212
+ "stream_index": {"type": "integer", "minimum": 0},
213
+ "start_pts": {"type": "string", "pattern": "^-?[0-9]+$"},
214
+ "end_pts": {"type": "string", "pattern": "^-?[0-9]+$"},
215
+ "time_base": {
216
+ "type": "object",
217
+ "properties": {
218
+ "num": {"type": "integer", "minimum": 1},
219
+ "den": {"type": "integer", "minimum": 1},
220
+ },
221
+ "required": ["num", "den"],
222
+ "additionalProperties": False,
223
+ },
224
+ },
225
+ "required": ["version_id", "stream_index", "start_pts", "end_pts", "time_base"],
226
+ "additionalProperties": False,
227
+ },
228
+ **SUMMARY,
229
+ },
230
+ ),
231
+ schema(
232
+ "list_transcripts",
233
+ "Read complete source utterances remapped to the current cut, or a candidate before cutting. include_drafts explicitly exposes low-confidence ASR as unverified draft cues, not human-approved speech.",
234
+ {"candidate_id": ID, "include_drafts": {"type": "boolean"}},
235
+ [],
236
+ ),
237
+ schema(
238
+ "replace_subtitles",
239
+ "Replace the editable subtitle track using returned cue IDs and faithful text; [] removes subtitles. source_excerpt selects an exact character range [start,end) in the source cue, with estimated timing, to omit uncertain ASR without inventing replacement speech. Omit unreliable cues entirely when needed; original audio is preserved.",
240
+ {
241
+ "captions": {
242
+ "type": "array",
243
+ "items": {
244
+ "type": "object",
245
+ "properties": {
246
+ "cue_id": ID,
247
+ "text": TEXT,
248
+ "source_excerpt": {
249
+ "type": "object",
250
+ "properties": {
251
+ "start": {"type": "integer", "minimum": 0, "maximum": 500},
252
+ "end": {"type": "integer", "minimum": 1, "maximum": 500},
253
+ },
254
+ "required": ["start", "end"],
255
+ "additionalProperties": False,
256
+ },
257
+ "delivery": {"enum": ["dialogue", "punchline", "quiet"]},
258
+ "emphasis": {
259
+ "type": "array",
260
+ "items": {"type": "string", "minLength": 1, "maxLength": 16},
261
+ "maxItems": 4,
262
+ "uniqueItems": True,
263
+ },
264
+ },
265
+ "required": ["cue_id", "text"],
266
+ "additionalProperties": False,
267
+ },
268
+ "maxItems": 960,
269
+ },
270
+ "allow_asr_draft": {"type": "boolean"},
271
+ **SUMMARY,
272
+ },
273
+ ["captions", "summary"],
274
+ ),
275
+ schema(
276
+ "remove_item",
277
+ "Delete a selected timeline element; video deletion closes the gap and invalidates time-bound overlays.",
278
+ {"item_id": ID, **SUMMARY},
279
+ ),
280
+ schema(
281
+ "trim_clip",
282
+ "Trim within the current source span, close the gap, and invalidate overlays/audio placements whose timing changed.",
283
+ {"item_id": ID, "start_offset_frames": FRAME, "duration_frames": LENGTH, **SUMMARY},
284
+ ),
285
+ schema(
286
+ "reorder_clips",
287
+ "Reorder all video item IDs exactly once. Clears overlays and audio placements; inspect and reapply them against the new cut.",
288
+ {"item_ids": {"type": "array", "items": ID, "minItems": 1, "maxItems": 180}, **SUMMARY},
289
+ ),
290
+ schema(
291
+ "split_clip",
292
+ "Split a video clip at a relative frame. Existing effects/placements on that clip are cleared for explicit reapplication.",
293
+ {"item_id": ID, "offset_frames": LENGTH, **SUMMARY},
294
+ ),
295
+ schema(
296
+ "insert_clip",
297
+ "Insert a precisely trimmed candidate before a video item, or at end when before_item_id is null. Invalidates overlays.",
298
+ {
299
+ "candidate_id": ID,
300
+ "start_offset_seconds": {"type": "number", "minimum": 0},
301
+ "duration_seconds": {"type": "number", "minimum": 0.75, "maximum": 30},
302
+ "before_item_id": {"anyOf": [ID, {"type": "null"}]},
303
+ **SUMMARY,
304
+ },
305
+ ),
306
+ schema(
307
+ "set_source_audio",
308
+ "Choose camera sound treatment and gain for one video clip.",
309
+ {"item_id": ID, "mode": {"enum": ["keep", "mute", "dialogue"]}, "gain_db": GAIN, **SUMMARY},
310
+ ),
311
+ schema(
312
+ "set_color_grade",
313
+ "Set explicit per-clip exposure/contrast/saturation; neutral values remove the visual grade.",
314
+ {
315
+ "item_id": ID,
316
+ "contrast": {"type": "number", "minimum": 0.5, "maximum": 2},
317
+ "saturation": {"type": "number", "minimum": 0, "maximum": 2},
318
+ "brightness": {"type": "number", "minimum": -0.3, "maximum": 0.3},
319
+ **SUMMARY,
320
+ },
321
+ ),
322
+ schema(
323
+ "set_mosaic",
324
+ "Set static timed rectangular mosaic regions in final canvas coordinates. Multiple intervals permit manual tracking; no automatic tracking claim. [] clears.",
325
+ {
326
+ "item_id": ID,
327
+ "regions": {
328
+ "type": "array",
329
+ "items": {"type": "object", "properties": RECT, "required": list(RECT), "additionalProperties": False},
330
+ "maxItems": 32,
331
+ },
332
+ **SUMMARY,
333
+ },
334
+ ),
335
+ schema(
336
+ "set_transition",
337
+ "Set a dip to black/white at the incoming clip boundary, or none. Duration is in timeline frames.",
338
+ {
339
+ "item_id": ID,
340
+ "kind": {"enum": ["dip_black", "dip_white", "none"]},
341
+ "duration_frames": {"type": "integer", "minimum": 2, "maximum": 60},
342
+ **SUMMARY,
343
+ },
344
+ ),
345
+ schema(
346
+ "set_fade",
347
+ "Fade the beginning/end of THIS shot to black. Use fade_out_frames on the final shot for an actual ending. This is independent of incoming scene transitions. Zero removes that fade.",
348
+ {"item_id": ID, "fade_in_frames": FRAME, "fade_out_frames": FRAME, **SUMMARY},
349
+ ),
350
+ schema(
351
+ "remove_clip_effect",
352
+ "Remove any named semantic effect from a video/audio clip.",
353
+ {"item_id": ID, "effect_id": ID, **SUMMARY},
354
+ ),
355
+ schema(
356
+ "search_music",
357
+ "Search and acquire up to three public instrumental candidates. Only generic music tags leave the project; preserve source/license evidence.",
358
+ {"tags": {"type": "array", "items": {"enum": MUSIC_TAGS}, "minItems": 1, "maxItems": 4}},
359
+ ),
360
+ schema("list_audio_assets", "List acquired audio candidates and provenance without filesystem paths."),
361
+ schema(
362
+ "extract_audio",
363
+ "Prepare a local source range as an audio asset for ambience, dialogue or sound effects. No ownership/license claim is invented.",
364
+ {
365
+ "candidate_id": ID,
366
+ "start_offset_seconds": {"type": "number", "minimum": 0},
367
+ "duration_seconds": {"type": "number", "exclusiveMinimum": 0, "maximum": 90},
368
+ },
369
+ ),
370
+ schema(
371
+ "inspect_audio",
372
+ "Read measured loudness, peaks, onsets, BPM and source/license metadata. This is analysis, not listening.",
373
+ {"asset_id": ID},
374
+ ),
375
+ schema(
376
+ "place_audio",
377
+ "Add/update a named audio layer anchored to a video clip. Supports independent offsets, gain, fades and dialogue ducking.",
378
+ {
379
+ "item_id": ID,
380
+ "layer_id": ID,
381
+ "asset_id": ID,
42
382
  **SPAN,
43
- 'item_ids':{'type':'array','items':ID,'minItems':1,'maxItems':30,'uniqueItems':True},
44
- 'dialogue_ids':{'type':'array','items':ID,'maxItems':30,'uniqueItems':True},'source_evidence':TEXT,'audience_takeaway':TEXT},
45
- 'required':['beat_id','role','item_ids','dialogue_ids','source_evidence','audience_takeaway'],'additionalProperties':False}}}),
46
- schema('set_canvas','Choose a bounded SDR preview canvas before styling. Changes the revision and invalidates previous render review; source media and timing remain intact.',
47
- {'width':{'enum':[640,1280,1920]},'height':{'enum':[360,720,1080]},**SUMMARY}),
48
- schema('set_target_duration','Update the production duration only when the latest user revision request changes the desired length (including matching selected music). Cite an exact request_excerpt and derive seconds from the request or measured music. Never lower the target just to pass delivery checks. Saves an audit event without changing shots, graphics, audio or render review.',
49
- {'target_duration_seconds':{'type':'integer','minimum':30,'maximum':1200},'request_excerpt':TEXT,**SUMMARY}),
50
- schema('sample_source','Choose exact sample offsets inside a candidate. Returns actual frames with source timestamps; does not infer unseen motion.',
51
- {'candidate_id':ID,'offsets_seconds':{'type':'array','items':{'type':'number','minimum':0},'minItems':1,'maxItems':8}}),
52
- schema('inspect_candidates','Audition up to three candidate source ranges before choosing shots. Returns start/middle/end images, transcripts and evidence limitations in one call. Prefer this to repeatedly requesting single cached stills; refine with sample_source when action is missed.',
53
- {'candidate_ids':{'type':'array','items':ID,'minItems':1,'maxItems':3,'uniqueItems':True}}),
54
- schema('inspect_cut','Inspect start/middle/end of up to three current shots in one call, with exact source ranges, speech repair spans and overlapping text. Omit render_id to inspect sources before decorating; provide render_id for rendered review. All shots and text must be covered before finish.',
55
- {'item_ids':{'type':'array','items':ID,'minItems':1,'maxItems':3,'uniqueItems':True},'render_id':ID},['item_ids']),
56
- schema('inspect_pacing','Inspect actual source continuity across the current timeline. Adjacent pieces of the same take are grouped even when split; use this to find prolonged stretches to review. This does not decide whether a scene is interesting.'),
57
- schema('review_cut','Save an editorial assessment of the exact current revision after inspecting every changed rendered shot (unchanged shots accepted earlier in this run are carried and may be omitted). Keep specific unresolved problems as revise/matches=false; these block finish. This is a model assessment, not human approval.',
58
- {'shots':{'type':'array','maxItems':180,'items':{'type':'object','properties':{'item_id':ID,'observation':TEXT,'decision':{'enum':['keep','revise']}},'required':['item_id','observation','decision'],'additionalProperties':False}},
59
- 'text_checks':{'type':'array','maxItems':960,'items':{'type':'object','properties':{'item_id':ID,'evidence':TEXT,'matches':{'type':'boolean'}},'required':['item_id','evidence','matches'],'additionalProperties':False}},
60
- 'story_assessment':TEXT,'audio_limitations':TEXT}),
61
- schema('replace_clip_source','Replace one shot with an exact inventoried source span, including expansion to a complete utterance returned by list_transcripts. Reflows the timeline and invalidates overlays. Does not restrict selection to earlier candidate windows.',
62
- {'item_id':ID,'source':{'type':'object','properties':{'version_id':ID,'stream_index':{'type':'integer','minimum':0},'start_pts':{'type':'string','pattern':'^-?[0-9]+$'},'end_pts':{'type':'string','pattern':'^-?[0-9]+$'},'time_base':{'type':'object','properties':{'num':{'type':'integer','minimum':1},'den':{'type':'integer','minimum':1}},'required':['num','den'],'additionalProperties':False}},'required':['version_id','stream_index','start_pts','end_pts','time_base'],'additionalProperties':False},**SUMMARY}),
63
- schema('list_transcripts','Read complete source utterances remapped to the current cut, or a candidate before cutting. include_drafts explicitly exposes low-confidence ASR as unverified draft cues, not human-approved speech.',{'candidate_id':ID,'include_drafts':{'type':'boolean'}},[]),
64
- schema('replace_subtitles','Replace the editable subtitle track using returned cue IDs and faithful text; [] removes subtitles. source_excerpt selects an exact character range [start,end) in the source cue, with estimated timing, to omit uncertain ASR without inventing replacement speech. Omit unreliable cues entirely when needed; original audio is preserved.',
65
- {'captions':{'type':'array','items':{'type':'object','properties':{'cue_id':ID,'text':TEXT,'source_excerpt':{'type':'object','properties':{'start':{'type':'integer','minimum':0,'maximum':500},'end':{'type':'integer','minimum':1,'maximum':500}},'required':['start','end'],'additionalProperties':False},'delivery':{'enum':['dialogue','punchline','quiet']},'emphasis':{'type':'array','items':{'type':'string','minLength':1,'maxLength':16},'maxItems':4,'uniqueItems':True}},'required':['cue_id','text'],'additionalProperties':False},'maxItems':960},'allow_asr_draft':{'type':'boolean'},**SUMMARY},['captions','summary']),
66
- schema('remove_item','Delete a selected timeline element; video deletion closes the gap and invalidates time-bound overlays.',{'item_id':ID,**SUMMARY}),
67
- schema('trim_clip','Trim within the current source span, close the gap, and invalidate overlays/audio placements whose timing changed.',
68
- {'item_id':ID,'start_offset_frames':FRAME,'duration_frames':LENGTH,**SUMMARY}),
69
- schema('reorder_clips','Reorder all video item IDs exactly once. Clears overlays and audio placements; inspect and reapply them against the new cut.',
70
- {'item_ids':{'type':'array','items':ID,'minItems':1,'maxItems':180},**SUMMARY}),
71
- schema('split_clip','Split a video clip at a relative frame. Existing effects/placements on that clip are cleared for explicit reapplication.',
72
- {'item_id':ID,'offset_frames':LENGTH,**SUMMARY}),
73
- schema('insert_clip','Insert a precisely trimmed candidate before a video item, or at end when before_item_id is null. Invalidates overlays.',
74
- {'candidate_id':ID,'start_offset_seconds':{'type':'number','minimum':0},'duration_seconds':{'type':'number','minimum':0.75,'maximum':30},'before_item_id':{'anyOf':[ID,{'type':'null'}]},**SUMMARY}),
75
- schema('set_source_audio','Choose camera sound treatment and gain for one video clip.',
76
- {'item_id':ID,'mode':{'enum':['keep','mute','dialogue']},'gain_db':GAIN,**SUMMARY}),
77
- schema('set_color_grade','Set explicit per-clip exposure/contrast/saturation; neutral values remove the visual grade.',
78
- {'item_id':ID,'contrast':{'type':'number','minimum':0.5,'maximum':2},'saturation':{'type':'number','minimum':0,'maximum':2},'brightness':{'type':'number','minimum':-0.3,'maximum':0.3},**SUMMARY}),
79
- schema('set_mosaic','Set static timed rectangular mosaic regions in final canvas coordinates. Multiple intervals permit manual tracking; no automatic tracking claim. [] clears.',
80
- {'item_id':ID,'regions':{'type':'array','items':{'type':'object','properties':RECT,'required':list(RECT),'additionalProperties':False},'maxItems':32},**SUMMARY}),
81
- schema('set_transition','Set a dip to black/white at the incoming clip boundary, or none. Duration is in timeline frames.',
82
- {'item_id':ID,'kind':{'enum':['dip_black','dip_white','none']},'duration_frames':{'type':'integer','minimum':2,'maximum':60},**SUMMARY}),
83
- schema('set_fade','Fade the beginning/end of THIS shot to black. Use fade_out_frames on the final shot for an actual ending. This is independent of incoming scene transitions. Zero removes that fade.',
84
- {'item_id':ID,'fade_in_frames':FRAME,'fade_out_frames':FRAME,**SUMMARY}),
85
- schema('remove_clip_effect','Remove any named semantic effect from a video/audio clip.',{'item_id':ID,'effect_id':ID,**SUMMARY}),
86
- schema('search_music','Search and acquire up to three public instrumental candidates. Only generic music tags leave the project; preserve source/license evidence.',
87
- {'tags':{'type':'array','items':{'enum':MUSIC_TAGS},'minItems':1,'maxItems':4}}),
88
- schema('list_audio_assets','List acquired audio candidates and provenance without filesystem paths.'),
89
- schema('extract_audio','Prepare a local source range as an audio asset for ambience, dialogue or sound effects. No ownership/license claim is invented.',
90
- {'candidate_id':ID,'start_offset_seconds':{'type':'number','minimum':0},'duration_seconds':{'type':'number','exclusiveMinimum':0,'maximum':90}}),
91
- schema('inspect_audio','Read measured loudness, peaks, onsets, BPM and source/license metadata. This is analysis, not listening.',{'asset_id':ID}),
92
- schema('place_audio','Add/update a named audio layer anchored to a video clip. Supports independent offsets, gain, fades and dialogue ducking.',
93
- {'item_id':ID,'layer_id':ID,'asset_id':ID,**SPAN,'source_offset_seconds':{'type':'number','minimum':0,'maximum':3600},'gain_db':GAIN,'duck':{'type':'boolean'},'fade_seconds':{'type':'number','minimum':0,'maximum':5},**SUMMARY}),
94
- schema('remove_audio','Remove one named audio layer from the current timeline.',{'layer_id':ID,**SUMMARY}),
95
- schema('render_preview','Render the current immutable revision locally for review. Asynchronous: inspect_preview reads the actual result. Reuses a successful exact-revision render.'),
96
- schema('inspect_preview','Wait at most 30 seconds for a run-owned preview and inspect exact output timestamps. Does not claim audio listening or full-motion review.',
97
- {'render_id':ID,'offsets_seconds':{'type':'array','items':{'type':'number','minimum':0},'maxItems':8},'wait_seconds':{'type':'number','minimum':0,'maximum':30}},['render_id','offsets_seconds']),
98
- schema('cancel_preview','Cancel a preview started in this run; preserves the timeline.',{'render_id':ID}),
99
- schema('validate_sequence','Check executable timing, effects, audio references and render freshness. Returns actionable issues; never aesthetic approval.'),
100
- schema('get_edit_history','Read this run\'s versions (one per complete edit) and its most recent tool events, newest first. Page back with before_sequence.',
101
- {'before_sequence':{'type':'integer','minimum':1},'limit':{'type':'integer','minimum':1,'maximum':80}},required=[]),
102
- schema('restore_revision','Restore a run-owned immutable revision as a new current selection.',{'revision_id':ID,**SUMMARY}),
103
- schema('export_edit','Save native editable timeline JSON and source/license credits for the current revision. This is not a Resolve project.'),
383
+ "source_offset_seconds": {"type": "number", "minimum": 0, "maximum": 3600},
384
+ "gain_db": GAIN,
385
+ "duck": {"type": "boolean"},
386
+ "fade_seconds": {"type": "number", "minimum": 0, "maximum": 5},
387
+ **SUMMARY,
388
+ },
389
+ ),
390
+ schema("remove_audio", "Remove one named audio layer from the current timeline.", {"layer_id": ID, **SUMMARY}),
391
+ schema(
392
+ "render_preview",
393
+ "Render the current immutable revision locally for review. Asynchronous: inspect_preview reads the actual result. Reuses a successful exact-revision render.",
394
+ ),
395
+ schema(
396
+ "inspect_preview",
397
+ "Wait at most 30 seconds for a run-owned preview and inspect exact output timestamps. Does not claim audio listening or full-motion review.",
398
+ {
399
+ "render_id": ID,
400
+ "offsets_seconds": {"type": "array", "items": {"type": "number", "minimum": 0}, "maxItems": 8},
401
+ "wait_seconds": {"type": "number", "minimum": 0, "maximum": 30},
402
+ },
403
+ ["render_id", "offsets_seconds"],
404
+ ),
405
+ schema("cancel_preview", "Cancel a preview started in this run; preserves the timeline.", {"render_id": ID}),
406
+ schema(
407
+ "validate_sequence",
408
+ "Check executable timing, effects, audio references and render freshness. Returns actionable issues; never aesthetic approval.",
409
+ ),
410
+ schema(
411
+ "get_edit_history",
412
+ "Read this run's versions (one per complete edit) and its most recent tool events, newest first. Page back with before_sequence.",
413
+ {
414
+ "before_sequence": {"type": "integer", "minimum": 1},
415
+ "limit": {"type": "integer", "minimum": 1, "maximum": 80},
416
+ },
417
+ required=[],
418
+ ),
419
+ schema(
420
+ "restore_revision",
421
+ "Restore a run-owned immutable revision as a new current selection.",
422
+ {"revision_id": ID, **SUMMARY},
423
+ ),
424
+ schema(
425
+ "export_edit",
426
+ "Save native editable timeline JSON and source/license credits for the current revision. This is not a Resolve project.",
427
+ ),
104
428
  )
105
429
  CUSTOM_COMPONENT_HELP = (
106
430
  "Design an in-picture graphic freely as one self-contained web page: any HTML, CSS, SVG, Canvas or JavaScript, any layout, "
@@ -115,17 +439,31 @@ CUSTOM_COMPONENT_HELP = (
115
439
  "Text may only use the look's typefaces (anything else is refused); colours, layout, shapes and motion stay free. To use another typeface, "
116
440
  "change the look or make a new one; every graphic using a look follows its changes. Only technical checks apply otherwise: the page must load, run without "
117
441
  "errors, draw each frame within 10 seconds, draw something, and stay under 200 KB. The result returns two images: a still of the graphic at rest over the footage, and a sheet of frames from entry to exit (labelled by frame number), so you can judge the motion; look at both and fix what does not read. "
118
- "Mark what people may change themselves: put each main wording as plain text in an element with data-clipen-text=\"key\" "
119
- "(optional data-clipen-label=\"主標\"), and declare main colours as :root custom properties named --clipen-<name> (e.g. --clipen-主色) used via var(). "
442
+ 'Mark what people may change themselves: put each main wording as plain text in an element with data-clipen-text="key" '
443
+ '(optional data-clipen-label="主標"), and declare main colours as :root custom properties named --clipen-<name> (e.g. --clipen-主色) used via var(). '
120
444
  "Their changes are applied before your scripts run; split text into letters on DOMContentLoaded or later, from the element's current text."
121
445
  )
122
446
  CUSTOM_COMPONENT_FIELDS = {
123
- "element_id": ID, "item_id": {**ID, "description": "The shot the graphic starts in; it follows that footage on a recut and may run on past the cut."},
124
- "start_offset_frames": FRAME, "duration_frames": LENGTH,
125
- "name": {"type": "string", "minLength": 1, "maxLength": 40, "description": "Short label people see on the timeline, e.g. 澀谷地標標題."},
447
+ "element_id": ID,
448
+ "item_id": {
449
+ **ID,
450
+ "description": "The shot the graphic starts in; it follows that footage on a recut and may run on past the cut.",
451
+ },
452
+ "start_offset_frames": FRAME,
453
+ "duration_frames": LENGTH,
454
+ "name": {
455
+ "type": "string",
456
+ "minLength": 1,
457
+ "maxLength": 40,
458
+ "description": "Short label people see on the timeline, e.g. 澀谷地標標題.",
459
+ },
126
460
  "html": {"type": "string", "minLength": 1, "maxLength": 200000},
127
- "look_id": {**ID, "description": "The look (typefaces and colours) this graphic uses, from set_component_look. Required when adding."},
128
- "evidence": TEXT, **SUMMARY,
461
+ "look_id": {
462
+ **ID,
463
+ "description": "The look (typefaces and colours) this graphic uses, from set_component_look. Required when adding.",
464
+ },
465
+ "evidence": TEXT,
466
+ **SUMMARY,
129
467
  }
130
468
  LOOK_KEY = {"type": "string", "minLength": 1, "maxLength": 24}
131
469
  LOOK_HELP = (
@@ -140,53 +478,152 @@ LOOK_HELP = (
140
478
  "Japanese text. At most 8 looks, 3 typefaces and 6 colours each."
141
479
  )
142
480
  SKILL_TOOLS = (
143
- schema("list_production_skills", "List bundled production skills; selecting one never analyzes or uploads footage."),
144
- schema("read_production_skill", "Read one resource from the skill version frozen for this session. Start with SKILL.md, then load relevant references.",
145
- {"resource": {"type": "string", "maxLength": 120}}, []),
146
- schema("list_program_components", "Read executable components, visual presets, exact tool parameters and limitations for the selected skill."),
147
- schema("remove_program_component", "Remove one programme graphic without changing the cut, captions or music.", {"element_id": ID, **SUMMARY}),
148
- schema("set_component_look", LOOK_HELP, {
149
- "look_id": ID, "name": {"type": "string", "minLength": 1, "maxLength": 24, "description": "What people see, e.g. 章節, 地點, 反應字."},
150
- "fonts": {"type": "array", "minItems": 1, "maxItems": 3, "items": {"type": "object", "properties": {
151
- "key": LOOK_KEY, "label": LOOK_KEY, "family": {"type": "string", "maxLength": 40}}, "required": ["key", "family"], "additionalProperties": False}},
152
- "colors": {"type": "array", "maxItems": 6, "items": {"type": "object", "properties": {
153
- "key": LOOK_KEY, "label": LOOK_KEY, "value": {"type": "string", "pattern": "^#[0-9a-fA-F]{6}$"}}, "required": ["key", "value"], "additionalProperties": False}},
154
- **SUMMARY}, ["look_id", "name", "fonts", "summary"]),
155
- schema("add_custom_component", CUSTOM_COMPONENT_HELP, CUSTOM_COMPONENT_FIELDS, ["element_id", "item_id", "start_offset_frames", "duration_frames", "name", "html", "look_id", "summary"]),
156
- schema("update_custom_component", "Replace any part of a graphic made with add_custom_component (its page, name, shot, timing or look); anything left out stays as it is. An older graphic without a look needs look_id. Preserves its identity and supports exact revision undo.",
157
- CUSTOM_COMPONENT_FIELDS, ["element_id", "summary"]),
481
+ schema(
482
+ "list_production_skills", "List bundled production skills; selecting one never analyzes or uploads footage."
483
+ ),
484
+ schema(
485
+ "read_production_skill",
486
+ "Read one resource from the skill version frozen for this session. Start with SKILL.md, then load relevant references.",
487
+ {"resource": {"type": "string", "maxLength": 120}},
488
+ [],
489
+ ),
490
+ schema(
491
+ "list_program_components",
492
+ "Read executable components, visual presets, exact tool parameters and limitations for the selected skill.",
493
+ ),
494
+ schema(
495
+ "remove_program_component",
496
+ "Remove one programme graphic without changing the cut, captions or music.",
497
+ {"element_id": ID, **SUMMARY},
498
+ ),
499
+ schema(
500
+ "set_component_look",
501
+ LOOK_HELP,
502
+ {
503
+ "look_id": ID,
504
+ "name": {
505
+ "type": "string",
506
+ "minLength": 1,
507
+ "maxLength": 24,
508
+ "description": "What people see, e.g. 章節, 地點, 反應字.",
509
+ },
510
+ "fonts": {
511
+ "type": "array",
512
+ "minItems": 1,
513
+ "maxItems": 3,
514
+ "items": {
515
+ "type": "object",
516
+ "properties": {"key": LOOK_KEY, "label": LOOK_KEY, "family": {"type": "string", "maxLength": 40}},
517
+ "required": ["key", "family"],
518
+ "additionalProperties": False,
519
+ },
520
+ },
521
+ "colors": {
522
+ "type": "array",
523
+ "maxItems": 6,
524
+ "items": {
525
+ "type": "object",
526
+ "properties": {
527
+ "key": LOOK_KEY,
528
+ "label": LOOK_KEY,
529
+ "value": {"type": "string", "pattern": "^#[0-9a-fA-F]{6}$"},
530
+ },
531
+ "required": ["key", "value"],
532
+ "additionalProperties": False,
533
+ },
534
+ },
535
+ **SUMMARY,
536
+ },
537
+ ["look_id", "name", "fonts", "summary"],
538
+ ),
539
+ schema(
540
+ "add_custom_component",
541
+ CUSTOM_COMPONENT_HELP,
542
+ CUSTOM_COMPONENT_FIELDS,
543
+ ["element_id", "item_id", "start_offset_frames", "duration_frames", "name", "html", "look_id", "summary"],
544
+ ),
545
+ schema(
546
+ "update_custom_component",
547
+ "Replace any part of a graphic made with add_custom_component (its page, name, shot, timing or look); anything left out stays as it is. An older graphic without a look needs look_id. Preserves its identity and supports exact revision undo.",
548
+ CUSTOM_COMPONENT_FIELDS,
549
+ ["element_id", "summary"],
550
+ ),
158
551
  )
159
552
 
160
553
  EXTRA_TOOLS += SKILL_TOOLS
161
554
  EXTRA_TOOLS += (
162
- schema('transcribe_source_range','Transcribe one registered source range locally, on demand. No old analysis/plan needed. Async job with explicit coverage; does not invent word timing.',
163
- {'candidate_id':ID,'language':{'enum':['zh','en','ja']},'align_words':{'type':'boolean'}},['candidate_id']),
164
- schema('align_source_speech','Align the exact ASR text from a successful transcription job to its source audio using an installed offline aligner. Does not verify wording or upload audio.',
165
- {'transcript_job_id':ID}),
166
- schema('read_evidence_job','Read a run-owned local evidence job. Wait up to 15 seconds; polling never repeats inference.',
167
- {'job_id':ID,'wait_seconds':{'type':'number','minimum':0,'maximum':15}},['job_id']),
168
- schema('cancel_evidence_job','Cancel local source transcription/alignment; preserves completed evidence and edit revisions.',{'job_id':ID}),
169
- schema('inspect_mix','Read measurements and dialogue-driven duck envelopes from an actual run-owned render. Reports camera/music/final stems separately; numeric evidence is not audio listening.',{'render_id':ID}),
170
- schema('prepare_local_speech','Prepare the fixed local transcription or word-alignment runtime when unavailable. Requires the session model-download grant. Async and cancellable; never uploads source audio.',{'target':{'enum':['transcription','alignment']}}),
171
- schema('retry_evidence_job','Explicitly retry a failed/cancelled/interrupted LOCAL evidence job as a new attempt. The old outcome is preserved; reuse request_id to avoid starting the same retry twice.',{'job_id':ID,'request_id':ID}),
172
- schema('revise_source_speech','Propose a grounded correction to one source utterance and re-align it locally. Preserves original ASR, reason and model-authored authority; never claims human verification.',
173
- {'transcript_job_id':ID,'segment_ordinal':{'type':'integer','minimum':0,'maximum':99},'text':TEXT,'evidence':TEXT}),
174
- schema('read_mutation_receipt','Read one run-owned mutation outcome after a lost response. A started receipt means outcome unknown: inspect the current revision before choosing another action.',{'mutation_id':ID}),
555
+ schema(
556
+ "transcribe_source_range",
557
+ "Transcribe one registered source range locally, on demand. No old analysis/plan needed. Async job with explicit coverage; does not invent word timing.",
558
+ {"candidate_id": ID, "language": {"enum": ["zh", "en", "ja"]}, "align_words": {"type": "boolean"}},
559
+ ["candidate_id"],
560
+ ),
561
+ schema(
562
+ "align_source_speech",
563
+ "Align the exact ASR text from a successful transcription job to its source audio using an installed offline aligner. Does not verify wording or upload audio.",
564
+ {"transcript_job_id": ID},
565
+ ),
566
+ schema(
567
+ "read_evidence_job",
568
+ "Read a run-owned local evidence job. Wait up to 15 seconds; polling never repeats inference.",
569
+ {"job_id": ID, "wait_seconds": {"type": "number", "minimum": 0, "maximum": 15}},
570
+ ["job_id"],
571
+ ),
572
+ schema(
573
+ "cancel_evidence_job",
574
+ "Cancel local source transcription/alignment; preserves completed evidence and edit revisions.",
575
+ {"job_id": ID},
576
+ ),
577
+ schema(
578
+ "inspect_mix",
579
+ "Read measurements and dialogue-driven duck envelopes from an actual run-owned render. Reports camera/music/final stems separately; numeric evidence is not audio listening.",
580
+ {"render_id": ID},
581
+ ),
582
+ schema(
583
+ "prepare_local_speech",
584
+ "Prepare the fixed local transcription or word-alignment runtime when unavailable. Requires the session model-download grant. Async and cancellable; never uploads source audio.",
585
+ {"target": {"enum": ["transcription", "alignment"]}},
586
+ ),
587
+ schema(
588
+ "retry_evidence_job",
589
+ "Explicitly retry a failed/cancelled/interrupted LOCAL evidence job as a new attempt. The old outcome is preserved; reuse request_id to avoid starting the same retry twice.",
590
+ {"job_id": ID, "request_id": ID},
591
+ ),
592
+ schema(
593
+ "revise_source_speech",
594
+ "Propose a grounded correction to one source utterance and re-align it locally. Preserves original ASR, reason and model-authored authority; never claims human verification.",
595
+ {
596
+ "transcript_job_id": ID,
597
+ "segment_ordinal": {"type": "integer", "minimum": 0, "maximum": 99},
598
+ "text": TEXT,
599
+ "evidence": TEXT,
600
+ },
601
+ ),
602
+ schema(
603
+ "read_mutation_receipt",
604
+ "Read one run-owned mutation outcome after a lost response. A started receipt means outcome unknown: inspect the current revision before choosing another action.",
605
+ {"mutation_id": ID},
606
+ ),
175
607
  )
176
- EXTRA_NAMES=tuple(t['name'] for t in EXTRA_TOOLS)
608
+ EXTRA_NAMES = tuple(t["name"] for t in EXTRA_TOOLS)
177
609
  # Older films keep graphics made with the retired built-in templates; Clipen still draws them, and the
178
610
  # AI may remove one, but it designs every new graphic itself (add_custom_component).
179
- AGENT_TOOLS=EXTRA_TOOLS
180
- AGENT_NAMES=EXTRA_NAMES
181
- BY_NAME={t['name']:t for t in EXTRA_TOOLS}
611
+ AGENT_TOOLS = EXTRA_TOOLS
612
+ AGENT_NAMES = EXTRA_NAMES
613
+ BY_NAME = {t["name"]: t for t in EXTRA_TOOLS}
182
614
 
183
615
 
184
616
  def validate_arguments(name, arguments):
185
- errors=list(Draft202012Validator(BY_NAME[name]['inputSchema']).iter_errors(arguments))
617
+ errors = list(Draft202012Validator(BY_NAME[name]["inputSchema"]).iter_errors(arguments))
186
618
  if errors:
187
619
  # Report the failing field and constraint, never echo source text/IDs or
188
620
  # a potentially huge value. Models otherwise repeat the same invalid call.
189
- error=errors[0];field='.'.join(str(p) for p in error.absolute_path) or 'arguments'
190
- constraint=error.validator
191
- expected=json.dumps(error.validator_value,ensure_ascii=False)[:240]
192
- raise ProjectError('agent_input_invalid',f'{name}: {field} 不符合 {constraint}={expected};請依工具 schema 修正。',status_code=422)
621
+ error = errors[0]
622
+ field = ".".join(str(p) for p in error.absolute_path) or "arguments"
623
+ constraint = error.validator
624
+ expected = json.dumps(error.validator_value, ensure_ascii=False)[:240]
625
+ raise ProjectError(
626
+ "agent_input_invalid",
627
+ f"{name}: {field} 不符合 {constraint}={expected};請依工具 schema 修正。",
628
+ status_code=422,
629
+ )