@slatesvideo/shared 0.7.7 → 0.7.9

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.
Files changed (122) hide show
  1. package/README.md +3 -6
  2. package/dist/analytics/events.d.ts +1 -1
  3. package/dist/analytics/events.js +7 -0
  4. package/dist/auth.d.ts +2 -0
  5. package/dist/auth.js +5 -0
  6. package/dist/clients/cloud.d.ts +2 -0
  7. package/dist/clients/cloud.js +5 -1
  8. package/dist/clients/desktop.js +6 -1
  9. package/dist/index.d.ts +7 -3
  10. package/dist/index.js +7 -3
  11. package/dist/manual/content.d.ts +1 -1
  12. package/dist/manual/content.js +1 -1
  13. package/dist/operations/index.d.ts +724 -173
  14. package/dist/operations/index.js +875 -65
  15. package/dist/operations/surface.d.ts +2 -2
  16. package/dist/operations/surface.js +26 -6
  17. package/dist/prompts/agent-doctrine.d.ts +12 -2
  18. package/dist/prompts/agent-doctrine.js +56 -28
  19. package/dist/prompts/banned-tokens.js +23 -13
  20. package/dist/prompts/brain.d.ts +29 -0
  21. package/dist/prompts/brain.js +72 -0
  22. package/dist/prompts/craft-cards.d.ts +15 -4
  23. package/dist/prompts/craft-cards.js +71 -9
  24. package/dist/prompts/generation-policy.d.ts +1 -1
  25. package/dist/prompts/guide-discovery.d.ts +6 -6
  26. package/dist/prompts/guide-retrieval.d.ts +7 -1
  27. package/dist/prompts/guide-retrieval.js +33 -5
  28. package/dist/prompts/partials.generated.js +1 -13
  29. package/dist/prompts/shot-grammar.d.ts +1 -1
  30. package/dist/prompts/shot-grammar.js +1 -1
  31. package/dist/skills/brain-check.d.ts +44 -0
  32. package/dist/skills/brain-check.js +174 -0
  33. package/dist/skills/content.d.ts +3 -0
  34. package/dist/skills/content.js +81 -44
  35. package/dist/skills/hyperframes-content.js +4 -4
  36. package/dist/skills/my-brain.d.ts +52 -0
  37. package/dist/skills/my-brain.js +218 -0
  38. package/dist/skills/served.d.ts +56 -0
  39. package/dist/skills/served.js +232 -0
  40. package/package.json +2 -4
  41. package/skills/hyperframes/NOTICE +19 -3
  42. package/skills/hyperframes/SLATES-MAPPING.md +1 -1
  43. package/skills/hyperframes/embedded-captions/CATALOG.md +3 -0
  44. package/skills/hyperframes/embedded-captions/SKILL.md +6 -6
  45. package/skills/hyperframes/embedded-captions/assets/fonts/char-widths.json +227 -1
  46. package/skills/hyperframes/embedded-captions/modes/standard/fonts/build-fonts-css.cjs +19 -2
  47. package/skills/hyperframes/embedded-captions/modes/standard/fonts/files/archivo-latin-wdth-italic.woff2 +0 -0
  48. package/skills/hyperframes/embedded-captions/modes/standard/fonts/files/archivo-latin-wdth-normal.woff2 +0 -0
  49. package/skills/hyperframes/embedded-captions/scripts/make-theme.cjs +438 -3
  50. package/skills/hyperframes/embedded-captions/scripts/make-theme.test.mjs +1 -0
  51. package/skills/hyperframes/embedded-captions/themes/README.md +26 -1
  52. package/skills/hyperframes/embedded-captions/themes/lesson.json +31 -0
  53. package/skills/slates-start-here.md +78 -0
  54. package/exports/slates-chatgpt-images/generated/SKILL.md +0 -113
  55. package/exports/slates-chatgpt-images/generated/slates-chatgpt-images.skill +0 -0
  56. package/exports/slates-prompt-builder/generated/SKILL.md +0 -71
  57. package/exports/slates-prompt-builder/generated/reference-character.md +0 -92
  58. package/exports/slates-prompt-builder/generated/reference-content-policy.md +0 -81
  59. package/exports/slates-prompt-builder/generated/reference-gpt-image-2-5.md +0 -191
  60. package/exports/slates-prompt-builder/generated/reference-kling.md +0 -295
  61. package/exports/slates-prompt-builder/generated/reference-nano-banana.md +0 -240
  62. package/exports/slates-prompt-builder/generated/reference-omni-flash.md +0 -97
  63. package/exports/slates-prompt-builder/generated/reference-seedance-2-5.md +0 -392
  64. package/exports/slates-prompt-builder/generated/reference-seedance.md +0 -441
  65. package/exports/slates-prompt-builder/generated/slates-prompt-builder-manifest.json +0 -133
  66. package/exports/slates-prompt-builder/generated/slates-prompt-builder.skill +0 -0
  67. package/skills/_partials/blender-action-curves.md +0 -24
  68. package/skills/_partials/cinematic-card.md +0 -8
  69. package/skills/_partials/decision-log.md +0 -1
  70. package/skills/_partials/image-defaults.md +0 -9
  71. package/skills/_partials/iteration-diagnosis.md +0 -5
  72. package/skills/_partials/living-performance.md +0 -22
  73. package/skills/_partials/model-routing.md +0 -35
  74. package/skills/_partials/references-read-literally.md +0 -11
  75. package/skills/_partials/seedance-25-timestamps.md +0 -34
  76. package/skills/_partials/sheet-tool-defaults.md +0 -6
  77. package/skills/_partials/still-gate.md +0 -3
  78. package/skills/_partials/thresholds.md +0 -19
  79. package/skills/slates-blocking-to-prompt.md +0 -279
  80. package/skills/slates-camera-language.md +0 -234
  81. package/skills/slates-captions.md +0 -81
  82. package/skills/slates-character-identity.md +0 -117
  83. package/skills/slates-chatgpt-images.md +0 -113
  84. package/skills/slates-cinematic-look.md +0 -237
  85. package/skills/slates-content-policy.md +0 -88
  86. package/skills/slates-cost-discipline.md +0 -150
  87. package/skills/slates-cuts.md +0 -46
  88. package/skills/slates-dialogue-blocking.md +0 -134
  89. package/skills/slates-direct-response-ad.md +0 -26
  90. package/skills/slates-edit-and-iterate.md +0 -76
  91. package/skills/slates-layer-brand-captions.md +0 -87
  92. package/skills/slates-layer-lower-third.md +0 -85
  93. package/skills/slates-layer-title.md +0 -82
  94. package/skills/slates-model-selection.md +0 -129
  95. package/skills/slates-motion.md +0 -57
  96. package/skills/slates-one-prompt-film.md +0 -38
  97. package/skills/slates-previs-blocking.md +0 -186
  98. package/skills/slates-project-organization.md +0 -42
  99. package/skills/slates-prompting-elevenlabs.md +0 -128
  100. package/skills/slates-prompting-flux-3.md +0 -157
  101. package/skills/slates-prompting-gpt-image-2-5.md +0 -196
  102. package/skills/slates-prompting-inworld-tts.md +0 -174
  103. package/skills/slates-prompting-kling-v3.md +0 -303
  104. package/skills/slates-prompting-lip-sync.md +0 -216
  105. package/skills/slates-prompting-ltx-2-5.md +0 -245
  106. package/skills/slates-prompting-minimax-h3.md +0 -383
  107. package/skills/slates-prompting-motion-transfer.md +0 -202
  108. package/skills/slates-prompting-nano-banana-2-1.md +0 -250
  109. package/skills/slates-prompting-omni-flash.md +0 -117
  110. package/skills/slates-prompting-seed-audio.md +0 -168
  111. package/skills/slates-prompting-seedance-2-5.md +0 -420
  112. package/skills/slates-prompting-seedance.md +0 -462
  113. package/skills/slates-prompting-seedream-5-lite.md +0 -122
  114. package/skills/slates-prompting-wan-3.md +0 -143
  115. package/skills/slates-restyle-from-blocking.md +0 -121
  116. package/skills/slates-script-craft.md +0 -45
  117. package/skills/slates-shot-variety.md +0 -24
  118. package/skills/slates-storyboard-from-script.md +0 -32
  119. package/skills/slates-style-prompting.md +0 -56
  120. package/skills/slates-transitions.md +0 -40
  121. package/skills/slates-ugc-influencer-ad.md +0 -32
  122. package/skills/slates-vision-feedback-loop.md +0 -118
package/README.md CHANGED
@@ -24,13 +24,10 @@ Prompting doctrine that applies to more than one model lives **once**, in `skill
24
24
 
25
25
  ## Portable Prompt Builder export
26
26
 
27
- The downloadable Claude `.skill` is generated at `exports/slates-prompt-builder/generated/`. Its model, character, and content-policy references come directly from the resolved production files in `skills/`; its routing table derives from `MODEL_FACTS`; the portable wrapper owns only export-specific scope and output behavior.
27
+ The downloadable Claude `.skill` is built into `exports/slates-prompt-builder/generated/`, which is gitignored and outside this package's `files`: its model, character and content-policy references are license-tier guides from the private brain (`slates-api/brain/`), so they never enter this public repo or the npm tarball. Its routing table derives from `MODEL_FACTS`; the portable wrapper (`prompt-builder.md`) owns only export-specific scope and output behavior.
28
28
 
29
29
  ```bash
30
- npm run sync-prompt-builder # regenerate markdown, manifest, and deterministic .skill
31
- npm run typecheck # fails if the committed export is stale
30
+ npm run sync-prompt-builder # build the markdown, manifest and deterministic .skill into generated/, and sync the vault mirror
32
31
  ```
33
32
 
34
- `scripts/build-prompt-builder.mjs --check` validates generated text content (normalizing LF/CRLF), keeps the archive byte-exact, opens it to verify its exact entry set, and enforces the runtime character contract (one sheet, the canonical `IDENTITY_PLATE_HEX`, flat/shadowless light, and the three-panel builder). Never edit `exports/slates-prompt-builder/generated/` directly.
35
-
36
- The repository verification workflow runs both typecheck and build on every pull request and push to `main`, so stale exports cannot merge through the normal GitHub path.
33
+ `scripts/build-prompt-builder.mjs --check` (in build and typecheck) renders the export in memory, keeps the archive byte-exact, verifies its entry set and the runtime character contract (one sheet, the canonical `IDENTITY_PLATE_HEX`, flat/shadowless light, the three-panel builder), and fails if `generated/` could publish: tracked, not ignored, or in `files`. `scripts/brain-leak-check.mjs` (root build) fails on any tracked file holding a 90-character line of the brain. The download is served from the private slates-web repo (`public/slates-prompt-builder.skill`): refresh it by copying the built `.skill` there.
@@ -29,7 +29,7 @@ export type AnalyticsKind =
29
29
  | 'account'
30
30
  /** Offers, leads and codes from the offer machine. */
31
31
  | 'offer'
32
- /** A server-side failure worth counting. */
32
+ /** A failure worth counting, on the server or in the app. */
33
33
  | 'ops';
34
34
  export interface AnalyticsEvent {
35
35
  readonly name: string;
@@ -128,6 +128,13 @@ export const ANALYTICS_EVENTS = [
128
128
  { name: 'account_email_reverted', senders: API, kind: 'account', what: 'An email change undone' },
129
129
  { name: 'refund_processed', senders: API, kind: 'account', what: 'A refund taken back what its payment granted' },
130
130
  { name: 'dispute_opened', senders: API, kind: 'account', what: 'A chargeback opened' },
131
+ // ── Failures (second-brain plans/2026-10-25-slates-bug-capture.md): crashes as `$exception`, and the failures that throw nothing ──
132
+ { name: '$exception', senders: [...APP, ...API], kind: 'ops', what: 'An error: posthog-js exception capture in the app, captureException in main and slates-api', library: true },
133
+ { name: 'generation_failed', senders: APP, kind: 'ops', what: 'A generation turned failed: its model, error class and provider status, never the prompt' },
134
+ { name: 'export_failed', senders: APP, kind: 'ops', what: 'An MP4 or XML export failed, by error class' },
135
+ { name: 'agent_op_failed', senders: APP, kind: 'ops', what: "An outside agent's /agent request answered 500, or a Studio Agent tool call threw" },
136
+ { name: 'action_retried', senders: APP, kind: 'ops', what: 'One action (same target, same input) failed three times inside ten minutes' },
137
+ { name: 'session_ended_after_error', senders: APP, kind: 'ops', what: 'The app quit within a minute of one of the failures above' },
131
138
  ];
132
139
  const BY_NAME = new Map(ANALYTICS_EVENTS.map((e) => [e.name, e]));
133
140
  if (BY_NAME.size !== ANALYTICS_EVENTS.length) {
package/dist/auth.d.ts CHANGED
@@ -35,6 +35,8 @@ export declare class MissingDesktopServerError extends Error {
35
35
  code: string;
36
36
  constructor();
37
37
  }
38
+ /** A short hash of a bearer token, so a file can name which login wrote it without holding the token. */
39
+ export declare function tokenHash(token: string | null | undefined): string | null;
38
40
  export declare function requireCloudToken(): string;
39
41
  export declare function requireDesktop(): {
40
42
  port: number;
package/dist/auth.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { createHash } from 'node:crypto';
1
2
  import { homedir } from 'node:os';
2
3
  import { join } from 'node:path';
3
4
  import { existsSync, readFileSync, writeFileSync, mkdirSync, } from 'node:fs';
@@ -68,6 +69,10 @@ export class MissingDesktopServerError extends Error {
68
69
  super('Slates desktop is not running with its local server on. Open Slates → Settings → AI tools and connect (Send link, or Connect without the email link).');
69
70
  }
70
71
  }
72
+ /** A short hash of a bearer token, so a file can name which login wrote it without holding the token. */
73
+ export function tokenHash(token) {
74
+ return token ? createHash('sha256').update(token).digest('hex').slice(0, 16) : null;
75
+ }
71
76
  export function requireCloudToken() {
72
77
  const c = readConnection();
73
78
  if (!c.cloud.token)
@@ -7,6 +7,8 @@ export declare class SlatesCloudClient {
7
7
  private readonly token;
8
8
  private readonly baseUrl;
9
9
  constructor(token?: string, baseUrl?: string);
10
+ /** A hash of the token this client sends: the served brain's cache names the login it fetched with by it. */
11
+ get credentialKey(): string | null;
10
12
  get<T>(path: string): Promise<T>;
11
13
  post<T>(path: string, body: unknown): Promise<T>;
12
14
  /** Name the op's own path in the failure — "fetch failed" tells nobody which
@@ -1,4 +1,4 @@
1
- import { requireCloudToken } from '../auth.js';
1
+ import { requireCloudToken, tokenHash } from '../auth.js';
2
2
  import { SLATES_API_URL } from '../api-url.js';
3
3
  const FALLBACK_CLOUD_BASE_URL = SLATES_API_URL;
4
4
  // The slates_sk_ bearer is attached to every cloud request. SLATES_CLOUD_BASE_URL
@@ -55,6 +55,10 @@ export class SlatesCloudClient {
55
55
  this.token = token;
56
56
  this.baseUrl = baseUrl;
57
57
  }
58
+ /** A hash of the token this client sends: the served brain's cache names the login it fetched with by it. */
59
+ get credentialKey() {
60
+ return tokenHash(this.token);
61
+ }
58
62
  async get(path) {
59
63
  const res = await this.fetchOrFriendly(path, `${this.baseUrl}${path}`, {
60
64
  headers: { Authorization: `Bearer ${this.token}` },
@@ -1,4 +1,8 @@
1
+ import { randomUUID } from 'node:crypto';
1
2
  import { requireDesktop } from '../auth.js';
3
+ // One agent session per process (an MCP server's connection, or one CLI run): the desktop counts
4
+ // what it spends against the person's per-session spend limit (`slates_get_spend_limits`).
5
+ const AGENT_SESSION = randomUUID();
2
6
  // Friendly message for the by-far-most-common failure: the desktop app
3
7
  // isn't running (or the connection file holds a stale port). A raw
4
8
  // "fetch failed" tells the agent nothing actionable.
@@ -94,7 +98,7 @@ export class SlatesDesktopClient {
94
98
  }
95
99
  }
96
100
  const res = await this.fetchOrFriendly(url.toString(), {
97
- headers: { Authorization: `Bearer ${this.token}` },
101
+ headers: { Authorization: `Bearer ${this.token}`, 'X-Slates-Session': AGENT_SESSION },
98
102
  });
99
103
  return this.handle(path, res);
100
104
  }
@@ -104,6 +108,7 @@ export class SlatesDesktopClient {
104
108
  headers: {
105
109
  'Content-Type': 'application/json',
106
110
  Authorization: `Bearer ${this.token}`,
111
+ 'X-Slates-Session': AGENT_SESSION,
107
112
  },
108
113
  body: JSON.stringify(body),
109
114
  });
package/dist/index.d.ts CHANGED
@@ -1,17 +1,21 @@
1
1
  export * from './auth.js';
2
2
  export { SlatesCloudClient, type SlatesUserInfo, type CreditsBalance, type ModelRegistryResponse } from './clients/cloud.js';
3
3
  export { SlatesDesktopClient, type DesktopHealth } from './clients/desktop.js';
4
- export { SKILLS } from './skills/content.js';
4
+ export { BRAIN_SHAPE, SKILLS } from './skills/content.js';
5
+ export { BRAIN_CACHE, brainFiles, clearServedBrain, refreshServedBrain, servedBrain, useBrainSource, type LockedGuide, type ServedBrain } from './skills/served.js';
6
+ export { myBrainProblems, type BrainShape, type MyBrainProblem } from './skills/brain-check.js';
5
7
  export { parseSkillMetadata, type SkillMetadata } from './skills/metadata.js';
8
+ export { ARCHIVE_AFTER_DAYS, archiveUnused, archiveUnusedDaily, brainSkills, loadMyBrain, myBrainDir, myBrainPreload, noteUsed, MY_BRAIN_PRELOAD_CHARS, type Brain } from './skills/my-brain.js';
6
9
  export * as operations from './operations/index.js';
7
10
  export { ALL_OPERATIONS, VIDEO_MODELS, AUDIO_MODELS, IMAGE_MODELS, defaultContext, OperationCancelledError, type Operation, type OperationContext, type OperationResult, type OperationAnnotations, type OperationTier, type OperationGroup } from './operations/index.js';
8
11
  export { CONFIRM_CREDITS, DEVIATION_FACTOR, WORKING_METHOD_TOPIC } from './operations/index.js';
9
12
  export { toolDefinitions, toolDefinition, groupFor, tierFor, OPERATION_GROUPS, GROUP_SUMMARY, STARTUP_TOOL_IDS, type ToolDefinition, } from './operations/index.js';
10
13
  export { MODEL_FACTS, getModelFact, multimodalRefSummary, multimodalRefModels, describeRouting, SEEDANCE_TASK_INTENT_WORDS, seedanceTaskIntentWords, type ModelFact, } from './prompts/model-facts.js';
11
14
  export { MODEL_CAPABILITIES, ALL_ASPECT_RATIOS, AGENT_ROUTE_PROVIDER, getModelCapability, aspectRatiosFor, videoResolutionsFor, defaultVideoResolutionFor, durationsFor, durationValuesFor, aspectRatioUnion, videoResolutionUnion, durationBounds, checkAspectRatio, checkVideoResolution, checkDuration, describeAspectRatios, describeVideoResolutions, describeDurations, describeReferenceImageCaps, type AspectRatio, type VideoResolution, type ModelCapability, type DurationCapability, type VideoResolutionCapability, } from './prompts/model-capabilities.js';
12
- export { buildAgentDoctrine, buildMcpInstructions, type AgentSurface } from './prompts/agent-doctrine.js';
15
+ export { buildAgentDoctrine, buildMcpInstructions, ROUTER_NOTICE, type AgentSurface } from './prompts/agent-doctrine.js';
16
+ export { BRAIN_ROUTER, DIRECTOR_CARD, MY_BRAIN_TOPIC, PLAYBOOKS } from './prompts/brain.js';
13
17
  export { BANNED_PROMPT_TOKENS, describeBannedTokens, findBannedTokens, bannedTokenWarning, refusableBannedTokens, bannedTokensForSkill, describeBannedTokensForSkill, type BannedToken, type BannedTokenScope, type BannedTokenCondition, } from './prompts/banned-tokens.js';
14
- export { CRAFT_CARDS, CRAFT_CARD_CEILING, craftCard, describeCraftCard } from './prompts/craft-cards.js';
18
+ export { CRAFT_CARDS, CRAFT_CARD_CEILING, craftCard, craftCardOf, describeCraftCard, oversizedCraftCards } from './prompts/craft-cards.js';
15
19
  export { PROMPTING_TIPS, getPromptingTips, type PromptingTipsEntry, type PromptingTipCard, type PromptingTipsKey } from './prompts/prompting-tips.js';
16
20
  export { SLATES_API_URL } from './api-url.js';
17
21
  export { APP_MANUAL, appManualIndex, appManualSections, manualReader } from './manual/index.js';
package/dist/index.js CHANGED
@@ -1,8 +1,11 @@
1
1
  export * from './auth.js';
2
2
  export { SlatesCloudClient } from './clients/cloud.js';
3
3
  export { SlatesDesktopClient } from './clients/desktop.js';
4
- export { SKILLS } from './skills/content.js';
4
+ export { BRAIN_SHAPE, SKILLS } from './skills/content.js';
5
+ export { BRAIN_CACHE, brainFiles, clearServedBrain, refreshServedBrain, servedBrain, useBrainSource } from './skills/served.js';
6
+ export { myBrainProblems } from './skills/brain-check.js';
5
7
  export { parseSkillMetadata } from './skills/metadata.js';
8
+ export { ARCHIVE_AFTER_DAYS, archiveUnused, archiveUnusedDaily, brainSkills, loadMyBrain, myBrainDir, myBrainPreload, noteUsed, MY_BRAIN_PRELOAD_CHARS } from './skills/my-brain.js';
6
9
  export * as operations from './operations/index.js';
7
10
  export { ALL_OPERATIONS, VIDEO_MODELS, AUDIO_MODELS, IMAGE_MODELS, defaultContext, OperationCancelledError } from './operations/index.js';
8
11
  // The spend thresholds the DESKTOP and the SKILLS both quote. `CONFIRM_CREDITS`
@@ -44,7 +47,8 @@ export { MODEL_CAPABILITIES, ALL_ASPECT_RATIOS, AGENT_ROUTE_PROVIDER, getModelCa
44
47
  // stay off the public surface — an export nothing calls is an export nothing
45
48
  // keeps honest, which is why `buildModelRouting` was deleted rather than left
46
49
  // here "in case".
47
- export { buildAgentDoctrine, buildMcpInstructions } from './prompts/agent-doctrine.js';
50
+ export { buildAgentDoctrine, buildMcpInstructions, ROUTER_NOTICE } from './prompts/agent-doctrine.js';
51
+ export { BRAIN_ROUTER, DIRECTOR_CARD, MY_BRAIN_TOPIC, PLAYBOOKS } from './prompts/brain.js';
48
52
  // Banned prompt tokens — EXTRACTED from the skills' own never-use lists and
49
53
  // inlined into the generate ops' descriptions. Enforcement of "load the guide"
50
54
  // that the model cannot skip, because a description is always in context.
@@ -63,7 +67,7 @@ bannedTokensForSkill, describeBannedTokensForSkill, } from './prompts/banned-tok
63
67
  // own `@card` blocks and delivered on the estimate result. The eval scorer reads
64
68
  // CRAFT_CARDS to build its lever vocabulary, so the assertion can never be
65
69
  // scored against a hand-retyped word list.
66
- export { CRAFT_CARDS, CRAFT_CARD_CEILING, craftCard, describeCraftCard } from './prompts/craft-cards.js';
70
+ export { CRAFT_CARDS, CRAFT_CARD_CEILING, craftCard, craftCardOf, describeCraftCard, oversizedCraftCards } from './prompts/craft-cards.js';
67
71
  // Per-model prompting tips — the SSOT for the desktop "See prompting tips"
68
72
  // modals. The desktop renders these; it never hand-writes tips content.
69
73
  export { PROMPTING_TIPS, getPromptingTips } from './prompts/prompting-tips.js';