@mengine/medeo-tool 1.2.1-alpha.0 → 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 +36 -6
- package/dist/entity-contract-B3txrzTt.d.mts +174 -0
- package/dist/index.d.mts +87 -17
- package/dist/index.mjs +740 -149
- package/dist/index.mjs.map +1 -1
- package/dist/sandbox-api.d.mts +176 -3
- package/dist/script-session-BF44uKv_.mjs +1501 -0
- package/dist/script-session-BF44uKv_.mjs.map +1 -0
- package/dist/worker-entry.d.mts +2 -0
- package/dist/worker-entry.mjs +23 -4
- package/dist/worker-entry.mjs.map +1 -1
- package/package.json +4 -3
- package/dist/script-session-DdPA4tTf.mjs +0 -447
- package/dist/script-session-DdPA4tTf.mjs.map +0 -1
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
|
|
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 `
|
|
12
|
-
-
|
|
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
|
|
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,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
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";
|
|
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,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;
|
|
@@ -123,8 +138,8 @@ interface EditFacade {
|
|
|
123
138
|
deleteSpeeches: (input: DeleteSpeechesInput) => Promise<void>;
|
|
124
139
|
deleteVideoClips: (input: DeleteVideoClipsInput) => Promise<void>;
|
|
125
140
|
moveSpeeches: (input: MoveSpeechesInput) => Promise<void>;
|
|
126
|
-
moveVideoClipsByAnchor: (input: MoveVideoClipsByAnchorInput) => Promise<void>;
|
|
127
141
|
moveVideoClips: (input: MoveVideoClipsInput) => Promise<void>;
|
|
142
|
+
moveVideoClipsByAnchor: (input: MoveVideoClipsByAnchorInput) => Promise<void>;
|
|
128
143
|
replaceVideoClipContent: (input: ReplaceVideoClipContentInput) => Promise<void>;
|
|
129
144
|
replaceVideoClipSequence: (input: ReplaceVideoClipSequenceInput) => Promise<void>;
|
|
130
145
|
setBgm: (input: SetBgmInput) => Promise<void>;
|
|
@@ -157,6 +172,8 @@ interface RunEditScriptOptions {
|
|
|
157
172
|
baseVersion: string;
|
|
158
173
|
script: string;
|
|
159
174
|
inputs?: Record<string, unknown>;
|
|
175
|
+
/** Authoritative entity/relation rows and revision fetched for this document. */
|
|
176
|
+
entityState?: EntityStoreSnapshot;
|
|
160
177
|
/** Deterministic id mint label for tests; omit to use the default ULID factory. */
|
|
161
178
|
idLabel?: string;
|
|
162
179
|
/** Hard wall-clock timeout; default 2000 ms. */
|
|
@@ -181,6 +198,7 @@ type EditScriptResult = {
|
|
|
181
198
|
};
|
|
182
199
|
partial: {
|
|
183
200
|
ops: readonly JournalEntry[];
|
|
201
|
+
entityCommands: readonly EntityCommand[];
|
|
184
202
|
logs: string[];
|
|
185
203
|
};
|
|
186
204
|
};
|
|
@@ -219,11 +237,11 @@ declare const MEDEO_TOOL_PARAMETERS: {
|
|
|
219
237
|
readonly script: {
|
|
220
238
|
readonly type: 'string';
|
|
221
239
|
readonly minLength: 1;
|
|
222
|
-
readonly description: 'JavaScript body for run-edit-script. It receives edit, timeline, checkpoint, rollbackTo, inputs, and console
|
|
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.';
|
|
223
241
|
};
|
|
224
242
|
readonly inputs: {
|
|
225
243
|
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.';
|
|
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.';
|
|
227
245
|
};
|
|
228
246
|
readonly timeout_ms: {
|
|
229
247
|
readonly type: 'integer';
|
|
@@ -247,7 +265,7 @@ declare const MEDEO_TOOL_PARAMETERS: {
|
|
|
247
265
|
readonly validation: {
|
|
248
266
|
readonly type: 'string';
|
|
249
267
|
readonly enum: readonly ['version', 'preflight'];
|
|
250
|
-
readonly description: 'commit
|
|
268
|
+
readonly description: 'Timeline commit mode: version rejects any concurrent change; preflight revalidates each op. Entity plans always use revision CAS and reject preflight.';
|
|
251
269
|
};
|
|
252
270
|
};
|
|
253
271
|
readonly oneOf: readonly [{
|
|
@@ -310,23 +328,39 @@ declare const MEDEO_TOOL_PARAMETERS: {
|
|
|
310
328
|
//#region src/session/commit-plan.d.ts
|
|
311
329
|
/**
|
|
312
330
|
* A sandbox journal plus the opaque version token taken at fork time.
|
|
313
|
-
* `commitPlan` rejects the whole plan when the live
|
|
331
|
+
* `commitPlan` rejects the whole plan when the live document has moved on
|
|
314
332
|
* (phase-1 version gate), or localizes a business conflict to a journal
|
|
315
333
|
* entry under `{ validation: 'preflight' }`.
|
|
316
334
|
*/
|
|
317
335
|
interface CommitPlan {
|
|
318
|
-
/** `
|
|
336
|
+
/** Encoded `ManualSyncDoc.versionMark()` from when the sandbox was forked. */
|
|
319
337
|
base_version: string;
|
|
320
338
|
ops: readonly JournalEntry[];
|
|
321
339
|
}
|
|
340
|
+
interface CommitPlanWarning {
|
|
341
|
+
kind: 'pull_failed';
|
|
342
|
+
message: string;
|
|
343
|
+
}
|
|
322
344
|
type CommitPlanResult = {
|
|
323
345
|
kind: 'committed';
|
|
324
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;
|
|
325
354
|
} | {
|
|
326
355
|
kind: 'rejected';
|
|
327
356
|
reason: 'version_mismatch';
|
|
328
357
|
expected: string;
|
|
329
358
|
actual: string;
|
|
359
|
+
} | {
|
|
360
|
+
kind: 'rejected';
|
|
361
|
+
reason: 'push_rejected';
|
|
362
|
+
code?: string;
|
|
363
|
+
message: string;
|
|
330
364
|
} | {
|
|
331
365
|
kind: 'rejected';
|
|
332
366
|
reason: 'op_conflict'; /** Failing entry index in the journal — agent rerun anchor. */
|
|
@@ -339,18 +373,18 @@ interface CommitPlanOptions {
|
|
|
339
373
|
validation?: 'version' | 'preflight';
|
|
340
374
|
}
|
|
341
375
|
/**
|
|
342
|
-
* Replay a sandbox journal into a
|
|
343
|
-
*
|
|
376
|
+
* Replay a sandbox journal into a manually-synchronized document and push the
|
|
377
|
+
* whole plan as one causally complete update.
|
|
344
378
|
*
|
|
345
|
-
* - Default / `{ validation: 'version' }`: if
|
|
346
|
-
* `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.
|
|
347
381
|
* - `{ validation: 'preflight' }`: skip the version gate; revalidate each op
|
|
348
382
|
* against a PlainMemoryAdapter seeded from the current live snapshot, then
|
|
349
383
|
* replay for real. A SchemaValidator failure becomes `op_conflict` with the
|
|
350
384
|
* failing entry's index. Journal integrity errors (unrecorded/unconsumed
|
|
351
385
|
* ids) still propagate as throws in both modes.
|
|
352
386
|
*/
|
|
353
|
-
declare function commitPlan(
|
|
387
|
+
declare function commitPlan(doc: ManualSyncDoc, plan: CommitPlan, options?: CommitPlanOptions): Promise<CommitPlanResult>;
|
|
354
388
|
//#endregion
|
|
355
389
|
//#region src/host-tool.d.ts
|
|
356
390
|
type ContextualValue<T> = T | ((docId: string) => T | undefined);
|
|
@@ -358,7 +392,7 @@ interface CreateMedeoToolOptions {
|
|
|
358
392
|
/**
|
|
359
393
|
* Mengine HTTP origin for a document. The host owns environment routing
|
|
360
394
|
* (local/stg/prd/lane) and may return a different origin per document.
|
|
361
|
-
*
|
|
395
|
+
* Documents cache by doc id, so the origin must remain stable for that doc.
|
|
362
396
|
*/
|
|
363
397
|
httpOrigin: ContextualValue<string>;
|
|
364
398
|
/** Optional bearer token, evaluated for each HTTP request. */
|
|
@@ -375,6 +409,7 @@ interface CreateMedeoToolOptions {
|
|
|
375
409
|
*/
|
|
376
410
|
loadInitialDraft?: (docId: string) => Promise<VideoDraft>;
|
|
377
411
|
fetchImpl?: typeof fetch;
|
|
412
|
+
/** @deprecated ManualSyncDoc has no SSE or reconnect loop. */
|
|
378
413
|
sseReconnectDelayMs?: number;
|
|
379
414
|
/** Defaults passed to runEditScript; each call may override them. */
|
|
380
415
|
sandbox?: {
|
|
@@ -415,24 +450,56 @@ type MedeoToolInput = {
|
|
|
415
450
|
plan_id: string;
|
|
416
451
|
validation?: 'version' | 'preflight';
|
|
417
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;
|
|
418
479
|
type MedeoToolResult = {
|
|
419
480
|
ok: true;
|
|
420
481
|
op: 'snapshot';
|
|
421
482
|
doc_id: string;
|
|
422
483
|
version: string;
|
|
423
484
|
preview: string;
|
|
485
|
+
collaborated?: boolean;
|
|
486
|
+
warnings?: MedeoToolWarning[];
|
|
424
487
|
} | {
|
|
425
488
|
ok: true;
|
|
426
489
|
op: 'run-edit-script';
|
|
427
490
|
doc_id: string;
|
|
428
491
|
plan_id: string;
|
|
492
|
+
plan_kind: 'timeline' | 'entities';
|
|
429
493
|
base_version: string;
|
|
494
|
+
entity_base_revision: number;
|
|
430
495
|
ops_count: number;
|
|
431
496
|
preview: string;
|
|
432
497
|
logs: string[];
|
|
433
498
|
duration_ms: number;
|
|
434
499
|
committed?: boolean;
|
|
435
|
-
commit_result?:
|
|
500
|
+
commit_result?: MedeoCommitResult;
|
|
501
|
+
collaborated?: boolean;
|
|
502
|
+
warnings?: MedeoToolWarning[];
|
|
436
503
|
} | {
|
|
437
504
|
ok: false;
|
|
438
505
|
op: 'run-edit-script';
|
|
@@ -453,8 +520,11 @@ type MedeoToolResult = {
|
|
|
453
520
|
op: 'commit-plan';
|
|
454
521
|
doc_id: string;
|
|
455
522
|
plan_id: string;
|
|
523
|
+
plan_kind: 'timeline' | 'entities';
|
|
456
524
|
committed: boolean;
|
|
457
|
-
result:
|
|
525
|
+
result: MedeoCommitResult;
|
|
526
|
+
collaborated?: boolean;
|
|
527
|
+
warnings?: MedeoToolWarning[];
|
|
458
528
|
} | {
|
|
459
529
|
ok: false;
|
|
460
530
|
op: MedeoToolOp;
|
|
@@ -472,12 +542,12 @@ type MedeoInitialDraft = VideoDraft;
|
|
|
472
542
|
/**
|
|
473
543
|
* Create the self-contained Medeo LLM tool.
|
|
474
544
|
*
|
|
475
|
-
* The package owns
|
|
545
|
+
* The package owns document construction, compact projection, sandbox execution,
|
|
476
546
|
* plan caching, commit, document get-or-create, and shutdown. The host supplies
|
|
477
547
|
* environment facts plus the authoritative legacy draft loader used only when
|
|
478
548
|
* Mengine has no document yet.
|
|
479
549
|
*/
|
|
480
550
|
declare function createMedeoTool(options: CreateMedeoToolOptions): MedeoTool;
|
|
481
551
|
//#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 };
|
|
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 };
|
|
483
553
|
//# sourceMappingURL=index.d.mts.map
|