@@ -22,6 +22,7 @@ import {
2222 resolveWatermark ,
2323 ASYNC_FLAG ,
2424 CONCURRENT_FLAG ,
25+ redactDataUri ,
2526} from "bailian-cli-core" ;
2627import { poll } from "bailian-cli-runtime" ;
2728import { downloadFile } from "bailian-cli-runtime" ;
@@ -31,10 +32,15 @@ import { resolveImageSize } from "bailian-cli-runtime";
3132import { join } from "path" ;
3233import { BOOL_FLAG_PROMPT_EXTEND_CLI_TRUE , BOOL_FLAG_WATERMARK } from "bailian-cli-runtime" ;
3334
34- const SYNC_MODEL_PREFIXES = [ "qwen-image-2.0" , "qwen-image-max" ] ;
35+ const SYNC_MODEL_PREFIXES = [ "qwen-image-2.0" , "qwen-image-max" , "wan2.7-image" ] ;
36+ const PROMPT_EXTEND_DEFAULT_PREFIXES = [ "qwen-image-2.0" , "qwen-image-max" ] ;
3537
3638function isSyncModel ( model : string ) : boolean {
37- return SYNC_MODEL_PREFIXES . some ( ( p ) => model . startsWith ( p ) ) ;
39+ return SYNC_MODEL_PREFIXES . some ( ( prefix ) => model . startsWith ( prefix ) ) ;
40+ }
41+
42+ function enablesPromptExtendByDefault ( model : string ) : boolean {
43+ return PROMPT_EXTEND_DEFAULT_PREFIXES . some ( ( prefix ) => model . startsWith ( prefix ) ) ;
3844}
3945
4046const EDIT_FLAGS = {
@@ -98,7 +104,7 @@ const EDIT_FLAGS = {
98104type EditFlags = ParsedFlags < typeof EDIT_FLAGS > ;
99105
100106export default defineCommand ( {
101- description : "Edit an existing image with text instructions (Qwen-Image)" ,
107+ description : "Edit an existing image with text instructions (Qwen-Image / Wan 2.7 )" ,
102108 auth : "apiKey" ,
103109 usageArgs : "--image <url> --prompt <text> [flags]" ,
104110 flags : EDIT_FLAGS ,
@@ -107,6 +113,7 @@ export default defineCommand({
107113 '--image https://example.com/logo.png --prompt "Change color to blue" --n 3' ,
108114 '--image ./a.png --image ./b.png --prompt "Merge two images into one collage"' ,
109115 '--image https://example.com/photo.png --prompt "Remove the person" --model qwen-image-2.0-pro' ,
116+ '--image ./photo.png --prompt "Change the style" --model wan2.7-image' ,
110117 '--image ./photo.png --prompt "Replace the background with a beach" --watermark false' ,
111118 ] ,
112119 async run ( ctx ) {
@@ -125,13 +132,13 @@ export default defineCommand({
125132
126133 // Auto-upload local files (resolve all images in parallel)
127134 const resolvedImages = await Promise . all (
128- rawImages . map ( ( img ) => ctx . client . uploadFile ( img , model ) ) ,
135+ rawImages . map ( ( image ) => ctx . client . resolveImageInput ( image , model ) ) ,
129136 ) ;
130137 const n = flags . n ?? 1 ;
131138
132139 const promptExtend = resolveBooleanFlag (
133140 flags . promptExtend ,
134- useSync ? true : undefined ,
141+ enablesPromptExtendByDefault ( model ) ? true : undefined ,
135142 "prompt-extend" ,
136143 ) ;
137144
@@ -169,7 +176,18 @@ export default defineCommand({
169176 const format = detectOutputFormat ( settings . output ) ;
170177
171178 if ( settings . dryRun ) {
172- emitResult ( { request : body , mode : useSync ? "sync" : "async" } , format ) ;
179+ const previewBody = {
180+ ...body ,
181+ input : {
182+ messages : body . input . messages . map ( ( message ) => ( {
183+ ...message ,
184+ content : message . content . map ( ( item ) =>
185+ item . image ? { ...item , image : redactDataUri ( item . image ) } : item ,
186+ ) ,
187+ } ) ) ,
188+ } ,
189+ } ;
190+ emitResult ( { request : previewBody , mode : useSync ? "sync" : "async" } , format ) ;
173191 return ;
174192 }
175193
0 commit comments