@mengine/medeo-client 1.2.1-alpha.2 → 1.2.1-alpha.4

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