@mochi-fish/fish-bridge 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +272 -2
- package/README_en.md +275 -0
- package/THIRD-PARTY-NOTICES +529 -0
- package/dist/fish-bridge.mjs +14877 -0
- package/index.mjs +3 -0
- package/package.json +61 -4
- package/ui/README.md +62 -0
- package/ui/client.js +294 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mochi-fish contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,273 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @mochi-fish/fish-bridge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**简体中文** | [English](./README_en.md)
|
|
4
|
+
|
|
5
|
+
陪伴体「大肥鱼」用的 DSH 插件:把她在各处收到的话送进**同一条会话**,给每条话标上是谁说的,在她用工具之前替门把一道关,把她说的话按原样发回去,并且在请求发给模型之前做几处必要的改写。
|
|
6
|
+
|
|
7
|
+
[fish-sessionless](https://github.com/mochi-fish/fish-sessionless) 的其它包(身份配置、证据账、受众判定、门的插件)单独装都拼不成能聊天的系统,缺的就是这一块。
|
|
8
|
+
|
|
9
|
+
> **状态:早期(0.1.x)。** 接口、配置和状态文件的格式都还会变,没有版本承诺。
|
|
10
|
+
|
|
11
|
+
## 它做什么
|
|
12
|
+
|
|
13
|
+
| 模块 | 一句话 | 缺省 |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| [会话与路由](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/routing.md) | 所有渠道的话进她一条会话;标作者;防抖;请求期改写 | 开 |
|
|
16
|
+
| [群](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/groups.md) | 群里的近况、戳一戳、引用里的图、每个群的开关、撤回、群信箱 | 开(群信箱关) |
|
|
17
|
+
| [QQ 适配](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/qq.md) | 表情包发真图、收图、`im_send` 的几种发法、`qq` 操作工具、QQ 空间 | 开(QQ 空间关) |
|
|
18
|
+
| [和 dsh-fish 配合](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/with-dsh-fish.md) | 身份段和叫醒段改实话、主动找主人、夜里那一轮、卡片、便条 | 大部分开 |
|
|
19
|
+
| [门与证据账](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/gate-and-ledger.md) | 证据账、门的桥这一侧、路径门、网址先解析再判、撤回墓碑、heard | 开,门缺省 `enforce` |
|
|
20
|
+
| [记忆指路](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/memory-pointers.md) | `qq_history`、旧话去哪翻、相对日期、时间目录、答前递旧话 | 部分开 |
|
|
21
|
+
| [可选活动](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/activities.md) | 我的世界、杀戮尖塔 2、VRChat、豆包画图 | 关 |
|
|
22
|
+
| [可选感官](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/senses.md) | 眼耳嘴、屏幕操作、梗百科 | 关 |
|
|
23
|
+
| [帮手](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/helper.md) | 电脑上的活交给单独的帮手会话 | 关 |
|
|
24
|
+
| [教学与面板](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/teach-panel.md) | 她的话先给主人看,审批面板 | 关 |
|
|
25
|
+
| [回复器与拆句](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/replier-and-split.md) | 群聊改写(她要才过)、一段话拆成几条发 | 回复器关,拆句开 |
|
|
26
|
+
| [运维开关](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/operations.md) | 状态目录、状态文件、开关文件、停用 | — |
|
|
27
|
+
|
|
28
|
+
## 要什么
|
|
29
|
+
|
|
30
|
+
- Node.js 22 或更新。
|
|
31
|
+
- DSH 0.2.3-alpha.2 起、0.3 以前(`package.json` 的 `engines.dsh`;网页接口的鉴权写法要这一版起的宿主)。
|
|
32
|
+
- [dsh-fish](https://github.com/mochi-fish/dsh-fish) 1.0 或更新:她本体。桥认它的段名、叫醒行、工具说明,读它的几份内部模块。
|
|
33
|
+
- [dsh-onebot-qq](https://github.com/mario841859784/dsh-onebot) 0.10.0 或更新:要接 QQ 就要它,还有一个 OneBot v11 的实现。桥要靠它给每条 QQ 消息套的信封(`<user_message …>`)分出说话的人自己的字。它的平常话格式(`promptStyle: 'plain'`)要 0.11.1 起,桥两种格式都认。
|
|
34
|
+
- 共用身份配置(`@mochi-fish/config` 的 schema 2):告诉桥主人是谁。没有也能起,只是没有主人(见下面「没配置时」)。
|
|
35
|
+
- 门的主判在另一个 DSH 插件 [`@mochi-fish/fish-ledger`](https://github.com/mochi-fish/fish-sessionless/tree/main/packages/fish-ledger);桥是同一张表的兜底。两样都装。
|
|
36
|
+
|
|
37
|
+
可选的(每样对应一个缺省关的功能):dsh-meme、dsh-memewiki、dsh-doubao-painter、nowledge-mem-deepseek-harness、dsh-computer-use-win、dsh-watch-together、dsh-bili-humanism、压缩代理([trillion-context](https://github.com/mochi-fish/trillion-context),billion-context 的陪伴向 fork;原版 billion-context 也能用)。VRChat 还要另外装身体和动作服务器(见下面「身体要另外装」),门要 `@mochi-fish/audience` ≥ 1.4.4。
|
|
38
|
+
|
|
39
|
+
## 装
|
|
40
|
+
|
|
41
|
+
DSH 停着的时候做。
|
|
42
|
+
|
|
43
|
+
1. 装包:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
dsh plugin --profile desktop add @mochi-fish/fish-bridge
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
2. 在 profile 的 `cordis.patch.yml` 里手加一行 insert(这个包**不会**自己加:桥会改她会话的系统提示、每次请求的历史和发出去的消息,装上就生效太重):
|
|
50
|
+
|
|
51
|
+
```yaml
|
|
52
|
+
- insert:
|
|
53
|
+
- id: fish-bridge
|
|
54
|
+
name: '@mochi-fish/fish-bridge'
|
|
55
|
+
config:
|
|
56
|
+
identityFile: '~/.config/fish/identity.json'
|
|
57
|
+
# stateDir: '~/.dsh/fish-bridge'
|
|
58
|
+
# fishHome: '~/.dsh-fish/home'
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
审批面板在同一个包里(`exports` 的 `./client`),这一行就带上了,不用另加。
|
|
62
|
+
|
|
63
|
+
3. 写身份配置(下一节),起 DSH。
|
|
64
|
+
|
|
65
|
+
4. 看它起来了没有:状态目录里有 `local-bridge.status.json`,启动时间是刚才(见下面「看它跑没跑」)。
|
|
66
|
+
|
|
67
|
+
插件之间的加载顺序不能声明。桥对 dsh-fish、dsh-onebot-qq 这些都是晚绑定:用到时才去找,找不到那一样功能就不开,`status` 里记一笔。
|
|
68
|
+
|
|
69
|
+
### 身体要另外装(只有 VRChat 用得上)
|
|
70
|
+
|
|
71
|
+
fish-bridge 不带「身体」,也不带动作服务器。要让大肥鱼在 VRChat 里动起来,要另外装两样:
|
|
72
|
+
|
|
73
|
+
1. **动作服务器**:按文字生成动作的服务,走 WebSocket,缺省 `ws://127.0.0.1:8765`。可以自己先开着,也可以在配置的 `motionServer.start` / `stop` 里写怎么开、怎么关;桥只关自己开的那个。桥不连它,只看它的端口开没开。
|
|
74
|
+
2. **身体**:一个单独的进程,连动作服务器,把生成的动作和头顶的字用 OSC 发给 VRChat(`oscIn`,缺省 9000)。
|
|
75
|
+
|
|
76
|
+
把起身体的命令写进 `<DSH_HOME>/vrchat/config.json` 的 `body`(一串字,第一个是程序;别的键见[可选活动 · VRChat](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/activities.md#vrchatvrc))。没写 `body`,`join` 会拒绝并说缺的是这一项。
|
|
77
|
+
|
|
78
|
+
桥起身体时,在 `body` 后面追加这几个参数:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
<body…> --server <motionServer.url> --osc-port <oscIn> --listen-port 0 --loco 0|1 [--allow-9000]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`oscIn` 是 9000 时才带 `--allow-9000`。`--listen-port 0` 的意思是不听 VRChat 发回来的 OSC,免得抢掉主人别的 OSC 工具的包。环境变量里多一个 `PYTHONIOENCODING=utf-8`。
|
|
85
|
+
|
|
86
|
+
桥和身体之间用 stdin / stdout 通信,一行一个 JSON;身体的 stderr 追加进 `<DSH_HOME>/vrchat/body.log`。
|
|
87
|
+
|
|
88
|
+
桥 → 身体(`op`):
|
|
89
|
+
|
|
90
|
+
- `{"op":"do","motion":"waves with the right hand","once":false,"seconds":0}`:做一个动作。`once` 做一次,`seconds` 做几秒(0.5–600);`once` 是 false、`seconds` 是 0 时一直做,直到下一个 op。
|
|
91
|
+
- `{"op":"steps","steps":["…","…"],"seconds_each":4}`:2–8 句按顺序做。她没给秒数时没有 `seconds_each`。
|
|
92
|
+
- `{"op":"stop"}`:回到站着,身体还由这里驱动。
|
|
93
|
+
- `{"op":"free"}`:交还给游戏:停下生成,`/avatar/parameters/FBT/Enable` 关掉,移动输入归零。
|
|
94
|
+
- `{"op":"chatbox","id":1,"text":"…","gap":3.5}`:头顶聊天框。`id` 递增;`text` 桥已经拆好(144 个 UTF-16 单位、9 行以内);发完等 `gap` 秒(2–15)再发下一条。
|
|
95
|
+
- `{"op":"typing","on":true}`:头顶的「正在输入」。
|
|
96
|
+
- `{"op":"quit"}`:交还身体,回一句 `bye`,然后退出。3 秒还没退,桥就结束这个进程、自己交还。
|
|
97
|
+
|
|
98
|
+
身体 → 桥(`ev`),桥认这几样:
|
|
99
|
+
|
|
100
|
+
- `{"ev":"ready"}`:起来了。没报过 `ready` 就退出的,桥算起不来,不接了。
|
|
101
|
+
- `{"ev":"server","up":true|false}`:和动作服务器连没连上。`do` 要它是 true。
|
|
102
|
+
- `{"ev":"doing",…}`:现在在做什么。字段有 `motion`、`once`、`seconds`、`steps`、`stopped`;交还时是 `free:true`,交还的原因放在 `reason`(`server`:动作服务器断了;`stall`:动作服务器几秒没动静)。
|
|
103
|
+
- `{"ev":"error","message":"…"}`:只记进 `status.vrc.lastError`,不转给她。
|
|
104
|
+
- `{"ev":"bye"}`:交还完了,要退了。
|
|
105
|
+
|
|
106
|
+
别的 `ev` 和不是 JSON 的行,桥不管。
|
|
107
|
+
|
|
108
|
+
身体自己要守的:
|
|
109
|
+
|
|
110
|
+
- stdin 断了(桥没了)就交还身体、退出。
|
|
111
|
+
- 有自己的看门狗:动作没有新帧时把移动输入归零,再久一点就交还给游戏。
|
|
112
|
+
|
|
113
|
+
桥这边也兜底:
|
|
114
|
+
|
|
115
|
+
- 身体没说 `bye` 就没了,桥自己往 `127.0.0.1:<oscIn>` 发 UDP:`FBT/Enable` 关、移动和转向输入归零、「正在输入」关。
|
|
116
|
+
- 起来过的身体退了就重起;一分钟里退了两次就不接了。
|
|
117
|
+
|
|
118
|
+
参考实现另外发布:[mochi-fish/vrc-body](https://github.com/mochi-fish/vrc-body)(AGPL-3.0-only)。
|
|
119
|
+
|
|
120
|
+
## 配置
|
|
121
|
+
|
|
122
|
+
分三层:
|
|
123
|
+
|
|
124
|
+
| 层 | 在哪 | 管什么 | 改了什么时候生效 |
|
|
125
|
+
|---|---|---|---|
|
|
126
|
+
| 插件配置 | `cordis.patch.yml` 那一行的 `config` | 三个键:`identityFile`、`stateDir`、`fishHome` | 重启 DSH |
|
|
127
|
+
| 身份配置 | `identityFile` 指的文件(不写就看环境变量 `FISH_IDENTITY_FILE`) | 主人是谁、她是谁、哪些功能**能**开 | 重启 DSH |
|
|
128
|
+
| 开关文件 | 状态目录里 | 哪些功能**现在**开着 | 大多每次现读 |
|
|
129
|
+
|
|
130
|
+
**身份配置里的功能开关决定「能不能开」,开关文件决定「现在开没开」。** 功能开关关着时,开关文件写什么都不算。
|
|
131
|
+
|
|
132
|
+
### 插件配置
|
|
133
|
+
|
|
134
|
+
| 键 | 缺省 | 说明 |
|
|
135
|
+
|---|---|---|
|
|
136
|
+
| `identityFile` | 环境变量 `FISH_IDENTITY_FILE`;都没有 = 没有主人 | 身份配置文件 |
|
|
137
|
+
| `stateDir` | `<DSH_HOME>/fish-bridge` | 状态目录。不能在任何 `node_modules` 下面,否则桥不起 |
|
|
138
|
+
| `fishHome` | 照 dsh-fish 的缺省 | 她的家目录 |
|
|
139
|
+
|
|
140
|
+
### 身份配置(schema 2)
|
|
141
|
+
|
|
142
|
+
格式以 [`packages/config/SCHEMA.md`](https://github.com/mochi-fish/fish-sessionless/blob/main/packages/config/SCHEMA.md) 为准。schema 1 的老文件照读(当作没有 `bridge` 段)。下面的号都是编的:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"schema": 2,
|
|
147
|
+
"owner": { "displayName": "主人", "ids": { "qq": ["10001"] } },
|
|
148
|
+
"companion": { "name": "大肥鱼", "ids": { "qq": ["20000"] } },
|
|
149
|
+
"ledgerRoot": "~/.dsh-fish-ledger",
|
|
150
|
+
"bridge": {
|
|
151
|
+
"profile": "desktop",
|
|
152
|
+
"ownerLabel": { "fallback": "主人" },
|
|
153
|
+
"groups": { "example": "30000" },
|
|
154
|
+
"privacy": { "blockBridgeDir": true },
|
|
155
|
+
"privateDirs": ["~/recorder-archive"],
|
|
156
|
+
"features": { "helper": false, "teach": false }
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`bridge` 段的键:
|
|
162
|
+
|
|
163
|
+
| 键 | 说明 |
|
|
164
|
+
|---|---|
|
|
165
|
+
| `profile` | DSH 的 profile 名;不写照 `--profile`、`DSH_PROFILE`、`desktop` 的顺序 |
|
|
166
|
+
| `ownerLabel.fallback` | 她还没认出怎么叫主人时用的叫法,缺省「主人」 |
|
|
167
|
+
| `ownerLabel.fullName` | 审批面板上「X 觉得这样表达更好」那一句里的名字 |
|
|
168
|
+
| `ownerLabel.marks`、`ownerLabel.shownLike` | 群里有人冒充主人记号时要认的写法 |
|
|
169
|
+
| `groups.nameTrigger` | 「有人提到她」的正则串,最多 400 字 |
|
|
170
|
+
| `groups.example` | 工具说明里举例用的群号(`qq:group:<号>`);不写用一个编的号 |
|
|
171
|
+
| `groups.allow` | 群号的数组。**桥不按它挡群**,只用来核对 `example`:写了 `allow`,`example` 就得是其中一个。哪些群收、哪些不收,在 dsh-onebot-qq 那边配 |
|
|
172
|
+
| `helper.model` | 帮手用的模型(`provider`、`model`);不写不换 |
|
|
173
|
+
| `replier` | 回复器的 `name`、`nicknames`、`persona`、`baseUrl`;没有 `baseUrl` = 回复器不开 |
|
|
174
|
+
| `privacy.blockBridgeDir` | 状态目录进她的路径门,缺省 `true` |
|
|
175
|
+
| `privateDirs` | 另外不让她的文件工具碰的目录(绝对路径或 `~/` 开头) |
|
|
176
|
+
| `memSyncedUntil` | `"YYYY-MM-DD"`:Mem 里的对话原文存到哪天为止,身份段的 Mem 那句照它写;不写就不带日期 |
|
|
177
|
+
| `features.*` | 功能开关,全部缺省 `false`(下面) |
|
|
178
|
+
|
|
179
|
+
`bridge` 段只认上面这些键,多写一个(哪怕是拼错)整份身份配置就算不对,按没有主人处理。
|
|
180
|
+
|
|
181
|
+
主人的号:QQ 上只认**正好一个**,多于一个按没有主人。身份配置的 `proactiveChats` 桥不看:主动找人只找主人的 QQ 私聊(见[和 dsh-fish 配合](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/with-dsh-fish.md#主动找主人夜里那一轮))。
|
|
182
|
+
|
|
183
|
+
### 功能开关(全部缺省关)
|
|
184
|
+
|
|
185
|
+
| 键 | 管什么 |
|
|
186
|
+
|---|---|
|
|
187
|
+
| `helper` | 帮手会话和 `helper` 工具 |
|
|
188
|
+
| `sts` / `mc` / `vrc` / `doubao` | 杀戮尖塔 2 / 我的世界 / VRChat / 豆包画图 |
|
|
189
|
+
| `watch` / `wincu` | 眼耳嘴 / 屏幕操作插件的工具给不给她 |
|
|
190
|
+
| `memewikiTrim` | 梗百科的结果去掉插件自带的规则 |
|
|
191
|
+
| `teach` | 教学模式和审批面板 |
|
|
192
|
+
| `replier` | 回复器 |
|
|
193
|
+
| `qzoneRead` / `qzoneWrite` | QQ 空间读 / 写 |
|
|
194
|
+
| `bilingual` | `im_send` 要两种语言的写法 |
|
|
195
|
+
| `biliHumanismOnly` | B 站只走 bili-humanism |
|
|
196
|
+
| `wakeWords` | 叫醒时最后那段她自己能改 |
|
|
197
|
+
| `changeLog` / `life` | 系统提示里指向她家目录「改动记录」「以前的日子」的话 |
|
|
198
|
+
| `heMark` | 旧群记录里主人记号的老写法说明 |
|
|
199
|
+
| `memNarrow` | Mem 的工具只对她收窄 |
|
|
200
|
+
| `shadowCompare` | 按受众拼请求的影子比对 |
|
|
201
|
+
| `modelPin` | 开机钉住她会话的模型 |
|
|
202
|
+
| `desk` | 维护助手的渠道 |
|
|
203
|
+
| `dnsLimit` | 判网址时的域名解析限流:同时最多问 3 个名字、同一个名字合并着问,A / AAAA 有一种答得慢时不干等 |
|
|
204
|
+
| `memeProbe` | 每 10 分钟自查一次收表情包时读本机图的那一层还在不在,结果在 `status.memeFetch` |
|
|
205
|
+
| `knowFirstDrop` | 身份段「你认识的…」里去掉「第一次说话」那一行 |
|
|
206
|
+
|
|
207
|
+
关着的功能:不注册工具、不起定时器、不挂接口,对应的工具名在她那边也藏起来([ADR 0010](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/adr/0010-companion-features-off-and-hidden.md))。`dnsLimit`、`memeProbe`、`knowFirstDrop` 不是她专属的功能,是部署上的取舍,不涉及工具。每样开之前先读它那一页的「为什么缺省关」。
|
|
208
|
+
|
|
209
|
+
### 开关文件
|
|
210
|
+
|
|
211
|
+
在状态目录里,每个文件管什么、什么时候生效,见[运维开关](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/operations.md#开关文件)。写坏了一律按关或者缺省值。
|
|
212
|
+
|
|
213
|
+
## 没配置时
|
|
214
|
+
|
|
215
|
+
身份配置没写、读不到或者读坏了,桥照样起,按最严的那一边:
|
|
216
|
+
|
|
217
|
+
| 项 | 行为 |
|
|
218
|
+
|---|---|
|
|
219
|
+
| 主人 | 没有。QQ 上的来话一律按别人的话算 |
|
|
220
|
+
| dsh-onebot-qq 的 `adminUsers` | 单靠它不算主人(见下面「安全模型」);没有主人时一律按别人的话算 |
|
|
221
|
+
| 桌面上直接打字 | 算主人(DSH 自己认过这是 owner) |
|
|
222
|
+
| 功能开关 | 全关,工具名藏起来 |
|
|
223
|
+
| 门 | `enforce` |
|
|
224
|
+
| 证据账 | 缺省的根在就写;不在就不写,门照判 |
|
|
225
|
+
| 主动找主人、heard、卡片转 QQ、主人来过 | 没有主人,永不触发 |
|
|
226
|
+
| 防抖 | 开,10 秒 / 60 秒 |
|
|
227
|
+
| 群信箱、时间目录、答前递旧话、相对日期注记 | 关 |
|
|
228
|
+
| 状态目录 | `<DSH_HOME>/fish-bridge`,在她的路径门里 |
|
|
229
|
+
|
|
230
|
+
## 看它跑没跑
|
|
231
|
+
|
|
232
|
+
- 状态目录的 `local-bridge.status.json`:启动时间、各功能的状态和计数,只有计数和词,没有聊天原文。有事件时才落盘。
|
|
233
|
+
- 身份配置读得怎么样也在里面:`status.identity.file` 是 `ok`,或者读不了的原因(`no-file`、`not-json`、`invalid`、`no-owner`、`owner-qq` 等);`status.identity.features` 列出开着的功能开关。
|
|
234
|
+
- **DSH 的兼容检查会悄悄跳过插件。** DSH 的版本不在这个包声明的范围里,整个插件不加载,桌面版不报错。看出来的办法:重启 DSH 以后 `local-bridge.status.json` 的启动时间没变,她手上没有 `im_send`。这时先对一下 DSH 的版本和这个包 `package.json` 里的 `engines`。
|
|
235
|
+
|
|
236
|
+
## 安全模型
|
|
237
|
+
|
|
238
|
+
一句话:**不确定是谁的话,就按别人的话算;不确定能不能给,就不给。**
|
|
239
|
+
|
|
240
|
+
- **作者记号**:每条送进她会话的话都标上是主人的、别人的、还是带着别人话的主人消息。门、帮手、眼耳嘴、游戏里的身体都照它判。
|
|
241
|
+
- **QQ 上怎么认主人**:dsh-onebot-qq 把发话人列在 `adminUsers` 里还不够。主人的 QQ 私聊算主人的;别处(群里、别的私聊),这条消息里每一段信封、每一段平常话抬头上的 QQ 号都得是身份配置里的主人号,有一段不是(比如按群合并投递时混进了群友的话)、或者一段都认不出,就按别人的话算。被这样改判的次数在 `status.groups.adminNotOwner`。
|
|
242
|
+
- **门**:群和来客那几轮挡能翻旧事、碰本机的工具。开关读不到按 `enforce`;放行表缺省只有 `acp_status`。主判在 fish-ledger,桥兜底。
|
|
243
|
+
- **证据账**:只记指针、编号和带盐的哈希,不记原文,放在她的工具碰不到的地方。
|
|
244
|
+
- **路径门**:她的文件工具碰不到证据账、桥的状态目录、身份副本和 `privateDirs`。
|
|
245
|
+
- **网址先解析再判**:取网页、收表情包只放公网主机。
|
|
246
|
+
- **撤回墓碑**:撤回的话之后谁都看不到,墓碑只增不减。
|
|
247
|
+
- **专属功能缺省关、工具名一起藏**。
|
|
248
|
+
|
|
249
|
+
逐项的做法和局限见[门与证据账](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/gate-and-ledger.md)、[受众和工具的门](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/audience-gate.md)、[已知局限](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/known-limitations.md)。安全问题请按 [SECURITY.md](https://github.com/mochi-fish/fish-sessionless/blob/main/SECURITY.md) 私下报告。
|
|
250
|
+
|
|
251
|
+
**状态目录里有聊天原文**(群近况、防抖攒着的、教学队列等)。她碰不到,这台电脑上别的程序读得到;备份和同步时当聊天记录对待。
|
|
252
|
+
|
|
253
|
+
## 升级上游插件之前
|
|
254
|
+
|
|
255
|
+
桥逐字认 dsh-fish、dsh-onebot-qq、dsh-meme、dsh-memewiki、dsh-doubao-painter 的一些原文。上游改一个字,桥那一处就静悄悄地不生效。升它们之前,拿解开的新包跑一遍仓库里的 `packages/fish-bridge/tools/anchor-check.mjs`(参数见它开头的说明),退 0 再升。这个工具在仓库里,不在 npm 包里。
|
|
256
|
+
|
|
257
|
+
## 停用
|
|
258
|
+
|
|
259
|
+
1. 先把状态目录里的 `local-bridge.debounce.json` 写成 `{"ms":0}`,等攒着的话送完;开着教学模式的,先在面板里关掉。
|
|
260
|
+
2. 停 DSH,删掉 `cordis.patch.yml` 里 `id: fish-bridge` 那一行,再起。
|
|
261
|
+
3. 状态目录和证据账不会被删。写进 dsh-fish 事件流的 heard 删不掉。
|
|
262
|
+
|
|
263
|
+
## 测试
|
|
264
|
+
|
|
265
|
+
测试在仓库里(`packages/fish-bridge/test/`),不进 npm 包。在 `packages/fish-bridge` 下 `npm run build` 再 `npm test`:测的是拼好的 `dist/fish-bridge.mjs`,每个测试文件一个子进程,入口自己带上 `FISH_BRIDGE_TEST=1`,`DSH_HOME`、`DSH_FISH_HOME`、身份配置都指到系统临时目录里新建的目录,跑完删掉。自己另写测试也照这个来。**不要把在用的状态目录交给测试**:测试会删、会改状态目录里的文件。
|
|
266
|
+
|
|
267
|
+
## 许可
|
|
268
|
+
|
|
269
|
+
MIT,见 [LICENSE](./LICENSE)。
|
|
270
|
+
|
|
271
|
+
桥逐字认的上游原文(dsh-fish、dsh-onebot-qq、dsh-meme、dsh-memewiki、dsh-doubao-painter、nowledge-mem-deepseek-harness、dsh-computer-use-win、DSH)和回复器照抄的 mai_replier 模型卡,出处和许可全文见 [THIRD-PARTY-NOTICES](./THIRD-PARTY-NOTICES)。「一段话分几条发」的思路来自 [MaiBot](https://github.com/MaiM-with-u/MaiBot),代码是自己写的。
|
|
272
|
+
|
|
273
|
+
本项目与 DeepSeek、DSH 官方没有关系。
|
package/README_en.md
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
# @mochi-fish/fish-bridge
|
|
2
|
+
|
|
3
|
+
[简体中文](./README.md) | **English**
|
|
4
|
+
|
|
5
|
+
A DSH plugin for the companion agent "Dafeiyu" (大肥鱼, "the big fat fish"). It routes everything she receives, from every channel, into **one session**; marks who said each message; acts as a second gate before she uses a tool; sends her words back out as she wrote them; and makes a few necessary rewrites to each request before it reaches the model.
|
|
6
|
+
|
|
7
|
+
The other packages in [fish-sessionless](https://github.com/mochi-fish/fish-sessionless) (identity config, evidence ledger, audience rules, the gate plugin) do not add up to a working chat system on their own. This is the missing piece.
|
|
8
|
+
|
|
9
|
+
> **Status: early (0.1.x).** Interfaces, configuration and state file formats will change. No compatibility promises yet.
|
|
10
|
+
|
|
11
|
+
The Chinese documentation is the canonical version; module pages are linked below.
|
|
12
|
+
|
|
13
|
+
## What it does
|
|
14
|
+
|
|
15
|
+
| Module | In one line | Default |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| [Sessions and routing](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/routing.md) | All channels into one session; author marks; inbound debounce; request-time rewrites | on |
|
|
18
|
+
| [Groups](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/groups.md) | Recent group lines, pokes, images inside quotes, per-group switch, recalls, group inbox | on (inbox off) |
|
|
19
|
+
| [QQ adapters](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/qq.md) | Real images for stickers, receiving images, `im_send` variants, the `qq` operations tool, QQ Zone | on (QQ Zone off) |
|
|
20
|
+
| [Working with dsh-fish](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/with-dsh-fish.md) | Truthful identity and wake sections, reaching out to the owner, the night turn, cards, notes | mostly on |
|
|
21
|
+
| [Gate and ledger](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/gate-and-ledger.md) | Evidence ledger, the bridge side of the gate, path gate, resolve-then-judge URLs, recall tombstones, heard | on, gate defaults to `enforce` |
|
|
22
|
+
| [Memory pointers](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/memory-pointers.md) | `qq_history`, where old words live, relative date notes, time directory, offering old lines before she answers | partly on |
|
|
23
|
+
| [Optional activities](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/activities.md) | Minecraft, Slay the Spire 2, VRChat, Doubao painting | off |
|
|
24
|
+
| [Optional senses](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/senses.md) | Eyes / ears / mouth, screen automation, meme wiki | off |
|
|
25
|
+
| [Helper](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/helper.md) | Computer chores go to a separate helper session | off |
|
|
26
|
+
| [Teaching and panel](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/teach-panel.md) | Her messages are shown to the owner first; approval panel | off |
|
|
27
|
+
| [Replier and splitting](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/replier-and-split.md) | Group-chat rewording (only when she asks); one paragraph sent as several messages | replier off, splitting on |
|
|
28
|
+
| [Operations](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/operations.md) | State directory, state files, switch files, uninstalling | — |
|
|
29
|
+
|
|
30
|
+
## Requirements
|
|
31
|
+
|
|
32
|
+
- Node.js 22 or newer.
|
|
33
|
+
- DSH from 0.2.3-alpha.2 up to, but not including, 0.3 (`engines.dsh` in `package.json`; the web API authentication used by the panel needs it).
|
|
34
|
+
- [dsh-fish](https://github.com/mochi-fish/dsh-fish) 1.0 or newer: the companion itself. The bridge recognizes its section names, wake lines and tool descriptions and reads a few of its internal modules.
|
|
35
|
+
- [dsh-onebot-qq](https://github.com/mario841859784/dsh-onebot) 0.10.0 or later, plus a OneBot v11 implementation, if you want QQ. The bridge relies on the envelope it puts around every QQ message (`<user_message …>`) to tell the speaker's own words apart. Its plain prompt style (`promptStyle: 'plain'`) needs 0.11.1 or later; the bridge understands both formats.
|
|
36
|
+
- The shared identity config (`@mochi-fish/config`, schema 2), which tells the bridge who the owner is. The bridge starts without it, but then there is no owner (see "Without configuration").
|
|
37
|
+
- The gate's main judge lives in another DSH plugin, [`@mochi-fish/fish-ledger`](https://github.com/mochi-fish/fish-sessionless/tree/main/packages/fish-ledger); the bridge is the fallback for the same table. Install both.
|
|
38
|
+
|
|
39
|
+
Optional, each behind a feature switch that is off by default: dsh-meme, dsh-memewiki, dsh-doubao-painter, nowledge-mem-deepseek-harness, dsh-computer-use-win, dsh-watch-together, dsh-bili-humanism, and a context compression proxy ([trillion-context](https://github.com/mochi-fish/trillion-context), the companion-oriented fork of billion-context; the original billion-context works too). VRChat additionally needs a separately installed body and motion server (see "The body is installed separately" below), and the gate needs `@mochi-fish/audience` 1.4.4 or later.
|
|
40
|
+
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
Do this while DSH is stopped.
|
|
44
|
+
|
|
45
|
+
1. Install the package:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
dsh plugin --profile desktop add @mochi-fish/fish-bridge
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
2. Add one insert line to the profile's `cordis.patch.yml` by hand. The package does **not** add it for you: the bridge changes her system prompt, the history in every request and the messages she sends, which is too much to switch on silently at install time.
|
|
52
|
+
|
|
53
|
+
```yaml
|
|
54
|
+
- insert:
|
|
55
|
+
- id: fish-bridge
|
|
56
|
+
name: '@mochi-fish/fish-bridge'
|
|
57
|
+
config:
|
|
58
|
+
identityFile: '~/.config/fish/identity.json'
|
|
59
|
+
# stateDir: '~/.dsh/fish-bridge'
|
|
60
|
+
# fishHome: '~/.dsh-fish/home'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The approval panel ships in the same package (`exports["./client"]`), so this one line covers it.
|
|
64
|
+
|
|
65
|
+
3. Write the identity config (next section) and start DSH.
|
|
66
|
+
|
|
67
|
+
4. Check that it started: `local-bridge.status.json` in the state directory shows a fresh start time (see "Is it running").
|
|
68
|
+
|
|
69
|
+
Plugin load order cannot be declared. The bridge binds late to dsh-fish, dsh-onebot-qq and the others: it looks them up when first needed, and if one is missing, only that feature stays off and `status` records it.
|
|
70
|
+
|
|
71
|
+
### The body is installed separately (VRChat only)
|
|
72
|
+
|
|
73
|
+
fish-bridge ships neither the "body" nor a motion server. To let Dafeiyu move in VRChat you install two more things:
|
|
74
|
+
|
|
75
|
+
1. **Motion server**: a service that generates motion from text, over WebSocket, default `ws://127.0.0.1:8765`. Either keep it running yourself, or put how to start and stop it in the config's `motionServer.start` / `stop`; the bridge only stops a server it started. The bridge does not connect to it; it only checks whether its port is open.
|
|
76
|
+
2. **Body**: a separate process that connects to the motion server and sends the generated motion and the overhead text to VRChat over OSC (`oscIn`, default 9000).
|
|
77
|
+
|
|
78
|
+
Put the command that starts the body in `body` in `<DSH_HOME>/vrchat/config.json` (an array of strings, the first one is the program; for the other keys see [Optional activities · VRChat](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/activities.md#vrchatvrc), in Chinese). Without `body`, `join` refuses and names the missing key.
|
|
79
|
+
|
|
80
|
+
The bridge starts the body by appending these arguments to `body`:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
<body…> --server <motionServer.url> --osc-port <oscIn> --listen-port 0 --loco 0|1 [--allow-9000]
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`--allow-9000` is added only when `oscIn` is 9000. `--listen-port 0` means: do not listen for the OSC that VRChat sends back, so the body does not steal packets from the owner's other OSC tools. The environment gets one extra variable, `PYTHONIOENCODING=utf-8`.
|
|
87
|
+
|
|
88
|
+
The bridge and the body talk over stdin / stdout, one JSON object per line; the body's stderr is appended to `<DSH_HOME>/vrchat/body.log`.
|
|
89
|
+
|
|
90
|
+
Bridge → body (`op`):
|
|
91
|
+
|
|
92
|
+
- `{"op":"do","motion":"waves with the right hand","once":false,"seconds":0}`: do one motion. `once` does it once, `seconds` does it for that many seconds (0.5–600); with `once` false and `seconds` 0 it keeps going until the next op.
|
|
93
|
+
- `{"op":"steps","steps":["…","…"],"seconds_each":4}`: do 2–8 motions in order. `seconds_each` is absent when she gave no duration.
|
|
94
|
+
- `{"op":"stop"}`: go back to standing; the body is still driven from here.
|
|
95
|
+
- `{"op":"free"}`: hand control back to the game: stop generating, turn `/avatar/parameters/FBT/Enable` off, zero the movement inputs.
|
|
96
|
+
- `{"op":"chatbox","id":1,"text":"…","gap":3.5}`: the overhead chatbox. `id` increases; the bridge has already split `text` (at most 144 UTF-16 units and 9 lines); wait `gap` seconds (2–15) after sending before the next one.
|
|
97
|
+
- `{"op":"typing","on":true}`: the overhead "typing" indicator.
|
|
98
|
+
- `{"op":"quit"}`: hand control back, answer `bye`, then exit. If the process has not exited after 3 seconds, the bridge ends it and hands control back itself.
|
|
99
|
+
|
|
100
|
+
Body → bridge (`ev`); the bridge reads these:
|
|
101
|
+
|
|
102
|
+
- `{"ev":"ready"}`: started. If the body exits without ever sending `ready`, the bridge treats it as failing to start and stops.
|
|
103
|
+
- `{"ev":"server","up":true|false}`: whether it is connected to the motion server. `do` needs this to be true.
|
|
104
|
+
- `{"ev":"doing",…}`: what it is doing now. Fields: `motion`, `once`, `seconds`, `steps`, `stopped`; on handing back it sends `free:true` with the reason in `reason` (`server`: the motion server dropped; `stall`: the motion server went silent for a few seconds).
|
|
105
|
+
- `{"ev":"error","message":"…"}`: recorded in `status.vrc.lastError` only, never passed to her.
|
|
106
|
+
- `{"ev":"bye"}`: control handed back, about to exit.
|
|
107
|
+
|
|
108
|
+
Other `ev` values and lines that are not JSON are ignored.
|
|
109
|
+
|
|
110
|
+
What the body must do itself:
|
|
111
|
+
|
|
112
|
+
- When stdin closes (the bridge is gone), hand control back and exit.
|
|
113
|
+
- Run its own watchdog: when the motion has no new frames, zero the movement inputs, and a little later hand control back to the game.
|
|
114
|
+
|
|
115
|
+
What the bridge does as a fallback:
|
|
116
|
+
|
|
117
|
+
- If the body disappears without sending `bye`, the bridge sends UDP to `127.0.0.1:<oscIn>` itself: `FBT/Enable` off, movement and turning inputs zeroed, "typing" off.
|
|
118
|
+
- A body that had started and then exits is restarted; if it exits twice within one minute, the bridge stops.
|
|
119
|
+
|
|
120
|
+
Reference implementation, published separately: [mochi-fish/vrc-body](https://github.com/mochi-fish/vrc-body) (AGPL-3.0-only).
|
|
121
|
+
|
|
122
|
+
## Configuration
|
|
123
|
+
|
|
124
|
+
Three layers:
|
|
125
|
+
|
|
126
|
+
| Layer | Where | What it controls | Takes effect |
|
|
127
|
+
|---|---|---|---|
|
|
128
|
+
| Plugin config | `config` on the insert line | Three keys: `identityFile`, `stateDir`, `fishHome` | DSH restart |
|
|
129
|
+
| Identity config | The file `identityFile` points to (else env `FISH_IDENTITY_FILE`) | Who the owner is, who she is, which features **may** be enabled | DSH restart |
|
|
130
|
+
| Switch files | In the state directory | Which features are on **right now** | Most are re-read on every use |
|
|
131
|
+
|
|
132
|
+
**Feature switches in the identity config decide whether a feature may be on; switch files decide whether it is on now.** While a feature switch is off, nothing in its switch file counts.
|
|
133
|
+
|
|
134
|
+
### Plugin config
|
|
135
|
+
|
|
136
|
+
| Key | Default | Notes |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| `identityFile` | env `FISH_IDENTITY_FILE`; neither = no owner | Identity config file |
|
|
139
|
+
| `stateDir` | `<DSH_HOME>/fish-bridge` | State directory. Must not be under any `node_modules`, or the bridge refuses to start |
|
|
140
|
+
| `fishHome` | dsh-fish's default | Her home directory |
|
|
141
|
+
|
|
142
|
+
### Identity config (schema 2)
|
|
143
|
+
|
|
144
|
+
[`packages/config/SCHEMA.md`](https://github.com/mochi-fish/fish-sessionless/blob/main/packages/config/SCHEMA.md) is authoritative. Old schema 1 files are still read (as if there were no `bridge` section). All numbers below are made up:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"schema": 2,
|
|
149
|
+
"owner": { "displayName": "主人", "ids": { "qq": ["10001"] } },
|
|
150
|
+
"companion": { "name": "大肥鱼", "ids": { "qq": ["20000"] } },
|
|
151
|
+
"ledgerRoot": "~/.dsh-fish-ledger",
|
|
152
|
+
"bridge": {
|
|
153
|
+
"profile": "desktop",
|
|
154
|
+
"ownerLabel": { "fallback": "主人" },
|
|
155
|
+
"groups": { "example": "30000" },
|
|
156
|
+
"privacy": { "blockBridgeDir": true },
|
|
157
|
+
"privateDirs": ["~/recorder-archive"],
|
|
158
|
+
"features": { "helper": false, "teach": false }
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Keys in the `bridge` section:
|
|
164
|
+
|
|
165
|
+
| Key | Notes |
|
|
166
|
+
|---|---|
|
|
167
|
+
| `profile` | DSH profile name; if absent: `--profile`, then `DSH_PROFILE`, then `desktop` |
|
|
168
|
+
| `ownerLabel.fallback` | What she calls the owner before she has worked out a name; default 「主人」 ("owner") |
|
|
169
|
+
| `ownerLabel.fullName` | The name used on the approval panel ("X thinks this would read better") |
|
|
170
|
+
| `ownerLabel.marks`, `ownerLabel.shownLike` | Forms to recognize when someone in a group imitates the owner's mark |
|
|
171
|
+
| `groups.nameTrigger` | Regex source for "someone mentioned her", at most 400 characters |
|
|
172
|
+
| `groups.example` | Group number used as the example in tool descriptions (`qq:group:<number>`); a made-up number if absent |
|
|
173
|
+
| `groups.allow` | Array of group numbers. **The bridge does not filter groups by it**; it is only used to check `example`: if `allow` is given, `example` must be one of them. Which groups are received is configured in dsh-onebot-qq |
|
|
174
|
+
| `helper.model` | Model for the helper (`provider`, `model`); absent = unchanged |
|
|
175
|
+
| `replier` | Replier `name`, `nicknames`, `persona`, `baseUrl`; no `baseUrl` = replier off |
|
|
176
|
+
| `privacy.blockBridgeDir` | Put the state directory behind her path gate; default `true` |
|
|
177
|
+
| `privateDirs` | Extra directories her file tools must not touch (absolute, or starting with `~/`) |
|
|
178
|
+
| `memSyncedUntil` | `"YYYY-MM-DD"`: the last day whose conversations are stored in Mem; the Mem sentence in her identity section uses it. Absent = no date |
|
|
179
|
+
| `features.*` | Feature switches, all `false` by default (below) |
|
|
180
|
+
|
|
181
|
+
The `bridge` section accepts only the keys above. One extra key (a typo included) makes the whole identity config invalid, which means no owner.
|
|
182
|
+
|
|
183
|
+
On QQ the owner must have **exactly one** number; more than one means no owner. The bridge does not read `proactiveChats` from the identity config: reaching out only ever goes to the owner's QQ private chat (see [Working with dsh-fish](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/with-dsh-fish.md#主动找主人夜里那一轮), Chinese).
|
|
184
|
+
|
|
185
|
+
### Feature switches (all off by default)
|
|
186
|
+
|
|
187
|
+
| Key | Controls |
|
|
188
|
+
|---|---|
|
|
189
|
+
| `helper` | Helper session and the `helper` tool |
|
|
190
|
+
| `sts` / `mc` / `vrc` / `doubao` | Slay the Spire 2 / Minecraft / VRChat / Doubao painting |
|
|
191
|
+
| `watch` / `wincu` | Eyes, ears, mouth / whether she gets the screen automation plugin's tools |
|
|
192
|
+
| `memewikiTrim` | Strip the meme wiki plugin's built-in rules from results |
|
|
193
|
+
| `teach` | Teaching mode and the approval panel |
|
|
194
|
+
| `replier` | Replier |
|
|
195
|
+
| `qzoneRead` / `qzoneWrite` | QQ Zone read / write |
|
|
196
|
+
| `bilingual` | `im_send` takes the message in two languages |
|
|
197
|
+
| `biliHumanismOnly` | Bilibili only through bili-humanism |
|
|
198
|
+
| `wakeWords` | She can edit the last part of her wake messages |
|
|
199
|
+
| `changeLog` / `life` | Pointers in the system prompt to her "change log" and "earlier days" files |
|
|
200
|
+
| `heMark` | Note on the old form of the owner mark in old group logs |
|
|
201
|
+
| `memNarrow` | Narrow the Mem tools for her |
|
|
202
|
+
| `shadowCompare` | Shadow comparison for per-audience request assembly |
|
|
203
|
+
| `modelPin` | Pin her session's model at startup |
|
|
204
|
+
| `desk` | Maintainer channel |
|
|
205
|
+
| `dnsLimit` | Rate-limit DNS lookups when judging URLs: at most 3 names in flight, identical lookups merged, no waiting on a slow A or AAAA answer |
|
|
206
|
+
| `memeProbe` | Every 10 minutes, check that the layer which reads local images for sticker saving is still in place; result in `status.memeFetch` |
|
|
207
|
+
| `knowFirstDrop` | Drop the "first time we talked" line from the "people you know" part of her identity section |
|
|
208
|
+
|
|
209
|
+
A feature that is off registers no tools, starts no timers and mounts no routes, and its tool names are hidden from her as well ([ADR 0010](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/adr/0010-companion-features-off-and-hidden.md)). `dnsLimit`, `memeProbe` and `knowFirstDrop` are not companion-specific; they are deployment trade-offs and involve no tools. Read the "why it is off by default" part of a feature's page before turning it on.
|
|
210
|
+
|
|
211
|
+
### Switch files
|
|
212
|
+
|
|
213
|
+
See [Operations](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/operations.md) for each file and when it takes effect. A malformed switch file always counts as off or as the default value.
|
|
214
|
+
|
|
215
|
+
## Without configuration
|
|
216
|
+
|
|
217
|
+
If the identity config is missing, unreadable or invalid, the bridge still starts, on the strict side:
|
|
218
|
+
|
|
219
|
+
| Item | Behaviour |
|
|
220
|
+
|---|---|
|
|
221
|
+
| Owner | None. Every incoming QQ message counts as someone else's |
|
|
222
|
+
| dsh-onebot-qq `adminUsers` | Not enough on its own (see "Security model" below); with no owner, everything counts as someone else's |
|
|
223
|
+
| Typing directly in the desktop app | Counts as the owner (DSH has already authenticated the owner) |
|
|
224
|
+
| Feature switches | All off, tool names hidden |
|
|
225
|
+
| Gate | `enforce` |
|
|
226
|
+
| Evidence ledger | Written if the default root exists; otherwise not written, the gate still judges |
|
|
227
|
+
| Reaching out, heard, card relay, "owner was here" | Never, since there is no owner |
|
|
228
|
+
| Debounce | On, 10 s / 60 s |
|
|
229
|
+
| Group inbox, time directory, offering old lines, relative date notes | Off |
|
|
230
|
+
| State directory | `<DSH_HOME>/fish-bridge`, behind her path gate |
|
|
231
|
+
|
|
232
|
+
## Is it running
|
|
233
|
+
|
|
234
|
+
- `local-bridge.status.json` in the state directory: start time, per-feature state and counters. Counts and words only, never chat text. Written when something happens.
|
|
235
|
+
- It also shows how the identity config was read: `status.identity.file` is `ok`, or the reason it could not be used (`no-file`, `not-json`, `invalid`, `no-owner`, `owner-qq`, and so on); `status.identity.features` lists the feature switches that are on.
|
|
236
|
+
- **DSH's compatibility check skips plugins silently.** If the DSH version is outside the range this package declares, the whole plugin is not loaded and the desktop app reports nothing. You can tell because after a DSH restart the start time in `local-bridge.status.json` has not changed and she has no `im_send`. Compare the DSH version with `engines` in this package's `package.json`.
|
|
237
|
+
|
|
238
|
+
## Security model
|
|
239
|
+
|
|
240
|
+
In one line: **if we cannot tell whose words these are, treat them as someone else's; if we cannot tell whether something may be shown, do not show it.**
|
|
241
|
+
|
|
242
|
+
- **Author marks**: every message entering her session is marked as the owner's, someone else's, or the owner's message carrying someone else's words. The gate, the helper, eyes/ears/mouth and her body in games all decide from this.
|
|
243
|
+
- **Recognizing the owner on QQ**: being listed in dsh-onebot-qq's `adminUsers` is not enough. The owner's QQ private chat counts as the owner's; anywhere else (groups, other private chats) every envelope and every plain-format header in the message must carry the owner number from the identity config. If one segment carries another number (for example when queued group messages are merged and someone else's line is folded in), or no segment can be recognized at all, the message counts as someone else's. Each such downgrade is counted in `status.groups.adminNotOwner`.
|
|
244
|
+
- **Gate**: in group and guest turns, tools that can dig up old conversations or reach this computer are blocked. An unreadable switch means `enforce`; the allow list contains only `acp_status` by default. fish-ledger is the main judge; the bridge is the fallback.
|
|
245
|
+
- **Evidence ledger**: pointers, ids and salted hashes only, never text, stored where her tools cannot reach.
|
|
246
|
+
- **Path gate**: her file tools cannot touch the ledger, the bridge state directory, her identity copy or `privateDirs`.
|
|
247
|
+
- **Resolve, then judge URLs**: fetching pages and saving stickers only go to public hosts.
|
|
248
|
+
- **Recall tombstones**: recalled messages disappear from every view she gets; tombstones only accumulate.
|
|
249
|
+
- **Companion-specific features off by default, tool names hidden.**
|
|
250
|
+
|
|
251
|
+
Details and limits: [Gate and ledger](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/bridge/gate-and-ledger.md), [Audience gate](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/audience-gate.md), [Known limitations](https://github.com/mochi-fish/fish-sessionless/blob/main/docs/zh/known-limitations.md) (Chinese). Report security issues privately as described in [SECURITY.md](https://github.com/mochi-fish/fish-sessionless/blob/main/SECURITY.md).
|
|
252
|
+
|
|
253
|
+
**The state directory contains chat text** (recent group lines, debounced messages, the teaching queue, and so on). She cannot reach it; other programs on this computer can. Treat backups and syncs of it as chat logs.
|
|
254
|
+
|
|
255
|
+
## Before upgrading upstream plugins
|
|
256
|
+
|
|
257
|
+
The bridge recognizes some text from dsh-fish, dsh-onebot-qq, dsh-meme, dsh-memewiki and dsh-doubao-painter verbatim. If upstream changes a single character, that part of the bridge silently stops working. Before upgrading them, run `packages/fish-bridge/tools/anchor-check.mjs` from the repository against the unpacked new package (arguments are described at the top of the file) and upgrade only when it exits 0. The tool lives in the repository, not in the npm package.
|
|
258
|
+
|
|
259
|
+
## Uninstalling
|
|
260
|
+
|
|
261
|
+
1. Write `{"ms":0}` into `local-bridge.debounce.json` in the state directory and wait until held messages are delivered. If teaching mode is on, switch it off in the panel first.
|
|
262
|
+
2. Stop DSH, remove the `id: fish-bridge` insert line from `cordis.patch.yml`, start DSH again.
|
|
263
|
+
3. The state directory and the ledger are not deleted. heard entries written into dsh-fish's event stream cannot be removed.
|
|
264
|
+
|
|
265
|
+
## Tests
|
|
266
|
+
|
|
267
|
+
Tests live in the repository (`packages/fish-bridge/test/`) and are not in the npm package. In `packages/fish-bridge`, run `npm run build`, then `npm test`: the tests exercise the built `dist/fish-bridge.mjs`, one child process per test file; the runner sets `FISH_BRIDGE_TEST=1` itself and points `DSH_HOME`, `DSH_FISH_HOME` and the identity config at fresh directories under the system temp directory, removed afterwards. Do the same if you write your own tests. **Never hand a state directory that is in use to the tests**: they delete and rewrite files in it.
|
|
268
|
+
|
|
269
|
+
## License
|
|
270
|
+
|
|
271
|
+
MIT, see [LICENSE](./LICENSE).
|
|
272
|
+
|
|
273
|
+
For the upstream text the bridge recognizes verbatim (dsh-fish, dsh-onebot-qq, dsh-meme, dsh-memewiki, dsh-doubao-painter, nowledge-mem-deepseek-harness, dsh-computer-use-win, DSH) and the parts of the mai_replier model card copied for the replier, see [THIRD-PARTY-NOTICES](./THIRD-PARTY-NOTICES) for sources and full license texts. The idea of sending one paragraph as several messages comes from [MaiBot](https://github.com/MaiM-with-u/MaiBot); the code is our own.
|
|
274
|
+
|
|
275
|
+
This project is not affiliated with DeepSeek or the DSH project.
|