@slatesvideo/shared 0.7.3 → 0.7.4
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/analytics/events.d.ts +155 -0
- package/dist/analytics/events.js +430 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -0
- package/dist/manual/content.d.ts +1 -1
- package/dist/manual/content.js +1 -1
- package/dist/operations/index.d.ts +14 -6
- package/dist/operations/index.js +224 -30
- package/dist/operations/surface.js +1 -0
- package/dist/prompts/agent-doctrine.js +51 -32
- package/dist/prompts/banned-tokens.d.ts +18 -0
- package/dist/prompts/banned-tokens.js +59 -4
- package/dist/prompts/model-capabilities.d.ts +3 -3
- package/dist/prompts/model-capabilities.js +3 -3
- package/dist/prompts/model-facts.d.ts +1 -1
- package/dist/prompts/prompting-tips.js +6 -6
- package/dist/prompts/shot-grammar.d.ts +2 -2
- package/dist/prompts/shot-grammar.js +2 -2
- package/dist/skills/content.js +1 -1
- package/dist/update-check.js +1 -1
- package/exports/slates-prompt-builder/generated/slates-prompt-builder-manifest.json +2 -2
- package/package.json +5 -2
- package/skills/slates-vision-feedback-loop.md +117 -117
|
@@ -440,6 +440,14 @@ export declare const uploadReferenceImage: Operation<{
|
|
|
440
440
|
dataUrl?: string;
|
|
441
441
|
type?: 'image' | 'video' | 'audio';
|
|
442
442
|
folderId?: string | null;
|
|
443
|
+
label?: string;
|
|
444
|
+
note?: string;
|
|
445
|
+
}>;
|
|
446
|
+
export declare const updateAsset: Operation<{
|
|
447
|
+
projectId: string;
|
|
448
|
+
assetId: string;
|
|
449
|
+
label?: string;
|
|
450
|
+
note?: string;
|
|
443
451
|
}>;
|
|
444
452
|
export declare const listFolders: Operation<{
|
|
445
453
|
projectId: string;
|
|
@@ -1521,8 +1529,8 @@ declare const writeScriptDocumentInput: z.ZodObject<{
|
|
|
1521
1529
|
type: "strong" | "em";
|
|
1522
1530
|
end: number;
|
|
1523
1531
|
}[];
|
|
1524
|
-
level?: 2 | 3 | undefined;
|
|
1525
1532
|
label?: string | undefined;
|
|
1533
|
+
level?: 3 | 2 | undefined;
|
|
1526
1534
|
}, {
|
|
1527
1535
|
start: number;
|
|
1528
1536
|
end: number;
|
|
@@ -1533,8 +1541,8 @@ declare const writeScriptDocumentInput: z.ZodObject<{
|
|
|
1533
1541
|
type: "strong" | "em";
|
|
1534
1542
|
end: number;
|
|
1535
1543
|
}[];
|
|
1536
|
-
level?: 2 | 3 | undefined;
|
|
1537
1544
|
label?: string | undefined;
|
|
1545
|
+
level?: 3 | 2 | undefined;
|
|
1538
1546
|
}>, "many">;
|
|
1539
1547
|
}, "strip", z.ZodTypeAny, {
|
|
1540
1548
|
sceneId: string;
|
|
@@ -1548,8 +1556,8 @@ declare const writeScriptDocumentInput: z.ZodObject<{
|
|
|
1548
1556
|
type: "strong" | "em";
|
|
1549
1557
|
end: number;
|
|
1550
1558
|
}[];
|
|
1551
|
-
level?: 2 | 3 | undefined;
|
|
1552
1559
|
label?: string | undefined;
|
|
1560
|
+
level?: 3 | 2 | undefined;
|
|
1553
1561
|
}[];
|
|
1554
1562
|
}, {
|
|
1555
1563
|
sceneId: string;
|
|
@@ -1563,8 +1571,8 @@ declare const writeScriptDocumentInput: z.ZodObject<{
|
|
|
1563
1571
|
type: "strong" | "em";
|
|
1564
1572
|
end: number;
|
|
1565
1573
|
}[];
|
|
1566
|
-
level?: 2 | 3 | undefined;
|
|
1567
1574
|
label?: string | undefined;
|
|
1575
|
+
level?: 3 | 2 | undefined;
|
|
1568
1576
|
}[];
|
|
1569
1577
|
}>, "many">>;
|
|
1570
1578
|
move: z.ZodOptional<z.ZodObject<{
|
|
@@ -1641,8 +1649,8 @@ declare const writeScriptDocumentInput: z.ZodObject<{
|
|
|
1641
1649
|
type: "strong" | "em";
|
|
1642
1650
|
end: number;
|
|
1643
1651
|
}[];
|
|
1644
|
-
level?: 2 | 3 | undefined;
|
|
1645
1652
|
label?: string | undefined;
|
|
1653
|
+
level?: 3 | 2 | undefined;
|
|
1646
1654
|
}[];
|
|
1647
1655
|
}[] | undefined;
|
|
1648
1656
|
move?: {
|
|
@@ -1687,8 +1695,8 @@ declare const writeScriptDocumentInput: z.ZodObject<{
|
|
|
1687
1695
|
type: "strong" | "em";
|
|
1688
1696
|
end: number;
|
|
1689
1697
|
}[];
|
|
1690
|
-
level?: 2 | 3 | undefined;
|
|
1691
1698
|
label?: string | undefined;
|
|
1699
|
+
level?: 3 | 2 | undefined;
|
|
1692
1700
|
}[];
|
|
1693
1701
|
}[] | undefined;
|
|
1694
1702
|
move?: {
|
package/dist/operations/index.js
CHANGED
|
@@ -36,10 +36,11 @@ toolModelFor, CHATGPT_FRAMING_RATIOS, } from '../prompts/model-facts.js';
|
|
|
36
36
|
// never re-state one of those constraints as a literal enum or a sentence
|
|
37
37
|
// again. It did until 2026-08-16, and every axis had drifted: an invented
|
|
38
38
|
// `9:21`, "Kling/Seedance support all" (Seedance takes 6 of 11 and has no
|
|
39
|
-
// `4:5`),
|
|
40
|
-
// `videoResolution` line that never mentioned Kling, and 4s
|
|
41
|
-
//
|
|
42
|
-
// queued, credits reserved,
|
|
39
|
+
// `4:5`), a model said to lock to 16:9 (it took two on fal), "Kling: 5-15"
|
|
40
|
+
// (min is 3), a `videoResolution` line that never mentioned Kling, and 4s
|
|
41
|
+
// quoted for a model at 1080p that only took 8s there. A customer burned a
|
|
42
|
+
// round trip on `4:5` + Seedance: accepted here, queued, credits reserved,
|
|
43
|
+
// rejected by the provider asynchronously.
|
|
43
44
|
import { AGENT_ROUTE_PROVIDER, defaultImageResolutionFor, aspectRatioUnion, videoResolutionUnion, durationBounds, aspectRatiosFor, getModelCapability, defaultVideoResolutionFor, checkAspectRatio, checkVideoResolution, checkDuration, describeAspectRatios, describeVideoResolutions, describeDurations, describeReferenceImageCaps, } from '../prompts/model-capabilities.js';
|
|
44
45
|
// Per-model warnings are extracted from skill @banned blocks. They ride the
|
|
45
46
|
// selected model's estimate and submitted-prompt result, never another model's schema.
|
|
@@ -228,6 +229,23 @@ const BACKGROUND_DESCRIBE = 'Return generationId(s) now instead of blocking; pol
|
|
|
228
229
|
// folderId to the folder chosen in the window, so every op and the Studio Agent get it at once.
|
|
229
230
|
const FOLDER_DESCRIBE = "Folder the result lands in (slates_list_folders). Omit it to follow the folder chosen in the user's Slates window, else the project root; null is the root, on purpose.";
|
|
230
231
|
const folderIdField = z.string().uuid().nullable().optional().describe(FOLDER_DESCRIBE);
|
|
232
|
+
// A name and a note for an asset (`slates_upload_reference_image`, `slates_update_asset`). The desktop
|
|
233
|
+
// enforces both limits (slate/src/shared/assetLabel.ts, MAX_ASSET_LABEL and MAX_ASSET_NOTE); these copies
|
|
234
|
+
// give the model the refusal before the call, and lockstep check 13 holds the two equal.
|
|
235
|
+
const ASSET_LABEL_MAX = 120;
|
|
236
|
+
const ASSET_NOTE_MAX = 2000;
|
|
237
|
+
const assetLabelField = z
|
|
238
|
+
.string()
|
|
239
|
+
.trim()
|
|
240
|
+
.min(1)
|
|
241
|
+
.max(ASSET_LABEL_MAX)
|
|
242
|
+
.describe('The name shown on the asset card and in lists, with its code, e.g. "Ref: copper No".');
|
|
243
|
+
const assetNoteField = z
|
|
244
|
+
.string()
|
|
245
|
+
.trim()
|
|
246
|
+
.min(1)
|
|
247
|
+
.max(ASSET_NOTE_MAX)
|
|
248
|
+
.describe("What the asset is, stored as the asset's prompt text and read back by slates_get_asset.");
|
|
231
249
|
/** The `folderId` part of a generate or upload body: present only when the caller named one (null is the root). */
|
|
232
250
|
const folderBody = (folderId) => (folderId === undefined ? {} : { folderId });
|
|
233
251
|
// ── Vision QC pointers (the "quality-check with vision" rule, made structural) ──
|
|
@@ -242,7 +260,11 @@ const folderBody = (folderId) => (folderId === undefined ? {} : { folderId });
|
|
|
242
260
|
// it to re-fetch something already in front of it burns a turn for nothing:
|
|
243
261
|
// a blocking image generation returns the pixels inline, a video generation
|
|
244
262
|
// returns none, and a background submission has no asset yet.
|
|
245
|
-
|
|
263
|
+
// The check is spelled out because looking was not enough: on 2026-10-07 the
|
|
264
|
+
// agent received the pixels of a lighthouse with its lantern cut off by the top
|
|
265
|
+
// edge, described the image, and called it on brief (fix-after-review, 2 of 8).
|
|
266
|
+
const IMAGE_INLINE_REVIEW = 'The image is attached to this result — look at it against the brief before you describe it: ' +
|
|
267
|
+
'first the frame edges (is every subject whole, or is one cut off where the brief did not ask for a crop?), then each thing the brief named. ' +
|
|
246
268
|
'Any claim about how it LOOKS must come from pixels you actually received (slates-vision-feedback-loop).';
|
|
247
269
|
const VIDEO_REVIEW_POINTER = 'You have NOT seen this clip: call slates_get_asset_video_frames on the asset id above before ' +
|
|
248
270
|
'describing visible composition or identity. Sampled stills do not establish continuous motion, lip sync or sound; use actual playback through a capable host for those, or report them unreviewed.';
|
|
@@ -443,6 +465,8 @@ const describeLooking = (v) => {
|
|
|
443
465
|
parts.push(`Folder ${v.media.folderId} is chosen: new pictures land in it.`);
|
|
444
466
|
if (v.viewer?.assetId)
|
|
445
467
|
parts.push(`The picture viewer is open on ${v.viewer.assetId}.`);
|
|
468
|
+
if (v.viewer?.mode === 'source' && v.viewer.sourceAssetId)
|
|
469
|
+
parts.push(`The timeline's Viewer shows the clip ${v.viewer.sourceAssetId} (Source).`);
|
|
446
470
|
if (v.compare?.open)
|
|
447
471
|
parts.push(`Compare is open on ${v.compare.assetIds.length} items.`);
|
|
448
472
|
if (v.animatic?.open)
|
|
@@ -485,7 +509,7 @@ const describeView = (v) => {
|
|
|
485
509
|
*/
|
|
486
510
|
export const getView = {
|
|
487
511
|
id: 'slates_get_view',
|
|
488
|
-
description: "What the user is looking at in Slates: Home or a project, the tab (Media, Script or Board), the open board and its View and Filter, Media's tab, chosen folder and narrowing, a Library page, the picture viewer, Compare, the animatic, Settings, whether the prompt box is hidden, the timeline and the side panels, and any dialog or menu open over the page. Read it before telling the user where to click.",
|
|
512
|
+
description: "What the user is looking at in Slates: Home or a project, the tab (Media, Script or Board), the open board and its View and Filter, Media's tab, chosen folder and narrowing, a Library page, the picture viewer, the timeline Viewer's mode and clip, Compare, the animatic, Settings, whether the prompt box is hidden, the timeline and the side panels, and any dialog or menu open over the page. Read it before telling the user where to click.",
|
|
489
513
|
input: z.object({}).strict(),
|
|
490
514
|
async run(_input, ctx) {
|
|
491
515
|
await ctx.desktop().requireCapability('view', 'the window layout');
|
|
@@ -513,7 +537,7 @@ export const getView = {
|
|
|
513
537
|
*/
|
|
514
538
|
export const setView = {
|
|
515
539
|
id: 'slates_set_view',
|
|
516
|
-
description: "Change what the user is looking at, as their own clicks would: open a project or go Home, switch tab, open a board, jump to a scene, set the Board's View and Filter, set Media's tab, folder and narrowing, jump to a card in Media, open a Library page, the picture viewer, Compare, the animatic or Settings on a pane, show or hide the prompt box, open or park the timeline or switch the cut on it, open a Shot's panel on Script. Only the fields you name change; the app clamps sizes, answers with what it settled on, and names any field it could not apply. A project change is applied alone (it restores that project's own view). Use it when the user asks you to show or open something, not to answer a question they can see for themselves.",
|
|
540
|
+
description: "Change what the user is looking at, as their own clicks would: open a project or go Home, switch tab, open a board, jump to a scene, set the Board's View and Filter, set Media's tab, folder and narrowing, jump to a card in Media, open a Library page, a picture in the picture viewer or a clip in the timeline's Viewer, Compare, the animatic or Settings on a pane, show or hide the prompt box, open or park the timeline or switch the cut on it, open a Shot's panel on Script. Only the fields you name change; the app clamps sizes, answers with what it settled on, and names any field it could not apply. A project change is applied alone (it restores that project's own view). Use it when the user asks you to show or open something, not to answer a question they can see for themselves.",
|
|
517
541
|
input: z
|
|
518
542
|
.object({
|
|
519
543
|
projectId: z.string().nullable().optional().describe('Open this project, or null for Home. Applied alone.'),
|
|
@@ -589,7 +613,7 @@ export const setView = {
|
|
|
589
613
|
.strict()
|
|
590
614
|
.optional(),
|
|
591
615
|
library: z.object({ categoryId: z.string().nullable() }).strict().optional().describe("Open a Library category's page in Media's place; null goes back to the grid."),
|
|
592
|
-
viewer: z.object({ assetId: z.string().nullable() }).strict().optional().describe(
|
|
616
|
+
viewer: z.object({ assetId: z.string().nullable() }).strict().optional().describe("A picture opens in the picture viewer; a clip plays in the timeline's Viewer (Source), on desktops after 1.6.2. null closes the picture viewer."),
|
|
593
617
|
compare: z
|
|
594
618
|
.object({ open: z.boolean().optional(), assetIds: z.array(z.string()).max(4).optional().describe('The compare set, two to four items.') })
|
|
595
619
|
.strict()
|
|
@@ -965,8 +989,6 @@ export const VIDEO_MODELS = [
|
|
|
965
989
|
'kling-v3.0-std',
|
|
966
990
|
'kling-v3.0-pro',
|
|
967
991
|
'kling-v3.0-omni',
|
|
968
|
-
// Veo 3.1 Fast and Standard were retired on 2026-10-02 (Eric). The server
|
|
969
|
-
// keeps their keys for older desktops only; nothing here offers them.
|
|
970
992
|
'seedance-2',
|
|
971
993
|
// Seedance 2.5 is the DEFAULT video model (Eric, 2026-09-13): 30s takes, 30
|
|
972
994
|
// image references, audio-only references, up to 1080p (2026-08-24). 2.0 stays
|
|
@@ -1296,6 +1318,25 @@ export const estimateGenerationCost = {
|
|
|
1296
1318
|
const skill = promptingSkillFor(input.model);
|
|
1297
1319
|
const card = describeCraftCard(skill);
|
|
1298
1320
|
const banned = describeBannedTokensForSkill(skill);
|
|
1321
|
+
// Before the card on purpose: the desktop strips a repeated card by cutting
|
|
1322
|
+
// the text at "--- HOW TO PROMPT", and this line must survive that.
|
|
1323
|
+
const ownImage = IMAGE_MODELS.includes(input.model) ? input.model : null;
|
|
1324
|
+
const cheaper = ownImage ? cheaperImageOptions(byKey, perCredits, ownImage, input.aspectRatio) : null;
|
|
1325
|
+
const framing = input.aspectRatio ?? '16:9';
|
|
1326
|
+
const unpricedNote = cheaper?.unpriced.length
|
|
1327
|
+
? ` Not on the price list at ${framing}: ${cheaper.unpriced.join(', ')}; estimate one directly to price it.`
|
|
1328
|
+
: '';
|
|
1329
|
+
const cheaperLine = cheaper?.shown.length
|
|
1330
|
+
? `\nCheaper per image on the price list at ${framing}` +
|
|
1331
|
+
`${cheaper.cheaper > cheaper.shown.length ? ` (${cheaper.shown.length} of ${cheaper.cheaper})` : ''}: ` +
|
|
1332
|
+
cheaper.shown.map((o) => {
|
|
1333
|
+
const settings = [
|
|
1334
|
+
...(o.resolution !== defaultImageResolutionFor(o.model) ? [o.resolution] : []),
|
|
1335
|
+
...(o.quality && o.quality !== DEFAULT_GPT_QUALITY ? [`quality ${o.quality}`] : []),
|
|
1336
|
+
];
|
|
1337
|
+
return `${o.model} ${fmtCredits(o.credits)}${settings.length ? ` (${settings.join(', ')})` : ''}`;
|
|
1338
|
+
}).join('; ') + `.${unpricedNote}`
|
|
1339
|
+
: unpricedNote ? `\n${unpricedNote.trim()}` : '';
|
|
1299
1340
|
return ok({
|
|
1300
1341
|
model: input.model,
|
|
1301
1342
|
cost_key: key,
|
|
@@ -1303,9 +1344,11 @@ export const estimateGenerationCost = {
|
|
|
1303
1344
|
cost_per_credits: perCredits,
|
|
1304
1345
|
total_credits: totalCredits,
|
|
1305
1346
|
requires_confirm: totalCredits > CONFIRM_CREDITS,
|
|
1347
|
+
...(cheaper?.shown.length ? { cheaper_options: cheaper.shown } : {}),
|
|
1306
1348
|
...(card ? { craft_card: card, craft_card_skill: skill } : {}),
|
|
1307
1349
|
...(banned ? { banned_tokens: banned } : {}),
|
|
1308
1350
|
}, `${input.model}${qty > 1 ? ` ×${qty}` : ''}: ${fmtCredits(totalCredits)} (${key}).` +
|
|
1351
|
+
cheaperLine +
|
|
1309
1352
|
(card ? `\n\n--- HOW TO PROMPT ${input.model} ---\n${card}` : '') +
|
|
1310
1353
|
(banned ? `\n\n${banned}` : ''));
|
|
1311
1354
|
},
|
|
@@ -1622,7 +1665,7 @@ export const saveExternalImage = {
|
|
|
1622
1665
|
};
|
|
1623
1666
|
export const uploadReferenceImage = {
|
|
1624
1667
|
id: 'slates_upload_reference_image',
|
|
1625
|
-
description: 'Add a reference image, video clip, or audio file to a Slates project from disk. Pass either filePath (absolute path to a local file) or dataUrl (base64 data: URL) — exactly one. Set type:"video" to bring in a clip (the user\'s own footage to edit/relocate/trim) or type:"audio" for music/VO/SFX they already have; both are probed on ingest, so duration (and for video, dimensions) are available immediately, and audio gets its waveform. Default type is "image". dataUrl is image-only.',
|
|
1668
|
+
description: 'Add a reference image, video clip, or audio file to a Slates project from disk. Pass either filePath (absolute path to a local file) or dataUrl (base64 data: URL) — exactly one. Set type:"video" to bring in a clip (the user\'s own footage to edit/relocate/trim) or type:"audio" for music/VO/SFX they already have; both are probed on ingest, so duration (and for video, dimensions) are available immediately, and audio gets its waveform. Default type is "image". dataUrl is image-only. Pass label to name it and note to record what it is; without them it is "Imported file". A picture derived from a project asset (edited, masked, upscaled or converted outside Slates) belongs in slates_save_external_image with referenceAssetIds, so its source and prompt are recorded.',
|
|
1626
1669
|
input: z
|
|
1627
1670
|
.object({
|
|
1628
1671
|
projectId: z.string().uuid(),
|
|
@@ -1633,6 +1676,8 @@ export const uploadReferenceImage = {
|
|
|
1633
1676
|
.optional()
|
|
1634
1677
|
.describe('Asset kind for a filePath import — "image" (default), "video", or "audio". A dataUrl is always an image.'),
|
|
1635
1678
|
folderId: folderIdField,
|
|
1679
|
+
label: assetLabelField.optional(),
|
|
1680
|
+
note: assetNoteField.optional(),
|
|
1636
1681
|
})
|
|
1637
1682
|
.refine((d) => !!d.filePath !== !!d.dataUrl, {
|
|
1638
1683
|
message: 'Pass exactly one of filePath or dataUrl',
|
|
@@ -1642,12 +1687,17 @@ export const uploadReferenceImage = {
|
|
|
1642
1687
|
// A desktop before the folder rule ignores folderId and files at the root.
|
|
1643
1688
|
if (input.folderId !== undefined)
|
|
1644
1689
|
await desktop.requireCapability('media-folder', 'choosing the folder a result lands in');
|
|
1690
|
+
// A desktop before the name ignores label and note and imports it as "Imported file".
|
|
1691
|
+
if (input.label !== undefined || input.note !== undefined)
|
|
1692
|
+
await desktop.requireCapability('asset-naming', 'naming an upload');
|
|
1693
|
+
const naming = { ...(input.label !== undefined ? { label: input.label } : {}), ...(input.note !== undefined ? { note: input.note } : {}) };
|
|
1645
1694
|
if (input.filePath) {
|
|
1646
1695
|
const r = await desktop.post('/agent/assets/upload', {
|
|
1647
1696
|
projectId: input.projectId,
|
|
1648
1697
|
filePath: input.filePath,
|
|
1649
1698
|
type: input.type ?? 'image',
|
|
1650
1699
|
...folderBody(input.folderId),
|
|
1700
|
+
...naming,
|
|
1651
1701
|
});
|
|
1652
1702
|
return ok(r);
|
|
1653
1703
|
}
|
|
@@ -1658,10 +1708,29 @@ export const uploadReferenceImage = {
|
|
|
1658
1708
|
projectId: input.projectId,
|
|
1659
1709
|
dataUrl: input.dataUrl,
|
|
1660
1710
|
...folderBody(input.folderId),
|
|
1711
|
+
...naming,
|
|
1661
1712
|
});
|
|
1662
1713
|
return ok(r);
|
|
1663
1714
|
},
|
|
1664
1715
|
};
|
|
1716
|
+
export const updateAsset = {
|
|
1717
|
+
id: 'slates_update_asset',
|
|
1718
|
+
description: "Rename an asset (its label, shown with its code on its card and in lists) and/or replace the note stored as its prompt text. UUID or badge code. A note changes only an upload or a picture saved from an external host; a generated asset keeps the prompt that made it but can still be renamed.",
|
|
1719
|
+
input: z
|
|
1720
|
+
.object({ projectId: z.string().uuid(), assetId: z.string().min(1), label: assetLabelField.optional(), note: assetNoteField.optional() })
|
|
1721
|
+
.strict()
|
|
1722
|
+
.refine((d) => d.label !== undefined || d.note !== undefined, { message: 'Pass a label, a note or both' }),
|
|
1723
|
+
async run(input, ctx) {
|
|
1724
|
+
await ctx.desktop().requireCapability('asset-naming', 'naming an asset');
|
|
1725
|
+
const id = (await resolveAssetRefs(ctx, input.projectId, [input.assetId])).get(input.assetId).id;
|
|
1726
|
+
const { asset } = await ctx.desktop().post('/agent/assets/update', {
|
|
1727
|
+
assetId: id,
|
|
1728
|
+
...(input.label !== undefined ? { label: input.label } : {}),
|
|
1729
|
+
...(input.note !== undefined ? { note: input.note } : {}),
|
|
1730
|
+
});
|
|
1731
|
+
return ok({ asset: { ...compactAsset(asset), note: asset.prompt } });
|
|
1732
|
+
},
|
|
1733
|
+
};
|
|
1665
1734
|
// ── Folders ─────────────────────────────────────────────────────
|
|
1666
1735
|
export const listFolders = {
|
|
1667
1736
|
id: 'slates_list_folders',
|
|
@@ -2182,6 +2251,49 @@ export function imageCostKey(model, resolution, quality = DEFAULT_GPT_QUALITY, a
|
|
|
2182
2251
|
return `${model}-${gptKeyTier(quality)}-${resolution}${gptKeyAspect(aspectRatio)}`;
|
|
2183
2252
|
return `nano-banana-2-${resolution}`;
|
|
2184
2253
|
}
|
|
2254
|
+
/**
|
|
2255
|
+
* Image settings on the price list that cost less per image than `than`: each
|
|
2256
|
+
* seat's cheapest legal resolution (and GPT Image tier), ties going to the
|
|
2257
|
+
* seat's default resolution and then the higher tier. The quoted seat's own
|
|
2258
|
+
* cheaper setting is kept first, then the cheapest others, four in all.
|
|
2259
|
+
* Priced at `aspectRatio` (GPT Image prices square and 4:3 frames higher) and
|
|
2260
|
+
* read only from the registry the estimate already fetched: a seat whose key
|
|
2261
|
+
* at that framing is not on the list is reported unpriced, never fetched.
|
|
2262
|
+
*
|
|
2263
|
+
* WHY IT RIDES THE ESTIMATE: asked for "the cheapest and best version" on
|
|
2264
|
+
* 2026-10-07, the agent priced Nano Banana 2 alone (6 credits), called it the
|
|
2265
|
+
* cheapest option and generated; 1- and 2-credit seats were never compared.
|
|
2266
|
+
* Which seat is right stays the agent's call ("cheap" and "best" trade), so
|
|
2267
|
+
* nothing is routed here: the comparison is a fact in front of it instead.
|
|
2268
|
+
*/
|
|
2269
|
+
function cheaperImageOptions(byKey, than, own, aspectRatio) {
|
|
2270
|
+
const all = [];
|
|
2271
|
+
const unpriced = [];
|
|
2272
|
+
for (const model of IMAGE_MODELS) {
|
|
2273
|
+
const qualities = isGptImageModel(model) ? [...GPT_QUALITY_TIERS] : [undefined];
|
|
2274
|
+
const fallback = defaultImageResolutionFor(model);
|
|
2275
|
+
let best = null;
|
|
2276
|
+
for (const resolution of MODEL_CAPABILITIES[model]?.imageResolutions ?? []) {
|
|
2277
|
+
for (const quality of qualities) {
|
|
2278
|
+
const credits = byKey.get(imageCostKey(model, resolution, quality, aspectRatio));
|
|
2279
|
+
if (credits == null)
|
|
2280
|
+
continue;
|
|
2281
|
+
const better = !best || credits < best.credits || (credits === best.credits && ((resolution === fallback && best.resolution !== fallback) ||
|
|
2282
|
+
(resolution === best.resolution && quality != null && best.quality != null &&
|
|
2283
|
+
GPT_QUALITY_TIERS.indexOf(quality) > GPT_QUALITY_TIERS.indexOf(best.quality))));
|
|
2284
|
+
if (better)
|
|
2285
|
+
best = { model, credits, resolution, ...(quality ? { quality } : {}) };
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
if (!best)
|
|
2289
|
+
unpriced.push(model);
|
|
2290
|
+
else if (best.credits < than)
|
|
2291
|
+
all.push(best);
|
|
2292
|
+
}
|
|
2293
|
+
const sorted = all.sort((x, y) => x.credits - y.credits || x.model.localeCompare(y.model));
|
|
2294
|
+
const mine = sorted.filter((o) => o.model === own);
|
|
2295
|
+
return { shown: [...mine, ...sorted.filter((o) => o.model !== own)].slice(0, 4), cheaper: sorted.length, unpriced };
|
|
2296
|
+
}
|
|
2185
2297
|
// The default image seat with a project to route through, READ from MODEL_FACTS
|
|
2186
2298
|
// `tier`. Asserted at load so a default moved to a seat this op cannot send
|
|
2187
2299
|
// fails the build instead of every omitted-model call.
|
|
@@ -2219,7 +2331,7 @@ export const generateImage = {
|
|
|
2219
2331
|
quality: z.enum(GPT_QUALITY_TIERS).optional().describe(`GPT Image only. Default ${DEFAULT_GPT_QUALITY}; estimate the chosen tier before generation.`),
|
|
2220
2332
|
backgroundMode: z.enum(GPT_BACKGROUNDS).optional().describe('GPT Image only. transparent = alpha channel. Free.'),
|
|
2221
2333
|
aspectRatio: zEnum(IMAGE_ASPECT_RATIOS).optional().describe(`Pick from the use case: cinematic 16:9 · TikTok/Reels 9:16 · IG square 1:1 · ultra-wide 21:9. 1:1 costs most on GPT Image. Per model: ${describeAspectRatios(IMAGE_MODELS)}`),
|
|
2222
|
-
count: z.number().int().min(1).max(MAX_IMAGE_VARIATIONS).optional().describe(`Up to ${MAX_IMAGE_VARIATIONS} with projectId; headless caps at ${HEADLESS_BATCH_CAP}.`),
|
|
2334
|
+
count: z.number().int().min(1).max(MAX_IMAGE_VARIATIONS).optional().describe(`Variations of this one prompt: every image gets the same prompt, so different subjects are separate calls. Up to ${MAX_IMAGE_VARIATIONS} with projectId; headless caps at ${HEADLESS_BATCH_CAP}.`),
|
|
2223
2335
|
referenceImageUrls: z.array(z.string().url()).max(14).optional().describe('Headless (no projectId) nano-banana-2 only. With a projectId, upload via slates_upload_reference_image. Label every image role in the prompt.'),
|
|
2224
2336
|
referenceAssetIds: z.array(z.string()).max(16).optional().describe("Project assets as references — UUIDs or badge codes (\"IMG-A8\"), resolved at call time. Requires projectId. Caps: GPT Image 16, nano-banana-2 14, FLUX/Seedream lower. Label every reference role in the prompt."),
|
|
2225
2337
|
background: z.boolean().optional().describe(BACKGROUND_DESCRIBE),
|
|
@@ -2239,8 +2351,8 @@ export const generateImage = {
|
|
|
2239
2351
|
// which is where a rewrite is still free.
|
|
2240
2352
|
// Omitted model: the default seat when there is a project to route through,
|
|
2241
2353
|
// nano-banana-2 without one, because it is the only headless seat. The
|
|
2242
|
-
// desktop
|
|
2243
|
-
//
|
|
2354
|
+
// desktop resolves the same seat for its cost and plan-model guards
|
|
2355
|
+
// (`imageModelFor`, slate src/main/studio-agent/guards.ts): change both together.
|
|
2244
2356
|
const imageModel = input.model ?? (input.projectId ? DEFAULT_IMAGE_MODEL : 'nano-banana-2');
|
|
2245
2357
|
const promptWarning = bannedTokenWarning(input.prompt, 'image', promptingSkillFor(imageModel));
|
|
2246
2358
|
input = { ...input, resolution: input.resolution ?? defaultImageResolutionFor(imageModel) };
|
|
@@ -2843,7 +2955,8 @@ export const extractGridCells = {
|
|
|
2843
2955
|
* rather than a raw Zod error the agent has to guess its way out of.
|
|
2844
2956
|
*
|
|
2845
2957
|
* `promptMode` matters for any row that declares `duration.modeOverrides.ingredients`
|
|
2846
|
-
* (
|
|
2958
|
+
* (for an endpoint whose reference-to-video mode takes fewer durations than its
|
|
2959
|
+
* frame modes; no row sets one today). Free reference images
|
|
2847
2960
|
* with no first/last frame IS ingredients mode.
|
|
2848
2961
|
*/
|
|
2849
2962
|
function assertVideoCapabilities(input) {
|
|
@@ -3229,7 +3342,7 @@ export const generateVideo = {
|
|
|
3229
3342
|
prompt: z.string().min(1).max(4000),
|
|
3230
3343
|
// ROUTING doctrine only. Every capability number was stripped on 2026-08-16
|
|
3231
3344
|
// and now lives in the aspectRatio / duration / videoResolution descriptions
|
|
3232
|
-
// below, generated from MODEL_CAPABILITIES. "
|
|
3345
|
+
// below, generated from MODEL_CAPABILITIES. "16:9 only" for a model and
|
|
3233
3346
|
// "seedance-2.5 480p/720p" were both stated here AND there, and the two
|
|
3234
3347
|
// copies disagreed — and the second of those went stale on 2026-08-24 when
|
|
3235
3348
|
// 2.5 gained 1080p, which is exactly the failure mode generating it fixes.
|
|
@@ -3343,7 +3456,7 @@ export const generateVideo = {
|
|
|
3343
3456
|
`Missing required field(s): ${missing.join(', ')}. ` +
|
|
3344
3457
|
`Read the slates-cost-discipline + ${promptingSkillFor(input.model)} skills, ` +
|
|
3345
3458
|
// Generated from MODEL_CAPABILITIES. The prose that stood here claimed
|
|
3346
|
-
//
|
|
3459
|
+
// a model locked to 16:9, "Kling/Seedance support 1:1 16:9 9:16 4:3 3:4
|
|
3347
3460
|
// 21:9" and "Kling 5-15s" — three wrong claims in one sentence.
|
|
3348
3461
|
`or ask the user. ` +
|
|
3349
3462
|
`Aspect ratio for ${input.model}: ${aspectRatiosFor(input.model, AGENT_ROUTE_PROVIDER).join(', ')}. ` +
|
|
@@ -3503,11 +3616,6 @@ export const generateVideo = {
|
|
|
3503
3616
|
});
|
|
3504
3617
|
}
|
|
3505
3618
|
}
|
|
3506
|
-
// ⛔ The hand-written Veo duration block that stood here is GONE. It read
|
|
3507
|
-
// `![4,6,8].includes(duration)` plus "4K only at 8s" — and the registry
|
|
3508
|
-
// forces 8s at 1080p TOO, so it happily quoted a 4s 1080p Veo the provider
|
|
3509
|
-
// rejects. `assertVideoCapabilities` above covers both, plus the
|
|
3510
|
-
// reference-to-video 8s rule it never knew about, from the SSOT.
|
|
3511
3619
|
// Resolve every asset reference (UUID or badge code) against the
|
|
3512
3620
|
// project AT CALL TIME. Codes the user just spoke ("a8 is the one")
|
|
3513
3621
|
// resolve to whatever exists NOW — including assets created in the UI
|
|
@@ -5870,11 +5978,54 @@ export const createShot = {
|
|
|
5870
5978
|
? ` Saved from ${input.fromAssetId}: its recorded recipe is the Shot's, and that result is its first take (unless another Shot already holds it).` +
|
|
5871
5979
|
(r.unsavedPaths?.length ? ` ${r.unsavedPaths.length} recorded attachment(s) are not project assets and are not on the Shot.` : '')
|
|
5872
5980
|
: '';
|
|
5981
|
+
// 🔑 THE COUNTS RIDE THIS RESULT TOO (2026-10-07). Writing a shot list is
|
|
5982
|
+
// when sameness is cheapest to fix, and the eval showed the agent wrote
|
|
5983
|
+
// three Shots and never called slates_list_shots in 3 of 4 trials. Same
|
|
5984
|
+
// reasoning as describeVarietyReport: what it must choose to fetch does not
|
|
5985
|
+
// reach it, so the board's running counts arrive with each new Shot. A
|
|
5986
|
+
// storyboardId placed the Shot only when no frameId or sceneId came with it
|
|
5987
|
+
// (the schema ignores it then), so only then does it name the board.
|
|
5988
|
+
const varietyNote = await boardSoFar(desktop, {
|
|
5989
|
+
projectId: input.projectId,
|
|
5990
|
+
shotId: r.shot?.id,
|
|
5991
|
+
storyboardId: input.storyboardId && !input.frameId && !input.sceneId ? input.storyboardId : undefined,
|
|
5992
|
+
});
|
|
5873
5993
|
// The CODE is the address the user sees on the row — say it back so the
|
|
5874
5994
|
// next call, and the next sentence to the user, can point at it.
|
|
5875
|
-
return ok(r.shot, `${r.shot?.code || 'Shot'} — "${r.shot?.name || 'Untitled'}". ${refEcho}${fromNote}`.trim());
|
|
5995
|
+
return ok(r.shot, `${r.shot?.code || 'Shot'} — "${r.shot?.name || 'Untitled'}". ${refEcho}${fromNote}`.trim() + varietyNote);
|
|
5876
5996
|
},
|
|
5877
5997
|
};
|
|
5998
|
+
/**
|
|
5999
|
+
* The board's running counts after a Shot write, as the "Board so far" line, or ''.
|
|
6000
|
+
* Scoped to the Shot's OWN board: the listing falls back to every board in the
|
|
6001
|
+
* project when none is named, so an unscoped read would report other boards' cuts
|
|
6002
|
+
* as this one's. `storyboardId` is used only when it alone placed the Shot;
|
|
6003
|
+
* otherwise the board whose listing holds the Shot is found. No board found means
|
|
6004
|
+
* no counts, never project-wide ones. A failed read never fails the write.
|
|
6005
|
+
*/
|
|
6006
|
+
async function boardSoFar(desktop, where) {
|
|
6007
|
+
try {
|
|
6008
|
+
let board = null;
|
|
6009
|
+
if (where.storyboardId) {
|
|
6010
|
+
board = await desktop.get('/agent/shots', { storyboardId: where.storyboardId });
|
|
6011
|
+
}
|
|
6012
|
+
else if (where.shotId) {
|
|
6013
|
+
const { storyboards } = await desktop.get('/agent/storyboards', { projectId: where.projectId });
|
|
6014
|
+
for (const sb of (storyboards ?? []).slice(0, 10)) {
|
|
6015
|
+
const listed = await desktop.get('/agent/shots', { storyboardId: sb.id });
|
|
6016
|
+
if ((listed.shots ?? []).some((s) => s.id === where.shotId)) {
|
|
6017
|
+
board = listed;
|
|
6018
|
+
break;
|
|
6019
|
+
}
|
|
6020
|
+
}
|
|
6021
|
+
}
|
|
6022
|
+
const described = describeVarietyReport(board?.variety);
|
|
6023
|
+
return described ? `\nBoard so far: ${described}` : '';
|
|
6024
|
+
}
|
|
6025
|
+
catch {
|
|
6026
|
+
return ''; // counts are a courtesy here; slates_list_shots is the full read
|
|
6027
|
+
}
|
|
6028
|
+
}
|
|
5878
6029
|
export const updateShot = {
|
|
5879
6030
|
id: 'slates_update_shot',
|
|
5880
6031
|
description: 'Change part of a Shot, or attach/detach it from a board frame — anything you omit is left exactly as it was. ' +
|
|
@@ -5921,7 +6072,10 @@ export const updateShot = {
|
|
|
5921
6072
|
posterAssetId: input.posterAssetId,
|
|
5922
6073
|
},
|
|
5923
6074
|
});
|
|
5924
|
-
|
|
6075
|
+
// An edit to framing changes the counts, and the agent read them BEFORE it
|
|
6076
|
+
// (agent eval round 11: two runs fixed a repeat and never saw the new counts).
|
|
6077
|
+
const varietyNote = await boardSoFar(desktop, { projectId: input.projectId, shotId: r.shot?.id });
|
|
6078
|
+
return ok(r.shot, JSON.stringify(r.shot) + varietyNote);
|
|
5925
6079
|
},
|
|
5926
6080
|
};
|
|
5927
6081
|
export const duplicateShot = {
|
|
@@ -6072,13 +6226,44 @@ export const listShots = {
|
|
|
6072
6226
|
credits: q?.credits ?? null,
|
|
6073
6227
|
};
|
|
6074
6228
|
});
|
|
6229
|
+
// 🚨 THE ROWS ARE IN THE TEXT. The desktop Studio Agent reads only `text`
|
|
6230
|
+
// (`opResultToContent` in slate's studio-agent/ops.ts); `data` reaches MCP
|
|
6231
|
+
// clients as structured content and nobody else. This text used to be the
|
|
6232
|
+
// totals alone, so the in-app agent could see "3 shot(s), 444 credits" and
|
|
6233
|
+
// no Shot it could name: on 2026-10-07 it listed the same board six times,
|
|
6234
|
+
// tried `slates_get_shot("SHOT-1")`, and the eval trial timed out.
|
|
6235
|
+
// The variety report comes first and the rows stop at SHOT_ROWS_CHARS, so a
|
|
6236
|
+
// long board can never push the report past the desktop's 12,000-character
|
|
6237
|
+
// result cap (TOOL_RESULT_CHAR_CAP in slate's studio-agent/ops.ts).
|
|
6238
|
+
const rowText = [];
|
|
6239
|
+
let rowChars = 0;
|
|
6240
|
+
for (const s of shots) {
|
|
6241
|
+
const line = [
|
|
6242
|
+
[s.place, s.code].filter(Boolean).join(' ') || '—',
|
|
6243
|
+
JSON.stringify(s.name),
|
|
6244
|
+
s.model ?? 'no model',
|
|
6245
|
+
s.credits == null ? 'unpriced' : fmtCredits(s.credits),
|
|
6246
|
+
`id ${s.id}`,
|
|
6247
|
+
].join(' · ');
|
|
6248
|
+
if (rowChars + line.length + 1 > SHOT_ROWS_CHARS)
|
|
6249
|
+
break;
|
|
6250
|
+
rowText.push(line);
|
|
6251
|
+
rowChars += line.length + 1;
|
|
6252
|
+
}
|
|
6253
|
+
const omitted = shots.length - rowText.length;
|
|
6254
|
+
const report = describeVarietyReport(r.variety);
|
|
6075
6255
|
return ok({ shots, total_credits: total, unpriced, variety: r.variety }, `${shots.length} shot(s), at least ${fmtCredits(total)} to fire them all` +
|
|
6076
6256
|
(unpriced > 0 ? ` (${unpriced} could not be priced — no model or no duration set).` : '.') +
|
|
6077
|
-
(
|
|
6078
|
-
|
|
6079
|
-
|
|
6257
|
+
(report ? `\n\n${report}` : '') +
|
|
6258
|
+
(rowText.length ? `\n\n${rowText.join('\n')}` : '') +
|
|
6259
|
+
(omitted > 0
|
|
6260
|
+
? `\n…and ${omitted} more Shot(s) not listed here: pass storyboardId or frameId to list part of the board, or read one with slates_get_shot.`
|
|
6261
|
+
: ''));
|
|
6080
6262
|
},
|
|
6081
6263
|
};
|
|
6264
|
+
/** Room for Shot rows in the slates_list_shots text: about 65 rows, well inside the
|
|
6265
|
+
* desktop's 12,000-character result cap with the totals and the variety report. */
|
|
6266
|
+
const SHOT_ROWS_CHARS = 8000;
|
|
6082
6267
|
export const getShot = {
|
|
6083
6268
|
id: 'slates_get_shot',
|
|
6084
6269
|
description: 'Read one Shot in full — the COMPOSED prompt the request will actually carry, its numbered references, anything it points at that no longer exists, its exact credit quote, and its place on the board (2C, as the window shows it). Audit your own work here before firing.',
|
|
@@ -6505,7 +6690,10 @@ export const generateFromShots = {
|
|
|
6505
6690
|
quote.items
|
|
6506
6691
|
.map((i) => `${i.code ?? i.name}: ${i.credits == null ? 'unpriced' : fmtCredits(i.credits)}${i.blocked ? ` — ${i.blocked}` : ''}`)
|
|
6507
6692
|
.join('\n') +
|
|
6508
|
-
|
|
6693
|
+
// Printed, not only in `data`: a client without elicitation reads this text
|
|
6694
|
+
// alone, and the confirm step refuses without the fingerprint (agent eval, round 9).
|
|
6695
|
+
`\nfingerprint: ${quote.fingerprint}` +
|
|
6696
|
+
'\nGet approval for these prices, then pass this fingerprint with confirm: true.');
|
|
6509
6697
|
}
|
|
6510
6698
|
return ok(await desktop.post('/agent/shots/batch-generate', {
|
|
6511
6699
|
shotIds: quote.items.map((i) => i.shotId),
|
|
@@ -6843,8 +7031,13 @@ export const loadTools = {
|
|
|
6843
7031
|
}
|
|
6844
7032
|
const names = input.names ?? OPERATION_GROUPS[input.group];
|
|
6845
7033
|
const unknown = names.filter((id) => !ALL_OPERATIONS.some((op) => op.id === id));
|
|
6846
|
-
if (unknown.length)
|
|
6847
|
-
|
|
7034
|
+
if (unknown.length) {
|
|
7035
|
+
// Name the real tools a guessed name was reaching for. On 2026-10-07 the
|
|
7036
|
+
// agent tried slates_generate_shot, slates_run_shot and slates_get_shots
|
|
7037
|
+
// one call at a time before finding slates_generate_from_shots.
|
|
7038
|
+
const near = [...new Set(unknown.flatMap((id) => searchTools(ALL_OPERATIONS, id.replace(/^slates_/, '').replace(/_/g, ' ')).slice(0, 3).map(({ op }) => op.id)))];
|
|
7039
|
+
throw new Error(`Unknown operation(s): ${unknown.join(', ')}.${near.length ? ` Closest real tools: ${near.join(', ')}.` : ''}`);
|
|
7040
|
+
}
|
|
6848
7041
|
const defs = toolDefinitions(ALL_OPERATIONS.filter((op) => names.includes(op.id)), { surface: 'mcp' });
|
|
6849
7042
|
return ok({ group: input.group, tools: defs }, `Loaded tools (call by name):\n${JSON.stringify(defs)}`);
|
|
6850
7043
|
},
|
|
@@ -7033,6 +7226,7 @@ export const ALL_OPERATIONS = [
|
|
|
7033
7226
|
getAssetsBatch,
|
|
7034
7227
|
getAssetVideoFrames,
|
|
7035
7228
|
uploadReferenceImage,
|
|
7229
|
+
updateAsset,
|
|
7036
7230
|
saveExternalImage,
|
|
7037
7231
|
getChatGptStatus,
|
|
7038
7232
|
connectChatGpt,
|
|
@@ -169,6 +169,7 @@ export const OPERATION_GROUPS = {
|
|
|
169
169
|
// Rename, delete, reorder. The 63-op CRUD tail the review measured at 39.5 KB.
|
|
170
170
|
admin: [
|
|
171
171
|
'slates_update_project',
|
|
172
|
+
'slates_update_asset',
|
|
172
173
|
'slates_delete_project',
|
|
173
174
|
'slates_delete_asset',
|
|
174
175
|
'slates_update_character',
|