bailian-cli 1.0.0 โ†’ 1.0.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 CHANGED
@@ -1,28 +1,28 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import{BailianError as e,DOCS_HOSTS as t,ExitCode as n,GLOBAL_OPTIONS as r,McpClient as i,appCompletionEndpoint as a,callConsoleGateway as o,chatEndpoint as s,clearApiKey as c,defineCommand as l,detectOutputFormat as u,formatOutput as d,generateFilename as f,generateToolSchema as p,getConfigDir as m,getConfigPath as h,imageEndpoint as g,imageSyncEndpoint as _,isInteractive as v,isLocalFile as y,loadConfig as b,maskToken as x,mcpWebSearchEndpoint as S,memoryAddEndpoint as ee,memoryListEndpoint as te,memoryNodeEndpoint as C,memorySearchEndpoint as ne,parseSSE as re,profileSchemaEndpoint as ie,readConfigFile as w,request as ae,requestJson as T,resolveCredential as E,resolveFileUrl as D,resolveOutputDir as O,signRequest as oe,speechRecognizeEndpoint as se,speechSynthesizeEndpoint as ce,stripUndefined as le,taskEndpoint as k,trackCommandExecution as ue,trackingHeaders as de,uploadFile as fe,userProfileEndpoint as pe,videoGenerateEndpoint as me,writeConfigFile as he}from"bailian-cli-core";import{execFile as ge}from"node:child_process";import{randomBytes as _e}from"node:crypto";import ve from"node:http";import A,{stdin as ye,stdout as be}from"node:process";import*as xe from"node:readline";import Se from"node:readline";import{WriteStream as Ce}from"node:tty";import{createWriteStream as we,existsSync as Te,mkdirSync as Ee,readFileSync as De,unlinkSync as Oe,writeFileSync as ke}from"fs";import{dirname as Ae,extname as je,join as Me}from"path";import{execSync as Ne}from"child_process";import{homedir as Pe}from"os";var Fe=Object.create,Ie=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,Re=Object.getOwnPropertyNames,ze=Object.getPrototypeOf,Be=Object.prototype.hasOwnProperty,j=(e,t)=>()=>(e&&(t=e(e=0)),t),Ve=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),He=(e,t)=>{let n={};for(var r in e)Ie(n,r,{get:e[r],enumerable:!0});return t||Ie(n,Symbol.toStringTag,{value:`Module`}),n},Ue=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Re(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Be.call(e,s)&&s!==n&&Ie(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Le(t,s))||r.enumerable});return e},We=(e,t,n)=>(n=e==null?{}:Fe(ze(e)),Ue(t||!e||!e.__esModule?Ie(n,`default`,{value:e,enumerable:!0}):n,e));function Ge(e){return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function Ke(e){let t=e.flag.match(/^--([a-z][a-z0-9-]*)/i);return t?Ge(t[1]):null}function qe(e){return e.type===`boolean`?!0:e.type===`string`||e.type===`number`||e.type===`array`?!1:!e.flag.includes(`<`)&&!e.flag.includes(`[`)}function Je(e){let t=new Set,n=new Set,r=new Set;for(let i of e){let e=Ke(i);e&&(qe(i)?t.add(e):i.type===`number`?n.add(e):i.type===`array`&&r.add(e))}return{booleans:t,numbers:n,arrays:r}}function Ye(e,t=[]){let n=Je(t),r=[],i=0;for(;i<e.length;){let t=e[i];if(t===`--`)break;if(t.startsWith(`--`)){let r=t.indexOf(`=`),a=Ge(r===-1?t.slice(2):t.slice(2,r));if(!n.booleans.has(a)&&r===-1){let t=e[i+1];t===void 0||t.startsWith(`-`)?i+=1:i+=2}else i+=1;continue}if(t.startsWith(`-`)){i++;continue}r.push(t),i++}return r}function Xe(t,r){let i=Je(r),a={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},o=0;for(;o<t.length;){let r=t[o];if(r===`--help`||r===`-h`){a.help=!0,o++;continue}if(r===`--`)break;if(r.startsWith(`--`)){let s=r.indexOf(`=`),c,l;s===-1?c=r.slice(2):(c=r.slice(2,s),l=r.slice(s+1));let u=Ge(c);if(i.booleans.has(u)){a[u]=!0,o++;continue}if(l===void 0&&(o++,l=t[o]),l===void 0)throw new e(`Flag --${c} requires a value.`,n.USAGE);if(i.arrays.has(u)){let e=a[u];e?e.push(l):a[u]=[l]}else if(i.numbers.has(u)){let t=Number(l);if(!Number.isFinite(t))throw new e(`Flag --${c} requires a finite number.`,n.USAGE);a[u]=t}else a[u]=l}o++}return a}var Ze,Qe,$e,et=j((()=>{Ze=`https://bailian.console.aliyun.com`,Qe=`${Ze}/cn-beijing`,$e=`${Qe}/?tab=app#/api-key`}));function tt(){let e=process.stderr.isTTY;return{purple:e?`\x1B[38;2;147;51;234m`:``,dim:e?`\x1B[2m`:``,reset:e?`\x1B[0m`:``}}function nt(){let{purple:e,reset:t}=tt();process.stderr.write(`\n Welcome to ${e}Bailian${t} CLI!\n\n`),process.stderr.write(` Get started in 2 steps:
4
- `),process.stderr.write(` 1. Get your API Key: ${$e}\n`),process.stderr.write(` 2. Login: bl auth login --api-key <your-key>
3
+ import{BailianError as e,CONSOLE_GATEWAY_NO_TOKEN_MESSAGE as t,DOCS_HOSTS as n,ExitCode as r,GLOBAL_OPTIONS as i,McpClient as a,appCompletionEndpoint as o,callConsoleGateway as s,chatEndpoint as c,clearApiKey as l,defineCommand as u,detectOutputFormat as d,flushTelemetry as f,formatOutput as p,generateFilename as m,generateToolSchema as h,getConfigDir as g,getConfigPath as _,imageEndpoint as v,imageSyncEndpoint as y,isInteractive as b,isLocalFile as x,loadConfig as S,maskToken as C,mcpWebSearchEndpoint as ee,memoryAddEndpoint as te,memoryListEndpoint as ne,memoryNodeEndpoint as re,memorySearchEndpoint as ie,parseSSE as ae,profileSchemaEndpoint as oe,readConfigFile as w,request as se,requestJson as T,resolveConsoleGatewayCredential as ce,resolveCredential as E,resolveFileUrl as D,resolveOutputDir as O,signRequest as le,speechRecognizeEndpoint as ue,speechSynthesizeEndpoint as de,stripUndefined as fe,taskEndpoint as k,trackCommandExecution as pe,trackingHeaders as me,uploadFile as he,userProfileEndpoint as ge,videoGenerateEndpoint as _e,writeConfigFile as ve}from"bailian-cli-core";import{execFile as ye}from"node:child_process";import{randomBytes as be}from"node:crypto";import xe from"node:http";import A,{stdin as Se,stdout as Ce}from"node:process";import*as we from"node:readline";import Te from"node:readline";import{WriteStream as Ee}from"node:tty";import{createWriteStream as De,existsSync as Oe,mkdirSync as ke,readFileSync as Ae,unlinkSync as je,writeFileSync as Me}from"fs";import{dirname as Ne,extname as Pe,join as Fe}from"path";import{execSync as Ie}from"child_process";import{homedir as Le}from"os";var Re=Object.create,ze=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,Ve=Object.getOwnPropertyNames,He=Object.getPrototypeOf,Ue=Object.prototype.hasOwnProperty,j=(e,t)=>()=>(e&&(t=e(e=0)),t),We=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Ge=(e,t)=>{let n={};for(var r in e)ze(n,r,{get:e[r],enumerable:!0});return t||ze(n,Symbol.toStringTag,{value:`Module`}),n},Ke=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Ve(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ue.call(e,s)&&s!==n&&ze(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Be(t,s))||r.enumerable});return e},qe=(e,t,n)=>(n=e==null?{}:Re(He(e)),Ke(t||!e||!e.__esModule?ze(n,`default`,{value:e,enumerable:!0}):n,e));function Je(e){return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function Ye(e){let t=e.flag.match(/^--([a-z][a-z0-9-]*)/i);return t?Je(t[1]):null}function Xe(e){return e.type===`boolean`?!0:e.type===`string`||e.type===`number`||e.type===`array`?!1:!e.flag.includes(`<`)&&!e.flag.includes(`[`)}function Ze(e){let t=new Set,n=new Set,r=new Set;for(let i of e){let e=Ye(i);e&&(Xe(i)?t.add(e):i.type===`number`?n.add(e):i.type===`array`&&r.add(e))}return{booleans:t,numbers:n,arrays:r}}function Qe(e,t=[]){let n=Ze(t),r=[],i=0;for(;i<e.length;){let t=e[i];if(t===`--`)break;if(t.startsWith(`--`)){let r=t.indexOf(`=`),a=Je(r===-1?t.slice(2):t.slice(2,r));if(!n.booleans.has(a)&&r===-1){let t=e[i+1];t===void 0||t.startsWith(`-`)?i+=1:i+=2}else i+=1;continue}if(t.startsWith(`-`)){i++;continue}r.push(t),i++}return r}function $e(t,n){let i=Ze(n),a={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},o=0;for(;o<t.length;){let n=t[o];if(n===`--help`||n===`-h`){a.help=!0,o++;continue}if(n===`--`)break;if(n.startsWith(`--`)){let s=n.indexOf(`=`),c,l;s===-1?c=n.slice(2):(c=n.slice(2,s),l=n.slice(s+1));let u=Je(c);if(i.booleans.has(u)){a[u]=!0,o++;continue}if(l===void 0&&(o++,l=t[o]),l===void 0)throw new e(`Flag --${c} requires a value.`,r.USAGE);if(i.arrays.has(u)){let e=a[u];e?e.push(l):a[u]=[l]}else if(i.numbers.has(u)){let t=Number(l);if(!Number.isFinite(t))throw new e(`Flag --${c} requires a finite number.`,r.USAGE);a[u]=t}else a[u]=l}o++}return a}var et,tt,nt,rt=j((()=>{et=`https://bailian.console.aliyun.com`,tt=`${et}/cn-beijing`,nt=`${tt}/?tab=app#/api-key`}));function it(){let e=process.stderr.isTTY;return{purple:e?`\x1B[38;2;147;51;234m`:``,dim:e?`\x1B[2m`:``,reset:e?`\x1B[0m`:``}}function at(){let{purple:e,reset:t}=it();process.stderr.write(`\n Welcome to ${e}Bailian${t} CLI!\n\n`),process.stderr.write(` Get started in 2 steps:
4
+ `),process.stderr.write(` 1. Get your API Key: ${nt}\n`),process.stderr.write(` 2. Login: bl auth login --api-key <your-key>
5
5
 
6
- `)}function rt(){let{dim:e,reset:t}=tt();process.stderr.write(`
6
+ `)}function ot(){let{dim:e,reset:t}=it();process.stderr.write(`
7
7
  ๐ŸŽฏ Try these with your AI coding assistant:
8
8
 
9
- `),it.forEach((n,r)=>{process.stderr.write(`${e}${r+1}${t} ${n}\n`)}),process.stderr.write(`
10
- `)}var it,at=j((()=>{et(),it=[`ๅธฎๆˆ‘็”Ÿๆˆไธ€ๅฅ—้ธญ่ˆŒๅธฝ็š„ไบš้ฉฌ้€Š็”ตๅ•†ไธปๅ›พ(็™ฝๅบ• + ๅœบๆ™ฏๅ›พ + ๆจก็‰นไธŠ่บซๅ›พ)`,`ๅธฎๆˆ‘็”Ÿๆˆไธ€ๆฎต 3 ๅˆ†้’Ÿ็š„ๅนฝ้ป˜็›ธๅฃฐ้Ÿณ้ข‘`,`ๅธฎๆˆ‘็”Ÿๆˆไธ€ๅฅ—ๅฐ็บขๅธฝๆ•…ไบ‹็ป˜ๆœฌ PDF(ๅซๆ’ๅ›พ)`,`ๅธฎๆˆ‘ๅˆ†ๆž่ฟ™ไธช่ง†้ข‘็š„ๅ†…ๅฎนๅนถๅ†™ไธ€็ฏ‡ๅฐ็บขไนฆๆ–‡ๆกˆ`]}));function M(e,t){process.stdout.write(d(e,t)+`
9
+ `),st.forEach((n,r)=>{process.stderr.write(`${e}${r+1}${t} ${n}\n`)}),process.stderr.write(`
10
+ `)}var st,ct=j((()=>{rt(),st=[`ๅธฎๆˆ‘็”Ÿๆˆไธ€ๅฅ—้ธญ่ˆŒๅธฝ็š„ไบš้ฉฌ้€Š็”ตๅ•†ไธปๅ›พ(็™ฝๅบ• + ๅœบๆ™ฏๅ›พ + ๆจก็‰นไธŠ่บซๅ›พ)`,`ๅธฎๆˆ‘็”Ÿๆˆไธ€ๆฎต 3 ๅˆ†้’Ÿ็š„ๅนฝ้ป˜็›ธๅฃฐ้Ÿณ้ข‘`,`ๅธฎๆˆ‘็”Ÿๆˆไธ€ๅฅ—ๅฐ็บขๅธฝๆ•…ไบ‹็ป˜ๆœฌ PDF(ๅซๆ’ๅ›พ)`,`ๅธฎๆˆ‘ๅˆ†ๆž่ฟ™ไธช่ง†้ข‘็š„ๅ†…ๅฎนๅนถๅ†™ไธ€็ฏ‡ๅฐ็บขไนฆๆ–‡ๆกˆ`]}));function M(e,t){process.stdout.write(p(e,t)+`
11
11
  `)}function N(e){process.stdout.write(e+`
12
- `)}var P=j((()=>{}));function ot(e){ut=e}function st(){return ut}function ct(e){dt=e}function lt(e=process.stderr){dt&&ut.length>0&&dt(ut,e)}var ut,dt,ft=j((()=>{ut=[],dt=null})),pt=Ve(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),mt=Ve(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c}));function ht({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}function gt(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Tt,``)}function _t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function vt(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=gt(e),e.length===0))return 0;e=e.replace(At(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(Ot.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}function yt(){let e=new Map;for(let[t,n]of Object.entries(L)){for(let[t,r]of Object.entries(n))L[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=L[t],e.set(r[0],r[1]);Object.defineProperty(L,t,{value:n,enumerable:!1})}return Object.defineProperty(L,`codes`,{value:e,enumerable:!1}),L.color.close=`\x1B[39m`,L.bgColor.close=`\x1B[49m`,L.color.ansi=Mt(),L.color.ansi256=Nt(),L.color.ansi16m=Pt(),L.bgColor.ansi=Mt(jt),L.bgColor.ansi256=Nt(jt),L.bgColor.ansi16m=Pt(jt),Object.defineProperties(L,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>L.rgbToAnsi256(...L.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>L.ansi256ToAnsi(L.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>L.ansi256ToAnsi(L.hexToAnsi256(e)),enumerable:!1}}),L}function bt(e,t,n){return String(e).normalize().replace(/\r\n/g,`
12
+ `)}var P=j((()=>{}));function lt(e){pt=e}function ut(){return pt}function dt(e){mt=e}function ft(e=process.stderr){mt&&pt.length>0&&mt(pt,e)}var pt,mt,ht=j((()=>{pt=[],mt=null})),gt=We(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),_t=We(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c}));function vt({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}function yt(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Ot,``)}function bt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function xt(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=yt(e),e.length===0))return 0;e=e.replace(Nt(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(jt.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}function St(){let e=new Map;for(let[t,n]of Object.entries(L)){for(let[t,r]of Object.entries(n))L[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=L[t],e.set(r[0],r[1]);Object.defineProperty(L,t,{value:n,enumerable:!1})}return Object.defineProperty(L,`codes`,{value:e,enumerable:!1}),L.color.close=`\x1B[39m`,L.bgColor.close=`\x1B[49m`,L.color.ansi=Ft(),L.color.ansi256=It(),L.color.ansi16m=Lt(),L.bgColor.ansi=Ft(Pt),L.bgColor.ansi256=It(Pt),L.bgColor.ansi16m=Lt(Pt),Object.defineProperties(L,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>L.rgbToAnsi256(...L.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>L.ansi256ToAnsi(L.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>L.ansi256ToAnsi(L.hexToAnsi256(e)),enumerable:!1}}),L}function Ct(e,t,n){return String(e).normalize().replace(/\r\n/g,`
13
13
  `).split(`
14
- `).map(e=>Xt(e,t,n)).join(`
15
- `)}function xt(e,t){if(e===t)return;let n=e.split(`
14
+ `).map(e=>$t(e,t,n)).join(`
15
+ `)}function wt(e,t){if(e===t)return;let n=e.split(`
16
16
  `),r=t.split(`
17
- `),i=[];for(let e=0;e<Math.max(n.length,r.length);e++)n[e]!==r[e]&&i.push(e);return i}function St(e){return e===$t}function Ct(e,t){e.isTTY&&e.setRawMode(t)}function wt({input:e=ye,output:t=be,overwrite:n=!0,hideCursor:r=!0}={}){let i=xe.createInterface({input:e,output:t,prompt:``,tabSize:1});xe.emitKeypressEvents(e,i),e.isTTY&&e.setRawMode(!0);let a=(i,{name:o})=>{if(String(i)===``){r&&t.write(F.cursor.show),process.exit(0);return}if(!n)return;let s=o===`return`?0:-1,c=o===`return`?-1:0;xe.moveCursor(t,s,c,()=>{xe.clearLine(t,1,()=>{e.once(`keypress`,a)})})};return r&&t.write(F.cursor.hide),e.once(`keypress`,a),()=>{e.off(`keypress`,a),r&&t.write(F.cursor.show),e.isTTY&&!On&&e.setRawMode(!1),i.terminal=!1,i.close()}}var F,I,Tt,Et,Dt,Ot,kt,At,jt,Mt,Nt,Pt,L,Ft,It,Lt,Rt,zt,Bt,Vt,Ht,Ut,Wt,Gt,Kt,qt,Jt,Yt,Xt,Zt,Qt,R,$t,en,tn,z,nn,rn,an,on,sn,cn,ln,un,dn,fn,pn,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn=j((()=>{F=pt(),I=We(mt(),1),Tt=ht(),Et={exports:{}},(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-+(u==2))if(o+u<=i)a+=l;else break;o+=u}return a}})(Et),Dt=Et.exports,Ot=_t(Dt),kt=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},At=_t(kt),jt=10,Mt=(e=0)=>t=>`\x1B[${t+e}m`,Nt=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Pt=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,L={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Object.keys(L.modifier),Ft=Object.keys(L.color),It=Object.keys(L.bgColor),[...Ft,...It],Lt=yt(),Rt=new Set([`\x1B`,`ย›`]),zt=39,Bt=`\x07`,Vt=`[`,Ht=`]`,Ut=`m`,Wt=`${Ht}8;;`,Gt=e=>`${Rt.values().next().value}${Vt}${e}${Ut}`,Kt=e=>`${Rt.values().next().value}${Wt}${e}${Bt}`,qt=e=>e.split(` `).map(e=>vt(e)),Jt=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=vt(gt(e[e.length-1]));for(let[t,s]of r.entries()){let c=vt(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),Rt.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(Wt)),i){a?s===Bt&&(i=!1,a=!1):s===Ut&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Yt=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(vt(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Xt=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=qt(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=vt(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),Jt(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){Jt(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){Jt(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>Yt(e)));let c=[...s.join(`
18
- `)];for(let[e,t]of c.entries()){if(r+=t,Rt.has(t)){let{groups:t}=RegExp(`(?:\\${Vt}(?<code>\\d+)m|\\${Wt}(?<uri>.*)${Bt})`).exec(c.slice(e).join(``))||{groups:{}};if(t.code!==void 0){let e=Number.parseFloat(t.code);i=e===zt?void 0:e}else t.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}let n=Lt.codes.get(Number(i));c[e+1]===`
19
- `?(a&&(r+=Kt(``)),i&&n&&(r+=Gt(n))):t===`
20
- `&&(i&&n&&(r+=Gt(i)),a&&(r+=Kt(a)))}return r},Zt=Object.defineProperty,Qt=(e,t,n)=>t in e?Zt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,R=(e,t,n)=>(Qt(e,typeof t==`symbol`?t:t+``,n),n),$t=Symbol(`clack:cancel`),en=new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`]]),tn=new Set([`up`,`down`,`left`,`right`,`space`,`enter`]),z=class{constructor({render:e,input:t=ye,output:n=be,...r},i=!0){R(this,`input`),R(this,`output`),R(this,`rl`),R(this,`opts`),R(this,`_track`,!1),R(this,`_render`),R(this,`_cursor`,0),R(this,`state`,`initial`),R(this,`value`),R(this,`error`,``),R(this,`subscribers`,new Map),R(this,`_prevFrame`,``),this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=e.bind(this),this._track=i,this.input=t,this.output=n}prompt(){let e=new Ce(0);return e._write=(e,t,n)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,``),this._cursor=this.rl.cursor,this.emit(`value`,this.value)),n()},this.input.pipe(e),this.rl=Se.createInterface({input:this.input,output:e,tabSize:2,prompt:``,escapeCodeTimeout:50}),Se.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on(`keypress`,this.onKeypress),Ct(this.input,!0),this.output.on(`resize`,this.render),this.render(),new Promise((e,t)=>{this.once(`submit`,()=>{this.output.write(F.cursor.show),this.output.off(`resize`,this.render),Ct(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(F.cursor.show),this.output.off(`resize`,this.render),Ct(this.input,!1),e($t)})})}on(e,t){let n=this.subscribers.get(e)??[];n.push({cb:t}),this.subscribers.set(e,n)}once(e,t){let n=this.subscribers.get(e)??[];n.push({cb:t,once:!0}),this.subscribers.set(e,n)}emit(e,...t){let n=this.subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}unsubscribe(){this.subscribers.clear()}onKeypress(e,t){if(this.state===`error`&&(this.state=`active`),t?.name&&!this._track&&en.has(t.name)&&this.emit(`cursor`,en.get(t.name)),t?.name&&tn.has(t.name)&&this.emit(`cursor`,t.name),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),e===` `&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit(`value`,this.opts.placeholder))),e&&this.emit(`key`,e.toLowerCase()),t?.name===`return`){if(this.opts.validate){let e=this.opts.validate(this.value);e&&(this.error=e,this.state=`error`,this.rl.write(this.value))}this.state!==`error`&&(this.state=`submit`)}e===``&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
21
- `),Ct(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=bt(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
22
- `).length-1;this.output.write(F.cursor.move(-999,e*-1))}render(){let e=bt(this._render(this)??``,process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(F.cursor.hide);else{let t=xt(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let n=t[0];this.output.write(F.cursor.move(0,n)),this.output.write(F.erase.lines(1));let r=e.split(`
17
+ `),i=[];for(let e=0;e<Math.max(n.length,r.length);e++)n[e]!==r[e]&&i.push(e);return i}function Tt(e){return e===nn}function Et(e,t){e.isTTY&&e.setRawMode(t)}function Dt({input:e=Se,output:t=Ce,overwrite:n=!0,hideCursor:r=!0}={}){let i=we.createInterface({input:e,output:t,prompt:``,tabSize:1});we.emitKeypressEvents(e,i),e.isTTY&&e.setRawMode(!0);let a=(i,{name:o})=>{if(String(i)===``){r&&t.write(F.cursor.show),process.exit(0);return}if(!n)return;let s=o===`return`?0:-1,c=o===`return`?-1:0;we.moveCursor(t,s,c,()=>{we.clearLine(t,1,()=>{e.once(`keypress`,a)})})};return r&&t.write(F.cursor.hide),e.once(`keypress`,a),()=>{e.off(`keypress`,a),r&&t.write(F.cursor.show),e.isTTY&&!jn&&e.setRawMode(!1),i.terminal=!1,i.close()}}var F,I,Ot,kt,At,jt,Mt,Nt,Pt,Ft,It,Lt,L,Rt,zt,Bt,Vt,Ht,Ut,Wt,Gt,Kt,qt,Jt,Yt,Xt,Zt,Qt,$t,en,tn,R,nn,rn,an,z,on,sn,cn,ln,un,dn,fn,pn,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn=j((()=>{F=gt(),I=qe(_t(),1),Ot=vt(),kt={exports:{}},(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-+(u==2))if(o+u<=i)a+=l;else break;o+=u}return a}})(kt),At=kt.exports,jt=bt(At),Mt=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},Nt=bt(Mt),Pt=10,Ft=(e=0)=>t=>`\x1B[${t+e}m`,It=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Lt=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,L={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Object.keys(L.modifier),Rt=Object.keys(L.color),zt=Object.keys(L.bgColor),[...Rt,...zt],Bt=St(),Vt=new Set([`\x1B`,`ย›`]),Ht=39,Ut=`\x07`,Wt=`[`,Gt=`]`,Kt=`m`,qt=`${Gt}8;;`,Jt=e=>`${Vt.values().next().value}${Wt}${e}${Kt}`,Yt=e=>`${Vt.values().next().value}${qt}${e}${Ut}`,Xt=e=>e.split(` `).map(e=>xt(e)),Zt=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=xt(yt(e[e.length-1]));for(let[t,s]of r.entries()){let c=xt(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),Vt.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(qt)),i){a?s===Ut&&(i=!1,a=!1):s===Kt&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Qt=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(xt(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},$t=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=Xt(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=xt(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),Zt(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){Zt(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){Zt(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>Qt(e)));let c=[...s.join(`
18
+ `)];for(let[e,t]of c.entries()){if(r+=t,Vt.has(t)){let{groups:t}=RegExp(`(?:\\${Wt}(?<code>\\d+)m|\\${qt}(?<uri>.*)${Ut})`).exec(c.slice(e).join(``))||{groups:{}};if(t.code!==void 0){let e=Number.parseFloat(t.code);i=e===Ht?void 0:e}else t.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}let n=Bt.codes.get(Number(i));c[e+1]===`
19
+ `?(a&&(r+=Yt(``)),i&&n&&(r+=Jt(n))):t===`
20
+ `&&(i&&n&&(r+=Jt(i)),a&&(r+=Yt(a)))}return r},en=Object.defineProperty,tn=(e,t,n)=>t in e?en(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,R=(e,t,n)=>(tn(e,typeof t==`symbol`?t:t+``,n),n),nn=Symbol(`clack:cancel`),rn=new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`]]),an=new Set([`up`,`down`,`left`,`right`,`space`,`enter`]),z=class{constructor({render:e,input:t=Se,output:n=Ce,...r},i=!0){R(this,`input`),R(this,`output`),R(this,`rl`),R(this,`opts`),R(this,`_track`,!1),R(this,`_render`),R(this,`_cursor`,0),R(this,`state`,`initial`),R(this,`value`),R(this,`error`,``),R(this,`subscribers`,new Map),R(this,`_prevFrame`,``),this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=e.bind(this),this._track=i,this.input=t,this.output=n}prompt(){let e=new Ee(0);return e._write=(e,t,n)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,``),this._cursor=this.rl.cursor,this.emit(`value`,this.value)),n()},this.input.pipe(e),this.rl=Te.createInterface({input:this.input,output:e,tabSize:2,prompt:``,escapeCodeTimeout:50}),Te.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on(`keypress`,this.onKeypress),Et(this.input,!0),this.output.on(`resize`,this.render),this.render(),new Promise((e,t)=>{this.once(`submit`,()=>{this.output.write(F.cursor.show),this.output.off(`resize`,this.render),Et(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(F.cursor.show),this.output.off(`resize`,this.render),Et(this.input,!1),e(nn)})})}on(e,t){let n=this.subscribers.get(e)??[];n.push({cb:t}),this.subscribers.set(e,n)}once(e,t){let n=this.subscribers.get(e)??[];n.push({cb:t,once:!0}),this.subscribers.set(e,n)}emit(e,...t){let n=this.subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}unsubscribe(){this.subscribers.clear()}onKeypress(e,t){if(this.state===`error`&&(this.state=`active`),t?.name&&!this._track&&rn.has(t.name)&&this.emit(`cursor`,rn.get(t.name)),t?.name&&an.has(t.name)&&this.emit(`cursor`,t.name),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),e===` `&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit(`value`,this.opts.placeholder))),e&&this.emit(`key`,e.toLowerCase()),t?.name===`return`){if(this.opts.validate){let e=this.opts.validate(this.value);e&&(this.error=e,this.state=`error`,this.rl.write(this.value))}this.state!==`error`&&(this.state=`submit`)}e===``&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
21
+ `),Et(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=Ct(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
22
+ `).length-1;this.output.write(F.cursor.move(-999,e*-1))}render(){let e=Ct(this._render(this)??``,process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(F.cursor.hide);else{let t=wt(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let n=t[0];this.output.write(F.cursor.move(0,n)),this.output.write(F.erase.lines(1));let r=e.split(`
23
23
  `);this.output.write(r[n]),this._prevFrame=e,this.output.write(F.cursor.move(0,r.length-n-1));return}else if(t&&t?.length>1){let n=t[0];this.output.write(F.cursor.move(0,n)),this.output.write(F.erase.down());let r=e.split(`
24
24
  `).slice(n);this.output.write(r.join(`
25
- `)),this._prevFrame=e;return}this.output.write(F.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},nn=class extends z{get cursor(){return+!this.value}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`value`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(F.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},rn=Object.defineProperty,an=(e,t,n)=>t in e?rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,on=(e,t,n)=>(an(e,typeof t==`symbol`?t:t+``,n),n),sn=class extends z{constructor(e){super(e,!1),on(this,`options`),on(this,`cursor`,0);let{options:t}=e;this.options=Object.entries(t).flatMap(([e,t])=>[{value:e,group:!0,label:e},...t.map(t=>({...t,group:e}))]),this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case`space`:this.toggleValue();break}})}getGroupItems(e){return this.options.filter(t=>t.group===e)}isGroupSelected(e){return this.getGroupItems(e).every(e=>this.value.includes(e.value))}toggleValue(){let e=this.options[this.cursor];if(e.group===!0){let t=e.value,n=this.getGroupItems(t);this.isGroupSelected(t)?this.value=this.value.filter(e=>n.findIndex(t=>t.value===e)===-1):this.value=[...this.value,...n.map(e=>e.value)],this.value=Array.from(new Set(this.value))}else{let t=this.value.includes(e.value);this.value=t?this.value.filter(t=>t!==e.value):[...this.value,e.value]}}},cn=Object.defineProperty,ln=(e,t,n)=>t in e?cn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,un=(e,t,n)=>(ln(e,typeof t==`symbol`?t:t+``,n),n),dn=class extends z{constructor(e){super(e,!1),un(this,`options`),un(this,`cursor`,0),this.options=e.options,this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on(`key`,e=>{e===`a`&&this.toggleAll()}),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case`space`:this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let e=this.value.length===this.options.length;this.value=e?[]:this.options.map(e=>e.value)}toggleValue(){let e=this.value.includes(this._value);this.value=e?this.value.filter(e=>e!==this._value):[...this.value,this._value]}},fn=Object.defineProperty,pn=(e,t,n)=>t in e?fn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mn=(e,t,n)=>(pn(e,typeof t==`symbol`?t:t+``,n),n),hn=class extends z{constructor({mask:e,...t}){super(t),mn(this,`valueWithCursor`,``),mn(this,`_mask`,`โ€ข`),this._mask=e??`โ€ข`,this.on(`finalize`,()=>{this.valueWithCursor=this.masked}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${I.default.inverse(I.default.hidden(`_`))}`;else{let e=this.masked.slice(0,this.cursor),t=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${I.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}},gn=Object.defineProperty,_n=(e,t,n)=>t in e?gn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vn=(e,t,n)=>(_n(e,typeof t==`symbol`?t:t+``,n),n),yn=class extends z{constructor(e){super(e,!1),vn(this,`options`),vn(this,`cursor`,0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},bn=Object.defineProperty,xn=(e,t,n)=>t in e?bn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Sn=(e,t,n)=>(xn(e,typeof t==`symbol`?t:t+``,n),n),Cn=class extends z{constructor(e){super(e,!1),Sn(this,`options`),Sn(this,`cursor`,0),this.options=e.options;let t=this.options.map(({value:[e]})=>e?.toLowerCase());this.cursor=Math.max(t.indexOf(e.initialValue),0),this.on(`key`,e=>{if(!t.includes(e))return;let n=this.options.find(({value:[t]})=>t?.toLowerCase()===e);n&&(this.value=n.value,this.state=`submit`,this.emit(`submit`))})}},wn=Object.defineProperty,Tn=(e,t,n)=>t in e?wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,En=(e,t,n)=>(Tn(e,typeof t==`symbol`?t:t+``,n),n),Dn=class extends z{constructor(e){super(e),En(this,`valueWithCursor`,``),this.on(`finalize`,()=>{this.value||=e.defaultValue,this.valueWithCursor=this.value}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${I.default.inverse(I.default.hidden(`_`))}`;else{let e=this.value.slice(0,this.cursor),t=this.value.slice(this.cursor);this.valueWithCursor=`${e}${I.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}},On=globalThis.process.platform.startsWith(`win`)})),An=He({cancel:()=>lr,confirm:()=>nr,group:()=>pr,groupMultiselect:()=>or,intro:()=>ur,isCancel:()=>St,log:()=>G,multiselect:()=>ar,note:()=>cr,outro:()=>dr,password:()=>tr,select:()=>rr,selectKey:()=>ir,spinner:()=>fr,text:()=>er});function jn(){return A.platform===`win32`?!!A.env.CI||!!A.env.WT_SESSION||!!A.env.TERMINUS_SUBLIME||A.env.ConEmuTask===`{cmd::Cmder}`||A.env.TERM_PROGRAM===`Terminus-Sublime`||A.env.TERM_PROGRAM===`vscode`||A.env.TERM===`xterm-256color`||A.env.TERM===`alacritty`||A.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:A.env.TERM!==`linux`}function Mn(){let e=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(e,`g`)}var B,Nn,Pn,V,Fn,In,Ln,Rn,zn,H,U,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn,Qn,$n,W,er,tr,nr,rr,ir,ar,or,sr,cr,lr,ur,dr,G,fr,pr,mr=j((()=>{kn(),B=We(mt(),1),Nn=pt(),Pn=jn(),V=(e,t)=>Pn?e:t,Fn=V(`โ—†`,`*`),In=V(`โ– `,`x`),Ln=V(`โ–ฒ`,`x`),Rn=V(`โ—‡`,`o`),zn=V(`โ”Œ`,`T`),H=V(`โ”‚`,`|`),U=V(`โ””`,`โ€”`),Bn=V(`โ—`,`>`),Vn=V(`โ—‹`,` `),Hn=V(`โ—ป`,`[โ€ข]`),Un=V(`โ—ผ`,`[+]`),Wn=V(`โ—ป`,`[ ]`),Gn=V(`โ–ช`,`โ€ข`),Kn=V(`โ”€`,`-`),qn=V(`โ•ฎ`,`+`),Jn=V(`โ”œ`,`+`),Yn=V(`โ•ฏ`,`+`),Xn=V(`โ—`,`โ€ข`),Zn=V(`โ—†`,`*`),Qn=V(`โ–ฒ`,`!`),$n=V(`โ– `,`x`),W=e=>{switch(e){case`initial`:case`active`:return B.default.cyan(Fn);case`cancel`:return B.default.red(In);case`error`:return B.default.yellow(Ln);case`submit`:return B.default.green(Rn)}},er=e=>new Dn({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){let t=`${B.default.gray(H)}
25
+ `)),this._prevFrame=e;return}this.output.write(F.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},on=class extends z{get cursor(){return+!this.value}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`value`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(F.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},sn=Object.defineProperty,cn=(e,t,n)=>t in e?sn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ln=(e,t,n)=>(cn(e,typeof t==`symbol`?t:t+``,n),n),un=class extends z{constructor(e){super(e,!1),ln(this,`options`),ln(this,`cursor`,0);let{options:t}=e;this.options=Object.entries(t).flatMap(([e,t])=>[{value:e,group:!0,label:e},...t.map(t=>({...t,group:e}))]),this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case`space`:this.toggleValue();break}})}getGroupItems(e){return this.options.filter(t=>t.group===e)}isGroupSelected(e){return this.getGroupItems(e).every(e=>this.value.includes(e.value))}toggleValue(){let e=this.options[this.cursor];if(e.group===!0){let t=e.value,n=this.getGroupItems(t);this.isGroupSelected(t)?this.value=this.value.filter(e=>n.findIndex(t=>t.value===e)===-1):this.value=[...this.value,...n.map(e=>e.value)],this.value=Array.from(new Set(this.value))}else{let t=this.value.includes(e.value);this.value=t?this.value.filter(t=>t!==e.value):[...this.value,e.value]}}},dn=Object.defineProperty,fn=(e,t,n)=>t in e?dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pn=(e,t,n)=>(fn(e,typeof t==`symbol`?t:t+``,n),n),mn=class extends z{constructor(e){super(e,!1),pn(this,`options`),pn(this,`cursor`,0),this.options=e.options,this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on(`key`,e=>{e===`a`&&this.toggleAll()}),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case`space`:this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let e=this.value.length===this.options.length;this.value=e?[]:this.options.map(e=>e.value)}toggleValue(){let e=this.value.includes(this._value);this.value=e?this.value.filter(e=>e!==this._value):[...this.value,this._value]}},hn=Object.defineProperty,gn=(e,t,n)=>t in e?hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_n=(e,t,n)=>(gn(e,typeof t==`symbol`?t:t+``,n),n),vn=class extends z{constructor({mask:e,...t}){super(t),_n(this,`valueWithCursor`,``),_n(this,`_mask`,`โ€ข`),this._mask=e??`โ€ข`,this.on(`finalize`,()=>{this.valueWithCursor=this.masked}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${I.default.inverse(I.default.hidden(`_`))}`;else{let e=this.masked.slice(0,this.cursor),t=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${I.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}},yn=Object.defineProperty,bn=(e,t,n)=>t in e?yn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xn=(e,t,n)=>(bn(e,typeof t==`symbol`?t:t+``,n),n),Sn=class extends z{constructor(e){super(e,!1),xn(this,`options`),xn(this,`cursor`,0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},Cn=Object.defineProperty,wn=(e,t,n)=>t in e?Cn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tn=(e,t,n)=>(wn(e,typeof t==`symbol`?t:t+``,n),n),En=class extends z{constructor(e){super(e,!1),Tn(this,`options`),Tn(this,`cursor`,0),this.options=e.options;let t=this.options.map(({value:[e]})=>e?.toLowerCase());this.cursor=Math.max(t.indexOf(e.initialValue),0),this.on(`key`,e=>{if(!t.includes(e))return;let n=this.options.find(({value:[t]})=>t?.toLowerCase()===e);n&&(this.value=n.value,this.state=`submit`,this.emit(`submit`))})}},Dn=Object.defineProperty,On=(e,t,n)=>t in e?Dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,kn=(e,t,n)=>(On(e,typeof t==`symbol`?t:t+``,n),n),An=class extends z{constructor(e){super(e),kn(this,`valueWithCursor`,``),this.on(`finalize`,()=>{this.value||=e.defaultValue,this.valueWithCursor=this.value}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${I.default.inverse(I.default.hidden(`_`))}`;else{let e=this.value.slice(0,this.cursor),t=this.value.slice(this.cursor);this.valueWithCursor=`${e}${I.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}},jn=globalThis.process.platform.startsWith(`win`)})),Nn=Ge({cancel:()=>fr,confirm:()=>ar,group:()=>gr,groupMultiselect:()=>lr,intro:()=>pr,isCancel:()=>Tt,log:()=>G,multiselect:()=>cr,note:()=>dr,outro:()=>mr,password:()=>ir,select:()=>or,selectKey:()=>sr,spinner:()=>hr,text:()=>rr});function Pn(){return A.platform===`win32`?!!A.env.CI||!!A.env.WT_SESSION||!!A.env.TERMINUS_SUBLIME||A.env.ConEmuTask===`{cmd::Cmder}`||A.env.TERM_PROGRAM===`Terminus-Sublime`||A.env.TERM_PROGRAM===`vscode`||A.env.TERM===`xterm-256color`||A.env.TERM===`alacritty`||A.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:A.env.TERM!==`linux`}function Fn(){let e=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(e,`g`)}var B,In,Ln,V,Rn,zn,Bn,Vn,Hn,H,U,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn,Qn,$n,er,tr,nr,W,rr,ir,ar,or,sr,cr,lr,ur,dr,fr,pr,mr,G,hr,gr,_r=j((()=>{Mn(),B=qe(_t(),1),In=gt(),Ln=Pn(),V=(e,t)=>Ln?e:t,Rn=V(`โ—†`,`*`),zn=V(`โ– `,`x`),Bn=V(`โ–ฒ`,`x`),Vn=V(`โ—‡`,`o`),Hn=V(`โ”Œ`,`T`),H=V(`โ”‚`,`|`),U=V(`โ””`,`โ€”`),Un=V(`โ—`,`>`),Wn=V(`โ—‹`,` `),Gn=V(`โ—ป`,`[โ€ข]`),Kn=V(`โ—ผ`,`[+]`),qn=V(`โ—ป`,`[ ]`),Jn=V(`โ–ช`,`โ€ข`),Yn=V(`โ”€`,`-`),Xn=V(`โ•ฎ`,`+`),Zn=V(`โ”œ`,`+`),Qn=V(`โ•ฏ`,`+`),$n=V(`โ—`,`โ€ข`),er=V(`โ—†`,`*`),tr=V(`โ–ฒ`,`!`),nr=V(`โ– `,`x`),W=e=>{switch(e){case`initial`:case`active`:return B.default.cyan(Rn);case`cancel`:return B.default.red(zn);case`error`:return B.default.yellow(Bn);case`submit`:return B.default.green(Vn)}},rr=e=>new An({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){let t=`${B.default.gray(H)}
26
26
  ${W(this.state)} ${e.message}
27
27
  `,n=e.placeholder?B.default.inverse(e.placeholder[0])+B.default.dim(e.placeholder.slice(1)):B.default.inverse(B.default.hidden(`_`)),r=this.value?this.valueWithCursor:n;switch(this.state){case`error`:return`${t.trim()}
28
28
  ${B.default.yellow(H)} ${r}
@@ -30,7 +30,7 @@ ${B.default.yellow(U)} ${B.default.yellow(this.error)}
30
30
  `;case`submit`:return`${t}${B.default.gray(H)} ${B.default.dim(this.value||e.placeholder)}`;case`cancel`:return`${t}${B.default.gray(H)} ${B.default.strikethrough(B.default.dim(this.value??``))}${this.value?.trim()?`
31
31
  `+B.default.gray(H):``}`;default:return`${t}${B.default.cyan(H)} ${r}
32
32
  ${B.default.cyan(U)}
33
- `}}}).prompt(),tr=e=>new hn({validate:e.validate,mask:e.mask??Gn,render(){let t=`${B.default.gray(H)}
33
+ `}}}).prompt(),ir=e=>new vn({validate:e.validate,mask:e.mask??Jn,render(){let t=`${B.default.gray(H)}
34
34
  ${W(this.state)} ${e.message}
35
35
  `,n=this.valueWithCursor,r=this.masked;switch(this.state){case`error`:return`${t.trim()}
36
36
  ${B.default.yellow(H)} ${r}
@@ -38,24 +38,24 @@ ${B.default.yellow(U)} ${B.default.yellow(this.error)}
38
38
  `;case`submit`:return`${t}${B.default.gray(H)} ${B.default.dim(r)}`;case`cancel`:return`${t}${B.default.gray(H)} ${B.default.strikethrough(B.default.dim(r??``))}${r?`
39
39
  `+B.default.gray(H):``}`;default:return`${t}${B.default.cyan(H)} ${n}
40
40
  ${B.default.cyan(U)}
41
- `}}}).prompt(),nr=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new nn({active:t,inactive:n,initialValue:e.initialValue??!0,render(){let r=`${B.default.gray(H)}
41
+ `}}}).prompt(),ar=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new on({active:t,inactive:n,initialValue:e.initialValue??!0,render(){let r=`${B.default.gray(H)}
42
42
  ${W(this.state)} ${e.message}
43
43
  `,i=this.value?t:n;switch(this.state){case`submit`:return`${r}${B.default.gray(H)} ${B.default.dim(i)}`;case`cancel`:return`${r}${B.default.gray(H)} ${B.default.strikethrough(B.default.dim(i))}
44
- ${B.default.gray(H)}`;default:return`${r}${B.default.cyan(H)} ${this.value?`${B.default.green(Bn)} ${t}`:`${B.default.dim(Vn)} ${B.default.dim(t)}`} ${B.default.dim(`/`)} ${this.value?`${B.default.dim(Vn)} ${B.default.dim(n)}`:`${B.default.green(Bn)} ${n}`}
44
+ ${B.default.gray(H)}`;default:return`${r}${B.default.cyan(H)} ${this.value?`${B.default.green(Un)} ${t}`:`${B.default.dim(Wn)} ${B.default.dim(t)}`} ${B.default.dim(`/`)} ${this.value?`${B.default.dim(Wn)} ${B.default.dim(n)}`:`${B.default.green(Un)} ${n}`}
45
45
  ${B.default.cyan(U)}
46
- `}}}).prompt()},rr=e=>{let t=(e,t)=>{let n=e.label??String(e.value);return t===`active`?`${B.default.green(Bn)} ${n} ${e.hint?B.default.dim(`(${e.hint})`):``}`:t===`selected`?`${B.default.dim(n)}`:t===`cancelled`?`${B.default.strikethrough(B.default.dim(n))}`:`${B.default.dim(Vn)} ${B.default.dim(n)}`},n=0;return new yn({options:e.options,initialValue:e.initialValue,render(){let r=`${B.default.gray(H)}
46
+ `}}}).prompt()},or=e=>{let t=(e,t)=>{let n=e.label??String(e.value);return t===`active`?`${B.default.green(Un)} ${n} ${e.hint?B.default.dim(`(${e.hint})`):``}`:t===`selected`?`${B.default.dim(n)}`:t===`cancelled`?`${B.default.strikethrough(B.default.dim(n))}`:`${B.default.dim(Wn)} ${B.default.dim(n)}`},n=0;return new Sn({options:e.options,initialValue:e.initialValue,render(){let r=`${B.default.gray(H)}
47
47
  ${W(this.state)} ${e.message}
48
48
  `;switch(this.state){case`submit`:return`${r}${B.default.gray(H)} ${t(this.options[this.cursor],`selected`)}`;case`cancel`:return`${r}${B.default.gray(H)} ${t(this.options[this.cursor],`cancelled`)}
49
49
  ${B.default.gray(H)}`;default:{let i=e.maxItems===void 0?1/0:Math.max(e.maxItems,5);this.cursor>=n+i-3?n=Math.max(Math.min(this.cursor-i+3,this.options.length-i),0):this.cursor<n+2&&(n=Math.max(this.cursor-2,0));let a=i<this.options.length&&n>0,o=i<this.options.length&&n+i<this.options.length;return`${r}${B.default.cyan(H)} ${this.options.slice(n,n+i).map((e,r,i)=>r===0&&a||r===i.length-1&&o?B.default.dim(`...`):t(e,r+n===this.cursor?`active`:`inactive`)).join(`
50
50
  ${B.default.cyan(H)} `)}
51
51
  ${B.default.cyan(U)}
52
- `}}}}).prompt()},ir=e=>{let t=(e,t=`inactive`)=>{let n=e.label??String(e.value);return t===`selected`?`${B.default.dim(n)}`:t===`cancelled`?`${B.default.strikethrough(B.default.dim(n))}`:t===`active`?`${B.default.bgCyan(B.default.gray(` ${e.value} `))} ${n} ${e.hint?B.default.dim(`(${e.hint})`):``}`:`${B.default.gray(B.default.bgWhite(B.default.inverse(` ${e.value} `)))} ${n} ${e.hint?B.default.dim(`(${e.hint})`):``}`};return new Cn({options:e.options,initialValue:e.initialValue,render(){let n=`${B.default.gray(H)}
52
+ `}}}}).prompt()},sr=e=>{let t=(e,t=`inactive`)=>{let n=e.label??String(e.value);return t===`selected`?`${B.default.dim(n)}`:t===`cancelled`?`${B.default.strikethrough(B.default.dim(n))}`:t===`active`?`${B.default.bgCyan(B.default.gray(` ${e.value} `))} ${n} ${e.hint?B.default.dim(`(${e.hint})`):``}`:`${B.default.gray(B.default.bgWhite(B.default.inverse(` ${e.value} `)))} ${n} ${e.hint?B.default.dim(`(${e.hint})`):``}`};return new En({options:e.options,initialValue:e.initialValue,render(){let n=`${B.default.gray(H)}
53
53
  ${W(this.state)} ${e.message}
54
54
  `;switch(this.state){case`submit`:return`${n}${B.default.gray(H)} ${t(this.options.find(e=>e.value===this.value),`selected`)}`;case`cancel`:return`${n}${B.default.gray(H)} ${t(this.options[0],`cancelled`)}
55
55
  ${B.default.gray(H)}`;default:return`${n}${B.default.cyan(H)} ${this.options.map((e,n)=>t(e,n===this.cursor?`active`:`inactive`)).join(`
56
56
  ${B.default.cyan(H)} `)}
57
57
  ${B.default.cyan(U)}
58
- `}}}).prompt()},ar=e=>{let t=(e,t)=>{let n=e.label??String(e.value);return t===`active`?`${B.default.cyan(Hn)} ${n} ${e.hint?B.default.dim(`(${e.hint})`):``}`:t===`selected`?`${B.default.green(Un)} ${B.default.dim(n)}`:t===`cancelled`?`${B.default.strikethrough(B.default.dim(n))}`:t===`active-selected`?`${B.default.green(Un)} ${n} ${e.hint?B.default.dim(`(${e.hint})`):``}`:t===`submitted`?`${B.default.dim(n)}`:`${B.default.dim(Wn)} ${B.default.dim(n)}`};return new dn({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
58
+ `}}}).prompt()},cr=e=>{let t=(e,t)=>{let n=e.label??String(e.value);return t===`active`?`${B.default.cyan(Gn)} ${n} ${e.hint?B.default.dim(`(${e.hint})`):``}`:t===`selected`?`${B.default.green(Kn)} ${B.default.dim(n)}`:t===`cancelled`?`${B.default.strikethrough(B.default.dim(n))}`:t===`active-selected`?`${B.default.green(Kn)} ${n} ${e.hint?B.default.dim(`(${e.hint})`):``}`:t===`submitted`?`${B.default.dim(n)}`:`${B.default.dim(qn)} ${B.default.dim(n)}`};return new mn({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
59
59
  ${B.default.reset(B.default.dim(`Press ${B.default.gray(B.default.bgWhite(B.default.inverse(` space `)))} to select, ${B.default.gray(B.default.bgWhite(B.default.inverse(` enter `)))} to submit`))}`},render(){let n=`${B.default.gray(H)}
60
60
  ${W(this.state)} ${e.message}
61
61
  `;switch(this.state){case`submit`:return`${n}${B.default.gray(H)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`submitted`)).join(B.default.dim(`, `))||B.default.dim(`none`)}`;case`cancel`:{let e=this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`cancelled`)).join(B.default.dim(`, `));return`${n}${B.default.gray(H)} ${e.trim()?`${e}
@@ -67,7 +67,7 @@ ${B.default.yellow(H)} `)+`
67
67
  `}default:return`${n}${B.default.cyan(H)} ${this.options.map((e,n)=>{let r=this.value.includes(e.value),i=n===this.cursor;return i&&r?t(e,`active-selected`):r?t(e,`selected`):t(e,i?`active`:`inactive`)}).join(`
68
68
  ${B.default.cyan(H)} `)}
69
69
  ${B.default.cyan(U)}
70
- `}}}).prompt()},or=e=>{let t=(e,t,n=[])=>{let r=e.label??String(e.value),i=typeof e.group==`string`,a=i&&(n[n.indexOf(e)+1]??{group:!0}),o=i&&a.group===!0,s=i?`${o?U:H} `:``;return t===`active`?`${B.default.dim(s)}${B.default.cyan(Hn)} ${r} ${e.hint?B.default.dim(`(${e.hint})`):``}`:t===`group-active`?`${s}${B.default.cyan(Hn)} ${B.default.dim(r)}`:t===`group-active-selected`?`${s}${B.default.green(Un)} ${B.default.dim(r)}`:t===`selected`?`${B.default.dim(s)}${B.default.green(Un)} ${B.default.dim(r)}`:t===`cancelled`?`${B.default.strikethrough(B.default.dim(r))}`:t===`active-selected`?`${B.default.dim(s)}${B.default.green(Un)} ${r} ${e.hint?B.default.dim(`(${e.hint})`):``}`:t===`submitted`?`${B.default.dim(r)}`:`${B.default.dim(s)}${B.default.dim(Wn)} ${B.default.dim(r)}`};return new sn({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
70
+ `}}}).prompt()},lr=e=>{let t=(e,t,n=[])=>{let r=e.label??String(e.value),i=typeof e.group==`string`,a=i&&(n[n.indexOf(e)+1]??{group:!0}),o=i&&a.group===!0,s=i?`${o?U:H} `:``;return t===`active`?`${B.default.dim(s)}${B.default.cyan(Gn)} ${r} ${e.hint?B.default.dim(`(${e.hint})`):``}`:t===`group-active`?`${s}${B.default.cyan(Gn)} ${B.default.dim(r)}`:t===`group-active-selected`?`${s}${B.default.green(Kn)} ${B.default.dim(r)}`:t===`selected`?`${B.default.dim(s)}${B.default.green(Kn)} ${B.default.dim(r)}`:t===`cancelled`?`${B.default.strikethrough(B.default.dim(r))}`:t===`active-selected`?`${B.default.dim(s)}${B.default.green(Kn)} ${r} ${e.hint?B.default.dim(`(${e.hint})`):``}`:t===`submitted`?`${B.default.dim(r)}`:`${B.default.dim(s)}${B.default.dim(qn)} ${B.default.dim(r)}`};return new un({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
71
71
  ${B.default.reset(B.default.dim(`Press ${B.default.gray(B.default.bgWhite(B.default.inverse(` space `)))} to select, ${B.default.gray(B.default.bgWhite(B.default.inverse(` enter `)))} to submit`))}`},render(){let n=`${B.default.gray(H)}
72
72
  ${W(this.state)} ${e.message}
73
73
  `;switch(this.state){case`submit`:return`${n}${B.default.gray(H)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`submitted`)).join(B.default.dim(`, `))}`;case`cancel`:{let e=this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`cancelled`)).join(B.default.dim(`, `));return`${n}${B.default.gray(H)} ${e.trim()?`${e}
@@ -79,91 +79,92 @@ ${e}
79
79
  `}default:return`${n}${B.default.cyan(H)} ${this.options.map((e,n,r)=>{let i=this.value.includes(e.value)||e.group===!0&&this.isGroupSelected(`${e.value}`),a=n===this.cursor;return!a&&typeof e.group==`string`&&this.options[this.cursor].value===e.group?t(e,i?`group-active-selected`:`group-active`,r):a&&i?t(e,`active-selected`,r):i?t(e,`selected`,r):t(e,a?`active`:`inactive`,r)}).join(`
80
80
  ${B.default.cyan(H)} `)}
81
81
  ${B.default.cyan(U)}
82
- `}}}).prompt()},sr=e=>e.replace(Mn(),``),cr=(e=``,t=``)=>{let n=`
82
+ `}}}).prompt()},ur=e=>e.replace(Fn(),``),dr=(e=``,t=``)=>{let n=`
83
83
  ${e}
84
84
  `.split(`
85
- `),r=sr(t).length,i=Math.max(n.reduce((e,t)=>(t=sr(t),t.length>e?t.length:e),0),r)+2,a=n.map(e=>`${B.default.gray(H)} ${B.default.dim(e)}${` `.repeat(i-sr(e).length)}${B.default.gray(H)}`).join(`
85
+ `),r=ur(t).length,i=Math.max(n.reduce((e,t)=>(t=ur(t),t.length>e?t.length:e),0),r)+2,a=n.map(e=>`${B.default.gray(H)} ${B.default.dim(e)}${` `.repeat(i-ur(e).length)}${B.default.gray(H)}`).join(`
86
86
  `);process.stdout.write(`${B.default.gray(H)}
87
- ${B.default.green(Rn)} ${B.default.reset(t)} ${B.default.gray(Kn.repeat(Math.max(i-r-1,1))+qn)}
87
+ ${B.default.green(Vn)} ${B.default.reset(t)} ${B.default.gray(Yn.repeat(Math.max(i-r-1,1))+Xn)}
88
88
  ${a}
89
- ${B.default.gray(Jn+Kn.repeat(i+2)+Yn)}
90
- `)},lr=(e=``)=>{process.stdout.write(`${B.default.gray(U)} ${B.default.red(e)}
89
+ ${B.default.gray(Zn+Yn.repeat(i+2)+Qn)}
90
+ `)},fr=(e=``)=>{process.stdout.write(`${B.default.gray(U)} ${B.default.red(e)}
91
91
 
92
- `)},ur=(e=``)=>{process.stdout.write(`${B.default.gray(zn)} ${e}
93
- `)},dr=(e=``)=>{process.stdout.write(`${B.default.gray(H)}
92
+ `)},pr=(e=``)=>{process.stdout.write(`${B.default.gray(Hn)} ${e}
93
+ `)},mr=(e=``)=>{process.stdout.write(`${B.default.gray(H)}
94
94
  ${B.default.gray(U)} ${e}
95
95
 
96
96
  `)},G={message:(e=``,{symbol:t=B.default.gray(H)}={})=>{let n=[`${B.default.gray(H)}`];if(e){let[r,...i]=e.split(`
97
97
  `);n.push(`${t} ${r}`,...i.map(e=>`${B.default.gray(H)} ${e}`))}process.stdout.write(`${n.join(`
98
98
  `)}
99
- `)},info:e=>{G.message(e,{symbol:B.default.blue(Xn)})},success:e=>{G.message(e,{symbol:B.default.green(Zn)})},step:e=>{G.message(e,{symbol:B.default.green(Rn)})},warn:e=>{G.message(e,{symbol:B.default.yellow(Qn)})},warning:e=>{G.warn(e)},error:e=>{G.message(e,{symbol:B.default.red($n)})}},fr=()=>{let e=Pn?[`โ—’`,`โ—`,`โ—“`,`โ—‘`]:[`โ€ข`,`o`,`O`,`0`],t=Pn?80:120,n,r,i=!1,a=``,o=(o=``)=>{i=!0,n=wt(),a=o.replace(/\.+$/,``),process.stdout.write(`${B.default.gray(H)}
100
- `);let s=0,c=0;r=setInterval(()=>{let t=B.default.magenta(e[s]),n=`.`.repeat(Math.floor(c)).slice(0,3);process.stdout.write(Nn.cursor.move(-999,0)),process.stdout.write(Nn.erase.down(1)),process.stdout.write(`${t} ${a}${n}`),s=s+1<e.length?s+1:0,c=c<e.length?c+.125:0},t)},s=(e=``,t=0)=>{a=e??a,i=!1,clearInterval(r);let o=t===0?B.default.green(Rn):t===1?B.default.red(In):B.default.red(Ln);process.stdout.write(Nn.cursor.move(-999,0)),process.stdout.write(Nn.erase.down(1)),process.stdout.write(`${o} ${a}
101
- `),n()},c=(e=``)=>{a=e??a},l=e=>{i&&s(e>1?`Something went wrong`:`Canceled`,e)};return process.on(`uncaughtExceptionMonitor`,()=>l(2)),process.on(`unhandledRejection`,()=>l(2)),process.on(`SIGINT`,()=>l(1)),process.on(`SIGTERM`,()=>l(1)),process.on(`exit`,l),{start:o,stop:s,message:c}},pr=async(e,t)=>{let n={},r=Object.keys(e);for(let i of r){let r=e[i],a=await r({results:n})?.catch(e=>{throw e});if(typeof t?.onCancel==`function`&&St(a)){n[i]=`canceled`,t.onCancel({results:n});continue}n[i]=a}return n}}));async function K(e){if(!v())return;let{defaultValue:t,message:n}=e,r=await(await Promise.resolve().then(()=>(mr(),An))).text({message:n,default:t,placeholder:t});if(typeof r!=`symbol`)return r}async function hr(e){if(!v())return;let{message:t,initialValue:n}=e,r=await(await Promise.resolve().then(()=>(mr(),An))).confirm({message:t,initialValue:n});if(typeof r!=`symbol`)return r}async function gr(e){if(!v())return;let{message:t,choices:n,defaultValue:r}=e,i=await(await Promise.resolve().then(()=>(mr(),An))).select({message:t,initialValue:r,options:n});if(typeof i!=`symbol`)return i}function q(t,r){throw st().length>0&&(lt(process.stderr),process.exit(0)),new e(`Missing required argument: --${t}\nHint: In non-interactive (CI / agent) environments all required flags must be provided.\n In an interactive terminal, run without --${t} and the CLI will prompt for it.`,n.USAGE,r)}var J=j((()=>{ft()}));function _r(){return process.env.BAILIAN_CONSOLE_ORIGIN||Mr}function vr(e){return new Promise((t,n)=>{let r=0,i=[];e.on(`data`,e=>{if(r+=e.length,r>jr){n(Error(`payload too large`));return}i.push(e)}),e.on(`end`,()=>t(Buffer.concat(i).toString(`utf8`))),e.on(`error`,n)})}function yr(e){let t=e.headers[`content-type`];return Array.isArray(t)?t[0]??``:typeof t==`string`?t:``}function br(e){let t=e.split(`;`);for(let e of t){let t=e.trim();if(!t.toLowerCase().startsWith(`boundary=`))continue;let n=t.slice(9).trim();return(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`))&&(n=n.slice(1,-1)),n.length>0?n:null}return null}function xr(e,t){let n=`--${t}`,r=e.split(n);for(let e=1;e<r.length;e++){let t=r[e];if(!/name\s*=\s*["'](?:access_token|accessToken)["']/i.test(t))continue;let n=t.match(/\r\n\r\n|\n\n/);if(!n||n.index===void 0)continue;let i=t.slice(n.index+n[0].length);if(i=i.replace(/(?:\r\n)+$/g,``).replace(/\n+$/g,``).trim(),i)return i}return null}function Sr(e){for(let t of[`access_token`,`accessToken`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return null}function Cr(e){let t=e.trim();if(t.charCodeAt(0)===65279&&(t=t.slice(1)),!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n,i=Sr(r);if(i)return i;let a=r.data;if(a&&typeof a==`object`&&!Array.isArray(a)){let e=Sr(a);if(e)return e}return null}function wr(e,t){let n=t.toLowerCase();if(!e.trim())return null;if(n.includes(`multipart/form-data`)){let n=br(t);if(n){let t=xr(e,n);if(t)return t}}if(n.includes(`application/json`)||n.includes(`text/json`)){let t=Cr(e);if(t)return t}if(n.includes(`application/x-www-form-urlencoded`))try{let t=new URLSearchParams(e.trim()),n=t.get(`access_token`)??t.get(`accessToken`);if(n?.trim())return n.trim()}catch{}let r=Cr(e);if(r)return r;try{let t=new URLSearchParams(e.trim()),n=t.get(`access_token`)??t.get(`accessToken`);if(n?.trim())return n.trim()}catch{}let i=br(t);if(i){let t=xr(e,i);if(t)return t}return null}async function Tr(e){let t=new URL(e.url??`/`,`http://127.0.0.1`),n=t.searchParams.get(`access_token`)??t.searchParams.get(`accessToken`);if(n?.trim())return n.trim();let r=e.method??`GET`;if(r!==`POST`&&r!==`PUT`&&r!==`PATCH`)return null;let i=yr(e);try{return wr(await vr(e),i)}catch{return null}}function Er(e){return new Promise((t,n)=>{let r=e=>n(e);e.once(`error`,r),e.listen({port:0,host:`127.0.0.1`,exclusive:!0},()=>{e.off(`error`,r);let i=e.address();if(!i||typeof i==`string`){n(Error(`Expected TCP socket address`));return}t(i.port)})})}function Dr(e){let t=process.platform,n=t===`darwin`?`open`:t===`win32`?`cmd`:`xdg-open`,r=t===`win32`?[`/c`,`start`,``,e]:[e];return new Promise((e,t)=>{ge(n,r,{windowsHide:!0},n=>{n?t(n):e()})})}async function Or(e,t){process.stderr.write(`Testing key... `);let n={...e,apiKey:t};await T(n,{url:s(n.baseUrl),method:`POST`,body:{model:`qwen3.6-plus`,messages:[{role:`user`,content:`hi`}],max_tokens:1}}),process.stderr.write(`Valid
102
- `);let r=w();r.api_key=t,delete r.access_token,await he(r),process.stderr.write(`Saved to ${h()}\n`)}async function kr(t){let r=_e(16).toString(`hex`),i=ve.createServer(async(e,t)=>{try{if(e.method===`OPTIONS`){t.writeHead(204,{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`GET, POST, PUT, PATCH, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),t.end();return}if(new URL(e.url??`/`,`http://127.0.0.1`).searchParams.get(`state`)!==r){t.writeHead(400,{"Content-Type":`text/plain; charset=utf-8`}),t.end(`bad state
103
- `);return}let n=await Tr(e);if(n)try{let e=w();e.access_token=n,delete e.api_key,await he(e),process.stderr.write(`access_token saved to ${h()} (removed stored api_key so CLI uses the console token)\n`)}catch{t.writeHead(500,{"Content-Type":`text/plain; charset=utf-8`}),t.end(`Failed to save access_token
99
+ `)},info:e=>{G.message(e,{symbol:B.default.blue($n)})},success:e=>{G.message(e,{symbol:B.default.green(er)})},step:e=>{G.message(e,{symbol:B.default.green(Vn)})},warn:e=>{G.message(e,{symbol:B.default.yellow(tr)})},warning:e=>{G.warn(e)},error:e=>{G.message(e,{symbol:B.default.red(nr)})}},hr=()=>{let e=Ln?[`โ—’`,`โ—`,`โ—“`,`โ—‘`]:[`โ€ข`,`o`,`O`,`0`],t=Ln?80:120,n,r,i=!1,a=``,o=(o=``)=>{i=!0,n=Dt(),a=o.replace(/\.+$/,``),process.stdout.write(`${B.default.gray(H)}
100
+ `);let s=0,c=0;r=setInterval(()=>{let t=B.default.magenta(e[s]),n=`.`.repeat(Math.floor(c)).slice(0,3);process.stdout.write(In.cursor.move(-999,0)),process.stdout.write(In.erase.down(1)),process.stdout.write(`${t} ${a}${n}`),s=s+1<e.length?s+1:0,c=c<e.length?c+.125:0},t)},s=(e=``,t=0)=>{a=e??a,i=!1,clearInterval(r);let o=t===0?B.default.green(Vn):t===1?B.default.red(zn):B.default.red(Bn);process.stdout.write(In.cursor.move(-999,0)),process.stdout.write(In.erase.down(1)),process.stdout.write(`${o} ${a}
101
+ `),n()},c=(e=``)=>{a=e??a},l=e=>{i&&s(e>1?`Something went wrong`:`Canceled`,e)};return process.on(`uncaughtExceptionMonitor`,()=>l(2)),process.on(`unhandledRejection`,()=>l(2)),process.on(`SIGINT`,()=>l(1)),process.on(`SIGTERM`,()=>l(1)),process.on(`exit`,l),{start:o,stop:s,message:c}},gr=async(e,t)=>{let n={},r=Object.keys(e);for(let i of r){let r=e[i],a=await r({results:n})?.catch(e=>{throw e});if(typeof t?.onCancel==`function`&&Tt(a)){n[i]=`canceled`,t.onCancel({results:n});continue}n[i]=a}return n}}));async function K(e){if(!b())return;let{defaultValue:t,message:n}=e,r=await(await Promise.resolve().then(()=>(_r(),Nn))).text({message:n,default:t,placeholder:t});if(typeof r!=`symbol`)return r}async function vr(e){if(!b())return;let{message:t,initialValue:n}=e,r=await(await Promise.resolve().then(()=>(_r(),Nn))).confirm({message:t,initialValue:n});if(typeof r!=`symbol`)return r}async function yr(e){if(!b())return;let{message:t,choices:n,defaultValue:r}=e,i=await(await Promise.resolve().then(()=>(_r(),Nn))).select({message:t,initialValue:r,options:n});if(typeof i!=`symbol`)return i}function q(t,n){throw ut().length>0&&(ft(process.stderr),process.exit(0)),new e(`Missing required argument: --${t}\nHint: In non-interactive (CI / agent) environments all required flags must be provided.\n In an interactive terminal, run without --${t} and the CLI will prompt for it.`,r.USAGE,n)}var J=j((()=>{ht()}));function br(){return process.env.BAILIAN_CONSOLE_ORIGIN||Fr}function xr(e){return new Promise((t,n)=>{let r=0,i=[];e.on(`data`,e=>{if(r+=e.length,r>Pr){n(Error(`payload too large`));return}i.push(e)}),e.on(`end`,()=>t(Buffer.concat(i).toString(`utf8`))),e.on(`error`,n)})}function Sr(e){let t=e.headers[`content-type`];return Array.isArray(t)?t[0]??``:typeof t==`string`?t:``}function Cr(e){let t=e.split(`;`);for(let e of t){let t=e.trim();if(!t.toLowerCase().startsWith(`boundary=`))continue;let n=t.slice(9).trim();return(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`))&&(n=n.slice(1,-1)),n.length>0?n:null}return null}function wr(e,t){let n=`--${t}`,r=e.split(n);for(let e=1;e<r.length;e++){let t=r[e];if(!/name\s*=\s*["'](?:access_token|accessToken)["']/i.test(t))continue;let n=t.match(/\r\n\r\n|\n\n/);if(!n||n.index===void 0)continue;let i=t.slice(n.index+n[0].length);if(i=i.replace(/(?:\r\n)+$/g,``).replace(/\n+$/g,``).trim(),i)return i}return null}function Tr(e){for(let t of[`access_token`,`accessToken`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return null}function Er(e){let t=e.trim();if(t.charCodeAt(0)===65279&&(t=t.slice(1)),!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n,i=Tr(r);if(i)return i;let a=r.data;if(a&&typeof a==`object`&&!Array.isArray(a)){let e=Tr(a);if(e)return e}return null}function Dr(e,t){let n=t.toLowerCase();if(!e.trim())return null;if(n.includes(`multipart/form-data`)){let n=Cr(t);if(n){let t=wr(e,n);if(t)return t}}if(n.includes(`application/json`)||n.includes(`text/json`)){let t=Er(e);if(t)return t}if(n.includes(`application/x-www-form-urlencoded`))try{let t=new URLSearchParams(e.trim()),n=t.get(`access_token`)??t.get(`accessToken`);if(n?.trim())return n.trim()}catch{}let r=Er(e);if(r)return r;try{let t=new URLSearchParams(e.trim()),n=t.get(`access_token`)??t.get(`accessToken`);if(n?.trim())return n.trim()}catch{}let i=Cr(t);if(i){let t=wr(e,i);if(t)return t}return null}async function Or(e){let t=new URL(e.url??`/`,`http://127.0.0.1`),n=t.searchParams.get(`access_token`)??t.searchParams.get(`accessToken`);if(n?.trim())return n.trim();let r=e.method??`GET`;if(r!==`POST`&&r!==`PUT`&&r!==`PATCH`)return null;let i=Sr(e);try{return Dr(await xr(e),i)}catch{return null}}function kr(e){return new Promise((t,n)=>{let r=e=>n(e);e.once(`error`,r),e.listen({port:0,host:`127.0.0.1`,exclusive:!0},()=>{e.off(`error`,r);let i=e.address();if(!i||typeof i==`string`){n(Error(`Expected TCP socket address`));return}t(i.port)})})}function Ar(e){let t=process.platform,n=t===`darwin`?`open`:t===`win32`?`cmd`:`xdg-open`,r=t===`win32`?[`/c`,`start`,``,e]:[e];return new Promise((e,t)=>{ye(n,r,{windowsHide:!0},n=>{n?t(n):e()})})}async function jr(e,t){process.stderr.write(`Testing key... `);let n={...e,apiKey:t};await T(n,{url:c(n.baseUrl),method:`POST`,body:{model:`qwen3.6-plus`,messages:[{role:`user`,content:`hi`}],max_tokens:1}}),process.stderr.write(`Valid
102
+ `);let r=w();r.api_key=t,await ve(r),process.stderr.write(`Saved to ${_()}\n`)}async function Mr(t){let n=be(16).toString(`hex`),i=xe.createServer(async(e,t)=>{try{if(e.method===`OPTIONS`){t.writeHead(204,{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`GET, POST, PUT, PATCH, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),t.end();return}if(new URL(e.url??`/`,`http://127.0.0.1`).searchParams.get(`state`)!==n){t.writeHead(400,{"Content-Type":`text/plain; charset=utf-8`}),t.end(`bad state
103
+ `);return}let r=await Or(e);if(r)try{let e=w();e.access_token=r,await ve(e),process.stderr.write(`access_token saved to ${_()}\n`)}catch{t.writeHead(500,{"Content-Type":`text/plain; charset=utf-8`}),t.end(`Failed to save access_token
104
104
  `);return}t.writeHead(200,{"Content-Type":`text/plain; charset=utf-8`,"Access-Control-Allow-Origin":`*`}),t.end(`OK
105
- `),n&&i.close()}catch{t.statusCode=500,t.end()}}),a;try{a=await Er(i)}catch(t){throw new e(`Could not bind to 127.0.0.1 (no free port or permission denied): ${t instanceof Error?t.message:String(t)}`,n.USAGE)}let o=`${t}/console-login?notice=127.0.0.1:${a}?state=${encodeURIComponent(r)}`;try{await Dr(o),process.stderr.write(`Opened the login page in your default browser. This process keeps the local port open for the console; press Ctrl+C when finished (or wait for idle timeout).
105
+ `),r&&i.close()}catch{t.statusCode=500,t.end()}}),a;try{a=await kr(i)}catch(t){throw new e(`Could not bind to 127.0.0.1 (no free port or permission denied): ${t instanceof Error?t.message:String(t)}`,r.USAGE)}let o=`${t}/console-login?notice=127.0.0.1:${a}?state=${encodeURIComponent(n)}`;try{await Ar(o),process.stderr.write(`Opened the login page in your default browser. This process keeps the local port open for the console; press Ctrl+C when finished (or wait for idle timeout).
106
106
  `)}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`Could not open the default browser (${t}). Open this URL manually:\n\n`),process.stdout.write(`${o}\n`),process.stderr.write(`
107
107
  This process keeps the local port open for the console; press Ctrl+C when finished (or wait for idle timeout).
108
- `)}await new Promise((e,t)=>{let n=!1,r=()=>{n||(n=!0,clearTimeout(a),e())},a=setTimeout(()=>{i.close()},Ar);i.once(`close`,r),i.once(`error`,e=>{clearTimeout(a),n||(n=!0,t(e))})})}var Ar,jr,Mr,Nr,Pr=j((()=>{at(),P(),J(),ft(),Ar=900*1e3,jr=65536,Mr=`https://bailian.console.aliyun.com`,Nr=l({name:`auth login`,description:`Authenticate with API key`,usage:`bl auth login --api-key <key> | bl auth login --console`,options:[{flag:`--api-key <key>`,description:`DashScope API key to store`},{flag:`--console`,description:`Sign in via browser; opens the console login URL in your default browser`,type:`boolean`}],examples:[`bl auth login --api-key sk-xxxxx`,`bl auth login --console`],async run(e,t){if(t.console){if(e.dryRun){N(`Would bind a free port on 127.0.0.1 and open the console login URL in your browser.`);return}await kr(_r());return}let n=process.env.DASHSCOPE_API_KEY;if(n&&!t.apiKey){let t=x(n);v({nonInteractive:e.nonInteractive})?await hr({message:`Detected DASHSCOPE_API_KEY in environment (${t}).\nYou are already authenticated via env.\nDo you still want to configure local persistent credentials?`,initialValue:!1})||(process.stdout.write(`Login skipped. Using environment variables.
108
+ `)}await new Promise((e,t)=>{let n=!1,r=()=>{n||(n=!0,clearTimeout(a),e())},a=setTimeout(()=>{i.close()},Nr);i.once(`close`,r),i.once(`error`,e=>{clearTimeout(a),n||(n=!0,t(e))})})}var Nr,Pr,Fr,Ir,Lr=j((()=>{ct(),P(),J(),ht(),Nr=900*1e3,Pr=65536,Fr=`https://bailian.console.aliyun.com`,Ir=u({name:`auth login`,description:`Authenticate with API key or console browser login (credentials can coexist)`,usage:`bl auth login --api-key <key> | bl auth login --console`,options:[{flag:`--api-key <key>`,description:`DashScope API key to store`},{flag:`--console`,description:`Sign in via browser; opens the console login URL in your default browser`,type:`boolean`}],examples:[`bl auth login --api-key sk-xxxxx`,`bl auth login --console`],async run(e,t){if(t.console){if(e.dryRun){N(`Would bind a free port on 127.0.0.1 and open the console login URL in your browser.`);return}await Mr(br());return}let n=process.env.DASHSCOPE_API_KEY;if(n&&!t.apiKey){let t=C(n);b({nonInteractive:e.nonInteractive})?await vr({message:`Detected DASHSCOPE_API_KEY in environment (${t}).\nYou are already authenticated via env.\nDo you still want to configure local persistent credentials?`,initialValue:!1})||(process.stdout.write(`Login skipped. Using environment variables.
109
109
  `),process.exit(0)):process.stderr.write(`Warning: DASHSCOPE_API_KEY is already set in environment.
110
- `)}let r=t.apiKey||e.apiKey;r||(lt(process.stderr),process.exit(0)),e.dryRun?N(`Would validate and save API key.`):(await Or(e,r),rt())}})})),Fr,Ir=j((()=>{P(),et(),Fr=l({name:`auth status`,description:`Show current authentication state`,usage:`bl auth status`,examples:[`bl auth status`,`bl auth status --output json`],async run(e,t){try{let t=await E(e),n=u(e.output);if(n!==`text`){M({method:t.method,source:t.source,key:x(t.token)},n);return}N(`Authentication Status:`),N(` Method: ${t.method}`),N(` Source: ${t.source}`),N(` Key: ${x(t.token)}`)}catch{let t=u(e.output);M({authenticated:!1,message:`Not authenticated.`,hint:`Run: bl auth login --api-key <your-key>\nOr set DASHSCOPE_API_KEY\nGet API Key: ${$e}`},t)}}})}));async function Lr(){let e=w();return e.access_token?(delete e.access_token,await he(e),!0):!1}var Rr,zr=j((()=>{P(),Rr=l({name:`auth logout`,description:`Clear stored credentials`,usage:`bl auth logout [--console] [--yes] [--dry-run]`,options:[{flag:`--console`,description:`Only clear the console access_token, keep api_key intact`,type:`boolean`},{flag:`--yes`,description:`Skip confirmation prompt`}],examples:[`bl auth logout`,`bl auth logout --console`,`bl auth logout --dry-run`,`bl auth logout --yes`],async run(e,t){let n=w();if(t.console){let t=!!n.access_token;if(e.dryRun){N(t?`Would clear access_token from ~/.bailian/config.json`:`No console access_token to clear.`),N(`No changes made.`);return}t?(await Lr(),process.stderr.write(`Cleared access_token from ${h()}\n`),n.api_key&&process.stderr.write(`api_key is still configured and will be used for authentication.
110
+ `)}let r=t.apiKey||e.apiKey;r||(ft(process.stderr),process.exit(0)),e.dryRun?N(`Would validate and save API key.`):(await jr(e,r),ot())}})}));function Rr(e){if(e.apiKey)return{configured:!0,source:`flag`,masked:C(e.apiKey)};if(e.fileApiKey)return{configured:!0,source:`config.json`,masked:C(e.fileApiKey)};let t=process.env.DASHSCOPE_API_KEY?.trim();return t?{configured:!0,source:`DASHSCOPE_API_KEY`,masked:C(t)}:{configured:!1}}function zr(e){return e.accessTokenEnv?{configured:!0,source:`DASHSCOPE_ACCESS_TOKEN`,masked:C(e.accessTokenEnv)}:e.fileAccessToken?{configured:!0,source:`config.json`,masked:C(e.fileAccessToken)}:{configured:!1}}async function Br(e){try{return await E(e)}catch{return}}async function Vr(e){try{return await ce(e)}catch{return}}async function Hr(e){let t={api_key:Rr(e),access_token:zr(e)},n=await Br(e);n&&(t.dashscope_commands={method:n.method,source:n.source,masked:C(n.token)});let r=await Vr(e);return r&&(t.console_gateway_commands={method:r.method,source:r.source,masked:C(r.token)}),t}function Ur(e){return e.api_key.configured||e.access_token.configured||!!e.dashscope_commands||!!e.console_gateway_commands}function Wr(e){N(`Authentication Status:`),N(` Stored credentials (can coexist):`),e.api_key.configured?N(` API key: ${e.api_key.source} ${e.api_key.masked}`):N(` API key: not configured`),e.access_token.configured?N(` Console token: ${e.access_token.source} ${e.access_token.masked}`):N(` Console token: not configured`),N(` Effective credential per command family:`),e.dashscope_commands?N(` DashScope API: ${e.dashscope_commands.method} (${e.dashscope_commands.source}) ${e.dashscope_commands.masked}`):N(` DashScope API: unavailable`),e.console_gateway_commands?N(` Console gateway: ${e.console_gateway_commands.method} (${e.console_gateway_commands.source}) ${e.console_gateway_commands.masked}`):N(` Console gateway: unavailable (run bl auth login --console)`)}var Gr,Kr=j((()=>{P(),rt(),Gr=u({name:`auth status`,description:`Show current authentication state`,usage:`bl auth status`,examples:[`bl auth status`,`bl auth status --output json`],async run(e,t){let n=d(e.output),r=await Hr(e);if(!Ur(r)){M({authenticated:!1,message:`Not authenticated.`,hint:[`DashScope API: bl auth login --api-key <key> or DASHSCOPE_API_KEY`,`Console gateway: bl auth login --console or DASHSCOPE_ACCESS_TOKEN`,`Get API Key: ${nt}`].join(`
111
+ `),...r},n);return}if(n!==`text`){M({authenticated:!0,...r},n);return}Wr(r)}})}));async function qr(){let e=w();return e.access_token?(delete e.access_token,await ve(e),!0):!1}var Jr,Yr=j((()=>{P(),Jr=u({name:`auth logout`,description:`Clear stored credentials`,usage:`bl auth logout [--console] [--yes] [--dry-run]`,options:[{flag:`--console`,description:`Only clear the console access_token, keep api_key intact`,type:`boolean`},{flag:`--yes`,description:`Skip confirmation prompt`}],examples:[`bl auth logout`,`bl auth logout --console`,`bl auth logout --dry-run`,`bl auth logout --yes`],async run(e,t){let n=w();if(t.console){let t=!!n.access_token;if(e.dryRun){N(t?`Would clear access_token from ~/.bailian/config.json`:`No console access_token to clear.`),N(`No changes made.`);return}t?(await qr(),process.stderr.write(`Cleared access_token from ${_()}\n`),n.api_key&&process.stderr.write(`api_key is still configured and will be used for authentication.
111
112
  `)):process.stderr.write(`No console access_token to clear.
112
- `);return}let r=!!(n.api_key||n.access_token);if(e.dryRun){N(r?`Would clear api_key / access_token from ~/.bailian/config.json`:`No credentials to clear.`),N(`No changes made.`);return}r?(await c(),process.stderr.write(`Cleared api_key / access_token from ~/.bailian/config.json
113
+ `);return}let r=!!(n.api_key||n.access_token);if(e.dryRun){N(r?`Would clear api_key / access_token from ~/.bailian/config.json`:`No credentials to clear.`),N(`No changes made.`);return}r?(await l(),process.stderr.write(`Cleared api_key / access_token from ~/.bailian/config.json
113
114
  `)):process.stderr.write(`No credentials to clear.
114
- `)}})}));function Br(e){let t=[],n;if(e.system&&(n=e.system),e.messagesFile){let r=e.messagesFile,i=De(r===`-`?`/dev/stdin`:r,`utf-8`),a=JSON.parse(i);for(let e of a)e.role===`system`?n=typeof e.content==`string`?e.content:``:t.push(e)}if(e.message){let r=new Set([`system`,`user`,`assistant`]),i=e.message;for(let e of i){let i=e.indexOf(`:`),a=i===-1?``:e.slice(0,i);if(r.has(a)){let r=e.slice(i+1);a===`system`?n=r:t.push({role:a,content:r})}else t.push({role:`user`,content:e})}}return{system:n,messages:t}}var Vr,Hr=j((()=>{J(),P(),Vr=l({name:`text chat`,description:`Send a chat completion (OpenAI compatible, DashScope)`,apiDocs:`/compatibility-of-openai-with-dashscope`,usage:`bl text chat --message <text> [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: qwen3.6-plus)`},{flag:`--message <text>`,description:`Message text (repeatable, prefix role: to set role)`,required:!0,type:`array`},{flag:`--messages-file <path>`,description:`JSON file with messages array (use - for stdin)`},{flag:`--system <text>`,description:`System prompt`},{flag:`--max-tokens <n>`,description:`Maximum tokens to generate (default: 4096)`,type:`number`},{flag:`--temperature <n>`,description:`Sampling temperature (0.0, 2.0]`,type:`number`},{flag:`--top-p <n>`,description:`Nucleus sampling threshold`,type:`number`},{flag:`--stream`,description:`Stream response tokens (default: on in TTY)`},{flag:`--tool <json-or-path>`,description:`Tool definition as JSON or file path (repeatable)`,type:`array`},{flag:`--enable-thinking`,description:`Enable thinking/reasoning mode (for qwen3/qwq models)`},{flag:`--thinking-budget <n>`,description:`Max tokens for thinking (default: 4096)`,type:`number`}],examples:[`bl text chat --message "What is Qwen?"`,`bl text chat --model qwen-max --system "You are a coding assistant." --message "Write fizzbuzz in Python"`,`bl text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"`,`cat conversation.json | bl text chat --messages-file - --stream`,`bl text chat --message "Hello" --output json`,`bl text chat --model qwq-plus --message "Solve 1+1" --enable-thinking`],async run(e,t){let{system:n,messages:r}=Br(t),i=r;if(i.length===0)if(v({nonInteractive:e.nonInteractive})){let e=await K({message:`Enter your message:`});e||(process.stderr.write(`Chat cancelled.
115
- `),process.exit(1)),i=[{role:`user`,content:e}]}else q(`message`,`bl text chat --message <text>`);let a=t.model||e.defaultTextModel||`qwen3.6-plus`,o=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,c=u(e.output),l=[];n&&l.push({role:`system`,content:n}),l.push(...i);let d={model:a,messages:l,max_tokens:t.maxTokens??4096,stream:o};if(t.temperature!==void 0&&(d.temperature=t.temperature),t.topP!==void 0&&(d.top_p=t.topP),t.enableThinking&&(d.enable_thinking=!0,t.thinkingBudget!==void 0&&(d.thinking_budget=t.thinkingBudget)),t.tool&&(d.tools=t.tool.map(e=>{try{return JSON.parse(e)}catch{let t=De(e,`utf-8`);return JSON.parse(t)}})),e.dryRun){M({request:d},c);return}let f=s(e.baseUrl);if(o){let t=await ae(e,{url:f,method:`POST`,body:d,stream:!0}),n=``,r=!1,i=c===`text`,a=e.noColor?``:`\x1B[2m`,o=e.noColor?``:`\x1B[0m`,s=process.stdout.isTTY,l=c===`json`?process.stderr:s?process.stdout:process.stderr,u=process.stdout;for await(let e of re(t)){if(e.data===`[DONE]`)break;try{let t=JSON.parse(e.data);for(let e of t.choices){let t=e.delta;t.reasoning_content&&(i&&!r&&(r=!0,l.write(`${a}Thinking:\n`)),i&&l.write(t.reasoning_content)),t.content&&(i&&r&&(l.write(`${o}\n\nResponse:\n`),r=!1),n+=t.content,i&&u.write(t.content))}}catch{}}r&&l.write(o),c===`json`?M({content:n},c):u.write(`
116
- `)}else{let t=await T(e,{url:f,method:`POST`,body:d}),n=t.choices?.[0]?.message?.content??``;e.quiet||c===`text`?N(n):M(t,c)}}})}));function Ur(e){let t=Buffer.alloc(44);return t.write(`RIFF`,0),t.writeUInt32LE(36+e,4),t.write(`WAVE`,8),t.write(`fmt `,12),t.writeUInt32LE(16,16),t.writeUInt16LE(1,20),t.writeUInt16LE(1,22),t.writeUInt32LE(24e3,24),t.writeUInt32LE(48e3,28),t.writeUInt16LE(2,32),t.writeUInt16LE(16,34),t.write(`data`,36),t.writeUInt32LE(e,40),t}var Wr,Gr,Kr=j((()=>{J(),P(),Wr=[`Chelsie`,`Cherry`,`Ethan`,`Serena`,`Tina`],Gr=l({name:`omni`,description:`Multimodal chat with text + audio output (Qwen-Omni)`,apiDocs:`/model-studio/qwen-omni`,usage:`bl omni --message <text> [flags]`,options:[{flag:`--message <text>`,description:`Message text (repeatable, prefix role: to set role)`,required:!0,type:`array`},{flag:`--model <model>`,description:`Model ID (default: qwen3.5-omni-plus)`},{flag:`--system <text>`,description:`System prompt`},{flag:`--image <url>`,description:`Image URL or local file (repeatable)`,type:`array`},{flag:`--audio <url>`,description:`Audio URL or local file (repeatable)`,type:`array`},{flag:`--video <url>`,description:`Video file URL / local path, or comma-separated frame URLs`,type:`array`},{flag:`--voice <voice>`,description:`Output voice (default: Cherry). Options: ${Wr.join(`, `)}`},{flag:`--audio-format <fmt>`,description:`Audio output format (default: wav)`},{flag:`--audio-out <path>`,description:`Save audio to file (default: auto-generate)`},{flag:`--text-only`,description:`Output text only, no audio generation`},{flag:`--max-tokens <n>`,description:`Maximum tokens to generate`,type:`number`},{flag:`--temperature <n>`,description:`Sampling temperature (0.0, 2.0]`,type:`number`}],examples:[`bl omni --message "ไฝ ๅฅฝ๏ผŒไฝ ๆ˜ฏ่ฐ๏ผŸ"`,`bl omni --message "ๆ่ฟฐ่ฟ™ๅผ ๅ›พ็‰‡" --image ./photo.jpg`,`bl omni --message "่ฟ™ๆฎต้Ÿณ้ข‘ๅœจ่ฏดไป€ไนˆ๏ผŸ" --audio https://example.com/audio.wav`,`bl omni --message "ๆ€ป็ป“่ฟ™ไธช่ง†้ข‘" --video https://example.com/video.mp4`,`bl omni --message "่ฟ™ไธช่ง†้ข‘่ฎฒไบ†ไป€ไนˆ" --video ./local-video.mp4 --text-only`,`bl omni --message "็”จๅ››ๅท่ฏๅ›ž็ญ”๏ผšไปŠๅคฉๅคฉๆฐ”ๆ€Žไนˆๆ ท" --voice Serena`,`bl omni --message "Hello" --text-only --output json`,`bl omni --message "ๆœ—่ฏป่ฟ™ๆฎต่ฏ" --audio-out greeting.wav`],async run(e,t){let n=[];if(t.message&&(n=t.message),n.length===0)if(v({nonInteractive:e.nonInteractive})){let e=await K({message:`Enter your message:`});e||(process.stderr.write(`Omni chat cancelled.
117
- `),process.exit(1)),n=[e]}else q(`message`,`bl text omni --message <text>`);let r=t.model||e.defaultOmniModel||`qwen3.5-omni-plus`,i=t.voice||`Cherry`,a=t.audioFormat||`wav`,o=t.textOnly===!0,c=u(e.output),l=[];t.system&&l.push({role:`system`,content:t.system});let d=new Set([`system`,`user`,`assistant`]);for(let e of n){let t=e.indexOf(`:`),n=t===-1?``:e.slice(0,t);if(d.has(n)){let r=e.slice(t+1);n===`system`?l.push({role:`system`,content:r}):l.push({role:n,content:r})}else l.push({role:`user`,content:e})}let f=t.image||[],p=t.audio||[],m=t.video||[],h=[],g=[],_=[];if(f.length>0||p.length>0||m.length>0){let t=await E(e);for(let e of f){let n=await D(e,t.token,r);h.push(n)}for(let e of p){let n=await D(e,t.token,r);g.push(n)}for(let e of m)if(e.includes(`,`)){let n=e.split(`,`).map(e=>e.trim()).filter(Boolean);for(let e of n){let n=await D(e,t.token,r);_.push(`frame:${n}`)}}else{let n=await D(e,t.token,r);_.push(n)}}if(h.length>0||g.length>0||_.length>0){for(let e=l.length-1;e>=0;e--)if(l[e].role===`user`){let t=l[e].content,n=[];typeof t==`string`?n.push({type:`text`,text:t}):Array.isArray(t)&&n.push(...t);for(let e of h)n.push({type:`image_url`,image_url:{url:e}});for(let e of g)n.push({type:`audio_url`,audio_url:{url:e}});let r=_.filter(e=>e.startsWith(`frame:`)).map(e=>e.slice(6)),i=_.filter(e=>!e.startsWith(`frame:`));r.length>0&&n.push({type:`video`,video:r});for(let e of i)n.push({type:`video_url`,video_url:{url:e}});l[e]={role:`user`,content:n};break}}let y={model:r,messages:l,stream:!0,stream_options:{include_usage:!0}};if(o||(y.modalities=[`text`,`audio`],y.audio={voice:i,format:a}),t.maxTokens!==void 0&&(y.max_tokens=t.maxTokens),t.temperature!==void 0&&(y.temperature=t.temperature),e.dryRun){M({request:y},c);return}if(!e.quiet){let e=o?`text-only`:`text+audio, voice: ${i}`;process.stderr.write(`[Model: ${r}] [${e}]\n`)}let b=await ae(e,{url:s(e.baseUrl),method:`POST`,body:y,stream:!0}),x=``,S=``,ee=process.stdout.isTTY,te=process.stdout;for await(let e of re(b)){if(e.data===`[DONE]`)break;try{let t=JSON.parse(e.data);for(let e of t.choices){let t=e.delta;t.content&&(x+=t.content,ee&&te.write(t.content)),t.audio?.data&&(S+=t.audio.data)}}catch{}}ee&&x&&te.write(`
118
- `);let C;if(S&&!o){let n=Buffer.from(S,`base64`),r=Ur(n.length),i=Buffer.concat([r,n]),a=t.audioOut;if(!a){let{join:t}=await import(`path`);a=t(O(e,{subDir:`omni`}),`omni_${Date.now()}.wav`)}ke(a,i),C=a,e.quiet||process.stderr.write(`Audio saved: ${a}\n`)}if(!ee||c===`json`){let e={content:x};C&&(e.audio_saved=C,e.voice=i),M(e,c)}}})}));function qr(e){let t=process.stderr.isTTY,n=0,r=null,i=e;return{start(){t&&(r=setInterval(()=>{process.stderr.write(`\r${Yr[n%Yr.length]} ${i}`),n++},80))},update(e){i=e},stop(e){r&&=(clearInterval(r),null),t&&(process.stderr.write(`\r\x1B[K`),e&&process.stderr.write(`${e}\n`))}}}function Jr(e,t=``){let n=process.stderr.isTTY;return{update(r){if(!n)return;let i=Math.min(1,r/e),a=Math.round(30*i),o=30-a,s=`โ–ˆ`.repeat(a)+`โ–‘`.repeat(o),c=`${Math.round(i*100)}%`;process.stderr.write(`\r${t} ${s} ${c}`)},finish(){n&&process.stderr.write(`
119
- `)}}}var Yr,Xr=j((()=>{Yr=[`โ ‹`,`โ ™`,`โ น`,`โ ธ`,`โ ผ`,`โ ด`,`โ ฆ`,`โ ง`,`โ ‡`,`โ `]}));async function Zr(t,r){let i=Date.now()+r.timeoutSec*1e3,a=qr(`Polling...`);t.quiet||a.start();try{for(;Date.now()<i;){let i=await T(t,{url:r.url});if(r.getStatus&&!t.quiet&&a.update(`Status: ${r.getStatus(i)}`),r.isComplete(i))return a.stop(`Done.`),i;if(r.isFailed(i)){a.stop(`Failed.`),t.verbose&&process.stderr.write(`[verbose] Task response: ${JSON.stringify(i,null,2)}\n`);let o=r.getErrorMessage?.(i);throw new e(o?`Task failed: ${o}`:`Task failed.`,n.GENERAL,o?void 0:`Use --verbose to see full API response details.`)}await new Promise(e=>setTimeout(e,r.intervalSec*1e3))}}finally{a.stop()}throw new e(`Polling timed out.`,n.TIMEOUT,`Try increasing --timeout or check task status manually.`)}var Qr=j((()=>{Xr()}));async function Y(t,r,i){let a=await fetch(t,{headers:de()});if(!a.ok)throw new e(`Download failed: HTTP ${a.status}`,n.GENERAL);let o=Number(a.headers.get(`content-length`)||0),s=a.body?.getReader();if(!s)throw new e(`No response body`,n.GENERAL);Ee(Ae(r),{recursive:!0});let c=we(r),l=o>0&&!i?.quiet?Jr(o,`Downloading`):null,u=0,d=!1;try{let e=new Promise((e,t)=>{c.on(`error`,t)});for(;;){let{done:t,value:n}=await Promise.race([s.read(),e]);if(t)break;c.write(n)||await new Promise(e=>c.once(`drain`,()=>e())),u+=n.byteLength,l?.update(u)}d=!0}finally{if(s.releaseLock(),l?.finish(),await new Promise((e,t)=>{c.on(`finish`,e),c.on(`error`,t),c.end()}),!d)try{Oe(r)}catch{}}return{size:u}}function $r(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}var X=j((()=>{Xr()}));function ei(e){let t=e.concurrent;return Math.max(1,t??1)}async function ti(e,t,n,r=`requests`){if(e<=1)return[await n(0)];t.quiet||process.stderr.write(`[Concurrent: ${e} ${r}]\n`);let i=Array.from({length:e},(e,t)=>n(t));return Promise.all(i)}async function ni(e,t,n){return Promise.all(e.map(({url:e,destPath:r})=>t(e,r,n).then(()=>r)))}var ri=j((()=>{}));function ii(e){return li.some(t=>e.startsWith(t))}function ai(e,t){return(t?ui:di)[e]||e}async function oi(t,r,i,a,o,s){let c=_(t.baseUrl),l=(await ti(s,t,()=>T(t,{url:c,method:`POST`,body:i}))).flatMap(e=>e.output.choices||[]).flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);if(l.length===0)throw new e(`Generation completed but no images returned.`,n.GENERAL);await ci(l,a,t,o)}async function si(t,r,i,a,o,s){let c=g(t.baseUrl),l=(await ti(s,t,()=>T(t,{url:c,method:`POST`,body:i,async:!0}),`tasks`)).map(e=>e.output.task_id);if(a.noWait||t.async){M({task_ids:l},o);return}let u=a.pollInterval??3,d=l.map(e=>Zr(t,{url:k(t.baseUrl,e),intervalSec:u,timeoutSec:t.timeout,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}})),f=await Promise.all(d),p=[];for(let e of f){if(e.output.choices){let t=e.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);p.push(...t)}if(e.output.results){let t=e.output.results.map(e=>e.url).filter(Boolean);t.length>0&&p.length===0&&p.push(...t)}}if(p.length===0)throw new e(`All tasks completed but no images returned.`,n.GENERAL);await ci(p,a,t,o,l.length===1?l[0]:void 0,l)}async function ci(e,t,n,r,i,a){let o=O(n,{flagDir:t.outDir,subDir:t.outDir?void 0:`images`}),s=t.prompt||t._positional?.[0]||``,c=t.outPrefix||f(`image`,s),l=await ni(e.length>1?e.map((e,t)=>({url:e,destPath:Me(o,`${c}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:e[0],destPath:Me(o,`${c}.png`)}],Y,{quiet:n.quiet});if(n.quiet)N(l.join(`
120
- `));else{let t={urls:e,saved:l,total:e.length};i&&(t.task_id=i),a&&a.length>1&&(t.task_ids=a),M(t,r)}}var li,ui,di,fi,pi=j((()=>{Qr(),X(),ri(),J(),P(),li=[`qwen-image-2.0`,`qwen-image-max`],ui={"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},di={"16:9":`1664*928`,"4:3":`1472*1104`,"1:1":`1328*1328`,"3:4":`1104*1472`,"9:16":`928*1664`},fi=l({name:`image generate`,description:`Generate images (Qwen-Image / wan2.x)`,apiDocs:`/best-practice/wanx/text-to-image`,usage:`bl image generate --prompt <text> [flags]`,options:[{flag:`--prompt <text>`,description:`Image description`,required:!0},{flag:`--model <model>`,description:`Model ID (default: qwen-image-2.0)`},{flag:`--size <W*H>`,description:`Image size: ratio (3:4, 16:9, 1:1) or pixels (2048*2048)`},{flag:`--n <count>`,description:`Number of images per request (default: 1, max: 6)`,type:`number`},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--prompt-extend`,description:`Automatically extend prompt for better results (default: true for qwen-image)`},{flag:`--no-prompt-extend`,description:`Disable prompt extend`},{flag:`--watermark`,description:`Add watermark to generated images`},{flag:`--no-wait`,description:`Return task ID immediately without waiting (async models only)`},{flag:`--out-dir <dir>`,description:`Download images to directory`},{flag:`--out-prefix <prefix>`,description:`Filename prefix (default: image)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 3)`,type:`number`}],examples:[`bl image generate --prompt "ไธ€ๅช็ฉฟๅคช็ฉบๆœ็š„็Œซๅœจ็ซๆ˜ŸไธŠ"`,`bl image generate --prompt "Logo design" --n 3 --out-dir ./generated/`,`bl image generate --prompt "Mountain landscape" --size 2688*1536`,`bl image generate --prompt "A castle" --seed 42 --no-prompt-extend`,`bl image generate --prompt "sunset" --model wan2.6-t2i --no-wait --quiet`,`bl image generate --prompt "Pro quality" --model qwen-image-2.0-pro`,`bl image generate --prompt "Product shots" --n 2 --concurrent 3 # 6 images in parallel`],async run(e,t){let n=t.prompt??t._positional?.[0];if(!n)if(v({nonInteractive:e.nonInteractive})){let e=await K({message:`Enter your image prompt:`});e||(process.stderr.write(`Image generation cancelled.
121
- `),process.exit(1)),n=e}else q(`prompt`,`bl image generate --prompt <text>`);let r=t.model||e.defaultImageModel||`qwen-image-2.0`,i=ii(r),a=ai(t.size||`1:1`,i),o=t.n??1,s=ei(t),c;t.noPromptExtend===!0?c=!1:(t.promptExtend===!0||i)&&(c=!0);let l={model:r,input:{messages:[{role:`user`,content:[{text:n}]}]},parameters:{size:a,n:o,seed:t.seed,prompt_extend:c,watermark:t.watermark===!0?!0:void 0,negative_prompt:t.negativePrompt||void 0}},d=u(e.output);if(e.dryRun){M({request:l,mode:i?`sync`:`async`},d);return}e.quiet||process.stderr.write(`[Model: ${r}] [Mode: ${i?`sync`:`async`}]\n`),i?await oi(e,r,l,t,d,s):await si(e,r,l,t,d,s)}})}));function mi(e){if(e)return hi[e]??e}var hi,gi,_i=j((()=>{X(),ri(),J(),P(),hi={"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},gi=l({name:`image edit`,description:`Edit an existing image with text instructions (Qwen-Image)`,apiDocs:`/developer-reference/qwen-image-edit-api`,usage:`bl image edit --image <url> --prompt <text> [flags]`,options:[{flag:`--image <url>`,description:`Source image URL or local file path (repeatable for multi-image merge)`,required:!0,type:`array`},{flag:`--prompt <text>`,description:`Edit instruction text`,required:!0},{flag:`--model <model>`,description:`Model ID (default: qwen-image-2.0)`},{flag:`--size <W*H>`,description:`Output image size: ratio (3:4, 16:9) or pixels (2048*2048)`},{flag:`--n <count>`,description:`Number of images (default: 1, max: 6)`,type:`number`},{flag:`--seed <n>`,description:`Random seed for reproducible results`,type:`number`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--prompt-extend`,description:`Enable prompt smart rewrite (default: true)`},{flag:`--no-prompt-extend`,description:`Disable prompt extend`},{flag:`--watermark`,description:`Add watermark to output images`},{flag:`--out-dir <dir>`,description:`Download images to directory`},{flag:`--out-prefix <prefix>`,description:`Filename prefix (default: edited)`}],examples:[`bl image edit --image ./photo.png --prompt "ๆŠŠ่ƒŒๆ™ฏๆขๆˆๆตทๆปฉ"`,`bl image edit --image https://example.com/logo.png --prompt "Change color to blue" --n 3`,`bl image edit --image ./a.png --image ./b.png --prompt "ๆŠŠไธคๅผ ๅ›พๅˆๅนถๆˆไธ€ๅผ ๆ‹ผๅ›พ"`,`bl image edit --image https://example.com/photo.png --prompt "Remove the person" --model qwen-image-2.0-pro`],async run(t,r){let i=[];Array.isArray(r.image)?i=r.image:typeof r.image==`string`&&(i=[r.image]),i.length===0&&q(`image`,`bl image edit --image <url> --prompt <text>`);let a=r.prompt;if(!a)if(v({nonInteractive:t.nonInteractive})){let e=await K({message:`Enter your edit instruction:`});e||(process.stderr.write(`Image editing cancelled.
122
- `),process.exit(1)),a=e}else q(`prompt`,`bl image edit --image <url> --prompt <text>`);let o=r.model||t.defaultImageModel||`qwen-image-2.0`,s=await E(t),c=await Promise.all(i.map(e=>D(e,s.token,o))),l=r.n??1,d;d=r.noPromptExtend===!0?!1:(r.promptExtend,!0);let p=c.map(e=>({image:e}));p.push({text:a});let m={model:o,input:{messages:[{role:`user`,content:p}]},parameters:{size:mi(r.size)||void 0,n:l,seed:r.seed,prompt_extend:d,watermark:r.watermark===!0?!0:void 0,negative_prompt:r.negativePrompt||void 0}};le(m.parameters);let h=u(t.output);if(t.dryRun){M({request:m},h);return}t.quiet||process.stderr.write(`[Model: ${o}] [Mode: sync] [Images: ${c.length}]\n`);let g=_(t.baseUrl),y=(await ti(ei(r),t,()=>T(t,{url:g,method:`POST`,body:m}))).flatMap(e=>e.output.choices||[]).flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);if(y.length===0)throw new e(`Edit completed but no images returned.`,n.GENERAL);let b=O(t,{flagDir:r.outDir,subDir:r.outDir?void 0:`images`}),x=r.outPrefix||f(`edited`,r?.prompt),S=await ni(y.length>1?y.map((e,t)=>({url:e,destPath:Me(b,`${x}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:y[0],destPath:Me(b,`${x}.png`)}],Y,{quiet:t.quiet});t.quiet?N(S.join(`
123
- `)):M({urls:y,saved:S,total:y.length},h)}})}));function vi(e){if(e)return yi[e.toLowerCase()]||e}var yi,bi,xi=j((()=>{Qr(),X(),ri(),J(),P(),yi={"720p":`1280*720`,"1080p":`1920*1080`,"480p":`832*480`},bi=l({name:`video generate`,description:`Generate a video from text or image (happyhorse-1.0-t2v / happyhorse-1.0-i2v / wan2.6-t2v)`,apiDocs:`/best-practice/wanx/text-to-video`,usage:`bl video generate --prompt <text> [--image <url>] [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-t2v, or happyhorse-1.0-i2v with --image)`},{flag:`--prompt <text>`,description:`Video description`,required:!0},{flag:`--image <url>`,description:`Input image URL for image-to-video generation`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--resolution <res>`,description:`Resolution (e.g. 1280*720, 960*960)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (e.g. 16:9, 1:1)`},{flag:`--duration <seconds>`,description:`Video duration in seconds (default: 5)`,type:`number`},{flag:`--prompt-extend`,description:`Automatically extend prompt for better results`},{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: 5)`,type:`number`}],examples:[`bl video generate --prompt "ไธ€ไธชไบบๅœจ่ฏปไนฆ๏ผŒ้™ๆ€้•œๅคด"`,`bl video generate --prompt "Ocean waves at sunset." --download sunset.mp4`,`bl video generate --image https://example.com/cat.png --prompt "่ฎฉ็”ป้ขไธญ็š„็ŒซๅŠจ่ตทๆฅ"`,`bl video generate --prompt "Mountain landscape" --resolution 1280*720 --duration 5`],async run(t,r){let i=r.prompt;if(!i)if(v({nonInteractive:t.nonInteractive})){let e=await K({message:`Enter your video prompt:`});e||(process.stderr.write(`Video generation cancelled.
124
- `),process.exit(1)),i=e}else q(`prompt`,`bl video generate --prompt <text>`);let a=r.model||t.defaultVideoModel||(r.image?`happyhorse-1.0-i2v`:`happyhorse-1.0-t2v`),o=u(t.output),s=r.image,c;s&&(c=await D(s,(await E(t)).token,a));let l={model:a,input:{prompt:i,negative_prompt:r.negativePrompt||void 0,...c?{media:[{type:`first_frame`,url:c}]}:{}},parameters:{resolution:vi(r.resolution)||void 0,ratio:r.ratio||void 0,duration:r.duration||void 0,prompt_extend:r.promptExtend===!0?!0:void 0,watermark:r.watermark===!0?!0:void 0,seed:r.seed}};if(t.dryRun){M({request:l},o);return}let d=ei(r),f=me(t.baseUrl),p=(await ti(d,t,()=>T(t,{url:f,method:`POST`,body:l,async:!0}),`tasks`)).map(e=>e.output.task_id);if(t.quiet||process.stderr.write(`[Model: ${a}]\n`),r.noWait||t.async){M(p.length===1?{task_id:p[0]}:{task_ids:p},o);return}let m=r.pollInterval??5,h=p.map(e=>Zr(t,{url:k(t.baseUrl,e),intervalSec:m,timeoutSec:t.timeout,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=await Promise.all(h),_=[];for(let e=0;e<g.length;e++){let t=g[e],n=t.output.video_url||t.output.results&&t.output.results[0]?.url;n&&_.push({taskId:p[e],videoUrl:n})}if(_.length===0)throw new e(`All tasks completed but no video URLs returned.`,n.GENERAL);if(r.download){let e=r.download,{size:n}=await Y(_[0].videoUrl,e,{quiet:t.quiet});t.quiet?N(e):M({task_id:_[0].taskId,video_url:_[0].videoUrl,status:`SUCCEEDED`,saved:e,size:$r(n)},o);return}let y=O(t,{subDir:`videos`}),{join:b}=await import(`path`),x=[];await Promise.all(_.map(async({taskId:e,videoUrl:n})=>{let r=b(y,`${e}.mp4`);await Y(n,r,{quiet:t.quiet}),x.push({task_id:e,video_url:n,saved:r})})),x.length===1?M(x[0],o):M({videos:x,total:x.length},o)}})})),Si,Ci=j((()=>{Qr(),X(),J(),P(),Si=l({name:`video edit`,description:`Edit a video with happyhorse-1.0-video-edit (style transfer, object replacement, etc.)`,apiDocs:`/best-practice/wanx/video-edit`,usage:`bl video edit --video <url> --prompt <text> [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-video-edit)`},{flag:`--video <url>`,description:`Input video URL or local file (mp4/mov, 2-10s)`,required:!0},{flag:`--prompt <text>`,description:`Edit instruction (e.g. "ๅฐ†็”ป้ข่ฝฌๆขไธบ้ปๅœŸ้ฃŽๆ ผ")`},{flag:`--ref-image <url>`,description:`Reference image URL (up to 4, comma-separated)`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--resolution <res>`,description:`Resolution: 720P or 1080P (default: 1080P)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (16:9, 9:16, 1:1, 4:3, 3:4)`},{flag:`--duration <seconds>`,description:`Output video duration in seconds (2-10)`,type:`number`},{flag:`--audio-setting <mode>`,description:`Audio: auto (default) or origin (keep original)`},{flag:`--prompt-extend`,description:`Enable prompt intelligent rewriting (default: true)`},{flag:`--no-prompt-extend`,description:`Disable prompt intelligent rewriting`},{flag:`--watermark`,description:`Add "AI็”Ÿๆˆ" watermark`},{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 edit --video https://example.com/input.mp4 --prompt "ๅฐ†ๆ•ดไธช็”ป้ข่ฝฌๆขไธบ้ปๅœŸ้ฃŽๆ ผ"`,`bl video edit --video https://example.com/input.mp4 --prompt "ๆ›ฟๆข่กฃๆœไธบๅ›พ็‰‡ไธญ็š„ๆฌพๅผ" --ref-image https://example.com/clothes.png`,`bl video edit --video https://example.com/input.mp4 --prompt "Convert to anime style" --resolution 720P --download output.mp4`],async run(t,r){let i=r.video;if(!i)if(v({nonInteractive:t.nonInteractive})){let e=await K({message:`Enter the video URL to edit:`});e||(process.stderr.write(`Video editing cancelled.
125
- `),process.exit(1)),i=e}else q(`video`,`bl video edit --video <url> --prompt <text>`);let a=r.prompt;if(!a&&v({nonInteractive:t.nonInteractive})){let e=await K({message:`Enter your edit instruction:`});e||(process.stderr.write(`Video editing cancelled.
126
- `),process.exit(1)),a=e}let o=r.model||`happyhorse-1.0-video-edit`,s=u(t.output),c=await E(t),l=[{type:`video`,url:await D(i,c.token,o)}],d=r.refImage;if(d){let e=d.split(`,`).map(e=>e.trim()).filter(Boolean);for(let t of e){let e=await D(t,c.token,o);l.push({type:`reference_image`,url:e})}}let f=r.noPromptExtend===!0?!1:r.promptExtend===!0?!0:void 0,p={model:o,input:{prompt:a||void 0,negative_prompt:r.negativePrompt||void 0,media:l},parameters:{resolution:r.resolution||void 0,ratio:r.ratio||void 0,duration:r.duration||void 0,audio_setting:r.audioSetting||void 0,prompt_extend:f,watermark:r.watermark===!0?!0:void 0,seed:r.seed}};if(t.dryRun){M({request:p},s);return}let m=(await T(t,{url:me(t.baseUrl),method:`POST`,body:p,async:!0})).output.task_id;if(t.quiet||(process.stderr.write(`[Model: ${o}]\n`),process.stderr.write(`Note: Video editing typically takes 5-8 minutes. Please be patient.
127
- `)),r.noWait||t.async){M({task_id:m},s);return}let h=r.pollInterval??15,g=await Zr(t,{url:k(t.baseUrl,m),intervalSec:h,timeoutSec:Math.max(t.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 e(`Task completed but no video URL returned.`,n.GENERAL);if(r.download){let e=r.download,{size:n}=await Y(_,e,{quiet:t.quiet});t.quiet?N(e):M({task_id:m,video_url:_,status:`SUCCEEDED`,saved:e,size:$r(n)},s);return}let{join:y}=await import(`path`),b=y(O(t,{subDir:`videos`}),`${m}.mp4`);await Y(_,b,{quiet:t.quiet}),M({task_id:m,video_url:_,saved:b},s)}})})),wi,Ti=j((()=>{Qr(),X(),J(),P(),wi=l({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(t,r){let i=r.prompt;if(!i)if(v({nonInteractive:t.nonInteractive})){let e=await K({message:`Enter your video prompt (use ๅ›พ1, ่ง†้ข‘1 to reference inputs):`});e||(process.stderr.write(`Video generation cancelled.
128
- `),process.exit(1)),i=e}else q(`prompt`,`bl video ref --prompt <text> --image <url>`);let a=r.image||[],o=r.refVideo||[];if(a.length===0&&o.length===0)throw new e(`At least one --image or --ref-video is required.`,n.USAGE,`bl video ref --prompt "ๆ่ฟฐ" --image person.jpg`);let s=r.imageVoice||[],c=r.videoVoice||[],l=r.model||`happyhorse-1.0-r2v`,d=u(t.output),f=await E(t),p=[];for(let e=0;e<a.length;e++){let t={type:`reference_image`,url:await D(a[e],f.token,l)};s[e]&&(t.reference_voice=await D(s[e],f.token,l)),p.push(t)}for(let e=0;e<o.length;e++){let t={type:`reference_video`,url:await D(o[e],f.token,l)};c[e]&&(t.reference_voice=await D(c[e],f.token,l)),p.push(t)}let m=r.noPromptExtend===!0?!1:r.promptExtend===!0?!0:void 0,h={model:l,input:{prompt:i,media:p},parameters:{resolution:r.resolution||void 0,ratio:r.ratio||void 0,duration:r.duration||void 0,prompt_extend:m,watermark:r.watermark===!0?!0:void 0,seed:r.seed}};if(t.dryRun){M({request:h},d);return}let g=(await T(t,{url:me(t.baseUrl),method:`POST`,body:h,async:!0})).output.task_id;if(t.quiet||(process.stderr.write(`[Model: ${l}]\n`),process.stderr.write(`Note: Reference-to-video typically takes 5-10 minutes. Please be patient.
129
- `)),r.noWait||t.async){M({task_id:g},d);return}let _=r.pollInterval??15,y=await Zr(t,{url:k(t.baseUrl,g),intervalSec:_,timeoutSec:Math.max(t.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}}),b=y.output.video_url||y.output.results&&y.output.results[0]?.url;if(!b)throw new e(`Task completed but no video URL returned.`,n.GENERAL);if(r.download){let e=r.download,{size:n}=await Y(b,e,{quiet:t.quiet});t.quiet?N(e):M({task_id:g,video_url:b,status:`SUCCEEDED`,saved:e,size:$r(n)},d);return}let{join:x}=await import(`path`),S=x(O(t,{subDir:`videos`}),`${g}.mp4`);await Y(b,S,{quiet:t.quiet}),M({task_id:g,video_url:b,saved:S},d)}})})),Ei,Di=j((()=>{J(),P(),Ei=l({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||q(`task-id`,`bl video task get --task-id <id>`);let r=u(e.output);if(e.dryRun){M({task_id:n},r);return}let i=await T(e,{url:k(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)}})})),Oi,ki=j((()=>{X(),J(),P(),Oi=l({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(t,r){let i=r.taskId;i||q(`task-id`,`bl video download --task-id <id> --out <path>`);let a=r.out;a||q(`out`,`bl video download --task-id <id> --out video.mp4`);let o=u(t.output);if(t.dryRun){M({task_id:i,action:`download`,out:a},o);return}let s=await T(t,{url:k(t.baseUrl,i)});if(s.output.task_status!==`SUCCEEDED`)throw new e(`Task is not complete (status: ${s.output.task_status}).`,n.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 e(`No download URL available for this task.`,n.GENERAL);let{size:l}=await Y(c,a,{quiet:t.quiet});if(t.quiet){N(a);return}M({saved:a,size:$r(l)},o)}})}));function Ai(e){let t=je(e).toLowerCase().split(`?`)[0];return!!(Ni.has(t)||/\.(mp4|mov|avi|mkv|webm|flv|wmv)(\?|$)/i.test(e))}async function ji(t){if(t.startsWith(`data:`)||t.startsWith(`http://`)||t.startsWith(`https://`)||t.startsWith(`oss://`))return t;if(!Te(t))throw new e(`File not found: ${t}`,n.USAGE);let r=je(t).toLowerCase(),i=Mi[r];if(!i)throw new e(`Unsupported image format "${r}". Supported: jpg, jpeg, png, webp`,n.USAGE);return`data:${i};base64,${De(t).toString(`base64`)}`}var Mi,Ni,Pi,Fi=j((()=>{J(),P(),Mi={".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".webp":`image/webp`},Ni=new Set([`.mp4`,`.mov`,`.avi`,`.mkv`,`.webm`,`.flv`,`.wmv`]),Pi=l({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: qwen-vl-max)`}],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(t,r){let i=r.image??r._positional?.[0],a=r.video??[],o=r.model||`qwen-vl-max`;i&&Ai(i)&&(a.push(i),i=void 0);let c=a.length>0,l=c?`Describe the video.`:`Describe the image.`,d=r.prompt||l;if(!i&&!c)if(v({nonInteractive:t.nonInteractive})){let e=await K({message:`Enter image/video path or URL:`});e||(process.stderr.write(`Vision describe cancelled.
130
- `),process.exit(1)),Ai(e)?a.push(e):i=e}else throw new e(`Missing required argument --image or --video.`,n.USAGE,`bl vision describe --image <path-or-url>
131
- bl vision describe --video <url-or-path>`);let f=u(t.output);if(t.dryRun){M({request:{prompt:d,image:i,video:a.length?a:void 0,model:o}},f);return}let p=[];if(a.length>0)for(let r of a){let i=r;if(y(r)){if(!Te(r))throw new e(`Video file not found: ${r}`,n.USAGE);i=await D(r,(await E(t)).token,o)}p.push({type:`video_url`,video_url:{url:i}})}if(i){let e=await ji(i),n=e;if(y(i)&&e.startsWith(`data:`)){let{statSync:e}=await import(`fs`);if(e(i).size>5*1024*1024){let e=await E(t);n=await D(i,e.token,o)}}p.push({type:`image_url`,image_url:{url:n}})}p.push({type:`text`,text:d});let m={model:o,messages:[{role:`user`,content:p}]},h=await T(t,{url:s(t.baseUrl),method:`POST`,body:m}),g=h.choices?.[0]?.message?.content;if(f!==`text`){M(h,f);return}N(g||``)}})})),Ii,Li=j((()=>{P(),Ii=l({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=w(),r=u(e.output),i={region:e.region,base_url:e.baseUrl,output:e.output,timeout:e.timeout,config_file:h()};n.api_key&&(i.api_key=x(n.api_key)),n.access_token&&(i.access_token=x(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)}})})),Ri,zi,Bi,Vi=j((()=>{P(),Ri=[`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`],zi={"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`},Bi=l({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(t,r){let i=r.key,a=r.value;if(!i||a===void 0)throw new e(`--key and --value are required.`,n.USAGE,`bl config set --key <key> --value <value>`);let o=zi[i]||i;if(!Ri.includes(o))throw new e(`Invalid config key "${i}". Valid keys: ${Ri.join(`, `)}`,n.USAGE);if(o===`region`&&![`cn`,`us`,`intl`].includes(a))throw new e(`Invalid region "${a}". Valid values: cn, us, intl`,n.USAGE);if(o===`output`&&![`text`,`json`].includes(a))throw new e(`Invalid output format "${a}". Valid values: text, json`,n.USAGE);if(o===`timeout`){let t=Number(a);if(isNaN(t)||t<=0)throw new e(`Invalid timeout "${a}". Must be a positive number.`,n.USAGE)}let s=u(t.output);if(t.dryRun){M({would_set:{[o]:a}},s);return}let c=w();c[o]=o===`timeout`?Number(a):a,await he(c),t.quiet||M({[o]:c[o]},s)}})})),Hi,Ui,Wi=j((()=>{Hi=[`auth `,`config `,`update`],Ui=l({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(t,r){let{commands:i}=await Promise.resolve().then(()=>(ro(),to)),a=r.command;if(a){let t=i[a];if(!t)throw new e(`Command "${a}" not found.`,n.USAGE);let r=p(t);process.stdout.write(JSON.stringify(r,null,2)+`
132
- `);return}let o=Object.values(i).filter(e=>!Hi.some(t=>e.name.startsWith(t))).map(e=>p(e));process.stdout.write(JSON.stringify(o,null,2)+`
133
- `)}})}));Pr(),Ir(),zr(),Hr(),Kr(),pi(),_i(),xi(),Ci(),Ti(),Di(),ki(),Fi(),Li(),Vi(),Wi();var Gi=`1.0.0`,Z,Ki=j((()=>{Z=Gi}));function qi(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 Ji(){try{let e=De(ta(),`utf-8`);return JSON.parse(e)}catch{return null}}function Yi(e){try{ke(ta(),JSON.stringify(e))}catch{}}async function Xi(e=ra){try{let t=ea.replace(`/`,`%2f`),n=await fetch(`${$i}/${t}/latest`,{headers:{Accept:`application/json`,...de()},signal:AbortSignal.timeout(e)});return n.ok?(await n.json()).version??null:null}catch{return null}}function Zi(){return ia}async function Qi(e){if(process.env.CI||!process.stderr.isTTY)return;let t=Ji(),n=Date.now();if(t&&n-t.lastChecked<na){t.latestVersion&&qi(t.latestVersion,e)&&(ia=t.latestVersion);return}let r=await Xi();r&&(Yi({lastChecked:n,latestVersion:r}),r&&qi(r,e)&&(ia=r))}var $i,ea,ta,na,ra,ia,aa=j((()=>{$i=`https://registry.npmjs.org`,ea=`bailian-cli`,ta=()=>Me(m(),`update-state.json`),na=14400*1e3,ra=3e3,ia=null}));function oa(){return{cmd:`npm install -g ${ea}@latest`,label:`npm`}}var sa,ca=j((()=>{Ki(),aa(),sa=l({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}${Z}${r}\n`),process.stderr.write(`Checking for updates...
134
- `);let i=await Xi(5e3);if(i&&i===Z){process.stderr.write(`${t}\u2713 Already up to date (${Z}).${r}\n`);return}i&&process.stderr.write(`Latest version: ${t}${i}${r}\n\n`);let{cmd:a,label:o}=oa();process.stderr.write(`Updating ${ea} via ${o}...\n\n`);try{Ne(a,{stdio:`inherit`});try{let e=Ne(`bl --version 2>/dev/null`,{encoding:`utf-8`}).trim().replace(/^bl\s+/,``);process.stderr.write(`\n${t}\u2713 Update complete: ${Z} \u2192 ${e}${r}\n`);try{ke(Me(m(),`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(`
115
+ `)}})}));function Xr(e){let t=[],n;if(e.system&&(n=e.system),e.messagesFile){let r=e.messagesFile,i=Ae(r===`-`?`/dev/stdin`:r,`utf-8`),a=JSON.parse(i);for(let e of a)e.role===`system`?n=typeof e.content==`string`?e.content:``:t.push(e)}if(e.message){let r=new Set([`system`,`user`,`assistant`]),i=e.message;for(let e of i){let i=e.indexOf(`:`),a=i===-1?``:e.slice(0,i);if(r.has(a)){let r=e.slice(i+1);a===`system`?n=r:t.push({role:a,content:r})}else t.push({role:`user`,content:e})}}return{system:n,messages:t}}var Zr,Qr=j((()=>{J(),P(),Zr=u({name:`text chat`,description:`Send a chat completion (OpenAI compatible, DashScope)`,apiDocs:`/compatibility-of-openai-with-dashscope`,usage:`bl text chat --message <text> [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: qwen3.6-plus)`},{flag:`--message <text>`,description:`Message text (repeatable, prefix role: to set role)`,required:!0,type:`array`},{flag:`--messages-file <path>`,description:`JSON file with messages array (use - for stdin)`},{flag:`--system <text>`,description:`System prompt`},{flag:`--max-tokens <n>`,description:`Maximum tokens to generate (default: 4096)`,type:`number`},{flag:`--temperature <n>`,description:`Sampling temperature (0.0, 2.0]`,type:`number`},{flag:`--top-p <n>`,description:`Nucleus sampling threshold`,type:`number`},{flag:`--stream`,description:`Stream response tokens (default: on in TTY)`},{flag:`--tool <json-or-path>`,description:`Tool definition as JSON or file path (repeatable)`,type:`array`},{flag:`--enable-thinking`,description:`Enable thinking/reasoning mode (for qwen3/qwq models)`},{flag:`--thinking-budget <n>`,description:`Max tokens for thinking (default: 4096)`,type:`number`}],examples:[`bl text chat --message "What is Qwen?"`,`bl text chat --model qwen-max --system "You are a coding assistant." --message "Write fizzbuzz in Python"`,`bl text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"`,`cat conversation.json | bl text chat --messages-file - --stream`,`bl text chat --message "Hello" --output json`,`bl text chat --model qwq-plus --message "Solve 1+1" --enable-thinking`],async run(e,t){let{system:n,messages:r}=Xr(t),i=r;if(i.length===0)if(b({nonInteractive:e.nonInteractive})){let e=await K({message:`Enter your message:`});e||(process.stderr.write(`Chat cancelled.
116
+ `),process.exit(1)),i=[{role:`user`,content:e}]}else q(`message`,`bl text chat --message <text>`);let a=t.model||e.defaultTextModel||`qwen3.6-plus`,o=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,s=d(e.output),l=[];n&&l.push({role:`system`,content:n}),l.push(...i);let u={model:a,messages:l,max_tokens:t.maxTokens??4096,stream:o};if(t.temperature!==void 0&&(u.temperature=t.temperature),t.topP!==void 0&&(u.top_p=t.topP),t.enableThinking&&(u.enable_thinking=!0,t.thinkingBudget!==void 0&&(u.thinking_budget=t.thinkingBudget)),t.tool&&(u.tools=t.tool.map(e=>{try{return JSON.parse(e)}catch{let t=Ae(e,`utf-8`);return JSON.parse(t)}})),e.dryRun){M({request:u},s);return}let f=c(e.baseUrl);if(o){let t=await se(e,{url:f,method:`POST`,body:u,stream:!0}),n=``,r=!1,i=s===`text`,a=e.noColor?``:`\x1B[2m`,o=e.noColor?``:`\x1B[0m`,c=process.stdout.isTTY,l=s===`json`?process.stderr:c?process.stdout:process.stderr,d=process.stdout;for await(let e of ae(t)){if(e.data===`[DONE]`)break;try{let t=JSON.parse(e.data);for(let e of t.choices){let t=e.delta;t.reasoning_content&&(i&&!r&&(r=!0,l.write(`${a}Thinking:\n`)),i&&l.write(t.reasoning_content)),t.content&&(i&&r&&(l.write(`${o}\n\nResponse:\n`),r=!1),n+=t.content,i&&d.write(t.content))}}catch{}}r&&l.write(o),s===`json`?M({content:n},s):d.write(`
117
+ `)}else{let t=await T(e,{url:f,method:`POST`,body:u}),n=t.choices?.[0]?.message?.content??``;e.quiet||s===`text`?N(n):M(t,s)}}})}));function $r(e){let t=Buffer.alloc(44);return t.write(`RIFF`,0),t.writeUInt32LE(36+e,4),t.write(`WAVE`,8),t.write(`fmt `,12),t.writeUInt32LE(16,16),t.writeUInt16LE(1,20),t.writeUInt16LE(1,22),t.writeUInt32LE(24e3,24),t.writeUInt32LE(48e3,28),t.writeUInt16LE(2,32),t.writeUInt16LE(16,34),t.write(`data`,36),t.writeUInt32LE(e,40),t}var ei,ti,ni=j((()=>{J(),P(),ei=[`Chelsie`,`Cherry`,`Ethan`,`Serena`,`Tina`],ti=u({name:`omni`,description:`Multimodal chat with text + audio output (Qwen-Omni)`,apiDocs:`/model-studio/qwen-omni`,usage:`bl omni --message <text> [flags]`,options:[{flag:`--message <text>`,description:`Message text (repeatable, prefix role: to set role)`,required:!0,type:`array`},{flag:`--model <model>`,description:`Model ID (default: qwen3.5-omni-plus)`},{flag:`--system <text>`,description:`System prompt`},{flag:`--image <url>`,description:`Image URL or local file (repeatable)`,type:`array`},{flag:`--audio <url>`,description:`Audio URL or local file (repeatable)`,type:`array`},{flag:`--video <url>`,description:`Video file URL / local path, or comma-separated frame URLs`,type:`array`},{flag:`--voice <voice>`,description:`Output voice (default: Cherry). Options: ${ei.join(`, `)}`},{flag:`--audio-format <fmt>`,description:`Audio output format (default: wav)`},{flag:`--audio-out <path>`,description:`Save audio to file (default: auto-generate)`},{flag:`--text-only`,description:`Output text only, no audio generation`},{flag:`--max-tokens <n>`,description:`Maximum tokens to generate`,type:`number`},{flag:`--temperature <n>`,description:`Sampling temperature (0.0, 2.0]`,type:`number`}],examples:[`bl omni --message "ไฝ ๅฅฝ๏ผŒไฝ ๆ˜ฏ่ฐ๏ผŸ"`,`bl omni --message "ๆ่ฟฐ่ฟ™ๅผ ๅ›พ็‰‡" --image ./photo.jpg`,`bl omni --message "่ฟ™ๆฎต้Ÿณ้ข‘ๅœจ่ฏดไป€ไนˆ๏ผŸ" --audio https://example.com/audio.wav`,`bl omni --message "ๆ€ป็ป“่ฟ™ไธช่ง†้ข‘" --video https://example.com/video.mp4`,`bl omni --message "่ฟ™ไธช่ง†้ข‘่ฎฒไบ†ไป€ไนˆ" --video ./local-video.mp4 --text-only`,`bl omni --message "็”จๅ››ๅท่ฏๅ›ž็ญ”๏ผšไปŠๅคฉๅคฉๆฐ”ๆ€Žไนˆๆ ท" --voice Serena`,`bl omni --message "Hello" --text-only --output json`,`bl omni --message "ๆœ—่ฏป่ฟ™ๆฎต่ฏ" --audio-out greeting.wav`],async run(e,t){let n=[];if(t.message&&(n=t.message),n.length===0)if(b({nonInteractive:e.nonInteractive})){let e=await K({message:`Enter your message:`});e||(process.stderr.write(`Omni chat cancelled.
118
+ `),process.exit(1)),n=[e]}else q(`message`,`bl text omni --message <text>`);let r=t.model||e.defaultOmniModel||`qwen3.5-omni-plus`,i=t.voice||`Cherry`,a=t.audioFormat||`wav`,o=t.textOnly===!0,s=d(e.output),l=[];t.system&&l.push({role:`system`,content:t.system});let u=new Set([`system`,`user`,`assistant`]);for(let e of n){let t=e.indexOf(`:`),n=t===-1?``:e.slice(0,t);if(u.has(n)){let r=e.slice(t+1);n===`system`?l.push({role:`system`,content:r}):l.push({role:n,content:r})}else l.push({role:`user`,content:e})}let f=t.image||[],p=t.audio||[],m=t.video||[],h=[],g=[],_=[];if(f.length>0||p.length>0||m.length>0){let t=await E(e);for(let e of f){let n=await D(e,t.token,r);h.push(n)}for(let e of p){let n=await D(e,t.token,r);g.push(n)}for(let e of m)if(e.includes(`,`)){let n=e.split(`,`).map(e=>e.trim()).filter(Boolean);for(let e of n){let n=await D(e,t.token,r);_.push(`frame:${n}`)}}else{let n=await D(e,t.token,r);_.push(n)}}if(h.length>0||g.length>0||_.length>0){for(let e=l.length-1;e>=0;e--)if(l[e].role===`user`){let t=l[e].content,n=[];typeof t==`string`?n.push({type:`text`,text:t}):Array.isArray(t)&&n.push(...t);for(let e of h)n.push({type:`image_url`,image_url:{url:e}});for(let e of g)n.push({type:`audio_url`,audio_url:{url:e}});let r=_.filter(e=>e.startsWith(`frame:`)).map(e=>e.slice(6)),i=_.filter(e=>!e.startsWith(`frame:`));r.length>0&&n.push({type:`video`,video:r});for(let e of i)n.push({type:`video_url`,video_url:{url:e}});l[e]={role:`user`,content:n};break}}let v={model:r,messages:l,stream:!0,stream_options:{include_usage:!0}};if(o||(v.modalities=[`text`,`audio`],v.audio={voice:i,format:a}),t.maxTokens!==void 0&&(v.max_tokens=t.maxTokens),t.temperature!==void 0&&(v.temperature=t.temperature),e.dryRun){M({request:v},s);return}if(!e.quiet){let e=o?`text-only`:`text+audio, voice: ${i}`;process.stderr.write(`[Model: ${r}] [${e}]\n`)}let y=await se(e,{url:c(e.baseUrl),method:`POST`,body:v,stream:!0}),x=``,S=``,C=process.stdout.isTTY,ee=process.stdout;for await(let e of ae(y)){if(e.data===`[DONE]`)break;try{let t=JSON.parse(e.data);for(let e of t.choices){let t=e.delta;t.content&&(x+=t.content,C&&ee.write(t.content)),t.audio?.data&&(S+=t.audio.data)}}catch{}}C&&x&&ee.write(`
119
+ `);let te;if(S&&!o){let n=Buffer.from(S,`base64`),r=$r(n.length),i=Buffer.concat([r,n]),a=t.audioOut;if(!a){let{join:t}=await import(`path`);a=t(O(e,{subDir:`omni`}),`omni_${Date.now()}.wav`)}Me(a,i),te=a,e.quiet||process.stderr.write(`Audio saved: ${a}\n`)}if(!C||s===`json`){let e={content:x};te&&(e.audio_saved=te,e.voice=i),M(e,s)}}})}));function ri(e){let t=process.stderr.isTTY,n=0,r=null,i=e;return{start(){t&&(r=setInterval(()=>{process.stderr.write(`\r${ai[n%ai.length]} ${i}`),n++},80))},update(e){i=e},stop(e){r&&=(clearInterval(r),null),t&&(process.stderr.write(`\r\x1B[K`),e&&process.stderr.write(`${e}\n`))}}}function ii(e,t=``){let n=process.stderr.isTTY;return{update(r){if(!n)return;let i=Math.min(1,r/e),a=Math.round(30*i),o=30-a,s=`โ–ˆ`.repeat(a)+`โ–‘`.repeat(o),c=`${Math.round(i*100)}%`;process.stderr.write(`\r${t} ${s} ${c}`)},finish(){n&&process.stderr.write(`
120
+ `)}}}var ai,oi=j((()=>{ai=[`โ ‹`,`โ ™`,`โ น`,`โ ธ`,`โ ผ`,`โ ด`,`โ ฆ`,`โ ง`,`โ ‡`,`โ `]}));async function si(t,n){let i=Date.now()+n.timeoutSec*1e3,a=ri(`Polling...`);t.quiet||a.start();try{for(;Date.now()<i;){let i=await T(t,{url:n.url});if(n.getStatus&&!t.quiet&&a.update(`Status: ${n.getStatus(i)}`),n.isComplete(i))return a.stop(`Done.`),i;if(n.isFailed(i)){a.stop(`Failed.`),t.verbose&&process.stderr.write(`[verbose] Task response: ${JSON.stringify(i,null,2)}\n`);let o=n.getErrorMessage?.(i);throw new e(o?`Task failed: ${o}`:`Task failed.`,r.GENERAL,o?void 0:`Use --verbose to see full API response details.`)}await new Promise(e=>setTimeout(e,n.intervalSec*1e3))}}finally{a.stop()}throw new e(`Polling timed out.`,r.TIMEOUT,`Try increasing --timeout or check task status manually.`)}var ci=j((()=>{oi()}));async function Y(t,n,i){let a=await fetch(t,{headers:me()});if(!a.ok)throw new e(`Download failed: HTTP ${a.status}`,r.GENERAL);let o=Number(a.headers.get(`content-length`)||0),s=a.body?.getReader();if(!s)throw new e(`No response body`,r.GENERAL);ke(Ne(n),{recursive:!0});let c=De(n),l=o>0&&!i?.quiet?ii(o,`Downloading`):null,u=0,d=!1;try{let e=new Promise((e,t)=>{c.on(`error`,t)});for(;;){let{done:t,value:n}=await Promise.race([s.read(),e]);if(t)break;c.write(n)||await new Promise(e=>c.once(`drain`,()=>e())),u+=n.byteLength,l?.update(u)}d=!0}finally{if(s.releaseLock(),l?.finish(),await new Promise((e,t)=>{c.on(`finish`,e),c.on(`error`,t),c.end()}),!d)try{je(n)}catch{}}return{size:u}}function li(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}var X=j((()=>{oi()}));function ui(e){let t=e.concurrent;return Math.max(1,t??1)}async function di(e,t,n,r=`requests`){if(e<=1)return[await n(0)];t.quiet||process.stderr.write(`[Concurrent: ${e} ${r}]\n`);let i=Array.from({length:e},(e,t)=>n(t));return Promise.all(i)}async function fi(e,t,n){return Promise.all(e.map(({url:e,destPath:r})=>t(e,r,n).then(()=>r)))}var pi=j((()=>{}));function mi(e){return yi.some(t=>e.startsWith(t))}function hi(e,t){return(t?bi:xi)[e]||e}async function gi(t,n,i,a,o,s){let c=y(t.baseUrl),l=(await di(s,t,()=>T(t,{url:c,method:`POST`,body:i}))).flatMap(e=>e.output.choices||[]).flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);if(l.length===0)throw new e(`Generation completed but no images returned.`,r.GENERAL);await vi(l,a,t,o)}async function _i(t,n,i,a,o,s){let c=v(t.baseUrl),l=(await di(s,t,()=>T(t,{url:c,method:`POST`,body:i,async:!0}),`tasks`)).map(e=>e.output.task_id);if(a.noWait||t.async){M({task_ids:l},o);return}let u=a.pollInterval??3,d=l.map(e=>si(t,{url:k(t.baseUrl,e),intervalSec:u,timeoutSec:t.timeout,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}})),f=await Promise.all(d),p=[];for(let e of f){if(e.output.choices){let t=e.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);p.push(...t)}if(e.output.results){let t=e.output.results.map(e=>e.url).filter(Boolean);t.length>0&&p.length===0&&p.push(...t)}}if(p.length===0)throw new e(`All tasks completed but no images returned.`,r.GENERAL);await vi(p,a,t,o,l.length===1?l[0]:void 0,l)}async function vi(e,t,n,r,i,a){let o=O(n,{flagDir:t.outDir,subDir:t.outDir?void 0:`images`}),s=t.prompt||t._positional?.[0]||``,c=t.outPrefix||m(`image`,s),l=await fi(e.length>1?e.map((e,t)=>({url:e,destPath:Fe(o,`${c}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:e[0],destPath:Fe(o,`${c}.png`)}],Y,{quiet:n.quiet});if(n.quiet)N(l.join(`
121
+ `));else{let t={urls:e,saved:l,total:e.length};i&&(t.task_id=i),a&&a.length>1&&(t.task_ids=a),M(t,r)}}var yi,bi,xi,Si,Ci=j((()=>{ci(),X(),pi(),J(),P(),yi=[`qwen-image-2.0`,`qwen-image-max`],bi={"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},xi={"16:9":`1664*928`,"4:3":`1472*1104`,"1:1":`1328*1328`,"3:4":`1104*1472`,"9:16":`928*1664`},Si=u({name:`image generate`,description:`Generate images (Qwen-Image / wan2.x)`,apiDocs:`/best-practice/wanx/text-to-image`,usage:`bl image generate --prompt <text> [flags]`,options:[{flag:`--prompt <text>`,description:`Image description`,required:!0},{flag:`--model <model>`,description:`Model ID (default: qwen-image-2.0)`},{flag:`--size <W*H>`,description:`Image size: ratio (3:4, 16:9, 1:1) or pixels (2048*2048)`},{flag:`--n <count>`,description:`Number of images per request (default: 1, max: 6)`,type:`number`},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--prompt-extend`,description:`Automatically extend prompt for better results (default: true for qwen-image)`},{flag:`--no-prompt-extend`,description:`Disable prompt extend`},{flag:`--watermark`,description:`Add watermark to generated images`},{flag:`--no-wait`,description:`Return task ID immediately without waiting (async models only)`},{flag:`--out-dir <dir>`,description:`Download images to directory`},{flag:`--out-prefix <prefix>`,description:`Filename prefix (default: image)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 3)`,type:`number`}],examples:[`bl image generate --prompt "ไธ€ๅช็ฉฟๅคช็ฉบๆœ็š„็Œซๅœจ็ซๆ˜ŸไธŠ"`,`bl image generate --prompt "Logo design" --n 3 --out-dir ./generated/`,`bl image generate --prompt "Mountain landscape" --size 2688*1536`,`bl image generate --prompt "A castle" --seed 42 --no-prompt-extend`,`bl image generate --prompt "sunset" --model wan2.6-t2i --no-wait --quiet`,`bl image generate --prompt "Pro quality" --model qwen-image-2.0-pro`,`bl image generate --prompt "Product shots" --n 2 --concurrent 3 # 6 images in parallel`],async run(e,t){let n=t.prompt??t._positional?.[0];if(!n)if(b({nonInteractive:e.nonInteractive})){let e=await K({message:`Enter your image prompt:`});e||(process.stderr.write(`Image generation cancelled.
122
+ `),process.exit(1)),n=e}else q(`prompt`,`bl image generate --prompt <text>`);let r=t.model||e.defaultImageModel||`qwen-image-2.0`,i=mi(r),a=hi(t.size||`1:1`,i),o=t.n??1,s=ui(t),c;t.noPromptExtend===!0?c=!1:(t.promptExtend===!0||i)&&(c=!0);let l={model:r,input:{messages:[{role:`user`,content:[{text:n}]}]},parameters:{size:a,n:o,seed:t.seed,prompt_extend:c,watermark:t.watermark===!0?!0:void 0,negative_prompt:t.negativePrompt||void 0}},u=d(e.output);if(e.dryRun){M({request:l,mode:i?`sync`:`async`},u);return}e.quiet||process.stderr.write(`[Model: ${r}] [Mode: ${i?`sync`:`async`}]\n`),i?await gi(e,r,l,t,u,s):await _i(e,r,l,t,u,s)}})}));function wi(e){if(e)return Ti[e]??e}var Ti,Ei,Di=j((()=>{X(),pi(),J(),P(),Ti={"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},Ei=u({name:`image edit`,description:`Edit an existing image with text instructions (Qwen-Image)`,apiDocs:`/developer-reference/qwen-image-edit-api`,usage:`bl image edit --image <url> --prompt <text> [flags]`,options:[{flag:`--image <url>`,description:`Source image URL or local file path (repeatable for multi-image merge)`,required:!0,type:`array`},{flag:`--prompt <text>`,description:`Edit instruction text`,required:!0},{flag:`--model <model>`,description:`Model ID (default: qwen-image-2.0)`},{flag:`--size <W*H>`,description:`Output image size: ratio (3:4, 16:9) or pixels (2048*2048)`},{flag:`--n <count>`,description:`Number of images (default: 1, max: 6)`,type:`number`},{flag:`--seed <n>`,description:`Random seed for reproducible results`,type:`number`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--prompt-extend`,description:`Enable prompt smart rewrite (default: true)`},{flag:`--no-prompt-extend`,description:`Disable prompt extend`},{flag:`--watermark`,description:`Add watermark to output images`},{flag:`--out-dir <dir>`,description:`Download images to directory`},{flag:`--out-prefix <prefix>`,description:`Filename prefix (default: edited)`}],examples:[`bl image edit --image ./photo.png --prompt "ๆŠŠ่ƒŒๆ™ฏๆขๆˆๆตทๆปฉ"`,`bl image edit --image https://example.com/logo.png --prompt "Change color to blue" --n 3`,`bl image edit --image ./a.png --image ./b.png --prompt "ๆŠŠไธคๅผ ๅ›พๅˆๅนถๆˆไธ€ๅผ ๆ‹ผๅ›พ"`,`bl image edit --image https://example.com/photo.png --prompt "Remove the person" --model qwen-image-2.0-pro`],async run(t,n){let i=[];Array.isArray(n.image)?i=n.image:typeof n.image==`string`&&(i=[n.image]),i.length===0&&q(`image`,`bl image edit --image <url> --prompt <text>`);let a=n.prompt;if(!a)if(b({nonInteractive:t.nonInteractive})){let e=await K({message:`Enter your edit instruction:`});e||(process.stderr.write(`Image editing cancelled.
123
+ `),process.exit(1)),a=e}else q(`prompt`,`bl image edit --image <url> --prompt <text>`);let o=n.model||t.defaultImageModel||`qwen-image-2.0`,s=await E(t),c=await Promise.all(i.map(e=>D(e,s.token,o))),l=n.n??1,u;u=n.noPromptExtend===!0?!1:(n.promptExtend,!0);let f=c.map(e=>({image:e}));f.push({text:a});let p={model:o,input:{messages:[{role:`user`,content:f}]},parameters:{size:wi(n.size)||void 0,n:l,seed:n.seed,prompt_extend:u,watermark:n.watermark===!0?!0:void 0,negative_prompt:n.negativePrompt||void 0}};fe(p.parameters);let h=d(t.output);if(t.dryRun){M({request:p},h);return}t.quiet||process.stderr.write(`[Model: ${o}] [Mode: sync] [Images: ${c.length}]\n`);let g=y(t.baseUrl),_=(await di(ui(n),t,()=>T(t,{url:g,method:`POST`,body:p}))).flatMap(e=>e.output.choices||[]).flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);if(_.length===0)throw new e(`Edit completed but no images returned.`,r.GENERAL);let v=O(t,{flagDir:n.outDir,subDir:n.outDir?void 0:`images`}),x=n.outPrefix||m(`edited`,n?.prompt),S=await fi(_.length>1?_.map((e,t)=>({url:e,destPath:Fe(v,`${x}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:_[0],destPath:Fe(v,`${x}.png`)}],Y,{quiet:t.quiet});t.quiet?N(S.join(`
124
+ `)):M({urls:_,saved:S,total:_.length},h)}})}));function Oi(e){if(e)return ki[e.toLowerCase()]||e}var ki,Ai,ji=j((()=>{ci(),X(),pi(),J(),P(),ki={"720p":`1280*720`,"1080p":`1920*1080`,"480p":`832*480`},Ai=u({name:`video generate`,description:`Generate a video from text or image (happyhorse-1.0-t2v / happyhorse-1.0-i2v / wan2.6-t2v)`,apiDocs:`/best-practice/wanx/text-to-video`,usage:`bl video generate --prompt <text> [--image <url>] [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-t2v, or happyhorse-1.0-i2v with --image)`},{flag:`--prompt <text>`,description:`Video description`,required:!0},{flag:`--image <url>`,description:`Input image URL for image-to-video generation`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--resolution <res>`,description:`Resolution (e.g. 1280*720, 960*960)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (e.g. 16:9, 1:1)`},{flag:`--duration <seconds>`,description:`Video duration in seconds (default: 5)`,type:`number`},{flag:`--prompt-extend`,description:`Automatically extend prompt for better results`},{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: 5)`,type:`number`}],examples:[`bl video generate --prompt "ไธ€ไธชไบบๅœจ่ฏปไนฆ๏ผŒ้™ๆ€้•œๅคด"`,`bl video generate --prompt "Ocean waves at sunset." --download sunset.mp4`,`bl video generate --image https://example.com/cat.png --prompt "่ฎฉ็”ป้ขไธญ็š„็ŒซๅŠจ่ตทๆฅ"`,`bl video generate --prompt "Mountain landscape" --resolution 1280*720 --duration 5`],async run(t,n){let i=n.prompt;if(!i)if(b({nonInteractive:t.nonInteractive})){let e=await K({message:`Enter your video prompt:`});e||(process.stderr.write(`Video generation cancelled.
125
+ `),process.exit(1)),i=e}else q(`prompt`,`bl video generate --prompt <text>`);let a=n.model||t.defaultVideoModel||(n.image?`happyhorse-1.0-i2v`:`happyhorse-1.0-t2v`),o=d(t.output),s=n.image,c;s&&(c=await D(s,(await E(t)).token,a));let l={model:a,input:{prompt:i,negative_prompt:n.negativePrompt||void 0,...c?{media:[{type:`first_frame`,url:c}]}:{}},parameters:{resolution:Oi(n.resolution)||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,prompt_extend:n.promptExtend===!0?!0:void 0,watermark:n.watermark===!0?!0:void 0,seed:n.seed}};if(t.dryRun){M({request:l},o);return}let u=ui(n),f=_e(t.baseUrl),p=(await di(u,t,()=>T(t,{url:f,method:`POST`,body:l,async:!0}),`tasks`)).map(e=>e.output.task_id);if(t.quiet||process.stderr.write(`[Model: ${a}]\n`),n.noWait||t.async){M(p.length===1?{task_id:p[0]}:{task_ids:p},o);return}let m=n.pollInterval??5,h=p.map(e=>si(t,{url:k(t.baseUrl,e),intervalSec:m,timeoutSec:t.timeout,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=await Promise.all(h),_=[];for(let e=0;e<g.length;e++){let t=g[e],n=t.output.video_url||t.output.results&&t.output.results[0]?.url;n&&_.push({taskId:p[e],videoUrl:n})}if(_.length===0)throw new e(`All tasks completed but no video URLs returned.`,r.GENERAL);if(n.download){let e=n.download,{size:r}=await Y(_[0].videoUrl,e,{quiet:t.quiet});t.quiet?N(e):M({task_id:_[0].taskId,video_url:_[0].videoUrl,status:`SUCCEEDED`,saved:e,size:li(r)},o);return}let v=O(t,{subDir:`videos`}),{join:y}=await import(`path`),x=[];await Promise.all(_.map(async({taskId:e,videoUrl:n})=>{let r=y(v,`${e}.mp4`);await Y(n,r,{quiet:t.quiet}),x.push({task_id:e,video_url:n,saved:r})})),x.length===1?M(x[0],o):M({videos:x,total:x.length},o)}})})),Mi,Ni=j((()=>{ci(),X(),J(),P(),Mi=u({name:`video edit`,description:`Edit a video with happyhorse-1.0-video-edit (style transfer, object replacement, etc.)`,apiDocs:`/best-practice/wanx/video-edit`,usage:`bl video edit --video <url> --prompt <text> [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-video-edit)`},{flag:`--video <url>`,description:`Input video URL or local file (mp4/mov, 2-10s)`,required:!0},{flag:`--prompt <text>`,description:`Edit instruction (e.g. "ๅฐ†็”ป้ข่ฝฌๆขไธบ้ปๅœŸ้ฃŽๆ ผ")`},{flag:`--ref-image <url>`,description:`Reference image URL (up to 4, comma-separated)`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--resolution <res>`,description:`Resolution: 720P or 1080P (default: 1080P)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (16:9, 9:16, 1:1, 4:3, 3:4)`},{flag:`--duration <seconds>`,description:`Output video duration in seconds (2-10)`,type:`number`},{flag:`--audio-setting <mode>`,description:`Audio: auto (default) or origin (keep original)`},{flag:`--prompt-extend`,description:`Enable prompt intelligent rewriting (default: true)`},{flag:`--no-prompt-extend`,description:`Disable prompt intelligent rewriting`},{flag:`--watermark`,description:`Add "AI็”Ÿๆˆ" watermark`},{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 edit --video https://example.com/input.mp4 --prompt "ๅฐ†ๆ•ดไธช็”ป้ข่ฝฌๆขไธบ้ปๅœŸ้ฃŽๆ ผ"`,`bl video edit --video https://example.com/input.mp4 --prompt "ๆ›ฟๆข่กฃๆœไธบๅ›พ็‰‡ไธญ็š„ๆฌพๅผ" --ref-image https://example.com/clothes.png`,`bl video edit --video https://example.com/input.mp4 --prompt "Convert to anime style" --resolution 720P --download output.mp4`],async run(t,n){let i=n.video;if(!i)if(b({nonInteractive:t.nonInteractive})){let e=await K({message:`Enter the video URL to edit:`});e||(process.stderr.write(`Video editing cancelled.
126
+ `),process.exit(1)),i=e}else q(`video`,`bl video edit --video <url> --prompt <text>`);let a=n.prompt;if(!a&&b({nonInteractive:t.nonInteractive})){let e=await K({message:`Enter your edit instruction:`});e||(process.stderr.write(`Video editing cancelled.
127
+ `),process.exit(1)),a=e}let o=n.model||`happyhorse-1.0-video-edit`,s=d(t.output),c=await E(t),l=[{type:`video`,url:await D(i,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 D(t,c.token,o);l.push({type:`reference_image`,url:e})}}let f=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:f,watermark:n.watermark===!0?!0:void 0,seed:n.seed}};if(t.dryRun){M({request:p},s);return}let m=(await T(t,{url:_e(t.baseUrl),method:`POST`,body:p,async:!0})).output.task_id;if(t.quiet||(process.stderr.write(`[Model: ${o}]\n`),process.stderr.write(`Note: Video editing typically takes 5-8 minutes. Please be patient.
128
+ `)),n.noWait||t.async){M({task_id:m},s);return}let h=n.pollInterval??15,g=await si(t,{url:k(t.baseUrl,m),intervalSec:h,timeoutSec:Math.max(t.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 e(`Task completed but no video URL returned.`,r.GENERAL);if(n.download){let e=n.download,{size:r}=await Y(_,e,{quiet:t.quiet});t.quiet?N(e):M({task_id:m,video_url:_,status:`SUCCEEDED`,saved:e,size:li(r)},s);return}let v=await import(`path`),y=O(t,{subDir:`videos`}),x=v.join(y,`${m}.mp4`);await Y(_,x,{quiet:t.quiet}),M({task_id:m,video_url:_,saved:x},s)}})})),Pi,Fi=j((()=>{ci(),X(),J(),P(),Pi=u({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(t,n){let i=n.prompt;if(!i)if(b({nonInteractive:t.nonInteractive})){let e=await K({message:`Enter your video prompt (use ๅ›พ1, ่ง†้ข‘1 to reference inputs):`});e||(process.stderr.write(`Video generation cancelled.
129
+ `),process.exit(1)),i=e}else q(`prompt`,`bl video ref --prompt <text> --image <url>`);let a=n.image||[],o=n.refVideo||[];if(a.length===0&&o.length===0)throw new e(`At least one --image or --ref-video is required.`,r.USAGE,`bl video ref --prompt "ๆ่ฟฐ" --image person.jpg`);let s=n.imageVoice||[],c=n.videoVoice||[],l=n.model||`happyhorse-1.0-r2v`,u=d(t.output),f=await E(t),p=[];for(let e=0;e<a.length;e++){let t={type:`reference_image`,url:await D(a[e],f.token,l)};s[e]&&(t.reference_voice=await D(s[e],f.token,l)),p.push(t)}for(let e=0;e<o.length;e++){let t={type:`reference_video`,url:await D(o[e],f.token,l)};c[e]&&(t.reference_voice=await D(c[e],f.token,l)),p.push(t)}let m=n.noPromptExtend===!0?!1:n.promptExtend===!0?!0:void 0,h={model:l,input:{prompt:i,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(t.dryRun){M({request:h},u);return}let g=(await T(t,{url:_e(t.baseUrl),method:`POST`,body:h,async:!0})).output.task_id;if(t.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||t.async){M({task_id:g},u);return}let _=n.pollInterval??15,v=await si(t,{url:k(t.baseUrl,g),intervalSec:_,timeoutSec:Math.max(t.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 e(`Task completed but no video URL returned.`,r.GENERAL);if(n.download){let e=n.download,{size:r}=await Y(y,e,{quiet:t.quiet});t.quiet?N(e):M({task_id:g,video_url:y,status:`SUCCEEDED`,saved:e,size:li(r)},u);return}let{join:x}=await import(`path`),S=x(O(t,{subDir:`videos`}),`${g}.mp4`);await Y(y,S,{quiet:t.quiet}),M({task_id:g,video_url:y,saved:S},u)}})})),Ii,Li=j((()=>{J(),P(),Ii=u({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||q(`task-id`,`bl video task get --task-id <id>`);let r=d(e.output);if(e.dryRun){M({task_id:n},r);return}let i=await T(e,{url:k(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)}})})),Ri,zi=j((()=>{X(),J(),P(),Ri=u({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(t,n){let i=n.taskId;i||q(`task-id`,`bl video download --task-id <id> --out <path>`);let a=n.out;a||q(`out`,`bl video download --task-id <id> --out video.mp4`);let o=d(t.output);if(t.dryRun){M({task_id:i,action:`download`,out:a},o);return}let s=await T(t,{url:k(t.baseUrl,i)});if(s.output.task_status!==`SUCCEEDED`)throw new e(`Task is not complete (status: ${s.output.task_status}).`,r.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 e(`No download URL available for this task.`,r.GENERAL);let{size:l}=await Y(c,a,{quiet:t.quiet});if(t.quiet){N(a);return}M({saved:a,size:li(l)},o)}})}));function Bi(e){let t=Pe(e).toLowerCase().split(`?`)[0];return!!(Ui.has(t)||/\.(mp4|mov|avi|mkv|webm|flv|wmv)(\?|$)/i.test(e))}async function Vi(t){if(t.startsWith(`data:`)||t.startsWith(`http://`)||t.startsWith(`https://`)||t.startsWith(`oss://`))return t;if(!Oe(t))throw new e(`File not found: ${t}`,r.USAGE);let n=Pe(t).toLowerCase(),i=Hi[n];if(!i)throw new e(`Unsupported image format "${n}". Supported: jpg, jpeg, png, webp`,r.USAGE);return`data:${i};base64,${Ae(t).toString(`base64`)}`}var Hi,Ui,Wi,Gi=j((()=>{J(),P(),Hi={".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".webp":`image/webp`},Ui=new Set([`.mp4`,`.mov`,`.avi`,`.mkv`,`.webm`,`.flv`,`.wmv`]),Wi=u({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: qwen-vl-max)`}],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(t,n){let i=n.image??n._positional?.[0],a=n.video??[],o=n.model||`qwen-vl-max`;i&&Bi(i)&&(a.push(i),i=void 0);let s=a.length>0,l=s?`Describe the video.`:`Describe the image.`,u=n.prompt||l;if(!i&&!s)if(b({nonInteractive:t.nonInteractive})){let e=await K({message:`Enter image/video path or URL:`});e||(process.stderr.write(`Vision describe cancelled.
131
+ `),process.exit(1)),Bi(e)?a.push(e):i=e}else throw new e(`Missing required argument --image or --video.`,r.USAGE,`bl vision describe --image <path-or-url>
132
+ bl vision describe --video <url-or-path>`);let f=d(t.output);if(t.dryRun){M({request:{prompt:u,image:i,video:a.length?a:void 0,model:o}},f);return}let p=[];if(a.length>0)for(let n of a){let i=n;if(x(n)){if(!Oe(n))throw new e(`Video file not found: ${n}`,r.USAGE);i=await D(n,(await E(t)).token,o)}p.push({type:`video_url`,video_url:{url:i}})}if(i){let e=await Vi(i),n=e;if(x(i)&&e.startsWith(`data:`)){let{statSync:e}=await import(`fs`);if(e(i).size>5*1024*1024){let e=await E(t);n=await D(i,e.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 T(t,{url:c(t.baseUrl),method:`POST`,body:m}),g=h.choices?.[0]?.message?.content;if(f!==`text`){M(h,f);return}N(g||``)}})})),Ki,qi=j((()=>{P(),Ki=u({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=w(),r=d(e.output),i={region:e.region,base_url:e.baseUrl,output:e.output,timeout:e.timeout,config_file:_()};n.api_key&&(i.api_key=C(n.api_key)),n.access_token&&(i.access_token=C(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)}})})),Ji,Yi,Xi,Zi=j((()=>{P(),Ji=[`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`],Yi={"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`},Xi=u({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(t,n){let i=n.key,a=n.value;if(!i||a===void 0)throw new e(`--key and --value are required.`,r.USAGE,`bl config set --key <key> --value <value>`);let o=Yi[i]||i;if(!Ji.includes(o))throw new e(`Invalid config key "${i}". Valid keys: ${Ji.join(`, `)}`,r.USAGE);if(o===`region`&&![`cn`,`us`,`intl`].includes(a))throw new e(`Invalid region "${a}". Valid values: cn, us, intl`,r.USAGE);if(o===`output`&&![`text`,`json`].includes(a))throw new e(`Invalid output format "${a}". Valid values: text, json`,r.USAGE);if(o===`timeout`){let t=Number(a);if(isNaN(t)||t<=0)throw new e(`Invalid timeout "${a}". Must be a positive number.`,r.USAGE)}let s=d(t.output);if(t.dryRun){M({would_set:{[o]:a}},s);return}let c=w();c[o]=o===`timeout`?Number(a):a,await ve(c),t.quiet||M({[o]:c[o]},s)}})})),Qi,$i,ea=j((()=>{Qi=[`auth `,`config `,`update`],$i=u({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(t,n){let{commands:i}=await Promise.resolve().then(()=>(po(),uo)),a=n.command;if(a){let t=i[a];if(!t)throw new e(`Command "${a}" not found.`,r.USAGE);let n=h(t);process.stdout.write(JSON.stringify(n,null,2)+`
133
+ `);return}let o=Object.values(i).filter(e=>!Qi.some(t=>e.name.startsWith(t))).map(e=>h(e));process.stdout.write(JSON.stringify(o,null,2)+`
134
+ `)}})}));Lr(),Kr(),Yr(),Qr(),ni(),Ci(),Di(),ji(),Ni(),Fi(),Li(),zi(),Gi(),qi(),Zi(),ea();var ta=`1.0.2`,Z,na=j((()=>{Z=ta}));function ra(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 ia(){try{let e=Ae(da(),`utf-8`);return JSON.parse(e)}catch{return null}}function aa(e){try{Me(da(),JSON.stringify(e))}catch{}}async function oa(e=pa){try{let t=ua.replace(`/`,`%2f`),n=await fetch(`${la}/${t}/latest`,{headers:{Accept:`application/json`,...me()},signal:AbortSignal.timeout(e)});return n.ok?(await n.json()).version??null:null}catch{return null}}function sa(){return ma}async function ca(e){if(process.env.CI||!process.stderr.isTTY)return;let t=ia(),n=Date.now();if(t&&n-t.lastChecked<fa){t.latestVersion&&ra(t.latestVersion,e)&&(ma=t.latestVersion);return}let r=await oa();r&&(aa({lastChecked:n,latestVersion:r}),r&&ra(r,e)&&(ma=r))}var la,ua,da,fa,pa,ma,ha=j((()=>{la=`https://registry.npmjs.org`,ua=`bailian-cli`,da=()=>Fe(g(),`update-state.json`),fa=14400*1e3,pa=3e3,ma=null}));function ga(){return{cmd:`npm install -g ${ua}@latest`,label:`npm`}}var _a,va=j((()=>{na(),ha(),_a=u({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}${Z}${r}\n`),process.stderr.write(`Checking for updates...
135
+ `);let i=await oa(5e3);if(i&&i===Z){process.stderr.write(`${t}\u2713 Already up to date (${Z}).${r}\n`);return}i&&process.stderr.write(`Latest version: ${t}${i}${r}\n\n`);let{cmd:a,label:o}=ga();process.stderr.write(`Updating ${ua} via ${o}...\n\n`);try{Ie(a,{stdio:`inherit`});try{let e=Ie(`bl --version 2>/dev/null`,{encoding:`utf-8`}).trim().replace(/^bl\s+/,``);process.stderr.write(`\n${t}\u2713 Update complete: ${Z} \u2192 ${e}${r}\n`);try{Me(Fe(g(),`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(`
135
136
  Automatic update failed. Please run manually:
136
- `),process.stderr.write(` ${a}\n\n`)}}})})),la,ua=j((()=>{J(),P(),la=l({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||q(`app-id`,`bl app call --app-id <id> --prompt <text>`);let r=t.prompt;r||q(`prompt`,`bl app call --app-id <id> --prompt <text>`);let i=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,o=u(e.output),s={input:{prompt:r},parameters:{incremental_output:i}};t.sessionId&&(s.input.session_id=t.sessionId);let c=t.image;c&&c.length>0&&(s.input.image_list=c);let l=t.fileId;if(l&&l.length>0&&(s.input.file_ids=l),t.hasThoughts&&(s.parameters.has_thoughts=!0),t.pipelineIds){let e=t.pipelineIds.split(`,`).map(e=>e.trim()).filter(Boolean);s.parameters.rag_options={pipeline_ids:e}}if(t.memoryId&&(s.parameters.memory_id=t.memoryId),t.bizParams)try{s.input.biz_params=JSON.parse(t.bizParams)}catch{process.stderr.write(`Error: --biz-params must be valid JSON
137
- `),process.exit(1)}if(e.dryRun){M({endpoint:a(e.baseUrl,n),request:s},o);return}let d=a(e.baseUrl,n);if(i){let n=await ae(e,{url:d,method:`POST`,body:s,headers:{"X-DashScope-SSE":`enable`},stream:!0}),r=``,i=``,a=o===`text`,c=e.noColor?``:`\x1B[2m`,l=e.noColor?``:`\x1B[0m`;for await(let e of re(n)){if(e.data===`[DONE]`)break;try{let n=JSON.parse(e.data),o=n.output?.text;if(o&&(a&&process.stdout.write(o),r+=o),n.output?.session_id&&(i=n.output.session_id),n.output?.thoughts&&t.hasThoughts)for(let e of n.output.thoughts)e.thought&&process.stderr.write(`${c}[Thinking] ${e.thought}${l}\n`),e.action_name&&process.stderr.write(`${c}[Action] ${e.action_name}: ${e.action_input||``}${l}\n`),e.observation&&process.stderr.write(`${c}[Observation] ${e.observation}${l}\n`)}catch{}}i&&!e.quiet&&process.stderr.write(`${c}Session ID: ${i}${l}\n`),o===`json`?M({text:r,session_id:i},o):process.stdout.write(`
138
- `)}else{let t=await T(e,{url:d,method:`POST`,body:s}),n=t.output?.text??``;e.quiet||o===`text`?N(n):M(t,o)}}})})),da,fa,pa=j((()=>{P(),da=`zeldaEasy.broadscope-bailian.app-control.list`,fa=l({name:`app list`,description:`List Bailian applications`,usage:`bl app list [flags]`,options:[{flag:`--name <name>`,description:`Filter by app name (keyword search)`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--page-size <n>`,description:`Results per page (default: 30)`,type:`number`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl app list`,`bl app list --name ๅฎขๆœ`,`bl app list --page 2 --page-size 10`,`bl app list --output json`],async run(e,t){let n=t.name||``,r=t.page||1,i=t.pageSize||30,a=t.region||`cn-beijing`,s=u(t.output||`yaml`),c=await E(e),l={reqDTO:{name:n,notInTypes:[10],type:5,statuses:[1,4],page_no:r,page_size:i}};if(e.dryRun){M({api:da,data:l,region:a,token:c.token.slice(0,8)+`...`},s);return}let d=await o(e,c.token,{api:da,data:l,region:a}),f=d?.data?.DataV2?.data?.data?.list??[];M({total:d?.data?.DataV2?.data?.data?.total??0,apps:f.map(e=>({code:e.code,name:e.name,user_prompt_params:e.config?.user_prompt_params??[]}))},s)}})})),ma,ha=j((()=>{J(),P(),ma=l({name:`memory add`,description:`Add memory from messages or custom content`,usage:`bl memory add --user-id <id> [--messages <json>] [--content <text>] [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--messages <json>`,description:`Messages JSON array: [{"role":"user","content":"..."},...]`},{flag:`--content <text>`,description:`Custom content text to memorize`},{flag:`--profile-schema <id>`,description:`Profile schema ID for user profiling`},{flag:`--memory-library-id <id>`,description:`Memory library ID (isolate memory space)`}],examples:[`bl memory add --user-id user1 --content "็”จๆˆทๅ–œๆฌขPython็ผ–็จ‹"`,`bl memory add --user-id user1 --messages '[{"role":"user","content":"ๆˆ‘ๅ–œๆฌขๆ—…่กŒ"}]'`,`bl memory add --user-id user1 --content "ไฝๅœจๅŒ—ไบฌ" --profile-schema schema_xxx`],async run(e,t){let n=t.userId;n||q(`user-id`,`bl memory add --user-id <id>`);let r={user_id:n};if(t.messages)try{r.messages=JSON.parse(t.messages)}catch{process.stderr.write(`Error: --messages must be valid JSON array
137
+ `),process.stderr.write(` ${a}\n\n`)}}})})),ya,ba=j((()=>{J(),P(),ya=u({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||q(`app-id`,`bl app call --app-id <id> --prompt <text>`);let r=t.prompt;r||q(`prompt`,`bl app call --app-id <id> --prompt <text>`);let i=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,a=d(e.output),s={input:{prompt:r},parameters:{incremental_output:i}};t.sessionId&&(s.input.session_id=t.sessionId);let c=t.image;c&&c.length>0&&(s.input.image_list=c);let l=t.fileId;if(l&&l.length>0&&(s.input.file_ids=l),t.hasThoughts&&(s.parameters.has_thoughts=!0),t.pipelineIds){let e=t.pipelineIds.split(`,`).map(e=>e.trim()).filter(Boolean);s.parameters.rag_options={pipeline_ids:e}}if(t.memoryId&&(s.parameters.memory_id=t.memoryId),t.bizParams)try{s.input.biz_params=JSON.parse(t.bizParams)}catch{process.stderr.write(`Error: --biz-params must be valid JSON
138
+ `),process.exit(1)}if(e.dryRun){M({endpoint:o(e.baseUrl,n),request:s},a);return}let u=o(e.baseUrl,n);if(i){let n=await se(e,{url:u,method:`POST`,body:s,headers:{"X-DashScope-SSE":`enable`},stream:!0}),r=``,i=``,o=a===`text`,c=e.noColor?``:`\x1B[2m`,l=e.noColor?``:`\x1B[0m`;for await(let e of ae(n)){if(e.data===`[DONE]`)break;try{let n=JSON.parse(e.data),a=n.output?.text;if(a&&(o&&process.stdout.write(a),r+=a),n.output?.session_id&&(i=n.output.session_id),n.output?.thoughts&&t.hasThoughts)for(let e of n.output.thoughts)e.thought&&process.stderr.write(`${c}[Thinking] ${e.thought}${l}\n`),e.action_name&&process.stderr.write(`${c}[Action] ${e.action_name}: ${e.action_input||``}${l}\n`),e.observation&&process.stderr.write(`${c}[Observation] ${e.observation}${l}\n`)}catch{}}i&&!e.quiet&&process.stderr.write(`${c}Session ID: ${i}${l}\n`),a===`json`?M({text:r,session_id:i},a):process.stdout.write(`
139
+ `)}else{let t=await T(e,{url:u,method:`POST`,body:s}),n=t.output?.text??``;e.quiet||a===`text`?N(n):M(t,a)}}})})),xa,Sa,Ca=j((()=>{P(),xa=`zeldaEasy.broadscope-bailian.app-control.list`,Sa=u({name:`app list`,description:`List Bailian applications`,usage:`bl app list [flags]`,options:[{flag:`--name <name>`,description:`Filter by app name (keyword search)`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--page-size <n>`,description:`Results per page (default: 30)`,type:`number`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl app list`,`bl app list --name ๅฎขๆœ`,`bl app list --page 2 --page-size 10`,`bl app list --output json`],async run(e,t){let n=t.name||``,r=t.page||1,i=t.pageSize||30,a=t.region||`cn-beijing`,o=d(e.output),c=await ce(e),l={reqDTO:{name:n,notInTypes:[10],type:5,statuses:[1,4],page_no:r,page_size:i}};if(e.dryRun){M({api:xa,data:l,region:a,token:c.token.slice(0,8)+`...`},o);return}let u=await s(e,c.token,{api:xa,data:l,region:a}),f=u?.data?.DataV2?.data?.data?.list??[];M({total:u?.data?.DataV2?.data?.data?.total??0,apps:f.map(e=>({code:e.code,name:e.name,user_prompt_params:e.config?.user_prompt_params??[]}))},o)}})})),wa,Ta=j((()=>{J(),P(),wa=u({name:`memory add`,description:`Add memory from messages or custom content`,usage:`bl memory add --user-id <id> [--messages <json>] [--content <text>] [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--messages <json>`,description:`Messages JSON array: [{"role":"user","content":"..."},...]`},{flag:`--content <text>`,description:`Custom content text to memorize`},{flag:`--profile-schema <id>`,description:`Profile schema ID for user profiling`},{flag:`--memory-library-id <id>`,description:`Memory library ID (isolate memory space)`}],examples:[`bl memory add --user-id user1 --content "็”จๆˆทๅ–œๆฌขPython็ผ–็จ‹"`,`bl memory add --user-id user1 --messages '[{"role":"user","content":"ๆˆ‘ๅ–œๆฌขๆ—…่กŒ"}]'`,`bl memory add --user-id user1 --content "ไฝๅœจๅŒ—ไบฌ" --profile-schema schema_xxx`],async run(e,t){let n=t.userId;n||q(`user-id`,`bl memory add --user-id <id>`);let r={user_id:n};if(t.messages)try{r.messages=JSON.parse(t.messages)}catch{process.stderr.write(`Error: --messages must be valid JSON array
139
140
  `),process.exit(1)}t.content&&(r.custom_content=t.content),!r.messages&&!r.custom_content&&(process.stderr.write(`Error: at least one of --messages or --content is required
140
- `),process.exit(1)),t.profileSchema&&(r.profile_schema=t.profileSchema),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=u(e.output);if(e.dryRun){M({endpoint:ee(e.baseUrl),request:r},i);return}let a=await T(e,{url:ee(e.baseUrl),method:`POST`,body:r});e.quiet||i===`text`?N(`Memory added. IDs: ${a.memory_ids?.join(`, `)||`none`}`):M(a,i)}})})),ga,_a=j((()=>{J(),P(),ga=l({name:`memory search`,description:`Search memory nodes by query or messages`,usage:`bl memory search --user-id <id> [--query <text>] [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--query <text>`,description:`Search query text`},{flag:`--messages <json>`,description:`Messages JSON array for context-based search`},{flag:`--top-k <n>`,description:`Number of results to return (default: 10)`,type:`number`},{flag:`--memory-library-id <id>`,description:`Memory library ID`}],examples:[`bl memory search --user-id user1 --query "็ผ–็จ‹ๅๅฅฝ"`,`bl memory search --user-id user1 --messages '[{"role":"user","content":"ๆŽจ่ไธ€ๆœฌไนฆ"}]' --top-k 5`],async run(e,t){let n=t.userId;n||q(`user-id`,`bl memory search --user-id <id>`);let r={user_id:n};if(t.query&&(r.query=t.query),t.messages)try{r.messages=JSON.parse(t.messages)}catch{process.stderr.write(`Error: --messages must be valid JSON array
141
+ `),process.exit(1)),t.profileSchema&&(r.profile_schema=t.profileSchema),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=d(e.output);if(e.dryRun){M({endpoint:te(e.baseUrl),request:r},i);return}let a=await T(e,{url:te(e.baseUrl),method:`POST`,body:r});e.quiet||i===`text`?N(`Memory added. IDs: ${a.memory_ids?.join(`, `)||`none`}`):M(a,i)}})})),Ea,Da=j((()=>{J(),P(),Ea=u({name:`memory search`,description:`Search memory nodes by query or messages`,usage:`bl memory search --user-id <id> [--query <text>] [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--query <text>`,description:`Search query text`},{flag:`--messages <json>`,description:`Messages JSON array for context-based search`},{flag:`--top-k <n>`,description:`Number of results to return (default: 10)`,type:`number`},{flag:`--memory-library-id <id>`,description:`Memory library ID`}],examples:[`bl memory search --user-id user1 --query "็ผ–็จ‹ๅๅฅฝ"`,`bl memory search --user-id user1 --messages '[{"role":"user","content":"ๆŽจ่ไธ€ๆœฌไนฆ"}]' --top-k 5`],async run(e,t){let n=t.userId;n||q(`user-id`,`bl memory search --user-id <id>`);let r={user_id:n};if(t.query&&(r.query=t.query),t.messages)try{r.messages=JSON.parse(t.messages)}catch{process.stderr.write(`Error: --messages must be valid JSON array
141
142
  `),process.exit(1)}!r.messages&&r.query&&(r.messages=[{role:`user`,content:r.query}]),!r.query&&!r.messages&&(process.stderr.write(`Error: at least one of --query or --messages is required
142
- `),process.exit(1)),t.topK!==void 0&&(r.top_k=t.topK),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=u(e.output);if(e.dryRun){M({endpoint:ne(e.baseUrl),request:r},i);return}let a=await T(e,{url:ne(e.baseUrl),method:`POST`,body:r});if(e.quiet||i===`text`)if(!a.memory_nodes||a.memory_nodes.length===0)N(`No memory nodes found.`);else for(let e of a.memory_nodes)N(`[${e.memory_node_id}] ${e.content}`);else M(a,i)}})})),va,ya=j((()=>{J(),P(),va=l({name:`memory list`,description:`List memory nodes for a user`,usage:`bl memory list --user-id <id> [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--page-size <n>`,description:`Results per page (default: 10)`,type:`number`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--memory-library-id <id>`,description:`Memory library ID`}],examples:[`bl memory list --user-id user1`,`bl memory list --user-id user1 --page-size 20 --page 2`],async run(e,t){let n=t.userId;n||q(`user-id`,`bl memory list --user-id <id>`);let r=u(e.output),i=new URLSearchParams;i.set(`user_id`,n),t.pageSize!==void 0&&i.set(`page_size`,String(t.pageSize)),t.page!==void 0&&i.set(`page_num`,String(t.page)),t.memoryLibraryId&&i.set(`memory_library_id`,t.memoryLibraryId);let a=`${te(e.baseUrl)}?${i.toString()}`;if(e.dryRun){M({endpoint:a,method:`GET`},r);return}let o=await T(e,{url:a,method:`GET`});if(e.quiet||r===`text`)if(!o.memory_nodes||o.memory_nodes.length===0)N(`No memory nodes found.`);else{for(let e of o.memory_nodes)N(`[${e.memory_node_id}] ${e.content}`);o.total!==void 0&&N(`\nTotal: ${o.total}`)}else M(o,r)}})})),ba,xa=j((()=>{J(),P(),ba=l({name:`memory update`,description:`Update a memory node content`,usage:`bl memory update --node-id <id> --user-id <id> --content <text>`,options:[{flag:`--node-id <id>`,description:`Memory node ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--content <text>`,description:`New content for the memory node (required)`,required:!0},{flag:`--memory-library-id <id>`,description:`Memory library ID (non-default library)`}],examples:[`bl memory update --node-id node_xxx --user-id user1 --content "ๆ›ดๆ–ฐๅŽ็š„่ฎฐๅฟ†ๅ†…ๅฎน"`],async run(e,t){let n=t.nodeId;n||q(`node-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let r=t.userId;r||q(`user-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let i=t.content;i||q(`content`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let a={user_id:r,custom_content:i};t.memoryLibraryId&&(a.memory_library_id=t.memoryLibraryId);let o=u(e.output);if(e.dryRun){M({endpoint:C(e.baseUrl,n),method:`PATCH`,request:a},o);return}let s=await T(e,{url:C(e.baseUrl,n),method:`PATCH`,body:a});e.quiet||o===`text`?N(`Memory node ${n} updated.`):M(s,o)}})})),Sa,Ca=j((()=>{J(),P(),Sa=l({name:`memory delete`,description:`Delete a memory node`,usage:`bl memory delete --node-id <id> --user-id <id>`,options:[{flag:`--node-id <id>`,description:`Memory node ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--memory-library-id <id>`,description:`Memory library ID (non-default library)`}],examples:[`bl memory delete --node-id node_xxx --user-id user1`],async run(e,t){let n=t.nodeId;n||q(`node-id`,`bl memory delete --node-id <id> --user-id <id>`);let r=t.userId;r||q(`user-id`,`bl memory delete --node-id <id> --user-id <id>`);let i=u(e.output),a=new URLSearchParams({user_id:r});t.memoryLibraryId&&a.set(`memory_library_id`,t.memoryLibraryId);let o=`${C(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){M({endpoint:o,method:`DELETE`},i);return}let s=await T(e,{url:o,method:`DELETE`});e.quiet||i===`text`?N(`Memory node ${n} deleted.`):M(s,i)}})})),wa,Ta=j((()=>{J(),P(),wa=l({name:`memory profile create`,description:`Create a user profile schema for memory profiling`,usage:`bl memory profile create --name <name> --attributes <json> [flags]`,options:[{flag:`--name <name>`,description:`Schema name (required)`,required:!0},{flag:`--description <text>`,description:`Schema description`},{flag:`--attributes <json>`,description:`Attributes JSON array: [{"name":"age","description":"ๅนด้พ„"}]`,required:!0}],examples:[`bl memory profile create --name "user_basic" --attributes '[{"name":"age","description":"ๅนด้พ„"},{"name":"hobby","description":"็ˆฑๅฅฝ"}]'`],async run(e,t){let n=t.name;n||q(`name`,`bl memory profile create --name <name> --attributes <json>`);let r=t.attributes;r||q(`attributes`,`bl memory profile create --name <name> --attributes <json>`);let i;try{i=JSON.parse(r)}catch{process.stderr.write(`Error: --attributes must be valid JSON array
143
- `),process.exit(1)}let a={name:n,attributes:i};t.description&&(a.description=t.description);let o=u(e.output);if(e.dryRun){M({endpoint:ie(e.baseUrl),request:a},o);return}let s=await T(e,{url:ie(e.baseUrl),method:`POST`,body:a});e.quiet||o===`text`?N(`Profile schema created: ${s.profile_schema_id}`):M(s,o)}})})),Ea,Da=j((()=>{J(),P(),Ea=l({name:`memory profile get`,description:`Get user profile by schema ID and user ID`,usage:`bl memory profile get --schema-id <id> --user-id <id>`,options:[{flag:`--schema-id <id>`,description:`Profile schema ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0}],examples:[`bl memory profile get --schema-id schema_xxx --user-id user1`],async run(e,t){let n=t.schemaId;n||q(`schema-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let r=t.userId;r||q(`user-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let i=u(e.output),a=new URLSearchParams({user_id:r}),o=`${pe(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){M({endpoint:o,method:`GET`},i);return}let s=await T(e,{url:o,method:`GET`});if(e.quiet||i===`text`)if(s.profile?.attributes)for(let e of s.profile.attributes)N(`${e.name}: ${e.value??`(empty)`}`);else N(`No profile data found.`);else M(s,i)}})})),Oa,ka,Aa=j((()=>{J(),P(),Oa=`bailian.cn-beijing.aliyuncs.com`,ka=l({name:`knowledge retrieve`,description:`Retrieve from a Bailian knowledge base (requires AK/SK)`,usage:`bl knowledge retrieve --index-id <id> --query <text> [flags]`,options:[{flag:`--index-id <id>`,description:`Knowledge base index ID (required)`,required:!0},{flag:`--query <text>`,description:`Search query (required)`,required:!0},{flag:`--workspace-id <id>`,description:`Bailian workspace ID (or env BAILIAN_WORKSPACE_ID)`},{flag:`--top-k <n>`,description:`Number of results (default: 10)`,type:`number`},{flag:`--rerank`,description:`Enable rerank`},{flag:`--rerank-top-n <n>`,description:`Rerank top N results`,type:`number`},{flag:`--access-key-id <key>`,description:`Alibaba Cloud Access Key ID (or env)`},{flag:`--access-key-secret <key>`,description:`Alibaba Cloud Access Key Secret (or env)`}],examples:[`bl knowledge retrieve --index-id idx_xxx --query "ๅฆ‚ไฝ•ไฝฟ็”จ้˜ฟ้‡Œไบ‘็™พ็‚ผ" --workspace-id ws_xxx`,`bl knowledge retrieve --index-id idx_xxx --query "API้™ๆต" --top-k 5 --rerank`],async run(t,r){let i=r.indexId;i||q(`index-id`,`bl knowledge retrieve --index-id <id> --query <text>`);let a=r.query;a||q(`query`,`bl knowledge retrieve --index-id <id> --query <text>`);let o=r.accessKeyId||t.accessKeyId,s=r.accessKeySecret||t.accessKeySecret,c=r.workspaceId||t.workspaceId;if(!o||!s)throw new e(`Knowledge retrieve requires Alibaba Cloud AK/SK.
143
+ `),process.exit(1)),t.topK!==void 0&&(r.top_k=t.topK),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=d(e.output);if(e.dryRun){M({endpoint:ie(e.baseUrl),request:r},i);return}let a=await T(e,{url:ie(e.baseUrl),method:`POST`,body:r});if(e.quiet||i===`text`)if(!a.memory_nodes||a.memory_nodes.length===0)N(`No memory nodes found.`);else for(let e of a.memory_nodes)N(`[${e.memory_node_id}] ${e.content}`);else M(a,i)}})})),Oa,ka=j((()=>{J(),P(),Oa=u({name:`memory list`,description:`List memory nodes for a user`,usage:`bl memory list --user-id <id> [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--page-size <n>`,description:`Results per page (default: 10)`,type:`number`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--memory-library-id <id>`,description:`Memory library ID`}],examples:[`bl memory list --user-id user1`,`bl memory list --user-id user1 --page-size 20 --page 2`],async run(e,t){let n=t.userId;n||q(`user-id`,`bl memory list --user-id <id>`);let r=d(e.output),i=new URLSearchParams;i.set(`user_id`,n),t.pageSize!==void 0&&i.set(`page_size`,String(t.pageSize)),t.page!==void 0&&i.set(`page_num`,String(t.page)),t.memoryLibraryId&&i.set(`memory_library_id`,t.memoryLibraryId);let a=`${ne(e.baseUrl)}?${i.toString()}`;if(e.dryRun){M({endpoint:a,method:`GET`},r);return}let o=await T(e,{url:a,method:`GET`});if(e.quiet||r===`text`)if(!o.memory_nodes||o.memory_nodes.length===0)N(`No memory nodes found.`);else{for(let e of o.memory_nodes)N(`[${e.memory_node_id}] ${e.content}`);o.total!==void 0&&N(`\nTotal: ${o.total}`)}else M(o,r)}})})),Aa,ja=j((()=>{J(),P(),Aa=u({name:`memory update`,description:`Update a memory node content`,usage:`bl memory update --node-id <id> --user-id <id> --content <text>`,options:[{flag:`--node-id <id>`,description:`Memory node ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--content <text>`,description:`New content for the memory node (required)`,required:!0},{flag:`--memory-library-id <id>`,description:`Memory library ID (non-default library)`}],examples:[`bl memory update --node-id node_xxx --user-id user1 --content "ๆ›ดๆ–ฐๅŽ็š„่ฎฐๅฟ†ๅ†…ๅฎน"`],async run(e,t){let n=t.nodeId;n||q(`node-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let r=t.userId;r||q(`user-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let i=t.content;i||q(`content`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let a={user_id:r,custom_content:i};t.memoryLibraryId&&(a.memory_library_id=t.memoryLibraryId);let o=d(e.output);if(e.dryRun){M({endpoint:re(e.baseUrl,n),method:`PATCH`,request:a},o);return}let s=await T(e,{url:re(e.baseUrl,n),method:`PATCH`,body:a});e.quiet||o===`text`?N(`Memory node ${n} updated.`):M(s,o)}})})),Ma,Na=j((()=>{J(),P(),Ma=u({name:`memory delete`,description:`Delete a memory node`,usage:`bl memory delete --node-id <id> --user-id <id>`,options:[{flag:`--node-id <id>`,description:`Memory node ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--memory-library-id <id>`,description:`Memory library ID (non-default library)`}],examples:[`bl memory delete --node-id node_xxx --user-id user1`],async run(e,t){let n=t.nodeId;n||q(`node-id`,`bl memory delete --node-id <id> --user-id <id>`);let r=t.userId;r||q(`user-id`,`bl memory delete --node-id <id> --user-id <id>`);let i=d(e.output),a=new URLSearchParams({user_id:r});t.memoryLibraryId&&a.set(`memory_library_id`,t.memoryLibraryId);let o=`${re(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){M({endpoint:o,method:`DELETE`},i);return}let s=await T(e,{url:o,method:`DELETE`});e.quiet||i===`text`?N(`Memory node ${n} deleted.`):M(s,i)}})})),Pa,Fa=j((()=>{J(),P(),Pa=u({name:`memory profile create`,description:`Create a user profile schema for memory profiling`,usage:`bl memory profile create --name <name> --attributes <json> [flags]`,options:[{flag:`--name <name>`,description:`Schema name (required)`,required:!0},{flag:`--description <text>`,description:`Schema description`},{flag:`--attributes <json>`,description:`Attributes JSON array: [{"name":"age","description":"ๅนด้พ„"}]`,required:!0}],examples:[`bl memory profile create --name "user_basic" --attributes '[{"name":"age","description":"ๅนด้พ„"},{"name":"hobby","description":"็ˆฑๅฅฝ"}]'`],async run(e,t){let n=t.name;n||q(`name`,`bl memory profile create --name <name> --attributes <json>`);let r=t.attributes;r||q(`attributes`,`bl memory profile create --name <name> --attributes <json>`);let i;try{i=JSON.parse(r)}catch{process.stderr.write(`Error: --attributes must be valid JSON array
144
+ `),process.exit(1)}let a={name:n,attributes:i};t.description&&(a.description=t.description);let o=d(e.output);if(e.dryRun){M({endpoint:oe(e.baseUrl),request:a},o);return}let s=await T(e,{url:oe(e.baseUrl),method:`POST`,body:a});e.quiet||o===`text`?N(`Profile schema created: ${s.profile_schema_id}`):M(s,o)}})})),Ia,La=j((()=>{J(),P(),Ia=u({name:`memory profile get`,description:`Get user profile by schema ID and user ID`,usage:`bl memory profile get --schema-id <id> --user-id <id>`,options:[{flag:`--schema-id <id>`,description:`Profile schema ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0}],examples:[`bl memory profile get --schema-id schema_xxx --user-id user1`],async run(e,t){let n=t.schemaId;n||q(`schema-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let r=t.userId;r||q(`user-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let i=d(e.output),a=new URLSearchParams({user_id:r}),o=`${ge(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){M({endpoint:o,method:`GET`},i);return}let s=await T(e,{url:o,method:`GET`});if(e.quiet||i===`text`)if(s.profile?.attributes)for(let e of s.profile.attributes)N(`${e.name}: ${e.value??`(empty)`}`);else N(`No profile data found.`);else M(s,i)}})})),Ra,za,Ba=j((()=>{J(),P(),Ra=`bailian.cn-beijing.aliyuncs.com`,za=u({name:`knowledge retrieve`,description:`Retrieve from a Bailian knowledge base (requires AK/SK)`,usage:`bl knowledge retrieve --index-id <id> --query <text> [flags]`,options:[{flag:`--index-id <id>`,description:`Knowledge base index ID (required)`,required:!0},{flag:`--query <text>`,description:`Search query (required)`,required:!0},{flag:`--workspace-id <id>`,description:`Bailian workspace ID (or env BAILIAN_WORKSPACE_ID)`},{flag:`--top-k <n>`,description:`Number of results (default: 10)`,type:`number`},{flag:`--rerank`,description:`Enable rerank`},{flag:`--rerank-top-n <n>`,description:`Rerank top N results`,type:`number`},{flag:`--access-key-id <key>`,description:`Alibaba Cloud Access Key ID (or env)`},{flag:`--access-key-secret <key>`,description:`Alibaba Cloud Access Key Secret (or env)`}],examples:[`bl knowledge retrieve --index-id idx_xxx --query "ๅฆ‚ไฝ•ไฝฟ็”จ้˜ฟ้‡Œไบ‘็™พ็‚ผ" --workspace-id ws_xxx`,`bl knowledge retrieve --index-id idx_xxx --query "API้™ๆต" --top-k 5 --rerank`],async run(t,n){let i=n.indexId;i||q(`index-id`,`bl knowledge retrieve --index-id <id> --query <text>`);let a=n.query;a||q(`query`,`bl knowledge retrieve --index-id <id> --query <text>`);let o=n.accessKeyId||t.accessKeyId,s=n.accessKeySecret||t.accessKeySecret,c=n.workspaceId||t.workspaceId;if(!o||!s)throw new e(`Knowledge retrieve requires Alibaba Cloud AK/SK.
144
145
  Set via: --access-key-id / --access-key-secret flags,
145
146
  or env: ALIBABA_CLOUD_ACCESS_KEY_ID / ALIBABA_CLOUD_ACCESS_KEY_SECRET,
146
- or config: bl config set access_key_id <key>`,n.AUTH);if(!c)throw new e(`Knowledge retrieve requires a workspace ID.
147
- Set via: --workspace-id flag, or env: BAILIAN_WORKSPACE_ID, or config: bl config set workspace_id <id>`,n.USAGE);let l={IndexId:i,Query:a};r.topK!==void 0&&(l.TopK=r.topK),r.rerank&&(l.Rerank=!0),r.rerankTopN!==void 0&&(l.RerankTopN=r.rerankTopN);let d=u(t.output),f=`/${c}/index/retrieve`;if(t.dryRun){M({endpoint:`https://${Oa}${f}`,workspaceId:c,request:l},d);return}let p=JSON.stringify(l),m=oe({accessKeyId:o,accessKeySecret:s,action:`Retrieve`,version:`2023-12-29`,body:p,host:Oa,pathname:f}),h=`https://${Oa}${f}`;t.verbose&&(process.stderr.write(`> POST ${h}\n`),process.stderr.write(`> AK: ${o.slice(0,8)}...\n`));let g=t.timeout*1e3,_=await fetch(h,{method:`POST`,headers:{...m,...de()},body:p,signal:AbortSignal.timeout(g)});t.verbose&&process.stderr.write(`< ${_.status} ${_.statusText}\n`);let v=await _.json();if(!_.ok||v.Code&&v.Code!==`Success`)throw new e(`Knowledge retrieve failed: ${v.Code||_.status} - ${v.Message||_.statusText}`,n.GENERAL);if(t.quiet||d===`text`){let e=v.Data?.Nodes||[];if(e.length===0)N(`No results found.`);else for(let t=0;t<e.length;t++){let n=e[t];N(`[${t+1}] (score: ${n.Score.toFixed(4)})`),N(n.Text),N(``)}}else M(v,d)}})})),ja,Ma=j((()=>{Xr(),J(),P(),ja=l({name:`search web`,description:`Search the web using DashScope MCP WebSearch service`,usage:`bl search web --query <text> [flags]`,options:[{flag:`--query <text>`,description:`Search query text`,required:!0},{flag:`--count <n>`,description:`Number of search results (default: 10)`,type:`number`},{flag:`--list-tools`,description:`List available MCP tools and exit`}],examples:[`bl search web --query "้˜ฟ้‡Œไบ‘็™พ็‚ผๆœ€ๆ–ฐๅŠŸ่ƒฝ"`,`bl search web --query "TypeScript 5.9 new features" --count 5`,`bl search web --query "ไปŠๆ—ฅๆ–ฐ้—ป"`,`bl search web --list-tools`],async run(e,t){let n=S(e.baseUrl),r=u(e.output);if(t.listTools){if(e.dryRun){M({endpoint:n,action:`tools/list`},r);return}let t=new i(e,n);await t.initialize(),M({tools:await t.listTools()},r);return}let a=t.query;if(!a)if(v({nonInteractive:e.nonInteractive})){let e=await K({message:`Enter your search query:`});e||(process.stderr.write(`Search cancelled.
148
- `),process.exit(1)),a=e}else q(`query`,`bl search web --query <text>`);if(e.dryRun){M({endpoint:n,action:`tools/call`,tool:`bailian_web_search`,arguments:{query:a,count:t.count||void 0}},r);return}let o=new i(e,n),s=qr(`Initializing search...`);e.quiet||s.start();try{await o.initialize(),e.quiet||s.update(`Searching...`);let n={query:a};t.count&&(n.count=t.count);let i=await o.callTool(`bailian_web_search`,n);if(e.quiet||s.stop(`Done.`),i.isError){let e=i.content.map(e=>e.text||``).join(`
149
- `);process.stderr.write(`Search error: ${e}\n`),process.exit(1)}if(r===`json`)M(i,r);else for(let e of i.content)if(e.type===`text`&&e.text)try{let t=JSON.parse(e.text);t.pages&&Array.isArray(t.pages)?M({pages:t.pages,total:t.pages.length},r):M(t,r)}catch{M({text:e.text},r)}}catch(e){throw s.stop(`Failed.`),e}}})}));function Na(e){let t=Ra[e];if(!t){process.stdout.write(`No built-in voice list available for model: ${e}\n`);return}if(t.length===0){process.stdout.write(`Model ${e} has no system voices.\n`),process.stdout.write(`Use clone or design voices created via the CosyVoice API.
150
- `),process.stdout.write(`See: ${Ia}\n`);return}let n=(e,t)=>e.padEnd(t);process.stdout.write(`\nSystem voices for ${e}:\n`),process.stdout.write(`${n(`VOICE ID`,26)} ${n(`NAME`,10)} ${n(`DESCRIPTION`,16)} LANGUAGE\n`),process.stdout.write(`${`-`.repeat(26)} ${`-`.repeat(10)} ${`-`.repeat(16)} ${`-`.repeat(12)}\n`);for(let e of t)process.stdout.write(`${n(e.voice,26)} ${n(e.name,10)} ${n(e.desc,16)} ${e.lang}\n`);process.stdout.write(`\nTotal: ${t.length} voices\n`)}async function Pa(t,r,i,a,o){let s=await ti(ei(a),t,()=>T(t,{url:r,method:`POST`,body:i})),c=s.map(e=>e.output?.audio?.url).filter(Boolean);if(c.length===0)throw new e(`API returned no audio URL.`,n.GENERAL);let{join:l}=await import(`path`),u=O(t,{subDir:`speech`}),d=await ni(c.map((e,t)=>{let n=a.out;return n&&c.length===1||(n=l(u,`tts_${Date.now()}${c.length>1?`_${String(t+1).padStart(3,`0`)}`:``}.${i.input.format??`mp3`}`)),{url:e,destPath:n}}),Y,{quiet:t.quiet});if(t.quiet)N(d.join(`
151
- `));else if(d.length===1){let e=s[0].output?.audio?.expires_at;M({saved:d[0],audio_url:c[0],model:i.model,voice:i.input.voice,...e?{url_expires_at:e}:{}},o)}else M({saved:d,audio_urls:c,total:d.length,model:i.model,voice:i.input.voice},o)}async function Fa(e,t,n,r,i){let a=await ae(e,{url:t,method:`POST`,body:n,stream:!0,headers:{Accept:`text/event-stream`,"X-DashScope-SSE":`enable`}}),o=r.out,s=o?we(o):null,c;try{for await(let t of re(a)){if(!t.data||t.data===`[DONE]`)continue;let n;try{n=JSON.parse(t.data)}catch{continue}let r=n.output?.audio?.data;if(r){let e=Buffer.from(r,`base64`);s?s.write(e)||await new Promise(e=>s.once(`drain`,()=>e())):process.stdout.write(e)}if(n.output?.finish_reason===`stop`){c=n.output?.audio?.url,c&&!e.quiet&&process.stderr.write(`\nFull audio URL: ${c}\n`);break}}}finally{s&&(await new Promise((e,t)=>{s.on(`finish`,e),s.on(`error`,t),s.end()}),!e.quiet&&o&&process.stderr.write(`Saved: ${o}\n`))}o&&M({saved:o,...c?{audio_url:c}:{},model:n.model,voice:n.input.voice},i)}var Ia,La,Ra,za,Ba=j((()=>{X(),ri(),J(),P(),Ia=`${t.cn}/cosyvoice-clone-design-api`,La=[{voice:`longanyang`,name:`้พ™ๅฎ‰ๆด‹`,desc:`้˜ณๅ…‰ๅคง็”ทๅญฉ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longanhuan`,name:`้พ™ๅฎ‰ๆฌข`,desc:`ๆฌข่„ฑๅ…ƒๆฐ”ๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longantai_v3`,name:`้พ™ๅฎ‰ๅฐ`,desc:`ๅ—ฒ็”œๅฐๆนพๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longhua_v3`,name:`้พ™ๅŽ`,desc:`ๅ…ƒๆฐ”็”œ็พŽๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longcheng_v3`,name:`้พ™ๆฉ™`,desc:`ๆ™บๆ…ง้’ๅนด็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longze_v3`,name:`้พ™ๆณฝ`,desc:`ๆธฉๆš–ๅ…ƒๆฐ”็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longzhe_v3`,name:`้พ™ๅ“ฒ`,desc:`ๅ‘†ๆฟๅคงๆš–็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longyan_v3`,name:`้พ™้ขœ`,desc:`ๆธฉๆš–ๆ˜ฅ้ฃŽๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longxing_v3`,name:`้พ™ๆ˜Ÿ`,desc:`ๆธฉๅฉ‰้‚ปๅฎถๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longtian_v3`,name:`้พ™ๅคฉ`,desc:`็ฃๆ€ง็†ๆ™บ็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longwan_v3`,name:`้พ™ๅฉ‰`,desc:`็ป†่…ปๆŸ”ๅฃฐๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longqiang_v3`,name:`้พ™ๅซฑ`,desc:`ๆตชๆผซ้ฃŽๆƒ…ๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longfeifei_v3`,name:`้พ™่ฒ่ฒ`,desc:`็”œ็พŽๅจ‡ๆฐ”ๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longhao_v3`,name:`้พ™ๆตฉ`,desc:`ๅคšๆƒ…ๅฟง้ƒ็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longanrou_v3`,name:`้พ™ๅฎ‰ๆŸ”`,desc:`ๆธฉๆŸ”ๅจด้™ๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longxiaochun_v3`,name:`้พ™ๅฐๆทณ`,desc:`็Ÿฅๆ€ง็งฏๆžๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longxiaoxia_v3`,name:`้พ™ๅฐๅค`,desc:`ๆฒ‰็จณๆƒๅจๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longyumi_v3`,name:`YUMI`,desc:`ๆญฃ็ป้’ๅนดๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longanyun_v3`,name:`้พ™ๅฎ‰ๆ˜€`,desc:`ๅฑ…ๅฎถๆš–็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longanwen_v3`,name:`้พ™ๅฎ‰ๆธฉ`,desc:`ไผ˜้›…็Ÿฅๆ€งๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longanli_v3`,name:`้พ™ๅฎ‰่މ`,desc:`ๅˆฉ่ฝไปŽๅฎนๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longanlang_v3`,name:`้พ™ๅฎ‰ๆœ—`,desc:`ๆธ…็ˆฝๅˆฉ่ฝ็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longyingmu_v3`,name:`้พ™ๅบ”ๆฒ`,desc:`ไผ˜้›…็Ÿฅๆ€งๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longyingxun_v3`,name:`้พ™ๅบ”่ฏข`,desc:`ๅนด่ฝป้’ๆถฉ็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longyingjing_v3`,name:`้พ™ๅบ”้™`,desc:`ไฝŽ่ฐƒๅ†ท้™ๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longyingling_v3`,name:`้พ™ๅบ”่†`,desc:`ๆธฉๅ’Œๅ…ฑๆƒ…ๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longyingtao_v3`,name:`้พ™ๅบ”ๆกƒ`,desc:`ๆธฉๆŸ”ๆทกๅฎšๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longyingxiao_v3`,name:`้พ™ๅบ”็ฌ‘`,desc:`ๆธ…็”œๆŽจ้”€ๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longfei_v3`,name:`้พ™้ฃž`,desc:`็ƒญ่ก€็ฃๆ€ง็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longhuhu_v3`,name:`้พ™ๅ‘ผๅ‘ผ`,desc:`ๅคฉ็œŸ็ƒ‚ๆผซๅฅณ็ซฅ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longpaopao_v3`,name:`้พ™ๆณกๆณก`,desc:`้ฃžๅคฉๆณกๆณก้Ÿณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longjielidou_v3`,name:`้พ™ๆฐๅŠ›่ฑ†`,desc:`้˜ณๅ…‰้กฝ็šฎ็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longxian_v3`,name:`้พ™ไป™`,desc:`่ฑชๆ”พๅฏ็ˆฑๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longling_v3`,name:`้พ™้“ƒ`,desc:`็จšๆฐ”ๅ‘†ๆฟๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longshanshan_v3`,name:`้พ™้—ช้—ช`,desc:`ๆˆๅ‰งๅŒ–็ซฅๅฃฐ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longniuniu_v3`,name:`้พ™็‰›็‰›`,desc:`้˜ณๅ…‰็”ท็ซฅๅฃฐ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longjiaxin_v3`,name:`้พ™ๅ˜‰ๆฌฃ`,desc:`ไผ˜้›…็ฒค่ฏญๅฅณ`,lang:`็ฒค่ฏญ/่‹ฑๆ–‡`},{voice:`longjiayi_v3`,name:`้พ™ๅ˜‰ๆ€ก`,desc:`็Ÿฅๆ€ง็ฒค่ฏญๅฅณ`,lang:`็ฒค่ฏญ/่‹ฑๆ–‡`},{voice:`longanyue_v3`,name:`้พ™ๅฎ‰็ฒค`,desc:`ๆฌข่„ฑ็ฒค่ฏญ็”ท`,lang:`็ฒค่ฏญ/่‹ฑๆ–‡`},{voice:`longlaotie_v3`,name:`้พ™่€้“`,desc:`ไธœๅŒ—็›ด็އ็”ท`,lang:`ไธœๅŒ—่ฏ/่‹ฑๆ–‡`},{voice:`longshange_v3`,name:`้พ™้™•ๅ“ฅ`,desc:`ๅŽŸๅ‘ณ้™•ๅŒ—็”ท`,lang:`้™•่ฅฟ่ฏ/่‹ฑๆ–‡`},{voice:`longanmin_v3`,name:`้พ™ๅฎ‰้—ฝ`,desc:`ๆธ…็บฏ่่މๅฅณ`,lang:`้—ฝๅ—่ฏ/่‹ฑๆ–‡`},{voice:`loongabby_v3`,name:`loongabby`,desc:`็พŽๅผ่‹ฑๆ–‡ๅฅณ`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongandy_v3`,name:`loongandy`,desc:`็พŽๅผ่‹ฑๆ–‡็”ท`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongannie_v3`,name:`loongannie`,desc:`็พŽๅผ่‹ฑๆ–‡ๅฅณ`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongava_v3`,name:`loongava`,desc:`็พŽๅผ่‹ฑๆ–‡ๅฅณ`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongbeth_v3`,name:`loongbeth`,desc:`็พŽๅผ่‹ฑๆ–‡ๅฅณ`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongbetty_v3`,name:`loongbetty`,desc:`็พŽๅผ่‹ฑๆ–‡ๅฅณ`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongcally_v3`,name:`loongcally`,desc:`็พŽๅผ่‹ฑๆ–‡ๅฅณ`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongcindy_v3`,name:`loongcindy`,desc:`็พŽๅผ่‹ฑๆ–‡ๅฅณ`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongdavid_v3`,name:`loongdavid`,desc:`็พŽๅผ่‹ฑๆ–‡็”ท`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongdonna_v3`,name:`loongdonna`,desc:`็พŽๅผ่‹ฑๆ–‡ๅฅณ`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongemily_v3`,name:`loongemily`,desc:`่‹ฑๅผ่‹ฑๆ–‡ๅฅณ`,lang:`่‹ฑๅผ่‹ฑ่ฏญ`},{voice:`loongeric_v3`,name:`loongeric`,desc:`่‹ฑๅผ่‹ฑๆ–‡็”ท`,lang:`่‹ฑๅผ่‹ฑ่ฏญ`},{voice:`loongluna_v3`,name:`loongluna`,desc:`่‹ฑๅผ่‹ฑๆ–‡ๅฅณ`,lang:`่‹ฑๅผ่‹ฑ่ฏญ`},{voice:`loongluca_v3`,name:`loongluca`,desc:`่‹ฑๅผ่‹ฑๆ–‡็”ท`,lang:`่‹ฑๅผ่‹ฑ่ฏญ`},{voice:`loongriko_v3`,name:`Riko`,desc:`ไบŒๆฌกๅ…ƒ้œ“่™นๅฅณ`,lang:`ๆ—ฅ่ฏญ`},{voice:`loongtomoka_v3`,name:`loongtomoka`,desc:`ๆ—ฅ่ฏญๅฅณ`,lang:`ๆ—ฅ่ฏญ`},{voice:`loongtomoya_v3`,name:`loongtomoya`,desc:`ๆ—ฅ่ฏญ็”ท`,lang:`ๆ—ฅ่ฏญ`},{voice:`loongyuuna_v3`,name:`Yuuna`,desc:`ๆ—ฅ่ฏญๅฅณ`,lang:`ๆ—ฅ่ฏญ`},{voice:`loongyuuma_v3`,name:`Yuuma`,desc:`ๆ—ฅ่ฏญ็”ท`,lang:`ๆ—ฅ่ฏญ`},{voice:`loongkyong_v3`,name:`loongkyong`,desc:`้Ÿฉ่ฏญๅฅณ`,lang:`้Ÿฉ่ฏญ`},{voice:`loongjihun_v3`,name:`Jihun`,desc:`้Ÿฉ่ฏญ็”ท`,lang:`้Ÿฉ่ฏญ`},{voice:`loongindah_v3`,name:`loongindah`,desc:`ๅฐๅฐผๅฅณ`,lang:`ๅฐๅฐผ่ฏญ`}],Ra={"cosyvoice-v3-flash":La,"cosyvoice-v3-plus":La,"cosyvoice-v3.5-flash":[],"cosyvoice-v3.5-plus":[],"cosyvoice-v2":[]},za=l({name:`speech synthesize`,description:`Synthesize speech from text (CosyVoice TTS)`,apiDocs:`/developer-reference/cosyvoice`,usage:`bl speech synthesize --text <text> [flags]`,options:[{flag:`--text <text>`,description:`Text to synthesize into speech`,required:!0},{flag:`--text-file <path>`,description:`Read text from a file instead of --text`},{flag:`--model <model>`,description:`Model ID (default: cosyvoice-v3-flash). System voices available for cosyvoice-v3-flash`},{flag:`--voice <voice>`,description:`Voice ID. Use --list-voices to see system voices for cosyvoice-v3-flash; for v3.5-flash provide a clone/design voice ID`},{flag:`--list-voices`,description:`List available system voices for the selected model and exit`},{flag:`--format <format>`,description:`Audio format: mp3, pcm, wav, opus (default: mp3)`},{flag:`--sample-rate <rate>`,description:`Audio sample rate in Hz (e.g. 24000)`},{flag:`--volume <volume>`,description:`Volume 0-100 (default: 50)`},{flag:`--rate <rate>`,description:`Speech rate 0.5-2.0 (default: 1.0)`},{flag:`--pitch <pitch>`,description:`Pitch multiplier 0.5-2.0 (default: 1.0)`},{flag:`--seed <seed>`,description:`Random seed 0-65535 for reproducible synthesis`},{flag:`--language <lang>`,description:`Language hint (e.g. zh, en, ja, ko, fr, de)`},{flag:`--instruction <text>`,description:`Natural language instruction to control speech style (e.g. "่ฏท็”จๆธฉๆŸ”็š„่ฏญ่ฐƒ"๏ผ‰`},{flag:`--enable-ssml`,description:`Enable SSML markup parsing in input text`},{flag:`--out <path>`,description:`Save audio to file (default: auto-generate in temp dir)`},{flag:`--stream`,description:`Stream raw PCM audio to stdout (pipe to player)`}],examples:[`bl speech synthesize --list-voices --model cosyvoice-v3-flash`,`bl speech synthesize --text "ไฝ ๅฅฝ๏ผŒๆˆ‘ๆ˜ฏๅƒ้—ฎ" --voice <voice_id>`,`bl speech synthesize --text "Hello world" --voice <voice_id> --language en`,`bl speech synthesize --text-file script.txt --out speech.wav --voice <voice_id>`,`bl speech synthesize --text "ไปŠๅคฉๅคฉๆฐ”็œŸๅฅฝ" --voice <voice_id> --instruction "่ฏท็”จๆธฉๆŸ”็š„่ฏญ่ฐƒ่ฏด่ฏ"`,`bl speech synthesize --text "Hello" --voice <voice_id> --format wav --sample-rate 24000`,`# Stream to audio player (macOS)`,`bl speech synthesize --text "ไฝ ๅฅฝ" --voice <voice_id> --stream | afplay -`,`# Pipe to ffplay`,`bl speech synthesize --text "Hello" --voice <voice_id> --stream | ffplay -nodisp -autoexit -f s16le -ar 24000 -ac 1 -`],async run(t,r){let i=r.model||t.defaultSpeechModel||`cosyvoice-v3-flash`;if(r.listVoices){Na(i);return}let a=r.text;if(!a&&r.textFile){let t=r.textFile;try{a=De(t,`utf-8`).trim()}catch{throw new e(`Cannot read text file: ${t}`,n.USAGE)}}if(!a)if(v({nonInteractive:t.nonInteractive})){let e=await K({message:`Enter text to synthesize:`});e||(process.stderr.write(`Speech synthesis cancelled.
152
- `),process.exit(1)),a=e}else q(`text`,`bl speech synthesize --text <text>`);let o=r.voice||void 0;if(!o)if(v({nonInteractive:t.nonInteractive})){let e=Ra[i];if(e&&e.length>0){let t=e[0].voice,n=e.map(e=>({value:e.voice,label:`${e.name} (${e.voice})`,hint:`${e.desc} ยท ${e.lang}`})),r=await gr({message:`Select a voice (default: ${t}):`,choices:n,defaultValue:t});r||(process.stderr.write(`Speech synthesis cancelled.
147
+ or config: bl config set access_key_id <key>`,r.AUTH);if(!c)throw new e(`Knowledge retrieve requires a workspace ID.
148
+ Set via: --workspace-id flag, or env: BAILIAN_WORKSPACE_ID, or config: bl config set workspace_id <id>`,r.USAGE);let l={IndexId:i,Query:a};n.topK!==void 0&&(l.TopK=n.topK),n.rerank&&(l.Rerank=!0),n.rerankTopN!==void 0&&(l.RerankTopN=n.rerankTopN);let u=d(t.output),f=`/${c}/index/retrieve`;if(t.dryRun){M({endpoint:`https://${Ra}${f}`,workspaceId:c,request:l},u);return}let p=JSON.stringify(l),m=le({accessKeyId:o,accessKeySecret:s,action:`Retrieve`,version:`2023-12-29`,body:p,host:Ra,pathname:f}),h=`https://${Ra}${f}`;t.verbose&&(process.stderr.write(`> POST ${h}\n`),process.stderr.write(`> AK: ${o.slice(0,8)}...\n`));let g=t.timeout*1e3,_=await fetch(h,{method:`POST`,headers:{...m,...me()},body:p,signal:AbortSignal.timeout(g)});t.verbose&&process.stderr.write(`< ${_.status} ${_.statusText}\n`);let v=await _.json();if(!_.ok||v.Code&&v.Code!==`Success`)throw new e(`Knowledge retrieve failed: ${v.Code||_.status} - ${v.Message||_.statusText}`,r.GENERAL);if(t.quiet||u===`text`){let e=v.Data?.Nodes||[];if(e.length===0)N(`No results found.`);else for(let t=0;t<e.length;t++){let n=e[t];N(`[${t+1}] (score: ${n.Score.toFixed(4)})`),N(n.Text),N(``)}}else M(v,u)}})})),Va,Ha=j((()=>{oi(),J(),P(),Va=u({name:`search web`,description:`Search the web using DashScope MCP WebSearch service`,usage:`bl search web --query <text> [flags]`,options:[{flag:`--query <text>`,description:`Search query text`,required:!0},{flag:`--count <n>`,description:`Number of search results (default: 10)`,type:`number`},{flag:`--list-tools`,description:`List available MCP tools and exit`}],examples:[`bl search web --query "้˜ฟ้‡Œไบ‘็™พ็‚ผๆœ€ๆ–ฐๅŠŸ่ƒฝ"`,`bl search web --query "TypeScript 5.9 new features" --count 5`,`bl search web --query "ไปŠๆ—ฅๆ–ฐ้—ป"`,`bl search web --list-tools`],async run(e,t){let n=ee(e.baseUrl),r=d(e.output);if(t.listTools){if(e.dryRun){M({endpoint:n,action:`tools/list`},r);return}let t=new a(e,n);await t.initialize(),M({tools:await t.listTools()},r);return}let i=t.query;if(!i)if(b({nonInteractive:e.nonInteractive})){let e=await K({message:`Enter your search query:`});e||(process.stderr.write(`Search cancelled.
149
+ `),process.exit(1)),i=e}else q(`query`,`bl search web --query <text>`);if(e.dryRun){M({endpoint:n,action:`tools/call`,tool:`bailian_web_search`,arguments:{query:i,count:t.count||void 0}},r);return}let o=new a(e,n),s=ri(`Initializing search...`);e.quiet||s.start();try{await o.initialize(),e.quiet||s.update(`Searching...`);let n={query:i};t.count&&(n.count=t.count);let a=await o.callTool(`bailian_web_search`,n);if(e.quiet||s.stop(`Done.`),a.isError){let e=a.content.map(e=>e.text||``).join(`
150
+ `);process.stderr.write(`Search error: ${e}\n`),process.exit(1)}if(r===`json`)M(a,r);else for(let e of a.content)if(e.type===`text`&&e.text)try{let t=JSON.parse(e.text);t.pages&&Array.isArray(t.pages)?M({pages:t.pages,total:t.pages.length},r):M(t,r)}catch{M({text:e.text},r)}}catch(e){throw s.stop(`Failed.`),e}}})}));function Ua(e){let t=Ja[e];if(!t){process.stdout.write(`No built-in voice list available for model: ${e}\n`);return}if(t.length===0){process.stdout.write(`Model ${e} has no system voices.\n`),process.stdout.write(`Use clone or design voices created via the CosyVoice API.
151
+ `),process.stdout.write(`See: ${Ka}\n`);return}let n=(e,t)=>e.padEnd(t);process.stdout.write(`\nSystem voices for ${e}:\n`),process.stdout.write(`${n(`VOICE ID`,26)} ${n(`NAME`,10)} ${n(`DESCRIPTION`,16)} LANGUAGE\n`),process.stdout.write(`${`-`.repeat(26)} ${`-`.repeat(10)} ${`-`.repeat(16)} ${`-`.repeat(12)}\n`);for(let e of t)process.stdout.write(`${n(e.voice,26)} ${n(e.name,10)} ${n(e.desc,16)} ${e.lang}\n`);process.stdout.write(`\nTotal: ${t.length} voices\n`)}async function Wa(t,n,i,a,o){let s=await di(ui(a),t,()=>T(t,{url:n,method:`POST`,body:i})),c=s.map(e=>e.output?.audio?.url).filter(Boolean);if(c.length===0)throw new e(`API returned no audio URL.`,r.GENERAL);let l=await import(`path`),u=O(t,{subDir:`speech`}),d=await fi(c.map((e,t)=>{let n=a.out;if(!(n&&c.length===1)){let e=Date.now(),r=c.length>1?`_${String(t+1).padStart(3,`0`)}`:``,a=i.input.format??`mp3`;n=l.join(u,`tts_${e}${r}.${a}`)}return{url:e,destPath:n}}),Y,{quiet:t.quiet});if(t.quiet)N(d.join(`
152
+ `));else if(d.length===1){let e=s[0].output?.audio?.expires_at;M({saved:d[0],audio_url:c[0],model:i.model,voice:i.input.voice,...e?{url_expires_at:e}:{}},o)}else M({saved:d,audio_urls:c,total:d.length,model:i.model,voice:i.input.voice},o)}async function Ga(e,t,n,r,i){let a=await se(e,{url:t,method:`POST`,body:n,stream:!0,headers:{Accept:`text/event-stream`,"X-DashScope-SSE":`enable`}}),o=r.out,s=o?De(o):null,c;try{for await(let t of ae(a)){if(!t.data||t.data===`[DONE]`)continue;let n;try{n=JSON.parse(t.data)}catch{continue}let r=n.output?.audio?.data;if(r){let e=Buffer.from(r,`base64`);s?s.write(e)||await new Promise(e=>s.once(`drain`,()=>e())):process.stdout.write(e)}if(n.output?.finish_reason===`stop`){c=n.output?.audio?.url,c&&!e.quiet&&process.stderr.write(`\nFull audio URL: ${c}\n`);break}}}finally{s&&(await new Promise((e,t)=>{s.on(`finish`,e),s.on(`error`,t),s.end()}),!e.quiet&&o&&process.stderr.write(`Saved: ${o}\n`))}o&&M({saved:o,...c?{audio_url:c}:{},model:n.model,voice:n.input.voice},i)}var Ka,qa,Ja,Ya,Xa=j((()=>{X(),pi(),J(),P(),Ka=`${n.cn}/cosyvoice-clone-design-api`,qa=[{voice:`longanyang`,name:`้พ™ๅฎ‰ๆด‹`,desc:`้˜ณๅ…‰ๅคง็”ทๅญฉ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longanhuan`,name:`้พ™ๅฎ‰ๆฌข`,desc:`ๆฌข่„ฑๅ…ƒๆฐ”ๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longantai_v3`,name:`้พ™ๅฎ‰ๅฐ`,desc:`ๅ—ฒ็”œๅฐๆนพๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longhua_v3`,name:`้พ™ๅŽ`,desc:`ๅ…ƒๆฐ”็”œ็พŽๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longcheng_v3`,name:`้พ™ๆฉ™`,desc:`ๆ™บๆ…ง้’ๅนด็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longze_v3`,name:`้พ™ๆณฝ`,desc:`ๆธฉๆš–ๅ…ƒๆฐ”็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longzhe_v3`,name:`้พ™ๅ“ฒ`,desc:`ๅ‘†ๆฟๅคงๆš–็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longyan_v3`,name:`้พ™้ขœ`,desc:`ๆธฉๆš–ๆ˜ฅ้ฃŽๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longxing_v3`,name:`้พ™ๆ˜Ÿ`,desc:`ๆธฉๅฉ‰้‚ปๅฎถๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longtian_v3`,name:`้พ™ๅคฉ`,desc:`็ฃๆ€ง็†ๆ™บ็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longwan_v3`,name:`้พ™ๅฉ‰`,desc:`็ป†่…ปๆŸ”ๅฃฐๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longqiang_v3`,name:`้พ™ๅซฑ`,desc:`ๆตชๆผซ้ฃŽๆƒ…ๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longfeifei_v3`,name:`้พ™่ฒ่ฒ`,desc:`็”œ็พŽๅจ‡ๆฐ”ๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longhao_v3`,name:`้พ™ๆตฉ`,desc:`ๅคšๆƒ…ๅฟง้ƒ็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longanrou_v3`,name:`้พ™ๅฎ‰ๆŸ”`,desc:`ๆธฉๆŸ”ๅจด้™ๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longxiaochun_v3`,name:`้พ™ๅฐๆทณ`,desc:`็Ÿฅๆ€ง็งฏๆžๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longxiaoxia_v3`,name:`้พ™ๅฐๅค`,desc:`ๆฒ‰็จณๆƒๅจๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longyumi_v3`,name:`YUMI`,desc:`ๆญฃ็ป้’ๅนดๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longanyun_v3`,name:`้พ™ๅฎ‰ๆ˜€`,desc:`ๅฑ…ๅฎถๆš–็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longanwen_v3`,name:`้พ™ๅฎ‰ๆธฉ`,desc:`ไผ˜้›…็Ÿฅๆ€งๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longanli_v3`,name:`้พ™ๅฎ‰่މ`,desc:`ๅˆฉ่ฝไปŽๅฎนๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longanlang_v3`,name:`้พ™ๅฎ‰ๆœ—`,desc:`ๆธ…็ˆฝๅˆฉ่ฝ็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longyingmu_v3`,name:`้พ™ๅบ”ๆฒ`,desc:`ไผ˜้›…็Ÿฅๆ€งๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longyingxun_v3`,name:`้พ™ๅบ”่ฏข`,desc:`ๅนด่ฝป้’ๆถฉ็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longyingjing_v3`,name:`้พ™ๅบ”้™`,desc:`ไฝŽ่ฐƒๅ†ท้™ๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longyingling_v3`,name:`้พ™ๅบ”่†`,desc:`ๆธฉๅ’Œๅ…ฑๆƒ…ๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longyingtao_v3`,name:`้พ™ๅบ”ๆกƒ`,desc:`ๆธฉๆŸ”ๆทกๅฎšๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longyingxiao_v3`,name:`้พ™ๅบ”็ฌ‘`,desc:`ๆธ…็”œๆŽจ้”€ๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longfei_v3`,name:`้พ™้ฃž`,desc:`็ƒญ่ก€็ฃๆ€ง็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longhuhu_v3`,name:`้พ™ๅ‘ผๅ‘ผ`,desc:`ๅคฉ็œŸ็ƒ‚ๆผซๅฅณ็ซฅ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longpaopao_v3`,name:`้พ™ๆณกๆณก`,desc:`้ฃžๅคฉๆณกๆณก้Ÿณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longjielidou_v3`,name:`้พ™ๆฐๅŠ›่ฑ†`,desc:`้˜ณๅ…‰้กฝ็šฎ็”ท`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longxian_v3`,name:`้พ™ไป™`,desc:`่ฑชๆ”พๅฏ็ˆฑๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longling_v3`,name:`้พ™้“ƒ`,desc:`็จšๆฐ”ๅ‘†ๆฟๅฅณ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longshanshan_v3`,name:`้พ™้—ช้—ช`,desc:`ๆˆๅ‰งๅŒ–็ซฅๅฃฐ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longniuniu_v3`,name:`้พ™็‰›็‰›`,desc:`้˜ณๅ…‰็”ท็ซฅๅฃฐ`,lang:`ไธญๆ–‡/่‹ฑๆ–‡`},{voice:`longjiaxin_v3`,name:`้พ™ๅ˜‰ๆฌฃ`,desc:`ไผ˜้›…็ฒค่ฏญๅฅณ`,lang:`็ฒค่ฏญ/่‹ฑๆ–‡`},{voice:`longjiayi_v3`,name:`้พ™ๅ˜‰ๆ€ก`,desc:`็Ÿฅๆ€ง็ฒค่ฏญๅฅณ`,lang:`็ฒค่ฏญ/่‹ฑๆ–‡`},{voice:`longanyue_v3`,name:`้พ™ๅฎ‰็ฒค`,desc:`ๆฌข่„ฑ็ฒค่ฏญ็”ท`,lang:`็ฒค่ฏญ/่‹ฑๆ–‡`},{voice:`longlaotie_v3`,name:`้พ™่€้“`,desc:`ไธœๅŒ—็›ด็އ็”ท`,lang:`ไธœๅŒ—่ฏ/่‹ฑๆ–‡`},{voice:`longshange_v3`,name:`้พ™้™•ๅ“ฅ`,desc:`ๅŽŸๅ‘ณ้™•ๅŒ—็”ท`,lang:`้™•่ฅฟ่ฏ/่‹ฑๆ–‡`},{voice:`longanmin_v3`,name:`้พ™ๅฎ‰้—ฝ`,desc:`ๆธ…็บฏ่่މๅฅณ`,lang:`้—ฝๅ—่ฏ/่‹ฑๆ–‡`},{voice:`loongabby_v3`,name:`loongabby`,desc:`็พŽๅผ่‹ฑๆ–‡ๅฅณ`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongandy_v3`,name:`loongandy`,desc:`็พŽๅผ่‹ฑๆ–‡็”ท`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongannie_v3`,name:`loongannie`,desc:`็พŽๅผ่‹ฑๆ–‡ๅฅณ`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongava_v3`,name:`loongava`,desc:`็พŽๅผ่‹ฑๆ–‡ๅฅณ`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongbeth_v3`,name:`loongbeth`,desc:`็พŽๅผ่‹ฑๆ–‡ๅฅณ`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongbetty_v3`,name:`loongbetty`,desc:`็พŽๅผ่‹ฑๆ–‡ๅฅณ`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongcally_v3`,name:`loongcally`,desc:`็พŽๅผ่‹ฑๆ–‡ๅฅณ`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongcindy_v3`,name:`loongcindy`,desc:`็พŽๅผ่‹ฑๆ–‡ๅฅณ`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongdavid_v3`,name:`loongdavid`,desc:`็พŽๅผ่‹ฑๆ–‡็”ท`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongdonna_v3`,name:`loongdonna`,desc:`็พŽๅผ่‹ฑๆ–‡ๅฅณ`,lang:`็พŽๅผ่‹ฑ่ฏญ`},{voice:`loongemily_v3`,name:`loongemily`,desc:`่‹ฑๅผ่‹ฑๆ–‡ๅฅณ`,lang:`่‹ฑๅผ่‹ฑ่ฏญ`},{voice:`loongeric_v3`,name:`loongeric`,desc:`่‹ฑๅผ่‹ฑๆ–‡็”ท`,lang:`่‹ฑๅผ่‹ฑ่ฏญ`},{voice:`loongluna_v3`,name:`loongluna`,desc:`่‹ฑๅผ่‹ฑๆ–‡ๅฅณ`,lang:`่‹ฑๅผ่‹ฑ่ฏญ`},{voice:`loongluca_v3`,name:`loongluca`,desc:`่‹ฑๅผ่‹ฑๆ–‡็”ท`,lang:`่‹ฑๅผ่‹ฑ่ฏญ`},{voice:`loongriko_v3`,name:`Riko`,desc:`ไบŒๆฌกๅ…ƒ้œ“่™นๅฅณ`,lang:`ๆ—ฅ่ฏญ`},{voice:`loongtomoka_v3`,name:`loongtomoka`,desc:`ๆ—ฅ่ฏญๅฅณ`,lang:`ๆ—ฅ่ฏญ`},{voice:`loongtomoya_v3`,name:`loongtomoya`,desc:`ๆ—ฅ่ฏญ็”ท`,lang:`ๆ—ฅ่ฏญ`},{voice:`loongyuuna_v3`,name:`Yuuna`,desc:`ๆ—ฅ่ฏญๅฅณ`,lang:`ๆ—ฅ่ฏญ`},{voice:`loongyuuma_v3`,name:`Yuuma`,desc:`ๆ—ฅ่ฏญ็”ท`,lang:`ๆ—ฅ่ฏญ`},{voice:`loongkyong_v3`,name:`loongkyong`,desc:`้Ÿฉ่ฏญๅฅณ`,lang:`้Ÿฉ่ฏญ`},{voice:`loongjihun_v3`,name:`Jihun`,desc:`้Ÿฉ่ฏญ็”ท`,lang:`้Ÿฉ่ฏญ`},{voice:`loongindah_v3`,name:`loongindah`,desc:`ๅฐๅฐผๅฅณ`,lang:`ๅฐๅฐผ่ฏญ`}],Ja={"cosyvoice-v3-flash":qa,"cosyvoice-v3-plus":qa,"cosyvoice-v3.5-flash":[],"cosyvoice-v3.5-plus":[],"cosyvoice-v2":[]},Ya=u({name:`speech synthesize`,description:`Synthesize speech from text (CosyVoice TTS)`,apiDocs:`/developer-reference/cosyvoice`,usage:`bl speech synthesize --text <text> [flags]`,options:[{flag:`--text <text>`,description:`Text to synthesize into speech`,required:!0},{flag:`--text-file <path>`,description:`Read text from a file instead of --text`},{flag:`--model <model>`,description:`Model ID (default: cosyvoice-v3-flash). System voices available for cosyvoice-v3-flash`},{flag:`--voice <voice>`,description:`Voice ID. Use --list-voices to see system voices for cosyvoice-v3-flash; for v3.5-flash provide a clone/design voice ID`},{flag:`--list-voices`,description:`List available system voices for the selected model and exit`},{flag:`--format <format>`,description:`Audio format: mp3, pcm, wav, opus (default: mp3)`},{flag:`--sample-rate <rate>`,description:`Audio sample rate in Hz (e.g. 24000)`},{flag:`--volume <volume>`,description:`Volume 0-100 (default: 50)`},{flag:`--rate <rate>`,description:`Speech rate 0.5-2.0 (default: 1.0)`},{flag:`--pitch <pitch>`,description:`Pitch multiplier 0.5-2.0 (default: 1.0)`},{flag:`--seed <seed>`,description:`Random seed 0-65535 for reproducible synthesis`},{flag:`--language <lang>`,description:`Language hint (e.g. zh, en, ja, ko, fr, de)`},{flag:`--instruction <text>`,description:`Natural language instruction to control speech style (e.g. "่ฏท็”จๆธฉๆŸ”็š„่ฏญ่ฐƒ"๏ผ‰`},{flag:`--enable-ssml`,description:`Enable SSML markup parsing in input text`},{flag:`--out <path>`,description:`Save audio to file (default: auto-generate in temp dir)`},{flag:`--stream`,description:`Stream raw PCM audio to stdout (pipe to player)`}],examples:[`bl speech synthesize --list-voices --model cosyvoice-v3-flash`,`bl speech synthesize --text "ไฝ ๅฅฝ๏ผŒๆˆ‘ๆ˜ฏๅƒ้—ฎ" --voice <voice_id>`,`bl speech synthesize --text "Hello world" --voice <voice_id> --language en`,`bl speech synthesize --text-file script.txt --out speech.wav --voice <voice_id>`,`bl speech synthesize --text "ไปŠๅคฉๅคฉๆฐ”็œŸๅฅฝ" --voice <voice_id> --instruction "่ฏท็”จๆธฉๆŸ”็š„่ฏญ่ฐƒ่ฏด่ฏ"`,`bl speech synthesize --text "Hello" --voice <voice_id> --format wav --sample-rate 24000`,`# Stream to audio player (macOS)`,`bl speech synthesize --text "ไฝ ๅฅฝ" --voice <voice_id> --stream | afplay -`,`# Pipe to ffplay`,`bl speech synthesize --text "Hello" --voice <voice_id> --stream | ffplay -nodisp -autoexit -f s16le -ar 24000 -ac 1 -`],async run(t,n){let i=n.model||t.defaultSpeechModel||`cosyvoice-v3-flash`;if(n.listVoices){Ua(i);return}let a=n.text;if(!a&&n.textFile){let t=n.textFile;try{a=Ae(t,`utf-8`).trim()}catch{throw new e(`Cannot read text file: ${t}`,r.USAGE)}}if(!a)if(b({nonInteractive:t.nonInteractive})){let e=await K({message:`Enter text to synthesize:`});e||(process.stderr.write(`Speech synthesis cancelled.
153
+ `),process.exit(1)),a=e}else q(`text`,`bl speech synthesize --text <text>`);let o=n.voice||void 0;if(!o)if(b({nonInteractive:t.nonInteractive})){let e=Ja[i];if(e&&e.length>0){let t=e[0].voice,n=e.map(e=>({value:e.voice,label:`${e.name} (${e.voice})`,hint:`${e.desc} ยท ${e.lang}`})),r=await yr({message:`Select a voice (default: ${t}):`,choices:n,defaultValue:t});r||(process.stderr.write(`Speech synthesis cancelled.
153
154
  `),process.exit(1)),o=r}else{let e=await K({message:`Enter voice ID (clone/design voice):`});e||(process.stderr.write(`Speech synthesis cancelled.
154
- `),process.exit(1)),o=e}}else{let t=Ra[i];throw t&&t.length>0?new e(`--voice is required.\nRun the following to see available voices:\n bl speech synthesize --list-voices --model ${i}`,n.USAGE):new e(`--voice is required. Model ${i} has no built-in system voices.\nCreate a clone or design voice first, then pass its ID via --voice <voice_id>.\nSee: ${Ia}`,n.USAGE)}let s=r.language||void 0,c=r.instruction||void 0,l=r.format||void 0,d=r.sampleRate===void 0?void 0:Number(r.sampleRate),f=r.volume===void 0?void 0:Number(r.volume),p=r.rate===void 0?void 0:Number(r.rate),m=r.pitch===void 0?void 0:Number(r.pitch),h=r.seed===void 0?void 0:Number(r.seed),g=r.enableSsml===!0?!0:void 0,_=r.stream===!0,y=u(t.output),b={model:i,input:{text:a,voice:o,format:l,sample_rate:d,volume:f,rate:p,pitch:m,seed:h,language_hints:s?[s]:void 0,instruction:c,enable_ssml:g}};if(le(b.input),t.dryRun){M({request:b},y);return}t.quiet||process.stderr.write(`[Model: ${i}] [Voice: ${o}]\n`);let x=ce(t.baseUrl);_?await Fa(t,x,b,r,y):await Pa(t,x,b,r,y)}})}));async function Va(t,r,i,a,o,s){let c=(await T(t,{url:r,method:`POST`,body:i,async:!0})).output.task_id;if(a.noWait||t.async){M({task_id:c},o);return}let l=a.pollInterval??2,u=await Zr(t,{url:k(t.baseUrl,c),intervalSec:l,timeoutSec:t.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>e.output.message}),d=u.output.results??[];if(d.length===0){M({task_id:c,status:u.output.task_status},o);return}let f=[];for(let t=0;t<d.length;t++){let r=d[t],i=s>1;if(i&&process.stdout.write(`=== [${t+1}/${d.length}] ${r.file_url??``} ===\n`),r.subtask_status===`FAILED`){let e=r.message??r.code??`unknown error`;process.stdout.write(`[FAILED] ${r.file_url??``} โ€” ${e}\n`),i&&process.stdout.write(`
155
- `);continue}if(!r.transcription_url){i&&process.stdout.write(`
156
- `);continue}let a=await fetch(r.transcription_url,{headers:de()});if(!a.ok)throw new e(`Failed to download transcription: HTTP ${a.status}`,n.GENERAL);let o=await a.json();f.push(o);let c=o.transcripts;if(c&&c.length>0)for(let e of c)if(e.sentences&&e.sentences.length>0)for(let t of e.sentences){let e=t.speaker_id===void 0?``:` [Speaker ${t.speaker_id}]`;process.stdout.write(`${t.text}${e}\n`)}else e.text&&process.stdout.write(e.text+`
155
+ `),process.exit(1)),o=e}}else{let t=Ja[i];throw t&&t.length>0?new e(`--voice is required.\nRun the following to see available voices:\n bl speech synthesize --list-voices --model ${i}`,r.USAGE):new e(`--voice is required. Model ${i} has no built-in system voices.\nCreate a clone or design voice first, then pass its ID via --voice <voice_id>.\nSee: ${Ka}`,r.USAGE)}let s=n.language||void 0,c=n.instruction||void 0,l=n.format||void 0,u=n.sampleRate===void 0?void 0:Number(n.sampleRate),f=n.volume===void 0?void 0:Number(n.volume),p=n.rate===void 0?void 0:Number(n.rate),m=n.pitch===void 0?void 0:Number(n.pitch),h=n.seed===void 0?void 0:Number(n.seed),g=n.enableSsml===!0?!0:void 0,_=n.stream===!0,v=d(t.output),y={model:i,input:{text:a,voice:o,format:l,sample_rate:u,volume:f,rate:p,pitch:m,seed:h,language_hints:s?[s]:void 0,instruction:c,enable_ssml:g}};if(fe(y.input),t.dryRun){M({request:y},v);return}t.quiet||process.stderr.write(`[Model: ${i}] [Voice: ${o}]\n`);let x=de(t.baseUrl);_?await Ga(t,x,y,n,v):await Wa(t,x,y,n,v)}})}));async function Za(t,n,i,a,o,s){let c=(await T(t,{url:n,method:`POST`,body:i,async:!0})).output.task_id;if(a.noWait||t.async){M({task_id:c},o);return}let l=a.pollInterval??2,u=await si(t,{url:k(t.baseUrl,c),intervalSec:l,timeoutSec:t.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>e.output.message}),d=u.output.results??[];if(d.length===0){M({task_id:c,status:u.output.task_status},o);return}let f=[];for(let t=0;t<d.length;t++){let n=d[t],i=s>1;if(i&&process.stdout.write(`=== [${t+1}/${d.length}] ${n.file_url??``} ===\n`),n.subtask_status===`FAILED`){let e=n.message??n.code??`unknown error`;process.stdout.write(`[FAILED] ${n.file_url??``} โ€” ${e}\n`),i&&process.stdout.write(`
156
+ `);continue}if(!n.transcription_url){i&&process.stdout.write(`
157
+ `);continue}let a=await fetch(n.transcription_url,{headers:me()});if(!a.ok)throw new e(`Failed to download transcription: HTTP ${a.status}`,r.GENERAL);let o=await a.json();f.push(o);let c=o.transcripts;if(c&&c.length>0)for(let e of c)if(e.sentences&&e.sentences.length>0)for(let t of e.sentences){let e=t.speaker_id===void 0?``:` [Speaker ${t.speaker_id}]`;process.stdout.write(`${t.text}${e}\n`)}else e.text&&process.stdout.write(e.text+`
157
158
  `);else N(JSON.stringify(o));i&&process.stdout.write(`
158
- `)}if(a.out){let e=a.out,n=f.length===1?f[0]:f;ke(e,JSON.stringify(n,null,2)+`
159
- `),t.quiet||process.stderr.write(`Full result saved to: ${e}\n`)}}var Ha,Ua=j((()=>{Qr(),J(),P(),Ha=l({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(t,r){let i=[];Array.isArray(r.url)?i=r.url:typeof r.url==`string`&&(i=[r.url]),i.length===0&&q(`url`,`bl speech recognize --url <audio-url>`);let a=r.speakerCount,o=r.diarization===!0;if(a!==void 0&&!o)throw new e(`--speaker-count requires --diarization to be enabled.
160
- Hint: Add --diarization flag to enable speaker separation.`,n.USAGE);let s=r.model||`fun-asr`,c=u(t.output),l=await E(t),d=await Promise.all(i.map(e=>D(e,l.token,s))),f=r.channelId,p=r.language,m=r.vocabularyId,h={model:s,input:{file_urls:d},parameters:{channel_id:f===void 0?[0]:[f],language_hints:p?[p]:void 0,diarization_enabled:o?!0:void 0,speaker_count:a,vocabulary_id:m}};if(le(h.parameters),t.dryRun){M({request:h,mode:`async`},c);return}t.quiet||process.stderr.write(`[Model: ${s}] [Mode: async] [Files: ${d.length}]\n`),await Va(t,se(t.baseUrl),h,r,c,d.length)}})})),Wa,Ga=j((()=>{J(),P(),Wa=l({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 qwen-vl-max`,`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||q(`file`,`bl file upload --file <path> --model <model>`);let r=t.model;r||q(`model`,`bl file upload --file <path> --model <model>`);let i=u(e.output);if(e.dryRun){M({action:`upload`,file:n,model:r},i);return}let a=await fe({apiKey:(await E(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)}})}));function Ka(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}K`:String(e)}var qa,Ja,Ya=j((()=>{P(),qa=`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,Ja=l({name:`model list`,description:`List available foundation models`,usage:`bl model list [flags]`,options:[{flag:`--name <name>`,description:`Filter by model name (keyword search)`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--page-size <n>`,description:`Results per page (default: 50)`,type:`number`},{flag:`--provider <name>`,description:`Filter by model provider (repeatable)`,type:`array`},{flag:`--capability <name>`,description:`Filter by capability (repeatable)`,type:`array`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl model list`,`bl model list --name qwen`,`bl model list --page-size 20`,`bl model list --output json`],async run(e,t){let n=t.name||``,r=t.page||1,i=t.pageSize||50,a=t.provider||[],s=t.capability||[],c=t.region||`cn-beijing`,l=u(t.output||`yaml`),d=await E(e),f={input:{pageNo:r,pageSize:i,name:n,providers:a,inferenceProviders:[],features:[],group:!0,capabilities:s,contextWindows:[]}};if(e.dryRun){M({api:qa,data:f,region:c,token:d.token.slice(0,8)+`...`},l);return}let p=await o(e,d.token,{api:qa,data:f,region:c}),m=p?.data?.DataV2?.data??p?.data??{},h=m?.data?.list??m?.list??[],g=[];for(let e of h)if(e.items?.length)for(let t of e.items)g.push(t);else g.push(e);if(l!==`text`){M({total:g.length,models:g},l);return}if(g.length===0){N(`No models found.`);return}N(`Found ${g.length} model(s):\n`);let _=Math.max(...g.map(e=>(e.model??``).length),10);for(let e of g){let t=e.model??`unknown`,n=e.name??``,r=[e.provider??``,e.contextWindow?`ctx:${Ka(e.contextWindow)}`:``,e.capabilities?.length?e.capabilities.join(`, `):``].filter(Boolean).join(` | `),i=r?` (${r})`:``,a=n&&n!==t?` ${n}`:``;N(` ${t.padEnd(_)}${a}${i}`)}}})})),Xa,Za=j((()=>{J(),P(),Xa=l({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,t){let n=t.api;n||q(`api`,`bl console call --api <api> --data <json>`);let r=t.data;r||q(`data`,`bl console call --api <api> --data <json>`);let i;try{i=JSON.parse(r)}catch{process.stderr.write(`Error: --data must be valid JSON
161
- `),process.exit(1)}let a=t.region||`cn-beijing`,s=u(e.output),c=await E(e);if(e.dryRun){M({api:n,data:i,region:a,token:c.token.slice(0,8)+`...`},s);return}M(await o(e,c.token,{api:n,data:i,region:a}),s)}})})),Qa,$a,eo=j((()=>{J(),P(),Qa=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota`,$a=l({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||q(`model`,`bl usage free --model <model>`);let r=t.region||`cn-beijing`,i=u(t.output||`yaml`),a=await E(e),s={queryFreeTierQuotaRequest:{models:[n]}};if(e.dryRun){M({api:Qa,data:s,region:r,token:a.token.slice(0,8)+`...`},i);return}M(await o(e,a.token,{api:Qa,data:s,region:r}),i)}})})),to=He({commands:()=>no}),no,ro=j((()=>{ca(),ua(),pa(),ha(),_a(),ya(),xa(),Ca(),Ta(),Da(),Aa(),Ma(),Ba(),Ua(),Ga(),Ya(),Za(),eo(),no={"auth login":Nr,"auth status":Fr,"auth logout":Rr,"text chat":Vr,omni:Gr,"image generate":fi,"image edit":gi,"video generate":bi,"video edit":Si,"video ref":wi,"video task get":Ei,"video download":Oi,"vision describe":Pi,"app call":la,"app list":fa,"memory add":ma,"memory search":ga,"memory list":va,"memory update":ba,"memory delete":Sa,"memory profile create":wa,"memory profile get":Ea,"knowledge retrieve":ka,"search web":ja,"speech synthesize":za,"speech recognize":Ha,"file upload":Wa,"model list":Ja,"console call":Xa,"usage free":$a,"config show":Ii,"config set":Bi,"config export-schema":Ui,update:sa}}));ro();const io=new class{root={children:new Map};constructor(e){for(let[t,n]of Object.entries(e))this.register(t,n)}register(e,t){let n=e.split(` `),r=this.root;for(let e of n)r.children.has(e)||r.children.set(e,{children:new Map}),r=r.children.get(e);r.command=t}getAllCommands(){let e=[],t=n=>{n.command&&e.push(n.command);for(let e of n.children.values())t(e)};return t(this.root),e}isGroupPath(e){let t=this.root;for(let n of e){let e=t.children.get(n);if(!e)return!1;t=e}return!t.command&&t.children.size>0}resolve(t){let r=this.root,i=[];for(let e of t){let t=r.children.get(e);if(!t)break;r=t,i.push(e)}if(r.command)return{command:r.command,extra:t.slice(i.length)};if(i.length>0&&r.children.size===1){let[,e]=r.children.entries().next().value;if(e.command)return{command:e.command,extra:t.slice(i.length)}}if(i.length>0&&r.children.size>0){let a=Array.from(r.children.entries()).map(([e,t])=>{if(t.command)return` ${i.join(` `)} ${e} ${t.command.description}`;let n=Array.from(t.children.keys()).join(`, `);return` ${i.join(` `)} ${e} [${n}]`}).join(`
162
- `);throw new e(`Unknown command: bl ${t.join(` `)}\n\nAvailable commands:\n${a}`,n.USAGE,`bl ${i.join(` `)} --help`)}throw new e(`Unknown command: bl ${t.join(` `)}`,n.USAGE,`bl --help`)}buildResourceLines(e,t){let n=[],r=(e,t)=>{for(let[i,a]of e.children){let e=t?`${t} ${i}`:i;a.command&&n.push({path:e,desc:a.command.description}),a.children.size>0&&r(a,e)}};r(this.root,``);let i=Math.max(...n.map(e=>e.path.length));return n.map(n=>` ${e(n.path.padEnd(i+2))} ${t(n.desc)}`).join(`
163
- `)}buildGlobalFlagLines(e,t){let n=Math.max(...r.map(e=>e.flag.length));return r.map(r=>` ${e(r.flag.padEnd(n+2))} ${t(r.description)}`).join(`
159
+ `)}if(a.out){let e=a.out,n=f.length===1?f[0]:f;Me(e,JSON.stringify(n,null,2)+`
160
+ `),t.quiet||process.stderr.write(`Full result saved to: ${e}\n`)}}var Qa,$a=j((()=>{ci(),J(),P(),Qa=u({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(t,n){let i=[];Array.isArray(n.url)?i=n.url:typeof n.url==`string`&&(i=[n.url]),i.length===0&&q(`url`,`bl speech recognize --url <audio-url>`);let a=n.speakerCount,o=n.diarization===!0;if(a!==void 0&&!o)throw new e(`--speaker-count requires --diarization to be enabled.
161
+ Hint: Add --diarization flag to enable speaker separation.`,r.USAGE);let s=n.model||`fun-asr`,c=d(t.output),l=await E(t),u=await Promise.all(i.map(e=>D(e,l.token,s))),f=n.channelId,p=n.language,m=n.vocabularyId,h={model:s,input:{file_urls:u},parameters:{channel_id:f===void 0?[0]:[f],language_hints:p?[p]:void 0,diarization_enabled:o?!0:void 0,speaker_count:a,vocabulary_id:m}};if(fe(h.parameters),t.dryRun){M({request:h,mode:`async`},c);return}t.quiet||process.stderr.write(`[Model: ${s}] [Mode: async] [Files: ${u.length}]\n`),await Za(t,ue(t.baseUrl),h,n,c,u.length)}})})),eo,to=j((()=>{J(),P(),eo=u({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 qwen-vl-max`,`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||q(`file`,`bl file upload --file <path> --model <model>`);let r=t.model;r||q(`model`,`bl file upload --file <path> --model <model>`);let i=d(e.output);if(e.dryRun){M({action:`upload`,file:n,model:r},i);return}let a=await he({apiKey:(await E(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)}})})),no,ro,io=j((()=>{P(),no=`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,ro=u({name:`model list`,description:`List available foundation models`,usage:`bl model list [flags]`,options:[{flag:`--name <name>`,description:`Filter by model name (keyword search)`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--page-size <n>`,description:`Results per page (default: 50)`,type:`number`},{flag:`--provider <name>`,description:`Filter by model provider (repeatable)`,type:`array`},{flag:`--capability <name>`,description:`Filter by capability (repeatable)`,type:`array`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl model list`,`bl model list --name qwen`,`bl model list --page-size 20`,`bl model list --output json`],async run(e,t){let n=t.name||``,r=t.page||1,i=t.pageSize||50,a=t.provider||[],o=t.capability||[],c=t.region||`cn-beijing`,l=d(e.output),u=await ce(e),f={input:{pageNo:r,pageSize:i,name:n,providers:a,inferenceProviders:[],features:[],group:!0,capabilities:o,contextWindows:[]}};if(e.dryRun){M({api:no,data:f,region:c,token:u.token.slice(0,8)+`...`},l);return}let p=await s(e,u.token,{api:no,data:f,region:c}),m=p?.data?.DataV2?.data??p?.data??{},h=m?.data?.list??m?.list??[],g=[];for(let e of h)if(e.items?.length)for(let t of e.items)g.push(t);else g.push(e);M({total:g.length,models:g},l)}})})),ao,oo=j((()=>{J(),P(),ao=u({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,t){let n=t.api;n||q(`api`,`bl console call --api <api> --data <json>`);let r=t.data;r||q(`data`,`bl console call --api <api> --data <json>`);let i;try{i=JSON.parse(r)}catch{process.stderr.write(`Error: --data must be valid JSON
162
+ `),process.exit(1)}let a=t.region||`cn-beijing`,o=d(e.output),c=await ce(e);if(e.dryRun){M({api:n,data:i,region:a,token:c.token.slice(0,8)+`...`},o);return}M(await s(e,c.token,{api:n,data:i,region:a}),o)}})})),so,co,lo=j((()=>{J(),P(),so=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota`,co=u({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||q(`model`,`bl usage free --model <model>`);let r=t.region||`cn-beijing`,i=d(e.output),a=await ce(e),o={queryFreeTierQuotaRequest:{models:[n]}};if(e.dryRun){M({api:so,data:o,region:r,token:a.token.slice(0,8)+`...`},i);return}M(await s(e,a.token,{api:so,data:o,region:r}),i)}})})),uo=Ge({commands:()=>fo}),fo,po=j((()=>{va(),ba(),Ca(),Ta(),Da(),ka(),ja(),Na(),Fa(),La(),Ba(),Ha(),Xa(),$a(),to(),io(),oo(),lo(),fo={"auth login":Ir,"auth status":Gr,"auth logout":Jr,"text chat":Zr,omni:ti,"image generate":Si,"image edit":Ei,"video generate":Ai,"video edit":Mi,"video ref":Pi,"video task get":Ii,"video download":Ri,"vision describe":Wi,"app call":ya,"app list":Sa,"memory add":wa,"memory search":Ea,"memory list":Oa,"memory update":Aa,"memory delete":Ma,"memory profile create":Pa,"memory profile get":Ia,"knowledge retrieve":za,"search web":Va,"speech synthesize":Ya,"speech recognize":Qa,"file upload":eo,"model list":ro,"console call":ao,"usage free":co,"config show":Ki,"config set":Xi,"config export-schema":$i,update:_a}}));po();const mo=new class{root={children:new Map};constructor(e){for(let[t,n]of Object.entries(e))this.register(t,n)}register(e,t){let n=e.split(` `),r=this.root;for(let e of n)r.children.has(e)||r.children.set(e,{children:new Map}),r=r.children.get(e);r.command=t}getAllCommands(){let e=[],t=n=>{n.command&&e.push(n.command);for(let e of n.children.values())t(e)};return t(this.root),e}isGroupPath(e){let t=this.root;for(let n of e){let e=t.children.get(n);if(!e)return!1;t=e}return!t.command&&t.children.size>0}resolve(t){let n=this.root,i=[];for(let e of t){let t=n.children.get(e);if(!t)break;n=t,i.push(e)}if(n.command)return{command:n.command,extra:t.slice(i.length)};if(i.length>0&&n.children.size===1){let[,e]=n.children.entries().next().value;if(e.command)return{command:e.command,extra:t.slice(i.length)}}if(i.length>0&&n.children.size>0){let a=Array.from(n.children.entries()).map(([e,t])=>{if(t.command)return` ${i.join(` `)} ${e} ${t.command.description}`;let n=Array.from(t.children.keys()).join(`, `);return` ${i.join(` `)} ${e} [${n}]`}).join(`
163
+ `);throw new e(`Unknown command: bl ${t.join(` `)}\n\nAvailable commands:\n${a}`,r.USAGE,`bl ${i.join(` `)} --help`)}throw new e(`Unknown command: bl ${t.join(` `)}`,r.USAGE,`bl --help`)}buildResourceLines(e,t){let n=[],r=(e,t)=>{for(let[i,a]of e.children){let e=t?`${t} ${i}`:i;a.command&&n.push({path:e,desc:a.command.description}),a.children.size>0&&r(a,e)}};r(this.root,``);let i=Math.max(...n.map(e=>e.path.length));return n.map(n=>` ${e(n.path.padEnd(i+2))} ${t(n.desc)}`).join(`
164
+ `)}buildGlobalFlagLines(e,t){let n=Math.max(...i.map(e=>e.flag.length));return i.map(r=>` ${e(r.flag.padEnd(n+2))} ${t(r.description)}`).join(`
164
165
  `)}bold=(e,t)=>t.isTTY?`\x1b[1m${e}\x1b[0m`:e;accent=(e,t)=>t.isTTY?`\x1b[38;2;59;130;246m${e}\x1b[0m`:e;dim=(e,t)=>t.isTTY?`\x1b[2m${e}\x1b[0m`:e;printHelp(e,t=process.stdout,n=`cn`){if(e.length===0){this.printRootHelp(t);return}let r=this.root;for(let n of e){let e=r.children.get(n);if(!e){this.printRootHelp(t);return}r=e}if(r.command){this.printCommandHelp(r.command,t,n);return}let i=e.join(` `);t.write(`\n${this.bold(`Usage:`,t)} bl ${i} <command> [flags]\n\n`),t.write(`${this.bold(`Commands:`,t)}\n`),this.printChildren(r,i,t),t.write(`
165
166
  `)}printRootHelp(e){let t=[`โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—`,`โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘`,`โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘`,`โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘`,`โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ•‘`,`โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ• โ•šโ•โ•โ•šโ•โ•โ•šโ•โ•โ•โ•โ•โ•โ•โ•šโ•โ•โ•šโ•โ• โ•šโ•โ•โ•šโ•โ• โ•šโ•โ•โ•โ•`];e.write(`
166
- `);for(let n of t)e.isTTY?e.write(`${n}\n`):e.write(n+`
167
+ `);for(let n of t)e.isTTY?e.write(`${n}\n`):e.write(n+`
167
168
  `);let n=t=>this.bold(t,e),r=t=>this.accent(t,e),i=t=>this.dim(t,e),a=this.buildResourceLines(r,i),o=this.buildGlobalFlagLines(r,i);e.write(`
168
169
  ${n(`Usage:`)} bl <resource> <command> [flags]
169
170
 
@@ -176,13 +177,13 @@ ${o}
176
177
  ${n(`Getting Help:`)}
177
178
  ${i(`Add --help after any command to see its full list of options, defaults,`)}
178
179
  ${i(`and usage examples. For example:`)} bl text chat --help
179
- `)}printCommandHelp(e,n,r=`cn`){let i=e=>this.bold(e,n),a=e=>this.accent(e,n),o=e=>this.dim(e,n);if(n.write(`\n${e.description}\n`),e.usage&&n.write(`${i(`Usage:`)} ${e.usage}\n`),e.options&&e.options.length>0){let t=Math.max(...e.options.map(e=>e.flag.length));n.write(`\n${i(`Options:`)}\n`);for(let r of e.options)n.write(` ${a(r.flag.padEnd(t+2))} ${o(r.description)}\n`)}if(e.examples&&e.examples.length>0){n.write(`\n${i(`Examples:`)}\n`);for(let t of e.examples)n.write(` ${o(t)}\n`)}e.apiDocs&&n.write(`\n${i(`API Reference:`)} ${o(t[r]+e.apiDocs)}\n`),n.write(`\n${o(`Global flags (--api-key, --output, --quiet, etc.) are always available.`)}\n`),n.write(`${o(`Run`)} bl --help ${o(`for the full list.`)}\n`)}printChildren(e,t,n){let r=[],i=(e,t)=>{for(let[n,a]of e.children)a.command&&r.push({fullName:`${t} ${n}`,description:a.command.description}),a.children.size>0&&i(a,`${t} ${n}`)};i(e,t);let a=Math.max(...r.map(e=>e.fullName.length));for(let{fullName:e,description:t}of r)n.write(` ${this.accent(e.padEnd(a),n)} ${this.dim(t,n)}\n`)}}(no);J();async function ao(t){if(t.apiKey||t.fileApiKey||t.accessTokenEnv||t.fileAccessToken)return;let r=process.env.DASHSCOPE_API_KEY,i;if(r&&(v({nonInteractive:t.nonInteractive})?await hr({message:`Found DASHSCOPE_API_KEY in environment (${x(r)}). Save it to config file?`})&&(i=r):i=r),!i){if(!v({nonInteractive:t.nonInteractive}))throw new e(`No API key found.`,n.AUTH,`Set DASHSCOPE_API_KEY environment variable, pass --api-key, or run interactively to be prompted.`);let r=await K({message:`Enter your DashScope API key:`});if(!r)throw new e(`API key is required.`,n.AUTH);i=r}let a={...w(),api_key:i};delete a.access_token,await he(a),t.fileApiKey=i;let o=t.configPath??`~/.bailian/config.json`;process.stderr.write(`API key saved to ${o}\n`)}et();function Q(e){return e.padEnd(13)}function oo(e){return e.split(`
180
+ `)}printCommandHelp(e,t,r=`cn`){let i=e=>this.bold(e,t),a=e=>this.accent(e,t),o=e=>this.dim(e,t);if(t.write(`\n${e.description}\n`),e.usage&&t.write(`${i(`Usage:`)} ${e.usage}\n`),e.options&&e.options.length>0){let n=Math.max(...e.options.map(e=>e.flag.length));t.write(`\n${i(`Options:`)}\n`);for(let r of e.options)t.write(` ${a(r.flag.padEnd(n+2))} ${o(r.description)}\n`)}if(e.examples&&e.examples.length>0){t.write(`\n${i(`Examples:`)}\n`);for(let n of e.examples)t.write(` ${o(n)}\n`)}e.apiDocs&&t.write(`\n${i(`API Reference:`)} ${o(n[r]+e.apiDocs)}\n`),t.write(`\n${o(`Global flags (--api-key, --output, --quiet, etc.) are always available.`)}\n`),t.write(`${o(`Run`)} bl --help ${o(`for the full list.`)}\n`)}printChildren(e,t,n){let r=[],i=(e,t)=>{for(let[n,a]of e.children)a.command&&r.push({fullName:`${t} ${n}`,description:a.command.description}),a.children.size>0&&i(a,`${t} ${n}`)};i(e,t);let a=Math.max(...r.map(e=>e.fullName.length));for(let{fullName:e,description:t}of r)n.write(` ${this.accent(e.padEnd(a),n)} ${this.dim(t,n)}\n`)}}(fo);J();async function ho(t){if(t.apiKey||t.fileApiKey||t.accessTokenEnv||t.fileAccessToken)return;let n=process.env.DASHSCOPE_API_KEY,i;if(n&&(b({nonInteractive:t.nonInteractive})?await vr({message:`Found DASHSCOPE_API_KEY in environment (${C(n)}). Save it to config file?`})&&(i=n):i=n),!i){if(!b({nonInteractive:t.nonInteractive}))throw new e(`No API key found.`,r.AUTH,`Set DASHSCOPE_API_KEY environment variable, pass --api-key, or run interactively to be prompted.`);let n=await K({message:`Enter your DashScope API key:`});if(!n)throw new e(`API key is required.`,r.AUTH);i=n}await ve({...w(),api_key:i}),t.fileApiKey=i;let a=t.configPath??`~/.bailian/config.json`;process.stderr.write(`API key saved to ${a}\n`)}rt();function Q(e){return e.padEnd(13)}function go(e){return e.split(`
180
181
  `).map((e,t)=>t===0?e:` `.repeat(13)+e).join(`
181
- `)}function so(e){return e.exitCode===n.AUTH?[e.hint,``,`bl auth login --api-key <your-key>`,`bl auth status`,`Get API Key: ${$e}`].filter(e=>e!==void 0).join(`
182
- `):e.hint}function co(e=process.argv.slice(2),t=process.env.DASHSCOPE_OUTPUT){for(let n=0;n<e.length;n++){let r=e[n];if(r===`--output`)return u(e[n+1]||t);if(r?.startsWith(`--output=`))return u(r.slice(9))}return u(t)}function lo(t){let r=t.cause,i=r?.code,a=r?.message,o=[];return i&&o.push(i),a&&a!==i&&o.push(a),new e(`Network request failed: ${o.length>0?o.join(`: `):`unknown cause`}`,n.NETWORK,uo(i),{cause:t})}function uo(e){switch(e){case`ENOTFOUND`:case`EAI_AGAIN`:return`DNS resolution failed. Check DASHSCOPE_BASE_URL or your DNS / network.`;case`ECONNREFUSED`:return`Connection refused. Check the target host/port and proxy settings.`;case`ECONNRESET`:return`Connection reset by peer. Retry, or check proxy / firewall.`;case`ETIMEDOUT`:return`Connection timed out. Check your network or try a different region.`;case`CERT_HAS_EXPIRED`:case`UNABLE_TO_VERIFY_LEAF_SIGNATURE`:case`DEPTH_ZERO_SELF_SIGNED_CERT`:return`TLS certificate error. Check system clock and CA bundle.`;default:return`Check network connection, proxy settings (HTTP_PROXY / HTTPS_PROXY), and DASHSCOPE_BASE_URL.`}}function fo(t){let r=t.code,i=`Check the file path and permissions.`;return r===`ENOENT`?i=`File or directory not found.`:r===`EACCES`||r===`EPERM`?i=`Permission denied โ€” check file or directory permissions.`:r===`ENOSPC`&&(i=`Disk full โ€” free up space and try again.`),new e(`File system error: ${t.message}`,n.GENERAL,i,{cause:t})}function po(e){let t=e.cause,n=0;for(;t instanceof Error&&n<5;)process.stderr.write(`${Q(`Caused by:`)}${t.message}\n`),t=t.cause,n++}function mo(e){process.stderr.write(`\n${Q(`Error:`)}${e.message}\n`);let t=so(e);t&&process.stderr.write(`${Q(`Hint:`)}${oo(t)}\n`);let n=e.api;if(n){if(n.httpStatus!==void 0){let e=n.apiCode?` (${n.apiCode})`:``;process.stderr.write(`${Q(`Status:`)}HTTP ${n.httpStatus}${e}\n`)}else n.apiCode&&process.stderr.write(`${Q(`Code:`)}${n.apiCode}\n`);n.requestId&&process.stderr.write(`${Q(`Request ID:`)}${n.requestId}\n`)}po(e),process.stderr.write(`${Q(`Exit code:`)}${e.exitCode}\n`)}function ho(t){if(t instanceof e&&(co()===`json`?process.stderr.write(JSON.stringify(t.toJSON(),null,2)+`
183
- `):mo(t),process.exit(t.exitCode)),t instanceof Error){if(t.name===`AbortError`||t.name===`TimeoutError`||t.message.includes(`timed out`))return ho(new e(`Request timed out.`,n.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
182
+ `)}function _o(e){return e.exitCode===r.AUTH?e.message===t?e.hint:[e.hint,``,`bl auth login --api-key <your-key>`,`bl auth status`,`Get API Key: ${nt}`].filter(e=>e!==void 0).join(`
183
+ `):e.hint}function vo(e=process.argv.slice(2),t=process.env.DASHSCOPE_OUTPUT){for(let n=0;n<e.length;n++){let r=e[n];if(r===`--output`)return d(e[n+1]||t);if(r?.startsWith(`--output=`))return d(r.slice(9))}return d(t)}function yo(t){let n=t.cause,i=n?.code,a=n?.message,o=[];return i&&o.push(i),a&&a!==i&&o.push(a),new e(`Network request failed: ${o.length>0?o.join(`: `):`unknown cause`}`,r.NETWORK,bo(i),{cause:t})}function bo(e){switch(e){case`ENOTFOUND`:case`EAI_AGAIN`:return`DNS resolution failed. Check DASHSCOPE_BASE_URL or your DNS / network.`;case`ECONNREFUSED`:return`Connection refused. Check the target host/port and proxy settings.`;case`ECONNRESET`:return`Connection reset by peer. Retry, or check proxy / firewall.`;case`ETIMEDOUT`:return`Connection timed out. Check your network or try a different region.`;case`CERT_HAS_EXPIRED`:case`UNABLE_TO_VERIFY_LEAF_SIGNATURE`:case`DEPTH_ZERO_SELF_SIGNED_CERT`:return`TLS certificate error. Check system clock and CA bundle.`;default:return`Check network connection, proxy settings (HTTP_PROXY / HTTPS_PROXY), and DASHSCOPE_BASE_URL.`}}function xo(t){let n=t.code,i=`Check the file path and permissions.`;return n===`ENOENT`?i=`File or directory not found.`:n===`EACCES`||n===`EPERM`?i=`Permission denied โ€” check file or directory permissions.`:n===`ENOSPC`&&(i=`Disk full โ€” free up space and try again.`),new e(`File system error: ${t.message}`,r.GENERAL,i,{cause:t})}function So(e){let t=e.cause,n=0;for(;t instanceof Error&&n<5;)process.stderr.write(`${Q(`Caused by:`)}${t.message}\n`),t=t.cause,n++}function Co(e){process.stderr.write(`\n${Q(`Error:`)}${e.message}\n`);let t=_o(e);t&&process.stderr.write(`${Q(`Hint:`)}${go(t)}\n`);let n=e.api;if(n){if(n.httpStatus!==void 0){let e=n.apiCode?` (${n.apiCode})`:``;process.stderr.write(`${Q(`Status:`)}HTTP ${n.httpStatus}${e}\n`)}else n.apiCode&&process.stderr.write(`${Q(`Code:`)}${n.apiCode}\n`);n.requestId&&process.stderr.write(`${Q(`Request ID:`)}${n.requestId}\n`)}So(e),process.stderr.write(`${Q(`Exit code:`)}${e.exitCode}\n`)}function wo(t){if(t instanceof e&&(vo()===`json`?process.stderr.write(JSON.stringify(t.toJSON(),null,2)+`
184
+ `):Co(t),process.exit(t.exitCode)),t instanceof Error){if(t.name===`AbortError`||t.name===`TimeoutError`||t.message.includes(`timed out`))return wo(new e(`Request timed out.`,r.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
184
185
  If this happens on every request with a valid API key, you may be hitting the wrong region.
185
186
  Run: bl auth status โ€” to check your credentials and region.
186
- Run: bl config set --key region --value cn โ€” to override the region.`,{cause:t}));if(t instanceof TypeError&&t.message===`fetch failed`)return ho(lo(t));let r=t.code;if(typeof r==`string`&&r.startsWith(`E`))return ho(fo(t));process.stderr.write(`\n${Q(`Error:`)}${t.message}\n`),po(t),process.env.DASHSCOPE_VERBOSE===`1`&&process.stderr.write(`${t.stack}\n`)}else process.stderr.write(`\n${Q(`Error:`)}${String(t)}\n`);process.exit(n.GENERAL)}const $=`\x1B[0m`,go=`\x1B[2m`;function _o(e){return e.startsWith(Pe())?e.replace(Pe(),`~`):e}function vo(e,t,n){if(e.quiet||!process.stderr.isTTY)return;let r=e.configPath?_o(e.configPath):`~/.bailian/config.json`,i=e.fileRegion?`${e.fileRegion} (file)`:`cn (default)`,a=n?`${n.source} ยท ${n.method}`:e.apiKey?`flag ยท api-key`:`config`,o=x(t);process.stderr.write(`BAILIAN${$} ${go}${r}${$} ${go}|${$} ${go}Region:${$} ${i}${$} ${go}|${$} ${go}Auth:${$} ${o}${$} ${go}${a}${$}\n`)}aa(),at(),Ki(),ft(),ct((e,t)=>{let n=process.argv.slice(2),r=n.indexOf(`--region`),i=r>=0&&n[r+1]||process.env.DASHSCOPE_REGION||w().region||`cn`;io.printHelp(e,t,i)}),process.on(`SIGINT`,()=>{process.stderr.write(`
187
+ Run: bl config set --key region --value cn โ€” to override the region.`,{cause:t}));if(t instanceof TypeError&&t.message===`fetch failed`)return wo(yo(t));let n=t.code;if(typeof n==`string`&&n.startsWith(`E`))return wo(xo(t));process.stderr.write(`\n${Q(`Error:`)}${t.message}\n`),So(t),process.env.DASHSCOPE_VERBOSE===`1`&&process.stderr.write(`${t.stack}\n`)}else process.stderr.write(`\n${Q(`Error:`)}${String(t)}\n`);process.exit(r.GENERAL)}const $=`\x1B[0m`,To=`\x1B[2m`;function Eo(e){return e.startsWith(Le())?e.replace(Le(),`~`):e}function Do(e,t,n){if(e.quiet||!process.stderr.isTTY)return;let r=e.configPath?Eo(e.configPath):`~/.bailian/config.json`,i=e.fileRegion?`${e.fileRegion} (file)`:`cn (default)`,a=n?`${n.source} ยท ${n.method}`:e.apiKey?`flag ยท api-key`:`config`,o=C(t);process.stderr.write(`BAILIAN${$} ${To}${r}${$} ${To}|${$} ${To}Region:${$} ${i}${$} ${To}|${$} ${To}Auth:${$} ${o}${$} ${To}${a}${$}\n`)}ha(),ct(),na(),ht(),dt((e,t)=>{let n=process.argv.slice(2),r=n.indexOf(`--region`),i=r>=0&&n[r+1]||process.env.DASHSCOPE_REGION||w().region||`cn`;mo.printHelp(e,t,i)}),process.on(`SIGINT`,()=>{process.stderr.write(`
187
188
  Interrupted. Exiting.
188
- `),process.exit(130)}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e});const yo=[[`auth`,`login`],[`auth`,`logout`],[`config`,`show`],[`config`,`set`],[`config`,`export-schema`],[`update`],[`knowledge`,`retrieve`],[`model`,`list`],[`app`,`list`],[`console`,`call`],[`usage`,`free`]];async function bo(){let e=process.argv.slice(2);(e.includes(`--version`)||e.includes(`-v`))&&(process.stdout.write(`bl ${Z}\n`),process.exit(0));let t=Ye(e,r);if(e.includes(`--help`)||e.includes(`-h`)){let n=e.indexOf(`--region`),r=n>=0&&e[n+1]||process.env.DASHSCOPE_REGION||w().region||`cn`;io.printHelp(t,process.stderr,r),process.exit(0)}if(t.length===0){io.printHelp([],process.stderr);let t=b(Xe(e,r));t.clientName=`bailian-cli`,t.clientVersion=Z,t.apiKey||t.fileApiKey||t.fileAccessToken||t.accessTokenEnv?rt():nt(),process.exit(0)}if(io.isGroupPath(t)){let n=e.indexOf(`--region`),r=n>=0&&e[n+1]||process.env.DASHSCOPE_REGION||w().region||`cn`;io.printHelp(t,process.stderr,r),process.exit(0)}let{command:n,extra:i}=io.resolve(t),a=Xe(e,[...r,...n.options??[]]);i.length>0&&(a._positional=i);let o=b(a);if(o.clientName=`bailian-cli`,o.clientVersion=Z,!yo.some(e=>e.every((e,n)=>t[n]===e))){await ao(o);try{let e=await E(o);vo(o,e.token,e)}catch{}}let s=Qi(Z).catch(()=>{});ot(t),t[0]===`auth`&&t[1]===`login`&&!a.console&&!String(a.apiKey??``).trim()&&!String(o.apiKey??``).trim()&&!process.env.DASHSCOPE_API_KEY?.trim()&&(lt(process.stderr),process.exit(0)),await ue(o,t,a,()=>n.execute(o,a)),await s;let c=t.length===1&&t[0]===`update`,l=Zi();if(l&&!o.quiet&&!c){let e=process.stderr.isTTY,t=e?`\x1B[33m`:``,n=e?`\x1B[36m`:``,r=e?`\x1B[0m`:``;process.stderr.write(`\n ${t}Update available: ${Z} โ†’ ${l}${r}\n`),process.stderr.write(` Run ${n}bl update${r} to upgrade\n\n`)}}bo().catch(ho);export{};
189
+ `),f(500).finally(()=>process.exit(130))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e});const Oo=[[`auth`,`login`],[`auth`,`logout`],[`config`,`show`],[`config`,`set`],[`config`,`export-schema`],[`update`],[`knowledge`,`retrieve`],[`model`,`list`],[`app`,`list`],[`console`,`call`],[`usage`,`free`]];async function ko(){let e=process.argv.slice(2);(e.includes(`--version`)||e.includes(`-v`))&&(process.stdout.write(`bl ${Z}\n`),process.exit(0));let t=Qe(e,i);if(e.includes(`--help`)||e.includes(`-h`)){let n=e.indexOf(`--region`),r=n>=0&&e[n+1]||process.env.DASHSCOPE_REGION||w().region||`cn`;mo.printHelp(t,process.stderr,r),process.exit(0)}if(t.length===0){mo.printHelp([],process.stderr);let t=S($e(e,i));t.clientName=`bailian-cli`,t.clientVersion=Z,t.apiKey||t.fileApiKey||t.fileAccessToken||t.accessTokenEnv?ot():at(),process.exit(0)}if(mo.isGroupPath(t)){let n=e.indexOf(`--region`),r=n>=0&&e[n+1]||process.env.DASHSCOPE_REGION||w().region||`cn`;mo.printHelp(t,process.stderr,r),process.exit(0)}let{command:n,extra:r}=mo.resolve(t),a=$e(e,[...i,...n.options??[]]);r.length>0&&(a._positional=r);let o=S(a);if(o.clientName=`bailian-cli`,o.clientVersion=Z,!Oo.some(e=>e.every((e,n)=>t[n]===e))){await ho(o);try{let e=await E(o);Do(o,e.token,e)}catch{}}let s=ca(Z).catch(()=>{});lt(t),t[0]===`auth`&&t[1]===`login`&&!a.console&&!String(a.apiKey??``).trim()&&!String(o.apiKey??``).trim()&&!process.env.DASHSCOPE_API_KEY?.trim()&&(ft(process.stderr),process.exit(0)),await pe(o,t,a,()=>n.execute(o,a)),await s;let c=t.length===1&&t[0]===`update`,l=sa();if(l&&!o.quiet&&!c){let e=process.stderr.isTTY,t=e?`\x1B[33m`:``,n=e?`\x1B[36m`:``,r=e?`\x1B[0m`:``;process.stderr.write(`\n ${t}Update available: ${Z} โ†’ ${l}${r}\n`),process.stderr.write(` Run ${n}bl update${r} to upgrade\n\n`)}await f(1e3)}ko().catch(e=>{f(1e3).finally(()=>wo(e))});export{};