@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
|
@@ -133,6 +133,20 @@ export const SubGateNameSchema = z.enum([
|
|
|
133
133
|
])
|
|
134
134
|
export type SubGateName = z.infer<typeof SubGateNameSchema>
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* The sub-gates `POST /v1/pipelines/:id/sub-gates/:gate/{approve,reject}`
|
|
138
|
+
* resolves: Stage 7's (`animate_audio_edit`). `match_cut_break_pending` is not
|
|
139
|
+
* one of them — it clears per shot, one break at a time, through
|
|
140
|
+
* `POST /v1/pipelines/:id/entities/:sceneId/helpers/accept_match_cut_break`
|
|
141
|
+
* (`MATCH_CUT_BREAK_GATE`).
|
|
142
|
+
*/
|
|
143
|
+
export const ANIMATE_SUB_GATES = ["silent_cut_preview", "dialogue_recheck"] as const satisfies readonly SubGateName[]
|
|
144
|
+
export const AnimateSubGateSchema = z.enum(ANIMATE_SUB_GATES)
|
|
145
|
+
export type AnimateSubGate = (typeof ANIMATE_SUB_GATES)[number]
|
|
146
|
+
|
|
147
|
+
/** Stage 6's sub-gate, cleared by accepting each flagged break (see {@link ANIMATE_SUB_GATES}). */
|
|
148
|
+
export const MATCH_CUT_BREAK_GATE = "match_cut_break_pending" satisfies SubGateName
|
|
149
|
+
|
|
136
150
|
/**
|
|
137
151
|
* Phase 1C.2 — emitted when Stage 6 (scene_images) or Stage 7
|
|
138
152
|
* (animate_audio_edit) pauses at a sub-gate. Carries an optional `payload`
|
package/src/producer-types.ts
CHANGED
|
@@ -239,4 +239,89 @@ export const FAN_OUT_EACH_TYPES: ReadonlySet<string> = new Set([
|
|
|
239
239
|
// to the scalar `edl` value (no fan-out) — the same graceful degradation
|
|
240
240
|
// web-scrape relies on. See `unwrapEditPlanOutput` in `edit-plan-contract.ts`.
|
|
241
241
|
"edit-plan",
|
|
242
|
+
// Content Ideas emits one creative brief per idea on `listResults`, so an
|
|
243
|
+
// edge leaving it defaults to "each" — the node after it (typically
|
|
244
|
+
// Generate Script) runs once per idea, on the server too.
|
|
245
|
+
"content-ideas",
|
|
242
246
|
])
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Per-HANDLE "each" defaults, for a node whose outputs differ in kind: on the
|
|
250
|
+
* `each` handles an edge without an explicit `outputMode` defaults to "each",
|
|
251
|
+
* on its other handles to "last". `primary` is the handle an edge with no
|
|
252
|
+
* `sourceHandle` reads (agent-written workflow JSON often omits it).
|
|
253
|
+
*
|
|
254
|
+
* The list an "each" edge reads is the node's per-iteration results
|
|
255
|
+
* (`listResults`) — it exists only when the node itself ran once per item, so
|
|
256
|
+
* after a single run the edge degrades to the single value, exactly like a
|
|
257
|
+
* `FAN_OUT_EACH_TYPES` member with one item.
|
|
258
|
+
*/
|
|
259
|
+
export const FAN_OUT_EACH_HANDLES: Readonly<Record<string, { readonly each: readonly string[]; readonly primary: string }>> = {
|
|
260
|
+
// Camera Switch run once per clip (Edit Plan in clips mode): each clip's
|
|
261
|
+
// switched EDL is its own Apply EDL render. Its transcript is the same for
|
|
262
|
+
// every clip (the master clock, renamed), so that handle stays one value
|
|
263
|
+
// (decided 2026-10-04).
|
|
264
|
+
"camera-switch": { each: ["edl"], primary: "edl" },
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** The `outputMode` an edge has when none is set on it — the ONE rule both
|
|
268
|
+
* engines, the credit estimate and the editor read. */
|
|
269
|
+
export function defaultEdgeOutputMode(
|
|
270
|
+
sourceType: string | null | undefined,
|
|
271
|
+
sourceHandle: string | null | undefined,
|
|
272
|
+
): "each" | "last" {
|
|
273
|
+
if (typeof sourceType !== "string") return "last"
|
|
274
|
+
if (FAN_OUT_EACH_TYPES.has(sourceType)) return "each"
|
|
275
|
+
const entry = FAN_OUT_EACH_HANDLES[sourceType]
|
|
276
|
+
if (!entry) return "last"
|
|
277
|
+
return entry.each.includes(sourceHandle || entry.primary) ? "each" : "last"
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Whether an edge from `sourceHandle` reads the node's per-iteration results
|
|
281
|
+
* (`listResults` — each iteration's PRIMARY output). False on the other
|
|
282
|
+
* handles of a `FAN_OUT_EACH_HANDLES` node: Camera Switch's transcript is one
|
|
283
|
+
* value, never the list of switched EDLs, whatever mode its edge is set to. */
|
|
284
|
+
export function listResultsServeHandle(
|
|
285
|
+
sourceType: string | null | undefined,
|
|
286
|
+
sourceHandle: string | null | undefined,
|
|
287
|
+
): boolean {
|
|
288
|
+
const entry = typeof sourceType === "string" ? FAN_OUT_EACH_HANDLES[sourceType] : undefined
|
|
289
|
+
return !entry || entry.each.includes(sourceHandle || entry.primary)
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* FAN-IN targets: nodes that FOLD everything wired into them into ONE run,
|
|
294
|
+
* instead of running once per upstream item. Keyed by node type; the value
|
|
295
|
+
* names the target handles that fold (`"*"` = every handle). An edge into any
|
|
296
|
+
* other handle of such a node is routed normally — Content Ideas folds its
|
|
297
|
+
* recipes but reads its brand from a `field-brand` wire like any field.
|
|
298
|
+
*
|
|
299
|
+
* Single source of truth for both engines' input resolvers (the backend and
|
|
300
|
+
* the editor each used to keep a private `new Set(["reduce"])`). A fan-in
|
|
301
|
+
* node is never itself fanned out by an upstream list.
|
|
302
|
+
*/
|
|
303
|
+
export const FAN_IN_TARGETS: Readonly<Record<string, "*" | readonly string[]>> = {
|
|
304
|
+
// Choose Best — every wire is a candidate.
|
|
305
|
+
reduce: "*",
|
|
306
|
+
// Content Ideas — one or more recipes, from several Content Recipe nodes
|
|
307
|
+
// and/or one that ran once per post.
|
|
308
|
+
"content-ideas": ["recipes"],
|
|
309
|
+
// Telegram Reply — one message per run, whatever is wired into its text
|
|
310
|
+
// input: a list (or a writer that ran once per item) arrives as one
|
|
311
|
+
// message, never as a burst of sends to the owner's chat.
|
|
312
|
+
"telegram-account-send": ["in"],
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export function isFanInNodeType(nodeType: string | undefined | null): boolean {
|
|
316
|
+
return typeof nodeType === "string" && Object.prototype.hasOwnProperty.call(FAN_IN_TARGETS, nodeType)
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** True when an edge into `targetHandle` of a `targetType` node is folded.
|
|
320
|
+
* An edge with NO target handle (workflow JSON written by an agent often
|
|
321
|
+
* omits it) lands on the node's primary input, which is the folding one. */
|
|
322
|
+
export function isFanInEdge(targetType: string | undefined | null, targetHandle: string | null | undefined): boolean {
|
|
323
|
+
if (!isFanInNodeType(targetType)) return false
|
|
324
|
+
const spec = FAN_IN_TARGETS[targetType as string]!
|
|
325
|
+
if (spec === "*") return true
|
|
326
|
+
return targetHandle == null || targetHandle === "" || spec.includes(targetHandle)
|
|
327
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a recast render packs scenes into parts — the values `segmentSec` takes
|
|
3
|
+
* on `POST /v1/recast`, `/v1/recast/estimate` and `/v1/recast/:id/start`. A
|
|
4
|
+
* name, not seconds, despite the field's name:
|
|
5
|
+
*
|
|
6
|
+
* - `"scenes-max"` (Long): whole scenes grouped into as few parts as fit, the
|
|
7
|
+
* fewest seams.
|
|
8
|
+
* - `"scenes"` (Short): whole scenes in shorter parts.
|
|
9
|
+
* - `"max"`: the longest parts the model allows, not grouped by scene.
|
|
10
|
+
*/
|
|
11
|
+
export const RECAST_SEGMENT_PACKS = ["max", "scenes-max", "scenes"] as const
|
|
12
|
+
|
|
13
|
+
export type RecastSegmentPack = (typeof RECAST_SEGMENT_PACKS)[number]
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { injectUpstream } from "./inject-upstream.js"
|
|
2
2
|
|
|
3
|
+
/** A live wire into a field's handle: which node, and which of its outputs. */
|
|
4
|
+
export interface FieldEdgeSource {
|
|
5
|
+
readonly sourceNodeId: string
|
|
6
|
+
readonly sourceHandle?: string | null
|
|
7
|
+
}
|
|
8
|
+
|
|
3
9
|
/**
|
|
4
10
|
* Resolve fieldMappings + {} injection for all text fields on a node.
|
|
5
11
|
*
|
|
@@ -19,23 +25,27 @@ import { injectUpstream } from "./inject-upstream.js"
|
|
|
19
25
|
* from NodeExecutionState.output. Same pattern as ancestor-refs.ts.
|
|
20
26
|
*
|
|
21
27
|
* `edgeSourceForField` is optional: when omitted, behaviour is identical to
|
|
22
|
-
* the prior fieldMappings-only resolver (existing callers stay valid).
|
|
28
|
+
* the prior fieldMappings-only resolver (existing callers stay valid). When
|
|
29
|
+
* it names the wire's source HANDLE too, the value is that handle's output —
|
|
30
|
+
* a Router's route, a trigger's named output — not the source's primary one.
|
|
23
31
|
*/
|
|
24
32
|
export function resolveFieldMappings(
|
|
25
33
|
data: Record<string, unknown>,
|
|
26
34
|
upstreamText: string | undefined,
|
|
27
35
|
mappableFieldNames: ReadonlyArray<string>,
|
|
28
|
-
getSourceOutput: (sourceNodeId: string) => string | undefined,
|
|
29
|
-
edgeSourceForField?: (field: string) => string | undefined,
|
|
36
|
+
getSourceOutput: (sourceNodeId: string, sourceHandle?: string | null) => string | undefined,
|
|
37
|
+
edgeSourceForField?: (field: string) => FieldEdgeSource | string | undefined,
|
|
30
38
|
): Record<string, unknown> {
|
|
31
39
|
const fm = data.fieldMappings as Record<string, { sourceNodeId: string }> | undefined
|
|
32
40
|
const resolved = { ...data }
|
|
33
41
|
|
|
34
42
|
for (const field of mappableFieldNames) {
|
|
35
|
-
const
|
|
43
|
+
const wired = edgeSourceForField?.(field)
|
|
44
|
+
const edge: FieldEdgeSource | undefined = typeof wired === "string" ? { sourceNodeId: wired } : wired
|
|
45
|
+
const sourceNodeId = edge?.sourceNodeId ?? fm?.[field]?.sourceNodeId
|
|
36
46
|
|
|
37
47
|
if (sourceNodeId) {
|
|
38
|
-
const output = getSourceOutput(sourceNodeId)
|
|
48
|
+
const output = getSourceOutput(sourceNodeId, edge?.sourceHandle)
|
|
39
49
|
if (output != null) resolved[field] = output
|
|
40
50
|
} else {
|
|
41
51
|
const current = resolved[field]
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Saved posts — the inspiration wall's wire contract.
|
|
3
|
+
*
|
|
4
|
+
* A person saves a post they found (a Social Search result) with a note and
|
|
5
|
+
* tags, to come back to it or feed it into a workflow. The row keeps a
|
|
6
|
+
* snapshot of the post, because platform links and numbers change, and the
|
|
7
|
+
* post's still is copied into the person's storage so the wall outlives the
|
|
8
|
+
* platform's signed image links.
|
|
9
|
+
*
|
|
10
|
+
* Why public: `SavedPost` is what `GET /v1/saved-posts` returns and the SDK's
|
|
11
|
+
* `savedPosts` resource types.
|
|
12
|
+
*/
|
|
13
|
+
import type { SocialPlatform, SocialPost } from "./social-search.js"
|
|
14
|
+
|
|
15
|
+
/** Where a save came from. */
|
|
16
|
+
export const SAVED_POST_SOURCES = ["picker", "competitors", "manual", "api"] as const
|
|
17
|
+
export type SavedPostSource = (typeof SAVED_POST_SOURCES)[number]
|
|
18
|
+
|
|
19
|
+
export const SAVED_POST_NOTE_MAX = 2000
|
|
20
|
+
export const SAVED_POST_MAX_TAGS = 10
|
|
21
|
+
export const SAVED_POST_TAG_MAX = 40
|
|
22
|
+
export const SAVED_POSTS_PAGE_MAX = 100
|
|
23
|
+
/** How many post ids one lookup may ask about. */
|
|
24
|
+
export const SAVED_POSTS_LOOKUP_MAX = 200
|
|
25
|
+
|
|
26
|
+
export interface SavedPost {
|
|
27
|
+
readonly id: string
|
|
28
|
+
/** The post's own id (`SocialPost.id`); one save per post per person. */
|
|
29
|
+
readonly postId: string
|
|
30
|
+
readonly platform: SocialPlatform
|
|
31
|
+
readonly url: string
|
|
32
|
+
/** The post as it was when saved. */
|
|
33
|
+
readonly post: SocialPost
|
|
34
|
+
/** The still, copied into the person's storage; null when the copy failed
|
|
35
|
+
* (the post's own `media.thumbnailUrl` is then the only, expiring, link). */
|
|
36
|
+
readonly thumbnailUrl: string | null
|
|
37
|
+
readonly note: string
|
|
38
|
+
readonly tags: readonly string[]
|
|
39
|
+
readonly source: SavedPostSource
|
|
40
|
+
readonly createdAt: string
|
|
41
|
+
readonly updatedAt: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The body of `POST /v1/saved-posts`. Saving a post already saved updates
|
|
45
|
+
* its note and tags (when given) and returns the existing save. */
|
|
46
|
+
export type SavePostInput = {
|
|
47
|
+
readonly post: SocialPost
|
|
48
|
+
readonly note?: string
|
|
49
|
+
readonly tags?: readonly string[]
|
|
50
|
+
readonly source?: SavedPostSource
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The body of `PATCH /v1/saved-posts/:id`. */
|
|
54
|
+
export type UpdateSavedPostInput = {
|
|
55
|
+
readonly note?: string
|
|
56
|
+
readonly tags?: readonly string[]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Query of `GET /v1/saved-posts`. */
|
|
60
|
+
export type ListSavedPostsParams = {
|
|
61
|
+
readonly platform?: SocialPlatform
|
|
62
|
+
/** Only saves carrying this tag. */
|
|
63
|
+
readonly tag?: string
|
|
64
|
+
/** Words to find in the note or the post's text. */
|
|
65
|
+
readonly q?: string
|
|
66
|
+
/** The `nextCursor` of the previous page. */
|
|
67
|
+
readonly cursor?: string
|
|
68
|
+
/** 1–100, default 40. */
|
|
69
|
+
readonly limit?: number
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface ListSavedPostsResult {
|
|
73
|
+
readonly data: readonly SavedPost[]
|
|
74
|
+
readonly nextCursor: string | null
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The answer of `POST /v1/saved-posts/lookup`: which of the asked posts are saved. */
|
|
78
|
+
export interface SavedPostsLookupResult {
|
|
79
|
+
readonly saved: ReadonlyArray<{ readonly postId: string; readonly id: string }>
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Tags as stored: split on commas (`,` `,` `、`, so "hooks, openers" is two
|
|
84
|
+
* tags in any script), trimmed, inner whitespace collapsed, lower-cased, a
|
|
85
|
+
* leading `#` dropped, braces, quotes and backslashes removed (they would
|
|
86
|
+
* change a tag filter's meaning), each at most 40 characters, no repeats, at
|
|
87
|
+
* most 10.
|
|
88
|
+
*/
|
|
89
|
+
export function normalizeSavedPostTags(tags: unknown): string[] {
|
|
90
|
+
if (!Array.isArray(tags)) return []
|
|
91
|
+
const clean = tags
|
|
92
|
+
.filter((t): t is string => typeof t === "string")
|
|
93
|
+
.flatMap((t) => t.split(/[,,、]/))
|
|
94
|
+
.map((t) =>
|
|
95
|
+
t
|
|
96
|
+
.replace(/[{}"\\]/g, "")
|
|
97
|
+
.trim()
|
|
98
|
+
.replace(/^#+/, "")
|
|
99
|
+
.replace(/\s+/g, " ")
|
|
100
|
+
.toLowerCase()
|
|
101
|
+
.slice(0, SAVED_POST_TAG_MAX)
|
|
102
|
+
.trim(),
|
|
103
|
+
)
|
|
104
|
+
.filter((t) => t.length > 0)
|
|
105
|
+
return Array.from(new Set(clean)).slice(0, SAVED_POST_MAX_TAGS)
|
|
106
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate Script's request settings: ONE reader for both DAG engines, and the
|
|
3
|
+
* limits the `/v1/generate-script` route validates against.
|
|
4
|
+
*
|
|
5
|
+
* A run reads the node's data AFTER field mappings rewrote it, so a value can
|
|
6
|
+
* arrive in a shape its field never had: a Scene Count or Duration node maps
|
|
7
|
+
* its number as TEXT ("6"), and a Tone mapped from a Text node can be a whole
|
|
8
|
+
* paragraph. Passing those on raw failed the editor's single-node run on the
|
|
9
|
+
* route's 400 and sent the server run's text as-is. This reader coerces instead
|
|
10
|
+
* of rejecting (the `normalizeModelInput` principle): a number-like value
|
|
11
|
+
* becomes a whole number clamped to the route's range, text is trimmed and cut
|
|
12
|
+
* to the route's length, and an unusable value is dropped so the generator's
|
|
13
|
+
* own default applies.
|
|
14
|
+
*/
|
|
15
|
+
import { resolveNodeRefs } from "./node-refs.js"
|
|
16
|
+
import { LLM_TEXT_INPUT_MAX } from "./model-constants.js"
|
|
17
|
+
|
|
18
|
+
export const SCRIPT_SCENE_COUNT_RANGE = { min: 1, max: 20 } as const
|
|
19
|
+
export const SCRIPT_TARGET_DURATION_RANGE = { min: 5, max: 600 } as const
|
|
20
|
+
/** What the script generator uses when a request leaves the field out. */
|
|
21
|
+
export const SCRIPT_SCENE_COUNT_DEFAULT = 5
|
|
22
|
+
/** Seconds; what the script generator uses when a request leaves it out. */
|
|
23
|
+
export const SCRIPT_TARGET_DURATION_DEFAULT = 60
|
|
24
|
+
export const SCRIPT_TONE_MAX_LENGTH = 200
|
|
25
|
+
export const SCRIPT_STYLE_GUIDE_MAX_LENGTH = LLM_TEXT_INPUT_MAX
|
|
26
|
+
|
|
27
|
+
export interface ScriptSettings {
|
|
28
|
+
sceneCount?: number
|
|
29
|
+
tone?: string
|
|
30
|
+
/** Seconds. */
|
|
31
|
+
targetDuration?: number
|
|
32
|
+
styleGuide?: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function clampInt(value: unknown, range: { readonly min: number; readonly max: number }): number | undefined {
|
|
36
|
+
const n = typeof value === "number"
|
|
37
|
+
? value
|
|
38
|
+
: typeof value === "string" && value.trim().length > 0 ? Number(value) : Number.NaN
|
|
39
|
+
if (!Number.isFinite(n)) return undefined
|
|
40
|
+
return Math.min(range.max, Math.max(range.min, Math.round(n)))
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function clampText(value: unknown, max: number): string | undefined {
|
|
44
|
+
if (typeof value !== "string") return undefined
|
|
45
|
+
const text = value.trim()
|
|
46
|
+
return text.length > 0 ? text.slice(0, max) : undefined
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The settings a Generate Script node sends. `refMap` resolves `{Node Label}`
|
|
51
|
+
* references in the style guide, the one field here with a reference-aware
|
|
52
|
+
* editor; references with no matching node stay as typed.
|
|
53
|
+
*/
|
|
54
|
+
export function readScriptSettings(
|
|
55
|
+
data: Record<string, unknown>,
|
|
56
|
+
refMap?: ReadonlyMap<string, string>,
|
|
57
|
+
): ScriptSettings {
|
|
58
|
+
const styleGuide = typeof data.styleGuide === "string" && refMap && refMap.size > 0
|
|
59
|
+
? resolveNodeRefs(data.styleGuide, refMap)
|
|
60
|
+
: data.styleGuide
|
|
61
|
+
return {
|
|
62
|
+
sceneCount: clampInt(data.sceneCount, SCRIPT_SCENE_COUNT_RANGE),
|
|
63
|
+
// The panel's own fields (the ones a mapping writes) come first. `style` is
|
|
64
|
+
// an older key for the tone, and `targetDuration` is the route's name for
|
|
65
|
+
// the length, which workflow JSON written by an agent can carry.
|
|
66
|
+
tone: clampText(data.tone ?? data.style, SCRIPT_TONE_MAX_LENGTH),
|
|
67
|
+
targetDuration: clampInt(data.targetLength ?? data.targetDuration, SCRIPT_TARGET_DURATION_RANGE),
|
|
68
|
+
styleGuide: clampText(styleGuide, SCRIPT_STYLE_GUIDE_MAX_LENGTH),
|
|
69
|
+
}
|
|
70
|
+
}
|