dsh-brain/docs/configuration.md

66 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 安装与配置
> 从安装到登录取令牌、全部配置字段与环境变量。
---
## 安装
```powershell
# 装进当前 profile(默认 desktop)
dsh plugin --profile desktop add dsh-brain
```
装好后确认 profile 的 `package.json` 里有两处:
```jsonc
{
"dependencies": { "dsh-brain": "^0.8.0" },
"dsh": { "profile": { "bundles": [ /* ..., */ "dsh-cloud-memory" ] } }
}
```
重启 DSH,在「设置 → 插件 → 云端记忆」里配置(备用入口:`http://127.0.0.1:<当次端口>/cloud-memory`)。
> `baseUrl` 默认是占位符 `https://your-memory-host/api/longmemory`。**首次使用必须先把它改成你自己的 LongMemory 服务地址**(配置页里填,或写进 `$DSH_HOME/cloud-memory.json`),否则上报与工具都会连接失败。
## 登录(推荐)
在设置卡里填云端面板的**普通用户**账号和密码,点「登录并获取令牌」:
```
密码 → POST /api/auth/login(一次性会话 cookie)
→ POST /api/auth/tokens ×2(activity:write、memory:write)
→ 只把两个 cmt_… 令牌写进 $DSH_HOME/cloud-memory.json
→ 密码与会话 cookie 立即丢弃
```
- 密码只在这一串请求里存在:不落盘、不写日志、不随 `/cloud-memory/status` 回显。
- 服务端只保存令牌哈希,令牌可单独撤销;改密码不影响已签发令牌。
- 服务地址不是 HTTPS(且不是 loopback)时插件拒绝发送密码。
- 管理员账号不能签发个人令牌(服务端 `403 management_only`),请用普通用户。
- 也可跳过登录,直接手填两个令牌(见下)。
## 配置
配置文件 `$DSH_HOME/cloud-memory.json`(默认 `%USERPROFILE%\.dsh\cloud-memory.json`),字段:
| 字段 | 默认 | 说明 |
| --- | --- | --- |
| `enabled` | `true` | 关闭后不上报、工具直接报错。 |
| `baseUrl` | `https://your-memory-host/api/longmemory` | 服务基址,自动去掉结尾斜杠。 |
| `clientId` | `dsh-desktop` | 上报时的 `client_id`。 |
| `requestTimeoutMs` | `8000` | 单次请求超时,1000–60000。 |
| `defaultK` | `10` | `memory_search` 未指定 `k` 时的条数。 |
| `activityToken` | — | `activity:write` 令牌,形如 `cmt_…`。 |
| `memoryToken` | — | `memory:read` / `memory:write` 令牌,形如 `cmt_…`。 |
| `skillsSyncEnabled` | `true` | 云端技能中心与本机技能目录的双向同步开关。 |
| `skillsDir` | 空 | 本机技能目录覆盖;为空时用 `$DSH_HOME/skills`。 |
两个令牌也可以用环境变量 `DSH_CLOUD_MEMORY_ACTIVITY_TOKEN`、`DSH_CLOUD_MEMORY_MEMORY_TOKEN` 覆盖。
> 一个 key 只有一种 scope,所以需要两个令牌:只做上报就只填活动令牌,只做检索就只填记忆令牌。