@mengine/medeo-client 1.2.1-alpha.8 → 1.3.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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { t as index_d_exports } from "./index-CMa6ZCtX.js";
2
- import { $ as EntityId, A as generatePartId, At as CaptionPart$1, B as ResolvedEntityClipPlacement, C as PlannedSemanticOpKind, Ct as VideoDocumentValidationIssue, D as SnapshotReadable, Dt as effectiveVideoClipDurationMs, E as SchemaValidator, Et as VideoDraftPartUnion, F as videoDocumentMirrorSchema, Ft as Track$1, G as EntityTimelineProjectionError, H as ResolvedEntityTrack, I as VideoDocumentValidationError, It as TrackItem$1, J as JsonValue, K as EntityRelationRows, L as assertValidVideoDocument, M as TrackItemDraft, Mt as PartAggregation, N as VideoDocumentDraft, Nt as SpeedShift, O as ValidationError, Ot as speedOf, P as VideoDocumentMirrorSchema, Pt as Timeline$1, Q as VoiceDescriptor, R as validateVideoDocument, S as ImplementedSemanticOpKind, St as VideoDocumentSchemaVersion, T as isImplementedSemanticOpKind, Tt as VideoDraft, U as resolveEntityTimelineLayout, V as ResolvedEntityTimelineLayout, W as projectEntityTimeline, X as SequenceDuration, Y as CaptionStyleFields, Z as SequenceRange, _ as SemanticEditor, _t as TrackItem, a as PlainMemoryAdapter, at as derivePositionFromAbs, b as TransactAudit, bt as VideoClipPart, c as MirrorVideoDocumentAdapter, ct as BgmPart, d as createMirrorVideoDocument, dt as ENTITY_TIMELINE_PROJECTION_SCHEMA_VERSION, et as InitialDocumentFacts, f as createMirrorVideoDocumentAdapter, ft as PartKind, g as SemanticDocumentAdapter, gt as Track, h as OpActor, ht as Timeline, i as JournalEntry, it as buildSpeechHostMap, j as TrackDraft, jt as CaptionStyle, k as PartIdFactory, kt as Attachment, l as MirrorVideoDocumentOptions, lt as CaptionPart, m as CommitOptions, mt as SpeechPart, n as videoDocumentSchema, nt as DerivedItemPosition, o as PlainMemoryAdapterOptions, ot as fromVideoDocument, p as writeVideoDocumentToDraft, pt as PartUnion, q as JsonObject, r as readVideoDocumentFromDraft, rt as SpeechHostMap, s as createPlainMemoryAdapter, st as toVideoDocument, t as partUnionSchema, tt as buildInitialVideoDocument, u as applyEntityTimelineProjection, ut as DEFAULT_UNIT_TIME_MS, v as SemanticOpInput, vt as TrackItemTimePosition, w as SemanticOpKind, wt as VideoDocumentValidationIssueCode, x as IMPLEMENTED_SEMANTIC_OP_KINDS, xt as VideoDocument, y as SemanticOpName, yt as VIDEO_DOCUMENT_SCHEMA_VERSION, z as EntityTimelineTrackRole } from "./index-CbuWTReu.js";
1
+ import { $ as VideoDocumentSchemaVersion, A as assertValidVideoDocument, B as BgmPart, C as index_d_exports, D as VideoDocumentMirrorSchema, E as VideoDocumentDraft, F as SpeechHostMap, G as SpeechPart, H as DEFAULT_UNIT_TIME_MS, I as buildSpeechHostMap, J as TrackItem, K as Timeline, L as derivePositionFromAbs, M as InitialDocumentFacts, N as buildInitialVideoDocument, O as videoDocumentMirrorSchema, P as DerivedItemPosition, Q as VideoDocument, R as fromVideoDocument, S as ValidationError, T as TrackItemDraft, U as PartKind, V as CaptionPart, W as PartUnion, X as VIDEO_DOCUMENT_SCHEMA_VERSION, Y as TrackItemTimePosition, Z as VideoClipPart, _ as PlannedSemanticOpKind, a as MirrorVideoDocumentOptions, at as CaptionPart$1, b as SchemaValidator, c as CommitOptions, ct as SpeedShift, d as SemanticEditor, dt as TrackItem$1, et as VideoDocumentValidationIssue, f as SemanticOpInput, g as ImplementedSemanticOpKind, h as IMPLEMENTED_SEMANTIC_OP_KINDS, i as MirrorVideoDocumentAdapter, it as Attachment, j as validateVideoDocument, k as VideoDocumentValidationError, l as OpActor, lt as Timeline$1, m as TransactAudit, n as videoDocumentSchema, nt as VideoDraft, o as createMirrorVideoDocument, ot as CaptionStyle, p as SemanticOpName, q as Track, r as readVideoDocumentFromDraft, rt as VideoDraftPartUnion, s as createMirrorVideoDocumentAdapter, st as PartAggregation, t as partUnionSchema, tt as VideoDocumentValidationIssueCode, u as SemanticDocumentAdapter, ut as Track$1, v as SemanticOpKind, w as TrackDraft, x as SnapshotReadable, y as isImplementedSemanticOpKind, z as toVideoDocument } from "./index-DWVYLTjv.js";
3
2
  import { PeerID } from "loro-crdt";
4
3
  import { DocState } from "@mengine/sync";
5
4
  import { BaseDocStorage, Connection, DocDiff, DocPushReceipt, DocSnapshotRecord, DocStorage, DocStorageOptions, DocUpdate, DocUpdateRecord } from "@mengine/storage";
@@ -178,361 +177,33 @@ interface MengineEventStreamOptions {
178
177
  }
179
178
  declare function readMengineEventStream(options: MengineEventStreamOptions): Promise<void>;
180
179
  //#endregion
181
- //#region src/entity-editor/entity-graph-http-client.d.ts
182
- /** One authenticated revision of the authoritative Medeo Entity graph. */
183
- interface EntityGraphState {
184
- readonly revision: number;
185
- readonly rows: EntityRelationRows;
186
- }
187
- interface EntityGraphCommitOptions {
188
- /** Server version vector proving the explicit legacy-to-Entity migration baseline. */
189
- readonly migrationBaseVv?: string;
190
- }
191
- /** Browser-safe authenticated CAS client for a document's Entity graph. */
192
- declare class EntityGraphHttpClient {
193
- private readonly options;
194
- private readonly transport;
195
- private readonly endpoint;
196
- constructor(options: MengineHttpClientOptions);
197
- fetchState(): Promise<EntityGraphState>;
198
- /**
199
- * Replace the complete Entity graph under the baseline revision.
200
- *
201
- * Deletion intent is derived from baseline IDs omitted from `nextRows`, so a
202
- * transient create-then-remove never becomes a request to delete unknown
203
- * persisted data.
204
- */
205
- commit(baseState: EntityGraphState, nextRows: EntityRelationRows, options?: EntityGraphCommitOptions): Promise<EntityGraphState>;
206
- private request;
207
- }
208
- //#endregion
209
- //#region src/entity-editor/types.d.ts
210
- /** Injectable domain-id mint shared by Entity and Relation authoring surfaces. */
211
- type EntityTimelineIdFactory = (prefix: 'entity' | 'relation') => string;
212
- interface ImageMediaAssetFact {
213
- readonly assetId: string;
214
- readonly kind: 'image';
215
- readonly storageKey?: string;
216
- }
217
- interface VideoMediaAssetFact {
218
- readonly assetId: string;
219
- readonly kind: 'video';
220
- readonly durationMs: number;
221
- readonly storageKey?: string;
222
- }
223
- interface AudioMediaAssetFact {
224
- readonly assetId: string;
225
- readonly kind: 'audio';
226
- readonly durationMs: number;
227
- readonly storageKey: string;
228
- }
229
- interface VoiceMediaAssetFact {
230
- /** Stable external speech result id, independent of the placed Clip id. */
231
- readonly assetId: string;
232
- readonly kind: 'voice';
233
- readonly durationMs: number;
234
- readonly storageKey: string;
235
- readonly voice: VoiceDescriptor;
236
- }
237
- /** Facts resolved from media storage. A trim window never substitutes for intrinsic duration. */
238
- type MediaAssetFact = ImageMediaAssetFact | VideoMediaAssetFact | AudioMediaAssetFact | VoiceMediaAssetFact;
239
- type ClipPlacement = {
240
- readonly kind: 'sequential';
241
- readonly order: number;
242
- } | {
243
- readonly kind: 'absolute';
244
- readonly targetRange: SequenceRange<number>;
245
- } | {
246
- readonly kind: 'anchored';
247
- readonly hostClipEntityId: string;
248
- readonly anchorOffset: number;
249
- };
250
- interface InsertPlacedClipInput {
251
- readonly trackEntityId: string;
252
- readonly contentEntityId: string;
253
- readonly sourceRange: SequenceRange<number>;
254
- readonly duration: SequenceDuration<number>;
255
- readonly placement: ClipPlacement;
256
- readonly clipPayload?: JsonObject;
257
- /** Stable caller-owned placement identity, when one already exists outside the graph. */
258
- readonly clipEntityId?: string;
259
- }
260
- interface SetClipPlacementInput {
261
- readonly clipEntityId: string;
262
- readonly placement: ClipPlacement;
263
- }
264
- type SequentialClipAnchor = {
265
- readonly position: 'before' | 'after';
266
- readonly clipEntityId: string;
267
- } | {
268
- readonly position: 'trackStart';
269
- };
270
- interface MoveSequentialClipsInput {
271
- readonly clipEntityIds: readonly string[];
272
- readonly anchor: SequentialClipAnchor;
273
- readonly onAnchored: 'follow' | 'keepAbsolute';
274
- }
275
- interface MoveClipsToStartsInput {
276
- readonly moves: readonly {
277
- readonly clipEntityId: string;
278
- readonly newStartMs: number;
279
- }[];
280
- /** Absolute-time drags preserve every voiceover's current visible landing. */
281
- readonly onAnchored: 'keepAbsolute';
282
- }
283
- interface DeleteClipTreeInput {
284
- readonly clipEntityIds: readonly string[];
285
- readonly onAnchored: 'cascade' | 'detach';
286
- }
287
- interface VoiceoverCaptionFact {
288
- /** Stable placed caption identity supplied by the materialized side effect. */
289
- readonly captionClipEntityId: string;
290
- readonly text: string;
291
- readonly startMs: number;
292
- readonly durationMs: number;
293
- readonly style?: CaptionStyleFields;
294
- }
295
- interface VoiceoverTakeInput {
296
- readonly timelineEntityId: string;
297
- /** Stable placed speech identity, distinct from media.assetId. */
298
- readonly voiceoverClipEntityId: string;
299
- readonly hostClipEntityId: string;
300
- readonly anchorOffset: number;
301
- readonly media: VoiceMediaAssetFact;
302
- /** Complete spoken text; the editor owns the deterministic local script segment identity. */
303
- readonly scriptText: string;
304
- readonly volume: number;
305
- readonly captions: readonly VoiceoverCaptionFact[];
306
- }
307
- type VisualMediaAssetFact = ImageMediaAssetFact | VideoMediaAssetFact;
308
- interface InsertMediaClipInput {
309
- readonly timelineEntityId: string;
310
- readonly clipEntityId?: string;
311
- readonly media: VisualMediaAssetFact;
312
- /** Source/display window in whole milliseconds. Images use this as their finite display span. */
313
- readonly sourceRange: SequenceRange<number>;
314
- readonly placement: ClipPlacement;
315
- readonly volume?: number;
316
- }
317
- interface ReplaceMediaClipInput {
318
- readonly clipEntityId: string;
319
- readonly media: VisualMediaAssetFact;
320
- readonly sourceRange: SequenceRange<number>;
321
- }
322
- interface ReplacementMediaClipInput {
323
- readonly clipEntityId?: string;
324
- readonly media: VisualMediaAssetFact;
325
- readonly sourceRange: SequenceRange<number>;
326
- readonly volume?: number;
327
- }
328
- type MediaClipInsertion = {
329
- readonly kind: 'before';
330
- readonly clipEntityId: string;
331
- } | {
332
- readonly kind: 'after';
333
- readonly clipEntityId: string;
334
- } | {
335
- readonly kind: 'firstStart';
336
- readonly startMs: number;
337
- };
338
- interface InsertMediaClipsInput {
339
- readonly timelineEntityId: string;
340
- readonly clips: readonly ReplacementMediaClipInput[];
341
- /** One placement decision for the whole input-ordered block. */
342
- readonly insertion: MediaClipInsertion;
343
- }
344
- interface ReplaceSequentialClipsInput {
345
- readonly timelineEntityId: string;
346
- readonly oldClipEntityIds: readonly string[];
347
- readonly newClips: readonly ReplacementMediaClipInput[];
348
- readonly onAnchored: 'remap' | 'cascade';
349
- }
350
- interface SetClipVolumeInput {
351
- readonly clipEntityId: string;
352
- /** Playback gain in decibels. */
353
- readonly volume: number;
354
- }
355
- interface LinearClipSpeed {
356
- readonly kind: 'linear';
357
- readonly rate: number;
358
- readonly mode?: string;
359
- }
360
- interface SetClipSpeedInput {
361
- readonly clipEntityId: string;
362
- readonly timeRemapping: LinearClipSpeed | null;
363
- }
364
- interface TrimClipInput {
365
- readonly clipEntityId: string;
366
- readonly sourceRange: SequenceRange<number>;
367
- }
368
- interface VoiceoverTakeResult {
369
- readonly voiceoverClipEntityId: string;
370
- readonly voiceEntityId: string;
371
- readonly audioScriptEntityId: string;
372
- readonly captionClipEntityIds: readonly string[];
373
- }
374
- interface MoveVoiceoverInput {
375
- readonly voiceoverClipEntityId: string;
376
- /** Absolute requested timeline start; MEngine resolves and persists the host relation. */
377
- readonly newStartMs: number;
378
- }
379
- interface DeleteVoiceoverInput {
380
- readonly voiceoverClipEntityIds: readonly string[];
381
- }
382
- interface SetBgmInput {
383
- readonly timelineEntityId: string;
384
- readonly bgmClipEntityId: string;
385
- readonly media: AudioMediaAssetFact;
386
- readonly volume: number;
387
- }
388
- interface DeleteBgmInput {
389
- readonly timelineEntityId: string;
390
- }
391
- interface SetCaptionVisibilityInput {
392
- readonly timelineEntityId: string;
393
- readonly hidden: boolean;
394
- }
395
- interface PatchCaptionStyleInput {
396
- readonly timelineEntityId: string;
397
- readonly style: CaptionStyleFields;
398
- }
399
- interface InsertClipInput {
400
- readonly trackEntityId: string;
401
- /** Existing Sequence media Entity id. Asset ids and URLs are not content ids. */
402
- readonly contentEntityId: string;
403
- readonly sourceRange: SequenceRange<number>;
404
- readonly duration: SequenceDuration<number>;
405
- readonly targetRange?: SequenceRange<number>;
406
- readonly clipPayload?: JsonObject;
407
- }
408
- interface UpdateClipMarkerInput {
409
- readonly clipEntityId: string;
410
- readonly sourceRange?: SequenceRange<number>;
411
- /** Passing `undefined` explicitly removes the optional target range. */
412
- readonly targetRange?: SequenceRange<number> | undefined;
413
- readonly duration?: SequenceDuration<number>;
414
- /** Passing `undefined` explicitly removes the optional remapping value. */
415
- readonly timeRemapping?: JsonValue | undefined;
416
- }
417
- interface MoveClipInput {
418
- readonly clipEntityId: string;
419
- readonly trackEntityId: string;
420
- }
421
- interface ReplaceClipContentInput {
422
- readonly clipEntityId: string;
423
- /** Existing Sequence media Entity id. Asset ids and URLs are not content ids. */
424
- readonly contentEntityId: string;
425
- readonly sourceRange: SequenceRange<number>;
426
- readonly duration: SequenceDuration<number>;
427
- readonly targetRange?: SequenceRange<number>;
428
- readonly timeRemapping?: JsonValue;
429
- }
430
- interface DeleteClipInput {
431
- readonly clipEntityId: string;
432
- }
433
- interface UpdateClipInput {
434
- readonly clipEntityId: string;
435
- /** Complete replacement for the Clip-owned payload. */
436
- readonly payload: JsonObject;
437
- }
438
- type ClipEntityId = EntityId;
439
- //#endregion
440
- //#region src/entity-editor/entity-timeline-editor.d.ts
180
+ //#region src/editor/id-gen.d.ts
441
181
  /**
442
- * Graph-native timeline authoring over authoritative Medeo Entity and Relation rows.
182
+ * Part-id generation, aligned with the online ecosystem.
443
183
  *
444
- * Each mutation is applied to a detached graph, validated as a complete DSL set,
445
- * and committed only after validation succeeds.
446
- */
447
- declare class EntityTimelineEditor {
448
- private readonly idFactory;
449
- private state;
450
- constructor(initialRows: EntityRelationRows, idFactory?: EntityTimelineIdFactory);
451
- rows(): EntityRelationRows;
452
- insertClip(input: InsertClipInput): ClipEntityId;
453
- insertPlacedClip(input: InsertPlacedClipInput): ClipEntityId;
454
- updateClipMarker(input: UpdateClipMarkerInput): void;
455
- setClipPlacement(input: SetClipPlacementInput): void;
456
- moveSequentialClips(input: MoveSequentialClipsInput): void;
457
- moveClipsToStarts(input: MoveClipsToStartsInput): void;
458
- moveClip(input: MoveClipInput): void;
459
- replaceClipContent(input: ReplaceClipContentInput): void;
460
- insertMediaClip(input: InsertMediaClipInput): ClipEntityId;
461
- insertMediaClips(input: InsertMediaClipsInput): readonly ClipEntityId[];
462
- replaceMediaClip(input: ReplaceMediaClipInput): void;
463
- setClipVolume(input: SetClipVolumeInput): void;
464
- setClipSpeed(input: SetClipSpeedInput): void;
465
- trimClip(input: TrimClipInput): void;
466
- replaceSequentialClips(input: ReplaceSequentialClipsInput): readonly ClipEntityId[];
467
- deleteClip(input: DeleteClipInput): void;
468
- deleteClipTree(input: DeleteClipTreeInput): void;
469
- updateClip(input: UpdateClipInput): void;
470
- upsertVoiceoverTake(input: VoiceoverTakeInput): VoiceoverTakeResult;
471
- moveVoiceover(input: MoveVoiceoverInput): void;
472
- deleteVoiceover(input: DeleteVoiceoverInput): void;
473
- setBgm(input: SetBgmInput): ClipEntityId;
474
- deleteBgm(input: DeleteBgmInput): void;
475
- setCaptionVisibility(input: SetCaptionVisibilityInput): void;
476
- patchCaptionStyle(input: PatchCaptionStyleInput): void;
477
- private insertPlacedClipIntoDraft;
478
- private ensureRoleTrack;
479
- private ensureAudioScript;
480
- private reconcileVoiceoverCaptions;
481
- private ensureRoleTrackForClip;
482
- private replaceCaptionSemanticRelations;
483
- private removeCaptionClipGraph;
484
- private replaceAnchorHost;
485
- /** Rebuild the legacy edit baseline from current visual order before a high-level cascade. */
486
- private normalizeMainSequential;
487
- private resolveOneVoiceoverOverlap;
488
- private applyClipPlacement;
489
- private reanchorAtAbsolute;
490
- private removeAnchoredDescendants;
491
- private removeClipGraph;
492
- private transact;
493
- private mintEntityId;
494
- private createRelation;
495
- private relinkRelation;
496
- private mintRelationId;
497
- }
498
- //#endregion
499
- //#region src/entity-editor/media-asset-import.d.ts
500
- interface ImportedMediaAsset {
501
- readonly rows: EntityRelationRows;
502
- readonly assetEntityId: string;
503
- readonly contentEntityId: string;
504
- }
505
- /** Disambiguates a valid many-to-many graph; absence never licenses an arbitrary choice. */
506
- interface MediaAssetSelection {
507
- readonly assetEntityId?: string;
508
- readonly contentEntityId?: string;
509
- }
510
- /** Import at the editor boundary, not at asset generation time. Existing provenance is retained. */
511
- declare function importMediaAsset(initial: EntityRelationRows, fact: MediaAssetFact, idFactory?: EntityTimelineIdFactory, selection?: MediaAssetSelection): ImportedMediaAsset;
512
- //#endregion
513
- //#region src/entity-editor/legacy-entity-migration.d.ts
514
- /** One-time import only. Ordinary editor operations must never reverse-diff a legacy document. */
515
- declare function migrateLegacyTimelineToEntities(legacy: VideoDocument, assetFacts: readonly MediaAssetFact[], initial?: EntityRelationRows, idFactory?: EntityTimelineIdFactory): EntityRelationRows;
516
- /** Server gate: a cutover may change representation, never the existing render facts. */
517
- declare function assertEntityProjectionPreservesLegacy(legacy: VideoDocument, projection: VideoDocument, rows: EntityRelationRows): void;
518
- //#endregion
519
- //#region src/editor/journal.d.ts
520
- /**
521
- * Wire a plain-memory adapter + editor that share a recording id factory, so
522
- * every mutating transact lands in `journal` with ordered `generated_ids`.
184
+ * The authoritative online producers — agent-harness (`@harness/shared`
185
+ * `genObjId`) and director.v2 (`common/obj_id.py` `gen_obj_id`) — both mint part
186
+ * ids as `` `${prefix}_${ulid()}` ``, and real captured drafts use exactly that
187
+ * shape (`clip_…` / `spe_…` / `cap_…` / `bgm_…`, each a 26-char ULID). The engine
188
+ * previously emitted `vc_<base36 timestamp><6 random>`, a different prefix AND a
189
+ * different encoding — the sole cross-repo id divergence. This module removes it
190
+ * by emitting the same `<prefix>_<ULID>` bytes.
191
+ *
192
+ * The ULID is generated inline (Crockford Base32, 48-bit time + 80-bit random)
193
+ * rather than pulling the `ulid` npm package: the randomness class matches the
194
+ * old generator (both `Math.random`-based) and it keeps `@mengine/medeo-client`
195
+ * dependency-free for a purely mechanical id string. Part ids only need to be
196
+ * unique and lexicographically time-sortable, which this satisfies.
523
197
  */
524
- declare function createEditSandbox(document: VideoDocument, options?: PlainMemoryAdapterOptions): {
525
- adapter: PlainMemoryAdapter;
526
- editor: SemanticEditor;
527
- journal: readonly JournalEntry[];
528
- };
529
198
  /**
530
- * Re-drive `doc` from a recorded journal, forcing each entry's `generated_ids`
531
- * through a queue-backed id factory. Never mints fresh ids: an empty queue on
532
- * demand throws `unrecorded id`; leftover ids after an entry throws
533
- * `unconsumed ids`. Legacy entries without `generated_ids` are treated as `[]`.
199
+ * Online part-id semantic prefixes. `clip` (video clip) is the only value the
200
+ * engine currently mints (see `addVideoClips`); the rest are declared so the
201
+ * type documents the shared vocabulary and guards against reintroducing the old
202
+ * `vc`/`sp`/`cp`/`bg` names. Speech/caption/bgm ids arrive pre-minted in op
203
+ * payloads, so the engine never generates them itself.
534
204
  */
535
- declare function replayJournal(doc: SemanticDocumentAdapter, journal: readonly JournalEntry[]): Promise<void>;
205
+ type PartIdPrefix = 'clip' | 'spe' | 'cap' | 'bgm' | 'ti';
206
+ declare function generatePartId(prefix: PartIdPrefix): string;
536
207
  //#endregion
537
208
  //#region src/editor/snapshot-utils.d.ts
538
209
  /** Main-track item identity read from a raw snapshot (only `part_id` is needed). */
@@ -625,7 +296,9 @@ type PushResultKind = 'ack' | 'duplicate' | 'rejected' | 'failed' | 'nothing_to_
625
296
  */
626
297
  interface PushResult {
627
298
  kind: PushResultKind;
628
- /** Server-allocated sequence number; only present for `ack`. */
299
+ /** Server document sequence observed after a successful `ack` or `duplicate`. */
300
+ mengineUpdateSeq?: number | undefined;
301
+ /** @deprecated Ack-only sequence retained until consumers adopt `mengineUpdateSeq`. */
629
302
  updateSeq?: number | undefined;
630
303
  /** Whether the server held ops the local document lacked. See above. */
631
304
  collaborated: boolean;
@@ -751,16 +424,6 @@ declare class ManualSyncDoc {
751
424
  editorPeerId(): PeerID;
752
425
  /** Current document projected to the legacy `VideoDraft` read shape. */
753
426
  draft(): VideoDraft;
754
- /**
755
- * Replay a deterministic sandbox journal into this document.
756
- *
757
- * The adapter stays private so callers cannot bypass the manual-sync
758
- * lifecycle; journal replay is the one host-side operation that needs the
759
- * adapter's transaction boundary and recorded id queue. Durability is still
760
- * explicit: call {@link push} after replay and report success only from its
761
- * verdict.
762
- */
763
- replayJournal(journal: readonly JournalEntry[]): Promise<void>;
764
427
  /**
765
428
  * Mark the document state the caller has just observed, for a later
766
429
  * {@link hasChangedSince}.
@@ -914,6 +577,9 @@ declare class MedeoHttpDocStorage implements DocStorage {
914
577
  * tool-level ack wait) subscribe here.
915
578
  */
916
579
  subscribePushOutcome(callback: (outcome: PushOutcome) => void): () => void;
580
+ /** Authoritative HTTP reads and accepted pushes, never inferred from SSE bytes. */
581
+ subscribeServerVersion(callback: (version: Uint8Array) => void): () => void;
582
+ private reportServerVersion;
917
583
  deleteDoc(_docId: string): Promise<void>;
918
584
  subscribeDocUpdate(callback: (update: DocUpdate, origin: unknown) => void): () => void;
919
585
  private assertDocId;
@@ -962,6 +628,14 @@ interface WaitForServerAckOptions {
962
628
  /** Deadline in ms. Rejects with reason `timeout` when it elapses. */
963
629
  timeoutMs?: number;
964
630
  }
631
+ /** Document-level confirmation is independent of local operation completion. */
632
+ interface MengineDocSyncState {
633
+ /** Remote-only imports do not create a new local confirmation obligation. */
634
+ readonly confirmation: 'unknown' | 'pending' | 'confirmed';
635
+ /** Transport/activity phase. Idle does not imply confirmation; failure details
636
+ * remain available through push outcomes and confirmation wait errors. */
637
+ readonly phase: 'connecting' | 'idle' | 'syncing' | 'offline' | 'failed';
638
+ }
965
639
  interface MengineDocSessionOptions {
966
640
  docId: string;
967
641
  client: MengineHttpClient;
@@ -972,11 +646,6 @@ interface MengineDocSessionOptions {
972
646
  */
973
647
  localStorage?: DocStorageLike;
974
648
  sseReconnectDelayMs?: number;
975
- /**
976
- * Keep remote synchronization read-only: pull snapshot/diffs and subscribe to
977
- * SSE updates, but never POST local Loro updates to the server.
978
- */
979
- readonlyMode?: boolean;
980
649
  }
981
650
  /**
982
651
  * A live editing session for one Medeo document — the single entry point clients
@@ -1012,8 +681,14 @@ declare class MengineDocSession {
1012
681
  private adapterValue;
1013
682
  private editorValue;
1014
683
  private started;
684
+ private destroyed;
685
+ private lifetime;
686
+ private hasConnected;
687
+ private initialVersionValue;
688
+ private localVersionValue;
689
+ private pushErrorValue;
1015
690
  /**
1016
- * Latest server oplog version seen on a push outcome. Lets `waitForServerAck`
691
+ * Latest server oplog version seen on an authoritative HTTP response. Lets `waitForServerAck`
1017
692
  * return without waiting when the server is already known to cover the local
1018
693
  * doc (e.g. nothing was edited since the last confirmed push).
1019
694
  */
@@ -1028,14 +703,14 @@ declare class MengineDocSession {
1028
703
  */
1029
704
  subscribePushOutcome(callback: (outcome: PushOutcome) => void): () => void;
1030
705
  /**
1031
- * Resolve once the server has durably accepted the local document state as of
706
+ * Resolve once the server has durably accepted the local commits as of
1032
707
  * *now* — the capability an Agent tool needs to answer "did my edit land?"
1033
708
  * before reporting success.
1034
709
  *
1035
710
  * Call it right after the editor ops whose durability matters. It snapshots the
1036
- * local doc's current version and resolves on the first push outcome whose
1037
- * `serverVV` covers that version, i.e. the server log is at least as advanced as
1038
- * the local doc was when this was called.
711
+ * latest local commit's version (or the loaded baseline before any edit) and
712
+ * resolves when an authoritative server version covers it. Remote-only
713
+ * imports do not extend this target, matching the displayed confirmation state.
1039
714
  *
1040
715
  * Version coverage, not byte identity, is the acceptance test — for two reasons:
1041
716
  * the ops may reach the server inside a merged blob rather than as the exact
@@ -1057,18 +732,6 @@ declare class MengineDocSession {
1057
732
  * step. The committed change drives DocManager's local-update push.
1058
733
  */
1059
734
  get editor(): SemanticEditor;
1060
- /**
1061
- * Opaque version token of the local oplog (base64 `VersionVector.encode`).
1062
- * Equality-comparable only: equal means no observed change (local or
1063
- * remote-arrived) since the token was taken. Throws when not started.
1064
- */
1065
- version(): string;
1066
- /**
1067
- * The live document adapter, exposed for journal replay (commit channel).
1068
- * Replaying through it still goes SemanticEditor → Loro → mengine-server —
1069
- * no write bypass. Typed by the narrow interface on purpose.
1070
- */
1071
- get documentAdapter(): SemanticDocumentAdapter;
1072
735
  /** Current document snapshot (read model). */
1073
736
  snapshot(): VideoDocument;
1074
737
  /**
@@ -1079,6 +742,11 @@ declare class MengineDocSession {
1079
742
  * surfaces through `subscribe`.
1080
743
  */
1081
744
  start(): Promise<VideoDocument>;
745
+ getSyncState(): MengineDocSyncState;
746
+ private confirmationTarget;
747
+ /** Immediately supplies current state; unsubscribe when the host changes docs. */
748
+ subscribeSyncState(cb: (state: MengineDocSyncState) => void): () => void;
749
+ private emitSyncState;
1082
750
  subscribe(cb: (event: MengineDocSessionUpdateEvent) => void): () => void;
1083
751
  onStateChange(cb: (state: DocState) => void): () => void;
1084
752
  getState(): DocState;
@@ -1420,4 +1088,4 @@ declare function hostForAbsMs(ranges: MainClipRange[], absMs: number): MainClipR
1420
1088
  */
1421
1089
  declare function relativePositionForAbs(ranges: MainClipRange[], absMs: number): TrackItemTimePosition;
1422
1090
  //#endregion
1423
- export { type Aggregation, type Attachment, type AudioMediaAssetFact, type BgmPart, type CaptionPart, type CaptionStyle, type ClipEntityId, type ClipPlacement, type CommitOptions, DEFAULT_UNIT_TIME_MS, type DeleteBgmInput, type DeleteClipInput, type DeleteClipTreeInput, type DeleteVoiceoverInput, type DerivedItemPosition, type DocStorageLike, type DocVersionMark, ENTITY_TIMELINE_PROJECTION_SCHEMA_VERSION, type EntityGraphCommitOptions, EntityGraphHttpClient, type EntityGraphState, EntityTimelineEditor, type EntityTimelineIdFactory, EntityTimelineProjectionError, type EntityTimelineTrackRole, IMPLEMENTED_SEMANTIC_OP_KINDS, type ImageMediaAssetFact, type ImplementedSemanticOpKind, type ImportedMediaAsset, type InitialDocumentFacts, type InsertClipInput, type InsertMediaClipInput, type InsertMediaClipsInput, type InsertPlacedClipInput, type JournalEntry, LANE_KINDS_IN_STACK_ORDER, type LaneKind, type LinearClipSpeed, type MainClipRange, type MakeEmptyPart, ManualSyncDoc, type ManualSyncDocOptions, MedeoHttpDocStorage, type MedeoHttpDocStorageOptions, type MediaAssetFact, type MediaAssetSelection, type MediaClipInsertion, MemoryDocStorage, MengineAckFailedError, type MengineAuditEntry, type MengineAuditResponse, MengineDocSession, type MengineDocSessionOptions, type MengineDocSessionUpdateEvent, type MengineDocumentVersion, type MengineEventStreamOptions, MengineHttpClient, type MengineHttpClientOptions, MengineHttpRequestError, MenginePushRejectedError, type MenginePushResponse, type MenginePushUpdateResponse, type MengineRejectedResponse, type MengineSnapshotResponse, type MengineSseUpdateEvent, type MengineSyncResponse, type MengineUpdateMeta, MirrorVideoDocumentAdapter, type MirrorVideoDocumentOptions, type MoveClipInput, type MoveClipsToStartsInput, type MoveSequentialClipsInput, type MoveVoiceoverInput, type OpActor, type PartAggregation, type PartIdFactory, type PartKind, type PartUnion, type PatchCaptionStyleInput, PlainMemoryAdapter, type PlainMemoryAdapterOptions, type PlannedSemanticOpKind, type PullFailureReason, type PullResult, type PushOutcome, type PushOutcomeKind, type PushResult, type PushResultKind, type ReplaceClipContentInput, type ReplaceMediaClipInput, type ReplaceSequentialClipsInput, type ReplacementMediaClipInput, type ResolvedEntityClipPlacement, type ResolvedEntityTimelineLayout, type ResolvedEntityTrack, SchemaValidator, type SemanticDocumentAdapter, SemanticEditor, type SemanticOpInput, type SemanticOpKind, type SemanticOpName, type SequentialClipAnchor, type SetBgmInput, type SetCaptionVisibilityInput, type SetClipPlacementInput, type SetClipSpeedInput, type SetClipVolumeInput, type SnapshotReadable, type SolvedVideoDocument, type SpeechHostMap, type SpeechPart, type SpeedShift, TIMELINE_SKELETON_DURATION_MS, type Timeline, type TimelineDoc, type TimelineItem, type Track, type TrackDraft, type TrackItem, type TrackItemDraft, type TrackItemTimePosition, type TransactAudit, type TrimClipInput, type UpdateClipInput, type UpdateClipMarkerInput, VIDEO_DOCUMENT_SCHEMA_VERSION, ValidationError, type VideoClipPart, type VideoDocument, type VideoDocumentDraft, type VideoDocumentMirrorSchema, type VideoDocumentSchemaVersion, VideoDocumentValidationError, type VideoDocumentValidationIssue, type VideoDocumentValidationIssueCode, type VideoDraft, type CaptionPart$1 as VideoDraftCaptionPart, type VideoDraftPartUnion, type Timeline$1 as VideoDraftTimeline, type Track$1 as VideoDraftTrack, type TrackItem$1 as VideoDraftTrackItem, type VideoMediaAssetFact, type VisualMediaAssetFact, type VoiceMediaAssetFact, type VoiceoverCaptionFact, type VoiceoverTakeInput, type VoiceoverTakeResult, type WaitForServerAckOptions, applyEntityTimelineProjection, arrangeMainTrackSeamlessly, assertEntityProjectionPreservesLegacy, assertValidVideoDocument, base64ToBytes, buildInitialVideoDocument, buildSpeechHostMap, bytesToBase64, cascadeAfterVideoClipChanges, createEditSandbox, createMirrorVideoDocument, createMirrorVideoDocumentAdapter, createPlainMemoryAdapter, decodeDocVersionMark, derivePositionFromAbs, effectiveVideoClipDurationMs, encodeDocVersionMark, ensureLaneTrack, fillMainTrackTimeGaps, findLaneTrack, fromVideoDocument, generatePartId, getAt, hostForAbsMs, importMediaAsset, isEmptyVideoClip, isImplementedSemanticOpKind, isMap, laneTrackId, mainTrackRanges, migrateLegacyTimelineToEntities, partDurationMs, partUnionSchema, projectEntityTimeline, readMainTrackItems, readMengineEventStream, readPart, readPartDurationMs, readVideoDocumentFromDraft, reassignSpeechesToVideoClipsByTime, recalculateTimelineDuration, relativePositionForAbs, replayJournal, resolveAllSpeechOverlaps, resolveEntityTimelineLayout, resolveSpeechOverlapByShiftingVideos, safeDurationMs, index_d_exports as schemas, snapshotToPlain, solveVideoDocument, speedOf, syncAggregatedClipsTimePosition, toVideoDocument, validateVideoDocument, videoDocumentMirrorSchema, videoDocumentSchema, writeVideoDocumentToDraft };
1091
+ export { type Aggregation, type Attachment, type BgmPart, type CaptionPart, type CaptionStyle, type CommitOptions, DEFAULT_UNIT_TIME_MS, type DerivedItemPosition, type DocStorageLike, type DocVersionMark, IMPLEMENTED_SEMANTIC_OP_KINDS, type ImplementedSemanticOpKind, type InitialDocumentFacts, LANE_KINDS_IN_STACK_ORDER, type LaneKind, type MainClipRange, type MakeEmptyPart, ManualSyncDoc, type ManualSyncDocOptions, MedeoHttpDocStorage, type MedeoHttpDocStorageOptions, MemoryDocStorage, MengineAckFailedError, type MengineAuditEntry, type MengineAuditResponse, MengineDocSession, type MengineDocSessionOptions, type MengineDocSessionUpdateEvent, type MengineDocSyncState, type MengineDocumentVersion, type MengineEventStreamOptions, MengineHttpClient, type MengineHttpClientOptions, MengineHttpRequestError, MenginePushRejectedError, type MenginePushResponse, type MenginePushUpdateResponse, type MengineRejectedResponse, type MengineSnapshotResponse, type MengineSseUpdateEvent, type MengineSyncResponse, type MengineUpdateMeta, MirrorVideoDocumentAdapter, type MirrorVideoDocumentOptions, type OpActor, type PartAggregation, type PartKind, type PartUnion, type PlannedSemanticOpKind, type PullFailureReason, type PullResult, type PushOutcome, type PushOutcomeKind, type PushResult, type PushResultKind, SchemaValidator, type SemanticDocumentAdapter, SemanticEditor, type SemanticOpInput, type SemanticOpKind, type SemanticOpName, type SnapshotReadable, type SolvedVideoDocument, type SpeechHostMap, type SpeechPart, type SpeedShift, TIMELINE_SKELETON_DURATION_MS, type Timeline, type TimelineDoc, type TimelineItem, type Track, type TrackDraft, type TrackItem, type TrackItemDraft, type TrackItemTimePosition, type TransactAudit, VIDEO_DOCUMENT_SCHEMA_VERSION, ValidationError, type VideoClipPart, type VideoDocument, type VideoDocumentDraft, type VideoDocumentMirrorSchema, type VideoDocumentSchemaVersion, VideoDocumentValidationError, type VideoDocumentValidationIssue, type VideoDocumentValidationIssueCode, type VideoDraft, type CaptionPart$1 as VideoDraftCaptionPart, type VideoDraftPartUnion, type Timeline$1 as VideoDraftTimeline, type Track$1 as VideoDraftTrack, type TrackItem$1 as VideoDraftTrackItem, type WaitForServerAckOptions, arrangeMainTrackSeamlessly, assertValidVideoDocument, base64ToBytes, buildInitialVideoDocument, buildSpeechHostMap, bytesToBase64, cascadeAfterVideoClipChanges, createMirrorVideoDocument, createMirrorVideoDocumentAdapter, decodeDocVersionMark, derivePositionFromAbs, encodeDocVersionMark, ensureLaneTrack, fillMainTrackTimeGaps, findLaneTrack, fromVideoDocument, generatePartId, getAt, hostForAbsMs, isEmptyVideoClip, isImplementedSemanticOpKind, isMap, laneTrackId, mainTrackRanges, partDurationMs, partUnionSchema, readMainTrackItems, readMengineEventStream, readPart, readPartDurationMs, readVideoDocumentFromDraft, reassignSpeechesToVideoClipsByTime, recalculateTimelineDuration, relativePositionForAbs, resolveAllSpeechOverlaps, resolveSpeechOverlapByShiftingVideos, safeDurationMs, index_d_exports as schemas, snapshotToPlain, solveVideoDocument, syncAggregatedClipsTimePosition, toVideoDocument, validateVideoDocument, videoDocumentMirrorSchema, videoDocumentSchema };