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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
- import { JournalEntry, MengineDocSession, PartIdFactory, SemanticOpName, VideoDocument, VideoDraft, fromVideoDocument } from "@mengine/medeo-client";
1
+ import { _ as SandboxEntity, a as EntityFacade, b as UpdateEntityInput, c as JsonObject, d as KnownEntityKind, f as KnownRelationKind, g as ResourceEntityKind, h as RelationFacade, i as EntityCommand, l as JsonPrimitive, m as LinkRelationInput, n as CreateEntityInput, o as EntityPlanState, p as LinkGeneratedRelationInput, r as DeleteEntityInput, s as EntityStoreSnapshot, t as AuthorableRelationKind, u as JsonValue, v as SandboxRelation, y as UnlinkRelationInput } from "./entity-contract-C5HHaYKk.mjs";
2
+ import { JournalEntry, ManualSyncDoc, MediaAssetFact, PartIdFactory, SemanticOpName, VideoDocument, VideoDraft, fromVideoDocument } from "@mengine/medeo-client";
2
3
  import { AddSpeechesInput, AddVideoClipsInput, AdjustBgmVolumeInput, AdjustSpeechVolumeInput, AdjustVideoClipDurationInput, AdjustVideoClipVolumeInput, ChangeSpeechScriptInput, ChangeSpeechVoiceInput, DeleteBgmInput, DeleteSpeechesInput, DeleteVideoClipsInput, MoveSpeechesInput, MoveVideoClipsByAnchorInput, MoveVideoClipsInput, ReplaceVideoClipContentInput, ReplaceVideoClipSequenceInput, SetBgmInput, SetCaptionStyleInput, SetCaptionVisibilityInput, SetVideoClipSpeedShiftInput } from "@mengine/medeo-client/schemas";
3
4
 
4
5
  //#region src/document/compact-projection.d.ts
@@ -32,6 +33,9 @@ declare function collectAffectedPartIds(journal: readonly JournalEntry[]): Set<s
32
33
  */
33
34
  declare function renderPreview(document: VideoDocument, journal: readonly JournalEntry[]): string;
34
35
  //#endregion
36
+ //#region src/entity/entity-sandbox.d.ts
37
+ type DomainIdFactory = (prefix: 'entity' | 'relation') => string;
38
+ //#endregion
35
39
  //#region src/sandbox/script-session.d.ts
36
40
  /**
37
41
  * Runtime-neutral edit-sandbox session: `edit.*` / `timeline.*` / checkpoint
@@ -45,9 +49,15 @@ interface SandboxCheckpoint {
45
49
  readonly index: number;
46
50
  }
47
51
  interface ChangePlan {
52
+ readonly plan_kind: 'timeline' | 'entities';
48
53
  doc_id: string;
49
54
  base_version: string;
50
55
  ops: readonly JournalEntry[];
56
+ entity_base_revision: number;
57
+ entity_commands: readonly EntityCommand[];
58
+ entity_rows?: EntityStoreSnapshot;
59
+ deleted_entity_ids?: readonly string[];
60
+ deleted_relation_ids?: readonly string[];
51
61
  preview: string;
52
62
  logs: string[];
53
63
  }
@@ -57,6 +67,10 @@ interface EditSandboxSessionOptions {
57
67
  onLog?: (line: string) => void;
58
68
  /** Notify host that the streamed journal was truncated to `index` (rollback). */
59
69
  onTruncate?: (index: number) => void;
70
+ entityState?: EntityStoreSnapshot;
71
+ domainIdFactory?: DomainIdFactory;
72
+ onEntityCommand?: (command: EntityCommand) => void;
73
+ onEntityTruncate?: (index: number) => void;
60
74
  }
61
75
  interface TimelineClipDescriptor {
62
76
  id: string;
@@ -83,6 +97,7 @@ declare class EditSandboxSession {
83
97
  private readonly onEntry;
84
98
  private readonly onLog;
85
99
  private readonly onTruncate;
100
+ private readonly entitySandbox;
86
101
  private current;
87
102
  /** Adapter journal length already accounted for — new slices are real commits. */
88
103
  private adapterJournalSeen;
@@ -92,6 +107,8 @@ declare class EditSandboxSession {
92
107
  private logCapped;
93
108
  readonly edit: EditFacade;
94
109
  readonly timeline: TimelineFacade;
110
+ readonly entities: EntityFacade;
111
+ readonly relations: RelationFacade;
95
112
  readonly console: ConsoleShim;
96
113
  readonly checkpoint: () => SandboxCheckpoint;
97
114
  readonly rollbackTo: (cp: SandboxCheckpoint) => void;
@@ -123,8 +140,8 @@ interface EditFacade {
123
140
  deleteSpeeches: (input: DeleteSpeechesInput) => Promise<void>;
124
141
  deleteVideoClips: (input: DeleteVideoClipsInput) => Promise<void>;
125
142
  moveSpeeches: (input: MoveSpeechesInput) => Promise<void>;
126
- moveVideoClipsByAnchor: (input: MoveVideoClipsByAnchorInput) => Promise<void>;
127
143
  moveVideoClips: (input: MoveVideoClipsInput) => Promise<void>;
144
+ moveVideoClipsByAnchor: (input: MoveVideoClipsByAnchorInput) => Promise<void>;
128
145
  replaceVideoClipContent: (input: ReplaceVideoClipContentInput) => Promise<void>;
129
146
  replaceVideoClipSequence: (input: ReplaceVideoClipSequenceInput) => Promise<void>;
130
147
  setBgm: (input: SetBgmInput) => Promise<void>;
@@ -157,8 +174,12 @@ interface RunEditScriptOptions {
157
174
  baseVersion: string;
158
175
  script: string;
159
176
  inputs?: Record<string, unknown>;
177
+ /** Authoritative entity/relation rows and revision fetched for this document. */
178
+ entityState?: EntityStoreSnapshot;
160
179
  /** Deterministic id mint label for tests; omit to use the default ULID factory. */
161
180
  idLabel?: string;
181
+ /** @internal Select the graph-native Entity session used by the production host. */
182
+ entityOnly?: boolean;
162
183
  /** Hard wall-clock timeout; default 2000 ms. */
163
184
  timeoutMs?: number;
164
185
  /** V8 old-generation ceiling for the worker; default 256 MB. */
@@ -181,20 +202,53 @@ type EditScriptResult = {
181
202
  };
182
203
  partial: {
183
204
  ops: readonly JournalEntry[];
205
+ entityCommands: readonly EntityCommand[];
184
206
  logs: string[];
185
207
  };
186
208
  };
187
209
  /** Run `script` against a forked document snapshot; always resolves (never rejects). */
188
210
  declare function runEditScript(options: RunEditScriptOptions): Promise<EditScriptResult>;
189
211
  //#endregion
212
+ //#region src/entity/generation-sync.d.ts
213
+ /** Factual generation lineage for recalled Memota assets, supplied by the host. */
214
+ interface AssetGenerationFact {
215
+ /** External asset id of the generation output (memota asset or speech result id). */
216
+ readonly outputAssetId: string;
217
+ /** Factual input asset ids; empty for text-only generation. */
218
+ readonly inputAssetIds: readonly string[];
219
+ }
220
+ /**
221
+ * Host callback resolving lineage by external asset id. Implementations return
222
+ * every known generation record involving the given ids in either role; an
223
+ * empty array means no known lineage and a rejection means the lineage query
224
+ * failed. Entity and Relation semantics stay inside this package.
225
+ */
226
+ type GenerationFactsLoader = (docId: string, assetIds: readonly string[]) => Promise<readonly AssetGenerationFact[]>;
227
+ /**
228
+ * Outcome of the post-commit lineage sync. `failed` is always also surfaced as
229
+ * a `generation_sync_failed` warning so an unavailable lineage query is never
230
+ * presented as synced state.
231
+ */
232
+ interface GenerationSyncOutcome {
233
+ /**
234
+ * applied: new generated Relations were committed.
235
+ * current: the query succeeded and nothing was missing (no created asset,
236
+ * single side absent, text-only generation, or pair already linked).
237
+ * failed: the host query or the sync commit failed.
238
+ */
239
+ readonly status: 'applied' | 'current' | 'failed';
240
+ readonly created_relation_ids?: readonly string[];
241
+ readonly message?: string;
242
+ }
243
+ //#endregion
190
244
  //#region src/prompt.d.ts
191
245
  declare const MEDEO_TOOL_DESCRIPTION: string;
192
246
  //#endregion
193
247
  //#region src/schema.d.ts
194
248
  declare const MEDEO_TOOL_NAME = "medeo";
195
- type MedeoToolOp = 'snapshot' | 'run-edit-script' | 'commit-plan';
249
+ type MedeoToolOp = 'snapshot' | 'migrate-legacy' | 'run-edit-script' | 'commit-plan';
196
250
  /**
197
- * JSON Schema for the host-facing three-op `medeo` tool surface.
251
+ * JSON Schema for the host-facing `medeo` tool surface.
198
252
  *
199
253
  * The schema intentionally does not return or accept the full op journal:
200
254
  * journals stay in the tool process and are referenced by `plan_id`. This keeps
@@ -202,105 +256,223 @@ type MedeoToolOp = 'snapshot' | 'run-edit-script' | 'commit-plan';
202
256
  * journal used for commit.
203
257
  */
204
258
  declare const MEDEO_TOOL_PARAMETERS: {
205
- readonly type: 'object';
206
- readonly required: readonly ['op', 'doc_id'];
259
+ readonly type: "object";
260
+ readonly required: readonly ["op", "doc_id"];
207
261
  readonly additionalProperties: false;
208
262
  readonly properties: {
209
263
  readonly op: {
210
- readonly type: 'string';
211
- readonly enum: readonly ['snapshot', 'run-edit-script', 'commit-plan'];
212
- readonly description: 'Which Medeo document operation to run.';
264
+ readonly type: "string";
265
+ readonly enum: readonly ["snapshot", "migrate-legacy", "run-edit-script", "commit-plan"];
266
+ readonly description: "Which Medeo document operation to run.";
213
267
  };
214
268
  readonly doc_id: {
215
- readonly type: 'string';
269
+ readonly type: "string";
216
270
  readonly minLength: 1;
217
- readonly description: 'Medeo document id. Copy it from the host context; never invent it.';
271
+ readonly description: "Medeo document id. Copy it from the host context; never invent it.";
218
272
  };
219
273
  readonly script: {
220
- readonly type: 'string';
274
+ readonly type: "string";
221
275
  readonly minLength: 1;
222
- readonly description: 'JavaScript body for run-edit-script. It receives edit, timeline, checkpoint, rollbackTo, inputs, and console; perform all calculations in the script.';
276
+ readonly description: "JavaScript body for run-edit-script. Use edit, timeline, entities, relations, checkpoint, rollbackTo, inputs, and console. Asset import, media relations, and timeline entity edits share one entity plan.";
223
277
  };
224
278
  readonly inputs: {
225
- readonly type: 'object';
226
- readonly description: 'Pre-materialized, side-effect-free values passed into the script. Generation and network IO must happen in the host before this call.';
279
+ readonly type: "object";
280
+ readonly description: "Pre-materialized, side-effect-free values passed into the script, including recalled asset facts. Generation history is never an input: the host queries lineage itself and syncs generated Relations after each commit. Generation and network IO must happen in the host before this call.";
281
+ };
282
+ readonly asset_facts: {
283
+ readonly type: "array";
284
+ readonly description: "Factual asset metadata recalled by the host for migrate-legacy only. The package reads the canonical legacy snapshot and version itself; never supply a clip trim window as media duration.";
285
+ readonly items: {
286
+ readonly oneOf: readonly [{
287
+ readonly type: "object";
288
+ readonly additionalProperties: false;
289
+ readonly required: readonly ["assetId", "kind"];
290
+ readonly properties: {
291
+ readonly assetId: {
292
+ readonly type: "string";
293
+ readonly minLength: 1;
294
+ };
295
+ readonly kind: {
296
+ readonly const: "image";
297
+ };
298
+ readonly storageKey: {
299
+ readonly type: "string";
300
+ readonly minLength: 1;
301
+ };
302
+ };
303
+ }, {
304
+ readonly type: "object";
305
+ readonly additionalProperties: false;
306
+ readonly required: readonly ["assetId", "kind", "durationMs"];
307
+ readonly properties: {
308
+ readonly assetId: {
309
+ readonly type: "string";
310
+ readonly minLength: 1;
311
+ };
312
+ readonly kind: {
313
+ readonly const: "video";
314
+ };
315
+ readonly durationMs: {
316
+ readonly type: "integer";
317
+ readonly minimum: 1;
318
+ };
319
+ readonly storageKey: {
320
+ readonly type: "string";
321
+ readonly minLength: 1;
322
+ };
323
+ };
324
+ }, {
325
+ readonly type: "object";
326
+ readonly additionalProperties: false;
327
+ readonly required: readonly ["assetId", "kind", "durationMs", "storageKey"];
328
+ readonly properties: {
329
+ readonly assetId: {
330
+ readonly type: "string";
331
+ readonly minLength: 1;
332
+ };
333
+ readonly kind: {
334
+ readonly const: "audio";
335
+ };
336
+ readonly durationMs: {
337
+ readonly type: "integer";
338
+ readonly minimum: 1;
339
+ };
340
+ readonly storageKey: {
341
+ readonly type: "string";
342
+ readonly minLength: 1;
343
+ };
344
+ };
345
+ }, {
346
+ readonly type: "object";
347
+ readonly additionalProperties: false;
348
+ readonly required: readonly ["assetId", "kind", "durationMs", "storageKey", "voice"];
349
+ readonly properties: {
350
+ readonly kind: {
351
+ readonly const: "voice";
352
+ };
353
+ readonly assetId: {
354
+ readonly type: "string";
355
+ readonly minLength: 1;
356
+ };
357
+ readonly durationMs: {
358
+ readonly type: "integer";
359
+ readonly minimum: 1;
360
+ };
361
+ readonly storageKey: {
362
+ readonly type: "string";
363
+ readonly minLength: 1;
364
+ };
365
+ readonly voice: {
366
+ readonly type: "object";
367
+ readonly additionalProperties: false;
368
+ readonly required: readonly ["system", "key"];
369
+ readonly properties: {
370
+ readonly system: {
371
+ readonly const: "voice-library";
372
+ };
373
+ readonly key: {
374
+ readonly type: "string";
375
+ readonly minLength: 1;
376
+ };
377
+ readonly name: {
378
+ readonly type: "string";
379
+ };
380
+ };
381
+ };
382
+ };
383
+ }];
384
+ };
227
385
  };
228
386
  readonly timeout_ms: {
229
- readonly type: 'integer';
387
+ readonly type: "integer";
230
388
  readonly minimum: 1;
231
- readonly description: 'Maximum script wall-clock time after worker startup (default 2000).';
389
+ readonly description: "Maximum script wall-clock time after worker startup (default 2000).";
232
390
  };
233
391
  readonly memory_limit_mb: {
234
- readonly type: 'integer';
392
+ readonly type: "integer";
235
393
  readonly minimum: 16;
236
- readonly description: 'Worker old-generation memory ceiling in MB (default 256).';
394
+ readonly description: "Worker old-generation memory ceiling in MB (default 256).";
237
395
  };
238
396
  readonly auto_commit: {
239
- readonly type: 'boolean';
240
- readonly description: 'Commit the returned plan immediately after the sandbox succeeds. Default false: return preview plus plan_id for explicit commit.';
397
+ readonly type: "boolean";
398
+ readonly description: "Commit the returned plan immediately after the sandbox succeeds. Default false: return preview plus plan_id for explicit commit.";
241
399
  };
242
400
  readonly plan_id: {
243
- readonly type: 'string';
401
+ readonly type: "string";
244
402
  readonly minLength: 1;
245
- readonly description: 'Plan id returned by run-edit-script; required by commit-plan.';
403
+ readonly description: "Plan id returned by run-edit-script; required by commit-plan.";
246
404
  };
247
405
  readonly validation: {
248
- readonly type: 'string';
249
- readonly enum: readonly ['version', 'preflight'];
250
- readonly description: 'commit-plan mode: version rejects any concurrent change; preflight revalidates each op against the current snapshot.';
406
+ readonly type: "string";
407
+ readonly enum: readonly ["version"];
408
+ readonly description: "Commit with Entity revision CAS; reject concurrent changes.";
251
409
  };
252
410
  };
253
411
  readonly oneOf: readonly [{
254
- readonly required: readonly ['op', 'doc_id'];
412
+ readonly required: readonly ["op", "doc_id", "asset_facts"];
255
413
  readonly properties: {
256
414
  readonly op: {
257
- readonly const: 'snapshot';
415
+ readonly const: "migrate-legacy";
258
416
  };
259
417
  readonly doc_id: {
260
- readonly $ref: '#/properties/doc_id';
418
+ readonly $ref: "#/properties/doc_id";
419
+ };
420
+ readonly asset_facts: {
421
+ readonly $ref: "#/properties/asset_facts";
261
422
  };
262
423
  };
263
424
  readonly additionalProperties: false;
264
425
  }, {
265
- readonly required: readonly ['op', 'doc_id', 'script'];
426
+ readonly required: readonly ["op", "doc_id"];
266
427
  readonly properties: {
267
428
  readonly op: {
268
- readonly const: 'run-edit-script';
429
+ readonly const: "snapshot";
269
430
  };
270
431
  readonly doc_id: {
271
- readonly $ref: '#/properties/doc_id';
432
+ readonly $ref: "#/properties/doc_id";
433
+ };
434
+ };
435
+ readonly additionalProperties: false;
436
+ }, {
437
+ readonly required: readonly ["op", "doc_id", "script"];
438
+ readonly properties: {
439
+ readonly op: {
440
+ readonly const: "run-edit-script";
441
+ };
442
+ readonly doc_id: {
443
+ readonly $ref: "#/properties/doc_id";
272
444
  };
273
445
  readonly script: {
274
- readonly $ref: '#/properties/script';
446
+ readonly $ref: "#/properties/script";
275
447
  };
276
448
  readonly inputs: {
277
- readonly $ref: '#/properties/inputs';
449
+ readonly $ref: "#/properties/inputs";
278
450
  };
279
451
  readonly timeout_ms: {
280
- readonly $ref: '#/properties/timeout_ms';
452
+ readonly $ref: "#/properties/timeout_ms";
281
453
  };
282
454
  readonly memory_limit_mb: {
283
- readonly $ref: '#/properties/memory_limit_mb';
455
+ readonly $ref: "#/properties/memory_limit_mb";
284
456
  };
285
457
  readonly auto_commit: {
286
- readonly $ref: '#/properties/auto_commit';
458
+ readonly $ref: "#/properties/auto_commit";
287
459
  };
288
460
  };
289
461
  readonly additionalProperties: false;
290
462
  }, {
291
- readonly required: readonly ['op', 'doc_id', 'plan_id'];
463
+ readonly required: readonly ["op", "doc_id", "plan_id"];
292
464
  readonly properties: {
293
465
  readonly op: {
294
- readonly const: 'commit-plan';
466
+ readonly const: "commit-plan";
295
467
  };
296
468
  readonly doc_id: {
297
- readonly $ref: '#/properties/doc_id';
469
+ readonly $ref: "#/properties/doc_id";
298
470
  };
299
471
  readonly plan_id: {
300
- readonly $ref: '#/properties/plan_id';
472
+ readonly $ref: "#/properties/plan_id";
301
473
  };
302
474
  readonly validation: {
303
- readonly $ref: '#/properties/validation';
475
+ readonly $ref: "#/properties/validation";
304
476
  };
305
477
  };
306
478
  readonly additionalProperties: false;
@@ -310,23 +482,39 @@ declare const MEDEO_TOOL_PARAMETERS: {
310
482
  //#region src/session/commit-plan.d.ts
311
483
  /**
312
484
  * A sandbox journal plus the opaque version token taken at fork time.
313
- * `commitPlan` rejects the whole plan when the live session has moved on
485
+ * `commitPlan` rejects the whole plan when the live document has moved on
314
486
  * (phase-1 version gate), or localizes a business conflict to a journal
315
487
  * entry under `{ validation: 'preflight' }`.
316
488
  */
317
489
  interface CommitPlan {
318
- /** `session.version()` at the moment the sandbox was forked. */
490
+ /** Encoded `ManualSyncDoc.versionMark()` from when the sandbox was forked. */
319
491
  base_version: string;
320
492
  ops: readonly JournalEntry[];
321
493
  }
494
+ interface CommitPlanWarning {
495
+ kind: 'pull_failed';
496
+ message: string;
497
+ }
322
498
  type CommitPlanResult = {
323
499
  kind: 'committed';
324
500
  ops_applied: number;
501
+ collaborated: boolean;
502
+ warnings?: CommitPlanWarning[];
503
+ } | {
504
+ kind: 'unconfirmed';
505
+ reason: 'push_failed';
506
+ ops_applied: number;
507
+ message: string;
325
508
  } | {
326
509
  kind: 'rejected';
327
510
  reason: 'version_mismatch';
328
511
  expected: string;
329
512
  actual: string;
513
+ } | {
514
+ kind: 'rejected';
515
+ reason: 'push_rejected';
516
+ code?: string;
517
+ message: string;
330
518
  } | {
331
519
  kind: 'rejected';
332
520
  reason: 'op_conflict'; /** Failing entry index in the journal — agent rerun anchor. */
@@ -339,18 +527,18 @@ interface CommitPlanOptions {
339
527
  validation?: 'version' | 'preflight';
340
528
  }
341
529
  /**
342
- * Replay a sandbox journal into a live session through its document adapter
343
- * (SemanticEditor Loro mengine-server).
530
+ * Replay a sandbox journal into a manually-synchronized document and push the
531
+ * whole plan as one causally complete update.
344
532
  *
345
- * - Default / `{ validation: 'version' }`: if `session.version()`
346
- * `plan.base_version`, reject with zero writes.
533
+ * - Default / `{ validation: 'version' }`: if the current document mark differs
534
+ * from `plan.base_version`, reject with zero writes.
347
535
  * - `{ validation: 'preflight' }`: skip the version gate; revalidate each op
348
536
  * against a PlainMemoryAdapter seeded from the current live snapshot, then
349
537
  * replay for real. A SchemaValidator failure becomes `op_conflict` with the
350
538
  * failing entry's index. Journal integrity errors (unrecorded/unconsumed
351
539
  * ids) still propagate as throws in both modes.
352
540
  */
353
- declare function commitPlan(session: MengineDocSession, plan: CommitPlan, options?: CommitPlanOptions): Promise<CommitPlanResult>;
541
+ declare function commitPlan(doc: ManualSyncDoc, plan: CommitPlan, options?: CommitPlanOptions): Promise<CommitPlanResult>;
354
542
  //#endregion
355
543
  //#region src/host-tool.d.ts
356
544
  type ContextualValue<T> = T | ((docId: string) => T | undefined);
@@ -358,7 +546,7 @@ interface CreateMedeoToolOptions {
358
546
  /**
359
547
  * Mengine HTTP origin for a document. The host owns environment routing
360
548
  * (local/stg/prd/lane) and may return a different origin per document.
361
- * Sessions cache by doc id, so the origin must remain stable for that doc.
549
+ * Documents cache by doc id, so the origin must remain stable for that doc.
362
550
  */
363
551
  httpOrigin: ContextualValue<string>;
364
552
  /** Optional bearer token, evaluated for each HTTP request. */
@@ -374,7 +562,17 @@ interface CreateMedeoToolOptions {
374
562
  * snapshot, and tolerates a concurrent creator winning the race.
375
563
  */
376
564
  loadInitialDraft?: (docId: string) => Promise<VideoDraft>;
565
+ /**
566
+ * Resolve factual generation lineage by external asset id after a confirmed
567
+ * entity commit. Return every known generation record involving the given
568
+ * ids in either role; an empty array means no known lineage and a rejection
569
+ * means the lineage query failed (surfaced as a warning, never as synced
570
+ * state). The package owns all Entity/Relation semantics: the host never
571
+ * names entities, relations, or endpoints.
572
+ */
573
+ loadGenerationFacts?: GenerationFactsLoader;
377
574
  fetchImpl?: typeof fetch;
575
+ /** @deprecated ManualSyncDoc has no SSE or reconnect loop. */
378
576
  sseReconnectDelayMs?: number;
379
577
  /** Defaults passed to runEditScript; each call may override them. */
380
578
  sandbox?: {
@@ -401,6 +599,10 @@ interface MedeoModelContext {
401
599
  type MedeoToolInput = {
402
600
  op: 'snapshot';
403
601
  doc_id: string;
602
+ } | {
603
+ op: 'migrate-legacy';
604
+ doc_id: string;
605
+ asset_facts: readonly MediaAssetFact[];
404
606
  } | {
405
607
  op: 'run-edit-script';
406
608
  doc_id: string;
@@ -415,24 +617,68 @@ type MedeoToolInput = {
415
617
  plan_id: string;
416
618
  validation?: 'version' | 'preflight';
417
619
  };
620
+ type MedeoToolWarning = {
621
+ kind: 'pull_failed';
622
+ message: string;
623
+ } | {
624
+ kind: 'generation_sync_failed';
625
+ message: string;
626
+ };
627
+ type EntityCommitResult = {
628
+ kind: 'committed';
629
+ ops_applied: number;
630
+ collaborated: false;
631
+ entity_revision: number; /** Present only when the host supplies loadGenerationFacts. */
632
+ generation_sync?: GenerationSyncOutcome;
633
+ warnings?: MedeoToolWarning[];
634
+ } | {
635
+ kind: 'unconfirmed';
636
+ reason: 'push_failed';
637
+ ops_applied: number;
638
+ message: string;
639
+ } | {
640
+ kind: 'rejected';
641
+ reason: 'entity_revision_mismatch';
642
+ expected: number;
643
+ actual: number;
644
+ } | {
645
+ kind: 'rejected';
646
+ reason: 'entity_state_rejected';
647
+ status: number;
648
+ message: string;
649
+ };
650
+ type MedeoCommitResult = CommitPlanResult | EntityCommitResult;
418
651
  type MedeoToolResult = {
652
+ ok: true;
653
+ op: 'migrate-legacy';
654
+ doc_id: string;
655
+ migration_status: 'committed' | 'already_entity';
656
+ entity_revision: number;
657
+ next_action: 'snapshot';
658
+ } | {
419
659
  ok: true;
420
660
  op: 'snapshot';
421
661
  doc_id: string;
422
662
  version: string;
423
663
  preview: string;
664
+ collaborated?: boolean;
665
+ warnings?: MedeoToolWarning[];
424
666
  } | {
425
667
  ok: true;
426
668
  op: 'run-edit-script';
427
669
  doc_id: string;
428
670
  plan_id: string;
671
+ plan_kind: 'timeline' | 'entities';
429
672
  base_version: string;
673
+ entity_base_revision: number;
430
674
  ops_count: number;
431
675
  preview: string;
432
676
  logs: string[];
433
677
  duration_ms: number;
434
678
  committed?: boolean;
435
- commit_result?: CommitPlanResult;
679
+ commit_result?: MedeoCommitResult;
680
+ collaborated?: boolean;
681
+ warnings?: MedeoToolWarning[];
436
682
  } | {
437
683
  ok: false;
438
684
  op: 'run-edit-script';
@@ -453,8 +699,11 @@ type MedeoToolResult = {
453
699
  op: 'commit-plan';
454
700
  doc_id: string;
455
701
  plan_id: string;
702
+ plan_kind: 'timeline' | 'entities';
456
703
  committed: boolean;
457
- result: CommitPlanResult;
704
+ result: MedeoCommitResult;
705
+ collaborated?: boolean;
706
+ warnings?: MedeoToolWarning[];
458
707
  } | {
459
708
  ok: false;
460
709
  op: MedeoToolOp;
@@ -472,12 +721,12 @@ type MedeoInitialDraft = VideoDraft;
472
721
  /**
473
722
  * Create the self-contained Medeo LLM tool.
474
723
  *
475
- * The package owns session construction, compact projection, sandbox execution,
724
+ * The package owns document construction, compact projection, sandbox execution,
476
725
  * plan caching, commit, document get-or-create, and shutdown. The host supplies
477
726
  * environment facts plus the authoritative legacy draft loader used only when
478
727
  * Mengine has no document yet.
479
728
  */
480
729
  declare function createMedeoTool(options: CreateMedeoToolOptions): MedeoTool;
481
730
  //#endregion
482
- export { type ChangePlan, type CommitPlan, type CommitPlanOptions, type CommitPlanResult, type CompactProjectionOptions, type ConsoleShim, type CreateMedeoToolOptions, type EditFacade, EditSandboxSession, type EditSandboxSessionOptions, type EditScriptResult, MEDEO_TOOL_DESCRIPTION, MEDEO_TOOL_NAME, MEDEO_TOOL_PARAMETERS, type MedeoInitialDraft, type MedeoModelContext, type MedeoModelContextInput, type MedeoTool, type MedeoToolInput, type MedeoToolOp, type MedeoToolResult, type RunEditScriptOptions, type SandboxCheckpoint, type TimelineClipDescriptor, type TimelineFacade, type TimelinePartDescriptor, collectAffectedPartIds, commitPlan, createMedeoTool, renderCompactProjection, renderPreview, runEditScript };
731
+ export { type AssetGenerationFact, type AuthorableRelationKind, type ChangePlan, type CommitPlan, type CommitPlanOptions, type CommitPlanResult, type CompactProjectionOptions, type ConsoleShim, type CreateEntityInput, type CreateMedeoToolOptions, type DeleteEntityInput, type EditFacade, EditSandboxSession, type EditSandboxSessionOptions, type EditScriptResult, type EntityCommand, type EntityCommitResult, type EntityFacade, type EntityPlanState, type EntityStoreSnapshot, type GenerationFactsLoader, type GenerationSyncOutcome, type JsonObject, type JsonPrimitive, type JsonValue, type KnownEntityKind, type KnownRelationKind, type LinkGeneratedRelationInput, type LinkRelationInput, MEDEO_TOOL_DESCRIPTION, MEDEO_TOOL_NAME, MEDEO_TOOL_PARAMETERS, type MedeoCommitResult, type MedeoInitialDraft, type MedeoModelContext, type MedeoModelContextInput, type MedeoTool, type MedeoToolInput, type MedeoToolOp, type MedeoToolResult, type RelationFacade, type ResourceEntityKind, type RunEditScriptOptions, type SandboxCheckpoint, type SandboxEntity, type SandboxRelation, type TimelineClipDescriptor, type TimelineFacade, type TimelinePartDescriptor, type UnlinkRelationInput, type UpdateEntityInput, collectAffectedPartIds, commitPlan, createMedeoTool, renderCompactProjection, renderPreview, runEditScript };
483
732
  //# sourceMappingURL=index.d.mts.map