@slatesvideo/shared 0.7.23 → 0.7.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ export declare const CONFIRM_CREDITS = 17;
2
+ //# sourceMappingURL=confirm-threshold.d.ts.map
@@ -0,0 +1,2 @@
1
+ export const CONFIRM_CREDITS = 17;
2
+ //# sourceMappingURL=confirm-threshold.js.map
@@ -24,13 +24,19 @@ export interface OperationContext {
24
24
  */
25
25
  signal?: AbortSignal;
26
26
  /**
27
- * The guides this session has read through `slates_get_prompting_guide`, by
28
- * guide name. Present, it gates every generation: a model whose guide is not
29
- * in it is refused, with the guide's card, before anything is spent
30
- * (`requireGuideRead`). The MCP server keeps one per connection and the
31
- * desktop one per chat. Absent (the CLI, one call per process), no gate.
27
+ * Guides or cards opened by name. MCP keeps them per connection and the desktop
28
+ * per chat. Hosts also supply guide evidence for the estimate and full-guide paths.
29
+ * CLI calls carry no session ledger.
32
30
  */
33
31
  guidesRead?: Set<string>;
32
+ /** Guide evidence from tool results that reached this session. A rejection requires the full guide. */
33
+ guideEvidence?: {
34
+ cards: Set<string>;
35
+ full: Set<string>;
36
+ rejected: Set<string>;
37
+ };
38
+ onGenerationGuide?: (topic: string) => void;
39
+ onGenerationRejected?: () => void;
34
40
  /**
35
41
  * The host's own spending decision for this one call, where the host has one (the desktop Studio Agent's loop):
36
42
  * the credits the user approved beyond the call's own quote, the quote they approved (its `fingerprint`), and
@@ -62,8 +68,13 @@ export declare class GuideNotReadError extends Error {
62
68
  readonly model: string;
63
69
  readonly guide: string;
64
70
  code: string;
65
- constructor(model: string, guide: string);
71
+ constructor(model: string, guide: string, full?: boolean);
66
72
  }
73
+ /**
74
+ * Routine calls can use a delivered estimate card. Other calls and retries need the full guide.
75
+ * A locked guide's returned notice counts as the most this account can read.
76
+ */
77
+ export declare function recordGenerationRejection(ctx: Pick<OperationContext, 'guideEvidence'>, fallbackOp: string, model: unknown, topics?: ReadonlySet<string>): void;
67
78
  export interface OperationResult {
68
79
  text: string;
69
80
  images?: Array<{
@@ -138,8 +149,8 @@ export interface OperationAnnotations {
138
149
  openWorldHint: boolean;
139
150
  }
140
151
  export type OperationTier = 'core' | 'extended';
141
- export type OperationGroup = 'script' | 'library' | 'timeline' | 'admin' | 'blender';
142
- export declare const CONFIRM_CREDITS = 17;
152
+ export type OperationGroup = 'script' | 'library' | 'timeline' | 'admin' | 'blender' | 'ads';
153
+ export { CONFIRM_CREDITS } from './confirm-threshold.js';
143
154
  /**
144
155
  * The desktop deviation guard's ceiling multiplier: the Studio Agent pauses and
145
156
  * re-asks when projected generation spend exceeds the approved ledger by more
@@ -1813,12 +1824,12 @@ declare const variantSlotsInput: z.ZodObject<{
1813
1824
  }, "strict", z.ZodTypeAny, {
1814
1825
  projectId: string;
1815
1826
  action: "add" | "update" | "remove" | "add-alternative" | "update-alternative" | "remove-alternative";
1827
+ name?: string | undefined;
1816
1828
  timelineId?: string | undefined;
1817
1829
  at?: number | undefined;
1818
1830
  slotId?: string | undefined;
1819
1831
  slotName?: string | undefined;
1820
1832
  alternativeId?: string | undefined;
1821
- name?: string | undefined;
1822
1833
  orderIndex?: number | undefined;
1823
1834
  bedFrame?: number | null | undefined;
1824
1835
  clipIds?: string[] | undefined;
@@ -1826,12 +1837,12 @@ declare const variantSlotsInput: z.ZodObject<{
1826
1837
  }, {
1827
1838
  projectId: string;
1828
1839
  action: "add" | "update" | "remove" | "add-alternative" | "update-alternative" | "remove-alternative";
1840
+ name?: string | undefined;
1829
1841
  timelineId?: string | undefined;
1830
1842
  at?: number | undefined;
1831
1843
  slotId?: string | undefined;
1832
1844
  slotName?: string | undefined;
1833
1845
  alternativeId?: string | undefined;
1834
- name?: string | undefined;
1835
1846
  orderIndex?: number | undefined;
1836
1847
  bedFrame?: number | null | undefined;
1837
1848
  clipIds?: string[] | undefined;
@@ -1911,8 +1922,8 @@ declare const variantsInput: z.ZodObject<{
1911
1922
  }, "strict", z.ZodTypeAny, {
1912
1923
  projectId: string;
1913
1924
  action: "add" | "update" | "remove" | "rebuild";
1914
- timelineId?: string | undefined;
1915
1925
  name?: string | undefined;
1926
+ timelineId?: string | undefined;
1916
1927
  variantId?: string | undefined;
1917
1928
  combinations?: boolean | undefined;
1918
1929
  choices?: Record<string, string> | undefined;
@@ -1937,8 +1948,8 @@ declare const variantsInput: z.ZodObject<{
1937
1948
  }, {
1938
1949
  projectId: string;
1939
1950
  action: "add" | "update" | "remove" | "rebuild";
1940
- timelineId?: string | undefined;
1941
1951
  name?: string | undefined;
1952
+ timelineId?: string | undefined;
1942
1953
  variantId?: string | undefined;
1943
1954
  combinations?: boolean | undefined;
1944
1955
  choices?: Record<string, string> | undefined;
@@ -1,3 +1,4 @@
1
+ import { CONFIRM_CREDITS } from './confirm-threshold.js';
1
2
  import { randomUUID } from 'node:crypto';
2
3
  import { MAX_IMAGE_VARIATIONS, SHEET_TOOL_ASPECT_RATIO, SHEET_TOOL_GPT_QUALITY } from '../prompts/generation-policy.js';
3
4
  import { STYLE_LIBRARY, DEFAULT_STYLE_ID } from '../prompts/style-library.js';
@@ -57,6 +58,7 @@ import { describeBannedTokens, bannedTokenWarning, describeBannedTokensForSkill,
57
58
  // that make a shot good rather than merely un-bad — and it rides the estimate
58
59
  // RESULT, which the doctrine already makes the agent call before generating.
59
60
  // Zero prefix bytes, present at the moment the model has just been named.
61
+ import { hasReferenceMention } from '../prompts/reference-composer.js';
60
62
  import { describeCraftCard } from '../prompts/craft-cards.js';
61
63
  // ONE captioning rule for a generated asset, shared with the desktop gallery.
62
64
  import { assetCaption } from '../prompts/asset-label.js';
@@ -95,35 +97,62 @@ export class GuideNotReadError extends Error {
95
97
  model;
96
98
  guide;
97
99
  code = 'GUIDE_NOT_READ';
98
- constructor(model, guide) {
100
+ constructor(model, guide, full = false) {
101
+ const request = `topic "${guide}"${full ? ' and depth "full"' : ''}`;
99
102
  const head = `Refused: this session has not read ${guide}, the guide for ${model}. Nothing was generated or charged. `;
100
103
  const body = brainSkills().skills[guide];
101
104
  const served = servedBrain();
102
105
  const locked = body === undefined ? served.locked.find(entry => entry.name === guide) : undefined;
103
106
  super(body !== undefined
104
107
  ? head +
105
- `Call slates_get_prompting_guide with topic "${guide}", rewrite the prompt against it, then call this again. Its card:\n\n` +
108
+ `Call slates_get_prompting_guide with ${request}, rewrite the prompt against it, then call this again. Its card:\n\n` +
106
109
  // The card this user's brain serves, so a model guide from their My brain is the one in the refusal.
107
110
  describeCraftCard(guide, body)
108
111
  : locked
109
112
  ? // Past this account's tier: no body here, so the server's notice (its card included) is what it reads.
110
113
  head +
111
- `Call slates_get_prompting_guide with topic "${guide}", rewrite the prompt against what it says, then call this again. What it says:\n\n` +
114
+ `Call slates_get_prompting_guide with ${request}, rewrite the prompt against what it says, then call this again. What it says:\n\n` +
112
115
  (locked.notice ?? `${guide} is not open to this account. Run the job on the general rules.`)
113
116
  : // No copy here and none locked: the brain never arrived, so asking for the guide again cannot help.
114
117
  head +
115
118
  `The guide comes from the connected Slates account and is not on this machine (${served.problem ?? 'no brain received yet'}). ` +
116
- `${CONNECT_FOR_BRAIN}; then call slates_get_prompting_guide with topic "${guide}" and call this again.`);
119
+ `${CONNECT_FOR_BRAIN}; then call slates_get_prompting_guide with ${request} and call this again.`);
117
120
  this.model = model;
118
121
  this.guide = guide;
119
122
  }
120
123
  }
121
- /** Refuse the generation when the session keeps a ledger and `model`'s guide is not in it. A seat with no model id names its guide. */
122
- function requireGuideRead(ctx, model, guide = model ? resolveGuideTopic(model) : null) {
123
- if (!ctx?.guidesRead || !model)
124
+ /**
125
+ * Routine calls can use a delivered estimate card. Other calls and retries need the full guide.
126
+ * A locked guide's returned notice counts as the most this account can read.
127
+ */
128
+ export function recordGenerationRejection(ctx, fallbackOp, model, topics = new Set()) {
129
+ const rejected = ctx.guideEvidence?.rejected;
130
+ if (!rejected)
131
+ return;
132
+ if (topics.size) {
133
+ for (const topic of topics)
134
+ rejected.add(topic);
135
+ }
136
+ else {
137
+ rejected.add((typeof model === 'string' && resolveGuideTopic(model)) || fallbackOp);
138
+ }
139
+ }
140
+ function requireGuideRead(ctx, model, guide = model ? resolveGuideTopic(model) : null, routineOp) {
141
+ if (!ctx || !model || !guide)
124
142
  return;
125
- if (guide && !ctx.guidesRead.has(guide))
126
- throw new GuideNotReadError(model, guide);
143
+ ctx.onGenerationGuide?.(guide);
144
+ if (!ctx.guidesRead)
145
+ return;
146
+ const evidence = ctx.guideEvidence;
147
+ if (!evidence) {
148
+ if (!ctx.guidesRead.has(guide))
149
+ throw new GuideNotReadError(model, guide);
150
+ return;
151
+ }
152
+ const full = !routineOp || evidence.rejected.has(guide) || evidence.rejected.has(routineOp);
153
+ if (evidence.full.has(guide) || (!full && (evidence.cards.has(guide) || ctx.guidesRead.has(guide))))
154
+ return;
155
+ throw new GuideNotReadError(model, guide, full);
127
156
  }
128
157
  /** Throw if the caller has cancelled. Call between billable items, never inside one. */
129
158
  function throwIfCancelled(ctx, detail) {
@@ -172,7 +201,7 @@ function ok(data, text) {
172
201
  // the same credit value); balances the same. Read via creditCost(); display
173
202
  // via fmtCredits(). The confirm gate fires above CONFIRM_CREDITS (≈ the old
174
203
  // $0.50 gate at the 3¢/credit peg).
175
- export const CONFIRM_CREDITS = 17;
204
+ export { CONFIRM_CREDITS } from './confirm-threshold.js';
176
205
  const CENTS_PER_CREDIT = 3; // peg: 1 credit = 3¢ billed = 2¢ COGS (mirror of slates-api)
177
206
  /**
178
207
  * The desktop deviation guard's ceiling multiplier: the Studio Agent pauses and
@@ -2076,6 +2105,32 @@ export const estimateGenerationCost = {
2076
2105
  });
2077
2106
  }
2078
2107
  }
2108
+ // 3b) 5s-block tool keys (motion transfer & lip-sync): accept both dynamic
2109
+ // block keys (`kling-mc-std-10s`) and base stem + duration (`kling-mc-std`, 10).
2110
+ // Query the cloud's dynamic costKey endpoint first; fall back to scaling the
2111
+ // registry's 5s block row when a static price list does not synthesize rows.
2112
+ if (!key && !input.seedanceDraft) {
2113
+ const toolKeyMatch = /^(kling-lip-sync-(?:video|avatar|avatar-pro)|kling-mc-(?:std|pro))(?:-(?:(\d+)s))?$/.exec(input.model);
2114
+ if (toolKeyMatch) {
2115
+ const stem = toolKeyMatch[1];
2116
+ const secs = toolKeyMatch[2] ? Number(toolKeyMatch[2]) : input.duration;
2117
+ if (!secs) {
2118
+ return ok({
2119
+ requires_clarification: true,
2120
+ missing: ['duration'],
2121
+ message: `${stem} bills per 5-second block of the driving clip — pass duration in seconds (or a block key like ${stem}-10s).`,
2122
+ });
2123
+ }
2124
+ const blocks = Math.max(1, toolBlocks(secs));
2125
+ key = toolBlockKey(stem, blocks);
2126
+ await loadDynamicPrice(ctx, byKey, key);
2127
+ if (!byKey.has(key)) {
2128
+ const oneBlock = byKey.get(toolBlockKey(stem, 1));
2129
+ if (oneBlock != null)
2130
+ byKey.set(key, oneBlock * blocks);
2131
+ }
2132
+ }
2133
+ }
2079
2134
  await loadDynamicPrice(ctx, byKey, key);
2080
2135
  const perCredits = key != null ? byKey.get(key) : undefined;
2081
2136
  if (key != null && perCredits == null && key !== input.model) {
@@ -3492,7 +3547,8 @@ export const generateImage = {
3492
3547
  // A desktop before the folder rule ignores folderId and files at the root.
3493
3548
  if (input.folderId !== undefined)
3494
3549
  await ctx.desktop().requireCapability('media-folder', 'choosing the folder a result lands in');
3495
- requireGuideRead(ctx, imageModel);
3550
+ const multiReference = (input.referenceAssetIds?.length ?? 0) + (input.referenceImageUrls?.length ?? 0) > 1;
3551
+ requireGuideRead(ctx, imageModel, undefined, !multiReference && !hasReferenceMention(input.prompt) && (input.count ?? 1) === 1 ? generateImage.id : undefined);
3496
3552
  const promptWarning = bannedTokenWarning(input.prompt, 'image', promptingSkillFor(imageModel));
3497
3553
  input = { ...input, resolution: input.resolution ?? defaultImageResolutionFor(imageModel) };
3498
3554
  if (!input.aspectRatio || !input.resolution) {
@@ -4814,7 +4870,12 @@ export const generateVideo = {
4814
4870
  }
4815
4871
  if (input.seedanceDraft)
4816
4872
  input.videoResolution = draftResolution(input.model, input.videoResolution ?? resolved.videoResolution);
4817
- requireGuideRead(ctx, input.model);
4873
+ const imageRefs = (input.firstFrameAssetId ? 1 : 0) + (input.lastFrameAssetId ? 1 : 0) +
4874
+ (input.ingredientAssetIds?.length ?? 0) + (input.characterAssetIds?.length ?? 0) +
4875
+ (input.environmentAssetIds?.length ?? 0) + (input.styleAssetIds?.length ?? 0);
4876
+ const sceneReference = input.videoReferenceAssetId || input.videoReferenceAssetIds?.length ||
4877
+ input.audioReferenceAssetId || input.audioReferenceAssetIds?.length;
4878
+ requireGuideRead(ctx, input.model, undefined, imageRefs <= 1 && !input.lastFrameAssetId && !sceneReference && !hasReferenceMention(input.prompt ?? '') ? generateVideo.id : undefined);
4818
4879
  if (input.duration == null && resolved.duration != null)
4819
4880
  input.duration = resolved.duration;
4820
4881
  if (input.videoResolution == null && resolved.videoResolution != null)
@@ -5538,7 +5599,8 @@ export const generateAudio = {
5538
5599
  folderId: folderIdField,
5539
5600
  }),
5540
5601
  run: async (input, ctx) => {
5541
- requireGuideRead(ctx, input.model);
5602
+ const multiReference = (input.audioReferenceAssetIds?.length ?? 0) + (input.imageReferenceAssetId ? 1 : 0) > 1;
5603
+ requireGuideRead(ctx, input.model, undefined, multiReference ? undefined : generateAudio.id);
5542
5604
  const lengthError = promptLengthError(input.model, input.prompt);
5543
5605
  if (lengthError)
5544
5606
  throw new Error(lengthError);
@@ -6339,7 +6401,10 @@ export const getGenerationStatus = {
6339
6401
  const r = await desktop.get('/agent/generation/status', { id: input.generationId });
6340
6402
  const g = r.generation;
6341
6403
  const status = g?.status ?? r.status;
6342
- const terminal = status === 'completed' || status === 'failed' || status === 'cancelled';
6404
+ const failed = status === 'failed' || status === 'rejected';
6405
+ if (failed)
6406
+ recordGenerationRejection(ctx, getGenerationStatus.id, g?.model);
6407
+ const terminal = status === 'completed' || failed || status === 'cancelled';
6343
6408
  if (terminal || Date.now() >= deadline) {
6344
6409
  if (!g)
6345
6410
  return ok(r);
@@ -10141,8 +10206,12 @@ export const generateFromShots = {
10141
10206
  const quote = await desktop.quote('/agent/shots/quote', 'input', {
10142
10207
  projectId: details[0].projectId, shotIds: details.map((d) => d.id), draft,
10143
10208
  });
10144
- for (const model of new Set(quote.items.map((i) => i.model)))
10145
- requireGuideRead(ctx, model);
10209
+ const shot = details.length === 1 ? details[0] : undefined;
10210
+ const routine = shot?.cuts === 1 && shot.referenceCount <= 1 && Array.isArray(shot.references) &&
10211
+ shot.references.length <= 1 && shot.references.every((ref) => ref.kind === 'image');
10212
+ for (const model of new Set(quote.items.map((i) => i.model))) {
10213
+ requireGuideRead(ctx, model, undefined, routine ? generateFromShots.id : undefined);
10214
+ }
10146
10215
  const total = quote.items.reduce((n, i) => n + (i.credits ?? 0), 0);
10147
10216
  const largest = Math.max(0, ...quote.items.map((i) => i.credits ?? 0));
10148
10217
  // ONE approval for the set, on the STATED total; a stale fingerprint is a
@@ -10164,6 +10233,11 @@ export const generateFromShots = {
10164
10233
  fingerprint: quote.fingerprint,
10165
10234
  draft,
10166
10235
  });
10236
+ for (const item of ran.results ?? []) {
10237
+ if (item.status === 'failed' || item.status === 'rejected') {
10238
+ recordGenerationRejection(ctx, generateFromShots.id, quote.items.find((shot) => shot.shotId === item.shotId)?.model);
10239
+ }
10240
+ }
10167
10241
  return seatNote ? ok(ran, `${JSON.stringify(ran)}\n${seatNote}`) : ok(ran);
10168
10242
  },
10169
10243
  };
@@ -10681,6 +10755,7 @@ export const getPromptingGuide = {
10681
10755
  const guide = locked.notice ?? `${locked.name} is not open to this account. Run the job on the general rules.`;
10682
10756
  // The guide gate makes an agent read what this account holds; a guide it cannot open never blocks a generation.
10683
10757
  ctx?.guidesRead?.add(locked.name);
10758
+ ctx?.guideEvidence?.full.add(locked.name);
10684
10759
  return { text: guide, data: { topic: locked.name, tier: locked.tier, locked: true, bytes: Buffer.byteLength(guide, 'utf8'), guide } };
10685
10760
  }
10686
10761
  // The shared brain with the user's My brain laid over it; theirs wins on a conflict (skills/my-brain.ts).
@@ -10716,8 +10791,10 @@ export const getPromptingGuide = {
10716
10791
  const guide = lockedAlias?.notice ?? `The guide ${resolved} comes from the connected Slates account and is not on this machine (${served.problem ?? 'no brain received yet'}). ${CONNECT_FOR_BRAIN}, then ask again.`;
10717
10792
  // A locked guide's notice carries its craft card (slates-api lib/brain.ts lockedNotice), so it counts as read; a
10718
10793
  // guide that never arrived does not, so no generation runs without the card (Eric, 2026-10-23: a hard blocker).
10719
- if (lockedAlias)
10794
+ if (lockedAlias) {
10720
10795
  ctx?.guidesRead?.add(resolved);
10796
+ ctx?.guideEvidence?.full.add(resolved);
10797
+ }
10721
10798
  return { text: guide, data: { topic: resolved, ...(lockedAlias ? { tier: lockedAlias.tier, locked: true } : { unavailable: true }), bytes: Buffer.byteLength(guide, 'utf8'), guide } };
10722
10799
  }
10723
10800
  if (resolved) {
@@ -10731,8 +10808,12 @@ export const getPromptingGuide = {
10731
10808
  // router with the preload only to a connection that has not opened it, so this answer is the agent's one copy.
10732
10809
  const preload = resolved === BRAIN_ROUTER ? myBrainPreload() : '';
10733
10810
  const guide = `${preload ? `${preload}\n\n` : ''}${own}${retrieveGuide(resolved, brain.skills[resolved], depth, input.query)}`;
10734
- ctx?.guidesRead?.add(resolved);
10735
- return { text: guide, data: { topic: resolved, tier: 'free', ...(mine ? { source: 'my-brain' } : {}), depth: servedDepth(resolved, depth, input.query), bytes: Buffer.byteLength(guide, 'utf8'), guide } };
10811
+ const deliveredDepth = servedDepth(resolved, depth, input.query);
10812
+ if (deliveredDepth === 'full' || (deliveredDepth === 'card' && !input.query?.trim()))
10813
+ ctx?.guidesRead?.add(resolved);
10814
+ if (deliveredDepth === 'full')
10815
+ ctx?.guideEvidence?.full.add(resolved);
10816
+ return { text: guide, data: { topic: resolved, tier: 'free', ...(mine ? { source: 'my-brain' } : {}), depth: deliveredDepth, bytes: Buffer.byteLength(guide, 'utf8'), guide } };
10736
10817
  }
10737
10818
  const member = await memberGuideCatalog(ctx);
10738
10819
  const privateEntry = member.entries.find(entry => entry.name === topic);
@@ -10749,7 +10830,10 @@ export const getPromptingGuide = {
10749
10830
  throw new Error('Invalid member guide body');
10750
10831
  const depth = input.depth ?? 'card';
10751
10832
  const guide = retrieveGuide(privateEntry.name, result.markdown, depth, input.query);
10752
- ctx?.guidesRead?.add(privateEntry.name);
10833
+ if (depth === 'full' || (depth === 'card' && !input.query))
10834
+ ctx?.guidesRead?.add(privateEntry.name);
10835
+ if (depth === 'full')
10836
+ ctx?.guideEvidence?.full.add(privateEntry.name);
10753
10837
  return { text: guide, data: { topic: privateEntry.name, tier: 'paid', depth, bytes: Buffer.byteLength(guide, 'utf8'), guide } };
10754
10838
  }
10755
10839
  // Slates' guides first, then HyperFrames' (they carry the craft for HTML layers and editing).
@@ -10799,9 +10883,9 @@ export const loadTools = {
10799
10883
  // Worded to be true on both surfaces: the desktop agent must load an
10800
10884
  // extended tool before calling it, while the MCP server lists every tool, so
10801
10885
  // "missing from your list" never happens there by default.
10802
- description: 'Find Slates tools by task. query searches tool names and descriptions and returns a compact list. names returns up to five exact tools with their schemas; group returns a whole task group. Call the tools by their own names. If a tool you need is missing from your tool list, a names or group load adds it; a load replaces the previous optional selection, and query alone does not change it. Groups: ' + Object.entries(GROUP_SUMMARY).map(([g, s]) => `${g}: ${s}`).join('; '),
10886
+ description: 'Find Slates tools by task. query searches names and descriptions. names loads up to five exact schemas; group loads a task group. Each load replaces the previous optional selection. Search alone leaves it in place. Groups: ' + Object.entries(GROUP_SUMMARY).map(([g, s]) => `${g}: ${s}`).join('; '),
10803
10887
  input: z.object({
10804
- group: z.enum(['script', 'library', 'timeline', 'admin', 'blender']).optional(),
10888
+ group: z.enum(Object.keys(GROUP_SUMMARY)).optional(),
10805
10889
  query: z.string().min(1).max(160).optional().describe('Search for a task such as generate image, create shot, or edit video.'),
10806
10890
  names: z.array(z.string()).min(1).max(5).optional().describe('Exact operation names to load after discovery. Their permission annotations remain separate.'),
10807
10891
  }).refine((v) => [v.group, v.query, v.names].filter(Boolean).length === 1, 'Pass exactly one of query, names, or group.'),
@@ -36,8 +36,7 @@ export declare function annotate(id: string, billable: boolean | undefined): Ope
36
36
  */
37
37
  export declare const OPERATION_GROUPS: Record<OperationGroup, readonly string[]>;
38
38
  export declare function groupFor(id: string): OperationGroup | undefined;
39
- /** `extended` iff the op names a group. Absent from every group ⇒ `core`, so a
40
- * new op is visible until someone deliberately defers it. */
39
+ /** Only the explicit startup set appears in every Slates Basic prompt. */
41
40
  export declare const STARTUP_TOOL_IDS: Set<string>;
42
41
  export declare function tierFor(id: string): OperationTier;
43
42
  /** One-line summary of each group, for `slates_load_tools`' own description. */
@@ -238,7 +238,6 @@ export const OPERATION_GROUPS = {
238
238
  ],
239
239
  // Rename, delete, reorder. The 63-op CRUD tail the review measured at 39.5 KB.
240
240
  admin: [
241
- 'slates_get_client_ad_report',
242
241
  'slates_update_project',
243
242
  'slates_update_asset',
244
243
  'slates_delete_project',
@@ -263,6 +262,17 @@ export const OPERATION_GROUPS = {
263
262
  'slates_get_spend_limits',
264
263
  'slates_set_spend_limits',
265
264
  ],
265
+ ads: [
266
+ 'slates_get_client_ad_report',
267
+ 'slates_get_ad_winners',
268
+ 'slates_set_recipe_verdict',
269
+ 'slates_more_like_this',
270
+ 'slates_plan_split_test',
271
+ 'slates_evaluate_split_test_winner',
272
+ 'slates_find_winning_ads',
273
+ 'slates_list_winning_ad_niches',
274
+ 'slates_break_down_winning_ad',
275
+ ],
266
276
  // A third transport nobody without Blender installed can reach.
267
277
  blender: [
268
278
  'slates_blender_status',
@@ -281,8 +291,7 @@ for (const [group, ids] of Object.entries(OPERATION_GROUPS)) {
281
291
  export function groupFor(id) {
282
292
  return GROUP_BY_OP.get(id);
283
293
  }
284
- /** `extended` iff the op names a group. Absent from every group ⇒ `core`, so a
285
- * new op is visible until someone deliberately defers it. */
294
+ /** Only the explicit startup set appears in every Slates Basic prompt. */
286
295
  export const STARTUP_TOOL_IDS = new Set([
287
296
  'slates_load_tools', 'slates_get_prompting_guide', 'slates_get_workspace_state',
288
297
  'slates_list_projects', 'slates_create_project', 'slates_list_assets',
@@ -296,6 +305,7 @@ export const GROUP_SUMMARY = {
296
305
  library: 'folders, favorites, pins, the Library (user-named categories of saved references: characters, locations, products, looks) and styles, templates (list, export, import), exporting original asset files, moving and copying assets and Library items between projects, moving a project into the current projects folder, revealing files on disk',
297
306
  script: 'rich script documents, anchored sections and their saved versions, reusable passages, variations and take input history',
298
307
  timeline: 'named cuts and exporting several at once, what made an exported ad (its recipe ID); the timeline (tracks, clips, markers, settings), text, picture and HTML motion layers, captions, video export and FCP7 XML export for DaVinci Resolve or Premiere, clip trimming',
308
+ ads: 'ad accounts, split tests and winning ads',
299
309
  admin: 'rename / delete / reorder for projects, characters, locations, looks, boards, scenes and frames; shot duplicate, split and merge; spend limits',
300
310
  blender: 'the Blender previs bridge — scene inspection, bpy execution, API docs, grey-box render',
301
311
  };
@@ -88,7 +88,7 @@ const PREAMBLE = fork(`You are Slates Director — a production assistant living
88
88
  - SPENDING: before ANY generation, price every step with slates_estimate_generation_cost, show the user the itemized total in ONE message, and wait for their OK. Pass confirm: true only to relay an explicit user OK for that exact spend.
89
89
  - REAL NUMBERS ONLY: every cost, balance or count you state is copied from a tool result in this session. Never describe how a generation looks unless you fetched it this session.
90
90
  - PROJECT: call slates_get_workspace_state once and work in the user's current project; never create one unless asked. Read any shot or board they name before answering.
91
- - CRAFT: before a model's first generation this session, read its guide (slates_get_prompting_guide, topic: the model); an estimate's card or guidance in context doesn't count. UI help: topic "app-manual".
91
+ - CRAFT: call slates_get_prompting_guide for the job's playbook before answering. Estimate cards cover single shots; full guide (depth: full) for multi-ref, previs, edits, lip-sync, motion transfer or retries. UI: "app-manual".
92
92
  - Speak in the app's words and name assets by code and label (IMG-A12), never by tool name or UUID.`);
93
93
  // ── The working method ─────────────────────────────────────────────
94
94
  export const WORKING_METHOD = [
@@ -99,7 +99,7 @@ export const WORKING_METHOD = [
99
99
  // so its agent must load before calling. The MCP server lists every tool and
100
100
  // the host decides what to show (Essentials, FINDING TOOLS), so telling an MCP
101
101
  // client to load first costs it a turn for a tool it already has.
102
- fork(`3. LOAD KNOWLEDGE ON DEMAND: discover craft from the brief with slates_get_prompting_guide(query: the need); no topic returns ranked guides, no query returns the catalog. With a topic, read a short card or query a section/technique when needed. Use slates_load_tools with query to find a capability, then names to load its exact schema. A load replaces the previous optional selection. Before quoting a model, load its tool schema or routing guide. Use workspace generationDefaults when the user has no preference. Before a model's first generation in this chat, read its guide (slates_get_prompting_guide, topic: the model); the estimate's card and guidance already in context do not count, and the generation is refused until then. Then fetch a section or full guide for an unfamiliar mode or missing detail.`, `3. LOAD KNOWLEDGE ON DEMAND: discover craft from the brief with slates_get_prompting_guide(query: the need); no topic returns ranked guides, no query returns the catalog. With a topic, read a short card or query a section/technique when needed. Before quoting a model, read its tool schema or routing guide. Use workspace generationDefaults when the user has no preference. Before a model's first generation, read its guide (CRAFT); the estimate's card and guidance in context do not count. Then fetch a section or full guide for an unfamiliar mode or missing detail.`),
102
+ fork(`3. LOAD KNOWLEDGE ON DEMAND: discover craft from the brief with slates_get_prompting_guide(query: the need); no topic returns ranked guides, no query returns the catalog. With a topic, read a short card or query a section/technique when needed. Use slates_load_tools with query to find a capability, then names to load its exact schema. A load replaces the previous optional selection. Before quoting a model, load its tool schema or routing guide. Use workspace generationDefaults when the user has no preference. Read the job's playbook before advising or building. Use the estimate's craft card for a routine single shot. Fetch the model's full guide (depth: full) for complex references, previs, edits and retries after a refusal.`, `3. LOAD KNOWLEDGE ON DEMAND: discover craft from the brief with slates_get_prompting_guide(query: the need); no topic returns ranked guides, no query returns the catalog. With a topic, read a short card or query a section/technique when needed. Before quoting a model, read its tool schema or routing guide. Use workspace generationDefaults when the user has no preference. Read the job's playbook before advising or building. Use the estimate's craft card for a routine single shot. Fetch the model's full guide (depth: full) for complex references, previs, edits and retries after a refusal.`),
103
103
  // FORKED: `present_plan` is a loop-level DESKTOP tool, deliberately not in
104
104
  // ALL_OPERATIONS, so MCP never sees it and has no plan gate at all. Its
105
105
  // substitute is the itemized quote and explicit user approval in chat,
@@ -9,7 +9,7 @@
9
9
  * Only explicit Ban and Warn rows declare literals. Conditions live on those rows.
10
10
  */
11
11
  import { brainFiles, servedBrain } from '../skills/served.js';
12
- import { parseGuideBans } from './guide-bans.js';
12
+ import { matcherFor, parseGuideBans } from './guide-bans.js';
13
13
  // Read from the brain this process holds (skills/served.ts) and rebuilt when it changes: the model guides that
14
14
  // carry the @banned blocks are served by the account's tier.
15
15
  let built;
@@ -31,16 +31,6 @@ export const BANNED_PROMPT_TOKENS = Object.freeze([]);
31
31
  export function bannedTokensFor(_scope) { return BANNED_PROMPT_TOKENS; }
32
32
  export function describeBannedTokens(_scope) { return ''; }
33
33
  export function bannedTokensForSkill(skill) { return bannedBySkill().get(skill) ?? []; }
34
- const matchers = new Map();
35
- function matcherFor(token) {
36
- let matcher = matchers.get(token);
37
- if (!matcher) {
38
- const escaped = token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
39
- matcher = new RegExp(`(?<!\\w)${escaped}(?!\\w)`, 'i');
40
- matchers.set(token, matcher);
41
- }
42
- return matcher;
43
- }
44
34
  export function findBannedTokens(prompt, _scope, skill) {
45
35
  return skill ? bannedTokensForSkill(skill).filter((b) => matcherFor(b.token).test(prompt)) : [];
46
36
  }
@@ -13,4 +13,5 @@ export interface BannedToken {
13
13
  when?: BannedTokenCondition;
14
14
  }
15
15
  export declare function parseGuideBans(skill: string, content: string, strict?: boolean): BannedToken[];
16
+ export declare function matcherFor(token: string): RegExp;
16
17
  //# sourceMappingURL=guide-bans.d.ts.map
@@ -37,4 +37,14 @@ export function parseGuideBans(skill, content, strict = false) {
37
37
  }
38
38
  return tokens;
39
39
  }
40
+ const matchers = new Map();
41
+ export function matcherFor(token) {
42
+ let matcher = matchers.get(token);
43
+ if (!matcher) {
44
+ const escaped = token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
45
+ matcher = new RegExp(`(?<!\\w)${escaped}(?!\\w)`, 'i');
46
+ matchers.set(token, matcher);
47
+ }
48
+ return matcher;
49
+ }
40
50
  //# sourceMappingURL=guide-bans.js.map
@@ -74,6 +74,7 @@ export interface ComposedReferences {
74
74
  */
75
75
  unresolvedTokens: string[];
76
76
  }
77
+ export declare function hasReferenceMention(prompt: string): boolean;
77
78
  /**
78
79
  * 🚨 A HEX COLOUR IS NOT A TAG. `#000000` is to `#` what `eric@gmail.com` is to
79
80
  * `@`: an everyday literal that happens to open with our sigil, written by
@@ -92,6 +92,9 @@ function joinNums(nums) {
92
92
  * capability attaches to the primitive, it does not stand in the way of it.
93
93
  */
94
94
  const TOKEN_RE = /(?<![\w.@#])([@#])([\w-]+(?:\.[\w-]+)*)/g;
95
+ export function hasReferenceMention(prompt) {
96
+ return prompt.search(TOKEN_RE) !== -1;
97
+ }
95
98
  /**
96
99
  * 🚨 A HEX COLOUR IS NOT A TAG. `#000000` is to `#` what `eric@gmail.com` is to
97
100
  * `@`: an everyday literal that happens to open with our sigil, written by
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slatesvideo/shared",
3
- "version": "0.7.23",
3
+ "version": "0.7.24",
4
4
  "description": "Shared operations layer for the Slates MCP server and CLI: auth, cloud/desktop clients, and the single tool surface both consume. Most users want @slatesvideo/mcp-server or @slatesvideo/cli instead.",
5
5
  "license": "MIT",
6
6
  "type": "module",