bailian-cli-commands 2.1.0 → 2.2.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 +1 -1
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -2761,7 +2761,7 @@ Hint: Add --diarization flag to enable speaker separation.`,l.USAGE);let s=r.mod
2761
2761
  `);else{let e=g.slice(0,10),n=g.length-e.length;oh({quotas:e,stopMap:v,typeMap:p,title:`Free Tier Quota · ${g.length} models · sorted by urgency`,moreHint:n>0?`+ ${n} more · ${t.binName} usage free to browse all`:void 0})}process.stdout.write(`
2762
2762
  `),s?y?hh(y,u,c,a):process.stdout.write(b.dim(`No usage data in this period.`)+`
2763
2763
  `):process.stdout.write(b.dim(`Usage overview skipped · set --workspace-id or \`${t.binName} config set workspace_id <id>\` to include it.`)+`
2764
- `)}});function Ch(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function wh(e){let t=Math.round(e*1e3)/10;return`${Number.isInteger(t)?t:t.toFixed(1)}%`}function Th(e,t){let n=Math.max(0,e-t),r=Math.floor(n/6e4);if(r===0)return`now`;let i=Math.floor(r/1440),a=Math.floor(r%1440/60),o=r%60,s=[];return i>0&&s.push(`${i}d`),a>0&&s.push(`${a}h`),(o>0||s.length===0)&&s.push(`${o}m`),s.join(` `)}function Eh(e,t,n){let r=E(process.stdout),i=(e=``,t)=>{let n=Math.max(0,76-hr(` ${e}`));process.stdout.write(`│ ${t?t(e):e}${` `.repeat(n)}│\n`)},a=e=>{let t=Math.max(0,76-hr(` ${e.plain}`));process.stdout.write(`│ ${e.colored}${` `.repeat(t)}│\n`)},o=e=>{if(i(e.label,r.bold),e.percentage===void 0){i(e.emptyMessage,r.dim);return}let t=`${wh(e.percentage)} used`;if(a(Mr(e.percentage*100,t)),e.detail&&i(e.detail,r.dim),e.resetTime===void 0){i(`Resets: not applicable (no usage yet)`,r.dim);return}let o=`Resets: ${qm(e.resetTime)} (in ${Th(e.resetTime,n)})`;i(o,r.dim)};process.stdout.write(`┌${`─`.repeat(76)}┐\n`),i(e,r.cyan),i(`Generated at: ${qm(n)} (local time)`,r.dim);for(let e of t)process.stdout.write(`├${`─`.repeat(76)}┤\n`),o(e);process.stdout.write(`└${`─`.repeat(76)}┘\n`)}const Dh=`zeldaHttp.apikeyMgr./tokenplan/personal/api/v2/usage`;function Oh(e){let t=qn(e),n={},r=Ch(t.per5HourPercentage);r!==void 0&&(n.per5HourPercentage=r);let i=Ch(t.per5HourResetTime);i!==void 0&&(n.per5HourResetTime=i);let a=Ch(t.per1WeekPercentage);a!==void 0&&(n.per1WeekPercentage=a);let o=Ch(t.per1WeekResetTime);return o!==void 0&&(n.per1WeekResetTime=o),n}function kh(e,t){Eh(`Token Plan Usage`,[{label:`5-hour quota`,emptyMessage:`The 5-hour limit may be unlimited; verify in the Bailian Token Plan console.`,percentage:e.per5HourPercentage,resetTime:e.per5HourResetTime},{label:`1-week quota`,emptyMessage:`The 1-week limit may be unlimited; verify in the Bailian Token Plan console.`,percentage:e.per1WeekPercentage,resetTime:e.per1WeekResetTime}],t)}var Ah=S({description:{"en-US":`Show Token Plan quota usage`,"zh-CN":`查看 Token Plan 配额使用情况`},auth:`console`,usageArgs:`[flags]`,exampleArgs:[``,`--output json`],async run(e){let{settings:t}=e,n=C(t.output);if(t.dryRun){O({api:Dh,data:{}},n);return}let r=Oh(await e.client.console(Dh,{}));if(n===`json`){O(r,n);return}kh(r,Date.now())}});const jh=`zeldaEasy.broadscope-bailian.codingPlan.queryCodingPlanInstanceInfoV2`,Mh={domestic:`sfm_codingplan_public_cn`,international:`sfm_codingplan_public_intl`};function Nh(e,t){let n={};if(!e)return n;let r=Ch(e[`${t}UsedQuota`]);r!==void 0&&(n.usedQuota=r);let i=Ch(e[`${t}TotalQuota`]);i!==void 0&&(n.totalQuota=i);let a=Ch(e[`${t}QuotaNextRefreshTime`]);return a!==void 0&&(n.resetTime=a),r!==void 0&&i!==void 0&&i>0&&(n.percentage=r/i),n}function Ph(e){let t=qn(e),n=(Array.isArray(t.codingPlanInstanceInfos)?t.codingPlanInstanceInfos:[]).find(e=>e.status===`VALID`);if(!n)return;let r=n.codingPlanQuotaInfo,i={per5Hour:Nh(r,`per5Hour`),perWeek:Nh(r,`perWeek`),perBillMonth:Nh(r,`perBillMonth`)};return typeof n.instanceType==`string`&&n.instanceType&&(i.instanceType=n.instanceType),i}function Fh(e,t){let n={label:e,emptyMessage:`No quota data for this window; verify in the Bailian Coding Plan console.`,percentage:t.percentage,resetTime:t.resetTime};return t.usedQuota!==void 0&&t.totalQuota!==void 0&&(n.detail=`Used: ${V(t.usedQuota)} / ${V(t.totalQuota)}`),n}function Ih(e,t){Eh(`Coding Plan Usage${e.instanceType?` (${e.instanceType})`:``}`,[Fh(`5-hour quota`,e.per5Hour),Fh(`1-week quota`,e.perWeek),Fh(`Monthly quota`,e.perBillMonth)],t)}var Lh=S({description:{"en-US":`Show Coding Plan quota usage`,"zh-CN":`查看 Coding Plan 配额使用情况`},auth:`console`,usageArgs:`[flags]`,exampleArgs:[``,`--output json`],async run(e){let{settings:t}=e,n=C(t.output),r={queryCodingPlanInstanceInfoRequest:{commodityCode:Mh[t.consoleSite??`domestic`],onlyLatestOne:!0}};if(t.dryRun){O({api:jh,data:r},n);return}let i=Ph(await e.client.console(jh,r));if(n===`json`){O(i??{},n);return}if(!i){process.stdout.write(`No active Coding Plan subscription found.
2764
+ `)}});function Ch(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function wh(e){let t=Math.round(e*1e3)/10;return`${Number.isInteger(t)?t:t.toFixed(1)}%`}function Th(e,t){let n=Math.max(0,e-t),r=Math.floor(n/6e4);if(r===0)return`now`;let i=Math.floor(r/1440),a=Math.floor(r%1440/60),o=r%60,s=[];return i>0&&s.push(`${i}d`),a>0&&s.push(`${a}h`),(o>0||s.length===0)&&s.push(`${o}m`),s.join(` `)}function Eh(e,t,n){let r=E(process.stdout),i=(e=``,t)=>{let n=Math.max(0,76-hr(` ${e}`));process.stdout.write(`│ ${t?t(e):e}${` `.repeat(n)}│\n`)},a=e=>{let t=Math.max(0,76-hr(` ${e.plain}`));process.stdout.write(`│ ${e.colored}${` `.repeat(t)}│\n`)},o=e=>{if(i(e.label,r.bold),e.percentage===void 0){i(e.emptyMessage,r.dim);return}let t=`${wh(e.percentage)} used`;if(a(Mr(e.percentage*100,t)),e.detail&&i(e.detail,r.dim),e.resetTime===void 0){i(`Resets: not applicable (no usage yet)`,r.dim);return}let o=`Resets: ${qm(e.resetTime)} (in ${Th(e.resetTime,n)})`;i(o,r.dim)};process.stdout.write(`┌${`─`.repeat(76)}┐\n`),i(e,r.cyan),i(`Generated at: ${qm(n)} (local time)`,r.dim);for(let e of t)process.stdout.write(`├${`─`.repeat(76)}┤\n`),o(e);process.stdout.write(`└${`─`.repeat(76)}┘\n`)}const Dh=`zeldaHttp.apikeyMgr./tokenplan/personal/api/v2/usage`;function Oh(e){let t=qn(e),n={},r=Ch(t.per1MonthPercentage);r!==void 0&&(n.per1MonthPercentage=r);let i=Ch(t.per1MonthResetTime);return i!==void 0&&(n.per1MonthResetTime=i),n}function kh(e,t){Eh(`Token Plan Usage`,[{label:`Monthly quota`,emptyMessage:`The monthly limit may be unlimited; verify in the Bailian Token Plan console.`,percentage:e.per1MonthPercentage,resetTime:e.per1MonthResetTime}],t)}var Ah=S({description:{"en-US":`Show Token Plan quota usage`,"zh-CN":`查看 Token Plan 配额使用情况`},auth:`console`,usageArgs:`[flags]`,exampleArgs:[``,`--output json`],async run(e){let{settings:t}=e,n=C(t.output);if(t.dryRun){O({api:Dh,data:{}},n);return}let r=Oh(await e.client.console(Dh,{}));if(n===`json`){O(r,n);return}kh(r,Date.now())}});const jh=`zeldaEasy.broadscope-bailian.codingPlan.queryCodingPlanInstanceInfoV2`,Mh={domestic:`sfm_codingplan_public_cn`,international:`sfm_codingplan_public_intl`};function Nh(e,t){let n={};if(!e)return n;let r=Ch(e[`${t}UsedQuota`]);r!==void 0&&(n.usedQuota=r);let i=Ch(e[`${t}TotalQuota`]);i!==void 0&&(n.totalQuota=i);let a=Ch(e[`${t}QuotaNextRefreshTime`]);return a!==void 0&&(n.resetTime=a),r!==void 0&&i!==void 0&&i>0&&(n.percentage=r/i),n}function Ph(e){let t=qn(e),n=(Array.isArray(t.codingPlanInstanceInfos)?t.codingPlanInstanceInfos:[]).find(e=>e.status===`VALID`);if(!n)return;let r=n.codingPlanQuotaInfo,i={per5Hour:Nh(r,`per5Hour`),perWeek:Nh(r,`perWeek`),perBillMonth:Nh(r,`perBillMonth`)};return typeof n.instanceType==`string`&&n.instanceType&&(i.instanceType=n.instanceType),i}function Fh(e,t){let n={label:e,emptyMessage:`No quota data for this window; verify in the Bailian Coding Plan console.`,percentage:t.percentage,resetTime:t.resetTime};return t.usedQuota!==void 0&&t.totalQuota!==void 0&&(n.detail=`Used: ${V(t.usedQuota)} / ${V(t.totalQuota)}`),n}function Ih(e,t){Eh(`Coding Plan Usage${e.instanceType?` (${e.instanceType})`:``}`,[Fh(`5-hour quota`,e.per5Hour),Fh(`1-week quota`,e.perWeek),Fh(`Monthly quota`,e.perBillMonth)],t)}var Lh=S({description:{"en-US":`Show Coding Plan quota usage`,"zh-CN":`查看 Coding Plan 配额使用情况`},auth:`console`,usageArgs:`[flags]`,exampleArgs:[``,`--output json`],async run(e){let{settings:t}=e,n=C(t.output),r={queryCodingPlanInstanceInfoRequest:{commodityCode:Mh[t.consoleSite??`domestic`],onlyLatestOne:!0}};if(t.dryRun){O({api:jh,data:r},n);return}let i=Ph(await e.client.console(jh,r));if(n===`json`){O(i??{},n);return}if(!i){process.stdout.write(`No active Coding Plan subscription found.
2765
2765
  `);return}Ih(i,Date.now())}});async function Rh(e){let t=await Ei(e,`utf-8`).catch(e=>{throw new x(`cannot read pipeline file: ${e.message}`)}),n=fi(e).toLowerCase(),r;if(n===`.yaml`||n===`.yml`){let{parse:e}=await import(`yaml`);r=e(t)}else try{r=JSON.parse(t)}catch{let{parse:e}=await import(`yaml`);r=e(t)}return r}var zh=S({description:{"en-US":`Run a pipeline workflow definition`,"zh-CN":`运行 Pipeline 工作流定义`},auth:`none`,usageArgs:`--file <path> [flags]`,flags:{file:{type:`string`,valueHint:`<path>`,description:{"en-US":`Pipeline definition file (YAML/JSON)`,"zh-CN":`Pipeline 定义文件(YAML/JSON)`},required:!0},input:{type:`string`,valueHint:`<json>`,description:{"en-US":`Runtime input as inline JSON`,"zh-CN":`内联 JSON 格式的运行时输入`}},inputFile:{type:`string`,valueHint:`<path>`,description:{"en-US":`Runtime input from a JSON file`,"zh-CN":`来自 JSON 文件的运行时输入`}},concurrency:{type:`number`,valueHint:`<n>`,description:{"en-US":`Max parallel steps (default: 1)`,"zh-CN":`最大并行步骤数(默认:1)`}},events:{type:`string`,valueHint:`<format>`,description:{"en-US":`Emit lifecycle events: jsonl`,"zh-CN":`输出生命周期事件:jsonl`},choices:[`jsonl`]},stepTimeout:{type:`number`,valueHint:`<seconds>`,description:{"en-US":`Default step timeout in seconds`,"zh-CN":`默认步骤超时时间,单位为秒`}}},exampleArgs:[{"en-US":`--file workflow.yaml --input '{"brief":"hello"}'`,"zh-CN":`--file workflow.yaml --input '{"brief":"你好"}'`},`--file workflow.json --input-file inputs.json --concurrency 3`,`--file workflow.yaml --dry-run`,`--file workflow.json --events jsonl`,`--file workflow.yaml --output json`],validate:e=>e.input&&e.inputFile?`use --input or --input-file, not both`:void 0,async run(e){let{settings:t,flags:n}=e,r=n.file;wr();let i=n.events,a=M(r),o=await Rh(a),s=await Bh(n),c=di(a);if(i===`jsonl`){for await(let e of Fr(o,s,{concurrency:n.concurrency,basePath:c,dryRun:t.dryRun,timeoutSeconds:n.stepTimeout}))process.stdout.write(JSON.stringify(e)+`
2766
2766
  `);return}let l=await vr(o,s,{concurrency:n.concurrency,basePath:c,dryRun:t.dryRun,timeoutSeconds:n.stepTimeout,onEvent:t.verbose?Vh:void 0});t.output===`json`?O(l,`json`):Uh(l),l.status===`failed`&&(process.exitCode=1)}});async function Bh(e){let t=e.input,n=e.inputFile;if(t)return JSON.parse(t);if(n){let e=await Ei(M(n),`utf-8`);return JSON.parse(e)}return{}}function Vh(e){let t=`[${e.type}]`;if(`stepCount`in e){process.stderr.write(`${t} ${e.stepCount} step${e.stepCount===1?``:`s`}\n`);return}`step`in e&&e.step?process.stderr.write(`${t} ${Hh(e.step)}\n`):process.stderr.write(`${t}\n`)}function Hh(e){return`${e.index!==void 0&&e.total!==void 0?`${e.index}/${e.total} `:``}${e.id} (${e.type})`}function Uh(e){let t=e.status===`succeeded`?`+`:e.status===`failed`?`x`:`~`;process.stdout.write(`\nPipeline ${e.status} [${t}]\n\n`);for(let t of e.steps){let e=` [${t.status===`succeeded`?`+`:t.status===`failed`?`x`:t.status===`skipped`?`-`:`~`}] ${t.id} (${t.type}) — ${t.status}`;t.skipReason&&(e+=` (${t.skipReason})`),t.error&&(e+=`: ${t.error.message}`),process.stdout.write(e+`
2767
2767
  `)}process.stdout.write(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bailian-cli-commands",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Command library for bailian-cli products (knowledge, memory, media, …). See https://www.npmjs.com/package/bailian-cli for usage.",
5
5
  "homepage": "https://bailian.console.aliyun.com/cli",
6
6
  "bugs": {
@@ -32,8 +32,8 @@
32
32
  "chalk": "^5.6.2",
33
33
  "smol-toml": "^1.4.2",
34
34
  "yaml": "^2.8.3",
35
- "bailian-cli-core": "2.1.0",
36
- "bailian-cli-runtime": "2.1.0"
35
+ "bailian-cli-core": "2.2.0",
36
+ "bailian-cli-runtime": "2.2.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^24",