@vargai/sdk 0.1.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/.env.example +24 -0
- package/CLAUDE.md +118 -0
- package/HIGGSFIELD_REWRITE_SUMMARY.md +300 -0
- package/README.md +231 -0
- package/SKILLS.md +157 -0
- package/STRUCTURE.md +92 -0
- package/TEST_RESULTS.md +122 -0
- package/action/captions/SKILL.md +170 -0
- package/action/captions/index.ts +169 -0
- package/action/edit/SKILL.md +235 -0
- package/action/edit/index.ts +437 -0
- package/action/image/SKILL.md +140 -0
- package/action/image/index.ts +105 -0
- package/action/sync/SKILL.md +136 -0
- package/action/sync/index.ts +145 -0
- package/action/transcribe/SKILL.md +179 -0
- package/action/transcribe/index.ts +210 -0
- package/action/video/SKILL.md +116 -0
- package/action/video/index.ts +125 -0
- package/action/voice/SKILL.md +125 -0
- package/action/voice/index.ts +136 -0
- package/biome.json +33 -0
- package/bun.lock +842 -0
- package/cli/commands/find.ts +58 -0
- package/cli/commands/help.ts +70 -0
- package/cli/commands/list.ts +49 -0
- package/cli/commands/run.ts +237 -0
- package/cli/commands/which.ts +66 -0
- package/cli/discover.ts +66 -0
- package/cli/index.ts +33 -0
- package/cli/runner.ts +65 -0
- package/cli/types.ts +49 -0
- package/cli/ui.ts +185 -0
- package/index.ts +75 -0
- package/lib/README.md +144 -0
- package/lib/ai-sdk/fal.ts +106 -0
- package/lib/ai-sdk/replicate.ts +107 -0
- package/lib/elevenlabs.ts +382 -0
- package/lib/fal.ts +467 -0
- package/lib/ffmpeg.ts +467 -0
- package/lib/fireworks.ts +235 -0
- package/lib/groq.ts +246 -0
- package/lib/higgsfield/MIGRATION.md +308 -0
- package/lib/higgsfield/README.md +273 -0
- package/lib/higgsfield/example.ts +228 -0
- package/lib/higgsfield/index.ts +241 -0
- package/lib/higgsfield/soul.ts +262 -0
- package/lib/higgsfield.ts +176 -0
- package/lib/remotion/SKILL.md +823 -0
- package/lib/remotion/cli.ts +115 -0
- package/lib/remotion/functions.ts +283 -0
- package/lib/remotion/index.ts +19 -0
- package/lib/remotion/templates.ts +73 -0
- package/lib/replicate.ts +304 -0
- package/output.txt +1 -0
- package/package.json +42 -0
- package/pipeline/cookbooks/SKILL.md +285 -0
- package/pipeline/cookbooks/remotion-video.md +585 -0
- package/pipeline/cookbooks/round-video-character.md +337 -0
- package/pipeline/cookbooks/talking-character.md +59 -0
- package/scripts/produce-menopause-campaign.sh +202 -0
- package/service/music/SKILL.md +229 -0
- package/service/music/index.ts +296 -0
- package/test-import.ts +7 -0
- package/test-services.ts +97 -0
- package/tsconfig.json +29 -0
- package/utilities/s3.ts +147 -0
package/utilities/s3.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* cloudflare r2 / s3 storage wrapper
|
|
4
|
+
* usage: bun run utilities/s3.ts <command> <args>
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
GetObjectCommand,
|
|
9
|
+
PutObjectCommand,
|
|
10
|
+
S3Client,
|
|
11
|
+
} from "@aws-sdk/client-s3";
|
|
12
|
+
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
13
|
+
|
|
14
|
+
const client = new S3Client({
|
|
15
|
+
region: "auto",
|
|
16
|
+
endpoint: process.env.CLOUDFLARE_R2_API_URL,
|
|
17
|
+
credentials: {
|
|
18
|
+
accessKeyId: process.env.CLOUDFLARE_ACCESS_KEY_ID || "",
|
|
19
|
+
secretAccessKey: process.env.CLOUDFLARE_ACCESS_SECRET || "",
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const BUCKET = process.env.CLOUDFLARE_R2_BUCKET || "m";
|
|
24
|
+
|
|
25
|
+
export async function uploadFile(
|
|
26
|
+
filePath: string,
|
|
27
|
+
objectKey: string,
|
|
28
|
+
): Promise<string> {
|
|
29
|
+
console.log(`[s3] uploading ${filePath} to ${objectKey}`);
|
|
30
|
+
|
|
31
|
+
const file = Bun.file(filePath);
|
|
32
|
+
const buffer = await file.arrayBuffer();
|
|
33
|
+
|
|
34
|
+
await client.send(
|
|
35
|
+
new PutObjectCommand({
|
|
36
|
+
Bucket: BUCKET,
|
|
37
|
+
Key: objectKey,
|
|
38
|
+
Body: new Uint8Array(buffer),
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return getPublicUrl(objectKey);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function uploadFromUrl(
|
|
46
|
+
url: string,
|
|
47
|
+
objectKey: string,
|
|
48
|
+
): Promise<string> {
|
|
49
|
+
console.log(`[s3] downloading from ${url}`);
|
|
50
|
+
|
|
51
|
+
const response = await fetch(url);
|
|
52
|
+
const buffer = await response.arrayBuffer();
|
|
53
|
+
|
|
54
|
+
console.log(`[s3] uploading to ${objectKey}`);
|
|
55
|
+
|
|
56
|
+
await client.send(
|
|
57
|
+
new PutObjectCommand({
|
|
58
|
+
Bucket: BUCKET,
|
|
59
|
+
Key: objectKey,
|
|
60
|
+
Body: new Uint8Array(buffer),
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
return getPublicUrl(objectKey);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export async function generatePresignedUrl(
|
|
68
|
+
objectKey: string,
|
|
69
|
+
expiresIn = 3600,
|
|
70
|
+
): Promise<string> {
|
|
71
|
+
const command = new GetObjectCommand({
|
|
72
|
+
Bucket: BUCKET,
|
|
73
|
+
Key: objectKey,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return await getSignedUrl(client, command, { expiresIn });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function getPublicUrl(objectKey: string): string {
|
|
80
|
+
const endpoint = process.env.CLOUDFLARE_R2_API_URL || "";
|
|
81
|
+
|
|
82
|
+
if (endpoint.includes("localhost")) {
|
|
83
|
+
return `${endpoint}/${BUCKET}/${objectKey}`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return `http://s3.varg.ai/${BUCKET}/${objectKey}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// cli runner
|
|
90
|
+
if (import.meta.main) {
|
|
91
|
+
const [command, ...args] = process.argv.slice(2);
|
|
92
|
+
|
|
93
|
+
switch (command) {
|
|
94
|
+
case "upload": {
|
|
95
|
+
if (!args[0] || !args[1]) {
|
|
96
|
+
console.log(`
|
|
97
|
+
usage:
|
|
98
|
+
bun run utilities/s3.ts upload <filePath> <objectKey>
|
|
99
|
+
`);
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
const uploadResult = await uploadFile(args[0], args[1]);
|
|
103
|
+
console.log(uploadResult);
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
case "upload_from_url": {
|
|
108
|
+
if (!args[0] || !args[1]) {
|
|
109
|
+
console.log(`
|
|
110
|
+
usage:
|
|
111
|
+
bun run utilities/s3.ts upload_from_url <url> <objectKey>
|
|
112
|
+
`);
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
const urlUploadResult = await uploadFromUrl(args[0], args[1]);
|
|
116
|
+
console.log(urlUploadResult);
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
case "presigned_url": {
|
|
121
|
+
if (!args[0]) {
|
|
122
|
+
console.log(`
|
|
123
|
+
usage:
|
|
124
|
+
bun run utilities/s3.ts presigned_url <objectKey> [expiresIn]
|
|
125
|
+
`);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
const expiresIn = args[1] ? Number.parseInt(args[1], 10) : 3600;
|
|
129
|
+
if (Number.isNaN(expiresIn)) {
|
|
130
|
+
console.error("expiresIn must be a valid number");
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
const presignedUrl = await generatePresignedUrl(args[0], expiresIn);
|
|
134
|
+
console.log(presignedUrl);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
default:
|
|
139
|
+
console.log(`
|
|
140
|
+
usage:
|
|
141
|
+
bun run utilities/s3.ts upload <filePath> <objectKey>
|
|
142
|
+
bun run utilities/s3.ts upload_from_url <url> <objectKey>
|
|
143
|
+
bun run utilities/s3.ts presigned_url <objectKey> [expiresIn]
|
|
144
|
+
`);
|
|
145
|
+
process.exit(1);
|
|
146
|
+
}
|
|
147
|
+
}
|