@skyphusion-labs/vivijure-core 0.9.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.
Files changed (267) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +87 -0
  3. package/dist/audio-routing.d.ts +2 -0
  4. package/dist/audio-routing.d.ts.map +1 -0
  5. package/dist/audio-routing.js +4 -0
  6. package/dist/audio-routing.js.map +1 -0
  7. package/dist/audio-stage.d.ts +4 -0
  8. package/dist/audio-stage.d.ts.map +1 -0
  9. package/dist/audio-stage.js +25 -0
  10. package/dist/audio-stage.js.map +1 -0
  11. package/dist/beat-analyze.d.ts +22 -0
  12. package/dist/beat-analyze.d.ts.map +1 -0
  13. package/dist/beat-analyze.js +111 -0
  14. package/dist/beat-analyze.js.map +1 -0
  15. package/dist/beat-sync-types.d.ts +33 -0
  16. package/dist/beat-sync-types.d.ts.map +1 -0
  17. package/dist/beat-sync-types.js +4 -0
  18. package/dist/beat-sync-types.js.map +1 -0
  19. package/dist/bundle-assembler.d.ts +54 -0
  20. package/dist/bundle-assembler.d.ts.map +1 -0
  21. package/dist/bundle-assembler.js +376 -0
  22. package/dist/bundle-assembler.js.map +1 -0
  23. package/dist/bundle-durations.d.ts +5 -0
  24. package/dist/bundle-durations.d.ts.map +1 -0
  25. package/dist/bundle-durations.js +68 -0
  26. package/dist/bundle-durations.js.map +1 -0
  27. package/dist/bundle-storyboard.d.ts +11 -0
  28. package/dist/bundle-storyboard.d.ts.map +1 -0
  29. package/dist/bundle-storyboard.js +82 -0
  30. package/dist/bundle-storyboard.js.map +1 -0
  31. package/dist/captions.d.ts +25 -0
  32. package/dist/captions.d.ts.map +1 -0
  33. package/dist/captions.js +56 -0
  34. package/dist/captions.js.map +1 -0
  35. package/dist/cast-db.d.ts +61 -0
  36. package/dist/cast-db.d.ts.map +1 -0
  37. package/dist/cast-db.js +324 -0
  38. package/dist/cast-db.js.map +1 -0
  39. package/dist/cast-lora-train.d.ts +18 -0
  40. package/dist/cast-lora-train.d.ts.map +1 -0
  41. package/dist/cast-lora-train.js +215 -0
  42. package/dist/cast-lora-train.js.map +1 -0
  43. package/dist/cast-loras.d.ts +21 -0
  44. package/dist/cast-loras.d.ts.map +1 -0
  45. package/dist/cast-loras.js +69 -0
  46. package/dist/cast-loras.js.map +1 -0
  47. package/dist/clip-content-validate.d.ts +43 -0
  48. package/dist/clip-content-validate.d.ts.map +1 -0
  49. package/dist/clip-content-validate.js +115 -0
  50. package/dist/clip-content-validate.js.map +1 -0
  51. package/dist/clip-job-model.d.ts +42 -0
  52. package/dist/clip-job-model.d.ts.map +1 -0
  53. package/dist/clip-job-model.js +8 -0
  54. package/dist/clip-job-model.js.map +1 -0
  55. package/dist/clip-validate.d.ts +33 -0
  56. package/dist/clip-validate.d.ts.map +1 -0
  57. package/dist/clip-validate.js +247 -0
  58. package/dist/clip-validate.js.map +1 -0
  59. package/dist/d1-retry.d.ts +20 -0
  60. package/dist/d1-retry.d.ts.map +1 -0
  61. package/dist/d1-retry.js +67 -0
  62. package/dist/d1-retry.js.map +1 -0
  63. package/dist/db-env.d.ts +6 -0
  64. package/dist/db-env.d.ts.map +1 -0
  65. package/dist/db-env.js +2 -0
  66. package/dist/db-env.js.map +1 -0
  67. package/dist/dialogue-lines.d.ts +23 -0
  68. package/dist/dialogue-lines.d.ts.map +1 -0
  69. package/dist/dialogue-lines.js +84 -0
  70. package/dist/dialogue-lines.js.map +1 -0
  71. package/dist/film-advance-lease.d.ts +9 -0
  72. package/dist/film-advance-lease.d.ts.map +1 -0
  73. package/dist/film-advance-lease.js +19 -0
  74. package/dist/film-advance-lease.js.map +1 -0
  75. package/dist/film-model.d.ts +415 -0
  76. package/dist/film-model.d.ts.map +1 -0
  77. package/dist/film-model.js +541 -0
  78. package/dist/film-model.js.map +1 -0
  79. package/dist/film-orchestrator.d.ts +216 -0
  80. package/dist/film-orchestrator.d.ts.map +1 -0
  81. package/dist/film-orchestrator.js +2204 -0
  82. package/dist/film-orchestrator.js.map +1 -0
  83. package/dist/film-render-bridge.d.ts +26 -0
  84. package/dist/film-render-bridge.d.ts.map +1 -0
  85. package/dist/film-render-bridge.js +176 -0
  86. package/dist/film-render-bridge.js.map +1 -0
  87. package/dist/finish-hash.d.ts +10 -0
  88. package/dist/finish-hash.d.ts.map +1 -0
  89. package/dist/finish-hash.js +60 -0
  90. package/dist/finish-hash.js.map +1 -0
  91. package/dist/index.d.ts +48 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +45 -0
  94. package/dist/index.js.map +1 -0
  95. package/dist/key-safety.d.ts +5 -0
  96. package/dist/key-safety.d.ts.map +1 -0
  97. package/dist/key-safety.js +23 -0
  98. package/dist/key-safety.js.map +1 -0
  99. package/dist/lora-bundle.d.ts +19 -0
  100. package/dist/lora-bundle.d.ts.map +1 -0
  101. package/dist/lora-bundle.js +75 -0
  102. package/dist/lora-bundle.js.map +1 -0
  103. package/dist/lora-keys.d.ts +2 -0
  104. package/dist/lora-keys.d.ts.map +1 -0
  105. package/dist/lora-keys.js +4 -0
  106. package/dist/lora-keys.js.map +1 -0
  107. package/dist/modules/conformance.d.ts +58 -0
  108. package/dist/modules/conformance.d.ts.map +1 -0
  109. package/dist/modules/conformance.js +369 -0
  110. package/dist/modules/conformance.js.map +1 -0
  111. package/dist/modules/manifest-validate.d.ts +5 -0
  112. package/dist/modules/manifest-validate.d.ts.map +1 -0
  113. package/dist/modules/manifest-validate.js +60 -0
  114. package/dist/modules/manifest-validate.js.map +1 -0
  115. package/dist/modules/registry.d.ts +184 -0
  116. package/dist/modules/registry.d.ts.map +1 -0
  117. package/dist/modules/registry.js +653 -0
  118. package/dist/modules/registry.js.map +1 -0
  119. package/dist/modules/render-pipeline.d.ts +38 -0
  120. package/dist/modules/render-pipeline.d.ts.map +1 -0
  121. package/dist/modules/render-pipeline.js +40 -0
  122. package/dist/modules/render-pipeline.js.map +1 -0
  123. package/dist/modules/types.d.ts +544 -0
  124. package/dist/modules/types.d.ts.map +1 -0
  125. package/dist/modules/types.js +57 -0
  126. package/dist/modules/types.js.map +1 -0
  127. package/dist/operator-config.d.ts +20 -0
  128. package/dist/operator-config.d.ts.map +1 -0
  129. package/dist/operator-config.js +85 -0
  130. package/dist/operator-config.js.map +1 -0
  131. package/dist/output-extract.d.ts +8 -0
  132. package/dist/output-extract.d.ts.map +1 -0
  133. package/dist/output-extract.js +129 -0
  134. package/dist/output-extract.js.map +1 -0
  135. package/dist/planner-prompt.d.ts +12 -0
  136. package/dist/planner-prompt.d.ts.map +1 -0
  137. package/dist/planner-prompt.js +337 -0
  138. package/dist/planner-prompt.js.map +1 -0
  139. package/dist/planner-yaml.d.ts +15 -0
  140. package/dist/planner-yaml.d.ts.map +1 -0
  141. package/dist/planner-yaml.js +157 -0
  142. package/dist/planner-yaml.js.map +1 -0
  143. package/dist/platform/fetcher.d.ts +3 -0
  144. package/dist/platform/fetcher.d.ts.map +1 -0
  145. package/dist/platform/fetcher.js +7 -0
  146. package/dist/platform/fetcher.js.map +1 -0
  147. package/dist/platform/index.d.ts +6 -0
  148. package/dist/platform/index.d.ts.map +1 -0
  149. package/dist/platform/index.js +5 -0
  150. package/dist/platform/index.js.map +1 -0
  151. package/dist/platform/object-store-r2.d.ts +26 -0
  152. package/dist/platform/object-store-r2.d.ts.map +1 -0
  153. package/dist/platform/object-store-r2.js +74 -0
  154. package/dist/platform/object-store-r2.js.map +1 -0
  155. package/dist/platform/orchestrator-context.d.ts +20 -0
  156. package/dist/platform/orchestrator-context.d.ts.map +1 -0
  157. package/dist/platform/orchestrator-context.js +28 -0
  158. package/dist/platform/orchestrator-context.js.map +1 -0
  159. package/dist/platform/r2-types.d.ts +41 -0
  160. package/dist/platform/r2-types.d.ts.map +1 -0
  161. package/dist/platform/r2-types.js +3 -0
  162. package/dist/platform/r2-types.js.map +1 -0
  163. package/dist/platform/types.d.ts +90 -0
  164. package/dist/platform/types.d.ts.map +1 -0
  165. package/dist/platform/types.js +23 -0
  166. package/dist/platform/types.js.map +1 -0
  167. package/dist/preflight.d.ts +57 -0
  168. package/dist/preflight.d.ts.map +1 -0
  169. package/dist/preflight.js +243 -0
  170. package/dist/preflight.js.map +1 -0
  171. package/dist/presign.d.ts +5 -0
  172. package/dist/presign.d.ts.map +1 -0
  173. package/dist/presign.js +24 -0
  174. package/dist/presign.js.map +1 -0
  175. package/dist/public-id.d.ts +8 -0
  176. package/dist/public-id.d.ts.map +1 -0
  177. package/dist/public-id.js +25 -0
  178. package/dist/public-id.js.map +1 -0
  179. package/dist/render-adopt.d.ts +3 -0
  180. package/dist/render-adopt.d.ts.map +1 -0
  181. package/dist/render-adopt.js +92 -0
  182. package/dist/render-adopt.js.map +1 -0
  183. package/dist/render-log.d.ts +25 -0
  184. package/dist/render-log.d.ts.map +1 -0
  185. package/dist/render-log.js +139 -0
  186. package/dist/render-log.js.map +1 -0
  187. package/dist/render-module-config.d.ts +28 -0
  188. package/dist/render-module-config.d.ts.map +1 -0
  189. package/dist/render-module-config.js +124 -0
  190. package/dist/render-module-config.js.map +1 -0
  191. package/dist/render-mux.d.ts +18 -0
  192. package/dist/render-mux.d.ts.map +1 -0
  193. package/dist/render-mux.js +69 -0
  194. package/dist/render-mux.js.map +1 -0
  195. package/dist/render-orchestrator.d.ts +71 -0
  196. package/dist/render-orchestrator.d.ts.map +1 -0
  197. package/dist/render-orchestrator.js +376 -0
  198. package/dist/render-orchestrator.js.map +1 -0
  199. package/dist/render-sweep.d.ts +5 -0
  200. package/dist/render-sweep.d.ts.map +1 -0
  201. package/dist/render-sweep.js +62 -0
  202. package/dist/render-sweep.js.map +1 -0
  203. package/dist/renders-db.d.ts +129 -0
  204. package/dist/renders-db.d.ts.map +1 -0
  205. package/dist/renders-db.js +752 -0
  206. package/dist/renders-db.js.map +1 -0
  207. package/dist/runpod-submit.d.ts +151 -0
  208. package/dist/runpod-submit.d.ts.map +1 -0
  209. package/dist/runpod-submit.js +469 -0
  210. package/dist/runpod-submit.js.map +1 -0
  211. package/dist/runpod-types.d.ts +2 -0
  212. package/dist/runpod-types.d.ts.map +1 -0
  213. package/dist/runpod-types.js +4 -0
  214. package/dist/runpod-types.js.map +1 -0
  215. package/dist/scatter-notify.d.ts +4 -0
  216. package/dist/scatter-notify.d.ts.map +1 -0
  217. package/dist/scatter-notify.js +43 -0
  218. package/dist/scatter-notify.js.map +1 -0
  219. package/dist/scatter-orchestrator-types.d.ts +56 -0
  220. package/dist/scatter-orchestrator-types.d.ts.map +1 -0
  221. package/dist/scatter-orchestrator-types.js +3 -0
  222. package/dist/scatter-orchestrator-types.js.map +1 -0
  223. package/dist/scatter-orchestrator.d.ts +70 -0
  224. package/dist/scatter-orchestrator.d.ts.map +1 -0
  225. package/dist/scatter-orchestrator.js +614 -0
  226. package/dist/scatter-orchestrator.js.map +1 -0
  227. package/dist/scatter.d.ts +35 -0
  228. package/dist/scatter.d.ts.map +1 -0
  229. package/dist/scatter.js +171 -0
  230. package/dist/scatter.js.map +1 -0
  231. package/dist/secret-store.d.ts +5 -0
  232. package/dist/secret-store.d.ts.map +1 -0
  233. package/dist/secret-store.js +19 -0
  234. package/dist/secret-store.js.map +1 -0
  235. package/dist/shot-durations-parse.d.ts +3 -0
  236. package/dist/shot-durations-parse.d.ts.map +1 -0
  237. package/dist/shot-durations-parse.js +43 -0
  238. package/dist/shot-durations-parse.js.map +1 -0
  239. package/dist/srt.d.ts +11 -0
  240. package/dist/srt.d.ts.map +1 -0
  241. package/dist/srt.js +54 -0
  242. package/dist/srt.js.map +1 -0
  243. package/dist/storyboard-ids.d.ts +2 -0
  244. package/dist/storyboard-ids.d.ts.map +1 -0
  245. package/dist/storyboard-ids.js +12 -0
  246. package/dist/storyboard-ids.js.map +1 -0
  247. package/dist/storyboard-projects-db.d.ts +31 -0
  248. package/dist/storyboard-projects-db.d.ts.map +1 -0
  249. package/dist/storyboard-projects-db.js +153 -0
  250. package/dist/storyboard-projects-db.js.map +1 -0
  251. package/dist/storyboard-validate.d.ts +72 -0
  252. package/dist/storyboard-validate.d.ts.map +1 -0
  253. package/dist/storyboard-validate.js +595 -0
  254. package/dist/storyboard-validate.js.map +1 -0
  255. package/dist/structured-events.d.ts +6 -0
  256. package/dist/structured-events.d.ts.map +1 -0
  257. package/dist/structured-events.js +15 -0
  258. package/dist/structured-events.js.map +1 -0
  259. package/dist/tar.d.ts +9 -0
  260. package/dist/tar.d.ts.map +1 -0
  261. package/dist/tar.js +151 -0
  262. package/dist/tar.js.map +1 -0
  263. package/dist/voices.d.ts +12 -0
  264. package/dist/voices.d.ts.map +1 -0
  265. package/dist/voices.js +37 -0
  266. package/dist/voices.js.map +1 -0
  267. package/package.json +71 -0
@@ -0,0 +1,216 @@
1
+ import type { Env } from "./platform/orchestrator-context.js";
2
+ import { type FilmScene, type FilmKeyframeRef, type FilmJob } from "./film-model.js";
3
+ import type { RegisteredModule, DialogueLine } from "./modules/types.js";
4
+ import { clipFileMatchesShot, type ClipJob } from "./render-orchestrator.js";
5
+ export * from "./film-model.js";
6
+ /** Collect finished clip keys from a terminal clips_only (or full) film job doc. */
7
+ export declare function clipKeysFromFilmJob(env: Env, job: FilmJob): Promise<Map<string, string>>;
8
+ /** #584 dialogue-aware finish order. A finish module that CONSUMES the shot dialogue audio
9
+ * (`finish_consumes_audio`, i.e. lip-sync) is calibrated to the SOURCE frame rate, so it must run on
10
+ * the native-fps clip BEFORE any finish step that resamples time (interpolation); otherwise its
11
+ * audio->mouth mapping smears across the interpolated frames (the breathy look). For a shot that HAS a
12
+ * dialogue line, stable-partition `serving` so audio-consuming modules run first, preserving ui.order
13
+ * within each group (`serving` is already ui.order-sorted and Array.filter keeps order): rife 10 ->
14
+ * lipsync 15 -> upscale 20 becomes lipsync -> rife -> upscale. A shot with NO line keeps the plain
15
+ * ui.order unchanged, where such a module no-ops (no audio_key). The reorder changes each step INPUT
16
+ * clip, so the #583 finishStepInputHash differs on its own -- no special-case. */
17
+ export declare function finishChainForShot(serving: RegisteredModule[], isDialogueShot: boolean): RegisteredModule[];
18
+ /** Call the video-finish container's POST /finish, retrying on a transient gateway status -- 503 (a
19
+ * cold container can 503 while its port is still binding -- same shape as callImagePrep in
20
+ * bundle-assembler) or 504 (a cold-boot + ffmpeg concat that exceeds the request window; issue #82).
21
+ * backoffMs is injectable so tests do not actually wait. Returns the Response or null on a network
22
+ * error. The orchestrator (enterAssemblePhase) adds an outer, across-polls auto-recover on top of
23
+ * this in-request retry, since a single request window may not outlast a fully-cold container. */
24
+ export declare function callVideoFinish(env: Env, payload: {
25
+ clips: {
26
+ url: string;
27
+ }[];
28
+ outputUrl: string;
29
+ outputKey: string;
30
+ width?: number;
31
+ height?: number;
32
+ fps?: number;
33
+ audioUrl?: string;
34
+ remuxAudioOnly?: boolean;
35
+ keepClipAudio?: boolean;
36
+ }, opts?: {
37
+ retries?: number;
38
+ backoffMs?: number;
39
+ }): Promise<Response | null>;
40
+ /** POST to the always-on fleet audio-mix container (/mix), mirroring callVideoFinish: a private
41
+ * Workers VPC binding, retry the transient gateway statuses. Returns null when the binding is not
42
+ * provisioned (#231 is additive -- the caller then degrades to the single-track remux). */
43
+ export declare function callAudioMix(env: Env, payload: {
44
+ tracks: {
45
+ url: string;
46
+ role: "dialogue" | "music" | "sfx";
47
+ gainDb?: number;
48
+ }[];
49
+ outputUrl: string;
50
+ outputKey: string;
51
+ format?: string;
52
+ loudnessTargetLufs?: number;
53
+ }, opts?: {
54
+ retries?: number;
55
+ backoffMs?: number;
56
+ }): Promise<Response | null>;
57
+ /** Pure: should the mux phase run the multi-track mix (#231)? Only when the film has BOTH dialogue
58
+ * (baked into the assembled video by lip-sync) AND a music bed, and the audio-mix VPC is bound.
59
+ * Otherwise the single-track remux is correct (and unchanged). */
60
+ export declare function shouldMultiTrackMix(job: FilmJob, env: Env): boolean;
61
+ export declare const FILM_FINISH_INFLIGHT_WINDOW_SECONDS = 1200;
62
+ /** Inputs for runFilmFinish -- job-shape-agnostic so BOTH the single-film path (advanceFilmJob) and the
63
+ * scatter gather can run the film.finish chain on an assembled+muxed film (#284/#285). */
64
+ export interface RunFilmFinishInput {
65
+ film_key: string;
66
+ scenes: FilmScene[];
67
+ dialogue_lines?: DialogueLine[];
68
+ film_titles?: {
69
+ title?: {
70
+ text: string;
71
+ subtitle?: string;
72
+ };
73
+ credits?: {
74
+ lines: string[];
75
+ };
76
+ };
77
+ film_finish_config?: Record<string, Record<string, unknown>>;
78
+ bundle_key: string;
79
+ project: string;
80
+ job_id: string;
81
+ actual_durations?: Record<string, number>;
82
+ }
83
+ export interface RunFilmFinishResult {
84
+ ran: boolean;
85
+ film_key: string;
86
+ applied: string[];
87
+ adopted: string[];
88
+ errors: string[];
89
+ steps?: string[];
90
+ degraded?: string;
91
+ complete: boolean;
92
+ sidecar_key?: string;
93
+ }
94
+ export declare const FILM_FINISH_STEP_MAX_ATTEMPTS = 3;
95
+ export declare const FILM_FINISH_ASYNC_PRESIGN_TTL_SECONDS = 7200;
96
+ /** Run the film.finish chain (subtitle / title / credit cards) on an assembled+muxed film. Reused by the
97
+ * single-film path AND the scatter gather. Captions are FILM-LEVEL (buildCaptionCues computes each line
98
+ * start from the cumulative duration of preceding shots), so the caller passes the FULL scenes +
99
+ * dialogue_lines in assembled (shot) order.
100
+ *
101
+ * #600 SURVIVABLE: each step writes a DETERMINISTIC per-step key (<film>-ff<n>.mp4), so before running a
102
+ * step the chain HEADs that key -- PRESENT means ADOPT the prior attempt output (no re-encode), ABSENT
103
+ * means dispatch. A big film whose whole chain exceeds one request budget therefore makes progress
104
+ * across the existing per-tick assemble re-entry: each tick adopts every completed step and re-runs only
105
+ * the incomplete one, instead of re-burning the whole chain under a fresh random key (the film-374268a2
106
+ * loop). R2 presence IS the persisted progress (#122 / #141). FAIL-SAFE: a step soft-degrade / failure
107
+ * passes the film through (recorded in degraded), never drops it (#190). */
108
+ export declare function runFilmFinish(env: Env, input: RunFilmFinishInput, preModules?: RegisteredModule[], opts?: {
109
+ dispatched?: Record<string, number>;
110
+ persistDispatch?: (key: string, ts: number) => Promise<void>;
111
+ polls?: Record<string, string>;
112
+ attempts?: Record<string, number>;
113
+ persistPoll?: (key: string, token: string | null) => Promise<void>;
114
+ prepends?: Record<string, number>;
115
+ persistPrepend?: (key: string, seconds: number) => Promise<void>;
116
+ now?: number;
117
+ }): Promise<RunFilmFinishResult>;
118
+ /** Start a film at the clips phase using existing keyframe keys (finalize / cloud / hybrid). */
119
+ export declare function startFilmFromKeyframes(env: Env, args: {
120
+ project: string;
121
+ bundle_key: string;
122
+ scenes: FilmScene[];
123
+ keyframes: FilmKeyframeRef[];
124
+ motion_backend?: string;
125
+ per_shot_motion?: Record<string, string>;
126
+ motion_config?: Record<string, unknown>;
127
+ motion_configs?: Record<string, Record<string, unknown>>;
128
+ finish_config?: Record<string, Record<string, unknown>>;
129
+ speech_config?: Record<string, Record<string, unknown>>;
130
+ film_finish_config?: Record<string, Record<string, unknown>>;
131
+ master_config?: Record<string, Record<string, unknown>>;
132
+ derive_mode: "finalized" | "cloud-finalized";
133
+ parent_render_id?: number;
134
+ audio_key?: string;
135
+ }, preModules?: RegisteredModule[]): Promise<FilmJob>;
136
+ /** Start a film job: resolve the keyframe module, submit the project preview, persist the poll token. */
137
+ export declare function startFilmJob(env: Env, args: {
138
+ project: string;
139
+ bundle_key: string;
140
+ scenes: FilmScene[];
141
+ motion_backend?: string;
142
+ keyframe_backend?: string;
143
+ keyframe_config?: Record<string, unknown>;
144
+ motion_config?: Record<string, unknown>;
145
+ finish_config?: Record<string, Record<string, unknown>>;
146
+ speech_config?: Record<string, Record<string, unknown>>;
147
+ film_finish_config?: Record<string, Record<string, unknown>>;
148
+ master_config?: Record<string, Record<string, unknown>>;
149
+ keyframes_only?: boolean;
150
+ clips_only?: boolean;
151
+ pretrained_loras?: Record<string, string>;
152
+ quality_tier?: "draft" | "standard" | "final";
153
+ audio_key?: string;
154
+ dialogue_lines?: DialogueLine[];
155
+ cast_loras?: Record<string, number>;
156
+ film_titles?: {
157
+ title?: {
158
+ text: string;
159
+ subtitle?: string;
160
+ };
161
+ credits?: {
162
+ lines: string[];
163
+ };
164
+ };
165
+ }, preModules?: RegisteredModule[]): Promise<FilmJob>;
166
+ /** Mark an in-flight film job cancelled. Terminal jobs are returned unchanged. */
167
+ export declare function cancelFilmJob(env: Env, filmId: string): Promise<FilmJob | null>;
168
+ /** List the keyframe PNGs the GPU wrote for a project and join them to the job's scenes. The keyframe
169
+ * stage writes `renders/<project>/keyframes/<shot_id>.png` itself (its own R2 creds; see the keyframe
170
+ * module), so the core can recover an orphaned keyframe phase straight from R2 presence -- no GPU re-
171
+ * run. Returns only keyframes whose shot_id is in the storyboard, so a stale PNG from an older render
172
+ * of the same project can never inject a shot the film did not ask for. Also drops any keyframe written BEFORE
173
+ * this run started (`createdAtMs`, the film job created_at): a prior render of the same project name leaves a
174
+ * FULL stale set at the identical shot_id paths, which the pending-poll fast path would otherwise adopt on
175
+ * tick one -- cancelling the live producer and shipping wrong content silently (#661, the #245/#249 class).
176
+ * This run own orphans (the #129/#619/#143 recovery) always upload AFTER created_at, so legit recovery
177
+ * survives; a leftover from an older render becomes invisible. */
178
+ export declare function listProjectKeyframes(env: Env, project: string, scenes: FilmScene[], createdAtMs: number): Promise<FilmKeyframeRef[]>;
179
+ /** True iff EVERY scene's keyframe is already in R2 (the full set, one per shot). Gate for adopting on a
180
+ * pending poll (#129 envelope-freeze): a partial set means generation is still in flight, so we must NOT
181
+ * advance early -- only adopt once the set is complete. (The 20min stall backstop is intentionally
182
+ * lenient on partials, treating absent shots as genuine non-renders at the ceiling.) */
183
+ export declare function keyframeSetCompleteInR2(env: Env, job: FilmJob): Promise<boolean>;
184
+ /** Cancel the film's in-flight keyframe RunPod job THROUGH its module, honestly. No-op when no keyframe
185
+ * job is in flight (wrong phase, no poll token, or no bound backend). When the bound module is missing
186
+ * or not `cancelable`, or the cancel call fails, we LOG the orphan rather than swallow it: an orphaned
187
+ * GPU job is a money leak that betrays scale-to-zero (#327 / #328), so it stays visible even when we
188
+ * cannot stop it. Read keyframe_poll BEFORE the caller clears it. Exported for the orchestrator
189
+ * unit test (it asserts the adopt + DELETE-cancel paths actually issue a cancel). */
190
+ export declare function cancelInFlightKeyframe(env: Env, job: FilmJob): Promise<void>;
191
+ export { clipFileMatchesShot };
192
+ /** List the motion clips the GPU wrote for a project, joined to the job's scenes by shot id (scene-shaped
193
+ * wrapper over render-orchestrator's listClipsByShotId). When a motion.backend poll never resolves (GC'd
194
+ * RunPod job), the clip is still in R2; matching by shot-id boundary recovers a stalled clips phase from
195
+ * R2 presence, no GPU re-run. Only shots in the storyboard are returned. */
196
+ export declare function listProjectClips(env: Env, project: string, scenes: FilmScene[], createdAtMs: number): Promise<{
197
+ shot_id: string;
198
+ clip_key: string;
199
+ }[]>;
200
+ /** Advance a film job across its two phases. Returns the job + the underlying clip job (for the
201
+ * summary), or null if no such film job exists.
202
+ *
203
+ * ONE DRIVER PER TICK (S4): this function is driven concurrently by the 1-minute cron sweep AND
204
+ * every client status poll, and its body is an unlocked read-modify-write on the R2 job doc with
205
+ * submit-bearing legs (clip start, dialogue batch, per-shot finish/speech/master steps, mux,
206
+ * notify). Two concurrent drivers could each observe phase N incomplete and BOTH submit phase
207
+ * N+1's external work -- duplicated GPU spend -- and clobber each other's doc writes (a lost
208
+ * poll token orphans a RunPod job). So the whole tick runs under a D1 lease (claimFilmAdvance,
209
+ * the claimFinish conditional-UPDATE pattern): the loser skips quietly and reports the doc
210
+ * read-only; the lease is released after the tick and expires on its own if the winner crashed,
211
+ * so a genuine retry is never deadlocked. */
212
+ export declare function advanceFilmJob(env: Env, filmId: string): Promise<{
213
+ job: FilmJob;
214
+ clipJob: ClipJob | null;
215
+ } | null>;
216
+ //# sourceMappingURL=film-orchestrator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"film-orchestrator.d.ts","sourceRoot":"","sources":["../src/film-orchestrator.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oCAAoC,CAAC;AAc9D,OAAO,EAGL,KAAK,SAAS,EA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