bailian-cli 1.1.1 → 1.1.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.
- package/dist/bailian.mjs +4 -4
- package/package.json +2 -2
package/dist/bailian.mjs
CHANGED
|
@@ -127,11 +127,11 @@ This process keeps the local port open for the console; press Ctrl+C when finish
|
|
|
127
127
|
`),process.exit(1)),a=e}let o=n.model||`happyhorse-1.0-video-edit`,s=f(e.output),c=await O(e),l=[{type:`video`,url:await k(r,c.token,o)}],u=n.refImage;if(u){let e=u.split(`,`).map(e=>e.trim()).filter(Boolean);for(let t of e){let e=await k(t,c.token,o);l.push({type:`reference_image`,url:e})}}let d=n.noPromptExtend===!0?!1:n.promptExtend===!0?!0:void 0,p={model:o,input:{prompt:a||void 0,negative_prompt:n.negativePrompt||void 0,media:l},parameters:{resolution:n.resolution||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,audio_setting:n.audioSetting||void 0,prompt_extend:d,watermark:n.watermark===!0?!0:void 0,seed:n.seed}};if(e.dryRun){M({request:p},s);return}let m=(await D(e,{url:ve(e.baseUrl),method:`POST`,body:p,async:!0})).output.task_id;if(e.quiet||(process.stderr.write(`[Model: ${o}]\n`),process.stderr.write(`Note: Video editing typically takes 5-8 minutes. Please be patient.
|
|
128
128
|
`)),n.noWait||e.async){M({task_id:m},s);return}let h=n.pollInterval??15,g=await xi(e,{url:pe(e.baseUrl,m),intervalSec:h,timeoutSec:Math.max(e.timeout,600),isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}}),_=g.output.video_url||g.output.results&&g.output.results[0]?.url;if(!_)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Ci(_,t,{quiet:e.quiet});e.quiet?N(t):M({task_id:m,video_url:_,status:`SUCCEEDED`,saved:t,size:wi(r)},s);return}let v=await import(`path`),y=ce(e,{subDir:`videos`}),b=v.join(y,`${m}.mp4`);await Ci(_,b,{quiet:e.quiet}),M({task_id:m,video_url:_,saved:b},s)}})})),Yi,Xi=A((()=>{Si(),Ti(),U(),P(),Yi=d({name:`video ref`,description:`Reference-to-video generation (happyhorse-1.0-r2v / wan2.6-r2v): multi-subject, multi-shot with voice`,apiDocs:`/best-practice/wanx/video-reference`,usage:`bl video ref --prompt <text> --image <url>... [--ref-video <url>...] [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-r2v)`},{flag:`--prompt <text>`,description:`Video description with reference markers (图1, 视频1, etc.)`,required:!0},{flag:`--image <url>`,description:`Reference image URL or local file (repeatable for multiple subjects)`,type:`array`},{flag:`--ref-video <url>`,description:`Reference video URL or local file (repeatable)`,type:`array`},{flag:`--image-voice <url>`,description:`Voice URL for corresponding image (pairs by position)`,type:`array`},{flag:`--video-voice <url>`,description:`Voice URL for corresponding ref-video (pairs by position)`,type:`array`},{flag:`--resolution <res>`,description:`Resolution: 720P or 1080P (default: 720P)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (16:9, 9:16, 1:1)`},{flag:`--duration <seconds>`,description:`Video duration in seconds (2-10, default: 5)`,type:`number`},{flag:`--prompt-extend`,description:`Enable prompt intelligent rewriting`},{flag:`--no-prompt-extend`,description:`Disable prompt intelligent rewriting`},{flag:`--watermark`,description:`Add watermark to generated video`},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--download <path>`,description:`Save video to file on completion`},{flag:`--no-wait`,description:`Return task ID immediately without waiting`},{flag:`--async`,description:`Return task ID immediately (agent/CI mode, same as --no-wait)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 15)`,type:`number`}],examples:[`bl video ref --prompt "图1在草地上奔跑" --image person.jpg`,`bl video ref --prompt "视频1在弹吉他,图1走过来" --ref-video scene.mp4 --image person.jpg`,`bl video ref --prompt "图1说话" --image person.jpg --image-voice voice.mp3 --resolution 1080P`,`bl video ref --prompt "图1和图2在对话" --image a.jpg --image b.jpg --image-voice va.mp3 --image-voice vb.mp3`],async run(e,n){let r=n.prompt;if(!r)if(x({nonInteractive:e.nonInteractive})){let e=await jr({message:`Enter your video prompt (use 图1, 视频1 to reference inputs):`});e||(process.stderr.write(`Video generation cancelled.
|
|
129
129
|
`),process.exit(1)),r=e}else H(`prompt`,`bl video ref --prompt <text> --image <url>`);let a=n.image||[],o=n.refVideo||[];if(a.length===0&&o.length===0)throw new t(`At least one --image or --ref-video is required.`,i.USAGE,`bl video ref --prompt "描述" --image person.jpg`);let s=n.imageVoice||[],c=n.videoVoice||[],l=n.model||`happyhorse-1.0-r2v`,u=f(e.output),d=await O(e),p=[];for(let e=0;e<a.length;e++){let t={type:`reference_image`,url:await k(a[e],d.token,l)};s[e]&&(t.reference_voice=await k(s[e],d.token,l)),p.push(t)}for(let e=0;e<o.length;e++){let t={type:`reference_video`,url:await k(o[e],d.token,l)};c[e]&&(t.reference_voice=await k(c[e],d.token,l)),p.push(t)}let m=n.noPromptExtend===!0?!1:n.promptExtend===!0?!0:void 0,h={model:l,input:{prompt:r,media:p},parameters:{resolution:n.resolution||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,prompt_extend:m,watermark:n.watermark===!0?!0:void 0,seed:n.seed}};if(e.dryRun){M({request:h},u);return}let g=(await D(e,{url:ve(e.baseUrl),method:`POST`,body:h,async:!0})).output.task_id;if(e.quiet||(process.stderr.write(`[Model: ${l}]\n`),process.stderr.write(`Note: Reference-to-video typically takes 5-10 minutes. Please be patient.
|
|
130
|
-
`)),n.noWait||e.async){M({task_id:g},u);return}let _=n.pollInterval??15,v=await xi(e,{url:pe(e.baseUrl,g),intervalSec:_,timeoutSec:Math.max(e.timeout,600),isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}}),y=v.output.video_url||v.output.results&&v.output.results[0]?.url;if(!y)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Ci(y,t,{quiet:e.quiet});e.quiet?N(t):M({task_id:g,video_url:y,status:`SUCCEEDED`,saved:t,size:wi(r)},u);return}let{join:b}=await import(`path`),S=b(ce(e,{subDir:`videos`}),`${g}.mp4`);await Ci(y,S,{quiet:e.quiet}),M({task_id:g,video_url:y,saved:S},u)}})})),Zi,Qi=A((()=>{U(),P(),Zi=d({name:`video task get`,description:`Query async task status`,usage:`bl video task get --task-id <id>`,options:[{flag:`--task-id <id>`,description:`Async task ID`}],examples:[`bl video task get --task-id 3b256896-3e70-xxxx-xxxx-xxxxxxxxxxxx`,`bl video task get --task-id 3b256896-3e70-xxxx --output json`],async run(e,t){let n=t.taskId;n||H(`task-id`,`bl video task get --task-id <id>`);let r=f(e.output);if(e.dryRun){M({task_id:n},r);return}let i=await D(e,{url:pe(e.baseUrl,n)});if(e.quiet){N(i.output.task_status);return}M({task_id:i.output.task_id,task_status:i.output.task_status,video_url:i.output.video_url,results:i.output.results,submit_time:i.output.submit_time,end_time:i.output.end_time},r)}})})),$i,ea=A((()=>{Ti(),U(),P(),$i=d({name:`video download`,description:`Download a completed video by task ID`,usage:`bl video download --task-id <id> --out <path>`,options:[{flag:`--task-id <id>`,description:`Task ID to download from`},{flag:`--out <path>`,description:`Output file path`}],examples:[`bl video download --task-id 3b256896-xxxx --out video.mp4`,`bl video download --task-id 3b256896-xxxx --out video.mp4 --quiet`],async run(e,n){let r=n.taskId;r||H(`task-id`,`bl video download --task-id <id> --out <path>`);let a=n.out;a||H(`out`,`bl video download --task-id <id> --out video.mp4`);let o=f(e.output);if(e.dryRun){M({task_id:r,action:`download`,out:a},o);return}let s=await D(e,{url:pe(e.baseUrl,r)});if(s.output.task_status!==`SUCCEEDED`)throw new t(`Task is not complete (status: ${s.output.task_status}).`,i.GENERAL,`Wait for the task to complete before downloading.`);let c=s.output.video_url||s.output.results&&s.output.results[0]?.url;if(!c)throw new t(`No download URL available for this task.`,i.GENERAL);let{size:l}=await Ci(c,a,{quiet:e.quiet});if(e.quiet){N(a);return}M({saved:a,size:wi(l)},o)}})}));function ta(e){let t=Ie(e).toLowerCase().split(`?`)[0];return!!(ia.has(t)||/\.(mp4|mov|avi|mkv|webm|flv|wmv)(\?|$)/i.test(e))}async function na(e){if(e.startsWith(`data:`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`oss://`))return e;if(!Ae(e))throw new t(`File not found: ${e}`,i.USAGE);let n=Ie(e).toLowerCase(),r=ra[n];if(!r)throw new t(`Unsupported image format "${n}". Supported: jpg, jpeg, png, webp`,i.USAGE);return`data:${r};base64,${Me(e).toString(`base64`)}`}var ra,ia,aa,oa=A((()=>{U(),P(),ra={".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".webp":`image/webp`},ia=new Set([`.mp4`,`.mov`,`.avi`,`.mkv`,`.webm`,`.flv`,`.wmv`]),aa=d({name:`vision describe`,description:`Describe an image or video using Qwen-VL`,usage:`bl vision describe --image <path-or-url> [--video <url>] [--prompt <text>]`,options:[{flag:`--image <path-or-url>`,description:`Local image path or URL`},{flag:`--video <url>`,description:`Video file URL or local path (mp4/mov/avi/mkv/webm)`,type:`array`},{flag:`--prompt <text>`,description:`Question about the content (default: auto-detected)`},{flag:`--model <model>`,description:`Vision model (default:
|
|
130
|
+
`)),n.noWait||e.async){M({task_id:g},u);return}let _=n.pollInterval??15,v=await xi(e,{url:pe(e.baseUrl,g),intervalSec:_,timeoutSec:Math.max(e.timeout,600),isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}}),y=v.output.video_url||v.output.results&&v.output.results[0]?.url;if(!y)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Ci(y,t,{quiet:e.quiet});e.quiet?N(t):M({task_id:g,video_url:y,status:`SUCCEEDED`,saved:t,size:wi(r)},u);return}let{join:b}=await import(`path`),S=b(ce(e,{subDir:`videos`}),`${g}.mp4`);await Ci(y,S,{quiet:e.quiet}),M({task_id:g,video_url:y,saved:S},u)}})})),Zi,Qi=A((()=>{U(),P(),Zi=d({name:`video task get`,description:`Query async task status`,usage:`bl video task get --task-id <id>`,options:[{flag:`--task-id <id>`,description:`Async task ID`}],examples:[`bl video task get --task-id 3b256896-3e70-xxxx-xxxx-xxxxxxxxxxxx`,`bl video task get --task-id 3b256896-3e70-xxxx --output json`],async run(e,t){let n=t.taskId;n||H(`task-id`,`bl video task get --task-id <id>`);let r=f(e.output);if(e.dryRun){M({task_id:n},r);return}let i=await D(e,{url:pe(e.baseUrl,n)});if(e.quiet){N(i.output.task_status);return}M({task_id:i.output.task_id,task_status:i.output.task_status,video_url:i.output.video_url,results:i.output.results,submit_time:i.output.submit_time,end_time:i.output.end_time},r)}})})),$i,ea=A((()=>{Ti(),U(),P(),$i=d({name:`video download`,description:`Download a completed video by task ID`,usage:`bl video download --task-id <id> --out <path>`,options:[{flag:`--task-id <id>`,description:`Task ID to download from`},{flag:`--out <path>`,description:`Output file path`}],examples:[`bl video download --task-id 3b256896-xxxx --out video.mp4`,`bl video download --task-id 3b256896-xxxx --out video.mp4 --quiet`],async run(e,n){let r=n.taskId;r||H(`task-id`,`bl video download --task-id <id> --out <path>`);let a=n.out;a||H(`out`,`bl video download --task-id <id> --out video.mp4`);let o=f(e.output);if(e.dryRun){M({task_id:r,action:`download`,out:a},o);return}let s=await D(e,{url:pe(e.baseUrl,r)});if(s.output.task_status!==`SUCCEEDED`)throw new t(`Task is not complete (status: ${s.output.task_status}).`,i.GENERAL,`Wait for the task to complete before downloading.`);let c=s.output.video_url||s.output.results&&s.output.results[0]?.url;if(!c)throw new t(`No download URL available for this task.`,i.GENERAL);let{size:l}=await Ci(c,a,{quiet:e.quiet});if(e.quiet){N(a);return}M({saved:a,size:wi(l)},o)}})}));function ta(e){let t=Ie(e).toLowerCase().split(`?`)[0];return!!(ia.has(t)||/\.(mp4|mov|avi|mkv|webm|flv|wmv)(\?|$)/i.test(e))}async function na(e){if(e.startsWith(`data:`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`oss://`))return e;if(!Ae(e))throw new t(`File not found: ${e}`,i.USAGE);let n=Ie(e).toLowerCase(),r=ra[n];if(!r)throw new t(`Unsupported image format "${n}". Supported: jpg, jpeg, png, webp`,i.USAGE);return`data:${r};base64,${Me(e).toString(`base64`)}`}var ra,ia,aa,oa=A((()=>{U(),P(),ra={".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".webp":`image/webp`},ia=new Set([`.mp4`,`.mov`,`.avi`,`.mkv`,`.webm`,`.flv`,`.wmv`]),aa=d({name:`vision describe`,description:`Describe an image or video using Qwen-VL`,usage:`bl vision describe --image <path-or-url> [--video <url>] [--prompt <text>]`,options:[{flag:`--image <path-or-url>`,description:`Local image path or URL`},{flag:`--video <url>`,description:`Video file URL or local path (mp4/mov/avi/mkv/webm)`,type:`array`},{flag:`--prompt <text>`,description:`Question about the content (default: auto-detected)`},{flag:`--model <model>`,description:`Vision model (default: qwen3-vl-plus)`}],examples:[`bl vision describe --image photo.jpg`,`bl vision describe --image https://example.com/photo.jpg --prompt "这只狗是什么品种?"`,`bl vision describe --video https://example.com/video.mp4 --prompt "总结视频内容"`,`bl vision describe --video ./local-video.mp4`,`bl vision describe --image photo.png --prompt "Extract the text" --model qwen-vl-plus`],async run(e,n){let r=n.image??n._positional?.[0],a=n.video??[],o=n.model||`qwen3-vl-plus`;r&&ta(r)&&(a.push(r),r=void 0);let s=a.length>0,c=s?`Describe the video.`:`Describe the image.`,u=n.prompt||c;if(!r&&!s)if(x({nonInteractive:e.nonInteractive})){let e=await jr({message:`Enter image/video path or URL:`});e||(process.stderr.write(`Vision describe cancelled.
|
|
131
131
|
`),process.exit(1)),ta(e)?a.push(e):r=e}else throw new t(`Missing required argument --image or --video.`,i.USAGE,`bl vision describe --image <path-or-url>
|
|
132
132
|
bl vision describe --video <url-or-path>`);let d=f(e.output);if(e.dryRun){M({request:{prompt:u,image:r,video:a.length?a:void 0,model:o}},d);return}let p=[];if(a.length>0)for(let n of a){let r=n;if(S(n)){if(!Ae(n))throw new t(`Video file not found: ${n}`,i.USAGE);r=await k(n,(await O(e)).token,o)}p.push({type:`video_url`,video_url:{url:r}})}if(r){let t=await na(r),n=t;if(S(r)&&t.startsWith(`data:`)){let{statSync:t}=await import(`fs`);if(t(r).size>5*1024*1024){let t=await O(e);n=await k(r,t.token,o)}}p.push({type:`image_url`,image_url:{url:n}})}p.push({type:`text`,text:u});let m={model:o,messages:[{role:`user`,content:p}]},h=await D(e,{url:l(e.baseUrl),method:`POST`,body:m}),g=h.choices?.[0]?.message?.content;if(d!==`text`){M(h,d);return}N(g||``)}})})),sa,ca=A((()=>{P(),sa=d({name:`config show`,description:`Display current configuration`,usage:`bl config show`,examples:[`bl config show`,`bl config show --output json`],async run(e,t){let n=ae(),r=f(e.output),i={region:e.region,base_url:e.baseUrl,output:e.output,timeout:e.timeout,config_file:v()};n.api_key&&(i.api_key=w(n.api_key)),n.access_token&&(i.access_token=w(n.access_token)),n.default_text_model&&(i.default_text_model=n.default_text_model),n.default_video_model&&(i.default_video_model=n.default_video_model),n.default_image_model&&(i.default_image_model=n.default_image_model),M(i,r)}})})),la,ua,da,fa=A((()=>{P(),la=[`region`,`base_url`,`output`,`output_dir`,`timeout`,`api_key`,`access_token`,`default_text_model`,`default_video_model`,`default_image_model`,`default_speech_model`,`default_omni_model`,`access_key_id`,`access_key_secret`,`workspace_id`],ua={"base-url":`base_url`,"output-dir":`output_dir`,"api-key":`api_key`,"access-token":`access_token`,"default-text-model":`default_text_model`,"default-video-model":`default_video_model`,"default-image-model":`default_image_model`,"default-speech-model":`default_speech_model`,"default-omni-model":`default_omni_model`,"access-key-id":`access_key_id`,"access-key-secret":`access_key_secret`,"workspace-id":`workspace_id`},da=d({name:`config set`,description:`Set a config value`,usage:`bl config set --key <key> --value <value>`,options:[{flag:`--key <key>`,description:`Config key (region, base_url, output, output_dir, timeout, api_key, access_token, default_*_model, access_key_id, access_key_secret, workspace_id)`},{flag:`--value <value>`,description:`Value to set`}],examples:[`bl config set --key output --value json`,`bl config set --key timeout --value 600`,`bl config set --key base_url --value https://dashscope.aliyuncs.com`],async run(e,n){let r=n.key,a=n.value;if(!r||a===void 0)throw new t(`--key and --value are required.`,i.USAGE,`bl config set --key <key> --value <value>`);let o=ua[r]||r;if(!la.includes(o))throw new t(`Invalid config key "${r}". Valid keys: ${la.join(`, `)}`,i.USAGE);if(o===`region`&&![`cn`,`us`,`intl`].includes(a))throw new t(`Invalid region "${a}". Valid values: cn, us, intl`,i.USAGE);if(o===`output`&&![`text`,`json`].includes(a))throw new t(`Invalid output format "${a}". Valid values: text, json`,i.USAGE);if(o===`timeout`){let e=Number(a);if(isNaN(e)||e<=0)throw new t(`Invalid timeout "${a}". Must be a positive number.`,i.USAGE)}let s=f(e.output);if(e.dryRun){M({would_set:{[o]:a}},s);return}let c=ae();c[o]=o===`timeout`?Number(a):a,await ye(c),e.quiet||M({[o]:c[o]},s)}})})),pa,ma,ha=A((()=>{pa=[`auth `,`config `,`update`],ma=d({name:`config export-schema`,description:`Export all (or one) CLI command(s) as Anthropic/OpenAI-compatible JSON tool schemas`,usage:`bl config export-schema [--command "<name>"]`,options:[{flag:`--command <name>`,description:`Export schema for a specific command only (e.g. "image generate")`}],examples:[`bl config export-schema`,`bl config export-schema --command "video generate"`],async run(e,n){let{commands:r}=await Promise.resolve().then(()=>(jd(),kd)),a=n.command;if(a){let e=r[a];if(!e)throw new t(`Command "${a}" not found.`,i.USAGE);let n=g(e);process.stdout.write(JSON.stringify(n,null,2)+`
|
|
133
133
|
`);return}let o=Object.values(r).filter(e=>!pa.some(t=>e.name.startsWith(t))).map(e=>g(e));process.stdout.write(JSON.stringify(o,null,2)+`
|
|
134
|
-
`)}})}));Zr(),oi(),li(),fi(),gi(),Bi(),Hi(),Ki(),Ji(),Xi(),Qi(),ea(),oa(),ca(),fa(),ha();var ga=`1.1.
|
|
134
|
+
`)}})}));Zr(),oi(),li(),fi(),gi(),Bi(),Hi(),Ki(),Ji(),Xi(),Qi(),ea(),oa(),ca(),fa(),ha();var ga=`1.1.2`,_a,va=A((()=>{_a=ga}));function ya(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if((n[e]??0)>(r[e]??0))return!0;if((n[e]??0)<(r[e]??0))return!1}return!1}function ba(){try{let e=Me(Da(),`utf-8`);return JSON.parse(e)}catch{return null}}function xa(e){try{Pe(Da(),JSON.stringify(e))}catch{}}async function Sa(e=ka){try{let t=Ea.replace(`/`,`%2f`),n=await fetch(`${Ta}/${t}/latest`,{headers:{Accept:`application/json`,...he()},signal:AbortSignal.timeout(e)});return n.ok?(await n.json()).version??null:null}catch{return null}}function Ca(){return Aa}async function wa(e){if(process.env.CI||!process.stderr.isTTY)return;let t=ba(),n=Date.now();if(t&&n-t.lastChecked<Oa){t.latestVersion&&ya(t.latestVersion,e)&&(Aa=t.latestVersion);return}let r=await Sa();r&&(xa({lastChecked:n,latestVersion:r}),r&&ya(r,e)&&(Aa=r))}var Ta,Ea,Da,Oa,ka,Aa,ja=A((()=>{Ta=`https://registry.npmjs.org`,Ea=`bailian-cli`,Da=()=>Le(_(),`update-state.json`),Oa=14400*1e3,ka=3e3,Aa=null}));function Ma(){return{cmd:`npm install -g ${Ea}@latest`,label:`npm`}}var Na,Pa=A((()=>{va(),ja(),Na=d({name:`update`,description:`Update bl to the latest version`,usage:`bl update`,examples:[`bl update`],async run(){let e=process.stderr.isTTY,t=e?`\x1B[32m`:``,n=e?`\x1B[33m`:``,r=e?`\x1B[0m`:``;process.stderr.write(`Current version: ${n}${_a}${r}\n`),process.stderr.write(`Checking for updates...
|
|
135
135
|
`);let i=await Sa(5e3);if(i&&i===_a){process.stderr.write(`${t}\u2713 Already up to date (${_a}).${r}\n`);return}i&&process.stderr.write(`Latest version: ${t}${i}${r}\n\n`);let{cmd:a,label:o}=Ma();process.stderr.write(`Updating ${Ea} via ${o}...\n\n`);try{Re(a,{stdio:`inherit`});try{let e=Re(`bl --version 2>/dev/null`,{encoding:`utf-8`}).trim().replace(/^bl\s+/,``);process.stderr.write(`\n${t}\u2713 Update complete: ${_a} \u2192 ${e}${r}\n`);try{Pe(Le(_(),`update-state.json`),JSON.stringify({lastChecked:Date.now(),latestVersion:e}))}catch{}}catch{process.stderr.write(`\n${t}\u2713 Update complete.${r}\n`)}}catch{process.stderr.write(`
|
|
136
136
|
Automatic update failed. Please run manually:
|
|
137
137
|
`),process.stderr.write(` ${a}\n\n`)}}})})),Fa,Ia=A((()=>{U(),P(),Fa=d({name:`app call`,description:`Call a Bailian application (agent or workflow)`,usage:`bl app call --app-id <id> --prompt <text> [flags]`,options:[{flag:`--app-id <id>`,description:`Application ID (required)`,required:!0},{flag:`--prompt <text>`,description:`Input prompt text`,required:!0},{flag:`--image <url>`,description:`Image URL(s) to pass to the app (repeatable)`,type:`array`},{flag:`--file-id <id>`,description:`Pre-uploaded file ID(s) (repeatable)`,type:`array`},{flag:`--session-id <id>`,description:`Session ID for multi-turn conversation`},{flag:`--stream`,description:`Stream response (default: on in TTY)`},{flag:`--pipeline-ids <ids>`,description:`Knowledge base pipeline IDs (comma-separated)`},{flag:`--memory-id <id>`,description:`Memory ID for long-term memory`},{flag:`--biz-params <json>`,description:`Business parameters JSON (workflow variables)`},{flag:`--has-thoughts`,description:`Show agent thinking process`}],examples:[`bl app call --app-id abc123 --prompt "你好"`,`bl app call --app-id abc123 --prompt "描述这张图片" --image https://example.com/photo.jpg`,`bl app call --app-id abc123 --prompt "分析图片" --image img1.jpg --image img2.jpg`,`bl app call --app-id abc123 --prompt "继续" --session-id sess_xxx --stream`,`bl app call --app-id abc123 --prompt "搜索资料" --pipeline-ids pipe1,pipe2`,`bl app call --app-id abc123 --prompt "开始" --biz-params '{"key":"value"}'`],async run(e,t){let n=t.appId;n||H(`app-id`,`bl app call --app-id <id> --prompt <text>`);let r=t.prompt;r||H(`prompt`,`bl app call --app-id <id> --prompt <text>`);let i=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,a=f(e.output),o={input:{prompt:r},parameters:{incremental_output:i}};t.sessionId&&(o.input.session_id=t.sessionId);let c=t.image;c&&c.length>0&&(o.input.image_list=c);let l=t.fileId;if(l&&l.length>0&&(o.input.file_ids=l),t.hasThoughts&&(o.parameters.has_thoughts=!0),t.pipelineIds){let e=t.pipelineIds.split(`,`).map(e=>e.trim()).filter(Boolean);o.parameters.rag_options={pipeline_ids:e}}if(t.memoryId&&(o.parameters.memory_id=t.memoryId),t.bizParams)try{o.input.biz_params=JSON.parse(t.bizParams)}catch{process.stderr.write(`Error: --biz-params must be valid JSON
|
|
@@ -158,8 +158,8 @@ Set via: --workspace-id flag, or env: BAILIAN_WORKSPACE_ID, or config: bl config
|
|
|
158
158
|
`);else N(JSON.stringify(o));r&&process.stdout.write(`
|
|
159
159
|
`)}if(a.out){let t=a.out,n=f.length===1?f[0]:f;Pe(t,JSON.stringify(n,null,2)+`
|
|
160
160
|
`),e.quiet||process.stderr.write(`Full result saved to: ${t}\n`)}}var ho,go=A((()=>{Si(),U(),P(),ho=d({name:`speech recognize`,description:`Recognize speech from audio files (FunAudio-ASR)`,apiDocs:`/developer-reference/recording-file-recognition`,usage:`bl speech recognize --url <audio-url> [flags]`,options:[{flag:`--url <url>`,description:`Audio file URL or local file path (repeatable, max 100)`,required:!0,type:`array`},{flag:`--model <model>`,description:`Model ID (default: fun-asr)`},{flag:`--language <lang>`,description:`Language hint (e.g. zh, en, ja)`},{flag:`--diarization`,description:`Enable automatic speaker diarization`},{flag:`--speaker-count <n>`,description:`Expected number of speakers (requires --diarization)`,type:`number`},{flag:`--vocabulary-id <id>`,description:`Hot-word vocabulary ID for improved accuracy`},{flag:`--channel-id <n>`,description:`Audio channel ID (default: 0)`,type:`number`},{flag:`--out <path>`,description:`Save full transcription result to JSON file`},{flag:`--no-wait`,description:`Return task ID immediately without polling`},{flag:`--poll-interval <seconds>`,description:`Polling interval in seconds (default: 2)`,type:`number`}],examples:[`bl speech recognize --url https://example.com/audio.mp3`,`bl speech recognize --url https://example.com/a.mp3 --url https://example.com/b.mp3`,`bl speech recognize --url https://example.com/meeting.wav --diarization --speaker-count 3`,`bl speech recognize --url https://example.com/audio.mp3 --language zh`,`bl speech recognize --url https://example.com/audio.mp3 --vocabulary-id vocab-abc123`,`bl speech recognize --url https://example.com/audio.mp3 --out result.json`,`bl speech recognize --url https://example.com/audio.mp3 --no-wait --quiet`],async run(e,n){let r=[];Array.isArray(n.url)?r=n.url:typeof n.url==`string`&&(r=[n.url]),r.length===0&&H(`url`,`bl speech recognize --url <audio-url>`);let a=n.speakerCount,o=n.diarization===!0;if(a!==void 0&&!o)throw new t(`--speaker-count requires --diarization to be enabled.
|
|
161
|
-
Hint: Add --diarization flag to enable speaker separation.`,i.USAGE);let s=n.model||`fun-asr`,c=f(e.output),l=await O(e),u=await Promise.all(r.map(e=>k(e,l.token,s))),d=n.channelId,p=n.language,m=n.vocabularyId,h={model:s,input:{file_urls:u},parameters:{channel_id:d===void 0?[0]:[d],language_hints:p?[p]:void 0,diarization_enabled:o?!0:void 0,speaker_count:a,vocabulary_id:m}};if(fe(h.parameters),e.dryRun){M({request:h,mode:`async`},c);return}e.quiet||process.stderr.write(`[Model: ${s}] [Mode: async] [Files: ${u.length}]\n`),await mo(e,ue(e.baseUrl),h,n,c,u.length)}})})),_o,vo=A((()=>{U(),P(),_o=d({name:`file upload`,description:`Upload a local file to DashScope temporary storage (48h)`,apiDocs:`/developer-reference/get-temporary-file-url`,usage:`bl file upload --file <path> --model <model>`,options:[{flag:`--file <path>`,description:`Local file to upload (image, video, audio)`,required:!0},{flag:`--model <model>`,description:`Target model name (file is bound to this model)`,required:!0}],examples:[`bl file upload --file photo.jpg --model
|
|
162
|
-
`),process.exit(1)}let s=r.region||`cn-beijing`,l=f(e.output),u;try{u=(await se(e)).token}catch(e){if(!(e instanceof t&&e.message===n))throw e}if(e.dryRun){M({api:i,data:o,region:s,token:u?u.slice(0,8)+`...`:null},l);return}M(await c(e,u,{api:i,data:o,region:s}),l)}})})),xo,So,Co=A((()=>{U(),P(),xo=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota`,So=d({name:`usage free`,description:`Query free-tier quota for a model`,usage:`bl usage free --model <model> [flags]`,options:[{flag:`--model <model>`,description:`Model name to query (e.g. qwen3-max, qwen-turbo)`,required:!0},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl usage free --model qwen3-max`,`bl usage free --model qwen-turbo --output json`,`bl usage free --model qwen3-max --region cn-beijing`],async run(e,t){let n=t.model;n||H(`model`,`bl usage free --model <model>`);let r=t.region||`cn-beijing`,i=f(e.output),a=await se(e),o={queryFreeTierQuotaRequest:{models:[n]}};if(e.dryRun){M({api:xo,data:o,region:r,token:a.token.slice(0,8)+`...`},i);return}M(await c(e,a.token,{api:xo,data:o,region:r}),i)}})}));function wo(e,t){return e instanceof W?e:new W(`step_execution_error`,e instanceof Error?e.message:String(e),{step:t})}var W,To=A((()=>{W=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 Eo(){return ko}function Do(e,t,n,r){let i,a;n instanceof Oo?(i=n,a=r):(i=ko,a=n??r),i.registerStep(e,t,a)}var Oo,ko,Ao=A((()=>{To(),Oo=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 W(`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)}},ko=new Oo}));function jo(){let e=C(Mo);return e.clientName=`bailian-cli`,e}var Mo,No=A((()=>{Mo={output:`json`,nonInteractive:!0,noColor:!0,quiet:!0,verbose:!1,yes:!1,dryRun:!1,help:!1,async:!1}}));function Po(e){return e.startsWith(`./`)||e.startsWith(`../`)}function Fo(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))typeof a==`string`&&Po(a)?(n[i]=Ge(t,a),r.push(i)):n[i]=a;return{input:n,resolvedKeys:r}}async function Io(e,t,n){let r=[];for(let i of t){let t=e[i];typeof t==`string`&&(await ze(t).then(()=>!0,()=>!1)||r.push(`Step "${n}" input "${i}" references file that does not exist: ${t}`))}return r}function Lo(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 G(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Ro(e,t){if(Array.isArray(e)){e.forEach(e=>Ro(e,t));return}if(G(e)){`$from`in e&&typeof e.$from==`string`&&t.add(e.$from);for(let n of Object.values(e))Ro(n,t)}}async function zo(e,t){let n=[];for(let r of e)for(let[e,i]of Object.entries(r.input)){if(Bo.includes(e)||typeof i!=`string`||!Po(i))continue;let a=Ge(t,i);await ze(a).then(()=>!0,()=>!1)||n.push(`Step "${r.id}" input "${e}" references file that does not exist: ${a}`)}return n}var Bo,Vo=A((()=>{Bo=[`download`,`out-dir`,`output`]}));async function Ho(e,t,n){if(!t.message)throw new W(`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};return 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`])),await D(e,{url:l(e.baseUrl),method:`POST`,body:a,timeout:n.blRequestTimeoutSeconds,signal:n.signal})}async function Uo(e,t,n){let r=t.model||`qwen-vl-max`,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;if(S(i)){let t=await O(e);i=await k(i,t.token,r,{signal:n.signal})}s.push({type:`video_url`,video_url:{url:i}})}for(let t of i){let i=t;S(t)&&(i=await k(t,(await O(e)).token,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}]};return await D(e,{url:l(e.baseUrl),method:`POST`,body:c,signal:n.signal})}function Wo(e){return ts.some(t=>e.startsWith(t))}async function Go(e,t,n){if(!t.prompt)throw new W(`missing_input`,`image/generate requires 'prompt' input`,{step:`image/generate`});let r=t.model||`qwen-image-2.0`,i=Wo(r),a=t.n??1,o;t[`no-prompt-extend`]?o=!1:(t[`prompt-extend`]||i)&&(o=!0);let s={model:r,input:{messages:[{role:`user`,content:[{text:t.prompt}]}]},parameters:{size:Ai(t.size,i),n:a,seed:t.seed,prompt_extend:o,watermark:t.watermark===!0?!0:void 0,negative_prompt:t[`negative-prompt`]||void 0}};if(i){let r=await D(e,{url:b(e.baseUrl),method:`POST`,body:s,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),a=await qo(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await D(e,{url:y(e.baseUrl),method:`POST`,body:s,async:!0,signal:n.signal})).output.task_id,i=await Qo(e,r,n),a=await qo(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function Ko(e,t,n){if(!t.prompt)throw new W(`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=Wo(i),o=t.n??1,s;t[`no-prompt-extend`]?s=!1:(t[`prompt-extend`]||a)&&(s=!0);let c=[];for(let t of r){let r=t;S(t)&&(r=await k(t,(await O(e)).token,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:Ai(t.size,a),n:o,seed:t.seed,prompt_extend:s,watermark:t.watermark===!0?!0:void 0,negative_prompt:t[`negative-prompt`]||void 0}};if(a){let r=await D(e,{url:b(e.baseUrl),method:`POST`,body:l,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),a=await qo(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await D(e,{url:y(e.baseUrl),method:`POST`,body:l,async:!0,signal:n.signal})).output.task_id,i=await Qo(e,r,n),a=await qo(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function qo(e,t,n){if(!t||e.length===0)return;await Be(t,{recursive:!0});let r=n&&n.length>0?n:`image`,i=e.length===1?[{url:e[0],destPath:We(t,`${r}.png`)}]:e.map((e,n)=>({url:e,destPath:We(t,`${r}_${String(n+1).padStart(3,`0`)}.png`)})),a=[];for(let{url:e,destPath:t}of i)await Ci(e,t,{quiet:!0}),a.push(t);return a}async function Jo(e,t,n){if(!t.prompt)throw new W(`missing_input`,`video/generate requires 'prompt' input`,{step:`video/generate`});let r=t.model||(t.image?`happyhorse-1.0-i2v`:`happyhorse-1.0-t2v`),i;if(t.image)if(S(t.image)){let a=await O(e);i=await k(t.image,a.token,r,{signal:n.signal})}else i=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:t[`prompt-extend`],watermark:t.watermark,seed:t.seed}};fe(a.parameters);let o=(await D(e,{url:ve(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await $o(e,o,(t[`poll-interval`]??10)*1e3,(n.timeoutSeconds??900)*1e3,n)}async function Yo(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 W(`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`]}};fe(a.input);let o=await D(e,{url:de(e.baseUrl),method:`POST`,body:a,signal:n.signal});return{audio_url:o.output.audio.url,url_expires_at:o.output.audio.expires_at,model:i,voice:t.voice,request_id:o.request_id}}async function Xo(e,t,n){let r=Array.isArray(t.url)?t.url:t.url?[t.url]:[];if(r.length===0)throw new W(`missing_input`,`speech/recognize requires 'url' input`,{step:`speech/recognize`});let i=[];for(let a of r)if(S(a)){let r=await O(e);i.push(await k(a,r.token,t.model||`fun-asr`,{signal:n.signal}))}else 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`]}};fe(a.parameters);let o=(await D(e,{url:ue(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await $o(e,o,(t[`poll-interval`]??2)*1e3,(n.timeoutSeconds??300)*1e3,n)}function Zo(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 Qo(e,t,n){return await $o(e,t,3e3,e.timeout*1e3,n)}async function $o(e,t,n,r,i){let a=Date.now(),o=0;for(;;){if(i?.signal?.aborted)throw new W(`aborted`,`Task polling was aborted`,{details:{taskId:t}});await es(n,i?.signal),o++;let s=await D(e,{url:pe(e.baseUrl,t),method:`GET`,signal:i?.signal}),c=s.output.task_status;if(c===`SUCCEEDED`)return Zo(s);if(c===`FAILED`)throw new W(`async_task_failed`,s.output.message||s.output.code||`Task failed`,{details:{taskId:t,data:s}});let l=Date.now()-a;if(await i?.emitEvent?.({type:`step.polling`,timestamp:new Date().toISOString(),status:`running`,taskId:t,taskStatus:c,elapsedMs:l,pollAttempt:o}),l>r)throw new W(`async_poll_timeout`,`Task ${t} timed out after ${Math.round(r/1e3)}s`,{details:{taskId:t,timeoutMs:r,pollAttempts:o}})}}function es(e,t){return t?new Promise((n,r)=>{let i=setTimeout(()=>{o(),n()},e),a=()=>{o(),r(new W(`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))}var ts,ns=A((()=>{To(),Ni(),Ti(),ts=[`qwen-image-2.0`,`qwen-image-max`]}));function rs(e){for(let t of Object.keys(fs))Do(t,async(e,n)=>await is(t,e,n),e,ms[t])}async function is(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=fs[e];if(!r)throw Error(`No direct API handler registered for step: ${e}`);let i=await r(n.blConfig??jo(),t,n),a=ps[e];return a?a(i):{data:i,warnings:[],metadata:{}}}function as(e){if(!G(e))return;let t=[],n=K(e.task_id)??K(e.taskId);for(let r of ls(e.urls))t.push({url:r,taskId:n,kind:us(r)});for(let r of ls(e.saved))t.push({path:r,taskId:n,kind:ds(r)});let r=K(e.video_url)??K(e.videoUrl);r&&t.push({url:r,taskId:n,kind:`video`});let i=K(e.saved);if(i&&t.push({path:i,taskId:n,kind:ds(i)}),Array.isArray(e.videos))for(let n of e.videos){if(!G(n))continue;let e=K(n.task_id)??K(n.taskId),r=K(n.video_url)??K(n.videoUrl),i=K(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(K).filter(cs):[];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 os(e,t){if(!G(e))return;let n=[],r=K(e.task_id)??K(e.taskId),i=[K(e.url),K(e.audio_url),K(e.audioUrl),K(e.output_url),K(e.outputUrl)].filter(cs);for(let e of i)n.push({url:e,taskId:r,kind:t});let a=[K(e.saved),K(e.path),K(e.output_path),K(e.outputPath)].filter(cs);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?ss(n):void 0}function ss(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 cs(e){return typeof e==`string`}function K(e){return typeof e==`string`&&e.length>0?e:void 0}function ls(e){return Array.isArray(e)?e.map(K).filter(cs):[]}function us(e){try{return ds(new URL(e).pathname)}catch{return`artifact`}}function ds(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 fs,ps,ms,hs=A((()=>{Ao(),No(),Vo(),ns(),fs={"text/chat":(e,t,n)=>Ho(e,t,n),"vision/describe":(e,t,n)=>Uo(e,t,n),"image/generate":(e,t,n)=>Go(e,t,n),"image/edit":(e,t,n)=>Ko(e,t,n),"video/generate":(e,t,n)=>Jo(e,t,n),"speech/synthesize":(e,t,n)=>Yo(e,t,n),"speech/recognize":(e,t,n)=>Xo(e,t,n)},ps={"image/generate":e=>({data:e,artifacts:as(e),warnings:[],metadata:{}}),"image/edit":e=>({data:e,artifacts:as(e),warnings:[],metadata:{}}),"video/generate":e=>({data:e,artifacts:as(e),warnings:[],metadata:{}}),"speech/synthesize":e=>({data:e,artifacts:os(e,`audio`),warnings:[],metadata:{}}),"speech/recognize":e=>({data:e,artifacts:os(e,`transcript`),warnings:[],metadata:{}})},ms={"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`}]}}})),gs=j((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})),_s=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=gs();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}}})),q=j((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=gs(),n=_s();var r=gs();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=_s();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&&=ne(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=ne(this.rhs,e,n),this}get names(){return te(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=ne(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)||(re(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>ee(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(ie(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=ne(this.condition,e,t),this}get names(){let e=super.names;return te(e,this.condition),this.else&&ee(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=ne(this.iteration,e,t),this}get names(){return ee(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 te(te(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=ne(this.iterable,e,t),this}get names(){return ee(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&&ee(e,this.catch.names),this.finally&&ee(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?`
|
|
161
|
+
Hint: Add --diarization flag to enable speaker separation.`,i.USAGE);let s=n.model||`fun-asr`,c=f(e.output),l=await O(e),u=await Promise.all(r.map(e=>k(e,l.token,s))),d=n.channelId,p=n.language,m=n.vocabularyId,h={model:s,input:{file_urls:u},parameters:{channel_id:d===void 0?[0]:[d],language_hints:p?[p]:void 0,diarization_enabled:o?!0:void 0,speaker_count:a,vocabulary_id:m}};if(fe(h.parameters),e.dryRun){M({request:h,mode:`async`},c);return}e.quiet||process.stderr.write(`[Model: ${s}] [Mode: async] [Files: ${u.length}]\n`),await mo(e,ue(e.baseUrl),h,n,c,u.length)}})})),_o,vo=A((()=>{U(),P(),_o=d({name:`file upload`,description:`Upload a local file to DashScope temporary storage (48h)`,apiDocs:`/developer-reference/get-temporary-file-url`,usage:`bl file upload --file <path> --model <model>`,options:[{flag:`--file <path>`,description:`Local file to upload (image, video, audio)`,required:!0},{flag:`--model <model>`,description:`Target model name (file is bound to this model)`,required:!0}],examples:[`bl file upload --file photo.jpg --model qwen3-vl-plus`,`bl file upload --file video.mp4 --model wan2.1-t2v-plus`,`bl file upload --file audio.wav --model qwen3-asr-flash`,`bl file upload --file cat.png --model qwen-image-2.0`],async run(e,t){let n=t.file;n||H(`file`,`bl file upload --file <path> --model <model>`);let r=t.model;r||H(`model`,`bl file upload --file <path> --model <model>`);let i=f(e.output);if(e.dryRun){M({action:`upload`,file:n,model:r},i);return}let a=await ge({apiKey:(await O(e)).token,model:r,filePath:n});e.quiet?N(a):M({url:a,model:r,expires_in:`48 hours`,note:`When using this URL in API calls, add header: X-DashScope-OssResourceResolve: enable`},i)}})})),yo,bo=A((()=>{U(),P(),yo=d({name:`console call`,description:`Call a Bailian console API via the CLI gateway`,usage:`bl console call --api <api> --data <json> [flags]`,options:[{flag:`--api <api>`,description:`API name (e.g. zeldaEasy.broadscope-bailian.memory-library.getLibraries)`,required:!0},{flag:`--data <json>`,description:`Request data as JSON string`,required:!0},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl console call --api zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota --data '{"queryFreeTierQuotaRequest":{"models":["qwen3-max"]}}'`,`bl console call --api some.api.name --data '{"key":"value"}' --region cn-beijing`],async run(e,r){let i=r.api;i||H(`api`,`bl console call --api <api> --data <json>`);let a=r.data;a||H(`data`,`bl console call --api <api> --data <json>`);let o;try{o=JSON.parse(a)}catch{process.stderr.write(`Error: --data must be valid JSON
|
|
162
|
+
`),process.exit(1)}let s=r.region||`cn-beijing`,l=f(e.output),u;try{u=(await se(e)).token}catch(e){if(!(e instanceof t&&e.message===n))throw e}if(e.dryRun){M({api:i,data:o,region:s,token:u?u.slice(0,8)+`...`:null},l);return}M(await c(e,u,{api:i,data:o,region:s}),l)}})})),xo,So,Co=A((()=>{U(),P(),xo=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota`,So=d({name:`usage free`,description:`Query free-tier quota for a model`,usage:`bl usage free --model <model> [flags]`,options:[{flag:`--model <model>`,description:`Model name to query (e.g. qwen3-max, qwen-turbo)`,required:!0},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl usage free --model qwen3-max`,`bl usage free --model qwen-turbo --output json`,`bl usage free --model qwen3-max --region cn-beijing`],async run(e,t){let n=t.model;n||H(`model`,`bl usage free --model <model>`);let r=t.region||`cn-beijing`,i=f(e.output),a=await se(e),o={queryFreeTierQuotaRequest:{models:[n]}};if(e.dryRun){M({api:xo,data:o,region:r,token:a.token.slice(0,8)+`...`},i);return}M(await c(e,a.token,{api:xo,data:o,region:r}),i)}})}));function wo(e,t){return e instanceof W?e:new W(`step_execution_error`,e instanceof Error?e.message:String(e),{step:t})}var W,To=A((()=>{W=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 Eo(){return ko}function Do(e,t,n,r){let i,a;n instanceof Oo?(i=n,a=r):(i=ko,a=n??r),i.registerStep(e,t,a)}var Oo,ko,Ao=A((()=>{To(),Oo=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 W(`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)}},ko=new Oo}));function jo(){let e=C(Mo);return e.clientName=`bailian-cli`,e}var Mo,No=A((()=>{Mo={output:`json`,nonInteractive:!0,noColor:!0,quiet:!0,verbose:!1,yes:!1,dryRun:!1,help:!1,async:!1}}));function Po(e){return e.startsWith(`./`)||e.startsWith(`../`)}function Fo(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))typeof a==`string`&&Po(a)?(n[i]=Ge(t,a),r.push(i)):n[i]=a;return{input:n,resolvedKeys:r}}async function Io(e,t,n){let r=[];for(let i of t){let t=e[i];typeof t==`string`&&(await ze(t).then(()=>!0,()=>!1)||r.push(`Step "${n}" input "${i}" references file that does not exist: ${t}`))}return r}function Lo(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 G(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Ro(e,t){if(Array.isArray(e)){e.forEach(e=>Ro(e,t));return}if(G(e)){`$from`in e&&typeof e.$from==`string`&&t.add(e.$from);for(let n of Object.values(e))Ro(n,t)}}async function zo(e,t){let n=[];for(let r of e)for(let[e,i]of Object.entries(r.input)){if(Bo.includes(e)||typeof i!=`string`||!Po(i))continue;let a=Ge(t,i);await ze(a).then(()=>!0,()=>!1)||n.push(`Step "${r.id}" input "${e}" references file that does not exist: ${a}`)}return n}var Bo,Vo=A((()=>{Bo=[`download`,`out-dir`,`output`]}));async function Ho(e,t,n){if(!t.message)throw new W(`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};return 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`])),await D(e,{url:l(e.baseUrl),method:`POST`,body:a,timeout:n.blRequestTimeoutSeconds,signal:n.signal})}async function Uo(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;if(S(i)){let t=await O(e);i=await k(i,t.token,r,{signal:n.signal})}s.push({type:`video_url`,video_url:{url:i}})}for(let t of i){let i=t;S(t)&&(i=await k(t,(await O(e)).token,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}]};return await D(e,{url:l(e.baseUrl),method:`POST`,body:c,signal:n.signal})}function Wo(e){return ts.some(t=>e.startsWith(t))}async function Go(e,t,n){if(!t.prompt)throw new W(`missing_input`,`image/generate requires 'prompt' input`,{step:`image/generate`});let r=t.model||`qwen-image-2.0`,i=Wo(r),a=t.n??1,o;t[`no-prompt-extend`]?o=!1:(t[`prompt-extend`]||i)&&(o=!0);let s={model:r,input:{messages:[{role:`user`,content:[{text:t.prompt}]}]},parameters:{size:Ai(t.size,i),n:a,seed:t.seed,prompt_extend:o,watermark:t.watermark===!0?!0:void 0,negative_prompt:t[`negative-prompt`]||void 0}};if(i){let r=await D(e,{url:b(e.baseUrl),method:`POST`,body:s,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),a=await qo(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await D(e,{url:y(e.baseUrl),method:`POST`,body:s,async:!0,signal:n.signal})).output.task_id,i=await Qo(e,r,n),a=await qo(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function Ko(e,t,n){if(!t.prompt)throw new W(`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=Wo(i),o=t.n??1,s;t[`no-prompt-extend`]?s=!1:(t[`prompt-extend`]||a)&&(s=!0);let c=[];for(let t of r){let r=t;S(t)&&(r=await k(t,(await O(e)).token,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:Ai(t.size,a),n:o,seed:t.seed,prompt_extend:s,watermark:t.watermark===!0?!0:void 0,negative_prompt:t[`negative-prompt`]||void 0}};if(a){let r=await D(e,{url:b(e.baseUrl),method:`POST`,body:l,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),a=await qo(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await D(e,{url:y(e.baseUrl),method:`POST`,body:l,async:!0,signal:n.signal})).output.task_id,i=await Qo(e,r,n),a=await qo(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function qo(e,t,n){if(!t||e.length===0)return;await Be(t,{recursive:!0});let r=n&&n.length>0?n:`image`,i=e.length===1?[{url:e[0],destPath:We(t,`${r}.png`)}]:e.map((e,n)=>({url:e,destPath:We(t,`${r}_${String(n+1).padStart(3,`0`)}.png`)})),a=[];for(let{url:e,destPath:t}of i)await Ci(e,t,{quiet:!0}),a.push(t);return a}async function Jo(e,t,n){if(!t.prompt)throw new W(`missing_input`,`video/generate requires 'prompt' input`,{step:`video/generate`});let r=t.model||(t.image?`happyhorse-1.0-i2v`:`happyhorse-1.0-t2v`),i;if(t.image)if(S(t.image)){let a=await O(e);i=await k(t.image,a.token,r,{signal:n.signal})}else i=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:t[`prompt-extend`],watermark:t.watermark,seed:t.seed}};fe(a.parameters);let o=(await D(e,{url:ve(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await $o(e,o,(t[`poll-interval`]??10)*1e3,(n.timeoutSeconds??900)*1e3,n)}async function Yo(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 W(`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`]}};fe(a.input);let o=await D(e,{url:de(e.baseUrl),method:`POST`,body:a,signal:n.signal});return{audio_url:o.output.audio.url,url_expires_at:o.output.audio.expires_at,model:i,voice:t.voice,request_id:o.request_id}}async function Xo(e,t,n){let r=Array.isArray(t.url)?t.url:t.url?[t.url]:[];if(r.length===0)throw new W(`missing_input`,`speech/recognize requires 'url' input`,{step:`speech/recognize`});let i=[];for(let a of r)if(S(a)){let r=await O(e);i.push(await k(a,r.token,t.model||`fun-asr`,{signal:n.signal}))}else 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`]}};fe(a.parameters);let o=(await D(e,{url:ue(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await $o(e,o,(t[`poll-interval`]??2)*1e3,(n.timeoutSeconds??300)*1e3,n)}function Zo(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 Qo(e,t,n){return await $o(e,t,3e3,e.timeout*1e3,n)}async function $o(e,t,n,r,i){let a=Date.now(),o=0;for(;;){if(i?.signal?.aborted)throw new W(`aborted`,`Task polling was aborted`,{details:{taskId:t}});await es(n,i?.signal),o++;let s=await D(e,{url:pe(e.baseUrl,t),method:`GET`,signal:i?.signal}),c=s.output.task_status;if(c===`SUCCEEDED`)return Zo(s);if(c===`FAILED`)throw new W(`async_task_failed`,s.output.message||s.output.code||`Task failed`,{details:{taskId:t,data:s}});let l=Date.now()-a;if(await i?.emitEvent?.({type:`step.polling`,timestamp:new Date().toISOString(),status:`running`,taskId:t,taskStatus:c,elapsedMs:l,pollAttempt:o}),l>r)throw new W(`async_poll_timeout`,`Task ${t} timed out after ${Math.round(r/1e3)}s`,{details:{taskId:t,timeoutMs:r,pollAttempts:o}})}}function es(e,t){return t?new Promise((n,r)=>{let i=setTimeout(()=>{o(),n()},e),a=()=>{o(),r(new W(`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))}var ts,ns=A((()=>{To(),Ni(),Ti(),ts=[`qwen-image-2.0`,`qwen-image-max`]}));function rs(e){for(let t of Object.keys(fs))Do(t,async(e,n)=>await is(t,e,n),e,ms[t])}async function is(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=fs[e];if(!r)throw Error(`No direct API handler registered for step: ${e}`);let i=await r(n.blConfig??jo(),t,n),a=ps[e];return a?a(i):{data:i,warnings:[],metadata:{}}}function as(e){if(!G(e))return;let t=[],n=K(e.task_id)??K(e.taskId);for(let r of ls(e.urls))t.push({url:r,taskId:n,kind:us(r)});for(let r of ls(e.saved))t.push({path:r,taskId:n,kind:ds(r)});let r=K(e.video_url)??K(e.videoUrl);r&&t.push({url:r,taskId:n,kind:`video`});let i=K(e.saved);if(i&&t.push({path:i,taskId:n,kind:ds(i)}),Array.isArray(e.videos))for(let n of e.videos){if(!G(n))continue;let e=K(n.task_id)??K(n.taskId),r=K(n.video_url)??K(n.videoUrl),i=K(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(K).filter(cs):[];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 os(e,t){if(!G(e))return;let n=[],r=K(e.task_id)??K(e.taskId),i=[K(e.url),K(e.audio_url),K(e.audioUrl),K(e.output_url),K(e.outputUrl)].filter(cs);for(let e of i)n.push({url:e,taskId:r,kind:t});let a=[K(e.saved),K(e.path),K(e.output_path),K(e.outputPath)].filter(cs);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?ss(n):void 0}function ss(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 cs(e){return typeof e==`string`}function K(e){return typeof e==`string`&&e.length>0?e:void 0}function ls(e){return Array.isArray(e)?e.map(K).filter(cs):[]}function us(e){try{return ds(new URL(e).pathname)}catch{return`artifact`}}function ds(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 fs,ps,ms,hs=A((()=>{Ao(),No(),Vo(),ns(),fs={"text/chat":(e,t,n)=>Ho(e,t,n),"vision/describe":(e,t,n)=>Uo(e,t,n),"image/generate":(e,t,n)=>Go(e,t,n),"image/edit":(e,t,n)=>Ko(e,t,n),"video/generate":(e,t,n)=>Jo(e,t,n),"speech/synthesize":(e,t,n)=>Yo(e,t,n),"speech/recognize":(e,t,n)=>Xo(e,t,n)},ps={"image/generate":e=>({data:e,artifacts:as(e),warnings:[],metadata:{}}),"image/edit":e=>({data:e,artifacts:as(e),warnings:[],metadata:{}}),"video/generate":e=>({data:e,artifacts:as(e),warnings:[],metadata:{}}),"speech/synthesize":e=>({data:e,artifacts:os(e,`audio`),warnings:[],metadata:{}}),"speech/recognize":e=>({data:e,artifacts:os(e,`transcript`),warnings:[],metadata:{}})},ms={"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`}]}}})),gs=j((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})),_s=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=gs();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}}})),q=j((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=gs(),n=_s();var r=gs();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=_s();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&&=ne(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=ne(this.rhs,e,n),this}get names(){return te(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=ne(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)||(re(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>ee(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(ie(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=ne(this.condition,e,t),this}get names(){let e=super.names;return te(e,this.condition),this.else&&ee(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=ne(this.iteration,e,t),this}get names(){return ee(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 te(te(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=ne(this.iterable,e,t),this}get names(){return ee(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&&ee(e,this.catch.names),this.finally&&ee(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?`
|
|
163
163
|
`:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function ee(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function te(e,n){return n instanceof t._CodeOrName?ee(e,n.names):e}function ne(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function re(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function ie(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${k(e)}`}e.not=ie;let ae=O(e.operators.AND);function oe(...e){return e.reduce(ae)}e.and=oe;let D=O(e.operators.OR);function se(...e){return e.reduce(D)}e.or=se;function O(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${k(n)} ${e} ${k(r)}`}function k(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),J=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;let t=q(),n=gs();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;let _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),vs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),ys=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=q(),n=J(),r=vs();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}let u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),bs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=ys(),n=q(),r=vs(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),xs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;let t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),Ss=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),Cs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;let t=xs(),n=Ss(),r=ys(),i=q(),a=J();var o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;let u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
|
|
164
164
|
|| (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
|
|
165
165
|
|| (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bailian-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "CLI for Aliyun Model Studio (DashScope) AI Platform.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"registry": "https://registry.npmjs.org/"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"bailian-cli-core": "1.1.
|
|
39
|
+
"bailian-cli-core": "1.1.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@clack/prompts": "^0.7.0",
|