@vanillaskyai/video 0.1.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 (162) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/LICENSE +201 -0
  3. package/PUBLIC-API.md +276 -0
  4. package/README.md +152 -0
  5. package/SECURITY.md +22 -0
  6. package/SUPPORT.md +28 -0
  7. package/bin/vanillasky.js +3 -0
  8. package/dist/bg-confetti-WNQXS7ZS.js +89 -0
  9. package/dist/bg-emoji-ETI47GLS.js +150 -0
  10. package/dist/bg-media-SVUZAMGX.js +99 -0
  11. package/dist/brand-message-F3RD4P3P.js +253 -0
  12. package/dist/builtin-server-F7YXRVCH.js +8 -0
  13. package/dist/catalog-types-BIhSpOWK.d.ts +74 -0
  14. package/dist/chart-bar-CNSC7BNK.js +304 -0
  15. package/dist/chart-counter-MCRHKN77.js +299 -0
  16. package/dist/chart-progress-ring-RMI4A7ZK.js +296 -0
  17. package/dist/check-runtime.d.ts +15 -0
  18. package/dist/check-runtime.js +102 -0
  19. package/dist/chunk-2E6T633S.js +27 -0
  20. package/dist/chunk-352ZZCET.js +83 -0
  21. package/dist/chunk-73NTSFFI.js +81 -0
  22. package/dist/chunk-A2X45FET.js +46 -0
  23. package/dist/chunk-ABPKM4GK.js +187 -0
  24. package/dist/chunk-ABZACD4G.js +216 -0
  25. package/dist/chunk-BCRUUJ6A.js +756 -0
  26. package/dist/chunk-CHLGW22F.js +3551 -0
  27. package/dist/chunk-CJ7F2CE6.js +104 -0
  28. package/dist/chunk-CR7FE7BW.js +109 -0
  29. package/dist/chunk-E7CL7UPB.js +109 -0
  30. package/dist/chunk-EE6PK6XC.js +18 -0
  31. package/dist/chunk-ERY4S6QV.js +385 -0
  32. package/dist/chunk-EVG2ZYIY.js +125 -0
  33. package/dist/chunk-FNAEQ7QO.js +155 -0
  34. package/dist/chunk-FQ47WXAJ.js +38 -0
  35. package/dist/chunk-FSG2PYWG.js +336 -0
  36. package/dist/chunk-GHJEAP4O.js +504 -0
  37. package/dist/chunk-GRMUV7QY.js +262 -0
  38. package/dist/chunk-IFOW65Z6.js +205 -0
  39. package/dist/chunk-IXCUY3B3.js +786 -0
  40. package/dist/chunk-L5BTTCZV.js +97 -0
  41. package/dist/chunk-LMG3GHLL.js +107 -0
  42. package/dist/chunk-OOPIETLW.js +101 -0
  43. package/dist/chunk-P22HHFDK.js +43 -0
  44. package/dist/chunk-QAAO7OAY.js +19 -0
  45. package/dist/chunk-S7HFLYNN.js +35 -0
  46. package/dist/chunk-SPVTJH3F.js +24 -0
  47. package/dist/chunk-W2XJKG6C.js +3177 -0
  48. package/dist/chunk-XB7LH4J2.js +301 -0
  49. package/dist/chunk-XGRA2MUV.js +242 -0
  50. package/dist/chunk-XTOXFMLM.js +105 -0
  51. package/dist/chunk-YC5MFXA5.js +132 -0
  52. package/dist/cli.d.ts +1 -0
  53. package/dist/cli.js +1681 -0
  54. package/dist/compose-video-CN3VSWST.js +13 -0
  55. package/dist/cta-logo-SVA5GP2A.js +209 -0
  56. package/dist/cta-media-E7VLLK42.js +215 -0
  57. package/dist/events-_wfjbmEp.d.ts +81 -0
  58. package/dist/incoming-call-62MFZL3Z.js +320 -0
  59. package/dist/index.d.ts +15 -0
  60. package/dist/index.js +14 -0
  61. package/dist/infographic-before-after-AXCDAWND.js +460 -0
  62. package/dist/infographic-feature-list-GW5GUE6O.js +266 -0
  63. package/dist/infographic-problem-solution-7NURJANA.js +340 -0
  64. package/dist/infographic-stat-row-J7IZR6ZN.js +241 -0
  65. package/dist/infographic-steps-VSZM6F5M.js +400 -0
  66. package/dist/kit-BMNcHqa9.d.ts +79 -0
  67. package/dist/prompt-input-LOUCRXCY.js +236 -0
  68. package/dist/react.d.ts +81 -0
  69. package/dist/react.js +835 -0
  70. package/dist/reaction-QG4CYZLQ.js +119 -0
  71. package/dist/server.d.ts +141 -0
  72. package/dist/server.js +498 -0
  73. package/dist/showcase-code-RUTFZR3H.js +351 -0
  74. package/dist/showcase-phone-6CP6XEU5.js +272 -0
  75. package/dist/showcase-terminal-MGAEQWPR.js +306 -0
  76. package/dist/showcase-web-Y4W2HVRJ.js +390 -0
  77. package/dist/social-conversation-75SD2637.js +695 -0
  78. package/dist/social-milestone-XI2QE5BO.js +292 -0
  79. package/dist/social-notification-2UOHQCUY.js +244 -0
  80. package/dist/social-review-stack-FDYZGZTJ.js +239 -0
  81. package/dist/social-testimonial-OQ7N52GJ.js +284 -0
  82. package/dist/social-tweet-5OLCNPPC.js +295 -0
  83. package/dist/state-DZcKuS32.d.ts +3 -0
  84. package/dist/system-prompt-A6UXNTPK.js +8 -0
  85. package/dist/template-catalog.d.ts +24 -0
  86. package/dist/template-catalog.js +6 -0
  87. package/dist/templates.d.ts +25 -0
  88. package/dist/templates.js +19 -0
  89. package/dist/test.d.ts +149 -0
  90. package/dist/test.js +272 -0
  91. package/dist/text-stream-6XHC7J47.js +10 -0
  92. package/dist/types-B-PZR6G_.d.ts +208 -0
  93. package/dist/validate-T7GBU2YF.js +8 -0
  94. package/docs/agent-integration.md +39 -0
  95. package/docs/architecture.md +84 -0
  96. package/docs/branding-and-personalization.md +87 -0
  97. package/docs/concepts.md +106 -0
  98. package/docs/custom-templates.md +329 -0
  99. package/docs/customization.md +141 -0
  100. package/docs/errors.md +70 -0
  101. package/docs/getting-started.md +111 -0
  102. package/docs/input-and-first-scene.md +41 -0
  103. package/docs/integrate-nextjs.md +79 -0
  104. package/docs/media-and-audio.md +69 -0
  105. package/docs/motion-and-effects.md +107 -0
  106. package/docs/persistence.md +95 -0
  107. package/docs/production.md +122 -0
  108. package/docs/prompt-and-input.md +185 -0
  109. package/docs/provider-integration.md +115 -0
  110. package/docs/reference/protocol.md +96 -0
  111. package/docs/reference/provider-adapters.md +158 -0
  112. package/docs/responsive-orientation.md +37 -0
  113. package/docs/security.md +38 -0
  114. package/docs/streaming-protocol.md +15 -0
  115. package/docs/testing.md +137 -0
  116. package/docs/use-cases.md +59 -0
  117. package/examples/custom-template/README.md +19 -0
  118. package/examples/custom-template/minimal-text.tsx +82 -0
  119. package/examples/custom-template/structured-data.tsx +104 -0
  120. package/examples/custom-template/supplied-media.tsx +92 -0
  121. package/examples/nextjs-quickstart/.env.example +2 -0
  122. package/examples/nextjs-quickstart/README.md +22 -0
  123. package/examples/nextjs-quickstart/next-env.d.ts +4 -0
  124. package/examples/nextjs-quickstart/package.json +24 -0
  125. package/examples/nextjs-quickstart/src/app/api/video/route.ts +22 -0
  126. package/examples/nextjs-quickstart/src/app/layout.tsx +5 -0
  127. package/examples/nextjs-quickstart/src/app/page.tsx +31 -0
  128. package/examples/nextjs-quickstart/tsconfig.json +26 -0
  129. package/package.json +167 -0
  130. package/registry/items/backgrounds.json +52 -0
  131. package/registry/items/barChart.json +237 -0
  132. package/registry/items/beforeAfter.json +180 -0
  133. package/registry/items/bigNumber.json +225 -0
  134. package/registry/items/brandMessage.json +158 -0
  135. package/registry/items/cardList.json +206 -0
  136. package/registry/items/chatMessenger.json +151 -0
  137. package/registry/items/chatWhatsapp.json +151 -0
  138. package/registry/items/codeEditor.json +184 -0
  139. package/registry/items/confetti.json +107 -0
  140. package/registry/items/ctaLogo.json +160 -0
  141. package/registry/items/ctaMedia.json +193 -0
  142. package/registry/items/emojiBurst.json +101 -0
  143. package/registry/items/incomingCall.json +170 -0
  144. package/registry/items/media.json +179 -0
  145. package/registry/items/milestone.json +205 -0
  146. package/registry/items/motion.json +45 -0
  147. package/registry/items/notification.json +182 -0
  148. package/registry/items/phoneMockup.json +254 -0
  149. package/registry/items/problemSolution.json +186 -0
  150. package/registry/items/progressRing.json +199 -0
  151. package/registry/items/promptInput.json +148 -0
  152. package/registry/items/reaction.json +170 -0
  153. package/registry/items/reviewStack.json +224 -0
  154. package/registry/items/steps.json +207 -0
  155. package/registry/items/template-context.json +31 -0
  156. package/registry/items/terminal.json +212 -0
  157. package/registry/items/testimonial.json +164 -0
  158. package/registry/items/theme.json +47 -0
  159. package/registry/items/tripleStats.json +228 -0
  160. package/registry/items/tweet.json +203 -0
  161. package/registry/items/typography.json +47 -0
  162. package/registry/items/webMockup.json +273 -0
@@ -0,0 +1,104 @@
1
+ import {
2
+ getCelebrationParticleTiming
3
+ } from "./chunk-QAAO7OAY.js";
4
+
5
+ // src/visual-system/scene-templates/confetti-layer.tsx
6
+ import { Fragment, jsx } from "react/jsx-runtime";
7
+ var PARTICLE_COUNT = 200;
8
+ var COLORS = ["#ef4444", "#ff6b6b", "#f97316", "#fb923c", "#ffd93d", "#34d399", "#6bcbff", "#818cf8", "#a78bfa", "#f472b6", "#ffffff"];
9
+ function seededRandom(seed) {
10
+ const x = Math.sin(seed * 12.9898 + seed * 78.233) * 43758.5453;
11
+ return x - Math.floor(x);
12
+ }
13
+ function easeOutQuad(p) {
14
+ return 1 - (1 - p) * (1 - p);
15
+ }
16
+ function hexHue(hex) {
17
+ const r = parseInt(hex.slice(1, 3), 16) / 255;
18
+ const g = parseInt(hex.slice(3, 5), 16) / 255;
19
+ const b = parseInt(hex.slice(5, 7), 16) / 255;
20
+ const max = Math.max(r, g, b);
21
+ const min = Math.min(r, g, b);
22
+ const d = max - min;
23
+ if (d === 0) return 0;
24
+ let h = 0;
25
+ if (max === r) h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
26
+ else if (max === g) h = ((b - r) / d + 2) / 6;
27
+ else h = ((r - g) / d + 4) / 6;
28
+ return h * 360;
29
+ }
30
+ function hueDistance(a, b) {
31
+ const d = Math.abs(a - b) % 360;
32
+ return d > 180 ? 360 - d : d;
33
+ }
34
+ var ConfettiLayer = ({
35
+ progress,
36
+ width,
37
+ height,
38
+ beatIntensity = 0,
39
+ bgColor
40
+ }) => {
41
+ const s = Math.min(width, height) / 1080;
42
+ const BURST_RADIUS = Math.max(width, height) * 0.95;
43
+ let allColors = COLORS;
44
+ if (bgColor) {
45
+ const bgHue = hexHue(bgColor);
46
+ const filtered = COLORS.filter((c) => c === "#ffffff" || hueDistance(hexHue(c), bgHue) > 35);
47
+ if (filtered.length >= 4) allColors = filtered;
48
+ }
49
+ return /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: PARTICLE_COUNT }, (_, i) => {
50
+ const seed = i + 1;
51
+ const angle = i / PARTICLE_COUNT * Math.PI * 2;
52
+ const forceFactor = 0.75 + seededRandom(seed * 1) * 0.5;
53
+ const durationFactor = 1.1 + seededRandom(seed * 3) * 0.6;
54
+ const color = allColors[i % allColors.length];
55
+ const isCircle = seededRandom(seed * 4) > 0.85;
56
+ const startRot = seededRandom(seed * 5) * 360;
57
+ const rotSpeed = (seededRandom(seed * 6) - 0.5) * 1440;
58
+ const flipSpeed = 3 + seededRandom(seed * 7) * 4;
59
+ const flipPhase = seededRandom(seed * 8) * Math.PI * 2;
60
+ const widthFactor = 0.45 + seededRandom(seed * 9) * 0.6;
61
+ const heightFactor = 0.7 + seededRandom(seed * 10) * 0.6;
62
+ const timing = getCelebrationParticleTiming(progress, i, durationFactor);
63
+ if (!timing) return null;
64
+ const p = timing.progress;
65
+ const reach = BURST_RADIUS * forceFactor;
66
+ const radialP = easeOutQuad(p);
67
+ const gravity = height * 0.08 * p * p;
68
+ const x = width * 0.5 + Math.cos(angle) * reach * radialP;
69
+ const y = height * 0.5 + Math.sin(angle) * reach * radialP + gravity;
70
+ const flip = Math.cos(p * Math.PI * flipSpeed + flipPhase);
71
+ const rot = startRot + rotSpeed * p;
72
+ const baseSize = (8 + seededRandom(seed * 11) * 10) * s;
73
+ const w = baseSize * widthFactor;
74
+ const h = isCircle ? w : baseSize * heightFactor;
75
+ const popScale = Math.min(1, p * 30);
76
+ const particleOpacity = p < 0.85 ? 1 : Math.max(0, 1 - (p - 0.85) / 0.15);
77
+ const opacity = particleOpacity * timing.opacity;
78
+ const beatPulse = 1 + beatIntensity * 0.15;
79
+ if (opacity <= 0) return null;
80
+ if (y > height + 120 || y < -120 || x < -120 || x > width + 120) return null;
81
+ return /* @__PURE__ */ jsx(
82
+ "div",
83
+ {
84
+ style: {
85
+ position: "absolute",
86
+ left: x - w / 2,
87
+ top: y - h / 2,
88
+ width: w,
89
+ height: h,
90
+ borderRadius: isCircle ? "50%" : 1,
91
+ backgroundColor: color,
92
+ opacity,
93
+ transform: `rotate(${rot}deg) scaleX(${flip}) scale(${popScale * beatPulse})`,
94
+ pointerEvents: "none"
95
+ }
96
+ },
97
+ i
98
+ );
99
+ }) });
100
+ };
101
+
102
+ export {
103
+ ConfettiLayer
104
+ };
@@ -0,0 +1,109 @@
1
+ import {
2
+ assertTemplateTransitionMetadata
3
+ } from "./chunk-2E6T633S.js";
4
+
5
+ // src/visual-system/catalog/kit.ts
6
+ function toMetadata(template) {
7
+ return {
8
+ id: template.id,
9
+ label: template.label,
10
+ description: template.description,
11
+ category: template.category,
12
+ family: template.family,
13
+ usesGlobalTextEffect: template.usesGlobalTextEffect,
14
+ usesGlobalTransition: template.usesGlobalTransition,
15
+ transitionTiming: template.transitionTiming,
16
+ usesGlobalBackgroundEffect: template.usesGlobalBackgroundEffect,
17
+ textCanvas: template.textCanvas,
18
+ jobs: template.jobs,
19
+ register: template.register,
20
+ useWhen: template.useWhen,
21
+ avoidWhen: template.avoidWhen,
22
+ schema: template.schema,
23
+ minDuration: template.minDuration,
24
+ preferredDuration: template.preferredDuration,
25
+ timing: template.timing
26
+ };
27
+ }
28
+ function isTemplateJsonSchema(value) {
29
+ if (typeof value !== "object" || value == null) return false;
30
+ const schema = value;
31
+ return schema.type === "object" && typeof schema.properties === "object" && schema.properties != null;
32
+ }
33
+ function defineTemplate(definition) {
34
+ if (!/^[A-Za-z][A-Za-z0-9_-]*$/.test(definition.id)) {
35
+ throw new Error(`Invalid template id: ${definition.id}`);
36
+ }
37
+ const suppliedSchema = "schema" in definition ? definition.schema : void 0;
38
+ const standard = suppliedSchema && "~standard" in suppliedSchema ? suppliedSchema["~standard"] : void 0;
39
+ const convertedSchema = standard?.jsonSchema ? standard.jsonSchema.input({ target: "draft-07" }) : suppliedSchema && !("~standard" in suppliedSchema) ? suppliedSchema : void 0;
40
+ if (standard && !standard.jsonSchema) {
41
+ throw new Error("Template schemas must expose Standard JSON Schema so the server registry can be generated safely");
42
+ }
43
+ if (!convertedSchema || !isTemplateJsonSchema(convertedSchema)) {
44
+ throw new Error("Template schema must describe a JSON object");
45
+ }
46
+ const schema = { ...convertedSchema, additionalProperties: convertedSchema.additionalProperties ?? false };
47
+ const transitionMetadata = {
48
+ id: definition.id,
49
+ usesGlobalTransition: definition.usesGlobalTransition ?? false,
50
+ transitionTiming: definition.transitionTiming
51
+ };
52
+ assertTemplateTransitionMetadata(transitionMetadata);
53
+ const { schema: _runtimeSchema, duration, ...definitionWithoutSchema } = definition;
54
+ return Object.freeze({
55
+ label: definition.id,
56
+ description: "",
57
+ usesGlobalTextEffect: false,
58
+ usesGlobalTransition: false,
59
+ usesGlobalBackgroundEffect: false,
60
+ ...definitionWithoutSchema,
61
+ schema,
62
+ ...duration == null ? {} : { preferredDuration: duration }
63
+ });
64
+ }
65
+ function createRenderTemplateRegistry(options) {
66
+ const byId = /* @__PURE__ */ new Map();
67
+ for (const template of options.templates) {
68
+ assertTemplateTransitionMetadata(template);
69
+ if (byId.has(template.id)) throw new Error(`Duplicate template id: ${template.id}`);
70
+ byId.set(template.id, template);
71
+ }
72
+ const templates = Object.freeze([...options.templates]);
73
+ if (options.metadata && options.metadata.map(({ id }) => id).join("\0") !== templates.map(({ id }) => id).join("\0")) {
74
+ throw new Error("Template metadata does not match render templates");
75
+ }
76
+ const metadata = new Map((options.metadata ?? templates.map(toMetadata)).map((template) => [template.id, template]));
77
+ const capabilities = { templates: templates.map(({ id }) => id) };
78
+ return Object.freeze({
79
+ templates,
80
+ capabilities,
81
+ getTemplate: (id) => byId.get(id),
82
+ getTemplateMetadata: (id) => metadata.get(id),
83
+ listTemplateMetadata: () => [...metadata.values()]
84
+ });
85
+ }
86
+ function overlayTemplateRegistry(defaults, customer) {
87
+ const customerTemplates = new Map(customer.templates.map((template) => [template.id, template]));
88
+ const defaultIds = new Set(defaults.templates.map(({ id }) => id));
89
+ const templates = [
90
+ ...defaults.templates.map((template) => customerTemplates.get(template.id) ?? template),
91
+ ...customer.templates.filter(({ id }) => !defaultIds.has(id))
92
+ ];
93
+ const customerMetadataList = customer.listTemplateMetadata();
94
+ const customerMetadata = new Map(customerMetadataList.map((template) => [template.id, template]));
95
+ const metadata = [
96
+ ...defaults.listTemplateMetadata().map((template) => customerMetadata.get(template.id) ?? template),
97
+ ...customerMetadataList.filter(({ id }) => !defaultIds.has(id))
98
+ ];
99
+ return createRenderTemplateRegistry({ templates, metadata });
100
+ }
101
+ function createTemplateRegistry(options) {
102
+ return createRenderTemplateRegistry({ templates: options.definitions });
103
+ }
104
+
105
+ export {
106
+ defineTemplate,
107
+ overlayTemplateRegistry,
108
+ createTemplateRegistry
109
+ };
@@ -0,0 +1,109 @@
1
+ // src/server/lifecycle.ts
2
+ var MAX_RAW_PROVIDER_BYTES = 16384;
3
+ var MAX_RAW_DEPTH = 6;
4
+ var MAX_RAW_ENTRIES = 50;
5
+ var MAX_RAW_STRING_LENGTH = 2048;
6
+ var MAX_MODEL_ID_LENGTH = 256;
7
+ var SENSITIVE_METADATA_KEY = /^(?:authorization|api[_-]?key|secret|password|prompt|input|messages?|content)$/i;
8
+ var LIFECYCLE_SINKS = /* @__PURE__ */ new WeakMap();
9
+ function attachGenerationLifecycleSink(context, sink) {
10
+ LIFECYCLE_SINKS.set(context, sink);
11
+ }
12
+ function getGenerationLifecycleSink(context) {
13
+ return LIFECYCLE_SINKS.get(context);
14
+ }
15
+ function tokenCount(value) {
16
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) return void 0;
17
+ return Math.min(Number.MAX_SAFE_INTEGER, Math.floor(value));
18
+ }
19
+ function object(value) {
20
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
21
+ }
22
+ function tokenFrom(value, ...keys) {
23
+ const source = object(value);
24
+ if (!source) return tokenCount(value);
25
+ for (const key of keys) {
26
+ const count = tokenCount(source[key]);
27
+ if (count != null) return count;
28
+ }
29
+ return void 0;
30
+ }
31
+ function firstToken(source, keys) {
32
+ for (const key of keys) {
33
+ const count = tokenCount(source[key]);
34
+ if (count != null) return count;
35
+ }
36
+ return void 0;
37
+ }
38
+ function boundedValue(value, depth = 0, seen = /* @__PURE__ */ new Set()) {
39
+ if (value == null || typeof value === "boolean") return value;
40
+ if (typeof value === "string") {
41
+ return value.length <= MAX_RAW_STRING_LENGTH ? value : `${value.slice(0, MAX_RAW_STRING_LENGTH - 1)}\u2026`;
42
+ }
43
+ if (typeof value === "number") return Number.isFinite(value) ? value : String(value);
44
+ if (typeof value === "bigint") return value.toString();
45
+ if (typeof value !== "object" || depth >= MAX_RAW_DEPTH || seen.has(value)) return "[omitted]";
46
+ seen.add(value);
47
+ let result;
48
+ if (Array.isArray(value)) {
49
+ result = value.slice(0, MAX_RAW_ENTRIES).map((item) => boundedValue(item, depth + 1, seen));
50
+ } else {
51
+ result = Object.fromEntries(Object.entries(value).slice(0, MAX_RAW_ENTRIES).map(([key, child]) => [
52
+ key.slice(0, 128),
53
+ SENSITIVE_METADATA_KEY.test(key) ? "[redacted]" : boundedValue(child, depth + 1, seen)
54
+ ]));
55
+ }
56
+ seen.delete(value);
57
+ try {
58
+ if (new TextEncoder().encode(JSON.stringify(result)).byteLength > MAX_RAW_PROVIDER_BYTES) {
59
+ return { truncated: true };
60
+ }
61
+ } catch {
62
+ return { truncated: true };
63
+ }
64
+ return result;
65
+ }
66
+ function boundProviderValue(value) {
67
+ return boundedValue(value);
68
+ }
69
+ function normalizeModelId(value) {
70
+ if (typeof value !== "string") return void 0;
71
+ const normalized = Array.from(value, (character) => {
72
+ const code = character.codePointAt(0) ?? 0;
73
+ return code < 32 || code === 127 ? " " : character;
74
+ }).join("").trim();
75
+ if (!normalized) return void 0;
76
+ return normalized.slice(0, MAX_MODEL_ID_LENGTH);
77
+ }
78
+ function normalizeProviderUsage(value, includeRaw) {
79
+ const source = object(value);
80
+ if (!source) return void 0;
81
+ const input = source.inputTokens ?? source.promptTokens ?? source.input_tokens ?? source.prompt_tokens;
82
+ const output = source.outputTokens ?? source.completionTokens ?? source.output_tokens ?? source.completion_tokens;
83
+ const inputDetails = object(source.inputTokenDetails) ?? object(input);
84
+ const outputDetails = object(source.outputTokenDetails) ?? object(output);
85
+ const inputTokens = tokenFrom(input, "total") ?? firstToken(source, ["inputTokenCount", "promptTokenCount"]);
86
+ const outputTokens = tokenFrom(output, "total") ?? firstToken(source, ["outputTokenCount", "completionTokenCount"]);
87
+ const totalTokens = firstToken(source, ["totalTokens", "total_tokens", "totalTokenCount"]) ?? (inputTokens != null && outputTokens != null ? inputTokens + outputTokens : void 0);
88
+ const cachedInputTokens = inputDetails ? firstToken(inputDetails, ["cacheReadTokens", "cachedInputTokens", "cache_read", "cacheRead"]) : firstToken(source, ["cachedInputTokens", "cacheReadInputTokens", "cache_read_input_tokens"]);
89
+ const cacheWriteTokens = inputDetails ? firstToken(inputDetails, ["cacheWriteTokens", "cacheCreationTokens", "cache_write", "cacheWrite"]) : firstToken(source, ["cacheWriteTokens", "cacheCreationInputTokens", "cache_creation_input_tokens"]);
90
+ const reasoningTokens = outputDetails ? firstToken(outputDetails, ["reasoningTokens", "reasoning"]) : firstToken(source, ["reasoningTokens", "reasoning_tokens"]);
91
+ const normalized = {
92
+ ...inputTokens != null ? { inputTokens } : {},
93
+ ...outputTokens != null ? { outputTokens } : {},
94
+ ...totalTokens != null ? { totalTokens } : {},
95
+ ...cachedInputTokens != null ? { cachedInputTokens } : {},
96
+ ...cacheWriteTokens != null ? { cacheWriteTokens } : {},
97
+ ...reasoningTokens != null ? { reasoningTokens } : {},
98
+ ...includeRaw ? { raw: boundProviderValue(value) } : {}
99
+ };
100
+ return Object.keys(normalized).length ? normalized : void 0;
101
+ }
102
+
103
+ export {
104
+ attachGenerationLifecycleSink,
105
+ getGenerationLifecycleSink,
106
+ boundProviderValue,
107
+ normalizeModelId,
108
+ normalizeProviderUsage
109
+ };
@@ -0,0 +1,18 @@
1
+ // src/protocol/types.ts
2
+ var VIDEO_PROTOCOL_VERSION = "0.4";
3
+ var VIDEO_SCHEMA_VERSION = "0.1";
4
+ function createVideoRequest(input, options) {
5
+ return {
6
+ protocolVersion: VIDEO_PROTOCOL_VERSION,
7
+ requestId: options.requestId,
8
+ input,
9
+ ...options.capabilities ? { capabilities: options.capabilities } : {},
10
+ ...options.resume ? { resume: options.resume } : {}
11
+ };
12
+ }
13
+
14
+ export {
15
+ VIDEO_PROTOCOL_VERSION,
16
+ VIDEO_SCHEMA_VERSION,
17
+ createVideoRequest
18
+ };