bailian-cli 1.0.2 → 1.0.3
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/README.md +1 -1
- package/README_CN.md +1 -1
- package/dist/bailian.mjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
[](https://www.typescriptlang.org)
|
|
12
12
|
[](LICENSE)
|
|
13
13
|
|
|
14
|
-
[Aliyun Model Studio CLI Site](https://bailian.console.aliyun.com/cli) · [中文文档](README_CN.md) · [API Documentation](https://help.aliyun.com/zh/model-studio/) · [Get API Key](https://bailian.console.aliyun.com/cn-beijing/?tab=app#/api-key)
|
|
14
|
+
[Aliyun Model Studio CLI Site](https://bailian.console.aliyun.com/cli) · [中文文档](https://unpkg.com/bailian-cli/README_CN.md) · [API Documentation](https://help.aliyun.com/zh/model-studio/) · [Get API Key](https://bailian.console.aliyun.com/cn-beijing/?tab=app#/api-key)
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
package/README_CN.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
[](https://www.typescriptlang.org)
|
|
12
12
|
[](LICENSE)
|
|
13
13
|
|
|
14
|
-
[阿里云百炼 CLI 官方主页](https://bailian.console.aliyun.com/cli) · [English](README.md) · [API 文档](https://help.aliyun.com/zh/model-studio/) · [获取 API Key](https://bailian.console.aliyun.com/cn-beijing/?tab=app#/api-key)
|
|
14
|
+
[阿里云百炼 CLI 官方主页](https://bailian.console.aliyun.com/cli) · [English](https://unpkg.com/bailian-cli/README.md) · [API 文档](https://help.aliyun.com/zh/model-studio/) · [获取 API Key](https://bailian.console.aliyun.com/cn-beijing/?tab=app#/api-key)
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
package/dist/bailian.mjs
CHANGED
|
@@ -131,7 +131,7 @@ This process keeps the local port open for the console; press Ctrl+C when finish
|
|
|
131
131
|
`),process.exit(1)),Bi(e)?a.push(e):i=e}else throw new e(`Missing required argument --image or --video.`,r.USAGE,`bl vision describe --image <path-or-url>
|
|
132
132
|
bl vision describe --video <url-or-path>`);let f=d(t.output);if(t.dryRun){M({request:{prompt:u,image:i,video:a.length?a:void 0,model:o}},f);return}let p=[];if(a.length>0)for(let n of a){let i=n;if(x(n)){if(!Oe(n))throw new e(`Video file not found: ${n}`,r.USAGE);i=await D(n,(await E(t)).token,o)}p.push({type:`video_url`,video_url:{url:i}})}if(i){let e=await Vi(i),n=e;if(x(i)&&e.startsWith(`data:`)){let{statSync:e}=await import(`fs`);if(e(i).size>5*1024*1024){let e=await E(t);n=await D(i,e.token,o)}}p.push({type:`image_url`,image_url:{url:n}})}p.push({type:`text`,text:u});let m={model:o,messages:[{role:`user`,content:p}]},h=await T(t,{url:c(t.baseUrl),method:`POST`,body:m}),g=h.choices?.[0]?.message?.content;if(f!==`text`){M(h,f);return}N(g||``)}})})),Ki,qi=j((()=>{P(),Ki=u({name:`config show`,description:`Display current configuration`,usage:`bl config show`,examples:[`bl config show`,`bl config show --output json`],async run(e,t){let n=w(),r=d(e.output),i={region:e.region,base_url:e.baseUrl,output:e.output,timeout:e.timeout,config_file:_()};n.api_key&&(i.api_key=C(n.api_key)),n.access_token&&(i.access_token=C(n.access_token)),n.default_text_model&&(i.default_text_model=n.default_text_model),n.default_video_model&&(i.default_video_model=n.default_video_model),n.default_image_model&&(i.default_image_model=n.default_image_model),M(i,r)}})})),Ji,Yi,Xi,Zi=j((()=>{P(),Ji=[`region`,`base_url`,`output`,`output_dir`,`timeout`,`api_key`,`access_token`,`default_text_model`,`default_video_model`,`default_image_model`,`default_speech_model`,`default_omni_model`,`access_key_id`,`access_key_secret`,`workspace_id`],Yi={"base-url":`base_url`,"output-dir":`output_dir`,"api-key":`api_key`,"access-token":`access_token`,"default-text-model":`default_text_model`,"default-video-model":`default_video_model`,"default-image-model":`default_image_model`,"default-speech-model":`default_speech_model`,"default-omni-model":`default_omni_model`,"access-key-id":`access_key_id`,"access-key-secret":`access_key_secret`,"workspace-id":`workspace_id`},Xi=u({name:`config set`,description:`Set a config value`,usage:`bl config set --key <key> --value <value>`,options:[{flag:`--key <key>`,description:`Config key (region, base_url, output, output_dir, timeout, api_key, access_token, default_*_model, access_key_id, access_key_secret, workspace_id)`},{flag:`--value <value>`,description:`Value to set`}],examples:[`bl config set --key output --value json`,`bl config set --key timeout --value 600`,`bl config set --key base_url --value https://dashscope.aliyuncs.com`],async run(t,n){let i=n.key,a=n.value;if(!i||a===void 0)throw new e(`--key and --value are required.`,r.USAGE,`bl config set --key <key> --value <value>`);let o=Yi[i]||i;if(!Ji.includes(o))throw new e(`Invalid config key "${i}". Valid keys: ${Ji.join(`, `)}`,r.USAGE);if(o===`region`&&![`cn`,`us`,`intl`].includes(a))throw new e(`Invalid region "${a}". Valid values: cn, us, intl`,r.USAGE);if(o===`output`&&![`text`,`json`].includes(a))throw new e(`Invalid output format "${a}". Valid values: text, json`,r.USAGE);if(o===`timeout`){let t=Number(a);if(isNaN(t)||t<=0)throw new e(`Invalid timeout "${a}". Must be a positive number.`,r.USAGE)}let s=d(t.output);if(t.dryRun){M({would_set:{[o]:a}},s);return}let c=w();c[o]=o===`timeout`?Number(a):a,await ve(c),t.quiet||M({[o]:c[o]},s)}})})),Qi,$i,ea=j((()=>{Qi=[`auth `,`config `,`update`],$i=u({name:`config export-schema`,description:`Export all (or one) CLI command(s) as Anthropic/OpenAI-compatible JSON tool schemas`,usage:`bl config export-schema [--command "<name>"]`,options:[{flag:`--command <name>`,description:`Export schema for a specific command only (e.g. "image generate")`}],examples:[`bl config export-schema`,`bl config export-schema --command "video generate"`],async run(t,n){let{commands:i}=await Promise.resolve().then(()=>(po(),uo)),a=n.command;if(a){let t=i[a];if(!t)throw new e(`Command "${a}" not found.`,r.USAGE);let n=h(t);process.stdout.write(JSON.stringify(n,null,2)+`
|
|
133
133
|
`);return}let o=Object.values(i).filter(e=>!Qi.some(t=>e.name.startsWith(t))).map(e=>h(e));process.stdout.write(JSON.stringify(o,null,2)+`
|
|
134
|
-
`)}})}));Lr(),Kr(),Yr(),Qr(),ni(),Ci(),Di(),ji(),Ni(),Fi(),Li(),zi(),Gi(),qi(),Zi(),ea();var ta=`1.0.
|
|
134
|
+
`)}})}));Lr(),Kr(),Yr(),Qr(),ni(),Ci(),Di(),ji(),Ni(),Fi(),Li(),zi(),Gi(),qi(),Zi(),ea();var ta=`1.0.3`,Z,na=j((()=>{Z=ta}));function ra(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if((n[e]??0)>(r[e]??0))return!0;if((n[e]??0)<(r[e]??0))return!1}return!1}function ia(){try{let e=Ae(da(),`utf-8`);return JSON.parse(e)}catch{return null}}function aa(e){try{Me(da(),JSON.stringify(e))}catch{}}async function oa(e=pa){try{let t=ua.replace(`/`,`%2f`),n=await fetch(`${la}/${t}/latest`,{headers:{Accept:`application/json`,...me()},signal:AbortSignal.timeout(e)});return n.ok?(await n.json()).version??null:null}catch{return null}}function sa(){return ma}async function ca(e){if(process.env.CI||!process.stderr.isTTY)return;let t=ia(),n=Date.now();if(t&&n-t.lastChecked<fa){t.latestVersion&&ra(t.latestVersion,e)&&(ma=t.latestVersion);return}let r=await oa();r&&(aa({lastChecked:n,latestVersion:r}),r&&ra(r,e)&&(ma=r))}var la,ua,da,fa,pa,ma,ha=j((()=>{la=`https://registry.npmjs.org`,ua=`bailian-cli`,da=()=>Fe(g(),`update-state.json`),fa=14400*1e3,pa=3e3,ma=null}));function ga(){return{cmd:`npm install -g ${ua}@latest`,label:`npm`}}var _a,va=j((()=>{na(),ha(),_a=u({name:`update`,description:`Update bl to the latest version`,usage:`bl update`,examples:[`bl update`],async run(){let e=process.stderr.isTTY,t=e?`\x1B[32m`:``,n=e?`\x1B[33m`:``,r=e?`\x1B[0m`:``;process.stderr.write(`Current version: ${n}${Z}${r}\n`),process.stderr.write(`Checking for updates...
|
|
135
135
|
`);let i=await oa(5e3);if(i&&i===Z){process.stderr.write(`${t}\u2713 Already up to date (${Z}).${r}\n`);return}i&&process.stderr.write(`Latest version: ${t}${i}${r}\n\n`);let{cmd:a,label:o}=ga();process.stderr.write(`Updating ${ua} via ${o}...\n\n`);try{Ie(a,{stdio:`inherit`});try{let e=Ie(`bl --version 2>/dev/null`,{encoding:`utf-8`}).trim().replace(/^bl\s+/,``);process.stderr.write(`\n${t}\u2713 Update complete: ${Z} \u2192 ${e}${r}\n`);try{Me(Fe(g(),`update-state.json`),JSON.stringify({lastChecked:Date.now(),latestVersion:e}))}catch{}}catch{process.stderr.write(`\n${t}\u2713 Update complete.${r}\n`)}}catch{process.stderr.write(`
|
|
136
136
|
Automatic update failed. Please run manually:
|
|
137
137
|
`),process.stderr.write(` ${a}\n\n`)}}})})),ya,ba=j((()=>{J(),P(),ya=u({name:`app call`,description:`Call a Bailian application (agent or workflow)`,usage:`bl app call --app-id <id> --prompt <text> [flags]`,options:[{flag:`--app-id <id>`,description:`Application ID (required)`,required:!0},{flag:`--prompt <text>`,description:`Input prompt text`,required:!0},{flag:`--image <url>`,description:`Image URL(s) to pass to the app (repeatable)`,type:`array`},{flag:`--file-id <id>`,description:`Pre-uploaded file ID(s) (repeatable)`,type:`array`},{flag:`--session-id <id>`,description:`Session ID for multi-turn conversation`},{flag:`--stream`,description:`Stream response (default: on in TTY)`},{flag:`--pipeline-ids <ids>`,description:`Knowledge base pipeline IDs (comma-separated)`},{flag:`--memory-id <id>`,description:`Memory ID for long-term memory`},{flag:`--biz-params <json>`,description:`Business parameters JSON (workflow variables)`},{flag:`--has-thoughts`,description:`Show agent thinking process`}],examples:[`bl app call --app-id abc123 --prompt "你好"`,`bl app call --app-id abc123 --prompt "描述这张图片" --image https://example.com/photo.jpg`,`bl app call --app-id abc123 --prompt "分析图片" --image img1.jpg --image img2.jpg`,`bl app call --app-id abc123 --prompt "继续" --session-id sess_xxx --stream`,`bl app call --app-id abc123 --prompt "搜索资料" --pipeline-ids pipe1,pipe2`,`bl app call --app-id abc123 --prompt "开始" --biz-params '{"key":"value"}'`],async run(e,t){let n=t.appId;n||q(`app-id`,`bl app call --app-id <id> --prompt <text>`);let r=t.prompt;r||q(`prompt`,`bl app call --app-id <id> --prompt <text>`);let i=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,a=d(e.output),s={input:{prompt:r},parameters:{incremental_output:i}};t.sessionId&&(s.input.session_id=t.sessionId);let c=t.image;c&&c.length>0&&(s.input.image_list=c);let l=t.fileId;if(l&&l.length>0&&(s.input.file_ids=l),t.hasThoughts&&(s.parameters.has_thoughts=!0),t.pipelineIds){let e=t.pipelineIds.split(`,`).map(e=>e.trim()).filter(Boolean);s.parameters.rag_options={pipeline_ids:e}}if(t.memoryId&&(s.parameters.memory_id=t.memoryId),t.bizParams)try{s.input.biz_params=JSON.parse(t.bizParams)}catch{process.stderr.write(`Error: --biz-params must be valid JSON
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bailian-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "CLI for Aliyun Model Studio (DashScope) AI Platform.",
|
|
5
5
|
"homepage": "https://bailian.console.aliyun.com/cli",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"registry": "https://registry.npmjs.org/"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"bailian-cli-core": "1.0.
|
|
27
|
+
"bailian-cli-core": "1.0.3"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@clack/prompts": "^0.7.0",
|