@mengine/medeo-tool 1.0.1-alpha.2 → 1.2.1-alpha.7

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/README.md CHANGED
@@ -1,15 +1,16 @@
1
1
  # `@mengine/medeo-tool`
2
2
 
3
- Node tool surface for editing a Medeo video document through the deterministic
4
- edit sandbox.
3
+ Node tool surface for editing a Medeo video document and its explicit
4
+ Entity/Relation state through the deterministic edit sandbox.
5
5
 
6
6
  The package owns the complete tool path:
7
7
 
8
8
  - compact snapshot projection;
9
9
  - trusted worker execution of an agent-authored JavaScript edit script;
10
10
  - op-journal `ChangePlan` caching;
11
- - versioned or per-op-preflight commit through `MengineDocSession`;
12
- - session cache and shutdown.
11
+ - versioned or per-op-preflight commit through `ManualSyncDoc`;
12
+ - complete Entity/Relation snapshot reads and revision-CAS commits;
13
+ - per-document serialization, document cache, and shutdown.
13
14
 
14
15
  A host supplies only environment facts: Mengine HTTP origin, optional request
15
16
  identity headers, `fetch`, and a stable agent peer id.
@@ -36,9 +37,38 @@ const commit = await medeo.handle({
36
37
  plan_id: run.plan_id,
37
38
  });
38
39
 
40
+ // Generation facts are recalled by the host and passed into the sandbox.
41
+ const entityRun = await medeo.handle({
42
+ op: 'run-edit-script',
43
+ doc_id: docId,
44
+ inputs: { output_asset_id: 'asset-from-host', generation_id: 'generation-from-host' },
45
+ script: `
46
+ if (typeof inputs.output_asset_id !== 'string' || typeof inputs.generation_id !== 'string') {
47
+ throw new Error('missing recalled generation facts');
48
+ }
49
+ const asset = entities.importAsset({ asset_id: inputs.output_asset_id });
50
+ const input = entities.create({
51
+ entity_kind: 'image',
52
+ payload: { extent: { kind: 'unbounded', start: 0 }, sampling: 'constant', coordinateSpace: 'ms' },
53
+ });
54
+ const output = entities.create({
55
+ entity_kind: 'video',
56
+ payload: { extent: { kind: 'bounded', start: 0, end: 1000 }, sampling: 'native', coordinateSpace: 'ms' },
57
+ });
58
+ relations.link({ relation_kind: 'physical-asset', endpoint_0_entity_id: output, endpoint_1_entity_id: asset });
59
+ relations.linkGenerated({ output_entity_id: output, input_entity_id: input, trace: { generation_id: inputs.generation_id } });
60
+ `,
61
+ });
62
+
39
63
  await medeo.close();
40
64
  ```
41
65
 
42
66
  The sandbox has no network, storage, clock, or generation access. Materialize
43
- speech/media side effects in the host first and pass stable facts through
44
- `inputs`.
67
+ or recall speech/media side effects in the host first and pass stable facts
68
+ through `inputs`. There is no automatic Asset→Entity projection: the model
69
+ selects and imports assets, creates only known typed Entities, and links them
70
+ explicitly. Assets and media Entities are intentionally not one-to-one.
71
+
72
+ Timeline mutations and Entity/Relation mutations use different storage and CAS
73
+ boundaries. A single script plan cannot mix them; create and commit two plans
74
+ when a workflow needs both.
@@ -0,0 +1,174 @@
1
+ //#region src/entity/entity-contract.d.ts
2
+ type JsonPrimitive = string | number | boolean | null;
3
+ type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
4
+ interface JsonObject {
5
+ [key: string]: JsonValue;
6
+ }
7
+ type KnownEntityKind = 'axvideo' | 'timeline' | 'track' | 'clip' | 'asset' | 'video' | 'audio' | 'voice' | 'image' | 'sequence-marker' | 'viewport' | 'audio-script' | 'phonetic-script' | 'caption';
8
+ type KnownRelationKind = 'timeline-track' | 'track-clip' | 'clip-marker' | 'marker-content' | 'axvideo-marker' | 'marker-timeline' | 'physical-asset' | 'generated' | 'phonetic-script-provenance' | 'caption-provenance' | 'caption-alignment';
9
+ type AuthorableRelationKind = Exclude<KnownRelationKind, 'generated'>;
10
+ interface BoundedNativeSequencePayload extends JsonObject {
11
+ /** Factual coordinates from recalled media metadata; never invent an end/duration. */
12
+ extent: {
13
+ kind: 'bounded';
14
+ start: number;
15
+ end: number;
16
+ };
17
+ sampling: 'native';
18
+ coordinateSpace: JsonValue;
19
+ }
20
+ interface UnboundedConstantSequencePayload extends JsonObject {
21
+ extent: {
22
+ kind: 'unbounded';
23
+ start: number;
24
+ };
25
+ sampling: 'constant';
26
+ coordinateSpace: JsonValue;
27
+ }
28
+ interface BoundedDerivedSequencePayload extends JsonObject {
29
+ extent: {
30
+ kind: 'bounded';
31
+ start: number;
32
+ end: number;
33
+ };
34
+ sampling: 'derived';
35
+ coordinateSpace: JsonValue;
36
+ }
37
+ type ScriptTextSegment = JsonObject & {
38
+ segmentId: string;
39
+ text: string;
40
+ language?: string;
41
+ };
42
+ interface EntityPayloadByKind {
43
+ axvideo: BoundedDerivedSequencePayload;
44
+ timeline: JsonObject;
45
+ track: JsonObject & {
46
+ hidden?: boolean;
47
+ role?: string;
48
+ };
49
+ clip: JsonObject;
50
+ /** Asset-owned metadata. Peer media associations belong in physical-asset Relations. */
51
+ asset: JsonObject;
52
+ video: BoundedNativeSequencePayload;
53
+ audio: BoundedNativeSequencePayload;
54
+ voice: BoundedNativeSequencePayload;
55
+ image: UnboundedConstantSequencePayload;
56
+ 'sequence-marker': JsonObject & {
57
+ sourceRange: {
58
+ start: number;
59
+ end: number;
60
+ };
61
+ targetRange?: {
62
+ start: number;
63
+ end: number;
64
+ };
65
+ duration: {
66
+ mode: 'from-source';
67
+ } | {
68
+ mode: 'fixed';
69
+ value: number;
70
+ };
71
+ timeRemapping?: JsonValue;
72
+ };
73
+ viewport: JsonObject;
74
+ 'audio-script': JsonObject & {
75
+ segments: ScriptTextSegment[];
76
+ };
77
+ 'phonetic-script': JsonObject & {
78
+ segments: ScriptTextSegment[];
79
+ };
80
+ caption: BoundedNativeSequencePayload;
81
+ }
82
+ interface SandboxEntity<K extends KnownEntityKind = KnownEntityKind> {
83
+ entity_id: string;
84
+ entity_kind: K;
85
+ payload: EntityPayloadByKind[K];
86
+ }
87
+ interface SandboxRelation {
88
+ relation_id: string;
89
+ relation_kind: KnownRelationKind;
90
+ endpoint_0_entity_id: string;
91
+ endpoint_1_entity_id: string;
92
+ metadata: JsonObject;
93
+ trace: JsonObject;
94
+ }
95
+ interface EntityStoreSnapshot {
96
+ revision: number;
97
+ entities: SandboxEntity[];
98
+ relations: SandboxRelation[];
99
+ }
100
+ type CreateEntityInput = { [K in KnownEntityKind]: {
101
+ entity_id?: string;
102
+ entity_kind: K;
103
+ payload: EntityPayloadByKind[K];
104
+ } }[KnownEntityKind];
105
+ interface ImportAssetInput {
106
+ asset_id: string;
107
+ entity_id?: string;
108
+ payload?: JsonObject;
109
+ }
110
+ type EmptyRelationKind = 'timeline-track' | 'track-clip' | 'clip-marker' | 'marker-content' | 'axvideo-marker' | 'marker-timeline';
111
+ interface LinkRelationBase {
112
+ relation_id?: string;
113
+ endpoint_0_entity_id: string;
114
+ endpoint_1_entity_id: string;
115
+ trace?: JsonObject;
116
+ }
117
+ type LinkRelationInput = (LinkRelationBase & {
118
+ relation_kind: EmptyRelationKind;
119
+ metadata?: {
120
+ [key: string]: never;
121
+ };
122
+ }) | (LinkRelationBase & {
123
+ relation_kind: 'physical-asset';
124
+ metadata?: JsonObject;
125
+ }) | (LinkRelationBase & {
126
+ relation_kind: 'phonetic-script-provenance' | 'caption-provenance';
127
+ metadata: JsonObject & {
128
+ segmentAlignment: JsonValue;
129
+ };
130
+ }) | (LinkRelationBase & {
131
+ relation_kind: 'caption-alignment';
132
+ metadata: JsonObject & {
133
+ alignment: JsonValue;
134
+ };
135
+ });
136
+ interface LinkGeneratedRelationInput {
137
+ relation_id?: string;
138
+ output_entity_id: string;
139
+ input_entity_id: string;
140
+ trace?: JsonObject;
141
+ }
142
+ type EntityCommand = {
143
+ kind: 'create-entity';
144
+ entity: SandboxEntity;
145
+ } | {
146
+ kind: 'link-relation';
147
+ relation: SandboxRelation;
148
+ };
149
+ interface EntityPlanState {
150
+ base_revision: number;
151
+ commands: readonly EntityCommand[];
152
+ rows: EntityStoreSnapshot;
153
+ }
154
+ interface EntityFacade {
155
+ list(): SandboxEntity[];
156
+ get(entityId: string): SandboxEntity | null;
157
+ /** Return every explicitly imported Asset entity for a Memota asset id. */
158
+ findByAssetId(assetId: string): SandboxEntity<'asset'>[];
159
+ create(input: CreateEntityInput): string;
160
+ /** Import one physical asset without implying a one-to-one media Entity mapping. */
161
+ importAsset(input: ImportAssetInput): string;
162
+ }
163
+ interface RelationFacade {
164
+ list(): SandboxRelation[];
165
+ /** Incident lookup is endpoint-agnostic; persisted endpoint positions stay unchanged. */
166
+ of(entityId: string, relationKind?: KnownRelationKind): SandboxRelation[];
167
+ /** For physical-asset use sequence media as endpoint 0 and Asset as endpoint 1. */
168
+ link(input: LinkRelationInput): string;
169
+ /** Author ordered generated(output,input); generic link() deliberately rejects this kind. */
170
+ linkGenerated(input: LinkGeneratedRelationInput): string;
171
+ }
172
+ //#endregion
173
+ export { SandboxRelation as _, EntityPlanState as a, JsonObject as c, KnownEntityKind as d, KnownRelationKind as f, SandboxEntity as g, RelationFacade as h, EntityFacade as i, JsonPrimitive as l, LinkRelationInput as m, CreateEntityInput as n, EntityStoreSnapshot as o, LinkGeneratedRelationInput as p, EntityCommand as r, ImportAssetInput as s, AuthorableRelationKind as t, JsonValue as u };
174
+ //# sourceMappingURL=entity-contract-B3txrzTt.d.mts.map
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 SandboxRelation, a as EntityPlanState, c as JsonObject, d as KnownEntityKind, f as KnownRelationKind, g as SandboxEntity, h as RelationFacade, i as EntityFacade, l as JsonPrimitive, m as LinkRelationInput, n as CreateEntityInput, o as EntityStoreSnapshot, p as LinkGeneratedRelationInput, r as EntityCommand, s as ImportAssetInput, t as AuthorableRelationKind, u as JsonValue } from "./entity-contract-B3txrzTt.mjs";
2
+ import { JournalEntry, ManualSyncDoc, 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,13 @@ 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;
51
59
  preview: string;
52
60
  logs: string[];
53
61
  }
@@ -57,6 +65,10 @@ interface EditSandboxSessionOptions {
57
65
  onLog?: (line: string) => void;
58
66
  /** Notify host that the streamed journal was truncated to `index` (rollback). */
59
67
  onTruncate?: (index: number) => void;
68
+ entityState?: EntityStoreSnapshot;
69
+ domainIdFactory?: DomainIdFactory;
70
+ onEntityCommand?: (command: EntityCommand) => void;
71
+ onEntityTruncate?: (index: number) => void;
60
72
  }
61
73
  interface TimelineClipDescriptor {
62
74
  id: string;
@@ -83,6 +95,7 @@ declare class EditSandboxSession {
83
95
  private readonly onEntry;
84
96
  private readonly onLog;
85
97
  private readonly onTruncate;
98
+ private readonly entitySandbox;
86
99
  private current;
87
100
  /** Adapter journal length already accounted for — new slices are real commits. */
88
101
  private adapterJournalSeen;
@@ -92,6 +105,8 @@ declare class EditSandboxSession {
92
105
  private logCapped;
93
106
  readonly edit: EditFacade;
94
107
  readonly timeline: TimelineFacade;
108
+ readonly entities: EntityFacade;
109
+ readonly relations: RelationFacade;
95
110
  readonly console: ConsoleShim;
96
111
  readonly checkpoint: () => SandboxCheckpoint;
97
112
  readonly rollbackTo: (cp: SandboxCheckpoint) => void;
@@ -124,7 +139,9 @@ interface EditFacade {
124
139
  deleteVideoClips: (input: DeleteVideoClipsInput) => Promise<void>;
125
140
  moveSpeeches: (input: MoveSpeechesInput) => Promise<void>;
126
141
  moveVideoClips: (input: MoveVideoClipsInput) => Promise<void>;
142
+ moveVideoClipsByAnchor: (input: MoveVideoClipsByAnchorInput) => Promise<void>;
127
143
  replaceVideoClipContent: (input: ReplaceVideoClipContentInput) => Promise<void>;
144
+ replaceVideoClipSequence: (input: ReplaceVideoClipSequenceInput) => Promise<void>;
128
145
  setBgm: (input: SetBgmInput) => Promise<void>;
129
146
  setCaptionStyle: (input: SetCaptionStyleInput) => Promise<void>;
130
147
  setCaptionVisibility: (input: SetCaptionVisibilityInput) => Promise<void>;
@@ -155,6 +172,8 @@ interface RunEditScriptOptions {
155
172
  baseVersion: string;
156
173
  script: string;
157
174
  inputs?: Record<string, unknown>;
175
+ /** Authoritative entity/relation rows and revision fetched for this document. */
176
+ entityState?: EntityStoreSnapshot;
158
177
  /** Deterministic id mint label for tests; omit to use the default ULID factory. */
159
178
  idLabel?: string;
160
179
  /** Hard wall-clock timeout; default 2000 ms. */
@@ -179,6 +198,7 @@ type EditScriptResult = {
179
198
  };
180
199
  partial: {
181
200
  ops: readonly JournalEntry[];
201
+ entityCommands: readonly EntityCommand[];
182
202
  logs: string[];
183
203
  };
184
204
  };
@@ -217,11 +237,11 @@ declare const MEDEO_TOOL_PARAMETERS: {
217
237
  readonly script: {
218
238
  readonly type: 'string';
219
239
  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.';
240
+ readonly description: 'JavaScript body for run-edit-script. It receives edit, timeline, entities, relations, checkpoint, rollbackTo, inputs, and console. A plan may mutate the timeline or Entity/Relation state, never both.';
221
241
  };
222
242
  readonly inputs: {
223
243
  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.';
244
+ readonly description: 'Pre-materialized, side-effect-free values passed into the script, including recalled generation lineage and asset facts. Generation and network IO must happen in the host before this call.';
225
245
  };
226
246
  readonly timeout_ms: {
227
247
  readonly type: 'integer';
@@ -245,7 +265,7 @@ declare const MEDEO_TOOL_PARAMETERS: {
245
265
  readonly validation: {
246
266
  readonly type: 'string';
247
267
  readonly enum: readonly ['version', 'preflight'];
248
- readonly description: 'commit-plan mode: version rejects any concurrent change; preflight revalidates each op against the current snapshot.';
268
+ readonly description: 'Timeline commit mode: version rejects any concurrent change; preflight revalidates each op. Entity plans always use revision CAS and reject preflight.';
249
269
  };
250
270
  };
251
271
  readonly oneOf: readonly [{
@@ -308,23 +328,39 @@ declare const MEDEO_TOOL_PARAMETERS: {
308
328
  //#region src/session/commit-plan.d.ts
309
329
  /**
310
330
  * 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
331
+ * `commitPlan` rejects the whole plan when the live document has moved on
312
332
  * (phase-1 version gate), or localizes a business conflict to a journal
313
333
  * entry under `{ validation: 'preflight' }`.
314
334
  */
315
335
  interface CommitPlan {
316
- /** `session.version()` at the moment the sandbox was forked. */
336
+ /** Encoded `ManualSyncDoc.versionMark()` from when the sandbox was forked. */
317
337
  base_version: string;
318
338
  ops: readonly JournalEntry[];
319
339
  }
340
+ interface CommitPlanWarning {
341
+ kind: 'pull_failed';
342
+ message: string;
343
+ }
320
344
  type CommitPlanResult = {
321
345
  kind: 'committed';
322
346
  ops_applied: number;
347
+ collaborated: boolean;
348
+ warnings?: CommitPlanWarning[];
349
+ } | {
350
+ kind: 'unconfirmed';
351
+ reason: 'push_failed';
352
+ ops_applied: number;
353
+ message: string;
323
354
  } | {
324
355
  kind: 'rejected';
325
356
  reason: 'version_mismatch';
326
357
  expected: string;
327
358
  actual: string;
359
+ } | {
360
+ kind: 'rejected';
361
+ reason: 'push_rejected';
362
+ code?: string;
363
+ message: string;
328
364
  } | {
329
365
  kind: 'rejected';
330
366
  reason: 'op_conflict'; /** Failing entry index in the journal — agent rerun anchor. */
@@ -337,18 +373,18 @@ interface CommitPlanOptions {
337
373
  validation?: 'version' | 'preflight';
338
374
  }
339
375
  /**
340
- * Replay a sandbox journal into a live session through its document adapter
341
- * (SemanticEditor Loro mengine-server).
376
+ * Replay a sandbox journal into a manually-synchronized document and push the
377
+ * whole plan as one causally complete update.
342
378
  *
343
- * - Default / `{ validation: 'version' }`: if `session.version()`
344
- * `plan.base_version`, reject with zero writes.
379
+ * - Default / `{ validation: 'version' }`: if the current document mark differs
380
+ * from `plan.base_version`, reject with zero writes.
345
381
  * - `{ validation: 'preflight' }`: skip the version gate; revalidate each op
346
382
  * against a PlainMemoryAdapter seeded from the current live snapshot, then
347
383
  * replay for real. A SchemaValidator failure becomes `op_conflict` with the
348
384
  * failing entry's index. Journal integrity errors (unrecorded/unconsumed
349
385
  * ids) still propagate as throws in both modes.
350
386
  */
351
- declare function commitPlan(session: MengineDocSession, plan: CommitPlan, options?: CommitPlanOptions): Promise<CommitPlanResult>;
387
+ declare function commitPlan(doc: ManualSyncDoc, plan: CommitPlan, options?: CommitPlanOptions): Promise<CommitPlanResult>;
352
388
  //#endregion
353
389
  //#region src/host-tool.d.ts
354
390
  type ContextualValue<T> = T | ((docId: string) => T | undefined);
@@ -356,7 +392,7 @@ interface CreateMedeoToolOptions {
356
392
  /**
357
393
  * Mengine HTTP origin for a document. The host owns environment routing
358
394
  * (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.
395
+ * Documents cache by doc id, so the origin must remain stable for that doc.
360
396
  */
361
397
  httpOrigin: ContextualValue<string>;
362
398
  /** Optional bearer token, evaluated for each HTTP request. */
@@ -373,6 +409,7 @@ interface CreateMedeoToolOptions {
373
409
  */
374
410
  loadInitialDraft?: (docId: string) => Promise<VideoDraft>;
375
411
  fetchImpl?: typeof fetch;
412
+ /** @deprecated ManualSyncDoc has no SSE or reconnect loop. */
376
413
  sseReconnectDelayMs?: number;
377
414
  /** Defaults passed to runEditScript; each call may override them. */
378
415
  sandbox?: {
@@ -381,6 +418,20 @@ interface CreateMedeoToolOptions {
381
418
  };
382
419
  /** Maximum cached plans; oldest plans are evicted (default 16). */
383
420
  maxPlans?: number;
421
+ /** Maximum model-call version baselines retained across host contexts (default 128). */
422
+ maxModelContexts?: number;
423
+ }
424
+ interface MedeoModelContextInput {
425
+ /** Internal MEngine document id. This is host-supplied and never model-facing. */
426
+ doc_id: string;
427
+ /** Stable host conversation/session key used to compare consecutive model calls. */
428
+ context_id: string;
429
+ }
430
+ interface MedeoModelContext {
431
+ /** Complete MEngine-owned prompt: workflow, runtime state, and sandbox TypeScript interface. */
432
+ prompt: string;
433
+ document_version: string;
434
+ updated_since_previous_model_call: boolean | null;
384
435
  }
385
436
  type MedeoToolInput = {
386
437
  op: 'snapshot';
@@ -399,24 +450,56 @@ type MedeoToolInput = {
399
450
  plan_id: string;
400
451
  validation?: 'version' | 'preflight';
401
452
  };
453
+ interface MedeoToolWarning {
454
+ kind: 'pull_failed';
455
+ message: string;
456
+ }
457
+ type EntityCommitResult = {
458
+ kind: 'committed';
459
+ ops_applied: number;
460
+ collaborated: false;
461
+ entity_revision: number;
462
+ } | {
463
+ kind: 'unconfirmed';
464
+ reason: 'push_failed';
465
+ ops_applied: number;
466
+ message: string;
467
+ } | {
468
+ kind: 'rejected';
469
+ reason: 'entity_revision_mismatch';
470
+ expected: number;
471
+ actual: number;
472
+ } | {
473
+ kind: 'rejected';
474
+ reason: 'entity_state_rejected';
475
+ status: number;
476
+ message: string;
477
+ };
478
+ type MedeoCommitResult = CommitPlanResult | EntityCommitResult;
402
479
  type MedeoToolResult = {
403
480
  ok: true;
404
481
  op: 'snapshot';
405
482
  doc_id: string;
406
483
  version: string;
407
484
  preview: string;
485
+ collaborated?: boolean;
486
+ warnings?: MedeoToolWarning[];
408
487
  } | {
409
488
  ok: true;
410
489
  op: 'run-edit-script';
411
490
  doc_id: string;
412
491
  plan_id: string;
492
+ plan_kind: 'timeline' | 'entities';
413
493
  base_version: string;
494
+ entity_base_revision: number;
414
495
  ops_count: number;
415
496
  preview: string;
416
497
  logs: string[];
417
498
  duration_ms: number;
418
499
  committed?: boolean;
419
- commit_result?: CommitPlanResult;
500
+ commit_result?: MedeoCommitResult;
501
+ collaborated?: boolean;
502
+ warnings?: MedeoToolWarning[];
420
503
  } | {
421
504
  ok: false;
422
505
  op: 'run-edit-script';
@@ -437,8 +520,11 @@ type MedeoToolResult = {
437
520
  op: 'commit-plan';
438
521
  doc_id: string;
439
522
  plan_id: string;
523
+ plan_kind: 'timeline' | 'entities';
440
524
  committed: boolean;
441
- result: CommitPlanResult;
525
+ result: MedeoCommitResult;
526
+ collaborated?: boolean;
527
+ warnings?: MedeoToolWarning[];
442
528
  } | {
443
529
  ok: false;
444
530
  op: MedeoToolOp;
@@ -448,6 +534,7 @@ interface MedeoTool {
448
534
  name: typeof MEDEO_TOOL_NAME;
449
535
  description: typeof MEDEO_TOOL_DESCRIPTION;
450
536
  parameters: typeof MEDEO_TOOL_PARAMETERS;
537
+ getModelContext(input: MedeoModelContextInput): Promise<MedeoModelContext>;
451
538
  handle(input: unknown): Promise<MedeoToolResult>;
452
539
  close(): Promise<void>;
453
540
  }
@@ -455,12 +542,12 @@ type MedeoInitialDraft = VideoDraft;
455
542
  /**
456
543
  * Create the self-contained Medeo LLM tool.
457
544
  *
458
- * The package owns session construction, compact projection, sandbox execution,
545
+ * The package owns document construction, compact projection, sandbox execution,
459
546
  * plan caching, commit, document get-or-create, and shutdown. The host supplies
460
547
  * environment facts plus the authoritative legacy draft loader used only when
461
548
  * Mengine has no document yet.
462
549
  */
463
550
  declare function createMedeoTool(options: CreateMedeoToolOptions): MedeoTool;
464
551
  //#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 };
552
+ export { type AuthorableRelationKind, type ChangePlan, type CommitPlan, type CommitPlanOptions, type CommitPlanResult, type CompactProjectionOptions, type ConsoleShim, type CreateEntityInput, type CreateMedeoToolOptions, type EditFacade, EditSandboxSession, type EditSandboxSessionOptions, type EditScriptResult, type EntityCommand, type EntityCommitResult, type EntityFacade, type EntityPlanState, type EntityStoreSnapshot, type ImportAssetInput, 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 RunEditScriptOptions, type SandboxCheckpoint, type SandboxEntity, type SandboxRelation, type TimelineClipDescriptor, type TimelineFacade, type TimelinePartDescriptor, collectAffectedPartIds, commitPlan, createMedeoTool, renderCompactProjection, renderPreview, runEditScript };
466
553
  //# sourceMappingURL=index.d.mts.map