vibedgames 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/assets/align-framing.py +242 -0
- package/assets/render-model.py +406 -0
- package/assets/tilemap-editor.html +630 -0
- package/dist/THIRD_PARTY_NOTICES.txt +2 -2
- package/dist/chunk-2KVQJKIZ.js +6495 -0
- package/dist/{chunk-56OY4TEP.js → chunk-2SBBKY5C.js} +1361 -4493
- package/dist/{chunk-FC233UKH.js → chunk-2ZKS7V72.js} +16 -16
- package/dist/{chunk-BMTHAVMS.js → chunk-3HGBIUM5.js} +22 -19
- package/dist/chunk-3UGGMFJJ.js +22 -0
- package/dist/{chunk-3HUWAJQH.js → chunk-42K3BJJH.js} +93 -76
- package/dist/{chunk-ST5FC2W3.js → chunk-43P4U7CB.js} +20 -11
- package/dist/chunk-4FJXCS3K.js +741 -0
- package/dist/{chunk-WSRIF6K4.js → chunk-4UU622RK.js} +5 -4
- package/dist/chunk-5YPLKGY3.js +87 -0
- package/dist/chunk-6KXXZXSO.js +475 -0
- package/dist/chunk-7RPLQWR2.js +91 -0
- package/dist/{chunk-ZCYWDKYP.js → chunk-A556KALN.js} +14 -13
- package/dist/{chunk-UFR6G6BL.js → chunk-ABTUEIRC.js} +554 -254
- package/dist/{chunk-PEUP4MZR.js → chunk-AWJNAGPE.js} +6 -3
- package/dist/{chunk-HNRVSBRK.js → chunk-BN3Q7UEC.js} +20 -17
- package/dist/chunk-BZOMEG3X.js +412 -0
- package/dist/{chunk-ZYCSYJWX.js → chunk-COSLGSVO.js} +14 -24
- package/dist/{chunk-KZBZNTM4.js → chunk-CTY2WZQK.js} +9 -13
- package/dist/chunk-DB7WVFS7.js +80 -0
- package/dist/chunk-DOOQUFPG.js +73 -0
- package/dist/{chunk-K2U7L4RU.js → chunk-E3FJUPLT.js} +15 -21
- package/dist/chunk-E7NDOZ27.js +428 -0
- package/dist/{chunk-TBQ5BU3Q.js → chunk-F42QKWBB.js} +18 -18
- package/dist/chunk-FXXVXDTW.js +168 -0
- package/dist/{chunk-VFFOT7KD.js → chunk-G66HRVDW.js} +1 -1
- package/dist/chunk-GLEW7VJQ.js +45 -0
- package/dist/{chunk-AXTLPJ2F.js → chunk-H2C4QUTG.js} +8 -7
- package/dist/{chunk-H3IPLBXQ.js → chunk-HRKVAXNN.js} +17 -14
- package/dist/{chunk-UXCWSWWX.js → chunk-HSMG6U7J.js} +8 -7
- package/dist/chunk-HX5Q63UA.js +48 -0
- package/dist/chunk-HYOXGNWS.js +53 -0
- package/dist/chunk-I5LELJSK.js +22 -0
- package/dist/{chunk-7CXMMC5S.js → chunk-JN4WZCR7.js} +5 -4
- package/dist/{chunk-7QZSDU52.js → chunk-K36EOII3.js} +5 -4
- package/dist/chunk-KAGVI3CE.js +62 -0
- package/dist/chunk-KJK5CB6E.js +58 -0
- package/dist/chunk-KLFBAFXD.js +25 -0
- package/dist/{chunk-355VG7EO.js → chunk-LONQWRTR.js} +107 -77
- package/dist/{chunk-Z5TFZQ5U.js → chunk-LORGE2NB.js} +68 -62
- package/dist/{chunk-LY2GQ32S.js → chunk-MEAO33XW.js} +22 -20
- package/dist/{chunk-OD2MNYXD.js → chunk-MR5KIFI7.js} +23 -22
- package/dist/{chunk-2VUUMXAQ.js → chunk-N2UHAQXC.js} +18 -11
- package/dist/chunk-NCX6LYNJ.js +117 -0
- package/dist/chunk-OGX4DKIS.js +215 -0
- package/dist/chunk-OPUCUUID.js +41 -0
- package/dist/chunk-Q2QC6KAZ.js +132 -0
- package/dist/{chunk-NDHXM4PL.js → chunk-Q3XQPNF6.js} +12 -12
- package/dist/{chunk-RXHTGX7C.js → chunk-Q5NZNXJE.js} +6 -10
- package/dist/chunk-QLCVLCPM.js +126 -0
- package/dist/chunk-R2WVORGD.js +91 -0
- package/dist/chunk-RKS7SI5L.js +64 -0
- package/dist/{chunk-US6QZICZ.js → chunk-RPJR3S5S.js} +32 -18
- package/dist/chunk-RPSUFZAG.js +3307 -0
- package/dist/chunk-RRI23NK2.js +40 -0
- package/dist/chunk-S7HYWITX.js +57 -0
- package/dist/chunk-SBXCK2I2.js +48 -0
- package/dist/chunk-SUSX3QIA.js +62 -0
- package/dist/{chunk-6EWHKL7Z.js → chunk-SXYQL4GK.js} +7 -6
- package/dist/{chunk-ZI6PKVXG.js → chunk-TMPBGXT4.js} +6 -5
- package/dist/chunk-TXOE5UY5.js +72 -0
- package/dist/chunk-U6DTE5IX.js +124 -0
- package/dist/{chunk-UZM6OSW5.js → chunk-UPHB5HWO.js} +15 -13
- package/dist/chunk-UQ7VO6B3.js +91 -0
- package/dist/chunk-VB4WLJR2.js +47 -0
- package/dist/{chunk-25BAMW5X.js → chunk-VIEKOGKG.js} +18 -2
- package/dist/{chunk-LXS3NJYD.js → chunk-VZEJ2ZHE.js} +14 -15
- package/dist/{chunk-Z4Z24FWO.js → chunk-YNCYMWER.js} +8 -5
- package/dist/chunk-ZHLPE6LI.js +71 -0
- package/dist/index.js +39 -36
- package/package.json +31 -16
- package/templates/none/src/main.ts +4 -0
- package/templates/none/vite.config.ts +0 -2
- package/templates/phaser/src/main.ts +0 -1
- package/templates/phaser/src/scenes/game-scene.ts +10 -8
- package/templates/phaser/vite.config.ts +0 -2
- package/templates/react-r3f/src/app.tsx +3 -1
- package/templates/react-r3f/src/main.tsx +1 -0
- package/templates/react-r3f/vite.config.ts +0 -2
- package/templates/threejs/src/main.ts +10 -1
- package/templates/threejs/vite.config.ts +0 -2
- package/LICENSE +0 -21
- package/dist/chunk-J6PKNPI2.js +0 -26
|
@@ -6,50 +6,215 @@ var __filename = __fileURLToPath(import.meta.url);
|
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
7
|
import {
|
|
8
8
|
resolveSetting
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JN4WZCR7.js";
|
|
10
10
|
import {
|
|
11
|
-
createClient
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-Z4Z24FWO.js";
|
|
16
|
-
import "./chunk-PEUP4MZR.js";
|
|
17
|
-
import "./chunk-RXHTGX7C.js";
|
|
18
|
-
import {
|
|
19
|
-
require_cross_spawn
|
|
20
|
-
} from "./chunk-5535KDYI.js";
|
|
11
|
+
createClient
|
|
12
|
+
} from "./chunk-CTY2WZQK.js";
|
|
13
|
+
import "./chunk-E3FJUPLT.js";
|
|
14
|
+
import "./chunk-Q5NZNXJE.js";
|
|
21
15
|
import {
|
|
22
16
|
isJsonOutput,
|
|
23
17
|
outputArgs,
|
|
24
18
|
writeJson,
|
|
25
19
|
writeStructured
|
|
26
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-COSLGSVO.js";
|
|
21
|
+
import {
|
|
22
|
+
defineCommand
|
|
23
|
+
} from "./chunk-MBXCVCC4.js";
|
|
24
|
+
import {
|
|
25
|
+
require_cross_spawn
|
|
26
|
+
} from "./chunk-5535KDYI.js";
|
|
27
27
|
import {
|
|
28
28
|
consola
|
|
29
29
|
} from "./chunk-D2RF35HJ.js";
|
|
30
|
+
import "./chunk-YNCYMWER.js";
|
|
31
|
+
import "./chunk-AWJNAGPE.js";
|
|
30
32
|
import {
|
|
33
|
+
external_exports,
|
|
31
34
|
isJsonNumber,
|
|
32
35
|
isJsonObject,
|
|
33
|
-
isJsonString
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} from "./chunk-MBXCVCC4.js";
|
|
36
|
+
isJsonString,
|
|
37
|
+
parseJson
|
|
38
|
+
} from "./chunk-RPSUFZAG.js";
|
|
39
|
+
import "./chunk-2SBBKY5C.js";
|
|
38
40
|
import {
|
|
39
41
|
__toESM
|
|
40
42
|
} from "./chunk-GKDUYJ7R.js";
|
|
41
43
|
|
|
42
|
-
// src/
|
|
43
|
-
|
|
44
|
+
// ../../packages/contract/src/generate/generate-schema.ts
|
|
45
|
+
var uploadInput = external_exports.object({
|
|
46
|
+
contentType: external_exports.string().min(1).max(127).describe("The file's MIME type, e.g. `image/png`; PUT the bytes with this Content-Type"),
|
|
47
|
+
fileName: external_exports.string().min(1).max(255).describe("The file's name with its extension, e.g. `hero.png`, up to 255 characters")
|
|
48
|
+
});
|
|
49
|
+
var MAX_WAIT_SECONDS = 25;
|
|
50
|
+
var endpointId = external_exports.string().min(1).max(256).describe("A model's endpoint id, as generate models lists it, e.g. `fal-ai/flux/dev`");
|
|
51
|
+
var requestId = external_exports.string().min(1).max(128).describe("The job's `request_id`, as generate returned it, with the endpoint_id it ran on");
|
|
52
|
+
var runInput = external_exports.object({
|
|
53
|
+
endpoint_id: endpointId,
|
|
54
|
+
input: external_exports.record(external_exports.string(), external_exports.json()).describe("The model's input, per generate schema"),
|
|
55
|
+
wait_seconds: external_exports.number().int().min(0).max(MAX_WAIT_SECONDS).default(20).describe("How long to wait for the result before returning the request id")
|
|
56
|
+
});
|
|
57
|
+
var statusInput = external_exports.object({
|
|
58
|
+
action: external_exports.enum(["status", "result", "cancel"]).default("status").describe(
|
|
59
|
+
"`status` (the default) reports where the job is; `result` fetches its output once COMPLETED, which settles the bill; `cancel` stops a job that is still queued or running"
|
|
60
|
+
),
|
|
61
|
+
endpoint_id: endpointId,
|
|
62
|
+
logs: external_exports.boolean().default(false).describe("Include the job's logs with its status"),
|
|
63
|
+
request_id: requestId
|
|
64
|
+
});
|
|
65
|
+
var modelsInput = external_exports.object({
|
|
66
|
+
category: external_exports.string().max(128).optional().describe("Only models in this category, e.g. `text-to-image`, `image-to-video`"),
|
|
67
|
+
cursor: external_exports.string().max(512).optional().describe(
|
|
68
|
+
"The `next_cursor` of a previous result, for the page after it; omit for the first page"
|
|
69
|
+
),
|
|
70
|
+
endpoint_id: external_exports.array(external_exports.string().min(1).max(256)).max(50).optional().describe("Endpoint ids to look up directly instead of searching, e.g. `fal-ai/flux/dev`"),
|
|
71
|
+
expand: external_exports.array(external_exports.enum(["openapi-3.0", "enterprise_status"])).optional().describe("Extra fields to include per model: `openapi-3.0`, `enterprise_status`"),
|
|
72
|
+
limit: external_exports.number().int().min(1).max(100).default(20).describe("How many models to return per page, 1 to 100; default 20"),
|
|
73
|
+
query: external_exports.string().max(500).optional().describe("Free text, e.g. `pixel art sprite`"),
|
|
74
|
+
status: external_exports.enum(["active", "deprecated", "all"]).optional().describe("`deprecated` or `all` to include models past their prime; omit for active models")
|
|
75
|
+
});
|
|
76
|
+
var schemaInput = external_exports.object({
|
|
77
|
+
endpoint_id: endpointId,
|
|
78
|
+
format: external_exports.enum(["compact", "openapi"]).default("compact").describe(
|
|
79
|
+
"`compact` (the default) returns the model's catalog entry; `openapi` adds its full OpenAPI 3.0 document, with every input and output field"
|
|
80
|
+
)
|
|
81
|
+
});
|
|
82
|
+
var pricingInput = external_exports.object({ endpoint_id: endpointId });
|
|
83
|
+
var docsInput = external_exports.object({
|
|
84
|
+
query: external_exports.string().min(1).max(500).describe(
|
|
85
|
+
"What to look up, in plain words and up to 500 characters, e.g. `how to prompt seedance camera moves`"
|
|
86
|
+
)
|
|
87
|
+
});
|
|
44
88
|
|
|
45
|
-
// ../../packages/contract/src/generate/
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
89
|
+
// ../../packages/contract/src/generate/media-schema.ts
|
|
90
|
+
var options = external_exports.record(external_exports.string(), external_exports.json()).default({}).describe(
|
|
91
|
+
"Any other input the model takes, per generate schema of its endpoint; the fields above win"
|
|
92
|
+
);
|
|
93
|
+
var prompt = external_exports.string().min(1).max(5e3);
|
|
94
|
+
var imageUrl = external_exports.url().describe("An image's URL, e.g. from generate upload");
|
|
95
|
+
var waitSeconds = runInput.shape.wait_seconds;
|
|
96
|
+
var animate3dInput = external_exports.object({
|
|
97
|
+
animation_action_ids: external_exports.array(external_exports.number().int().min(0).max(696)).min(1).max(10).describe("Up to 10 clips from Meshy's animation library, one GLB each, e.g. 0 for Idle"),
|
|
98
|
+
height_meters: external_exports.number().positive().max(100).optional().describe("The character's height, 1.7 by default"),
|
|
99
|
+
model_url: external_exports.url().describe("The character's GLB, e.g. generate 3d's model_glb"),
|
|
100
|
+
options,
|
|
101
|
+
wait_seconds: waitSeconds
|
|
102
|
+
});
|
|
103
|
+
var imageInput = external_exports.object({
|
|
104
|
+
background: external_exports.enum(["auto", "transparent", "opaque"]).optional().describe(
|
|
105
|
+
"`transparent` leaves no background, for sprites and props; `opaque` always fills one; `auto` lets the model choose. Omit for the model's default"
|
|
106
|
+
),
|
|
107
|
+
image_size: external_exports.enum([
|
|
108
|
+
"auto",
|
|
109
|
+
"square_hd",
|
|
110
|
+
"square",
|
|
111
|
+
"portrait_4_3",
|
|
112
|
+
"portrait_16_9",
|
|
113
|
+
"landscape_4_3",
|
|
114
|
+
"landscape_16_9"
|
|
115
|
+
]).optional().describe("A preset; pass `{width, height}` through options for an exact size"),
|
|
116
|
+
image_urls: external_exports.array(imageUrl).min(1).max(16).optional().describe("Images to edit or combine"),
|
|
117
|
+
num_images: external_exports.number().int().min(1).max(4).optional().describe("How many images to make from the one prompt, 1 to 4; omit for the model's default"),
|
|
118
|
+
options,
|
|
119
|
+
prompt: prompt.describe(
|
|
120
|
+
"What to draw, or with image_urls how to edit or combine them, up to 5,000 characters, e.g. `pixel-art knight sprite, side view`"
|
|
121
|
+
),
|
|
122
|
+
quality: external_exports.enum(["auto", "low", "medium", "high", "xhigh", "max"]).optional().describe(
|
|
123
|
+
"Rendering quality from `low` (quick drafts) to `max`; higher takes longer and may cost more (see generate pricing). `auto` lets the model choose; omit for the model's default"
|
|
124
|
+
),
|
|
125
|
+
wait_seconds: waitSeconds
|
|
126
|
+
});
|
|
127
|
+
var model3dInput = external_exports.object({
|
|
128
|
+
image_url: imageUrl.optional(),
|
|
129
|
+
options,
|
|
130
|
+
pose_mode: external_exports.enum(["a-pose", "t-pose"]).optional().describe("Model a character in this pose, which rigs cleanly in animate-3d"),
|
|
131
|
+
prompt: prompt.max(600).optional().describe("What to model; needed without image_url"),
|
|
132
|
+
target_polycount: external_exports.number().int().min(100).max(3e5).optional().describe(
|
|
133
|
+
"The mesh's polygon budget, 100 to 300,000; the model's default is 30,000. Games suit 5,000 to 15,000 for a prop, 15,000 to 40,000 for a hero character"
|
|
134
|
+
),
|
|
135
|
+
topology: external_exports.enum(["quad", "triangle"]).optional().describe(
|
|
136
|
+
"The mesh's faces: `triangle` (the model's default) keeps detail, `quad` gives smoother surfaces"
|
|
137
|
+
),
|
|
138
|
+
wait_seconds: waitSeconds
|
|
139
|
+
});
|
|
140
|
+
var musicInput = external_exports.object({
|
|
141
|
+
force_instrumental: external_exports.boolean().optional().describe("true makes a track with no vocals; omit to let the prompt decide"),
|
|
142
|
+
music_length_ms: external_exports.number().int().min(3e3).max(6e5).optional().describe(
|
|
143
|
+
"The track's length in milliseconds, 3,000 to 600,000 (3 seconds to 10 minutes), e.g. 60000 for a minute; omit for the model's default"
|
|
144
|
+
),
|
|
145
|
+
options,
|
|
146
|
+
prompt: prompt.describe(
|
|
147
|
+
"The music to compose, up to 5,000 characters: genre, mood, instruments, tempo, structure, e.g. `upbeat chiptune boss battle loop, 140 bpm`"
|
|
148
|
+
),
|
|
149
|
+
wait_seconds: waitSeconds
|
|
150
|
+
});
|
|
151
|
+
var removeBackgroundInput = external_exports.object({
|
|
152
|
+
image_url: imageUrl,
|
|
153
|
+
options,
|
|
154
|
+
prompt: external_exports.string().min(1).max(500).optional().describe("What to keep, e.g. the knight"),
|
|
155
|
+
wait_seconds: waitSeconds
|
|
156
|
+
});
|
|
157
|
+
var soundInput = external_exports.object({
|
|
158
|
+
duration_seconds: external_exports.number().min(0.5).max(30).optional().describe(
|
|
159
|
+
"The sound's length in seconds, 0.5 to 30; omit to let the model fit the length to the sound"
|
|
160
|
+
),
|
|
161
|
+
loop: external_exports.boolean().optional().describe("Make it loop seamlessly"),
|
|
162
|
+
options,
|
|
163
|
+
text: prompt.describe("The sound to make"),
|
|
164
|
+
wait_seconds: waitSeconds
|
|
165
|
+
});
|
|
166
|
+
var speechInput = external_exports.object({
|
|
167
|
+
options,
|
|
168
|
+
text: prompt.describe("What to say"),
|
|
169
|
+
voice: external_exports.string().min(1).optional().describe("A voice name, e.g. Rachel, Aria, Roger"),
|
|
170
|
+
wait_seconds: waitSeconds
|
|
171
|
+
});
|
|
172
|
+
var videoInput = external_exports.object({
|
|
173
|
+
aspect_ratio: external_exports.enum(["auto", "21:9", "16:9", "4:3", "1:1", "3:4", "9:16"]).optional().describe(
|
|
174
|
+
"The frame's width to height, e.g. `16:9` landscape, `9:16` portrait, `1:1` square; `auto` lets the model choose, e.g. from image_url. Omit for the model's default"
|
|
175
|
+
),
|
|
176
|
+
duration: external_exports.enum([
|
|
177
|
+
"auto",
|
|
178
|
+
"4",
|
|
179
|
+
"5",
|
|
180
|
+
"6",
|
|
181
|
+
"7",
|
|
182
|
+
"8",
|
|
183
|
+
"9",
|
|
184
|
+
"10",
|
|
185
|
+
"11",
|
|
186
|
+
"12",
|
|
187
|
+
"13",
|
|
188
|
+
"14",
|
|
189
|
+
"15",
|
|
190
|
+
"16",
|
|
191
|
+
"17",
|
|
192
|
+
"18",
|
|
193
|
+
"19",
|
|
194
|
+
"20",
|
|
195
|
+
"21",
|
|
196
|
+
"22",
|
|
197
|
+
"23",
|
|
198
|
+
"24",
|
|
199
|
+
"25",
|
|
200
|
+
"26",
|
|
201
|
+
"27",
|
|
202
|
+
"28",
|
|
203
|
+
"29",
|
|
204
|
+
"30"
|
|
205
|
+
]).optional().describe("Seconds, 4 to 30"),
|
|
206
|
+
end_image_url: imageUrl.optional().describe("The last frame, with image_url"),
|
|
207
|
+
generate_audio: external_exports.boolean().optional().describe(
|
|
208
|
+
"false makes a silent clip; omit for the model's default, which generates sound with the video"
|
|
209
|
+
),
|
|
210
|
+
image_url: imageUrl.optional().describe("The first frame"),
|
|
211
|
+
options,
|
|
212
|
+
prompt: prompt.optional().describe("What happens; needed without image_url"),
|
|
213
|
+
resolution: external_exports.enum(["480p", "720p", "1080p"]).optional().describe(
|
|
214
|
+
"The clip's resolution; higher takes longer and may cost more (see generate pricing). Omit for the model's default"
|
|
215
|
+
),
|
|
216
|
+
wait_seconds: waitSeconds
|
|
217
|
+
});
|
|
53
218
|
|
|
54
219
|
// src/lib/codex.ts
|
|
55
220
|
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
@@ -92,9 +257,9 @@ var parseValue = (raw) => {
|
|
|
92
257
|
if (raw === "null") {
|
|
93
258
|
return null;
|
|
94
259
|
}
|
|
95
|
-
if (raw.length > 0 && (raw
|
|
260
|
+
if (raw.length > 0 && (raw.startsWith("{") || raw.startsWith("["))) {
|
|
96
261
|
try {
|
|
97
|
-
return
|
|
262
|
+
return parseJson(raw);
|
|
98
263
|
} catch {
|
|
99
264
|
return raw;
|
|
100
265
|
}
|
|
@@ -111,7 +276,7 @@ var parseRunInput = (argv) => {
|
|
|
111
276
|
const out = {};
|
|
112
277
|
for (let i = 0; i < argv.length; i += 1) {
|
|
113
278
|
const arg = argv[i];
|
|
114
|
-
if (
|
|
279
|
+
if (arg === void 0 || arg === "" || !arg.startsWith("--")) {
|
|
115
280
|
continue;
|
|
116
281
|
}
|
|
117
282
|
if (arg === "--") {
|
|
@@ -123,7 +288,7 @@ var parseRunInput = (argv) => {
|
|
|
123
288
|
if (RUN_RESERVED_FLAGS.has(name)) {
|
|
124
289
|
if (name === "--download" && inlineValue === void 0) {
|
|
125
290
|
const next2 = argv[i + 1];
|
|
126
|
-
if (next2 && !next2.startsWith("--")) {
|
|
291
|
+
if (next2 !== void 0 && next2 !== "" && !next2.startsWith("--")) {
|
|
127
292
|
i += 1;
|
|
128
293
|
}
|
|
129
294
|
}
|
|
@@ -212,7 +377,7 @@ var parseDownloadFlag = (argv) => {
|
|
|
212
377
|
let inlineValue;
|
|
213
378
|
for (let i = 0; i < argv.length; i += 1) {
|
|
214
379
|
const arg = argv[i];
|
|
215
|
-
if (
|
|
380
|
+
if (arg === void 0 || arg === "") {
|
|
216
381
|
continue;
|
|
217
382
|
}
|
|
218
383
|
if (arg === "--") {
|
|
@@ -249,7 +414,7 @@ var SUFFIXES = [".fal.media", ".fal.run", ".fal.ai"];
|
|
|
249
414
|
var HTTPS = /^https:\/\/(?<host>[a-z0-9.-]+)(?::\d{1,5})?(?:[/?#]|$)/iu;
|
|
250
415
|
var isMediaUrl = (url) => {
|
|
251
416
|
const host = HTTPS.exec(url)?.groups?.host?.toLowerCase();
|
|
252
|
-
if (
|
|
417
|
+
if (host === void 0 || host === "") {
|
|
253
418
|
return false;
|
|
254
419
|
}
|
|
255
420
|
return HOSTS.has(host) || SUFFIXES.some((suffix) => host.endsWith(suffix));
|
|
@@ -305,7 +470,7 @@ var visit = (value, refs, seen) => {
|
|
|
305
470
|
if (isJsonString(url) && isMediaUrl(url) && !seen.has(url)) {
|
|
306
471
|
const contentType = isJsonString(value.content_type) ? value.content_type.toLowerCase() : null;
|
|
307
472
|
const filenameField = isJsonString(value.file_name) ? sanitizeFilename(value.file_name) : null;
|
|
308
|
-
const ext = filenameField ? path2.extname(filenameField).slice(1).toLowerCase() : extFromUrl(url);
|
|
473
|
+
const ext = filenameField !== null && filenameField !== "" ? path2.extname(filenameField).slice(1).toLowerCase() : extFromUrl(url);
|
|
309
474
|
const looksMedia = contentType === null ? MEDIA_EXT.has(ext) : /^(?:image|video|audio)\//u.test(contentType);
|
|
310
475
|
if (looksMedia) {
|
|
311
476
|
seen.add(url);
|
|
@@ -354,8 +519,8 @@ var mislabelOf = (target, ref) => {
|
|
|
354
519
|
if (!asked) {
|
|
355
520
|
return null;
|
|
356
521
|
}
|
|
357
|
-
const actual = ref.contentType ? EXT_FOR_CONTENT_TYPE.get(ref.contentType) : void 0;
|
|
358
|
-
if (
|
|
522
|
+
const actual = ref.contentType !== null && ref.contentType !== "" ? EXT_FOR_CONTENT_TYPE.get(ref.contentType) : void 0;
|
|
523
|
+
if (actual === void 0 || actual === "" || canonicalExt(actual) === asked) {
|
|
359
524
|
return null;
|
|
360
525
|
}
|
|
361
526
|
return { actual, path: target };
|
|
@@ -379,7 +544,7 @@ var disambiguateTargets = (paths) => {
|
|
|
379
544
|
return `${p.slice(0, p.length - ext.length)}_${n}${ext}`;
|
|
380
545
|
});
|
|
381
546
|
};
|
|
382
|
-
var renderTemplate = (ref, template, index,
|
|
547
|
+
var renderTemplate = (ref, template, index, requestId2) => {
|
|
383
548
|
const ext = (() => {
|
|
384
549
|
const fromName = path2.extname(ref.filename).slice(1);
|
|
385
550
|
if (fromName) {
|
|
@@ -390,14 +555,14 @@ var renderTemplate = (ref, template, index, requestId) => {
|
|
|
390
555
|
const lowerName = ref.filename.toLowerCase();
|
|
391
556
|
const dotExt = `.${ext.toLowerCase()}`;
|
|
392
557
|
const stem = lowerName.endsWith(dotExt) ? ref.filename.slice(0, -dotExt.length) || "output" : ref.filename || "output";
|
|
393
|
-
if (
|
|
394
|
-
if (template && path2.extname(template)) {
|
|
558
|
+
if (template === void 0 || template === "" || !template.includes("{")) {
|
|
559
|
+
if (template !== void 0 && template !== "" && path2.extname(template)) {
|
|
395
560
|
return path2.resolve(template);
|
|
396
561
|
}
|
|
397
562
|
const dir = template ?? process.cwd();
|
|
398
563
|
return path2.resolve(dir, ref.filename || `output-${index}.${ext}`);
|
|
399
564
|
}
|
|
400
|
-
const rendered = template.replaceAll("{index}", String(index)).replaceAll("{name}", stem).replaceAll("{ext}", ext).replaceAll("{request_id}",
|
|
565
|
+
const rendered = template.replaceAll("{index}", String(index)).replaceAll("{name}", stem).replaceAll("{ext}", ext).replaceAll("{request_id}", requestId2);
|
|
401
566
|
return path2.resolve(rendered);
|
|
402
567
|
};
|
|
403
568
|
var downloadMedia = async (opts) => {
|
|
@@ -416,7 +581,11 @@ var downloadMedia = async (opts) => {
|
|
|
416
581
|
try {
|
|
417
582
|
const res = await fetch(ref.url);
|
|
418
583
|
if (!res.ok) {
|
|
419
|
-
return {
|
|
584
|
+
return {
|
|
585
|
+
error: `${res.status} ${res.statusText}`,
|
|
586
|
+
ok: false,
|
|
587
|
+
url: ref.url
|
|
588
|
+
};
|
|
420
589
|
}
|
|
421
590
|
const bytes = new Uint8Array(await res.arrayBuffer());
|
|
422
591
|
writeFileSync(target, bytes);
|
|
@@ -468,7 +637,7 @@ var parseProvider = (raw, from = "--provider") => {
|
|
|
468
637
|
throw new Error(`Unknown provider "${name}" (${from}). Supported: vibedgames, codex.`);
|
|
469
638
|
};
|
|
470
639
|
var CODEX_ENDPOINT = "codex";
|
|
471
|
-
var isOpenAiImageEndpoint = (
|
|
640
|
+
var isOpenAiImageEndpoint = (endpointId2) => /^openai\/gpt-image/iu.test(endpointId2);
|
|
472
641
|
var isLocalReference = (ref) => !/^(?:https?:|data:)/iu.test(ref);
|
|
473
642
|
var chooseProvider = (flag, run) => {
|
|
474
643
|
if (flag !== void 0 && flag.trim() !== "") {
|
|
@@ -527,11 +696,11 @@ var buildSizeHint = (input) => {
|
|
|
527
696
|
return parts.length > 0 ? parts.join(", ") : void 0;
|
|
528
697
|
};
|
|
529
698
|
var parseCodexInput = (input) => {
|
|
530
|
-
let
|
|
699
|
+
let prompt2 = "";
|
|
531
700
|
for (const key of PROMPT_KEYS) {
|
|
532
701
|
const v = input[key];
|
|
533
702
|
if (isJsonString(v) && v.trim().length > 0) {
|
|
534
|
-
|
|
703
|
+
prompt2 = v.trim();
|
|
535
704
|
break;
|
|
536
705
|
}
|
|
537
706
|
}
|
|
@@ -556,7 +725,7 @@ var parseCodexInput = (input) => {
|
|
|
556
725
|
}
|
|
557
726
|
}
|
|
558
727
|
}
|
|
559
|
-
return { count, prompt, referenceCandidates, sizeHint: buildSizeHint(input) };
|
|
728
|
+
return { count, prompt: prompt2, referenceCandidates, sizeHint: buildSizeHint(input) };
|
|
560
729
|
};
|
|
561
730
|
var buildCodexPrompt = (input, filenames, hasReferences) => {
|
|
562
731
|
const n = filenames.length;
|
|
@@ -565,7 +734,7 @@ var buildCodexPrompt = (input, filenames, hasReferences) => {
|
|
|
565
734
|
hasReferences ? `Edit the attached reference image to produce ${noun} using your built-in image generation.` : `Generate ${noun} using your built-in image generation.`,
|
|
566
735
|
`Prompt: ${input.prompt}`
|
|
567
736
|
];
|
|
568
|
-
if (input.sizeHint) {
|
|
737
|
+
if (input.sizeHint !== void 0 && input.sizeHint !== "") {
|
|
569
738
|
lines.push(
|
|
570
739
|
`Size: aim for ${input.sizeHint}. Use the closest size the generator offers and save that as-is \u2014 never resize, crop or ask about it.`
|
|
571
740
|
);
|
|
@@ -576,12 +745,12 @@ var buildCodexPrompt = (input, filenames, hasReferences) => {
|
|
|
576
745
|
);
|
|
577
746
|
return lines.join("\n");
|
|
578
747
|
};
|
|
579
|
-
var renderLocalTarget = (template, index, ext,
|
|
580
|
-
if (
|
|
581
|
-
return path3.resolve(process.cwd(), `codex-image-${
|
|
748
|
+
var renderLocalTarget = (template, index, ext, requestId2, count) => {
|
|
749
|
+
if (template === void 0 || template === "") {
|
|
750
|
+
return path3.resolve(process.cwd(), `codex-image-${requestId2}-${index}.${ext}`);
|
|
582
751
|
}
|
|
583
752
|
if (template.includes("{")) {
|
|
584
|
-
const rendered = template.replaceAll("{index}", String(index)).replaceAll("{ext}", ext).replaceAll("{request_id}",
|
|
753
|
+
const rendered = template.replaceAll("{index}", String(index)).replaceAll("{ext}", ext).replaceAll("{request_id}", requestId2).replaceAll("{name}", "output");
|
|
585
754
|
return path3.resolve(rendered);
|
|
586
755
|
}
|
|
587
756
|
if (path3.extname(template)) {
|
|
@@ -624,37 +793,37 @@ var pickNewest = (paths, limit) => {
|
|
|
624
793
|
try {
|
|
625
794
|
({ mtimeMs } = statSync2(p));
|
|
626
795
|
} catch {
|
|
796
|
+
mtimeMs = 0;
|
|
627
797
|
}
|
|
628
798
|
return { mtimeMs, p };
|
|
629
799
|
});
|
|
630
800
|
return withTime.toSorted((a, b) => b.mtimeMs - a.mtimeMs).slice(0, limit).map((x) => x.p).toSorted();
|
|
631
801
|
};
|
|
632
|
-
var spawnCodex = (bin, args, cwd) =>
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
output: output + err.message
|
|
650
|
-
});
|
|
651
|
-
});
|
|
652
|
-
child.on("close", (code) => {
|
|
653
|
-
resolve({ code: code ?? 1, notFound: false, output });
|
|
802
|
+
var spawnCodex = async (bin, args, cwd) => {
|
|
803
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
804
|
+
const child = (0, import_cross_spawn.default)(bin, args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
805
|
+
let output = "";
|
|
806
|
+
child.stdout?.on("data", (c) => {
|
|
807
|
+
output += c.toString("utf-8");
|
|
808
|
+
process.stderr.write(c);
|
|
809
|
+
});
|
|
810
|
+
child.stderr?.on("data", (c) => {
|
|
811
|
+
output += c.toString("utf-8");
|
|
812
|
+
process.stderr.write(c);
|
|
813
|
+
});
|
|
814
|
+
child.on("error", (err) => {
|
|
815
|
+
resolve({
|
|
816
|
+
code: 1,
|
|
817
|
+
notFound: err.code === "ENOENT",
|
|
818
|
+
output: output + err.message
|
|
654
819
|
});
|
|
655
|
-
})
|
|
656
|
-
)
|
|
657
|
-
|
|
820
|
+
});
|
|
821
|
+
child.on("close", (code) => {
|
|
822
|
+
resolve({ code: code ?? 1, notFound: false, output });
|
|
823
|
+
});
|
|
824
|
+
return await promise;
|
|
825
|
+
};
|
|
826
|
+
var codexExecArgs = (workDir, references, prompt2) => [
|
|
658
827
|
"exec",
|
|
659
828
|
"--skip-git-repo-check",
|
|
660
829
|
"-s",
|
|
@@ -662,10 +831,8 @@ var codexExecArgs = (workDir, references, prompt) => [
|
|
|
662
831
|
"-C",
|
|
663
832
|
workDir,
|
|
664
833
|
...references.flatMap((r) => ["-i", r]),
|
|
665
|
-
// `-i` is variadic (`--image <FILE>...`): without the separator it
|
|
666
|
-
// swallows the prompt as one more image and codex waits on stdin for one.
|
|
667
834
|
"--",
|
|
668
|
-
|
|
835
|
+
prompt2
|
|
669
836
|
];
|
|
670
837
|
var generateImagesWithCodex = async (opts) => {
|
|
671
838
|
const parsed = parseCodexInput(opts.input);
|
|
@@ -682,12 +849,12 @@ var generateImagesWithCodex = async (opts) => {
|
|
|
682
849
|
ignoredReferences.push(candidate);
|
|
683
850
|
}
|
|
684
851
|
}
|
|
685
|
-
const
|
|
852
|
+
const requestId2 = randomBytes(4).toString("hex");
|
|
686
853
|
const workDir = mkdtempSync(path3.join(tmpdir(), "vg-codex-"));
|
|
687
854
|
const filenames = Array.from({ length: parsed.count }, (_, i) => `output-${i}.png`);
|
|
688
|
-
const
|
|
855
|
+
const prompt2 = buildCodexPrompt(parsed, filenames, references.length > 0);
|
|
689
856
|
const bin = resolveSetting("generate.codex-bin").value;
|
|
690
|
-
const args = codexExecArgs(workDir, references,
|
|
857
|
+
const args = codexExecArgs(workDir, references, prompt2);
|
|
691
858
|
const storeDir = path3.join(codexHome(), "generated_images");
|
|
692
859
|
const before = new Set(listImages(storeDir));
|
|
693
860
|
const outcome = await spawnCodex(bin, args, workDir);
|
|
@@ -721,14 +888,14 @@ var generateImagesWithCodex = async (opts) => {
|
|
|
721
888
|
{ output: outcome.output }
|
|
722
889
|
);
|
|
723
890
|
}
|
|
724
|
-
return { ignoredReferences, prompt, rawFiles, requestId };
|
|
891
|
+
return { ignoredReferences, prompt: prompt2, rawFiles, requestId: requestId2 };
|
|
725
892
|
};
|
|
726
|
-
var placeCodexOutputs = (rawFiles, template,
|
|
893
|
+
var placeCodexOutputs = (rawFiles, template, requestId2) => {
|
|
727
894
|
const downloaded = [];
|
|
728
895
|
const failed = [];
|
|
729
896
|
const rendered = rawFiles.map((source, index) => {
|
|
730
897
|
const ext = path3.extname(source).slice(1).toLowerCase() || "png";
|
|
731
|
-
return renderLocalTarget(template, index, ext,
|
|
898
|
+
return renderLocalTarget(template, index, ext, requestId2, rawFiles.length);
|
|
732
899
|
});
|
|
733
900
|
const targets = disambiguateTargets(rendered);
|
|
734
901
|
for (const [index, source] of rawFiles.entries()) {
|
|
@@ -749,6 +916,114 @@ var placeCodexOutputs = (rawFiles, template, requestId) => {
|
|
|
749
916
|
return { downloaded, failed };
|
|
750
917
|
};
|
|
751
918
|
|
|
919
|
+
// ../../packages/contract/src/run-in-order.ts
|
|
920
|
+
var runInOrder = async (items, step) => {
|
|
921
|
+
const iterator = items[Symbol.iterator]();
|
|
922
|
+
const results = [];
|
|
923
|
+
const advance = async () => {
|
|
924
|
+
const current = iterator.next();
|
|
925
|
+
if (current.done === true) {
|
|
926
|
+
return results;
|
|
927
|
+
}
|
|
928
|
+
results.push(await step(current.value, results.length));
|
|
929
|
+
return await advance();
|
|
930
|
+
};
|
|
931
|
+
return await advance();
|
|
932
|
+
};
|
|
933
|
+
|
|
934
|
+
// src/lib/media-flags.ts
|
|
935
|
+
var RESERVED = /* @__PURE__ */ new Set(["options", "wait_seconds"]);
|
|
936
|
+
var REMOTE = /^(?:https?:|data:)/iu;
|
|
937
|
+
var unwrap = (schema) => schema instanceof external_exports.ZodOptional || schema instanceof external_exports.ZodDefault ? unwrap(schema.def.innerType) : schema;
|
|
938
|
+
var kindOf = (schema) => {
|
|
939
|
+
const inner = unwrap(schema);
|
|
940
|
+
if (inner instanceof external_exports.ZodArray) {
|
|
941
|
+
return "array";
|
|
942
|
+
}
|
|
943
|
+
if (inner instanceof external_exports.ZodBoolean) {
|
|
944
|
+
return "boolean";
|
|
945
|
+
}
|
|
946
|
+
if (inner instanceof external_exports.ZodNumber) {
|
|
947
|
+
return "number";
|
|
948
|
+
}
|
|
949
|
+
if (inner instanceof external_exports.ZodRecord) {
|
|
950
|
+
return "record";
|
|
951
|
+
}
|
|
952
|
+
return "string";
|
|
953
|
+
};
|
|
954
|
+
var elementOf = (schema) => {
|
|
955
|
+
const inner = unwrap(schema);
|
|
956
|
+
return inner instanceof external_exports.ZodArray ? kindOf(inner.element) : "string";
|
|
957
|
+
};
|
|
958
|
+
var describe = (schema) => external_exports.globalRegistry.get(schema)?.description ?? external_exports.globalRegistry.get(unwrap(schema))?.description ?? "";
|
|
959
|
+
var isLocalFileField = (key) => key.endsWith("_url") || key.endsWith("_urls");
|
|
960
|
+
var mediaFlagArgs = (fields) => Object.fromEntries(
|
|
961
|
+
Object.entries(fields).filter(([key]) => !RESERVED.has(key)).map(([key, schema]) => {
|
|
962
|
+
const kind = kindOf(schema);
|
|
963
|
+
const local = isLocalFileField(key) ? " A local path is uploaded first." : "";
|
|
964
|
+
const many = kind === "array" ? " Repeat or comma-separate." : "";
|
|
965
|
+
return [
|
|
966
|
+
key,
|
|
967
|
+
{
|
|
968
|
+
description: `${describe(schema)}.${many}${local}`.replaceAll("..", "."),
|
|
969
|
+
type: kind === "boolean" ? "boolean" : "string"
|
|
970
|
+
}
|
|
971
|
+
];
|
|
972
|
+
})
|
|
973
|
+
);
|
|
974
|
+
var coerce = (kind, value) => {
|
|
975
|
+
if (kind === "number") {
|
|
976
|
+
return isJsonString(value) ? Number(value) : value;
|
|
977
|
+
}
|
|
978
|
+
if (kind === "string") {
|
|
979
|
+
return isJsonNumber(value) || value === true || value === false ? String(value) : value;
|
|
980
|
+
}
|
|
981
|
+
return value;
|
|
982
|
+
};
|
|
983
|
+
var listOf = (value) => {
|
|
984
|
+
if (Array.isArray(value)) {
|
|
985
|
+
return value;
|
|
986
|
+
}
|
|
987
|
+
if (isJsonString(value)) {
|
|
988
|
+
return value.split(",").map((part) => part.trim()).filter(Boolean);
|
|
989
|
+
}
|
|
990
|
+
return [value];
|
|
991
|
+
};
|
|
992
|
+
var readMediaInput = async (fields, argv, upload) => {
|
|
993
|
+
const raw = parseRunInput(argv);
|
|
994
|
+
const input = {};
|
|
995
|
+
const resolve = async (key, value) => {
|
|
996
|
+
if (!isJsonString(value) || !isLocalFileField(key)) {
|
|
997
|
+
return value;
|
|
998
|
+
}
|
|
999
|
+
if (REMOTE.test(value)) {
|
|
1000
|
+
return value;
|
|
1001
|
+
}
|
|
1002
|
+
const file = readExplicitLocalFile(value);
|
|
1003
|
+
if (!file) {
|
|
1004
|
+
throw new Error(`--${key}: no file at ${value}, and it is not an http(s) or data: URL.`);
|
|
1005
|
+
}
|
|
1006
|
+
return await upload(file);
|
|
1007
|
+
};
|
|
1008
|
+
await runInOrder(Object.entries(fields), async ([key, schema]) => {
|
|
1009
|
+
const kind = kindOf(schema);
|
|
1010
|
+
const value = kind === "boolean" && raw[`no-${key}`] === true ? false : raw[key];
|
|
1011
|
+
if (value === void 0 || key === "wait_seconds") {
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
if (kind === "array") {
|
|
1015
|
+
const element = elementOf(schema);
|
|
1016
|
+
input[key] = await runInOrder(
|
|
1017
|
+
listOf(value),
|
|
1018
|
+
async (item) => coerce(element, await resolve(key, item))
|
|
1019
|
+
);
|
|
1020
|
+
} else {
|
|
1021
|
+
input[key] = coerce(kind, await resolve(key, value));
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
|
+
return input;
|
|
1025
|
+
};
|
|
1026
|
+
|
|
752
1027
|
// src/lib/media-poll.ts
|
|
753
1028
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
754
1029
|
var POLL_INTERVAL_MS = 2e3;
|
|
@@ -772,44 +1047,36 @@ var pickErrorReason = (value) => {
|
|
|
772
1047
|
return null;
|
|
773
1048
|
};
|
|
774
1049
|
var waitForCompletion = async (client, endpoint_id, request_id, opts) => {
|
|
775
|
-
const
|
|
1050
|
+
const job = { endpoint_id, request_id };
|
|
776
1051
|
const deadline = Date.now() + POLL_TIMEOUT_MS;
|
|
777
|
-
|
|
778
|
-
while (true) {
|
|
1052
|
+
const poll = async (lastStatus) => {
|
|
779
1053
|
if (Date.now() > deadline) {
|
|
780
1054
|
throw new Error(
|
|
781
1055
|
`Job did not complete within ${POLL_TIMEOUT_MS}ms (endpoint=${endpoint_id} request_id=${request_id}). Use \`vg generate status ${endpoint_id} ${request_id} --result\` to check later.`
|
|
782
1056
|
);
|
|
783
1057
|
}
|
|
784
|
-
const raw = await
|
|
785
|
-
method: "GET",
|
|
786
|
-
path: `/${ep}/requests/${request_id}/status`,
|
|
787
|
-
target: "queue"
|
|
788
|
-
});
|
|
1058
|
+
const raw = await client.generate.status({ ...job, action: "status" });
|
|
789
1059
|
const status = isJsonObject(raw) && isJsonString(raw.status) ? raw.status : "UNKNOWN";
|
|
790
1060
|
const upper = status.toUpperCase();
|
|
791
1061
|
if (!opts.quiet && upper !== lastStatus) {
|
|
792
|
-
lastStatus = upper;
|
|
793
1062
|
const queuePos = isJsonObject(raw) && isJsonNumber(raw.queue_position) ? raw.queue_position : null;
|
|
794
1063
|
const tag = queuePos === null ? upper.toLowerCase() : `${upper.toLowerCase()} (queue ${queuePos})`;
|
|
795
1064
|
consola.log(` ${tag}`);
|
|
796
1065
|
}
|
|
797
1066
|
if (upper === "COMPLETED") {
|
|
798
|
-
|
|
1067
|
+
return;
|
|
799
1068
|
}
|
|
800
1069
|
if (upper === "FAILED" || upper === "CANCELLED") {
|
|
801
1070
|
const reason = pickErrorReason(raw);
|
|
802
1071
|
throw new Error(
|
|
803
|
-
reason ? `Job ${upper.toLowerCase()}: ${reason}` : `Job ${upper.toLowerCase()}`
|
|
1072
|
+
reason !== null && reason !== "" ? `Job ${upper.toLowerCase()}: ${reason}` : `Job ${upper.toLowerCase()}`
|
|
804
1073
|
);
|
|
805
1074
|
}
|
|
806
1075
|
await sleep(POLL_INTERVAL_MS);
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
target: "queue"
|
|
812
|
-
});
|
|
1076
|
+
await poll(upper);
|
|
1077
|
+
};
|
|
1078
|
+
await poll(void 0);
|
|
1079
|
+
const result = await client.generate.status({ ...job, action: "result" });
|
|
813
1080
|
return { request_id, result };
|
|
814
1081
|
};
|
|
815
1082
|
|
|
@@ -858,7 +1125,7 @@ var warnMislabeled = (mislabeled) => {
|
|
|
858
1125
|
};
|
|
859
1126
|
var runViaCodex = async (opts) => {
|
|
860
1127
|
const { args, finalInput, downloadFlag, endpoint_id } = opts;
|
|
861
|
-
if (args.async) {
|
|
1128
|
+
if (args.async === true) {
|
|
862
1129
|
consola.error("--async is not supported with --provider codex (Codex runs synchronously).");
|
|
863
1130
|
process.exit(1);
|
|
864
1131
|
}
|
|
@@ -872,18 +1139,18 @@ var runViaCodex = async (opts) => {
|
|
|
872
1139
|
}
|
|
873
1140
|
throw error;
|
|
874
1141
|
}
|
|
875
|
-
const { requestId, rawFiles, prompt, ignoredReferences } = result;
|
|
1142
|
+
const { requestId: requestId2, rawFiles, prompt: prompt2, ignoredReferences } = result;
|
|
876
1143
|
for (const ref of ignoredReferences) {
|
|
877
1144
|
consola.warn(`Ignored non-local reference (codex needs a local file path): ${ref}`);
|
|
878
1145
|
}
|
|
879
1146
|
const template = downloadFlag.mode === "on" ? downloadFlag.template : void 0;
|
|
880
|
-
const { downloaded, failed } = placeCodexOutputs(rawFiles, template,
|
|
1147
|
+
const { downloaded, failed } = placeCodexOutputs(rawFiles, template, requestId2);
|
|
881
1148
|
const payload = {
|
|
882
1149
|
downloaded_files: downloaded,
|
|
883
1150
|
endpoint_id,
|
|
884
1151
|
provider: "codex",
|
|
885
|
-
request_id:
|
|
886
|
-
result: { images: downloaded.map((path4) => ({ path: path4 })), prompt, provider: "codex" },
|
|
1152
|
+
request_id: requestId2,
|
|
1153
|
+
result: { images: downloaded.map((path4) => ({ path: path4 })), prompt: prompt2, provider: "codex" },
|
|
887
1154
|
status: "completed"
|
|
888
1155
|
};
|
|
889
1156
|
if (failed.length > 0) {
|
|
@@ -893,7 +1160,7 @@ var runViaCodex = async (opts) => {
|
|
|
893
1160
|
payload.ignored_references = ignoredReferences;
|
|
894
1161
|
}
|
|
895
1162
|
if (!writeStructured(payload, args)) {
|
|
896
|
-
consola.success(`Codex generated ${downloaded.length} image(s) (${
|
|
1163
|
+
consola.success(`Codex generated ${downloaded.length} image(s) (${requestId2})`);
|
|
897
1164
|
for (const path4 of downloaded) {
|
|
898
1165
|
consola.log(` ${path4}`);
|
|
899
1166
|
}
|
|
@@ -905,9 +1172,9 @@ var runViaCodex = async (opts) => {
|
|
|
905
1172
|
process.exit(1);
|
|
906
1173
|
}
|
|
907
1174
|
};
|
|
908
|
-
var buildRunPayload = (
|
|
1175
|
+
var buildRunPayload = (endpointId2, completed, downloaded) => {
|
|
909
1176
|
const payload = {
|
|
910
|
-
endpoint_id:
|
|
1177
|
+
endpoint_id: endpointId2,
|
|
911
1178
|
request_id: completed.request_id,
|
|
912
1179
|
result: completed.result,
|
|
913
1180
|
status: "completed"
|
|
@@ -935,12 +1202,49 @@ var reportRun = (completed, downloaded) => {
|
|
|
935
1202
|
}
|
|
936
1203
|
warnMislabeled(downloaded.mislabeled);
|
|
937
1204
|
}
|
|
938
|
-
if (
|
|
1205
|
+
if (downloaded === void 0 || downloaded.downloaded.length === void 0 || downloaded.downloaded.length === 0) {
|
|
939
1206
|
for (const url of extractMediaUrls(completed.result)) {
|
|
940
1207
|
consola.log(` ${url}`);
|
|
941
1208
|
}
|
|
942
1209
|
}
|
|
943
1210
|
};
|
|
1211
|
+
var finishRun = async (client, opts) => {
|
|
1212
|
+
const { args, downloadFlag, submission } = opts;
|
|
1213
|
+
const { endpoint_id } = submission;
|
|
1214
|
+
const requestId2 = submission.request_id;
|
|
1215
|
+
if (args.async === true) {
|
|
1216
|
+
const payload2 = {
|
|
1217
|
+
endpoint_id,
|
|
1218
|
+
hint: `Check status: vg generate status ${endpoint_id} ${requestId2}`,
|
|
1219
|
+
request_id: requestId2,
|
|
1220
|
+
status: "submitted"
|
|
1221
|
+
};
|
|
1222
|
+
if (!writeStructured(payload2, args)) {
|
|
1223
|
+
consola.success(`Submitted ${endpoint_id}`);
|
|
1224
|
+
consola.log(` request_id: ${requestId2}`);
|
|
1225
|
+
}
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
const completed = submission.status.toUpperCase() === "COMPLETED" ? { request_id: requestId2, result: submission.result } : await waitForCompletion(client, endpoint_id, requestId2, {
|
|
1229
|
+
quiet: Boolean(args.quiet) || isStructuredOutput(args)
|
|
1230
|
+
});
|
|
1231
|
+
let downloaded;
|
|
1232
|
+
if (downloadFlag.mode === "on") {
|
|
1233
|
+
const refs = extractMediaRefs(completed.result);
|
|
1234
|
+
downloaded = await downloadMedia({
|
|
1235
|
+
refs,
|
|
1236
|
+
requestId: completed.request_id,
|
|
1237
|
+
template: downloadFlag.template
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
const payload = buildRunPayload(endpoint_id, completed, downloaded);
|
|
1241
|
+
if (!writeStructured(payload, args)) {
|
|
1242
|
+
reportRun(completed, downloaded);
|
|
1243
|
+
}
|
|
1244
|
+
if (downloaded && downloaded.failed.length > 0 && downloaded.downloaded.length === 0) {
|
|
1245
|
+
process.exit(1);
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
944
1248
|
var runCommand = defineCommand({
|
|
945
1249
|
args: {
|
|
946
1250
|
async: {
|
|
@@ -973,7 +1277,7 @@ var runCommand = defineCommand({
|
|
|
973
1277
|
endpointId: endpoint_id,
|
|
974
1278
|
input: finalInput
|
|
975
1279
|
});
|
|
976
|
-
if (choice.note) {
|
|
1280
|
+
if (choice.note !== void 0 && choice.note !== "") {
|
|
977
1281
|
process.stderr.write(`${choice.note}
|
|
978
1282
|
`);
|
|
979
1283
|
}
|
|
@@ -982,66 +1286,15 @@ var runCommand = defineCommand({
|
|
|
982
1286
|
return;
|
|
983
1287
|
}
|
|
984
1288
|
const client = createClient();
|
|
985
|
-
const submission = await
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
target: "queue"
|
|
990
|
-
});
|
|
991
|
-
const requestId = isJsonObject(submission) && isJsonString(submission.request_id) ? submission.request_id : null;
|
|
992
|
-
if (!requestId) {
|
|
993
|
-
throw new Error("queue submit did not return a request_id.");
|
|
994
|
-
}
|
|
995
|
-
if (args.async) {
|
|
996
|
-
const payload2 = {
|
|
997
|
-
endpoint_id,
|
|
998
|
-
hint: `Check status: vg generate status ${endpoint_id} ${requestId}`,
|
|
999
|
-
request_id: requestId,
|
|
1000
|
-
status: "submitted"
|
|
1001
|
-
};
|
|
1002
|
-
if (!writeStructured(payload2, args)) {
|
|
1003
|
-
consola.success(`Submitted ${endpoint_id}`);
|
|
1004
|
-
consola.log(` request_id: ${requestId}`);
|
|
1005
|
-
}
|
|
1006
|
-
return;
|
|
1007
|
-
}
|
|
1008
|
-
const completed = await waitForCompletion(client, endpoint_id, requestId, {
|
|
1009
|
-
quiet: Boolean(args.quiet) || isStructuredOutput(args)
|
|
1289
|
+
const submission = await client.generate.run({
|
|
1290
|
+
endpoint_id,
|
|
1291
|
+
input: finalInput,
|
|
1292
|
+
wait_seconds: 0
|
|
1010
1293
|
});
|
|
1011
|
-
|
|
1012
|
-
if (downloadFlag.mode === "on") {
|
|
1013
|
-
const refs = extractMediaRefs(completed.result);
|
|
1014
|
-
downloaded = await downloadMedia({
|
|
1015
|
-
refs,
|
|
1016
|
-
requestId: completed.request_id,
|
|
1017
|
-
template: downloadFlag.template
|
|
1018
|
-
});
|
|
1019
|
-
}
|
|
1020
|
-
const payload = buildRunPayload(endpoint_id, completed, downloaded);
|
|
1021
|
-
if (!writeStructured(payload, args)) {
|
|
1022
|
-
reportRun(completed, downloaded);
|
|
1023
|
-
}
|
|
1024
|
-
if (downloaded && downloaded.failed.length > 0 && downloaded.downloaded.length === 0) {
|
|
1025
|
-
process.exit(1);
|
|
1026
|
-
}
|
|
1294
|
+
await finishRun(client, { args, downloadFlag, submission });
|
|
1027
1295
|
}
|
|
1028
1296
|
});
|
|
1029
|
-
var
|
|
1030
|
-
const statusPath = `/${ep}/requests/${requestId}/status`;
|
|
1031
|
-
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
1032
|
-
await sleep2(1e3);
|
|
1033
|
-
try {
|
|
1034
|
-
const poll = await forwardJson(client, { method: "GET", path: statusPath, target: "queue" });
|
|
1035
|
-
const status = isJsonObject(poll) && isJsonString(poll.status) ? poll.status.toUpperCase() : "";
|
|
1036
|
-
if (["CANCELLED", "FAILED", "COMPLETED"].includes(status)) {
|
|
1037
|
-
break;
|
|
1038
|
-
}
|
|
1039
|
-
} catch {
|
|
1040
|
-
break;
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
};
|
|
1044
|
-
var reportStatus = (action, endpointId, requestId, data, downloaded) => {
|
|
1297
|
+
var reportStatus = (action, endpointId2, requestId2, data, downloaded) => {
|
|
1045
1298
|
if (action === "status") {
|
|
1046
1299
|
const status = isJsonObject(data) && isJsonString(data.status) ? data.status : "?";
|
|
1047
1300
|
consola.log(`status: ${status}`);
|
|
@@ -1050,7 +1303,7 @@ var reportStatus = (action, endpointId, requestId, data, downloaded) => {
|
|
|
1050
1303
|
}
|
|
1051
1304
|
return;
|
|
1052
1305
|
}
|
|
1053
|
-
consola.success(`${action} ${
|
|
1306
|
+
consola.success(`${action} ${endpointId2} ${requestId2}`);
|
|
1054
1307
|
if (downloaded) {
|
|
1055
1308
|
for (const p of downloaded.downloaded) {
|
|
1056
1309
|
consola.log(` ${p}`);
|
|
@@ -1060,7 +1313,7 @@ var reportStatus = (action, endpointId, requestId, data, downloaded) => {
|
|
|
1060
1313
|
}
|
|
1061
1314
|
warnMislabeled(downloaded.mislabeled);
|
|
1062
1315
|
}
|
|
1063
|
-
if (action === "result" &&
|
|
1316
|
+
if (action === "result" && (downloaded === void 0 || downloaded.downloaded.length === void 0 || downloaded.downloaded.length === 0)) {
|
|
1064
1317
|
for (const url of extractMediaUrls(data)) {
|
|
1065
1318
|
consola.log(` ${url}`);
|
|
1066
1319
|
}
|
|
@@ -1084,31 +1337,25 @@ var statusCommand = defineCommand({
|
|
|
1084
1337
|
name: "status"
|
|
1085
1338
|
},
|
|
1086
1339
|
run: async ({ args, rawArgs }) => {
|
|
1087
|
-
if (args.result && args.cancel) {
|
|
1340
|
+
if (args.result === true && args.cancel === true) {
|
|
1088
1341
|
consola.error("Pick one of --result or --cancel.");
|
|
1089
1342
|
process.exit(1);
|
|
1090
1343
|
}
|
|
1091
1344
|
const downloadFlag = parseDownloadFlag(rawArgs);
|
|
1092
|
-
const wantResult = args.result || downloadFlag.mode === "on";
|
|
1345
|
+
const wantResult = args.result === true || downloadFlag.mode === "on";
|
|
1093
1346
|
let action = "status";
|
|
1094
|
-
if (args.cancel) {
|
|
1347
|
+
if (args.cancel === true) {
|
|
1095
1348
|
action = "cancel";
|
|
1096
1349
|
} else if (wantResult) {
|
|
1097
1350
|
action = "result";
|
|
1098
1351
|
}
|
|
1099
|
-
const ep = queueAppId(args.endpoint_id);
|
|
1100
1352
|
const client = createClient();
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
query: action === "status" && args.logs ? { logs: "1" } : void 0,
|
|
1107
|
-
target: "queue"
|
|
1353
|
+
const data = await client.generate.status({
|
|
1354
|
+
action,
|
|
1355
|
+
endpoint_id: args.endpoint_id,
|
|
1356
|
+
logs: Boolean(args.logs),
|
|
1357
|
+
request_id: args.request_id
|
|
1108
1358
|
});
|
|
1109
|
-
if (action === "cancel") {
|
|
1110
|
-
await confirmCancelled(client, ep, args.request_id);
|
|
1111
|
-
}
|
|
1112
1359
|
let downloaded;
|
|
1113
1360
|
if (action === "result" && downloadFlag.mode === "on") {
|
|
1114
1361
|
const refs = extractMediaRefs(data);
|
|
@@ -1142,7 +1389,7 @@ var statusCommand = defineCommand({
|
|
|
1142
1389
|
}
|
|
1143
1390
|
});
|
|
1144
1391
|
var splitList = (value) => {
|
|
1145
|
-
if (
|
|
1392
|
+
if (value === void 0 || value === "") {
|
|
1146
1393
|
return [];
|
|
1147
1394
|
}
|
|
1148
1395
|
return value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
@@ -1153,22 +1400,28 @@ var printModels = (data) => {
|
|
|
1153
1400
|
if (!isJsonObject(m)) {
|
|
1154
1401
|
continue;
|
|
1155
1402
|
}
|
|
1156
|
-
const id =
|
|
1403
|
+
const id = isJsonString(m.endpoint_id) ? m.endpoint_id : "?";
|
|
1157
1404
|
const meta = isJsonObject(m.metadata) ? m.metadata : {};
|
|
1158
|
-
const tags = []
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
}
|
|
1162
|
-
if (meta.status) {
|
|
1163
|
-
tags.push(String(meta.status));
|
|
1164
|
-
}
|
|
1405
|
+
const tags = [meta.category, meta.status].filter(
|
|
1406
|
+
(tag) => isJsonString(tag) && tag !== ""
|
|
1407
|
+
);
|
|
1165
1408
|
consola.log(`${id}${tags.length > 0 ? ` [${tags.join(", ")}]` : ""}`);
|
|
1166
1409
|
}
|
|
1167
|
-
if (isJsonObject(data) && data.next_cursor) {
|
|
1410
|
+
if (isJsonObject(data) && isJsonString(data.next_cursor) && data.next_cursor !== "") {
|
|
1168
1411
|
consola.log(`
|
|
1169
|
-
next_cursor: ${
|
|
1412
|
+
next_cursor: ${data.next_cursor}`);
|
|
1170
1413
|
}
|
|
1171
1414
|
};
|
|
1415
|
+
var MODEL_STATUSES = ["active", "deprecated", "all"];
|
|
1416
|
+
var MODEL_EXPANSIONS = ["openapi-3.0", "enterprise_status"];
|
|
1417
|
+
var pickOne = (allowed, value, flag) => {
|
|
1418
|
+
const found = allowed.find((option) => option === value);
|
|
1419
|
+
if (found === void 0 || found === "") {
|
|
1420
|
+
consola.error(`--${flag} takes ${allowed.join(" | ")}, not "${value}".`);
|
|
1421
|
+
process.exit(1);
|
|
1422
|
+
}
|
|
1423
|
+
return found;
|
|
1424
|
+
};
|
|
1172
1425
|
var modelsCommand = defineCommand({
|
|
1173
1426
|
args: {
|
|
1174
1427
|
category: { description: "Filter by category.", type: "string" },
|
|
@@ -1188,34 +1441,16 @@ var modelsCommand = defineCommand({
|
|
|
1188
1441
|
},
|
|
1189
1442
|
meta: { description: "Search/list available models.", name: "models" },
|
|
1190
1443
|
run: async ({ args }) => {
|
|
1191
|
-
const query = {};
|
|
1192
|
-
if (args.query) {
|
|
1193
|
-
query.q = args.query;
|
|
1194
|
-
}
|
|
1195
|
-
if (args.category) {
|
|
1196
|
-
query.category = args.category;
|
|
1197
|
-
}
|
|
1198
|
-
if (args.status && args.status !== "all") {
|
|
1199
|
-
query.status = args.status;
|
|
1200
|
-
}
|
|
1201
|
-
query.limit = args.limit ?? "20";
|
|
1202
|
-
if (args.cursor) {
|
|
1203
|
-
query.cursor = args.cursor;
|
|
1204
|
-
}
|
|
1205
1444
|
const endpointIds = splitList(args.endpoint_id);
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
method: "GET",
|
|
1216
|
-
path: "/v1/models",
|
|
1217
|
-
query,
|
|
1218
|
-
target: "platform"
|
|
1445
|
+
const expand = splitList(args.expand).map((e) => pickOne(MODEL_EXPANSIONS, e, "expand"));
|
|
1446
|
+
const data = await createClient().generate.models({
|
|
1447
|
+
category: args.category === void 0 || args.category === "" ? void 0 : args.category,
|
|
1448
|
+
cursor: args.cursor === void 0 || args.cursor === "" ? void 0 : args.cursor,
|
|
1449
|
+
endpoint_id: endpointIds.length > 0 ? endpointIds : void 0,
|
|
1450
|
+
expand: expand.length > 0 ? expand : void 0,
|
|
1451
|
+
limit: args.limit !== void 0 && args.limit !== "" ? Number(args.limit) : 20,
|
|
1452
|
+
query: args.query === void 0 || args.query === "" ? void 0 : args.query,
|
|
1453
|
+
status: args.status !== void 0 && args.status !== "" ? pickOne(MODEL_STATUSES, args.status, "status") : void 0
|
|
1219
1454
|
});
|
|
1220
1455
|
if (!writeStructured(data, args)) {
|
|
1221
1456
|
printModels(data);
|
|
@@ -1230,19 +1465,9 @@ var schemaCommand = defineCommand({
|
|
|
1230
1465
|
},
|
|
1231
1466
|
meta: { description: "Fetch a model's input/output schema.", name: "schema" },
|
|
1232
1467
|
run: async ({ args }) => {
|
|
1233
|
-
const
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
query.endpoint_id = args.endpoint_id;
|
|
1237
|
-
query.limit = "1";
|
|
1238
|
-
if (expand.length > 0) {
|
|
1239
|
-
query.expand = expand;
|
|
1240
|
-
}
|
|
1241
|
-
const data = await forwardJson(client, {
|
|
1242
|
-
method: "GET",
|
|
1243
|
-
path: "/v1/models",
|
|
1244
|
-
query,
|
|
1245
|
-
target: "platform"
|
|
1468
|
+
const data = await createClient().generate.schema({
|
|
1469
|
+
endpoint_id: args.endpoint_id,
|
|
1470
|
+
format: args.format === "openapi" ? "openapi" : "compact"
|
|
1246
1471
|
});
|
|
1247
1472
|
if (!writeStructured(data, args)) {
|
|
1248
1473
|
writeJson(data);
|
|
@@ -1256,13 +1481,7 @@ var pricingCommand = defineCommand({
|
|
|
1256
1481
|
},
|
|
1257
1482
|
meta: { description: "Fetch pricing for a model.", name: "pricing" },
|
|
1258
1483
|
run: async ({ args }) => {
|
|
1259
|
-
const
|
|
1260
|
-
const data = await forwardJson(client, {
|
|
1261
|
-
method: "GET",
|
|
1262
|
-
path: "/v1/models/pricing",
|
|
1263
|
-
query: { endpoint_id: args.endpoint_id },
|
|
1264
|
-
target: "platform"
|
|
1265
|
-
});
|
|
1484
|
+
const data = await createClient().generate.pricing({ endpoint_id: args.endpoint_id });
|
|
1266
1485
|
if (!writeStructured(data, args)) {
|
|
1267
1486
|
writeJson(data);
|
|
1268
1487
|
}
|
|
@@ -1275,18 +1494,7 @@ var docsCommand = defineCommand({
|
|
|
1275
1494
|
},
|
|
1276
1495
|
meta: { description: "Search generative-model documentation.", name: "docs" },
|
|
1277
1496
|
run: async ({ args }) => {
|
|
1278
|
-
const
|
|
1279
|
-
const data = await forwardJson(client, {
|
|
1280
|
-
body: {
|
|
1281
|
-
id: 1,
|
|
1282
|
-
jsonrpc: "2.0",
|
|
1283
|
-
method: "tools/call",
|
|
1284
|
-
params: { arguments: { query: args.query }, name: "search_fal" }
|
|
1285
|
-
},
|
|
1286
|
-
method: "POST",
|
|
1287
|
-
path: "/docs/mcp",
|
|
1288
|
-
target: "docs"
|
|
1289
|
-
});
|
|
1497
|
+
const data = await createClient().generate.docs({ query: args.query });
|
|
1290
1498
|
if (!writeStructured(data, args)) {
|
|
1291
1499
|
writeJson(data);
|
|
1292
1500
|
}
|
|
@@ -1315,12 +1523,104 @@ var uploadCommand = defineCommand({
|
|
|
1315
1523
|
}
|
|
1316
1524
|
}
|
|
1317
1525
|
});
|
|
1526
|
+
var mediaCommand = (name, description, schema, submit) => defineCommand({
|
|
1527
|
+
args: {
|
|
1528
|
+
...mediaFlagArgs(schema.shape),
|
|
1529
|
+
async: {
|
|
1530
|
+
description: "Submit to queue and return request_id without waiting.",
|
|
1531
|
+
type: "boolean"
|
|
1532
|
+
},
|
|
1533
|
+
download: {
|
|
1534
|
+
description: "Download media from result. Optional value is a path or template with {index},{name},{ext},{request_id}.",
|
|
1535
|
+
type: "string"
|
|
1536
|
+
},
|
|
1537
|
+
options: {
|
|
1538
|
+
description: "Any other model input as a JSON object; the flags above win.",
|
|
1539
|
+
type: "string"
|
|
1540
|
+
},
|
|
1541
|
+
...outputArgs,
|
|
1542
|
+
quiet: { description: "Suppress progress output while waiting.", type: "boolean" }
|
|
1543
|
+
},
|
|
1544
|
+
meta: { description, name },
|
|
1545
|
+
run: async ({ args, rawArgs }) => {
|
|
1546
|
+
const client = createClient();
|
|
1547
|
+
const downloadFlag = parseDownloadFlag(rawArgs);
|
|
1548
|
+
const input = await readMediaInput(
|
|
1549
|
+
schema.shape,
|
|
1550
|
+
rawArgs,
|
|
1551
|
+
async (file) => await uploadFile(client, file)
|
|
1552
|
+
);
|
|
1553
|
+
const parsed = schema.safeParse({ ...input, wait_seconds: 0 });
|
|
1554
|
+
if (!parsed.success) {
|
|
1555
|
+
for (const issue of parsed.error.issues) {
|
|
1556
|
+
consola.error(`--${issue.path.join(".") || "input"}: ${issue.message}`);
|
|
1557
|
+
}
|
|
1558
|
+
process.exit(1);
|
|
1559
|
+
}
|
|
1560
|
+
await finishRun(client, {
|
|
1561
|
+
args,
|
|
1562
|
+
downloadFlag,
|
|
1563
|
+
submission: await submit(client, parsed.data)
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
});
|
|
1567
|
+
var mediaCommands = {
|
|
1568
|
+
"3d": mediaCommand(
|
|
1569
|
+
"3d",
|
|
1570
|
+
"Generate a textured 3D model (GLB) from a prompt or an image.",
|
|
1571
|
+
model3dInput,
|
|
1572
|
+
async (client, body) => await client.generate.model3d(body)
|
|
1573
|
+
),
|
|
1574
|
+
"animate-3d": mediaCommand(
|
|
1575
|
+
"animate-3d",
|
|
1576
|
+
"Rig a humanoid GLB and bake animation clips onto it.",
|
|
1577
|
+
animate3dInput,
|
|
1578
|
+
async (client, body) => await client.generate.animate3d(body)
|
|
1579
|
+
),
|
|
1580
|
+
image: mediaCommand(
|
|
1581
|
+
"image",
|
|
1582
|
+
"Generate images from a prompt, or edit and combine reference images.",
|
|
1583
|
+
imageInput,
|
|
1584
|
+
async (client, body) => await client.generate.image(body)
|
|
1585
|
+
),
|
|
1586
|
+
music: mediaCommand(
|
|
1587
|
+
"music",
|
|
1588
|
+
"Compose music from a prompt.",
|
|
1589
|
+
musicInput,
|
|
1590
|
+
async (client, body) => await client.generate.music(body)
|
|
1591
|
+
),
|
|
1592
|
+
"remove-background": mediaCommand(
|
|
1593
|
+
"remove-background",
|
|
1594
|
+
"Cut an image's subject out onto a transparent background.",
|
|
1595
|
+
removeBackgroundInput,
|
|
1596
|
+
async (client, body) => await client.generate.removeBackground(body)
|
|
1597
|
+
),
|
|
1598
|
+
sound: mediaCommand(
|
|
1599
|
+
"sound",
|
|
1600
|
+
"Generate a sound effect from a description.",
|
|
1601
|
+
soundInput,
|
|
1602
|
+
async (client, body) => await client.generate.sound(body)
|
|
1603
|
+
),
|
|
1604
|
+
speech: mediaCommand(
|
|
1605
|
+
"speech",
|
|
1606
|
+
"Speak a line of text.",
|
|
1607
|
+
speechInput,
|
|
1608
|
+
async (client, body) => await client.generate.speech(body)
|
|
1609
|
+
),
|
|
1610
|
+
video: mediaCommand(
|
|
1611
|
+
"video",
|
|
1612
|
+
"Generate a video clip from a prompt, or animate an image.",
|
|
1613
|
+
videoInput,
|
|
1614
|
+
async (client, body) => await client.generate.video(body)
|
|
1615
|
+
)
|
|
1616
|
+
};
|
|
1318
1617
|
var generateCommand = defineCommand({
|
|
1319
1618
|
meta: {
|
|
1320
1619
|
description: "Generate, edit, and inspect images, video, and audio.",
|
|
1321
1620
|
name: "generate"
|
|
1322
1621
|
},
|
|
1323
1622
|
subCommands: {
|
|
1623
|
+
...mediaCommands,
|
|
1324
1624
|
docs: docsCommand,
|
|
1325
1625
|
models: modelsCommand,
|
|
1326
1626
|
pricing: pricingCommand,
|