@melite/models-h3 0.1.5-pre-alpha → 0.2.2-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.
@@ -0,0 +1,196 @@
1
+ import type { GraphBuilder, OutputHandle } from '@melite/comfyui-card-kit/graph';
2
+ import type { H3Facts } from './actions.js';
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+ export declare const loadVideo: (g: GraphBuilder, path: string, frameLoadCap?: number, skipFirstFrames?: number) => OutputHandle[];
16
+ export declare const RESOLUTION_SHORT_EDGE: Readonly<Record<string, number>>;
17
+ /** The engine's plan_clips shape math, ported (ext lines 270-273):
18
+ * scale the source by shortEdge/min(w,h), snap both edges to 32
19
+ * (round), floor 32. Cited, never re-derived — an engine-side move
20
+ * of this math must update this port or the admission lies. */
21
+ export declare const planTierShape: (width: number, height: number, shortEdge: number) => {
22
+ width: number;
23
+ height: number;
24
+ };
25
+ /** THE CROSS-REGIME JOIN ADMISSION: given the film regime's shape
26
+ * (the doc's width/height — the shape this estate's film arm
27
+ * renders and the join appends onto) and the mod bag's tier, answer
28
+ * the admission text when the tier would render a DIFFERENT shape,
29
+ * null when the join is shape-true. The text names both regimes,
30
+ * the engine-derived mod shape, and the pin (the tier whose short
31
+ * edge matches the film's — 768p for the film regime's 768 short
32
+ * edge — or the plan node's short_edge knob for any other shape).
33
+ * @param filmWidth the film regime's width (the doc knob)
34
+ * @param filmHeight the film regime's height (the doc knob)
35
+ * @param tier the mod bag's resolution tier (e.g. '736p')
36
+ * @returns the admission warning text, or null when shapes agree */
37
+ export declare const admitCrossRegimeJoin: (filmWidth: number, filmHeight: number, tier: string) => string | null;
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+ export declare const h3MaskedEditPlane: (g: GraphBuilder, p: Record<string, unknown>, facts: H3Facts, clipSeconds: number) => {
57
+ sigmaModel: OutputHandle;
58
+ samplerSel: OutputHandle;
59
+ clip: OutputHandle;
60
+ vaeVideo: OutputHandle;
61
+ vaeAudio: OutputHandle;
62
+ };
63
+ /** What the seat's body callback receives: the ChainCurrent node
64
+ * (its .out(k) seats), the plane's encoders/decoders, the muted
65
+ * chain audio (the r2v ref_video_audios seat), and the window's own
66
+ * frames + muted slice audio (the H3SourceSlice seats). */
67
+ export interface ChainBodyHandles {
68
+ /** MiniMaxH3ChainCurrent — out(0) state, out(5) seed, out(6)
69
+ * length, out(7) steps, out(8)/out(9) width/height, out(12) the
70
+ * chain's carried audio. */
71
+ readonly cur: {
72
+ out(k: number): OutputHandle;
73
+ };
74
+ readonly clip: OutputHandle;
75
+ readonly vaeVideo: OutputHandle;
76
+ readonly vaeAudio: OutputHandle;
77
+ /** the chain's carried audio, muted −100dB (the r2v audio ref). */
78
+ readonly mutedChainAudio: OutputHandle;
79
+ /** the window's frames (the seat's loader, slot 0). */
80
+ readonly srcFrames: OutputHandle;
81
+ /** the window's source audio, muted (the slice's audio seat). */
82
+ readonly sliceAudio: OutputHandle;
83
+ }
84
+ /** The seat's masked-edit body: the nodes between ChainCurrent and
85
+ * ChainContext — the r2v anchors, the source slice, the edit latent,
86
+ * the masked target. Returns the two wires ChainContext consumes. */
87
+ export type ChainBody = (h: ChainBodyHandles) => {
88
+ /** the r2v's conditioning output. */
89
+ readonly conditioning: OutputHandle;
90
+ /** the ContexMaskedTarget's output. */
91
+ readonly targetLatent: OutputHandle;
92
+ };
93
+ /** The terminal: ChainAssemble's config, or null when the seat joins
94
+ * by file instead (the single-window extend posture). */
95
+ export interface ChainAssembleSeat {
96
+ /** 'source' keeps the source soundtrack; 'generated' assembles the
97
+ * checkpointed H3 sound. */
98
+ readonly audioSource: 'source' | 'generated';
99
+ /** the assemble basename (the `<runId>/<kind>` prefix). */
100
+ readonly filename: string;
101
+ }
102
+ /** ONE masked-edit chain seat — every delta the spine does not own.
103
+ * The seat validates its own entry, loads its own media, derives its
104
+ * own mask, and hands the body callback; the spine emits everything
105
+ * else with the seats' historical parameters verbatim. */
106
+ export interface MaskedChainSeat {
107
+ /** the walked doc params (the lora mod bag + SLA/shift knobs). */
108
+ readonly p: Record<string, unknown>;
109
+ /** the family's lane facts (unet off the DECL row). */
110
+ readonly facts: H3Facts;
111
+ /** the per-window clip budget (the plane's preview + the plan's
112
+ * default duration; for multi-window seats this is ONE window's
113
+ * seconds, never the total). */
114
+ readonly clipSeconds: number;
115
+ /** the plan node's overlap knob (the seat's entry default 39). */
116
+ readonly overlapFrames: number;
117
+ readonly resolution: string;
118
+ readonly seed: number;
119
+ readonly steps: number;
120
+ /** the swap's roles text ('' on repair/extend). */
121
+ readonly roles: string;
122
+ /** the staged source leaf (loader + timeline + lazy video wire). */
123
+ readonly sourceClip: string;
124
+ /** the window's start frame (repair's seat; 0 otherwise). */
125
+ readonly windowStart: number;
126
+ /** the staged picture_1 — the plan's geometry anchor. */
127
+ readonly picture1: OutputHandle;
128
+ /** the window's frames + audio (the seat's loadVideo call). */
129
+ readonly srcFrames: OutputHandle;
130
+ readonly srcAudio: OutputHandle;
131
+ /** the literal plan_json — REQUIRED by ChainPlanModern. When
132
+ * planFromSource is true it is the ignored fallback (the swap and
133
+ * repair ride the plan node's engine-derived shots); when false it
134
+ * IS the plan (the extend cure: the seat's own continuation shots
135
+ * rule — a raw prior is never re-sliced, §3 of the design). */
136
+ readonly planJson: string;
137
+ /** true wires plan_json_input from the plan node (source slicing —
138
+ * the swap/repair semantics); false leaves the literal ruling. */
139
+ readonly planFromSource: boolean;
140
+ /** the scheduler denoise: 1 fresh (swap/extend), partial refine
141
+ * (repair — its own law refuses >= 1 at the seat's door). */
142
+ readonly denoise: number;
143
+ /** the seat's masked-edit body. */
144
+ readonly body: ChainBody;
145
+ /** the ChainAssemble terminal, or null (file-join posture). */
146
+ readonly assemble: ChainAssembleSeat | null;
147
+ }
148
+ /** The spine's returned handles: the loop-trimmed window (the seat's
149
+ * file join consumes its streams), the ChainAssemble node's video_path
150
+ * when the seat assembles, and the plan node's own width/height — the
151
+ * shot geometry every window renders at, engine-derived from the
152
+ * source frames (the seat-side consumer is the extend seat's raw
153
+ * prior join, the F34 shape-true cure). */
154
+ export interface ChainRender {
155
+ /** MiniMaxH3LoopTrim — out(0) frames, out(1) audio, out(2) the
156
+ * with-overlap images. */
157
+ readonly trimmed: {
158
+ out(k: number): OutputHandle;
159
+ };
160
+ /** ChainAssemble's video_path when the seat assembles; else null. */
161
+ readonly assemblePath: OutputHandle | null;
162
+ /** THE CHAIN PLAN'S SHOT GEOMETRY (the F34 cure): the plan node's
163
+ * width/height outputs — the canvas the chain renders, derived by
164
+ * the engine from the source's own frames under the stated tier. */
165
+ readonly planShape: {
166
+ width: OutputHandle;
167
+ height: OutputHandle;
168
+ };
169
+ }
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+ /** @dev Judged against the boot census (served-grid-truth.spec.ts's
180
+ * band arm): the fixture's H3OneClickSwapPlan row is the engine's
181
+ * own word, and this pin must match it or the wall reds — an
182
+ * engine-side band move can never silently outdate the clamp. */
183
+ export declare const PLAN_CLIP_BAND: {
184
+ readonly min: 2.5;
185
+ readonly max: 15;
186
+ };
187
+ /** Emit the shared masked-edit chain for one seat. The node
188
+ * parameters are the three seats' historical spellings, verbatim;
189
+ * the seat's deltas arrive through the seat interface. The emission
190
+ * ends in LoopEnd (top_level_requeue) and, when configured,
191
+ * ChainAssemble.
192
+ * @param g the run's graph builder
193
+ * @param seat the seat's deltas (see MaskedChainSeat)
194
+ * @returns the trimmed window + optional assemble path (see ChainRender) */
195
+ export declare function renderMaskedEditChain(g: GraphBuilder, seat: MaskedChainSeat): ChainRender;
196
+ //# sourceMappingURL=chainEdit.d.ts.map
@@ -0,0 +1,334 @@
1
+ import { LANE_FILES, h3LoraStackOf, h3ShiftVideoOf } from './actions.js';
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+ export const loadVideo = (g, path, frameLoadCap = 0, skipFirstFrames = 0) => {
15
+ const n = g.node('VHS_LoadVideo', {
16
+ video: path, force_rate: 24, custom_width: 0, custom_height: 0,
17
+ frame_load_cap: frameLoadCap, skip_first_frames: skipFirstFrames,
18
+ select_every_nth: 1, format: 'None',
19
+ });
20
+ return [n.out(0), n.out(2)];
21
+ };
22
+
23
+ // Two resolution regimes live in one family: the FILM path renders
24
+ // at the doc's own width/height (schema defaults 1344×768), the mod
25
+ // bags (replace/repair/extend) render at a plan TIER — a short-edge
26
+ // label the engine resolves against the source's own shape. Mixed
27
+ // film+mod chains joined mismatched shapes silently (friction F18):
28
+ // the film at 1344×768, the mod window at 736p = 1280×736. The cure
29
+ // is an ADMISSION WARNING at the compose door (operator order
30
+
31
+ // output changes, never a refusal). The tier math below is the
32
+ // ENGINE'S OWN LAW, ported verbatim from the live extension
33
+ // (comfyui-h3-oneclick-swap/__init__.py): RESOLUTIONS at line 28
34
+ // maps every tier to its short edge; plan_clips at lines 268-273
35
+ // scales the SOURCE shape by shortEdge/min(w,h) and snaps both
36
+ // edges to 32. The port cites the pin too: a tier whose short edge
37
+ // equals the film's own short edge composes the film's shape
38
+ // exactly (768p on 1344×768: scale 1.0 — the join stays
39
+ // shape-true), and any other shape reconciles through the plan
40
+ // node's optional short_edge knob (step 32), never by re-rendering
41
+ // the film.
42
+ export const RESOLUTION_SHORT_EDGE = {
43
+ '480p': 480, '576p': 576, '736p': 736, '768p': 768, '1080p': 1080,
44
+ };
45
+ /** The engine's plan_clips shape math, ported (ext lines 270-273):
46
+ * scale the source by shortEdge/min(w,h), snap both edges to 32
47
+ * (round), floor 32. Cited, never re-derived — an engine-side move
48
+ * of this math must update this port or the admission lies. */
49
+ export const planTierShape = (width, height, shortEdge) => {
50
+ const scale = shortEdge / Math.min(width, height);
51
+ return {
52
+ width: Math.max(32, Math.round(width * scale / 32) * 32),
53
+ height: Math.max(32, Math.round(height * scale / 32) * 32),
54
+ };
55
+ };
56
+ /** THE CROSS-REGIME JOIN ADMISSION: given the film regime's shape
57
+ * (the doc's width/height — the shape this estate's film arm
58
+ * renders and the join appends onto) and the mod bag's tier, answer
59
+ * the admission text when the tier would render a DIFFERENT shape,
60
+ * null when the join is shape-true. The text names both regimes,
61
+ * the engine-derived mod shape, and the pin (the tier whose short
62
+ * edge matches the film's — 768p for the film regime's 768 short
63
+ * edge — or the plan node's short_edge knob for any other shape).
64
+ * @param filmWidth the film regime's width (the doc knob)
65
+ * @param filmHeight the film regime's height (the doc knob)
66
+ * @param tier the mod bag's resolution tier (e.g. '736p')
67
+ * @returns the admission warning text, or null when shapes agree */
68
+ export const admitCrossRegimeJoin = (filmWidth, filmHeight, tier) => {
69
+ const shortEdge = RESOLUTION_SHORT_EDGE[tier];
70
+ if (shortEdge === undefined)
71
+ return null;
72
+ const shape = planTierShape(filmWidth, filmHeight, shortEdge);
73
+ if (shape.width === filmWidth && shape.height === filmHeight)
74
+ return null;
75
+ const filmShort = Math.min(filmWidth, filmHeight);
76
+ const pin = Object.entries(RESOLUTION_SHORT_EDGE)
77
+ .find(([, e]) => e === filmShort)?.[0];
78
+ const pinText = pin !== undefined
79
+ ? `pin the bag's resolution ${pin} (short edge ${String(filmShort)} — the plan then composes ${String(filmWidth)}×${String(filmHeight)} exactly)`
80
+ : `pin the plan's short_edge ${String(filmShort)} (the film's own short edge — no tier spells it)`;
81
+ return `h3-timeline: CROSS-REGIME JOIN — the film regime renders ${String(filmWidth)}×${String(filmHeight)} but the mod bag's tier '${tier}' renders ${String(shape.width)}×${String(shape.height)} on a film-shaped source (the engine scales the short edge to ${String(shortEdge)}, snaps to 32); the join mismatches shapes. To join shape-true, ${pinText}; to keep the mismatch, carry on — this admission warns, it never refuses.`;
82
+ };
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+ export const h3MaskedEditPlane = (g, p, facts, clipSeconds) => {
102
+ const stabilize = p.sla_stabilize_motion ?? true;
103
+ const unet = g.node('UNETLoader', { unet_name: facts.unet, weight_dtype: 'default' }).out();
104
+ const sla = g.node('H3SLAAttention', {
105
+ model: unet,
106
+ sparsity_ratio: p.sla_sparsity,
107
+ block_size: p.sla_block_size,
108
+ min_seq_len: p.sla_min_seq_len,
109
+ dense_last_steps: p.sla_dense_last_steps,
110
+ protect_audio: p.sla_protect_audio,
111
+ enabled: true,
112
+ dense_steps: p.sla_dense_steps,
113
+ dense_backend: p.sla_dense_backend,
114
+ disable_fp16_accum: p.sla_disable_fp16_accum,
115
+ stabilize_motion: stabilize,
116
+ reference_protection: p.sla_reference_protection !== 'Off',
117
+ }).out();
118
+ const chunked = g.node('MiniMaxChunkFeedForward', {
119
+ model: g.node('MiniMaxLowVRAMAttention', { model: sla, head_chunks: 4 }).out(),
120
+ chunks: 2, seq_threshold: 4096,
121
+ }).out();
122
+ const clip = g.node('CLIPLoader', {
123
+ clip_name: LANE_FILES.clip, type: 'minimax',
124
+ }).out();
125
+ const vaeVideo = g.node('VAELoader', { vae_name: LANE_FILES.vae_video }).out();
126
+ const vaeAudio = g.node('VAELoader', { vae_name: LANE_FILES.vae_audio }).out();
127
+ let slaSel = p.sla_enabled === false
128
+ ? true
129
+ : (p.sla_switch ?? null);
130
+ if (slaSel === null)
131
+ slaSel = g.node('PrimitiveBoolean', { value: false }).out();
132
+ const picked = g.node('ComfySwitchNode', { switch: slaSel, on_true: chunked, on_false: sla }).out();
133
+ const loraModel = g.node('LTX_lora_loader', {
134
+ model: picked, mode: 'minimax', stack_data: h3LoraStackOf(p),
135
+ }).out();
136
+ // The preview override's frame budget: the caller's one clip at
137
+ // the film clock (the film rides its own length node — the clock
138
+ // node is film-owned; a literal rides here, the same posture the
139
+ // reference's fixed preview knobs take).
140
+ const previewed = g.node('ModelPreviewOverrideKJ', {
141
+ max_resolution: 512, jpeg_quality: 80,
142
+ suppress_default_preview: true, preview_frames: Math.round(clipSeconds * 24),
143
+ preview_fps: 8, tiny_vae: 'none', model: loraModel,
144
+ }).out();
145
+ const adaln = g.node('H3AdaLNLoRAFix', { model: previewed, mode: 'port' }).out();
146
+ const sigmaModel = g.node('MiniMaxH3SigmaShift', {
147
+ model: adaln, shift_video: h3ShiftVideoOf(p), shift_audio: p.shift_audio,
148
+ }).out();
149
+ const samplerSel = g.node('KSamplerSelect', { sampler_name: 'euler' }).out();
150
+ return { sigmaModel, samplerSel, clip, vaeVideo, vaeAudio };
151
+ };
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+ /** @dev Judged against the boot census (served-grid-truth.spec.ts's
162
+ * band arm): the fixture's H3OneClickSwapPlan row is the engine's
163
+ * own word, and this pin must match it or the wall reds — an
164
+ * engine-side band move can never silently outdate the clamp. */
165
+ export const PLAN_CLIP_BAND = { min: 2.5, max: 15.0 };
166
+ const planClipFeed = (seconds) => Math.min(PLAN_CLIP_BAND.max, Math.max(PLAN_CLIP_BAND.min, seconds));
167
+ /** Emit the shared masked-edit chain for one seat. The node
168
+ * parameters are the three seats' historical spellings, verbatim;
169
+ * the seat's deltas arrive through the seat interface. The emission
170
+ * ends in LoopEnd (top_level_requeue) and, when configured,
171
+ * ChainAssemble.
172
+ * @param g the run's graph builder
173
+ * @param seat the seat's deltas (see MaskedChainSeat)
174
+ * @returns the trimmed window + optional assemble path (see ChainRender) */
175
+ export function renderMaskedEditChain(g, seat) {
176
+ const { p, facts } = seat;
177
+ // ── the family's own model + lora plane (the shared masked-edit
178
+ // seat — the operator's lora law; a seat NEVER hand-rolls a stack) ──
179
+ const { sigmaModel, samplerSel, clip, vaeVideo, vaeAudio } = h3MaskedEditPlane(g, p, facts, seat.clipSeconds);
180
+ // ── the audio prep (the seats' shared posture: the source audio
181
+ // trims to the loop budget; the slice's copy is muted — the edit
182
+ // latent holds the source picture, never its sound) ──
183
+ const srcAudioTrim = g.node('TrimAudioDuration', {
184
+ start_index: 0, duration: 2048, audio: seat.srcAudio,
185
+ }).out(0);
186
+ const sliceAudio = g.node('AudioAdjustVolume', {
187
+ volume: -100, audio: srcAudioTrim,
188
+ }).out(0);
189
+ // ── the plan head (the entry's scalars, engine-derived geometry;
190
+ // picture_1 = the seat's anchor — the grid snap + tier scaling
191
+ // stay ENGINE-OWNED, never re-derived renderer-side). clip_seconds
192
+ // rides the WIDGET BAND clamp above (the node's own floor/ceiling
193
+ // would 400 the edge rungs at submit); the window's true length
194
+ // rides default_duration_seconds below, never this seat ──
195
+ const plan = g.node('H3OneClickSwapPlan', {
196
+ clip_seconds: planClipFeed(seat.clipSeconds),
197
+ overlap_frames: seat.overlapFrames,
198
+ resolution: seat.resolution,
199
+ steps: seat.steps,
200
+ seed: seat.seed,
201
+ roles: seat.roles,
202
+ source_frames: seat.srcFrames,
203
+ picture_1: seat.picture1,
204
+ });
205
+ const profile = g.node('MiniMaxH3GenerationProfile', {
206
+ scene_continuity: 'Hard picture + protected audio',
207
+ audio_profile: 'Generate audio',
208
+ }).out(0);
209
+ const chainPlan = g.node('MiniMaxH3ChainPlanModern', {
210
+ plan_json: seat.planJson,
211
+ run_name: plan.out(3),
212
+ generation_fingerprint: '',
213
+ width: plan.out(1),
214
+ height: plan.out(2),
215
+ encode_mode: 'video',
216
+ crop: 'center',
217
+ default_duration_seconds: seat.clipSeconds,
218
+ default_steps: seat.steps,
219
+ base_seed: seat.seed,
220
+ segment_crf: 16,
221
+ video_blend_frames: 0,
222
+ chain_policy: profile,
223
+ // THE PLAN-INPUT LAW (the extend cure, design §3): only a
224
+ // source-SLICING seat wires the plan node's derived shots — a
225
+ // non-empty plan_json_input OVERRIDES the literal, and the plan
226
+ // node slices the SOURCE by clip_seconds (the swap's semantics,
227
+ // the repair's window re-slice). A continuation seat (extend)
228
+ // leaves the literal ruling: its shots are NEW seconds, never a
229
+ // re-slice of the raw prior.
230
+ ...(seat.planFromSource ? { plan_json_input: plan.out(0) } : {}),
231
+ }).out(0);
232
+ const timeline = g.node('MiniMaxH3SourceTimeline', {
233
+ video_path: seat.sourceClip, audio_path: '', embedded_audio: 'auto',
234
+ // the window rides BOTH loaders identically (the VHS seat's
235
+ // skip + this one): the timeline maps the chain onto the same
236
+ // window the frames/audio were cut from.
237
+ skip_first_frames: Math.round(seat.windowStart), source_audio: srcAudioTrim,
238
+ // THE LAZY-VIDEO WIRE (friction-report #4): the timeline's
239
+ // video_path is a raw CWD-relative filesystem path (upstream
240
+ // _resolved_media_path: abspath, never the input dir), while
241
+ // VHS_LoadVideo.video must be an input-dir leaf — one string
242
+ // cannot satisfy both. The node prefers "a native file-backed
243
+ // VIDEO connection" (its own tooltip): the core loader resolves
244
+ // the staged leaf in the input dir, and the timeline reads the
245
+ // file back off the wire's stream source — video_path rides
246
+ // along staged but unread.
247
+ source_video: g.node('LoadVideo', {
248
+ file: seat.sourceClip,
249
+ }).out(0),
250
+ }).out(0);
251
+ const loop = g.node('MiniMaxH3ChainLoopStart', {
252
+ start_clip: 1, scene_range: '', verify_resume_history: true,
253
+ plan: chainPlan, source_timeline: timeline,
254
+ });
255
+ const cur = g.node('MiniMaxH3ChainCurrent', {
256
+ align_audio_reference: false, state: loop.out(1),
257
+ });
258
+ const mutedChainAudio = g.node('AudioAdjustVolume', {
259
+ volume: -100, audio: cur.out(12),
260
+ }).out(0);
261
+ // ── the seat's masked-edit body (anchors + slice + edit latent +
262
+ // masked target — the seat's true deltas) ──
263
+ const { conditioning, targetLatent } = seat.body({
264
+ cur, clip, vaeVideo, vaeAudio, mutedChainAudio,
265
+ srcFrames: seat.srcFrames, sliceAudio,
266
+ });
267
+ const ctx = g.node('MiniMaxH3ChainContext', {
268
+ state: cur.out(0), conditioning,
269
+ vae: vaeVideo, latent: targetLatent, audio_vae: vaeAudio,
270
+ });
271
+ // ── the sampler tail (the denoise pole is the seat's one knob:
272
+ // full 1 fresh — swap/extend; partial refine — the repair's law) ──
273
+ const sample = g.node('SamplerCustomAdvanced', {
274
+ noise: g.node('RandomNoise', { noise_seed: cur.out(5) }).out(0),
275
+ guider: g.node('BasicGuider', { model: sigmaModel, conditioning: ctx.out(0) }).out(0),
276
+ sampler: samplerSel,
277
+ sigmas: g.node('BasicScheduler', {
278
+ scheduler: 'simple', steps: cur.out(7), denoise: seat.denoise, model: sigmaModel,
279
+ }).out(0),
280
+ latent_image: ctx.out(3),
281
+ }).out(0);
282
+ const decoded = g.node('VAEDecode', { samples: sample, vae: vaeVideo }).out(0);
283
+ const decodedAudio = g.node('VAEDecodeAudio', { samples: sample, vae: vaeAudio }).out(0);
284
+ const trimmed = g.node('MiniMaxH3LoopTrim', {
285
+ trim_frames: ctx.out(1), fps: 24, match_tail: true,
286
+ audio_trim_mode: 'sync_with_video',
287
+ images: decoded, audio: decodedAudio, state: cur.out(0),
288
+ });
289
+ const seg = g.node('MiniMaxH3ChainSegmentSave', {
290
+ state: cur.out(0), images: trimmed.out(0), sampled_latent: sample,
291
+ audio: trimmed.out(1), images_with_overlap: trimmed.out(2),
292
+ }).out(0);
293
+ const review = g.node('MiniMaxH3ChainReview', {
294
+ enabled: false, play_notification_sound: false,
295
+ auto_continue_timeout_minutes: 0, unload_models_while_waiting: false,
296
+ assemble_partial_on_stop: true, partial_audio_source: 'checkpointed',
297
+ candidate_count: 1, review_each_candidate: false,
298
+ state: cur.out(0), segment: seg, audio: trimmed.out(1),
299
+ }).out(0);
300
+ const loopEnd = g.node('MiniMaxH3ChainLoopEnd', {
301
+
302
+ // expansion dies past clip 2 (subgraph-qualified node ids stop
303
+ // resolving at depth >= 3 — the pack now refuses >2-scene
304
+ // recursive plans at hop 1). Requeue mode checkpoints each scene,
305
+ // ends its prompt terminal-success, and the estate's requeue
306
+ // DRIVER (comfyui-execute.ts driveH3ChainRequeue) claims the
307
+ // durable handoff, patches LoopStart to the owed scene, and
308
+ // re-submits until the chain completes — the film assembles on
309
+ // the final prompt.
310
+ between_scene_cleanup: 'off', execution_mode: 'top_level_requeue',
311
+ flow: loop.out(0), state: cur.out(0),
312
+ images: trimmed.out(0), sampled_latent: sample, segment: review,
313
+ });
314
+ // ── the terminal: ChainAssemble when the seat assembles in-chain
315
+ // (the latent-seam machinery — blend_schedule 'plan' rides the
316
+ // policy's own overlaps); null when the seat joins by file. ──
317
+ if (seat.assemble === null) {
318
+ return { trimmed, assemblePath: null, planShape: { width: plan.out(1), height: plan.out(2) } };
319
+ }
320
+ const assemble = g.node('MiniMaxH3ChainAssemble', {
321
+ audio_source: seat.assemble.audioSource,
322
+ filename: seat.assemble.filename,
323
+ audio_bitrate: 256, copy_to_output: true, output_subfolder: '',
324
+ blend_schedule: 'plan', boundary_tone_match: 'off',
325
+ color_stabilization: 'off', delete_checkpoints_after_assembly: false,
326
+ generated_audio_join: 'av_overlap',
327
+ manifest: loopEnd.out(0),
328
+ });
329
+ return {
330
+ trimmed, assemblePath: assemble.out(0),
331
+ planShape: { width: plan.out(1), height: plan.out(2) },
332
+ };
333
+ }
334
+ //# sourceMappingURL=chainEdit.js.map
@@ -0,0 +1,25 @@
1
+ import type { GraphBuilder } from '@melite/comfyui-card-kit/graph';
2
+ import type { H3Facts } from './actions.js';
3
+ /** The arm predicate: BAG PRESENCE — the same law as the
4
+ * replace/repair/extend/refine/reshoot arms (a commission is armed
5
+ * when its bag is a NON-EMPTY ARRAY). Absent or empty bag = the
6
+ * compose never sees the chain (byte-stable graphs).
7
+ * @param p the gated compose doc
8
+ * @returns true when the upscale bag carries at least one entry */
9
+ export declare function upscaleArmed(p: Record<string, unknown>): boolean;
10
+ /** The chain-upscale renderer: validates the bound entry, then
11
+ * composes the deferred 2x loop over the named prior run. The film
12
+ * path never reaches here (the card branches on a non-empty upscale
13
+ * bag, and a bag beside any other edit arm refuses loud: one door
14
+ * per doc). The emission ends in ChainAssemble at `<runId>/upscale`
15
+ * (copy_to_output — the estate's film law; the recipe's dated
16
+ * filename and no-copy posture is a browser-session spelling, not an
17
+ * estate one).
18
+ * @param entry the upscale mod's single bound entry
19
+ * @param p the walked doc params (the lora mod bag + scheduler knobs
20
+ * — the family plane this loop renders under)
21
+ * @param facts the family's lane facts (unet off the DECL row)
22
+ * @param g the run's graph builder
23
+ * @param runId the run tree's id (the assemble filename rides it) */
24
+ export declare function renderH3ChainUpscale(entry: Record<string, unknown>, p: Record<string, unknown>, facts: H3Facts, g: GraphBuilder, runId: string): void;
25
+ //# sourceMappingURL=chainUpscale.d.ts.map