@nodaro/shared 3.14.0 → 3.16.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 +1293 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1483 -30
- package/dist/index.d.ts +1483 -30
- package/dist/index.js +1134 -56
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/camera-switch-contract.test.ts +98 -0
- package/src/__tests__/competitors.test.ts +49 -0
- package/src/__tests__/content-recipe-ideas.test.ts +96 -0
- package/src/__tests__/edl-multicam.test.ts +192 -0
- package/src/__tests__/llm-models.test.ts +5 -2
- package/src/__tests__/music-provider.test.ts +17 -0
- package/src/__tests__/node-runtime-keys.test.ts +10 -0
- package/src/__tests__/parameter-node-value.test.ts +2 -1
- package/src/__tests__/per-unit-video-pricing.test.ts +97 -0
- package/src/__tests__/producer-types.test.ts +35 -0
- package/src/__tests__/saved-posts.test.ts +37 -0
- package/src/__tests__/script-settings.test.ts +61 -0
- package/src/__tests__/settings-input.test.ts +252 -0
- package/src/__tests__/social-search.test.ts +243 -0
- package/src/__tests__/studio-take-voice.test.ts +200 -0
- package/src/__tests__/studio-transient.test.ts +37 -0
- package/src/__tests__/sub-gates.test.ts +21 -0
- package/src/__tests__/telegram-account-trigger.test.ts +120 -0
- package/src/__tests__/video-analysis-pricing.test.ts +27 -13
- package/src/__tests__/video-link.test.ts +2 -2
- package/src/__tests__/video-utils.test.ts +89 -83
- package/src/__tests__/workflow-export-strip.test.ts +37 -0
- package/src/camera-switch-contract.ts +166 -0
- package/src/catalog-projection.ts +7 -0
- package/src/competitors.ts +430 -0
- package/src/content-recipe-ideas.ts +69 -0
- package/src/credit-estimators/index.ts +14 -0
- package/src/credit-estimators/ltx-extend.ts +33 -0
- package/src/credit-estimators/ltx-retake.ts +30 -0
- package/src/credit-estimators/video-sfx.ts +41 -0
- package/src/credit-estimators/video-utils.ts +38 -24
- package/src/credit-identifiers.ts +10 -0
- package/src/edl-multicam.ts +220 -0
- package/src/fan-out-rows.ts +7 -2
- package/src/i18n/action-fx.ko.ts +18 -18
- package/src/i18n/action-fx.pt-BR.ts +66 -66
- package/src/i18n/aesthetic.ko.ts +49 -49
- package/src/i18n/aesthetic.pt-BR.ts +14 -14
- package/src/i18n/animals.ko.ts +126 -126
- package/src/i18n/animals.pt-BR.ts +33 -33
- package/src/i18n/atmosphere.ko.ts +37 -37
- package/src/i18n/atmosphere.pt-BR.ts +29 -29
- package/src/i18n/backdrop.ko.ts +40 -40
- package/src/i18n/backdrop.pt-BR.ts +38 -38
- package/src/i18n/camera-format.ko.ts +31 -31
- package/src/i18n/camera-format.pt-BR.ts +12 -12
- package/src/i18n/camera-motions.ko.ts +66 -66
- package/src/i18n/camera-motions.pt-BR.ts +51 -51
- package/src/i18n/character-fx.ko.ts +19 -19
- package/src/i18n/character-fx.pt-BR.ts +64 -52
- package/src/i18n/character-motion.ko.ts +164 -164
- package/src/i18n/character-motion.pt-BR.ts +867 -858
- package/src/i18n/color-look.ko.ts +41 -41
- package/src/i18n/color-look.pt-BR.ts +23 -23
- package/src/i18n/composition-effects.ko.ts +18 -18
- package/src/i18n/composition-effects.pt-BR.ts +17 -17
- package/src/i18n/era.ko.ts +28 -28
- package/src/i18n/era.pt-BR.ts +20 -20
- package/src/i18n/exposure-settings.ko.ts +20 -20
- package/src/i18n/exposure-settings.pt-BR.ts +3 -3
- package/src/i18n/framing.ko.ts +66 -66
- package/src/i18n/framing.pt-BR.ts +50 -50
- package/src/i18n/furniture.ko.ts +78 -78
- package/src/i18n/furniture.pt-BR.ts +46 -46
- package/src/i18n/held-prop.ko.ts +60 -60
- package/src/i18n/held-prop.pt-BR.ts +30 -30
- package/src/i18n/instrumentation.ko.ts +62 -62
- package/src/i18n/instrumentation.pt-BR.ts +64 -64
- package/src/i18n/lens.ko.ts +16 -16
- package/src/i18n/lens.pt-BR.ts +5 -5
- package/src/i18n/lighting.ko.ts +68 -68
- package/src/i18n/lighting.pt-BR.ts +43 -43
- package/src/i18n/loop-subject.ko.ts +1 -1
- package/src/i18n/loop-subject.pt-BR.ts +31 -31
- package/src/i18n/materials.ko.ts +66 -66
- package/src/i18n/materials.pt-BR.ts +22 -22
- package/src/i18n/mood.ko.ts +50 -50
- package/src/i18n/mood.pt-BR.ts +12 -12
- package/src/i18n/music-genre.ko.ts +28 -28
- package/src/i18n/music-genre.pt-BR.ts +50 -50
- package/src/i18n/music-mood.ko.ts +27 -27
- package/src/i18n/music-mood.pt-BR.ts +20 -20
- package/src/i18n/person.ko.ts +396 -396
- package/src/i18n/person.pt-BR.ts +237 -237
- package/src/i18n/photo-genre.ko.ts +46 -46
- package/src/i18n/photo-genre.pt-BR.ts +32 -32
- package/src/i18n/photographer.ko.ts +63 -63
- package/src/i18n/photographer.pt-BR.ts +15 -15
- package/src/i18n/pose.ko.ts +81 -81
- package/src/i18n/pose.pt-BR.ts +65 -65
- package/src/i18n/post-process-effects.ko.ts +18 -18
- package/src/i18n/post-process-effects.pt-BR.ts +18 -18
- package/src/i18n/render-quality.ko.ts +24 -24
- package/src/i18n/render-quality.pt-BR.ts +12 -12
- package/src/i18n/setting.ko.ts +64 -64
- package/src/i18n/setting.pt-BR.ts +41 -41
- package/src/i18n/style.ko.ts +49 -49
- package/src/i18n/style.pt-BR.ts +19 -19
- package/src/i18n/styling.ko.ts +265 -265
- package/src/i18n/styling.pt-BR.ts +141 -141
- package/src/i18n/temporal.ko.ts +18 -18
- package/src/i18n/temporal.pt-BR.ts +12 -12
- package/src/i18n/transitions.ko.ts +14 -14
- package/src/i18n/transitions.pt-BR.ts +83 -71
- package/src/i18n/vehicles.ko.ts +107 -107
- package/src/i18n/vehicles.pt-BR.ts +55 -55
- package/src/i18n/voice-character.ko.ts +19 -19
- package/src/i18n/voice-character.pt-BR.ts +19 -19
- package/src/i18n/voice-delivery.ko.ts +22 -22
- package/src/i18n/voice-delivery.pt-BR.ts +22 -22
- package/src/i18n/weapons.ko.ts +85 -85
- package/src/i18n/weapons.pt-BR.ts +46 -46
- package/src/index.ts +202 -1
- package/src/llm-models.ts +11 -0
- package/src/model-catalog.ts +30 -14
- package/src/model-constants.ts +28 -0
- package/src/node-mappable-fields.ts +21 -5
- package/src/node-runtime-keys.ts +33 -0
- package/src/oauth-scopes.ts +28 -0
- package/src/parameter-node-value.ts +13 -5
- package/src/pipeline-defaults.ts +14 -0
- package/src/pipeline-state-types.ts +14 -0
- package/src/producer-types.ts +85 -0
- package/src/recast-segment-packs.ts +13 -0
- package/src/resolve-field-mappings.ts +15 -5
- package/src/saved-posts.ts +106 -0
- package/src/script-settings.ts +70 -0
- package/src/settings-input.ts +366 -0
- package/src/social-search.ts +467 -0
- package/src/studio-transient.ts +176 -5
- package/src/telegram-account-send.ts +32 -0
- package/src/telegram-account-trigger.ts +108 -0
- package/src/video-analysis-pricing.ts +17 -6
- package/src/video-link.ts +16 -4
- package/src/workflow-export.ts +7 -0
package/src/studio-transient.ts
CHANGED
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
* of them and does not own them; all they carry across is job ids.
|
|
13
13
|
* - `freecutDraftUrl` — an unsaved editor draft.
|
|
14
14
|
*
|
|
15
|
+
* Two more things are the owner's alone though neither is transient: a
|
|
16
|
+
* scene's EMPTY media slots — unsubmitted drafts ({@link STUDIO_SHOT_DRAFT_KEYS})
|
|
17
|
+
* — and a finished take's VOICE RECORD ({@link STUDIO_TAKE_VOICE_KEYS}), which
|
|
18
|
+
* rides the canvas node's result rows rather than `settings`. The owner's own
|
|
19
|
+
* reads and exports keep both; every other reader's projection drops them, and
|
|
20
|
+
* drops them from the bin's deleted entries too.
|
|
21
|
+
*
|
|
15
22
|
* They do NOT all live at the same level, and that is the whole reason this
|
|
16
23
|
* file exists rather than one array: the writer puts `trash` and
|
|
17
24
|
* `freecutDraftUrl` on `settings.studio` itself, and puts the per-shot markers
|
|
@@ -60,6 +67,39 @@ export const STUDIO_TRANSIENT_KEYS = [
|
|
|
60
67
|
*/
|
|
61
68
|
export const STUDIO_SHOT_TRANSIENT_KEYS = ["pendingClips", "pendingClip", "pendingStills"] as const
|
|
62
69
|
|
|
70
|
+
/**
|
|
71
|
+
* ...and a SHOT entry's owner DRAFTS: the studio's empty media slots — a slot
|
|
72
|
+
* the owner opened and filled in but has not generated from yet.
|
|
73
|
+
*
|
|
74
|
+
* Not transient — the owner's own exports and copies keep them — so they are
|
|
75
|
+
* NOT on {@link STUDIO_SHOT_TRANSIENT_KEYS}. They are unsubmitted prose and
|
|
76
|
+
* reference urls the owner never generated, so no OTHER reader receives them.
|
|
77
|
+
* The studio codec keeps its own copy of these two keys for its own non-owner
|
|
78
|
+
* projection.
|
|
79
|
+
*/
|
|
80
|
+
export const STUDIO_SHOT_DRAFT_KEYS = ["stillSlots", "clipSlots"] as const
|
|
81
|
+
|
|
82
|
+
/** Everything a shot entry loses on its way to a reader who is not its owner. */
|
|
83
|
+
const STUDIO_SHOT_PRIVATE_KEYS: ReadonlyArray<string> = [...STUDIO_SHOT_TRANSIENT_KEYS, ...STUDIO_SHOT_DRAFT_KEYS]
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* ...and a finished TAKE's voice record (studio ruling T42): the plan a clip
|
|
87
|
+
* was recast with (`revoiceTo` — the owner's voice ids) and the Voice control's
|
|
88
|
+
* mode (`voiceMode`). Both live on the RESULT, so on a canvas node's
|
|
89
|
+
* `data.generatedResults` rows — never on `settings.studio.shots[]`, which is
|
|
90
|
+
* why no settings strip reaches them ({@link stripStudioTakeVoiceRecords} does).
|
|
91
|
+
*
|
|
92
|
+
* Results only: a scene recipe's `voiceMode` and a clip's `revoicedVoiceId` /
|
|
93
|
+
* `revoicedVoiceName` are not a take's record and stay. The studio codec keeps
|
|
94
|
+
* its own copy of these two keys (`READER_PRIVATE_TAKE_KEYS`) for its own
|
|
95
|
+
* non-owner projections, as it does the slot pair.
|
|
96
|
+
*/
|
|
97
|
+
export const STUDIO_TAKE_VOICE_KEYS = ["revoiceTo", "voiceMode"] as const
|
|
98
|
+
|
|
99
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
100
|
+
return !!value && typeof value === "object" && !Array.isArray(value)
|
|
101
|
+
}
|
|
102
|
+
|
|
63
103
|
function withoutKeys(
|
|
64
104
|
source: Record<string, unknown>,
|
|
65
105
|
drop: ReadonlyArray<string>,
|
|
@@ -73,22 +113,22 @@ function withoutKeys(
|
|
|
73
113
|
}
|
|
74
114
|
|
|
75
115
|
/**
|
|
76
|
-
* `settings.studio.shots` with
|
|
116
|
+
* `settings.studio.shots` with the given per-shot keys removed.
|
|
77
117
|
*
|
|
78
118
|
* Returns the SAME array when no shot carried one, so an idle production's
|
|
79
119
|
* share read allocates nothing. Anything that is not a shot-shaped object rides
|
|
80
120
|
* through untouched: this runs on whatever is in the column, and a projection
|
|
81
121
|
* that threw on an unexpected row would take the share read down with it.
|
|
82
122
|
*/
|
|
83
|
-
function stripShots(value: unknown): unknown {
|
|
123
|
+
function stripShots(value: unknown, drop: ReadonlyArray<string>): unknown {
|
|
84
124
|
if (!Array.isArray(value)) return value
|
|
85
125
|
let changed = false
|
|
86
126
|
const out = value.map((entry) => {
|
|
87
127
|
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return entry
|
|
88
128
|
const shot = entry as Record<string, unknown>
|
|
89
|
-
if (!
|
|
129
|
+
if (!drop.some((key) => key in shot)) return entry
|
|
90
130
|
changed = true
|
|
91
|
-
return withoutKeys(shot,
|
|
131
|
+
return withoutKeys(shot, drop)
|
|
92
132
|
})
|
|
93
133
|
return changed ? out : value
|
|
94
134
|
}
|
|
@@ -112,7 +152,7 @@ export function stripStudioTransientSettings(settings: unknown): unknown {
|
|
|
112
152
|
|
|
113
153
|
const source = studio as Record<string, unknown>
|
|
114
154
|
const kept = withoutKeys(source, STUDIO_TRANSIENT_KEYS)
|
|
115
|
-
const shots = stripShots(source.shots)
|
|
155
|
+
const shots = stripShots(source.shots, STUDIO_SHOT_PRIVATE_KEYS)
|
|
116
156
|
if (source.shots !== undefined) kept.shots = shots
|
|
117
157
|
|
|
118
158
|
// Nothing to drop at either level — hand back the original object so an
|
|
@@ -122,3 +162,134 @@ export function stripStudioTransientSettings(settings: unknown): unknown {
|
|
|
122
162
|
}
|
|
123
163
|
return { ...(settings as Record<string, unknown>), studio: kept }
|
|
124
164
|
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* A workflow's `nodes` with every result row's voice record removed
|
|
168
|
+
* ({@link STUDIO_TAKE_VOICE_KEYS}, T42).
|
|
169
|
+
*
|
|
170
|
+
* Every node's `data.generatedResults` is walked, not only a clip node's: the
|
|
171
|
+
* keys exist only on clip takes, and a type list would be one more thing to
|
|
172
|
+
* keep in step. Copy-on-write, and the SAME array back when no row carries
|
|
173
|
+
* either key. Anything that is not node-shaped rides through untouched: this
|
|
174
|
+
* runs on whatever is in the column.
|
|
175
|
+
*/
|
|
176
|
+
export function stripStudioTakeVoiceRecords(nodes: unknown): unknown {
|
|
177
|
+
if (!Array.isArray(nodes)) return nodes
|
|
178
|
+
let changed = false
|
|
179
|
+
const out = nodes.map((node: unknown) => {
|
|
180
|
+
const data = isRecord(node) ? node.data : undefined
|
|
181
|
+
const rows = isRecord(data) ? data.generatedResults : undefined
|
|
182
|
+
if (!Array.isArray(rows)) return node
|
|
183
|
+
let touched = false
|
|
184
|
+
const kept = rows.map((row: unknown) => {
|
|
185
|
+
if (!isRecord(row) || !STUDIO_TAKE_VOICE_KEYS.some((key) => key in row)) return row
|
|
186
|
+
touched = true
|
|
187
|
+
return withoutKeys(row, STUDIO_TAKE_VOICE_KEYS)
|
|
188
|
+
})
|
|
189
|
+
if (!touched) return node
|
|
190
|
+
changed = true
|
|
191
|
+
return { ...(node as Record<string, unknown>), data: { ...(data as Record<string, unknown>), generatedResults: kept } }
|
|
192
|
+
})
|
|
193
|
+
return changed ? out : nodes
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* `settings` with every SHOT's owner-private state removed — its empty media
|
|
198
|
+
* slots ({@link STUDIO_SHOT_DRAFT_KEYS}) and its in-flight run markers
|
|
199
|
+
* ({@link STUDIO_SHOT_TRANSIENT_KEYS}) — and the bin kept WITHOUT the owner's
|
|
200
|
+
* drafts in it ({@link stripBin}: deleted empty slots, deleted takes' voice
|
|
201
|
+
* records). The document-level markers and everything else stay.
|
|
202
|
+
*
|
|
203
|
+
* For a reader the owner let LOOK but not edit: a `view` reader's
|
|
204
|
+
* `GET /v1/workflows/:id` and `GET /v1/workflows/:id/export`, and the MCP
|
|
205
|
+
* `get_workflow_json` / `export_workflow` tools on the same access — each
|
|
206
|
+
* through {@link stripStudioDraftWorkflow}, which strips the nodes as well.
|
|
207
|
+
* The markers go with the slots because a viewer cannot land the owner's runs,
|
|
208
|
+
* and a marker for a run started from a slot carries that slot's unsent
|
|
209
|
+
* inputs. An editor keeps all of it: their editor saves `settings` back whole.
|
|
210
|
+
*
|
|
211
|
+
* The very same object back when neither a shot nor the bin carries any of it.
|
|
212
|
+
*/
|
|
213
|
+
export function stripStudioDraftSettings(settings: unknown): unknown {
|
|
214
|
+
if (!settings || typeof settings !== "object") return settings
|
|
215
|
+
const studio = (settings as { studio?: unknown }).studio
|
|
216
|
+
if (!isRecord(studio)) return settings
|
|
217
|
+
const shots = stripShots(studio.shots, STUDIO_SHOT_PRIVATE_KEYS)
|
|
218
|
+
const trash = stripBin(studio.trash)
|
|
219
|
+
if (shots === studio.shots && trash === studio.trash) return settings
|
|
220
|
+
const kept: Record<string, unknown> = { ...studio }
|
|
221
|
+
if (shots !== studio.shots) kept.shots = shots
|
|
222
|
+
if (trash !== studio.trash) kept.trash = trash
|
|
223
|
+
return { ...(settings as Record<string, unknown>), studio: kept }
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* The owner's BIN (`settings.studio.trash`) as a `view` reader receives it —
|
|
228
|
+
* T11 and T42 applied to what the owner deleted:
|
|
229
|
+
*
|
|
230
|
+
* - a deleted EMPTY slot (`kind: "slot"`) goes whole: it is an unsubmitted
|
|
231
|
+
* draft, prose and reference urls the owner never generated;
|
|
232
|
+
* - a deleted SCENE (`kind: "shot"`) is a one-scene production graph, so it
|
|
233
|
+
* gets what a live production gets: its takes' records off the graph's nodes
|
|
234
|
+
* and its slots and runs off the graph's scene entry;
|
|
235
|
+
* - any other entry — a deleted take (`kind: "clip"`, or a legacy entry with
|
|
236
|
+
* no kind, which the bin reads as a clip) — keeps its result without the
|
|
237
|
+
* voice record. A deleted still or keyframe carries none and rides through.
|
|
238
|
+
*
|
|
239
|
+
* Mirrors the studio codec's `withoutBinDrafts` branch for branch. Copy-on-
|
|
240
|
+
* write, the SAME array back when no entry carries any of it, and anything
|
|
241
|
+
* that is not an entry rides through untouched.
|
|
242
|
+
*/
|
|
243
|
+
function stripBin(trash: unknown): unknown {
|
|
244
|
+
if (!Array.isArray(trash)) return trash
|
|
245
|
+
let changed = false
|
|
246
|
+
const out: unknown[] = []
|
|
247
|
+
for (const entry of trash as unknown[]) {
|
|
248
|
+
if (isRecord(entry) && entry.kind === "slot") {
|
|
249
|
+
changed = true
|
|
250
|
+
continue
|
|
251
|
+
}
|
|
252
|
+
const kept = !isRecord(entry) ? entry : entry.kind === "shot" ? binSceneForReader(entry) : binTakeForReader(entry)
|
|
253
|
+
if (kept !== entry) changed = true
|
|
254
|
+
out.push(kept)
|
|
255
|
+
}
|
|
256
|
+
return changed ? out : trash
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** A deleted scene's graph through the two `view` strips. */
|
|
260
|
+
function binSceneForReader(entry: Record<string, unknown>): Record<string, unknown> {
|
|
261
|
+
const graph = entry.graph
|
|
262
|
+
if (!isRecord(graph)) return entry
|
|
263
|
+
const nodes = stripStudioTakeVoiceRecords(graph.nodes)
|
|
264
|
+
const settings = stripStudioDraftSettings(graph.settings)
|
|
265
|
+
if (nodes === graph.nodes && settings === graph.settings) return entry
|
|
266
|
+
return { ...entry, graph: { ...graph, nodes, settings } }
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** A deleted take without its voice record; any other entry as it is. */
|
|
270
|
+
function binTakeForReader(entry: Record<string, unknown>): Record<string, unknown> {
|
|
271
|
+
const result = entry.result
|
|
272
|
+
if (!isRecord(result) || !STUDIO_TAKE_VOICE_KEYS.some((key) => key in result)) return entry
|
|
273
|
+
return { ...entry, result: withoutKeys(result, STUDIO_TAKE_VOICE_KEYS) }
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* A workflow row as a reader the owner let LOOK but not edit receives it: the
|
|
278
|
+
* takes' voice records off its `nodes` ({@link stripStudioTakeVoiceRecords})
|
|
279
|
+
* and the owner's drafts and runs off its `settings`
|
|
280
|
+
* ({@link stripStudioDraftSettings}).
|
|
281
|
+
*
|
|
282
|
+
* The ONE strip every `view` door applies, so no door can strip the settings
|
|
283
|
+
* and forget the nodes. A half the row does not carry is not added. Copy-on-
|
|
284
|
+
* write, and the very same row back when neither half changed.
|
|
285
|
+
*/
|
|
286
|
+
export function stripStudioDraftWorkflow<T extends { nodes?: unknown; settings?: unknown }>(row: T): T {
|
|
287
|
+
const nodes = "nodes" in row ? stripStudioTakeVoiceRecords(row.nodes) : row.nodes
|
|
288
|
+
const settings = "settings" in row ? stripStudioDraftSettings(row.settings) : row.settings
|
|
289
|
+
if (nodes === row.nodes && settings === row.settings) return row
|
|
290
|
+
return {
|
|
291
|
+
...row,
|
|
292
|
+
...(nodes !== row.nodes ? { nodes } : {}),
|
|
293
|
+
...(settings !== row.settings ? { settings } : {}),
|
|
294
|
+
}
|
|
295
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram Reply (`telegram-account-send`) — who writes the message and
|
|
3
|
+
* where it goes, as node data spells it. Structural vocabulary only: every
|
|
4
|
+
* destination is the run's OWNER — the chat of the post they shared, their
|
|
5
|
+
* Saved Messages, or their private chat with their own bot. How the Cloud
|
|
6
|
+
* connector sends is not part of the contract.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const TELEGRAM_ACCOUNT_SEND_NODE_TYPE = "telegram-account-send"
|
|
10
|
+
|
|
11
|
+
/** `account`: the owner's connected account writes. `bot`: the owner's own bot writes to them privately. */
|
|
12
|
+
export const TELEGRAM_SEND_AS = ["account", "bot"] as const
|
|
13
|
+
export type TelegramSendAs = (typeof TELEGRAM_SEND_AS)[number]
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Where an account-written message goes. `reply`: under the post that started
|
|
17
|
+
* the run, in its chat (a run started by the Telegram Account Trigger only).
|
|
18
|
+
* `saved`: the owner's Saved Messages. A bot always writes to the owner's
|
|
19
|
+
* private chat with it, so it has no destination to choose.
|
|
20
|
+
*/
|
|
21
|
+
export const TELEGRAM_SEND_DESTINATIONS = ["reply", "saved"] as const
|
|
22
|
+
export type TelegramSendDestination = (typeof TELEGRAM_SEND_DESTINATIONS)[number]
|
|
23
|
+
|
|
24
|
+
/** The node's `sendAs`, as every reader reads it: anything else is the account. */
|
|
25
|
+
export function telegramSendAsOf(value: unknown): TelegramSendAs {
|
|
26
|
+
return value === "bot" ? "bot" : "account"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The node's `destination`, as every reader reads it: anything else is a reply. */
|
|
30
|
+
export function telegramSendDestinationOf(value: unknown): TelegramSendDestination {
|
|
31
|
+
return value === "saved" ? "saved" : "reply"
|
|
32
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Telegram Account Trigger's named outputs — the wire contract between the
|
|
3
|
+
* Cloud connector that starts a run (it writes these keys into the run's
|
|
4
|
+
* trigger data) and everything that reads them: both workflow engines, the
|
|
5
|
+
* canvas card and the public node registry. A handle id IS the trigger-data
|
|
6
|
+
* key, so the two can never disagree.
|
|
7
|
+
*
|
|
8
|
+
* Structural vocabulary only: the keys and what each one carries. How the
|
|
9
|
+
* connector decides which key a post fills is not part of the contract.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** The message itself — the card's original output. */
|
|
13
|
+
export const TELEGRAM_ACCOUNT_TRIGGER_MESSAGE_HANDLE = "out"
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Named outputs, in the order the card shows them. Exactly one of `videoLink`
|
|
17
|
+
* and `postText` carries a value in a run that is about a shared post; both
|
|
18
|
+
* are empty otherwise. Never undefined — an engine reading an empty one gets
|
|
19
|
+
* "", never the message text in its place.
|
|
20
|
+
*/
|
|
21
|
+
export const TELEGRAM_ACCOUNT_TRIGGER_POST_FIELDS = [
|
|
22
|
+
/** The post's link, when the post has a video to analyze. */
|
|
23
|
+
"videoLink",
|
|
24
|
+
/** The post's words, when it has no video: the message, the link's preview, or the forwarded post. */
|
|
25
|
+
"postText",
|
|
26
|
+
/** The link of the post this run is about, whatever its kind. */
|
|
27
|
+
"postLink",
|
|
28
|
+
] as const
|
|
29
|
+
|
|
30
|
+
export type TelegramAccountTriggerPostField = (typeof TELEGRAM_ACCOUNT_TRIGGER_POST_FIELDS)[number]
|
|
31
|
+
|
|
32
|
+
/** Message facts carried alongside — read through trigger tokens and JSON-authored wires. */
|
|
33
|
+
export const TELEGRAM_ACCOUNT_TRIGGER_MESSAGE_FIELDS = [
|
|
34
|
+
"chatId",
|
|
35
|
+
"chatType",
|
|
36
|
+
"messageId",
|
|
37
|
+
"senderId",
|
|
38
|
+
] as const
|
|
39
|
+
|
|
40
|
+
/** Every handle the card renders, `out` first. */
|
|
41
|
+
export const TELEGRAM_ACCOUNT_TRIGGER_OUTPUT_HANDLES: readonly string[] = [
|
|
42
|
+
TELEGRAM_ACCOUNT_TRIGGER_MESSAGE_HANDLE,
|
|
43
|
+
...TELEGRAM_ACCOUNT_TRIGGER_POST_FIELDS,
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
const NAMED_HANDLES: ReadonlySet<string> = new Set([...TELEGRAM_ACCOUNT_TRIGGER_POST_FIELDS, ...TELEGRAM_ACCOUNT_TRIGGER_MESSAGE_FIELDS])
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A handle naming one value of the run (a post field or a message fact) —
|
|
50
|
+
* every handle but the message itself. A wire from one carries that value,
|
|
51
|
+
* "" when the run has none, never the message in its place.
|
|
52
|
+
*/
|
|
53
|
+
export function isTelegramAccountTriggerNamedHandle(handle: unknown): handle is string {
|
|
54
|
+
return typeof handle === "string" && NAMED_HANDLES.has(handle)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* What an account trigger listens to, and whether it listens: the settings
|
|
59
|
+
* only its owner may set. One canonical string, so the editor that changed a
|
|
60
|
+
* trigger and the server that arms it compare the same thing — the server
|
|
61
|
+
* arms a trigger the owner's editor named only while the stored node still
|
|
62
|
+
* says exactly what that editor set.
|
|
63
|
+
*
|
|
64
|
+
* It states what the trigger hears, not how the node spells it: in inbox mode
|
|
65
|
+
* the owner's own messages are always heard, so `includeOutgoing` reads as on
|
|
66
|
+
* there — a setting the panel does not show in that mode never decides a match.
|
|
67
|
+
* The account id is the one exception: it is read exactly as written, because
|
|
68
|
+
* the server never listens on one that is not written exactly (padded), and
|
|
69
|
+
* the editor shows such an id as no account of the owner's.
|
|
70
|
+
*/
|
|
71
|
+
export function telegramAccountListeningSignature(data: unknown): string {
|
|
72
|
+
const d = (data !== null && typeof data === "object" ? data : {}) as Record<string, unknown>
|
|
73
|
+
const list = (value: unknown): string[] =>
|
|
74
|
+
Array.isArray(value)
|
|
75
|
+
? [...new Set(value.filter((x): x is string => typeof x === "string").map((x) => x.trim()).filter((x) => x !== ""))].sort()
|
|
76
|
+
: []
|
|
77
|
+
return JSON.stringify({
|
|
78
|
+
accountId: typeof d.accountId === "string" ? d.accountId : "",
|
|
79
|
+
chatIds: list(d.chatIds),
|
|
80
|
+
senderIds: list(d.senderIds),
|
|
81
|
+
messageTypeFilters: list(d.messageTypeFilters),
|
|
82
|
+
keywords: list(d.keywords),
|
|
83
|
+
includeOutgoing: d.inboxMode === true || d.includeOutgoing === true,
|
|
84
|
+
inboxMode: d.inboxMode === true,
|
|
85
|
+
isActive: d.isActive === true,
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function stringField(value: unknown): string {
|
|
90
|
+
if (typeof value === "string") return value.trim()
|
|
91
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value)
|
|
92
|
+
return ""
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The named outputs of one run, from its trigger data: every post field
|
|
97
|
+
* present (possibly ""), each message field only when it has a value.
|
|
98
|
+
*/
|
|
99
|
+
export function telegramAccountTriggerOutputs(triggerData: Record<string, unknown> | null | undefined): Record<string, string> {
|
|
100
|
+
const td = triggerData ?? {}
|
|
101
|
+
const out: Record<string, string> = {}
|
|
102
|
+
for (const key of TELEGRAM_ACCOUNT_TRIGGER_POST_FIELDS) out[key] = stringField(td[key])
|
|
103
|
+
for (const key of TELEGRAM_ACCOUNT_TRIGGER_MESSAGE_FIELDS) {
|
|
104
|
+
const value = stringField(td[key])
|
|
105
|
+
if (value !== "") out[key] = value
|
|
106
|
+
}
|
|
107
|
+
return out
|
|
108
|
+
}
|
|
@@ -33,9 +33,19 @@
|
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
35
|
export const VIDEO_ANALYSIS_DURATION_BUCKETS = [60, 180, 360, 600] as const
|
|
36
|
+
/** Pricing grace: a clip at most this far past a bucket edge is priced at that
|
|
37
|
+
* bucket. A part chosen as 1:00 in the Video URL chooser downloads at about
|
|
38
|
+
* 1:03 (the cut lands on keyframes), and must cost a minute, not three. Read
|
|
39
|
+
* by pickVideoAnalysisBucket — the ONE bucket picker every price reads (the
|
|
40
|
+
* editor estimate, the orchestrator reserve, the cloud routes). */
|
|
41
|
+
export const VIDEO_ANALYSIS_BUCKET_GRACE_SEC = 3
|
|
36
42
|
/** Worker re-check grace: route metadata is integer-rounded, provider durations nominal;
|
|
37
|
-
* ffprobe floats run 0.05–2 s over. Zero tolerance fails legit videos at 1:00/3:00/6:00/10:00.
|
|
38
|
-
|
|
43
|
+
* ffprobe floats run 0.05–2 s over. Zero tolerance fails legit videos at 1:00/3:00/6:00/10:00.
|
|
44
|
+
* It sits ON TOP of the pricing grace: a clip the grace priced into a bucket
|
|
45
|
+
* (probe 63 s → 60 s) must still pass the worker gate (bucket + tolerance) at
|
|
46
|
+
* its float length (63.4 s). The cloud plugin reads this constant from the
|
|
47
|
+
* host app at run time, so its gate moves with it. */
|
|
48
|
+
export const VIDEO_ANALYSIS_DURATION_TOLERANCE_SEC = VIDEO_ANALYSIS_BUCKET_GRACE_SEC + 3
|
|
39
49
|
export const VIDEO_ANALYSIS_MAX_DURATION_SEC = 600
|
|
40
50
|
const WINDOW_LEN = 150, WINDOW_STRIDE = 145, WINDOW_OVERLAP = 5
|
|
41
51
|
export const VIDEO_ANALYSIS_WINDOW = { LEN: WINDOW_LEN, STRIDE: WINDOW_STRIDE, OVERLAP: WINDOW_OVERLAP, SINGLE_MAX: 180 } as const
|
|
@@ -113,13 +123,14 @@ export const VIDEO_ANALYSIS_WINDOW = { LEN: WINDOW_LEN, STRIDE: WINDOW_STRIDE, O
|
|
|
113
123
|
// the legacy `gemini-3-flash` family moves too.
|
|
114
124
|
// Output of the plugin's `scripts/gen-va-buckets.mjs`, pasted verbatim.
|
|
115
125
|
export const VIDEO_ANALYSIS_BUCKET_CREDITS: Record<string, number> = {
|
|
116
|
-
//
|
|
126
|
+
// Current fast tier (VIDEO_ANALYSIS_TIERS.fast; it was also the fast model
|
|
127
|
+
// before 2026-07).
|
|
117
128
|
"video-analysis:gemini-3-flash:60s": 181,
|
|
118
129
|
"video-analysis:gemini-3-flash:180s": 186,
|
|
119
130
|
"video-analysis:gemini-3-flash:360s": 516,
|
|
120
131
|
"video-analysis:gemini-3-flash:600s": 849,
|
|
121
|
-
//
|
|
122
|
-
//
|
|
132
|
+
// Legacy fast-tier model (backed the fast tier 2026-07 → 2026-07-29) — kept
|
|
133
|
+
// for stored raw-id configs; still ≤ pro per bucket.
|
|
123
134
|
"video-analysis:gemini-3.6-flash:60s": 205,
|
|
124
135
|
"video-analysis:gemini-3.6-flash:180s": 219,
|
|
125
136
|
"video-analysis:gemini-3.6-flash:360s": 603,
|
|
@@ -159,7 +170,7 @@ export function videoAnalysisCreditSegment(modelOrSentinel: string): string {
|
|
|
159
170
|
}
|
|
160
171
|
|
|
161
172
|
export function pickVideoAnalysisBucket(durationSec: number): number {
|
|
162
|
-
for (const b of VIDEO_ANALYSIS_DURATION_BUCKETS) if (durationSec <= b) return b
|
|
173
|
+
for (const b of VIDEO_ANALYSIS_DURATION_BUCKETS) if (durationSec <= b + VIDEO_ANALYSIS_BUCKET_GRACE_SEC) return b
|
|
163
174
|
return VIDEO_ANALYSIS_MAX_DURATION_SEC
|
|
164
175
|
}
|
|
165
176
|
|
package/src/video-link.ts
CHANGED
|
@@ -98,16 +98,19 @@ export function detectVideoLinkPlatform(url: string): VideoLinkPlatform {
|
|
|
98
98
|
/**
|
|
99
99
|
* Node types that can use a Video URL node WITHOUT its downloaded file, because
|
|
100
100
|
* they never read the video: `suno-cover` and `transcribe` take the node's
|
|
101
|
-
* separately-fetched audio track (`downloadedAudioUrl`),
|
|
102
|
-
* page link to a provider that fetches it itself
|
|
103
|
-
*
|
|
104
|
-
*
|
|
101
|
+
* separately-fetched audio track (`downloadedAudioUrl`), `dubbing` hands the
|
|
102
|
+
* page link to a provider that fetches it itself, and `content-recipe` cites the
|
|
103
|
+
* post's page link on its `link` input (`videoLinkPageUrl`, both resolvers) —
|
|
104
|
+
* a Video URL can reach it on no other input. A run whose only consumers of a
|
|
105
|
+
* link are these must not be made to download — or to choose a part of — a
|
|
106
|
+
* video nobody will look at. Structural vocabulary: it mirrors those
|
|
105
107
|
* server-side readers; add a type here only together with its reader.
|
|
106
108
|
*/
|
|
107
109
|
export const VIDEO_LINK_TOLERANT_CONSUMER_TYPES: ReadonlySet<string> = new Set([
|
|
108
110
|
"suno-cover",
|
|
109
111
|
"transcribe",
|
|
110
112
|
"dubbing",
|
|
113
|
+
"content-recipe",
|
|
111
114
|
])
|
|
112
115
|
|
|
113
116
|
/**
|
|
@@ -156,6 +159,15 @@ export function resolveVideoLinkOutput(data: VideoLinkNodeFields): string | unde
|
|
|
156
159
|
return videoLinkDownloadedFile(data) ?? trimmed(data.youtubeUrl)
|
|
157
160
|
}
|
|
158
161
|
|
|
162
|
+
/**
|
|
163
|
+
* The page link a Video URL node was given (the post's own address), never
|
|
164
|
+
* the downloaded file. Read by consumers that CITE a post rather than watch
|
|
165
|
+
* it — Content Recipe's "Source post" input stores it as the recipe's source.
|
|
166
|
+
*/
|
|
167
|
+
export function videoLinkPageUrl(data: VideoLinkNodeFields): string | undefined {
|
|
168
|
+
return trimmed(data.youtubeUrl)
|
|
169
|
+
}
|
|
170
|
+
|
|
159
171
|
/**
|
|
160
172
|
* True when the node holds a social link with no file for it yet — the state
|
|
161
173
|
* in which its output is a web PAGE, which no video consumer can read.
|
package/src/workflow-export.ts
CHANGED
|
@@ -197,6 +197,8 @@ const NODE_EXTRA_FIELDS: Record<string, string[]> = {
|
|
|
197
197
|
// (a schedule starts paused), and the rules themselves are config that
|
|
198
198
|
// travels.
|
|
199
199
|
"schedule-trigger": ["active"],
|
|
200
|
+
// Same for a Telegram Account Trigger: listening is the importer's to start.
|
|
201
|
+
"telegram-account-trigger": ["isActive"],
|
|
200
202
|
character: ["expressions", "poses", "lightingVariations", "angles", "customVariations"],
|
|
201
203
|
object: ["angles", "materials", "variations", "customVariations"],
|
|
202
204
|
creature: ["angles", "poses", "variations", "customVariations"],
|
|
@@ -232,6 +234,11 @@ const NODE_EXTRA_FIELDS: Record<string, string[]> = {
|
|
|
232
234
|
*/
|
|
233
235
|
const UNOWNED_REF_FIELDS: Record<string, readonly string[]> = {
|
|
234
236
|
"webhook-output": ["credentialId"],
|
|
237
|
+
// The exporter's connected Telegram account and its chats (a Saved Messages
|
|
238
|
+
// chat id IS the exporter's Telegram user id) — the importer picks their own.
|
|
239
|
+
"telegram-account-trigger": ["accountId", "chatIds", "chatTitles", "senderIds"],
|
|
240
|
+
// Telegram Reply: the exporter's account and their bot.
|
|
241
|
+
"telegram-account-send": ["accountId", "connectionId"],
|
|
235
242
|
...Object.fromEntries([...SOCIAL_POST_NODE_TYPES].map((type) => [type, ["connectionId"]])),
|
|
236
243
|
}
|
|
237
244
|
|