@doufunao123/asset-gateway 0.8.1 → 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/dist/index.js +47 -12
- 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) {
|
|
@@ -527,7 +527,7 @@ async function saveOutput(result, assetType, outputDir) {
|
|
|
527
527
|
function createGenerateCommand() {
|
|
528
528
|
const command = new Command3("generate").description("Generate assets via the gateway");
|
|
529
529
|
command.addCommand(
|
|
530
|
-
new Command3("image").description("Generate an image from a text prompt").requiredOption("--prompt <text>", "Image description prompt").option("--provider <id>", "Provider to use").option("--transparent", "Request transparent background").option("--model <model>", "Model to use").option("--size <size>", "Image size (e.g. 1024x1024)").option("--input <url>", "Input image URL for editing (Gemini/Grok)").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
|
|
530
|
+
new Command3("image").description("Generate an image from a text prompt").requiredOption("--prompt <text>", "Image description prompt").option("--provider <id>", "Provider to use").option("--transparent", "Request transparent background").option("--model <model>", "Model to use").option("--size <size>", "Image size (e.g. 1024x1024)").option("--input <url>", "Input image URL for editing (Gemini/Grok)").option("--ref <urls...>", "Reference image URLs for multi-image editing (repeatable)").option("--edit-mode <mode>", "Edit mode: edit, inpaint, restyle, expand").option("--session <id>", "Session ID for multi-turn editing").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
|
|
531
531
|
try {
|
|
532
532
|
const ctx = createContext(this);
|
|
533
533
|
const body = {
|
|
@@ -539,6 +539,9 @@ function createGenerateCommand() {
|
|
|
539
539
|
if (options.model) body.model = options.model;
|
|
540
540
|
if (options.size) body.size = options.size;
|
|
541
541
|
if (options.input) body.input_file = options.input;
|
|
542
|
+
if (options.ref && options.ref.length > 0) body.reference_images = options.ref;
|
|
543
|
+
if (options.editMode) body.edit_mode = options.editMode;
|
|
544
|
+
if (options.session) body.session_id = options.session;
|
|
542
545
|
const data = await ctx.client.post("/api/generate", body);
|
|
543
546
|
const localPath = await saveOutput(data, "image", options.outputDir);
|
|
544
547
|
if (localPath) data.local_path = localPath;
|
|
@@ -574,8 +577,10 @@ function createGenerateCommand() {
|
|
|
574
577
|
asset_type: "audio",
|
|
575
578
|
prompt: options.prompt
|
|
576
579
|
};
|
|
577
|
-
|
|
578
|
-
if (options.
|
|
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;
|
|
579
584
|
const data = await ctx.client.post("/api/generate", body);
|
|
580
585
|
const localPath = await saveOutput(data, "audio", options.outputDir);
|
|
581
586
|
if (localPath) data.local_path = localPath;
|
|
@@ -585,6 +590,26 @@ function createGenerateCommand() {
|
|
|
585
590
|
}
|
|
586
591
|
})
|
|
587
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
|
+
);
|
|
588
613
|
command.addCommand(
|
|
589
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) {
|
|
590
615
|
try {
|
|
@@ -836,7 +861,7 @@ async function saveProcess3dOutput(data, operation, outputDir, format) {
|
|
|
836
861
|
function createProcess3dCommand() {
|
|
837
862
|
const command = new Command6("process3d").description("3D model post-processing via Tripo pipeline");
|
|
838
863
|
command.addCommand(
|
|
839
|
-
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) {
|
|
864
|
+
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) {
|
|
840
865
|
try {
|
|
841
866
|
const ctx = createContext(this);
|
|
842
867
|
const params = {
|
|
@@ -844,6 +869,10 @@ function createProcess3dCommand() {
|
|
|
844
869
|
};
|
|
845
870
|
if (options.quad) params.quad = true;
|
|
846
871
|
if (options.faceLimit) params.face_limit = Number(options.faceLimit);
|
|
872
|
+
if (options.packUv) params.pack_uv = true;
|
|
873
|
+
if (options.bake) params.bake = true;
|
|
874
|
+
if (options.textureFormat) params.texture_format = options.textureFormat;
|
|
875
|
+
if (options.forceSymmetry) params.force_symmetry = true;
|
|
847
876
|
const data = await ctx.client.post("/api/process3d", {
|
|
848
877
|
task_id: options.taskId,
|
|
849
878
|
operation: "convert",
|
|
@@ -858,13 +887,17 @@ function createProcess3dCommand() {
|
|
|
858
887
|
})
|
|
859
888
|
);
|
|
860
889
|
command.addCommand(
|
|
861
|
-
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) {
|
|
890
|
+
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) {
|
|
862
891
|
try {
|
|
863
892
|
const ctx = createContext(this);
|
|
864
893
|
const params = {};
|
|
865
894
|
if (options.prompt) params.prompt = options.prompt;
|
|
895
|
+
if (options.styleImage) params.style_image = options.styleImage;
|
|
866
896
|
if (options.pbr) params.pbr = true;
|
|
867
|
-
if (options.quality) params.
|
|
897
|
+
if (options.quality) params.texture_quality = options.quality;
|
|
898
|
+
if (options.textureAlignment) params.texture_alignment = options.textureAlignment;
|
|
899
|
+
if (options.bake) params.bake = true;
|
|
900
|
+
if (options.textureVersion) params.model_version = options.textureVersion;
|
|
868
901
|
const data = await ctx.client.post("/api/process3d", {
|
|
869
902
|
task_id: options.taskId,
|
|
870
903
|
operation: "texture",
|
|
@@ -879,16 +912,18 @@ function createProcess3dCommand() {
|
|
|
879
912
|
})
|
|
880
913
|
);
|
|
881
914
|
command.addCommand(
|
|
882
|
-
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) {
|
|
915
|
+
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) {
|
|
883
916
|
try {
|
|
884
917
|
const ctx = createContext(this);
|
|
918
|
+
const params = {
|
|
919
|
+
out_format: options.format,
|
|
920
|
+
spec: options.spec
|
|
921
|
+
};
|
|
922
|
+
if (options.rigType) params.rig_type = options.rigType;
|
|
885
923
|
const data = await ctx.client.post("/api/process3d", {
|
|
886
924
|
task_id: options.taskId,
|
|
887
925
|
operation: "rig",
|
|
888
|
-
params
|
|
889
|
-
format: options.format,
|
|
890
|
-
spec: options.spec
|
|
891
|
-
}
|
|
926
|
+
params
|
|
892
927
|
});
|
|
893
928
|
const localPath = await saveProcess3dOutput(data, "rig", options.outputDir, options.format);
|
|
894
929
|
if (localPath) data.local_path = localPath;
|