@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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/manual/content.d.ts +1 -1
- package/dist/manual/content.js +1 -1
- package/dist/operations/confirm-threshold.d.ts +2 -0
- package/dist/operations/confirm-threshold.js +2 -0
- package/dist/operations/index.d.ts +246 -234
- package/dist/operations/index.js +194 -57
- package/dist/operations/surface.d.ts +1 -2
- package/dist/operations/surface.js +13 -3
- package/dist/prompts/agent-doctrine.js +2 -2
- package/dist/prompts/banned-tokens.d.ts +2 -14
- package/dist/prompts/banned-tokens.js +5 -58
- package/dist/prompts/guide-bans.d.ts +17 -0
- package/dist/prompts/guide-bans.js +50 -0
- package/dist/prompts/model-capabilities.d.ts +10 -0
- package/dist/prompts/model-capabilities.js +87 -2
- package/dist/prompts/model-facts.js +11 -0
- package/dist/prompts/prompting-tips.d.ts +1 -1
- package/dist/prompts/prompting-tips.js +48 -0
- package/dist/prompts/reference-composer.d.ts +1 -0
- package/dist/prompts/reference-composer.js +3 -0
- package/dist/skills/content.js +2 -1
- package/package.json +1 -1
package/dist/operations/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CONFIRM_CREDITS } from './confirm-threshold.js';
|
|
1
2
|
import { randomUUID } from 'node:crypto';
|
|
2
3
|
import { MAX_IMAGE_VARIATIONS, SHEET_TOOL_ASPECT_RATIO, SHEET_TOOL_GPT_QUALITY } from '../prompts/generation-policy.js';
|
|
3
4
|
import { STYLE_LIBRARY, DEFAULT_STYLE_ID } from '../prompts/style-library.js';
|
|
@@ -48,7 +49,7 @@ toolModelFor, CHATGPT_FRAMING_RATIOS, } from '../prompts/model-facts.js';
|
|
|
48
49
|
// quoted for a model at 1080p that only took 8s there. A customer burned a
|
|
49
50
|
// round trip on `4:5` + Seedance: accepted here, queued, credits reserved,
|
|
50
51
|
// 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';
|
|
52
|
+
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
53
|
// Per-model warnings are extracted from skill @banned blocks. They ride the
|
|
53
54
|
// selected model's estimate and submitted-prompt result, never another model's schema.
|
|
54
55
|
import { describeBannedTokens, bannedTokenWarning, describeBannedTokensForSkill, } from '../prompts/banned-tokens.js';
|
|
@@ -57,6 +58,7 @@ import { describeBannedTokens, bannedTokenWarning, describeBannedTokensForSkill,
|
|
|
57
58
|
// that make a shot good rather than merely un-bad — and it rides the estimate
|
|
58
59
|
// RESULT, which the doctrine already makes the agent call before generating.
|
|
59
60
|
// Zero prefix bytes, present at the moment the model has just been named.
|
|
61
|
+
import { hasReferenceMention } from '../prompts/reference-composer.js';
|
|
60
62
|
import { describeCraftCard } from '../prompts/craft-cards.js';
|
|
61
63
|
// ONE captioning rule for a generated asset, shared with the desktop gallery.
|
|
62
64
|
import { assetCaption } from '../prompts/asset-label.js';
|
|
@@ -95,35 +97,62 @@ export class GuideNotReadError extends Error {
|
|
|
95
97
|
model;
|
|
96
98
|
guide;
|
|
97
99
|
code = 'GUIDE_NOT_READ';
|
|
98
|
-
constructor(model, guide) {
|
|
100
|
+
constructor(model, guide, full = false) {
|
|
101
|
+
const request = `topic "${guide}"${full ? ' and depth "full"' : ''}`;
|
|
99
102
|
const head = `Refused: this session has not read ${guide}, the guide for ${model}. Nothing was generated or charged. `;
|
|
100
103
|
const body = brainSkills().skills[guide];
|
|
101
104
|
const served = servedBrain();
|
|
102
105
|
const locked = body === undefined ? served.locked.find(entry => entry.name === guide) : undefined;
|
|
103
106
|
super(body !== undefined
|
|
104
107
|
? head +
|
|
105
|
-
`Call slates_get_prompting_guide with
|
|
108
|
+
`Call slates_get_prompting_guide with ${request}, rewrite the prompt against it, then call this again. Its card:\n\n` +
|
|
106
109
|
// The card this user's brain serves, so a model guide from their My brain is the one in the refusal.
|
|
107
110
|
describeCraftCard(guide, body)
|
|
108
111
|
: locked
|
|
109
112
|
? // Past this account's tier: no body here, so the server's notice (its card included) is what it reads.
|
|
110
113
|
head +
|
|
111
|
-
`Call slates_get_prompting_guide with
|
|
114
|
+
`Call slates_get_prompting_guide with ${request}, rewrite the prompt against what it says, then call this again. What it says:\n\n` +
|
|
112
115
|
(locked.notice ?? `${guide} is not open to this account. Run the job on the general rules.`)
|
|
113
116
|
: // No copy here and none locked: the brain never arrived, so asking for the guide again cannot help.
|
|
114
117
|
head +
|
|
115
118
|
`The guide comes from the connected Slates account and is not on this machine (${served.problem ?? 'no brain received yet'}). ` +
|
|
116
|
-
`${CONNECT_FOR_BRAIN}; then call slates_get_prompting_guide with
|
|
119
|
+
`${CONNECT_FOR_BRAIN}; then call slates_get_prompting_guide with ${request} and call this again.`);
|
|
117
120
|
this.model = model;
|
|
118
121
|
this.guide = guide;
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
|
-
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Routine calls can use a delivered estimate card. Other calls and retries need the full guide.
|
|
126
|
+
* A locked guide's returned notice counts as the most this account can read.
|
|
127
|
+
*/
|
|
128
|
+
export function recordGenerationRejection(ctx, fallbackOp, model, topics = new Set()) {
|
|
129
|
+
const rejected = ctx.guideEvidence?.rejected;
|
|
130
|
+
if (!rejected)
|
|
131
|
+
return;
|
|
132
|
+
if (topics.size) {
|
|
133
|
+
for (const topic of topics)
|
|
134
|
+
rejected.add(topic);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
rejected.add((typeof model === 'string' && resolveGuideTopic(model)) || fallbackOp);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function requireGuideRead(ctx, model, guide = model ? resolveGuideTopic(model) : null, routineOp) {
|
|
141
|
+
if (!ctx || !model || !guide)
|
|
142
|
+
return;
|
|
143
|
+
ctx.onGenerationGuide?.(guide);
|
|
144
|
+
if (!ctx.guidesRead)
|
|
145
|
+
return;
|
|
146
|
+
const evidence = ctx.guideEvidence;
|
|
147
|
+
if (!evidence) {
|
|
148
|
+
if (!ctx.guidesRead.has(guide))
|
|
149
|
+
throw new GuideNotReadError(model, guide);
|
|
124
150
|
return;
|
|
125
|
-
|
|
126
|
-
|
|
151
|
+
}
|
|
152
|
+
const full = !routineOp || evidence.rejected.has(guide) || evidence.rejected.has(routineOp);
|
|
153
|
+
if (evidence.full.has(guide) || (!full && (evidence.cards.has(guide) || ctx.guidesRead.has(guide))))
|
|
154
|
+
return;
|
|
155
|
+
throw new GuideNotReadError(model, guide, full);
|
|
127
156
|
}
|
|
128
157
|
/** Throw if the caller has cancelled. Call between billable items, never inside one. */
|
|
129
158
|
function throwIfCancelled(ctx, detail) {
|
|
@@ -172,7 +201,7 @@ function ok(data, text) {
|
|
|
172
201
|
// the same credit value); balances the same. Read via creditCost(); display
|
|
173
202
|
// via fmtCredits(). The confirm gate fires above CONFIRM_CREDITS (≈ the old
|
|
174
203
|
// $0.50 gate at the 3¢/credit peg).
|
|
175
|
-
export
|
|
204
|
+
export { CONFIRM_CREDITS } from './confirm-threshold.js';
|
|
176
205
|
const CENTS_PER_CREDIT = 3; // peg: 1 credit = 3¢ billed = 2¢ COGS (mirror of slates-api)
|
|
177
206
|
/**
|
|
178
207
|
* The desktop deviation guard's ceiling multiplier: the Studio Agent pauses and
|
|
@@ -952,7 +981,7 @@ function describeComposer(r) {
|
|
|
952
981
|
? `a draft from ${r.draftFrom.code ?? r.draftFrom.assetId}`
|
|
953
982
|
: 'an unsaved draft';
|
|
954
983
|
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
|
|
984
|
+
lines.push(`Words (${promptLengthFor(r.model.id, r.prompt)}${r.promptMax ? `/${r.promptMax}` : ''}): ${r.prompt ? JSON.stringify(r.prompt) : 'none'}`);
|
|
956
985
|
if (r.params.length)
|
|
957
986
|
lines.push(`Settings: ${r.params.map((p) => `${p.label} ${p.value || '(none)'}`).join(' · ')}`);
|
|
958
987
|
if (r.tiles.length) {
|
|
@@ -1751,6 +1780,10 @@ export const VIDEO_MODELS = [
|
|
|
1751
1780
|
// start and end frames OR references (10 images, 5 videos, 5 audio clips).
|
|
1752
1781
|
// Reference video seconds bill on top of output seconds, so it has a vref key.
|
|
1753
1782
|
'wan-3.0',
|
|
1783
|
+
// MAGI-2 (added 2026-11-26): 4-30s at 1080p only, sound on or off, start and
|
|
1784
|
+
// end frames OR references (10 images, 5 videos, 5 audio clips). One price per
|
|
1785
|
+
// output second: references and sound do not move it.
|
|
1786
|
+
'magi-2',
|
|
1754
1787
|
// Kling 4.0 (added 2026-10-23 beside 3.0, which stays the default Kling):
|
|
1755
1788
|
// one row with no Standard/Pro split, frames or text only, sound always on.
|
|
1756
1789
|
// `kling-v4.0` never starts with `kling-v3.0`, so no 3.0 branch can take it.
|
|
@@ -1876,9 +1909,10 @@ function editClipBounds(model) {
|
|
|
1876
1909
|
const EDIT_VIDEO_RESOLUTIONS = videoResolutionUnion(['seedance-2.5-edit', 'omni-flash-1-2-edit']);
|
|
1877
1910
|
export const estimateGenerationCost = {
|
|
1878
1911
|
id: 'slates_estimate_generation_cost',
|
|
1879
|
-
description: 'Quote credits before
|
|
1912
|
+
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
1913
|
input: z.object({
|
|
1881
|
-
model: z.string().describe('
|
|
1914
|
+
model: z.string().describe('Generation model id (e.g. "seedance-2") or exact cost key (e.g. "seedance-2-1080p-8s").'),
|
|
1915
|
+
prompt: z.string().optional().describe('Check prompt length before quoting.'),
|
|
1882
1916
|
quantity: z.number().int().min(1).max(10).optional().describe('Number of generations (default 1)'),
|
|
1883
1917
|
// Video windows and resolutions GENERATED from MODEL_CAPABILITIES. The
|
|
1884
1918
|
// hand-typed "Video 3-15" here was wrong the day seedance-2.5 (4-30s)
|
|
@@ -1905,6 +1939,9 @@ export const estimateGenerationCost = {
|
|
|
1905
1939
|
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
1940
|
}),
|
|
1907
1941
|
async run(input, ctx) {
|
|
1942
|
+
const lengthError = promptLengthError(resolveVideoModel(input.model)?.model ?? input.model, input.prompt);
|
|
1943
|
+
if (lengthError)
|
|
1944
|
+
throw new Error(lengthError);
|
|
1908
1945
|
// A retired seat is never quoted: its keys still bill older desktops, and `nano-banana-2-1k` (the
|
|
1909
1946
|
// retired Nano Banana 2 at 1K) would otherwise answer an agent that meant Nano Banana 2.1.
|
|
1910
1947
|
const retired = retiredModelOfKey(input.model);
|
|
@@ -2068,6 +2105,32 @@ export const estimateGenerationCost = {
|
|
|
2068
2105
|
});
|
|
2069
2106
|
}
|
|
2070
2107
|
}
|
|
2108
|
+
// 3b) 5s-block tool keys (motion transfer & lip-sync): accept both dynamic
|
|
2109
|
+
// block keys (`kling-mc-std-10s`) and base stem + duration (`kling-mc-std`, 10).
|
|
2110
|
+
// Query the cloud's dynamic costKey endpoint first; fall back to scaling the
|
|
2111
|
+
// registry's 5s block row when a static price list does not synthesize rows.
|
|
2112
|
+
if (!key && !input.seedanceDraft) {
|
|
2113
|
+
const toolKeyMatch = /^(kling-lip-sync-(?:video|avatar|avatar-pro)|kling-mc-(?:std|pro))(?:-(?:(\d+)s))?$/.exec(input.model);
|
|
2114
|
+
if (toolKeyMatch) {
|
|
2115
|
+
const stem = toolKeyMatch[1];
|
|
2116
|
+
const secs = toolKeyMatch[2] ? Number(toolKeyMatch[2]) : input.duration;
|
|
2117
|
+
if (!secs) {
|
|
2118
|
+
return ok({
|
|
2119
|
+
requires_clarification: true,
|
|
2120
|
+
missing: ['duration'],
|
|
2121
|
+
message: `${stem} bills per 5-second block of the driving clip — pass duration in seconds (or a block key like ${stem}-10s).`,
|
|
2122
|
+
});
|
|
2123
|
+
}
|
|
2124
|
+
const blocks = Math.max(1, toolBlocks(secs));
|
|
2125
|
+
key = toolBlockKey(stem, blocks);
|
|
2126
|
+
await loadDynamicPrice(ctx, byKey, key);
|
|
2127
|
+
if (!byKey.has(key)) {
|
|
2128
|
+
const oneBlock = byKey.get(toolBlockKey(stem, 1));
|
|
2129
|
+
if (oneBlock != null)
|
|
2130
|
+
byKey.set(key, oneBlock * blocks);
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2071
2134
|
await loadDynamicPrice(ctx, byKey, key);
|
|
2072
2135
|
const perCredits = key != null ? byKey.get(key) : undefined;
|
|
2073
2136
|
if (key != null && perCredits == null && key !== input.model) {
|
|
@@ -3440,7 +3503,7 @@ export const generateImage = {
|
|
|
3440
3503
|
// demonstrably skipped the call that would have taught it.
|
|
3441
3504
|
describeBannedTokens('image'),
|
|
3442
3505
|
input: z.object({
|
|
3443
|
-
prompt: z.string().min(1)
|
|
3506
|
+
prompt: z.string().min(1),
|
|
3444
3507
|
// Routing GENERATED from MODEL_FACTS.
|
|
3445
3508
|
model: zEnum(IMAGE_MODELS).optional().describe(`Image model. Omitted: ${DEFAULT_IMAGE_MODEL} with projectId, ${HEADLESS_IMAGE_MODEL} (the only headless seat) without.\n` +
|
|
3446
3509
|
`${describeRouting('image')}\n` +
|
|
@@ -3475,13 +3538,17 @@ export const generateImage = {
|
|
|
3475
3538
|
? await defaultImageSeatFor(() => ctx.desktop(), input.model, `${input.model ?? DEFAULT_IMAGE_MODEL} generation`)
|
|
3476
3539
|
: { model: input.model ?? HEADLESS_IMAGE_MODEL, note: '' };
|
|
3477
3540
|
const imageModel = seat.model;
|
|
3541
|
+
const lengthError = promptLengthError(imageModel, input.prompt);
|
|
3542
|
+
if (lengthError)
|
|
3543
|
+
throw new Error(lengthError);
|
|
3478
3544
|
const dropped = droppedImageParams(imageModel, input);
|
|
3479
3545
|
if (dropped)
|
|
3480
3546
|
return ok(dropped);
|
|
3481
3547
|
// A desktop before the folder rule ignores folderId and files at the root.
|
|
3482
3548
|
if (input.folderId !== undefined)
|
|
3483
3549
|
await ctx.desktop().requireCapability('media-folder', 'choosing the folder a result lands in');
|
|
3484
|
-
|
|
3550
|
+
const multiReference = (input.referenceAssetIds?.length ?? 0) + (input.referenceImageUrls?.length ?? 0) > 1;
|
|
3551
|
+
requireGuideRead(ctx, imageModel, undefined, !multiReference && !hasReferenceMention(input.prompt) && (input.count ?? 1) === 1 ? generateImage.id : undefined);
|
|
3485
3552
|
const promptWarning = bannedTokenWarning(input.prompt, 'image', promptingSkillFor(imageModel));
|
|
3486
3553
|
input = { ...input, resolution: input.resolution ?? defaultImageResolutionFor(imageModel) };
|
|
3487
3554
|
if (!input.aspectRatio || !input.resolution) {
|
|
@@ -3958,7 +4025,7 @@ export const editImage = {
|
|
|
3958
4025
|
input: z.object({
|
|
3959
4026
|
projectId: z.string().uuid(),
|
|
3960
4027
|
sourceAssetId: z.string().uuid().describe('Image asset to edit. Must exist in the project. ' + ASSET_UUID_ONLY),
|
|
3961
|
-
prompt: z.string().min(1).
|
|
4028
|
+
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
4029
|
editModel: zEnum(IMAGE_MODELS).optional(),
|
|
3963
4030
|
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
4031
|
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 +4049,9 @@ export const editImage = {
|
|
|
3982
4049
|
? await defaultImageSeatFor(() => desktop, undefined, 'image editing')
|
|
3983
4050
|
: { model: toolModelFor('image-edit'), note: '' };
|
|
3984
4051
|
const editModel = seat.model;
|
|
4052
|
+
const lengthError = promptLengthError(editModel, input.prompt);
|
|
4053
|
+
if (lengthError)
|
|
4054
|
+
throw new Error(lengthError);
|
|
3985
4055
|
const resolution = input.resolution ?? defaultImageResolutionFor(editModel);
|
|
3986
4056
|
// The same gates as slates_generate_image, from the same functions.
|
|
3987
4057
|
const refusal = droppedImageParams(editModel, input) ??
|
|
@@ -4391,6 +4461,12 @@ export function videoCostKey(input) {
|
|
|
4391
4461
|
}
|
|
4392
4462
|
return `wan-3.0-${res}-${input.duration}s`;
|
|
4393
4463
|
}
|
|
4464
|
+
if (input.model === 'magi-2') {
|
|
4465
|
+
// Mirrors magiCreditKey() in slate/src/shared/pricing.ts. One resolution
|
|
4466
|
+
// and one rate per output second on every endpoint: references, sound and
|
|
4467
|
+
// frames do not move the price, so the key is the length alone.
|
|
4468
|
+
return `magi-2-1080p-${input.duration}s`;
|
|
4469
|
+
}
|
|
4394
4470
|
throw new Error(`Unknown video model: ${input.model}`);
|
|
4395
4471
|
}
|
|
4396
4472
|
// Kling O3 video-to-video edit cost key — mirrors klingEditCreditKey() in
|
|
@@ -4611,6 +4687,9 @@ function resolveVideoModel(raw) {
|
|
|
4611
4687
|
'hailuo-3': 'minimax-h3',
|
|
4612
4688
|
'hailuo-3.0': 'minimax-h3',
|
|
4613
4689
|
hailuo: 'minimax-h3',
|
|
4690
|
+
magi: 'magi-2',
|
|
4691
|
+
magi2: 'magi-2',
|
|
4692
|
+
'magi-2.0': 'magi-2',
|
|
4614
4693
|
};
|
|
4615
4694
|
if (aliases[s]) {
|
|
4616
4695
|
out.model = aliases[s];
|
|
@@ -4700,14 +4779,14 @@ export const generateVideo = {
|
|
|
4700
4779
|
billable: true,
|
|
4701
4780
|
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
4781
|
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
|
|
4782
|
+
') 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
4783
|
confirmGateSentence('any image reference (frame, ingredient, character, environment or style)') +
|
|
4705
4784
|
' 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
4785
|
// GENERATED from the skill's own slop-token list. Always in context on both
|
|
4707
4786
|
// surfaces, so it survives an agent that skips slates_get_prompting_guide.
|
|
4708
4787
|
describeBannedTokens('video'),
|
|
4709
4788
|
input: z.object({
|
|
4710
|
-
prompt: z.string().
|
|
4789
|
+
prompt: z.string().optional().describe("Optional when the selected model can animate a start frame on its own."),
|
|
4711
4790
|
// ROUTING doctrine only. Every capability number was stripped on 2026-08-16
|
|
4712
4791
|
// and now lives in the aspectRatio / duration / videoResolution descriptions
|
|
4713
4792
|
// below, generated from MODEL_CAPABILITIES. "16:9 only" for a model and
|
|
@@ -4758,7 +4837,7 @@ export const generateVideo = {
|
|
|
4758
4837
|
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
4838
|
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
4839
|
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(
|
|
4840
|
+
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
4841
|
audioLanguage: z.enum(['EN', 'ZH', 'JA', 'KO', 'ES']).optional().describe('Any Kling 3.0 model with sound on — language for dialogue.'),
|
|
4763
4842
|
generateMusic: z.boolean().optional().describe('Any Kling 3.0 model with sound on — auto-generate background music.'),
|
|
4764
4843
|
seedanceDraft: z.boolean().optional().describe('Create a finishable Seedance 2.5 preview at 480p.'),
|
|
@@ -4791,7 +4870,12 @@ export const generateVideo = {
|
|
|
4791
4870
|
}
|
|
4792
4871
|
if (input.seedanceDraft)
|
|
4793
4872
|
input.videoResolution = draftResolution(input.model, input.videoResolution ?? resolved.videoResolution);
|
|
4794
|
-
|
|
4873
|
+
const imageRefs = (input.firstFrameAssetId ? 1 : 0) + (input.lastFrameAssetId ? 1 : 0) +
|
|
4874
|
+
(input.ingredientAssetIds?.length ?? 0) + (input.characterAssetIds?.length ?? 0) +
|
|
4875
|
+
(input.environmentAssetIds?.length ?? 0) + (input.styleAssetIds?.length ?? 0);
|
|
4876
|
+
const sceneReference = input.videoReferenceAssetId || input.videoReferenceAssetIds?.length ||
|
|
4877
|
+
input.audioReferenceAssetId || input.audioReferenceAssetIds?.length;
|
|
4878
|
+
requireGuideRead(ctx, input.model, undefined, imageRefs <= 1 && !input.lastFrameAssetId && !sceneReference && !hasReferenceMention(input.prompt ?? '') ? generateVideo.id : undefined);
|
|
4795
4879
|
if (input.duration == null && resolved.duration != null)
|
|
4796
4880
|
input.duration = resolved.duration;
|
|
4797
4881
|
if (input.videoResolution == null && resolved.videoResolution != null)
|
|
@@ -4808,6 +4892,15 @@ export const generateVideo = {
|
|
|
4808
4892
|
// not reasonable for video given the cost.
|
|
4809
4893
|
// Non-blocking prompt hygiene, computed once. Reported on the gates that
|
|
4810
4894
|
// fire BEFORE any spend, where a rewrite is still free.
|
|
4895
|
+
const promptError = videoPromptError(input.model, input.prompt, !!input.firstFrameAssetId);
|
|
4896
|
+
if (promptError)
|
|
4897
|
+
return ok({ requires_clarification: true, missing: ['prompt'], message: promptError });
|
|
4898
|
+
input.prompt ??= '';
|
|
4899
|
+
const needsRatio = aspectRatioApplies(input.model, {
|
|
4900
|
+
firstFrame: !!input.firstFrameAssetId,
|
|
4901
|
+
referenceImages: [input.ingredientAssetIds, input.characterAssetIds, input.environmentAssetIds, input.styleAssetIds]
|
|
4902
|
+
.reduce((n, ids) => n + (ids?.length ?? 0), 0),
|
|
4903
|
+
});
|
|
4811
4904
|
const promptWarning = bannedTokenWarning(input.prompt, 'video', promptingSkillFor(resolved.model));
|
|
4812
4905
|
if (!input.projectId) {
|
|
4813
4906
|
return ok({
|
|
@@ -4818,9 +4911,9 @@ export const generateVideo = {
|
|
|
4818
4911
|
'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
4912
|
});
|
|
4820
4913
|
}
|
|
4821
|
-
if (!input.aspectRatio || !input.duration) {
|
|
4914
|
+
if ((needsRatio && !input.aspectRatio) || !input.duration) {
|
|
4822
4915
|
const missing = [];
|
|
4823
|
-
if (!input.aspectRatio)
|
|
4916
|
+
if (needsRatio && !input.aspectRatio)
|
|
4824
4917
|
missing.push('aspectRatio');
|
|
4825
4918
|
if (!input.duration)
|
|
4826
4919
|
missing.push('duration');
|
|
@@ -4835,7 +4928,7 @@ export const generateVideo = {
|
|
|
4835
4928
|
// a model locked to 16:9, "Kling/Seedance support 1:1 16:9 9:16 4:3 3:4
|
|
4836
4929
|
// 21:9" and "Kling 5-15s" — three wrong claims in one sentence.
|
|
4837
4930
|
`or ask the user. ` +
|
|
4838
|
-
`Aspect ratio for ${input.model}: ${aspectRatiosFor(input.model, AGENT_ROUTE_PROVIDER).join(', ')}. ` +
|
|
4931
|
+
(needsRatio ? `Aspect ratio for ${input.model}: ${aspectRatiosFor(input.model, AGENT_ROUTE_PROVIDER).join(', ')}. ` : '') +
|
|
4839
4932
|
`Duration: ${describeDurations([input.model])}. ` +
|
|
4840
4933
|
`Cost scales linearly with duration.`,
|
|
4841
4934
|
});
|
|
@@ -4895,14 +4988,16 @@ export const generateVideo = {
|
|
|
4895
4988
|
return ok({ requires_clarification: true, missing: [], message: shapeError });
|
|
4896
4989
|
}
|
|
4897
4990
|
}
|
|
4898
|
-
// Wan 3.0's SHAPE constraints. The same split as Omni Flash:
|
|
4899
|
-
// takes a start frame and an optional end frame,
|
|
4900
|
-
// images, videos and audio, and
|
|
4901
|
-
// exclusive"
|
|
4991
|
+
// Wan 3.0's and MAGI-2's SHAPE constraints. The same split as Omni Flash:
|
|
4992
|
+
// image-to-video takes a start frame and an optional end frame,
|
|
4993
|
+
// reference-to-video takes images, videos and audio, and the two never mix
|
|
4994
|
+
// (Alibaba: "mutually exclusive"; MAGI-2: references "cannot be added to a
|
|
4995
|
+
// frame request"). The reference endpoint has no frame slot, so frames with
|
|
4902
4996
|
// references are refused, never dropped (the MiniMax H3 rule, slate
|
|
4903
4997
|
// .claude/rules/models.md invariant 7). Caps are read from the SSOT.
|
|
4904
|
-
if (input.model === 'wan-3.0') {
|
|
4905
|
-
const
|
|
4998
|
+
if (input.model === 'wan-3.0' || input.model === 'magi-2') {
|
|
4999
|
+
const label = input.model === 'wan-3.0' ? 'Wan 3.0' : 'MAGI-2';
|
|
5000
|
+
const cap = getModelCapability(input.model);
|
|
4906
5001
|
const imageRefs = (input.ingredientAssetIds?.length ?? 0) +
|
|
4907
5002
|
(input.characterAssetIds?.length ?? 0) +
|
|
4908
5003
|
(input.environmentAssetIds?.length ?? 0) +
|
|
@@ -4918,11 +5013,11 @@ export const generateVideo = {
|
|
|
4918
5013
|
[refAll, cap?.maxReferenceFilesTotal, 'reference files across all types'],
|
|
4919
5014
|
].find(([n, max]) => max !== undefined && n > max);
|
|
4920
5015
|
const shapeError = refAll > 0 && (input.firstFrameAssetId || input.lastFrameAssetId)
|
|
4921
|
-
?
|
|
5016
|
+
? `${label} takes first/last frames OR references, not both: its reference endpoint has no frame slots. Drop one side.`
|
|
4922
5017
|
: input.lastFrameAssetId && !input.firstFrameAssetId
|
|
4923
|
-
?
|
|
5018
|
+
? `${label} needs a start frame (firstFrameAssetId) with a last frame.`
|
|
4924
5019
|
: overCap
|
|
4925
|
-
?
|
|
5020
|
+
? `${label} takes at most ${overCap[1]} ${overCap[2]} (you passed ${overCap[0]}).`
|
|
4926
5021
|
: null;
|
|
4927
5022
|
if (shapeError) {
|
|
4928
5023
|
return ok({ requires_clarification: true, missing: [], message: shapeError });
|
|
@@ -5504,7 +5599,11 @@ export const generateAudio = {
|
|
|
5504
5599
|
folderId: folderIdField,
|
|
5505
5600
|
}),
|
|
5506
5601
|
run: async (input, ctx) => {
|
|
5507
|
-
|
|
5602
|
+
const multiReference = (input.audioReferenceAssetIds?.length ?? 0) + (input.imageReferenceAssetId ? 1 : 0) > 1;
|
|
5603
|
+
requireGuideRead(ctx, input.model, undefined, multiReference ? undefined : generateAudio.id);
|
|
5604
|
+
const lengthError = promptLengthError(input.model, input.prompt);
|
|
5605
|
+
if (lengthError)
|
|
5606
|
+
throw new Error(lengthError);
|
|
5508
5607
|
// A desktop before the folder rule ignores folderId and files at the root.
|
|
5509
5608
|
if (input.folderId !== undefined)
|
|
5510
5609
|
await ctx.desktop().requireCapability('media-folder', 'choosing the folder a result lands in');
|
|
@@ -5526,8 +5625,9 @@ export const generateAudio = {
|
|
|
5526
5625
|
// because "the words that get spoken" and "what you asked for" are the
|
|
5527
5626
|
// same thing here. That also means the character count is knowable
|
|
5528
5627
|
// client-side, which is what makes the quote below exact.
|
|
5529
|
-
|
|
5530
|
-
|
|
5628
|
+
const characters = promptLengthFor(input.model, input.prompt);
|
|
5629
|
+
if (characters > TTS_MAX_CHARACTERS) {
|
|
5630
|
+
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
5631
|
}
|
|
5532
5632
|
if (input.durationSeconds != null) {
|
|
5533
5633
|
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 +5669,9 @@ export const generateAudio = {
|
|
|
5569
5669
|
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
5670
|
});
|
|
5571
5671
|
}
|
|
5572
|
-
|
|
5573
|
-
|
|
5672
|
+
const characters = promptLengthFor(input.model, input.prompt);
|
|
5673
|
+
if (characters > 450) {
|
|
5674
|
+
throw new Error(`Sound Effects accepts up to 450 characters — this prompt is ${characters}.`);
|
|
5574
5675
|
}
|
|
5575
5676
|
}
|
|
5576
5677
|
await ctx.desktop().requireCapability('audio-generation', 'audio generation');
|
|
@@ -5596,7 +5697,7 @@ export const generateAudio = {
|
|
|
5596
5697
|
const costKey = audioCostKey({
|
|
5597
5698
|
model: input.model,
|
|
5598
5699
|
durationSeconds: seconds,
|
|
5599
|
-
characters: input.model === TTS_MODEL ? input.prompt
|
|
5700
|
+
characters: input.model === TTS_MODEL ? promptLengthFor(input.model, input.prompt) : undefined,
|
|
5600
5701
|
});
|
|
5601
5702
|
const entry = registry.models.find((m) => m.model === costKey) ??
|
|
5602
5703
|
(await cloud.get(`/api/agent/models?costKey=${encodeURIComponent(costKey)}`)).models[0];
|
|
@@ -6040,7 +6141,7 @@ export const editVideo = {
|
|
|
6040
6141
|
input: z.object({
|
|
6041
6142
|
projectId: z.string().uuid().describe('Project the source clip lives in.'),
|
|
6042
6143
|
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).
|
|
6144
|
+
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
6145
|
// Clip windows and resolutions GENERATED from MODEL_CAPABILITIES.
|
|
6045
6146
|
model: zEnum(EDIT_VIDEO_MODELS).optional().describe(
|
|
6046
6147
|
// Routing GENERATED from MODEL_FACTS; the paragraph that stood here was
|
|
@@ -6068,6 +6169,9 @@ export const editVideo = {
|
|
|
6068
6169
|
await desktop.requireCapability('background-generation', 'background generation');
|
|
6069
6170
|
}
|
|
6070
6171
|
const model = input.model ?? EDIT_VIDEO_DEFAULT;
|
|
6172
|
+
const lengthError = promptLengthError(model, input.prompt);
|
|
6173
|
+
if (lengthError)
|
|
6174
|
+
throw new Error(lengthError);
|
|
6071
6175
|
requireGuideRead(ctx, model);
|
|
6072
6176
|
const isOmniFlashEdit = model === 'omni-flash-1-2-edit';
|
|
6073
6177
|
const isSeedanceEdit = model === 'seedance-2.5-edit';
|
|
@@ -6297,7 +6401,10 @@ export const getGenerationStatus = {
|
|
|
6297
6401
|
const r = await desktop.get('/agent/generation/status', { id: input.generationId });
|
|
6298
6402
|
const g = r.generation;
|
|
6299
6403
|
const status = g?.status ?? r.status;
|
|
6300
|
-
const
|
|
6404
|
+
const failed = status === 'failed' || status === 'rejected';
|
|
6405
|
+
if (failed)
|
|
6406
|
+
recordGenerationRejection(ctx, getGenerationStatus.id, g?.model);
|
|
6407
|
+
const terminal = status === 'completed' || failed || status === 'cancelled';
|
|
6301
6408
|
if (terminal || Date.now() >= deadline) {
|
|
6302
6409
|
if (!g)
|
|
6303
6410
|
return ok(r);
|
|
@@ -6781,9 +6888,10 @@ export const resolveReviewNote = {
|
|
|
6781
6888
|
const META_WINNERS = 'the Winners Loop (ad results per recipe)';
|
|
6782
6889
|
export const getClientAdReport = {
|
|
6783
6890
|
id: 'slates_get_client_ad_report',
|
|
6784
|
-
|
|
6891
|
+
// No Google Ads: Google's Ads API policy bars re-exposing it through an MCP server on our Cloud project.
|
|
6892
|
+
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
6893
|
input: z.object({
|
|
6786
|
-
platform: z.enum(['
|
|
6894
|
+
platform: z.enum(['tiktok']),
|
|
6787
6895
|
accountId: z.string().regex(/^\d{1,24}$/).optional(),
|
|
6788
6896
|
managerId: z.string().regex(/^\d{10}$/).optional(),
|
|
6789
6897
|
since: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
@@ -9270,7 +9378,12 @@ async function shotRowId(ref, read) {
|
|
|
9270
9378
|
/** Params whose legality depends on the Shot's model. */
|
|
9271
9379
|
const MODEL_BOUND_SHOT_PARAMS = ['aspectRatio', 'videoResolution', 'imageResolution', 'duration', 'seedanceDraft'];
|
|
9272
9380
|
/** An edit that names no model is checked against the stored Shot's, the gate create runs. */
|
|
9273
|
-
async function assertStoredShotCapabilities(model, params, read) {
|
|
9381
|
+
async function assertStoredShotCapabilities(model, params, read, prompt) {
|
|
9382
|
+
if (prompt !== undefined || model !== undefined) {
|
|
9383
|
+
const error = promptLengthError(model ?? (await read()).model, prompt ?? (await read()).rawPrompt);
|
|
9384
|
+
if (error)
|
|
9385
|
+
throw new Error(error);
|
|
9386
|
+
}
|
|
9274
9387
|
if (model !== undefined || !MODEL_BOUND_SHOT_PARAMS.some((k) => params?.[k] !== undefined))
|
|
9275
9388
|
return null;
|
|
9276
9389
|
return assertShotCapabilities((await read()).model ?? undefined, params);
|
|
@@ -9300,7 +9413,7 @@ export const createShot = {
|
|
|
9300
9413
|
input: z.object({
|
|
9301
9414
|
projectId: z.string().uuid(),
|
|
9302
9415
|
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).
|
|
9416
|
+
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
9417
|
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
9418
|
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
9419
|
params: shotParamsSchema,
|
|
@@ -9320,6 +9433,9 @@ export const createShot = {
|
|
|
9320
9433
|
async run(input, ctx) {
|
|
9321
9434
|
if (!input.prompt && !input.fromAssetId)
|
|
9322
9435
|
throw new Error('Pass a prompt, or fromAssetId to save a result\'s recorded recipe as the Shot.');
|
|
9436
|
+
const lengthError = promptLengthError(input.model, input.prompt);
|
|
9437
|
+
if (lengthError)
|
|
9438
|
+
throw new Error(lengthError);
|
|
9323
9439
|
const capErr = assertShotCapabilities(input.model, input.params);
|
|
9324
9440
|
if (capErr)
|
|
9325
9441
|
return capErr;
|
|
@@ -9407,7 +9523,7 @@ export const updateShot = {
|
|
|
9407
9523
|
shotId: z.string().describe('The Shot id, or its SHOT-A code as shown on the row.'),
|
|
9408
9524
|
projectId: z.string().uuid().describe('The Shot\'s project — badge codes and entity ids resolve against it.'),
|
|
9409
9525
|
name: z.string().max(120).optional(),
|
|
9410
|
-
prompt: z.string().
|
|
9526
|
+
prompt: z.string().optional(),
|
|
9411
9527
|
model: z.string().optional(),
|
|
9412
9528
|
params: shotParamsSchemaTerse,
|
|
9413
9529
|
refs: shotRefsSchemaTerse,
|
|
@@ -9432,7 +9548,7 @@ export const updateShot = {
|
|
|
9432
9548
|
const desktop = ctx.desktop();
|
|
9433
9549
|
await desktop.requireCapability('shots', 'saved Shots');
|
|
9434
9550
|
const read = shotReader(desktop, input.shotId, input.projectId);
|
|
9435
|
-
const storedErr = await assertStoredShotCapabilities(input.model, input.params, read);
|
|
9551
|
+
const storedErr = await assertStoredShotCapabilities(input.model, input.params, read, input.prompt);
|
|
9436
9552
|
if (storedErr)
|
|
9437
9553
|
return storedErr;
|
|
9438
9554
|
await requireDraftShotDesktop(desktop, input.model, input.params, read);
|
|
@@ -9463,7 +9579,7 @@ export const duplicateShot = {
|
|
|
9463
9579
|
shotId: z.string().describe('The Shot id, or its SHOT-A code.'),
|
|
9464
9580
|
projectId: z.string().uuid().optional().describe(SHOT_PROJECT_DESCRIBE),
|
|
9465
9581
|
name: z.string().max(120).optional().describe('Name for the copy (default: the original plus "copy").'),
|
|
9466
|
-
prompt: z.string().
|
|
9582
|
+
prompt: z.string().optional().describe('Replace the prompt on the copy. Omit to keep the original\'s.'),
|
|
9467
9583
|
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
9584
|
params: shotParamsSchemaTerse,
|
|
9469
9585
|
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 +9591,7 @@ export const duplicateShot = {
|
|
|
9475
9591
|
const desktop = ctx.desktop();
|
|
9476
9592
|
await desktop.requireCapability('shots', 'saved Shots');
|
|
9477
9593
|
const read = shotReader(desktop, input.shotId, input.projectId);
|
|
9478
|
-
const storedErr = await assertStoredShotCapabilities(input.model, input.params, read);
|
|
9594
|
+
const storedErr = await assertStoredShotCapabilities(input.model, input.params, read, input.prompt);
|
|
9479
9595
|
if (storedErr)
|
|
9480
9596
|
return storedErr;
|
|
9481
9597
|
await requireDraftShotDesktop(desktop, input.model, input.params, read);
|
|
@@ -10090,8 +10206,12 @@ export const generateFromShots = {
|
|
|
10090
10206
|
const quote = await desktop.quote('/agent/shots/quote', 'input', {
|
|
10091
10207
|
projectId: details[0].projectId, shotIds: details.map((d) => d.id), draft,
|
|
10092
10208
|
});
|
|
10093
|
-
|
|
10094
|
-
|
|
10209
|
+
const shot = details.length === 1 ? details[0] : undefined;
|
|
10210
|
+
const routine = shot?.cuts === 1 && shot.referenceCount <= 1 && Array.isArray(shot.references) &&
|
|
10211
|
+
shot.references.length <= 1 && shot.references.every((ref) => ref.kind === 'image');
|
|
10212
|
+
for (const model of new Set(quote.items.map((i) => i.model))) {
|
|
10213
|
+
requireGuideRead(ctx, model, undefined, routine ? generateFromShots.id : undefined);
|
|
10214
|
+
}
|
|
10095
10215
|
const total = quote.items.reduce((n, i) => n + (i.credits ?? 0), 0);
|
|
10096
10216
|
const largest = Math.max(0, ...quote.items.map((i) => i.credits ?? 0));
|
|
10097
10217
|
// ONE approval for the set, on the STATED total; a stale fingerprint is a
|
|
@@ -10113,6 +10233,11 @@ export const generateFromShots = {
|
|
|
10113
10233
|
fingerprint: quote.fingerprint,
|
|
10114
10234
|
draft,
|
|
10115
10235
|
});
|
|
10236
|
+
for (const item of ran.results ?? []) {
|
|
10237
|
+
if (item.status === 'failed' || item.status === 'rejected') {
|
|
10238
|
+
recordGenerationRejection(ctx, generateFromShots.id, quote.items.find((shot) => shot.shotId === item.shotId)?.model);
|
|
10239
|
+
}
|
|
10240
|
+
}
|
|
10116
10241
|
return seatNote ? ok(ran, `${JSON.stringify(ran)}\n${seatNote}`) : ok(ran);
|
|
10117
10242
|
},
|
|
10118
10243
|
};
|
|
@@ -10383,6 +10508,8 @@ export function resolveGuideTopic(topic) {
|
|
|
10383
10508
|
return 'slates-prompting-omni-flash';
|
|
10384
10509
|
if (t.startsWith('wan') || t === 'alibaba-wan-3.0')
|
|
10385
10510
|
return 'slates-prompting-wan-3';
|
|
10511
|
+
if (t.startsWith('magi'))
|
|
10512
|
+
return 'slates-prompting-magi-2';
|
|
10386
10513
|
// MiniMax H3 — both seats share one skill. Placed BEFORE the seed/seedance
|
|
10387
10514
|
// block for the same reason seed-audio is: no prefix collision exists today,
|
|
10388
10515
|
// but a `minimax-*` id must never fall through to a Seedance guide.
|
|
@@ -10628,6 +10755,7 @@ export const getPromptingGuide = {
|
|
|
10628
10755
|
const guide = locked.notice ?? `${locked.name} is not open to this account. Run the job on the general rules.`;
|
|
10629
10756
|
// The guide gate makes an agent read what this account holds; a guide it cannot open never blocks a generation.
|
|
10630
10757
|
ctx?.guidesRead?.add(locked.name);
|
|
10758
|
+
ctx?.guideEvidence?.full.add(locked.name);
|
|
10631
10759
|
return { text: guide, data: { topic: locked.name, tier: locked.tier, locked: true, bytes: Buffer.byteLength(guide, 'utf8'), guide } };
|
|
10632
10760
|
}
|
|
10633
10761
|
// The shared brain with the user's My brain laid over it; theirs wins on a conflict (skills/my-brain.ts).
|
|
@@ -10663,8 +10791,10 @@ export const getPromptingGuide = {
|
|
|
10663
10791
|
const guide = lockedAlias?.notice ?? `The guide ${resolved} comes from the connected Slates account and is not on this machine (${served.problem ?? 'no brain received yet'}). ${CONNECT_FOR_BRAIN}, then ask again.`;
|
|
10664
10792
|
// A locked guide's notice carries its craft card (slates-api lib/brain.ts lockedNotice), so it counts as read; a
|
|
10665
10793
|
// guide that never arrived does not, so no generation runs without the card (Eric, 2026-10-23: a hard blocker).
|
|
10666
|
-
if (lockedAlias)
|
|
10794
|
+
if (lockedAlias) {
|
|
10667
10795
|
ctx?.guidesRead?.add(resolved);
|
|
10796
|
+
ctx?.guideEvidence?.full.add(resolved);
|
|
10797
|
+
}
|
|
10668
10798
|
return { text: guide, data: { topic: resolved, ...(lockedAlias ? { tier: lockedAlias.tier, locked: true } : { unavailable: true }), bytes: Buffer.byteLength(guide, 'utf8'), guide } };
|
|
10669
10799
|
}
|
|
10670
10800
|
if (resolved) {
|
|
@@ -10678,8 +10808,12 @@ export const getPromptingGuide = {
|
|
|
10678
10808
|
// router with the preload only to a connection that has not opened it, so this answer is the agent's one copy.
|
|
10679
10809
|
const preload = resolved === BRAIN_ROUTER ? myBrainPreload() : '';
|
|
10680
10810
|
const guide = `${preload ? `${preload}\n\n` : ''}${own}${retrieveGuide(resolved, brain.skills[resolved], depth, input.query)}`;
|
|
10681
|
-
|
|
10682
|
-
|
|
10811
|
+
const deliveredDepth = servedDepth(resolved, depth, input.query);
|
|
10812
|
+
if (deliveredDepth === 'full' || (deliveredDepth === 'card' && !input.query?.trim()))
|
|
10813
|
+
ctx?.guidesRead?.add(resolved);
|
|
10814
|
+
if (deliveredDepth === 'full')
|
|
10815
|
+
ctx?.guideEvidence?.full.add(resolved);
|
|
10816
|
+
return { text: guide, data: { topic: resolved, tier: 'free', ...(mine ? { source: 'my-brain' } : {}), depth: deliveredDepth, bytes: Buffer.byteLength(guide, 'utf8'), guide } };
|
|
10683
10817
|
}
|
|
10684
10818
|
const member = await memberGuideCatalog(ctx);
|
|
10685
10819
|
const privateEntry = member.entries.find(entry => entry.name === topic);
|
|
@@ -10696,7 +10830,10 @@ export const getPromptingGuide = {
|
|
|
10696
10830
|
throw new Error('Invalid member guide body');
|
|
10697
10831
|
const depth = input.depth ?? 'card';
|
|
10698
10832
|
const guide = retrieveGuide(privateEntry.name, result.markdown, depth, input.query);
|
|
10699
|
-
|
|
10833
|
+
if (depth === 'full' || (depth === 'card' && !input.query))
|
|
10834
|
+
ctx?.guidesRead?.add(privateEntry.name);
|
|
10835
|
+
if (depth === 'full')
|
|
10836
|
+
ctx?.guideEvidence?.full.add(privateEntry.name);
|
|
10700
10837
|
return { text: guide, data: { topic: privateEntry.name, tier: 'paid', depth, bytes: Buffer.byteLength(guide, 'utf8'), guide } };
|
|
10701
10838
|
}
|
|
10702
10839
|
// Slates' guides first, then HyperFrames' (they carry the craft for HTML layers and editing).
|
|
@@ -10746,9 +10883,9 @@ export const loadTools = {
|
|
|
10746
10883
|
// Worded to be true on both surfaces: the desktop agent must load an
|
|
10747
10884
|
// extended tool before calling it, while the MCP server lists every tool, so
|
|
10748
10885
|
// "missing from your list" never happens there by default.
|
|
10749
|
-
description: 'Find Slates tools by task. query searches
|
|
10886
|
+
description: 'Find Slates tools by task. query searches names and descriptions. names loads up to five exact schemas; group loads a task group. Each load replaces the previous optional selection. Search alone leaves it in place. Groups: ' + Object.entries(GROUP_SUMMARY).map(([g, s]) => `${g}: ${s}`).join('; '),
|
|
10750
10887
|
input: z.object({
|
|
10751
|
-
group: z.enum(
|
|
10888
|
+
group: z.enum(Object.keys(GROUP_SUMMARY)).optional(),
|
|
10752
10889
|
query: z.string().min(1).max(160).optional().describe('Search for a task such as generate image, create shot, or edit video.'),
|
|
10753
10890
|
names: z.array(z.string()).min(1).max(5).optional().describe('Exact operation names to load after discovery. Their permission annotations remain separate.'),
|
|
10754
10891
|
}).refine((v) => [v.group, v.query, v.names].filter(Boolean).length === 1, 'Pass exactly one of query, names, or group.'),
|