Skip to content

Commit 9cf5883

Browse files
committed
feat(bailian-kb-dsh): update dependencies and configuration for new plugin architecture
- Updated `pnpm-lock.yaml` to reflect new versions for dependencies, including `@deepseek-ai/cordis` and `@deepseek-ai/dsh-agent`. - Refactored `dsh-plugin.md` documentation to clarify plugin responsibilities and configuration. - Introduced a new implementation plan for Dsh plugin configuration in `2026-10-09-dsh-config.md`. - Enhanced `README.md` and `README.zh.md` to provide clearer instructions on plugin setup and usage. - Added new configuration and credential management files to streamline API key handling and workspace settings. - Improved error handling and validation for API key and workspace configurations in the plugin.
1 parent 44dd129 commit 9cf5883

66 files changed

Lines changed: 3933 additions & 3321 deletions

Some content is hidden

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

‎docs/agents/dsh-plugin.md‎

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121

2222
当前包:
2323

24-
| 包 | 职责 | 目标 dsh | 设计文档 |
25-
| ------------------ | ------------------------------------------ | --------------------------------------------- | ------------------------------ |
26-
| `bailian-kb-dsh` | 知识库 `kb_search` / `kb_chat` + skill | 仍为 rc-era SettingsProvider 模式(迁移另开) | [docs/kb-dsh/](../kb-dsh/) |
27-
| `bailian-memo-dsh` | 个人记忆自动召回 / 静默筛选 / 工具与设置页 | **0.2.1** Volatile Config + SettingsForms | [docs/memo-dsh/](../memo-dsh/) |
24+
| 包 | 职责 | 目标 dsh | 设计文档 |
25+
| ------------------ | ------------------------------------------ | ----------------------------------------- | ------------------------------ |
26+
| `bailian-kb-dsh` | 知识库 `kb_search` / `kb_chat` + skill | **0.2.1** Volatile Config + SettingsForms | [docs/kb-dsh/](../kb-dsh/) |
27+
| `bailian-memo-dsh` | 个人记忆自动召回 / 静默筛选 / 工具与设置页 | **0.2.1** Volatile Config + SettingsForms | [docs/memo-dsh/](../memo-dsh/) |
2828

2929
## tsconfig 三件套(改动前先读)
3030

@@ -61,13 +61,24 @@
6161

6262
### D. 现代 vs 遗留 Settings(重要)
6363

64-
| | `bailian-memo-dsh`(新) | `bailian-kb-dsh`(遗留,待迁移) |
65-
| ------------- | ----------------------------------------------- | ------------------------------------------------- |
66-
| Config | `Volatile` / `.volatile()` | 普通 Config + `SettingsProvider` |
67-
| Client | `SettingsFormModel` + `configForms.whileServed` | 自定义 `/settings` bridge + `credentials/updated` |
68-
| Host 辅助路由 | `webServer` + `connection.requestRejection` | 同类 bridge 路由 |
64+
| | `bailian-memo-dsh` / `bailian-kb-dsh` |
65+
| ------------- | ----------------------------------------------- |
66+
| Config | `Volatile` / `.volatile()` |
67+
| Client | `SettingsFormModel` + `configForms.whileServed` |
68+
| Host 辅助路由 | `webServer` + `connection.requestRejection` |
6969

70-
**新插件禁止**复制 kb-dsh 的 SettingsProvider / `/settings` bridge / `credentials/updated`。kb-dsh 迁移到 0.2.1 模式另开任务,不要塞进 memo 变更。
70+
**新插件禁止**复制已删除的 SettingsProvider / `/settings` bridge / `credentials/updated`。API Key 放凭据域,页面字段放插件 Volatile Config。
71+
72+
### 配置归属与迁移
73+
74+
- 两插件分别使用 dsh credentials 的 `BAILIAN_KB_API_KEY` / `BAILIAN_MEMO_API_KEY`,独立读写,运行时不读取通用 `DASHSCOPE_API_KEY`;Workspace、默认服务、行为设置只放各自的 dsh Volatile Config。
75+
- `endpointHost` 不再是插件配置,使用固定北京端点。
76+
- bl `~/.bailian/config.json` 只作为启动默认值来源,按根级 `active_config` 指向的命名 block 读取,不混用默认 Profile 的字段。
77+
- 首次启动将旧 Workspace / 默认服务迁入 dsh settings;`configInitialized` 防止用户清空后再次导入。缺失的插件专属 Key 仍允许在启动时补入。
78+
- memo 个人文件只负责身份、授权状态和 Workspace 绑定;请求 Workspace 取 dsh,绑定不一致必须阻止请求,不能静默修改绑定。
79+
- kb 管理操作走 `kb_manage`,宿主用独立临时配置目录执行 bl,传递当前 dsh Key / Workspace,拒绝连接覆盖参数(含 camelCase 形式),保留 CLI 确认机制。
80+
- 手动 Key / Workspace 编辑使用独立连接草稿和受鉴权保护的保存接口;Key 留空保留、旧值不回显,先验证组合再保存。密钥不进入 SettingsForm 业务配置,错误消息不能包含请求中的密钥;页面明确两个插件的 Key 和 Workspace 相互独立。
81+
- 改配置时测试启动等待、迁移优先级、清空后重启、运行时配置修改、身份绑定和管理进程隔离。
7182

7283
### E. 文档
7384

@@ -132,3 +143,11 @@ node tools/release/publish-kb-dsh.mjs --dry-run
132143
- memo 设计:[docs/memo-dsh/](../memo-dsh/)
133144
- kb 设计 / 运行时:[docs/kb-dsh/](../kb-dsh/)
134145
- 用户面:各包 `README.md` / `README.zh.md`
146+
147+
### Memo 画像规则
148+
149+
- `extractProfile` 默认 false,保存在 memo 的 dsh settings;显式记忆与自动整理共用此开关,模型参数不能越过它。
150+
- 不创建画像模板;用户所选 `profileSchemaId` 保存在 memo dsh settings;每次实际提交画像抽取或读取画像前查询已有规则,普通 search 无需查询。
151+
- 列表/详情实测都没有默认标记和创建时间;按用户约定,未选择时默认完整列表最后一项。UI 在开启抽取时显示选择框,保存时持久化所选 ID;已有 ID 不可用必须提示重选。不能将列表顺序解释为创建时间。
152+
- 抽取关闭不删除或停止召回已有画像;画像读取失败不阻断普通记忆召回。画像删除全过程必须使用同一个已解析 ID。
153+
- 个人配置 v3 去掉旧画像引用,保留身份/授权/暂停/绑定;回归测试必须隔离 homedir 或显式传入临时路径,禁止真实个人配置读写。

‎packages/bailian-kb-dsh/README.md‎

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -50,71 +50,33 @@ Verify the plugin is composed — `dsh --profile web --dump-config` should list
5050

5151
## Configuration
5252

53-
### Option 1 — Settings page (recommended)
53+
Configure the plugin from its dsh settings page. The API key belongs only to this plugin in dsh credentials (`BAILIAN_KB_API_KEY`, normally `~/.dsh/.credentials.yaml`; the host owns the actual path). All business settings belong exclusively to this plugin's dsh configuration:
5454

55-
After installation, **Settings → Bailian KB** appears in the web UI:
55+
| Field | Meaning | Default |
56+
| ------------------------ | ----------------------------------------- | ---------------- |
57+
| `workspaceId` | Workspace for all knowledge calls | Required |
58+
| `defaultRetrieveAgentId` | Default retrieval service | Unset |
59+
| `defaultChatAgentId` | Default Q&A service | Unset |
60+
| `agentVersion` | Draft `beta` or published service version | Latest published |
61+
| `chatTimeoutMs` | Chat timeout in milliseconds | 300000 |
5662

57-
- **Fetch from console login** — opens the Bailian console in a browser on the host machine; when you finish signing in, the API key and workspace id of that account are stored on the host (the key never travels to the browser). Each login requests a freshly issued key, so switching accounts is one click.
58-
- **API key** — write-only: the stored value is never echoed back, only reported as configured or not.
59-
- **Workspace id / default retrieval service / default Q&A service** — editable with echo; the service ids can be picked from the cached service list. Clearing a value falls back to the layers below.
60-
- **Retrieval service cache** — shows when the injected service list was last fetched, how many services it holds, and offers a manual refresh for a service you just created.
63+
The endpoint is fixed to `cn-beijing.maas.aliyuncs.com`. There is no endpoint setting. Settings page edits apply to the next call.
6164

62-
If you have already run `bl auth login`, the API key and workspace id are adopted once from `~/.bailian/config.json` at startup. A value you deliberately clear is never re-filled.
65+
At startup, a missing API key may be imported from the active profile in `~/.bailian/config.json`. On the first configuration migration, missing workspace/default-service fields are imported from legacy dsh credentials, with the bl profile as the workspace default. Explicit dsh settings win. The internal `configInitialized` marker prevents cleared settings from being imported again. A missing API key can still be seeded on subsequent startups.
6366

64-
### Option 2 — Environment and credential files
67+
After initialization, business fields are read only from dsh plugin settings, never from bl or legacy credential fields. Clearing Workspace makes calls fail until it is configured again. Console login saves the key in dsh credentials and Workspace in dsh settings. KB does not create a `personal-kb/config.json` file.
6568

66-
```sh
67-
# ~/.dsh/.env, or the credential store at ~/.dsh/.credentials.yaml
68-
DASHSCOPE_API_KEY=sk-xxx # required
69-
BAILIAN_WORKSPACE_ID=ws-xxx # required
70-
BAILIAN_DEFAULT_RETRIEVE_AGENT_ID=aid-xxx # optional
71-
BAILIAN_DEFAULT_CHAT_AGENT_ID=aid-xxx # optional
72-
```
73-
74-
### Option 3 — Profile patch
75-
76-
The bundle inserts its own entry into the profile; you can override it by id in `~/.dsh/cordis.patch.yml` or the profile's patch file. An override **replaces the whole config object** (no deep merge):
77-
78-
```yaml
79-
- id: tool-bailian-kb
80-
config:
81-
defaultRetrieveAgentId: aid-search-service
82-
defaultChatAgentId: aid-chat-service
83-
chatTimeoutMs: 600000
84-
```
85-
86-
Disable the plugin with `- id: tool-bailian-kb` plus `disabled: true`.
69+
The connection panel also accepts a new API key in a password field. Leave it blank to retain the current key, then use **Verify and save** to validate the key/Workspace pair before saving. Failed validation changes neither value; a settings-write failure attempts to restore the previous pair. The key is never read back and the input is cleared after success. Each plugin keeps its own API key and Workspace; editing one plugin does not affect the other. A key supplied by the launch environment must be changed there.
8770

88-
### Config fields
89-
90-
The config doubles as the `bailian-kb` settings section, so edits in the settings page or settings document apply to the next call without a restart.
91-
92-
| Field | Type | Default | Meaning |
93-
| ------------------------ | ------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------- |
94-
| `workspaceId` | string? | — | Bailian workspace id; the API host is the workspace subdomain `https://<workspaceId>.<endpointHost>` |
95-
| `endpointHost` | string | `cn-beijing.maas.aliyuncs.com` | Host suffix; replace for another region or a private deployment |
96-
| `defaultRetrieveAgentId` | string? | — | Service `kb_search` falls back to when the caller omits `agent_id` |
97-
| `defaultChatAgentId` | string? | — | Service `kb_chat` falls back to when the caller omits `agent_id` |
98-
| `agentVersion` | string? | — | `beta` (draft) or a published version number; defaults to the latest published version. Not exposed to the model |
99-
| `chatTimeoutMs` | number | `300000` | `kb_chat` timeout — the server side is a minutes-scale agentic loop |
100-
101-
### Resolution order
102-
103-
| Value | Settings layer (settings page) | Entry config (profile patch) | Credential store / env |
104-
| ------------------------- | ------------------------------ | ---------------------------- | ----------------------------------- |
105-
| `DASHSCOPE_API_KEY` | write-only control | — | `DASHSCOPE_API_KEY` |
106-
| workspace id | ✅ `workspaceId` | ✅ `workspaceId` | `BAILIAN_WORKSPACE_ID` |
107-
| default retrieval service | ✅ `defaultRetrieveAgentId` | ✅ `defaultRetrieveAgentId` | `BAILIAN_DEFAULT_RETRIEVE_AGENT_ID` |
108-
| default Q&A service | ✅ `defaultChatAgentId` | ✅ `defaultChatAgentId` | `BAILIAN_DEFAULT_CHAT_AGENT_ID` |
109-
110-
Every value is re-read per call, so a rotated key or a switched workspace takes effect immediately. The API key and workspace id are mandatory: without them the tools fail with a message pointing at these configuration paths. Default services are optional — when the workspace has exactly one deployed service for a scene, that one is used.
71+
Management uses `kb_manage` with arguments after `bl knowledge`, for example `{"args":["service","list","--scene","search"]}`. The host executes the installed `bl` executable with a temporary isolated config directory and the same current key/Workspace as the native tools. Connection override flags are rejected. Secrets are passed through the child environment, never tool arguments. Direct shell invocation of bl remains independent and is not the plugin management path.
11172

11273
## Tools
11374

11475
| Tool | Parameters | Returns |
11576
| ----------- | ---------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- |
11677
| `kb_search` | `query`, `agent_id` (required), `top_k?` (default 5, applied client-side), `images?` (image URLs for multimodal) | Scored chunks with source references, plus a total |
11778
| `kb_chat` | `message`, `agent_id` (required) | The complete answer plus a `request_id` |
79+
| `kb_manage` | `args` | Knowledge management using dsh configuration |
11880

11981
`agent_id` is required in both schemas: the schema cannot tell the model whether this deployment pins a default, and discovering a missing default at call time wastes a round-trip. The configured default is still honoured for programmatic calls that omit it.
12082

@@ -157,3 +119,5 @@ Bug reports, feature requests, and PRs are welcome. See [CONTRIBUTING.md](https:
157119
## License
158120

159121
[Apache 2.0](LICENSE)
122+
123+
The former shared `DASHSCOPE_API_KEY` is no longer read, modified, or deleted. If the plugin-specific key is absent and bl has no default to import, save a key on each plugin’s page.

0 commit comments

Comments
 (0)