@doufunao123/asset-gateway 0.9.0 → 0.11.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 (2) hide show
  1. package/dist/index.js +44 -48
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -490,7 +490,7 @@ import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
490
490
  import { join as join2 } from "path";
491
491
  import { Command as Command3 } from "commander";
492
492
  function inferExtension(assetType) {
493
- const map = { image: "png", audio: "mp3", tts: "mp3", video: "mp4", model3d: "glb", text: "txt" };
493
+ const map = { image: "png", audio: "mp3", music: "mp3", tts: "mp3", video: "mp4", model3d: "glb", text: "txt" };
494
494
  return map[assetType] ?? "bin";
495
495
  }
496
496
  function stripDataUri(data) {
@@ -577,8 +577,10 @@ function createGenerateCommand() {
577
577
  asset_type: "audio",
578
578
  prompt: options.prompt
579
579
  };
580
- if (options.type) body.audio_type = options.type;
581
- if (options.duration) body.duration = Number(options.duration);
580
+ const params = {};
581
+ if (options.type) params.audio_type = options.type;
582
+ if (options.duration) params.duration_seconds = Number(options.duration);
583
+ if (Object.keys(params).length > 0) body.params = params;
582
584
  const data = await ctx.client.post("/api/generate", body);
583
585
  const localPath = await saveOutput(data, "audio", options.outputDir);
584
586
  if (localPath) data.local_path = localPath;
@@ -588,6 +590,26 @@ function createGenerateCommand() {
588
590
  }
589
591
  })
590
592
  );
593
+ command.addCommand(
594
+ new Command3("music").description("Generate music from a text prompt").requiredOption("--prompt <text>", "Music description prompt").option("--duration <seconds>", "Duration in seconds").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
595
+ try {
596
+ const ctx = createContext(this);
597
+ const body = {
598
+ asset_type: "music",
599
+ prompt: options.prompt
600
+ };
601
+ if (options.duration) {
602
+ body.params = { duration_seconds: Number(options.duration) };
603
+ }
604
+ const data = await ctx.client.post("/api/generate", body);
605
+ const localPath = await saveOutput(data, "music", options.outputDir);
606
+ if (localPath) data.local_path = localPath;
607
+ printSuccess("generate.music", data, ctx);
608
+ } catch (error2) {
609
+ printError("generate.music", error2);
610
+ }
611
+ })
612
+ );
591
613
  command.addCommand(
592
614
  new Command3("tts").description("Text-to-speech synthesis via Qwen3-TTS").requiredOption("--prompt <text>", "Text to synthesize").option("--voice <name>", "Voice name or custom voice ID", "Cherry").option("--language <lang>", "Language hint: Auto, Chinese, English, Japanese, etc.", "Auto").option("--model <model>", "Qwen3-TTS model", "qwen3-tts-flash").option("--instructions <text>", "Natural language speaking instructions (for instruct models)").option("--provider <id>", "Provider to use").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
593
615
  try {
@@ -732,27 +754,7 @@ function saveProcessOutput(data, outputDir) {
732
754
  return filePath;
733
755
  }
734
756
  function createProcessCommand() {
735
- const command = new Command5("process").description("Post-process images (remove-bg, crop, resize, upscale)");
736
- command.addCommand(
737
- new Command5("remove-bg").description("Remove background from an image (AI-powered, BiRefNet)").requiredOption("--input <path>", "Input image (file path or URL)").option("--smart-crop", "Also crop to power-of-2 after removing background").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
738
- try {
739
- const ctx = createContext(this);
740
- const ops = [{ op: "remove_bg" }];
741
- if (options.smartCrop) {
742
- ops.push({ op: "smart_crop", mode: "power_of2" });
743
- }
744
- const data = await ctx.client.post("/api/process", {
745
- input: readInputAsBase64(options.input),
746
- operations: ops
747
- });
748
- const localPath = saveProcessOutput(data, options.outputDir);
749
- if (localPath) data.local_path = localPath;
750
- printSuccess("process.remove-bg", data, ctx);
751
- } catch (error2) {
752
- printError("process.remove-bg", error2);
753
- }
754
- })
755
- );
757
+ const command = new Command5("process").description("Post-process images (crop, resize)");
756
758
  command.addCommand(
757
759
  new Command5("crop").description("Smart crop an image (trim transparent borders)").requiredOption("--input <path>", "Input image (file path or URL)").option("--mode <mode>", "Crop mode: tightest or power_of2", "tightest").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
758
760
  try {
@@ -785,22 +787,6 @@ function createProcessCommand() {
785
787
  }
786
788
  })
787
789
  );
788
- command.addCommand(
789
- new Command5("upscale").description("AI upscale an image (2x or 4x via Real-ESRGAN)").requiredOption("--input <path>", "Input image (file path or URL)").option("--scale <n>", "Scale factor (2 or 4)", "4").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
790
- try {
791
- const ctx = createContext(this);
792
- const data = await ctx.client.post("/api/process", {
793
- input: readInputAsBase64(options.input),
794
- operations: [{ op: "upscale", scale: Number(options.scale) }]
795
- });
796
- const localPath = saveProcessOutput(data, options.outputDir);
797
- if (localPath) data.local_path = localPath;
798
- printSuccess("process.upscale", data, ctx);
799
- } catch (error2) {
800
- printError("process.upscale", error2);
801
- }
802
- })
803
- );
804
790
  return command;
805
791
  }
806
792
 
@@ -839,7 +825,7 @@ async function saveProcess3dOutput(data, operation, outputDir, format) {
839
825
  function createProcess3dCommand() {
840
826
  const command = new Command6("process3d").description("3D model post-processing via Tripo pipeline");
841
827
  command.addCommand(
842
- new Command6("convert").description("Convert 3D model format (FBX/USDZ/OBJ/STL/GLTF/3MF)").requiredOption("--task-id <id>", "Tripo task ID from generate model").requiredOption("--format <fmt>", "Target format: FBX, USDZ, OBJ, STL, GLTF, 3MF").option("--quad", "Enable quad remeshing").option("--face-limit <n>", "Max face count").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
828
+ new Command6("convert").description("Convert 3D model format (FBX/USDZ/OBJ/STL/GLTF/3MF)").requiredOption("--task-id <id>", "Tripo task ID from generate model").requiredOption("--format <fmt>", "Target format: FBX, USDZ, OBJ, STL, GLTF, 3MF").option("--quad", "Enable quad remeshing").option("--face-limit <n>", "Max face count").option("--pack-uv", "Pack UVs during export").option("--bake", "Bake textures during export").option("--texture-format <fmt>", "Texture export format override").option("--force-symmetry", "Force symmetry during conversion").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
843
829
  try {
844
830
  const ctx = createContext(this);
845
831
  const params = {
@@ -847,6 +833,10 @@ function createProcess3dCommand() {
847
833
  };
848
834
  if (options.quad) params.quad = true;
849
835
  if (options.faceLimit) params.face_limit = Number(options.faceLimit);
836
+ if (options.packUv) params.pack_uv = true;
837
+ if (options.bake) params.bake = true;
838
+ if (options.textureFormat) params.texture_format = options.textureFormat;
839
+ if (options.forceSymmetry) params.force_symmetry = true;
850
840
  const data = await ctx.client.post("/api/process3d", {
851
841
  task_id: options.taskId,
852
842
  operation: "convert",
@@ -861,13 +851,17 @@ function createProcess3dCommand() {
861
851
  })
862
852
  );
863
853
  command.addCommand(
864
- new Command6("texture").description("Re-texture a 3D model with new materials").requiredOption("--task-id <id>", "Tripo task ID").option("--prompt <text>", "Texture description prompt").option("--pbr", "Enable PBR materials").option("--quality <q>", "Texture quality: standard or detailed").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
854
+ new Command6("texture").description("Re-texture a 3D model with new materials").requiredOption("--task-id <id>", "Tripo task ID").option("--prompt <text>", "Texture description prompt").option("--style-image <input>", "Texture style reference image URL or local file path").option("--pbr", "Enable PBR materials").option("--quality <q>", "Texture quality: standard or detailed").option("--texture-alignment <mode>", "Tripo texture alignment mode").option("--bake", "Bake textures during re-texturing").option("--texture-version <version>", "Tripo texture model version override").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
865
855
  try {
866
856
  const ctx = createContext(this);
867
857
  const params = {};
868
858
  if (options.prompt) params.prompt = options.prompt;
859
+ if (options.styleImage) params.style_image = options.styleImage;
869
860
  if (options.pbr) params.pbr = true;
870
- if (options.quality) params.quality = options.quality;
861
+ if (options.quality) params.texture_quality = options.quality;
862
+ if (options.textureAlignment) params.texture_alignment = options.textureAlignment;
863
+ if (options.bake) params.bake = true;
864
+ if (options.textureVersion) params.model_version = options.textureVersion;
871
865
  const data = await ctx.client.post("/api/process3d", {
872
866
  task_id: options.taskId,
873
867
  operation: "texture",
@@ -882,16 +876,18 @@ function createProcess3dCommand() {
882
876
  })
883
877
  );
884
878
  command.addCommand(
885
- new Command6("rig").description("Auto-rig a 3D model (add skeleton for animation)").requiredOption("--task-id <id>", "Tripo task ID").option("--format <fmt>", "Output format: glb or fbx", "glb").option("--spec <spec>", "Rig spec: mixamo or tripo", "mixamo").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
879
+ new Command6("rig").description("Auto-rig a 3D model (add skeleton for animation)").requiredOption("--task-id <id>", "Tripo task ID").option("--format <fmt>", "Output format: glb or fbx", "glb").option("--spec <spec>", "Rig spec: mixamo or tripo", "mixamo").option("--rig-type <type>", "Rig type override passed through to Tripo").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
886
880
  try {
887
881
  const ctx = createContext(this);
882
+ const params = {
883
+ out_format: options.format,
884
+ spec: options.spec
885
+ };
886
+ if (options.rigType) params.rig_type = options.rigType;
888
887
  const data = await ctx.client.post("/api/process3d", {
889
888
  task_id: options.taskId,
890
889
  operation: "rig",
891
- params: {
892
- format: options.format,
893
- spec: options.spec
894
- }
890
+ params
895
891
  });
896
892
  const localPath = await saveProcess3dOutput(data, "rig", options.outputDir, options.format);
897
893
  if (localPath) data.local_path = localPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doufunao123/asset-gateway",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "Universal asset generation gateway CLI",
5
5
  "type": "module",
6
6
  "bin": {