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.
- package/.claude/settings.local.json +1 -1
- package/.env.example +3 -0
- package/.github/workflows/ci.yml +23 -0
- package/.husky/README.md +102 -0
- package/.husky/commit-msg +6 -0
- package/.husky/pre-commit +9 -0
- package/.husky/pre-push +6 -0
- package/.size-limit.json +8 -0
- package/.test-hooks.ts +5 -0
- package/CLAUDE.md +10 -3
- package/CONTRIBUTING.md +150 -0
- package/LICENSE.md +53 -0
- package/README.md +56 -209
- package/SKILLS.md +26 -10
- package/biome.json +7 -1
- package/bun.lock +1286 -0
- package/commitlint.config.js +22 -0
- package/docs/index.html +1130 -0
- package/docs/prompting.md +326 -0
- package/docs/react.md +834 -0
- package/docs/sdk.md +812 -0
- package/ffmpeg/CLAUDE.md +68 -0
- package/package.json +43 -10
- package/pipeline/cookbooks/scripts/animate-frames-parallel.ts +84 -0
- package/pipeline/cookbooks/scripts/combine-scenes.sh +53 -0
- package/pipeline/cookbooks/scripts/generate-frames-parallel.ts +99 -0
- package/pipeline/cookbooks/scripts/still-to-video.sh +37 -0
- package/pipeline/cookbooks/text-to-tiktok.md +669 -0
- package/pipeline/cookbooks/trendwatching.md +156 -0
- package/plan.md +281 -0
- package/scripts/.gitkeep +0 -0
- package/src/ai-sdk/cache.ts +142 -0
- package/src/ai-sdk/examples/cached-generation.ts +53 -0
- package/src/ai-sdk/examples/duet-scene-4.ts +53 -0
- package/src/ai-sdk/examples/duet-scene-5-audio.ts +32 -0
- package/src/ai-sdk/examples/duet-video.ts +56 -0
- package/src/ai-sdk/examples/editly-composition.ts +63 -0
- package/src/ai-sdk/examples/editly-test.ts +57 -0
- package/src/ai-sdk/examples/editly-video-test.ts +52 -0
- package/src/ai-sdk/examples/fal-lipsync.ts +43 -0
- package/src/ai-sdk/examples/higgsfield-image.ts +61 -0
- package/src/ai-sdk/examples/music-generation.ts +19 -0
- package/src/ai-sdk/examples/openai-sora.ts +34 -0
- package/src/ai-sdk/examples/replicate-bg-removal.ts +52 -0
- package/src/ai-sdk/examples/simpsons-scene.ts +61 -0
- package/src/ai-sdk/examples/talking-lion.ts +55 -0
- package/src/ai-sdk/examples/video-generation.ts +39 -0
- package/src/ai-sdk/examples/workflow-animated-girl.ts +104 -0
- package/src/ai-sdk/examples/workflow-before-after.ts +114 -0
- package/src/ai-sdk/examples/workflow-character-grid.ts +112 -0
- package/src/ai-sdk/examples/workflow-slideshow.ts +161 -0
- package/src/ai-sdk/file-cache.ts +112 -0
- package/src/ai-sdk/file.ts +238 -0
- package/src/ai-sdk/generate-element.ts +92 -0
- package/src/ai-sdk/generate-music.ts +46 -0
- package/src/ai-sdk/generate-video.ts +165 -0
- package/src/ai-sdk/index.ts +72 -0
- package/src/ai-sdk/music-model.ts +110 -0
- package/src/ai-sdk/providers/editly/editly.test.ts +1108 -0
- package/src/ai-sdk/providers/editly/ffmpeg.ts +60 -0
- package/src/ai-sdk/providers/editly/index.ts +817 -0
- package/src/ai-sdk/providers/editly/layers.ts +776 -0
- package/src/ai-sdk/providers/editly/plan.md +144 -0
- package/src/ai-sdk/providers/editly/types.ts +328 -0
- package/src/ai-sdk/providers/elevenlabs-provider.ts +255 -0
- package/src/ai-sdk/providers/fal-provider.ts +512 -0
- package/src/ai-sdk/providers/higgsfield.ts +379 -0
- package/src/ai-sdk/providers/openai.ts +251 -0
- package/src/ai-sdk/providers/replicate.ts +16 -0
- package/src/ai-sdk/video-model.ts +185 -0
- package/src/cli/commands/find.tsx +137 -0
- package/src/cli/commands/help.tsx +85 -0
- package/src/cli/commands/index.ts +6 -0
- package/src/cli/commands/list.tsx +238 -0
- package/src/cli/commands/render.tsx +71 -0
- package/src/cli/commands/run.tsx +511 -0
- package/src/cli/commands/which.tsx +253 -0
- package/src/cli/index.ts +114 -0
- package/src/cli/quiet.ts +44 -0
- package/src/cli/types.ts +32 -0
- package/src/cli/ui/components/Badge.tsx +29 -0
- package/src/cli/ui/components/DataTable.tsx +51 -0
- package/src/cli/ui/components/Header.tsx +23 -0
- package/src/cli/ui/components/HelpBlock.tsx +44 -0
- package/src/cli/ui/components/KeyValue.tsx +33 -0
- package/src/cli/ui/components/OptionRow.tsx +81 -0
- package/src/cli/ui/components/Separator.tsx +23 -0
- package/src/cli/ui/components/StatusBox.tsx +108 -0
- package/src/cli/ui/components/VargBox.tsx +51 -0
- package/src/cli/ui/components/VargProgress.tsx +36 -0
- package/src/cli/ui/components/VargSpinner.tsx +34 -0
- package/src/cli/ui/components/VargText.tsx +56 -0
- package/src/cli/ui/components/index.ts +19 -0
- package/src/cli/ui/index.ts +12 -0
- package/src/cli/ui/render.ts +35 -0
- package/src/cli/ui/theme.ts +63 -0
- package/src/cli/utils.ts +78 -0
- package/src/core/executor/executor.ts +201 -0
- package/src/core/executor/index.ts +13 -0
- package/src/core/executor/job.ts +214 -0
- package/src/core/executor/pipeline.ts +222 -0
- package/src/core/index.ts +11 -0
- package/src/core/registry/index.ts +9 -0
- package/src/core/registry/loader.ts +149 -0
- package/src/core/registry/registry.ts +221 -0
- package/src/core/registry/resolver.ts +206 -0
- package/src/core/schema/helpers.ts +134 -0
- package/src/core/schema/index.ts +8 -0
- package/src/core/schema/shared.ts +102 -0
- package/src/core/schema/types.ts +279 -0
- package/src/core/schema/validator.ts +92 -0
- package/src/definitions/actions/captions.ts +261 -0
- package/src/definitions/actions/edit.ts +298 -0
- package/src/definitions/actions/image.ts +125 -0
- package/src/definitions/actions/index.ts +114 -0
- package/src/definitions/actions/music.ts +205 -0
- package/src/definitions/actions/sync.ts +128 -0
- package/{action/transcribe/index.ts → src/definitions/actions/transcribe.ts} +58 -68
- package/src/definitions/actions/upload.ts +111 -0
- package/src/definitions/actions/video.ts +163 -0
- package/src/definitions/actions/voice.ts +119 -0
- package/src/definitions/index.ts +23 -0
- package/src/definitions/models/elevenlabs.ts +50 -0
- package/src/definitions/models/flux.ts +56 -0
- package/src/definitions/models/index.ts +36 -0
- package/src/definitions/models/kling.ts +56 -0
- package/src/definitions/models/llama.ts +54 -0
- package/src/definitions/models/nano-banana-pro.ts +102 -0
- package/src/definitions/models/sonauto.ts +68 -0
- package/src/definitions/models/soul.ts +65 -0
- package/src/definitions/models/wan.ts +54 -0
- package/src/definitions/models/whisper.ts +44 -0
- package/src/definitions/skills/index.ts +12 -0
- package/src/definitions/skills/talking-character.ts +87 -0
- package/src/definitions/skills/text-to-tiktok.ts +97 -0
- package/src/index.ts +118 -0
- package/src/providers/apify.ts +269 -0
- package/src/providers/base.ts +264 -0
- package/src/providers/elevenlabs.ts +217 -0
- package/src/providers/fal.ts +392 -0
- package/src/providers/ffmpeg.ts +544 -0
- package/src/providers/fireworks.ts +193 -0
- package/src/providers/groq.ts +149 -0
- package/src/providers/higgsfield.ts +145 -0
- package/src/providers/index.ts +143 -0
- package/src/providers/replicate.ts +147 -0
- package/src/providers/storage.ts +206 -0
- package/src/react/cli.ts +52 -0
- package/src/react/elements.ts +146 -0
- package/src/react/examples/branching.tsx +66 -0
- package/src/react/examples/captions-demo.tsx +37 -0
- package/src/react/examples/character-video.tsx +84 -0
- package/src/react/examples/grid.tsx +53 -0
- package/src/react/examples/layouts-demo.tsx +57 -0
- package/src/react/examples/madi.tsx +60 -0
- package/src/react/examples/music-test.tsx +35 -0
- package/src/react/examples/onlyfans-1m/workflow.tsx +88 -0
- package/src/react/examples/orange-portrait.tsx +41 -0
- package/src/react/examples/split-element-demo.tsx +60 -0
- package/src/react/examples/split-layout-demo.tsx +60 -0
- package/src/react/examples/split.tsx +41 -0
- package/src/react/examples/video-grid.tsx +46 -0
- package/src/react/index.ts +43 -0
- package/src/react/layouts/grid.tsx +28 -0
- package/src/react/layouts/index.ts +2 -0
- package/src/react/layouts/split.tsx +20 -0
- package/src/react/react.test.ts +309 -0
- package/src/react/render.ts +21 -0
- package/src/react/renderers/animate.ts +59 -0
- package/src/react/renderers/captions.ts +297 -0
- package/src/react/renderers/clip.ts +248 -0
- package/src/react/renderers/context.ts +17 -0
- package/src/react/renderers/image.ts +109 -0
- package/src/react/renderers/index.ts +22 -0
- package/src/react/renderers/music.ts +60 -0
- package/src/react/renderers/packshot.ts +84 -0
- package/src/react/renderers/progress.ts +173 -0
- package/src/react/renderers/render.ts +243 -0
- package/src/react/renderers/slider.ts +69 -0
- package/src/react/renderers/speech.ts +53 -0
- package/src/react/renderers/split.ts +91 -0
- package/src/react/renderers/subtitle.ts +16 -0
- package/src/react/renderers/swipe.ts +75 -0
- package/src/react/renderers/title.ts +17 -0
- package/src/react/renderers/utils.ts +124 -0
- package/src/react/renderers/video.ts +127 -0
- package/src/react/runtime/jsx-dev-runtime.ts +43 -0
- package/src/react/runtime/jsx-runtime.ts +35 -0
- package/src/react/types.ts +232 -0
- package/src/studio/index.ts +26 -0
- package/src/studio/scanner.ts +102 -0
- package/src/studio/server.ts +554 -0
- package/src/studio/stages.ts +251 -0
- package/src/studio/step-renderer.ts +279 -0
- package/src/studio/types.ts +60 -0
- package/src/studio/ui/cache.html +303 -0
- package/src/studio/ui/index.html +1820 -0
- package/src/tests/all.test.ts +509 -0
- package/src/tests/index.ts +33 -0
- package/src/tests/unit.test.ts +403 -0
- package/tsconfig.cli.json +8 -0
- package/tsconfig.json +21 -3
- package/TEST_RESULTS.md +0 -122
- package/action/captions/SKILL.md +0 -170
- package/action/captions/index.ts +0 -169
- package/action/edit/SKILL.md +0 -235
- package/action/edit/index.ts +0 -437
- package/action/image/SKILL.md +0 -140
- package/action/image/index.ts +0 -105
- package/action/sync/SKILL.md +0 -136
- package/action/sync/index.ts +0 -145
- package/action/transcribe/SKILL.md +0 -179
- package/action/video/SKILL.md +0 -116
- package/action/video/index.ts +0 -125
- package/action/voice/SKILL.md +0 -125
- package/action/voice/index.ts +0 -136
- package/cli/commands/find.ts +0 -58
- package/cli/commands/help.ts +0 -70
- package/cli/commands/list.ts +0 -49
- package/cli/commands/run.ts +0 -237
- package/cli/commands/which.ts +0 -66
- package/cli/discover.ts +0 -66
- package/cli/index.ts +0 -33
- package/cli/runner.ts +0 -65
- package/cli/types.ts +0 -49
- package/cli/ui.ts +0 -185
- package/index.ts +0 -75
- package/lib/README.md +0 -144
- package/lib/ai-sdk/fal.ts +0 -106
- package/lib/ai-sdk/replicate.ts +0 -107
- package/lib/elevenlabs.ts +0 -382
- package/lib/fal.ts +0 -467
- package/lib/ffmpeg.ts +0 -467
- package/lib/fireworks.ts +0 -235
- package/lib/groq.ts +0 -246
- package/lib/higgsfield.ts +0 -176
- package/lib/remotion/SKILL.md +0 -823
- package/lib/remotion/cli.ts +0 -115
- package/lib/remotion/functions.ts +0 -283
- package/lib/remotion/index.ts +0 -19
- package/lib/remotion/templates.ts +0 -73
- package/lib/replicate.ts +0 -304
- package/output.txt +0 -1
- package/test-import.ts +0 -7
- package/test-services.ts +0 -97
- 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
|
+
}
|