@slatesvideo/shared 0.7.18 → 0.7.20

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.
@@ -1,3 +1,4 @@
1
+ import { randomUUID } from 'node:crypto';
1
2
  import { MAX_IMAGE_VARIATIONS, SHEET_TOOL_ASPECT_RATIO, SHEET_TOOL_GPT_QUALITY } from '../prompts/generation-policy.js';
2
3
  import { STYLE_LIBRARY, DEFAULT_STYLE_ID } from '../prompts/style-library.js';
3
4
  import { discoverGuides, guideCatalog } from '../prompts/guide-discovery.js';
@@ -21,6 +22,7 @@ import { SlatesDesktopClient } from '../clients/desktop.js';
21
22
  import { BlenderBridgeClient, BLENDER_SETUP_HINT, RENDER_TIMEOUT_MS } from '../clients/blender.js';
22
23
  import { SKILLS } from '../skills/content.js';
23
24
  import { brainSkills, myBrainDir, myBrainPreload, noteUsed } from '../skills/my-brain.js';
25
+ import { remember } from '../skills/my-brain-write.js';
24
26
  import { brainFiles, refreshServedBrain, servedBrain } from '../skills/served.js';
25
27
  import { HYPERFRAMES_MAPPING, findHyperframesGuide, hyperframesCard, hyperframesCatalog, hyperframesFilesOf, hyperframesGuideHeader, hyperframesSkillBodies, loadHyperframes } from '../skills/hyperframes.js';
26
28
  import { appManualIndex, appManualSections } from '../manual/index.js';
@@ -541,10 +543,11 @@ export const setSelection = {
541
543
  const VIEW_LENSES = ['board', 'media', 'script'];
542
544
  const VIEW_CUT_SIDES = ['bottom', 'left', 'right'];
543
545
  const VIEW_DOCK_SECTIONS = ['storyboards', 'library', 'folders', 'pinned'];
544
- // W3: the one window's two layouts (`WINDOW_LAYOUTS`).
546
+ // W3: the one window's two layouts (`WINDOW_LAYOUTS`), and its shape (`SHAPE_SETTINGS`).
545
547
  const VIEW_WINDOW_LAYOUTS = ['plan', 'edit'];
546
548
  // What the timeline's Viewer shows (`VIEWER_MODES`).
547
549
  const VIEW_VIEWER_MODES = ['source', 'timeline'];
550
+ const VIEW_SHAPE_SETTINGS = ['auto', 'landscape', 'vertical'];
548
551
  // 1.6.1: what the user is looking at. Mirrors slate's `@shared/types/view` (lockstep check 12).
549
552
  const VIEW_BOARD_LEVELS = ['film', 'scenes', 'shot'];
550
553
  const VIEW_BOARD_FILTERS = ['all', 'with-clip', 'without-clip'];
@@ -555,11 +558,28 @@ const DOCK_SECTION_NAMES = { storyboards: 'Boards', library: 'Library', folders:
555
558
  // Delivery ids and dimensions come from the desktop catalog, not model capabilities.
556
559
  const deliveryAspectInput = z.string().min(1).describe('Delivery format id from slates_get_variant_grid.formats; the desktop validates it and supplies dimensions.');
557
560
  const gridSelectionInput = z.object({ rowKeys: z.array(z.string()), aspects: z.array(deliveryAspectInput) }).strict();
561
+ // A file's encoding. Mirrors slate's `@shared/deliveryFormats` (PLATFORM_PRESET_IDS, EXPORT_VIDEO_CODECS,
562
+ // EXPORT_FRAME_RATES, VIDEO_BITRATE_RANGE); the desktop validates every value again.
563
+ const PLATFORM_PRESET_IDS = ['tiktok', 'reels', 'meta-feed', 'stories', 'shorts', 'youtube'];
564
+ const exportEncodingShape = {
565
+ presetId: z.enum(PLATFORM_PRESET_IDS).optional().describe("A platform's targets: its frame size, H.264 bitrate, frame-rate ceiling and sound."),
566
+ codec: z.enum(['h264', 'h265', 'prores']).optional().describe('h264 (default) and h265 write an .mp4; prores writes a .mov with PCM sound for editing elsewhere.'),
567
+ videoBitrateMbps: z.number().min(2).max(120).nullable().optional().describe("The picture's Mb/s; null is Auto (the preset's, else the engine's own). Ignored by prores."),
568
+ fps: z.union([z.literal(24), z.literal(30), z.literal(60)]).nullable().optional().describe("The file's frame rate; null is the timeline's."),
569
+ };
570
+ const exportEncodingInput = z.object(exportEncodingShape).strict();
558
571
  const deliveryInput = z.object({
559
572
  formats: z.array(deliveryAspectInput).min(1),
560
573
  shortSide: z.number().int().positive().optional().describe('Optional short side supported by the desktop delivery settings.'),
561
574
  mode: z.enum(['fill', 'fit']).optional().describe('Fill crops around focus; fit pads the frame.'),
575
+ presetId: z.enum(PLATFORM_PRESET_IDS).nullable().optional().describe('The platform the cut is made for: its encoding targets and its safe-area guide.'),
576
+ encoding: exportEncodingInput.nullable().optional().describe("The cut's own encoding over the preset's; every export of it uses it."),
562
577
  }).strict();
578
+ /** A delivery naming a preset or an encoding: an older desktop drops both without a word. */
579
+ async function requireDeliveryEncoding(desktop, delivery) {
580
+ if (delivery && (delivery.presetId != null || delivery.encoding != null))
581
+ await desktop.requireCapability('export-encoding', 'platform presets and export encoding');
582
+ }
563
583
  const taxonomyInput = z.object({
564
584
  concept: z.string().min(1), variant: z.string().min(1),
565
585
  hook: z.string().optional(), body: z.string().optional(), cast: z.string().optional(),
@@ -645,7 +665,7 @@ const describeView = (v) => {
645
665
  `The project navigator is ${v.leftDock.open ? `open (${v.leftDock.width}px)` : 'closed'}, and ${agent}.` +
646
666
  (v.leftDock.folded?.length ? ` Folded in the navigator: ${v.leftDock.folded.map((f) => DOCK_SECTION_NAMES[f] ?? f).join(', ')}.` : '') +
647
667
  (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'}.`
668
+ ? ` 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
669
  : '') +
650
670
  (v.script ? ` The Script page shows ${v.script.details ? 'Words + shots (each shot\'s picture beside its words)' : 'Words (the words alone)'}.` : '') +
651
671
  describeLooking(v));
@@ -657,7 +677,7 @@ const describeView = (v) => {
657
677
  */
658
678
  export const getView = {
659
679
  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.",
680
+ 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
681
  input: z.object({}).strict(),
662
682
  async run(_input, ctx) {
663
683
  await ctx.desktop().requireCapability('view', 'the window layout');
@@ -685,7 +705,7 @@ export const getView = {
685
705
  */
686
706
  export const setView = {
687
707
  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.",
708
+ 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, Review mode (review, reviewAssetIds), 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
709
  input: z
690
710
  .object({
691
711
  projectId: z.string().nullable().optional().describe('Open this project, or null for Home. Applied alone.'),
@@ -775,19 +795,31 @@ export const setView = {
775
795
  .object({ open: z.boolean().optional(), assetIds: z.array(z.string()).max(4).optional().describe('The compare set, two to four items.') })
776
796
  .strict()
777
797
  .optional(),
798
+ review: z.boolean().optional().describe("Review mode on or off, as the Viewer's Review button: on shows the Viewer with the Notes view in its drawer, where the person marks, rates and sends notes."),
799
+ reviewAssetIds: z.array(z.string()).nullable().optional().describe('With review on: the pictures and clips the arrow keys step through (a round to review); null steps through what is on screen. Turns review on.'),
778
800
  animatic: z.object({ open: z.boolean(), fromShotId: z.string().optional() }).strict().optional().describe('Play the board as a rough cut from a Shot (the Board or Script tab must be showing).'),
779
801
  settings: z.object({ open: z.boolean(), pane: z.enum(VIEW_SETTINGS_PANES).optional() }).strict().optional().describe('Open Settings, on a pane (ai is AI tools, keys is API keys).'),
780
802
  composer: z.object({ open: z.boolean() }).strict().optional().describe('Show or hide the prompt box.'),
781
803
  window: z
782
804
  .object({
783
805
  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.'),
806
+ preset: z
807
+ .string()
808
+ .min(1)
809
+ .optional()
810
+ .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."),
811
+ reset: z.boolean().optional().describe("true puts the current layout back as it was saved (the Layout map's Reset layout)."),
812
+ shape: z
813
+ .enum(VIEW_SHAPE_SETTINGS)
814
+ .optional()
815
+ .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
816
  viewer: z.boolean().optional().describe('Show or hide the Viewer.'),
785
817
  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
818
  lensWidth: z.number().optional().describe("The Media, Board and Script column's width in px in the Edit layout."),
787
819
  })
788
820
  .strict()
789
821
  .optional()
790
- .describe('The one window (desktops with it): its layout and which areas show.'),
822
+ .describe('The one window (desktops with it): its layout, its shape and which areas show.'),
791
823
  })
792
824
  .strict(),
793
825
  async run(input, ctx) {
@@ -803,9 +835,14 @@ export const setView = {
803
835
  input.script?.panelShotId !== undefined;
804
836
  if (widened)
805
837
  await ctx.desktop().requireCapability('view-v2', 'showing and opening things in the window');
838
+ if (input.window?.preset !== undefined || input.window?.reset !== undefined || input.window?.shape !== undefined) {
839
+ await ctx.desktop().requireCapability('layout-presets', 'choosing a layout or the window shape');
840
+ }
806
841
  if (input.cut?.format !== undefined || input.cut?.gridSelection !== undefined) {
807
842
  await ctx.desktop().requireCapability('ad-variant-export', 'delivery preview and variant grid selection');
808
843
  }
844
+ if (input.review !== undefined || input.reviewAssetIds !== undefined)
845
+ await ctx.desktop().requireCapability('view-review', 'Review mode');
809
846
  // A desktop from before the one window has no capability token for it, and refuses a patch holding only
810
847
  // `window` as empty; its view report has no `window`, so read that first.
811
848
  if (input.window !== undefined && Object.entries(input).every(([k, v]) => k === 'window' || v === undefined)) {
@@ -1866,6 +1903,7 @@ export const estimateGenerationCost = {
1866
1903
  quality: z.enum(GPT_QUALITY_TIERS).optional().describe(`GPT Image tier; default ${DEFAULT_GPT_QUALITY}.`),
1867
1904
  aspectRatio: z.string().optional().describe('GPT Image: the frame shape changes the price; pass the generation\'s value.'),
1868
1905
  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.'),
1906
+ seedanceDraft: z.boolean().optional().describe('Create a finishable Seedance 2.5 preview at 480p.'),
1869
1907
  seedanceFace: z.boolean().optional().describe('Seedance Face row, for an AI character\'s face.'),
1870
1908
  seedanceRealFace: z.boolean().optional().describe('Seedance with a consented real person (premium key).'),
1871
1909
  videoRefSeconds: z.number().nonnegative().optional().describe('Combined reference-video seconds, measured from the clips.'),
@@ -1879,10 +1917,14 @@ export const estimateGenerationCost = {
1879
1917
  if (retired) {
1880
1918
  throw new Error(`${retired} was retired and ${RETIRED_MODELS[retired]} replaced it. Quote ${RETIRED_MODELS[retired]} with the same parameters.`);
1881
1919
  }
1920
+ if (input.seedanceDraft) {
1921
+ const video = resolveVideoModel(input.model);
1922
+ input.videoResolution = draftResolution(video?.model, input.videoResolution ?? video?.videoResolution);
1923
+ }
1882
1924
  const registry = await ctx.cloud().get('/api/agent/models');
1883
1925
  const byKey = new Map(registry.models.filter((m) => !retiredModelOfKey(m.model)).map((m) => [m.model, creditCost(m)]));
1884
1926
  // 1) exact registry cost key
1885
- let key = byKey.has(input.model) ? input.model : null;
1927
+ let key = !input.seedanceDraft && byKey.has(input.model) ? input.model : null;
1886
1928
  // 2) image base id + resolution (+ quality for GPT Image)
1887
1929
  if (!key) {
1888
1930
  // IMAGE_MODELS, never a second hand-typed copy: this list is declared
@@ -2002,7 +2044,7 @@ export const estimateGenerationCost = {
2002
2044
  resolved.videoResolution ??
2003
2045
  // Seedance quotes are resolution-scaled, so a missing resolution has
2004
2046
  // 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
2047
+ // row and a blanket literal can quote a key that does
2006
2048
  // not exist. Read from the SSOT; this used to be a hand-typed
2007
2049
  // model-id ternary.
2008
2050
  defaultVideoResolutionFor(resolved.model),
@@ -4013,7 +4055,7 @@ export function videoCostKey(input) {
4013
4055
  // (fal partner endpoint). A reference video flips to `-vref-{res}-{T}s`,
4014
4056
  // T = in + out, or max(in, out) + out on the AI-face route.
4015
4057
  //
4016
- // ⚠️ EVERY BOUND HERE IS VERSION-SCOPED. 2.5 runs 480p/720p/1080p (no 4K),
4058
+ // ⚠️ EVERY BOUND HERE IS VERSION-SCOPED. 2.5 runs through native 4K,
4017
4059
  // reaches 30s, and takes references to 30s combined — so its vref total
4018
4060
  // reaches 60, DOUBLE 2.0's ceiling of 30. Clamping a 2.5 quote at 30 would
4019
4061
  // quote a real key at a fraction of the real bill. The ladder itself lives in
@@ -4363,6 +4405,12 @@ function promptingSkillFor(model) {
4363
4405
  const VIDEO_MODEL_GUIDES = [
4364
4406
  ...new Set(VIDEO_MODELS.map((m) => promptingSkillFor(m))),
4365
4407
  ].join(' / ');
4408
+ function draftResolution(model, resolution) {
4409
+ if (model !== 'seedance-2.5' || (resolution != null && resolution !== '480p')) {
4410
+ throw new Error('Draft previews require Seedance 2.5 at 480p.');
4411
+ }
4412
+ return '480p';
4413
+ }
4366
4414
  export const generateVideo = {
4367
4415
  id: 'slates_generate_video',
4368
4416
  billable: true,
@@ -4429,6 +4477,7 @@ export const generateVideo = {
4429
4477
  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.'),
4430
4478
  audioLanguage: z.enum(['EN', 'ZH', 'JA', 'KO', 'ES']).optional().describe('Any Kling 3.0 model with sound on — language for dialogue.'),
4431
4479
  generateMusic: z.boolean().optional().describe('Any Kling 3.0 model with sound on — auto-generate background music.'),
4480
+ seedanceDraft: z.boolean().optional().describe('Create a finishable Seedance 2.5 preview at 480p.'),
4432
4481
  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.'),
4433
4482
  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.'),
4434
4483
  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.'),
@@ -4452,6 +4501,11 @@ export const generateVideo = {
4452
4501
  `pass the base id and set duration / videoResolution as separate params.`);
4453
4502
  }
4454
4503
  input.model = resolved.model;
4504
+ if (input.seedanceDraft || (input.model === 'seedance-2.5' && (input.videoResolution ?? resolved.videoResolution) === '4k')) {
4505
+ await ctx.desktop().requireCapability('seedance-drafts', 'Seedance 2.5 drafts and 4K output');
4506
+ }
4507
+ if (input.seedanceDraft)
4508
+ input.videoResolution = draftResolution(input.model, input.videoResolution ?? resolved.videoResolution);
4455
4509
  requireGuideRead(ctx, input.model);
4456
4510
  if (input.duration == null && resolved.duration != null)
4457
4511
  input.duration = resolved.duration;
@@ -4976,6 +5030,7 @@ export const generateVideo = {
4976
5030
  generateMusic: input.generateMusic,
4977
5031
  seedanceFace: input.seedanceFace,
4978
5032
  seedanceRealFace: input.seedanceRealFace,
5033
+ seedanceDraft: input.seedanceDraft,
4979
5034
  realFaceConsent: input.realFaceConsent,
4980
5035
  negativePrompt: input.negativePrompt,
4981
5036
  ...folderBody(input.folderId),
@@ -6058,20 +6113,249 @@ const reframeClipInput = reframeReportInput.extend({ clipId: z.string().uuid(),
6058
6113
  mode: z.enum(['fill', 'fit']).optional(), focusX: z.number().min(0).max(1).optional(),
6059
6114
  focusY: z.number().min(0).max(1).optional(), zoom: z.number().min(1).optional(),
6060
6115
  }).strict().nullable().optional().describe('Normalized focus and zoom for this clip/aspect. Null resets the override; the desktop binds it to the current take. Required unless follow is set.'),
6061
- follow: z.enum(['face', 'off']).optional().describe('"face" finds the face in the clip and keys its focusX/focusY to it (smooth, held where the face is lost; every format draws those keys, each keyframe editable by hand or with slates_set_clip_keyframes); "off" removes those keys. Runs on the computer and spends nothing.') });
6116
+ follow: z.union([z.enum(['face', 'off']), z.object({ maskId: z.string().regex(/^[A-Za-z0-9_-]{1,80}$/) }).strict()]).optional().describe('"face" finds the face in the clip and keys its focusX/focusY to it (smooth, held where the face is lost; every format draws those keys, each keyframe editable by hand or with slates_set_clip_keyframes); { maskId } follows one of the clip\'s subject masks instead (slates_get_subject_mask lists them); "off" removes those keys. Runs on the computer and spends nothing.') });
6062
6117
  export const reframeClip = {
6063
- id: 'slates_reframe_clip', description: 'Set or reset a clip framing override for one delivery aspect and return the desktop computed framing report. Changes focus, fill/fit and zoom without duplicating the timeline or generating media. follow: "face" makes a vertical cut follow a talking head (framing, when sent too, lands first) and answers follow: the clip keyframes, samples, found, still and the lost spans in seconds. Requires ad-variant-export, and reframe-follow for follow; update Slates on capability refusal.',
6118
+ id: 'slates_reframe_clip', description: 'Set or reset a clip framing override for one delivery aspect and return the desktop computed framing report. Changes focus, fill/fit and zoom without duplicating the timeline or generating media. follow: "face" makes a vertical cut follow a talking head, or { maskId } a subject mask (framing, when sent too, lands first) and answers follow: the clip keyframes, samples, found, still and the lost spans in seconds. Requires ad-variant-export, and reframe-follow for follow; update Slates on capability refusal.',
6064
6119
  billable: false,
6065
6120
  input: reframeClipInput,
6066
6121
  async run(input, ctx) {
6067
6122
  await ctx.desktop().requireCapability('ad-variant-export', 'clip delivery reframing');
6068
6123
  if (input.follow)
6069
6124
  await ctx.desktop().requireCapability('reframe-follow', 'following a face');
6125
+ if (typeof input.follow === 'object')
6126
+ await ctx.desktop().requireCapability('subject-follow', 'following a subject mask');
6070
6127
  else if (input.framing === undefined)
6071
6128
  throw new Error('Send framing (null resets it) or follow');
6072
6129
  return ok(await ctx.desktop().post('/agent/timeline/reframe', input));
6073
6130
  },
6074
6131
  };
6132
+ // ── The Cut's finishing tools and Review mode (slate roadmap Waves 1 to 3) ─────────────
6133
+ // Desktop routes in slate `src/main/agent/routes-finishing.ts`; each calls the core the window's own control
6134
+ // calls. A clip's grade, LUT, colour key, shape mask and reverse are fields on slates_update_clip.
6135
+ const clipTargetInput = {
6136
+ projectId: z.string().uuid(),
6137
+ clipId: z.string().uuid().describe('The clip on the timeline (slates_get_timeline lists them).'),
6138
+ };
6139
+ export const freezeFrame = {
6140
+ id: 'slates_freeze_frame',
6141
+ billable: false,
6142
+ description: "Hold one frame of a video clip as a still, as the Inspector's Freeze frame does: the frame at the timeline point named (frame, or sec) is saved as a new picture and placed on the clip's own lane for seconds (default 2), the clip splitting around it and everything after moving later; linked: false leaves the clip's linked sound where it is. Returns the clips written, stillClipId and stillAssetId. Free, on this machine. Requires freeze-frame; update Slates on capability refusal.",
6143
+ input: z.object({
6144
+ ...clipTargetInput,
6145
+ frame: z.number().int().min(0).optional().describe('The timeline frame to hold. Or sec.'),
6146
+ sec: z.number().min(0).optional().describe('The timeline second to hold. Or frame.'),
6147
+ seconds: z.number().min(0.1).max(60).optional().describe('How long the still holds, 0.1 to 60 seconds. Default 2.'),
6148
+ linked: z.boolean().optional().describe("False: leave the linked sound in place. Default true."),
6149
+ }).strict(),
6150
+ async run(input, ctx) {
6151
+ if (input.frame === undefined && input.sec === undefined)
6152
+ throw new Error('Name the frame to hold: frame (timeline frames) or sec (timeline seconds).');
6153
+ await ctx.desktop().requireCapability('freeze-frame', 'freeze frame');
6154
+ return ok(await ctx.desktop().post('/agent/timeline/freeze-frame', input));
6155
+ },
6156
+ };
6157
+ export const stabilizeClip = {
6158
+ id: 'slates_stabilize_clip',
6159
+ billable: false,
6160
+ description: "Steady a shaky video clip, as the Inspector's Stabilize does: the file's motion is analysed on this machine and a steadied copy plays in its place (the original file is untouched). strength light keeps most of the move and crops least, strong holds the frame stillest and crops most; null turns it off. Takes about as long as the clip runs. Free. Requires stabilize; update Slates on capability refusal.",
6161
+ input: z.object({
6162
+ ...clipTargetInput,
6163
+ strength: z.enum(['light', 'standard', 'strong']).nullable().describe('How steady; null turns stabilize off.'),
6164
+ }).strict(),
6165
+ async run(input, ctx) {
6166
+ await ctx.desktop().requireCapability('stabilize', 'stabilize');
6167
+ return ok(await ctx.desktop().post('/agent/timeline/stabilize', input));
6168
+ },
6169
+ };
6170
+ export const slideClip = {
6171
+ id: 'slates_slide_clip',
6172
+ billable: false,
6173
+ description: "Slide a clip between its neighbours, as the Slide tool does: the clip keeps its own content and length and moves deltaFrames later (or earlier, negative), the clip before it growing and the one after shrinking to fill, so nothing else on the timeline moves. Needs a clip touching each side; held to the media each neighbour has. Returns the clips written and slidFrames, the move made. Free. Requires slide-edit; update Slates on capability refusal.",
6174
+ input: z.object({
6175
+ ...clipTargetInput,
6176
+ deltaFrames: z.number().int().describe('Frames to move: positive later, negative earlier.'),
6177
+ }).strict(),
6178
+ async run(input, ctx) {
6179
+ await ctx.desktop().requireCapability('slide-edit', 'slide edit');
6180
+ return ok(await ctx.desktop().post('/agent/timeline/slide-clip', input));
6181
+ },
6182
+ };
6183
+ export const punchIn = {
6184
+ id: 'slates_punch_in',
6185
+ billable: false,
6186
+ description: "Punch in on a video clip or picture, as the Inspector's Punch in does: scale and position keys that push in about the subject (its framing focus). From a point: fromFrame (frames from the clip's start, default 0) to the clip's end. On emphasis words: words (indexes into slates_get_asset_transcript's words) each punch in on the word and back out holdSec after it (default about half a second). style: cut (a hard punch), ease-in, slow-push. amount is the scale, above 1 and at most 1.5 (default 1.15). off: true takes the punch away. A clip with hand-set scale or position keys is refused unless replaceKeys: true. Returns the clip's keyframes and the punch read back. Every key stays editable with slates_set_clip_keyframes. Free. Requires punch-in; update Slates on capability refusal.",
6187
+ input: z.object({
6188
+ ...clipTargetInput,
6189
+ amount: z.number().gt(1).max(1.5).optional().describe('The scale, above 1 and at most 1.5. Default 1.15.'),
6190
+ style: z.enum(['cut', 'ease-in', 'slow-push']).optional(),
6191
+ fromFrame: z.number().int().min(0).optional().describe("Where the punch starts, in frames from the clip's start."),
6192
+ words: z.array(z.number().int().min(0)).min(1).optional().describe("Punch on these words, by index in the clip's transcript words."),
6193
+ holdSec: z.number().min(0).max(5).optional().describe('With words: how long each punch holds past its word, 0 to 5 seconds.'),
6194
+ off: z.boolean().optional().describe('True removes the punch in.'),
6195
+ replaceKeys: z.boolean().optional().describe("True puts the punch in place of the clip's own scale and position keys."),
6196
+ }).strict(),
6197
+ async run(input, ctx) {
6198
+ await ctx.desktop().requireCapability('punch-in', 'punch in');
6199
+ return ok(await ctx.desktop().post('/agent/timeline/punch-in', input));
6200
+ },
6201
+ };
6202
+ const dialogueCleanupOptions = z.object({
6203
+ fillers: z.boolean().optional().describe('Filler words (um, uh, like as a filler). Default on.'),
6204
+ pauses: z.boolean().optional().describe('Long pauses. Default on.'),
6205
+ repeats: z.boolean().optional().describe('A word or phrase said twice in a row: the first goes. Default on.'),
6206
+ minPauseSec: z.number().min(0).optional().describe('A pause counts from this long.'),
6207
+ keepAirSec: z.number().min(0).optional().describe('Air kept at each side of a cut pause.'),
6208
+ }).strict();
6209
+ export const cleanUpDialogue = {
6210
+ id: 'slates_clean_up_dialogue',
6211
+ billable: false,
6212
+ description: "Clean up a talking clip by its transcript, as the Transcript page's Clean up does. scan (default, writes nothing) lists the fillers, long pauses and repeated words found, with counts, the top fillers, what apply would cut and the joins an earlier clean-up left. apply cuts them all in one edit (ripple; the linked sound and captions follow unless linked: false) and lists each join. restore puts one join's cut back (range, as scan or apply listed it); nudge moves the clip edge at a join (edge start or end) by deltaFrames. options turns each kind on or off and sets the pause length and the air kept. The clip needs a transcript (slates_transcribe_asset, free). For words picked one by one, slates_cut_by_transcript. Free. Requires dialogue-cleanup; update Slates on capability refusal.",
6213
+ input: z.object({
6214
+ ...clipTargetInput,
6215
+ action: z.enum(['scan', 'apply', 'restore', 'nudge']).optional().describe('Default scan.'),
6216
+ options: dialogueCleanupOptions.optional(),
6217
+ range: z.object({ startSec: z.number().min(0), endSec: z.number().min(0) }).strict().optional().describe("restore: the join's range, in the file's own seconds."),
6218
+ edge: z.enum(['start', 'end']).optional().describe('nudge: start (where the cut begins) or end (where it stops).'),
6219
+ deltaFrames: z.number().int().optional().describe('nudge: frames to move the edge, positive later.'),
6220
+ linked: z.boolean().optional().describe("False: cut only the clip's lane. Default true."),
6221
+ }).strict(),
6222
+ async run(input, ctx) {
6223
+ if (input.action === 'restore' && !input.range)
6224
+ throw new Error('restore needs range: a join as scan or apply listed it.');
6225
+ if (input.action === 'nudge' && (!input.edge || input.deltaFrames === undefined))
6226
+ throw new Error('nudge needs edge and deltaFrames.');
6227
+ await ctx.desktop().requireCapability('dialogue-cleanup', 'dialogue clean-up');
6228
+ return ok(await ctx.desktop().post('/agent/timeline/dialogue-cleanup', input));
6229
+ },
6230
+ };
6231
+ export const autoColourClip = {
6232
+ id: 'slates_auto_colour_clip',
6233
+ billable: false,
6234
+ description: "Give a video clip or picture a neutral grade from its own frame, as the Inspector's Auto colour does: the frame at frame or sec (default the clip's middle) is read, and exposure, contrast, temperature, tint, highlights and shadows are written to the clip's look as ordinary values (other look fields kept), each editable with slates_update_clip. Returns the values, the look and the frame read. Free, on this machine. Requires clip-grade; update Slates on capability refusal.",
6235
+ input: z.object({
6236
+ ...clipTargetInput,
6237
+ frame: z.number().int().min(0).optional().describe('The timeline frame to read.'),
6238
+ sec: z.number().min(0).optional().describe('The timeline second to read.'),
6239
+ }).strict(),
6240
+ async run(input, ctx) {
6241
+ await ctx.desktop().requireCapability('clip-grade', 'auto colour');
6242
+ return ok(await ctx.desktop().post('/agent/timeline/auto-colour', input));
6243
+ },
6244
+ };
6245
+ export const autoDuck = {
6246
+ id: 'slates_auto_duck',
6247
+ billable: false,
6248
+ description: "Dip music under speech, as the lane's Auto duck does: a music lane (trackId) or one clip (clipId) drops by duckDb wherever another lane speaks, read from the transcripts (a clip with no transcript counts as speech for its whole sound). attackSec and releaseSec shape the dip, holdSec keeps it down past each word, bridgeSec joins gaps shorter than that. Written as one effect on the lane or clip, redone on each call; off: true takes it away. Returns dips, the number of dips. Transcribe the voice first for word-tight dips (slates_transcribe_asset, free). Free. Requires audio-suite; update Slates on capability refusal.",
6249
+ input: z.object({
6250
+ projectId: z.string().uuid(),
6251
+ trackId: z.string().min(1).optional().describe('The music lane. Or clipId.'),
6252
+ clipId: z.string().uuid().optional().describe('One clip. Or trackId.'),
6253
+ duckDb: z.number().min(-40).max(0).optional().describe('The dip in dB, -40 to 0. Default -12.'),
6254
+ attackSec: z.number().min(0).max(10).optional().describe('How fast it dips. Default 0.15.'),
6255
+ releaseSec: z.number().min(0).max(10).optional().describe('How fast it comes back. Default 0.3.'),
6256
+ holdSec: z.number().min(0).max(10).optional().describe('How long it stays down past a word. Default 0.1.'),
6257
+ bridgeSec: z.number().min(0).max(10).optional().describe('Gaps in speech shorter than this stay ducked. Default 0.6.'),
6258
+ off: z.boolean().optional().describe('True removes the auto duck.'),
6259
+ }).strict(),
6260
+ async run(input, ctx) {
6261
+ if ((input.trackId === undefined) === (input.clipId === undefined))
6262
+ throw new Error('Name trackId (a lane) or clipId (one clip), not both.');
6263
+ await ctx.desktop().requireCapability('audio-suite', 'auto duck');
6264
+ return ok(await ctx.desktop().post('/agent/timeline/auto-duck', input));
6265
+ },
6266
+ };
6267
+ export const matchLoudness = {
6268
+ id: 'slates_match_loudness',
6269
+ billable: false,
6270
+ description: "Bring a mix or one lane to -14 LUFS, the level social platforms play at, as the Output level popover's Match does: the sound is measured as the export writes it, then one gain is set on the master (or on the lane, with trackId) to land on -14 LUFS integrated under a -1 dBTP true peak (held lower when the peak would pass it). Redone on each call. Returns the target, what was measured, the gain set and the effects. Measure without changing anything with slates_get_timeline_loudness. Free. Requires audio-suite; update Slates on capability refusal.",
6271
+ input: z.object({
6272
+ projectId: z.string().uuid(),
6273
+ timelineId: z.string().uuid().optional().describe("The cut; absent: the project's default timeline."),
6274
+ trackId: z.string().min(1).optional().describe('Match this lane alone; absent: the whole mix, on the master.'),
6275
+ }).strict(),
6276
+ async run(input, ctx) {
6277
+ const desktop = ctx.desktop();
6278
+ await desktop.requireCapability('audio-suite', 'loudness match');
6279
+ await requireNamedCut(desktop, input.timelineId);
6280
+ return ok(await desktop.post('/agent/timeline/match-loudness', input));
6281
+ },
6282
+ };
6283
+ export const upscaleImage = {
6284
+ id: 'slates_upscale_image',
6285
+ billable: true,
6286
+ description: "Make a sharper copy of a picture at 2x or 4x its size, as the picture viewer's Upscale does: faithful (no new content), saved as a new picture beside the original, which is untouched. Priced by the picture's size; a picture that would pass 144 megapixels at 4x is refused (try 2x). " +
6287
+ CONFIRM_GATE_SENTENCE +
6288
+ ' Supply a new UUID requestId once per intended upscale and reuse it for a retry: the same id never pays twice (a retry waits for the same run, or returns its picture). Returns the new picture (id, code, file, size) and cost_credits spent. Requires image-upscale; update Slates on capability refusal.',
6289
+ input: z.object({
6290
+ projectId: z.string().uuid(),
6291
+ assetId: z.string().min(1).describe('The picture: its code (IMG-A4) or id.'),
6292
+ factor: z.union([z.literal(2), z.literal(4)]).describe('2 or 4 times the size.'),
6293
+ confirm: z.boolean().optional().describe(CONFIRM_PARAM),
6294
+ requestId: z.string().uuid().optional().describe('A new UUID per intended upscale; the same one on a retry. Absent: one is made for this call.'),
6295
+ }).strict(),
6296
+ async run(input, ctx) {
6297
+ const desktop = ctx.desktop();
6298
+ await desktop.requireCapability('image-upscale', 'picture upscale');
6299
+ const id = (await resolveAssetRefs(ctx, input.projectId, [input.assetId])).get(input.assetId).id;
6300
+ const quote = await desktop.get('/agent/generation/upscale-quote', { projectId: input.projectId, assetId: id, factor: String(input.factor) });
6301
+ if (quote.credits === null)
6302
+ throw new Error(quote.refused ?? 'This picture cannot be upscaled at that size.');
6303
+ const name = quote.code ?? id;
6304
+ const size = `${quote.width}x${quote.height} to ${quote.outWidth}x${quote.outHeight}`;
6305
+ if (quote.credits > CONFIRM_CREDITS && !input.confirm) {
6306
+ return ok({
6307
+ requires_confirm: true, estimated_credits: quote.credits, estimated_cents: quote.credits, factor: quote.factor,
6308
+ width: quote.width, height: quote.height, outWidth: quote.outWidth, outHeight: quote.outHeight,
6309
+ message: `Cost: ${fmtCredits(quote.credits)} to upscale ${name} ${quote.factor}x (${size}). Re-call with confirm=true after the user explicitly OKs the spend.`,
6310
+ });
6311
+ }
6312
+ const requestId = input.requestId ?? randomUUID();
6313
+ const r = await desktop.post('/agent/generation/upscale-image', { projectId: input.projectId, assetId: id, factor: input.factor, expectedCredits: quote.credits, requestId });
6314
+ if (!r.asset)
6315
+ return ok({ ...r, requestId }, `The upscale of ${name} under this requestId is still running; check slates_get_generation_status with ${r.generationId ?? requestId}. Do not start it again with a new requestId.`);
6316
+ const spent = r.cost_credits ?? r.credits ?? quote.credits;
6317
+ return ok({ ...r, cost_credits: spent, requestId }, `Upscaled ${name} ${quote.factor}x (${size}) into ${r.asset.code ?? r.asset.id} for ${fmtCredits(spent)}.`);
6318
+ },
6319
+ };
6320
+ export const getReviewPacket = {
6321
+ id: 'slates_get_review_packet',
6322
+ description: "Read the notes the person sent from Review mode (the Viewer's Review button): each note with its number, its words or a wordless mark (mark: true, no words: 'this is off'), what it points at (a picture region, a clip span, a transition, a transcript join) with a still, its thread, and the ratings changed since (stars, favourite, rejected, redo, more like this). By default the oldest packet the person sent and nobody has read; include: open reads notes and ratings not yet sent; include: all reads every note and rating in the project, with the packets they were sent in, and claims nothing. Reading a sent packet claims it, so the person sees it was picked up (claim: false only peeks). Answer each note with slates_resolve_review_note. null with a reason when nothing waits. Free. Requires review-mode; update Slates on capability refusal.",
6323
+ input: z.object({
6324
+ projectId: z.string().uuid(),
6325
+ packetId: z.string().min(1).optional().describe('One packet by id; absent: the oldest unread.'),
6326
+ include: z.enum(['sent', 'open', 'all']).optional().describe('sent (default): a packet the person sent. open: unsent notes and ratings. all: every note and rating, with its packets; never claims.'),
6327
+ claim: z.boolean().optional().describe('False reads without claiming. Default true for a sent packet.'),
6328
+ }).strict(),
6329
+ async run(input, ctx) {
6330
+ await ctx.desktop().requireCapability('review-mode', 'Review mode');
6331
+ return ok(await ctx.desktop().get('/agent/review/packet', {
6332
+ projectId: input.projectId,
6333
+ ...(input.packetId ? { packetId: input.packetId } : {}),
6334
+ ...(input.include ? { include: input.include } : {}),
6335
+ ...(input.claim !== undefined ? { claim: String(input.claim) } : {}),
6336
+ }));
6337
+ },
6338
+ };
6339
+ export const resolveReviewNote = {
6340
+ id: 'slates_resolve_review_note',
6341
+ description: "Answer the person's review notes, on the note where it was pinned, as the Notes view shows it. One reply per note: fixed (done; text optional), question (ask what they meant), why_not (why it stays as is), alternates (two or three takes to choose from, assetIds), note (anything else). A wordless mark (mark: true with no words) is answered with alternates, two or three versions, never one guess, unless the person has since written in its thread. Only a sent note can be answered (not one still being written, nor one already answered or done); alternates are two or three different pictures or clips; every take is in this project. Returns each note's new state and how many in its packet still wait. Free. Requires review-mode; update Slates on capability refusal.",
6342
+ input: z.object({
6343
+ projectId: z.string().uuid(),
6344
+ replies: z.array(z.object({
6345
+ noteId: z.string().min(1),
6346
+ kind: z.enum(['fixed', 'question', 'why_not', 'alternates', 'note']),
6347
+ text: z.string().max(4000).optional().describe('The answer. Needed for question, why_not and note.'),
6348
+ assetIds: z.array(z.string().min(1)).max(3).optional().describe('alternates: two or three takes, codes or ids. fixed: the take that fixes it.'),
6349
+ }).strict()).min(1),
6350
+ }).strict(),
6351
+ async run(input, ctx) {
6352
+ await ctx.desktop().requireCapability('review-mode', 'Review mode');
6353
+ const refs = [...new Set(input.replies.flatMap((r) => r.assetIds ?? []))];
6354
+ const resolved = refs.length ? await resolveAssetRefs(ctx, input.projectId, refs) : new Map();
6355
+ const replies = input.replies.map((r) => (r.assetIds ? { ...r, assetIds: r.assetIds.map((a) => resolved.get(a).id) } : r));
6356
+ return ok(await ctx.desktop().post('/agent/review/resolve', { projectId: input.projectId, replies }));
6357
+ },
6358
+ };
6075
6359
  export const listTimelines = {
6076
6360
  id: 'slates_list_timelines', description: "List the independent named cuts in a project (not a slot's alternative timelines: slates_get_variants names those). Use the selected timelineId for edits, builds and exports.",
6077
6361
  input: z.object({ projectId: z.string().uuid() }),
@@ -6088,6 +6372,7 @@ export const saveTimeline = {
6088
6372
  if (input.delivery !== undefined || input.taxonomy !== undefined || input.gridBinding !== undefined) {
6089
6373
  await ctx.desktop().requireCapability('ad-variant-export', 'cut delivery, naming and grid bindings');
6090
6374
  }
6375
+ await requireDeliveryEncoding(ctx.desktop(), input.delivery);
6091
6376
  return ok(await ctx.desktop().post('/agent/timelines', input));
6092
6377
  },
6093
6378
  };
@@ -6412,7 +6697,7 @@ const audioEffectList = z
6412
6697
  .array(z
6413
6698
  .object({
6414
6699
  id: z.string().max(64).optional().describe('Kept when sent back; a new effect gets one.'),
6415
- type: z.enum(['volume', 'eq']).describe("volume: gain in dB (param gainDb, -60 silent to +12). eq: ten bands in this order: a high-pass, a low shelf, six bells, a high shelf, a low-pass; send the ones it plays as bands. An older eq's 'lowpass.frequency' and 'lowpass.q' read as the low-pass at 12 dB."),
6700
+ type: z.enum(['volume', 'eq', 'denoise', 'voice_enhance']).describe("volume: gain in dB (param gainDb, -60 silent to +12). eq: ten bands in this order: a high-pass, a low shelf, six bells, a high shelf, a low-pass; send the ones it plays as bands. An older eq's 'lowpass.frequency' and 'lowpass.q' read as the low-pass at 12 dB. denoise: pushes the noise between words down (amount 0 to 1, floorDb -48 to -12). voice_enhance: a broadcast voice chain, EQ and levelling (amount 0 to 1)."),
6416
6701
  bypass: z.boolean().optional(),
6417
6702
  params: z.record(z.number()).optional().describe("Fixed values by parameter name ('gainDb'; an eq's '<band>.<name>', as 'bell3.gain' or 'highpass.slope')."),
6418
6703
  keyframes: z.record(keyframeKeys.max(4000)).optional().describe('Keys by parameter name; a keyed parameter reads its keys instead of its fixed value.'),
@@ -6420,6 +6705,8 @@ const audioEffectList = z
6420
6705
  })
6421
6706
  .strict())
6422
6707
  .max(16);
6708
+ /** True when an effect list holds a voice cleaner (denoise, voice_enhance), which an older desktop refuses. */
6709
+ const usesVoiceCleaners = (effects) => (effects ?? []).some((e) => e.type === 'denoise' || e.type === 'voice_enhance');
6423
6710
  /** True when an effect list uses the ten-band EQ: a band list, or a parameter an older desktop does not know. */
6424
6711
  function usesEqBands(effects) {
6425
6712
  const legacy = new Set(['lowpass.frequency', 'lowpass.q']);
@@ -6430,6 +6717,8 @@ function usesEqBands(effects) {
6430
6717
  async function requireEqBands(desktop, effects) {
6431
6718
  if (usesEqBands(effects))
6432
6719
  await desktop.requireCapability('eq-bands', 'the ten-band EQ');
6720
+ if (usesVoiceCleaners(effects))
6721
+ await desktop.requireCapability('audio-suite', 'denoise and voice enhance');
6433
6722
  }
6434
6723
  /** A clip's panel (slate's `src/shared/clipPanel.ts`): lengths in fractions of the frame's height. */
6435
6724
  const clipPanel = z.object({
@@ -6447,9 +6736,53 @@ const clipPanel = z.object({
6447
6736
  color: z.string().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/).optional().describe('#rrggbb; default white.'),
6448
6737
  }).strict().optional().describe('Present is on: {} is the default border.'),
6449
6738
  }).strict();
6739
+ /** A clip's look (slate's `src/shared/clipLook.ts`): blend, grain, colour, exposure, the grade and a LUT. */
6740
+ const GRADE_DESCRIBE = '-1 to 1; 0 is as shot.';
6741
+ const clipLookInput = z.object({
6742
+ blend: z.enum(['normal', 'multiply', 'screen', 'overlay', 'soft-light']).optional(),
6743
+ grain: z.number().min(0).max(1).optional(),
6744
+ saturation: z.number().min(0).max(2).optional(),
6745
+ exposure: z.number().min(-4).max(4).optional().describe('Stops of light: 1 is twice as bright, -1 half.'),
6746
+ contrast: z.number().min(-1).max(1).optional().describe(`Flat (-1) to punchy (1). ${GRADE_DESCRIBE}`),
6747
+ temperature: z.number().min(-1).max(1).optional().describe(`Cool blue (-1) to warm amber (1). ${GRADE_DESCRIBE}`),
6748
+ tint: z.number().min(-1).max(1).optional().describe(`Green (-1) to magenta (1). ${GRADE_DESCRIBE}`),
6749
+ highlights: z.number().min(-1).max(1).optional().describe(`Pulls the bright parts down (-1) or lifts them (1). ${GRADE_DESCRIBE}`),
6750
+ shadows: z.number().min(-1).max(1).optional().describe(`Crushes the dark parts (-1) or opens them (1). ${GRADE_DESCRIBE}`),
6751
+ lutPath: localFile('lutPath', ['cube']).optional().describe('A 3D LUT (.cube) laid on after the grade, by its absolute path; the app copies it into the project.'),
6752
+ lutIntensity: z.number().min(0).max(1).optional().describe('How much of the LUT shows, 0 to 1 (default 1).'),
6753
+ }).strict();
6754
+ const GRADE_FIELDS = ['contrast', 'temperature', 'tint', 'highlights', 'shadows', 'lutPath', 'lutIntensity'];
6755
+ /** A clip's matte (slate's `src/shared/clipMatte.ts`): a subject mask, a shape, or a colour key. One kind at a time. */
6756
+ const clipMatteInput = z.union([
6757
+ z.object({
6758
+ maskId: z.string().regex(/^[A-Za-z0-9_-]{1,80}$/).describe("One of the clip's own media's subject masks."),
6759
+ mode: z.enum(['subject', 'background']).optional().describe('subject (default) draws only the subject; background everything but it.'),
6760
+ feather: z.number().min(0).max(1).optional().describe('How soft the edge is: 0 as made, 1 softened over about 3% of the picture height. Default 0.'),
6761
+ }).strict(),
6762
+ z.object({
6763
+ shape: z.object({
6764
+ kind: z.enum(['rect', 'ellipse']),
6765
+ x: z.number().min(0).max(1).describe('Centre, 0 left to 1 right.'),
6766
+ y: z.number().min(0).max(1).describe('Centre, 0 top to 1 bottom.'),
6767
+ w: z.number().min(0.01).max(2).describe("Width as a fraction of the picture's."),
6768
+ h: z.number().min(0.01).max(2).describe("Height as a fraction of the picture's."),
6769
+ rotation: z.number().min(-180).max(180).optional().describe('Degrees clockwise.'),
6770
+ feather: z.number().min(0).max(1).optional().describe('0 crisp to 1 soft.'),
6771
+ invert: z.boolean().optional().describe('Draw what is outside the shape instead.'),
6772
+ }).strict(),
6773
+ }).strict(),
6774
+ z.object({
6775
+ chroma: z.object({
6776
+ color: z.string().regex(/^#[0-9a-fA-F]{6}$/).describe("The screen's colour, #rrggbb (#00ff00 green, #0000ff blue)."),
6777
+ tolerance: z.number().min(0).max(1).describe('How far from the colour still keys out; 0.35 is a good start.'),
6778
+ softness: z.number().min(0).max(1).describe('Width of the soft edge; 0.2 is a good start.'),
6779
+ spill: z.number().min(0).max(1).optional().describe("How much of the screen's colour is pulled off the subject."),
6780
+ }).strict(),
6781
+ }).strict(),
6782
+ ]);
6450
6783
  export const updateClip = {
6451
6784
  id: 'slates_update_clip',
6452
- description: "Set a timeline clip's own speed, volume, split edit (J-cut or L-cut) and fades, as the Cut's Inspector does. Only the fields you name change; null puts one back to the default. speed keeps the clip's media in and out points and its start and changes its length (2 is twice as fast, half as long); with ripple: true the lane's later clips move by the change, otherwise a longer clip covers what follows. audioOffsetFrames, on a video clip, moves its own sound against its picture in sync: below 0 is a J-cut (the sound starts first), above 0 an L-cut (it runs on). Fades are frames: fadeIn/fadeOut for the picture, audioFadeIn/audioFadeOut for the sound. volume is linear gain (1 = 0 dB, 0 = silent). look, on a clip with a picture, is the Inspector's Blend, Grain, Colour and Exposure, sent whole: blend mixes the picture with what is under it (multiply darkens, screen lightens, overlay and soft-light add contrast), grain is film grain from 0 to 1, saturation is colour from 0 (black and white) through 1 (as shot) to 2, exposure is stops of light from -4 to 4 (1 twice as bright); null clears the look. matte draws a video clip through one of its subject masks (slates_get_subject_mask lists them): mode subject draws only the subject, background everything but it, feather softens the edge from 0 to 1; lay a matted copy over the clip and put a title on a lane between them (slates_update_timeline_track above or below) to put the title behind the subject. space turns any picture clip in 3D about its centre: pitch leans the top away (degrees, -85 to 85), yaw turns the right edge away (-85 to 85), perspective 0 flat to 1 very wide (0.5 a normal lens). panel makes it a floating panel: radius rounds the corners, shadow puts a soft shadow under it, border a line just inside its edge; lengths are fractions of the frame's height (0.02 is about 22 px at 1080p). blur is a lens blur, amount 0 sharp to 1 (a point spreads over 5% of the frame's height), with a maskId to blur only around the subject and keep it sharp. Each of matte, space, panel and blur is sent whole and null clears it; their amounts can be keyed with slates_set_clip_keyframes. effects is the clip's sound effects, sent whole, in order: a volume (gain in dB) and an eq (up to ten bands: high- and low-pass cuts at 6 to 48 dB per octave, shelves, bells, a notch, a band-pass), each value fixed or keyed in frames from the clip's start, the same in preview and export. speedRamp keys the speed over the clip (a slow-motion ramp): media in and out stay, the length becomes what the keys take, and the sound follows tape-style; not with speed. speedSound 'tape' makes a constant speed's sound change pitch with it. On an audio lane, startSec, sourceInSec and sourceOutSec (or sourceInSample and sourceOutSample) set where its sound starts and its media in and out to the sample, for a music edit between frames; a longer clip covers what follows unless ripple; not with speed in the same call.",
6785
+ description: "Set a timeline clip's own speed, volume, split edit (J-cut or L-cut) and fades, as the Cut's Inspector does. Only the fields you name change; null puts one back to the default. speed keeps the clip's media in and out points and its start and changes its length (2 is twice as fast, half as long); with ripple: true the lane's later clips move by the change, otherwise a longer clip covers what follows. audioOffsetFrames, on a video clip, moves its own sound against its picture in sync: below 0 is a J-cut (the sound starts first), above 0 an L-cut (it runs on). Fades are frames: fadeIn/fadeOut for the picture, audioFadeIn/audioFadeOut for the sound. volume is linear gain (1 = 0 dB, 0 = silent). look, on a clip with a picture, is the Inspector's Blend, Grain, Colour and Exposure, sent whole: blend mixes the picture with what is under it (multiply darkens, screen lightens, overlay and soft-light add contrast), grain is film grain from 0 to 1, saturation is colour from 0 (black and white) through 1 (as shot) to 2, exposure is stops of light from -4 to 4 (1 twice as bright); null clears the look. matte draws a video clip through one of its subject masks (slates_get_subject_mask lists them): mode subject draws only the subject, background everything but it, feather softens the edge from 0 to 1; lay a matted copy over the clip and put a title on a lane between them (slates_update_timeline_track above or below) to put the title behind the subject. space turns any picture clip in 3D about its centre: pitch leans the top away (degrees, -85 to 85), yaw turns the right edge away (-85 to 85), perspective 0 flat to 1 very wide (0.5 a normal lens). panel makes it a floating panel: radius rounds the corners, shadow puts a soft shadow under it, border a line just inside its edge; lengths are fractions of the frame's height (0.02 is about 22 px at 1080p). blur is a lens blur, amount 0 sharp to 1 (a point spreads over 5% of the frame's height), with a maskId to blur only around the subject and keep it sharp. look also takes a grade and a .cube LUT, matte a shape mask or a colour key, and reversed plays it backward (each field says how). Each of matte, space, panel and blur is sent whole and null clears it; their amounts can be keyed with slates_set_clip_keyframes. effects is the clip's sound effects, sent whole, in order: a volume (gain in dB) and an eq (up to ten bands: high- and low-pass cuts at 6 to 48 dB per octave, shelves, bells, a notch, a band-pass), each value fixed or keyed in frames from the clip's start, the same in preview and export. speedRamp keys the speed over the clip (a slow-motion ramp): media in and out stay, the length becomes what the keys take, and the sound follows tape-style; not with speed. speedSound 'tape' makes a constant speed's sound change pitch with it. On an audio lane, startSec, sourceInSec and sourceOutSec (or sourceInSample and sourceOutSample) set where its sound starts and its media in and out to the sample, for a music edit between frames; a longer clip covers what follows unless ripple; not with speed in the same call.",
6453
6786
  input: z.object({
6454
6787
  projectId: z.string().uuid(),
6455
6788
  clipId: z.string().uuid(),
@@ -6460,17 +6793,9 @@ export const updateClip = {
6460
6793
  fadeOutFrames: z.number().int().min(0).nullable().optional(),
6461
6794
  audioFadeInFrames: z.number().int().min(0).nullable().optional(),
6462
6795
  audioFadeOutFrames: z.number().int().min(0).nullable().optional(),
6463
- look: z.object({
6464
- blend: z.enum(['normal', 'multiply', 'screen', 'overlay', 'soft-light']).optional(),
6465
- grain: z.number().min(0).max(1).optional(),
6466
- saturation: z.number().min(0).max(2).optional(),
6467
- exposure: z.number().min(-4).max(4).optional().describe('Stops of light: 1 is twice as bright, -1 half.'),
6468
- }).strict().nullable().optional().describe('The whole look, at least one field; a field left out is its default (normal, no grain, colour 1, exposure 0). null clears it.'),
6469
- matte: z.object({
6470
- maskId: z.string().regex(/^[A-Za-z0-9_-]{1,80}$/).describe("One of the clip's own media's subject masks."),
6471
- mode: z.enum(['subject', 'background']).optional().describe('subject (default) draws only the subject; background everything but it.'),
6472
- feather: z.number().min(0).max(1).optional().describe('How soft the edge is: 0 as made, 1 softened over about 3% of the picture height. Default 0.'),
6473
- }).strict().nullable().optional().describe('A video clip drawn through a subject mask; null draws the whole picture.'),
6796
+ look: clipLookInput.nullable().optional().describe('The whole look, at least one field; a field left out is its default (normal, no grain, colour 1, exposure 0, no grade, no LUT). null clears it.'),
6797
+ matte: clipMatteInput.nullable().optional().describe('A subject mask ({ maskId }), a shape ({ shape }) or a colour key ({ chroma }); null draws the whole picture.'),
6798
+ reversed: z.boolean().nullable().optional().describe("true plays the clip's media backward (its linked sound too); false or null forward."),
6474
6799
  space: z.object({
6475
6800
  pitch: z.number().min(-85).max(85).optional().describe('Degrees; positive leans the top away.'),
6476
6801
  yaw: z.number().min(-85).max(85).optional().describe('Degrees; positive turns the right edge away.'),
@@ -6499,7 +6824,11 @@ export const updateClip = {
6499
6824
  }
6500
6825
  // An empty look would clear the clip's look without saying so; null is how to ask for that.
6501
6826
  if (input.look && Object.keys(input.look).length === 0)
6502
- throw new Error('look needs at least one of blend, grain, saturation or exposure; send look: null to clear it');
6827
+ throw new Error('look needs at least one field (blend, grain, saturation, exposure, a grade value or a LUT); send look: null to clear it');
6828
+ const matteKind = input.matte && ('shape' in input.matte || 'chroma' in input.matte);
6829
+ if (GRADE_FIELDS.some((f) => input.look?.[f] !== undefined) || matteKind || input.reversed !== undefined) {
6830
+ await desktop.requireCapability('clip-grade', 'the grade, LUTs, colour keys, shape masks and reverse');
6831
+ }
6503
6832
  if (input.look !== undefined)
6504
6833
  await desktop.requireCapability('clip-look', "a clip's blend, grain and colour");
6505
6834
  if (input.look?.exposure !== undefined || input.matte !== undefined || input.space !== undefined || input.panel !== undefined || input.blur !== undefined) {
@@ -6563,7 +6892,9 @@ export const addTimelineTrack = {
6563
6892
  // and the batch cap slate's `src/main/agent/routes-editor.ts`, which this package cannot import;
6564
6893
  // lockstep check 12 fails when they differ. The 0..1 position and
6565
6894
  // opacity are fractions by definition, not a desktop choice.
6566
- const TEXT_STYLE_IDS = ['word-pop', 'keyword', 'subtitle', 'headline', 'clean', 'plain'];
6895
+ // A desktop before the caption presets refuses one of the last six by name, so they need no gate.
6896
+ const TEXT_STYLE_IDS = ['word-pop', 'keyword', 'subtitle', 'headline', 'clean', 'plain',
6897
+ 'active-pill', 'reel-bold', 'impact-hook', 'lower-third', 'minimal-caption', 'kinetic-pop'];
6567
6898
  // A text clip set exactly (slate 1.6.x, capability text-fonts): the fonts Slates carries, the exact size,
6568
6899
  // the picture before the words and a line of clips, mirrored from slate's `src/shared/textStyles.ts` and
6569
6900
  // `src/shared/overlays.ts` like the rest (lockstep check 12).
@@ -7034,6 +7365,7 @@ export const updateTimelineSettings = {
7034
7365
  if (input.delivery !== undefined || input.taxonomy !== undefined || input.gridBinding !== undefined) {
7035
7366
  await desktop.requireCapability('ad-variant-export', 'cut delivery, naming and grid bindings');
7036
7367
  }
7368
+ await requireDeliveryEncoding(desktop, input.delivery);
7037
7369
  if (input.timelineId && input.delivery !== undefined && Object.keys(input).every(key => ['projectId', 'timelineId', 'delivery'].includes(key))) {
7038
7370
  return ok(await desktop.post('/agent/timeline/delivery', input));
7039
7371
  }
@@ -7044,16 +7376,17 @@ export const updateTimelineSettings = {
7044
7376
  export const exportVideo = {
7045
7377
  id: 'slates_export_video',
7046
7378
  billable: false,
7047
- description: "Render the project's timeline to an MP4 file on disk through the desktop app's timeline engine, the renderer its monitor shows, so the file matches the preview (H.264 + AAC, every video lane composited with its transitions, fades and keyframes, gaps rendered as black; the Slates window must be open, and the export opens the timeline's project there first, answering openedProject: true when it did). No dialogs — pass an absolute outputPath ending in .mp4. Fails if the file exists unless overwrite=true. Blocks until encoding finishes (can take minutes for long timelines) and returns the real file size and probed duration. After success, consider slates_reveal_file to show the file to the user. Requires at least one video clip on the timeline. The sound is AAC at the timeline's Sound bitrate (slates_update_timeline_settings audioBitrate; default 320 kb/s) unless audioBitrate names one for this file. Pass exactly one of projectId (the project's default timeline) or timelineId (a named cut).",
7379
+ description: "Render the project's timeline to a video file on disk through the desktop app's timeline engine, the renderer its monitor shows, so the file matches the preview (H.264 + AAC by default, every video lane composited with its transitions, fades and keyframes, gaps rendered as black; the Slates window must be open, and the export opens the timeline's project there first, answering openedProject: true when it did). No dialogs — pass an absolute outputPath ending in .mp4 (.mov for codec prores). presetId exports for a platform (tiktok, reels, meta-feed, stories, shorts, youtube: its bitrate, frame-rate ceiling and sound); codec, videoBitrateMbps and fps override it, or the cut's own encoding, for this file. Fails if the file exists unless overwrite=true. Blocks until encoding finishes (can take minutes for long timelines) and returns the real file size and probed duration. After success, consider slates_reveal_file to show the file to the user. Requires at least one video clip on the timeline. The sound is AAC at the timeline's Sound bitrate (slates_update_timeline_settings audioBitrate; default 320 kb/s) unless audioBitrate names one for this file. Pass exactly one of projectId (the project's default timeline) or timelineId (a named cut).",
7048
7380
  input: z
7049
7381
  .object({
7050
7382
  projectId: z.string().uuid().optional(),
7051
7383
  timelineId: z.string().uuid().optional(),
7052
- outputPath: localFile('outputPath', ['mp4'])
7053
- .describe('Absolute path for the rendered file, ending in .mp4 (e.g. C:\\Users\\you\\Videos\\ad.mp4 or /Users/you/ad.mp4). slates_get_project_directory gives a sensible default folder.'),
7384
+ outputPath: localFile('outputPath', ['mp4', 'mov'])
7385
+ .describe('Absolute path for the rendered file, ending in .mp4, or .mov for prores (e.g. C:\\Users\\you\\Videos\\ad.mp4 or /Users/you/ad.mp4). slates_get_project_directory gives a sensible default folder.'),
7054
7386
  overwrite: z.boolean().optional(),
7055
7387
  aspect: deliveryAspectInput.optional().describe('Optional delivery aspect from slates_get_variant_grid; requires ad-variant-export. Omission keeps existing export behavior.'),
7056
7388
  audioBitrate: audioBitrateInput.optional().describe(`This file's AAC sound in kb/s (${AUDIO_BITRATES.join(', ')}); omit for the timeline's Sound bitrate.`),
7389
+ ...exportEncodingShape,
7057
7390
  })
7058
7391
  .refine((d) => !!d.projectId !== !!d.timelineId, {
7059
7392
  message: 'Pass exactly one of projectId or timelineId',
@@ -7061,6 +7394,12 @@ export const exportVideo = {
7061
7394
  async run(input, ctx) {
7062
7395
  const desktop = ctx.desktop();
7063
7396
  await desktop.requireCapability('export', 'video export');
7397
+ if (input.presetId !== undefined || input.codec !== undefined || input.videoBitrateMbps !== undefined || input.fps !== undefined) {
7398
+ await desktop.requireCapability('export-encoding', 'platform presets and export encoding');
7399
+ }
7400
+ if (input.codec !== undefined && (input.codec === 'prores') !== /\.mov$/i.test(input.outputPath)) {
7401
+ throw new Error('A prores export writes a .mov file and every other codec an .mp4: change outputPath to match.');
7402
+ }
7064
7403
  if (input.aspect !== undefined)
7065
7404
  await desktop.requireCapability('ad-variant-export', 'single video delivery export');
7066
7405
  if (input.audioBitrate !== undefined)
@@ -7072,9 +7411,13 @@ export const exportVideo = {
7072
7411
  overwrite: input.overwrite,
7073
7412
  aspect: input.aspect,
7074
7413
  audioBitrate: input.audioBitrate,
7414
+ presetId: input.presetId,
7415
+ codec: input.codec,
7416
+ videoBitrateMbps: input.videoBitrateMbps,
7417
+ fps: input.fps,
7075
7418
  });
7076
7419
  const mb = r.fileSizeBytes != null ? (r.fileSizeBytes / (1024 * 1024)).toFixed(1) : '?';
7077
- return ok(r, `Exported ${r.durationSec ?? '?'}s MP4 (${mb} MB) to ${r.outputPath ?? input.outputPath}.`);
7420
+ return ok(r, `Exported ${r.durationSec ?? '?'}s ${/\.mov$/i.test(input.outputPath) ? 'MOV' : 'MP4'} (${mb} MB) to ${r.outputPath ?? input.outputPath}.`);
7078
7421
  },
7079
7422
  };
7080
7423
  export const exportTimelineXml = {
@@ -7896,6 +8239,7 @@ function shotParamsShape(described) {
7896
8239
  imageQuantity: d(z.number().int().min(1).max(10).optional(), 'Image models only.'),
7897
8240
  negativePrompt: z.string().optional(),
7898
8241
  sound: d(z.boolean().optional(), 'Video models that co-generate audio.'),
8242
+ seedanceDraft: d(z.boolean().optional(), 'Make a finishable Seedance 2.5 preview at 480p.'),
7899
8243
  seedanceFace: d(z.boolean().optional(), "Seedance only — a reference shows an AI character's face; without it faces are blocked. The estimate prices it."),
7900
8244
  audioDurationSeconds: d(z.number().int().min(1).max(120).optional(), 'Audio lane. On seed-audio the requested duration IS the bill.'),
7901
8245
  // The TTS voice — the same three fields slates_generate_audio takes, so a
@@ -8004,6 +8348,8 @@ function shotParamsPatch(p) {
8004
8348
  for (const [k, v] of Object.entries(p))
8005
8349
  if (v !== undefined)
8006
8350
  out[k] = v;
8351
+ if (p.seedanceDraft && p.videoResolution === undefined)
8352
+ out.videoResolution = '480p';
8007
8353
  return out;
8008
8354
  }
8009
8355
  /**
@@ -8166,6 +8512,8 @@ function namedSpecPatch(input, spec) {
8166
8512
  * model, which is worse than the gap.
8167
8513
  */
8168
8514
  function assertShotCapabilities(model, params) {
8515
+ if (params?.seedanceDraft && model)
8516
+ draftResolution(model, params.videoResolution);
8169
8517
  if (!model || !VIDEO_MODELS.includes(model))
8170
8518
  return null;
8171
8519
  const err = assertVideoCapabilities({
@@ -8176,6 +8524,16 @@ function assertShotCapabilities(model, params) {
8176
8524
  });
8177
8525
  return err ? ok(err) : null;
8178
8526
  }
8527
+ async function requireDraftShotDesktop(desktop, model, params, shotId) {
8528
+ if (params?.seedanceDraft) {
8529
+ await desktop.requireCapability('seedance-drafts', 'saving a Seedance 2.5 draft');
8530
+ }
8531
+ else if (params?.videoResolution === '4k') {
8532
+ const target = model ?? (shotId ? (await desktop.get('/agent/shots/get', { id: shotId })).shot.model : undefined);
8533
+ if (target === 'seedance-2.5')
8534
+ await desktop.requireCapability('seedance-drafts', 'saving a native 4K Seedance Shot');
8535
+ }
8536
+ }
8179
8537
  /** Fetch a dynamic cloud cost key for the standalone generation estimate. */
8180
8538
  async function loadDynamicPrice(ctx, byKey, key) {
8181
8539
  if (!key || byKey.has(key))
@@ -8219,6 +8577,7 @@ export const createShot = {
8219
8577
  return alignErr;
8220
8578
  const desktop = ctx.desktop();
8221
8579
  await desktop.requireCapability('shots', 'saved Shots');
8580
+ await requireDraftShotDesktop(desktop, input.model, input.params);
8222
8581
  // 1.6.0 ignores fromAssetId, and would then refuse the missing prompt.
8223
8582
  if (input.fromAssetId)
8224
8583
  await desktop.requireCapability('shot-from-asset', 'saving a result as a Shot');
@@ -8321,6 +8680,7 @@ export const updateShot = {
8321
8680
  return alignErr;
8322
8681
  const desktop = ctx.desktop();
8323
8682
  await desktop.requireCapability('shots', 'saved Shots');
8683
+ await requireDraftShotDesktop(desktop, input.model, input.params, input.shotId);
8324
8684
  const { spec, seatNote } = await buildShotSpecInput(ctx, input.projectId, input);
8325
8685
  // Only send the halves the caller actually named; the route merges a PARTIAL
8326
8686
  // spec over the stored one, so an omitted field is never silently cleared.
@@ -8358,6 +8718,7 @@ export const duplicateShot = {
8358
8718
  return capErr;
8359
8719
  const desktop = ctx.desktop();
8360
8720
  await desktop.requireCapability('shots', 'saved Shots');
8721
+ await requireDraftShotDesktop(desktop, input.model, input.params, input.shotId);
8361
8722
  // Only the halves actually named. The route merges two levels deep, so an
8362
8723
  // omitted param on the copy keeps the original's value rather than clearing it.
8363
8724
  const spec = {};
@@ -8954,6 +9315,12 @@ export const generateFromShots = {
8954
9315
  await desktop.requireCapability('board-quote', 'Shot prices');
8955
9316
  // Resolved first so a SHOT-A code fails here, not halfway through a billed run.
8956
9317
  const details = await Promise.all(input.shotIds.map((id) => desktop.get('/agent/shots/get', { id })));
9318
+ // Older desktops drop the draft flag when reading a saved recipe. Its persisted 480p
9319
+ // resolution survives, so require a capable desktop before firing an ambiguous video Shot.
9320
+ if (!input.draft && details.some(({ shot }) => shot.model === 'seedance-2.5' &&
9321
+ (shot.params?.seedanceDraft || ['480p', '4k'].includes(String(shot.params?.videoResolution))))) {
9322
+ await desktop.requireCapability('seedance-drafts', 'generating saved Seedance 2.5 preview or 4K Shots');
9323
+ }
8957
9324
  const { draft, note: seatNote } = await desktopDraft(desktop, input.draft);
8958
9325
  const quote = await desktop.get('/agent/shots/quote', {
8959
9326
  input: JSON.stringify({ projectId: details[0].shot.projectId, shotIds: details.map((d) => d.shot.id), draft }),
@@ -9011,6 +9378,107 @@ export const getBoardProgress = {
9011
9378
  return ok(await ctx.desktop().get('/agent/shots/progress', input));
9012
9379
  },
9013
9380
  };
9381
+ const draftFinishInput = z.object({
9382
+ projectId: z.string().uuid(),
9383
+ assetId: z.string().describe('Draft video asset ID or badge code.'),
9384
+ resolution: z.enum(['1080p', '4k']),
9385
+ });
9386
+ const draftApproval = {
9387
+ confirm: z.literal(true).describe('The user approved this finish at the quoted price.'),
9388
+ maxCredits: z.number().int().nonnegative().describe('Maximum credits the user approved for the finish.'),
9389
+ };
9390
+ const paidDraftFinishInput = draftFinishInput.extend(draftApproval);
9391
+ export const quoteDraftFinish = {
9392
+ id: 'slates_quote_draft_finish',
9393
+ description: 'Quote a draft take at its full source duration and check its expiry or existing final.',
9394
+ input: draftFinishInput,
9395
+ async run(input, ctx) {
9396
+ const desktop = ctx.desktop();
9397
+ await desktop.requireCapability('seedance-drafts', 'finishing draft takes');
9398
+ const refs = await resolveAssetRefs(ctx, input.projectId, [input.assetId]);
9399
+ return ok(await desktop.get('/agent/assets/quote-draft-finish', { ...input, assetId: refs.get(input.assetId).id }));
9400
+ },
9401
+ };
9402
+ export const finishDraft = {
9403
+ id: 'slates_finish_draft',
9404
+ description: 'Finish an approved draft at 1080p or 4K. Quote the full price first. Check a background generation with slates_get_generation_status.',
9405
+ input: paidDraftFinishInput,
9406
+ billable: true,
9407
+ async run(input, ctx) {
9408
+ requireGuideRead(ctx, 'seedance-2.5');
9409
+ const desktop = ctx.desktop();
9410
+ await desktop.requireCapability('seedance-drafts', 'finishing draft takes');
9411
+ const refs = await resolveAssetRefs(ctx, input.projectId, [input.assetId]);
9412
+ const receipt = await desktop.post('/agent/assets/finish-draft', { ...input, assetId: refs.get(input.assetId).id, background: true });
9413
+ if (!ctx.waitForCutFinish || receipt.status === 'completed')
9414
+ return ok(receipt);
9415
+ if (!receipt.generationId)
9416
+ throw new Error('The finish did not return a generation ID.');
9417
+ for (;;) {
9418
+ if (ctx.signal?.aborted)
9419
+ throw new OperationCancelledError('check the submitted finish in Generations');
9420
+ const status = await desktop.get('/agent/generation/status', { id: receipt.generationId });
9421
+ if (status.generation.status === 'completed') {
9422
+ const cost = receipt.cost_credits === 0 ? 0 : status.generation.draftFinishCredits ?? receipt.cost_credits;
9423
+ return ok({ ...receipt, status: 'completed', cost_credits: cost, assetId: status.asset?.id ?? status.generation.assetId });
9424
+ }
9425
+ if (status.generation.status !== 'processing' && status.generation.status !== 'pending') {
9426
+ throw new Error(status.generation.error || 'The draft finish failed.');
9427
+ }
9428
+ await new Promise(resolve => setTimeout(resolve, 2000));
9429
+ }
9430
+ },
9431
+ };
9432
+ const cutDraftInput = z.object({ projectId: z.string().uuid(), timelineId: z.string().uuid() });
9433
+ const quoteCutInput = cutDraftInput.extend({
9434
+ resolutions: z.record(z.enum(['1080p', '4k'])).optional().describe('Target resolution by draft asset UUID. Defaults to 1080p.'),
9435
+ });
9436
+ const cutFinishStatusInput = cutDraftInput.extend({
9437
+ quoteId: z.string().min(1).describe('Identifier returned by slates_quote_cut_drafts.'),
9438
+ });
9439
+ const finishCutInput = cutFinishStatusInput.extend(draftApproval);
9440
+ export const quoteCutDrafts = {
9441
+ id: 'slates_quote_cut_drafts',
9442
+ description: 'Price the distinct draft sources used in a cut. Returns full-source prices, expiry and a quote ID for approval.',
9443
+ input: quoteCutInput,
9444
+ async run(input, ctx) {
9445
+ const desktop = ctx.desktop();
9446
+ await desktop.requireCapability('seedance-drafts', 'finishing drafts in a cut');
9447
+ return ok(await desktop.post('/agent/timeline/cut', { ...input, action: 'quoteDrafts' }));
9448
+ },
9449
+ };
9450
+ export const finishCutDrafts = {
9451
+ id: 'slates_finish_cut_drafts',
9452
+ 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.',
9453
+ input: finishCutInput,
9454
+ billable: true,
9455
+ async run(input, ctx) {
9456
+ requireGuideRead(ctx, 'seedance-2.5');
9457
+ const desktop = ctx.desktop();
9458
+ await desktop.requireCapability('seedance-drafts', 'finishing drafts in a cut');
9459
+ const query = { projectId: input.projectId, timelineId: input.timelineId, quoteId: input.quoteId };
9460
+ let receipt = await desktop.post('/agent/timeline/cut', {
9461
+ ...input, action: 'finishDrafts', background: true,
9462
+ });
9463
+ while (ctx.waitForCutFinish && receipt.status === 'running') {
9464
+ if (ctx.signal?.aborted)
9465
+ throw new OperationCancelledError('check the cut finish status for any source already submitted');
9466
+ await new Promise(resolve => setTimeout(resolve, 2000));
9467
+ receipt = await desktop.get('/agent/timeline/draft-finish', query);
9468
+ }
9469
+ return ok(receipt);
9470
+ },
9471
+ };
9472
+ export const getCutDraftStatus = {
9473
+ id: 'slates_get_cut_draft_status',
9474
+ description: 'Check which sources in an approved cut have been finished, replaced, or kept as drafts.',
9475
+ input: cutFinishStatusInput,
9476
+ async run(input, ctx) {
9477
+ const desktop = ctx.desktop();
9478
+ await desktop.requireCapability('seedance-drafts', 'finishing drafts in a cut');
9479
+ return ok(await desktop.get('/agent/timeline/draft-finish', input));
9480
+ },
9481
+ };
9014
9482
  export const editCut = {
9015
9483
  id: 'slates_edit_cut',
9016
9484
  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.',
@@ -9489,6 +9957,23 @@ export const getPromptingGuide = {
9489
9957
  return { text, data: { ...result, ...(tied.length ? { tied } : {}), memberAccess: member.access, bytes: Buffer.byteLength(text, 'utf8') } };
9490
9958
  },
9491
9959
  };
9960
+ export const rememberInMyBrain = {
9961
+ id: 'slates_remember',
9962
+ 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.',
9963
+ input: z.object({
9964
+ 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.'),
9965
+ 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.'),
9966
+ source: z.string().max(120).optional().describe('What taught it: "said always", "corrected twice", "kept take IMG-A8".'),
9967
+ replaces: z.string().min(3).max(300).optional().describe('Text of the existing line this lesson replaces; alone, the line to remove.'),
9968
+ }),
9969
+ async run(input) {
9970
+ const result = remember(input);
9971
+ const text = result.unchanged ? `Already in your brain (${result.file}): ${result.saved}`
9972
+ : result.saved ? `Saved to your brain (${result.file}): ${result.saved}${result.removed ? ` (replaces: ${result.removed})` : ''}`
9973
+ : `Removed from your brain (${result.file}): ${result.removed}`;
9974
+ return { text, data: { ...result } };
9975
+ },
9976
+ };
9492
9977
  /**
9493
9978
  * Task discovery and exact schemas share one operation. The desktop uses
9494
9979
  * names/group to replace its optional selection; MCP keeps its full list fixed.
@@ -9800,6 +10285,17 @@ export const ALL_OPERATIONS = [
9800
10285
  getRecipe,
9801
10286
  reframeClip,
9802
10287
  getReframeReport,
10288
+ freezeFrame,
10289
+ stabilizeClip,
10290
+ slideClip,
10291
+ punchIn,
10292
+ cleanUpDialogue,
10293
+ autoColourClip,
10294
+ autoDuck,
10295
+ matchLoudness,
10296
+ upscaleImage,
10297
+ getReviewPacket,
10298
+ resolveReviewNote,
9803
10299
  getTimeline,
9804
10300
  getTimelineLoudness,
9805
10301
  addClipToTimeline,
@@ -9903,8 +10399,14 @@ export const ALL_OPERATIONS = [
9903
10399
  generateFromShots,
9904
10400
  quoteBoard,
9905
10401
  getBoardProgress,
10402
+ quoteDraftFinish,
10403
+ finishDraft,
10404
+ quoteCutDrafts,
10405
+ finishCutDrafts,
10406
+ getCutDraftStatus,
9906
10407
  editCut,
9907
10408
  getPromptingGuide,
10409
+ rememberInMyBrain,
9908
10410
  loadTools,
9909
10411
  // ── Blender previs, LAST and deliberately ────────────────────────────
9910
10412
  // These six landed at the TOP once, which put a third transport nobody