@nodetool-ai/storyboard 0.8.1

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/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # @nodetool-ai/storyboard
2
+
3
+ Storyboard derivations, shared by the `nodetool.storyboard.*` nodes, the agent
4
+ capabilities and the board editor.
5
+
6
+ - `recastStoryboard` — the same approved board with a different cast: entities
7
+ substituted, their names rewritten whole-word through the shot text, and only
8
+ the takes whose prompt actually moved cleared.
9
+ - `planShotRenders` — what a render call would send per shot, and which shots
10
+ are already up to date.
11
+ - `renderShots` — the one path that spends: generate, stamp the render record,
12
+ write the shot back with a compare-and-set.
13
+
14
+ The pure half depends on `@nodetool-ai/protocol` and `@nodetool-ai/timeline`
15
+ only. The IO half takes a host interface, so it stays below runtime and models
16
+ in the build order.
17
+
18
+ See [AGENTS.md](AGENTS.md) and
19
+ [docs/graph-resources/design.md](../../docs/graph-resources/design.md) §3.1.
@@ -0,0 +1 @@
1
+ 2026-09-28T09:19:05.727Z
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The persisted storyboard payload, as this package sees it.
3
+ *
4
+ * The authoritative declaration is `StoryboardDocument` in
5
+ * `@nodetool-ai/models`, which this package cannot import: models sits above
6
+ * runtime in the build order and this one sits directly on protocol + timeline
7
+ * (design §3.1). The two declarations are structurally identical, so a models
8
+ * document is passed straight in and a derived document straight back out; a
9
+ * field added there without being added here fails the caller's assignment
10
+ * rather than going missing quietly.
11
+ */
12
+ import type { CreativeContext, Screenplay, Shot } from "@nodetool-ai/protocol";
13
+ import type { StoryboardSetupStage } from "@nodetool-ai/protocol/api-schemas/storyboards.js";
14
+ export interface StoryboardDocument {
15
+ screenplay: Screenplay | null;
16
+ shots: Shot[];
17
+ brief: string;
18
+ style: string;
19
+ creative_context?: CreativeContext;
20
+ /** Library entity (asset) ids applied to the board's shot prompts. */
21
+ entityIds: string[];
22
+ aspectRatio: string;
23
+ setupStage: StoryboardSetupStage;
24
+ genre: string;
25
+ directorModel: Record<string, unknown> | null;
26
+ imageModel: Record<string, unknown> | null;
27
+ videoModel: Record<string, unknown> | null;
28
+ /** The board this one was recast from (design §2.1). */
29
+ templateId?: string | null;
30
+ /** The canonical substitution mapping that produced this copy. */
31
+ recastKey?: string | null;
32
+ }
33
+ //# sourceMappingURL=document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AAE7F,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,eAAe,CAAC;IACnC,sEAAsE;IACtE,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,oBAAoB,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC9C,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC3C,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC3C,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The persisted storyboard payload, as this package sees it.
3
+ *
4
+ * The authoritative declaration is `StoryboardDocument` in
5
+ * `@nodetool-ai/models`, which this package cannot import: models sits above
6
+ * runtime in the build order and this one sits directly on protocol + timeline
7
+ * (design §3.1). The two declarations are structurally identical, so a models
8
+ * document is passed straight in and a derived document straight back out; a
9
+ * field added there without being added here fails the caller's assignment
10
+ * rather than going missing quietly.
11
+ */
12
+ export {};
13
+ //# sourceMappingURL=document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.js","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @nodetool-ai/storyboard — storyboard derivations.
3
+ *
4
+ * Recasting a board onto a new cast and planning its shot renders are
5
+ * storyboard-only, need protocol's prompt composition and timeline's linked
6
+ * shot timing, and are called from three places: the `nodetool.storyboard.*`
7
+ * nodes, the agent capabilities, and the board editor. Hence a package of their
8
+ * own (design §3.1). `recast.ts` and `render-plan.ts` are pure; `io/` holds the
9
+ * one render path that spends money.
10
+ */
11
+ export type { StoryboardDocument } from "./document.js";
12
+ export { recastStoryboard, recastKeyFor } from "./recast.js";
13
+ export type { RecastCastEntry, RecastInput, RecastResult } from "./recast.js";
14
+ export { boardRenderContext, planShotRenders } from "./render-plan.js";
15
+ export type { ShotRenderPlan, ShotRenderPlanOptions, WireEntity } from "./render-plan.js";
16
+ export { renderShots } from "./io/render-shots.js";
17
+ export type { RenderGenerationRequest, RenderGenerationResult, RenderShotsOptions, ShotRenderOutcome, StoryboardRenderHost, StoryboardSnapshot } from "./io/render-shots.js";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7D,YAAY,EACV,eAAe,EACf,WAAW,EACX,YAAY,EACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACvE,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,UAAU,EACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,YAAY,EACV,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @nodetool-ai/storyboard — storyboard derivations.
3
+ *
4
+ * Recasting a board onto a new cast and planning its shot renders are
5
+ * storyboard-only, need protocol's prompt composition and timeline's linked
6
+ * shot timing, and are called from three places: the `nodetool.storyboard.*`
7
+ * nodes, the agent capabilities, and the board editor. Hence a package of their
8
+ * own (design §3.1). `recast.ts` and `render-plan.ts` are pure; `io/` holds the
9
+ * one render path that spends money.
10
+ */
11
+ export { recastStoryboard, recastKeyFor } from "./recast.js";
12
+ export { boardRenderContext, planShotRenders } from "./render-plan.js";
13
+ export { renderShots } from "./io/render-shots.js";
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM7D,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMvE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Running a storyboard render plan: the IO half of `planShotRenders`.
3
+ *
4
+ * One render path for the agent capability and the `nodetool.storyboard.*`
5
+ * nodes (design §3.1), so what a graph spends and what chat spends are the same
6
+ * call, and both stamp the record `stale_only` later reads.
7
+ *
8
+ * The host seam is structural rather than a `ProcessingContext` import: this
9
+ * package sits on protocol + timeline, below runtime and models. The caller
10
+ * supplies the four operations below and keeps its own ownership checks,
11
+ * generation origin and conflict handling.
12
+ */
13
+ import type { ImageRef, KeyframeVersion } from "@nodetool-ai/protocol";
14
+ import type { StoryboardDocument } from "../document.js";
15
+ import type { ShotRenderPlan } from "../render-plan.js";
16
+ /** The provider call a plan turns into. */
17
+ export interface RenderGenerationRequest {
18
+ /** Minted by the caller of `runGeneration`, so a background caller has it early. */
19
+ id: string;
20
+ provider: string;
21
+ capability: "text_to_image" | "image_to_video" | "reference_to_video" | "text_to_video";
22
+ model: string;
23
+ params: Record<string, unknown>;
24
+ /** Save the result as an asset: the board can only reference persisted media. */
25
+ persist: {
26
+ name: string;
27
+ mime?: string;
28
+ };
29
+ /** Server-side destination retained if the caller disappears before attach. */
30
+ destination: {
31
+ document_id: string;
32
+ target_type: "storyboard_keyframe" | "storyboard_clip";
33
+ target_id: string;
34
+ selected: boolean;
35
+ };
36
+ }
37
+ export interface RenderGenerationResult {
38
+ output: unknown;
39
+ assets: Array<{
40
+ asset_id?: string | null;
41
+ uri?: string | null;
42
+ }>;
43
+ }
44
+ /** The board as it stands, with the token a write has to present. */
45
+ export interface StoryboardSnapshot {
46
+ document: StoryboardDocument;
47
+ updatedAt: string;
48
+ }
49
+ export interface StoryboardRenderHost {
50
+ /** Run one generation through the seam that records and persists it. */
51
+ runGeneration(request: RenderGenerationRequest): Promise<RenderGenerationResult>;
52
+ /** Read the board; null when it is gone or not owned. */
53
+ getStoryboard(id: string): Promise<StoryboardSnapshot | null>;
54
+ /**
55
+ * Write the document if `baseUpdatedAt` is still current; null on a
56
+ * concurrent write, which {@link renderShots} answers by re-reading. `shotId`
57
+ * names the shot that moved, so an open editor merges the write into its
58
+ * draft per shot instead of treating the board as replaced.
59
+ */
60
+ updateStoryboard(args: {
61
+ id: string;
62
+ document: StoryboardDocument;
63
+ baseUpdatedAt: string;
64
+ shotId: string;
65
+ }): Promise<StoryboardSnapshot | null>;
66
+ /** Read a stored still back as bytes — the seed a keyframe-mode clip animates. */
67
+ loadMedia?(ref: KeyframeVersion | ImageRef): Promise<Uint8Array | null>;
68
+ /**
69
+ * The real length of a rendered clip. A video model quantizes the duration it
70
+ * was asked for, and assembly lays down what the ref says.
71
+ */
72
+ videoDurationSeconds?(bytes: Uint8Array): number | null;
73
+ }
74
+ export interface RenderShotsOptions {
75
+ /** Renders in flight at once. Defaults to 1. */
76
+ concurrency?: number;
77
+ /** Named resolution tier for clips, when the caller overrides one. */
78
+ resolution?: string;
79
+ /** Ids for the generation rows. Defaults to `crypto.randomUUID`. */
80
+ newId?: () => string;
81
+ }
82
+ /** One shot's outcome, in plan order. */
83
+ export interface ShotRenderOutcome {
84
+ shotId: string;
85
+ index: number;
86
+ slug?: string;
87
+ kind: "keyframe" | "clip";
88
+ mode: "keyframe" | "direct" | "reference";
89
+ ok: boolean;
90
+ assetId?: string;
91
+ assetUri?: string;
92
+ /** The ledger row for this render; `get_generation` reads its cost. */
93
+ generationId?: string;
94
+ status?: string;
95
+ error?: string;
96
+ }
97
+ /**
98
+ * Render every plan and write each result onto its shot.
99
+ *
100
+ * A plan already marked `fresh` is still rendered: skipping is the caller's
101
+ * decision (`stale_only`, `only_stale`), taken before the plans reach here.
102
+ */
103
+ export declare function renderShots(host: StoryboardRenderHost, ref: {
104
+ id: string;
105
+ }, plans: readonly ShotRenderPlan[], options?: RenderShotsOptions): Promise<ShotRenderOutcome[]>;
106
+ //# sourceMappingURL=render-shots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-shots.d.ts","sourceRoot":"","sources":["../../src/io/render-shots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAEV,QAAQ,EACR,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,kBAAkB,EA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B,GAC/B,OAAO,CAAC,iBAAiB,EAAE,CAAC,CA2J9B"}
@@ -0,0 +1,230 @@
1
+ /**
2
+ * Running a storyboard render plan: the IO half of `planShotRenders`.
3
+ *
4
+ * One render path for the agent capability and the `nodetool.storyboard.*`
5
+ * nodes (design §3.1), so what a graph spends and what chat spends are the same
6
+ * call, and both stamp the record `stale_only` later reads.
7
+ *
8
+ * The host seam is structural rather than a `ProcessingContext` import: this
9
+ * package sits on protocol + timeline, below runtime and models. The caller
10
+ * supplies the four operations below and keeps its own ownership checks,
11
+ * generation origin and conflict handling.
12
+ */
13
+ import { stampRenderInputs } from "@nodetool-ai/protocol";
14
+ /** Attempts to land a document write: the first try plus one re-read-and-reapply (ADR 0001). */
15
+ const CAS_ATTEMPTS = 2;
16
+ const errorMessage = (e) => e instanceof Error ? e.message : String(e);
17
+ /** Run `task` over `items`, at most `limit` in flight. */
18
+ async function mapWithConcurrency(items, limit, task) {
19
+ const results = new Array(items.length);
20
+ let next = 0;
21
+ const workers = Array.from({ length: Math.max(1, Math.min(limit, items.length)) }, async () => {
22
+ for (;;) {
23
+ const index = next++;
24
+ if (index >= items.length)
25
+ return;
26
+ results[index] = await task(items[index]);
27
+ }
28
+ });
29
+ await Promise.all(workers);
30
+ return results;
31
+ }
32
+ /**
33
+ * Apply `patch` to one shot and persist the board.
34
+ *
35
+ * Renders run concurrently against a single row, so the write is a CAS on the
36
+ * board's update token: on conflict the row is re-read and the patch re-applied
37
+ * to the fresher document, never to the stale copy the render started from.
38
+ */
39
+ async function patchShot(host, storyboardId, shotId, patch) {
40
+ for (let attempt = 0; attempt < CAS_ATTEMPTS; attempt++) {
41
+ const snapshot = await host.getStoryboard(storyboardId);
42
+ if (!snapshot) {
43
+ return { error: `Storyboard ${storyboardId} was not found.` };
44
+ }
45
+ const { document, updatedAt } = snapshot;
46
+ const index = document.shots.findIndex((s) => s.id === shotId);
47
+ if (index === -1) {
48
+ return { error: `Shot ${shotId} is no longer on the board.` };
49
+ }
50
+ const updated = patch(document.shots[index]);
51
+ const shots = [...document.shots];
52
+ shots[index] = updated;
53
+ const saved = await host.updateStoryboard({
54
+ id: storyboardId,
55
+ document: { ...document, shots },
56
+ baseUpdatedAt: updatedAt,
57
+ shotId
58
+ });
59
+ if (saved)
60
+ return updated;
61
+ }
62
+ return {
63
+ error: `Storyboard ${storyboardId} is being modified concurrently; the render finished but could not be saved. Retry the call.`
64
+ };
65
+ }
66
+ const isError = (value) => !!value &&
67
+ typeof value === "object" &&
68
+ typeof value.error === "string";
69
+ /** The provider capability a plan calls. */
70
+ const capabilityFor = (plan) => plan.kind === "keyframe"
71
+ ? "text_to_image"
72
+ : plan.mode === "reference"
73
+ ? "reference_to_video"
74
+ : plan.mode === "direct"
75
+ ? "text_to_video"
76
+ : "image_to_video";
77
+ /**
78
+ * Render every plan and write each result onto its shot.
79
+ *
80
+ * A plan already marked `fresh` is still rendered: skipping is the caller's
81
+ * decision (`stale_only`, `only_stale`), taken before the plans reach here.
82
+ */
83
+ export async function renderShots(host, ref, plans, options = {}) {
84
+ const newId = options.newId ?? (() => crypto.randomUUID());
85
+ return mapWithConcurrency(plans, options.concurrency ?? 1, async (plan) => {
86
+ const base = {
87
+ shotId: plan.shotId,
88
+ index: plan.index,
89
+ kind: plan.kind,
90
+ mode: plan.mode,
91
+ ok: false
92
+ };
93
+ if (plan.slug !== undefined)
94
+ base.slug = plan.slug;
95
+ const capability = capabilityFor(plan);
96
+ if (capability === "image_to_video" && !plan.sourceKeyframe) {
97
+ return {
98
+ ...base,
99
+ error: 'Shot has no still to animate. Run render_storyboard_stills first, or set its render_mode to "direct".'
100
+ };
101
+ }
102
+ try {
103
+ const params = {
104
+ prompt: plan.prompt,
105
+ entities: plan.entities,
106
+ aspect_ratio: plan.aspectRatio
107
+ };
108
+ if (plan.kind === "clip") {
109
+ params["resolution"] = options.resolution;
110
+ params["duration_seconds"] = plan.durationSeconds;
111
+ }
112
+ if (capability === "image_to_video" && plan.sourceKeyframe) {
113
+ const seed = host.loadMedia
114
+ ? await host.loadMedia(plan.sourceKeyframe)
115
+ : null;
116
+ if (!seed || seed.length === 0) {
117
+ return {
118
+ ...base,
119
+ error: "The shot's still could not be read back from storage."
120
+ };
121
+ }
122
+ params["image"] = seed;
123
+ // Keep the historical serialized shape for callers that inspect the
124
+ // generation request. It contains exactly the one selected start frame.
125
+ params["images"] = [seed];
126
+ }
127
+ if (capability === "reference_to_video" && !host.loadMedia) {
128
+ return {
129
+ ...base,
130
+ error: "Entity reference images cannot be read from storage."
131
+ };
132
+ }
133
+ if (capability === "reference_to_video" && host.loadMedia) {
134
+ const references = await Promise.all(plan.referenceImages.map((reference) => host.loadMedia?.(reference)));
135
+ if (references.some((value) => !(value instanceof Uint8Array) || value.length === 0)) {
136
+ return {
137
+ ...base,
138
+ error: "A storyboard entity reference image could not be read from storage."
139
+ };
140
+ }
141
+ params["reference_images"] = references;
142
+ }
143
+ const generationId = newId();
144
+ const persist = plan.kind === "keyframe"
145
+ ? { name: `shot-${plan.index + 1}-still` }
146
+ : { name: `shot-${plan.index + 1}-clip`, mime: "video/mp4" };
147
+ const result = await host.runGeneration({
148
+ id: generationId,
149
+ provider: plan.model.provider,
150
+ capability,
151
+ model: plan.model.model,
152
+ params,
153
+ persist,
154
+ destination: {
155
+ document_id: ref.id,
156
+ target_type: plan.kind === "keyframe"
157
+ ? "storyboard_keyframe"
158
+ : "storyboard_clip",
159
+ target_id: plan.shotId,
160
+ selected: true
161
+ }
162
+ });
163
+ const asset = result.assets[0];
164
+ if (!asset?.asset_id) {
165
+ return {
166
+ ...base,
167
+ error: "The render succeeded but could not be saved as an asset, so it cannot be attached to the shot. This host has no asset storage wired."
168
+ };
169
+ }
170
+ const assetId = asset.asset_id;
171
+ const assetUri = asset.uri ?? "";
172
+ const render_inputs = stampRenderInputs(plan.renderInputs);
173
+ const updated = await patchShot(host, ref.id, plan.shotId, (current) => {
174
+ if (plan.kind === "keyframe") {
175
+ const keyframe = {
176
+ type: "image",
177
+ asset_id: assetId,
178
+ uri: assetUri,
179
+ render_inputs
180
+ };
181
+ const versions = current.keyframe_versions ??
182
+ (current.keyframe ? [current.keyframe] : []);
183
+ return {
184
+ ...current,
185
+ keyframe,
186
+ keyframe_versions: [...versions, keyframe],
187
+ status: "keyframe_ready"
188
+ };
189
+ }
190
+ const clip = {
191
+ type: "video",
192
+ asset_id: assetId,
193
+ uri: assetUri,
194
+ render_inputs
195
+ };
196
+ const bytes = result.output;
197
+ if (bytes instanceof Uint8Array && host.videoDurationSeconds) {
198
+ const seconds = host.videoDurationSeconds(bytes);
199
+ if (seconds !== null)
200
+ clip.duration = seconds;
201
+ }
202
+ const versions = current.clip_versions ?? (current.clip ? [current.clip] : []);
203
+ return {
204
+ ...current,
205
+ clip,
206
+ clip_versions: [...versions, clip],
207
+ status: "rendered"
208
+ };
209
+ });
210
+ if (isError(updated))
211
+ return { ...base, error: updated.error };
212
+ return {
213
+ ...base,
214
+ ok: true,
215
+ assetId,
216
+ assetUri,
217
+ generationId,
218
+ status: updated.status
219
+ };
220
+ }
221
+ catch (e) {
222
+ await patchShot(host, ref.id, plan.shotId, (current) => ({
223
+ ...current,
224
+ status: "failed"
225
+ }));
226
+ return { ...base, error: `${capability} failed: ${errorMessage(e)}` };
227
+ }
228
+ });
229
+ }
230
+ //# sourceMappingURL=render-shots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-shots.js","sourceRoot":"","sources":["../../src/io/render-shots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAiG1D,gGAAgG;AAChG,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB,MAAM,YAAY,GAAG,CAAC,CAAU,EAAU,EAAE,CAC1C,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAE7C,0DAA0D;AAC1D,KAAK,UAAU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,KAAK,EAAE,CAAC;YAC/D,OAAO;gBACL,GAAG,IAAI;gBACP,EAAE,EAAE,IAAI;gBACR,OAAO;gBACP,QAAQ;gBACR,YAAY;gBACZ,MAAM,EAAE,OAAO,CAAC,MAAM;aACvB,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;gBACvD,GAAG,OAAO;gBACV,MAAM,EAAE,QAAQ;aACjB,CAAC,CAAC,CAAC;YACJ,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,UAAU,YAAY,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACxE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Recast a storyboard onto a new cast.
3
+ *
4
+ * A director approves one board. A batch then wants the same board with a
5
+ * different product, a different actor, a different location — and wants to pay
6
+ * only for the frames that actually changed. `recastStoryboard` is that
7
+ * mapping: it substitutes entities, rewrites the names they are referred to by,
8
+ * and clears the takes whose prompt moved (design §3.1).
9
+ *
10
+ * Pure. The node, the agent capability and the editor call this same function,
11
+ * so a recast made headlessly matches one made in the UI.
12
+ */
13
+ import type { Entity } from "@nodetool-ai/protocol";
14
+ import type { StoryboardDocument } from "./document.js";
15
+ /** One incoming cast member, and the board entity it stands in for. */
16
+ export interface RecastCastEntry {
17
+ entity: Entity;
18
+ /** Board entity id or name. Absent means "infer from kind" (below). */
19
+ replaces?: string;
20
+ }
21
+ export interface RecastInput {
22
+ /** The template, as it is now. */
23
+ document: StoryboardDocument;
24
+ /**
25
+ * The template board's row id, stamped as `templateId` on the copy. A
26
+ * {@link StoryboardDocument} carries no id of its own, so the caller passes
27
+ * the row's.
28
+ */
29
+ sourceId?: string | null;
30
+ /** Entities on the source board, resolved. */
31
+ boardEntities: Entity[];
32
+ /** Incoming cast. Each replaces the board entity it targets. */
33
+ cast: RecastCastEntry[];
34
+ /** The copy a previous run made for this mapping, when reusing. */
35
+ existing?: StoryboardDocument;
36
+ }
37
+ export interface RecastResult {
38
+ /** New or re-derived copy, lineage stamped. */
39
+ document: StoryboardDocument;
40
+ substitutions: Array<{
41
+ from: Entity;
42
+ to: Entity;
43
+ }>;
44
+ /** Entities appended to the cast because they replaced nothing. */
45
+ appended: Entity[];
46
+ /** Shots whose rendered prompt changed and lost their takes. */
47
+ invalidatedShotIds: string[];
48
+ /**
49
+ * Every other shot on the copy: its prompt is unchanged and it kept its
50
+ * versions, or it had none to lose.
51
+ */
52
+ keptShotIds: string[];
53
+ /** Shots the template no longer has; their takes on `existing` are gone. */
54
+ droppedShotIds: string[];
55
+ recastKey: string;
56
+ }
57
+ /**
58
+ * The mapping, canonically: `<source>><dest>` per substitution, `+<dest>` per
59
+ * append, sorted and joined. Input order does not matter, role assignment does,
60
+ * so A→X,B→Y and A→Y,B→X are two keys and therefore two copies.
61
+ */
62
+ export declare function recastKeyFor(substitutions: ReadonlyArray<{
63
+ from: Entity;
64
+ to: Entity;
65
+ }>, appended: readonly Entity[]): string;
66
+ /**
67
+ * Derive a copy of `document` for a new cast.
68
+ *
69
+ * With `existing` set the derivation still runs from the *current* template and
70
+ * the *current* cast — there is no shortcut keyed on a fingerprint. The copy is
71
+ * then merged onto the previous one by shot id, and the prompt-hash rule
72
+ * decides which of the carried takes survive.
73
+ *
74
+ * A carried take is measured against the prompt that actually produced it: the
75
+ * `render_inputs.prompt_hash` the render wrote, compared with the hash the
76
+ * render path would write for the derived shot now. So a hand edit made on the
77
+ * copy after it rendered does not cost a re-render, and a template edit does.
78
+ * A take with no record — an upload, a flip, a legacy version — has no such
79
+ * witness, so it falls back to the injected-prompt comparison above.
80
+ *
81
+ * One case is out of reach on a reused copy: a destination entity whose
82
+ * *descriptor* changed between two reuses, under the same id and the same name.
83
+ * `RenderInputs.prompt_hash` hashes the composed prompt *before* entities are
84
+ * injected (`promptHashFor` in protocol's `render-record.ts`), so the record
85
+ * does not cover a descriptor, and the previous run's descriptors are not among
86
+ * this function's inputs either. A fresh recast (no `existing`) does see it,
87
+ * because there both sides are injected prompts over known entities. Closing it
88
+ * on the reuse path means making the render record hash the injected prompt,
89
+ * which would re-stale every version already on every board.
90
+ */
91
+ export declare function recastStoryboard(input: RecastInput): RecastResult;
92
+ //# sourceMappingURL=recast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recast.d.ts","sourceRoot":"","sources":["../src/recast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAWH,OAAO,KAAK,EAAE,MAAM,EAAoB,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGxD,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,kCAAkC;IAClC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,8CAA8C;IAC9C,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,gEAAgE;IAChE,IAAI,EAAE,eAAe,EAAE,CAAC;IACxB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B;AAED,MAAM,WAAW,YAAY;IAC3B,+CAA+C;IAC/C,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,aAAa,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,mEAAmE;IACnE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,gEAAgE;IAChE,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B;;;OAGG;IACH,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,4EAA4E;IAC5E,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB;AAkED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,aAAa,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,EAC1D,QAAQ,EAAE,SAAS,MAAM,EAAE,GAC1B,MAAM,CAOR;AA+PD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CA+FjE"}
package/dist/recast.js ADDED
@@ -0,0 +1,370 @@
1
+ /**
2
+ * Recast a storyboard onto a new cast.
3
+ *
4
+ * A director approves one board. A batch then wants the same board with a
5
+ * different product, a different actor, a different location — and wants to pay
6
+ * only for the frames that actually changed. `recastStoryboard` is that
7
+ * mapping: it substitutes entities, rewrites the names they are referred to by,
8
+ * and clears the takes whose prompt moved (design §3.1).
9
+ *
10
+ * Pure. The node, the agent capability and the editor call this same function,
11
+ * so a recast made headlessly matches one made in the UI.
12
+ */
13
+ import { currentRenderInputs, entitiesForShot, injectEntities, keyframePrompt, clipPromptFor, sceneForShot, sha256Hex } from "@nodetool-ai/protocol";
14
+ import { boardRenderContext } from "./render-plan.js";
15
+ const trimmed = (value) => (value ?? "").trim();
16
+ const lower = (value) => trimmed(value).toLowerCase();
17
+ // ---------------------------------------------------------------------------
18
+ // Targeting
19
+ // ---------------------------------------------------------------------------
20
+ /**
21
+ * Which board entity each cast entry stands in for.
22
+ *
23
+ * Two passes, so the answer does not depend on the order the cast arrives in:
24
+ * every explicit `replaces` claims its target first, then a kind with exactly
25
+ * one unclaimed board entity and exactly one un-targeted cast entry pairs up.
26
+ * Anything else — two candidates, none, or two applicants for one seat — is an
27
+ * append, and renames nothing.
28
+ */
29
+ function resolveTargets(boardEntities, cast) {
30
+ const claimed = new Set();
31
+ const targetOf = new Map();
32
+ for (const entry of cast) {
33
+ const wanted = trimmed(entry.replaces);
34
+ if (!wanted)
35
+ continue;
36
+ const match = boardEntities.find((e) => e.id === wanted) ??
37
+ boardEntities.find((e) => lower(e.name) === wanted.toLowerCase());
38
+ if (!match || claimed.has(match.id))
39
+ continue;
40
+ claimed.add(match.id);
41
+ targetOf.set(entry, match);
42
+ }
43
+ const implicit = cast.filter((entry) => !targetOf.has(entry) && !trimmed(entry.replaces));
44
+ const kinds = new Set(implicit.map((entry) => entry.entity.kind));
45
+ for (const kind of kinds) {
46
+ const seats = boardEntities.filter((e) => e.kind === kind && !claimed.has(e.id));
47
+ const applicants = implicit.filter((entry) => entry.entity.kind === kind);
48
+ if (seats.length !== 1 || applicants.length !== 1)
49
+ continue;
50
+ claimed.add(seats[0].id);
51
+ targetOf.set(applicants[0], seats[0]);
52
+ }
53
+ const substitutions = [];
54
+ const appended = [];
55
+ for (const entry of cast) {
56
+ const target = targetOf.get(entry);
57
+ if (target) {
58
+ substitutions.push({ from: target, to: entry.entity });
59
+ }
60
+ else {
61
+ appended.push(entry.entity);
62
+ }
63
+ }
64
+ return { substitutions, appended };
65
+ }
66
+ /**
67
+ * The mapping, canonically: `<source>><dest>` per substitution, `+<dest>` per
68
+ * append, sorted and joined. Input order does not matter, role assignment does,
69
+ * so A→X,B→Y and A→Y,B→X are two keys and therefore two copies.
70
+ */
71
+ export function recastKeyFor(substitutions, appended) {
72
+ return [
73
+ ...substitutions.map((s) => `${s.from.id}>${s.to.id}`),
74
+ ...appended.map((e) => `+${e.id}`)
75
+ ]
76
+ .sort()
77
+ .join(",");
78
+ }
79
+ // ---------------------------------------------------------------------------
80
+ // Renaming
81
+ // ---------------------------------------------------------------------------
82
+ const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
83
+ /**
84
+ * A whole-word, case-insensitive replacer for every renamed entity at once.
85
+ *
86
+ * One pass with alternation, longest name first, so a chain (A→B, B→C) cannot
87
+ * carry A all the way to C. The boundaries are lookarounds rather than `\b`:
88
+ * `\b` is defined against ASCII word characters, so it neither holds for a name
89
+ * that ends in an accent nor stops "Nova" from matching inside "Novak" when the
90
+ * name itself ends in punctuation. Null when nothing is renamed.
91
+ */
92
+ function buildRenamer(renames) {
93
+ const names = [...renames.keys()].sort((a, b) => b.length - a.length);
94
+ if (names.length === 0)
95
+ return null;
96
+ const pattern = new RegExp(`(?<![\\p{L}\\p{N}_])(${names.map(escapeRegExp).join("|")})(?![\\p{L}\\p{N}_])`, "giu");
97
+ return (text) => text.replace(pattern, (match) => renames.get(match.toLowerCase()) ?? match);
98
+ }
99
+ const renameField = (value, rename) => value === undefined || rename === null ? value : rename(value);
100
+ const remapIds = (ids, idMap, append = []) => {
101
+ if (ids === undefined)
102
+ return undefined;
103
+ const out = [];
104
+ for (const id of [...ids, ...append]) {
105
+ const mapped = idMap.get(id) ?? id;
106
+ if (!out.includes(mapped))
107
+ out.push(mapped);
108
+ }
109
+ return out;
110
+ };
111
+ /** The template shot as it reads for the new cast: names rewritten, ids remapped. */
112
+ function deriveShot(shot, rename, idMap) {
113
+ const next = {
114
+ ...shot,
115
+ action: renameField(shot.action, rename) ?? shot.action
116
+ };
117
+ const slug = renameField(shot.slug, rename);
118
+ if (slug !== undefined)
119
+ next.slug = slug;
120
+ const motion = renameField(shot.motion, rename);
121
+ if (motion !== undefined)
122
+ next.motion = motion;
123
+ const dialogue = renameField(shot.dialogue, rename);
124
+ if (dialogue !== undefined)
125
+ next.dialogue = dialogue;
126
+ const narration = renameField(shot.narration, rename);
127
+ if (narration !== undefined)
128
+ next.narration = narration;
129
+ const entityIds = remapIds(shot.entity_ids, idMap);
130
+ if (entityIds !== undefined)
131
+ next.entity_ids = entityIds;
132
+ if (shot.location_id) {
133
+ next.location_id = idMap.get(shot.location_id) ?? shot.location_id;
134
+ }
135
+ return next;
136
+ }
137
+ function deriveScreenplay(screenplay, shots, rename, idMap, appendedIds) {
138
+ if (!screenplay)
139
+ return null;
140
+ const next = {
141
+ ...screenplay,
142
+ shots,
143
+ title: renameField(screenplay.title, rename) ?? screenplay.title
144
+ };
145
+ const narration = renameField(screenplay.narration, rename);
146
+ if (narration !== undefined)
147
+ next.narration = narration;
148
+ const logline = renameField(screenplay.logline, rename);
149
+ if (logline !== undefined)
150
+ next.logline = logline;
151
+ const entityIds = remapIds(screenplay.entity_ids, idMap, appendedIds);
152
+ if (entityIds !== undefined)
153
+ next.entity_ids = entityIds;
154
+ return next;
155
+ }
156
+ const injectedPrompt = (prompt, shot, entities) => {
157
+ const applied = entitiesForShot(shot, [...entities]);
158
+ return injectEntities(prompt, applied, applied.map((e) => e.id)).prompt;
159
+ };
160
+ /**
161
+ * What this shot would render from, on this board, with this cast.
162
+ *
163
+ * The composition is the render path's own (`keyframePrompt`, `clipPromptFor`)
164
+ * plus `injectEntities`, and the digest is `sha256Hex`, the one that writes
165
+ * `RenderInputs.prompt_hash`. Two of these are compared against
166
+ * each other, which is what makes a descriptor edit visible: the stored record
167
+ * hashes the composed prompt *before* injection, so it does not cover one.
168
+ */
169
+ function promptHashes(shot, doc, entities) {
170
+ const context = {
171
+ scene: sceneForShot(shot, doc.screenplay?.scenes),
172
+ style: doc.style
173
+ };
174
+ return {
175
+ keyframe: sha256Hex(injectedPrompt(keyframePrompt(shot, context), shot, entities)),
176
+ clip: sha256Hex(injectedPrompt(clipPromptFor(shot, context), shot, entities))
177
+ };
178
+ }
179
+ /** The hash the render path recorded for the take this shot carries. */
180
+ const recordedPromptHash = (shot, kind) => (kind === "keyframe" ? shot.keyframe : shot.clip)?.render_inputs
181
+ ?.prompt_hash;
182
+ /**
183
+ * The hash the render path would record for this shot on this board.
184
+ *
185
+ * `currentRenderInputs` is the function that writes the record, so the two
186
+ * sides of the comparison are produced by the same code — a change to what the
187
+ * record hashes moves both at once and cannot silently stop matching.
188
+ */
189
+ const currentPromptHash = (shot, doc, entities, kind) => currentRenderInputs(shot, boardRenderContext(doc, entities), kind)
190
+ .prompt_hash;
191
+ /** The status a shot with these takes sits at. */
192
+ const statusFor = (shot) => {
193
+ if (shot.clip)
194
+ return "rendered";
195
+ if (shot.keyframe)
196
+ return "keyframe_ready";
197
+ return "planned";
198
+ };
199
+ /** Whether the shot has anything of this kind that an invalidation could take. */
200
+ const hasTake = (shot, kind) => kind === "keyframe"
201
+ ? !!shot.keyframe || !!shot.keyframe_versions?.length
202
+ : !!shot.clip || !!shot.clip_versions?.length;
203
+ /**
204
+ * Carry the takes a shot is entitled to keep, and say whether any were dropped.
205
+ *
206
+ * `keyframe` moving takes the clip with it — a keyframe-mode clip animates the
207
+ * still that no longer exists, and both prompts are built from `action`. `clip`
208
+ * moving on its own (a `motion` edit) leaves the still alone. A kind the shot
209
+ * has no take of is not asked about: there is nothing to lose, so the shot is
210
+ * not reported as invalidated for it.
211
+ */
212
+ function applyInvalidation(shot, moved) {
213
+ const keyframeMoved = hasTake(shot, "keyframe") && moved("keyframe");
214
+ const clipMoved = hasTake(shot, "clip") && (keyframeMoved || moved("clip"));
215
+ if (!keyframeMoved && !clipMoved) {
216
+ return { shot, invalidated: false };
217
+ }
218
+ const next = { ...shot };
219
+ if (keyframeMoved) {
220
+ delete next.keyframe;
221
+ delete next.keyframe_versions;
222
+ }
223
+ if (clipMoved) {
224
+ delete next.clip;
225
+ delete next.clip_versions;
226
+ delete next.covered_by;
227
+ }
228
+ next.status = statusFor(next);
229
+ return { shot: next, invalidated: true };
230
+ }
231
+ /** The render state one shot carries: what a reused copy hands to its successor. */
232
+ const takesOf = (shot) => ({
233
+ keyframe: shot.keyframe,
234
+ keyframe_versions: shot.keyframe_versions,
235
+ clip: shot.clip,
236
+ clip_versions: shot.clip_versions,
237
+ covered_by: shot.covered_by,
238
+ status: shot.status
239
+ });
240
+ /** Apply `takes` to `shot`, dropping the keys the donor did not have. */
241
+ function withTakes(shot, takes) {
242
+ const next = { ...shot };
243
+ for (const key of [
244
+ "keyframe",
245
+ "keyframe_versions",
246
+ "clip",
247
+ "clip_versions",
248
+ "covered_by"
249
+ ]) {
250
+ const value = takes[key];
251
+ if (value === undefined || value === null) {
252
+ delete next[key];
253
+ }
254
+ else {
255
+ Object.assign(next, { [key]: value });
256
+ }
257
+ }
258
+ next.status = takes.status ?? statusFor(next);
259
+ return next;
260
+ }
261
+ // ---------------------------------------------------------------------------
262
+ // Recast
263
+ // ---------------------------------------------------------------------------
264
+ /**
265
+ * Derive a copy of `document` for a new cast.
266
+ *
267
+ * With `existing` set the derivation still runs from the *current* template and
268
+ * the *current* cast — there is no shortcut keyed on a fingerprint. The copy is
269
+ * then merged onto the previous one by shot id, and the prompt-hash rule
270
+ * decides which of the carried takes survive.
271
+ *
272
+ * A carried take is measured against the prompt that actually produced it: the
273
+ * `render_inputs.prompt_hash` the render wrote, compared with the hash the
274
+ * render path would write for the derived shot now. So a hand edit made on the
275
+ * copy after it rendered does not cost a re-render, and a template edit does.
276
+ * A take with no record — an upload, a flip, a legacy version — has no such
277
+ * witness, so it falls back to the injected-prompt comparison above.
278
+ *
279
+ * One case is out of reach on a reused copy: a destination entity whose
280
+ * *descriptor* changed between two reuses, under the same id and the same name.
281
+ * `RenderInputs.prompt_hash` hashes the composed prompt *before* entities are
282
+ * injected (`promptHashFor` in protocol's `render-record.ts`), so the record
283
+ * does not cover a descriptor, and the previous run's descriptors are not among
284
+ * this function's inputs either. A fresh recast (no `existing`) does see it,
285
+ * because there both sides are injected prompts over known entities. Closing it
286
+ * on the reuse path means making the render record hash the injected prompt,
287
+ * which would re-stale every version already on every board.
288
+ */
289
+ export function recastStoryboard(input) {
290
+ const { document, boardEntities, cast, existing } = input;
291
+ const { substitutions, appended } = resolveTargets(boardEntities, cast);
292
+ const idMap = new Map(substitutions.map((s) => [s.from.id, s.to.id]));
293
+ const renames = new Map();
294
+ for (const { from, to } of substitutions) {
295
+ const oldName = trimmed(from.name);
296
+ const newName = trimmed(to.name);
297
+ if (oldName && newName && oldName.toLowerCase() !== newName.toLowerCase()) {
298
+ renames.set(oldName.toLowerCase(), newName);
299
+ }
300
+ }
301
+ const rename = buildRenamer(renames);
302
+ const appendedIds = appended.map((e) => e.id);
303
+ const entityIds = remapIds(document.entityIds ?? [], idMap, appendedIds) ?? [];
304
+ const castEntities = [
305
+ ...boardEntities.map((e) => {
306
+ const replacement = substitutions.find((s) => s.from.id === e.id);
307
+ return replacement ? replacement.to : e;
308
+ }),
309
+ ...appended
310
+ ];
311
+ const derived = document.shots.map((shot) => deriveShot(shot, rename, idMap));
312
+ const copy = {
313
+ ...document,
314
+ shots: derived,
315
+ entityIds,
316
+ screenplay: deriveScreenplay(document.screenplay, derived, rename, idMap, appendedIds),
317
+ templateId: input.sourceId ?? document.templateId ?? null,
318
+ recastKey: recastKeyFor(substitutions, appended)
319
+ };
320
+ // The approved cut belongs to the board it was assembled for; a copy earns
321
+ // its own. The row's `timeline_id` is a column, but a document that carried
322
+ // one through passthrough must not take it along.
323
+ delete copy.timeline_id;
324
+ const existingDoc = existing ?? document;
325
+ const existingById = new Map((existing?.shots ?? []).map((shot) => [shot.id, shot]));
326
+ const invalidatedShotIds = [];
327
+ const keptShotIds = [];
328
+ copy.shots = copy.shots.map((shot, index) => {
329
+ const template = document.shots[index];
330
+ const previous = existingById.get(shot.id);
331
+ // What produced the takes this shot carries: the previous copy when there
332
+ // is one, else the template the copy inherited them from.
333
+ const carried = previous ? withTakes(shot, takesOf(previous)) : shot;
334
+ // The injected pair, which is the only comparison that sees a descriptor.
335
+ // On a reuse it is the fallback: the previous run's entities are not inputs
336
+ // to this function, so `previous` can only be seasoned with the current
337
+ // cast, and the record below is the better witness where one exists.
338
+ const before = previous
339
+ ? promptHashes(previous, existingDoc, castEntities)
340
+ : promptHashes(template, document, boardEntities);
341
+ const after = promptHashes(carried, copy, castEntities);
342
+ const moved = (kind) => {
343
+ const recorded = previous ? recordedPromptHash(carried, kind) : undefined;
344
+ if (recorded !== undefined) {
345
+ return recorded !== currentPromptHash(carried, copy, castEntities, kind);
346
+ }
347
+ return before[kind] !== after[kind];
348
+ };
349
+ const { shot: settled, invalidated } = applyInvalidation(carried, moved);
350
+ (invalidated ? invalidatedShotIds : keptShotIds).push(settled.id);
351
+ return settled;
352
+ });
353
+ if (copy.screenplay) {
354
+ copy.screenplay = { ...copy.screenplay, shots: copy.shots };
355
+ }
356
+ const liveIds = new Set(copy.shots.map((shot) => shot.id));
357
+ const droppedShotIds = (existing?.shots ?? [])
358
+ .map((shot) => shot.id)
359
+ .filter((id) => !liveIds.has(id));
360
+ return {
361
+ document: copy,
362
+ substitutions,
363
+ appended,
364
+ invalidatedShotIds,
365
+ keptShotIds,
366
+ droppedShotIds,
367
+ recastKey: copy.recastKey ?? ""
368
+ };
369
+ }
370
+ //# sourceMappingURL=recast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recast.js","sourceRoot":"","sources":["../src/recast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,cAAc,EACd,aAAa,EACb,YAAY,EACZ,SAAS,EACV,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AA4CtD,MAAM,OAAO,GAAG,CAAC,KAAgC,EAAU,EAAE,CAC3D,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAEvB,MAAM,KAAK,GAAG,CAAC,KAAgC,EAAU,EAAE,CACzD,OAAO,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AAE/B,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,SAAS,cAAc,CACrB,aAAgC,EAChC,IAAgC;IAEhC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;IAEpD,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;QACzB,MA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AAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3D,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC;SAC3C,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;SACtB,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAEpC,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,aAAa;QACb,QAAQ;QACR,kBAAkB;QAClB,WAAW;QACX,cAAc;QACd,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,EAAE;KAChC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * What a storyboard render call would send, per shot.
3
+ *
4
+ * The plan is the whole decision — which prompt, which entities, which model,
5
+ * which shots are already current — separated from the spending. The agent
6
+ * capability (`render_storyboard_stills`, `render_storyboard_clips`) and the
7
+ * `nodetool.storyboard.*` render nodes both plan through here, so a board
8
+ * rendered from a graph matches one rendered from chat (design §3.1).
9
+ *
10
+ * Pure: no provider, no database, no clock.
11
+ */
12
+ import type { BoardRenderContext, Entity, ImageRef, KeyframeVersion, RenderInputsDraft } from "@nodetool-ai/protocol";
13
+ import type { ScriptLine } from "@nodetool-ai/protocol/api-schemas/scripts.js";
14
+ import type { StoryboardDocument } from "./document.js";
15
+ /** The wire shape the provider layer expands: descriptor text and one image. */
16
+ export interface WireEntity {
17
+ name: string;
18
+ descriptor: string;
19
+ reference_images: NonNullable<Entity["reference_images"]>;
20
+ }
21
+ export interface ShotRenderPlan {
22
+ shotId: string;
23
+ /** The shot's 0-based position, for asset naming and result rows. */
24
+ index: number;
25
+ slug?: string;
26
+ kind: "keyframe" | "clip";
27
+ /** The composed shot prompt. Entities ride alongside in {@link entities}. */
28
+ prompt: string;
29
+ /** The entities seasoning this shot, in the shape the provider layer reads. */
30
+ entities: WireEntity[];
31
+ referenceAssetIds: string[];
32
+ model: {
33
+ provider: string;
34
+ model: string;
35
+ };
36
+ aspectRatio: string;
37
+ /** How a clip is produced. Always `"keyframe"` on a stills plan. */
38
+ mode: "keyframe" | "direct" | "reference";
39
+ /** Ordered entity reference images to pass to reference_to_video. */
40
+ referenceImages: ImageRef[];
41
+ /** Clip length, when the shot or its linked lines fix one. */
42
+ durationSeconds?: number;
43
+ /** The still a keyframe-mode clip animates. Null when there is none. */
44
+ sourceKeyframe: KeyframeVersion | null;
45
+ /** What to stamp on the version this plan produces. */
46
+ renderInputs: RenderInputsDraft;
47
+ /** True when render_inputs match this plan: nothing to do. */
48
+ fresh: boolean;
49
+ }
50
+ /** Per-call overrides. Each one is recorded, so a render made against something
51
+ * other than the board's own settings reads stale against the board. */
52
+ export interface ShotRenderPlanOptions {
53
+ provider?: string;
54
+ model?: string;
55
+ style?: string;
56
+ aspectRatio?: string;
57
+ /** Forces every shot's clip mode for this call only. */
58
+ mode?: "keyframe" | "direct" | "reference";
59
+ /** Linked script lines, so a clip is rendered long enough to hold its voiceover. */
60
+ scriptLines?: Map<string, ScriptLine>;
61
+ }
62
+ /**
63
+ * The board values a version's render record is compared against.
64
+ *
65
+ * The board's one style entity is the last style id in the cast, which is what
66
+ * `set_style` writes.
67
+ */
68
+ export declare function boardRenderContext(doc: StoryboardDocument, entities: readonly Entity[]): BoardRenderContext;
69
+ /**
70
+ * The render each selected shot needs for `kind`.
71
+ *
72
+ * `fresh` is measured against the board's own settings, never the call's
73
+ * overrides — a shot is current when the board would render it the same way,
74
+ * which is what "skip what is already up to date" means. The record on
75
+ * {@link ShotRenderPlan.renderInputs} is the opposite: it says what this call
76
+ * actually rendered with, overrides included.
77
+ */
78
+ export declare function planShotRenders(doc: StoryboardDocument, entities: readonly Entity[], kind: "keyframe" | "clip", targets?: string[], options?: ShotRenderPlanOptions): ShotRenderPlan[];
79
+ //# sourceMappingURL=render-plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-plan.d.ts","sourceRoot":"","sources":["../src/render-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH,OAAO,KAAK,EACV,kBAAkB,EAElB,MAAM,EACN,QAAQ,EACR,eAAe,EACf,iBAAiB,EAElB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAC/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD,gFAAgF;AAChF,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;CAC3D;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC;IAC1B,6EAA6E;IAC7E,MAAM,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,IAAI,EAAE,UAAU,GAAG,QAAQ,GAAG,WAAW,CAAC;IAC1C,qEAAqE;IACrE,eAAe,EAAE,QAAQ,EAAE,CAAC;IAC5B,8DAA8D;IAC9D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wEAAwE;IACxE,cAAc,EAAE,eAAe,GAAG,IAAI,CAAC;IACvC,uDAAuD;IACvD,YAAY,EAAE,iBAAiB,CAAC;IAChC,8DAA8D;IAC9D,KAAK,EAAE,OAAO,CAAC;CAChB;AAcD;wEACwE;AACxE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,IAAI,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,WAAW,CAAC;IAC3C,oFAAoF;IACpF,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACvC;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,kBAAkB,EACvB,QAAQ,EAAE,SAAS,MAAM,EAAE,GAC1B,kBAAkB,CAoBpB;AAsCD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,kBAAkB,EACvB,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,IAAI,EAAE,UAAU,GAAG,MAAM,EACzB,OAAO,CAAC,EAAE,MAAM,EAAE,EAClB,OAAO,GAAE,qBAA0B,GAClC,cAAc,EAAE,CA4ElB"}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * What a storyboard render call would send, per shot.
3
+ *
4
+ * The plan is the whole decision — which prompt, which entities, which model,
5
+ * which shots are already current — separated from the spending. The agent
6
+ * capability (`render_storyboard_stills`, `render_storyboard_clips`) and the
7
+ * `nodetool.storyboard.*` render nodes both plan through here, so a board
8
+ * rendered from a graph matches one rendered from chat (design §3.1).
9
+ *
10
+ * Pure: no provider, no database, no clock.
11
+ */
12
+ import { currentRenderInputs, entitiesForShot, isVersionStale, keyframePrompt, clipPromptFor, sceneForShot, shotRenderMode } from "@nodetool-ai/protocol";
13
+ import { effectiveShotDuration } from "@nodetool-ai/timeline";
14
+ function imageAssetId(image) {
15
+ if (typeof image.asset_id === "string" && image.asset_id.length > 0) {
16
+ return image.asset_id;
17
+ }
18
+ if (typeof image.uri !== "string" || !image.uri.startsWith("asset://")) {
19
+ return undefined;
20
+ }
21
+ const locator = image.uri.slice("asset://".length);
22
+ const extension = locator.lastIndexOf(".");
23
+ return extension > 0 ? locator.slice(0, extension) : locator || undefined;
24
+ }
25
+ /**
26
+ * The board values a version's render record is compared against.
27
+ *
28
+ * The board's one style entity is the last style id in the cast, which is what
29
+ * `set_style` writes.
30
+ */
31
+ export function boardRenderContext(doc, entities) {
32
+ const styleIds = new Set(entities.filter((e) => e.kind === "style").map((e) => e.id));
33
+ const modelId = (selection) => typeof selection?.["id"] === "string" ? selection["id"] : "";
34
+ return {
35
+ aspect_ratio: doc.aspectRatio || "16:9",
36
+ image_model: modelId(doc.imageModel),
37
+ video_model: modelId(doc.videoModel),
38
+ style_entity_id: [...(doc.entityIds ?? [])].reverse().find((id) => styleIds.has(id)) ??
39
+ null,
40
+ style: doc.style,
41
+ scenes: doc.screenplay?.scenes ?? null,
42
+ reference_asset_ids: entities
43
+ .filter((entity) => (doc.entityIds ?? []).includes(entity.id))
44
+ .flatMap((entity) => (entity.reference_images ?? []).map(imageAssetId))
45
+ .filter((id) => typeof id === "string" && id.length > 0)
46
+ };
47
+ }
48
+ const wireEntity = (entity) => ({
49
+ name: entity.name,
50
+ descriptor: entity.descriptor,
51
+ reference_images: entity.reference_images?.slice(0, 1) ?? []
52
+ });
53
+ const stringField = (selection, key) => (typeof selection?.[key] === "string" ? selection[key] : "");
54
+ /** Resolve a target: shot id, 0-based index, or slug. */
55
+ function findShot(shots, target) {
56
+ const byId = shots.find((s) => s.id === target);
57
+ if (byId)
58
+ return byId;
59
+ const index = Number(target);
60
+ if (Number.isInteger(index)) {
61
+ const byIndex = shots.find((s) => s.index === index);
62
+ if (byIndex)
63
+ return byIndex;
64
+ }
65
+ const slug = target.trim().toLowerCase();
66
+ return shots.find((s) => (s.slug ?? "").trim().toLowerCase() === slug);
67
+ }
68
+ /** The shots a plan covers: `targets` in the order given, else every shot by index. */
69
+ function selectShots(doc, targets) {
70
+ const ordered = [...doc.shots].sort((a, b) => a.index - b.index);
71
+ if (!targets)
72
+ return ordered;
73
+ const selected = [];
74
+ for (const target of targets) {
75
+ const shot = findShot(ordered, String(target));
76
+ if (shot && !selected.includes(shot))
77
+ selected.push(shot);
78
+ }
79
+ return selected;
80
+ }
81
+ /**
82
+ * The render each selected shot needs for `kind`.
83
+ *
84
+ * `fresh` is measured against the board's own settings, never the call's
85
+ * overrides — a shot is current when the board would render it the same way,
86
+ * which is what "skip what is already up to date" means. The record on
87
+ * {@link ShotRenderPlan.renderInputs} is the opposite: it says what this call
88
+ * actually rendered with, overrides included.
89
+ */
90
+ export function planShotRenders(doc, entities, kind, targets, options = {}) {
91
+ const board = boardRenderContext(doc, entities);
92
+ const style = options.style ?? doc.style;
93
+ const aspectRatio = options.aspectRatio ?? (doc.aspectRatio || "16:9");
94
+ const selection = kind === "keyframe" ? doc.imageModel : doc.videoModel;
95
+ const model = {
96
+ provider: options.provider || stringField(selection, "provider"),
97
+ model: options.model || stringField(selection, "id")
98
+ };
99
+ // What this call renders with, which is not always what the board says.
100
+ const rendered = {
101
+ ...board,
102
+ ...(kind === "keyframe"
103
+ ? { image_model: model.model }
104
+ : { video_model: model.model }),
105
+ aspect_ratio: aspectRatio,
106
+ style
107
+ };
108
+ const lines = options.scriptLines ?? new Map();
109
+ return selectShots(doc, targets).map((shot) => {
110
+ const mode = options.mode ?? shotRenderMode(shot);
111
+ const context = {
112
+ scene: sceneForShot(shot, doc.screenplay?.scenes),
113
+ style
114
+ };
115
+ const prompt = kind === "keyframe"
116
+ ? keyframePrompt(shot, context)
117
+ : clipPromptFor(shot, context, mode);
118
+ const applied = entitiesForShot(shot, [...entities]);
119
+ const shotReferenceAssetIds = applied.flatMap((entity) => (entity.reference_images ?? [])
120
+ .map(imageAssetId)
121
+ .filter((id) => typeof id === "string" && id.length > 0));
122
+ const shotBoard = { ...board, reference_asset_ids: shotReferenceAssetIds };
123
+ const shotRendered = { ...rendered, reference_asset_ids: shotReferenceAssetIds };
124
+ const version = kind === "keyframe" ? shot.keyframe : shot.clip;
125
+ const plan = {
126
+ shotId: shot.id,
127
+ index: shot.index,
128
+ kind,
129
+ prompt,
130
+ entities: applied.map(wireEntity),
131
+ referenceAssetIds: applied.flatMap((e) => (e.reference_images ?? [])
132
+ .map(imageAssetId)
133
+ .filter((id) => typeof id === "string" && id.length > 0)),
134
+ model,
135
+ aspectRatio,
136
+ mode: kind === "keyframe" ? "keyframe" : mode,
137
+ referenceImages: mode === "reference"
138
+ ? applied.flatMap((entity) => entity.reference_images ?? [])
139
+ : [],
140
+ sourceKeyframe: shot.keyframe ?? null,
141
+ renderInputs: kind === "clip"
142
+ ? currentRenderInputs({ ...shot, render_mode: mode }, shotRendered, kind)
143
+ : currentRenderInputs(shot, shotRendered, kind),
144
+ fresh: !isVersionStale(version, shot, shotBoard)
145
+ };
146
+ if (shot.slug !== undefined)
147
+ plan.slug = shot.slug;
148
+ if (kind === "clip") {
149
+ const duration = effectiveShotDuration(shot, lines).seconds;
150
+ if (duration !== undefined)
151
+ plan.durationSeconds = duration;
152
+ }
153
+ return plan;
154
+ });
155
+ }
156
+ //# sourceMappingURL=render-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-plan.js","sourceRoot":"","sources":["../src/render-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,cAAc,EACd,aAAa,EACb,YAAY,EACZ,cAAc,EACf,MAAM,uBAAuB,CAAC;AAU/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAsC9D,SAAS,YAAY,CAAC,KAAe;IACnC,IAAI,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC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yboard derivations: recast a board onto a new cast, and plan/run its shot renders",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=22.0.0"
8
+ },
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "scripts": {
12
+ "build": "node ../../scripts/build-typescript-workspace.mjs",
13
+ "test": "node ../../scripts/run-vitest.mjs run",
14
+ "test:watch": "node ../../scripts/run-vitest.mjs",
15
+ "lint": "node ../../scripts/run-tsc.mjs --noEmit"
16
+ },
17
+ "dependencies": {
18
+ "@nodetool-ai/protocol": "^0.8.1",
19
+ "@nodetool-ai/timeline": "^0.8.1"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "^22.0.0",
23
+ "typescript": "npm:@typescript/typescript6@6.0.2",
24
+ "vitest": "^5.0.1"
25
+ },
26
+ "exports": {
27
+ ".": {
28
+ "nodetool-dev": "./src/index.ts",
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js",
31
+ "default": "./dist/index.js"
32
+ }
33
+ },
34
+ "license": "MIT",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/nodetool-ai/nodetool.git",
38
+ "directory": "packages/storyboard"
39
+ },
40
+ "homepage": "https://nodetool.ai",
41
+ "bugs": {
42
+ "url": "https://github.com/nodetool-ai/nodetool/issues"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "files": [
48
+ "dist",
49
+ "README.md"
50
+ ],
51
+ "keywords": [
52
+ "nodetool",
53
+ "ai",
54
+ "storyboard",
55
+ "video",
56
+ "typescript"
57
+ ]
58
+ }