@doufunao123/asset-gateway 0.12.1 → 0.12.2

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 (2) hide show
  1. package/dist/index.js +34 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -627,7 +627,7 @@ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as rea
627
627
  import { dirname as dirname2, extname, join as join2 } from "path";
628
628
  import { Command as Command3 } from "commander";
629
629
  function inferExtension(assetType) {
630
- const map = { image: "png", audio: "mp3", music: "mp3", tts: "mp3", video: "mp4", model3d: "glb", text: "txt", sprite: "png" };
630
+ const map = { image: "png", audio: "mp3", music: "mp3", tts: "mp3", video: "mp4", model3d: "glb", text: "txt", sprite: "png", world: "spz" };
631
631
  return map[assetType] ?? "bin";
632
632
  }
633
633
  function stripDataUri(data) {
@@ -948,6 +948,39 @@ function createGenerateCommand() {
948
948
  }
949
949
  })
950
950
  );
951
+ command.addCommand(
952
+ new Command3("world").description("Generate a 3D world/environment using WorldLabs Marble").requiredOption("--prompt <text>", "Text prompt describing the environment").option("--input <path>", "Input image (local path or URL) for image-to-world").option("--model <model>", "Model: marble-1.0-draft, marble-1.0, marble-1.1, marble-1.1-plus", "marble-1.1").option("--display-name <name>", "Display name for the generated world").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
953
+ try {
954
+ const ctx = createContext(this);
955
+ const params = {};
956
+ if (options.displayName) params.display_name = options.displayName;
957
+ let inputFile;
958
+ if (options.input) {
959
+ if (existsSync3(options.input)) {
960
+ const ext = extname(options.input).toLowerCase();
961
+ const mime = ext === ".jpg" || ext === ".jpeg" ? "image/jpeg" : "image/png";
962
+ const b64 = readFileSync2(options.input).toString("base64");
963
+ inputFile = `data:${mime};base64,${b64}`;
964
+ } else {
965
+ inputFile = options.input;
966
+ }
967
+ }
968
+ const body = {
969
+ asset_type: "world",
970
+ prompt: options.prompt,
971
+ model: options.model,
972
+ params
973
+ };
974
+ if (inputFile) body.input_file = inputFile;
975
+ const data = await ctx.client.post("/api/generate", body);
976
+ const localPath = await saveOutput(data, "world", options.outputDir);
977
+ if (localPath) data.local_path = localPath;
978
+ printSuccess("generate.world", data, ctx);
979
+ } catch (error2) {
980
+ printError("generate.world", error2);
981
+ }
982
+ })
983
+ );
951
984
  return command;
952
985
  }
953
986
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doufunao123/asset-gateway",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "description": "Universal asset generation gateway CLI",
5
5
  "type": "module",
6
6
  "bin": {