vibedgames 0.8.0 → 0.9.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.
Files changed (40) hide show
  1. package/README.md +14 -6
  2. package/dist/THIRD_PARTY_NOTICES.txt +58 -6
  3. package/dist/{chunk-FNYBZNW2.js → chunk-25BAMW5X.js} +3 -1
  4. package/dist/{chunk-SAANBZ25.js → chunk-2VUUMXAQ.js} +4 -4
  5. package/dist/{chunk-XK5RZQMX.js → chunk-355VG7EO.js} +14 -13
  6. package/dist/{chunk-I6O4HIDY.js → chunk-3HUWAJQH.js} +76 -61
  7. package/dist/{chunk-2QBYTIMH.js → chunk-5535KDYI.js} +1 -1
  8. package/dist/chunk-56OY4TEP.js +20125 -0
  9. package/dist/{chunk-XDC7QGOF.js → chunk-6EWHKL7Z.js} +14 -6
  10. package/dist/{chunk-6FZPPUQH.js → chunk-7CXMMC5S.js} +1 -1
  11. package/dist/chunk-7QZSDU52.js +26 -0
  12. package/dist/{chunk-AZGENOOR.js → chunk-AXTLPJ2F.js} +5 -4
  13. package/dist/{chunk-IO6OM6WM.js → chunk-BMTHAVMS.js} +7 -33
  14. package/dist/{chunk-CU7UY5YJ.js → chunk-D2RF35HJ.js} +1 -1
  15. package/dist/chunk-FC233UKH.js +170 -0
  16. package/dist/{chunk-CAKBGDCY.js → chunk-GKDUYJ7R.js} +5 -0
  17. package/dist/{chunk-TYVYWBY6.js → chunk-H3IPLBXQ.js} +9 -8
  18. package/dist/{chunk-TMK6V5FV.js → chunk-HNRVSBRK.js} +7 -7
  19. package/dist/chunk-K2U7L4RU.js +183 -0
  20. package/dist/{chunk-PQDBCZRT.js → chunk-KZBZNTM4.js} +203 -153
  21. package/dist/{chunk-GUF6ADBF.js → chunk-LXS3NJYD.js} +8 -7
  22. package/dist/{chunk-W5XP4ZVU.js → chunk-LY2GQ32S.js} +11 -10
  23. package/dist/{chunk-K5SC6SXO.js → chunk-NDHXM4PL.js} +5 -5
  24. package/dist/{chunk-HASKWB6B.js → chunk-OD2MNYXD.js} +48 -22
  25. package/dist/{chunk-JT2AU24K.js → chunk-QARXJGI5.js} +1 -1
  26. package/dist/{chunk-RYFO3ZPO.js → chunk-RXHTGX7C.js} +9 -2
  27. package/dist/chunk-ST5FC2W3.js +95 -0
  28. package/dist/chunk-TBQ5BU3Q.js +39 -0
  29. package/dist/{chunk-RIGKOLNN.js → chunk-UFR6G6BL.js} +40 -65
  30. package/dist/{chunk-CZPKN32Z.js → chunk-US6QZICZ.js} +10 -10
  31. package/dist/{chunk-Y552BNFZ.js → chunk-UXCWSWWX.js} +7 -7
  32. package/dist/chunk-UZM6OSW5.js +113 -0
  33. package/dist/{chunk-FL6IFBUF.js → chunk-WSRIF6K4.js} +4 -4
  34. package/dist/chunk-X75Y7LUW.js +126 -0
  35. package/dist/chunk-Z5TFZQ5U.js +2478 -0
  36. package/dist/{chunk-H4NBRFBY.js → chunk-ZCYWDKYP.js} +30 -5
  37. package/dist/index.js +30 -19
  38. package/package.json +6 -5
  39. package/dist/chunk-RNBUX5VF.js +0 -68
  40. package/dist/chunk-X4ZABSCN.js +0 -415
@@ -6,16 +6,18 @@ var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
7
  import {
8
8
  extractSource
9
- } from "./chunk-I6O4HIDY.js";
9
+ } from "./chunk-3HUWAJQH.js";
10
10
  import "./chunk-VFFOT7KD.js";
11
- import {
12
- SLUG_RE
13
- } from "./chunk-ZI6PKVXG.js";
14
11
  import {
15
12
  createClient
16
- } from "./chunk-PQDBCZRT.js";
13
+ } from "./chunk-KZBZNTM4.js";
14
+ import "./chunk-K2U7L4RU.js";
17
15
  import "./chunk-Z4Z24FWO.js";
18
16
  import "./chunk-PEUP4MZR.js";
17
+ import "./chunk-RXHTGX7C.js";
18
+ import {
19
+ SLUG_RE
20
+ } from "./chunk-ZI6PKVXG.js";
19
21
  import {
20
22
  isJsonOutput,
21
23
  outputArgs,
@@ -24,17 +26,16 @@ import {
24
26
  import {
25
27
  assertKnownFlags
26
28
  } from "./chunk-RZ4DIJQW.js";
27
- import "./chunk-RYFO3ZPO.js";
29
+ import {
30
+ consola
31
+ } from "./chunk-D2RF35HJ.js";
28
32
  import {
29
33
  isJsonObject
30
34
  } from "./chunk-J6PKNPI2.js";
31
- import {
32
- consola
33
- } from "./chunk-CU7UY5YJ.js";
34
35
  import {
35
36
  defineCommand
36
37
  } from "./chunk-MBXCVCC4.js";
37
- import "./chunk-CAKBGDCY.js";
38
+ import "./chunk-GKDUYJ7R.js";
38
39
 
39
40
  // src/commands/fork.ts
40
41
  import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
@@ -13,7 +13,8 @@ import {
13
13
  saveSetting,
14
14
  settingsPath,
15
15
  validate
16
- } from "./chunk-6FZPPUQH.js";
16
+ } from "./chunk-7CXMMC5S.js";
17
+ import "./chunk-RXHTGX7C.js";
17
18
  import {
18
19
  outputArgs,
19
20
  writeStructured
@@ -21,15 +22,14 @@ import {
21
22
  import {
22
23
  assertKnownFlags
23
24
  } from "./chunk-RZ4DIJQW.js";
24
- import "./chunk-RYFO3ZPO.js";
25
- import "./chunk-J6PKNPI2.js";
26
25
  import {
27
26
  consola
28
- } from "./chunk-CU7UY5YJ.js";
27
+ } from "./chunk-D2RF35HJ.js";
28
+ import "./chunk-J6PKNPI2.js";
29
29
  import {
30
30
  defineCommand
31
31
  } from "./chunk-MBXCVCC4.js";
32
- import "./chunk-CAKBGDCY.js";
32
+ import "./chunk-GKDUYJ7R.js";
33
33
 
34
34
  // src/commands/config.ts
35
35
  var keyArg = {
@@ -4,20 +4,22 @@ import { fileURLToPath as __fileURLToPath } from "node:url";
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
+ import {
8
+ FACTORY_PACKAGE,
9
+ installedFactoryVersion,
10
+ updateFactory
11
+ } from "./chunk-ZCYWDKYP.js";
7
12
  import {
8
13
  findInstall,
9
- isMissingCommand,
10
14
  reportSkills,
11
- run,
12
15
  settleSync,
13
16
  syncSkills
14
- } from "./chunk-IO6OM6WM.js";
15
- import "./chunk-2QBYTIMH.js";
17
+ } from "./chunk-BMTHAVMS.js";
16
18
  import {
17
19
  fetchLatestVersion,
18
20
  isNewerVersion
19
- } from "./chunk-SAANBZ25.js";
20
- import "./chunk-6FZPPUQH.js";
21
+ } from "./chunk-2VUUMXAQ.js";
22
+ import "./chunk-7CXMMC5S.js";
21
23
  import "./chunk-VFFOT7KD.js";
22
24
  import {
23
25
  PACKAGE_VERSION
@@ -27,24 +29,51 @@ import {
27
29
  globalInstallArgs,
28
30
  globalInstallCommand
29
31
  } from "./chunk-PEUP4MZR.js";
32
+ import "./chunk-RXHTGX7C.js";
33
+ import {
34
+ isMissingCommand,
35
+ run
36
+ } from "./chunk-TBQ5BU3Q.js";
37
+ import "./chunk-5535KDYI.js";
30
38
  import {
31
39
  assertKnownFlags
32
40
  } from "./chunk-RZ4DIJQW.js";
33
- import "./chunk-RYFO3ZPO.js";
34
- import "./chunk-J6PKNPI2.js";
35
41
  import {
36
42
  consola
37
- } from "./chunk-CU7UY5YJ.js";
43
+ } from "./chunk-D2RF35HJ.js";
44
+ import "./chunk-J6PKNPI2.js";
38
45
  import {
39
46
  defineCommand
40
47
  } from "./chunk-MBXCVCC4.js";
41
- import "./chunk-CAKBGDCY.js";
48
+ import "./chunk-GKDUYJ7R.js";
42
49
 
43
50
  // src/commands/update.ts
44
51
  var updateInstalledSkills = async (global) => {
45
52
  const found = findInstall(global ? ["global"] : ["project", "global"]);
46
53
  return found ? await syncSkills(found.target, found.agents) : null;
47
54
  };
55
+ var autoUpdate = async (manager, global, factoryVersion) => {
56
+ const [latest, latestFactory] = await Promise.all([
57
+ fetchLatestVersion("vibedgames"),
58
+ factoryVersion === null ? null : fetchLatestVersion(FACTORY_PACKAGE)
59
+ ]);
60
+ const cliNewer = latest !== null && isNewerVersion(latest, PACKAGE_VERSION);
61
+ const factoryNewer = factoryVersion !== null && latestFactory !== null && isNewerVersion(latestFactory, factoryVersion);
62
+ await Promise.all([
63
+ cliNewer && run(manager, globalInstallArgs(manager)),
64
+ cliNewer && settleSync(updateInstalledSkills(global)),
65
+ factoryNewer && updateFactory()
66
+ ]);
67
+ };
68
+ var reportFactory = (result) => {
69
+ if (result.code === 0) {
70
+ consola.success(`${FACTORY_PACKAGE} updated to latest`);
71
+ return;
72
+ }
73
+ consola.warn(
74
+ `Couldn't update the factory (npm exit ${result.code}). Update manually: npm install -g ${FACTORY_PACKAGE}@latest`
75
+ );
76
+ };
48
77
  var updateArgs = {
49
78
  auto: {
50
79
  default: false,
@@ -61,28 +90,22 @@ var updateArgs = {
61
90
  var updateCommand = defineCommand({
62
91
  args: updateArgs,
63
92
  meta: {
64
- description: "Update the vg CLI and vibedgames skills to latest (runs automatically once a day; turn that off with `vg config set update.auto false`)",
93
+ description: "Update the vg CLI, vibedgames skills and, if installed, the factory to latest (runs automatically once a day; turn that off with `vg config set update.auto false`)",
65
94
  name: "update"
66
95
  },
67
96
  run: async ({ args, rawArgs }) => {
68
97
  assertKnownFlags(rawArgs, updateArgs);
69
98
  const manager = detectPackageManager(import.meta.filename);
99
+ const factoryVersion = installedFactoryVersion();
70
100
  if (args.auto) {
71
- const latest = await fetchLatestVersion();
72
- if (!latest || !isNewerVersion(latest, PACKAGE_VERSION)) {
73
- return;
74
- }
75
- await Promise.all([
76
- run(manager, globalInstallArgs(manager)),
77
- // Silent background mode: a failed skills sync waits for the next run.
78
- settleSync(updateInstalledSkills(args.global))
79
- ]);
101
+ await autoUpdate(manager, args.global, factoryVersion);
80
102
  return;
81
103
  }
82
104
  consola.start("Updating the vg CLI and vibedgames skills...");
83
- const [cli, skills] = await Promise.all([
105
+ const [cli, skills, factory] = await Promise.all([
84
106
  run(manager, globalInstallArgs(manager)),
85
- settleSync(updateInstalledSkills(args.global))
107
+ settleSync(updateInstalledSkills(args.global)),
108
+ factoryVersion === null ? null : updateFactory()
86
109
  ]);
87
110
  if (cli.code === 0) {
88
111
  consola.success(`vg CLI updated to latest with ${manager}`);
@@ -101,6 +124,9 @@ var updateCommand = defineCommand({
101
124
  } else {
102
125
  consola.info("No vibedgames skills installed here or in your home directory: run vg init");
103
126
  }
127
+ if (factory) {
128
+ reportFactory(factory);
129
+ }
104
130
  if (cli.code !== 0 && !skills.ok) {
105
131
  throw new Error("update failed for both the CLI and skills");
106
132
  }
@@ -4,7 +4,7 @@ import { fileURLToPath as __fileURLToPath } from "node:url";
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import "./chunk-CAKBGDCY.js";
7
+ import "./chunk-GKDUYJ7R.js";
8
8
 
9
9
  // ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/chunks/prompt.mjs
10
10
  import g, { stdin, stdout } from "node:process";
@@ -5,6 +5,7 @@ const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
7
  import {
8
+ isJsonNumber,
8
9
  isJsonObject,
9
10
  isJsonString
10
11
  } from "./chunk-J6PKNPI2.js";
@@ -33,11 +34,16 @@ var getConfig = () => {
33
34
  if (!isJsonObject(raw)) {
34
35
  return null;
35
36
  }
36
- const { token, baseUrl } = raw;
37
+ const { baseUrl, expiresAt, refreshToken, token } = raw;
37
38
  if (!isJsonString(token) || !isJsonString(baseUrl)) {
38
39
  return null;
39
40
  }
40
- return { baseUrl, token };
41
+ return {
42
+ baseUrl,
43
+ expiresAt: isJsonNumber(expiresAt) ? expiresAt : void 0,
44
+ refreshToken: isJsonString(refreshToken) ? refreshToken : void 0,
45
+ token
46
+ };
41
47
  };
42
48
  var saveConfig = (config) => {
43
49
  const dir = getConfigDir();
@@ -64,6 +70,7 @@ var getToken = () => (
64
70
 
65
71
  export {
66
72
  getConfigDir,
73
+ getConfig,
67
74
  saveConfig,
68
75
  clearConfig,
69
76
  getBaseUrl,
@@ -0,0 +1,95 @@
1
+ import { createRequire as __createRequire } from "node:module";
2
+ import { dirname as __pathDirname } from "node:path";
3
+ import { fileURLToPath as __fileURLToPath } from "node:url";
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import {
8
+ OAuthError,
9
+ pollDeviceToken,
10
+ requestDeviceCode
11
+ } from "./chunk-K2U7L4RU.js";
12
+ import {
13
+ getBaseUrl,
14
+ saveConfig
15
+ } from "./chunk-RXHTGX7C.js";
16
+ import {
17
+ consola
18
+ } from "./chunk-D2RF35HJ.js";
19
+ import "./chunk-J6PKNPI2.js";
20
+ import {
21
+ defineCommand
22
+ } from "./chunk-MBXCVCC4.js";
23
+ import "./chunk-GKDUYJ7R.js";
24
+
25
+ // src/commands/login.ts
26
+ import { spawn } from "node:child_process";
27
+ import { setTimeout as sleep } from "node:timers/promises";
28
+ var SLOW_DOWN_STEP_MS = 5e3;
29
+ var openBrowser = (url, baseUrl) => {
30
+ let target;
31
+ try {
32
+ target = new URL(url);
33
+ } catch {
34
+ return;
35
+ }
36
+ if (target.origin !== new URL(baseUrl).origin) {
37
+ return;
38
+ }
39
+ const openers = {
40
+ darwin: ["open", [target.href]],
41
+ win32: ["rundll32", ["url.dll,FileProtocolHandler", target.href]]
42
+ };
43
+ const [cmd, args] = openers[process.platform] ?? ["xdg-open", [target.href]];
44
+ const child = spawn(cmd, args, { detached: true, stdio: "ignore" });
45
+ child.on("error", () => {
46
+ });
47
+ child.unref();
48
+ };
49
+ var fail = (message) => {
50
+ consola.error(message);
51
+ process.exit(1);
52
+ };
53
+ var loginCommand = defineCommand({
54
+ meta: {
55
+ description: "Authenticate with vibedgames",
56
+ name: "login"
57
+ },
58
+ run: async () => {
59
+ const baseUrl = getBaseUrl();
60
+ const device = await requestDeviceCode(baseUrl);
61
+ consola.box(`Code: ${device.userCode}`);
62
+ consola.info(
63
+ `Opening ${device.verificationUriComplete}: approve there if it shows this same code.`
64
+ );
65
+ openBrowser(device.verificationUriComplete, baseUrl);
66
+ consola.start("Waiting for approval...");
67
+ let intervalMs = device.interval * 1e3;
68
+ const deadline = Date.now() + device.expiresIn * 1e3;
69
+ while (Date.now() < deadline) {
70
+ await sleep(intervalMs);
71
+ try {
72
+ saveConfig(await pollDeviceToken(baseUrl, device.deviceCode));
73
+ consola.success("Logged in successfully");
74
+ return;
75
+ } catch (error) {
76
+ if (!(error instanceof OAuthError)) {
77
+ throw error;
78
+ }
79
+ if (error.code === "slow_down") {
80
+ intervalMs += SLOW_DOWN_STEP_MS;
81
+ } else if (error.code === "access_denied") {
82
+ fail("Login was denied in the browser.");
83
+ } else if (error.code === "expired_token") {
84
+ fail("Code expired. Run `vg login` to try again.");
85
+ } else if (error.code !== "authorization_pending") {
86
+ throw error;
87
+ }
88
+ }
89
+ }
90
+ fail("Timed out waiting for approval. Run `vg login` to try again.");
91
+ }
92
+ });
93
+ export {
94
+ loginCommand
95
+ };
@@ -0,0 +1,39 @@
1
+ import { createRequire as __createRequire } from "node:module";
2
+ import { dirname as __pathDirname } from "node:path";
3
+ import { fileURLToPath as __fileURLToPath } from "node:url";
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import {
8
+ require_cross_spawn
9
+ } from "./chunk-5535KDYI.js";
10
+ import {
11
+ __toESM
12
+ } from "./chunk-GKDUYJ7R.js";
13
+
14
+ // src/lib/run.ts
15
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
16
+ var isMissingCommand = (result) => result.code !== 0 && /ENOENT|not found|not recognized/iu.test(result.output);
17
+ var run = (cmd, args, cwd) => (
18
+ // oxlint-disable-next-line promise/avoid-new -- child_process.spawn is event-based
19
+ new Promise((resolve) => {
20
+ const chunks = [];
21
+ const child = (0, import_cross_spawn.default)(cmd, args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
22
+ const collect = (c) => {
23
+ chunks.push(c);
24
+ };
25
+ child.stdout?.on("data", collect);
26
+ child.stderr?.on("data", collect);
27
+ child.on("error", (err) => resolve({ code: 1, output: `${err.message}
28
+ ` }));
29
+ child.on(
30
+ "close",
31
+ (code) => resolve({ code: code ?? 1, output: Buffer.concat(chunks).toString("utf-8") })
32
+ );
33
+ })
34
+ );
35
+
36
+ export {
37
+ isMissingCommand,
38
+ run
39
+ };
@@ -4,43 +4,53 @@ import { fileURLToPath as __fileURLToPath } from "node:url";
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import {
8
- require_cross_spawn
9
- } from "./chunk-2QBYTIMH.js";
10
7
  import {
11
8
  resolveSetting
12
- } from "./chunk-6FZPPUQH.js";
9
+ } from "./chunk-7CXMMC5S.js";
13
10
  import {
14
11
  createClient,
15
12
  forwardJson
16
- } from "./chunk-PQDBCZRT.js";
13
+ } from "./chunk-KZBZNTM4.js";
14
+ import "./chunk-K2U7L4RU.js";
17
15
  import "./chunk-Z4Z24FWO.js";
18
16
  import "./chunk-PEUP4MZR.js";
17
+ import "./chunk-RXHTGX7C.js";
18
+ import {
19
+ require_cross_spawn
20
+ } from "./chunk-5535KDYI.js";
19
21
  import {
20
22
  isJsonOutput,
21
23
  outputArgs,
22
24
  writeJson,
23
25
  writeStructured
24
26
  } from "./chunk-ZYCSYJWX.js";
25
- import "./chunk-RYFO3ZPO.js";
27
+ import {
28
+ consola
29
+ } from "./chunk-D2RF35HJ.js";
26
30
  import {
27
31
  isJsonNumber,
28
32
  isJsonObject,
29
33
  isJsonString
30
34
  } from "./chunk-J6PKNPI2.js";
31
- import {
32
- consola
33
- } from "./chunk-CU7UY5YJ.js";
34
35
  import {
35
36
  defineCommand
36
37
  } from "./chunk-MBXCVCC4.js";
37
38
  import {
38
39
  __toESM
39
- } from "./chunk-CAKBGDCY.js";
40
+ } from "./chunk-GKDUYJ7R.js";
40
41
 
41
42
  // src/commands/generate.ts
42
43
  import { setTimeout as sleep2 } from "node:timers/promises";
43
44
 
45
+ // ../../packages/contract/src/generate/queue-path.ts
46
+ var endpointPath = (endpointId) => endpointId.replaceAll(/^\/+|\/+$/gu, "");
47
+ var QUEUE_APP_NAMESPACES = /* @__PURE__ */ new Set(["workflows", "comfy"]);
48
+ var queueAppId = (endpointId) => {
49
+ const parts = endpointPath(endpointId).split("/").filter(Boolean);
50
+ const take = QUEUE_APP_NAMESPACES.has(parts[0] ?? "") ? 3 : 2;
51
+ return parts.slice(0, take).join("/");
52
+ };
53
+
44
54
  // src/lib/codex.ts
45
55
  var import_cross_spawn = __toESM(require_cross_spawn(), 1);
46
56
  import { randomBytes } from "node:crypto";
@@ -232,6 +242,20 @@ var parseDownloadFlag = (argv) => {
232
242
  // src/lib/media-download.ts
233
243
  import { mkdirSync, writeFileSync } from "node:fs";
234
244
  import path2 from "node:path";
245
+
246
+ // ../../packages/contract/src/generate/media-hosts.ts
247
+ var HOSTS = /* @__PURE__ */ new Set(["fal.media", "fal.run", "fal.ai"]);
248
+ var SUFFIXES = [".fal.media", ".fal.run", ".fal.ai"];
249
+ var HTTPS = /^https:\/\/(?<host>[a-z0-9.-]+)(?::\d{1,5})?(?:[/?#]|$)/iu;
250
+ var isMediaUrl = (url) => {
251
+ const host = HTTPS.exec(url)?.groups?.host?.toLowerCase();
252
+ if (!host) {
253
+ return false;
254
+ }
255
+ return HOSTS.has(host) || SUFFIXES.some((suffix) => host.endsWith(suffix));
256
+ };
257
+
258
+ // src/lib/media-download.ts
235
259
  var MEDIA_EXT = /* @__PURE__ */ new Set([
236
260
  "png",
237
261
  "jpg",
@@ -251,24 +275,6 @@ var MEDIA_EXT = /* @__PURE__ */ new Set([
251
275
  "flac",
252
276
  "m4a"
253
277
  ]);
254
- var TRUSTED_HOST_SUFFIXES = [".fal.media", ".fal.run", ".fal.ai"];
255
- var TRUSTED_HOSTS = /* @__PURE__ */ new Set(["fal.media", "fal.run", "fal.ai"]);
256
- var isTrustedFalContentHost = (url) => {
257
- let parsed;
258
- try {
259
- parsed = new URL(url);
260
- } catch {
261
- return false;
262
- }
263
- if (parsed.protocol !== "https:") {
264
- return false;
265
- }
266
- const host = parsed.hostname.toLowerCase();
267
- if (TRUSTED_HOSTS.has(host)) {
268
- return true;
269
- }
270
- return TRUSTED_HOST_SUFFIXES.some((suffix) => host.endsWith(suffix));
271
- };
272
278
  var extFromUrl = (url) => {
273
279
  try {
274
280
  const { pathname } = new URL(url);
@@ -296,7 +302,7 @@ var visit = (value, refs, seen) => {
296
302
  return;
297
303
  }
298
304
  const { url } = value;
299
- if (isJsonString(url) && isTrustedFalContentHost(url) && !seen.has(url)) {
305
+ if (isJsonString(url) && isMediaUrl(url) && !seen.has(url)) {
300
306
  const contentType = isJsonString(value.content_type) ? value.content_type.toLowerCase() : null;
301
307
  const filenameField = isJsonString(value.file_name) ? sanitizeFilename(value.file_name) : null;
302
308
  const ext = filenameField ? path2.extname(filenameField).slice(1).toLowerCase() : extFromUrl(url);
@@ -745,13 +751,6 @@ var placeCodexOutputs = (rawFiles, template, requestId) => {
745
751
 
746
752
  // src/lib/media-poll.ts
747
753
  import { setTimeout as sleep } from "node:timers/promises";
748
- var endpointPath = (endpointId) => endpointId.replaceAll(/^\/+|\/+$/gu, "");
749
- var QUEUE_APP_NAMESPACES = /* @__PURE__ */ new Set(["workflows", "comfy"]);
750
- var queueAppId = (endpointId) => {
751
- const parts = endpointPath(endpointId).split("/").filter(Boolean);
752
- const take = QUEUE_APP_NAMESPACES.has(parts[0] ?? "") ? 3 : 2;
753
- return parts.slice(0, take).join("/");
754
- };
755
754
  var POLL_INTERVAL_MS = 2e3;
756
755
  var POLL_TIMEOUT_MS = 30 * 60 * 1e3;
757
756
  var pickErrorReason = (value) => {
@@ -816,42 +815,18 @@ var waitForCompletion = async (client, endpoint_id, request_id, opts) => {
816
815
 
817
816
  // src/lib/media-upload.ts
818
817
  import { openAsBlob } from "node:fs";
819
- var pickUrl = (slot, key) => {
820
- const value = isJsonObject(slot) ? slot[key] : void 0;
821
- if (!isJsonString(value) || value.length === 0) {
822
- throw new Error(`fal storage initiate response missing ${key}.`);
823
- }
824
- let parsed;
825
- try {
826
- parsed = new URL(value);
827
- } catch {
828
- throw new Error(`fal storage initiate response ${key} is not a valid URL.`);
829
- }
830
- if (parsed.protocol !== "https:") {
831
- throw new Error(`fal storage initiate response ${key} must be HTTPS, got ${parsed.protocol}.`);
832
- }
833
- return value;
834
- };
835
818
  var uploadFile = async (client, file) => {
836
- const slot = await forwardJson(client, {
837
- body: { content_type: file.contentType, file_name: file.filename },
838
- method: "POST",
839
- path: "/storage/upload/initiate",
840
- target: "storage"
819
+ const slot = await client.generate.upload({
820
+ contentType: file.contentType,
821
+ fileName: file.filename
841
822
  });
842
- const uploadUrl = pickUrl(slot, "upload_url");
843
- const fileUrl = pickUrl(slot, "file_url");
844
823
  const body = await openAsBlob(file.path, { type: file.contentType });
845
- const res = await fetch(uploadUrl, {
846
- body,
847
- headers: { "Content-Type": file.contentType },
848
- method: "PUT"
849
- });
824
+ const res = await fetch(slot.uploadUrl, { body, headers: slot.headers, method: "PUT" });
850
825
  if (!res.ok) {
851
826
  const text = await res.text().catch(() => "");
852
827
  throw new Error(`Upload failed for ${file.filename}: ${res.status} ${res.statusText} ${text}`);
853
828
  }
854
- return fileUrl;
829
+ return slot.fileUrl;
855
830
  };
856
831
 
857
832
  // src/commands/generate.ts
@@ -4,30 +4,30 @@ import { fileURLToPath as __fileURLToPath } from "node:url";
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import {
8
- require_cross_spawn
9
- } from "./chunk-2QBYTIMH.js";
10
7
  import {
11
8
  isNewerVersion
12
- } from "./chunk-SAANBZ25.js";
9
+ } from "./chunk-2VUUMXAQ.js";
10
+ import {
11
+ getBaseUrl,
12
+ getConfigDir
13
+ } from "./chunk-RXHTGX7C.js";
14
+ import {
15
+ require_cross_spawn
16
+ } from "./chunk-5535KDYI.js";
13
17
  import {
14
18
  SLUG_RE,
15
19
  findProjectRoot,
16
20
  readProjectConfig
17
21
  } from "./chunk-ZI6PKVXG.js";
18
- import {
19
- getBaseUrl,
20
- getConfigDir
21
- } from "./chunk-RYFO3ZPO.js";
22
22
  import {
23
23
  consola
24
- } from "./chunk-CU7UY5YJ.js";
24
+ } from "./chunk-D2RF35HJ.js";
25
25
  import {
26
26
  defineCommand
27
27
  } from "./chunk-MBXCVCC4.js";
28
28
  import {
29
29
  __toESM
30
- } from "./chunk-CAKBGDCY.js";
30
+ } from "./chunk-GKDUYJ7R.js";
31
31
 
32
32
  // src/commands/playtest.ts
33
33
  import { createHash } from "node:crypto";
@@ -16,16 +16,16 @@ import {
16
16
  resolveGameUrl,
17
17
  runPlaytest,
18
18
  withScopedSession
19
- } from "./chunk-CZPKN32Z.js";
20
- import "./chunk-2QBYTIMH.js";
21
- import "./chunk-SAANBZ25.js";
22
- import "./chunk-6FZPPUQH.js";
19
+ } from "./chunk-US6QZICZ.js";
20
+ import "./chunk-2VUUMXAQ.js";
21
+ import "./chunk-7CXMMC5S.js";
22
+ import "./chunk-RXHTGX7C.js";
23
+ import "./chunk-5535KDYI.js";
23
24
  import "./chunk-ZI6PKVXG.js";
24
- import "./chunk-RYFO3ZPO.js";
25
+ import "./chunk-D2RF35HJ.js";
25
26
  import "./chunk-J6PKNPI2.js";
26
- import "./chunk-CU7UY5YJ.js";
27
27
  import "./chunk-MBXCVCC4.js";
28
- import "./chunk-CAKBGDCY.js";
28
+ import "./chunk-GKDUYJ7R.js";
29
29
  export {
30
30
  bareTokens,
31
31
  bootstrap,