@slatesvideo/shared 0.7.16 → 0.7.18

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, 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:
@@ -996,11 +996,16 @@ export const setComposer = {
996
996
  if (Object.keys(input).filter((k) => k !== 'projectId').length === 0) {
997
997
  throw new Error('Name at least one change, e.g. model, prompt, attach or params. To read the box, use slates_get_composer.');
998
998
  }
999
- const r = await ctx.desktop().post('/agent/composer', input);
999
+ // The box takes the model by name, so a seat this desktop lacks is staged as the one it has (`desktopModelId`).
1000
+ // A length given as text ("15", "15s") is the same length: the 10-second check must see it.
1001
+ const asked = input.params?.duration;
1002
+ const duration = typeof asked === 'number' ? asked : typeof asked === 'string' && Number.isFinite(Number.parseFloat(asked)) ? Number.parseFloat(asked) : undefined;
1003
+ const seat = await desktopModelId(ctx.desktop(), input.model, `staging ${input.model}`, duration);
1004
+ const r = await ctx.desktop().post('/agent/composer', { ...input, ...(seat.note ? { model: seat.model } : {}) });
1000
1005
  if (!r.report)
1001
1006
  return { text: `Nothing was staged (${r.reason ?? 'no answer'}).`, data: { report: null } };
1002
1007
  const skipped = r.skipped?.length ? `\nNot applied:\n- ${r.skipped.join('\n- ')}` : '';
1003
- return { text: `${describeComposer(r.report)}${skipped}`, data: { report: r.report, skipped: r.skipped ?? [] } };
1008
+ return { text: `${describeComposer(r.report)}${skipped}${seat.note ? `\n${seat.note}` : ''}`, data: { report: r.report, skipped: r.skipped ?? [] } };
1004
1009
  },
1005
1010
  };
1006
1011
  /**
@@ -1678,9 +1683,10 @@ export const VIDEO_MODELS = [
1678
1683
  // not here; edit models live on slates_edit_video, same as the Kling and Omni
1679
1684
  // Flash ones.
1680
1685
  'seedance-2.5',
1681
- // Gemini Omni Flash, version 1.1 since 2026-10-17: swapped in place, same id,
1682
- // fal's `google/gemini-omni-flash/v1.1/*` endpoints.
1683
- 'omni-flash',
1686
+ // Gemini Omni Flash 1.2 (2026-11-10), fal's `google/gemini-omni-flash/v1.2/*`.
1687
+ // It replaced 1.1 (`omni-flash`, in RETIRED_MODELS) seat for seat; a desktop
1688
+ // without `video-models-v2` gets the 1.1 seat (`desktopModelId`).
1689
+ 'omni-flash-1-2',
1684
1690
  // Wan 3.0 (Alibaba, added 2026-10-17): 2-30s at 480p-1080p, sound on or off,
1685
1691
  // start and end frames OR references (10 images, 5 videos, 5 audio clips).
1686
1692
  // Reference video seconds bill on top of output seconds, so it has a vref key.
@@ -1733,10 +1739,10 @@ const VIDEO_ASPECT_RATIOS = aspectRatioUnion(VIDEO_MODELS, AGENT_ROUTE_PROVIDER)
1733
1739
  const VIDEO_RESOLUTIONS = videoResolutionUnion(VIDEO_MODELS);
1734
1740
  /** Widest legal duration window across every video model. */
1735
1741
  const VIDEO_DURATION_BOUNDS = durationBounds(VIDEO_MODELS);
1736
- /** Omni Flash's combined reference-image cap, read from the SSOT (10 on 1.1). */
1737
- const omniFlashRefCap = getModelCapability('omni-flash')?.maxIngredientImages ?? 0;
1742
+ /** Omni Flash's combined reference-image cap, read from the SSOT (6 on 1.2). */
1743
+ const omniFlashRefCap = getModelCapability('omni-flash-1-2')?.maxIngredientImages ?? 0;
1738
1744
  /** Omni Flash's per-clip reference-video ceiling in seconds, read from the SSOT. */
1739
- const omniFlashRefClipMax = getModelCapability('omni-flash')?.referenceVideoDuration?.max ?? 0;
1745
+ const omniFlashRefClipMax = getModelCapability('omni-flash-1-2')?.referenceVideoDuration?.max ?? 0;
1740
1746
  /** Every resolution token any video model speaks, for the forgiving cost-key
1741
1747
  * parser. Derived, so 768p and 2k arrived with the models rather than with a
1742
1748
  * later bug report. */
@@ -1810,7 +1816,7 @@ function minimaxRefSurchargeCount(model, referenceImages) {
1810
1816
  export const EDIT_VIDEO_MODELS = [
1811
1817
  'kling-v3.0-omni-edit',
1812
1818
  'kling-v3.0-omni-pro-edit',
1813
- 'omni-flash-edit',
1819
+ 'omni-flash-1-2-edit',
1814
1820
  'seedance-2.5-edit',
1815
1821
  ];
1816
1822
  // The op's default, not MODEL_FACTS' edit tier default: the desktop route defaults to the same Kling
@@ -1825,7 +1831,7 @@ const EDIT_VIDEO_ELEMENTS_ONLY = `Only ${EDIT_VIDEO_ELEMENT_MODELS.join(' and ')
1825
1831
  *
1826
1832
  * On an edit row the output length FOLLOWS the source clip, so the model's
1827
1833
  * declared duration window is exactly the legal clip window — Kling 3-15s,
1828
- * Omni Flash 3-10s, Seedance 2.5 4-30s. These three pairs used to be typed
1834
+ * Omni Flash 1.2 3-15s, Seedance 2.5 4-30s. These three pairs used to be typed
1829
1835
  * inline as `isSeedanceEdit ? 4 : 3` / `isSeedanceEdit ? 30 : isOmniFlashEdit ?
1830
1836
  * 10 : 15`, i.e. a fourth copy of registry data keyed on model-id comparisons.
1831
1837
  */
@@ -1835,9 +1841,9 @@ function editClipBounds(model) {
1835
1841
  throw new Error(`editClipBounds: no duration capability for "${model}"`);
1836
1842
  return { min: d.min, max: d.max };
1837
1843
  }
1838
- /** Resolutions any edit engine exposes as a PARAM. Seedance's and Omni Flash
1839
- * 1.1's edit prices move with resolution; the Kling rows follow the source. */
1840
- const EDIT_VIDEO_RESOLUTIONS = videoResolutionUnion(['seedance-2.5-edit', 'omni-flash-edit']);
1844
+ /** Resolutions any edit engine exposes as a PARAM. Seedance's and Omni Flash's
1845
+ * edit prices move with resolution; the Kling rows follow the source. */
1846
+ const EDIT_VIDEO_RESOLUTIONS = videoResolutionUnion(['seedance-2.5-edit', 'omni-flash-1-2-edit']);
1841
1847
  export const estimateGenerationCost = {
1842
1848
  id: 'slates_estimate_generation_cost',
1843
1849
  description: 'Quote credits before any generate_* op. For saved Shots, a board or a scene, quote with slates_get_board_quote instead. Accepts the generation model ids and parameters (edit seats other than Kling, lip-sync and motion-transfer engines need an exact registry cost key), or an exact registry cost key. Show the user the total and wait for their OK before the generate call; the result flags requires_confirm above the threshold and carries the model\'s prompting card.',
@@ -1864,7 +1870,7 @@ export const estimateGenerationCost = {
1864
1870
  seedanceRealFace: z.boolean().optional().describe('Seedance with a consented real person (premium key).'),
1865
1871
  videoRefSeconds: z.number().nonnegative().optional().describe('Combined reference-video seconds, measured from the clips.'),
1866
1872
  audioRefSeconds: z.number().nonnegative().optional().describe('Combined reference-audio seconds, including attached character voices.'),
1867
- 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.`),
1873
+ 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.`),
1868
1874
  }),
1869
1875
  async run(input, ctx) {
1870
1876
  // A retired seat is never quoted: its keys still bill older desktops, and `nano-banana-2-1k` (the
@@ -1877,7 +1883,7 @@ export const estimateGenerationCost = {
1877
1883
  const byKey = new Map(registry.models.filter((m) => !retiredModelOfKey(m.model)).map((m) => [m.model, creditCost(m)]));
1878
1884
  // 1) exact registry cost key
1879
1885
  let key = byKey.has(input.model) ? input.model : null;
1880
- // 2) image base id + resolution (+ quality for GPT Image 2.5)
1886
+ // 2) image base id + resolution (+ quality for GPT Image)
1881
1887
  if (!key) {
1882
1888
  // IMAGE_MODELS, never a second hand-typed copy: this list is declared
1883
1889
  // below (a runtime read, so no temporal-dead-zone hazard) and is the same
@@ -1891,7 +1897,7 @@ export const estimateGenerationCost = {
1891
1897
  // generation quoted 1 cr for a 2 cr job. Four separate copies of one
1892
1898
  // default is what made that possible; there are now none.
1893
1899
  if (img)
1894
- key = imageCostKey(img, input.resolution ?? defaultImageResolutionFor(img), input.quality, input.aspectRatio);
1900
+ key = imageCostKey(img, input.resolution ?? defaultImageResolutionFor(img), input.quality, input.aspectRatio, input.referenceImages ?? 0);
1895
1901
  }
1896
1902
  // 2a) audio base id → seconds. Both surfaces bill per second, so a
1897
1903
  // duration is always required. Runs BEFORE the video resolver: it is
@@ -2032,7 +2038,7 @@ export const estimateGenerationCost = {
2032
2038
  // Before the card on purpose: the desktop strips a repeated card by cutting
2033
2039
  // the text at "--- HOW TO PROMPT", and this line must survive that.
2034
2040
  const ownImage = IMAGE_MODELS.includes(input.model) ? input.model : null;
2035
- const cheaper = ownImage ? cheaperImageOptions(byKey, perCredits, ownImage, input.aspectRatio) : null;
2041
+ const cheaper = ownImage ? cheaperImageOptions(byKey, perCredits, ownImage, input.aspectRatio, input.referenceImages ?? 0) : null;
2036
2042
  const framing = input.aspectRatio ?? '16:9';
2037
2043
  const unpricedNote = cheaper?.unpriced.length
2038
2044
  ? ` Not on the price list at ${framing}: ${cheaper.unpriced.join(', ')}; estimate one directly to price it.`
@@ -2720,7 +2726,7 @@ export const generateCharacterIdentity = {
2720
2726
  baseAssetId: z.string().uuid().describe('The base portrait asset the identity is generated from. ' + ASSET_UUID_ONLY),
2721
2727
  userNotes: z.string().optional().describe('Extra instruction, e.g. "use the woman on the left".'),
2722
2728
  model: z
2723
- .enum(['nano-banana-2-1', 'gpt-image-2-5-flare', 'gpt-image-2-5-sunburst'])
2729
+ .enum(['nano-banana-2-1', 'gpt-image-2-6-flare', 'gpt-image-2-6-sunburst'])
2724
2730
  .optional()
2725
2731
  .describe(`Image model for the sheet. Omit for the sheet tool's seat (${toolModelFor('character-sheet')}), which is what the app's own button uses. Pass another only to compare seats side by side.`),
2726
2732
  confirm: z.boolean().optional().describe(CONFIRM_PARAM),
@@ -2733,8 +2739,9 @@ export const generateCharacterIdentity = {
2733
2739
  // and `editImage` gate against; this op was simply missed when the gate was
2734
2740
  // introduced, and the 2.5 swap is what makes it reachable in practice.
2735
2741
  requireGuideRead(ctx, input.model ?? toolModelFor('character-sheet'));
2736
- if (isGptImageModel(input.model)) {
2737
- await ctx.desktop().requireCapability('image-models-v3', `${input.model} character identity`);
2742
+ let sentModel = input.model;
2743
+ if (input.model && isGptImageModel(input.model)) {
2744
+ sentModel = await gptImageSeatFor(ctx.desktop(), input.model, `${input.model} character identity`);
2738
2745
  }
2739
2746
  else if (isImageModelV4(input.model)) {
2740
2747
  await ctx.desktop().requireCapability('image-models-v4', `${input.model} character identity`);
@@ -2747,13 +2754,15 @@ export const generateCharacterIdentity = {
2747
2754
  const quote = await sheetConfirmGate(ctx, input, (input.model ?? toolModelFor('character-sheet')));
2748
2755
  if (quote)
2749
2756
  return quote;
2750
- return ok(await ctx.desktop().post('/agent/characters/generate-identity', {
2757
+ const made = await ctx.desktop().post('/agent/characters/generate-identity', {
2751
2758
  characterId: input.characterId,
2752
2759
  projectId: input.projectId,
2753
2760
  baseAssetIds: [input.baseAssetId],
2754
2761
  userNotes: input.userNotes,
2755
- model: input.model,
2756
- }));
2762
+ model: sentModel,
2763
+ });
2764
+ const substitution = input.model && sentModel ? gptImageSubstitution(input.model, sentModel) : '';
2765
+ return ok(made, substitution ? `${substitution} ${JSON.stringify(made)}` : undefined);
2757
2766
  },
2758
2767
  };
2759
2768
  export const generateEnvironmentPlate = {
@@ -2973,15 +2982,148 @@ async function previewAssets(ctx, refs) {
2973
2982
  export const THREE_K_IMAGE_MODELS = Object.keys(MODEL_CAPABILITIES).filter((id) => MODEL_CAPABILITIES[id].imageResolutions?.includes('3k'));
2974
2983
  export const IMAGE_MODELS = [
2975
2984
  'nano-banana-2-1',
2976
- 'gpt-image-2-5-flare',
2977
- 'gpt-image-2-5-sunburst',
2985
+ 'gpt-image-2-6-flare',
2986
+ 'gpt-image-2-6-sunburst',
2978
2987
  'flux-3',
2979
- 'seedream-5-lite',
2988
+ 'seedream-5-5',
2980
2989
  ];
2981
- /** True for either GPT Image 2.5 seat. Flare and Sunburst differ in latency
2990
+ /** True for either GPT Image seat. Flare and Sunburst differ in latency
2982
2991
  * and routing advice, never in pricing shape or param surface. */
2983
2992
  export function isGptImageModel(model) {
2984
- return model === 'gpt-image-2-5-flare' || model === 'gpt-image-2-5-sunburst';
2993
+ return model === 'gpt-image-2-6-flare' || model === 'gpt-image-2-6-sunburst';
2994
+ }
2995
+ /**
2996
+ * The GPT Image id to send this desktop for a 2.6 seat: the seat itself on a
2997
+ * desktop advertising `image-models-v5`, else the 2.5 seat it replaced.
2998
+ *
2999
+ * Why not refuse, as v3 and v4 do: 2.6 Sunburst is the default image seat, so a
3000
+ * refusal would stop every plain image call and edit on an installed desktop
3001
+ * (1.6.8 and older know only the 2.5 ids). 2.6 takes 2.5's fields, sizes and
3002
+ * tiers at the same price per cell (metered 2026-11-10, second-brain
3003
+ * plans/2026-11-10-slates-gpt-image-2-6-swap.md), and slates-api keeps 2.5
3004
+ * billable for those desktops, so the 2.5 seat renders what was quoted. The
3005
+ * result names the substitution. A desktop without v3 knows no GPT Image seat
3006
+ * and would render its Nano Banana path at a GPT price, so it still refuses.
3007
+ */
3008
+ async function gptImageSeatFor(desktop, model, feature) {
3009
+ try {
3010
+ await desktop.requireCapability('image-models-v5', feature);
3011
+ return model;
3012
+ }
3013
+ catch {
3014
+ // A real failure (desktop not running) throws again here.
3015
+ await desktop.requireCapability('image-models-v3', feature);
3016
+ return Object.keys(RETIRED_MODELS).find((id) => id.startsWith('gpt-image-2-5-') && RETIRED_MODELS[id] === model) ?? model;
3017
+ }
3018
+ }
3019
+ /** The line a result carries when `gptImageSeatFor` sent the 2.5 seat. */
3020
+ function gptImageSubstitution(asked, sent) {
3021
+ 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
+ }
3023
+ /**
3024
+ * The image seats that take `backgroundMode` (transparent / opaque / auto): both
3025
+ * GPT Image seats and Seedream 5.5 (BytePlus `background`, read 2026-11-16). The
3026
+ * desktop's twin is the `transparentBackground` feature on its registry rows,
3027
+ * which shows the Background control; the wire field is `gptBackground` for
3028
+ * every seat, a name kept from when GPT Image was the only one.
3029
+ */
3030
+ export function takesBackgroundMode(model) {
3031
+ return isGptImageModel(model) || model === 'seedream-5-5';
3032
+ }
3033
+ /** The default image seat before Seedream 5.5 took it, which an older desktop still renders. */
3034
+ const PREVIOUS_DEFAULT_IMAGE_MODEL = 'gpt-image-2-6-sunburst';
3035
+ /**
3036
+ * The seat to run when the caller left `model` out, on this desktop. Seedream
3037
+ * 5.5 is the default, and only a desktop advertising `image-models-v6` (1.7.0
3038
+ * and newer) knows it: an older one would render its Nano Banana fallback at a
3039
+ * Seedream quote. So an unnamed call on such a desktop runs the previous
3040
+ * default, which it knows, and the result says so; a call that NAMES Seedream
3041
+ * 5.5 is refused with the update message instead, since the caller asked for it.
3042
+ */
3043
+ async function defaultImageSeatFor(desktop, named, feature) {
3044
+ const model = named ?? DEFAULT_IMAGE_MODEL;
3045
+ if (model !== 'seedream-5-5')
3046
+ return { model, note: '' };
3047
+ if (named) {
3048
+ await desktop().requireCapability('image-models-v6', feature);
3049
+ return { model, note: '' };
3050
+ }
3051
+ try {
3052
+ await desktop().requireCapability('image-models-v6', feature);
3053
+ return { model, note: '' };
3054
+ }
3055
+ catch {
3056
+ return {
3057
+ model: PREVIOUS_DEFAULT_IMAGE_MODEL,
3058
+ 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.`,
3059
+ };
3060
+ }
3061
+ }
3062
+ /** True for either Gemini Omni Flash 1.2 seat, generation or edit. */
3063
+ export function isOmniFlash12Model(model) {
3064
+ return model === 'omni-flash-1-2' || model === 'omni-flash-1-2-edit';
3065
+ }
3066
+ /**
3067
+ * Omni Flash 1.1's longest clip, output or edit source. Frozen here because the
3068
+ * capability table no longer carries 1.1: fal's 1.1 `duration` stopped at 10, and
3069
+ * Google's 1.1 doc read "Input videos for editing and extension must be 10
3070
+ * seconds or less".
3071
+ */
3072
+ const OMNI_FLASH_11_MAX_SECONDS = 10;
3073
+ /**
3074
+ * The Omni Flash id to send this desktop for a 1.2 seat: the seat itself on a
3075
+ * desktop advertising `video-models-v2`, else the 1.1 seat it replaced, when the
3076
+ * request fits 1.1 (`seconds` is the output length, or an edit's source length).
3077
+ *
3078
+ * Why not refuse: 1.6.8 and older know only the 1.1 ids. 1.2 bills the same
3079
+ * credits per second as 1.1 at every resolution Slates sells, slates-api keeps
3080
+ * 1.1 billable for those desktops, and every 1.2 reference limit sits inside
3081
+ * 1.1's, so up to 10s the 1.1 seat renders what was quoted. A longer clip has
3082
+ * no 1.1 seat and refuses with "update Slates". A desktop without
3083
+ * `image-models-v4` predates 1.1 (both arrived in 1.6.3) and would bill 1.0's
3084
+ * keys, so it refuses too.
3085
+ */
3086
+ async function omniFlashSeatFor(desktop, model, feature, seconds) {
3087
+ try {
3088
+ await desktop.requireCapability('video-models-v2', feature);
3089
+ return model;
3090
+ }
3091
+ catch {
3092
+ // A real failure (desktop not running), or a desktop before 1.1, throws again here.
3093
+ await desktop.requireCapability('image-models-v4', feature);
3094
+ if (seconds != null && seconds > OMNI_FLASH_11_MAX_SECONDS + 0.05) {
3095
+ throw new Error(`This Slates desktop runs Gemini Omni Flash 1.1, which stops at ${OMNI_FLASH_11_MAX_SECONDS}s, so ${feature} at ${seconds}s needs 1.2. ` +
3096
+ `Update Slates (Settings → Check for Updates) and retry, or keep it to ${OMNI_FLASH_11_MAX_SECONDS}s or less.`);
3097
+ }
3098
+ return Object.keys(RETIRED_MODELS).find((id) => id.startsWith('omni-flash') && RETIRED_MODELS[id] === model) ?? model;
3099
+ }
3100
+ }
3101
+ /** The line a result carries when `omniFlashSeatFor` sent the 1.1 seat. */
3102
+ function omniFlashSubstitution(asked, sent) {
3103
+ return sent === asked ? '' : `${sent} ran in place of ${asked}, at the same price: this Slates desktop predates Gemini Omni Flash 1.2. Update Slates to run 1.2.`;
3104
+ }
3105
+ /**
3106
+ * A model id an op hands the desktop by name (a generation's, a Shot's or a draft's model), as this desktop knows
3107
+ * it: a GPT Image 2.6 seat goes through `gptImageSeatFor`, an Omni Flash 1.2 seat through `omniFlashSeatFor`
3108
+ * (`seconds` as it takes them), every other id passes untouched. A 1.6.8 desktop's `draftShot` throws on an id it
3109
+ * lacks, so every such hand-off comes through here, with the line its result says.
3110
+ */
3111
+ async function desktopModelId(desktop, model, feature, seconds) {
3112
+ if (model && isOmniFlash12Model(model)) {
3113
+ const sent = (await omniFlashSeatFor(desktop, model, feature, seconds));
3114
+ return { model: sent, note: omniFlashSubstitution(model, sent) };
3115
+ }
3116
+ if (!model || !isGptImageModel(model))
3117
+ return { model, note: '' };
3118
+ const sent = (await gptImageSeatFor(desktop, model, feature));
3119
+ return { model: sent, note: gptImageSubstitution(model, sent) };
3120
+ }
3121
+ /** `draft` with its model as this desktop knows it (`desktopModelId`). */
3122
+ async function desktopDraft(desktop, draft) {
3123
+ if (!draft?.model)
3124
+ return { draft, note: '' };
3125
+ const { model, note } = await desktopModelId(desktop, draft.model, `previews on ${draft.model}`);
3126
+ return { draft: { ...draft, model }, note };
2985
3127
  }
2986
3128
  /**
2987
3129
  * The seats that arrived 2026-10-23, which only a desktop advertising
@@ -3000,7 +3142,7 @@ const HEADLESS_IMAGE_MODEL = 'nano-banana-2-1';
3000
3142
  * value no model accepts. It used to be a hand-typed eleven-value list whose
3001
3143
  * `9:21` exists in ZERO models; that phantom is gone by construction.
3002
3144
  *
3003
- * ⚠️ STILL A UNION, NOT A PER-MODEL CHECK. GPT Image 2.5 takes five of these
3145
+ * ⚠️ STILL A UNION, NOT A PER-MODEL CHECK. GPT Image takes five of these
3004
3146
  * ten and the other five would be accepted here. The image param surface has
3005
3147
  * not been audited (aspect ratios, resolution classes, per-model reference
3006
3148
  * caps) — that audit is the named follow-up in
@@ -3012,7 +3154,7 @@ const IMAGE_ASPECT_RATIOS = aspectRatioUnion(IMAGE_MODELS);
3012
3154
  // Registry cost-key for an image model+resolution. Mirrors imageCreditKey()
3013
3155
  // in slate/src/shared/pricing.ts — MUST byte-match it (the same hard rule as
3014
3156
  // videoCostKey): Nano Banana 2.1 and FLUX 3 price per resolution, Seedream is
3015
- // flat, GPT Image 2.5 is quality × resolution-class over ALL FIVE exposed tiers.
3157
+ // flat, GPT Image is quality × resolution-class over ALL FIVE exposed tiers.
3016
3158
  //
3017
3159
  // 🚨 THE KEY SUFFIX IS `med` WHILE THE WIRE VALUE IS `medium` — the one
3018
3160
  // tier name that differs between fal's enum and our cost keys, inherited from
@@ -3039,11 +3181,19 @@ function gptKeyAspect(aspectRatio) {
3039
3181
  // imports it and asserts, key by key, that it equals the desktop's
3040
3182
  // `imageCreditKey`. Before that check existed the byte-match was a comment and
3041
3183
  // a hope — the two are in different repos and nothing compared them.
3042
- export function imageCostKey(model, resolution, quality = DEFAULT_GPT_QUALITY, aspectRatio) {
3184
+ /**
3185
+ * BytePlus bills every input image of a Seedream 5.5 call, so its key names the
3186
+ * reference count (`seedream55CostKey`, model-capabilities.ts), and a quote made
3187
+ * before the desktop composes @mention pictures can be short of the bill.
3188
+ */
3189
+ function billsEachInputImage(model) {
3190
+ return model === 'seedream-5-5';
3191
+ }
3192
+ export function imageCostKey(model, resolution, quality = DEFAULT_GPT_QUALITY, aspectRatio, referenceCount = 0) {
3043
3193
  if (model === 'flux-3')
3044
3194
  return `flux-3-${resolution}`;
3045
- if (model === 'seedream-5-lite')
3046
- return 'seedream-5-lite';
3195
+ if (billsEachInputImage(model))
3196
+ return seedream55CostKey(resolution, referenceCount);
3047
3197
  if (isGptImageModel(model))
3048
3198
  return `${model}-${gptKeyTier(quality)}-${resolution}${gptKeyAspect(aspectRatio)}`;
3049
3199
  return `nano-banana-2-1-${resolution}`;
@@ -3063,7 +3213,7 @@ export function imageCostKey(model, resolution, quality = DEFAULT_GPT_QUALITY, a
3063
3213
  * Which seat is right stays the agent's call ("cheap" and "best" trade), so
3064
3214
  * nothing is routed here: the comparison is a fact in front of it instead.
3065
3215
  */
3066
- function cheaperImageOptions(byKey, than, own, aspectRatio) {
3216
+ function cheaperImageOptions(byKey, than, own, aspectRatio, referenceCount = 0) {
3067
3217
  const all = [];
3068
3218
  const unpriced = [];
3069
3219
  for (const model of IMAGE_MODELS) {
@@ -3072,7 +3222,7 @@ function cheaperImageOptions(byKey, than, own, aspectRatio) {
3072
3222
  let best = null;
3073
3223
  for (const resolution of MODEL_CAPABILITIES[model]?.imageResolutions ?? []) {
3074
3224
  for (const quality of qualities) {
3075
- const credits = byKey.get(imageCostKey(model, resolution, quality, aspectRatio));
3225
+ const credits = byKey.get(imageCostKey(model, resolution, quality, aspectRatio, referenceCount));
3076
3226
  if (credits == null)
3077
3227
  continue;
3078
3228
  const better = !best || credits < best.credits || (credits === best.credits && ((resolution === fallback && best.resolution !== fallback) ||
@@ -3125,13 +3275,14 @@ export const generateImage = {
3125
3275
  projectId: z.string().uuid().optional().describe(`Save into this Slates project. Renderer refreshes live. Required for every model except ${HEADLESS_IMAGE_MODEL}.`),
3126
3276
  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.'),
3127
3277
  quality: z.enum(GPT_QUALITY_TIERS).optional().describe(`GPT Image only. Default ${DEFAULT_GPT_QUALITY}; estimate the chosen tier before generation.`),
3128
- backgroundMode: z.enum(GPT_BACKGROUNDS).optional().describe('GPT Image only. transparent = alpha channel. Free.'),
3278
+ backgroundMode: z.enum(GPT_BACKGROUNDS).optional().describe(`${IMAGE_MODELS.filter(takesBackgroundMode).join(', ')} only. transparent = alpha channel (PNG). Free.`),
3129
3279
  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)}`),
3130
3280
  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.`),
3131
3281
  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.`),
3132
3282
  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.`),
3133
3283
  background: z.boolean().optional().describe(BACKGROUND_DESCRIBE),
3134
3284
  confirm: z.boolean().optional().describe(CONFIRM_PARAM),
3285
+ 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.'),
3135
3286
  folderId: z.string().uuid().nullable().optional().describe(`${FOLDER_DESCRIBE} Needs projectId.`),
3136
3287
  }),
3137
3288
  async run(input, ctx) {
@@ -3149,7 +3300,10 @@ export const generateImage = {
3149
3300
  // HEADLESS_IMAGE_MODEL without one, because it is the only headless seat. The
3150
3301
  // desktop resolves the same seat for its cost and plan-model guards
3151
3302
  // (`imageModelFor`, slate src/main/studio-agent/guards.ts): change both together.
3152
- const imageModel = input.model ?? (input.projectId ? DEFAULT_IMAGE_MODEL : HEADLESS_IMAGE_MODEL);
3303
+ const seat = input.projectId
3304
+ ? await defaultImageSeatFor(() => ctx.desktop(), input.model, `${input.model ?? DEFAULT_IMAGE_MODEL} generation`)
3305
+ : { model: input.model ?? HEADLESS_IMAGE_MODEL, note: '' };
3306
+ const imageModel = seat.model;
3153
3307
  requireGuideRead(ctx, imageModel);
3154
3308
  const promptWarning = bannedTokenWarning(input.prompt, 'image', promptingSkillFor(imageModel));
3155
3309
  input = { ...input, resolution: input.resolution ?? defaultImageResolutionFor(imageModel) };
@@ -3233,12 +3387,11 @@ export const generateImage = {
3233
3387
  // New-roster models need a desktop that knows them — an older desktop's
3234
3388
  // allowlist would silently fall back to its Nano Banana path while we quote
3235
3389
  // the new model's price.
3390
+ let sentModel = imageModel;
3236
3391
  if (input.projectId && isGptImageModel(imageModel)) {
3237
- // 🚨 v3, NOT v2. GPT Image 2.5 landed 2026-09-09 with new ids and a
3238
- // five-rung ladder; a desktop that only knows v2 has neither, so it would
3239
- // fall back to its Nano Banana path while this op quotes a 2.5 price — precisely
3240
- // the failure the gate was built to stop. Reusing v2 reintroduces it.
3241
- await ctx.desktop().requireCapability('image-models-v3', `${imageModel} generation`);
3392
+ // A desktop that knows 2.5 and not 2.6 gets the 2.5 seat; one that knows
3393
+ // neither refuses (gptImageSeatFor says why).
3394
+ sentModel = await gptImageSeatFor(ctx.desktop(), imageModel, `${imageModel} generation`);
3242
3395
  }
3243
3396
  else if (input.projectId && isImageModelV4(imageModel)) {
3244
3397
  await ctx.desktop().requireCapability('image-models-v4', `${imageModel} generation`);
@@ -3247,7 +3400,7 @@ export const generateImage = {
3247
3400
  if (input.projectId && (input.count ?? 1) > LEGACY_DESKTOP_IMAGE_BATCH) {
3248
3401
  await ctx.desktop().requireCapability('image-variations', 'more than 4 images per call');
3249
3402
  }
3250
- const costKey = imageCostKey(imageModel, resolution, input.quality, input.aspectRatio ?? '1:1');
3403
+ const costKey = imageCostKey(imageModel, resolution, input.quality, input.aspectRatio ?? '1:1', referenceAssetIds.length);
3251
3404
  const cloud = ctx.cloud();
3252
3405
  const registry = await cloud.get('/api/agent/models');
3253
3406
  const entry = registry.models.find((m) => m.model === costKey) ??
@@ -3313,15 +3466,31 @@ export const generateImage = {
3313
3466
  const result = await desktop.post('/agent/generation/image', {
3314
3467
  projectId: input.projectId,
3315
3468
  prompt: input.prompt,
3316
- model: imageModel,
3469
+ model: sentModel,
3317
3470
  resolution,
3318
3471
  aspectRatio: input.aspectRatio ?? '1:1',
3319
3472
  count: input.count ?? 1,
3320
- ...(isGptImageModel(imageModel) ? { gptQuality: input.quality ?? DEFAULT_GPT_QUALITY, gptBackground: input.backgroundMode } : {}),
3473
+ ...(isGptImageModel(imageModel) ? { gptQuality: input.quality ?? DEFAULT_GPT_QUALITY } : {}),
3474
+ ...(takesBackgroundMode(imageModel) ? { gptBackground: input.backgroundMode } : {}),
3321
3475
  ...(referenceAssetIds.length > 0 ? { referenceAssetIds } : {}),
3476
+ // The desktop adds @mention pictures this op cannot see; on a seat that bills
3477
+ // each input it runs nothing above what the user was quoted or approved.
3478
+ ...(billsEachInputImage(sentModel) ? { maxCredits: Math.max(totalCents, input.approvedCredits ?? 0) } : {}),
3322
3479
  ...folderBody(input.folderId),
3323
3480
  background: input.background,
3324
3481
  });
3482
+ if (result.quoteExceeded) {
3483
+ const { credits, costKey: billedKey } = result.quoteExceeded;
3484
+ return ok({
3485
+ requires_confirm: true,
3486
+ quote_exceeded: true,
3487
+ model: billedKey,
3488
+ estimated_cents: credits,
3489
+ estimated_credits: credits,
3490
+ message: `Nothing ran. The @mention pictures in the prompt are paid inputs on ${imageModel}: this call bills ${fmtCredits(credits)} (${billedKey}), ` +
3491
+ `not the ${fmtCredits(totalCents)} quoted. Tell the user, and once they approve, re-call with confirm=true and approvedCredits=${credits}.`,
3492
+ });
3493
+ }
3325
3494
  // Partial multi-image failure: the desktop attaches an error message
3326
3495
  // but result.assets still holds the images that DID save. Throwing
3327
3496
  // here would discard real, paid-for assets and invite a full retry
@@ -3330,15 +3499,17 @@ export const generateImage = {
3330
3499
  if (!result.success && !partialFailure) {
3331
3500
  throw new Error(result.error ?? 'Generation failed');
3332
3501
  }
3502
+ const substitution = [seat.note, gptImageSubstitution(imageModel, sentModel)].filter(Boolean).join(' ');
3333
3503
  if (result.background) {
3334
3504
  const ids = result.generationIds ?? (result.generationId ? [result.generationId] : []);
3335
3505
  return backgroundSubmitted(`${imageModel} image generation`, ids, {
3336
3506
  model: imageModel,
3507
+ ...(substitution ? { ranOn: sentModel } : {}),
3337
3508
  costKey,
3338
3509
  projectId: input.projectId,
3339
3510
  cost_cents: totalCents,
3340
3511
  cost_credits: totalCents,
3341
- }, refEcho);
3512
+ }, [refEcho, substitution].filter(Boolean).join(' '));
3342
3513
  }
3343
3514
  const assetList = result.assets
3344
3515
  ?? (result.asset ? [result.asset] : []);
@@ -3371,10 +3542,12 @@ export const generateImage = {
3371
3542
  : `Generated ${assetList.length} image(s) into project ${input.projectId} ` +
3372
3543
  `for ${fmtCredits(totalCents)}. ` +
3373
3544
  `Prompt: "${input.prompt.slice(0, 60)}${input.prompt.length > 60 ? '...' : ''}"` +
3374
- (refEcho ? ` ${refEcho}` : '')),
3545
+ (refEcho ? ` ${refEcho}` : '')) +
3546
+ (substitution ? ` ${substitution}` : ''),
3375
3547
  images,
3376
3548
  data: {
3377
3549
  model: imageModel,
3550
+ ...(substitution ? { ranOn: sentModel } : {}),
3378
3551
  costKey,
3379
3552
  projectId: input.projectId,
3380
3553
  aspectRatio: input.aspectRatio,
@@ -3513,9 +3686,9 @@ export const editImage = {
3513
3686
  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.'),
3514
3687
  editModel: zEnum(IMAGE_MODELS).optional(),
3515
3688
  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(', ')}.`),
3516
- resolution: z.enum(['1k', '2k', '3k', '4k']).optional().describe('3k = GPT Image/seedream-5-lite only.'),
3689
+ 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(', ')}.`),
3517
3690
  quality: z.enum(GPT_QUALITY_TIERS).optional().describe(`GPT Image tier; default ${DEFAULT_GPT_QUALITY}.`),
3518
- backgroundMode: z.enum(GPT_BACKGROUNDS).optional().describe('GPT Image only. transparent = alpha channel. Free.'),
3691
+ backgroundMode: z.enum(GPT_BACKGROUNDS).optional().describe(`${IMAGE_MODELS.filter(takesBackgroundMode).join(', ')} only. transparent = alpha channel (PNG). Free.`),
3519
3692
  aspectRatio: z.string().optional(),
3520
3693
  confirm: z.boolean().optional().describe(CONFIRM_PARAM),
3521
3694
  background: z.boolean().optional().describe(BACKGROUND_DESCRIBE),
@@ -3526,17 +3699,22 @@ export const editImage = {
3526
3699
  if (input.background) {
3527
3700
  await desktop.requireCapability('background-generation', 'background generation');
3528
3701
  }
3529
- // The image-edit tool's seat (TOOL_SEAT), the model the app's own Edit uses.
3530
- const editModel = input.editModel ?? toolModelFor('image-edit');
3702
+ // The image-edit tool's seat (TOOL_SEAT), the model the app's own Edit uses;
3703
+ // on a desktop that predates Seedream 5.5, the seat it knows (defaultImageSeatFor).
3704
+ const seat = input.editModel
3705
+ ? await defaultImageSeatFor(() => desktop, input.editModel, `${input.editModel} editing`)
3706
+ : toolModelFor('image-edit') === DEFAULT_IMAGE_MODEL
3707
+ ? await defaultImageSeatFor(() => desktop, undefined, 'image editing')
3708
+ : { model: toolModelFor('image-edit'), note: '' };
3709
+ const editModel = seat.model;
3531
3710
  requireGuideRead(ctx, editModel);
3532
3711
  const resolution = input.resolution ?? defaultImageResolutionFor(editModel);
3712
+ let sentModel = editModel;
3533
3713
  if (isGptImageModel(editModel)) {
3534
- // 🚨 v3, LIKE generateImage — this site was missed once already.
3535
- // A pre-2.5 desktop advertises v2, so gating the 2.5 seats on v2 lets it
3536
- // through; `isFalImageModel` is then false for these ids on that build and
3537
- // handleEditImage falls through to the nano-banana path — NB2 output billed
3538
- // at a quoted 2.5 price. Exactly the bug the gate exists to stop.
3539
- await desktop.requireCapability('image-models-v3', `${editModel} editing`);
3714
+ // Like generateImage; this site was missed once already. A desktop that
3715
+ // knows no GPT Image seat falls through to its Nano Banana path at a quoted
3716
+ // GPT price, so it refuses; one that knows 2.5 and not 2.6 gets the 2.5 seat.
3717
+ sentModel = await gptImageSeatFor(desktop, editModel, `${editModel} editing`);
3540
3718
  }
3541
3719
  else if (isImageModelV4(editModel)) {
3542
3720
  await desktop.requireCapability('image-models-v4', `${editModel} editing`);
@@ -3546,13 +3724,15 @@ export const editImage = {
3546
3724
  }
3547
3725
  // Past the model's cap the desktop sends the first ones and says so in its reply (`note`).
3548
3726
  const referencesOver = (input.referenceAssetIds?.length ?? 0) - editReferenceCap(editModel);
3549
- // Nano-Banana family + GPT Image 2.5 edits charge the same key as gen;
3550
- // FLUX / Seedream route to dedicated edit endpoints priced under '-edit' keys.
3727
+ // Nano Banana and GPT Image edits charge the same key as gen; FLUX routes to
3728
+ // a dedicated edit endpoint priced under an '-edit' key; Seedream 5.5 bills
3729
+ // every input image, the source included, so its key counts them.
3551
3730
  // Mirrors `editCreditKey` in the desktop's src/shared/imageEdit.ts, which
3552
3731
  // this package cannot import: change both together.
3553
- const costKey = editModel === 'flux-3' || editModel === 'seedream-5-lite'
3732
+ const editInputs = 1 + Math.min(input.referenceAssetIds?.length ?? 0, editReferenceCap(editModel));
3733
+ const costKey = editModel === 'flux-3'
3554
3734
  ? `${imageCostKey(editModel, resolution)}-edit`
3555
- : imageCostKey(editModel, resolution, input.quality, input.aspectRatio);
3735
+ : imageCostKey(editModel, resolution, input.quality, input.aspectRatio, editInputs);
3556
3736
  const cloud = ctx.cloud();
3557
3737
  const registry = await cloud.get('/api/agent/models');
3558
3738
  const entry = registry.models.find((m) => m.model === costKey) ??
@@ -3578,15 +3758,17 @@ export const editImage = {
3578
3758
  projectId: input.projectId,
3579
3759
  sourceAssetId: input.sourceAssetId,
3580
3760
  prompt: input.prompt,
3581
- editModel,
3761
+ editModel: sentModel,
3582
3762
  referenceAssetIds: input.referenceAssetIds,
3583
3763
  resolution,
3584
- ...(isGptImageModel(editModel) ? { gptQuality: input.quality ?? DEFAULT_GPT_QUALITY, gptBackground: input.backgroundMode } : {}),
3764
+ ...(isGptImageModel(editModel) ? { gptQuality: input.quality ?? DEFAULT_GPT_QUALITY } : {}),
3765
+ ...(takesBackgroundMode(editModel) ? { gptBackground: input.backgroundMode } : {}),
3585
3766
  aspectRatio: input.aspectRatio,
3586
3767
  background: input.background,
3587
3768
  });
3588
3769
  if (!result.success)
3589
3770
  throw new Error(result.error ?? 'Image edit failed');
3771
+ const substitution = [seat.note, gptImageSubstitution(editModel, sentModel)].filter(Boolean).join(' ');
3590
3772
  if (result.background) {
3591
3773
  const ids = result.generationIds ?? (result.generationId ? [result.generationId] : []);
3592
3774
  return backgroundSubmitted(`${editModel} image edit`, ids, {
@@ -3597,7 +3779,8 @@ export const editImage = {
3597
3779
  cost_cents: totalCents,
3598
3780
  cost_credits: totalCents,
3599
3781
  ...(result.note ? { note: result.note } : {}),
3600
- }, result.note ? `${result.note}.` : undefined);
3782
+ ...(substitution ? { ranOn: sentModel } : {}),
3783
+ }, [result.note ? `${result.note}.` : '', substitution].filter(Boolean).join(' ') || undefined);
3601
3784
  }
3602
3785
  // Inline the edited result so the LLM sees whether the surgery landed —
3603
3786
  // same best-effort pattern as slates_generate_image.
@@ -3616,10 +3799,12 @@ export const editImage = {
3616
3799
  text: `Edited image saved as a new asset in project ${input.projectId} ` +
3617
3800
  `for ${fmtCredits(totalCents)} via ${editModel}. ` +
3618
3801
  `Edit: "${input.prompt.slice(0, 60)}${input.prompt.length > 60 ? '...' : ''}"` +
3619
- (result.note ? ` ${result.note}.` : ''),
3802
+ (result.note ? ` ${result.note}.` : '') +
3803
+ (substitution ? ` ${substitution}` : ''),
3620
3804
  images,
3621
3805
  data: {
3622
3806
  editModel,
3807
+ ...(substitution ? { ranOn: sentModel } : {}),
3623
3808
  variant: costKey,
3624
3809
  projectId: input.projectId,
3625
3810
  sourceAssetId: input.sourceAssetId,
@@ -3641,7 +3826,7 @@ export const editImage = {
3641
3826
  * with no `confirm`, the op answers with the price and the exact prompt, and spends nothing.
3642
3827
  */
3643
3828
  /** The seats the viewer's Cells box offers. Mirrors slate's `GRID_EXTRACT_MODELS` (`shared/prompts/storyboard-grids.ts`), which this package cannot import. */
3644
- const GRID_EXTRACT_SEATS = ['nano-banana-2-1', 'flux-3', 'seedream-5-lite'];
3829
+ const GRID_EXTRACT_SEATS = ['nano-banana-2-1', 'flux-3', 'seedream-5-5'];
3645
3830
  export const extractGridCells = {
3646
3831
  id: 'slates_extract_grid_cells',
3647
3832
  billable: true,
@@ -3874,14 +4059,14 @@ export function videoCostKey(input) {
3874
4059
  const res = input.videoResolution ?? defaultVideoResolutionFor(input.model);
3875
4060
  return `kling-v4-${res}-${input.duration}s`;
3876
4061
  }
3877
- if (input.model === 'omni-flash') {
4062
+ if (input.model === 'omni-flash-1-2') {
3878
4063
  // Mirrors omniFlashCreditKey() in slate/src/shared/pricing.ts. Omni Flash
3879
- // 1.1 prices each output second by resolution, so the key carries it. Audio
3880
- // is native and included, and references do not move fal's 1.1 price.
3881
- // 1.0's flat `omni-flash-{N}s` keys are legacy: only desktops released
3882
- // before the swap send them.
4064
+ // prices each output second by resolution, so the key carries it. Audio is
4065
+ // native and included, and references do not move fal's 1.2 listed price.
4066
+ // 1.1's `omni-flash-{res}-{N}s` and 1.0's `omni-flash-{N}s` keys stay
4067
+ // billable for the desktops released before each swap.
3883
4068
  const res = input.videoResolution ?? defaultVideoResolutionFor(input.model);
3884
- return `omni-flash-${res}-${input.duration}s`;
4069
+ return `omni-flash-1-2-${res}-${input.duration}s`;
3885
4070
  }
3886
4071
  if (input.model === 'wan-3.0') {
3887
4072
  // Mirrors wanCreditKey() in slate/src/shared/pricing.ts. Output seconds at
@@ -3911,10 +4096,10 @@ export function klingEditCostKey(model, duration) {
3911
4096
  // Omni Flash video-edit cost key — mirrors omniFlashCreditKey() in
3912
4097
  // slate/src/shared/pricing.ts (must byte-match; checked by the slates-api
3913
4098
  // pricing-consistency script). Duration is the CEILED source-clip length. The
3914
- // resolution is the output's, because Omni Flash 1.1 prices edit seconds by it.
4099
+ // resolution is the output's, because Omni Flash prices edit seconds by it.
3915
4100
  export function omniFlashEditCostKey(duration, videoResolution) {
3916
- const res = videoResolution ?? defaultVideoResolutionFor('omni-flash-edit');
3917
- return `omni-flash-edit-${res}-${duration}s`;
4101
+ const res = videoResolution ?? defaultVideoResolutionFor('omni-flash-1-2-edit');
4102
+ return `omni-flash-1-2-edit-${res}-${duration}s`;
3918
4103
  }
3919
4104
  /** Max billed (input + output) seconds on a Seedance video-reference gen.
3920
4105
  * 2.0: refs 2–15s + output 4–15s. 2.5: refs to 30s + output to 30s. */
@@ -4078,12 +4263,19 @@ function resolveVideoModel(raw) {
4078
4263
  'seedance-2-5': 'seedance-2.5',
4079
4264
  'seedance2.5': 'seedance-2.5',
4080
4265
  seedance: 'seedance-2',
4081
- 'gemini-omni-flash': 'omni-flash',
4082
- 'gemini-omni-flash-preview': 'omni-flash',
4083
- 'omni-flash-preview': 'omni-flash',
4084
- 'gemini-omni-1.1-flash': 'omni-flash',
4085
- 'gemini-omni-flash-1.1': 'omni-flash',
4086
- 'omni-flash-1.1': 'omni-flash',
4266
+ // Every Omni Flash spelling lands on 1.2, the retired 1.1 id and its cost
4267
+ // keys (`omni-flash-720p-8s`) included: RETIRED_MODELS moves 1.1 to 1.2.
4268
+ 'omni-flash': 'omni-flash-1-2',
4269
+ 'gemini-omni-flash': 'omni-flash-1-2',
4270
+ 'gemini-omni-flash-preview': 'omni-flash-1-2',
4271
+ 'omni-flash-preview': 'omni-flash-1-2',
4272
+ 'gemini-omni-1.1-flash': 'omni-flash-1-2',
4273
+ 'gemini-omni-flash-1.1': 'omni-flash-1-2',
4274
+ 'omni-flash-1.1': 'omni-flash-1-2',
4275
+ 'gemini-omni-1.2-flash': 'omni-flash-1-2',
4276
+ 'gemini-omni-flash-1.2': 'omni-flash-1-2',
4277
+ 'omni-flash-1.2': 'omni-flash-1-2',
4278
+ 'omni-flash-12': 'omni-flash-1-2',
4087
4279
  'wan-3': 'wan-3.0',
4088
4280
  'wan-3-0': 'wan-3.0',
4089
4281
  'wan3': 'wan-3.0',
@@ -4317,17 +4509,17 @@ export const generateVideo = {
4317
4509
  const capErr = assertVideoCapabilities(input);
4318
4510
  if (capErr)
4319
4511
  return ok(capErr);
4320
- // Omni Flash 1.1's SHAPE constraints. Frames ride image-to-video (a start
4321
- // frame and an optional end frame); references ride reference-to-video (up
4322
- // to 10 images and 3 videos, each within the per-clip cap). With references, the desktop
4323
- // sends a start frame as reference image 1 (as it did on 1.0), so it counts
4324
- // toward the image cap; a last frame has no slot there and is refused. There
4325
- // is no audio reference at all (Google: "Uploading audio references is
4326
- // unsupported"). Counts are read from the capability SSOT; duration and
4327
- // resolution are covered by the capability gate above.
4328
- if (input.model === 'omni-flash') {
4329
- const cap = getModelCapability('omni-flash');
4330
- const maxVideos = cap?.maxReferenceVideos ?? 0;
4512
+ // Omni Flash 1.2's SHAPE constraints. Frames ride image-to-video (a start
4513
+ // frame and an optional end frame, 10s or less with the end frame);
4514
+ // references ride reference-to-video (Google's limits: 6 images, reference
4515
+ // videos of 3s or less, three on a clip of 10s or less and one above). With
4516
+ // references, the desktop sends a start frame as reference image 1, so it
4517
+ // counts toward the image cap; a last frame has no slot there and is
4518
+ // refused. No audio reference at all (Google: "Uploading audio inputs or
4519
+ // audio references is unsupported"). Counts come from the capability SSOT
4520
+ // through `checkReferenceShape`, the function the desktop's composer runs;
4521
+ // duration and resolution are covered by the capability gate above.
4522
+ if (input.model === 'omni-flash-1-2') {
4331
4523
  const videoRefs = (input.videoReferenceAssetIds?.length ?? 0) + (input.videoReferenceAssetId ? 1 : 0);
4332
4524
  const audioRefs = (input.audioReferenceAssetIds?.length ?? 0) + (input.audioReferenceAssetId ? 1 : 0);
4333
4525
  const imageRefs = (input.ingredientAssetIds?.length ?? 0) +
@@ -4336,6 +4528,11 @@ export const generateVideo = {
4336
4528
  (input.styleAssetIds?.length ?? 0);
4337
4529
  const hasRefs = imageRefs + videoRefs > 0;
4338
4530
  const refCount = imageRefs + (hasRefs && input.firstFrameAssetId ? 1 : 0);
4531
+ // Only the lengths given; a missing one is asked for below, before the quote.
4532
+ const refSeconds = [
4533
+ ...(input.videoReferenceAssetId && input.videoReferenceSeconds != null ? [input.videoReferenceSeconds] : []),
4534
+ ...(input.videoReferenceSecondsEach ?? []),
4535
+ ];
4339
4536
  const shapeError = audioRefs > 0
4340
4537
  ? 'Omni Flash takes no audio references. Drop them, or switch to seedance-2.5 or wan-3.0, which read reference audio.'
4341
4538
  : hasRefs && input.lastFrameAssetId
@@ -4343,12 +4540,14 @@ export const generateVideo = {
4343
4540
  : input.lastFrameAssetId && !input.firstFrameAssetId
4344
4541
  ? 'Omni Flash needs a start frame (firstFrameAssetId) with a last frame.'
4345
4542
  : refCount > omniFlashRefCap
4346
- ? `Omni Flash takes at most ${omniFlashRefCap} reference images combined, a start frame included (you passed ${refCount}). Trim the list.`
4347
- : videoRefs > maxVideos
4348
- ? `Omni Flash takes at most ${maxVideos} reference videos (you passed ${videoRefs}).`
4349
- : [input.videoReferenceSeconds ?? 0, ...(input.videoReferenceSecondsEach ?? [])].some((d) => d > omniFlashRefClipMax + 0.05)
4350
- ? `Each Omni Flash reference video must be ${omniFlashRefClipMax}s or shorter. Trim it first with slates_trim_video.`
4351
- : null;
4543
+ ? `Omni Flash takes at most ${omniFlashRefCap} reference images combined (at most 3 of one character, 2 characters), a start frame included (you passed ${refCount}). Trim the list.`
4544
+ : checkReferenceShape(input.model, {
4545
+ duration: input.duration,
4546
+ lastFrame: !!input.lastFrameAssetId,
4547
+ referenceVideoCount: videoRefs,
4548
+ referenceVideoSeconds: refSeconds,
4549
+ label: 'Omni Flash',
4550
+ })?.replace('Trim it first.', 'Trim it first with slates_trim_video.') ?? null;
4352
4551
  if (shapeError) {
4353
4552
  return ok({ requires_clarification: true, missing: [], message: shapeError });
4354
4553
  }
@@ -4606,7 +4805,7 @@ export const generateVideo = {
4606
4805
  // Wan 3.0 bills reference video seconds on top of output seconds too, and
4607
4806
  // Omni Flash's per-clip cap needs every length to check.
4608
4807
  const isSeedance = input.model.startsWith('seedance');
4609
- const needsRefSeconds = isSeedance || input.model === 'wan-3.0' || input.model === 'omni-flash';
4808
+ const needsRefSeconds = isSeedance || input.model === 'wan-3.0' || input.model === 'omni-flash-1-2';
4610
4809
  if (input.videoReferenceAssetId && needsRefSeconds && !input.videoReferenceSeconds) {
4611
4810
  return ok({
4612
4811
  requires_clarification: true,
@@ -4623,6 +4822,9 @@ export const generateVideo = {
4623
4822
  message: `A Seedance or Wan 3.0 video reference bills on combined input+output seconds (on a Seedance 2.5 Face row, max(input, output) + output), and Omni Flash caps each clip at ${omniFlashRefClipMax}s. Pass videoReferenceSecondsEach with exactly ${pluralRefCount} duration${pluralRefCount === 1 ? '' : 's'}, in the same order as videoReferenceAssetIds (durations are shown in slates_list_assets), so the pre-flight quote matches the bill.`,
4624
4823
  });
4625
4824
  }
4825
+ // A desktop without Omni Flash 1.2 gets the 1.1 seat at the same price (`desktopModelId`), resolved before the
4826
+ // quote so a job it cannot run is refused before the agent is asked to confirm it.
4827
+ const seat = await desktopModelId(ctx.desktop(), input.model, `${input.model} generation`, input.duration);
4626
4828
  const cloud = ctx.cloud();
4627
4829
  const registry = await cloud.get('/api/agent/models');
4628
4830
  const costKey = input.model === 'minimax-h3-max'
@@ -4744,7 +4946,7 @@ export const generateVideo = {
4744
4946
  }
4745
4947
  const result = await desktop.post('/agent/generation/video', {
4746
4948
  projectId: input.projectId,
4747
- model: input.model,
4949
+ model: seat.model,
4748
4950
  prompt: input.prompt,
4749
4951
  aspectRatio: input.aspectRatio,
4750
4952
  duration: input.duration,
@@ -4786,6 +4988,7 @@ export const generateVideo = {
4786
4988
  const ids = result.generationIds ?? (result.generationId ? [result.generationId] : []);
4787
4989
  return backgroundSubmitted(`${input.duration}s ${input.model} video generation`, ids, {
4788
4990
  model: input.model,
4991
+ ...(seat.note ? { ranOn: seat.model } : {}),
4789
4992
  variant: costKey,
4790
4993
  projectId: input.projectId,
4791
4994
  cost_cents: totalCents,
@@ -4794,7 +4997,7 @@ export const generateVideo = {
4794
4997
  role,
4795
4998
  ...(resolvedRefs.get(ref) ?? { id: ref, code: null, label: null }),
4796
4999
  })),
4797
- }, refEcho);
5000
+ }, [refEcho, seat.note].filter(Boolean).join(' '));
4798
5001
  }
4799
5002
  return {
4800
5003
  text:
@@ -4805,9 +5008,11 @@ export const generateVideo = {
4805
5008
  `Generated ${input.duration}s ${input.model} video into project ${input.projectId} ` +
4806
5009
  `for ${fmtCredits(totalCents)}. ` +
4807
5010
  `Prompt: "${input.prompt.slice(0, 60)}${input.prompt.length > 60 ? '...' : ''}"` +
4808
- (refEcho ? ` ${refEcho}` : ''),
5011
+ (refEcho ? ` ${refEcho}` : '') +
5012
+ (seat.note ? ` ${seat.note}` : ''),
4809
5013
  data: {
4810
5014
  model: input.model,
5015
+ ...(seat.note ? { ranOn: seat.model } : {}),
4811
5016
  variant: costKey,
4812
5017
  projectId: input.projectId,
4813
5018
  aspectRatio: input.aspectRatio,
@@ -5373,7 +5578,7 @@ export const editVideo = {
5373
5578
  input: z.object({
5374
5579
  projectId: z.string().uuid().describe('Project the source clip lives in.'),
5375
5580
  sourceVideoAssetId: z.string().describe('The VIDEO asset to edit — UUID or badge code ("VID-V3", bare "V3"); codes resolve against the project at call time. Clip-length windows per engine are on `model`.'),
5376
- prompt: z.string().min(1).max(2500).describe('The change, not the whole scene — e.g. "replace the man with @marcus", "make it a rainy night", "turn the street into a neon Tokyo alley". Mention subjects with @name; the transport compiles them to Kling\'s @ElementN notation (Kling models). For omni-flash-edit keep it simple and add "Keep everything else the same."'),
5581
+ prompt: z.string().min(1).max(2500).describe('The change, not the whole scene — e.g. "replace the man with @marcus", "make it a rainy night", "turn the street into a neon Tokyo alley". Mention subjects with @name; the transport compiles them to Kling\'s @ElementN notation (Kling models). For omni-flash-1-2-edit keep it simple and add "Keep everything else the same."'),
5377
5582
  // Clip windows and resolutions GENERATED from MODEL_CAPABILITIES.
5378
5583
  model: zEnum(EDIT_VIDEO_MODELS).optional().describe(
5379
5584
  // Routing GENERATED from MODEL_FACTS; the paragraph that stood here was
@@ -5384,8 +5589,8 @@ export const editVideo = {
5384
5589
  `Source-clip length per engine: ${describeDurations(EDIT_VIDEO_MODELS)}. Output resolution: ${describeVideoResolutions(EDIT_VIDEO_MODELS)}`),
5385
5590
  characterAssetIds: z.array(z.string()).max(EDIT_VIDEO_ELEMENT_CAP).optional().describe('Subject/element image assets to swap IN (UUIDs or badge codes). Each becomes an element (@ElementN). ' + EDIT_VIDEO_ELEMENTS_ONLY),
5386
5591
  styleAssetIds: z.array(z.string()).max(EDIT_VIDEO_ELEMENT_CAP).optional().describe(`Style/appearance reference images (@ImageN). Max ${EDIT_VIDEO_ELEMENT_CAP} combined with characterAssetIds. ` + EDIT_VIDEO_ELEMENTS_ONLY),
5387
- keepAudio: z.boolean().optional().describe('Preserve the original audio track (default true; Kling models only — omni-flash-edit and seedance-2.5-edit output carry their own audio).'),
5388
- videoResolution: zEnum(EDIT_VIDEO_RESOLUTIONS).optional().describe(`seedance-2.5-edit (default ${defaultVideoResolutionFor('seedance-2.5-edit')}) and omni-flash-edit (default ${defaultVideoResolutionFor('omni-flash-edit')}; its 1080p and 4K are upscales). Ignored by the Kling engines, whose output follows the source clip.`),
5592
+ keepAudio: z.boolean().optional().describe('Preserve the original audio track (default true; Kling models only — omni-flash-1-2-edit and seedance-2.5-edit output carry their own audio).'),
5593
+ videoResolution: zEnum(EDIT_VIDEO_RESOLUTIONS).optional().describe(`seedance-2.5-edit (default ${defaultVideoResolutionFor('seedance-2.5-edit')}) and omni-flash-1-2-edit (default ${defaultVideoResolutionFor('omni-flash-1-2-edit')}; its 1080p and 4K are upscales). Ignored by the Kling engines, whose output follows the source clip.`),
5389
5594
  seedanceFace: z.boolean().optional().describe(`seedance-2.5-edit ONLY: set true when a CHARACTER FACE is visible in the clip. Without it a face is blocked outright; with it the edit is priced higher: quote it with slates_estimate_generation_cost by its cost key as model (${seedanceEditCostKey({ duration: SEEDANCE_25_EDIT_MIN_SECONDS, videoResolution: defaultVideoResolutionFor('seedance-2.5-edit'), seedanceFace: true })} for ${SEEDANCE_25_EDIT_MIN_SECONDS}s at ${defaultVideoResolutionFor('seedance-2.5-edit')}). A face edit submitted without this flag is rejected, not silently downgraded.`),
5390
5595
  background: z.boolean().optional().describe(BACKGROUND_DESCRIBE),
5391
5596
  confirm: z.boolean().optional().describe(CONFIRM_PARAM),
@@ -5402,10 +5607,10 @@ export const editVideo = {
5402
5607
  }
5403
5608
  const model = input.model ?? EDIT_VIDEO_DEFAULT;
5404
5609
  requireGuideRead(ctx, model);
5405
- const isOmniFlashEdit = model === 'omni-flash-edit';
5610
+ const isOmniFlashEdit = model === 'omni-flash-1-2-edit';
5406
5611
  const isSeedanceEdit = model === 'seedance-2.5-edit';
5407
5612
  // Source-clip window, read from the capability SSOT per engine — never a
5408
- // model-id ternary. (Kling 3–15s, Omni Flash 3–10s, Seedance 2.5 4–30s.)
5613
+ // model-id ternary. (Kling 3–15s, Omni Flash 1.2 3–15s, Seedance 2.5 4–30s.)
5409
5614
  const { min: minClipSeconds, max: maxClipSeconds } = editClipBounds(model);
5410
5615
  if (!EDIT_VIDEO_ELEMENT_MODELS.includes(model) && ((input.characterAssetIds?.length ?? 0) > 0 || (input.styleAssetIds?.length ?? 0) > 0)) {
5411
5616
  throw new Error(`${model} takes the prompt and the source clip only on this op — no character/style reference images. Drop the refs, or switch to ${EDIT_VIDEO_ELEMENT_MODELS.join(' or ')}, which take them.`);
@@ -5443,6 +5648,9 @@ export const editVideo = {
5443
5648
  (maxClipSeconds < SEEDANCE_25_EDIT_MAX_SECONDS ? ', or switch to seedance-2.5-edit which accepts up to 30s' : '') +
5444
5649
  '.');
5445
5650
  }
5651
+ // A desktop without Omni Flash 1.2 gets the 1.1 edit seat at the same price, on a clip 1.1 takes
5652
+ // (`desktopModelId`), resolved before the quote so a job it cannot run is refused before the agent confirms it.
5653
+ const seat = await desktopModelId(desktop, model, `${model} editing`, clipSeconds);
5446
5654
  const billedSeconds = Math.min(maxClipSeconds, Math.max(minClipSeconds, Math.ceil(clipSeconds - 0.05)));
5447
5655
  // Three engines, three key shapes — only Seedance's carries a resolution and
5448
5656
  // a face route, because only its price moves with them.
@@ -5456,7 +5664,7 @@ export const editVideo = {
5456
5664
  seedanceFace: input.seedanceFace === true,
5457
5665
  })
5458
5666
  : isOmniFlashEdit
5459
- ? omniFlashEditCostKey(billedSeconds, (input.videoResolution ?? defaultVideoResolutionFor('omni-flash-edit')))
5667
+ ? omniFlashEditCostKey(billedSeconds, (input.videoResolution ?? defaultVideoResolutionFor('omni-flash-1-2-edit')))
5460
5668
  : klingEditCostKey(model, billedSeconds);
5461
5669
  const cloud = ctx.cloud();
5462
5670
  const registry = await cloud.get('/api/agent/models');
@@ -5491,7 +5699,7 @@ export const editVideo = {
5491
5699
  }
5492
5700
  const result = await desktop.post('/agent/generation/edit-video', {
5493
5701
  projectId: input.projectId,
5494
- model,
5702
+ model: seat.model,
5495
5703
  prompt: input.prompt,
5496
5704
  sourceVideoAssetId: sourceId,
5497
5705
  characterAssetIds,
@@ -5508,20 +5716,23 @@ export const editVideo = {
5508
5716
  const ids = result.generationId ? [result.generationId] : [];
5509
5717
  return backgroundSubmitted(`${billedSeconds}s video edit (${model})`, ids, {
5510
5718
  model,
5719
+ ...(seat.note ? { ranOn: seat.model } : {}),
5511
5720
  variant: costKey,
5512
5721
  projectId: input.projectId,
5513
5722
  sourceVideoAssetId: sourceId,
5514
5723
  cost_cents: totalCents,
5515
5724
  cost_credits: totalCents,
5516
- }, refEcho);
5725
+ }, [refEcho, seat.note].filter(Boolean).join(' '));
5517
5726
  }
5518
5727
  return {
5519
5728
  text: `Edited ${billedSeconds}s clip saved as a new asset in project ${input.projectId} ` +
5520
5729
  `for ${fmtCredits(totalCents)} via ${model}. ` +
5521
5730
  `Edit: "${input.prompt.slice(0, 60)}${input.prompt.length > 60 ? '...' : ''}"` +
5522
- (refEcho ? ` ${refEcho}` : ''),
5731
+ (refEcho ? ` ${refEcho}` : '') +
5732
+ (seat.note ? ` ${seat.note}` : ''),
5523
5733
  data: {
5524
5734
  model,
5735
+ ...(seat.note ? { ranOn: seat.model } : {}),
5525
5736
  variant: costKey,
5526
5737
  projectId: input.projectId,
5527
5738
  sourceVideoAssetId: sourceId,
@@ -7397,13 +7608,15 @@ export const breakDownReference = {
7397
7608
  throw new Error('Give exactly one of assetId (a video or picture in the project), filePath or url.');
7398
7609
  }
7399
7610
  const assetId = input.assetId ? (await resolveAssetRefs(ctx, input.projectId, [input.assetId])).get(input.assetId).id : input.assetId;
7400
- const r = await ctx.desktop().post('/agent/reference/breakdown', { ...input, assetId, cancel: undefined });
7611
+ // Every Shot is stored under this id, as the desktop knows it (`desktopModelId`).
7612
+ const seat = await desktopModelId(ctx.desktop(), input.model, `a breakdown's Shots on ${input.model}`);
7613
+ const r = await ctx.desktop().post('/agent/reference/breakdown', { ...input, assetId, model: seat.model, cancel: undefined });
7401
7614
  const cuts = r.breakdown.segments.length;
7402
7615
  const fetched = r.source ? `Fetched the ${r.source.kind === 'meta' ? 'Meta Ad Library ad' : 'video link'} into Media as ${r.breakdown.sourceCode ?? 'a video'}. ` : '';
7403
7616
  const head = r.board
7404
7617
  ? `Board ${r.board.storyboardId} built: ${r.board.shotCodes.length} Shot${r.board.shotCodes.length === 1 ? '' : 's'} (${r.board.shotCodes.join(', ')}), nothing generated.${r.board.timing.length ? ` Timing: ${r.board.timing.join(' ')}` : ''}`
7405
7618
  : `${cuts} cut${cuts === 1 ? '' : 's'} found in ${r.breakdown.sourceCode ?? 'the reference'}; frames saved, no board yet.`;
7406
- return ok(r, `${fetched}${head} ${JSON.stringify(r)}`);
7619
+ return ok(r, `${seat.note ? `${seat.note} ` : ''}${fetched}${head} ${JSON.stringify(r)}`);
7407
7620
  },
7408
7621
  };
7409
7622
  // ── Product intake ──────────────────────────────────────────────────────
@@ -7842,6 +8055,8 @@ function shotRefInputs(input) {
7842
8055
  * something else entirely.
7843
8056
  */
7844
8057
  async function buildShotSpecInput(ctx, projectId, input) {
8058
+ // The Shot is stored and drafted on the desktop under this id (`desktopModelId`).
8059
+ const seat = await desktopModelId(ctx.desktop(), input.model, `a Shot on ${input.model}`, input.params?.duration);
7845
8060
  const refInputs = shotRefInputs(input);
7846
8061
  const resolvedRefs = await resolveAssetRefs(ctx, projectId, refInputs.map((r) => r.ref));
7847
8062
  const rid = (v) => (v ? (resolvedRefs.get(v)?.id ?? v) : null);
@@ -7862,11 +8077,11 @@ async function buildShotSpecInput(ctx, projectId, input) {
7862
8077
  return {
7863
8078
  spec: {
7864
8079
  prompt: input.prompt,
7865
- model: input.model ?? null,
8080
+ model: seat.model ?? null,
7866
8081
  // The prompt is recorded as written FOR this model. Swapping the model
7867
8082
  // later diverges from it and the desktop card says so — the prompt is
7868
8083
  // never rewritten (that is prompt enhancement, deleted 2026-08-01).
7869
- authoredFor: input.model ?? null,
8084
+ authoredFor: seat.model ?? null,
7870
8085
  params: {
7871
8086
  ...shotParamsPatch(input.params),
7872
8087
  ...(input.params?.voiceReferenceAssetId ? { voiceReferenceAssetId: rid(input.params.voiceReferenceAssetId) } : {}),
@@ -7882,6 +8097,7 @@ async function buildShotSpecInput(ctx, projectId, input) {
7882
8097
  audioRefSpokenText: spoken,
7883
8098
  },
7884
8099
  refEcho: describeResolvedRefs(refInputs, resolvedRefs),
8100
+ seatNote: seat.note,
7885
8101
  };
7886
8102
  }
7887
8103
  /**
@@ -7894,7 +8110,8 @@ function namedSpecPatch(input, spec) {
7894
8110
  if (input.prompt !== undefined)
7895
8111
  patch.prompt = input.prompt;
7896
8112
  if (input.model !== undefined) {
7897
- patch.model = input.model;
8113
+ // The built id: the one this desktop knows (`desktopModelId`).
8114
+ patch.model = spec.model;
7898
8115
  // 🚨 `authoredFor` is NOT re-stamped on a model swap. The whole point of
7899
8116
  // recording it is that the prompt stays written for the model it was
7900
8117
  // written for — the grammars genuinely differ — so the card can say so.
@@ -8008,7 +8225,7 @@ export const createShot = {
8008
8225
  // 1.5.8 ignores `position` and files the Shot last.
8009
8226
  if (input.position !== undefined)
8010
8227
  await desktop.requireCapability('shot-position', 'placing a new Shot at a slot');
8011
- const { spec, refEcho } = await buildShotSpecInput(ctx, input.projectId, input);
8228
+ const { spec, refEcho, seatNote } = await buildShotSpecInput(ctx, input.projectId, input);
8012
8229
  const r = await desktop.post('/agent/shots', {
8013
8230
  projectId: input.projectId,
8014
8231
  name: input.name,
@@ -8038,7 +8255,7 @@ export const createShot = {
8038
8255
  });
8039
8256
  // The CODE is the address the user sees on the row — say it back so the
8040
8257
  // next call, and the next sentence to the user, can point at it.
8041
- return ok(r.shot, `${r.shot?.code || 'Shot'} — "${r.shot?.name || 'Untitled'}". ${refEcho}${fromNote}`.trim() + varietyNote);
8258
+ return ok(r.shot, `${r.shot?.code || 'Shot'} — "${r.shot?.name || 'Untitled'}". ${refEcho}${fromNote}${seatNote ? ` ${seatNote}` : ''}`.trim() + varietyNote);
8042
8259
  },
8043
8260
  };
8044
8261
  /**
@@ -8104,7 +8321,7 @@ export const updateShot = {
8104
8321
  return alignErr;
8105
8322
  const desktop = ctx.desktop();
8106
8323
  await desktop.requireCapability('shots', 'saved Shots');
8107
- const { spec } = await buildShotSpecInput(ctx, input.projectId, input);
8324
+ const { spec, seatNote } = await buildShotSpecInput(ctx, input.projectId, input);
8108
8325
  // Only send the halves the caller actually named; the route merges a PARTIAL
8109
8326
  // spec over the stored one, so an omitted field is never silently cleared.
8110
8327
  const patch = namedSpecPatch(input, spec);
@@ -8121,7 +8338,7 @@ export const updateShot = {
8121
8338
  // An edit to framing changes the counts, and the agent read them BEFORE it
8122
8339
  // (agent eval round 11: two runs fixed a repeat and never saw the new counts).
8123
8340
  const varietyNote = await boardSoFar(desktop, { projectId: input.projectId, shotId: r.shot?.id });
8124
- return ok(r.shot, JSON.stringify(r.shot) + varietyNote);
8341
+ return ok(r.shot, JSON.stringify(r.shot) + (seatNote ? `\n${seatNote}` : '') + varietyNote);
8125
8342
  },
8126
8343
  };
8127
8344
  export const duplicateShot = {
@@ -8146,8 +8363,9 @@ export const duplicateShot = {
8146
8363
  const spec = {};
8147
8364
  if (input.prompt !== undefined)
8148
8365
  spec.prompt = input.prompt;
8366
+ const seat = await desktopModelId(desktop, input.model, `a Shot on ${input.model}`, input.params?.duration);
8149
8367
  if (input.model !== undefined)
8150
- spec.model = input.model;
8368
+ spec.model = seat.model;
8151
8369
  if (input.params !== undefined) {
8152
8370
  const voiceRef = input.params.voiceReferenceAssetId;
8153
8371
  if (voiceRef && !UUID_RE.test(voiceRef)) {
@@ -8165,7 +8383,7 @@ export const duplicateShot = {
8165
8383
  ...(Object.keys(spec).length > 0 ? { spec } : {}),
8166
8384
  frameId: input.frameId,
8167
8385
  });
8168
- return ok(r.shot, `Forked into "${r.shot?.name || 'Untitled'}".`);
8386
+ return ok(r.shot, `Forked into "${r.shot?.name || 'Untitled'}".${seat.note ? ` ${seat.note}` : ''}`);
8169
8387
  },
8170
8388
  };
8171
8389
  /**
@@ -8736,8 +8954,9 @@ export const generateFromShots = {
8736
8954
  await desktop.requireCapability('board-quote', 'Shot prices');
8737
8955
  // Resolved first so a SHOT-A code fails here, not halfway through a billed run.
8738
8956
  const details = await Promise.all(input.shotIds.map((id) => desktop.get('/agent/shots/get', { id })));
8957
+ const { draft, note: seatNote } = await desktopDraft(desktop, input.draft);
8739
8958
  const quote = await desktop.get('/agent/shots/quote', {
8740
- input: JSON.stringify({ projectId: details[0].shot.projectId, shotIds: details.map((d) => d.shot.id), draft: input.draft }),
8959
+ input: JSON.stringify({ projectId: details[0].shot.projectId, shotIds: details.map((d) => d.shot.id), draft }),
8741
8960
  });
8742
8961
  for (const model of new Set(quote.items.map((i) => i.model)))
8743
8962
  requireGuideRead(ctx, model);
@@ -8753,13 +8972,15 @@ export const generateFromShots = {
8753
8972
  // Printed, not only in `data`: a client without elicitation reads this text
8754
8973
  // alone, and the confirm step refuses without the fingerprint (agent eval, round 9).
8755
8974
  `\nfingerprint: ${quote.fingerprint}` +
8756
- '\nGet approval for these prices, then pass this fingerprint with confirm: true.');
8975
+ '\nGet approval for these prices, then pass this fingerprint with confirm: true.' +
8976
+ (seatNote ? `\n${seatNote}` : ''));
8757
8977
  }
8758
- return ok(await desktop.post('/agent/shots/batch-generate', {
8978
+ const ran = await desktop.post('/agent/shots/batch-generate', {
8759
8979
  shotIds: quote.items.map((i) => i.shotId),
8760
8980
  fingerprint: quote.fingerprint,
8761
- draft: input.draft,
8762
- }));
8981
+ draft,
8982
+ });
8983
+ return seatNote ? ok(ran, `${JSON.stringify(ran)}\n${seatNote}`) : ok(ran);
8763
8984
  },
8764
8985
  };
8765
8986
  export const quoteBoard = {
@@ -8774,8 +8995,11 @@ export const quoteBoard = {
8774
8995
  draft: DRAFT_INPUT.describe('Generate previews: pass {} to price one picture for each Shot in scope with no picture, instead of each Shot recipe.'),
8775
8996
  }),
8776
8997
  async run(input, ctx) {
8777
- await ctx.desktop().requireCapability('board-quote', 'the board prices');
8778
- return ok(await ctx.desktop().get('/agent/shots/quote', { input: JSON.stringify(input) }));
8998
+ const desktop = ctx.desktop();
8999
+ await desktop.requireCapability('board-quote', 'the board prices');
9000
+ const { draft, note } = await desktopDraft(desktop, input.draft);
9001
+ const quote = await desktop.get('/agent/shots/quote', { input: JSON.stringify({ ...input, draft }) });
9002
+ return note ? ok(quote, `${JSON.stringify(quote)}\n${note}`) : ok(quote);
8779
9003
  },
8780
9004
  };
8781
9005
  export const getBoardProgress = {
@@ -8913,11 +9137,11 @@ export function resolveGuideTopic(topic) {
8913
9137
  if (t.startsWith('nano-banana'))
8914
9138
  return 'slates-prompting-nano-banana-2-1';
8915
9139
  if (t === 'sunburst' || t === 'flare' || t.startsWith('gpt-image') || t.startsWith('gpt image'))
8916
- return 'slates-prompting-gpt-image-2-5';
9140
+ return 'slates-prompting-gpt-image-2-6';
8917
9141
  if (t.startsWith('flux'))
8918
9142
  return 'slates-prompting-flux-3';
8919
9143
  if (t.startsWith('seedream'))
8920
- return 'slates-prompting-seedream-5-lite';
9144
+ return 'slates-prompting-seedream-5-5';
8921
9145
  if (t.startsWith('omni-flash') || t.startsWith('gemini-omni') || t === 'omni flash')
8922
9146
  return 'slates-prompting-omni-flash';
8923
9147
  if (t.startsWith('wan') || t === 'alibaba-wan-3.0')
@@ -9017,6 +9241,35 @@ function editDistance(a, b) {
9017
9241
  }
9018
9242
  return d[a.length][b.length];
9019
9243
  }
9244
+ /**
9245
+ * The seat that replaced a retired model a topic names, or null. The topic is a model id or a guide name
9246
+ * (`gpt-image-2-5-sunburst`, `gpt-image-2-5`, `slates-prompting-gpt-image-2-5`); it names a retired model
9247
+ * when it is a retired id, or a stem of retired ids that no current id shares (`gpt-image-2-5`, never
9248
+ * `flux` or `nano-banana`). The guide op serves the replacement's guide and says so first, as it does for
9249
+ * a typo: an agent asking for the 2.5 guide learns 2.5 is gone, not that 2.6 is what it asked for.
9250
+ *
9251
+ * A stem covering several seats names their family (`gpt-image-2-6`), never one of them. A topic under the
9252
+ * stem of its replacement's own guide is that guide, not a retired model: `omni-flash` is the retired 1.1 id
9253
+ * and also the name of the live `slates-prompting-omni-flash`, so it and `omni-flash-edit` are null.
9254
+ */
9255
+ export function retiredModelOfTopic(topic) {
9256
+ const core = topic.trim().toLowerCase().replace(/^(slates-)?prompting-/, '');
9257
+ const under = (id) => id === core || id.startsWith(`${core}-`);
9258
+ const retiredIds = Object.hasOwn(RETIRED_MODELS, core) ? [core]
9259
+ : Object.keys(MODEL_CAPABILITIES).some(under) ? []
9260
+ : Object.keys(RETIRED_MODELS).filter(under);
9261
+ if (retiredIds.length === 0)
9262
+ return null;
9263
+ const seats = [...new Set(retiredIds.map(id => RETIRED_MODELS[id]))].map(id => id.split('-'));
9264
+ let common = 0;
9265
+ while (common < seats[0].length && seats.every(seat => seat[common] === seats[0][common]))
9266
+ common++;
9267
+ const replacement = seats[0].slice(0, common || seats[0].length).join('-');
9268
+ const stem = resolveGuideTopic(replacement)?.replace(/^slates-prompting-/, '');
9269
+ if (stem && (core === stem || core.startsWith(`${stem}-`)))
9270
+ return null;
9271
+ return { retired: core, replacement };
9272
+ }
9020
9273
  /**
9021
9274
  * The one guide a near-miss name means: the name without its `slates-` prefix, or a typo of one name
9022
9275
  * ("slaes-direct-response-ad"). Two names equally close come back as `tied`, for the caller to name rather
@@ -9157,6 +9410,14 @@ export const getPromptingGuide = {
9157
9410
  const guide = `${hyperframesGuideHeader(hf.key)}${body}${others.length ? `\n\nIts other files (request each as a topic): ${others.join(', ')}` : ''}`;
9158
9411
  return { text: guide, data: { topic: hf.key, tier: 'free', source: 'motion', depth, bytes: Buffer.byteLength(guide, 'utf8'), guide } };
9159
9412
  }
9413
+ // A retired model serves its replacement's guide, said first (retiredModelOfTopic).
9414
+ const retiredTopic = topic && !Object.hasOwn(brain.skills, topic) ? retiredModelOfTopic(topic) : null;
9415
+ const replacementGuide = retiredTopic ? resolveGuideTopic(retiredTopic.replacement) : null;
9416
+ // Never back to the topic asked: a replacement guide that is the asked topic falls through to it.
9417
+ if (retiredTopic && replacementGuide && replacementGuide !== topic) {
9418
+ const served = await getPromptingGuide.run({ ...input, topic: replacementGuide }, ctx);
9419
+ return { ...served, text: `${retiredTopic.retired} is retired and ${retiredTopic.replacement} replaced it: served ${replacementGuide}.\n\n${served.text}` };
9420
+ }
9160
9421
  // The user's file by its exact name wins over an alias (their `flux-portraits` is theirs, not the FLUX guide);
9161
9422
  // the router's names are reserved in the loader, so none of them reaches here as a local file. A name missing
9162
9423
  // its `slates-` prefix is that guide, resolved here so it never waits on the member check.