@tangle-network/agent-app 0.11.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/TimelineEditor-OXPJZDP2.js +12 -0
- package/dist/TimelineEditor-OXPJZDP2.js.map +1 -0
- package/dist/apply-Cp8c3K9D.d.ts +249 -0
- package/dist/chunk-3WAJWYKD.js +1730 -0
- package/dist/chunk-3WAJWYKD.js.map +1 -0
- package/dist/chunk-CF5DZELC.js +111 -0
- package/dist/chunk-CF5DZELC.js.map +1 -0
- package/dist/{chunk-4YTWB5MG.js → chunk-ETX4O4BB.js} +98 -1
- package/dist/chunk-ETX4O4BB.js.map +1 -0
- package/dist/chunk-IHR6K3GF.js +2367 -0
- package/dist/chunk-IHR6K3GF.js.map +1 -0
- package/dist/{chunk-OLCVUGGI.js → chunk-IJZJWKUK.js} +1 -61
- package/dist/chunk-IJZJWKUK.js.map +1 -0
- package/dist/chunk-ZYBWGSAZ.js +130 -0
- package/dist/chunk-ZYBWGSAZ.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +128 -6
- package/dist/mcp-CIupfjxV.d.ts +112 -0
- package/dist/runtime/index.d.ts +108 -1
- package/dist/runtime/index.js +7 -1
- package/dist/sequences/drizzle.d.ts +1244 -0
- package/dist/sequences/drizzle.js +368 -0
- package/dist/sequences/drizzle.js.map +1 -0
- package/dist/sequences/index.d.ts +327 -0
- package/dist/sequences/index.js +114 -0
- package/dist/sequences/index.js.map +1 -0
- package/dist/sequences-react/index.d.ts +752 -0
- package/dist/sequences-react/index.js +241 -0
- package/dist/sequences-react/index.js.map +1 -0
- package/dist/store-gckrNq-g.d.ts +242 -0
- package/dist/tools/index.d.ts +24 -108
- package/dist/tools/index.js +12 -6
- package/package.json +37 -2
- package/dist/chunk-4YTWB5MG.js.map +0 -1
- package/dist/chunk-OLCVUGGI.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SEQUENCE_MEDIA_DRAG_TYPE,
|
|
3
|
+
TimelineEditor,
|
|
4
|
+
TimelineEditor_default
|
|
5
|
+
} from "./chunk-IHR6K3GF.js";
|
|
6
|
+
import "./chunk-ZYBWGSAZ.js";
|
|
7
|
+
export {
|
|
8
|
+
SEQUENCE_MEDIA_DRAG_TYPE,
|
|
9
|
+
TimelineEditor,
|
|
10
|
+
TimelineEditor_default as default
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=TimelineEditor-OXPJZDP2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { q as SequenceTrackKind, f as SequenceExportFormat, p as SequenceTrack, o as SequenceTimeline, T as TimelineClipBounds, S as SequenceClip, g as SequenceExportRecord, k as SequenceMeta, m as SequenceStore } from './store-gckrNq-g.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The sequence operation union — the ONE mutation vocabulary shared by every
|
|
5
|
+
* writer of a timeline: the MCP tool dispatcher (agent edits), the React
|
|
6
|
+
* editor's command stack (human edits, undo/redo), and batch agent plans.
|
|
7
|
+
* Positions are integer frames; the seconds→frames conversion happens at the
|
|
8
|
+
* tool-argument edge (./mcp), never here.
|
|
9
|
+
*
|
|
10
|
+
* Validation lives in ./validate (`validateSequenceOperations`) and runs
|
|
11
|
+
* against a `SequenceTimeline` BEFORE any store write; application lives in
|
|
12
|
+
* ./apply (`applySequenceOperation`) which maps one validated operation to
|
|
13
|
+
* `SequenceStore` calls. Keeping the union closed and frame-typed is what lets
|
|
14
|
+
* undo work: every operation has a computable inverse given the pre-state.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
interface PlaceClipOperation {
|
|
18
|
+
type: 'place_clip';
|
|
19
|
+
/** Omitted → first unlocked track matching the media kind. */
|
|
20
|
+
trackId?: string;
|
|
21
|
+
label: string;
|
|
22
|
+
startFrame: number;
|
|
23
|
+
durationFrames: number;
|
|
24
|
+
sourceInFrame?: number;
|
|
25
|
+
/** Explicit source out-point; null/omitted → natural end of the source.
|
|
26
|
+
* Carried so the durable inverse of a delete can restore a split clip's
|
|
27
|
+
* exact playable window. */
|
|
28
|
+
sourceOutFrame?: number | null;
|
|
29
|
+
/** Create the clip disabled; omitted → enabled. Carried so the durable
|
|
30
|
+
* inverse of deleting a disabled clip does not resurrect it visible. */
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
media?: {
|
|
33
|
+
url: string;
|
|
34
|
+
kind: 'video' | 'image' | 'audio';
|
|
35
|
+
};
|
|
36
|
+
generationId?: string;
|
|
37
|
+
assetId?: string;
|
|
38
|
+
metadata?: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
interface AddCaptionOperation {
|
|
41
|
+
type: 'add_caption';
|
|
42
|
+
text: string;
|
|
43
|
+
/** BCP-47 tag; omitted → sequence default language. */
|
|
44
|
+
language?: string;
|
|
45
|
+
/** Omitted → placed near the playhead via `chooseCaptionPlacement`. */
|
|
46
|
+
startFrame?: number;
|
|
47
|
+
durationFrames?: number;
|
|
48
|
+
/** Target caption track; omitted → first unlocked caption track, creating
|
|
49
|
+
* a per-language track when `language` names one that has none. */
|
|
50
|
+
trackId?: string;
|
|
51
|
+
}
|
|
52
|
+
interface MoveClipOperation {
|
|
53
|
+
type: 'move_clip';
|
|
54
|
+
clipId: string;
|
|
55
|
+
startFrame: number;
|
|
56
|
+
trackId?: string;
|
|
57
|
+
}
|
|
58
|
+
interface TrimClipOperation {
|
|
59
|
+
type: 'trim_clip';
|
|
60
|
+
clipId: string;
|
|
61
|
+
startFrame: number;
|
|
62
|
+
durationFrames: number;
|
|
63
|
+
/** New source in-point when trimming the head; omitted → unchanged. */
|
|
64
|
+
sourceInFrame?: number;
|
|
65
|
+
/** New source out-point; null releases it to the source's natural end;
|
|
66
|
+
* omitted → unchanged. Required when extending a clip whose stored window
|
|
67
|
+
* (e.g. a split head's cut point) is too short for the new duration, and
|
|
68
|
+
* by the durable inverse of `split_clip` to restore the original window. */
|
|
69
|
+
sourceOutFrame?: number | null;
|
|
70
|
+
}
|
|
71
|
+
interface SplitClipOperation {
|
|
72
|
+
type: 'split_clip';
|
|
73
|
+
clipId: string;
|
|
74
|
+
/** Sequence-frame to cut at; must fall strictly inside the clip. */
|
|
75
|
+
atFrame: number;
|
|
76
|
+
}
|
|
77
|
+
interface SetClipTextOperation {
|
|
78
|
+
type: 'set_clip_text';
|
|
79
|
+
clipId: string;
|
|
80
|
+
text: string;
|
|
81
|
+
language?: string;
|
|
82
|
+
}
|
|
83
|
+
interface SetClipDisabledOperation {
|
|
84
|
+
type: 'set_clip_disabled';
|
|
85
|
+
clipId: string;
|
|
86
|
+
disabled: boolean;
|
|
87
|
+
}
|
|
88
|
+
interface DeleteClipOperation {
|
|
89
|
+
type: 'delete_clip';
|
|
90
|
+
clipId: string;
|
|
91
|
+
}
|
|
92
|
+
interface CreateTrackOperation {
|
|
93
|
+
type: 'create_track';
|
|
94
|
+
kind: SequenceTrackKind;
|
|
95
|
+
name: string;
|
|
96
|
+
}
|
|
97
|
+
interface ExtendSequenceOperation {
|
|
98
|
+
type: 'extend_sequence';
|
|
99
|
+
durationFrames: number;
|
|
100
|
+
}
|
|
101
|
+
interface QueueExportOperation {
|
|
102
|
+
type: 'queue_export';
|
|
103
|
+
format: SequenceExportFormat;
|
|
104
|
+
metadata?: Record<string, unknown>;
|
|
105
|
+
}
|
|
106
|
+
type SequenceOperation = PlaceClipOperation | AddCaptionOperation | MoveClipOperation | TrimClipOperation | SplitClipOperation | SetClipTextOperation | SetClipDisabledOperation | DeleteClipOperation | CreateTrackOperation | ExtendSequenceOperation | QueueExportOperation;
|
|
107
|
+
/** A batch of operations with the agent's stated intent — the decision-log
|
|
108
|
+
* unit for agent edits. */
|
|
109
|
+
interface SequencePlan {
|
|
110
|
+
summary: string;
|
|
111
|
+
operations: SequenceOperation[];
|
|
112
|
+
}
|
|
113
|
+
type SequenceOperationType = SequenceOperation['type'];
|
|
114
|
+
declare const SEQUENCE_OPERATION_TYPES: readonly SequenceOperationType[];
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Pre-write validation for sequence operations. Every rule runs against a
|
|
118
|
+
* `SequenceTimeline` snapshot BEFORE any `SequenceStore` write, so a rejected
|
|
119
|
+
* plan leaves no partial state. Batch errors carry the shape
|
|
120
|
+
* `operation N (type): reason` — precise enough for an LLM planner to repair
|
|
121
|
+
* the offending operation and resubmit.
|
|
122
|
+
*
|
|
123
|
+
* The resolution helpers (`resolvePlaceClipTrack`, `resolveCaptionTarget`,
|
|
124
|
+
* `resolveCaptionPlacement`) are shared with ./apply so validation and
|
|
125
|
+
* application cannot disagree about which track or bounds an operation lands
|
|
126
|
+
* on.
|
|
127
|
+
*
|
|
128
|
+
* Validation is static: a batch is checked against the timeline as given, so
|
|
129
|
+
* an operation may not reference entities created by an earlier operation in
|
|
130
|
+
* the same batch. Dispatchers that chain operations must refresh the timeline
|
|
131
|
+
* between applications and validate per-operation.
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
/** Editor/agent context an operation is resolved against. `playheadFrame` is
|
|
135
|
+
* the implicit position for omitted caption placement; never persisted. */
|
|
136
|
+
interface SequenceOperationContext {
|
|
137
|
+
playheadFrame: number;
|
|
138
|
+
}
|
|
139
|
+
declare function validateSequenceOperations(timeline: SequenceTimeline, operations: SequenceOperation[], ctx: SequenceOperationContext): void;
|
|
140
|
+
declare function validateSequenceOperation(timeline: SequenceTimeline, operation: SequenceOperation, ctx: SequenceOperationContext): void;
|
|
141
|
+
declare function validatePlaceClip(timeline: SequenceTimeline, operation: PlaceClipOperation): void;
|
|
142
|
+
declare function validateAddCaption(timeline: SequenceTimeline, operation: AddCaptionOperation, ctx: SequenceOperationContext): void;
|
|
143
|
+
declare function validateMoveClip(timeline: SequenceTimeline, operation: MoveClipOperation): void;
|
|
144
|
+
declare function validateTrimClip(timeline: SequenceTimeline, operation: TrimClipOperation): void;
|
|
145
|
+
declare function validateSplitClip(timeline: SequenceTimeline, operation: SplitClipOperation): void;
|
|
146
|
+
declare function validateSetClipText(timeline: SequenceTimeline, operation: SetClipTextOperation): void;
|
|
147
|
+
declare function validateSetClipDisabled(timeline: SequenceTimeline, operation: SetClipDisabledOperation): void;
|
|
148
|
+
declare function validateDeleteClip(timeline: SequenceTimeline, operation: DeleteClipOperation): void;
|
|
149
|
+
declare function validateCreateTrack(operation: CreateTrackOperation): void;
|
|
150
|
+
declare function validateExtendSequence(timeline: SequenceTimeline, operation: ExtendSequenceOperation): void;
|
|
151
|
+
declare function validateQueueExport(operation: QueueExportOperation): void;
|
|
152
|
+
/**
|
|
153
|
+
* Shape-gate untrusted JSON (a product's `onApplyOperations` route body) into
|
|
154
|
+
* `SequenceOperation[]` BEFORE `validateSequenceOperations` sees it. The
|
|
155
|
+
* validator assumes well-typed fields (`label.trim()` on a number is a raw
|
|
156
|
+
* TypeError → 500); this parser turns junk into a thrown Error naming the
|
|
157
|
+
* operation index and field so the route can answer 400 with an actionable
|
|
158
|
+
* reason. Unknown fields are dropped — only vocabulary fields reach the
|
|
159
|
+
* validator and store.
|
|
160
|
+
*/
|
|
161
|
+
declare function parseSequenceOperations(input: unknown): SequenceOperation[];
|
|
162
|
+
type CaptionTargetResolution = {
|
|
163
|
+
kind: 'existing';
|
|
164
|
+
track: SequenceTrack;
|
|
165
|
+
} | {
|
|
166
|
+
kind: 'create';
|
|
167
|
+
language: string;
|
|
168
|
+
name: string;
|
|
169
|
+
};
|
|
170
|
+
/** Naming convention for auto-created per-language caption tracks. The name
|
|
171
|
+
* doubles as the recognition rule because `SequenceStore.createTrack` cannot
|
|
172
|
+
* persist track metadata — matching by `metadata.language` alone would never
|
|
173
|
+
* find tracks this module created. */
|
|
174
|
+
declare function captionTrackNameForLanguage(language: string): string;
|
|
175
|
+
/** Target track for a `place_clip`. Video and image media land on video
|
|
176
|
+
* tracks, audio media on audio tracks; a `reference` track is valid only when
|
|
177
|
+
* targeted explicitly. Media-less clips (placeholders, agent markers) need an
|
|
178
|
+
* explicit trackId because no kind can be inferred. */
|
|
179
|
+
declare function resolvePlaceClipTrack(timeline: SequenceTimeline, operation: PlaceClipOperation): SequenceTrack;
|
|
180
|
+
/** Target caption track for an `add_caption`. With `language` set and no
|
|
181
|
+
* matching caption track, resolution returns a `create` instruction the apply
|
|
182
|
+
* layer turns into a real track — a locked matching track is an error, never
|
|
183
|
+
* a silent duplicate. */
|
|
184
|
+
declare function resolveCaptionTarget(timeline: SequenceTimeline, operation: AddCaptionOperation): CaptionTargetResolution;
|
|
185
|
+
/** Caption bounds. Fully omitted placement slides past occupied intervals via
|
|
186
|
+
* `chooseCaptionPlacement`; a partially explicit placement fills the missing
|
|
187
|
+
* half deterministically (startFrame ← playhead, durationFrames ← fps*3) and
|
|
188
|
+
* must pass the caller's bounds check — no collision slide. */
|
|
189
|
+
declare function resolveCaptionPlacement(timeline: SequenceTimeline, operation: AddCaptionOperation, ctx: SequenceOperationContext, targetTrackId: string | null): TimelineClipBounds;
|
|
190
|
+
/** Last occupied frame across all clips — the floor for `extend_sequence`. */
|
|
191
|
+
declare function lastClipEndFrame(timeline: SequenceTimeline): number;
|
|
192
|
+
/** Media references must be provider URLs or app-served paths. Local sandbox
|
|
193
|
+
* artifacts (file:, data:, /tmp/, /home/) are rejected because they are
|
|
194
|
+
* unreachable from the product and signal an agent substituting local ffmpeg
|
|
195
|
+
* output for real provider generation. */
|
|
196
|
+
declare function assertSequenceMediaUrl(url: string): void;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Maps one validated `SequenceOperation` to `SequenceStore` calls and reports
|
|
200
|
+
* what changed. Each call re-validates its single operation against the
|
|
201
|
+
* provided timeline — a dispatcher that skips batch validation still cannot
|
|
202
|
+
* reach the store with an invalid write. The timeline must be the CURRENT
|
|
203
|
+
* state: dispatchers applying a batch refresh it between operations so later
|
|
204
|
+
* operations can reference entities earlier ones created.
|
|
205
|
+
*
|
|
206
|
+
* Split assumes source frames advance 1:1 with sequence frames (the model
|
|
207
|
+
* addresses source in/out points at sequence fps); time-remapped clips are
|
|
208
|
+
* outside this operation vocabulary.
|
|
209
|
+
*/
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* The entity an operation changed, for the MCP layer to serialize back to the
|
|
213
|
+
* agent. Conventions for multi-entity operations:
|
|
214
|
+
* - `split_clip` returns the newly created second half (the first half is the
|
|
215
|
+
* original clip id with a shortened duration).
|
|
216
|
+
* - `delete_clip` returns the pre-delete clip snapshot.
|
|
217
|
+
*/
|
|
218
|
+
type SequenceApplyResult = {
|
|
219
|
+
kind: 'clip';
|
|
220
|
+
clip: SequenceClip;
|
|
221
|
+
} | {
|
|
222
|
+
kind: 'track';
|
|
223
|
+
track: SequenceTrack;
|
|
224
|
+
} | {
|
|
225
|
+
kind: 'export';
|
|
226
|
+
record: SequenceExportRecord;
|
|
227
|
+
} | {
|
|
228
|
+
kind: 'sequence';
|
|
229
|
+
sequence: SequenceMeta;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* The batch path every dispatcher (the MCP tools, a product's editor
|
|
233
|
+
* persistence route) funnels through: fetch the timeline, validate the WHOLE
|
|
234
|
+
* batch against pre-state, then apply in order with a timeline refresh between
|
|
235
|
+
* operations — later operations must see earlier writes (the static-validation
|
|
236
|
+
* boundary in ./validate).
|
|
237
|
+
*
|
|
238
|
+
* Atomicity contract: validation throws (before the first store write) leave
|
|
239
|
+
* the sequence untouched. Store-layer throws after at least one successful
|
|
240
|
+
* write leave a prefix-committed state — operations 1..N-1 are persisted,
|
|
241
|
+
* operations N..end are not. The store is non-transactional (SQLite D1);
|
|
242
|
+
* callers that receive a partial-commit throw must treat the result as partial
|
|
243
|
+
* success, not a full rollback. Decision-log rows are the caller's job: the
|
|
244
|
+
* MCP layer records `agent_edit`, an editor route records `human_edit`.
|
|
245
|
+
*/
|
|
246
|
+
declare function applySequenceOperations(store: SequenceStore, operations: SequenceOperation[], ctx: SequenceOperationContext): Promise<SequenceApplyResult[]>;
|
|
247
|
+
declare function applySequenceOperation(store: SequenceStore, timeline: SequenceTimeline, op: SequenceOperation, ctx: SequenceOperationContext): Promise<SequenceApplyResult>;
|
|
248
|
+
|
|
249
|
+
export { type AddCaptionOperation as A, validateSequenceOperations as B, type CaptionTargetResolution as C, type DeleteClipOperation as D, type ExtendSequenceOperation as E, validateSetClipDisabled as F, validateSetClipText as G, validateSplitClip as H, validateTrimClip as I, type MoveClipOperation as M, type PlaceClipOperation as P, type QueueExportOperation as Q, SEQUENCE_OPERATION_TYPES as S, type TrimClipOperation as T, type CreateTrackOperation as a, type SequenceApplyResult as b, type SequenceOperation as c, type SequenceOperationContext as d, type SequenceOperationType as e, type SequencePlan as f, type SetClipDisabledOperation as g, type SetClipTextOperation as h, type SplitClipOperation as i, applySequenceOperation as j, applySequenceOperations as k, assertSequenceMediaUrl as l, captionTrackNameForLanguage as m, lastClipEndFrame as n, resolveCaptionTarget as o, parseSequenceOperations as p, resolvePlaceClipTrack as q, resolveCaptionPlacement as r, validateCreateTrack as s, validateDeleteClip as t, validateExtendSequence as u, validateAddCaption as v, validateMoveClip as w, validatePlaceClip as x, validateQueueExport as y, validateSequenceOperation as z };
|