@slatesvideo/shared 0.7.22 → 0.7.23

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.
@@ -48,7 +48,7 @@ toolModelFor, CHATGPT_FRAMING_RATIOS, } from '../prompts/model-facts.js';
48
48
  // quoted for a model at 1080p that only took 8s there. A customer burned a
49
49
  // round trip on `4:5` + Seedance: accepted here, queued, credits reserved,
50
50
  // rejected by the provider asynchronously.
51
- import { AGENT_ROUTE_PROVIDER, defaultImageResolutionFor, aspectRatioUnion, videoResolutionUnion, durationBounds, aspectRatiosFor, getModelCapability, defaultVideoResolutionFor, maxIngredientImagesFor, maxReferenceVideosFor, checkAspectRatio, checkVideoResolution, describeAspectRatios, describeVideoResolutions, describeDurations, describeReferenceImageCaps, } from '../prompts/model-capabilities.js';
51
+ import { AGENT_ROUTE_PROVIDER, defaultImageResolutionFor, aspectRatioUnion, videoResolutionUnion, durationBounds, aspectRatioApplies, promptLengthError, promptLengthFor, videoPromptError, aspectRatiosFor, getModelCapability, defaultVideoResolutionFor, maxIngredientImagesFor, maxReferenceVideosFor, checkAspectRatio, checkVideoResolution, describeAspectRatios, describeVideoResolutions, describeDurations, describeReferenceImageCaps, } from '../prompts/model-capabilities.js';
52
52
  // Per-model warnings are extracted from skill @banned blocks. They ride the
53
53
  // selected model's estimate and submitted-prompt result, never another model's schema.
54
54
  import { describeBannedTokens, bannedTokenWarning, describeBannedTokensForSkill, } from '../prompts/banned-tokens.js';
@@ -952,7 +952,7 @@ function describeComposer(r) {
952
952
  ? `a draft from ${r.draftFrom.code ?? r.draftFrom.assetId}`
953
953
  : 'an unsaved draft';
954
954
  lines.push(`Prompt box (${r.open ? 'showing' : 'hidden'}), ${r.lane} lane, ${r.model.label}${r.destination === 'chatgpt' ? ' (ChatGPT)' : ''}; ${where}.`);
955
- lines.push(`Words (${r.prompt.length}${r.promptMax ? `/${r.promptMax}` : ''}): ${r.prompt ? JSON.stringify(r.prompt) : 'none'}`);
955
+ lines.push(`Words (${promptLengthFor(r.model.id, r.prompt)}${r.promptMax ? `/${r.promptMax}` : ''}): ${r.prompt ? JSON.stringify(r.prompt) : 'none'}`);
956
956
  if (r.params.length)
957
957
  lines.push(`Settings: ${r.params.map((p) => `${p.label} ${p.value || '(none)'}`).join(' · ')}`);
958
958
  if (r.tiles.length) {
@@ -1751,6 +1751,10 @@ export const VIDEO_MODELS = [
1751
1751
  // start and end frames OR references (10 images, 5 videos, 5 audio clips).
1752
1752
  // Reference video seconds bill on top of output seconds, so it has a vref key.
1753
1753
  'wan-3.0',
1754
+ // MAGI-2 (added 2026-11-26): 4-30s at 1080p only, sound on or off, start and
1755
+ // end frames OR references (10 images, 5 videos, 5 audio clips). One price per
1756
+ // output second: references and sound do not move it.
1757
+ 'magi-2',
1754
1758
  // Kling 4.0 (added 2026-10-23 beside 3.0, which stays the default Kling):
1755
1759
  // one row with no Standard/Pro split, frames or text only, sound always on.
1756
1760
  // `kling-v4.0` never starts with `kling-v3.0`, so no 3.0 branch can take it.
@@ -1876,9 +1880,10 @@ function editClipBounds(model) {
1876
1880
  const EDIT_VIDEO_RESOLUTIONS = videoResolutionUnion(['seedance-2.5-edit', 'omni-flash-1-2-edit']);
1877
1881
  export const estimateGenerationCost = {
1878
1882
  id: 'slates_estimate_generation_cost',
1879
- 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.',
1883
+ description: 'Quote credits before generating. For saved Shots, boards and scenes use slates_get_board_quote. Pass a model id and settings or an exact cost key (required for non-Kling edits, lip sync and motion transfer). Show the total and wait for approval. Returns the model card and requires_confirm above the threshold.',
1880
1884
  input: z.object({
1881
- model: z.string().describe('Base model id as passed to the generate op (e.g. "seedance-2", "kling-v3.0-std", "nano-banana-2-1") or an exact registry cost key ("nano-banana-2-1-2k", "seedance-2-1080p-8s")'),
1885
+ model: z.string().describe('Generation model id (e.g. "seedance-2") or exact cost key (e.g. "seedance-2-1080p-8s").'),
1886
+ prompt: z.string().optional().describe('Check prompt length before quoting.'),
1882
1887
  quantity: z.number().int().min(1).max(10).optional().describe('Number of generations (default 1)'),
1883
1888
  // Video windows and resolutions GENERATED from MODEL_CAPABILITIES. The
1884
1889
  // hand-typed "Video 3-15" here was wrong the day seedance-2.5 (4-30s)
@@ -1905,6 +1910,9 @@ export const estimateGenerationCost = {
1905
1910
  referenceImages: z.number().int().min(0).optional().describe(`MiniMax H3 and seedream-5-5: how many reference IMAGES the generation carries. A paid dimension of the cost key: a quote without it 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. minimax-h3 gives ${MINIMAX_FREE_REF_IMAGES_BY_MODEL['minimax-h3']} free, minimax-h3-max ${MINIMAX_FREE_REF_IMAGES_BY_MODEL['minimax-h3-max']}; start/end frames are free and are not reference images. Ignored by every other model.`),
1906
1911
  }),
1907
1912
  async run(input, ctx) {
1913
+ const lengthError = promptLengthError(resolveVideoModel(input.model)?.model ?? input.model, input.prompt);
1914
+ if (lengthError)
1915
+ throw new Error(lengthError);
1908
1916
  // A retired seat is never quoted: its keys still bill older desktops, and `nano-banana-2-1k` (the
1909
1917
  // retired Nano Banana 2 at 1K) would otherwise answer an agent that meant Nano Banana 2.1.
1910
1918
  const retired = retiredModelOfKey(input.model);
@@ -3440,7 +3448,7 @@ export const generateImage = {
3440
3448
  // demonstrably skipped the call that would have taught it.
3441
3449
  describeBannedTokens('image'),
3442
3450
  input: z.object({
3443
- prompt: z.string().min(1).max(4000),
3451
+ prompt: z.string().min(1),
3444
3452
  // Routing GENERATED from MODEL_FACTS.
3445
3453
  model: zEnum(IMAGE_MODELS).optional().describe(`Image model. Omitted: ${DEFAULT_IMAGE_MODEL} with projectId, ${HEADLESS_IMAGE_MODEL} (the only headless seat) without.\n` +
3446
3454
  `${describeRouting('image')}\n` +
@@ -3475,6 +3483,9 @@ export const generateImage = {
3475
3483
  ? await defaultImageSeatFor(() => ctx.desktop(), input.model, `${input.model ?? DEFAULT_IMAGE_MODEL} generation`)
3476
3484
  : { model: input.model ?? HEADLESS_IMAGE_MODEL, note: '' };
3477
3485
  const imageModel = seat.model;
3486
+ const lengthError = promptLengthError(imageModel, input.prompt);
3487
+ if (lengthError)
3488
+ throw new Error(lengthError);
3478
3489
  const dropped = droppedImageParams(imageModel, input);
3479
3490
  if (dropped)
3480
3491
  return ok(dropped);
@@ -3958,7 +3969,7 @@ export const editImage = {
3958
3969
  input: z.object({
3959
3970
  projectId: z.string().uuid(),
3960
3971
  sourceAssetId: z.string().uuid().describe('Image asset to edit. Must exist in the project. ' + ASSET_UUID_ONLY),
3961
- 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.'),
3972
+ prompt: z.string().min(1).describe('The change, not the whole image. @name and #look words attach nothing here: pass those pictures in referenceAssetIds.'),
3962
3973
  editModel: zEnum(IMAGE_MODELS).optional(),
3963
3974
  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(', ')}.`),
3964
3975
  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(', ')}.`),
@@ -3982,6 +3993,9 @@ export const editImage = {
3982
3993
  ? await defaultImageSeatFor(() => desktop, undefined, 'image editing')
3983
3994
  : { model: toolModelFor('image-edit'), note: '' };
3984
3995
  const editModel = seat.model;
3996
+ const lengthError = promptLengthError(editModel, input.prompt);
3997
+ if (lengthError)
3998
+ throw new Error(lengthError);
3985
3999
  const resolution = input.resolution ?? defaultImageResolutionFor(editModel);
3986
4000
  // The same gates as slates_generate_image, from the same functions.
3987
4001
  const refusal = droppedImageParams(editModel, input) ??
@@ -4391,6 +4405,12 @@ export function videoCostKey(input) {
4391
4405
  }
4392
4406
  return `wan-3.0-${res}-${input.duration}s`;
4393
4407
  }
4408
+ if (input.model === 'magi-2') {
4409
+ // Mirrors magiCreditKey() in slate/src/shared/pricing.ts. One resolution
4410
+ // and one rate per output second on every endpoint: references, sound and
4411
+ // frames do not move the price, so the key is the length alone.
4412
+ return `magi-2-1080p-${input.duration}s`;
4413
+ }
4394
4414
  throw new Error(`Unknown video model: ${input.model}`);
4395
4415
  }
4396
4416
  // Kling O3 video-to-video edit cost key — mirrors klingEditCreditKey() in
@@ -4611,6 +4631,9 @@ function resolveVideoModel(raw) {
4611
4631
  'hailuo-3': 'minimax-h3',
4612
4632
  'hailuo-3.0': 'minimax-h3',
4613
4633
  hailuo: 'minimax-h3',
4634
+ magi: 'magi-2',
4635
+ magi2: 'magi-2',
4636
+ 'magi-2.0': 'magi-2',
4614
4637
  };
4615
4638
  if (aliases[s]) {
4616
4639
  out.model = aliases[s];
@@ -4700,14 +4723,14 @@ export const generateVideo = {
4700
4723
  billable: true,
4701
4724
  description: 'Generate video via Slates credits. Choose the model with slates-model-selection. Video models prompt very differently: the estimate returns the chosen model\'s prompting card, and its full guide (' +
4702
4725
  VIDEO_MODEL_GUIDES +
4703
- ') covers modes the card leaves out, via slates_get_prompting_guide. Read slates-content-policy when the scene involves conflict, creatures, crowds, destruction, weapons, or young characters. projectId, aspectRatio, and duration are required (requires_clarification otherwise). ' +
4726
+ ') covers modes the card leaves out, via slates_get_prompting_guide. Read slates-content-policy when the scene involves conflict, creatures, crowds, destruction, weapons, or young characters. projectId and duration are required, plus aspectRatio when the endpoint takes it (requires_clarification otherwise). ' +
4704
4727
  confirmGateSentence('any image reference (frame, ingredient, character, environment or style)') +
4705
4728
  ' Image-to-video via firstFrameAssetId; a last frame via lastFrameAssetId and ingredients via ingredientAssetIds, each param stating which models take it. Asset params take UUIDs or badge codes ("IMG-A8"). ' +
4706
4729
  // GENERATED from the skill's own slop-token list. Always in context on both
4707
4730
  // surfaces, so it survives an agent that skips slates_get_prompting_guide.
4708
4731
  describeBannedTokens('video'),
4709
4732
  input: z.object({
4710
- prompt: z.string().min(1).max(4000),
4733
+ prompt: z.string().optional().describe("Optional when the selected model can animate a start frame on its own."),
4711
4734
  // ROUTING doctrine only. Every capability number was stripped on 2026-08-16
4712
4735
  // and now lives in the aspectRatio / duration / videoResolution descriptions
4713
4736
  // below, generated from MODEL_CAPABILITIES. "16:9 only" for a model and
@@ -4758,7 +4781,7 @@ export const generateVideo = {
4758
4781
  videoReferenceSecondsEach: z.array(z.number()).optional().describe("Each clip's duration in seconds (slates_list_assets shows it), same order and length as videoReferenceAssetIds. The desktop measures every clip for the quote; a desktop before that needs these."),
4759
4782
  audioReferenceAssetIds: z.array(z.string()).optional().describe(`Reference AUDIO, cited as "audio 1", "audio 2"… in the order given. ${multimodalRefModels().join(' / ')} only. No surcharge on Seedance; on H3 Max, audio counts toward the reference-token pool. ${multimodalRefModels().map(multimodalRefSummary).join(' ')}`),
4760
4783
  audioReferenceSpokenText: z.array(z.string()).optional().describe('The exact words in each reference clip — same order and length as audioReferenceAssetIds, "" for a clip with no speech. The model RE-TRANSCRIBES a take rather than using it verbatim, so audio decides voice/accent/timing and only this decides the WORDS. Omit it and the words are a guess.'),
4761
- sound: z.boolean().optional().describe('Kling 3.0 (every tier) 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.'),
4784
+ sound: z.boolean().optional().describe(`Sound on by default. Pass false for a silent take on ${VIDEO_MODELS.filter(id => getModelCapability(id)?.soundCanBeDisabled).join(', ')}. Kling 3.0 bills audio separately.`),
4762
4785
  audioLanguage: z.enum(['EN', 'ZH', 'JA', 'KO', 'ES']).optional().describe('Any Kling 3.0 model with sound on — language for dialogue.'),
4763
4786
  generateMusic: z.boolean().optional().describe('Any Kling 3.0 model with sound on — auto-generate background music.'),
4764
4787
  seedanceDraft: z.boolean().optional().describe('Create a finishable Seedance 2.5 preview at 480p.'),
@@ -4808,6 +4831,15 @@ export const generateVideo = {
4808
4831
  // not reasonable for video given the cost.
4809
4832
  // Non-blocking prompt hygiene, computed once. Reported on the gates that
4810
4833
  // fire BEFORE any spend, where a rewrite is still free.
4834
+ const promptError = videoPromptError(input.model, input.prompt, !!input.firstFrameAssetId);
4835
+ if (promptError)
4836
+ return ok({ requires_clarification: true, missing: ['prompt'], message: promptError });
4837
+ input.prompt ??= '';
4838
+ const needsRatio = aspectRatioApplies(input.model, {
4839
+ firstFrame: !!input.firstFrameAssetId,
4840
+ referenceImages: [input.ingredientAssetIds, input.characterAssetIds, input.environmentAssetIds, input.styleAssetIds]
4841
+ .reduce((n, ids) => n + (ids?.length ?? 0), 0),
4842
+ });
4811
4843
  const promptWarning = bannedTokenWarning(input.prompt, 'video', promptingSkillFor(resolved.model));
4812
4844
  if (!input.projectId) {
4813
4845
  return ok({
@@ -4818,9 +4850,9 @@ export const generateVideo = {
4818
4850
  'projectId is required for video generation. Use slates_list_projects to find one or slates_create_project to make a new one. Video gens cost tens to a few hundred credits per call — they need to land in a project so the user sees the progress card and the result.',
4819
4851
  });
4820
4852
  }
4821
- if (!input.aspectRatio || !input.duration) {
4853
+ if ((needsRatio && !input.aspectRatio) || !input.duration) {
4822
4854
  const missing = [];
4823
- if (!input.aspectRatio)
4855
+ if (needsRatio && !input.aspectRatio)
4824
4856
  missing.push('aspectRatio');
4825
4857
  if (!input.duration)
4826
4858
  missing.push('duration');
@@ -4835,7 +4867,7 @@ export const generateVideo = {
4835
4867
  // a model locked to 16:9, "Kling/Seedance support 1:1 16:9 9:16 4:3 3:4
4836
4868
  // 21:9" and "Kling 5-15s" — three wrong claims in one sentence.
4837
4869
  `or ask the user. ` +
4838
- `Aspect ratio for ${input.model}: ${aspectRatiosFor(input.model, AGENT_ROUTE_PROVIDER).join(', ')}. ` +
4870
+ (needsRatio ? `Aspect ratio for ${input.model}: ${aspectRatiosFor(input.model, AGENT_ROUTE_PROVIDER).join(', ')}. ` : '') +
4839
4871
  `Duration: ${describeDurations([input.model])}. ` +
4840
4872
  `Cost scales linearly with duration.`,
4841
4873
  });
@@ -4895,14 +4927,16 @@ export const generateVideo = {
4895
4927
  return ok({ requires_clarification: true, missing: [], message: shapeError });
4896
4928
  }
4897
4929
  }
4898
- // Wan 3.0's SHAPE constraints. The same split as Omni Flash: image-to-video
4899
- // takes a start frame and an optional end frame, reference-to-video takes
4900
- // images, videos and audio, and Alibaba calls the two modes "mutually
4901
- // exclusive". The reference endpoint has no frame slot, so frames with
4930
+ // Wan 3.0's and MAGI-2's SHAPE constraints. The same split as Omni Flash:
4931
+ // image-to-video takes a start frame and an optional end frame,
4932
+ // reference-to-video takes images, videos and audio, and the two never mix
4933
+ // (Alibaba: "mutually exclusive"; MAGI-2: references "cannot be added to a
4934
+ // frame request"). The reference endpoint has no frame slot, so frames with
4902
4935
  // references are refused, never dropped (the MiniMax H3 rule, slate
4903
4936
  // .claude/rules/models.md invariant 7). Caps are read from the SSOT.
4904
- if (input.model === 'wan-3.0') {
4905
- const cap = getModelCapability('wan-3.0');
4937
+ if (input.model === 'wan-3.0' || input.model === 'magi-2') {
4938
+ const label = input.model === 'wan-3.0' ? 'Wan 3.0' : 'MAGI-2';
4939
+ const cap = getModelCapability(input.model);
4906
4940
  const imageRefs = (input.ingredientAssetIds?.length ?? 0) +
4907
4941
  (input.characterAssetIds?.length ?? 0) +
4908
4942
  (input.environmentAssetIds?.length ?? 0) +
@@ -4918,11 +4952,11 @@ export const generateVideo = {
4918
4952
  [refAll, cap?.maxReferenceFilesTotal, 'reference files across all types'],
4919
4953
  ].find(([n, max]) => max !== undefined && n > max);
4920
4954
  const shapeError = refAll > 0 && (input.firstFrameAssetId || input.lastFrameAssetId)
4921
- ? 'Wan 3.0 takes first/last frames OR references, not both: Alibaba calls the two modes mutually exclusive. Drop one side.'
4955
+ ? `${label} takes first/last frames OR references, not both: its reference endpoint has no frame slots. Drop one side.`
4922
4956
  : input.lastFrameAssetId && !input.firstFrameAssetId
4923
- ? 'Wan 3.0 needs a start frame (firstFrameAssetId) with a last frame.'
4957
+ ? `${label} needs a start frame (firstFrameAssetId) with a last frame.`
4924
4958
  : overCap
4925
- ? `Wan 3.0 takes at most ${overCap[1]} ${overCap[2]} (you passed ${overCap[0]}).`
4959
+ ? `${label} takes at most ${overCap[1]} ${overCap[2]} (you passed ${overCap[0]}).`
4926
4960
  : null;
4927
4961
  if (shapeError) {
4928
4962
  return ok({ requires_clarification: true, missing: [], message: shapeError });
@@ -5505,6 +5539,9 @@ export const generateAudio = {
5505
5539
  }),
5506
5540
  run: async (input, ctx) => {
5507
5541
  requireGuideRead(ctx, input.model);
5542
+ const lengthError = promptLengthError(input.model, input.prompt);
5543
+ if (lengthError)
5544
+ throw new Error(lengthError);
5508
5545
  // A desktop before the folder rule ignores folderId and files at the root.
5509
5546
  if (input.folderId !== undefined)
5510
5547
  await ctx.desktop().requireCapability('media-folder', 'choosing the folder a result lands in');
@@ -5526,8 +5563,9 @@ export const generateAudio = {
5526
5563
  // because "the words that get spoken" and "what you asked for" are the
5527
5564
  // same thing here. That also means the character count is knowable
5528
5565
  // client-side, which is what makes the quote below exact.
5529
- if (input.prompt.length > TTS_MAX_CHARACTERS) {
5530
- throw new Error(`${TTS_MODEL} accepts up to ${TTS_MAX_CHARACTERS} characters in one take — this text is ${input.prompt.length}. Split it into separate lines and generate each one.`);
5566
+ const characters = promptLengthFor(input.model, input.prompt);
5567
+ if (characters > TTS_MAX_CHARACTERS) {
5568
+ throw new Error(`${TTS_MODEL} accepts up to ${TTS_MAX_CHARACTERS} characters in one take — this text is ${characters}. Split it into separate lines and generate each one.`);
5531
5569
  }
5532
5570
  if (input.durationSeconds != null) {
5533
5571
  throw new Error(`${TTS_MODEL} has no duration parameter — speech length falls out of the text, and it bills per character. Drop durationSeconds.`);
@@ -5569,8 +5607,9 @@ export const generateAudio = {
5569
5607
  message: `Sound Effects needs a durationSeconds of ${ELEVEN_SFX_MIN_SECONDS}-${ELEVEN_SFX_MAX_SECONDS}. It is billed per second and is never left for the model to pick (that would make the charge non-deterministic). Roughly: ${ELEVEN_SFX_MIN_SECONDS}s for an impact, 2-4s for a whoosh, 8-${ELEVEN_SFX_MAX_SECONDS}s for a loopable bed.`,
5570
5608
  });
5571
5609
  }
5572
- if (input.prompt.length > 450) {
5573
- throw new Error(`Sound Effects accepts up to 450 characters — this prompt is ${input.prompt.length}.`);
5610
+ const characters = promptLengthFor(input.model, input.prompt);
5611
+ if (characters > 450) {
5612
+ throw new Error(`Sound Effects accepts up to 450 characters — this prompt is ${characters}.`);
5574
5613
  }
5575
5614
  }
5576
5615
  await ctx.desktop().requireCapability('audio-generation', 'audio generation');
@@ -5596,7 +5635,7 @@ export const generateAudio = {
5596
5635
  const costKey = audioCostKey({
5597
5636
  model: input.model,
5598
5637
  durationSeconds: seconds,
5599
- characters: input.model === TTS_MODEL ? input.prompt.length : undefined,
5638
+ characters: input.model === TTS_MODEL ? promptLengthFor(input.model, input.prompt) : undefined,
5600
5639
  });
5601
5640
  const entry = registry.models.find((m) => m.model === costKey) ??
5602
5641
  (await cloud.get(`/api/agent/models?costKey=${encodeURIComponent(costKey)}`)).models[0];
@@ -6040,7 +6079,7 @@ export const editVideo = {
6040
6079
  input: z.object({
6041
6080
  projectId: z.string().uuid().describe('Project the source clip lives in.'),
6042
6081
  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`.'),
6043
- 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."'),
6082
+ prompt: z.string().min(1).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."'),
6044
6083
  // Clip windows and resolutions GENERATED from MODEL_CAPABILITIES.
6045
6084
  model: zEnum(EDIT_VIDEO_MODELS).optional().describe(
6046
6085
  // Routing GENERATED from MODEL_FACTS; the paragraph that stood here was
@@ -6068,6 +6107,9 @@ export const editVideo = {
6068
6107
  await desktop.requireCapability('background-generation', 'background generation');
6069
6108
  }
6070
6109
  const model = input.model ?? EDIT_VIDEO_DEFAULT;
6110
+ const lengthError = promptLengthError(model, input.prompt);
6111
+ if (lengthError)
6112
+ throw new Error(lengthError);
6071
6113
  requireGuideRead(ctx, model);
6072
6114
  const isOmniFlashEdit = model === 'omni-flash-1-2-edit';
6073
6115
  const isSeedanceEdit = model === 'seedance-2.5-edit';
@@ -6781,9 +6823,10 @@ export const resolveReviewNote = {
6781
6823
  const META_WINNERS = 'the Winners Loop (ad results per recipe)';
6782
6824
  export const getClientAdReport = {
6783
6825
  id: 'slates_get_client_ad_report',
6784
- description: 'List connected Google Ads or TikTok Ads advertisers, or read date-range ad performance with linked Slates exports. Uses the signed-in desktop connection. Publishing and account changes happen in the window.',
6826
+ // No Google Ads: Google's Ads API policy bars re-exposing it through an MCP server on our Cloud project.
6827
+ description: 'List connected TikTok Ads advertisers, or read date-range ad performance with linked Slates exports. Uses the signed-in desktop connection. Publishing and account changes happen in the window. Google Ads results are shown only in the Slates window: agents cannot read or change Google Ads, so send the person to Ads, then Google Ads.',
6785
6828
  input: z.object({
6786
- platform: z.enum(['google', 'tiktok']),
6829
+ platform: z.enum(['tiktok']),
6787
6830
  accountId: z.string().regex(/^\d{1,24}$/).optional(),
6788
6831
  managerId: z.string().regex(/^\d{10}$/).optional(),
6789
6832
  since: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
@@ -9270,7 +9313,12 @@ async function shotRowId(ref, read) {
9270
9313
  /** Params whose legality depends on the Shot's model. */
9271
9314
  const MODEL_BOUND_SHOT_PARAMS = ['aspectRatio', 'videoResolution', 'imageResolution', 'duration', 'seedanceDraft'];
9272
9315
  /** An edit that names no model is checked against the stored Shot's, the gate create runs. */
9273
- async function assertStoredShotCapabilities(model, params, read) {
9316
+ async function assertStoredShotCapabilities(model, params, read, prompt) {
9317
+ if (prompt !== undefined || model !== undefined) {
9318
+ const error = promptLengthError(model ?? (await read()).model, prompt ?? (await read()).rawPrompt);
9319
+ if (error)
9320
+ throw new Error(error);
9321
+ }
9274
9322
  if (model !== undefined || !MODEL_BOUND_SHOT_PARAMS.some((k) => params?.[k] !== undefined))
9275
9323
  return null;
9276
9324
  return assertShotCapabilities((await read()).model ?? undefined, params);
@@ -9300,7 +9348,7 @@ export const createShot = {
9300
9348
  input: z.object({
9301
9349
  projectId: z.string().uuid(),
9302
9350
  name: z.string().max(120).optional().describe('What to call it. Shown on the card; the prompt supplies one if you omit it.'),
9303
- prompt: z.string().min(1).max(4000).optional().describe('The RAW prompt, @mentions intact. Never write "image 1" yourself — the composer numbers references, and a hand-written number is wrong the moment one moves. Required unless fromAssetId supplies the recipe.'),
9351
+ prompt: z.string().min(1).optional().describe('The RAW prompt, @mentions intact. Never write "image 1" yourself — the composer numbers references, and a hand-written number is wrong the moment one moves. Required unless fromAssetId supplies the recipe.'),
9304
9352
  fromAssetId: z.string().optional().describe("Save as shot: start from this asset's RECORDED recipe (UUID or badge code) — its prompt, model, settings and references — as Media's Save as shot does. That result becomes the Shot's first take unless another Shot already holds it. Anything else you pass overrides the recipe."),
9305
9353
  model: z.string().optional().describe('Model id — the same ids slates_generate_image / slates_generate_video / slates_generate_audio take, and their descriptions carry the routing. Optional: a Shot can be planned before the model is decided.'),
9306
9354
  params: shotParamsSchema,
@@ -9320,6 +9368,9 @@ export const createShot = {
9320
9368
  async run(input, ctx) {
9321
9369
  if (!input.prompt && !input.fromAssetId)
9322
9370
  throw new Error('Pass a prompt, or fromAssetId to save a result\'s recorded recipe as the Shot.');
9371
+ const lengthError = promptLengthError(input.model, input.prompt);
9372
+ if (lengthError)
9373
+ throw new Error(lengthError);
9323
9374
  const capErr = assertShotCapabilities(input.model, input.params);
9324
9375
  if (capErr)
9325
9376
  return capErr;
@@ -9407,7 +9458,7 @@ export const updateShot = {
9407
9458
  shotId: z.string().describe('The Shot id, or its SHOT-A code as shown on the row.'),
9408
9459
  projectId: z.string().uuid().describe('The Shot\'s project — badge codes and entity ids resolve against it.'),
9409
9460
  name: z.string().max(120).optional(),
9410
- prompt: z.string().max(4000).optional(),
9461
+ prompt: z.string().optional(),
9411
9462
  model: z.string().optional(),
9412
9463
  params: shotParamsSchemaTerse,
9413
9464
  refs: shotRefsSchemaTerse,
@@ -9432,7 +9483,7 @@ export const updateShot = {
9432
9483
  const desktop = ctx.desktop();
9433
9484
  await desktop.requireCapability('shots', 'saved Shots');
9434
9485
  const read = shotReader(desktop, input.shotId, input.projectId);
9435
- const storedErr = await assertStoredShotCapabilities(input.model, input.params, read);
9486
+ const storedErr = await assertStoredShotCapabilities(input.model, input.params, read, input.prompt);
9436
9487
  if (storedErr)
9437
9488
  return storedErr;
9438
9489
  await requireDraftShotDesktop(desktop, input.model, input.params, read);
@@ -9463,7 +9514,7 @@ export const duplicateShot = {
9463
9514
  shotId: z.string().describe('The Shot id, or its SHOT-A code.'),
9464
9515
  projectId: z.string().uuid().optional().describe(SHOT_PROJECT_DESCRIBE),
9465
9516
  name: z.string().max(120).optional().describe('Name for the copy (default: the original plus "copy").'),
9466
- prompt: z.string().max(4000).optional().describe('Replace the prompt on the copy. Omit to keep the original\'s.'),
9517
+ prompt: z.string().optional().describe('Replace the prompt on the copy. Omit to keep the original\'s.'),
9467
9518
  model: z.string().optional().describe('Point the copy at a different model — the A/B lever. The prompt is NOT rewritten, and the copy records which model it was written for.'),
9468
9519
  params: shotParamsSchemaTerse,
9469
9520
  frameId: z.string().uuid().nullable().optional().describe('Attach the copy to this frame. Omit to keep the original\'s frame; pass null to leave it unattached.'),
@@ -9475,7 +9526,7 @@ export const duplicateShot = {
9475
9526
  const desktop = ctx.desktop();
9476
9527
  await desktop.requireCapability('shots', 'saved Shots');
9477
9528
  const read = shotReader(desktop, input.shotId, input.projectId);
9478
- const storedErr = await assertStoredShotCapabilities(input.model, input.params, read);
9529
+ const storedErr = await assertStoredShotCapabilities(input.model, input.params, read, input.prompt);
9479
9530
  if (storedErr)
9480
9531
  return storedErr;
9481
9532
  await requireDraftShotDesktop(desktop, input.model, input.params, read);
@@ -10383,6 +10434,8 @@ export function resolveGuideTopic(topic) {
10383
10434
  return 'slates-prompting-omni-flash';
10384
10435
  if (t.startsWith('wan') || t === 'alibaba-wan-3.0')
10385
10436
  return 'slates-prompting-wan-3';
10437
+ if (t.startsWith('magi'))
10438
+ return 'slates-prompting-magi-2';
10386
10439
  // MiniMax H3 — both seats share one skill. Placed BEFORE the seed/seedance
10387
10440
  // block for the same reason seed-audio is: no prefix collision exists today,
10388
10441
  // but a `minimax-*` id must never fall through to a Seedance guide.
@@ -1,17 +1,5 @@
1
- export type BannedTokenScope = 'image' | 'video';
2
- /** The call shape a block's heading limits its tokens to. */
3
- export type BannedTokenCondition = 'reference-video' | 'edit';
4
- export interface BannedToken {
5
- token: string;
6
- skill: string;
7
- scope: BannedTokenScope;
8
- /** The never-use line the token came from, as the skill words it. */
9
- note: string;
10
- /** False when the rule needs context the call cannot show; such a token only warns. */
11
- checkable: boolean;
12
- /** Set when the block's heading limits it to a call shape. */
13
- when?: BannedTokenCondition;
14
- }
1
+ import { type BannedToken, type BannedTokenScope } from './guide-bans.js';
2
+ export type { BannedToken, BannedTokenCondition, BannedTokenScope } from './guide-bans.js';
15
3
  /** Compatibility exports: there is no cross-model blacklist. */
16
4
  export declare const BANNED_PROMPT_TOKENS: readonly BannedToken[];
17
5
  export declare function bannedTokensFor(_scope: BannedTokenScope): readonly BannedToken[];
@@ -6,47 +6,10 @@
6
6
  * 2026-10-07): a word the user typed passes, and the identical call sent again
7
7
  * after the refusal runs. No model's list is universal.
8
8
  *
9
- * WHAT A BLOCK MAY CONTAIN. Every `backticked` string is a never-use token,
10
- * except the right way written beside it, which is never a token: `(say \`x\`)`,
11
- * `than \`x\``, `as in: \`x\`` and `(\`x\`) passed`. A heading that limits the
12
- * block to a call shape ("with a reference video", "in an EDIT prompt") limits
13
- * the refusal to calls of that shape. A line whose rule depends on context the
14
- * call cannot show ("after the first introduction") stays a warning only.
9
+ * Only explicit Ban and Warn rows declare literals. Conditions live on those rows.
15
10
  */
16
11
  import { brainFiles, servedBrain } from '../skills/served.js';
17
- /** The right way, written next to the wrong one: never a token. */
18
- const POSITIVE_BEFORE = [/\(\s*say\s*$/i, /\bthan\s*$/i, /\bas in:?\s*$/i];
19
- const POSITIVE_AFTER = /^\)\s*passed\b/i;
20
- /** A rule the call alone cannot settle. */
21
- const CONTEXTUAL = /after the first introduction/i;
22
- function conditionOf(heading) {
23
- if (/with a reference video/i.test(heading))
24
- return 'reference-video';
25
- if (/in an EDIT prompt/i.test(heading))
26
- return 'edit';
27
- return undefined;
28
- }
29
- /** One fence → its tokens, positives dropped, each with its line and its limits. */
30
- function parseBannedBlock(body, skill, scope) {
31
- const lines = body.replace(/<!--[\s\S]*?-->/g, '').split('\n').map((l) => l.trim()).filter(Boolean);
32
- const heading = lines.find((l) => /never use|avoid/i.test(l)) ?? '';
33
- const when = conditionOf(heading.replace(/`[^`\n]*`/g, ''));
34
- const out = [];
35
- for (const line of lines) {
36
- const note = line.replace(/^-\s*/, '').replace(/`([^`\n]+)`/g, '"$1"');
37
- for (const m of line.matchAll(/`([^`\n]+)`/g)) {
38
- const before = line.slice(0, m.index);
39
- const after = line.slice((m.index ?? 0) + m[0].length);
40
- if (POSITIVE_BEFORE.some((re) => re.test(before)) || POSITIVE_AFTER.test(after))
41
- continue;
42
- const token = m[1].trim();
43
- if (out.some((t) => t.token === token))
44
- continue;
45
- out.push({ token, skill, scope, note, checkable: !CONTEXTUAL.test(line), ...(when ? { when } : {}) });
46
- }
47
- }
48
- return out;
49
- }
12
+ import { parseGuideBans } from './guide-bans.js';
50
13
  // Read from the brain this process holds (skills/served.ts) and rebuilt when it changes: the model guides that
51
14
  // carry the @banned blocks are served by the account's tier.
52
15
  let built;
@@ -56,15 +19,9 @@ function bannedBySkill() {
56
19
  return built.bySkill;
57
20
  const bySkill = new Map();
58
21
  for (const [skill, content] of Object.entries(brainFiles())) {
59
- const fences = [...content.matchAll(/<!--\s*@banned:start\s*-->([\s\S]*?)<!--\s*@banned:end\s*-->/g)];
60
- if (!fences.length)
61
- continue;
62
- const scope = /nano-banana|gpt-image|flux|seedream/.test(skill) ? 'image' : 'video';
63
- const tokens = fences.flatMap((f) => parseBannedBlock(f[1], skill, scope))
64
- .filter((t, i, all) => all.findIndex((o) => o.token === t.token) === i);
65
- if (!tokens.length)
66
- throw new Error(`${skill}: @banned block contains no tokens`);
67
- bySkill.set(skill, tokens);
22
+ const tokens = parseGuideBans(skill, content);
23
+ if (tokens.length)
24
+ bySkill.set(skill, tokens);
68
25
  }
69
26
  built = { brain, bySkill };
70
27
  return bySkill;
@@ -0,0 +1,16 @@
1
+ export type BannedTokenScope = 'image' | 'video';
2
+ /** The call shape a block's heading limits its tokens to. */
3
+ export type BannedTokenCondition = 'reference-video' | 'edit';
4
+ export interface BannedToken {
5
+ token: string;
6
+ skill: string;
7
+ scope: BannedTokenScope;
8
+ /** The never-use line the token came from, as the skill words it. */
9
+ note: string;
10
+ /** False when the rule needs context the call cannot show; such a token only warns. */
11
+ checkable: boolean;
12
+ /** Set when the block's heading limits it to a call shape. */
13
+ when?: BannedTokenCondition;
14
+ }
15
+ export declare function parseGuideBans(skill: string, content: string, strict?: boolean): BannedToken[];
16
+ //# sourceMappingURL=guide-bans.d.ts.map
@@ -0,0 +1,40 @@
1
+ // A ban row lists only literals before the pipe. The note after it is free prose.
2
+ const ROW = /^- (Ban|Warn)(?: \((reference-video|edit)\))?: ((?:`[^`\n]+`)(?:, `[^`\n]+`)*)(?: \| (.+))?$/;
3
+ // A cached pre-migration guide can still name a leading list of literals. Read only
4
+ // that list. Words embedded in an explanation cannot establish a legacy ban.
5
+ function cachedRow(line, heading) {
6
+ const match = /^(?:- |\*\*Slop tokens to avoid:\*\* )(?:avoid )?(`[^`]+`(?:, `[^`]+`)*)(.*)$/i.exec(line);
7
+ if (!match)
8
+ return undefined;
9
+ const condition = /with a reference video/i.test(heading) ? ' (reference-video)' : /in an edit prompt/i.test(heading) ? ' (edit)' : '';
10
+ const action = /after the first introduction/i.test(line) ? 'Warn' : 'Ban';
11
+ return `- ${action}${condition}: ${match[1]} | ${line.replace(/^- /, '')}`;
12
+ }
13
+ export function parseGuideBans(skill, content, strict = false) {
14
+ const scope = /nano-banana|gpt-image|flux|seedream/.test(skill) ? 'image' : 'video';
15
+ const tokens = [];
16
+ for (const fence of content.matchAll(/<!--\s*@banned:start\s*-->([\s\S]*?)<!--\s*@banned:end\s*-->/g)) {
17
+ const lines = fence[1].replace(/<!--[\s\S]*?-->/g, '').split(/\r?\n/).map(line => line.trim()).filter(Boolean);
18
+ let count = 0;
19
+ for (const line of lines) {
20
+ if (line.startsWith('- Guidance: ') || (line.startsWith('**') && !line.includes('`')))
21
+ continue;
22
+ const row = ROW.exec(line) ?? (!strict && ROW.exec(cachedRow(line, lines[0]) ?? ''));
23
+ if (!row) {
24
+ if (strict)
25
+ throw new Error(`${skill}: expected a structured @banned row (- Ban: \`literal\` | explanation): ${line}`);
26
+ continue;
27
+ }
28
+ const [, action, condition, literals, explanation] = row;
29
+ for (const [, token] of literals.matchAll(/`([^`]+)`/g)) {
30
+ count++;
31
+ tokens.push({ token, skill, scope, note: explanation || literals, checkable: action === 'Ban',
32
+ ...(condition ? { when: condition } : {}) });
33
+ }
34
+ }
35
+ if (strict && !count)
36
+ throw new Error(`${skill}: @banned block contains no structured literals`);
37
+ }
38
+ return tokens;
39
+ }
40
+ //# sourceMappingURL=guide-bans.js.map
@@ -174,7 +174,12 @@ export declare function falImageSize(model: string, aspectRatio?: string, resolu
174
174
  * ("can take several minutes") are not offered (Eric, 2026-10-23).
175
175
  */
176
176
  export declare const FLUX_3_RESOLUTIONS: Record<'1k' | '2k' | '4k', '1k' | '1.5k' | '2k'>;
177
+ /** Largest conditioned video the direct reference upload must carry. */
178
+ export declare const VIDEO_REFERENCE_UPLOAD_BYTES: number;
177
179
  export interface ModelCapability {
180
+ soundCanBeDisabled?: boolean;
181
+ maxPromptLength?: number;
182
+ promptOptionalWithFirstFrame?: boolean;
178
183
  imageResolutions?: ImageResolution[];
179
184
  /** Product default shared by estimates and generation. */
180
185
  defaultImageResolution?: ImageResolution;
@@ -190,6 +195,7 @@ export interface ModelCapability {
190
195
  */
191
196
  maxBatchImages?: number;
192
197
  /** Per-file reference-audio bounds, independently of the combined cap. */
198
+ referenceSecondsTolerance?: number;
193
199
  referenceVideoDuration?: {
194
200
  min: number;
195
201
  max: number;
@@ -413,6 +419,10 @@ export declare function checkReferenceSeconds(model: string, kind: 'video' | 'au
413
419
  * row's endpoint for that resolution has no reference slot
414
420
  * (`noReferenceImagesAt`), else the row's `maxIngredientImages`. */
415
421
  export declare function maxIngredientImagesFor(model: string, videoResolution?: string): number;
422
+ export declare function requestSoundFor(model: string, requested: boolean | undefined): boolean;
423
+ export declare function promptLengthFor(_model: string, prompt: string): number;
424
+ export declare function promptLengthError(model: string | null | undefined, prompt: string | undefined): string | undefined;
425
+ export declare function videoPromptError(model: string, prompt: unknown, firstFrame: boolean, hasCuts?: boolean): string | undefined;
416
426
  /** Whether the aspect ratio shapes this request. With a start frame the frame
417
427
  * decides, unless the row's frame request carries a ratio
418
428
  * (`aspectRatioWithFirstFrame`). */