Skip to content

Commit bbf45a5

Browse files
committed
Merge branch 'main' of github.com:modelstudioai/cli into feat/config-agent-fix
# Conflicts: # CHANGELOG.md # CHANGELOG.zh.md # packages/cli/package.json # packages/commands/package.json # packages/core/package.json # packages/kscli/package.json # packages/runtime/package.json # skills/bailian-cli/SKILL.md
2 parents 3988e70 + 3b7993e commit bbf45a5

94 files changed

Lines changed: 6311 additions & 515 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
66

77
[中文版](CHANGELOG.zh.md) · [README](README.md) · [Contributing](CONTRIBUTING.md)
88

9-
## [1.11.0] - 2026-07-28
9+
## [1.12.0] - 2026-07-28
1010

1111
### Added
1212

@@ -24,6 +24,44 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
2424
- `bl config agent` configurations now match each agent's official format: Claude Code honors `CLAUDE_CONFIG_DIR` and removes a stale `ANTHROPIC_API_KEY`; Qwen Code uses the v3 settings schema and writes credentials so a system-level `OPENAI_API_KEY` no longer takes precedence; OpenCode accepts JSONC config files (comments and trailing commas); OpenClaw registers the primary model in the model allowlist with complete cost metadata; Hermes uses the official flat `model.*` layout; Codex writes the official `env_key` with an `auth.json` fallback.
2525
- `bl config agent` now preserves existing user configuration when writing: it merges instead of overwriting, avoids duplicate provider entries, and keeps custom display names.
2626

27+
## [1.11.2] - 2026-07-28
28+
29+
### Changed
30+
31+
- MCP tools and WebSearch now provide activation guidance and direct marketplace links when Bailian reports that the corresponding service is not activated. WebSearch also guides users with legacy SSE connections to reactivate the service using Streamable HTTP.
32+
33+
### Fixed
34+
35+
- Fixed text chat and API Key validation compatibility failures caused by sending unsupported `enable_thinking` values. Text chat now sends the parameter only when thinking is explicitly enabled, while validation uses a compatible model without sending it.
36+
37+
## [1.11.1] - 2026-07-28
38+
39+
### Added
40+
41+
- `bl image edit` now supports `--function` for specifying edit operations with Wanx image-edit models such as `wanx2.1-imageedit`.
42+
43+
### Fixed
44+
45+
- Fixed image generation and editing failures and incorrect size parameters for some image models, improving compatibility with Qwen-Image, Wan/Wanx, Z-Image, and dated `wanx-v1` variants.
46+
47+
## [1.11.0] - 2026-07-28
48+
49+
### Added
50+
51+
- **`bl managed-agent`** — declaratively manage Managed Agent infrastructure through a unified CLI. The Bailian provider connects to AgentStudio, with Claude, Qoder, and Ark providers also supported:
52+
- `init` / `validate` / `plan` / `apply` / `destroy` — initialize and validate `agents.yaml`, preview and apply resource changes, and destroy managed resources.
53+
- `state list` / `state show` / `state rm` / `state import` — inspect and manage local resource state, including adopting an existing remote resource or removing it from local state without destroying it remotely.
54+
- `session create` / `session list` / `session get` / `session delete` / `session run` / `session send` / `session events` — manage the full session lifecycle with streaming responses and structured `--output json` output.
55+
- `skill-list` — browse custom and official skills; use `--source all` to return both catalogs in one call.
56+
57+
### Changed
58+
59+
- Model Base URLs are now normalized to the URL origin; paths, query parameters, and fragments supplied in the Base URL are no longer included when constructing API request paths.
60+
61+
### Fixed
62+
63+
- The installation guide no longer recommends the removed `--non-interactive` flag and now documents explicit required arguments, `--output json`, and `NO_COLOR=1` for non-interactive environments.
64+
2765
## [1.10.1] - 2026-07-22
2866

2967
### Changed

CHANGELOG.zh.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
[English](CHANGELOG.md) · [README](README.zh.md) · [参与贡献](CONTRIBUTING.zh.md)
88

9-
## [1.11.0] - 2026-07-28
9+
## [1.12.0] - 2026-07-28
1010

1111
### 新增
1212

@@ -24,6 +24,44 @@
2424
- `bl config agent` 写入的配置现已与各 Agent 官方格式对齐:Claude Code 尊重 `CLAUDE_CONFIG_DIR` 并清理残留的 `ANTHROPIC_API_KEY`;Qwen Code 采用 v3 配置 schema 并正确写入凭证,避免被系统级 `OPENAI_API_KEY` 干扰;OpenCode 支持带注释和尾部逗号的 JSONC 配置文件;OpenClaw 会将主模型注册进模型白名单并补齐计费元数据;Hermes 改用官方扁平 `model.*` 结构;Codex 写入官方 `env_key` 并支持 `auth.json` 兜底。
2525
- `bl config agent` 写入配置时现会保留用户已有配置:合并而非覆盖,避免重复添加 provider 条目,并保留用户自定义的显示名。
2626

27+
## [1.11.2] - 2026-07-28
28+
29+
### 变更
30+
31+
- MCP 工具或 WebSearch 因对应服务未开通而不可用时,CLI 现在会提供开通指引和市场直达链接;对于使用旧版 SSE 连接的 WebSearch,还会提示重新开通以切换至 Streamable HTTP。
32+
33+
### 修复
34+
35+
- 修复文本对话与 API Key 登录校验因传递不受支持的 `enable_thinking` 参数值而产生的兼容性错误。文本对话仅在用户明确开启思考模式时传递该参数,登录校验则改用兼容模型且不再传递该参数。
36+
37+
## [1.11.1] - 2026-07-28
38+
39+
### 新增
40+
41+
- `bl image edit` 新增 `--function` 参数,支持为万相图片编辑模型(如 `wanx2.1-imageedit`)指定编辑功能。
42+
43+
### 修复
44+
45+
- 修复部分图片模型在图片生成与编辑时的调用失败和尺寸参数错误,并完善 Qwen-Image、Wan/Wanx、Z-Image 系列及 `wanx-v1` 日期版本的兼容性。
46+
47+
## [1.11.0] - 2026-07-28
48+
49+
### 新增
50+
51+
- **`bl managed-agent`** —— 通过统一 CLI 声明式管理 Managed Agent 基础设施;百炼 Provider 对接 AgentStudio,并支持 Claude、Qoder 和 Ark:
52+
- `init` / `validate` / `plan` / `apply` / `destroy` —— 基于 `agents.yaml` 初始化、校验、预览和执行资源变更,以及销毁已托管资源。
53+
- `state list` / `state show` / `state rm` / `state import` —— 查看和管理本地资源状态,包括纳管已有远端资源或仅解除本地跟踪。
54+
- `session create` / `session list` / `session get` / `session delete` / `session run` / `session send` / `session events` —— 完整的会话生命周期操作,支持流式响应和结构化的 `--output json` 输出。
55+
- `skill-list` —— 浏览自定义与官方 Skill;使用 `--source all` 可一次返回两个来源。
56+
57+
### 变更
58+
59+
- 模型 Base URL 现在统一仅保留 URL Origin;传入的路径、查询参数和 Fragment 不再参与后续 API 请求路径拼接。
60+
61+
### 修复
62+
63+
- 安装指南不再推荐已移除的 `--non-interactive`,改为说明显式传入必填参数,并使用 `--output json``NO_COLOR=1` 适配非交互环境。
64+
2765
## [1.10.1] - 2026-07-22
2866

2967
### 变更

docs/agents/auth-change.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ defineCommand({ auth }) → runtime/authStage → ctx.client → command.run(ctx
4343
解析分工:
4444

4545
- `resolveApiKey()``auth: "apiKey"` 命令;优先级 `--api-key` > `DASHSCOPE_API_KEY` > config `api_key`
46-
- `resolveModelBaseUrl()` — model base URL;优先级 `--base-url` > `DASHSCOPE_BASE_URL` > config `base_url` > `REGIONS.cn`返回前统一去除 query、fragment、尾斜杠和已知 SDK/API Base 后缀,同时保留自定义网关前缀
46+
- `resolveModelBaseUrl()` — model base URL;优先级 `--base-url` > `DASHSCOPE_BASE_URL` > config `base_url` > `REGIONS.cn`返回前统一归一化为 URL origin(仅保留协议、host 和显式端口,去除 path、query、fragment)
4747
- `--config` 只选择 config 文件 block,不提升该 block 的字段优先级;内置套餐 Profile(当前为 `token-plan`)的预设仅在登录时物化写入,运行时继续走统一的 flag > env > selected config file > 默认值
4848
- 显式 `auth login --config <name>` 在凭证验证并落盘成功后自动激活目标 Profile;未传
4949
`--config` 时继续写当前激活项,失败和 dry-run 不切换
@@ -53,6 +53,23 @@ defineCommand({ auth }) → runtime/authStage → ctx.client → command.run(ctx
5353

5454
命令不要直接解析 token、env 或 config。业务请求统一走 `ctx.client`;登录/配置命令通过 `ctx.authStore` / `ctx.configStore` 的窄接口操作落盘。
5555

56+
### 例外:agent 命令的分层鉴权与 SDK 凭证内存注入
57+
58+
`bl managed-agent *` 按调用链分两层:
59+
60+
- **离线命令**`init``validate``state list/show/rm`:`auth: "none"`,只读写本地文件,无需登录;引擎侧传 `credentials: "none"` 跳过凭证断言
61+
- **联网命令**`plan``apply``destroy``state import``skill-list`、全部 `session *`:统一声明 `auth: "apiKey"` 硬门禁 —— 无论目标 provider 是谁,authStage 都经 `resolveApiKey(sources)` 解析 bailian 凭证(flag > env > active profile config),缺失报统一 AUTH;引擎层 `assertProviderCredentials` 再对 agents.yaml 里**全部已声明 provider** 的空 key 拦截并给 provider 专属 hint。例外:`plan --no-refresh` / `plan --dry-run``credentials: "none"` 并强制 `refresh: false`(不联网、不回写 state,不查 provider key),其中 `--dry-run` 连登录也不要求(authStage 的 dry-run 豁免),`--no-refresh` 仍需登录。
62+
63+
凭证不以真实值写入 `process.env`,而是经 `packages/commands/src/commands/managed-agent/_engine/`**内存注入管道**(`resolveAgentProjectConfig`)注入 SDK,管道五步:
64+
65+
1. `prepareProviderEnv()` — 先 `bootstrapRuntimeCredentialsSync()`(SDK 把 `.env` / `~/.agents/config.json` 灌进 env,服务 claude/ark/qoder 等非 bailian provider),再把全部凭证类 env(`CREDENTIAL_ENV_KEYS`,含别名)中仍为 undefined 的占位为 `""`,使 agents.yaml 插值不因缺变量抛错
66+
2. `resolveProjectConfig` — 插值发生:bailian 插值拿到占位空串,claude/ark 拿到真实 env 值;随后 `normalizeInterpolatedProviderBlocks()` 把插值为空导致的 YAML `null` 归一为 `""`(避免离线命令下空 key 在 SDK zod 层报 "received null")
67+
3. `injectProviderCredentials()` — 用 `ctx.client.exportApiCredential()`(lint 限定 `managed-agent/_engine/**` 可用)覆写内存 config 对象的 bailian 块:有凭证时 `api_key` 无条件覆写;`base_url`(拼 `/api/v1/agentstudio` 后缀,无凭证时用 client 默认域名补齐以满足 schema)/`workspace_id`(取 `settings.workspaceId`)仅在引用且为空时填充
68+
4. `scrubCredentialEnv()` — 从 `process.env` 删除全部凭证变量(真实凭证此后只存于 config 对象 → provider adapter 实例内存,不驻留 env / 不被子进程继承)
69+
5. `assertProviderCredentials(providers)` — 任一已声明 provider 的 `api_key` 为空 → CLI 权威 `AUTH` 错误 + provider 专属 hint(取代 SDK 原始插值/zod 报错);离线命令传 `credentials: "none"` 整体跳过
70+
71+
`bl auth login` 仅管理 bailian(DashScope)凭证;claude/ark/qoder 的 key 从 env(shell / `.env` / `~/.agents/config.json`)经插值进入 config 对象,同样被清扫。禁止命令层直接 `readConfigFile` 裸读凭证;bailian 字段以 CLI 鉴权链为唯一信源。
72+
5673
## 必查清单
5774

5875
### A. core 层(类型 + 解析)

docs/agents/url-change.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ runtime/src/urls.ts ← 用户面控制台 URL(cn-only)
2020
BAILIAN_CONSOLE BAILIAN_CONSOLE_ROOT/cn-beijing
2121
API_KEY_PAGE BAILIAN_CONSOLE/?tab=app#/api-key
2222
TOKEN_PLAN_PAGE BAILIAN_CONSOLE_ROOT/cn-beijing?tab=plan#/efm/subscription/overview
23+
MCP_WEBSEARCH_PAGE mcpMarketplaceDetailPage("WebSearch")
24+
mcpMarketplaceDetailPage BAILIAN_CONSOLE?tab=mcp#/mcp-market/detail/<serverCode>
2325
2426
core/files/upload.ts ← 文件上传 endpoint(cn-pinned)
2527
UPLOAD_API ${REGIONS.cn}/api/v1/uploads

packages/cli/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ node_modules
22
dist
33
*.log
44
.DS_Store
5-
outputs/
5+
outputs/
6+
# agents
7+
agents.state.json
8+
.env

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bailian-cli",
3-
"version": "1.11.0",
3+
"version": "1.12.0",
44
"description": "CLI for Aliyun Model Studio (DashScope) AI Platform.",
55
"keywords": [
66
"agent",

packages/cli/src/commands.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,23 @@ import {
8989
pluginLink,
9090
pluginList,
9191
pluginRemove,
92+
managedAgentInit,
93+
managedAgentValidate,
94+
managedAgentPlan,
95+
managedAgentApply,
96+
managedAgentDestroy,
97+
managedAgentStateList,
98+
managedAgentStateShow,
99+
managedAgentStateRm,
100+
managedAgentStateImport,
101+
managedAgentSessionCreate,
102+
managedAgentSessionList,
103+
managedAgentSessionGet,
104+
managedAgentSessionDelete,
105+
managedAgentSessionRun,
106+
managedAgentSessionSend,
107+
managedAgentSessionEvents,
108+
managedAgentSkillList,
92109
} from "bailian-cli-commands";
93110

94111
// Full bailian-cli product: every command, exposed under the `bl` binary.
@@ -186,4 +203,21 @@ export const commands: Record<string, AnyCommand> = {
186203
"plugin link": pluginLink,
187204
"plugin list": pluginList,
188205
"plugin remove": pluginRemove,
206+
"managed-agent init": managedAgentInit,
207+
"managed-agent validate": managedAgentValidate,
208+
"managed-agent plan": managedAgentPlan,
209+
"managed-agent apply": managedAgentApply,
210+
"managed-agent destroy": managedAgentDestroy,
211+
"managed-agent state list": managedAgentStateList,
212+
"managed-agent state show": managedAgentStateShow,
213+
"managed-agent state rm": managedAgentStateRm,
214+
"managed-agent state import": managedAgentStateImport,
215+
"managed-agent session create": managedAgentSessionCreate,
216+
"managed-agent session list": managedAgentSessionList,
217+
"managed-agent session get": managedAgentSessionGet,
218+
"managed-agent session delete": managedAgentSessionDelete,
219+
"managed-agent session run": managedAgentSessionRun,
220+
"managed-agent session send": managedAgentSessionSend,
221+
"managed-agent session events": managedAgentSessionEvents,
222+
"managed-agent skill-list": managedAgentSkillList,
189223
};

packages/commands/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bailian-cli-commands",
3-
"version": "1.11.0",
3+
"version": "1.12.0",
44
"description": "Command library for bailian-cli products (knowledge, memory, media, …). See https://www.npmjs.com/package/bailian-cli for usage.",
55
"homepage": "https://bailian.console.aliyun.com/cli",
66
"bugs": {
@@ -40,6 +40,7 @@
4040
"check": "vp check"
4141
},
4242
"dependencies": {
43+
"@openagentpack/sdk": "0.3.1",
4344
"bailian-cli-core": "workspace:*",
4445
"bailian-cli-runtime": "workspace:*",
4546
"boxen": "catalog:",

packages/commands/src/commands/auth/login-api-key.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export async function validateAndPersistApiKey(
5757
const persistBaseUrl = profile.persistBaseUrl
5858
? normalizeModelBaseUrl(profile.persistBaseUrl)
5959
: undefined;
60-
const validationModel = profile.defaultTextModel || "qwen3.7-max";
60+
const validationModel = "qwen3.7-max";
6161
const requestOpts = {
6262
url: baseUrl + chatPath(),
6363
method: "POST",
@@ -68,7 +68,6 @@ export async function validateAndPersistApiKey(
6868
messages: [{ role: "user", content: "hi" }],
6969
max_tokens: 1,
7070
stream: false,
71-
enable_thinking: validationModel === "qwen3.8-max-preview",
7271
},
7372
};
7473

packages/commands/src/commands/auth/login.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ export default defineCommand({
2121
usageArgs:
2222
"--api-key <key> | --console | --open-api --access-key-id <id> --access-key-secret <secret>",
2323
flags: {
24-
apiKey: { type: "string", valueHint: "<key>", description: "Model API key to store" },
24+
apiKey: {
25+
type: "string",
26+
valueHint: "<key>",
27+
description: "Model API key to store",
28+
},
2529
baseUrl: {
2630
type: "string",
2731
valueHint: "<url>",

0 commit comments

Comments
 (0)