bailian-cli-runtime 2.3.0 → 2.3.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
|
@@ -46,7 +46,7 @@ If you are behind a VPN or corporate proxy, route ${R} through it:\nexport HTTPS
|
|
|
46
46
|
`):Rn(e),process.exit(e.exitCode)),e instanceof Error){if(e.name===`AbortError`||e.name===`TimeoutError`||e.message.includes(`timed out`))return B(new t(`Request timed out.`,c.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
|
|
47
47
|
${kn()}\nRun: ${R} auth status — to check credentials.`,{cause:e}),R);if(e instanceof TypeError&&e.message===`fetch failed`)return B(Pn(e),R);let n=e.code;if(typeof n==`string`&&n.startsWith(`E`))return B(In(e),R);process.stderr.write(`\n${z(`Error:`)}${e.message}\n`),Ln(e),process.env.DASHSCOPE_VERBOSE===`1`&&process.stderr.write(`${e.stack}\n`)}else process.stderr.write(`\n${z(`Error:`)}${String(e)}\n`);process.exit(c.GENERAL)}function zn(e){return M(re(),`plugins`,e.npmPackage)}function Bn(e){return M(zn(e),`package.json`)}function Vn(e,t){return M(zn(e),`node_modules`,...t.split(`/`))}async function Hn(e){try{return JSON.parse(await Ke(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 Un(e){let t=Bn(e);return Be(t)?Hn(t):{dependencies:{}}}async function Wn(e,t){return Gn(Vn(e,t))}async function Gn(e){return Hn(M(e,`package.json`))}const Kn=/* @__PURE__ */ new Set([`none`,`apiKey`,`console`,`openapi`]),qn=/^[a-z0-9][a-z0-9-]*$/;function Jn(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&&Xt(r.version,i.minCliVersion)<0)throw Error(`Command Pack requires ${r.npmPackage} ${i.minCliVersion} or newer; current version is ${r.version}.`);if(!i.entry||et(i.entry))throw Error(`Command Pack "${e}" must declare a relative bailianCli.entry.`);return i}function Yn(e,t){let n=e.split(/\s+/).filter(Boolean).join(` `);if(!e||e!==n||!e.split(` `).every(e=>qn.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 Xn(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 Zn(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return t.level===`high`&&Xn(t.message)}function Qn(e,t){if(!t||typeof t!=`object`)throw Error(`Command "${e}" must export an object.`);let n=t;if(!Xn(n.description))throw Error(`Command "${e}" is missing a description.`);if(!n.auth||!Kn.has(n.auth))throw Error(`Command "${e}" has an invalid auth requirement.`);if(n.risk!==void 0&&!Zn(n.risk))throw Error(`Command "${e}" has invalid risk metadata.`);if(typeof n.run!=`function`)throw Error(`Command "${e}" is missing run(ctx).`)}function $n(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 er(e,t,n,r,i=Vn(r,e)){let a=Jn(e,t,r),o=await Ye(i),s=await Ye(nt(o,a.entry)),c=tt(o,s);if(!c||c.startsWith(`..`)||et(c))throw Error(`Command Pack entry must stay inside the package root: ${a.entry}`);let l=(await import(rt(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)Yn(e,n),Qn(e,t);let d=$n(e,l,n);return new Lt(d,r.binName),d}function tr(e){return e.startsWith(`file:`)?`linked`:`installed`}async function nr(e,t,n){let r={...e},i=[],a;try{a=await Un(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=tr(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 Wn(t,e),o=await er(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 rr={name:`bailian-cli-command-packs`,private:!0,dependencies:{}},ir=/* @__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(`.`)),ar=/* @__PURE__ */ new Set([`registry`,`userconfig`,`globalconfig`,`cache`,`proxy`,`https_proxy`,`noproxy`,`strict_ssl`,`ca`,`cafile`]);function or(e){let t=/^(?:npm_config_|NPM_CONFIG_)(.+)$/.exec(e);return!!t&&ar.has(t[1].toLowerCase())}function sr(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 cr(e=process.env){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(ir.has(n)||n.startsWith(`LC_`)||or(n))&&(t[n]=r);return t}async function lr(e){await k(e,{recursive:!0,mode:448});let t=M(e,`package.json`);Be(t)||await Qe(t,`${JSON.stringify(rr,null,2)}\n`,{mode:384})}async function ur(e,n){if(at(`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=it(`npm`,e,{cwd:n,env:cr(),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 dr(e){let n=zn(e);await lr(n);let r=M(n,`.lock`);for(let e=0;e<2;e++)try{let e=await Ge(r,`wx`,384);return await e.writeFile(`${process.pid} ${Date.now()}\n`),await e.close(),async()=>{try{await j(r)}catch{}}}catch(e){if(e.code!==`EEXIST`)throw e;try{let e=await Ze(r);if(Date.now()-e.mtimeMs>6e5){await j(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 fr(e,t){let n=await dr(e);try{return await t()}finally{await n()}}function pr(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,sr(n,r));return{name:o,requested:i}}async function mr(e,t,n,r){let i=r.supported[e],a=await Gn(t);return{pjson:a,commands:await er(e,a,i,n,t)}}function hr(e,t){return t.startsWith(`file:`)?t:`${e}@${t}`}async function gr(e,t,n){if(t){await ur([`install`,hr(e,t),`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],n);return}await ur([`uninstall`,e,`--ignore-scripts`,`--no-fund`,`--no-audit`],n)}async function _r(e,n,r){let{name:i,requested:a}=pr(e,n,r);return fr(n,async()=>{let e=zn(n),o=(await Un(n)).dependencies?.[i];try{await ur([`install`,a,`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],e);let o=await mr(i,Vn(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 gr(i,o,e)}catch{}throw t}})}async function vr(e,n,r){let i=nt(e);if(!Be(M(i,`package.json`)))throw new t(`Command Pack path does not exist: ${i}`,c.USAGE);let a=(await Gn(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,sr(n,r));let o=await mr(a,i,n,r);return fr(n,async()=>{await ur([`install`,`file:${i}`,`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],zn(n));let e=await mr(a,Vn(n,a),n,r);return{name:a,version:e.pjson.version??o.pjson.version,commands:Object.keys(e.commands).sort()}})}async function yr(e,n,r){if(!r.supported[e])throw new t(`Command Pack "${e}" is not allowlisted for ${n.binName}.`,c.USAGE,sr(n,r));if(!(e in((await Un(n)).dependencies??{})))throw new t(`Command Pack "${e}" is not installed.`,c.USAGE);await fr(n,()=>ur([`uninstall`,e,`--ignore-scripts`,`--no-fund`,`--no-audit`],zn(n)))}async function br(e,t){return(await nr({},e,t)).reports}function xr(e,t){return{install:n=>_r(n,e,t),link:n=>vr(n,e,t),list:()=>br(e,t),remove:n=>yr(n,e,t)}}function Sr(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function Cr(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{}}function wr(e){try{bn()}catch(t){B(t,e)}process.on(`SIGINT`,()=>{process.stderr.write(`
|
|
48
48
|
Interrupted. Exiting.
|
|
49
|
-
`),O(500).finally(()=>process.exit(130))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e})}function Tr(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=xr(c,u),f;wr(n);let m=fn([mn,gn,hn,pn,_n]);function h(){return f||=nr(e,c,u),f}async function g(e){let t=_t(b(Cr(e)).file.language??s);return{registry:new Lt((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=Rt(t,e,a);switch(o.kind){case`version`:process.stdout.write(`${n} ${r}\n`);return;case`help`:_(e,o.path,o.parsedFlags);return;case`usageError`:B(o.error,n);return;case`run`:try{let e=w(o.command),t=o.parsedFlags,n=Sr(t,[...Object.keys(l),...Object.keys(e)]),r=Sr(t,Object.keys(o.command.flags??{})),s=await o.command.validate?.(r);if(s)throw new p(s);let u=b(n),f=y(u),h={identity:c,path:o.path,command:o.command,flags:r,confirmed:t.yes===!0,localize:a,settings:f,sources:u,configStore:ce(u.configName),authStore:se(u),commandPacks:d,client:new i({identity:c,settings:f,...ve(u)})};await m(h),await O(1e3)}catch(t){if(t instanceof p&&o.rest.length===0){e.printHelp(o.path,process.stderr);return}await O(1e3),B(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(()=>B(e,n)))}}}const Er=`2.3.
|
|
49
|
+
`),O(500).finally(()=>process.exit(130))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e})}function Tr(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=xr(c,u),f;wr(n);let m=fn([mn,gn,hn,pn,_n]);function h(){return f||=nr(e,c,u),f}async function g(e){let t=_t(b(Cr(e)).file.language??s);return{registry:new Lt((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=Rt(t,e,a);switch(o.kind){case`version`:process.stdout.write(`${n} ${r}\n`);return;case`help`:_(e,o.path,o.parsedFlags);return;case`usageError`:B(o.error,n);return;case`run`:try{let e=w(o.command),t=o.parsedFlags,n=Sr(t,[...Object.keys(l),...Object.keys(e)]),r=Sr(t,Object.keys(o.command.flags??{})),s=await o.command.validate?.(r);if(s)throw new p(s);let u=b(n),f=y(u),h={identity:c,path:o.path,command:o.command,flags:r,confirmed:t.yes===!0,localize:a,settings:f,sources:u,configStore:ce(u.configName),authStore:se(u),commandPacks:d,client:new i({identity:c,settings:f,...ve(u)})};await m(h),await O(1e3)}catch(t){if(t instanceof p&&o.rest.length===0){e.printHelp(o.path,process.stderr);return}await O(1e3),B(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(()=>B(e,n)))}}}const Er=`2.3.2`;function Dr(e,t){process.stdout.write(ne(e,t)+`
|
|
50
50
|
`)}function Or(e){process.stdout.write(e+`
|
|
51
51
|
`)}function kr(e,t){e&&!t&&process.stderr.write(`request_id: ${e}\n`)}function Ar(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}function jr(e){return e>=11904&&e<=40959||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=131072&&e<=195103}function V(e){let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=jr(e)?2:1}return t}function Mr(e,t){let n=t-V(e);return n>0?e+` `.repeat(n):e}const Nr=` │ `,Pr=[0,150,160],Fr=[176,205,250],Ir=[160,160,170];function Lr(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(!wt(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 Rr(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 zr(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 Br(e,t,n,r,i=38){return e>=3?`${i};2;${t};${n};${r}`:e===2?`${i};5;${Rr(t,n,r)}`:String(zr(t,n,r,i))}function Vr(e,[t,n,r],i){return e<=0?i:`\x1b[${Br(e,t,n,r)}m${i}\x1b[0m`}function Hr(e,t,n){return t<=0?e:`\x1b[1;${Br(t,255,255,255,38)};${Br(t,n[0],n[1],n[2],48)}m${e}\x1b[0m`}function Ur(e,t){let n=t-V(e);return n>0?` `.repeat(n)+e:e}function Wr(e,t,n=20,r=process.stdout){return Gr(e,t,n,Lr(r))}function Gr(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+=Vr(r,Pr,`█`)):(s+=` `,c+=` `);let l=a?Fr:Ir;return s+=` ${t}`,c+=` ${Vr(r,l,t)}`,{plain:s,colored:c}}function Kr(e){let t=Lr(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(Gr(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=V(t);for(let t=0;t<e.rows.length;t++){let e=V(o(t,n));e>r&&(r=e)}return r}),c=[],l=e.headers.map((e,t)=>n[t]===`right`?Ur(e,s[t]):Mr(e,s[t])).join(Nr),u=Math.max(V(l),...e.rows.map((e,t)=>V(Array.from({length:i},(e,n)=>o(t,n)).join(Nr))));c.push(Hr(` ${Mr(l,u)} `,t,Pr));let d=` ${Vr(t,Pr,`│`)} `;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-V(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`?Ur(c,i):Mr(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 qr=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function Jr(e){let t=process.stderr.isTTY,n=0,r=null,i=e;return{start(){t&&(r=setInterval(()=>{process.stderr.write(`\r${qr[n%qr.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 Yr(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(`
|
|
52
52
|
`)}}}async function Xr(e,n,r){let i=Date.now()+r.timeoutSec*1e3,a=Jr(`Polling...`);n.quiet||a.start();try{for(;Date.now()<i;){let i=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 Zr(e,n,r){let i=await 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);Pe(je(n),{recursive:!0});let s=Ne(n),l=a>0&&!r?.quiet?Yr(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{Ie(n)}catch{}}return{size:u}}function Qr(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 $r(e){return Math.max(1,e.concurrent??1)}async function ei(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 ti(e,t,n){return Promise.all(e.map(({url:e,destPath:r})=>t(e,r,n).then(()=>r)))}const ni={"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 ri(e,t){if(e)return ni[typeof t==`boolean`?t?`qwen-image-2.0`:`qwen-image-fixed`:t][e]??e}var ii=/* @__PURE__ */ mt({ensureBinaryPathEntries:()=>Si,ensureWindowsBinJunction:()=>wi,fetchBinaryChannelManifest:()=>li,fetchBinaryChannelVersion:()=>ci,getBinaryBinRoot:()=>ai,getBinaryCurrentPath:()=>si,getBinaryShareRoot:()=>H,getBinaryVersionsDir:()=>oi,isValidUpdateTargetVersion:()=>fi,normalizeBinaryVersion:()=>ui,performBinaryUpdate:()=>Ei,pruneBinaryVersions:()=>Ti,readCurrentVersionDir:()=>yi,resolveBinaryDownloadSpec:()=>mi,switchCurrentToVersion:()=>xi});function H(){return process.env.BAILIAN_SHARE_DIR?process.env.BAILIAN_SHARE_DIR:process.platform===`win32`?M(process.env.LOCALAPPDATA||M(ot(),`AppData`,`Local`),`bailian-cli`):M(ot(),`.local`,`share`,`bailian-cli`)}function ai(){return process.env.BAILIAN_BIN_DIR?process.env.BAILIAN_BIN_DIR:process.platform===`win32`?M(H(),`bin`):M(ot(),`.local`,`bin`)}function oi(){return M(H(),`versions`)}function si(){return M(H(),`current`)}async function ci(e=`latest`,t=5e3){try{let n=await fetch(x(e),{signal:AbortSignal.timeout(t)});return n.ok?(await n.json()).version??null:null}catch{return null}}async function li(e=`latest`,t=8e3){try{let n=await fetch(x(e),{signal:AbortSignal.timeout(t)});return n.ok?await n.json():null}catch{return null}}function ui(e){let t=e.trim();return/^v\d/i.test(t)?t.slice(1):t}const di=/^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 fi(e){let t=e.trim();return t?di.test(t):!1}async function pi(e,t,n=8e3){try{let r=await fetch(ue(e,`SHA256SUMS`),{signal:AbortSignal.timeout(n)});if(!r.ok)return;let i=await r.text();for(let e of i.split(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bailian-cli-runtime",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.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.3.
|
|
33
|
+
"bailian-cli-core": "2.3.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@clack/prompts": "^0.7.0",
|