@slatesvideo/shared 0.7.17 → 0.7.19

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.
@@ -3,7 +3,7 @@ import { STYLE_LIBRARY, DEFAULT_STYLE_ID } from '../prompts/style-library.js';
3
3
  import { discoverGuides, guideCatalog } from '../prompts/guide-discovery.js';
4
4
  import { retrieveGuide, servedDepth } from '../prompts/guide-retrieval.js';
5
5
  import { BRAIN_ROUTER, MY_BRAIN_TOPIC, ROUTER_ALIASES } from '../prompts/brain.js';
6
- import { MINIMAX_MAX_REFERENCE, minimaxMaxReferenceTokens, MODEL_CAPABILITIES, RETIRED_MODELS, retiredModelOfKey, checkReferenceShape, GPT_QUALITY_TIERS, DEFAULT_GPT_QUALITY, GPT_BACKGROUNDS } from '../prompts/model-capabilities.js';
6
+ import { MINIMAX_MAX_REFERENCE, minimaxMaxReferenceTokens, MODEL_CAPABILITIES, RETIRED_MODELS, retiredModelOfKey, checkReferenceShape, GPT_QUALITY_TIERS, DEFAULT_GPT_QUALITY, GPT_BACKGROUNDS, seedream55CostKey } from '../prompts/model-capabilities.js';
7
7
  // Operations layer — the ONE place every Slates agent tool is defined.
8
8
  // Both the MCP server and the CLI register these as their tool / command
9
9
  // surface. Every operation:
@@ -21,6 +21,7 @@ import { SlatesDesktopClient } from '../clients/desktop.js';
21
21
  import { BlenderBridgeClient, BLENDER_SETUP_HINT, RENDER_TIMEOUT_MS } from '../clients/blender.js';
22
22
  import { SKILLS } from '../skills/content.js';
23
23
  import { brainSkills, myBrainDir, myBrainPreload, noteUsed } from '../skills/my-brain.js';
24
+ import { remember } from '../skills/my-brain-write.js';
24
25
  import { brainFiles, refreshServedBrain, servedBrain } from '../skills/served.js';
25
26
  import { HYPERFRAMES_MAPPING, findHyperframesGuide, hyperframesCard, hyperframesCatalog, hyperframesFilesOf, hyperframesGuideHeader, hyperframesSkillBodies, loadHyperframes } from '../skills/hyperframes.js';
26
27
  import { appManualIndex, appManualSections } from '../manual/index.js';
@@ -541,10 +542,11 @@ export const setSelection = {
541
542
  const VIEW_LENSES = ['board', 'media', 'script'];
542
543
  const VIEW_CUT_SIDES = ['bottom', 'left', 'right'];
543
544
  const VIEW_DOCK_SECTIONS = ['storyboards', 'library', 'folders', 'pinned'];
544
- // W3: the one window's two layouts (`WINDOW_LAYOUTS`).
545
+ // W3: the one window's two layouts (`WINDOW_LAYOUTS`), and its shape (`SHAPE_SETTINGS`).
545
546
  const VIEW_WINDOW_LAYOUTS = ['plan', 'edit'];
546
547
  // What the timeline's Viewer shows (`VIEWER_MODES`).
547
548
  const VIEW_VIEWER_MODES = ['source', 'timeline'];
549
+ const VIEW_SHAPE_SETTINGS = ['auto', 'landscape', 'vertical'];
548
550
  // 1.6.1: what the user is looking at. Mirrors slate's `@shared/types/view` (lockstep check 12).
549
551
  const VIEW_BOARD_LEVELS = ['film', 'scenes', 'shot'];
550
552
  const VIEW_BOARD_FILTERS = ['all', 'with-clip', 'without-clip'];
@@ -645,7 +647,7 @@ const describeView = (v) => {
645
647
  `The project navigator is ${v.leftDock.open ? `open (${v.leftDock.width}px)` : 'closed'}, and ${agent}.` +
646
648
  (v.leftDock.folded?.length ? ` Folded in the navigator: ${v.leftDock.folded.map((f) => DOCK_SECTION_NAMES[f] ?? f).join(', ')}.` : '') +
647
649
  (v.window
648
- ? ` The window is in the ${v.window.layout === 'edit' ? 'Edit' : 'Plan'} layout, showing ${areas.length > 1 ? `${areas.slice(0, -1).join(', ')} and ${areas.at(-1)}` : areas[0] ?? 'none of its areas'}.`
650
+ ? ` The window is in the ${v.window.presetName ?? (v.window.layout === 'edit' ? 'Edit' : 'Plan')} layout${v.window.changed ? ' (changed since it was saved)' : ''}${v.window.shape ? `, ${v.window.shape}` : ''}, showing ${areas.length > 1 ? `${areas.slice(0, -1).join(', ')} and ${areas.at(-1)}` : areas[0] ?? 'none of its areas'}.`
649
651
  : '') +
650
652
  (v.script ? ` The Script page shows ${v.script.details ? 'Words + shots (each shot\'s picture beside its words)' : 'Words (the words alone)'}.` : '') +
651
653
  describeLooking(v));
@@ -657,7 +659,7 @@ const describeView = (v) => {
657
659
  */
658
660
  export const getView = {
659
661
  id: 'slates_get_view',
660
- description: "What the user is looking at in Slates: Home or a project, the tab (Media, Script or Board), the open board and its View and Filter, Media's tab, chosen folder and narrowing, a Library page, the picture viewer, the timeline Viewer's mode and clip, Compare, the animatic, Settings, whether the prompt box is hidden, the timeline and the side panels, and, from a desktop with the one-window layout, the window's layout (Plan or Edit, which areas show, the Viewer's Inspector drawer open or shut for want of room), and any dialog or menu open over the page. New desktops also report cut.format and the selected variant grid rows and aspects. Read it before telling the user where to click.",
662
+ description: "What the user is looking at in Slates: Home or a project, the tab (Media, Script or Board), the open board and its View and Filter, Media's tab, chosen folder and narrowing, a Library page, the picture viewer, the timeline Viewer's mode and clip, Compare, the animatic, Settings, whether the prompt box is hidden, the timeline and the side panels, and, from a desktop with the one-window layout, the window's layout (Edit, Plan or one the user saved, whether it changed since saved, the landscape or vertical shape, which areas show, the Viewer's Inspector drawer open or shut for want of room), and any dialog or menu open over the page. New desktops also report cut.format and the selected variant grid rows and aspects. Read it before telling the user where to click.",
661
663
  input: z.object({}).strict(),
662
664
  async run(_input, ctx) {
663
665
  await ctx.desktop().requireCapability('view', 'the window layout');
@@ -685,7 +687,7 @@ export const getView = {
685
687
  */
686
688
  export const setView = {
687
689
  id: 'slates_set_view',
688
- description: "Change what the user is looking at, as their own clicks would: open a project or go Home, switch tab, open a board, jump to a scene, set the Board's View and Filter, set Media's tab, folder and narrowing, jump to a card in Media, open a Library page, a picture in the picture viewer or a clip in the timeline's Viewer, Compare, the animatic or Settings on a pane, show or hide the prompt box, open or park the timeline or switch the cut on it, open a Shot's panel on Script, set the side panels (the project navigator and its folded sections, the Slates Director panel), the Script page's Words or Words + shots and its text size, the Board's card size and linked clips, and on a desktop with the one-window layout the layout and which areas show. Only the fields you name change; the app clamps sizes, answers with what it settled on, and names any field it could not apply. A project change is applied alone (it restores that project's own view). Use it when the user asks you to show or open something, not to answer a question they can see for themselves.",
690
+ description: "Change what the user is looking at, as their own clicks would: open a project or go Home, switch tab, open a board, jump to a scene, set the Board's View and Filter, set Media's tab, folder and narrowing, jump to a card in Media, open a Library page, a picture in the picture viewer or a clip in the timeline's Viewer, Compare, the animatic or Settings on a pane, show or hide the prompt box, open or park the timeline or switch the cut on it, open a Shot's panel on Script, set the side panels (the project navigator and its folded sections, the Slates Director panel), the Script page's Words or Words + shots and its text size, the Board's card size and linked clips, and on a desktop with the one-window layout the layout (Edit, Plan or one the user saved), its shape and which areas show. Only the fields you name change; the app clamps sizes, answers with what it settled on, and names any field it could not apply. A project change is applied alone (it restores that project's own view). Use it when the user asks you to show or open something, not to answer a question they can see for themselves.",
689
691
  input: z
690
692
  .object({
691
693
  projectId: z.string().nullable().optional().describe('Open this project, or null for Home. Applied alone.'),
@@ -781,13 +783,23 @@ export const setView = {
781
783
  window: z
782
784
  .object({
783
785
  layout: z.enum(VIEW_WINDOW_LAYOUTS).optional().describe('edit gives the Viewer the room, with Media, Board and Script a column at its left; plan gives it to them, with the Viewer a column at their right.'),
786
+ preset: z
787
+ .string()
788
+ .min(1)
789
+ .optional()
790
+ .describe("Switch to this layout, by id or by name in any case: Edit, Plan or one the user saved (slates_get_view lists them in window.presets). An unknown name comes back as a note naming the layouts."),
791
+ reset: z.boolean().optional().describe("true puts the current layout back as it was saved (the Layout map's Reset layout)."),
792
+ shape: z
793
+ .enum(VIEW_SHAPE_SETTINGS)
794
+ .optional()
795
+ .describe('landscape: the timeline full width along the bottom. vertical: the Viewer and the Inspector full height at the right, Media, Board and Script over the timeline at the left. auto follows the open timeline (vertical while it is taller than wide).'),
784
796
  viewer: z.boolean().optional().describe('Show or hide the Viewer.'),
785
797
  inspector: z.boolean().optional().describe("Open or shut the Inspector, the Viewer's drawer (opening it shows the Viewer); in a window with no room, Media, Board and Script fold to make room."),
786
798
  lensWidth: z.number().optional().describe("The Media, Board and Script column's width in px in the Edit layout."),
787
799
  })
788
800
  .strict()
789
801
  .optional()
790
- .describe('The one window (desktops with it): its layout and which areas show.'),
802
+ .describe('The one window (desktops with it): its layout, its shape and which areas show.'),
791
803
  })
792
804
  .strict(),
793
805
  async run(input, ctx) {
@@ -803,6 +815,9 @@ export const setView = {
803
815
  input.script?.panelShotId !== undefined;
804
816
  if (widened)
805
817
  await ctx.desktop().requireCapability('view-v2', 'showing and opening things in the window');
818
+ if (input.window?.preset !== undefined || input.window?.reset !== undefined || input.window?.shape !== undefined) {
819
+ await ctx.desktop().requireCapability('layout-presets', 'choosing a layout or the window shape');
820
+ }
806
821
  if (input.cut?.format !== undefined || input.cut?.gridSelection !== undefined) {
807
822
  await ctx.desktop().requireCapability('ad-variant-export', 'delivery preview and variant grid selection');
808
823
  }
@@ -1866,11 +1881,12 @@ export const estimateGenerationCost = {
1866
1881
  quality: z.enum(GPT_QUALITY_TIERS).optional().describe(`GPT Image tier; default ${DEFAULT_GPT_QUALITY}.`),
1867
1882
  aspectRatio: z.string().optional().describe('GPT Image: the frame shape changes the price; pass the generation\'s value.'),
1868
1883
  sound: z.boolean().optional().describe('Kling 3.0: a silent take prices differently from one with sound. Omitted means sound on, as generation bills it; pass false to price a silent take. Kling 4K keys include audio.'),
1884
+ seedanceDraft: z.boolean().optional().describe('Create a finishable Seedance 2.5 preview at 480p.'),
1869
1885
  seedanceFace: z.boolean().optional().describe('Seedance Face row, for an AI character\'s face.'),
1870
1886
  seedanceRealFace: z.boolean().optional().describe('Seedance with a consented real person (premium key).'),
1871
1887
  videoRefSeconds: z.number().nonnegative().optional().describe('Combined reference-video seconds, measured from the clips.'),
1872
1888
  audioRefSeconds: z.number().nonnegative().optional().describe('Combined reference-audio seconds, including attached character voices.'),
1873
- referenceImages: z.number().int().min(0).optional().describe(`MiniMax H3 rows only — how many reference IMAGES the generation will carry. Each image past the row's free allowance is a paid dimension of the cost key, so a quote that omits this UNDER-REPORTS a reference-heavy job. The allowances differ: minimax-h3 gives ${MINIMAX_FREE_REF_IMAGES_BY_MODEL['minimax-h3']} free, minimax-h3-max gives ${MINIMAX_FREE_REF_IMAGES_BY_MODEL['minimax-h3-max']}. Ignored by every other model. Start/end frames are free on both rows and are not reference images.`),
1889
+ referenceImages: z.number().int().min(0).optional().describe(`MiniMax H3 rows and seedream-5-5 — how many reference IMAGES the generation will carry. They are a paid dimension of the cost key, so a quote that omits this UNDER-REPORTS a reference-heavy job. seedream-5-5 pays for every input image, @mention pictures included, and an edit's source picture counts as one. The MiniMax allowances differ: minimax-h3 gives ${MINIMAX_FREE_REF_IMAGES_BY_MODEL['minimax-h3']} free, minimax-h3-max gives ${MINIMAX_FREE_REF_IMAGES_BY_MODEL['minimax-h3-max']}; start/end frames are free on both rows and are not reference images. Ignored by every other model.`),
1874
1890
  }),
1875
1891
  async run(input, ctx) {
1876
1892
  // A retired seat is never quoted: its keys still bill older desktops, and `nano-banana-2-1k` (the
@@ -1879,10 +1895,14 @@ export const estimateGenerationCost = {
1879
1895
  if (retired) {
1880
1896
  throw new Error(`${retired} was retired and ${RETIRED_MODELS[retired]} replaced it. Quote ${RETIRED_MODELS[retired]} with the same parameters.`);
1881
1897
  }
1898
+ if (input.seedanceDraft) {
1899
+ const video = resolveVideoModel(input.model);
1900
+ input.videoResolution = draftResolution(video?.model, input.videoResolution ?? video?.videoResolution);
1901
+ }
1882
1902
  const registry = await ctx.cloud().get('/api/agent/models');
1883
1903
  const byKey = new Map(registry.models.filter((m) => !retiredModelOfKey(m.model)).map((m) => [m.model, creditCost(m)]));
1884
1904
  // 1) exact registry cost key
1885
- let key = byKey.has(input.model) ? input.model : null;
1905
+ let key = !input.seedanceDraft && byKey.has(input.model) ? input.model : null;
1886
1906
  // 2) image base id + resolution (+ quality for GPT Image)
1887
1907
  if (!key) {
1888
1908
  // IMAGE_MODELS, never a second hand-typed copy: this list is declared
@@ -1897,7 +1917,7 @@ export const estimateGenerationCost = {
1897
1917
  // generation quoted 1 cr for a 2 cr job. Four separate copies of one
1898
1918
  // default is what made that possible; there are now none.
1899
1919
  if (img)
1900
- key = imageCostKey(img, input.resolution ?? defaultImageResolutionFor(img), input.quality, input.aspectRatio);
1920
+ key = imageCostKey(img, input.resolution ?? defaultImageResolutionFor(img), input.quality, input.aspectRatio, input.referenceImages ?? 0);
1901
1921
  }
1902
1922
  // 2a) audio base id → seconds. Both surfaces bill per second, so a
1903
1923
  // duration is always required. Runs BEFORE the video resolver: it is
@@ -2002,7 +2022,7 @@ export const estimateGenerationCost = {
2002
2022
  resolved.videoResolution ??
2003
2023
  // Seedance quotes are resolution-scaled, so a missing resolution has
2004
2024
  // to fall back to the model's OWN default — the ladders differ per
2005
- // row (2.5 has no 4K) and a blanket literal quotes a key that does
2025
+ // row and a blanket literal can quote a key that does
2006
2026
  // not exist. Read from the SSOT; this used to be a hand-typed
2007
2027
  // model-id ternary.
2008
2028
  defaultVideoResolutionFor(resolved.model),
@@ -2038,7 +2058,7 @@ export const estimateGenerationCost = {
2038
2058
  // Before the card on purpose: the desktop strips a repeated card by cutting
2039
2059
  // the text at "--- HOW TO PROMPT", and this line must survive that.
2040
2060
  const ownImage = IMAGE_MODELS.includes(input.model) ? input.model : null;
2041
- const cheaper = ownImage ? cheaperImageOptions(byKey, perCredits, ownImage, input.aspectRatio) : null;
2061
+ const cheaper = ownImage ? cheaperImageOptions(byKey, perCredits, ownImage, input.aspectRatio, input.referenceImages ?? 0) : null;
2042
2062
  const framing = input.aspectRatio ?? '16:9';
2043
2063
  const unpricedNote = cheaper?.unpriced.length
2044
2064
  ? ` Not on the price list at ${framing}: ${cheaper.unpriced.join(', ')}; estimate one directly to price it.`
@@ -2985,7 +3005,7 @@ export const IMAGE_MODELS = [
2985
3005
  'gpt-image-2-6-flare',
2986
3006
  'gpt-image-2-6-sunburst',
2987
3007
  'flux-3',
2988
- 'seedream-5-lite',
3008
+ 'seedream-5-5',
2989
3009
  ];
2990
3010
  /** True for either GPT Image seat. Flare and Sunburst differ in latency
2991
3011
  * and routing advice, never in pricing shape or param surface. */
@@ -3020,6 +3040,45 @@ async function gptImageSeatFor(desktop, model, feature) {
3020
3040
  function gptImageSubstitution(asked, sent) {
3021
3041
  return sent === asked ? '' : `${sent} ran in place of ${asked}, at the same price: this Slates desktop predates GPT Image 2.6. Update Slates to run 2.6.`;
3022
3042
  }
3043
+ /**
3044
+ * The image seats that take `backgroundMode` (transparent / opaque / auto): both
3045
+ * GPT Image seats and Seedream 5.5 (BytePlus `background`, read 2026-11-16). The
3046
+ * desktop's twin is the `transparentBackground` feature on its registry rows,
3047
+ * which shows the Background control; the wire field is `gptBackground` for
3048
+ * every seat, a name kept from when GPT Image was the only one.
3049
+ */
3050
+ export function takesBackgroundMode(model) {
3051
+ return isGptImageModel(model) || model === 'seedream-5-5';
3052
+ }
3053
+ /** The default image seat before Seedream 5.5 took it, which an older desktop still renders. */
3054
+ const PREVIOUS_DEFAULT_IMAGE_MODEL = 'gpt-image-2-6-sunburst';
3055
+ /**
3056
+ * The seat to run when the caller left `model` out, on this desktop. Seedream
3057
+ * 5.5 is the default, and only a desktop advertising `image-models-v6` (1.7.0
3058
+ * and newer) knows it: an older one would render its Nano Banana fallback at a
3059
+ * Seedream quote. So an unnamed call on such a desktop runs the previous
3060
+ * default, which it knows, and the result says so; a call that NAMES Seedream
3061
+ * 5.5 is refused with the update message instead, since the caller asked for it.
3062
+ */
3063
+ async function defaultImageSeatFor(desktop, named, feature) {
3064
+ const model = named ?? DEFAULT_IMAGE_MODEL;
3065
+ if (model !== 'seedream-5-5')
3066
+ return { model, note: '' };
3067
+ if (named) {
3068
+ await desktop().requireCapability('image-models-v6', feature);
3069
+ return { model, note: '' };
3070
+ }
3071
+ try {
3072
+ await desktop().requireCapability('image-models-v6', feature);
3073
+ return { model, note: '' };
3074
+ }
3075
+ catch {
3076
+ return {
3077
+ model: PREVIOUS_DEFAULT_IMAGE_MODEL,
3078
+ note: `${PREVIOUS_DEFAULT_IMAGE_MODEL} ran as the default image model: this Slates desktop predates Seedream 5.5, the default now. Update Slates to run it.`,
3079
+ };
3080
+ }
3081
+ }
3023
3082
  /** True for either Gemini Omni Flash 1.2 seat, generation or edit. */
3024
3083
  export function isOmniFlash12Model(model) {
3025
3084
  return model === 'omni-flash-1-2' || model === 'omni-flash-1-2-edit';
@@ -3142,11 +3201,19 @@ function gptKeyAspect(aspectRatio) {
3142
3201
  // imports it and asserts, key by key, that it equals the desktop's
3143
3202
  // `imageCreditKey`. Before that check existed the byte-match was a comment and
3144
3203
  // a hope — the two are in different repos and nothing compared them.
3145
- export function imageCostKey(model, resolution, quality = DEFAULT_GPT_QUALITY, aspectRatio) {
3204
+ /**
3205
+ * BytePlus bills every input image of a Seedream 5.5 call, so its key names the
3206
+ * reference count (`seedream55CostKey`, model-capabilities.ts), and a quote made
3207
+ * before the desktop composes @mention pictures can be short of the bill.
3208
+ */
3209
+ function billsEachInputImage(model) {
3210
+ return model === 'seedream-5-5';
3211
+ }
3212
+ export function imageCostKey(model, resolution, quality = DEFAULT_GPT_QUALITY, aspectRatio, referenceCount = 0) {
3146
3213
  if (model === 'flux-3')
3147
3214
  return `flux-3-${resolution}`;
3148
- if (model === 'seedream-5-lite')
3149
- return 'seedream-5-lite';
3215
+ if (billsEachInputImage(model))
3216
+ return seedream55CostKey(resolution, referenceCount);
3150
3217
  if (isGptImageModel(model))
3151
3218
  return `${model}-${gptKeyTier(quality)}-${resolution}${gptKeyAspect(aspectRatio)}`;
3152
3219
  return `nano-banana-2-1-${resolution}`;
@@ -3166,7 +3233,7 @@ export function imageCostKey(model, resolution, quality = DEFAULT_GPT_QUALITY, a
3166
3233
  * Which seat is right stays the agent's call ("cheap" and "best" trade), so
3167
3234
  * nothing is routed here: the comparison is a fact in front of it instead.
3168
3235
  */
3169
- function cheaperImageOptions(byKey, than, own, aspectRatio) {
3236
+ function cheaperImageOptions(byKey, than, own, aspectRatio, referenceCount = 0) {
3170
3237
  const all = [];
3171
3238
  const unpriced = [];
3172
3239
  for (const model of IMAGE_MODELS) {
@@ -3175,7 +3242,7 @@ function cheaperImageOptions(byKey, than, own, aspectRatio) {
3175
3242
  let best = null;
3176
3243
  for (const resolution of MODEL_CAPABILITIES[model]?.imageResolutions ?? []) {
3177
3244
  for (const quality of qualities) {
3178
- const credits = byKey.get(imageCostKey(model, resolution, quality, aspectRatio));
3245
+ const credits = byKey.get(imageCostKey(model, resolution, quality, aspectRatio, referenceCount));
3179
3246
  if (credits == null)
3180
3247
  continue;
3181
3248
  const better = !best || credits < best.credits || (credits === best.credits && ((resolution === fallback && best.resolution !== fallback) ||
@@ -3228,13 +3295,14 @@ export const generateImage = {
3228
3295
  projectId: z.string().uuid().optional().describe(`Save into this Slates project. Renderer refreshes live. Required for every model except ${HEADLESS_IMAGE_MODEL}.`),
3229
3296
  resolution: z.enum(['1k', '2k', '3k', '4k']).optional().describe('Omit for the selected model default. Override for a specific delivery size; use the same setting when estimating.'),
3230
3297
  quality: z.enum(GPT_QUALITY_TIERS).optional().describe(`GPT Image only. Default ${DEFAULT_GPT_QUALITY}; estimate the chosen tier before generation.`),
3231
- backgroundMode: z.enum(GPT_BACKGROUNDS).optional().describe('GPT Image only. transparent = alpha channel. Free.'),
3298
+ backgroundMode: z.enum(GPT_BACKGROUNDS).optional().describe(`${IMAGE_MODELS.filter(takesBackgroundMode).join(', ')} only. transparent = alpha channel (PNG). Free.`),
3232
3299
  aspectRatio: zEnum(IMAGE_ASPECT_RATIOS).optional().describe(`Pick from the use case: cinematic 16:9 · TikTok/Reels 9:16 · IG square 1:1 · ultra-wide 21:9. 1:1 costs most on GPT Image. Per model: ${describeAspectRatios(IMAGE_MODELS)}`),
3233
3300
  count: z.number().int().min(1).max(MAX_IMAGE_VARIATIONS).optional().describe(`Variations of this one prompt: every image gets the same prompt, so different subjects are separate calls. Up to ${MAX_IMAGE_VARIATIONS} with projectId; headless caps at ${HEADLESS_BATCH_CAP}. A 2x2 or 3x3 grid in one picture is a Shot's or the prompt box's Grid (params.gridMode), not count.`),
3234
3301
  referenceImageUrls: z.array(z.string().url()).max(14).optional().describe(`Headless (no projectId) ${HEADLESS_IMAGE_MODEL} only. With a projectId, upload via slates_upload_reference_image. Label every image role in the prompt.`),
3235
3302
  referenceAssetIds: z.array(z.string()).max(16).optional().describe(`Project assets as references — UUIDs or badge codes ("IMG-A8"), resolved at call time. Requires projectId. Caps: ${describeReferenceImageCaps(IMAGE_MODELS)}. Label every reference role in the prompt.`),
3236
3303
  background: z.boolean().optional().describe(BACKGROUND_DESCRIBE),
3237
3304
  confirm: z.boolean().optional().describe(CONFIRM_PARAM),
3305
+ approvedCredits: z.number().int().positive().optional().describe('Only after a reply with `quote_exceeded`: the credits that reply named, once the user has approved them. The desktop counts @mention pictures as paid inputs on seedream-5-5 and runs nothing above the approved total.'),
3238
3306
  folderId: z.string().uuid().nullable().optional().describe(`${FOLDER_DESCRIBE} Needs projectId.`),
3239
3307
  }),
3240
3308
  async run(input, ctx) {
@@ -3252,7 +3320,10 @@ export const generateImage = {
3252
3320
  // HEADLESS_IMAGE_MODEL without one, because it is the only headless seat. The
3253
3321
  // desktop resolves the same seat for its cost and plan-model guards
3254
3322
  // (`imageModelFor`, slate src/main/studio-agent/guards.ts): change both together.
3255
- const imageModel = input.model ?? (input.projectId ? DEFAULT_IMAGE_MODEL : HEADLESS_IMAGE_MODEL);
3323
+ const seat = input.projectId
3324
+ ? await defaultImageSeatFor(() => ctx.desktop(), input.model, `${input.model ?? DEFAULT_IMAGE_MODEL} generation`)
3325
+ : { model: input.model ?? HEADLESS_IMAGE_MODEL, note: '' };
3326
+ const imageModel = seat.model;
3256
3327
  requireGuideRead(ctx, imageModel);
3257
3328
  const promptWarning = bannedTokenWarning(input.prompt, 'image', promptingSkillFor(imageModel));
3258
3329
  input = { ...input, resolution: input.resolution ?? defaultImageResolutionFor(imageModel) };
@@ -3349,7 +3420,7 @@ export const generateImage = {
3349
3420
  if (input.projectId && (input.count ?? 1) > LEGACY_DESKTOP_IMAGE_BATCH) {
3350
3421
  await ctx.desktop().requireCapability('image-variations', 'more than 4 images per call');
3351
3422
  }
3352
- const costKey = imageCostKey(imageModel, resolution, input.quality, input.aspectRatio ?? '1:1');
3423
+ const costKey = imageCostKey(imageModel, resolution, input.quality, input.aspectRatio ?? '1:1', referenceAssetIds.length);
3353
3424
  const cloud = ctx.cloud();
3354
3425
  const registry = await cloud.get('/api/agent/models');
3355
3426
  const entry = registry.models.find((m) => m.model === costKey) ??
@@ -3419,11 +3490,27 @@ export const generateImage = {
3419
3490
  resolution,
3420
3491
  aspectRatio: input.aspectRatio ?? '1:1',
3421
3492
  count: input.count ?? 1,
3422
- ...(isGptImageModel(imageModel) ? { gptQuality: input.quality ?? DEFAULT_GPT_QUALITY, gptBackground: input.backgroundMode } : {}),
3493
+ ...(isGptImageModel(imageModel) ? { gptQuality: input.quality ?? DEFAULT_GPT_QUALITY } : {}),
3494
+ ...(takesBackgroundMode(imageModel) ? { gptBackground: input.backgroundMode } : {}),
3423
3495
  ...(referenceAssetIds.length > 0 ? { referenceAssetIds } : {}),
3496
+ // The desktop adds @mention pictures this op cannot see; on a seat that bills
3497
+ // each input it runs nothing above what the user was quoted or approved.
3498
+ ...(billsEachInputImage(sentModel) ? { maxCredits: Math.max(totalCents, input.approvedCredits ?? 0) } : {}),
3424
3499
  ...folderBody(input.folderId),
3425
3500
  background: input.background,
3426
3501
  });
3502
+ if (result.quoteExceeded) {
3503
+ const { credits, costKey: billedKey } = result.quoteExceeded;
3504
+ return ok({
3505
+ requires_confirm: true,
3506
+ quote_exceeded: true,
3507
+ model: billedKey,
3508
+ estimated_cents: credits,
3509
+ estimated_credits: credits,
3510
+ message: `Nothing ran. The @mention pictures in the prompt are paid inputs on ${imageModel}: this call bills ${fmtCredits(credits)} (${billedKey}), ` +
3511
+ `not the ${fmtCredits(totalCents)} quoted. Tell the user, and once they approve, re-call with confirm=true and approvedCredits=${credits}.`,
3512
+ });
3513
+ }
3427
3514
  // Partial multi-image failure: the desktop attaches an error message
3428
3515
  // but result.assets still holds the images that DID save. Throwing
3429
3516
  // here would discard real, paid-for assets and invite a full retry
@@ -3432,7 +3519,7 @@ export const generateImage = {
3432
3519
  if (!result.success && !partialFailure) {
3433
3520
  throw new Error(result.error ?? 'Generation failed');
3434
3521
  }
3435
- const substitution = gptImageSubstitution(imageModel, sentModel);
3522
+ const substitution = [seat.note, gptImageSubstitution(imageModel, sentModel)].filter(Boolean).join(' ');
3436
3523
  if (result.background) {
3437
3524
  const ids = result.generationIds ?? (result.generationId ? [result.generationId] : []);
3438
3525
  return backgroundSubmitted(`${imageModel} image generation`, ids, {
@@ -3619,9 +3706,9 @@ export const editImage = {
3619
3706
  prompt: z.string().min(1).max(4000).describe('The change, not the whole image. @name and #look words attach nothing here: pass those pictures in referenceAssetIds.'),
3620
3707
  editModel: zEnum(IMAGE_MODELS).optional(),
3621
3708
  referenceAssetIds: z.array(z.string().uuid().describe(ASSET_UUID_ONLY)).max(Math.max(...IMAGE_MODELS.map(editReferenceCap))).optional().describe(`Images beside the source, which is image 1. Each model's own cap: ${IMAGE_MODELS.map((m) => `${m} ${editReferenceCap(m)}`).join(', ')}.`),
3622
- resolution: z.enum(['1k', '2k', '3k', '4k']).optional().describe('3k = GPT Image/seedream-5-lite only.'),
3709
+ resolution: z.enum(['1k', '2k', '3k', '4k']).optional().describe(`Omit for the model's default. Per model: ${IMAGE_MODELS.map((m) => `${m} ${(MODEL_CAPABILITIES[m]?.imageResolutions ?? []).join('/')}`).join(', ')}.`),
3623
3710
  quality: z.enum(GPT_QUALITY_TIERS).optional().describe(`GPT Image tier; default ${DEFAULT_GPT_QUALITY}.`),
3624
- backgroundMode: z.enum(GPT_BACKGROUNDS).optional().describe('GPT Image only. transparent = alpha channel. Free.'),
3711
+ backgroundMode: z.enum(GPT_BACKGROUNDS).optional().describe(`${IMAGE_MODELS.filter(takesBackgroundMode).join(', ')} only. transparent = alpha channel (PNG). Free.`),
3625
3712
  aspectRatio: z.string().optional(),
3626
3713
  confirm: z.boolean().optional().describe(CONFIRM_PARAM),
3627
3714
  background: z.boolean().optional().describe(BACKGROUND_DESCRIBE),
@@ -3632,8 +3719,14 @@ export const editImage = {
3632
3719
  if (input.background) {
3633
3720
  await desktop.requireCapability('background-generation', 'background generation');
3634
3721
  }
3635
- // The image-edit tool's seat (TOOL_SEAT), the model the app's own Edit uses.
3636
- const editModel = input.editModel ?? toolModelFor('image-edit');
3722
+ // The image-edit tool's seat (TOOL_SEAT), the model the app's own Edit uses;
3723
+ // on a desktop that predates Seedream 5.5, the seat it knows (defaultImageSeatFor).
3724
+ const seat = input.editModel
3725
+ ? await defaultImageSeatFor(() => desktop, input.editModel, `${input.editModel} editing`)
3726
+ : toolModelFor('image-edit') === DEFAULT_IMAGE_MODEL
3727
+ ? await defaultImageSeatFor(() => desktop, undefined, 'image editing')
3728
+ : { model: toolModelFor('image-edit'), note: '' };
3729
+ const editModel = seat.model;
3637
3730
  requireGuideRead(ctx, editModel);
3638
3731
  const resolution = input.resolution ?? defaultImageResolutionFor(editModel);
3639
3732
  let sentModel = editModel;
@@ -3651,13 +3744,15 @@ export const editImage = {
3651
3744
  }
3652
3745
  // Past the model's cap the desktop sends the first ones and says so in its reply (`note`).
3653
3746
  const referencesOver = (input.referenceAssetIds?.length ?? 0) - editReferenceCap(editModel);
3654
- // Nano Banana and GPT Image edits charge the same key as gen;
3655
- // FLUX / Seedream route to dedicated edit endpoints priced under '-edit' keys.
3747
+ // Nano Banana and GPT Image edits charge the same key as gen; FLUX routes to
3748
+ // a dedicated edit endpoint priced under an '-edit' key; Seedream 5.5 bills
3749
+ // every input image, the source included, so its key counts them.
3656
3750
  // Mirrors `editCreditKey` in the desktop's src/shared/imageEdit.ts, which
3657
3751
  // this package cannot import: change both together.
3658
- const costKey = editModel === 'flux-3' || editModel === 'seedream-5-lite'
3752
+ const editInputs = 1 + Math.min(input.referenceAssetIds?.length ?? 0, editReferenceCap(editModel));
3753
+ const costKey = editModel === 'flux-3'
3659
3754
  ? `${imageCostKey(editModel, resolution)}-edit`
3660
- : imageCostKey(editModel, resolution, input.quality, input.aspectRatio);
3755
+ : imageCostKey(editModel, resolution, input.quality, input.aspectRatio, editInputs);
3661
3756
  const cloud = ctx.cloud();
3662
3757
  const registry = await cloud.get('/api/agent/models');
3663
3758
  const entry = registry.models.find((m) => m.model === costKey) ??
@@ -3686,13 +3781,14 @@ export const editImage = {
3686
3781
  editModel: sentModel,
3687
3782
  referenceAssetIds: input.referenceAssetIds,
3688
3783
  resolution,
3689
- ...(isGptImageModel(editModel) ? { gptQuality: input.quality ?? DEFAULT_GPT_QUALITY, gptBackground: input.backgroundMode } : {}),
3784
+ ...(isGptImageModel(editModel) ? { gptQuality: input.quality ?? DEFAULT_GPT_QUALITY } : {}),
3785
+ ...(takesBackgroundMode(editModel) ? { gptBackground: input.backgroundMode } : {}),
3690
3786
  aspectRatio: input.aspectRatio,
3691
3787
  background: input.background,
3692
3788
  });
3693
3789
  if (!result.success)
3694
3790
  throw new Error(result.error ?? 'Image edit failed');
3695
- const substitution = gptImageSubstitution(editModel, sentModel);
3791
+ const substitution = [seat.note, gptImageSubstitution(editModel, sentModel)].filter(Boolean).join(' ');
3696
3792
  if (result.background) {
3697
3793
  const ids = result.generationIds ?? (result.generationId ? [result.generationId] : []);
3698
3794
  return backgroundSubmitted(`${editModel} image edit`, ids, {
@@ -3750,7 +3846,7 @@ export const editImage = {
3750
3846
  * with no `confirm`, the op answers with the price and the exact prompt, and spends nothing.
3751
3847
  */
3752
3848
  /** The seats the viewer's Cells box offers. Mirrors slate's `GRID_EXTRACT_MODELS` (`shared/prompts/storyboard-grids.ts`), which this package cannot import. */
3753
- const GRID_EXTRACT_SEATS = ['nano-banana-2-1', 'flux-3', 'seedream-5-lite'];
3849
+ const GRID_EXTRACT_SEATS = ['nano-banana-2-1', 'flux-3', 'seedream-5-5'];
3754
3850
  export const extractGridCells = {
3755
3851
  id: 'slates_extract_grid_cells',
3756
3852
  billable: true,
@@ -3937,7 +4033,7 @@ export function videoCostKey(input) {
3937
4033
  // (fal partner endpoint). A reference video flips to `-vref-{res}-{T}s`,
3938
4034
  // T = in + out, or max(in, out) + out on the AI-face route.
3939
4035
  //
3940
- // ⚠️ EVERY BOUND HERE IS VERSION-SCOPED. 2.5 runs 480p/720p/1080p (no 4K),
4036
+ // ⚠️ EVERY BOUND HERE IS VERSION-SCOPED. 2.5 runs through native 4K,
3941
4037
  // reaches 30s, and takes references to 30s combined — so its vref total
3942
4038
  // reaches 60, DOUBLE 2.0's ceiling of 30. Clamping a 2.5 quote at 30 would
3943
4039
  // quote a real key at a fraction of the real bill. The ladder itself lives in
@@ -4287,6 +4383,12 @@ function promptingSkillFor(model) {
4287
4383
  const VIDEO_MODEL_GUIDES = [
4288
4384
  ...new Set(VIDEO_MODELS.map((m) => promptingSkillFor(m))),
4289
4385
  ].join(' / ');
4386
+ function draftResolution(model, resolution) {
4387
+ if (model !== 'seedance-2.5' || (resolution != null && resolution !== '480p')) {
4388
+ throw new Error('Draft previews require Seedance 2.5 at 480p.');
4389
+ }
4390
+ return '480p';
4391
+ }
4290
4392
  export const generateVideo = {
4291
4393
  id: 'slates_generate_video',
4292
4394
  billable: true,
@@ -4353,6 +4455,7 @@ export const generateVideo = {
4353
4455
  sound: z.boolean().optional().describe('Kling 3.0 (every tier), LTX and Wan 3.0: sound on (default) or silent (false); Kling 3.0 bills audio as its own key. Seedance, Omni Flash, H3 and Kling 4.0 always generate audio.'),
4354
4456
  audioLanguage: z.enum(['EN', 'ZH', 'JA', 'KO', 'ES']).optional().describe('Any Kling 3.0 model with sound on — language for dialogue.'),
4355
4457
  generateMusic: z.boolean().optional().describe('Any Kling 3.0 model with sound on — auto-generate background music.'),
4458
+ seedanceDraft: z.boolean().optional().describe('Create a finishable Seedance 2.5 preview at 480p.'),
4356
4459
  seedanceFace: z.boolean().optional().describe('Seedance only: a reference shows an AI character\'s face. Without it, faces are blocked; the estimate prices it. A real person fails here with [REAL_FACE_DETECTED]; see seedanceRealFace.'),
4357
4460
  seedanceRealFace: z.boolean().optional().describe('Seedance ONLY: a reference shows a REAL person. The real-person tier, priced above Face: estimate it with the flag set first. REQUIRES realFaceConsent=true.'),
4358
4461
  realFaceConsent: z.boolean().optional().describe('MANDATORY with seedanceRealFace: true ONLY after the user has explicitly confirmed they hold rights/consent to this likeness and it does not impersonate or misrepresent them. Refused without it; public figures fail on every tier.'),
@@ -4376,6 +4479,11 @@ export const generateVideo = {
4376
4479
  `pass the base id and set duration / videoResolution as separate params.`);
4377
4480
  }
4378
4481
  input.model = resolved.model;
4482
+ if (input.seedanceDraft || (input.model === 'seedance-2.5' && (input.videoResolution ?? resolved.videoResolution) === '4k')) {
4483
+ await ctx.desktop().requireCapability('seedance-drafts', 'Seedance 2.5 drafts and 4K output');
4484
+ }
4485
+ if (input.seedanceDraft)
4486
+ input.videoResolution = draftResolution(input.model, input.videoResolution ?? resolved.videoResolution);
4379
4487
  requireGuideRead(ctx, input.model);
4380
4488
  if (input.duration == null && resolved.duration != null)
4381
4489
  input.duration = resolved.duration;
@@ -4900,6 +5008,7 @@ export const generateVideo = {
4900
5008
  generateMusic: input.generateMusic,
4901
5009
  seedanceFace: input.seedanceFace,
4902
5010
  seedanceRealFace: input.seedanceRealFace,
5011
+ seedanceDraft: input.seedanceDraft,
4903
5012
  realFaceConsent: input.realFaceConsent,
4904
5013
  negativePrompt: input.negativePrompt,
4905
5014
  ...folderBody(input.folderId),
@@ -7820,6 +7929,7 @@ function shotParamsShape(described) {
7820
7929
  imageQuantity: d(z.number().int().min(1).max(10).optional(), 'Image models only.'),
7821
7930
  negativePrompt: z.string().optional(),
7822
7931
  sound: d(z.boolean().optional(), 'Video models that co-generate audio.'),
7932
+ seedanceDraft: d(z.boolean().optional(), 'Make a finishable Seedance 2.5 preview at 480p.'),
7823
7933
  seedanceFace: d(z.boolean().optional(), "Seedance only — a reference shows an AI character's face; without it faces are blocked. The estimate prices it."),
7824
7934
  audioDurationSeconds: d(z.number().int().min(1).max(120).optional(), 'Audio lane. On seed-audio the requested duration IS the bill.'),
7825
7935
  // The TTS voice — the same three fields slates_generate_audio takes, so a
@@ -7928,6 +8038,8 @@ function shotParamsPatch(p) {
7928
8038
  for (const [k, v] of Object.entries(p))
7929
8039
  if (v !== undefined)
7930
8040
  out[k] = v;
8041
+ if (p.seedanceDraft && p.videoResolution === undefined)
8042
+ out.videoResolution = '480p';
7931
8043
  return out;
7932
8044
  }
7933
8045
  /**
@@ -8090,6 +8202,8 @@ function namedSpecPatch(input, spec) {
8090
8202
  * model, which is worse than the gap.
8091
8203
  */
8092
8204
  function assertShotCapabilities(model, params) {
8205
+ if (params?.seedanceDraft && model)
8206
+ draftResolution(model, params.videoResolution);
8093
8207
  if (!model || !VIDEO_MODELS.includes(model))
8094
8208
  return null;
8095
8209
  const err = assertVideoCapabilities({
@@ -8100,6 +8214,16 @@ function assertShotCapabilities(model, params) {
8100
8214
  });
8101
8215
  return err ? ok(err) : null;
8102
8216
  }
8217
+ async function requireDraftShotDesktop(desktop, model, params, shotId) {
8218
+ if (params?.seedanceDraft) {
8219
+ await desktop.requireCapability('seedance-drafts', 'saving a Seedance 2.5 draft');
8220
+ }
8221
+ else if (params?.videoResolution === '4k') {
8222
+ const target = model ?? (shotId ? (await desktop.get('/agent/shots/get', { id: shotId })).shot.model : undefined);
8223
+ if (target === 'seedance-2.5')
8224
+ await desktop.requireCapability('seedance-drafts', 'saving a native 4K Seedance Shot');
8225
+ }
8226
+ }
8103
8227
  /** Fetch a dynamic cloud cost key for the standalone generation estimate. */
8104
8228
  async function loadDynamicPrice(ctx, byKey, key) {
8105
8229
  if (!key || byKey.has(key))
@@ -8143,6 +8267,7 @@ export const createShot = {
8143
8267
  return alignErr;
8144
8268
  const desktop = ctx.desktop();
8145
8269
  await desktop.requireCapability('shots', 'saved Shots');
8270
+ await requireDraftShotDesktop(desktop, input.model, input.params);
8146
8271
  // 1.6.0 ignores fromAssetId, and would then refuse the missing prompt.
8147
8272
  if (input.fromAssetId)
8148
8273
  await desktop.requireCapability('shot-from-asset', 'saving a result as a Shot');
@@ -8245,6 +8370,7 @@ export const updateShot = {
8245
8370
  return alignErr;
8246
8371
  const desktop = ctx.desktop();
8247
8372
  await desktop.requireCapability('shots', 'saved Shots');
8373
+ await requireDraftShotDesktop(desktop, input.model, input.params, input.shotId);
8248
8374
  const { spec, seatNote } = await buildShotSpecInput(ctx, input.projectId, input);
8249
8375
  // Only send the halves the caller actually named; the route merges a PARTIAL
8250
8376
  // spec over the stored one, so an omitted field is never silently cleared.
@@ -8282,6 +8408,7 @@ export const duplicateShot = {
8282
8408
  return capErr;
8283
8409
  const desktop = ctx.desktop();
8284
8410
  await desktop.requireCapability('shots', 'saved Shots');
8411
+ await requireDraftShotDesktop(desktop, input.model, input.params, input.shotId);
8285
8412
  // Only the halves actually named. The route merges two levels deep, so an
8286
8413
  // omitted param on the copy keeps the original's value rather than clearing it.
8287
8414
  const spec = {};
@@ -8878,6 +9005,12 @@ export const generateFromShots = {
8878
9005
  await desktop.requireCapability('board-quote', 'Shot prices');
8879
9006
  // Resolved first so a SHOT-A code fails here, not halfway through a billed run.
8880
9007
  const details = await Promise.all(input.shotIds.map((id) => desktop.get('/agent/shots/get', { id })));
9008
+ // Older desktops drop the draft flag when reading a saved recipe. Its persisted 480p
9009
+ // resolution survives, so require a capable desktop before firing an ambiguous video Shot.
9010
+ if (!input.draft && details.some(({ shot }) => shot.model === 'seedance-2.5' &&
9011
+ (shot.params?.seedanceDraft || ['480p', '4k'].includes(String(shot.params?.videoResolution))))) {
9012
+ await desktop.requireCapability('seedance-drafts', 'generating saved Seedance 2.5 preview or 4K Shots');
9013
+ }
8881
9014
  const { draft, note: seatNote } = await desktopDraft(desktop, input.draft);
8882
9015
  const quote = await desktop.get('/agent/shots/quote', {
8883
9016
  input: JSON.stringify({ projectId: details[0].shot.projectId, shotIds: details.map((d) => d.shot.id), draft }),
@@ -8935,6 +9068,107 @@ export const getBoardProgress = {
8935
9068
  return ok(await ctx.desktop().get('/agent/shots/progress', input));
8936
9069
  },
8937
9070
  };
9071
+ const draftFinishInput = z.object({
9072
+ projectId: z.string().uuid(),
9073
+ assetId: z.string().describe('Draft video asset ID or badge code.'),
9074
+ resolution: z.enum(['1080p', '4k']),
9075
+ });
9076
+ const draftApproval = {
9077
+ confirm: z.literal(true).describe('The user approved this finish at the quoted price.'),
9078
+ maxCredits: z.number().int().nonnegative().describe('Maximum credits the user approved for the finish.'),
9079
+ };
9080
+ const paidDraftFinishInput = draftFinishInput.extend(draftApproval);
9081
+ export const quoteDraftFinish = {
9082
+ id: 'slates_quote_draft_finish',
9083
+ description: 'Quote a draft take at its full source duration and check its expiry or existing final.',
9084
+ input: draftFinishInput,
9085
+ async run(input, ctx) {
9086
+ const desktop = ctx.desktop();
9087
+ await desktop.requireCapability('seedance-drafts', 'finishing draft takes');
9088
+ const refs = await resolveAssetRefs(ctx, input.projectId, [input.assetId]);
9089
+ return ok(await desktop.get('/agent/assets/quote-draft-finish', { ...input, assetId: refs.get(input.assetId).id }));
9090
+ },
9091
+ };
9092
+ export const finishDraft = {
9093
+ id: 'slates_finish_draft',
9094
+ description: 'Finish an approved draft at 1080p or 4K. Quote the full price first. Check a background generation with slates_get_generation_status.',
9095
+ input: paidDraftFinishInput,
9096
+ billable: true,
9097
+ async run(input, ctx) {
9098
+ requireGuideRead(ctx, 'seedance-2.5');
9099
+ const desktop = ctx.desktop();
9100
+ await desktop.requireCapability('seedance-drafts', 'finishing draft takes');
9101
+ const refs = await resolveAssetRefs(ctx, input.projectId, [input.assetId]);
9102
+ const receipt = await desktop.post('/agent/assets/finish-draft', { ...input, assetId: refs.get(input.assetId).id, background: true });
9103
+ if (!ctx.waitForCutFinish || receipt.status === 'completed')
9104
+ return ok(receipt);
9105
+ if (!receipt.generationId)
9106
+ throw new Error('The finish did not return a generation ID.');
9107
+ for (;;) {
9108
+ if (ctx.signal?.aborted)
9109
+ throw new OperationCancelledError('check the submitted finish in Generations');
9110
+ const status = await desktop.get('/agent/generation/status', { id: receipt.generationId });
9111
+ if (status.generation.status === 'completed') {
9112
+ const cost = receipt.cost_credits === 0 ? 0 : status.generation.draftFinishCredits ?? receipt.cost_credits;
9113
+ return ok({ ...receipt, status: 'completed', cost_credits: cost, assetId: status.asset?.id ?? status.generation.assetId });
9114
+ }
9115
+ if (status.generation.status !== 'processing' && status.generation.status !== 'pending') {
9116
+ throw new Error(status.generation.error || 'The draft finish failed.');
9117
+ }
9118
+ await new Promise(resolve => setTimeout(resolve, 2000));
9119
+ }
9120
+ },
9121
+ };
9122
+ const cutDraftInput = z.object({ projectId: z.string().uuid(), timelineId: z.string().uuid() });
9123
+ const quoteCutInput = cutDraftInput.extend({
9124
+ resolutions: z.record(z.enum(['1080p', '4k'])).optional().describe('Target resolution by draft asset UUID. Defaults to 1080p.'),
9125
+ });
9126
+ const cutFinishStatusInput = cutDraftInput.extend({
9127
+ quoteId: z.string().min(1).describe('Identifier returned by slates_quote_cut_drafts.'),
9128
+ });
9129
+ const finishCutInput = cutFinishStatusInput.extend(draftApproval);
9130
+ export const quoteCutDrafts = {
9131
+ id: 'slates_quote_cut_drafts',
9132
+ description: 'Price the distinct draft sources used in a cut. Returns full-source prices, expiry and a quote ID for approval.',
9133
+ input: quoteCutInput,
9134
+ async run(input, ctx) {
9135
+ const desktop = ctx.desktop();
9136
+ await desktop.requireCapability('seedance-drafts', 'finishing drafts in a cut');
9137
+ return ok(await desktop.post('/agent/timeline/cut', { ...input, action: 'quoteDrafts' }));
9138
+ },
9139
+ };
9140
+ export const finishCutDrafts = {
9141
+ id: 'slates_finish_cut_drafts',
9142
+ description: 'Start finishing the approved cut in the background. Each ready final replaces its draft throughout the cut. Check progress with slates_get_cut_draft_status.',
9143
+ input: finishCutInput,
9144
+ billable: true,
9145
+ async run(input, ctx) {
9146
+ requireGuideRead(ctx, 'seedance-2.5');
9147
+ const desktop = ctx.desktop();
9148
+ await desktop.requireCapability('seedance-drafts', 'finishing drafts in a cut');
9149
+ const query = { projectId: input.projectId, timelineId: input.timelineId, quoteId: input.quoteId };
9150
+ let receipt = await desktop.post('/agent/timeline/cut', {
9151
+ ...input, action: 'finishDrafts', background: true,
9152
+ });
9153
+ while (ctx.waitForCutFinish && receipt.status === 'running') {
9154
+ if (ctx.signal?.aborted)
9155
+ throw new OperationCancelledError('check the cut finish status for any source already submitted');
9156
+ await new Promise(resolve => setTimeout(resolve, 2000));
9157
+ receipt = await desktop.get('/agent/timeline/draft-finish', query);
9158
+ }
9159
+ return ok(receipt);
9160
+ },
9161
+ };
9162
+ export const getCutDraftStatus = {
9163
+ id: 'slates_get_cut_draft_status',
9164
+ description: 'Check which sources in an approved cut have been finished, replaced, or kept as drafts.',
9165
+ input: cutFinishStatusInput,
9166
+ async run(input, ctx) {
9167
+ const desktop = ctx.desktop();
9168
+ await desktop.requireCapability('seedance-drafts', 'finishing drafts in a cut');
9169
+ return ok(await desktop.get('/agent/timeline/draft-finish', input));
9170
+ },
9171
+ };
8938
9172
  export const editCut = {
8939
9173
  id: 'slates_edit_cut',
8940
9174
  description: 'Build the timeline from the board\'s chosen clips (a marker per scene), or keep it in step with the board\'s favourite takes: read pending preferred-take changes, explicitly replace one clip, sync a board’s preferred clips, or build a cut in board order. Read changes first for the count. Swaps keep timeline starts and source timing when possible; shorter takes are visibly marked. Never changes a shot recipe or poster. Undo swaps with restore and the returned before snapshots; undo a build with undo-build and its clipIds/markerIds.',
@@ -9065,7 +9299,7 @@ export function resolveGuideTopic(topic) {
9065
9299
  if (t.startsWith('flux'))
9066
9300
  return 'slates-prompting-flux-3';
9067
9301
  if (t.startsWith('seedream'))
9068
- return 'slates-prompting-seedream-5-lite';
9302
+ return 'slates-prompting-seedream-5-5';
9069
9303
  if (t.startsWith('omni-flash') || t.startsWith('gemini-omni') || t === 'omni flash')
9070
9304
  return 'slates-prompting-omni-flash';
9071
9305
  if (t.startsWith('wan') || t === 'alibaba-wan-3.0')
@@ -9413,6 +9647,23 @@ export const getPromptingGuide = {
9413
9647
  return { text, data: { ...result, ...(tied.length ? { tied } : {}), memberAccess: member.access, bytes: Buffer.byteLength(text, 'utf8') } };
9414
9648
  },
9415
9649
  };
9650
+ export const rememberInMyBrain = {
9651
+ id: 'slates_remember',
9652
+ description: 'Save a lesson to the user\'s own brain (My brain, on their machine; it wins over the shared brain on every later job). Call it without asking when they say remember, always or never, or correct the same thing a second time; then tell them in one line what was saved and that "undo" removes it. One lesson per call, in their words. file groups lessons by topic (hooks, captions, profile for who they are and what they make; a shared guide\'s name adds to that guide for them). To change a rule pass replaces with the old line; to undo or forget pass replaces alone. A refusal names why (a cap, a lesson the shared brain already holds): merge into an existing line instead. Free.',
9653
+ input: z.object({
9654
+ lesson: z.string().min(3).max(300).optional().describe('One rule or preset in the user\'s words, for example "cut every hook to its first word". Omit with replaces to remove a line.'),
9655
+ file: z.string().min(1).max(60).optional().describe('Their file, lowercase-hyphenated: a topic (hooks), profile, or a shared guide name. Default my-rules.'),
9656
+ source: z.string().max(120).optional().describe('What taught it: "said always", "corrected twice", "kept take IMG-A8".'),
9657
+ replaces: z.string().min(3).max(300).optional().describe('Text of the existing line this lesson replaces; alone, the line to remove.'),
9658
+ }),
9659
+ async run(input) {
9660
+ const result = remember(input);
9661
+ const text = result.unchanged ? `Already in your brain (${result.file}): ${result.saved}`
9662
+ : result.saved ? `Saved to your brain (${result.file}): ${result.saved}${result.removed ? ` (replaces: ${result.removed})` : ''}`
9663
+ : `Removed from your brain (${result.file}): ${result.removed}`;
9664
+ return { text, data: { ...result } };
9665
+ },
9666
+ };
9416
9667
  /**
9417
9668
  * Task discovery and exact schemas share one operation. The desktop uses
9418
9669
  * names/group to replace its optional selection; MCP keeps its full list fixed.
@@ -9827,8 +10078,14 @@ export const ALL_OPERATIONS = [
9827
10078
  generateFromShots,
9828
10079
  quoteBoard,
9829
10080
  getBoardProgress,
10081
+ quoteDraftFinish,
10082
+ finishDraft,
10083
+ quoteCutDrafts,
10084
+ finishCutDrafts,
10085
+ getCutDraftStatus,
9830
10086
  editCut,
9831
10087
  getPromptingGuide,
10088
+ rememberInMyBrain,
9832
10089
  loadTools,
9833
10090
  // ── Blender previs, LAST and deliberately ────────────────────────────
9834
10091
  // These six landed at the TOP once, which put a third transport nobody