@vanillaskyai/video 0.5.8 → 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.
- package/CHANGELOG.md +178 -0
- package/PUBLIC-API.md +129 -9
- package/README.md +70 -108
- package/dist/{bg-confetti-SHQI7ATB.js → bg-confetti-HITCGLGD.js} +1 -1
- package/dist/{bg-emoji-XYFRA63Q.js → bg-emoji-VU4UZYZN.js} +1 -1
- package/dist/{bg-media-FEBATBT2.js → bg-media-L34PDQXJ.js} +4 -4
- package/dist/{brand-message-P56WEJPG.js → brand-message-FUJ4STFO.js} +3 -3
- package/dist/{builtin-server-YHEZ2JRF.js → builtin-server-KB7FKF6A.js} +2 -2
- package/dist/{chart-bar-ZB45ZRKH.js → chart-bar-EGPHJATL.js} +4 -4
- package/dist/{chart-counter-HFYNE4HT.js → chart-counter-5FFWQNZO.js} +4 -4
- package/dist/{chart-progress-ring-ZKMLRGSB.js → chart-progress-ring-JMXQLMLC.js} +4 -4
- package/dist/check-runtime.js +2 -2
- package/dist/{chunk-66MNRUCR.js → chunk-2PYO6VAC.js} +51 -3
- package/dist/{chunk-ZQQQAAKP.js → chunk-2XT4MZ76.js} +33 -2
- package/dist/chunk-5CDAM24P.js +31 -0
- package/dist/{chunk-PNS52FL4.js → chunk-5SLENAJW.js} +19 -6
- package/dist/{chunk-EFL34TXF.js → chunk-AITKH6QT.js} +24 -8
- package/dist/{chunk-HT6BGERF.js → chunk-FRN6WKHA.js} +28 -10
- package/dist/{chunk-FZHMQFG3.js → chunk-GAIOHGNR.js} +5 -21
- package/dist/{chunk-3RV4YKB3.js → chunk-JNN3EYVP.js} +51 -26
- package/dist/{chunk-NGY3TNND.js → chunk-K746NUIP.js} +70 -50
- package/dist/{chunk-HVCPEAQF.js → chunk-LKBZX7GV.js} +9 -6
- package/dist/{chunk-G66Z5CWR.js → chunk-MMUXVA47.js} +27 -3
- package/dist/{chunk-6M6DATLW.js → chunk-MXZSDGZQ.js} +6 -5
- package/dist/{chunk-3OU7HIEB.js → chunk-RE4IMWJR.js} +15 -31
- package/dist/{chunk-FVTMYS6U.js → chunk-RGF452LL.js} +1 -1
- package/dist/{chunk-34O5BY6X.js → chunk-RXHW4EP4.js} +21 -4
- package/dist/chunk-SKRGRKHY.js +142 -0
- package/dist/{chunk-TCEHK2BW.js → chunk-YJJC4N4D.js} +2 -1
- package/dist/cli.js +438 -30
- package/dist/{compose-video-JWIEDTEJ.js → compose-video-PD6LKKRK.js} +4 -4
- package/dist/{cta-logo-S4OMTNXD.js → cta-logo-YR7LYUR5.js} +3 -3
- package/dist/{cta-media-EROTHDRR.js → cta-media-DQJBKUO2.js} +4 -4
- package/dist/{events-BBP30j3c.d.ts → events-B6qS1Lsb.d.ts} +2 -2
- package/dist/{incoming-call-5IWJ2TAS.js → incoming-call-54KQ7O5A.js} +3 -3
- package/dist/index.d.ts +89 -3
- package/dist/index.js +12 -1
- package/dist/{infographic-before-after-2I7YZVDD.js → infographic-before-after-ROS52GOW.js} +1 -1
- package/dist/{infographic-feature-list-7SK65U3K.js → infographic-feature-list-E7MGUDAN.js} +4 -4
- package/dist/{infographic-problem-solution-IW35S6BR.js → infographic-problem-solution-3S6NGO5N.js} +4 -4
- package/dist/{infographic-stat-row-XHUZZPDM.js → infographic-stat-row-SYB7AB7H.js} +4 -4
- package/dist/{infographic-steps-JDDEDI7X.js → infographic-steps-KCE6JWE2.js} +4 -4
- package/dist/{kit-DEG3fcaL.d.ts → kit-8g46H2RZ.d.ts} +1 -1
- package/dist/{prompt-input-6ZWXEL3V.js → prompt-input-MHX4O42G.js} +3 -3
- package/dist/react.d.ts +200 -6
- package/dist/react.js +1859 -43
- package/dist/{reaction-Z3JIM3MQ.js → reaction-SLEGR3BE.js} +4 -4
- package/dist/{scene-video-backdrop-IL4F2SVD.js → scene-video-backdrop-XFPX4O3I.js} +2 -1
- package/dist/server.d.ts +104 -4
- package/dist/server.js +976 -26
- package/dist/{showcase-code-NWQAAJIA.js → showcase-code-2HLAVKBM.js} +4 -4
- package/dist/{showcase-phone-5UW45ATT.js → showcase-phone-Q4HEO4LH.js} +4 -4
- package/dist/{showcase-terminal-UVOD25UF.js → showcase-terminal-DL45LUFG.js} +4 -4
- package/dist/{showcase-web-3AW6VHIG.js → showcase-web-2QZO73FZ.js} +4 -4
- package/dist/{social-milestone-KPKHFOB5.js → social-milestone-GEFUQSBF.js} +3 -3
- package/dist/{social-notification-EDOU6TZB.js → social-notification-FJ5VHVLK.js} +3 -3
- package/dist/{social-review-stack-EZOO33SV.js → social-review-stack-KXQCKFRP.js} +3 -3
- package/dist/{social-testimonial-DLOINMMY.js → social-testimonial-JZ7CHC7S.js} +3 -3
- package/dist/{social-tweet-6JUM323G.js → social-tweet-UCDXM25F.js} +3 -3
- package/dist/{system-prompt-4I6Z5HK3.js → system-prompt-RRXIWDDD.js} +5 -3
- package/dist/template-catalog.js +1 -1
- package/dist/templates.d.ts +3 -3
- package/dist/test.d.ts +2 -2
- package/dist/test.js +3 -3
- package/dist/{text-stream-J6EDDJP4.js → text-stream-FW4BLBAL.js} +2 -2
- package/dist/{types-BV9IqExh.d.ts → types-2wHBqtg8.d.ts} +29 -1
- package/dist/types-DrABlRa7.d.ts +46 -0
- package/docs/agent-integration.md +49 -25
- package/docs/architecture.md +37 -22
- package/docs/branding-and-personalization.md +1 -1
- package/docs/concepts.md +14 -0
- package/docs/custom-templates.md +9 -9
- package/docs/customization.md +41 -5
- package/docs/getting-started.md +81 -84
- package/docs/media-and-audio.md +113 -117
- package/docs/persistence.md +1 -1
- package/docs/production.md +81 -92
- package/docs/prompt-and-input.md +71 -161
- package/docs/provider-integration.md +91 -49
- package/docs/responsive-orientation.md +1 -1
- package/docs/security.md +6 -5
- package/docs/streaming-protocol.md +1 -1
- package/docs/testing.md +51 -43
- package/examples/custom-template/README.md +1 -1
- package/package.json +20 -21
- package/registry/items/backgrounds.json +2 -2
- package/registry/items/barChart.json +6 -4
- package/registry/items/beforeAfter.json +1 -1
- package/registry/items/bigNumber.json +4 -3
- package/registry/items/brandMessage.json +3 -2
- package/registry/items/cardList.json +6 -4
- package/registry/items/codeEditor.json +4 -3
- package/registry/items/confetti.json +1 -1
- package/registry/items/ctaLogo.json +3 -2
- package/registry/items/ctaMedia.json +4 -3
- package/registry/items/emojiBurst.json +1 -1
- package/registry/items/incomingCall.json +3 -2
- package/registry/items/media.json +4 -3
- package/registry/items/milestone.json +3 -2
- package/registry/items/notification.json +3 -2
- package/registry/items/phoneMockup.json +4 -3
- package/registry/items/problemSolution.json +4 -3
- package/registry/items/progressRing.json +4 -3
- package/registry/items/promptInput.json +3 -2
- package/registry/items/reaction.json +2 -2
- package/registry/items/reviewStack.json +3 -2
- package/registry/items/steps.json +6 -4
- package/registry/items/terminal.json +5 -4
- package/registry/items/testimonial.json +3 -2
- package/registry/items/tripleStats.json +4 -3
- package/registry/items/tweet.json +3 -2
- package/registry/items/webMockup.json +4 -3
- package/starters/video-chat/.env.example +16 -0
- package/starters/video-chat/README.md +63 -0
- package/starters/video-chat/index.html +12 -0
- package/starters/video-chat/package.json +28 -0
- package/starters/video-chat/server.ts +152 -0
- package/starters/video-chat/src/main.tsx +8 -0
- package/starters/video-chat/stock.ts +139 -0
- package/starters/video-chat/tsconfig.json +20 -0
- package/starters/video-chat/vite.config.ts +81 -0
- package/styles/video-chat.css +713 -0
- package/dist/chunk-C6WVCZRW.js +0 -19
- package/docs/input-and-first-scene.md +0 -64
- package/docs/integrate-nextjs.md +0 -86
- package/docs/live-channels.md +0 -149
- package/docs/use-cases.md +0 -59
- package/examples/nextjs-quickstart/.env.example +0 -2
- package/examples/nextjs-quickstart/README.md +0 -27
- package/examples/nextjs-quickstart/next-env.d.ts +0 -4
- package/examples/nextjs-quickstart/package.json +0 -25
- package/examples/nextjs-quickstart/src/app/api/video/route.ts +0 -24
- package/examples/nextjs-quickstart/src/app/layout.tsx +0 -5
- package/examples/nextjs-quickstart/src/app/page.tsx +0 -31
- package/examples/nextjs-quickstart/tsconfig.json +0 -26
package/docs/production.md
CHANGED
|
@@ -2,121 +2,110 @@
|
|
|
2
2
|
|
|
3
3
|
# Production guide
|
|
4
4
|
|
|
5
|
-
Use
|
|
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,
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
- Bound
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
56
|
+
## Failure experience
|
|
75
57
|
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
66
|
+
Record safe server timing and quality fields rather than one opaque total:
|
|
91
67
|
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
101
|
-
|
|
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
|
-
- [ ]
|
|
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
|
-
- [ ]
|
|
119
|
-
- [ ]
|
|
120
|
-
- [ ]
|
|
121
|
-
- [ ]
|
|
122
|
-
- [ ]
|
|
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)
|
package/docs/prompt-and-input.md
CHANGED
|
@@ -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
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
##
|
|
9
|
+
## What the viewer sends
|
|
10
10
|
|
|
11
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
43
|
-
|
|
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
|
-
|
|
57
|
-
|
|
27
|
+
await chat.ask(card.prompt, {
|
|
28
|
+
opening: card.opening,
|
|
29
|
+
openingMedia: card.media,
|
|
58
30
|
});
|
|
59
31
|
```
|
|
60
32
|
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
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
|
-
|
|
38
|
+
Use the server handler's `instructions` option for durable product direction:
|
|
76
39
|
|
|
77
40
|
```ts
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
|
56
|
+
## What reaches the model
|
|
109
57
|
|
|
110
|
-
|
|
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
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
176
|
-
should be explicit.
|
|
80
|
+
## One stream, one answer
|
|
177
81
|
|
|
178
|
-
|
|
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
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
193
|
-
|
|
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
|
-
|
|
106
|
+
Check these boundaries in order:
|
|
198
107
|
|
|
199
|
-
1.
|
|
200
|
-
2.
|
|
201
|
-
3.
|
|
202
|
-
4.
|
|
203
|
-
5.
|
|
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,
|
|
206
|
-
|
|
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)
|