@slatesvideo/shared 0.7.21 → 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.
@@ -0,0 +1,47 @@
1
+ import type { z } from 'zod/v3';
2
+ import type { Operation, OperationContext, OperationResult } from './index.js';
3
+ /**
4
+ * THE ONE PATH FROM A CALLER'S RAW ARGUMENTS TO `op.run`.
5
+ *
6
+ * Every host (the MCP server, the CLI, the desktop Director) goes through
7
+ * `prepareOperation`, so the op's Zod schema (defaults, integer checks, enums,
8
+ * refinements) applies the same way everywhere. Until 2026-11-24 each host wrote
9
+ * its own path and the Director skipped the parse: a model that sent
10
+ * `duration: "5"` reached `checkDuration` with a string, and a customer saw
11
+ * "wan-3.0 accepts 2-30s — 5s is not legal" for a legal 5-second clip.
12
+ * `slate/scripts/op-entry-check.mjs` and `slates-mcp/scripts/op-entry-check.mjs`
13
+ * fail any direct `.run(` on an operation outside this file.
14
+ */
15
+ export type ParsedInput<I> = {
16
+ ok: true;
17
+ input: I;
18
+ } | {
19
+ ok: false;
20
+ message: string;
21
+ };
22
+ /** One readable line per Zod issue, for an agent that pays a turn for every unclear error. */
23
+ export declare function flattenZodError(err: z.ZodError, indent?: string): string;
24
+ /** Parse raw arguments against the op's schema, repairing stringified scalars once. */
25
+ export declare function parseOperationInput<I>(op: Operation<I>, raw: unknown): ParsedInput<I>;
26
+ /**
27
+ * A parsed call, ready to run. A host may adjust `input` before `run` (a consent
28
+ * gate setting `confirm`, a session filling `projectId`); `patch` overrides
29
+ * fields for one run without touching `input`.
30
+ */
31
+ export interface PreparedOperation<I> {
32
+ op: Operation<I>;
33
+ input: I;
34
+ run(ctx: OperationContext, patch?: Partial<I>): Promise<OperationResult>;
35
+ }
36
+ export declare function prepareOperation<I>(op: Operation<I>, raw: unknown): {
37
+ ok: true;
38
+ call: PreparedOperation<I>;
39
+ } | {
40
+ ok: false;
41
+ message: string;
42
+ };
43
+ /** Parse, then run; a parse failure comes back as the op's own error text. */
44
+ export declare function runOperation<I>(op: Operation<I>, raw: unknown, ctx: OperationContext): Promise<OperationResult & {
45
+ invalid?: true;
46
+ }>;
47
+ //# sourceMappingURL=parse-input.d.ts.map
@@ -0,0 +1,100 @@
1
+ /** One readable line per Zod issue, for an agent that pays a turn for every unclear error. */
2
+ export function flattenZodError(err, indent = '') {
3
+ return err.issues
4
+ .map((issue) => {
5
+ const path = issue.path.length > 0 ? issue.path.join('.') : '(root)';
6
+ if (issue.code === 'invalid_enum_value') {
7
+ return `${indent}${path}: ${JSON.stringify(issue.received)} is not allowed. Legal values: ${issue.options.join(', ')}`;
8
+ }
9
+ if (issue.code === 'unrecognized_keys') {
10
+ return `${indent}${path}: unknown parameter(s) ${issue.keys.join(', ')}. Check the tool schema`;
11
+ }
12
+ return `${indent}${path}: ${issue.message}`;
13
+ })
14
+ .join('\n');
15
+ }
16
+ /** A decimal number as a model or a shell types it: '5', '.5', '-.5', '5.', '+5', '1e3'. Never '', 'Infinity' or '0x10'. */
17
+ const NUMERIC = /^\s*[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?\s*$/;
18
+ /** Every issue that names a wrong scalar type, with the type the schema wanted; a union's branches included. */
19
+ function* scalarIssues(err) {
20
+ for (const issue of err.issues) {
21
+ if (issue.code === 'invalid_union')
22
+ for (const branch of issue.unionErrors)
23
+ yield* scalarIssues(branch);
24
+ else if (issue.code === 'invalid_type')
25
+ yield { path: issue.path, expected: issue.expected };
26
+ // `fps: 24 | 30 | 60` reports each literal it is not, never "expected number".
27
+ else if (issue.code === 'invalid_literal')
28
+ yield { path: issue.path, expected: typeof issue.expected };
29
+ }
30
+ }
31
+ /**
32
+ * A model or a shell sends `"5"` or `"true"` where the schema wants a number or
33
+ * a boolean. The intent is unambiguous, so it is repaired at the exact path Zod
34
+ * named and nowhere else. Only `"true"` and `"false"` are booleans: `"on"` or
35
+ * `"yes"` stays a string and fails the schema by name. Returns a repaired copy,
36
+ * or null when nothing was repairable.
37
+ *
38
+ * This is the only scalar coercion any host has. The CLI once ran its own
39
+ * first, which turned `--sound on` into `false` without a word (2026-11-24).
40
+ */
41
+ function repairScalars(value, err) {
42
+ if (typeof value !== 'object' || value === null)
43
+ return null;
44
+ const copy = structuredClone(value);
45
+ let changed = false;
46
+ for (const issue of scalarIssues(err)) {
47
+ if (issue.path.length === 0)
48
+ continue;
49
+ let parent = copy;
50
+ for (const p of issue.path.slice(0, -1)) {
51
+ parent = typeof parent === 'object' && parent !== null ? parent[p] : undefined;
52
+ }
53
+ if (typeof parent !== 'object' || parent === null)
54
+ continue;
55
+ const holder = parent;
56
+ const key = issue.path[issue.path.length - 1];
57
+ const current = holder[key];
58
+ if (typeof current !== 'string')
59
+ continue;
60
+ if (issue.expected === 'number' && NUMERIC.test(current)) {
61
+ holder[key] = Number(current);
62
+ changed = true;
63
+ }
64
+ else if (issue.expected === 'boolean' && (current === 'true' || current === 'false')) {
65
+ holder[key] = current === 'true';
66
+ changed = true;
67
+ }
68
+ }
69
+ return changed ? copy : null;
70
+ }
71
+ /** Parse raw arguments against the op's schema, repairing stringified scalars once. */
72
+ export function parseOperationInput(op, raw) {
73
+ const first = op.input.safeParse(raw ?? {});
74
+ if (first.success)
75
+ return { ok: true, input: first.data };
76
+ const repaired = repairScalars(raw ?? {}, first.error);
77
+ const second = repaired ? op.input.safeParse(repaired) : first;
78
+ if (second.success)
79
+ return { ok: true, input: second.data };
80
+ return { ok: false, message: `Invalid arguments for ${op.id}:\n${flattenZodError(second.error)}` };
81
+ }
82
+ export function prepareOperation(op, raw) {
83
+ const parsed = parseOperationInput(op, raw);
84
+ if (!parsed.ok)
85
+ return parsed;
86
+ const call = {
87
+ op,
88
+ input: parsed.input,
89
+ run: (ctx, patch) => op.run(patch ? { ...call.input, ...patch } : call.input, ctx),
90
+ };
91
+ return { ok: true, call };
92
+ }
93
+ /** Parse, then run; a parse failure comes back as the op's own error text. */
94
+ export async function runOperation(op, raw, ctx) {
95
+ const prepared = prepareOperation(op, raw);
96
+ if (!prepared.ok)
97
+ return { text: prepared.message, invalid: true };
98
+ return prepared.call.run(ctx);
99
+ }
100
+ //# sourceMappingURL=parse-input.js.map
@@ -238,6 +238,7 @@ 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',
241
242
  'slates_update_project',
242
243
  'slates_update_asset',
243
244
  'slates_delete_project',
@@ -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
@@ -6,20 +6,8 @@ export type AspectRatio = '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4'
6
6
  * and prices between 480p and 2K ($0.060/s vs 720p Seedance's $0.15/s — a
7
7
  * different tier of a different model, not a rename); 2K is H3's upscaled tier.
8
8
  * Aliasing either onto 720p/1080p would build a cost key that does not exist.
9
- *
10
- * 🚨 `1440p` entered with LTX-2.5 (2026-08-29) and is likewise NOT an alias —
11
- * specifically it is NOT `2k`, despite both being ~1440 lines tall. `2k` is
12
- * H3's UPSCALED tier ($0.130/s, an H3-Regenerate-2K pass over a 768p base);
13
- * `1440p` is LTX's NATIVELY GENERATED tier ($0.190/s). Different models,
14
- * different mechanisms, different prices, and `ltx-2-5-2k-6s` is a key that
15
- * exists nowhere. Co-height is not sameness.
16
- *
17
- * ⚠️ Our `4k` is LTX's `2160p` ON THE WIRE. fal's enum literal for that tier is
18
- * `2160p` while its own pricing copy calls it "4K". `4k` stays the token here
19
- * because it is what every cost key, `is4kVideoKey` and the Pro gate already
20
- * speak; the handler translates at the request boundary.
21
9
  */
22
- export type VideoResolution = '480p' | '720p' | '768p' | '1080p' | '1440p' | '2k' | '4k';
10
+ export type VideoResolution = '480p' | '720p' | '768p' | '1080p' | '2k' | '4k';
23
11
  /**
24
12
  * The full ten, in display order. `9:21` was in the MCP op's enum and in NO
25
13
  * model — it was invented downstream. Do not add a ratio here that no model
@@ -35,7 +23,7 @@ export interface DurationCapability {
35
23
  mode: 'continuous' | 'discrete';
36
24
  /** For discrete mode: the exact allowed durations. */
37
25
  values?: number[];
38
- /** Resolution-dependent narrowing: a resolution that allows fewer durations (LTX sets this). */
26
+ /** Resolution-dependent narrowing: a resolution that allows fewer durations. No row sets one today. */
39
27
  resolutionOverrides?: Record<string, Pick<DurationCapability, 'min' | 'max' | 'mode' | 'values'>>;
40
28
  /** Prompt-mode narrowing: a mode, such as reference-to-video, that allows fewer durations. No row sets one today. */
41
29
  modeOverrides?: Record<string, Pick<DurationCapability, 'min' | 'max' | 'mode' | 'values'>>;
@@ -186,7 +174,12 @@ export declare function falImageSize(model: string, aspectRatio?: string, resolu
186
174
  * ("can take several minutes") are not offered (Eric, 2026-10-23).
187
175
  */
188
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;
189
179
  export interface ModelCapability {
180
+ soundCanBeDisabled?: boolean;
181
+ maxPromptLength?: number;
182
+ promptOptionalWithFirstFrame?: boolean;
190
183
  imageResolutions?: ImageResolution[];
191
184
  /** Product default shared by estimates and generation. */
192
185
  defaultImageResolution?: ImageResolution;
@@ -202,6 +195,7 @@ export interface ModelCapability {
202
195
  */
203
196
  maxBatchImages?: number;
204
197
  /** Per-file reference-audio bounds, independently of the combined cap. */
198
+ referenceSecondsTolerance?: number;
205
199
  referenceVideoDuration?: {
206
200
  min: number;
207
201
  max: number;
@@ -238,6 +232,26 @@ export interface ModelCapability {
238
232
  /** The longest output with a last frame, when shorter than `duration.max`
239
233
  * (`lastFrameMaxSecondsFor`). Absent = the model's whole window. */
240
234
  lastFrameMaxSeconds?: number;
235
+ /** How the combined reference-VIDEO cap is counted (`checkReferenceSeconds`).
236
+ * 'billed' sums each clip rounded up to a whole second, because the row's
237
+ * video-reference key adds exactly that sum to the output and its key ladder
238
+ * ends at the cap. Absent = 'actual', the measured seconds, which is what the
239
+ * provider's own limit counts. Reference audio is always 'actual'. */
240
+ referenceVideoSecondsBasis?: 'actual' | 'billed';
241
+ /** Least combined reference-video seconds, when the row states one that is
242
+ * not a per-clip floor. Absent = `referenceVideoDuration.min`, else none. */
243
+ minReferenceVideoSeconds?: number;
244
+ /** Resolutions whose endpoint has no reference-image slot (`checkVideoParams`,
245
+ * `maxIngredientImagesFor`). Absent = references at every resolution. */
246
+ noReferenceImagesAt?: VideoResolution[];
247
+ /** Whether a request with a start frame still carries the aspect ratio
248
+ * (`aspectRatioApplies`). Absent = the frame decides the shape: the row's
249
+ * image-to-video request has no ratio parameter. 'with-references' = only
250
+ * when reference images ride with the frame. */
251
+ aspectRatioWithFirstFrame?: 'always' | 'with-references';
252
+ /** With references, a start frame is sent as reference image 1 and uses one
253
+ * image slot. Absent = frames and reference media never travel together. */
254
+ firstFrameRidesAsReference?: boolean;
241
255
  /**
242
256
  * Max characters in ONE synthesis request. Present ⟺ the surface is TTS.
243
257
  * This is the number the character BILLING BUCKET is sized against, so it
@@ -261,15 +275,7 @@ export interface ModelCapability {
261
275
  */
262
276
  export declare const AGENT_ROUTE_PROVIDER = "fal";
263
277
  export declare const MODEL_CAPABILITIES: Record<string, ModelCapability>;
264
- /**
265
- * Seats that left the roster, each with the seat that replaced it. The desktop
266
- * moves a stored or sent id onto its replacement (slate `migrateRetiredModel`,
267
- * which reads this map and adds the retired video seats this repo does not name).
268
- * The server keeps their cost keys so desktops released before a retirement
269
- * still bill; the list and estimate ops hide those keys and name the replacement
270
- * instead.
271
- */
272
- export declare const RETIRED_MODELS: Readonly<Record<string, string>>;
278
+ export { RETIRED_MODELS, RETIRED_SEATS, HISTORY_MODEL_LABELS, type RetiredSeat } from './retired-models.js';
273
279
  /**
274
280
  * The retired seat a cost key bills, or null when the key belongs to a current
275
281
  * row or to no row. A key is its row's id, alone or followed by `-` and its
@@ -332,6 +338,98 @@ export declare function checkReferenceShape(model: string, opts: {
332
338
  referenceVideoSeconds?: readonly number[];
333
339
  label?: string;
334
340
  }): string | null;
341
+ /**
342
+ * Frames beside reference video or audio. A reference endpoint has no frame
343
+ * parameters, so the pair is refused, never sent with one side dropped. A row
344
+ * that sends a first frame as reference image 1 (`firstFrameRidesAsReference`)
345
+ * carries it there, and only its last frame has no slot. A plain message naming
346
+ * `label`, or null. One function for the agent op, the desktop's composer and
347
+ * the handlers.
348
+ */
349
+ export declare function checkFramesWithReferenceMedia(model: string, opts: {
350
+ firstFrame?: boolean;
351
+ lastFrame?: boolean;
352
+ referenceVideos?: number;
353
+ referenceAudio?: number;
354
+ label?: string;
355
+ }): string | null;
356
+ /** A probe reads a clip a few hundredths long (an "8 second" file measures
357
+ * 8.02), so that much over a whole second or over a ceiling is not counted. */
358
+ export declare const REFERENCE_SECONDS_TOLERANCE = 0.05;
359
+ /** An edit's source clip is probed the same way, so it takes the same slack. */
360
+ export declare const EDIT_SECONDS_TOLERANCE = 0.05;
361
+ /** The whole seconds a probed length counts as: up past the probe slack, so
362
+ * 4.3s is 5 and 8.02s is 8. The one rounding every billed clip length takes;
363
+ * slates-api's `check:all` fails on a copy of it anywhere else. */
364
+ export declare function probedWholeSeconds(seconds: number): number;
365
+ /** The whole seconds a reference-video key bills for these clips: each measured
366
+ * clip rounds up on its own (4.3s bills 5, 8.02s bills 8), never the sum. A
367
+ * length of zero or less is an unmeasured clip and adds nothing. */
368
+ export declare function billedReferenceSeconds(clips: readonly number[]): number;
369
+ /** The whole seconds a video edit bills for a measured source clip. An edit's
370
+ * output follows its source, so the row's duration window is the clip window
371
+ * and the probed length is held inside it. A row with no window throws: an
372
+ * edit priced on a guessed window bills the wrong key. */
373
+ export declare function billedEditSeconds(model: string, seconds: number): number;
374
+ /** Lip-sync and motion transfer bill in whole blocks of this many seconds. */
375
+ export declare const TOOL_BLOCK_SECONDS = 5;
376
+ /** The whole tool blocks a length bills: rounded up with no probe slack, since a
377
+ * block already absorbs it (a 5.02s clip and a 5.0s clip are both one block).
378
+ * Zero for no length; each caller sets its own floor. */
379
+ export declare function toolBlocks(seconds: number): number;
380
+ /** A tool's credit key for `blocks` whole blocks: `${stem}-${blocks × 5}s`, as the
381
+ * server's price list names them. */
382
+ export declare function toolBlockKey(stem: string, blocks: number): string;
383
+ /** The per-clip window, the least and most combined seconds a row takes for one
384
+ * kind of reference, and how its combined cap is counted. `max` 0 = no cap. */
385
+ export declare function referenceSecondsBounds(model: string, kind: 'video' | 'audio'): {
386
+ clip?: {
387
+ min: number;
388
+ max: number;
389
+ };
390
+ min: number;
391
+ max: number;
392
+ basis: 'actual' | 'billed';
393
+ };
394
+ /** Whether one measured clip fits the row's per-clip window. The ceiling takes
395
+ * the probe tolerance; the floor does not (a probe never reads short). A row
396
+ * with no per-clip window takes any measured length. */
397
+ export declare function referenceClipInBounds(model: string, kind: 'video' | 'audio', seconds: number): boolean;
398
+ export interface ReferenceSecondsVerdict {
399
+ /** Measured seconds, summed. */
400
+ actual: number;
401
+ /** `billedReferenceSeconds` of the same clips. */
402
+ billed: number;
403
+ /** A plain message naming the limit, or null when the clips fit. */
404
+ error: string | null;
405
+ }
406
+ /**
407
+ * THE verdict on a request's reference clips of one kind, from each clip's
408
+ * length in seconds: every clip inside the row's per-clip window, and the
409
+ * combined length inside the row's bounds, counted on the row's own basis
410
+ * (`referenceVideoSecondsBasis`). A length of zero or less is a clip nobody has
411
+ * measured yet: it is skipped, unless `measured` says every clip was probed, in
412
+ * which case it is refused. A row with no bounds for the kind accepts.
413
+ */
414
+ export declare function checkReferenceSeconds(model: string, kind: 'video' | 'audio', clips: readonly number[], opts?: {
415
+ label?: string;
416
+ measured?: boolean;
417
+ }): ReferenceSecondsVerdict;
418
+ /** Reference images a request may carry at this resolution: none where the
419
+ * row's endpoint for that resolution has no reference slot
420
+ * (`noReferenceImagesAt`), else the row's `maxIngredientImages`. */
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;
426
+ /** Whether the aspect ratio shapes this request. With a start frame the frame
427
+ * decides, unless the row's frame request carries a ratio
428
+ * (`aspectRatioWithFirstFrame`). */
429
+ export declare function aspectRatioApplies(model: string, opts?: {
430
+ firstFrame?: boolean;
431
+ referenceImages?: number;
432
+ }): boolean;
335
433
  /** Every legal whole-second duration. Mirrors `getAvailableDurations`. */
336
434
  export declare function durationValuesFor(model: string, opts?: {
337
435
  videoResolution?: string;
@@ -346,17 +444,41 @@ export declare function durationBounds(models: readonly string[]): {
346
444
  min: number;
347
445
  max: number;
348
446
  };
349
- export declare function checkAspectRatio(model: string, aspectRatio: string | undefined, provider?: string): string | null;
350
- export declare function checkVideoResolution(model: string, videoResolution: string | undefined): string | null;
447
+ export declare function checkAspectRatio(model: string, aspectRatio: string | undefined, provider?: string, label?: string): string | null;
448
+ export declare function checkVideoResolution(model: string, videoResolution: string | undefined, label?: string): string | null;
449
+ /**
450
+ * THE verdict on a video request's shape parameters, in the order a caller can
451
+ * fix them: aspect ratio (only where it shapes the request, `aspectRatioApplies`),
452
+ * resolution, reference images at that resolution, then duration, whose window
453
+ * depends on the resolution. The agent op and the desktop's composition check
454
+ * (which the prompt bar, the agent route and the handlers run) both call this,
455
+ * so a ratio, resolution or length one refuses is refused by all. `field` names
456
+ * the parameter to change.
457
+ */
458
+ export declare function checkVideoParams(model: string, req: {
459
+ aspectRatio?: string;
460
+ videoResolution?: string;
461
+ duration?: number;
462
+ provider?: string;
463
+ firstFrame?: boolean;
464
+ lastFrame?: boolean;
465
+ /** Free reference images (ingredients, characters, environments, styles). */
466
+ referenceImages?: number;
467
+ label?: string;
468
+ }): {
469
+ field: 'aspectRatio' | 'videoResolution' | 'references' | 'duration';
470
+ message: string;
471
+ } | null;
351
472
  export declare function checkDuration(model: string, duration: number | undefined, opts?: {
352
473
  videoResolution?: string;
353
474
  promptMode?: string;
475
+ label?: string;
354
476
  }): string | null;
355
477
  /** e.g. "kling-v3.0-std/kling-v3.0-pro: 16:9, 9:16, 1:1 · seedance-2: 21:9, …" */
356
478
  export declare function describeAspectRatios(models: readonly string[], provider?: string): string;
357
- /** e.g. "seedance-2: 480p, 720p, 1080p, 4k (default 1080p) · ltx-2-5-pro: 720p, 1080p (default 1080p)" */
479
+ /** e.g. "seedance-2: 480p, 720p, 1080p, 4k (default 1080p) · wan-3.0: 480p, 720p, 1080p (default 720p)" */
358
480
  export declare function describeVideoResolutions(models: readonly string[]): string;
359
- /** e.g. "kling-v3.0-std: 3-15s · ltx-2-5: 6s/8s/10s/12s/14s/16s/18s/20s (1440p/4k: 6s/8s/10s only)" */
481
+ /** e.g. "kling-v3.0-std: 3-15s · seedance-2.5: 4-30s" */
360
482
  export declare function describeDurations(models: readonly string[]): string;
361
483
  /** e.g. "seedance-2: 9 · seedance-2.5: 30 · omni-flash: 10 · seedance-2.5-edit: 0 (prompt + source clip only)" */
362
484
  export declare function describeReferenceImageCaps(models: readonly string[]): string;