@melite/models-h3 0.2.2-alpha → 0.3.0-alpha

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/lib/swap.js CHANGED
@@ -1,4 +1,5 @@
1
- import { loadVideo, renderMaskedEditChain } from './chainEdit.js';
1
+ import { resolveCarryOverlap } from './timelineContract.js';
2
+ import { contexMaskedTarget, loadVideo, renderMaskedEditChain, resolvePlanTier, sheetRefSlots } from './chainEdit.js';
2
3
  /** The swap entry's required media + text seats (the reshoot idiom:
3
4
  * an armed doc with an empty seat refuses loud naming the seat). */
4
5
  const REQUIRED_SEATS = [
@@ -8,8 +9,40 @@ const REQUIRED_SEATS = [
8
9
  ['mask', 'ONE staged PNG from the track-card run — the pixel-max UNION of its grown per-frame masks is recommended (per-frame motion rides the mannequin; the edit-latent + masked-target mask, reference GrowMaskWithBlur expand 40)'],
9
10
  ['swap_prompt', 'the swap action text (agent-composed, user-confirmed — the R2V prompt seat; the estate has no in-graph describers)'],
10
11
  ];
11
- const str = (p, k) => typeof p[k] === 'string' ? p[k] : '';
12
- const num = (p, k, d) => typeof p[k] === 'number' ? p[k] : d;
12
+ /** Reads one required seat NARROWED by its own refusal — the seat
13
+ * is a string or the door never composes (no fallback arm exists:
14
+ * a validated seat re-read through a forgiving helper would be a
15
+ * second, weaker validator below the law — a silent error). */
16
+ const requiredSeat = (entry, seat, what) => {
17
+ const v = entry[seat];
18
+ if (typeof v !== 'string' || v.trim() === '') {
19
+ throw new Error(`h3-timeline replace: '${seat}' names no media — ${what}; a swap needs all five seats bound (source_clip, still, mannequin, mask, swap_prompt)`);
20
+ }
21
+ return v;
22
+ };
23
+ /** An optional number seat: absent falls to the documented default;
24
+ * a stated non-number REFUSES — a defaulting fallback would swallow
25
+ * a bypassed door's wrong-typed value as a silent error. */
26
+ const statedNumber = (p, k, d) => {
27
+ const v = p[k];
28
+ if (v === undefined)
29
+ return d;
30
+ if (typeof v !== 'number' || !Number.isFinite(v)) {
31
+ throw new Error(`h3-timeline replace: '${k}' is stated as ${JSON.stringify(v)} — a number seat carries a number (absent falls to ${d}); a wrong-typed value never silently defaults`);
32
+ }
33
+ return v;
34
+ };
35
+ /** An optional text seat: absent is the lawful unstated ('' rides
36
+ * on); a stated non-string REFUSES. */
37
+ const seatString = (p, k) => {
38
+ const v = p[k];
39
+ if (v === undefined)
40
+ return '';
41
+ if (typeof v !== 'string') {
42
+ throw new Error(`h3-timeline replace: '${k}' is stated as ${JSON.stringify(v)} — a text seat carries text; a wrong-typed value never silently reads as unbound`);
43
+ }
44
+ return v;
45
+ };
13
46
  /** The swap renderer: validates the bound entry, then composes the
14
47
  * masked-edit chain per the reference map above. The film path
15
48
  * never reaches here (the card branches ONLY on a non-empty replace
@@ -21,73 +54,69 @@ const num = (p, k, d) => typeof p[k] === 'number' ? p[k] : d;
21
54
  * @param g the run's graph builder
22
55
  * @param runId the run tree's id (the assemble filename rides it) */
23
56
  export function renderH3Swap(entry, p, facts, g, runId) {
24
- for (const [seat, what] of REQUIRED_SEATS) {
25
- const v = entry[seat];
26
- if (typeof v !== 'string' || v.trim() === '') {
27
- throw new Error(`h3-timeline replace: '${seat}' names no media — ${what}; a swap needs all five seats bound (source_clip, still, mannequin, mask, swap_prompt)`);
28
- }
29
- }
57
+ // NO FALLBACK READS: every required seat narrows through its own
58
+ // refusal; optional seats refuse wrong-typed stated values.
59
+ const sourceClipSeat = requiredSeat(entry, 'source_clip', REQUIRED_SEATS[0][1]);
60
+ const stillSeat = requiredSeat(entry, 'still', REQUIRED_SEATS[1][1]);
61
+ const mannequinSeat = requiredSeat(entry, 'mannequin', REQUIRED_SEATS[2][1]);
62
+ const maskSeat = requiredSeat(entry, 'mask', REQUIRED_SEATS[3][1]);
63
+ const swapPromptSeat = requiredSeat(entry, 'swap_prompt', REQUIRED_SEATS[4][1]);
30
64
  const keepAudio = entry.keep_audio !== false;
31
- const seed = num(entry, 'seed', 0);
32
- const steps = num(entry, 'steps', 6);
33
- const clipSeconds = num(entry, 'clip_seconds', 6);
34
- const resolution = str(entry, 'resolution') || '736p';
65
+ const seed = statedNumber(entry, 'seed', 0);
66
+ const steps = statedNumber(entry, 'steps', 6);
67
+ const clipSeconds = statedNumber(entry, 'clip_seconds', 6);
68
+ const resolution = resolvePlanTier(entry, p);
35
69
  // ── the staged media (the R0 cards' artifacts: the source clip,
36
70
  // the still, the track card's mannequin + grown mask) ──
37
- const [srcFrames, srcAudio] = loadVideo(g, str(entry, 'source_clip'));
38
- const stillImg = g.node('LoadImage', { image: str(entry, 'still') }).out(0);
71
+ const [srcFrames, srcAudio] = loadVideo(g, sourceClipSeat);
72
+ const stillImg = g.node('LoadImage', { image: stillSeat }).out(0);
39
73
  const maskOf = g.node('ImageToMask', {
40
- image: g.node('LoadImage', { image: str(entry, 'mask') }).out(0),
74
+ image: g.node('LoadImage', { image: maskSeat }).out(0),
41
75
  channel: 'red',
42
76
  }).out(0);
43
- const [mannequin] = loadVideo(g, str(entry, 'mannequin'));
77
+ const [mannequin] = loadVideo(g, mannequinSeat);
44
78
  renderMaskedEditChain(g, {
45
79
  p, facts,
46
80
  clipSeconds,
47
- overlapFrames: num(entry, 'overlap_frames', 39),
81
+ overlapFrames: resolveCarryOverlap(entry),
48
82
  resolution, seed, steps,
49
- roles: str(entry, 'roles'),
50
- sourceClip: str(entry, 'source_clip'),
83
+ roles: seatString(entry, 'roles'),
84
+ sourceClip: sourceClipSeat,
51
85
  windowStart: 0,
52
86
  picture1: stillImg,
53
87
  srcFrames, srcAudio,
54
88
  // the ignored literal fallback — the plan node's SOURCE-SLICED
55
89
  // shots ride plan_json_input (the swap's own semantics)
56
- planJson: JSON.stringify({ shots: [{ id: 'swap', prompt: str(entry, 'swap_prompt') }] }),
90
+ planJson: JSON.stringify({ shots: [{ id: 'swap', prompt: swapPromptSeat }] }),
57
91
  planFromSource: true,
58
92
  denoise: 1,
59
93
  assemble: {
60
94
  audioSource: keepAudio ? 'source' : 'generated',
61
95
  filename: `${runId}/swap`,
62
96
  },
63
- body: ({ cur, clip, vaeVideo, vaeAudio, mutedChainAudio, sliceAudio }) => {
97
+ body: ({ cur, clip, vaeVideo, vaeAudio, mutedChainAudio, sliceAudio, refImages }) => {
64
98
  // ── the masked edit body: the still anchors identity, the
65
99
  // mannequin carries motion, the staged PNG masks the edit ──
66
100
  const r2v = g.node('MiniMaxH3ReferenceToVideo', {
67
- prompt: str(entry, 'swap_prompt'),
101
+ prompt: swapPromptSeat,
68
102
  width: cur.out(8), height: cur.out(9), length: cur.out(6),
69
103
  ref_image_size: 'match',
70
104
  clip, vae: vaeVideo, audio_vae: vaeAudio,
71
105
  'ref_images.ref_image_0': stillImg,
72
106
  'ref_videos.ref_video_0': mannequin,
73
107
  'ref_video_audios.ref_video_audio_0': mutedChainAudio,
108
+ // THE SHEET (P0-1): the still owns slot 0 — the declared
109
+ // sheet follows it, the same input-slot grammar as gen.
110
+ ...sheetRefSlots(refImages, 1),
74
111
  });
75
112
  const slice = g.node('H3SourceSlice', {
76
113
  source_fps: 24, crop: 'center',
77
114
  state: cur.out(0), latent: r2v.out(1),
78
115
  audio_vae: vaeAudio, source_frames: srcFrames, source_audio: sliceAudio,
79
116
  });
80
- const edit = g.node('MiniMaxH3FantasticVideoEditLatent', {
81
- grow: 0, keep_audio: keepAudio, megapixels: 0,
82
- vae: vaeVideo, images: slice.out(0), mask: maskOf,
83
- audio_vae: vaeAudio, audio: slice.out(1),
84
- }).out(0);
85
- const target = g.node('MiniMaxH3ContexMaskedTarget', {
86
- mask_meaning: 'white = generate',
87
- audio_mode: keepAudio ? 'preserve source audio' : 'generate all audio',
88
- mask_conversion: 'H3 exact (causal/token max)',
89
- target_latent: edit, mask: maskOf,
90
- }).out(0);
117
+ const target = contexMaskedTarget(g, { vaeVideo, vaeAudio }, {
118
+ frames: slice.out(0), audio: slice.out(1), mask: maskOf, keepAudio,
119
+ });
91
120
  return { conditioning: r2v.out(0), targetLatent: target };
92
121
  },
93
122
  });
@@ -1,20 +1,83 @@
1
+ /** The frames of generated context a carried seam contributes — the
2
+ * generation head a non-cut join rides (a carried window's authored
3
+ * span excludes it; its render includes it). */
1
4
  export declare const SEAM_OVERLAP_FRAMES = 22;
5
+ /** The window grid's floor and first rung: every legal length is BASE + STEP·k. */
2
6
  export declare const GRID_BASE_FRAMES = 22;
7
+ /** The window grid's rung spacing: legal lengths advance 17 frames per step. */
3
8
  export declare const GRID_STEP_FRAMES = 17;
9
+ /** The window grid's ceiling: no window renders more than 362 frames. */
4
10
  export declare const GRID_MAX_FRAMES = 362;
11
+ /** The generated-length residue: a carried window renders 17k + 22 ≡ 5
12
+ * (mod 17) frames — the "% 17 == 5" the engine's own refusals name. */
5
13
  export declare const GRID_REMAINDER = 5;
14
+ /** The conditioning image bus's slot count (bundle inputs 3–9). */
6
15
  export declare const IMAGE_BUS_SLOTS = 9;
16
+ /** The family's LAST-FRAME PICK spelling (one home, both readers —
17
+ * extend.ts's anchor and the seam's keyframe carry): a positive
18
+ * out-of-band batch index the engine clamps onto the clip's FINAL
19
+ * row (min(shape−1, index)) under every build; the negative
20
+ * spelling slices empty on the live estate and is banned
21
+ * family-wide. */
22
+ export declare const LAST_FRAME_BATCH_INDEX = 16384;
23
+ /** Per-media reference caps — the max stack each declared ref lane admits. */
7
24
  export declare const REF_CAPS: {
8
25
  readonly images: 8;
9
26
  readonly videos: 3;
10
27
  readonly audios: 3;
11
28
  readonly refmods: 8;
12
29
  };
30
+ /** THE AV-CONTINUITY LAW, one TS home (defect board row 4, the
31
+ * "derive the carry value" rider). The engine's own vocabulary is
32
+ * AV_TRANSITION_CONTEXT_LENGTHS = (39, 90, 141, 192, 243)
33
+ * (vendor/comfyui_extensions/ComfyUI-MiniMaxH3-Context-Loop/
34
+ * contracts_v05.py:55); on a generated-audio carry join (the edit
35
+ * chain's own mode — context > 0) any other positive boundary
36
+ * refuses AT THE NODE, eight graphs deep
37
+ * (run-1f91718b7cde: "H3 AV generated-audio continuity requires an
38
+ * exact shared video/audio boundary: 39, 90, 141, 192, or 243
39
+ * context frames"). The compose door judges THIS vocabulary at zero
40
+ * GPU so no agent ever discovers it by a burned run; 0 (the cut
41
+ * join, carry: false — the engine's own "cut / independent" preset,
42
+ * contracts_v05.py:158-162) is the one legal value outside it. */
43
+ export declare const AV_CONTINUITY_OVERLAPS: readonly [39, 90, 141, 192, 243];
44
+ /** The derived carry join (defect board row 4: "join with the same
45
+ * overlap" — the smallest legal boundary, the least context spent;
46
+ * the engine's own reference value and the chain's historical
47
+ * default, now DERIVED instead of typed). */
48
+ export declare const CARRY_JOIN_OVERLAP = 39;
49
+ /** The carry statement's admission (defect board row 4: "expose
50
+ * exactly one new concept — carry: true"). ABSENT = carry, THE
51
+ * DEFAULT — the gen seam's own law (docModel.ts: "'extend'
52
+ * (ABSENT = carry, THE DEFAULT)"): the film splits on its own
53
+ * timeline and every segment continues from the last frame of the
54
+ * previous. Stated false = the cut join (each segment stands
55
+ * alone; the engine's cut preset, context 0).
56
+ * @param entry the edit-bag entry carrying the carry seat
57
+ * @returns true when segments join with context carry */
58
+ export declare function entryCarries(entry: Record<string, unknown>): boolean;
59
+ /** THE CARRY-OVERLAP RESOLVER (defect board row 4 — the door the
60
+ * operator asked for five times): the join boundary is DERIVED from
61
+ * the engine's AV-continuity vocabulary, never hand-typed. Unstated
62
+ * → the derived 39 (carry on) or 0 (carry: false); an explicitly
63
+ * stated overlap_frames — the expert override, served on AUTHORED
64
+ * seams' context_length (the plan head itself carries only the
65
+ * AV-legal 39; see chainEdit's planOverlapFeed) — must be 0 or one
66
+ * of the five legal boundaries and REFUSES HERE, at the compose
67
+ * door, quoting the engine's law and naming the stated value, so
68
+ * the run-1f91718b7cde class (a boundary typed legal-looking,
69
+ * refused eight nodes deep) is dead at zero GPU.
70
+ * @param entry the edit-bag entry (overlap_frames / carry seats)
71
+ * @returns the join boundary in frames: 0, 39, 90, 141, 192 or 243 */
72
+ export declare function resolveCarryOverlap(entry: Record<string, unknown>): number;
73
+ /** One authored window in film frames: half-open [start, end), with
74
+ * the seam its join carries (undefined = the carry default). */
13
75
  export interface TimelineSpan {
14
76
  readonly start: number;
15
77
  readonly end: number;
16
78
  readonly transition?: string;
17
79
  }
80
+ /** The calls-row spelling of a window: start/end_frame plus the seam. */
18
81
  export interface TimelineCallSpan {
19
82
  readonly start_frame: number;
20
83
  readonly end_frame: number;
@@ -28,7 +91,14 @@ export interface TimelineCallSpan {
28
91
 
29
92
 
30
93
 
94
+
95
+
31
96
  export declare function isMediaRef(v: string): boolean;
97
+ /** The context frames a seam carries: 0 for the cut join, the
98
+ * SEAM_OVERLAP_FRAMES generation head for any other transition
99
+ * (unstated included — carry is the default).
100
+ * @param transition the seam a call states (undefined = carry)
101
+ * @returns the join's context overlap in frames */
32
102
  export declare function transitionOverlap(transition?: string): number;
33
103
 
34
104
 
@@ -49,6 +119,14 @@ export declare function transitionOverlap(transition?: string): number;
49
119
 
50
120
 
51
121
  export declare const DOC_FPS_DEFAULT: 24;
122
+ /** The doc's LENGTH row default — the schema row's own (56f, the
123
+ * engine grid's design window 22+17·2), the same seed the walk
124
+ * fills for span-less calls. One owner, the same law as
125
+ * DOC_FPS_DEFAULT: the studio's axis fallback reads THIS, never a
126
+ * second literal (the D-19 cure retired the `: 1` collapse — an
127
+ * empty-calls axis books the doc's own plan floor, never a
128
+ * 1-frame sliver strip). */
129
+ export declare const DOC_LENGTH_DEFAULT: 56;
52
130
 
53
131
 
54
132
 
@@ -140,8 +218,23 @@ export declare const FAMILY_LAW: {
140
218
 
141
219
 
142
220
  export declare function deriveWindowFamily(raw: Record<string, unknown>): 't4r' | 't4_open' | 't4_chain';
221
+ /** A span's join overlap — transitionOverlap over the span's own seam.
222
+ * @param span the authored window
223
+ * @returns the window's context overlap in frames */
143
224
  export declare function spanOverlap(span: TimelineSpan): number;
225
+ /** The window's render length on the engine grid: the span plus its
226
+ * carry, snapped to 22+17k inside [22,362]. Off-grid spans snap;
227
+ * doors that must refuse use assertSpanGrid instead.
228
+ * @param span the authored window
229
+ * @param carry the seam overlap the window rides (0 for first/cut)
230
+ * @returns the grid-legal generated length in frames */
144
231
  export declare function spanStanzaFrames(span: TimelineSpan, carry?: number): number;
232
+ /** A carried window's grid geometry: the generated start (span.start −
233
+ * carry), the snapped generated length, and the two neighboring legal
234
+ * end frames a refusal names.
235
+ * @param span the authored carried window (span = 17k content frames)
236
+ * @param carry the seam overlap (the SEAM_OVERLAP_FRAMES default)
237
+ * @returns the snapped geometry — never a legality verdict */
145
238
  export interface CarriedSpanGrid {
146
239
  readonly generatedStart: number;
147
240
  readonly generatedEnd: number;
@@ -149,25 +242,143 @@ export interface CarriedSpanGrid {
149
242
  readonly lowerEnd: number;
150
243
  readonly upperEnd: number;
151
244
  }
245
+ /** Compute a carried window's grid geometry without judging it: the
246
+ * generated start, the snapped length, and the neighboring legal ends.
247
+ * @param span the authored carried window
248
+ * @param carry the seam overlap (the SEAM_OVERLAP_FRAMES default)
249
+ * @returns the CarriedSpanGrid for the window */
152
250
  export declare function carriedSpanGrid(span: TimelineSpan, carry?: number): CarriedSpanGrid;
251
+ /** The carried window's admission gate: the snapped grid length must
252
+ * equal the requested span+carry exactly; anything else refuses loud
253
+ * naming the authored range, the snapped range, and the legal
254
+ * neighboring end frames.
255
+ * @param span the authored carried window
256
+ * @param where the refusal's voice (the calling door's name)
257
+ * @param carry the seam overlap (the SEAM_OVERLAP_FRAMES default)
258
+ * @returns the grid-legal generated length in frames */
153
259
  export declare function assertCarriedSpanGrid(span: TimelineSpan, where: string, carry?: number): number;
154
260
  /** The booked render clock, one home: the seconds seat rounds its
155
261
  * quotient to milliseconds before it rides the wire, so every
156
262
  * consumer that needs the value the graph will actually carry (the
157
263
  * schema's own rail bounds, the mix ledger) books through here —
158
- * never a second copy of the rounding. */
264
+ * never a second copy of the rounding.
265
+ * @param lengthFrames the window's generated length
266
+ * @param fps the doc's playback clock
267
+ * @returns the length in seconds, rounded to milliseconds */
159
268
  export declare function bookSeconds(lengthFrames: number, fps: number): number;
269
+ /** The nearest legal 22+17k length (round to the rung, clamp into
270
+ * [22,362]) — the "nearest legal" value refusal voices quote.
271
+ * @param length the requested length in frames
272
+ * @returns the nearest grid-legal length */
160
273
  export declare function gridSnap(length: number): number;
161
274
  /** THE GRID PREDICATE, one owner: a length the engine can render is
162
275
  * 22+17k inside [22,362]. Every refusal door asks this question, so
163
276
  * knob pins, single windows, cut windows, and carried windows cannot
164
- * drift into different laws. */
277
+ * drift into different laws.
278
+ * @param length the candidate length in frames
279
+ * @returns true when length is 22+17k inside [22,362] */
165
280
  export declare function isGridLength(length: number): boolean;
281
+ /** The grid admission gate: a non-number or off-grid length refuses
282
+ * naming the nearest legal value; a legal length passes verbatim.
283
+ * @param length the value under admission (a number is required)
284
+ * @param where the refusal's voice (the calling door's name)
285
+ * @returns the length, verbatim */
166
286
  export declare function assertGridLength(length: unknown, where: string): number;
167
287
  /** The chain policy's masked_av context — the overlap every composed
168
288
  * seam after the first carries (the swap's clip law, shared with the
169
289
  * extend's window composition). */
170
290
  export declare const CONTEXT_OVERLAP_FRAMES = 39;
291
+ /** The three carry states a split seat states (§0.9's vocabulary,
292
+ * the same three the call card's seam seat and the strip head's
293
+ * carry menu serve). */
294
+ export type SplitCarry = 'cut' | 'extend' | 'carry+keyframe';
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+ /** Is this window's seam a carried join? Index-aware — index 0 is
313
+ * always a first window (no carry), and a 'cut' seam never
314
+ * carries.
315
+ * @param index the window's position in the calls array (0-based)
316
+ * @param call the window's own row (its transition seat)
317
+ * @returns true when the seam rides the carry join */
318
+ export declare function isCarriedShape(index: number, call: Pick<TimelineCallSpan, 'transition'>): boolean;
319
+ /** Is this authored LENGTH legal for the window's shape? A carried
320
+ * window rides the 17k step (content + 22f carry head ≤ 362); a
321
+ * first/cut window rides the 22+17k grid.
322
+ * @param length the authored length in frames
323
+ * @param carried true when the window is a carried join
324
+ * @returns true when the shape's own grid admits the length */
325
+ export declare function isLegalCallLength(length: number, carried: boolean): boolean;
326
+ /** The splice frame for a split where BOTH halves must be legal —
327
+ * the gesture's frame when it already qualifies, else the nearest
328
+ * one that does. NULL when no interior frame qualifies (the §0.5
329
+ * fence): a window at its shape's floor has no legal split at all
330
+ * — the caller refuses loud, never repairs.
331
+ * @param start the containing window's first frame
332
+ * @param end the containing window's end frame
333
+ * @param leftCarried whether the left half keeps the carried shape
334
+ * @param rightCarried whether the right half takes the carried shape
335
+ * @param gesture the frame the split was asked at
336
+ * @returns the legal frame nearest the gesture, or null */
337
+ export declare function snapSplitFrame(start: number, end: number, leftCarried: boolean, rightCarried: boolean, gesture: number): number | null;
338
+ /** The seam toggle's re-frame: the 22-frame carry moves from the
339
+ * generation head to (or from) the authored span. A first window
340
+ * has no carry either way, so its toggle never moves frames.
341
+ * @param call the window row the toggle re-frames
342
+ * @param index the window's position in the calls array (0-based)
343
+ * @param next the seam state after the toggle
344
+ * @returns the window's re-framed end frame */
345
+ export declare function reflowSeamSpan(call: Pick<TimelineCallSpan, 'start_frame' | 'end_frame' | 'transition'>, index: number, next: 'extend' | 'cut' | 'carry+keyframe'): number;
346
+ /** Split the doc's calls at a gesture frame with a selected carry —
347
+ * §0.5's split, verbatim: the gesture frame snaps to the authoring
348
+ * lattice, one window becomes its own two halves (the row carries
349
+ * whole into both; the seam the split births states CUT), everything
350
+ * downstream rebases, and a selected carry mode re-frames the NEW
351
+ * seam. A gesture with no legal split frame REFUSES (null): the doc
352
+ * keeps its identity. Generic over the row: the rest of the call
353
+ * (text, refs, knobs, anchors) carries whole by construction.
354
+ * @param calls the doc's own windows (the calls rows)
355
+ * @param gestureFrame the frame the split is asked at (doc space)
356
+ * @param carry the seam state the NEW split births after the stock
357
+ * cut ("cut" keeps the split's own default seam)
358
+ * @returns the next calls array, or null when no legal split exists. */
359
+ export declare function splitCallsAt<T extends TimelineCallSpan>(calls: T[], gestureFrame: number, carry: SplitCarry): T[] | null;
360
+ /** THE CUTS VERB'S OUTCOME — the rows, or the loud refusal (never a
361
+ * silent drop, never a repair behind the caller's back). */
362
+ export type CutsResult<T extends TimelineCallSpan> = {
363
+ ok: true;
364
+ calls: T[];
365
+ } | {
366
+ ok: false;
367
+ refusal: string;
368
+ };
369
+ /** THE CUTS VERB (the agent's door into the one storage): seconds,
370
+ * never frame math (the run-e79f3b304e4b law — hand-typed frames
371
+ * repaired 90 of 243 frames once). "2.5, 5" splits the containing
372
+ * windows at those seconds — each fold rides splitCallsAt, so the
373
+ * verb IS the split law, not a second arithmetic. The seconds
374
+ * spelling never persists: every write door expands it into the
375
+ * calls rows and drops it (ONE storage; a lingering cuts key on a
376
+ * doc is a bug, refused by the walk).
377
+ * @param calls the doc's own windows the verb splits
378
+ * @param cuts the comma-separated seconds ("2.5, 5")
379
+ * @param carry the seam state every new seam births
380
+ * @returns the next calls array, or the refusal naming the cure. */
381
+ export declare function expandCuts<T extends TimelineCallSpan>(calls: T[], cuts: string, carry?: SplitCarry): CutsResult<T>;
171
382
  /** The plan's scene cap (chain_nodes: a 32-scene cap refuses
172
383
  * mis-authored loops) — the composition solver's window ceiling. */
173
384
  export declare const MAX_COMPOSED_WINDOWS = 32;
@@ -202,15 +413,54 @@ export declare function solveWindowComposition(totalFrames: number, where: strin
202
413
 
203
414
 
204
415
 
416
+
417
+
418
+
419
+
205
420
  export declare function assertSpanGrid(span: TimelineSpan, where: string, carry?: number): number;
421
+ /** The frames a window contributes to the delivered film: a first or
422
+ * cut window contributes its span verbatim; a carried window nets
423
+ * out the SEAM_OVERLAP_FRAMES it shares with the previous window.
424
+ * @param call the window row
425
+ * @param index the window's position in the calls array (0-based)
426
+ * @returns the delivered frame count (never negative) */
206
427
  export declare function deliveredFrames(call: TimelineCallSpan, index: number): number;
428
+ /** The image-bus seats available to loose references: a last-frame
429
+ * pin spends one of the REF_CAPS.images seats when it is set.
430
+ * @param hasLastFrame whether a last-frame pin occupies the bus
431
+ * @returns the maximum reference-image stack */
207
432
  export declare function imageReferenceCap(hasLastFrame: boolean): number;
433
+ /** Split a comma-separated reference string into entries, trimming
434
+ * separators and surrounding spaces; a data: URI's mime comma does
435
+ * not split its entry.
436
+ * @param value the wire spelling (undefined = no refs)
437
+ * @returns the entries, in order, without empties */
208
438
  export declare function splitRefList(value: string | undefined): string[];
439
+ /** A declared ref seat's entries, either wire spelling: an array
440
+ * passes its non-empty strings; a comma string rides splitRefList;
441
+ * any other value is zero refs.
442
+ * @param value the ref seat's raw value
443
+ * @returns the reference entries, in order */
209
444
  export declare function normalizeDeclaredRefs(value: unknown): string[];
445
+ /** The inverse wire spelling: entries join into one ", "-separated
446
+ * string; empty input yields undefined (no seat, never an empty string).
447
+ * @param value an array of entries, a string, or absent
448
+ * @returns the joined string, or undefined when nothing is stated */
210
449
  export declare function joinRefList(value: unknown): string | undefined;
450
+ /** A reference's media genre: the engine's video_w* naming first (its
451
+ * _last_frame/_prev faces are images), else the extension of the name
452
+ * or the URL's path (?path= decoded wins), else 'other'.
453
+ * @param name the entry's file name
454
+ * @param url the entry's URL, when one rides
455
+ * @returns 'image' | 'video' | 'audio' | 'other' */
211
456
  export declare function refGenreOf(name: string, url?: string): 'image' | 'video' | 'audio' | 'other';
457
+ /** The per-call knob vocabulary in serve order — the studio renders a
458
+ * call's knob rows in this order; KnobKey and CALL_KNOB_KEYS derive
459
+ * from it. */
212
460
  export declare const KNOB_ORDER: readonly ["steps", "denoise", "sampler_name", "sched_name", "shift_video", "shift_audio", "sla_sparsity", "sla_block_size", "sla_min_seq_len", "sla_dense_last_steps", "sla_protect_audio", "sla_stabilize_motion", "sla_reference_protection", "sla_dense_backend", "sla_dense_steps", "sla_disable_fp16_accum", "sharpen_enabled", "sharpen_method", "sharpen_strength", "sharpen_radius", "sharpen_threshold", "sharpen_iterations", "interpolate_enabled", "interp_model", "interp_multiplier", "length"];
461
+ /** One per-call knob key — a member of KNOB_ORDER. */
213
462
  export type KnobKey = (typeof KNOB_ORDER)[number];
463
+ /** The admitted per-call knob keys — KNOB_ORDER as a membership set. */
214
464
  export declare const CALL_KNOB_KEYS: ReadonlySet<string>;
215
465
 
216
466
 
@@ -228,6 +478,21 @@ export declare const SECOND_PASS_KNOBS: ReadonlySet<string>;
228
478
 
229
479
 
230
480
  export declare const CALL_KEYS: ReadonlySet<string>;
481
+
482
+
483
+
484
+
485
+
486
+
487
+
488
+
489
+
490
+
491
+
492
+
493
+ export declare const CALL_TRANSITIONS: readonly ["cut", "extend", "carry+keyframe"];
494
+ /** Legacy knob spellings → their current knob keys (a stored row
495
+ * carrying the left column reads under the right). */
231
496
  export declare const LEGACY_KNOB_KEY: {
232
497
  readonly sampling_steps: "steps";
233
498
  readonly sampler: "sampler_name";
@@ -245,5 +510,9 @@ export declare const LEGACY_KNOB_KEY: {
245
510
  readonly interpolate_model: "interp_model";
246
511
  readonly interpolate_multiplier: "interp_multiplier";
247
512
  };
513
+ /** Map a legacy knob spelling to its current knob key; an unknown key
514
+ * passes through verbatim.
515
+ * @param key the stored or stated knob key
516
+ * @returns the current knob key */
248
517
  export declare function migrateCallKnobKey(key: string): string;
249
518
  //# sourceMappingURL=timelineContract.d.ts.map