@nodaro/shared 3.36.0 → 3.38.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-FKQJYMCO.js → chunk-2BHOAYZW.js} +38 -13
- package/dist/chunk-2BHOAYZW.js.map +1 -0
- package/dist/{chunk-BSQCKTXH.cjs → chunk-33QG2DOW.cjs} +6 -6
- package/dist/{chunk-BSQCKTXH.cjs.map → chunk-33QG2DOW.cjs.map} +1 -1
- package/dist/{chunk-NYMOHNYV.js → chunk-5OED47LE.js} +3 -3
- package/dist/{chunk-NYMOHNYV.js.map → chunk-5OED47LE.js.map} +1 -1
- package/dist/{chunk-GZH2SIOF.cjs → chunk-5PCI6M44.cjs} +18 -6
- package/dist/chunk-5PCI6M44.cjs.map +1 -0
- package/dist/chunk-6Q4BS6AR.js +158 -0
- package/dist/chunk-6Q4BS6AR.js.map +1 -0
- package/dist/{chunk-AXUW64ZY.js → chunk-7QITUDRT.js} +3 -3
- package/dist/{chunk-AXUW64ZY.js.map → chunk-7QITUDRT.js.map} +1 -1
- package/dist/{chunk-V3N56Z2S.cjs → chunk-7VDPBFER.cjs} +43 -12
- package/dist/chunk-7VDPBFER.cjs.map +1 -0
- package/dist/{chunk-LT5IJO4Y.cjs → chunk-AQA6YXY5.cjs} +39 -10
- package/dist/chunk-AQA6YXY5.cjs.map +1 -0
- package/dist/{chunk-7AB3AE5L.js → chunk-BDSFMY4X.js} +5 -18
- package/dist/chunk-BDSFMY4X.js.map +1 -0
- package/dist/chunk-BLZBDPZJ.js +16 -0
- package/dist/chunk-BLZBDPZJ.js.map +1 -0
- package/dist/{chunk-TCBHVIMD.js → chunk-CQJYKSXF.js} +18 -6
- package/dist/chunk-CQJYKSXF.js.map +1 -0
- package/dist/{chunk-AWWOQH46.cjs → chunk-D33YBZ3B.cjs} +170 -143
- package/dist/chunk-D33YBZ3B.cjs.map +1 -0
- package/dist/chunk-DBD4BCGH.cjs +169 -0
- package/dist/chunk-DBD4BCGH.cjs.map +1 -0
- package/dist/{chunk-7VQPHLZ5.cjs → chunk-ENFBA33M.cjs} +21 -21
- package/dist/{chunk-7VQPHLZ5.cjs.map → chunk-ENFBA33M.cjs.map} +1 -1
- package/dist/{chunk-BBLE4UTG.cjs → chunk-GLON7ANZ.cjs} +48 -15
- package/dist/chunk-GLON7ANZ.cjs.map +1 -0
- package/dist/{chunk-JSGIEF6Z.cjs → chunk-HSJU5KNR.cjs} +6 -3
- package/dist/chunk-HSJU5KNR.cjs.map +1 -0
- package/dist/{chunk-YN6AXDN5.cjs → chunk-HZ46RDLD.cjs} +9 -24
- package/dist/chunk-HZ46RDLD.cjs.map +1 -0
- package/dist/{chunk-NITAUX3A.cjs → chunk-JLKZEKQ3.cjs} +45 -28
- package/dist/chunk-JLKZEKQ3.cjs.map +1 -0
- package/dist/{chunk-WXNQMJ67.js → chunk-LOWOJN65.js} +100 -6
- package/dist/chunk-LOWOJN65.js.map +1 -0
- package/dist/chunk-M7G66F6H.js +17 -0
- package/dist/chunk-M7G66F6H.js.map +1 -0
- package/dist/chunk-PSAWDKO3.cjs +19 -0
- package/dist/chunk-PSAWDKO3.cjs.map +1 -0
- package/dist/{chunk-2HVFF5SS.js → chunk-QLCSS6DK.js} +165 -141
- package/dist/chunk-QLCSS6DK.js.map +1 -0
- package/dist/{chunk-ANOQWAMU.js → chunk-R6B2UDFR.js} +35 -5
- package/dist/chunk-R6B2UDFR.js.map +1 -0
- package/dist/chunk-T3TOSWVH.cjs +20 -0
- package/dist/chunk-T3TOSWVH.cjs.map +1 -0
- package/dist/{chunk-J65CAOUV.cjs → chunk-TGZJXCLL.cjs} +105 -5
- package/dist/chunk-TGZJXCLL.cjs.map +1 -0
- package/dist/{chunk-56VQ7V3V.js → chunk-THGNDVVH.js} +29 -4
- package/dist/chunk-THGNDVVH.js.map +1 -0
- package/dist/{chunk-XNISPHTZ.js → chunk-WPT5ZTA2.js} +6 -3
- package/dist/chunk-WPT5ZTA2.js.map +1 -0
- package/dist/{chunk-NTHRTRQK.js → chunk-XA53RUSD.js} +22 -6
- package/dist/chunk-XA53RUSD.js.map +1 -0
- package/dist/entries/apps.cjs +38 -38
- package/dist/entries/apps.js +3 -3
- package/dist/entries/credits.cjs +135 -134
- package/dist/entries/credits.js +3 -2
- package/dist/entries/llm-models.cjs +81 -49
- package/dist/entries/llm-models.d.cts +82 -14
- package/dist/entries/llm-models.d.ts +82 -14
- package/dist/entries/llm-models.js +2 -2
- package/dist/entries/media.cjs +66 -42
- package/dist/entries/media.d.cts +145 -4
- package/dist/entries/media.d.ts +145 -4
- package/dist/entries/media.js +1 -1
- package/dist/entries/models.cjs +84 -27
- package/dist/entries/models.d.cts +109 -3
- package/dist/entries/models.d.ts +109 -3
- package/dist/entries/models.js +3 -2
- package/dist/entries/nodes.cjs +204 -199
- package/dist/entries/nodes.d.cts +19 -2
- package/dist/entries/nodes.d.ts +19 -2
- package/dist/entries/nodes.js +5 -4
- package/dist/entries/pipeline.d.cts +2 -2
- package/dist/entries/pipeline.d.ts +2 -2
- package/dist/entries/social.cjs +187 -174
- package/dist/entries/social.d.cts +26 -1
- package/dist/entries/social.d.ts +26 -1
- package/dist/entries/social.js +3 -2
- package/dist/entries/workflow.cjs +157 -144
- package/dist/entries/workflow.d.cts +49 -1
- package/dist/entries/workflow.d.ts +49 -1
- package/dist/entries/workflow.js +4 -3
- package/dist/index.cjs +942 -800
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +14 -12
- package/dist/{scene-node-types-Cvbtf-0a.d.ts → model-constants-C43YS07I.d.cts} +1 -497
- package/dist/{scene-node-types-Cvbtf-0a.d.cts → model-constants-C43YS07I.d.ts} +1 -497
- package/dist/scene-node-types-BSrTKnV7.d.cts +499 -0
- package/dist/scene-node-types-BSrTKnV7.d.ts +499 -0
- package/package.json +1 -1
- package/src/__tests__/cast-swap-limits.test.ts +40 -0
- package/src/__tests__/fixtures/root-exports.baseline.json +6 -0
- package/src/__tests__/llm-models.test.ts +61 -18
- package/src/__tests__/llm-price-key.test.ts +55 -0
- package/src/__tests__/node-preset-extract.test.ts +10 -0
- package/src/__tests__/node-runtime-keys.test.ts +21 -2
- package/src/__tests__/render-output.test.ts +64 -0
- package/src/__tests__/schedule-retry.test.ts +35 -0
- package/src/__tests__/scrape-analysis-pricing.test.ts +41 -0
- package/src/__tests__/suno-separate.test.ts +78 -0
- package/src/__tests__/video-mask.test.ts +27 -0
- package/src/cast-swap-limits.ts +52 -0
- package/src/entries/llm-models.ts +7 -0
- package/src/entries/models.ts +26 -1
- package/src/entries/social.ts +1 -0
- package/src/entries/workflow.ts +6 -0
- package/src/generated/unit-contracts.ts +8 -2
- package/src/llm-models.ts +111 -23
- package/src/mask-composite.ts +80 -3
- package/src/node-preset-extract.ts +4 -0
- package/src/node-runtime-keys.ts +7 -0
- package/src/render-output.ts +36 -1
- package/src/schedule-retry.ts +71 -0
- package/src/scrape-analysis-pricing.ts +73 -0
- package/src/script-model.ts +21 -0
- package/src/suno-separate.ts +210 -0
- package/src/video-mask.ts +97 -0
- package/dist/chunk-2HVFF5SS.js.map +0 -1
- package/dist/chunk-56VQ7V3V.js.map +0 -1
- package/dist/chunk-7AB3AE5L.js.map +0 -1
- package/dist/chunk-ANOQWAMU.js.map +0 -1
- package/dist/chunk-AWWOQH46.cjs.map +0 -1
- package/dist/chunk-BBLE4UTG.cjs.map +0 -1
- package/dist/chunk-FG4E7MTG.cjs +0 -4
- package/dist/chunk-FG4E7MTG.cjs.map +0 -1
- package/dist/chunk-FKQJYMCO.js.map +0 -1
- package/dist/chunk-GZH2SIOF.cjs.map +0 -1
- package/dist/chunk-J65CAOUV.cjs.map +0 -1
- package/dist/chunk-JSGIEF6Z.cjs.map +0 -1
- package/dist/chunk-LT5IJO4Y.cjs.map +0 -1
- package/dist/chunk-NITAUX3A.cjs.map +0 -1
- package/dist/chunk-NTHRTRQK.js.map +0 -1
- package/dist/chunk-TCBHVIMD.js.map +0 -1
- package/dist/chunk-TZE673G6.js +0 -3
- package/dist/chunk-TZE673G6.js.map +0 -1
- package/dist/chunk-V3N56Z2S.cjs.map +0 -1
- package/dist/chunk-WXNQMJ67.js.map +0 -1
- package/dist/chunk-XNISPHTZ.js.map +0 -1
- package/dist/chunk-YN6AXDN5.cjs.map +0 -1
package/src/entries/social.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* `@nodaro/shared`.
|
|
7
7
|
*/
|
|
8
8
|
export { normalizePinterestUrl } from "../pinterest-url.js"
|
|
9
|
+
export { SCRAPE_ANALYSIS_FEATURE, scrapeAnalysisPriceParts, scrapeAnalysisQuoteId, type ScrapeAnalysisPriceParts } from "../scrape-analysis-pricing.js"
|
|
9
10
|
export { SCRAPER_OUTPUT_FIELDS } from "../scraper-output-schemas.js"
|
|
10
11
|
export {
|
|
11
12
|
SOCIAL_POST_NODE_TYPES,
|
package/src/entries/workflow.ts
CHANGED
|
@@ -133,6 +133,12 @@ export {
|
|
|
133
133
|
type ScheduleSpec,
|
|
134
134
|
type LocalTime,
|
|
135
135
|
} from "../schedule-rules.js"
|
|
136
|
+
export {
|
|
137
|
+
SCHEDULE_RETRY_LIMITS,
|
|
138
|
+
SCHEDULE_RETRY_DEFAULTS,
|
|
139
|
+
normalizeScheduleRetry,
|
|
140
|
+
type ScheduleRetry,
|
|
141
|
+
} from "../schedule-retry.js"
|
|
136
142
|
export { VARIABLES_HANDLE_ID, buildConditionVariables } from "../condition-variables.js"
|
|
137
143
|
export { extractAllGeneratedResults, extractGeneratedJsonAsList, spreadJsonArrayIfSingleton } from "../generated-results.js"
|
|
138
144
|
export { resolveFieldMappings, resolveLocationFields, type FieldEdgeSource } from "../resolve-field-mappings.js"
|
|
@@ -10,6 +10,7 @@ export const UNIT_CONTRACTS: ReadonlyArray<readonly [type: string, producer: "au
|
|
|
10
10
|
["tighten-episode", "dynamic"], // unit:tighten-episode
|
|
11
11
|
["episode-trailer", "video"], // unit:episode-trailer
|
|
12
12
|
["clip-pack", "dynamic"], // unit:clip-pack
|
|
13
|
+
["speaker-layout", "video"], // unit:speaker-layout
|
|
13
14
|
["remove-audio", "video"], // unit:remove-audio
|
|
14
15
|
["gif-to-video", "video"], // unit:gif-to-video
|
|
15
16
|
]
|
|
@@ -20,6 +21,7 @@ export const UNIT_USE_CASE_TYPES = [
|
|
|
20
21
|
"episode-chapters", // unit:episode-chapters
|
|
21
22
|
"episode-trailer", // unit:episode-trailer
|
|
22
23
|
"clip-pack", // unit:clip-pack
|
|
24
|
+
"speaker-layout", // unit:speaker-layout
|
|
23
25
|
] as const
|
|
24
26
|
|
|
25
27
|
// What each JSON (look) output pip carries (contract.jsonPips) — json-kinds.ts composes these.
|
|
@@ -28,13 +30,16 @@ export const UNIT_JSON_PIPS: ReadonlyArray<readonly [type: string, pips: Readonl
|
|
|
28
30
|
["episode-chapters", { "json": "other" }], // unit:episode-chapters
|
|
29
31
|
["episode-trailer", { "json": "edl" }], // unit:episode-trailer
|
|
30
32
|
["clip-pack", { "json": "edl" }], // unit:clip-pack
|
|
33
|
+
["speaker-layout", { "json": "edl" }], // unit:speaker-layout
|
|
31
34
|
["speaker-map", { "edl": "edl", "json": "other" }], // unit:speaker-map
|
|
32
35
|
]
|
|
33
36
|
|
|
34
37
|
// Input pips that are never a prompt lane (contract.nonPromptInputs) — fan-out-rows.ts composes these.
|
|
35
38
|
export const UNIT_NON_PROMPT_INPUTS: ReadonlyArray<readonly [type: string, handles: ReadonlyArray<string>]> = [
|
|
36
|
-
["tighten-episode", ["music"]], // unit:tighten-episode
|
|
37
|
-
["episode-trailer", ["introCard"]], // unit:episode-trailer
|
|
39
|
+
["tighten-episode", ["music", "masterAudio"]], // unit:tighten-episode
|
|
40
|
+
["episode-trailer", ["introCard", "masterAudio"]], // unit:episode-trailer
|
|
41
|
+
["clip-pack", ["masterAudio"]], // unit:clip-pack
|
|
42
|
+
["speaker-layout", ["masterAudio"]], // unit:speaker-layout
|
|
38
43
|
]
|
|
39
44
|
|
|
40
45
|
// Use-case units whose review-on run ends at a Preview that holds what follows (contract.reviewHold) — preview-gate.ts.
|
|
@@ -42,6 +47,7 @@ export const UNIT_REVIEW_HOLDS: ReadonlyArray<string> = [
|
|
|
42
47
|
"tighten-episode", // unit:tighten-episode
|
|
43
48
|
"episode-trailer", // unit:episode-trailer
|
|
44
49
|
"clip-pack", // unit:clip-pack
|
|
50
|
+
"speaker-layout", // unit:speaker-layout
|
|
45
51
|
]
|
|
46
52
|
|
|
47
53
|
// How a published app shows each unit's result where the producer sets do not decide it (contract.presents) — presentation-utils.ts.
|
package/src/llm-models.ts
CHANGED
|
@@ -1062,6 +1062,40 @@ export const STRUCTURED_VISION_MODELS = LLM_MODELS.filter(
|
|
|
1062
1062
|
(m) => m.supportsImages && m.structuredOutputMode != null,
|
|
1063
1063
|
)
|
|
1064
1064
|
|
|
1065
|
+
/**
|
|
1066
|
+
* Models {@link STRUCTURED_VISION_MODELS} carries that describe-to-picker does
|
|
1067
|
+
* NOT offer — now none.
|
|
1068
|
+
*
|
|
1069
|
+
* Claude Fable 5 was withheld here (production cost audit, 2026-10-20): a
|
|
1070
|
+
* legend-sized read cost far above every tier rung. Metered pricing charges
|
|
1071
|
+
* each read what it really costs (tokens × the model's rate on the lane that
|
|
1072
|
+
* served it), so nothing needs withholding and the set is empty.
|
|
1073
|
+
*
|
|
1074
|
+
* @deprecated Always empty since metered LLM pricing. Kept exported so existing
|
|
1075
|
+
* importers keep compiling; it will be removed in a future major.
|
|
1076
|
+
*/
|
|
1077
|
+
export const DESCRIBE_TO_PICKER_WITHHELD_MODELS: ReadonlySet<string> = new Set<string>()
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* The same (empty) set for the other legend-sized structured reads:
|
|
1081
|
+
* `POST /v1/text-to-picker` and `POST /v1/llm/structured`.
|
|
1082
|
+
*
|
|
1083
|
+
* @deprecated Always empty since metered LLM pricing; see
|
|
1084
|
+
* {@link DESCRIBE_TO_PICKER_WITHHELD_MODELS}.
|
|
1085
|
+
*/
|
|
1086
|
+
export const LLM_STRUCTURED_WITHHELD_MODELS: ReadonlySet<string> = DESCRIBE_TO_PICKER_WITHHELD_MODELS
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* The models describe-to-picker offers and accepts: the structured vision
|
|
1090
|
+
* models minus {@link DESCRIBE_TO_PICKER_WITHHELD_MODELS} (empty — every one). The ONE list the
|
|
1091
|
+
* route gate, the config panel and the quick strip read, so a model the route
|
|
1092
|
+
* refuses is never offered and a saved node naming one is snapped to the
|
|
1093
|
+
* default (the route answers it with a `validation_error`).
|
|
1094
|
+
*/
|
|
1095
|
+
export const DESCRIBE_TO_PICKER_MODELS = STRUCTURED_VISION_MODELS.filter(
|
|
1096
|
+
(m) => !DESCRIBE_TO_PICKER_WITHHELD_MODELS.has(m.id),
|
|
1097
|
+
)
|
|
1098
|
+
|
|
1065
1099
|
/**
|
|
1066
1100
|
* Vendor presentation order + labels for model pickers. Every LlmVendor MUST
|
|
1067
1101
|
* appear in the order list (guarded by a registry test) so a new vendor can't
|
|
@@ -1177,9 +1211,14 @@ export const LLM_FEATURE_DEFAULTS: Record<LlmFeature, string> = {
|
|
|
1177
1211
|
// runs once per returned ad — volume, not depth. Must stay an image-capable
|
|
1178
1212
|
// structured-output model (STRUCTURED_VISION_MODELS); a registry test pins it.
|
|
1179
1213
|
"meta-ads-analysis": "gemini-3.6-flash",
|
|
1180
|
-
//
|
|
1181
|
-
//
|
|
1182
|
-
|
|
1214
|
+
// Economy by decision (2026-10-20, from a production cost audit): the
|
|
1215
|
+
// analyzer's legend-sized prompt made the former default, Opus 5.5 at high
|
|
1216
|
+
// on Anthropic's own API, the platform's most expensive read per run. Gemini
|
|
1217
|
+
// 3.8 Flash reads it on the aggregator at the cheapest rung; Opus 5.5 at
|
|
1218
|
+
// high stays available by choice (LLM_FEATURE_DEFAULT_EFFORTS). Still an
|
|
1219
|
+
// image-capable structured model (DESCRIBE_TO_PICKER_MODELS) — a registry
|
|
1220
|
+
// test pins it.
|
|
1221
|
+
"describe-to-picker": "gemini-3.8-flash",
|
|
1183
1222
|
"qa-check": "gemini-3.6-flash",
|
|
1184
1223
|
"generate-script": "gemini-3.6-flash",
|
|
1185
1224
|
"translate": "gemini-3.6-flash",
|
|
@@ -1193,6 +1232,24 @@ export const LLM_FEATURE_DEFAULTS: Record<LlmFeature, string> = {
|
|
|
1193
1232
|
"content-ideas": "gemini-3.6-flash",
|
|
1194
1233
|
}
|
|
1195
1234
|
|
|
1235
|
+
/**
|
|
1236
|
+
* Billed features with no defaults of their own → the feature whose defaults
|
|
1237
|
+
* (model, {@link LLM_FEATURE_DEFAULT_EFFORTS} effort) their route borrows:
|
|
1238
|
+
* Generate Structured runs on Generate Text's, Text to Picker on Describe to
|
|
1239
|
+
* Picker's, the Choose Best judge on `pick-best-llm`'s. Read it through
|
|
1240
|
+
* {@link llmDefaultsFeature}. Structure only — no prices.
|
|
1241
|
+
*/
|
|
1242
|
+
export const LLM_FEATURE_DEFAULTS_FROM: Readonly<Record<string, LlmFeature>> = {
|
|
1243
|
+
"llm-structured": "llm-chat",
|
|
1244
|
+
"text-to-picker": "describe-to-picker",
|
|
1245
|
+
"reduce:pick-best-llm": "pick-best-llm",
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
/** The feature whose defaults a call of `feature` runs with: its {@link LLM_FEATURE_DEFAULTS_FROM} entry, else itself. */
|
|
1249
|
+
export function llmDefaultsFeature(feature: string): string {
|
|
1250
|
+
return Object.hasOwn(LLM_FEATURE_DEFAULTS_FROM, feature) ? LLM_FEATURE_DEFAULTS_FROM[feature]! : feature
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1196
1253
|
/**
|
|
1197
1254
|
* The model describe-to-picker re-asks ONCE when a Claude analyzer could not
|
|
1198
1255
|
* answer for a platform-side reason: its direct lane down or the platform's
|
|
@@ -1209,39 +1266,43 @@ export const LLM_FEATURE_DEFAULTS: Record<LlmFeature, string> = {
|
|
|
1209
1266
|
export const DESCRIBE_TO_PICKER_FALLBACK_MODEL = "gemini-3.8-flash"
|
|
1210
1267
|
|
|
1211
1268
|
/**
|
|
1212
|
-
* Feature → the reasoning effort
|
|
1213
|
-
* sends none. Read it through
|
|
1214
|
-
*
|
|
1215
|
-
*
|
|
1269
|
+
* Feature → ONE model with a recipe: the reasoning effort it runs at on that
|
|
1270
|
+
* feature when the caller sends none. Read it through
|
|
1271
|
+
* {@link defaultReasoningEffort}, never directly: the effort belongs to that
|
|
1272
|
+
* model, so a call on any other model — the feature's default included, when
|
|
1273
|
+
* it is a different model — must not pick it up.
|
|
1216
1274
|
*/
|
|
1217
|
-
export const LLM_FEATURE_DEFAULT_EFFORTS: Partial<Record<LlmFeature, LlmReasoningEffort>> = {
|
|
1275
|
+
export const LLM_FEATURE_DEFAULT_EFFORTS: Partial<Record<LlmFeature, { model: string; effort: LlmReasoningEffort }>> = {
|
|
1218
1276
|
// Decided 2026-10-09 from the picker bake-off v2: Opus 5.5 at `high` read
|
|
1219
1277
|
// 4/4 portraits with the most attributes per image, ~9 s a read. Its effort
|
|
1220
|
-
// only takes effect on Anthropic's own API (`effortRequiresDirect`), so
|
|
1221
|
-
//
|
|
1222
|
-
|
|
1278
|
+
// only takes effect on Anthropic's own API (`effortRequiresDirect`), so a
|
|
1279
|
+
// read on it runs direct — and bills as such (`llmServesDirect`). It was the
|
|
1280
|
+
// feature's default model until 2026-10-20 (see LLM_FEATURE_DEFAULTS); the
|
|
1281
|
+
// recipe stays with the model, so choosing Opus 5.5 still reads at high.
|
|
1282
|
+
"describe-to-picker": { model: "claude-opus-5.5", effort: "high" },
|
|
1223
1283
|
}
|
|
1224
1284
|
|
|
1225
1285
|
/**
|
|
1226
1286
|
* The reasoning effort a `feature` call runs at when the caller sends none:
|
|
1227
|
-
* the
|
|
1228
|
-
*
|
|
1229
|
-
* (`undefined` / `""`)
|
|
1230
|
-
*
|
|
1287
|
+
* the recipe effort ({@link LLM_FEATURE_DEFAULT_EFFORTS}), but ONLY while the
|
|
1288
|
+
* call runs on the recipe's model — named, or reached because the model was
|
|
1289
|
+
* omitted (`undefined` / `""`) and it is the feature's default. A caller on
|
|
1290
|
+
* any other model with no effort gets `undefined`: that model's Auto.
|
|
1231
1291
|
*
|
|
1232
|
-
* WHY only on
|
|
1233
|
-
*
|
|
1234
|
-
*
|
|
1235
|
-
*
|
|
1292
|
+
* WHY only on that model: the effort is part of that model's recipe, not a
|
|
1293
|
+
* feature policy. Forcing `high` on a Gemini or GPT call that never asked for
|
|
1294
|
+
* it would change the timing of every existing workflow that picked one (and,
|
|
1295
|
+
* on a Claude model, its lane and its bill) — which is also why the feature's
|
|
1296
|
+
* default model gets it only when it IS the recipe's model.
|
|
1236
1297
|
*
|
|
1237
1298
|
* The one place the route, the node's credit badge and its effort pickers
|
|
1238
1299
|
* read, so what runs, what is billed and what is shown cannot disagree.
|
|
1239
1300
|
*/
|
|
1240
1301
|
export function defaultReasoningEffort(feature: string, modelId?: string): LlmReasoningEffort | undefined {
|
|
1241
|
-
const
|
|
1242
|
-
if (!
|
|
1243
|
-
|
|
1244
|
-
return getLlmModel(
|
|
1302
|
+
const recipe = LLM_FEATURE_DEFAULT_EFFORTS[feature as LlmFeature]
|
|
1303
|
+
if (!recipe) return undefined
|
|
1304
|
+
const effective = modelId || LLM_FEATURE_DEFAULTS[feature as LlmFeature]
|
|
1305
|
+
return getLlmModel(effective)?.id === recipe.model ? recipe.effort : undefined
|
|
1245
1306
|
}
|
|
1246
1307
|
|
|
1247
1308
|
/**
|
|
@@ -1507,6 +1568,33 @@ export function llmServesDirect(
|
|
|
1507
1568
|
)
|
|
1508
1569
|
}
|
|
1509
1570
|
|
|
1571
|
+
/**
|
|
1572
|
+
* The price key of a metered LLM call — what a client asks
|
|
1573
|
+
* `POST /v1/credits/model-costs` (or `GET /v1/credits/model-cost?model=`) for
|
|
1574
|
+
* the call's estimated price: `<feature>:<modelId>`, plus `:direct` when the
|
|
1575
|
+
* call is served on the vendor's own API ({@link llmServesDirect}), which is
|
|
1576
|
+
* priced at the direct rate.
|
|
1577
|
+
*
|
|
1578
|
+
* With no `reasoningEffort` the default effort of the feature the call
|
|
1579
|
+
* borrows its defaults from applies ({@link llmDefaultsFeature},
|
|
1580
|
+
* {@link defaultReasoningEffort}) — the effort the call then runs at — so the
|
|
1581
|
+
* key names the lane the call is held and charged on.
|
|
1582
|
+
*
|
|
1583
|
+
* `modelId` must already be resolved: the model the call runs on, never empty
|
|
1584
|
+
* (a caller with no model passes the feature's default, `LLM_FEATURE_DEFAULTS`
|
|
1585
|
+
* of {@link llmDefaultsFeature}). An empty id throws a `TypeError`.
|
|
1586
|
+
*/
|
|
1587
|
+
export function llmPriceKey(
|
|
1588
|
+
feature: string,
|
|
1589
|
+
modelId: string,
|
|
1590
|
+
reasoningEffort?: string,
|
|
1591
|
+
advancedMode?: boolean,
|
|
1592
|
+
): string {
|
|
1593
|
+
if (!modelId) throw new TypeError(`llmPriceKey: modelId must be a resolved model id (feature "${feature}")`)
|
|
1594
|
+
const effort = reasoningEffort ?? defaultReasoningEffort(llmDefaultsFeature(feature), modelId)
|
|
1595
|
+
return llmServesDirect(modelId, effort, advancedMode) ? `${feature}:${modelId}:direct` : `${feature}:${modelId}`
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1510
1598
|
/**
|
|
1511
1599
|
* The credit rungs an LLM feature bills on, cheapest first. `premium-direct` is
|
|
1512
1600
|
* reached only by a premium model served direct (decided 2026-10-08): the bump
|
package/src/mask-composite.ts
CHANGED
|
@@ -10,6 +10,15 @@
|
|
|
10
10
|
* background is fitted to that frame (`backgroundFit`) and loops when shorter;
|
|
11
11
|
* the mask is stretched to the frame and holds its last frame when shorter.
|
|
12
12
|
*
|
|
13
|
+
* `fill` picks what fills the masked area. `"video"` (the default) is the
|
|
14
|
+
* foreground, as above. `"pixelate"` and `"blur"` fill it with the BACKGROUND
|
|
15
|
+
* itself, pixelated or blurred: there is no foreground then (a sent
|
|
16
|
+
* `foregroundUrl` is ignored), so the render follows the BACKGROUND (its size,
|
|
17
|
+
* frame rate and length; `backgroundFit` has nothing to fit), and the run is
|
|
18
|
+
* priced on the background's length. With no foreground the result always
|
|
19
|
+
* carries the background's sound — `audioSource` is ignored there
|
|
20
|
+
* ({@link maskCompositeEffectiveAudioSource}); the canvas hides the control.
|
|
21
|
+
*
|
|
13
22
|
* Priced per started 5 seconds of the result (the foreground's length), like
|
|
14
23
|
* Trim / Loop / Combine Videos: the node's own `model_pricing` row is ONE unit
|
|
15
24
|
* (`maskCompositeUnits` counts them). Worked examples (repeated in
|
|
@@ -23,6 +32,10 @@
|
|
|
23
32
|
export const MASK_COMPOSITE_BACKGROUND_FITS = ["cover", "contain", "stretch"] as const
|
|
24
33
|
export type MaskCompositeBackgroundFit = (typeof MASK_COMPOSITE_BACKGROUND_FITS)[number]
|
|
25
34
|
|
|
35
|
+
/** What fills the masked area: the foreground video, or the background itself pixelated or blurred. */
|
|
36
|
+
export const MASK_COMPOSITE_FILLS = ["video", "pixelate", "blur"] as const
|
|
37
|
+
export type MaskCompositeFill = (typeof MASK_COMPOSITE_FILLS)[number]
|
|
38
|
+
|
|
26
39
|
/** Which sound the result carries. `mix` blends both tracks at equal level. */
|
|
27
40
|
export const MASK_COMPOSITE_AUDIO_SOURCES = ["foreground", "background", "mix", "none"] as const
|
|
28
41
|
export type MaskCompositeAudioSource = (typeof MASK_COMPOSITE_AUDIO_SOURCES)[number]
|
|
@@ -34,7 +47,19 @@ export const MASK_COMPOSITE_BOUNDS = {
|
|
|
34
47
|
/** Grow (+) or shrink (−) the white region, pixels. */
|
|
35
48
|
GROW_MIN: -10,
|
|
36
49
|
GROW_MAX: 10,
|
|
37
|
-
/**
|
|
50
|
+
/** How strongly the foreground covers the background inside the mask
|
|
51
|
+
* (1 = fully, today's output; 0 = not at all). */
|
|
52
|
+
OPACITY_MIN: 0,
|
|
53
|
+
OPACITY_MAX: 1,
|
|
54
|
+
/** Pixelate: the block size as a % of the frame's WIDTH (relative, so a
|
|
55
|
+
* setting looks the same at any resolution); the worker makes the blocks
|
|
56
|
+
* max(2, round(width × pct / 100)) px. 1.25 % = 16 px on a 1280-wide frame. */
|
|
57
|
+
PIXEL_SIZE_PCT_MIN: 0.2,
|
|
58
|
+
PIXEL_SIZE_PCT_MAX: 10,
|
|
59
|
+
/** Blur: the gaussian's sigma as a % of the frame's WIDTH (2 % ≈ sigma 25 px on a 1280-wide frame). */
|
|
60
|
+
BLUR_STRENGTH_PCT_MIN: 0.1,
|
|
61
|
+
BLUR_STRENGTH_PCT_MAX: 5,
|
|
62
|
+
/** The longest leading video (the foreground; the background when `fill` is not video) a run accepts, seconds. */
|
|
38
63
|
MAX_DURATION_SEC: 300,
|
|
39
64
|
} as const
|
|
40
65
|
|
|
@@ -60,6 +85,10 @@ export const MASK_COMPOSITE_DEFAULTS = {
|
|
|
60
85
|
invertMask: false,
|
|
61
86
|
feather: 2,
|
|
62
87
|
grow: 0,
|
|
88
|
+
opacity: 1,
|
|
89
|
+
fill: "video" as MaskCompositeFill,
|
|
90
|
+
pixelSizePct: 1.25,
|
|
91
|
+
blurStrengthPct: 2,
|
|
63
92
|
backgroundFit: "cover" as MaskCompositeBackgroundFit,
|
|
64
93
|
audioSource: "foreground" as MaskCompositeAudioSource,
|
|
65
94
|
} as const
|
|
@@ -68,6 +97,14 @@ export interface MaskCompositeSettings {
|
|
|
68
97
|
readonly invertMask: boolean
|
|
69
98
|
readonly feather: number
|
|
70
99
|
readonly grow: number
|
|
100
|
+
/** Inside the mask: opacity × foreground + (1 − opacity) × background. */
|
|
101
|
+
readonly opacity: number
|
|
102
|
+
/** What fills the masked area (`video` = the foreground). */
|
|
103
|
+
readonly fill: MaskCompositeFill
|
|
104
|
+
/** Pixelate block size, % of the frame width (used when `fill` is `pixelate`). */
|
|
105
|
+
readonly pixelSizePct: number
|
|
106
|
+
/** Blur strength: the gaussian's sigma as a % of the frame width (used when `fill` is `blur`). */
|
|
107
|
+
readonly blurStrengthPct: number
|
|
71
108
|
readonly backgroundFit: MaskCompositeBackgroundFit
|
|
72
109
|
readonly audioSource: MaskCompositeAudioSource
|
|
73
110
|
}
|
|
@@ -75,6 +112,9 @@ export interface MaskCompositeSettings {
|
|
|
75
112
|
const clampInt = (v: unknown, min: number, max: number, fallback: number): number =>
|
|
76
113
|
typeof v === "number" && Number.isFinite(v) ? Math.min(max, Math.max(min, Math.round(v))) : fallback
|
|
77
114
|
|
|
115
|
+
const clampNumber = (v: unknown, min: number, max: number, fallback: number): number =>
|
|
116
|
+
typeof v === "number" && Number.isFinite(v) ? Math.min(max, Math.max(min, v)) : fallback
|
|
117
|
+
|
|
78
118
|
/**
|
|
79
119
|
* Node data (or any loose object) → settings every engine renders with.
|
|
80
120
|
* Unknown enum values fall back to the default and numbers are clamped, so a
|
|
@@ -88,6 +128,10 @@ export function resolveMaskCompositeSettings(data: Readonly<Record<string, unkno
|
|
|
88
128
|
invertMask: typeof data.invertMask === "boolean" ? data.invertMask : d.invertMask,
|
|
89
129
|
feather: clampInt(data.feather, b.FEATHER_MIN, b.FEATHER_MAX, d.feather),
|
|
90
130
|
grow: clampInt(data.grow, b.GROW_MIN, b.GROW_MAX, d.grow),
|
|
131
|
+
opacity: clampNumber(data.opacity, b.OPACITY_MIN, b.OPACITY_MAX, d.opacity),
|
|
132
|
+
fill: maskCompositeFillOf(data),
|
|
133
|
+
pixelSizePct: clampNumber(data.pixelSizePct, b.PIXEL_SIZE_PCT_MIN, b.PIXEL_SIZE_PCT_MAX, d.pixelSizePct),
|
|
134
|
+
blurStrengthPct: clampNumber(data.blurStrengthPct, b.BLUR_STRENGTH_PCT_MIN, b.BLUR_STRENGTH_PCT_MAX, d.blurStrengthPct),
|
|
91
135
|
backgroundFit: (MASK_COMPOSITE_BACKGROUND_FITS as readonly string[]).includes(data.backgroundFit as string)
|
|
92
136
|
? (data.backgroundFit as MaskCompositeBackgroundFit)
|
|
93
137
|
: d.backgroundFit,
|
|
@@ -97,10 +141,43 @@ export function resolveMaskCompositeSettings(data: Readonly<Record<string, unkno
|
|
|
97
141
|
}
|
|
98
142
|
}
|
|
99
143
|
|
|
144
|
+
/** The fill a node, payload or request body asks for: an unknown value is `video` (the default). */
|
|
145
|
+
export function maskCompositeFillOf(data: Readonly<Record<string, unknown>> | null | undefined): MaskCompositeFill {
|
|
146
|
+
const f = data?.fill
|
|
147
|
+
return (MASK_COMPOSITE_FILLS as readonly string[]).includes(f as string) ? (f as MaskCompositeFill) : MASK_COMPOSITE_DEFAULTS.fill
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Does this fill take a foreground video? Only `video` does; pixelate and blur fill from the background. */
|
|
151
|
+
export function maskCompositeUsesForeground(fill: MaskCompositeFill): boolean {
|
|
152
|
+
return fill === "video"
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The input whose size, rate and length the result has (and so the one a run
|
|
157
|
+
* is measured and priced on): the canvas handle — `video` (the foreground) for
|
|
158
|
+
* the video fill, `background-video` for pixelate and blur. The one rule the
|
|
159
|
+
* route, the workflow run, the run estimates and the length walks read.
|
|
160
|
+
*/
|
|
161
|
+
export function maskCompositeLeadHandle(data: Readonly<Record<string, unknown>> | null | undefined): "video" | "background-video" {
|
|
162
|
+
return maskCompositeUsesForeground(maskCompositeFillOf(data)) ? "video" : "background-video"
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The sound a render actually carries. With no foreground (pixelate / blur) it
|
|
167
|
+
* is ALWAYS the background's — the only track there is — whatever
|
|
168
|
+
* `audioSource` says (the canvas hides that control for these fills, so a
|
|
169
|
+
* stored `none` from the Video fill can never silently mute the result).
|
|
170
|
+
*/
|
|
171
|
+
export function maskCompositeEffectiveAudioSource(s: Pick<MaskCompositeSettings, "fill" | "audioSource">): MaskCompositeAudioSource {
|
|
172
|
+
if (maskCompositeUsesForeground(s.fill)) return s.audioSource
|
|
173
|
+
return "background"
|
|
174
|
+
}
|
|
175
|
+
|
|
100
176
|
/** `POST /v1/mask-composite` request body. */
|
|
101
177
|
export interface MaskCompositeRequest extends Partial<MaskCompositeSettings> {
|
|
102
|
-
/** The video whose white-masked region is kept (its size, rate and length lead).
|
|
103
|
-
|
|
178
|
+
/** The video whose white-masked region is kept (its size, rate and length lead).
|
|
179
|
+
* Required when `fill` is `video` (the default); not used by `pixelate` / `blur`. */
|
|
180
|
+
readonly foregroundUrl?: string
|
|
104
181
|
/** The video shown where the mask is black. */
|
|
105
182
|
readonly backgroundUrl: string
|
|
106
183
|
/** The mask video — white = foreground (Video Mask's output). */
|
|
@@ -165,6 +165,10 @@ export const PRESET_EXCLUDED_KEYS: ReadonlySet<string> = new Set([
|
|
|
165
165
|
"extraRefs",
|
|
166
166
|
// editor-only memory of the node's own wiring (an audio recording's lock)
|
|
167
167
|
"settingsBeforeAudio",
|
|
168
|
+
// a use-case node's recordings order (its upstream node ids — this node's
|
|
169
|
+
// wiring) and the cameras report of its last run (a result, never config)
|
|
170
|
+
"mediaOrder",
|
|
171
|
+
"useCaseCameras",
|
|
168
172
|
// structural identifiers
|
|
169
173
|
"routes",
|
|
170
174
|
"routeId",
|
package/src/node-runtime-keys.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SUNO_SEPARATE_META_FIELDS, SUNO_SEPARATE_RESULT_FIELDS } from "./suno-separate.js"
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Field names on a node's `data` that hold runtime / result / transient execution
|
|
3
5
|
* state (job ids, progress, generated outputs, fan-out bookkeeping). These are NEVER
|
|
@@ -175,6 +177,10 @@ export const EXECUTION_DATA_KEYS: ReadonlySet<string> = new Set([
|
|
|
175
177
|
* warnings, length and Re-render marks (`rerenderPending`: the clips pressed for
|
|
176
178
|
* Re-render that no run has rendered yet — run bookkeeping; the press itself,
|
|
177
179
|
* `rerender`, is a choice).
|
|
180
|
+
*
|
|
181
|
+
* Suno Separate: every stem / take URL a run writes and the run's facts (its
|
|
182
|
+
* engine, a Demucs fallback's refusal and reason, its mode) — not `stemName`,
|
|
183
|
+
* the node's instrument setting that the run only echoes back.
|
|
178
184
|
*/
|
|
179
185
|
export const NODE_TYPE_EXECUTION_DATA_KEYS: Readonly<Record<string, readonly string[]>> = {
|
|
180
186
|
"ugc-creator": ["ugcOutputs", "candidates", "optionFailed"],
|
|
@@ -182,6 +188,7 @@ export const NODE_TYPE_EXECUTION_DATA_KEYS: Readonly<Record<string, readonly str
|
|
|
182
188
|
"ugc-clips": ["ugcOutputs", "quote"],
|
|
183
189
|
"ugc-clip": ["ugcOutputs", "clipWarnings", "durationSec", "rerenderPending"],
|
|
184
190
|
"ugc-cards": ["ugcOutputs"],
|
|
191
|
+
"suno-separate": [...SUNO_SEPARATE_RESULT_FIELDS, ...SUNO_SEPARATE_META_FIELDS.filter((key) => key !== "stemName")],
|
|
185
192
|
}
|
|
186
193
|
|
|
187
194
|
/** Is `key` execution data (run state or a run's result) on a node of `type`: global, or that type's own? */
|
package/src/render-output.ts
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
import { normalizeEdl } from "./edl.js"
|
|
24
24
|
import { editPlanBasis } from "./edit-plan-review.js"
|
|
25
25
|
import { defaultEdgeOutputMode } from "./producer-types.js"
|
|
26
|
-
import { resolveIndex, selectListItems, type SelectorFields } from "./selector.js"
|
|
26
|
+
import { isDefaultSelectorConfig, resolveIndex, selectListItems, type SelectorFields } from "./selector.js"
|
|
27
27
|
|
|
28
28
|
/** The quality an Apply EDL render was made at. "proxy" is a Preview. */
|
|
29
29
|
export type RenderQuality = "proxy" | "final"
|
|
@@ -423,6 +423,41 @@ export function renderPlanClipKey(
|
|
|
423
423
|
return renderClipKey(planClips(planNode), row, path.hops)
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
+
/**
|
|
427
|
+
* The row a render run ONCE reads behind a pass-through node whose batch has
|
|
428
|
+
* exactly one delivered row (decided 2026-10-20): Camera Switch ran per clip,
|
|
429
|
+
* every row but row k failed (`""`), and both engines run the render once on
|
|
430
|
+
* the one live value, with no list row — a list with one live value drives
|
|
431
|
+
* nothing (their `> 1` fan-out rule, which stays). That value IS row k of the
|
|
432
|
+
* switch's batch, which is the row space `renderPlanValue` indexes after a
|
|
433
|
+
* pass-through hop, so the render is stamped as if row k drove it.
|
|
434
|
+
*
|
|
435
|
+
* Only when the render's last wire is an Each wire out of a pass-through node
|
|
436
|
+
* (two hops or more, `renderPlanPath`) with no selector of its own — a
|
|
437
|
+
* selector would re-index the batch. `batchOf` reads the pass-through node's
|
|
438
|
+
* batch as the engine holds it (a hole is `""` or `null`). `undefined`
|
|
439
|
+
* otherwise; callers pass `row ?? renderLoneRow(…)`, so a list-driven render
|
|
440
|
+
* and a render wired straight to its plan are untouched.
|
|
441
|
+
*/
|
|
442
|
+
export function renderLoneRow(
|
|
443
|
+
renderId: string,
|
|
444
|
+
nodes: readonly RenderGraphNode[],
|
|
445
|
+
edges: readonly RenderGraphEdge[],
|
|
446
|
+
batchOf: (passNode: RenderGraphNode) => readonly unknown[] | undefined,
|
|
447
|
+
): number | undefined {
|
|
448
|
+
const path = renderPlanPath(renderId, nodes, edges)
|
|
449
|
+
if (!path || path.hops.length < 2) return undefined
|
|
450
|
+
const last = path.hops[path.hops.length - 1]!
|
|
451
|
+
if (!last.each || !isDefaultSelectorConfig(last.edge.data as SelectorFields | undefined)) return undefined
|
|
452
|
+
// The node the last wire hands on from: the target of the hop before it.
|
|
453
|
+
const passId = path.hops[path.hops.length - 2]!.edge.target
|
|
454
|
+
const passNode = nodes.find((n) => n.id === passId)
|
|
455
|
+
const batch = passNode ? batchOf(passNode) : undefined
|
|
456
|
+
if (!batch) return undefined
|
|
457
|
+
const live = batch.flatMap((v, k) => (isHole(v) ? [] : [k]))
|
|
458
|
+
return live.length === 1 ? live[0] : undefined
|
|
459
|
+
}
|
|
460
|
+
|
|
426
461
|
/**
|
|
427
462
|
* The clip key of EVERY iteration of a render's fan-out, row-aligned with its
|
|
428
463
|
* batch: `rows[k]` is iteration k's list row (`FanOutPlan.rows`), as both
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schedule Trigger "Retry on failure" — the ONE shape both sides read.
|
|
3
|
+
*
|
|
4
|
+
* A scheduled run nobody watches can fail for a reason that passes
|
|
5
|
+
* (a provider lane down for a while). With a retry policy on the node, the
|
|
6
|
+
* server runs the failed run again after a wait, a bounded number of times;
|
|
7
|
+
* absent, nothing is retried and the schedule behaves exactly as before.
|
|
8
|
+
*
|
|
9
|
+
* - `afterMinutes` — how long after the failure the retry may start.
|
|
10
|
+
* - `maxAttempts` — how many retries one failed scheduled run may get
|
|
11
|
+
* (the original run is not an attempt).
|
|
12
|
+
* - `cheapLanesOnly` — the model calls made by the run (the original
|
|
13
|
+
* scheduled run AND its retries) that honour the flag stay on the
|
|
14
|
+
* aggregator lane: a call that fails there is not re-asked on the vendor's
|
|
15
|
+
* own, pricier API; it fails, and the retry handles it later. Which node
|
|
16
|
+
* types honour it is listed on the Schedule Trigger's docs page
|
|
17
|
+
* (docs/nodes/input/schedule-trigger.md, "Cheap lanes only").
|
|
18
|
+
*
|
|
19
|
+
* The node stores it as `data.retry`, the server projects it onto the
|
|
20
|
+
* trigger row's `config.retry` (lib/workflow-trigger-sync.ts), and the API
|
|
21
|
+
* takes the same object in `config` (POST / PATCH /v1/workflow-triggers).
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export interface ScheduleRetry {
|
|
25
|
+
/** 5–1440 (a day). */
|
|
26
|
+
readonly afterMinutes: number
|
|
27
|
+
/** 1–5. */
|
|
28
|
+
readonly maxAttempts: number
|
|
29
|
+
readonly cheapLanesOnly: boolean
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const SCHEDULE_RETRY_LIMITS = {
|
|
33
|
+
afterMinutes: [5, 1440] as const,
|
|
34
|
+
maxAttempts: [1, 5] as const,
|
|
35
|
+
} as const
|
|
36
|
+
|
|
37
|
+
export const SCHEDULE_RETRY_DEFAULTS: ScheduleRetry = Object.freeze({
|
|
38
|
+
afterMinutes: 30,
|
|
39
|
+
maxAttempts: 3,
|
|
40
|
+
cheapLanesOnly: true,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
function int(value: unknown): number | null {
|
|
44
|
+
if (typeof value === "number" && Number.isFinite(value)) return Math.trunc(value)
|
|
45
|
+
if (typeof value === "string" && /^-?\d+$/.test(value.trim())) return parseInt(value.trim(), 10)
|
|
46
|
+
return null
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function clamp(value: number | null, [lo, hi]: readonly [number, number], fallback: number): number {
|
|
50
|
+
if (value === null) return fallback
|
|
51
|
+
return Math.min(hi, Math.max(lo, value))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A retry policy as stored on a node or a row → the policy the server runs,
|
|
56
|
+
* or `null` when there is none (absent, `null`, or not an object — the
|
|
57
|
+
* feature off). Out-of-range numbers are clamped, never refused: like a
|
|
58
|
+
* rule, a half-typed value must not silently switch the retry off; the API
|
|
59
|
+
* refuses out-of-range values before they are stored (its Zod), so a stored
|
|
60
|
+
* value reaching the clamp is a node written by hand.
|
|
61
|
+
*/
|
|
62
|
+
export function normalizeScheduleRetry(raw: unknown): ScheduleRetry | null {
|
|
63
|
+
if (!raw || typeof raw !== "object") return null
|
|
64
|
+
const r = raw as Record<string, unknown>
|
|
65
|
+
return {
|
|
66
|
+
afterMinutes: clamp(int(r.afterMinutes), SCHEDULE_RETRY_LIMITS.afterMinutes, SCHEDULE_RETRY_DEFAULTS.afterMinutes),
|
|
67
|
+
maxAttempts: clamp(int(r.maxAttempts), SCHEDULE_RETRY_LIMITS.maxAttempts, SCHEDULE_RETRY_DEFAULTS.maxAttempts),
|
|
68
|
+
// Off only when said so: the default keeps a scheduled run on the cheap lanes.
|
|
69
|
+
cheapLanesOnly: r.cheapLanesOnly !== false,
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two price parts of a Meta Ads or Instagram scrape with AI analysis while
|
|
3
|
+
* metered LLM pricing is on: the scrape's own fixed id (no analysis suffix), and
|
|
4
|
+
* the requested items, each analysed by one call of the analysis model — the
|
|
5
|
+
* item count and model both routes hold through `reserveFixedPlusLlmCalls`
|
|
6
|
+
* (the analysis feature `meta-ads-analysis`, both scrapes). ONE rule for the
|
|
7
|
+
* server's estimate and the editor's, so the two can never price a scrape
|
|
8
|
+
* apart. Pure; null for a scrape without analysis and for any other node.
|
|
9
|
+
*/
|
|
10
|
+
import { LLM_FEATURE_DEFAULTS, llmPriceKey } from "./llm-models.js"
|
|
11
|
+
import { unitQuoteCreditId } from "./credit-estimators/unit-quote.js"
|
|
12
|
+
import {
|
|
13
|
+
META_ADS_SCRAPE_DEFAULT_COUNT,
|
|
14
|
+
META_ADS_SCRAPE_MAX_COUNT,
|
|
15
|
+
META_ADS_SCRAPE_MAX_SOURCES,
|
|
16
|
+
buildMetaAdsScrapeCreditId,
|
|
17
|
+
metaAdsAnalysisTierFrom,
|
|
18
|
+
metaAdsScrapeSources,
|
|
19
|
+
} from "./meta-ads-scrape.js"
|
|
20
|
+
import {
|
|
21
|
+
INSTAGRAM_SCRAPE_DEFAULT_COUNT,
|
|
22
|
+
INSTAGRAM_SCRAPE_MAX_COUNT,
|
|
23
|
+
buildInstagramScrapeCreditId,
|
|
24
|
+
instagramAnalysisTierFrom,
|
|
25
|
+
instagramRequestedCount,
|
|
26
|
+
instagramScrapeMode,
|
|
27
|
+
instagramScrapeSources,
|
|
28
|
+
} from "./instagram-scrape.js"
|
|
29
|
+
|
|
30
|
+
/** The analysis feature both scrapes bill their per-item analysis under. */
|
|
31
|
+
export const SCRAPE_ANALYSIS_FEATURE = "meta-ads-analysis"
|
|
32
|
+
|
|
33
|
+
export interface ScrapeAnalysisPriceParts {
|
|
34
|
+
/** The scrape's own fixed credit id (no analysis suffix). */
|
|
35
|
+
readonly fixedId: string
|
|
36
|
+
/** The model every item's analysis call runs on. */
|
|
37
|
+
readonly analysisModel: string
|
|
38
|
+
/** How many analysis calls the run holds: the items requested. */
|
|
39
|
+
readonly items: number
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const clamp = (n: number, max: number) => Math.min(Math.max(Math.trunc(n) || 1, 1), max)
|
|
43
|
+
|
|
44
|
+
export function scrapeAnalysisPriceParts(node: { readonly type?: string; readonly data?: Record<string, unknown> }): ScrapeAnalysisPriceParts | null {
|
|
45
|
+
const data = node.data ?? {}
|
|
46
|
+
const analysisModel = typeof data.analysisModel === "string" && data.analysisModel ? data.analysisModel : LLM_FEATURE_DEFAULTS[SCRAPE_ANALYSIS_FEATURE]
|
|
47
|
+
if (node.type === "meta-ads-scrape" && metaAdsAnalysisTierFrom(data)) {
|
|
48
|
+
const count = typeof data.count === "number" ? data.count : META_ADS_SCRAPE_DEFAULT_COUNT
|
|
49
|
+
const sources = metaAdsScrapeSources(data)
|
|
50
|
+
return { fixedId: buildMetaAdsScrapeCreditId({ count, sources }), analysisModel, items: clamp(count, META_ADS_SCRAPE_MAX_COUNT) * clamp(sources, META_ADS_SCRAPE_MAX_SOURCES) }
|
|
51
|
+
}
|
|
52
|
+
if (node.type === "instagram-scrape" && instagramAnalysisTierFrom(data)) {
|
|
53
|
+
// The count the route accepts (its Zod: 1..INSTAGRAM_SCRAPE_MAX_COUNT), as the run sends it.
|
|
54
|
+
const stored = typeof data.count === "number" ? data.count : INSTAGRAM_SCRAPE_DEFAULT_COUNT
|
|
55
|
+
const count = instagramRequestedCount(instagramScrapeMode(data.mode as string | undefined), clamp(stored, INSTAGRAM_SCRAPE_MAX_COUNT))
|
|
56
|
+
const sources = instagramScrapeSources(data)
|
|
57
|
+
return { fixedId: buildInstagramScrapeCreditId({ count, sources }), analysisModel, items: Math.max(1, count * sources) }
|
|
58
|
+
}
|
|
59
|
+
return null
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The whole analysis of a scrape as ONE price id: `<analysis key>:<items>u`
|
|
64
|
+
* (`unitQuoteCreditId` on the analysis model's metered price key). The server
|
|
65
|
+
* prices it as the run is held: the key's estimate × the items, rounded up
|
|
66
|
+
* once, marked up once at the call's charge id — so a client quotes the
|
|
67
|
+
* scrape's fixed id plus this, never the served one-call estimate × the items
|
|
68
|
+
* (rounded up per call, and marked up per call). Answered as an estimate while
|
|
69
|
+
* metered pricing is on; `missing` under the rollback.
|
|
70
|
+
*/
|
|
71
|
+
export function scrapeAnalysisQuoteId(parts: ScrapeAnalysisPriceParts): string {
|
|
72
|
+
return unitQuoteCreditId(llmPriceKey(SCRAPE_ANALYSIS_FEATURE, parts.analysisModel), parts.items)
|
|
73
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The model a Generate Script call runs on, in one place: an explicit
|
|
3
|
+
* `llmModel`, else a legacy script `provider` alias (nodes saved before the
|
|
4
|
+
* per-model picker), else the feature's default. The route validates against
|
|
5
|
+
* it, the worker runs it, and the server's estimate and the editor's price it —
|
|
6
|
+
* one rule, so none of them can name a different model.
|
|
7
|
+
*/
|
|
8
|
+
import { LLM_FEATURE_DEFAULTS } from "./llm-models.js"
|
|
9
|
+
import type { ScriptProvider } from "./model-constants.js"
|
|
10
|
+
|
|
11
|
+
/** Legacy provider names → the LLM model ids they ran. */
|
|
12
|
+
export const SCRIPT_LEGACY_PROVIDER_MODELS: Readonly<Record<ScriptProvider, string>> = {
|
|
13
|
+
gemini: "gemini-3.6-flash",
|
|
14
|
+
claude: "claude-sonnet-4.6",
|
|
15
|
+
gpt: "gpt-5.2",
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function resolveScriptModelId(provider?: string, llmModel?: string): string {
|
|
19
|
+
const legacy = provider && Object.hasOwn(SCRIPT_LEGACY_PROVIDER_MODELS, provider) ? SCRIPT_LEGACY_PROVIDER_MODELS[provider as ScriptProvider] : undefined
|
|
20
|
+
return llmModel || legacy || LLM_FEATURE_DEFAULTS["generate-script"]
|
|
21
|
+
}
|