@slatesvideo/shared 0.7.7 → 0.7.8
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/README.md +3 -6
- package/dist/analytics/events.d.ts +1 -1
- package/dist/analytics/events.js +7 -0
- package/dist/auth.d.ts +2 -0
- package/dist/auth.js +5 -0
- package/dist/clients/cloud.d.ts +2 -0
- package/dist/clients/cloud.js +5 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.js +7 -3
- package/dist/manual/content.d.ts +1 -1
- package/dist/manual/content.js +1 -1
- package/dist/operations/index.d.ts +587 -161
- package/dist/operations/index.js +663 -57
- package/dist/operations/surface.d.ts +2 -2
- package/dist/operations/surface.js +18 -5
- package/dist/prompts/agent-doctrine.d.ts +12 -2
- package/dist/prompts/agent-doctrine.js +56 -28
- package/dist/prompts/banned-tokens.js +23 -13
- package/dist/prompts/brain.d.ts +29 -0
- package/dist/prompts/brain.js +72 -0
- package/dist/prompts/craft-cards.d.ts +15 -4
- package/dist/prompts/craft-cards.js +71 -9
- package/dist/prompts/generation-policy.d.ts +1 -1
- package/dist/prompts/guide-discovery.d.ts +6 -6
- package/dist/prompts/guide-retrieval.d.ts +7 -1
- package/dist/prompts/guide-retrieval.js +33 -5
- package/dist/prompts/partials.generated.js +1 -13
- package/dist/prompts/shot-grammar.d.ts +1 -1
- package/dist/prompts/shot-grammar.js +1 -1
- package/dist/skills/brain-check.d.ts +44 -0
- package/dist/skills/brain-check.js +172 -0
- package/dist/skills/content.d.ts +3 -0
- package/dist/skills/content.js +81 -44
- package/dist/skills/hyperframes-content.js +4 -4
- package/dist/skills/my-brain.d.ts +52 -0
- package/dist/skills/my-brain.js +218 -0
- package/dist/skills/served.d.ts +52 -0
- package/dist/skills/served.js +202 -0
- package/package.json +2 -4
- package/skills/hyperframes/NOTICE +19 -3
- package/skills/hyperframes/SLATES-MAPPING.md +1 -1
- package/skills/hyperframes/embedded-captions/CATALOG.md +3 -0
- package/skills/hyperframes/embedded-captions/SKILL.md +6 -6
- package/skills/hyperframes/embedded-captions/assets/fonts/char-widths.json +227 -1
- package/skills/hyperframes/embedded-captions/modes/standard/fonts/build-fonts-css.cjs +19 -2
- package/skills/hyperframes/embedded-captions/modes/standard/fonts/files/archivo-latin-wdth-italic.woff2 +0 -0
- package/skills/hyperframes/embedded-captions/modes/standard/fonts/files/archivo-latin-wdth-normal.woff2 +0 -0
- package/skills/hyperframes/embedded-captions/scripts/make-theme.cjs +438 -3
- package/skills/hyperframes/embedded-captions/scripts/make-theme.test.mjs +1 -0
- package/skills/hyperframes/embedded-captions/themes/README.md +26 -1
- package/skills/hyperframes/embedded-captions/themes/lesson.json +31 -0
- package/skills/slates-start-here.md +78 -0
- package/exports/slates-chatgpt-images/generated/SKILL.md +0 -113
- package/exports/slates-chatgpt-images/generated/slates-chatgpt-images.skill +0 -0
- package/exports/slates-prompt-builder/generated/SKILL.md +0 -71
- package/exports/slates-prompt-builder/generated/reference-character.md +0 -92
- package/exports/slates-prompt-builder/generated/reference-content-policy.md +0 -81
- package/exports/slates-prompt-builder/generated/reference-gpt-image-2-5.md +0 -191
- package/exports/slates-prompt-builder/generated/reference-kling.md +0 -295
- package/exports/slates-prompt-builder/generated/reference-nano-banana.md +0 -240
- package/exports/slates-prompt-builder/generated/reference-omni-flash.md +0 -97
- package/exports/slates-prompt-builder/generated/reference-seedance-2-5.md +0 -392
- package/exports/slates-prompt-builder/generated/reference-seedance.md +0 -441
- package/exports/slates-prompt-builder/generated/slates-prompt-builder-manifest.json +0 -133
- package/exports/slates-prompt-builder/generated/slates-prompt-builder.skill +0 -0
- package/skills/_partials/blender-action-curves.md +0 -24
- package/skills/_partials/cinematic-card.md +0 -8
- package/skills/_partials/decision-log.md +0 -1
- package/skills/_partials/image-defaults.md +0 -9
- package/skills/_partials/iteration-diagnosis.md +0 -5
- package/skills/_partials/living-performance.md +0 -22
- package/skills/_partials/model-routing.md +0 -35
- package/skills/_partials/references-read-literally.md +0 -11
- package/skills/_partials/seedance-25-timestamps.md +0 -34
- package/skills/_partials/sheet-tool-defaults.md +0 -6
- package/skills/_partials/still-gate.md +0 -3
- package/skills/_partials/thresholds.md +0 -19
- package/skills/slates-blocking-to-prompt.md +0 -279
- package/skills/slates-camera-language.md +0 -234
- package/skills/slates-captions.md +0 -81
- package/skills/slates-character-identity.md +0 -117
- package/skills/slates-chatgpt-images.md +0 -113
- package/skills/slates-cinematic-look.md +0 -237
- package/skills/slates-content-policy.md +0 -88
- package/skills/slates-cost-discipline.md +0 -150
- package/skills/slates-cuts.md +0 -46
- package/skills/slates-dialogue-blocking.md +0 -134
- package/skills/slates-direct-response-ad.md +0 -26
- package/skills/slates-edit-and-iterate.md +0 -76
- package/skills/slates-layer-brand-captions.md +0 -87
- package/skills/slates-layer-lower-third.md +0 -85
- package/skills/slates-layer-title.md +0 -82
- package/skills/slates-model-selection.md +0 -129
- package/skills/slates-motion.md +0 -57
- package/skills/slates-one-prompt-film.md +0 -38
- package/skills/slates-previs-blocking.md +0 -186
- package/skills/slates-project-organization.md +0 -42
- package/skills/slates-prompting-elevenlabs.md +0 -128
- package/skills/slates-prompting-flux-3.md +0 -157
- package/skills/slates-prompting-gpt-image-2-5.md +0 -196
- package/skills/slates-prompting-inworld-tts.md +0 -174
- package/skills/slates-prompting-kling-v3.md +0 -303
- package/skills/slates-prompting-lip-sync.md +0 -216
- package/skills/slates-prompting-ltx-2-5.md +0 -245
- package/skills/slates-prompting-minimax-h3.md +0 -383
- package/skills/slates-prompting-motion-transfer.md +0 -202
- package/skills/slates-prompting-nano-banana-2-1.md +0 -250
- package/skills/slates-prompting-omni-flash.md +0 -117
- package/skills/slates-prompting-seed-audio.md +0 -168
- package/skills/slates-prompting-seedance-2-5.md +0 -420
- package/skills/slates-prompting-seedance.md +0 -462
- package/skills/slates-prompting-seedream-5-lite.md +0 -122
- package/skills/slates-prompting-wan-3.md +0 -143
- package/skills/slates-restyle-from-blocking.md +0 -121
- package/skills/slates-script-craft.md +0 -45
- package/skills/slates-shot-variety.md +0 -24
- package/skills/slates-storyboard-from-script.md +0 -32
- package/skills/slates-style-prompting.md +0 -56
- package/skills/slates-transitions.md +0 -40
- package/skills/slates-ugc-influencer-ad.md +0 -32
- package/skills/slates-vision-feedback-loop.md +0 -118
package/dist/operations/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { MAX_IMAGE_VARIATIONS } from '../prompts/generation-policy.js';
|
|
2
2
|
import { STYLE_LIBRARY, DEFAULT_STYLE_ID } from '../prompts/style-library.js';
|
|
3
3
|
import { discoverGuides, guideCatalog } from '../prompts/guide-discovery.js';
|
|
4
|
-
import { retrieveGuide } from '../prompts/guide-retrieval.js';
|
|
4
|
+
import { retrieveGuide, servedDepth } from '../prompts/guide-retrieval.js';
|
|
5
|
+
import { BRAIN_ROUTER, MY_BRAIN_TOPIC, ROUTER_ALIASES } from '../prompts/brain.js';
|
|
5
6
|
import { MINIMAX_MAX_REFERENCE, minimaxMaxReferenceTokens, MODEL_CAPABILITIES, RETIRED_MODELS, retiredModelOfKey, GPT_QUALITY_TIERS, DEFAULT_GPT_QUALITY, GPT_BACKGROUNDS } from '../prompts/model-capabilities.js';
|
|
6
7
|
// Operations layer — the ONE place every Slates agent tool is defined.
|
|
7
8
|
// Both the MCP server and the CLI register these as their tool / command
|
|
@@ -19,6 +20,8 @@ import { SlatesCloudClient, SlatesCloudHttpError } from '../clients/cloud.js';
|
|
|
19
20
|
import { SlatesDesktopClient } from '../clients/desktop.js';
|
|
20
21
|
import { BlenderBridgeClient, BLENDER_SETUP_HINT, RENDER_TIMEOUT_MS } from '../clients/blender.js';
|
|
21
22
|
import { SKILLS } from '../skills/content.js';
|
|
23
|
+
import { brainSkills, myBrainDir, myBrainPreload, noteUsed } from '../skills/my-brain.js';
|
|
24
|
+
import { brainFiles, refreshServedBrain, servedBrain } from '../skills/served.js';
|
|
22
25
|
import { HYPERFRAMES_MAPPING, findHyperframesGuide, hyperframesCard, hyperframesCatalog, hyperframesFilesOf, hyperframesGuideHeader, hyperframesSkillBodies, loadHyperframes } from '../skills/hyperframes.js';
|
|
23
26
|
import { appManualIndex, appManualSections } from '../manual/index.js';
|
|
24
27
|
// Reference-capacity prose is DERIVED, never hand-typed — root CLAUDE.md:
|
|
@@ -84,16 +87,25 @@ export class OperationCancelledError extends Error {
|
|
|
84
87
|
* Eric, 2026-10-23, after a Seedance test was prompted before its guide was
|
|
85
88
|
* read: *"That needs to be a hard blocker."* Nothing was generated or charged.
|
|
86
89
|
*/
|
|
90
|
+
/** How a machine with no brain gets one: the desktop app signed in here writes it, or a CLI login fetches it. */
|
|
91
|
+
export const CONNECT_FOR_BRAIN = 'Have the user open the Slates app signed in on this machine (it brings the brain here), or run `slates login`';
|
|
87
92
|
export class GuideNotReadError extends Error {
|
|
88
93
|
model;
|
|
89
94
|
guide;
|
|
90
95
|
code = 'GUIDE_NOT_READ';
|
|
91
96
|
constructor(model, guide) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
const head = `Refused: this session has not read ${guide}, the guide for ${model}. Nothing was generated or charged. `;
|
|
98
|
+
const body = brainSkills().skills[guide];
|
|
99
|
+
const served = servedBrain();
|
|
100
|
+
super(body !== undefined || served.locked.some(entry => entry.name === guide)
|
|
101
|
+
? head +
|
|
102
|
+
`Call slates_get_prompting_guide with topic "${guide}", rewrite the prompt against it, then call this again. Its card:\n\n` +
|
|
103
|
+
// The card this user's brain serves, so a model guide from their My brain is the one in the refusal.
|
|
104
|
+
describeCraftCard(guide, body)
|
|
105
|
+
: // No copy here and none locked: the brain never arrived, so asking for the guide again cannot help.
|
|
106
|
+
head +
|
|
107
|
+
`The guide comes from the connected Slates account and is not on this machine (${served.problem ?? 'no brain received yet'}). ` +
|
|
108
|
+
`${CONNECT_FOR_BRAIN}; then call slates_get_prompting_guide with topic "${guide}" and call this again.`);
|
|
97
109
|
this.model = model;
|
|
98
110
|
this.guide = guide;
|
|
99
111
|
}
|
|
@@ -449,32 +461,39 @@ export const getSelection = {
|
|
|
449
461
|
};
|
|
450
462
|
// 1.6.1: what is ticked. Mirrors slate's `SELECTION_TARGETS` and `SELECTION_MODES` in `@shared/types/view`
|
|
451
463
|
// (lockstep check 12), which this package cannot import.
|
|
452
|
-
const SELECTION_TARGETS = ['media', 'board'];
|
|
464
|
+
const SELECTION_TARGETS = ['media', 'board', 'timeline'];
|
|
453
465
|
const SELECTION_MODES = ['replace', 'add', 'remove', 'clear', 'all'];
|
|
454
466
|
/**
|
|
455
|
-
* SET what is selected, as the user's clicks do: the cards ticked in Media, the Shots ticked on the Board
|
|
467
|
+
* SET what is selected, as the user's clicks do: the cards ticked in Media, the Shots ticked on the Board, the
|
|
468
|
+
* clips selected on the timeline (which also opens the Cut on them, scrolls to them and opens the Inspector).
|
|
456
469
|
* Pairs with `slates_get_selection`, which reads it: "tick the shots with no clip, then price them" is this op
|
|
457
470
|
* and then the quote. The desktop applies it through the stores the grids write and answers with what SETTLED.
|
|
458
471
|
*/
|
|
459
472
|
export const setSelection = {
|
|
460
473
|
id: 'slates_set_selection',
|
|
461
|
-
description: "
|
|
474
|
+
description: "Select cards in Media, Shots on the Board or clips on the timeline, as clicks, Shift-click, Escape and Ctrl/Cmd+A do: replace makes the ids the whole selection, add and remove change only them, clear empties it, all ticks everything the tab shows (Media: the grid as filtered, folded rounds left out; Board: every Shot on the open board; timeline: every clip on the open timeline). Every surface needs a project open in the window, Media its grid showing and the Board the Board or Script tab; slates_set_view opens and switches. On the timeline, clip ids open the Cut on their timeline, scroll to them and open the Inspector on the last, so use it to show the user a clip instead of asking them to click it; all, or replace with no ids, needs a timeline open (slates_set_view cut.timelineId). Ids are asset ids or badge codes (Media), Shot ids or SHOT-A codes (Board) or clip ids from slates_get_timeline (timeline, all on one timeline). Answers with the selection as it settled and names any id it could not select. slates_get_selection reads it back (timeline clips under timeline.selectedClips); what is selected is what the user means by 'these'.",
|
|
462
475
|
input: z
|
|
463
476
|
.object({
|
|
464
477
|
surface: z.enum(SELECTION_TARGETS),
|
|
465
478
|
mode: z.enum(SELECTION_MODES),
|
|
466
|
-
ids: z.array(z.string().min(1)).max(500).optional().describe('Asset ids or codes (media)
|
|
479
|
+
ids: z.array(z.string().min(1)).max(500).optional().describe('Asset ids or codes (media), Shot ids or codes (board) or clip ids (timeline). Not used by clear or all.'),
|
|
467
480
|
})
|
|
468
481
|
.strict(),
|
|
469
482
|
async run(input, ctx) {
|
|
470
483
|
await ctx.desktop().requireCapability('selection-set', 'setting what is selected');
|
|
484
|
+
if (input.surface === 'timeline')
|
|
485
|
+
await ctx.desktop().requireCapability('timeline-select', 'selecting timeline clips');
|
|
471
486
|
if ((input.mode === 'add' || input.mode === 'remove') && !input.ids?.length)
|
|
472
487
|
throw new Error(`${input.mode} needs ids.`);
|
|
473
488
|
const r = await ctx.desktop().post('/agent/selection', input);
|
|
474
489
|
if (!r.selection)
|
|
475
490
|
return { text: `Nothing was changed (${r.reason ?? 'no answer'}).`, data: { selection: null } };
|
|
476
|
-
const where = r.selection.surface === 'media' ? 'Media' : 'the Board';
|
|
477
|
-
const named = (row) =>
|
|
491
|
+
const where = r.selection.surface === 'media' ? 'Media' : r.selection.surface === 'timeline' ? 'the timeline' : 'the Board';
|
|
492
|
+
const named = (row) => {
|
|
493
|
+
const coded = row.code ? (row.label ? `${row.code} — ${row.label}` : row.code) : null;
|
|
494
|
+
// A timeline row appends its id, so its label may stand in for a code; a Media or Board row without one is named by its id.
|
|
495
|
+
return row.track && row.start ? `${coded ?? row.label ?? row.id} (${row.track}, ${row.start.timecode}, ${row.id})` : coded ?? row.id;
|
|
496
|
+
};
|
|
478
497
|
const notes = r.notes?.length ? ` Not applied: ${r.notes.join('; ')}.` : '';
|
|
479
498
|
return {
|
|
480
499
|
text: (r.selection.items.length ? `${r.selection.items.length} selected on ${where}: ${r.selection.items.map(named).join(', ')}.` : `Nothing is selected on ${where}.`) + notes,
|
|
@@ -490,6 +509,8 @@ const VIEW_CUT_SIDES = ['bottom', 'left', 'right'];
|
|
|
490
509
|
const VIEW_DOCK_SECTIONS = ['storyboards', 'library', 'folders', 'pinned'];
|
|
491
510
|
// W3: the one window's two layouts (`WINDOW_LAYOUTS`).
|
|
492
511
|
const VIEW_WINDOW_LAYOUTS = ['plan', 'edit'];
|
|
512
|
+
// What the timeline's Viewer shows (`VIEWER_MODES`).
|
|
513
|
+
const VIEW_VIEWER_MODES = ['source', 'timeline'];
|
|
493
514
|
// 1.6.1: what the user is looking at. Mirrors slate's `@shared/types/view` (lockstep check 12).
|
|
494
515
|
const VIEW_BOARD_LEVELS = ['film', 'scenes', 'shot'];
|
|
495
516
|
const VIEW_BOARD_FILTERS = ['all', 'with-clip', 'without-clip'];
|
|
@@ -708,7 +729,14 @@ export const setView = {
|
|
|
708
729
|
.strict()
|
|
709
730
|
.optional(),
|
|
710
731
|
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."),
|
|
711
|
-
viewer: z
|
|
732
|
+
viewer: z
|
|
733
|
+
.object({
|
|
734
|
+
assetId: z.string().nullable().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."),
|
|
735
|
+
mode: z.enum(VIEW_VIEWER_MODES).optional().describe("What the timeline's Viewer shows: source (a clip opened to watch) or timeline (the timeline). Compare opens through compare.open. Desktops from 1.6.3."),
|
|
736
|
+
})
|
|
737
|
+
.strict()
|
|
738
|
+
.refine((v) => v.assetId !== undefined || v.mode !== undefined, { message: 'viewer: name assetId or mode' })
|
|
739
|
+
.optional(),
|
|
712
740
|
compare: z
|
|
713
741
|
.object({ open: z.boolean().optional(), assetIds: z.array(z.string()).max(4).optional().describe('The compare set, two to four items.') })
|
|
714
742
|
.strict()
|
|
@@ -1523,7 +1551,8 @@ export const estimateGenerationCost = {
|
|
|
1523
1551
|
// paid for on every turn of every session and read once — this is paid for
|
|
1524
1552
|
// only by the call that is about to use the model.
|
|
1525
1553
|
const skill = promptingSkillFor(input.model);
|
|
1526
|
-
|
|
1554
|
+
// From the user's brain: their My brain card for this model rides first when they wrote one (craft-cards.ts).
|
|
1555
|
+
const card = describeCraftCard(skill, brainSkills().skills[skill]);
|
|
1527
1556
|
const banned = describeBannedTokensForSkill(skill);
|
|
1528
1557
|
// Before the card on purpose: the desktop strips a repeated card by cutting
|
|
1529
1558
|
// the text at "--- HOW TO PROMPT", and this line must survive that.
|
|
@@ -5074,13 +5103,18 @@ export const listGenerations = {
|
|
|
5074
5103
|
const legacyExportCutsInput = z.object({ projectId: z.string().uuid(), directory: z.string(), manifestId: z.string().min(1),
|
|
5075
5104
|
action: z.enum(['start', 'status', 'cancel']).optional().describe('start (default) begins, or re-attaches to a running export; status reads it; cancel stops after the output being rendered.'),
|
|
5076
5105
|
items: z.array(z.object({ timelineId: z.string().uuid(), format: z.enum(['mp4', 'xml']) }).strict()).min(1).optional().describe('Required to start.') }).strict();
|
|
5106
|
+
// A pick from a cut's variant grid (desktop engine plan E3b; slate shared/variantSlots.ts normalizeVariantGridPick).
|
|
5107
|
+
const variantGridPicks = z.record(z.string().uuid(), z.array(z.string().uuid())).describe('Slot id to the alternative ids picked in it; a slot left out takes all its alternatives.');
|
|
5108
|
+
const variantGridAspects = z.array(deliveryAspectInput).min(1).describe("Delivery format ids; default the cut's own formats, else master.");
|
|
5077
5109
|
const adCopyInput = z.object({ destinationUrl: z.string().optional(), primaryText: z.string().optional(), headline: z.string().optional(), cta: z.string().optional() }).strict();
|
|
5078
5110
|
const batchExportCutsInput = z.object({
|
|
5079
5111
|
version: z.literal(2).describe('Use version 2 with batchId and items for delivery-format batches. Omit version for legacy directory/manifestId requests.'),
|
|
5080
5112
|
projectId: z.string().uuid(), batchId: z.string().min(1).describe('Required for version 2. Reuse this id and the same items to reattach or retry.'),
|
|
5081
5113
|
exportRoot: z.string().optional().describe('Optional export root; the desktop remembers it and creates a fresh batch folder.'),
|
|
5082
5114
|
items: z.array(z.object({ timelineId: z.string().uuid(), aspects: z.array(deliveryAspectInput).min(1).optional(),
|
|
5083
|
-
formats: z.array(z.enum(['mp4', 'xml'])).min(1).optional(), taxonomy: taxonomyInput.optional() }).strict())
|
|
5115
|
+
formats: z.array(z.enum(['mp4', 'xml'])).min(1).optional(), taxonomy: taxonomyInput.optional() }).strict()),
|
|
5116
|
+
variants: z.object({ timelineId: z.string().uuid().describe('The cut with the slots, or any timeline of its family.'), picks: variantGridPicks.optional(), aspects: variantGridAspects.optional() }).strict()
|
|
5117
|
+
.describe('A grid pick to export: each combination gets a variant row if it has none, and every variant exports in every format, beside any items. Requires variant-grid.').optional(),
|
|
5084
5118
|
copy: adCopyInput.optional().describe('User-entered batch ad copy and destination defaults. Omission leaves them empty; never copy script or video text here.'),
|
|
5085
5119
|
outputCopy: z.record(adCopyInput).optional().describe('Per-output ad copy overrides keyed by the desktop receipt output key.'),
|
|
5086
5120
|
}).strict();
|
|
@@ -5090,15 +5124,17 @@ const exportCutsInput = z.object({
|
|
|
5090
5124
|
...legacyExportCutsInput.partial().shape,
|
|
5091
5125
|
...batchExportCutsInput.partial().shape,
|
|
5092
5126
|
projectId: z.string().uuid(),
|
|
5093
|
-
items: z.array(z.union([batchExportCutsInput.shape.items.element, legacyExportCutsInput.shape.items.unwrap().element])).
|
|
5127
|
+
items: z.array(z.union([batchExportCutsInput.shape.items.element, legacyExportCutsInput.shape.items.unwrap().element])).optional().describe('Required for version 2 start/retry (may be [] beside variants) and legacy start. Version 2 selects existing timelineIds with aspects/formats/taxonomy; legacy selects timelineId/format.'),
|
|
5094
5128
|
}).strict().superRefine((input, ctx) => {
|
|
5095
5129
|
const parsed = (input.version === 2 ? batchExportCutsInput : legacyExportCutsInput).safeParse(input);
|
|
5096
5130
|
if (!parsed.success)
|
|
5097
5131
|
for (const issue of parsed.error.issues)
|
|
5098
5132
|
ctx.addIssue(issue);
|
|
5133
|
+
if (input.items?.length === 0 && !(input.version === 2 && input.variants))
|
|
5134
|
+
ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['items'], message: 'items needs at least one cut, unless version 2 names variants' });
|
|
5099
5135
|
});
|
|
5100
5136
|
export const exportCuts = {
|
|
5101
|
-
id: 'slates_export_cuts', description: 'Start or retry a background export of existing named cuts to local files without generating media or spending credits. Version 2 selects cuts × delivery aspects from slates_get_variant_grid and returns batchId, manifestPath and frozen named outputs immediately; poll slates_get_export_batch. Repeating the same batchId and selection reattaches or retries unfinished outputs; completed files are checked and never overwritten. Naming, delivery and provenance are frozen by the desktop. CSV contains completed MP4s only and is unverified against a live Meta import. Missing takes are reported per cut, never filled. Version 2 requires ad-variant-export; update Slates on capability refusal. Legacy directory/manifestId/items/action requests remain supported. For one cut, slates_export_video is enough.',
|
|
5137
|
+
id: 'slates_export_cuts', description: 'Start or retry a background export of existing named cuts to local files without generating media or spending credits. Version 2 selects cuts × delivery aspects from slates_get_variant_grid and returns batchId, manifestPath and frozen named outputs immediately; poll slates_get_export_batch. Version 2 with variants (a pick read through slates_get_variants grid) and items [] exports every variant of a cut\'s slots in every picked format in one request, adding the rows a combination lacks: one body and ten hooks in four formats is forty named files. Each variant\'s picture is joined from parts rendered once per format and kept, so a shared body renders once and an unchanged export again renders nothing; an output cut at a seam carries segments (parts, reused), and one that rendered whole says why. Variants requires variant-grid. Repeating the same batchId and selection reattaches or retries unfinished outputs; completed files are checked and never overwritten. Naming, delivery and provenance are frozen by the desktop. CSV contains completed MP4s only and is unverified against a live Meta import. Missing takes are reported per cut, never filled. Version 2 requires ad-variant-export; update Slates on capability refusal. Legacy directory/manifestId/items/action requests remain supported. For one cut, slates_export_video is enough.',
|
|
5102
5138
|
billable: false,
|
|
5103
5139
|
input: exportCutsInput,
|
|
5104
5140
|
async run(input, ctx) {
|
|
@@ -5106,6 +5142,8 @@ export const exportCuts = {
|
|
|
5106
5142
|
await desktop.requireCapability('named-cuts', 'named cuts');
|
|
5107
5143
|
if (input.version === 2)
|
|
5108
5144
|
await desktop.requireCapability('ad-variant-export', 'ad variant batch export and retry');
|
|
5145
|
+
if (input.variants !== undefined)
|
|
5146
|
+
await desktop.requireCapability('variant-grid', 'exporting a variant grid pick');
|
|
5109
5147
|
return ok(await desktop.post('/agent/timeline/export-cuts', input));
|
|
5110
5148
|
},
|
|
5111
5149
|
};
|
|
@@ -5131,7 +5169,7 @@ export const cancelExportBatch = {
|
|
|
5131
5169
|
},
|
|
5132
5170
|
};
|
|
5133
5171
|
export const getVariantGrid = {
|
|
5134
|
-
id: 'slates_get_variant_grid', description: 'Read the variant grid of existing named cuts, recorded slot choices, missing takes and delivery format ids with actual dimensions. Shows absent combinations without creating them; missing-take prices are local quotes, never generation requests. Select existing timelineIds and returned aspects for slates_export_cuts. Requires ad-variant-export; update Slates on capability refusal.',
|
|
5172
|
+
id: 'slates_get_variant_grid', description: 'Read the variant grid of existing named cuts, recorded slot choices, missing takes and delivery format ids with actual dimensions. Shows absent combinations without creating them; missing-take prices are local quotes, never generation requests. Select existing timelineIds and returned aspects for slates_export_cuts. For a cut\'s slots (hooks, body, end card) crossed with formats, read slates_get_variants with grid. Requires ad-variant-export; update Slates on capability refusal.',
|
|
5135
5173
|
billable: false,
|
|
5136
5174
|
input: z.object({ projectId: z.string().uuid() }).strict(),
|
|
5137
5175
|
async run(input, ctx) {
|
|
@@ -5139,6 +5177,103 @@ export const getVariantGrid = {
|
|
|
5139
5177
|
return ok(await ctx.desktop().get('/agent/timeline/variant-grid', input));
|
|
5140
5178
|
},
|
|
5141
5179
|
};
|
|
5180
|
+
// Ad variants on one shared body (desktop engine plan E3b; the design heads slate's main/editor/variants.ts).
|
|
5181
|
+
// The desktop's normalizeSeamSetting (slate shared/variantSlots.ts): frames 1 to 600 for j, l and crossfade; a cut takes none.
|
|
5182
|
+
const seamSetting = z.union([
|
|
5183
|
+
z.literal('auto'),
|
|
5184
|
+
z.object({ kind: z.literal('cut'), frames: z.number().optional() }).strict(),
|
|
5185
|
+
z.object({ kind: z.enum(['j', 'l', 'crossfade']), frames: z.number().int().min(1).max(600) }).strict(),
|
|
5186
|
+
]).describe("'auto' for the automatic pick, { kind: 'cut' }, or { kind, frames } with frames 1 to 600: j (the next slot's sound leads by frames), l (this slot's sound runs on), crossfade (its length).");
|
|
5187
|
+
const variantChoices = z.record(z.string().uuid(), z.string().uuid()).describe('Slot id to alternative id. A slot left out plays its first alternative.');
|
|
5188
|
+
const variantSeams = z.record(z.string().uuid(), seamSetting).describe('Keyed by the slot AFTER the seam.');
|
|
5189
|
+
const getVariantsInput = z.object({
|
|
5190
|
+
projectId: z.string().uuid(),
|
|
5191
|
+
timelineId: z.string().uuid(),
|
|
5192
|
+
grid: z.object({ picks: variantGridPicks.optional(), aspects: variantGridAspects.optional() }).strict().optional()
|
|
5193
|
+
.describe("Add the grid for this pick: {} for every alternative in the cut's formats. Requires variant-grid."),
|
|
5194
|
+
}).strict();
|
|
5195
|
+
export const getVariants = {
|
|
5196
|
+
id: 'slates_get_variants',
|
|
5197
|
+
description: "Read a cut's ad variants: hooks, a shared body and an end card as slots laid end to end, each slot's alternatives (each a timeline: sequenceId, its length), and the variant rows, one alternative per slot, each built into an ordinary timeline (cutId) with its seams (J-cut, L-cut, crossfade or cut, who picked it and why, and what the media held back) and its state: current, edited by hand and left alone, or unbuilt, with behind once its sources changed since its timeline was built. The cut's own lanes are the bed under every variant. Any timeline of the family answers: the cut, a slot's sequence or a variant's timeline. With grid, it adds the grid for a pick of alternatives per slot and of delivery formats: each combination (name, variantId and cutId, null when no row has it yet), files (combinations × formats), the formats offered with their sizes, and missingTakes (shotIds of intended takes the picked alternatives lack; credits, what making them bills in all, the figure to quote; costs, dollars per take request; both null when unpriceable; the grid never generates). Export that pick with slates_export_cuts variants. Reading writes nothing: a behind variant catches up when its timeline is opened (slates_get_timeline) or exported, after any slates_edit_variant_slots or slates_edit_variants call, and on rebuild, which also drops hand edits. Requires ad-variants; update Slates on capability refusal.",
|
|
5198
|
+
billable: false,
|
|
5199
|
+
input: getVariantsInput,
|
|
5200
|
+
async run(input, ctx) {
|
|
5201
|
+
const desktop = ctx.desktop();
|
|
5202
|
+
await desktop.requireCapability('ad-variants', 'ad variants on one shared body');
|
|
5203
|
+
const { grid, ...ids } = input;
|
|
5204
|
+
if (grid === undefined)
|
|
5205
|
+
return ok(await desktop.get('/agent/timeline/variants', ids));
|
|
5206
|
+
await desktop.requireCapability('variant-grid', 'the variant grid: combinations, files and missing takes');
|
|
5207
|
+
return ok(withGridCredits(await desktop.get('/agent/timeline/variants', { ...ids, grid: true,
|
|
5208
|
+
picks: grid.picks === undefined ? undefined : JSON.stringify(grid.picks), aspects: grid.aspects?.join(',') })));
|
|
5209
|
+
},
|
|
5210
|
+
};
|
|
5211
|
+
/** The grid's missing takes in credits. A desktop before slate 9f9b9ea sends only `costs`, dollars per request,
|
|
5212
|
+
* so their credits are summed here, each request rounded alone as it bills. */
|
|
5213
|
+
function withGridCredits(answer) {
|
|
5214
|
+
const takes = answer?.grid?.missingTakes;
|
|
5215
|
+
if (takes && takes.credits === undefined) {
|
|
5216
|
+
takes.credits = Array.isArray(takes.costs) ? takes.costs.reduce((sum, cost) => sum + creditsFromDollars(cost), 0) : null;
|
|
5217
|
+
}
|
|
5218
|
+
return answer;
|
|
5219
|
+
}
|
|
5220
|
+
const variantSlotsInput = z.object({
|
|
5221
|
+
projectId: z.string().uuid(),
|
|
5222
|
+
action: z.enum(['add', 'update', 'remove', 'add-alternative', 'update-alternative', 'remove-alternative']),
|
|
5223
|
+
timelineId: z.string().uuid().optional().describe('The cut: for add, and for add-alternative with slotName instead of slotId.'),
|
|
5224
|
+
slotId: z.string().uuid().optional().describe('For update, remove and add-alternative.'),
|
|
5225
|
+
slotName: z.string().min(1).max(80).optional().describe('add-alternative without slotId: makes this slot first.'),
|
|
5226
|
+
alternativeId: z.string().uuid().optional().describe('For update-alternative and remove-alternative.'),
|
|
5227
|
+
name: z.string().min(1).max(80).optional().describe("A slot's or an alternative's name. Defaults: Hook, Body, End card; '<slot> 1'."),
|
|
5228
|
+
at: z.number().int().min(0).optional().describe('add: the position among the slots.'),
|
|
5229
|
+
orderIndex: z.number().int().min(0).optional().describe('update or update-alternative: move it to this position.'),
|
|
5230
|
+
bedFrame: z.number().int().min(0).nullable().optional().describe("update: the bed frame this slot's first frame meets in every variant (one slot per cut); null clears it."),
|
|
5231
|
+
clipIds: z.array(z.string().uuid()).min(1).optional().describe('add-alternative: move these clips (and their linked sound) off the cut into a new sequence; what stays is the bed.'),
|
|
5232
|
+
sequenceId: z.string().uuid().optional().describe('add-alternative: an existing timeline of this project to hold as it is.'),
|
|
5233
|
+
}).strict();
|
|
5234
|
+
export const editVariantSlots = {
|
|
5235
|
+
id: 'slates_edit_variant_slots',
|
|
5236
|
+
description: "Add, rename, move or remove a cut's ad-variant slots (hook, body, end card: names, never types) and their alternatives, as the Ad variants view in the Inspector does. add-alternative with clipIds collapses those clips off the cut into a new nested sequence, so the body exists once and a fix to it shows in every variant; the first slot made from clips, or one named Body, anchors the bed where its clips sat. Without clipIds or sequenceId it makes an empty sequence to fill with slates_add_clip_to_timeline (its sequenceId is the timelineId). Removing an alternative also removes the variant rows that pick it (removedVariantIds), each with its timeline unless edited by hand; removing a slot drops each row's pick for it. A removed slot's or alternative's own sequence stays, as an ordinary cut. Every unedited variant rebuilds after. Returns the whole set as slates_get_variants does, with the new slotId or alternativeId. Requires ad-variants; update Slates on capability refusal.",
|
|
5237
|
+
billable: false,
|
|
5238
|
+
input: variantSlotsInput,
|
|
5239
|
+
async run(input, ctx) {
|
|
5240
|
+
await ctx.desktop().requireCapability('ad-variants', 'ad variants on one shared body');
|
|
5241
|
+
return ok(await ctx.desktop().post('/agent/timeline/variant-slots', input));
|
|
5242
|
+
},
|
|
5243
|
+
};
|
|
5244
|
+
const variantsInput = z.object({
|
|
5245
|
+
projectId: z.string().uuid(),
|
|
5246
|
+
action: z.enum(['add', 'update', 'remove', 'rebuild']),
|
|
5247
|
+
timelineId: z.string().uuid().optional().describe('add: the cut with the slots.'),
|
|
5248
|
+
variantId: z.string().uuid().optional().describe('update, remove and rebuild.'),
|
|
5249
|
+
combinations: z.boolean().optional().describe("add: one row per combination of the slots' alternatives not already a row."),
|
|
5250
|
+
rows: z.array(z.object({ name: z.string().min(1).max(80).optional(), choices: variantChoices.optional(), seams: variantSeams.optional() }).strict()).optional().describe('add: the rows to add; omit for one row of first alternatives.'),
|
|
5251
|
+
name: z.string().min(1).max(80).optional().describe('update: the row and its timeline take it.'),
|
|
5252
|
+
choices: variantChoices.optional().describe('update: merged into the row.'),
|
|
5253
|
+
seams: variantSeams.optional().describe("update: merged; 'auto' gives a seam back to the automatic pick."),
|
|
5254
|
+
}).strict();
|
|
5255
|
+
export const editVariants = {
|
|
5256
|
+
id: 'slates_edit_variants',
|
|
5257
|
+
description: "Add, change, rebuild or remove ad variant rows on a cut's slots, as the Ad variants view does. Each row picks one alternative per slot and is built into an ordinary timeline (cutId), named for ad export, ready for slates_export_cuts. Seams: the picture always cuts where slots meet; the sound is picked from the transcripts (L-cut when the outgoing line runs past its picture, J-cut when the next slot opens on speech, a short crossfade when both sides have sound on audio lanes, else a cut, a picture cut over the bed with no dialogue), or set by hand per seam; either way held to the media past the cut, with the reason in the result. A row's timeline catches up with its sources when opened, exported or after any slot or row action, unless edited by hand; rebuild takes the sources and drops the hand edits. remove deletes the row and its timeline unless edited by hand. Returns the whole set and the new variantIds. Requires ad-variants; update Slates on capability refusal.",
|
|
5258
|
+
billable: false,
|
|
5259
|
+
input: variantsInput,
|
|
5260
|
+
async run(input, ctx) {
|
|
5261
|
+
await ctx.desktop().requireCapability('ad-variants', 'ad variants on one shared body');
|
|
5262
|
+
return ok(await ctx.desktop().post('/agent/timeline/variants', input));
|
|
5263
|
+
},
|
|
5264
|
+
};
|
|
5265
|
+
export const getRecipe = {
|
|
5266
|
+
id: 'slates_get_recipe', description: 'Find what made an exported ad from its recipe ID, its full ad name or its file name (anything holding __r-<id>). Returns every export that carried the recipe (batch, export time, ad name, files per format, the timeline id and name, its taxonomy); then each clip with its timing and asset and, when generated, the model, prompt, references and key settings frozen at export, and the Shot and board it came from (Shot, board and asset names and labels are read as they are now, not frozen); then any timeline that still renders the recipe. Searches every project unless projectId is given. When nothing matches, notFound says why: exported before ad names carried a recipe ID, or the timeline changed and its export folder is unreachable. Read-only; never generates or spends. Requires recipe-lookup; update Slates on capability refusal.',
|
|
5267
|
+
billable: false,
|
|
5268
|
+
input: z.object({
|
|
5269
|
+
recipe: z.string().min(1).describe('The recipe ID (the characters after __r-), or a whole ad name, file name or path containing __r-<id>.'),
|
|
5270
|
+
projectId: z.string().uuid().optional().describe('Search only this project; omit to search every project.'),
|
|
5271
|
+
}).strict(),
|
|
5272
|
+
async run(input, ctx) {
|
|
5273
|
+
await ctx.desktop().requireCapability('recipe-lookup', 'looking up the recipe behind an exported ad');
|
|
5274
|
+
return ok(await ctx.desktop().get('/agent/timeline/recipe', input));
|
|
5275
|
+
},
|
|
5276
|
+
};
|
|
5142
5277
|
const reframeReportInput = z.object({ projectId: z.string().uuid(), timelineId: z.string().uuid(), aspect: deliveryAspectInput, clipId: z.string().uuid().optional() }).strict();
|
|
5143
5278
|
export const getReframeReport = {
|
|
5144
5279
|
id: 'slates_get_reframe_report', description: 'Inspect effective delivery framing, computed dimensions, kept frame percentage, upscale and stale-take or missing-media warnings for a cut or one clip. Read before reframing; warnings never trigger generation or disable export. Requires ad-variant-export; update Slates on capability refusal.',
|
|
@@ -5163,7 +5298,7 @@ export const reframeClip = {
|
|
|
5163
5298
|
},
|
|
5164
5299
|
};
|
|
5165
5300
|
export const listTimelines = {
|
|
5166
|
-
id: 'slates_list_timelines', description:
|
|
5301
|
+
id: 'slates_list_timelines', description: "List the independent named cuts in a project (not a slot's alternative timelines: slates_get_variants names those). Use the selected timelineId for edits, builds and exports.",
|
|
5167
5302
|
input: z.object({ projectId: z.string().uuid() }),
|
|
5168
5303
|
async run(input, ctx) {
|
|
5169
5304
|
await ctx.desktop().requireCapability('named-cuts', 'named cuts');
|
|
@@ -5212,9 +5347,63 @@ export const getTimeline = {
|
|
|
5212
5347
|
JSON.stringify(r, null, 2));
|
|
5213
5348
|
},
|
|
5214
5349
|
};
|
|
5350
|
+
const loudnessInput = z.object({
|
|
5351
|
+
projectId: z.string().uuid(),
|
|
5352
|
+
timelineId: z.string().uuid().optional().describe("The cut to measure; absent: the project's default timeline."),
|
|
5353
|
+
fromSec: z.number().min(0).optional().describe('Measure from here (timeline seconds), as if the span were exported alone.'),
|
|
5354
|
+
toSec: z.number().positive().optional().describe('Measure to here (timeline seconds); absent: the end.'),
|
|
5355
|
+
trackId: z.string().min(1).optional().describe('Read this one lane alone (with the mix); absent: every lane heard.'),
|
|
5356
|
+
});
|
|
5357
|
+
export const getTimelineLoudness = {
|
|
5358
|
+
id: 'slates_get_timeline_loudness',
|
|
5359
|
+
description: "Measure a timeline's loudness as its export writes it: integrated LUFS (gated, ITU-R BS.1770), loudness range (LRA, LU), " +
|
|
5360
|
+
'true peak (dBTP, read 4x oversampled) and sample peak of the whole mix, the same for each lane alone (every other lane muted), ' +
|
|
5361
|
+
'and a short-term (3 s) and momentary (400 ms) reading per second in `mix.trace`. Read-only: the desktop renders the sound to a ' +
|
|
5362
|
+
'temporary file and measures it; nothing is saved and nothing is spent. Check a mix against its bar before exporting: a short for ' +
|
|
5363
|
+
'social is -14 LUFS integrated with a true peak of -1 dBTP or under (`target` in the answer, shown, never enforced). To move the ' +
|
|
5364
|
+
'integrated level by D dB, multiply masterVolume by 10^(D/20) with slates_update_timeline_settings, then measure again and check the ' +
|
|
5365
|
+
'true peak. fromSec and toSec measure one span alone; trackId reads one lane. Null means silence, or a span too short (range and ' +
|
|
5366
|
+
"short-term need 3 s). Same numbers as the Output level popover's Measure. Requires the desktop's loudness capability; update Slates on refusal.",
|
|
5367
|
+
billable: false,
|
|
5368
|
+
input: loudnessInput,
|
|
5369
|
+
async run(input, ctx) {
|
|
5370
|
+
const desktop = ctx.desktop();
|
|
5371
|
+
await desktop.requireCapability('loudness', 'the loudness meter');
|
|
5372
|
+
await requireNamedCut(desktop, input.timelineId);
|
|
5373
|
+
const r = await desktop.get('/agent/timeline/loudness', input);
|
|
5374
|
+
const show = (n, unit) => (n == null ? '-' : `${n} ${unit}`);
|
|
5375
|
+
const lanes = (r.lanes ?? []).map((l) => `${l.name} ${show(l.integratedLufs, 'LUFS')}`).join(', ');
|
|
5376
|
+
return ok(r, `Mix: ${show(r.mix?.integratedLufs, 'LUFS')} integrated, range ${show(r.mix?.loudnessRangeLu, 'LU')}, true peak ${show(r.mix?.truePeakDbtp, 'dBTP')} ` +
|
|
5377
|
+
`(target ${r.target?.integratedLufs ?? '?'} LUFS, ${r.target?.truePeakDbtp ?? '?'} dBTP).${lanes ? ` Lanes: ${lanes}.` : ''}\n\n` +
|
|
5378
|
+
JSON.stringify(r, null, 2));
|
|
5379
|
+
},
|
|
5380
|
+
};
|
|
5381
|
+
// ── Sound to the sample (music edits between frames) ───────────
|
|
5382
|
+
// Mirrors of slate's limits, held equal by lockstep check 12: the rate a sound clip set to the sample counts
|
|
5383
|
+
// its file in (`AUDIO_SOURCE_FPS`, src/shared/clipTiming.ts), the crossfade's millisecond range and curves
|
|
5384
|
+
// (src/shared/transitions.ts) and the export's sound bitrates (src/shared/audioBitrate.ts).
|
|
5385
|
+
const SOUND_SAMPLE_RATE = 48000;
|
|
5386
|
+
const SOUND_CROSSFADE_MS = { min: 1, max: 10000 };
|
|
5387
|
+
const SOUND_CURVES = ['equal-power', 'linear'];
|
|
5388
|
+
const AUDIO_BITRATES = [128, 192, 256, 320];
|
|
5389
|
+
const AUDIO_BITRATE_DEFAULT = 320;
|
|
5390
|
+
const audioBitrateInput = z.union(AUDIO_BITRATES.map((kbps) => z.literal(kbps)));
|
|
5391
|
+
const soundEdgesInput = {
|
|
5392
|
+
startSec: z.number().min(0).optional().describe('Audio lane: where its sound starts on the timeline, in seconds to the sample; it may fall between frames.'),
|
|
5393
|
+
sourceInSec: z.number().min(0).optional().describe('Audio lane: where in its file the sound starts, in seconds, to the sample.'),
|
|
5394
|
+
sourceOutSec: z.number().positive().optional().describe('Audio lane: where in its file the sound ends, in seconds, to the sample.'),
|
|
5395
|
+
sourceInSample: z.number().int().min(0).optional().describe(`The media in as a sample count at ${SOUND_SAMPLE_RATE} Hz, instead of sourceInSec.`),
|
|
5396
|
+
sourceOutSample: z.number().int().positive().optional().describe(`The media out as a sample count at ${SOUND_SAMPLE_RATE} Hz, instead of sourceOutSec.`),
|
|
5397
|
+
};
|
|
5398
|
+
const SOUND_EDGE_FIELDS = Object.keys(soundEdgesInput);
|
|
5399
|
+
const asksSoundEdges = (input) => SOUND_EDGE_FIELDS.some((field) => input[field] !== undefined);
|
|
5400
|
+
/** An older desktop drops the fields and keeps the clip on its frames; this one refuses instead. */
|
|
5401
|
+
async function requireSoundPrecision(desktop) {
|
|
5402
|
+
await desktop.requireCapability('sound-precision', 'sound edges to the sample, millisecond crossfades and the sound bitrate');
|
|
5403
|
+
}
|
|
5215
5404
|
export const addClipToTimeline = {
|
|
5216
5405
|
id: 'slates_add_clip_to_timeline',
|
|
5217
|
-
description: "Append a video or audio asset from the project to the project's timeline (or place it at an explicit startFrame). Defaults match the desktop UI: video clips go to the end of the first video track; audio clips (music, voiceover, AI audio) go after the last clip on the first AUDIO track and are mixed under the video on export. An empty timeline auto-adopts the first video clip's resolution and frame rate; later higher-resolution clips raise the canvas. Overlapping video clips resolve top-track-wins. Optionally trim with sourceInFrame/sourceOutFrame (frames at the SOURCE fps). Use slates_get_timeline first to see current clips and pick positions. To lay a board's chosen clips in board order, use slates_edit_cut (build) instead.",
|
|
5406
|
+
description: "Append a video or audio asset from the project to the project's timeline (or place it at an explicit startFrame). Defaults match the desktop UI: video clips go to the end of the first video track; audio clips (music, voiceover, AI audio) go after the last clip on the first AUDIO track and are mixed under the video on export. An empty timeline auto-adopts the first video clip's resolution and frame rate; later higher-resolution clips raise the canvas. Overlapping video clips resolve top-track-wins. Optionally trim with sourceInFrame/sourceOutFrame (frames at the SOURCE fps). An audio asset may instead take startSec, sourceInSec and sourceOutSec (or sourceInSample/sourceOutSample) to the sample, for a music edit between frames; with no startSec it starts where the lane's last sound ends, so clips appended in turn butt exactly. Use slates_get_timeline first to see current clips and pick positions. To lay a board's chosen clips in board order, use slates_edit_cut (build) instead.",
|
|
5218
5407
|
input: z.object({
|
|
5219
5408
|
projectId: z.string().uuid(), timelineId: z.string().uuid().optional(),
|
|
5220
5409
|
assetId: z.string().uuid().describe('Video or audio asset already in the project.'),
|
|
@@ -5222,11 +5411,18 @@ export const addClipToTimeline = {
|
|
|
5222
5411
|
startFrame: z.number().int().min(0).optional().describe('Timeline frame to place the clip at. Default: append after the last clip.'),
|
|
5223
5412
|
sourceInFrame: z.number().int().min(0).optional(),
|
|
5224
5413
|
sourceOutFrame: z.number().int().min(1).optional(),
|
|
5414
|
+
...soundEdgesInput,
|
|
5225
5415
|
}),
|
|
5226
5416
|
async run(input, ctx) {
|
|
5227
5417
|
const desktop = ctx.desktop();
|
|
5228
5418
|
await desktop.requireCapability('timeline', 'timeline editing');
|
|
5229
5419
|
await requireNamedCut(desktop, input.timelineId);
|
|
5420
|
+
const precise = asksSoundEdges(input);
|
|
5421
|
+
if (precise && (input.startFrame !== undefined || input.sourceInFrame !== undefined || input.sourceOutFrame !== undefined)) {
|
|
5422
|
+
throw new Error("Send the clip's edges in frames or in seconds and samples, not both.");
|
|
5423
|
+
}
|
|
5424
|
+
if (precise)
|
|
5425
|
+
await requireSoundPrecision(desktop);
|
|
5230
5426
|
const r = await desktop.post('/agent/timeline/add-clip', {
|
|
5231
5427
|
projectId: input.projectId, timelineId: input.timelineId,
|
|
5232
5428
|
assetId: input.assetId,
|
|
@@ -5234,6 +5430,7 @@ export const addClipToTimeline = {
|
|
|
5234
5430
|
startFrame: input.startFrame,
|
|
5235
5431
|
sourceInFrame: input.sourceInFrame,
|
|
5236
5432
|
sourceOutFrame: input.sourceOutFrame,
|
|
5433
|
+
...Object.fromEntries(SOUND_EDGE_FIELDS.map((field) => [field, input[field]])),
|
|
5237
5434
|
});
|
|
5238
5435
|
const clip = r.clip ?? {};
|
|
5239
5436
|
// Code + label for the chat reference: prefer fields on the clip, fall
|
|
@@ -5288,10 +5485,12 @@ const transitionShape = {
|
|
|
5288
5485
|
durationSec: z.number().positive().optional().describe('The same, in seconds.'),
|
|
5289
5486
|
alignment: z.enum(['center', 'start', 'end']).optional().describe('center (default) straddles the cut; start begins at the cut; end finishes at it.'),
|
|
5290
5487
|
params: z.record(z.string(), z.unknown()).optional().describe("The kind's settings. freeze: true holds the edge frame where the media runs short. On a picture transition, audio: false stops the clips' sound crossfading with it."),
|
|
5488
|
+
durationMs: z.number().min(SOUND_CROSSFADE_MS.min).max(SOUND_CROSSFADE_MS.max).optional().describe(`Audio lane: the crossfade's length in milliseconds (${SOUND_CROSSFADE_MS.min} to ${SOUND_CROSSFADE_MS.max}), placed to the sample, so it may be shorter than a frame. Instead of durationFrames or durationSec.`),
|
|
5489
|
+
curve: z.enum(SOUND_CURVES).optional().describe("Audio lane: 'equal-power' (default) for two different sounds, 'linear' (straight lines, a triangular crossfade) for a join inside one piece of music."),
|
|
5291
5490
|
};
|
|
5292
5491
|
export const addTransition = {
|
|
5293
5492
|
id: 'slates_add_transition',
|
|
5294
|
-
description: "Put a transition (dissolve, wipe, crossfade and the other kinds) on a cut between two clips that meet on one lane, as the Cut's clip menu does. Name the cut by fromClipId and toClipId, or by one clipId and side ('end' runs this clip into the next, 'start' the last clip into this one). A cut holds one transition, so adding where one exists changes it. It never refuses short media: the result's shortHandles says how many frames are missing and offers the fixes (slates_update_transition fix: freeze or shorten). For a fade to or from black, set the clip's fades with slates_update_clip instead. The open Cut shows the change.",
|
|
5493
|
+
description: "Put a transition (dissolve, wipe, crossfade and the other kinds) on a cut between two clips that meet on one lane, as the Cut's clip menu does. Name the cut by fromClipId and toClipId, or by one clipId and side ('end' runs this clip into the next, 'start' the last clip into this one). A cut holds one transition, so adding where one exists changes it. It never refuses short media: the result's shortHandles says how many frames are missing and offers the fixes (slates_update_transition fix: freeze or shorten). On an audio lane, durationMs sets a crossfade to the millisecond and curve how the sounds cross: a 10 ms linear crossfade with alignment 'end' joins two cuts of one song as a triangular crossfade does. For a fade to or from black, set the clip's fades with slates_update_clip instead. The open Cut shows the change.",
|
|
5295
5494
|
input: z.object({
|
|
5296
5495
|
projectId: z.string().uuid(),
|
|
5297
5496
|
fromClipId: z.string().uuid().optional().describe('The clip before the cut.'),
|
|
@@ -5305,12 +5504,14 @@ export const addTransition = {
|
|
|
5305
5504
|
await desktop.requireCapability('timeline-transitions', 'transitions');
|
|
5306
5505
|
if (!input.fromClipId && !input.toClipId && !input.clipId)
|
|
5307
5506
|
throw new Error('Name the cut: fromClipId and toClipId, or clipId with side.');
|
|
5507
|
+
if (input.durationMs !== undefined || input.curve !== undefined)
|
|
5508
|
+
await requireSoundPrecision(desktop);
|
|
5308
5509
|
return ok(await desktop.post('/agent/timeline/add-transition', input));
|
|
5309
5510
|
},
|
|
5310
5511
|
};
|
|
5311
5512
|
export const updateTransition = {
|
|
5312
5513
|
id: 'slates_update_transition',
|
|
5313
|
-
description: "Change a transition's kind, length, alignment or settings by its id (slates_get_timeline lists them under transitions), or apply one of the two fixes for short media: fix 'freeze' holds the edge frame for the missing frames, fix 'shorten' cuts it to the longest the media covers. Only the fields you name change. Returns the transition with its span and any frames still missing.",
|
|
5514
|
+
description: "Change a transition's kind, length, alignment or settings by its id (slates_get_timeline lists them under transitions), or apply one of the two fixes for short media: fix 'freeze' holds the edge frame for the missing frames, fix 'shorten' cuts it to the longest the media covers. Only the fields you name change; on an audio lane durationMs and curve set a crossfade to the millisecond, and a length in frames or seconds replaces one in milliseconds. Returns the transition with its span (durationSec, curve) and any frames still missing.",
|
|
5314
5515
|
input: z.object({
|
|
5315
5516
|
projectId: z.string().uuid(),
|
|
5316
5517
|
transitionId: z.string().uuid(),
|
|
@@ -5320,6 +5521,8 @@ export const updateTransition = {
|
|
|
5320
5521
|
async run(input, ctx) {
|
|
5321
5522
|
const desktop = ctx.desktop();
|
|
5322
5523
|
await desktop.requireCapability('timeline-transitions', 'transitions');
|
|
5524
|
+
if (input.durationMs !== undefined || input.curve !== undefined)
|
|
5525
|
+
await requireSoundPrecision(desktop);
|
|
5323
5526
|
return ok(await desktop.post('/agent/timeline/update-transition', input));
|
|
5324
5527
|
},
|
|
5325
5528
|
};
|
|
@@ -5375,9 +5578,42 @@ export const editTimelineClips = {
|
|
|
5375
5578
|
return ok(await desktop.post('/agent/timeline/split-clip', body));
|
|
5376
5579
|
},
|
|
5377
5580
|
};
|
|
5581
|
+
const keyframeEasing = z.union([
|
|
5582
|
+
z.enum(['linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out', 'hold']),
|
|
5583
|
+
z.object({ cubicBezier: z.tuple([z.number().min(0).max(1), z.number(), z.number().min(0).max(1), z.number()]) }).strict(),
|
|
5584
|
+
]);
|
|
5585
|
+
const keyframeKeys = z.array(z
|
|
5586
|
+
.object({
|
|
5587
|
+
frame: z.number().finite().min(0).describe("Frames from the clip's start, at the timeline's frame rate; may fall between frames, read at that exact time (110.4 is 4.6 s at 24 fps)."),
|
|
5588
|
+
value: z.number().finite(),
|
|
5589
|
+
easing: keyframeEasing.optional().describe('The curve from this key to the next. Default linear; hold jumps at the next key.'),
|
|
5590
|
+
})
|
|
5591
|
+
.strict());
|
|
5592
|
+
const keyframeList = keyframeKeys.max(500);
|
|
5593
|
+
/** Any key off a whole frame, in any of these key lists or effect lists' keys. */
|
|
5594
|
+
function keysBetweenFrames(...lists) {
|
|
5595
|
+
return lists.some((list) => (list ?? []).some((item) => 'frame' in item ? !Number.isInteger(item.frame) : Object.values(item.keyframes ?? {}).some((keys) => keys.some((k) => !Number.isInteger(k.frame)))));
|
|
5596
|
+
}
|
|
5597
|
+
/** An older desktop refuses a key that is not a whole frame; ask first, so the refusal names the update. */
|
|
5598
|
+
async function requireKeysBetweenFrames(desktop, ...lists) {
|
|
5599
|
+
if (keysBetweenFrames(...lists))
|
|
5600
|
+
await desktop.requireCapability('keys-between-frames', 'keys between frames (a frame such as 110.4)');
|
|
5601
|
+
}
|
|
5602
|
+
/** An effect list as the desktop stores it (`slate/src/shared/audioEffects.ts`); slates_get_timeline's audioEffects lists each type's parameters and ranges. */
|
|
5603
|
+
const audioEffectList = z
|
|
5604
|
+
.array(z
|
|
5605
|
+
.object({
|
|
5606
|
+
id: z.string().max(64).optional().describe('Kept when sent back; a new effect gets one.'),
|
|
5607
|
+
type: z.enum(['volume', 'eq']).describe("volume: gain in dB (param gainDb, -60 silent to +12). eq: its low-pass (params 'lowpass.frequency' in Hz, 20 to 20000, swept by octave; 'lowpass.q', 0.1 to 10, 0.71 flat)."),
|
|
5608
|
+
bypass: z.boolean().optional(),
|
|
5609
|
+
params: z.record(z.number()).optional().describe('Fixed values by parameter name.'),
|
|
5610
|
+
keyframes: z.record(keyframeKeys.max(4000)).optional().describe('Keys by parameter name; a keyed parameter reads its keys instead of its fixed value.'),
|
|
5611
|
+
})
|
|
5612
|
+
.strict())
|
|
5613
|
+
.max(16);
|
|
5378
5614
|
export const updateClip = {
|
|
5379
5615
|
id: 'slates_update_clip',
|
|
5380
|
-
description: "Set a timeline clip's own speed, volume, split edit (J-cut or L-cut) and fades, as the Cut's Inspector does. Only the fields you name change; null puts one back to the default. speed keeps the clip's media in and out points and its start and changes its length (2 is twice as fast, half as long); with ripple: true the lane's later clips move by the change, otherwise a longer clip covers what follows. audioOffsetFrames, on a video clip, moves its own sound against its picture in sync: below 0 is a J-cut (the sound starts first), above 0 an L-cut (it runs on). Fades are frames: fadeIn/fadeOut for the picture, audioFadeIn/audioFadeOut for the sound. volume is linear gain (1 = 0 dB, 0 = silent). look, on a clip with a picture, is the Inspector's Blend, Grain and Colour, sent whole: blend mixes the picture with what is under it (multiply darkens, screen lightens, overlay and soft-light add contrast), grain is film grain from 0 to 1, saturation is colour from 0 (black and white) through 1 (as shot) to 2; null clears the look.",
|
|
5616
|
+
description: "Set a timeline clip's own speed, volume, split edit (J-cut or L-cut) and fades, as the Cut's Inspector does. Only the fields you name change; null puts one back to the default. speed keeps the clip's media in and out points and its start and changes its length (2 is twice as fast, half as long); with ripple: true the lane's later clips move by the change, otherwise a longer clip covers what follows. audioOffsetFrames, on a video clip, moves its own sound against its picture in sync: below 0 is a J-cut (the sound starts first), above 0 an L-cut (it runs on). Fades are frames: fadeIn/fadeOut for the picture, audioFadeIn/audioFadeOut for the sound. volume is linear gain (1 = 0 dB, 0 = silent). look, on a clip with a picture, is the Inspector's Blend, Grain and Colour, sent whole: blend mixes the picture with what is under it (multiply darkens, screen lightens, overlay and soft-light add contrast), grain is film grain from 0 to 1, saturation is colour from 0 (black and white) through 1 (as shot) to 2; null clears the look. effects is the clip's sound effects, sent whole, in order: a volume (gain in dB) and an eq (its low-pass), each fixed or keyed in frames from the clip's start, the same in preview and export. speedRamp keys the speed over the clip (a slow-motion ramp): media in and out stay, the length becomes what the keys take, and the sound follows tape-style; not with speed. speedSound 'tape' makes a constant speed's sound change pitch with it. On an audio lane, startSec, sourceInSec and sourceOutSec (or sourceInSample and sourceOutSample) set where its sound starts and its media in and out to the sample, for a music edit between frames; a longer clip covers what follows unless ripple; not with speed in the same call.",
|
|
5381
5617
|
input: z.object({
|
|
5382
5618
|
projectId: z.string().uuid(),
|
|
5383
5619
|
clipId: z.string().uuid(),
|
|
@@ -5393,16 +5629,31 @@ export const updateClip = {
|
|
|
5393
5629
|
grain: z.number().min(0).max(1).optional(),
|
|
5394
5630
|
saturation: z.number().min(0).max(2).optional(),
|
|
5395
5631
|
}).strict().nullable().optional().describe('The whole look, at least one field; a field left out is its default (normal, no grain, colour 1). null clears it.'),
|
|
5396
|
-
|
|
5632
|
+
effects: audioEffectList.nullable().optional().describe("A clip with sound: its effect list, sent whole; null clears it. A split picture's go to its sound clip."),
|
|
5633
|
+
speedRamp: keyframeKeys.max(4000).nullable().optional().describe("Speeds (0.05 to 20) keyed in frames from the clip's start; null goes back to one speed. Its linked sound follows."),
|
|
5634
|
+
speedSound: z.enum(['tape', 'keep-pitch']).nullable().optional().describe("How a constant speed's sound plays: tape moves pitch with speed; keep-pitch (or null) holds it. A ramp's is always tape."),
|
|
5635
|
+
ripple: z.boolean().optional().describe("With speed, speedRamp or a sound clip's new media out: move the lane's later clips instead of covering them."),
|
|
5636
|
+
...soundEdgesInput,
|
|
5397
5637
|
}),
|
|
5398
5638
|
async run(input, ctx) {
|
|
5399
5639
|
const desktop = ctx.desktop();
|
|
5400
5640
|
await desktop.requireCapability('timeline-editing', "a clip's speed, volume, split edit and fades");
|
|
5641
|
+
if (input.speed !== undefined && input.speedRamp !== undefined)
|
|
5642
|
+
throw new Error('Send speed (one speed) or speedRamp (keyed), not both.');
|
|
5643
|
+
if (input.effects !== undefined || input.speedRamp !== undefined || input.speedSound !== undefined) {
|
|
5644
|
+
await desktop.requireCapability('audio-effects', 'audio effects and speed ramps');
|
|
5645
|
+
await requireKeysBetweenFrames(desktop, input.speedRamp, input.effects);
|
|
5646
|
+
}
|
|
5401
5647
|
// An empty look would clear the clip's look without saying so; null is how to ask for that.
|
|
5402
5648
|
if (input.look && Object.keys(input.look).length === 0)
|
|
5403
5649
|
throw new Error('look needs at least one of blend, grain or saturation; send look: null to clear it');
|
|
5404
5650
|
if (input.look !== undefined)
|
|
5405
5651
|
await desktop.requireCapability('clip-look', "a clip's blend, grain and colour");
|
|
5652
|
+
if (asksSoundEdges(input)) {
|
|
5653
|
+
if (input.speed !== undefined || input.speedRamp !== undefined)
|
|
5654
|
+
throw new Error("Set a clip's speed and its edges in seconds or samples in two calls.");
|
|
5655
|
+
await requireSoundPrecision(desktop);
|
|
5656
|
+
}
|
|
5406
5657
|
return ok(await desktop.post('/agent/timeline/update-clip', input));
|
|
5407
5658
|
},
|
|
5408
5659
|
};
|
|
@@ -5450,7 +5701,18 @@ export const addTimelineTrack = {
|
|
|
5450
5701
|
// and the batch cap slate's `src/main/agent/routes-editor.ts`, which this package cannot import;
|
|
5451
5702
|
// lockstep check 12 fails when they differ. The 0..1 position and
|
|
5452
5703
|
// opacity are fractions by definition, not a desktop choice.
|
|
5453
|
-
const TEXT_STYLE_IDS = ['word-pop', 'keyword', 'subtitle', 'headline', 'clean'];
|
|
5704
|
+
const TEXT_STYLE_IDS = ['word-pop', 'keyword', 'subtitle', 'headline', 'clean', 'plain'];
|
|
5705
|
+
// A text clip set exactly (slate 1.6.x, capability text-fonts): the fonts Slates carries, the exact size,
|
|
5706
|
+
// the picture before the words and a line of clips, mirrored from slate's `src/shared/textStyles.ts` and
|
|
5707
|
+
// `src/shared/overlays.ts` like the rest (lockstep check 12).
|
|
5708
|
+
const TEXT_FONT_IDS = ['bebas-neue', 'montserrat-medium', 'montserrat-bold', 'montserrat-extrabold', 'montserrat-black',
|
|
5709
|
+
'geist-regular', 'geist-medium', 'geist-semibold', 'geist-bold'];
|
|
5710
|
+
const TEXT_FONT_SIZE_RANGE = { min: 0.005, max: 0.5 };
|
|
5711
|
+
const TEXT_PICTURE_HEIGHT_RANGE = { min: 0.1, max: 5 };
|
|
5712
|
+
const TEXT_PICTURE_GAP_RANGE = { min: 0, max: 2 };
|
|
5713
|
+
const TEXT_LINE_GAP_RANGE = { min: 0, max: 4 };
|
|
5714
|
+
const TEXT_LINE_NAME_MAX = 40;
|
|
5715
|
+
const TEXT_LINE_PLACE_MAX = 99;
|
|
5454
5716
|
const TEXT_STYLE_DEFAULT = 'subtitle';
|
|
5455
5717
|
const OVERLAY_TEXT_MAX = 2000;
|
|
5456
5718
|
const OVERLAY_WORDS_MAX = 2000;
|
|
@@ -5484,6 +5746,53 @@ const textLookInput = {
|
|
|
5484
5746
|
size: textSizeInput.optional(),
|
|
5485
5747
|
color: z.string().regex(/^#[0-9a-fA-F]{6}$/).optional().describe('The text colour as #rrggbb. Default: the style\'s.'),
|
|
5486
5748
|
};
|
|
5749
|
+
/** The fields of a text clip set exactly; each is checked by the desktop again. */
|
|
5750
|
+
const textSetInput = {
|
|
5751
|
+
font: z.enum(TEXT_FONT_IDS).describe("A font Slates carries, drawn the same in preview and export on any machine. Default: the style's font."),
|
|
5752
|
+
fontSize: z.number().min(TEXT_FONT_SIZE_RANGE.min).max(TEXT_FONT_SIZE_RANGE.max)
|
|
5753
|
+
.describe("The exact size as a fraction of the frame's height (72 px on a 1920-high frame is 0.0375); replaces size."),
|
|
5754
|
+
pictureAssetId: z.string().min(1).describe('An image asset in the project (code IMG-A12 or id) drawn before the words, centred on them.'),
|
|
5755
|
+
pictureHeight: z.number().min(TEXT_PICTURE_HEIGHT_RANGE.min).max(TEXT_PICTURE_HEIGHT_RANGE.max)
|
|
5756
|
+
.describe("The picture's height as a multiple of the font size. Default: the capitals' height."),
|
|
5757
|
+
pictureGap: z.number().min(TEXT_PICTURE_GAP_RANGE.min).max(TEXT_PICTURE_GAP_RANGE.max)
|
|
5758
|
+
.describe('The space after the picture, a multiple of the font size. Default: 0.25.'),
|
|
5759
|
+
line: z
|
|
5760
|
+
.object({
|
|
5761
|
+
name: z.string().max(TEXT_LINE_NAME_MAX).regex(/\S/, 'must not be blank'),
|
|
5762
|
+
place: z.number().int().min(0).max(TEXT_LINE_PLACE_MAX).optional().describe('Left to right, lowest first. Default: 0; a tie keeps the lower lane first.'),
|
|
5763
|
+
})
|
|
5764
|
+
.strict()
|
|
5765
|
+
.describe("Text clips on screen together with one line name are set side by side, centred as one on the first clip's x and y."),
|
|
5766
|
+
gap: z.number().min(TEXT_LINE_GAP_RANGE.min).max(TEXT_LINE_GAP_RANGE.max)
|
|
5767
|
+
.describe('In a line: the space before this clip, a multiple of its font size. Default: 0.25.'),
|
|
5768
|
+
};
|
|
5769
|
+
const TEXT_SET_FIELDS = Object.keys(textSetInput);
|
|
5770
|
+
/** The plain style came with text-fonts (slate 22f76ea), so a desktop without the token lacks it. */
|
|
5771
|
+
const TEXT_FONTS_STYLE = 'plain';
|
|
5772
|
+
/**
|
|
5773
|
+
* Items setting a text clip exactly, or in the plain style, need a desktop that takes them (an older one
|
|
5774
|
+
* would drop the fields and draw in the style's font, or not know the style), and their pictures named by
|
|
5775
|
+
* code become asset ids.
|
|
5776
|
+
*/
|
|
5777
|
+
async function textSetItems(ctx, desktop, projectId, items) {
|
|
5778
|
+
const needsFonts = (item) => item.style === TEXT_FONTS_STYLE
|
|
5779
|
+
|| TEXT_SET_FIELDS.some((field) => item[field] !== undefined);
|
|
5780
|
+
if (!items.some(needsFonts))
|
|
5781
|
+
return items;
|
|
5782
|
+
await desktop.requireCapability('text-fonts', 'bundled fonts, exact sizes, pictures and lines on text clips');
|
|
5783
|
+
const named = items.flatMap((item) => (typeof item.pictureAssetId === 'string' ? [item.pictureAssetId] : []));
|
|
5784
|
+
if (named.length === 0)
|
|
5785
|
+
return items;
|
|
5786
|
+
const refs = await resolveAssetRefs(ctx, projectId, named);
|
|
5787
|
+
return items.map((item, i) => {
|
|
5788
|
+
if (typeof item.pictureAssetId !== 'string')
|
|
5789
|
+
return item;
|
|
5790
|
+
const asset = refs.get(item.pictureAssetId);
|
|
5791
|
+
if (!asset)
|
|
5792
|
+
throw new Error(`items[${i}].pictureAssetId "${item.pictureAssetId}" is not an asset in this project (slates_list_assets).`);
|
|
5793
|
+
return { ...item, pictureAssetId: asset.id };
|
|
5794
|
+
});
|
|
5795
|
+
}
|
|
5487
5796
|
const overlayWordsInput = z
|
|
5488
5797
|
.array(z
|
|
5489
5798
|
.object({ text: overlayText(OVERLAY_WORD_TEXT_MAX), start: z.number().min(0), end: z.number().min(0) })
|
|
@@ -5508,7 +5817,7 @@ const overlayCount = (r, what) => {
|
|
|
5508
5817
|
};
|
|
5509
5818
|
export const addTextClip = {
|
|
5510
5819
|
id: 'slates_add_text_clip',
|
|
5511
|
-
description: "Put text on the timeline: captions, a headline, a keyword, a call to action. Each item is one text clip on an overlay track, drawn over the video in preview and export; a batch lands in one transaction, all or none. Captions that follow the voice: one clip per line, with each word's timing in words. Read slates_get_timeline first for the frame rate
|
|
5820
|
+
description: "Put text on the timeline: captions, a headline, a keyword, a call to action, a title-card label, a logo with words. Each item is one text clip on an overlay track, drawn over the video in preview and export; a batch lands in one transaction, all or none. Captions that follow the voice: one clip per line, with each word's timing in words. Set a label exactly with font (a font Slates carries) and fontSize (a fraction of the frame's height); it then centres the middle of its capitals on x, y. pictureAssetId draws an image before the words; clips sharing a line name are set side by side and centred as one, so a logo strip such as 'Blender + slates' is three items in one line (needs text-fonts; update Slates on refusal). Read slates_get_timeline first for the frame rate, where clips sit and textFonts. Returns the clips and the timeline. Change one later with slates_update_overlay_clip, remove it with slates_remove_clip.",
|
|
5512
5821
|
input: z.object({
|
|
5513
5822
|
projectId: z.string().uuid(), timelineId: z.string().uuid().optional(),
|
|
5514
5823
|
items: z
|
|
@@ -5517,6 +5826,13 @@ export const addTextClip = {
|
|
|
5517
5826
|
text: overlayText(OVERLAY_TEXT_MAX).describe('What it says.'),
|
|
5518
5827
|
words: overlayWordsInput.optional(),
|
|
5519
5828
|
...textLookInput,
|
|
5829
|
+
font: textSetInput.font.optional(),
|
|
5830
|
+
fontSize: textSetInput.fontSize.optional(),
|
|
5831
|
+
pictureAssetId: textSetInput.pictureAssetId.optional(),
|
|
5832
|
+
pictureHeight: textSetInput.pictureHeight.optional(),
|
|
5833
|
+
pictureGap: textSetInput.pictureGap.optional(),
|
|
5834
|
+
line: textSetInput.line.optional(),
|
|
5835
|
+
gap: textSetInput.gap.optional(),
|
|
5520
5836
|
...overlayPlacementInput,
|
|
5521
5837
|
})
|
|
5522
5838
|
.strict())
|
|
@@ -5528,7 +5844,8 @@ export const addTextClip = {
|
|
|
5528
5844
|
await desktop.requireCapability('timeline-overlays', 'text and image overlays');
|
|
5529
5845
|
await requireNamedCut(desktop, input.timelineId);
|
|
5530
5846
|
requireOverlayStart(input.items);
|
|
5531
|
-
const
|
|
5847
|
+
const items = await textSetItems(ctx, desktop, input.projectId, input.items);
|
|
5848
|
+
const r = await desktop.post('/agent/timeline/add-text', { ...input, items });
|
|
5532
5849
|
return ok(r, `${overlayCount(r, 'text clip')} ${JSON.stringify(r)}`);
|
|
5533
5850
|
},
|
|
5534
5851
|
};
|
|
@@ -5568,7 +5885,7 @@ export const addImageOverlay = {
|
|
|
5568
5885
|
};
|
|
5569
5886
|
export const updateOverlayClip = {
|
|
5570
5887
|
id: 'slates_update_overlay_clip',
|
|
5571
|
-
description: "Change a text clip's words or look, or an image overlay's place, size and opacity. Only the fields you name change; null puts one back to the style's or the default. words replaces a text clip's timings, and [] drops them; new text keeps the old timings, so send words with it. When the clip shows does not change here: to move one, remove it (slates_remove_clip) and add it again. A batch lands in one transaction, all or none. Returns the changed clips.",
|
|
5888
|
+
description: "Change a text clip's words or look, or an image overlay's place, size and opacity. Only the fields you name change; null puts one back to the style's or the default. A text clip also takes font, fontSize, pictureAssetId (null takes the picture away), pictureHeight, pictureGap, line and gap, as slates_add_text_clip describes (needs text-fonts); in a line, x and y are read from its first clip. words replaces a text clip's timings, and [] drops them; new text keeps the old timings, so send words with it. When the clip shows does not change here: to move one, remove it (slates_remove_clip) and add it again. A batch lands in one transaction, all or none. Returns the changed clips.",
|
|
5572
5889
|
input: z.object({
|
|
5573
5890
|
projectId: z.string().uuid(),
|
|
5574
5891
|
items: z
|
|
@@ -5584,6 +5901,13 @@ export const updateOverlayClip = {
|
|
|
5584
5901
|
color: z.string().regex(/^#[0-9a-fA-F]{6}$/).nullable().optional().describe('Text clips: #rrggbb.'),
|
|
5585
5902
|
width: imageWidthInput.nullable().optional().describe(`Image clips: ${imageWidthInput.description}`),
|
|
5586
5903
|
opacity: z.number().min(0).max(1).nullable().optional().describe('Image clips.'),
|
|
5904
|
+
font: textSetInput.font.nullable().optional(),
|
|
5905
|
+
fontSize: textSetInput.fontSize.nullable().optional(),
|
|
5906
|
+
pictureAssetId: textSetInput.pictureAssetId.nullable().optional().describe(`${textSetInput.pictureAssetId.description} null: none.`),
|
|
5907
|
+
pictureHeight: textSetInput.pictureHeight.nullable().optional(),
|
|
5908
|
+
pictureGap: textSetInput.pictureGap.nullable().optional(),
|
|
5909
|
+
line: textSetInput.line.nullable().optional().describe(`${textSetInput.line.description} null: out of the line.`),
|
|
5910
|
+
gap: textSetInput.gap.nullable().optional(),
|
|
5587
5911
|
})
|
|
5588
5912
|
.strict()
|
|
5589
5913
|
.refine((item) => Object.keys(item).some((k) => k !== 'clipId'), { message: 'name at least one field to change besides clipId' }))
|
|
@@ -5593,26 +5917,14 @@ export const updateOverlayClip = {
|
|
|
5593
5917
|
async run(input, ctx) {
|
|
5594
5918
|
const desktop = ctx.desktop();
|
|
5595
5919
|
await desktop.requireCapability('timeline-overlays', 'text and image overlays');
|
|
5596
|
-
|
|
5920
|
+
const items = await textSetItems(ctx, desktop, input.projectId, input.items);
|
|
5921
|
+
return ok(await desktop.post('/agent/timeline/update-overlay', { ...input, items }));
|
|
5597
5922
|
},
|
|
5598
5923
|
};
|
|
5599
5924
|
const KEYFRAME_PROPERTY_IDS = ['positionX', 'positionY', 'scale', 'rotation', 'opacity', 'cropLeft', 'cropTop', 'cropRight', 'cropBottom', 'focusX', 'focusY', 'zoom'];
|
|
5600
|
-
const keyframeEasing = z.union([
|
|
5601
|
-
z.enum(['linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out', 'hold']),
|
|
5602
|
-
z.object({ cubicBezier: z.tuple([z.number().min(0).max(1), z.number(), z.number().min(0).max(1), z.number()]) }).strict(),
|
|
5603
|
-
]);
|
|
5604
|
-
const keyframeList = z
|
|
5605
|
-
.array(z
|
|
5606
|
-
.object({
|
|
5607
|
-
frame: z.number().int().min(0).describe("Frames from the clip's start, at the timeline's frame rate."),
|
|
5608
|
-
value: z.number().finite(),
|
|
5609
|
-
easing: keyframeEasing.optional().describe('The curve from this key to the next. Default linear; hold jumps at the next key.'),
|
|
5610
|
-
})
|
|
5611
|
-
.strict())
|
|
5612
|
-
.max(500);
|
|
5613
5925
|
export const setClipKeyframes = {
|
|
5614
5926
|
id: 'slates_set_clip_keyframes',
|
|
5615
|
-
description: "Animate or set a timeline clip's transform with keyframes: a punch-in, a slow push, a Ken Burns move, a slide, a spin, a fade, a crop. Each property you name gets exactly the keys you send ([] clears it back to its static value); properties you leave out keep theirs, and all of them land in one transaction. One key holds a value for the whole clip. Frames count from the clip's start. Units: positionX/positionY move the picture's centre in frame widths/heights (0.1 = a tenth of the frame right or down, -4..4); scale multiplies the framed size about the frame's centre (1 = as framed, 0.01..20); rotation is degrees clockwise; opacity 0..1; cropLeft/Top/Right/Bottom remove that fraction of the source from its side (0..0.99); focusX/focusY (0..1) and zoom (1..20) animate the clip's reframe for the aspect being exported. Drawn by the Cut's monitor and its export alike, both the timeline engine. Returns the clip's keys; slates_get_timeline lists every clip's keys in timeline.keyframes. Requires timeline-keyframes; update Slates on capability refusal.",
|
|
5927
|
+
description: "Animate or set a timeline clip's transform with keyframes: a punch-in, a slow push, a Ken Burns move, a slide, a spin, a fade, a crop. Each property you name gets exactly the keys you send ([] clears it back to its static value); properties you leave out keep theirs, and all of them land in one transaction. One key holds a value for the whole clip. Frames count from the clip's start and may fall between frames (110.4), read at that exact time. Units: positionX/positionY move the picture's centre in frame widths/heights (0.1 = a tenth of the frame right or down, -4..4); scale multiplies the framed size about the frame's centre (1 = as framed, 0.01..20); rotation is degrees clockwise; opacity 0..1; cropLeft/Top/Right/Bottom remove that fraction of the source from its side (0..0.99); focusX/focusY (0..1) and zoom (1..20) animate the clip's reframe for the aspect being exported. Drawn by the Cut's monitor and its export alike, both the timeline engine. Returns the clip's keys; slates_get_timeline lists every clip's keys in timeline.keyframes. Requires timeline-keyframes; update Slates on capability refusal.",
|
|
5616
5928
|
input: z.object({
|
|
5617
5929
|
projectId: z.string().uuid(),
|
|
5618
5930
|
timelineId: z.string().uuid(),
|
|
@@ -5626,6 +5938,7 @@ export const setClipKeyframes = {
|
|
|
5626
5938
|
async run(input, ctx) {
|
|
5627
5939
|
const desktop = ctx.desktop();
|
|
5628
5940
|
await desktop.requireCapability('timeline-keyframes', 'clip keyframes');
|
|
5941
|
+
await requireKeysBetweenFrames(desktop, ...Object.values(input.properties));
|
|
5629
5942
|
return ok(await desktop.post('/agent/timeline/keyframes', input));
|
|
5630
5943
|
},
|
|
5631
5944
|
};
|
|
@@ -5676,6 +5989,8 @@ export const addCaptions = {
|
|
|
5676
5989
|
await ctx.desktop().requireCapability('caption-components', 'caption components');
|
|
5677
5990
|
if (input.html !== undefined)
|
|
5678
5991
|
await ctx.desktop().requireCapability('caption-html', 'caption layers of your own');
|
|
5992
|
+
if (input.style === TEXT_FONTS_STYLE)
|
|
5993
|
+
await ctx.desktop().requireCapability('text-fonts', 'the plain text style');
|
|
5679
5994
|
if (input.html !== undefined && input.component)
|
|
5680
5995
|
throw new Error('html is your own caption layer and component a ready one. Pass one or the other.');
|
|
5681
5996
|
if (input.html !== undefined && input.style)
|
|
@@ -5782,7 +6097,7 @@ export const listMotionBlocks = {
|
|
|
5782
6097
|
};
|
|
5783
6098
|
export const updateTimelineTrack = {
|
|
5784
6099
|
id: 'slates_update_timeline_track',
|
|
5785
|
-
description: 'Update a timeline track: rename, mute/unmute, lock/unlock, or set its volume fader (linear gain, -∞ to +12 dB). Track volume applies to both preview and MP4 export — audio-track clips are mixed at this gain; a muted video track still shows video but its embedded audio is silenced.',
|
|
6100
|
+
description: 'Update a timeline track: rename, mute/unmute, lock/unlock, or set its volume fader (linear gain, -∞ to +12 dB). Track volume applies to both preview and MP4 export — audio-track clips are mixed at this gain; a muted video track still shows video but its embedded audio is silenced. effects puts an effect list on a sound lane, heard after its clips\' own (the same shape as slates_update_clip, keys in frames from the timeline start).',
|
|
5786
6101
|
input: z.object({
|
|
5787
6102
|
projectId: z.string().uuid(),
|
|
5788
6103
|
trackId: z.string().uuid(),
|
|
@@ -5790,10 +6105,14 @@ export const updateTimelineTrack = {
|
|
|
5790
6105
|
muted: z.boolean().optional(),
|
|
5791
6106
|
locked: z.boolean().optional(),
|
|
5792
6107
|
volume: z.number().min(0).max(4).optional().describe('Track fader as LINEAR gain: 0 = -∞ (silent), 1 = 0 dB (unity), ~3.98 = +12 dB (max boost).'),
|
|
6108
|
+
effects: audioEffectList.nullable().optional().describe('A video or audio lane: its effect list, sent whole; null clears it.'),
|
|
5793
6109
|
}),
|
|
5794
6110
|
async run(input, ctx) {
|
|
5795
6111
|
const desktop = ctx.desktop();
|
|
5796
6112
|
await desktop.requireCapability('timeline-tracks', 'timeline tracks + audio mixing');
|
|
6113
|
+
if (input.effects !== undefined)
|
|
6114
|
+
await desktop.requireCapability('audio-effects', 'audio effects on a lane');
|
|
6115
|
+
await requireKeysBetweenFrames(desktop, input.effects);
|
|
5797
6116
|
return ok(await desktop.post('/agent/timeline/update-track', input));
|
|
5798
6117
|
},
|
|
5799
6118
|
};
|
|
@@ -5812,18 +6131,25 @@ export const removeTimelineTrack = {
|
|
|
5812
6131
|
};
|
|
5813
6132
|
export const updateTimelineSettings = {
|
|
5814
6133
|
id: 'slates_update_timeline_settings',
|
|
5815
|
-
description: "Update a timeline's output settings: resolution, frame rate (24/30/60; all clips are conformed to it on export), masterVolume, or delivery formats, naming taxonomy and explicit variant grid bindings. New fields require ad-variant-export; null clears them. Read aspects and dimensions from slates_get_variant_grid. Delivery-only updates on an explicit timeline return the computed formats. masterVolume is the output fader (linear gain: 0 is silent, 1 is unity, 4 is the maximum boost) applied to the preview and the final mix; use it to prevent clipping when stacking loud tracks. These are normally auto-managed: the first video clip sets fps and resolution, higher-res clips raise the canvas, and delivery preserves the master aspect. Changing frameRate keeps clip positions, lengths and markers in seconds, rounded to the nearest new frame.",
|
|
6134
|
+
description: "Update a timeline's output settings: resolution, frame rate (24/30/60; all clips are conformed to it on export), masterVolume, or delivery formats, naming taxonomy and explicit variant grid bindings. New fields require ad-variant-export; null clears them. Read aspects and dimensions from slates_get_variant_grid. Delivery-only updates on an explicit timeline return the computed formats. masterVolume is the output fader (linear gain: 0 is silent, 1 is unity, 4 is the maximum boost) applied to the preview and the final mix; use it to prevent clipping when stacking loud tracks. These are normally auto-managed: the first video clip sets fps and resolution, higher-res clips raise the canvas, and delivery preserves the master aspect. Changing frameRate keeps clip positions, lengths and markers in seconds, rounded to the nearest new frame. effects puts an effect list on the master, after the output fader (the same shape as slates_update_clip, keys in frames from the timeline start). audioBitrate is the exported MP4's sound in kb/s, the Sound bitrate the settings button shows.",
|
|
5816
6135
|
input: z.object({
|
|
5817
6136
|
projectId: z.string().uuid(), timelineId: z.string().uuid().optional(),
|
|
5818
6137
|
width: z.number().int().min(16).optional(),
|
|
5819
6138
|
height: z.number().int().min(16).optional(),
|
|
5820
6139
|
frameRate: z.union([z.literal(24), z.literal(30), z.literal(60)]).optional(),
|
|
5821
6140
|
masterVolume: z.number().min(0).max(4).optional().describe('Output fader as LINEAR gain: 0 = -∞ (silent), 1 = 0 dB (unity), ~3.98 = +12 dB (max boost).'),
|
|
6141
|
+
effects: audioEffectList.nullable().optional().describe("The master's effect list, sent whole; null clears it."),
|
|
6142
|
+
audioBitrate: audioBitrateInput.nullable().optional().describe(`The export's AAC sound in kb/s: ${AUDIO_BITRATES.join(', ')}; null goes back to the default ${AUDIO_BITRATE_DEFAULT}.`),
|
|
5822
6143
|
...cutOptionsInput,
|
|
5823
6144
|
}),
|
|
5824
6145
|
async run(input, ctx) {
|
|
5825
6146
|
const desktop = ctx.desktop();
|
|
5826
6147
|
await desktop.requireCapability('timeline-tracks', 'timeline tracks + audio mixing');
|
|
6148
|
+
if (input.effects !== undefined)
|
|
6149
|
+
await desktop.requireCapability('audio-effects', 'audio effects on the master');
|
|
6150
|
+
await requireKeysBetweenFrames(desktop, input.effects);
|
|
6151
|
+
if (input.audioBitrate !== undefined)
|
|
6152
|
+
await requireSoundPrecision(desktop);
|
|
5827
6153
|
await requireNamedCut(desktop, input.timelineId);
|
|
5828
6154
|
if (input.delivery !== undefined || input.taxonomy !== undefined || input.gridBinding !== undefined) {
|
|
5829
6155
|
await desktop.requireCapability('ad-variant-export', 'cut delivery, naming and grid bindings');
|
|
@@ -5839,7 +6165,7 @@ const ABSOLUTE_PATH_RE = /^([A-Za-z]:[\\/]|\/)/;
|
|
|
5839
6165
|
export const exportVideo = {
|
|
5840
6166
|
id: 'slates_export_video',
|
|
5841
6167
|
billable: false,
|
|
5842
|
-
description: "Render the project's timeline to an MP4 file on disk through the desktop app's timeline engine, the renderer its monitor shows, so the file matches the preview (H.264 + AAC, every video lane composited with its transitions, fades and keyframes, gaps rendered as black; the Slates window must be open). No dialogs — pass an absolute outputPath ending in .mp4. Fails if the file exists unless overwrite=true. Blocks until encoding finishes (can take minutes for long timelines) and returns the real file size and probed duration. After success, consider slates_reveal_file to show the file to the user. Requires at least one video clip on the timeline. Pass exactly one of projectId (the project's default timeline) or timelineId (a named cut).",
|
|
6168
|
+
description: "Render the project's timeline to an MP4 file on disk through the desktop app's timeline engine, the renderer its monitor shows, so the file matches the preview (H.264 + AAC, every video lane composited with its transitions, fades and keyframes, gaps rendered as black; the Slates window must be open). No dialogs — pass an absolute outputPath ending in .mp4. Fails if the file exists unless overwrite=true. Blocks until encoding finishes (can take minutes for long timelines) and returns the real file size and probed duration. After success, consider slates_reveal_file to show the file to the user. Requires at least one video clip on the timeline. The sound is AAC at the timeline's Sound bitrate (slates_update_timeline_settings audioBitrate; default 320 kb/s) unless audioBitrate names one for this file. Pass exactly one of projectId (the project's default timeline) or timelineId (a named cut).",
|
|
5843
6169
|
input: z
|
|
5844
6170
|
.object({
|
|
5845
6171
|
projectId: z.string().uuid().optional(),
|
|
@@ -5851,6 +6177,7 @@ export const exportVideo = {
|
|
|
5851
6177
|
.describe('Absolute path for the rendered file, ending in .mp4 (e.g. C:\\Users\\you\\Videos\\ad.mp4 or /Users/you/ad.mp4). slates_get_project_directory gives a sensible default folder.'),
|
|
5852
6178
|
overwrite: z.boolean().optional(),
|
|
5853
6179
|
aspect: deliveryAspectInput.optional().describe('Optional delivery aspect from slates_get_variant_grid; requires ad-variant-export. Omission keeps existing export behavior.'),
|
|
6180
|
+
audioBitrate: audioBitrateInput.optional().describe(`This file's AAC sound in kb/s (${AUDIO_BITRATES.join(', ')}); omit for the timeline's Sound bitrate.`),
|
|
5854
6181
|
})
|
|
5855
6182
|
.refine((d) => !!d.projectId !== !!d.timelineId, {
|
|
5856
6183
|
message: 'Pass exactly one of projectId or timelineId',
|
|
@@ -5860,12 +6187,15 @@ export const exportVideo = {
|
|
|
5860
6187
|
await desktop.requireCapability('export', 'video export');
|
|
5861
6188
|
if (input.aspect !== undefined)
|
|
5862
6189
|
await desktop.requireCapability('ad-variant-export', 'single video delivery export');
|
|
6190
|
+
if (input.audioBitrate !== undefined)
|
|
6191
|
+
await requireSoundPrecision(desktop);
|
|
5863
6192
|
const r = await desktop.post('/agent/timeline/export-video', {
|
|
5864
6193
|
projectId: input.projectId,
|
|
5865
6194
|
timelineId: input.timelineId,
|
|
5866
6195
|
outputPath: input.outputPath,
|
|
5867
6196
|
overwrite: input.overwrite,
|
|
5868
6197
|
aspect: input.aspect,
|
|
6198
|
+
audioBitrate: input.audioBitrate,
|
|
5869
6199
|
});
|
|
5870
6200
|
const mb = r.fileSizeBytes != null ? (r.fileSizeBytes / (1024 * 1024)).toFixed(1) : '?';
|
|
5871
6201
|
return ok(r, `Exported ${r.durationSec ?? '?'}s MP4 (${mb} MB) to ${r.outputPath ?? input.outputPath}.`);
|
|
@@ -6174,7 +6504,7 @@ export const createLibraryItem = {
|
|
|
6174
6504
|
};
|
|
6175
6505
|
export const updateLibraryItem = {
|
|
6176
6506
|
id: 'slates_update_library_item',
|
|
6177
|
-
description: "Update a Library item: rename it, move it to another category (categoryId), bind its picture (imageAssetId) or its voice (voiceAssetId, an audio asset; a thing in a location category composes as an environment and carries none). null clears an asset; the asset itself stays. Moving between a 'thing' and a 'look' category flips the sigil (@ ↔ #), and moving a thing into or out of a 'location'-template category changes what it composes as. A rename changes its handle. In every case each saved Shot that mentions the item is rewritten to match (the mention in its prompt, and its mention id), and the result's `move` reports `shotsMentioning`, `shotsRetagged` and the old and new `mention`: tell the user what changed. Pass retagShots:false to leave Shots alone; they then show the item as missing until it is mentioned again. Moving it back, or renaming it back, undoes the rewrite.",
|
|
6507
|
+
description: "Update a Library item: rename it, move it to another category (categoryId), bind its picture (imageAssetId) or its voice (voiceAssetId, an audio asset; a thing in a location category composes as an environment and carries none). null clears an asset; the asset itself stays. Moving between a 'thing' and a 'look' category flips the sigil (@ ↔ #), and moving a thing into or out of a 'location'-template category changes what it composes as. A rename changes its handle. In every case each saved Shot that mentions the item is rewritten to match (the mention in its prompt, and its mention id), and the result's `move` reports `shotsMentioning`, `shotsRetagged` and the old and new `mention`: tell the user what changed. Pass retagShots:false to leave Shots alone; they then show the item as missing until it is mentioned again. Moving it back, or renaming it back, undoes the rewrite. extraAssetIds sets the item's extra pictures (the whole ordered list; [] clears; a mention still sends only its picture) and palette its colours (up to six; [] clears; shown and read, never sent to a model).",
|
|
6178
6508
|
input: z.object({
|
|
6179
6509
|
projectId: z.string().uuid().describe('The project the item is in — asset codes resolve against it.'),
|
|
6180
6510
|
itemId: z.string().uuid(),
|
|
@@ -6185,10 +6515,15 @@ export const updateLibraryItem = {
|
|
|
6185
6515
|
retagShots: z.boolean().optional().describe('Only with categoryId or name. Default true: Shots that mention the item follow a move or a rename that changes how it is mentioned.'),
|
|
6186
6516
|
imageAssetId: z.string().min(1).nullable().optional().describe('UUID or badge code; null clears.'),
|
|
6187
6517
|
voiceAssetId: z.string().min(1).nullable().optional().describe('An AUDIO asset, UUID or badge code; null detaches.'),
|
|
6518
|
+
extraAssetIds: z.array(z.string().min(1)).max(24).optional().describe('More pictures of it, in order: UUIDs or badge codes of pictures in this project. [] clears.'),
|
|
6519
|
+
palette: z.array(z.string().min(1)).max(6).optional().describe('Its colours: #rrggbb, #rgb or rgb(r, g, b). [] clears.'),
|
|
6188
6520
|
}),
|
|
6189
6521
|
async run(input, ctx) {
|
|
6190
6522
|
await ctx.desktop().requireCapability('library', 'the Library');
|
|
6191
|
-
|
|
6523
|
+
if (input.extraAssetIds !== undefined || input.palette !== undefined) {
|
|
6524
|
+
await ctx.desktop().requireCapability('product-intake', "a Library item's extra pictures and colours");
|
|
6525
|
+
}
|
|
6526
|
+
const refs = [input.imageAssetId, input.voiceAssetId, ...(input.extraAssetIds ?? [])].filter((r) => typeof r === 'string');
|
|
6192
6527
|
const resolved = await resolveAssetRefs(ctx, input.projectId, refs);
|
|
6193
6528
|
const asset = (ref) => typeof ref === 'string' ? resolved.get(ref).id : ref;
|
|
6194
6529
|
return ok(await ctx.desktop().post('/agent/library/items/update', {
|
|
@@ -6203,6 +6538,8 @@ export const updateLibraryItem = {
|
|
|
6203
6538
|
// explicit null is the clear.
|
|
6204
6539
|
...(input.imageAssetId !== undefined ? { imageAssetId: asset(input.imageAssetId) } : {}),
|
|
6205
6540
|
...(input.voiceAssetId !== undefined ? { voiceAssetId: asset(input.voiceAssetId) } : {}),
|
|
6541
|
+
...(input.extraAssetIds !== undefined ? { extraAssetIds: input.extraAssetIds.map((ref) => resolved.get(ref).id) } : {}),
|
|
6542
|
+
...(input.palette !== undefined ? { palette: input.palette } : {}),
|
|
6206
6543
|
},
|
|
6207
6544
|
}));
|
|
6208
6545
|
},
|
|
@@ -6317,6 +6654,142 @@ export const importTemplate = {
|
|
|
6317
6654
|
return ok(await ctx.desktop().post('/agent/templates/import', { ...input, swaps }));
|
|
6318
6655
|
},
|
|
6319
6656
|
};
|
|
6657
|
+
// ── Start from a reference ad ───────────────────────────────────────────
|
|
6658
|
+
// A finished ad becomes an ordinary board: one Shot per cut, each postered with
|
|
6659
|
+
// its keyframe, the heard words on the Script page. Local and free, and the
|
|
6660
|
+
// board generates nothing. Read and write are two tools so a host can
|
|
6661
|
+
// auto-approve the read (mcp-server-design § Annotations).
|
|
6662
|
+
export const getReferenceBreakdown = {
|
|
6663
|
+
id: 'slates_get_reference_breakdown',
|
|
6664
|
+
description: "Read a reference ad's cuts and words without changing anything: each cut's start, end and seconds, the words heard in it, and the reference's size, frame rate and form (a still, no voice, soft cuts). When slates_break_down_reference already saved this asset's frames, they come back too (framesSaved: true, each cut's keyframeCode and compositeCode, the first and last frame side by side); otherwise there are no pictures and the words are the stored transcript only. Free; writes nothing. To start from a reference, read it here, then break it down.",
|
|
6665
|
+
input: z
|
|
6666
|
+
.object({
|
|
6667
|
+
projectId: z.string().uuid(),
|
|
6668
|
+
assetId: z.string().min(1).describe('The reference video or picture in the project: its code (VID-V3) or id.'),
|
|
6669
|
+
})
|
|
6670
|
+
.strict(),
|
|
6671
|
+
async run(input, ctx) {
|
|
6672
|
+
await ctx.desktop().requireCapability('reference-breakdown', 'breaking a reference ad into shots');
|
|
6673
|
+
const assetId = (await resolveAssetRefs(ctx, input.projectId, [input.assetId])).get(input.assetId).id;
|
|
6674
|
+
return ok(await ctx.desktop().get('/agent/reference/breakdown', { projectId: input.projectId, assetId }));
|
|
6675
|
+
},
|
|
6676
|
+
};
|
|
6677
|
+
export const breakDownReference = {
|
|
6678
|
+
id: 'slates_break_down_reference',
|
|
6679
|
+
billable: false,
|
|
6680
|
+
description: "Start from a reference ad: break a finished video into a new board with one Shot per cut, as the clip's Break down into shots command does, so the user can remake it with their own product. Each Shot is postered with its cut's keyframe (a poster only, never a reference or first frame), named by its seconds in the reference, and holds the words heard in that cut on the Script page. Nothing is generated and nothing spends: the result carries the board's quote, the Shot codes and each timing gap in words (a cut shorter than the model's shortest length). Local and free; the first transcription can take minutes. Name the reference by assetId, filePath or url, one of them: a url is fetched into the project's Media first, and works for a Meta Ad Library ad link (facebook.com/ads/library/?id=...) or a direct link to a video file; TikTok Creative Center, YouTube and TikTok post links are refused with the reason (download the video, then pass filePath). The result's source names the link, its kind and the video file it fetched. build false saves each cut's keyframe and first-and-last composite to a frames folder and returns the cuts, without a board: look at them with slates_get_asset_image, then call again with build (the frames are reused) and `cuts` (each cut's description, written for the user's product, becomes its Shot's prompt; onScreenText becomes a direction line), `sections` (headings) and `roles` (who or what recurs; itemId points the role at the user's own Library item). A still becomes one Shot. Generate only after the user approves the quote (slates_generate_from_shots). To be able to stop a run, name it with jobId; cancel true with that jobId (and projectId, nothing else) stops it at its next step, removing its frames and any video it fetched, until its board build starts (too late then: the board is kept).",
|
|
6681
|
+
input: z
|
|
6682
|
+
.object({
|
|
6683
|
+
projectId: z.string().uuid(),
|
|
6684
|
+
assetId: z.string().min(1).optional().describe('A video or picture already in the project: its code (VID-V3) or id. Give this, filePath or url.'),
|
|
6685
|
+
filePath: z.string().min(1).optional().describe('An absolute path to a video or picture on this computer; it is imported first.'),
|
|
6686
|
+
url: z
|
|
6687
|
+
.string()
|
|
6688
|
+
.url()
|
|
6689
|
+
.optional()
|
|
6690
|
+
.describe('A link to the reference: a Meta Ad Library ad or a direct video file link, fetched and imported first. Creative Center and post links are refused with the reason.'),
|
|
6691
|
+
build: z.boolean().optional().describe('false: save the frames and return the cuts, with no board. Default true.'),
|
|
6692
|
+
transcribe: z.boolean().optional().describe('Hear the words when no transcript is stored. Default true.'),
|
|
6693
|
+
name: z.string().min(1).max(80).optional().describe("The board's name. Defaults to the reference's."),
|
|
6694
|
+
model: z.string().min(1).optional().describe("A video model id for every Shot; defaults to the app's default video model."),
|
|
6695
|
+
cuts: z
|
|
6696
|
+
.array(z
|
|
6697
|
+
.object({
|
|
6698
|
+
index: z.number().int().min(0).describe("The cut's index from the breakdown's segments."),
|
|
6699
|
+
description: z.string().max(4000).optional().describe("What this Shot shows, for the user's product: its prompt."),
|
|
6700
|
+
onScreenText: z.string().max(500).optional().describe('Words on screen in this cut, kept as a direction line, never sent as action.'),
|
|
6701
|
+
})
|
|
6702
|
+
.strict())
|
|
6703
|
+
.optional(),
|
|
6704
|
+
sections: z
|
|
6705
|
+
.array(z.object({ label: z.string().min(1).max(120), fromCut: z.number().int().min(0) }).strict())
|
|
6706
|
+
.optional()
|
|
6707
|
+
.describe('Headings on the Script page, each before the cut it starts at (hook, problem, offer...).'),
|
|
6708
|
+
roles: z
|
|
6709
|
+
.array(z
|
|
6710
|
+
.object({
|
|
6711
|
+
name: z.string().min(1).max(80),
|
|
6712
|
+
kind: z.enum(['person', 'location', 'product']).optional(),
|
|
6713
|
+
itemId: z.string().min(1).optional().describe('A Library item of this project (slates_list_library) to use for the role.'),
|
|
6714
|
+
cuts: z.array(z.number().int().min(0)).describe('The cut indices the role appears in.'),
|
|
6715
|
+
})
|
|
6716
|
+
.strict())
|
|
6717
|
+
.optional()
|
|
6718
|
+
.describe('Who or what recurs. Without itemId a role becomes a new Library item to fill in.'),
|
|
6719
|
+
jobId: z.string().min(1).max(120).optional().describe('A name for this run, so a later call with cancel can stop it.'),
|
|
6720
|
+
cancel: z.boolean().optional().describe('true: stop the run named by jobId instead of starting one.'),
|
|
6721
|
+
})
|
|
6722
|
+
.strict(),
|
|
6723
|
+
async run(input, ctx) {
|
|
6724
|
+
await ctx.desktop().requireCapability('reference-breakdown', 'breaking a reference ad into shots');
|
|
6725
|
+
if (input.cancel) {
|
|
6726
|
+
if (!input.jobId)
|
|
6727
|
+
throw new Error('cancel stops a run by its jobId: give the jobId the breakdown was started with.');
|
|
6728
|
+
await ctx.desktop().requireCapability('reference-cancel', 'stopping a reference breakdown');
|
|
6729
|
+
const c = await ctx.desktop().post('/agent/reference/cancel', { jobId: input.jobId });
|
|
6730
|
+
return ok(c, c.cancelled ? `Stopping breakdown ${c.jobId}: it ends at its next step, its frames and any fetched video removed.` : `Nothing to stop: no breakdown named ${c.jobId} is running, or it has reached its board build, which finishes and keeps the board.`);
|
|
6731
|
+
}
|
|
6732
|
+
if (input.jobId)
|
|
6733
|
+
await ctx.desktop().requireCapability('reference-cancel', 'naming a reference breakdown so it can be stopped');
|
|
6734
|
+
if ([input.assetId, input.filePath, input.url].filter(Boolean).length !== 1) {
|
|
6735
|
+
throw new Error('Give exactly one of assetId (a video or picture in the project), filePath or url.');
|
|
6736
|
+
}
|
|
6737
|
+
const assetId = input.assetId ? (await resolveAssetRefs(ctx, input.projectId, [input.assetId])).get(input.assetId).id : input.assetId;
|
|
6738
|
+
const r = await ctx.desktop().post('/agent/reference/breakdown', { ...input, assetId, cancel: undefined });
|
|
6739
|
+
const cuts = r.breakdown.segments.length;
|
|
6740
|
+
const fetched = r.source ? `Fetched the ${r.source.kind === 'meta' ? 'Meta Ad Library ad' : 'video link'} into Media as ${r.breakdown.sourceCode ?? 'a video'}. ` : '';
|
|
6741
|
+
const head = r.board
|
|
6742
|
+
? `Board ${r.board.storyboardId} built: ${r.board.shotCodes.length} Shot${r.board.shotCodes.length === 1 ? '' : 's'} (${r.board.shotCodes.join(', ')}), nothing generated.${r.board.timing.length ? ` Timing: ${r.board.timing.join(' ')}` : ''}`
|
|
6743
|
+
: `${cuts} cut${cuts === 1 ? '' : 's'} found in ${r.breakdown.sourceCode ?? 'the reference'}; frames saved, no board yet.`;
|
|
6744
|
+
return ok(r, `${fetched}${head} ${JSON.stringify(r)}`);
|
|
6745
|
+
},
|
|
6746
|
+
};
|
|
6747
|
+
// ── Product intake ──────────────────────────────────────────────────────
|
|
6748
|
+
// A product page becomes Library items a remade ad's roles can use: the product
|
|
6749
|
+
// (a thing, with its pictures) and its brand (a look, with its logo and colours).
|
|
6750
|
+
// Read and write are two tools so a host can auto-approve the read.
|
|
6751
|
+
export const getProductPage = {
|
|
6752
|
+
id: 'slates_get_product_page',
|
|
6753
|
+
description: "Read a product page without changing anything: the product's name, description, brand, slogan, price, pictures, logo candidates, the brand's declared colours and the page's bullet points, each with where it came from (json-ld product data, a Shopify store's product data, open-graph sharing tags, other meta tags, or the page's own pictures by size), plus notes on what the page lacks. The desktop fetches the page itself (public addresses only, no browser, nothing signed in). A page that builds itself with JavaScript, an ad library link, a post, or a link to a picture or video file is refused with the reason. Free; writes nothing. Read here first when the user names a product page, then make the product with slates_import_product.",
|
|
6754
|
+
input: z
|
|
6755
|
+
.object({
|
|
6756
|
+
url: z.string().url().describe("The product page, such as a shop's /products/... page."),
|
|
6757
|
+
})
|
|
6758
|
+
.strict(),
|
|
6759
|
+
async run(input, ctx) {
|
|
6760
|
+
await ctx.desktop().requireCapability('product-intake', 'reading product pages');
|
|
6761
|
+
return ok(await ctx.desktop().get('/agent/library/intake', { url: input.url }));
|
|
6762
|
+
},
|
|
6763
|
+
};
|
|
6764
|
+
export const importProduct = {
|
|
6765
|
+
id: 'slates_import_product',
|
|
6766
|
+
billable: false,
|
|
6767
|
+
description: "Add a product to the Library from its page, as the app's Add as product does: the product becomes a thing (in Products, or the things categoryId given) with the page's first picture as its picture, the next ones as its extra pictures and the page's bullet points, price and link as its notes; its brand becomes a look with the brand's logo as its picture and the page's and logo's colours as its palette. A look of the same name already in the Library is filled in where empty, never overwritten. Pictures land in a Media folder named after the product. Give url, filePaths (absolute paths to pictures on this computer, the product's first), or both. html is the page's HTML when you already have it (a page that builds itself with JavaScript, read in your own browser); url still names the page and its pictures are still fetched. Free; nothing is generated. The result gives the product and the brand with their mention (@name, #name) for prompts and for slates_break_down_reference roles (itemId), each picture and where it came from, each picture left out with its reason, and notes on what the page lacked.",
|
|
6768
|
+
input: z
|
|
6769
|
+
.object({
|
|
6770
|
+
projectId: z.string().uuid(),
|
|
6771
|
+
url: z.string().url().optional().describe('The product page.'),
|
|
6772
|
+
html: z.string().min(1).optional().describe("The page's HTML, read instead of fetching the page. Needs url."),
|
|
6773
|
+
filePaths: z.array(z.string().min(1)).optional().describe('Absolute paths to pictures of the product on this computer, first in the order given.'),
|
|
6774
|
+
name: z.string().min(1).max(120).optional().describe("The product's name. Defaults to the page's, else the first file's."),
|
|
6775
|
+
categoryId: z.string().uuid().optional().describe('A things category (slates_list_library) to file the product in. Defaults to Products.'),
|
|
6776
|
+
brand: z.boolean().optional().describe('false: make no look for the brand. Default true.'),
|
|
6777
|
+
maxPictures: z.number().int().min(1).optional().describe('How many pictures to fetch from the page. Default 6; the desktop takes at most 12.'),
|
|
6778
|
+
})
|
|
6779
|
+
.strict(),
|
|
6780
|
+
async run(input, ctx) {
|
|
6781
|
+
await ctx.desktop().requireCapability('product-intake', 'adding products from their pages');
|
|
6782
|
+
if (!input.url && !input.filePaths?.length)
|
|
6783
|
+
throw new Error('Give url (the product page), filePaths (pictures on this computer), or both.');
|
|
6784
|
+
if (input.html && !input.url)
|
|
6785
|
+
throw new Error('html needs url: the address the page came from.');
|
|
6786
|
+
const r = await ctx.desktop().post('/agent/library/intake', input);
|
|
6787
|
+
const brand = r.brand ? ` Its brand ${r.brand.mention} ${r.brandReused ? 'was already in the Library and was filled in' : 'is a new look'}.` : '';
|
|
6788
|
+
const left = r.skipped.length ? ` ${r.skipped.length} picture${r.skipped.length === 1 ? '' : 's'} left out (see skipped).` : '';
|
|
6789
|
+
const head = `Added ${r.product.mention} with ${r.pictures.length} picture${r.pictures.length === 1 ? '' : 's'}.${brand}${left}${r.notes.length ? ` ${r.notes.join(' ')}` : ''}`;
|
|
6790
|
+
return ok(r, `${head} ${JSON.stringify(r)}`);
|
|
6791
|
+
},
|
|
6792
|
+
};
|
|
6320
6793
|
export const updateStoryboard = {
|
|
6321
6794
|
id: 'slates_update_storyboard',
|
|
6322
6795
|
description: 'Update a board\'s name and/or description.',
|
|
@@ -7686,6 +8159,9 @@ export function resolveGuideTopic(topic) {
|
|
|
7686
8159
|
const t = topic.trim().toLowerCase();
|
|
7687
8160
|
if (Object.hasOwn(SKILLS, t))
|
|
7688
8161
|
return t;
|
|
8162
|
+
// The brain's front door: the Director card and the router (prompts/brain.ts).
|
|
8163
|
+
if (ROUTER_ALIASES.includes(t))
|
|
8164
|
+
return BRAIN_ROUTER;
|
|
7689
8165
|
if (t === 'slates-character-turnaround' || t === 'character-turnaround') {
|
|
7690
8166
|
return 'slates-character-identity';
|
|
7691
8167
|
}
|
|
@@ -7707,8 +8183,13 @@ export function resolveGuideTopic(topic) {
|
|
|
7707
8183
|
// Timeline craft: placing transitions, and the cutting pass (trim, roll, slip, J- and L-cuts).
|
|
7708
8184
|
if (t === 'transition' || t === 'transitions' || t === 'dissolve' || t === 'crossfade' || t === 'wipe')
|
|
7709
8185
|
return 'slates-transitions';
|
|
8186
|
+
// Starting from a finished ad: the breakdown and the remake.
|
|
8187
|
+
if (t === 'remake' || t === 'reference ad' || t === 'reference-ad' || t === 'breakdown' || t === 'break down')
|
|
8188
|
+
return 'slates-storyboard-from-script';
|
|
7710
8189
|
if (t === 'cut' || t === 'cuts' || t === 'cutting' || t === 'editing' || t === 'pacing' || t === 'trim' || t === 'j-cut' || t === 'l-cut' || t === 'split-edit' || t === 'split edit')
|
|
7711
8190
|
return 'slates-cuts';
|
|
8191
|
+
if (['variants', 'variant', 'ad-variants', 'ad variants', 'hook variants', 'variant grid', 'variant-grid'].includes(t))
|
|
8192
|
+
return 'slates-ad-variants';
|
|
7712
8193
|
if (['captions', 'caption', 'subtitles', 'subtitle', 'transcribe', 'transcript', 'transcription'].includes(t))
|
|
7713
8194
|
return 'slates-captions';
|
|
7714
8195
|
// `motion-graphics` is HyperFrames' own guide, matched by name before these aliases.
|
|
@@ -7853,6 +8334,60 @@ export function resolveGuideTopic(topic) {
|
|
|
7853
8334
|
}
|
|
7854
8335
|
return null;
|
|
7855
8336
|
}
|
|
8337
|
+
/** Edits between two names: insert, delete, substitute or swap two neighbours (optimal string alignment). */
|
|
8338
|
+
function editDistance(a, b) {
|
|
8339
|
+
const d = Array.from({ length: a.length + 1 }, (_, i) => [i, ...Array(b.length).fill(0)]);
|
|
8340
|
+
for (let j = 1; j <= b.length; j++)
|
|
8341
|
+
d[0][j] = j;
|
|
8342
|
+
for (let i = 1; i <= a.length; i++) {
|
|
8343
|
+
for (let j = 1; j <= b.length; j++) {
|
|
8344
|
+
d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
8345
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1])
|
|
8346
|
+
d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
|
|
8347
|
+
}
|
|
8348
|
+
}
|
|
8349
|
+
return d[a.length][b.length];
|
|
8350
|
+
}
|
|
8351
|
+
/**
|
|
8352
|
+
* The one guide a near-miss name means: the name without its `slates-` prefix, or a typo of one name
|
|
8353
|
+
* ("slaes-direct-response-ad"). Two names equally close come back as `tied`, for the caller to name rather
|
|
8354
|
+
* than pick. Only the guide op uses it: a model id resolves exactly or not at all (resolveGuideTopic), since
|
|
8355
|
+
* a near guess there would gate a generation on another model's guide.
|
|
8356
|
+
*/
|
|
8357
|
+
export function nearestGuideName(topic, names) {
|
|
8358
|
+
const t = topic.trim().toLowerCase().replace(/[\s_]+/g, '-');
|
|
8359
|
+
if (!t || t.length > 128)
|
|
8360
|
+
return null;
|
|
8361
|
+
if (names.includes(t))
|
|
8362
|
+
return { name: t };
|
|
8363
|
+
if (names.includes(`slates-${t}`))
|
|
8364
|
+
return { name: `slates-${t}` };
|
|
8365
|
+
// Two edits in a long name, one in a short one, none under four letters: past that it is another guide.
|
|
8366
|
+
const core = t.replace(/^slates-/, '').length;
|
|
8367
|
+
const allowed = core >= 8 ? 2 : core >= 4 ? 1 : 0;
|
|
8368
|
+
// A version is not a typo: seedance-2-0 is not seedance-2-5, and kling-v2 is not kling-v3.
|
|
8369
|
+
const digits = (s) => (s.match(/\d+/g) ?? []).join('.');
|
|
8370
|
+
const version = digits(t);
|
|
8371
|
+
let best = allowed + 1;
|
|
8372
|
+
let closest = [];
|
|
8373
|
+
for (const name of new Set(names)) {
|
|
8374
|
+
if (digits(name) !== version)
|
|
8375
|
+
continue;
|
|
8376
|
+
// A length gap past the budget, against the name as typed or prefixed, is past it in edits too.
|
|
8377
|
+
if (Math.abs(name.length - t.length) > allowed && Math.abs(name.length - t.length - 7) > allowed)
|
|
8378
|
+
continue;
|
|
8379
|
+
const d = Math.min(editDistance(t, name), editDistance(`slates-${t}`, name));
|
|
8380
|
+
if (d < best) {
|
|
8381
|
+
best = d;
|
|
8382
|
+
closest = [name];
|
|
8383
|
+
}
|
|
8384
|
+
else if (d === best && d <= allowed)
|
|
8385
|
+
closest.push(name);
|
|
8386
|
+
}
|
|
8387
|
+
if (!closest.length)
|
|
8388
|
+
return null;
|
|
8389
|
+
return closest.length === 1 ? { name: closest[0] } : { tied: closest.sort() };
|
|
8390
|
+
}
|
|
7856
8391
|
// Discovery is the first call of most briefs: a slow or unentitled member check
|
|
7857
8392
|
// must not cost every call a round trip, or hang free craft behind a 30s read.
|
|
7858
8393
|
const MEMBER_CATALOG_TTL_MS = 60_000;
|
|
@@ -7910,6 +8445,10 @@ export const getPromptingGuide = {
|
|
|
7910
8445
|
if (topic === WORKING_METHOD_TOPIC) {
|
|
7911
8446
|
// Imported here: agent-doctrine imports this module at load.
|
|
7912
8447
|
const { buildAgentDoctrine } = await import('../prompts/agent-doctrine.js');
|
|
8448
|
+
// Its per-model guide line reads the served brain, so the brain is checked first: a signed-in user whose brain
|
|
8449
|
+
// is not cached yet is otherwise told to connect.
|
|
8450
|
+
if (ctx?.cloud)
|
|
8451
|
+
await refreshServedBrain(ctx.cloud);
|
|
7913
8452
|
const content = buildAgentDoctrine({ surface: 'mcp' });
|
|
7914
8453
|
return { text: content, data: { topic: WORKING_METHOD_TOPIC, bytes: Buffer.byteLength(content, 'utf8'), guide: content } };
|
|
7915
8454
|
}
|
|
@@ -7917,9 +8456,31 @@ export const getPromptingGuide = {
|
|
|
7917
8456
|
const content = input.query || input.depth === 'full' ? appManualSections(input.query) : appManualIndex();
|
|
7918
8457
|
return { text: content, data: { topic: 'app-manual', bytes: Buffer.byteLength(content, 'utf8'), guide: content } };
|
|
7919
8458
|
}
|
|
8459
|
+
if (topic === MY_BRAIN_TOPIC) {
|
|
8460
|
+
// What an agent reads of the user's own brain before the router, on request: the router's answer carries it
|
|
8461
|
+
// too, and so does the router the MCP server sends a connection that has not opened it.
|
|
8462
|
+
const content = myBrainPreload() || `The user's own brain (My brain) is empty: no files in ${myBrainDir()}. Each file there is a markdown guide in the shared skills' shape (frontmatter, then an operative summary); a file named like a shared guide adds their rules to it, a new name adds a guide, and profile.md is read first.`;
|
|
8463
|
+
return { text: content, data: { topic: MY_BRAIN_TOPIC, bytes: Buffer.byteLength(content, 'utf8'), guide: content } };
|
|
8464
|
+
}
|
|
7920
8465
|
const hyperframes = await loadHyperframes();
|
|
8466
|
+
// The playbooks, rules and model guides come from the account's tier (skills/served.ts): checked against the
|
|
8467
|
+
// server at most every ten minutes, the cache when it cannot be reached.
|
|
8468
|
+
if (ctx?.cloud)
|
|
8469
|
+
await refreshServedBrain(ctx.cloud);
|
|
8470
|
+
const served = servedBrain();
|
|
8471
|
+
// A playbook past the account's tier: the job still runs, on the general rules, and the user hears once where
|
|
8472
|
+
// the playbook lives (the server's own words).
|
|
8473
|
+
const locked = topic ? served.locked.find(entry => entry.name === topic || entry.name === `slates-${topic}`) : undefined;
|
|
8474
|
+
if (locked) {
|
|
8475
|
+
const guide = locked.notice ?? `${locked.name} is not open to this account. Run the job on the general rules.`;
|
|
8476
|
+
// The guide gate makes an agent read what this account holds; a guide it cannot open never blocks a generation.
|
|
8477
|
+
ctx?.guidesRead?.add(locked.name);
|
|
8478
|
+
return { text: guide, data: { topic: locked.name, tier: locked.tier, locked: true, bytes: Buffer.byteLength(guide, 'utf8'), guide } };
|
|
8479
|
+
}
|
|
8480
|
+
// The shared brain with the user's My brain laid over it; theirs wins on a conflict (skills/my-brain.ts).
|
|
8481
|
+
const brain = brainSkills();
|
|
7921
8482
|
// A motion skill or file by its exact name wins over an alias (`motion-audio` is not `audio`).
|
|
7922
|
-
const hf = topic && !Object.hasOwn(
|
|
8483
|
+
const hf = topic && !Object.hasOwn(brain.skills, topic) ? findHyperframesGuide(hyperframes, topic) : null;
|
|
7923
8484
|
if (hf) {
|
|
7924
8485
|
const depth = input.depth ?? 'card';
|
|
7925
8486
|
const body = depth === 'card' && !input.query?.trim() ? hyperframesCard(hf.content) : retrieveGuide(hf.key, hf.content, depth, input.query);
|
|
@@ -7927,12 +8488,37 @@ export const getPromptingGuide = {
|
|
|
7927
8488
|
const guide = `${hyperframesGuideHeader(hf.key)}${body}${others.length ? `\n\nIts other files (request each as a topic): ${others.join(', ')}` : ''}`;
|
|
7928
8489
|
return { text: guide, data: { topic: hf.key, tier: 'free', source: 'motion', depth, bytes: Buffer.byteLength(guide, 'utf8'), guide } };
|
|
7929
8490
|
}
|
|
7930
|
-
|
|
8491
|
+
// The user's file by its exact name wins over an alias (their `flux-portraits` is theirs, not the FLUX guide);
|
|
8492
|
+
// the router's names are reserved in the loader, so none of them reaches here as a local file. A name missing
|
|
8493
|
+
// its `slates-` prefix is that guide, resolved here so it never waits on the member check.
|
|
8494
|
+
// With no brain on this machine, an exact `slates-*` name (the one a guide-gate refusal gives) is that guide, not
|
|
8495
|
+
// an unknown topic: it answers with how to get the brain instead of the catalog, and so never loops.
|
|
8496
|
+
const unheld = topic && served.source === 'none' && /^slates-[a-z0-9-]+$/.test(topic) ? topic : null;
|
|
8497
|
+
const resolved = topic ? (Object.hasOwn(brain.skills, topic) ? topic : resolveGuideTopic(topic) ?? (Object.hasOwn(brain.skills, `slates-${topic}`) ? `slates-${topic}` : unheld)) : null;
|
|
8498
|
+
if (resolved && !Object.hasOwn(brain.skills, resolved)) {
|
|
8499
|
+
// An alias named a guide this process does not hold: a locked one, or no brain at all (not connected, and
|
|
8500
|
+
// nothing cached yet).
|
|
8501
|
+
const lockedAlias = served.locked.find(entry => entry.name === resolved);
|
|
8502
|
+
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.`;
|
|
8503
|
+
// A locked guide's notice carries its craft card (slates-api lib/brain.ts lockedNotice), so it counts as read; a
|
|
8504
|
+
// guide that never arrived does not, so no generation runs without the card (Eric, 2026-10-23: a hard blocker).
|
|
8505
|
+
if (lockedAlias)
|
|
8506
|
+
ctx?.guidesRead?.add(resolved);
|
|
8507
|
+
return { text: guide, data: { topic: resolved, ...(lockedAlias ? { tier: lockedAlias.tier, locked: true } : { unavailable: true }), bytes: Buffer.byteLength(guide, 'utf8'), guide } };
|
|
8508
|
+
}
|
|
7931
8509
|
if (resolved) {
|
|
7932
8510
|
const depth = input.depth ?? 'card';
|
|
7933
|
-
const
|
|
8511
|
+
const mine = brain.mine.has(resolved);
|
|
8512
|
+
if (mine)
|
|
8513
|
+
noteUsed(resolved);
|
|
8514
|
+
// A file laid over a shared guide says so itself (prompts/brain.ts, overlayGuide); a new name needs the line.
|
|
8515
|
+
const own = mine && !Object.hasOwn(brainFiles(), resolved) ? "From the user's own brain (My brain).\n\n" : '';
|
|
8516
|
+
// The router's answer carries the user's brain in front, as Director's prompt does: the MCP server sends the
|
|
8517
|
+
// router with the preload only to a connection that has not opened it, so this answer is the agent's one copy.
|
|
8518
|
+
const preload = resolved === BRAIN_ROUTER ? myBrainPreload() : '';
|
|
8519
|
+
const guide = `${preload ? `${preload}\n\n` : ''}${own}${retrieveGuide(resolved, brain.skills[resolved], depth, input.query)}`;
|
|
7934
8520
|
ctx?.guidesRead?.add(resolved);
|
|
7935
|
-
return { text: guide, data: { topic: resolved, tier: 'free', depth, bytes: Buffer.byteLength(guide, 'utf8'), guide } };
|
|
8521
|
+
return { text: guide, data: { topic: resolved, tier: 'free', ...(mine ? { source: 'my-brain' } : {}), depth: servedDepth(resolved, depth, input.query), bytes: Buffer.byteLength(guide, 'utf8'), guide } };
|
|
7936
8522
|
}
|
|
7937
8523
|
const member = await memberGuideCatalog(ctx);
|
|
7938
8524
|
const privateEntry = member.entries.find(entry => entry.name === topic);
|
|
@@ -7953,13 +8539,24 @@ export const getPromptingGuide = {
|
|
|
7953
8539
|
return { text: guide, data: { topic: privateEntry.name, tier: 'paid', depth, bytes: Buffer.byteLength(guide, 'utf8'), guide } };
|
|
7954
8540
|
}
|
|
7955
8541
|
// Slates' guides first, then HyperFrames' (they carry the craft for HTML layers and editing).
|
|
7956
|
-
const
|
|
7957
|
-
|
|
7958
|
-
const
|
|
8542
|
+
const own = guideCatalog(brain.skills).map(entry => (brain.mine.has(entry.name) ? { ...entry, source: 'my-brain' } : entry));
|
|
8543
|
+
// Locked playbooks stay listed, so an agent can tell the user where one lives.
|
|
8544
|
+
const lockedEntries = served.locked.map(entry => ({ name: entry.name, description: `(not open to this account) ${entry.description}`, tier: 'paid' }));
|
|
8545
|
+
const catalog = [...[...own, ...member.entries, ...lockedEntries].sort((a, b) => a.name.localeCompare(b.name)), ...hyperframesCatalog(hyperframes)];
|
|
8546
|
+
// A typo of one guide's name serves that guide; a name as close to two is answered with both, never a guess.
|
|
8547
|
+
const near = topic && topic !== 'catalog' && topic !== 'index' ? nearestGuideName(topic, catalog.map(entry => entry.name)) : null;
|
|
8548
|
+
if (near && 'name' in near) {
|
|
8549
|
+
const served = await getPromptingGuide.run({ ...input, topic: near.name }, ctx);
|
|
8550
|
+
// Said first, so the agent sees the substitution and learns the real name.
|
|
8551
|
+
return { ...served, text: `Served ${near.name} for "${input.topic}", the closest guide name.\n\n${served.text}` };
|
|
8552
|
+
}
|
|
8553
|
+
const tied = near && 'tied' in near ? near.tied : [];
|
|
8554
|
+
const result = discoverGuides(catalog, { ...brain.skills, ...hyperframesSkillBodies(hyperframes) }, input.query ?? (topic && topic !== 'catalog' && topic !== 'index' ? input.topic : undefined), input.limit, input.offset);
|
|
8555
|
+
const label = (entry) => (entry.source === 'motion' ? 'motion' : entry.source === 'my-brain' ? 'yours' : entry.tier);
|
|
7959
8556
|
const guide = result.guides.map(entry => `${entry.name} (${label(entry)}): ${entry.description}${entry.sections.length ? `\n Matching sections: ${entry.sections.join('; ')}` : ''}`).join('\n\n');
|
|
7960
8557
|
const rest = result.rest.length ? `\n\nEvery other guide (keyword hints above only see shared words; choose by the brief):\n${result.rest.map(entry => `- ${entry.name} (${label(entry)}): ${entry.description}`).join('\n')}` : '';
|
|
7961
|
-
const text = `${result.fallback ? 'No keyword match; choose relevant craft from the catalog.\n\n' : ''}${guide}${rest}\n\n${result.total} ${result.query && !result.fallback ? 'keyword matches' : 'guides'}; nextOffset: ${result.nextOffset ?? 'none'}. Member guides: ${member.access}. Retrieve a name with depth card/index or query for a section. Motion guides are the motion engine's own; topic motion/${HYPERFRAMES_MAPPING} maps their CLI and Studio onto Slates. The user does not need to choose guides.`;
|
|
7962
|
-
return { text, data: { ...result, memberAccess: member.access, bytes: Buffer.byteLength(text, 'utf8') } };
|
|
8558
|
+
const text = `${tied.length ? `"${input.topic}" is equally close to ${tied.join(' and ')}; request one of them by name.\n\n` : ''}${result.fallback ? 'No keyword match; choose relevant craft from the catalog.\n\n' : ''}${guide}${rest}\n\n${result.total} ${result.query && !result.fallback ? 'keyword matches' : 'guides'}; nextOffset: ${result.nextOffset ?? 'none'}. Member guides: ${member.access}. Retrieve a name with depth card/index or query for a section. Motion guides are the motion engine's own; topic motion/${HYPERFRAMES_MAPPING} maps their CLI and Studio onto Slates. The user does not need to choose guides.`;
|
|
8559
|
+
return { text, data: { ...result, ...(tied.length ? { tied } : {}), memberAccess: member.access, bytes: Buffer.byteLength(text, 'utf8') } };
|
|
7963
8560
|
},
|
|
7964
8561
|
};
|
|
7965
8562
|
/**
|
|
@@ -8229,9 +8826,14 @@ export const ALL_OPERATIONS = [
|
|
|
8229
8826
|
getExportBatch,
|
|
8230
8827
|
cancelExportBatch,
|
|
8231
8828
|
getVariantGrid,
|
|
8829
|
+
getVariants,
|
|
8830
|
+
editVariantSlots,
|
|
8831
|
+
editVariants,
|
|
8832
|
+
getRecipe,
|
|
8232
8833
|
reframeClip,
|
|
8233
8834
|
getReframeReport,
|
|
8234
8835
|
getTimeline,
|
|
8836
|
+
getTimelineLoudness,
|
|
8235
8837
|
addClipToTimeline,
|
|
8236
8838
|
reorderClips,
|
|
8237
8839
|
removeClip,
|
|
@@ -8283,6 +8885,10 @@ export const ALL_OPERATIONS = [
|
|
|
8283
8885
|
getTemplate,
|
|
8284
8886
|
exportTemplate,
|
|
8285
8887
|
importTemplate,
|
|
8888
|
+
getReferenceBreakdown,
|
|
8889
|
+
breakDownReference,
|
|
8890
|
+
getProductPage,
|
|
8891
|
+
importProduct,
|
|
8286
8892
|
updateStoryboard,
|
|
8287
8893
|
deleteStoryboard,
|
|
8288
8894
|
updateScene,
|