varg.ai-sdk 0.1.1 → 0.4.0-alpha.1

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 (246) hide show
  1. package/.claude/settings.local.json +1 -1
  2. package/.env.example +3 -0
  3. package/.github/workflows/ci.yml +23 -0
  4. package/.husky/README.md +102 -0
  5. package/.husky/commit-msg +6 -0
  6. package/.husky/pre-commit +9 -0
  7. package/.husky/pre-push +6 -0
  8. package/.size-limit.json +8 -0
  9. package/.test-hooks.ts +5 -0
  10. package/CLAUDE.md +10 -3
  11. package/CONTRIBUTING.md +150 -0
  12. package/LICENSE.md +53 -0
  13. package/README.md +56 -209
  14. package/SKILLS.md +26 -10
  15. package/biome.json +7 -1
  16. package/bun.lock +1286 -0
  17. package/commitlint.config.js +22 -0
  18. package/docs/index.html +1130 -0
  19. package/docs/prompting.md +326 -0
  20. package/docs/react.md +834 -0
  21. package/docs/sdk.md +812 -0
  22. package/ffmpeg/CLAUDE.md +68 -0
  23. package/package.json +43 -10
  24. package/pipeline/cookbooks/scripts/animate-frames-parallel.ts +84 -0
  25. package/pipeline/cookbooks/scripts/combine-scenes.sh +53 -0
  26. package/pipeline/cookbooks/scripts/generate-frames-parallel.ts +99 -0
  27. package/pipeline/cookbooks/scripts/still-to-video.sh +37 -0
  28. package/pipeline/cookbooks/text-to-tiktok.md +669 -0
  29. package/pipeline/cookbooks/trendwatching.md +156 -0
  30. package/plan.md +281 -0
  31. package/scripts/.gitkeep +0 -0
  32. package/src/ai-sdk/cache.ts +142 -0
  33. package/src/ai-sdk/examples/cached-generation.ts +53 -0
  34. package/src/ai-sdk/examples/duet-scene-4.ts +53 -0
  35. package/src/ai-sdk/examples/duet-scene-5-audio.ts +32 -0
  36. package/src/ai-sdk/examples/duet-video.ts +56 -0
  37. package/src/ai-sdk/examples/editly-composition.ts +63 -0
  38. package/src/ai-sdk/examples/editly-test.ts +57 -0
  39. package/src/ai-sdk/examples/editly-video-test.ts +52 -0
  40. package/src/ai-sdk/examples/fal-lipsync.ts +43 -0
  41. package/src/ai-sdk/examples/higgsfield-image.ts +61 -0
  42. package/src/ai-sdk/examples/music-generation.ts +19 -0
  43. package/src/ai-sdk/examples/openai-sora.ts +34 -0
  44. package/src/ai-sdk/examples/replicate-bg-removal.ts +52 -0
  45. package/src/ai-sdk/examples/simpsons-scene.ts +61 -0
  46. package/src/ai-sdk/examples/talking-lion.ts +55 -0
  47. package/src/ai-sdk/examples/video-generation.ts +39 -0
  48. package/src/ai-sdk/examples/workflow-animated-girl.ts +104 -0
  49. package/src/ai-sdk/examples/workflow-before-after.ts +114 -0
  50. package/src/ai-sdk/examples/workflow-character-grid.ts +112 -0
  51. package/src/ai-sdk/examples/workflow-slideshow.ts +161 -0
  52. package/src/ai-sdk/file-cache.ts +112 -0
  53. package/src/ai-sdk/file.ts +238 -0
  54. package/src/ai-sdk/generate-element.ts +92 -0
  55. package/src/ai-sdk/generate-music.ts +46 -0
  56. package/src/ai-sdk/generate-video.ts +165 -0
  57. package/src/ai-sdk/index.ts +72 -0
  58. package/src/ai-sdk/music-model.ts +110 -0
  59. package/src/ai-sdk/providers/editly/editly.test.ts +1108 -0
  60. package/src/ai-sdk/providers/editly/ffmpeg.ts +60 -0
  61. package/src/ai-sdk/providers/editly/index.ts +817 -0
  62. package/src/ai-sdk/providers/editly/layers.ts +776 -0
  63. package/src/ai-sdk/providers/editly/plan.md +144 -0
  64. package/src/ai-sdk/providers/editly/types.ts +328 -0
  65. package/src/ai-sdk/providers/elevenlabs-provider.ts +255 -0
  66. package/src/ai-sdk/providers/fal-provider.ts +512 -0
  67. package/src/ai-sdk/providers/higgsfield.ts +379 -0
  68. package/src/ai-sdk/providers/openai.ts +251 -0
  69. package/src/ai-sdk/providers/replicate.ts +16 -0
  70. package/src/ai-sdk/video-model.ts +185 -0
  71. package/src/cli/commands/find.tsx +137 -0
  72. package/src/cli/commands/help.tsx +85 -0
  73. package/src/cli/commands/index.ts +6 -0
  74. package/src/cli/commands/list.tsx +238 -0
  75. package/src/cli/commands/render.tsx +71 -0
  76. package/src/cli/commands/run.tsx +511 -0
  77. package/src/cli/commands/which.tsx +253 -0
  78. package/src/cli/index.ts +114 -0
  79. package/src/cli/quiet.ts +44 -0
  80. package/src/cli/types.ts +32 -0
  81. package/src/cli/ui/components/Badge.tsx +29 -0
  82. package/src/cli/ui/components/DataTable.tsx +51 -0
  83. package/src/cli/ui/components/Header.tsx +23 -0
  84. package/src/cli/ui/components/HelpBlock.tsx +44 -0
  85. package/src/cli/ui/components/KeyValue.tsx +33 -0
  86. package/src/cli/ui/components/OptionRow.tsx +81 -0
  87. package/src/cli/ui/components/Separator.tsx +23 -0
  88. package/src/cli/ui/components/StatusBox.tsx +108 -0
  89. package/src/cli/ui/components/VargBox.tsx +51 -0
  90. package/src/cli/ui/components/VargProgress.tsx +36 -0
  91. package/src/cli/ui/components/VargSpinner.tsx +34 -0
  92. package/src/cli/ui/components/VargText.tsx +56 -0
  93. package/src/cli/ui/components/index.ts +19 -0
  94. package/src/cli/ui/index.ts +12 -0
  95. package/src/cli/ui/render.ts +35 -0
  96. package/src/cli/ui/theme.ts +63 -0
  97. package/src/cli/utils.ts +78 -0
  98. package/src/core/executor/executor.ts +201 -0
  99. package/src/core/executor/index.ts +13 -0
  100. package/src/core/executor/job.ts +214 -0
  101. package/src/core/executor/pipeline.ts +222 -0
  102. package/src/core/index.ts +11 -0
  103. package/src/core/registry/index.ts +9 -0
  104. package/src/core/registry/loader.ts +149 -0
  105. package/src/core/registry/registry.ts +221 -0
  106. package/src/core/registry/resolver.ts +206 -0
  107. package/src/core/schema/helpers.ts +134 -0
  108. package/src/core/schema/index.ts +8 -0
  109. package/src/core/schema/shared.ts +102 -0
  110. package/src/core/schema/types.ts +279 -0
  111. package/src/core/schema/validator.ts +92 -0
  112. package/src/definitions/actions/captions.ts +261 -0
  113. package/src/definitions/actions/edit.ts +298 -0
  114. package/src/definitions/actions/image.ts +125 -0
  115. package/src/definitions/actions/index.ts +114 -0
  116. package/src/definitions/actions/music.ts +205 -0
  117. package/src/definitions/actions/sync.ts +128 -0
  118. package/{action/transcribe/index.ts → src/definitions/actions/transcribe.ts} +58 -68
  119. package/src/definitions/actions/upload.ts +111 -0
  120. package/src/definitions/actions/video.ts +163 -0
  121. package/src/definitions/actions/voice.ts +119 -0
  122. package/src/definitions/index.ts +23 -0
  123. package/src/definitions/models/elevenlabs.ts +50 -0
  124. package/src/definitions/models/flux.ts +56 -0
  125. package/src/definitions/models/index.ts +36 -0
  126. package/src/definitions/models/kling.ts +56 -0
  127. package/src/definitions/models/llama.ts +54 -0
  128. package/src/definitions/models/nano-banana-pro.ts +102 -0
  129. package/src/definitions/models/sonauto.ts +68 -0
  130. package/src/definitions/models/soul.ts +65 -0
  131. package/src/definitions/models/wan.ts +54 -0
  132. package/src/definitions/models/whisper.ts +44 -0
  133. package/src/definitions/skills/index.ts +12 -0
  134. package/src/definitions/skills/talking-character.ts +87 -0
  135. package/src/definitions/skills/text-to-tiktok.ts +97 -0
  136. package/src/index.ts +118 -0
  137. package/src/providers/apify.ts +269 -0
  138. package/src/providers/base.ts +264 -0
  139. package/src/providers/elevenlabs.ts +217 -0
  140. package/src/providers/fal.ts +392 -0
  141. package/src/providers/ffmpeg.ts +544 -0
  142. package/src/providers/fireworks.ts +193 -0
  143. package/src/providers/groq.ts +149 -0
  144. package/src/providers/higgsfield.ts +145 -0
  145. package/src/providers/index.ts +143 -0
  146. package/src/providers/replicate.ts +147 -0
  147. package/src/providers/storage.ts +206 -0
  148. package/src/react/cli.ts +52 -0
  149. package/src/react/elements.ts +146 -0
  150. package/src/react/examples/branching.tsx +66 -0
  151. package/src/react/examples/captions-demo.tsx +37 -0
  152. package/src/react/examples/character-video.tsx +84 -0
  153. package/src/react/examples/grid.tsx +53 -0
  154. package/src/react/examples/layouts-demo.tsx +57 -0
  155. package/src/react/examples/madi.tsx +60 -0
  156. package/src/react/examples/music-test.tsx +35 -0
  157. package/src/react/examples/onlyfans-1m/workflow.tsx +88 -0
  158. package/src/react/examples/orange-portrait.tsx +41 -0
  159. package/src/react/examples/split-element-demo.tsx +60 -0
  160. package/src/react/examples/split-layout-demo.tsx +60 -0
  161. package/src/react/examples/split.tsx +41 -0
  162. package/src/react/examples/video-grid.tsx +46 -0
  163. package/src/react/index.ts +43 -0
  164. package/src/react/layouts/grid.tsx +28 -0
  165. package/src/react/layouts/index.ts +2 -0
  166. package/src/react/layouts/split.tsx +20 -0
  167. package/src/react/react.test.ts +309 -0
  168. package/src/react/render.ts +21 -0
  169. package/src/react/renderers/animate.ts +59 -0
  170. package/src/react/renderers/captions.ts +297 -0
  171. package/src/react/renderers/clip.ts +248 -0
  172. package/src/react/renderers/context.ts +17 -0
  173. package/src/react/renderers/image.ts +109 -0
  174. package/src/react/renderers/index.ts +22 -0
  175. package/src/react/renderers/music.ts +60 -0
  176. package/src/react/renderers/packshot.ts +84 -0
  177. package/src/react/renderers/progress.ts +173 -0
  178. package/src/react/renderers/render.ts +243 -0
  179. package/src/react/renderers/slider.ts +69 -0
  180. package/src/react/renderers/speech.ts +53 -0
  181. package/src/react/renderers/split.ts +91 -0
  182. package/src/react/renderers/subtitle.ts +16 -0
  183. package/src/react/renderers/swipe.ts +75 -0
  184. package/src/react/renderers/title.ts +17 -0
  185. package/src/react/renderers/utils.ts +124 -0
  186. package/src/react/renderers/video.ts +127 -0
  187. package/src/react/runtime/jsx-dev-runtime.ts +43 -0
  188. package/src/react/runtime/jsx-runtime.ts +35 -0
  189. package/src/react/types.ts +232 -0
  190. package/src/studio/index.ts +26 -0
  191. package/src/studio/scanner.ts +102 -0
  192. package/src/studio/server.ts +554 -0
  193. package/src/studio/stages.ts +251 -0
  194. package/src/studio/step-renderer.ts +279 -0
  195. package/src/studio/types.ts +60 -0
  196. package/src/studio/ui/cache.html +303 -0
  197. package/src/studio/ui/index.html +1820 -0
  198. package/src/tests/all.test.ts +509 -0
  199. package/src/tests/index.ts +33 -0
  200. package/src/tests/unit.test.ts +403 -0
  201. package/tsconfig.cli.json +8 -0
  202. package/tsconfig.json +21 -3
  203. package/TEST_RESULTS.md +0 -122
  204. package/action/captions/SKILL.md +0 -170
  205. package/action/captions/index.ts +0 -169
  206. package/action/edit/SKILL.md +0 -235
  207. package/action/edit/index.ts +0 -437
  208. package/action/image/SKILL.md +0 -140
  209. package/action/image/index.ts +0 -105
  210. package/action/sync/SKILL.md +0 -136
  211. package/action/sync/index.ts +0 -145
  212. package/action/transcribe/SKILL.md +0 -179
  213. package/action/video/SKILL.md +0 -116
  214. package/action/video/index.ts +0 -125
  215. package/action/voice/SKILL.md +0 -125
  216. package/action/voice/index.ts +0 -136
  217. package/cli/commands/find.ts +0 -58
  218. package/cli/commands/help.ts +0 -70
  219. package/cli/commands/list.ts +0 -49
  220. package/cli/commands/run.ts +0 -237
  221. package/cli/commands/which.ts +0 -66
  222. package/cli/discover.ts +0 -66
  223. package/cli/index.ts +0 -33
  224. package/cli/runner.ts +0 -65
  225. package/cli/types.ts +0 -49
  226. package/cli/ui.ts +0 -185
  227. package/index.ts +0 -75
  228. package/lib/README.md +0 -144
  229. package/lib/ai-sdk/fal.ts +0 -106
  230. package/lib/ai-sdk/replicate.ts +0 -107
  231. package/lib/elevenlabs.ts +0 -382
  232. package/lib/fal.ts +0 -467
  233. package/lib/ffmpeg.ts +0 -467
  234. package/lib/fireworks.ts +0 -235
  235. package/lib/groq.ts +0 -246
  236. package/lib/higgsfield.ts +0 -176
  237. package/lib/remotion/SKILL.md +0 -823
  238. package/lib/remotion/cli.ts +0 -115
  239. package/lib/remotion/functions.ts +0 -283
  240. package/lib/remotion/index.ts +0 -19
  241. package/lib/remotion/templates.ts +0 -73
  242. package/lib/replicate.ts +0 -304
  243. package/output.txt +0 -1
  244. package/test-import.ts +0 -7
  245. package/test-services.ts +0 -97
  246. package/utilities/s3.ts +0 -147
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Shared Zod schemas for reuse across definitions
3
+ * These schemas represent common patterns used in multiple models/actions/skills
4
+ */
5
+
6
+ import { z } from "zod";
7
+
8
+ // Video aspect ratios
9
+ export const aspectRatioSchema = z.enum(["16:9", "9:16", "1:1"]);
10
+ export type AspectRatio = z.infer<typeof aspectRatioSchema>;
11
+
12
+ // Video duration in seconds (number version)
13
+ export const videoDurationSchema = z.union([z.literal(5), z.literal(10)]);
14
+ export type VideoDuration = z.infer<typeof videoDurationSchema>;
15
+
16
+ // Video duration as string (for models that expect string)
17
+ export const videoDurationStringSchema = z.enum(["5", "10"]);
18
+ export type VideoDurationString = z.infer<typeof videoDurationStringSchema>;
19
+
20
+ // Video resolution
21
+ export const resolutionSchema = z.enum(["480p", "720p", "1080p"]);
22
+ export type Resolution = z.infer<typeof resolutionSchema>;
23
+
24
+ // ElevenLabs preset voices
25
+ export const voiceNameSchema = z.enum([
26
+ "rachel",
27
+ "domi",
28
+ "bella",
29
+ "antoni",
30
+ "josh",
31
+ "adam",
32
+ "sam",
33
+ ]);
34
+ export type VoiceName = z.infer<typeof voiceNameSchema>;
35
+
36
+ // Simplified voice set (commonly used in skills)
37
+ export const simpleVoiceSchema = z.enum(["rachel", "sam", "adam", "josh"]);
38
+ export type SimpleVoice = z.infer<typeof simpleVoiceSchema>;
39
+
40
+ // Caption styles
41
+ export const captionStyleSchema = z.enum(["default", "tiktok", "youtube"]);
42
+ export type CaptionStyle = z.infer<typeof captionStyleSchema>;
43
+
44
+ // Audio output formats
45
+ export const audioFormatSchema = z.enum(["mp3", "wav", "flac", "ogg", "m4a"]);
46
+ export type AudioFormat = z.infer<typeof audioFormatSchema>;
47
+
48
+ // Flux image sizes
49
+ export const imageSizeSchema = z.enum([
50
+ "square_hd",
51
+ "square",
52
+ "portrait_4_3",
53
+ "portrait_16_9",
54
+ "landscape_4_3",
55
+ "landscape_16_9",
56
+ ]);
57
+ export type ImageSize = z.infer<typeof imageSizeSchema>;
58
+
59
+ // Soul character quality
60
+ export const soulQualitySchema = z.enum(["SD", "HD", "UHD"]);
61
+ export type SoulQuality = z.infer<typeof soulQualitySchema>;
62
+
63
+ // ElevenLabs TTS model IDs
64
+ export const elevenLabsModelSchema = z.enum([
65
+ "eleven_multilingual_v2",
66
+ "eleven_monolingual_v1",
67
+ "eleven_turbo_v2",
68
+ ]);
69
+ export type ElevenLabsModel = z.infer<typeof elevenLabsModelSchema>;
70
+
71
+ // Transcription providers
72
+ export const transcriptionProviderSchema = z.enum(["groq", "fireworks"]);
73
+ export type TranscriptionProvider = z.infer<typeof transcriptionProviderSchema>;
74
+
75
+ // Provider name choices
76
+ export const providerNameSchema = z.enum([
77
+ "fal",
78
+ "replicate",
79
+ "elevenlabs",
80
+ "higgsfield",
81
+ "groq",
82
+ "fireworks",
83
+ ]);
84
+ export type ProviderName = z.infer<typeof providerNameSchema>;
85
+
86
+ // Common format validators
87
+ export const filePathSchema = z.string().min(1, "File path cannot be empty");
88
+ export const urlSchema = z.string().url("Must be a valid URL");
89
+ export const uriSchema = z
90
+ .string()
91
+ .refine(
92
+ (val) =>
93
+ val.startsWith("http://") ||
94
+ val.startsWith("https://") ||
95
+ val.startsWith("file://") ||
96
+ val.startsWith("/"),
97
+ "Must be a URL or absolute path",
98
+ );
99
+
100
+ // Number range helpers
101
+ export const percentSchema = z.number().min(0).max(1);
102
+ export const positiveIntSchema = z.number().int().positive();
@@ -0,0 +1,279 @@
1
+ /**
2
+ * Core type definitions for varg SDK
3
+ * These types form the foundation of the registry, executor, and provider systems
4
+ */
5
+
6
+ import type { z } from "zod";
7
+
8
+ // ============================================================================
9
+ // Zod Schema Types
10
+ // ============================================================================
11
+
12
+ /**
13
+ * Schema definition using Zod
14
+ * TInput: Zod schema for input validation
15
+ * TOutput: Zod schema for output type definition
16
+ */
17
+ export interface ZodSchema<
18
+ TInput extends z.ZodTypeAny = z.ZodTypeAny,
19
+ TOutput extends z.ZodTypeAny = z.ZodTypeAny,
20
+ > {
21
+ input: TInput;
22
+ output: TOutput;
23
+ }
24
+
25
+ /**
26
+ * Infer the TypeScript type from a ZodSchema's input
27
+ */
28
+ export type InferInput<S extends ZodSchema> = z.infer<S["input"]>;
29
+
30
+ /**
31
+ * Infer the TypeScript type from a ZodSchema's output
32
+ */
33
+ export type InferOutput<S extends ZodSchema> = z.infer<S["output"]>;
34
+
35
+ // ============================================================================
36
+ // Legacy Schema Types (for JSON Schema compatibility)
37
+ // These are used by CLI introspection via Zod v4's native toJSONSchema()
38
+ // ============================================================================
39
+
40
+ export interface SchemaProperty {
41
+ type: "string" | "number" | "integer" | "boolean" | "array" | "object";
42
+ description?: string;
43
+ enum?: (string | number)[];
44
+ default?: unknown;
45
+ format?: string;
46
+ items?: SchemaProperty;
47
+ properties?: Record<string, SchemaProperty>;
48
+ required?: string[];
49
+ }
50
+
51
+ export interface JsonSchema {
52
+ type: "object";
53
+ required?: string[];
54
+ properties?: Record<string, SchemaProperty>;
55
+ description?: string;
56
+ }
57
+
58
+ // ============================================================================
59
+ // Job Types
60
+ // ============================================================================
61
+
62
+ export type JobStatus =
63
+ | "pending"
64
+ | "queued"
65
+ | "processing"
66
+ | "completed"
67
+ | "failed"
68
+ | "cancelled";
69
+
70
+ export interface Job {
71
+ id: string;
72
+ status: JobStatus;
73
+ provider: string;
74
+ model: string;
75
+ inputs: Record<string, unknown>;
76
+ output?: unknown;
77
+ error?: string;
78
+ createdAt: Date;
79
+ updatedAt: Date;
80
+ completedAt?: Date;
81
+ progress?: number;
82
+ logs?: string[];
83
+ }
84
+
85
+ export interface JobStatusUpdate {
86
+ status: JobStatus;
87
+ progress?: number;
88
+ logs?: string[];
89
+ output?: unknown;
90
+ error?: string;
91
+ }
92
+
93
+ // ============================================================================
94
+ // Provider Types
95
+ // ============================================================================
96
+
97
+ export interface ProviderConfig {
98
+ apiKey?: string;
99
+ baseUrl?: string;
100
+ timeout?: number;
101
+ retries?: number;
102
+ }
103
+
104
+ export interface Provider {
105
+ readonly name: string;
106
+
107
+ /**
108
+ * Submit a job to the provider
109
+ * @returns Job ID from the provider
110
+ */
111
+ submit(
112
+ model: string,
113
+ inputs: Record<string, unknown>,
114
+ config?: ProviderConfig,
115
+ ): Promise<string>;
116
+
117
+ /**
118
+ * Get the current status of a job
119
+ */
120
+ getStatus(jobId: string): Promise<JobStatusUpdate>;
121
+
122
+ /**
123
+ * Get the result of a completed job
124
+ */
125
+ getResult(jobId: string): Promise<unknown>;
126
+
127
+ /**
128
+ * Cancel a running job (if supported)
129
+ */
130
+ cancel?(jobId: string): Promise<void>;
131
+
132
+ /**
133
+ * Upload a file to the provider's storage (if supported)
134
+ */
135
+ uploadFile?(
136
+ file: File | Blob | ArrayBuffer,
137
+ filename?: string,
138
+ ): Promise<string>;
139
+ }
140
+
141
+ // ============================================================================
142
+ // Definition Types
143
+ // ============================================================================
144
+
145
+ export interface ModelDefinition<S extends ZodSchema = ZodSchema> {
146
+ type: "model";
147
+ name: string;
148
+ description: string;
149
+ providers: string[];
150
+ defaultProvider: string;
151
+ schema: S;
152
+ /**
153
+ * Provider-specific model identifiers
154
+ * e.g., { fal: "fal-ai/kling-video/v2.5", replicate: "..." }
155
+ */
156
+ providerModels?: Record<string, string>;
157
+ }
158
+
159
+ export interface ActionRoute {
160
+ /** Target model or action name */
161
+ target: string;
162
+ /** Conditions that must be met for this route */
163
+ when?: Record<string, unknown>;
164
+ /** Priority (higher = preferred) */
165
+ priority?: number;
166
+ /** Transform inputs before passing to target */
167
+ transform?: (inputs: Record<string, unknown>) => Record<string, unknown>;
168
+ }
169
+
170
+ export interface ActionDefinition<S extends ZodSchema = ZodSchema> {
171
+ type: "action";
172
+ name: string;
173
+ description: string;
174
+ schema: S;
175
+ /** Routes to models or other actions */
176
+ routes: ActionRoute[];
177
+ /** Direct execution function (for local actions like ffmpeg) */
178
+ execute?: (inputs: InferInput<S>) => Promise<InferOutput<S>>;
179
+ }
180
+
181
+ export interface SkillStep {
182
+ name: string;
183
+ /** Action or model to run */
184
+ run: string;
185
+ /** Input mapping from previous steps or initial inputs */
186
+ inputs: Record<string, unknown>;
187
+ /** Condition to run this step */
188
+ when?: Record<string, unknown>;
189
+ }
190
+
191
+ export interface SkillDefinition<S extends ZodSchema = ZodSchema> {
192
+ type: "skill";
193
+ name: string;
194
+ description: string;
195
+ schema: S;
196
+ /** Ordered steps to execute */
197
+ steps: SkillStep[];
198
+ }
199
+
200
+ export type Definition =
201
+ | ModelDefinition<ZodSchema>
202
+ | ActionDefinition<ZodSchema>
203
+ | SkillDefinition<ZodSchema>;
204
+
205
+ // ============================================================================
206
+ // Execution Types
207
+ // ============================================================================
208
+
209
+ export interface RunOptions {
210
+ /** Override the default provider */
211
+ provider?: string;
212
+ /** Timeout in milliseconds */
213
+ timeout?: number;
214
+ /** Whether to wait for completion */
215
+ wait?: boolean;
216
+ /** Output directory for downloaded files */
217
+ outputDir?: string;
218
+ /** Progress callback */
219
+ onProgress?: (progress: number, logs?: string[]) => void;
220
+ /** Status change callback */
221
+ onStatusChange?: (status: JobStatus) => void;
222
+ }
223
+
224
+ export interface ExecutionResult {
225
+ /** Primary output (URL or file path) */
226
+ output: string | Record<string, unknown>;
227
+ /** Estimated cost in USD */
228
+ cost?: number;
229
+ /** Duration in milliseconds */
230
+ duration: number;
231
+ /** Provider used */
232
+ provider: string;
233
+ /** Model used */
234
+ model: string;
235
+ /** Job ID for reference */
236
+ jobId?: string;
237
+ /** Additional metadata */
238
+ metadata?: Record<string, unknown>;
239
+ }
240
+
241
+ // ============================================================================
242
+ // Registry Types
243
+ // ============================================================================
244
+
245
+ export interface RegistryOptions {
246
+ /** Paths to scan for definitions */
247
+ definitionPaths?: string[];
248
+ /** Paths to scan for user skills */
249
+ skillPaths?: string[];
250
+ }
251
+
252
+ export interface SearchOptions {
253
+ /** Filter by type */
254
+ type?: "model" | "action" | "skill";
255
+ /** Filter by input type */
256
+ inputType?: string;
257
+ /** Filter by output type */
258
+ outputType?: string;
259
+ /** Filter by provider */
260
+ provider?: string;
261
+ }
262
+
263
+ // ============================================================================
264
+ // Config Types
265
+ // ============================================================================
266
+
267
+ export interface VargConfig {
268
+ /** Default provider for each capability */
269
+ defaults?: {
270
+ imageToVideo?: string;
271
+ textToVideo?: string;
272
+ textToImage?: string;
273
+ textToSpeech?: string;
274
+ };
275
+ /** Provider-specific configuration */
276
+ providers?: Record<string, ProviderConfig>;
277
+ /** Output directory */
278
+ outputDir?: string;
279
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Input validation using Zod
3
+ * Validates inputs before execution
4
+ */
5
+
6
+ import type { z } from "zod";
7
+
8
+ export interface ValidationError {
9
+ path: string;
10
+ message: string;
11
+ value?: unknown;
12
+ }
13
+
14
+ export interface ValidationResult<T = unknown> {
15
+ valid: boolean;
16
+ errors: ValidationError[];
17
+ data?: T;
18
+ }
19
+
20
+ /**
21
+ * Validate inputs against a Zod schema
22
+ */
23
+ export function validateInputs<T extends z.ZodTypeAny>(
24
+ inputs: unknown,
25
+ schema: T,
26
+ ): ValidationResult<z.infer<T>> {
27
+ const result = schema.safeParse(inputs);
28
+
29
+ if (result.success) {
30
+ return {
31
+ valid: true,
32
+ errors: [],
33
+ data: result.data,
34
+ };
35
+ }
36
+
37
+ return {
38
+ valid: false,
39
+ errors: result.error.issues.map((issue) => ({
40
+ path: issue.path.join("."),
41
+ message: issue.message,
42
+ value: inputs,
43
+ })),
44
+ };
45
+ }
46
+
47
+ /**
48
+ * Validate and prepare inputs in one step
49
+ * Zod automatically applies defaults during parsing
50
+ */
51
+ export function validateAndPrepare<T extends z.ZodTypeAny>(
52
+ inputs: unknown,
53
+ schema: T,
54
+ ): ValidationResult<z.infer<T>> {
55
+ return validateInputs(inputs, schema);
56
+ }
57
+
58
+ /**
59
+ * Type-safe validation helper that throws on invalid input
60
+ */
61
+ export function parseOrThrow<T extends z.ZodTypeAny>(
62
+ inputs: unknown,
63
+ schema: T,
64
+ ): z.infer<T> {
65
+ return schema.parse(inputs);
66
+ }
67
+
68
+ /**
69
+ * Apply defaults to inputs using Zod schema
70
+ * Zod automatically applies defaults during parsing
71
+ * Returns the input with defaults applied
72
+ */
73
+ export function applyDefaults(
74
+ inputs: unknown,
75
+ // biome-ignore lint/suspicious/noExplicitAny: Zod v4 type compatibility
76
+ schema: any,
77
+ ): Record<string, unknown> {
78
+ // If schema has .input property (ZodSchema interface), use that
79
+ const zodSchema = schema.input || schema;
80
+
81
+ // Parse with defaults - if invalid, return inputs as-is
82
+ try {
83
+ return zodSchema.parse(inputs);
84
+ } catch {
85
+ // If validation fails, try to apply partial defaults
86
+ const partial = zodSchema.partial().safeParse(inputs);
87
+ if (partial.success) {
88
+ return { ...(inputs as Record<string, unknown>), ...partial.data };
89
+ }
90
+ return inputs as Record<string, unknown>;
91
+ }
92
+ }