@@ -25,7 +25,7 @@ defineCommand({ auth }) → runtime/authStage → ctx.client → command.run(ctx
2525当前 command 鉴权域(` AuthRequirement ` ):
2626
2727- ` apiKey ` — DashScope / OpenAI-compatible 模型域,用 API key 与 model base URL
28- - ` console ` — Bailian Console Gateway,用 console access token + region/site/switchAgent/workspace
28+ - ` console ` — Bailian Console Gateway,用 console access token + region/site/switchAgent; ` workspace_id ` 是独立的 Settings 作用域,不属于 credential
2929- ` openapi ` — 阿里云 OpenAPI 签名域,用 AccessKey ID/Secret 调用 Token Plan 等 OpenAPI
3030- ` none ` — 本地命令、登录/配置类命令、无需 credential 的命令
3131
@@ -35,7 +35,7 @@ defineCommand({ auth }) → runtime/authStage → ctx.client → command.run(ctx
3535
3636- ` bl auth login --api-key ... ` 只更新 ` api_key ` / ` base_url `
3737- ` bl auth login --console ` 只更新 ` access_token ` 以及回调携带的 console 作用域字段
38- - ` bl auth login --open-api ... ` 只更新 ` access_key_id ` / ` access_key_secret `
38+ - ` bl auth login --open-api ... ` 更新 ` access_key_id ` / ` access_key_secret ` ,同时会调用 OpenAPI 生成 CLI ` access_token ` 并一并写入;即一次 ` --open-api ` 登录同时产生 ` openapi ` 与 ` console ` 域凭证
3939- ` bl auth logout --console ` 只清 ` access_token `
4040- ` bl auth logout --open-api ` 只清 ` access_key_id ` / ` access_key_secret ` / ` security_token `
4141- ` bl auth logout ` 清 ` api_key ` + ` base_url ` + ` access_token ` + ` access_key_* `
@@ -78,6 +78,9 @@ defineCommand({ auth }) → runtime/authStage → ctx.client → command.run(ctx
7878 - 如新增鉴权域,扩展 ` AuthRequirement `
7979 - 更新 ` credentialFlagDefs() ` 暴露该域可见的 flag
8080 - 必要时新增 ` *_AUTH_FLAGS `
81+ - ` workspace_id ` 是作用域字段而非 credential,不要把它放进 ` ConsoleCredential ` ;读取方式按命令 ` auth ` 域区分:
82+ - ` auth: "console" ` 命令通过 ` CONSOLE_AUTH_FLAGS ` 自动获得 ` --workspace-id ` ,由 ` buildSettings() ` 解析到 ` settings.workspaceId ` ,命令统一从 ` settings.workspaceId ` 读取
83+ - ` auth: "apiKey" ` /` "openapi" ` /` "none" ` 命令如需 ` --workspace-id ` ,必须自声明 flag;因它不会进入 credential/global flags,命令从 ` ctx.flags.workspaceId ` 读取(可回退到 ` settings.workspaceId ` )
8184- [ ] ` packages/core/src/auth/types.ts ` :
8285 - 新增 credential 类型 / source / scope 字段
8386- [ ] ` packages/core/src/auth/resolver.ts ` :
@@ -131,6 +134,8 @@ defineCommand({ auth }) → runtime/authStage → ctx.client → command.run(ctx
131134
132135## 完成后自查
133136
137+ 本仓库同时存在 ` bl ` (packages/cli) 与 ` kscli ` (packages/kscli) 两个入口,二者共享 core/runtime 鉴权链路,但暴露的命令不同。如果改动会影响两个入口共用的命令或错误提示,再分别验证它们各自实际暴露的路径;不要假设 ` kscli ` 也有 ` bl auth * ` 命令。
138+
134139``` sh
135140# 各种凭证组合
136141unset DASHSCOPE_API_KEY ALIBABA_CLOUD_ACCESS_KEY_ID ALIBABA_CLOUD_ACCESS_KEY_SECRET
@@ -150,9 +155,11 @@ Console 登录/网关相关改动:
150155
151156``` sh
152157pnpm -F bailian-cli exec tsx src/main.ts auth login --console
153- pnpm -F bailian-cli exec tsx src/main.ts usage stats --dry-run --output json
158+ pnpm -F bailian-cli exec tsx src/main.ts usage stats --dry-run --output json --workspace-id ws-xxx
154159```
155160
161+ 注意:` usage stats --dry-run ` 仍会先校验 workspace,必须传入 ` --workspace-id ` (或 ` BAILIAN_WORKSPACE_ID ` / config ` workspace_id ` )。
162+
156163## 常见漏点
157164
158165- ✗ 加了新 token 来源但忘了改 resolver 优先级,实际不生效
0 commit comments