@nodaro/shared 3.66.0 → 3.68.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.
Files changed (77) hide show
  1. package/dist/{chunk-JTYCJ5OL.cjs → chunk-4XR66IWF.cjs} +51 -13
  2. package/dist/chunk-4XR66IWF.cjs.map +1 -0
  3. package/dist/{chunk-6FQBKI2A.cjs → chunk-6JSYNKFL.cjs} +4 -4
  4. package/dist/{chunk-6FQBKI2A.cjs.map → chunk-6JSYNKFL.cjs.map} +1 -1
  5. package/dist/{chunk-23IKLMRL.cjs → chunk-BCY3A62O.cjs} +4 -4
  6. package/dist/{chunk-23IKLMRL.cjs.map → chunk-BCY3A62O.cjs.map} +1 -1
  7. package/dist/{chunk-RVQW623D.js → chunk-BHL7TAQO.js} +43 -12
  8. package/dist/chunk-BHL7TAQO.js.map +1 -0
  9. package/dist/{chunk-CLAKSLXF.js → chunk-E3PU7YC6.js} +3 -3
  10. package/dist/{chunk-CLAKSLXF.js.map → chunk-E3PU7YC6.js.map} +1 -1
  11. package/dist/{chunk-ALRXY4QH.cjs → chunk-N7ZJD4CK.cjs} +6 -2
  12. package/dist/chunk-N7ZJD4CK.cjs.map +1 -0
  13. package/dist/{chunk-O2QOBA6Q.js → chunk-NPGP6FMU.js} +43 -3
  14. package/dist/chunk-NPGP6FMU.js.map +1 -0
  15. package/dist/chunk-NWNRATS3.js +13 -0
  16. package/dist/chunk-NWNRATS3.js.map +1 -0
  17. package/dist/{chunk-NYZQOIXJ.cjs → chunk-Q2LEJXLZ.cjs} +93 -6
  18. package/dist/chunk-Q2LEJXLZ.cjs.map +1 -0
  19. package/dist/{chunk-O6TBB4IF.cjs → chunk-TZWXZDSX.cjs} +48 -2
  20. package/dist/chunk-TZWXZDSX.cjs.map +1 -0
  21. package/dist/{chunk-FGBGKBML.js → chunk-UVUHVY7F.js} +71 -4
  22. package/dist/chunk-UVUHVY7F.js.map +1 -0
  23. package/dist/{chunk-GTBW2KAY.js → chunk-XNJDAW3M.js} +3 -3
  24. package/dist/{chunk-GTBW2KAY.js.map → chunk-XNJDAW3M.js.map} +1 -1
  25. package/dist/entries/credits.cjs +192 -164
  26. package/dist/entries/credits.d.cts +82 -5
  27. package/dist/entries/credits.d.ts +82 -5
  28. package/dist/entries/credits.js +2 -2
  29. package/dist/entries/media.cjs +171 -87
  30. package/dist/entries/media.d.cts +118 -2
  31. package/dist/entries/media.d.ts +118 -2
  32. package/dist/entries/media.js +3 -3
  33. package/dist/entries/models.cjs +82 -82
  34. package/dist/entries/models.js +3 -3
  35. package/dist/entries/runtime-config.cjs +53 -29
  36. package/dist/entries/runtime-config.d.cts +53 -1
  37. package/dist/entries/runtime-config.d.ts +53 -1
  38. package/dist/entries/runtime-config.js +1 -1
  39. package/dist/entries/types.d.cts +12 -5
  40. package/dist/entries/types.d.ts +12 -5
  41. package/dist/index.cjs +495 -359
  42. package/dist/index.d.cts +3 -3
  43. package/dist/index.d.ts +3 -3
  44. package/dist/index.js +6 -6
  45. package/package.json +1 -1
  46. package/src/__tests__/add-captions-nemotron-pricing.test.ts +13 -1
  47. package/src/__tests__/fixtures/measured-input-quote-parity.json +1816 -1
  48. package/src/__tests__/fixtures/planned-length-quote-parity.json +55 -10
  49. package/src/__tests__/fixtures/video-utility-quote-parity.json +834 -38
  50. package/src/__tests__/freecut-ai-panel.test.ts +149 -0
  51. package/src/__tests__/nemotron-transcribe-pricing.test.ts +32 -0
  52. package/src/__tests__/runtime-config-lists.test.ts +92 -0
  53. package/src/catalog-projection.ts +12 -5
  54. package/src/credit-estimators/add-captions-nemotron.ts +11 -1
  55. package/src/credit-estimators/index.ts +6 -1
  56. package/src/credit-estimators/nemotron-transcribe.ts +35 -3
  57. package/src/credit-estimators/pitch-tempo.ts +14 -0
  58. package/src/credit-estimators/video-sfx.ts +15 -0
  59. package/src/credit-estimators/video-utils.ts +48 -12
  60. package/src/entries/credits.ts +1 -0
  61. package/src/entries/media.ts +1 -0
  62. package/src/entries/runtime-config.ts +10 -1
  63. package/src/freecut-ai-panel.ts +172 -0
  64. package/src/freecut-protocol.ts +13 -0
  65. package/src/lip-sync-pricing.ts +15 -0
  66. package/src/priced-clip-seconds.ts +19 -1
  67. package/src/runtime-config/lists.ts +87 -0
  68. package/src/runtime-config/worlds.ts +10 -0
  69. package/dist/chunk-ALRXY4QH.cjs.map +0 -1
  70. package/dist/chunk-FGBGKBML.js.map +0 -1
  71. package/dist/chunk-JTYCJ5OL.cjs.map +0 -1
  72. package/dist/chunk-NYZQOIXJ.cjs.map +0 -1
  73. package/dist/chunk-O2QOBA6Q.js.map +0 -1
  74. package/dist/chunk-O6TBB4IF.cjs.map +0 -1
  75. package/dist/chunk-RVQW623D.js.map +0 -1
  76. package/dist/chunk-SMOO5FAH.js +0 -10
  77. package/dist/chunk-SMOO5FAH.js.map +0 -1
@@ -0,0 +1,149 @@
1
+ import { describe, expect, it, vi } from "vitest"
2
+ import {
3
+ AI_PANEL_EDITOR_ANSWERS,
4
+ AI_PANEL_EDITOR_REQUESTS,
5
+ AI_PANEL_PATH,
6
+ NODARO_AI_PANEL_CLOSE,
7
+ NODARO_AI_PANEL_INIT,
8
+ NODARO_AI_PANEL_LAYOUT,
9
+ NODARO_AI_PANEL_READY,
10
+ aiPanelOffered,
11
+ createAiPanelRelay,
12
+ routeAiPanelMessage,
13
+ type AiPanelRelayContext,
14
+ } from "../freecut-ai-panel.js"
15
+ import {
16
+ FREECUT_OPS_RESULT,
17
+ FREECUT_TIMELINE,
18
+ FREECUT_UNDO_RESULT,
19
+ NODARO_APPLY_OPS,
20
+ NODARO_GET_TIMELINE,
21
+ NODARO_IMPORT_FILES,
22
+ NODARO_PLAYBACK,
23
+ NODARO_PRESENCE,
24
+ NODARO_UNDO_EDIT,
25
+ } from "../freecut-protocol.js"
26
+
27
+ const PANEL_ORIGIN = "https://app.nodaro.ai"
28
+ const EDITOR_ORIGIN = "https://freecut.nodaro.ai"
29
+ const panel = { name: "panel" }
30
+ const editor = { name: "editor" }
31
+ const context = (asked = new Set<string>()): AiPanelRelayContext => ({ panel, panelOrigin: PANEL_ORIGIN, editor, editorOrigin: EDITOR_ORIGIN, asked })
32
+ const fromPanel = (data: unknown) => ({ data, origin: PANEL_ORIGIN, source: panel })
33
+ const fromEditor = (data: unknown) => ({ data, origin: EDITOR_ORIGIN, source: editor })
34
+
35
+ describe("the Edit with AI frame protocol", () => {
36
+ it("pins the wire strings a host and the panel share", () => {
37
+ expect({
38
+ AI_PANEL_PATH,
39
+ NODARO_AI_PANEL_READY,
40
+ NODARO_AI_PANEL_CLOSE,
41
+ NODARO_AI_PANEL_LAYOUT,
42
+ NODARO_AI_PANEL_INIT,
43
+ NODARO_GET_TIMELINE,
44
+ NODARO_APPLY_OPS,
45
+ NODARO_UNDO_EDIT,
46
+ NODARO_PLAYBACK,
47
+ NODARO_PRESENCE,
48
+ FREECUT_TIMELINE,
49
+ FREECUT_OPS_RESULT,
50
+ FREECUT_UNDO_RESULT,
51
+ }).toEqual({
52
+ AI_PANEL_PATH: "/embed/edit-with-ai",
53
+ NODARO_AI_PANEL_READY: "NODARO_AI_PANEL_READY",
54
+ NODARO_AI_PANEL_CLOSE: "NODARO_AI_PANEL_CLOSE",
55
+ NODARO_AI_PANEL_LAYOUT: "NODARO_AI_PANEL_LAYOUT",
56
+ NODARO_AI_PANEL_INIT: "NODARO_AI_PANEL_INIT",
57
+ NODARO_GET_TIMELINE: "NODARO_GET_TIMELINE",
58
+ NODARO_APPLY_OPS: "NODARO_APPLY_OPS",
59
+ NODARO_UNDO_EDIT: "NODARO_UNDO_EDIT",
60
+ NODARO_PLAYBACK: "NODARO_PLAYBACK",
61
+ NODARO_PRESENCE: "NODARO_PRESENCE",
62
+ FREECUT_TIMELINE: "FREECUT_TIMELINE",
63
+ FREECUT_OPS_RESULT: "FREECUT_OPS_RESULT",
64
+ FREECUT_UNDO_RESULT: "FREECUT_UNDO_RESULT",
65
+ })
66
+ expect(AI_PANEL_EDITOR_REQUESTS).toEqual(["NODARO_GET_TIMELINE", "NODARO_APPLY_OPS", "NODARO_UNDO_EDIT", "NODARO_IMPORT_FILES", "NODARO_PLAYBACK", "NODARO_PRESENCE"])
67
+ expect(AI_PANEL_EDITOR_ANSWERS).toEqual(["FREECUT_TIMELINE", "FREECUT_OPS_RESULT", "FREECUT_UNDO_RESULT"])
68
+ })
69
+
70
+ it("is offered only on an editor that can be edited, read, played and shown presence", () => {
71
+ expect(aiPanelOffered(["edit-ops", "timeline-read", "playback", "presence", "timeline-add"])).toBe(true)
72
+ expect(aiPanelOffered(["edit-ops", "timeline-read", "playback"])).toBe(false)
73
+ expect(aiPanelOffered([])).toBe(false)
74
+ })
75
+ })
76
+
77
+ describe("routeAiPanelMessage", () => {
78
+ it("carries each of the panel's editor requests to the editor, as sent", () => {
79
+ for (const type of AI_PANEL_EDITOR_REQUESTS) {
80
+ const payload = { requestId: `r-${type}`, label: "Cut the pauses" }
81
+ expect(routeAiPanelMessage(fromPanel({ type, payload }), context())).toEqual({ to: "editor", message: { type, payload }, transfer: [] })
82
+ }
83
+ })
84
+
85
+ it("hands an import's buffers over again", () => {
86
+ const buffer = new ArrayBuffer(8)
87
+ const payload = { files: [{ ref: "ai-music-1", name: "ai-music.mp3", type: "audio/mpeg", size: 8, buffer }] }
88
+ const route = routeAiPanelMessage(fromPanel({ type: NODARO_IMPORT_FILES, payload }), context())
89
+ expect(route?.to).toBe("editor")
90
+ expect(route?.transfer).toEqual([buffer])
91
+ expect(route?.transfer[0]).toBe(buffer)
92
+ })
93
+
94
+ it("passes back an answer to a request the panel made, once", () => {
95
+ const ctx = context()
96
+ routeAiPanelMessage(fromPanel({ type: NODARO_GET_TIMELINE, payload: { requestId: "r1" } }), ctx)
97
+ const answer = { type: FREECUT_TIMELINE, payload: { requestId: "r1", timeline: { items: [] } } }
98
+ expect(routeAiPanelMessage(fromEditor(answer), ctx)).toEqual({ to: "panel", message: answer, transfer: [] })
99
+ expect(routeAiPanelMessage(fromEditor(answer), ctx)).toBeNull()
100
+ })
101
+
102
+ it("never passes the host's own answers to the panel", () => {
103
+ // The host asked for this one itself (its own requestId), and the panel never did.
104
+ const answer = { type: FREECUT_OPS_RESULT, payload: { requestId: "host-1", ok: true } }
105
+ expect(routeAiPanelMessage(fromEditor(answer), context())).toBeNull()
106
+ expect(routeAiPanelMessage(fromEditor({ type: "FREECUT_TIMELINE_ADDED", payload: { requestId: "host-2" } }), context(new Set(["host-2"])))).toBeNull()
107
+ })
108
+
109
+ it("leaves alone what is not the panel's: other types, other frames, other origins", () => {
110
+ expect(routeAiPanelMessage(fromPanel({ type: "NODARO_LOAD_VIDEO", payload: {} }), context())).toBeNull()
111
+ expect(routeAiPanelMessage(fromPanel({ type: "NODARO_RESET_PROJECT", payload: {} }), context())).toBeNull()
112
+ expect(routeAiPanelMessage({ data: { type: NODARO_APPLY_OPS, payload: {} }, origin: "https://evil.example", source: panel }, context())).toBeNull()
113
+ expect(routeAiPanelMessage({ data: { type: NODARO_APPLY_OPS, payload: {} }, origin: PANEL_ORIGIN, source: { other: true } }, context())).toBeNull()
114
+ const asked = new Set(["r1"])
115
+ expect(routeAiPanelMessage({ data: { type: FREECUT_TIMELINE, payload: { requestId: "r1" } }, origin: PANEL_ORIGIN, source: editor }, context(asked))).toBeNull()
116
+ expect(asked.has("r1")).toBe(true)
117
+ expect(routeAiPanelMessage(fromPanel("NODARO_APPLY_OPS"), context())).toBeNull()
118
+ expect(routeAiPanelMessage(fromPanel(null), context())).toBeNull()
119
+ })
120
+
121
+ it("does not route for a frame that is gone", () => {
122
+ const gone: AiPanelRelayContext = { ...context(), panel: null }
123
+ expect(routeAiPanelMessage({ data: { type: NODARO_PLAYBACK, payload: { action: "play" } }, origin: PANEL_ORIGIN, source: null }, gone)).toBeNull()
124
+ })
125
+ })
126
+
127
+ describe("createAiPanelRelay", () => {
128
+ it("posts requests to the editor and answers to the panel, each on its own origin, until disposed", () => {
129
+ let listener: ((event: MessageEvent) => void) | null = null
130
+ const host = {
131
+ addEventListener: vi.fn((_type: "message", fn: (event: MessageEvent) => void) => {
132
+ listener = fn
133
+ }),
134
+ removeEventListener: vi.fn(),
135
+ }
136
+ const panelWindow = { postMessage: vi.fn() }
137
+ const editorWindow = { postMessage: vi.fn() }
138
+ const relay = createAiPanelRelay({ host, panel: () => panelWindow, panelOrigin: PANEL_ORIGIN, editor: () => editorWindow, editorOrigin: EDITOR_ORIGIN })
139
+ const send = (data: unknown, origin: string, source: unknown) => listener!({ data, origin, source } as MessageEvent)
140
+
141
+ send({ type: NODARO_APPLY_OPS, payload: { requestId: "r9", label: "Cut", ops: [] } }, PANEL_ORIGIN, panelWindow)
142
+ expect(editorWindow.postMessage).toHaveBeenCalledWith({ type: NODARO_APPLY_OPS, payload: { requestId: "r9", label: "Cut", ops: [] } }, EDITOR_ORIGIN, [])
143
+ send({ type: FREECUT_OPS_RESULT, payload: { requestId: "r9", ok: true } }, EDITOR_ORIGIN, editorWindow)
144
+ expect(panelWindow.postMessage).toHaveBeenCalledWith({ type: FREECUT_OPS_RESULT, payload: { requestId: "r9", ok: true } }, PANEL_ORIGIN, [])
145
+
146
+ relay.dispose()
147
+ expect(host.removeEventListener).toHaveBeenCalledWith("message", listener)
148
+ })
149
+ })
@@ -2,12 +2,16 @@ import { describe, expect, it } from "vitest"
2
2
  import {
3
3
  NEMOTRON_TRANSCRIBE_ID,
4
4
  NEMOTRON_TRANSCRIBE_PRICING,
5
+ NEMOTRON_UPWARD_GRACE_SEC,
6
+ nemotronHeldMinutes,
5
7
  nemotronTranscribeBaseCredits,
6
8
  nemotronTranscribeCreditId,
9
+ nemotronTranscribeHeldCreditId,
7
10
  nemotronTranscribeQuoteCreditId,
8
11
  nemotronTranscribeStartedMinutes,
9
12
  parseNemotronTranscribeCreditId,
10
13
  } from "../credit-estimators/nemotron-transcribe.js"
14
+ import { addCaptionsNemotronHeldCreditId, addCaptionsNemotronQuoteCreditId, parseAddCaptionsNemotronCreditId } from "../credit-estimators/add-captions-nemotron.js"
11
15
  import { MODEL_CATALOG } from "../model-catalog.js"
12
16
 
13
17
  const RATE = NEMOTRON_TRANSCRIBE_PRICING.CREDITS_PER_RATE_DEFAULT
@@ -53,6 +57,34 @@ describe("Nemotron 3.5 Transcribe pricing (per started minute, decided 2026-11-1
53
57
  expect(nemotronTranscribeQuoteCreditId(125)).toBe("nemotron-3-5-transcribe:3m")
54
58
  })
55
59
 
60
+ it("holds a measured file at the minutes the charge settles at: up to the grace past a minute is the minute below", () => {
61
+ expect(NEMOTRON_UPWARD_GRACE_SEC).toBe(1)
62
+ // A re-encoded 60-second cut measures a hair past 60 s (60.0004–60.011 s): held, and charged, at one minute.
63
+ expect(nemotronHeldMinutes(60)).toBe(1)
64
+ expect(nemotronHeldMinutes(60.0004)).toBe(1)
65
+ expect(nemotronHeldMinutes(60.011)).toBe(1)
66
+ expect(nemotronHeldMinutes(61)).toBe(1)
67
+ expect(nemotronHeldMinutes(61.001)).toBe(2)
68
+ expect(nemotronHeldMinutes(0.4)).toBe(1)
69
+ expect(nemotronHeldMinutes(3600)).toBe(60)
70
+ expect(nemotronTranscribeHeldCreditId(60.011)).toBe("nemotron-3-5-transcribe:1m")
71
+ expect(nemotronTranscribeHeldCreditId(125)).toBe("nemotron-3-5-transcribe:3m")
72
+ })
73
+
74
+ // The guard: a quote of a known length is never below the hold of a file that measures up to the grace past it.
75
+ const KNOWN = [0.5, 1, 30, 59, 59.5, 60, 60.5, 61, 119, 120, 180, 599.99, 600, 1800, 3540, 3599, 3600]
76
+ const OVER = [0, 1e-6, 0.0004, 0.011, 0.25, 0.5, 0.999, NEMOTRON_UPWARD_GRACE_SEC]
77
+ it.each(KNOWN)("a quote of %s s is never below the hold of a file measured up to the grace past it", (known) => {
78
+ for (const over of OVER) {
79
+ const measured = Math.min(known + over, NEMOTRON_TRANSCRIBE_PRICING.MAX_DURATION_SEC)
80
+ const quoted = parseNemotronTranscribeCreditId(nemotronTranscribeQuoteCreditId(known))!.minutes
81
+ expect(parseNemotronTranscribeCreditId(nemotronTranscribeHeldCreditId(measured))!.minutes, `${known} + ${over}`).toBeLessThanOrEqual(quoted)
82
+ // Add Captions on Nemotron: the same rule, its own ids.
83
+ const captionQuote = parseAddCaptionsNemotronCreditId(addCaptionsNemotronQuoteCreditId(known))!.minutes
84
+ expect(parseAddCaptionsNemotronCreditId(addCaptionsNemotronHeldCreditId(measured))!.minutes, `${known} + ${over}`).toBeLessThanOrEqual(captionQuote)
85
+ }
86
+ })
87
+
56
88
  it("lists the four-minute rate row in the catalog at the launch rate", () => {
57
89
  const entry = MODEL_CATALOG[NEMOTRON_TRANSCRIBE_ID as keyof typeof MODEL_CATALOG] as unknown as { pricing: Array<{ identifier: string; credits: number }>; maker?: string }
58
90
  expect(entry.pricing).toEqual([expect.objectContaining({ identifier: NEMOTRON_TRANSCRIBE_PRICING.RATE_CREDIT_ID, credits: RATE })])
@@ -0,0 +1,92 @@
1
+ import { describe, expect, it } from "vitest"
2
+ import {
3
+ ALLOW_LIST_EXEMPT_NODE_TYPES,
4
+ WORLD_IDS,
5
+ isAllowListGatedNodeType,
6
+ listsSet,
7
+ listsWithhold,
8
+ nodeListsWithhold,
9
+ worldOffered,
10
+ } from "../entries/runtime-config.js"
11
+
12
+ const NONE = { allow: [], deny: [] }
13
+ const everything = () => true
14
+
15
+ describe("listsWithhold — a deployment's own allow/deny lists", () => {
16
+ it("lists that are not set withhold nothing", () => {
17
+ expect(listsWithhold(NONE, "generate-image", everything)).toBe(false)
18
+ expect(listsSet(NONE)).toBe(false)
19
+ expect(listsSet(undefined)).toBe(false)
20
+ })
21
+
22
+ it("a non-empty allow withholds every governed id outside it", () => {
23
+ const lists = { allow: ["generate-image"], deny: [] }
24
+ expect(listsSet(lists)).toBe(true)
25
+ expect(listsWithhold(lists, "generate-image", everything)).toBe(false)
26
+ expect(listsWithhold(lists, "generate-video", everything)).toBe(true)
27
+ })
28
+
29
+ it("an id the allow list does not govern is withheld only by deny", () => {
30
+ const lists = { allow: ["generate-image"], deny: ["preview"] }
31
+ const governed = (id: string) => id !== "sticky-note" && id !== "preview"
32
+ expect(listsWithhold(lists, "sticky-note", governed)).toBe(false)
33
+ expect(listsWithhold(lists, "preview", governed)).toBe(true)
34
+ })
35
+
36
+ it("deny withholds what it names, also inside allow", () => {
37
+ const lists = { allow: ["generate-image", "dubbing"], deny: ["dubbing"] }
38
+ expect(listsSet({ allow: [], deny: ["dubbing"] })).toBe(true)
39
+ expect(listsWithhold(lists, "dubbing", everything)).toBe(true)
40
+ expect(listsWithhold(lists, "generate-image", everything)).toBe(false)
41
+ })
42
+ })
43
+
44
+ describe("nodeListsWithhold — the node lists", () => {
45
+ it("a whitelist never withholds a utility node or Site Capture by leaving it out", () => {
46
+ const lists = { allow: ["generate-image"], deny: [] }
47
+ expect(ALLOW_LIST_EXEMPT_NODE_TYPES).toEqual(expect.arrayContaining(["sticky-note", "preview", "group", "site-capture"]))
48
+ for (const type of ALLOW_LIST_EXEMPT_NODE_TYPES) {
49
+ expect(isAllowListGatedNodeType(type), type).toBe(false)
50
+ expect(nodeListsWithhold(lists, type), type).toBe(false)
51
+ expect(nodeListsWithhold({ allow: ["generate-image"], deny: [type] }, type), type).toBe(true)
52
+ }
53
+ })
54
+
55
+ it("a whitelist withholds every other node type it does not list, features with no canvas node included", () => {
56
+ const lists = { allow: ["generate-image", "dubbing"], deny: [] }
57
+ for (const type of ["generate-video", "combine-text", "sub-workflow", "cast-swap", "voice-clone-one-off"]) {
58
+ expect(isAllowListGatedNodeType(type), type).toBe(true)
59
+ expect(nodeListsWithhold(lists, type), type).toBe(true)
60
+ }
61
+ expect(nodeListsWithhold(lists, "dubbing")).toBe(false)
62
+ })
63
+
64
+ it("a deny of the Voice Clone node withholds a one-off clone too; a whitelist without it does not", () => {
65
+ expect(nodeListsWithhold({ allow: [], deny: ["voice-clone"] }, "voice-clone-one-off")).toBe(true)
66
+ expect(nodeListsWithhold({ allow: ["voice-clone-one-off"], deny: [] }, "voice-clone-one-off")).toBe(false)
67
+ })
68
+
69
+ it("takes the caller's own idea of what a whitelist governs", () => {
70
+ const lists = { allow: ["generate-image"], deny: [] }
71
+ expect(nodeListsWithhold(lists, "a-type-the-caller-does-not-know", (type) => type === "generate-video")).toBe(false)
72
+ expect(nodeListsWithhold(lists, "generate-video", (type) => type === "generate-video")).toBe(true)
73
+ })
74
+ })
75
+
76
+ describe("worldOffered — a world, by the profile's allowlist and the node types it runs", () => {
77
+ it("every world, where nothing is withheld and no allowlist is set", () => {
78
+ for (const id of WORLD_IDS) expect(worldOffered(undefined, id, () => false), id).toBe(true)
79
+ })
80
+
81
+ it("not a world the allowlist leaves out", () => {
82
+ expect(worldOffered({ allow: ["image"] }, "video", () => false)).toBe(false)
83
+ expect(worldOffered({ allow: ["image"] }, "image", () => false)).toBe(true)
84
+ })
85
+
86
+ it("not a world one of whose node types is withheld; a world that runs none follows the allowlist alone", () => {
87
+ const withheld = (type: string) => type === "text-to-video"
88
+ expect(worldOffered(undefined, "video", withheld)).toBe(false)
89
+ expect(worldOffered(undefined, "image", withheld)).toBe(true)
90
+ expect(worldOffered(undefined, "app", () => true)).toBe(true)
91
+ })
92
+ })
@@ -50,6 +50,13 @@ export interface ProjectedCatalogOption {
50
50
  * look previews, which only Nodaro Cloud serves. Absent when the option has
51
51
  * no picture. Content-hashed where self-hosted: a changed picture gets a new
52
52
  * URL, so it can be cached indefinitely.
53
+ *
54
+ * On a deployment that shows its own pictures (`catalogs.images: "own"`) it
55
+ * is the deployment's picture: an absolute URL on its media host, or — on
56
+ * the REST replies — a path on the deployment's own site (`/brand/…`), which
57
+ * resolves against the address the API was called at (a page on that site
58
+ * uses it as it is; a client elsewhere resolves it against its API base).
59
+ * The MCP tools give that path absolute.
53
60
  */
54
61
  imageUrl?: string
55
62
  /**
@@ -61,11 +68,11 @@ export interface ProjectedCatalogOption {
61
68
  */
62
69
  imageSrcSet?: string
63
70
  /**
64
- * Absolute URL of the option's enlarged picture: the larger version to show
65
- * where a picker shows the option big (hover, zoom, a detail view). Present
66
- * only on a deployment that shows its own pictures (`catalogs.images:
67
- * "own"`) and gave one for this option, on the REST replies; on its media
68
- * host, like `imageUrl`. Absent otherwise — draw `imageUrl` there instead.
71
+ * The option's enlarged picture: the larger version to show where a picker
72
+ * shows the option big (hover, zoom, a detail view). Present only on a
73
+ * deployment that shows its own pictures (`catalogs.images: "own"`) and gave
74
+ * one for this option, on the REST replies; on its media host or a path on
75
+ * its site, like `imageUrl`. Absent otherwise — draw `imageUrl` there instead.
69
76
  */
70
77
  imageLargeUrl?: string
71
78
  }
@@ -21,6 +21,7 @@
21
21
  */
22
22
  import {
23
23
  NEMOTRON_TRANSCRIBE_PRICING,
24
+ nemotronHeldMinutes,
24
25
  nemotronTranscribeBaseCredits,
25
26
  nemotronTranscribeStartedMinutes,
26
27
  } from "./nemotron-transcribe.js"
@@ -37,11 +38,20 @@ export function addCaptionsNemotronMinutesId(minutes: number): string {
37
38
  return `${ADD_CAPTIONS_NEMOTRON_ID_PREFIX}:${n}m`
38
39
  }
39
40
 
40
- /** The id a Nemotron caption run on a video of `durationSec` seconds holds (its started minutes). */
41
+ /** The id of a Nemotron caption run on a video of `durationSec` seconds' started minutes (the price of that length; a quote names it). */
41
42
  export function addCaptionsNemotronCreditId(durationSec: number | null | undefined): string {
42
43
  return addCaptionsNemotronMinutesId(nemotronTranscribeStartedMinutes(durationSec))
43
44
  }
44
45
 
46
+ /**
47
+ * The id a Nemotron caption run on a video it measured at `measuredSec`
48
+ * seconds HOLDS: the started minutes less the one second its charge forgives
49
+ * (`nemotronHeldMinutes`, the Transcribe node's own rule).
50
+ */
51
+ export function addCaptionsNemotronHeldCreditId(measuredSec: number): string {
52
+ return addCaptionsNemotronMinutesId(nemotronHeldMinutes(measuredSec))
53
+ }
54
+
45
55
  /**
46
56
  * The id a QUOTE names for a video of `durationSec` seconds — every estimate
47
57
  * before a run. A known length is the id its run holds; an UNKNOWN length is
@@ -14,7 +14,7 @@ export {
14
14
  imageOverlayCredits,
15
15
  } from "./image-overlay.js"
16
16
 
17
- export { VIDEO_SFX_PRICING, videoSfxCreditId, videoSfxQuoteCreditId } from "./video-sfx.js"
17
+ export { VIDEO_SFX_PRICING, videoSfxCreditId, videoSfxHeldCreditId, videoSfxQuoteCreditId } from "./video-sfx.js"
18
18
 
19
19
  export {
20
20
  TEXT_TO_AUDIO_PRICING,
@@ -80,6 +80,7 @@ export {
80
80
  PITCH_TEMPO_LIMITS,
81
81
  pitchTempoStartedMinutes,
82
82
  pitchTempoCreditId,
83
+ pitchTempoHeldCreditId,
83
84
  pitchTempoQuoteCreditId,
84
85
  parsePitchTempoCreditId,
85
86
  pitchTempoBaseCredits,
@@ -89,8 +90,11 @@ export {
89
90
  export {
90
91
  NEMOTRON_TRANSCRIBE_ID,
91
92
  NEMOTRON_TRANSCRIBE_PRICING,
93
+ NEMOTRON_UPWARD_GRACE_SEC,
92
94
  nemotronTranscribeStartedMinutes,
95
+ nemotronHeldMinutes,
93
96
  nemotronTranscribeCreditId,
97
+ nemotronTranscribeHeldCreditId,
94
98
  nemotronTranscribeQuoteCreditId,
95
99
  parseNemotronTranscribeCreditId,
96
100
  nemotronTranscribeBaseCredits,
@@ -101,6 +105,7 @@ export {
101
105
  ADD_CAPTIONS_NEMOTRON_ID_PREFIX,
102
106
  addCaptionsNemotronMinutesId,
103
107
  addCaptionsNemotronCreditId,
108
+ addCaptionsNemotronHeldCreditId,
104
109
  addCaptionsNemotronQuoteCreditId,
105
110
  parseAddCaptionsNemotronCreditId,
106
111
  addCaptionsNemotronBaseCredits,
@@ -5,7 +5,8 @@
5
5
  * The base price is 0.75 credits a minute, which no whole-credit row can hold
6
6
  * (`model_pricing.credit_cost` is an integer), so the rate row prices FOUR
7
7
  * minutes — the same trick as Nodaro Video Upscale's four-second rows. A run
8
- * reserves `nemotron-3-5-transcribe:<N>m` (N = started minutes, 1..60), which
8
+ * reserves `nemotron-3-5-transcribe:<N>m` (N = started minutes, 1..60; a
9
+ * measured file's less the one second its charge forgives), which
9
10
  * billing prices as that row × N ÷ 4, rounded up once for the whole run, then
10
11
  * marked up once — never a row of its own, so a retune of the rate row moves
11
12
  * the route, the workflow run, the node's Run button and every estimate
@@ -16,7 +17,9 @@
16
17
  * `lib/nemotron-transcribe-settle.ts`).
17
18
  *
18
19
  * Worked base prices at the row's launch value of 3 (per 4 minutes):
19
- * 0:45 → 1, 1:00 → 1, 1:01 → 2, 10:00 → 8, 60:00 → 45.
20
+ * 0:45 → 1, 1:00 → 1, 1:05 → 2, 10:00 → 8, 60:00 → 45
21
+ * (a length's started minutes; a measured file up to 1 s past a minute is
22
+ * held and charged the minute below, {@link nemotronHeldMinutes}).
20
23
  * The listed (marked-up) price follows from those.
21
24
  */
22
25
 
@@ -50,11 +53,40 @@ export function nemotronTranscribeStartedMinutes(durationSec: number | null | un
50
53
  return Math.min(NEMOTRON_TRANSCRIBE_PRICING.MAX_MINUTES, Math.max(1, Math.ceil(durationSec / 60)))
51
54
  }
52
55
 
53
- /** `nemotron-3-5-transcribe:<N>m` — the id a run on a file of `durationSec` seconds reserves. */
56
+ /** `nemotron-3-5-transcribe:<N>m` — the id of `durationSec` seconds' started minutes (the price of that length; a quote names it). */
54
57
  export function nemotronTranscribeCreditId(durationSec: number | null | undefined): string {
55
58
  return `${NEMOTRON_TRANSCRIBE_ID}:${nemotronTranscribeStartedMinutes(durationSec)}m`
56
59
  }
57
60
 
61
+ /**
62
+ * How far past a whole minute a file may run and still be held and charged the
63
+ * minute below it: one second (decided 2026-11-12 for the charge, which reads
64
+ * KIE's decoded length; the hold reads it too, {@link nemotronHeldMinutes}).
65
+ * Decoders and containers disagree by a few hundredths at a file's end — a
66
+ * 60-second cut re-encoded with its sound measures 60.0004–60.011 s.
67
+ */
68
+ export const NEMOTRON_UPWARD_GRACE_SEC = 1
69
+
70
+ /**
71
+ * The started minutes a run HOLDS for a file it measured at `measuredSec`
72
+ * before it runs: those of the length less {@link NEMOTRON_UPWARD_GRACE_SEC},
73
+ * at least 1, at most 60 — the minutes its charge settles at when KIE decodes
74
+ * the file within the grace of them (backend `nemotronChargeId`, which forgives
75
+ * only a length past the HELD minutes). So a quote of a length the graph knows
76
+ * is never below the hold of a file that measures up to the grace past it, and
77
+ * a file a hair past a minute is held and charged as that minute. The one rule
78
+ * both holds read: the Transcribe node's (`nemotronTranscribeHeldCreditId`) and
79
+ * Add Captions' on Nemotron (`addCaptionsNemotronHeldCreditId`).
80
+ */
81
+ export function nemotronHeldMinutes(measuredSec: number): number {
82
+ return nemotronTranscribeStartedMinutes(measuredSec - NEMOTRON_UPWARD_GRACE_SEC)
83
+ }
84
+
85
+ /** `nemotron-3-5-transcribe:<N>m` — the id a run on a file it measured at `measuredSec` seconds holds ({@link nemotronHeldMinutes}). */
86
+ export function nemotronTranscribeHeldCreditId(measuredSec: number): string {
87
+ return `${NEMOTRON_TRANSCRIBE_ID}:${nemotronHeldMinutes(measuredSec)}m`
88
+ }
89
+
58
90
  /**
59
91
  * The id a QUOTE names for a file of `durationSec` seconds — every estimate
60
92
  * before a run. A known length is the id its run reserves. An UNKNOWN length is
@@ -14,6 +14,8 @@
14
14
  * 0:45 → 20, 1:00 → 20, 1:01 → 40, 3:10 → 80, 30:00 → 600.
15
15
  */
16
16
 
17
+ import { gracedMeasuredSec } from "../priced-clip-seconds.js"
18
+
17
19
  export const PITCH_TEMPO_PRICING = {
18
20
  /** The rate row: credits per started minute. Never reserved by itself. */
19
21
  RATE_CREDIT_ID: "pitch-tempo",
@@ -49,6 +51,18 @@ export function pitchTempoCreditId(durationSec: number | null | undefined): stri
49
51
  return `pitch-tempo:${pitchTempoStartedMinutes(durationSec)}m`
50
52
  }
51
53
 
54
+ /**
55
+ * `pitch-tempo:<N>m` — the id a run HOLDS and is CHARGED for an input it
56
+ * measured at `measuredSec` seconds: the started minutes of the length less
57
+ * `CLIP_PRICE_GRACE_SEC` (0.05 s, decided 2026-11-14), so a file a hair past a
58
+ * minute is charged the minute its length is quoted at
59
+ * ({@link pitchTempoQuoteCreditId} reads the length exactly).
60
+ */
61
+ export function pitchTempoHeldCreditId(measuredSec: number): string {
62
+ // Less a float-noise hair too (`gracedMeasuredSec`): 60.05 s less 0.05 s is 60.00000000000001, not past a minute.
63
+ return pitchTempoCreditId(Math.max(Number.MIN_VALUE, gracedMeasuredSec(measuredSec)))
64
+ }
65
+
52
66
  /**
53
67
  * The id a QUOTE names for an input of `durationSec` seconds — every estimate
54
68
  * before a run. A known length is the id its run reserves
@@ -10,6 +10,8 @@
10
10
  * 5 s → `:8s`, 12 s → `:15s`, 31 s → `:60s`, 180 s → `:300s`.
11
11
  */
12
12
 
13
+ import { gracedMeasuredSec } from "../priced-clip-seconds.js"
14
+
13
15
  export const VIDEO_SFX_PRICING = {
14
16
  /** The longest input video a run accepts, in seconds. */
15
17
  MAX_DURATION_SEC: 300,
@@ -40,6 +42,19 @@ export function videoSfxCreditId(durationSec: number | null | undefined): string
40
42
  return bucket.creditId
41
43
  }
42
44
 
45
+ /**
46
+ * The price row a run HOLDS and is CHARGED for an input video it measured at
47
+ * `measuredSec` seconds: the row of the length less `CLIP_PRICE_GRACE_SEC`
48
+ * (0.05 s, decided 2026-11-14), so a container a hair past a row's length (a
49
+ * re-encoded 30 s cut measures 30.016 s) is charged that row, the one its
50
+ * length is quoted at ({@link videoSfxQuoteCreditId}, which reads the length
51
+ * exactly). Past the grace, the next row.
52
+ */
53
+ export function videoSfxHeldCreditId(measuredSec: number): string {
54
+ // Less a float-noise hair too (`gracedMeasuredSec`): 15.05 s less 0.05 s is 15.000000000000002, not past 15 s.
55
+ return videoSfxCreditId(Math.max(Number.MIN_VALUE, gracedMeasuredSec(measuredSec)))
56
+ }
57
+
43
58
  /**
44
59
  * The price row a QUOTE names for an input video of `durationSec` seconds —
45
60
  * every estimate before a run (the node's Run button, the workflow estimate,
@@ -58,8 +58,30 @@ export interface CombineVideosEstimatorInput {
58
58
  transitionDuration?: number
59
59
  trimStartFrames?: number
60
60
  trimEndFrames?: number
61
+ /**
62
+ * The frame rate the clips' frame trims are cut at (the rate the join
63
+ * conforms its clips to), when known. Absent, 24 fps, the estimate's
64
+ * long-standing assumption. The trims come off at the joins only: the start
65
+ * of every clip but the first, the end of every clip but the last.
66
+ */
67
+ trimFramesPerSecond?: number
68
+ /**
69
+ * Per-join transitions (Combine Videos' `transitions`): `index` k is the
70
+ * join between clip k and clip k + 1. A join with an entry blends for its
71
+ * own `duration` (a `"cut"`, or a duration of 0, overlaps nothing); every
72
+ * other join keeps `transition` / `transitionDuration`. An index outside the
73
+ * joins is ignored, and a later entry for the same join wins, as the join
74
+ * renders them.
75
+ */
76
+ transitions?: ReadonlyArray<{ readonly index?: number; readonly transition?: string; readonly duration?: number }>
61
77
  }
62
78
 
79
+ /** The most a join may overlap, as a share of the shortest clip it joins (the render's own clamp). */
80
+ const COMBINE_MAX_OVERLAP_SHARE = 0.9
81
+
82
+ /** A length in seconds when it is a positive one, else 0 (a transition with no length overlaps nothing). */
83
+ const positiveSeconds = (v: unknown): number => (typeof v === "number" && Number.isFinite(v) && v > 0 ? v : 0)
84
+
63
85
  export function estimateLoopVideoCredits(
64
86
  data: LoopVideoEstimatorInput,
65
87
  upstreamDuration?: number,
@@ -130,19 +152,33 @@ export function estimateCombineVideosCredits(
130
152
  const fallback = VIDEO_UTIL_PRICING.FALLBACK_DURATION_SECONDS
131
153
  const n = upstreamDurations.length
132
154
 
133
- let total = 0
134
- for (const d of upstreamDurations) {
135
- total += typeof d === "number" && Number.isFinite(d) && d >= 0 ? d : fallback
155
+ const trimFps =
156
+ data.trimFramesPerSecond !== undefined && Number.isFinite(data.trimFramesPerSecond) && data.trimFramesPerSecond > 0
157
+ ? data.trimFramesPerSecond
158
+ : VIDEO_UTIL_PRICING.FRAMES_PER_CREDIT
159
+ const startSec = (data.trimStartFrames ?? 0) / trimFps
160
+ const endSec = (data.trimEndFrames ?? 0) / trimFps
161
+ // Each clip as the join cuts it: the trims come off only where two clips
162
+ // meet — the start of every clip but the first, the end of every clip but
163
+ // the last. The film's own first and last frames are kept.
164
+ const clips = upstreamDurations.map((d, i) => {
165
+ const sec = typeof d === "number" && Number.isFinite(d) && d >= 0 ? d : fallback
166
+ return sec - (i > 0 ? startSec : 0) - (i < n - 1 ? endSec : 0)
167
+ })
168
+ let total = clips.reduce((sum, sec) => sum + sec, 0)
169
+
170
+ // Each join's overlap, as the join renders it: its own transition where one
171
+ // is set, else the global one; at most 90 % of the shortest clip.
172
+ const globalOverlap = data.transition && data.transition !== "cut" ? Math.max(0, data.transitionDuration ?? 0.5) : 0
173
+ const overrides = new Map<number, number>()
174
+ for (const entry of data.transitions ?? []) {
175
+ const index = entry?.index
176
+ if (typeof index !== "number" || !Number.isInteger(index) || index < 0 || index >= n - 1) continue
177
+ const overlap = positiveSeconds(entry.duration)
178
+ overrides.set(index, entry.transition === "cut" ? 0 : overlap)
136
179
  }
137
-
138
- if (data.transition && data.transition !== "cut" && n > 1) {
139
- total -= (data.transitionDuration ?? 0.5) * (n - 1)
140
- }
141
-
142
- const trimSecPerClip =
143
- ((data.trimStartFrames ?? 0) + (data.trimEndFrames ?? 0)) /
144
- VIDEO_UTIL_PRICING.FRAMES_PER_CREDIT
145
- total -= trimSecPerClip * n
180
+ const maxOverlap = Math.max(0, Math.min(...clips) * COMBINE_MAX_OVERLAP_SHARE)
181
+ for (let k = 0; k < n - 1; k++) total -= Math.min(overrides.get(k) ?? globalOverlap, maxOverlap)
146
182
 
147
183
  const base = Math.ceil(Math.max(0, total) / 5)
148
184
  const inputAdder = Math.max(0, n - 2)
@@ -103,6 +103,7 @@ export {
103
103
  OMNIHUMAN_2_0_PER_SECOND_CREDIT_ID,
104
104
  lipSyncAudioRateOf,
105
105
  lipSyncBilledSeconds,
106
+ lipSyncHeldSeconds,
106
107
  lipSyncEstimateSeconds,
107
108
  lipSyncFifteenSecondCreditId,
108
109
  LIP_SYNC_UNMEASURED_ESTIMATE_SECONDS,
@@ -6,6 +6,7 @@
6
6
  * `@nodaro/shared`.
7
7
  */
8
8
  export * from "../freecut-protocol.js"
9
+ export * from "../freecut-ai-panel.js"
9
10
  export { describeMaskRegion } from "../inpaint-region.js"
10
11
  export type { MaskRegionDescriptor, PixelBox } from "../inpaint-region.js"
11
12
  export * from "../priced-clip-seconds.js"
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `@nodaro/shared/runtime-config` — The deployment runtime config contract: `/config.js`'s keys and their shapes, a lenient parser, and the worlds a deployment can offer.
2
+ * `@nodaro/shared/runtime-config` — The deployment runtime config contract: `/config.js`'s keys and their shapes, a lenient parser, the worlds a deployment can offer, and how its own lists withhold what it offers.
3
3
  *
4
4
  * One of the package's subpath entries (see `src/index.ts`). The root
5
5
  * re-exports every entry, so each name here is also importable from
@@ -10,10 +10,19 @@ export {
10
10
  WORLD_REQUIRED_NODE_TYPES,
11
11
  isWorldId,
12
12
  worldAllowed,
13
+ worldOffered,
13
14
  orderWorlds,
14
15
  type WorldId,
15
16
  type SurfaceWorlds,
16
17
  } from "../runtime-config/worlds.js"
18
+ export {
19
+ ALLOW_LIST_EXEMPT_NODE_TYPES,
20
+ isAllowListGatedNodeType,
21
+ listsSet,
22
+ listsWithhold,
23
+ nodeListsWithhold,
24
+ type SurfaceAllowDeny,
25
+ } from "../runtime-config/lists.js"
17
26
  export {
18
27
  RUNTIME_CONFIG_GLOBAL,
19
28
  RUNTIME_CONFIG_KEYS,