mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
fix(core): normalize model base URLs across all sources
- preserve custom gateway path prefixes - strip query, fragment, trailing slash, and known SDK suffixes - normalize flag, environment, config, and fallback sources - normalize auth and config writes before persistence - add resolver, login, config, and UI coverage
This commit is contained in:
@@ -43,7 +43,7 @@ defineCommand({ auth }) → runtime/authStage → ctx.client → command.run(ctx
|
||||
解析分工:
|
||||
|
||||
- `resolveApiKey()` — `auth: "apiKey"` 命令;优先级 `--api-key` > `DASHSCOPE_API_KEY` > config `api_key`
|
||||
- `resolveModelBaseUrl()` — model base URL;优先级 `--base-url` > `DASHSCOPE_BASE_URL` > config `base_url` > `REGIONS.cn`
|
||||
- `resolveModelBaseUrl()` — model base URL;优先级 `--base-url` > `DASHSCOPE_BASE_URL` > config `base_url` > `REGIONS.cn`,返回前统一去除 query、fragment、尾斜杠和已知 SDK/API Base 后缀,同时保留自定义网关前缀
|
||||
- `--config` 只选择 config 文件 block,不提升该 block 的字段优先级;内置套餐 Profile(当前为 `token-plan`)的预设仅在登录时物化写入,运行时继续走统一的 flag > env > selected config file > 默认值
|
||||
- `resolveConsole()` — `auth: "console"` 命令;当前 token 来自 config `access_token`,region/site/switchAgent 来自 flag > config > 默认
|
||||
- `resolveOpenApi()` — `auth: "openapi"` 命令;优先级 `--access-key-id/--access-key-secret` > `ALIBABA_CLOUD_ACCESS_KEY_ID/ALIBABA_CLOUD_ACCESS_KEY_SECRET` > config `access_key_*`。兼容读取旧字段 `openapi_access_key_*`,新写入只写短字段
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Token Plan Profile 与激活配置接入方案
|
||||
|
||||
> 状态:Token Plan 模型消费 MVP 与 Config 激活状态已实现;通用 Base URL 归一化待实现。
|
||||
> 状态:Token Plan 模型消费、Config 激活状态与通用 Base URL 归一化均已实现。
|
||||
>
|
||||
> 目标分支:`feat/cli-access-token`。
|
||||
|
||||
@@ -96,7 +96,7 @@ bl auth login \
|
||||
https://proxy.example.com/bailian
|
||||
```
|
||||
|
||||
紧急交付阶段以“不传 `--base-url`”的推荐登录路径为准,直接使用 `token-plan` 预设中的 canonical 根地址。完整的 SDK Base URL、自定义代理前缀和其他输入来源归一化在独立的通用 Base URL commit 中完成。在该 commit 合入前,如需显式覆盖,用户必须传入已经规范化的根地址,不能传 `/compatible-mode/v1` 或 `/apps/anthropic` 后缀。
|
||||
推荐路径仍是不传 `--base-url`,直接使用 `token-plan` 预设中的 canonical 根地址。显式覆盖时可以传服务根地址、自定义代理前缀,或带 `/compatible-mode/v1`、`/apps/anthropic` 的 SDK Base URL;CLI 会在验证和落盘前统一归一化。
|
||||
|
||||
### 2. 单次选择 Config
|
||||
|
||||
@@ -273,7 +273,7 @@ Selected Profile
|
||||
|
||||
## 通用模型 Base URL 归一化
|
||||
|
||||
Base URL 归一化是独立的通用能力,必须在 Token Plan 接入前完成,不能只针对 Token Plan hostname 实现。
|
||||
Base URL 归一化是独立的通用能力,不针对 Token Plan hostname 做特判。
|
||||
|
||||
### 语义
|
||||
|
||||
@@ -480,7 +480,7 @@ feat(config): add active profile selection
|
||||
|
||||
激活项选择的是完整 Config,而不是只选择模型消费凭证。激活 `token-plan` 后,Token Plan 管控命令也会从该 Profile 解析 OpenAPI AK/SK,Console 命令也会从该 Profile 解析 Console 凭证。如果相应凭证仍保存在顶层 `default`,用户需要为单次命令显式传入 `--config default`,或将对应凭证域登录到 `token-plan`;CLI 不为不同鉴权域做隐式跨 Profile 回退。
|
||||
|
||||
### Commit 5:通用模型 Base URL 归一化(待实现)
|
||||
### Commit 5:通用模型 Base URL 归一化(已实现)
|
||||
|
||||
建议提交信息:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user