@nodaro/shared 3.58.0 → 3.60.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-OWNPYQSH.cjs → chunk-4GGLKRYI.cjs} +16 -3
- package/dist/chunk-4GGLKRYI.cjs.map +1 -0
- package/dist/{chunk-5PJC4ZWO.cjs → chunk-5G23AJBU.cjs} +6 -6
- package/dist/{chunk-5PJC4ZWO.cjs.map → chunk-5G23AJBU.cjs.map} +1 -1
- package/dist/{chunk-IKOKRJDI.cjs → chunk-5HK5Z5OB.cjs} +4 -4
- package/dist/{chunk-IKOKRJDI.cjs.map → chunk-5HK5Z5OB.cjs.map} +1 -1
- package/dist/{chunk-WLFT5UVV.cjs → chunk-5Y42RIGY.cjs} +8 -8
- package/dist/{chunk-WLFT5UVV.cjs.map → chunk-5Y42RIGY.cjs.map} +1 -1
- package/dist/{chunk-L26G7B27.js → chunk-6AJOTEVC.js} +3 -3
- package/dist/{chunk-L26G7B27.js.map → chunk-6AJOTEVC.js.map} +1 -1
- package/dist/{chunk-OMUYZKRB.js → chunk-6Q6SI7AG.js} +3 -3
- package/dist/{chunk-OMUYZKRB.js.map → chunk-6Q6SI7AG.js.map} +1 -1
- package/dist/{chunk-4ZZ6SVIQ.cjs → chunk-A6HRY3WF.cjs} +269 -37
- package/dist/chunk-A6HRY3WF.cjs.map +1 -0
- package/dist/{chunk-ZX6RRM6R.cjs → chunk-AXT7YNOR.cjs} +51 -51
- package/dist/{chunk-ZX6RRM6R.cjs.map → chunk-AXT7YNOR.cjs.map} +1 -1
- package/dist/{chunk-ODTZV3BW.js → chunk-AZGONXWV.js} +4 -4
- package/dist/{chunk-ODTZV3BW.js.map → chunk-AZGONXWV.js.map} +1 -1
- package/dist/{chunk-S5VBJJUT.cjs → chunk-BDXXOEBZ.cjs} +80 -57
- package/dist/chunk-BDXXOEBZ.cjs.map +1 -0
- package/dist/{chunk-QPBBIRLF.cjs → chunk-BGIJO5V4.cjs} +39 -39
- package/dist/{chunk-QPBBIRLF.cjs.map → chunk-BGIJO5V4.cjs.map} +1 -1
- package/dist/{chunk-NZRG5CXQ.cjs → chunk-BLJUCPMV.cjs} +5 -2
- package/dist/chunk-BLJUCPMV.cjs.map +1 -0
- package/dist/{chunk-KYHDKKUJ.cjs → chunk-BXNPO3PL.cjs} +8 -8
- package/dist/{chunk-KYHDKKUJ.cjs.map → chunk-BXNPO3PL.cjs.map} +1 -1
- package/dist/{chunk-S7FCFQ6X.js → chunk-CF4S4N5X.js} +16 -4
- package/dist/chunk-CF4S4N5X.js.map +1 -0
- package/dist/{chunk-4UUX62S3.cjs → chunk-CIOXUPCJ.cjs} +12 -12
- package/dist/{chunk-4UUX62S3.cjs.map → chunk-CIOXUPCJ.cjs.map} +1 -1
- package/dist/{chunk-5UVBFY2G.cjs → chunk-DQIJPDHC.cjs} +11 -11
- package/dist/{chunk-5UVBFY2G.cjs.map → chunk-DQIJPDHC.cjs.map} +1 -1
- package/dist/{chunk-UMPZR56R.js → chunk-DS2TOM32.js} +3 -3
- package/dist/{chunk-UMPZR56R.js.map → chunk-DS2TOM32.js.map} +1 -1
- package/dist/{chunk-K6UMB37V.js → chunk-EN2YI5TV.js} +3 -3
- package/dist/{chunk-K6UMB37V.js.map → chunk-EN2YI5TV.js.map} +1 -1
- package/dist/{chunk-SEQ5L72K.js → chunk-G6GMY5BC.js} +21 -4
- package/dist/chunk-G6GMY5BC.js.map +1 -0
- package/dist/chunk-G7ZYZQKO.cjs +27 -0
- package/dist/{chunk-QCW6J6BQ.cjs.map → chunk-G7ZYZQKO.cjs.map} +1 -1
- package/dist/{chunk-WBERPAXE.cjs → chunk-GNPJ2JLE.cjs} +6 -6
- package/dist/{chunk-WBERPAXE.cjs.map → chunk-GNPJ2JLE.cjs.map} +1 -1
- package/dist/{chunk-VZXRDSWA.cjs → chunk-GWBQ3GPO.cjs} +43 -21
- package/dist/chunk-GWBQ3GPO.cjs.map +1 -0
- package/dist/{chunk-DCP7JFSE.cjs → chunk-HDHLZK7C.cjs} +5 -5
- package/dist/{chunk-DCP7JFSE.cjs.map → chunk-HDHLZK7C.cjs.map} +1 -1
- package/dist/{chunk-QVPIO2NU.cjs → chunk-HNEF2N5C.cjs} +5 -5
- package/dist/{chunk-QVPIO2NU.cjs.map → chunk-HNEF2N5C.cjs.map} +1 -1
- package/dist/{chunk-7JM5EZF3.cjs → chunk-HOKWJXHA.cjs} +13 -13
- package/dist/{chunk-7JM5EZF3.cjs.map → chunk-HOKWJXHA.cjs.map} +1 -1
- package/dist/{chunk-FVKCNAEQ.js → chunk-HP3YIWNJ.js} +9 -4
- package/dist/chunk-HP3YIWNJ.js.map +1 -0
- package/dist/{chunk-UJJUX6NW.cjs → chunk-HW6TLOK4.cjs} +9 -3
- package/dist/chunk-HW6TLOK4.cjs.map +1 -0
- package/dist/{chunk-A5ESI2NY.js → chunk-ICDLYU4I.js} +9 -9
- package/dist/{chunk-A5ESI2NY.js.map → chunk-ICDLYU4I.js.map} +1 -1
- package/dist/{chunk-JUEFRVHZ.js → chunk-IV6IDECY.js} +4 -4
- package/dist/{chunk-JUEFRVHZ.js.map → chunk-IV6IDECY.js.map} +1 -1
- package/dist/{chunk-HEUWAIXG.js → chunk-JKZVRKN3.js} +36 -14
- package/dist/chunk-JKZVRKN3.js.map +1 -0
- package/dist/{chunk-ZMH56CLL.js → chunk-KJZVQIN4.js} +3 -3
- package/dist/{chunk-ZMH56CLL.js.map → chunk-KJZVQIN4.js.map} +1 -1
- package/dist/{chunk-6CYS7VRH.js → chunk-KOLC7AF2.js} +262 -38
- package/dist/chunk-KOLC7AF2.js.map +1 -0
- package/dist/{chunk-CNSRCZYY.js → chunk-LN3EVFRS.js} +5 -5
- package/dist/{chunk-CNSRCZYY.js.map → chunk-LN3EVFRS.js.map} +1 -1
- package/dist/{chunk-DC2QPACA.js → chunk-MHY47BLL.js} +4 -4
- package/dist/{chunk-DC2QPACA.js.map → chunk-MHY47BLL.js.map} +1 -1
- package/dist/{chunk-AWS4BWEC.js → chunk-Q6IES3U2.js} +5 -2
- package/dist/chunk-Q6IES3U2.js.map +1 -0
- package/dist/{chunk-PK4ZR2SK.cjs → chunk-RRPPXZ36.cjs} +4 -4
- package/dist/{chunk-PK4ZR2SK.cjs.map → chunk-RRPPXZ36.cjs.map} +1 -1
- package/dist/{chunk-6TFWFYYI.js → chunk-SCYBGTX6.js} +3 -3
- package/dist/{chunk-6TFWFYYI.js.map → chunk-SCYBGTX6.js.map} +1 -1
- package/dist/{chunk-I7NG2D6X.cjs → chunk-SKFJIFEV.cjs} +21 -21
- package/dist/{chunk-I7NG2D6X.cjs.map → chunk-SKFJIFEV.cjs.map} +1 -1
- package/dist/{chunk-VVGSIWNL.js → chunk-TZ42IVSF.js} +4 -4
- package/dist/{chunk-VVGSIWNL.js.map → chunk-TZ42IVSF.js.map} +1 -1
- package/dist/{chunk-IQBIH3AE.js → chunk-URLDVK67.js} +3 -3
- package/dist/{chunk-IQBIH3AE.js.map → chunk-URLDVK67.js.map} +1 -1
- package/dist/{chunk-IOET54EV.js → chunk-VB2ARGQ6.js} +35 -3
- package/dist/chunk-VB2ARGQ6.js.map +1 -0
- package/dist/{chunk-BSENM6HM.js → chunk-VYQ25YQF.js} +3 -3
- package/dist/{chunk-BSENM6HM.js.map → chunk-VYQ25YQF.js.map} +1 -1
- package/dist/{chunk-QSWUSXRL.cjs → chunk-WGKAOUEQ.cjs} +41 -2
- package/dist/chunk-WGKAOUEQ.cjs.map +1 -0
- package/dist/{chunk-M7SMSAOU.js → chunk-YHVEZVAO.js} +4 -4
- package/dist/{chunk-M7SMSAOU.js.map → chunk-YHVEZVAO.js.map} +1 -1
- package/dist/entries/apps.cjs +43 -43
- package/dist/entries/apps.js +8 -8
- package/dist/entries/credits.cjs +155 -151
- package/dist/entries/credits.d.cts +32 -3
- package/dist/entries/credits.d.ts +32 -3
- package/dist/entries/credits.js +8 -8
- package/dist/entries/edl.cjs +63 -59
- package/dist/entries/edl.d.cts +15 -1
- package/dist/entries/edl.d.ts +15 -1
- package/dist/entries/edl.js +1 -1
- package/dist/entries/llm-models.d.cts +1 -1
- package/dist/entries/llm-models.d.ts +1 -1
- package/dist/entries/model-catalog.cjs +144 -84
- package/dist/entries/model-catalog.d.cts +4 -47
- package/dist/entries/model-catalog.d.ts +4 -47
- package/dist/entries/model-catalog.js +5 -5
- package/dist/entries/models.cjs +308 -288
- 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 -208
- package/dist/entries/nodes.d.cts +1 -1
- package/dist/entries/nodes.d.ts +1 -1
- package/dist/entries/nodes.js +10 -10
- package/dist/entries/pipeline.cjs +152 -152
- package/dist/entries/pipeline.d.cts +1 -1
- package/dist/entries/pipeline.d.ts +1 -1
- package/dist/entries/pipeline.js +3 -3
- package/dist/entries/runtime-config.cjs +32 -28
- package/dist/entries/runtime-config.d.cts +24 -2
- package/dist/entries/runtime-config.d.ts +24 -2
- package/dist/entries/runtime-config.js +1 -1
- 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 +147 -147
- package/dist/entries/workflow.d.cts +8 -0
- package/dist/entries/workflow.d.ts +8 -0
- package/dist/entries/workflow.js +2 -2
- package/dist/gpt-image-2-6-BeZdT-pW.d.cts +98 -0
- package/dist/gpt-image-2-6-BeZdT-pW.d.ts +98 -0
- package/dist/index.cjs +1412 -1320
- package/dist/index.d.cts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +22 -22
- package/dist/{model-catalog-CCsA1isC.d.ts → model-catalog-D6Es7VG-.d.cts} +59 -3
- package/dist/{model-catalog-CCsA1isC.d.cts → model-catalog-D6Es7VG-.d.ts} +59 -3
- package/dist/{model-constants-BtXkUsX3.d.cts → model-constants-22k3fjp1.d.cts} +22 -1
- package/dist/{model-constants-BtXkUsX3.d.ts → model-constants-22k3fjp1.d.ts} +22 -1
- package/package.json +1 -1
- package/src/__tests__/camera-switch-contract.test.ts +12 -3
- package/src/__tests__/credit-identifiers.test.ts +18 -9
- package/src/__tests__/gpt-image-2-6-formats.test.ts +171 -0
- package/src/__tests__/gpt-image-2-size-rules.test.ts +80 -0
- package/src/__tests__/normalize-model-input.test.ts +10 -10
- package/src/__tests__/runtime-config.test.ts +28 -0
- package/src/camera-switch-contract.ts +13 -1
- package/src/credit-identifiers.ts +63 -3
- package/src/entries/credits.ts +1 -0
- package/src/entries/model-catalog.ts +17 -0
- package/src/entries/models.ts +7 -0
- package/src/entries/runtime-config.ts +1 -0
- package/src/gpt-image-2-6.ts +72 -0
- package/src/model-catalog.ts +350 -40
- package/src/model-constants.ts +40 -0
- package/src/node-execution-state.ts +8 -0
- package/src/node-runtime-keys.ts +3 -0
- package/src/runtime-config/contract.ts +34 -0
- package/dist/chunk-4ZZ6SVIQ.cjs.map +0 -1
- package/dist/chunk-6CYS7VRH.js.map +0 -1
- package/dist/chunk-AWS4BWEC.js.map +0 -1
- package/dist/chunk-FVKCNAEQ.js.map +0 -1
- package/dist/chunk-HEUWAIXG.js.map +0 -1
- package/dist/chunk-IOET54EV.js.map +0 -1
- package/dist/chunk-NZRG5CXQ.cjs.map +0 -1
- package/dist/chunk-OWNPYQSH.cjs.map +0 -1
- package/dist/chunk-QCW6J6BQ.cjs +0 -27
- package/dist/chunk-QSWUSXRL.cjs.map +0 -1
- package/dist/chunk-S5VBJJUT.cjs.map +0 -1
- package/dist/chunk-S7FCFQ6X.js.map +0 -1
- package/dist/chunk-SEQ5L72K.js.map +0 -1
- package/dist/chunk-UJJUX6NW.cjs.map +0 -1
- package/dist/chunk-VZXRDSWA.cjs.map +0 -1
|
@@ -39,7 +39,10 @@ var RUNTIME_CONFIG_KEYS = Object.freeze([
|
|
|
39
39
|
"surface",
|
|
40
40
|
"moderation",
|
|
41
41
|
"previewStopRule",
|
|
42
|
-
"mediaOrigin"
|
|
42
|
+
"mediaOrigin",
|
|
43
|
+
"flowUiOrigin",
|
|
44
|
+
"legacyUiHosts",
|
|
45
|
+
"linkOrigin"
|
|
43
46
|
]);
|
|
44
47
|
var SURFACE_HEADER_MODES = Object.freeze(["default", "white-label"]);
|
|
45
48
|
var SURFACE_CATALOG_IMAGES = Object.freeze(["default", "none", "own"]);
|
|
@@ -88,6 +91,9 @@ function surfaceUnitLabel(labels, locale, single) {
|
|
|
88
91
|
const word = labels && locale !== void 0 && Object.hasOwn(labels, locale) ? labels[locale] : void 0;
|
|
89
92
|
return typeof word === "string" && word.length > 0 ? word : single;
|
|
90
93
|
}
|
|
94
|
+
function isLegacyUiHost(value) {
|
|
95
|
+
return typeof value === "string" && /^[a-z0-9.-]+$/.test(value);
|
|
96
|
+
}
|
|
91
97
|
function isHttpsOrigin(value) {
|
|
92
98
|
if (typeof value !== "string") return false;
|
|
93
99
|
try {
|
|
@@ -242,6 +248,12 @@ function parseRuntimeConfig(raw) {
|
|
|
242
248
|
if (isRecord(raw.moderation) && raw.moderation.uploadImage === true) out.moderation = { uploadImage: true };
|
|
243
249
|
if (raw.previewStopRule === true) out.previewStopRule = true;
|
|
244
250
|
if (isHttpsOrigin(raw.mediaOrigin)) out.mediaOrigin = raw.mediaOrigin;
|
|
251
|
+
if (isHttpsOrigin(raw.flowUiOrigin)) out.flowUiOrigin = raw.flowUiOrigin;
|
|
252
|
+
if (Array.isArray(raw.legacyUiHosts)) {
|
|
253
|
+
const hosts = raw.legacyUiHosts.filter(isLegacyUiHost);
|
|
254
|
+
if (hosts.length > 0) out.legacyUiHosts = hosts;
|
|
255
|
+
}
|
|
256
|
+
if (isHttpsOrigin(raw.linkOrigin)) out.linkOrigin = raw.linkOrigin;
|
|
245
257
|
return out;
|
|
246
258
|
}
|
|
247
259
|
function readRuntimeConfig(scope = globalThis) {
|
|
@@ -263,6 +275,7 @@ exports.WORLD_REQUIRED_NODE_TYPES = WORLD_REQUIRED_NODE_TYPES;
|
|
|
263
275
|
exports.buildUiStringManifest = buildUiStringManifest;
|
|
264
276
|
exports.isBrandLogoRef = isBrandLogoRef;
|
|
265
277
|
exports.isHttpsOrigin = isHttpsOrigin;
|
|
278
|
+
exports.isLegacyUiHost = isLegacyUiHost;
|
|
266
279
|
exports.isSameSitePath = isSameSitePath;
|
|
267
280
|
exports.isSsoOnly = isSsoOnly;
|
|
268
281
|
exports.isWorldId = isWorldId;
|
|
@@ -279,5 +292,5 @@ exports.surfaceUnitLabel = surfaceUnitLabel;
|
|
|
279
292
|
exports.uiStringManifestFile = uiStringManifestFile;
|
|
280
293
|
exports.uiStringPlaceholders = uiStringPlaceholders;
|
|
281
294
|
exports.worldAllowed = worldAllowed;
|
|
282
|
-
//# sourceMappingURL=chunk-
|
|
283
|
-
//# sourceMappingURL=chunk-
|
|
295
|
+
//# sourceMappingURL=chunk-4GGLKRYI.cjs.map
|
|
296
|
+
//# sourceMappingURL=chunk-4GGLKRYI.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime-config/worlds.ts","../src/runtime-config/contract.ts"],"names":["strings"],"mappings":";;;AAaO,IAAM,SAAA,GAAY,MAAA,CAAO,MAAA,CAAO,CAAC,SAAA,EAAW,OAAA,EAAS,OAAA,EAAS,OAAA,EAAS,QAAA,EAAU,QAAA,EAAU,OAAA,EAAS,KAAA,EAAO,QAAQ,CAAU;AAIpI,IAAM,YAAA,GAAoC,IAAI,GAAA,CAAI,SAAS,CAAA;AAEpD,SAAS,UAAU,KAAA,EAAkC;AAC1D,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,YAAA,CAAa,IAAI,KAAK,CAAA;AAC5D;AAiBO,IAAM,yBAAA,GAA0E,OAAO,MAAA,CAAO;AAAA,EACnG,OAAA,EAAS,MAAA,CAAO,MAAA,CAAO,EAAE,CAAA;AAAA,EACzB,KAAA,EAAO,MAAA,CAAO,MAAA,CAAO,CAAC,gBAAgB,CAAC,CAAA;AAAA,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AAA,MAAO,OAAA,GAAU,mBAAA,CAAoB,IAAI,OAAO,CAAA;AACxE,EAAA,IAAI,QAAA,CAAS,GAAA,CAAI,UAAU,CAAA,IAAK,GAAA,CAAI,UAAA,CAAW,WAAA,KAAgB,IAAA,EAAM,GAAA,CAAI,UAAA,GAAa,EAAE,WAAA,EAAa,IAAA,EAAK;AAC1G,EAAA,IAAI,GAAA,CAAI,eAAA,KAAoB,IAAA,EAAM,GAAA,CAAI,eAAA,GAAkB,IAAA;AACxD,EAAA,IAAI,cAAc,GAAA,CAAI,WAAW,CAAA,EAAG,GAAA,CAAI,cAAc,GAAA,CAAI,WAAA;AAC1D,EAAA,IAAI,cAAc,GAAA,CAAI,YAAY,CAAA,EAAG,GAAA,CAAI,eAAe,GAAA,CAAI,YAAA;AAC5D,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,GAAA,CAAI,aAAa,CAAA,EAAG;AACpC,IAAA,MAAM,KAAA,GAAQ,GAAA,CAAI,aAAA,CAAc,MAAA,CAAO,cAAc,CAAA;AACrD,IAAA,IAAI,KAAA,CAAM,MAAA,GAAS,CAAA,EAAG,GAAA,CAAI,aAAA,GAAgB,KAAA;AAAA,EAC5C;AACA,EAAA,IAAI,cAAc,GAAA,CAAI,UAAU,CAAA,EAAG,GAAA,CAAI,aAAa,GAAA,CAAI,UAAA;AACxD,EAAA,OAAO,GAAA;AACT;AAGO,SAAS,iBAAA,CAAkB,QAAiB,UAAA,EAAiC;AAClF,EAAA,IAAI;AACF,IAAA,OAAO,kBAAA,CAAmB,QAAA,CAAS,KAAK,CAAA,IAAK,OAAO,UAAU,UAAA,GAAc,KAAA,CAAc,qBAAqB,CAAA,GAAI,KAAA,CAAS,CAAA;AAAA,EAC9H,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAC;AAAA,EACV;AACF","file":"chunk-4GGLKRYI.cjs","sourcesContent":["/**\n * The worlds a Nodaro deployment can offer — the tabs of the shared site\n * header, in its canonical display order — and the node types each one runs.\n *\n * A world is offered to a viewer when the deployment's profile allows it\n * (`surface.worlds.allow`, when set) AND every node type it runs is available\n * to that viewer. The platform's `GET /v1/surface/availability` answers both\n * per viewer; this table is the one copy that answer and every client read,\n * so a world is never shown where its runs would be refused.\n *\n * Structural vocabulary only (ids and node-type names), no content.\n */\n\nexport const WORLD_IDS = Object.freeze([\"explore\", \"image\", \"video\", \"music\", \"trends\", \"motion\", \"voice\", \"app\", \"studio\"] as const)\n\nexport type WorldId = (typeof WORLD_IDS)[number]\n\nconst WORLD_ID_SET: ReadonlySet<string> = new Set(WORLD_IDS)\n\nexport function isWorldId(value: unknown): value is WorldId {\n return typeof value === \"string\" && WORLD_ID_SET.has(value)\n}\n\n/**\n * The node types each world runs: a world is offered only while every one of\n * them is available to the viewer. A world with none runs no node of its own\n * and is gated by the allowlist alone: Explore is a showcase, App is the\n * workflow editor (whose nodes are gated one by one inside it), Studio is its\n * own product.\n *\n * - `image`: Generate Image (`POST /v1/generate-image`).\n * - `video`: Generate Video and Text to Video — the world's two routes\n * (`/v1/generate-video` from a start frame, `/v1/text-to-video` from a\n * prompt). The canvas's Image to Video node is not one of them.\n * - `music`: Suno Create Music (`/v1/suno/generate`).\n * - `trends`, `motion`: Cast Swap (`/v1/cast-swap`), the run both worlds start.\n * - `voice`: Voice Changer Pro (`/v1/voice-changer-pro`).\n */\nexport const WORLD_REQUIRED_NODE_TYPES: Readonly<Record<WorldId, readonly string[]>> = Object.freeze({\n explore: Object.freeze([]),\n image: Object.freeze([\"generate-image\"]),\n video: Object.freeze([\"generate-video\", \"text-to-video\"]),\n music: Object.freeze([\"suno-generate\"]),\n trends: Object.freeze([\"cast-swap\"]),\n motion: Object.freeze([\"cast-swap\"]),\n voice: Object.freeze([\"voice-changer-pro\"]),\n app: Object.freeze([]),\n studio: Object.freeze([]),\n})\n\n/** The worlds part of a deployment's surface profile. */\nexport interface SurfaceWorlds {\n /**\n * When PRESENT, exactly these worlds are offered (`[]` offers none). Absent:\n * every world is, subject to its node types. Unlike the profile's other\n * lists, presence is what narrows, so a list whose ids are all unknown\n * offers nothing instead of everything.\n */\n readonly allow?: readonly string[]\n /** The world a visit to the site's root lands on. Always one `allow` lets through. */\n readonly home?: WorldId\n /** Display order; worlds it leaves out follow in canonical order. */\n readonly order?: readonly WorldId[]\n}\n\n/** Does the profile's allowlist let this world through? (Node availability is checked separately.) */\nexport function worldAllowed(worlds: SurfaceWorlds | undefined, id: string): boolean {\n return worlds?.allow === undefined || worlds.allow.includes(id)\n}\n\n/** Every world, `order`'s known ids first (each once), then the rest in canonical order. */\nexport function orderWorlds(order?: readonly string[]): WorldId[] {\n const out: WorldId[] = []\n for (const id of order ?? []) if (isWorldId(id) && !out.includes(id)) out.push(id)\n for (const id of WORLD_IDS) if (!out.includes(id)) out.push(id)\n return out\n}\n","import { isWorldId, type SurfaceWorlds, type WorldId } from \"./worlds.js\"\n\n/**\n * The deployment runtime config — the object a Nodaro platform container\n * writes to `/config.js` at boot as `window.__NODARO_RUNTIME__`, and that every\n * product served from the same site reads before its app starts. One published\n * build then serves any deployment without a rebuild.\n *\n * This module is the contract between that writer and its readers: the key\n * names, their shapes, and a lenient parser. Structural vocabulary only: no\n * content, no prices, nothing about any one deployment. The platform's own\n * schema stays the authority on what a deployment may set. What reaches the\n * page has already been validated there and stripped of every server-only\n * value; this parser only refuses to hand a reader a value of the wrong type.\n */\n\n/** The global `/config.js` assigns. */\nexport const RUNTIME_CONFIG_GLOBAL = \"__NODARO_RUNTIME__\"\n\n/** Every top-level key `/config.js` can carry. */\nexport const RUNTIME_CONFIG_KEYS = Object.freeze([\n \"apiUrl\",\n \"supabaseUrl\",\n \"supabaseAnonKey\",\n \"freecutUrl\",\n \"audiomassUrl\",\n \"defaultLocale\",\n \"surface\",\n \"moderation\",\n \"previewStopRule\",\n \"mediaOrigin\",\n \"flowUiOrigin\",\n \"legacyUiHosts\",\n \"linkOrigin\",\n] as const)\nexport type RuntimeConfigKey = (typeof RUNTIME_CONFIG_KEYS)[number]\n\nexport const SURFACE_HEADER_MODES = Object.freeze([\"default\", \"white-label\"] as const)\n/** `white-label`: the deployment's own header, with no platform links or art. */\nexport type SurfaceHeaderMode = (typeof SURFACE_HEADER_MODES)[number]\n\nexport const SURFACE_CATALOG_IMAGES = Object.freeze([\"default\", \"none\", \"own\"] as const)\n/** Pictures on picker options: the platform's (`default`), none, or the deployment's own (`own`). */\nexport type SurfaceCatalogImages = (typeof SURFACE_CATALOG_IMAGES)[number]\n\nexport interface RuntimeSurfaceSibling {\n readonly label: string\n readonly url: string\n readonly urlByHost?: Readonly<Record<string, string>>\n}\n\nexport interface RuntimeSurfaceBrand {\n readonly productName: string\n readonly description?: string\n readonly wordmark?: string\n readonly platformLinks?: boolean\n /** A same-site path (`/brand/logo.svg`) or an https URL. */\n readonly logo?: string\n /** The page's icons, each a path on this site (`/brand/favicon.svg`): see `isSameSitePath`. */\n readonly favicon?: readonly string[]\n}\n\n/**\n * Overrides of a product's UI strings, `product → locale id → message key →\n * text`. Each product reads only its own namespace (`UI_STRING_PRODUCTS`). The\n * platform checks every entry against that product's dictionary before it\n * reaches a page: the key exists, the locale is one the deployment offers, the\n * text is plain and keeps the base string's `{placeholders}`.\n */\nexport type RuntimeSurfaceStrings = Readonly<Record<string, Readonly<Record<string, Readonly<Record<string, string>>>>>>\n\n/** The display side of billing. The server-only billing keys never reach a page. */\nexport interface RuntimeSurfaceBilling {\n readonly costTab: \"inherit\" | \"hidden\"\n readonly sidebarCard: \"inherit\" | \"hidden\"\n readonly selfServe: boolean\n readonly unitLabel?: string\n readonly unitRate?: number\n readonly unitDecimals?: number\n /**\n * The unit's word per interface language, beside the single `unitLabel`: a\n * language the deployment gives no word for uses `unitLabel`. Read with\n * `surfaceUnitLabel`.\n */\n readonly unitLabels?: Readonly<Record<string, string>>\n}\n\n/**\n * The deployment's surface profile as a page receives it, with every default\n * applied. Lists that are empty keep the product's own default, except\n * `worlds.allow` (see `SurfaceWorlds`).\n */\nexport interface RuntimeSurface {\n readonly nav: { readonly hide: readonly string[] }\n readonly features: { readonly hide: readonly string[] }\n readonly dashboard: { readonly tabs: readonly string[] }\n readonly nodes: { readonly deny: readonly string[]; readonly allow: readonly string[] }\n readonly models: { readonly deny: readonly string[]; readonly allow: readonly string[] }\n /** `requireSignIn`: no guest visits. When the deployment does not say, true exactly when sign-in is SSO-only. */\n readonly auth: { readonly methods: readonly string[]; readonly ssoLabel?: string; readonly requireSignIn: boolean }\n readonly siblings: { readonly apps: readonly RuntimeSurfaceSibling[] }\n readonly brand: RuntimeSurfaceBrand\n /** `offered`: the languages a visitor may pick from; absent = every language the product ships. */\n readonly locale: { readonly default?: string; readonly picker: boolean; readonly offered?: readonly string[] }\n readonly outputs: { readonly allowPublic: boolean }\n readonly voice: { readonly allowedGenders: readonly string[] }\n readonly billing: RuntimeSurfaceBilling\n readonly catalogs: { readonly required: boolean; readonly factoryPresets: boolean; readonly images: SurfaceCatalogImages }\n /** `links`: whether media may be imported from a link to another site. */\n readonly imports: { readonly links: boolean }\n readonly header: SurfaceHeaderMode\n readonly worlds: SurfaceWorlds\n /** The deployment's own wording for UI strings; `{}` = none. Read with `surfaceStringOverride`. */\n readonly strings: RuntimeSurfaceStrings\n /** Carried as given; no reader acts on it. */\n readonly catalogPolicy?: unknown\n}\n\nexport interface NodaroRuntimeConfig {\n /** The API base. `\"/\"` means this page's own origin: see `resolveRuntimeApiBase`. */\n readonly apiUrl?: string\n /** The Supabase URL. `\"/supabase\"` means this page's own origin: see `resolveRuntimeSupabaseUrl`. */\n readonly supabaseUrl?: string\n readonly supabaseAnonKey?: string\n /** The platform editor's embedded video editor. */\n readonly freecutUrl?: string\n /** The platform editor's embedded audio editor. */\n readonly audiomassUrl?: string\n /** The language a first-time visitor starts in. */\n readonly defaultLocale?: string\n /** Present only when the deployment configured a surface profile. */\n readonly surface?: RuntimeSurface\n /** The platform editor's upload-moderation capability. */\n readonly moderation?: { readonly uploadImage?: boolean }\n /** A platform editor rollout flag. */\n readonly previewStopRule?: boolean\n /**\n * The https origin this deployment serves user media from\n * (`https://media.example.com`). Present only on a white-label deployment\n * whose public media URL is https; absent, a reader trusts no media host\n * beyond its own site.\n */\n readonly mediaOrigin?: string\n /**\n * The https origin the app's own pages live on, when this deployment moved\n * them to a host of their own. A page on it calls the API same-origin.\n * Absent: the deployment has one host.\n */\n readonly flowUiOrigin?: string\n /** The hosts the app's pages moved away from (with `flowUiOrigin`): a navigation on one goes to the page's home. */\n readonly legacyUiHosts?: readonly string[]\n /**\n * The https origin developer-facing links name (published apps, embeds, API\n * examples) when the app's pages live elsewhere. Absent: the page's own\n * origin, as ever.\n */\n readonly linkOrigin?: string\n}\n\n// ── Rules shared by the platform and its readers ─────────────────────────────\n\n/** Sign-in is SSO-only when SSO is the one method offered. */\nexport function isSsoOnly(methods: readonly unknown[]): boolean {\n return methods.length > 0 && methods.every((m) => m === \"sso\")\n}\n\n/** An explicit `requireSignIn` wins; otherwise a deployment requires sign-in exactly when it is SSO-only. */\nexport function surfaceRequiresSignIn(auth: { readonly methods?: unknown; readonly requireSignIn?: unknown } | undefined): boolean {\n if (typeof auth?.requireSignIn === \"boolean\") return auth.requireSignIn\n return isSsoOnly(strings(auth?.methods))\n}\n\n// Whitespace, control characters and backslashes never belong in a logo\n// reference, and a browser reads `/\\host` as `//host`: another site.\nconst UNSAFE_REF_CHARS = /[\\s\\u0000-\\u001f\\u007f\\\\]/\nconst PROBE_ORIGIN = \"https://origin.invalid\"\n\n/**\n * A brand logo reference a page may load: a path on the page's own site\n * (`/brand/logo.svg`), or an https URL without credentials. A protocol-relative\n * `//host/…`, any other scheme (`http:`, `data:`, `javascript:`) and anything\n * with whitespace or a backslash is not one.\n */\nexport function isBrandLogoRef(value: unknown): value is string {\n if (typeof value !== \"string\" || value.length === 0 || UNSAFE_REF_CHARS.test(value)) return false\n try {\n if (value.startsWith(\"/\")) return !value.startsWith(\"//\") && new URL(value, PROBE_ORIGIN).origin === PROBE_ORIGIN\n const url = new URL(value)\n return url.protocol === \"https:\" && url.hostname.length > 0 && !url.username && !url.password\n } catch {\n return false\n }\n}\n\n// Quotes, angle brackets and backticks would end an HTML attribute that holds\n// the path, and none belongs in a path anyway.\nconst HTML_SPECIAL_CHARS = /[\"'<>`]/\n\n/**\n * A path on the page's own site (`/brand/favicon.svg`, `/icon.png?v=2`): what\n * `brand.favicon` holds, written into the page's `<head>` as a link. Stricter\n * than `isBrandLogoRef`: no URL to another site at all, and no character that\n * could end an HTML attribute.\n */\nexport function isSameSitePath(value: unknown): value is string {\n return typeof value === \"string\" && value.startsWith(\"/\") && !HTML_SPECIAL_CHARS.test(value) && isBrandLogoRef(value)\n}\n\n/**\n * The products whose UI strings a deployment may override, each keyed in\n * `surface.strings` by its id and checked against that product's own\n * dictionary. `flow`: the platform's workflow editor; `tools`: the tools app;\n * `voice`: the voice app. One profile words them all. A product adopts the\n * overrides by adding its id here and giving the platform its key manifest\n * (`uiStringManifestFile`), which a deployment composing the app into one\n * image copies next to Flow's own.\n */\nexport const UI_STRING_PRODUCTS = Object.freeze([\"flow\", \"tools\", \"voice\"] as const)\nexport type UiStringProduct = (typeof UI_STRING_PRODUCTS)[number]\n\n/**\n * What a product's build emits beside its output so the platform can check a\n * deployment's overrides at boot: every key of its base (English) dictionary\n * with the placeholder names that key's text uses, and the locales the product\n * offers. Keys and names only, never the text.\n */\nexport interface UiStringManifest {\n /** The `surface.strings` namespace the dictionary answers to (`UI_STRING_PRODUCTS`). */\n readonly product: string\n /** The locales overrides may target when the deployment sets no `locale.offered`. */\n readonly locales: readonly string[]\n /** Every key a deployment may override → the placeholder names its base text uses, sorted. */\n readonly keys: Readonly<Record<string, readonly string[]>>\n}\n\n/** The manifest's file name, at the root of the product's build output. */\nexport function uiStringManifestFile(product: string): string {\n return `ui-strings-manifest.${product}.json`\n}\n\n// `{name}`: anything else in braces (`{{now}}`, `{image:1}`, `{ variables`) is\n// text, the same way the dictionaries' interpolation reads it.\nconst UI_STRING_PLACEHOLDER = /\\{(\\w+)\\}/g\n\n/** The placeholder names `text` uses, each once, sorted. */\nexport function uiStringPlaceholders(text: string): string[] {\n return [...new Set(Array.from(text.matchAll(UI_STRING_PLACEHOLDER), (m) => m[1]))].sort()\n}\n\n/**\n * The manifest of a base dictionary. A key whose base text is blank is left\n * out: it is grammar data (a word's grammatical gender, the gap between two\n * joined fragments), not wording, and overriding it would only break the\n * sentences built from it.\n */\nexport function buildUiStringManifest(product: string, dict: Readonly<Record<string, string>>, locales: readonly string[]): UiStringManifest {\n const keys = Object.entries(dict)\n .filter(([, text]) => text.trim() !== \"\")\n .map(([key, text]): [string, string[]] => [key, uiStringPlaceholders(text)])\n return { product, locales: [...locales], keys: Object.fromEntries(keys) }\n}\n\n/** The deployment's text for `key` in `locale` of `product`, or undefined. */\nexport function surfaceStringOverride(strings: RuntimeSurfaceStrings | undefined, product: string, locale: string, key: string): string | undefined {\n const byLocale = strings && Object.hasOwn(strings, product) ? strings[product] : undefined\n const texts = byLocale && Object.hasOwn(byLocale, locale) ? byLocale[locale] : undefined\n const text = texts && Object.hasOwn(texts, key) ? texts[key] : undefined\n return typeof text === \"string\" ? text : undefined\n}\n\n/**\n * The deployment's word for its unit in `locale`: the `billing.unitLabels`\n * entry for that language, else its single `unitLabel` (`single`). `labels` is\n * the map as it arrives, on the surface or on a `display` object beside its\n * `unit`.\n */\nexport function surfaceUnitLabel(labels: Readonly<Record<string, string>> | undefined, locale: string | undefined, single: string): string {\n const word = labels && locale !== undefined && Object.hasOwn(labels, locale) ? labels[locale] : undefined\n return typeof word === \"string\" && word.length > 0 ? word : single\n}\n\n/**\n * A host the app's pages move away from, on a deployment that moved them to a\n * host of their own (`LEGACY_UI_HOSTS`, `legacyUiHosts`): a bare host name in\n * lower case, with no scheme, port, path or space. The one rule for it: the\n * server refuses to start on an entry that is not one, and a reader of\n * /config.js drops it.\n */\nexport function isLegacyUiHost(value: unknown): value is string {\n return typeof value === \"string\" && /^[a-z0-9.-]+$/.test(value)\n}\n\n/**\n * An https origin, spelled exactly as a browser spells one\n * (`https://media.example.com`, a port only when it is not 443): what\n * `new URL(src).origin` is compared with, so a path, a trailing slash,\n * credentials, another letter case or any other scheme could never match, and\n * is not one.\n */\nexport function isHttpsOrigin(value: unknown): value is string {\n if (typeof value !== \"string\") return false\n try {\n const url = new URL(value)\n return url.protocol === \"https:\" && url.origin === value\n } catch {\n return false\n }\n}\n\n/**\n * The base a client builds API URLs on. `\"/\"` is the same-origin sentinel (a\n * site answering on more than one hostname cannot name one) and resolves to\n * `\"\"`: build every URL relative to the page. `undefined` when the config names\n * none, so the app keeps its own build-time value. It never makes up a URL.\n */\nexport function resolveRuntimeApiBase(cfg: Pick<NodaroRuntimeConfig, \"apiUrl\"> | undefined): string | undefined {\n const value = typeof cfg?.apiUrl === \"string\" ? cfg.apiUrl.trim() : \"\"\n if (!value) return undefined\n return value === \"/\" ? \"\" : value\n}\n\n/**\n * The Supabase URL a browser client uses. supabase-js needs an absolute URL, so\n * the same-origin sentinel `\"/supabase\"` resolves against `origin`, the page's\n * own (`location.origin`). `undefined` when the config names none.\n */\nexport function resolveRuntimeSupabaseUrl(cfg: Pick<NodaroRuntimeConfig, \"supabaseUrl\"> | undefined, origin: string): string | undefined {\n const value = typeof cfg?.supabaseUrl === \"string\" ? cfg.supabaseUrl.trim() : \"\"\n if (!value) return undefined\n return value === \"/supabase\" ? `${origin.replace(/\\/+$/, \"\")}/supabase` : value\n}\n\n// ── The parser ───────────────────────────────────────────────────────────────\n\ntype Rec = Readonly<Record<string, unknown>>\n\nfunction isRecord(value: unknown): value is Rec {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\nconst record = (value: unknown): Rec => (isRecord(value) ? value : {})\nfunction strings(value: unknown): string[] {\n return Array.isArray(value) ? value.filter((x): x is string => typeof x === \"string\") : []\n}\nconst optional = <K extends string, V>(key: K, value: V | undefined): { [P in K]?: V } =>\n (value === undefined ? {} : { [key]: value }) as { [P in K]?: V }\nconst asString = (value: unknown): string | undefined => (typeof value === \"string\" ? value : undefined)\nconst asBoolean = (value: unknown): boolean | undefined => (typeof value === \"boolean\" ? value : undefined)\n\nfunction siblingApps(value: unknown): RuntimeSurfaceSibling[] {\n if (!Array.isArray(value)) return []\n return value.flatMap((raw) => {\n if (!isRecord(raw) || typeof raw.label !== \"string\" || typeof raw.url !== \"string\") return []\n const byHost = isRecord(raw.urlByHost)\n ? Object.fromEntries(Object.entries(raw.urlByHost).filter((e): e is [string, string] => typeof e[1] === \"string\"))\n : {}\n return [{ label: raw.label, url: raw.url, ...optional(\"urlByHost\", Object.keys(byHost).length ? byHost : undefined) }]\n })\n}\n\nfunction faviconsOf(value: unknown): string[] | undefined {\n const paths = (Array.isArray(value) ? value : [value]).filter(isSameSitePath)\n return paths.length ? [...new Set(paths)] : undefined\n}\n\nfunction brandOf(value: unknown): RuntimeSurfaceBrand {\n const b = record(value)\n return {\n productName: typeof b.productName === \"string\" && b.productName ? b.productName : \"Nodaro\",\n ...optional(\"description\", asString(b.description)),\n ...optional(\"wordmark\", asString(b.wordmark)),\n ...optional(\"platformLinks\", asBoolean(b.platformLinks)),\n ...optional(\"logo\", isBrandLogoRef(b.logo) ? b.logo : undefined),\n ...optional(\"favicon\", faviconsOf(b.favicon)),\n }\n}\n\n/**\n * `surface.strings`, keeping only text: a product, locale or key whose value\n * has the wrong type is left out, and an emptied level with it. Built from\n * entries, so a `\"__proto__\"` key stays an ordinary key. Never throws.\n */\nexport function parseRuntimeStrings(raw: unknown): RuntimeSurfaceStrings {\n const products: [string, Record<string, Record<string, string>>][] = []\n for (const [product, byLocale] of Object.entries(record(raw))) {\n const locales: [string, Record<string, string>][] = []\n for (const [locale, texts] of Object.entries(record(byLocale))) {\n const kept = Object.entries(record(texts)).filter((e): e is [string, string] => typeof e[1] === \"string\")\n if (kept.length) locales.push([locale, Object.fromEntries(kept)])\n }\n if (locales.length) products.push([product, Object.fromEntries(locales)])\n }\n return Object.fromEntries(products)\n}\n\nfunction localeOf(value: unknown): RuntimeSurface[\"locale\"] {\n const l = record(value)\n return {\n ...optional(\"default\", asString(l.default)),\n picker: l.picker !== false,\n ...optional(\"offered\", Array.isArray(l.offered) ? strings(l.offered) : undefined),\n }\n}\n\n/** Text words only, built from entries so a `\"__proto__\"` key stays an ordinary key; nothing usable leaves the key out. */\nfunction unitLabelsOf(value: unknown): Readonly<Record<string, string>> | undefined {\n const words = Object.entries(record(value)).filter((e): e is [string, string] => typeof e[1] === \"string\" && e[1].length > 0)\n return words.length ? Object.fromEntries(words) : undefined\n}\n\nfunction billingOf(value: unknown): RuntimeSurfaceBilling {\n const b = record(value)\n // Both or neither: a label without a rate (or the reverse) would put one\n // unit's name on another unit's numbers. The per-language words stand beside\n // the label, so they live and fall with it.\n const coherent = typeof b.unitLabel === \"string\" && b.unitLabel.length > 0 && typeof b.unitRate === \"number\" && Number.isFinite(b.unitRate) && b.unitRate > 0\n const decimals = typeof b.unitDecimals === \"number\" && Number.isInteger(b.unitDecimals) && b.unitDecimals >= 0 && b.unitDecimals <= 4 ? b.unitDecimals : undefined\n return {\n costTab: b.costTab === \"hidden\" ? \"hidden\" : \"inherit\",\n sidebarCard: b.sidebarCard === \"hidden\" ? \"hidden\" : \"inherit\",\n selfServe: b.selfServe !== false,\n ...(coherent\n ? { unitLabel: b.unitLabel as string, unitRate: b.unitRate as number, ...optional(\"unitDecimals\", decimals), ...optional(\"unitLabels\", unitLabelsOf(b.unitLabels)) }\n : {}),\n }\n}\n\n/** A value outside the known set reads as the restrictive one: a reader older than its platform must not show more. */\nfunction catalogImagesOf(value: unknown): SurfaceCatalogImages {\n if (value === undefined) return \"default\"\n return (SURFACE_CATALOG_IMAGES as readonly unknown[]).includes(value) ? (value as SurfaceCatalogImages) : \"none\"\n}\n\nfunction linksAllowed(value: unknown): boolean {\n if (value === undefined) return true\n if (!isRecord(value)) return false\n return value.links === undefined ? true : value.links === true\n}\n\nfunction headerModeOf(value: unknown): SurfaceHeaderMode {\n return value === undefined || value === \"default\" ? \"default\" : \"white-label\"\n}\n\nfunction worldsOf(value: unknown): SurfaceWorlds {\n if (value === undefined) return {}\n // Present but not an object: offer none rather than everything.\n if (!isRecord(value)) return { allow: [] }\n const allow = value.allow === undefined ? undefined : strings(value.allow)\n const order = Array.isArray(value.order) ? [...new Set(value.order.filter(isWorldId))] : []\n const home: WorldId | undefined = isWorldId(value.home) && (allow === undefined || allow.includes(value.home)) ? value.home : undefined\n return { ...optional(\"allow\", allow), ...optional(\"home\", home), ...optional(\"order\", order.length ? order : undefined) }\n}\n\n/** The surface block of `/config.js`, every default applied. Never throws. */\nexport function parseRuntimeSurface(raw: unknown): RuntimeSurface {\n const s = record(raw)\n const auth = record(s.auth)\n const methods = strings(auth.methods)\n const allowDeny = (v: unknown) => ({ deny: strings(record(v).deny), allow: strings(record(v).allow) })\n const catalogs = record(s.catalogs)\n return {\n nav: { hide: strings(record(s.nav).hide) },\n features: { hide: strings(record(s.features).hide) },\n dashboard: { tabs: strings(record(s.dashboard).tabs) },\n nodes: allowDeny(s.nodes),\n models: allowDeny(s.models),\n auth: { methods, ...optional(\"ssoLabel\", asString(auth.ssoLabel)), requireSignIn: surfaceRequiresSignIn({ methods, requireSignIn: auth.requireSignIn }) },\n siblings: { apps: siblingApps(record(s.siblings).apps) },\n brand: brandOf(s.brand),\n locale: localeOf(s.locale),\n outputs: { allowPublic: record(s.outputs).allowPublic !== false },\n voice: { allowedGenders: strings(record(s.voice).allowedGenders) },\n billing: billingOf(s.billing),\n catalogs: { required: catalogs.required === true, factoryPresets: catalogs.factoryPresets !== false, images: catalogImagesOf(catalogs.images) },\n imports: { links: linksAllowed(s.imports) },\n header: headerModeOf(s.header),\n worlds: worldsOf(s.worlds),\n strings: parseRuntimeStrings(s.strings),\n ...optional(\"catalogPolicy\", s.catalogPolicy),\n }\n}\n\nfunction deepFreeze<T>(value: T): T {\n if (typeof value === \"object\" && value !== null) {\n for (const child of Object.values(value)) deepFreeze(child)\n Object.freeze(value)\n }\n return value\n}\n\n/** The surface a deployment that configured none renders. */\nexport const RUNTIME_SURFACE_DEFAULT: RuntimeSurface = deepFreeze(parseRuntimeSurface(undefined))\n\nconst STRING_KEYS = [\"apiUrl\", \"supabaseUrl\", \"supabaseAnonKey\", \"freecutUrl\", \"audiomassUrl\", \"defaultLocale\"] as const\n\n/**\n * `/config.js`'s object, typed. Keeps each key only when it has the expected\n * type; a blank string is no value. Never throws.\n */\nexport function parseRuntimeConfig(raw: unknown): NodaroRuntimeConfig {\n if (!isRecord(raw)) return {}\n const out: { -readonly [K in keyof NodaroRuntimeConfig]: NodaroRuntimeConfig[K] } = {}\n for (const key of STRING_KEYS) {\n const value = raw[key]\n if (typeof value === \"string\" && value.trim()) out[key] = value.trim()\n }\n if (isRecord(raw.surface)) out.surface = parseRuntimeSurface(raw.surface)\n if (isRecord(raw.moderation) && raw.moderation.uploadImage === true) out.moderation = { uploadImage: true }\n if (raw.previewStopRule === true) out.previewStopRule = true\n if (isHttpsOrigin(raw.mediaOrigin)) out.mediaOrigin = raw.mediaOrigin\n if (isHttpsOrigin(raw.flowUiOrigin)) out.flowUiOrigin = raw.flowUiOrigin\n if (Array.isArray(raw.legacyUiHosts)) {\n const hosts = raw.legacyUiHosts.filter(isLegacyUiHost)\n if (hosts.length > 0) out.legacyUiHosts = hosts\n }\n if (isHttpsOrigin(raw.linkOrigin)) out.linkOrigin = raw.linkOrigin\n return out\n}\n\n/** Read and parse the runtime config `/config.js` set on `scope` (default: the global object). */\nexport function readRuntimeConfig(scope: unknown = globalThis): NodaroRuntimeConfig {\n try {\n return parseRuntimeConfig(isRecord(scope) || typeof scope === \"function\" ? (scope as Rec)[RUNTIME_CONFIG_GLOBAL] : undefined)\n } catch {\n return {}\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkA6HRY3WF_cjs = require('./chunk-A6HRY3WF.cjs');
|
|
4
4
|
|
|
5
5
|
// src/tts-capabilities.ts
|
|
6
6
|
var TTS_PROVIDER_ALIASES = {
|
|
@@ -13,12 +13,12 @@ function canonicalTtsProvider(provider) {
|
|
|
13
13
|
function findTtsCapabilities(provider) {
|
|
14
14
|
if (typeof provider !== "string" || !provider) return void 0;
|
|
15
15
|
const id = canonicalTtsProvider(provider);
|
|
16
|
-
if (!Object.hasOwn(
|
|
17
|
-
const entry =
|
|
16
|
+
if (!Object.hasOwn(chunkA6HRY3WF_cjs.MODEL_CATALOG, id)) return void 0;
|
|
17
|
+
const entry = chunkA6HRY3WF_cjs.MODEL_CATALOG[id];
|
|
18
18
|
return entry.modes.includes("tts") ? entry.tts : void 0;
|
|
19
19
|
}
|
|
20
20
|
function getTtsCapabilities(provider) {
|
|
21
|
-
return findTtsCapabilities(provider) ??
|
|
21
|
+
return findTtsCapabilities(provider) ?? chunkA6HRY3WF_cjs.MODEL_CATALOG[TTS_FALLBACK_PROVIDER].tts;
|
|
22
22
|
}
|
|
23
23
|
function ttsSupportsAudioTags(provider) {
|
|
24
24
|
return getTtsCapabilities(provider).audioTags;
|
|
@@ -50,5 +50,5 @@ exports.ttsSupportsAudioTags = ttsSupportsAudioTags;
|
|
|
50
50
|
exports.ttsSupportsSsmlBreaks = ttsSupportsSsmlBreaks;
|
|
51
51
|
exports.ttsSupportsStitching = ttsSupportsStitching;
|
|
52
52
|
exports.ttsSupportsTimestamps = ttsSupportsTimestamps;
|
|
53
|
-
//# sourceMappingURL=chunk-
|
|
54
|
-
//# sourceMappingURL=chunk-
|
|
53
|
+
//# sourceMappingURL=chunk-5G23AJBU.cjs.map
|
|
54
|
+
//# sourceMappingURL=chunk-5G23AJBU.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tts-capabilities.ts"],"names":["MODEL_CATALOG"],"mappings":";;;;;AAkBO,IAAM,oBAAA,GAAyD;AAAA,EACpE,UAAA,EAAY;AACd;AAGO,IAAM,qBAAA,GAAwB;AAQ9B,SAAS,qBAAqB,QAAA,EAA0B;AAC7D,EAAA,OAAO,OAAO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AAA,CAAY,UAA8B,KAAA,EAAiC;AACzF,EAAA,OAAO,kBAAA,CAAmB,QAAQ,CAAA,CAAE,MAAA,CAAO,SAAS,KAAK,CAAA;AAC3D;AAGO,SAAS,sBAAsB,QAAA,EAAuC;AAC3E,EAAA,OAAO,kBAAA,CAAmB,QAAQ,CAAA,CAAE,UAAA;AACtC;AAGO,SAAS,iBAAiB,QAAA,EAAiD;AAChF,EAAA,OAAO,kBAAA,CAAmB,QAAQ,CAAA,CAAE,SAAA;AACtC","file":"chunk-5G23AJBU.cjs","sourcesContent":["/**\n * Capability lookups for the text-to-speech lane.\n *\n * Every \"does this model do X\" decision on that lane reads the model's `tts`\n * sheet in `MODEL_CATALOG` through these helpers — tag stripping, which voice\n * settings are sent and shown, the language picker, whether neighbouring text\n * is sent. Declare the sheet honestly\n * on the catalog entry and a new model is covered everywhere; do not compare a\n * provider id by hand.\n *\n * \"The text-to-speech lane\" means the models that list the `tts` mode. The\n * dialogue models carry a sheet too, read by `dialogue-capabilities.ts`; a\n * text-to-speech request that names one runs as the fallback model, so these\n * helpers answer for the fallback there.\n */\nimport { MODEL_CATALOG, type TtsCapabilities, type TtsSettingLever } from \"./model-catalog.js\"\n\n/** Legacy provider ids that are another model under an old name. They have no catalog entry of their own. */\nexport const TTS_PROVIDER_ALIASES: Readonly<Record<string, string>> = {\n elevenlabs: \"elevenlabs-turbo\",\n}\n\n/** The model a request runs on when its provider id is missing or unknown. */\nexport const TTS_FALLBACK_PROVIDER = \"elevenlabs-turbo\"\n\n/**\n * Resolve a legacy alias to the catalog id it runs as. Any other id passes\n * through unchanged. Own properties only: an id that happens to be the name of\n * an inherited object member (`constructor`, `__proto__`, `toString`) is an\n * unknown id like any other, never a function.\n */\nexport function canonicalTtsProvider(provider: string): string {\n return typeof provider === \"string\" && Object.hasOwn(TTS_PROVIDER_ALIASES, provider) ? TTS_PROVIDER_ALIASES[provider]! : provider\n}\n\n/** The capability sheet of a text-to-speech model, or `undefined` when the id is not one. */\nexport function findTtsCapabilities(provider: string | undefined): TtsCapabilities | undefined {\n // `typeof`: node data can be written straight into workflow JSON, so the \"string\" is not guaranteed — and\n // `Object.hasOwn` would coerce an array like [\"elevenlabs-v3\"] into that model's id. A non-string is an unknown id.\n if (typeof provider !== \"string\" || !provider) return undefined\n const id = canonicalTtsProvider(provider)\n if (!Object.hasOwn(MODEL_CATALOG, id)) return undefined\n const entry = MODEL_CATALOG[id]!\n return entry.modes.includes(\"tts\") ? entry.tts : undefined\n}\n\n/**\n * The capability sheet a text-to-speech request will actually run under: a\n * missing or unknown provider id runs as {@link TTS_FALLBACK_PROVIDER}, so it\n * gets that sheet — including its `maxChars` (turbo's 40,000), where\n * `getMaxTtsChars` keeps answering its 5,000 default for such ids.\n */\nexport function getTtsCapabilities(provider: string | undefined): TtsCapabilities {\n return findTtsCapabilities(provider) ?? MODEL_CATALOG[TTS_FALLBACK_PROVIDER]!.tts!\n}\n\n/** The model performs inline `[audio tags]`. false ⇒ strip them before sending. */\nexport function ttsSupportsAudioTags(provider: string | undefined): boolean {\n return getTtsCapabilities(provider).audioTags\n}\n\n/** The model honours SSML `<break time=\"…\"/>` tags. */\nexport function ttsSupportsSsmlBreaks(provider: string | undefined): boolean {\n return getTtsCapabilities(provider).ssmlBreaks\n}\n\n/**\n * The model conditions on neighbouring text (`previous_text` / `next_text`).\n * false ⇒ the provider funnel never puts the fields on the wire, whatever the\n * request carries — the model would reject them.\n */\nexport function ttsSupportsStitching(provider: string | undefined): boolean {\n return getTtsCapabilities(provider).stitching\n}\n\n/** The model honours this voice-setting lever. */\nexport function ttsHasLever(provider: string | undefined, lever: TtsSettingLever): boolean {\n return getTtsCapabilities(provider).levers.includes(lever)\n}\n\n/** The model answers `/v1/text-to-speech/{voice}/with-timestamps` (character timings). */\nexport function ttsSupportsTimestamps(provider: string | undefined): boolean {\n return getTtsCapabilities(provider).timestamps\n}\n\n/** Language codes offered for the model, in catalog order. */\nexport function ttsLanguageCodes(provider: string | undefined): readonly string[] {\n return getTtsCapabilities(provider).languages\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkGWBQ3GPO_cjs = require('./chunk-GWBQ3GPO.cjs');
|
|
4
4
|
|
|
5
5
|
// src/fan-out-meta.ts
|
|
6
6
|
function fanOutItemMeta(output) {
|
|
@@ -441,7 +441,7 @@ function ugcCardsJobs(input) {
|
|
|
441
441
|
if (typeof transcript !== "string") return { error: NEEDS_TRANSCRIPT };
|
|
442
442
|
return {
|
|
443
443
|
alignment: { path: "/v1/forced-alignment", body: { audioUrl: videoUrl, transcript } },
|
|
444
|
-
transcribe: { path: "/v1/transcribe", body: { ...transcribeArgs, audioUrl: videoUrl, provider:
|
|
444
|
+
transcribe: { path: "/v1/transcribe", body: { ...transcribeArgs, audioUrl: videoUrl, provider: chunkGWBQ3GPO_cjs.DEFAULT_TRANSCRIBE_NODE_PROVIDER, wordTimestamps: true } },
|
|
445
445
|
plan
|
|
446
446
|
};
|
|
447
447
|
}
|
|
@@ -522,5 +522,5 @@ exports.ugcRunWaitsForPick = ugcRunWaitsForPick;
|
|
|
522
522
|
exports.ugcScriptBody = ugcScriptBody;
|
|
523
523
|
exports.ugcScriptOutputs = ugcScriptOutputs;
|
|
524
524
|
exports.ugcScriptResult = ugcScriptResult;
|
|
525
|
-
//# sourceMappingURL=chunk-
|
|
526
|
-
//# sourceMappingURL=chunk-
|
|
525
|
+
//# sourceMappingURL=chunk-5HK5Z5OB.cjs.map
|
|
526
|
+
//# sourceMappingURL=chunk-5HK5Z5OB.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fan-out-meta.ts","../src/ugc-run-state.ts","../src/ugc-node-wires.ts"],"names":["DEFAULT_TRANSCRIBE_NODE_PROVIDER"],"mappings":";;;;;AAKO,SAAS,eAAe,MAAA,EAA8F;AAC3H,EAAA,MAAM,IAAI,MAAA,EAAQ,YAAA;AAClB,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,CAAQ,MAAA,CAAO,SAAS,CAAA,GAAI,MAAA,CAAO,SAAA,GAAY,EAAE,CAAA;AAAA,IACjF,WAAA,EAAa,IAAA,CAAK,SAAA,CAAU,QAAA,CAAS,MAAM,CAAA,GAAI,EAAE,CAAA,EAAG,CAAA,EAAG,GAAG,MAAA,EAAO,GAAI,kBAAkB,CAAA;AAAA,IACvF,MAAA,EAAQ,KAAA,CAAM,IAAA,CAAK,IAAI;AAAA,GACzB;AACF","file":"chunk-IKOKRJDI.cjs","sourcesContent":["/** One fan-out item's notes: its warnings and its real length (UGC Clip). */\nexport interface FanOutItemMeta { readonly warnings: readonly string[]; readonly durationSec: number | null }\n/** One row of UGC Cards' `notes` input. */\nexport interface ClipNote { readonly clip: number; readonly warnings: readonly string[]; readonly durationSec?: number }\n\nexport function fanOutItemMeta(output: { clipWarnings?: unknown; durationSec?: unknown } | null | undefined): FanOutItemMeta {\n const w = output?.clipWarnings\n const d = output?.durationSec\n return {\n warnings: Array.isArray(w) ? w.filter((x): x is string => typeof x === \"string\") : [],\n durationSec: typeof d === \"number\" && Number.isFinite(d) && d > 0 ? d : null,\n }\n}\n\n/** Row-aligned meta (or one single output) → the notes UGC Cards reads, clip numbers from 1. */\nexport function clipNotesFrom(meta: ReadonlyArray<FanOutItemMeta | null | undefined> | undefined, single?: FanOutItemMeta): ClipNote[] {\n const rows = meta && meta.length > 0 ? meta : single ? [single] : []\n return rows.map((m, i) => ({\n clip: i + 1,\n warnings: m?.warnings ?? [],\n ...(typeof m?.durationSec === \"number\" ? { durationSec: m.durationSec } : {}),\n }))\n}\n","/** The UGC node types (Cloud only; served by a private plugin). */\nexport const UGC_NODE_TYPES: ReadonlySet<string> = new Set([\"ugc-creator\", \"ugc-script\", \"ugc-clips\", \"ugc-clip\", \"ugc-cards\", \"ugc-finish-clips\"])\n\n/** UGC Creator: the node-data key that holds a round's passing candidates until the person picks one (run state). */\nexport const UGC_CREATOR_CANDIDATES_KEY = \"candidates\"\n\n/** A run that would execute a UGC Creator whose options wait for the person's pick. */\nexport const UGC_PICK_FIRST_MESSAGE = \"Pick a creator first.\"\n\n/**\n * Per UGC type, the node-data keys that are a RUN's state, never a choice. A\n * published app's snapshot is readable by every runner, so publishing strips\n * them (the last plan, the clip tickets, the publisher's kept creator).\n *\n * UGC Creator's image (`generatedImageUrl`) goes from every creator, whatever its\n * source: after a My photo run it IS the author's photo, and a creator switched\n * to another source after such a run, or whose photo was removed, still holds it.\n * UGC Clip's takes and UGC Cards' Notes (`generatedText`, and `text`, the Notes\n * as a run hands them on) are the author's renders: a published node starts empty.\n *\n * A published snapshot is stripped through `stripUgcPublishState`\n * (@nodaro/render-rules), which also empties every run result a lane writes under\n * a generic name, every node made from the UGC video, and every node on a path\n * into a UGC Creator's photo input.\n */\nexport const UGC_NODE_RUN_STATE_KEYS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"result\", \"keepResult\", \"ugcOutputs\", UGC_CREATOR_CANDIDATES_KEY, \"optionFailed\", \"generatedImageUrl\"],\n // `exampleLines`: a template's example run, shown until the node's own first script (display only).\n \"ugc-script\": [\"result\", \"keepResult\", \"ugcOutputs\", \"exampleLines\"],\n \"ugc-clips\": [\"result\", \"quote\", \"__listResults\", \"ugcOutputs\"],\n \"ugc-clip\": [\n \"warnings\", \"rerender\", \"rerenderPending\", \"__listResults\", \"__listResultMeta\", \"clipWarnings\", \"durationSec\", \"ugcOutputs\",\n \"generatedVideoUrl\", \"generatedResults\", \"activeResultIndex\",\n ],\n \"ugc-cards\": [\"result\", \"ugcOutputs\", \"generatedText\", \"text\"],\n \"ugc-finish-clips\": [\"ugcOutputs\", \"__listResults\", \"__listResultMeta\", \"generatedVideoUrl\", \"generatedResults\", \"activeResultIndex\"],\n}\n\n/**\n * The ONLY UGC keys a run request's `inputOverrides` may set — an allow-list,\n * so a run-state field added later is locked without anyone listing it.\n *\n * No UGC type may gain a `LEGACY_EXPOSED_FIELD_KEYS` row: the lock reads the\n * stored key, before that table renames it.\n */\nexport const UGC_OVERRIDABLE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"source\", \"gender\", \"photoUrl\"],\n \"ugc-script\": [\"targetDurationSec\", \"language\"],\n \"ugc-clips\": [],\n \"ugc-clip\": [],\n \"ugc-cards\": [],\n \"ugc-finish-clips\": [],\n}\n\nconst KEEP_RESULT_TYPES: ReadonlySet<string> = new Set([\"ugc-creator\", \"ugc-script\"])\n\n/** UGC Creator holds options for the person to pick: the ones a run drew, or the ones a credits stop kept. */\nexport function ugcPickPending(data: unknown): boolean {\n const candidates = data && typeof data === \"object\" ? (data as Record<string, unknown>)[UGC_CREATOR_CANDIDATES_KEY] : undefined\n return Array.isArray(candidates) && candidates.length > 0\n}\n\n/**\n * A run that would execute a UGC Creator whose options wait is refused (\"Pick a creator first.\"),\n * except that creator's own re-draw. One rule for the editor's check before a run and the\n * orchestrator's.\n */\nexport function ugcRunWaitsForPick(\n runNodes: ReadonlyArray<{ readonly id: string; readonly type?: string | null; readonly data?: unknown }>,\n opts: { readonly redrawId?: string } = {},\n): boolean {\n return runNodes.some((n) => n.type === \"ugc-creator\" && n.id !== opts.redrawId && ugcPickPending(n.data))\n}\n\n/**\n * Per UGC type, the author's own content a published snapshot never carries: UGC Creator's photo\n * of a person (`photoUrl`). A choice, not run state — so it stays on the author's own workflow —\n * but a runner gives their own photo (or the run is refused for want of one) and a template's\n * cloner adds theirs.\n */\nexport const UGC_PUBLISH_PRIVATE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"photoUrl\"],\n}\n\n/**\n * The UGC types' own strip: a copy of `nodes` with every UGC node's run state and the author's own\n * photo removed (and `keepResult: false`). Other nodes are returned as they are. Publishing, a\n * share link's view and a viewer's run go through `stripUgcPublishState` (@nodaro/render-rules),\n * which starts here.\n */\nexport function stripUgcRunState<T extends { type?: unknown; data?: unknown }>(nodes: readonly T[]): T[] {\n return nodes.map((node) => {\n const type = typeof node.type === \"string\" ? node.type : \"\"\n if (!UGC_NODE_TYPES.has(type) || !node.data || typeof node.data !== \"object\") return node\n const data: Record<string, unknown> = { ...(node.data as Record<string, unknown>) }\n for (const key of UGC_NODE_RUN_STATE_KEYS[type] ?? []) delete data[key]\n for (const key of UGC_PUBLISH_PRIVATE_FIELDS[type] ?? []) delete data[key]\n if (KEEP_RESULT_TYPES.has(type)) data.keepResult = false\n return { ...node, data }\n })\n}\n\n/** Every override entry that would set a non-overridable key on a UGC node, in node then key order. Pure. */\nexport function findUgcLockedFields(\n nodes: ReadonlyArray<{ id: string; type?: string }> | null | undefined,\n inputOverrides: Record<string, Record<string, unknown>> | null | undefined,\n): Array<{ nodeId: string; nodeType: string; field: string }> {\n if (!nodes || !inputOverrides) return []\n const found: Array<{ nodeId: string; nodeType: string; field: string }> = []\n for (const node of nodes) {\n const type = node?.type\n if (typeof type !== \"string\" || !UGC_NODE_TYPES.has(type)) continue\n const allowed = UGC_OVERRIDABLE_FIELDS[type] ?? []\n const fields = inputOverrides[node.id]\n if (!fields || typeof fields !== \"object\") continue\n for (const field of Object.keys(fields)) {\n if (!allowed.includes(field)) found.push({ nodeId: String(node.id), nodeType: type, field })\n }\n }\n return found\n}\n","/**\n * The UGC node wires: every request body the five UGC nodes send and every\n * output they hand on, as ONE pure implementation that both engines (the\n * workflow orchestrator and the editor) call, so the two can never disagree.\n *\n * Content-free. A creator record is read only for `v`, `gender` and\n * `identityImages`, a plan only for `v`, a clip ticket only for `v`, `index`\n * and `durationSec`; every other key is opaque and passes through as it came.\n * Every UGC-private JSON a node emits carries `v: 1`, and a wire with another\n * `v` is refused, never guessed at.\n */\nimport type { CaptionPlan } from \"./caption-plan.js\"\nimport { fanOutItemMeta, type ClipNote } from \"./fan-out-meta.js\"\nimport { DEFAULT_TRANSCRIBE_NODE_PROVIDER } from \"./model-constants.js\"\nimport { ugcPickPending } from \"./ugc-run-state.js\"\n\n/** A UGC call that reached a deployment without the UGC routes (the router's 404). */\nexport const UGC_NOT_SERVED_MESSAGE = \"UGC videos are a Nodaro Cloud feature and are not served on this deployment.\"\n/** A wire whose `v` this app does not read. */\nexport const UGC_VERSION_MESSAGE = \"This workflow was made with a newer version of the UGC nodes.\"\n/** An answer this app cannot run: a tool it does not know, or a shape it cannot read. */\nexport const UGC_NEWER_APP_MESSAGE = \"This step needs a newer app version.\"\n/** A creator pick whose options are gone (another run replaced them, or they were never this node's). */\nexport const UGC_PICK_GONE_MESSAGE = \"These creator options are no longer available. Run UGC Creator again.\"\n/** UGC Clips with no creator on its creator input (UGC Creator has not run, or waits for a pick). */\nexport const UGC_CREATOR_MISSING_MESSAGE = \"UGC Creator has no creator yet. Run it, or pick one of its options.\"\n/** UGC Script's target length in seconds when the node holds none: the node's default (the route requires a length). */\nexport const UGC_SCRIPT_DEFAULT_TARGET_SEC = 15\n/** The range of a UGC script's length, in whole seconds: the script route's, and a plan's own. */\nexport const UGC_SCRIPT_MIN_TARGET_SEC = 4\nexport const UGC_SCRIPT_MAX_TARGET_SEC = 300\n\nconst MINOR_AGE_MESSAGE = \"That age can't be used: UGC creators are adults only.\"\nconst NEEDS_GENDER = \"Choose woman or man.\"\nconst NEEDS_PHOTO = \"Connect or upload a photo of yourself.\"\nconst NEEDS_CATEGORY = \"Run UGC Script first, or pick a product category.\"\nconst NEEDS_SITE = \"Add the product name or website.\"\n/** The opening of the sentence UGC Clips fails with when the plugin refuses the script: \"<this> <each error and its fix>\". */\nexport const UGC_SCRIPT_NEEDS_CHANGES = \"The script needs changes:\"\nconst NEEDS_PLAN_OUT = \"Connect the Script (sized) output of UGC Clips.\"\nconst NEEDS_PLAN = \"Connect the Script output of UGC Script.\"\nconst NEEDS_TICKET = \"Connect the Clips output of UGC Clips.\"\nconst NEEDS_VIDEO = \"Connect the joined video.\"\nconst NEEDS_TRANSCRIPT = \"Connect the Transcript output of UGC Clips.\"\n/**\n * A run of a video whose clips are cut from one recorded speech, on a graph with no UGC Finish on this UGC\n * Clips' Script (sized) output: refused before anything is spent.\n */\nexport const UGC_NEEDS_FINISH_MESSAGE = \"Add a UGC Finish node after UGC Clip, and connect UGC Clips' Script (sized) output to it.\"\n/** UGC Finish with nothing on its clips input. */\nexport const UGC_FINISH_NEEDS_CLIPS_MESSAGE = \"Connect the Video output of UGC Clip.\"\n/** UGC Finish's job answered that a clip does not follow its speech (each clip checks itself first, so this is rare). */\nexport const UGC_FINISH_NOT_READY_MESSAGE = \"A clip did not follow its speech. Re-render it from the UGC Clip node and run again.\"\n/**\n * A video cut from one recorded speech whose clips, priced once the speech is split, would hold more\n * than the run was checked for before it started: the run stops at UGC Clips, before any clip renders.\n */\nexport const UGC_OVER_HOLD_MESSAGE =\n \"The clips for this recording would cost more than this run was checked for, so none was rendered. Run UGC Clips again to record the speech again.\"\n\n/**\n * Every fixed sentence a UGC node fails with, by id: the English both engines write on the node.\n * The editor shows each in the person's language by its id. Not listed: the sentence that opens\n * with `UGC_SCRIPT_NEEDS_CHANGES` (the plugin's own words finish it), a route's own message, and\n * \"UGC step failed (<status>)\".\n */\nexport const UGC_NODE_MESSAGES = Object.freeze({\n notServed: UGC_NOT_SERVED_MESSAGE,\n version: UGC_VERSION_MESSAGE,\n newerApp: UGC_NEWER_APP_MESSAGE,\n pickGone: UGC_PICK_GONE_MESSAGE,\n creatorMissing: UGC_CREATOR_MISSING_MESSAGE,\n minorAge: MINOR_AGE_MESSAGE,\n needsGender: NEEDS_GENDER,\n needsPhoto: NEEDS_PHOTO,\n needsCategory: NEEDS_CATEGORY,\n needsSite: NEEDS_SITE,\n needsPlanOut: NEEDS_PLAN_OUT,\n needsPlan: NEEDS_PLAN,\n needsTicket: NEEDS_TICKET,\n needsVideo: NEEDS_VIDEO,\n needsTranscript: NEEDS_TRANSCRIPT,\n needsFinish: UGC_NEEDS_FINISH_MESSAGE,\n finishNeedsClips: UGC_FINISH_NEEDS_CLIPS_MESSAGE,\n finishNotReady: UGC_FINISH_NOT_READY_MESSAGE,\n overHold: UGC_OVER_HOLD_MESSAGE,\n} as const)\n\n/** The id of a fixed sentence a UGC node fails with (`UGC_NODE_MESSAGES`). */\nexport type UgcNodeMessageId = keyof typeof UGC_NODE_MESSAGES\n\n/** UGC Script's screenshot inputs, in card order. */\nexport const UGC_SCREENSHOT_HANDLES: readonly string[] = [\n \"screenshot\", \"screenshot2\", \"screenshot3\", \"screenshot4\", \"screenshot5\", \"screenshot6\", \"screenshot7\", \"screenshot8\",\n]\n\n/** Per UGC type, the output an edge with no source handle reads. */\nexport const UGC_PRIMARY_HANDLE: Readonly<Record<string, string>> = {\n \"ugc-creator\": \"creator\",\n \"ugc-script\": \"plan\",\n \"ugc-clips\": \"clips\",\n \"ugc-clip\": \"video-out\",\n \"ugc-cards\": \"layerPlan\",\n \"ugc-finish-clips\": \"video-out\",\n}\n\n/** A UGC node's outputs: handle id → the value that handle carries (a JSON string, text or a URL). */\nexport type UgcOutputs = Readonly<Record<string, string>>\n\ntype Obj = Record<string, unknown>\nconst isObject = (x: unknown): x is Obj => !!x && typeof x === \"object\" && !Array.isArray(x)\n\n/**\n * The length a saved UGC plan was written to: its own `targetDurationSec`, a whole number of\n * seconds in the script's range. Besides the lines (the opening line, each beat's line, the\n * closing line), one of the two keys of a plan the app reads (the other: whether each beat carries\n * a screenshot, `ugcPlanScreenshotCount`): a script that hands on its saved plan is priced at the\n * plan's length, and shows it, never at the length setting, which may have changed since. Takes\n * the plan or its wire (a JSON string); undefined for anything that is not a plan carrying a length.\n */\nexport function ugcPlanLengthSec(plan: unknown): number | undefined {\n const value = savedPlanOf(plan)\n if (!value) return undefined\n const sec = value.targetDurationSec\n return typeof sec === \"number\" && Number.isInteger(sec) && sec >= UGC_SCRIPT_MIN_TARGET_SEC && sec <= UGC_SCRIPT_MAX_TARGET_SEC ? sec : undefined\n}\n\n/**\n * How many of a saved UGC plan's beats carry a screenshot: the screenshot cards the plan was\n * written with. Read beat by beat: a beat carries one when its `screenshot` is an object, as the\n * plan's own screenshots are (whatever it names); a beat that is not an object, or whose screenshot\n * is anything else, carries none — and never makes the rest unreadable. A plan whose beats carry\n * none is a talking-head plan (0). Read, like its length, so a script that hands on its saved plan\n * is priced at the screenshots that plan holds, never at the script's wires, which may have changed\n * since. Takes the plan or its wire (a JSON string); undefined only for a plan with no beats to read\n * and for anything that is not a plan.\n */\nexport function ugcPlanScreenshotCount(plan: unknown): number | undefined {\n const value = savedPlanOf(plan)\n if (!value || !Array.isArray(value.beats)) return undefined\n return value.beats.filter((beat) => isObject(beat) && isObject(beat.screenshot)).length\n}\n\n/** A saved plan, or its wire (a JSON string), as an object; undefined for anything else. */\nfunction savedPlanOf(plan: unknown): Obj | undefined {\n let value: unknown = plan\n if (typeof value === \"string\") {\n try {\n value = JSON.parse(value)\n } catch {\n return undefined\n }\n }\n return isObject(value) ? value : undefined\n}\n/** A string with something in it; an empty or blank field or input counts as absent. */\nconst filled = (x: unknown): string | undefined => (typeof x === \"string\" && x.trim() !== \"\" ? x : undefined)\n\n/**\n * What an edge from a UGC node reads, on both engines: the value of the pip it leaves — an edge\n * with no source handle reads the node's primary output — from the node's outputs by pip. Only a\n * pip the outputs hold as a string (\"\" included: an empty transcript is a value); an inherited\n * key or a non-string is no value.\n */\nexport function ugcPipValue(outputs: unknown, sourceType: string, sourceHandle?: string | null): string | undefined {\n const pip = sourceHandle || (Object.hasOwn(UGC_PRIMARY_HANDLE, sourceType) ? UGC_PRIMARY_HANDLE[sourceType] : undefined)\n if (pip === undefined || !isObject(outputs) || !Object.hasOwn(outputs, pip)) return undefined\n const value = outputs[pip]\n return typeof value === \"string\" ? value : undefined\n}\n\n/**\n * A UGC wire (a JSON string or an object) → its value when it is an object with `v: 1`.\n * Another `v` → the version message. Anything that is not a UGC wire at all (nothing\n * connected, not JSON, no `v`) → `unreadable`, which a node words as the input it needs.\n */\nexport function readUgcWire(raw: unknown, unreadable: string = UGC_VERSION_MESSAGE): { value: Record<string, unknown> } | { error: string } {\n let parsed: unknown = raw\n if (typeof raw === \"string\") {\n try {\n parsed = JSON.parse(raw)\n } catch {\n return { error: unreadable }\n }\n }\n if (!isObject(parsed) || parsed.v === undefined) return { error: unreadable }\n if (parsed.v !== 1) return { error: UGC_VERSION_MESSAGE }\n return { value: parsed }\n}\n\n/** The route's `{ error: { code, message } }` (or a framework error's top-level `message`). */\nfunction routeErrorOf(body: string): { code?: string; message?: string } {\n let parsed: unknown\n try {\n parsed = JSON.parse(body)\n } catch {\n return {}\n }\n if (!isObject(parsed)) return {}\n if (isObject(parsed.error)) {\n const { code, message } = parsed.error\n return { code: typeof code === \"string\" ? code : undefined, message: filled(message) }\n }\n return { message: filled(parsed.message) }\n}\n\n/**\n * A failed UGC call → the sentence the node fails with. A 404 that names no error code is\n * the router's (the route is not registered here) → the Cloud sentence; a route's own 404\n * names a code and keeps its message. `minor_age_refused` → the adults-only sentence. A 4xx\n * or 503 → the route's message. Anything else → \"UGC step failed (<status>)\".\n */\nexport function ugcFailure(status: number, body: string): string {\n const error = routeErrorOf(body)\n if (status === 404 && error.code === undefined) return UGC_NOT_SERVED_MESSAGE\n if (error.code === \"minor_age_refused\") return MINOR_AGE_MESSAGE\n if ((status === 503 || (status >= 400 && status < 500)) && error.message) return error.message\n return `UGC step failed (${status})`\n}\n\n// ── UGC Creator ──────────────────────────────────────────────────────────────\n\n/**\n * The pickers whose own set fields shape a sampled creator: the picker types UGC Creator's\n * `pickers` input takes (the route takes no other). One list for the editor's connection rule\n * and both engines' input resolvers.\n */\nexport const UGC_CREATOR_PICKER_TYPES: ReadonlySet<string> = new Set([\"person\", \"styling\", \"setting\", \"lighting\"])\n\n/** The UGC Creator node-data keys its request body reads. */\nexport interface UgcCreatorFields {\n readonly source?: string\n readonly gender?: string\n readonly photoUrl?: string\n readonly categoryOverride?: string\n readonly seed?: number\n readonly keepResult?: boolean\n readonly result?: Readonly<Record<string, unknown>>\n /** The options a draw left waiting for the pick (run state): read only for `previous`. */\n readonly candidates?: unknown\n}\n\n/** The traits of the latest creator the person saw: the first waiting option's, else the last result's (Keep off). */\nfunction previousTraits(data: UgcCreatorFields): unknown {\n if (ugcPickPending(data)) {\n const first: unknown = (data.candidates as readonly unknown[])[0]\n const record = isObject(first) ? first.record : undefined\n return isObject(record) ? record.traits : undefined\n }\n return !data.keepResult && isObject(data.result) ? data.result.traits : undefined\n}\n\n/** The wired pickers that set a field (their own fields, as the resolver read them); undefined when none did. */\nfunction setPickers(pickers: Record<string, Record<string, unknown>> | undefined): Record<string, Record<string, unknown>> | undefined {\n if (!pickers) return undefined\n const set = Object.entries(pickers).filter(([, fields]) => isObject(fields) && Object.keys(fields).length > 0)\n return set.length > 0 ? Object.fromEntries(set) : undefined\n}\n\n/**\n * The `/v1/ugc/creator` body. A photo: the wired photo, else the node's own. A sampled\n * creator: the product category (the node's override, else the wired one), the pickers that\n * set a field, the node's seed, and the traits of the latest creator the person saw as\n * `previous`, so the next one differs: the first option waiting for the pick, else — on a\n * re-run that does not keep the result — the last creator's. Refuses before any call.\n */\nexport function ugcCreatorBody(input: {\n data: UgcCreatorFields\n photoUrl?: string\n category?: string\n pickers?: Record<string, Record<string, unknown>>\n}): { body: Record<string, unknown> } | { error: string } {\n const { data } = input\n const gender = data.gender\n if (gender !== \"woman\" && gender !== \"man\") return { error: NEEDS_GENDER }\n if (data.source === \"photo\") {\n const imageUrl = filled(input.photoUrl) ?? filled(data.photoUrl)\n if (!imageUrl) return { error: NEEDS_PHOTO }\n return { body: { source: { kind: \"photo\", imageUrl, gender } } }\n }\n const productCategory = filled(data.categoryOverride) ?? filled(input.category)\n if (!productCategory) return { error: NEEDS_CATEGORY }\n const pickers = setPickers(input.pickers)\n const traits = previousTraits(data)\n return {\n body: {\n ...(typeof data.seed === \"number\" ? { seed: data.seed } : {}),\n source: {\n kind: \"sampled\",\n gender,\n productCategory,\n ...(pickers ? { pickers } : {}),\n ...(isObject(traits) ? { previous: traits } : {}),\n },\n },\n }\n}\n\n/**\n * The creator the node hands on: the record (`creator`, v1) and its first image (`image`).\n * `identityImages` are the images of the candidate the node hands on — the picked one where\n * a person picked. The record copies the listed fields only, so `candidates`, `fallback`,\n * `pick` and `image` never reach the `creator` wire.\n */\nexport function ugcCreatorOutputs(answer: Record<string, unknown>, identityImages: readonly string[]): { outputs: UgcOutputs; imageUrl: string; record: Record<string, unknown> } {\n const record: Record<string, unknown> = {\n v: 1,\n kind: answer.kind,\n gender: answer.gender,\n identityImages: [...identityImages],\n traits: answer.traits ?? null,\n seed: answer.seed ?? null,\n promptsVersion: answer.promptsVersion,\n productCategory: answer.productCategory ?? null,\n }\n const imageUrl = identityImages[0] ?? \"\"\n return { outputs: { creator: JSON.stringify(record), ...(imageUrl ? { image: imageUrl } : {}) }, imageUrl, record }\n}\n\n/** One builder call as the app runs it: `tool` and `args`, nothing else (a candidate's other keys, its model included, are never read). */\nexport interface UgcCreatorCall { readonly tool: string; readonly args: Readonly<Record<string, unknown>> }\n\n/** What a creator answer asks the node to render. */\nexport interface UgcCreatorCandidateCalls {\n /** Every candidate's image call, the primary first. One call (`image`) for an answer from before candidates; none for a photo. */\n readonly calls: readonly UgcCreatorCall[]\n /** The round's one moderation fallback: it runs once, and only when every candidate the run rendered was blocked. */\n readonly fallback: UgcCreatorCall | null\n /** \"user\": a person picks among `calls` where one can be asked; \"primary\": `calls[0]` alone; null: nothing to render (a photo). */\n readonly pick: \"user\" | \"primary\" | null\n}\n\nconst callOf = (raw: unknown): UgcCreatorCall | undefined => {\n if (!raw || typeof raw !== \"object\") return undefined\n const { tool, args } = raw as { tool?: unknown; args?: unknown }\n if (typeof tool !== \"string\" || !args || typeof args !== \"object\" || Array.isArray(args)) return undefined\n return { tool, args: args as Readonly<Record<string, unknown>> }\n}\nconst fallbackOf = (image: unknown): unknown => (image && typeof image === \"object\" ? (image as { fallback?: unknown }).fallback : undefined)\n\n/**\n * A `/v1/ugc/creator` answer's image calls. Content-free: reads `image` (`tool`, `args`,\n * `fallback`), `candidates[].tool|args`, `fallback` and `pick.how` — never a candidate's\n * model. An answer without `candidates` (an older builder) renders `image` alone, as before.\n */\nexport function ugcCreatorCandidates(answer: Readonly<Record<string, unknown>>): UgcCreatorCandidateCalls | { readonly error: string } {\n const listed = answer.candidates\n const noList = listed === undefined || listed === null || (Array.isArray(listed) && listed.length === 0)\n const noImage = answer.image === undefined || answer.image === null\n if (noList && noImage) return { calls: [], fallback: null, pick: null }\n if (noList) {\n const image = callOf(answer.image)\n if (!image) return { error: UGC_NEWER_APP_MESSAGE }\n return { calls: [image], fallback: callOf(fallbackOf(answer.image)) ?? null, pick: \"primary\" }\n }\n if (!Array.isArray(listed)) return { error: UGC_NEWER_APP_MESSAGE }\n const calls = listed.map(callOf)\n if (calls.some((c) => c === undefined)) return { error: UGC_NEWER_APP_MESSAGE }\n const how = (answer.pick as { how?: unknown } | null | undefined)?.how\n return {\n calls: calls as UgcCreatorCall[],\n fallback: callOf(answer.fallback) ?? callOf(fallbackOf(answer.image)) ?? null,\n pick: how === \"user\" && calls.length > 1 ? \"user\" : \"primary\",\n }\n}\n\n/** The calls a run renders: every candidate where a person is there to pick, else the primary alone. */\nexport function ugcCreatorCallsToRender(c: UgcCreatorCandidateCalls, opts: { readonly personPicks: boolean }): readonly UgcCreatorCall[] {\n return opts.personPicks && c.pick === \"user\" ? c.calls : c.calls.slice(0, 1)\n}\n\n/** One rendered candidate that passed its checks, kept on the node until the person picks (run state, never a wire). */\nexport interface UgcCreatorCandidate { readonly imageUrl: string; readonly record: Readonly<Record<string, unknown>> }\n\nexport function ugcCreatorCandidate(answer: Readonly<Record<string, unknown>>, images: readonly string[]): UgcCreatorCandidate {\n const out = ugcCreatorOutputs(answer as Record<string, unknown>, images)\n return { imageUrl: out.imageUrl, record: out.record }\n}\n\n/** A UGC Creator run output that waits for the person's pick: two or more options (`ugcCandidates`). */\nexport function ugcAwaitsPick(output: unknown): boolean {\n const candidates = isObject(output) ? output.ugcCandidates : undefined\n return Array.isArray(candidates) && candidates.length >= 2\n}\n\n/** The person's pick, read back from node data (untrusted): a stale index, a foreign list or another version is refused. */\nexport function ugcCreatorPick(candidates: unknown, index: number):\n { readonly result: Readonly<Record<string, unknown>>; readonly outputs: UgcOutputs; readonly imageUrl: string } | { readonly error: string } {\n const entry: unknown = Array.isArray(candidates) && Number.isInteger(index) && index >= 0 ? candidates[index] : undefined\n const imageUrl = (entry as { imageUrl?: unknown } | undefined)?.imageUrl\n const record = (entry as { record?: unknown } | undefined)?.record\n if (typeof imageUrl !== \"string\" || !record || typeof record !== \"object\" || Array.isArray(record)) return { error: UGC_PICK_GONE_MESSAGE }\n const r = record as Record<string, unknown>\n if (r.v !== 1) return { error: UGC_VERSION_MESSAGE }\n if (!Array.isArray(r.identityImages) || r.identityImages[0] !== imageUrl) return { error: UGC_PICK_GONE_MESSAGE }\n return { result: r, outputs: { creator: JSON.stringify(r), image: imageUrl }, imageUrl }\n}\n\n// ── UGC Script ───────────────────────────────────────────────────────────────\n\n/** The languages a UGC script can be written in: the node's choice (`UgcScriptData.language`). */\nexport const UGC_SCRIPT_LANGUAGES = [\"en\", \"he\"] as const\nexport type UgcScriptLanguage = (typeof UGC_SCRIPT_LANGUAGES)[number]\n\n/**\n * The `/v1/ugc/script` body: the product name or website (required), the screenshot slots\n * in card order with the empty ones dropped, the product image when set, the target length\n * (`UGC_SCRIPT_DEFAULT_TARGET_SEC` when the node holds no number), and the language (the\n * node's choice; English when it holds none or one this app does not know).\n */\nexport function ugcScriptBody(input: {\n site?: string\n screenshots: ReadonlyArray<string | undefined>\n productImage?: string\n targetDurationSec?: number\n language?: unknown\n}): { body: Record<string, unknown> } | { error: string } {\n const site = filled(input.site)?.trim()\n if (!site) return { error: NEEDS_SITE }\n const productImage = filled(input.productImage)\n return {\n body: {\n site,\n screenshots: input.screenshots.filter((s): s is string => filled(s) !== undefined),\n ...(productImage ? { productImage } : {}),\n targetDurationSec: typeof input.targetDurationSec === \"number\" ? input.targetDurationSec : UGC_SCRIPT_DEFAULT_TARGET_SEC,\n language: (UGC_SCRIPT_LANGUAGES as readonly unknown[]).includes(input.language) ? input.language : \"en\",\n },\n }\n}\n\n/** A finished UGC Script job → `plan` (the plan, v1) and `category` (text). */\nexport function ugcScriptOutputs(outputData: Record<string, unknown>): UgcOutputs {\n const plan = outputData.plan\n const category = filled(outputData.productCategory)\n return {\n ...(isObject(plan) ? { plan: JSON.stringify({ v: 1, ...plan }) } : {}),\n ...(category ? { category } : {}),\n }\n}\n\n/** UGC Script's last result, as the node holds it. */\nexport type UgcScriptResult = {\n plan: Record<string, unknown>\n productCategory: string\n warnings: unknown[]\n notes: string[]\n rounds: number\n}\n\n/** A finished UGC Script job → the node's `result`, written the same by both engines; none without a plan. */\nexport function ugcScriptResult(outputData: Readonly<Record<string, unknown>>): UgcScriptResult | undefined {\n const { plan, productCategory, warnings, notes, rounds } = outputData\n if (!isObject(plan)) return undefined\n return {\n plan,\n productCategory: filled(productCategory) ?? \"\",\n warnings: Array.isArray(warnings) ? [...warnings] : [],\n notes: Array.isArray(notes) ? notes.filter((n): n is string => typeof n === \"string\") : [],\n rounds: typeof rounds === \"number\" && Number.isFinite(rounds) ? rounds : 0,\n }\n}\n\n// ── Kept results ─────────────────────────────────────────────────────────────\n\n/**\n * What a UGC Creator or UGC Script with Keep on hands on instead of running: the outputs of\n * the result it holds. Null — the node runs — when Keep is off, when the result holds nothing\n * to hand on (a creator without its image, a script without its plan), and for a creator whose\n * options wait for a pick, whatever Keep says. The creator record goes on unread; whoever reads\n * it refuses another version.\n */\nexport function ugcKeptOutputs(type: \"ugc-creator\" | \"ugc-script\", data: Readonly<Record<string, unknown>>): UgcOutputs | null {\n if (type === \"ugc-creator\" && ugcPickPending(data)) return null\n const result = data.keepResult === true ? data.result : undefined\n if (!isObject(result)) return null\n if (type === \"ugc-creator\") {\n const image = Array.isArray(result.identityImages) ? filled(result.identityImages[0]) : undefined\n return image ? { creator: JSON.stringify(result), image } : null\n }\n if (type === \"ugc-script\") return isObject(result.plan) ? ugcScriptOutputs(result) : null\n return null\n}\n\n// ── UGC Clips ────────────────────────────────────────────────────────────────\n\n/** The `/v1/ugc/clips` canvas body: the plan, the creator's gender, traits and images, and the picked voice. */\nexport function ugcClipsBody(input: { planWire: unknown; creatorWire: unknown; voiceId?: string }): { body: Record<string, unknown> } | { error: string } {\n const plan = readUgcWire(input.planWire, NEEDS_PLAN)\n if (\"error\" in plan) return plan\n const creator = readUgcWire(input.creatorWire, UGC_CREATOR_MISSING_MESSAGE)\n if (\"error\" in creator) return creator\n const voiceId = filled(input.voiceId)\n return {\n body: {\n plan: plan.value,\n gender: creator.value.gender,\n traits: creator.value.traits ?? null,\n identityImages: creator.value.identityImages,\n surface: \"canvas\",\n ...(voiceId ? { voiceId } : {}),\n },\n }\n}\n\n/**\n * The `/v1/ugc/clips` answer → the tickets (one per clip, as JSON strings), `clips` (the\n * first), `plan-out` (`{ v: 1, plan, transcribeArgs }` for UGC Cards), `transcript`, whether\n * the plan has cards, and whether the clips go through UGC Finish's job (`finishes`: the plan-out\n * carries a finish call, which is what UGC Finish reads to run it). An answer with errors → \"The script needs changes: …\" with each\n * error and its fix; an answer without the parts UGC Cards needs fails here, before any clip\n * is paid for.\n */\nexport function ugcClipsOutputs(answer: Record<string, unknown>): { outputs: UgcOutputs; tickets: string[]; hasCards: boolean; finishes: boolean } | { error: string } {\n const errors = Array.isArray(answer.errors) ? answer.errors : []\n if (errors.length > 0) {\n const said = errors.flatMap((e) => (isObject(e) ? [filled(e.message), filled(e.fix)] : [])).filter((s): s is string => s !== undefined)\n return { error: said.length > 0 ? `${UGC_SCRIPT_NEEDS_CHANGES} ${said.join(\" \")}` : UGC_NEWER_APP_MESSAGE }\n }\n const { tickets, sizedPlan, transcript, speechCheckCall } = answer\n if (!Array.isArray(tickets) || tickets.length === 0 || !tickets.every(isObject) || !isObject(sizedPlan) || typeof transcript !== \"string\") {\n return { error: UGC_NEWER_APP_MESSAGE }\n }\n const wires = tickets.map((t) => JSON.stringify(t))\n // The speech check's arguments ride to UGC Cards' transcription unread (an answer without them: none).\n const transcribeArgs = isObject(speechCheckCall) && isObject(speechCheckCall.args) ? speechCheckCall.args : {}\n // A video cut from one recorded speech (the segmented lane) also hands UGC Finish its finish call's\n // arguments (the segments with their room), opaque; any other answer's plan-out is unchanged.\n const finish = isObject(answer.finish) && isObject(answer.finish.args) ? { finish: answer.finish.args } : {}\n return {\n outputs: { clips: wires[0]!, \"plan-out\": JSON.stringify({ v: 1, plan: sizedPlan, transcribeArgs, ...finish }), transcript },\n tickets: wires,\n hasCards: answer.hasCards === true,\n finishes: \"finish\" in finish,\n }\n}\n\n// ── UGC Clip ─────────────────────────────────────────────────────────────────\n\n/**\n * The `/v1/ugc/clip` body for one ticket: the ticket, `nonce` = how many times this clip was\n * re-rendered (`rerender[\"<clip number>\"]`, else 0) and `runKey` when one is given.\n */\nexport function ugcClipBody(input: { ticketWire: unknown; rerender?: Readonly<Record<string, number>>; runKey?: string }):\n { body: Record<string, unknown>; clipNumber: number; durationSec: number } | { error: string } {\n const read = readUgcWire(input.ticketWire, NEEDS_TICKET)\n if (\"error\" in read) return read\n const ticket = read.value\n const { index, durationSec } = ticket\n if (typeof index !== \"number\" || !Number.isInteger(index) || index < 0) return { error: NEEDS_TICKET }\n if (typeof durationSec !== \"number\" || !Number.isFinite(durationSec) || durationSec <= 0) return { error: NEEDS_TICKET }\n const clipNumber = index + 1\n const count = input.rerender?.[String(clipNumber)]\n const nonce = typeof count === \"number\" && Number.isInteger(count) && count >= 0 ? count : 0\n const runKey = filled(input.runKey)\n return { body: { ticket, nonce, ...(runKey ? { runKey } : {}) }, clipNumber, durationSec }\n}\n\n/**\n * A finished UGC Clip job (`{ videoUrl, durationSec, clipWarnings, … }`) → `video-out`, the\n * clip's real length (null when unknown) and its warnings ([] when it has none).\n */\nexport function ugcClipOutputs(outputData: Record<string, unknown>): { outputs: UgcOutputs; videoUrl: string; durationSec: number | null; clipWarnings: string[] } {\n const videoUrl = filled(outputData.videoUrl) ?? \"\"\n const meta = fanOutItemMeta(outputData)\n return { outputs: videoUrl ? { \"video-out\": videoUrl } : {}, videoUrl, durationSec: meta.durationSec, clipWarnings: [...meta.warnings] }\n}\n\n/**\n * What a list read (a Bundle edge, a fold) takes from a UGC Clip's saved data, on both engines:\n * its last fanned-out batch — one take per clip, in clip order — when its last run was one; else\n * exactly the take it shows (its active result, else its video). Never the earlier takes it keeps:\n * a video of one clip (one ticket, so no fan-out) would join every take. A single run clears the\n * batch (the editor's job patch), so a batch held is always the last run's. Undefined when it holds\n * no take at all.\n */\nexport function ugcClipSavedList(data: unknown): string[] | undefined {\n if (!isObject(data)) return undefined\n const batch = Array.isArray(data.__listResults) ? data.__listResults.filter((u): u is string => typeof u === \"string\" && u !== \"\") : []\n if (batch.length > 0) return batch\n const results = Array.isArray(data.generatedResults) ? data.generatedResults : []\n const index = typeof data.activeResultIndex === \"number\" && Number.isInteger(data.activeResultIndex) ? data.activeResultIndex : 0\n const active = results[index]\n const url = (isObject(active) ? filled(active.url) : undefined) ?? filled(data.generatedVideoUrl)\n return url ? [url] : undefined\n}\n\n// ── UGC Cards ────────────────────────────────────────────────────────────────\n\n/**\n * UGC Cards' two timing jobs on the joined video, and the plan they time. The plan input must\n * be UGC Clips' `{ v: 1, plan, transcribeArgs }`; anything else is refused before either job.\n * The transcription spreads `transcribeArgs` unread, then sets the node's own fields last, so\n * the wire can add a language but never change the provider or the word timings.\n */\nexport function ugcCardsJobs(input: { planOutWire: unknown; videoUrl?: string; transcript?: string }): {\n alignment: { path: \"/v1/forced-alignment\"; body: Record<string, unknown> }\n transcribe: { path: \"/v1/transcribe\"; body: Record<string, unknown> }\n plan: Record<string, unknown>\n} | { error: string } {\n const read = readUgcWire(input.planOutWire, NEEDS_PLAN_OUT)\n if (\"error\" in read) return read\n const { plan, transcribeArgs } = read.value\n if (!isObject(plan) || !isObject(transcribeArgs)) return { error: NEEDS_PLAN_OUT }\n const videoUrl = filled(input.videoUrl)\n if (!videoUrl) return { error: NEEDS_VIDEO }\n // An empty transcript is what UGC Clips said, not a missing input: it goes on as it came.\n const transcript = input.transcript\n if (typeof transcript !== \"string\") return { error: NEEDS_TRANSCRIPT }\n return {\n alignment: { path: \"/v1/forced-alignment\", body: { audioUrl: videoUrl, transcript } },\n transcribe: { path: \"/v1/transcribe\", body: { ...transcribeArgs, audioUrl: videoUrl, provider: DEFAULT_TRANSCRIBE_NODE_PROVIDER, wordTimestamps: true } },\n plan,\n }\n}\n\n/**\n * The `/v1/ugc/cards` canvas body: the plan, the video, whichever timing came back as a list,\n * the timing jobs that failed, and the clips' notes.\n */\nexport function ugcCardsBody(input: {\n plan: Record<string, unknown>\n videoUrl: string\n alignment?: unknown\n words?: unknown\n failed: ReadonlyArray<\"alignment\" | \"words\">\n clipNotes: ReadonlyArray<ClipNote>\n}): Record<string, unknown> {\n return {\n surface: \"canvas\",\n plan: input.plan,\n videoUrl: input.videoUrl,\n ...(Array.isArray(input.alignment) ? { alignment: input.alignment } : {}),\n ...(Array.isArray(input.words) ? { words: input.words } : {}),\n failed: [...input.failed],\n clipNotes: [...input.clipNotes],\n }\n}\n\n/** The caption plan when nothing could be timed: Add Captions renders no captions from it. */\nconst EMPTY_CAPTION_PLAN: CaptionPlan = { v: 1, hookText: \"\", hookEndMs: 0, bodyEndMs: 0, captions: [] }\n\n/** The `/v1/ugc/cards` answer → `layerPlan`, `captionPlan` (v1; the empty plan when untimed) and `report` (one line per sentence). */\nexport function ugcCardsOutputs(answer: Record<string, unknown>): UgcOutputs {\n const timing = answer.captionTiming\n const report = answer.report\n const lines = isObject(report) && Array.isArray(report.lines) ? report.lines.filter((l): l is string => typeof l === \"string\") : []\n return {\n layerPlan: JSON.stringify(Array.isArray(answer.layerPlan) ? answer.layerPlan : []),\n captionPlan: JSON.stringify(isObject(timing) ? { v: 1, ...timing } : EMPTY_CAPTION_PLAN),\n report: lines.join(\"\\n\"),\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/fan-out-meta.ts","../src/ugc-run-state.ts","../src/ugc-node-wires.ts"],"names":["DEFAULT_TRANSCRIBE_NODE_PROVIDER"],"mappings":";;;;;AAKO,SAAS,eAAe,MAA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A,IACL,SAAA,EAAW,IAAA,CAAK,SAAA,CAAU,KAAA,CAAM,OAAA,CAAQ,MAAA,CAAO,SAAS,CAAA,GAAI,MAAA,CAAO,SAAA,GAAY,EAAE,CAAA;AAAA,IACjF,WAAA,EAAa,IAAA,CAAK,SAAA,CAAU,QAAA,CAAS,MAAM,CAAA,GAAI,EAAE,CAAA,EAAG,CAAA,EAAG,GAAG,MAAA,EAAO,GAAI,kBAAkB,CAAA;AAAA,IACvF,MAAA,EAAQ,KAAA,CAAM,IAAA,CAAK,IAAI;AAAA,GACzB;AACF","file":"chunk-5HK5Z5OB.cjs","sourcesContent":["/** One fan-out item's notes: its warnings and its real length (UGC Clip). */\nexport interface FanOutItemMeta { readonly warnings: readonly string[]; readonly durationSec: number | null }\n/** One row of UGC Cards' `notes` input. */\nexport interface ClipNote { readonly clip: number; readonly warnings: readonly string[]; readonly durationSec?: number }\n\nexport function fanOutItemMeta(output: { clipWarnings?: unknown; durationSec?: unknown } | null | undefined): FanOutItemMeta {\n const w = output?.clipWarnings\n const d = output?.durationSec\n return {\n warnings: Array.isArray(w) ? w.filter((x): x is string => typeof x === \"string\") : [],\n durationSec: typeof d === \"number\" && Number.isFinite(d) && d > 0 ? d : null,\n }\n}\n\n/** Row-aligned meta (or one single output) → the notes UGC Cards reads, clip numbers from 1. */\nexport function clipNotesFrom(meta: ReadonlyArray<FanOutItemMeta | null | undefined> | undefined, single?: FanOutItemMeta): ClipNote[] {\n const rows = meta && meta.length > 0 ? meta : single ? [single] : []\n return rows.map((m, i) => ({\n clip: i + 1,\n warnings: m?.warnings ?? [],\n ...(typeof m?.durationSec === \"number\" ? { durationSec: m.durationSec } : {}),\n }))\n}\n","/** The UGC node types (Cloud only; served by a private plugin). */\nexport const UGC_NODE_TYPES: ReadonlySet<string> = new Set([\"ugc-creator\", \"ugc-script\", \"ugc-clips\", \"ugc-clip\", \"ugc-cards\", \"ugc-finish-clips\"])\n\n/** UGC Creator: the node-data key that holds a round's passing candidates until the person picks one (run state). */\nexport const UGC_CREATOR_CANDIDATES_KEY = \"candidates\"\n\n/** A run that would execute a UGC Creator whose options wait for the person's pick. */\nexport const UGC_PICK_FIRST_MESSAGE = \"Pick a creator first.\"\n\n/**\n * Per UGC type, the node-data keys that are a RUN's state, never a choice. A\n * published app's snapshot is readable by every runner, so publishing strips\n * them (the last plan, the clip tickets, the publisher's kept creator).\n *\n * UGC Creator's image (`generatedImageUrl`) goes from every creator, whatever its\n * source: after a My photo run it IS the author's photo, and a creator switched\n * to another source after such a run, or whose photo was removed, still holds it.\n * UGC Clip's takes and UGC Cards' Notes (`generatedText`, and `text`, the Notes\n * as a run hands them on) are the author's renders: a published node starts empty.\n *\n * A published snapshot is stripped through `stripUgcPublishState`\n * (@nodaro/render-rules), which also empties every run result a lane writes under\n * a generic name, every node made from the UGC video, and every node on a path\n * into a UGC Creator's photo input.\n */\nexport const UGC_NODE_RUN_STATE_KEYS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"result\", \"keepResult\", \"ugcOutputs\", UGC_CREATOR_CANDIDATES_KEY, \"optionFailed\", \"generatedImageUrl\"],\n // `exampleLines`: a template's example run, shown until the node's own first script (display only).\n \"ugc-script\": [\"result\", \"keepResult\", \"ugcOutputs\", \"exampleLines\"],\n \"ugc-clips\": [\"result\", \"quote\", \"__listResults\", \"ugcOutputs\"],\n \"ugc-clip\": [\n \"warnings\", \"rerender\", \"rerenderPending\", \"__listResults\", \"__listResultMeta\", \"clipWarnings\", \"durationSec\", \"ugcOutputs\",\n \"generatedVideoUrl\", \"generatedResults\", \"activeResultIndex\",\n ],\n \"ugc-cards\": [\"result\", \"ugcOutputs\", \"generatedText\", \"text\"],\n \"ugc-finish-clips\": [\"ugcOutputs\", \"__listResults\", \"__listResultMeta\", \"generatedVideoUrl\", \"generatedResults\", \"activeResultIndex\"],\n}\n\n/**\n * The ONLY UGC keys a run request's `inputOverrides` may set — an allow-list,\n * so a run-state field added later is locked without anyone listing it.\n *\n * No UGC type may gain a `LEGACY_EXPOSED_FIELD_KEYS` row: the lock reads the\n * stored key, before that table renames it.\n */\nexport const UGC_OVERRIDABLE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"source\", \"gender\", \"photoUrl\"],\n \"ugc-script\": [\"targetDurationSec\", \"language\"],\n \"ugc-clips\": [],\n \"ugc-clip\": [],\n \"ugc-cards\": [],\n \"ugc-finish-clips\": [],\n}\n\nconst KEEP_RESULT_TYPES: ReadonlySet<string> = new Set([\"ugc-creator\", \"ugc-script\"])\n\n/** UGC Creator holds options for the person to pick: the ones a run drew, or the ones a credits stop kept. */\nexport function ugcPickPending(data: unknown): boolean {\n const candidates = data && typeof data === \"object\" ? (data as Record<string, unknown>)[UGC_CREATOR_CANDIDATES_KEY] : undefined\n return Array.isArray(candidates) && candidates.length > 0\n}\n\n/**\n * A run that would execute a UGC Creator whose options wait is refused (\"Pick a creator first.\"),\n * except that creator's own re-draw. One rule for the editor's check before a run and the\n * orchestrator's.\n */\nexport function ugcRunWaitsForPick(\n runNodes: ReadonlyArray<{ readonly id: string; readonly type?: string | null; readonly data?: unknown }>,\n opts: { readonly redrawId?: string } = {},\n): boolean {\n return runNodes.some((n) => n.type === \"ugc-creator\" && n.id !== opts.redrawId && ugcPickPending(n.data))\n}\n\n/**\n * Per UGC type, the author's own content a published snapshot never carries: UGC Creator's photo\n * of a person (`photoUrl`). A choice, not run state — so it stays on the author's own workflow —\n * but a runner gives their own photo (or the run is refused for want of one) and a template's\n * cloner adds theirs.\n */\nexport const UGC_PUBLISH_PRIVATE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"photoUrl\"],\n}\n\n/**\n * The UGC types' own strip: a copy of `nodes` with every UGC node's run state and the author's own\n * photo removed (and `keepResult: false`). Other nodes are returned as they are. Publishing, a\n * share link's view and a viewer's run go through `stripUgcPublishState` (@nodaro/render-rules),\n * which starts here.\n */\nexport function stripUgcRunState<T extends { type?: unknown; data?: unknown }>(nodes: readonly T[]): T[] {\n return nodes.map((node) => {\n const type = typeof node.type === \"string\" ? node.type : \"\"\n if (!UGC_NODE_TYPES.has(type) || !node.data || typeof node.data !== \"object\") return node\n const data: Record<string, unknown> = { ...(node.data as Record<string, unknown>) }\n for (const key of UGC_NODE_RUN_STATE_KEYS[type] ?? []) delete data[key]\n for (const key of UGC_PUBLISH_PRIVATE_FIELDS[type] ?? []) delete data[key]\n if (KEEP_RESULT_TYPES.has(type)) data.keepResult = false\n return { ...node, data }\n })\n}\n\n/** Every override entry that would set a non-overridable key on a UGC node, in node then key order. Pure. */\nexport function findUgcLockedFields(\n nodes: ReadonlyArray<{ id: string; type?: string }> | null | undefined,\n inputOverrides: Record<string, Record<string, unknown>> | null | undefined,\n): Array<{ nodeId: string; nodeType: string; field: string }> {\n if (!nodes || !inputOverrides) return []\n const found: Array<{ nodeId: string; nodeType: string; field: string }> = []\n for (const node of nodes) {\n const type = node?.type\n if (typeof type !== \"string\" || !UGC_NODE_TYPES.has(type)) continue\n const allowed = UGC_OVERRIDABLE_FIELDS[type] ?? []\n const fields = inputOverrides[node.id]\n if (!fields || typeof fields !== \"object\") continue\n for (const field of Object.keys(fields)) {\n if (!allowed.includes(field)) found.push({ nodeId: String(node.id), nodeType: type, field })\n }\n }\n return found\n}\n","/**\n * The UGC node wires: every request body the five UGC nodes send and every\n * output they hand on, as ONE pure implementation that both engines (the\n * workflow orchestrator and the editor) call, so the two can never disagree.\n *\n * Content-free. A creator record is read only for `v`, `gender` and\n * `identityImages`, a plan only for `v`, a clip ticket only for `v`, `index`\n * and `durationSec`; every other key is opaque and passes through as it came.\n * Every UGC-private JSON a node emits carries `v: 1`, and a wire with another\n * `v` is refused, never guessed at.\n */\nimport type { CaptionPlan } from \"./caption-plan.js\"\nimport { fanOutItemMeta, type ClipNote } from \"./fan-out-meta.js\"\nimport { DEFAULT_TRANSCRIBE_NODE_PROVIDER } from \"./model-constants.js\"\nimport { ugcPickPending } from \"./ugc-run-state.js\"\n\n/** A UGC call that reached a deployment without the UGC routes (the router's 404). */\nexport const UGC_NOT_SERVED_MESSAGE = \"UGC videos are a Nodaro Cloud feature and are not served on this deployment.\"\n/** A wire whose `v` this app does not read. */\nexport const UGC_VERSION_MESSAGE = \"This workflow was made with a newer version of the UGC nodes.\"\n/** An answer this app cannot run: a tool it does not know, or a shape it cannot read. */\nexport const UGC_NEWER_APP_MESSAGE = \"This step needs a newer app version.\"\n/** A creator pick whose options are gone (another run replaced them, or they were never this node's). */\nexport const UGC_PICK_GONE_MESSAGE = \"These creator options are no longer available. Run UGC Creator again.\"\n/** UGC Clips with no creator on its creator input (UGC Creator has not run, or waits for a pick). */\nexport const UGC_CREATOR_MISSING_MESSAGE = \"UGC Creator has no creator yet. Run it, or pick one of its options.\"\n/** UGC Script's target length in seconds when the node holds none: the node's default (the route requires a length). */\nexport const UGC_SCRIPT_DEFAULT_TARGET_SEC = 15\n/** The range of a UGC script's length, in whole seconds: the script route's, and a plan's own. */\nexport const UGC_SCRIPT_MIN_TARGET_SEC = 4\nexport const UGC_SCRIPT_MAX_TARGET_SEC = 300\n\nconst MINOR_AGE_MESSAGE = \"That age can't be used: UGC creators are adults only.\"\nconst NEEDS_GENDER = \"Choose woman or man.\"\nconst NEEDS_PHOTO = \"Connect or upload a photo of yourself.\"\nconst NEEDS_CATEGORY = \"Run UGC Script first, or pick a product category.\"\nconst NEEDS_SITE = \"Add the product name or website.\"\n/** The opening of the sentence UGC Clips fails with when the plugin refuses the script: \"<this> <each error and its fix>\". */\nexport const UGC_SCRIPT_NEEDS_CHANGES = \"The script needs changes:\"\nconst NEEDS_PLAN_OUT = \"Connect the Script (sized) output of UGC Clips.\"\nconst NEEDS_PLAN = \"Connect the Script output of UGC Script.\"\nconst NEEDS_TICKET = \"Connect the Clips output of UGC Clips.\"\nconst NEEDS_VIDEO = \"Connect the joined video.\"\nconst NEEDS_TRANSCRIPT = \"Connect the Transcript output of UGC Clips.\"\n/**\n * A run of a video whose clips are cut from one recorded speech, on a graph with no UGC Finish on this UGC\n * Clips' Script (sized) output: refused before anything is spent.\n */\nexport const UGC_NEEDS_FINISH_MESSAGE = \"Add a UGC Finish node after UGC Clip, and connect UGC Clips' Script (sized) output to it.\"\n/** UGC Finish with nothing on its clips input. */\nexport const UGC_FINISH_NEEDS_CLIPS_MESSAGE = \"Connect the Video output of UGC Clip.\"\n/** UGC Finish's job answered that a clip does not follow its speech (each clip checks itself first, so this is rare). */\nexport const UGC_FINISH_NOT_READY_MESSAGE = \"A clip did not follow its speech. Re-render it from the UGC Clip node and run again.\"\n/**\n * A video cut from one recorded speech whose clips, priced once the speech is split, would hold more\n * than the run was checked for before it started: the run stops at UGC Clips, before any clip renders.\n */\nexport const UGC_OVER_HOLD_MESSAGE =\n \"The clips for this recording would cost more than this run was checked for, so none was rendered. Run UGC Clips again to record the speech again.\"\n\n/**\n * Every fixed sentence a UGC node fails with, by id: the English both engines write on the node.\n * The editor shows each in the person's language by its id. Not listed: the sentence that opens\n * with `UGC_SCRIPT_NEEDS_CHANGES` (the plugin's own words finish it), a route's own message, and\n * \"UGC step failed (<status>)\".\n */\nexport const UGC_NODE_MESSAGES = Object.freeze({\n notServed: UGC_NOT_SERVED_MESSAGE,\n version: UGC_VERSION_MESSAGE,\n newerApp: UGC_NEWER_APP_MESSAGE,\n pickGone: UGC_PICK_GONE_MESSAGE,\n creatorMissing: UGC_CREATOR_MISSING_MESSAGE,\n minorAge: MINOR_AGE_MESSAGE,\n needsGender: NEEDS_GENDER,\n needsPhoto: NEEDS_PHOTO,\n needsCategory: NEEDS_CATEGORY,\n needsSite: NEEDS_SITE,\n needsPlanOut: NEEDS_PLAN_OUT,\n needsPlan: NEEDS_PLAN,\n needsTicket: NEEDS_TICKET,\n needsVideo: NEEDS_VIDEO,\n needsTranscript: NEEDS_TRANSCRIPT,\n needsFinish: UGC_NEEDS_FINISH_MESSAGE,\n finishNeedsClips: UGC_FINISH_NEEDS_CLIPS_MESSAGE,\n finishNotReady: UGC_FINISH_NOT_READY_MESSAGE,\n overHold: UGC_OVER_HOLD_MESSAGE,\n} as const)\n\n/** The id of a fixed sentence a UGC node fails with (`UGC_NODE_MESSAGES`). */\nexport type UgcNodeMessageId = keyof typeof UGC_NODE_MESSAGES\n\n/** UGC Script's screenshot inputs, in card order. */\nexport const UGC_SCREENSHOT_HANDLES: readonly string[] = [\n \"screenshot\", \"screenshot2\", \"screenshot3\", \"screenshot4\", \"screenshot5\", \"screenshot6\", \"screenshot7\", \"screenshot8\",\n]\n\n/** Per UGC type, the output an edge with no source handle reads. */\nexport const UGC_PRIMARY_HANDLE: Readonly<Record<string, string>> = {\n \"ugc-creator\": \"creator\",\n \"ugc-script\": \"plan\",\n \"ugc-clips\": \"clips\",\n \"ugc-clip\": \"video-out\",\n \"ugc-cards\": \"layerPlan\",\n \"ugc-finish-clips\": \"video-out\",\n}\n\n/** A UGC node's outputs: handle id → the value that handle carries (a JSON string, text or a URL). */\nexport type UgcOutputs = Readonly<Record<string, string>>\n\ntype Obj = Record<string, unknown>\nconst isObject = (x: unknown): x is Obj => !!x && typeof x === \"object\" && !Array.isArray(x)\n\n/**\n * The length a saved UGC plan was written to: its own `targetDurationSec`, a whole number of\n * seconds in the script's range. Besides the lines (the opening line, each beat's line, the\n * closing line), one of the two keys of a plan the app reads (the other: whether each beat carries\n * a screenshot, `ugcPlanScreenshotCount`): a script that hands on its saved plan is priced at the\n * plan's length, and shows it, never at the length setting, which may have changed since. Takes\n * the plan or its wire (a JSON string); undefined for anything that is not a plan carrying a length.\n */\nexport function ugcPlanLengthSec(plan: unknown): number | undefined {\n const value = savedPlanOf(plan)\n if (!value) return undefined\n const sec = value.targetDurationSec\n return typeof sec === \"number\" && Number.isInteger(sec) && sec >= UGC_SCRIPT_MIN_TARGET_SEC && sec <= UGC_SCRIPT_MAX_TARGET_SEC ? sec : undefined\n}\n\n/**\n * How many of a saved UGC plan's beats carry a screenshot: the screenshot cards the plan was\n * written with. Read beat by beat: a beat carries one when its `screenshot` is an object, as the\n * plan's own screenshots are (whatever it names); a beat that is not an object, or whose screenshot\n * is anything else, carries none — and never makes the rest unreadable. A plan whose beats carry\n * none is a talking-head plan (0). Read, like its length, so a script that hands on its saved plan\n * is priced at the screenshots that plan holds, never at the script's wires, which may have changed\n * since. Takes the plan or its wire (a JSON string); undefined only for a plan with no beats to read\n * and for anything that is not a plan.\n */\nexport function ugcPlanScreenshotCount(plan: unknown): number | undefined {\n const value = savedPlanOf(plan)\n if (!value || !Array.isArray(value.beats)) return undefined\n return value.beats.filter((beat) => isObject(beat) && isObject(beat.screenshot)).length\n}\n\n/** A saved plan, or its wire (a JSON string), as an object; undefined for anything else. */\nfunction savedPlanOf(plan: unknown): Obj | undefined {\n let value: unknown = plan\n if (typeof value === \"string\") {\n try {\n value = JSON.parse(value)\n } catch {\n return undefined\n }\n }\n return isObject(value) ? value : undefined\n}\n/** A string with something in it; an empty or blank field or input counts as absent. */\nconst filled = (x: unknown): string | undefined => (typeof x === \"string\" && x.trim() !== \"\" ? x : undefined)\n\n/**\n * What an edge from a UGC node reads, on both engines: the value of the pip it leaves — an edge\n * with no source handle reads the node's primary output — from the node's outputs by pip. Only a\n * pip the outputs hold as a string (\"\" included: an empty transcript is a value); an inherited\n * key or a non-string is no value.\n */\nexport function ugcPipValue(outputs: unknown, sourceType: string, sourceHandle?: string | null): string | undefined {\n const pip = sourceHandle || (Object.hasOwn(UGC_PRIMARY_HANDLE, sourceType) ? UGC_PRIMARY_HANDLE[sourceType] : undefined)\n if (pip === undefined || !isObject(outputs) || !Object.hasOwn(outputs, pip)) return undefined\n const value = outputs[pip]\n return typeof value === \"string\" ? value : undefined\n}\n\n/**\n * A UGC wire (a JSON string or an object) → its value when it is an object with `v: 1`.\n * Another `v` → the version message. Anything that is not a UGC wire at all (nothing\n * connected, not JSON, no `v`) → `unreadable`, which a node words as the input it needs.\n */\nexport function readUgcWire(raw: unknown, unreadable: string = UGC_VERSION_MESSAGE): { value: Record<string, unknown> } | { error: string } {\n let parsed: unknown = raw\n if (typeof raw === \"string\") {\n try {\n parsed = JSON.parse(raw)\n } catch {\n return { error: unreadable }\n }\n }\n if (!isObject(parsed) || parsed.v === undefined) return { error: unreadable }\n if (parsed.v !== 1) return { error: UGC_VERSION_MESSAGE }\n return { value: parsed }\n}\n\n/** The route's `{ error: { code, message } }` (or a framework error's top-level `message`). */\nfunction routeErrorOf(body: string): { code?: string; message?: string } {\n let parsed: unknown\n try {\n parsed = JSON.parse(body)\n } catch {\n return {}\n }\n if (!isObject(parsed)) return {}\n if (isObject(parsed.error)) {\n const { code, message } = parsed.error\n return { code: typeof code === \"string\" ? code : undefined, message: filled(message) }\n }\n return { message: filled(parsed.message) }\n}\n\n/**\n * A failed UGC call → the sentence the node fails with. A 404 that names no error code is\n * the router's (the route is not registered here) → the Cloud sentence; a route's own 404\n * names a code and keeps its message. `minor_age_refused` → the adults-only sentence. A 4xx\n * or 503 → the route's message. Anything else → \"UGC step failed (<status>)\".\n */\nexport function ugcFailure(status: number, body: string): string {\n const error = routeErrorOf(body)\n if (status === 404 && error.code === undefined) return UGC_NOT_SERVED_MESSAGE\n if (error.code === \"minor_age_refused\") return MINOR_AGE_MESSAGE\n if ((status === 503 || (status >= 400 && status < 500)) && error.message) return error.message\n return `UGC step failed (${status})`\n}\n\n// ── UGC Creator ──────────────────────────────────────────────────────────────\n\n/**\n * The pickers whose own set fields shape a sampled creator: the picker types UGC Creator's\n * `pickers` input takes (the route takes no other). One list for the editor's connection rule\n * and both engines' input resolvers.\n */\nexport const UGC_CREATOR_PICKER_TYPES: ReadonlySet<string> = new Set([\"person\", \"styling\", \"setting\", \"lighting\"])\n\n/** The UGC Creator node-data keys its request body reads. */\nexport interface UgcCreatorFields {\n readonly source?: string\n readonly gender?: string\n readonly photoUrl?: string\n readonly categoryOverride?: string\n readonly seed?: number\n readonly keepResult?: boolean\n readonly result?: Readonly<Record<string, unknown>>\n /** The options a draw left waiting for the pick (run state): read only for `previous`. */\n readonly candidates?: unknown\n}\n\n/** The traits of the latest creator the person saw: the first waiting option's, else the last result's (Keep off). */\nfunction previousTraits(data: UgcCreatorFields): unknown {\n if (ugcPickPending(data)) {\n const first: unknown = (data.candidates as readonly unknown[])[0]\n const record = isObject(first) ? first.record : undefined\n return isObject(record) ? record.traits : undefined\n }\n return !data.keepResult && isObject(data.result) ? data.result.traits : undefined\n}\n\n/** The wired pickers that set a field (their own fields, as the resolver read them); undefined when none did. */\nfunction setPickers(pickers: Record<string, Record<string, unknown>> | undefined): Record<string, Record<string, unknown>> | undefined {\n if (!pickers) return undefined\n const set = Object.entries(pickers).filter(([, fields]) => isObject(fields) && Object.keys(fields).length > 0)\n return set.length > 0 ? Object.fromEntries(set) : undefined\n}\n\n/**\n * The `/v1/ugc/creator` body. A photo: the wired photo, else the node's own. A sampled\n * creator: the product category (the node's override, else the wired one), the pickers that\n * set a field, the node's seed, and the traits of the latest creator the person saw as\n * `previous`, so the next one differs: the first option waiting for the pick, else — on a\n * re-run that does not keep the result — the last creator's. Refuses before any call.\n */\nexport function ugcCreatorBody(input: {\n data: UgcCreatorFields\n photoUrl?: string\n category?: string\n pickers?: Record<string, Record<string, unknown>>\n}): { body: Record<string, unknown> } | { error: string } {\n const { data } = input\n const gender = data.gender\n if (gender !== \"woman\" && gender !== \"man\") return { error: NEEDS_GENDER }\n if (data.source === \"photo\") {\n const imageUrl = filled(input.photoUrl) ?? filled(data.photoUrl)\n if (!imageUrl) return { error: NEEDS_PHOTO }\n return { body: { source: { kind: \"photo\", imageUrl, gender } } }\n }\n const productCategory = filled(data.categoryOverride) ?? filled(input.category)\n if (!productCategory) return { error: NEEDS_CATEGORY }\n const pickers = setPickers(input.pickers)\n const traits = previousTraits(data)\n return {\n body: {\n ...(typeof data.seed === \"number\" ? { seed: data.seed } : {}),\n source: {\n kind: \"sampled\",\n gender,\n productCategory,\n ...(pickers ? { pickers } : {}),\n ...(isObject(traits) ? { previous: traits } : {}),\n },\n },\n }\n}\n\n/**\n * The creator the node hands on: the record (`creator`, v1) and its first image (`image`).\n * `identityImages` are the images of the candidate the node hands on — the picked one where\n * a person picked. The record copies the listed fields only, so `candidates`, `fallback`,\n * `pick` and `image` never reach the `creator` wire.\n */\nexport function ugcCreatorOutputs(answer: Record<string, unknown>, identityImages: readonly string[]): { outputs: UgcOutputs; imageUrl: string; record: Record<string, unknown> } {\n const record: Record<string, unknown> = {\n v: 1,\n kind: answer.kind,\n gender: answer.gender,\n identityImages: [...identityImages],\n traits: answer.traits ?? null,\n seed: answer.seed ?? null,\n promptsVersion: answer.promptsVersion,\n productCategory: answer.productCategory ?? null,\n }\n const imageUrl = identityImages[0] ?? \"\"\n return { outputs: { creator: JSON.stringify(record), ...(imageUrl ? { image: imageUrl } : {}) }, imageUrl, record }\n}\n\n/** One builder call as the app runs it: `tool` and `args`, nothing else (a candidate's other keys, its model included, are never read). */\nexport interface UgcCreatorCall { readonly tool: string; readonly args: Readonly<Record<string, unknown>> }\n\n/** What a creator answer asks the node to render. */\nexport interface UgcCreatorCandidateCalls {\n /** Every candidate's image call, the primary first. One call (`image`) for an answer from before candidates; none for a photo. */\n readonly calls: readonly UgcCreatorCall[]\n /** The round's one moderation fallback: it runs once, and only when every candidate the run rendered was blocked. */\n readonly fallback: UgcCreatorCall | null\n /** \"user\": a person picks among `calls` where one can be asked; \"primary\": `calls[0]` alone; null: nothing to render (a photo). */\n readonly pick: \"user\" | \"primary\" | null\n}\n\nconst callOf = (raw: unknown): UgcCreatorCall | undefined => {\n if (!raw || typeof raw !== \"object\") return undefined\n const { tool, args } = raw as { tool?: unknown; args?: unknown }\n if (typeof tool !== \"string\" || !args || typeof args !== \"object\" || Array.isArray(args)) return undefined\n return { tool, args: args as Readonly<Record<string, unknown>> }\n}\nconst fallbackOf = (image: unknown): unknown => (image && typeof image === \"object\" ? (image as { fallback?: unknown }).fallback : undefined)\n\n/**\n * A `/v1/ugc/creator` answer's image calls. Content-free: reads `image` (`tool`, `args`,\n * `fallback`), `candidates[].tool|args`, `fallback` and `pick.how` — never a candidate's\n * model. An answer without `candidates` (an older builder) renders `image` alone, as before.\n */\nexport function ugcCreatorCandidates(answer: Readonly<Record<string, unknown>>): UgcCreatorCandidateCalls | { readonly error: string } {\n const listed = answer.candidates\n const noList = listed === undefined || listed === null || (Array.isArray(listed) && listed.length === 0)\n const noImage = answer.image === undefined || answer.image === null\n if (noList && noImage) return { calls: [], fallback: null, pick: null }\n if (noList) {\n const image = callOf(answer.image)\n if (!image) return { error: UGC_NEWER_APP_MESSAGE }\n return { calls: [image], fallback: callOf(fallbackOf(answer.image)) ?? null, pick: \"primary\" }\n }\n if (!Array.isArray(listed)) return { error: UGC_NEWER_APP_MESSAGE }\n const calls = listed.map(callOf)\n if (calls.some((c) => c === undefined)) return { error: UGC_NEWER_APP_MESSAGE }\n const how = (answer.pick as { how?: unknown } | null | undefined)?.how\n return {\n calls: calls as UgcCreatorCall[],\n fallback: callOf(answer.fallback) ?? callOf(fallbackOf(answer.image)) ?? null,\n pick: how === \"user\" && calls.length > 1 ? \"user\" : \"primary\",\n }\n}\n\n/** The calls a run renders: every candidate where a person is there to pick, else the primary alone. */\nexport function ugcCreatorCallsToRender(c: UgcCreatorCandidateCalls, opts: { readonly personPicks: boolean }): readonly UgcCreatorCall[] {\n return opts.personPicks && c.pick === \"user\" ? c.calls : c.calls.slice(0, 1)\n}\n\n/** One rendered candidate that passed its checks, kept on the node until the person picks (run state, never a wire). */\nexport interface UgcCreatorCandidate { readonly imageUrl: string; readonly record: Readonly<Record<string, unknown>> }\n\nexport function ugcCreatorCandidate(answer: Readonly<Record<string, unknown>>, images: readonly string[]): UgcCreatorCandidate {\n const out = ugcCreatorOutputs(answer as Record<string, unknown>, images)\n return { imageUrl: out.imageUrl, record: out.record }\n}\n\n/** A UGC Creator run output that waits for the person's pick: two or more options (`ugcCandidates`). */\nexport function ugcAwaitsPick(output: unknown): boolean {\n const candidates = isObject(output) ? output.ugcCandidates : undefined\n return Array.isArray(candidates) && candidates.length >= 2\n}\n\n/** The person's pick, read back from node data (untrusted): a stale index, a foreign list or another version is refused. */\nexport function ugcCreatorPick(candidates: unknown, index: number):\n { readonly result: Readonly<Record<string, unknown>>; readonly outputs: UgcOutputs; readonly imageUrl: string } | { readonly error: string } {\n const entry: unknown = Array.isArray(candidates) && Number.isInteger(index) && index >= 0 ? candidates[index] : undefined\n const imageUrl = (entry as { imageUrl?: unknown } | undefined)?.imageUrl\n const record = (entry as { record?: unknown } | undefined)?.record\n if (typeof imageUrl !== \"string\" || !record || typeof record !== \"object\" || Array.isArray(record)) return { error: UGC_PICK_GONE_MESSAGE }\n const r = record as Record<string, unknown>\n if (r.v !== 1) return { error: UGC_VERSION_MESSAGE }\n if (!Array.isArray(r.identityImages) || r.identityImages[0] !== imageUrl) return { error: UGC_PICK_GONE_MESSAGE }\n return { result: r, outputs: { creator: JSON.stringify(r), image: imageUrl }, imageUrl }\n}\n\n// ── UGC Script ───────────────────────────────────────────────────────────────\n\n/** The languages a UGC script can be written in: the node's choice (`UgcScriptData.language`). */\nexport const UGC_SCRIPT_LANGUAGES = [\"en\", \"he\"] as const\nexport type UgcScriptLanguage = (typeof UGC_SCRIPT_LANGUAGES)[number]\n\n/**\n * The `/v1/ugc/script` body: the product name or website (required), the screenshot slots\n * in card order with the empty ones dropped, the product image when set, the target length\n * (`UGC_SCRIPT_DEFAULT_TARGET_SEC` when the node holds no number), and the language (the\n * node's choice; English when it holds none or one this app does not know).\n */\nexport function ugcScriptBody(input: {\n site?: string\n screenshots: ReadonlyArray<string | undefined>\n productImage?: string\n targetDurationSec?: number\n language?: unknown\n}): { body: Record<string, unknown> } | { error: string } {\n const site = filled(input.site)?.trim()\n if (!site) return { error: NEEDS_SITE }\n const productImage = filled(input.productImage)\n return {\n body: {\n site,\n screenshots: input.screenshots.filter((s): s is string => filled(s) !== undefined),\n ...(productImage ? { productImage } : {}),\n targetDurationSec: typeof input.targetDurationSec === \"number\" ? input.targetDurationSec : UGC_SCRIPT_DEFAULT_TARGET_SEC,\n language: (UGC_SCRIPT_LANGUAGES as readonly unknown[]).includes(input.language) ? input.language : \"en\",\n },\n }\n}\n\n/** A finished UGC Script job → `plan` (the plan, v1) and `category` (text). */\nexport function ugcScriptOutputs(outputData: Record<string, unknown>): UgcOutputs {\n const plan = outputData.plan\n const category = filled(outputData.productCategory)\n return {\n ...(isObject(plan) ? { plan: JSON.stringify({ v: 1, ...plan }) } : {}),\n ...(category ? { category } : {}),\n }\n}\n\n/** UGC Script's last result, as the node holds it. */\nexport type UgcScriptResult = {\n plan: Record<string, unknown>\n productCategory: string\n warnings: unknown[]\n notes: string[]\n rounds: number\n}\n\n/** A finished UGC Script job → the node's `result`, written the same by both engines; none without a plan. */\nexport function ugcScriptResult(outputData: Readonly<Record<string, unknown>>): UgcScriptResult | undefined {\n const { plan, productCategory, warnings, notes, rounds } = outputData\n if (!isObject(plan)) return undefined\n return {\n plan,\n productCategory: filled(productCategory) ?? \"\",\n warnings: Array.isArray(warnings) ? [...warnings] : [],\n notes: Array.isArray(notes) ? notes.filter((n): n is string => typeof n === \"string\") : [],\n rounds: typeof rounds === \"number\" && Number.isFinite(rounds) ? rounds : 0,\n }\n}\n\n// ── Kept results ─────────────────────────────────────────────────────────────\n\n/**\n * What a UGC Creator or UGC Script with Keep on hands on instead of running: the outputs of\n * the result it holds. Null — the node runs — when Keep is off, when the result holds nothing\n * to hand on (a creator without its image, a script without its plan), and for a creator whose\n * options wait for a pick, whatever Keep says. The creator record goes on unread; whoever reads\n * it refuses another version.\n */\nexport function ugcKeptOutputs(type: \"ugc-creator\" | \"ugc-script\", data: Readonly<Record<string, unknown>>): UgcOutputs | null {\n if (type === \"ugc-creator\" && ugcPickPending(data)) return null\n const result = data.keepResult === true ? data.result : undefined\n if (!isObject(result)) return null\n if (type === \"ugc-creator\") {\n const image = Array.isArray(result.identityImages) ? filled(result.identityImages[0]) : undefined\n return image ? { creator: JSON.stringify(result), image } : null\n }\n if (type === \"ugc-script\") return isObject(result.plan) ? ugcScriptOutputs(result) : null\n return null\n}\n\n// ── UGC Clips ────────────────────────────────────────────────────────────────\n\n/** The `/v1/ugc/clips` canvas body: the plan, the creator's gender, traits and images, and the picked voice. */\nexport function ugcClipsBody(input: { planWire: unknown; creatorWire: unknown; voiceId?: string }): { body: Record<string, unknown> } | { error: string } {\n const plan = readUgcWire(input.planWire, NEEDS_PLAN)\n if (\"error\" in plan) return plan\n const creator = readUgcWire(input.creatorWire, UGC_CREATOR_MISSING_MESSAGE)\n if (\"error\" in creator) return creator\n const voiceId = filled(input.voiceId)\n return {\n body: {\n plan: plan.value,\n gender: creator.value.gender,\n traits: creator.value.traits ?? null,\n identityImages: creator.value.identityImages,\n surface: \"canvas\",\n ...(voiceId ? { voiceId } : {}),\n },\n }\n}\n\n/**\n * The `/v1/ugc/clips` answer → the tickets (one per clip, as JSON strings), `clips` (the\n * first), `plan-out` (`{ v: 1, plan, transcribeArgs }` for UGC Cards), `transcript`, whether\n * the plan has cards, and whether the clips go through UGC Finish's job (`finishes`: the plan-out\n * carries a finish call, which is what UGC Finish reads to run it). An answer with errors → \"The script needs changes: …\" with each\n * error and its fix; an answer without the parts UGC Cards needs fails here, before any clip\n * is paid for.\n */\nexport function ugcClipsOutputs(answer: Record<string, unknown>): { outputs: UgcOutputs; tickets: string[]; hasCards: boolean; finishes: boolean } | { error: string } {\n const errors = Array.isArray(answer.errors) ? answer.errors : []\n if (errors.length > 0) {\n const said = errors.flatMap((e) => (isObject(e) ? [filled(e.message), filled(e.fix)] : [])).filter((s): s is string => s !== undefined)\n return { error: said.length > 0 ? `${UGC_SCRIPT_NEEDS_CHANGES} ${said.join(\" \")}` : UGC_NEWER_APP_MESSAGE }\n }\n const { tickets, sizedPlan, transcript, speechCheckCall } = answer\n if (!Array.isArray(tickets) || tickets.length === 0 || !tickets.every(isObject) || !isObject(sizedPlan) || typeof transcript !== \"string\") {\n return { error: UGC_NEWER_APP_MESSAGE }\n }\n const wires = tickets.map((t) => JSON.stringify(t))\n // The speech check's arguments ride to UGC Cards' transcription unread (an answer without them: none).\n const transcribeArgs = isObject(speechCheckCall) && isObject(speechCheckCall.args) ? speechCheckCall.args : {}\n // A video cut from one recorded speech (the segmented lane) also hands UGC Finish its finish call's\n // arguments (the segments with their room), opaque; any other answer's plan-out is unchanged.\n const finish = isObject(answer.finish) && isObject(answer.finish.args) ? { finish: answer.finish.args } : {}\n return {\n outputs: { clips: wires[0]!, \"plan-out\": JSON.stringify({ v: 1, plan: sizedPlan, transcribeArgs, ...finish }), transcript },\n tickets: wires,\n hasCards: answer.hasCards === true,\n finishes: \"finish\" in finish,\n }\n}\n\n// ── UGC Clip ─────────────────────────────────────────────────────────────────\n\n/**\n * The `/v1/ugc/clip` body for one ticket: the ticket, `nonce` = how many times this clip was\n * re-rendered (`rerender[\"<clip number>\"]`, else 0) and `runKey` when one is given.\n */\nexport function ugcClipBody(input: { ticketWire: unknown; rerender?: Readonly<Record<string, number>>; runKey?: string }):\n { body: Record<string, unknown>; clipNumber: number; durationSec: number } | { error: string } {\n const read = readUgcWire(input.ticketWire, NEEDS_TICKET)\n if (\"error\" in read) return read\n const ticket = read.value\n const { index, durationSec } = ticket\n if (typeof index !== \"number\" || !Number.isInteger(index) || index < 0) return { error: NEEDS_TICKET }\n if (typeof durationSec !== \"number\" || !Number.isFinite(durationSec) || durationSec <= 0) return { error: NEEDS_TICKET }\n const clipNumber = index + 1\n const count = input.rerender?.[String(clipNumber)]\n const nonce = typeof count === \"number\" && Number.isInteger(count) && count >= 0 ? count : 0\n const runKey = filled(input.runKey)\n return { body: { ticket, nonce, ...(runKey ? { runKey } : {}) }, clipNumber, durationSec }\n}\n\n/**\n * A finished UGC Clip job (`{ videoUrl, durationSec, clipWarnings, … }`) → `video-out`, the\n * clip's real length (null when unknown) and its warnings ([] when it has none).\n */\nexport function ugcClipOutputs(outputData: Record<string, unknown>): { outputs: UgcOutputs; videoUrl: string; durationSec: number | null; clipWarnings: string[] } {\n const videoUrl = filled(outputData.videoUrl) ?? \"\"\n const meta = fanOutItemMeta(outputData)\n return { outputs: videoUrl ? { \"video-out\": videoUrl } : {}, videoUrl, durationSec: meta.durationSec, clipWarnings: [...meta.warnings] }\n}\n\n/**\n * What a list read (a Bundle edge, a fold) takes from a UGC Clip's saved data, on both engines:\n * its last fanned-out batch — one take per clip, in clip order — when its last run was one; else\n * exactly the take it shows (its active result, else its video). Never the earlier takes it keeps:\n * a video of one clip (one ticket, so no fan-out) would join every take. A single run clears the\n * batch (the editor's job patch), so a batch held is always the last run's. Undefined when it holds\n * no take at all.\n */\nexport function ugcClipSavedList(data: unknown): string[] | undefined {\n if (!isObject(data)) return undefined\n const batch = Array.isArray(data.__listResults) ? data.__listResults.filter((u): u is string => typeof u === \"string\" && u !== \"\") : []\n if (batch.length > 0) return batch\n const results = Array.isArray(data.generatedResults) ? data.generatedResults : []\n const index = typeof data.activeResultIndex === \"number\" && Number.isInteger(data.activeResultIndex) ? data.activeResultIndex : 0\n const active = results[index]\n const url = (isObject(active) ? filled(active.url) : undefined) ?? filled(data.generatedVideoUrl)\n return url ? [url] : undefined\n}\n\n// ── UGC Cards ────────────────────────────────────────────────────────────────\n\n/**\n * UGC Cards' two timing jobs on the joined video, and the plan they time. The plan input must\n * be UGC Clips' `{ v: 1, plan, transcribeArgs }`; anything else is refused before either job.\n * The transcription spreads `transcribeArgs` unread, then sets the node's own fields last, so\n * the wire can add a language but never change the provider or the word timings.\n */\nexport function ugcCardsJobs(input: { planOutWire: unknown; videoUrl?: string; transcript?: string }): {\n alignment: { path: \"/v1/forced-alignment\"; body: Record<string, unknown> }\n transcribe: { path: \"/v1/transcribe\"; body: Record<string, unknown> }\n plan: Record<string, unknown>\n} | { error: string } {\n const read = readUgcWire(input.planOutWire, NEEDS_PLAN_OUT)\n if (\"error\" in read) return read\n const { plan, transcribeArgs } = read.value\n if (!isObject(plan) || !isObject(transcribeArgs)) return { error: NEEDS_PLAN_OUT }\n const videoUrl = filled(input.videoUrl)\n if (!videoUrl) return { error: NEEDS_VIDEO }\n // An empty transcript is what UGC Clips said, not a missing input: it goes on as it came.\n const transcript = input.transcript\n if (typeof transcript !== \"string\") return { error: NEEDS_TRANSCRIPT }\n return {\n alignment: { path: \"/v1/forced-alignment\", body: { audioUrl: videoUrl, transcript } },\n transcribe: { path: \"/v1/transcribe\", body: { ...transcribeArgs, audioUrl: videoUrl, provider: DEFAULT_TRANSCRIBE_NODE_PROVIDER, wordTimestamps: true } },\n plan,\n }\n}\n\n/**\n * The `/v1/ugc/cards` canvas body: the plan, the video, whichever timing came back as a list,\n * the timing jobs that failed, and the clips' notes.\n */\nexport function ugcCardsBody(input: {\n plan: Record<string, unknown>\n videoUrl: string\n alignment?: unknown\n words?: unknown\n failed: ReadonlyArray<\"alignment\" | \"words\">\n clipNotes: ReadonlyArray<ClipNote>\n}): Record<string, unknown> {\n return {\n surface: \"canvas\",\n plan: input.plan,\n videoUrl: input.videoUrl,\n ...(Array.isArray(input.alignment) ? { alignment: input.alignment } : {}),\n ...(Array.isArray(input.words) ? { words: input.words } : {}),\n failed: [...input.failed],\n clipNotes: [...input.clipNotes],\n }\n}\n\n/** The caption plan when nothing could be timed: Add Captions renders no captions from it. */\nconst EMPTY_CAPTION_PLAN: CaptionPlan = { v: 1, hookText: \"\", hookEndMs: 0, bodyEndMs: 0, captions: [] }\n\n/** The `/v1/ugc/cards` answer → `layerPlan`, `captionPlan` (v1; the empty plan when untimed) and `report` (one line per sentence). */\nexport function ugcCardsOutputs(answer: Record<string, unknown>): UgcOutputs {\n const timing = answer.captionTiming\n const report = answer.report\n const lines = isObject(report) && Array.isArray(report.lines) ? report.lines.filter((l): l is string => typeof l === \"string\") : []\n return {\n layerPlan: JSON.stringify(Array.isArray(answer.layerPlan) ? answer.layerPlan : []),\n captionPlan: JSON.stringify(isObject(timing) ? { v: 1, ...timing } : EMPTY_CAPTION_PLAN),\n report: lines.join(\"\\n\"),\n }\n}\n"]}
|