bailian-cli-core 2.3.3 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +2 -2
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{createRequire as e}from"node:module";import{appendFileSync as t,createReadStream as n,createWriteStream as r,existsSync as i,mkdirSync as a,readFileSync as o,renameSync as s,rmSync as c,statSync as l,unlinkSync as u,writeFileSync as d}from"fs";import{homedir as f,tmpdir as p}from"os";import{basename as m,extname as h,join as g}from"path";import{parse as _,stringify as v}from"yaml";import{Dispatcher as y,getGlobalDispatcher as b}from"undici";import{createHash as ee,createHmac as te,randomBytes as ne,randomUUID as re}from"crypto";import{Readable as ie}from"stream";import{createInterface as x}from"readline";import{pipeline as ae}from"stream/promises";import*as oe from"yauzl";import{copyFileSync as se,cpSync as ce,createWriteStream as le,existsSync as S,lstatSync as C,mkdirSync as w,readFileSync as T,readdirSync as E,readlinkSync as ue,realpathSync as de,renameSync as D,rmSync as O,statSync as fe,symlinkSync as k,writeFileSync as A}from"node:fs";import{basename as pe,dirname as j,isAbsolute as me,join as M,relative as he,resolve as ge,sep as _e}from"node:path";import{homedir as ve}from"node:os";import{createHash as ye}from"node:crypto";import{Readable as be}from"node:stream";import{pipeline as xe}from"node:stream/promises";import{createBrotliDecompress as Se}from"node:zlib";import Ce from"tar-stream";import{mkdir as we}from"node:fs/promises";var Te=Object.create,Ee=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Oe=Object.getOwnPropertyNames,ke=Object.getPrototypeOf,Ae=Object.prototype.hasOwnProperty,je=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Me=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Oe(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ae.call(e,s)&&s!==n&&Ee(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=De(t,s))||r.enumerable});return e},Ne=(e,t,n)=>(n=e==null?{}:Te(ke(e)),Me(t||!e||!e.__esModule||!Ae.call(e,`default`)?Ee(n,`default`,{value:e,enumerable:!0}):n,e)),Pe=/* @__PURE__ */ e(import.meta.url);const N={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONFIRMATION_REQUIRED:7,CONTENT_FILTER:10};var P=class extends Error{exitCode;hint;api;rawResponse;constructor(e,t=N.GENERAL,n,r){super(e,r?.cause===void 0?void 0:{cause:r.cause}),this.name=`BailianError`,this.exitCode=t,this.hint=n,this.api=r?.api,this.rawResponse=r?.rawResponse}toJSON(){let e=Fe(this.cause);return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{},...this.api?.httpStatus===void 0?{}:{http_status:this.api.httpStatus},...this.api?.apiCode?{api_code:this.api.apiCode}:{},...this.api?.requestId?{request_id:this.api.requestId}:{},...e?{cause:e}:{}}}}},F=class extends P{constructor(e,t){super(e,N.USAGE,t),this.name=`UsageError`}};function Fe(e){if(e!=null){if(e instanceof Error){let t={message:e.message},n=e.code;return n&&(t.code=n),t}if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return{message:String(e)};try{return{message:JSON.stringify(e)}}catch{return}}}function Ie(e,t,n){let r=t.error?.message||t.message||`HTTP ${e}`,i=t.error?.type??t.code,a=typeof i==`string`?i:typeof i==`number`?String(i):void 0;return new P(r,N.GENERAL,void 0,{api:{httpStatus:e,apiCode:a,requestId:t.request_id??t.requestID}})}function Le(e){let t=e.trim(),n;try{n=new URL(t)}catch{throw Re(e)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw Re(e);return n.origin}function Re(e){return new P(`Invalid model base URL "${e}".`,N.USAGE,`Use an absolute http(s) URL.`)}const ze={cn:`https://dashscope.aliyuncs.com`,us:`https://dashscope-us.aliyuncs.com`,intl:`https://dashscope-intl.aliyuncs.com`},Be={cn:`https://help.aliyun.com/zh/model-studio`,us:`https://help.aliyun.com/zh/model-studio`,intl:`https://help.aliyun.com/zh/model-studio`},Ve=`https://bailian.cn-beijing.aliyuncs.com`,He=[`en-US`,`zh-CN`],Ue=`en-US`,We=[`language`,`api_key`,`access_token`,`access_key_id`,`access_key_secret`,`security_token`,`base_url`,`output`,`output_dir`,`timeout`,`watermark`,`default_text_model`,`default_video_model`,`default_image_to_video_model`,`default_reference_to_video_model`,`default_image_model`,`default_speech_model`,`default_speech_recognition_model`,`default_omni_model`,`api_key_capabilities`,`workspace_id`,`console_site`,`console_region`,`console_switch_agent`,`telemetry`],Ge=/* @__PURE__ */ new Set([`text`,`json`]),Ke=/* @__PURE__ */ new Set([`domestic`,`international`]),qe=/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/;function Je(e){return qe.test(e)}function Ye(e){if(e===void 0)return;if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)return[];let e=n.trim();if(!Je(e))return[];t.includes(e)||t.push(e)}return t}function Xe(e){try{return Le(e)}catch{return}}function Ze(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t=e,n={};if(typeof t.language==`string`&&He.includes(t.language)&&(n.language=t.language),typeof t.api_key==`string`&&(n.api_key=t.api_key),typeof t.access_token==`string`&&t.access_token.length>0?n.access_token=t.access_token:typeof t.accessToken==`string`&&t.accessToken.length>0&&(n.access_token=t.accessToken),typeof t.access_key_id==`string`&&t.access_key_id.length>0?n.access_key_id=t.access_key_id:typeof t.openapi_access_key_id==`string`&&t.openapi_access_key_id.length>0&&(n.access_key_id=t.openapi_access_key_id),typeof t.access_key_secret==`string`&&t.access_key_secret.length>0?n.access_key_secret=t.access_key_secret:typeof t.openapi_access_key_secret==`string`&&t.openapi_access_key_secret.length>0&&(n.access_key_secret=t.openapi_access_key_secret),typeof t.security_token==`string`&&t.security_token.length>0&&(n.security_token=t.security_token),typeof t.base_url==`string`){let e=Xe(t.base_url);e&&(n.base_url=e)}typeof t.output==`string`&&Ge.has(t.output)&&(n.output=t.output),typeof t.output_dir==`string`&&t.output_dir.length>0&&(n.output_dir=t.output_dir),typeof t.timeout==`number`&&t.timeout>0&&(n.timeout=t.timeout),typeof t.watermark==`boolean`&&(n.watermark=t.watermark),typeof t.default_text_model==`string`&&t.default_text_model.length>0&&(n.default_text_model=t.default_text_model),typeof t.default_video_model==`string`&&t.default_video_model.length>0&&(n.default_video_model=t.default_video_model),typeof t.default_image_to_video_model==`string`&&t.default_image_to_video_model.length>0&&(n.default_image_to_video_model=t.default_image_to_video_model),typeof t.default_reference_to_video_model==`string`&&t.default_reference_to_video_model.length>0&&(n.default_reference_to_video_model=t.default_reference_to_video_model),typeof t.default_image_model==`string`&&t.default_image_model.length>0&&(n.default_image_model=t.default_image_model),typeof t.default_speech_model==`string`&&t.default_speech_model.length>0&&(n.default_speech_model=t.default_speech_model),typeof t.default_speech_recognition_model==`string`&&t.default_speech_recognition_model.length>0&&(n.default_speech_recognition_model=t.default_speech_recognition_model),typeof t.default_omni_model==`string`&&t.default_omni_model.length>0&&(n.default_omni_model=t.default_omni_model);let r=Ye(t.api_key_capabilities);return r!==void 0&&(n.api_key_capabilities=r),typeof t.workspace_id==`string`&&t.workspace_id.length>0&&(n.workspace_id=t.workspace_id),typeof t.console_site==`string`&&Ke.has(t.console_site)&&(n.console_site=t.console_site),typeof t.console_region==`string`&&t.console_region.length>0&&(n.console_region=t.console_region),typeof t.console_switch_agent==`number`&&t.console_switch_agent>0&&(n.console_switch_agent=t.console_switch_agent),typeof t.telemetry==`boolean`&&(n.telemetry=t.telemetry),n}function Qe(e,t=ze.cn){let n=e.flags.baseUrl||e.env.DASHSCOPE_BASE_URL||e.file.base_url;return{baseUrl:Le(n||t),baseUrlIsDefault:!n}}function $e(e,t=ze.cn){return Qe(e,t).baseUrl}function et(e){let t=$e(e);if(e.flags.apiKey)return{token:e.flags.apiKey,baseUrl:t,source:`flag`};let n=e.env.DASHSCOPE_API_KEY?.trim();if(n)return{token:n,baseUrl:t,source:`env`};if(e.file.api_key)return{token:e.file.api_key,baseUrl:t,source:`config`};throw new P(`No API key found.`,N.AUTH,"Set DASHSCOPE_API_KEY, pass --api-key, or run `bl auth login`.")}function tt(e){let t=e.file.access_token?.trim();if(!t)throw new P(`No console access token found.`,N.AUTH,"Run `bl auth login --console`.");return{token:t,region:e.flags.consoleRegion||e.file.console_region||`cn-beijing`,site:e.flags.consoleSite||e.file.console_site||`domestic`,switchAgent:e.flags.consoleSwitchAgent||e.file.console_switch_agent||void 0,source:`config`}}function nt(e){let t=rt(`flag`,e.flags.accessKeyId,e.flags.accessKeySecret,e.flags.accessKeyId!==void 0||e.flags.accessKeySecret!==void 0,e.flags.securityToken);if(t)return t;let n=rt(`env`,e.env.ALIBABA_CLOUD_ACCESS_KEY_ID,e.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET,!!(it(e.env.ALIBABA_CLOUD_ACCESS_KEY_ID)||it(e.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET)),e.env.ALIBABA_CLOUD_SECURITY_TOKEN);if(n)return n;let r=rt(`config`,e.file.access_key_id,e.file.access_key_secret,!!(e.file.access_key_id||e.file.access_key_secret),e.file.security_token);if(r)return r;throw new P(`No OpenAPI AK/SK credentials found.`,N.AUTH,"Set ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET, pass --access-key-id and --access-key-secret, or run `bl auth login --open-api`.")}function rt(e,t,n,r,i){if(!r)return;let a=it(t),o=it(n);if(!a||!o)throw new P(`Incomplete OpenAPI AK/SK credentials found.`,N.AUTH,at(e));return{accessKeyId:a,accessKeySecret:o,securityToken:it(i),source:e}}function it(e){return e?.trim()||void 0}function at(e){return e===`flag`?`Pass both --access-key-id and --access-key-secret, or remove the partial flags to use env/config credentials.`:e===`env`?`Set both ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET, or unset the partial env vars to use config credentials.`:"Run `bl auth login --open-api --access-key-id <id> --access-key-secret <secret>` again to save a complete pair."}function ot(e){let t={};try{t.apiKey=et(e)}catch{}try{t.console=tt(e)}catch{}try{t.openapi=nt(e)}catch{}return t}function I(){return process.env.BAILIAN_CONFIG_DIR?process.env.BAILIAN_CONFIG_DIR:g(f(),`.bailian`)}function L(){return g(I(),`config.json`)}function st(){return g(I(),`credentials.json`)}async function ct(){let e=I(),t=await import(`fs/promises`);await t.mkdir(e,{recursive:!0,mode:448});try{await t.chmod(e,448)}catch{}}function lt(e){return v(e).replace(/\n$/,``)}function ut(e){return JSON.stringify(e,null,2)}function dt(e,t,n){return JSON.stringify({error:{code:e,message:t,...n?{hint:n}:{}}},null,2)}function ft(e){return e===`json`||e===`text`?e:`text`}function pt(e,t){switch(t){case`json`:return ut(e);case`text`:return lt(e)}}const mt={"en-US":`Timeout must be a positive finite number.`,"zh-CN":`请求超时必须是一个有限的正数。`};function ht(e){if(typeof e!=`number`||!Number.isFinite(e)||e<=0)return mt}const gt=/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/,_t=`active_config`;function vt(e){return!(!e||typeof e!=`object`||Array.isArray(e))}function yt(e){if(e!==void 0&&e!==``&&e!=="default"){if(typeof e!=`string`||!gt.test(e))throw new P(`Invalid config name "${typeof e==`string`?e:JSON.stringify(e)}".`,N.USAGE,`Use letters, numbers, '-' or '_', starting with a letter or number.`);if(We.includes(e)||e===_t)throw new P(`Invalid config name "${e}". It conflicts with a config key.`,N.USAGE);return e}}function bt(){let e=L();if(!i(e))return{};try{let t=JSON.parse(o(e,`utf-8`));return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch(e){let t=e;return(t instanceof SyntaxError||t.message.includes(`JSON`))&&console.warn(`Warning: config file is corrupted; using defaults.`),{}}}function xt(e,t){let n=yt(e[_t]);if(n&&t&&!vt(e[n]))throw new P(`Active config "${n}" does not exist.`,N.USAGE,`Use --config default to select the default config, then activate an existing profile.`);return n}function St(e,t){if(!t)return e;let n=e[t];return vt(n)?n:{}}function R(e){return Ze(St(bt(),e))}async function Ct(e,t,n={}){let r=bt();if(t)r[t]=e;else{for(let e of Object.keys(r))We.includes(e)&&delete r[e];Object.assign(r,e)}n.activate&&(r[_t]=t??`default`),await wt(r)}async function wt(e){await ct();let t=L(),n=t+`.tmp`;d(n,JSON.stringify(e,null,2)+`
1
+ import{createRequire as e}from"node:module";import{appendFileSync as t,createReadStream as n,createWriteStream as r,existsSync as i,mkdirSync as a,readFileSync as o,renameSync as s,rmSync as c,statSync as l,unlinkSync as u,writeFileSync as d}from"fs";import{homedir as f,tmpdir as p}from"os";import{basename as m,extname as h,join as g}from"path";import{parse as _,stringify as v}from"yaml";import{Dispatcher as y,getGlobalDispatcher as b}from"undici";import{createHash as ee,createHmac as te,randomBytes as ne,randomUUID as re}from"crypto";import{Readable as ie}from"stream";import{createInterface as x}from"readline";import{pipeline as ae}from"stream/promises";import*as oe from"yauzl";import{copyFileSync as se,cpSync as ce,createWriteStream as le,existsSync as S,lstatSync as C,mkdirSync as w,readFileSync as T,readdirSync as E,readlinkSync as ue,realpathSync as de,renameSync as D,rmSync as O,statSync as fe,symlinkSync as k,writeFileSync as A}from"node:fs";import{basename as pe,dirname as j,isAbsolute as me,join as M,relative as he,resolve as ge,sep as _e}from"node:path";import{homedir as ve}from"node:os";import{createHash as ye}from"node:crypto";import{Readable as be}from"node:stream";import{pipeline as xe}from"node:stream/promises";import{createBrotliDecompress as Se}from"node:zlib";import Ce from"tar-stream";import{mkdir as we}from"node:fs/promises";var Te=Object.create,Ee=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Oe=Object.getOwnPropertyNames,ke=Object.getPrototypeOf,Ae=Object.prototype.hasOwnProperty,je=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Me=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Oe(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ae.call(e,s)&&s!==n&&Ee(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=De(t,s))||r.enumerable});return e},Ne=(e,t,n)=>(n=e==null?{}:Te(ke(e)),Me(t||!e||!e.__esModule||!Ae.call(e,`default`)?Ee(n,`default`,{value:e,enumerable:!0}):n,e)),Pe=/* @__PURE__ */ e(import.meta.url);const N={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONFIRMATION_REQUIRED:7,CONTENT_FILTER:10};var P=class extends Error{exitCode;hint;api;rawResponse;constructor(e,t=N.GENERAL,n,r){super(e,r?.cause===void 0?void 0:{cause:r.cause}),this.name=`BailianError`,this.exitCode=t,this.hint=n,this.api=r?.api,this.rawResponse=r?.rawResponse}toJSON(){let e=Fe(this.cause);return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{},...this.api?.httpStatus===void 0?{}:{http_status:this.api.httpStatus},...this.api?.apiCode?{api_code:this.api.apiCode}:{},...this.api?.requestId?{request_id:this.api.requestId}:{},...e?{cause:e}:{}}}}},F=class extends P{constructor(e,t){super(e,N.USAGE,t),this.name=`UsageError`}};function Fe(e){if(e!=null){if(e instanceof Error){let t={message:e.message},n=e.code;return n&&(t.code=n),t}if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return{message:String(e)};try{return{message:JSON.stringify(e)}}catch{return}}}function Ie(e,t,n){let r=t.error?.message||t.message||`HTTP ${e}`,i=t.error?.type??t.error?.code??t.code,a=typeof i==`string`?i:typeof i==`number`?String(i):void 0;return new P(r,N.GENERAL,void 0,{api:{httpStatus:e,apiCode:a,requestId:t.request_id??t.requestID}})}function Le(e){let t=e.trim(),n;try{n=new URL(t)}catch{throw Re(e)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw Re(e);return n.origin}function Re(e){return new P(`Invalid model base URL "${e}".`,N.USAGE,`Use an absolute http(s) URL.`)}const ze={cn:`https://dashscope.aliyuncs.com`,us:`https://dashscope-us.aliyuncs.com`,intl:`https://dashscope-intl.aliyuncs.com`},Be={cn:`https://help.aliyun.com/zh/model-studio`,us:`https://help.aliyun.com/zh/model-studio`,intl:`https://help.aliyun.com/zh/model-studio`},Ve=`https://bailian.cn-beijing.aliyuncs.com`,He=[`en-US`,`zh-CN`],Ue=`en-US`,We=[`language`,`api_key`,`access_token`,`access_key_id`,`access_key_secret`,`security_token`,`base_url`,`output`,`output_dir`,`timeout`,`watermark`,`default_text_model`,`default_video_model`,`default_image_to_video_model`,`default_reference_to_video_model`,`default_image_model`,`default_speech_model`,`default_speech_recognition_model`,`default_omni_model`,`api_key_capabilities`,`workspace_id`,`console_site`,`console_region`,`console_switch_agent`,`telemetry`],Ge=/* @__PURE__ */ new Set([`text`,`json`]),Ke=/* @__PURE__ */ new Set([`domestic`,`international`]),qe=/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/;function Je(e){return qe.test(e)}function Ye(e){if(e===void 0)return;if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)return[];let e=n.trim();if(!Je(e))return[];t.includes(e)||t.push(e)}return t}function Xe(e){try{return Le(e)}catch{return}}function Ze(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t=e,n={};if(typeof t.language==`string`&&He.includes(t.language)&&(n.language=t.language),typeof t.api_key==`string`&&(n.api_key=t.api_key),typeof t.access_token==`string`&&t.access_token.length>0?n.access_token=t.access_token:typeof t.accessToken==`string`&&t.accessToken.length>0&&(n.access_token=t.accessToken),typeof t.access_key_id==`string`&&t.access_key_id.length>0?n.access_key_id=t.access_key_id:typeof t.openapi_access_key_id==`string`&&t.openapi_access_key_id.length>0&&(n.access_key_id=t.openapi_access_key_id),typeof t.access_key_secret==`string`&&t.access_key_secret.length>0?n.access_key_secret=t.access_key_secret:typeof t.openapi_access_key_secret==`string`&&t.openapi_access_key_secret.length>0&&(n.access_key_secret=t.openapi_access_key_secret),typeof t.security_token==`string`&&t.security_token.length>0&&(n.security_token=t.security_token),typeof t.base_url==`string`){let e=Xe(t.base_url);e&&(n.base_url=e)}typeof t.output==`string`&&Ge.has(t.output)&&(n.output=t.output),typeof t.output_dir==`string`&&t.output_dir.length>0&&(n.output_dir=t.output_dir),typeof t.timeout==`number`&&t.timeout>0&&(n.timeout=t.timeout),typeof t.watermark==`boolean`&&(n.watermark=t.watermark),typeof t.default_text_model==`string`&&t.default_text_model.length>0&&(n.default_text_model=t.default_text_model),typeof t.default_video_model==`string`&&t.default_video_model.length>0&&(n.default_video_model=t.default_video_model),typeof t.default_image_to_video_model==`string`&&t.default_image_to_video_model.length>0&&(n.default_image_to_video_model=t.default_image_to_video_model),typeof t.default_reference_to_video_model==`string`&&t.default_reference_to_video_model.length>0&&(n.default_reference_to_video_model=t.default_reference_to_video_model),typeof t.default_image_model==`string`&&t.default_image_model.length>0&&(n.default_image_model=t.default_image_model),typeof t.default_speech_model==`string`&&t.default_speech_model.length>0&&(n.default_speech_model=t.default_speech_model),typeof t.default_speech_recognition_model==`string`&&t.default_speech_recognition_model.length>0&&(n.default_speech_recognition_model=t.default_speech_recognition_model),typeof t.default_omni_model==`string`&&t.default_omni_model.length>0&&(n.default_omni_model=t.default_omni_model);let r=Ye(t.api_key_capabilities);return r!==void 0&&(n.api_key_capabilities=r),typeof t.workspace_id==`string`&&t.workspace_id.length>0&&(n.workspace_id=t.workspace_id),typeof t.console_site==`string`&&Ke.has(t.console_site)&&(n.console_site=t.console_site),typeof t.console_region==`string`&&t.console_region.length>0&&(n.console_region=t.console_region),typeof t.console_switch_agent==`number`&&t.console_switch_agent>0&&(n.console_switch_agent=t.console_switch_agent),typeof t.telemetry==`boolean`&&(n.telemetry=t.telemetry),n}function Qe(e,t=ze.cn){let n=e.flags.baseUrl||e.env.DASHSCOPE_BASE_URL||e.file.base_url;return{baseUrl:Le(n||t),baseUrlIsDefault:!n}}function $e(e,t=ze.cn){return Qe(e,t).baseUrl}function et(e){let t=$e(e);if(e.flags.apiKey)return{token:e.flags.apiKey,baseUrl:t,source:`flag`};let n=e.env.DASHSCOPE_API_KEY?.trim();if(n)return{token:n,baseUrl:t,source:`env`};if(e.file.api_key)return{token:e.file.api_key,baseUrl:t,source:`config`};throw new P(`No API key found.`,N.AUTH,"Set DASHSCOPE_API_KEY, pass --api-key, or run `bl auth login`.")}function tt(e){let t=e.file.access_token?.trim();if(!t)throw new P(`No console access token found.`,N.AUTH,"Run `bl auth login --console`.");return{token:t,region:e.flags.consoleRegion||e.file.console_region||`cn-beijing`,site:e.flags.consoleSite||e.file.console_site||`domestic`,switchAgent:e.flags.consoleSwitchAgent||e.file.console_switch_agent||void 0,source:`config`}}function nt(e){let t=rt(`flag`,e.flags.accessKeyId,e.flags.accessKeySecret,e.flags.accessKeyId!==void 0||e.flags.accessKeySecret!==void 0,e.flags.securityToken);if(t)return t;let n=rt(`env`,e.env.ALIBABA_CLOUD_ACCESS_KEY_ID,e.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET,!!(it(e.env.ALIBABA_CLOUD_ACCESS_KEY_ID)||it(e.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET)),e.env.ALIBABA_CLOUD_SECURITY_TOKEN);if(n)return n;let r=rt(`config`,e.file.access_key_id,e.file.access_key_secret,!!(e.file.access_key_id||e.file.access_key_secret),e.file.security_token);if(r)return r;throw new P(`No OpenAPI AK/SK credentials found.`,N.AUTH,"Set ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET, pass --access-key-id and --access-key-secret, or run `bl auth login --open-api`.")}function rt(e,t,n,r,i){if(!r)return;let a=it(t),o=it(n);if(!a||!o)throw new P(`Incomplete OpenAPI AK/SK credentials found.`,N.AUTH,at(e));return{accessKeyId:a,accessKeySecret:o,securityToken:it(i),source:e}}function it(e){return e?.trim()||void 0}function at(e){return e===`flag`?`Pass both --access-key-id and --access-key-secret, or remove the partial flags to use env/config credentials.`:e===`env`?`Set both ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET, or unset the partial env vars to use config credentials.`:"Run `bl auth login --open-api --access-key-id <id> --access-key-secret <secret>` again to save a complete pair."}function ot(e){let t={};try{t.apiKey=et(e)}catch{}try{t.console=tt(e)}catch{}try{t.openapi=nt(e)}catch{}return t}function I(){return process.env.BAILIAN_CONFIG_DIR?process.env.BAILIAN_CONFIG_DIR:g(f(),`.bailian`)}function L(){return g(I(),`config.json`)}function st(){return g(I(),`credentials.json`)}async function ct(){let e=I(),t=await import(`fs/promises`);await t.mkdir(e,{recursive:!0,mode:448});try{await t.chmod(e,448)}catch{}}function lt(e){return v(e).replace(/\n$/,``)}function ut(e){return JSON.stringify(e,null,2)}function dt(e,t,n){return JSON.stringify({error:{code:e,message:t,...n?{hint:n}:{}}},null,2)}function ft(e){return e===`json`||e===`text`?e:`text`}function pt(e,t){switch(t){case`json`:return ut(e);case`text`:return lt(e)}}const mt={"en-US":`Timeout must be a positive finite number.`,"zh-CN":`请求超时必须是一个有限的正数。`};function ht(e){if(typeof e!=`number`||!Number.isFinite(e)||e<=0)return mt}const gt=/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/,_t=`active_config`;function vt(e){return!(!e||typeof e!=`object`||Array.isArray(e))}function yt(e){if(e!==void 0&&e!==``&&e!=="default"){if(typeof e!=`string`||!gt.test(e))throw new P(`Invalid config name "${typeof e==`string`?e:JSON.stringify(e)}".`,N.USAGE,`Use letters, numbers, '-' or '_', starting with a letter or number.`);if(We.includes(e)||e===_t)throw new P(`Invalid config name "${e}". It conflicts with a config key.`,N.USAGE);return e}}function bt(){let e=L();if(!i(e))return{};try{let t=JSON.parse(o(e,`utf-8`));return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch(e){let t=e;return(t instanceof SyntaxError||t.message.includes(`JSON`))&&console.warn(`Warning: config file is corrupted; using defaults.`),{}}}function xt(e,t){let n=yt(e[_t]);if(n&&t&&!vt(e[n]))throw new P(`Active config "${n}" does not exist.`,N.USAGE,`Use --config default to select the default config, then activate an existing profile.`);return n}function St(e,t){if(!t)return e;let n=e[t];return vt(n)?n:{}}function R(e){return Ze(St(bt(),e))}async function Ct(e,t,n={}){let r=bt();if(t)r[t]=e;else{for(let e of Object.keys(r))We.includes(e)&&delete r[e];Object.assign(r,e)}n.activate&&(r[_t]=t??`default`),await wt(r)}async function wt(e){await ct();let t=L(),n=t+`.tmp`;d(n,JSON.stringify(e,null,2)+`
2
2
  `,{mode:384}),s(n,t)}function Tt(){let e=bt(),t={};for(let[n,r]of Object.entries(e))We.includes(n)||n===_t||vt(r)&&(t[n]=Ze(r));return{default:Ze(e),named:t,active:xt(e,!0)??`default`}}function Et(e,t){let n=yt(t);if(n&&!vt(e[n]))throw new P(`Config "${n}" does not exist.`,N.USAGE,`Create or log in to the profile before activating it.`);return n??`default`}function Dt(e){return Et(bt(),e)}async function Ot(e){let t=bt(),n=Et(t,e);return t[_t]=n,await wt(t),n}async function kt(e){let t=yt(e);if(!t)throw new P(`Cannot delete the default profile.`,N.USAGE);let n=bt();return vt(n[t])?(delete n[t],xt(n,!1)===t&&(n[_t]=`default`),await wt(n),!0):!1}function At(e,t){if(e.flags.apiKey||e.flags.baseUrl||e.env.DASHSCOPE_API_KEY?.trim()||e.env.DASHSCOPE_BASE_URL||!e.configName)return{sources:e};let n=e.file.api_key_capabilities;return n===void 0||n.includes(t)?{sources:e}:{sources:{...e,file:R(),configName:void 0},fallbackFrom:e.configName}}function jt(e){let t=bt(),n=e.config!==void 0,r=xt(t,!n),i=n?yt(e.config):r;return{flags:e,file:Ze(St(t,i)),env:process.env,configName:i,configPath:L()}}function Mt(e){let{flags:t,file:n,env:r}=e,i=r.DASHSCOPE_TIMEOUT?Number(r.DASHSCOPE_TIMEOUT):void 0,a=ht(i)===void 0?i:void 0,o=t.timeout??a??n.timeout??300,s=ht(o);if(s)throw new P(s[`en-US`],N.USAGE);return{configPath:e.configPath??L(),configName:e.configName,output:ft(t.output||r.DASHSCOPE_OUTPUT||n.output),outputExplicit:!!(t.output||r.DASHSCOPE_OUTPUT||n.output),outputDir:n.output_dir||void 0,timeout:o,watermark:n.watermark??!0,defaultTextModel:n.default_text_model,defaultVideoModel:n.default_video_model,defaultImageToVideoModel:n.default_image_to_video_model,defaultReferenceToVideoModel:n.default_reference_to_video_model,defaultImageModel:n.default_image_model,defaultSpeechModel:n.default_speech_model,defaultSpeechRecognitionModel:n.default_speech_recognition_model,defaultOmniModel:n.default_omni_model,workspaceId:t.workspaceId||r.BAILIAN_WORKSPACE_ID||n.workspace_id||void 0,consoleRegion:t.consoleRegion||n.console_region||void 0,consoleSite:t.consoleSite||n.console_site||void 0,consoleSwitchAgent:t.consoleSwitchAgent||n.console_switch_agent||void 0,verbose:t.verbose||r.DASHSCOPE_VERBOSE===`1`,quiet:t.quiet||!1,dryRun:t.dryRun||!1,telemetry:r.DO_NOT_TRACK===`1`?!1:n.telemetry??!0}}const Nt={"token-plan":{baseUrl:`https://token-plan.cn-beijing.maas.aliyuncs.com`,defaultTextModel:`qwen3.8-max`,defaultVideoModel:`happyhorse-1.1-t2v`,defaultImageToVideoModel:`happyhorse-1.1-i2v`,defaultReferenceToVideoModel:`happyhorse-1.1-r2v`,defaultImageModel:`wan2.7-image`,defaultSpeechModel:`qwen-audio-3.0-tts-plus`,defaultSpeechRecognitionModel:`qwen-audio-3.0-asr-flash`,apiKeyCapabilities:[`text.chat`,`vision.describe`,`image.generate`,`image.edit`,`speech.recognize`,`speech.synthesize`,`video.generate`,`video.ref`,`video.task.get`,`video.download`]}};function Pt(e){return e?Nt[e]:void 0}function Ft(e){let t=e.trim();return t.startsWith(`sk-sp-`)?`token-plan`:t.startsWith(`sk-`)?`ordinary`:`unknown`}function It(e,t,n){if(n)return t;let r=Ft(e);if(r===`token-plan`)return`token-plan`;if(r!==`ordinary`||t!==`token-plan`)return t}const Lt={console:[`access_token`],openapi:[`access_key_id`,`access_key_secret`,`security_token`],all:[`api_key`,`base_url`,`access_token`,`access_key_id`,`access_key_secret`,`security_token`]};function Rt(e){let t=e.configName,n=e.flags.config!==void 0;return{describe:()=>ot({...e,file:R(t)}),stored(){let e=R(t);return{apiKey:!!e.api_key,console:!!e.access_token,openapi:!!(e.access_key_id||e.access_key_secret||e.security_token),baseUrl:e.base_url,apiKeyCapabilities:e.api_key_capabilities}},resolveBaseUrl:t=>$e(e,t),async login(e){let r=e.api_key?It(e.api_key,t,n):t,i=n||r!==t,a=R(r);for(let[t,n]of Object.entries(e))if(n!==void 0){if(t===`api_key_capabilities`&&Array.isArray(n)){let e=Array.isArray(a[t])?a[t]:[];a[t]=[.../* @__PURE__ */ new Set([...e,...n])]}else a[t]=t===`base_url`?Le(String(n)):n}await Ct(a,r,{activate:i})},async logout(e){let n=R(t),r=Lt[e];if(!r.some(e=>n[e]!==void 0))return!1;for(let e of r)delete n[e];return await Ct(n,t),!0},get path(){return e.configPath??L()}}}function zt(e){return e.length>8?`${e.slice(0,4)}...${e.slice(-4)}`:`***`}const Bt=`bailian-cli`,Vt=`BailianCLI`,Ht=`X-Dashscope-Service`;function Ut(e){return JSON.stringify({channel:Bt,tags:{t1:`public`,t2:e.binName,t3:e.version}})}function z(e){return{"x-dashscope-source-config":Ut(e),"x-dashscope-openapisource":Vt,[Ht]:Bt}}const Wt=e=>(t,n)=>e({...t,headersTimeout:0,bodyTimeout:0},n);function Gt(e){return typeof e!=`object`||!e||e instanceof FormData?!1:JSON.stringify(e).includes(`oss://`)}async function Kt(e,t){let n=Jt((t.timeout??e.settings.timeout)*1e3,t.signal);try{return Yt(await qt(e,t,n.signal),n)}catch(e){throw n.cleanup(),n.signal.aborted?n.signal.reason:e}}async function qt(e,t,n){let r=typeof FormData<`u`&&t.body instanceof FormData,i={"User-Agent":`${e.identity.clientName}/${e.identity.version}`,...z(e.identity),...t.headers};if(!r&&!i[`Content-Type`]&&(i[`Content-Type`]=`application/json`),t.async&&(i[`X-DashScope-Async`]=`enable`),Gt(t.body)&&(i[`X-DashScope-OssResourceResolve`]=`enable`),e.settings.verbose){console.error(`> ${t.method??`GET`} ${t.url}`);let n=i.Authorization;n&&console.error(`> Auth: ${zt(n.replace(/^Bearer /,``))}`),console.error(`> x-dashscope-source-config: ${Ut(e.identity)}`)}let a={method:t.method??`GET`,headers:i,body:t.body?r?t.body:JSON.stringify(t.body):void 0,signal:n,...process.versions.bun?{timeout:!1}:{dispatcher:y.prototype.compose.call(b(),Wt)}},o=await fetch(t.url,a);if(e.settings.verbose){console.error(`< ${o.status} ${o.statusText}`);let e=o.headers.get(`x-request-id`);e&&console.error(`request_id: ${e}`)}if(!o.ok){let e={};try{e=await o.json()}catch{if(n.aborted)throw n.reason}throw Ie(o.status,e,t.url)}return o}function Jt(e,t){let n=new AbortController,r,i=!1,a=t=>{i||(clearTimeout(r),r=setTimeout(()=>n.abort(t),e))},o=()=>n.abort(t?.reason),s=()=>{i=!0,clearTimeout(r),t?.removeEventListener(`abort`,o),n.signal.removeEventListener(`abort`,s)};return n.signal.addEventListener(`abort`,s,{once:!0}),t?.aborted?o():(t?.addEventListener(`abort`,o,{once:!0}),a()),{signal:n.signal,cleanup:s,abort:e=>n.abort(e),pauseTimeout:()=>clearTimeout(r),resetIdleTimeout:()=>a(new P(`Response body idle timeout: no data received for ${e/1e3}s.`,N.TIMEOUT,`Increase --timeout to allow a longer interval between response chunks.`))}}function Yt(e,t){if(!e.body)return t.cleanup(),e;t.pauseTimeout();let n=e.body.getReader(),{signal:r}=t,i=!1,a,o=()=>{i=!0,r.removeEventListener(`abort`,a),t.cleanup()},s=e=>n.cancel(e).finally(()=>n.releaseLock()),c=new ReadableStream({start(e){a=()=>{i||(o(),e.error(r.reason),s(r.reason).catch(()=>{}))},r.addEventListener(`abort`,a,{once:!0}),r.aborted&&a()},async pull(e){try{t.resetIdleTimeout();let r=await n.read();if(t.pauseTimeout(),i)return;r.done?(o(),n.releaseLock(),e.close()):e.enqueue(r.value)}catch(t){if(i)return;o(),n.releaseLock(),e.error(r.aborted?r.reason:t)}},cancel(e){return o(),t.abort(e),s(e).catch(()=>{})}},{highWaterMark:0}),l=new Response(c,{status:e.status,statusText:e.statusText,headers:e.headers});return Object.defineProperties(l,{url:{value:e.url},redirected:{value:e.redirected},type:{value:e.type}}),l}async function Xt(e,t){let n=Jt((t.timeout??e.settings.timeout)*1e3,t.signal);try{let r=await qt(e,t,n.signal),i;try{i=await r.json()}catch{if(n.signal.aborted)throw n.signal.reason;let e=r.headers.get(`content-type`)||``;throw new P(`API returned non-JSON response (${e||`unknown type`}). Server may be experiencing issues.\nAPI 返回了非 JSON 响应(${e||`未知类型`}),服务器可能出现问题。`,N.GENERAL)}if(i.code&&typeof i.code==`string`&&i.code!==`200`&&i.code!==`Success`)throw Ie(200,{error:{message:i.message,type:i.code}},t.url);return i}catch(e){throw n.signal.aborted?n.signal.reason:e}finally{n.cleanup()}}function Zt(e){let t=[];for(let[n,r]of Object.entries(e))if(r!==void 0&&r!==``){if(Array.isArray(r))for(let e=0;e<r.length;e++){let i=r[e];i!==``&&t.push([`${n}.${e+1}`,i])}else t.push([n,r])}return t.sort(([e],[t])=>e<t?-1:+(e>t)),t.map(([e,t])=>`${$t(e)}=${$t(String(t))}`).join(`&`)}function Qt(e){let t=e.method??`POST`,n=(/* @__PURE__ */ new Date()).toISOString().replace(/\.\d{3}Z$/,`Z`),r=re(),i=en(e.body),a={host:e.host,"x-acs-action":e.action,"x-acs-version":e.version,"x-acs-date":n,"x-acs-signature-nonce":r,"x-acs-content-sha256":i,"content-type":`application/json`};e.securityToken&&(a[`x-acs-security-token`]=e.securityToken);let o=Object.keys(a).filter(e=>e===`host`||e===`content-type`||e.startsWith(`x-acs-`)).sort(),s=o.map(e=>`${e}:${a[e]}`).join(`
3
3
  `)+`
4
4
  `,c=o.join(`;`),l=e.queryString??``,u=[t,e.pathname,l,s,c,i].join(`
@@ -26,7 +26,7 @@ ptu_default 仅支持 pre_paid。`:e.chargeType===J.POST_PAID&&Qs(e)?`Prepaid fl
26
26
  当前吞吐预留模型不支持 --thinking-output-tpm。`},async resolve(e){let t={charge_type:e.flags.chargeType,ptu_capacity:Zs(e.flags)};e.flags.serviceTier!==void 0&&(t.service_tier=e.flags.serviceTier),e.flags.suffix!==void 0&&(t.suffix=e.flags.suffix);let n=ec(e.flags);return n!==void 0&&(t.pre_paid_info=n),{body:t}}},rc={name:q.MU,validateFlags(){},async resolve(e){let t=e.flags.billingMethod||Ys,n=e.flags.deploySpec,r=e.flags.capacity;if(!e.dryRun&&!n){let i=()=>new P(`No mu-plan template found for model "${e.model}". Run \`${e.binName} deploy models --source base\` to inspect available models, or pass --deploy-spec explicitly.`,N.USAGE);try{let a=await Us(e.client,{modelSource:`base`,pageSize:100,version:`v1.0`}),o=((a.output??a.data)?.models??[]).find(t=>t.model_name===e.model)?.plans?.find(({plan:e})=>e===q.MU)?.templates??[];if(o.length===0)throw i();let s=t===Js.POST_PAY?J.POST_PAID:J.PRE_PAID,c=o.find(e=>e.charge_type===s)??o[0];if(!c?.deploy_spec&&!c?.template_id)throw i();n=c.deploy_spec??c.template_id,r===void 0&&(r=c.roles?.unified?.capacity_unit_per_instance??1)}catch(e){throw e instanceof P?e:new P(`Failed to auto-pick template for plan=mu: ${e.message}. Pass --deploy-spec explicitly.`,N.USAGE)}}let i={capacity:r??1,billing_method:t};return n&&(i.deploy_spec=n),{body:i}}},ic={[q.LORA]:tc,[q.PTU]:nc,[q.MU]:rc};function ac(e){let t=ic[e];if(!t)throw new P(`Unsupported plan "${e}". Supported plans: ${Object.keys(ic).join(`, `)}.`,N.USAGE);return t}const oc=`zeldaEasy.broadscope-platform.modelInstance.startModelService`,sc=`zeldaEasy.broadscope-platform.modelInstance.stopModelService`,cc=`zeldaEasy.broadscope-platform.modelInstance.listIndependentDeployedModel`;async function lc(e,t){return V(await e.console(oc,{input:{modelServiceId:t}}))}async function uc(e,t){return V(await e.console(sc,{input:{modelServiceId:t}}))}async function dc(e){let t=[],n=1;for(;;){let r=V(await e.console(cc,{input:{pageNo:n,pageSize:50}})),i=r.records??[];t.push(...i);let a=r.pageCount??1;if(n>=a||i.length===0)break;n++}return t}function fc(e,t){return e.find(e=>e.modelServiceId===t||e.deployedModel===t||e.deployed_model===t)}const pc=`speech-biasing`;function mc(e,t){return{model:pc,input:{action:e,...t}}}async function hc(e,t,n,r){return e.requestJson({path:ir(),method:`POST`,body:mc(t,n),signal:r})}function gc(e,t,n){return hc(e,`create_vocabulary`,{target_model:t.targetModel,prefix:t.prefix,vocabulary:t.vocabulary},n)}function _c(e,t={},n){let r={};return t.prefix!==void 0&&(r.prefix=t.prefix),t.pageIndex!==void 0&&(r.page_index=t.pageIndex),t.pageSize!==void 0&&(r.page_size=t.pageSize),hc(e,`list_vocabulary`,r,n)}function vc(e,t,n){return hc(e,`query_vocabulary`,{vocabulary_id:t},n)}function yc(e,t,n,r){return hc(e,`update_vocabulary`,{vocabulary_id:t,vocabulary:n},r)}function bc(e,t,n){return hc(e,`delete_vocabulary`,{vocabulary_id:t},n)}function xc(e,t){try{return JSON.parse(e)}catch(e){throw new F(`${t} is not valid JSON — ${e.message}`)}}function Sc(e){let t=xc(e,`--vocabulary`);if(!t||typeof t!=`object`||Array.isArray(t))throw new F(`--vocabulary must decode to a JSON object of word→weight.`);for(let[e,n]of Object.entries(t))if(typeof n!=`number`||!Number.isFinite(n))throw new F(`--vocabulary weight for "${e}" must be a number.`);return t}function Cc(e,t){let n=`--words`,r=xc(e,n),i;if(Array.isArray(r))i=r.map((e,t)=>{if(!e||typeof e!=`object`||Array.isArray(e))throw new F(`${n} entry #${t} must be an object with string "text" and number "weight".`);let r=e;if(typeof r.text!=`string`||typeof r.weight!=`number`)throw new F(`${n} entry #${t} must have a string "text" and a number "weight".`);if(!Number.isFinite(r.weight))throw new F(`${n} entry #${t} weight must be a finite number.`);return{text:r.text,weight:r.weight,...typeof r.lang==`string`?{lang:r.lang}:{}}});else if(!r||typeof r!=`object`)throw new F(`${n} must decode to a JSON object or array.`);else{i=[];for(let[e,a]of Object.entries(r)){if(typeof a!=`number`||!Number.isFinite(a))throw new F(`${n} weight for "${e}" must be a number.`);i.push({text:e,weight:a,...t?{lang:t}:{}})}}if(i.length===0)throw new F(`${n} must contain at least one hot word.`);return i}const wc={output:{type:`string`,valueHint:`<format>`,description:{"en-US":`Output format: text, json`,"zh-CN":`输出格式:text、json`}},timeout:{type:`number`,valueHint:`<seconds>`,description:{"en-US":`Request timeout`,"zh-CN":`请求超时时间`}},quiet:{type:`switch`,description:{"en-US":`Suppress non-essential output`,"zh-CN":`隐藏非必要输出`}},verbose:{type:`switch`,description:{"en-US":`Print HTTP request/response details`,"zh-CN":`打印 HTTP 请求和响应详情`}},dryRun:{type:`switch`,description:{"en-US":`Dry run mode`,"zh-CN":`仅预览,不实际执行`}},config:{type:`string`,valueHint:`<name>`,description:{"en-US":`Use a config profile for this command`,"zh-CN":`为当前命令使用指定配置 Profile`}},help:{type:`switch`,description:{"en-US":`Show help`,"zh-CN":`显示帮助信息`}},version:{type:`switch`,description:{"en-US":`Print version`,"zh-CN":`显示版本信息`}}},Tc={concurrent:{type:`number`,valueHint:`<n>`,description:{"en-US":`Run N parallel requests (default: 1)`,"zh-CN":`并行发送 N 个请求(默认:1)`}}},Ec={async:{type:`switch`,description:{"en-US":`Return async task id without waiting`,"zh-CN":`直接返回异步任务 ID,不等待任务完成`}}},Dc={apiKey:{type:`string`,valueHint:`<key>`,description:{"en-US":`API key`,"zh-CN":`API Key`}},baseUrl:{type:`string`,valueHint:`<url>`,description:{"en-US":`API base URL`,"zh-CN":`API Base URL`}}},Oc={consoleRegion:{type:`string`,valueHint:`<region>`,description:{"en-US":`Console gateway region (e.g. cn-beijing, ap-southeast-1)`,"zh-CN":`控制台网关地域(例如 cn-beijing、ap-southeast-1)`}},consoleSite:{type:`string`,valueHint:`<site>`,description:{"en-US":`Console site: domestic, international`,"zh-CN":`控制台站点:domestic、international`}},consoleSwitchAgent:{type:`number`,valueHint:`<uid>`,description:{"en-US":`Switch agent UID for delegated access`,"zh-CN":`切换代理访问的 UID`}},workspaceId:{type:`string`,valueHint:`<id>`,description:{"en-US":`Workspace ID (env: BAILIAN_WORKSPACE_ID)`,"zh-CN":`Workspace ID(环境变量:BAILIAN_WORKSPACE_ID)`}}},kc={accessKeyId:{type:`string`,valueHint:`<key>`,description:{"en-US":`Alibaba Cloud Access Key ID (env: ALIBABA_CLOUD_ACCESS_KEY_ID)`,"zh-CN":`阿里云 Access Key ID(环境变量:ALIBABA_CLOUD_ACCESS_KEY_ID)`}},accessKeySecret:{type:`string`,valueHint:`<key>`,description:{"en-US":`Alibaba Cloud Access Key Secret (env: ALIBABA_CLOUD_ACCESS_KEY_SECRET)`,"zh-CN":`阿里云 Access Key Secret(环境变量:ALIBABA_CLOUD_ACCESS_KEY_SECRET)`}},securityToken:{type:`string`,valueHint:`<token>`,description:{"en-US":`Alibaba Cloud STS Security Token (env: ALIBABA_CLOUD_SECURITY_TOKEN)`,"zh-CN":`阿里云 STS Security Token(环境变量:ALIBABA_CLOUD_SECURITY_TOKEN)`}}};function Ac(e){return e.auth===`apiKey`?Dc:e.auth===`console`?Oc:e.auth===`openapi`?kc:{}}function jc(e){return e}const Mc=1;function Nc(e,t){return e.normalize(`NFKC`).replace(/[\\/:*?"<>|]/g,`_`).replace(/\s+/g,`_`).replace(/_+/g,`_`).replace(/^_+|_+$/g,``)||t}function Pc(e,t){return`${Nc(e||`image`,`image`)}_${Nc((t||``).substring(0,20),`untitled`)}_${Date.now()}`}function Fc(e=f()){let t=process.env.HERMES_HOME?.trim();if(t)return Ic(t);if(process.platform===`win32`){let t=process.env.LOCALAPPDATA?.trim();return t?g(t,`hermes`):g(e,`AppData`,`Local`,`hermes`)}return g(e,`.hermes`)}function Ic(e){return e===`~`?f():e.startsWith(`~/`)||e.startsWith(`~\\`)?g(f(),e.slice(2)):e}const Lc=()=>g(f(),`bailian-output`);function Rc(e,t){let n=t?.flagDir||e.outputDir||Lc(),r=t?.subDir?g(n,t.subDir):n;return i(r)||a(r,{recursive:!0}),r}function zc(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Bc(e){return o(e===`-`?0:e,`utf-8`)}async function Vc(e,t){let n=[],r=0;async function i(){for(;r<e.length;){let t=r++;n[t]=await e[t]()}}let a=Array.from({length:Math.min(t,e.length)},()=>i());return await Promise.all(a),n}function Hc(e,t=`boolean`){if(typeof e==`boolean`)return e;if(typeof e==`string`){let t=e.trim().toLowerCase();if(t===`true`)return!0;if(t===`false`)return!1}throw new P(`Invalid ${t} value "${String(e)}". Use true or false.`,N.USAGE)}function Uc(e,t=`boolean`){if(e!=null)return Hc(e,t)}function Wc(e,t,n=`boolean`){let r=Uc(e,n);return r===void 0?t:r}function Gc(e,t){return Uc(e,`watermark`)??t??!0}function Kc(e){let t={command:e.command,timestamp:(/* @__PURE__ */ new Date()).toISOString(),durationMs:e.durationMs,success:e.success,cliVersion:e.cliVersion,nodeVersion:process.version,os:process.platform};return e.authMethod&&(t.authMethod=e.authMethod),!e.success&&e.error&&(e.error.message&&(t.errorMessage=e.error.message),e.error.exitCode!==void 0&&(t.exitCode=e.error.exitCode),e.error.httpStatus!==void 0&&(t.httpStatus=e.error.httpStatus),e.error.requestId&&(t.requestId=e.error.requestId)),e.params&&Object.keys(e.params).length>0&&(t.params=e.params),t}function qc(e){if(e==null)return;let t=typeof e==`string`?e:JSON.stringify(e);return t.length<=500?t:t.slice(0,500)}function Jc(e){let{command:t,params:n,...r}=e,i={et:`EXP`,ext:r,c1:n,c2:e.success?`success`:`failure`};return e.httpStatus!==void 0&&(i.c3=String(e.httpStatus)),e.errorMessage&&(i.c4=qc(e.errorMessage)),e.requestId&&(i.c5=e.requestId),i}let Y;function Yc(){return Y||(process.env.NODE_ENV===`development`?(Y=`dev`,Y):process.env.BAILIAN_COMPILED===`1`?(Y=`prod`,Y):(Y=import.meta.url.includes(`/node_modules/`)?`prod`:`dev`,Y))}var Xc=/* @__PURE__ */ je(((e,t)=>{t.exports=(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t||4&t&&typeof e==`object`&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&typeof e!=`string`)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=8)})([function(e,t){e.exports=Pe(`os`)},function(e,t){e.exports=globalThis.fetch},function(e,t,n){e.exports=n(6)},function(e,t){e.exports=Pe(`dns`)},function(e,t){e.exports=Pe(`util`)},function(e,t){e.exports=Pe(`crypto`)},function(e,t,n){Object.defineProperty(t,Symbol.toStringTag,{value:`Module`});let r=n(7),i=(e,t)=>{t.appName=`BaiduSpider`,t.appVersion=e.value,t.deviceBrand=`Baidu`,t.deviceType=`bot`,t.platform=`other`},a=(e,t)=>{t.appName=`360 Spider`,t.appVersion=e.value,t.deviceBrand=`360`,t.deviceType=`bot`,t.platform=`other`},o=(e,t)=>{t.appName=`BingBot`,t.appVersion=e.value,t.deviceBrand=`Microsoft`,t.deviceType=`bot`,t.platform=`other`},s=(e,t)=>{t.appName=`Googlebot`,t.appVersion=e.value,t.deviceBrand=`Google`,t.deviceType=`bot`,t.platform=`other`},c=(e,t)=>{t.appName=`YandexBot`,t.appVersion=e.value,t.deviceBrand=`Yandex`,t.deviceType=`bot`,t.platform=`other`},l=(e,t)=>{e.getPreviousNTokens(3)===`Sogou web spider`&&(t.deviceBrand=`Sogou.com`,t.appName=`SogouSpider`),t.appVersion=e.value,t.deviceType=`bot`},u=(e,t)=>{t.appName=`DataproviderBot`,t.appVersion=e.value,t.deviceBrand=`Dataprovider.com`,t.deviceType=`bot`,t.platform=`other`},d=(e,t)=>{t.appName=`AhrefsBot`,t.appVersion=e.value,t.deviceBrand=`Ahrefs`,t.deviceType=`bot`,t.platform=`other`},f=(e,t)=>{t.appName=`BitSightBot`,t.appVersion=e.value,t.deviceBrand=`Bitsight`,t.deviceType=`bot`,t.platform=`other`},p=(e,t)=>{t.appName=`oBot`,t.appVersion=e.value,t.deviceBrand=`IBM`,t.deviceType=`bot`,t.platform=`other`},m=(e,t)=>{t.appName=`Cincraw`,t.appVersion=e.value,t.deviceBrand=`CINC`,t.deviceType=`bot`,t.platform=`other`},h=(e,t)=>{t.appName=`DingTalkBot`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},g=(e,t)=>{t.appName=`YisouSpider`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},_=(e,t)=>{t.appName=`ByteSpider`,t.appVersion=e.value,t.deviceBrand=`ByteDance`,t.deviceType=`bot`,t.platform=`other`},v=(e,t)=>{t.appName=`HeadlineCrawler`,t.appVersion=e.value,t.deviceBrand=`Headline.com`,t.deviceType=`bot`,t.platform=`other`},y=(e,t)=>{t.appName=`BitDiscoveryBot`,t.appVersion=e.value,t.deviceBrand=`Tenable`,t.deviceType=`bot`,t.platform=`other`},b=(e,t)=>{e.getPreviousNTokens(4)===`Screaming Frog SEO Spider`&&(t.deviceBrand=`Screaming Frog`,t.appName=`Screaming Frog`),t.appVersion=e.value,t.deviceType=`bot`},ee=(e,t)=>{t.appName=`Ai2Bot`,t.appVersion=e.value,t.deviceBrand=`Ai2`,t.deviceType=`bot`,t.platform=`other`},te=(e,t)=>{t.appName=`DianjingAdSpider`,t.appVersion=e.value,t.deviceBrand=`Dianjing`,t.deviceType=`bot`,t.platform=`other`},ne=(e,t)=>{t.appName=`BaiduSpider`,t.appVersion=e.value,t.deviceBrand=`Baidu`,t.deviceType=`bot`,t.platform=`other`},re=(e,t)=>{t.appName=`360 Spider`,t.appVersion=e.value,t.deviceBrand=`360`,t.deviceType=`bot`,t.platform=`other`},ie=(e,t)=>{t.appName=`BingBot`,t.appVersion=e.value,t.deviceBrand=`Microsoft`,t.deviceType=`bot`,t.platform=`other`},x=(e,t)=>{t.appName=`Googlebot`,t.appVersion=e.value,t.deviceBrand=`Google`,t.deviceType=`bot`,t.platform=`other`},ae=(e,t)=>{t.appName=`YandexBot`,t.appVersion=e.value,t.deviceBrand=`Yandex`,t.deviceType=`bot`,t.platform=`other`},oe=(e,t)=>{e.getPreviousNTokens(3)===`Sogou web spider`&&(t.deviceBrand=`Sogou.com`,t.appName=`SogouSpider`),t.appVersion=e.value,t.deviceType=`bot`},se=(e,t)=>{t.appName=`DataproviderBot`,t.appVersion=e.value,t.deviceBrand=`Dataprovider.com`,t.deviceType=`bot`,t.platform=`other`},ce=(e,t)=>{t.appName=`AhrefsBot`,t.appVersion=e.value,t.deviceBrand=`Ahrefs`,t.deviceType=`bot`,t.platform=`other`},le=(e,t)=>{t.appName=`BitSightBot`,t.appVersion=e.value,t.deviceBrand=`Bitsight`,t.deviceType=`bot`,t.platform=`other`},S=(e,t)=>{t.appName=`oBot`,t.appVersion=e.value,t.deviceBrand=`IBM`,t.deviceType=`bot`,t.platform=`other`},C=(e,t)=>{t.appName=`Cincraw`,t.appVersion=e.value,t.deviceBrand=`CINC`,t.deviceType=`bot`,t.platform=`other`},w=(e,t)=>{t.appName=`DingTalkBot`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},T=(e,t)=>{t.appName=`YisouSpider`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},E=(e,t)=>{t.appName=`ByteSpider`,t.appVersion=e.value,t.deviceBrand=`ByteDance`,t.deviceType=`bot`,t.platform=`other`},ue=(e,t)=>{t.appName=`HeadlineCrawler`,t.appVersion=e.value,t.deviceBrand=`Headline.com`,t.deviceType=`bot`,t.platform=`other`},de=(e,t)=>{t.appName=`BitDiscoveryBot`,t.appVersion=e.value,t.deviceBrand=`Tenable`,t.deviceType=`bot`,t.platform=`other`},D=(e,t)=>{e.getPreviousNTokens(4)===`Screaming Frog SEO Spider`&&(t.deviceBrand=`Screaming Frog`,t.appName=`Screaming Frog`),t.appVersion=e.value,t.deviceType=`bot`},O=(e,t)=>{t.appName=`Ai2Bot`,t.appVersion=e.value,t.deviceBrand=`Ai2`,t.deviceType=`bot`,t.platform=`other`},fe=(e,t)=>{t.appName=`DianjingAdSpider`,t.appVersion=e.value,t.deviceBrand=`Dianjing`,t.deviceType=`bot`,t.platform=`other`},k=/* @__PURE__ */ new Map,A=/* @__PURE__ */ new Map;k.set(`Baiduspider-render`,i),k.set(`Baiduspider+`,i),k.set(`Baiduspider-image+`,i),k.set(`360Spider`,a),k.set(`360Spider-Image`,a),k.set(`bingbot`,o),k.set(`Googlebot`,s),k.set(`YandexRenderResourcesBot`,c),k.set(`spider`,l),k.set(`Dataprovider.com`,u),k.set(`AhrefsBot`,d),k.set(`BitSightBot`,f),k.set(`oBot`,p),k.set(`Cincraw`,m),k.set(`DingTalkBot-LinkService`,h),k.set(`YisouSpider`,g),k.set(`Bytespider`,_),k.set(`ev-crawler`,v),k.set(`bitdiscovery`,y),k.set(`Spider`,b),k.set(`Ai2Bot-Dolma`,ee),k.set(`dianjing_ad_spider`,te),A.set(`Baiduspider-render`,ne),A.set(`Baiduspider+`,ne),A.set(`Baiduspider-image+`,ne),A.set(`360Spider`,re),A.set(`360Spider-Image`,re),A.set(`bingbot`,ie),A.set(`Googlebot`,x),A.set(`YandexRenderResourcesBot`,ae),A.set(`spider`,oe),A.set(`Dataprovider.com`,se),A.set(`AhrefsBot`,ce),A.set(`BitSightBot`,le),A.set(`oBot`,S),A.set(`Cincraw`,C),A.set(`DingTalkBot-LinkService`,w),A.set(`YisouSpider`,T),A.set(`Bytespider`,E),A.set(`ev-crawler`,ue),A.set(`bitdiscovery`,de),A.set(`Spider`,D),A.set(`Ai2Bot-Dolma`,O),A.set(`dianjing_ad_spider`,fe);let pe={productHandlerMap:k,commentHandlerMap:A,getSpecialProductHandler:()=>null,getSpecialCommentHandler:()=>null,getDefaultModelHandler:()=>null};t.isBot=function(e){let t=r.createUAInfo();return r.runTask(e,t,pe),t.deviceType===`bot`}},function(e,t){function n(e){let t=[],n={parent:e,tokens:t,get firstToken(){return t.length===0?null:t[0]},getNewToken(r){let i=(function(){let e=[],t=[],n=[],r=null,i=null,a=null,o=!0,s=!0,c=!0,l=null,u={get key(){return o&&=(r=e.join(``),!1),r},get value(){return s&&=(i=t.join(``),!1),i},get originValue(){return c&&=(a=n.join(``),!1),a},previousToken:null,properties:null,appendKey(t){e.push(t),o=!0},appendValue(e){t.push(e===`_`?`.`:e),n.push(e),s=!0,c=!0,l=null},getSplitValue(e){if(l===null){let e=u.value;l=e===``?[]:e.split(`/`)}return e>=0&&e<l.length?l[e]:null},getPreviousNTokens(e){let t=[],n=u;for(let r=0;r<e;r++){if(n==null)return null;t.unshift(n.key),n=n.previousToken}return t.join(` `)}};return u})();return t.push(i),i.previousToken=r===void 0?t.length>1?t[t.length-2]:null:r,e&&(e.properties=n),i},getLastToken:()=>t.length===0?null:t[t.length-1],getFirstToken:()=>t.length===0?null:t[0],isEmpty:()=>t.length===0};return n}function r(){return{appName:null,appVersion:null,browserName:null,browserVersion:null,engineName:null,engineVersion:null,deviceBrand:null,deviceModel:null,deviceType:`mobile`,osName:null,osVersion:null,platform:`web`,tokenGroup:n(null)}}let i=new Set(` ;,"'`.split(``)),a=new Set(`/=:`.split(``)),o=/* @__PURE__ */ new Set([`Mozilla`,`AppleWebKit`,`Safari`,`Opera`,`Dalvik`,`com.ss.android.ugc.aweme`]);function s(e){return e.length===1&&i.has(e)}function c(e){return e.length===1&&a.has(e)}function l(e,t,n,r){if(e==null)return;let i=t.parent,a=e.key,s=null;if(i!=null){let e=i.key;o.has(e)?(s=r.commentHandlerMap.get(a)??null,s??=r.getSpecialCommentHandler(a),s==null&&a.endsWith(` Build`)&&(s=r.getDefaultModelHandler())):s=r.productHandlerMap.get(a)??r.getSpecialProductHandler(a)}else s=r.productHandlerMap.get(a)??r.getSpecialProductHandler(a);if(s!=null)try{s(e,n)}catch{}}function u(e,t,r){if(e==null)throw Error(`input can not be null`);return(function e(t,r,i,a,o){let u,d=null,f=null,p=!1,m=t.length,h=r>0?t[r-1]:`\0`;for(u=r;u<m;u++){let g=t[u];if(s(g)){let e=h!==`\0`&&s(h);if(!p&&r>0&&g===` `&&!e){let e=u+1;if(e<m){let n=t[e];/\d/.test(n)||n===`-`?p=!0:f?.appendKey(g)}else f?.appendKey(g)}else f!=null&&(d=f,f=null);h=g}else if(g===`(`){if(h===`(`){h=g;continue}let r=u;u=e(t,u+1,n(i.getLastToken()),a,o),f!=null&&(d=f,f=null),h=t[r]}else{if(g===`)`){if(r===0){h=g;continue}break}f??(l(i.getLastToken(),i,a,o),f=i.getNewToken(d),p=!1),c(g)?(p&&f.appendValue(g),p=!0):p?f.appendValue(g):f.appendKey(g),h=g}}return l(i.getLastToken(),i,a,o),u})(e,0,t.tokenGroup,t,r),t}Object.defineProperty(t,"DEFAULT_MODEL_HANDLER_KEY",{enumerable:!0,get:function(){return`DEFAULT_MODEL_HANDLER`}}),Object.defineProperty(t,"createUAInfo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"runTask",{enumerable:!0,get:function(){return u}})},function(e,t,n){n.r(t);var r=n(0),i=n.n(r),a=n(1),o=n.n(a);n(2);function s(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:20,t=arguments.length>1?arguments[1]:void 0;return t||=``,e?s(--e,`0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz`.charAt(Math.floor(60*Math.random()))+t):t}function c(e,t){for(var n in t)e[n]=t[n];return e}function l(e){return Object.prototype.toString.call(e)===`[object Object]`}function u(e){return typeof Promise<`u`&&e instanceof Promise}var d=Object.freeze({__aesBeforeSkip:1}),f=function(e){var t=Object.prototype.toString.call(e);if(t===`[object String]`&&e||t===`[object Number]`||t===`[object Boolean]`)return e;if(t===`[object Object]`||t===`[object Array]`)try{return JSON.stringify(e)}catch{}},p=function(e){var t={};for(var n in e){var r=e[n];r!==void 0&&(t[n]=f(r))}return t},m=function(e){var t=[];for(var n in e){var r=f(e[n]);r!==void 0&&t.push(`${n}=${encodeURIComponent(r)}`)}return t.join(`&`)};function h(e){return(e.requiredFields||[]).concat([`pid`]).some(function(t){return e[t]===void 0})}function g(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:``,t=arguments.length>1?arguments[1]:void 0;typeof console<`u`&&console.warn(`日志解析报错,埋点将被丢弃 => ${e}`,t)}var _=`AEM_TRACKER_UNIQUE_PVID`,v=typeof globalThis<`u`&&globalThis?globalThis:typeof window<`u`&&window?window:typeof global<`u`&&global?global:typeof self<`u`&&self?self:(console.error(`Unable to locate global object in current environment`),{});function y(e){this._queue=[],this._reqQueue=[],this._plugins={},this._subscribers={onConfigUpdated:[]},this._timeout=0,this._config={sdk_version:`3.3.18`,set pv_id(e){v[_]=e},get pv_id(){return v[_]||(v[_]=s()),v[_]},timezone_offset:(/* @__PURE__ */ new Date()).getTimezoneOffset()},e&&(this._config=c(this._config,e))}y.prototype={constructor:y,_sendAll:function(){if(this._timeout&&=(clearTimeout(this._timeout),0),this._queue.length){var e,t=this._config.maxUrlLength||3e4,n=this._getSendConfig();try{e=this._processData(this._queue,n)}catch{}if(e&&e.length<t)return this._queue=[],void this.send(e);for(var r,i=[];this._queue.length;){i.push(this._queue.shift());try{r=this._processData(i,n)}catch(e){var a=i.pop();g(e.message,a);continue}if(r.length>t){i.length>1&&(this._queue.unshift(i.pop()),r=this._processData(i,n));break}}r&&this.send(r),this._queue.length&&this._sendAll()}},_send:function(e,t){var n=this;if(!1===t){var r;try{r=this._processData([e])}catch(t){g(t.message,e)}r&&this.send(r)}else{this._queue.push(e);var i=this._config.mergeRequestInterval||500;this._timeout||=setTimeout(function(){n._sendAll()},i)}},_getSendConfig:function(){var e={},t=this._config;for(var n in t)n!==`requiredFields`&&n!==`maxUrlLength`&&n!==`queueGlobalName`&&n!==`debug`&&n!==`excludeCrawlers`&&n!==`collectClientHints`&&n.indexOf(`plugin`)!==0&&t[n]!==``&&t[n]!==null&&t[n]!==void 0&&(e[n]=f(t[n]));return e},_processData:function(e,t){t||=this._getSendConfig();var n=m(t);return n+=`&msg=`+encodeURIComponent(e.map(function(e){return m(e)}).join(`|`))},setConfig:function(e,t){var n=this,r={};t===void 0?r=e:r[e]=t;var i=!(function e(t,n){if(t===void 0||n===void 0||!l(t)||!l(n))return!1;for(var r in t)if(l(t[r])){if(!e(t[r],n[r]))return!1}else if(t[r]!==n[r])return!1;return!0})(r,this._config),a=function(){if(i){for(var e in r)l(r[e])?n._config[e]=c(n._config[e]||{},r[e]):n._config[e]=r[e];n._execSubscribe(`onConfigUpdated`,[r,n._config])}};this._reqQueue.length?(a(),h(this._config)||(this._reqQueue.forEach(function(e){n._send.apply(n,e)}),this._reqQueue=[])):(i&&this._sendAll(),a())},getConfig:function(e){return e?this._config[e]:this._config},updatePVID:(function(e,t){if(typeof e!=`function`)throw TypeError(`Expected a function`);t=typeof t==`number`&&t>=0?t:100;var n=null;return function(){if(n===null){var r=this,i=Array.prototype.slice.call(arguments);n=setTimeout(function(){n=null},t),e.apply(r,i)}}})(function(){v[_]=s()},200),log:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};e&&(t.ts=t.ts||(/* @__PURE__ */ new Date()).getTime(),t.type=e,this._print(`log`,e,t),t=p(t),h(this._config)?this._reqQueue.length<1e3&&this._reqQueue.push([t,n.combo]):this._send(t,n.combo))},before:function(e,t){var n=this;return function(){var r=arguments,i=t.apply(n,r);i!==d&&(u(i)?i.then(function(t){t!==d&&e.apply(n,t||r)}):e.apply(n,i||r))}},after:function(e,t){var n=this;return function(){var r=arguments;e.apply(n,r),t.apply(n,r)}},use:function(e,t){var n=this;return Object.prototype.toString.call(e)===`[object Array]`?e.map(function(e){if(Object.prototype.toString.call(e)===`[object Array]`){var t=e[0],r=e[1];return n._plugins[t]||(n._plugins[t]=new t(n,r))}return n._plugins[e]||(n._plugins[e]=new e(n))}):this._plugins[e]||(this._plugins[e]=new e(this,t))},_print:function(){this._config.debug&&typeof console<`u`&&console.log.apply(console,arguments)},onConfigUpdated:function(e){this._subscribers.onConfigUpdated&&this._subscribers.onConfigUpdated.push(e)},_execSubscribe:function(e,t){this._subscribers[e]&&this._subscribers[e].forEach(function(e){e.apply(this,t)})}};var b=y,ee=n(3),te=n.n(ee),ne=n(4),re=n(5),ie=n.n(re);function x(e){return(x=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e})(e)}function ae(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function oe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ae(Object(n),!0).forEach(function(t){se(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ae(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function se(e,t,n){return(t=(function(e){var t=(function(e,t){if(x(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(x(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)})(e,`string`);return x(t)==`symbol`?t:t+``})(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ce(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=S(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
27
27
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function le(e,t){return(function(e){if(Array.isArray(e))return e})(e)||(function(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}})(e,t)||S(e,t)||(function(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
28
28
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)})()}function S(e,t){if(e){if(typeof e==`string`)return C(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?C(e,t):void 0}}function C(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function w(){for(var e=/(?:[0]{1,2}[:-]){5}[0]{1,2}/,t=i.a.networkInterfaces(),n=0,r=Object.entries(t);n<r.length;n++){var a=le(r[n],2),o=(a[0],a[1]);if(o){var s,c=ce(o);try{for(c.s();!(s=c.n()).done;){var l=s.value;if(!1===e.test(l.mac))return l.mac}}catch(e){c.e(e)}finally{c.f()}}}return`00:00:00:00:00:00`}var T,E,ue=(T=process.version,{os:i.a.type(),os_version:i.a.release(),app_name:`node`,app_version:T,device_id:ie.a.createHash(`md5`).update(w()).digest(`hex`),platform:`node`}),de=(0,ne.promisify)(te.a.resolve);function D(e){this._offlineQueue=[],e.endpoint=e.endpoint||`gm.mmstat.com`,b.call(this,oe(oe({},ue),e)),this._config.endpoint_url=`https://${this._config.endpoint}/aes.1.1`}D.prototype=((E=function(){}).prototype=b.prototype,new E),D.prototype.constructor=D,D.prototype.send=function(e){var t,n=this;return(t=this._config.endpoint,de(t)).then(function(t){return n._offlineQueue.forEach(function(e){n.send(e)}),n._offlineQueue=[],n._print(`send`,e),o()(n._config.endpoint_url,{method:`POST`,keepalive:!0,body:JSON.stringify({gokey:encodeURIComponent(e),gmkey:`EXP`})}).catch(function(){})}).catch(function(t){n._offlineQueue.length>500&&n._offlineQueue.shift(),n._offlineQueue.push(e)})},t.default=D}]).default})),Zc=/* @__PURE__ */ je(((e,t)=>{t.exports=(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t||4&t&&typeof e==`object`&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&typeof e!=`string`)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=0)})([function(e,t,n){n.r(t);var r=[`ec`,`ea`,`el`,`et`],i=function(e,t){var n=function(e){var n=e.ec,r=e.ea,i=e.el,a=e.et,o=a===void 0?`CLK`:a,s=e.xpath;delete e.ec,delete e.ea,delete e.el,delete e.et,delete e.xpath,e.p1=n,e.p2=r,e.p3=i,e.p4=o,e.p5=s;try{t.log(`event`,e)}catch{}};return function(){var t=arguments,i={};if(t.length!==0){for(var a=0;a<t.length;a++){var o,s,c=t[a];if(a!==0&&typeof c==`object`&&a!==t.length-1)return void(e==null||(o=e.console)==null||(s=o.warn)==null||s.call(o,`Only the last argument can be object type`));if(typeof c==`string`||typeof c==`number`)i[r[a]]=c;else if(typeof c==`object`&&a===t.length-1)for(var l in c)c.hasOwnProperty(l)&&(i[l]=c[l])}n(i)}else{var u,d;(u=e.console)==null||(d=u.warn)==null||d.call(u,`At lease one augument`)}}};t.default=function(e,t){return i(global,e)}}]).default})),Qc=/* @__PURE__ */ Ne(Xc(),1),$c=/* @__PURE__ */ Ne(Zc(),1);const el=()=>g(I(),`telemetry.jsonl`);let tl;const nl=/* @__PURE__ */ new Set;let rl;try{let e=new Qc.default({pid:`bailian-cli-node`,env:Yc()}),t=e.send.bind(e);e.send=function(e){let n=t(e);if(n&&typeof n.then==`function`){let e=n;nl.add(e),e.finally(()=>nl.delete(e))}return n},rl=e,tl=e.use($c.default)}catch{}async function il(e=1e3){try{if(rl)try{typeof rl._sendAll==`function`&&rl._sendAll()}catch{}if(nl.size===0)return;let t=[...nl].map(e=>e.catch(()=>void 0));await Promise.race([Promise.allSettled(t),new Promise(t=>setTimeout(t,e).unref?.())])}catch{}}async function al(e){try{await ct();let n=el();try{l(n).size>5242880&&u(n)}catch{}t(n,JSON.stringify(e)+`
29
- `,{mode:384})}catch{}}async function ol(e){try{if(!tl)return;tl(e.command,Jc(e))}catch{}}const sl=/* @__PURE__ */ new Set([`apiKey`,`baseUrl`,`output`,`quiet`,`verbose`,`timeout`,`dryRun`,`help`,`console`]),cl=/* @__PURE__ */ new Set(/* @__PURE__ */ `page.pageSize.n.count.model.voice.language.provider.capability.temperature.topP.topK.maxTokens.seed.stream.size.resolution.ratio.duration.format.audioFormat.sampleRate.pitch.rate.volume.api.mode.download.textOnly.promptExtend.enableSsml.watermark.hasThoughts.listTools.rerank.rerankTopN.diarization`.split(`.`));function ll(e){let t={};for(let[n,r]of Object.entries(e))n.startsWith(`_`)||sl.has(n)||cl.has(n)&&r!==void 0&&r!==!1&&(t[n]=r);return t}async function ul(e,t,n,r){if(!e.settings.telemetry){await r();return}let i=performance.now(),a=!0,o,s,c,l;try{await r()}catch(e){throw a=!1,e instanceof P?(o=e.message,s=e.exitCode,c=e.api?.httpStatus,l=e.api?.requestId):e instanceof Error&&(o=e.message),e}finally{let r=Math.round(performance.now()-i),u=Kc({command:t.join(` `),durationMs:r,success:a,error:a?void 0:{message:o,exitCode:s,httpStatus:c,requestId:l},cliVersion:e.identity.version,authMethod:e.authMethod,params:ll(n)});al(u).catch(()=>{}),ol(u).catch(()=>{})}}function dl(e){if(!e.model)return null;let t=e.inferenceMetadata;return{model:e.model,name:e.name??e.model,description:e.description??e.shortDescription??``,shortDescription:e.shortDescription,provider:e.provider??``,capabilities:e.capabilities??[],features:e.features??[],category:e.category,contextWindow:e.contextWindow??void 0,maxOutputTokens:e.maxOutputTokens??void 0,maxInputTokens:e.maxInputTokens??void 0,docUrl:e.docUrl,collectionTag:e.collectionTag,inferenceMetadata:t,prices:e.prices,qpmInfo:e.qpmInfo,versionTag:e.versionTag,openSource:e.openSource}}var fl=class{settings;name=`api`;constructor(e){this.settings=e}available(){return!0}async load(){return(await Gi(An(this.settings))).map(dl).filter(e=>e!==null)}};function pl(){return M(I(),`skills/bailian-docs-llm-wiki`)}function ml(){return M(pl(),`models`,`models.jsonl`)}function hl(e){return!e.model||typeof e.model!=`string`?null:{model:e.model,name:e.name??e.model,description:e.description??``,provider:e.provider??``,capabilities:e.capabilities??[],features:e.features??[],contextWindow:e.contextWindow,maxOutputTokens:e.maxOutputTokens,docUrl:e.docUrl,inferenceMetadata:e.inferenceMetadata,shortDescription:e.shortDescription,category:e.category,collectionTag:e.collectionTag,maxInputTokens:e.maxInputTokens,prices:e.prices,qpmInfo:e.qpmInfo,versionTag:e.versionTag,openSource:e.openSource,family:e.family,familyName:e.familyName}}function gl(e){let t=T(e,`utf-8`).split(`
29
+ `,{mode:384})}catch{}}async function ol(e){try{if(!tl)return;tl(e.command,Jc(e))}catch{}}const sl=/* @__PURE__ */ new Set([`apiKey`,`baseUrl`,`output`,`quiet`,`verbose`,`timeout`,`dryRun`,`help`,`console`]),cl=/* @__PURE__ */ new Set(/* @__PURE__ */ `page.pageSize.n.count.model.voice.language.provider.capability.temperature.topP.topK.maxTokens.seed.stream.size.resolution.ratio.duration.format.audioFormat.sampleRate.pitch.rate.volume.api.mode.download.textOnly.promptExtend.enableSsml.watermark.hasThoughts.listTools.rerank.rerankTopN.diarization`.split(`.`));function ll(e){let t={};for(let[n,r]of Object.entries(e))n.startsWith(`_`)||sl.has(n)||cl.has(n)&&r!==void 0&&r!==!1&&(n!==`page`||typeof r==`number`&&Number.isFinite(r))&&(t[n]=r);return t}async function ul(e,t,n,r){if(!e.settings.telemetry){await r();return}let i=performance.now(),a=!0,o,s,c,l;try{await r()}catch(e){throw a=!1,e instanceof P?(o=e.message,s=e.exitCode,c=e.api?.httpStatus,l=e.api?.requestId):e instanceof Error&&(o=e.message),e}finally{let r=Math.round(performance.now()-i),u=Kc({command:t.join(` `),durationMs:r,success:a,error:a?void 0:{message:o,exitCode:s,httpStatus:c,requestId:l},cliVersion:e.identity.version,authMethod:e.authMethod,params:ll(n)});al(u).catch(()=>{}),ol(u).catch(()=>{})}}function dl(e){if(!e.model)return null;let t=e.inferenceMetadata;return{model:e.model,name:e.name??e.model,description:e.description??e.shortDescription??``,shortDescription:e.shortDescription,provider:e.provider??``,capabilities:e.capabilities??[],features:e.features??[],category:e.category,contextWindow:e.contextWindow??void 0,maxOutputTokens:e.maxOutputTokens??void 0,maxInputTokens:e.maxInputTokens??void 0,docUrl:e.docUrl,collectionTag:e.collectionTag,inferenceMetadata:t,prices:e.prices,qpmInfo:e.qpmInfo,versionTag:e.versionTag,openSource:e.openSource}}var fl=class{settings;name=`api`;constructor(e){this.settings=e}available(){return!0}async load(){return(await Gi(An(this.settings))).map(dl).filter(e=>e!==null)}};function pl(){return M(I(),`skills/bailian-docs-llm-wiki`)}function ml(){return M(pl(),`models`,`models.jsonl`)}function hl(e){return!e.model||typeof e.model!=`string`?null:{model:e.model,name:e.name??e.model,description:e.description??``,provider:e.provider??``,capabilities:e.capabilities??[],features:e.features??[],contextWindow:e.contextWindow,maxOutputTokens:e.maxOutputTokens,docUrl:e.docUrl,inferenceMetadata:e.inferenceMetadata,shortDescription:e.shortDescription,category:e.category,collectionTag:e.collectionTag,maxInputTokens:e.maxInputTokens,prices:e.prices,qpmInfo:e.qpmInfo,versionTag:e.versionTag,openSource:e.openSource,family:e.family,familyName:e.familyName}}function gl(e){let t=T(e,`utf-8`).split(`
30
30
  `).filter(Boolean),n=[];for(let e of t)try{let t=hl(JSON.parse(e));t&&n.push(t)}catch{}return n}var _l=class{name=`catalog`;constructor(e){}available(){return S(ml())}async load(){return this.available()?gl(ml()):[]}};async function vl(e,t){let n=[new _l({onPrepareStart:t?.onPrepareStart}),new fl(e)];for(let e of n)if(e.available()){let t=await e.load();if(t.length>0)return t}let r=await n[0].load();if(r.length>0)return r;throw new P(`No model data available.`,N.GENERAL)}const yl={Text:`Text`,Image:`Image`,Video:`Video`,Audio:`Audio`},X={Single:`single`,Pipeline:`pipeline`},bl={Low:`low`,Medium:`medium`,High:`high`},xl={Standard:`standard`,Large:`large`,ExtraLarge:`extra-large`},Z={Flagship:`flagship`,Balanced:`balanced`,CostOptimized:`cost-optimized`},Q={TG:`TG`,Reasoning:`Reasoning`,VU:`VU`,IG:`IG`,VG:`VG`,TTS:`TTS`,ASR:`ASR`,RealtimeASR:`Realtime-ASR`,RealtimeTTS:`Realtime-Text-to-Speech`,RealtimeAudioTranslate:`Realtime-Audio-Translate`,RealtimeOmni:`Realtime-Omni`,MultimodalOmni:`Multimodal-Omni`,ME:`ME`,TR:`TR`,ThreeDGeneration:`3D-generation`},Sl={FunctionCalling:`function-calling`,WebSearch:`web-search`,StructuredOutputs:`structured-outputs`,PrefixCompletion:`prefix-completion`},Cl={Flagship:`Flagship`,CostOptimized:`Cost-optimized`},wl=20,Tl=/-\d{4}-\d{2}-\d{2}$/,El=/* @__PURE__ */ new Set([Q.IG,Q.VG,Q.TTS,Q.RealtimeTTS,Q.ThreeDGeneration]),Dl=/* @__PURE__ */ new Set([Q.TG,Q.Reasoning,Q.ASR,Q.RealtimeASR,Q.RealtimeAudioTranslate,Q.TR,Q.ME]),Ol={standard:0,large:32e3,"extra-large":128e3};console.assert(!0,`FUSION_HARD_WEIGHT + FUSION_SOFT_WEIGHT must sum to 1`),console.assert(!0,`HARD_WEIGHT_* sub-weights must sum to 1`);const kl=`You are a model recommendation advisor for Alibaba Cloud Model Studio. From the candidate models below, select the best recommendations.
31
31
 
32
32
  CRITICAL: You MUST respond entirely in English. Do not use any Chinese characters anywhere in your response. Every field — reason, highlights, step, summary — must be written in English.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bailian-cli-core",
3
- "version": "2.3.3",
3
+ "version": "2.4.0",
4
4
  "description": "Core SDK for bailian-cli. See https://www.npmjs.com/package/bailian-cli for usage.",
5
5
  "homepage": "https://bailian.console.aliyun.com/cli",
6
6
  "bugs": {