@mengine/medeo-tool 1.2.1-alpha.0 → 1.2.1-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,742 +1,502 @@
1
- //#region src/sandbox/generated/edit-sandbox-api.d.ts
2
- /**
3
- * @generated by gen:sandbox-dts — DO NOT EDIT MANUALLY
4
- *
5
- * Schema version: video-document/v0
6
- * Semantic ops: 20
7
- *
8
- * Boundary: zod `superRefine` / custom refine rules are NOT introspectable and
9
- * do not appear here. Business mutual-exclusion rules surface via runtime
10
- * validation errors (L3 feedback channel).
11
- *
12
- * @example 读取→计算→批量写
13
- * ```ts
14
- * const clips = timeline.clipsInRange(0, 10_000);
15
- * await edit.setVideoClipSpeedShift({
16
- * clips: clips.map((c) => ({ clip_id: c.id, speed_shift: { category: 'linear', mode: 'constant', config: { linear: { speed: 1.5 } } } })),
17
- * });
18
- * ```
19
- *
20
- * @example anchored 删除
21
- * ```ts
22
- * await edit.deleteVideoClips({ clip_ids: ['clip_a'], on_anchored: 'detach' });
23
- * ```
24
- */
25
- /**
26
- * A clip's playback-speed fact, the only thing `SetVideoClipSpeedShift` writes.
27
- */
28
- interface SpeedShift {
29
- category: 'linear' | 'curve';
30
- mode: string;
31
- config: {
32
- linear: {
33
- /**
34
- * @constraint positive
35
- */
36
- speed: number;
1
+ //#region src/sandbox/generated/entity-edit-sandbox-api.d.ts
2
+ /** @generated by gen:sandbox-dts. Entity-native editor contract; DO NOT EDIT. */
3
+ interface AudioMediaAssetFact {
4
+ readonly assetId: string;
5
+ readonly kind: 'audio';
6
+ readonly durationMs: number;
7
+ readonly storageKey: string;
8
+ }
9
+ interface BoundedDerivedSequencePayload extends JsonObject {
10
+ extent: {
11
+ kind: 'bounded';
12
+ start: number;
13
+ end: number;
14
+ };
15
+ sampling: 'derived';
16
+ coordinateSpace: JsonValue;
17
+ }
18
+ interface BoundedNativeSequencePayload extends JsonObject {
19
+ /** Factual coordinates from recalled media metadata; never invent an end/duration. */
20
+ extent: {
21
+ kind: 'bounded';
22
+ start: number;
23
+ end: number;
24
+ };
25
+ sampling: 'native';
26
+ coordinateSpace: JsonValue;
27
+ }
28
+ interface CaptionFontDescriptor {
29
+ readonly system: 'font-library';
30
+ readonly key: string;
31
+ }
32
+ interface CaptionStyleFields {
33
+ readonly font?: CaptionFontDescriptor;
34
+ readonly fontSize?: number;
35
+ readonly fontColor?: string;
36
+ readonly fontWeight?: number;
37
+ readonly entranceAnimation?: string;
38
+ readonly entranceAnimationDurationMs?: number;
39
+ readonly strokeColor?: string;
40
+ readonly strokeWidth?: number;
41
+ readonly positionX?: number;
42
+ readonly positionY?: number;
43
+ }
44
+ type ClipEntityId = EntityId;
45
+ type ClipPlacement = {
46
+ readonly kind: 'sequential';
47
+ readonly order: number;
48
+ } | {
49
+ readonly kind: 'absolute';
50
+ readonly targetRange: SequenceRange<number>;
51
+ } | {
52
+ readonly kind: 'anchored';
53
+ readonly hostClipEntityId: string;
54
+ readonly anchorOffset: number;
55
+ };
56
+ type CreateEntityInput = { [K in KnownEntityKind]: {
57
+ entity_id?: string;
58
+ entity_kind: K;
59
+ payload: EntityPayloadByKind[K];
60
+ } }[KnownEntityKind];
61
+ interface DeleteBgmInput {
62
+ readonly timelineEntityId: string;
63
+ }
64
+ interface DeleteClipInput {
65
+ readonly clipEntityId: string;
66
+ }
67
+ interface DeleteClipTreeInput {
68
+ readonly clipEntityIds: readonly string[];
69
+ readonly onAnchored: 'cascade' | 'detach';
70
+ }
71
+ interface DeleteEntityInput {
72
+ entity_id: string;
73
+ }
74
+ interface DeleteVoiceoverInput {
75
+ readonly voiceoverClipEntityIds: readonly string[];
76
+ }
77
+ type EmptyRelationKind = 'timeline-track' | 'track-clip' | 'clip-marker' | 'marker-content' | 'axvideo-marker' | 'marker-timeline';
78
+ interface EntityFacade {
79
+ list(): SandboxEntity[];
80
+ get(entityId: string): SandboxEntity | null;
81
+ /** Find document resources by external Memota asset id, including directly composed media variants. */
82
+ findByAssetId(assetId: string): SandboxEntity<ResourceEntityKind>[];
83
+ create(input: CreateEntityInput): string;
84
+ /** Replace one Entity's owned payload without changing its identity or kind. */
85
+ update(input: UpdateEntityInput): void;
86
+ /** Delete an Entity only after all of its incident Relations have been explicitly unlinked. */
87
+ delete(input: DeleteEntityInput): void;
88
+ /** Get or create one typed Asset by factual external id and return its single content identity. Never creates a Clip. */
89
+ ensureMedia(fact: MediaAssetFact): {
90
+ contentEntityId: string;
91
+ };
92
+ }
93
+ type EntityId = string;
94
+ interface EntityPayloadByKind {
95
+ axvideo: BoundedDerivedSequencePayload;
96
+ timeline: JsonObject;
97
+ track: JsonObject & {
98
+ hidden?: boolean;
99
+ role?: string;
100
+ };
101
+ clip: JsonObject;
102
+ /** Inline caption text; external media uses a typed Asset variant. */
103
+ asset: JsonObject;
104
+ video: BoundedNativeSequencePayload & MediaAssetPayload;
105
+ audio: BoundedNativeSequencePayload & MediaAssetPayload;
106
+ voice: BoundedNativeSequencePayload & MediaAssetPayload;
107
+ image: UnboundedConstantSequencePayload & MediaAssetPayload;
108
+ 'sequence-marker': JsonObject & {
109
+ sourceRange: {
110
+ start: number;
111
+ end: number;
112
+ };
113
+ targetRange?: {
114
+ start: number;
115
+ end: number;
37
116
  };
38
- } | {
39
- curve: {
40
- /**
41
- * @constraint minLength(2)
42
- */
43
- keyframes: {
44
- /**
45
- * @constraint min(0)
46
- * @constraint max(1)
47
- */
48
- position: number;
49
- /**
50
- * @constraint min(0)
51
- */
52
- rate: number;
53
- /**
54
- * Bezier tangent handle (x, y)
55
- */
56
- in_tangent?: {
57
- x: number;
58
- y: number;
59
- };
60
- /**
61
- * Bezier tangent handle (x, y)
62
- */
63
- out_tangent?: {
64
- x: number;
65
- y: number;
66
- };
67
- }[];
117
+ duration: {
118
+ mode: 'from-source';
119
+ } | {
120
+ mode: 'fixed';
121
+ value: number;
68
122
  };
123
+ timeRemapping?: JsonValue;
124
+ anchorOffset?: number;
125
+ durationPolicy?: 'timeline';
126
+ };
127
+ viewport: JsonObject;
128
+ 'audio-script': JsonObject & {
129
+ segments: ScriptTextSegment[];
69
130
  };
131
+ 'phonetic-script': JsonObject & {
132
+ segments: ScriptTextSegment[];
133
+ };
134
+ caption: BoundedNativeSequencePayload;
70
135
  }
71
- /**
72
- * TTS voice summary attached to a speech
73
- */
74
- interface Voice {
75
- /**
76
- * @constraint minLength(1)
77
- */
78
- id: string;
79
- name: string;
80
- }
81
- /**
82
- * A materialized speech-subtree write (speeches + their captions).
83
- */
84
- interface SpeechAssets {
85
- /**
86
- * Materialized speech parts to write
87
- * @constraint minLength(1)
88
- */
89
- speeches: {
90
- /**
91
- * The speech part ID (= side-effect speech_parts[].id)
92
- * @constraint minLength(1)
93
- */
94
- speech_id: string;
95
- /**
96
- * Host video clip part ID the speech anchors to (RFC 02 §4)
97
- * @constraint minLength(1)
98
- */
99
- anchor_part_id: string;
100
- /**
101
- * Offset within the host clip (speech.abs = host.abs + offset_ms)
102
- * @constraint int
103
- * @constraint min(0)
104
- */
105
- offset_ms: number;
106
- /**
107
- * @constraint minLength(1)
108
- */
109
- audio_storage_key: string;
110
- /**
111
- * Duration in milliseconds (> 0)
112
- * @constraint int
113
- * @constraint positive
114
- */
115
- duration_ms: number;
116
- audio_script: string;
117
- /**
118
- * Volume in decibels (-60.0 to 20.0; 0.0 = original, -60 = mute, +20 = max)
119
- * @constraint min(-60)
120
- * @constraint max(20)
121
- */
122
- volume: number;
123
- /**
124
- * TTS voice summary attached to a speech
125
- */
126
- voice: {
127
- /**
128
- * @constraint minLength(1)
129
- */
130
- id: string;
131
- name: string;
132
- };
133
- /**
134
- * @constraint minLength(1)
135
- */
136
- origin_speech_id: string;
137
- /**
138
- * Caption part IDs owned by this speech
139
- */
140
- caption_ids: string[];
141
- }[];
142
- /**
143
- * Materialized caption parts owned by the speeches
144
- */
145
- captions: {
146
- /**
147
- * The caption part ID (= side-effect created_caption_parts[].id)
148
- * @constraint minLength(1)
149
- */
150
- caption_id: string;
151
- /**
152
- * The owning speech part ID
153
- * @constraint minLength(1)
154
- */
155
- speech_part_id: string;
156
- text: string;
157
- /**
158
- * Offset within the host speech (caption.abs = speech.abs + start_ms)
159
- * @constraint int
160
- * @constraint min(0)
161
- */
162
- start_ms: number;
163
- /**
164
- * Duration in milliseconds (> 0)
165
- * @constraint int
166
- * @constraint positive
167
- */
168
- duration_ms: number;
169
- }[];
136
+ interface EntityStoreSnapshot {
137
+ revision: number;
138
+ entities: SandboxEntity[];
139
+ relations: SandboxRelation[];
170
140
  }
171
- interface MoveVideoClipsInput {
172
- /**
173
- * List of video clips to move to new positions
174
- * @constraint minLength(1)
175
- */
176
- clips: {
177
- /**
178
- * The video clip part ID to move
179
- * @constraint minLength(1)
180
- */
181
- clip_id: string;
182
- /**
183
- * New absolute start time in milliseconds on the timeline
184
- * @constraint int
185
- * @constraint min(0)
186
- */
187
- new_start_ms: number;
188
- /**
189
- * Target track ID to move the clip to (optional)
190
- * @constraint minLength(1)
191
- */
192
- new_track_id?: string;
193
- }[];
141
+ interface ImageMediaAssetFact {
142
+ readonly assetId: string;
143
+ readonly kind: 'image';
144
+ readonly storageKey?: string;
145
+ }
146
+ interface InsertClipInput {
147
+ readonly trackEntityId: string;
148
+ /** Existing Sequence media Entity id. Asset ids and URLs are not content ids. */
149
+ readonly contentEntityId: string;
150
+ readonly sourceRange: SequenceRange<number>;
151
+ readonly duration: SequenceDuration<number>;
152
+ readonly targetRange?: SequenceRange<number>;
153
+ readonly clipPayload?: JsonObject;
154
+ }
155
+ interface InsertMediaClipInput {
156
+ readonly timelineEntityId: string;
157
+ readonly clipEntityId?: string;
158
+ readonly media: VisualMediaAssetFact;
159
+ /** Source/display window in whole milliseconds. Images use this as their finite display span. */
160
+ readonly sourceRange: SequenceRange<number>;
161
+ readonly placement: ClipPlacement;
162
+ readonly volume?: number;
163
+ }
164
+ interface InsertMediaClipsInput {
165
+ readonly timelineEntityId: string;
166
+ readonly clips: readonly ReplacementMediaClipInput[];
167
+ /** One placement decision for the whole input-ordered block. */
168
+ readonly insertion: MediaClipInsertion;
169
+ }
170
+ interface InsertPlacedClipInput {
171
+ readonly trackEntityId: string;
172
+ readonly contentEntityId: string;
173
+ readonly sourceRange: SequenceRange<number>;
174
+ readonly duration: SequenceDuration<number>;
175
+ readonly placement: ClipPlacement;
176
+ readonly clipPayload?: JsonObject;
177
+ /** Stable caller-owned placement identity, when one already exists outside the graph. */
178
+ readonly clipEntityId?: string;
179
+ }
180
+ interface JsonObject {
181
+ [key: string]: JsonValue;
182
+ }
183
+ type JsonPrimitive = string | number | boolean | null;
184
+ type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
185
+ type KnownEntityKind = 'axvideo' | 'timeline' | 'track' | 'clip' | 'asset' | 'video' | 'audio' | 'voice' | 'image' | 'sequence-marker' | 'viewport' | 'audio-script' | 'phonetic-script' | 'caption';
186
+ type KnownRelationKind = 'timeline-track' | 'track-clip' | 'clip-marker' | 'marker-content' | 'axvideo-marker' | 'marker-timeline' | 'physical-asset' | 'generated' | 'phonetic-script-provenance' | 'caption-provenance' | 'caption-alignment' | 'clip-anchor' | 'audio-script-render';
187
+ interface LinearClipSpeed {
188
+ readonly kind: 'linear';
189
+ readonly rate: number;
190
+ readonly mode?: string;
191
+ }
192
+ interface LinkAudioScriptRenderRelationInput {
193
+ relation_id?: string;
194
+ output_entity_id: string;
195
+ script_entity_id: string;
196
+ trace?: JsonObject;
194
197
  }
195
- interface MoveVideoClipsByAnchorInput {
196
- /**
197
- * Clips to move as one block, keeping their relative order. Need not be contiguous on the track.
198
- * @constraint minLength(1)
199
- */
200
- clip_ids: string[];
201
- /**
202
- * Where the moved block lands: before/after a reference clip, or at the head of the track
203
- */
204
- anchor: {
205
- position: 'before';
206
- /**
207
- * The moved block lands immediately before this clip
208
- * @constraint minLength(1)
209
- */
210
- clip_id: string;
211
- } | {
212
- position: 'after';
213
- /**
214
- * The moved block lands immediately after this clip
215
- * @constraint minLength(1)
216
- */
217
- clip_id: string;
218
- } | {
219
- position: 'track_start';
198
+ interface LinkClipAnchorRelationInput {
199
+ relation_id?: string;
200
+ child_clip_entity_id: string;
201
+ host_clip_entity_id: string;
202
+ trace?: JsonObject;
203
+ }
204
+ interface LinkGeneratedRelationInput {
205
+ relation_id?: string;
206
+ output_entity_id: string;
207
+ input_entity_id: string;
208
+ trace?: JsonObject;
209
+ }
210
+ interface LinkRelationBase {
211
+ relation_id?: string;
212
+ endpoint_0_entity_id: string;
213
+ endpoint_1_entity_id: string;
214
+ trace?: JsonObject;
215
+ }
216
+ type LinkRelationInput = (LinkRelationBase & {
217
+ relation_kind: EmptyRelationKind;
218
+ metadata?: {
219
+ [key: string]: never;
220
220
  };
221
- /**
222
- * What happens to speeches anchored to the moved clips (required — see the policy doc)
223
- */
224
- on_anchored: 'follow' | 'keep_absolute';
225
- }
226
- interface DeleteVideoClipsInput {
227
- /**
228
- * List of video clip part IDs to delete from the main track
229
- * @constraint minLength(1)
230
- */
231
- clip_ids: string[];
232
- /**
233
- * How to treat anchored children (default cascade)
234
- */
235
- on_anchored?: 'cascade' | 'detach';
236
- }
237
- /**
238
- * Add video clips to a track.
239
- */
240
- interface AddVideoClipsInput {
241
- /**
242
- * List of video clips to create
243
- * @constraint minLength(1)
244
- */
245
- clips: {
246
- /**
247
- * The media asset ID for the video clip
248
- * @constraint minLength(1)
249
- */
250
- media_id: string;
251
- /**
252
- * Absolute start time in milliseconds on the timeline
253
- * @constraint int
254
- * @constraint min(0)
255
- */
256
- start_ms?: number;
257
- /**
258
- * The source media's intrinsic full length in ms
259
- * @constraint int
260
- * @constraint positive
261
- */
262
- media_duration_ms: number;
263
- /**
264
- * Trim window start in the media (default 0)
265
- * @constraint int
266
- * @constraint min(0)
267
- */
268
- play_in?: number;
269
- /**
270
- * Trim window end in the media (default media_duration_ms)
271
- * @constraint int
272
- * @constraint positive
273
- */
274
- play_out?: number;
275
- /**
276
- * Target track ID (optional, defaults to main track)
277
- * @constraint minLength(1)
278
- */
279
- track_id?: string;
280
- }[];
281
- /**
282
- * Insert new clips before this clip ID
283
- * @constraint minLength(1)
284
- */
285
- before_clip_id?: string;
286
- /**
287
- * Insert new clips after this clip ID
288
- * @constraint minLength(1)
289
- */
290
- after_clip_id?: string;
291
- }
292
- interface AdjustVideoClipVolumeInput {
293
- /**
294
- * List of video clips with their new volume settings
295
- * @constraint minLength(1)
296
- */
297
- clips: {
298
- /**
299
- * The video clip part ID to adjust volume for
300
- * @constraint minLength(1)
301
- */
302
- clip_id: string;
303
- /**
304
- * Volume in decibels (-60.0 to 20.0; 0.0 = original)
305
- * @constraint min(-60)
306
- * @constraint max(20)
307
- */
308
- volume: number;
309
- }[];
221
+ }) | (LinkRelationBase & {
222
+ relation_kind: 'physical-asset';
223
+ metadata?: JsonObject;
224
+ }) | (LinkRelationBase & {
225
+ relation_kind: 'phonetic-script-provenance' | 'caption-provenance';
226
+ metadata: JsonObject & {
227
+ segmentAlignment: JsonValue;
228
+ };
229
+ }) | (LinkRelationBase & {
230
+ relation_kind: 'caption-alignment';
231
+ metadata: JsonObject & {
232
+ alignment: JsonValue;
233
+ };
234
+ });
235
+ /** Facts resolved from media storage. A trim window never substitutes for intrinsic duration. */
236
+ type MediaAssetFact = ImageMediaAssetFact | VideoMediaAssetFact | AudioMediaAssetFact | VoiceMediaAssetFact;
237
+ type MediaAssetPayload = JsonObject & {
238
+ external: {
239
+ system: 'memota' | 'memota-speech';
240
+ key: string;
241
+ };
242
+ storageKey?: string;
243
+ };
244
+ type MediaClipInsertion = {
245
+ readonly kind: 'before';
246
+ readonly clipEntityId: string;
247
+ } | {
248
+ readonly kind: 'after';
249
+ readonly clipEntityId: string;
250
+ } | {
251
+ readonly kind: 'firstStart';
252
+ readonly startMs: number;
253
+ };
254
+ interface MoveClipInput {
255
+ readonly clipEntityId: string;
256
+ readonly trackEntityId: string;
310
257
  }
311
- /**
312
- * Set the playback speed of existing video clips.
313
- */
314
- interface SetVideoClipSpeedShiftInput {
315
- /**
316
- * Video clips with their new speed settings
317
- * @constraint minLength(1)
318
- */
319
- clips: {
320
- /**
321
- * The video clip part ID to set speed for
322
- * @constraint minLength(1)
323
- */
324
- clip_id: string;
325
- /**
326
- * The new speed setting, or null to reset to 1×
327
- */
328
- speed_shift: {
329
- category: 'linear' | 'curve';
330
- mode: string;
331
- config: {
332
- linear: {
333
- /**
334
- * @constraint positive
335
- */
336
- speed: number;
337
- };
338
- } | {
339
- curve: {
340
- /**
341
- * @constraint minLength(2)
342
- */
343
- keyframes: {
344
- /**
345
- * @constraint min(0)
346
- * @constraint max(1)
347
- */
348
- position: number;
349
- /**
350
- * @constraint min(0)
351
- */
352
- rate: number;
353
- /**
354
- * Bezier tangent handle (x, y)
355
- */
356
- in_tangent?: {
357
- x: number;
358
- y: number;
359
- };
360
- /**
361
- * Bezier tangent handle (x, y)
362
- */
363
- out_tangent?: {
364
- x: number;
365
- y: number;
366
- };
367
- }[];
368
- };
369
- };
370
- } | null;
258
+ interface MoveClipsToStartsInput {
259
+ readonly moves: readonly {
260
+ readonly clipEntityId: string;
261
+ readonly newStartMs: number;
371
262
  }[];
263
+ /** Absolute-time drags preserve every voiceover's current visible landing. */
264
+ readonly onAnchored: 'keepAbsolute';
372
265
  }
373
- /**
374
- * Replace the media backing existing video clips.
375
- */
376
- interface ReplaceVideoClipContentInput {
377
- /**
378
- * Video clips whose media is being replaced
379
- * @constraint minLength(1)
380
- */
381
- clips: {
382
- /**
383
- * Existing video clip part ID to re-point
384
- * @constraint minLength(1)
385
- */
386
- clip_id: string;
387
- /**
388
- * The new media asset ID
389
- * @constraint minLength(1)
390
- */
391
- origin_media_id: string;
392
- /**
393
- * The new media's intrinsic full length
394
- * @constraint int
395
- * @constraint positive
396
- */
397
- media_duration_ms: number;
398
- /**
399
- * Trim window start in the new media (usually 0)
400
- * @constraint int
401
- * @constraint min(0)
402
- */
403
- play_in: number;
404
- /**
405
- * Trim window end in the new media (usually = media_duration_ms)
406
- * @constraint int
407
- * @constraint positive
408
- */
409
- play_out: number;
410
- /**
411
- * Volume in decibels (-60.0 to 20.0; 0.0 = original, -60 = mute, +20 = max)
412
- * @constraint min(-60)
413
- * @constraint max(20)
414
- */
415
- volume: number;
416
- }[];
266
+ interface MoveSequentialClipsInput {
267
+ readonly clipEntityIds: readonly string[];
268
+ readonly anchor: SequentialClipAnchor;
269
+ readonly onAnchored: 'follow' | 'keepAbsolute';
417
270
  }
418
- interface ReplaceVideoClipSequenceInput {
419
- /**
420
- * The clips being replaced: a contiguous main-track run, listed in timeline order
421
- * @constraint minLength(1)
422
- */
423
- old_clip_ids: string[];
424
- /**
425
- * The replacement clips, in the order they take on the track
426
- * @constraint minLength(1)
427
- */
428
- new_clips: {
429
- /**
430
- * The replacement media asset ID. Omit to create an empty placeholder clip.
431
- * @constraint minLength(1)
432
- */
433
- media_id?: string;
434
- /**
435
- * The source media's intrinsic full length in ms
436
- * @constraint int
437
- * @constraint positive
438
- */
439
- media_duration_ms: number;
440
- /**
441
- * Trim window start in the media (default 0)
442
- * @constraint int
443
- * @constraint min(0)
444
- */
445
- play_in?: number;
446
- /**
447
- * Trim window end in the media (default media_duration_ms)
448
- * @constraint int
449
- * @constraint positive
450
- */
451
- play_out?: number;
452
- }[];
453
- /**
454
- * What happens to speeches anchored to the replaced clips (required — see the policy doc)
455
- */
456
- on_anchored: 'remap' | 'cascade';
457
- }
458
- /**
459
- * Re-trim existing video clips (the user-facing "adjust duration" gesture is a trim of the source window).
460
- */
461
- interface AdjustVideoClipDurationInput {
462
- /**
463
- * Video clips with their new trim windows
464
- * @constraint minLength(1)
465
- */
466
- clips: {
467
- /**
468
- * The video clip part ID to re-trim
469
- * @constraint minLength(1)
470
- */
471
- clip_id: string;
472
- /**
473
- * New trim window start in the source media
474
- * @constraint int
475
- * @constraint min(0)
476
- */
477
- play_in: number;
478
- /**
479
- * New trim window end in the source media
480
- * @constraint int
481
- * @constraint positive
482
- */
483
- play_out: number;
484
- }[];
271
+ interface MoveVoiceoverInput {
272
+ readonly voiceoverClipEntityId: string;
273
+ /** Absolute requested timeline start; MEngine resolves and persists the host relation. */
274
+ readonly newStartMs: number;
485
275
  }
486
- /**
487
- * Add speeches (and their captions).
488
- */
489
- interface AddSpeechesInput extends SpeechAssets {}
490
- /**
491
- * Delete speeches with their captions.
492
- */
493
- interface DeleteSpeechesInput {
494
- /**
495
- * Speech part IDs to delete (their captions cascade-delete)
496
- * @constraint minLength(1)
497
- */
498
- speech_ids: string[];
499
- }
500
- /**
501
- * Move speeches in time.
502
- */
503
- interface MoveSpeechesInput {
504
- /**
505
- * Speeches to move to new positions
506
- * @constraint minLength(1)
507
- */
508
- speeches: {
509
- /**
510
- * The speech part ID to move
511
- * @constraint minLength(1)
512
- */
513
- speech_id: string;
514
- /**
515
- * New absolute start time on the timeline
516
- * @constraint int
517
- * @constraint min(0)
518
- */
519
- new_start_ms: number;
520
- }[];
276
+ interface PatchCaptionStyleInput {
277
+ readonly timelineEntityId: string;
278
+ readonly style: CaptionStyleFields;
521
279
  }
522
- /**
523
- * Change a speech's script or voice.
524
- */
525
- interface ChangeSpeechScriptInput extends SpeechAssets {}
526
- interface ChangeSpeechVoiceInput extends SpeechAssets {}
527
- interface AdjustSpeechVolumeInput {
528
- /**
529
- * List of speeches with their new volume settings
530
- * @constraint minLength(1)
531
- */
532
- speeches: {
533
- /**
534
- * The speech part ID to adjust volume for
535
- * @constraint minLength(1)
536
- */
537
- speech_id: string;
538
- /**
539
- * Volume in decibels (-60.0 to 20.0; 0.0 = original)
540
- * @constraint min(-60)
541
- * @constraint max(20)
542
- */
543
- volume: number;
544
- }[];
280
+ interface RelationFacade {
281
+ list(): SandboxRelation[];
282
+ /** Incident lookup is endpoint-agnostic; persisted endpoint positions stay unchanged. */
283
+ of(entityId: string, relationKind?: KnownRelationKind): SandboxRelation[];
284
+ /** physical-asset binds inline Caption text, never external media. */
285
+ link(input: LinkRelationInput): string;
286
+ /** Author ordered generated(output,input); generic link() deliberately rejects this kind. */
287
+ linkGenerated(input: LinkGeneratedRelationInput): string;
288
+ /** Author ordered clip-anchor(child,host) without positional endpoint ambiguity. */
289
+ linkClipAnchor(input: LinkClipAnchorRelationInput): string;
290
+ /** Author ordered audio-script-render(output,script) without positional endpoint ambiguity. */
291
+ linkAudioScriptRender(input: LinkAudioScriptRenderRelationInput): string;
292
+ /** Remove a Relation by identity; endpoint replacement is an explicit unlink plus link. */
293
+ unlink(input: UnlinkRelationInput): void;
545
294
  }
546
- /**
547
- * Toggle caption visibility (the caption track's `is_hidden` flag).
548
- */
549
- interface SetCaptionVisibilityInput {
550
- /**
551
- * Whether the caption track is hidden
552
- */
553
- is_hidden: boolean;
554
- }
555
- /**
556
- * Set the caption visual style.
557
- */
558
- interface SetCaptionStyleInput {
559
- /**
560
- * Font ID referencing a font from the font library
561
- * @constraint minLength(1)
562
- */
563
- font_id?: string;
564
- /**
565
- * Font size in points
566
- * @constraint positive
567
- */
568
- font_size?: number;
569
- /**
570
- * Font color as hex string, e.g. "#FFFFFF"
571
- * @constraint minLength(1)
572
- */
573
- font_color?: string;
574
- /**
575
- * Numeric font weight, e.g. 400 or 700
576
- * @constraint int
577
- */
578
- font_weight?: number;
579
- /**
580
- * Entrance animation preset ID, e.g. "fade" or "none"
581
- */
582
- entrance_animation?: string;
583
- /**
584
- * Entrance animation duration in ms
585
- * @constraint min(0)
586
- */
587
- entrance_animation_duration_ms?: number;
588
- /**
589
- * Outline/stroke color as hex string, e.g. "#000000"
590
- * @constraint minLength(1)
591
- */
592
- stroke_color?: string;
593
- /**
594
- * Outline/stroke width in pixels
595
- * @constraint min(0)
596
- */
597
- stroke_width?: number;
598
- /**
599
- * Caption center X as a fraction (0.0 to 1.0)
600
- */
601
- position_x?: number;
602
- /**
603
- * Caption center Y as a fraction (0.0 to 1.0)
604
- */
605
- position_y?: number;
606
- }
607
- /**
608
- * Set the document BGM.
609
- */
295
+ interface ReplaceClipContentInput {
296
+ readonly clipEntityId: string;
297
+ /** Existing Sequence media Entity id. Asset ids and URLs are not content ids. */
298
+ readonly contentEntityId: string;
299
+ readonly sourceRange: SequenceRange<number>;
300
+ readonly duration: SequenceDuration<number>;
301
+ readonly targetRange?: SequenceRange<number>;
302
+ readonly timeRemapping?: JsonValue;
303
+ }
304
+ interface ReplaceMediaClipInput {
305
+ readonly clipEntityId: string;
306
+ readonly media: VisualMediaAssetFact;
307
+ readonly sourceRange: SequenceRange<number>;
308
+ }
309
+ interface ReplaceSequentialClipsInput {
310
+ readonly timelineEntityId: string;
311
+ readonly oldClipEntityIds: readonly string[];
312
+ readonly newClips: readonly ReplacementMediaClipInput[];
313
+ readonly onAnchored: 'remap' | 'cascade';
314
+ }
315
+ interface ReplacementMediaClipInput {
316
+ readonly clipEntityId?: string;
317
+ readonly media: VisualMediaAssetFact;
318
+ readonly sourceRange: SequenceRange<number>;
319
+ readonly volume?: number;
320
+ }
321
+ /** Asset identity, either an old physical-only row or a directly composed media variant. */
322
+ type ResourceEntityKind = 'image' | 'video' | 'audio' | 'voice';
323
+ interface SandboxEntity<K extends KnownEntityKind = KnownEntityKind> {
324
+ entity_id: string;
325
+ entity_kind: K;
326
+ payload: EntityPayloadByKind[K];
327
+ }
328
+ interface SandboxRelation {
329
+ relation_id: string;
330
+ relation_kind: KnownRelationKind;
331
+ endpoint_0_entity_id: string;
332
+ endpoint_1_entity_id: string;
333
+ metadata: JsonObject;
334
+ trace: JsonObject;
335
+ }
336
+ type ScriptTextSegment = JsonObject & {
337
+ segmentId: string;
338
+ text: string;
339
+ language?: string;
340
+ };
341
+ type SequenceDuration<Span = unknown> = {
342
+ readonly mode: 'from-source';
343
+ } | {
344
+ readonly mode: 'fixed';
345
+ readonly value: Span;
346
+ };
347
+ interface SequenceRange<Point = unknown> {
348
+ readonly start: Point;
349
+ readonly end: Point;
350
+ }
351
+ type SequentialClipAnchor = {
352
+ readonly position: 'before' | 'after';
353
+ readonly clipEntityId: string;
354
+ } | {
355
+ readonly position: 'trackStart';
356
+ };
610
357
  interface SetBgmInput {
611
- /**
612
- * The bgm part ID to write
613
- * @constraint minLength(1)
614
- */
615
- bgm_id: string;
616
- /**
617
- * @constraint minLength(1)
618
- */
619
- audio_storage_key: string;
620
- /**
621
- * The media asset ID
622
- * @constraint minLength(1)
623
- */
624
- origin_media_id: string;
625
- /**
626
- * Volume in decibels (-60.0 to 20.0; 0.0 = original, -60 = mute, +20 = max)
627
- * @constraint min(-60)
628
- * @constraint max(20)
629
- */
630
- volume: number;
631
- }
632
- /**
633
- * Remove the document BGM.
634
- */
635
- interface DeleteBgmInput {
636
- [key: string]: never;
637
- }
638
- interface AdjustBgmVolumeInput {
639
- /**
640
- * List of bgm parts with their new volume settings
641
- * @constraint minLength(1)
642
- */
643
- bgm: {
644
- /**
645
- * The bgm part ID to adjust volume for
646
- * @constraint minLength(1)
647
- */
648
- bgm_id: string;
649
- /**
650
- * Volume in decibels (-60.0 to 20.0; 0.0 = original)
651
- * @constraint min(-60)
652
- * @constraint max(20)
653
- */
654
- volume: number;
655
- }[];
358
+ readonly timelineEntityId: string;
359
+ readonly bgmClipEntityId: string;
360
+ readonly media: AudioMediaAssetFact;
361
+ readonly volume: number;
656
362
  }
657
- /** Agent write surface — one method per SemanticOp kind. */
658
- interface EditApi {
659
- moveVideoClips(input: MoveVideoClipsInput): Promise<void>;
660
- moveVideoClipsByAnchor(input: MoveVideoClipsByAnchorInput): Promise<void>;
661
- deleteVideoClips(input: DeleteVideoClipsInput): Promise<void>;
662
- /** Add video clips to a track. */
663
- addVideoClips(input: AddVideoClipsInput): Promise<void>;
664
- adjustVideoClipVolume(input: AdjustVideoClipVolumeInput): Promise<void>;
665
- /** Set the playback speed of existing video clips. */
666
- setVideoClipSpeedShift(input: SetVideoClipSpeedShiftInput): Promise<void>;
667
- /** Replace the media backing existing video clips. */
668
- replaceVideoClipContent(input: ReplaceVideoClipContentInput): Promise<void>;
669
- replaceVideoClipSequence(input: ReplaceVideoClipSequenceInput): Promise<void>;
670
- /** Re-trim existing video clips (the user-facing "adjust duration" gesture is a trim of the source window). */
671
- adjustVideoClipDuration(input: AdjustVideoClipDurationInput): Promise<void>;
672
- /** Add speeches (and their captions). */
673
- addSpeeches(input: AddSpeechesInput): Promise<void>;
674
- /** Delete speeches with their captions. */
675
- deleteSpeeches(input: DeleteSpeechesInput): Promise<void>;
676
- /** Move speeches in time. */
677
- moveSpeeches(input: MoveSpeechesInput): Promise<void>;
678
- /** Change a speech's script or voice. */
679
- changeSpeechScript(input: ChangeSpeechScriptInput): Promise<void>;
680
- changeSpeechVoice(input: ChangeSpeechVoiceInput): Promise<void>;
681
- adjustSpeechVolume(input: AdjustSpeechVolumeInput): Promise<void>;
682
- /** Toggle caption visibility (the caption track's `is_hidden` flag). */
683
- setCaptionVisibility(input: SetCaptionVisibilityInput): Promise<void>;
684
- /** Set the caption visual style. */
685
- setCaptionStyle(input: SetCaptionStyleInput): Promise<void>;
686
- /** Set the document BGM. */
687
- setBgm(input: SetBgmInput): Promise<void>;
688
- /** Remove the document BGM. */
689
- deleteBgm(input: DeleteBgmInput): Promise<void>;
690
- adjustBgmVolume(input: AdjustBgmVolumeInput): Promise<void>;
691
- }
692
- /** Clip hit from `clipsInRange`. */
693
- interface TimelineClipDescriptor {
694
- id: string;
695
- start_ms: number;
696
- end_ms: number;
697
- duration_ms: number;
698
- speed_shift: unknown;
699
- volume: number | undefined;
700
- media_id: string | undefined;
701
- }
702
- /** Part descriptor from `part(id)`. */
703
- interface TimelinePartDescriptor {
704
- id: string;
705
- kind: string;
706
- lane: string;
707
- start_ms: number;
708
- end_ms: number;
709
- duration_ms: number;
710
- part: unknown;
711
- }
712
- /** Opaque VideoDraft projection (full IDL lives in host document types). */
713
- type VideoDraftProjection = {
714
- readonly timeline?: {
715
- readonly duration_ms?: number;
363
+ interface SetCaptionVisibilityInput {
364
+ readonly timelineEntityId: string;
365
+ readonly hidden: boolean;
366
+ }
367
+ interface SetClipPlacementInput {
368
+ readonly clipEntityId: string;
369
+ readonly placement: ClipPlacement;
370
+ }
371
+ interface SetClipSpeedInput {
372
+ readonly clipEntityId: string;
373
+ readonly timeRemapping: LinearClipSpeed | null;
374
+ }
375
+ interface SetClipVolumeInput {
376
+ readonly clipEntityId: string;
377
+ /** Playback gain in decibels. */
378
+ readonly volume: number;
379
+ }
380
+ interface TrimClipInput {
381
+ readonly clipEntityId: string;
382
+ readonly sourceRange: SequenceRange<number>;
383
+ }
384
+ interface UnboundedConstantSequencePayload extends JsonObject {
385
+ extent: {
386
+ kind: 'unbounded';
387
+ start: number;
716
388
  };
717
- readonly [key: string]: unknown;
718
- };
719
- /** Agent read surface over the forked document. */
389
+ sampling: 'constant';
390
+ coordinateSpace: JsonValue;
391
+ }
392
+ interface UnlinkRelationInput {
393
+ relation_id: string;
394
+ }
395
+ interface UpdateClipInput {
396
+ readonly clipEntityId: string;
397
+ /** Complete replacement for the Clip-owned payload. */
398
+ readonly payload: JsonObject;
399
+ }
400
+ interface UpdateClipMarkerInput {
401
+ readonly clipEntityId: string;
402
+ readonly sourceRange?: SequenceRange<number>;
403
+ /** Passing `undefined` explicitly removes the optional target range. */
404
+ readonly targetRange?: SequenceRange<number> | undefined;
405
+ readonly duration?: SequenceDuration<number>;
406
+ /** Passing `undefined` explicitly removes the optional remapping value. */
407
+ readonly timeRemapping?: JsonValue | undefined;
408
+ }
409
+ interface UpdateEntityInput {
410
+ entity_id: string;
411
+ payload: JsonObject;
412
+ }
413
+ interface VideoMediaAssetFact {
414
+ readonly assetId: string;
415
+ readonly kind: 'video';
416
+ readonly durationMs: number;
417
+ readonly storageKey?: string;
418
+ }
419
+ type VisualMediaAssetFact = ImageMediaAssetFact | VideoMediaAssetFact;
420
+ interface VoiceDescriptor {
421
+ readonly system: 'voice-library';
422
+ readonly key: string;
423
+ readonly name?: string;
424
+ }
425
+ interface VoiceMediaAssetFact {
426
+ /** Stable external speech result id, independent of the placed Clip id. */
427
+ readonly assetId: string;
428
+ readonly kind: 'voice';
429
+ readonly durationMs: number;
430
+ readonly storageKey: string;
431
+ readonly voice: VoiceDescriptor;
432
+ }
433
+ interface VoiceoverCaptionFact {
434
+ /** Stable placed caption identity supplied by the materialized side effect. */
435
+ readonly captionClipEntityId: string;
436
+ readonly text: string;
437
+ readonly startMs: number;
438
+ readonly durationMs: number;
439
+ readonly style?: CaptionStyleFields;
440
+ }
441
+ interface VoiceoverTakeInput {
442
+ readonly timelineEntityId: string;
443
+ /** Stable placed speech identity, distinct from media.assetId. */
444
+ readonly voiceoverClipEntityId: string;
445
+ readonly hostClipEntityId: string;
446
+ readonly anchorOffset: number;
447
+ readonly media: VoiceMediaAssetFact;
448
+ /** Complete spoken text; the editor owns the deterministic local script segment identity. */
449
+ readonly scriptText: string;
450
+ readonly volume: number;
451
+ readonly captions: readonly VoiceoverCaptionFact[];
452
+ }
453
+ interface VoiceoverTakeResult {
454
+ readonly voiceoverClipEntityId: string;
455
+ readonly voiceEntityId: string;
456
+ readonly audioScriptEntityId: string;
457
+ readonly captionClipEntityIds: readonly string[];
458
+ }
459
+ /** Timeline writes accept existing media Entity ids, never Memota asset ids or URLs. */
460
+ interface EditApi {
461
+ insertClip(input: InsertClipInput): ClipEntityId;
462
+ insertPlacedClip(input: InsertPlacedClipInput): ClipEntityId;
463
+ updateClipMarker(input: UpdateClipMarkerInput): void;
464
+ setClipPlacement(input: SetClipPlacementInput): void;
465
+ moveSequentialClips(input: MoveSequentialClipsInput): void;
466
+ moveClip(input: MoveClipInput): void;
467
+ replaceClipContent(input: ReplaceClipContentInput): void;
468
+ insertMediaClip(input: InsertMediaClipInput): ClipEntityId;
469
+ insertMediaClips(input: InsertMediaClipsInput): readonly ClipEntityId[];
470
+ replaceMediaClip(input: ReplaceMediaClipInput): void;
471
+ setClipVolume(input: SetClipVolumeInput): void;
472
+ setClipSpeed(input: SetClipSpeedInput): void;
473
+ trimClip(input: TrimClipInput): void;
474
+ replaceSequentialClips(input: ReplaceSequentialClipsInput): readonly ClipEntityId[];
475
+ deleteClip(input: DeleteClipInput): void;
476
+ deleteClipTree(input: DeleteClipTreeInput): void;
477
+ updateClip(input: UpdateClipInput): void;
478
+ upsertVoiceoverTake(input: VoiceoverTakeInput): VoiceoverTakeResult;
479
+ moveVoiceover(input: MoveVoiceoverInput): void;
480
+ moveClipsToStarts(input: MoveClipsToStartsInput): void;
481
+ deleteVoiceover(input: DeleteVoiceoverInput): void;
482
+ setBgm(input: SetBgmInput): ClipEntityId;
483
+ deleteBgm(input: DeleteBgmInput): void;
484
+ setCaptionVisibility(input: SetCaptionVisibilityInput): void;
485
+ patchCaptionStyle(input: PatchCaptionStyleInput): void;
486
+ }
720
487
  interface TimelineApi {
721
- /** Snapshot the current VideoDraft projection. */
722
- snapshot(): VideoDraftProjection;
723
- /** Clips whose midpoint falls in `[startMs, endMs)`. */
724
- clipsInRange(startMs: number, endMs: number): TimelineClipDescriptor[];
725
- /** Look up a part by id, or null if missing. */
726
- part(id: string): TimelinePartDescriptor | null;
727
- }
728
- /** Opaque checkpoint handle for rollback. */
488
+ snapshot(): EntityStoreSnapshot;
489
+ }
729
490
  interface SandboxCheckpoint {
730
491
  readonly index: number;
731
492
  }
732
493
  declare const edit: EditApi;
733
494
  declare const timeline: TimelineApi;
734
- /** Capture a rollback point. */
495
+ declare const entities: EntityFacade;
496
+ declare const relations: RelationFacade;
735
497
  declare function checkpoint(): SandboxCheckpoint;
736
- /** Roll the sandbox document back to a prior checkpoint. */
737
498
  declare function rollbackTo(cp: SandboxCheckpoint): void;
738
- /** Host-injected script arguments (opaque). */
739
- declare const inputs: unknown;
499
+ declare const inputs: Readonly<Record<string, unknown>>;
740
500
  //#endregion
741
- export type { AddSpeechesInput, AddVideoClipsInput, AdjustBgmVolumeInput, AdjustSpeechVolumeInput, AdjustVideoClipDurationInput, AdjustVideoClipVolumeInput, ChangeSpeechScriptInput, ChangeSpeechVoiceInput, DeleteBgmInput, DeleteSpeechesInput, DeleteVideoClipsInput, EditApi, MoveSpeechesInput, MoveVideoClipsByAnchorInput, MoveVideoClipsInput, ReplaceVideoClipContentInput, ReplaceVideoClipSequenceInput, SandboxCheckpoint, SetBgmInput, SetCaptionStyleInput, SetCaptionVisibilityInput, SetVideoClipSpeedShiftInput, SpeechAssets, SpeedShift, TimelineApi, TimelineClipDescriptor, TimelinePartDescriptor, VideoDraftProjection, Voice, checkpoint, edit, inputs, rollbackTo, timeline };
501
+ export type { AudioMediaAssetFact, BoundedDerivedSequencePayload, BoundedNativeSequencePayload, CaptionFontDescriptor, CaptionStyleFields, ClipEntityId, ClipPlacement, CreateEntityInput, DeleteBgmInput, DeleteClipInput, DeleteClipTreeInput, DeleteEntityInput, DeleteVoiceoverInput, EditApi, EmptyRelationKind, EntityFacade, EntityId, EntityPayloadByKind, EntityStoreSnapshot, ImageMediaAssetFact, InsertClipInput, InsertMediaClipInput, InsertMediaClipsInput, InsertPlacedClipInput, JsonObject, JsonPrimitive, JsonValue, KnownEntityKind, KnownRelationKind, LinearClipSpeed, LinkAudioScriptRenderRelationInput, LinkClipAnchorRelationInput, LinkGeneratedRelationInput, LinkRelationInput, MediaAssetFact, MediaAssetPayload, MediaClipInsertion, MoveClipInput, MoveClipsToStartsInput, MoveSequentialClipsInput, MoveVoiceoverInput, PatchCaptionStyleInput, RelationFacade, ReplaceClipContentInput, ReplaceMediaClipInput, ReplaceSequentialClipsInput, ReplacementMediaClipInput, ResourceEntityKind, SandboxCheckpoint, SandboxEntity, SandboxRelation, ScriptTextSegment, SequenceDuration, SequenceRange, SequentialClipAnchor, SetBgmInput, SetCaptionVisibilityInput, SetClipPlacementInput, SetClipSpeedInput, SetClipVolumeInput, TimelineApi, TrimClipInput, UnboundedConstantSequencePayload, UnlinkRelationInput, UpdateClipInput, UpdateClipMarkerInput, UpdateEntityInput, VideoMediaAssetFact, VisualMediaAssetFact, VoiceDescriptor, VoiceMediaAssetFact, VoiceoverCaptionFact, VoiceoverTakeInput, VoiceoverTakeResult, checkpoint, edit, entities, inputs, relations, rollbackTo, timeline };
742
502
  //# sourceMappingURL=sandbox-api.d.mts.map