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
@@ -1,66 +0,0 @@
1
- /**
2
- * varg which command
3
- * inspect an action by scanning filesystem
4
- */
5
-
6
- import { defineCommand } from "citty";
7
- import { resolve } from "../discover";
8
- import { box, c, header, separator } from "../ui";
9
-
10
- export const whichCmd = defineCommand({
11
- meta: {
12
- name: "which",
13
- description: "inspect what's behind an action",
14
- },
15
- args: {
16
- name: {
17
- type: "positional",
18
- description: "action name",
19
- required: true,
20
- },
21
- },
22
- async run({ args }) {
23
- const name = args.name;
24
-
25
- if (!name) {
26
- console.error(`${c.red("error:")} action name required`);
27
- console.log(`\nusage: ${c.cyan("varg which <name>")}`);
28
- process.exit(1);
29
- }
30
-
31
- const item = await resolve(name);
32
-
33
- if (!item) {
34
- console.error(`${c.red("error:")} '${name}' not found`);
35
- console.log(`\nrun ${c.cyan("varg list")} to see available actions`);
36
- process.exit(1);
37
- }
38
-
39
- const content: string[] = [];
40
- content.push("");
41
- content.push(` ${item.description}`);
42
- content.push("");
43
-
44
- content.push(header("SCHEMA"));
45
- content.push("");
46
-
47
- for (const [key, prop] of Object.entries(item.schema.input.properties)) {
48
- const required = item.schema.input.required.includes(key);
49
- const reqTag = required ? c.yellow("*") : " ";
50
- const defaultVal = prop.default
51
- ? c.dim(` (default: ${prop.default})`)
52
- : "";
53
- content.push(
54
- ` ${reqTag}${c.cyan(key.padEnd(12))}${prop.description}${defaultVal}`,
55
- );
56
- }
57
-
58
- content.push("");
59
- content.push(separator());
60
- content.push("");
61
- content.push(` run ${c.cyan(`varg run ${name} --info`)} for full options`);
62
- content.push("");
63
-
64
- console.log(box(`action: ${name}`, content));
65
- },
66
- });
package/cli/discover.ts DELETED
@@ -1,66 +0,0 @@
1
- /**
2
- * filesystem-based discovery for varg cli
3
- * scans action/ directory for modules with meta exports
4
- */
5
-
6
- import { readdir } from "node:fs/promises";
7
- import { join } from "node:path";
8
- import type { ActionMeta, Meta } from "./types";
9
-
10
- const ACTION_DIR = join(import.meta.dir, "..", "action");
11
-
12
- let cachedActions: ActionMeta[] | null = null;
13
-
14
- export async function discoverActions(): Promise<ActionMeta[]> {
15
- if (cachedActions) return cachedActions;
16
-
17
- const actions: ActionMeta[] = [];
18
- const dirs = await readdir(ACTION_DIR);
19
-
20
- for (const dir of dirs) {
21
- try {
22
- const mod = await import(`../action/${dir}`);
23
- if (mod.meta && mod.meta.type === "action") {
24
- actions.push(mod.meta);
25
- }
26
- } catch {
27
- // skip directories without valid modules
28
- }
29
- }
30
-
31
- cachedActions = actions;
32
- return actions;
33
- }
34
-
35
- export async function resolve(name: string): Promise<Meta | null> {
36
- const actions = await discoverActions();
37
-
38
- // check explicit namespace
39
- if (name.startsWith("action/")) {
40
- const actionName = name.slice(7);
41
- return actions.find((a) => a.name === actionName) || null;
42
- }
43
-
44
- // check actions
45
- const action = actions.find((a) => a.name === name);
46
- if (action) return action;
47
-
48
- return null;
49
- }
50
-
51
- export async function search(query: string): Promise<Meta[]> {
52
- const actions = await discoverActions();
53
- const q = query.toLowerCase();
54
-
55
- return actions.filter(
56
- (a) =>
57
- a.name.toLowerCase().includes(q) ||
58
- a.description.toLowerCase().includes(q) ||
59
- a.inputType.toLowerCase().includes(q) ||
60
- a.outputType.toLowerCase().includes(q),
61
- );
62
- }
63
-
64
- export async function list(): Promise<Meta[]> {
65
- return discoverActions();
66
- }
package/cli/index.ts DELETED
@@ -1,33 +0,0 @@
1
- #!/usr/bin/env bun
2
-
3
- /**
4
- * varg cli
5
- * ai video infrastructure from your terminal
6
- */
7
-
8
- import { defineCommand, runMain } from "citty";
9
- import { findCmd } from "./commands/find";
10
- import { helpCmd } from "./commands/help";
11
- import { listCmd } from "./commands/list";
12
- import { runCmd } from "./commands/run";
13
- import { whichCmd } from "./commands/which";
14
-
15
- const main = defineCommand({
16
- meta: {
17
- name: "varg",
18
- version: "0.1.0",
19
- description: "ai video infrastructure from your terminal",
20
- },
21
- subCommands: {
22
- run: runCmd,
23
- list: listCmd,
24
- ls: listCmd,
25
- find: findCmd,
26
- search: findCmd,
27
- which: whichCmd,
28
- inspect: whichCmd,
29
- help: helpCmd,
30
- },
31
- });
32
-
33
- runMain(main);
package/cli/runner.ts DELETED
@@ -1,65 +0,0 @@
1
- /**
2
- * shared cli runner for actions
3
- * parses args and calls meta.run()
4
- */
5
-
6
- import type { Meta } from "./types";
7
-
8
- export async function runCli(meta: Meta) {
9
- const args = process.argv.slice(2);
10
-
11
- if (args[0] === "help" || args[0] === "--help" || args.length === 0) {
12
- console.log(`
13
- ${meta.name} - ${meta.description}
14
-
15
- usage:
16
- bun run action/${meta.name} [options]
17
-
18
- options:`);
19
-
20
- for (const [key, prop] of Object.entries(meta.schema.input.properties)) {
21
- const req = meta.schema.input.required.includes(key) ? " (required)" : "";
22
- const def =
23
- prop.default !== undefined ? ` [default: ${prop.default}]` : "";
24
- console.log(` --${key.padEnd(14)} ${prop.description}${req}${def}`);
25
- }
26
-
27
- console.log(`
28
- examples:
29
- bun run action/${meta.name} --${meta.schema.input.required[0]} "value"
30
- `);
31
- return;
32
- }
33
-
34
- // parse args
35
- const options: Record<string, unknown> = {};
36
- const firstRequired = meta.schema.input.required[0];
37
-
38
- for (let i = 0; i < args.length; i++) {
39
- const arg = args[i];
40
- if (arg?.startsWith("--")) {
41
- const key = arg.slice(2);
42
- const value = args[++i];
43
- options[key] = value;
44
- } else if (arg && firstRequired && !options[firstRequired]) {
45
- // first positional arg goes to first required field
46
- options[firstRequired] = arg;
47
- }
48
- }
49
-
50
- // validate required
51
- for (const req of meta.schema.input.required) {
52
- if (!options[req]) {
53
- console.error(`error: --${req} is required`);
54
- process.exit(1);
55
- }
56
- }
57
-
58
- try {
59
- const result = await meta.run(options);
60
- console.log(JSON.stringify(result, null, 2));
61
- } catch (err) {
62
- console.error(`error: ${err instanceof Error ? err.message : err}`);
63
- process.exit(1);
64
- }
65
- }
package/cli/types.ts DELETED
@@ -1,49 +0,0 @@
1
- /**
2
- * shared types for varg cli
3
- * actions and models export meta objects conforming to these types
4
- */
5
-
6
- export interface SchemaProperty {
7
- type: string;
8
- description: string;
9
- enum?: (string | number)[];
10
- default?: unknown;
11
- format?: string;
12
- }
13
-
14
- export interface Schema {
15
- input: {
16
- type: "object";
17
- required: string[];
18
- properties: Record<string, SchemaProperty>;
19
- };
20
- output: {
21
- type: string;
22
- format?: string;
23
- description: string;
24
- };
25
- }
26
-
27
- export interface ActionMeta {
28
- name: string;
29
- type: "action";
30
- description: string;
31
- inputType: string;
32
- outputType: string;
33
- schema: Schema;
34
- run: (options: Record<string, unknown>) => Promise<unknown>;
35
- }
36
-
37
- export interface ModelMeta {
38
- name: string;
39
- type: "model";
40
- description: string;
41
- inputType: string;
42
- outputType: string;
43
- providers: string[];
44
- defaultProvider: string;
45
- schema: Schema;
46
- run: (options: Record<string, unknown>) => Promise<unknown>;
47
- }
48
-
49
- export type Meta = ActionMeta | ModelMeta;
package/cli/ui.ts DELETED
@@ -1,185 +0,0 @@
1
- /**
2
- * terminal ui helpers for varg cli
3
- * beautiful boxes and formatting
4
- */
5
-
6
- const COLORS = {
7
- reset: "\x1b[0m",
8
- bold: "\x1b[1m",
9
- dim: "\x1b[2m",
10
- green: "\x1b[32m",
11
- yellow: "\x1b[33m",
12
- blue: "\x1b[34m",
13
- magenta: "\x1b[35m",
14
- cyan: "\x1b[36m",
15
- red: "\x1b[31m",
16
- gray: "\x1b[90m",
17
- };
18
-
19
- export const c = {
20
- reset: (s: string) => `${COLORS.reset}${s}${COLORS.reset}`,
21
- bold: (s: string) => `${COLORS.bold}${s}${COLORS.reset}`,
22
- dim: (s: string) => `${COLORS.dim}${s}${COLORS.reset}`,
23
- green: (s: string) => `${COLORS.green}${s}${COLORS.reset}`,
24
- yellow: (s: string) => `${COLORS.yellow}${s}${COLORS.reset}`,
25
- blue: (s: string) => `${COLORS.blue}${s}${COLORS.reset}`,
26
- magenta: (s: string) => `${COLORS.magenta}${s}${COLORS.reset}`,
27
- cyan: (s: string) => `${COLORS.cyan}${s}${COLORS.reset}`,
28
- red: (s: string) => `${COLORS.red}${s}${COLORS.reset}`,
29
- gray: (s: string) => `${COLORS.gray}${s}${COLORS.reset}`,
30
- };
31
-
32
- // strip ansi codes for length calculation
33
- // biome-ignore lint/complexity/useRegexLiterals: literal triggers noControlCharactersInRegex
34
- const ANSI_REGEX = new RegExp("\x1b\\[[0-9;]*m", "g");
35
- function stripAnsi(s: string): string {
36
- return s.replace(ANSI_REGEX, "");
37
- }
38
-
39
- // box drawing characters
40
- const BOX = {
41
- topLeft: "┌",
42
- topRight: "┐",
43
- bottomLeft: "└",
44
- bottomRight: "┘",
45
- horizontal: "─",
46
- vertical: "│",
47
- line: "─",
48
- };
49
-
50
- export const WIDTH = 71;
51
-
52
- export function box(title: string, content: string[]): string {
53
- const lines: string[] = [];
54
-
55
- // top border with title
56
- const titlePart = title ? `${BOX.line} ${title} ` : "";
57
- const remainingWidth = WIDTH - 2 - stripAnsi(titlePart).length;
58
- lines.push(
59
- `${BOX.topLeft}${titlePart}${BOX.horizontal.repeat(remainingWidth)}${BOX.topRight}`,
60
- );
61
-
62
- // content lines
63
- for (const line of content) {
64
- const stripped = stripAnsi(line);
65
- const padding = WIDTH - 2 - stripped.length;
66
- if (padding >= 0) {
67
- lines.push(`${BOX.vertical}${line}${" ".repeat(padding)}${BOX.vertical}`);
68
- } else {
69
- // truncate if too long
70
- lines.push(
71
- `${BOX.vertical}${line.slice(0, WIDTH - 5)}...${BOX.vertical}`,
72
- );
73
- }
74
- }
75
-
76
- // bottom border
77
- lines.push(
78
- `${BOX.bottomLeft}${BOX.horizontal.repeat(WIDTH - 2)}${BOX.bottomRight}`,
79
- );
80
-
81
- return lines.join("\n");
82
- }
83
-
84
- export function separator(): string {
85
- return ` ${c.dim(BOX.horizontal.repeat(WIDTH - 4))}`;
86
- }
87
-
88
- export function header(text: string): string {
89
- return c.bold(c.dim(` ${text}`));
90
- }
91
-
92
- export function row(label: string, value: string, indent = 2): string {
93
- const spaces = " ".repeat(indent);
94
- const labelWidth = 14;
95
- const paddedLabel = label.padEnd(labelWidth);
96
- return `${spaces}${c.dim(paddedLabel)}${value}`;
97
- }
98
-
99
- export function success(message: string): string {
100
- return ` ${c.green("✓")} ${message}`;
101
- }
102
-
103
- export function error(message: string): string {
104
- return ` ${c.red("✗")} ${message}`;
105
- }
106
-
107
- export function spinner(message: string): string {
108
- return ` ${c.cyan("◐")} ${message}`;
109
- }
110
-
111
- export function formatDuration(ms: number): string {
112
- if (ms < 1000) return `${ms}ms`;
113
- const s = Math.round(ms / 1000);
114
- return `${s}s`;
115
- }
116
-
117
- export function formatCost(dollars: number): string {
118
- return `$${dollars.toFixed(3)}`;
119
- }
120
-
121
- // table formatting for list command
122
- export interface TableRow {
123
- name: string;
124
- description: string;
125
- providers?: string;
126
- }
127
-
128
- export function table(rows: TableRow[], nameWidth = 16): string[] {
129
- const lines: string[] = [];
130
-
131
- for (const row of rows) {
132
- const name = row.name.padEnd(nameWidth);
133
- const desc = row.description;
134
- const providers = row.providers ? c.dim(row.providers) : "";
135
-
136
- if (providers) {
137
- lines.push(` ${c.cyan(name)}${desc.padEnd(30)}${providers}`);
138
- } else {
139
- lines.push(` ${c.cyan(name)}${desc}`);
140
- }
141
- }
142
-
143
- return lines;
144
- }
145
-
146
- // progress output for running commands
147
- export function runningBox(
148
- name: string,
149
- params: Record<string, string>,
150
- status: "running" | "done" | "error",
151
- result?: { output?: string; cost?: number; error?: string; time?: number },
152
- ): string {
153
- const content: string[] = [""];
154
-
155
- // params
156
- for (const [key, value] of Object.entries(params)) {
157
- const displayValue =
158
- value.length > 40 ? `"${value.slice(0, 37)}..."` : `"${value}"`;
159
- content.push(row(key, displayValue));
160
- }
161
-
162
- content.push("");
163
-
164
- // status
165
- if (status === "running") {
166
- content.push(spinner("generating..."));
167
- } else if (status === "done" && result) {
168
- content.push(success(`done in ${formatDuration(result.time || 0)}`));
169
- content.push("");
170
- if (result.output) {
171
- content.push(row("output", result.output));
172
- }
173
- if (result.cost) {
174
- content.push(row("cost", formatCost(result.cost)));
175
- }
176
- } else if (status === "error" && result?.error) {
177
- content.push(error("failed"));
178
- content.push("");
179
- content.push(row("error", result.error));
180
- }
181
-
182
- content.push("");
183
-
184
- return box(name, content);
185
- }
package/index.ts DELETED
@@ -1,75 +0,0 @@
1
- /**
2
- * varg.ai sdk
3
- * video generation and editing tools
4
- */
5
-
6
- // re-export external clients
7
- export { fal } from "@ai-sdk/fal";
8
- export { replicate } from "@ai-sdk/replicate";
9
- export { fal as falClient } from "@fal-ai/client";
10
- export { HiggsfieldClient } from "@higgsfield/client";
11
- // action exports (excluding meta to avoid conflicts)
12
- export {
13
- type AddCaptionsOptions,
14
- addCaptions,
15
- type SubtitleStyle,
16
- } from "./action/captions";
17
- export {
18
- type CreateMontageOptions,
19
- createMontage,
20
- type EditPipelineOptions,
21
- type EditPipelineStep,
22
- editPipeline,
23
- mergeWithAudio,
24
- type PrepareForSocialOptions,
25
- prepareForSocial,
26
- quickResize,
27
- quickTrim,
28
- } from "./action/edit";
29
- export {
30
- generateWithFal,
31
- generateWithSoul,
32
- type ImageGenerationResult,
33
- } from "./action/image";
34
- export {
35
- type LipsyncOptions,
36
- lipsync,
37
- lipsyncOverlay,
38
- lipsyncWav2Lip,
39
- type Wav2LipOptions,
40
- } from "./action/sync";
41
- export {
42
- type TranscribeOptions,
43
- type TranscribeResult,
44
- transcribe,
45
- } from "./action/transcribe";
46
- export {
47
- generateVideoFromImage,
48
- generateVideoFromText,
49
- type VideoGenerationResult,
50
- } from "./action/video";
51
- export {
52
- type GenerateVoiceOptions,
53
- generateVoice,
54
- type VoiceResult,
55
- } from "./action/voice";
56
- // lib exports - ai-sdk/fal (provider)
57
- export * as aiSdkFal from "./lib/ai-sdk/fal";
58
- // lib exports - ai-sdk/replicate (provider)
59
- export * as aiSdkReplicate from "./lib/ai-sdk/replicate";
60
- // lib exports - elevenlabs
61
- export * from "./lib/elevenlabs";
62
- // lib exports - fal (client)
63
- export * from "./lib/fal";
64
- // lib exports - ffmpeg
65
- export * from "./lib/ffmpeg";
66
- // lib exports - fireworks
67
- export * from "./lib/fireworks";
68
- // lib exports - groq
69
- export * from "./lib/groq";
70
- // lib exports - higgsfield
71
- export * from "./lib/higgsfield";
72
- // lib exports - replicate
73
- export * from "./lib/replicate";
74
- // utilities exports
75
- export * from "./utilities/s3";
package/lib/README.md DELETED
@@ -1,144 +0,0 @@
1
- # lib/ modules
2
-
3
- ## two fal implementations
4
-
5
- ### lib/ai-sdk/fal.ts - ai-sdk provider (recommended for images)
6
-
7
- uses `@ai-sdk/fal` with the vercel ai sdk's `experimental_generateImage`
8
-
9
- **benefits:**
10
- - clean, typed api via vercel ai sdk
11
- - automatic image format handling (uint8array)
12
- - consistent interface with other ai providers
13
- - built-in aspect ratio support
14
- - better for standard image generation
15
-
16
- **example:**
17
- ```bash
18
- bun run lib/ai-sdk/fal.ts generate_image "cyberpunk city" "fal-ai/flux/dev" "16:9"
19
- ```
20
-
21
- **code:**
22
- ```typescript
23
- import { fal } from "@ai-sdk/fal"
24
- import { experimental_generateImage as generateImage } from "ai"
25
-
26
- const { image, providerMetadata } = await generateImage({
27
- model: fal.image("fal-ai/flux/dev"),
28
- prompt: "beautiful sunset",
29
- aspectRatio: "16:9",
30
- })
31
- ```
32
-
33
- ### lib/fal.ts - fal client direct (for video & advanced features)
34
-
35
- uses `@fal-ai/client` directly with the raw fal api
36
-
37
- **benefits:**
38
- - access to all fal features (video, advanced params)
39
- - streaming/queue updates
40
- - full control over api parameters
41
- - required for video generation (no ai-sdk support yet)
42
- - **supports local images** - automatically uploads local files to fal storage
43
-
44
- **examples:**
45
- ```bash
46
- # image generation
47
- bun run lib/fal.ts generate_image "aurora borealis" "fal-ai/flux-pro/v1.1"
48
-
49
- # video from url
50
- bun run lib/fal.ts image_to_video "person talking" "https://image.url" 5
51
-
52
- # video from local file (auto-uploads)
53
- bun run lib/fal.ts image_to_video "ocean waves" "./media/beach.jpg" 10
54
- ```
55
-
56
- **code:**
57
- ```typescript
58
- import { imageToVideo } from "./lib/fal"
59
-
60
- // works with both urls and local files
61
- const result = await imageToVideo({
62
- prompt: "person talking",
63
- imageUrl: "./local/image.jpg", // or "https://..."
64
- duration: 5,
65
- })
66
-
67
- // local files are automatically uploaded to fal storage
68
- ```
69
-
70
- ## when to use which?
71
-
72
- | use case | approach |
73
- |----------|----------|
74
- | standard image generation | ai-sdk provider ✓ |
75
- | video generation | fal client direct ✓ |
76
- | advanced fal features | fal client direct ✓ |
77
- | multi-provider app | ai-sdk provider ✓ |
78
- | custom queue handling | fal client direct ✓ |
79
-
80
- ## higgsfield.ts
81
-
82
- uses `@higgsfield/client` for soul character generation
83
-
84
- **features:**
85
- - generate soul images with custom styles
86
- - create and manage character references
87
- - list available soul styles
88
- - poll for job completion
89
-
90
- **example:**
91
- ```bash
92
- HF_API_KEY=xxx HF_API_SECRET=xxx bun run lib/higgsfield.ts generate_soul "professional headshot"
93
- ```
94
-
95
- ## elevenlabs.ts
96
-
97
- uses `@elevenlabs/elevenlabs-js` for voice, music, and sound effects generation
98
-
99
- **features:**
100
- - text-to-speech with multiple voices
101
- - music generation from text prompts
102
- - sound effects generation
103
- - voice management
104
-
105
- **examples:**
106
- ```bash
107
- # text-to-speech
108
- bun run lib/elevenlabs.ts tts "hello world" rachel output.mp3
109
-
110
- # music generation
111
- bun run lib/elevenlabs.ts music "upbeat electronic dance music" 30000 music.mp3
112
-
113
- # sound effects
114
- bun run lib/elevenlabs.ts sfx "ocean waves crashing" 5 waves.mp3
115
-
116
- # list voices
117
- bun run lib/elevenlabs.ts voices
118
- ```
119
-
120
- **code:**
121
- ```typescript
122
- import { textToSpeech, generateMusic, generateSoundEffect } from "./lib/elevenlabs"
123
-
124
- // voice
125
- const audio = await textToSpeech({
126
- text: "hello world",
127
- voiceId: "rachel",
128
- outputPath: "output.mp3"
129
- })
130
-
131
- // music
132
- const music = await generateMusic({
133
- prompt: "epic orchestral music",
134
- musicLengthMs: 60000,
135
- outputPath: "music.mp3"
136
- })
137
-
138
- // sound effects
139
- const sfx = await generateSoundEffect({
140
- text: "thunder and rain",
141
- durationSeconds: 10,
142
- outputPath: "sfx.mp3"
143
- })
144
- ```