Skip to content

Commit a1023ce

Browse files
committed
chore(kb-dsh): 精简 src 若干注释
删除子仓时期特有的溯源信息("从 bl CLI 类型镜像"、验证时间戳、 Endpoint.AccessDenied 归因等冗余展开)——迁入本仓后这些细节已无参照必要。 涉及 api-types.ts / bl-cli.ts / console-login.ts / index.ts / service-cache.ts / web/bailian-card-controller.ts。
1 parent 7bc1c49 commit a1023ce

3 files changed

Lines changed: 16 additions & 24 deletions

File tree

packages/bailian-kb-dsh/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
百炼知识库的 dsh 插件包(同时是 dsh bundle):在 `ctx.tools` 注册两个检索模型工具(kb_search、kb_chat),并在 skills 服务可用时注册管理面 skill。服务发现通过 bl CLI(bailian-cli)完成。
44

5-
设计文档与实现计划归档在仓库 [`docs/kb-dsh/`](../../docs/kb-dsh/);维护约定见 [`docs/agents/dsh-plugin.md`](../../docs/agents/dsh-plugin.md)
6-
75
## 安装(dsh 用户)
86

97
```sh
@@ -66,7 +64,7 @@ dsh plugin --profile dev add <本仓库>/packages/bailian-kb-dsh
6664

6765
- **DashScope API Key** — write-only,`type=password` 遮罩输入草稿,仅显示 configured/来自环境变量 徽标;写 `~/.dsh/.credentials.yaml`
6866
- **Bailian Workspace ID / 默认检索服务 ID / 默认对话服务 ID** — 回显:读写 `bailian-kb` settings 用户层,预填当前解析值;清空保存 = 移除用户层,回退 entry config → credential
69-
- **自动获取** — 按钮调 Host 桥接路由 `/bailian-kb/autofill`:Host **自己走百炼控制台登录回调协议**(不经 `bl` 命令,也不读 `~/.bailian/config.json`)在宿主机拉起浏览器登录,回调落到本机 loopback 端口后直接把 API 密钥写入凭据存储、工作空间 ID 写入 settings,明文 key 不过浏览器;面板轮询到完成后自动刷新(无需再次点击)。登录 URL 始终带 `needapikey=true`,因此**每次都由本次登录的账号签发新 key**,key 与 workspaceId 必然同账号,切换账号直接点一次即可;`bl auth login --console` 自身做不到这点(它硬编码 `needApiKey: !hasApiKey`,已存 key 时不再签发,会把旧账号的 key 和新账号的 workspaceId 配在一起且无任何提示)
67+
- **自动获取** — 按钮调 Host 桥接路由 `/bailian-kb/autofill`:Host 在宿主机拉起浏览器登录百炼控制台(不经 `bl` 命令,回调落到本机 loopback 端口后直接把 API 密钥写入凭据存储、工作空间 ID 写入 settings,明文 key 不过浏览器;面板轮询到完成后自动刷新(无需再次点击)。登录 URL 始终请求签发新 key,因此每次都与当前账号配对,切换账号直接点一次即可
7068

7169
首次接入 seed:启动时若 API key / workspaceId 从未被设置过(settings、credential、env 均无值),自动从 `~/.bailian/config.json` 采纳一次;`seededFields` 字段(settings 文档内,面板不可编辑)记账已消费/已由用户管理的字段,用户主动清空的值永不会被重新填回。
7270

@@ -167,5 +165,5 @@ Config 同时注册为 `bailian-kb` settings namespace(`installSettingsSection
167165

168166
- kb_chat 执行期无进展显示(缓冲式;进展会话事件设计见仓库根 README 与 spec 附录 A)。
169167
- `top_k` 是客户端截断:请求体不含该参数,服务端返回条数由检索服务配置决定,截断只影响进入模型上下文的量。
170-
- **服务画像的质量上限取决于服务名**:`service list` 接口当前不返回描述(已对两个 workspace 实测确认),所以模型只能靠 `agent_name` 判断一个服务能查什么。名字形如 `test-0819` 的部署,引导能力接近于零。后端补齐描述字段后只需改三处(`api-types` 补字段名 → `services.ts` 解析 → `buildServiceCatalog` 追加并截断到 200 字符),缓存已预留 `description` 键,无需迁移。
171-
- 拉取每个 scene 最多 2 页 / 200 条(`page_size` 服务端硬顶 100),超出时标 `truncated` 并在清单里告知。
168+
- **服务画像的质量上限取决于服务名**:`service list` 接口当前不返回描述字段,所以模型只能靠 `agent_name` 判断一个服务能查什么。名字模糊的部署引导能力接近于零。后端补齐描述字段后只需改三处(`api-types` 补字段名 → `services.ts` 解析 → `buildServiceCatalog` 追加并截断到 200 字符),缓存已预留 `description` 键,无需迁移。
169+
- 拉取每个 scene 最多 2 页,超出时标 `truncated` 并在清单里告知。

packages/bailian-kb-dsh/src/api-types.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
1-
/** Request/response fields of the DashScope search and chat endpoints, mirrored from the verified bl CLI types. */
1+
/** Request/response fields of the DashScope search and chat endpoints. */
22

33
/** Retrieval-service scenes; the server requires one per list query. */
44
export type ServiceScene = "chat" | "search";
55

66
export interface ServiceListRequest {
77
agent_scene: ServiceScene;
8-
/**
9-
* Verified to be honored by the server, and to mean "deployed or edited"
10-
* (matching the CLI's documented `--status deployed(含 edited)`). The
11-
* spellings `status` and `agent_status_list` are silently ignored.
12-
*/
8+
/** Filter to deployed services (spelling required by the server). */
139
agent_status?: "deployed";
1410
agent_name?: string;
1511
page_number: number;
1612
page_size: number;
1713
}
1814

1915
/**
20-
* One row of the service list, mirrored from a verified live response
21-
* (2026-08-23). The response carries NO description field — confirmed against
22-
* two workspaces, including a name-filtered single-row query — even though
23-
* `service create --description` accepts one. `description` is therefore absent
24-
* here until the backend adds it; when it does, **name the field from the real
25-
* response** rather than guessing.
16+
* One row of the service list.
2617
*
27-
* `pipeline_list` is typed but deliberately never consumed: it frequently omits
28-
* `pipeline_name` (leaving an opaque id) and is sometimes empty outright, so it
29-
* cannot serve as a knowledge-base label.
18+
* `description` is not included: the listing endpoint does not currently return
19+
* it, even for services created with a description. Add it here once it starts
20+
* appearing on the wire.
21+
*
22+
* `pipeline_list` is typed but deliberately never consumed: it can omit
23+
* `pipeline_name` or come back empty, so it cannot serve as a knowledge-base
24+
* label.
3025
*/
3126
export interface ServiceListRow {
3227
agent_id?: string;

packages/bailian-kb-dsh/src/service-cache.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
* On-disk cache of the workspace's deployed retrieval services.
33
*
44
* Landing spot: `${DSH_HOME:-~/.dsh}/cache/bailian-kb/services-<workspaceId>.json`.
5-
* Per-workspace files are required, not cosmetic: an api key only reaches its own
6-
* workspace (cross-pairs return `Endpoint.AccessDenied`), and the panel's
7-
* "autofill" button exists to switch accounts, so one shared file would blend
8-
* services from different accounts.
5+
* Per-workspace files are required: an api key is scoped to one workspace, and
6+
* the panel's "autofill" button exists to switch accounts, so one shared file
7+
* would blend services from different accounts.
98
*
109
* Why not `ctx.storage`: the storage hub is absent from every shipped agent
1110
* preset, so `inject(['storage'])` may never fire for a third-party plugin, and

0 commit comments

Comments
 (0)