bailian-cli-runtime 0.0.0-beta-c188441-20260708 → 0.0.0-beta-49095c3-20260709

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.mjs +1 -1
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -49,7 +49,7 @@ ${pt()}\nRun: ${R} auth status — to check credentials.`,{cause:t}),R);if(t ins
49
49
  `),St.forEach((t,n)=>{process.stderr.write(`${e.dim(String(n+1))} ${t}\n`)}),process.stderr.write(`
50
50
  `)}function Tt(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function Et(e){try{ct()}catch(t){B(t,e)}process.on(`SIGINT`,()=>{process.stderr.write(`
51
51
  Interrupted. Exiting.
52
- `),p(500).finally(()=>process.exit(130))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e})}function Dt(e,r){let l=new je(e,r.binName),{binName:f,version:m,npmPackage:h,clientName:g}=r,_={binName:f,version:m,npmPackage:h,clientName:g};Et(f);let v=tt([it,rt,nt,at]);function x(e,n){if(l.printHelp(e,process.stderr),e.length>0)return;let r=!1;try{let e=d(c(Ee(n,{...i,...a,...t})));r=!!(e.apiKey||e.console)}catch{}r?wt():Ct(f)}async function S(e){let t=Me(e,l);switch(t.kind){case`version`:process.stdout.write(`${f} ${m}\n`);return;case`help`:x(t.path,e);return;case`usageError`:B(t.error,f);return;case`run`:try{let e=u(t.command),r=Ee(t.rest,{...i,...e,...t.command.flags}),a=Tt(r,[...Object.keys(i),...Object.keys(e)]),l=Tt(r,Object.keys(t.command.flags??{})),d=t.command.validate?.(l);if(d)throw new o(d);let f=c(a),m=s(f);await v({identity:_,path:t.path,command:t.command,flags:l,settings:m,sources:f,configStore:()=>b(),authStore:()=>y(f),client:new n({identity:_,settings:m,baseUrl:E(f)})}),await p(1e3)}catch(e){if(e instanceof o&&t.rest.length===0){l.printHelp(t.path,process.stderr);return}await p(1e3),B(e,f)}return}}return{run(e=process.argv.slice(2)){return S(e).catch(e=>p(1e3).finally(()=>B(e,f)))}}}const Ot=`0.0.0-beta-c188441-20260708`;function kt(e,t){process.stdout.write(m(e,t)+`
52
+ `),p(500).finally(()=>process.exit(130))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e})}function Dt(e,r){let l=new je(e,r.binName),{binName:f,version:m,npmPackage:h,clientName:g}=r,_={binName:f,version:m,npmPackage:h,clientName:g};Et(f);let v=tt([it,rt,nt,at]);function x(e,n){if(l.printHelp(e,process.stderr),e.length>0)return;let r=!1;try{let e=d(c(Ee(n,{...i,...a,...t})));r=!!(e.apiKey||e.console)}catch{}r?wt():Ct(f)}async function S(e){let t=Me(e,l);switch(t.kind){case`version`:process.stdout.write(`${f} ${m}\n`);return;case`help`:x(t.path,e);return;case`usageError`:B(t.error,f);return;case`run`:try{let e=u(t.command),r=Ee(t.rest,{...i,...e,...t.command.flags}),a=Tt(r,[...Object.keys(i),...Object.keys(e)]),l=Tt(r,Object.keys(t.command.flags??{})),d=t.command.validate?.(l);if(d)throw new o(d);let f=c(a),m=s(f);await v({identity:_,path:t.path,command:t.command,flags:l,settings:m,sources:f,configStore:()=>b(),authStore:()=>y(f),client:new n({identity:_,settings:m,baseUrl:E(f)})}),await p(1e3)}catch(e){if(e instanceof o&&t.rest.length===0){l.printHelp(t.path,process.stderr);return}await p(1e3),B(e,f)}return}}return{run(e=process.argv.slice(2)){return S(e).catch(e=>p(1e3).finally(()=>B(e,f)))}}}const Ot=`0.0.0-beta-49095c3-20260709`;function kt(e,t){process.stdout.write(m(e,t)+`
53
53
  `)}function At(e){process.stdout.write(e+`
54
54
  `)}function jt(e,t,{gap:n=2}={}){let r=e.map((e,n)=>{let r=e.length;for(let e of t){let t=e[n]??``;t.length>r&&(r=t.length)}return r}),i=` `.repeat(n),a=e=>e.map((e,t)=>(e??``).padEnd(r[t])).join(i),o=[];o.push(a(e));for(let e of t)o.push(a(e));return o}const Mt=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function Nt(e){let t=process.stderr.isTTY,n=0,r=null,i=e;return{start(){t&&(r=setInterval(()=>{process.stderr.write(`\r${Mt[n%Mt.length]} ${i}`),n++},80))},update(e){i=e},stop(e){r&&=(clearInterval(r),null),t&&(process.stderr.write(`\r\x1B[K`),e&&process.stderr.write(`${e}\n`))}}}function Pt(e,t=``){let n=process.stderr.isTTY;return{update(r){if(!n)return;let i=Math.min(1,r/e),a=Math.round(30*i),o=30-a,s=`█`.repeat(a)+`░`.repeat(o),c=`${Math.round(i*100)}%`;process.stderr.write(`\r${t} ${s} ${c}`)},finish(){n&&process.stderr.write(`
55
55
  `)}}}function Ft(e){return e>=11904&&e<=40959||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=131072&&e<=195103}function It(e){let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=Ft(e)?2:1}return t}function Lt(e,t){let n=t-It(e);return n>0?e+` `.repeat(n):e}async function Rt(t,n,i){let a=Date.now()+i.timeoutSec*1e3,o=Nt(`Polling...`);n.quiet||o.start();try{for(;Date.now()<a;){let a=await t.requestJson({path:i.url});if(i.getStatus&&!n.quiet&&o.update(`Status: ${i.getStatus(a)}`),i.isComplete(a))return o.stop(`Done.`),a;if(i.isFailed(a)){o.stop(`Failed.`),n.verbose&&process.stderr.write(`[verbose] Task response: ${JSON.stringify(a,null,2)}\n`);let t=i.getErrorMessage?.(a);throw new e(t?`Task failed: ${t}`:`Task failed.`,r.GENERAL,t?void 0:`Use --verbose to see full API response details.`)}await new Promise(e=>setTimeout(e,i.intervalSec*1e3))}}finally{o.stop()}throw new e(`Polling timed out.`,r.TIMEOUT,`Try increasing --timeout or check task status manually.`)}async function zt(t,n,i){let a=await fetch(t,{headers:j()});if(!a.ok)throw new e(`Download failed: HTTP ${a.status}`,r.GENERAL);let o=Number(a.headers.get(`content-length`)||0),s=a.body?.getReader();if(!s)throw new e(`No response body`,r.GENERAL);ae(re(n),{recursive:!0});let c=ie(n),l=o>0&&!i?.quiet?Pt(o,`Downloading`):null,u=0,d=!1;try{let e=new Promise((e,t)=>{c.on(`error`,t)});for(;;){let{done:t,value:n}=await Promise.race([s.read(),e]);if(t)break;c.write(n)||await new Promise(e=>c.once(`drain`,()=>e())),u+=n.byteLength,l?.update(u)}d=!0}finally{if(s.releaseLock(),l?.finish(),await new Promise((e,t)=>{c.on(`finish`,e),c.on(`error`,t),c.end()}),!d)try{se(n)}catch{}}return{size:u}}function Bt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function Vt(e){return Math.max(1,e.concurrent??1)}async function Ht(e,t,n,r=`requests`){if(e<=1)return[await n(0)];t.quiet||process.stderr.write(`[Concurrent: ${e} ${r}]\n`);let i=Array.from({length:e},(e,t)=>n(t));return Promise.all(i)}async function Ut(e,t,n){return Promise.all(e.map(({url:e,destPath:r})=>t(e,r,n).then(()=>r)))}const Wt={"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},Gt={"16:9":`1664*928`,"4:3":`1472*1104`,"1:1":`1328*1328`,"3:4":`1104*1472`,"9:16":`928*1664`};function Kt(e,t){if(e)return(t?Wt:Gt)[e]??e}const qt=`Enable watermark (true/false). Omit flag to use CLI default (true).`,Jt=`Enable prompt extend (true/false). Omit flag to use CLI default (true).`,Yt=`Enable prompt extend (true/false). Omit flag: true for qwen-image sync; parameter omitted on async models (API default).`,Xt=`Enable prompt extend (true/false). Omit flag to omit the parameter (DashScope default).`;var V=class extends Error{code;step;details;constructor(e,t,n){super(t),this.name=`PipelineError`,this.code=e,this.step=n?.step,this.details=n?.details}toJSON(){return{code:this.code,message:this.message,...this.step?{step:this.step}:{},...this.details?{details:this.details}:{}}}};function Zt(e,t){return e instanceof V?e:new V(`step_execution_error`,e instanceof Error?e.message:String(e),{step:t})}var Qt=class{handlers=new Map;outputSchemas=new Map;registerStep(e,t,n){this.handlers.set(e,t),n&&this.outputSchemas.set(e,n)}executeStep(e,t,n){let r=this.handlers.get(e);if(!r)throw new V(`unknown_step`,`Unknown step type: ${e}`,{details:{available:this.listSteps()}});return r(t,n)}hasStep(e){return this.handlers.has(e)}listSteps(){return Array.from(this.handlers.keys()).sort()}getOutputSchema(e){return this.outputSchemas.get(e)}};const $t=new Qt;function en(){return $t}function tn(e,t,n,r){let i,a;n instanceof Qt?(i=n,a=r):(i=$t,a=n??r),i.registerStep(e,t,a)}function nn(){let e={flags:{},file:S(),env:process.env},t={...s(e),output:`json`,outputExplicit:!0,quiet:!0},r={binName:`bl`,version:`0.0.0-dev`,npmPackage:`bailian-cli`,clientName:`bailian-cli`},i;try{i=C(e)}catch{}return{client:new n({identity:r,settings:t,baseUrl:E(e),apiCred:i}),settings:t}}const rn=[`download`,`out-dir`,`output`];function an(e){return e.startsWith(`./`)||e.startsWith(`../`)}function on(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))typeof a==`string`&&an(a)?(n[i]=me(t,a),r.push(i)):n[i]=a;return{input:n,resolvedKeys:r}}async function sn(e,t,n){let r=[];for(let i of t){let t=e[i];typeof t==`string`&&(await de(t).then(()=>!0,()=>!1)||r.push(`Step "${n}" input "${i}" references file that does not exist: ${t}`))}return r}function cn(e){if(e===void 0)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m)?$/);if(!t)return;let n=Number(t[1]);if(!Number.isFinite(n)||n<=0)return;let r=t[2]??`s`;return r===`ms`?n/1e3:r===`m`?n*60:n}function H(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function U(e,t){if(Array.isArray(e)){e.forEach(e=>U(e,t));return}if(H(e)){`$from`in e&&typeof e.$from==`string`&&t.add(e.$from);for(let n of Object.values(e))U(n,t)}}async function ln(e,t){let n=[];for(let r of e)for(let[e,i]of Object.entries(r.input)){if(rn.includes(e)||typeof i!=`string`||!an(i))continue;let a=me(t,i);await de(a).then(()=>!0,()=>!1)||n.push(`Step "${r.id}" input "${e}" references file that does not exist: ${a}`)}return n}async function un(e,t,n){if(!t.message)throw new V(`missing_input`,`text/chat requires 'message' input`,{step:`text/chat`});let r=t.model||`qwen3.7-max`,i=[];t.system&&i.push({role:`system`,content:t.system}),i.push({role:`user`,content:t.message});let a={model:r,messages:i,max_tokens:t[`max-tokens`]??4096,stream:!1};t.temperature!==void 0&&(a.temperature=t.temperature),t[`top-p`]!==void 0&&(a.top_p=t[`top-p`]),t[`enable-thinking`]&&(a.enable_thinking=!0,t[`thinking-budget`]!==void 0&&(a.thinking_budget=t[`thinking-budget`]));let o=l();return await e.client.requestJson({path:o,method:`POST`,body:a,timeout:n.blRequestTimeoutSeconds,signal:n.signal})}async function dn(e,t,n){let r=t.model||`qwen3-vl-plus`,i=Array.isArray(t.image)?t.image:t.image?[t.image]:[],a=t.video?`Describe the video.`:`Describe the image.`,o=t.prompt||a,s=[];if(t.video){let i=t.video;v(i)&&(i=await e.client.uploadFile(i,r,{signal:n.signal})),s.push({type:`video_url`,video_url:{url:i}})}for(let t of i){let i=t;v(t)&&(i=await e.client.uploadFile(t,r,{signal:n.signal})),s.push({type:`image_url`,image_url:{url:i}})}s.push({type:`text`,text:o});let c={model:r,messages:[{role:`user`,content:s}]},u=l();return await e.client.requestJson({path:u,method:`POST`,body:c,signal:n.signal})}const fn=[`qwen-image-2.0`,`qwen-image-max`];function pn(e){return fn.some(t=>e.startsWith(t))}async function mn(e,t,n){if(!t.prompt)throw new V(`missing_input`,`image/generate requires 'prompt' input`,{step:`image/generate`});let r=t.model||`qwen-image-2.0`,i=pn(r),a=t.n??1,o=w(t[`prompt-extend`],i?!0:void 0,`prompt-extend`),s={model:r,input:{messages:[{role:`user`,content:[{text:t.prompt}]}]},parameters:{size:Kt(t.size,i),n:a,seed:t.seed,prompt_extend:o,watermark:D(t.watermark),negative_prompt:t[`negative-prompt`]||void 0}};if(i){let r=_(),i=await e.client.requestJson({path:r,method:`POST`,body:s,signal:n.signal}),a=i.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),o=await gn(a,t[`out-dir`],t[`out-prefix`]);return{urls:a,request_id:i.request_id,...o?{saved:o}:{}}}else{let r=g(),i=(await e.client.requestJson({path:r,method:`POST`,body:s,async:!0,signal:n.signal})).output.task_id,a=await xn(e,i,n),o=await gn(Array.isArray(a.urls)?a.urls:[],t[`out-dir`],t[`out-prefix`]);return o&&(a.saved=o),a}}async function hn(e,t,n){if(!t.prompt)throw new V(`missing_input`,`image/edit requires 'prompt' input`,{step:`image/edit`});let r=Array.isArray(t.image)?t.image:t.image?[t.image]:[],i=t.model||`qwen-image-2.0`,a=pn(i),o=t.n??1,s=w(t[`prompt-extend`],a?!0:void 0,`prompt-extend`),c=[];for(let t of r){let r=t;v(t)&&(r=await e.client.uploadFile(t,i,{signal:n.signal})),c.push({image:r})}c.push({text:t.prompt});let l={model:i,input:{messages:[{role:`user`,content:c}]},parameters:{size:Kt(t.size,a),n:o,seed:t.seed,prompt_extend:s,watermark:D(t.watermark),negative_prompt:t[`negative-prompt`]||void 0}};if(a){let r=_(),i=await e.client.requestJson({path:r,method:`POST`,body:l,signal:n.signal}),a=i.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),o=await gn(a,t[`out-dir`],t[`out-prefix`]);return{urls:a,request_id:i.request_id,...o?{saved:o}:{}}}else{let r=g(),i=(await e.client.requestJson({path:r,method:`POST`,body:l,async:!0,signal:n.signal})).output.task_id,a=await xn(e,i,n),o=await gn(Array.isArray(a.urls)?a.urls:[],t[`out-dir`],t[`out-prefix`]);return o&&(a.saved=o),a}}async function gn(e,t,n){if(!t||e.length===0)return;await fe(t,{recursive:!0});let r=n&&n.length>0?n:`image`,i=e.length===1?[{url:e[0],destPath:pe(t,`${r}.png`)}]:e.map((e,n)=>({url:e,destPath:pe(t,`${r}_${String(n+1).padStart(3,`0`)}.png`)})),a=[];for(let{url:e,destPath:t}of i)await zt(e,t,{quiet:!0}),a.push(t);return a}async function _n(e,t,n){if(!t.prompt)throw new V(`missing_input`,`video/generate requires 'prompt' input`,{step:`video/generate`});let r=t.model||(t.image?`happyhorse-1.1-i2v`:`happyhorse-1.1-t2v`),i;t.image&&(i=v(t.image)?await e.client.uploadFile(t.image,r,{signal:n.signal}):t.image);let a={model:r,input:{prompt:t.prompt,negative_prompt:t[`negative-prompt`]||void 0,...i?{media:[{type:`first_frame`,url:i}]}:{}},parameters:{resolution:t.resolution||void 0,ratio:t.ratio||void 0,duration:t.duration,prompt_extend:w(t[`prompt-extend`],void 0,`prompt-extend`),watermark:D(t.watermark),seed:t.seed}};A(a.parameters);let o=M(),s=(await e.client.requestJson({path:o,method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Sn(e,s,(t[`poll-interval`]??10)*1e3,(n.timeoutSeconds??900)*1e3,n)}async function vn(e,t,n){let r=t.text;if(!r&&t[`text-file`]){let{readFileSync:e}=await import(`node:fs`);r=e(t[`text-file`],`utf-8`).trim()}if(!r)throw new V(`missing_input`,`speech/synthesize requires 'text' input`,{step:`speech/synthesize`});let i=t.model||`cosyvoice-v3-flash`,a={model:i,input:{text:r,voice:t.voice,format:t.format,sample_rate:t[`sample-rate`],volume:t.volume,rate:t.rate,pitch:t.pitch,seed:t.seed,language_hints:t.language?[t.language]:void 0,instruction:t.instruction,enable_ssml:t[`enable-ssml`]}};A(a.input);let o=k(),s=await e.client.requestJson({path:o,method:`POST`,body:a,signal:n.signal});return{audio_url:s.output.audio.url,url_expires_at:s.output.audio.expires_at,model:i,voice:t.voice,request_id:s.request_id}}async function yn(e,t,n){let r=Array.isArray(t.url)?t.url:t.url?[t.url]:[];if(r.length===0)throw new V(`missing_input`,`speech/recognize requires 'url' input`,{step:`speech/recognize`});let i=[];for(let a of r)v(a)?i.push(await e.client.uploadFile(a,t.model||`fun-asr`,{signal:n.signal})):i.push(a);let a={model:t.model||`fun-asr`,input:{file_urls:i},parameters:{channel_id:t[`channel-id`]===void 0?void 0:[t[`channel-id`]],language_hints:t.language?[t.language]:void 0,diarization_enabled:t.diarization,speaker_count:t[`speaker-count`],vocabulary_id:t[`vocabulary-id`]}};A(a.parameters);let o=O(),s=(await e.client.requestJson({path:o,method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Sn(e,s,(t[`poll-interval`]??2)*1e3,(n.timeoutSeconds??300)*1e3,n)}function bn(e){let{output:t,request_id:n,usage:r}=e,i={task_id:t.task_id,task_status:t.task_status,request_id:n};if(t.video_url&&(i.video_url=t.video_url),t.choices){let e=t.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);e.length>0&&(i.urls=e)}if(t.results){let e=t.results.map(e=>e.url).filter(Boolean);e.length>0&&!i.urls&&(i.urls=e)}return t.task_metrics&&(i.task_metrics=t.task_metrics),r&&(i.usage=r),i}async function xn(e,t,n){return await Sn(e,t,3e3,e.settings.timeout*1e3,n)}async function Sn(e,t,n,r,i){let a=Date.now(),o=0;for(;;){if(i?.signal?.aborted)throw new V(`aborted`,`Task polling was aborted`,{details:{taskId:t}});await Cn(n,i?.signal),o++;let s=ee(t),c=await e.client.requestJson({path:s,method:`GET`,signal:i?.signal}),l=c.output.task_status;if(l===`SUCCEEDED`)return bn(c);if(l===`FAILED`)throw new V(`async_task_failed`,c.output.message||c.output.code||`Task failed`,{details:{taskId:t,data:c}});let u=Date.now()-a;if(await i?.emitEvent?.({type:`step.polling`,timestamp:new Date().toISOString(),status:`running`,taskId:t,taskStatus:l,elapsedMs:u,pollAttempt:o}),u>r)throw new V(`async_poll_timeout`,`Task ${t} timed out after ${Math.round(r/1e3)}s`,{details:{taskId:t,timeoutMs:r,pollAttempts:o}})}}function Cn(e,t){return t?new Promise((n,r)=>{let i=setTimeout(()=>{o(),n()},e),a=()=>{o(),r(new V(`aborted`,`Poll delay was aborted`))},o=()=>{clearTimeout(i),t.removeEventListener(`abort`,a)};t.aborted?a():t.addEventListener(`abort`,a,{once:!0})}):new Promise(t=>setTimeout(t,e))}const wn={"text/chat":(e,t,n)=>un(e,t,n),"vision/describe":(e,t,n)=>dn(e,t,n),"image/generate":(e,t,n)=>mn(e,t,n),"image/edit":(e,t,n)=>hn(e,t,n),"video/generate":(e,t,n)=>_n(e,t,n),"speech/synthesize":(e,t,n)=>vn(e,t,n),"speech/recognize":(e,t,n)=>yn(e,t,n)},Tn={"image/generate":e=>({data:e,artifacts:kn(e),warnings:[],metadata:{}}),"image/edit":e=>({data:e,artifacts:kn(e),warnings:[],metadata:{}}),"video/generate":e=>({data:e,artifacts:kn(e),warnings:[],metadata:{}}),"speech/synthesize":e=>({data:e,artifacts:An(e,`audio`),warnings:[],metadata:{}}),"speech/recognize":e=>({data:e,artifacts:An(e,`transcript`),warnings:[],metadata:{}})},En={"text/chat":{description:`LLM text completion via chat API`,paths:[{path:`/data/choices/0/message/content`,description:`Generated text content`},{path:`/data/choices/0/message/role`,description:`Message role (assistant)`},{path:`/data/usage/total_tokens`,description:`Total token usage`}]},"vision/describe":{description:`Multimodal vision understanding (image/video to text)`,paths:[{path:`/data/choices/0/message/content`,description:`Generated description text`},{path:`/data/choices/0/message/role`,description:`Message role (assistant)`},{path:`/data/usage/total_tokens`,description:`Total token usage`}]},"image/generate":{description:`Text-to-image generation`,paths:[{path:`/data/urls`,description:`Array of generated image URLs`},{path:`/data/urls/0`,description:`First generated image URL`},{path:`/data/task_id`,description:`Async task ID (if applicable)`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"image/edit":{description:`Image editing with reference image(s)`,paths:[{path:`/data/urls`,description:`Array of generated image URLs`},{path:`/data/urls/0`,description:`First generated image URL`},{path:`/data/task_id`,description:`Async task ID (if applicable)`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"video/generate":{description:`Video generation (text-to-video or image-to-video)`,paths:[{path:`/data/video_url`,description:`Generated video URL`},{path:`/data/task_id`,description:`Async task ID`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"speech/synthesize":{description:`Text-to-speech synthesis`,paths:[{path:`/data/audio_url`,description:`Generated audio URL`},{path:`/data/url_expires_at`,description:`Audio URL expiration time`},{path:`/artifacts/0/url`,description:`First artifact URL`}]},"speech/recognize":{description:`Speech recognition (ASR)`,paths:[{path:`/data/text`,description:`Full transcribed text`},{path:`/data/task_id`,description:`Async task ID`},{path:`/artifacts/0/taskId`,description:`Task ID from artifact`}]}};function Dn(e){for(let t of Object.keys(wn))tn(t,async(e,n)=>await On(t,e,n),e,En[t])}async function On(e,t,n){if(n.dryRun)return{metadata:{dryRun:!0,step:e,plannedInput:t},warnings:[{code:`dry_run_skipped`,message:`Step ${e} was not executed in dry-run mode`}]};let r=wn[e];if(!r)throw Error(`No direct API handler registered for step: ${e}`);let i=await r(n.blEnv??nn(),t,n),a=Tn[e];return a?a(i):{data:i,warnings:[],metadata:{}}}function kn(e){if(!H(e))return;let t=[],n=W(e.task_id)??W(e.taskId);for(let r of Nn(e.urls))t.push({url:r,taskId:n,kind:Pn(r)});for(let r of Nn(e.saved))t.push({path:r,taskId:n,kind:Fn(r)});let r=W(e.video_url)??W(e.videoUrl);r&&t.push({url:r,taskId:n,kind:`video`});let i=W(e.saved);if(i&&t.push({path:i,taskId:n,kind:Fn(i)}),Array.isArray(e.videos))for(let n of e.videos){if(!H(n))continue;let e=W(n.task_id)??W(n.taskId),r=W(n.video_url)??W(n.videoUrl),i=W(n.saved);r&&t.push({url:r,taskId:e,kind:`video`}),i&&t.push({path:i,taskId:e,kind:`video`})}let a=Array.isArray(e.task_ids)?e.task_ids.map(W).filter(Mn):[];for(let e of a)t.push({taskId:e,kind:`task`});return t.length===0&&n&&t.push({taskId:n,kind:`task`}),t.length>0?t:void 0}function An(e,t){if(!H(e))return;let n=[],r=W(e.task_id)??W(e.taskId),i=[W(e.url),W(e.audio_url),W(e.audioUrl),W(e.output_url),W(e.outputUrl)].filter(Mn);for(let e of i)n.push({url:e,taskId:r,kind:t});let a=[W(e.saved),W(e.path),W(e.output_path),W(e.outputPath)].filter(Mn);for(let e of a)n.push({path:e,taskId:r,kind:t});return n.length===0&&r&&n.push({taskId:r,kind:`task`}),n.length>0?jn(n):void 0}function jn(e){let t=new Set,n=[];for(let r of e){let e=`${r.kind??``}:${r.taskId??``}:${r.url??``}:${r.path??``}`;t.has(e)||(t.add(e),n.push(r))}return n}function Mn(e){return typeof e==`string`}function W(e){return typeof e==`string`&&e.length>0?e:void 0}function Nn(e){return Array.isArray(e)?e.map(W).filter(Mn):[]}function Pn(e){try{return Fn(new URL(e).pathname)}catch{return`artifact`}}function Fn(e){let t=e.toLowerCase();return t.endsWith(`.mp4`)||t.endsWith(`.mov`)||t.endsWith(`.webm`)?`video`:t.endsWith(`.png`)||t.endsWith(`.jpg`)||t.endsWith(`.jpeg`)||t.endsWith(`.webp`)?`image`:`artifact`}var In=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),Ln=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=In();var n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;let o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),G=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let t=In(),n=Ln();var r=In();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=Ln();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(ee(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bailian-cli-runtime",
3
- "version": "0.0.0-beta-c188441-20260708",
3
+ "version": "0.0.0-beta-49095c3-20260709",
4
4
  "description": "Runtime framework for bailian-cli (createCli, registry, args, output, pipeline). See https://www.npmjs.com/package/bailian-cli for usage.",
5
5
  "homepage": "https://bailian.console.aliyun.com/cli",
6
6
  "bugs": {
@@ -30,7 +30,7 @@
30
30
  "boxen": "^8.0.1",
31
31
  "chalk": "^5.6.2",
32
32
  "undici": "^8.4.1",
33
- "bailian-cli-core": "0.0.0-beta-c188441-20260708"
33
+ "bailian-cli-core": "0.0.0-beta-49095c3-20260709"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@clack/prompts": "^0.7.0",