@mengine/medeo-tool 1.0.1-alpha.2 → 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,5 +1,6 @@
1
- import { JournalEntry, MengineDocSession, PartIdFactory, SemanticOpName, VideoDocument, VideoDraft, fromVideoDocument } from "@mengine/medeo-client";
2
- import { AddSpeechesInput, AddVideoClipsInput, AdjustBgmVolumeInput, AdjustSpeechVolumeInput, AdjustVideoClipDurationInput, AdjustVideoClipVolumeInput, ChangeSpeechScriptInput, ChangeSpeechVoiceInput, DeleteBgmInput, DeleteSpeechesInput, DeleteVideoClipsInput, MoveSpeechesInput, MoveVideoClipsInput, ReplaceVideoClipContentInput, SetBgmInput, SetCaptionStyleInput, SetCaptionVisibilityInput, SetVideoClipSpeedShiftInput } from "@mengine/medeo-client/schemas";
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";
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
5
6
  /**
@@ -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;
@@ -124,7 +141,9 @@ interface EditFacade {
124
141
  deleteVideoClips: (input: DeleteVideoClipsInput) => Promise<void>;
125
142
  moveSpeeches: (input: MoveSpeechesInput) => Promise<void>;
126
143
  moveVideoClips: (input: MoveVideoClipsInput) => Promise<void>;
144
+ moveVideoClipsByAnchor: (input: MoveVideoClipsByAnchorInput) => Promise<void>;
127
145
  replaceVideoClipContent: (input: ReplaceVideoClipContentInput) => Promise<void>;
146
+ replaceVideoClipSequence: (input: ReplaceVideoClipSequenceInput) => Promise<void>;
128
147
  setBgm: (input: SetBgmInput) => Promise<void>;
129
148
  setCaptionStyle: (input: SetCaptionStyleInput) => Promise<void>;
130
149
  setCaptionVisibility: (input: SetCaptionVisibilityInput) => Promise<void>;
@@ -155,8 +174,12 @@ interface RunEditScriptOptions {
155
174
  baseVersion: string;
156
175
  script: string;
157
176
  inputs?: Record<string, unknown>;
177
+ /** Authoritative entity/relation rows and revision fetched for this document. */
178
+ entityState?: EntityStoreSnapshot;
158
179
  /** Deterministic id mint label for tests; omit to use the default ULID factory. */
159
180
  idLabel?: string;
181
+ /** @internal Select the graph-native Entity session used by the production host. */
182
+ entityOnly?: boolean;
160
183
  /** Hard wall-clock timeout; default 2000 ms. */
161
184
  timeoutMs?: number;
162
185
  /** V8 old-generation ceiling for the worker; default 256 MB. */
@@ -179,20 +202,53 @@ type EditScriptResult = {
179
202
  };
180
203
  partial: {
181
204
  ops: readonly JournalEntry[];
205
+ entityCommands: readonly EntityCommand[];
182
206
  logs: string[];
183
207
  };
184
208
  };
185
209
  /** Run `script` against a forked document snapshot; always resolves (never rejects). */
186
210
  declare function runEditScript(options: RunEditScriptOptions): Promise<EditScriptResult>;
187
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
188
244
  //#region src/prompt.d.ts
189
245
  declare const MEDEO_TOOL_DESCRIPTION: string;
190
246
  //#endregion
191
247
  //#region src/schema.d.ts
192
248
  declare const MEDEO_TOOL_NAME = "medeo";
193
- type MedeoToolOp = 'snapshot' | 'run-edit-script' | 'commit-plan';
249
+ type MedeoToolOp = 'snapshot' | 'migrate-legacy' | 'run-edit-script' | 'commit-plan';
194
250
  /**
195
- * JSON Schema for the host-facing three-op `medeo` tool surface.
251
+ * JSON Schema for the host-facing `medeo` tool surface.
196
252
  *
197
253
  * The schema intentionally does not return or accept the full op journal:
198
254
  * journals stay in the tool process and are referenced by `plan_id`. This keeps
@@ -200,105 +256,223 @@ type MedeoToolOp = 'snapshot' | 'run-edit-script' | 'commit-plan';
200
256
  * journal used for commit.
201
257
  */
202
258
  declare const MEDEO_TOOL_PARAMETERS: {
203
- readonly type: 'object';
204
- readonly required: readonly ['op', 'doc_id'];
259
+ readonly type: "object";
260
+ readonly required: readonly ["op", "doc_id"];
205
261
  readonly additionalProperties: false;
206
262
  readonly properties: {
207
263
  readonly op: {
208
- readonly type: 'string';
209
- readonly enum: readonly ['snapshot', 'run-edit-script', 'commit-plan'];
210
- 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.";
211
267
  };
212
268
  readonly doc_id: {
213
- readonly type: 'string';
269
+ readonly type: "string";
214
270
  readonly minLength: 1;
215
- 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.";
216
272
  };
217
273
  readonly script: {
218
- readonly type: 'string';
274
+ readonly type: "string";
219
275
  readonly minLength: 1;
220
- 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.";
221
277
  };
222
278
  readonly inputs: {
223
- readonly type: 'object';
224
- 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
+ };
225
385
  };
226
386
  readonly timeout_ms: {
227
- readonly type: 'integer';
387
+ readonly type: "integer";
228
388
  readonly minimum: 1;
229
- 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).";
230
390
  };
231
391
  readonly memory_limit_mb: {
232
- readonly type: 'integer';
392
+ readonly type: "integer";
233
393
  readonly minimum: 16;
234
- readonly description: 'Worker old-generation memory ceiling in MB (default 256).';
394
+ readonly description: "Worker old-generation memory ceiling in MB (default 256).";
235
395
  };
236
396
  readonly auto_commit: {
237
- readonly type: 'boolean';
238
- 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.";
239
399
  };
240
400
  readonly plan_id: {
241
- readonly type: 'string';
401
+ readonly type: "string";
242
402
  readonly minLength: 1;
243
- 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.";
244
404
  };
245
405
  readonly validation: {
246
- readonly type: 'string';
247
- readonly enum: readonly ['version', 'preflight'];
248
- 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.";
249
409
  };
250
410
  };
251
411
  readonly oneOf: readonly [{
252
- readonly required: readonly ['op', 'doc_id'];
412
+ readonly required: readonly ["op", "doc_id", "asset_facts"];
253
413
  readonly properties: {
254
414
  readonly op: {
255
- readonly const: 'snapshot';
415
+ readonly const: "migrate-legacy";
256
416
  };
257
417
  readonly doc_id: {
258
- readonly $ref: '#/properties/doc_id';
418
+ readonly $ref: "#/properties/doc_id";
419
+ };
420
+ readonly asset_facts: {
421
+ readonly $ref: "#/properties/asset_facts";
259
422
  };
260
423
  };
261
424
  readonly additionalProperties: false;
262
425
  }, {
263
- readonly required: readonly ['op', 'doc_id', 'script'];
426
+ readonly required: readonly ["op", "doc_id"];
264
427
  readonly properties: {
265
428
  readonly op: {
266
- readonly const: 'run-edit-script';
429
+ readonly const: "snapshot";
267
430
  };
268
431
  readonly doc_id: {
269
- 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";
270
444
  };
271
445
  readonly script: {
272
- readonly $ref: '#/properties/script';
446
+ readonly $ref: "#/properties/script";
273
447
  };
274
448
  readonly inputs: {
275
- readonly $ref: '#/properties/inputs';
449
+ readonly $ref: "#/properties/inputs";
276
450
  };
277
451
  readonly timeout_ms: {
278
- readonly $ref: '#/properties/timeout_ms';
452
+ readonly $ref: "#/properties/timeout_ms";
279
453
  };
280
454
  readonly memory_limit_mb: {
281
- readonly $ref: '#/properties/memory_limit_mb';
455
+ readonly $ref: "#/properties/memory_limit_mb";
282
456
  };
283
457
  readonly auto_commit: {
284
- readonly $ref: '#/properties/auto_commit';
458
+ readonly $ref: "#/properties/auto_commit";
285
459
  };
286
460
  };
287
461
  readonly additionalProperties: false;
288
462
  }, {
289
- readonly required: readonly ['op', 'doc_id', 'plan_id'];
463
+ readonly required: readonly ["op", "doc_id", "plan_id"];
290
464
  readonly properties: {
291
465
  readonly op: {
292
- readonly const: 'commit-plan';
466
+ readonly const: "commit-plan";
293
467
  };
294
468
  readonly doc_id: {
295
- readonly $ref: '#/properties/doc_id';
469
+ readonly $ref: "#/properties/doc_id";
296
470
  };
297
471
  readonly plan_id: {
298
- readonly $ref: '#/properties/plan_id';
472
+ readonly $ref: "#/properties/plan_id";
299
473
  };
300
474
  readonly validation: {
301
- readonly $ref: '#/properties/validation';
475
+ readonly $ref: "#/properties/validation";
302
476
  };
303
477
  };
304
478
  readonly additionalProperties: false;
@@ -308,23 +482,39 @@ declare const MEDEO_TOOL_PARAMETERS: {
308
482
  //#region src/session/commit-plan.d.ts
309
483
  /**
310
484
  * A sandbox journal plus the opaque version token taken at fork time.
311
- * `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
312
486
  * (phase-1 version gate), or localizes a business conflict to a journal
313
487
  * entry under `{ validation: 'preflight' }`.
314
488
  */
315
489
  interface CommitPlan {
316
- /** `session.version()` at the moment the sandbox was forked. */
490
+ /** Encoded `ManualSyncDoc.versionMark()` from when the sandbox was forked. */
317
491
  base_version: string;
318
492
  ops: readonly JournalEntry[];
319
493
  }
494
+ interface CommitPlanWarning {
495
+ kind: 'pull_failed';
496
+ message: string;
497
+ }
320
498
  type CommitPlanResult = {
321
499
  kind: 'committed';
322
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;
323
508
  } | {
324
509
  kind: 'rejected';
325
510
  reason: 'version_mismatch';
326
511
  expected: string;
327
512
  actual: string;
513
+ } | {
514
+ kind: 'rejected';
515
+ reason: 'push_rejected';
516
+ code?: string;
517
+ message: string;
328
518
  } | {
329
519
  kind: 'rejected';
330
520
  reason: 'op_conflict'; /** Failing entry index in the journal — agent rerun anchor. */
@@ -337,18 +527,18 @@ interface CommitPlanOptions {
337
527
  validation?: 'version' | 'preflight';
338
528
  }
339
529
  /**
340
- * Replay a sandbox journal into a live session through its document adapter
341
- * (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.
342
532
  *
343
- * - Default / `{ validation: 'version' }`: if `session.version()`
344
- * `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.
345
535
  * - `{ validation: 'preflight' }`: skip the version gate; revalidate each op
346
536
  * against a PlainMemoryAdapter seeded from the current live snapshot, then
347
537
  * replay for real. A SchemaValidator failure becomes `op_conflict` with the
348
538
  * failing entry's index. Journal integrity errors (unrecorded/unconsumed
349
539
  * ids) still propagate as throws in both modes.
350
540
  */
351
- declare function commitPlan(session: MengineDocSession, plan: CommitPlan, options?: CommitPlanOptions): Promise<CommitPlanResult>;
541
+ declare function commitPlan(doc: ManualSyncDoc, plan: CommitPlan, options?: CommitPlanOptions): Promise<CommitPlanResult>;
352
542
  //#endregion
353
543
  //#region src/host-tool.d.ts
354
544
  type ContextualValue<T> = T | ((docId: string) => T | undefined);
@@ -356,7 +546,7 @@ interface CreateMedeoToolOptions {
356
546
  /**
357
547
  * Mengine HTTP origin for a document. The host owns environment routing
358
548
  * (local/stg/prd/lane) and may return a different origin per document.
359
- * 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.
360
550
  */
361
551
  httpOrigin: ContextualValue<string>;
362
552
  /** Optional bearer token, evaluated for each HTTP request. */
@@ -372,7 +562,17 @@ interface CreateMedeoToolOptions {
372
562
  * snapshot, and tolerates a concurrent creator winning the race.
373
563
  */
374
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;
375
574
  fetchImpl?: typeof fetch;
575
+ /** @deprecated ManualSyncDoc has no SSE or reconnect loop. */
376
576
  sseReconnectDelayMs?: number;
377
577
  /** Defaults passed to runEditScript; each call may override them. */
378
578
  sandbox?: {
@@ -381,10 +581,28 @@ interface CreateMedeoToolOptions {
381
581
  };
382
582
  /** Maximum cached plans; oldest plans are evicted (default 16). */
383
583
  maxPlans?: number;
584
+ /** Maximum model-call version baselines retained across host contexts (default 128). */
585
+ maxModelContexts?: number;
586
+ }
587
+ interface MedeoModelContextInput {
588
+ /** Internal MEngine document id. This is host-supplied and never model-facing. */
589
+ doc_id: string;
590
+ /** Stable host conversation/session key used to compare consecutive model calls. */
591
+ context_id: string;
592
+ }
593
+ interface MedeoModelContext {
594
+ /** Complete MEngine-owned prompt: workflow, runtime state, and sandbox TypeScript interface. */
595
+ prompt: string;
596
+ document_version: string;
597
+ updated_since_previous_model_call: boolean | null;
384
598
  }
385
599
  type MedeoToolInput = {
386
600
  op: 'snapshot';
387
601
  doc_id: string;
602
+ } | {
603
+ op: 'migrate-legacy';
604
+ doc_id: string;
605
+ asset_facts: readonly MediaAssetFact[];
388
606
  } | {
389
607
  op: 'run-edit-script';
390
608
  doc_id: string;
@@ -399,24 +617,68 @@ type MedeoToolInput = {
399
617
  plan_id: string;
400
618
  validation?: 'version' | 'preflight';
401
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;
402
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
+ } | {
403
659
  ok: true;
404
660
  op: 'snapshot';
405
661
  doc_id: string;
406
662
  version: string;
407
663
  preview: string;
664
+ collaborated?: boolean;
665
+ warnings?: MedeoToolWarning[];
408
666
  } | {
409
667
  ok: true;
410
668
  op: 'run-edit-script';
411
669
  doc_id: string;
412
670
  plan_id: string;
671
+ plan_kind: 'timeline' | 'entities';
413
672
  base_version: string;
673
+ entity_base_revision: number;
414
674
  ops_count: number;
415
675
  preview: string;
416
676
  logs: string[];
417
677
  duration_ms: number;
418
678
  committed?: boolean;
419
- commit_result?: CommitPlanResult;
679
+ commit_result?: MedeoCommitResult;
680
+ collaborated?: boolean;
681
+ warnings?: MedeoToolWarning[];
420
682
  } | {
421
683
  ok: false;
422
684
  op: 'run-edit-script';
@@ -437,8 +699,11 @@ type MedeoToolResult = {
437
699
  op: 'commit-plan';
438
700
  doc_id: string;
439
701
  plan_id: string;
702
+ plan_kind: 'timeline' | 'entities';
440
703
  committed: boolean;
441
- result: CommitPlanResult;
704
+ result: MedeoCommitResult;
705
+ collaborated?: boolean;
706
+ warnings?: MedeoToolWarning[];
442
707
  } | {
443
708
  ok: false;
444
709
  op: MedeoToolOp;
@@ -448,6 +713,7 @@ interface MedeoTool {
448
713
  name: typeof MEDEO_TOOL_NAME;
449
714
  description: typeof MEDEO_TOOL_DESCRIPTION;
450
715
  parameters: typeof MEDEO_TOOL_PARAMETERS;
716
+ getModelContext(input: MedeoModelContextInput): Promise<MedeoModelContext>;
451
717
  handle(input: unknown): Promise<MedeoToolResult>;
452
718
  close(): Promise<void>;
453
719
  }
@@ -455,12 +721,12 @@ type MedeoInitialDraft = VideoDraft;
455
721
  /**
456
722
  * Create the self-contained Medeo LLM tool.
457
723
  *
458
- * The package owns session construction, compact projection, sandbox execution,
724
+ * The package owns document construction, compact projection, sandbox execution,
459
725
  * plan caching, commit, document get-or-create, and shutdown. The host supplies
460
726
  * environment facts plus the authoritative legacy draft loader used only when
461
727
  * Mengine has no document yet.
462
728
  */
463
729
  declare function createMedeoTool(options: CreateMedeoToolOptions): MedeoTool;
464
730
  //#endregion
465
- 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 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 };
466
732
  //# sourceMappingURL=index.d.mts.map