@slatesvideo/shared 0.7.22 → 0.7.24

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.
@@ -36,8 +36,7 @@ export declare function annotate(id: string, billable: boolean | undefined): Ope
36
36
  */
37
37
  export declare const OPERATION_GROUPS: Record<OperationGroup, readonly string[]>;
38
38
  export declare function groupFor(id: string): OperationGroup | undefined;
39
- /** `extended` iff the op names a group. Absent from every group ⇒ `core`, so a
40
- * new op is visible until someone deliberately defers it. */
39
+ /** Only the explicit startup set appears in every Slates Basic prompt. */
41
40
  export declare const STARTUP_TOOL_IDS: Set<string>;
42
41
  export declare function tierFor(id: string): OperationTier;
43
42
  /** One-line summary of each group, for `slates_load_tools`' own description. */
@@ -238,7 +238,6 @@ export const OPERATION_GROUPS = {
238
238
  ],
239
239
  // Rename, delete, reorder. The 63-op CRUD tail the review measured at 39.5 KB.
240
240
  admin: [
241
- 'slates_get_client_ad_report',
242
241
  'slates_update_project',
243
242
  'slates_update_asset',
244
243
  'slates_delete_project',
@@ -263,6 +262,17 @@ export const OPERATION_GROUPS = {
263
262
  'slates_get_spend_limits',
264
263
  'slates_set_spend_limits',
265
264
  ],
265
+ ads: [
266
+ 'slates_get_client_ad_report',
267
+ 'slates_get_ad_winners',
268
+ 'slates_set_recipe_verdict',
269
+ 'slates_more_like_this',
270
+ 'slates_plan_split_test',
271
+ 'slates_evaluate_split_test_winner',
272
+ 'slates_find_winning_ads',
273
+ 'slates_list_winning_ad_niches',
274
+ 'slates_break_down_winning_ad',
275
+ ],
266
276
  // A third transport nobody without Blender installed can reach.
267
277
  blender: [
268
278
  'slates_blender_status',
@@ -281,8 +291,7 @@ for (const [group, ids] of Object.entries(OPERATION_GROUPS)) {
281
291
  export function groupFor(id) {
282
292
  return GROUP_BY_OP.get(id);
283
293
  }
284
- /** `extended` iff the op names a group. Absent from every group ⇒ `core`, so a
285
- * new op is visible until someone deliberately defers it. */
294
+ /** Only the explicit startup set appears in every Slates Basic prompt. */
286
295
  export const STARTUP_TOOL_IDS = new Set([
287
296
  'slates_load_tools', 'slates_get_prompting_guide', 'slates_get_workspace_state',
288
297
  'slates_list_projects', 'slates_create_project', 'slates_list_assets',
@@ -296,6 +305,7 @@ export const GROUP_SUMMARY = {
296
305
  library: 'folders, favorites, pins, the Library (user-named categories of saved references: characters, locations, products, looks) and styles, templates (list, export, import), exporting original asset files, moving and copying assets and Library items between projects, moving a project into the current projects folder, revealing files on disk',
297
306
  script: 'rich script documents, anchored sections and their saved versions, reusable passages, variations and take input history',
298
307
  timeline: 'named cuts and exporting several at once, what made an exported ad (its recipe ID); the timeline (tracks, clips, markers, settings), text, picture and HTML motion layers, captions, video export and FCP7 XML export for DaVinci Resolve or Premiere, clip trimming',
308
+ ads: 'ad accounts, split tests and winning ads',
299
309
  admin: 'rename / delete / reorder for projects, characters, locations, looks, boards, scenes and frames; shot duplicate, split and merge; spend limits',
300
310
  blender: 'the Blender previs bridge — scene inspection, bpy execution, API docs, grey-box render',
301
311
  };
@@ -88,7 +88,7 @@ const PREAMBLE = fork(`You are Slates Director — a production assistant living
88
88
  - SPENDING: before ANY generation, price every step with slates_estimate_generation_cost, show the user the itemized total in ONE message, and wait for their OK. Pass confirm: true only to relay an explicit user OK for that exact spend.
89
89
  - REAL NUMBERS ONLY: every cost, balance or count you state is copied from a tool result in this session. Never describe how a generation looks unless you fetched it this session.
90
90
  - PROJECT: call slates_get_workspace_state once and work in the user's current project; never create one unless asked. Read any shot or board they name before answering.
91
- - CRAFT: before a model's first generation this session, read its guide (slates_get_prompting_guide, topic: the model); an estimate's card or guidance in context doesn't count. UI help: topic "app-manual".
91
+ - CRAFT: call slates_get_prompting_guide for the job's playbook before answering. Estimate cards cover single shots; full guide (depth: full) for multi-ref, previs, edits, lip-sync, motion transfer or retries. UI: "app-manual".
92
92
  - Speak in the app's words and name assets by code and label (IMG-A12), never by tool name or UUID.`);
93
93
  // ── The working method ─────────────────────────────────────────────
94
94
  export const WORKING_METHOD = [
@@ -99,7 +99,7 @@ export const WORKING_METHOD = [
99
99
  // so its agent must load before calling. The MCP server lists every tool and
100
100
  // the host decides what to show (Essentials, FINDING TOOLS), so telling an MCP
101
101
  // client to load first costs it a turn for a tool it already has.
102
- fork(`3. LOAD KNOWLEDGE ON DEMAND: discover craft from the brief with slates_get_prompting_guide(query: the need); no topic returns ranked guides, no query returns the catalog. With a topic, read a short card or query a section/technique when needed. Use slates_load_tools with query to find a capability, then names to load its exact schema. A load replaces the previous optional selection. Before quoting a model, load its tool schema or routing guide. Use workspace generationDefaults when the user has no preference. Before a model's first generation in this chat, read its guide (slates_get_prompting_guide, topic: the model); the estimate's card and guidance already in context do not count, and the generation is refused until then. Then fetch a section or full guide for an unfamiliar mode or missing detail.`, `3. LOAD KNOWLEDGE ON DEMAND: discover craft from the brief with slates_get_prompting_guide(query: the need); no topic returns ranked guides, no query returns the catalog. With a topic, read a short card or query a section/technique when needed. Before quoting a model, read its tool schema or routing guide. Use workspace generationDefaults when the user has no preference. Before a model's first generation, read its guide (CRAFT); the estimate's card and guidance in context do not count. Then fetch a section or full guide for an unfamiliar mode or missing detail.`),
102
+ fork(`3. LOAD KNOWLEDGE ON DEMAND: discover craft from the brief with slates_get_prompting_guide(query: the need); no topic returns ranked guides, no query returns the catalog. With a topic, read a short card or query a section/technique when needed. Use slates_load_tools with query to find a capability, then names to load its exact schema. A load replaces the previous optional selection. Before quoting a model, load its tool schema or routing guide. Use workspace generationDefaults when the user has no preference. Read the job's playbook before advising or building. Use the estimate's craft card for a routine single shot. Fetch the model's full guide (depth: full) for complex references, previs, edits and retries after a refusal.`, `3. LOAD KNOWLEDGE ON DEMAND: discover craft from the brief with slates_get_prompting_guide(query: the need); no topic returns ranked guides, no query returns the catalog. With a topic, read a short card or query a section/technique when needed. Before quoting a model, read its tool schema or routing guide. Use workspace generationDefaults when the user has no preference. Read the job's playbook before advising or building. Use the estimate's craft card for a routine single shot. Fetch the model's full guide (depth: full) for complex references, previs, edits and retries after a refusal.`),
103
103
  // FORKED: `present_plan` is a loop-level DESKTOP tool, deliberately not in
104
104
  // ALL_OPERATIONS, so MCP never sees it and has no plan gate at all. Its
105
105
  // substitute is the itemized quote and explicit user approval in chat,
@@ -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 { matcherFor, 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;
@@ -74,16 +31,6 @@ export const BANNED_PROMPT_TOKENS = Object.freeze([]);
74
31
  export function bannedTokensFor(_scope) { return BANNED_PROMPT_TOKENS; }
75
32
  export function describeBannedTokens(_scope) { return ''; }
76
33
  export function bannedTokensForSkill(skill) { return bannedBySkill().get(skill) ?? []; }
77
- const matchers = new Map();
78
- function matcherFor(token) {
79
- let matcher = matchers.get(token);
80
- if (!matcher) {
81
- const escaped = token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
82
- matcher = new RegExp(`(?<!\\w)${escaped}(?!\\w)`, 'i');
83
- matchers.set(token, matcher);
84
- }
85
- return matcher;
86
- }
87
34
  export function findBannedTokens(prompt, _scope, skill) {
88
35
  return skill ? bannedTokensForSkill(skill).filter((b) => matcherFor(b.token).test(prompt)) : [];
89
36
  }
@@ -0,0 +1,17 @@
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
+ export declare function matcherFor(token: string): RegExp;
17
+ //# sourceMappingURL=guide-bans.d.ts.map
@@ -0,0 +1,50 @@
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
+ const matchers = new Map();
41
+ export function matcherFor(token) {
42
+ let matcher = matchers.get(token);
43
+ if (!matcher) {
44
+ const escaped = token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
45
+ matcher = new RegExp(`(?<!\\w)${escaped}(?!\\w)`, 'i');
46
+ matchers.set(token, matcher);
47
+ }
48
+ return matcher;
49
+ }
50
+ //# 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`). */
@@ -84,6 +84,13 @@ const OMNI_FLASH_ASPECT_RATIOS = ['16:9', '9:16'];
84
84
  * the H3 rows make.
85
85
  */
86
86
  const WAN_3_ASPECT_RATIOS = ['16:9', '4:3', '1:1', '3:4', '9:16'];
87
+ /**
88
+ * MAGI-2: six, on the text-to-video and reference-to-video requests (Kie's
89
+ * `magi-2/*` schemas, ripped 2026-11-25 to second-brain
90
+ * business/projects/slates/provider-docs/kie-magi-2-docs.md). Image-to-video
91
+ * has no ratio field: the start frame decides the shape.
92
+ */
93
+ const MAGI_2_ASPECT_RATIOS = ['21:9', '16:9', '4:3', '1:1', '3:4', '9:16'];
87
94
  /** Seedance (both seats, and the edit row): six — notably NO `4:5`. */
88
95
  const SEEDANCE_ASPECT_RATIOS = ['21:9', '16:9', '4:3', '1:1', '3:4', '9:16'];
89
96
  /**
@@ -316,6 +323,8 @@ export const FLUX_3_RESOLUTIONS = {
316
323
  '2k': '1.5k',
317
324
  '4k': '2k',
318
325
  };
326
+ /** Largest conditioned video the direct reference upload must carry. */
327
+ export const VIDEO_REFERENCE_UPLOAD_BYTES = 200 * 1024 * 1024;
319
328
  /**
320
329
  * The provider every AGENT generation actually lands on for Kling.
321
330
  *
@@ -455,6 +464,8 @@ export const MODEL_CAPABILITIES = {
455
464
  // with reference images lands, takes the three-ratio enum (fal OpenAPI, read
456
465
  // 2026-11-24).
457
466
  'kling-v3.0-std': {
467
+ soundCanBeDisabled: true,
468
+ maxPromptLength: 2500,
458
469
  aspectRatios: KLING_DIRECT_ASPECT_RATIOS,
459
470
  providerAspectRatios: { fal: KLING_FAL_ASPECT_RATIOS },
460
471
  videoResolution: { options: ['720p', '4k'] },
@@ -464,6 +475,8 @@ export const MODEL_CAPABILITIES = {
464
475
  noReferenceImagesAt: ['4k'],
465
476
  },
466
477
  'kling-v3.0-pro': {
478
+ soundCanBeDisabled: true,
479
+ maxPromptLength: 2500,
467
480
  aspectRatios: KLING_DIRECT_ASPECT_RATIOS,
468
481
  providerAspectRatios: { fal: KLING_FAL_ASPECT_RATIOS },
469
482
  videoResolution: { options: ['1080p', '4k'] },
@@ -472,6 +485,8 @@ export const MODEL_CAPABILITIES = {
472
485
  noReferenceImagesAt: ['4k'],
473
486
  },
474
487
  'kling-v3.0-omni': {
488
+ soundCanBeDisabled: true,
489
+ maxPromptLength: 2500,
475
490
  aspectRatios: KLING_DIRECT_ASPECT_RATIOS,
476
491
  providerAspectRatios: { fal: KLING_FAL_ASPECT_RATIOS },
477
492
  // O3 Standard: 720p, as Standard above. Omni Pro is the 1080p tier.
@@ -482,6 +497,8 @@ export const MODEL_CAPABILITIES = {
482
497
  aspectRatioWithFirstFrame: 'with-references',
483
498
  },
484
499
  'kling-v3.0-omni-pro': {
500
+ soundCanBeDisabled: true,
501
+ maxPromptLength: 2500,
485
502
  aspectRatios: KLING_DIRECT_ASPECT_RATIOS,
486
503
  providerAspectRatios: { fal: KLING_FAL_ASPECT_RATIOS },
487
504
  videoResolution: { options: ['1080p', '4k'] },
@@ -493,12 +510,14 @@ export const MODEL_CAPABILITIES = {
493
510
  // Kling O3 video-to-video edit (fal-only; the source clip is the canvas, so
494
511
  // aspect/resolution/duration all follow it).
495
512
  'kling-v3.0-omni-edit': {
513
+ maxPromptLength: 2500,
496
514
  aspectRatios: KLING_FAL_ASPECT_RATIOS,
497
515
  videoResolution: { options: ['1080p'], fixed: '1080p' },
498
516
  duration: { min: 3, max: 15, mode: 'continuous' },
499
517
  maxIngredientImages: 4, // elements + style refs combined (fal cap)
500
518
  },
501
519
  'kling-v3.0-omni-pro-edit': {
520
+ maxPromptLength: 2500,
502
521
  aspectRatios: KLING_FAL_ASPECT_RATIOS,
503
522
  videoResolution: { options: ['1080p'], fixed: '1080p' },
504
523
  duration: { min: 3, max: 15, mode: 'continuous' },
@@ -513,6 +532,7 @@ export const MODEL_CAPABILITIES = {
513
532
  // (Kling O3, Seedance 2.5 and Omni Flash hold the reference seat), so there is
514
533
  // no transport for an ingredient. Frames are frame slots, not references.
515
534
  'kling-v4.0': {
535
+ maxPromptLength: 26000,
516
536
  aspectRatios: KLING_V4_ASPECT_RATIOS,
517
537
  videoResolution: { options: ['720p', '1080p'], default: '720p' },
518
538
  duration: { min: 3, max: 30, mode: 'continuous' },
@@ -533,6 +553,7 @@ export const MODEL_CAPABILITIES = {
533
553
  // 360p is NOT offered: it sits below every other row's floor and would need
534
554
  // a new resolution token in every exhaustive map.
535
555
  'omni-flash-1-2': {
556
+ maxPromptLength: 5000,
536
557
  aspectRatios: OMNI_FLASH_ASPECT_RATIOS,
537
558
  videoResolution: { options: ['720p', '1080p', '4k'], default: '720p' },
538
559
  // fal: `duration` integer, minimum 3, maximum 15. Google: "any whole second
@@ -567,6 +588,7 @@ export const MODEL_CAPABILITIES = {
567
588
  firstFrameRidesAsReference: true,
568
589
  },
569
590
  'omni-flash-1-2-edit': {
591
+ maxPromptLength: 5000,
570
592
  aspectRatios: OMNI_FLASH_ASPECT_RATIOS,
571
593
  // fal's v1.2 edit takes `resolution`, same enum and default; no duration
572
594
  // parameter, so the output follows the source clip.
@@ -588,6 +610,8 @@ export const MODEL_CAPABILITIES = {
588
610
  // ride reference-to-video; Alibaba: "First-and-last-frame mode and
589
611
  // all-reference mode are mutually exclusive."
590
612
  'wan-3.0': {
613
+ soundCanBeDisabled: true,
614
+ maxPromptLength: 20000,
591
615
  aspectRatios: WAN_3_ASPECT_RATIOS,
592
616
  // fal enum 480p / 720p / 1080p, schema default 1080p. Our default is 720p
593
617
  // for the Seedance 2.5 reason: a 30s take at 1080p is 300 credits, and
@@ -608,8 +632,38 @@ export const MODEL_CAPABILITIES = {
608
632
  maxReferenceVideoSeconds: 15,
609
633
  maxReferenceAudioSeconds: 15,
610
634
  },
635
+ // ── MAGI-2 (added 2026-11-26) ─────────────────────────────────────────────
636
+ //
637
+ // Every value READ OFF Kie's schemas for magi-2/{text,image,reference}-to-video,
638
+ // ripped 2026-11-25 (second-brain business/projects/slates/provider-docs/
639
+ // kie-magi-2-docs.md). Frames ride image-to-video and references ride
640
+ // reference-to-video; the two never travel together. No aspectRatioWithFirstFrame:
641
+ // the image-to-video request has no ratio field.
642
+ 'magi-2': {
643
+ soundCanBeDisabled: true,
644
+ promptOptionalWithFirstFrame: true,
645
+ referenceSecondsTolerance: 0,
646
+ maxPromptLength: 15000,
647
+ aspectRatios: MAGI_2_ASPECT_RATIOS,
648
+ // resolution enum is `1080p` alone on all three endpoints.
649
+ videoResolution: { options: ['1080p'], fixed: '1080p' },
650
+ // duration: integer 4-30 on all three endpoints.
651
+ duration: { min: 4, max: 30, mode: 'continuous' },
652
+ // reference_image_urls maxItems 10, reference_video_urls maxItems 5 and
653
+ // reference_audio_urls maxItems 5; each clip 2-30 s and 30 s per type.
654
+ // References are not billed, so the combined seconds count 'actual'.
655
+ maxIngredientImages: 10,
656
+ maxReferenceVideos: 5,
657
+ maxReferenceAudio: 5,
658
+ maxReferenceFilesTotal: 20,
659
+ referenceVideoDuration: { min: 2, max: 30 },
660
+ referenceAudioDuration: { min: 2, max: 30 },
661
+ maxReferenceVideoSeconds: 30,
662
+ maxReferenceAudioSeconds: 30,
663
+ },
611
664
  // ── Seedance ───────────────────────────────────────────────────────────────
612
665
  'seedance-2': {
666
+ maxPromptLength: 4000,
613
667
  aspectRatios: SEEDANCE_ASPECT_RATIOS,
614
668
  videoResolution: { options: ['480p', '720p', '1080p', '4k'], default: '1080p' },
615
669
  duration: { min: 4, max: 15, mode: 'continuous' },
@@ -654,6 +708,7 @@ export const MODEL_CAPABILITIES = {
654
708
  aspectRatioWithFirstFrame: 'always',
655
709
  },
656
710
  'seedance-2.5': {
711
+ maxPromptLength: 4000,
657
712
  aspectRatios: SEEDANCE_ASPECT_RATIOS,
658
713
  // Keep 720p as the default: a 30s take at 1080p is ~853 credits.
659
714
  videoResolution: { options: ['480p', '720p', '1080p', '4k'], default: '720p' },
@@ -669,6 +724,7 @@ export const MODEL_CAPABILITIES = {
669
724
  minReferenceVideoSeconds: 2,
670
725
  },
671
726
  'seedance-2.5-edit': {
727
+ maxPromptLength: 4000,
672
728
  aspectRatios: SEEDANCE_ASPECT_RATIOS,
673
729
  videoResolution: { options: ['480p', '720p', '1080p', '4k'], default: '720p' },
674
730
  duration: { min: 4, max: 30, mode: 'continuous' },
@@ -700,6 +756,7 @@ export const MODEL_CAPABILITIES = {
700
756
  // different price at the tiers they share. Every lookup downstream is an
701
757
  // exact-id map, not a prefix.
702
758
  'minimax-h3': {
759
+ maxPromptLength: 7000,
703
760
  // fal reference-to-video schema, 2026-09-09: each audio clip is 2-15s.
704
761
  referenceAudioDuration: { min: 2, max: 15 },
705
762
  referenceVideoDuration: { min: 2, max: 15 },
@@ -734,6 +791,7 @@ export const MODEL_CAPABILITIES = {
734
791
  maxReferenceAudioSeconds: 15,
735
792
  },
736
793
  'minimax-h3-max': {
794
+ maxPromptLength: 7000,
737
795
  // fal reference-to-video schema, 2026-09-09: each audio clip is 2-15s.
738
796
  referenceAudioDuration: { min: 2, max: 15 },
739
797
  referenceVideoDuration: { min: 2, max: 15 },
@@ -770,6 +828,7 @@ export const MODEL_CAPABILITIES = {
770
828
  duration: { min: 5, max: 15, mode: 'continuous' },
771
829
  },
772
830
  'minimax-h3-max-turbo': {
831
+ maxPromptLength: 7000,
773
832
  aspectRatios: MINIMAX_H3_ASPECT_RATIOS,
774
833
  // fal schema for both Turbo endpoints, 2026-09-29: enum
775
834
  // ["480P","768P","1080P"], default "768P", the same 1080P "latent
@@ -792,12 +851,14 @@ export const MODEL_CAPABILITIES = {
792
851
  // are mirrored in three repos and locked by `pricing-consistency-check.mjs` §4
793
852
  // — moving them here would split one clamp across two files.
794
853
  'seed-audio': {
854
+ maxPromptLength: 2048,
795
855
  aspectRatios: [],
796
856
  // ONE image XOR up to 3 audio clips; the XOR is enforced by
797
857
  // `validateComposition`, this is only the image arm.
798
858
  maxRefImages: 1,
799
859
  },
800
860
  'eleven-sfx': {
861
+ maxPromptLength: 450,
801
862
  aspectRatios: [],
802
863
  },
803
864
  // ── Text-to-speech ─────────────────────────────────────────────────────────
@@ -1050,7 +1111,8 @@ export function referenceClipInBounds(model, kind, seconds) {
1050
1111
  if (!Number.isFinite(seconds) || seconds <= 0)
1051
1112
  return false;
1052
1113
  const { clip } = referenceSecondsBounds(model, kind);
1053
- return !clip || (seconds >= clip.min && seconds <= clip.max + REFERENCE_SECONDS_TOLERANCE);
1114
+ const tolerance = MODEL_CAPABILITIES[model]?.referenceSecondsTolerance ?? REFERENCE_SECONDS_TOLERANCE;
1115
+ return !clip || (seconds >= clip.min && seconds <= clip.max + tolerance);
1054
1116
  }
1055
1117
  /**
1056
1118
  * THE verdict on a request's reference clips of one kind, from each clip's
@@ -1077,7 +1139,8 @@ export function checkReferenceSeconds(model, kind, clips, opts = {}) {
1077
1139
  return verdict(null);
1078
1140
  const total = basis === 'billed' ? billed : actual;
1079
1141
  const shown = basis === 'billed' ? `${billed}s, each clip rounded up to a whole second` : `${actual.toFixed(1)}s`;
1080
- if (max > 0 && total > max + (basis === 'billed' ? 0 : REFERENCE_SECONDS_TOLERANCE)) {
1142
+ const tolerance = MODEL_CAPABILITIES[model]?.referenceSecondsTolerance ?? REFERENCE_SECONDS_TOLERANCE;
1143
+ if (max > 0 && total > max + (basis === 'billed' ? 0 : tolerance)) {
1081
1144
  return verdict(`${name} takes at most ${max}s of reference ${kind} in total, and this has ${shown}. Trim a clip first.`);
1082
1145
  }
1083
1146
  if (total < min) {
@@ -1094,6 +1157,28 @@ export function maxIngredientImagesFor(model, videoResolution) {
1094
1157
  return 0;
1095
1158
  return cap?.maxIngredientImages ?? 0;
1096
1159
  }
1160
+ export function requestSoundFor(model, requested) {
1161
+ return !MODEL_CAPABILITIES[model]?.soundCanBeDisabled || requested !== false;
1162
+ }
1163
+ export function promptLengthFor(_model, prompt) {
1164
+ return Array.from(prompt).length;
1165
+ }
1166
+ const maxLivePromptLength = Math.max(...Object.values(MODEL_CAPABILITIES).map(cap => cap.maxPromptLength ?? cap.maxCharacters ?? 0));
1167
+ export function promptLengthError(model, prompt) {
1168
+ const cap = model ? MODEL_CAPABILITIES[model] : undefined;
1169
+ const limit = cap?.maxPromptLength ?? cap?.maxCharacters ?? (cap?.imageResolutions ? 4000 : maxLivePromptLength);
1170
+ if (prompt && promptLengthFor(model ?? '', prompt) > limit) {
1171
+ return `${model || 'A Shot'} takes at most ${limit} prompt characters.`;
1172
+ }
1173
+ }
1174
+ export function videoPromptError(model, prompt, firstFrame, hasCuts = false) {
1175
+ const cap = MODEL_CAPABILITIES[model];
1176
+ if (prompt != null && typeof prompt !== 'string')
1177
+ return 'The prompt must be text.';
1178
+ if (!prompt?.trim() && !hasCuts && !(firstFrame && cap?.promptOptionalWithFirstFrame))
1179
+ return 'A prompt is required.';
1180
+ return promptLengthError(model, prompt ?? undefined);
1181
+ }
1097
1182
  /** Whether the aspect ratio shapes this request. With a start frame the frame
1098
1183
  * decides, unless the row's frame request carries a ratio
1099
1184
  * (`aspectRatioWithFirstFrame`). */
@@ -356,6 +356,17 @@ export const MODEL_FACTS = [
356
356
  ...caps('wan-3.0'),
357
357
  notes: 'Alibaba\'s video model, added 2026-10-17: first on Artificial Analysis text-to-video that day, at about a third of Seedance 2.5\'s price per second at 1080p. Long single takes, multi-shot sequences with timestamps, sound on or off. Start frame with an optional last frame, or references across images, videos and audio cited as Image N / Video N / Audio N (audio-only allowed); frames and references never mix. Reference video seconds bill on top of the output. Route here for long takes, timed multi-shot scenes and reference-driven shots on a budget; Seedance 2.5 stays the default. VIDEO-ONLY.',
358
358
  },
359
+ {
360
+ id: 'magi-2',
361
+ tipsKey: 'magi-2',
362
+ route: 'generate',
363
+ tier: 'specialist',
364
+ label: 'MAGI-2',
365
+ kind: 'video',
366
+ // 1080p only; 10 images + 5 videos + 5 audio, each clip 2-30s, 30s per type.
367
+ ...caps('magi-2'),
368
+ notes: "First on Artificial Analysis image-to-video that day, level with Seedance 2.5 inside the confidence interval, at a small fraction of its price per second. 1080p only, sound on or off. Start frame with an optional end frame, or references across images, videos and audio, each named in the prompt by what it shows; frames and references never mix, and references add nothing to the bill. Route here for small, cheap image-to-video jobs. Seedance 2.5 stays the default and runs the main workflow (draft, edit, upscale), and a Blender previs blocking always goes to Seedance 2.5 (MAGI-2 ignored one in our 2026-11-26 test). VIDEO-ONLY.",
369
+ },
359
370
  {
360
371
  id: 'seed-audio',
361
372
  tipsKey: 'seed-audio',
@@ -16,7 +16,7 @@ export interface PromptingTipsEntry {
16
16
  /** Footer callout paragraphs. */
17
17
  footer?: string[];
18
18
  }
19
- export type PromptingTipsKey = 'seedance' | 'seedance-2-5' | 'seedance-2-5-edit' | 'kling' | 'kling-edit' | 'omni-flash' | 'omni-flash-edit' | 'minimax-h3' | 'wan-3' | 'nano-banana' | 'gpt-image-2-6' | 'seed-audio' | 'eleven-sfx' | 'inworld-tts-2';
19
+ export type PromptingTipsKey = 'seedance' | 'seedance-2-5' | 'seedance-2-5-edit' | 'kling' | 'kling-edit' | 'omni-flash' | 'omni-flash-edit' | 'minimax-h3' | 'wan-3' | 'magi-2' | 'nano-banana' | 'gpt-image-2-6' | 'seed-audio' | 'eleven-sfx' | 'inworld-tts-2';
20
20
  export declare const PROMPTING_TIPS: Record<PromptingTipsKey, PromptingTipsEntry>;
21
21
  /** Null when no tips exist for the key — callers render an honest fallback. */
22
22
  export declare function getPromptingTips(key: string): PromptingTipsEntry | null;
@@ -756,6 +756,53 @@ const WAN_3 = {
756
756
  'Slates turns off the provider\'s prompt rewriter, so what you write is what the model reads. End with a short list of what must not appear (No subtitles, No watermark), never padded with what the prompt already says.',
757
757
  ],
758
758
  };
759
+ const MAGI_2 = {
760
+ label: 'MAGI-2',
761
+ intro: [
762
+ 'MAGI-2 makes 1080p video with its own soundtrack (dialogue, effects, ambience, music), sound on or off. Text-to-video, a start frame with an optional end frame, or references across images, video clips and audio clips. Frames and references never mix, and references add nothing to the price.',
763
+ ],
764
+ columns: [
765
+ [
766
+ {
767
+ heading: "Write the whole shot as a director's caption",
768
+ example: 'Subject and setting · the action beat by beat · camera · light · Sound: line',
769
+ note: 'The Preview model trained on structured captions. Try that format for a shot with several beats. Plain, direct English, heavy on verbs and on how things change over time.',
770
+ },
771
+ {
772
+ heading: 'From a start frame, spend the words on motion',
773
+ example: 'Open on the frame as it is; she turns to the window, lifts the cup and sets it down while the camera eases closer',
774
+ note: 'The frame already fixes the look. Describe the start, the movement and where it ends, and how bodies and objects keep their shape through fast motion.',
775
+ critical: true,
776
+ },
777
+ {
778
+ heading: 'Name each reference by what it shows',
779
+ example: 'The woman in the first reference image, the red-haired runner, leads; keep her face, hair and outfit the same',
780
+ note: 'Say which reference and what it is, every time. Never a bare tag, never an @ sign, and give every image a role: character, product, wardrobe, location or style.',
781
+ critical: true,
782
+ },
783
+ ],
784
+ [
785
+ {
786
+ heading: 'Numbered shots for longer takes',
787
+ example: 'Shot 1: wide, rain over the harbour. Shot 2: close-up, her hands on the rope.',
788
+ note: 'One event per shot, starting just before the action and ending on its result. Repeat key appearance details in every shot.',
789
+ },
790
+ {
791
+ heading: 'A Sound: line, and dialogue in quotes',
792
+ example: 'Sound: gravel under the tyres, gulls, low wind, continuing to the very last frame · She says: "Not here."',
793
+ note: 'Name the sources you want to hear. Write dialogue yourself, in the language it should be spoken.',
794
+ },
795
+ {
796
+ heading: 'Describe visible targets',
797
+ example: 'static camera · an empty street · clear daylight',
798
+ note: 'Try naming what should appear in the frame. A readable sign or label: the exact words, facing the camera, held still for a second.',
799
+ },
800
+ ],
801
+ ],
802
+ footer: [
803
+ 'Draft at a short length, then render the full take once the shot works. The provider may rewrite prompts on its side and offers no switch to turn that off on this model.',
804
+ ],
805
+ };
759
806
  export const PROMPTING_TIPS = {
760
807
  seedance: SEEDANCE,
761
808
  'seedance-2-5': SEEDANCE_25,
@@ -766,6 +813,7 @@ export const PROMPTING_TIPS = {
766
813
  'omni-flash-edit': OMNI_FLASH_EDIT,
767
814
  'minimax-h3': MINIMAX_H3,
768
815
  'wan-3': WAN_3,
816
+ 'magi-2': MAGI_2,
769
817
  'nano-banana': NANO_BANANA,
770
818
  'gpt-image-2-6': GPT_IMAGE_26,
771
819
  'seed-audio': SEED_AUDIO,
@@ -74,6 +74,7 @@ export interface ComposedReferences {
74
74
  */
75
75
  unresolvedTokens: string[];
76
76
  }
77
+ export declare function hasReferenceMention(prompt: string): boolean;
77
78
  /**
78
79
  * 🚨 A HEX COLOUR IS NOT A TAG. `#000000` is to `#` what `eric@gmail.com` is to
79
80
  * `@`: an everyday literal that happens to open with our sigil, written by