@slatesvideo/shared 0.7.16 → 0.7.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/manual/content.d.ts +1 -1
- package/dist/manual/content.js +1 -1
- package/dist/operations/index.d.ts +29 -12
- package/dist/operations/index.js +294 -109
- package/dist/prompts/model-capabilities.d.ts +39 -6
- package/dist/prompts/model-capabilities.js +120 -43
- package/dist/prompts/model-facts.d.ts +1 -1
- package/dist/prompts/model-facts.js +26 -21
- package/dist/prompts/prompting-tips.d.ts +1 -1
- package/dist/prompts/prompting-tips.js +16 -11
- package/dist/prompts/reference-composer.d.ts +4 -0
- package/dist/prompts/reference-composer.js +14 -1
- package/dist/prompts/shot-spec.d.ts +1 -1
- package/dist/skills/content.js +1 -1
- package/package.json +1 -1
package/dist/operations/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { STYLE_LIBRARY, DEFAULT_STYLE_ID } from '../prompts/style-library.js';
|
|
|
3
3
|
import { discoverGuides, guideCatalog } from '../prompts/guide-discovery.js';
|
|
4
4
|
import { retrieveGuide, servedDepth } from '../prompts/guide-retrieval.js';
|
|
5
5
|
import { BRAIN_ROUTER, MY_BRAIN_TOPIC, ROUTER_ALIASES } from '../prompts/brain.js';
|
|
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
|
+
import { MINIMAX_MAX_REFERENCE, minimaxMaxReferenceTokens, MODEL_CAPABILITIES, RETIRED_MODELS, retiredModelOfKey, checkReferenceShape, GPT_QUALITY_TIERS, DEFAULT_GPT_QUALITY, GPT_BACKGROUNDS } from '../prompts/model-capabilities.js';
|
|
7
7
|
// Operations layer — the ONE place every Slates agent tool is defined.
|
|
8
8
|
// Both the MCP server and the CLI register these as their tool / command
|
|
9
9
|
// surface. Every operation:
|
|
@@ -996,11 +996,16 @@ export const setComposer = {
|
|
|
996
996
|
if (Object.keys(input).filter((k) => k !== 'projectId').length === 0) {
|
|
997
997
|
throw new Error('Name at least one change, e.g. model, prompt, attach or params. To read the box, use slates_get_composer.');
|
|
998
998
|
}
|
|
999
|
-
|
|
999
|
+
// The box takes the model by name, so a seat this desktop lacks is staged as the one it has (`desktopModelId`).
|
|
1000
|
+
// A length given as text ("15", "15s") is the same length: the 10-second check must see it.
|
|
1001
|
+
const asked = input.params?.duration;
|
|
1002
|
+
const duration = typeof asked === 'number' ? asked : typeof asked === 'string' && Number.isFinite(Number.parseFloat(asked)) ? Number.parseFloat(asked) : undefined;
|
|
1003
|
+
const seat = await desktopModelId(ctx.desktop(), input.model, `staging ${input.model}`, duration);
|
|
1004
|
+
const r = await ctx.desktop().post('/agent/composer', { ...input, ...(seat.note ? { model: seat.model } : {}) });
|
|
1000
1005
|
if (!r.report)
|
|
1001
1006
|
return { text: `Nothing was staged (${r.reason ?? 'no answer'}).`, data: { report: null } };
|
|
1002
1007
|
const skipped = r.skipped?.length ? `\nNot applied:\n- ${r.skipped.join('\n- ')}` : '';
|
|
1003
|
-
return { text: `${describeComposer(r.report)}${skipped}`, data: { report: r.report, skipped: r.skipped ?? [] } };
|
|
1008
|
+
return { text: `${describeComposer(r.report)}${skipped}${seat.note ? `\n${seat.note}` : ''}`, data: { report: r.report, skipped: r.skipped ?? [] } };
|
|
1004
1009
|
},
|
|
1005
1010
|
};
|
|
1006
1011
|
/**
|
|
@@ -1678,9 +1683,10 @@ export const VIDEO_MODELS = [
|
|
|
1678
1683
|
// not here; edit models live on slates_edit_video, same as the Kling and Omni
|
|
1679
1684
|
// Flash ones.
|
|
1680
1685
|
'seedance-2.5',
|
|
1681
|
-
// Gemini Omni Flash
|
|
1682
|
-
//
|
|
1683
|
-
|
|
1686
|
+
// Gemini Omni Flash 1.2 (2026-11-10), fal's `google/gemini-omni-flash/v1.2/*`.
|
|
1687
|
+
// It replaced 1.1 (`omni-flash`, in RETIRED_MODELS) seat for seat; a desktop
|
|
1688
|
+
// without `video-models-v2` gets the 1.1 seat (`desktopModelId`).
|
|
1689
|
+
'omni-flash-1-2',
|
|
1684
1690
|
// Wan 3.0 (Alibaba, added 2026-10-17): 2-30s at 480p-1080p, sound on or off,
|
|
1685
1691
|
// start and end frames OR references (10 images, 5 videos, 5 audio clips).
|
|
1686
1692
|
// Reference video seconds bill on top of output seconds, so it has a vref key.
|
|
@@ -1733,10 +1739,10 @@ const VIDEO_ASPECT_RATIOS = aspectRatioUnion(VIDEO_MODELS, AGENT_ROUTE_PROVIDER)
|
|
|
1733
1739
|
const VIDEO_RESOLUTIONS = videoResolutionUnion(VIDEO_MODELS);
|
|
1734
1740
|
/** Widest legal duration window across every video model. */
|
|
1735
1741
|
const VIDEO_DURATION_BOUNDS = durationBounds(VIDEO_MODELS);
|
|
1736
|
-
/** Omni Flash's combined reference-image cap, read from the SSOT (
|
|
1737
|
-
const omniFlashRefCap = getModelCapability('omni-flash')?.maxIngredientImages ?? 0;
|
|
1742
|
+
/** Omni Flash's combined reference-image cap, read from the SSOT (6 on 1.2). */
|
|
1743
|
+
const omniFlashRefCap = getModelCapability('omni-flash-1-2')?.maxIngredientImages ?? 0;
|
|
1738
1744
|
/** Omni Flash's per-clip reference-video ceiling in seconds, read from the SSOT. */
|
|
1739
|
-
const omniFlashRefClipMax = getModelCapability('omni-flash')?.referenceVideoDuration?.max ?? 0;
|
|
1745
|
+
const omniFlashRefClipMax = getModelCapability('omni-flash-1-2')?.referenceVideoDuration?.max ?? 0;
|
|
1740
1746
|
/** Every resolution token any video model speaks, for the forgiving cost-key
|
|
1741
1747
|
* parser. Derived, so 768p and 2k arrived with the models rather than with a
|
|
1742
1748
|
* later bug report. */
|
|
@@ -1810,7 +1816,7 @@ function minimaxRefSurchargeCount(model, referenceImages) {
|
|
|
1810
1816
|
export const EDIT_VIDEO_MODELS = [
|
|
1811
1817
|
'kling-v3.0-omni-edit',
|
|
1812
1818
|
'kling-v3.0-omni-pro-edit',
|
|
1813
|
-
'omni-flash-edit',
|
|
1819
|
+
'omni-flash-1-2-edit',
|
|
1814
1820
|
'seedance-2.5-edit',
|
|
1815
1821
|
];
|
|
1816
1822
|
// The op's default, not MODEL_FACTS' edit tier default: the desktop route defaults to the same Kling
|
|
@@ -1825,7 +1831,7 @@ const EDIT_VIDEO_ELEMENTS_ONLY = `Only ${EDIT_VIDEO_ELEMENT_MODELS.join(' and ')
|
|
|
1825
1831
|
*
|
|
1826
1832
|
* On an edit row the output length FOLLOWS the source clip, so the model's
|
|
1827
1833
|
* declared duration window is exactly the legal clip window — Kling 3-15s,
|
|
1828
|
-
* Omni Flash 3-
|
|
1834
|
+
* Omni Flash 1.2 3-15s, Seedance 2.5 4-30s. These three pairs used to be typed
|
|
1829
1835
|
* inline as `isSeedanceEdit ? 4 : 3` / `isSeedanceEdit ? 30 : isOmniFlashEdit ?
|
|
1830
1836
|
* 10 : 15`, i.e. a fourth copy of registry data keyed on model-id comparisons.
|
|
1831
1837
|
*/
|
|
@@ -1835,9 +1841,9 @@ function editClipBounds(model) {
|
|
|
1835
1841
|
throw new Error(`editClipBounds: no duration capability for "${model}"`);
|
|
1836
1842
|
return { min: d.min, max: d.max };
|
|
1837
1843
|
}
|
|
1838
|
-
/** Resolutions any edit engine exposes as a PARAM. Seedance's and Omni Flash
|
|
1839
|
-
*
|
|
1840
|
-
const EDIT_VIDEO_RESOLUTIONS = videoResolutionUnion(['seedance-2.5-edit', 'omni-flash-edit']);
|
|
1844
|
+
/** Resolutions any edit engine exposes as a PARAM. Seedance's and Omni Flash's
|
|
1845
|
+
* edit prices move with resolution; the Kling rows follow the source. */
|
|
1846
|
+
const EDIT_VIDEO_RESOLUTIONS = videoResolutionUnion(['seedance-2.5-edit', 'omni-flash-1-2-edit']);
|
|
1841
1847
|
export const estimateGenerationCost = {
|
|
1842
1848
|
id: 'slates_estimate_generation_cost',
|
|
1843
1849
|
description: 'Quote credits before any generate_* op. For saved Shots, a board or a scene, quote with slates_get_board_quote instead. Accepts the generation model ids and parameters (edit seats other than Kling, lip-sync and motion-transfer engines need an exact registry cost key), or an exact registry cost key. Show the user the total and wait for their OK before the generate call; the result flags requires_confirm above the threshold and carries the model\'s prompting card.',
|
|
@@ -1877,7 +1883,7 @@ export const estimateGenerationCost = {
|
|
|
1877
1883
|
const byKey = new Map(registry.models.filter((m) => !retiredModelOfKey(m.model)).map((m) => [m.model, creditCost(m)]));
|
|
1878
1884
|
// 1) exact registry cost key
|
|
1879
1885
|
let key = byKey.has(input.model) ? input.model : null;
|
|
1880
|
-
// 2) image base id + resolution (+ quality for GPT Image
|
|
1886
|
+
// 2) image base id + resolution (+ quality for GPT Image)
|
|
1881
1887
|
if (!key) {
|
|
1882
1888
|
// IMAGE_MODELS, never a second hand-typed copy: this list is declared
|
|
1883
1889
|
// below (a runtime read, so no temporal-dead-zone hazard) and is the same
|
|
@@ -2720,7 +2726,7 @@ export const generateCharacterIdentity = {
|
|
|
2720
2726
|
baseAssetId: z.string().uuid().describe('The base portrait asset the identity is generated from. ' + ASSET_UUID_ONLY),
|
|
2721
2727
|
userNotes: z.string().optional().describe('Extra instruction, e.g. "use the woman on the left".'),
|
|
2722
2728
|
model: z
|
|
2723
|
-
.enum(['nano-banana-2-1', 'gpt-image-2-
|
|
2729
|
+
.enum(['nano-banana-2-1', 'gpt-image-2-6-flare', 'gpt-image-2-6-sunburst'])
|
|
2724
2730
|
.optional()
|
|
2725
2731
|
.describe(`Image model for the sheet. Omit for the sheet tool's seat (${toolModelFor('character-sheet')}), which is what the app's own button uses. Pass another only to compare seats side by side.`),
|
|
2726
2732
|
confirm: z.boolean().optional().describe(CONFIRM_PARAM),
|
|
@@ -2733,8 +2739,9 @@ export const generateCharacterIdentity = {
|
|
|
2733
2739
|
// and `editImage` gate against; this op was simply missed when the gate was
|
|
2734
2740
|
// introduced, and the 2.5 swap is what makes it reachable in practice.
|
|
2735
2741
|
requireGuideRead(ctx, input.model ?? toolModelFor('character-sheet'));
|
|
2736
|
-
|
|
2737
|
-
|
|
2742
|
+
let sentModel = input.model;
|
|
2743
|
+
if (input.model && isGptImageModel(input.model)) {
|
|
2744
|
+
sentModel = await gptImageSeatFor(ctx.desktop(), input.model, `${input.model} character identity`);
|
|
2738
2745
|
}
|
|
2739
2746
|
else if (isImageModelV4(input.model)) {
|
|
2740
2747
|
await ctx.desktop().requireCapability('image-models-v4', `${input.model} character identity`);
|
|
@@ -2747,13 +2754,15 @@ export const generateCharacterIdentity = {
|
|
|
2747
2754
|
const quote = await sheetConfirmGate(ctx, input, (input.model ?? toolModelFor('character-sheet')));
|
|
2748
2755
|
if (quote)
|
|
2749
2756
|
return quote;
|
|
2750
|
-
|
|
2757
|
+
const made = await ctx.desktop().post('/agent/characters/generate-identity', {
|
|
2751
2758
|
characterId: input.characterId,
|
|
2752
2759
|
projectId: input.projectId,
|
|
2753
2760
|
baseAssetIds: [input.baseAssetId],
|
|
2754
2761
|
userNotes: input.userNotes,
|
|
2755
|
-
model:
|
|
2756
|
-
})
|
|
2762
|
+
model: sentModel,
|
|
2763
|
+
});
|
|
2764
|
+
const substitution = input.model && sentModel ? gptImageSubstitution(input.model, sentModel) : '';
|
|
2765
|
+
return ok(made, substitution ? `${substitution} ${JSON.stringify(made)}` : undefined);
|
|
2757
2766
|
},
|
|
2758
2767
|
};
|
|
2759
2768
|
export const generateEnvironmentPlate = {
|
|
@@ -2973,15 +2982,109 @@ async function previewAssets(ctx, refs) {
|
|
|
2973
2982
|
export const THREE_K_IMAGE_MODELS = Object.keys(MODEL_CAPABILITIES).filter((id) => MODEL_CAPABILITIES[id].imageResolutions?.includes('3k'));
|
|
2974
2983
|
export const IMAGE_MODELS = [
|
|
2975
2984
|
'nano-banana-2-1',
|
|
2976
|
-
'gpt-image-2-
|
|
2977
|
-
'gpt-image-2-
|
|
2985
|
+
'gpt-image-2-6-flare',
|
|
2986
|
+
'gpt-image-2-6-sunburst',
|
|
2978
2987
|
'flux-3',
|
|
2979
2988
|
'seedream-5-lite',
|
|
2980
2989
|
];
|
|
2981
|
-
/** True for either GPT Image
|
|
2990
|
+
/** True for either GPT Image seat. Flare and Sunburst differ in latency
|
|
2982
2991
|
* and routing advice, never in pricing shape or param surface. */
|
|
2983
2992
|
export function isGptImageModel(model) {
|
|
2984
|
-
return model === 'gpt-image-2-
|
|
2993
|
+
return model === 'gpt-image-2-6-flare' || model === 'gpt-image-2-6-sunburst';
|
|
2994
|
+
}
|
|
2995
|
+
/**
|
|
2996
|
+
* The GPT Image id to send this desktop for a 2.6 seat: the seat itself on a
|
|
2997
|
+
* desktop advertising `image-models-v5`, else the 2.5 seat it replaced.
|
|
2998
|
+
*
|
|
2999
|
+
* Why not refuse, as v3 and v4 do: 2.6 Sunburst is the default image seat, so a
|
|
3000
|
+
* refusal would stop every plain image call and edit on an installed desktop
|
|
3001
|
+
* (1.6.8 and older know only the 2.5 ids). 2.6 takes 2.5's fields, sizes and
|
|
3002
|
+
* tiers at the same price per cell (metered 2026-11-10, second-brain
|
|
3003
|
+
* plans/2026-11-10-slates-gpt-image-2-6-swap.md), and slates-api keeps 2.5
|
|
3004
|
+
* billable for those desktops, so the 2.5 seat renders what was quoted. The
|
|
3005
|
+
* result names the substitution. A desktop without v3 knows no GPT Image seat
|
|
3006
|
+
* and would render its Nano Banana path at a GPT price, so it still refuses.
|
|
3007
|
+
*/
|
|
3008
|
+
async function gptImageSeatFor(desktop, model, feature) {
|
|
3009
|
+
try {
|
|
3010
|
+
await desktop.requireCapability('image-models-v5', feature);
|
|
3011
|
+
return model;
|
|
3012
|
+
}
|
|
3013
|
+
catch {
|
|
3014
|
+
// A real failure (desktop not running) throws again here.
|
|
3015
|
+
await desktop.requireCapability('image-models-v3', feature);
|
|
3016
|
+
return Object.keys(RETIRED_MODELS).find((id) => id.startsWith('gpt-image-2-5-') && RETIRED_MODELS[id] === model) ?? model;
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
/** The line a result carries when `gptImageSeatFor` sent the 2.5 seat. */
|
|
3020
|
+
function gptImageSubstitution(asked, sent) {
|
|
3021
|
+
return sent === asked ? '' : `${sent} ran in place of ${asked}, at the same price: this Slates desktop predates GPT Image 2.6. Update Slates to run 2.6.`;
|
|
3022
|
+
}
|
|
3023
|
+
/** True for either Gemini Omni Flash 1.2 seat, generation or edit. */
|
|
3024
|
+
export function isOmniFlash12Model(model) {
|
|
3025
|
+
return model === 'omni-flash-1-2' || model === 'omni-flash-1-2-edit';
|
|
3026
|
+
}
|
|
3027
|
+
/**
|
|
3028
|
+
* Omni Flash 1.1's longest clip, output or edit source. Frozen here because the
|
|
3029
|
+
* capability table no longer carries 1.1: fal's 1.1 `duration` stopped at 10, and
|
|
3030
|
+
* Google's 1.1 doc read "Input videos for editing and extension must be 10
|
|
3031
|
+
* seconds or less".
|
|
3032
|
+
*/
|
|
3033
|
+
const OMNI_FLASH_11_MAX_SECONDS = 10;
|
|
3034
|
+
/**
|
|
3035
|
+
* The Omni Flash id to send this desktop for a 1.2 seat: the seat itself on a
|
|
3036
|
+
* desktop advertising `video-models-v2`, else the 1.1 seat it replaced, when the
|
|
3037
|
+
* request fits 1.1 (`seconds` is the output length, or an edit's source length).
|
|
3038
|
+
*
|
|
3039
|
+
* Why not refuse: 1.6.8 and older know only the 1.1 ids. 1.2 bills the same
|
|
3040
|
+
* credits per second as 1.1 at every resolution Slates sells, slates-api keeps
|
|
3041
|
+
* 1.1 billable for those desktops, and every 1.2 reference limit sits inside
|
|
3042
|
+
* 1.1's, so up to 10s the 1.1 seat renders what was quoted. A longer clip has
|
|
3043
|
+
* no 1.1 seat and refuses with "update Slates". A desktop without
|
|
3044
|
+
* `image-models-v4` predates 1.1 (both arrived in 1.6.3) and would bill 1.0's
|
|
3045
|
+
* keys, so it refuses too.
|
|
3046
|
+
*/
|
|
3047
|
+
async function omniFlashSeatFor(desktop, model, feature, seconds) {
|
|
3048
|
+
try {
|
|
3049
|
+
await desktop.requireCapability('video-models-v2', feature);
|
|
3050
|
+
return model;
|
|
3051
|
+
}
|
|
3052
|
+
catch {
|
|
3053
|
+
// A real failure (desktop not running), or a desktop before 1.1, throws again here.
|
|
3054
|
+
await desktop.requireCapability('image-models-v4', feature);
|
|
3055
|
+
if (seconds != null && seconds > OMNI_FLASH_11_MAX_SECONDS + 0.05) {
|
|
3056
|
+
throw new Error(`This Slates desktop runs Gemini Omni Flash 1.1, which stops at ${OMNI_FLASH_11_MAX_SECONDS}s, so ${feature} at ${seconds}s needs 1.2. ` +
|
|
3057
|
+
`Update Slates (Settings → Check for Updates) and retry, or keep it to ${OMNI_FLASH_11_MAX_SECONDS}s or less.`);
|
|
3058
|
+
}
|
|
3059
|
+
return Object.keys(RETIRED_MODELS).find((id) => id.startsWith('omni-flash') && RETIRED_MODELS[id] === model) ?? model;
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
/** The line a result carries when `omniFlashSeatFor` sent the 1.1 seat. */
|
|
3063
|
+
function omniFlashSubstitution(asked, sent) {
|
|
3064
|
+
return sent === asked ? '' : `${sent} ran in place of ${asked}, at the same price: this Slates desktop predates Gemini Omni Flash 1.2. Update Slates to run 1.2.`;
|
|
3065
|
+
}
|
|
3066
|
+
/**
|
|
3067
|
+
* A model id an op hands the desktop by name (a generation's, a Shot's or a draft's model), as this desktop knows
|
|
3068
|
+
* it: a GPT Image 2.6 seat goes through `gptImageSeatFor`, an Omni Flash 1.2 seat through `omniFlashSeatFor`
|
|
3069
|
+
* (`seconds` as it takes them), every other id passes untouched. A 1.6.8 desktop's `draftShot` throws on an id it
|
|
3070
|
+
* lacks, so every such hand-off comes through here, with the line its result says.
|
|
3071
|
+
*/
|
|
3072
|
+
async function desktopModelId(desktop, model, feature, seconds) {
|
|
3073
|
+
if (model && isOmniFlash12Model(model)) {
|
|
3074
|
+
const sent = (await omniFlashSeatFor(desktop, model, feature, seconds));
|
|
3075
|
+
return { model: sent, note: omniFlashSubstitution(model, sent) };
|
|
3076
|
+
}
|
|
3077
|
+
if (!model || !isGptImageModel(model))
|
|
3078
|
+
return { model, note: '' };
|
|
3079
|
+
const sent = (await gptImageSeatFor(desktop, model, feature));
|
|
3080
|
+
return { model: sent, note: gptImageSubstitution(model, sent) };
|
|
3081
|
+
}
|
|
3082
|
+
/** `draft` with its model as this desktop knows it (`desktopModelId`). */
|
|
3083
|
+
async function desktopDraft(desktop, draft) {
|
|
3084
|
+
if (!draft?.model)
|
|
3085
|
+
return { draft, note: '' };
|
|
3086
|
+
const { model, note } = await desktopModelId(desktop, draft.model, `previews on ${draft.model}`);
|
|
3087
|
+
return { draft: { ...draft, model }, note };
|
|
2985
3088
|
}
|
|
2986
3089
|
/**
|
|
2987
3090
|
* The seats that arrived 2026-10-23, which only a desktop advertising
|
|
@@ -3000,7 +3103,7 @@ const HEADLESS_IMAGE_MODEL = 'nano-banana-2-1';
|
|
|
3000
3103
|
* value no model accepts. It used to be a hand-typed eleven-value list whose
|
|
3001
3104
|
* `9:21` exists in ZERO models; that phantom is gone by construction.
|
|
3002
3105
|
*
|
|
3003
|
-
* ⚠️ STILL A UNION, NOT A PER-MODEL CHECK. GPT Image
|
|
3106
|
+
* ⚠️ STILL A UNION, NOT A PER-MODEL CHECK. GPT Image takes five of these
|
|
3004
3107
|
* ten and the other five would be accepted here. The image param surface has
|
|
3005
3108
|
* not been audited (aspect ratios, resolution classes, per-model reference
|
|
3006
3109
|
* caps) — that audit is the named follow-up in
|
|
@@ -3012,7 +3115,7 @@ const IMAGE_ASPECT_RATIOS = aspectRatioUnion(IMAGE_MODELS);
|
|
|
3012
3115
|
// Registry cost-key for an image model+resolution. Mirrors imageCreditKey()
|
|
3013
3116
|
// in slate/src/shared/pricing.ts — MUST byte-match it (the same hard rule as
|
|
3014
3117
|
// videoCostKey): Nano Banana 2.1 and FLUX 3 price per resolution, Seedream is
|
|
3015
|
-
// flat, GPT Image
|
|
3118
|
+
// flat, GPT Image is quality × resolution-class over ALL FIVE exposed tiers.
|
|
3016
3119
|
//
|
|
3017
3120
|
// 🚨 THE KEY SUFFIX IS `med` WHILE THE WIRE VALUE IS `medium` — the one
|
|
3018
3121
|
// tier name that differs between fal's enum and our cost keys, inherited from
|
|
@@ -3233,12 +3336,11 @@ export const generateImage = {
|
|
|
3233
3336
|
// New-roster models need a desktop that knows them — an older desktop's
|
|
3234
3337
|
// allowlist would silently fall back to its Nano Banana path while we quote
|
|
3235
3338
|
// the new model's price.
|
|
3339
|
+
let sentModel = imageModel;
|
|
3236
3340
|
if (input.projectId && isGptImageModel(imageModel)) {
|
|
3237
|
-
//
|
|
3238
|
-
//
|
|
3239
|
-
|
|
3240
|
-
// the failure the gate was built to stop. Reusing v2 reintroduces it.
|
|
3241
|
-
await ctx.desktop().requireCapability('image-models-v3', `${imageModel} generation`);
|
|
3341
|
+
// A desktop that knows 2.5 and not 2.6 gets the 2.5 seat; one that knows
|
|
3342
|
+
// neither refuses (gptImageSeatFor says why).
|
|
3343
|
+
sentModel = await gptImageSeatFor(ctx.desktop(), imageModel, `${imageModel} generation`);
|
|
3242
3344
|
}
|
|
3243
3345
|
else if (input.projectId && isImageModelV4(imageModel)) {
|
|
3244
3346
|
await ctx.desktop().requireCapability('image-models-v4', `${imageModel} generation`);
|
|
@@ -3313,7 +3415,7 @@ export const generateImage = {
|
|
|
3313
3415
|
const result = await desktop.post('/agent/generation/image', {
|
|
3314
3416
|
projectId: input.projectId,
|
|
3315
3417
|
prompt: input.prompt,
|
|
3316
|
-
model:
|
|
3418
|
+
model: sentModel,
|
|
3317
3419
|
resolution,
|
|
3318
3420
|
aspectRatio: input.aspectRatio ?? '1:1',
|
|
3319
3421
|
count: input.count ?? 1,
|
|
@@ -3330,15 +3432,17 @@ export const generateImage = {
|
|
|
3330
3432
|
if (!result.success && !partialFailure) {
|
|
3331
3433
|
throw new Error(result.error ?? 'Generation failed');
|
|
3332
3434
|
}
|
|
3435
|
+
const substitution = gptImageSubstitution(imageModel, sentModel);
|
|
3333
3436
|
if (result.background) {
|
|
3334
3437
|
const ids = result.generationIds ?? (result.generationId ? [result.generationId] : []);
|
|
3335
3438
|
return backgroundSubmitted(`${imageModel} image generation`, ids, {
|
|
3336
3439
|
model: imageModel,
|
|
3440
|
+
...(substitution ? { ranOn: sentModel } : {}),
|
|
3337
3441
|
costKey,
|
|
3338
3442
|
projectId: input.projectId,
|
|
3339
3443
|
cost_cents: totalCents,
|
|
3340
3444
|
cost_credits: totalCents,
|
|
3341
|
-
}, refEcho);
|
|
3445
|
+
}, [refEcho, substitution].filter(Boolean).join(' '));
|
|
3342
3446
|
}
|
|
3343
3447
|
const assetList = result.assets
|
|
3344
3448
|
?? (result.asset ? [result.asset] : []);
|
|
@@ -3371,10 +3475,12 @@ export const generateImage = {
|
|
|
3371
3475
|
: `Generated ${assetList.length} image(s) into project ${input.projectId} ` +
|
|
3372
3476
|
`for ${fmtCredits(totalCents)}. ` +
|
|
3373
3477
|
`Prompt: "${input.prompt.slice(0, 60)}${input.prompt.length > 60 ? '...' : ''}"` +
|
|
3374
|
-
(refEcho ? ` ${refEcho}` : ''))
|
|
3478
|
+
(refEcho ? ` ${refEcho}` : '')) +
|
|
3479
|
+
(substitution ? ` ${substitution}` : ''),
|
|
3375
3480
|
images,
|
|
3376
3481
|
data: {
|
|
3377
3482
|
model: imageModel,
|
|
3483
|
+
...(substitution ? { ranOn: sentModel } : {}),
|
|
3378
3484
|
costKey,
|
|
3379
3485
|
projectId: input.projectId,
|
|
3380
3486
|
aspectRatio: input.aspectRatio,
|
|
@@ -3530,13 +3636,12 @@ export const editImage = {
|
|
|
3530
3636
|
const editModel = input.editModel ?? toolModelFor('image-edit');
|
|
3531
3637
|
requireGuideRead(ctx, editModel);
|
|
3532
3638
|
const resolution = input.resolution ?? defaultImageResolutionFor(editModel);
|
|
3639
|
+
let sentModel = editModel;
|
|
3533
3640
|
if (isGptImageModel(editModel)) {
|
|
3534
|
-
//
|
|
3535
|
-
//
|
|
3536
|
-
//
|
|
3537
|
-
|
|
3538
|
-
// at a quoted 2.5 price. Exactly the bug the gate exists to stop.
|
|
3539
|
-
await desktop.requireCapability('image-models-v3', `${editModel} editing`);
|
|
3641
|
+
// Like generateImage; this site was missed once already. A desktop that
|
|
3642
|
+
// knows no GPT Image seat falls through to its Nano Banana path at a quoted
|
|
3643
|
+
// GPT price, so it refuses; one that knows 2.5 and not 2.6 gets the 2.5 seat.
|
|
3644
|
+
sentModel = await gptImageSeatFor(desktop, editModel, `${editModel} editing`);
|
|
3540
3645
|
}
|
|
3541
3646
|
else if (isImageModelV4(editModel)) {
|
|
3542
3647
|
await desktop.requireCapability('image-models-v4', `${editModel} editing`);
|
|
@@ -3546,7 +3651,7 @@ export const editImage = {
|
|
|
3546
3651
|
}
|
|
3547
3652
|
// Past the model's cap the desktop sends the first ones and says so in its reply (`note`).
|
|
3548
3653
|
const referencesOver = (input.referenceAssetIds?.length ?? 0) - editReferenceCap(editModel);
|
|
3549
|
-
// Nano
|
|
3654
|
+
// Nano Banana and GPT Image edits charge the same key as gen;
|
|
3550
3655
|
// FLUX / Seedream route to dedicated edit endpoints priced under '-edit' keys.
|
|
3551
3656
|
// Mirrors `editCreditKey` in the desktop's src/shared/imageEdit.ts, which
|
|
3552
3657
|
// this package cannot import: change both together.
|
|
@@ -3578,7 +3683,7 @@ export const editImage = {
|
|
|
3578
3683
|
projectId: input.projectId,
|
|
3579
3684
|
sourceAssetId: input.sourceAssetId,
|
|
3580
3685
|
prompt: input.prompt,
|
|
3581
|
-
editModel,
|
|
3686
|
+
editModel: sentModel,
|
|
3582
3687
|
referenceAssetIds: input.referenceAssetIds,
|
|
3583
3688
|
resolution,
|
|
3584
3689
|
...(isGptImageModel(editModel) ? { gptQuality: input.quality ?? DEFAULT_GPT_QUALITY, gptBackground: input.backgroundMode } : {}),
|
|
@@ -3587,6 +3692,7 @@ export const editImage = {
|
|
|
3587
3692
|
});
|
|
3588
3693
|
if (!result.success)
|
|
3589
3694
|
throw new Error(result.error ?? 'Image edit failed');
|
|
3695
|
+
const substitution = gptImageSubstitution(editModel, sentModel);
|
|
3590
3696
|
if (result.background) {
|
|
3591
3697
|
const ids = result.generationIds ?? (result.generationId ? [result.generationId] : []);
|
|
3592
3698
|
return backgroundSubmitted(`${editModel} image edit`, ids, {
|
|
@@ -3597,7 +3703,8 @@ export const editImage = {
|
|
|
3597
3703
|
cost_cents: totalCents,
|
|
3598
3704
|
cost_credits: totalCents,
|
|
3599
3705
|
...(result.note ? { note: result.note } : {}),
|
|
3600
|
-
|
|
3706
|
+
...(substitution ? { ranOn: sentModel } : {}),
|
|
3707
|
+
}, [result.note ? `${result.note}.` : '', substitution].filter(Boolean).join(' ') || undefined);
|
|
3601
3708
|
}
|
|
3602
3709
|
// Inline the edited result so the LLM sees whether the surgery landed —
|
|
3603
3710
|
// same best-effort pattern as slates_generate_image.
|
|
@@ -3616,10 +3723,12 @@ export const editImage = {
|
|
|
3616
3723
|
text: `Edited image saved as a new asset in project ${input.projectId} ` +
|
|
3617
3724
|
`for ${fmtCredits(totalCents)} via ${editModel}. ` +
|
|
3618
3725
|
`Edit: "${input.prompt.slice(0, 60)}${input.prompt.length > 60 ? '...' : ''}"` +
|
|
3619
|
-
(result.note ? ` ${result.note}.` : '')
|
|
3726
|
+
(result.note ? ` ${result.note}.` : '') +
|
|
3727
|
+
(substitution ? ` ${substitution}` : ''),
|
|
3620
3728
|
images,
|
|
3621
3729
|
data: {
|
|
3622
3730
|
editModel,
|
|
3731
|
+
...(substitution ? { ranOn: sentModel } : {}),
|
|
3623
3732
|
variant: costKey,
|
|
3624
3733
|
projectId: input.projectId,
|
|
3625
3734
|
sourceAssetId: input.sourceAssetId,
|
|
@@ -3874,14 +3983,14 @@ export function videoCostKey(input) {
|
|
|
3874
3983
|
const res = input.videoResolution ?? defaultVideoResolutionFor(input.model);
|
|
3875
3984
|
return `kling-v4-${res}-${input.duration}s`;
|
|
3876
3985
|
}
|
|
3877
|
-
if (input.model === 'omni-flash') {
|
|
3986
|
+
if (input.model === 'omni-flash-1-2') {
|
|
3878
3987
|
// Mirrors omniFlashCreditKey() in slate/src/shared/pricing.ts. Omni Flash
|
|
3879
|
-
//
|
|
3880
|
-
//
|
|
3881
|
-
// 1.
|
|
3882
|
-
//
|
|
3988
|
+
// prices each output second by resolution, so the key carries it. Audio is
|
|
3989
|
+
// native and included, and references do not move fal's 1.2 listed price.
|
|
3990
|
+
// 1.1's `omni-flash-{res}-{N}s` and 1.0's `omni-flash-{N}s` keys stay
|
|
3991
|
+
// billable for the desktops released before each swap.
|
|
3883
3992
|
const res = input.videoResolution ?? defaultVideoResolutionFor(input.model);
|
|
3884
|
-
return `omni-flash-${res}-${input.duration}s`;
|
|
3993
|
+
return `omni-flash-1-2-${res}-${input.duration}s`;
|
|
3885
3994
|
}
|
|
3886
3995
|
if (input.model === 'wan-3.0') {
|
|
3887
3996
|
// Mirrors wanCreditKey() in slate/src/shared/pricing.ts. Output seconds at
|
|
@@ -3911,10 +4020,10 @@ export function klingEditCostKey(model, duration) {
|
|
|
3911
4020
|
// Omni Flash video-edit cost key — mirrors omniFlashCreditKey() in
|
|
3912
4021
|
// slate/src/shared/pricing.ts (must byte-match; checked by the slates-api
|
|
3913
4022
|
// pricing-consistency script). Duration is the CEILED source-clip length. The
|
|
3914
|
-
// resolution is the output's, because Omni Flash
|
|
4023
|
+
// resolution is the output's, because Omni Flash prices edit seconds by it.
|
|
3915
4024
|
export function omniFlashEditCostKey(duration, videoResolution) {
|
|
3916
|
-
const res = videoResolution ?? defaultVideoResolutionFor('omni-flash-edit');
|
|
3917
|
-
return `omni-flash-edit-${res}-${duration}s`;
|
|
4025
|
+
const res = videoResolution ?? defaultVideoResolutionFor('omni-flash-1-2-edit');
|
|
4026
|
+
return `omni-flash-1-2-edit-${res}-${duration}s`;
|
|
3918
4027
|
}
|
|
3919
4028
|
/** Max billed (input + output) seconds on a Seedance video-reference gen.
|
|
3920
4029
|
* 2.0: refs 2–15s + output 4–15s. 2.5: refs to 30s + output to 30s. */
|
|
@@ -4078,12 +4187,19 @@ function resolveVideoModel(raw) {
|
|
|
4078
4187
|
'seedance-2-5': 'seedance-2.5',
|
|
4079
4188
|
'seedance2.5': 'seedance-2.5',
|
|
4080
4189
|
seedance: 'seedance-2',
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
'omni-flash
|
|
4084
|
-
'gemini-omni-
|
|
4085
|
-
'gemini-omni-flash-
|
|
4086
|
-
'omni-flash-
|
|
4190
|
+
// Every Omni Flash spelling lands on 1.2, the retired 1.1 id and its cost
|
|
4191
|
+
// keys (`omni-flash-720p-8s`) included: RETIRED_MODELS moves 1.1 to 1.2.
|
|
4192
|
+
'omni-flash': 'omni-flash-1-2',
|
|
4193
|
+
'gemini-omni-flash': 'omni-flash-1-2',
|
|
4194
|
+
'gemini-omni-flash-preview': 'omni-flash-1-2',
|
|
4195
|
+
'omni-flash-preview': 'omni-flash-1-2',
|
|
4196
|
+
'gemini-omni-1.1-flash': 'omni-flash-1-2',
|
|
4197
|
+
'gemini-omni-flash-1.1': 'omni-flash-1-2',
|
|
4198
|
+
'omni-flash-1.1': 'omni-flash-1-2',
|
|
4199
|
+
'gemini-omni-1.2-flash': 'omni-flash-1-2',
|
|
4200
|
+
'gemini-omni-flash-1.2': 'omni-flash-1-2',
|
|
4201
|
+
'omni-flash-1.2': 'omni-flash-1-2',
|
|
4202
|
+
'omni-flash-12': 'omni-flash-1-2',
|
|
4087
4203
|
'wan-3': 'wan-3.0',
|
|
4088
4204
|
'wan-3-0': 'wan-3.0',
|
|
4089
4205
|
'wan3': 'wan-3.0',
|
|
@@ -4317,17 +4433,17 @@ export const generateVideo = {
|
|
|
4317
4433
|
const capErr = assertVideoCapabilities(input);
|
|
4318
4434
|
if (capErr)
|
|
4319
4435
|
return ok(capErr);
|
|
4320
|
-
// Omni Flash 1.
|
|
4321
|
-
// frame and an optional end frame
|
|
4322
|
-
//
|
|
4323
|
-
//
|
|
4324
|
-
//
|
|
4325
|
-
//
|
|
4326
|
-
//
|
|
4327
|
-
//
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4436
|
+
// Omni Flash 1.2's SHAPE constraints. Frames ride image-to-video (a start
|
|
4437
|
+
// frame and an optional end frame, 10s or less with the end frame);
|
|
4438
|
+
// references ride reference-to-video (Google's limits: 6 images, reference
|
|
4439
|
+
// videos of 3s or less, three on a clip of 10s or less and one above). With
|
|
4440
|
+
// references, the desktop sends a start frame as reference image 1, so it
|
|
4441
|
+
// counts toward the image cap; a last frame has no slot there and is
|
|
4442
|
+
// refused. No audio reference at all (Google: "Uploading audio inputs or
|
|
4443
|
+
// audio references is unsupported"). Counts come from the capability SSOT
|
|
4444
|
+
// through `checkReferenceShape`, the function the desktop's composer runs;
|
|
4445
|
+
// duration and resolution are covered by the capability gate above.
|
|
4446
|
+
if (input.model === 'omni-flash-1-2') {
|
|
4331
4447
|
const videoRefs = (input.videoReferenceAssetIds?.length ?? 0) + (input.videoReferenceAssetId ? 1 : 0);
|
|
4332
4448
|
const audioRefs = (input.audioReferenceAssetIds?.length ?? 0) + (input.audioReferenceAssetId ? 1 : 0);
|
|
4333
4449
|
const imageRefs = (input.ingredientAssetIds?.length ?? 0) +
|
|
@@ -4336,6 +4452,11 @@ export const generateVideo = {
|
|
|
4336
4452
|
(input.styleAssetIds?.length ?? 0);
|
|
4337
4453
|
const hasRefs = imageRefs + videoRefs > 0;
|
|
4338
4454
|
const refCount = imageRefs + (hasRefs && input.firstFrameAssetId ? 1 : 0);
|
|
4455
|
+
// Only the lengths given; a missing one is asked for below, before the quote.
|
|
4456
|
+
const refSeconds = [
|
|
4457
|
+
...(input.videoReferenceAssetId && input.videoReferenceSeconds != null ? [input.videoReferenceSeconds] : []),
|
|
4458
|
+
...(input.videoReferenceSecondsEach ?? []),
|
|
4459
|
+
];
|
|
4339
4460
|
const shapeError = audioRefs > 0
|
|
4340
4461
|
? 'Omni Flash takes no audio references. Drop them, or switch to seedance-2.5 or wan-3.0, which read reference audio.'
|
|
4341
4462
|
: hasRefs && input.lastFrameAssetId
|
|
@@ -4343,12 +4464,14 @@ export const generateVideo = {
|
|
|
4343
4464
|
: input.lastFrameAssetId && !input.firstFrameAssetId
|
|
4344
4465
|
? 'Omni Flash needs a start frame (firstFrameAssetId) with a last frame.'
|
|
4345
4466
|
: refCount > omniFlashRefCap
|
|
4346
|
-
? `Omni Flash takes at most ${omniFlashRefCap} reference images combined, a start frame included (you passed ${refCount}). Trim the list.`
|
|
4347
|
-
:
|
|
4348
|
-
|
|
4349
|
-
:
|
|
4350
|
-
|
|
4351
|
-
|
|
4467
|
+
? `Omni Flash takes at most ${omniFlashRefCap} reference images combined (at most 3 of one character, 2 characters), a start frame included (you passed ${refCount}). Trim the list.`
|
|
4468
|
+
: checkReferenceShape(input.model, {
|
|
4469
|
+
duration: input.duration,
|
|
4470
|
+
lastFrame: !!input.lastFrameAssetId,
|
|
4471
|
+
referenceVideoCount: videoRefs,
|
|
4472
|
+
referenceVideoSeconds: refSeconds,
|
|
4473
|
+
label: 'Omni Flash',
|
|
4474
|
+
})?.replace('Trim it first.', 'Trim it first with slates_trim_video.') ?? null;
|
|
4352
4475
|
if (shapeError) {
|
|
4353
4476
|
return ok({ requires_clarification: true, missing: [], message: shapeError });
|
|
4354
4477
|
}
|
|
@@ -4606,7 +4729,7 @@ export const generateVideo = {
|
|
|
4606
4729
|
// Wan 3.0 bills reference video seconds on top of output seconds too, and
|
|
4607
4730
|
// Omni Flash's per-clip cap needs every length to check.
|
|
4608
4731
|
const isSeedance = input.model.startsWith('seedance');
|
|
4609
|
-
const needsRefSeconds = isSeedance || input.model === 'wan-3.0' || input.model === 'omni-flash';
|
|
4732
|
+
const needsRefSeconds = isSeedance || input.model === 'wan-3.0' || input.model === 'omni-flash-1-2';
|
|
4610
4733
|
if (input.videoReferenceAssetId && needsRefSeconds && !input.videoReferenceSeconds) {
|
|
4611
4734
|
return ok({
|
|
4612
4735
|
requires_clarification: true,
|
|
@@ -4623,6 +4746,9 @@ export const generateVideo = {
|
|
|
4623
4746
|
message: `A Seedance or Wan 3.0 video reference bills on combined input+output seconds (on a Seedance 2.5 Face row, max(input, output) + output), and Omni Flash caps each clip at ${omniFlashRefClipMax}s. Pass videoReferenceSecondsEach with exactly ${pluralRefCount} duration${pluralRefCount === 1 ? '' : 's'}, in the same order as videoReferenceAssetIds (durations are shown in slates_list_assets), so the pre-flight quote matches the bill.`,
|
|
4624
4747
|
});
|
|
4625
4748
|
}
|
|
4749
|
+
// A desktop without Omni Flash 1.2 gets the 1.1 seat at the same price (`desktopModelId`), resolved before the
|
|
4750
|
+
// quote so a job it cannot run is refused before the agent is asked to confirm it.
|
|
4751
|
+
const seat = await desktopModelId(ctx.desktop(), input.model, `${input.model} generation`, input.duration);
|
|
4626
4752
|
const cloud = ctx.cloud();
|
|
4627
4753
|
const registry = await cloud.get('/api/agent/models');
|
|
4628
4754
|
const costKey = input.model === 'minimax-h3-max'
|
|
@@ -4744,7 +4870,7 @@ export const generateVideo = {
|
|
|
4744
4870
|
}
|
|
4745
4871
|
const result = await desktop.post('/agent/generation/video', {
|
|
4746
4872
|
projectId: input.projectId,
|
|
4747
|
-
model:
|
|
4873
|
+
model: seat.model,
|
|
4748
4874
|
prompt: input.prompt,
|
|
4749
4875
|
aspectRatio: input.aspectRatio,
|
|
4750
4876
|
duration: input.duration,
|
|
@@ -4786,6 +4912,7 @@ export const generateVideo = {
|
|
|
4786
4912
|
const ids = result.generationIds ?? (result.generationId ? [result.generationId] : []);
|
|
4787
4913
|
return backgroundSubmitted(`${input.duration}s ${input.model} video generation`, ids, {
|
|
4788
4914
|
model: input.model,
|
|
4915
|
+
...(seat.note ? { ranOn: seat.model } : {}),
|
|
4789
4916
|
variant: costKey,
|
|
4790
4917
|
projectId: input.projectId,
|
|
4791
4918
|
cost_cents: totalCents,
|
|
@@ -4794,7 +4921,7 @@ export const generateVideo = {
|
|
|
4794
4921
|
role,
|
|
4795
4922
|
...(resolvedRefs.get(ref) ?? { id: ref, code: null, label: null }),
|
|
4796
4923
|
})),
|
|
4797
|
-
}, refEcho);
|
|
4924
|
+
}, [refEcho, seat.note].filter(Boolean).join(' '));
|
|
4798
4925
|
}
|
|
4799
4926
|
return {
|
|
4800
4927
|
text:
|
|
@@ -4805,9 +4932,11 @@ export const generateVideo = {
|
|
|
4805
4932
|
`Generated ${input.duration}s ${input.model} video into project ${input.projectId} ` +
|
|
4806
4933
|
`for ${fmtCredits(totalCents)}. ` +
|
|
4807
4934
|
`Prompt: "${input.prompt.slice(0, 60)}${input.prompt.length > 60 ? '...' : ''}"` +
|
|
4808
|
-
(refEcho ? ` ${refEcho}` : '')
|
|
4935
|
+
(refEcho ? ` ${refEcho}` : '') +
|
|
4936
|
+
(seat.note ? ` ${seat.note}` : ''),
|
|
4809
4937
|
data: {
|
|
4810
4938
|
model: input.model,
|
|
4939
|
+
...(seat.note ? { ranOn: seat.model } : {}),
|
|
4811
4940
|
variant: costKey,
|
|
4812
4941
|
projectId: input.projectId,
|
|
4813
4942
|
aspectRatio: input.aspectRatio,
|
|
@@ -5373,7 +5502,7 @@ export const editVideo = {
|
|
|
5373
5502
|
input: z.object({
|
|
5374
5503
|
projectId: z.string().uuid().describe('Project the source clip lives in.'),
|
|
5375
5504
|
sourceVideoAssetId: z.string().describe('The VIDEO asset to edit — UUID or badge code ("VID-V3", bare "V3"); codes resolve against the project at call time. Clip-length windows per engine are on `model`.'),
|
|
5376
|
-
prompt: z.string().min(1).max(2500).describe('The change, not the whole scene — e.g. "replace the man with @marcus", "make it a rainy night", "turn the street into a neon Tokyo alley". Mention subjects with @name; the transport compiles them to Kling\'s @ElementN notation (Kling models). For omni-flash-edit keep it simple and add "Keep everything else the same."'),
|
|
5505
|
+
prompt: z.string().min(1).max(2500).describe('The change, not the whole scene — e.g. "replace the man with @marcus", "make it a rainy night", "turn the street into a neon Tokyo alley". Mention subjects with @name; the transport compiles them to Kling\'s @ElementN notation (Kling models). For omni-flash-1-2-edit keep it simple and add "Keep everything else the same."'),
|
|
5377
5506
|
// Clip windows and resolutions GENERATED from MODEL_CAPABILITIES.
|
|
5378
5507
|
model: zEnum(EDIT_VIDEO_MODELS).optional().describe(
|
|
5379
5508
|
// Routing GENERATED from MODEL_FACTS; the paragraph that stood here was
|
|
@@ -5384,8 +5513,8 @@ export const editVideo = {
|
|
|
5384
5513
|
`Source-clip length per engine: ${describeDurations(EDIT_VIDEO_MODELS)}. Output resolution: ${describeVideoResolutions(EDIT_VIDEO_MODELS)}`),
|
|
5385
5514
|
characterAssetIds: z.array(z.string()).max(EDIT_VIDEO_ELEMENT_CAP).optional().describe('Subject/element image assets to swap IN (UUIDs or badge codes). Each becomes an element (@ElementN). ' + EDIT_VIDEO_ELEMENTS_ONLY),
|
|
5386
5515
|
styleAssetIds: z.array(z.string()).max(EDIT_VIDEO_ELEMENT_CAP).optional().describe(`Style/appearance reference images (@ImageN). Max ${EDIT_VIDEO_ELEMENT_CAP} combined with characterAssetIds. ` + EDIT_VIDEO_ELEMENTS_ONLY),
|
|
5387
|
-
keepAudio: z.boolean().optional().describe('Preserve the original audio track (default true; Kling models only — omni-flash-edit and seedance-2.5-edit output carry their own audio).'),
|
|
5388
|
-
videoResolution: zEnum(EDIT_VIDEO_RESOLUTIONS).optional().describe(`seedance-2.5-edit (default ${defaultVideoResolutionFor('seedance-2.5-edit')}) and omni-flash-edit (default ${defaultVideoResolutionFor('omni-flash-edit')}; its 1080p and 4K are upscales). Ignored by the Kling engines, whose output follows the source clip.`),
|
|
5516
|
+
keepAudio: z.boolean().optional().describe('Preserve the original audio track (default true; Kling models only — omni-flash-1-2-edit and seedance-2.5-edit output carry their own audio).'),
|
|
5517
|
+
videoResolution: zEnum(EDIT_VIDEO_RESOLUTIONS).optional().describe(`seedance-2.5-edit (default ${defaultVideoResolutionFor('seedance-2.5-edit')}) and omni-flash-1-2-edit (default ${defaultVideoResolutionFor('omni-flash-1-2-edit')}; its 1080p and 4K are upscales). Ignored by the Kling engines, whose output follows the source clip.`),
|
|
5389
5518
|
seedanceFace: z.boolean().optional().describe(`seedance-2.5-edit ONLY: set true when a CHARACTER FACE is visible in the clip. Without it a face is blocked outright; with it the edit is priced higher: quote it with slates_estimate_generation_cost by its cost key as model (${seedanceEditCostKey({ duration: SEEDANCE_25_EDIT_MIN_SECONDS, videoResolution: defaultVideoResolutionFor('seedance-2.5-edit'), seedanceFace: true })} for ${SEEDANCE_25_EDIT_MIN_SECONDS}s at ${defaultVideoResolutionFor('seedance-2.5-edit')}). A face edit submitted without this flag is rejected, not silently downgraded.`),
|
|
5390
5519
|
background: z.boolean().optional().describe(BACKGROUND_DESCRIBE),
|
|
5391
5520
|
confirm: z.boolean().optional().describe(CONFIRM_PARAM),
|
|
@@ -5402,10 +5531,10 @@ export const editVideo = {
|
|
|
5402
5531
|
}
|
|
5403
5532
|
const model = input.model ?? EDIT_VIDEO_DEFAULT;
|
|
5404
5533
|
requireGuideRead(ctx, model);
|
|
5405
|
-
const isOmniFlashEdit = model === 'omni-flash-edit';
|
|
5534
|
+
const isOmniFlashEdit = model === 'omni-flash-1-2-edit';
|
|
5406
5535
|
const isSeedanceEdit = model === 'seedance-2.5-edit';
|
|
5407
5536
|
// Source-clip window, read from the capability SSOT per engine — never a
|
|
5408
|
-
// model-id ternary. (Kling 3–15s, Omni Flash 3–
|
|
5537
|
+
// model-id ternary. (Kling 3–15s, Omni Flash 1.2 3–15s, Seedance 2.5 4–30s.)
|
|
5409
5538
|
const { min: minClipSeconds, max: maxClipSeconds } = editClipBounds(model);
|
|
5410
5539
|
if (!EDIT_VIDEO_ELEMENT_MODELS.includes(model) && ((input.characterAssetIds?.length ?? 0) > 0 || (input.styleAssetIds?.length ?? 0) > 0)) {
|
|
5411
5540
|
throw new Error(`${model} takes the prompt and the source clip only on this op — no character/style reference images. Drop the refs, or switch to ${EDIT_VIDEO_ELEMENT_MODELS.join(' or ')}, which take them.`);
|
|
@@ -5443,6 +5572,9 @@ export const editVideo = {
|
|
|
5443
5572
|
(maxClipSeconds < SEEDANCE_25_EDIT_MAX_SECONDS ? ', or switch to seedance-2.5-edit which accepts up to 30s' : '') +
|
|
5444
5573
|
'.');
|
|
5445
5574
|
}
|
|
5575
|
+
// A desktop without Omni Flash 1.2 gets the 1.1 edit seat at the same price, on a clip 1.1 takes
|
|
5576
|
+
// (`desktopModelId`), resolved before the quote so a job it cannot run is refused before the agent confirms it.
|
|
5577
|
+
const seat = await desktopModelId(desktop, model, `${model} editing`, clipSeconds);
|
|
5446
5578
|
const billedSeconds = Math.min(maxClipSeconds, Math.max(minClipSeconds, Math.ceil(clipSeconds - 0.05)));
|
|
5447
5579
|
// Three engines, three key shapes — only Seedance's carries a resolution and
|
|
5448
5580
|
// a face route, because only its price moves with them.
|
|
@@ -5456,7 +5588,7 @@ export const editVideo = {
|
|
|
5456
5588
|
seedanceFace: input.seedanceFace === true,
|
|
5457
5589
|
})
|
|
5458
5590
|
: isOmniFlashEdit
|
|
5459
|
-
? omniFlashEditCostKey(billedSeconds, (input.videoResolution ?? defaultVideoResolutionFor('omni-flash-edit')))
|
|
5591
|
+
? omniFlashEditCostKey(billedSeconds, (input.videoResolution ?? defaultVideoResolutionFor('omni-flash-1-2-edit')))
|
|
5460
5592
|
: klingEditCostKey(model, billedSeconds);
|
|
5461
5593
|
const cloud = ctx.cloud();
|
|
5462
5594
|
const registry = await cloud.get('/api/agent/models');
|
|
@@ -5491,7 +5623,7 @@ export const editVideo = {
|
|
|
5491
5623
|
}
|
|
5492
5624
|
const result = await desktop.post('/agent/generation/edit-video', {
|
|
5493
5625
|
projectId: input.projectId,
|
|
5494
|
-
model,
|
|
5626
|
+
model: seat.model,
|
|
5495
5627
|
prompt: input.prompt,
|
|
5496
5628
|
sourceVideoAssetId: sourceId,
|
|
5497
5629
|
characterAssetIds,
|
|
@@ -5508,20 +5640,23 @@ export const editVideo = {
|
|
|
5508
5640
|
const ids = result.generationId ? [result.generationId] : [];
|
|
5509
5641
|
return backgroundSubmitted(`${billedSeconds}s video edit (${model})`, ids, {
|
|
5510
5642
|
model,
|
|
5643
|
+
...(seat.note ? { ranOn: seat.model } : {}),
|
|
5511
5644
|
variant: costKey,
|
|
5512
5645
|
projectId: input.projectId,
|
|
5513
5646
|
sourceVideoAssetId: sourceId,
|
|
5514
5647
|
cost_cents: totalCents,
|
|
5515
5648
|
cost_credits: totalCents,
|
|
5516
|
-
}, refEcho);
|
|
5649
|
+
}, [refEcho, seat.note].filter(Boolean).join(' '));
|
|
5517
5650
|
}
|
|
5518
5651
|
return {
|
|
5519
5652
|
text: `Edited ${billedSeconds}s clip saved as a new asset in project ${input.projectId} ` +
|
|
5520
5653
|
`for ${fmtCredits(totalCents)} via ${model}. ` +
|
|
5521
5654
|
`Edit: "${input.prompt.slice(0, 60)}${input.prompt.length > 60 ? '...' : ''}"` +
|
|
5522
|
-
(refEcho ? ` ${refEcho}` : '')
|
|
5655
|
+
(refEcho ? ` ${refEcho}` : '') +
|
|
5656
|
+
(seat.note ? ` ${seat.note}` : ''),
|
|
5523
5657
|
data: {
|
|
5524
5658
|
model,
|
|
5659
|
+
...(seat.note ? { ranOn: seat.model } : {}),
|
|
5525
5660
|
variant: costKey,
|
|
5526
5661
|
projectId: input.projectId,
|
|
5527
5662
|
sourceVideoAssetId: sourceId,
|
|
@@ -7397,13 +7532,15 @@ export const breakDownReference = {
|
|
|
7397
7532
|
throw new Error('Give exactly one of assetId (a video or picture in the project), filePath or url.');
|
|
7398
7533
|
}
|
|
7399
7534
|
const assetId = input.assetId ? (await resolveAssetRefs(ctx, input.projectId, [input.assetId])).get(input.assetId).id : input.assetId;
|
|
7400
|
-
|
|
7535
|
+
// Every Shot is stored under this id, as the desktop knows it (`desktopModelId`).
|
|
7536
|
+
const seat = await desktopModelId(ctx.desktop(), input.model, `a breakdown's Shots on ${input.model}`);
|
|
7537
|
+
const r = await ctx.desktop().post('/agent/reference/breakdown', { ...input, assetId, model: seat.model, cancel: undefined });
|
|
7401
7538
|
const cuts = r.breakdown.segments.length;
|
|
7402
7539
|
const fetched = r.source ? `Fetched the ${r.source.kind === 'meta' ? 'Meta Ad Library ad' : 'video link'} into Media as ${r.breakdown.sourceCode ?? 'a video'}. ` : '';
|
|
7403
7540
|
const head = r.board
|
|
7404
7541
|
? `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(' ')}` : ''}`
|
|
7405
7542
|
: `${cuts} cut${cuts === 1 ? '' : 's'} found in ${r.breakdown.sourceCode ?? 'the reference'}; frames saved, no board yet.`;
|
|
7406
|
-
return ok(r, `${fetched}${head} ${JSON.stringify(r)}`);
|
|
7543
|
+
return ok(r, `${seat.note ? `${seat.note} ` : ''}${fetched}${head} ${JSON.stringify(r)}`);
|
|
7407
7544
|
},
|
|
7408
7545
|
};
|
|
7409
7546
|
// ── Product intake ──────────────────────────────────────────────────────
|
|
@@ -7842,6 +7979,8 @@ function shotRefInputs(input) {
|
|
|
7842
7979
|
* something else entirely.
|
|
7843
7980
|
*/
|
|
7844
7981
|
async function buildShotSpecInput(ctx, projectId, input) {
|
|
7982
|
+
// The Shot is stored and drafted on the desktop under this id (`desktopModelId`).
|
|
7983
|
+
const seat = await desktopModelId(ctx.desktop(), input.model, `a Shot on ${input.model}`, input.params?.duration);
|
|
7845
7984
|
const refInputs = shotRefInputs(input);
|
|
7846
7985
|
const resolvedRefs = await resolveAssetRefs(ctx, projectId, refInputs.map((r) => r.ref));
|
|
7847
7986
|
const rid = (v) => (v ? (resolvedRefs.get(v)?.id ?? v) : null);
|
|
@@ -7862,11 +8001,11 @@ async function buildShotSpecInput(ctx, projectId, input) {
|
|
|
7862
8001
|
return {
|
|
7863
8002
|
spec: {
|
|
7864
8003
|
prompt: input.prompt,
|
|
7865
|
-
model:
|
|
8004
|
+
model: seat.model ?? null,
|
|
7866
8005
|
// The prompt is recorded as written FOR this model. Swapping the model
|
|
7867
8006
|
// later diverges from it and the desktop card says so — the prompt is
|
|
7868
8007
|
// never rewritten (that is prompt enhancement, deleted 2026-08-01).
|
|
7869
|
-
authoredFor:
|
|
8008
|
+
authoredFor: seat.model ?? null,
|
|
7870
8009
|
params: {
|
|
7871
8010
|
...shotParamsPatch(input.params),
|
|
7872
8011
|
...(input.params?.voiceReferenceAssetId ? { voiceReferenceAssetId: rid(input.params.voiceReferenceAssetId) } : {}),
|
|
@@ -7882,6 +8021,7 @@ async function buildShotSpecInput(ctx, projectId, input) {
|
|
|
7882
8021
|
audioRefSpokenText: spoken,
|
|
7883
8022
|
},
|
|
7884
8023
|
refEcho: describeResolvedRefs(refInputs, resolvedRefs),
|
|
8024
|
+
seatNote: seat.note,
|
|
7885
8025
|
};
|
|
7886
8026
|
}
|
|
7887
8027
|
/**
|
|
@@ -7894,7 +8034,8 @@ function namedSpecPatch(input, spec) {
|
|
|
7894
8034
|
if (input.prompt !== undefined)
|
|
7895
8035
|
patch.prompt = input.prompt;
|
|
7896
8036
|
if (input.model !== undefined) {
|
|
7897
|
-
|
|
8037
|
+
// The built id: the one this desktop knows (`desktopModelId`).
|
|
8038
|
+
patch.model = spec.model;
|
|
7898
8039
|
// 🚨 `authoredFor` is NOT re-stamped on a model swap. The whole point of
|
|
7899
8040
|
// recording it is that the prompt stays written for the model it was
|
|
7900
8041
|
// written for — the grammars genuinely differ — so the card can say so.
|
|
@@ -8008,7 +8149,7 @@ export const createShot = {
|
|
|
8008
8149
|
// 1.5.8 ignores `position` and files the Shot last.
|
|
8009
8150
|
if (input.position !== undefined)
|
|
8010
8151
|
await desktop.requireCapability('shot-position', 'placing a new Shot at a slot');
|
|
8011
|
-
const { spec, refEcho } = await buildShotSpecInput(ctx, input.projectId, input);
|
|
8152
|
+
const { spec, refEcho, seatNote } = await buildShotSpecInput(ctx, input.projectId, input);
|
|
8012
8153
|
const r = await desktop.post('/agent/shots', {
|
|
8013
8154
|
projectId: input.projectId,
|
|
8014
8155
|
name: input.name,
|
|
@@ -8038,7 +8179,7 @@ export const createShot = {
|
|
|
8038
8179
|
});
|
|
8039
8180
|
// The CODE is the address the user sees on the row — say it back so the
|
|
8040
8181
|
// next call, and the next sentence to the user, can point at it.
|
|
8041
|
-
return ok(r.shot, `${r.shot?.code || 'Shot'} — "${r.shot?.name || 'Untitled'}". ${refEcho}${fromNote}`.trim() + varietyNote);
|
|
8182
|
+
return ok(r.shot, `${r.shot?.code || 'Shot'} — "${r.shot?.name || 'Untitled'}". ${refEcho}${fromNote}${seatNote ? ` ${seatNote}` : ''}`.trim() + varietyNote);
|
|
8042
8183
|
},
|
|
8043
8184
|
};
|
|
8044
8185
|
/**
|
|
@@ -8104,7 +8245,7 @@ export const updateShot = {
|
|
|
8104
8245
|
return alignErr;
|
|
8105
8246
|
const desktop = ctx.desktop();
|
|
8106
8247
|
await desktop.requireCapability('shots', 'saved Shots');
|
|
8107
|
-
const { spec } = await buildShotSpecInput(ctx, input.projectId, input);
|
|
8248
|
+
const { spec, seatNote } = await buildShotSpecInput(ctx, input.projectId, input);
|
|
8108
8249
|
// Only send the halves the caller actually named; the route merges a PARTIAL
|
|
8109
8250
|
// spec over the stored one, so an omitted field is never silently cleared.
|
|
8110
8251
|
const patch = namedSpecPatch(input, spec);
|
|
@@ -8121,7 +8262,7 @@ export const updateShot = {
|
|
|
8121
8262
|
// An edit to framing changes the counts, and the agent read them BEFORE it
|
|
8122
8263
|
// (agent eval round 11: two runs fixed a repeat and never saw the new counts).
|
|
8123
8264
|
const varietyNote = await boardSoFar(desktop, { projectId: input.projectId, shotId: r.shot?.id });
|
|
8124
|
-
return ok(r.shot, JSON.stringify(r.shot) + varietyNote);
|
|
8265
|
+
return ok(r.shot, JSON.stringify(r.shot) + (seatNote ? `\n${seatNote}` : '') + varietyNote);
|
|
8125
8266
|
},
|
|
8126
8267
|
};
|
|
8127
8268
|
export const duplicateShot = {
|
|
@@ -8146,8 +8287,9 @@ export const duplicateShot = {
|
|
|
8146
8287
|
const spec = {};
|
|
8147
8288
|
if (input.prompt !== undefined)
|
|
8148
8289
|
spec.prompt = input.prompt;
|
|
8290
|
+
const seat = await desktopModelId(desktop, input.model, `a Shot on ${input.model}`, input.params?.duration);
|
|
8149
8291
|
if (input.model !== undefined)
|
|
8150
|
-
spec.model =
|
|
8292
|
+
spec.model = seat.model;
|
|
8151
8293
|
if (input.params !== undefined) {
|
|
8152
8294
|
const voiceRef = input.params.voiceReferenceAssetId;
|
|
8153
8295
|
if (voiceRef && !UUID_RE.test(voiceRef)) {
|
|
@@ -8165,7 +8307,7 @@ export const duplicateShot = {
|
|
|
8165
8307
|
...(Object.keys(spec).length > 0 ? { spec } : {}),
|
|
8166
8308
|
frameId: input.frameId,
|
|
8167
8309
|
});
|
|
8168
|
-
return ok(r.shot, `Forked into "${r.shot?.name || 'Untitled'}"
|
|
8310
|
+
return ok(r.shot, `Forked into "${r.shot?.name || 'Untitled'}".${seat.note ? ` ${seat.note}` : ''}`);
|
|
8169
8311
|
},
|
|
8170
8312
|
};
|
|
8171
8313
|
/**
|
|
@@ -8736,8 +8878,9 @@ export const generateFromShots = {
|
|
|
8736
8878
|
await desktop.requireCapability('board-quote', 'Shot prices');
|
|
8737
8879
|
// Resolved first so a SHOT-A code fails here, not halfway through a billed run.
|
|
8738
8880
|
const details = await Promise.all(input.shotIds.map((id) => desktop.get('/agent/shots/get', { id })));
|
|
8881
|
+
const { draft, note: seatNote } = await desktopDraft(desktop, input.draft);
|
|
8739
8882
|
const quote = await desktop.get('/agent/shots/quote', {
|
|
8740
|
-
input: JSON.stringify({ projectId: details[0].shot.projectId, shotIds: details.map((d) => d.shot.id), draft
|
|
8883
|
+
input: JSON.stringify({ projectId: details[0].shot.projectId, shotIds: details.map((d) => d.shot.id), draft }),
|
|
8741
8884
|
});
|
|
8742
8885
|
for (const model of new Set(quote.items.map((i) => i.model)))
|
|
8743
8886
|
requireGuideRead(ctx, model);
|
|
@@ -8753,13 +8896,15 @@ export const generateFromShots = {
|
|
|
8753
8896
|
// Printed, not only in `data`: a client without elicitation reads this text
|
|
8754
8897
|
// alone, and the confirm step refuses without the fingerprint (agent eval, round 9).
|
|
8755
8898
|
`\nfingerprint: ${quote.fingerprint}` +
|
|
8756
|
-
'\nGet approval for these prices, then pass this fingerprint with confirm: true.'
|
|
8899
|
+
'\nGet approval for these prices, then pass this fingerprint with confirm: true.' +
|
|
8900
|
+
(seatNote ? `\n${seatNote}` : ''));
|
|
8757
8901
|
}
|
|
8758
|
-
|
|
8902
|
+
const ran = await desktop.post('/agent/shots/batch-generate', {
|
|
8759
8903
|
shotIds: quote.items.map((i) => i.shotId),
|
|
8760
8904
|
fingerprint: quote.fingerprint,
|
|
8761
|
-
draft
|
|
8762
|
-
})
|
|
8905
|
+
draft,
|
|
8906
|
+
});
|
|
8907
|
+
return seatNote ? ok(ran, `${JSON.stringify(ran)}\n${seatNote}`) : ok(ran);
|
|
8763
8908
|
},
|
|
8764
8909
|
};
|
|
8765
8910
|
export const quoteBoard = {
|
|
@@ -8774,8 +8919,11 @@ export const quoteBoard = {
|
|
|
8774
8919
|
draft: DRAFT_INPUT.describe('Generate previews: pass {} to price one picture for each Shot in scope with no picture, instead of each Shot recipe.'),
|
|
8775
8920
|
}),
|
|
8776
8921
|
async run(input, ctx) {
|
|
8777
|
-
|
|
8778
|
-
|
|
8922
|
+
const desktop = ctx.desktop();
|
|
8923
|
+
await desktop.requireCapability('board-quote', 'the board prices');
|
|
8924
|
+
const { draft, note } = await desktopDraft(desktop, input.draft);
|
|
8925
|
+
const quote = await desktop.get('/agent/shots/quote', { input: JSON.stringify({ ...input, draft }) });
|
|
8926
|
+
return note ? ok(quote, `${JSON.stringify(quote)}\n${note}`) : ok(quote);
|
|
8779
8927
|
},
|
|
8780
8928
|
};
|
|
8781
8929
|
export const getBoardProgress = {
|
|
@@ -8913,7 +9061,7 @@ export function resolveGuideTopic(topic) {
|
|
|
8913
9061
|
if (t.startsWith('nano-banana'))
|
|
8914
9062
|
return 'slates-prompting-nano-banana-2-1';
|
|
8915
9063
|
if (t === 'sunburst' || t === 'flare' || t.startsWith('gpt-image') || t.startsWith('gpt image'))
|
|
8916
|
-
return 'slates-prompting-gpt-image-2-
|
|
9064
|
+
return 'slates-prompting-gpt-image-2-6';
|
|
8917
9065
|
if (t.startsWith('flux'))
|
|
8918
9066
|
return 'slates-prompting-flux-3';
|
|
8919
9067
|
if (t.startsWith('seedream'))
|
|
@@ -9017,6 +9165,35 @@ function editDistance(a, b) {
|
|
|
9017
9165
|
}
|
|
9018
9166
|
return d[a.length][b.length];
|
|
9019
9167
|
}
|
|
9168
|
+
/**
|
|
9169
|
+
* The seat that replaced a retired model a topic names, or null. The topic is a model id or a guide name
|
|
9170
|
+
* (`gpt-image-2-5-sunburst`, `gpt-image-2-5`, `slates-prompting-gpt-image-2-5`); it names a retired model
|
|
9171
|
+
* when it is a retired id, or a stem of retired ids that no current id shares (`gpt-image-2-5`, never
|
|
9172
|
+
* `flux` or `nano-banana`). The guide op serves the replacement's guide and says so first, as it does for
|
|
9173
|
+
* a typo: an agent asking for the 2.5 guide learns 2.5 is gone, not that 2.6 is what it asked for.
|
|
9174
|
+
*
|
|
9175
|
+
* A stem covering several seats names their family (`gpt-image-2-6`), never one of them. A topic under the
|
|
9176
|
+
* stem of its replacement's own guide is that guide, not a retired model: `omni-flash` is the retired 1.1 id
|
|
9177
|
+
* and also the name of the live `slates-prompting-omni-flash`, so it and `omni-flash-edit` are null.
|
|
9178
|
+
*/
|
|
9179
|
+
export function retiredModelOfTopic(topic) {
|
|
9180
|
+
const core = topic.trim().toLowerCase().replace(/^(slates-)?prompting-/, '');
|
|
9181
|
+
const under = (id) => id === core || id.startsWith(`${core}-`);
|
|
9182
|
+
const retiredIds = Object.hasOwn(RETIRED_MODELS, core) ? [core]
|
|
9183
|
+
: Object.keys(MODEL_CAPABILITIES).some(under) ? []
|
|
9184
|
+
: Object.keys(RETIRED_MODELS).filter(under);
|
|
9185
|
+
if (retiredIds.length === 0)
|
|
9186
|
+
return null;
|
|
9187
|
+
const seats = [...new Set(retiredIds.map(id => RETIRED_MODELS[id]))].map(id => id.split('-'));
|
|
9188
|
+
let common = 0;
|
|
9189
|
+
while (common < seats[0].length && seats.every(seat => seat[common] === seats[0][common]))
|
|
9190
|
+
common++;
|
|
9191
|
+
const replacement = seats[0].slice(0, common || seats[0].length).join('-');
|
|
9192
|
+
const stem = resolveGuideTopic(replacement)?.replace(/^slates-prompting-/, '');
|
|
9193
|
+
if (stem && (core === stem || core.startsWith(`${stem}-`)))
|
|
9194
|
+
return null;
|
|
9195
|
+
return { retired: core, replacement };
|
|
9196
|
+
}
|
|
9020
9197
|
/**
|
|
9021
9198
|
* The one guide a near-miss name means: the name without its `slates-` prefix, or a typo of one name
|
|
9022
9199
|
* ("slaes-direct-response-ad"). Two names equally close come back as `tied`, for the caller to name rather
|
|
@@ -9157,6 +9334,14 @@ export const getPromptingGuide = {
|
|
|
9157
9334
|
const guide = `${hyperframesGuideHeader(hf.key)}${body}${others.length ? `\n\nIts other files (request each as a topic): ${others.join(', ')}` : ''}`;
|
|
9158
9335
|
return { text: guide, data: { topic: hf.key, tier: 'free', source: 'motion', depth, bytes: Buffer.byteLength(guide, 'utf8'), guide } };
|
|
9159
9336
|
}
|
|
9337
|
+
// A retired model serves its replacement's guide, said first (retiredModelOfTopic).
|
|
9338
|
+
const retiredTopic = topic && !Object.hasOwn(brain.skills, topic) ? retiredModelOfTopic(topic) : null;
|
|
9339
|
+
const replacementGuide = retiredTopic ? resolveGuideTopic(retiredTopic.replacement) : null;
|
|
9340
|
+
// Never back to the topic asked: a replacement guide that is the asked topic falls through to it.
|
|
9341
|
+
if (retiredTopic && replacementGuide && replacementGuide !== topic) {
|
|
9342
|
+
const served = await getPromptingGuide.run({ ...input, topic: replacementGuide }, ctx);
|
|
9343
|
+
return { ...served, text: `${retiredTopic.retired} is retired and ${retiredTopic.replacement} replaced it: served ${replacementGuide}.\n\n${served.text}` };
|
|
9344
|
+
}
|
|
9160
9345
|
// The user's file by its exact name wins over an alias (their `flux-portraits` is theirs, not the FLUX guide);
|
|
9161
9346
|
// the router's names are reserved in the loader, so none of them reaches here as a local file. A name missing
|
|
9162
9347
|
// its `slates-` prefix is that guide, resolved here so it never waits on the member check.
|