@nodaro/shared 3.54.1 → 3.56.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/{chunk-3CHOZ573.js → chunk-2AR3OXAA.js} +276 -17
- package/dist/chunk-2AR3OXAA.js.map +1 -0
- package/dist/{chunk-ZKHQSG76.js → chunk-2J6NTA5I.js} +4 -4
- package/dist/{chunk-ZKHQSG76.js.map → chunk-2J6NTA5I.js.map} +1 -1
- package/dist/{chunk-AGTCHDG5.cjs → chunk-33P5FI2U.cjs} +6 -6
- package/dist/{chunk-AGTCHDG5.cjs.map → chunk-33P5FI2U.cjs.map} +1 -1
- package/dist/{chunk-HG3KKCJJ.js → chunk-4JODLC2N.js} +3 -3
- package/dist/{chunk-HG3KKCJJ.js.map → chunk-4JODLC2N.js.map} +1 -1
- package/dist/{chunk-N3WL6IOJ.js → chunk-4O5STV7N.js} +55 -5
- package/dist/chunk-4O5STV7N.js.map +1 -0
- package/dist/chunk-4ONS6QRT.js +42 -0
- package/dist/chunk-4ONS6QRT.js.map +1 -0
- package/dist/{chunk-E4YES25K.js → chunk-55FQBILM.js} +4 -4
- package/dist/{chunk-E4YES25K.js.map → chunk-55FQBILM.js.map} +1 -1
- package/dist/{chunk-ZWB3NG4M.js → chunk-62ZQQA7L.js} +3 -3
- package/dist/{chunk-ZWB3NG4M.js.map → chunk-62ZQQA7L.js.map} +1 -1
- package/dist/{chunk-HEF4BIMA.js → chunk-6GGHM33Z.js} +4 -4
- package/dist/{chunk-HEF4BIMA.js.map → chunk-6GGHM33Z.js.map} +1 -1
- package/dist/{chunk-KMSEU6FK.js → chunk-7DGJDISO.js} +3 -3
- package/dist/{chunk-KMSEU6FK.js.map → chunk-7DGJDISO.js.map} +1 -1
- package/dist/{chunk-2OYV6K7D.cjs → chunk-7JM5EZF3.cjs} +13 -13
- package/dist/{chunk-2OYV6K7D.cjs.map → chunk-7JM5EZF3.cjs.map} +1 -1
- package/dist/{chunk-QP5JLSCJ.cjs → chunk-AFQFGZN7.cjs} +30 -3
- package/dist/chunk-AFQFGZN7.cjs.map +1 -0
- package/dist/chunk-AKDJKMAL.cjs +48 -0
- package/dist/chunk-AKDJKMAL.cjs.map +1 -0
- package/dist/{chunk-HZL7QMXK.js → chunk-AWS4BWEC.js} +7 -3
- package/dist/chunk-AWS4BWEC.js.map +1 -0
- package/dist/{chunk-5DVDHL7Y.js → chunk-AZDVL7IM.js} +20 -6
- package/dist/chunk-AZDVL7IM.js.map +1 -0
- package/dist/{chunk-2R74OU76.cjs → chunk-CGZLENU4.cjs} +276 -16
- package/dist/chunk-CGZLENU4.cjs.map +1 -0
- package/dist/{chunk-G7IUQKRU.cjs → chunk-CLKU3ZIU.cjs} +51 -51
- package/dist/{chunk-G7IUQKRU.cjs.map → chunk-CLKU3ZIU.cjs.map} +1 -1
- package/dist/{chunk-MCIBQ5BF.js → chunk-DURFRWAW.js} +9 -9
- package/dist/{chunk-MCIBQ5BF.js.map → chunk-DURFRWAW.js.map} +1 -1
- package/dist/{chunk-C5S75476.js → chunk-EAKO7PGC.js} +8 -4
- package/dist/{chunk-C5S75476.js.map → chunk-EAKO7PGC.js.map} +1 -1
- package/dist/{chunk-IPCWYKX5.cjs → chunk-EWARI452.cjs} +60 -46
- package/dist/chunk-EWARI452.cjs.map +1 -0
- package/dist/{chunk-C6IQCKJT.cjs → chunk-FCQYMPUQ.cjs} +4 -4
- package/dist/{chunk-C6IQCKJT.cjs.map → chunk-FCQYMPUQ.cjs.map} +1 -1
- package/dist/{chunk-CZCOL3M5.js → chunk-G4XWVWRI.js} +25 -4
- package/dist/chunk-G4XWVWRI.js.map +1 -0
- package/dist/{chunk-WVACGZYV.cjs → chunk-H7VMJBNZ.cjs} +8 -8
- package/dist/{chunk-WVACGZYV.cjs.map → chunk-H7VMJBNZ.cjs.map} +1 -1
- package/dist/{chunk-SEEQ3H22.cjs → chunk-HWJE4FNS.cjs} +59 -6
- package/dist/chunk-HWJE4FNS.cjs.map +1 -0
- package/dist/{chunk-3633VD2M.cjs → chunk-IKP4GOWZ.cjs} +8 -8
- package/dist/{chunk-3633VD2M.cjs.map → chunk-IKP4GOWZ.cjs.map} +1 -1
- package/dist/{chunk-5R6LTKE5.cjs → chunk-ILMHITHK.cjs} +5 -5
- package/dist/{chunk-5R6LTKE5.cjs.map → chunk-ILMHITHK.cjs.map} +1 -1
- package/dist/chunk-IOET54EV.js +39 -0
- package/dist/chunk-IOET54EV.js.map +1 -0
- package/dist/{chunk-ZAK276QF.js → chunk-JHTYULY2.js} +4 -4
- package/dist/{chunk-ZAK276QF.js.map → chunk-JHTYULY2.js.map} +1 -1
- package/dist/{chunk-OVIIJVXH.cjs → chunk-JO3XSUO2.cjs} +21 -21
- package/dist/{chunk-OVIIJVXH.cjs.map → chunk-JO3XSUO2.cjs.map} +1 -1
- package/dist/{chunk-UWMXMLMV.js → chunk-MROKQP4U.js} +3 -3
- package/dist/{chunk-UWMXMLMV.js.map → chunk-MROKQP4U.js.map} +1 -1
- package/dist/{chunk-J4CVGAAV.cjs → chunk-NZRG5CXQ.cjs} +7 -2
- package/dist/chunk-NZRG5CXQ.cjs.map +1 -0
- package/dist/{chunk-KM35K2M5.cjs → chunk-O7DXNX5J.cjs} +92 -25
- package/dist/chunk-O7DXNX5J.cjs.map +1 -0
- package/dist/chunk-OWNPYQSH.cjs +283 -0
- package/dist/chunk-OWNPYQSH.cjs.map +1 -0
- package/dist/{chunk-FIYVKW7F.cjs → chunk-PFXPAWPQ.cjs} +12 -12
- package/dist/{chunk-FIYVKW7F.cjs.map → chunk-PFXPAWPQ.cjs.map} +1 -1
- package/dist/chunk-QSWUSXRL.cjs +53 -0
- package/dist/chunk-QSWUSXRL.cjs.map +1 -0
- package/dist/{chunk-MGJR5OXO.js → chunk-RX7WII6I.js} +5 -5
- package/dist/{chunk-MGJR5OXO.js.map → chunk-RX7WII6I.js.map} +1 -1
- package/dist/chunk-S7FCFQ6X.js +255 -0
- package/dist/chunk-S7FCFQ6X.js.map +1 -0
- package/dist/{chunk-YBZQXZ6A.js → chunk-ST4WQ6ND.js} +68 -8
- package/dist/chunk-ST4WQ6ND.js.map +1 -0
- package/dist/{chunk-LKCPFD5X.js → chunk-SWVGHAYO.js} +5 -3
- package/dist/chunk-SWVGHAYO.js.map +1 -0
- package/dist/{chunk-MTUNORQB.cjs → chunk-TSKYEREJ.cjs} +11 -11
- package/dist/{chunk-MTUNORQB.cjs.map → chunk-TSKYEREJ.cjs.map} +1 -1
- package/dist/{chunk-LYWJAXPT.js → chunk-UMPZR56R.js} +3 -3
- package/dist/{chunk-LYWJAXPT.js.map → chunk-UMPZR56R.js.map} +1 -1
- package/dist/{chunk-6HUWQLF2.cjs → chunk-WKCFTWLO.cjs} +6 -6
- package/dist/{chunk-6HUWQLF2.cjs.map → chunk-WKCFTWLO.cjs.map} +1 -1
- package/dist/chunk-XPUGMYAJ.cjs +27 -0
- package/dist/{chunk-HD45Y7QU.cjs.map → chunk-XPUGMYAJ.cjs.map} +1 -1
- package/dist/{chunk-G5NTNQ7W.cjs → chunk-XROE3CAS.cjs} +5 -3
- package/dist/chunk-XROE3CAS.cjs.map +1 -0
- package/dist/{chunk-SZUDEFX2.cjs → chunk-ZXDH3L3P.cjs} +43 -39
- package/dist/{chunk-SZUDEFX2.cjs.map → chunk-ZXDH3L3P.cjs.map} +1 -1
- package/dist/{chunk-25KAGSPT.js → chunk-ZYITB47P.js} +3 -3
- package/dist/{chunk-25KAGSPT.js.map → chunk-ZYITB47P.js.map} +1 -1
- package/dist/entries/apps.cjs +43 -42
- package/dist/entries/apps.js +8 -7
- package/dist/entries/credits.cjs +151 -150
- package/dist/entries/credits.d.cts +4 -1
- package/dist/entries/credits.d.ts +4 -1
- package/dist/entries/credits.js +8 -7
- package/dist/entries/entities.cjs +125 -125
- package/dist/entries/entities.d.cts +1 -1
- package/dist/entries/entities.d.ts +1 -1
- package/dist/entries/entities.js +1 -1
- package/dist/entries/llm-models.d.cts +1 -1
- package/dist/entries/llm-models.d.ts +1 -1
- package/dist/entries/media.cjs +80 -56
- package/dist/entries/media.d.cts +49 -3
- package/dist/entries/media.d.ts +49 -3
- package/dist/entries/media.js +1 -1
- package/dist/entries/model-catalog.cjs +127 -66
- package/dist/entries/model-catalog.d.cts +61 -9
- package/dist/entries/model-catalog.d.ts +61 -9
- package/dist/entries/model-catalog.js +5 -4
- package/dist/entries/models.cjs +304 -276
- package/dist/entries/models.d.cts +3 -3
- package/dist/entries/models.d.ts +3 -3
- package/dist/entries/models.js +4 -4
- package/dist/entries/nodes.cjs +208 -207
- package/dist/entries/nodes.d.cts +1 -1
- package/dist/entries/nodes.d.ts +1 -1
- package/dist/entries/nodes.js +10 -9
- package/dist/entries/organizations.d.cts +9 -1
- package/dist/entries/organizations.d.ts +9 -1
- package/dist/entries/pipeline.cjs +161 -149
- package/dist/entries/pipeline.d.cts +165 -26
- package/dist/entries/pipeline.d.ts +165 -26
- package/dist/entries/pipeline.js +3 -3
- package/dist/entries/runtime-config.cjs +116 -0
- package/dist/entries/runtime-config.cjs.map +1 -0
- package/dist/entries/runtime-config.d.cts +308 -0
- package/dist/entries/runtime-config.d.ts +308 -0
- package/dist/entries/runtime-config.js +3 -0
- package/dist/entries/runtime-config.js.map +1 -0
- package/dist/entries/ugc.cjs +71 -71
- package/dist/entries/ugc.js +4 -4
- package/dist/entries/video.cjs +117 -117
- package/dist/entries/video.js +4 -4
- package/dist/entries/workflow.cjs +150 -146
- package/dist/entries/workflow.d.cts +8 -1
- package/dist/entries/workflow.d.ts +8 -1
- package/dist/entries/workflow.js +2 -2
- package/dist/index.cjs +3169 -2931
- package/dist/index.d.cts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +24 -22
- package/dist/{model-catalog-Dm2UiwUe.d.ts → model-catalog-vQ3NWn24.d.cts} +33 -2
- package/dist/{model-catalog-Dm2UiwUe.d.cts → model-catalog-vQ3NWn24.d.ts} +33 -2
- package/dist/{model-constants-DZUGVDOw.d.ts → model-constants-QZVHZX25.d.cts} +35 -6
- package/dist/{model-constants-DZUGVDOw.d.cts → model-constants-QZVHZX25.d.ts} +35 -6
- package/package.json +6 -1
- package/src/__tests__/fixtures/root-exports.baseline.json +2 -0
- package/src/__tests__/gpt-image-2-6.test.ts +277 -0
- package/src/__tests__/image-model-roles.test.ts +28 -9
- package/src/__tests__/runtime-config.test.ts +398 -0
- package/src/__tests__/video-face-mesh.test.ts +45 -2
- package/src/__tests__/voice-library-values.test.ts +24 -0
- package/src/credit-identifiers.ts +42 -0
- package/src/entries/model-catalog.ts +17 -0
- package/src/entries/models.ts +9 -0
- package/src/entries/runtime-config.ts +51 -0
- package/src/entries/workflow.ts +1 -1
- package/src/gpt-image-2-6.ts +104 -0
- package/src/i18n/style.ko.ts +2 -2
- package/src/i18n/style.pt-BR.ts +14 -14
- package/src/image-model-roles.ts +31 -10
- package/src/index.ts +1 -0
- package/src/model-catalog.ts +302 -14
- package/src/model-constants.ts +84 -3
- package/src/node-default-mappings.ts +4 -0
- package/src/node-refs.ts +11 -0
- package/src/organizations/views.ts +9 -1
- package/src/pipeline-types.ts +2 -0
- package/src/reference-board-templates.ts +2 -0
- package/src/runtime-config/contract.ts +492 -0
- package/src/runtime-config/worlds.ts +77 -0
- package/src/video-face-mesh.ts +72 -4
- package/src/voices.ts +175 -2
- package/dist/chunk-2R74OU76.cjs.map +0 -1
- package/dist/chunk-3CHOZ573.js.map +0 -1
- package/dist/chunk-5DVDHL7Y.js.map +0 -1
- package/dist/chunk-ATWLKUAI.cjs +0 -34
- package/dist/chunk-ATWLKUAI.cjs.map +0 -1
- package/dist/chunk-CZCOL3M5.js.map +0 -1
- package/dist/chunk-DUL5ZLTJ.js +0 -29
- package/dist/chunk-DUL5ZLTJ.js.map +0 -1
- package/dist/chunk-G5NTNQ7W.cjs.map +0 -1
- package/dist/chunk-HD45Y7QU.cjs +0 -27
- package/dist/chunk-HZL7QMXK.js.map +0 -1
- package/dist/chunk-IPCWYKX5.cjs.map +0 -1
- package/dist/chunk-J4CVGAAV.cjs.map +0 -1
- package/dist/chunk-KM35K2M5.cjs.map +0 -1
- package/dist/chunk-LKCPFD5X.js.map +0 -1
- package/dist/chunk-N3WL6IOJ.js.map +0 -1
- package/dist/chunk-QP5JLSCJ.cjs.map +0 -1
- package/dist/chunk-SEEQ3H22.cjs.map +0 -1
- package/dist/chunk-YBZQXZ6A.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pipeline-defaults.ts","../src/scene-node-types.ts","../src/pipeline-types.ts","../src/pipeline-chat.ts","../src/pipeline-events.ts","../src/pipeline-state-types.ts","../src/pipeline-validation.ts","../src/voice-matcher-types.ts","../src/voices.ts","../src/character-voice.ts","../src/entity-approval-types.ts","../src/image-critic-types.ts","../src/image-critic-node.ts","../src/scene-helper-types.ts","../src/studio-transient.ts","../src/sequence-execution.ts"],"names":["z","SceneInputModeSchema","canonicalVideoProvider"],"mappings":";;;;;;AAAO,IAAM,cAAA,GAAiB,CAAC,gBAAA,EAAkB,qBAAqB;AAG/D,IAAM,gBAAA,GAAmB;AAAA,EAC9B,SAAA;AAAA,EACA,YAAA;AAAA,EACA,aAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF;AAGO,IAAM,cAAA,GAAiB,CAAC,QAAA,EAAU,MAAA,EAAQ,QAAQ;AAGlD,IAAM,yBAAA,GAA4B,CAAC,aAAA,EAAe,cAAc;AAGhE,IAAM,2BAAA,GAA8B,CAAC,MAAA,EAAQ,MAAA,EAAQ,SAAS,IAAI;AAGlE,IAAM,0BAAA,GAGT;AAAA,EACF,IAAA,EAAM,EAAE,GAAA,EAAK,CAAA,EAAG,KAAK,EAAA,EAAG;AAAA,EACxB,UAAA,EAAY,EAAE,GAAA,EAAK,EAAA,EAAI,KAAK,EAAA,EAAG;AAAA,EAC/B,OAAA,EAAS,EAAE,GAAA,EAAK,EAAA,EAAI,KAAK,GAAA,EAAI;AAAA,EAC7B,UAAA,EAAY,EAAE,GAAA,EAAK,EA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C,IAAA,CAAK,IAAA,IAAQ,OAAO,IAAA,CAAK,IAAA,KAAS,QAAA,IAAY,KAAA,CAAM,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAA,EAAG,OAAO,KAAA;AACpF,EAAA,MAAM,OAAO,IAAA,CAAK,IAAA;AAClB,EAAA,OAAO,IAAA,CAAK,UAAA,KAAe,MAAA,IAAa,IAAA,CAAK,oBAAoB,MAAA,IAC3D,KAAA,CAAM,OAAA,CAAQ,IAAA,CAAK,oBAAoB,CAAA,IAAK,IAAA,CAAK,oBAAA,CAAqB,SAAS,kCAAkC,CAAA;AACzH;AAEO,SAAS,6BAA6B,KAAA,EAAwD;AACnG,EAAA,MAAM,OAAA,GAAU,MAAM,MAAA,CAAO,yBAAyB,EAAE,GAAA,CAAI,CAAC,IAAA,KAAS,IAAA,CAAK,EAAE,CAAA;AAC7E,EAAA,IAAI,OAAA,CAAQ,MAAA,EAAQ,MAAM,IAAI,+BAA+B,OAAO,CAAA;AACtE","file":"chunk-HWJE4FNS.cjs","sourcesContent":["export const PIPELINE_TYPES = [\"story_to_video\", \"song_to_music_video\"] as const\nexport type PipelineType = (typeof PIPELINE_TYPES)[number]\n\nexport const PIPELINE_FORMATS = [\n \"trailer\",\n \"short_film\",\n \"music_video\",\n \"reel\",\n \"commercial\",\n] as const\nexport type PipelineFormat = (typeof PIPELINE_FORMATS)[number]\n\nexport const PIPELINE_MODES = [\"manual\", \"auto\", \"guided\"] as const\nexport type PipelineMode = (typeof PIPELINE_MODES)[number]\n\nexport const PIPELINE_ACTIVATION_MODES = [\"interactive\", \"programmatic\"] as const\nexport type PipelineActivationMode = (typeof PIPELINE_ACTIVATION_MODES)[number]\n\nexport const PIPELINE_OUTPUT_RESOLUTIONS = [\"480p\", \"720p\", \"1080p\", \"4K\"] as const\nexport type PipelineOutputResolution = (typeof PIPELINE_OUTPUT_RESOLUTIONS)[number]\n\nexport const PER_FORMAT_DURATION_BOUNDS: Record<\n PipelineFormat,\n { min: number; max: number }\n> = {\n reel: { min: 7, max: 90 },\n commercial: { min: 10, max: 90 },\n trailer: { min: 30, max: 180 },\n short_film: { min: 12, max: 600 },\n music_video: { min: 30, max: 600 },\n}\n\nexport const GLOBAL_MAX_DURATION_SECONDS = 600\n\nexport function validateDurationForFormat(\n format: PipelineFormat,\n seconds: number,\n): { ok: true } | { ok: false; reason: string } {\n if (seconds > GLOBAL_MAX_DURATION_SECONDS) {\n return { ok: false, reason: `target_duration_seconds must be <= ${GLOBAL_MAX_DURATION_SECONDS}` }\n }\n const bounds = PER_FORMAT_DURATION_BOUNDS[format]\n if (seconds < bounds.min || seconds > bounds.max) {\n return {\n ok: false,\n reason: `${format} requires duration in [${bounds.min}, ${bounds.max}] seconds`,\n }\n }\n return { ok: true }\n}\n\nexport function validateModeActivation(\n mode: PipelineMode,\n activation: PipelineActivationMode,\n): { ok: true } | { ok: false; reason: string } {\n if (activation === \"programmatic\" && mode === \"guided\") {\n return {\n ok: false,\n reason: \"Programmatic activation cannot use guided mode (no user for chat turns)\",\n }\n }\n return { ok: true }\n}\n\n// Tier → max parallel pipelines (Architecture §5.4)\nexport const TIER_PIPELINE_PARALLELISM: Record<string, number> = {\n free: 0,\n payg: 1, // derived tier — pipeline entitlements copy basic's\n basic: 1,\n standard: 2,\n pro: 3,\n business: 5,\n}\n\n// Tier → default hard cost cap when max_cost_credits omitted (Architecture §6.6.3)\n//\n// These are a FRACTION OF THE TIER'S GRANT, so they move with `TIER_CREDITS`:\n// the 2026-07-30 ×10 re-denomination multiplied every grant, and leaving these\n// behind would have silently tightened each cap tenfold — a basic-tier pipeline\n// would abort at 300 credits out of a 4,500-credit grant, i.e. 6% of the plan\n// the user paid for, instead of the intended two-thirds.\nexport const TIER_MAX_PIPELINE_COST_CREDITS: Record<string, number> = {\n free: 0,\n payg: 3000, // derived tier — copies basic\n basic: 3000,\n standard: 8000,\n pro: 20000,\n business: 50000,\n}\n\n// Per-stage soft timeout (matches workflow-orchestration)\nexport const PIPELINE_STAGE_TIMEOUT_MS = 30 * 60 * 1000\n// Hard ceiling for a SINGLE orchestrator drive (pipeline-worker aborts the\n// in-flight drive when this fires). One drive runs a whole stage's work; the\n// heaviest is animate_audio_edit, which fans out every scene × every shot\n// (KIE video gen + per-shot critic + audio + merge). For a multi-scene film\n// that legitimately exceeds 90 min — the old value aborted such drives\n// mid-fan-out, and before the scene-level resume short-circuit landed each\n// retry restarted from scratch and tripped the resume cap (prod pipeline\n// 64b76ed9). 4 h gives a heavy drive room to finish in one pass while staying\n// well under the reconcile cron's 6 h abandon threshold. Worker concurrency is\n// 5, so even a pathological long drive leaves 4 slots free.\nexport const PIPELINE_HARD_TIMEOUT_MS = 4 * 60 * 60 * 1000\n\n/**\n * Per-stage hard retry caps applied to image-gen for that stage.\n * Pipeline-level credit cap (max_cost_credits) is the ultimate guard, but\n * these prevent a single stage from sucking all the budget.\n */\nexport const ENTITY_TOOL_RETRY_CAP = 3 // tool-level failure retries per entity\n\n/**\n * Default variant counts when ShowrunnerPlan doesn't suggest specifics.\n */\nexport const DEFAULT_CHARACTER_ANGLE_COUNT = 3 // main + 2 variants for non-protagonist\nexport const DEFAULT_CHARACTER_EXPRESSION_COUNT = 2 // baseline expression variants\n\n/**\n * Short-film lean reference set. A few-shot film can't meaningfully consume\n * 5-8 reference variants per character: each shot is animated from exactly ONE\n * reference image (the video providers accept a single reference and drop the\n * rest — see `allocateReferenceSlots`), so the extra angle/expression variants\n * are pure wall-clock + KIE load with ~no quality return. For films at or under\n * the threshold we generate only main + 1 angle + 1 expression; longer films\n * keep the full plan-driven variant set unchanged.\n *\n * Measured impact: the characters stage was the joint-largest time sink (≈27\n * min for a 40 s film — 23 character images at ~58 s each on KIE). Capping a\n * ≤2 min film to 2 variants/character cuts that to ~12 images.\n */\nexport const SHORT_FILM_VARIANT_THRESHOLD_SEC = 120\nexport const SHORT_FILM_ANGLE_COUNT = 2 // main + 1 angle variant\nexport const SHORT_FILM_EXPRESSION_COUNT = 1 // neutral only\n\n/**\n * Max location variants generated even if Showrunner suggests more — cost guard.\n */\nexport const MAX_LOCATION_VARIANTS = 4\n\n/**\n * Maximum user-turn count per stage for the chat refine flow. Enforced by\n * the chat POST route (counts existing `role='user'` rows and rejects when\n * the cap is reached). 1D.2b ships **Script chat only** per the LLM Spec\n * v4.0 narrowing — `shot_list` + `post_merge` caps are pre-declared so\n * adding their chat surfaces in 1D.2d only needs route+UI wiring, not a\n * type/constant change.\n */\nexport const CHAT_TURN_CAPS = {\n script: 20,\n shot_list: 15,\n post_merge: 8,\n} as const\n\n/**\n * Pipeline entity error code emitted by Phase 1D.2c-a image critics\n * (Stage 2 Characters + Stage 4 Locations) and any future image-level\n * validators. Constant lets the frontend compare equality (not substring)\n * and the backend writes a single canonical value.\n *\n * Written to `pipeline_entities.metadata.last_error` after the critic retry\n * cap exhausts. Auto-mode's failure-aggregator (`detectImageCriticFailures`\n * + `failPipelineForImageCriticUnresolvable`) reads this exact value.\n */\nexport const IMAGE_CRITIC_UNRESOLVABLE = \"image_critic_unresolvable\"\n\n/**\n * Maximum critic-feedback retry budget per entity in Phase 1D.2c-a image\n * critics. Each fail triggers a regeneration with critic suggestions injected\n * into the prompt; after this many retries the entity is marked failed and\n * surfaces in EntityCard with recovery buttons.\n */\nexport const IMAGE_CRITIC_MAX_RETRIES = 2\n\n/**\n * Score threshold below which the critic's verdict is overridden to \"fail\"\n * regardless of the verdict field. Defends against an overly lenient critic\n * that says verdict='pass' on a borderline image. The numeric score (0-10)\n * is enforced by the schema and the system prompt anchors the meaning.\n */\nexport const IMAGE_CRITIC_MIN_ADHERENCE_SCORE = 5\n\n/**\n * Metadata keys written by the image-critic retry loop (Phase 1D.2c-a)\n * onto `pipeline_entities.metadata` when an entity's critic budget is\n * exhausted. The retry-image-generation route clears these to reset the\n * entity to a fresh attempt; EntityCard reads them to render findings +\n * the failed image.\n *\n * Single source of truth so the writer (`_image-critic-loop.ts`) and the\n * clearer (`routes/pipelines.ts:retry-image-generation`) can't drift.\n */\nexport const IMAGE_CRITIC_METADATA_KEYS = [\n \"last_error\",\n \"last_error_at\",\n \"critic_findings\",\n \"last_attempted_image_url\",\n \"last_attempted_asset_id\",\n \"image_critic_retry_count\",\n] as const\n\nexport type ImageCriticMetadataKey = (typeof IMAGE_CRITIC_METADATA_KEYS)[number]\n\n/**\n * Removes every {@link IMAGE_CRITIC_METADATA_KEYS} entry from a metadata\n * blob, returning a shallow copy. Used by the retry-image-generation route\n * to wipe critic-only state while preserving everything else (`name`,\n * `voice_match`, `reject_count`, etc.).\n */\nexport function clearImageCriticMetadata(\n meta: Record<string, unknown> | null | undefined,\n): Record<string, unknown> {\n if (!meta) return {}\n const next: Record<string, unknown> = { ...meta }\n for (const key of IMAGE_CRITIC_METADATA_KEYS) {\n delete next[key]\n }\n return next\n}\n\n/**\n * Phase 1D.2c-b-ii — Video Critic frame extraction modes.\n * Each pipeline picks one via PipelineInput.video_critic_frame_count.\n * Default 'first_last' uses the input keyframe + extractLastFrame output\n * (both already produced by Stage 6 + extractLastFrame call), so no new\n * frame extractions are needed in the default case.\n */\nexport const VIDEO_CRITIC_FRAME_MODES = [\"first_last\", \"first_middle_last\", \"five_evenly\"] as const\nexport type VideoCriticFrameMode = (typeof VIDEO_CRITIC_FRAME_MODES)[number]\n\n/**\n * Credits the pipeline's upfront estimate reserves per shot for the Video\n * Critic, by frame mode — a worst case; what goes unused is refunded when the\n * pipeline completes. The config panel quotes these as \"up to N credits per\n * shot\". The server derives its reservation separately, and a test there\n * fails when the two disagree (they drifted ten-fold across a credit\n * re-denomination while the panel still read ~2 / ~3 / ~4).\n */\nexport const VIDEO_CRITIC_RESERVED_CREDITS_PER_SHOT: Readonly<Record<VideoCriticFrameMode, number>> = {\n first_last: 20,\n first_middle_last: 30,\n five_evenly: 40,\n}\n\n/** Cap=1 retry per shot — cost-aware (every retry is a full paid video\n * generation, the priciest step in the loop). */\nexport const VIDEO_CRITIC_MAX_RETRIES = 1\n\n/** Auto-fail threshold for both prompt_adherence_score and continuity_score. */\nexport const VIDEO_CRITIC_MIN_ADHERENCE_SCORE = 5\n\n/**\n * Phase 1D.2c-b-ii — Video Critic ShotSpec sibling field names that get\n * persisted by the per-shot retry loop (`runVideoCriticLoopForShot` in\n * `scene-internal-pipeline.ts`) and stripped by the retry-video-generation\n * recovery route + the frontend Regenerate button.\n *\n * Single source of truth so the writer + clearer can't drift. Mirror of\n * {@link IMAGE_CRITIC_METADATA_KEYS} for the entity-level image critic.\n */\nexport const VIDEO_CRITIC_METADATA_KEYS = [\n \"video_critic_findings\",\n \"video_critic_score\",\n \"video_critic_continuity_score\",\n \"video_critic_identified_action\",\n \"video_critic_retry_count\",\n \"video_critic_last_attempted_url\",\n \"video_critic_failed\",\n \"video_critic_verdict\",\n] as const\n\nexport type VideoCriticMetadataKey = (typeof VIDEO_CRITIC_METADATA_KEYS)[number]\n\n/**\n * Returns a shallow copy of `shot` with all `video_critic_*` keys stripped.\n * Used by the retry-video-generation route + frontend Regenerate handler to\n * reset a shot to a fresh critic attempt while preserving everything else\n * (camera, action, motion_prompt, …).\n */\nexport function clearVideoCriticMetadata<T extends Record<string, unknown>>(\n shot: T,\n): Omit<T, VideoCriticMetadataKey> {\n const cleaned = { ...shot } as Record<string, unknown>\n for (const key of VIDEO_CRITIC_METADATA_KEYS) {\n delete cleaned[key]\n }\n return cleaned as Omit<T, VideoCriticMetadataKey>\n}\n\n/**\n * Phase 1D.2 — single source of truth for chat-stage configuration.\n *\n * `wired: true` = the route has a specialist implemented + the LLM emits\n * valid `ChatTurnResponse` for this stage's artifact.\n * `wired: false` = stage is in the v0.5 spec but not yet implemented\n * (the chat POST returns HTTP 501 `chat_not_wired_for_stage`).\n *\n * Per spec §5.12 v0.5: `script` + `shot_list` + `post_merge`.\n *\n * - `script`: wired in 1D.2b (chat-refine-showrunner)\n * - `post_merge`: wired in 1D.2c (chat-refine-postmerge; suggest_branch only)\n * - `shot_list`: pre-declared, ships in 1D.2d (blocked by v4.0 per-scene\n * architecture)\n *\n * Prefer reading `CHAT_STAGES[stage].wired` directly in new code; the\n * sibling `CHAT_ENABLED_STAGES` / `CHAT_WIRED_STAGES` exports below are\n * derived and remain for backward compatibility with existing call sites.\n */\nexport const CHAT_STAGES = {\n script: { wired: true },\n shot_list: { wired: false },\n post_merge: { wired: true },\n} as const\n\nexport type ChatEnabledStage = keyof typeof CHAT_STAGES\n\n/**\n * Ordered list of stages with chat enabled. Derived from {@link CHAT_STAGES}.\n * **In 1D.2c, `script` AND `post_merge` have chat code paths wired** —\n * post-merge ships with a dedicated `chat-refine-postmerge` specialist\n * (suggest_branch only — see {@link STAGE_PATCH_SCHEMA}, `post_merge` stays\n * `null` since the merged video isn't user-editable in place). `shot_list`\n * is pre-declared for 1D.2d. The route's chat dispatch checks\n * {@link CHAT_WIRED_STAGES} to decide which specialist to invoke (or 501\n * for unwired stages).\n */\nexport const CHAT_ENABLED_STAGES: readonly ChatEnabledStage[] = Object.keys(\n CHAT_STAGES,\n) as ChatEnabledStage[]\n\n/**\n * Per-stage boolean map of whether chat code paths are actually wired\n * end-to-end. Derived from {@link CHAT_STAGES}. The chat POST route reads\n * this to decide whether to invoke a specialist (true) or return 501\n * `chat_not_wired_for_stage` (false).\n */\nexport const CHAT_WIRED_STAGES: Record<ChatEnabledStage, boolean> = {\n script: CHAT_STAGES.script.wired,\n shot_list: CHAT_STAGES.shot_list.wired,\n post_merge: CHAT_STAGES.post_merge.wired,\n}\n","import { z } from \"zod\"\n\n// SceneInputMode lives in model-constants.ts — re-export so all SceneNodeData\n// consumers import from one place.\nimport { SceneInputModeSchema } from \"./model-constants.js\"\n\n/**\n * TransitionType — the set of allowed shot-to-shot transitions emitted by the\n * Editor LLM stage. Single source of truth shared across:\n * - ShotSpec.cut_decision.transition_to_next (this file)\n * - backend/src/ee/pipelines/llms/editor.ts (LLM result schema)\n * - backend/src/ee/pipelines/services/pipeline-final-merge.ts\n * - backend/src/ee/pipelines/freecut-export.ts\n */\nexport const TransitionTypeSchema = z.enum([\n \"hard_cut\",\n \"dissolve\",\n \"match_cut\",\n \"overlap\",\n])\nexport type TransitionType = z.infer<typeof TransitionTypeSchema>\n\n/**\n * Tags a ShotSpec field that only a render or the user writes — measured\n * audio, the Editor LLM's cut, the dialogue no-cut zone, an accepted\n * match-cut break — and never the plan. Fields named for a url or an asset id\n * need no tag (their name already says so). A custom registry, not `.meta()`,\n * so the tag never appears in a JSON schema rendered from ShotSpecSchema.\n */\nexport const sceneRenderStateRegistry = z.registry<{ render_state: true }>()\nconst RENDER_STATE = { render_state: true } as const\n\n/**\n * ShotSpec — one shot inside a SceneNodeData.\n * Mirrors Architecture §6.9.1 + v4.1 Method-2/3/5/7/8/10 field additions.\n */\nexport const ShotSpecSchema = z.object({\n shot_id: z.string().regex(/^shot_\\d{2,3}$/, \"shot_id must be shot_NN or shot_NNN\"),\n camera: z.object({\n shot_type: z.enum([\n \"wide\", \"medium\", \"close_up\", \"extreme_close_up\", \"pov\", \"over_shoulder\",\n ]),\n angle: z.enum([\"eye_level\", \"low\", \"high\", \"dutch\", \"birds_eye\"]),\n motion: z.enum([\"static\", \"pan\", \"tilt\", \"dolly\", \"tracking\", \"handheld\"]),\n }),\n shot_intensity_kind: z.enum([\n \"establishing_shot\", \"action_shot\", \"dialogue_shot\",\n \"reaction_shot\", \"climactic_shot\", \"transition_shot\",\n ]),\n\n action: z.string().max(300),\n dialogue_line: z.string().max(200).nullable(),\n duration_seconds: z.number().min(0.3).max(8),\n\n motion_prompt: z.string().max(200),\n\n // Internal continuity within this scene\n start_state: z.string().max(200),\n end_state: z.string().max(200),\n continuity_with_previous: z.string().max(200).nullable(),\n\n // Provider-neutral intent — engine maps to provider-specific directives at call time\n shot_intent: z.object({\n needs_multishot_reference: z.boolean().default(false),\n is_loopable: z.boolean().default(false),\n needs_music_suppression: z.boolean().default(true),\n is_match_cut: z.boolean().default(false), // v4.1 Method 7\n }),\n\n visual_keyframe_prompt: z.string().min(1).max(1000),\n\n // v4.1 Method 2 — pre-planned paired keyframes (required when shot_input_mode='first_last_frame')\n end_keyframe_prompt: z.string().max(1000).optional(),\n\n // v4.1 Method 3 — video continuation (this shot extends extends_shot_id's clip)\n extends_shot_id: z.string().optional(),\n\n // v4.1 Method 5 — i2i bridge applied to prior last_frame before this shot animates\n bridge_image_prompt: z.string().max(500).optional(),\n\n // v4.1 Method 8 — sparse keyframes for interpolation models\n interpolation_keyframes: z\n .array(\n z.object({\n timestamp_sec: z.number().nonnegative(),\n prompt: z.string().min(10).max(1000),\n }),\n )\n .max(16)\n .optional(),\n\n // Phase 1C.3 Method 8 — generated R2 URLs of the sub-keyframes, one per\n // `interpolation_keyframes[N].prompt`. Stage 6 writes these BEFORE Stage 7\n // runs so the animate step can pass them to the interpolation provider.\n // Length MUST equal `interpolation_keyframes.length` when populated.\n interpolation_keyframe_urls: z.array(z.string().url()).max(16).optional(),\n\n // v4.1 Method 10 — parametric 3D camera path\n camera_path_directive: z\n .object({\n path_kind: z.enum([\"orbit\", \"dolly\", \"crane\", \"arc\", \"reveal\"]),\n parameters: z.record(z.string(), z.unknown()).optional(),\n })\n .optional(),\n\n // ─── Execution state (engine writes; null on planning) ─────────────────────\n // Phase 1C.1: per-shot execution state lands directly on the shot record so\n // the SceneNode internal pipeline + continuity chain can read/write them in\n // one place. All optional — planning-time ShotSpec carries none of these.\n\n // Stage 6 (scene_images) writes these after keyframe generation.\n keyframe_asset_id: z.string().uuid().optional(),\n keyframe_url: z.string().url().optional(),\n\n // Stage 7 (animate_audio_edit) step 3 (animate) writes these after the\n // image-to-video / text-to-video call succeeds.\n video_asset_id: z.string().uuid().optional(),\n video_url: z.string().url().optional(),\n\n // Stage 7 step 3 (extract_frame chain — sequential mode only) writes these\n // after each shot's last frame is extracted at duration - 0.1s. Used by the\n // next shot's continuity chain (Method 1).\n last_frame_asset_id: z.string().uuid().optional(),\n last_frame_url: z.string().url().optional(),\n\n // Stage 7 step 4 (speech) writes these per shot with dialogue_line.\n audio_asset_id: z.string().uuid().optional(),\n audio_url: z.string().url().optional(),\n\n // Stage 7 step 5 (lip-sync) writes these when lipsync_enabled and the shot\n // has dialogue. The lipsynced clip replaces the shot's video_url in the\n // step-6 combine call.\n lipsynced_asset_id: z.string().uuid().optional(),\n lipsynced_url: z.string().url().optional(),\n\n // Phase 1C.3 — bridged frame (Method 5). Defensive placeholder; never set\n // in 1C.1 (continuity.applyContinuityToStartFrame already reads this).\n bridged_frame_url: z.string().url().optional(),\n\n // Phase 1D.1 Method 7 — set true when the user accepts a MatchCutCritic\n // 'break' verdict for this shot's pair. Stage 6 reads this to know the\n // break is resolved and the scene can advance to Stage 7.\n accepted_match_cut_break: z.boolean().optional().register(sceneRenderStateRegistry, RENDER_STATE),\n\n // ─── Phase 1C.2 — dialogue + editor cut metadata ───────────────────────────\n // All optional; planning-time ShotSpec carries none of these. Populated by\n // the Editor LLM (Stage 7) and the silent-cut-preview sub-gate handler.\n\n // True when `dialogue_line` is non-null AND the speech generator produced\n // an audio track. The Editor LLM uses this to gate cut-in / cut-out into\n // the dialogue_no_cut_zone (Method 5.13.1 — never trim a syllable).\n has_dialogue: z.boolean().default(false).register(sceneRenderStateRegistry, RENDER_STATE),\n\n // Measured length of the per-shot speech audio (Stage 7 step 4 writes this).\n // Separate from `duration_seconds` (the planning intent) — the actual\n // recording can run longer/shorter than the spec.\n actual_audio_duration_sec: z.number().optional().register(sceneRenderStateRegistry, RENDER_STATE),\n\n // Inclusive [start, end] window (seconds, relative to the shot's video clip)\n // during which the Editor LLM MUST NOT cut. Computed from\n // `actual_audio_duration_sec` + small padding by the Editor LLM stage.\n // null when has_dialogue=false (no zone to protect).\n dialogue_no_cut_zone: z\n .object({ start: z.number(), end: z.number() })\n .nullable()\n .optional()\n .register(sceneRenderStateRegistry, RENDER_STATE),\n\n // Editor LLM output (Phase 1C.2). Populated by the Editor LLM stage; the\n // silent-cut-preview sub-gate may patch it via user-applied overrides.\n // Mirrors the editor_decisions audit row shape (migration 135).\n cut_decision: z\n .object({\n in_offset_sec: z.number().min(0).max(2).default(0),\n out_offset_sec: z.number().min(0).max(2).default(0),\n transition_to_next: TransitionTypeSchema,\n transition_duration_sec: z.number().min(0).max(2).optional(),\n beat_snap_seconds: z.number().nullable().optional(),\n })\n .optional()\n .register(sceneRenderStateRegistry, RENDER_STATE),\n})\nexport type ShotSpec = z.infer<typeof ShotSpecSchema>\n\n/**\n * AssetRef — minimal asset reference shape for execution-state fields.\n * Phase 1B.2 doesn't populate these (Stage 6+ work) but the schema must accept them\n * for parse round-trips.\n */\nexport const AssetRefSchema = z.object({\n asset_id: z.string().uuid(),\n url: z.string().url(),\n})\nexport type AssetRef = z.infer<typeof AssetRefSchema>\n\n/**\n * SceneNodeData — what the Scene Director emits, what the SceneNode renders,\n * what the engine persists on `pipeline_entities.metadata` (for entity_type='scene').\n * Mirrors Architecture §6.9.1.\n */\nexport const SceneNodeDataSchema = z.object({\n // Plan fields (Scene Director fills; user editable)\n scene_index: z.number().int().min(1),\n description: z.string().max(500),\n emotional_beat: z.string(),\n duration_seconds: z.number().positive(),\n\n // Input mode — gates which video_model values are valid\n shot_input_mode: SceneInputModeSchema,\n\n // Echoed inputs (Scene Director copies from SceneSpec)\n cast_keys: z.array(z.string()),\n location_key: z.string(),\n object_keys: z.array(z.string()),\n continuity_from_prev: z.enum([\"hard_cut\", \"match_last_frame\", \"dissolve\"]),\n\n // Model picks\n image_model: z.string(),\n video_model: z.string(),\n\n // Shot list\n shots: z.array(ShotSpecSchema).min(1).max(8),\n\n // v4.1 Method 6 — pre-generated master keyframe (set in 1C; Phase 1B.2 always null)\n scene_anchor_keyframe: AssetRefSchema.nullable().default(null),\n\n // Optional per-scene style override\n style_directives: z\n .object({\n visualStyle: z.string().optional(),\n colorPalette: z.string().optional(),\n lighting: z.string().optional(),\n cameraLanguage: z.string().optional(),\n avoid: z.string().optional(),\n })\n .partial()\n .optional(),\n\n // Execution state (engine writes; null on planning — Phase 1C populates)\n generated_keyframes: z.array(AssetRefSchema).default([]),\n generated_clips: z.array(AssetRefSchema).default([]),\n composite_video: AssetRefSchema.nullable().default(null),\n last_frame: AssetRefSchema.nullable().default(null),\n scene_audio_track: AssetRefSchema.nullable().default(null),\n\n // Phase 1C.1 Stage 7 result — composite video assembled from the per-shot\n // clips inside this scene. Optional flat fields kept alongside\n // `composite_video` (AssetRefSchema) so consumers can read either shape.\n composite_video_asset_id: z.string().uuid().optional(),\n composite_video_url: z.string().url().optional(),\n})\nexport type SceneNodeData = z.infer<typeof SceneNodeDataSchema>\n\n/**\n * SceneMetadataSchema — what gets persisted on `pipeline_entities.metadata`\n * for entity_type='scene'. The discriminated union in pipeline-types.ts already has\n * Character/Object/Location entries from 1A; this Phase 1B.2 task extends it.\n */\nexport const SceneMetadataSchema = z.object({\n entity_type: z.literal(\"scene\"),\n scene_id: z.string(),\n shot_ids: z.array(z.string()),\n emotional_beat: z.string(),\n // Canonical pointer to the canvas SceneNode (workflows.nodes[i].id)\n scene_node_id: z.string(),\n // Opt-in Explode tracking (Phase 2 — null in 1B.2)\n exploded_to_workflow_id: z.string().uuid().nullable().default(null),\n // Phase 1B.2 stashes the full SceneNodeData here so the orchestrator + panel UI\n // don't have to re-resolve it from canvas state.\n // Optional because Stage 5 inserts the entity row BEFORE the Scene Director runs\n // (status='pending' / 'generating') — the field lands after the Scene Director succeeds.\n scene_node_data: SceneNodeDataSchema.optional(),\n})\nexport type SceneMetadata = z.infer<typeof SceneMetadataSchema>\n\n/**\n * MatchCutVerdictSchema — Phase 1D.1 Method 7.\n *\n * What Stage 6 persists in `pipeline_stages.output.match_cut_verdicts` for\n * each match-cut shot pair. Keyed by the TARGET shot_id (the shot with\n * `shot_intent.is_match_cut=true`). The pair is [target, next-shot].\n *\n * Stage 6 runs `runValidateMatchCut` for every eligible target and stores\n * one MatchCutVerdict per pair. The `pendingBreaks` list in the orchestrator\n * result identifies shots the user must explicitly accept before Stage 7 runs.\n */\nexport const MatchCutVerdictSchema = z.object({\n shot_pair: z.tuple([z.string(), z.string()]),\n match_strength: z.enum([\"strong\", \"moderate\", \"weak\", \"break\"]),\n suggested_adjustments: z.string().max(300),\n checked_at: z.string().datetime(),\n})\nexport type MatchCutVerdict = z.infer<typeof MatchCutVerdictSchema>\n","import { z } from \"zod\"\nimport {\n PIPELINE_FORMATS,\n PIPELINE_MODES,\n PIPELINE_OUTPUT_RESOLUTIONS,\n PIPELINE_TYPES,\n VIDEO_CRITIC_FRAME_MODES,\n} from \"./pipeline-defaults.js\"\nimport { SceneMetadataSchema } from \"./scene-node-types.js\"\nimport { canonicalVideoProvider } from \"./model-constants.js\"\n\n// ─── Input schema (POST /v1/pipelines body) ───────────────────────────────────\n\nexport const StyleDirectivesSchema = z.object({\n visualStyle: z.string().max(200).optional(),\n colorPalette: z.string().max(200).optional(),\n lighting: z.string().max(200).optional(),\n cameraLanguage: z.string().max(200).optional(),\n avoid: z.string().max(400).optional(),\n})\nexport type StyleDirectives = z.infer<typeof StyleDirectivesSchema>\n\n// User-configurable per-stage model overrides. Keys follow `<stage>_<kind>` so\n// the resolver can fall back to the global `<kind>_model` field below when a\n// stage key is absent. When neither stage nor global is set, downstream code\n// keeps its current \"LLM picks\" or \"hardcoded default\" behavior.\nexport const PIPELINE_MODEL_STAGES = [\n \"characters_image\",\n \"locations_image\",\n \"objects_image\",\n \"scene_keyframes_image\",\n \"shots_video\",\n \"script_llm\",\n] as const\nexport type PipelineModelStage = (typeof PIPELINE_MODEL_STAGES)[number]\nconst PipelineModelStageEnum = z.enum(PIPELINE_MODEL_STAGES)\n\n// User-pinnable model identifiers. Curated allowlists — both the Zod schema\n// AND the frontend dropdowns derive from these. Three reasons the allowlist\n// matters even with the `model_pricing` hard-fail guard downstream:\n// 1. Closes the unknown-ID oracle (an unknown id returns a 503 from the\n// route, an known-but-internal id would silently 500 mid-pipeline).\n// 2. Keeps internal-only synthetic ids (e.g. `flux-lora-character`) out of\n// the user-pinnable surface — those should ONLY be set by the\n// orchestrator at runtime.\n// 3. Prevents prompt injection via raw interpolation of the override string\n// into the Scene Director's LLM prompt — if it isn't in the enum it\n// can't reach the prompt.\n// Tier-restriction enforcement (free tier blocked from veo3 etc.) lives at\n// the route level via `canAffordCredits` — see `routes/pipelines.ts`.\nexport const PIPELINE_PINNABLE_IMAGE_MODELS = [\n \"nano-banana\",\n \"nano-banana-pro\",\n \"nano-banana-2-1\",\n \"flux\",\n \"gpt-image\",\n \"gpt-image-2\",\n \"gpt-image-2-5-flare\",\n \"gpt-image-2-5-sunburst\",\n \"gpt-image-2-6-flare\",\n \"gpt-image-2-6-sunburst\",\n] as const\nexport type PipelinePinnableImageModel = (typeof PIPELINE_PINNABLE_IMAGE_MODELS)[number]\n\n// Image models no longer OFFERED as a pin but still honoured when a saved\n// pipeline names one: Nano Banana 2.1 replaced Nano Banana 2 in the picker\n// (decided 2026-10-08), and a pipeline pinned to NB2 before that keeps its pin.\nexport const PIPELINE_LEGACY_PINNED_IMAGE_MODELS = [\"nano-banana-2\"] as const\n\n/** Every image model a pipeline's config may name: the offered pins plus the legacy ones. */\nexport const PIPELINE_ACCEPTED_IMAGE_MODELS = [\n ...PIPELINE_PINNABLE_IMAGE_MODELS,\n ...PIPELINE_LEGACY_PINNED_IMAGE_MODELS,\n] as const\n\nexport const PIPELINE_PINNABLE_VIDEO_MODELS = [\n \"kling-turbo\",\n \"kling\",\n \"kling-3.0\",\n \"seedance-2\",\n \"seedance-2-fast\",\n \"seedance-2-mini\",\n \"seedance-2-5\",\n \"veo3\",\n \"veo3.1\",\n \"veo3_lite\",\n \"minimax\",\n \"hailuo-standard\",\n \"wan-turbo\",\n \"bytedance-lite\",\n \"bytedance-pro\",\n] as const\nexport type PipelinePinnableVideoModel = (typeof PIPELINE_PINNABLE_VIDEO_MODELS)[number]\n\n// Script LLM — Anthropic-only. The pipeline's `callLLM` is hardwired to the\n// Anthropic SDK; picking a non-Anthropic model would 400 mid-stage and burn\n// the upfront credit reservation. Adding GPT/Gemini support requires routing\n// through `lib/llm-client.ts` first; until then, keep this list tight.\nexport const PIPELINE_PINNABLE_SCRIPT_LLMS = [\n \"claude-haiku-5-5\",\n // The pipeline's own default (Auto) since 2026-10-16; callLLM asks it with\n // tool_choice auto, as it refuses a forced tool choice.\n \"claude-sonnet-5-5\",\n \"claude-sonnet-4-6\",\n \"claude-opus-4-7\",\n \"claude-opus-5\",\n] as const\n\n// Script LLMs no longer OFFERED as a pin but still honoured when a saved\n// pipeline names one: Claude Haiku 5.5 replaced Claude Haiku 4.5 in the picker\n// (decided 2026-10-10), and a pipeline pinned to Haiku 4.5 before that keeps\n// its pin.\nexport const PIPELINE_LEGACY_PINNED_SCRIPT_LLMS = [\"claude-haiku-4-5\"] as const\n\n/** Every script LLM a pipeline's config may name: the offered pins plus the legacy ones. */\nexport const PIPELINE_ACCEPTED_SCRIPT_LLMS = [\n ...PIPELINE_PINNABLE_SCRIPT_LLMS,\n ...PIPELINE_LEGACY_PINNED_SCRIPT_LLMS,\n] as const\n/** A script LLM a pipeline config may carry — an offered pin or a legacy one a saved pipeline still names. */\nexport type PipelinePinnableScriptLlm = (typeof PIPELINE_ACCEPTED_SCRIPT_LLMS)[number]\n\nconst ImageModelEnum = z.enum(PIPELINE_ACCEPTED_IMAGE_MODELS)\n// A saved pipeline pinned to a retired video model (RETIRED_VIDEO_PROVIDERS)\n// reads as the model it now runs as, never as an invalid config.\nconst VideoModelEnum = z.preprocess(canonicalVideoProvider, z.enum(PIPELINE_PINNABLE_VIDEO_MODELS))\nconst ScriptLlmEnum = z.enum(PIPELINE_ACCEPTED_SCRIPT_LLMS)\n\n// Per-stage override map. Each stage key maps to a model id valid for its\n// kind. Defined as a discriminated shape (instead of `Record<stage, string>`)\n// so the type system rejects `stage_models.shots_video = \"nano-banana\"`.\nconst StageModelsSchema = z\n .object({\n characters_image: ImageModelEnum.optional(),\n locations_image: ImageModelEnum.optional(),\n objects_image: ImageModelEnum.optional(),\n scene_keyframes_image: ImageModelEnum.optional(),\n shots_video: VideoModelEnum.optional(),\n script_llm: ScriptLlmEnum.optional(),\n })\n .optional()\n\nexport const PipelineConfigSchema = z.object({\n music_enabled: z.boolean().default(true),\n narration_enabled: z.boolean().default(true),\n lipsync_enabled: z.boolean().default(true),\n freecut_export_enabled: z.boolean().default(false),\n // Phase 1C.2.1 §H — when freecut_export_enabled, choose the serialization\n // format. JSON is the original Nodaro-flat-timeline-v1 shape; FCPXML emits\n // an FCPXML 1.10 timeline that Final Cut Pro / DaVinci Resolve / Premiere\n // can ingest directly. Both reuse the same in-memory timeline reduction.\n freecut_export_format: z.enum([\"json\", \"fcpxml\"]).default(\"json\"),\n shot_generation_mode: z.enum([\"parallel\", \"sequential\"]).default(\"parallel\"),\n silent_cut_review: z.boolean().default(true),\n // Phase 0 studio — when true, the script stage skips the critic + refine loop\n // and pauses for the user immediately after the first draft (\"critic off by\n // default; you decide\" — the user can Edit / Regenerate at the gate).\n skip_script_critic: z.boolean().default(false),\n // Studio — when true, the PRODUCTION stages (shot_list / scene_images) advance\n // automatically instead of pausing for per-scene / keyframe review. The\n // studio's control is the creative entities (script/cast/props/locations); the\n // engine then produces the film. The final cut (post_merge) still pauses for\n // review, and animate sub-gates (dialogue/silent-cut) still surface. Mirrors\n // auto-mode's advance for those stages without skipping the creative gates.\n auto_advance_production: z.boolean().default(false),\n // Studio speed — when true, the shot-list stage does NOT auto-force sequential\n // mode for shot continuity, so the animate stage renders all shots in parallel\n // (~minutes vs ~an hour for a multi-shot reel). Trades continuity chaining for\n // speed; per-shot keyframe identity still holds.\n force_parallel_animate: z.boolean().default(false),\n // Global model overrides — apply to every stage of the matching kind unless\n // a more-specific entry in `stage_models` overrides it. Constrained to the\n // pinnable allowlists above; the route handler still re-validates against\n // tier restrictions before pipeline creation.\n image_model: ImageModelEnum.optional(),\n video_model: VideoModelEnum.optional(),\n music_model: z.string().optional(),\n script_llm: ScriptLlmEnum.optional(),\n // Per-stage overrides. Each key is constrained to its kind's allowlist.\n // Empty/missing key = fall back to the global field.\n stage_models: StageModelsSchema,\n})\nexport type PipelineConfig = z.infer<typeof PipelineConfigSchema>\n\n/**\n * Resolve which model a given stage should use, following the precedence:\n * 1. `config.stage_models[stage]` — user's per-stage override\n * 2. `config.<kind>_model` (or `config.script_llm`) — user's global pick\n * 3. `undefined` — caller falls back to its own default (LLM picks, or hardcode)\n *\n * Returns `undefined` (not `null`) so callers can use `??` chains cleanly.\n */\nexport function resolvePipelineModel(\n config: PipelineConfig | Partial<PipelineConfig> | null | undefined,\n stage: PipelineModelStage,\n): string | undefined {\n if (!config) return undefined\n const override = config.stage_models?.[stage]\n if (override) return override\n if (stage === \"script_llm\") return config.script_llm\n if (stage.endsWith(\"_video\")) return config.video_model\n if (stage.endsWith(\"_image\")) return config.image_model\n return undefined\n}\n\nexport const PipelineInputSchema = z.object({\n pipeline_type: z.enum(PIPELINE_TYPES).default(\"story_to_video\"),\n workflow_id: z.string().uuid().optional(),\n root_node_id: z.string().min(1),\n story_prompt: z.string().min(1).max(4000),\n target_duration_seconds: z.number().int().min(5).max(3600),\n format: z.enum(PIPELINE_FORMATS),\n output_resolution: z.enum(PIPELINE_OUTPUT_RESOLUTIONS).default(\"720p\"),\n language: z.string().min(2).max(10).default(\"en\"),\n mode: z.enum(PIPELINE_MODES).default(\"manual\"),\n // Legacy back-compat — when both `mode` and `auto_mode` present, `mode` wins.\n auto_mode: z.boolean().optional(),\n style_directives: StyleDirectivesSchema.optional(),\n config: PipelineConfigSchema.partial().optional(),\n max_cost_credits: z.number().int().positive().optional(),\n video_critic_frame_count: z.enum(VIDEO_CRITIC_FRAME_MODES).default(\"first_last\"),\n})\nexport type PipelineInput = z.infer<typeof PipelineInputSchema>\n\n// ─── Detection LLM output (LLM spec §1) ───────────────────────────────────────\n\nexport const DetectionResultSchema = z.object({\n characters: z.array(\n z.object({\n key: z.string().regex(/^[a-z][a-z0-9_]{0,63}$/),\n name: z.string(),\n visual_description: z.string(),\n role_hint: z.enum([\"protagonist\", \"antagonist\", \"supporting\", \"cameo\"]),\n has_dialogue_hint: z.boolean(),\n }),\n ),\n objects: z.array(\n z.object({\n key: z.string().regex(/^[a-z][a-z0-9_]{0,63}$/),\n name: z.string(),\n visual_description: z.string(),\n narrative_significance: z.string(),\n }),\n ),\n locations: z.array(\n z.object({\n key: z.string().regex(/^[a-z][a-z0-9_]{0,63}$/),\n name: z.string(),\n visual_description: z.string(),\n parent_location_key: z.string().nullable(),\n variant_kind: z\n .enum([\"main\", \"time_of_day\", \"weather\", \"aftermath\"])\n .nullable(),\n }),\n ),\n audio_intent: z.object({\n has_narrator: z.boolean(),\n narrator_profile_hint: z.string().nullable(),\n dialogue_speaker_keys: z.array(z.string()),\n music: z.object({\n mood_hint: z.string(),\n bpm_hint: z.number(),\n genre_hints: z.array(z.string()),\n }),\n sfx_hints: z.array(z.string()),\n }),\n})\nexport type DetectionResult = z.infer<typeof DetectionResultSchema>\n\n// ─── Showrunner output (LLM spec §2) ──────────────────────────────────────────\n\nexport const EMOTIONAL_BEAT = z.enum([\n \"setup\",\n \"inciting\",\n \"rising\",\n \"tension\",\n \"climax\",\n \"release\",\n \"denouement\",\n \"reveal\",\n \"shock\",\n \"release_humor\",\n \"reflection\",\n])\n\nexport const SceneSpecSchema = z.object({\n scene_index: z.number().int().min(1),\n description: z.string().max(500),\n emotional_beat: EMOTIONAL_BEAT,\n duration_seconds: z.number().positive(),\n cast_keys: z.array(z.string()),\n location_key: z.string(),\n object_keys: z.array(z.string()),\n dialogue: z\n .array(\n z.object({\n cast_key: z.string(),\n line: z.string().max(200),\n }),\n )\n .default([]),\n narration: z.string().nullable(),\n continuity_from_prev: z.enum([\"hard_cut\", \"match_last_frame\", \"dissolve\"]),\n shot_count_hint: z.number().int().min(1).max(8),\n})\n\nexport const ShowrunnerPlanSchema = z.object({\n title: z.string(),\n logline: z.string().max(200),\n target_duration_seconds: z.number().positive(),\n format: z.enum(PIPELINE_FORMATS),\n output_resolution: z.enum(PIPELINE_OUTPUT_RESOLUTIONS),\n language: z.string(),\n genre: z.enum([\n \"action\",\n \"drama\",\n \"thriller\",\n \"comedy\",\n \"horror\",\n \"sci-fi\",\n \"documentary\",\n ]),\n tone: z\n .array(\n z.enum([\n \"gritty\",\n \"hopeful\",\n \"tense\",\n \"melancholic\",\n \"playful\",\n \"epic\",\n \"intimate\",\n \"surreal\",\n \"nostalgic\",\n \"urgent\",\n \"dreamy\",\n \"cold\",\n \"warm\",\n \"menacing\",\n \"whimsical\",\n \"somber\",\n \"triumphant\",\n \"eerie\",\n ]),\n )\n .max(5),\n cast: z\n .array(\n z.object({\n key: z.string(),\n name: z.string(),\n role: z.enum([\"protagonist\", \"antagonist\", \"supporting\", \"cameo\"]),\n visual_description: z.string(),\n voice_profile: z.string(),\n has_dialogue: z.boolean(),\n angle_count_hint: z.number().int().min(1).max(8),\n expression_set_hint: z\n .array(\n z.enum([\n \"neutral\",\n \"smiling\",\n \"laughing\",\n \"angry\",\n \"scared\",\n \"determined\",\n \"sad\",\n \"surprised\",\n \"thoughtful\",\n \"crying\",\n ]),\n )\n .max(6)\n .default([]),\n }),\n )\n .max(8),\n locations: z\n .array(\n z.object({\n key: z.string(),\n name: z.string(),\n visual_description: z.string(),\n variants_needed: z.array(z.string()).default([]),\n }),\n )\n .max(8),\n objects: z\n .array(\n z.object({\n key: z.string(),\n name: z.string(),\n visual_description: z.string(),\n narrative_significance: z.string(),\n }),\n )\n .max(10),\n scenes: z.array(SceneSpecSchema).min(3).max(20),\n beats: z.array(\n z.object({\n type: z.enum([\"hook\", \"rising\", \"climax\", \"resolution\"]),\n scene_indices: z.array(z.number().int()),\n }),\n ),\n has_narrator: z.boolean(),\n narrator_profile: z.string().nullable(),\n /**\n * Phase 1C.2.1 §G — optional narration_script for omniscient narrator-style\n * formats (trailers, documentaries, retro storytelling). When present, Stage\n * 7 sub-step 7c synthesizes a single narration audio track that spans the\n * full pipeline duration and gets mixed over the music in the final merge\n * (music ducks to 60% volume per spec §G5). Leave undefined for dialogue-\n * driven scenes that don't benefit from narration.\n */\n narration_script: z\n .object({\n text: z.string().min(20).max(4000),\n voice_id: z.string().optional(),\n })\n .optional(),\n music_plan: z.object({\n mood: z.string(),\n bpm_target: z.number(),\n genre_hints: z.array(z.string()),\n }),\n global_style: z.object({\n visual_style: z.string(),\n color_palette: z.string(),\n lighting: z.string(),\n camera_language: z.string(),\n }),\n total_duration_seconds: z.number(),\n estimated_scene_count: z.number(),\n warnings: z.array(z.string()),\n})\nexport type ShowrunnerPlan = z.infer<typeof ShowrunnerPlanSchema>\n\n// ─── Critic output (LLM spec §4) ──────────────────────────────────────────────\n\nexport const CriticIssueSchema = z.object({\n severity: z.enum([\"blocking\", \"warning\"]),\n scene_index: z.number().int().nullable(),\n issue_type: z.string(),\n description: z.string(),\n suggested_fix: z.string(),\n})\n\nexport const ScriptCriticVerdictSchema = z.object({\n verdict: z.enum([\"pass\", \"fail\"]),\n issues: z.array(\n CriticIssueSchema.extend({\n issue_type: z.enum([\n \"duration\",\n \"consistency\",\n \"shot_count_hint\",\n \"generatability\",\n \"dialogue\",\n \"continuity\",\n \"arc\",\n ]),\n }),\n ),\n duration_analysis: z.object({\n target_seconds: z.number(),\n actual_sum_seconds: z.number(),\n deviation_percent: z.number(),\n within_tolerance: z.boolean(),\n }),\n improvement_suggestions: z.array(z.string()).optional(),\n})\nexport type ScriptCriticVerdict = z.infer<typeof ScriptCriticVerdictSchema>\n\nexport const CastCoverageCriticVerdictSchema = z.object({\n verdict: z.enum([\"pass\", \"fail\"]),\n issues: z.array(\n CriticIssueSchema.extend({\n issue_type: z.enum([\n \"orphan_cast\",\n \"unresolved_ref\",\n \"dialogue_load_skew\",\n \"role_completeness\",\n \"key_uniqueness\",\n ]),\n }),\n ),\n dialogue_distribution: z.array(\n z.object({\n cast_key: z.string(),\n line_count: z.number(),\n share_pct: z.number(),\n }),\n ),\n})\nexport type CastCoverageCriticVerdict = z.infer<typeof CastCoverageCriticVerdictSchema>\n\nexport const LocationsCoverageCriticIssueSchema = CriticIssueSchema.extend({\n issue_type: z.enum([\n \"orphan_location\",\n \"unresolved_scene_location_ref\",\n \"duplicate_key\",\n \"name_too_similar\",\n \"description_too_short\",\n \"redundant_location\",\n ]),\n // `nullish()` (= `.nullable().optional()`) instead of `.optional()` —\n // Sonnet routinely emits `\"location_key\": null` for issue_types like\n // `redundant_location` that flag a structural problem without pointing\n // at a specific key. `.optional()` only accepted `undefined`, so those\n // emits failed Zod validation, exhausted the critic retry budget, and\n // killed the whole Stage 1 with `locations_coverage validation failed\n // after 2 attempts: issues.N.location_key: Expected string, received\n // null`. Same fix already in place on `scene_index` below.\n location_key: z.string().nullish(),\n scene_index: z.number().int().nullish(),\n})\n\nexport const LocationsCoverageCriticVerdictSchema = z.object({\n verdict: z.enum([\"pass\", \"fail\"]),\n issues: z.array(LocationsCoverageCriticIssueSchema),\n})\nexport type LocationsCoverageCriticVerdict = z.infer<typeof LocationsCoverageCriticVerdictSchema>\n\n// Phase 1D.2c-a — image-level vision critics\n\nexport const CharacterImageCriticVerdictSchema = z.object({\n verdict: z.enum([\"pass\", \"fail\"]),\n prompt_adherence_score: z.number().int().min(0).max(10),\n identified_subject: z.string().min(1).max(500),\n issues: z.array(\n z.object({\n severity: z.enum([\"blocking\", \"warning\"]),\n category: z.enum([\n \"wrong_subject\",\n \"wrong_attributes\",\n \"visual_artifacts\",\n \"style_mismatch\",\n \"other\",\n ]),\n description: z.string().min(1).max(500),\n suggested_fix: z.string().min(1).max(300),\n }),\n ),\n approved_summary: z.string().min(1).max(500).optional(),\n})\nexport type CharacterImageCriticVerdict = z.infer<typeof CharacterImageCriticVerdictSchema>\n\nexport const LocationImageCriticVerdictSchema = z.object({\n verdict: z.enum([\"pass\", \"fail\"]),\n prompt_adherence_score: z.number().int().min(0).max(10),\n identified_subject: z.string().min(1).max(500),\n issues: z.array(\n z.object({\n severity: z.enum([\"blocking\", \"warning\"]),\n category: z.enum([\n \"wrong_location_type\",\n \"wrong_time_of_day\",\n \"wrong_attributes\",\n \"visual_artifacts\",\n \"style_mismatch\",\n \"other\",\n ]),\n description: z.string().min(1).max(500),\n suggested_fix: z.string().min(1).max(300),\n }),\n ),\n approved_summary: z.string().min(1).max(500).optional(),\n})\nexport type LocationImageCriticVerdict = z.infer<typeof LocationImageCriticVerdictSchema>\n\n// Phase 1D.2c-b-i — Storyboard Cohesion Critic (Stage 6, warn-only)\n\nexport const StoryboardCohesionCriticVerdictSchema = z.object({\n overall_assessment: z.enum([\"coherent\", \"minor_issues\", \"incoherent\"]),\n coherence_score: z.number().int().min(0).max(10),\n summary: z.string().min(1).max(500),\n findings: z.array(\n z.object({\n severity: z.enum([\"info\", \"warning\", \"blocking\"]),\n category: z.enum([\n \"character_inconsistency\",\n \"location_inconsistency\",\n \"lighting_mismatch\",\n \"style_drift\",\n \"missing_establishing_shot\",\n \"plot_jump\",\n \"other\",\n ]),\n affected_scenes: z.array(z.number().int().min(1)).max(20),\n description: z.string().min(1).max(500),\n suggested_action: z.string().min(1).max(300),\n }),\n ).max(30),\n})\nexport type StoryboardCohesionCriticVerdict = z.infer<typeof StoryboardCohesionCriticVerdictSchema>\n\n// Phase 1D.2c-b-ii — Video Critic (Stage 7)\n\nexport const VideoCriticVerdictSchema = z.object({\n verdict: z.enum([\"pass\", \"fail\"]),\n prompt_adherence_score: z.number().int().min(0).max(10),\n continuity_score: z.number().int().min(0).max(10).nullable(),\n identified_action: z.string().min(1).max(500),\n issues: z.array(\n z.object({\n severity: z.enum([\"blocking\", \"warning\"]),\n category: z.enum([\n \"wrong_action\",\n \"prompt_mismatch\",\n \"continuity_break\",\n \"visual_artifacts\",\n \"motion_glitch\",\n \"style_mismatch\",\n \"other\",\n ]),\n description: z.string().min(1).max(500),\n suggested_fix: z.string().min(1).max(300),\n }),\n ).max(20),\n approved_summary: z.string().min(1).max(500).optional(),\n})\nexport type VideoCriticVerdict = z.infer<typeof VideoCriticVerdictSchema>\n\n/**\n * Phase 1D.2c-b-ii — Video Critic ShotSpec sibling fields persisted by\n * Stage 7 (scene-internal-pipeline) directly on each ShotSpec record (NOT\n * under a nested `metadata` key). Persisting them as siblings lets the shot\n * recovery routes update them via a JSON-Patch-style path; the shared Zod\n * `ShotSpec` schema doesn't enumerate these because ShotSpec is an open\n * object on the persistence path, so this interface is the single source of\n * truth for backend + frontend consumers that need to read/write them.\n *\n * Persisted location:\n * `pipeline_entities.metadata.scene_node_data.shots[N].video_critic_*`\n *\n * Cleared by `clearVideoCriticMetadata` (see pipeline-defaults.ts) in the\n * retry-video-generation recovery route + the frontend Regenerate handler.\n */\nexport interface VideoCriticShotFields {\n video_critic_findings?: VideoCriticVerdict[\"issues\"]\n video_critic_score?: number\n video_critic_continuity_score?: number | null\n video_critic_identified_action?: string\n video_critic_retry_count?: number\n video_critic_last_attempted_url?: string\n video_critic_failed?: boolean\n video_critic_verdict?: \"pass\" | \"fail\"\n}\n\n// ─── Entity metadata (DB pipeline_entities.metadata) ──────────────────────────\n\nexport const CharacterMetadataSchema = z.object({\n entity_type: z.literal(\"character\"),\n name: z.string(),\n visual_description: z.string(),\n role: z.enum([\"protagonist\", \"antagonist\", \"supporting\", \"cameo\"]),\n estimated_screen_time_shots: z.number(),\n has_dialogue: z.boolean(),\n voice_profile: z.string().optional(),\n angle_count: z.number().int().min(1).max(8),\n})\n\nexport const ObjectMetadataSchema = z.object({\n entity_type: z.literal(\"object\"),\n name: z.string(),\n visual_description: z.string(),\n narrative_significance: z.string(),\n scenes_present: z.array(z.string()),\n})\n\nexport const LocationMetadataSchema = z.object({\n entity_type: z.literal(\"location\"),\n name: z.string(),\n visual_description: z.string(),\n variants_needed: z.array(z.string()),\n})\n\nexport const EntityMetadataSchema = z.discriminatedUnion(\"entity_type\", [\n CharacterMetadataSchema,\n ObjectMetadataSchema,\n LocationMetadataSchema,\n SceneMetadataSchema, // new in Phase 1B.2\n])\nexport type EntityMetadata = z.infer<typeof EntityMetadataSchema>\n","import { z } from \"zod\"\nimport type { Operation } from \"fast-json-patch\"\nimport type { PipelineStageName } from \"./pipeline-events.js\"\nimport { ShowrunnerPlanSchema } from \"./pipeline-types.js\"\n\n/** RFC 6902 JSON Patch operations. */\nexport type JsonPatch = Operation[]\n\n/**\n * Response from the chat-refine-showrunner LLM specialist. Either includes a\n * concrete proposed change the user can apply, or none (chat-only reply).\n *\n * Two variants:\n * - 'edit_artifact': JSON Patch operations to apply to the current stage\n * artifact (Script stage = ShowrunnerPlan).\n * - 'suggest_branch': the LLM thinks a deeper change is needed — recommend\n * the user use the Branch flow (1D.3) from this stage instead of trying\n * to patch inline.\n */\nexport const ChatTurnResponseSchema = z.object({\n reply: z.string().min(1).max(4000),\n proposed_change: z\n .discriminatedUnion(\"change_type\", [\n z.object({\n change_type: z.literal(\"edit_artifact\"),\n json_patch: z\n .array(\n z.object({\n op: z.enum([\"add\", \"remove\", \"replace\"]),\n path: z.string().min(1),\n value: z.unknown().optional(),\n }),\n )\n .min(1)\n .max(50),\n summary: z.string().min(1).max(200),\n }),\n z.object({\n change_type: z.literal(\"suggest_branch\"),\n from_stage: z.enum([\n \"script\",\n \"characters\",\n \"objects\",\n \"locations\",\n \"shot_list\",\n \"scene_images\",\n \"animate_audio_edit\",\n ]),\n reason: z.string().min(1).max(300),\n }),\n ])\n .nullable(),\n})\nexport type ChatTurnResponse = z.infer<typeof ChatTurnResponseSchema>\nexport type ProposedChange = NonNullable<ChatTurnResponse[\"proposed_change\"]>\n\n/**\n * Per-stage patch validation schema for `applyStageEdit`. Stages other than\n * `script` don't have chat enabled in 1D.2b (per LLM spec v4.0 narrowing) —\n * their entries are explicitly `null` to keep the type-check exhaustive when\n * future stages are added.\n */\nexport const STAGE_PATCH_SCHEMA: Record<PipelineStageName, z.ZodTypeAny | null> = {\n script: ShowrunnerPlanSchema,\n characters: null,\n objects: null,\n locations: null,\n shot_list: null,\n scene_images: null,\n animate_audio_edit: null,\n post_merge: null,\n}\n","import { z } from \"zod\"\nimport type { EntityStatus, EntityType } from \"./entity-approval-types.js\"\nimport type {\n EntityStateChangeEvent,\n EntityStaleEvent,\n PipelineForkedEvent,\n PipelineDriftSummary,\n PipelineCompletedEvent,\n StageAwaitingSubGateEvent,\n PipelineMusicReadyEvent,\n PipelineEditorDecisionsReadyEvent,\n} from \"./pipeline-state-types.js\"\n// Phase 1D.2b — Guided-mode chat. Type-only import to keep this file at the\n// root of the import graph (pipeline-chat.ts imports PipelineStageName from\n// here, so a value import would be circular).\nimport type { ProposedChange } from \"./pipeline-chat.js\"\n\n/**\n * Canonical pipeline stage order — Phase 1A→1C topology. The engine's\n * `runPipeline` walks this list in sequence; tests, the SSE event router,\n * and the admin-side stage timeline all consume this same tuple as the\n * source of truth for \"which stages exist + in what order\".\n */\nexport const PIPELINE_STAGE_NAMES = [\n \"script\",\n \"characters\",\n \"objects\",\n \"locations\",\n \"shot_list\",\n \"scene_images\",\n \"animate_audio_edit\",\n \"post_merge\",\n] as const\nexport const PipelineStageNameSchema = z.enum(PIPELINE_STAGE_NAMES)\nexport type PipelineStageName = (typeof PIPELINE_STAGE_NAMES)[number]\n\nexport const PipelineStatusSchema = z.enum([\n \"queued\",\n \"running\",\n \"awaiting_approval\",\n \"completed\",\n \"failed\",\n \"cancelled\",\n \"forked\",\n])\nexport type PipelineStatus = z.infer<typeof PipelineStatusSchema>\n\nexport const PipelineStageStatusSchema = z.enum([\n \"pending\",\n \"running\",\n \"awaiting_approval\",\n \"approved\",\n \"rejected\",\n \"failed\",\n \"cancelled\",\n])\nexport type PipelineStageStatus = z.infer<typeof PipelineStageStatusSchema>\n\nexport type PipelineEvent =\n | { type: \"pipeline:status\"; pipelineId: string; status: PipelineStatus }\n | {\n type: \"stage:status\"\n pipelineId: string\n stageName: PipelineStageName\n status: PipelineStageStatus\n output?: unknown\n criticFeedback?: unknown\n }\n | {\n type: \"pipeline:warning\"\n pipelineId: string\n code: string\n message: string\n }\n | { type: \"pipeline:done\"; pipelineId: string }\n | {\n type: \"entity:status\"\n pipelineId: string\n entityId: string\n entityType: EntityType\n entityKey: string\n status: EntityStatus\n mainAssetUrl?: string\n }\n | {\n type: \"entity:variant:added\"\n pipelineId: string\n entityId: string\n variantKey: string\n assetUrl: string\n }\n | {\n type: \"scene:status\"\n pipelineId: string\n sceneEntityId: string\n sceneIndex: number\n status: EntityStatus\n shotCount?: number\n }\n // Phase 1B.4 lifecycle events — see pipeline-state-types.ts for full JSDoc\n // on when each fires. SSE forwarders in routes/pipelines.ts are\n // event-type-agnostic and pass all of these through unchanged.\n | EntityStateChangeEvent\n | EntityStaleEvent\n | PipelineForkedEvent\n | PipelineDriftSummary\n // Phase 1C.1 — final-MP4 ready event carries the merged asset id + URL.\n | PipelineCompletedEvent\n // Phase 1C.2 — Stage 7 sub-gate pause, music ready, editor decisions ready.\n | StageAwaitingSubGateEvent\n | PipelineMusicReadyEvent\n | PipelineEditorDecisionsReadyEvent\n // Phase 1D.2b — Guided-mode chat. `chat:turn` fires after each LLM round-\n // trip (user prompt → assistant reply with optional proposed_change). The\n // event carries the full turn record so the frontend chat history can\n // render it without an extra GET /chat roundtrip. `chat:proposal_applied`\n // fires when the user accepts a proposed_change — the turnId + attemptId\n // let the UI mark the source turn as applied and link to the resulting\n // stage attempt (re-run output) it produced.\n | {\n type: \"chat:turn\"\n pipelineId: string\n stageName: PipelineStageName\n turn: {\n id: string\n turn_n: number\n role: \"user\" | \"assistant\"\n content: string\n proposed_change: ProposedChange | null\n }\n }\n | {\n type: \"chat:proposal_applied\"\n pipelineId: string\n stageName: PipelineStageName\n turnId: string\n attemptId: string\n }\n // Phase 1D.2c-b-ii — per-shot status emitted by the Stage 7 Video Critic\n // retry loop. Fires once per shot after the critic finalises (pass or\n // cap-exhausted fail). The frontend per-shot UI subscribes to update each\n // shot's badge/banner without re-reading the scene entity.\n | {\n type: \"shot:status\"\n pipelineId: string\n sceneId: string\n shotId: string\n status: \"approved\" | \"failed\"\n }\n // LLM-stream narrative progress, emitted by callLLM when a caller passes\n // an `onProgress` callback. Currently used by the Stage 1 Showrunner so the\n // pipeline panel can show a live \"Drafting plan…\" banner instead of a 2-\n // minute spinner. The `message` is human-readable; `bytesSoFar` is a coarse\n // proxy for stream progress (cumulative tool-use JSON delta bytes) that the\n // frontend may format into a percent or just ignore.\n | {\n type: \"stage:progress\"\n pipelineId: string\n stageName: PipelineStageName\n message: string\n bytesSoFar?: number\n }\n","import { z } from \"zod\"\n\n/**\n * Phase 1B.4 — pipeline_state lifecycle + drift event types.\n *\n * `pipeline_state` lives on `pipeline_entity_nodes.pipeline_state` (migration\n * 131). Mirrors the four-value CHECK constraint there.\n *\n * `pipeline_owned_running` — node belongs to the pipeline, work in flight\n * `pipeline_owned_awaiting_approval` — node belongs to the pipeline, user is the gate\n * `pipeline_owned_approved` — node belongs to the pipeline, work locked in\n * `pipeline_orphaned` — pipeline released ownership (cancel / fork / fail);\n * node survives so the user keeps the work\n */\nexport const PipelineStateSchema = z.enum([\n \"pipeline_owned_running\",\n \"pipeline_owned_awaiting_approval\",\n \"pipeline_owned_approved\",\n \"pipeline_orphaned\",\n])\nexport type PipelineState = z.infer<typeof PipelineStateSchema>\n\n/**\n * Emitted when a pipeline_entity_nodes row transitions to a new\n * `pipeline_state`. Fires on:\n * - stage transitioning to 'awaiting_approval' (per-entity batch)\n * - approveEntity success\n * - rejectEntity regenerate path\n * - force-stop / fork orphaning (every entity at once)\n *\n * Frontend swaps node visuals (running glow → awaiting frame → approved chip)\n * based on the new state.\n */\nexport const EntityStateChangeEventSchema = z.object({\n type: z.literal(\"entity:state_change\"),\n pipelineId: z.string(),\n pipelineEntityId: z.string(),\n newState: PipelineStateSchema,\n})\nexport type EntityStateChangeEvent = z.infer<typeof EntityStateChangeEventSchema>\n\n/**\n * Emitted when a `pipeline_entities.is_stale` flag flips to true via the\n * cascade staleness trigger (migration 131). Triggered after a `main_asset_id`\n * update on an upstream entity; the trigger marks every transitive dependent\n * stale, and the engine emits one event per dependent.\n *\n * Frontend overlays a \"Stale — needs regenerate\" warning on the affected\n * canvas nodes.\n */\nexport const EntityStaleEventSchema = z.object({\n type: z.literal(\"entity:stale\"),\n pipelineId: z.string(),\n pipelineEntityId: z.string(),\n reason: z.enum([\"upstream_changed\", \"user_edit\", \"manual\"]).optional(),\n})\nexport type EntityStaleEvent = z.infer<typeof EntityStaleEventSchema>\n\n/**\n * Emitted when a pipeline is force-stopped / forked. Carries the prior status\n * (`forked_status`) so the UI can render \"Forked from approval\" vs \"Forked\n * mid-Stage-5\" copy. The companion `entity:state_change` flurry that orphans\n * every node lands in the same SSE batch.\n */\nexport const PipelineForkedEventSchema = z.object({\n type: z.literal(\"pipeline:forked\"),\n pipelineId: z.string(),\n forkedAt: z.string(), // ISO timestamp\n forkedStatus: z.string(),\n forkReason: z.string().optional(),\n})\nexport type PipelineForkedEvent = z.infer<typeof PipelineForkedEventSchema>\n\n/**\n * Section H drift summary — when the engine pauses a stage at\n * 'awaiting_approval' because user edits on the canvas diverged from the\n * pipeline's recorded state, this payload is attached to the\n * `pipeline_stages.awaiting_reason='canvas_drift'` row so the UI can render\n * the DriftBanner with actionable diffs.\n *\n * Carried inside a `stage:status` event (or a future dedicated event); kept\n * as a standalone schema so callers can validate the drift payload\n * independently.\n */\nexport const PipelineDriftSummarySchema = z.object({\n type: z.literal(\"pipeline:drift\"),\n pipelineId: z.string(),\n stageName: z.string(),\n driftedEntityIds: z.array(z.string()),\n summary: z.string().optional(),\n})\nexport type PipelineDriftSummary = z.infer<typeof PipelineDriftSummarySchema>\n\n/**\n * Phase 1C.1 — emitted by Stage 8 (post_merge) when the pipeline reaches the\n * `completed` terminal state. Carries the final merged-MP4 asset id + URL so\n * the SSE consumer can render the player without an extra round-trip.\n *\n * Distinct from the legacy `pipeline:done` lifecycle event (which carries no\n * payload). SSE forwarders close on either type.\n */\nexport const PipelineCompletedEventSchema = z.object({\n type: z.literal(\"pipeline:completed\"),\n pipelineId: z.string(),\n finalOutputAssetId: z.string().uuid().nullable(),\n finalOutputUrl: z.string(),\n})\nexport type PipelineCompletedEvent = z.infer<typeof PipelineCompletedEventSchema>\n\n/**\n * Phase 1C.2 — Sub-gate names. Stage 7 (animate_audio_edit) and Stage 6\n * (scene_images) can pause at one of these mid-stage gates before resuming\n * the rest of the stage; the gate name is persisted on\n * `pipeline_stages.output.current_sub_gate` (JSONB) so a resumed orchestrator\n * picks up at the right step.\n *\n * `silent_cut_preview` — Stage 7: Editor LLM has emitted cut_decisions;\n * user reviews the preview reel before the\n * per-shot trims commit.\n * `dialogue_recheck` — Stage 7: A re-recorded dialogue line shifted\n * the dialogue_no_cut_zone; user confirms the\n * new cuts still respect the zone.\n * `match_cut_break_pending` — Stage 6: MatchCutCritic found one or more\n * match-cut shot pairs with `match_strength =\n * \"break\"`. User must accept each break (sets\n * `accepted_match_cut_break=true` on the shot)\n * before Stage 7 can animate those pairs.\n */\nexport const SubGateNameSchema = z.enum([\n \"silent_cut_preview\",\n \"dialogue_recheck\",\n \"match_cut_break_pending\",\n])\nexport type SubGateName = z.infer<typeof SubGateNameSchema>\n\n/**\n * The sub-gates `POST /v1/pipelines/:id/sub-gates/:gate/{approve,reject}`\n * resolves: Stage 7's (`animate_audio_edit`). `match_cut_break_pending` is not\n * one of them — it clears per shot, one break at a time, through\n * `POST /v1/pipelines/:id/entities/:sceneId/helpers/accept_match_cut_break`\n * (`MATCH_CUT_BREAK_GATE`).\n */\nexport const ANIMATE_SUB_GATES = [\"silent_cut_preview\", \"dialogue_recheck\"] as const satisfies readonly SubGateName[]\nexport const AnimateSubGateSchema = z.enum(ANIMATE_SUB_GATES)\nexport type AnimateSubGate = (typeof ANIMATE_SUB_GATES)[number]\n\n/** Stage 6's sub-gate, cleared by accepting each flagged break (see {@link ANIMATE_SUB_GATES}). */\nexport const MATCH_CUT_BREAK_GATE = \"match_cut_break_pending\" satisfies SubGateName\n\n/**\n * Phase 1C.2 — emitted when Stage 6 (scene_images) or Stage 7\n * (animate_audio_edit) pauses at a sub-gate. Carries an optional `payload`\n * (JSONB-shaped) for whatever the gate needs to render — e.g. the preview\n * reel URL, the affected shot ids, or the pending-break list.\n *\n * Distinct from `stage:status awaiting_approval` (which is the top-level\n * stage gate). Sub-gates stash `current_sub_gate` on the stage output AND\n * flip `status = \"awaiting_approval\"` so the pipeline engine waits.\n */\nexport const StageAwaitingSubGateEventSchema = z.object({\n type: z.literal(\"stage:awaiting_sub_gate\"),\n pipelineId: z.string().uuid(),\n stageName: z.enum([\"animate_audio_edit\", \"scene_images\"]),\n subGate: SubGateNameSchema,\n payload: z.record(z.string(), z.unknown()).optional(),\n})\nexport type StageAwaitingSubGateEvent = z.infer<typeof StageAwaitingSubGateEventSchema>\n\n/**\n * Phase 1C.2 — emitted when the music_timeline build step (Stage 7 sibling)\n * has produced the merged music track + beat grid. The SSE consumer can\n * render the music waveform + beat markers without an extra round-trip.\n */\nexport const PipelineMusicReadyEventSchema = z.object({\n type: z.literal(\"pipeline:music_ready\"),\n pipelineId: z.string().uuid(),\n musicAssetUrl: z.string().url(),\n beatGridLength: z.number(),\n})\nexport type PipelineMusicReadyEvent = z.infer<typeof PipelineMusicReadyEventSchema>\n\n/**\n * Phase 1C.2 — emitted when the Editor LLM has produced cut_decisions for\n * every shot in the pipeline. Frontend can render the silent-cut-preview UI\n * (timeline + accept/reject) once this fires. Payload is intentionally\n * minimal — the decisions are persisted on the shots' `cut_decision` field\n * and the `editor_decisions` audit table.\n */\nexport const PipelineEditorDecisionsReadyEventSchema = z.object({\n type: z.literal(\"pipeline:editor_decisions_ready\"),\n pipelineId: z.string().uuid(),\n})\nexport type PipelineEditorDecisionsReadyEvent = z.infer<\n typeof PipelineEditorDecisionsReadyEventSchema\n>\n\n/**\n * Union of the Phase 1B.4 + 1C.1 + 1C.2 lifecycle event payloads. The broader\n * `PipelineEvent` union in `pipeline-events.ts` extends this so SSE\n * forwarders accept all of them transparently.\n */\nexport type PipelineLifecycleEvent =\n | EntityStateChangeEvent\n | EntityStaleEvent\n | PipelineForkedEvent\n | PipelineDriftSummary\n | PipelineCompletedEvent\n | StageAwaitingSubGateEvent\n | PipelineMusicReadyEvent\n | PipelineEditorDecisionsReadyEvent\n","import type { ShowrunnerPlan } from \"./pipeline-types\"\n\nexport interface ObjectsValidationIssue {\n severity: \"blocking\" | \"warning\"\n type:\n | \"duplicate_key\"\n | \"empty_significance\"\n | \"orphan_object\"\n | \"unresolved_scene_object_ref\"\n object_key?: string\n scene_index?: number\n message: string\n}\n\nexport interface ObjectsValidationResult {\n ok: boolean\n verdict: \"pass\" | \"fail\"\n issues: ObjectsValidationIssue[]\n}\n\nexport function validateObjects(\n objects: ShowrunnerPlan[\"objects\"],\n plan: ShowrunnerPlan,\n): ObjectsValidationResult {\n const issues: ObjectsValidationIssue[] = []\n\n // 1. Duplicate keys\n const seenKeys = new Map<string, number>()\n for (const obj of objects) {\n seenKeys.set(obj.key, (seenKeys.get(obj.key) ?? 0) + 1)\n }\n for (const [key, count] of seenKeys) {\n if (count > 1) {\n issues.push({\n severity: \"blocking\",\n type: \"duplicate_key\",\n object_key: key,\n message: `Object key \"${key}\" appears ${count} times — keys must be unique`,\n })\n }\n }\n\n // 2. Empty narrative_significance\n for (const obj of objects) {\n if (!obj.narrative_significance || obj.narrative_significance.trim() === \"\") {\n issues.push({\n severity: \"blocking\",\n type: \"empty_significance\",\n object_key: obj.key,\n message: `Object \"${obj.key}\" has empty narrative_significance`,\n })\n }\n }\n\n // 3. Unresolved scene → object refs\n const objectKeySet = new Set(objects.map((o) => o.key))\n const referencedKeys = new Set<string>()\n for (const sc of plan.scenes) {\n for (const k of sc.object_keys) {\n referencedKeys.add(k)\n if (!objectKeySet.has(k)) {\n issues.push({\n severity: \"blocking\",\n type: \"unresolved_scene_object_ref\",\n object_key: k,\n scene_index: sc.scene_index,\n message: `Scene ${sc.scene_index} references unknown object_key \"${k}\"`,\n })\n }\n }\n }\n\n // 4. Orphan objects (listed but never referenced) — warning only\n for (const obj of objects) {\n if (!referencedKeys.has(obj.key)) {\n issues.push({\n severity: \"warning\",\n type: \"orphan_object\",\n object_key: obj.key,\n message: `Object \"${obj.key}\" listed but no scene references it`,\n })\n }\n }\n\n const ok = !issues.some((i) => i.severity === \"blocking\")\n return { ok, verdict: ok ? \"pass\" : \"fail\", issues }\n}\n","import { z } from \"zod\"\n\n/**\n * Voice Matcher (LLM spec §7.1) picks an ElevenLabs voice per dialogue-bearing\n * cast member. Two variants discriminated by `voice_source`:\n * - 'premade' → uses a catalog voice_id\n * - 'custom' → emits a prompt for ElevenLabs voice_design (used when no\n * premade fits)\n *\n * **Schema shape note:** this was originally `z.discriminatedUnion(...)` but\n * Anthropic's tool input_schema validator rejects union-at-root JSON Schemas —\n * it requires `\"type\": \"object\"` at the top level (`tools.0.custom.input_schema.type:\n * Field required`). Flattening to a single object with both optional fields +\n * a `.refine()` produces a valid schema (root is an object) while still\n * enforcing the per-variant required-field rule at parse time. `callLLM`'s\n * schema.safeParse triggers a retry-with-feedback if the LLM emits an invalid\n * combination (e.g., 'premade' without voice_id), so the LLM converges on\n * correct output.\n */\nexport const VoiceMatchSchema = z\n .object({\n voice_source: z.enum([\"premade\", \"custom\"]),\n voice_id: z.string().min(1).optional(),\n voice_design_prompt: z.string().max(500).optional(),\n reasoning: z.string().max(500),\n })\n .refine(\n (v) =>\n v.voice_source === \"premade\"\n ? typeof v.voice_id === \"string\" && v.voice_id.length > 0\n : typeof v.voice_design_prompt === \"string\" && v.voice_design_prompt.length > 0,\n {\n message:\n \"voice_id is required when voice_source='premade'; voice_design_prompt is required when voice_source='custom'\",\n },\n )\nexport type VoiceMatch = z.infer<typeof VoiceMatchSchema>\n","import type { TtsProvider } from \"./model-constants.js\"\n\n/**\n * A premade ElevenLabs voice as returned by `GET /v1/voices`.\n * Field names + types mirror the route verbatim: the route normalizes every\n * optional field to `\"\"` (never null), so these are all non-null strings.\n */\nexport interface Voice {\n voice_id: string\n name: string\n preview_url: string\n gender: string\n accent: string\n age: string\n description: string\n use_case: string\n category: string\n}\n\n/**\n * A shared/community Voice Library entry (`GET /v1/voices/library`).\n * Same shape as {@link Voice} plus the TTS provider the voice is verified on.\n */\nexport interface SharedVoice extends Voice {\n /**\n * The best of our TTS providers whose underlying ElevenLabs model the\n * voice lists in `verified_languages`, in the order `elevenlabs-v4` (when\n * verified for the base model `eleven_v4`), then `elevenlabs-v3`, which\n * renders any voice unmodified, then `elevenlabs-v4-turbo` (verified for the\n * exact id `eleven_v4_turbo`), then the cheapest v2 model: `elevenlabs-turbo`\n * preferred, else `elevenlabs-multilingual`. Only those two exact ids count\n * in the v4 family; the other `eleven_v4_…` variants (`_hq`, `_exp`, …) are\n * not models of ours and count toward nothing. Models the deployment does\n * not offer are never recommended.\n * Clients without a provider picker should send it as the `provider` on\n * text-to-speech so generation uses a model the voice is actually verified\n * for — rendering a voice on an unverified model is what makes output drift\n * audibly from its preview. Absent when the entry has no model metadata, or\n * when none of the models it is verified for is offered by the deployment.\n */\n recommendedProvider?: TtsProvider\n /**\n * Every TTS provider the voice is verified on and the deployment offers\n * (a subset of {@link TtsProvider}, in the order `elevenlabs-v4`,\n * `elevenlabs-v3`, `elevenlabs-v4-turbo`, `elevenlabs-turbo`,\n * `elevenlabs-multilingual` — the same order `recommendedProvider` is picked\n * from, so it is always the first entry); absent whenever\n * `recommendedProvider` is. Clients WITH a provider picker should only snap\n * the provider when the current choice is NOT in this set — most voices\n * verify more than one, and an explicit user choice within the set must win.\n * Do not switch over a closed list of members: a speech model added later\n * joins this set the release it ships.\n */\n verifiedProviders?: TtsProvider[]\n /**\n * The library's one-word tone for the voice (`calm`, `deep`, `cute`, …) —\n * one of {@link VOICE_LIBRARY_DESCRIPTIVES}, or a word the library added\n * since; `\"\"` when it states none, like every other field here. The value\n * a `descriptives` filter matches. Absent only on a server older than this\n * field.\n */\n descriptive?: string\n /**\n * The voice's primary language as the library codes it (`en`, `he`, …) and\n * its locale (`en-US`); `\"\"` when unstated. For what a `language` filter\n * matches see {@link SharedVoice.verifiedLanguages}. Absent only on a\n * server older than these fields.\n */\n language?: string\n locale?: string\n /**\n * Every language the voice is verified for, as the library codes them, the\n * primary language first — the set `GET /v1/voices/library?language=`\n * matches against (a voice whose primary language is English and that is\n * verified for Spanish is listed under `language=es`), and what the\n * `languages` facet counts. Absent only on a server older than this field.\n */\n verifiedLanguages?: string[]\n}\n\n/**\n * The `use_cases` values the Voice Library groups its voices by\n * (`GET /v1/voices/library?use_cases=<one>`): what a picker shows as its\n * categories. The route passes the value through verbatim, so a value the\n * library adds later works before it is listed here.\n */\nexport const VOICE_LIBRARY_USE_CASES = [\n \"advertisement\",\n \"characters_animation\",\n \"conversational\",\n \"entertainment_tv\",\n \"informative_educational\",\n \"narrative_story\",\n \"social_media\",\n] as const\nexport type VoiceLibraryUseCase = (typeof VOICE_LIBRARY_USE_CASES)[number]\n\n/**\n * The tones (`descriptives`) the Voice Library labels its voices with\n * (`GET /v1/voices/library?descriptives=<one>`), alphabetical — what a picker\n * shows as a category's sub-groups. Every voice carries at most one. The\n * library adds and drops words over time: this is the list it used when it\n * was last read (2026-11); `GET /v1/voices/library/facets` says which exist\n * now, with how many voices each, and the route passes any value through.\n */\nexport const VOICE_LIBRARY_DESCRIPTIVES = [\n \"anxious\",\n \"calm\",\n \"casual\",\n \"childish\",\n \"chill\",\n \"classy\",\n \"confident\",\n \"crisp\",\n \"cute\",\n \"deep\",\n \"excited\",\n \"formal\",\n \"gentle\",\n \"grumpy\",\n \"husky\",\n \"hyped\",\n \"intense\",\n \"mature\",\n \"meditative\",\n \"modulated\",\n \"neutral\",\n \"pleasant\",\n \"professional\",\n \"raspy\",\n \"relaxed\",\n \"robotic\",\n \"rough\",\n \"sad\",\n \"sassy\",\n \"serious\",\n \"soft\",\n \"upbeat\",\n \"whispery\",\n \"wise\",\n] as const\nexport type VoiceLibraryDescriptive = (typeof VOICE_LIBRARY_DESCRIPTIVES)[number]\n\n/** Query params for `GET /v1/voices/library`. All optional; sent as a querystring. */\nexport interface VoiceLibraryParams {\n search?: string\n gender?: string\n age?: string\n accent?: string\n /** A language code as the library uses them (`en`, `he`); matches a voice's VERIFIED languages, not only its primary one. */\n language?: string\n category?: string\n /** One of `VOICE_LIBRARY_USE_CASES` (any other string is passed through as sent). */\n use_cases?: VoiceLibraryUseCase | (string & {})\n /** One of `VOICE_LIBRARY_DESCRIPTIVES` (any other string is passed through as sent); one value per call. */\n descriptives?: VoiceLibraryDescriptive | (string & {})\n featured?: boolean\n /** e.g. \"trending\" — passed through to the route. */\n sort?: string\n /** 0-based page; route default 0. */\n page?: number\n /** Route default 30, clamped to 1..100. */\n page_size?: number\n}\n\n/** `GET /v1/voices/library` response. */\nexport interface VoiceLibraryResponse {\n voices: SharedVoice[]\n hasMore: boolean\n}\n\n/**\n * Query params for `GET /v1/voices/library/facets`: the listing's filters,\n * without paging and sort. All optional.\n */\nexport type VoiceLibraryFacetsParams = Pick<\n VoiceLibraryParams,\n \"search\" | \"gender\" | \"age\" | \"accent\" | \"language\" | \"category\" | \"use_cases\" | \"descriptives\" | \"featured\"\n>\n\n/** One value of a facet and how many voices carry it. */\nexport interface VoiceLibraryFacetCount {\n value: string\n count: number\n}\n\n/**\n * `GET /v1/voices/library/facets` response: for the filters sent, how many\n * library voices match (`total`) and that number broken down by every facet,\n * so one call fills a whole picker screen. Each facet's counts apply every\n * filter EXCEPT its own (a client shows every category's count while one is\n * chosen); values with no voices are left out; lists are sorted by count,\n * then by value. The values are the library's own spellings — the same\n * strings the listing's filters take.\n *\n * Counted over the platform's copy of the library, refreshed on a schedule\n * (`updatedAt` is when it was read), not over the live listing: a count may\n * trail the listing by a few voices. `languages` counts a voice under every\n * language it is verified for (what the listing's `language` filter matches),\n * so those counts add up to more than `total`.\n */\nexport interface VoiceLibraryFacets {\n /** Voices matching every filter sent. */\n total: number\n use_cases: VoiceLibraryFacetCount[]\n languages: VoiceLibraryFacetCount[]\n descriptives: VoiceLibraryFacetCount[]\n genders: VoiceLibraryFacetCount[]\n ages: VoiceLibraryFacetCount[]\n accents: VoiceLibraryFacetCount[]\n categories: VoiceLibraryFacetCount[]\n /**\n * True when `search` was sent: the library's own search is fuzzy (it stems\n * and tolerates a typo), which the counts cannot reproduce — under `search`\n * they match the name and description as written and are a lower estimate.\n */\n approximate: boolean\n /** When the copy these counts come from was read (ISO 8601); null when there is none (no speech key). */\n updatedAt: string | null\n /** Present (true) when the deployment has no speech key: nothing to count. */\n keyMissing?: boolean\n hint?: string\n}\n\n/**\n * A user voice clone. `GET /v1/voice-clones` returns the full shape; the create\n * response (`POST /v1/voice-clones/from-url`) returns only `id, name,\n * elevenlabsVoiceId, sampleAudioUrl, createdAt` (+ a credit-tracking `jobId`),\n * so the list-only fields are optional here. `elevenlabsVoiceId` is the id that\n * resolves the clone at text-to-speech time (use it as the selected voiceId).\n */\nexport interface VoiceClone {\n id: string\n name: string\n elevenlabsVoiceId: string\n sampleAudioUrl: string\n createdAt: string\n /** Present on the list response; absent on the create response. */\n description?: string | null\n previewUrl?: string | null\n gender?: string | null\n accent?: string | null\n updatedAt?: string\n /** Only on the create response (credit-tracking); never on the list. */\n jobId?: string\n}\n\n/**\n * What a favorite voice is — the `voiceType` a text-to-speech run takes for it:\n * a premade voice, a Voice Library voice, or one of the user's own clones\n * (`custom`). The one list the route, the MCP tool and the CLI validate against.\n */\nexport const VOICE_FAVORITE_TYPES = [\"premade\", \"library\", \"custom\"] as const\nexport type VoiceFavoriteType = (typeof VOICE_FAVORITE_TYPES)[number]\n\n/**\n * One of the signed-in user's favorite voices (`GET /v1/voices/favorites`), newest\n * first. `voiceId` is what a text-to-speech request takes as `voice` with\n * `voiceType`; `name` and `previewUrl` are the snapshot the client sent when it\n * starred the voice, so a favorites list renders with no second lookup.\n */\nexport interface VoiceFavorite {\n voiceId: string\n voiceType: VoiceFavoriteType\n name: string\n previewUrl: string | null\n createdAt: string\n}\n\n/** Body of `PUT /v1/voices/favorites/:voiceId`: the voice's kind and the snapshot to show it by. */\nexport interface VoiceFavoriteInput {\n voiceId: string\n voiceType: VoiceFavoriteType\n name: string\n previewUrl?: string | null\n}\n","import type { TtsProvider } from \"./model-constants.js\"\n\n/**\n * How the TTS layer resolves a voice id. Mirrors `CharacterVoice.voiceType` on\n * the frontend character node: `premade` voices resolve by NAME, `library` /\n * `custom` voices resolve by ID. Carry it alongside the id or premade-vs-library\n * resolution misroutes (see backend `direct-tts.ts`).\n */\nexport type VoiceType = \"premade\" | \"library\" | \"custom\"\n\n/**\n * A character's saved voice as supplied to the voiced-video orchestration on\n * `POST /v1/generate-video`. A deliberate subset of the frontend `CharacterVoice`:\n * only the fields the server needs to synthesise speech (no `voiceName` /\n * `traits` / `previewUrl`, which are display-only and never read server-side).\n *\n * `speaker` is the join key: it matches a {@link DialogueLine}.speaker so a\n * multi-speaker prompt routes each line to its own voice. Omit it for a\n * single-voice clip (one spec, no dialogue attribution needed).\n */\nexport interface CharacterVoiceSpec {\n /** ElevenLabs voice id, or the premade voice NAME when `voiceType === \"premade\"`. */\n readonly voiceId: string\n /** How the TTS layer resolves {@link voiceId}. Defaults to `\"premade\"` downstream. */\n readonly voiceType?: VoiceType\n /** Recommended TTS provider for this voice; forwarded as `provider` to TTS. */\n readonly ttsProvider?: TtsProvider\n /**\n * Speaker label this voice belongs to (e.g. \"Anna\"). Joined to\n * {@link DialogueLine}.speaker case-insensitively (trimmed). Omit for a\n * single-voice clip.\n */\n readonly speaker?: string\n}\n\n/** One attributed line of dialogue: who speaks (`speaker`) and what they say (`line`). */\nexport interface DialogueLine {\n readonly speaker: string\n readonly line: string\n}\n\n/**\n * A dialogue line resolved to a concrete voice: `{ text, voice }` per line, in\n * order. `voice` is OUR identifier (premade name or library/custom UUID) — the\n * direct ElevenLabs Dialogue call resolves it per line to the `voice_id` the\n * wire shape (`inputs[]`) wants. `voiceType` rides along so the TTS layer\n * resolves premade-by-name vs library/custom-by-id correctly.\n */\nexport interface ResolvedDialogueVoiceLine {\n readonly text: string\n readonly voice: string\n readonly voiceType?: VoiceType\n}\n\n// Quote characters built from code points so this file stays pure ASCII. The\n// published @nodaro/shared package must survive a re-save in any locale, and a\n// literal curly quote or em-dash here is exactly the CP1255 mojibake hazard that\n// has reached main before. RDQUO/LDQUO = curly double quotes, RAQUO/LAQUO =\n// guillemets, RSQUO = right single quote (apostrophe inside a name like O'Brien).\nconst RDQUO = String.fromCharCode(0x201d)\nconst LDQUO = String.fromCharCode(0x201c)\nconst RAQUO = String.fromCharCode(0x00bb)\nconst LAQUO = String.fromCharCode(0x00ab)\nconst RSQUO = String.fromCharCode(0x2019)\n\n/**\n * Matches one attributed, QUOTED line of dialogue. Built with `new RegExp` +\n * `String.raw` so the regex backslashes stay literal while the non-ASCII quote\n * characters are injected from the code-point consts above.\n *\n * - A leading boundary lookbehind (`^`, newline, sentence punctuation, or a\n * CLOSING quote) keeps the speaker capture from bridging a sentence: e.g.\n * \"...kitchen. Anna: \"hi\"\" yields speaker \"Anna\", not \"kitchen. Anna\", and the\n * speaker after a closing quote (\"hi\" Gordon: \"yo\") is still found.\n * - Speaker = 1 to 4 short words (names are short; no \".\" inside a token).\n * - Body = the first quoted run in straight, curly, or guillemet quotes.\n *\n * Requiring quotes is what stops cinematic direction (\"Setting: a forest\",\n * \"Camera: dolly in\") from being read as dialogue.\n */\nconst ATTRIBUTED_DIALOGUE_RE = new RegExp(\n String.raw`(?<=^|[\\n\\r.!?;,\"${RDQUO}${RAQUO}])\\s*([\\p{L}][\\p{L}\\p{N}'${RSQUO}-]*(?:\\s+[\\p{L}][\\p{L}\\p{N}'${RSQUO}-]*){0,3})\\s*:\\s*(?:\"([^\"]+)\"|${LDQUO}([^${RDQUO}]+)${RDQUO}|${LAQUO}([^${RAQUO}]+)${RAQUO})`,\n \"gu\",\n)\n\n/**\n * Extract attributed dialogue (`Speaker: \"line\"`) from a free-text prompt.\n *\n * Deterministic and intentionally conservative (see {@link ATTRIBUTED_DIALOGUE_RE}):\n * only QUOTED lines attributed to a short speaker label are matched. Callers that\n * already have structured dialogue (studio prompt chips) should pass it directly\n * and skip this parser. Order is preserved (it drives the stitched dialogue\n * track). Returns `[]` when no attributed quoted dialogue is found.\n */\nexport function parseAttributedDialogue(prompt: string): DialogueLine[] {\n if (!prompt) return []\n const out: DialogueLine[] = []\n for (const m of prompt.matchAll(ATTRIBUTED_DIALOGUE_RE)) {\n const speaker = m[1]?.trim() ?? \"\"\n const line = (m[2] ?? m[3] ?? m[4] ?? \"\").trim()\n if (speaker && line) out.push({ speaker, line })\n }\n return out\n}\n\n/**\n * Resolve each dialogue line to a concrete voice by joining `line.speaker` to\n * `voices[].speaker` (case-insensitive, trimmed) - the \"Speaker mapping\" model.\n *\n * Fallback order for an unmatched / unattributed line: the matched speaker's\n * voice -> `defaultVoiceId` -> the sole voice (when exactly one spec is given) ->\n * the first voice. A line resolves to nothing only when there are no voices and\n * no default, in which case it is dropped (the caller decides whether an empty\n * result means \"no dialogue to synthesise\"). This mirrors the pipeline's\n * non-fatal missing-voice behaviour (`allowDefaultVoiceFallback`).\n */\nexport function resolveDialogueVoices(\n dialogue: readonly DialogueLine[],\n voices: readonly CharacterVoiceSpec[],\n defaultVoiceId?: string,\n): ResolvedDialogueVoiceLine[] {\n const bySpeaker = new Map<string, CharacterVoiceSpec>()\n for (const v of voices) {\n const key = v.speaker?.trim().toLowerCase()\n if (key) bySpeaker.set(key, v)\n }\n const soleVoice = voices.length === 1 ? voices[0] : undefined\n const firstVoice = voices[0]\n\n const lineFor = (text: string, spec: CharacterVoiceSpec): ResolvedDialogueVoiceLine => ({\n text,\n voice: spec.voiceId,\n ...(spec.voiceType ? { voiceType: spec.voiceType } : {}),\n })\n\n const out: ResolvedDialogueVoiceLine[] = []\n for (const { speaker, line } of dialogue) {\n const text = line.trim()\n if (!text) continue\n const matched = bySpeaker.get(speaker.trim().toLowerCase())\n if (matched) {\n out.push(lineFor(text, matched))\n } else if (defaultVoiceId) {\n out.push({ text, voice: defaultVoiceId })\n } else if (soleVoice) {\n out.push(lineFor(text, soleVoice))\n } else if (firstVoice) {\n out.push(lineFor(text, firstVoice))\n }\n }\n return out\n}\n","import { z } from \"zod\"\n\n/**\n * Body for POST /v1/pipelines/:id/entities/:entity_id/reject.\n * Approve takes no body (optional `edits` future-deferred).\n */\nexport const EntityRejectInputSchema = z.object({\n feedback: z.string().min(1).max(2000),\n})\nexport type EntityRejectInput = z.infer<typeof EntityRejectInputSchema>\n\nexport const ENTITY_STATUSES = [\n \"pending\",\n \"generating\",\n \"awaiting_approval\",\n \"approved\",\n \"rejected\",\n \"failed\",\n // Phase 3 (granular-pipeline-control) — Stage 2 Character Wizard.\n // `pending_description` is the initial state for character entities in\n // manual/guided mode pipelines; the engine waits for the user's Step A\n // approval before generating the portrait. `skipped` is a terminal state\n // for entities the user explicitly opts out of (no generation, excluded\n // from stage-advance gating). Migration: 154_phase_1d3_character_wizard.sql.\n \"pending_description\",\n \"skipped\",\n] as const\nexport type EntityStatus = (typeof ENTITY_STATUSES)[number]\n\nexport const ENTITY_TYPES = [\"character\", \"object\", \"location\", \"scene\"] as const\nexport type EntityType = (typeof ENTITY_TYPES)[number]\n","import { z } from \"zod\"\n\n/**\n * Image Critic types — shared between backend (Sonnet vision call) and\n * frontend (helper result modal renderers). The schema lives in\n * `@nodaro/shared` so the helper-result schemas in `scene-helper-types.ts`\n * can compose it, and the frontend modal can render a typed\n * {@link ImageCriticVerdict} without a backend round-trip-only type.\n *\n * The runtime + persistence implementation lives in\n * `backend/src/ee/pipelines/llms/image-critic.ts` which re-exports these\n * schemas for callers that import from one place.\n */\n\n/**\n * Issue types the Image Critic can flag. `continuity_break` is the\n * Phase 1C.1 newcomer — fires when a prior-shot last_frame is supplied\n * and the new keyframe doesn't plausibly continue from it.\n */\nexport const ImageCriticIssueSchema = z.object({\n type: z.enum([\n \"continuity_break\",\n \"identity_mismatch\",\n \"composition_break\",\n \"wardrobe_inconsistency\",\n \"style_drift\",\n \"prompt_mismatch\",\n ]),\n severity: z.enum([\"blocking\", \"warning\", \"info\"]),\n message: z.string(),\n suggested_fix: z.string().optional(),\n})\nexport type ImageCriticIssue = z.infer<typeof ImageCriticIssueSchema>\n\nexport const ImageCriticVerdictSchema = z.object({\n ok: z.boolean(),\n issues: z.array(ImageCriticIssueSchema),\n notes: z.string().max(500),\n})\nexport type ImageCriticVerdict = z.infer<typeof ImageCriticVerdictSchema>\n","import { z } from \"zod\"\n\nexport const IMAGE_CRITIC_LEAF_MODES = [\n \"character-consistency\",\n \"realism\",\n \"prompt-adherence\",\n \"anatomy\",\n \"aesthetic\",\n \"style-match\",\n] as const\n\nexport const IMAGE_CRITIC_MODES = [\n ...IMAGE_CRITIC_LEAF_MODES,\n \"all\",\n] as const\n\nexport type ImageCriticLeafMode = (typeof IMAGE_CRITIC_LEAF_MODES)[number]\nexport type ImageCriticMode = (typeof IMAGE_CRITIC_MODES)[number]\n\nconst modeResult = z.object({\n score: z.number().min(0).max(1),\n feedback: z.string().min(1).max(300),\n})\n\nconst issue = z.object({\n category: z.string(),\n severity: z.enum([\"blocking\", \"warning\", \"info\"]),\n description: z.string().max(400),\n})\n\n// The critic LLM frequently emits `issues` as a bare string array even when the\n// prompt asks for objects. Coerce strings into the issue shape so an otherwise\n// well-formed critique isn't rejected as invalid_llm_output (which surfaced as\n// a 502 from the /v1/image-critic route). Objects pass through unchanged.\nconst issueLenient = z.preprocess(\n (v) =>\n typeof v === \"string\"\n ? { category: \"general\", severity: \"warning\", description: v.slice(0, 400) }\n : v,\n issue,\n)\n\nexport const ImageCriticResultSchema = z.object({\n score: z.number().min(0).max(1),\n feedback: z.string().min(1).max(600),\n issues: z.array(issueLenient).optional(),\n perMode: z\n .object({\n \"character-consistency\": modeResult.optional(),\n \"realism\": modeResult.optional(),\n \"prompt-adherence\": modeResult.optional(),\n \"anatomy\": modeResult.optional(),\n \"aesthetic\": modeResult.optional(),\n \"style-match\": modeResult.optional(),\n })\n .strict()\n .optional(),\n})\n\nexport type ImageCriticResult = z.infer<typeof ImageCriticResultSchema>\nexport type ImageCriticNodeIssue = z.infer<typeof issue>\n","import { z } from \"zod\"\nimport { ImageCriticVerdictSchema } from \"./image-critic-types.js\"\nimport { ShotSpecSchema } from \"./scene-node-types.js\"\n\n/**\n * All 10 helpers — 7 text/planning helpers shipped in Phase 1B.3 +\n * 3 vision-keyframe helpers activated in Phase 1C.1.\n * Names match the §6.11 spec sub-section labels (URL-safe form).\n */\nexport const SCENE_HELPER_NAMES = [\n // Text/planning-only — shipped in 1B.3\n \"audit_prompt\",\n \"improve_prompt\",\n \"generate_motion\",\n \"optimize_for_model\",\n \"add_broll\",\n \"bridge_to_next_scene\",\n \"anchor_scene_style\",\n // Vision-keyframe — activated in Phase 1C.1\n \"audit_images\",\n \"fix_continuity\",\n \"validate_match_cut\",\n] as const\n\nexport const SceneHelperNameSchema = z.enum(SCENE_HELPER_NAMES)\nexport type SceneHelperName = z.infer<typeof SceneHelperNameSchema>\n\n/**\n * UI-gating set used by `scene-helper-buttons.tsx` to render active vs disabled\n * buttons. Phase 1C.1 promoted the 3 vision-keyframe helpers from disabled →\n * active; the constant name is preserved for compat (it remains \"the set of\n * helpers currently shipped\"), and {@link ACTIVE_SCENE_HELPERS} is a clearer\n * alias for new code.\n */\nexport const HELPERS_SHIPPED_IN_1B3: ReadonlySet<SceneHelperName> = new Set([\n \"audit_prompt\",\n \"improve_prompt\",\n \"generate_motion\",\n \"optimize_for_model\",\n \"add_broll\",\n \"bridge_to_next_scene\",\n \"anchor_scene_style\",\n // Phase 1C.1 — activated\n \"audit_images\",\n \"fix_continuity\",\n \"validate_match_cut\",\n])\n\n/** Cleaner-named alias for {@link HELPERS_SHIPPED_IN_1B3}. */\nexport const ACTIVE_SCENE_HELPERS = HELPERS_SHIPPED_IN_1B3\n\n// ─── 6.11.2 Audit Prompt — Haiku, text-only ────────────────────────────────────\n\nexport const AuditPromptIssueSchema = z.object({\n shot_id: z.string(),\n severity: z.enum([\"blocking\", \"warning\", \"info\"]),\n issue_type: z.enum([\n \"contradiction\",\n \"missing_beat\",\n \"off_format\",\n \"camera_motion_mismatch\",\n ]),\n message: z.string(),\n suggested_fix: z.string(),\n})\n\nexport const AuditPromptResultSchema = z.object({\n scene_id: z.string(),\n ok: z.boolean(),\n issues_per_shot: z.array(AuditPromptIssueSchema),\n scene_level_notes: z.string().max(400),\n})\nexport type AuditPromptResult = z.infer<typeof AuditPromptResultSchema>\n\n// ─── 6.11.3 Improve Prompt — Sonnet, target enum ────────────────────────────────\n\nexport const ImprovePromptInputSchema = z.object({\n shot_ids: z.array(z.string()).min(1),\n field_targets: z.array(z.enum([\"action\", \"motion_prompt\", \"dialogue\"])).min(1),\n})\nexport type ImprovePromptInput = z.infer<typeof ImprovePromptInputSchema>\n\nexport const ImprovePromptResultSchema = z.object({\n scene_id: z.string(),\n shots: z.array(\n z.object({\n shot_id: z.string(),\n action: z.string().max(300).optional(),\n motion_prompt: z.string().max(200).optional(),\n dialogue_line: z.string().max(200).optional(),\n reasoning: z.string().max(300),\n }),\n ),\n})\nexport type ImprovePromptResult = z.infer<typeof ImprovePromptResultSchema>\n\n// ─── 6.11.5 Generate Motion — Haiku, fills motion_prompt ───────────────────────\n\nexport const GenerateMotionInputSchema = z.object({\n shot_ids: z.array(z.string()).min(1),\n})\n\nexport const GenerateMotionResultSchema = z.object({\n scene_id: z.string(),\n shots: z.array(\n z.object({\n shot_id: z.string(),\n motion_prompt: z.string().max(200),\n }),\n ),\n})\nexport type GenerateMotionResult = z.infer<typeof GenerateMotionResultSchema>\n\n// ─── 6.11.6 Optimize for Model — Sonnet, rewrites for new prompting_style ─────\n\nexport const OptimizeForModelInputSchema = z.object({\n target_model: z.string(),\n})\n\nexport const OptimizeForModelResultSchema = z.object({\n scene_id: z.string(),\n target_model: z.string(),\n shots: z.array(\n z.object({\n shot_id: z.string(),\n action: z.string().max(300),\n motion_prompt: z.string().max(200),\n }),\n ),\n rationale: z.string().max(300),\n})\nexport type OptimizeForModelResult = z.infer<typeof OptimizeForModelResultSchema>\n\n// ─── 6.11.7 Add B-Roll — Sonnet, proposes new shots ────────────────────────────\n\nexport const AddBRollResultSchema = z.object({\n scene_id: z.string(),\n candidates: z\n .array(\n z.object({\n proposed_insert_after_shot_id: z.string(),\n insert_kind: z.enum([\"reaction_shot\", \"cutaway\", \"establishing\", \"transition\"]),\n shot: ShotSpecSchema,\n rationale: z.string().max(200),\n }),\n )\n .min(1)\n .max(4),\n scene_duration_delta: z.number(),\n})\nexport type AddBRollResult = z.infer<typeof AddBRollResultSchema>\n\n// ─── 6.11.10 Bridge to Next Scene — Sonnet, generates bridge_image_prompt ──────\n\nexport const BridgeToNextSceneInputSchema = z.object({\n target_shot_id: z.string(),\n})\n\nexport const BridgeToNextSceneResultSchema = z.object({\n scene_id: z.string(),\n target_shot_id: z.string(),\n bridge_image_prompt: z.string().max(500),\n reasoning: z.string().max(300),\n})\nexport type BridgeToNextSceneResult = z.infer<typeof BridgeToNextSceneResultSchema>\n\n// ─── 6.11.11 Anchor Scene Style — Sonnet plans + image_model generates ─────────\n\nexport const AnchorSceneStyleResultSchema = z.object({\n scene_id: z.string(),\n anchor_prompt: z.string().max(800),\n asset_id: z.string().uuid(),\n asset_url: z.string().url(),\n credits_spent: z.number(),\n})\nexport type AnchorSceneStyleResult = z.infer<typeof AnchorSceneStyleResultSchema>\n\n// ─── 6.11.12 Audit Images — Sonnet vision, per-shot keyframe critic loop ──────\n//\n// Runs `runImageCritic` over every shot's keyframe_url in the scene (no body\n// inputs). Aggregates verdicts into a per-shot issue list. `ok` rolls up to\n// scene-level: false when any shot has a blocking issue.\n\nexport const AuditImagesShotEntrySchema = z.object({\n shot_id: z.string(),\n ok: z.boolean(),\n /** Verdict body — empty when the shot has no `keyframe_url` yet (skipped). */\n verdict: ImageCriticVerdictSchema.nullable(),\n /** True when the shot had no keyframe to audit. */\n skipped: z.boolean(),\n})\nexport type AuditImagesShotEntry = z.infer<typeof AuditImagesShotEntrySchema>\n\nexport const AuditImagesResultSchema = z.object({\n scene_id: z.string(),\n ok: z.boolean(),\n shot_issues: z.array(AuditImagesShotEntrySchema),\n /** Roll-up summary suitable for in-app display (\"3 of 5 shots have issues\"). */\n summary: z.string().max(400),\n})\nexport type AuditImagesResult = z.infer<typeof AuditImagesResultSchema>\n\n// ─── 6.11.13 Fix Continuity — Sonnet vision + i2i regen ──────────────────────\n//\n// Body: { target_shot_id }. Runs Image Critic against the target shot's\n// keyframe with its PRIOR shot's `last_frame_url`. If a `continuity_break`\n// blocking issue is found, regenerates the keyframe via\n// `pipelineGenerateImage` using the prior last_frame as a strong reference,\n// and persists the new keyframe_url back to the scene's shots[target].\n\nexport const FixContinuityInputSchema = z.object({\n target_shot_id: z.string(),\n})\nexport type FixContinuityInput = z.infer<typeof FixContinuityInputSchema>\n\nexport const FixContinuityResultSchema = z.object({\n scene_id: z.string(),\n target_shot_id: z.string(),\n action: z.enum([\"regenerated\", \"no_action_needed\"]),\n critic_verdict: ImageCriticVerdictSchema,\n /** Populated only when `action === \"regenerated\"`. */\n new_keyframe_url: z.string().url().optional(),\n new_keyframe_asset_id: z.string().uuid().optional(),\n})\nexport type FixContinuityResult = z.infer<typeof FixContinuityResultSchema>\n\n// ─── 6.11.14 Validate Match Cut — Sonnet vision ──────────────────────────────\n//\n// Body: { target_shot_id }. Loads the target shot's keyframe + the NEXT shot's\n// keyframe and asks the Image Critic to evaluate the match-cut quality.\n// Returns a `match_strength` summary + the critic's full verdict. Returns 400\n// `not_a_match_cut` from the route layer when `shot_intent.is_match_cut`\n// is false on the target shot (pre-flight check before credit reservation).\n\nexport const ValidateMatchCutInputSchema = z.object({\n target_shot_id: z.string(),\n})\nexport type ValidateMatchCutInput = z.infer<typeof ValidateMatchCutInputSchema>\n\nexport const ValidateMatchCutResultSchema = z.object({\n scene_id: z.string(),\n /** Tuple [shot_id_a, shot_id_b] — the target shot + the next shot. */\n shot_pair: z.tuple([z.string(), z.string()]),\n match_strength: z.enum([\"strong\", \"moderate\", \"weak\", \"break\"]),\n critic_verdict: ImageCriticVerdictSchema,\n /** Optional follow-up actions the user could take (free-form, ≤300 chars). */\n suggested_adjustments: z.string().max(300),\n})\nexport type ValidateMatchCutResult = z.infer<typeof ValidateMatchCutResultSchema>\n","/**\n * The parts of `settings.studio` that must not leave the owner's account.\n *\n * A shared production is read by anyone with the link. Three things inside the\n * document are the OWNER'S working state and nobody else's business:\n *\n * - `trash` — the recycle bin, which holds every shot, still and clip they\n * deleted, with prompts and urls intact. A share viewer receiving the bin is\n * the sharpest of the three: it hands out work the owner explicitly threw away.\n * - the in-flight job markers — `pendingClips` / `pendingStills` per shot, and\n * `pendingMusic` / `pendingDraft` on the document. A viewer cannot land any\n * of them and does not own them; all they carry across is job ids.\n * - `freecutDraftUrl` — an unsaved editor draft.\n *\n * Two more things are the owner's alone though neither is transient: a\n * scene's EMPTY media slots — unsubmitted drafts ({@link STUDIO_SHOT_DRAFT_KEYS})\n * — and a finished take's VOICE RECORD ({@link STUDIO_TAKE_VOICE_KEYS}), which\n * rides the canvas node's result rows rather than `settings`. The owner's own\n * reads and exports keep both; every other reader's projection drops them, and\n * drops them from the bin's deleted entries too.\n *\n * So is a LINKED (keyframe / sequence) production's owner state (T87), on the\n * same terms: the director's sequence recommendations\n * ({@link STUDIO_SEQUENCE_PLANNING_KEYS}), the current generation preferences\n * ({@link STUDIO_SEQUENCE_POLICY_KEYS} — emptied, not dropped), a take's\n * endpoint pins ({@link STUDIO_TAKE_SEQUENCE_KEYS}, on the result rows), a\n * sequence take unit's continuation review\n * ({@link STUDIO_SEQUENCE_UNIT_REVIEW_KEYS}), a unit result's frozen request\n * ({@link STUDIO_SEQUENCE_UNIT_MANIFEST_KEYS}), a keyframe's in-flight runs\n * and review record ({@link STUDIO_KEYFRAME_NODE_TRANSIENT_KEYS},\n * {@link STUDIO_KEYFRAME_TRANSIENT_KEYS}, {@link STUDIO_KEYFRAME_REVIEW_KEYS}),\n * and the owner's reason for waiving a keyframe's requirements, inside its\n * acceptance ({@link STUDIO_KEYFRAME_ACCEPTANCE_PRIVATE_KEYS}).\n *\n * They do NOT all live at the same level, and that is the whole reason this\n * file exists rather than one array: the writer puts `trash` and\n * `freecutDraftUrl` on `settings.studio` itself, and puts the per-shot markers\n * on the `settings.studio.shots[]` entry. A strip that walked only the top\n * level would pass its own test and still hand a share viewer every marker in\n * the production.\n *\n * It lives in `@nodaro/shared` because two independent readers need the SAME\n * list: the public share read (which is the reason the list exists) and the\n * production writer's own bundle projection. A second copy of a list like this\n * does not stay equal — it goes one key stale and the stale side is the one\n * that publishes.\n *\n * This is a plain JSON walker on purpose. `settings` is a free-form column that\n * a client owns end to end; the projection reads the keys it must drop and\n * nothing else, so it never needs — and must never grow — a dependency on\n * whatever writes the rest of the document.\n */\n\n/**\n * `settings.studio`'s OWN transient keys.\n *\n * The per-shot pending lists are on this list as well as the shot one on\n * purpose: nothing writes them here today, and a stray one from an older\n * client — or from a client that is not the studio editor at all — still must\n * not ride out to a viewer.\n */\nexport const STUDIO_TRANSIENT_KEYS = [\n \"trash\",\n \"pendingStills\",\n \"pendingClips\",\n // The two markers that genuinely DO live at this level: a soundtrack render\n // and a story-planning run in flight. Same rule as the per-shot pair — they\n // name jobs on the owner's account and nobody else can land them.\n \"pendingMusic\",\n \"pendingDraft\",\n \"freecutDraftUrl\",\n] as const\n\n/**\n * ...and a SHOT entry's, which is where the per-shot markers actually are.\n *\n * `pendingClip` (singular) is the pre-concurrent-markers shape; the editor's\n * reader still migrates it on parse, so a row can still be carrying one and it\n * is still in-flight state.\n */\nexport const STUDIO_SHOT_TRANSIENT_KEYS = [\"pendingClips\", \"pendingClip\", \"pendingStills\"] as const\n\n/**\n * ...and a SHOT entry's owner DRAFTS: the studio's empty media slots — a slot\n * the owner opened and filled in but has not generated from yet.\n *\n * Not transient — the owner's own exports and copies keep them — so they are\n * NOT on {@link STUDIO_SHOT_TRANSIENT_KEYS}. They are unsubmitted prose and\n * reference urls the owner never generated, so no OTHER reader receives them.\n * The studio codec keeps its own copy of these two keys for its own non-owner\n * projection.\n */\nexport const STUDIO_SHOT_DRAFT_KEYS = [\"stillSlots\", \"clipSlots\"] as const\n\n/**\n * ...and a SHOT's 3D previsualization RUN STATE, on `shots[].previsualization`:\n * `pendingJobs` (the scene runs in flight) and `proSubmission` (a 3D Render Pro\n * submission's idempotency key and its exact priced body). Same reason as the\n * per-shot markers — they name jobs on the owner's account — and a sharper one\n * for the Pro key: carried out, it would let a replay adopt the owner's paid\n * run. A finished render and an unadopted result (`pendingPlan`) are results,\n * not run state, and stay.\n *\n * The PUBLIC share read's strip only ({@link stripStudioTransientSettings}),\n * mirroring the studio codec's non-owner projection (`stripTransientSettings`,\n * which drops the same two keys). A `view` read keeps them, as the codec's\n * read-only load does ({@link stripStudioDraftSettings}).\n */\nexport const STUDIO_PREVIZ_RUN_STATE_KEYS = [\"pendingJobs\", \"proSubmission\"] as const\n\n/** Everything a shot entry loses on its way to a reader who is not its owner. */\nconst STUDIO_SHOT_PRIVATE_KEYS: ReadonlyArray<string> = [...STUDIO_SHOT_TRANSIENT_KEYS, ...STUDIO_SHOT_DRAFT_KEYS]\n\n/**\n * ...and a finished TAKE's voice record (studio ruling T42): the plan a clip\n * was recast with (`revoiceTo` — the owner's voice ids) and the Voice control's\n * mode (`voiceMode`). Both live on the RESULT, so on a canvas node's\n * `data.generatedResults` rows — never on `settings.studio.shots[]`, which is\n * why no settings strip reaches them ({@link stripStudioTakeVoiceRecords} does).\n *\n * Results only: a scene recipe's `voiceMode` and a clip's `revoicedVoiceId` /\n * `revoicedVoiceName` are not a take's record and stay. The studio codec keeps\n * its own copy of these two keys (`READER_PRIVATE_TAKE_KEYS`) for its own\n * non-owner projections, as it does the slot pair.\n */\nexport const STUDIO_TAKE_VOICE_KEYS = [\"revoiceTo\", \"voiceMode\"] as const\n\n/**\n * ...and a finished TAKE's SEQUENCE PINS (studio ruling T87): the exact\n * keyframe results a linked scene's clip was generated between\n * (`sequenceEndpoints`). Like the voice record it rides the RESULT, on a canvas\n * node's `data.generatedResults` rows, so the same walker drops both\n * ({@link stripStudioTakeVoiceRecords}). The in-flight marker carrying the same\n * pins (`pendingClips[].sequenceEndpoints`) already goes whole with\n * {@link STUDIO_SHOT_TRANSIENT_KEYS}.\n */\nexport const STUDIO_TAKE_SEQUENCE_KEYS = [\"sequenceEndpoints\"] as const\n\n/** Everything a result row loses on its way to a reader who is not its owner. */\nconst STUDIO_TAKE_PRIVATE_KEYS: ReadonlyArray<string> = [...STUDIO_TAKE_VOICE_KEYS, ...STUDIO_TAKE_SEQUENCE_KEYS]\n\n/**\n * ...and a LINKED production's SEQUENCE PLANNING state on `settings.studio`\n * itself (T87): `sequenceRecommendations`, the director's suggested generation\n * policies for each sequence, with their reasons and provenance.\n *\n * The studio codec's non-owner view withholds more than the lists here carry\n * — a take's `policy` and `compilation`, a unit's result rows (on the unit\n * video node's `data.sequenceUnitResults`, mirrored in its `generatedResults`),\n * a keyframe's `plan`, its `acceptance` record and all its results but the\n * preview and the accepted one — because it builds that view AFTER reading\n * the row. These strips drop KEYS from the stored row; they never filter rows\n * or rewrite records, so all of it still goes out, the acceptance without its\n * waiver reason ({@link STUDIO_KEYFRAME_ACCEPTANCE_PRIVATE_KEYS}).\n *\n * Part of it the codec's reader requires (0.13.0's `parseProduction`; without\n * it every reader's load of the production fails): each take's `policy` and\n * `compilation`; every unit result row some take selects, plus, for the take\n * selected for export, the existing-clip opening row its policy names; a\n * keyframe plan's `id`, `label`, `revision`, `frame` (any record, `{}`\n * included) and `requirements` (a list, empty included); and the result its\n * `previewResultKey` names. The rest it can do without: the unit node's\n * mirror, the unit results no take selects, a keyframe's other results, its\n * plan's `frame` content and `references`, and its `acceptance` — from which\n * the non-owner view reads the accepted result. Studio ruling T94 keeps all of\n * it visible.\n */\nexport const STUDIO_SEQUENCE_PLANNING_KEYS = [\"sequenceRecommendations\"] as const\n\n/**\n * ...and a sequence TAKE's per-unit review (T87), on\n * `settings.studio.sequenceTakes[].units[]`: `continuationAcceptance` — which\n * result the owner accepted as the next continuation's predecessor, who, when,\n * and the review checks.\n */\nexport const STUDIO_SEQUENCE_UNIT_REVIEW_KEYS = [\"continuationAcceptance\"] as const\n\n/**\n * ...and a LINKED production's current GENERATION PREFERENCES on\n * `settings.studio` (T87): `sequenceGenerationPolicies`, the policy the owner\n * last set for each sequence — what its next take would be made with.\n *\n * EMPTIED, never deleted: a non-empty record goes out as `{}`. The codec's\n * reader parses the key as a record whenever a production has takes, and\n * reads an empty one fine. A row that does not carry the key never gains it:\n * that reader takes the key alone for take state, and refuses it on a\n * production that never declared takes. Each take's own `policy` — the one it\n * was made with — stays (the reader requires it), so `{}` withholds the\n * owner's current preference, not the takes' history.\n */\nexport const STUDIO_SEQUENCE_POLICY_KEYS = [\"sequenceGenerationPolicies\"] as const\n\n/**\n * ...and a sequence unit RESULT's frozen request (T87), on a unit video node's\n * `data.sequenceUnitResults[]` rows: `requestManifest` — the submission as the\n * host froze it, with the compiled prompts, the reference media, the endpoint\n * pins, the take's policy and snapshots of the owner's scenes as they stood\n * then. Optional to the codec's reader; the rest of the row stays.\n */\nexport const STUDIO_SEQUENCE_UNIT_MANIFEST_KEYS = [\"requestManifest\"] as const\n\n/**\n * ...and a KEYFRAME's in-flight image runs (T87, on T22's terms), which the\n * writer keeps on the frame's image node: `data.keyframePendingImages`. Each\n * names a job on the owner's account, with the frame it was submitted with and\n * that submission's provenance; a reader can land none of them.\n */\nexport const STUDIO_KEYFRAME_NODE_TRANSIENT_KEYS = [\"keyframePendingImages\"] as const\n\n/**\n * ...and the same runs on a DELETED keyframe, where the bin keeps the whole\n * frame (`trash[].keyframe`, `kind: \"keyframe\"`) and calls them `pendingImages`.\n */\nexport const STUDIO_KEYFRAME_TRANSIENT_KEYS = [\"pendingImages\"] as const\n\n/**\n * ...and a KEYFRAME's review record (T87): `rejections` — which of its results\n * the owner sent back for revision, who, when and why — on each\n * `settings.studio.keyframes[]` entry and on a deleted keyframe in the bin.\n * Optional to the codec's reader. The frame's `acceptance` stays, without its\n * waiver reason ({@link STUDIO_KEYFRAME_ACCEPTANCE_PRIVATE_KEYS}): every reader\n * is shown the accepted result, and that is where the reader finds it.\n */\nexport const STUDIO_KEYFRAME_REVIEW_KEYS = [\"rejections\"] as const\n\n/**\n * ...and a KEYFRAME acceptance's private part (T87): `waivedReason`, the\n * owner's own words on why the requirements they waived are acceptable. It is\n * one level down, inside the `acceptance` record of each\n * `settings.studio.keyframes[]` entry and of a deleted keyframe in the bin, so\n * the walk goes into the record ({@link keyframeForReader}).\n *\n * Optional to the codec's reader; the rest of the record stays, the waived\n * requirement checks included. Only the codec's resolution of an accepted\n * frame checks the reason (`reviewValid`): in a copy made from a stripped row,\n * a frame that waived a requirement must be accepted again before the codec\n * resolves it for a dependent frame or a clip.\n */\nexport const STUDIO_KEYFRAME_ACCEPTANCE_PRIVATE_KEYS = [\"waivedReason\"] as const\n\n/**\n * Everything a deleted keyframe entry loses on its way to a reader who is not\n * its owner. Its acceptance loses {@link STUDIO_KEYFRAME_ACCEPTANCE_PRIVATE_KEYS}\n * as well.\n */\nconst STUDIO_KEYFRAME_PRIVATE_KEYS: ReadonlyArray<string> = [...STUDIO_KEYFRAME_TRANSIENT_KEYS, ...STUDIO_KEYFRAME_REVIEW_KEYS]\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === \"object\" && !Array.isArray(value)\n}\n\nfunction withoutKeys(\n source: Record<string, unknown>,\n drop: ReadonlyArray<string>,\n): Record<string, unknown> {\n const kept: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(source)) {\n if (drop.includes(key)) continue\n kept[key] = value\n }\n return kept\n}\n\n/**\n * `settings.studio.shots` with the given per-shot keys removed.\n *\n * Returns the SAME array when no shot carried one, so an idle production's\n * share read allocates nothing. Anything that is not a shot-shaped object rides\n * through untouched: this runs on whatever is in the column, and a projection\n * that threw on an unexpected row would take the share read down with it.\n */\nfunction stripShots(value: unknown, drop: ReadonlyArray<string>): unknown {\n if (!Array.isArray(value)) return value\n let changed = false\n const out = value.map((entry) => {\n if (!entry || typeof entry !== \"object\" || Array.isArray(entry)) return entry\n const shot = entry as Record<string, unknown>\n if (!drop.some((key) => key in shot)) return entry\n changed = true\n return withoutKeys(shot, drop)\n })\n return changed ? out : value\n}\n\n/**\n * `settings.studio.shots` with every shot's 3D run state\n * ({@link STUDIO_PREVIZ_RUN_STATE_KEYS}) removed from its `previsualization`.\n * The SAME array back when no shot carried any, and anything that is not\n * shaped like a shot with a previsualization rides through untouched.\n */\nfunction stripPrevizRunState(value: unknown): unknown {\n if (!Array.isArray(value)) return value\n let changed = false\n const out = value.map((entry) => {\n if (!isRecord(entry)) return entry\n const previz = entry.previsualization\n if (!isRecord(previz) || !STUDIO_PREVIZ_RUN_STATE_KEYS.some((key) => key in previz)) return entry\n changed = true\n return { ...entry, previsualization: withoutKeys(previz, STUDIO_PREVIZ_RUN_STATE_KEYS) }\n })\n return changed ? out : value\n}\n\n/**\n * A production's `settings` with the owner's working state removed.\n *\n * Copy-on-write, and structurally: it rebuilds the objects without those keys\n * rather than deleting from the caller's, so the stored row is untouched. A\n * `settings` with no `studio` comes back unchanged — this is a studio concern,\n * and a workflow that is not a production has nothing here to strip.\n *\n * Takes and returns `unknown` because the column is free-form and every caller\n * already holds it as whatever its own layer calls JSON; narrowing here would\n * only move the cast one line up.\n */\nexport function stripStudioTransientSettings(settings: unknown): unknown {\n if (!settings || typeof settings !== \"object\") return settings\n const studio = (settings as { studio?: unknown }).studio\n if (!studio || typeof studio !== \"object\" || Array.isArray(studio)) return settings\n\n const source = studio as Record<string, unknown>\n const kept = withoutKeys(source, STUDIO_TRANSIENT_KEYS)\n const shots = stripPrevizRunState(stripShots(source.shots, STUDIO_SHOT_PRIVATE_KEYS))\n if (source.shots !== undefined) kept.shots = shots\n const planned = stripLinkedOwnerState(kept)\n\n // Nothing to drop at any level — hand back the original object so an\n // ordinary share read allocates nothing.\n if (Object.keys(kept).length === Object.keys(source).length && shots === source.shots && planned === kept) {\n return settings\n }\n return { ...(settings as Record<string, unknown>), studio: planned }\n}\n\n/**\n * A workflow's `nodes` without the owner's state that rides a NODE rather\n * than `settings`: every result row's voice record\n * ({@link STUDIO_TAKE_VOICE_KEYS}, T42) and sequence pins\n * ({@link STUDIO_TAKE_SEQUENCE_KEYS}, T87), every sequence unit result's\n * frozen request ({@link STUDIO_SEQUENCE_UNIT_MANIFEST_KEYS}, T87), and a\n * keyframe image node's in-flight runs\n * ({@link STUDIO_KEYFRAME_NODE_TRANSIENT_KEYS}, T87). Named for the first.\n *\n * Every node is walked, not only a clip, unit or keyframe node: the keys exist\n * only on those, and a type list would be one more thing to keep in step.\n * Copy-on-write, and the SAME array back when no node carries any of the keys.\n * Anything that is not node-shaped rides through untouched: this runs on\n * whatever is in the column.\n */\nexport function stripStudioTakeVoiceRecords(nodes: unknown): unknown {\n if (!Array.isArray(nodes)) return nodes\n let changed = false\n const out = nodes.map((node: unknown) => {\n const data = isRecord(node) ? node.data : undefined\n if (!isRecord(data)) return node\n const results = stripRows(data.generatedResults, STUDIO_TAKE_PRIVATE_KEYS)\n const unitResults = stripRows(data.sequenceUnitResults, STUDIO_SEQUENCE_UNIT_MANIFEST_KEYS)\n const running = STUDIO_KEYFRAME_NODE_TRANSIENT_KEYS.some((key) => key in data)\n if (results === data.generatedResults && unitResults === data.sequenceUnitResults && !running) return node\n changed = true\n const kept = withoutKeys(data, STUDIO_KEYFRAME_NODE_TRANSIENT_KEYS)\n if (results !== data.generatedResults) kept.generatedResults = results\n if (unitResults !== data.sequenceUnitResults) kept.sequenceUnitResults = unitResults\n return { ...(node as Record<string, unknown>), data: kept }\n })\n return changed ? out : nodes\n}\n\n/**\n * A list of rows with the given keys off every row — a node's result rows, a\n * unit's result rows. The SAME array back when no row carries one, and\n * anything that is not a list, or not a row, rides through untouched.\n */\nfunction stripRows(value: unknown, drop: ReadonlyArray<string>): unknown {\n if (!Array.isArray(value)) return value\n let changed = false\n const out = value.map((row: unknown) => {\n if (!isRecord(row) || !drop.some((key) => key in row)) return row\n changed = true\n return withoutKeys(row, drop)\n })\n return changed ? out : value\n}\n\n/**\n * `settings.studio` without the linked production's owner state these lists\n * carry (T87): its own {@link STUDIO_SEQUENCE_PLANNING_KEYS}; each\n * {@link STUDIO_SEQUENCE_POLICY_KEYS} record EMPTIED, never dropped and never\n * added; every sequence take's units without their\n * {@link STUDIO_SEQUENCE_UNIT_REVIEW_KEYS}; and every keyframe entry without\n * its {@link STUDIO_KEYFRAME_REVIEW_KEYS} or its acceptance's\n * {@link STUDIO_KEYFRAME_ACCEPTANCE_PRIVATE_KEYS}. Every other part of a take\n * or a frame stays, including what the codec's reader requires to read the\n * row (which part that is: {@link STUDIO_SEQUENCE_PLANNING_KEYS}).\n *\n * The ONE change site for both settings strips. The SAME object back when it\n * carries none of it, and anything that is not take- or frame-shaped rides\n * through — a preferences value that is not a record included.\n */\nfunction stripLinkedOwnerState(studio: Record<string, unknown>): Record<string, unknown> {\n const takes = stripTakeUnitReviews(studio.sequenceTakes)\n const keyframes = stripKeyframes(studio.keyframes)\n const preferences = STUDIO_SEQUENCE_POLICY_KEYS.filter((key) => {\n const value = studio[key]\n return isRecord(value) && Object.keys(value).length > 0\n })\n if (!STUDIO_SEQUENCE_PLANNING_KEYS.some((key) => key in studio) && takes === studio.sequenceTakes\n && keyframes === studio.keyframes && preferences.length === 0) return studio\n const kept = withoutKeys(studio, STUDIO_SEQUENCE_PLANNING_KEYS)\n if (takes !== studio.sequenceTakes) kept.sequenceTakes = takes\n if (keyframes !== studio.keyframes) kept.keyframes = keyframes\n for (const key of preferences) kept[key] = {}\n return kept\n}\n\n/** `settings.studio.sequenceTakes` with every unit's review removed; the SAME array back when no unit carries one. */\nfunction stripTakeUnitReviews(value: unknown): unknown {\n if (!Array.isArray(value)) return value\n let changed = false\n const out = value.map((take: unknown) => {\n if (!isRecord(take) || !Array.isArray(take.units)) return take\n let touched = false\n const units = take.units.map((unit: unknown) => {\n if (!isRecord(unit) || !STUDIO_SEQUENCE_UNIT_REVIEW_KEYS.some((key) => key in unit)) return unit\n touched = true\n return withoutKeys(unit, STUDIO_SEQUENCE_UNIT_REVIEW_KEYS)\n })\n if (!touched) return take\n changed = true\n return { ...take, units }\n })\n return changed ? out : value\n}\n\n/**\n * `settings.studio.keyframes` with every entry as {@link keyframeForReader}\n * leaves it: no {@link STUDIO_KEYFRAME_REVIEW_KEYS}, no acceptance waiver\n * reason. The SAME array back when no entry carries either, and anything that\n * is not a list, or not an entry, rides through untouched.\n */\nfunction stripKeyframes(value: unknown): unknown {\n if (!Array.isArray(value)) return value\n let changed = false\n const out = value.map((frame: unknown) => {\n if (!isRecord(frame)) return frame\n const kept = keyframeForReader(frame, STUDIO_KEYFRAME_REVIEW_KEYS)\n if (kept !== frame) changed = true\n return kept\n })\n return changed ? out : value\n}\n\n/**\n * A keyframe entry, live or deleted, without the given keys and without its\n * acceptance's {@link STUDIO_KEYFRAME_ACCEPTANCE_PRIVATE_KEYS}; the rest of the\n * acceptance stays. The ONE place either level is dropped, for the live\n * entries ({@link stripKeyframes}) and the bin's ({@link binKeyframeForReader}).\n * The SAME entry back when it carries none of it; an acceptance that is not a\n * record rides through.\n */\nfunction keyframeForReader(frame: Record<string, unknown>, drop: ReadonlyArray<string>): Record<string, unknown> {\n const acceptance = frame.acceptance\n const waived = isRecord(acceptance) && STUDIO_KEYFRAME_ACCEPTANCE_PRIVATE_KEYS.some((key) => key in acceptance)\n if (!waived && !drop.some((key) => key in frame)) return frame\n const kept = withoutKeys(frame, drop)\n if (waived) kept.acceptance = withoutKeys(acceptance, STUDIO_KEYFRAME_ACCEPTANCE_PRIVATE_KEYS)\n return kept\n}\n\n/**\n * `settings` with every SHOT's owner-private state removed — its empty media\n * slots ({@link STUDIO_SHOT_DRAFT_KEYS}) and its in-flight run markers\n * ({@link STUDIO_SHOT_TRANSIENT_KEYS}) — and the bin kept WITHOUT the owner's\n * drafts in it ({@link stripBin}: deleted empty slots, deleted takes' voice\n * records) — and without a linked production's owner state\n * ({@link stripLinkedOwnerState}, T87). The document-level markers and\n * everything else stay.\n *\n * For a reader the owner let LOOK but not edit: a `view` reader's\n * `GET /v1/workflows/:id` and `GET /v1/workflows/:id/export`, and the MCP\n * `get_workflow_json` / `export_workflow` tools on the same access — each\n * through {@link stripStudioDraftWorkflow}, which strips the nodes as well.\n * The markers go with the slots because a viewer cannot land the owner's runs,\n * and a marker for a run started from a slot carries that slot's unsent\n * inputs. An editor keeps all of it: their editor saves `settings` back whole.\n *\n * The very same object back when neither a shot, the bin nor the linked\n * owner state carries any of it.\n */\nexport function stripStudioDraftSettings(settings: unknown): unknown {\n if (!settings || typeof settings !== \"object\") return settings\n const studio = (settings as { studio?: unknown }).studio\n if (!isRecord(studio)) return settings\n const shots = stripShots(studio.shots, STUDIO_SHOT_PRIVATE_KEYS)\n const trash = stripBin(studio.trash)\n const planned = stripLinkedOwnerState(studio)\n if (shots === studio.shots && trash === studio.trash && planned === studio) return settings\n const kept: Record<string, unknown> = { ...planned }\n if (shots !== studio.shots) kept.shots = shots\n if (trash !== studio.trash) kept.trash = trash\n return { ...(settings as Record<string, unknown>), studio: kept }\n}\n\n/**\n * The owner's BIN (`settings.studio.trash`) as a `view` reader receives it —\n * T11, T42 and T87 applied to what the owner deleted:\n *\n * - a deleted EMPTY slot (`kind: \"slot\"`) goes whole: it is an unsubmitted\n * draft, prose and reference urls the owner never generated;\n * - a deleted SCENE (`kind: \"shot\"`) is a one-scene production graph, so it\n * gets what a live production gets: the owner's state off the graph's nodes\n * (takes' records and sequence pins, unit results' frozen requests, frame\n * runs), its slots and runs off the graph's scene entry, and its linked\n * owner state off the graph's settings;\n * - a deleted KEYFRAME (`kind: \"keyframe\"`) keeps the frame without its\n * in-flight runs, its review record or its acceptance's waiver reason\n * ({@link binKeyframeForReader});\n * - any other entry — a deleted take (`kind: \"clip\"`, or a legacy entry with\n * no kind, which the bin reads as a clip) — keeps its result without the\n * voice record or the sequence pins. A deleted still carries none and rides\n * through.\n *\n * Mirrors the studio codec's `withoutBinDrafts` branch for branch (that walker\n * does not drop the T87 state yet, and lets a deleted keyframe through\n * whole). Copy-on-write, the SAME array back when no entry carries any of it,\n * and anything that is not an entry rides through untouched.\n */\nfunction stripBin(trash: unknown): unknown {\n if (!Array.isArray(trash)) return trash\n let changed = false\n const out: unknown[] = []\n for (const entry of trash as unknown[]) {\n if (isRecord(entry) && entry.kind === \"slot\") {\n changed = true\n continue\n }\n const kept = !isRecord(entry) ? entry\n : entry.kind === \"shot\" ? binSceneForReader(entry)\n : entry.kind === \"keyframe\" ? binKeyframeForReader(entry)\n : binTakeForReader(entry)\n if (kept !== entry) changed = true\n out.push(kept)\n }\n return changed ? out : trash\n}\n\n/** A deleted scene's graph through the two `view` strips. */\nfunction binSceneForReader(entry: Record<string, unknown>): Record<string, unknown> {\n const graph = entry.graph\n if (!isRecord(graph)) return entry\n const nodes = stripStudioTakeVoiceRecords(graph.nodes)\n const settings = stripStudioDraftSettings(graph.settings)\n if (nodes === graph.nodes && settings === graph.settings) return entry\n return { ...entry, graph: { ...graph, nodes, settings } }\n}\n\n/** A deleted take without its voice record or sequence pins; any other entry as it is. */\nfunction binTakeForReader(entry: Record<string, unknown>): Record<string, unknown> {\n const result = entry.result\n if (!isRecord(result) || !STUDIO_TAKE_PRIVATE_KEYS.some((key) => key in result)) return entry\n return { ...entry, result: withoutKeys(result, STUDIO_TAKE_PRIVATE_KEYS) }\n}\n\n/**\n * A deleted keyframe without its in-flight runs or its review record\n * ({@link STUDIO_KEYFRAME_PRIVATE_KEYS}), and without its acceptance's waiver\n * reason ({@link keyframeForReader}); the SAME entry back when it carries none\n * of it.\n */\nfunction binKeyframeForReader(entry: Record<string, unknown>): Record<string, unknown> {\n const keyframe = entry.keyframe\n if (!isRecord(keyframe)) return entry\n const kept = keyframeForReader(keyframe, STUDIO_KEYFRAME_PRIVATE_KEYS)\n return kept === keyframe ? entry : { ...entry, keyframe: kept }\n}\n\n/**\n * A workflow row as a reader the owner let LOOK but not edit receives it: the\n * owner's state off its `nodes` ({@link stripStudioTakeVoiceRecords}) and the\n * owner's drafts, runs and linked-production state off its `settings`\n * ({@link stripStudioDraftSettings}).\n *\n * The ONE strip every `view` door applies, so no door can strip the settings\n * and forget the nodes. A half the row does not carry is not added. Copy-on-\n * write, and the very same row back when neither half changed.\n */\nexport function stripStudioDraftWorkflow<T extends { nodes?: unknown; settings?: unknown }>(row: T): T {\n const nodes = \"nodes\" in row ? stripStudioTakeVoiceRecords(row.nodes) : row.nodes\n const settings = \"settings\" in row ? stripStudioDraftSettings(row.settings) : row.settings\n if (nodes === row.nodes && settings === row.settings) return row\n return {\n ...row,\n ...(nodes !== row.nodes ? { nodes } : {}),\n ...(settings !== row.settings ? { settings } : {}),\n }\n}\n","/** Public workflow capability marker; creative planning stays in the Studio codec. */\nexport const STUDIO_DEPENDENT_FRAMES_CAPABILITY = \"studio-dependent-frames-v1\"\n\nexport class SequenceExecutionRequiredError extends Error {\n readonly code = \"sequence_execution_required\"\n readonly statusCode = 400\n constructor(readonly nodeIds: readonly string[]) {\n super(\"Generate linked frames and clips in Studio or through its production API so the reviewed images are used.\")\n this.name = \"SequenceExecutionRequiredError\"\n }\n}\n\n/** A missing declaration must not make a recognizable dependency node runnable. */\nexport function requiresSequenceExecution(node: { data?: unknown }): boolean {\n if (!node.data || typeof node.data !== \"object\" || Array.isArray(node.data)) return false\n const data = node.data as Record<string, unknown>\n return data.keyframeId !== undefined || data.sequenceBinding !== undefined\n || (Array.isArray(data.requiredCapabilities) && data.requiredCapabilities.includes(STUDIO_DEPENDENT_FRAMES_CAPABILITY))\n}\n\nexport function assertCanvasExecutionAllowed(nodes: readonly { id: string; data?: unknown }[]): void {\n const blocked = nodes.filter(requiresSequenceExecution).map((node) => node.id)\n if (blocked.length) throw new SequenceExecutionRequiredError(blocked)\n}\n"]}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkO7DXNX5J_cjs = require('./chunk-O7DXNX5J.cjs');
|
|
4
|
+
var chunkCGZLENU4_cjs = require('./chunk-CGZLENU4.cjs');
|
|
5
5
|
|
|
6
6
|
// src/dialogue-capabilities.ts
|
|
7
7
|
function findDialogueCapabilities(provider) {
|
|
8
8
|
if (typeof provider !== "string" || !provider) return void 0;
|
|
9
|
-
if (!Object.hasOwn(
|
|
10
|
-
const entry =
|
|
9
|
+
if (!Object.hasOwn(chunkCGZLENU4_cjs.MODEL_CATALOG, provider)) return void 0;
|
|
10
|
+
const entry = chunkCGZLENU4_cjs.MODEL_CATALOG[provider];
|
|
11
11
|
return entry.modes.includes("dialogue") ? entry.tts : void 0;
|
|
12
12
|
}
|
|
13
13
|
function dialogueProviderOf(provider) {
|
|
14
|
-
return findDialogueCapabilities(provider) ? provider :
|
|
14
|
+
return findDialogueCapabilities(provider) ? provider : chunkO7DXNX5J_cjs.DEFAULT_DIALOGUE_PROVIDER;
|
|
15
15
|
}
|
|
16
16
|
function getDialogueCapabilities(provider) {
|
|
17
|
-
return
|
|
17
|
+
return chunkCGZLENU4_cjs.MODEL_CATALOG[dialogueProviderOf(provider)].tts;
|
|
18
18
|
}
|
|
19
19
|
function dialogueHasLever(provider, lever) {
|
|
20
20
|
return getDialogueCapabilities(provider).levers.includes(lever);
|
|
@@ -34,5 +34,5 @@ exports.dialogueStabilityAccepted = dialogueStabilityAccepted;
|
|
|
34
34
|
exports.dialogueSupportsTimestamps = dialogueSupportsTimestamps;
|
|
35
35
|
exports.findDialogueCapabilities = findDialogueCapabilities;
|
|
36
36
|
exports.getDialogueCapabilities = getDialogueCapabilities;
|
|
37
|
-
//# sourceMappingURL=chunk-
|
|
38
|
-
//# sourceMappingURL=chunk-
|
|
37
|
+
//# sourceMappingURL=chunk-IKP4GOWZ.cjs.map
|
|
38
|
+
//# sourceMappingURL=chunk-IKP4GOWZ.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dialogue-capabilities.ts"],"names":["MODEL_CATALOG","DEFAULT_DIALOGUE_PROVIDER"],"mappings":";;;;;;AAeO,SAAS,yBAAyB,QAAA,EAAgD;AACvF,EAAA,IAAI,OAAO,QAAA,KAAa,QAAA,IAAY,CAAC,UAAU,OAAO,MAAA;AACtD,EAAA,IAAI,CAAC,MAAA,CAAO,MAAA,CAAOA,+BAAA,EAAe,QAAQ,GAAG,OAAO,MAAA;AACpD,EAAA,MA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pD,EAAA,MAAM,KAAA,GAAQA,gCAAc,QAAQ,CAAA;AACpC,EAAA,OAAO,MAAM,KAAA,CAAM,QAAA,CAAS,UAAU,CAAA,GAAI,MAAM,GAAA,GAAM,MAAA;AACxD;AAGO,SAAS,mBAAmB,QAAA,EAAqC;AACtE,EAAA,OAAO,wBAAA,CAAyB,QAAQ,CAAA,GAAK,QAAA,GAAgCC,2CAAA;AAC/E;AAGO,SAAS,wBAAwB,QAAA,EAAoC;AAC1E,EAAA,OAAOD,+BAAA,CAAc,kBAAA,CAAmB,QAAQ,CAAC,CAAA,CAAG,GAAA;AACtD;AAGO,SAAS,gBAAA,CAAiB,UAAmB,KAAA,EAAiC;AACnF,EAAA,OAAO,uBAAA,CAAwB,QAAQ,CAAA,CAAE,MAAA,CAAO,SAAS,KAAK,CAAA;AAChE;AAGO,SAAS,2BAA2B,QAAA,EAA4B;AACrE,EAAA,OAAO,uBAAA,CAAwB,QAAQ,CAAA,CAAE,UAAA;AAC3C;AAGO,SAAS,yBAAA,CAA0B,UAAmB,KAAA,EAAwB;AACnF,EAAA,IAAI,CAAC,OAAO,QAAA,CAAS,KAAK,KAAK,KAAA,GAAQ,CAAA,IAAK,KAAA,GAAQ,CAAA,EAAG,OAAO,KAAA;AAC9D,EAAA,MAAM,KAAA,GAAQ,uBAAA,CAAwB,QAAQ,CAAA,CAAE,cAAA;AAChD,EAAA,OAAO,KAAA,GAAQ,KAAA,CAAM,QAAA,CAAS,KAAK,CAAA,GAAI,IAAA;AACzC","file":"chunk-IKP4GOWZ.cjs","sourcesContent":["/**\n * Capability lookups for the DIALOGUE lane (`/v1/text-to-dialogue`, the Text to\n * Dialogue node, the voiced-video multi-speaker track).\n *\n * The dialogue models carry a `tts` sheet in `MODEL_CATALOG` like the\n * text-to-speech models, but each lane answers only for its own models: the\n * text-to-speech lookups (`tts-capabilities.ts`) treat a dialogue id as unknown,\n * and these treat a text-to-speech id as unknown. An unknown id here runs as\n * {@link DEFAULT_DIALOGUE_PROVIDER} (v3 dialogue) — not as the text-to-speech\n * fallback (turbo), which has no dialogue form.\n */\nimport { MODEL_CATALOG, type TtsCapabilities, type TtsSettingLever } from \"./model-catalog.js\"\nimport { DEFAULT_DIALOGUE_PROVIDER, type DialogueProvider } from \"./model-constants.js\"\n\n/** The sheet of a dialogue model, or `undefined` when the id is not one. Own properties only; a non-string is unknown. */\nexport function findDialogueCapabilities(provider: unknown): TtsCapabilities | undefined {\n if (typeof provider !== \"string\" || !provider) return undefined\n if (!Object.hasOwn(MODEL_CATALOG, provider)) return undefined\n const entry = MODEL_CATALOG[provider]!\n return entry.modes.includes(\"dialogue\") ? entry.tts : undefined\n}\n\n/** The dialogue model a request naming `provider` runs on (and is billed as). */\nexport function dialogueProviderOf(provider: unknown): DialogueProvider {\n return findDialogueCapabilities(provider) ? (provider as DialogueProvider) : DEFAULT_DIALOGUE_PROVIDER\n}\n\n/** The sheet a dialogue request runs under. */\nexport function getDialogueCapabilities(provider: unknown): TtsCapabilities {\n return MODEL_CATALOG[dialogueProviderOf(provider)]!.tts!\n}\n\n/** The dialogue model honours this voice-setting lever. */\nexport function dialogueHasLever(provider: unknown, lever: TtsSettingLever): boolean {\n return getDialogueCapabilities(provider).levers.includes(lever)\n}\n\n/** The dialogue model answers `/v1/text-to-dialogue/with-timestamps` (character timings + per-line voice segments). */\nexport function dialogueSupportsTimestamps(provider: unknown): boolean {\n return getDialogueCapabilities(provider).timestamps\n}\n\n/** `value` is a stability this platform accepts for the dialogue model: one of its steps, or any finite 0–1 when it has none. */\nexport function dialogueStabilityAccepted(provider: unknown, value: number): boolean {\n if (!Number.isFinite(value) || value < 0 || value > 1) return false\n const steps = getDialogueCapabilities(provider).stabilitySteps\n return steps ? steps.includes(value) : true\n}\n"]}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkCGZLENU4_cjs = require('./chunk-CGZLENU4.cjs');
|
|
4
4
|
|
|
5
5
|
// src/safety-retry-policy.ts
|
|
6
6
|
function safetyRetryPolicy(modelId) {
|
|
7
|
-
const entry =
|
|
7
|
+
const entry = chunkCGZLENU4_cjs.getModel(modelId);
|
|
8
8
|
const safetyFilter = entry?.safetyFilter;
|
|
9
9
|
if (!safetyFilter?.stochastic) return { maxAttempts: 1 };
|
|
10
10
|
const fallback = safetyFilter.fallback;
|
|
11
|
-
if (fallback &&
|
|
11
|
+
if (fallback && chunkCGZLENU4_cjs.getModel(fallback)) {
|
|
12
12
|
return { maxAttempts: 2, fallback };
|
|
13
13
|
}
|
|
14
14
|
return { maxAttempts: 2 };
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
exports.safetyRetryPolicy = safetyRetryPolicy;
|
|
18
|
-
//# sourceMappingURL=chunk-
|
|
19
|
-
//# sourceMappingURL=chunk-
|
|
18
|
+
//# sourceMappingURL=chunk-ILMHITHK.cjs.map
|
|
19
|
+
//# sourceMappingURL=chunk-ILMHITHK.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/safety-retry-policy.ts"],"names":["getModel"],"mappings":";;;;;AA0BO,SAAS,kBAAkB,OAAA,EAAoC;AACpE,EAAA,MAAM,KAAA,GAAQA,2BAAS,OAAO,CAAA;AAC9B,EAAA,MAAM,eAAe,KAAA,EAAO,YAAA;AAC5B,EAAA,IAAI,CAAC,YAAA,EAAc,UAAA,EAAY,OAAO,EAAE,aAAa,CAAA,EAAE;AAEvD,EAAA,MAAM,WAAW,YAAA,CAAa,QAAA;AAC9B,EAAA,IAAI,QAAA,IAAYA,0BAAA,CAAS,QAAQ,CAAA,EAAG;AAClC,IAAA,OAAO,EAAE,WAAA,EAAa,CAAA,EAAG,QAAA,EAAS;AAAA,EACpC;AACA,EAAA,OAAO,EAAE,aAAa,CAAA,EAAE;AAC1B","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/safety-retry-policy.ts"],"names":["getModel"],"mappings":";;;;;AA0BO,SAAS,kBAAkB,OAAA,EAAoC;AACpE,EAAA,MAAM,KAAA,GAAQA,2BAAS,OAAO,CAAA;AAC9B,EAAA,MAAM,eAAe,KAAA,EAAO,YAAA;AAC5B,EAAA,IAAI,CAAC,YAAA,EAAc,UAAA,EAAY,OAAO,EAAE,aAAa,CAAA,EAAE;AAEvD,EAAA,MAAM,WAAW,YAAA,CAAa,QAAA;AAC9B,EAAA,IAAI,QAAA,IAAYA,0BAAA,CAAS,QAAQ,CAAA,EAAG;AAClC,IAAA,OAAO,EAAE,WAAA,EAAa,CAAA,EAAG,QAAA,EAAS;AAAA,EACpC;AACA,EAAA,OAAO,EAAE,aAAa,CAAA,EAAE;AAC1B","file":"chunk-ILMHITHK.cjs","sourcesContent":["import { getModel } from \"./model-catalog.js\"\n\n/**\n * Retry/fallback behavior derived from a catalog entry's `safetyFilter`\n * flag (see `ModelCatalogEntry.safetyFilter` in `model-catalog.ts`).\n */\nexport interface SafetyRetryPolicy {\n /** 2 when the model declares `safetyFilter.stochastic`, else 1. */\n maxAttempts: 1 | 2\n /**\n * Catalog model id to offer when the retry also blocks. Only present\n * when the entry declares one AND it resolves to a real catalog entry.\n */\n fallback?: string\n}\n\n/**\n * The provider's safety filter is known to be non-deterministic on some\n * catalog models — a benign prompt can trip it once and pass on an\n * identical retry. For those models the platform retries a blocked\n * request once (`maxAttempts: 2`) before giving up; `fallback` names the\n * catalog model to offer the user when the retry also blocks.\n *\n * Every model not flagged this way — including an unrecognized id —\n * gets a single attempt and no fallback.\n */\nexport function safetyRetryPolicy(modelId: string): SafetyRetryPolicy {\n const entry = getModel(modelId)\n const safetyFilter = entry?.safetyFilter\n if (!safetyFilter?.stochastic) return { maxAttempts: 1 }\n\n const fallback = safetyFilter.fallback\n if (fallback && getModel(fallback)) {\n return { maxAttempts: 2, fallback }\n }\n return { maxAttempts: 2 }\n}\n"]}
|