@mengine/medeo-client 1.2.0 → 1.2.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ import { $ as adjustVideoClipVolumeInputSchema, A as MoveVideoClipsInput, B as AnchoredDeletePolicy, C as setBgmInputSchema, D as replaceVideoClipSequenceInputSchema, E as anchoredReplacePolicySchema, F as moveAnchorSchema, G as deleteSpeechesInputSchema, H as anchoredDeletePolicySchema, I as moveVideoClipsByAnchorInputSchema, J as ChangeSpeechScriptInput, K as DeleteBgmInput, L as movedClipAnchoredPolicySchema, M as MoveAnchor, N as MoveVideoClipsByAnchorInput, O as ReplaceVideoClipContentInput, P as MovedClipAnchoredPolicy, Q as AdjustVideoClipVolumeInput, R as MoveSpeechesInput, S as SetBgmInput, T as ReplaceVideoClipSequenceInput, U as deleteVideoClipsInputSchema, V as DeleteVideoClipsInput, W as DeleteSpeechesInput, X as changeSpeechScriptInputSchema, Y as ChangeSpeechVoiceInput, Z as changeSpeechVoiceInputSchema, _ as setVideoClipSpeedShiftInputSchema, a as speechAssetsSchema, at as adjustBgmVolumeInputSchema, b as SetCaptionStyleInput, c as mediaIdSchema, ct as AddSpeechesInput, d as speechIdsSchema, et as AdjustVideoClipDurationInput, f as speedShiftSchema, g as SetVideoClipSpeedShiftInput, h as volumeSchema, i as SpeechAssets, it as AdjustBgmVolumeInput, j as moveVideoClipsInputSchema, k as replaceVideoClipContentInputSchema, l as positiveMsSchema, lt as addSpeechesInputSchema, m as voiceSchema, n as CaptionAsset, nt as AdjustSpeechVolumeInput, o as clipIdSchema, ot as AddVideoClipsInput, p as timelineMsSchema, q as deleteBgmInputSchema, r as SpeechAsset, rt as adjustSpeechVolumeInputSchema, s as clipIdsSchema, st as addVideoClipsInputSchema, tt as adjustVideoClipDurationInputSchema, u as speechIdSchema, v as SetCaptionVisibilityInput, w as AnchoredReplacePolicy, x as setCaptionStyleInputSchema, y as setCaptionVisibilityInputSchema, z as moveSpeechesInputSchema } from "./index-InEWX9rk.js";
2
+ export { AddSpeechesInput, AddVideoClipsInput, AdjustBgmVolumeInput, AdjustSpeechVolumeInput, AdjustVideoClipDurationInput, AdjustVideoClipVolumeInput, AnchoredDeletePolicy, AnchoredReplacePolicy, CaptionAsset, ChangeSpeechScriptInput, ChangeSpeechVoiceInput, DeleteBgmInput, DeleteSpeechesInput, DeleteVideoClipsInput, MoveAnchor, MoveSpeechesInput, MoveVideoClipsByAnchorInput, MoveVideoClipsInput, MovedClipAnchoredPolicy, ReplaceVideoClipContentInput, ReplaceVideoClipSequenceInput, SetBgmInput, SetCaptionStyleInput, SetCaptionVisibilityInput, SetVideoClipSpeedShiftInput, SpeechAsset, SpeechAssets, addSpeechesInputSchema, addVideoClipsInputSchema, adjustBgmVolumeInputSchema, adjustSpeechVolumeInputSchema, adjustVideoClipDurationInputSchema, adjustVideoClipVolumeInputSchema, anchoredDeletePolicySchema, anchoredReplacePolicySchema, changeSpeechScriptInputSchema, changeSpeechVoiceInputSchema, clipIdSchema, clipIdsSchema, deleteBgmInputSchema, deleteSpeechesInputSchema, deleteVideoClipsInputSchema, mediaIdSchema, moveAnchorSchema, moveSpeechesInputSchema, moveVideoClipsByAnchorInputSchema, moveVideoClipsInputSchema, movedClipAnchoredPolicySchema, positiveMsSchema, replaceVideoClipContentInputSchema, replaceVideoClipSequenceInputSchema, setBgmInputSchema, setCaptionStyleInputSchema, setCaptionVisibilityInputSchema, setVideoClipSpeedShiftInputSchema, speechAssetsSchema, speechIdSchema, speechIdsSchema, speedShiftSchema, timelineMsSchema, voiceSchema, volumeSchema };
@@ -0,0 +1,518 @@
1
+ import { t as __exportAll } from "./chunk-D7D4PA-g.js";
2
+ import { z } from "zod";
3
+ //#region src/editor/schemas/shared.ts
4
+ const clipIdSchema = z.string().min(1).describe("The clip part ID on the timeline");
5
+ const clipIdsSchema = z.array(clipIdSchema).min(1).refine((ids) => new Set(ids).size === ids.length, { message: "Duplicate clip IDs are not allowed" }).describe("List of clip part IDs (no duplicates allowed)");
6
+ const mediaIdSchema = z.string().min(1).describe("The media asset ID");
7
+ const speechIdSchema = z.string().min(1).describe("The speech part ID on the timeline");
8
+ const timelineMsSchema = z.number().int().min(0).describe("Time position in milliseconds on the timeline (>= 0)");
9
+ const positiveMsSchema = z.number().int().positive().describe("Duration in milliseconds (> 0)");
10
+ const volumeSchema = z.number().min(-60).max(20).describe("Volume in decibels (-60.0 to 20.0; 0.0 = original, -60 = mute, +20 = max)");
11
+ const speechIdsSchema = z.array(speechIdSchema).min(1).refine((ids) => new Set(ids).size === ids.length, { message: "Duplicate speech IDs are not allowed" }).describe("List of speech part IDs (no duplicates allowed)");
12
+ const tangentHandleSchema = z.object({
13
+ x: z.number().finite(),
14
+ y: z.number().finite()
15
+ }).describe("Bezier tangent handle (x, y)");
16
+ const speedKeyframeSchema = z.object({
17
+ position: z.number().min(0).max(1),
18
+ rate: z.number().min(0),
19
+ in_tangent: tangentHandleSchema.optional(),
20
+ out_tangent: tangentHandleSchema.optional()
21
+ }).describe("A speed keyframe: normalized position (0..1), rate, optional tangents");
22
+ /**
23
+ * A clip's playback-speed fact, the only thing `SetVideoClipSpeedShift` writes.
24
+ * Mirrors the IDL `SpeedShift`: `category` is `linear` | `curve`, and `config`
25
+ * is a discriminated union — `{ linear: { speed } }` for a constant multiplier
26
+ * (the multiplier projection reads at `config.linear.speed`) or `{ curve: {
27
+ * keyframes } }` for a Bezier-controlled variable speed (RFC 02 / `reference/16`
28
+ * §0). Exactly one of `linear` / `curve` is present.
29
+ */
30
+ const speedShiftSchema = z.object({
31
+ category: z.enum(["linear", "curve"]),
32
+ mode: z.string(),
33
+ config: z.union([z.object({ linear: z.object({ speed: z.number().finite().positive() }) }), z.object({ curve: z.object({ keyframes: z.array(speedKeyframeSchema).min(2) }) })])
34
+ }).describe("Speed shift: linear multiplier or Bezier curve, mirroring the IDL shape");
35
+ const voiceSchema = z.object({
36
+ id: z.string().min(1),
37
+ name: z.string()
38
+ }).describe("TTS voice summary attached to a speech");
39
+ //#endregion
40
+ //#region src/editor/schemas/speech-assets.ts
41
+ /**
42
+ * The materialized TTS result shared by `AddSpeeches` / `ChangeSpeechScript` /
43
+ * `ChangeSpeechVoice` (see `results/phase-4-side-effect-payload-contract.md`
44
+ * §1/§2). The side effect (TTS/ASR + billing) runs upstream; the op receives the
45
+ * stable speech + caption parts and writes them as authoritative facts. No
46
+ * cascade runs on write — the projection derives absolute positions on read.
47
+ *
48
+ * Each speech carries the anchoring fact directly (RFC 02 §4): the host video
49
+ * clip `anchor_part_id` and the `offset_ms` within it. The upstream caller
50
+ * already knows which clip a speech attaches to, so the op writes
51
+ * `{ mode:'anchored', anchorPartId, offsetMs }` verbatim — no write-time
52
+ * host-picking. Captions anchor to their speech via the caption part's
53
+ * `start_ms` (offset within the speech).
54
+ */
55
+ const speechAssetSchema = z.object({
56
+ speech_id: speechIdSchema.describe("The speech part ID (= side-effect speech_parts[].id)"),
57
+ anchor_part_id: clipIdSchema.describe("Host video clip part ID the speech anchors to (RFC 02 §4)"),
58
+ offset_ms: timelineMsSchema.describe("Offset within the host clip (speech.abs = host.abs + offset_ms)"),
59
+ audio_storage_key: z.string().min(1),
60
+ duration_ms: positiveMsSchema,
61
+ audio_script: z.string(),
62
+ volume: volumeSchema,
63
+ voice: voiceSchema,
64
+ origin_speech_id: z.string().min(1),
65
+ caption_ids: z.array(z.string().min(1)).describe("Caption part IDs owned by this speech")
66
+ });
67
+ const captionAssetSchema = z.object({
68
+ caption_id: z.string().min(1).describe("The caption part ID (= side-effect created_caption_parts[].id)"),
69
+ speech_part_id: speechIdSchema.describe("The owning speech part ID"),
70
+ text: z.string(),
71
+ start_ms: timelineMsSchema.describe("Offset within the host speech (caption.abs = speech.abs + start_ms)"),
72
+ duration_ms: positiveMsSchema
73
+ });
74
+ /** A materialized speech-subtree write (speeches + their captions). */
75
+ const speechAssetsSchema = z.object({
76
+ speeches: z.array(speechAssetSchema).min(1).describe("Materialized speech parts to write"),
77
+ captions: z.array(captionAssetSchema).describe("Materialized caption parts owned by the speeches")
78
+ });
79
+ //#endregion
80
+ //#region src/editor/schemas/add-speeches.ts
81
+ /**
82
+ * Add speeches (and their captions). TTS runs upstream; the stable speech /
83
+ * caption parts arrive materialized (see `speech-assets.ts`). The op writes the
84
+ * parts and each speech's `{ mode:'anchored', anchorPartId, offsetMs }` fact
85
+ * verbatim — no write-time host-picking, no cascade (RFC 02 §4). The projection
86
+ * derives absolute positions on read.
87
+ */
88
+ const addSpeechesInputSchema = speechAssetsSchema.describe("Materialized speeches + captions to add");
89
+ //#endregion
90
+ //#region src/editor/schemas/add-video-clips.ts
91
+ /**
92
+ * Add video clips to a track. Each clip's duration facts are separated so a
93
+ * single number is never overloaded (RFC 02 / `reference/16` §0b):
94
+ *
95
+ * - `media_duration_ms` is the source media's intrinsic full length (a resource
96
+ * fact, written to the part);
97
+ * - `play_in` / `play_out` are the optional trim window into that media; when
98
+ * omitted the whole media is used (`play_in=0`, `play_out=media_duration_ms`).
99
+ *
100
+ * The clip's effective timeline duration is derived by the projection from the
101
+ * trim window and `speed_shift` — it is never an input here.
102
+ */
103
+ const addVideoClipsInputSchema = z.object({
104
+ clips: z.array(z.object({
105
+ media_id: mediaIdSchema.describe("The media asset ID for the video clip"),
106
+ start_ms: timelineMsSchema.optional().describe("Absolute start time in milliseconds on the timeline"),
107
+ media_duration_ms: positiveMsSchema.describe("The source media's intrinsic full length in ms"),
108
+ play_in: timelineMsSchema.optional().describe("Trim window start in the media (default 0)"),
109
+ play_out: positiveMsSchema.optional().describe("Trim window end in the media (default media_duration_ms)"),
110
+ track_id: z.string().min(1).optional().describe("Target track ID (optional, defaults to main track)")
111
+ })).min(1).describe("List of video clips to create"),
112
+ before_clip_id: z.string().min(1).optional().describe("Insert new clips before this clip ID"),
113
+ after_clip_id: z.string().min(1).optional().describe("Insert new clips after this clip ID")
114
+ }).superRefine((data, ctx) => {
115
+ if (data.before_clip_id != null && data.after_clip_id != null) {
116
+ ctx.addIssue({
117
+ code: z.ZodIssueCode.custom,
118
+ message: "Cannot provide both before_clip_id and after_clip_id"
119
+ });
120
+ return;
121
+ }
122
+ const hasRelative = data.before_clip_id != null || data.after_clip_id != null;
123
+ for (let i = 0; i < data.clips.length; i++) {
124
+ const clip = data.clips[i];
125
+ if (hasRelative && clip.start_ms != null) ctx.addIssue({
126
+ code: z.ZodIssueCode.custom,
127
+ message: `clips[${i}].start_ms must not be provided when using before_clip_id or after_clip_id`,
128
+ path: [
129
+ "clips",
130
+ i,
131
+ "start_ms"
132
+ ]
133
+ });
134
+ if (!hasRelative && clip.start_ms == null) ctx.addIssue({
135
+ code: z.ZodIssueCode.custom,
136
+ message: `clips[${i}].start_ms is required when not using relative positioning`,
137
+ path: [
138
+ "clips",
139
+ i,
140
+ "start_ms"
141
+ ]
142
+ });
143
+ const playIn = clip.play_in ?? 0;
144
+ const playOut = clip.play_out ?? clip.media_duration_ms;
145
+ if (playOut > clip.media_duration_ms) ctx.addIssue({
146
+ code: z.ZodIssueCode.custom,
147
+ message: `clips[${i}].play_out ${playOut}ms exceeds media_duration_ms ${clip.media_duration_ms}ms`,
148
+ path: [
149
+ "clips",
150
+ i,
151
+ "play_out"
152
+ ]
153
+ });
154
+ if (playIn >= playOut) ctx.addIssue({
155
+ code: z.ZodIssueCode.custom,
156
+ message: `clips[${i}].play_in ${playIn}ms must be less than play_out ${playOut}ms`,
157
+ path: [
158
+ "clips",
159
+ i,
160
+ "play_in"
161
+ ]
162
+ });
163
+ }
164
+ });
165
+ //#endregion
166
+ //#region src/editor/schemas/adjust-bgm-volume.ts
167
+ const adjustBgmVolumeInputSchema = z.object({ bgm: z.array(z.object({
168
+ bgm_id: clipIdSchema.describe("The bgm part ID to adjust volume for"),
169
+ volume: volumeSchema.describe("Volume in decibels (-60.0 to 20.0; 0.0 = original)")
170
+ })).min(1).describe("List of bgm parts with their new volume settings") });
171
+ //#endregion
172
+ //#region src/editor/schemas/adjust-speech-volume.ts
173
+ const adjustSpeechVolumeInputSchema = z.object({ speeches: z.array(z.object({
174
+ speech_id: speechIdSchema.describe("The speech part ID to adjust volume for"),
175
+ volume: volumeSchema.describe("Volume in decibels (-60.0 to 20.0; 0.0 = original)")
176
+ })).min(1).describe("List of speeches with their new volume settings") });
177
+ //#endregion
178
+ //#region src/editor/schemas/adjust-video-clip-duration.ts
179
+ /**
180
+ * Re-trim existing video clips (the user-facing "adjust duration" gesture is a
181
+ * trim of the source window). The new `play_in` / `play_out` are the facts; the
182
+ * effective timeline duration is derived from them and the clip's `speed_shift`,
183
+ * and the change reflows downstream clips, speeches, and the timeline inside the
184
+ * op's transaction (no caller-materialized cascade).
185
+ */
186
+ const adjustVideoClipDurationInputSchema = z.object({ clips: z.array(z.object({
187
+ clip_id: clipIdSchema.describe("The video clip part ID to re-trim"),
188
+ play_in: timelineMsSchema.describe("New trim window start in the source media"),
189
+ play_out: positiveMsSchema.describe("New trim window end in the source media")
190
+ })).min(1).describe("Video clips with their new trim windows") });
191
+ //#endregion
192
+ //#region src/editor/schemas/adjust-video-clip-volume.ts
193
+ const adjustVideoClipVolumeInputSchema = z.object({ clips: z.array(z.object({
194
+ clip_id: clipIdSchema.describe("The video clip part ID to adjust volume for"),
195
+ volume: volumeSchema.describe("Volume in decibels (-60.0 to 20.0; 0.0 = original)")
196
+ })).min(1).describe("List of video clips with their new volume settings") });
197
+ //#endregion
198
+ //#region src/editor/schemas/change-speech.ts
199
+ /**
200
+ * Change a speech's script or voice. Both re-run TTS upstream and return the
201
+ * regenerated speech / caption parts in the same materialized shape as
202
+ * `AddSpeeches` (`speech-assets.ts`); the op upserts them by id (the speech part
203
+ * id is preserved across a re-TTS), re-seats at `start_ms`, and reflows. Old
204
+ * caption parts no longer owned by the speech are removed via `caption_ids`.
205
+ */
206
+ const changeSpeechScriptInputSchema = speechAssetsSchema.describe("Regenerated speeches + captions (new script)");
207
+ const changeSpeechVoiceInputSchema = speechAssetsSchema.describe("Regenerated speeches + captions (new voice)");
208
+ //#endregion
209
+ //#region src/editor/schemas/delete-bgm.ts
210
+ /**
211
+ * Remove the document BGM. Pure document edit: clears the bgm lane and removes
212
+ * the bgm part. Takes no input (a document holds at most one bgm); an empty
213
+ * object keeps the op signature uniform with the rest.
214
+ */
215
+ const deleteBgmInputSchema = z.object({}).describe("Remove the document BGM (no parameters)");
216
+ //#endregion
217
+ //#region src/editor/schemas/delete-speeches.ts
218
+ /**
219
+ * Delete speeches with their captions. Pure document edit (no side effect): the
220
+ * op removes each speech part, cascade-deletes the captions it owns (via
221
+ * `caption_ids` / `speech_part_id`), drops their track items, and reflows.
222
+ */
223
+ const deleteSpeechesInputSchema = z.object({ speech_ids: speechIdsSchema.describe("Speech part IDs to delete (their captions cascade-delete)") });
224
+ //#endregion
225
+ //#region src/editor/schemas/delete-video-clips.ts
226
+ /**
227
+ * How a delete handles the anchored subtree (speeches anchored to a deleted clip,
228
+ * and their captions) — a delete-op policy, not a data-model field (reference/17
229
+ * §6). `cascade` (default) removes the subtree; `detach` keeps the direct
230
+ * anchored children, re-pinning them to `absolute` so they stay on the timeline.
231
+ */
232
+ const anchoredDeletePolicySchema = z.enum(["cascade", "detach"]);
233
+ const deleteVideoClipsInputSchema = z.object({
234
+ clip_ids: clipIdsSchema.describe("List of video clip part IDs to delete from the main track"),
235
+ on_anchored: anchoredDeletePolicySchema.optional().describe("How to treat anchored children (default cascade)")
236
+ });
237
+ //#endregion
238
+ //#region src/editor/schemas/move-speeches.ts
239
+ /**
240
+ * Move speeches in time. Pure document edit: the op re-seats each speech at its
241
+ * new absolute `start_ms`; the cascade reassigns it to the host video clip,
242
+ * resolves overlaps, and reflows. Captions follow their speech.
243
+ */
244
+ const moveSpeechesInputSchema = z.object({ speeches: z.array(z.object({
245
+ speech_id: speechIdSchema.describe("The speech part ID to move"),
246
+ new_start_ms: timelineMsSchema.describe("New absolute start time on the timeline")
247
+ })).min(1).describe("Speeches to move to new positions") });
248
+ //#endregion
249
+ //#region src/editor/schemas/move-video-clips-by-anchor.ts
250
+ /**
251
+ * Where the moved block lands on the main track.
252
+ *
253
+ * A discriminated union rather than two optional `before_clip_id` /
254
+ * `after_clip_id` fields (the shape `addVideoClips` had to use, because there the
255
+ * two modes share a whole clip description): here the alternatives carry nothing
256
+ * in common, so making them mutually exclusive *by type* removes three runtime
257
+ * `superRefine` checks that would otherwise have to be written and tested.
258
+ *
259
+ * `track_start` is an explicit member, not the absence of an anchor. The
260
+ * agent-harness mutation this maps from treats "neither anchor given" as
261
+ * "move to the front" (`applyBatchMoveVideoClips` falls back to `insertIndex = 0`),
262
+ * which is a default buried in a tool description. Requiring the caller to name
263
+ * that intent keeps a forgotten field from silently reordering the timeline.
264
+ */
265
+ const moveAnchorSchema = z.discriminatedUnion("position", [
266
+ z.object({
267
+ position: z.literal("before"),
268
+ clip_id: clipIdSchema.describe("The moved block lands immediately before this clip")
269
+ }),
270
+ z.object({
271
+ position: z.literal("after"),
272
+ clip_id: clipIdSchema.describe("The moved block lands immediately after this clip")
273
+ }),
274
+ z.object({ position: z.literal("track_start") })
275
+ ]).describe("Where the moved block lands: before/after a reference clip, or at the head of the track");
276
+ /**
277
+ * What happens to the speeches anchored to the clips being moved.
278
+ *
279
+ * - `follow` keeps each speech anchored where it is, so it travels with its clip
280
+ * to the new position. In the anchored model this is the *no-op* branch: a
281
+ * speech's authoritative fact is `{ anchorPartId, offsetMs }` and its absolute
282
+ * time is derived on read from the host's position, so moving the host moves
283
+ * the speech with no write to the speech at all.
284
+ * - `keep_absolute` preserves each speech's current absolute landing instead, then
285
+ * re-anchors it to whichever clip now covers that time (RFC 02 §9.1/§11.1). This
286
+ * is the branch that costs an extra pass, and the one the FE timeline uses.
287
+ *
288
+ * **Required, with no default**, matching `deleteVideoClips` and
289
+ * `replaceVideoClipSequence`. The two branches decide which picture the user's
290
+ * narration ends up over, which is too consequential to infer from a missing
291
+ * field — and neither branch is "safe enough" to be the implicit one.
292
+ */
293
+ const movedClipAnchoredPolicySchema = z.enum(["follow", "keep_absolute"]);
294
+ /**
295
+ * Reorder a set of main-track clips relative to a reference clip.
296
+ *
297
+ * Distinct from `moveVideoClips`, which positions clips by absolute time
298
+ * (`new_start_ms`) and is what the FE timeline dispatches after a drag. Main-track
299
+ * clips are `sequential`-positioned, so absolute time is not authoritative state
300
+ * there (RFC 02 §4/§7): `moveVideoClips` has to *guess* an index back out of the
301
+ * time it was handed, whereas an anchor already is the ordinal fact being changed.
302
+ * Keeping them separate also isolates blast radius — this method can diverge on
303
+ * speech policy without touching the FE path.
304
+ *
305
+ * `clip_ids` need not be contiguous. They move as one block, keeping their
306
+ * relative order, which is the agent-harness `batch_move_video_clips` contract.
307
+ */
308
+ const moveVideoClipsByAnchorInputSchema = z.object({
309
+ clip_ids: clipIdsSchema.describe("Clips to move as one block, keeping their relative order. Need not be contiguous on the track."),
310
+ anchor: moveAnchorSchema,
311
+ on_anchored: movedClipAnchoredPolicySchema.describe("What happens to speeches anchored to the moved clips (required — see the policy doc)")
312
+ });
313
+ //#endregion
314
+ //#region src/editor/schemas/move-video-clips.ts
315
+ const moveVideoClipsInputSchema = z.object({ clips: z.array(z.object({
316
+ clip_id: clipIdSchema.describe("The video clip part ID to move"),
317
+ new_start_ms: timelineMsSchema.describe("New absolute start time in milliseconds on the timeline"),
318
+ new_track_id: z.string().min(1).optional().describe("Target track ID to move the clip to (optional)")
319
+ })).min(1).describe("List of video clips to move to new positions") });
320
+ //#endregion
321
+ //#region src/editor/schemas/replace-video-clip-content.ts
322
+ /**
323
+ * Replace the media backing existing video clips. The media import runs upstream
324
+ * (Director); its stable result — the new media id, intrinsic length, and the
325
+ * reset trim window — arrives materialized (see
326
+ * `results/phase-4-side-effect-payload-contract.md` §4). Director resets
327
+ * `play_in=0` / `play_out=media_duration_ms` and clears `speed_shift` on
328
+ * replacement. The clip `part_id`s (hence their track items) are unchanged; the
329
+ * editor reflows the main track from the new effective durations.
330
+ */
331
+ const replaceVideoClipContentInputSchema = z.object({ clips: z.array(z.object({
332
+ clip_id: clipIdSchema.describe("Existing video clip part ID to re-point"),
333
+ origin_media_id: mediaIdSchema.describe("The new media asset ID"),
334
+ media_duration_ms: positiveMsSchema.describe("The new media's intrinsic full length"),
335
+ play_in: timelineMsSchema.describe("Trim window start in the new media (usually 0)"),
336
+ play_out: positiveMsSchema.describe("Trim window end in the new media (usually = media_duration_ms)"),
337
+ volume: volumeSchema
338
+ })).min(1).describe("Video clips whose media is being replaced") });
339
+ //#endregion
340
+ //#region src/editor/schemas/replace-video-clip-sequence.ts
341
+ /**
342
+ * What happens to the speeches anchored to the clips being replaced.
343
+ *
344
+ * - `remap` re-anchors each surviving speech to the new clip in the SAME POSITION
345
+ * of the sequence, keeping its offset — old[i]'s children become new[i]'s
346
+ * children. An old clip with no counterpart (fewer new clips than old) has its
347
+ * subtree deleted, because there is nothing left to anchor to.
348
+ * - `cascade` deletes every anchored speech (and its captions) outright, like
349
+ * `deleteVideoClips`.
350
+ *
351
+ * **Required, with no default.** The two branches differ in whether the user's
352
+ * narration survives, and the agent tool that drives this op makes its
353
+ * `preserve_speeches` flag required for that reason. A default here would let a
354
+ * caller that forgot the field silently delete speech.
355
+ */
356
+ const anchoredReplacePolicySchema = z.enum(["remap", "cascade"]);
357
+ /**
358
+ * Replace a contiguous run of main-track clips with a new run.
359
+ *
360
+ * A composite of delete + insert that cannot be expressed as the two ops in
361
+ * sequence, because the anchored speeches have to survive *across* the swap: with
362
+ * `remap` they are re-anchored positionally, which needs both the old and the new
363
+ * ids in the same transaction (ADR 0009 — the cascade stays in the editor, callers
364
+ * never re-wire anchors themselves).
365
+ *
366
+ * Duration facts follow `addVideoClips`: `media_duration_ms` is the source's
367
+ * intrinsic length and the trim window defaults to the whole media. The effective
368
+ * timeline duration is derived by the projection, never an input.
369
+ *
370
+ * `media_id` is optional: omitting it creates a **deliberate empty placeholder
371
+ * clip** (`origin_media_id: ''`) — structure with no picture. This is the only op
372
+ * that can produce one, and it is authoritative state, unlike the gap fillers the
373
+ * read-side solve mints (which never enter the document).
374
+ */
375
+ const replaceVideoClipSequenceInputSchema = z.object({
376
+ old_clip_ids: clipIdsSchema.describe("The clips being replaced: a contiguous main-track run, listed in timeline order"),
377
+ new_clips: z.array(z.object({
378
+ media_id: mediaIdSchema.optional().describe("The replacement media asset ID. Omit to create an empty placeholder clip."),
379
+ media_duration_ms: positiveMsSchema.describe("The source media's intrinsic full length in ms"),
380
+ play_in: timelineMsSchema.optional().describe("Trim window start in the media (default 0)"),
381
+ play_out: positiveMsSchema.optional().describe("Trim window end in the media (default media_duration_ms)")
382
+ })).min(1).describe("The replacement clips, in the order they take on the track"),
383
+ on_anchored: anchoredReplacePolicySchema.describe("What happens to speeches anchored to the replaced clips (required — see the policy doc)")
384
+ }).superRefine((data, ctx) => {
385
+ for (let i = 0; i < data.new_clips.length; i++) {
386
+ const clip = data.new_clips[i];
387
+ const playIn = clip.play_in ?? 0;
388
+ const playOut = clip.play_out ?? clip.media_duration_ms;
389
+ if (playOut > clip.media_duration_ms) ctx.addIssue({
390
+ code: z.ZodIssueCode.custom,
391
+ message: `new_clips[${i}].play_out ${playOut}ms exceeds media_duration_ms ${clip.media_duration_ms}ms`,
392
+ path: [
393
+ "new_clips",
394
+ i,
395
+ "play_out"
396
+ ]
397
+ });
398
+ if (playIn >= playOut) ctx.addIssue({
399
+ code: z.ZodIssueCode.custom,
400
+ message: `new_clips[${i}].play_in ${playIn}ms must be less than play_out ${playOut}ms`,
401
+ path: [
402
+ "new_clips",
403
+ i,
404
+ "play_in"
405
+ ]
406
+ });
407
+ }
408
+ });
409
+ //#endregion
410
+ //#region src/editor/schemas/set-bgm.ts
411
+ /**
412
+ * Set the document BGM. The media's stable result (storage key) arrives
413
+ * materialized from upstream (see
414
+ * `results/phase-4-side-effect-payload-contract.md` §3). The op upserts the bgm
415
+ * part and seats it on the bgm lane; its effective length is always the whole
416
+ * timeline, derived by the projection on read — so there is no `duration_ms`
417
+ * input or fact (RFC 02 / `reference/16` §0b). A `bgm_id` lets the op replace an
418
+ * existing bgm part by id.
419
+ */
420
+ const setBgmInputSchema = z.object({
421
+ bgm_id: z.string().min(1).describe("The bgm part ID to write"),
422
+ audio_storage_key: z.string().min(1),
423
+ origin_media_id: mediaIdSchema,
424
+ volume: volumeSchema
425
+ });
426
+ //#endregion
427
+ //#region src/editor/schemas/set-caption-style.ts
428
+ /**
429
+ * Set the caption visual style. GLOBAL by design: the style applies to every
430
+ * caption part in the document — it carries NO `caption_id`. This mirrors the FE,
431
+ * whose caption-style store (`caption-style.ts:persistCaptionStylePatch`) iterates
432
+ * ALL captions and writes the same normalized style to each; the product has a
433
+ * single document-wide caption style, not per-caption styling.
434
+ *
435
+ * Every field is optional and maps to a `CaptionStyle` attribute (snake_case
436
+ * IDL). A field present in the input is written to every caption; a field ABSENT
437
+ * from the input is left untouched on each caption (the editor merges the patch
438
+ * onto each caption's existing style — this is a value edit, not a full-style
439
+ * replace, so a partial patch such as "recolor only" does not wipe font size).
440
+ *
441
+ * Pure document edit, no cascade — captions keep their positions; only the style
442
+ * sub-map of each caption part changes.
443
+ */
444
+ const setCaptionStyleInputSchema = z.object({
445
+ font_id: z.string().min(1).optional().describe("Font ID referencing a font from the font library"),
446
+ font_size: z.number().positive().optional().describe("Font size in points"),
447
+ font_color: z.string().min(1).optional().describe("Font color as hex string, e.g. \"#FFFFFF\""),
448
+ font_weight: z.number().int().optional().describe("Numeric font weight, e.g. 400 or 700"),
449
+ entrance_animation: z.string().optional().describe("Entrance animation preset ID, e.g. \"fade\" or \"none\""),
450
+ entrance_animation_duration_ms: z.number().min(0).optional().describe("Entrance animation duration in ms"),
451
+ stroke_color: z.string().min(1).optional().describe("Outline/stroke color as hex string, e.g. \"#000000\""),
452
+ stroke_width: z.number().min(0).optional().describe("Outline/stroke width in pixels"),
453
+ position_x: z.number().optional().describe("Caption center X as a fraction (0.0 to 1.0)"),
454
+ position_y: z.number().optional().describe("Caption center Y as a fraction (0.0 to 1.0)")
455
+ }).describe("Document-wide caption style patch (no caption_id; applies to every caption)");
456
+ //#endregion
457
+ //#region src/editor/schemas/set-caption-visibility.ts
458
+ /**
459
+ * Toggle caption visibility (the caption track's `is_hidden` flag). Pure
460
+ * document edit, no cascade — captions keep their positions; only the lane's
461
+ * hidden flag changes.
462
+ */
463
+ const setCaptionVisibilityInputSchema = z.object({ is_hidden: z.boolean().describe("Whether the caption track is hidden") });
464
+ //#endregion
465
+ //#region src/editor/schemas/set-video-clip-speed-shift.ts
466
+ /**
467
+ * Set the playback speed of existing video clips. Per the speed-shift decision
468
+ * (`reference/16` §0): the op writes only the `speed_shift` fact — it does NOT
469
+ * store an effective `duration_ms` (projection derives it from the trim window /
470
+ * speed) and does NOT scale anchored speeches' relative offsets (offsets stay
471
+ * put; the cascade reflows absolute positions). A `null` speed_shift clears the
472
+ * speed back to original (1×).
473
+ */
474
+ const setVideoClipSpeedShiftInputSchema = z.object({ clips: z.array(z.object({
475
+ clip_id: clipIdSchema.describe("The video clip part ID to set speed for"),
476
+ speed_shift: speedShiftSchema.nullable().describe("The new speed setting, or null to reset to 1×")
477
+ })).min(1).describe("Video clips with their new speed settings") });
478
+ //#endregion
479
+ //#region src/editor/schemas/index.ts
480
+ var schemas_exports = /* @__PURE__ */ __exportAll({
481
+ addSpeechesInputSchema: () => addSpeechesInputSchema,
482
+ addVideoClipsInputSchema: () => addVideoClipsInputSchema,
483
+ adjustBgmVolumeInputSchema: () => adjustBgmVolumeInputSchema,
484
+ adjustSpeechVolumeInputSchema: () => adjustSpeechVolumeInputSchema,
485
+ adjustVideoClipDurationInputSchema: () => adjustVideoClipDurationInputSchema,
486
+ adjustVideoClipVolumeInputSchema: () => adjustVideoClipVolumeInputSchema,
487
+ anchoredDeletePolicySchema: () => anchoredDeletePolicySchema,
488
+ anchoredReplacePolicySchema: () => anchoredReplacePolicySchema,
489
+ changeSpeechScriptInputSchema: () => changeSpeechScriptInputSchema,
490
+ changeSpeechVoiceInputSchema: () => changeSpeechVoiceInputSchema,
491
+ clipIdSchema: () => clipIdSchema,
492
+ clipIdsSchema: () => clipIdsSchema,
493
+ deleteBgmInputSchema: () => deleteBgmInputSchema,
494
+ deleteSpeechesInputSchema: () => deleteSpeechesInputSchema,
495
+ deleteVideoClipsInputSchema: () => deleteVideoClipsInputSchema,
496
+ mediaIdSchema: () => mediaIdSchema,
497
+ moveAnchorSchema: () => moveAnchorSchema,
498
+ moveSpeechesInputSchema: () => moveSpeechesInputSchema,
499
+ moveVideoClipsByAnchorInputSchema: () => moveVideoClipsByAnchorInputSchema,
500
+ moveVideoClipsInputSchema: () => moveVideoClipsInputSchema,
501
+ movedClipAnchoredPolicySchema: () => movedClipAnchoredPolicySchema,
502
+ positiveMsSchema: () => positiveMsSchema,
503
+ replaceVideoClipContentInputSchema: () => replaceVideoClipContentInputSchema,
504
+ replaceVideoClipSequenceInputSchema: () => replaceVideoClipSequenceInputSchema,
505
+ setBgmInputSchema: () => setBgmInputSchema,
506
+ setCaptionStyleInputSchema: () => setCaptionStyleInputSchema,
507
+ setCaptionVisibilityInputSchema: () => setCaptionVisibilityInputSchema,
508
+ setVideoClipSpeedShiftInputSchema: () => setVideoClipSpeedShiftInputSchema,
509
+ speechAssetsSchema: () => speechAssetsSchema,
510
+ speechIdSchema: () => speechIdSchema,
511
+ speechIdsSchema: () => speechIdsSchema,
512
+ speedShiftSchema: () => speedShiftSchema,
513
+ timelineMsSchema: () => timelineMsSchema,
514
+ voiceSchema: () => voiceSchema,
515
+ volumeSchema: () => volumeSchema
516
+ });
517
+ //#endregion
518
+ export { addSpeechesInputSchema, addVideoClipsInputSchema, adjustBgmVolumeInputSchema, adjustSpeechVolumeInputSchema, adjustVideoClipDurationInputSchema, adjustVideoClipVolumeInputSchema, anchoredDeletePolicySchema, anchoredReplacePolicySchema, changeSpeechScriptInputSchema, changeSpeechVoiceInputSchema, clipIdSchema, clipIdsSchema, deleteBgmInputSchema, deleteSpeechesInputSchema, deleteVideoClipsInputSchema, mediaIdSchema, moveAnchorSchema, moveSpeechesInputSchema, moveVideoClipsByAnchorInputSchema, moveVideoClipsInputSchema, movedClipAnchoredPolicySchema, positiveMsSchema, replaceVideoClipContentInputSchema, replaceVideoClipSequenceInputSchema, setBgmInputSchema, setCaptionStyleInputSchema, setCaptionVisibilityInputSchema, setVideoClipSpeedShiftInputSchema, speechAssetsSchema, speechIdSchema, speechIdsSchema, speedShiftSchema, schemas_exports as t, timelineMsSchema, voiceSchema, volumeSchema };
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as MirrorVideoDocumentAdapter, nt as VideoDraft } from "./index-DWVYLTjv.js";
1
+ import { c as MirrorVideoDocumentAdapter, ct as VideoDraft } from "./index-BO2fSUKi.js";
2
2
 
3
3
  //#region src/testing/in-memory-mengine-server.d.ts
4
4
  /**
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import { N as VIDEO_DOCUMENT_SCHEMA_VERSION, R as base64ToBytes, r as createMirrorVideoDocumentAdapter, z as bytesToBase64 } from "./document-C0o_cjAH.js";
1
+ import { L as VIDEO_DOCUMENT_SCHEMA_VERSION, U as base64ToBytes, W as bytesToBase64, o as createMirrorVideoDocumentAdapter } from "./document-49OdvviW.js";
2
2
  import { t as classifyUpdate } from "./loro-relay-doc-ssdYpuef.js";
3
3
  import { LoroDoc, VersionVector, encodeFrontiers } from "loro-crdt";
4
4
  //#region src/testing/in-memory-mengine-server.ts
@@ -36,6 +36,10 @@ var InMemoryMengineServer = class {
36
36
  if (path.startsWith("sync") && method === "GET") return this.handleSync(url);
37
37
  if (path === "updates" && method === "POST") return this.handlePush(init);
38
38
  if (path === "events" && method === "GET") return this.handleEvents(init);
39
+ if (path === "audit" && method === "GET") return Response.json({ entries: extractAllMeta(this.doc).map((meta, index) => ({
40
+ ...meta,
41
+ update_seq: index
42
+ })) });
39
43
  return new Response("not found", { status: 404 });
40
44
  };
41
45
  parsePath(url) {
@@ -218,6 +222,41 @@ function extractMeta(doc, baseVV) {
218
222
  frontiers
219
223
  };
220
224
  }
225
+ /** Mirror the real server audit: one deterministic entry per Loro Change. */
226
+ function extractAllMeta(doc) {
227
+ const json = doc.exportJsonUpdates(new VersionVector(/* @__PURE__ */ new Map()));
228
+ const parsed = typeof json === "string" ? JSON.parse(json) : json;
229
+ const peers = parsed.peers ?? [];
230
+ return (parsed.changes ?? []).map((change) => {
231
+ const [counterPart, peerPart] = change.id.split("@");
232
+ return {
233
+ peer: peers[Number(peerPart)] ?? peerPart ?? "0",
234
+ counter: Number(counterPart),
235
+ opsLen: change.ops?.length ?? 1,
236
+ lamport: change.lamport ?? 0,
237
+ timestamp: change.timestamp ?? 0,
238
+ message: change.msg ?? change.message ?? null
239
+ };
240
+ }).sort((a, b) => a.lamport - b.lamport || a.peer.localeCompare(b.peer)).map((change) => {
241
+ const { semantic_op, payload, intent, actor, parse_error } = parseMessage(change.message);
242
+ return {
243
+ semantic_op,
244
+ payload,
245
+ intent,
246
+ actor,
247
+ message: change.message,
248
+ parse_error,
249
+ peer: change.peer,
250
+ counter: change.counter,
251
+ lamport: change.lamport,
252
+ timestamp: change.timestamp,
253
+ frontiers: bytesToBase64(encodeFrontiers([{
254
+ peer: change.peer,
255
+ counter: change.counter + change.opsLen - 1
256
+ }]))
257
+ };
258
+ });
259
+ }
221
260
  /**
222
261
  * Mirrors `apps/mengine-server`'s `parseMessage` / `parseActor`. Kept in step
223
262
  * deliberately: this double is what harness tests push against, so a divergence
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mengine/medeo-client",
3
- "version": "1.2.0",
3
+ "version": "1.2.1-alpha.0",
4
4
  "license": "UNLICENSED",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,6 +15,7 @@
15
15
  "exports": {
16
16
  ".": "./dist/index.js",
17
17
  "./relay": "./dist/relay.js",
18
+ "./schemas": "./dist/schemas.js",
18
19
  "./testing": "./dist/testing.js",
19
20
  "./package.json": "./package.json"
20
21
  },
@@ -23,16 +24,18 @@
23
24
  "registry": "https://registry.npmjs.org/"
24
25
  },
25
26
  "dependencies": {
27
+ "immer": "^10.2.0",
26
28
  "loro-mirror": "^2.2.0",
27
29
  "zod": "^4.4.3",
28
- "@mengine/sync": "1.2.0",
29
- "@mengine/storage": "1.2.0",
30
- "@mengine/utils": "1.2.0"
30
+ "@mengine/storage": "1.2.1-alpha.0",
31
+ "@mengine/sync": "1.2.1-alpha.0",
32
+ "@mengine/utils": "1.2.1-alpha.0"
31
33
  },
32
34
  "devDependencies": {
33
35
  "@types/node": "^25.9.1",
34
36
  "@typescript/native-preview": "7.0.0-dev.20260521.1",
35
37
  "loro-crdt": "^1.13.6",
38
+ "tsx": "^4.22.3",
36
39
  "typescript": "^6.0.3",
37
40
  "vite-plugin-wasm": "^3.6.0",
38
41
  "vite-plus": "^0.1.23",