bailian-cli-runtime 2.7.1 → 2.7.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/index.mjs +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -59,7 +59,7 @@ If you are behind a VPN or corporate proxy, route ${Kn} through it:\nexport HTTP
|
|
|
59
59
|
${qn()}\nRun: ${Kn} auth status — to check credentials.`,{cause:e});if(e instanceof TypeError&&e.message===`fetch failed`)return Qn(e);let n=e.code;return typeof n==`string`&&n.startsWith(`E`)?er(e):new t(e.message,c.GENERAL,void 0,{cause:e})}return new t(String(e))}function ir(e,n){if(Kn=n,e instanceof t&&(Zn()===`json`?process.stderr.write(JSON.stringify(e.toJSON(),null,2)+`
|
|
60
60
|
`):nr(e),process.exit(e.exitCode)),e instanceof Error){if(e.name===`AbortError`||e.name===`TimeoutError`||e.message.includes(`timed out`)||e instanceof TypeError&&e.message===`fetch failed`||typeof e.code==`string`&&e.code.startsWith(`E`))return ir(rr(e,n),n);process.stderr.write(`\n${V(`Error:`)}${e.message}\n`),tr(e),process.env.DASHSCOPE_VERBOSE===`1`&&process.stderr.write(`${e.stack}\n`)}else process.stderr.write(`\n${V(`Error:`)}${String(e)}\n`);process.exit(c.GENERAL)}function ar(e){return P(re(),`plugins`,e.npmPackage)}function or(e){return P(ar(e),`package.json`)}function sr(e,t){return P(ar(e),`node_modules`,...t.split(`/`))}async function cr(e){try{return JSON.parse(await Je(e,`utf8`))}catch(n){throw new t(`Could not parse JSON file: ${e}`,c.GENERAL,`Repair or remove the invalid file and try again.`,{cause:n})}}async function lr(e){let t=or(e);return He(t)?cr(t):{dependencies:{}}}async function ur(e,t){return dr(sr(e,t))}async function dr(e){return cr(P(e,`package.json`))}const fr=/* @__PURE__ */ new Set([`none`,`apiKey`,`console`,`openapi`]),pr=/^[a-z0-9][a-z0-9-]*$/;function mr(e,t,r){if(t.name!==e)throw Error(`Package name mismatch: expected "${e}", received "${t.name??``}".`);let i=t.bailianCli;if(!i||i.type!==`command-pack`)throw Error(`Package "${e}" is missing bailianCli.type="command-pack".`);if(i.apiVersion!==n)throw Error(`Command Pack API ${i.apiVersion} is not supported; this CLI supports API ${n}.`);if(i.minCliVersion&&on(r.version,i.minCliVersion)<0)throw Error(`Command Pack requires ${r.npmPackage} ${i.minCliVersion} or newer; current version is ${r.version}.`);if(!i.entry||nt(i.entry))throw Error(`Command Pack "${e}" must declare a relative bailianCli.entry.`);return i}function hr(e,t){let n=e.split(/\s+/).filter(Boolean).join(` `);if(!e||e!==n||!e.split(` `).every(e=>pr.test(e)))throw Error(`Invalid command path "${e}".`);if(!t.commandPrefixes.some(t=>e===t||e.startsWith(`${t} `)))throw Error(`Command "${e}" is outside the allowed prefixes: ${t.commandPrefixes.join(`, `)}.`)}function gr(e){if(typeof e==`string`)return e.length>0;if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return f.every(e=>typeof t[e]==`string`&&t[e].length>0)}function _r(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return t.level===`high`&&gr(t.message)}function vr(e,t){if(!t||typeof t!=`object`)throw Error(`Command "${e}" must export an object.`);let n=t;if(!gr(n.description))throw Error(`Command "${e}" is missing a description.`);if(!n.auth||!fr.has(n.auth))throw Error(`Command "${e}" has an invalid auth requirement.`);if(n.risk!==void 0&&!_r(n.risk))throw Error(`Command "${e}" has invalid risk metadata.`);if(typeof n.run!=`function`)throw Error(`Command "${e}" is missing run(ctx).`)}function yr(e,n,r){return Object.fromEntries(Object.entries(n).map(([n,i])=>[n,{description:i.description,auth:i.auth,risk:i.risk,usageArgs:i.usageArgs,exampleArgs:i.exampleArgs,notes:i.notes,flags:i.flags,validate:i.validate,run:a=>{let o={identity:a.identity,settings:a.settings,flags:a.flags,client:a.client,output:{result(e,t){let n=a.settings.output===`text`&&t?.text!==void 0?t.text:ne(e,a.settings.output);process.stdout.write(`${n}\n`)},line(e){process.stdout.write(`${e}\n`)},write(e){process.stdout.write(e)}},errors:{general(e,n){return new t(e,c.GENERAL,n?.hint,{cause:n?.cause})},usage(e,t){return new p(e,t)},timeout(e=`Request timed out.`,n){return new t(e,c.TIMEOUT,n?.hint,{cause:n?.cause})}},credentials:{apiKey(){if(!r.credentialAccess?.includes(`apiKey`))throw new t(`Command Pack "${e}" is not allowed to access API-key credentials.`,c.GENERAL);if(i.auth!==`apiKey`)throw new t(`Command "${n}" must declare auth="apiKey" before accessing API-key credentials.`,c.GENERAL);let o=a.client.exportApiCredential();if(!o)throw new t(`No API key available to the Command Pack.`,c.AUTH);return o}}};return i.run(o)}}]))}async function br(e,t,n,r,i=sr(r,e)){let a=mr(e,t,r),o=await Ze(i),s=await Ze(it(o,a.entry)),c=rt(o,s);if(!c||c.startsWith(`..`)||nt(c))throw Error(`Command Pack entry must stay inside the package root: ${a.entry}`);let l=(await import(at(s).href)).default;if(!l||typeof l!=`object`||Array.isArray(l))throw Error(`Command Pack "${e}" must default-export a command map.`);let u=Object.entries(l);if(u.length===0)throw Error(`Command Pack "${e}" does not export any commands.`);for(let[e,t]of u)hr(e,n),vr(e,t);let d=yr(e,l,n);return new zt(d,r.binName),d}function xr(e){return e.startsWith(`file:`)?`linked`:`installed`}async function Sr(e,t,n){let r={...e},i=[],a;try{a=await lr(t)}catch(e){return{commands:r,reports:[{name:`(plugin sandbox)`,source:`installed`,status:`failed`,commands:[],error:e instanceof Error?e.message:String(e)}]}}for(let[e,o]of Object.entries(a.dependencies??{}).sort(([e],[t])=>e.localeCompare(t))){let a=xr(o),s=n.supported[e];if(!s){i.push({name:e,source:a,status:`failed`,commands:[],error:`Command Pack "${e}" is not supported by ${t.binName}.`});continue}try{let n=await ur(t,e),o=await br(e,n,s,t),c=Object.keys(o).filter(e=>e in r);if(c.length>0)throw Error(`Command conflicts: ${c.join(`, `)}.`);Object.assign(r,o),i.push({name:e,version:n.version,source:a,status:`loaded`,commands:Object.keys(o).sort()})}catch(t){i.push({name:e,source:a,status:`failed`,commands:[],error:t instanceof Error?t.message:String(t)})}}return{commands:r,reports:i}}const Cr={name:`bailian-cli-command-packs`,private:!0,dependencies:{}},wr=/* @__PURE__ */ new Set(/* @__PURE__ */ `PATH.HOME.USER.LOGNAME.SHELL.TMPDIR.TEMP.TMP.LANG.TERM.NODE.NODE_PATH.NODE_OPTIONS.FORCE_COLOR.NO_COLOR.NPM_TOKEN.NODE_AUTH_TOKEN.HTTP_PROXY.HTTPS_PROXY.NO_PROXY.http_proxy.https_proxy.no_proxy.SystemRoot.ComSpec.APPDATA.PATHEXT`.split(`.`)),Tr=/* @__PURE__ */ new Set([`registry`,`userconfig`,`globalconfig`,`cache`,`proxy`,`https_proxy`,`noproxy`,`strict_ssl`,`ca`,`cafile`]);function Er(e){let t=/^(?:npm_config_|NPM_CONFIG_)(.+)$/.exec(e);return!!t&&Tr.has(t[1].toLowerCase())}function Dr(e,t){let n=Object.keys(t.supported);return n.length>0?`Allowed packages: ${n.join(`, `)}`:`${e.binName} does not currently support any Command Packs.`}function Or(e=process.env){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(wr.has(n)||n.startsWith(`LC_`)||Er(n))&&(t[n]=r);return t}async function kr(e){await j(e,{recursive:!0,mode:448});let t=P(e,`package.json`);He(t)||await et(t,`${JSON.stringify(Cr,null,2)}\n`,{mode:384})}async function Ar(e,n){if(st(`npm`,[`--version`],{encoding:`utf-8`}).status!==0){let e=ae()?"Command Packs need a local npm. Install Node.js, or use `npm install -g bailian-cli` instead of the binary install.":`Install Node.js / npm and retry.`;throw new t(`npm is required to install, link, or remove Command Packs, but was not found on PATH.`,c.GENERAL,e)}await new Promise((r,i)=>{let a=ot(`npm`,e,{cwd:n,env:Or(),stdio:[`inherit`,`pipe`,`pipe`]});a.stdout.on(`data`,e=>process.stderr.write(e)),a.stderr.on(`data`,e=>process.stderr.write(e)),a.once(`error`,i),a.once(`close`,(n,a)=>{if(n===0){r();return}i(new t(`npm ${e[0]} failed${a?` with signal ${a}`:` with exit code ${n}`}.`,c.GENERAL))})})}async function jr(e){let n=ar(e);await kr(n);let r=P(n,`.lock`);for(let e=0;e<2;e++)try{let e=await qe(r,`wx`,384);return await e.writeFile(`${process.pid} ${Date.now()}\n`),await e.close(),async()=>{try{await N(r)}catch{}}}catch(e){if(e.code!==`EEXIST`)throw e;try{let e=await $e(r);if(Date.now()-e.mtimeMs>6e5){await N(r);continue}}catch{continue}throw new t(`Another Command Pack install, link, or remove operation is already running.`,c.GENERAL,`Wait for it to finish and try again.`)}throw new t(`Could not acquire the Command Pack operation lock.`,c.GENERAL)}async function Mr(e,t){let n=await jr(e);try{return await t()}finally{await n()}}function Nr(e,n,r){let i=e.trim(),a=/^(@[^/\s]+\/[^@/\s]+)(?:@([a-zA-Z0-9][a-zA-Z0-9._-]*))?$/.exec(i);if(!a)throw new t(`Unsupported Command Pack package spec: "${e}".`,c.USAGE,`Use an allowlisted scoped package name with an optional version or tag.`);let o=a[1];if(!r.supported[o])throw new t(`Command Pack "${o}" is not allowlisted for ${n.binName}.`,c.USAGE,Dr(n,r));return{name:o,requested:i}}async function Pr(e,t,n,r){let i=r.supported[e],a=await dr(t);return{pjson:a,commands:await br(e,a,i,n,t)}}function Fr(e,t){return t.startsWith(`file:`)?t:`${e}@${t}`}async function Ir(e,t,n){if(t){await Ar([`install`,Fr(e,t),`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],n);return}await Ar([`uninstall`,e,`--ignore-scripts`,`--no-fund`,`--no-audit`],n)}async function Lr(e,n,r){let{name:i,requested:a}=Nr(e,n,r);return Mr(n,async()=>{let e=ar(n),o=(await lr(n)).dependencies?.[i];try{await Ar([`install`,a,`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],e);let o=await Pr(i,sr(n,i),n,r);if(!o.pjson.version)throw new t(`Command Pack "${i}" has no package version.`,c.USAGE);return{name:i,version:o.pjson.version,commands:Object.keys(o.commands).sort()}}catch(t){try{await Ir(i,o,e)}catch{}throw t}})}async function Rr(e,n,r){let i=it(e);if(!He(P(i,`package.json`)))throw new t(`Command Pack path does not exist: ${i}`,c.USAGE);let a=(await dr(i)).name;if(!a||!r.supported[a])throw new t(`Local package "${a??`(unnamed)`}" is not an allowlisted Command Pack for ${n.binName}.`,c.USAGE,Dr(n,r));let o=await Pr(a,i,n,r);return Mr(n,async()=>{await Ar([`install`,`file:${i}`,`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],ar(n));let e=await Pr(a,sr(n,a),n,r);return{name:a,version:e.pjson.version??o.pjson.version,commands:Object.keys(e.commands).sort()}})}async function zr(e,n,r){if(!r.supported[e])throw new t(`Command Pack "${e}" is not allowlisted for ${n.binName}.`,c.USAGE,Dr(n,r));if(!(e in((await lr(n)).dependencies??{})))throw new t(`Command Pack "${e}" is not installed.`,c.USAGE);await Mr(n,()=>Ar([`uninstall`,e,`--ignore-scripts`,`--no-fund`,`--no-audit`],ar(n)))}async function Br(e,t){return(await Sr({},e,t)).reports}function Vr(e,t){return{install:n=>Lr(n,e,t),link:n=>Rr(n,e,t),list:()=>Br(e,t),remove:n=>zr(n,e,t)}}function Hr(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function Ur(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`--config`){let n=e[t+1];return n===void 0||n.startsWith(`--`)?{}:{config:n}}if(n?.startsWith(`--config=`))return{config:n.slice(9)}}return{}}const Wr=/* @__PURE__ */ new Set;function Gr(e){let t=()=>e();return Wr.add(t),process.on(`SIGINT`,t),()=>{Wr.delete(t),process.removeListener(`SIGINT`,t)}}function Kr(e){try{In()}catch(t){ir(t,e)}process.on(`SIGINT`,()=>{Wr.size>0||(process.stderr.write(`
|
|
61
61
|
Interrupted. Exiting.
|
|
62
|
-
`),O(500).finally(()=>process.exit(130)))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e})}function qr(e,t){let{binName:n,version:r,npmPackage:a,clientName:o}=t,c={binName:n,version:r,npmPackage:a,clientName:o},u=t.commandPacks??{supported:{}},d=Vr(c,u),f;Kr(n);let m=On([An,Mn,jn,kn,Nn]);function h(){return f||=Sr(e,c,u),f}async function g(e){let t=yt(b(Ur(e)).file.language??s);return{registry:new zt((await h()).commands,n,t),localize:e=>t.localize(e)}}function _(e,n,r){if(e.printHelp(n,process.stderr),n.length>0)return;let i=!1;try{let e=T(b(r));i=!!(e.apiKey||e.console)}catch{}i?t.quickStartTasks?.length&&e.printQuickStart(t.quickStartTasks):e.printWelcome()}async function v(e,t,a){let o=Bt(t,e,a);switch(o.kind){case`introspect`:process.stdout.write(Wt(Ut(e,c,o.path)));return;case`version`:process.stdout.write(`${n} ${r}\n`);return;case`help`:_(e,o.path,o.parsedFlags);return;case`usageError`:ir(o.error,n);return;case`run`:try{let t=w(o.command),n=o.parsedFlags,r=Hr(n,[...Object.keys(l),...Object.keys(t)]),s=Hr(n,Object.keys(o.command.flags??{})),u=await o.command.validate?.(s);if(u)throw new p(a(u));let f=b(r),h=y(f),g={commandPath:t=>e.commandPath(t),identity:c,path:o.path,command:o.command,flags:s,confirmed:n.yes===!0,localize:a,settings:h,sources:f,configStore:ce(f.configName),authStore:se(f),commandPacks:d,client:new i({identity:c,settings:h,...ye(f)})};await m(g),await O(1e3)}catch(t){if(t instanceof p&&o.rest.length===0){e.printHelp(o.path,process.stderr);return}await O(1e3),ir(t,n)}return}}return{run(e=process.argv.slice(2)){return Promise.resolve().then(()=>g(e)).then(({registry:t,localize:n})=>v(t,e,n)).catch(e=>O(1e3).finally(()=>ir(e,n)))}}}const Jr=`2.7.
|
|
62
|
+
`),O(500).finally(()=>process.exit(130)))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e})}function qr(e,t){let{binName:n,version:r,npmPackage:a,clientName:o}=t,c={binName:n,version:r,npmPackage:a,clientName:o},u=t.commandPacks??{supported:{}},d=Vr(c,u),f;Kr(n);let m=On([An,Mn,jn,kn,Nn]);function h(){return f||=Sr(e,c,u),f}async function g(e){let t=yt(b(Ur(e)).file.language??s);return{registry:new zt((await h()).commands,n,t),localize:e=>t.localize(e)}}function _(e,n,r){if(e.printHelp(n,process.stderr),n.length>0)return;let i=!1;try{let e=T(b(r));i=!!(e.apiKey||e.console)}catch{}i?t.quickStartTasks?.length&&e.printQuickStart(t.quickStartTasks):e.printWelcome()}async function v(e,t,a){let o=Bt(t,e,a);switch(o.kind){case`introspect`:process.stdout.write(Wt(Ut(e,c,o.path)));return;case`version`:process.stdout.write(`${n} ${r}\n`);return;case`help`:_(e,o.path,o.parsedFlags);return;case`usageError`:ir(o.error,n);return;case`run`:try{let t=w(o.command),n=o.parsedFlags,r=Hr(n,[...Object.keys(l),...Object.keys(t)]),s=Hr(n,Object.keys(o.command.flags??{})),u=await o.command.validate?.(s);if(u)throw new p(a(u));let f=b(r),h=y(f),g={commandPath:t=>e.commandPath(t),identity:c,path:o.path,command:o.command,flags:s,confirmed:n.yes===!0,localize:a,settings:h,sources:f,configStore:ce(f.configName),authStore:se(f),commandPacks:d,client:new i({identity:c,settings:h,...ye(f)})};await m(g),await O(1e3)}catch(t){if(t instanceof p&&o.rest.length===0){e.printHelp(o.path,process.stderr);return}await O(1e3),ir(t,n)}return}}return{run(e=process.argv.slice(2)){return Promise.resolve().then(()=>g(e)).then(({registry:t,localize:n})=>v(t,e,n)).catch(e=>O(1e3).finally(()=>ir(e,n)))}}}const Jr=`2.7.2`;function Yr(e,t,{gap:n=2}={}){let r=e.map((e,n)=>{let r=e.length;for(let e of t){let t=e[n]??``;t.length>r&&(r=t.length)}return r}),i=` `.repeat(n),a=e=>e.map((e,t)=>(e??``).padEnd(r[t])).join(i),o=[];o.push(a(e));for(let e of t)o.push(a(e));return o}const Xr=` │ `,Zr=[0,150,160],Qr=[176,205,250],$r=[160,160,170];function ei(e){if(`NO_COLOR`in process.env)return 0;let t=process.env.FORCE_COLOR;if(t!=null){if(t===`0`||t===`false`)return 0;if(t===`3`||t===`truecolor`)return 3;if(t===`2`)return 2;if(t===`1`||t===`true`||t===``)return 1}if(!Et(e))return 0;let n=process.env.COLORTERM;if(n===`truecolor`||n===`24bit`)return 3;let r=process.env.TERM??``;return r===`dumb`?1:/-256(color)?$/i.test(r)?2:1}function ti(e,t,n){return e===t&&t===n?e<8?16:e>248?231:232+Math.round((e-8)/247*24):16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)}function ni(e,t,n,r){let i=Math.max(e,t,n)>127,a=i?128:64;return(r===48?i?100:40:i?90:30)+(e>=a|(t>=a?2:0)|(n>=a?4:0))}function ri(e,t,n,r,i=38){return e>=3?`${i};2;${t};${n};${r}`:e===2?`${i};5;${ti(t,n,r)}`:String(ni(t,n,r,i))}function ii(e,[t,n,r],i){return e<=0?i:`\x1b[${ri(e,t,n,r)}m${i}\x1b[0m`}function ai(e,t,n){return t<=0?e:`\x1b[1;${ri(t,255,255,255,38)};${ri(t,n[0],n[1],n[2],48)}m${e}\x1b[0m`}function oi(e,t){let n=t-B(e);return n>0?` `.repeat(n)+e:e}function si(e,t,n=20,r=process.stdout){return ci(e,t,n,ei(r))}function ci(e,t,n,r){let i=e==null?0:Math.max(0,Math.min(100,e)),a=e!=null,o=a?Math.round(i/100*n):0,s=``,c=``;for(let e=0;e<n;e++)a&&e<o?(s+=`█`,c+=ii(r,Zr,`█`)):(s+=` `,c+=` `);let l=a?Qr:$r;return s+=` ${t}`,c+=` ${ii(r,l,t)}`,{plain:s,colored:c}}function li(e){let t=ei(e.out??process.stdout),n=e.align??[],r=e.barColumns??[],i=e.headers.length,a={};for(let n of r){let r=n.width??20,i=[];for(let a=0;a<e.rows.length;a++){let e=n.percents[a]??null,o=n.labels?.[a]??(e==null?`-`:`${Number.isInteger(e)?e:e.toFixed(1)}%`);i.push(ci(e,o,r,t))}a[n.index]=i}let o=(t,n)=>a[n]?a[n][t].plain:e.rows[t][n]??``,s=e.headers.map((t,n)=>{let r=B(t);for(let t=0;t<e.rows.length;t++){let e=B(o(t,n));e>r&&(r=e)}return r}),c=[],l=e.headers.map((e,t)=>n[t]===`right`?oi(e,s[t]):Jt(e,s[t])).join(Xr),u=Math.max(B(l),...e.rows.map((e,t)=>B(Array.from({length:i},(e,n)=>o(t,n)).join(Xr))));c.push(ai(` ${Jt(l,u)} `,t,Zr));let d=` ${ii(t,Zr,`│`)} `;for(let t=0;t<e.rows.length;t++){let r=[];for(let o=0;o<i;o++){let i=s[o];if(a[o]){let e=a[o][t],n=i-B(e.plain);r.push(n>0?e.colored+` `.repeat(n):e.colored);continue}let c=e.rows[t][o]??``,l=e.cellColor?.(t,o,c),u=n[o]===`right`?oi(c,i):Jt(c,i);l?r.push(n[o]===`right`?u.slice(0,u.length-c.length)+l:l+u.slice(c.length)):r.push(u)}let o=` `;for(let e=0;e<i;e++)o+=r[e],e<i-1&&(o+=d);c.push(o)}return c}const ui=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function di(e){let t=process.stderr.isTTY,n=0,r=null,i=e;return{start(){t&&(r=setInterval(()=>{process.stderr.write(`\r${ui[n%ui.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 fi(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(`
|
|
63
63
|
`)}}}async function pi(e,n,r){let i=Date.now()+r.timeoutSec*1e3,a=di(`Polling...`);n.quiet||a.start();try{for(;Date.now()<i;){let i=r.load?await r.load():await e.requestJson({path:r.url});if(r.getStatus&&!n.quiet&&a.update(`Status: ${r.getStatus(i)}`),r.isComplete(i))return a.stop(`Done.`),i;if(r.isFailed(i)){a.stop(`Failed.`),n.verbose&&process.stderr.write(`[verbose] Task response: ${JSON.stringify(i,null,2)}\n`);let e=r.getErrorMessage?.(i);throw new t(e?`Task failed: ${e}`:`Task failed.`,c.GENERAL,e?void 0:`Use --verbose to see full API response details.`)}await new Promise(e=>setTimeout(e,r.intervalSec*1e3))}}finally{a.stop()}throw new t(`Polling timed out.`,c.TIMEOUT,`Try increasing --timeout or check task status manually.`)}async function mi(e,n,r){let i=await k.fetch(e);if(!i.ok)throw new t(`Download failed: HTTP ${i.status}`,c.GENERAL);let a=Number(i.headers.get(`content-length`)||0),o=i.body?.getReader();if(!o)throw new t(`No response body`,c.GENERAL);Ie(Ne(n),{recursive:!0});let s=Fe(n),l=a>0&&!r?.quiet?fi(a,`Downloading`):null,u=0,d=!1;try{let e=new Promise((e,t)=>{s.on(`error`,t)});for(;;){let{done:t,value:n}=await Promise.race([o.read(),e]);if(t)break;s.write(n)||await new Promise(e=>s.once(`drain`,()=>e())),u+=n.byteLength,l?.update(u)}d=!0}finally{if(o.releaseLock(),l?.finish(),await new Promise((e,t)=>{s.on(`finish`,e),s.on(`error`,t),s.end()}),!d)try{Re(n)}catch{}}return{size:u}}function hi(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}function gi(e){return Math.max(1,e.concurrent??1)}async function _i(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 vi(e,t,n){return Promise.all(e.map(({url:e,destPath:r})=>t(e,r,n).then(()=>r)))}const yi={"qwen-image-2.0":{"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},"qwen-image-fixed":{"16:9":`1664*928`,"4:3":`1472*1104`,"1:1":`1328*1328`,"3:4":`1104*1472`,"9:16":`928*1664`},wan27:{"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},"z-image":{"1:1":`1024*1024`,"16:9":`1280*720`,"9:16":`720*1280`,"4:3":`1152*864`,"3:4":`864*1152`,"3:2":`1248*832`,"2:3":`832*1248`},wan26:{"1:1":`1280*1280`,"16:9":`1696*960`,"9:16":`960*1696`,"4:3":`1472*1104`,"3:4":`1104*1472`},"wan-legacy":{"1:1":`1024*1024`,"16:9":`1280*720`,"9:16":`720*1280`,"3:4":`768*1152`,"4:3":`1152*768`},"wanx-v1":{"1:1":`1024*1024`,"9:16":`720*1280`,"3:4":`768*1152`,"16:9":`1280*720`},"wan25-i2i":{"1:1":`1280*1280`,"16:9":`1280*720`,"9:16":`720*1280`,"4:3":`1152*864`,"3:4":`864*1152`}};function bi(e,t){if(e)return yi[typeof t==`boolean`?t?`qwen-image-2.0`:`qwen-image-fixed`:t][e]??e}var xi=/* @__PURE__ */ gt({ensureBinaryPathEntries:()=>zi,ensureWindowsBinJunction:()=>Vi,fetchBinaryChannelManifest:()=>Ei,fetchBinaryChannelVersion:()=>Ti,getBinaryBinRoot:()=>Si,getBinaryCurrentPath:()=>wi,getBinaryShareRoot:()=>H,getBinaryVersionsDir:()=>Ci,isValidUpdateTargetVersion:()=>ki,normalizeBinaryVersion:()=>Di,performBinaryUpdate:()=>Ui,pruneBinaryVersions:()=>Hi,readCurrentVersionDir:()=>Ii,resolveBinaryDownloadSpec:()=>ji,switchCurrentToVersion:()=>Ri});function H(){return process.env.BAILIAN_SHARE_DIR?process.env.BAILIAN_SHARE_DIR:process.platform===`win32`?P(process.env.LOCALAPPDATA||P(ct(),`AppData`,`Local`),`bailian-cli`):P(ct(),`.local`,`share`,`bailian-cli`)}function Si(){return process.env.BAILIAN_BIN_DIR?process.env.BAILIAN_BIN_DIR:process.platform===`win32`?P(H(),`bin`):P(ct(),`.local`,`bin`)}function Ci(){return P(H(),`versions`)}function wi(){return P(H(),`current`)}async function Ti(e=`latest`,t=5e3){try{let n=await k.fetch(x(e),{signal:AbortSignal.timeout(t)});return n.ok?(await n.json()).version??null:null}catch{return null}}async function Ei(e=`latest`,t=8e3){try{let n=await k.fetch(x(e),{signal:AbortSignal.timeout(t)});return n.ok?await n.json():null}catch{return null}}function Di(e){let t=e.trim();return/^v\d/i.test(t)?t.slice(1):t}const Oi=/^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;function ki(e){let t=e.trim();return t?Oi.test(t):!1}async function Ai(e,t,n=8e3){try{let r=await k.fetch(de(e,`SHA256SUMS`),{signal:AbortSignal.timeout(n)});if(!r.ok)return;let i=await r.text();for(let e of i.split(`
|
|
64
64
|
`)){let n=e.trim().match(/^([a-fA-F0-9]{64})\s+(\S+)$/);if(n?.[2]===t)return n[1].toLowerCase()}}catch{}}async function ji(e){let t=Di(e),{os:n,arch:r,fileSuffix:i}=ee(),a=i===`.exe`,o=m(t,n,r,a),s=h(t,n,r,a),c=de(t,o),l=await Ai(t,o);if(!l){let e=await Ei(`latest`);e?.version===t&&(l=e.assets?.[`${n}-${r}`]?.sha256)}return{zipName:o,innerName:s,url:c,expectedSha:l}}async function Mi(e,t){let n=await k.fetch(e,{signal:AbortSignal.timeout(12e4)});if(!n.ok||!n.body)throw Error(`Download failed (${n.status}): ${e}`);let r=await n.arrayBuffer(),i=Buffer.from(r);return await j(tt(t),{recursive:!0}),await et(t,i),i}function Ni(e){return lt(`sha256`).update(e).digest(`hex`)}function Pi(){return process.platform===`win32`?`bl.exe`:`bl`}function Fi(){return process.platform===`win32`?`bailian.exe`:`bailian`}async function Ii(){let e=wi();try{let t=await Xe(e);return t.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(t)?t:P(tt(e),t)}catch{return null}}function Li(e){let t=Ci(),n=e.replaceAll(`\\`,`/`),r=t.replaceAll(`\\`,`/`).replace(/\/$/,``);if(!n.startsWith(`${r}/`)&&n!==r){let t=e.replaceAll(`\\`,`/`).split(`/`).pop();return t&&t!==`versions`?t:null}return n.slice(r.length+1).split(`/`)[0]??null}async function Ri(e){let t=P(Ci(),e),n=wi();await j(H(),{recursive:!0});try{await N(n)}catch{try{await M(n,{recursive:!0,force:!0})}catch{}}let{symlink:r}=await import(`node:fs/promises`);return process.platform===`win32`?await r(t,n,`junction`):await r(t,n),t}async function zi(e){let t=P(Ci(),e),n=Pi(),r=P(wi(),n),i=Si();if(process.platform===`win32`){await Vi(i);let e=P(t,n),r=P(t,Fi());try{await Ke(r)}catch{try{let{link:t}=await import(`node:fs/promises`);await t(e,r)}catch{await Ge(e,r)}}return}await j(i,{recursive:!0});let{symlink:a}=await import(`node:fs/promises`);for(let e of[`bl`,`bailian`]){let t=P(i,e);try{await N(t)}catch{}await a(r,t)}}function Bi(e){return e&&typeof e==`object`&&`code`in e?String(e.code??``):``}async function Vi(e){let t=wi(),{symlink:n,rename:r}=await import(`node:fs/promises`),i=null;try{let n=await Ke(e);if(n.isSymbolicLink()){let n=await Xe(e);if((n.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(n)?n:P(tt(e),n)).replaceAll(`\\`,`/`).toLowerCase()===t.replaceAll(`\\`,`/`).toLowerCase())return;await N(e)}else if(n.isDirectory()){i=`${e}.migrating.${process.pid}`;try{await r(e,i)}catch(t){try{await M(e,{recursive:!0,force:!0}),i=null}catch(n){let r=Bi(t)||Bi(n)||`EACCES`;throw Error(`Failed to migrate ${e} to a junction pointing at current (${r}). Close other bl sessions and re-run update, or re-run the install script once.`,{cause:n})}}}else await N(e).catch(()=>M(e,{recursive:!0,force:!0}))}catch(t){let n=Bi(t);if(n&&n!==`ENOENT`)throw t instanceof Error&&t.message.includes(`Failed to migrate`)?t:Error(`Failed to migrate ${e} to a junction pointing at current (${n}). Close other bl sessions and re-run update, or re-run the install script once.`,{cause:t})}await j(tt(e),{recursive:!0}),await n(t,e,`junction`),i&&await M(i,{recursive:!0,force:!0}).catch(()=>{})}async function Hi(e){let t=Ci(),n=new Set(e.filter(Boolean)),r=await Ii(),i=r?Li(r):null;i&&n.add(i);let a;try{a=await Ye(t)}catch{return}for(let e of a){if(e.startsWith(`.`)){await M(P(t,e),{recursive:!0,force:!0}).catch(()=>{});continue}n.has(e)||await M(P(t,e),{recursive:!0,force:!0}).catch(()=>{})}}async function Ui(t){let n=Di(t),{zipName:r,innerName:i,url:a,expectedSha:o}=await ji(n),s=H(),c=Ci();await j(P(s,`.tmp`),{recursive:!0}),await j(c,{recursive:!0});let l=await Ii(),u=l?Li(l):null,d=P(s,`.tmp`,r),f=Ni(await Mi(a,d));if(o&&o!==f)throw await N(d).catch(()=>{}),Error(`Checksum mismatch for ${r}`);let p=P(c,`.staging.${n}.${process.pid}`);await M(p,{recursive:!0,force:!0}).catch(()=>{}),await j(p,{recursive:!0});let m=Pi(),h=P(p,m),g=P(s,`.tmp`,`${m}.${process.pid}`);if(await D(d,g,i),await N(d).catch(()=>{}),await Qe(g,h),process.platform!==`win32`)await We(h,493);else{let e=P(p,Fi());try{let{link:t}=await import(`node:fs/promises`);await t(h,e)}catch{await Ge(h,e)}}let _=P(c,n);await M(_,{recursive:!0,force:!0}).catch(()=>{}),await Qe(p,_),await Ri(n),await zi(n);let v=[n];return u&&u!==n&&v.push(u),await Hi(v),je(`binary`,{clientName:e}),await j(re(),{recursive:!0}),n}const Wi={"en-US":`Enable watermark (true/false). Omit flag to use the Profile setting or CLI default (true).`,"zh-CN":`是否启用水印(true/false)。不传时使用 Profile 配置或 CLI 默认值 true。`},Gi={"en-US":`Enable prompt extend (true/false). Omit flag to use CLI default (true).`,"zh-CN":`是否启用提示词扩展(true/false)。不传时使用 CLI 默认值 true。`},Ki={"en-US":`Enable prompt extend (true/false). Omit flag: true for qwen-image sync; parameter omitted on async models (API default).`,"zh-CN":`是否启用提示词扩展(true/false)。不传时:qwen-image 同步调用默认为 true;异步模型不传该参数(使用 API 默认值)。`},qi={"en-US":`Enable prompt extend (true/false). Omit flag to omit the parameter (DashScope default).`,"zh-CN":`是否启用提示词扩展(true/false)。不传时省略该参数(使用 DashScope 默认值)。`};var U=class extends Error{code;step;details;constructor(e,t,n){super(t),this.name=`PipelineError`,this.code=e,this.step=n?.step,this.details=n?.details}toJSON(){return{code:this.code,message:this.message,...this.step?{step:this.step}:{},...this.details?{details:this.details}:{}}}};function Ji(e,t){return e instanceof U?e:new U(`step_execution_error`,e instanceof Error?e.message:String(e),{step:t})}var Yi=class{handlers=/* @__PURE__ */ new Map;outputSchemas=/* @__PURE__ */ new Map;registerStep(e,t,n){this.handlers.set(e,t),n&&this.outputSchemas.set(e,n)}executeStep(e,t,n){let r=this.handlers.get(e);if(!r)throw new U(`unknown_step`,`Unknown step type: ${e}`,{details:{available:this.listSteps()}});return r(t,n)}hasStep(e){return this.handlers.has(e)}listSteps(){return Array.from(this.handlers.keys()).sort()}getOutputSchema(e){return this.outputSchemas.get(e)}};const Xi=new Yi;function Zi(){return Xi}function Qi(e,t,n,r){let i,a;n instanceof Yi?(i=n,a=r):(i=Xi,a=n??r),i.registerStep(e,t,a)}const $i=/* @__PURE__ */ new Set([`image/generate`,`image/edit`,`video/generate`]);function ea(e,t,n){return!$i.has(e)||t.watermark!==void 0?t:{...t,watermark:n.watermark}}function ta(){let e=b({}),t={...y(e),output:`json`,outputExplicit:!0,quiet:!0},n={binName:`bl`,version:`0.0.0-dev`,npmPackage:`bailian-cli`,clientName:`bailian-cli`},r;try{r=fe(e)}catch{}return{client:new i({identity:n,settings:t,baseUrl:ve(e),apiCred:r}),settings:t}}const na=[`download`,`out-dir`,`output`];function ra(e){return e.startsWith(`./`)||e.startsWith(`../`)}function ia(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))typeof a==`string`&&ra(a)?(n[i]=it(t,a),r.push(i)):n[i]=a;return{input:n,resolvedKeys:r}}async function aa(e,t,n){let r=[];for(let i of t){let t=e[i];typeof t==`string`&&(await Ue(t).then(()=>!0,()=>!1)||r.push(`Step "${n}" input "${i}" references file that does not exist: ${t}`))}return r}function oa(e){if(e===void 0)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m)?$/);if(!t)return;let n=Number(t[1]);if(!Number.isFinite(n)||n<=0)return;let r=t[2]??`s`;return r===`ms`?n/1e3:r===`m`?n*60:n}function W(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function sa(e,t){if(Array.isArray(e)){e.forEach(e=>sa(e,t));return}if(W(e)){`$from`in e&&typeof e.$from==`string`&&t.add(e.$from);for(let n of Object.values(e))sa(n,t)}}async function ca(e,t){let n=[];for(let r of e)for(let[e,i]of Object.entries(r.input)){if(na.includes(e)||typeof i!=`string`||!ra(i))continue;let a=it(t,i);await Ue(a).then(()=>!0,()=>!1)||n.push(`Step "${r.id}" input "${e}" references file that does not exist: ${a}`)}return n}async function la(e,t,n){if(!t.message)throw new U(`missing_input`,`text/chat requires 'message' input`,{step:`text/chat`});let r=t.model||`qwen3.8-max`,i=[];t.system&&i.push({role:`system`,content:t.system}),i.push({role:`user`,content:t.message});let a={model:r,messages:i,max_tokens:t[`max-tokens`]??4096,stream:!1};t.temperature!==void 0&&(a.temperature=t.temperature),t[`top-p`]!==void 0&&(a.top_p=t[`top-p`]),t[`enable-thinking`]&&(a.enable_thinking=!0,t[`thinking-budget`]!==void 0&&(a.thinking_budget=t[`thinking-budget`]));let o=S();return await e.client.requestJson({path:o,method:`POST`,body:a,timeout:n.blRequestTimeoutSeconds,signal:n.signal})}async function ua(e,t,n){let r=t.model||`qwen3-vl-plus`,i=Array.isArray(t.image)?t.image:t.image?[t.image]:[],a=t.video?`Describe the video.`:`Describe the image.`,o=t.prompt||a,s=[];if(t.video){let i=t.video;A(i)&&(i=await e.client.uploadFile(i,r,{signal:n.signal})),s.push({type:`video_url`,video_url:{url:i}})}for(let t of i){let i=t;A(t)&&(i=await e.client.uploadFile(t,r,{signal:n.signal})),s.push({type:`image_url`,image_url:{url:i}})}s.push({type:`text`,text:o});let c={model:r,messages:[{role:`user`,content:s}]},l=S();return await e.client.requestJson({path:l,method:`POST`,body:c,signal:n.signal})}async function da(e,t,n){if(!t.prompt)throw new U(`missing_input`,`image/generate requires 'prompt' input`,{step:`image/generate`});let r=t.model||`qwen-image-3.0`,i=_e(r),a=t.n??1,o=me(t[`prompt-extend`],i.promptExtendDefault,`prompt-extend`),s={size:bi(t.size,i.sizeProfile),n:a,seed:t.seed,prompt_extend:o,watermark:Se(t.watermark,e.settings.watermark)},c=i.inputStyle===`prompt`?{model:r,input:{prompt:t.prompt,negative_prompt:t[`negative-prompt`]||void 0},parameters:s}:{model:r,input:{messages:[{role:`user`,content:[{text:t.prompt}]}]},parameters:{...s,negative_prompt:t[`negative-prompt`]||void 0}};if(i.useSync){let r=await e.client.requestJson({path:i.path,method:`POST`,body:c,signal:n.signal}),a=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),o=await pa(a,t[`out-dir`],t[`out-prefix`]);return{urls:a,request_id:r.request_id,...o?{saved:o}:{}}}let l=(await e.client.requestJson({path:i.path,method:`POST`,body:c,async:!0,signal:n.signal})).output.task_id,u=await va(e,l,n),d=await pa(Array.isArray(u.urls)?u.urls:[],t[`out-dir`],t[`out-prefix`]);return d&&(u.saved=d),u}async function fa(e,t,n){if(!t.prompt)throw new U(`missing_input`,`image/edit requires 'prompt' input`,{step:`image/edit`});let r=Array.isArray(t.image)?t.image:t.image?[t.image]:[],i=t.model||`qwen-image-3.0`,a=ge(i),o=t.n??1,s=me(t[`prompt-extend`],a.promptExtendDefault,`prompt-extend`),c=[];for(let t of r){let r=t;A(t)&&(r=await e.client.uploadFile(t,i,{signal:n.signal})),c.push(r)}let l={size:bi(t.size,a.sizeProfile),n:o,seed:t.seed,prompt_extend:s,watermark:Se(t.watermark,e.settings.watermark)},u;if(a.inputStyle===`function-base-image`){let e=c[0];if(!e)throw new U(`missing_input`,`image/edit with wanx*-imageedit requires at least one image`,{step:`image/edit`});u={model:i,input:{function:t.function||`description_edit`,prompt:t.prompt,base_image_url:e},parameters:l}}else if(a.inputStyle===`prompt-images`)u={model:i,input:{prompt:t.prompt,images:c,negative_prompt:t[`negative-prompt`]||void 0},parameters:l};else{let e=c.map(e=>({image:e}));e.push({text:t.prompt}),u={model:i,input:{messages:[{role:`user`,content:e}]},parameters:{...l,negative_prompt:t[`negative-prompt`]||void 0}}}if(a.useSync){let r=await e.client.requestJson({path:a.path,method:`POST`,body:u,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),o=await pa(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...o?{saved:o}:{}}}let d=(await e.client.requestJson({path:a.path,method:`POST`,body:u,async:!0,signal:n.signal})).output.task_id,f=await va(e,d,n),p=await pa(Array.isArray(f.urls)?f.urls:[],t[`out-dir`],t[`out-prefix`]);return p&&(f.saved=p),f}async function pa(e,t,n){if(!t||e.length===0)return;await j(t,{recursive:!0});let r=n&&n.length>0?n:`image`,i=e.length===1?[{url:e[0],destPath:P(t,`${r}.png`)}]:e.map((e,n)=>({url:e,destPath:P(t,`${r}_${String(n+1).padStart(3,`0`)}.png`)})),a=[];for(let{url:e,destPath:t}of i)await mi(e,t,{quiet:!0}),a.push(t);return a}async function ma(e,t,n){if(!t.prompt)throw new U(`missing_input`,`video/generate requires 'prompt' input`,{step:`video/generate`});let r=t.model||`wan3.0-video`,i;t.image&&(i=A(t.image)?await e.client.uploadFile(t.image,r,{signal:n.signal}):t.image);let a={model:r,input:{prompt:t.prompt,negative_prompt:t[`negative-prompt`]||void 0,...i?{media:[{type:`first_frame`,url:i}]}:{}},parameters:{resolution:t.resolution||void 0,ratio:t.ratio||void 0,duration:t.duration,prompt_extend:me(t[`prompt-extend`],void 0,`prompt-extend`),watermark:Se(t.watermark,e.settings.watermark),seed:t.seed}};Ee(a.parameters);let o=Ae(),s=(await e.client.requestJson({path:o,method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await ba(e,s,(t[`poll-interval`]??10)*1e3,(n.timeoutSeconds??900)*1e3,n)}async function ha(e,t,n){let r=t.text;if(!r&&t[`text-file`]){let{readFileSync:e}=await import(`node:fs`);r=e(t[`text-file`],`utf-8`).trim()}if(!r)throw new U(`missing_input`,`speech/synthesize requires 'text' input`,{step:`speech/synthesize`});let i=t.model||`cosyvoice-v3-flash`,a={model:i,input:{text:r,voice:t.voice,format:t.format,sample_rate:t[`sample-rate`],volume:t.volume,rate:t.rate,pitch:t.pitch,seed:t.seed,language_hints:t.language?[t.language]:void 0,instruction:t.instruction,enable_ssml:t[`enable-ssml`]}};Ee(a.input);let o=Te(),s=await e.client.requestJson({path:o,method:`POST`,body:a,signal:n.signal});return{audio_url:s.output.audio.url,url_expires_at:s.output.audio.expires_at,model:i,voice:t.voice,request_id:s.request_id}}async function ga(e,t,n){let r=Array.isArray(t.url)?t.url:t.url?[t.url]:[];if(r.length===0)throw new U(`missing_input`,`speech/recognize requires 'url' input`,{step:`speech/recognize`});let i=t.model||`fun-asr`,a=pe(i);if(a.kind===`unsupported`)throw new U(`invalid_input`,a.unsupportedReason??`Unsupported ASR model: ${i}`,{step:`speech/recognize`});if(a.kind===`sync-flash`){if(r.length!==1)throw new U(`invalid_input`,`Model "${i}" is a sync Flash ASR model and accepts exactly one url (got ${r.length})`,{step:`speech/recognize`});let e=[];if(t.diarization&&e.push(`diarization`),t[`speaker-count`]!==void 0&&e.push(`speaker-count`),a.flashFamily===`qwen3`&&(t[`vocabulary-id`]!==void 0&&e.push(`vocabulary-id`),t.vocabulary!==void 0&&e.push(`vocabulary`),t.context!==void 0&&e.push(`context`)),t[`channel-id`]!==void 0&&e.push(`channel-id`),e.length>0)throw new U(`invalid_input`,`Model "${i}" uses sync Flash ASR and does not support: ${e.join(`, `)}`,{step:`speech/recognize`})}if(a.kind===`async-filetrans`&&a.asyncInputStyle===`file_url`&&r.length!==1)throw new U(`invalid_input`,`Model "${i}" accepts exactly one url (got ${r.length})`,{step:`speech/recognize`});let o=[];for(let t of r)A(t)?o.push(await e.client.uploadFile(t,i,{signal:n.signal})):o.push(t);if(a.kind===`sync-flash`){let r=a.flashFamily,s=_({model:i,audioUrl:o[0],language:t.language,vocabularyId:t[`vocabulary-id`],vocabulary:t.vocabulary,context:t.context,flashFamily:r}),c=await e.client.requestJson({path:a.path,method:`POST`,headers:{"X-DashScope-SSE":`disable`},body:s,signal:n.signal});return{text:te(c,r),model:i,mode:`sync`,raw:c}}let s=v(a.asyncLanguageStyle??`language_hints`,t.language),c={model:i,input:{...a.asyncInputStyle===`file_url`?{file_url:o[0]}:{file_urls:o},...t.context?{context:g(t.context)}:{}},parameters:{channel_id:t[`channel-id`]===void 0?void 0:[t[`channel-id`]],...s,diarization_enabled:t.diarization,speaker_count:t[`speaker-count`],vocabulary_id:t[`vocabulary-id`],vocabulary:t.vocabulary}};Ee(c.parameters);let l=(await e.client.requestJson({path:we(),method:`POST`,body:c,async:!0,signal:n.signal})).output.task_id,u=await xa(e,l,(t[`poll-interval`]??2)*1e3,(n.timeoutSeconds??300)*1e3,n),d=C(u.output),f={task_id:u.output.task_id,task_status:u.output.task_status,request_id:u.request_id,mode:`async`,model:i};if(u.output.results&&(f.results=u.output.results),u.output.result&&(f.result=u.output.result,typeof u.output.result.transcription_url==`string`&&(f.transcription_url=u.output.result.transcription_url)),u.output.task_metrics&&(f.task_metrics=u.output.task_metrics),u.usage&&(f.usage=u.usage),d.length===0)return f;let p=[],m=[];for(let e of d){if(!e.transcription_url)continue;let t=await k.fetch(e.transcription_url,{signal:n.signal});if(!t.ok)throw new U(`async_task_failed`,`Failed to download transcription: HTTP ${t.status}`,{step:`speech/recognize`,details:{taskId:l,url:e.transcription_url}});let r=await t.json();m.push(r);let i=r.transcripts;if(i?.length)for(let e of i)if(e.sentences?.length)for(let t of e.sentences)t.text&&p.push(t.text);else e.text&&p.push(e.text)}return{...f,text:p.join(`
|
|
65
65
|
`),transcripts:m}}function _a(e){let{output:t,request_id:n,usage:r}=e,i={task_id:t.task_id,task_status:t.task_status,request_id:n};if(t.video_url&&(i.video_url=t.video_url),t.choices){let e=t.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);e.length>0&&(i.urls=e)}if(t.results){let e=t.results.map(e=>e.url).filter(Boolean);e.length>0&&!i.urls&&(i.urls=e)}return t.task_metrics&&(i.task_metrics=t.task_metrics),r&&(i.usage=r),i}async function va(e,t,n){return await ba(e,t,3e3,e.settings.timeout*1e3,n)}async function ya(e,t,n,r,i){let a=Date.now(),o=0;for(;;){if(i?.signal?.aborted)throw new U(`aborted`,`Task polling was aborted`,{details:{taskId:t}});await Sa(n,i?.signal),o++;let s=De(t),c=await e.client.requestJson({path:s,method:`GET`,signal:i?.signal}),l=c.output.task_status;if(l===`SUCCEEDED`)return c;if(l===`FAILED`)throw new U(`async_task_failed`,c.output.message||c.output.code||`Task failed`,{details:{taskId:t,data:c}});let u=Date.now()-a;if(await i?.emitEvent?.({type:`step.polling`,timestamp:(/* @__PURE__ */ new Date()).toISOString(),status:`running`,taskId:t,taskStatus:l,elapsedMs:u,pollAttempt:o}),u>r)throw new U(`async_poll_timeout`,`Task ${t} timed out after ${Math.round(r/1e3)}s`,{details:{taskId:t,timeoutMs:r,pollAttempts:o}})}}async function ba(e,t,n,r,i){return _a(await ya(e,t,n,r,i))}async function xa(e,t,n,r,i){return await ya(e,t,n,r,i)}function Sa(e,t){return t?new Promise((n,r)=>{let i=setTimeout(()=>{o(),n()},e),a=()=>{o(),r(new U(`aborted`,`Poll delay was aborted`))},o=()=>{clearTimeout(i),t.removeEventListener(`abort`,a)};t.aborted?a():t.addEventListener(`abort`,a,{once:!0})}):new Promise(t=>setTimeout(t,e))}const Ca={"text/chat":(e,t,n)=>la(e,t,n),"vision/describe":(e,t,n)=>ua(e,t,n),"image/generate":(e,t,n)=>da(e,t,n),"image/edit":(e,t,n)=>fa(e,t,n),"video/generate":(e,t,n)=>ma(e,t,n),"speech/synthesize":(e,t,n)=>ha(e,t,n),"speech/recognize":(e,t,n)=>ga(e,t,n)},wa={"image/generate":e=>({data:e,artifacts:Oa(e),warnings:[],metadata:{}}),"image/edit":e=>({data:e,artifacts:Oa(e),warnings:[],metadata:{}}),"video/generate":e=>({data:e,artifacts:Oa(e),warnings:[],metadata:{}}),"speech/synthesize":e=>({data:e,artifacts:ka(e,`audio`),warnings:[],metadata:{}}),"speech/recognize":e=>({data:e,artifacts:ka(e,`transcript`),warnings:[],metadata:{}})},Ta={"text/chat":{description:`LLM text completion via chat API`,paths:[{path:`/data/choices/0/message/content`,description:`Generated text content`},{path:`/data/choices/0/message/role`,description:`Message role (assistant)`},{path:`/data/usage/total_tokens`,description:`Total token usage`}]},"vision/describe":{description:`Multimodal vision understanding (image/video to text)`,paths:[{path:`/data/choices/0/message/content`,description:`Generated description text`},{path:`/data/choices/0/message/role`,description:`Message role (assistant)`},{path:`/data/usage/total_tokens`,description:`Total token usage`}]},"image/generate":{description:`Text-to-image generation`,paths:[{path:`/data/urls`,description:`Array of generated image URLs`},{path:`/data/urls/0`,description:`First generated image URL`},{path:`/data/task_id`,description:`Async task ID (if applicable)`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"image/edit":{description:`Image editing with reference image(s)`,paths:[{path:`/data/urls`,description:`Array of generated image URLs`},{path:`/data/urls/0`,description:`First generated image URL`},{path:`/data/task_id`,description:`Async task ID (if applicable)`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"video/generate":{description:`Video generation (text-to-video or image-to-video)`,paths:[{path:`/data/video_url`,description:`Generated video URL`},{path:`/data/task_id`,description:`Async task ID`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"speech/synthesize":{description:`Text-to-speech synthesis`,paths:[{path:`/data/audio_url`,description:`Generated audio URL`},{path:`/data/url_expires_at`,description:`Audio URL expiration time`},{path:`/artifacts/0/url`,description:`First artifact URL`}]},"speech/recognize":{description:`Speech recognition (ASR)`,paths:[{path:`/data/text`,description:`Full transcribed text`},{path:`/data/task_id`,description:`Async task ID`},{path:`/artifacts/0/taskId`,description:`Task ID from artifact`}]}};function Ea(e){for(let t of Object.keys(Ca))Qi(t,async(e,n)=>await Da(t,e,n),e,Ta[t])}async function Da(e,t,n){let r=n.blEnv??ta();if(n.dryRun)return{metadata:{dryRun:!0,step:e,plannedInput:ea(e,t,r.settings)},warnings:[{code:`dry_run_skipped`,message:`Step ${e} was not executed in dry-run mode`}]};let i=Ca[e];if(!i)throw Error(`No direct API handler registered for step: ${e}`);let a=await i(r,t,n),o=wa[e];return o?o(a):{data:a,warnings:[],metadata:{}}}function Oa(e){if(!W(e))return;let t=[],n=G(e.task_id)??G(e.taskId);for(let r of Ma(e.urls))t.push({url:r,taskId:n,kind:Na(r)});for(let r of Ma(e.saved))t.push({path:r,taskId:n,kind:Pa(r)});let r=G(e.video_url)??G(e.videoUrl);r&&t.push({url:r,taskId:n,kind:`video`});let i=G(e.saved);if(i&&t.push({path:i,taskId:n,kind:Pa(i)}),Array.isArray(e.videos))for(let n of e.videos){if(!W(n))continue;let e=G(n.task_id)??G(n.taskId),r=G(n.video_url)??G(n.videoUrl),i=G(n.saved);r&&t.push({url:r,taskId:e,kind:`video`}),i&&t.push({path:i,taskId:e,kind:`video`})}let a=Array.isArray(e.task_ids)?e.task_ids.map(G).filter(ja):[];for(let e of a)t.push({taskId:e,kind:`task`});return t.length===0&&n&&t.push({taskId:n,kind:`task`}),t.length>0?t:void 0}function ka(e,t){if(!W(e))return;let n=[],r=G(e.task_id)??G(e.taskId),i=[G(e.url),G(e.audio_url),G(e.audioUrl),G(e.output_url),G(e.outputUrl)].filter(ja);for(let e of i)n.push({url:e,taskId:r,kind:t});let a=[G(e.saved),G(e.path),G(e.output_path),G(e.outputPath)].filter(ja);for(let e of a)n.push({path:e,taskId:r,kind:t});return n.length===0&&r&&n.push({taskId:r,kind:`task`}),n.length>0?Aa(n):void 0}function Aa(e){let t=/* @__PURE__ */ new Set,n=[];for(let r of e){let e=`${r.kind??``}:${r.taskId??``}:${r.url??``}:${r.path??``}`;t.has(e)||(t.add(e),n.push(r))}return n}function ja(e){return typeof e==`string`}function G(e){return typeof e==`string`&&e.length>0?e:void 0}function Ma(e){return Array.isArray(e)?e.map(G).filter(ja):[]}function Na(e){try{return Pa(new URL(e).pathname)}catch{return`artifact`}}function Pa(e){let t=e.toLowerCase();return t.endsWith(`.mp4`)||t.endsWith(`.mov`)||t.endsWith(`.webm`)?`video`:t.endsWith(`.png`)||t.endsWith(`.jpg`)||t.endsWith(`.jpeg`)||t.endsWith(`.webp`)?`image`:`artifact`}var Fa=/* @__PURE__ */ F((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),Ia=/* @__PURE__ */ F((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=Fa();var n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;let o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=/* @__PURE__ */ new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||/* @__PURE__ */ new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),K=/* @__PURE__ */ F((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let t=Fa(),n=Ia();var r=Fa();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var i=Ia();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=D(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=D(this.rhs,e,n),this}get names(){return te(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=D(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(O(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>E(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(ne(t),n instanceof e?[n]:n.nodes);if(t!==!1&&this.nodes.length)return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=D(this.condition,e,t),this}get names(){let e=super.names;return te(e,this.condition),this.else&&E(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=D(this.iteration,e,t),this}get names(){return E(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return te(te(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=D(this.iterable,e,t),this}get names(){return E(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&E(e,this.catch.names),this.finally&&E(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var ee=class extends m{render(e){return`finally`+super.render(e)}};ee.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bailian-cli-runtime",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.2",
|
|
4
4
|
"description": "Runtime framework for bailian-cli (createCli, registry, args, output, pipeline). See https://www.npmjs.com/package/bailian-cli for usage.",
|
|
5
5
|
"homepage": "https://bailian.console.aliyun.com/cli",
|
|
6
6
|
"bugs": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"boxen": "^8.0.1",
|
|
31
31
|
"chalk": "^5.6.2",
|
|
32
32
|
"undici": "^6.27.0",
|
|
33
|
-
"bailian-cli-core": "2.7.
|
|
33
|
+
"bailian-cli-core": "2.7.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@clack/prompts": "^0.7.0",
|