@vanillaskyai/video 0.6.0 → 0.7.0

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 (130) hide show
  1. package/CHANGELOG.md +157 -0
  2. package/PUBLIC-API.md +123 -9
  3. package/README.md +69 -115
  4. package/dist/{bg-confetti-SHQI7ATB.js → bg-confetti-HITCGLGD.js} +1 -1
  5. package/dist/{bg-emoji-XYFRA63Q.js → bg-emoji-VU4UZYZN.js} +1 -1
  6. package/dist/{bg-media-G4XOQEAS.js → bg-media-L34PDQXJ.js} +2 -2
  7. package/dist/{brand-message-XHONEDNW.js → brand-message-FUJ4STFO.js} +1 -1
  8. package/dist/{builtin-server-YHEZ2JRF.js → builtin-server-KB7FKF6A.js} +2 -2
  9. package/dist/{chart-bar-HRHD57ML.js → chart-bar-EGPHJATL.js} +2 -2
  10. package/dist/{chart-counter-KFPV44RB.js → chart-counter-5FFWQNZO.js} +2 -2
  11. package/dist/{chart-progress-ring-OR2VOIHV.js → chart-progress-ring-JMXQLMLC.js} +2 -2
  12. package/dist/{chunk-66MNRUCR.js → chunk-2PYO6VAC.js} +51 -3
  13. package/dist/{chunk-ZQQQAAKP.js → chunk-2XT4MZ76.js} +33 -2
  14. package/dist/{chunk-PNS52FL4.js → chunk-5SLENAJW.js} +19 -6
  15. package/dist/{chunk-EFL34TXF.js → chunk-AITKH6QT.js} +24 -8
  16. package/dist/{chunk-FZHMQFG3.js → chunk-GAIOHGNR.js} +5 -21
  17. package/dist/{chunk-3RV4YKB3.js → chunk-JNN3EYVP.js} +51 -26
  18. package/dist/{chunk-HVCPEAQF.js → chunk-LKBZX7GV.js} +9 -6
  19. package/dist/{chunk-G66Z5CWR.js → chunk-MMUXVA47.js} +27 -3
  20. package/dist/{chunk-7BGAU6C3.js → chunk-MXZSDGZQ.js} +2 -1
  21. package/dist/{chunk-3OU7HIEB.js → chunk-RE4IMWJR.js} +15 -31
  22. package/dist/{chunk-FVTMYS6U.js → chunk-RGF452LL.js} +1 -1
  23. package/dist/{chunk-34O5BY6X.js → chunk-RXHW4EP4.js} +21 -4
  24. package/dist/chunk-SKRGRKHY.js +142 -0
  25. package/dist/{chunk-TCEHK2BW.js → chunk-YJJC4N4D.js} +2 -1
  26. package/dist/cli.js +438 -30
  27. package/dist/{compose-video-JWIEDTEJ.js → compose-video-PD6LKKRK.js} +4 -4
  28. package/dist/{cta-logo-JJOGK4UC.js → cta-logo-YR7LYUR5.js} +1 -1
  29. package/dist/{cta-media-IQ3MAWEH.js → cta-media-DQJBKUO2.js} +2 -2
  30. package/dist/{events-BBP30j3c.d.ts → events-B6qS1Lsb.d.ts} +2 -2
  31. package/dist/{incoming-call-KXF67OT2.js → incoming-call-54KQ7O5A.js} +1 -1
  32. package/dist/index.d.ts +89 -3
  33. package/dist/index.js +12 -1
  34. package/dist/{infographic-before-after-2I7YZVDD.js → infographic-before-after-ROS52GOW.js} +1 -1
  35. package/dist/{infographic-feature-list-QDM4I7XE.js → infographic-feature-list-E7MGUDAN.js} +2 -2
  36. package/dist/{infographic-problem-solution-FMLJCPG6.js → infographic-problem-solution-3S6NGO5N.js} +2 -2
  37. package/dist/{infographic-stat-row-VFTIXS5F.js → infographic-stat-row-SYB7AB7H.js} +2 -2
  38. package/dist/{infographic-steps-L7W24Z35.js → infographic-steps-KCE6JWE2.js} +2 -2
  39. package/dist/{kit-DEG3fcaL.d.ts → kit-8g46H2RZ.d.ts} +1 -1
  40. package/dist/{prompt-input-F3CYU2XH.js → prompt-input-MHX4O42G.js} +1 -1
  41. package/dist/react.d.ts +194 -6
  42. package/dist/react.js +1849 -40
  43. package/dist/{reaction-2XCLOJOK.js → reaction-SLEGR3BE.js} +2 -2
  44. package/dist/server.d.ts +102 -4
  45. package/dist/server.js +972 -27
  46. package/dist/{showcase-code-KHSMIPG6.js → showcase-code-2HLAVKBM.js} +2 -2
  47. package/dist/{showcase-phone-M4CEANIW.js → showcase-phone-Q4HEO4LH.js} +2 -2
  48. package/dist/{showcase-terminal-26I3DYF7.js → showcase-terminal-DL45LUFG.js} +2 -2
  49. package/dist/{showcase-web-TY6CZV2Z.js → showcase-web-2QZO73FZ.js} +2 -2
  50. package/dist/{social-milestone-TF6MX7ET.js → social-milestone-GEFUQSBF.js} +1 -1
  51. package/dist/{social-notification-2RJDAZSF.js → social-notification-FJ5VHVLK.js} +1 -1
  52. package/dist/{social-review-stack-2ICKJQG7.js → social-review-stack-KXQCKFRP.js} +1 -1
  53. package/dist/{social-testimonial-X7OGADA3.js → social-testimonial-JZ7CHC7S.js} +1 -1
  54. package/dist/{social-tweet-TK7SH2F6.js → social-tweet-UCDXM25F.js} +1 -1
  55. package/dist/{system-prompt-4I6Z5HK3.js → system-prompt-RRXIWDDD.js} +5 -3
  56. package/dist/template-catalog.js +1 -1
  57. package/dist/templates.d.ts +3 -3
  58. package/dist/test.d.ts +2 -2
  59. package/dist/test.js +3 -3
  60. package/dist/{text-stream-J6EDDJP4.js → text-stream-FW4BLBAL.js} +2 -2
  61. package/dist/{types-BV9IqExh.d.ts → types-2wHBqtg8.d.ts} +29 -1
  62. package/dist/types-DrABlRa7.d.ts +46 -0
  63. package/docs/agent-integration.md +49 -25
  64. package/docs/architecture.md +37 -22
  65. package/docs/branding-and-personalization.md +1 -1
  66. package/docs/concepts.md +14 -0
  67. package/docs/custom-templates.md +9 -9
  68. package/docs/customization.md +41 -5
  69. package/docs/getting-started.md +81 -84
  70. package/docs/media-and-audio.md +103 -166
  71. package/docs/persistence.md +1 -1
  72. package/docs/production.md +81 -92
  73. package/docs/prompt-and-input.md +71 -161
  74. package/docs/provider-integration.md +91 -49
  75. package/docs/responsive-orientation.md +1 -1
  76. package/docs/security.md +6 -5
  77. package/docs/streaming-protocol.md +1 -1
  78. package/docs/testing.md +51 -43
  79. package/examples/custom-template/README.md +1 -1
  80. package/package.json +20 -22
  81. package/registry/items/barChart.json +6 -4
  82. package/registry/items/beforeAfter.json +1 -1
  83. package/registry/items/bigNumber.json +4 -3
  84. package/registry/items/brandMessage.json +3 -2
  85. package/registry/items/cardList.json +6 -4
  86. package/registry/items/codeEditor.json +4 -3
  87. package/registry/items/confetti.json +1 -1
  88. package/registry/items/ctaLogo.json +3 -2
  89. package/registry/items/ctaMedia.json +4 -3
  90. package/registry/items/emojiBurst.json +1 -1
  91. package/registry/items/incomingCall.json +3 -2
  92. package/registry/items/media.json +4 -3
  93. package/registry/items/milestone.json +3 -2
  94. package/registry/items/notification.json +3 -2
  95. package/registry/items/phoneMockup.json +4 -3
  96. package/registry/items/problemSolution.json +4 -3
  97. package/registry/items/progressRing.json +4 -3
  98. package/registry/items/promptInput.json +3 -2
  99. package/registry/items/reaction.json +2 -2
  100. package/registry/items/reviewStack.json +3 -2
  101. package/registry/items/steps.json +6 -4
  102. package/registry/items/terminal.json +5 -4
  103. package/registry/items/testimonial.json +3 -2
  104. package/registry/items/tripleStats.json +4 -3
  105. package/registry/items/tweet.json +3 -2
  106. package/registry/items/webMockup.json +4 -3
  107. package/starters/video-chat/.env.example +16 -0
  108. package/starters/video-chat/README.md +63 -0
  109. package/starters/video-chat/index.html +12 -0
  110. package/starters/video-chat/package.json +28 -0
  111. package/starters/video-chat/server.ts +152 -0
  112. package/starters/video-chat/src/main.tsx +8 -0
  113. package/starters/video-chat/stock.ts +139 -0
  114. package/starters/video-chat/tsconfig.json +20 -0
  115. package/starters/video-chat/vite.config.ts +81 -0
  116. package/styles/video-chat.css +713 -0
  117. package/docs/input-and-first-scene.md +0 -64
  118. package/docs/integrate-nextjs.md +0 -86
  119. package/docs/live-channels.md +0 -149
  120. package/docs/use-cases.md +0 -59
  121. package/examples/nextjs-quickstart/.env.example +0 -2
  122. package/examples/nextjs-quickstart/README.md +0 -27
  123. package/examples/nextjs-quickstart/next-env.d.ts +0 -4
  124. package/examples/nextjs-quickstart/package.json +0 -25
  125. package/examples/nextjs-quickstart/src/app/api/video/route.ts +0 -33
  126. package/examples/nextjs-quickstart/src/app/layout.tsx +0 -5
  127. package/examples/nextjs-quickstart/src/app/page.tsx +0 -31
  128. package/examples/nextjs-quickstart/tsconfig.json +0 -26
  129. package/examples/server-integrations/README.md +0 -20
  130. package/examples/server-integrations/src/ai-sdk-media.ts +0 -90
@@ -2,121 +2,110 @@
2
2
 
3
3
  # Production guide
4
4
 
5
- Use this checklist before serving a video response to customers.
5
+ Use one `createVideoChatHandler` endpoint for capabilities, welcome content,
6
+ video responses, speech, transcription, stock search, and follow-up prompts.
7
+ Mount `<VideoChat />` or `useVideoChat` against that boundary.
6
8
 
7
9
  ## Server boundary
8
10
 
9
- - Keep provider keys, the system prompt, and tools on the server.
10
- - Authenticate the user and tenant before reading the request body.
11
- - Set an explicit origin allowlist. CORS is not authentication.
12
- - Apply per-user and per-tenant request, token, and concurrency limits.
13
- - Set route, model, media, and export timeouts with cancellation propagation.
14
- - Bound raw input size, media count, scene count, and maximum duration.
15
-
16
- Use `createVideoHandler()` for validated SSE and read
17
- [the security guide](security.md) for the mandatory controls.
18
- The handler automatically configures scene validation: it rejects unknown
19
- templates and fields, missing required variables, non-supplied media URLs, and
20
- fabricated quote-template content before a scene reaches the player.
21
- Applications with a custom stream adapter may authorize additional final URLs
22
- with `allowMediaUrl`; the callback validates URLs and does not resolve them.
23
- Invalid generated parts are dropped by default, after `onError` receives their
24
- private reason. Accepted scenes continue streaming with a safe recoverable
25
- diagnostic. Use `invalidPartBehavior: "fail"` only for deliberate fail-fast behavior.
11
+ - Keep provider keys, planner prompts, media tools, and raw errors on the server.
12
+ - Replace the generated localhost authorization with a real user and tenant check.
13
+ - Authenticate before reading the request body.
14
+ - Set an explicit origin allowlist; CORS is not authentication.
15
+ - Apply per-user and per-tenant request, token, concurrency, and spend limits.
16
+ - Bound prompt size, conversation turns, audio bytes, scene count, and duration.
17
+ - Forward cancellation to every text, speech, media, transcription, and video provider.
26
18
 
27
- ## Data and privacy
19
+ The handler rejects unknown templates and fields, invalid variables, unsafe
20
+ media, and fabricated quote-template content before a scene reaches the
21
+ player. Read the [security guide](security.md) for the complete controls.
28
22
 
29
- - Send the provider only the source and personalization required for the story.
30
- - Do not log raw prompts, personalization, authorization headers, signed URLs,
31
- or provider deltas.
32
- - Record request IDs, model ID, duration, event counts, safe error codes, token
33
- usage, and acceptance metrics.
34
- - Review your provider's retention settings and data-processing terms.
35
- - Keep signed asset URLs valid for the expected viewing and replay window.
36
-
37
- ## Reliability
38
-
39
- - Emit the supplied opening and selected audio before starting model work.
40
- - Abort provider work when the client disconnects.
41
- - Persist terminal snapshots for replay and export, then validate loaded values
42
- with `parseVideo` before use.
43
- - Persist event logs when resume is required; validate them with
44
- validate stored event logs before replay.
45
- - Treat the [persistence contract](persistence.md) as the storage boundary;
46
- database, tenant policy, object storage, deletion, and URL expiry remain
47
- host-owned.
48
- - Use idempotency keys around durable generation requests.
49
- - Retry only before visible output or from a validated resume point. Do not
50
- silently restart a response after the viewer has begun watching.
23
+ ## Visual modes and providers
51
24
 
52
- ## Failure experience
25
+ Keep templates available on every deployment. They are the reliable fallback
26
+ when stock, speech, or generated-video providers are missing or late. Add
27
+ `searchMedia` for approved stock footage and `generateVideo` for the separate
28
+ full AI video mode. Do not expose a partial generated-video mode.
29
+
30
+ Use explicit provider deadlines. Generated video should use idempotency keys
31
+ and `maxRetries: 0` so one visible action cannot silently create several
32
+ billable clips. Validate returned URLs, media types, byte sizes, duration, and
33
+ licensing before use.
53
34
 
54
- - Keep private provider details in `onError`; send only safe typed errors.
55
- - Do not display stack traces or protocol diagnostics inside the video.
56
- - Hold the current scene and continue audio through a recoverable generation
57
- gap.
58
- - End cleanly on a terminal error; never append blank media after completion.
59
- - Provide a normal application retry control outside the player.
35
+ ## Fast first response
60
36
 
61
- ## Media and audio
37
+ The planner's first streamed object supplies the spoken hook and media keyword.
38
+ Start speech immediately, resolve stock in parallel, and keep the opening
39
+ playing until the first narrated scene and its media are ready. Welcome cards
40
+ should carry a prepared hook and preloaded footage so they can start without a
41
+ model round trip.
62
42
 
63
- - Start generated playback with an asset-free scene.
64
- - Preload media for the next scene and commit it only when ready.
65
- - Resolve media before generation and pass approved results through
66
- `suppliedMedia`. Stock-keyword resolution is not part of the 0.1 handler.
67
- - Use customer-approved media domains and enforce type/byte limits.
68
- - Select soundtrack audio from an already-loaded catalog; declare a positive
69
- fade-out. Narration and speech synchronization are application-owned.
70
- - Respect browser autoplay rules and provide an explicit unmute control.
43
+ Do not wait for the complete plan before showing the first validated scene.
44
+ Preload upcoming assets and keep the current visual if the next one is late.
45
+ For full AI video, reserve the first shot in the opening object so generation
46
+ can begin while the planner streams later scenes.
71
47
 
72
- ## Observability
48
+ ## Data and privacy
49
+
50
+ - Send only the prompt, bounded conversation, and context needed for the answer.
51
+ - Do not log authorization headers, secret values, raw prompts, signed URLs, or provider deltas.
52
+ - Review provider retention and data-processing terms.
53
+ - Keep stored media URLs valid for the expected replay window.
54
+ - Validate persisted `Video` values with `parseVideo` before replay.
73
55
 
74
- Track at minimum:
56
+ ## Failure experience
75
57
 
76
- - time to supplied opening;
77
- - time to first generated scene;
78
- - time to complete plan;
79
- - seconds of future content buffered;
80
- - planner and protocol error codes;
81
- - media readiness failures;
82
- - completion and abandonment rate;
83
- - provider model and token usage.
58
+ - Keep private diagnostics in `onError`; expose only safe typed errors.
59
+ - Treat late media as a fallback case, not a reason to freeze playback.
60
+ - Keep the current scene and its narration during recoverable generation gaps.
61
+ - End cleanly on a terminal error and show an application retry control.
62
+ - Retry only before visible output or from an explicit validated resume point.
84
63
 
85
- Use the repository acceptance harness in smoke tests. The defaults
86
- require an opening within 250 ms, a generated scene within 15 seconds,
87
- completion within 30 seconds, resolved media, audio before the opening, three
88
- body scenes, three distinct templates, and a human quality score of 80.
64
+ ## Measure the stages
89
65
 
90
- ## Testing
66
+ Record safe server timing and quality fields rather than one opaque total:
91
67
 
92
- Use the React-free deterministic helpers in [Test integrations](testing.md) for
93
- Vitest, in-process streaming, and route-handler tests without a live provider.
68
+ - hook received;
69
+ - speech ready;
70
+ - first scene planned;
71
+ - first scene media ready;
72
+ - first frame painted;
73
+ - plan complete;
74
+ - accepted and rejected scene counts;
75
+ - provider model, finish reason, token usage, and media failures.
94
76
 
95
- Test the public path at its HTTP boundary. Pass a deterministic `streamText`
96
- generator to `createVideoHandler`, call the route with grounded input, and
97
- assert the validated terminal result through `useVideo`. Keep separate
98
- component tests for each trusted template.
77
+ Use `onComplete` for server-side cost and quality reporting and `onWarning` for
78
+ bounded recoverable issues. Never send provider-native metadata to the browser
79
+ unless the application has deliberately enabled and secured it.
99
80
 
100
- In CI, build and test the application. If the project owns copied templates,
101
- also verify that its registry is current:
81
+ ## Test the shipped path
82
+
83
+ Test the route with deterministic `streamText` and `generateText` callbacks.
84
+ Exercise `capabilities`, `welcome`, and `response`, then assert the rendered
85
+ conversation through `VideoChat`. Keep provider-adapter tests keyless and run a
86
+ small, explicitly gated real-provider smoke test before a release.
87
+
88
+ In CI, build one clean consumer from the packed SDK artifact. This catches
89
+ missing exports, server/browser boundary leaks, code-generation drift, and
90
+ dependency-resolution problems that workspace tests miss. If the application
91
+ owns copied templates, also run:
102
92
 
103
93
  ```bash
104
- npx vanillasky sync --check
94
+ npx vanillasky templates sync --check
105
95
  npm run build
106
96
  npm test
107
97
  ```
108
98
 
109
- Before release, build one clean consumer from the packed SDK tarball. This
110
- catches missing exports, React/server boundary leaks, code-generation drift,
111
- and dependency-resolution problems that workspace tests cannot detect.
112
-
113
99
  ## Deployment checklist
114
100
 
115
- - [ ] Provider keys exist only in the server secret store.
101
+ - [ ] Keys exist only in the server secret store.
116
102
  - [ ] Authentication, tenant policy, rate limits, and origin allowlist are live.
117
- - [ ] Cancellation, timeouts, and safe errors are tested.
118
- - [ ] Every installed template renders in both orientations.
119
- - [ ] Chromium, Firefox, WebKit, React, and Node compatibility checks pass.
120
- - [ ] A real provider run passes latency and human quality review.
121
- - [ ] Final snapshots replay exactly and export through the configured adapter.
122
- - [ ] Package and application dependency audits meet your severity policy.
103
+ - [ ] Cancellation, timeouts, fallbacks, and safe errors are tested.
104
+ - [ ] Template mode completes when every optional provider is unavailable.
105
+ - [ ] Full mode appears only when generated video is configured.
106
+ - [ ] Both orientations render and narration stays synchronized.
107
+ - [ ] A packed-artifact consumer and deterministic browser chat pass.
108
+ - [ ] One bounded real-provider run meets the product's latency and quality target.
109
+ - [ ] Stored responses replay exactly and application-owned export is verified.
110
+
111
+ [← Documentation home](../README.md) · [Previous: Errors and recovery](errors.md)
@@ -1,113 +1,63 @@
1
1
  [← Documentation home](../README.md) · [Next: Generate your first video →](getting-started.md)
2
2
 
3
- # Prompt and input
3
+ # Prompt and conversation input
4
4
 
5
- VanillaSky separates application truth from visual direction. You provide the
6
- facts and your server-side model. VanillaSky supplies the planner contract that
7
- turns those facts into a finite sequence of trusted scenes.
5
+ VanillaSky turns the same things people ask an AI chat into spoken video
6
+ answers. The SDK owns the video-planning prompt and conversation formatting;
7
+ the application owns the model, product guidance, authentication, and data.
8
8
 
9
- ## The four layers
9
+ ## What the viewer sends
10
10
 
11
- ### 1. VanillaSky system prompt
11
+ `<VideoChat />` and `useVideoChat` send the current prompt plus a bounded set of
12
+ earlier turns to one `/api/video-chat` endpoint. Prompts can ask for an
13
+ explanation, story, recommendation, ad, recap, or any other general-purpose AI
14
+ response. Do not put provider keys, private policy, or unrelated personal data
15
+ in the conversation.
12
16
 
13
- `createVideoHandler` generates `systemPrompt` from the trusted template
14
- registry. It tells the model:
15
-
16
- - which templates and variables exist;
17
- - how to emit the typed plan;
18
- - how to order and time complete scenes;
19
- - how to stay inside the factual and media boundaries;
20
- - how to finish a finite response.
21
-
22
- Normal applications should not build, copy, or expose this prompt in browser
23
- code. Pass it unchanged to the provider adapter.
24
-
25
- For maintainers, the base system rules live in
26
- `src/server/prompts/system-prompt.ts`, request-context formatting lives in
27
- `src/server/prompts/user-prompt.ts`, and template-specific catalog guidance
28
- lives in `src/visual-system/catalog/prompt.ts`. See the
29
- [architecture map](architecture.md) for the complete request flow.
30
-
31
- ### 2. Application instructions
32
-
33
- Use `instructions` for optional presentation direction:
17
+ When using the custom hook, ask in plain language:
34
18
 
35
19
  ```ts
36
- video.generate({
37
- input: "Account alerts launched today. They refresh every 15 minutes.",
38
- instructions: "Make the launch feel direct and energetic. End with adoption.",
39
- });
20
+ await chat.ask("Pitch a playful ad for a coffee mug that never spills");
40
21
  ```
41
22
 
42
- Instructions can influence selection, emphasis, ordering, tone, and pacing.
43
- They never change `knowledgeMode`, authorize a new media URL, or weaken the
44
- event and validation contract.
45
-
46
- For durable product-wide direction, use the server handler's `basePrompt`.
47
- Keep per-request creative direction in `instructions`.
48
-
49
- ### 3. Input and knowledge mode
50
-
51
- `input` is required. With the default `knowledgeMode: "input-only"`, it is the
52
- complete factual source for the video. It may be plain text or a serialized
53
- structured object:
23
+ A selected welcome or follow-up card can also include a prepared opening line
24
+ and already-loaded media:
54
25
 
55
26
  ```ts
56
- video.generate({
57
- input: "Activation increased from 41% to 58% after guided onboarding.",
27
+ await chat.ask(card.prompt, {
28
+ opening: card.opening,
29
+ openingMedia: card.media,
58
30
  });
59
31
  ```
60
32
 
61
- ```ts
62
- video.generate({
63
- input: JSON.stringify({
64
- period: "Q2",
65
- activation: { previous: 41, current: 58 },
66
- cause: "guided onboarding",
67
- }),
68
- });
69
- ```
33
+ That path starts immediately. A typed prompt instead receives its short spoken
34
+ hook and media keyword from the beginning of the planner stream.
70
35
 
71
- Include exact numbers, quote wording, attribution, names, dates, and product
72
- facts that may appear on screen. Do not place secrets, provider keys, or hidden
73
- policy in input.
36
+ ## Application guidance
74
37
 
75
- For a chat question or a request to develop content, opt in explicitly:
38
+ Use the server handler's `instructions` option for durable product direction:
76
39
 
77
40
  ```ts
78
- video.generate({
79
- input: "How can a small team improve customer onboarding?",
80
- knowledgeMode: "general",
41
+ createVideoChatHandler({
42
+ authorize: verifySession,
43
+ streamText: planWithYourModel,
44
+ generateText: runSmallTextTask,
45
+ instructions: [
46
+ "Speak like a warm, concise creative partner.",
47
+ "Prefer concrete examples over abstract explanations.",
48
+ ].join(" "),
81
49
  });
82
50
  ```
83
51
 
84
- General mode permits stable model knowledge. The generated system prompt still
85
- forbids invented citations, quotations, URLs, personal details, live facts,
86
- guarantees, and precise claims that require a source. Claims already present in
87
- `input` remain authoritative.
88
-
89
- `personalization`, `brand`, and `suppliedMedia` are separate structured context.
90
- They do not replace the source material.
91
-
92
- ### 4. Streamed plan
93
-
94
- Your provider streams text deltas. VanillaSky decodes them into typed planner
95
- parts, validates each complete scene, and emits deterministic protocol events.
96
- The model never returns React, HTML, CSS, or executable JavaScript.
97
-
98
- Every generated `scene.add` is complete and passes validation before the player
99
- sees it. Emitted scenes are immutable.
100
-
101
- The standard planner contract requires one `scene.add` with
102
- `placement: "closer"` immediately after the first playable body scene. The
103
- model writes short grounded conclusion copy: a supplied action when one
104
- exists, otherwise a declarative payoff that answers the story's “so what.” The
105
- runtime holds the closer and emits it last, so a long body plan cannot displace
106
- an ending that was already generated.
52
+ This can define a character, audience, subject area, tone, or answer style. It
53
+ does not change the protocol, authorize media, or weaken validation. Keep the
54
+ viewer prompt separate from these trusted server-side instructions.
107
55
 
108
- ## What reaches the LLM
56
+ ## What reaches the model
109
57
 
110
- The provider adapter receives:
58
+ `createVideoChatHandler` builds the trusted template catalog, video rules,
59
+ conversation context, and application guidance. Your provider adapter receives
60
+ two complete strings:
111
61
 
112
62
  ```ts
113
63
  streamText: ({ systemPrompt, userPrompt, signal }) => streamText({
@@ -115,94 +65,54 @@ streamText: ({ systemPrompt, userPrompt, signal }) => streamText({
115
65
  system: systemPrompt,
116
66
  prompt: userPrompt,
117
67
  abortSignal: signal,
118
- })
119
- ```
120
-
121
- `userPrompt` is assembled by VanillaSky from:
122
-
123
- - orientation and maximum duration;
124
- - whether a deterministic opening scene already exists or the host is waiting
125
- for the first generated scene;
126
- - raw `input`;
127
- - creative `instructions`;
128
- - personalization;
129
- - descriptions and opaque references for approved supplied media;
130
- - brand context.
131
-
132
- Provider credentials and application authentication never belong in either
133
- prompt. Original supplied-media URLs and data URIs also remain outside the
134
- model prompt; the server restores an exact SDK-issued opaque reference only
135
- after provider output has been parsed.
136
-
137
- Generated template values are validated exactly. VanillaSky does not silently
138
- truncate factual labels to satisfy a layout schema because truncation can drop
139
- qualifiers or change meaning. A rejected generated scene contributes to
140
- `rejectedSceneCount`; hosts can use the completion quality fields to retry with
141
- a stronger model or revised source.
142
-
143
- ## Input examples
144
-
145
- ### Product update
146
-
147
- ```ts
148
- video.generate({
149
- input: "Account alerts launched on August 16. They refresh every 15 minutes, filter by segment, and are available to all plans.",
150
68
  });
151
69
  ```
152
70
 
153
- ### Metrics recap
71
+ Pass both strings unchanged. The system prompt describes the installed
72
+ templates, schema limits, pacing, narration, opening contract, and safe media
73
+ fields. The user prompt contains the current request, bounded prior turns,
74
+ orientation, visual mode, and whether an opening was already spoken.
154
75
 
155
- ```ts
156
- video.generate({
157
- input: JSON.stringify({
158
- period: "Q2",
159
- customerConversations: 142,
160
- escalationsResolved: "96%",
161
- improvementsLaunched: 4,
162
- }),
163
- personalization: { role: "Product leader", focus: "activation" },
164
- });
165
- ```
166
-
167
- ### Grounded review
168
-
169
- ```ts
170
- video.generate({
171
- input: 'Review by Maya Chen, VP Product: "Setup took minutes, not weeks." Rating: 5/5.',
172
- });
173
- ```
76
+ Provider credentials and raw media URLs never belong in either prompt. Media
77
+ callbacks restore approved URLs on the server only after the model's structured
78
+ output has been parsed.
174
79
 
175
- Every visible quote must occur in the input exactly. Attribution and ratings
176
- should be explicit.
80
+ ## One stream, one answer
177
81
 
178
- ### Article or long source
82
+ The planner first emits a 6–9 word spoken hook and a media keyword, then keeps
83
+ streaming complete scenes. It is not a separate hook call followed by a second
84
+ planning call. This keeps the opening consistent with the scenes that follow
85
+ and lets the first playable scene arrive without waiting for the complete plan.
179
86
 
180
- Pass the source text and let the planner select the most decision-relevant
181
- takeaways that fit the duration. The planner summarizes; it should not attempt
182
- to place every paragraph on screen.
87
+ Every `scene.add` is validated before the browser receives it. The model never
88
+ returns React, HTML, CSS, or executable JavaScript. Accepted scenes are
89
+ immutable; invalid scenes are reported through safe warnings and omitted.
183
90
 
184
- ## Grounding and media safety
91
+ In template mode, the planner can choose any trusted template and request stock
92
+ media through `searchMedia`. In full mode, it plans a complete generated-video
93
+ answer and `generateVideo` resolves every visual beat. There is no mixed
94
+ "generate a few clips" mode.
185
95
 
186
- - Numeric templates require real numbers present in the source.
187
- - Every grounded quote value must occur in the source, not merely one quote in a scene.
188
- - Screenshot fields require an exact supplied image.
189
- - Media URLs must be supplied or approved by the server's `allowMediaUrl` policy.
190
- - Patches are validated after merging with the existing scene.
96
+ ## Grounding
191
97
 
192
- These checks happen at runtime. Prompt instructions improve model behavior but
193
- are not treated as a security boundary.
98
+ General chat permits stable model knowledge, but it still forbids invented
99
+ citations, quotations, URLs, personal details, live facts, and guarantees. If
100
+ exact numbers, names, dates, or wording matter, include them in the prompt or
101
+ conversation. Use retrieval in the application before calling VanillaSky when
102
+ the answer depends on private or current data.
194
103
 
195
- ## Debugging
104
+ ## Debugging weak answers
196
105
 
197
- If the plan is rejected or the result is weak, inspect the boundary in this order:
106
+ Check these boundaries in order:
198
107
 
199
- 1. **Input:** Does it contain the exact facts, numbers, quotes, and attribution?
200
- 2. **Instructions:** Are they presentation guidance rather than new claims?
201
- 3. **Provider adapter:** Does it pass both prompts unchanged and stream only text deltas?
202
- 4. **Finish reason:** Did the provider report `length`, a content filter, or an execution error?
203
- 5. **Template fit:** Does the trusted registry contain a suitable visual for the requested story?
108
+ 1. Does the prompt contain the exact facts the answer needs?
109
+ 2. Is `instructions` concise product guidance rather than extra source data?
110
+ 3. Does the provider pass `systemPrompt` and `userPrompt` unchanged?
111
+ 4. Is extended reasoning delaying the first streamed object?
112
+ 5. Do `onWarning` and `onComplete` show rejected scenes or a length limit?
113
+ 6. Does the trusted registry contain a suitable template for the requested answer?
204
114
 
205
- Log request IDs, provider finish reasons, and terminal SDK status. Do not log
206
- secrets or expose raw provider diagnostics inside the video.
115
+ Log request IDs, safe warning codes, provider finish reasons, model IDs, and
116
+ token usage. Never log credentials or expose raw provider errors in the video.
207
117
 
208
118
  [← Documentation home](../README.md) · [Next: Generate your first video →](getting-started.md)