@nodaro/shared 3.63.0 → 3.65.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-3K24DWOH.js → chunk-222QM7CO.js} +3 -3
- package/dist/{chunk-3K24DWOH.js.map → chunk-222QM7CO.js.map} +1 -1
- package/dist/chunk-27HA6YOL.cjs +377 -0
- package/dist/chunk-27HA6YOL.cjs.map +1 -0
- package/dist/{chunk-4DVWXEB6.js → chunk-2NKF476Z.js} +3 -3
- package/dist/{chunk-4DVWXEB6.js.map → chunk-2NKF476Z.js.map} +1 -1
- package/dist/chunk-3AU52TSW.js +143 -0
- package/dist/chunk-3AU52TSW.js.map +1 -0
- package/dist/{chunk-F6WGGYQW.cjs → chunk-5NVGKXJV.cjs} +68 -29
- package/dist/chunk-5NVGKXJV.cjs.map +1 -0
- package/dist/{chunk-HWQ2SYNA.js → chunk-5SSMPYE5.js} +99 -9
- package/dist/chunk-5SSMPYE5.js.map +1 -0
- package/dist/{chunk-WRSWH7US.cjs → chunk-6BRWPJPP.cjs} +17 -2
- package/dist/chunk-6BRWPJPP.cjs.map +1 -0
- package/dist/{chunk-KHH54GRP.cjs → chunk-6ET3KDO4.cjs} +15 -338
- package/dist/chunk-6ET3KDO4.cjs.map +1 -0
- package/dist/{chunk-TM5JYSJF.cjs → chunk-6OSIOVF7.cjs} +98 -37
- package/dist/chunk-6OSIOVF7.cjs.map +1 -0
- package/dist/{chunk-YUER7TJG.js → chunk-6X5PBAC4.js} +13 -4
- package/dist/chunk-6X5PBAC4.js.map +1 -0
- package/dist/chunk-7BN4EDIC.cjs +185 -0
- package/dist/chunk-7BN4EDIC.cjs.map +1 -0
- package/dist/{chunk-6M563QE6.js → chunk-7OWXHW7Z.js} +78 -28
- package/dist/chunk-7OWXHW7Z.js.map +1 -0
- package/dist/{chunk-FXGNRYQQ.js → chunk-AT53ZQUC.js} +3 -3
- package/dist/{chunk-FXGNRYQQ.js.map → chunk-AT53ZQUC.js.map} +1 -1
- package/dist/{chunk-HSHCCBIV.js → chunk-BQYCZLMF.js} +16 -3
- package/dist/chunk-BQYCZLMF.js.map +1 -0
- package/dist/{chunk-34QLPTSA.js → chunk-BSTAAGLY.js} +3 -3
- package/dist/{chunk-34QLPTSA.js.map → chunk-BSTAAGLY.js.map} +1 -1
- package/dist/{chunk-PSKZKLDG.js → chunk-CW6MMQNO.js} +562 -26
- package/dist/chunk-CW6MMQNO.js.map +1 -0
- package/dist/{chunk-EPXGG27L.js → chunk-D5Y3EYRM.js} +5 -5
- package/dist/{chunk-EPXGG27L.js.map → chunk-D5Y3EYRM.js.map} +1 -1
- package/dist/{chunk-XGVJGNZW.cjs → chunk-DQ2PARNH.cjs} +15 -5
- package/dist/chunk-DQ2PARNH.cjs.map +1 -0
- package/dist/{chunk-6BZC2ZHC.cjs → chunk-E66HSC2E.cjs} +9 -9
- package/dist/{chunk-6BZC2ZHC.cjs.map → chunk-E66HSC2E.cjs.map} +1 -1
- package/dist/{chunk-NIAFR5EE.js → chunk-FGBGKBML.js} +32 -3
- package/dist/chunk-FGBGKBML.js.map +1 -0
- package/dist/{chunk-M5OCFGHF.cjs → chunk-FI3HJZWM.cjs} +588 -25
- package/dist/chunk-FI3HJZWM.cjs.map +1 -0
- package/dist/{chunk-L2TVY6XN.cjs → chunk-FJZTQTF4.cjs} +4 -4
- package/dist/{chunk-L2TVY6XN.cjs.map → chunk-FJZTQTF4.cjs.map} +1 -1
- package/dist/{chunk-XGGZWA4A.cjs → chunk-GJ3D5X4X.cjs} +52 -49
- package/dist/chunk-GJ3D5X4X.cjs.map +1 -0
- package/dist/{chunk-Q6IES3U2.js → chunk-H5KHWTAE.js} +5 -2
- package/dist/chunk-H5KHWTAE.js.map +1 -0
- package/dist/{chunk-MD4XHED4.js → chunk-H745DQ6V.js} +3 -3
- package/dist/{chunk-MD4XHED4.js.map → chunk-H745DQ6V.js.map} +1 -1
- package/dist/{chunk-KCZHQH2O.js → chunk-HAH2F7LT.js} +4 -4
- package/dist/{chunk-KCZHQH2O.js.map → chunk-HAH2F7LT.js.map} +1 -1
- package/dist/{chunk-V5EEQR2U.cjs → chunk-JQMFJAYU.cjs} +21 -21
- package/dist/{chunk-V5EEQR2U.cjs.map → chunk-JQMFJAYU.cjs.map} +1 -1
- package/dist/{chunk-WZVIBAKN.cjs → chunk-JYU5EIRM.cjs} +12 -12
- package/dist/{chunk-WZVIBAKN.cjs.map → chunk-JYU5EIRM.cjs.map} +1 -1
- package/dist/{chunk-Y35JQPT6.cjs → chunk-K6RIN3LW.cjs} +142 -45
- package/dist/chunk-K6RIN3LW.cjs.map +1 -0
- package/dist/{chunk-BLJUCPMV.cjs → chunk-KSHAAPQF.cjs} +5 -2
- package/dist/chunk-KSHAAPQF.cjs.map +1 -0
- package/dist/{chunk-2PU3AGGS.cjs → chunk-KTCEKGBJ.cjs} +7 -7
- package/dist/{chunk-2PU3AGGS.cjs.map → chunk-KTCEKGBJ.cjs.map} +1 -1
- package/dist/{chunk-LH72PQO2.cjs → chunk-KWYS4IIM.cjs} +165 -50
- package/dist/chunk-KWYS4IIM.cjs.map +1 -0
- package/dist/{chunk-GSKLPI3J.cjs → chunk-MIT2USTS.cjs} +118 -61
- package/dist/chunk-MIT2USTS.cjs.map +1 -0
- package/dist/{chunk-Y4GCJJPF.cjs → chunk-NYZQOIXJ.cjs} +35 -2
- package/dist/chunk-NYZQOIXJ.cjs.map +1 -0
- package/dist/{chunk-A2PX5IRC.cjs → chunk-PERUFUVH.cjs} +13 -13
- package/dist/{chunk-A2PX5IRC.cjs.map → chunk-PERUFUVH.cjs.map} +1 -1
- package/dist/{chunk-X5BAFW3Q.cjs → chunk-PGDR7CO3.cjs} +8 -8
- package/dist/{chunk-X5BAFW3Q.cjs.map → chunk-PGDR7CO3.cjs.map} +1 -1
- package/dist/{chunk-OV3JTKBY.js → chunk-PL7AQQV7.js} +123 -22
- package/dist/chunk-PL7AQQV7.js.map +1 -0
- package/dist/chunk-Q4YOLT4M.js +164 -0
- package/dist/chunk-Q4YOLT4M.js.map +1 -0
- package/dist/{chunk-GMBDLNLD.cjs → chunk-R5ILCNCC.cjs} +197 -60
- package/dist/chunk-R5ILCNCC.cjs.map +1 -0
- package/dist/chunk-RP4KQUNU.cjs +168 -0
- package/dist/chunk-RP4KQUNU.cjs.map +1 -0
- package/dist/{chunk-77WU3V3J.cjs → chunk-SPU7MUWE.cjs} +6 -6
- package/dist/{chunk-77WU3V3J.cjs.map → chunk-SPU7MUWE.cjs.map} +1 -1
- package/dist/{chunk-XBTYGQ6Z.js → chunk-ST7OBB5J.js} +8 -5
- package/dist/chunk-ST7OBB5J.js.map +1 -0
- package/dist/{chunk-2QKF7M2Z.js → chunk-TAPBDT47.js} +3 -3
- package/dist/{chunk-2QKF7M2Z.js.map → chunk-TAPBDT47.js.map} +1 -1
- package/dist/{chunk-BMJVKYVB.js → chunk-V5NLQ4L5.js} +123 -7
- package/dist/chunk-V5NLQ4L5.js.map +1 -0
- package/dist/{chunk-KMGCHV6O.js → chunk-V6OXSXIX.js} +63 -30
- package/dist/chunk-V6OXSXIX.js.map +1 -0
- package/dist/{chunk-LMAQUR55.cjs → chunk-WQMPIURW.cjs} +6 -6
- package/dist/{chunk-LMAQUR55.cjs.map → chunk-WQMPIURW.cjs.map} +1 -1
- package/dist/{chunk-ZPE2ZTJ4.cjs → chunk-WZG6GZIL.cjs} +4 -4
- package/dist/{chunk-ZPE2ZTJ4.cjs.map → chunk-WZG6GZIL.cjs.map} +1 -1
- package/dist/{chunk-AE3AAJ4O.js → chunk-XJANKTIL.js} +3 -3
- package/dist/{chunk-AE3AAJ4O.js.map → chunk-XJANKTIL.js.map} +1 -1
- package/dist/{chunk-O7RZRUMZ.js → chunk-XJWED257.js} +14 -309
- package/dist/chunk-XJWED257.js.map +1 -0
- package/dist/chunk-XSSLNINL.js +346 -0
- package/dist/chunk-XSSLNINL.js.map +1 -0
- package/dist/{chunk-6TGB7ECA.cjs → chunk-YD4XY74W.cjs} +12 -8
- package/dist/chunk-YD4XY74W.cjs.map +1 -0
- package/dist/{chunk-YX6TFX7H.js → chunk-YMZUE2IX.js} +66 -11
- package/dist/chunk-YMZUE2IX.js.map +1 -0
- package/dist/{chunk-4MMZD63H.js → chunk-Z77M7Q2R.js} +3 -3
- package/dist/{chunk-4MMZD63H.js.map → chunk-Z77M7Q2R.js.map} +1 -1
- package/dist/{chunk-CZ5IQB3L.js → chunk-ZSRXY5YT.js} +8 -5
- package/dist/chunk-ZSRXY5YT.js.map +1 -0
- package/dist/entries/apps.cjs +43 -42
- package/dist/entries/apps.js +8 -7
- package/dist/entries/captions.cjs +38 -30
- package/dist/entries/captions.d.cts +48 -2
- package/dist/entries/captions.d.ts +48 -2
- package/dist/entries/captions.js +1 -1
- package/dist/entries/credits.cjs +319 -191
- package/dist/entries/credits.d.cts +260 -19
- package/dist/entries/credits.d.ts +260 -19
- package/dist/entries/credits.js +11 -11
- package/dist/entries/entities.cjs +202 -193
- package/dist/entries/entities.d.cts +44 -9
- package/dist/entries/entities.d.ts +44 -9
- package/dist/entries/entities.js +2 -1
- package/dist/entries/llm-models.cjs +86 -62
- package/dist/entries/llm-models.d.cts +73 -20
- package/dist/entries/llm-models.d.ts +73 -20
- package/dist/entries/llm-models.js +2 -2
- package/dist/entries/media.cjs +79 -63
- package/dist/entries/media.d.cts +154 -1
- package/dist/entries/media.d.ts +154 -1
- package/dist/entries/media.js +1 -1
- package/dist/entries/model-catalog.cjs +205 -109
- package/dist/entries/model-catalog.d.cts +65 -58
- package/dist/entries/model-catalog.d.ts +65 -58
- package/dist/entries/model-catalog.js +4 -4
- package/dist/entries/models.cjs +527 -346
- package/dist/entries/models.d.cts +86 -7
- package/dist/entries/models.d.ts +86 -7
- package/dist/entries/models.js +6 -5
- package/dist/entries/nodes.cjs +220 -211
- package/dist/entries/nodes.d.cts +46 -3
- package/dist/entries/nodes.d.ts +46 -3
- package/dist/entries/nodes.js +10 -9
- package/dist/entries/pipeline.cjs +156 -152
- package/dist/entries/pipeline.d.cts +14 -4
- package/dist/entries/pipeline.d.ts +14 -4
- package/dist/entries/pipeline.js +3 -3
- package/dist/entries/social.cjs +177 -177
- package/dist/entries/social.js +2 -2
- package/dist/entries/ugc.cjs +71 -71
- package/dist/entries/ugc.js +4 -4
- package/dist/entries/video.cjs +174 -145
- package/dist/entries/video.d.cts +114 -2
- package/dist/entries/video.d.ts +114 -2
- package/dist/entries/video.js +7 -6
- package/dist/entries/workflow.cjs +150 -150
- package/dist/entries/workflow.d.cts +1 -1
- package/dist/entries/workflow.d.ts +1 -1
- package/dist/entries/workflow.js +2 -2
- package/dist/index.cjs +2430 -1929
- package/dist/index.d.cts +13 -12
- package/dist/index.d.ts +13 -12
- package/dist/index.js +28 -27
- package/dist/{model-catalog-C_Eo35tL.d.cts → model-catalog-BoUKGFNl.d.cts} +182 -3
- package/dist/{model-catalog-C_Eo35tL.d.ts → model-catalog-BoUKGFNl.d.ts} +182 -3
- package/dist/{model-constants-DWcxOmaY.d.cts → model-constants-BElS3AeE.d.ts} +142 -23
- package/dist/{model-constants-Bg4ccSQb.d.ts → model-constants-CpQz1bGa.d.cts} +142 -23
- package/dist/tts-capabilities-BtnDWK9K.d.ts +133 -0
- package/dist/tts-capabilities-C52UccTI.d.cts +133 -0
- package/package.json +1 -1
- package/src/__tests__/add-captions-nemotron-pricing.test.ts +111 -0
- package/src/__tests__/dialogue-capabilities.test.ts +167 -6
- package/src/__tests__/extend-providers.test.ts +353 -26
- package/src/__tests__/fixtures/mask-composite-quote-parity.json +1 -1
- package/src/__tests__/fixtures/measured-input-quote-parity.json +1435 -0
- package/src/__tests__/fixtures/planned-length-quote-parity.json +1866 -0
- package/src/__tests__/fixtures/video-utility-quote-parity.json +2343 -0
- package/src/__tests__/flux-3-klein.test.ts +203 -0
- package/src/__tests__/gpt-image-2-6-formats.test.ts +3 -1
- package/src/__tests__/kling4-catalog.test.ts +1 -1
- package/src/__tests__/llm-models.test.ts +48 -13
- package/src/__tests__/llm-price-key.test.ts +12 -0
- package/src/__tests__/model-makers.test.ts +3 -0
- package/src/__tests__/node-runtime-keys.test.ts +7 -0
- package/src/__tests__/normalize-node-params.test.ts +147 -1
- package/src/__tests__/retired-lip-sync-providers.test.ts +43 -0
- package/src/__tests__/seedance-extend-source-credit-id.test.ts +89 -0
- package/src/__tests__/sequence-execution.test.ts +22 -1
- package/src/__tests__/speech-pricing.test.ts +62 -1
- package/src/__tests__/suno-credit-type.test.ts +21 -2
- package/src/__tests__/transcribe-capabilities.test.ts +4 -2
- package/src/__tests__/tts-capabilities.test.ts +160 -4
- package/src/__tests__/video-analysis-catalog-sync.test.ts +4 -2
- package/src/__tests__/video-analysis-pricing.test.ts +22 -9
- package/src/__tests__/video-subjects.test.ts +192 -0
- package/src/__tests__/wired-character-names.test.ts +142 -0
- package/src/caption-styles.ts +62 -0
- package/src/credit-estimators/add-captions-nemotron.ts +73 -0
- package/src/credit-estimators/index.ts +14 -0
- package/src/credit-estimators/speech.ts +57 -9
- package/src/credit-identifiers.ts +284 -13
- package/src/dialogue-capabilities.ts +220 -3
- package/src/dubbing-structure.ts +186 -0
- package/src/entries/captions.ts +2 -0
- package/src/entries/credits.ts +25 -1
- package/src/entries/entities.ts +2 -0
- package/src/entries/llm-models.ts +7 -0
- package/src/entries/media.ts +3 -1
- package/src/entries/model-catalog.ts +30 -0
- package/src/entries/models.ts +54 -0
- package/src/entries/nodes.ts +2 -0
- package/src/entries/pipeline.ts +1 -1
- package/src/entries/video.ts +8 -1
- package/src/flux-3-klein.ts +69 -0
- package/src/gemini-tts.ts +144 -0
- package/src/input-image-pricing.ts +23 -6
- package/src/llm-models.ts +130 -36
- package/src/model-catalog.ts +539 -25
- package/src/model-constants.ts +247 -25
- package/src/node-default-mappings.ts +3 -0
- package/src/node-runtime-keys.ts +3 -0
- package/src/normalize-node-params.ts +123 -2
- package/src/seedance-extend-rate.ts +116 -0
- package/src/sequence-execution.ts +24 -0
- package/src/transcribe-preflight.ts +23 -0
- package/src/tts-capabilities.ts +193 -1
- package/src/video-analysis-pricing.ts +39 -15
- package/src/video-character-refs.ts +160 -3
- package/src/wired-character-names.ts +134 -18
- package/src/wired-character-video-subjects.ts +63 -0
- package/dist/chunk-63H4C56Q.cjs +0 -38
- package/dist/chunk-63H4C56Q.cjs.map +0 -1
- package/dist/chunk-6M563QE6.js.map +0 -1
- package/dist/chunk-6TGB7ECA.cjs.map +0 -1
- package/dist/chunk-6XUG4L7X.cjs +0 -54
- package/dist/chunk-6XUG4L7X.cjs.map +0 -1
- package/dist/chunk-BLJUCPMV.cjs.map +0 -1
- package/dist/chunk-BMJVKYVB.js.map +0 -1
- package/dist/chunk-CZ5IQB3L.js.map +0 -1
- package/dist/chunk-F6WGGYQW.cjs.map +0 -1
- package/dist/chunk-GMBDLNLD.cjs.map +0 -1
- package/dist/chunk-GSKLPI3J.cjs.map +0 -1
- package/dist/chunk-HBXF6RUU.js +0 -31
- package/dist/chunk-HBXF6RUU.js.map +0 -1
- package/dist/chunk-HSHCCBIV.js.map +0 -1
- package/dist/chunk-HWQ2SYNA.js.map +0 -1
- package/dist/chunk-IY3Y462W.js +0 -42
- package/dist/chunk-IY3Y462W.js.map +0 -1
- package/dist/chunk-KHH54GRP.cjs.map +0 -1
- package/dist/chunk-KMGCHV6O.js.map +0 -1
- package/dist/chunk-LH72PQO2.cjs.map +0 -1
- package/dist/chunk-M5OCFGHF.cjs.map +0 -1
- package/dist/chunk-NIAFR5EE.js.map +0 -1
- package/dist/chunk-O7RZRUMZ.js.map +0 -1
- package/dist/chunk-OV3JTKBY.js.map +0 -1
- package/dist/chunk-PSKZKLDG.js.map +0 -1
- package/dist/chunk-Q6IES3U2.js.map +0 -1
- package/dist/chunk-TM5JYSJF.cjs.map +0 -1
- package/dist/chunk-WRSWH7US.cjs.map +0 -1
- package/dist/chunk-XBTYGQ6Z.js.map +0 -1
- package/dist/chunk-XGGZWA4A.cjs.map +0 -1
- package/dist/chunk-XGVJGNZW.cjs.map +0 -1
- package/dist/chunk-Y35JQPT6.cjs.map +0 -1
- package/dist/chunk-Y4GCJJPF.cjs.map +0 -1
- package/dist/chunk-YUER7TJG.js.map +0 -1
- package/dist/chunk-YX6TFX7H.js.map +0 -1
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { resolveEffectiveSourceType } from './chunk-CTANEPMY.js';
|
|
2
|
+
|
|
3
|
+
// src/character-usage-mode.ts
|
|
4
|
+
var USAGE_MODES = [
|
|
5
|
+
"identical",
|
|
6
|
+
"face",
|
|
7
|
+
"face-pose",
|
|
8
|
+
"pose",
|
|
9
|
+
"emotion",
|
|
10
|
+
"style",
|
|
11
|
+
"name",
|
|
12
|
+
"none"
|
|
13
|
+
];
|
|
14
|
+
var DEFAULT_USAGE_MODE = "identical";
|
|
15
|
+
function isUsageMode(s) {
|
|
16
|
+
return USAGE_MODES.includes(s);
|
|
17
|
+
}
|
|
18
|
+
function usageModeDirective(mode) {
|
|
19
|
+
switch (mode) {
|
|
20
|
+
case "identical":
|
|
21
|
+
return "The subject must remain exactly the same person \u2014 preserve 100% facial identity, bone structure, skin tone, proportions, and all unique features. Do not alter eyes, nose, mouth, or facial shape. Maintain natural skin texture, including pores and imperfections.";
|
|
22
|
+
case "face":
|
|
23
|
+
return "Take ONLY the facial features and expression \u2014 preserve 100% facial identity, bone structure, skin tone, and all unique features. Do not alter eyes, nose, mouth, or facial shape. Maintain natural skin texture, including pores and imperfections. Adopt clothing, hair styling, and posture from the rest of the prompt.";
|
|
24
|
+
case "face-pose":
|
|
25
|
+
return "Take the facial features AND body pose \u2014 preserve 100% facial identity, bone structure, skin tone, and all unique features. Do not alter eyes, nose, mouth, or facial shape. Maintain natural skin texture. Adopt clothing and styling from the rest of the prompt.";
|
|
26
|
+
case "pose":
|
|
27
|
+
return "Take only the body pose and posture \u2014 do not copy facial identity, features, or skin. Adopt face, clothing, hair, and all other details from the rest of the prompt.";
|
|
28
|
+
case "emotion":
|
|
29
|
+
return "Take only the emotional expression \u2014 preserve 100% facial identity and all unique features unchanged. Adopt face shape, clothing, body, and pose from the rest of the prompt; transfer only the emotional cue.";
|
|
30
|
+
case "style":
|
|
31
|
+
return "Take only the visual style and tone (lighting, color grade, atmosphere). Do not copy the subject's identity, clothing, or pose.";
|
|
32
|
+
case "name":
|
|
33
|
+
case "none":
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function usageModeLabel(mode) {
|
|
38
|
+
switch (mode) {
|
|
39
|
+
case "identical":
|
|
40
|
+
return "Identical";
|
|
41
|
+
case "face":
|
|
42
|
+
return "Face only";
|
|
43
|
+
case "face-pose":
|
|
44
|
+
return "Face + Pose";
|
|
45
|
+
case "pose":
|
|
46
|
+
return "Pose only";
|
|
47
|
+
case "emotion":
|
|
48
|
+
return "Emotion only";
|
|
49
|
+
case "style":
|
|
50
|
+
return "Style only";
|
|
51
|
+
case "name":
|
|
52
|
+
return "Name only";
|
|
53
|
+
case "none":
|
|
54
|
+
return "None";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function usageModeIncludesName(mode) {
|
|
58
|
+
return mode !== "none";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/character-mention-slug.ts
|
|
62
|
+
function characterMentionSlug(name) {
|
|
63
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
64
|
+
}
|
|
65
|
+
function parseCharacterMentionToken(text2, _knownCharacterSlugs) {
|
|
66
|
+
if (!text2.startsWith("@")) return null;
|
|
67
|
+
let rest = text2.slice(1);
|
|
68
|
+
if (rest.length === 0 || !/^[a-z]/.test(rest)) return null;
|
|
69
|
+
let lockField = {};
|
|
70
|
+
if (rest.endsWith("~nolock")) {
|
|
71
|
+
rest = rest.slice(0, -"~nolock".length);
|
|
72
|
+
lockField = { lock: false };
|
|
73
|
+
} else if (rest.endsWith("~lock")) {
|
|
74
|
+
rest = rest.slice(0, -"~lock".length);
|
|
75
|
+
lockField = { lock: true };
|
|
76
|
+
}
|
|
77
|
+
const parts = rest.split(":");
|
|
78
|
+
if (parts.length < 2 || parts.length > 4) return null;
|
|
79
|
+
const [characterSlug, indexStr, third, fourth] = parts;
|
|
80
|
+
if (!/^[a-z][a-z0-9-]*$/.test(characterSlug)) return null;
|
|
81
|
+
if (!/^\d+$/.test(indexStr)) return null;
|
|
82
|
+
const imageIndex = parseInt(indexStr, 10);
|
|
83
|
+
if (!Number.isInteger(imageIndex) || imageIndex < 1) return null;
|
|
84
|
+
if (parts.length === 2) {
|
|
85
|
+
return { characterSlug, imageIndex, variantSlug: null, usageMode: null, ...lockField };
|
|
86
|
+
}
|
|
87
|
+
if (parts.length === 3) {
|
|
88
|
+
if (!/^[a-z][a-z0-9-]*$/.test(third)) return null;
|
|
89
|
+
if (isUsageMode(third)) {
|
|
90
|
+
return { characterSlug, imageIndex, variantSlug: null, usageMode: third, ...lockField };
|
|
91
|
+
}
|
|
92
|
+
return { characterSlug, imageIndex, variantSlug: third, usageMode: null, ...lockField };
|
|
93
|
+
}
|
|
94
|
+
if (parts.length === 4) {
|
|
95
|
+
if (!/^[a-z][a-z0-9-]*$/.test(third)) return null;
|
|
96
|
+
if (!/^[a-z][a-z0-9-]*$/.test(fourth)) return null;
|
|
97
|
+
if (isUsageMode(fourth)) {
|
|
98
|
+
return { characterSlug, imageIndex, variantSlug: third, usageMode: fourth, ...lockField };
|
|
99
|
+
}
|
|
100
|
+
return { characterSlug, imageIndex, variantSlug: third, usageMode: null, role: fourth, ...lockField };
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
function findCharacterMentionTokens(prompt, knownCharacterSlugs) {
|
|
105
|
+
const tokens = [];
|
|
106
|
+
const regex = /(?:^|[^a-zA-Z0-9])(@[a-z][a-z0-9-]*:\d+(?::[a-z][a-z0-9-]*)?(?::[a-z][a-z0-9-]*)?(?:~(?:no)?lock(?![a-z0-9-]))?)/g;
|
|
107
|
+
const knownSet = new Set(knownCharacterSlugs);
|
|
108
|
+
for (const match of prompt.matchAll(regex)) {
|
|
109
|
+
const token = match[1];
|
|
110
|
+
const offset = (match.index ?? 0) + (match[0].length - token.length);
|
|
111
|
+
const parsed = parseCharacterMentionToken(token);
|
|
112
|
+
if (parsed && knownSet.has(parsed.characterSlug)) {
|
|
113
|
+
tokens.push({ token, ...parsed, offset });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return tokens;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/wired-character-names.ts
|
|
120
|
+
var CHARACTER_NODE_DEFAULT_LABEL = "Character Asset";
|
|
121
|
+
var CHARACTER_NODE_RETIRED_DEFAULT_LABELS = ["Character"];
|
|
122
|
+
var UNNAMED_CHARACTER_NAME_PREFIX = "Character";
|
|
123
|
+
var text = (v) => typeof v === "string" ? v.trim() : "";
|
|
124
|
+
function characterOwnName(data) {
|
|
125
|
+
const d = data ?? {};
|
|
126
|
+
const name = text(d.characterName);
|
|
127
|
+
if (name) return name;
|
|
128
|
+
const label = text(d.label);
|
|
129
|
+
if (!label || label === CHARACTER_NODE_DEFAULT_LABEL || CHARACTER_NODE_RETIRED_DEFAULT_LABELS.includes(label)) return "";
|
|
130
|
+
return label;
|
|
131
|
+
}
|
|
132
|
+
function wiredCharacterNames(sources) {
|
|
133
|
+
const order = [];
|
|
134
|
+
const seen = /* @__PURE__ */ new Set();
|
|
135
|
+
for (const s of sources) {
|
|
136
|
+
if (seen.has(s.key) || resolveEffectiveSourceType(s.type, s.sourceHandle) !== "character") continue;
|
|
137
|
+
seen.add(s.key);
|
|
138
|
+
const own = characterOwnName(s.data);
|
|
139
|
+
order.push({ key: s.key, own, identity: characterIdentity(own) ?? `node:${s.key}`, ownSlug: characterMentionSlug(own) });
|
|
140
|
+
}
|
|
141
|
+
const claims = /* @__PURE__ */ new Map();
|
|
142
|
+
for (const { identity, ownSlug } of order) {
|
|
143
|
+
if (!ownSlug) continue;
|
|
144
|
+
const set = claims.get(ownSlug) ?? /* @__PURE__ */ new Set();
|
|
145
|
+
set.add(identity);
|
|
146
|
+
claims.set(ownSlug, set);
|
|
147
|
+
}
|
|
148
|
+
const keepsOwnSlug = (identity, ownSlug) => !!ownSlug && (identity.startsWith(LATIN_IDENTITY) || claims.get(ownSlug)?.size === 1);
|
|
149
|
+
const taken = /* @__PURE__ */ new Set();
|
|
150
|
+
for (const { identity, ownSlug } of order) if (keepsOwnSlug(identity, ownSlug)) taken.add(ownSlug);
|
|
151
|
+
const out = /* @__PURE__ */ new Map();
|
|
152
|
+
const numberedOf = /* @__PURE__ */ new Map();
|
|
153
|
+
let next = 1;
|
|
154
|
+
for (const { key, own, identity, ownSlug } of order) {
|
|
155
|
+
if (keepsOwnSlug(identity, ownSlug)) {
|
|
156
|
+
out.set(key, { name: own, slug: ownSlug, unnamed: false });
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const same = numberedOf.get(identity);
|
|
160
|
+
if (same) {
|
|
161
|
+
out.set(key, { name: own, slug: same, unnamed: false });
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
while (taken.has(numberedSlug(next))) next++;
|
|
165
|
+
const slug = numberedSlug(next);
|
|
166
|
+
taken.add(slug);
|
|
167
|
+
numberedOf.set(identity, slug);
|
|
168
|
+
out.set(key, own ? { name: own, slug, unnamed: false } : { name: `${UNNAMED_CHARACTER_NAME_PREFIX} ${next}`, slug, unnamed: true });
|
|
169
|
+
next++;
|
|
170
|
+
}
|
|
171
|
+
return out;
|
|
172
|
+
}
|
|
173
|
+
var LATIN_IDENTITY = "latin:";
|
|
174
|
+
var OTHER_SCRIPT_LETTER = /(?=\p{L})\P{Script=Latin}/u;
|
|
175
|
+
function characterIdentity(name) {
|
|
176
|
+
const slug = characterMentionSlug(name);
|
|
177
|
+
if (slug && !OTHER_SCRIPT_LETTER.test(name)) return `${LATIN_IDENTITY}${slug}`;
|
|
178
|
+
const key = scriptNameKey(name);
|
|
179
|
+
return key ? `script:${key}` : void 0;
|
|
180
|
+
}
|
|
181
|
+
var numberedSlug = (n) => characterMentionSlug(`${UNNAMED_CHARACTER_NAME_PREFIX} ${n}`);
|
|
182
|
+
function scriptNameKey(name) {
|
|
183
|
+
return name.normalize("NFKC").toUpperCase().toLowerCase().replace(/[^\p{L}\p{N}\p{M}]+/gu, "-").replace(/^-+|-+$/g, "");
|
|
184
|
+
}
|
|
185
|
+
var RETIRED_CHARACTER_MENTION_SLUGS = [
|
|
186
|
+
characterMentionSlug(CHARACTER_NODE_DEFAULT_LABEL),
|
|
187
|
+
...CHARACTER_NODE_RETIRED_DEFAULT_LABELS.map(characterMentionSlug)
|
|
188
|
+
];
|
|
189
|
+
function aliasRetiredCharacterMentions(text2, names) {
|
|
190
|
+
if (!text2 || !text2.includes("@")) return text2;
|
|
191
|
+
let lone;
|
|
192
|
+
for (const n of names.values()) {
|
|
193
|
+
if (!n.unnamed) continue;
|
|
194
|
+
if (lone) return text2;
|
|
195
|
+
lone = n;
|
|
196
|
+
}
|
|
197
|
+
if (!lone) return text2;
|
|
198
|
+
const slugs = new Set([...names.values()].map((n) => n.slug));
|
|
199
|
+
let out = text2;
|
|
200
|
+
for (const retired of RETIRED_CHARACTER_MENTION_SLUGS) {
|
|
201
|
+
if (slugs.has(retired)) continue;
|
|
202
|
+
out = out.replace(new RegExp(`(^|[^a-zA-Z0-9])@${retired}(?=:\\d)`, "g"), `$1@${lone.slug}`);
|
|
203
|
+
}
|
|
204
|
+
return out;
|
|
205
|
+
}
|
|
206
|
+
function wiredCharacterNamesOf(consumerId, nodes, edges) {
|
|
207
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
208
|
+
const sources = [];
|
|
209
|
+
for (const e of edges) {
|
|
210
|
+
if (e.target !== consumerId) continue;
|
|
211
|
+
const n = byId.get(e.source);
|
|
212
|
+
if (!n) continue;
|
|
213
|
+
sources.push({ key: n.id, type: n.type, sourceHandle: e.sourceHandle, data: n.data });
|
|
214
|
+
}
|
|
215
|
+
return wiredCharacterNames(sources);
|
|
216
|
+
}
|
|
217
|
+
function wiredCharacterSlug(names, nodeId, data) {
|
|
218
|
+
const wired = names.get(nodeId)?.slug;
|
|
219
|
+
if (wired) return wired;
|
|
220
|
+
const own = characterOwnName(data);
|
|
221
|
+
const identity = characterIdentity(own);
|
|
222
|
+
if (!identity) return "";
|
|
223
|
+
for (const n of names.values()) {
|
|
224
|
+
if (!n.unnamed && characterIdentity(n.name) === identity) return n.slug;
|
|
225
|
+
}
|
|
226
|
+
if (!identity.startsWith(LATIN_IDENTITY)) return "";
|
|
227
|
+
const slug = characterMentionSlug(own);
|
|
228
|
+
for (const n of names.values()) if (n.slug === slug) return "";
|
|
229
|
+
return slug;
|
|
230
|
+
}
|
|
231
|
+
function wiredCharacterKey(names, nodeId, data) {
|
|
232
|
+
return wiredCharacterSlug(names, nodeId, data) || `node:${nodeId}`;
|
|
233
|
+
}
|
|
234
|
+
function wiredCharacterBySlug(names, slug) {
|
|
235
|
+
if (!slug) return void 0;
|
|
236
|
+
for (const [key, named] of names) if (named.slug === slug) return { key, named };
|
|
237
|
+
return void 0;
|
|
238
|
+
}
|
|
239
|
+
function wiredCharacterVideoUrls(consumerId, nodes, edges) {
|
|
240
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
241
|
+
const out = /* @__PURE__ */ new Map();
|
|
242
|
+
for (const [id, named] of wiredCharacterNamesOf(consumerId, nodes, edges)) {
|
|
243
|
+
const clip = byId.get(id)?.data?.subjectVideoUrl;
|
|
244
|
+
if (typeof clip === "string" && clip.trim() && !out.has(named.slug)) out.set(named.slug, clip.trim());
|
|
245
|
+
}
|
|
246
|
+
return out;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// src/entity-image-url.ts
|
|
250
|
+
function entityImageUrl(data) {
|
|
251
|
+
const d = data ?? {};
|
|
252
|
+
const str = (v) => typeof v === "string" && v ? v : void 0;
|
|
253
|
+
const results = Array.isArray(d.generatedResults) ? d.generatedResults : [];
|
|
254
|
+
const active = typeof d.activeResultIndex === "number" ? d.activeResultIndex : 0;
|
|
255
|
+
return str(d.defaultAssetUrl) || str(results[active]?.url) || str(d.sourceImageUrl);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// src/character-variant-assets.ts
|
|
259
|
+
var CHARACTER_VARIANT_ASSET_BUCKETS = [
|
|
260
|
+
"expressions",
|
|
261
|
+
"poses",
|
|
262
|
+
"motions",
|
|
263
|
+
"angles",
|
|
264
|
+
"bodyAngles",
|
|
265
|
+
"lightingVariations",
|
|
266
|
+
"outfitVariations",
|
|
267
|
+
"detailCloseups"
|
|
268
|
+
];
|
|
269
|
+
function characterVariantAssetArrays(data) {
|
|
270
|
+
const out = {};
|
|
271
|
+
for (const bucket of CHARACTER_VARIANT_ASSET_BUCKETS) {
|
|
272
|
+
const value = data?.[bucket];
|
|
273
|
+
out[bucket] = Array.isArray(value) ? value : [];
|
|
274
|
+
}
|
|
275
|
+
return out;
|
|
276
|
+
}
|
|
277
|
+
function characterSheetRefItems(sheets) {
|
|
278
|
+
if (!Array.isArray(sheets)) return [];
|
|
279
|
+
return sheets.flatMap((s) => {
|
|
280
|
+
const sheet = s;
|
|
281
|
+
if (!sheet || typeof sheet.url !== "string" || !sheet.url) return [];
|
|
282
|
+
const type = typeof sheet.type === "string" && sheet.type ? sheet.type : "sheet";
|
|
283
|
+
const skin = typeof sheet.skin === "string" && sheet.skin ? ` ${sheet.skin}` : "";
|
|
284
|
+
return [{ name: `${type}${skin}`, url: sheet.url }];
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
var BOARD_SHIM_KEY = "studioBoard";
|
|
288
|
+
var BOARD_SHIM_PREFIX = "studioBoard:";
|
|
289
|
+
function characterBoardItems(data) {
|
|
290
|
+
const column = Array.isArray(data?.boards) ? data.boards.flatMap((b) => {
|
|
291
|
+
const board = b;
|
|
292
|
+
if (!board || typeof board.url !== "string" || !board.url) return [];
|
|
293
|
+
return [{ name: typeof board.name === "string" && board.name ? board.name : "board", url: board.url }];
|
|
294
|
+
}) : [];
|
|
295
|
+
const map = data?.selectedAssetByVariant ?? {};
|
|
296
|
+
const shim = [];
|
|
297
|
+
const legacy = map[BOARD_SHIM_KEY];
|
|
298
|
+
if (typeof legacy === "string" && legacy) shim.push({ name: "board", url: legacy });
|
|
299
|
+
for (const [k, v] of Object.entries(map)) {
|
|
300
|
+
if (k.startsWith(BOARD_SHIM_PREFIX) && typeof v === "string" && v) {
|
|
301
|
+
shim.push({ name: k.slice(BOARD_SHIM_PREFIX.length) || "board", url: v });
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const haveNames = new Set(column.map((b) => b.name.toLowerCase()));
|
|
305
|
+
return [...column, ...shim.filter((b) => !haveNames.has(b.name.toLowerCase()))];
|
|
306
|
+
}
|
|
307
|
+
function characterMentionableAssetArrays(data) {
|
|
308
|
+
return {
|
|
309
|
+
...characterVariantAssetArrays(data),
|
|
310
|
+
sheets: characterSheetRefItems(data?.sheets),
|
|
311
|
+
boards: characterBoardItems(data)
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
var CHARACTER_PICKER_DISPLAY_ORDER = [
|
|
315
|
+
"boards",
|
|
316
|
+
"sheets",
|
|
317
|
+
...CHARACTER_VARIANT_ASSET_BUCKETS
|
|
318
|
+
];
|
|
319
|
+
function characterBucketDisplayRank(bucket) {
|
|
320
|
+
if (bucket === void 0) return -1;
|
|
321
|
+
const i = CHARACTER_PICKER_DISPLAY_ORDER.indexOf(bucket);
|
|
322
|
+
return i === -1 ? CHARACTER_PICKER_DISPLAY_ORDER.length : i;
|
|
323
|
+
}
|
|
324
|
+
function sortCharacterEntriesForDisplay(items) {
|
|
325
|
+
const out = [];
|
|
326
|
+
let i = 0;
|
|
327
|
+
while (i < items.length) {
|
|
328
|
+
const slug = items[i].characterSlug;
|
|
329
|
+
if (!slug) {
|
|
330
|
+
out.push(items[i]);
|
|
331
|
+
i++;
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
let j = i;
|
|
335
|
+
while (j < items.length && items[j].characterSlug === slug) j++;
|
|
336
|
+
const run = items.slice(i, j);
|
|
337
|
+
const ranked = run.map((it, k) => ({ it, k, r: characterBucketDisplayRank(it.bucket) })).sort((a, b) => a.r - b.r || a.k - b.k).map((x) => x.it);
|
|
338
|
+
out.push(...ranked);
|
|
339
|
+
i = j;
|
|
340
|
+
}
|
|
341
|
+
return out;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export { CHARACTER_NODE_DEFAULT_LABEL, CHARACTER_NODE_RETIRED_DEFAULT_LABELS, CHARACTER_PICKER_DISPLAY_ORDER, CHARACTER_VARIANT_ASSET_BUCKETS, DEFAULT_USAGE_MODE, RETIRED_CHARACTER_MENTION_SLUGS, UNNAMED_CHARACTER_NAME_PREFIX, USAGE_MODES, aliasRetiredCharacterMentions, characterBoardItems, characterBucketDisplayRank, characterMentionSlug, characterMentionableAssetArrays, characterOwnName, characterSheetRefItems, characterVariantAssetArrays, entityImageUrl, findCharacterMentionTokens, isUsageMode, parseCharacterMentionToken, sortCharacterEntriesForDisplay, usageModeDirective, usageModeIncludesName, usageModeLabel, wiredCharacterBySlug, wiredCharacterKey, wiredCharacterNames, wiredCharacterNamesOf, wiredCharacterSlug, wiredCharacterVideoUrls };
|
|
345
|
+
//# sourceMappingURL=chunk-XSSLNINL.js.map
|
|
346
|
+
//# sourceMappingURL=chunk-XSSLNINL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/character-usage-mode.ts","../src/character-mention-slug.ts","../src/wired-character-names.ts","../src/entity-image-url.ts","../src/character-variant-assets.ts"],"names":["text"],"mappings":";;;AAsBO,IAAM,WAAA,GAAc;AAAA,EACzB,WAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF;AAKO,IAAM,kBAAA,GAAgC;AAGtC,SAAS,YAAY,CAAA,EA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AA,IAAU,MAAM,CAAC,CAAA,CAAE,kBAAkB,IAAA,EAAM,CAAA,EAAA;AAC5D,IAAA,MAAM,GAAA,GAAM,KAAA,CAAM,KAAA,CAAM,CAAA,EAAG,CAAC,CAAA;AAC5B,IAAA,MAAM,MAAA,GAAS,GAAA,CACZ,GAAA,CAAI,CAAC,IAAI,CAAA,MAAO,EAAE,EAAA,EAAI,CAAA,EAAG,CAAA,EAAG,0BAAA,CAA2B,EAAA,CAAG,MAAM,GAAE,CAAE,CAAA,CACpE,IAAA,CAAK,CAAC,CAAA,EAAG,CAAA,KAAM,CAAA,CAAE,CAAA,GAAI,EAAE,CAAA,IAAK,CAAA,CAAE,CAAA,GAAI,CAAA,CAAE,CAAC,CAAA,CACrC,GAAA,CAAI,CAAC,CAAA,KAAM,EAAE,EAAE,CAAA;AAClB,IAAA,GAAA,CAAI,IAAA,CAAK,GAAG,MAAM,CAAA;AAClB,IAAA,CAAA,GAAI,CAAA;AAAA,EACN;AACA,EAAA,OAAO,GAAA;AACT","file":"chunk-XSSLNINL.js","sourcesContent":["/**\n * Character-mention usage modes — describe HOW the AI should consume a\n * referenced character image. The mode shapes the per-image directive in the\n * assembled prompt (see `usageModeDirective`) so the same character reference\n * can act as a full likeness replacement, a face-only crop, a style donor,\n * etc., without needing different upstream images.\n *\n * The mode source-of-truth lives in two places:\n *\n * 1. **Character node default** — `CharacterNodeData.defaultUsageMode`.\n * Set via the small dropdown in the character node's title row.\n * Propagates into every `ConnectedReference` derived from that node.\n *\n * 2. **Per-mention override** — optional 4th segment in the slug,\n * e.g. `@kira:1:smile:face` overrides the character's default for that\n * specific mention. Parsed by `parseCharacterMentionToken` in\n * `character-mention-slug.ts`.\n *\n * Mode resolution at prompt-build time (in `resolveCharacterMentions`):\n * token.usageMode ?? ref.defaultUsageMode ?? \"identical\"\n */\n\nexport const USAGE_MODES = [\n \"identical\",\n \"face\",\n \"face-pose\",\n \"pose\",\n \"emotion\",\n \"style\",\n \"name\",\n \"none\",\n] as const\n\nexport type UsageMode = (typeof USAGE_MODES)[number]\n\n/** Default mode when neither the slug nor the character node specifies one. */\nexport const DEFAULT_USAGE_MODE: UsageMode = \"identical\"\n\n/** Type guard — narrows an arbitrary string to `UsageMode` when valid. */\nexport function isUsageMode(s: string): s is UsageMode {\n return (USAGE_MODES as readonly string[]).includes(s)\n}\n\n/**\n * Return the natural-language directive appended to a per-image bullet for the\n * given mode. The text is intentionally explicit so the model knows exactly\n * which aspects of the reference to take and which to derive from the rest of\n * the prompt.\n *\n * `name` and `none` are minimal-intervention modes that return `null` — the\n * caller emits NO trailing directive for them. `name` still includes the\n * character name in the labeled subject (`Image A (shira)`); `none` suppresses\n * the name as well (bare `Image A`) and excludes the character entirely from\n * the top-level \"Use these characters:\" header when ALL of its mentions are\n * `none`. Use these when the user wants the visual reference to speak for\n * itself without textual bias.\n *\n * Calling sites: `resolveCharacterMentions` (shared/prompt-builder.ts) and the\n * per-character canonical fallback (also in prompt-builder.ts), plus the video\n * mention resolvers on frontend (execute-node.ts) and backend (payload-builder.ts)\n * which mirror the same directive shape.\n */\nexport function usageModeDirective(mode: UsageMode): string | null {\n switch (mode) {\n case \"identical\":\n return \"The subject must remain exactly the same person — preserve 100% facial identity, bone structure, skin tone, proportions, and all unique features. Do not alter eyes, nose, mouth, or facial shape. Maintain natural skin texture, including pores and imperfections.\"\n case \"face\":\n return \"Take ONLY the facial features and expression — preserve 100% facial identity, bone structure, skin tone, and all unique features. Do not alter eyes, nose, mouth, or facial shape. Maintain natural skin texture, including pores and imperfections. Adopt clothing, hair styling, and posture from the rest of the prompt.\"\n case \"face-pose\":\n return \"Take the facial features AND body pose — preserve 100% facial identity, bone structure, skin tone, and all unique features. Do not alter eyes, nose, mouth, or facial shape. Maintain natural skin texture. Adopt clothing and styling from the rest of the prompt.\"\n case \"pose\":\n return \"Take only the body pose and posture — do not copy facial identity, features, or skin. Adopt face, clothing, hair, and all other details from the rest of the prompt.\"\n case \"emotion\":\n return \"Take only the emotional expression — preserve 100% facial identity and all unique features unchanged. Adopt face shape, clothing, body, and pose from the rest of the prompt; transfer only the emotional cue.\"\n case \"style\":\n return \"Take only the visual style and tone (lighting, color grade, atmosphere). Do not copy the subject's identity, clothing, or pose.\"\n case \"name\":\n case \"none\":\n return null\n }\n}\n\n/** Human-readable label for the dropdown / badge UI. */\nexport function usageModeLabel(mode: UsageMode): string {\n switch (mode) {\n case \"identical\": return \"Identical\"\n case \"face\": return \"Face only\"\n case \"face-pose\": return \"Face + Pose\"\n case \"pose\": return \"Pose only\"\n case \"emotion\": return \"Emotion only\"\n case \"style\": return \"Style only\"\n case \"name\": return \"Name only\"\n case \"none\": return \"None\"\n }\n}\n\n/**\n * Whether the labeled subject for this mode should include the character name\n * in parens (e.g. `Image A (shira)`) or stay bare (`Image A`). Only `none`\n * returns false — every other mode (including `name`) keeps the name so the\n * model can correlate the bullet with a named entity in the rest of the\n * prompt. Used by `resolveCharacterMentions` to decide the subject form AND to\n * filter the top-level \"Use these characters:\" header (a character whose\n * mentions are ALL `none` is invisible textually — only the image is\n * attached).\n */\nexport function usageModeIncludesName(mode: UsageMode): boolean {\n return mode !== \"none\"\n}\n","import { isUsageMode, type UsageMode } from \"./character-usage-mode.js\"\n\n/**\n * Slugify a name (character or variant) for use in @-mention tokens.\n * Lowercase, strip non-alphanumeric, collapse runs of dashes.\n */\nexport function characterMentionSlug(name: string): string {\n return name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/-+/g, \"-\")\n .replace(/^-|-$/g, \"\")\n}\n\nexport interface CharacterMentionTokenInfo {\n readonly token: string\n readonly characterSlug: string\n /**\n * 1-based positional index assigned at insertion time by the autocomplete.\n * Lets the user wire a literal-text mention (`@kira:1`) to a final-prompt\n * identity directive (`Image 1 (person) — match exactly…`) so the order in\n * the typed prompt matches the order in the assembled directive block.\n */\n readonly imageIndex: number\n readonly variantSlug: string | null\n /**\n * Optional per-mention usage-mode override (e.g. `:face`, `:style`). When\n * `null`, the assembled directive falls back to the source character node's\n * `defaultUsageMode`, then to the global `\"identical\"` default. Always one\n * of the entries in `USAGE_MODES` when non-null — the parser rejects any\n * other 4-part token.\n */\n readonly usageMode: UsageMode | null\n /**\n * Per-mention ROLE from a NON-MODE 4th segment (Variant + Role Separation) —\n * coexists with a real variant: the variant picks the IMAGE, the role picks\n * the PHRASE (`@kira:1:walking:clothes` → walking image, \"the clothes from\n * …\"). Curated or custom slug, stored verbatim. OMITTED (undefined, not\n * null) for every other shape — 2/3-part tokens and mode-bearing 4-part\n * tokens keep their pre-existing parse byte-identically. Mirrors\n * `LocationMentionTokenInfo.role`.\n */\n readonly role?: string\n /**\n * Additive per-mention identity-lock sentinel (Unified Reference Roles,\n * Task 4 + F4). Tri-state: `true` (trailing `~lock`, force lock ON) |\n * `false` (trailing `~nolock`, force lock OFF — suppresses a ref-level\n * `identityLock.enabled = true`) | ABSENT/undefined (neither sentinel —\n * inherit the ref/source default; byte-identical to the pre-Task-4 shape).\n * Only ACTED UPON by the HYBRID resolvers; the LEGACY resolvers ignore it\n * entirely, so both `~lock` and `~nolock` are inert on the legacy path.\n */\n readonly lock?: boolean\n readonly offset: number\n}\n\n/**\n * Parse a single `@<character>:<index>(:<variant>)?(:<usageMode>)?` token.\n *\n * Supported shapes (each segment after `:` may contain internal dashes, so\n * `@young-kira:1:soft-smile` parses unambiguously as character + index +\n * variant):\n *\n * - `@kira:1` → canonical, default mode\n * - `@kira:1:smile` → variant smile, default mode\n * - `@kira:1:face` → canonical, mode \"face\" (mode is detected by\n * checking the 3rd segment against `USAGE_MODES`)\n * - `@kira:1:smile:face` → variant smile, mode \"face\"\n * - `@kira:1:walking:clothes` → variant walking, ROLE \"clothes\" (Variant +\n * Role Separation: a non-mode 4th segment is a\n * per-mention role — curated or custom — that\n * coexists with the variant)\n *\n * Format change: as of the index-in-slug update, the index segment is required.\n * Bare `@kira` is not a mention; the autocomplete always inserts at least\n * `@kira:N`.\n *\n * `knownCharacterSlugs` is no longer needed for parsing (the structure is\n * unambiguous given the closed `USAGE_MODES` enum) — it remains accepted for\n * API compatibility but ignored here. `findCharacterMentionTokens` still uses\n * it to filter unknown characters.\n */\nexport function parseCharacterMentionToken(\n text: string,\n _knownCharacterSlugs?: readonly string[],\n): { characterSlug: string; imageIndex: number; variantSlug: string | null; usageMode: UsageMode | null; role?: string; lock?: boolean } | null {\n if (!text.startsWith(\"@\")) return null\n let rest = text.slice(1)\n if (rest.length === 0 || !/^[a-z]/.test(rest)) return null\n\n // Additive `~lock` / `~nolock` sentinels (Unified Reference Roles, Task 4 +\n // F4). Strip a trailing `~nolock` (force lock OFF) or `~lock` (force lock ON)\n // BEFORE splitting on \":\" so the segment grammar below is byte-identical to\n // pre-Task-4 (a `~` can never appear inside a segment — the shapes are\n // `[a-z][a-z0-9-]*`). Check `~nolock` FIRST: `\"x~nolock\".endsWith(\"~lock\")` is\n // false (last 5 chars \"olock\"), but the explicit ordering keeps intent clear.\n // A token with NEITHER sentinel is untouched here and gains NO `lock` key\n // (byte-identical). The parsed tri-state `lock` (true/false/undefined) is only\n // honored by the HYBRID resolvers — undefined inherits the ref default, true\n // forces the lock on, false forces it off.\n let lockField: { lock?: boolean } = {}\n if (rest.endsWith(\"~nolock\")) {\n rest = rest.slice(0, -\"~nolock\".length)\n lockField = { lock: false }\n } else if (rest.endsWith(\"~lock\")) {\n rest = rest.slice(0, -\"~lock\".length)\n lockField = { lock: true }\n }\n\n // Format: <character>:<index>(:<variant|mode>)?(:<mode>)?.\n // Splitting on \":\" requires 2–4 parts (no bare @character anymore).\n const parts = rest.split(\":\")\n if (parts.length < 2 || parts.length > 4) return null\n\n const [characterSlug, indexStr, third, fourth] = parts\n if (!/^[a-z][a-z0-9-]*$/.test(characterSlug)) return null\n if (!/^\\d+$/.test(indexStr)) return null\n const imageIndex = parseInt(indexStr, 10)\n if (!Number.isInteger(imageIndex) || imageIndex < 1) return null\n\n // 2-part: kira:1 — canonical, default mode.\n if (parts.length === 2) {\n return { characterSlug, imageIndex, variantSlug: null, usageMode: null, ...lockField }\n }\n\n // 3-part: kira:1:X — X is either a usage-mode keyword or a variant slug.\n // The closed `USAGE_MODES` enum + the variant-slug shape constraint\n // (`[a-z][a-z0-9-]*`) makes this unambiguous. A keyword like \"face\" wins\n // the mode interpretation; anything else is treated as a variant slug.\n if (parts.length === 3) {\n if (!/^[a-z][a-z0-9-]*$/.test(third)) return null\n if (isUsageMode(third)) {\n return { characterSlug, imageIndex, variantSlug: null, usageMode: third, ...lockField }\n }\n return { characterSlug, imageIndex, variantSlug: third, usageMode: null, ...lockField }\n }\n\n // 4-part: kira:1:variant:X — variant + a 4th segment that is EITHER a\n // usage-mode override (today's shape, routed to `usageMode` byte-identically)\n // OR — Variant + Role Separation — any other slug, parsed as a per-mention\n // ROLE that coexists with the variant (the variant picks the image, the role\n // picks the phrase). The `role` key is emitted ONLY on the non-mode branch so\n // mode-bearing tokens keep their exact pre-existing shape.\n if (parts.length === 4) {\n if (!/^[a-z][a-z0-9-]*$/.test(third)) return null\n if (!/^[a-z][a-z0-9-]*$/.test(fourth)) return null\n if (isUsageMode(fourth)) {\n return { characterSlug, imageIndex, variantSlug: third, usageMode: fourth, ...lockField }\n }\n return { characterSlug, imageIndex, variantSlug: third, usageMode: null, role: fourth, ...lockField }\n }\n\n return null\n}\n\n/** Find all @-mentions in a prompt that match a known character slug. */\nexport function findCharacterMentionTokens(\n prompt: string,\n knownCharacterSlugs: readonly string[],\n): CharacterMentionTokenInfo[] {\n const tokens: CharacterMentionTokenInfo[] = []\n // `@<character>:<index>(:<variant|mode>)?(:<mode>)?` preceded by\n // non-alphanumeric (or start of string) to prevent email-like matches.\n // The `\\d+` index segment is required — see `parseCharacterMentionToken`\n // for the rationale. The two optional trailing `:<slug>` groups absorb\n // either `:<variant>`, `:<mode>`, or `:<variant>:<mode>`; the parser\n // disambiguates which segment is which based on `USAGE_MODES`. The optional\n // trailing `(?:~(?:no)?lock)?` absorbs the additive Task-4/F4 identity-lock\n // sentinel (`~lock` force-on OR `~nolock` force-off) INTO the token (so it is\n // spliced out at resolve time); it is optional, so a lock-less token matches\n // byte-identically to before. The `(?![a-z0-9-])` word boundary keeps\n // `~locked` / `~nolockx` literal.\n const regex = /(?:^|[^a-zA-Z0-9])(@[a-z][a-z0-9-]*:\\d+(?::[a-z][a-z0-9-]*)?(?::[a-z][a-z0-9-]*)?(?:~(?:no)?lock(?![a-z0-9-]))?)/g\n const knownSet = new Set(knownCharacterSlugs)\n for (const match of prompt.matchAll(regex)) {\n const token = match[1]\n const offset = (match.index ?? 0) + (match[0].length - token.length)\n const parsed = parseCharacterMentionToken(token)\n if (parsed && knownSet.has(parsed.characterSlug)) {\n tokens.push({ token, ...parsed, offset })\n }\n }\n return tokens\n}\n","import { characterMentionSlug } from \"./character-mention-slug.js\"\nimport { resolveEffectiveSourceType } from \"./entity-image-handle.js\"\n\n/**\n * The label a new Character node is created with (its node definition's\n * `label` and `defaultData.label` read this constant). It is the node's TYPE\n * name, not a character's name: a node still carrying it is unnamed.\n */\nexport const CHARACTER_NODE_DEFAULT_LABEL = \"Character Asset\"\n\n/**\n * Earlier defaults a Character node was created with, also read as \"unnamed\".\n * \"Character\" was the default label from 2026-02-03 until 2026-06-21, so the\n * graphs saved in that window carry it on every node nobody named.\n */\nexport const CHARACTER_NODE_RETIRED_DEFAULT_LABELS: readonly string[] = [\"Character\"]\n\n/** An unnamed wired character is called this, then its number: \"Character 1\". */\nexport const UNNAMED_CHARACTER_NAME_PREFIX = \"Character\"\n\nconst text = (v: unknown): string => (typeof v === \"string\" ? v.trim() : \"\")\n\n/**\n * The name a Character node was GIVEN: its `characterName`, else a label\n * someone typed, trimmed. A label equal to the default (or a retired default)\n * is no name, and neither is a value of only spaces, so an unnamed node\n * returns \"\". Never use it alone to name a WIRED character: two unnamed nodes\n * would both be \"\" — read {@link wiredCharacterNames} instead.\n */\nexport function characterOwnName(data: unknown): string {\n const d = (data ?? {}) as { readonly characterName?: unknown; readonly label?: unknown }\n const name = text(d.characterName)\n if (name) return name\n const label = text(d.label)\n if (!label || label === CHARACTER_NODE_DEFAULT_LABEL || CHARACTER_NODE_RETIRED_DEFAULT_LABELS.includes(label)) return \"\"\n return label\n}\n\n/** One wire into the consuming node, as {@link wiredCharacterNames} reads it. */\nexport interface WiredCharacterSource {\n /** The source node's id (the key of the returned map). */\n readonly key: string\n readonly type: string | null | undefined\n readonly sourceHandle?: string | null\n readonly data: unknown\n}\n\n/** What a wired Character node is called by the node it feeds. */\nexport interface WiredCharacterName {\n /** The name the model reads (the identity bullet, the subject's name). */\n readonly name: string\n /**\n * Its @-mention slug, never empty: the name slugified, or `character-N` for\n * a node numbered in the unnamed sequence (an unnamed node, or a typed name\n * with no Latin letter or digit such as \"マヤ\").\n */\n readonly slug: string\n /** True when the node had no name of its own (its name is \"Character N\"). */\n readonly unnamed: boolean\n}\n\n/**\n * The name and slug of every Character node wired into ONE consuming node, by\n * source key — the one rule the editor's Run, the workflow run and the editor's\n * panels all read, so they name the same characters the same way.\n *\n * - Only a wire that delivers a character counts (a Character node wired by\n * its plain `image` pip is an image, not a character); a node wired twice\n * counts once, at its first wire.\n * - A node with a name of its own ({@link characterOwnName}) keeps it. Two\n * nodes with the same typed name are the same character, as before.\n * - Each unnamed node is its OWN character, numbered in wire order among the\n * unnamed ones: \"Character 1\", \"Character 2\", …, skipping a number whose\n * name (by slug) another wired character already has. Unnamed nodes are\n * never merged.\n * - A typed name with a letter of another script (\"マヤ\", \"מאיה\", \"마야\",\n * and a mixed one such as \"マヤ1\" or \"マヤ A\") is a real name: the model\n * reads it as typed. Which character it is goes by the WHOLE name\n * ({@link scriptNameKey}), never by the Latin part the slug can spell, so\n * \"マヤ1\" and \"レオ1\" are two characters and \"マヤ A\" is not \"A\" (decided\n * 2026-11-13). Two nodes with the same such name are ONE character, as two\n * \"Maya\" nodes are (decided 2026-11-12).\n * - Its mention key: the name's own slug when the name has one and no other\n * wired character claims it (\"マヤ A\" alone stays `@a`); else — no slug\n * (\"マヤ\"), or a slug another character also claims — the next number of\n * the unnamed sequence (`character-N`), taken once per character, so it is\n * included on every path and no two keys collide.\n * - A name whose letters are all Latin is keyed by its slug, exactly as before\n * (\"Maya\", \"maya\" and \"MAYA\" are one character).\n *\n * `sources` are the consuming node's incoming wires in edge-array order.\n */\nexport function wiredCharacterNames(sources: readonly WiredCharacterSource[]): Map<string, WiredCharacterName> {\n const order: Array<{ key: string; own: string; identity: string; ownSlug: string }> = []\n const seen = new Set<string>()\n for (const s of sources) {\n if (seen.has(s.key) || resolveEffectiveSourceType(s.type, s.sourceHandle) !== \"character\") continue\n seen.add(s.key)\n const own = characterOwnName(s.data)\n order.push({ key: s.key, own, identity: characterIdentity(own) ?? `node:${s.key}`, ownSlug: characterMentionSlug(own) })\n }\n // Every character that would go by each slug: a Latin name always keeps its\n // own; another name keeps it only when it is the one character claiming it.\n const claims = new Map<string, Set<string>>()\n for (const { identity, ownSlug } of order) {\n if (!ownSlug) continue\n const set = claims.get(ownSlug) ?? new Set<string>()\n set.add(identity)\n claims.set(ownSlug, set)\n }\n const keepsOwnSlug = (identity: string, ownSlug: string): boolean =>\n !!ownSlug && (identity.startsWith(LATIN_IDENTITY) || claims.get(ownSlug)?.size === 1)\n const taken = new Set<string>()\n for (const { identity, ownSlug } of order) if (keepsOwnSlug(identity, ownSlug)) taken.add(ownSlug)\n const out = new Map<string, WiredCharacterName>()\n /** A character (by identity) → the `character-N` its first node took. */\n const numberedOf = new Map<string, string>()\n let next = 1\n for (const { key, own, identity, ownSlug } of order) {\n if (keepsOwnSlug(identity, ownSlug)) {\n out.set(key, { name: own, slug: ownSlug, unnamed: false })\n continue\n }\n const same = numberedOf.get(identity)\n if (same) {\n out.set(key, { name: own, slug: same, unnamed: false })\n continue\n }\n while (taken.has(numberedSlug(next))) next++\n const slug = numberedSlug(next)\n taken.add(slug)\n numberedOf.set(identity, slug)\n out.set(key, own ? { name: own, slug, unnamed: false } : { name: `${UNNAMED_CHARACTER_NAME_PREFIX} ${next}`, slug, unnamed: true })\n next++\n }\n return out\n}\n\nconst LATIN_IDENTITY = \"latin:\"\n\n/** A letter of a script other than Latin (accented Latin letters are Latin). */\nconst OTHER_SCRIPT_LETTER = /(?=\\p{L})\\P{Script=Latin}/u\n\n/**\n * Which character a typed name is — two names with the same identity are one\n * character. A name whose letters are all Latin: its slug, exactly as before.\n * Any other name with a letter or digit: the whole name ({@link scriptNameKey}).\n * Undefined for no name, or one with no letter or digit at all (\"!!!\"): such a\n * node is a character of its own.\n */\nfunction characterIdentity(name: string): string | undefined {\n const slug = characterMentionSlug(name)\n if (slug && !OTHER_SCRIPT_LETTER.test(name)) return `${LATIN_IDENTITY}${slug}`\n const key = scriptNameKey(name)\n return key ? `script:${key}` : undefined\n}\n\nconst numberedSlug = (n: number): string => characterMentionSlug(`${UNNAMED_CHARACTER_NAME_PREFIX} ${n}`)\n\n/**\n * When two typed names the slug cannot spell are the same name: the rule\n * {@link characterMentionSlug} applies to a Latin name (\"Maya\", \"maya\" and\n * \"MAYA\" are one; so are \"Maya Lee\" and \"maya-lee\"), over every script.\n * Unicode NFKC (half-width \"マヤ\" is \"マヤ\", a decomposed Hangul syllable is the\n * composed one), then case folded (Cyrillic \"Мая\" is \"мая\"), then every run of\n * characters that are no letter, digit or combining mark is one separator.\n * Marks stay: \"ガ\" is not \"カ\". \"\" for a name with no letter or digit at all\n * (\"!!!\"), which never matches another.\n */\nfunction scriptNameKey(name: string): string {\n return name\n .normalize(\"NFKC\")\n .toUpperCase()\n .toLowerCase()\n .replace(/[^\\p{L}\\p{N}\\p{M}]+/gu, \"-\")\n .replace(/^-+|-+$/g, \"\")\n}\n\n/**\n * The slugs an unnamed character's mentions were written with before it was\n * numbered: its default label's (\"Character Asset\") and the retired default's\n * (\"Character\").\n */\nexport const RETIRED_CHARACTER_MENTION_SLUGS: readonly string[] = [\n characterMentionSlug(CHARACTER_NODE_DEFAULT_LABEL),\n ...CHARACTER_NODE_RETIRED_DEFAULT_LABELS.map(characterMentionSlug),\n]\n\n/**\n * A mention saved before unnamed characters were numbered — `@character-asset:1`,\n * `@character:2:smile`, any index, variant, mode or lock — read as the ONE\n * unnamed character wired into the node: its slug replaces the old one. With\n * no unnamed character, or two or more, the text is left as it is (it stays\n * plain text, as nothing resolves it), and so is a retired slug a wired\n * character really goes by. Both run paths apply it to the prompt before they\n * resolve its mentions.\n */\nexport function aliasRetiredCharacterMentions<T extends string | undefined>(\n text: T,\n names: ReadonlyMap<string, WiredCharacterName>,\n): T {\n if (!text || !text.includes(\"@\")) return text\n let lone: WiredCharacterName | undefined\n for (const n of names.values()) {\n if (!n.unnamed) continue\n if (lone) return text\n lone = n\n }\n if (!lone) return text\n const slugs = new Set([...names.values()].map((n) => n.slug))\n let out: string = text\n for (const retired of RETIRED_CHARACTER_MENTION_SLUGS) {\n if (slugs.has(retired)) continue\n // The mention grammar (findCharacterMentionTokens): `@` at the start or\n // after a non-alphanumeric, the slug, then the required `:<index>`.\n out = out.replace(new RegExp(`(^|[^a-zA-Z0-9])@${retired}(?=:\\\\d)`, \"g\"), `$1@${lone.slug}`)\n }\n return out as T\n}\n\n/**\n * {@link wiredCharacterNames} over a graph: the Character nodes wired into\n * `consumerId`, keyed by node id. Pass the edges the run reads (a wire leaving\n * a Teleport already re-pointed at its origin, as both run paths do).\n */\nexport function wiredCharacterNamesOf(\n consumerId: string,\n nodes: ReadonlyArray<{ readonly id: string; readonly type?: string | null; readonly data?: unknown }>,\n edges: ReadonlyArray<{ readonly source: string; readonly target: string; readonly sourceHandle?: string | null }>,\n): Map<string, WiredCharacterName> {\n const byId = new Map(nodes.map((n) => [n.id, n] as const))\n const sources: WiredCharacterSource[] = []\n for (const e of edges) {\n if (e.target !== consumerId) continue\n const n = byId.get(e.source)\n if (!n) continue\n sources.push({ key: n.id, type: n.type, sourceHandle: e.sourceHandle, data: n.data })\n }\n return wiredCharacterNames(sources)\n}\n\n/**\n * The slug a Character node goes by for the node it feeds: its slug in\n * `names`; else — a node wired only by its plain `image` pip, which `names`\n * leaves out — the slug of the wired character that is the same name (the\n * same whole name is the same character, in any script); else a Latin name's\n * own slug, when no wired character of another identity goes by it; else \"\".\n */\nexport function wiredCharacterSlug(\n names: ReadonlyMap<string, WiredCharacterName>,\n nodeId: string,\n data: unknown,\n): string {\n const wired = names.get(nodeId)?.slug\n if (wired) return wired\n const own = characterOwnName(data)\n const identity = characterIdentity(own)\n if (!identity) return \"\"\n // The wired character that IS this name (the same identity, in any script).\n for (const n of names.values()) {\n if (!n.unnamed && characterIdentity(n.name) === identity) return n.slug\n }\n // None: a Latin name still goes by its own slug — unless a wired character\n // of ANOTHER identity goes by it (\"A\" beside a wired \"マヤ A\", decided\n // 2026-11-13), which it must never be filed under.\n if (!identity.startsWith(LATIN_IDENTITY)) return \"\"\n const slug = characterMentionSlug(own)\n for (const n of names.values()) if (n.slug === slug) return \"\"\n return slug\n}\n\n/**\n * The key a Character node's OWN elements (held prop, styling, …) are filed\n * under for the node it feeds, so they land on that character's identity\n * bullet: the slug it goes by ({@link wiredCharacterSlug}); else a key of its\n * own that no character carries, so an unnamed node's elements are never\n * merged into another character's.\n */\nexport function wiredCharacterKey(\n names: ReadonlyMap<string, WiredCharacterName>,\n nodeId: string,\n data: unknown,\n): string {\n return wiredCharacterSlug(names, nodeId, data) || `node:${nodeId}`\n}\n\n/** The wired character whose slug is `slug`, if any (first in wire order). */\nexport function wiredCharacterBySlug(\n names: ReadonlyMap<string, WiredCharacterName>,\n slug: string,\n): { readonly key: string; readonly named: WiredCharacterName } | undefined {\n if (!slug) return undefined\n for (const [key, named] of names) if (named.slug === slug) return { key, named }\n return undefined\n}\n\n/**\n * The clip each Character node wired into `consumerId` carries as its VIDEO\n * subject (its `subjectVideoUrl`, a short single-shot clip of the character),\n * by the slug the node goes by ({@link wiredCharacterNamesOf}) — the key\n * `characterReferencesFromWired` groups a character by. Two nodes that are one\n * character (the same typed name) take the first node's clip, in wire order. A\n * node wired only by its plain `image` pip is no character and gives none.\n * Read it only for a model that takes video subjects.\n */\nexport function wiredCharacterVideoUrls(\n consumerId: string,\n nodes: ReadonlyArray<{ readonly id: string; readonly type?: string | null; readonly data?: unknown }>,\n edges: ReadonlyArray<{ readonly source: string; readonly target: string; readonly sourceHandle?: string | null }>,\n): Map<string, string> {\n const byId = new Map(nodes.map((n) => [n.id, n] as const))\n const out = new Map<string, string>()\n for (const [id, named] of wiredCharacterNamesOf(consumerId, nodes, edges)) {\n const clip = (byId.get(id)?.data as { subjectVideoUrl?: unknown } | undefined)?.subjectVideoUrl\n if (typeof clip === \"string\" && clip.trim() && !out.has(named.slug)) out.set(named.slug, clip.trim())\n }\n return out\n}\n","/**\n * The image an entity node (character / face / object / creature / location)\n * gives out: the asset the user starred as its default, else its active\n * generated result, else its source image — the image its card shows. It is\n * the node's output on both run paths, and it is a wired Character's portrait\n * (its identity reference, a Kling subject's first image), so the character\n * and its output are one image and one image goes out. `||`, so an empty\n * string falls through.\n */\nexport function entityImageUrl(data: unknown): string | undefined {\n const d = (data ?? {}) as {\n readonly defaultAssetUrl?: unknown\n readonly generatedResults?: unknown\n readonly activeResultIndex?: unknown\n readonly sourceImageUrl?: unknown\n }\n const str = (v: unknown): string | undefined => (typeof v === \"string\" && v ? v : undefined)\n const results = Array.isArray(d.generatedResults) ? (d.generatedResults as ReadonlyArray<{ readonly url?: unknown } | null | undefined>) : []\n const active = typeof d.activeResultIndex === \"number\" ? d.activeResultIndex : 0\n return str(d.defaultAssetUrl) || str(results[active]?.url) || str(d.sourceImageUrl)\n}\n","/**\n * Single source of truth for a character's `{name, url}[]` variant-asset buckets\n * — the image/video variants that are expandable into connected references and\n * therefore selectable in the reference picker AND `@`-mentionable in prompts.\n *\n * Historically the expansion list was hardcoded (6 copies across frontend\n * `connected-references.ts` / `connected-refs-builder.ts` / `execute-node.ts` and\n * backend `payload-builder.ts`), so when wardrobe (`outfitVariations`) and detail\n * close-ups (`detailCloseups`) were added — same `{name,url}[]` shape, written by\n * studio.nodaro.ai — they were silently dropped from the picker and `@` list.\n * Drive every expansion site off this constant so a new bucket can't drift again.\n *\n * NOT included (different shapes, handled elsewhere):\n * - `sheets` (`ReferenceSheet[]` — composited multi-panel boards)\n * - `referenceVideosByVariant` (`Record<variant, url[]>` — per-emotion video refs)\n */\nexport const CHARACTER_VARIANT_ASSET_BUCKETS = [\n \"expressions\",\n \"poses\",\n \"motions\",\n \"angles\",\n \"bodyAngles\",\n \"lightingVariations\",\n \"outfitVariations\",\n \"detailCloseups\",\n] as const\n\nexport type CharacterVariantAssetBucket = (typeof CHARACTER_VARIANT_ASSET_BUCKETS)[number]\n\nexport interface CharacterVariantAssetItem {\n readonly name: string\n readonly url: string\n readonly description?: string\n}\n\n/**\n * Build the `{ bucket: items[] }` map for every variant-asset bucket from a\n * character node's data. Missing / non-array buckets coerce to `[]`. One helper\n * for all six expansion sites so the bucket set is defined exactly once.\n */\nexport function characterVariantAssetArrays(\n data: Record<string, unknown> | null | undefined,\n): Record<CharacterVariantAssetBucket, readonly CharacterVariantAssetItem[]> {\n const out = {} as Record<CharacterVariantAssetBucket, readonly CharacterVariantAssetItem[]>\n for (const bucket of CHARACTER_VARIANT_ASSET_BUCKETS) {\n const value = data?.[bucket]\n out[bucket] = Array.isArray(value) ? (value as readonly CharacterVariantAssetItem[]) : []\n }\n return out\n}\n\n/**\n * Map a character's composite reference `sheets` (ReferenceSheet[] — a different\n * shape, with a composite board `url` + `type`/`skin`) into mentionable\n * `{name,url}` items so they too can be picked / `@`-mentioned. Each sheet → one\n * item named `\"<type> <skin>\"` (e.g. \"turnaround studio\"). Drops url-less sheets.\n */\nexport function characterSheetRefItems(sheets: unknown): CharacterVariantAssetItem[] {\n if (!Array.isArray(sheets)) return []\n return sheets.flatMap((s) => {\n const sheet = s as { url?: unknown; type?: unknown; skin?: unknown }\n if (!sheet || typeof sheet.url !== \"string\" || !sheet.url) return []\n const type = typeof sheet.type === \"string\" && sheet.type ? sheet.type : \"sheet\"\n const skin = typeof sheet.skin === \"string\" && sheet.skin ? ` ${sheet.skin}` : \"\"\n return [{ name: `${type}${skin}`, url: sheet.url }]\n })\n}\n\n/** Legacy `selected_asset_by_variant` keys that hold boards born before the\n * `boards` column existed (studio.nodaro.ai's reserved namespace). */\nconst BOARD_SHIM_KEY = \"studioBoard\"\nconst BOARD_SHIM_PREFIX = \"studioBoard:\"\n\n/**\n * Resolve a character's named reference boards from BOTH the `boards` column AND\n * the LEGACY `selected_asset_by_variant` shim (`studioBoard` / `studioBoard:<name>`)\n * — mirroring studio.nodaro.ai's read (entity-boards.ts), which merges both since\n * pre-column boards still live in the shim. Column wins on duplicate name; the\n * unnamed legacy board is named \"board\". Drops url-less entries.\n */\nexport function characterBoardItems(\n data: Record<string, unknown> | null | undefined,\n): CharacterVariantAssetItem[] {\n const column: CharacterVariantAssetItem[] = Array.isArray(data?.boards)\n ? (data!.boards as unknown[]).flatMap((b) => {\n const board = b as { name?: unknown; url?: unknown }\n if (!board || typeof board.url !== \"string\" || !board.url) return []\n return [{ name: typeof board.name === \"string\" && board.name ? board.name : \"board\", url: board.url }]\n })\n : []\n\n const map = (data?.selectedAssetByVariant ?? {}) as Record<string, unknown>\n const shim: CharacterVariantAssetItem[] = []\n const legacy = map[BOARD_SHIM_KEY]\n if (typeof legacy === \"string\" && legacy) shim.push({ name: \"board\", url: legacy })\n for (const [k, v] of Object.entries(map)) {\n if (k.startsWith(BOARD_SHIM_PREFIX) && typeof v === \"string\" && v) {\n shim.push({ name: k.slice(BOARD_SHIM_PREFIX.length) || \"board\", url: v })\n }\n }\n\n const haveNames = new Set(column.map((b) => b.name.toLowerCase()))\n return [...column, ...shim.filter((b) => !haveNames.has(b.name.toLowerCase()))]\n}\n\n/**\n * The COMPLETE set of mentionable character asset arrays: the `{name,url}[]`\n * variant buckets + derived `sheets` and `boards` buckets. This is what the\n * connected-reference / `@`-mention expansion sites iterate, so every\n * studio-produced asset (variants, composite sheets, AND boards — incl. legacy\n * shim boards) surfaces in the reference picker and `@` list.\n */\nexport function characterMentionableAssetArrays(\n data: Record<string, unknown> | null | undefined,\n): Record<string, readonly CharacterVariantAssetItem[]> {\n return {\n ...characterVariantAssetArrays(data),\n sheets: characterSheetRefItems(data?.sheets),\n boards: characterBoardItems(data),\n }\n}\n\n/**\n * DISPLAY order for character asset groups in picker menus (swap-picker,\n * `@` autocomplete) — boards first (the highest-value identity reference),\n * then sheets, then the variant buckets in data order.\n *\n * DISPLAY ONLY. The data-record key order of\n * {@link characterMentionableAssetArrays} is payload-numbering-bearing\n * (`{image:N}` / `@name:N` are positional) and MUST NOT change; menus sort\n * their rendered rows by this rank instead. The guard test asserts this\n * list's key set stays identical to the data record's.\n */\nexport const CHARACTER_PICKER_DISPLAY_ORDER: readonly string[] = [\n \"boards\",\n \"sheets\",\n ...CHARACTER_VARIANT_ASSET_BUCKETS,\n]\n\n/**\n * Display rank for a character entry's asset bucket. Canonical entries\n * (no bucket — the portrait row) lead, then buckets per\n * {@link CHARACTER_PICKER_DISPLAY_ORDER}; unknown buckets sink to the end.\n */\nexport function characterBucketDisplayRank(bucket: string | undefined): number {\n if (bucket === undefined) return -1\n const i = CHARACTER_PICKER_DISPLAY_ORDER.indexOf(bucket)\n return i === -1 ? CHARACTER_PICKER_DISPLAY_ORDER.length : i\n}\n\n/**\n * Sort picker entries for display: within each CONTIGUOUS run of entries\n * sharing a `characterSlug`, order by {@link characterBucketDisplayRank}\n * (stable within a rank); entries without a slug — and run boundaries —\n * stay exactly where they are. Runs (not a global sort) because the flat\n * reference list interleaves characters with uploads/wired images whose\n * positions are meaningful.\n */\nexport function sortCharacterEntriesForDisplay<\n T extends { readonly characterSlug?: string; readonly bucket?: string },\n>(items: readonly T[]): T[] {\n const out: T[] = []\n let i = 0\n while (i < items.length) {\n const slug = items[i].characterSlug\n if (!slug) {\n out.push(items[i])\n i++\n continue\n }\n let j = i\n while (j < items.length && items[j].characterSlug === slug) j++\n const run = items.slice(i, j)\n const ranked = run\n .map((it, k) => ({ it, k, r: characterBucketDisplayRank(it.bucket) }))\n .sort((a, b) => a.r - b.r || a.k - b.k)\n .map((x) => x.it)\n out.push(...ranked)\n i = j\n }\n return out\n}\n"]}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkD34K455O_cjs = require('./chunk-D34K455O.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkFI3HJZWM_cjs = require('./chunk-FI3HJZWM.cjs');
|
|
5
5
|
|
|
6
6
|
// src/input-image-pricing.ts
|
|
7
7
|
function isPricedPerInputImage(model) {
|
|
8
|
-
return typeof model === "string" && (chunkD34K455O_cjs.isGptImage26Tiered(model) ||
|
|
8
|
+
return typeof model === "string" && (chunkD34K455O_cjs.isGptImage26Tiered(model) || chunkFI3HJZWM_cjs.isMinimaxH3Image(model) || chunkFI3HJZWM_cjs.isSeedream55(model));
|
|
9
9
|
}
|
|
10
10
|
function isPricedPerInputImageEdit(model) {
|
|
11
|
-
return typeof model === "string" && (chunkD34K455O_cjs.isGptImage26I2i(model) ||
|
|
11
|
+
return typeof model === "string" && (chunkD34K455O_cjs.isGptImage26I2i(model) || chunkFI3HJZWM_cjs.isMinimaxH3ImageI2i(model) || chunkFI3HJZWM_cjs.isSeedream55I2i(model));
|
|
12
|
+
}
|
|
13
|
+
function priceReadsInputImages(model) {
|
|
14
|
+
return isPricedPerInputImage(model) || chunkFI3HJZWM_cjs.isFlux3Klein(model);
|
|
12
15
|
}
|
|
13
16
|
function pricedSentImages(provider, references, baseImageUrl) {
|
|
14
|
-
const countsBase =
|
|
17
|
+
const countsBase = priceReadsInputImages(provider) && typeof baseImageUrl === "string" && baseImageUrl.length > 0 && !references.includes(baseImageUrl);
|
|
15
18
|
return references.length + (countsBase ? 1 : 0);
|
|
16
19
|
}
|
|
17
20
|
function namesMoodboard(direction) {
|
|
@@ -29,11 +32,11 @@ function pricedEstimatedImages(model, data, wiredImages) {
|
|
|
29
32
|
|
|
30
33
|
// src/safety-retry-policy.ts
|
|
31
34
|
function safetyRetryPolicy(modelId) {
|
|
32
|
-
const entry =
|
|
35
|
+
const entry = chunkFI3HJZWM_cjs.getModel(modelId);
|
|
33
36
|
const safetyFilter = entry?.safetyFilter;
|
|
34
37
|
if (!safetyFilter?.stochastic) return { maxAttempts: 1 };
|
|
35
38
|
const fallback = safetyFilter.fallback;
|
|
36
|
-
if (fallback &&
|
|
39
|
+
if (fallback && chunkFI3HJZWM_cjs.getModel(fallback)) {
|
|
37
40
|
return { maxAttempts: 2, fallback };
|
|
38
41
|
}
|
|
39
42
|
return { maxAttempts: 2 };
|
|
@@ -41,8 +44,9 @@ function safetyRetryPolicy(modelId) {
|
|
|
41
44
|
|
|
42
45
|
exports.isPricedPerInputImage = isPricedPerInputImage;
|
|
43
46
|
exports.isPricedPerInputImageEdit = isPricedPerInputImageEdit;
|
|
47
|
+
exports.priceReadsInputImages = priceReadsInputImages;
|
|
44
48
|
exports.pricedEstimatedImages = pricedEstimatedImages;
|
|
45
49
|
exports.pricedSentImages = pricedSentImages;
|
|
46
50
|
exports.safetyRetryPolicy = safetyRetryPolicy;
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
51
|
+
//# sourceMappingURL=chunk-YD4XY74W.cjs.map
|
|
52
|
+
//# sourceMappingURL=chunk-YD4XY74W.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/input-image-pricing.ts","../src/safety-retry-policy.ts"],"names":["isGptImage26Tiered","isMinimaxH3Image","isSeedream55","isGptImage26I2i","isMinimaxH3ImageI2i","isSeedream55I2i","isFlux3Klein","GPT_IMAGE_2_6_MOODBOARD_MAX_IMAGES","getModel"],"mappings":";;;;;;AAkBO,SAAS,sBAAsB,KAAA,EAAyB;AAC7D,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,KAAaA,oCAAA,CAAmB,KAAK,KAAKC,kCAAA,CAAiB,KAAK,CAAA,IAAKC,8BAAA,CAAa,KAAK,CAAA,CAAA;AACjH;AAGO,SAAS,0BAA0B,KA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A;AAC5E,EAAA,OACE,MAAA,CAAO,IAAA,CAAK,kBAAkB,CAAA,GAC9B,OAAO,IAAA,CAAK,sBAAsB,CAAA,GAClC,MAAA,CAAO,KAAK,SAAS,CAAA,GACrB,MAAA,CAAO,IAAA,CAAK,iBAAiB,CAAA,GAC7B,MAAA,CAAO,IAAA,CAAK,YAAY,CAAA,GACxB,MAAA,CAAO,IAAA,CAAK,cAAc,IAC1B,WAAA,IACC,cAAA,CAAe,IAAA,CAAK,SAAS,IAAIC,oDAAA,GAAqC,CAAA,CAAA,IACtE,yBAAA,CAA0B,KAAK,IAAI,CAAA,GAAI,CAAA,CAAA;AAE5C;;;AClEO,SAAS,kBAAkB,OAAA,EAAoC;AACpE,EAAA,MAAM,KAAA,GAAQC,2BAAS,OAAO,CAAA;AAC9B,EAAA,MAAM,eAAe,KAAA,EAAO,YAAA;AAC5B,EAAA,IAAI,CAAC,YAAA,EAAc,UAAA,EAAY,OAAO,EAAE,aAAa,CAAA,EAAE;AAEvD,EAAA,MAAM,WAAW,YAAA,CAAa,QAAA;AAC9B,EAAA,IAAI,QAAA,IAAYA,0BAAA,CAAS,QAAQ,CAAA,EAAG;AAClC,IAAA,OAAO,EAAE,WAAA,EAAa,CAAA,EAAG,QAAA,EAAS;AAAA,EACpC;AACA,EAAA,OAAO,EAAE,aAAa,CAAA,EAAE;AAC1B","file":"chunk-YD4XY74W.cjs","sourcesContent":["/**\n * The image models whose price depends on how many input images a run sends:\n * GPT Image 2.6 Flare and Sunburst, MiniMax H3 Image and Seedream 5.5. Every place that\n * prices a run counts those images through here, so a model that joins\n * `isPricedPerInputImage` is counted on every path at once. FLUX 3 Klein is\n * counted the same way (`priceReadsInputImages`): its price does not move with\n * the images, but whether any go decides the id it runs, and is priced, on.\n */\nimport {\n GPT_IMAGE_2_6_MOODBOARD_MAX_IMAGES,\n isGptImage26I2i,\n isGptImage26Tiered,\n} from \"./gpt-image-2-6.js\"\nimport { isMinimaxH3Image, isMinimaxH3ImageI2i } from \"./minimax-h3-image.js\"\nimport { isSeedream55, isSeedream55I2i } from \"./seedream-5-5.js\"\nimport { isFlux3Klein } from \"./flux-3-klein.js\"\n\n/** True for a model whose price counts the input images a run sends. */\nexport function isPricedPerInputImage(model: unknown): boolean {\n return typeof model === \"string\" && (isGptImage26Tiered(model) || isMinimaxH3Image(model) || isSeedream55(model))\n}\n\n/** True for the edit id of such a model: it always sends at least its source. */\nexport function isPricedPerInputImageEdit(model: unknown): boolean {\n return typeof model === \"string\" && (isGptImage26I2i(model) || isMinimaxH3ImageI2i(model) || isSeedream55I2i(model))\n}\n\n/**\n * True for a model whose price id reads the input images a run sends: one\n * priced per input image ({@link isPricedPerInputImage}), or FLUX 3 Klein, which\n * runs on its edit id whenever an image goes (its text-to-image endpoint takes\n * none) and is priced on that id, at the same price. Every place that prices a\n * run counts the images through {@link pricedSentImages} and\n * {@link pricedEstimatedImages} for such a model, so the id priced is the id\n * the provider runs.\n */\nexport function priceReadsInputImages(model: unknown): boolean {\n return isPricedPerInputImage(model) || isFlux3Klein(model)\n}\n\n/**\n * The images a Generate Image run sends its provider: its references and, when\n * it edits a base image, that image too (the worker puts it first, unless it is\n * already one of the references). The base is counted only on a model whose\n * price reads the images ({@link priceReadsInputImages}); any other model is\n * priced, and held to its image limit, on its references alone, as before.\n */\nexport function pricedSentImages(\n provider: string | undefined,\n references: readonly string[],\n baseImageUrl: unknown,\n): number {\n const countsBase =\n priceReadsInputImages(provider) &&\n typeof baseImageUrl === \"string\" &&\n baseImageUrl.length > 0 &&\n !references.includes(baseImageUrl)\n return references.length + (countsBase ? 1 : 0)\n}\n\nfunction namesMoodboard(direction: unknown): boolean {\n if (direction === null || typeof direction !== \"object\") return false\n const style = (direction as Record<string, unknown>).style\n return (Array.isArray(style) ? style : [style]).some(\n (value) => typeof value === \"string\" && value.startsWith(\"moodboard:\"),\n )\n}\n\n/**\n * The input images a workflow estimate counts for one node on a model whose\n * price reads them ({@link priceReadsInputImages}): every list on the node, its source or base image, what is\n * wired in, a moodboard its direction names (at the most a moodboard holds),\n * and an edit model's own source. An estimate may over-quote, never under.\n */\nexport function pricedEstimatedImages(\n model: string,\n data: Record<string, unknown>,\n wiredImages: number,\n): number {\n const listed = (v: unknown) => (Array.isArray(v) ? v.length : 0)\n const single = (v: unknown) => (typeof v === \"string\" && v.length > 0 ? 1 : 0)\n return (\n listed(data.referenceImageUrls) +\n listed(data.characterDefinitionIds) +\n listed(data.extraRefs) +\n single(data.referenceImageUrl) +\n single(data.baseImageUrl) +\n single(data.sourceImageUrl) +\n wiredImages +\n (namesMoodboard(data.direction) ? GPT_IMAGE_2_6_MOODBOARD_MAX_IMAGES : 0) +\n (isPricedPerInputImageEdit(model) ? 1 : 0)\n )\n}\n","import { getModel } from \"./model-catalog.js\"\n\n/**\n * Retry/fallback behavior derived from a catalog entry's `safetyFilter`\n * flag (see `ModelCatalogEntry.safetyFilter` in `model-catalog.ts`).\n */\nexport interface SafetyRetryPolicy {\n /** 2 when the model declares `safetyFilter.stochastic`, else 1. */\n maxAttempts: 1 | 2\n /**\n * Catalog model id to offer when the retry also blocks. Only present\n * when the entry declares one AND it resolves to a real catalog entry.\n */\n fallback?: string\n}\n\n/**\n * The provider's safety filter is known to be non-deterministic on some\n * catalog models — a benign prompt can trip it once and pass on an\n * identical retry. For those models the platform retries a blocked\n * request once (`maxAttempts: 2`) before giving up; `fallback` names the\n * catalog model to offer the user when the retry also blocks.\n *\n * Every model not flagged this way — including an unrecognized id —\n * gets a single attempt and no fallback.\n */\nexport function safetyRetryPolicy(modelId: string): SafetyRetryPolicy {\n const entry = getModel(modelId)\n const safetyFilter = entry?.safetyFilter\n if (!safetyFilter?.stochastic) return { maxAttempts: 1 }\n\n const fallback = safetyFilter.fallback\n if (fallback && getModel(fallback)) {\n return { maxAttempts: 2, fallback }\n }\n return { maxAttempts: 2 }\n}\n"]}
|