vibedgames 0.6.2 → 0.7.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 +14 -9
- package/dist/THIRD_PARTY_NOTICES.txt +383 -0
- package/dist/chunk-2GL2WJZX.js +172 -0
- package/dist/chunk-2QBYTIMH.js +511 -0
- package/dist/chunk-34AHIMX7.js +466 -0
- package/dist/chunk-6FZPPUQH.js +107 -0
- package/dist/chunk-BVVYDSFJ.js +99 -0
- package/dist/chunk-CAKBGDCY.js +47 -0
- package/dist/chunk-CBKOPVU6.js +1780 -0
- package/dist/chunk-CU7UY5YJ.js +1108 -0
- package/dist/chunk-CZPKN32Z.js +257 -0
- package/dist/chunk-DHEXGWJY.js +111 -0
- package/dist/chunk-FL6IFBUF.js +22 -0
- package/dist/chunk-FLUXEHMU.js +1360 -0
- package/dist/chunk-FNYBZNW2.js +165 -0
- package/dist/chunk-G5FRIFA3.js +22 -0
- package/dist/chunk-HCMTSR7E.js +69 -0
- package/dist/chunk-HKA5LBYW.js +159 -0
- package/dist/chunk-I6O4HIDY.js +1063 -0
- package/dist/chunk-J6PKNPI2.js +26 -0
- package/dist/chunk-JT2AU24K.js +759 -0
- package/dist/chunk-MBXCVCC4.js +478 -0
- package/dist/chunk-MJQSHP3Y.js +415 -0
- package/dist/chunk-MYFLYNPO.js +68 -0
- package/dist/chunk-PEUP4MZR.js +59 -0
- package/dist/chunk-PHEDW6C7.js +32 -0
- package/dist/chunk-PQDBCZRT.js +2017 -0
- package/dist/chunk-QGEITHUP.js +395 -0
- package/dist/chunk-QIVCBUYD.js +273 -0
- package/dist/chunk-RYFO3ZPO.js +71 -0
- package/dist/chunk-RZ4DIJQW.js +68 -0
- package/dist/chunk-SAANBZ25.js +118 -0
- package/dist/chunk-VFFOT7KD.js +2980 -0
- package/dist/chunk-Y552BNFZ.js +41 -0
- package/dist/chunk-Z4Z24FWO.js +39 -0
- package/dist/chunk-ZI6PKVXG.js +64 -0
- package/dist/chunk-ZYCSYJWX.js +87 -0
- package/dist/index.js +67 -60
- package/package.json +13 -16
- package/templates/none/_gitignore +3 -0
- package/templates/none/index.html +29 -0
- package/templates/none/package.json +16 -0
- package/templates/none/src/main.ts +16 -0
- package/templates/none/tsconfig.json +18 -0
- package/templates/none/vite.config.ts +8 -0
- package/templates/phaser/_gitignore +3 -0
- package/templates/phaser/index.html +24 -0
- package/templates/phaser/package.json +19 -0
- package/templates/phaser/src/main.ts +16 -0
- package/templates/phaser/src/scenes/game-scene.ts +65 -0
- package/templates/phaser/tsconfig.json +18 -0
- package/templates/phaser/vite.config.ts +8 -0
- package/templates/react-r3f/_gitignore +3 -0
- package/templates/react-r3f/index.html +24 -0
- package/templates/react-r3f/package.json +27 -0
- package/templates/react-r3f/src/app.tsx +33 -0
- package/templates/react-r3f/src/main.tsx +15 -0
- package/templates/react-r3f/tsconfig.json +19 -0
- package/templates/react-r3f/vite.config.ts +10 -0
- package/templates/threejs/_gitignore +3 -0
- package/templates/threejs/index.html +36 -0
- package/templates/threejs/package.json +20 -0
- package/templates/threejs/src/main.ts +44 -0
- package/templates/threejs/tsconfig.json +18 -0
- package/templates/threejs/vite.config.ts +8 -0
- package/dist/commands/completions.d.ts +0 -7
- package/dist/commands/completions.js +0 -145
- package/dist/commands/credits.d.ts +0 -10
- package/dist/commands/credits.js +0 -136
- package/dist/commands/deploy.d.ts +0 -26
- package/dist/commands/deploy.js +0 -257
- package/dist/commands/factory.d.ts +0 -3
- package/dist/commands/factory.js +0 -73
- package/dist/commands/fork.d.ts +0 -29
- package/dist/commands/fork.js +0 -124
- package/dist/commands/generate.d.ts +0 -1
- package/dist/commands/generate.js +0 -565
- package/dist/commands/init.d.ts +0 -20
- package/dist/commands/init.js +0 -105
- package/dist/commands/login.d.ts +0 -1
- package/dist/commands/login.js +0 -45
- package/dist/commands/logout.d.ts +0 -1
- package/dist/commands/logout.js +0 -13
- package/dist/commands/new.d.ts +0 -26
- package/dist/commands/new.js +0 -318
- package/dist/commands/playtest-run.d.ts +0 -66
- package/dist/commands/playtest-run.js +0 -268
- package/dist/commands/playtest.d.ts +0 -76
- package/dist/commands/playtest.js +0 -372
- package/dist/commands/update.d.ts +0 -13
- package/dist/commands/update.js +0 -82
- package/dist/commands/whoami.d.ts +0 -10
- package/dist/commands/whoami.js +0 -44
- package/dist/index.d.ts +0 -2
- package/dist/lib/api.d.ts +0 -18
- package/dist/lib/api.js +0 -27
- package/dist/lib/archive.d.ts +0 -17
- package/dist/lib/archive.js +0 -228
- package/dist/lib/codex.d.ts +0 -117
- package/dist/lib/codex.js +0 -426
- package/dist/lib/config-file.d.ts +0 -16
- package/dist/lib/config-file.js +0 -54
- package/dist/lib/config.d.ts +0 -11
- package/dist/lib/config.js +0 -54
- package/dist/lib/manifest.d.ts +0 -10
- package/dist/lib/manifest.js +0 -91
- package/dist/lib/media-args.d.ts +0 -30
- package/dist/lib/media-args.js +0 -219
- package/dist/lib/media-download.d.ts +0 -37
- package/dist/lib/media-download.js +0 -268
- package/dist/lib/media-poll.d.ts +0 -18
- package/dist/lib/media-poll.js +0 -86
- package/dist/lib/media-upload.d.ts +0 -12
- package/dist/lib/media-upload.js +0 -52
- package/dist/lib/output.d.ts +0 -68
- package/dist/lib/output.js +0 -102
- package/dist/lib/package-manager.d.ts +0 -25
- package/dist/lib/package-manager.js +0 -77
- package/dist/lib/playtest/agent.d.ts +0 -192
- package/dist/lib/playtest/agent.js +0 -652
- package/dist/lib/playtest/browser.d.ts +0 -109
- package/dist/lib/playtest/browser.js +0 -219
- package/dist/lib/playtest/controls.d.ts +0 -47
- package/dist/lib/playtest/controls.js +0 -218
- package/dist/lib/playtest/errors.d.ts +0 -9
- package/dist/lib/playtest/errors.js +0 -12
- package/dist/lib/playtest/keys.d.ts +0 -41
- package/dist/lib/playtest/keys.js +0 -157
- package/dist/lib/playtest/run.d.ts +0 -195
- package/dist/lib/playtest/run.js +0 -409
- package/dist/lib/run.d.ts +0 -19
- package/dist/lib/run.js +0 -23
- package/dist/lib/strict-args.d.ts +0 -27
- package/dist/lib/strict-args.js +0 -78
- package/dist/lib/types.d.ts +0 -16
- package/dist/lib/types.js +0 -10
- package/dist/lib/update.d.ts +0 -10
- package/dist/lib/update.js +0 -110
- package/dist/lib/upload.d.ts +0 -16
- package/dist/lib/upload.js +0 -41
|
@@ -1,565 +0,0 @@
|
|
|
1
|
-
import { setTimeout as sleep } from "node:timers/promises";
|
|
2
|
-
import { defineCommand } from "citty";
|
|
3
|
-
import { consola } from "consola";
|
|
4
|
-
import { createClient, forwardJson } from "../lib/api.js";
|
|
5
|
-
import { CodexError, generateImagesWithCodex, placeCodexOutputs, chooseProvider, findCodexBinary, } from "../lib/codex.js";
|
|
6
|
-
import { parseDownloadFlag, parseRunInput, readExplicitLocalFile } from "../lib/media-args.js";
|
|
7
|
-
import { downloadMedia, extractMediaRefs } from "../lib/media-download.js";
|
|
8
|
-
import { endpointPath, queueAppId, waitForCompletion } from "../lib/media-poll.js";
|
|
9
|
-
import { uploadFile } from "../lib/media-upload.js";
|
|
10
|
-
import { isJsonOutput, outputArgs, writeJson, writeStructured } from "../lib/output.js";
|
|
11
|
-
import { isJsonNumber, isJsonObject, isJsonString } from "../lib/types.js";
|
|
12
|
-
const buildActionFields = (action, data) => {
|
|
13
|
-
if (action === "result") {
|
|
14
|
-
return { result: data };
|
|
15
|
-
}
|
|
16
|
-
if (action === "status" && isJsonObject(data)) {
|
|
17
|
-
const fields = {};
|
|
18
|
-
if (isJsonString(data.status)) {
|
|
19
|
-
fields.status = data.status;
|
|
20
|
-
}
|
|
21
|
-
if (isJsonNumber(data.queue_position)) {
|
|
22
|
-
fields.queue_position = data.queue_position;
|
|
23
|
-
}
|
|
24
|
-
if (data.logs !== undefined) {
|
|
25
|
-
fields.logs = data.logs;
|
|
26
|
-
}
|
|
27
|
-
return fields;
|
|
28
|
-
}
|
|
29
|
-
return {};
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* True when stdout is carrying data rather than a progress narrative, so
|
|
33
|
-
* spinners and status lines must stay off it. `--field` counts: its whole
|
|
34
|
-
* point is that the output can be captured by a shell verbatim.
|
|
35
|
-
*/
|
|
36
|
-
const isStructuredOutput = (args) => isJsonOutput(args) || Boolean(args.field);
|
|
37
|
-
const extractMediaUrls = (result) => extractMediaRefs(result).map((r) => r.url);
|
|
38
|
-
// ---- run --------------------------------------------------------------------
|
|
39
|
-
/**
|
|
40
|
-
* A downloaded file whose extension does not match the bytes inside it.
|
|
41
|
-
*
|
|
42
|
-
* The model, not the CLI, picks the output format, so asking for `board.png`
|
|
43
|
-
* from an endpoint that returns JPEG produces a `.png` full of JPEG. The next
|
|
44
|
-
* tool in the pipeline reports "bad signature" with no hint of where it came
|
|
45
|
-
* from, so name it here while the cause is still on screen.
|
|
46
|
-
*/
|
|
47
|
-
const warnMislabeled = (mislabeled) => {
|
|
48
|
-
for (const m of mislabeled) {
|
|
49
|
-
consola.warn(` ${m.path} holds ${m.actual.toUpperCase()} data, not what its extension says`);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
// Delegate image generation to the local Codex CLI instead of the
|
|
53
|
-
// vibedgames model runner. Produces local files directly (Codex writes
|
|
54
|
-
// to disk), so there's no queue, no request polling, and no vibedgames
|
|
55
|
-
// backend call. The `--download` template still controls output naming;
|
|
56
|
-
// without it we default to cwd.
|
|
57
|
-
const runViaCodex = async (opts) => {
|
|
58
|
-
const { args, finalInput, downloadFlag, endpoint_id } = opts;
|
|
59
|
-
if (args.async) {
|
|
60
|
-
consola.error("--async is not supported with --provider codex (Codex runs synchronously).");
|
|
61
|
-
process.exit(1);
|
|
62
|
-
}
|
|
63
|
-
let result;
|
|
64
|
-
try {
|
|
65
|
-
result = await generateImagesWithCodex({ input: finalInput });
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
if (error instanceof CodexError) {
|
|
69
|
-
// Expected, user-facing failure (codex missing / declined / exec
|
|
70
|
-
// error). Present it cleanly with a deterministic exit code instead
|
|
71
|
-
// of an unhandled stack trace — consola.error goes to stderr, so it
|
|
72
|
-
// never corrupts a --json consumer's stdout. Codex's own output
|
|
73
|
-
// already streamed straight to stderr as it ran (and the message
|
|
74
|
-
// already names the vibedgames fallback), so we don't reprint here.
|
|
75
|
-
consola.error(error.message);
|
|
76
|
-
process.exit(1);
|
|
77
|
-
}
|
|
78
|
-
throw error;
|
|
79
|
-
}
|
|
80
|
-
const { requestId, rawFiles, prompt, ignoredReferences } = result;
|
|
81
|
-
// Warn about dropped (non-local) references on stderr regardless of
|
|
82
|
-
// --json/--quiet — stderr never corrupts the JSON payload — and also
|
|
83
|
-
// record them in the JSON so an agent parsing stdout sees the signal.
|
|
84
|
-
for (const ref of ignoredReferences) {
|
|
85
|
-
consola.warn(`Ignored non-local reference (codex needs a local file path): ${ref}`);
|
|
86
|
-
}
|
|
87
|
-
const template = downloadFlag.mode === "on" ? downloadFlag.template : undefined;
|
|
88
|
-
const { downloaded, failed } = placeCodexOutputs(rawFiles, template, requestId);
|
|
89
|
-
const payload = {
|
|
90
|
-
downloaded_files: downloaded,
|
|
91
|
-
endpoint_id,
|
|
92
|
-
provider: "codex",
|
|
93
|
-
request_id: requestId,
|
|
94
|
-
result: { images: downloaded.map((path) => ({ path })), prompt, provider: "codex" },
|
|
95
|
-
status: "completed",
|
|
96
|
-
};
|
|
97
|
-
if (failed.length > 0) {
|
|
98
|
-
payload.download_failures = failed;
|
|
99
|
-
}
|
|
100
|
-
if (ignoredReferences.length > 0) {
|
|
101
|
-
payload.ignored_references = ignoredReferences;
|
|
102
|
-
}
|
|
103
|
-
if (!writeStructured(payload, args)) {
|
|
104
|
-
consola.success(`Codex generated ${downloaded.length} image(s) (${requestId})`);
|
|
105
|
-
for (const path of downloaded) {
|
|
106
|
-
consola.log(` ${path}`);
|
|
107
|
-
}
|
|
108
|
-
for (const f of failed) {
|
|
109
|
-
consola.warn(` failed: ${f.url} (${f.error})`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (failed.length > 0 && downloaded.length === 0) {
|
|
113
|
-
process.exit(1);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
const buildRunPayload = (endpointId, completed, downloaded) => {
|
|
117
|
-
const payload = {
|
|
118
|
-
endpoint_id: endpointId,
|
|
119
|
-
request_id: completed.request_id,
|
|
120
|
-
result: completed.result,
|
|
121
|
-
status: "completed",
|
|
122
|
-
};
|
|
123
|
-
if (!downloaded) {
|
|
124
|
-
return payload;
|
|
125
|
-
}
|
|
126
|
-
payload.downloaded_files = downloaded.downloaded;
|
|
127
|
-
if (downloaded.failed.length > 0) {
|
|
128
|
-
payload.download_failures = downloaded.failed;
|
|
129
|
-
}
|
|
130
|
-
if (downloaded.mislabeled.length > 0) {
|
|
131
|
-
payload.download_format_mismatches = downloaded.mislabeled;
|
|
132
|
-
}
|
|
133
|
-
return payload;
|
|
134
|
-
};
|
|
135
|
-
const reportRun = (completed, downloaded) => {
|
|
136
|
-
consola.success(`Run completed (${completed.request_id})`);
|
|
137
|
-
if (downloaded) {
|
|
138
|
-
for (const file of downloaded.downloaded) {
|
|
139
|
-
consola.log(` ${file}`);
|
|
140
|
-
}
|
|
141
|
-
for (const f of downloaded.failed) {
|
|
142
|
-
consola.warn(` failed: ${f.url} (${f.error})`);
|
|
143
|
-
}
|
|
144
|
-
warnMislabeled(downloaded.mislabeled);
|
|
145
|
-
}
|
|
146
|
-
if (!downloaded?.downloaded.length) {
|
|
147
|
-
for (const url of extractMediaUrls(completed.result)) {
|
|
148
|
-
consola.log(` ${url}`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
const runCommand = defineCommand({
|
|
153
|
-
args: {
|
|
154
|
-
async: {
|
|
155
|
-
description: "Submit to queue and return request_id without waiting.",
|
|
156
|
-
type: "boolean",
|
|
157
|
-
},
|
|
158
|
-
download: {
|
|
159
|
-
description: "Download media from result. Optional value is a path or template with {index},{name},{ext},{request_id}.",
|
|
160
|
-
type: "string",
|
|
161
|
-
},
|
|
162
|
-
endpoint_id: {
|
|
163
|
-
description: "Model endpoint ID, e.g. fal-ai/flux/dev.",
|
|
164
|
-
required: true,
|
|
165
|
-
type: "positional",
|
|
166
|
-
},
|
|
167
|
-
provider: {
|
|
168
|
-
description: "Execution backend: vibedgames or codex (delegate image generation to the local Codex CLI / your Codex plan). Unset, OpenAI image models (openai/gpt-image-*) use codex when it is installed; everything else uses vibedgames. Also settable via VG_GENERATE_PROVIDER.",
|
|
169
|
-
type: "string",
|
|
170
|
-
},
|
|
171
|
-
...outputArgs,
|
|
172
|
-
quiet: { description: "Suppress progress output during sync runs.", type: "boolean" },
|
|
173
|
-
},
|
|
174
|
-
meta: { description: "Run a model (waits for result by default).", name: "run" },
|
|
175
|
-
run: async ({ args, rawArgs }) => {
|
|
176
|
-
const downloadFlag = parseDownloadFlag(rawArgs);
|
|
177
|
-
// parseRunInput already skips non-`--` tokens, so the positional
|
|
178
|
-
// endpoint_id and any subcommand name in argv are no-ops.
|
|
179
|
-
const finalInput = parseRunInput(rawArgs);
|
|
180
|
-
const { endpoint_id } = args;
|
|
181
|
-
const choice = chooseProvider(args.provider, {
|
|
182
|
-
async: Boolean(args.async),
|
|
183
|
-
codexInstalled: findCodexBinary() !== null,
|
|
184
|
-
endpointId: endpoint_id,
|
|
185
|
-
input: finalInput,
|
|
186
|
-
});
|
|
187
|
-
if (choice.provider === "codex") {
|
|
188
|
-
if (choice.auto) {
|
|
189
|
-
// stderr directly: consola.info targets stdout, which a --json
|
|
190
|
-
// consumer owns
|
|
191
|
-
process.stderr.write(`Running ${endpoint_id} through your local codex CLI (OpenAI image model, your own plan). ` +
|
|
192
|
-
`Pass --provider vibedgames to run it on vibedgames instead.\n`);
|
|
193
|
-
}
|
|
194
|
-
await runViaCodex({ args, downloadFlag, endpoint_id, finalInput });
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
const client = createClient();
|
|
198
|
-
const submission = await forwardJson(client, {
|
|
199
|
-
body: finalInput,
|
|
200
|
-
method: "POST",
|
|
201
|
-
path: `/${endpointPath(endpoint_id)}`,
|
|
202
|
-
target: "queue",
|
|
203
|
-
});
|
|
204
|
-
const requestId = isJsonObject(submission) && isJsonString(submission.request_id)
|
|
205
|
-
? submission.request_id
|
|
206
|
-
: null;
|
|
207
|
-
if (!requestId) {
|
|
208
|
-
throw new Error("queue submit did not return a request_id.");
|
|
209
|
-
}
|
|
210
|
-
if (args.async) {
|
|
211
|
-
const payload = {
|
|
212
|
-
endpoint_id,
|
|
213
|
-
hint: `Check status: vg generate status ${endpoint_id} ${requestId}`,
|
|
214
|
-
request_id: requestId,
|
|
215
|
-
status: "submitted",
|
|
216
|
-
};
|
|
217
|
-
if (!writeStructured(payload, args)) {
|
|
218
|
-
consola.success(`Submitted ${endpoint_id}`);
|
|
219
|
-
consola.log(` request_id: ${requestId}`);
|
|
220
|
-
}
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
const completed = await waitForCompletion(client, endpoint_id, requestId, {
|
|
224
|
-
quiet: Boolean(args.quiet) || isStructuredOutput(args),
|
|
225
|
-
});
|
|
226
|
-
let downloaded;
|
|
227
|
-
if (downloadFlag.mode === "on") {
|
|
228
|
-
const refs = extractMediaRefs(completed.result);
|
|
229
|
-
downloaded = await downloadMedia({
|
|
230
|
-
refs,
|
|
231
|
-
requestId: completed.request_id,
|
|
232
|
-
template: downloadFlag.template,
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
const payload = buildRunPayload(endpoint_id, completed, downloaded);
|
|
236
|
-
if (!writeStructured(payload, args)) {
|
|
237
|
-
reportRun(completed, downloaded);
|
|
238
|
-
}
|
|
239
|
-
if (downloaded && downloaded.failed.length > 0 && downloaded.downloaded.length === 0) {
|
|
240
|
-
process.exit(1);
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
});
|
|
244
|
-
// ---- status -----------------------------------------------------------------
|
|
245
|
-
/** Cancellation is confirmed asynchronously, and the platform refunds a
|
|
246
|
-
* cancelled job's credit hold when a status poll reports the terminal state —
|
|
247
|
-
* so confirm with a few polls instead of leaving the refund to whenever the
|
|
248
|
-
* user next checks. Best-effort: a miss just defers it. */
|
|
249
|
-
const confirmCancelled = async (client, ep, requestId) => {
|
|
250
|
-
const statusPath = `/${ep}/requests/${requestId}/status`;
|
|
251
|
-
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
252
|
-
await sleep(1000);
|
|
253
|
-
try {
|
|
254
|
-
const poll = await forwardJson(client, { method: "GET", path: statusPath, target: "queue" });
|
|
255
|
-
const status = isJsonObject(poll) && isJsonString(poll.status) ? poll.status.toUpperCase() : "";
|
|
256
|
-
if (["CANCELLED", "FAILED", "COMPLETED"].includes(status)) {
|
|
257
|
-
break;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
catch {
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
const reportStatus = (action, endpointId, requestId, data, downloaded) => {
|
|
266
|
-
if (action === "status") {
|
|
267
|
-
const status = isJsonObject(data) && isJsonString(data.status) ? data.status : "?";
|
|
268
|
-
consola.log(`status: ${status}`);
|
|
269
|
-
if (isJsonObject(data) && isJsonNumber(data.queue_position)) {
|
|
270
|
-
consola.log(`queue_position: ${data.queue_position}`);
|
|
271
|
-
}
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
consola.success(`${action} ${endpointId} ${requestId}`);
|
|
275
|
-
if (downloaded) {
|
|
276
|
-
for (const p of downloaded.downloaded) {
|
|
277
|
-
consola.log(` ${p}`);
|
|
278
|
-
}
|
|
279
|
-
for (const f of downloaded.failed) {
|
|
280
|
-
consola.warn(` failed: ${f.url} (${f.error})`);
|
|
281
|
-
}
|
|
282
|
-
warnMislabeled(downloaded.mislabeled);
|
|
283
|
-
}
|
|
284
|
-
if (action === "result" && !downloaded?.downloaded.length) {
|
|
285
|
-
for (const url of extractMediaUrls(data)) {
|
|
286
|
-
consola.log(` ${url}`);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
const statusCommand = defineCommand({
|
|
291
|
-
args: {
|
|
292
|
-
cancel: { description: "Cancel the job.", type: "boolean" },
|
|
293
|
-
download: {
|
|
294
|
-
description: "Download media from the result (implies --result).",
|
|
295
|
-
type: "string",
|
|
296
|
-
},
|
|
297
|
-
endpoint_id: { required: true, type: "positional" },
|
|
298
|
-
logs: { description: "Include logs.", type: "boolean" },
|
|
299
|
-
request_id: { required: true, type: "positional" },
|
|
300
|
-
result: { description: "Fetch the completed result.", type: "boolean" },
|
|
301
|
-
...outputArgs,
|
|
302
|
-
},
|
|
303
|
-
meta: {
|
|
304
|
-
description: "Check job status, fetch result, or cancel.",
|
|
305
|
-
name: "status",
|
|
306
|
-
},
|
|
307
|
-
run: async ({ args, rawArgs }) => {
|
|
308
|
-
if (args.result && args.cancel) {
|
|
309
|
-
consola.error("Pick one of --result or --cancel.");
|
|
310
|
-
process.exit(1);
|
|
311
|
-
}
|
|
312
|
-
const downloadFlag = parseDownloadFlag(rawArgs);
|
|
313
|
-
const wantResult = args.result || downloadFlag.mode === "on";
|
|
314
|
-
let action = "status";
|
|
315
|
-
if (args.cancel) {
|
|
316
|
-
action = "cancel";
|
|
317
|
-
}
|
|
318
|
-
else if (wantResult) {
|
|
319
|
-
action = "result";
|
|
320
|
-
}
|
|
321
|
-
const ep = queueAppId(args.endpoint_id);
|
|
322
|
-
const client = createClient();
|
|
323
|
-
const suffixes = { cancel: "/cancel", result: "", status: "/status" };
|
|
324
|
-
const path = `/${ep}/requests/${args.request_id}${suffixes[action]}`;
|
|
325
|
-
const data = await forwardJson(client, {
|
|
326
|
-
method: action === "cancel" ? "PUT" : "GET",
|
|
327
|
-
path,
|
|
328
|
-
query: action === "status" && args.logs ? { logs: "1" } : undefined,
|
|
329
|
-
target: "queue",
|
|
330
|
-
});
|
|
331
|
-
// Cancellation is confirmed asynchronously, and the platform refunds a
|
|
332
|
-
// cancelled job's credit hold when a status poll reports the terminal
|
|
333
|
-
// state — so confirm with a few polls instead of leaving the refund to
|
|
334
|
-
// whenever the user next checks. Best-effort: a miss just defers it.
|
|
335
|
-
if (action === "cancel") {
|
|
336
|
-
await confirmCancelled(client, ep, args.request_id);
|
|
337
|
-
}
|
|
338
|
-
let downloaded;
|
|
339
|
-
if (action === "result" && downloadFlag.mode === "on") {
|
|
340
|
-
const refs = extractMediaRefs(data);
|
|
341
|
-
downloaded = await downloadMedia({
|
|
342
|
-
refs,
|
|
343
|
-
requestId: args.request_id,
|
|
344
|
-
template: downloadFlag.template,
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
const payload = {
|
|
348
|
-
action,
|
|
349
|
-
endpoint_id: args.endpoint_id,
|
|
350
|
-
request_id: args.request_id,
|
|
351
|
-
...buildActionFields(action, data),
|
|
352
|
-
};
|
|
353
|
-
if (downloaded) {
|
|
354
|
-
payload.downloaded_files = downloaded.downloaded;
|
|
355
|
-
if (downloaded.failed.length > 0) {
|
|
356
|
-
payload.download_failures = downloaded.failed;
|
|
357
|
-
}
|
|
358
|
-
if (downloaded.mislabeled.length > 0) {
|
|
359
|
-
payload.download_format_mismatches = downloaded.mislabeled;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
if (!writeStructured(payload, args)) {
|
|
363
|
-
reportStatus(action, args.endpoint_id, args.request_id, data, downloaded);
|
|
364
|
-
}
|
|
365
|
-
if (downloaded && downloaded.failed.length > 0 && downloaded.downloaded.length === 0) {
|
|
366
|
-
process.exit(1);
|
|
367
|
-
}
|
|
368
|
-
},
|
|
369
|
-
});
|
|
370
|
-
// ---- models -----------------------------------------------------------------
|
|
371
|
-
const splitList = (value) => {
|
|
372
|
-
if (!value) {
|
|
373
|
-
return [];
|
|
374
|
-
}
|
|
375
|
-
return value
|
|
376
|
-
.split(",")
|
|
377
|
-
.map((s) => s.trim())
|
|
378
|
-
.filter(Boolean);
|
|
379
|
-
};
|
|
380
|
-
const printModels = (data) => {
|
|
381
|
-
const models = isJsonObject(data) && Array.isArray(data.models) ? data.models : [];
|
|
382
|
-
for (const m of models) {
|
|
383
|
-
if (!isJsonObject(m)) {
|
|
384
|
-
continue;
|
|
385
|
-
}
|
|
386
|
-
const id = String(m.endpoint_id ?? "?");
|
|
387
|
-
const meta = isJsonObject(m.metadata) ? m.metadata : {};
|
|
388
|
-
const tags = [];
|
|
389
|
-
if (meta.category) {
|
|
390
|
-
tags.push(String(meta.category));
|
|
391
|
-
}
|
|
392
|
-
if (meta.status) {
|
|
393
|
-
tags.push(String(meta.status));
|
|
394
|
-
}
|
|
395
|
-
consola.log(`${id}${tags.length > 0 ? ` [${tags.join(", ")}]` : ""}`);
|
|
396
|
-
}
|
|
397
|
-
if (isJsonObject(data) && data.next_cursor) {
|
|
398
|
-
consola.log(`\nnext_cursor: ${String(data.next_cursor)}`);
|
|
399
|
-
}
|
|
400
|
-
};
|
|
401
|
-
const modelsCommand = defineCommand({
|
|
402
|
-
args: {
|
|
403
|
-
category: { description: "Filter by category.", type: "string" },
|
|
404
|
-
cursor: { description: "Pagination cursor from a prior response.", type: "string" },
|
|
405
|
-
endpoint_id: {
|
|
406
|
-
description: "Specific endpoint id(s); repeat or comma-separate.",
|
|
407
|
-
type: "string",
|
|
408
|
-
},
|
|
409
|
-
expand: {
|
|
410
|
-
description: "Expand fields: openapi-3.0, enterprise_status. Repeat or comma-separate.",
|
|
411
|
-
type: "string",
|
|
412
|
-
},
|
|
413
|
-
limit: { description: "Max results (default 20).", type: "string" },
|
|
414
|
-
query: { description: "Search query.", required: false, type: "positional" },
|
|
415
|
-
status: { description: "active (default) | deprecated | all", type: "string" },
|
|
416
|
-
...outputArgs,
|
|
417
|
-
},
|
|
418
|
-
meta: { description: "Search/list available models.", name: "models" },
|
|
419
|
-
run: async ({ args }) => {
|
|
420
|
-
const query = {};
|
|
421
|
-
if (args.query) {
|
|
422
|
-
query.q = args.query;
|
|
423
|
-
}
|
|
424
|
-
if (args.category) {
|
|
425
|
-
query.category = args.category;
|
|
426
|
-
}
|
|
427
|
-
if (args.status && args.status !== "all") {
|
|
428
|
-
query.status = args.status;
|
|
429
|
-
}
|
|
430
|
-
query.limit = args.limit ?? "20";
|
|
431
|
-
if (args.cursor) {
|
|
432
|
-
query.cursor = args.cursor;
|
|
433
|
-
}
|
|
434
|
-
const endpointIds = splitList(args.endpoint_id);
|
|
435
|
-
if (endpointIds.length > 0) {
|
|
436
|
-
query.endpoint_id = endpointIds;
|
|
437
|
-
}
|
|
438
|
-
const expand = splitList(args.expand);
|
|
439
|
-
if (expand.length > 0) {
|
|
440
|
-
query.expand = expand;
|
|
441
|
-
}
|
|
442
|
-
const client = createClient();
|
|
443
|
-
const data = await forwardJson(client, {
|
|
444
|
-
method: "GET",
|
|
445
|
-
path: "/v1/models",
|
|
446
|
-
query,
|
|
447
|
-
target: "platform",
|
|
448
|
-
});
|
|
449
|
-
if (!writeStructured(data, args)) {
|
|
450
|
-
printModels(data);
|
|
451
|
-
}
|
|
452
|
-
},
|
|
453
|
-
});
|
|
454
|
-
// ---- schema -----------------------------------------------------------------
|
|
455
|
-
const schemaCommand = defineCommand({
|
|
456
|
-
args: {
|
|
457
|
-
endpoint_id: { required: true, type: "positional" },
|
|
458
|
-
format: { description: "compact (default) | openapi", type: "string" },
|
|
459
|
-
...outputArgs,
|
|
460
|
-
},
|
|
461
|
-
meta: { description: "Fetch a model's input/output schema.", name: "schema" },
|
|
462
|
-
run: async ({ args }) => {
|
|
463
|
-
const expand = args.format === "openapi" ? ["openapi-3.0"] : [];
|
|
464
|
-
const client = createClient();
|
|
465
|
-
const query = {};
|
|
466
|
-
query.endpoint_id = args.endpoint_id;
|
|
467
|
-
query.limit = "1";
|
|
468
|
-
if (expand.length > 0) {
|
|
469
|
-
query.expand = expand;
|
|
470
|
-
}
|
|
471
|
-
const data = await forwardJson(client, {
|
|
472
|
-
method: "GET",
|
|
473
|
-
path: "/v1/models",
|
|
474
|
-
query,
|
|
475
|
-
target: "platform",
|
|
476
|
-
});
|
|
477
|
-
if (!writeStructured(data, args)) {
|
|
478
|
-
writeJson(data);
|
|
479
|
-
}
|
|
480
|
-
},
|
|
481
|
-
});
|
|
482
|
-
// ---- pricing ----------------------------------------------------------------
|
|
483
|
-
const pricingCommand = defineCommand({
|
|
484
|
-
args: {
|
|
485
|
-
endpoint_id: { required: true, type: "positional" },
|
|
486
|
-
...outputArgs,
|
|
487
|
-
},
|
|
488
|
-
meta: { description: "Fetch pricing for a model.", name: "pricing" },
|
|
489
|
-
run: async ({ args }) => {
|
|
490
|
-
const client = createClient();
|
|
491
|
-
const data = await forwardJson(client, {
|
|
492
|
-
method: "GET",
|
|
493
|
-
path: "/v1/models/pricing",
|
|
494
|
-
query: { endpoint_id: args.endpoint_id },
|
|
495
|
-
target: "platform",
|
|
496
|
-
});
|
|
497
|
-
if (!writeStructured(data, args)) {
|
|
498
|
-
writeJson(data);
|
|
499
|
-
}
|
|
500
|
-
},
|
|
501
|
-
});
|
|
502
|
-
// ---- docs -------------------------------------------------------------------
|
|
503
|
-
const docsCommand = defineCommand({
|
|
504
|
-
args: {
|
|
505
|
-
query: { required: true, type: "positional" },
|
|
506
|
-
...outputArgs,
|
|
507
|
-
},
|
|
508
|
-
meta: { description: "Search generative-model documentation.", name: "docs" },
|
|
509
|
-
run: async ({ args }) => {
|
|
510
|
-
const client = createClient();
|
|
511
|
-
const data = await forwardJson(client, {
|
|
512
|
-
body: {
|
|
513
|
-
id: 1,
|
|
514
|
-
jsonrpc: "2.0",
|
|
515
|
-
method: "tools/call",
|
|
516
|
-
params: { arguments: { query: args.query }, name: "search_fal" },
|
|
517
|
-
},
|
|
518
|
-
method: "POST",
|
|
519
|
-
path: "/docs/mcp",
|
|
520
|
-
target: "docs",
|
|
521
|
-
});
|
|
522
|
-
if (!writeStructured(data, args)) {
|
|
523
|
-
writeJson(data);
|
|
524
|
-
}
|
|
525
|
-
},
|
|
526
|
-
});
|
|
527
|
-
// ---- upload -----------------------------------------------------------------
|
|
528
|
-
const uploadCommand = defineCommand({
|
|
529
|
-
args: {
|
|
530
|
-
path: { required: true, type: "positional" },
|
|
531
|
-
...outputArgs,
|
|
532
|
-
},
|
|
533
|
-
meta: {
|
|
534
|
-
description: "Upload a local file. Returns a stable hosted URL.",
|
|
535
|
-
name: "upload",
|
|
536
|
-
},
|
|
537
|
-
run: async ({ args }) => {
|
|
538
|
-
const stat = readExplicitLocalFile(args.path);
|
|
539
|
-
if (!stat) {
|
|
540
|
-
consola.error(`File not found: ${args.path}`);
|
|
541
|
-
process.exit(1);
|
|
542
|
-
}
|
|
543
|
-
const client = createClient();
|
|
544
|
-
const url = await uploadFile(client, stat);
|
|
545
|
-
if (!writeStructured({ url }, args)) {
|
|
546
|
-
process.stdout.write(`${url}\n`);
|
|
547
|
-
}
|
|
548
|
-
},
|
|
549
|
-
});
|
|
550
|
-
// ---- top-level --------------------------------------------------------------
|
|
551
|
-
export const generateCommand = defineCommand({
|
|
552
|
-
meta: {
|
|
553
|
-
description: "Generate, edit, and inspect images, video, and audio.",
|
|
554
|
-
name: "generate",
|
|
555
|
-
},
|
|
556
|
-
subCommands: {
|
|
557
|
-
docs: docsCommand,
|
|
558
|
-
models: modelsCommand,
|
|
559
|
-
pricing: pricingCommand,
|
|
560
|
-
run: runCommand,
|
|
561
|
-
schema: schemaCommand,
|
|
562
|
-
status: statusCommand,
|
|
563
|
-
upload: uploadCommand,
|
|
564
|
-
},
|
|
565
|
-
});
|
package/dist/commands/init.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare const initCommand: import("citty").CommandDef<{
|
|
2
|
-
readonly agent: {
|
|
3
|
-
readonly alias: "a";
|
|
4
|
-
readonly default: "claude-code,cursor,codex";
|
|
5
|
-
readonly description: "Comma-separated target agents. Default installs for Claude Code, Cursor, and Codex (symlinked from a shared .agents/skills/ dir). Pass '*' for every supported agent.";
|
|
6
|
-
readonly type: "string";
|
|
7
|
-
};
|
|
8
|
-
readonly global: {
|
|
9
|
-
readonly alias: "g";
|
|
10
|
-
readonly default: false;
|
|
11
|
-
readonly description: "Install to user directory instead of project";
|
|
12
|
-
readonly type: "boolean";
|
|
13
|
-
};
|
|
14
|
-
readonly yes: {
|
|
15
|
-
readonly alias: "y";
|
|
16
|
-
readonly default: true;
|
|
17
|
-
readonly description: "Skip confirmation prompts";
|
|
18
|
-
readonly type: "boolean";
|
|
19
|
-
};
|
|
20
|
-
}>;
|
package/dist/commands/init.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { defineCommand } from "citty";
|
|
2
|
-
import { consola } from "consola";
|
|
3
|
-
import { detectPackageManager, globalInstallArgs, globalInstallCommand, PKG_NAME, } from "../lib/package-manager.js";
|
|
4
|
-
import { isMissingCommand, run } from "../lib/run.js";
|
|
5
|
-
import { assertKnownFlags } from "../lib/strict-args.js";
|
|
6
|
-
const REPO = "kyh/vibedgames";
|
|
7
|
-
const DEFAULT_AGENTS = "claude-code,cursor,codex";
|
|
8
|
-
const description = "Install/update vibedgames skills and the vg CLI";
|
|
9
|
-
const skillsAddArgs = (agents, global, yes) => {
|
|
10
|
-
const args = ["-y", "skills", "add", REPO];
|
|
11
|
-
for (const agent of agents) {
|
|
12
|
-
args.push("-a", agent);
|
|
13
|
-
}
|
|
14
|
-
if (global) {
|
|
15
|
-
args.push("-g");
|
|
16
|
-
}
|
|
17
|
-
if (yes) {
|
|
18
|
-
args.push("-y");
|
|
19
|
-
}
|
|
20
|
-
return args;
|
|
21
|
-
};
|
|
22
|
-
const skillsUpdateArgs = (global, yes) => {
|
|
23
|
-
const args = ["-y", "skills", "update"];
|
|
24
|
-
if (global) {
|
|
25
|
-
args.push("-g");
|
|
26
|
-
}
|
|
27
|
-
if (yes) {
|
|
28
|
-
args.push("-y");
|
|
29
|
-
}
|
|
30
|
-
return args;
|
|
31
|
-
};
|
|
32
|
-
const initArgs = {
|
|
33
|
-
agent: {
|
|
34
|
-
alias: "a",
|
|
35
|
-
default: DEFAULT_AGENTS,
|
|
36
|
-
description: "Comma-separated target agents. Default installs for Claude Code, Cursor, and Codex (symlinked from a shared .agents/skills/ dir). Pass '*' for every supported agent.",
|
|
37
|
-
type: "string",
|
|
38
|
-
},
|
|
39
|
-
global: {
|
|
40
|
-
alias: "g",
|
|
41
|
-
default: false,
|
|
42
|
-
description: "Install to user directory instead of project",
|
|
43
|
-
type: "boolean",
|
|
44
|
-
},
|
|
45
|
-
yes: {
|
|
46
|
-
alias: "y",
|
|
47
|
-
default: true,
|
|
48
|
-
description: "Skip confirmation prompts",
|
|
49
|
-
type: "boolean",
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
export const initCommand = defineCommand({
|
|
53
|
-
args: initArgs,
|
|
54
|
-
meta: { description, name: "init" },
|
|
55
|
-
run: async ({ args, rawArgs }) => {
|
|
56
|
-
assertKnownFlags(rawArgs, initArgs);
|
|
57
|
-
const agents = args.agent
|
|
58
|
-
.split(",")
|
|
59
|
-
.map((s) => s.trim())
|
|
60
|
-
.filter(Boolean);
|
|
61
|
-
// Whatever installed this CLI is what should upgrade it. Installing with a
|
|
62
|
-
// different manager writes a second copy into a prefix the shell may not
|
|
63
|
-
// even be looking at, so `vg --version` would not move.
|
|
64
|
-
const manager = detectPackageManager(import.meta.filename);
|
|
65
|
-
consola.start("Installing/updating vibedgames skills and the vg CLI (this takes a few minutes — `skills` fetches the repo once per skill)...");
|
|
66
|
-
const [add, cli] = await Promise.all([
|
|
67
|
-
run("npx", skillsAddArgs(agents, args.global, args.yes), { stream: true }),
|
|
68
|
-
run(manager, globalInstallArgs(manager)),
|
|
69
|
-
]);
|
|
70
|
-
if (add.code !== 0) {
|
|
71
|
-
if (isMissingCommand(add)) {
|
|
72
|
-
throw new Error("`npx` was not found on PATH. It ships with Node, so this usually means " +
|
|
73
|
-
"the vg CLI is running from a standalone build — install Node, or add " +
|
|
74
|
-
`the skills yourself with: npx skills add ${REPO}`);
|
|
75
|
-
}
|
|
76
|
-
if (add.output.trim()) {
|
|
77
|
-
consola.error(add.output.trim());
|
|
78
|
-
}
|
|
79
|
-
throw new Error(`skills add exited with code ${add.code}`);
|
|
80
|
-
}
|
|
81
|
-
consola.success(`Installed vibedgames skills for ${agents.join(", ")}`);
|
|
82
|
-
const update = await run("npx", skillsUpdateArgs(args.global, args.yes), {
|
|
83
|
-
stream: true,
|
|
84
|
-
});
|
|
85
|
-
if (update.code === 0) {
|
|
86
|
-
consola.success("Refreshed installed skills to latest");
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
if (update.output.trim()) {
|
|
90
|
-
consola.warn(update.output.trim());
|
|
91
|
-
}
|
|
92
|
-
consola.warn(`'skills update' exited with code ${update.code}. Skills were just installed via 'add', so they should already be current.`);
|
|
93
|
-
}
|
|
94
|
-
if (cli.code !== 0) {
|
|
95
|
-
if (cli.output.trim() && !isMissingCommand(cli)) {
|
|
96
|
-
consola.warn(cli.output.trim());
|
|
97
|
-
}
|
|
98
|
-
consola.warn(isMissingCommand(cli)
|
|
99
|
-
? `Couldn't find ${manager} to update the vg CLI. Update manually: ${globalInstallCommand(manager)}`
|
|
100
|
-
: `Couldn't install the vg CLI globally (${manager} exit ${cli.code}). Install manually: ${globalInstallCommand(manager)}`);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
consola.success(`Installed/updated ${PKG_NAME} globally with ${manager}`);
|
|
104
|
-
},
|
|
105
|
-
});
|
package/dist/commands/login.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const loginCommand: import("citty").CommandDef<import("citty").ArgsDef>;
|