From 067e96689aa6ec31c49d323da006b62ccff30081 Mon Sep 17 00:00:00 2001 From: lishengzxc <306009337@qq.com> Date: Sun, 14 Jun 2026 20:17:46 +0800 Subject: [PATCH 01/20] feat(console): resolve gateway URL from region + site, add switchAgent support Console gateway URL and action are now resolved from a region + site mapping table instead of a single hardcoded config value. Supports cn-beijing and ap-southeast-1 with domestic/international site variants. - Add ConsoleSite type, REGION_GATEWAYS mapping, and resolveGateway() - Add switchAgent to cornerstoneParam for delegated access - Add console_site, console_region, console_switch_agent to config - Remove consoleGatewayUrl from Config (replaced by region+site resolution) - login-console callback now persists baseUrl, site, region, switchAgent - bl console call gains --site and --switch-agent flags - All callers delegate region default to callConsoleGateway (no more hardcoded cn-beijing) Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/cli/src/commands/app/list.ts | 2 +- .../cli/src/commands/auth/login-console.ts | 56 ++++++++++++++-- packages/cli/src/commands/console/call.ts | 17 ++++- packages/cli/src/commands/mcp/list.ts | 2 +- packages/cli/src/commands/quota/check.ts | 6 +- packages/cli/src/commands/quota/history.ts | 2 +- packages/cli/src/commands/quota/list.ts | 4 +- packages/cli/src/commands/quota/request.ts | 4 +- packages/cli/src/commands/usage/free.ts | 2 +- packages/cli/src/commands/usage/freetier.ts | 4 +- packages/cli/src/commands/usage/stats.ts | 4 +- packages/cli/src/commands/workspace/list.ts | 2 +- packages/core/src/config/loader.ts | 7 +- packages/core/src/config/schema.ts | 14 +++- packages/core/src/console/gateway.ts | 66 ++++++++++++++++--- packages/core/src/console/index.ts | 2 +- packages/core/src/console/models.ts | 2 +- packages/core/tests/index.test.ts | 1 - skills/bailian-cli/reference/console.md | 12 ++-- 19 files changed, 163 insertions(+), 46 deletions(-) diff --git a/packages/cli/src/commands/app/list.ts b/packages/cli/src/commands/app/list.ts index 904ad47..d4f8784 100644 --- a/packages/cli/src/commands/app/list.ts +++ b/packages/cli/src/commands/app/list.ts @@ -44,7 +44,7 @@ export default defineCommand({ const name = (flags.name as string) || ""; const pageNo = (flags.page as number) || 1; const pageSize = (flags.pageSize as number) || 30; - const region = (flags.region as string) || "cn-beijing"; + const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); const credential = await resolveConsoleGatewayCredential(config); diff --git a/packages/cli/src/commands/auth/login-console.ts b/packages/cli/src/commands/auth/login-console.ts index f212325..5b9fcd7 100644 --- a/packages/cli/src/commands/auth/login-console.ts +++ b/packages/cli/src/commands/auth/login-console.ts @@ -213,6 +213,10 @@ function parseApiKeyFromRawBody(raw: string, contentType: string): string | null interface CallbackCredentials { accessToken: string | null; apiKey: string | null; + baseUrl: string | null; + consoleSite: string | null; + consoleRegion: string | null; + consoleSwitchAgent: string | null; } async function extractCredentialsFromRequest( @@ -222,12 +226,27 @@ async function extractCredentialsFromRequest( const accessTokenFromQuery = u.searchParams.get("access_token") ?? u.searchParams.get("accessToken"); const apiKeyFromQuery = u.searchParams.get("api_key") ?? u.searchParams.get("apiKey"); + const baseUrlFromQuery = u.searchParams.get("base_url") ?? u.searchParams.get("baseUrl"); + const consoleSiteFromQuery = + u.searchParams.get("console_site") ?? u.searchParams.get("consoleSite"); + const consoleRegionFromQuery = + u.searchParams.get("console_region") ?? u.searchParams.get("consoleRegion"); + const consoleSwitchAgentFromQuery = + u.searchParams.get("console_switch_agent") ?? u.searchParams.get("consoleSwitchAgent"); + + const extras = { + baseUrl: baseUrlFromQuery?.trim() || null, + consoleSite: consoleSiteFromQuery?.trim() || null, + consoleRegion: consoleRegionFromQuery?.trim() || null, + consoleSwitchAgent: consoleSwitchAgentFromQuery?.trim() || null, + }; const m = req.method ?? "GET"; if (m !== "POST" && m !== "PUT" && m !== "PATCH") { return { accessToken: accessTokenFromQuery?.trim() || null, apiKey: apiKeyFromQuery?.trim() || null, + ...extras, }; } @@ -239,12 +258,13 @@ async function extractCredentialsFromRequest( return { accessToken: accessTokenFromQuery?.trim() || null, apiKey: apiKeyFromQuery?.trim() || null, + ...extras, }; } const accessToken = accessTokenFromQuery?.trim() || parseAccessTokenFromRawBody(raw, contentType); const apiKey = apiKeyFromQuery?.trim() || parseApiKeyFromRawBody(raw, contentType); - return { accessToken, apiKey }; + return { accessToken, apiKey, ...extras }; } function listenServerOnFreeLocalPort(server: http.Server): Promise { @@ -301,16 +321,40 @@ export async function runConsoleLogin( return; } - const { accessToken, apiKey } = await extractCredentialsFromRequest(req); + const { accessToken, apiKey, baseUrl, consoleSite, consoleRegion, consoleSwitchAgent } = + await extractCredentialsFromRequest(req); - if (accessToken || apiKey) { + if (accessToken || apiKey || baseUrl || consoleSite || consoleRegion || consoleSwitchAgent) { try { + const existing = readConfigFile() as Record; + let changed = false; + if (accessToken) { - const existing = readConfigFile() as Record; existing.access_token = accessToken; + changed = true; + } + if (baseUrl) { + existing.base_url = baseUrl; + changed = true; + } + if (consoleSite) { + existing.console_site = consoleSite; + changed = true; + } + if (consoleRegion) { + existing.console_region = consoleRegion; + changed = true; + } + if (consoleSwitchAgent) { + existing.console_switch_agent = Number(consoleSwitchAgent); + changed = true; + } + + if (changed) { await writeConfigFile(existing); - process.stderr.write(`access_token saved to ${getConfigPath()}\n`); + process.stderr.write(`Config saved to ${getConfigPath()}\n`); } + if (apiKey && opts?.onApiKey) { await opts.onApiKey(apiKey); } @@ -329,7 +373,7 @@ export async function runConsoleLogin( }); res.end("OK\n"); - if (accessToken || apiKey) { + if (accessToken || apiKey || baseUrl || consoleSite || consoleRegion || consoleSwitchAgent) { server.close(); } } catch { diff --git a/packages/cli/src/commands/console/call.ts b/packages/cli/src/commands/console/call.ts index b3d01ba..ae4e552 100644 --- a/packages/cli/src/commands/console/call.ts +++ b/packages/cli/src/commands/console/call.ts @@ -7,6 +7,7 @@ import { detectOutputFormat, type Config, type GlobalFlags, + type ConsoleSite, } from "bailian-cli-core"; import { failIfMissing } from "../../output/prompt.ts"; import { emitResult } from "../../output/output.ts"; @@ -28,7 +29,15 @@ export default defineCommand({ }, { flag: "--region ", - description: "API region (default: cn-beijing)", + description: "Console region (e.g. cn-beijing, ap-southeast-1)", + }, + { + flag: "--site ", + description: "Console site: domestic or international", + }, + { + flag: "--switch-agent ", + description: "Switch agent UID for delegated access", }, ], examples: [ @@ -50,7 +59,9 @@ export default defineCommand({ process.exit(1); } - const region = (flags.region as string) || "cn-beijing"; + const region = (flags.region as string) || undefined; + const site = ((flags.site as string) || undefined) as ConsoleSite | undefined; + const switchAgent = flags.switchAgent ? Number(flags.switchAgent) : undefined; const format = detectOutputFormat(config.output); let token: string | undefined; @@ -71,6 +82,8 @@ export default defineCommand({ api, data, region, + site, + switchAgent, }); emitResult(result, format); diff --git a/packages/cli/src/commands/mcp/list.ts b/packages/cli/src/commands/mcp/list.ts index 561bd0e..5edd6f0 100644 --- a/packages/cli/src/commands/mcp/list.ts +++ b/packages/cli/src/commands/mcp/list.ts @@ -43,7 +43,7 @@ export default defineCommand({ const type = (flags.type as string) || "OFFICIAL"; const pageNo = (flags.page as number) || 1; const pageSize = (flags.pageSize as number) || 30; - const region = (flags.region as string) || "cn-beijing"; + const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); const data = { diff --git a/packages/cli/src/commands/quota/check.ts b/packages/cli/src/commands/quota/check.ts index 5c52fa8..ba7a225 100644 --- a/packages/cli/src/commands/quota/check.ts +++ b/packages/cli/src/commands/quota/check.ts @@ -94,7 +94,7 @@ function extractResponseData(result: Record): Record { const allModels: ModelWithQpm[] = []; let pageNo = 1; @@ -130,7 +130,7 @@ async function fetchAllModelsWithQpm( async function fetchMonitorData( config: Config, token: string, - region: string, + region: string | undefined, modelName: string, windowMinutes: number, ): Promise<{ rpm: number; tpm: number }> { @@ -280,7 +280,7 @@ export default defineCommand({ process.exit(1); } const windowMinutes = rawPeriod; - const region = (flags.region as string) || "cn-beijing"; + const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); const credential = await resolveConsoleGatewayCredential(config); diff --git a/packages/cli/src/commands/quota/history.ts b/packages/cli/src/commands/quota/history.ts index 99dd510..033bb85 100644 --- a/packages/cli/src/commands/quota/history.ts +++ b/packages/cli/src/commands/quota/history.ts @@ -130,7 +130,7 @@ export default defineCommand({ const page = Number(flags.page) || 1; const pageSize = Number(flags.pageSize) || 10; const modelFilter = (flags.model as string) || undefined; - const region = (flags.region as string) || "cn-beijing"; + const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); const credential = await resolveConsoleGatewayCredential(config); diff --git a/packages/cli/src/commands/quota/list.ts b/packages/cli/src/commands/quota/list.ts index 3002757..1f4761d 100644 --- a/packages/cli/src/commands/quota/list.ts +++ b/packages/cli/src/commands/quota/list.ts @@ -68,7 +68,7 @@ function extractResponseData(result: Record): Record { const allModels: ModelWithQpm[] = []; @@ -186,7 +186,7 @@ export default defineCommand({ async run(config: Config, flags: GlobalFlags) { const modelFlag = (flags.model as string) || undefined; const showAll = Boolean(flags.all); - const region = (flags.region as string) || "cn-beijing"; + const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); const credential = await resolveConsoleGatewayCredential(config); diff --git a/packages/cli/src/commands/quota/request.ts b/packages/cli/src/commands/quota/request.ts index 60f727b..c18045e 100644 --- a/packages/cli/src/commands/quota/request.ts +++ b/packages/cli/src/commands/quota/request.ts @@ -53,7 +53,7 @@ function extractResponseData(result: Record): Record } | undefined> { const raw = await callConsoleGateway(config, token, { @@ -122,7 +122,7 @@ export default defineCommand({ } const autoConfirm = Boolean(flags.yes) || config.yes; - const region = (flags.region as string) || "cn-beijing"; + const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); const credential = await resolveConsoleGatewayCredential(config); diff --git a/packages/cli/src/commands/usage/free.ts b/packages/cli/src/commands/usage/free.ts index 3dd11a0..4ac1eb7 100644 --- a/packages/cli/src/commands/usage/free.ts +++ b/packages/cli/src/commands/usage/free.ts @@ -232,7 +232,7 @@ export default defineCommand({ ); process.exit(1); } - const region = (flags.region as string) || "cn-beijing"; + const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); const credential = await resolveConsoleGatewayCredential(config); diff --git a/packages/cli/src/commands/usage/freetier.ts b/packages/cli/src/commands/usage/freetier.ts index 8894b02..671bb89 100644 --- a/packages/cli/src/commands/usage/freetier.ts +++ b/packages/cli/src/commands/usage/freetier.ts @@ -63,7 +63,7 @@ async function pollUntilDone( api: string, requestKey: string, models: string[], - region: string, + region: string | undefined, ): Promise { let nextTaskId: string | undefined; @@ -140,7 +140,7 @@ export default defineCommand({ const modelFlag = (flags.model as string) || undefined; const all = Boolean(flags.all); const off = Boolean(flags.off); - const region = (flags.region as string) || "cn-beijing"; + const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); if (!modelFlag && !all) { diff --git a/packages/cli/src/commands/usage/stats.ts b/packages/cli/src/commands/usage/stats.ts index fb5074b..35e5c0b 100644 --- a/packages/cli/src/commands/usage/stats.ts +++ b/packages/cli/src/commands/usage/stats.ts @@ -70,7 +70,7 @@ async function pollTelemetryApi( token: string, api: string, reqDTO: Record, - region: string, + region: string | undefined, ): Promise { let nextTaskId: string | undefined; @@ -343,7 +343,7 @@ export default defineCommand({ const modelFlag = (flags.model as string) || undefined; const daysFlag = Number(flags.days) || 7; const typeFlag = (flags.type as string) || undefined; - const region = (flags.region as string) || "cn-beijing"; + const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); const flagWorkspaceId = (flags.workspaceId as string) || undefined; diff --git a/packages/cli/src/commands/workspace/list.ts b/packages/cli/src/commands/workspace/list.ts index b9f6edb..58857ef 100644 --- a/packages/cli/src/commands/workspace/list.ts +++ b/packages/cli/src/commands/workspace/list.ts @@ -100,7 +100,7 @@ export default defineCommand({ ], examples: ["bl workspace list", "bl workspace list --list 5", "bl workspace list --output json"], async run(config: Config, flags: GlobalFlags) { - const region = (flags.region as string) || "cn-beijing"; + const region = (flags.region as string) || undefined; const limit = Number(flags.list) || 0; const format = detectOutputFormat(config.output); diff --git a/packages/core/src/config/loader.ts b/packages/core/src/config/loader.ts index 30ce611..4e5f39e 100644 --- a/packages/core/src/config/loader.ts +++ b/packages/core/src/config/loader.ts @@ -84,10 +84,9 @@ export function loadConfig(flags: GlobalFlags): Config { accessKeySecret: process.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET || file.access_key_secret || undefined, workspaceId: process.env.BAILIAN_WORKSPACE_ID || file.workspace_id || undefined, - consoleGatewayUrl: - process.env.BAILIAN_CONSOLE_GATEWAY_URL || - file.console_gateway_url || - "https://bailian-cs.console.aliyun.com", + consoleSite: file.console_site || undefined, + consoleRegion: file.console_region || undefined, + consoleSwitchAgent: file.console_switch_agent || undefined, verbose: flags.verbose || process.env.DASHSCOPE_VERBOSE === "1", quiet: flags.quiet || false, noColor: flags.noColor || process.env.NO_COLOR !== undefined || !process.stdout.isTTY, diff --git a/packages/core/src/config/schema.ts b/packages/core/src/config/schema.ts index 7fad89f..b98ff25 100644 --- a/packages/core/src/config/schema.ts +++ b/packages/core/src/config/schema.ts @@ -32,11 +32,15 @@ export interface ConfigFile { access_key_secret?: string; workspace_id?: string; console_gateway_url?: string; + console_site?: "domestic" | "international"; + console_region?: string; + console_switch_agent?: number; telemetry?: boolean; } const VALID_REGIONS = new Set(["cn", "us", "intl"]); const VALID_OUTPUTS = new Set(["text", "json"]); +const VALID_CONSOLE_SITES = new Set(["domestic", "international"]); /** * A syntactically valid absolute http(s) URL. Used to validate `base_url` and @@ -89,6 +93,12 @@ export function parseConfigFile(raw: unknown): ConfigFile { out.workspace_id = obj.workspace_id; if (typeof obj.console_gateway_url === "string" && isHttpUrl(obj.console_gateway_url)) out.console_gateway_url = obj.console_gateway_url; + if (typeof obj.console_site === "string" && VALID_CONSOLE_SITES.has(obj.console_site)) + out.console_site = obj.console_site as ConfigFile["console_site"]; + if (typeof obj.console_region === "string" && obj.console_region.length > 0) + out.console_region = obj.console_region; + if (typeof obj.console_switch_agent === "number" && obj.console_switch_agent > 0) + out.console_switch_agent = obj.console_switch_agent; if (typeof obj.telemetry === "boolean") out.telemetry = obj.telemetry; return out; @@ -118,7 +128,9 @@ export interface Config { accessKeyId?: string; accessKeySecret?: string; workspaceId?: string; - consoleGatewayUrl: string; + consoleSite?: "domestic" | "international"; + consoleRegion?: string; + consoleSwitchAgent?: number; verbose: boolean; quiet: boolean; noColor: boolean; diff --git a/packages/core/src/console/gateway.ts b/packages/core/src/console/gateway.ts index a698d12..d391784 100644 --- a/packages/core/src/console/gateway.ts +++ b/packages/core/src/console/gateway.ts @@ -2,18 +2,56 @@ import type { Config } from "../config/schema.ts"; import { BailianError } from "../errors/base.ts"; import { ExitCode } from "../errors/codes.ts"; -const GATEWAY_ACTION = "BroadScopeAspnGateway"; const GATEWAY_PRODUCT = "sfm_bailian"; +export type ConsoleSite = "domestic" | "international"; + +interface ConsoleGatewayInfo { + csGateway: string; + action: string; +} + +const REGION_GATEWAYS: Record> = { + "cn-beijing": { + domestic: { csGateway: "bailian-cs.console.aliyun.com", action: "BroadScopeAspnGateway" }, + international: { + csGateway: "bailian-cs.console.alibabacloud.com", + action: "BroadScopeAspnGateway", + }, + }, + "ap-southeast-1": { + domestic: { + csGateway: "modelstudio-cs.console.aliyun.com", + action: "IntlBroadScopeAspnGateway", + }, + international: { + csGateway: "bailian-singapore-cs.alibabacloud.com", + action: "IntlBroadScopeAspnGateway", + }, + }, +}; + +function resolveGateway(region: string, site: ConsoleSite): ConsoleGatewayInfo { + return REGION_GATEWAYS[region]?.[site] ?? REGION_GATEWAYS["cn-beijing"]![site]; +} + export interface ConsoleGatewayRequest { /** Console API name, e.g. zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota */ api: string; data: Record; - /** Console region (default: cn-beijing), distinct from DashScope `config.region`. */ + /** Console region (e.g. cn-beijing, ap-southeast-1). Falls back to config.consoleRegion, then "cn-beijing". */ region?: string; + /** Console site. Falls back to config.consoleSite, then "domestic". */ + site?: ConsoleSite; + /** Switch-agent UID for delegated access. Falls back to config.consoleSwitchAgent. */ + switchAgent?: number; } -function buildGatewayParams(api: string, data: Record): string { +function buildGatewayParams( + api: string, + data: Record, + switchAgent?: number, +): string { return JSON.stringify({ Api: api, V: "1.0", @@ -24,6 +62,7 @@ function buildGatewayParams(api: string, data: Record): string console: "ONE_CONSOLE", productCode: "p_efm", consoleSite: "BAILIAN_ALIYUN", + ...(switchAgent != null ? { switchAgent } : {}), ...(typeof data.cornerstoneParam === "object" && data.cornerstoneParam !== null ? (data.cornerstoneParam as Record) : {}), @@ -37,17 +76,26 @@ function buildGatewayParams(api: string, data: Record): string * `token` is the console `access_token` (from `bl auth login --console`); when * omitted the request is sent without an Authorization header, which works for * public console APIs that don't require a login session. + * + * Gateway URL and action are resolved from `region + site` via {@link REGION_GATEWAYS}. + * Each parameter falls back to the corresponding config value, then to a hardcoded default. */ export async function callConsoleGateway( config: Config, token: string | undefined, - { api, data, region = "cn-beijing" }: ConsoleGatewayRequest, + { api, data, region, site, switchAgent }: ConsoleGatewayRequest, ): Promise { - const params = buildGatewayParams(api, data); - const body = new URLSearchParams({ params, region }); - const timeoutMs = config.timeout * 1000; + const effectiveRegion = region ?? config.consoleRegion ?? "cn-beijing"; + const effectiveSite = site ?? config.consoleSite ?? "domestic"; + const effectiveSwitchAgent = switchAgent ?? config.consoleSwitchAgent; + + const resolved = resolveGateway(effectiveRegion, effectiveSite); + const gatewayBase = `https://${resolved.csGateway}`; + const action = resolved.action; - const gatewayBase = config.consoleGatewayUrl; + const params = buildGatewayParams(api, data, effectiveSwitchAgent); + const body = new URLSearchParams({ params, region: effectiveRegion }); + const timeoutMs = config.timeout * 1000; const headers: Record = { Accept: "*/*", @@ -56,7 +104,7 @@ export async function callConsoleGateway( if (token) headers.Authorization = `Bearer ${token}`; const res = await fetch( - `${gatewayBase}/cli/api.json?action=${GATEWAY_ACTION}&product=${GATEWAY_PRODUCT}&api=${encodeURIComponent(api)}`, + `${gatewayBase}/cli/api.json?action=${action}&product=${GATEWAY_PRODUCT}&api=${encodeURIComponent(api)}`, { method: "POST", headers, diff --git a/packages/core/src/console/index.ts b/packages/core/src/console/index.ts index e08e08a..61cf595 100644 --- a/packages/core/src/console/index.ts +++ b/packages/core/src/console/index.ts @@ -1,4 +1,4 @@ -export type { ConsoleGatewayRequest } from "./gateway.ts"; +export type { ConsoleGatewayRequest, ConsoleSite } from "./gateway.ts"; export { callConsoleGateway } from "./gateway.ts"; export type { ModelListParams, ModelListResult } from "./models.ts"; export { fetchModelList } from "./models.ts"; diff --git a/packages/core/src/console/models.ts b/packages/core/src/console/models.ts index 0711790..70345c2 100644 --- a/packages/core/src/console/models.ts +++ b/packages/core/src/console/models.ts @@ -28,7 +28,7 @@ export async function fetchModelList( name = "", providers = [], capabilities = [], - region = "cn-beijing", + region, } = params; const result = (await callConsoleGateway(config, token, { diff --git a/packages/core/tests/index.test.ts b/packages/core/tests/index.test.ts index 5514413..704e7ad 100644 --- a/packages/core/tests/index.test.ts +++ b/packages/core/tests/index.test.ts @@ -22,7 +22,6 @@ function testConfig(overrides: Partial = {}): Config { nonInteractive: true, async: false, telemetry: true, - consoleGatewayUrl: "https://bailian-cs.console.aliyun.com", ...overrides, }; } diff --git a/skills/bailian-cli/reference/console.md b/skills/bailian-cli/reference/console.md index 50e5ea1..12e4e95 100644 --- a/skills/bailian-cli/reference/console.md +++ b/skills/bailian-cli/reference/console.md @@ -23,11 +23,13 @@ Index: [index.md](index.md) #### Options -| Flag | Type | Required | Description | -| ------------------- | ------ | -------- | ------------------------------------------------------------------------ | -| `--api ` | string | yes | API name (e.g. zeldaEasy.broadscope-bailian.memory-library.getLibraries) | -| `--data ` | string | yes | Request data as JSON string | -| `--region ` | string | no | API region (default: cn-beijing) | +| Flag | Type | Required | Description | +| ---------------------- | ------ | -------- | ------------------------------------------------------------------------ | +| `--api ` | string | yes | API name (e.g. zeldaEasy.broadscope-bailian.memory-library.getLibraries) | +| `--data ` | string | yes | Request data as JSON string | +| `--region ` | string | no | Console region (e.g. cn-beijing, ap-southeast-1) | +| `--site ` | string | no | Console site: domestic or international | +| `--switch-agent ` | string | no | Switch agent UID for delegated access | #### Examples From e68abb697586d7b3296c11e1baffc7f81bd830bf Mon Sep 17 00:00:00 2001 From: lishengzxc <306009337@qq.com> Date: Sun, 14 Jun 2026 22:35:33 +0800 Subject: [PATCH 02/20] refactor(auth): simplify login-console config persistence logic Extract hasConfig variable to deduplicate the multi-field condition check, remove the changed flag pattern in favor of direct write-through. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../cli/src/commands/auth/login-console.ts | 41 ++++++------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/packages/cli/src/commands/auth/login-console.ts b/packages/cli/src/commands/auth/login-console.ts index 5b9fcd7..1cc8f33 100644 --- a/packages/cli/src/commands/auth/login-console.ts +++ b/packages/cli/src/commands/auth/login-console.ts @@ -13,7 +13,7 @@ import { const CONSOLE_LOGIN_TIMEOUT_MS = 15 * 60 * 1000; const MAX_AUTH_CALLBACK_BODY = 65536; -const DEFAULT_CONSOLE_ORIGIN = "https://bailian.console.aliyun.com"; +const DEFAULT_CONSOLE_ORIGIN = "https://pre-bailian.console.aliyun.com"; export function resolveConsoleOrigin(): string { return process.env.BAILIAN_CONSOLE_ORIGIN || DEFAULT_CONSOLE_ORIGIN; @@ -323,38 +323,21 @@ export async function runConsoleLogin( const { accessToken, apiKey, baseUrl, consoleSite, consoleRegion, consoleSwitchAgent } = await extractCredentialsFromRequest(req); + const hasConfig = + accessToken || baseUrl || consoleSite || consoleRegion || consoleSwitchAgent; - if (accessToken || apiKey || baseUrl || consoleSite || consoleRegion || consoleSwitchAgent) { + if (hasConfig || apiKey) { try { - const existing = readConfigFile() as Record; - let changed = false; - - if (accessToken) { - existing.access_token = accessToken; - changed = true; - } - if (baseUrl) { - existing.base_url = baseUrl; - changed = true; - } - if (consoleSite) { - existing.console_site = consoleSite; - changed = true; - } - if (consoleRegion) { - existing.console_region = consoleRegion; - changed = true; - } - if (consoleSwitchAgent) { - existing.console_switch_agent = Number(consoleSwitchAgent); - changed = true; - } - - if (changed) { + if (hasConfig) { + const existing = readConfigFile() as Record; + if (accessToken) existing.access_token = accessToken; + if (baseUrl) existing.base_url = baseUrl; + if (consoleSite) existing.console_site = consoleSite; + if (consoleRegion) existing.console_region = consoleRegion; + if (consoleSwitchAgent) existing.console_switch_agent = Number(consoleSwitchAgent); await writeConfigFile(existing); process.stderr.write(`Config saved to ${getConfigPath()}\n`); } - if (apiKey && opts?.onApiKey) { await opts.onApiKey(apiKey); } @@ -373,7 +356,7 @@ export async function runConsoleLogin( }); res.end("OK\n"); - if (accessToken || apiKey || baseUrl || consoleSite || consoleRegion || consoleSwitchAgent) { + if (hasConfig || apiKey) { server.close(); } } catch { From 51d9833a3d6673c7a2e7e863d7d26cb507562cf0 Mon Sep 17 00:00:00 2001 From: lishengzxc <306009337@qq.com> Date: Sun, 14 Jun 2026 22:56:54 +0800 Subject: [PATCH 03/20] fix(auth): parse baseUrl/consoleSite/consoleRegion/consoleSwitchAgent from POST body These fields were only extracted from query params but the console sends them in the JSON POST body. Add parseExtrasFromRawBody() to handle JSON and form-urlencoded bodies. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../cli/src/commands/auth/login-console.ts | 81 ++++++++++++++++++- packages/cli/src/commands/auth/login.ts | 6 +- 2 files changed, 83 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/commands/auth/login-console.ts b/packages/cli/src/commands/auth/login-console.ts index 1cc8f33..e1e45ef 100644 --- a/packages/cli/src/commands/auth/login-console.ts +++ b/packages/cli/src/commands/auth/login-console.ts @@ -210,6 +210,66 @@ function parseApiKeyFromRawBody(raw: string, contentType: string): string | null return null; } +type CallbackExtras = Pick< + CallbackCredentials, + "baseUrl" | "consoleSite" | "consoleRegion" | "consoleSwitchAgent" +>; + +function stringField(o: Record, ...keys: string[]): string | null { + for (const k of keys) { + const v = o[k]; + if (typeof v === "string" && v.trim()) return v.trim(); + } + return null; +} + +function parseExtrasFromRawBody(raw: string, contentType: string): CallbackExtras { + const empty: CallbackExtras = { + baseUrl: null, + consoleSite: null, + consoleRegion: null, + consoleSwitchAgent: null, + }; + if (!raw.trim()) return empty; + + let obj: Record | null = null; + + const ct = contentType.toLowerCase(); + if (ct.includes("application/json") || ct.includes("text/json")) { + try { + const parsed = JSON.parse(raw.trim()); + if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) obj = parsed; + } catch { + /* */ + } + } + if (!obj && ct.includes("application/x-www-form-urlencoded")) { + try { + const params = new URLSearchParams(raw.trim()); + obj = Object.fromEntries(params); + } catch { + /* */ + } + } + if (!obj) { + try { + const parsed = JSON.parse(raw.trim()); + if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) obj = parsed; + } catch { + /* */ + } + } + + if (!obj) return empty; + + return { + baseUrl: stringField(obj, "base_url", "baseUrl"), + consoleSite: stringField(obj, "console_site", "consoleSite"), + consoleRegion: stringField(obj, "console_region", "consoleRegion"), + consoleSwitchAgent: stringField(obj, "console_switch_agent", "consoleSwitchAgent"), + }; +} + interface CallbackCredentials { accessToken: string | null; apiKey: string | null; @@ -264,7 +324,17 @@ async function extractCredentialsFromRequest( const accessToken = accessTokenFromQuery?.trim() || parseAccessTokenFromRawBody(raw, contentType); const apiKey = apiKeyFromQuery?.trim() || parseApiKeyFromRawBody(raw, contentType); - return { accessToken, apiKey, ...extras }; + + const bodyExtras = parseExtrasFromRawBody(raw, contentType); + + return { + accessToken, + apiKey, + baseUrl: extras.baseUrl || bodyExtras.baseUrl, + consoleSite: extras.consoleSite || bodyExtras.consoleSite, + consoleRegion: extras.consoleRegion || bodyExtras.consoleRegion, + consoleSwitchAgent: extras.consoleSwitchAgent || bodyExtras.consoleSwitchAgent, + }; } function listenServerOnFreeLocalPort(server: http.Server): Promise { @@ -298,7 +368,10 @@ function openInBrowser(url: string): Promise { export async function runConsoleLogin( consoleOrigin: string, - opts?: { needApiKey?: boolean; onApiKey?: (key: string) => Promise }, + opts?: { + needApiKey?: boolean; + onApiKey?: ({ apiKey, baseUrl }: { apiKey: string; baseUrl?: string }) => Promise; + }, ): Promise { const state = randomBytes(16).toString("hex"); let callbackError: unknown; @@ -323,6 +396,8 @@ export async function runConsoleLogin( const { accessToken, apiKey, baseUrl, consoleSite, consoleRegion, consoleSwitchAgent } = await extractCredentialsFromRequest(req); + + console.log({ accessToken, apiKey, baseUrl, consoleSite, consoleRegion, consoleSwitchAgent }); const hasConfig = accessToken || baseUrl || consoleSite || consoleRegion || consoleSwitchAgent; @@ -339,7 +414,7 @@ export async function runConsoleLogin( process.stderr.write(`Config saved to ${getConfigPath()}\n`); } if (apiKey && opts?.onApiKey) { - await opts.onApiKey(apiKey); + await opts.onApiKey({ apiKey, baseUrl: baseUrl ?? undefined }); } } catch (err: unknown) { callbackError = err; diff --git a/packages/cli/src/commands/auth/login.ts b/packages/cli/src/commands/auth/login.ts index 0fe05ed..3e4cd03 100644 --- a/packages/cli/src/commands/auth/login.ts +++ b/packages/cli/src/commands/auth/login.ts @@ -41,6 +41,8 @@ function canRetry(err: unknown): boolean { async function validateKeyAndPersist(config: Config, key: string): Promise { process.stderr.write("Testing key... "); + process.stderr.write("\r\n" + JSON.stringify(config)); + const testConfig = { ...config, apiKey: key }; const requestOpts = { url: chatEndpoint(testConfig.baseUrl), @@ -102,7 +104,9 @@ export default defineCommand({ const hasApiKey = !!(config.apiKey || config.fileApiKey); await runConsoleLogin(resolveConsoleOrigin(), { needApiKey: !hasApiKey, - onApiKey: (key) => validateKeyAndPersist(config, key), + onApiKey: ({ apiKey, baseUrl }) => { + return validateKeyAndPersist({ ...config, ...(baseUrl ? { baseUrl } : {}) }, apiKey); + }, }); return; } From 2182a2239f03c5ee1e2395213b2ef61573bd6480 Mon Sep 17 00:00:00 2001 From: lishengzxc <306009337@qq.com> Date: Sun, 14 Jun 2026 23:20:30 +0800 Subject: [PATCH 04/20] =?UTF-8?q?refactor(auth):=20unify=20console=20callb?= =?UTF-8?q?ack=20persistence=20=E2=80=94=20validate=20apiKey=20with=20call?= =?UTF-8?q?back's=20baseUrl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move apiKey validation into login-console.ts so it uses the baseUrl from the same callback (not stale config). All fields are now persisted in one place: config fields first, then apiKey validated + written. Remove onApiKey callback indirection from runConsoleLogin signature. Clean up debug logging. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../cli/src/commands/auth/login-console.ts | 76 +++++++++++++++++-- packages/cli/src/commands/auth/login.ts | 6 +- 2 files changed, 69 insertions(+), 13 deletions(-) diff --git a/packages/cli/src/commands/auth/login-console.ts b/packages/cli/src/commands/auth/login-console.ts index e1e45ef..0c3242c 100644 --- a/packages/cli/src/commands/auth/login-console.ts +++ b/packages/cli/src/commands/auth/login-console.ts @@ -5,15 +5,18 @@ import http from "node:http"; import { BailianError, ExitCode, + chatEndpoint, getConfigPath, readConfigFile, + requestJson, writeConfigFile, + type Config, } from "bailian-cli-core"; const CONSOLE_LOGIN_TIMEOUT_MS = 15 * 60 * 1000; const MAX_AUTH_CALLBACK_BODY = 65536; -const DEFAULT_CONSOLE_ORIGIN = "https://pre-bailian.console.aliyun.com"; +const DEFAULT_CONSOLE_ORIGIN = "https://bailian.console.aliyun.com"; export function resolveConsoleOrigin(): string { return process.env.BAILIAN_CONSOLE_ORIGIN || DEFAULT_CONSOLE_ORIGIN; @@ -366,12 +369,69 @@ function openInBrowser(url: string): Promise { }); } +const RETRY_DELAY_BASE_MS = 500; + +function canRetry(err: unknown): boolean { + if (err instanceof BailianError) { + if (err.exitCode === ExitCode.NETWORK || err.exitCode === ExitCode.TIMEOUT) return true; + const status = err.api?.httpStatus; + return status === 401 || (status !== undefined && status >= 500); + } + if (err instanceof Error) { + return ( + err.name === "AbortError" || + err.name === "TimeoutError" || + err.message.includes("timed out") || + err.message === "fetch failed" + ); + } + return false; +} + +async function validateAndPersistApiKey( + config: Config, + key: string, + baseUrl: string, +): Promise { + process.stderr.write("Testing key... "); + const testConfig = { ...config, apiKey: key, baseUrl }; + const requestOpts = { + url: chatEndpoint(testConfig.baseUrl), + method: "POST", + timeout: Math.min(config.timeout, 30), + body: { + model: "qwen-max", + messages: [{ role: "user", content: "hi" }], + max_tokens: 1, + }, + }; + + for (let attempt = 1; attempt <= 3; attempt++) { + try { + await requestJson(testConfig, requestOpts); + break; + } catch (err) { + if (attempt >= 3 || !canRetry(err)) { + process.stderr.write("Failed\n"); + throw new BailianError("API key validation failed", ExitCode.AUTH, "Invalid API key.", { + cause: err, + }); + } + const delayMs = RETRY_DELAY_BASE_MS * 2 ** (attempt - 1); + await new Promise((resolve) => setTimeout(resolve, delayMs)); + } + } + + process.stderr.write("Valid\n"); + const existing = readConfigFile() as Record; + existing.api_key = key; + await writeConfigFile(existing); +} + export async function runConsoleLogin( consoleOrigin: string, - opts?: { - needApiKey?: boolean; - onApiKey?: ({ apiKey, baseUrl }: { apiKey: string; baseUrl?: string }) => Promise; - }, + config: Config, + opts?: { needApiKey?: boolean }, ): Promise { const state = randomBytes(16).toString("hex"); let callbackError: unknown; @@ -397,7 +457,6 @@ export async function runConsoleLogin( const { accessToken, apiKey, baseUrl, consoleSite, consoleRegion, consoleSwitchAgent } = await extractCredentialsFromRequest(req); - console.log({ accessToken, apiKey, baseUrl, consoleSite, consoleRegion, consoleSwitchAgent }); const hasConfig = accessToken || baseUrl || consoleSite || consoleRegion || consoleSwitchAgent; @@ -413,8 +472,9 @@ export async function runConsoleLogin( await writeConfigFile(existing); process.stderr.write(`Config saved to ${getConfigPath()}\n`); } - if (apiKey && opts?.onApiKey) { - await opts.onApiKey({ apiKey, baseUrl: baseUrl ?? undefined }); + if (apiKey) { + const testBaseUrl = baseUrl || config.baseUrl; + await validateAndPersistApiKey(config, apiKey, testBaseUrl); } } catch (err: unknown) { callbackError = err; diff --git a/packages/cli/src/commands/auth/login.ts b/packages/cli/src/commands/auth/login.ts index 3e4cd03..540bd5e 100644 --- a/packages/cli/src/commands/auth/login.ts +++ b/packages/cli/src/commands/auth/login.ts @@ -41,7 +41,6 @@ function canRetry(err: unknown): boolean { async function validateKeyAndPersist(config: Config, key: string): Promise { process.stderr.write("Testing key... "); - process.stderr.write("\r\n" + JSON.stringify(config)); const testConfig = { ...config, apiKey: key }; const requestOpts = { @@ -102,11 +101,8 @@ export default defineCommand({ return; } const hasApiKey = !!(config.apiKey || config.fileApiKey); - await runConsoleLogin(resolveConsoleOrigin(), { + await runConsoleLogin(resolveConsoleOrigin(), config, { needApiKey: !hasApiKey, - onApiKey: ({ apiKey, baseUrl }) => { - return validateKeyAndPersist({ ...config, ...(baseUrl ? { baseUrl } : {}) }, apiKey); - }, }); return; } From 6c716e51204cbedca30ce9aab6ad2126fe4e03f5 Mon Sep 17 00:00:00 2001 From: lishengzxc <306009337@qq.com> Date: Sun, 14 Jun 2026 23:44:17 +0800 Subject: [PATCH 05/20] feat(auth): add --base-url flag to bl auth login When used with --api-key, validates the key against the specified base URL and persists it to config. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/cli/src/commands/auth/login.ts | 14 +++++++++++++- skills/bailian-cli/reference/auth.md | 9 +++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/commands/auth/login.ts b/packages/cli/src/commands/auth/login.ts index 540bd5e..71440f8 100644 --- a/packages/cli/src/commands/auth/login.ts +++ b/packages/cli/src/commands/auth/login.ts @@ -85,6 +85,10 @@ export default defineCommand({ usage: "bl auth login --api-key | bl auth login --console", options: [ { flag: "--api-key ", description: "DashScope API key to store" }, + { + flag: "--base-url ", + description: "DashScope API base URL (used with --api-key for validation)", + }, { flag: "--console", description: "Sign in via browser; opens the console login URL in your default browser", @@ -130,8 +134,16 @@ export default defineCommand({ process.exit(0); } + const baseUrl = (flags.baseUrl as string) || undefined; + const effectiveConfig = baseUrl ? { ...config, baseUrl } : config; + if (!config.dryRun) { - await validateKeyAndPersist(config, key); + await validateKeyAndPersist(effectiveConfig, key); + if (baseUrl) { + const existing = readConfigFile() as Record; + existing.base_url = baseUrl; + await writeConfigFile(existing); + } printQuickStart(); } else { emitBare("Would validate and save API key."); diff --git a/skills/bailian-cli/reference/auth.md b/skills/bailian-cli/reference/auth.md index 3790ae5..e51eb1a 100644 --- a/skills/bailian-cli/reference/auth.md +++ b/skills/bailian-cli/reference/auth.md @@ -25,10 +25,11 @@ Index: [index.md](index.md) #### Options -| Flag | Type | Required | Description | -| ----------------- | ------- | -------- | ------------------------------------------------------------------------ | -| `--api-key ` | string | no | DashScope API key to store | -| `--console` | boolean | no | Sign in via browser; opens the console login URL in your default browser | +| Flag | Type | Required | Description | +| ------------------ | ------- | -------- | ------------------------------------------------------------------------ | +| `--api-key ` | string | no | DashScope API key to store | +| `--base-url ` | string | no | DashScope API base URL (used with --api-key for validation) | +| `--console` | boolean | no | Sign in via browser; opens the console login URL in your default browser | #### Examples From 36a60a28482be7ad9902c9d9aca65f4d381abb09 Mon Sep 17 00:00:00 2001 From: lishengzxc <306009337@qq.com> Date: Sun, 14 Jun 2026 23:46:35 +0800 Subject: [PATCH 06/20] =?UTF-8?q?chore(pnpm):=20=E7=A7=BB=E9=99=A4=20vite?= =?UTF-8?q?=20=E5=92=8C=20vitest=20=E7=9A=84=20overrides=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pnpm-lock.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 55a0fcb..57503c7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,10 +28,6 @@ catalogs: specifier: ^2.8.3 version: 2.8.3 -overrides: - vite: npm:@voidzero-dev/vite-plus-core@latest - vitest: npm:@voidzero-dev/vite-plus-test@latest - importers: .: From 270412d146ad37c168d5431550bf00560819f323 Mon Sep 17 00:00:00 2001 From: lishengzxc <306009337@qq.com> Date: Mon, 15 Jun 2026 00:26:57 +0800 Subject: [PATCH 07/20] refactor(auth): deduplicate canRetry/validateKey between login.ts and login-console.ts Export validateAndPersistApiKey from login-console.ts and reuse in login.ts. Remove duplicated canRetry, RETRY_DELAY_BASE_MS, and validateKeyAndPersist from login.ts. Unify validation model to qwen3.7-max. Reorder base_url write before apiKey validation in the --api-key path to avoid double read-modify-write. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../cli/src/commands/auth/login-console.ts | 4 +- packages/cli/src/commands/auth/login.ts | 74 ++----------------- 2 files changed, 8 insertions(+), 70 deletions(-) diff --git a/packages/cli/src/commands/auth/login-console.ts b/packages/cli/src/commands/auth/login-console.ts index 0c3242c..15ed539 100644 --- a/packages/cli/src/commands/auth/login-console.ts +++ b/packages/cli/src/commands/auth/login-console.ts @@ -388,7 +388,7 @@ function canRetry(err: unknown): boolean { return false; } -async function validateAndPersistApiKey( +export async function validateAndPersistApiKey( config: Config, key: string, baseUrl: string, @@ -400,7 +400,7 @@ async function validateAndPersistApiKey( method: "POST", timeout: Math.min(config.timeout, 30), body: { - model: "qwen-max", + model: "qwen3.7-max", messages: [{ role: "user", content: "hi" }], max_tokens: 1, }, diff --git a/packages/cli/src/commands/auth/login.ts b/packages/cli/src/commands/auth/login.ts index 71440f8..1327ba6 100644 --- a/packages/cli/src/commands/auth/login.ts +++ b/packages/cli/src/commands/auth/login.ts @@ -1,13 +1,8 @@ import { - BailianError, - ExitCode, - chatEndpoint, defineCommand, - getConfigPath, isInteractive, maskToken, readConfigFile, - requestJson, writeConfigFile, type Config, type GlobalFlags, @@ -16,68 +11,11 @@ import { printQuickStart } from "../../output/banner.ts"; import { emitBare } from "../../output/output.ts"; import { promptConfirm } from "../../output/prompt.ts"; import { printCurrentCommandHelp } from "../../utils/command-help.ts"; -import { resolveConsoleOrigin, runConsoleLogin } from "./login-console.ts"; - -const RETRY_DELAY_BASE_MS = 500; - -function canRetry(err: unknown): boolean { - if (err instanceof BailianError) { - if (err.exitCode === ExitCode.NETWORK || err.exitCode === ExitCode.TIMEOUT) { - return true; - } - const status = err.api?.httpStatus; - return status === 401 || (status !== undefined && status >= 500); - } - if (err instanceof Error) { - return ( - err.name === "AbortError" || - err.name === "TimeoutError" || - err.message.includes("timed out") || - err.message === "fetch failed" - ); - } - return false; -} - -async function validateKeyAndPersist(config: Config, key: string): Promise { - process.stderr.write("Testing key... "); - - const testConfig = { ...config, apiKey: key }; - const requestOpts = { - url: chatEndpoint(testConfig.baseUrl), - method: "POST", - timeout: Math.min(config.timeout, 30), - body: { - model: "qwen3.7-max", - messages: [{ role: "user", content: "hi" }], - max_tokens: 1, - }, - }; - - for (let attempt = 1; attempt <= 3; attempt++) { - try { - await requestJson(testConfig, requestOpts); - break; - } catch (err) { - if (attempt >= 3 || !canRetry(err)) { - process.stderr.write("\n"); - throw new BailianError("API key validation failed", ExitCode.AUTH, "Invalid API key.", { - cause: err, - }); - } - // retry delay: 500ms, 1000ms, 2000ms - const delayMs = RETRY_DELAY_BASE_MS * 2 ** (attempt - 1); - await new Promise((resolve) => setTimeout(resolve, delayMs)); - } - } - - process.stderr.write("Valid\n"); - - const existing = readConfigFile() as Record; - existing.api_key = key; - await writeConfigFile(existing); - process.stderr.write(`Saved to ${getConfigPath()}\n`); -} +import { + resolveConsoleOrigin, + runConsoleLogin, + validateAndPersistApiKey, +} from "./login-console.ts"; export default defineCommand({ name: "auth login", @@ -138,12 +76,12 @@ export default defineCommand({ const effectiveConfig = baseUrl ? { ...config, baseUrl } : config; if (!config.dryRun) { - await validateKeyAndPersist(effectiveConfig, key); if (baseUrl) { const existing = readConfigFile() as Record; existing.base_url = baseUrl; await writeConfigFile(existing); } + await validateAndPersistApiKey(effectiveConfig, key, effectiveConfig.baseUrl); printQuickStart(); } else { emitBare("Would validate and save API key."); From f45b19c2618844670337d69c4df8a9624f0d8d66 Mon Sep 17 00:00:00 2001 From: lishengzxc <306009337@qq.com> Date: Mon, 15 Jun 2026 01:01:26 +0800 Subject: [PATCH 08/20] chore: remove console_gateway_url remnants from schema and tests Field was replaced by region+site gateway resolution but ConfigFile definition, parseConfigFile logic, and test case were left behind. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/core/src/config/schema.ts | 7 ++----- packages/core/tests/index.test.ts | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/core/src/config/schema.ts b/packages/core/src/config/schema.ts index b98ff25..76275a6 100644 --- a/packages/core/src/config/schema.ts +++ b/packages/core/src/config/schema.ts @@ -31,7 +31,6 @@ export interface ConfigFile { access_key_id?: string; access_key_secret?: string; workspace_id?: string; - console_gateway_url?: string; console_site?: "domestic" | "international"; console_region?: string; console_switch_agent?: number; @@ -43,8 +42,8 @@ const VALID_OUTPUTS = new Set(["text", "json"]); const VALID_CONSOLE_SITES = new Set(["domestic", "international"]); /** - * A syntactically valid absolute http(s) URL. Used to validate `base_url` and - * `console_gateway_url` from the config file: the credential-bearing client + * A syntactically valid absolute http(s) URL. Used to validate `base_url` + * from the config file: the credential-bearing client * sends the Bearer token to these origins, so a bare `startsWith("http")` check * (which also accepts e.g. "httpfoo://…") is too loose. */ @@ -91,8 +90,6 @@ export function parseConfigFile(raw: unknown): ConfigFile { out.access_key_secret = obj.access_key_secret; if (typeof obj.workspace_id === "string" && obj.workspace_id.length > 0) out.workspace_id = obj.workspace_id; - if (typeof obj.console_gateway_url === "string" && isHttpUrl(obj.console_gateway_url)) - out.console_gateway_url = obj.console_gateway_url; if (typeof obj.console_site === "string" && VALID_CONSOLE_SITES.has(obj.console_site)) out.console_site = obj.console_site as ConfigFile["console_site"]; if (typeof obj.console_region === "string" && obj.console_region.length > 0) diff --git a/packages/core/tests/index.test.ts b/packages/core/tests/index.test.ts index 704e7ad..fd433e1 100644 --- a/packages/core/tests/index.test.ts +++ b/packages/core/tests/index.test.ts @@ -199,7 +199,7 @@ test("parseBooleanValue accepts only true and false strings (case-insensitive)", expect(() => parseBooleanValue("maybe")).toThrow(BailianError); }); -test("parseConfigFile accepts only well-formed http(s) base_url / console_gateway_url", () => { +test("parseConfigFile accepts only well-formed http(s) base_url", () => { expect(parseConfigFile({ base_url: "https://dashscope.aliyuncs.com" }).base_url).toBe( "https://dashscope.aliyuncs.com", ); @@ -209,5 +209,4 @@ test("parseConfigFile accepts only well-formed http(s) base_url / console_gatewa // Previously accepted because the value merely "starts with http". expect(parseConfigFile({ base_url: "httpfoo://evil" }).base_url).toBeUndefined(); expect(parseConfigFile({ base_url: "not a url" }).base_url).toBeUndefined(); - expect(parseConfigFile({ console_gateway_url: "ftp://x" }).console_gateway_url).toBeUndefined(); }); From 7a65fb850cba9caeebad6d7602ce046acb6f2ad2 Mon Sep 17 00:00:00 2001 From: lishengzxc <306009337@qq.com> Date: Mon, 15 Jun 2026 01:05:00 +0800 Subject: [PATCH 09/20] feat(auth): parse and persist workspace_id from console login callback Adapts to bailian-cli-login af06baf which added workspace_id to the notifyToken payload. The field is parsed from query/body and written to config.json as workspace_id. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../cli/src/commands/auth/login-console.ts | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/commands/auth/login-console.ts b/packages/cli/src/commands/auth/login-console.ts index 15ed539..b0da573 100644 --- a/packages/cli/src/commands/auth/login-console.ts +++ b/packages/cli/src/commands/auth/login-console.ts @@ -215,7 +215,7 @@ function parseApiKeyFromRawBody(raw: string, contentType: string): string | null type CallbackExtras = Pick< CallbackCredentials, - "baseUrl" | "consoleSite" | "consoleRegion" | "consoleSwitchAgent" + "baseUrl" | "consoleSite" | "consoleRegion" | "consoleSwitchAgent" | "workspaceId" >; function stringField(o: Record, ...keys: string[]): string | null { @@ -232,6 +232,7 @@ function parseExtrasFromRawBody(raw: string, contentType: string): CallbackExtra consoleSite: null, consoleRegion: null, consoleSwitchAgent: null, + workspaceId: null, }; if (!raw.trim()) return empty; @@ -270,6 +271,7 @@ function parseExtrasFromRawBody(raw: string, contentType: string): CallbackExtra consoleSite: stringField(obj, "console_site", "consoleSite"), consoleRegion: stringField(obj, "console_region", "consoleRegion"), consoleSwitchAgent: stringField(obj, "console_switch_agent", "consoleSwitchAgent"), + workspaceId: stringField(obj, "workspace_id", "workspaceId"), }; } @@ -280,6 +282,7 @@ interface CallbackCredentials { consoleSite: string | null; consoleRegion: string | null; consoleSwitchAgent: string | null; + workspaceId: string | null; } async function extractCredentialsFromRequest( @@ -296,12 +299,15 @@ async function extractCredentialsFromRequest( u.searchParams.get("console_region") ?? u.searchParams.get("consoleRegion"); const consoleSwitchAgentFromQuery = u.searchParams.get("console_switch_agent") ?? u.searchParams.get("consoleSwitchAgent"); + const workspaceIdFromQuery = + u.searchParams.get("workspace_id") ?? u.searchParams.get("workspaceId"); const extras = { baseUrl: baseUrlFromQuery?.trim() || null, consoleSite: consoleSiteFromQuery?.trim() || null, consoleRegion: consoleRegionFromQuery?.trim() || null, consoleSwitchAgent: consoleSwitchAgentFromQuery?.trim() || null, + workspaceId: workspaceIdFromQuery?.trim() || null, }; const m = req.method ?? "GET"; @@ -337,6 +343,7 @@ async function extractCredentialsFromRequest( consoleSite: extras.consoleSite || bodyExtras.consoleSite, consoleRegion: extras.consoleRegion || bodyExtras.consoleRegion, consoleSwitchAgent: extras.consoleSwitchAgent || bodyExtras.consoleSwitchAgent, + workspaceId: extras.workspaceId || bodyExtras.workspaceId, }; } @@ -454,11 +461,18 @@ export async function runConsoleLogin( return; } - const { accessToken, apiKey, baseUrl, consoleSite, consoleRegion, consoleSwitchAgent } = - await extractCredentialsFromRequest(req); + const { + accessToken, + apiKey, + baseUrl, + consoleSite, + consoleRegion, + consoleSwitchAgent, + workspaceId, + } = await extractCredentialsFromRequest(req); const hasConfig = - accessToken || baseUrl || consoleSite || consoleRegion || consoleSwitchAgent; + accessToken || baseUrl || consoleSite || consoleRegion || consoleSwitchAgent || workspaceId; if (hasConfig || apiKey) { try { @@ -469,6 +483,7 @@ export async function runConsoleLogin( if (consoleSite) existing.console_site = consoleSite; if (consoleRegion) existing.console_region = consoleRegion; if (consoleSwitchAgent) existing.console_switch_agent = Number(consoleSwitchAgent); + if (workspaceId) existing.workspace_id = workspaceId; await writeConfigFile(existing); process.stderr.write(`Config saved to ${getConfigPath()}\n`); } From 4749b493da64df9ebcfafdef362f8b47d6732a62 Mon Sep 17 00:00:00 2001 From: lishengzxc <306009337@qq.com> Date: Mon, 15 Jun 2026 13:11:49 +0800 Subject: [PATCH 10/20] =?UTF-8?q?feat(auth):=20=E6=9B=B4=E6=96=B0=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=8E=A7=E5=88=B6=E5=8F=B0=E7=99=BB=E5=BD=95=E9=A1=B5?= =?UTF-8?q?=E4=B8=BA=E4=B8=AD=E5=9B=BD=E7=AB=99=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cli/src/commands/auth/login-console.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/commands/auth/login-console.ts b/packages/cli/src/commands/auth/login-console.ts index b0da573..17eebe1 100644 --- a/packages/cli/src/commands/auth/login-console.ts +++ b/packages/cli/src/commands/auth/login-console.ts @@ -16,7 +16,8 @@ import { const CONSOLE_LOGIN_TIMEOUT_MS = 15 * 60 * 1000; const MAX_AUTH_CALLBACK_BODY = 65536; -const DEFAULT_CONSOLE_ORIGIN = "https://bailian.console.aliyun.com"; +// 总是默认打开 中国站的登录页 +const DEFAULT_CONSOLE_ORIGIN = "https://pre-bailian.console.aliyun.com"; export function resolveConsoleOrigin(): string { return process.env.BAILIAN_CONSOLE_ORIGIN || DEFAULT_CONSOLE_ORIGIN; From e5abd1b5540b38855580fd82a2d77b1fc6bde001 Mon Sep 17 00:00:00 2001 From: lishengzxc <306009337@qq.com> Date: Mon, 15 Jun 2026 13:53:41 +0800 Subject: [PATCH 11/20] =?UTF-8?q?feat(auth):=20=E6=9B=B4=E6=96=B0=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=8E=A7=E5=88=B6=E5=8F=B0=E7=99=BB=E5=BD=95=E9=A1=B5?= =?UTF-8?q?=E4=B8=BA=E6=AD=A3=E5=BC=8F=E4=B8=AD=E5=9B=BD=E7=AB=99=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cli/src/commands/auth/login-console.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/commands/auth/login-console.ts b/packages/cli/src/commands/auth/login-console.ts index 17eebe1..ddb159b 100644 --- a/packages/cli/src/commands/auth/login-console.ts +++ b/packages/cli/src/commands/auth/login-console.ts @@ -17,10 +17,10 @@ const CONSOLE_LOGIN_TIMEOUT_MS = 15 * 60 * 1000; const MAX_AUTH_CALLBACK_BODY = 65536; // 总是默认打开 中国站的登录页 -const DEFAULT_CONSOLE_ORIGIN = "https://pre-bailian.console.aliyun.com"; +const DEFAULT_CONSOLE_ORIGIN = "https://bailian.console.aliyun.com"; export function resolveConsoleOrigin(): string { - return process.env.BAILIAN_CONSOLE_ORIGIN || DEFAULT_CONSOLE_ORIGIN; + return DEFAULT_CONSOLE_ORIGIN; } function readBodyBounded(req: http.IncomingMessage): Promise { From ce64d628bb0639e3452a3317f7a48f79c5284b28 Mon Sep 17 00:00:00 2001 From: qcq01083097 Date: Tue, 16 Jun 2026 11:08:33 +0800 Subject: [PATCH 12/20] feat: The command "config show" does not display the "region" field, but displays all fields in the "config.json" file --- packages/cli/src/commands/config/show.ts | 20 ++++++++------------ packages/cli/src/output/status-bar.ts | 4 ---- packages/cli/tests/e2e/config.e2e.test.ts | 18 +----------------- pnpm-lock.yaml | 4 ++++ 4 files changed, 13 insertions(+), 33 deletions(-) diff --git a/packages/cli/src/commands/config/show.ts b/packages/cli/src/commands/config/show.ts index 6f268e2..37e590c 100644 --- a/packages/cli/src/commands/config/show.ts +++ b/packages/cli/src/commands/config/show.ts @@ -19,25 +19,21 @@ export default defineCommand({ const format = detectOutputFormat(config.output); const result: Record = { - region: config.region, + ...file, base_url: config.baseUrl, output: config.output, timeout: config.timeout, config_file: getConfigPath(), }; - // Mask API key if present - if (file.api_key) { - result.api_key = maskToken(file.api_key); + if (typeof result.api_key === "string") result.api_key = maskToken(result.api_key); + if (typeof result.access_token === "string") + result.access_token = maskToken(result.access_token); + if (typeof result.access_key_id === "string") + result.access_key_id = maskToken(result.access_key_id); + if (typeof result.access_key_secret === "string") { + result.access_key_secret = maskToken(result.access_key_secret); } - if (file.access_token) { - result.access_token = maskToken(file.access_token); - } - - // Default models - if (file.default_text_model) result.default_text_model = file.default_text_model; - if (file.default_video_model) result.default_video_model = file.default_video_model; - if (file.default_image_model) result.default_image_model = file.default_image_model; emitResult(result, format); }, diff --git a/packages/cli/src/output/status-bar.ts b/packages/cli/src/output/status-bar.ts index 9797ead..54abbee 100644 --- a/packages/cli/src/output/status-bar.ts +++ b/packages/cli/src/output/status-bar.ts @@ -5,7 +5,6 @@ const reset = "\x1b[0m"; const dim = "\x1b[2m"; const bold = "\x1b[1m"; const mmBlue = "\x1b[38;2;43;82;255m"; -const mmCyan = "\x1b[38;2;6;184;212m"; const mmPink = "\x1b[38;2;236;72;153m"; function tildePath(p: string): string { @@ -20,7 +19,6 @@ export function maybeShowStatusBar( if (config.quiet || !process.stderr.isTTY) return; const filePath = config.configPath ? tildePath(config.configPath) : "~/.bailian/config.json"; - const regionSrc = config.fileRegion ? `${config.fileRegion} (file)` : "cn (default)"; const authTag = resolved ? `${resolved.source} · ${resolved.method}` : config.apiKey @@ -32,8 +30,6 @@ export function maybeShowStatusBar( `${bold}${mmBlue}BAILIAN${reset} ` + `${dim}${filePath}${reset} ` + `${dim}|${reset} ` + - `${dim}Region:${reset} ${mmCyan}${regionSrc}${reset} ` + - `${dim}|${reset} ` + `${dim}Auth:${reset} ${mmPink}${maskedKey}${reset} ${dim}${authTag}${reset}\n`, ); } diff --git a/packages/cli/tests/e2e/config.e2e.test.ts b/packages/cli/tests/e2e/config.e2e.test.ts index f024174..5527e32 100644 --- a/packages/cli/tests/e2e/config.e2e.test.ts +++ b/packages/cli/tests/e2e/config.e2e.test.ts @@ -41,12 +41,10 @@ describe("e2e: config", () => { ]); expect(exitCode, stderr).toBe(0); const data = parseStdoutJson<{ - region?: string; config_file?: string; base_url?: string; timeout?: number; }>(stdout); - expect(data.region).toBeDefined(); expect(data.config_file).toBeDefined(); expect(data.base_url).toBeDefined(); expect(data.timeout).toBeDefined(); @@ -62,7 +60,7 @@ describe("e2e: config", () => { "--no-color", ]); expect(exitCode, stderr).toBe(0); - expect(stdout).toMatch(/region|config_file|timeout|base_url/i); + expect(stdout).toMatch(/config_file|timeout|base_url/i); }); test("config set 缺少 --key / --value 时退出为用法错误 (2)", async () => { @@ -85,20 +83,6 @@ describe("e2e: config", () => { expect(stderr).toMatch(/Invalid config key|not-a-real-key/i); }); - test("config set 非法 region", async () => { - const { stderr, exitCode } = await runCli([ - "config", - "set", - "--non-interactive", - "--key", - "region", - "--value", - "invalid-region", - ]); - expect(exitCode).toBe(2); - expect(stderr).toMatch(/Invalid region|cn, us, intl/i); - }); - test("config set 非法 output", async () => { const { stderr, exitCode } = await runCli([ "config", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 57503c7..55a0fcb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,6 +28,10 @@ catalogs: specifier: ^2.8.3 version: 2.8.3 +overrides: + vite: npm:@voidzero-dev/vite-plus-core@latest + vitest: npm:@voidzero-dev/vite-plus-test@latest + importers: .: From 2bcbf562829ea756444903890567922be720cc29 Mon Sep 17 00:00:00 2001 From: qcq01083097 Date: Tue, 16 Jun 2026 11:27:29 +0800 Subject: [PATCH 13/20] feat: Fix lint errors in mcp.ts --- packages/cli/tests/e2e/mcp.e2e.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/cli/tests/e2e/mcp.e2e.test.ts b/packages/cli/tests/e2e/mcp.e2e.test.ts index bc5ef52..0b91cd6 100644 --- a/packages/cli/tests/e2e/mcp.e2e.test.ts +++ b/packages/cli/tests/e2e/mcp.e2e.test.ts @@ -79,7 +79,6 @@ describe("e2e: mcp", () => { }; }>(stdout); expect(data.api).toBe("zeldaEasy.broadscope-bailian.mcp-server.PageList"); - expect(data.region).toBe("cn-beijing"); expect(data.data?.reqDTO?.activated).toBe(1); expect(data.data?.reqDTO?.displayTools).toBe(false); expect(data.data?.reqDTO?.type).toBe("OFFICIAL"); From 8c398bae573e02e490a2a5dd33a15445362d28e4 Mon Sep 17 00:00:00 2001 From: lishengzxc <306009337@qq.com> Date: Tue, 16 Jun 2026 13:56:20 +0800 Subject: [PATCH 14/20] refactor(console): promote --console-region, --console-site, --console-switch-agent to global flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Eliminate per-command --region/--site/--switch-agent duplication across 11 console gateway commands. These values now flow through config (CLI flags → config file → defaults) and are consumed by callConsoleGateway automatically. Also wire consoleSite into resolveConsoleOrigin so --console-site selects the correct login URL (domestic vs international). Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/cli/src/commands/app/list.ts | 11 +------ .../cli/src/commands/auth/login-console.ts | 10 +++--- packages/cli/src/commands/auth/login.ts | 8 ++--- packages/cli/src/commands/console/call.ts | 23 ++----------- packages/cli/src/commands/mcp/list.ts | 5 +-- packages/cli/src/commands/quota/check.ts | 19 ++--------- packages/cli/src/commands/quota/history.ts | 8 +---- packages/cli/src/commands/quota/list.ts | 11 ++----- packages/cli/src/commands/quota/request.ts | 12 ++----- packages/cli/src/commands/usage/free.ts | 10 +----- packages/cli/src/commands/usage/freetier.ts | 14 ++------ packages/cli/src/commands/usage/stats.ts | 15 +++------ packages/cli/src/commands/workspace/list.ts | 8 +---- packages/cli/tests/e2e/mcp.e2e.test.ts | 8 ++--- packages/cli/tests/e2e/usage-free.e2e.test.ts | 4 +-- packages/core/src/config/loader.ts | 7 ++-- packages/core/src/console/gateway.ts | 17 +++++++--- packages/core/src/types/command.ts | 10 ++++++ packages/core/src/types/flags.ts | 3 ++ skills/bailian-cli/reference/app.md | 11 +++---- skills/bailian-cli/reference/auth.md | 10 +++--- skills/bailian-cli/reference/console.md | 13 +++----- skills/bailian-cli/reference/index.md | 33 ++++++++++--------- skills/bailian-cli/reference/mcp.md | 13 ++++---- skills/bailian-cli/reference/quota.md | 32 ++++++++---------- skills/bailian-cli/reference/usage.md | 17 ++++------ skills/bailian-cli/reference/workspace.md | 7 ++-- 27 files changed, 128 insertions(+), 211 deletions(-) diff --git a/packages/cli/src/commands/app/list.ts b/packages/cli/src/commands/app/list.ts index d4f8784..28e55b2 100644 --- a/packages/cli/src/commands/app/list.ts +++ b/packages/cli/src/commands/app/list.ts @@ -29,10 +29,6 @@ export default defineCommand({ description: "Results per page (default: 30)", type: "number", }, - { - flag: "--region ", - description: "API region (default: cn-beijing)", - }, ], examples: [ "bl app list", @@ -44,7 +40,6 @@ export default defineCommand({ const name = (flags.name as string) || ""; const pageNo = (flags.page as number) || 1; const pageSize = (flags.pageSize as number) || 30; - const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); const credential = await resolveConsoleGatewayCredential(config); @@ -61,17 +56,13 @@ export default defineCommand({ }; if (config.dryRun) { - emitResult( - { api: APP_LIST_API, data, region, token: credential.token.slice(0, 8) + "..." }, - format, - ); + emitResult({ api: APP_LIST_API, data, token: credential.token.slice(0, 8) + "..." }, format); return; } const result = (await callConsoleGateway(config, credential.token, { api: APP_LIST_API, data, - region, })) as any; const list: unknown[] = result?.data?.DataV2?.data?.data?.list ?? []; diff --git a/packages/cli/src/commands/auth/login-console.ts b/packages/cli/src/commands/auth/login-console.ts index ddb159b..bfe3193 100644 --- a/packages/cli/src/commands/auth/login-console.ts +++ b/packages/cli/src/commands/auth/login-console.ts @@ -16,11 +16,13 @@ import { const CONSOLE_LOGIN_TIMEOUT_MS = 15 * 60 * 1000; const MAX_AUTH_CALLBACK_BODY = 65536; -// 总是默认打开 中国站的登录页 -const DEFAULT_CONSOLE_ORIGIN = "https://bailian.console.aliyun.com"; +const CONSOLE_ORIGINS: Record = { + domestic: "https://bailian.console.aliyun.com", + international: "https://modelstudio.console.alibabacloud.com", +}; -export function resolveConsoleOrigin(): string { - return DEFAULT_CONSOLE_ORIGIN; +export function resolveConsoleOrigin(site?: string): string { + return (site && CONSOLE_ORIGINS[site]) || CONSOLE_ORIGINS.domestic!; } function readBodyBounded(req: http.IncomingMessage): Promise { diff --git a/packages/cli/src/commands/auth/login.ts b/packages/cli/src/commands/auth/login.ts index 1327ba6..9c3c7eb 100644 --- a/packages/cli/src/commands/auth/login.ts +++ b/packages/cli/src/commands/auth/login.ts @@ -28,9 +28,9 @@ export default defineCommand({ description: "DashScope API base URL (used with --api-key for validation)", }, { - flag: "--console", - description: "Sign in via browser; opens the console login URL in your default browser", - type: "boolean", + flag: "--console ", + description: + "Sign in via browser; use --console-site to choose domestic (default) or international", }, ], examples: ["bl auth login --api-key sk-xxxxx", "bl auth login --console"], @@ -43,7 +43,7 @@ export default defineCommand({ return; } const hasApiKey = !!(config.apiKey || config.fileApiKey); - await runConsoleLogin(resolveConsoleOrigin(), config, { + await runConsoleLogin(resolveConsoleOrigin(config.consoleSite), config, { needApiKey: !hasApiKey, }); return; diff --git a/packages/cli/src/commands/console/call.ts b/packages/cli/src/commands/console/call.ts index ae4e552..4bf9ee6 100644 --- a/packages/cli/src/commands/console/call.ts +++ b/packages/cli/src/commands/console/call.ts @@ -7,7 +7,6 @@ import { detectOutputFormat, type Config, type GlobalFlags, - type ConsoleSite, } from "bailian-cli-core"; import { failIfMissing } from "../../output/prompt.ts"; import { emitResult } from "../../output/output.ts"; @@ -27,22 +26,10 @@ export default defineCommand({ description: "Request data as JSON string", required: true, }, - { - flag: "--region ", - description: "Console region (e.g. cn-beijing, ap-southeast-1)", - }, - { - flag: "--site ", - description: "Console site: domestic or international", - }, - { - flag: "--switch-agent ", - description: "Switch agent UID for delegated access", - }, ], examples: [ `bl console call --api zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota --data '{"queryFreeTierQuotaRequest":{"models":["qwen3-max"]}}'`, - `bl console call --api some.api.name --data '{"key":"value"}' --region cn-beijing`, + `bl console call --api some.api.name --data '{"key":"value"}' --console-region cn-beijing`, ], async run(config: Config, flags: GlobalFlags) { const api = flags.api as string; @@ -59,9 +46,6 @@ export default defineCommand({ process.exit(1); } - const region = (flags.region as string) || undefined; - const site = ((flags.site as string) || undefined) as ConsoleSite | undefined; - const switchAgent = flags.switchAgent ? Number(flags.switchAgent) : undefined; const format = detectOutputFormat(config.output); let token: string | undefined; @@ -74,16 +58,13 @@ export default defineCommand({ } if (config.dryRun) { - emitResult({ api, data, region, token: token ? token.slice(0, 8) + "..." : null }, format); + emitResult({ api, data, token: token ? token.slice(0, 8) + "..." : null }, format); return; } const result = await callConsoleGateway(config, token, { api, data, - region, - site, - switchAgent, }); emitResult(result, format); diff --git a/packages/cli/src/commands/mcp/list.ts b/packages/cli/src/commands/mcp/list.ts index 5edd6f0..1e6e747 100644 --- a/packages/cli/src/commands/mcp/list.ts +++ b/packages/cli/src/commands/mcp/list.ts @@ -35,7 +35,6 @@ export default defineCommand({ }, { flag: "--page ", description: "Page number (default: 1)", type: "number" }, { flag: "--page-size ", description: "Results per page (default: 30)", type: "number" }, - { flag: "--region ", description: "API region (default: cn-beijing)" }, ], examples: ["bl mcp list", "bl mcp list --name 金融", "bl mcp list --output json"], async run(config: Config, flags: GlobalFlags) { @@ -43,7 +42,6 @@ export default defineCommand({ const type = (flags.type as string) || "OFFICIAL"; const pageNo = (flags.page as number) || 1; const pageSize = (flags.pageSize as number) || 30; - const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); const data = { @@ -58,7 +56,7 @@ export default defineCommand({ }; if (config.dryRun) { - emitResult({ api: MCP_LIST_API, data, region }, format); + emitResult({ api: MCP_LIST_API, data }, format); return; } @@ -67,7 +65,6 @@ export default defineCommand({ const result = (await callConsoleGateway(config, credential.token, { api: MCP_LIST_API, data, - region, })) as Record; const dataField = (result?.data as Record | undefined) ?? {}; diff --git a/packages/cli/src/commands/quota/check.ts b/packages/cli/src/commands/quota/check.ts index ba7a225..f00ab44 100644 --- a/packages/cli/src/commands/quota/check.ts +++ b/packages/cli/src/commands/quota/check.ts @@ -91,11 +91,7 @@ function extractResponseData(result: Record): Record { +async function fetchAllModelsWithQpm(config: Config, token: string): Promise { const allModels: ModelWithQpm[] = []; let pageNo = 1; @@ -112,7 +108,6 @@ async function fetchAllModelsWithQpm( supports: { selfServiceLimitIncrease: true }, }, }, - region, }); const resp = extractResponseData(raw as Record); @@ -130,7 +125,6 @@ async function fetchAllModelsWithQpm( async function fetchMonitorData( config: Config, token: string, - region: string | undefined, modelName: string, windowMinutes: number, ): Promise<{ rpm: number; tpm: number }> { @@ -155,7 +149,6 @@ async function fetchMonitorData( endTime: now, }, }, - region, }); const resp = extractResponseData(raw as Record); @@ -260,10 +253,6 @@ export default defineCommand({ flag: "--period ", description: "Query usage for the last N minutes (default: 2)", }, - { - flag: "--region ", - description: "API region (default: cn-beijing)", - }, ], examples: [ "bl quota check", @@ -280,7 +269,6 @@ export default defineCommand({ process.exit(1); } const windowMinutes = rawPeriod; - const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); const credential = await resolveConsoleGatewayCredential(config); @@ -289,14 +277,13 @@ export default defineCommand({ emitResult( { apis: [MODEL_LIST_API, MONITOR_API], - region, }, format, ); return; } - let models = await fetchAllModelsWithQpm(config, credential.token, region); + let models = await fetchAllModelsWithQpm(config, credential.token); if (modelFlag) { const names = new Set( @@ -316,7 +303,7 @@ export default defineCommand({ } const monitorResults = await Promise.all( - models.map((m) => fetchMonitorData(config, credential.token, region, m.model, windowMinutes)), + models.map((m) => fetchMonitorData(config, credential.token, m.model, windowMinutes)), ); const checkRows: CheckRow[] = models.map((m, idx) => { diff --git a/packages/cli/src/commands/quota/history.ts b/packages/cli/src/commands/quota/history.ts index 033bb85..284cea4 100644 --- a/packages/cli/src/commands/quota/history.ts +++ b/packages/cli/src/commands/quota/history.ts @@ -114,10 +114,6 @@ export default defineCommand({ flag: "--model ", description: "Filter by model name", }, - { - flag: "--region ", - description: "API region (default: cn-beijing)", - }, ], examples: [ "bl quota history", @@ -130,7 +126,6 @@ export default defineCommand({ const page = Number(flags.page) || 1; const pageSize = Number(flags.pageSize) || 10; const modelFilter = (flags.model as string) || undefined; - const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); const credential = await resolveConsoleGatewayCredential(config); @@ -140,7 +135,7 @@ export default defineCommand({ }; if (config.dryRun) { - emitResult({ api: HISTORY_API, data: requestData, region }, format); + emitResult({ api: HISTORY_API, data: requestData }, format); return; } @@ -149,7 +144,6 @@ export default defineCommand({ result = await callConsoleGateway(config, credential.token, { api: HISTORY_API, data: requestData, - region, }); } catch (err) { if (err instanceof BailianError && err.message.includes("NotLogined")) { diff --git a/packages/cli/src/commands/quota/list.ts b/packages/cli/src/commands/quota/list.ts index 1f4761d..40e9a80 100644 --- a/packages/cli/src/commands/quota/list.ts +++ b/packages/cli/src/commands/quota/list.ts @@ -68,7 +68,6 @@ function extractResponseData(result: Record): Record { const allModels: ModelWithQpm[] = []; @@ -89,7 +88,6 @@ async function fetchAllModelsWithQpm( const raw = await callConsoleGateway(config, token, { api: MODEL_LIST_API, data: { input }, - region, }); const resp = extractResponseData(raw as Record); @@ -171,10 +169,6 @@ export default defineCommand({ flag: "--all", description: "Show all models, not just self-service ones", }, - { - flag: "--region ", - description: "API region (default: cn-beijing)", - }, ], examples: [ "bl quota list", @@ -186,7 +180,6 @@ export default defineCommand({ async run(config: Config, flags: GlobalFlags) { const modelFlag = (flags.model as string) || undefined; const showAll = Boolean(flags.all); - const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); const credential = await resolveConsoleGatewayCredential(config); @@ -200,11 +193,11 @@ export default defineCommand({ ignoreWorkspaceServiceSite: true, }; if (!showAll) input.supports = { selfServiceLimitIncrease: true }; - emitResult({ api: MODEL_LIST_API, data: { input }, region }, format); + emitResult({ api: MODEL_LIST_API, data: { input } }, format); return; } - let models = await fetchAllModelsWithQpm(config, credential.token, region, !showAll); + let models = await fetchAllModelsWithQpm(config, credential.token, !showAll); if (modelFlag) { const names = new Set( diff --git a/packages/cli/src/commands/quota/request.ts b/packages/cli/src/commands/quota/request.ts index c18045e..c554c42 100644 --- a/packages/cli/src/commands/quota/request.ts +++ b/packages/cli/src/commands/quota/request.ts @@ -53,7 +53,6 @@ function extractResponseData(result: Record): Record } | undefined> { const raw = await callConsoleGateway(config, token, { @@ -69,7 +68,6 @@ async function fetchModelQpmInfo( supports: { selfServiceLimitIncrease: true }, }, }, - region, }); const resp = extractResponseData(raw as Record); @@ -98,10 +96,6 @@ export default defineCommand({ flag: "--yes", description: "Skip downgrade confirmation", }, - { - flag: "--region ", - description: "API region (default: cn-beijing)", - }, ], examples: [ "bl quota request --model qwen-turbo --tpm 100000", @@ -122,12 +116,11 @@ export default defineCommand({ } const autoConfirm = Boolean(flags.yes) || config.yes; - const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); const credential = await resolveConsoleGatewayCredential(config); - const modelInfo = await fetchModelQpmInfo(config, credential.token, region, modelName); + const modelInfo = await fetchModelQpmInfo(config, credential.token, modelName); if (!modelInfo) { process.stderr.write( `Error: model "${modelName}" not found or does not support self-service quota increase.\n`, @@ -160,7 +153,7 @@ export default defineCommand({ }; if (config.dryRun) { - emitResult({ api: UPDATE_LIMITS_API, data: requestData, region }, format); + emitResult({ api: UPDATE_LIMITS_API, data: requestData }, format); return; } @@ -172,7 +165,6 @@ export default defineCommand({ return await callConsoleGateway(config, credential.token, { api: UPDATE_LIMITS_API, data: requestData, - region, }); } catch (err) { if (err instanceof BailianError && err.message.includes("NotLogined")) { diff --git a/packages/cli/src/commands/usage/free.ts b/packages/cli/src/commands/usage/free.ts index 4ac1eb7..433085e 100644 --- a/packages/cli/src/commands/usage/free.ts +++ b/packages/cli/src/commands/usage/free.ts @@ -207,10 +207,6 @@ export default defineCommand({ flag: "--sort ", description: "Sort by: remaining (ascending), expires (ascending)", }, - { - flag: "--region ", - description: "API region (default: cn-beijing)", - }, ], examples: [ "bl usage free", @@ -219,7 +215,7 @@ export default defineCommand({ "bl usage free --expiring 30", "bl usage free --sort remaining", "bl usage free --model qwen-turbo --output json", - "bl usage free --model qwen3-max --region cn-beijing", + "bl usage free --model qwen3-max --console-region cn-beijing", ], async run(config: Config, flags: GlobalFlags) { const modelFlag = (flags.model as string) || undefined; @@ -232,7 +228,6 @@ export default defineCommand({ ); process.exit(1); } - const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); const credential = await resolveConsoleGatewayCredential(config); @@ -275,7 +270,6 @@ export default defineCommand({ { api: FREE_TIER_API, data: requestData, - region, token: credential.token.slice(0, 8) + "...", }, format, @@ -287,12 +281,10 @@ export default defineCommand({ callConsoleGateway(config, credential.token, { api: FREE_TIER_API, data: requestData, - region, }), callConsoleGateway(config, credential.token, { api: FREE_TIER_ONLY_STATUS_API, data: { queryFreeTierOnlyStatusRequest: { models } }, - region, }), ]); diff --git a/packages/cli/src/commands/usage/freetier.ts b/packages/cli/src/commands/usage/freetier.ts index 671bb89..5b1d191 100644 --- a/packages/cli/src/commands/usage/freetier.ts +++ b/packages/cli/src/commands/usage/freetier.ts @@ -63,7 +63,6 @@ async function pollUntilDone( api: string, requestKey: string, models: string[], - region: string | undefined, ): Promise { let nextTaskId: string | undefined; @@ -75,7 +74,6 @@ async function pollUntilDone( const raw = await callConsoleGateway(config, token, { api, data: requestData, - region, }); const resp = extractResponseData(raw as Record); @@ -123,10 +121,6 @@ export default defineCommand({ flag: "--off", description: "Disable auto-stop", }, - { - flag: "--region ", - description: "API region (default: cn-beijing)", - }, ], examples: [ "bl usage freetier --model qwen3-max", @@ -140,7 +134,6 @@ export default defineCommand({ const modelFlag = (flags.model as string) || undefined; const all = Boolean(flags.all); const off = Boolean(flags.off); - const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); if (!modelFlag && !all) { @@ -176,7 +169,6 @@ export default defineCommand({ { api, data: { [requestKey]: { models } }, - region, token: credential.token.slice(0, 8) + "...", }, format, @@ -189,12 +181,10 @@ export default defineCommand({ callConsoleGateway(config, credential.token, { api: FREE_TIER_API, data: { queryFreeTierQuotaRequest: { models } }, - region, }), callConsoleGateway(config, credential.token, { api: FREE_TIER_ONLY_STATUS_API, data: { queryFreeTierOnlyStatusRequest: { models } }, - region, }), ]); @@ -218,7 +208,7 @@ export default defineCommand({ ); continue; } - await pollUntilDone(config, credential.token, api, requestKey, [name], region); + await pollUntilDone(config, credential.token, api, requestKey, [name]); process.stdout.write(`Disabled auto-stop for "${name}".\n`); } return; @@ -226,7 +216,7 @@ export default defineCommand({ const jsonResults: unknown[] = []; for (const name of models) { - const result = await pollUntilDone(config, credential.token, api, requestKey, [name], region); + const result = await pollUntilDone(config, credential.token, api, requestKey, [name]); if (format === "json") { jsonResults.push(result); continue; diff --git a/packages/cli/src/commands/usage/stats.ts b/packages/cli/src/commands/usage/stats.ts index 35e5c0b..9587bfc 100644 --- a/packages/cli/src/commands/usage/stats.ts +++ b/packages/cli/src/commands/usage/stats.ts @@ -70,7 +70,6 @@ async function pollTelemetryApi( token: string, api: string, reqDTO: Record, - region: string | undefined, ): Promise { let nextTaskId: string | undefined; @@ -82,7 +81,6 @@ async function pollTelemetryApi( const raw = await callConsoleGateway(config, token, { api, data: requestData, - region, }); const resp = extractResponseData(raw as Record); @@ -325,10 +323,6 @@ export default defineCommand({ flag: "--workspace-id ", description: "Workspace ID (env: BAILIAN_WORKSPACE_ID)", }, - { - flag: "--region ", - description: "API region (default: cn-beijing)", - }, ], examples: [ "bl usage stats", @@ -343,7 +337,6 @@ export default defineCommand({ const modelFlag = (flags.model as string) || undefined; const daysFlag = Number(flags.days) || 7; const typeFlag = (flags.type as string) || undefined; - const region = (flags.region as string) || undefined; const format = detectOutputFormat(config.output); const flagWorkspaceId = (flags.workspaceId as string) || undefined; @@ -378,7 +371,7 @@ export default defineCommand({ if (config.dryRun) { emitResult( - { api: LIST_API, data: { reqDTO: { ...baseReqDTO, model: models.join(",") } }, region }, + { api: LIST_API, data: { reqDTO: { ...baseReqDTO, model: models.join(",") } } }, format, ); return; @@ -386,7 +379,7 @@ export default defineCommand({ const results = await Promise.all( models.map((model) => - pollTelemetryApi(config, credential.token, LIST_API, { ...baseReqDTO, model }, region), + pollTelemetryApi(config, credential.token, LIST_API, { ...baseReqDTO, model }), ), ); @@ -415,11 +408,11 @@ export default defineCommand({ if (typeFlag) reqDTO.obsModelType = typeFlag; if (config.dryRun) { - emitResult({ api: OVERVIEW_API, data: { reqDTO }, region }, format); + emitResult({ api: OVERVIEW_API, data: { reqDTO } }, format); return; } - const result = await pollTelemetryApi(config, credential.token, OVERVIEW_API, reqDTO, region); + const result = await pollTelemetryApi(config, credential.token, OVERVIEW_API, reqDTO); if (!result) { process.stderr.write("Error: request timed out.\n"); process.exit(1); diff --git a/packages/cli/src/commands/workspace/list.ts b/packages/cli/src/commands/workspace/list.ts index 58857ef..4e869e6 100644 --- a/packages/cli/src/commands/workspace/list.ts +++ b/packages/cli/src/commands/workspace/list.ts @@ -93,28 +93,22 @@ export default defineCommand({ flag: "--list ", description: "Limit number of results", }, - { - flag: "--region ", - description: "API region (default: cn-beijing)", - }, ], examples: ["bl workspace list", "bl workspace list --list 5", "bl workspace list --output json"], async run(config: Config, flags: GlobalFlags) { - const region = (flags.region as string) || undefined; const limit = Number(flags.list) || 0; const format = detectOutputFormat(config.output); const credential = await resolveConsoleGatewayCredential(config); if (config.dryRun) { - emitResult({ api: LIST_WORKSPACES_API, data: {}, region }, format); + emitResult({ api: LIST_WORKSPACES_API, data: {} }, format); return; } const result = await callConsoleGateway(config, credential.token, { api: LIST_WORKSPACES_API, data: {}, - region, }); if (format === "json") { diff --git a/packages/cli/tests/e2e/mcp.e2e.test.ts b/packages/cli/tests/e2e/mcp.e2e.test.ts index bc5ef52..c3757e5 100644 --- a/packages/cli/tests/e2e/mcp.e2e.test.ts +++ b/packages/cli/tests/e2e/mcp.e2e.test.ts @@ -88,20 +88,18 @@ describe("e2e: mcp", () => { expect(data.data?.reqDTO?.pageSize).toBe(5); }); - test("mcp list --dry-run 自定义 --region 透传", async () => { - const { stdout, stderr, exitCode } = await runCli([ + test("mcp list --dry-run 自定义 --console-region 透传", async () => { + const { stderr, exitCode } = await runCli([ "mcp", "list", "--dry-run", "--non-interactive", "--output", "json", - "--region", + "--console-region", "cn-hangzhou", ]); expect(exitCode, stderr).toBe(0); - const data = parseStdoutJson<{ region?: string }>(stdout); - expect(data.region).toBe("cn-hangzhou"); }); test("mcp tools --dry-run 输出 /api/v1/mcps//mcp 形态 URL", async () => { diff --git a/packages/cli/tests/e2e/usage-free.e2e.test.ts b/packages/cli/tests/e2e/usage-free.e2e.test.ts index 064f027..589239b 100644 --- a/packages/cli/tests/e2e/usage-free.e2e.test.ts +++ b/packages/cli/tests/e2e/usage-free.e2e.test.ts @@ -264,13 +264,13 @@ describe.skipIf(!isConsoleE2EReady())("e2e: usage free(Console)", () => { expect(hasAutoStop).toBe(true); }); - test("usage free --model --region cn-beijing 指定区域查询", async () => { + test("usage free --model --console-region cn-beijing 指定区域查询", async () => { const { stdout, stderr, exitCode } = await runCli([ "usage", "free", "--model", "qwen3-max", - "--region", + "--console-region", "cn-beijing", "--output", "json", diff --git a/packages/core/src/config/loader.ts b/packages/core/src/config/loader.ts index 4e5f39e..dbcbfc5 100644 --- a/packages/core/src/config/loader.ts +++ b/packages/core/src/config/loader.ts @@ -84,9 +84,10 @@ export function loadConfig(flags: GlobalFlags): Config { accessKeySecret: process.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET || file.access_key_secret || undefined, workspaceId: process.env.BAILIAN_WORKSPACE_ID || file.workspace_id || undefined, - consoleSite: file.console_site || undefined, - consoleRegion: file.console_region || undefined, - consoleSwitchAgent: file.console_switch_agent || undefined, + consoleSite: (flags.consoleSite as Config["consoleSite"]) || file.console_site || undefined, + consoleRegion: (flags.consoleRegion as string) || file.console_region || undefined, + consoleSwitchAgent: + (flags.consoleSwitchAgent as number) || file.console_switch_agent || undefined, verbose: flags.verbose || process.env.DASHSCOPE_VERBOSE === "1", quiet: flags.quiet || false, noColor: flags.noColor || process.env.NO_COLOR !== undefined || !process.stdout.isTTY, diff --git a/packages/core/src/console/gateway.ts b/packages/core/src/console/gateway.ts index d391784..ddda2ee 100644 --- a/packages/core/src/console/gateway.ts +++ b/packages/core/src/console/gateway.ts @@ -83,11 +83,11 @@ function buildGatewayParams( export async function callConsoleGateway( config: Config, token: string | undefined, - { api, data, region, site, switchAgent }: ConsoleGatewayRequest, + { api, data }: ConsoleGatewayRequest, ): Promise { - const effectiveRegion = region ?? config.consoleRegion ?? "cn-beijing"; - const effectiveSite = site ?? config.consoleSite ?? "domestic"; - const effectiveSwitchAgent = switchAgent ?? config.consoleSwitchAgent; + const effectiveRegion = config.consoleRegion ?? "cn-beijing"; + const effectiveSite = config.consoleSite ?? "domestic"; + const effectiveSwitchAgent = config.consoleSwitchAgent; const resolved = resolveGateway(effectiveRegion, effectiveSite); const gatewayBase = `https://${resolved.csGateway}`; @@ -103,6 +103,15 @@ export async function callConsoleGateway( }; if (token) headers.Authorization = `Bearer ${token}`; + console.log({ + gatewayBase, + action, + api, + effectiveRegion, + effectiveSite, + effectiveSwitchAgent, + }); + const res = await fetch( `${gatewayBase}/cli/api.json?action=${action}&product=${GATEWAY_PRODUCT}&api=${encodeURIComponent(api)}`, { diff --git a/packages/core/src/types/command.ts b/packages/core/src/types/command.ts index 02bbcf5..cff3bc1 100644 --- a/packages/core/src/types/command.ts +++ b/packages/core/src/types/command.ts @@ -50,6 +50,16 @@ export const GLOBAL_OPTIONS: OptionDef[] = [ { flag: "--dry-run", description: "Dry run mode" }, { flag: "--non-interactive", description: "Disable interactive prompts" }, { flag: "--concurrent ", description: "Run N parallel requests (default: 1)", type: "number" }, + { + flag: "--console-region ", + description: "Console gateway region (e.g. cn-beijing, ap-southeast-1)", + }, + { flag: "--console-site ", description: "Console site: domestic, international" }, + { + flag: "--console-switch-agent ", + description: "Switch agent UID for delegated access", + type: "number", + }, { flag: "--help", description: "Show help" }, { flag: "--version", description: "Print version" }, ]; diff --git a/packages/core/src/types/flags.ts b/packages/core/src/types/flags.ts index 4f29f85..41e1a5a 100644 --- a/packages/core/src/types/flags.ts +++ b/packages/core/src/types/flags.ts @@ -11,5 +11,8 @@ export interface GlobalFlags { help: boolean; nonInteractive: boolean; async: boolean; + consoleRegion?: string; + consoleSite?: string; + consoleSwitchAgent?: number; [key: string]: unknown; } diff --git a/skills/bailian-cli/reference/app.md b/skills/bailian-cli/reference/app.md index e486673..edbd154 100644 --- a/skills/bailian-cli/reference/app.md +++ b/skills/bailian-cli/reference/app.md @@ -73,12 +73,11 @@ bl app call --app-id abc123 --prompt "开始" --biz-params '{"key":"value"}' #### Options -| Flag | Type | Required | Description | -| ------------------- | ------ | -------- | ----------------------------------- | -| `--name ` | string | no | Filter by app name (keyword search) | -| `--page ` | number | no | Page number (default: 1) | -| `--page-size ` | number | no | Results per page (default: 30) | -| `--region ` | string | no | API region (default: cn-beijing) | +| Flag | Type | Required | Description | +| ----------------- | ------ | -------- | ----------------------------------- | +| `--name ` | string | no | Filter by app name (keyword search) | +| `--page ` | number | no | Page number (default: 1) | +| `--page-size ` | number | no | Results per page (default: 30) | #### Examples diff --git a/skills/bailian-cli/reference/auth.md b/skills/bailian-cli/reference/auth.md index e51eb1a..a67cd51 100644 --- a/skills/bailian-cli/reference/auth.md +++ b/skills/bailian-cli/reference/auth.md @@ -25,11 +25,11 @@ Index: [index.md](index.md) #### Options -| Flag | Type | Required | Description | -| ------------------ | ------- | -------- | ------------------------------------------------------------------------ | -| `--api-key ` | string | no | DashScope API key to store | -| `--base-url ` | string | no | DashScope API base URL (used with --api-key for validation) | -| `--console` | boolean | no | Sign in via browser; opens the console login URL in your default browser | +| Flag | Type | Required | Description | +| ------------------ | ------ | -------- | ------------------------------------------------------------------------------------- | +| `--api-key ` | string | no | DashScope API key to store | +| `--base-url ` | string | no | DashScope API base URL (used with --api-key for validation) | +| `--console ` | string | no | Sign in via browser; use --console-site to choose domestic (default) or international | #### Examples diff --git a/skills/bailian-cli/reference/console.md b/skills/bailian-cli/reference/console.md index 12e4e95..bb3a0c8 100644 --- a/skills/bailian-cli/reference/console.md +++ b/skills/bailian-cli/reference/console.md @@ -23,13 +23,10 @@ Index: [index.md](index.md) #### Options -| Flag | Type | Required | Description | -| ---------------------- | ------ | -------- | ------------------------------------------------------------------------ | -| `--api ` | string | yes | API name (e.g. zeldaEasy.broadscope-bailian.memory-library.getLibraries) | -| `--data ` | string | yes | Request data as JSON string | -| `--region ` | string | no | Console region (e.g. cn-beijing, ap-southeast-1) | -| `--site ` | string | no | Console site: domestic or international | -| `--switch-agent ` | string | no | Switch agent UID for delegated access | +| Flag | Type | Required | Description | +| --------------- | ------ | -------- | ------------------------------------------------------------------------ | +| `--api ` | string | yes | API name (e.g. zeldaEasy.broadscope-bailian.memory-library.getLibraries) | +| `--data ` | string | yes | Request data as JSON string | #### Examples @@ -38,5 +35,5 @@ bl console call --api zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota ``` ```bash -bl console call --api some.api.name --data '{"key":"value"}' --region cn-beijing +bl console call --api some.api.name --data '{"key":"value"}' --console-region cn-beijing ``` diff --git a/skills/bailian-cli/reference/index.md b/skills/bailian-cli/reference/index.md index 0da2213..5a19012 100644 --- a/skills/bailian-cli/reference/index.md +++ b/skills/bailian-cli/reference/index.md @@ -87,21 +87,24 @@ Use this index for the full quick index and global flags. Available on every command (in addition to command-specific options): -| Flag | Type | Required | Description | -| --------------------- | ------- | -------- | ------------------------------------ | -| `--api-key ` | string | no | API key | -| `--region ` | string | no | API region: cn (default), us, intl | -| `--base-url ` | string | no | API base URL | -| `--output ` | string | no | Output format: text, json | -| `--timeout ` | number | no | Request timeout | -| `--quiet` | boolean | no | Suppress non-essential output | -| `--verbose` | boolean | no | Print HTTP request/response details | -| `--no-color` | boolean | no | Disable ANSI colors | -| `--dry-run` | boolean | no | Dry run mode | -| `--non-interactive` | boolean | no | Disable interactive prompts | -| `--concurrent ` | number | no | Run N parallel requests (default: 1) | -| `--help` | boolean | no | Show help | -| `--version` | boolean | no | Print version | +| Flag | Type | Required | Description | +| ------------------------------ | ------- | -------- | -------------------------------------------------------- | +| `--api-key ` | string | no | API key | +| `--region ` | string | no | API region: cn (default), us, intl | +| `--base-url ` | string | no | API base URL | +| `--output ` | string | no | Output format: text, json | +| `--timeout ` | number | no | Request timeout | +| `--quiet` | boolean | no | Suppress non-essential output | +| `--verbose` | boolean | no | Print HTTP request/response details | +| `--no-color` | boolean | no | Disable ANSI colors | +| `--dry-run` | boolean | no | Dry run mode | +| `--non-interactive` | boolean | no | Disable interactive prompts | +| `--concurrent ` | number | no | Run N parallel requests (default: 1) | +| `--console-region ` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) | +| `--console-site ` | string | no | Console site: domestic, international | +| `--console-switch-agent ` | number | no | Switch agent UID for delegated access | +| `--help` | boolean | no | Show help | +| `--version` | boolean | no | Print version | ## Notes diff --git a/skills/bailian-cli/reference/mcp.md b/skills/bailian-cli/reference/mcp.md index 9c71795..b84b94e 100644 --- a/skills/bailian-cli/reference/mcp.md +++ b/skills/bailian-cli/reference/mcp.md @@ -57,13 +57,12 @@ bl mcp call market-cmapi00073529.SmartFundSelection --arg riskLevel=R3 --arg min #### Options -| Flag | Type | Required | Description | -| ------------------- | ------ | -------- | ---------------------------------------------------- | -| `--name ` | string | no | Filter by server name (substring match) | -| `--type ` | string | no | Server type: OFFICIAL \| PRIVATE (default: OFFICIAL) | -| `--page ` | number | no | Page number (default: 1) | -| `--page-size ` | number | no | Results per page (default: 30) | -| `--region ` | string | no | API region (default: cn-beijing) | +| Flag | Type | Required | Description | +| ----------------- | ------ | -------- | ---------------------------------------------------- | +| `--name ` | string | no | Filter by server name (substring match) | +| `--type ` | string | no | Server type: OFFICIAL \| PRIVATE (default: OFFICIAL) | +| `--page ` | number | no | Page number (default: 1) | +| `--page-size ` | number | no | Results per page (default: 30) | #### Examples diff --git a/skills/bailian-cli/reference/quota.md b/skills/bailian-cli/reference/quota.md index 86aa355..9b4ad06 100644 --- a/skills/bailian-cli/reference/quota.md +++ b/skills/bailian-cli/reference/quota.md @@ -30,7 +30,6 @@ Index: [index.md](index.md) | -------------------- | ------ | -------- | ----------------------------------------------- | | `--model ` | string | no | Model name(s), comma-separated | | `--period ` | string | no | Query usage for the last N minutes (default: 2) | -| `--region ` | string | no | API region (default: cn-beijing) | #### Examples @@ -64,12 +63,11 @@ bl quota check --output json #### Options -| Flag | Type | Required | Description | -| ------------------- | ------ | -------- | -------------------------------- | -| `--page ` | string | no | Page number (default: 1) | -| `--page-size ` | string | no | Page size (default: 10) | -| `--model ` | string | no | Filter by model name | -| `--region ` | string | no | API region (default: cn-beijing) | +| Flag | Type | Required | Description | +| ----------------- | ------ | -------- | ------------------------ | +| `--page ` | string | no | Page number (default: 1) | +| `--page-size ` | string | no | Page size (default: 10) | +| `--model ` | string | no | Filter by model name | #### Examples @@ -103,11 +101,10 @@ bl quota history --output json #### Options -| Flag | Type | Required | Description | -| ------------------- | ------- | -------- | ------------------------------------------- | -| `--model ` | string | no | Model name(s), comma-separated | -| `--all` | boolean | no | Show all models, not just self-service ones | -| `--region ` | string | no | API region (default: cn-beijing) | +| Flag | Type | Required | Description | +| ----------------- | ------- | -------- | ------------------------------------------- | +| `--model ` | string | no | Model name(s), comma-separated | +| `--all` | boolean | no | Show all models, not just self-service ones | #### Examples @@ -141,12 +138,11 @@ bl quota list --output json #### Options -| Flag | Type | Required | Description | -| ------------------- | ------- | -------- | -------------------------------- | -| `--model ` | string | yes | Model name (required) | -| `--tpm ` | string | yes | Target TPM value (required) | -| `--yes` | boolean | no | Skip downgrade confirmation | -| `--region ` | string | no | API region (default: cn-beijing) | +| Flag | Type | Required | Description | +| ----------------- | ------- | -------- | --------------------------- | +| `--model ` | string | yes | Model name (required) | +| `--tpm ` | string | yes | Target TPM value (required) | +| `--yes` | boolean | no | Skip downgrade confirmation | #### Examples diff --git a/skills/bailian-cli/reference/usage.md b/skills/bailian-cli/reference/usage.md index 52ccd11..9b9449c 100644 --- a/skills/bailian-cli/reference/usage.md +++ b/skills/bailian-cli/reference/usage.md @@ -30,7 +30,6 @@ Index: [index.md](index.md) | `--model ` | string | no | Model name(s) to query, comma-separated for multiple; omit for all models | | `--expiring ` | string | no | Only show quotas expiring within N days | | `--sort ` | string | no | Sort by: remaining (ascending), expires (ascending) | -| `--region ` | string | no | API region (default: cn-beijing) | #### Examples @@ -59,7 +58,7 @@ bl usage free --model qwen-turbo --output json ``` ```bash -bl usage free --model qwen3-max --region cn-beijing +bl usage free --model qwen3-max --console-region cn-beijing ``` ### `bl usage freetier` @@ -72,13 +71,12 @@ bl usage free --model qwen3-max --region cn-beijing #### Options -| Flag | Type | Required | Description | -| ------------------- | ------- | -------- | ------------------------------------------- | -| `--model ` | string | no | Model name(s), comma-separated for multiple | -| `--all` | boolean | no | Apply to all free-tier models | -| `--on` | boolean | no | Enable auto-stop (default behavior) | -| `--off` | boolean | no | Disable auto-stop | -| `--region ` | string | no | API region (default: cn-beijing) | +| Flag | Type | Required | Description | +| ----------------- | ------- | -------- | ------------------------------------------- | +| `--model ` | string | no | Model name(s), comma-separated for multiple | +| `--all` | boolean | no | Apply to all free-tier models | +| `--on` | boolean | no | Enable auto-stop (default behavior) | +| `--off` | boolean | no | Disable auto-stop | #### Examples @@ -122,7 +120,6 @@ bl usage freetier --off --all | `--days ` | string | no | Number of days (default: 7) | | `--type ` | string | no | Model type: Text, Vision, Multimodal, Audio, Embedding | | `--workspace-id ` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) | -| `--region ` | string | no | API region (default: cn-beijing) | #### Examples diff --git a/skills/bailian-cli/reference/workspace.md b/skills/bailian-cli/reference/workspace.md index 2428721..3606bb0 100644 --- a/skills/bailian-cli/reference/workspace.md +++ b/skills/bailian-cli/reference/workspace.md @@ -23,10 +23,9 @@ Index: [index.md](index.md) #### Options -| Flag | Type | Required | Description | -| ------------------- | ------ | -------- | -------------------------------- | -| `--list ` | string | no | Limit number of results | -| `--region ` | string | no | API region (default: cn-beijing) | +| Flag | Type | Required | Description | +| ------------ | ------ | -------- | ----------------------- | +| `--list ` | string | no | Limit number of results | #### Examples From f847476016c1c997f4de0d7b3176202456ef809d Mon Sep 17 00:00:00 2001 From: lishengzxc <306009337@qq.com> Date: Tue, 16 Jun 2026 14:15:58 +0800 Subject: [PATCH 15/20] =?UTF-8?q?refactor(auth):=20=E4=BF=AE=E6=94=B9=20--?= =?UTF-8?q?console=20=E6=A0=87=E5=BF=97=E4=BB=A5=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cli/src/commands/auth/login.ts | 4 ++-- skills/bailian-cli/reference/auth.md | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/commands/auth/login.ts b/packages/cli/src/commands/auth/login.ts index 9c3c7eb..809d5b3 100644 --- a/packages/cli/src/commands/auth/login.ts +++ b/packages/cli/src/commands/auth/login.ts @@ -28,7 +28,7 @@ export default defineCommand({ description: "DashScope API base URL (used with --api-key for validation)", }, { - flag: "--console ", + flag: "--console", description: "Sign in via browser; use --console-site to choose domestic (default) or international", }, @@ -43,7 +43,7 @@ export default defineCommand({ return; } const hasApiKey = !!(config.apiKey || config.fileApiKey); - await runConsoleLogin(resolveConsoleOrigin(config.consoleSite), config, { + await runConsoleLogin(resolveConsoleOrigin(config.consoleSite || "domestic"), config, { needApiKey: !hasApiKey, }); return; diff --git a/skills/bailian-cli/reference/auth.md b/skills/bailian-cli/reference/auth.md index a67cd51..d12269e 100644 --- a/skills/bailian-cli/reference/auth.md +++ b/skills/bailian-cli/reference/auth.md @@ -25,11 +25,11 @@ Index: [index.md](index.md) #### Options -| Flag | Type | Required | Description | -| ------------------ | ------ | -------- | ------------------------------------------------------------------------------------- | -| `--api-key ` | string | no | DashScope API key to store | -| `--base-url ` | string | no | DashScope API base URL (used with --api-key for validation) | -| `--console ` | string | no | Sign in via browser; use --console-site to choose domestic (default) or international | +| Flag | Type | Required | Description | +| ------------------ | ------- | -------- | ------------------------------------------------------------------------------------- | +| `--api-key ` | string | no | DashScope API key to store | +| `--base-url ` | string | no | DashScope API base URL (used with --api-key for validation) | +| `--console` | boolean | no | Sign in via browser; use --console-site to choose domestic (default) or international | #### Examples From 682321247bf42c8e8ab3361ed1f85f5b92aa164e Mon Sep 17 00:00:00 2001 From: qcq01083097 Date: Tue, 16 Jun 2026 16:39:05 +0800 Subject: [PATCH 16/20] feat: Delete invalid code --- packages/core/src/console/gateway.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/packages/core/src/console/gateway.ts b/packages/core/src/console/gateway.ts index ddda2ee..ffad27a 100644 --- a/packages/core/src/console/gateway.ts +++ b/packages/core/src/console/gateway.ts @@ -103,15 +103,6 @@ export async function callConsoleGateway( }; if (token) headers.Authorization = `Bearer ${token}`; - console.log({ - gatewayBase, - action, - api, - effectiveRegion, - effectiveSite, - effectiveSwitchAgent, - }); - const res = await fetch( `${gatewayBase}/cli/api.json?action=${action}&product=${GATEWAY_PRODUCT}&api=${encodeURIComponent(api)}`, { From 631a9c18180c64465d374774798e03be2d9a74be Mon Sep 17 00:00:00 2001 From: qcq01083097 Date: Tue, 16 Jun 2026 16:51:04 +0800 Subject: [PATCH 17/20] feat: Complete the missing changes for E2E Test --- packages/cli/src/commands/console/call.ts | 11 +- packages/cli/src/commands/mcp/list.ts | 3 +- packages/cli/src/commands/quota/check.ts | 2 + packages/cli/tests/e2e/auth.e2e.test.ts | 1 + .../cli/tests/e2e/console-flags.e2e.test.ts | 152 ++++++++++++++++++ packages/cli/tests/e2e/mcp.e2e.test.ts | 4 +- packages/cli/tests/e2e/quota.e2e.test.ts | 19 ++- packages/core/src/console/gateway.ts | 22 ++- packages/core/src/console/index.ts | 2 +- packages/core/src/console/models.ts | 10 +- 10 files changed, 209 insertions(+), 17 deletions(-) create mode 100644 packages/cli/tests/e2e/console-flags.e2e.test.ts diff --git a/packages/cli/src/commands/console/call.ts b/packages/cli/src/commands/console/call.ts index 4bf9ee6..d953a4f 100644 --- a/packages/cli/src/commands/console/call.ts +++ b/packages/cli/src/commands/console/call.ts @@ -1,6 +1,7 @@ import { defineCommand, callConsoleGateway, + effectiveConsoleGatewayConfig, resolveConsoleGatewayCredential, CONSOLE_GATEWAY_NO_TOKEN_MESSAGE, BailianError, @@ -58,7 +59,15 @@ export default defineCommand({ } if (config.dryRun) { - emitResult({ api, data, token: token ? token.slice(0, 8) + "..." : null }, format); + emitResult( + { + api, + data, + token: token ? token.slice(0, 8) + "..." : null, + ...effectiveConsoleGatewayConfig(config), + }, + format, + ); return; } diff --git a/packages/cli/src/commands/mcp/list.ts b/packages/cli/src/commands/mcp/list.ts index 1e6e747..6d39c71 100644 --- a/packages/cli/src/commands/mcp/list.ts +++ b/packages/cli/src/commands/mcp/list.ts @@ -1,6 +1,7 @@ import { defineCommand, callConsoleGateway, + effectiveConsoleGatewayConfig, resolveConsoleGatewayCredential, detectOutputFormat, BailianError, @@ -56,7 +57,7 @@ export default defineCommand({ }; if (config.dryRun) { - emitResult({ api: MCP_LIST_API, data }, format); + emitResult({ api: MCP_LIST_API, data, ...effectiveConsoleGatewayConfig(config) }, format); return; } diff --git a/packages/cli/src/commands/quota/check.ts b/packages/cli/src/commands/quota/check.ts index f00ab44..c6b6179 100644 --- a/packages/cli/src/commands/quota/check.ts +++ b/packages/cli/src/commands/quota/check.ts @@ -1,6 +1,7 @@ import { defineCommand, callConsoleGateway, + effectiveConsoleGatewayConfig, resolveConsoleGatewayCredential, detectOutputFormat, type Config, @@ -277,6 +278,7 @@ export default defineCommand({ emitResult( { apis: [MODEL_LIST_API, MONITOR_API], + ...effectiveConsoleGatewayConfig(config), }, format, ); diff --git a/packages/cli/tests/e2e/auth.e2e.test.ts b/packages/cli/tests/e2e/auth.e2e.test.ts index 3946e75..339383c 100644 --- a/packages/cli/tests/e2e/auth.e2e.test.ts +++ b/packages/cli/tests/e2e/auth.e2e.test.ts @@ -17,6 +17,7 @@ describe("e2e: auth", () => { const { stderr, exitCode } = await runCli(["auth", "login", "--help"]); expect(exitCode, stderr).toBe(0); expect(stderr).toMatch(/login|api-key/i); + expect(stderr).toMatch(/--console-site/); }); test("auth logout --help 正常退出", async () => { diff --git a/packages/cli/tests/e2e/console-flags.e2e.test.ts b/packages/cli/tests/e2e/console-flags.e2e.test.ts new file mode 100644 index 0000000..07ca49f --- /dev/null +++ b/packages/cli/tests/e2e/console-flags.e2e.test.ts @@ -0,0 +1,152 @@ +import { describe, expect, test } from "vite-plus/test"; +import { parseStdoutJson, runCli } from "./helpers.ts"; + +type ConsoleDryRunMeta = { + consoleRegion?: string; + consoleSite?: string; + consoleSwitchAgent?: number; +}; + +/** + * E2E for global console flags (`--console-region`, `--console-site`, + * `--console-switch-agent`) vs DashScope `--region`. + */ + +describe("e2e: console global flags", () => { + test("根帮助展示 --console-region / --console-site / --console-switch-agent", async () => { + const { stderr, exitCode } = await runCli(["--help"]); + expect(exitCode, stderr).toBe(0); + expect(stderr).toMatch(/--console-region/); + expect(stderr).toMatch(/--console-site/); + expect(stderr).toMatch(/--console-switch-agent/); + expect(stderr).toMatch(/--region.*cn.*us.*intl/i); + }); + + test("quota check --help 不重复命令级 region,并提示全局 flags", async () => { + const { stderr, exitCode } = await runCli(["quota", "check", "--help"]); + expect(exitCode, stderr).toBe(0); + expect(stderr).toMatch(/Global flags.*always available/i); + expect(stderr).toMatch(/--model /); + expect(stderr).toMatch(/--period /); + expect(stderr).not.toMatch(/API region \(default: cn-beijing\)/); + }); + + test("console call --help 不暴露命令级 region/site,示例使用 --console-region", async () => { + const { stderr, exitCode } = await runCli(["console", "call", "--help"]); + expect(exitCode, stderr).toBe(0); + expect(stderr).toMatch(/--api /); + expect(stderr).toMatch(/--data /); + expect(stderr).not.toMatch(/^\s*--region\s/m); + expect(stderr).not.toMatch(/^\s*--site\s/m); + expect(stderr).toMatch(/--console-region cn-beijing/); + }); + + test("auth login --help 描述 --console 与 --console-site 配合", async () => { + const { stderr, exitCode } = await runCli(["auth", "login", "--help"]); + expect(exitCode, stderr).toBe(0); + expect(stderr).toMatch(/--console-site/); + expect(stderr).toMatch(/--console.*console-site|console-site.*domestic|international/i); + }); + + test("console call --dry-run 默认 consoleRegion 为 cn-beijing", async () => { + const { stdout, stderr, exitCode } = await runCli([ + "console", + "call", + "--api", + "some.api.name", + "--data", + "{}", + "--dry-run", + "--non-interactive", + "--output", + "json", + ]); + expect(exitCode, stderr).toBe(0); + const data = parseStdoutJson(stdout); + expect(data.consoleRegion).toBe("cn-beijing"); + expect(data.consoleSite).toBe("domestic"); + }); + + test("console call --dry-run --console-region / --console-site / --console-switch-agent 透传", async () => { + const { stdout, stderr, exitCode } = await runCli([ + "console", + "call", + "--api", + "some.api.name", + "--data", + "{}", + "--dry-run", + "--non-interactive", + "--output", + "json", + "--console-region", + "ap-southeast-1", + "--console-site", + "international", + "--console-switch-agent", + "12345", + ]); + expect(exitCode, stderr).toBe(0); + const data = parseStdoutJson(stdout); + expect(data.consoleRegion).toBe("ap-southeast-1"); + expect(data.consoleSite).toBe("international"); + expect(data.consoleSwitchAgent).toBe(12345); + }); + + test("console call --dry-run --region cn-beijing 不改变 consoleRegion", async () => { + const { stdout, stderr, exitCode } = await runCli([ + "console", + "call", + "--api", + "some.api.name", + "--data", + "{}", + "--dry-run", + "--non-interactive", + "--output", + "json", + "--region", + "cn-beijing", + "--console-region", + "ap-southeast-1", + ]); + expect(exitCode, stderr).toBe(0); + const data = parseStdoutJson(stdout); + expect(data.consoleRegion).toBe("ap-southeast-1"); + }); + + test("mcp list --dry-run --console-region 透传", async () => { + const { stdout, stderr, exitCode } = await runCli([ + "mcp", + "list", + "--dry-run", + "--non-interactive", + "--output", + "json", + "--console-region", + "cn-hangzhou", + ]); + expect(exitCode, stderr).toBe(0); + const data = parseStdoutJson(stdout); + expect(data.consoleRegion).toBe("cn-hangzhou"); + }); + + test("quota check --dry-run --console-region 透传", async () => { + const { stdout, stderr, exitCode } = await runCli([ + "quota", + "check", + "--dry-run", + "--non-interactive", + "--output", + "json", + "--console-region", + "cn-hangzhou", + "--console-site", + "international", + ]); + expect(exitCode, stderr).toBe(0); + const data = parseStdoutJson(stdout); + expect(data.consoleRegion).toBe("cn-hangzhou"); + expect(data.consoleSite).toBe("international"); + }); +}); diff --git a/packages/cli/tests/e2e/mcp.e2e.test.ts b/packages/cli/tests/e2e/mcp.e2e.test.ts index 93eabf2..ee56cf4 100644 --- a/packages/cli/tests/e2e/mcp.e2e.test.ts +++ b/packages/cli/tests/e2e/mcp.e2e.test.ts @@ -88,7 +88,7 @@ describe("e2e: mcp", () => { }); test("mcp list --dry-run 自定义 --console-region 透传", async () => { - const { stderr, exitCode } = await runCli([ + const { stdout, stderr, exitCode } = await runCli([ "mcp", "list", "--dry-run", @@ -99,6 +99,8 @@ describe("e2e: mcp", () => { "cn-hangzhou", ]); expect(exitCode, stderr).toBe(0); + const data = parseStdoutJson<{ consoleRegion?: string }>(stdout); + expect(data.consoleRegion).toBe("cn-hangzhou"); }); test("mcp tools --dry-run 输出 /api/v1/mcps//mcp 形态 URL", async () => { diff --git a/packages/cli/tests/e2e/quota.e2e.test.ts b/packages/cli/tests/e2e/quota.e2e.test.ts index 19e537d..4e54fbb 100644 --- a/packages/cli/tests/e2e/quota.e2e.test.ts +++ b/packages/cli/tests/e2e/quota.e2e.test.ts @@ -228,11 +228,28 @@ describe.skipIf(!isConsoleE2EReady())("e2e: quota(Console)", () => { "json", ]); expect(exitCode, stderr).toBe(0); - const data = parseStdoutJson<{ apis?: string[] }>(stdout); + const data = parseStdoutJson<{ apis?: string[]; consoleRegion?: string }>(stdout); expect(data.apis).toContain( "zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels", ); expect(data.apis).toContain("zeldaEasy.bailian-telemetry.monitor.getMonitorData"); + expect(data.consoleRegion).toBe("cn-beijing"); + }); + + test("quota check --dry-run --console-region 透传", async () => { + const { stdout, stderr, exitCode } = await runCli([ + "quota", + "check", + "--dry-run", + "--non-interactive", + "--output", + "json", + "--console-region", + "cn-hangzhou", + ]); + expect(exitCode, stderr).toBe(0); + const data = parseStdoutJson<{ consoleRegion?: string }>(stdout); + expect(data.consoleRegion).toBe("cn-hangzhou"); }); test("quota check 文本输出包含双行表头", async () => { diff --git a/packages/core/src/console/gateway.ts b/packages/core/src/console/gateway.ts index ffad27a..3a636db 100644 --- a/packages/core/src/console/gateway.ts +++ b/packages/core/src/console/gateway.ts @@ -35,6 +35,20 @@ function resolveGateway(region: string, site: ConsoleSite): ConsoleGatewayInfo { return REGION_GATEWAYS[region]?.[site] ?? REGION_GATEWAYS["cn-beijing"]![site]; } +/** Resolved console gateway settings (same defaults as {@link callConsoleGateway}). */ +export function effectiveConsoleGatewayConfig(config: Config): { + consoleRegion: string; + consoleSite: ConsoleSite; + consoleSwitchAgent?: number; +} { + const consoleRegion = config.consoleRegion ?? "cn-beijing"; + const consoleSite = config.consoleSite ?? "domestic"; + const consoleSwitchAgent = config.consoleSwitchAgent; + return consoleSwitchAgent != null + ? { consoleRegion, consoleSite, consoleSwitchAgent } + : { consoleRegion, consoleSite }; +} + export interface ConsoleGatewayRequest { /** Console API name, e.g. zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota */ api: string; @@ -85,9 +99,11 @@ export async function callConsoleGateway( token: string | undefined, { api, data }: ConsoleGatewayRequest, ): Promise { - const effectiveRegion = config.consoleRegion ?? "cn-beijing"; - const effectiveSite = config.consoleSite ?? "domestic"; - const effectiveSwitchAgent = config.consoleSwitchAgent; + const { + consoleRegion: effectiveRegion, + consoleSite: effectiveSite, + consoleSwitchAgent: effectiveSwitchAgent, + } = effectiveConsoleGatewayConfig(config); const resolved = resolveGateway(effectiveRegion, effectiveSite); const gatewayBase = `https://${resolved.csGateway}`; diff --git a/packages/core/src/console/index.ts b/packages/core/src/console/index.ts index 61cf595..948e878 100644 --- a/packages/core/src/console/index.ts +++ b/packages/core/src/console/index.ts @@ -1,4 +1,4 @@ export type { ConsoleGatewayRequest, ConsoleSite } from "./gateway.ts"; -export { callConsoleGateway } from "./gateway.ts"; +export { callConsoleGateway, effectiveConsoleGatewayConfig } from "./gateway.ts"; export type { ModelListParams, ModelListResult } from "./models.ts"; export { fetchModelList } from "./models.ts"; diff --git a/packages/core/src/console/models.ts b/packages/core/src/console/models.ts index 70345c2..8366a2f 100644 --- a/packages/core/src/console/models.ts +++ b/packages/core/src/console/models.ts @@ -22,14 +22,7 @@ export async function fetchModelList( token: string, params: ModelListParams = {}, ): Promise { - const { - pageNo = 1, - pageSize = 50, - name = "", - providers = [], - capabilities = [], - region, - } = params; + const { pageNo = 1, pageSize = 50, name = "", providers = [], capabilities = [] } = params; const result = (await callConsoleGateway(config, token, { api: MODEL_LIST_API, @@ -46,7 +39,6 @@ export async function fetchModelList( contextWindows: [], }, }, - region, })) as any; const responseData = result?.data?.DataV2?.data ?? result?.data ?? {}; From a5d055f45a207aa38c53e0a0d945a89393b41246 Mon Sep 17 00:00:00 2001 From: qcq01083097 Date: Tue, 16 Jun 2026 17:16:25 +0800 Subject: [PATCH 18/20] feat: Adjust the priority of base_url in config to be higher than that of the environment variable DASHSCOPE_BASE_URL --- packages/core/src/config/loader.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/config/loader.ts b/packages/core/src/config/loader.ts index dbcbfc5..12d4d3b 100644 --- a/packages/core/src/config/loader.ts +++ b/packages/core/src/config/loader.ts @@ -42,8 +42,8 @@ export function loadConfig(flags: GlobalFlags): Config { const baseUrl = flags.baseUrl || - process.env.DASHSCOPE_BASE_URL || file.base_url || + process.env.DASHSCOPE_BASE_URL || REGIONS[region] || REGIONS.cn; From d320d36ba7818c5721b6d57231ceef57b4fe2a8c Mon Sep 17 00:00:00 2001 From: lishengzxc <306009337@qq.com> Date: Tue, 16 Jun 2026 17:50:11 +0800 Subject: [PATCH 19/20] docs: add console gateway flags convention to AGENTS.md and command help Add console global flags (--console-region, --console-site, --console-switch-agent) to the options of all 12 commands that depend on callConsoleGateway, so they appear in --help output. Document this as convention #4 in AGENTS.md for future commands. Co-Authored-By: Claude Opus 4.6 (1M context) --- AGENTS.md | 12 ++++++ packages/cli/src/commands/app/list.ts | 10 +++++ packages/cli/src/commands/auth/status.ts | 12 ++++++ packages/cli/src/commands/console/call.ts | 10 +++++ packages/cli/src/commands/mcp/list.ts | 10 +++++ packages/cli/src/commands/quota/check.ts | 10 +++++ packages/cli/src/commands/quota/history.ts | 10 +++++ packages/cli/src/commands/quota/list.ts | 10 +++++ packages/cli/src/commands/quota/request.ts | 10 +++++ packages/cli/src/commands/usage/free.ts | 10 +++++ packages/cli/src/commands/usage/freetier.ts | 10 +++++ packages/cli/src/commands/usage/stats.ts | 10 +++++ packages/cli/src/commands/workspace/list.ts | 10 +++++ skills/bailian-cli/reference/app.md | 13 +++--- skills/bailian-cli/reference/auth.md | 6 ++- skills/bailian-cli/reference/console.md | 11 +++-- skills/bailian-cli/reference/mcp.md | 15 ++++--- skills/bailian-cli/reference/quota.md | 48 +++++++++++++-------- skills/bailian-cli/reference/usage.md | 43 ++++++++++-------- skills/bailian-cli/reference/workspace.md | 9 ++-- 20 files changed, 225 insertions(+), 54 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 51afe94..0c52651 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -93,6 +93,18 @@ CLI 只为「自己能权威解释的错误」发出语义化信号,服务端的 不要扮演服务端错误的翻译官——我们没有最新的错误码体系认知,二次包装只会撒谎(详见 `docs/agents/error-hint-change.md` 中的反面 case)。 +### 4. Console Gateway 命令必须声明 console 全局 flags + +如果新命令使用了 `callConsoleGateway`,必须在 `options` 中添加以下三个全局 flag 的说明,以便 `--help` 中展示: + +```ts +{ flag: "--console-region ", description: "Console region (global flag)" }, +{ flag: "--console-site ", description: "Console site: domestic, international (global flag)" }, +{ flag: "--console-switch-agent ", description: "Switch agent UID (global flag)", type: "number" }, +``` + +这些 flag 已在 `GLOBAL_OPTIONS`(`packages/core/src/types/command.ts`)中注册,由 `loadConfig` 写入 `config.consoleRegion` / `config.consoleSite` / `config.consoleSwitchAgent`,`callConsoleGateway` 自动读取——命令无需手动提取或传递。 + ## 完成改动后的快速验证 ```sh diff --git a/packages/cli/src/commands/app/list.ts b/packages/cli/src/commands/app/list.ts index 28e55b2..185ed24 100644 --- a/packages/cli/src/commands/app/list.ts +++ b/packages/cli/src/commands/app/list.ts @@ -29,6 +29,16 @@ export default defineCommand({ description: "Results per page (default: 30)", type: "number", }, + { flag: "--console-region ", description: "Console region (global flag)" }, + { + flag: "--console-site ", + description: "Console site: domestic, international (global flag)", + }, + { + flag: "--console-switch-agent ", + description: "Switch agent UID (global flag)", + type: "number", + }, ], examples: [ "bl app list", diff --git a/packages/cli/src/commands/auth/status.ts b/packages/cli/src/commands/auth/status.ts index 7ea9b85..5276638 100644 --- a/packages/cli/src/commands/auth/status.ts +++ b/packages/cli/src/commands/auth/status.ts @@ -142,6 +142,18 @@ export default defineCommand({ name: "auth status", description: "Show current authentication state", usage: "bl auth status", + options: [ + { flag: "--console-region ", description: "Console region (global flag)" }, + { + flag: "--console-site ", + description: "Console site: domestic, international (global flag)", + }, + { + flag: "--console-switch-agent ", + description: "Switch agent UID (global flag)", + type: "number", + }, + ], examples: ["bl auth status", "bl auth status --output json"], async run(config: Config, _flags: GlobalFlags) { const format = detectOutputFormat(config.output); diff --git a/packages/cli/src/commands/console/call.ts b/packages/cli/src/commands/console/call.ts index d953a4f..b278fa5 100644 --- a/packages/cli/src/commands/console/call.ts +++ b/packages/cli/src/commands/console/call.ts @@ -27,6 +27,16 @@ export default defineCommand({ description: "Request data as JSON string", required: true, }, + { flag: "--console-region ", description: "Console region (global flag)" }, + { + flag: "--console-site ", + description: "Console site: domestic, international (global flag)", + }, + { + flag: "--console-switch-agent ", + description: "Switch agent UID (global flag)", + type: "number", + }, ], examples: [ `bl console call --api zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota --data '{"queryFreeTierQuotaRequest":{"models":["qwen3-max"]}}'`, diff --git a/packages/cli/src/commands/mcp/list.ts b/packages/cli/src/commands/mcp/list.ts index 6d39c71..48b7c42 100644 --- a/packages/cli/src/commands/mcp/list.ts +++ b/packages/cli/src/commands/mcp/list.ts @@ -36,6 +36,16 @@ export default defineCommand({ }, { flag: "--page ", description: "Page number (default: 1)", type: "number" }, { flag: "--page-size ", description: "Results per page (default: 30)", type: "number" }, + { flag: "--console-region ", description: "Console region (global flag)" }, + { + flag: "--console-site ", + description: "Console site: domestic, international (global flag)", + }, + { + flag: "--console-switch-agent ", + description: "Switch agent UID (global flag)", + type: "number", + }, ], examples: ["bl mcp list", "bl mcp list --name 金融", "bl mcp list --output json"], async run(config: Config, flags: GlobalFlags) { diff --git a/packages/cli/src/commands/quota/check.ts b/packages/cli/src/commands/quota/check.ts index c6b6179..09065cc 100644 --- a/packages/cli/src/commands/quota/check.ts +++ b/packages/cli/src/commands/quota/check.ts @@ -254,6 +254,16 @@ export default defineCommand({ flag: "--period ", description: "Query usage for the last N minutes (default: 2)", }, + { flag: "--console-region ", description: "Console region (global flag)" }, + { + flag: "--console-site ", + description: "Console site: domestic, international (global flag)", + }, + { + flag: "--console-switch-agent ", + description: "Switch agent UID (global flag)", + type: "number", + }, ], examples: [ "bl quota check", diff --git a/packages/cli/src/commands/quota/history.ts b/packages/cli/src/commands/quota/history.ts index 284cea4..3d6593c 100644 --- a/packages/cli/src/commands/quota/history.ts +++ b/packages/cli/src/commands/quota/history.ts @@ -114,6 +114,16 @@ export default defineCommand({ flag: "--model ", description: "Filter by model name", }, + { flag: "--console-region ", description: "Console region (global flag)" }, + { + flag: "--console-site ", + description: "Console site: domestic, international (global flag)", + }, + { + flag: "--console-switch-agent ", + description: "Switch agent UID (global flag)", + type: "number", + }, ], examples: [ "bl quota history", diff --git a/packages/cli/src/commands/quota/list.ts b/packages/cli/src/commands/quota/list.ts index 40e9a80..06e2b2a 100644 --- a/packages/cli/src/commands/quota/list.ts +++ b/packages/cli/src/commands/quota/list.ts @@ -169,6 +169,16 @@ export default defineCommand({ flag: "--all", description: "Show all models, not just self-service ones", }, + { flag: "--console-region ", description: "Console region (global flag)" }, + { + flag: "--console-site ", + description: "Console site: domestic, international (global flag)", + }, + { + flag: "--console-switch-agent ", + description: "Switch agent UID (global flag)", + type: "number", + }, ], examples: [ "bl quota list", diff --git a/packages/cli/src/commands/quota/request.ts b/packages/cli/src/commands/quota/request.ts index c554c42..89c7660 100644 --- a/packages/cli/src/commands/quota/request.ts +++ b/packages/cli/src/commands/quota/request.ts @@ -96,6 +96,16 @@ export default defineCommand({ flag: "--yes", description: "Skip downgrade confirmation", }, + { flag: "--console-region ", description: "Console region (global flag)" }, + { + flag: "--console-site ", + description: "Console site: domestic, international (global flag)", + }, + { + flag: "--console-switch-agent ", + description: "Switch agent UID (global flag)", + type: "number", + }, ], examples: [ "bl quota request --model qwen-turbo --tpm 100000", diff --git a/packages/cli/src/commands/usage/free.ts b/packages/cli/src/commands/usage/free.ts index 433085e..d6ef941 100644 --- a/packages/cli/src/commands/usage/free.ts +++ b/packages/cli/src/commands/usage/free.ts @@ -207,6 +207,16 @@ export default defineCommand({ flag: "--sort ", description: "Sort by: remaining (ascending), expires (ascending)", }, + { flag: "--console-region ", description: "Console region (global flag)" }, + { + flag: "--console-site ", + description: "Console site: domestic, international (global flag)", + }, + { + flag: "--console-switch-agent ", + description: "Switch agent UID (global flag)", + type: "number", + }, ], examples: [ "bl usage free", diff --git a/packages/cli/src/commands/usage/freetier.ts b/packages/cli/src/commands/usage/freetier.ts index 5b1d191..ec820ec 100644 --- a/packages/cli/src/commands/usage/freetier.ts +++ b/packages/cli/src/commands/usage/freetier.ts @@ -121,6 +121,16 @@ export default defineCommand({ flag: "--off", description: "Disable auto-stop", }, + { flag: "--console-region ", description: "Console region (global flag)" }, + { + flag: "--console-site ", + description: "Console site: domestic, international (global flag)", + }, + { + flag: "--console-switch-agent ", + description: "Switch agent UID (global flag)", + type: "number", + }, ], examples: [ "bl usage freetier --model qwen3-max", diff --git a/packages/cli/src/commands/usage/stats.ts b/packages/cli/src/commands/usage/stats.ts index 9587bfc..46d0f49 100644 --- a/packages/cli/src/commands/usage/stats.ts +++ b/packages/cli/src/commands/usage/stats.ts @@ -323,6 +323,16 @@ export default defineCommand({ flag: "--workspace-id ", description: "Workspace ID (env: BAILIAN_WORKSPACE_ID)", }, + { flag: "--console-region ", description: "Console region (global flag)" }, + { + flag: "--console-site ", + description: "Console site: domestic, international (global flag)", + }, + { + flag: "--console-switch-agent ", + description: "Switch agent UID (global flag)", + type: "number", + }, ], examples: [ "bl usage stats", diff --git a/packages/cli/src/commands/workspace/list.ts b/packages/cli/src/commands/workspace/list.ts index 4e869e6..3a95362 100644 --- a/packages/cli/src/commands/workspace/list.ts +++ b/packages/cli/src/commands/workspace/list.ts @@ -93,6 +93,16 @@ export default defineCommand({ flag: "--list ", description: "Limit number of results", }, + { flag: "--console-region ", description: "Console region (global flag)" }, + { + flag: "--console-site ", + description: "Console site: domestic, international (global flag)", + }, + { + flag: "--console-switch-agent ", + description: "Switch agent UID (global flag)", + type: "number", + }, ], examples: ["bl workspace list", "bl workspace list --list 5", "bl workspace list --output json"], async run(config: Config, flags: GlobalFlags) { diff --git a/skills/bailian-cli/reference/app.md b/skills/bailian-cli/reference/app.md index edbd154..7a1bc95 100644 --- a/skills/bailian-cli/reference/app.md +++ b/skills/bailian-cli/reference/app.md @@ -73,11 +73,14 @@ bl app call --app-id abc123 --prompt "开始" --biz-params '{"key":"value"}' #### Options -| Flag | Type | Required | Description | -| ----------------- | ------ | -------- | ----------------------------------- | -| `--name ` | string | no | Filter by app name (keyword search) | -| `--page ` | number | no | Page number (default: 1) | -| `--page-size ` | number | no | Results per page (default: 30) | +| Flag | Type | Required | Description | +| ------------------------------ | ------ | -------- | --------------------------------------------------- | +| `--name ` | string | no | Filter by app name (keyword search) | +| `--page ` | number | no | Page number (default: 1) | +| `--page-size ` | number | no | Results per page (default: 30) | +| `--console-region ` | string | no | Console region (global flag) | +| `--console-site ` | string | no | Console site: domestic, international (global flag) | +| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | #### Examples diff --git a/skills/bailian-cli/reference/auth.md b/skills/bailian-cli/reference/auth.md index d12269e..f0e5f4f 100644 --- a/skills/bailian-cli/reference/auth.md +++ b/skills/bailian-cli/reference/auth.md @@ -84,7 +84,11 @@ bl auth logout --yes #### Options -_No command-specific options._ +| Flag | Type | Required | Description | +| ------------------------------ | ------ | -------- | --------------------------------------------------- | +| `--console-region ` | string | no | Console region (global flag) | +| `--console-site ` | string | no | Console site: domestic, international (global flag) | +| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | #### Examples diff --git a/skills/bailian-cli/reference/console.md b/skills/bailian-cli/reference/console.md index bb3a0c8..e6b6b57 100644 --- a/skills/bailian-cli/reference/console.md +++ b/skills/bailian-cli/reference/console.md @@ -23,10 +23,13 @@ Index: [index.md](index.md) #### Options -| Flag | Type | Required | Description | -| --------------- | ------ | -------- | ------------------------------------------------------------------------ | -| `--api ` | string | yes | API name (e.g. zeldaEasy.broadscope-bailian.memory-library.getLibraries) | -| `--data ` | string | yes | Request data as JSON string | +| Flag | Type | Required | Description | +| ------------------------------ | ------ | -------- | ------------------------------------------------------------------------ | +| `--api ` | string | yes | API name (e.g. zeldaEasy.broadscope-bailian.memory-library.getLibraries) | +| `--data ` | string | yes | Request data as JSON string | +| `--console-region ` | string | no | Console region (global flag) | +| `--console-site ` | string | no | Console site: domestic, international (global flag) | +| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | #### Examples diff --git a/skills/bailian-cli/reference/mcp.md b/skills/bailian-cli/reference/mcp.md index b84b94e..bd22232 100644 --- a/skills/bailian-cli/reference/mcp.md +++ b/skills/bailian-cli/reference/mcp.md @@ -57,12 +57,15 @@ bl mcp call market-cmapi00073529.SmartFundSelection --arg riskLevel=R3 --arg min #### Options -| Flag | Type | Required | Description | -| ----------------- | ------ | -------- | ---------------------------------------------------- | -| `--name ` | string | no | Filter by server name (substring match) | -| `--type ` | string | no | Server type: OFFICIAL \| PRIVATE (default: OFFICIAL) | -| `--page ` | number | no | Page number (default: 1) | -| `--page-size ` | number | no | Results per page (default: 30) | +| Flag | Type | Required | Description | +| ------------------------------ | ------ | -------- | ---------------------------------------------------- | +| `--name ` | string | no | Filter by server name (substring match) | +| `--type ` | string | no | Server type: OFFICIAL \| PRIVATE (default: OFFICIAL) | +| `--page ` | number | no | Page number (default: 1) | +| `--page-size ` | number | no | Results per page (default: 30) | +| `--console-region ` | string | no | Console region (global flag) | +| `--console-site ` | string | no | Console site: domestic, international (global flag) | +| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | #### Examples diff --git a/skills/bailian-cli/reference/quota.md b/skills/bailian-cli/reference/quota.md index 9b4ad06..9f7a68c 100644 --- a/skills/bailian-cli/reference/quota.md +++ b/skills/bailian-cli/reference/quota.md @@ -26,10 +26,13 @@ Index: [index.md](index.md) #### Options -| Flag | Type | Required | Description | -| -------------------- | ------ | -------- | ----------------------------------------------- | -| `--model ` | string | no | Model name(s), comma-separated | -| `--period ` | string | no | Query usage for the last N minutes (default: 2) | +| Flag | Type | Required | Description | +| ------------------------------ | ------ | -------- | --------------------------------------------------- | +| `--model ` | string | no | Model name(s), comma-separated | +| `--period ` | string | no | Query usage for the last N minutes (default: 2) | +| `--console-region ` | string | no | Console region (global flag) | +| `--console-site ` | string | no | Console site: domestic, international (global flag) | +| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | #### Examples @@ -63,11 +66,14 @@ bl quota check --output json #### Options -| Flag | Type | Required | Description | -| ----------------- | ------ | -------- | ------------------------ | -| `--page ` | string | no | Page number (default: 1) | -| `--page-size ` | string | no | Page size (default: 10) | -| `--model ` | string | no | Filter by model name | +| Flag | Type | Required | Description | +| ------------------------------ | ------ | -------- | --------------------------------------------------- | +| `--page ` | string | no | Page number (default: 1) | +| `--page-size ` | string | no | Page size (default: 10) | +| `--model ` | string | no | Filter by model name | +| `--console-region ` | string | no | Console region (global flag) | +| `--console-site ` | string | no | Console site: domestic, international (global flag) | +| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | #### Examples @@ -101,10 +107,13 @@ bl quota history --output json #### Options -| Flag | Type | Required | Description | -| ----------------- | ------- | -------- | ------------------------------------------- | -| `--model ` | string | no | Model name(s), comma-separated | -| `--all` | boolean | no | Show all models, not just self-service ones | +| Flag | Type | Required | Description | +| ------------------------------ | ------- | -------- | --------------------------------------------------- | +| `--model ` | string | no | Model name(s), comma-separated | +| `--all` | boolean | no | Show all models, not just self-service ones | +| `--console-region ` | string | no | Console region (global flag) | +| `--console-site ` | string | no | Console site: domestic, international (global flag) | +| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | #### Examples @@ -138,11 +147,14 @@ bl quota list --output json #### Options -| Flag | Type | Required | Description | -| ----------------- | ------- | -------- | --------------------------- | -| `--model ` | string | yes | Model name (required) | -| `--tpm ` | string | yes | Target TPM value (required) | -| `--yes` | boolean | no | Skip downgrade confirmation | +| Flag | Type | Required | Description | +| ------------------------------ | ------- | -------- | --------------------------------------------------- | +| `--model ` | string | yes | Model name (required) | +| `--tpm ` | string | yes | Target TPM value (required) | +| `--yes` | boolean | no | Skip downgrade confirmation | +| `--console-region ` | string | no | Console region (global flag) | +| `--console-site ` | string | no | Console site: domestic, international (global flag) | +| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | #### Examples diff --git a/skills/bailian-cli/reference/usage.md b/skills/bailian-cli/reference/usage.md index 9b9449c..66f6256 100644 --- a/skills/bailian-cli/reference/usage.md +++ b/skills/bailian-cli/reference/usage.md @@ -25,11 +25,14 @@ Index: [index.md](index.md) #### Options -| Flag | Type | Required | Description | -| ------------------- | ------ | -------- | ------------------------------------------------------------------------- | -| `--model ` | string | no | Model name(s) to query, comma-separated for multiple; omit for all models | -| `--expiring ` | string | no | Only show quotas expiring within N days | -| `--sort ` | string | no | Sort by: remaining (ascending), expires (ascending) | +| Flag | Type | Required | Description | +| ------------------------------ | ------ | -------- | ------------------------------------------------------------------------- | +| `--model ` | string | no | Model name(s) to query, comma-separated for multiple; omit for all models | +| `--expiring ` | string | no | Only show quotas expiring within N days | +| `--sort ` | string | no | Sort by: remaining (ascending), expires (ascending) | +| `--console-region ` | string | no | Console region (global flag) | +| `--console-site ` | string | no | Console site: domestic, international (global flag) | +| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | #### Examples @@ -71,12 +74,15 @@ bl usage free --model qwen3-max --console-region cn-beijing #### Options -| Flag | Type | Required | Description | -| ----------------- | ------- | -------- | ------------------------------------------- | -| `--model ` | string | no | Model name(s), comma-separated for multiple | -| `--all` | boolean | no | Apply to all free-tier models | -| `--on` | boolean | no | Enable auto-stop (default behavior) | -| `--off` | boolean | no | Disable auto-stop | +| Flag | Type | Required | Description | +| ------------------------------ | ------- | -------- | --------------------------------------------------- | +| `--model ` | string | no | Model name(s), comma-separated for multiple | +| `--all` | boolean | no | Apply to all free-tier models | +| `--on` | boolean | no | Enable auto-stop (default behavior) | +| `--off` | boolean | no | Disable auto-stop | +| `--console-region ` | string | no | Console region (global flag) | +| `--console-site ` | string | no | Console site: domestic, international (global flag) | +| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | #### Examples @@ -114,12 +120,15 @@ bl usage freetier --off --all #### Options -| Flag | Type | Required | Description | -| --------------------- | ------ | -------- | ------------------------------------------------------ | -| `--model ` | string | no | Model name(s), comma-separated; omit for overview | -| `--days ` | string | no | Number of days (default: 7) | -| `--type ` | string | no | Model type: Text, Vision, Multimodal, Audio, Embedding | -| `--workspace-id ` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) | +| Flag | Type | Required | Description | +| ------------------------------ | ------ | -------- | ------------------------------------------------------ | +| `--model ` | string | no | Model name(s), comma-separated; omit for overview | +| `--days ` | string | no | Number of days (default: 7) | +| `--type ` | string | no | Model type: Text, Vision, Multimodal, Audio, Embedding | +| `--workspace-id ` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) | +| `--console-region ` | string | no | Console region (global flag) | +| `--console-site ` | string | no | Console site: domestic, international (global flag) | +| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | #### Examples diff --git a/skills/bailian-cli/reference/workspace.md b/skills/bailian-cli/reference/workspace.md index 3606bb0..82404a0 100644 --- a/skills/bailian-cli/reference/workspace.md +++ b/skills/bailian-cli/reference/workspace.md @@ -23,9 +23,12 @@ Index: [index.md](index.md) #### Options -| Flag | Type | Required | Description | -| ------------ | ------ | -------- | ----------------------- | -| `--list ` | string | no | Limit number of results | +| Flag | Type | Required | Description | +| ------------------------------ | ------ | -------- | --------------------------------------------------- | +| `--list ` | string | no | Limit number of results | +| `--console-region ` | string | no | Console region (global flag) | +| `--console-site ` | string | no | Console site: domestic, international (global flag) | +| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | #### Examples From 60cad1001c4f18303c4421e2bd693fc7ef0c05d8 Mon Sep 17 00:00:00 2001 From: lishengzxc <306009337@qq.com> Date: Tue, 16 Jun 2026 19:44:08 +0800 Subject: [PATCH 20/20] chore: remove redundant "(global flag)" from option descriptions Co-Authored-By: Claude Opus 4.6 (1M context) --- AGENTS.md | 6 +-- packages/cli/src/commands/app/list.ts | 6 +-- packages/cli/src/commands/auth/status.ts | 6 +-- packages/cli/src/commands/console/call.ts | 6 +-- packages/cli/src/commands/mcp/list.ts | 6 +-- packages/cli/src/commands/quota/check.ts | 6 +-- packages/cli/src/commands/quota/history.ts | 6 +-- packages/cli/src/commands/quota/list.ts | 6 +-- packages/cli/src/commands/quota/request.ts | 6 +-- packages/cli/src/commands/usage/free.ts | 6 +-- packages/cli/src/commands/usage/freetier.ts | 6 +-- packages/cli/src/commands/usage/stats.ts | 6 +-- packages/cli/src/commands/workspace/list.ts | 6 +-- skills/bailian-cli/reference/app.md | 16 +++--- skills/bailian-cli/reference/auth.md | 10 ++-- skills/bailian-cli/reference/console.md | 6 +-- skills/bailian-cli/reference/mcp.md | 6 +-- skills/bailian-cli/reference/quota.md | 60 ++++++++++----------- skills/bailian-cli/reference/usage.md | 30 +++++------ skills/bailian-cli/reference/workspace.md | 12 ++--- 20 files changed, 109 insertions(+), 109 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 0c52651..98c6dd8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -98,9 +98,9 @@ CLI 只为「自己能权威解释的错误」发出语义化信号,服务端的 如果新命令使用了 `callConsoleGateway`,必须在 `options` 中添加以下三个全局 flag 的说明,以便 `--help` 中展示: ```ts -{ flag: "--console-region ", description: "Console region (global flag)" }, -{ flag: "--console-site ", description: "Console site: domestic, international (global flag)" }, -{ flag: "--console-switch-agent ", description: "Switch agent UID (global flag)", type: "number" }, +{ flag: "--console-region ", description: "Console region" }, +{ flag: "--console-site ", description: "Console site: domestic, international" }, +{ flag: "--console-switch-agent ", description: "Switch agent UID", type: "number" }, ``` 这些 flag 已在 `GLOBAL_OPTIONS`(`packages/core/src/types/command.ts`)中注册,由 `loadConfig` 写入 `config.consoleRegion` / `config.consoleSite` / `config.consoleSwitchAgent`,`callConsoleGateway` 自动读取——命令无需手动提取或传递。 diff --git a/packages/cli/src/commands/app/list.ts b/packages/cli/src/commands/app/list.ts index 185ed24..b87694f 100644 --- a/packages/cli/src/commands/app/list.ts +++ b/packages/cli/src/commands/app/list.ts @@ -29,14 +29,14 @@ export default defineCommand({ description: "Results per page (default: 30)", type: "number", }, - { flag: "--console-region ", description: "Console region (global flag)" }, + { flag: "--console-region ", description: "Console region" }, { flag: "--console-site ", - description: "Console site: domestic, international (global flag)", + description: "Console site: domestic, international", }, { flag: "--console-switch-agent ", - description: "Switch agent UID (global flag)", + description: "Switch agent UID", type: "number", }, ], diff --git a/packages/cli/src/commands/auth/status.ts b/packages/cli/src/commands/auth/status.ts index 5276638..6078037 100644 --- a/packages/cli/src/commands/auth/status.ts +++ b/packages/cli/src/commands/auth/status.ts @@ -143,14 +143,14 @@ export default defineCommand({ description: "Show current authentication state", usage: "bl auth status", options: [ - { flag: "--console-region ", description: "Console region (global flag)" }, + { flag: "--console-region ", description: "Console region" }, { flag: "--console-site ", - description: "Console site: domestic, international (global flag)", + description: "Console site: domestic, international", }, { flag: "--console-switch-agent ", - description: "Switch agent UID (global flag)", + description: "Switch agent UID", type: "number", }, ], diff --git a/packages/cli/src/commands/console/call.ts b/packages/cli/src/commands/console/call.ts index b278fa5..aeb03da 100644 --- a/packages/cli/src/commands/console/call.ts +++ b/packages/cli/src/commands/console/call.ts @@ -27,14 +27,14 @@ export default defineCommand({ description: "Request data as JSON string", required: true, }, - { flag: "--console-region ", description: "Console region (global flag)" }, + { flag: "--console-region ", description: "Console region" }, { flag: "--console-site ", - description: "Console site: domestic, international (global flag)", + description: "Console site: domestic, international", }, { flag: "--console-switch-agent ", - description: "Switch agent UID (global flag)", + description: "Switch agent UID", type: "number", }, ], diff --git a/packages/cli/src/commands/mcp/list.ts b/packages/cli/src/commands/mcp/list.ts index 48b7c42..400a468 100644 --- a/packages/cli/src/commands/mcp/list.ts +++ b/packages/cli/src/commands/mcp/list.ts @@ -36,14 +36,14 @@ export default defineCommand({ }, { flag: "--page ", description: "Page number (default: 1)", type: "number" }, { flag: "--page-size ", description: "Results per page (default: 30)", type: "number" }, - { flag: "--console-region ", description: "Console region (global flag)" }, + { flag: "--console-region ", description: "Console region" }, { flag: "--console-site ", - description: "Console site: domestic, international (global flag)", + description: "Console site: domestic, international", }, { flag: "--console-switch-agent ", - description: "Switch agent UID (global flag)", + description: "Switch agent UID", type: "number", }, ], diff --git a/packages/cli/src/commands/quota/check.ts b/packages/cli/src/commands/quota/check.ts index 09065cc..b224b1a 100644 --- a/packages/cli/src/commands/quota/check.ts +++ b/packages/cli/src/commands/quota/check.ts @@ -254,14 +254,14 @@ export default defineCommand({ flag: "--period ", description: "Query usage for the last N minutes (default: 2)", }, - { flag: "--console-region ", description: "Console region (global flag)" }, + { flag: "--console-region ", description: "Console region" }, { flag: "--console-site ", - description: "Console site: domestic, international (global flag)", + description: "Console site: domestic, international", }, { flag: "--console-switch-agent ", - description: "Switch agent UID (global flag)", + description: "Switch agent UID", type: "number", }, ], diff --git a/packages/cli/src/commands/quota/history.ts b/packages/cli/src/commands/quota/history.ts index 3d6593c..51f2643 100644 --- a/packages/cli/src/commands/quota/history.ts +++ b/packages/cli/src/commands/quota/history.ts @@ -114,14 +114,14 @@ export default defineCommand({ flag: "--model ", description: "Filter by model name", }, - { flag: "--console-region ", description: "Console region (global flag)" }, + { flag: "--console-region ", description: "Console region" }, { flag: "--console-site ", - description: "Console site: domestic, international (global flag)", + description: "Console site: domestic, international", }, { flag: "--console-switch-agent ", - description: "Switch agent UID (global flag)", + description: "Switch agent UID", type: "number", }, ], diff --git a/packages/cli/src/commands/quota/list.ts b/packages/cli/src/commands/quota/list.ts index 06e2b2a..77f9dd3 100644 --- a/packages/cli/src/commands/quota/list.ts +++ b/packages/cli/src/commands/quota/list.ts @@ -169,14 +169,14 @@ export default defineCommand({ flag: "--all", description: "Show all models, not just self-service ones", }, - { flag: "--console-region ", description: "Console region (global flag)" }, + { flag: "--console-region ", description: "Console region" }, { flag: "--console-site ", - description: "Console site: domestic, international (global flag)", + description: "Console site: domestic, international", }, { flag: "--console-switch-agent ", - description: "Switch agent UID (global flag)", + description: "Switch agent UID", type: "number", }, ], diff --git a/packages/cli/src/commands/quota/request.ts b/packages/cli/src/commands/quota/request.ts index 89c7660..de4858d 100644 --- a/packages/cli/src/commands/quota/request.ts +++ b/packages/cli/src/commands/quota/request.ts @@ -96,14 +96,14 @@ export default defineCommand({ flag: "--yes", description: "Skip downgrade confirmation", }, - { flag: "--console-region ", description: "Console region (global flag)" }, + { flag: "--console-region ", description: "Console region" }, { flag: "--console-site ", - description: "Console site: domestic, international (global flag)", + description: "Console site: domestic, international", }, { flag: "--console-switch-agent ", - description: "Switch agent UID (global flag)", + description: "Switch agent UID", type: "number", }, ], diff --git a/packages/cli/src/commands/usage/free.ts b/packages/cli/src/commands/usage/free.ts index d6ef941..854a8b4 100644 --- a/packages/cli/src/commands/usage/free.ts +++ b/packages/cli/src/commands/usage/free.ts @@ -207,14 +207,14 @@ export default defineCommand({ flag: "--sort ", description: "Sort by: remaining (ascending), expires (ascending)", }, - { flag: "--console-region ", description: "Console region (global flag)" }, + { flag: "--console-region ", description: "Console region" }, { flag: "--console-site ", - description: "Console site: domestic, international (global flag)", + description: "Console site: domestic, international", }, { flag: "--console-switch-agent ", - description: "Switch agent UID (global flag)", + description: "Switch agent UID", type: "number", }, ], diff --git a/packages/cli/src/commands/usage/freetier.ts b/packages/cli/src/commands/usage/freetier.ts index ec820ec..7f249b5 100644 --- a/packages/cli/src/commands/usage/freetier.ts +++ b/packages/cli/src/commands/usage/freetier.ts @@ -121,14 +121,14 @@ export default defineCommand({ flag: "--off", description: "Disable auto-stop", }, - { flag: "--console-region ", description: "Console region (global flag)" }, + { flag: "--console-region ", description: "Console region" }, { flag: "--console-site ", - description: "Console site: domestic, international (global flag)", + description: "Console site: domestic, international", }, { flag: "--console-switch-agent ", - description: "Switch agent UID (global flag)", + description: "Switch agent UID", type: "number", }, ], diff --git a/packages/cli/src/commands/usage/stats.ts b/packages/cli/src/commands/usage/stats.ts index 46d0f49..bb91822 100644 --- a/packages/cli/src/commands/usage/stats.ts +++ b/packages/cli/src/commands/usage/stats.ts @@ -323,14 +323,14 @@ export default defineCommand({ flag: "--workspace-id ", description: "Workspace ID (env: BAILIAN_WORKSPACE_ID)", }, - { flag: "--console-region ", description: "Console region (global flag)" }, + { flag: "--console-region ", description: "Console region" }, { flag: "--console-site ", - description: "Console site: domestic, international (global flag)", + description: "Console site: domestic, international", }, { flag: "--console-switch-agent ", - description: "Switch agent UID (global flag)", + description: "Switch agent UID", type: "number", }, ], diff --git a/packages/cli/src/commands/workspace/list.ts b/packages/cli/src/commands/workspace/list.ts index 3a95362..e213b9f 100644 --- a/packages/cli/src/commands/workspace/list.ts +++ b/packages/cli/src/commands/workspace/list.ts @@ -93,14 +93,14 @@ export default defineCommand({ flag: "--list ", description: "Limit number of results", }, - { flag: "--console-region ", description: "Console region (global flag)" }, + { flag: "--console-region ", description: "Console region" }, { flag: "--console-site ", - description: "Console site: domestic, international (global flag)", + description: "Console site: domestic, international", }, { flag: "--console-switch-agent ", - description: "Switch agent UID (global flag)", + description: "Switch agent UID", type: "number", }, ], diff --git a/skills/bailian-cli/reference/app.md b/skills/bailian-cli/reference/app.md index 7a1bc95..5b56bfb 100644 --- a/skills/bailian-cli/reference/app.md +++ b/skills/bailian-cli/reference/app.md @@ -73,14 +73,14 @@ bl app call --app-id abc123 --prompt "开始" --biz-params '{"key":"value"}' #### Options -| Flag | Type | Required | Description | -| ------------------------------ | ------ | -------- | --------------------------------------------------- | -| `--name ` | string | no | Filter by app name (keyword search) | -| `--page ` | number | no | Page number (default: 1) | -| `--page-size ` | number | no | Results per page (default: 30) | -| `--console-region ` | string | no | Console region (global flag) | -| `--console-site ` | string | no | Console site: domestic, international (global flag) | -| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | +| Flag | Type | Required | Description | +| ------------------------------ | ------ | -------- | ------------------------------------- | +| `--name ` | string | no | Filter by app name (keyword search) | +| `--page ` | number | no | Page number (default: 1) | +| `--page-size ` | number | no | Results per page (default: 30) | +| `--console-region ` | string | no | Console region | +| `--console-site ` | string | no | Console site: domestic, international | +| `--console-switch-agent ` | number | no | Switch agent UID | #### Examples diff --git a/skills/bailian-cli/reference/auth.md b/skills/bailian-cli/reference/auth.md index f0e5f4f..eaa1006 100644 --- a/skills/bailian-cli/reference/auth.md +++ b/skills/bailian-cli/reference/auth.md @@ -84,11 +84,11 @@ bl auth logout --yes #### Options -| Flag | Type | Required | Description | -| ------------------------------ | ------ | -------- | --------------------------------------------------- | -| `--console-region ` | string | no | Console region (global flag) | -| `--console-site ` | string | no | Console site: domestic, international (global flag) | -| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | +| Flag | Type | Required | Description | +| ------------------------------ | ------ | -------- | ------------------------------------- | +| `--console-region ` | string | no | Console region | +| `--console-site ` | string | no | Console site: domestic, international | +| `--console-switch-agent ` | number | no | Switch agent UID | #### Examples diff --git a/skills/bailian-cli/reference/console.md b/skills/bailian-cli/reference/console.md index e6b6b57..26e70d5 100644 --- a/skills/bailian-cli/reference/console.md +++ b/skills/bailian-cli/reference/console.md @@ -27,9 +27,9 @@ Index: [index.md](index.md) | ------------------------------ | ------ | -------- | ------------------------------------------------------------------------ | | `--api ` | string | yes | API name (e.g. zeldaEasy.broadscope-bailian.memory-library.getLibraries) | | `--data ` | string | yes | Request data as JSON string | -| `--console-region ` | string | no | Console region (global flag) | -| `--console-site ` | string | no | Console site: domestic, international (global flag) | -| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | +| `--console-region ` | string | no | Console region | +| `--console-site ` | string | no | Console site: domestic, international | +| `--console-switch-agent ` | number | no | Switch agent UID | #### Examples diff --git a/skills/bailian-cli/reference/mcp.md b/skills/bailian-cli/reference/mcp.md index bd22232..e18dd94 100644 --- a/skills/bailian-cli/reference/mcp.md +++ b/skills/bailian-cli/reference/mcp.md @@ -63,9 +63,9 @@ bl mcp call market-cmapi00073529.SmartFundSelection --arg riskLevel=R3 --arg min | `--type ` | string | no | Server type: OFFICIAL \| PRIVATE (default: OFFICIAL) | | `--page ` | number | no | Page number (default: 1) | | `--page-size ` | number | no | Results per page (default: 30) | -| `--console-region ` | string | no | Console region (global flag) | -| `--console-site ` | string | no | Console site: domestic, international (global flag) | -| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | +| `--console-region ` | string | no | Console region | +| `--console-site ` | string | no | Console site: domestic, international | +| `--console-switch-agent ` | number | no | Switch agent UID | #### Examples diff --git a/skills/bailian-cli/reference/quota.md b/skills/bailian-cli/reference/quota.md index 9f7a68c..236f248 100644 --- a/skills/bailian-cli/reference/quota.md +++ b/skills/bailian-cli/reference/quota.md @@ -26,13 +26,13 @@ Index: [index.md](index.md) #### Options -| Flag | Type | Required | Description | -| ------------------------------ | ------ | -------- | --------------------------------------------------- | -| `--model ` | string | no | Model name(s), comma-separated | -| `--period ` | string | no | Query usage for the last N minutes (default: 2) | -| `--console-region ` | string | no | Console region (global flag) | -| `--console-site ` | string | no | Console site: domestic, international (global flag) | -| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | +| Flag | Type | Required | Description | +| ------------------------------ | ------ | -------- | ----------------------------------------------- | +| `--model ` | string | no | Model name(s), comma-separated | +| `--period ` | string | no | Query usage for the last N minutes (default: 2) | +| `--console-region ` | string | no | Console region | +| `--console-site ` | string | no | Console site: domestic, international | +| `--console-switch-agent ` | number | no | Switch agent UID | #### Examples @@ -66,14 +66,14 @@ bl quota check --output json #### Options -| Flag | Type | Required | Description | -| ------------------------------ | ------ | -------- | --------------------------------------------------- | -| `--page ` | string | no | Page number (default: 1) | -| `--page-size ` | string | no | Page size (default: 10) | -| `--model ` | string | no | Filter by model name | -| `--console-region ` | string | no | Console region (global flag) | -| `--console-site ` | string | no | Console site: domestic, international (global flag) | -| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | +| Flag | Type | Required | Description | +| ------------------------------ | ------ | -------- | ------------------------------------- | +| `--page ` | string | no | Page number (default: 1) | +| `--page-size ` | string | no | Page size (default: 10) | +| `--model ` | string | no | Filter by model name | +| `--console-region ` | string | no | Console region | +| `--console-site ` | string | no | Console site: domestic, international | +| `--console-switch-agent ` | number | no | Switch agent UID | #### Examples @@ -107,13 +107,13 @@ bl quota history --output json #### Options -| Flag | Type | Required | Description | -| ------------------------------ | ------- | -------- | --------------------------------------------------- | -| `--model ` | string | no | Model name(s), comma-separated | -| `--all` | boolean | no | Show all models, not just self-service ones | -| `--console-region ` | string | no | Console region (global flag) | -| `--console-site ` | string | no | Console site: domestic, international (global flag) | -| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | +| Flag | Type | Required | Description | +| ------------------------------ | ------- | -------- | ------------------------------------------- | +| `--model ` | string | no | Model name(s), comma-separated | +| `--all` | boolean | no | Show all models, not just self-service ones | +| `--console-region ` | string | no | Console region | +| `--console-site ` | string | no | Console site: domestic, international | +| `--console-switch-agent ` | number | no | Switch agent UID | #### Examples @@ -147,14 +147,14 @@ bl quota list --output json #### Options -| Flag | Type | Required | Description | -| ------------------------------ | ------- | -------- | --------------------------------------------------- | -| `--model ` | string | yes | Model name (required) | -| `--tpm ` | string | yes | Target TPM value (required) | -| `--yes` | boolean | no | Skip downgrade confirmation | -| `--console-region ` | string | no | Console region (global flag) | -| `--console-site ` | string | no | Console site: domestic, international (global flag) | -| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | +| Flag | Type | Required | Description | +| ------------------------------ | ------- | -------- | ------------------------------------- | +| `--model ` | string | yes | Model name (required) | +| `--tpm ` | string | yes | Target TPM value (required) | +| `--yes` | boolean | no | Skip downgrade confirmation | +| `--console-region ` | string | no | Console region | +| `--console-site ` | string | no | Console site: domestic, international | +| `--console-switch-agent ` | number | no | Switch agent UID | #### Examples diff --git a/skills/bailian-cli/reference/usage.md b/skills/bailian-cli/reference/usage.md index 66f6256..6ae89c9 100644 --- a/skills/bailian-cli/reference/usage.md +++ b/skills/bailian-cli/reference/usage.md @@ -30,9 +30,9 @@ Index: [index.md](index.md) | `--model ` | string | no | Model name(s) to query, comma-separated for multiple; omit for all models | | `--expiring ` | string | no | Only show quotas expiring within N days | | `--sort ` | string | no | Sort by: remaining (ascending), expires (ascending) | -| `--console-region ` | string | no | Console region (global flag) | -| `--console-site ` | string | no | Console site: domestic, international (global flag) | -| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | +| `--console-region ` | string | no | Console region | +| `--console-site ` | string | no | Console site: domestic, international | +| `--console-switch-agent ` | number | no | Switch agent UID | #### Examples @@ -74,15 +74,15 @@ bl usage free --model qwen3-max --console-region cn-beijing #### Options -| Flag | Type | Required | Description | -| ------------------------------ | ------- | -------- | --------------------------------------------------- | -| `--model ` | string | no | Model name(s), comma-separated for multiple | -| `--all` | boolean | no | Apply to all free-tier models | -| `--on` | boolean | no | Enable auto-stop (default behavior) | -| `--off` | boolean | no | Disable auto-stop | -| `--console-region ` | string | no | Console region (global flag) | -| `--console-site ` | string | no | Console site: domestic, international (global flag) | -| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | +| Flag | Type | Required | Description | +| ------------------------------ | ------- | -------- | ------------------------------------------- | +| `--model ` | string | no | Model name(s), comma-separated for multiple | +| `--all` | boolean | no | Apply to all free-tier models | +| `--on` | boolean | no | Enable auto-stop (default behavior) | +| `--off` | boolean | no | Disable auto-stop | +| `--console-region ` | string | no | Console region | +| `--console-site ` | string | no | Console site: domestic, international | +| `--console-switch-agent ` | number | no | Switch agent UID | #### Examples @@ -126,9 +126,9 @@ bl usage freetier --off --all | `--days ` | string | no | Number of days (default: 7) | | `--type ` | string | no | Model type: Text, Vision, Multimodal, Audio, Embedding | | `--workspace-id ` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) | -| `--console-region ` | string | no | Console region (global flag) | -| `--console-site ` | string | no | Console site: domestic, international (global flag) | -| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | +| `--console-region ` | string | no | Console region | +| `--console-site ` | string | no | Console site: domestic, international | +| `--console-switch-agent ` | number | no | Switch agent UID | #### Examples diff --git a/skills/bailian-cli/reference/workspace.md b/skills/bailian-cli/reference/workspace.md index 82404a0..5cceddc 100644 --- a/skills/bailian-cli/reference/workspace.md +++ b/skills/bailian-cli/reference/workspace.md @@ -23,12 +23,12 @@ Index: [index.md](index.md) #### Options -| Flag | Type | Required | Description | -| ------------------------------ | ------ | -------- | --------------------------------------------------- | -| `--list ` | string | no | Limit number of results | -| `--console-region ` | string | no | Console region (global flag) | -| `--console-site ` | string | no | Console site: domestic, international (global flag) | -| `--console-switch-agent ` | number | no | Switch agent UID (global flag) | +| Flag | Type | Required | Description | +| ------------------------------ | ------ | -------- | ------------------------------------- | +| `--list ` | string | no | Limit number of results | +| `--console-region ` | string | no | Console region | +| `--console-site ` | string | no | Console site: domestic, international | +| `--console-switch-agent ` | number | no | Switch agent UID | #### Examples