Skip to content

Commit 17c52fb

Browse files
committed
Merge branch 'main' into fix/default-model
2 parents 5825291 + 634d704 commit 17c52fb

62 files changed

Lines changed: 4862 additions & 194 deletions

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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@ 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
10+
11+
### Added
12+
13+
- **`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:
14+
- `init` / `validate` / `plan` / `apply` / `destroy` — initialize and validate `agents.yaml`, preview and apply resource changes, and destroy managed resources.
15+
- `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.
16+
- `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.
17+
- `skill-list` — browse custom and official skills; use `--source all` to return both catalogs in one call.
18+
19+
### Changed
20+
21+
- 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.
22+
23+
### Fixed
24+
25+
- 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.
26+
927
## [1.10.1] - 2026-07-22
1028

1129
### Changed

CHANGELOG.zh.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@
66

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

9+
## [1.11.0] - 2026-07-28
10+
11+
### 新增
12+
13+
- **`bl managed-agent`** —— 通过统一 CLI 声明式管理 Managed Agent 基础设施;百炼 Provider 对接 AgentStudio,并支持 Claude、Qoder 和 Ark:
14+
- `init` / `validate` / `plan` / `apply` / `destroy` —— 基于 `agents.yaml` 初始化、校验、预览和执行资源变更,以及销毁已托管资源。
15+
- `state list` / `state show` / `state rm` / `state import` —— 查看和管理本地资源状态,包括纳管已有远端资源或仅解除本地跟踪。
16+
- `session create` / `session list` / `session get` / `session delete` / `session run` / `session send` / `session events` —— 完整的会话生命周期操作,支持流式响应和结构化的 `--output json` 输出。
17+
- `skill-list` —— 浏览自定义与官方 Skill;使用 `--source all` 可一次返回两个来源。
18+
19+
### 变更
20+
21+
- 模型 Base URL 现在统一仅保留 URL Origin;传入的路径、查询参数和 Fragment 不再参与后续 API 请求路径拼接。
22+
23+
### 修复
24+
25+
- 安装指南不再推荐已移除的 `--non-interactive`,改为说明显式传入必填参数,并使用 `--output json``NO_COLOR=1` 适配非交互环境。
26+
927
## [1.10.1] - 2026-07-22
1028

1129
### 变更

docs/agents/auth-change.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 层(类型 + 解析)

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.10.1",
3+
"version": "1.11.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.10.1",
3+
"version": "1.11.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.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>",

packages/commands/src/commands/config/set.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ export default defineCommand({
1414
"Config key (base_url, output, output_dir, timeout, api_key, access_token, access_key_id, access_key_secret, security_token, default_*_model, workspace_id)",
1515
required: true,
1616
},
17-
value: { type: "string", valueHint: "<value>", description: "Value to set", required: true },
17+
value: {
18+
type: "string",
19+
valueHint: "<value>",
20+
description: "Value to set",
21+
required: true,
22+
},
1823
},
1924
exampleArgs: [
2025
"--key output --value json",
@@ -44,7 +49,9 @@ export default defineCommand({
4449
return;
4550
}
4651

47-
await ctx.configStore.write({ [resolvedKey]: coerced } as Partial<ConfigFile>);
52+
await ctx.configStore.write({
53+
[resolvedKey]: coerced,
54+
} as Partial<ConfigFile>);
4855

4956
if (!settings.quiet) {
5057
const shown = SECRET_KEYS.has(resolvedKey) ? maskToken(String(coerced)) : coerced;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { ResourceAddress } from "@openagentpack/sdk";
2+
3+
/** Full state address: provider.type.name */
4+
export function formatResourceAddress(address: ResourceAddress): string {
5+
return `${address.provider}.${address.type}.${address.name}`;
6+
}
7+
8+
/** CLI display short label: type.name (provider) */
9+
export function formatResourceLabel(address: ResourceAddress): string {
10+
return `${address.type}.${address.name} (${address.provider})`;
11+
}

0 commit comments

Comments
 (0)