@nodaro/shared 3.16.0 → 3.18.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/index.cjs +401 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +354 -34
- package/dist/index.d.ts +354 -34
- package/dist/index.js +373 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/apply-edl-credit-id.test.ts +25 -0
- package/src/__tests__/exposed-field-keys.test.ts +78 -0
- package/src/__tests__/instagram-scrape.test.ts +62 -0
- package/src/__tests__/node-runtime-keys.test.ts +1 -0
- package/src/__tests__/studio-sequence-owner.test.ts +356 -0
- package/src/__tests__/studio-transient.test.ts +34 -0
- package/src/__tests__/text-to-audio-pricing.test.ts +71 -0
- package/src/__tests__/tts-capabilities.test.ts +237 -0
- package/src/credit-estimators/index.ts +7 -0
- package/src/credit-estimators/text-to-audio.ts +58 -0
- package/src/credit-identifiers.ts +12 -0
- package/src/exposed-field-keys.ts +49 -0
- package/src/index.ts +34 -0
- package/src/instagram-scrape.ts +91 -16
- package/src/model-catalog.ts +121 -2
- package/src/model-constants.ts +26 -16
- package/src/node-runtime-keys.ts +12 -0
- package/src/presentation-utils.ts +5 -1
- package/src/social-search.ts +3 -3
- package/src/studio-transient.ts +337 -36
- package/src/tts-capabilities.ts +75 -0
package/src/instagram-scrape.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Instagram scraper node — shared vocabulary + credit identifiers.
|
|
3
3
|
*
|
|
4
|
-
* Pulls PUBLIC Instagram posts (feed images, carousels, reels) by profile
|
|
5
|
-
* by
|
|
4
|
+
* Pulls PUBLIC Instagram posts (feed images, carousels, reels) by profile, by
|
|
5
|
+
* hashtag or by post link and emits a normalized JSON array. Same shape of contract as the
|
|
6
6
|
* Meta Ads node: everything the backend guard/reservation, the frontend credit
|
|
7
7
|
* badge and the docs formula must agree on lives here.
|
|
8
8
|
*
|
|
9
9
|
* Pricing: 1 credit per REQUESTED post, rounded UP to a fixed tier of
|
|
10
|
-
* `count × sources` (a profile / hashtag is one source, up to 5
|
|
10
|
+
* `count × sources` (a profile / hashtag / post link is one source, up to 5;
|
|
11
|
+
* a post link is always ONE post — see `instagramRequestedCount`). Optional
|
|
11
12
|
* per-post AI analysis folds into the same identifier, priced by the model's
|
|
12
13
|
* tier — reusing the Meta analysis per-item values so the two nodes stay in
|
|
13
14
|
* lockstep.
|
|
@@ -22,7 +23,12 @@ import { classifyCreativeFormat, type MetaAdsFormat } from "./meta-ads-scrape.js
|
|
|
22
23
|
|
|
23
24
|
export const INSTAGRAM_SCRAPE_NODE_TYPE = "instagram-scrape" as const
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
/**
|
|
27
|
+
* `profile` = recent posts of an account, `hashtag` = recent posts under a tag,
|
|
28
|
+
* `post` = exactly the posts whose links are given (one post per link — the
|
|
29
|
+
* "remake this post" entry point, where a full run must land on THAT post).
|
|
30
|
+
*/
|
|
31
|
+
export const INSTAGRAM_SCRAPE_MODES = ["profile", "hashtag", "post"] as const
|
|
26
32
|
export type InstagramScrapeMode = (typeof INSTAGRAM_SCRAPE_MODES)[number]
|
|
27
33
|
|
|
28
34
|
export function isInstagramScrapeMode(value: unknown): value is InstagramScrapeMode {
|
|
@@ -103,17 +109,70 @@ export function isInstagramScrapeCount(value: unknown): value is number {
|
|
|
103
109
|
}
|
|
104
110
|
|
|
105
111
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
112
|
+
* A post link: instagram.com (any subdomain, an optional username segment
|
|
113
|
+
* before the kind) or instagr.am, `/p/`, `/reel/`, `/reels/` or `/tv/`, with or
|
|
114
|
+
* without scheme, query string or trailing slash. Group 1 = the kind, group 2 =
|
|
115
|
+
* the shortcode. The shortcode is CASE-SENSITIVE — two codes that differ only
|
|
116
|
+
* in case are two different posts — so the `i` flag only relaxes the host and
|
|
117
|
+
* the kind; the captured code keeps its case.
|
|
118
|
+
*
|
|
119
|
+
* Instagram's own path words are never a username: `/share/p/<token>/` (the
|
|
120
|
+
* token of a share redirect, not a shortcode), `/stories/…`, `/explore/…` and
|
|
121
|
+
* the kinds themselves would otherwise turn into a wrong post that still bills.
|
|
122
|
+
* `/reels/audio/<id>/` is an audio page, not a reel.
|
|
123
|
+
*/
|
|
124
|
+
const INSTAGRAM_POST_LINK_RE =
|
|
125
|
+
/^(?:https?:\/\/)?(?:[a-z0-9-]+\.)*(?:instagram\.com|instagr\.am)\/(?:(?!(?:share|stories|explore|accounts|direct|p|reels?|tv)\/)[A-Za-z0-9._]+\/)?(p|reels?|tv)\/(?!audio(?:[/?#]|$))([A-Za-z0-9_-]+)/i
|
|
126
|
+
|
|
127
|
+
function parseInstagramPostLink(value: string): { readonly link: string; readonly shortcode: string } | null {
|
|
128
|
+
const match = INSTAGRAM_POST_LINK_RE.exec(value.trim())
|
|
129
|
+
if (!match) return null
|
|
130
|
+
const kind = match[1].toLowerCase()
|
|
131
|
+
const segment = kind === "p" ? "p" : kind === "tv" ? "tv" : "reel"
|
|
132
|
+
return { link: `https://www.instagram.com/${segment}/${match[2]}/`, shortcode: match[2] }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** The canonical link of the post a value points at, or null when it is not an Instagram post link. */
|
|
136
|
+
export function instagramPostLink(value: string): string | null {
|
|
137
|
+
return parseInstagramPostLink(value)?.link ?? null
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Post links, canonicalised, deduped by shortcode (`/p/X` and `/reel/X` are
|
|
142
|
+
* one post), capped at MAX_SOURCES. An item holding several links (an API
|
|
143
|
+
* caller's array entry) is split like typed text.
|
|
144
|
+
*/
|
|
145
|
+
function splitInstagramPostLinks(raw: readonly string[]): string[] {
|
|
146
|
+
const seen = new Set<string>()
|
|
147
|
+
const out: string[] = []
|
|
148
|
+
for (const item of raw.flatMap((entry) => entry.split(/[\s,]+/))) {
|
|
149
|
+
const parsed = parseInstagramPostLink(item)
|
|
150
|
+
if (!parsed || seen.has(parsed.shortcode)) continue
|
|
151
|
+
seen.add(parsed.shortcode)
|
|
152
|
+
out.push(parsed.link)
|
|
153
|
+
if (out.length >= INSTAGRAM_SCRAPE_MAX_SOURCES) break
|
|
154
|
+
}
|
|
155
|
+
return out
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Targets are typed one per line; the route wants an array.
|
|
160
|
+
*
|
|
161
|
+
* - `profile` / `hashtag` (the default — the signature predates post mode):
|
|
162
|
+
* a target can be a bare username / `#tag`, so split on lines / commas only
|
|
163
|
+
* (never whitespace), strip a leading `@` or `#`, dedupe, cap at MAX_SOURCES.
|
|
164
|
+
* - `post`: only Instagram post links count; each is canonicalised (see
|
|
165
|
+
* `instagramPostLink`) and anything else is dropped, so the guard, the
|
|
166
|
+
* reservation and the scrape all see the same set of posts.
|
|
110
167
|
*/
|
|
111
|
-
export function splitInstagramTargets(value: unknown): string[] {
|
|
168
|
+
export function splitInstagramTargets(value: unknown, mode: InstagramScrapeMode = "profile"): string[] {
|
|
169
|
+
const separator = mode === "post" ? /[\s,]+/ : /[\n,]+/
|
|
112
170
|
const raw = Array.isArray(value)
|
|
113
171
|
? value.filter((v): v is string => typeof v === "string")
|
|
114
172
|
: typeof value === "string"
|
|
115
|
-
? value.split(
|
|
173
|
+
? value.split(separator)
|
|
116
174
|
: []
|
|
175
|
+
if (mode === "post") return splitInstagramPostLinks(raw)
|
|
117
176
|
const seen = new Set<string>()
|
|
118
177
|
const out: string[] = []
|
|
119
178
|
for (const item of raw) {
|
|
@@ -171,15 +230,29 @@ export interface InstagramNodeQuoteFields {
|
|
|
171
230
|
readonly analysisModel?: unknown
|
|
172
231
|
}
|
|
173
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Posts requested PER SOURCE: the `count` setting, except in post mode, where
|
|
235
|
+
* every source is one link and so one post (the count setting does not apply).
|
|
236
|
+
* Every price computation goes through this, so the guard, the reservation,
|
|
237
|
+
* the settlement and the node's badge cannot disagree on a post-mode run.
|
|
238
|
+
*/
|
|
239
|
+
export function instagramRequestedCount(mode: InstagramScrapeMode, count: number): number {
|
|
240
|
+
return mode === "post" ? 1 : count
|
|
241
|
+
}
|
|
242
|
+
|
|
174
243
|
/** Billable source count: number of targets (min 1). */
|
|
175
244
|
export function instagramScrapeSources(data: InstagramNodeQuoteFields): number {
|
|
176
|
-
return Math.max(1, Math.min(splitInstagramTargets(data.targets).length, INSTAGRAM_SCRAPE_MAX_SOURCES))
|
|
245
|
+
return Math.max(1, Math.min(splitInstagramTargets(data.targets, instagramScrapeMode(data.mode)).length, INSTAGRAM_SCRAPE_MAX_SOURCES))
|
|
177
246
|
}
|
|
178
247
|
|
|
179
248
|
/** The ONE credit identifier for a node's current settings. */
|
|
180
249
|
export function instagramScrapeCreditIdFromNode(data: InstagramNodeQuoteFields): string {
|
|
181
250
|
const count = typeof data.count === "number" ? data.count : INSTAGRAM_SCRAPE_DEFAULT_COUNT
|
|
182
|
-
return buildInstagramScrapeCreditId({
|
|
251
|
+
return buildInstagramScrapeCreditId({
|
|
252
|
+
count: instagramRequestedCount(instagramScrapeMode(data.mode), count),
|
|
253
|
+
sources: instagramScrapeSources(data),
|
|
254
|
+
analysis: instagramAnalysisTierFrom(data),
|
|
255
|
+
})
|
|
183
256
|
}
|
|
184
257
|
|
|
185
258
|
/**
|
|
@@ -187,16 +260,18 @@ export function instagramScrapeCreditIdFromNode(data: InstagramNodeQuoteFields):
|
|
|
187
260
|
* runs before Zod). Lands on the SAME tier the reservation computes.
|
|
188
261
|
*/
|
|
189
262
|
export function resolveInstagramScrapeCreditId(body: unknown): string {
|
|
190
|
-
const raw = body as { count?: unknown; targets?: unknown; analyze?: unknown; analysisModel?: unknown } | null | undefined
|
|
263
|
+
const raw = body as { mode?: unknown; count?: unknown; targets?: unknown; analyze?: unknown; analysisModel?: unknown } | null | undefined
|
|
191
264
|
if (!raw || typeof raw !== "object") return INSTAGRAM_SCRAPE_FALLBACK_CREDIT_ID
|
|
192
265
|
const count = raw.count === undefined ? INSTAGRAM_SCRAPE_DEFAULT_COUNT : raw.count
|
|
193
266
|
if (!isInstagramScrapeCount(count)) return INSTAGRAM_SCRAPE_FALLBACK_CREDIT_ID
|
|
194
|
-
// Same
|
|
267
|
+
// Same mode resolution as the route's Zod default (absent → profile) and the
|
|
268
|
+
// same splitter the handler uses for `sources` (dedupes, caps at MAX), so the
|
|
195
269
|
// pre-Zod guard and the post-Zod reservation always land on the same tier —
|
|
196
270
|
// a duplicate target bills once, not per copy.
|
|
197
|
-
const
|
|
271
|
+
const mode = instagramScrapeMode(raw.mode)
|
|
272
|
+
const sources = splitInstagramTargets(raw.targets, mode).length
|
|
198
273
|
if (sources < 1) return INSTAGRAM_SCRAPE_FALLBACK_CREDIT_ID
|
|
199
|
-
return buildInstagramScrapeCreditId({ count, sources, analysis: instagramAnalysisTierFrom(raw) })
|
|
274
|
+
return buildInstagramScrapeCreditId({ count: instagramRequestedCount(mode, count), sources, analysis: instagramAnalysisTierFrom(raw) })
|
|
200
275
|
}
|
|
201
276
|
|
|
202
277
|
// Re-export the shared creative-format vocabulary so the node imports one place.
|
package/src/model-catalog.ts
CHANGED
|
@@ -82,6 +82,40 @@ export interface PriceVariant {
|
|
|
82
82
|
note?: string
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/** A voice-setting lever a speech model honours. */
|
|
86
|
+
export type TtsSettingLever = "stability" | "similarity" | "style" | "speed" | "speakerBoost"
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* What a speech model (text-to-speech or dialogue) accepts. The ONE source for
|
|
90
|
+
* every "does this model do X" decision on the text-to-speech lane — tag
|
|
91
|
+
* stripping, which voice settings are sent and shown, the language picker, the
|
|
92
|
+
* per-request character cap. Never compare a provider id by hand; read the sheet
|
|
93
|
+
* through the helpers in `tts-capabilities.ts`.
|
|
94
|
+
*
|
|
95
|
+
* The dialogue model carries a sheet for its own lane too, but until that lane
|
|
96
|
+
* is moved onto it only `maxChars` and `languages` of that sheet are read:
|
|
97
|
+
* editing its other fields changes no dialogue request.
|
|
98
|
+
*/
|
|
99
|
+
export interface TtsCapabilities {
|
|
100
|
+
/** Inline `[audio tags]` are performed. false ⇒ strip them before sending (the model reads them aloud). */
|
|
101
|
+
audioTags: boolean
|
|
102
|
+
/** SSML `<break time="…"/>` tags are honoured. */
|
|
103
|
+
ssmlBreaks: boolean
|
|
104
|
+
/** Voice settings the model honours. A lever not listed is never sent and never shown. */
|
|
105
|
+
levers: readonly TtsSettingLever[]
|
|
106
|
+
/** The request may carry a language code. false ⇒ the field is omitted. */
|
|
107
|
+
languageCode: boolean
|
|
108
|
+
/**
|
|
109
|
+
* Per-request character cap (the total across lines for a dialogue model).
|
|
110
|
+
* `getMaxTtsChars` reads it by exact id and answers {@link TTS_TEXT_MAX}'s 5,000 for
|
|
111
|
+
* the legacy alias and for ids with no sheet, while the sheet lookups answer
|
|
112
|
+
* with the cap of the model such a request actually runs as (turbo's 40,000).
|
|
113
|
+
*/
|
|
114
|
+
maxChars: number
|
|
115
|
+
/** Languages offered in pickers (ISO 639-1; `fil` has no two-letter code). A curated list, not the vendor's full one. */
|
|
116
|
+
languages: readonly string[]
|
|
117
|
+
}
|
|
118
|
+
|
|
85
119
|
export interface ModelCatalogEntry {
|
|
86
120
|
id: string
|
|
87
121
|
kind: ModelKind
|
|
@@ -189,6 +223,11 @@ export interface ModelCatalogEntry {
|
|
|
189
223
|
* the catalog model to offer when it blocks again.
|
|
190
224
|
*/
|
|
191
225
|
safetyFilter?: { stochastic: true; fallback?: string }
|
|
226
|
+
/**
|
|
227
|
+
* Capability sheet of a speech model. REQUIRED on every entry whose `modes`
|
|
228
|
+
* include "tts" or "dialogue" — `tts-capabilities.test.ts` fails otherwise.
|
|
229
|
+
*/
|
|
230
|
+
tts?: TtsCapabilities
|
|
192
231
|
}
|
|
193
232
|
|
|
194
233
|
/**
|
|
@@ -2421,6 +2460,20 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
|
|
|
2421
2460
|
// =============================================================================
|
|
2422
2461
|
// AUDIO MODELS
|
|
2423
2462
|
// =============================================================================
|
|
2463
|
+
// Languages each speech model is offered in. The three lists nest: Multilingual
|
|
2464
|
+
// v2 ⊂ Flash v2.5 ⊂ v3.
|
|
2465
|
+
const TTS_LANGS_MULTILINGUAL_V2 = [
|
|
2466
|
+
"en", "ja", "zh", "de", "hi", "fr", "ko", "pt", "it", "es", "id", "nl", "tr", "fil", "pl",
|
|
2467
|
+
"sv", "bg", "ro", "ar", "cs", "el", "fi", "hr", "ms", "sk", "da", "ta", "uk", "ru",
|
|
2468
|
+
] as const
|
|
2469
|
+
const TTS_LANGS_FLASH_V25 = [...TTS_LANGS_MULTILINGUAL_V2, "hu", "no", "vi"] as const
|
|
2470
|
+
const TTS_LANGS_V3 = [
|
|
2471
|
+
...TTS_LANGS_FLASH_V25,
|
|
2472
|
+
"he", "th", "bn", "ur", "fa", "sr", "lt", "lv", "et", "ka", "is", "ca", "af", "sw",
|
|
2473
|
+
] as const
|
|
2474
|
+
// Every lever the v2 families are sent today.
|
|
2475
|
+
const TTS_LEVERS_V2 = ["stability", "similarity", "style", "speed", "speakerBoost"] as const
|
|
2476
|
+
|
|
2424
2477
|
const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
|
|
2425
2478
|
// ── ElevenLabs TTS ──
|
|
2426
2479
|
"elevenlabs-v3": {
|
|
@@ -2430,11 +2483,42 @@ const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
|
|
|
2430
2483
|
family: "ElevenLabs",
|
|
2431
2484
|
label: "ElevenLabs v3",
|
|
2432
2485
|
series: "ElevenLabs",
|
|
2433
|
-
description: "
|
|
2486
|
+
description: "Expressive ElevenLabs TTS — supports [audio tags] for emotion / pacing. Direct API.",
|
|
2434
2487
|
useCases: ["tts", "voice-over", "narration", "expressive"],
|
|
2435
2488
|
features: ["audio-tags", "voice-cloning"],
|
|
2436
2489
|
pricing: [{ identifier: "elevenlabs-v3", credits: 30 }],
|
|
2437
2490
|
featured: true,
|
|
2491
|
+
tts: {
|
|
2492
|
+
audioTags: true,
|
|
2493
|
+
ssmlBreaks: false,
|
|
2494
|
+
levers: ["stability"],
|
|
2495
|
+
languageCode: true,
|
|
2496
|
+
maxChars: 5000, // official cap (probed: 5,200 chars accepted; keep the clamp)
|
|
2497
|
+
languages: TTS_LANGS_V3,
|
|
2498
|
+
},
|
|
2499
|
+
},
|
|
2500
|
+
"elevenlabs-v4": {
|
|
2501
|
+
id: "elevenlabs-v4",
|
|
2502
|
+
kind: "audio",
|
|
2503
|
+
modes: ["tts"] as const,
|
|
2504
|
+
family: "ElevenLabs",
|
|
2505
|
+
label: "ElevenLabs v4",
|
|
2506
|
+
series: "ElevenLabs",
|
|
2507
|
+
description: "Newest ElevenLabs TTS — [audio tags], stability and similarity control, up to 10,000 characters per request. Direct API.",
|
|
2508
|
+
useCases: ["tts", "voice-over", "narration", "expressive", "long-form"],
|
|
2509
|
+
features: ["audio-tags", "voice-cloning"],
|
|
2510
|
+
pricing: [{ identifier: "elevenlabs-v4", credits: 30 }],
|
|
2511
|
+
tts: {
|
|
2512
|
+
audioTags: true,
|
|
2513
|
+
ssmlBreaks: false,
|
|
2514
|
+
levers: ["stability", "similarity"],
|
|
2515
|
+
languageCode: true,
|
|
2516
|
+
maxChars: 10000,
|
|
2517
|
+
// The curated picker, the same 46 as v3. The model itself lists 85
|
|
2518
|
+
// (it adds e.g. Cantonese, Maltese, Mongolian, Burmese, Uzbek); widening
|
|
2519
|
+
// the picker is its own change — it needs a name and a translation per language.
|
|
2520
|
+
languages: TTS_LANGS_V3,
|
|
2521
|
+
},
|
|
2438
2522
|
},
|
|
2439
2523
|
"elevenlabs-turbo": {
|
|
2440
2524
|
id: "elevenlabs-turbo",
|
|
@@ -2446,6 +2530,14 @@ const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
|
|
|
2446
2530
|
description: "Fast, cheap ElevenLabs TTS via the direct ElevenLabs API. Good for narration.",
|
|
2447
2531
|
useCases: ["tts", "narration", "fast"],
|
|
2448
2532
|
pricing: [{ identifier: "elevenlabs-turbo", credits: 15, note: "per 1K chars" }],
|
|
2533
|
+
tts: {
|
|
2534
|
+
audioTags: false,
|
|
2535
|
+
ssmlBreaks: true,
|
|
2536
|
+
levers: TTS_LEVERS_V2,
|
|
2537
|
+
languageCode: true,
|
|
2538
|
+
maxChars: 40000, // == eleven_flash_v2_5 (functionally equivalent)
|
|
2539
|
+
languages: TTS_LANGS_FLASH_V25,
|
|
2540
|
+
},
|
|
2449
2541
|
},
|
|
2450
2542
|
"elevenlabs-multilingual": {
|
|
2451
2543
|
id: "elevenlabs-multilingual",
|
|
@@ -2457,6 +2549,15 @@ const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
|
|
|
2457
2549
|
description: "Multi-language ElevenLabs TTS via the direct ElevenLabs API.",
|
|
2458
2550
|
useCases: ["tts", "multilingual"],
|
|
2459
2551
|
pricing: [{ identifier: "elevenlabs-multilingual", credits: 30, note: "per 1K chars" }],
|
|
2552
|
+
tts: {
|
|
2553
|
+
audioTags: false,
|
|
2554
|
+
ssmlBreaks: true,
|
|
2555
|
+
levers: TTS_LEVERS_V2,
|
|
2556
|
+
// The API reference: "This parameter is not supported for multilingual_v2 models."
|
|
2557
|
+
languageCode: false,
|
|
2558
|
+
maxChars: 10000,
|
|
2559
|
+
languages: TTS_LANGS_MULTILINGUAL_V2,
|
|
2560
|
+
},
|
|
2460
2561
|
},
|
|
2461
2562
|
"elevenlabs-dialogue": {
|
|
2462
2563
|
id: "elevenlabs-dialogue",
|
|
@@ -2472,6 +2573,16 @@ const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
|
|
|
2472
2573
|
useCases: ["tts", "dialogue", "multi-speaker"],
|
|
2473
2574
|
features: ["audio-tags", "voice-cloning"],
|
|
2474
2575
|
pricing: [{ identifier: "elevenlabs-dialogue", credits: 25, note: "per 1K chars" }],
|
|
2576
|
+
tts: {
|
|
2577
|
+
audioTags: true,
|
|
2578
|
+
ssmlBreaks: false,
|
|
2579
|
+
levers: ["stability"],
|
|
2580
|
+
languageCode: true,
|
|
2581
|
+
// Total across lines. The documented 2,000 is a recommendation, not a
|
|
2582
|
+
// limit (2,500 and 5,000 both probed 200); capped like v3, the model underneath.
|
|
2583
|
+
maxChars: 5000,
|
|
2584
|
+
languages: TTS_LANGS_V3,
|
|
2585
|
+
},
|
|
2475
2586
|
},
|
|
2476
2587
|
|
|
2477
2588
|
// ── ElevenLabs voice utilities ──
|
|
@@ -2589,7 +2700,15 @@ const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
|
|
|
2589
2700
|
series: "ElevenLabs",
|
|
2590
2701
|
description: "Generate short sound effects from a text prompt.",
|
|
2591
2702
|
useCases: ["sfx", "ambient"],
|
|
2592
|
-
|
|
2703
|
+
// Priced per whole second asked for (`elevenlabs-sfx:<n>s`, 1–30 s, rounded
|
|
2704
|
+
// up — textToAudioCreditId); representative rows, every second has its own.
|
|
2705
|
+
// First row = the default variant (a request with no duration bills 5 s).
|
|
2706
|
+
pricing: [
|
|
2707
|
+
{ identifier: "elevenlabs-sfx:5s", credits: 5, note: "5s — also the price when no duration is set; 1 credit per second, rounded up" },
|
|
2708
|
+
{ identifier: "elevenlabs-sfx:1s", credits: 1, note: "1s (min)" },
|
|
2709
|
+
{ identifier: "elevenlabs-sfx:10s", credits: 10, note: "10s" },
|
|
2710
|
+
{ identifier: "elevenlabs-sfx:30s", credits: 30, note: "30s (max)" },
|
|
2711
|
+
],
|
|
2593
2712
|
},
|
|
2594
2713
|
|
|
2595
2714
|
// ── Suno music ──
|
package/src/model-constants.ts
CHANGED
|
@@ -286,28 +286,29 @@ export function getMaxNegativePromptChars(provider: string | undefined): number
|
|
|
286
286
|
return (provider && MAX_NEGATIVE_PROMPT_CHARS_BY_PROVIDER[provider]) || NEGATIVE_PROMPT_MAX
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
-
/**
|
|
289
|
+
/** What {@link getMaxTtsChars} answers for an id with no entry of its own: the legacy `elevenlabs` alias (which runs as turbo — pass `canonicalTtsProvider(id)` to get that model's cap), a missing id and an unknown id. */
|
|
290
290
|
export const TTS_TEXT_MAX = 5000
|
|
291
291
|
|
|
292
292
|
/**
|
|
293
|
-
* Per-model Text-to-Speech character cap (PER REQUEST)
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
* returned 200 — the old "API hard-limits v3 at 3000" report no longer holds).
|
|
297
|
-
* Dialogue's documented 2,000 is a recommendation, not a limit (2,500 and
|
|
298
|
-
* 5,000 total chars both probed 200); we cap at 5000 like v3 — same model
|
|
299
|
-
* underneath. Absent → {@link TTS_TEXT_MAX}.
|
|
293
|
+
* Per-model Text-to-Speech character cap (PER REQUEST). DERIVED from each
|
|
294
|
+
* speech model's capability sheet (`tts.maxChars` in `MODEL_CATALOG`) — set the
|
|
295
|
+
* cap there, never here. Absent → {@link TTS_TEXT_MAX}.
|
|
300
296
|
*/
|
|
301
|
-
export const MAX_TTS_CHARS_BY_PROVIDER: Record<string, number> =
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
297
|
+
export const MAX_TTS_CHARS_BY_PROVIDER: Record<string, number> = Object.fromEntries(
|
|
298
|
+
Object.values(MODEL_CATALOG)
|
|
299
|
+
.filter((m) => m.tts !== undefined)
|
|
300
|
+
.map((m) => [m.id, m.tts!.maxChars]),
|
|
301
|
+
)
|
|
307
302
|
|
|
308
|
-
/**
|
|
303
|
+
/**
|
|
304
|
+
* Max TTS text length (chars) for a provider: verified override, else
|
|
305
|
+
* {@link TTS_TEXT_MAX}. The legacy `elevenlabs` alias has no entry of its own
|
|
306
|
+
* (callers that mean the model it runs as pass `canonicalTtsProvider(id)`), and
|
|
307
|
+
* an id named like an inherited object member (`constructor`) is just unknown.
|
|
308
|
+
*/
|
|
309
309
|
export function getMaxTtsChars(provider: string | undefined): number {
|
|
310
|
-
|
|
310
|
+
const cap = provider && Object.hasOwn(MAX_TTS_CHARS_BY_PROVIDER, provider) ? MAX_TTS_CHARS_BY_PROVIDER[provider] : undefined
|
|
311
|
+
return cap || TTS_TEXT_MAX
|
|
311
312
|
}
|
|
312
313
|
|
|
313
314
|
/**
|
|
@@ -1214,6 +1215,7 @@ export type MotionTransferProviderType = typeof MOTION_TRANSFER_PROVIDERS[number
|
|
|
1214
1215
|
/** Text-to-speech providers */
|
|
1215
1216
|
export const TTS_PROVIDERS = [
|
|
1216
1217
|
"elevenlabs-v3",
|
|
1218
|
+
"elevenlabs-v4",
|
|
1217
1219
|
"elevenlabs-turbo",
|
|
1218
1220
|
"elevenlabs-multilingual",
|
|
1219
1221
|
"elevenlabs",
|
|
@@ -1228,6 +1230,14 @@ export const TEXT_TO_AUDIO_PROVIDERS = [
|
|
|
1228
1230
|
] as const
|
|
1229
1231
|
export type TextToAudioProvider = typeof TEXT_TO_AUDIO_PROVIDERS[number]
|
|
1230
1232
|
|
|
1233
|
+
/**
|
|
1234
|
+
* The Text to Audio engine used when a request names none — the route's
|
|
1235
|
+
* credit reservation, the worker, the orchestrator payload and the editor's
|
|
1236
|
+
* node default all read THIS, so they can never disagree about which model
|
|
1237
|
+
* ran and which one was billed.
|
|
1238
|
+
*/
|
|
1239
|
+
export const DEFAULT_TEXT_TO_AUDIO_PROVIDER: TextToAudioProvider = "elevenlabs-sfx"
|
|
1240
|
+
|
|
1231
1241
|
/** Music generation providers */
|
|
1232
1242
|
export const MUSIC_PROVIDERS = [
|
|
1233
1243
|
// Replicate disabled
|
package/src/node-runtime-keys.ts
CHANGED
|
@@ -51,6 +51,11 @@ export const EXECUTION_DATA_KEYS: ReadonlySet<string> = new Set([
|
|
|
51
51
|
// List fan-out window flag (abandon-guard exemption). Set/cleared by
|
|
52
52
|
// executeNodeForList — purely execution-related, never user-edited.
|
|
53
53
|
"__listRunning",
|
|
54
|
+
// One token per paid run still out on this node that no executor mark
|
|
55
|
+
// covers (the editor's `withRunInFlight`, around each paid call outside the
|
|
56
|
+
// executors). Purely execution-related, never user-edited; also in
|
|
57
|
+
// TRANSIENT_RUNTIME_KEYS.
|
|
58
|
+
"__runsInFlight",
|
|
54
59
|
// Selector node dual-channel outputs (picked + rest). Server-side execution
|
|
55
60
|
// output, not user-edited config.
|
|
56
61
|
"pickedResults",
|
|
@@ -118,6 +123,10 @@ export const EXECUTION_DATA_KEYS: ReadonlySet<string> = new Set([
|
|
|
118
123
|
// and not config: it stops a reload from painting the same run again over
|
|
119
124
|
// edits made since. Persisted for the same reason as resultsClearedAt.
|
|
120
125
|
"resultsRunId",
|
|
126
|
+
// When that run ended the node (beside resultsRunId): the editor's reopen
|
|
127
|
+
// keeps a result a NEWER run left even when its own run listing cannot see
|
|
128
|
+
// that run. Bookkeeping, persisted for the same reason.
|
|
129
|
+
"resultsRunEndedAt",
|
|
121
130
|
// A trigger's last run values (also in TRANSIENT_RUNTIME_KEYS: never saved).
|
|
122
131
|
"__triggerData",
|
|
123
132
|
])
|
|
@@ -149,6 +158,9 @@ export const TRANSIENT_RUNTIME_KEYS: ReadonlySet<string> = new Set([
|
|
|
149
158
|
"__listTotal",
|
|
150
159
|
"__listCompleted",
|
|
151
160
|
"__listRunning",
|
|
161
|
+
// A paid run still out, held by the editor tab that started it. Never
|
|
162
|
+
// saved, so a reload, which has no such run, starts without one.
|
|
163
|
+
"__runsInFlight",
|
|
152
164
|
"_upstreamRefresh",
|
|
153
165
|
"__upstreamCount",
|
|
154
166
|
// Video URL node download ticks. They used to dirty the workflow twice a
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import type { GenericNode, GenericEdge } from "./types.js"
|
|
7
7
|
import type { PresentationItem } from "./presentation-types.js"
|
|
8
8
|
import { AUDIO_PRODUCER_TYPES, VIDEO_PRODUCER_TYPES } from "./producer-types.js"
|
|
9
|
+
import { canonicalizeOverrideKeys } from "./exposed-field-keys.js"
|
|
9
10
|
|
|
10
11
|
// ---------------------------------------------------------------------------
|
|
11
12
|
// Node type sets
|
|
@@ -422,13 +423,16 @@ const MEDIA_INPUT_FIELD_TYPES: ReadonlySet<InputFieldSchema["type"]> = new Set([
|
|
|
422
423
|
*
|
|
423
424
|
* Schema-driven on purpose: a new media input node is covered by its
|
|
424
425
|
* `INPUT_FIELD_MAP` row, with no list to remember here.
|
|
426
|
+
*
|
|
427
|
+
* An override sent under a renamed exposed-field key (an app published before
|
|
428
|
+
* the rename) lands on the node's current field — `canonicalizeOverrideKeys`.
|
|
425
429
|
*/
|
|
426
430
|
export function mergeNodeInputOverrides(
|
|
427
431
|
nodeType: string | undefined,
|
|
428
432
|
data: Record<string, unknown>,
|
|
429
433
|
overrides: Record<string, unknown>,
|
|
430
434
|
): Record<string, unknown> {
|
|
431
|
-
const merged: Record<string, unknown> = { ...data, ...overrides }
|
|
435
|
+
const merged: Record<string, unknown> = { ...data, ...canonicalizeOverrideKeys(nodeType, overrides) }
|
|
432
436
|
const schema = nodeType ? INPUT_FIELD_MAP[nodeType] : undefined
|
|
433
437
|
if (
|
|
434
438
|
schema &&
|
package/src/social-search.ts
CHANGED
|
@@ -19,8 +19,8 @@ export const SOCIAL_SEARCH_NODE_TYPE = "social-search" as const
|
|
|
19
19
|
export const SOCIAL_PLATFORMS = ["tiktok", "instagram", "youtube", "x", "reddit", "linkedin", "meta_ads"] as const
|
|
20
20
|
export type SocialPlatform = (typeof SOCIAL_PLATFORMS)[number]
|
|
21
21
|
|
|
22
|
-
/** `account` is a creator, a LinkedIn company page or
|
|
23
|
-
* `community` is a subreddit. */
|
|
22
|
+
/** `account` is a creator, a LinkedIn company page or person's profile, or
|
|
23
|
+
* a Meta advertiser; `community` is a subreddit. */
|
|
24
24
|
export const SOCIAL_SEARCH_MODES = ["keyword", "account", "community"] as const
|
|
25
25
|
export type SocialSearchMode = (typeof SOCIAL_SEARCH_MODES)[number]
|
|
26
26
|
|
|
@@ -165,7 +165,7 @@ export type SocialSearchParams = {
|
|
|
165
165
|
/** Default `keyword`. */
|
|
166
166
|
readonly mode?: SocialSearchMode
|
|
167
167
|
/** A keyword, or an account: a handle, a profile link, a subreddit, a
|
|
168
|
-
* LinkedIn company page, a Meta advertiser's name or page id. */
|
|
168
|
+
* LinkedIn company page or profile, a Meta advertiser's name or page id. */
|
|
169
169
|
readonly query: string
|
|
170
170
|
/** 20, 40 or 60 results. Default 20. */
|
|
171
171
|
readonly count?: SocialSearchCount
|