@michengai/dsh-im-connect 1.0.28 → 1.0.30
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/CHANGELOG.md +18 -0
- package/CHANGELOG.zh-CN.md +18 -0
- package/README.en.md +52 -0
- package/README.md +52 -0
- package/README.zh-CN.md +52 -0
- package/client.js +130 -5
- package/lib/channels/factory.d.ts.map +1 -1
- package/lib/channels/factory.js +13 -2
- package/lib/channels/factory.js.map +1 -1
- package/lib/channels/mention-policy.d.ts +29 -0
- package/lib/channels/mention-policy.d.ts.map +1 -0
- package/lib/channels/mention-policy.js +84 -0
- package/lib/channels/mention-policy.js.map +1 -0
- package/lib/channels/telegram.d.ts +5 -0
- package/lib/channels/telegram.d.ts.map +1 -1
- package/lib/channels/telegram.js +150 -8
- package/lib/channels/telegram.js.map +1 -1
- package/lib/channels/thinking-block.d.ts +35 -0
- package/lib/channels/thinking-block.d.ts.map +1 -0
- package/lib/channels/thinking-block.js +59 -0
- package/lib/channels/thinking-block.js.map +1 -0
- package/lib/client.js +130 -5
- package/lib/engine/command-messages.d.ts +2 -0
- package/lib/engine/command-messages.d.ts.map +1 -1
- package/lib/engine/command-messages.js +2 -0
- package/lib/engine/command-messages.js.map +1 -1
- package/lib/engine/gateway.d.ts +1 -0
- package/lib/engine/gateway.d.ts.map +1 -1
- package/lib/engine/gateway.js +59 -9
- package/lib/engine/gateway.js.map +1 -1
- package/lib/engine/thinking-display.d.ts +41 -0
- package/lib/engine/thinking-display.d.ts.map +1 -0
- package/lib/engine/thinking-display.js +190 -0
- package/lib/engine/thinking-display.js.map +1 -0
- package/lib/engine/types.d.ts +39 -0
- package/lib/engine/types.d.ts.map +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -1
- package/lib/manager.d.ts +3 -0
- package/lib/manager.d.ts.map +1 -1
- package/lib/manager.js +47 -1
- package/lib/manager.js.map +1 -1
- package/package.json +1 -1
- package/src/channels/factory.ts +14 -2
- package/src/channels/mention-policy.ts +95 -0
- package/src/channels/telegram.ts +152 -8
- package/src/channels/thinking-block.ts +88 -0
- package/src/engine/command-messages.ts +2 -0
- package/src/engine/gateway.ts +52 -8
- package/src/engine/thinking-display.ts +202 -0
- package/src/engine/types.ts +40 -0
- package/src/index.ts +9 -0
- package/src/manager.ts +47 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
|
|
3
|
+
## [1.0.30] - 2026-11-08
|
|
4
|
+
|
|
5
|
+
### Telegram collapsible thinking message & visual settings
|
|
6
|
+
|
|
7
|
+
- Collapsible thinking messages in Telegram: support sending the model's reasoning chain as a native collapsible quote block (`<blockquote expandable>`), allowing chat participants to tap and expand the thought process (#63).
|
|
8
|
+
- Visual dropdown setting: add a native "Show thinking process" dropdown (Off / Collapsed) in **Settings → IM Assistant → Telegram Account**, allowing quick per-account toggling or falling back to plugin defaults.
|
|
9
|
+
- Harmonized form layout: place the thinking process setting next to "Idle session rotation" in a balanced two-column grid with an inline privacy and display guidance tooltip.
|
|
10
|
+
|
|
11
|
+
## [1.0.29] - 2026-11-08
|
|
12
|
+
|
|
13
|
+
### Telegram group mention policy & visual configuration
|
|
14
|
+
|
|
15
|
+
- Telegram group mention policy: support choosing group chat trigger policy in account settings — "Mention or reply only (default)", "Always reply to all group messages", and "Free chat in specific groups only" (#62).
|
|
16
|
+
- Visual configuration for group whitelist: when choosing specific groups, enter group IDs directly in the visual settings panel. Draft inputs are retained when toggling between policies to prevent accidental input loss.
|
|
17
|
+
- Smart group ID parsing and link tolerance: support pasting Telegram Web group URLs directly (e.g. `web.telegram.org` and private links `t.me/c/...`), automatically normalize Unicode full-width minus signs, dashes, and topic suffixes, and provide real-time validation warnings for unrecognized entries.
|
|
18
|
+
- Group ID discovery guide: add clear instructions in README for discovering Telegram group IDs via browser address bar or query bots.
|
|
19
|
+
|
|
2
20
|
## [1.0.28] - 2026-11-06
|
|
3
21
|
|
|
4
22
|
### Telegram delivery reliability
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
# 更新日志
|
|
2
|
+
|
|
3
|
+
## [1.0.30] - 2026-11-08
|
|
4
|
+
|
|
5
|
+
### Telegram 思考过程可折叠展示与设置选项
|
|
6
|
+
|
|
7
|
+
- Telegram 思考过程折叠消息:支持将模型的深度思考内容通过 Telegram 原生可折叠引用块(`<blockquote expandable>`)单独发送,群聊或私聊中点击即可展开查看思维链(#63)。
|
|
8
|
+
- 可视化设置下拉选项:在「设置 → IM助理 → Telegram 账号」中提供「展示思考过程」原生下拉选项(关闭 / 折叠展示),支持账号级一键切换或跟随全局配置。
|
|
9
|
+
- 表单布局与体验优化:将思考过程选项排布在「空闲新开会话」右侧,两列网格整齐对称;右上角配备说明图标,解释折叠消息展示边界与群聊隐私指引。
|
|
10
|
+
|
|
11
|
+
## [1.0.29] - 2026-11-08
|
|
12
|
+
|
|
13
|
+
### Telegram 群聊免 @ 触发策略与可视化设置
|
|
14
|
+
|
|
15
|
+
- Telegram 群聊支持选择触发策略:可在账号设置中选择「仅 @提及 或回复时响应(默认)」、「所有群消息均响应」或「仅指定群免 @ 响应」(#62)。
|
|
16
|
+
- 支持可视化配置免 @ 群白名单:选择指定群模式时,可直接在设置界面填写群号列表;切换模式时自动保留已填写的群号草稿,避免重复输入。
|
|
17
|
+
- 群 ID 智能识别与链接容错:群名单支持直接粘贴 Telegram 网页版群聊链接(如 `web.telegram.org` 或私有群链接 `t.me/c/...`),自动兼容手机端复制的全角负号、破折号及话题后缀,并在输入无法识别的内容时展示即时格式警告。
|
|
18
|
+
- 完善群 ID 获取指引:在文档中补充了通过 Telegram 网页端地址栏、官方查询机器人获取群 ID 的详细步骤。
|
|
19
|
+
|
|
2
20
|
## [1.0.28] - 2026-11-06
|
|
3
21
|
|
|
4
22
|
### Telegram 投递可靠性
|
package/README.en.md
CHANGED
|
@@ -271,6 +271,58 @@ Native configuration options are provided here. Their values are persisted in `c
|
|
|
271
271
|
- **Channels Tab Preserved**: Filtering applies only to the official workspace tree. All channel sessions remain fully available and accessible at any time under the sidebar's **Channels** tab;
|
|
272
272
|
- **Lightweight Pipeline Collaboration**: Implemented via the `NativeTabRegistry.sessionFilters` inter-plugin protocol without invasive host hijacking. Toggling takes effect immediately and interoperates smoothly with Automation and Archive Manager. Non-supporting host shells degrade gracefully with a one-time warning.
|
|
273
273
|
|
|
274
|
+
### 4. Telegram group trigger policy (`mentionPolicy` / `freeChatGroups`)
|
|
275
|
+
- **Default**: `addressed` — in groups the bot only reacts to an @mention, a reply to it, or a direct message.
|
|
276
|
+
- **What it does**: to let a group chat with the bot without @mentioning it, configure the trigger policy directly in **Settings → IM Assistant → Telegram Account Details**, or in `channels.json`:
|
|
277
|
+
- **Scenario A (specific groups only)**: configure `freeChatGroups` only; other groups keep default:
|
|
278
|
+
```json
|
|
279
|
+
{
|
|
280
|
+
"channels": {
|
|
281
|
+
"<account id>": {
|
|
282
|
+
"config": {
|
|
283
|
+
"freeChatGroups": "-1001234567890, -5496760438"
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
- **Scenario B (all groups)**: configure `mentionPolicy` as `always` (no need to configure `freeChatGroups` in this mode):
|
|
290
|
+
```json
|
|
291
|
+
{
|
|
292
|
+
"channels": {
|
|
293
|
+
"<account id>": {
|
|
294
|
+
"config": {
|
|
295
|
+
"mentionPolicy": "always"
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
- Both only decide whether a message reaches the agent — direct-message admission, tool approvals and command permissions are unchanged.
|
|
302
|
+
- **Platform prerequisite**: with Telegram privacy mode the bot only receives mentions, replies and commands. Make the bot a group administrator, or run `setprivacy` → `Disable` in @BotFather, so plain group messages reach the plugin.
|
|
303
|
+
- **UI**: configure visually by expanding Telegram account details in **Settings → IM Assistant** with policy select and group ID inputs.
|
|
304
|
+
- **How to find Group IDs**:
|
|
305
|
+
- **Option 1 (Recommended)**: Open Telegram Web in your browser, enter the group, and copy the address bar URL (e.g. `https://web.telegram.org/a/#-1001234567890` or private group link `https://t.me/c/1234567890`). You can paste it directly into the input field;
|
|
306
|
+
- **Option 2**: Send any message in the group, forward it to a query bot (such as `@userinfobot`), and copy the chat `Id` (starts with a minus sign);
|
|
307
|
+
- **Option 3**: Call `https://api.telegram.org/bot<TOKEN>/getUpdates` directly in your browser and check `"chat":{"id": -100xxxxxxxxxx}`.
|
|
308
|
+
|
|
309
|
+
### 5. Collapsible thinking message (`thinkingDisplay`)
|
|
310
|
+
- **Default**: off (`mode: 'off'`).
|
|
311
|
+
- **What it does**: when enabled, the model's reasoning is sent as a separate Telegram collapsible quote (`<blockquote expandable>`) — about three lines collapsed, tap "show more" to expand. The same message is edited in place during the turn and retitled "🧠 Thought process" when the turn ends.
|
|
312
|
+
- **Example** (plugin config slot):
|
|
313
|
+
```yaml
|
|
314
|
+
thinkingDisplay:
|
|
315
|
+
mode: collapsed # off | collapsed
|
|
316
|
+
minChars: 120 # only send once this many characters accumulated
|
|
317
|
+
intervalMs: 2000 # minimum interval between refreshes
|
|
318
|
+
maxChars: 3500 # per-message cap; longer text is truncated and noted
|
|
319
|
+
```
|
|
320
|
+
- **Channel and UI support**: implemented for Telegram; can be enabled in **Settings → IM Assistant → Telegram Account** by selecting **Collapsed** in the **Show thinking process** dropdown. Other channels ignore the setting and keep the existing status line.
|
|
321
|
+
- **Boundaries and privacy**: collapsing is client-side display, not access control; everyone who can read the group message can expand the reasoning. Enable only where sharing reasoning is intentional. Thinking is not counted as final-answer delivery or included in automatic recovery.
|
|
322
|
+
- **Resources and lifecycle**: off/unsupported channels retain no raw reasoning. When enabled, each turn retains at most a 4096 UTF-16-unit prefix plus a scalar character count. Pending refreshes coalesce to the latest snapshot; cancellation, rebinding, muting, unloading and turn replacement prevent stale output.
|
|
323
|
+
- **Ranges**: `minChars` 0–4096 (also applied on final), `intervalMs` 1000–60000, `maxChars` 200–4096. Finite out-of-range values are clamped, nonfinite values use defaults. HTML escaping, labels, wrappers and truncation notes all fit the budget without splitting emoji surrogate pairs.
|
|
324
|
+
- **Fallback**: only a definite HTML entity rejection switches to plain text, which persists for later edits in that turn. Unknown network outcomes, authentication failures and rate limits do not trigger a format-switch resend.
|
|
325
|
+
|
|
274
326
|
## Usage
|
|
275
327
|
|
|
276
328
|
Open **Settings → IM Assistant**, select **Add account** under the target channel, then choose that account's workspace, model, permission, private-access mode, and send mode. To register a new workspace, click **Add workspace…** in the dropdown footer to invoke the system folder picker (manual path inputs are disallowed); hosts lacking native folder pickers show "This Host cannot create workspaces" (upgrade to one of the supported host releases listed in Requirements, or add via the host sidebar).
|
package/README.md
CHANGED
|
@@ -271,6 +271,58 @@ dsh --profile web --dump-config
|
|
|
271
271
|
- **频道面板不受影响**:关闭仅作用于主任务树,在侧栏「频道」页签中依然完整保留并可随时点开、回复和复盘全部渠道会话;
|
|
272
272
|
- **轻量管道协同**:基于 `NativeTabRegistry.sessionFilters` 标准协作协议实现,无需深度劫持宿主组件,切换即时生效,与定时插件及归档管理等第三方插件完全兼容。未支持该协议的外壳会自动安全降级并提示。
|
|
273
273
|
|
|
274
|
+
### 4. Telegram 群聊触发策略 (`mentionPolicy` / `freeChatGroups`)
|
|
275
|
+
- **默认状态**:`addressed`(群里只有 @bot、回复 bot 或私聊才会处理)
|
|
276
|
+
- **功能说明**:群聊希望「不 @ 也能直接聊」时,可直接在「设置 → IM助理 → Telegram 账号详情」中配置群聊触发策略,亦可在 `channels.json` 中配置:
|
|
277
|
+
- **场景 A(仅特定群免 @)**:仅配置 `freeChatGroups`,未列出的群保持默认:
|
|
278
|
+
```json
|
|
279
|
+
{
|
|
280
|
+
"channels": {
|
|
281
|
+
"<账号 id>": {
|
|
282
|
+
"config": {
|
|
283
|
+
"freeChatGroups": "-1001234567890, -5496760438"
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
- **场景 B(所有群均免 @)**:配置 `mentionPolicy` 为 `always`(此模式下无需配置 `freeChatGroups`):
|
|
290
|
+
```json
|
|
291
|
+
{
|
|
292
|
+
"channels": {
|
|
293
|
+
"<账号 id>": {
|
|
294
|
+
"config": {
|
|
295
|
+
"mentionPolicy": "always"
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
- 这两项只影响「这条消息要不要送进 agent」,不改变私聊准入、工具审批与命令权限。
|
|
302
|
+
- **平台侧前提**:Telegram 隐私模式下 bot 只能收到提及、回复与命令。要让普通群消息到达插件,需把 bot 设为该群管理员,或在 @BotFather 里 `setprivacy` → `Disable`。
|
|
303
|
+
- **界面支持**:可在「设置 → IM助理」展开 Telegram 账号详情,直接通过下拉选择与群号输入框进行可视化配置。
|
|
304
|
+
- **如何获取群 ID**:
|
|
305
|
+
- **方法 1(推荐)**:在电脑浏览器打开 Telegram Web 网页版进入群聊,直接复制地址栏 URL(如 `https://web.telegram.org/a/#-1001234567890`,或私有群链接 `https://t.me/c/1234567890`),可直接粘贴至输入框自动解析;
|
|
306
|
+
- **方法 2**:在群里随便发一条消息,转发给官方查询机器人(如 `@userinfobot`),复制其回复中 `Forwarded from chat` 的 `Id` 数字(以负号开头);
|
|
307
|
+
- **方法 3**:通过 Bot 原生接口查询 `https://api.telegram.org/bot<TOKEN>/getUpdates`,找到 `"chat":{"id": -100xxxxxxxxxx}`。
|
|
308
|
+
|
|
309
|
+
### 5. 思考过程折叠消息 (`thinkingDisplay`)
|
|
310
|
+
- **默认状态**:关闭(`mode: 'off'`)
|
|
311
|
+
- **功能说明**:开启后,模型的思考过程会单独发成一条 Telegram「可折叠引用块」消息(`<blockquote expandable>`),默认只显示约三行,点「显示更多」展开;同一回合就地编辑,回合结束时标题变为「🧠 思考过程」。
|
|
312
|
+
- **配置示例**(插件配置槽位):
|
|
313
|
+
```yaml
|
|
314
|
+
thinkingDisplay:
|
|
315
|
+
mode: collapsed # off | collapsed
|
|
316
|
+
minChars: 120 # 累计到这个字数才发第一条
|
|
317
|
+
intervalMs: 2000 # 两次刷新的最小间隔
|
|
318
|
+
maxChars: 3500 # 单条上限,超出截断并注明
|
|
319
|
+
```
|
|
320
|
+
- **渠道与界面支持**:目前由 Telegram 实现,可在「设置 → IM助理 → Telegram 账号」中通过「展示思考过程」下拉选择「折叠展示」一键开启;其他渠道会忽略该配置,只保留原有状态行。
|
|
321
|
+
- **边界与隐私**:折叠是客户端展示,不是访问控制,群内所有能看到消息的人均能点击展开思考内容。请只在明确允许公开展示思维链的部署中开启;思考消息不会被算作最终答案的送达或自动补发内容。
|
|
322
|
+
- **资源与生命周期**:关闭或渠道不支持时不缓存思考原文;开启时每回合最多保留 4096 个 UTF-16 单元的前缀和总字数。刷新合并为最新快照,停止、换绑、静音、卸载及下一回合会阻止过期输出。
|
|
323
|
+
- **参数范围**:`minChars` 为 0–4096(结束时同样适用),`intervalMs` 为 1000–60000,`maxChars` 为 200–4096;超界值收敛到范围,非有限数字使用默认值。实际 HTML 转义、标题、标签与截断提示均计入预算,不切开 emoji 代理对。
|
|
324
|
+
- **格式降级**:仅在平台明确拒绝 HTML 实体时切到纯文本,并在该回合后续编辑中保持纯文本;网络结果不明、鉴权失败、限流不会通过换格式重发绕过。
|
|
325
|
+
|
|
274
326
|
## 使用
|
|
275
327
|
|
|
276
328
|
打开「设置 → IM助理」,在目标渠道点击「添加账号」,并为该账号选择工作区、模型、权限、私聊准入和发送方式。若需要新工作区,可展开工作区下拉列表点击底部的「添加工作区…」直接调起系统文件选择器(禁止手输路径);不支持原生目录选择器的宿主会提示「当前 Host 无法新增工作区」,请升级到「环境要求」中列出的受支持宿主版本,或直接在宿主侧栏添加工作区。
|
package/README.zh-CN.md
CHANGED
|
@@ -271,6 +271,58 @@ dsh --profile web --dump-config
|
|
|
271
271
|
- **频道面板不受影响**:关闭仅作用于主任务树,在侧栏「频道」页签中依然完整保留并可随时点开、回复和复盘全部渠道会话;
|
|
272
272
|
- **轻量管道协同**:基于 `NativeTabRegistry.sessionFilters` 标准协作协议实现,无需深度劫持宿主组件,切换即时生效,与定时插件及归档管理等第三方插件完全兼容。未支持该协议的外壳会自动安全降级并提示。
|
|
273
273
|
|
|
274
|
+
### 4. Telegram 群聊触发策略 (`mentionPolicy` / `freeChatGroups`)
|
|
275
|
+
- **默认状态**:`addressed`(群里只有 @bot、回复 bot 或私聊才会处理)
|
|
276
|
+
- **功能说明**:群聊希望「不 @ 也能直接聊」时,可直接在「设置 → IM助理 → Telegram 账号详情」中配置群聊触发策略,亦可在 `channels.json` 中配置:
|
|
277
|
+
- **场景 A(仅特定群免 @)**:仅配置 `freeChatGroups`,未列出的群保持默认:
|
|
278
|
+
```json
|
|
279
|
+
{
|
|
280
|
+
"channels": {
|
|
281
|
+
"<账号 id>": {
|
|
282
|
+
"config": {
|
|
283
|
+
"freeChatGroups": "-1001234567890, -5496760438"
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
- **场景 B(所有群均免 @)**:配置 `mentionPolicy` 为 `always`(此模式下无需配置 `freeChatGroups`):
|
|
290
|
+
```json
|
|
291
|
+
{
|
|
292
|
+
"channels": {
|
|
293
|
+
"<账号 id>": {
|
|
294
|
+
"config": {
|
|
295
|
+
"mentionPolicy": "always"
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
- 这两项只影响「这条消息要不要送进 agent」,不改变私聊准入、工具审批与命令权限。
|
|
302
|
+
- **平台侧前提**:Telegram 隐私模式下 bot 只能收到提及、回复与命令。要让普通群消息到达插件,需把 bot 设为该群管理员,或在 @BotFather 里 `setprivacy` → `Disable`。
|
|
303
|
+
- **界面支持**:可在「设置 → IM助理」展开 Telegram 账号详情,直接通过下拉选择与群号输入框进行可视化配置。
|
|
304
|
+
- **如何获取群 ID**:
|
|
305
|
+
- **方法 1(推荐)**:在电脑浏览器打开 Telegram Web 网页版进入群聊,直接复制地址栏 URL(如 `https://web.telegram.org/a/#-1001234567890`,或私有群链接 `https://t.me/c/1234567890`),可直接粘贴至输入框自动解析;
|
|
306
|
+
- **方法 2**:在群里随便发一条消息,转发给官方查询机器人(如 `@userinfobot`),复制其回复中 `Forwarded from chat` 的 `Id` 数字(以负号开头);
|
|
307
|
+
- **方法 3**:通过 Bot 原生接口查询 `https://api.telegram.org/bot<TOKEN>/getUpdates`,找到 `"chat":{"id": -100xxxxxxxxxx}`。
|
|
308
|
+
|
|
309
|
+
### 5. 思考过程折叠消息 (`thinkingDisplay`)
|
|
310
|
+
- **默认状态**:关闭(`mode: 'off'`)
|
|
311
|
+
- **功能说明**:开启后,模型的思考过程会单独发成一条 Telegram「可折叠引用块」消息(`<blockquote expandable>`),默认只显示约三行,点「显示更多」展开;同一回合就地编辑,回合结束时标题变为「🧠 思考过程」。
|
|
312
|
+
- **配置示例**(插件配置槽位):
|
|
313
|
+
```yaml
|
|
314
|
+
thinkingDisplay:
|
|
315
|
+
mode: collapsed # off | collapsed
|
|
316
|
+
minChars: 120 # 累计到这个字数才发第一条
|
|
317
|
+
intervalMs: 2000 # 两次刷新的最小间隔
|
|
318
|
+
maxChars: 3500 # 单条上限,超出截断并注明
|
|
319
|
+
```
|
|
320
|
+
- **渠道与界面支持**:目前由 Telegram 实现,可在「设置 → IM助理 → Telegram 账号」中通过「展示思考过程」下拉选择「折叠展示」一键开启;其他渠道会忽略该配置,只保留原有状态行。
|
|
321
|
+
- **边界与隐私**:折叠是客户端展示,不是访问控制,群内所有能看到消息的人均能点击展开思考内容。请只在明确允许公开展示思维链的部署中开启;思考消息不会被算作最终答案的送达或自动补发内容。
|
|
322
|
+
- **资源与生命周期**:关闭或渠道不支持时不缓存思考原文;开启时每回合最多保留 4096 个 UTF-16 单元的前缀和总字数。刷新合并为最新快照,停止、换绑、静音、卸载及下一回合会阻止过期输出。
|
|
323
|
+
- **参数范围**:`minChars` 为 0–4096(结束时同样适用),`intervalMs` 为 1000–60000,`maxChars` 为 200–4096;超界值收敛到范围,非有限数字使用默认值。实际 HTML 转义、标题、标签与截断提示均计入预算,不切开 emoji 代理对。
|
|
324
|
+
- **格式降级**:仅在平台明确拒绝 HTML 实体时切到纯文本,并在该回合后续编辑中保持纯文本;网络结果不明、鉴权失败、限流不会通过换格式重发绕过。
|
|
325
|
+
|
|
274
326
|
## 使用
|
|
275
327
|
|
|
276
328
|
打开「设置 → IM助理」,在目标渠道点击「添加账号」,并为该账号选择工作区、模型、权限、私聊准入和发送方式。若需要新工作区,可展开工作区下拉列表点击底部的「添加工作区…」直接调起系统文件选择器(禁止手输路径);不支持原生目录选择器的宿主会提示「当前 Host 无法新增工作区」,请升级到「环境要求」中列出的受支持宿主版本,或直接在宿主侧栏添加工作区。
|
package/client.js
CHANGED
|
@@ -621,7 +621,7 @@ window.__ModuleLoader__.load({
|
|
|
621
621
|
"taskTreeSessions.entry.title": "在任务树显示 IM 会话", "taskTreeSessions.entry.desc": "在官方工作区任务树中显示各渠道会话。关闭后仅在侧栏「频道」页签中显示", "taskTreeSessions.entry.toggle": "切换在任务树显示 IM 会话",
|
|
622
622
|
"settings.aria": "IM助理", "settings.publicChatNotice": "未批准用户可以发起聊天,但不能批准工具调用。", "pending.notice": "有访问请求。批准后该用户才能驱动本机助手。", "action.approve": "批准", "action.deny": "拒绝", "loading": "加载中…",
|
|
623
623
|
"account.presetUnavailable": "预设不可用", "action.settings": "设置", "command.dm": "私聊命令", "command.group": "群聊命令", "command.enabled": "可以执行命令", "command.disabled": "仅正常对话",
|
|
624
|
-
"account.workspace": "工作区", "account.currentWorkspace": "当前工作区", "account.selectWorkspace": "请选择工作区", "account.selectModel": "请选择模型", "account.selectPermission": "请选择权限", "account.privateAccess": "私聊准入", "account.privateApproved": "仅已批准用户", "account.privateAll": "允许所有私聊用户", "account.sendMode": "发送方式", "account.sendQueue": "排队发送", "account.sendSteer": "插话发送", "account.sendSteerNote": "插话发送会把消息作为补充指令立即交给运行中的任务;任务空闲时与排队发送相同。", "account.sessionIdle": "空闲新开会话", "account.sessionIdleOff": "关闭(保持原会话)", "account.sessionIdleMin": "{n} 分钟", "account.sessionIdleHour": "{n} 小时", "account.sessionIdleHours": "{n} 小时", "account.sessionIdleNote": "距上一条消息超过该时间后再收到新消息,将开启新会话;旧会话仍可用 /sessions 找回。设为 0 表示关闭。", "account.segmentReply": "分段回复", "account.segmentFull": "完整发送", "account.segmentSplit": "分段发送", "account.segmentReplyNote": "选择分段发送时助手会把一次回复拆成多条短消息,在分隔标记处切开逐条发送;完整发送时仍是一条完整回复。", "account.segmentGap": "发送间隔", "account.segmentGapMin": "最小间隔", "account.segmentGapMax": "最大间隔", "account.segmentGapInvalid": "请填写 0 到 60 之间的秒数", "account.segmentGapOrder": "上限不能低于下限", "account.seconds": "秒", "account.autoNameNote": "绑定成功后会自动生成账号名,无需手动填写。需要区分使用者时,可在账号行填写备注。", "account.proxyMode": "网络代理", "account.proxyInherit": "跟随宿主", "account.proxyDirect": "直接连接", "account.proxyCustom": "手动配置", "account.proxyUrl": "代理地址", "account.proxyNote": "仅影响当前账号;保存后自动重连生效。", "account.proxySaved": "代理地址已保存;留空保存可保留当前地址。", "account.defaultName": "{channel}账号 {count}",
|
|
624
|
+
"account.workspace": "工作区", "account.currentWorkspace": "当前工作区", "account.selectWorkspace": "请选择工作区", "account.selectModel": "请选择模型", "account.selectPermission": "请选择权限", "account.privateAccess": "私聊准入", "account.privateApproved": "仅已批准用户", "account.privateAll": "允许所有私聊用户", "account.sendMode": "发送方式", "account.sendQueue": "排队发送", "account.sendSteer": "插话发送", "account.sendSteerNote": "插话发送会把消息作为补充指令立即交给运行中的任务;任务空闲时与排队发送相同。", "account.sessionIdle": "空闲新开会话", "account.sessionIdleOff": "关闭(保持原会话)", "account.sessionIdleMin": "{n} 分钟", "account.sessionIdleHour": "{n} 小时", "account.sessionIdleHours": "{n} 小时", "account.sessionIdleNote": "距上一条消息超过该时间后再收到新消息,将开启新会话;旧会话仍可用 /sessions 找回。设为 0 表示关闭。", "account.segmentReply": "分段回复", "account.segmentFull": "完整发送", "account.segmentSplit": "分段发送", "account.segmentReplyNote": "选择分段发送时助手会把一次回复拆成多条短消息,在分隔标记处切开逐条发送;完整发送时仍是一条完整回复。", "account.segmentGap": "发送间隔", "account.segmentGapMin": "最小间隔", "account.segmentGapMax": "最大间隔", "account.segmentGapInvalid": "请填写 0 到 60 之间的秒数", "account.segmentGapOrder": "上限不能低于下限", "account.seconds": "秒", "account.autoNameNote": "绑定成功后会自动生成账号名,无需手动填写。需要区分使用者时,可在账号行填写备注。", "account.proxyMode": "网络代理", "account.proxyInherit": "跟随宿主", "account.proxyDirect": "直接连接", "account.proxyCustom": "手动配置", "account.proxyUrl": "代理地址", "account.proxyNote": "仅影响当前账号;保存后自动重连生效。", "account.proxySaved": "代理地址已保存;留空保存可保留当前地址。", "account.telegramGroupPolicy": "群聊触发策略", "account.telegramGroupPolicyAddressed": "仅 @提及 或回复时响应(默认)", "account.telegramGroupPolicyAlways": "所有群消息均响应", "account.telegramGroupPolicyCustom": "仅指定群免 @ 响应", "account.telegramFreeChatGroups": "免 @ 群号白名单", "account.telegramFreeChatGroupsInvalid": "未检测到有效群 ID。群 ID 通常为负数纯数字(如 -1001234567890),亦可直接粘贴 Telegram 网页版群聊链接。", "account.telegramFreeChatGroupsPartial": "有 {count} 个群号无法识别,将被忽略;请填负数群号(如 -1001234567890)或 Telegram 网页版群聊链接。", "account.telegramGroupPolicyNote": "仅影响当前账号群聊;若需普通消息送达,请将 Bot 设为群管理员或在 @BotFather 中关闭隐私模式(/setprivacy → Disable)。", "account.telegramThinkingDisplay": "展示思考过程", "account.telegramThinkingDisplayOff": "关闭", "account.telegramThinkingDisplayCollapsed": "折叠展示", "account.telegramThinkingDisplayNote": "开启后,模型的思考过程会以可折叠引用块单独发送,点击可展开查看。群聊中所有成员均可展开,请在允许分享思考的部署开启。", "account.defaultName": "{channel}账号 {count}",
|
|
625
625
|
"account.remark": "名称备注", "account.remarkNote": "只在本机设置页区分账号,留空恢复自动名称。", "account.rename": "修改名称备注",
|
|
626
626
|
"account.count": "{count} 个账号", "account.statusProcessing": "处理中…", "account.statusNotConnected": "未连接", "account.receive": "接收消息", "account.receiveDescription": "关闭后保留账号配置,但不接收新消息", "account.removeConfirm": "确定移除这个账号?本机保存的配置和凭据将一并删除。",
|
|
627
627
|
"action.addAccount": "添加账号", "action.generateQr": "生成二维码", "action.checkConnection": "诊断连接", "action.reconnectAccount": "重新连接", "action.removeAccount": "移除接入", "status.saving": "保存中…", "status.saved": "已保存",
|
|
@@ -654,7 +654,7 @@ window.__ModuleLoader__.load({
|
|
|
654
654
|
"taskTreeSessions.entry.title": "Show IM sessions in task tree", "taskTreeSessions.entry.desc": "Show messaging channel sessions in the official workspace task tree. When disabled, sessions are shown only under the 'Channels' tab.", "taskTreeSessions.entry.toggle": "Toggle show IM sessions in task tree",
|
|
655
655
|
"settings.aria": "IM Assistant", "settings.publicChatNotice": "Unapproved users can start chats, but they cannot approve tool calls.", "pending.notice": "There are access requests. Approve a user before they can control the local assistant.", "action.approve": "Approve", "action.deny": "Deny", "loading": "Loading…",
|
|
656
656
|
"account.presetUnavailable": "Preset unavailable", "action.settings": "Settings", "command.dm": "DM commands", "command.group": "Group commands", "command.enabled": "Commands enabled", "command.disabled": "Conversation only",
|
|
657
|
-
"account.workspace": "Workspace", "account.currentWorkspace": "Current workspace", "account.selectWorkspace": "Select a workspace", "account.selectModel": "Select a model", "account.selectPermission": "Select a permission", "account.privateAccess": "Private chat access", "account.privateApproved": "Approved users only", "account.privateAll": "Allow all DM users", "account.sendMode": "Send mode", "account.sendQueue": "Queue", "account.sendSteer": "Steer", "account.sendSteerNote": "Steer hands the message to the running task as additional instructions at its next step; when the task is idle it behaves like Queue.", "account.sessionIdle": "Idle session rotation", "account.sessionIdleOff": "Disabled (keep session)", "account.sessionIdleMin": "{n} min", "account.sessionIdleHour": "{n} hr", "account.sessionIdleHours": "{n} hrs", "account.sessionIdleNote": "Start a new session when the next message arrives after this idle period; previous sessions remain accessible via /sessions. Set to 0 to disable.", "account.segmentReply": "Segmented replies", "account.segmentFull": "Send as whole", "account.segmentSplit": "Send in segments", "account.segmentReplyNote": "When set to Send in segments, the assistant splits one reply into several short messages at the separator and sends them one by one; Send as whole keeps the entire reply in a single message.", "account.segmentGap": "Send gap", "account.segmentGapMin": "Minimum gap", "account.segmentGapMax": "Maximum gap", "account.segmentGapInvalid": "Enter a number of seconds between 0 and 60.", "account.segmentGapOrder": "The maximum gap cannot be lower than the minimum.", "account.seconds": "s", "account.autoNameNote": "The account name is generated automatically after setup. Add a remark on the account row if you need to tell users apart.", "account.proxyMode": "Network proxy", "account.proxyInherit": "Follow Host", "account.proxyDirect": "Connect directly", "account.proxyCustom": "Configure manually", "account.proxyUrl": "Proxy address", "account.proxyNote": "Affects only this account. The channel reconnects automatically after saving.", "account.proxySaved": "A proxy address is saved. Leave the field blank to keep it.", "account.defaultName": "{channel} account {count}",
|
|
657
|
+
"account.workspace": "Workspace", "account.currentWorkspace": "Current workspace", "account.selectWorkspace": "Select a workspace", "account.selectModel": "Select a model", "account.selectPermission": "Select a permission", "account.privateAccess": "Private chat access", "account.privateApproved": "Approved users only", "account.privateAll": "Allow all DM users", "account.sendMode": "Send mode", "account.sendQueue": "Queue", "account.sendSteer": "Steer", "account.sendSteerNote": "Steer hands the message to the running task as additional instructions at its next step; when the task is idle it behaves like Queue.", "account.sessionIdle": "Idle session rotation", "account.sessionIdleOff": "Disabled (keep session)", "account.sessionIdleMin": "{n} min", "account.sessionIdleHour": "{n} hr", "account.sessionIdleHours": "{n} hrs", "account.sessionIdleNote": "Start a new session when the next message arrives after this idle period; previous sessions remain accessible via /sessions. Set to 0 to disable.", "account.segmentReply": "Segmented replies", "account.segmentFull": "Send as whole", "account.segmentSplit": "Send in segments", "account.segmentReplyNote": "When set to Send in segments, the assistant splits one reply into several short messages at the separator and sends them one by one; Send as whole keeps the entire reply in a single message.", "account.segmentGap": "Send gap", "account.segmentGapMin": "Minimum gap", "account.segmentGapMax": "Maximum gap", "account.segmentGapInvalid": "Enter a number of seconds between 0 and 60.", "account.segmentGapOrder": "The maximum gap cannot be lower than the minimum.", "account.seconds": "s", "account.autoNameNote": "The account name is generated automatically after setup. Add a remark on the account row if you need to tell users apart.", "account.proxyMode": "Network proxy", "account.proxyInherit": "Follow Host", "account.proxyDirect": "Connect directly", "account.proxyCustom": "Configure manually", "account.proxyUrl": "Proxy address", "account.proxyNote": "Affects only this account. The channel reconnects automatically after saving.", "account.proxySaved": "A proxy address is saved. Leave the field blank to keep it.", "account.telegramGroupPolicy": "Group trigger policy", "account.telegramGroupPolicyAddressed": "Only on @mention or reply (Default)", "account.telegramGroupPolicyAlways": "All group messages", "account.telegramGroupPolicyCustom": "Only specified groups without @", "account.telegramFreeChatGroups": "Free-chat group IDs", "account.telegramFreeChatGroupsInvalid": "No valid group IDs detected. Group IDs are typically negative integers (e.g. -1001234567890), or paste a Telegram Web chat link.", "account.telegramFreeChatGroupsPartial": "{count} group ID(s) could not be recognized and will be ignored. Use negative integers (e.g. -1001234567890) or a Telegram Web chat link.", "account.telegramGroupPolicyNote": "Applies only to this account. To receive plain group messages, make the bot a group admin or disable privacy mode in @BotFather (/setprivacy → Disable).", "account.telegramThinkingDisplay": "Show thinking process", "account.telegramThinkingDisplayOff": "Off", "account.telegramThinkingDisplayCollapsed": "Collapsed", "account.telegramThinkingDisplayNote": "When enabled, reasoning is sent as an expandable quote block that users can tap to expand. All group members can view expanded reasoning.", "account.defaultName": "{channel} account {count}",
|
|
658
658
|
"account.remark": "Name remark", "account.remarkNote": "Shown only in settings to tell accounts apart. Leave blank to restore the automatic name.", "account.rename": "Edit name remark",
|
|
659
659
|
"account.count": "{count} accounts", "account.statusProcessing": "Processing…", "account.statusNotConnected": "Not connected", "account.receive": "Receive messages", "account.receiveDescription": "Turn this off to keep the account settings without receiving new messages", "account.removeConfirm": "Remove this account? Its saved settings and credentials will also be deleted.",
|
|
660
660
|
"action.addAccount": "Add account", "action.generateQr": "Generate QR code", "action.checkConnection": "Diagnose connection", "action.reconnectAccount": "Reconnect", "action.removeAccount": "Remove", "status.saving": "Saving…", "status.saved": "Saved",
|
|
@@ -831,8 +831,8 @@ window.__ModuleLoader__.load({
|
|
|
831
831
|
.ima-segment-gap-input{flex:1 1 0;min-width:0}
|
|
832
832
|
.ima-segment-gap-sep,.ima-segment-gap-unit{color:var(--ima-muted, #8a8a8a);white-space:nowrap}
|
|
833
833
|
.ima-account-settings.compact{grid-template-columns:1fr}
|
|
834
|
-
.ima-proxy-settings{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 16px;width:100%;box-sizing:border-box}
|
|
835
|
-
.ima-proxy-settings>.ima-picker-note{grid-column:1/-1}
|
|
834
|
+
.ima-proxy-settings,.ima-mention-policy-settings{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 16px;width:100%;box-sizing:border-box}
|
|
835
|
+
.ima-proxy-settings>.ima-picker-note,.ima-mention-policy-settings>.ima-picker-note{grid-column:1/-1}
|
|
836
836
|
.ima-picker-field{display:flex;min-width:0;width:100%;flex-direction:column;gap:6px;box-sizing:border-box}
|
|
837
837
|
.ima-picker-field.wide,.ima-picker-note,.ima-model-effort{grid-column:1/-1}
|
|
838
838
|
.ima-model-effort{display:grid;grid-template-columns:1fr 1fr;gap:14px 16px;min-width:0;width:100%;box-sizing:border-box}
|
|
@@ -1885,6 +1885,29 @@ window.__ModuleLoader__.load({
|
|
|
1885
1885
|
},
|
|
1886
1886
|
}, h(IconInfoOutline, { size: 12 }));
|
|
1887
1887
|
|
|
1888
|
+
const thinkingDisplayTip = t("account.telegramThinkingDisplayNote");
|
|
1889
|
+
const thinkingTipAnchor = h("span", {
|
|
1890
|
+
className: "ima-label-tip",
|
|
1891
|
+
title: HostTooltip ? undefined : thinkingDisplayTip,
|
|
1892
|
+
"aria-label": thinkingDisplayTip,
|
|
1893
|
+
role: "button",
|
|
1894
|
+
tabIndex: 0,
|
|
1895
|
+
style: {
|
|
1896
|
+
display: "inline-flex",
|
|
1897
|
+
alignItems: "center",
|
|
1898
|
+
cursor: "help",
|
|
1899
|
+
color: "var(--dsw-alias-label-tertiary, var(--ima-muted))",
|
|
1900
|
+
marginLeft: 2,
|
|
1901
|
+
},
|
|
1902
|
+
}, h(IconInfoOutline, { size: 12 }));
|
|
1903
|
+
|
|
1904
|
+
const thinkingDisplayLabel = h("span", { style: { display: "inline-flex", alignItems: "center", gap: 4 } },
|
|
1905
|
+
h("span", null, t("account.telegramThinkingDisplay")),
|
|
1906
|
+
HostTooltip
|
|
1907
|
+
? h(HostTooltip, { label: thinkingDisplayTip, portal: true, side: "top" }, thinkingTipAnchor)
|
|
1908
|
+
: thinkingTipAnchor,
|
|
1909
|
+
);
|
|
1910
|
+
|
|
1888
1911
|
const sessionIdleLabel = h("span", { style: { display: "inline-flex", alignItems: "center", gap: 4 } },
|
|
1889
1912
|
h("span", null, t("account.sessionIdle")),
|
|
1890
1913
|
HostTooltip
|
|
@@ -2006,6 +2029,16 @@ window.__ModuleLoader__.load({
|
|
|
2006
2029
|
options: sessionIdleOptions,
|
|
2007
2030
|
onChange: (next) => update({ sessionIdleMinutes: Number(next) }),
|
|
2008
2031
|
})),
|
|
2032
|
+
props.thinkingDisplaySupported && field("thinkingDisplay", thinkingDisplayLabel, h(Select, {
|
|
2033
|
+
className: "ima-account-picker",
|
|
2034
|
+
value: value.thinkingDisplay ? "collapsed" : "off",
|
|
2035
|
+
"aria-label": t("account.telegramThinkingDisplay"),
|
|
2036
|
+
options: [
|
|
2037
|
+
{ value: "off", label: t("account.telegramThinkingDisplayOff") },
|
|
2038
|
+
{ value: "collapsed", label: t("account.telegramThinkingDisplayCollapsed") },
|
|
2039
|
+
],
|
|
2040
|
+
onChange: (next) => update({ thinkingDisplay: next === "collapsed" }),
|
|
2041
|
+
})),
|
|
2009
2042
|
segmentSupported && field("segmentReply", segmentReplyLabel, h(Select, {
|
|
2010
2043
|
className: "ima-account-picker",
|
|
2011
2044
|
value: segmentReply ? "segmented" : "full",
|
|
@@ -2112,11 +2145,37 @@ window.__ModuleLoader__.load({
|
|
|
2112
2145
|
);
|
|
2113
2146
|
}
|
|
2114
2147
|
|
|
2148
|
+
/**
|
|
2149
|
+
* 单个群号条目能否被识别。
|
|
2150
|
+
* 规则必须与后端 src/channels/mention-policy.ts 的 normalizeChatId 保持一致:
|
|
2151
|
+
* 纯数字群号(可带负号、可带 :topicId 后缀)、t.me/c 私有群链接、web.telegram.org 链接。
|
|
2152
|
+
*/
|
|
2153
|
+
function isValidFreeChatGroupToken(item) {
|
|
2154
|
+
const cleaned = String(item).trim().replace(/[\u2212\u2013\u2014\uFF0D]/g, "-");
|
|
2155
|
+
if (!cleaned) return false;
|
|
2156
|
+
return /^-?\d{1,20}$/.test(cleaned.split(":")[0])
|
|
2157
|
+
|| /t\.me\/c\/\d{1,18}(?:[/?#]|$)/i.test(cleaned)
|
|
2158
|
+
|| /web\.telegram\.org\/[^#]*#(?:-\d{1,18}|c?\d{1,18})(?![0-9])/i.test(cleaned);
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
/** 统计群号列表里的条目总数与无法识别的条数;前端只用于提示,不改变保存内容。 */
|
|
2162
|
+
function freeChatGroupTokenIssues(raw) {
|
|
2163
|
+
const tokens = typeof raw === "string" && raw.trim() ? raw.split(/[\s,,]+/).filter(Boolean) : [];
|
|
2164
|
+
let invalid = 0;
|
|
2165
|
+
for (const token of tokens) if (!isValidFreeChatGroupToken(token)) invalid += 1;
|
|
2166
|
+
return { total: tokens.length, invalid };
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2115
2169
|
function AccountInspector({ account, catalog, permissions, agentPresets, workspaces, createWorkspace, pickDirectory, modelT, permissionT, presetT, t, onAction, onSave, busy }) {
|
|
2116
2170
|
const [modal, modalHolder] = Modal.useModal();
|
|
2117
2171
|
const [draft, setDraft] = useState(account);
|
|
2118
2172
|
const [proxyModeDraft, setProxyModeDraft] = useState(account.proxyMode || "inherit");
|
|
2119
2173
|
const [proxyUrlDraft, setProxyUrlDraft] = useState(account.proxyUrl || "");
|
|
2174
|
+
const [mentionPolicyDraft, setMentionPolicyDraft] = useState(
|
|
2175
|
+
account.mentionPolicy === "always" ? "always" : (account.freeChatGroups ? "custom" : "addressed")
|
|
2176
|
+
);
|
|
2177
|
+
const [freeChatGroupsDraft, setFreeChatGroupsDraft] = useState(account.freeChatGroups || "");
|
|
2178
|
+
const accountIdRef = useRef(account.id);
|
|
2120
2179
|
const [note, setNote] = useState("");
|
|
2121
2180
|
const [checkResult, setCheckResult] = useState(null);
|
|
2122
2181
|
const [checkFailed, setCheckFailed] = useState(false);
|
|
@@ -2157,7 +2216,14 @@ window.__ModuleLoader__.load({
|
|
|
2157
2216
|
setDraft(account);
|
|
2158
2217
|
setProxyModeDraft(account.proxyMode || "inherit");
|
|
2159
2218
|
setNote("");
|
|
2160
|
-
}, [account.id, account.cwd, account.permission, account.agentPreset, account.privateAccess, account.sendMode, account.sessionIdleMinutes, account.segmentReply, account.segmentDelayMinSecs, account.segmentDelayMaxSecs, account.proxyMode, account.proxyConfigured, JSON.stringify(account.commandPermissions), account.receiveEnabled, account.assistant && account.assistant.provider, account.assistant && account.assistant.model, account.assistant && account.assistant.reasoningEffort]);
|
|
2219
|
+
}, [account.id, account.cwd, account.permission, account.agentPreset, account.privateAccess, account.sendMode, account.sessionIdleMinutes, account.segmentReply, account.segmentDelayMinSecs, account.segmentDelayMaxSecs, account.proxyMode, account.proxyConfigured, JSON.stringify(account.commandPermissions), account.receiveEnabled, account.assistant && account.assistant.provider, account.assistant && account.assistant.model, account.assistant && account.assistant.reasoningEffort, account.thinkingDisplay]);
|
|
2220
|
+
useEffect(() => {
|
|
2221
|
+
if (accountIdRef.current !== account.id) {
|
|
2222
|
+
accountIdRef.current = account.id;
|
|
2223
|
+
setFreeChatGroupsDraft(account.freeChatGroups || "");
|
|
2224
|
+
setMentionPolicyDraft(account.mentionPolicy === "always" ? "always" : (account.freeChatGroups ? "custom" : "addressed"));
|
|
2225
|
+
}
|
|
2226
|
+
}, [account.id, account.freeChatGroups, account.mentionPolicy]);
|
|
2161
2227
|
useEffect(() => {
|
|
2162
2228
|
setProxyUrlDraft(account.proxyUrl || "");
|
|
2163
2229
|
}, [account.id, account.proxyUrl]);
|
|
@@ -2190,6 +2256,16 @@ window.__ModuleLoader__.load({
|
|
|
2190
2256
|
payload.proxyUrl = Object.prototype.hasOwnProperty.call(patch, "proxyUrl") ? patch.proxyUrl : proxyUrlDraft;
|
|
2191
2257
|
}
|
|
2192
2258
|
}
|
|
2259
|
+
if (account.platform === "telegram") {
|
|
2260
|
+
const hasMentionPatch = Object.prototype.hasOwnProperty.call(patch, "mentionPolicy") || Object.prototype.hasOwnProperty.call(patch, "freeChatGroups");
|
|
2261
|
+
if (hasMentionPatch) {
|
|
2262
|
+
payload.mentionPolicy = Object.prototype.hasOwnProperty.call(patch, "mentionPolicy") ? patch.mentionPolicy : (mentionPolicyDraft === "always" ? "always" : "addressed");
|
|
2263
|
+
payload.freeChatGroups = Object.prototype.hasOwnProperty.call(patch, "freeChatGroups") ? patch.freeChatGroups : freeChatGroupsDraft;
|
|
2264
|
+
}
|
|
2265
|
+
if (Object.prototype.hasOwnProperty.call(patch, "thinkingDisplay")) {
|
|
2266
|
+
payload.thinkingDisplay = patch.thinkingDisplay;
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2193
2269
|
return onSave(account.id, payload).then((ok) => {
|
|
2194
2270
|
if (seq === saveSeq.current) setNote(ok ? "status.saved" : "error.save");
|
|
2195
2271
|
return ok;
|
|
@@ -2230,6 +2306,7 @@ window.__ModuleLoader__.load({
|
|
|
2230
2306
|
h(AccountSettingsPicker, {
|
|
2231
2307
|
value: draft,
|
|
2232
2308
|
onChange: applySettings,
|
|
2309
|
+
thinkingDisplaySupported: account.platform === "telegram",
|
|
2233
2310
|
segmentReplySupported: account.segmentReplySupported !== false,
|
|
2234
2311
|
catalog,
|
|
2235
2312
|
permissions,
|
|
@@ -2280,6 +2357,54 @@ window.__ModuleLoader__.load({
|
|
|
2280
2357
|
),
|
|
2281
2358
|
h("div", { className: "ima-picker-note" }, t("account.proxyNote")),
|
|
2282
2359
|
),
|
|
2360
|
+
account.platform === "telegram" && h("div", { className: "ima-mention-policy-settings" },
|
|
2361
|
+
h("label", { className: mentionPolicyDraft === "custom" ? "ima-picker-field" : "ima-picker-field wide" },
|
|
2362
|
+
h("span", { className: "ima-picker-label" }, t("account.telegramGroupPolicy")),
|
|
2363
|
+
h(Select, {
|
|
2364
|
+
className: "ima-account-picker",
|
|
2365
|
+
value: mentionPolicyDraft,
|
|
2366
|
+
"aria-label": t("account.telegramGroupPolicy"),
|
|
2367
|
+
options: [
|
|
2368
|
+
{ value: "addressed", label: t("account.telegramGroupPolicyAddressed") },
|
|
2369
|
+
{ value: "custom", label: t("account.telegramGroupPolicyCustom") },
|
|
2370
|
+
{ value: "always", label: t("account.telegramGroupPolicyAlways") },
|
|
2371
|
+
],
|
|
2372
|
+
onChange: (next) => {
|
|
2373
|
+
setMentionPolicyDraft(next);
|
|
2374
|
+
if (next === "addressed") {
|
|
2375
|
+
save({ mentionPolicy: "addressed", freeChatGroups: "" });
|
|
2376
|
+
} else if (next === "always") {
|
|
2377
|
+
save({ mentionPolicy: "always", freeChatGroups: "" });
|
|
2378
|
+
} else {
|
|
2379
|
+
save({ mentionPolicy: "addressed", freeChatGroups: freeChatGroupsDraft.trim() });
|
|
2380
|
+
}
|
|
2381
|
+
},
|
|
2382
|
+
}),
|
|
2383
|
+
),
|
|
2384
|
+
mentionPolicyDraft === "custom" && h("label", { className: "ima-picker-field" },
|
|
2385
|
+
h("span", { className: "ima-picker-label" }, t("account.telegramFreeChatGroups")),
|
|
2386
|
+
h(Input, {
|
|
2387
|
+
type: "text",
|
|
2388
|
+
value: freeChatGroupsDraft,
|
|
2389
|
+
placeholder: "-1001234567890, -5496760438",
|
|
2390
|
+
"aria-label": t("account.telegramFreeChatGroups"),
|
|
2391
|
+
onChange: (event) => {
|
|
2392
|
+
setFreeChatGroupsDraft(event.target.value);
|
|
2393
|
+
},
|
|
2394
|
+
onBlur: (event) => {
|
|
2395
|
+
const value = event.target.value.trim();
|
|
2396
|
+
save({ mentionPolicy: "addressed", freeChatGroups: value });
|
|
2397
|
+
},
|
|
2398
|
+
}),
|
|
2399
|
+
),
|
|
2400
|
+
mentionPolicyDraft === "custom" && (() => {
|
|
2401
|
+
const issues = freeChatGroupTokenIssues(freeChatGroupsDraft);
|
|
2402
|
+
if (issues.invalid === 0) return null;
|
|
2403
|
+
const key = issues.invalid === issues.total ? "account.telegramFreeChatGroupsInvalid" : "account.telegramFreeChatGroupsPartial";
|
|
2404
|
+
return h("div", { className: "ima-picker-note warning" }, t(key, { count: issues.invalid }));
|
|
2405
|
+
})(),
|
|
2406
|
+
h("div", { className: "ima-picker-note" }, t("account.telegramGroupPolicyNote")),
|
|
2407
|
+
),
|
|
2283
2408
|
h(CommandPermissionSettings, { value: draft.commandPermissions, onSave: commandPermissions => save({ commandPermissions }), t }),
|
|
2284
2409
|
note && h("div", { className: note === "status.saved" ? "ima-save-note ok" : "ima-save-note" }, t(note)),
|
|
2285
2410
|
h("div", { className: "ima-inspector-actions" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/channels/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/channels/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAYxD,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,SAAS,EACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE;QAAE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAAC,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,GACrK,cAAc,GAAG,SAAS,CAiD5B"}
|
package/lib/channels/factory.js
CHANGED
|
@@ -7,14 +7,25 @@ import { createWeixinChannel } from './weixin.js';
|
|
|
7
7
|
import { createQqChannel } from './qq.js';
|
|
8
8
|
import { createSlackChannel } from './slack.js';
|
|
9
9
|
import { parseAdditionalImageHosts } from './image-host-policy.js';
|
|
10
|
+
import { parseChatIdList } from './mention-policy.js';
|
|
10
11
|
export function createChannelAdapter(id, config, log, stateDir, options) {
|
|
11
12
|
let adapter;
|
|
12
13
|
const imageOptions = ['qq', 'wecom', 'dingtalk'].includes(id)
|
|
13
14
|
? { additionalImageHosts: parseAdditionalImageHosts(config.additionalImageHosts) } : {};
|
|
14
15
|
switch (id) {
|
|
15
|
-
case 'telegram':
|
|
16
|
-
|
|
16
|
+
case 'telegram': {
|
|
17
|
+
const freeChatGroups = parseChatIdList(config.freeChatGroups);
|
|
18
|
+
adapter = createTelegramChannel({
|
|
19
|
+
token: config.token,
|
|
20
|
+
stateDir,
|
|
21
|
+
host: options?.host,
|
|
22
|
+
proxyMode: config.proxyMode,
|
|
23
|
+
proxyUrl: config.proxyUrl,
|
|
24
|
+
mentionPolicy: config.mentionPolicy === 'always' ? 'always' : undefined,
|
|
25
|
+
...(freeChatGroups.length > 0 ? { freeChatGroups } : {}),
|
|
26
|
+
}, log);
|
|
17
27
|
break;
|
|
28
|
+
}
|
|
18
29
|
case 'discord':
|
|
19
30
|
adapter = createDiscordChannel({
|
|
20
31
|
token: config.token,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/channels/factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/channels/factory.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 群聊触发策略:判断一条入站消息是否算「在对 bot 说话」。
|
|
3
|
+
*
|
|
4
|
+
* 默认(`addressed`)只有三种情况会触发:私聊、回复 bot 自己的消息、文本里 @ 了 bot。
|
|
5
|
+
* 群组常常希望「不 @ 也能直接聊」,于是提供两种放宽方式:
|
|
6
|
+
*
|
|
7
|
+
* - `mentionPolicy: 'always'`:该账号下所有群的普通消息都触发。
|
|
8
|
+
* - `freeChatGroups: [...chatId]`:只放宽指定群,其余群保持默认。
|
|
9
|
+
*
|
|
10
|
+
* 两者都只影响「这条消息要不要送进 agent」,不改变消息授权(谁能用 bot)
|
|
11
|
+
* 与工具审批边界。
|
|
12
|
+
*/
|
|
13
|
+
export type MentionPolicy = 'addressed' | 'always';
|
|
14
|
+
export interface InboundAddressInput {
|
|
15
|
+
readonly direct: boolean;
|
|
16
|
+
readonly chatId: string | number;
|
|
17
|
+
readonly replyToBot: boolean;
|
|
18
|
+
readonly mentioned: boolean;
|
|
19
|
+
readonly policy?: MentionPolicy | undefined;
|
|
20
|
+
readonly freeChatGroups?: readonly string[] | undefined;
|
|
21
|
+
}
|
|
22
|
+
/** 一条入站消息是否算在对 bot 说话。 */
|
|
23
|
+
export declare function isInboundAddressed(input: InboundAddressInput): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* 解析渠道配置里的群号列表:支持逗号、中文逗号、空白分隔,非法项直接丢弃。
|
|
26
|
+
* 渠道配置是字符串键值对,支持 Unicode 负号、话题后缀剥离与 Telegram Web 链接提取。
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseChatIdList(raw: unknown): string[];
|
|
29
|
+
//# sourceMappingURL=mention-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mention-policy.d.ts","sourceRoot":"","sources":["../../src/channels/mention-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,QAAQ,CAAA;AAElD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IAChC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,SAAS,CAAA;IAC3C,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;CACxD;AAED,0BAA0B;AAC1B,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAOtE;AAgDD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,EAAE,CAUtD"}
|