@michengai/dsh-im-connect 1.0.21 → 1.0.23
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 +14 -0
- package/CHANGELOG.zh-CN.md +14 -0
- package/README.md +10 -10
- package/README.zh-CN.md +10 -10
- package/client.js +144 -30
- package/lib/channels/telegram.d.ts.map +1 -1
- package/lib/channels/telegram.js +17 -3
- package/lib/channels/telegram.js.map +1 -1
- package/lib/client.js +144 -30
- package/lib/engine/file-delivery.d.ts +1 -3
- package/lib/engine/file-delivery.d.ts.map +1 -1
- package/lib/engine/file-delivery.js +2 -51
- package/lib/engine/file-delivery.js.map +1 -1
- package/lib/engine/types.d.ts +3 -0
- package/lib/engine/types.d.ts.map +1 -1
- package/lib/manager.d.ts +3 -0
- package/lib/manager.d.ts.map +1 -1
- package/lib/manager.js +43 -9
- package/lib/manager.js.map +1 -1
- package/package.json +1 -1
- package/src/channels/telegram.ts +17 -3
- package/src/engine/file-delivery.ts +2 -34
- package/src/engine/types.ts +3 -0
- package/src/manager.ts +48 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.23 - 2026-11-03
|
|
4
|
+
|
|
5
|
+
- Fix Telegram status emoji reactions not appearing on incoming messages (#55, PR #56): when sending messages to the Telegram bot, original messages now properly show status reactions (👀 processing / 🤔 waiting / 👍 finished / 👎 failed) as the assistant makes progress, resolving an issue where reaction updates were silently swallowed due to targeting event cursors instead of user message IDs.
|
|
6
|
+
- Skip reactions on interactive callbacks: button clicks and menu selections no longer attempt redundant status reactions, eliminating unnecessary background warning logs.
|
|
7
|
+
|
|
8
|
+
## 1.0.22 - 2026-11-03
|
|
9
|
+
|
|
10
|
+
- File delivery now sends only what the assistant explicitly delivers (#54): previously, any file the assistant touched (a memory note, a config edit, a log write) could be treated as this turn's output and pushed into the chat, which is especially awkward in group conversations. Only files the assistant declares as deliverables are returned now; ordinary file writes, code edits and state files no longer appear in chat.
|
|
11
|
+
- Upgrade note: if you relied on "the assistant writes a file and it arrives automatically", ask the assistant to deliver that file explicitly. `/export` for session logs is unaffected.
|
|
12
|
+
- New three-way entry location setting: the plugin details page switch became "Entry location" with Both / Sidebar only / Settings only, applied immediately without a reload. The default stays "Settings only", matching the previous behavior; accounts that had the sidebar entry enabled carry over to Both and keep their icon.
|
|
13
|
+
- In "Sidebar only" mode the duplicated **Settings → IM Assistant** tab is no longer shown and configuration happens in the sidebar panel; switch back to Both on the plugin details page to bring the settings tab back.
|
|
14
|
+
- Accessibility hardening: the new control now carries the identifiers and accessible names the host primitive requires, so screen readers announce the control and its three options.
|
|
15
|
+
- Documentation: both READMEs now describe the entry location states, its default value, and the file-delivery rule as implemented.
|
|
16
|
+
|
|
3
17
|
## 1.0.21 - 2026-10-30
|
|
4
18
|
|
|
5
19
|
- Add idle session auto-rotation: After a long pause in conversation, incoming messages can automatically start a fresh session, preventing previous conversation context from polluting new topics; previous sessions are preserved in history and can be resumed anytime via `/sessions` (PR #52).
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -4,6 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
以下记录近期发布的版本。Git 标签与 GitHub Release 现已和这些条目同步;历史条目继续保留原始发布提交链接。
|
|
6
6
|
|
|
7
|
+
## 1.0.23 - 2026-11-03
|
|
8
|
+
|
|
9
|
+
- 修复 Telegram 消息状态表情无法显示的问题(#55,PR #56):给 Telegram 机器人发送消息后,原消息能正常显示「👀 思考中 / 🤔 等待确认 / 👍 已完成 / 👎 失败」等状态表情;此前因目标消息识别偏差导致表情更新一直被静默忽略。
|
|
10
|
+
- 规范交互回调事件的表情处理:点击菜单或选择按钮等回调交互时,跳过无效的状态表情处理,避免产生多余的重试与错误日志。
|
|
11
|
+
|
|
12
|
+
## 1.0.22 - 2026-11-03
|
|
13
|
+
|
|
14
|
+
- 文件回传改为只发助手明确交付的文件(#54):以前助手只要改动了文件(例如写记忆、改配置、记录日志)就会把该文件当成本轮产出发到聊天里,群聊中往往还有其他成员;现在只有助手明确声明「这是本轮要交付的文件」才会回传,普通写文件、改代码、写状态文件都不再出现在聊天里。
|
|
15
|
+
- 升级提示:若你以前依赖「助手写了文件就自动发过来」,请让助手明确交付该文件;`/export` 导出会话日志不受影响。
|
|
16
|
+
- 新增入口位置三态设置:插件详情页的「侧边栏入口」开关升级为「入口展示位置」,可在「全部展示 / 仅侧边栏 / 仅设置」之间切换,改完即时生效无需刷新。默认仍是「仅设置」,与升级前行为一致;原本开启过侧边栏入口的账号会沿用到「全部展示」,不会丢图标。
|
|
17
|
+
- 「仅侧边栏」模式下不再重复显示「设置 → IM助理」页签,配置从侧栏面板进入;想找回设置页签时在插件详情页切回「全部展示」即可。
|
|
18
|
+
- 无障碍补强:新的三态控件补齐了宿主原语要求的标识与可访问名称,读屏器能正确读出控件名与三个选项。
|
|
19
|
+
- 文档同步:中英文 README 的入口位置说明、默认值与文件回传规则已按当前行为更新。
|
|
20
|
+
|
|
7
21
|
## 1.0.21 - 2026-10-30
|
|
8
22
|
|
|
9
23
|
- 新增空闲超时自动新开会话功能:长时间未交流后再次发送新消息,助手可自动开启全新会话,避免旧会话上下文与新话题混杂;旧会话仍完好保留在历史中,随时可用 `/sessions` 命令切换找回(PR #52)。
|
package/README.md
CHANGED
|
@@ -103,8 +103,8 @@ WeChat, WeCom, DingTalk, Feishu, Lark, QQ, Telegram, Discord, and Slack accept o
|
|
|
103
103
|
|
|
104
104
|
WeChat, WeCom, DingTalk, Feishu, Lark, QQ, Telegram, Discord, and Slack can return files produced by the assistant. For example: “Create a PDF report and send me the file.”
|
|
105
105
|
|
|
106
|
-
-
|
|
107
|
-
- File access follows Chat: files outside the workspace are allowed when the host can read them. The plugin does not extract arbitrary paths from reply text. Files created through shell commands need to be presented explicitly.
|
|
106
|
+
- Aligned with DSH Host delivery contracts: when the assistant explicitly declares deliverables via `tool-present` (`deliverables/presented`), the corresponding files are returned as chat attachments. Ordinary low-level tool mutations (such as editing code or writing state files) are not sent automatically, preventing chat noise and credential leakage.
|
|
107
|
+
- File access follows Chat: files outside the workspace are allowed when the host can read them. The plugin does not extract arbitrary paths from reply text. Files created through shell commands or scripts need to be presented explicitly by the assistant.
|
|
108
108
|
- Supported hosts use Chat's complete-file download service and its configured size limit. Directories and symbolic links are not sent; channel-specific file limits still apply.
|
|
109
109
|
- A failed transfer produces a message naming the file and does not stop the remaining files. Switching away from the session or stopping the account prevents pending delivery from continuing to a different target.
|
|
110
110
|
- Send `/export` as a standalone command to receive the current linked session’s Chat ZIP logs in this chat, without child sessions. The ZIP limit is 32 MiB; channel limits also apply. If the file is too large or cannot be sent, use `/export` in web Chat. Paths and other session IDs are not accepted.
|
|
@@ -239,15 +239,15 @@ The configuration output should contain `im-connect`. Restart DSH Web and hard-r
|
|
|
239
239
|
The plugin follows standard DSH bundle configuration conventions. Options are located at:
|
|
240
240
|
> **Sidebar → Plugins → Click `@michengai/dsh-im-connect`** (the host's `plugins.bundle.config` slot).
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
Native configuration options are provided here. Their values are persisted in `channels.json` under the plugin's `stateDir` and survive restarts; they are not equivalent Cordis YAML options. `location` and `taskTreeSessions` are managed through this UI, while `onlineUpdate` is also subject to the host lock described below:
|
|
243
243
|
|
|
244
|
-
### 1.
|
|
245
|
-
- **Default**:
|
|
246
|
-
- **Description**:
|
|
247
|
-
- **
|
|
248
|
-
-
|
|
249
|
-
-
|
|
250
|
-
|
|
244
|
+
### 1. Entry Location (`location`)
|
|
245
|
+
- **Default**: Settings only (`settings`)
|
|
246
|
+
- **Description**: Controls where the IM Assistant management page is displayed in the host navigation, supporting three states (matching host bundle entry conventions):
|
|
247
|
+
- **Both (`both`)**: Displays a persistent icon in the left primary sidebar and retains the entry in **Settings → IM Assistant**;
|
|
248
|
+
- **Sidebar only (`sidebar`)**: Displays only the sidebar icon, omitting the global settings entry;
|
|
249
|
+
- **Settings only (`settings`)**: Unregisters the sidebar icon (gracefully switching active views if currently open) and retains only the entry in **Settings → IM Assistant**.
|
|
250
|
+
- **Effect**: Clicking the sidebar icon opens the IM Assistant management page directly in the primary workspace with a **960px centered container** (matching host plugin manager conventions). This eliminates vertical scrolling constraints in narrow settings dialogs; state is synchronized live across both entry points.
|
|
251
251
|
|
|
252
252
|
### 2. Online Updates (`onlineUpdate` / `updater`)
|
|
253
253
|
- **Default**: Enabled (`true`)
|
package/README.zh-CN.md
CHANGED
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
|
|
106
106
|
微信、企业微信、钉钉、飞书、Lark、QQ、Telegram、Discord 和 Slack 均可回传助手产出的文件。例如:“整理成 PDF 报告,并把文件发给我。”
|
|
107
107
|
|
|
108
|
-
-
|
|
109
|
-
- 文件访问范围与 Chat
|
|
108
|
+
- 遵循 DSH 宿主交付契约:当助手通过 `tool-present`(`deliverables/presented`)显式声明交付时,对应文件将作为附件发到聊天中;底层的普通工具写操作(如修改代码、记录状态文件)不会被自动当作产物发送,防止群聊噪音与隐私泄露。
|
|
109
|
+
- 文件访问范围与 Chat 一致,允许宿主可读取的工作区外文件。不从回复正文中猜测文件路径;通过脚本等方式生成的文件,由助手明确 `present` 交付。
|
|
110
110
|
- 已支持的宿主使用 Chat 完整文件下载服务及其配置的大小上限。目录和符号链接不发送,渠道自身的文件限制仍然适用。
|
|
111
111
|
- 单个文件发送失败会明确提示文件名,并继续处理其他文件;切走会话或停止账号后,不会把尚未投递的文件转发到其他聊天。
|
|
112
112
|
- 单独发送 `/export`,可将当前聊天绑定会话的 Chat ZIP 日志发回当前聊天(不含子会话)。ZIP 上限为 32 MiB,渠道自身限制仍适用;超限或发送失败时可在网页 Chat 使用 `/export` 下载。不接受路径或其他会话 ID 参数。
|
|
@@ -239,15 +239,15 @@ dsh --profile web --dump-config
|
|
|
239
239
|
插件遵循 DSH 官方扩展配置规范,配置项位于:
|
|
240
240
|
> **主界面侧边栏「插件」→ 点击 `@michengai/dsh-im-connect` 详情页**(对应宿主 `plugins.bundle.config` 槽位)。
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
此处提供原生配置项。界面配置值保存在插件 `stateDir` 下的 `channels.json` 中,重启后保留;它们不是等价的 Cordis YAML 配置项。`location` 和 `taskTreeSessions` 只通过此界面管理,`onlineUpdate` 另受下述宿主锁定规则约束:
|
|
243
243
|
|
|
244
|
-
### 1.
|
|
245
|
-
-
|
|
246
|
-
-
|
|
247
|
-
-
|
|
248
|
-
-
|
|
249
|
-
-
|
|
250
|
-
|
|
244
|
+
### 1. 入口位置 (`location`)
|
|
245
|
+
- **默认状态**:仅设置(`settings`)
|
|
246
|
+
- **功能说明**:控制 IM 管理面板在宿主中的导航入口展示位置,支持三态切换(对齐官方扩展入口规范):
|
|
247
|
+
- **全部展示 (`both`)**:同时在左侧侧边栏常驻图标并在「设置 → IM助理」保留入口;
|
|
248
|
+
- **仅侧边栏 (`sidebar`)**:仅在左侧主导航栏显示图标入口,不在全局设置侧栏中显示;
|
|
249
|
+
- **仅设置 (`settings`)**:注销侧边栏图标(若当前正停留在 IM 面板,会自动安全切回默认视图,防止悬空和白屏),仅在「设置 → IM助理」保留入口。
|
|
250
|
+
- **生效效果**:在侧边栏点击即可直达 IM 助理中心,并在主工作区以 **960px 居中版心**(对齐官方插件管理与市场规范)展开完整大面板,彻底告别在设置弹窗狭窄视口内滚动的局限;两处入口数据与状态 100% 实时同步。
|
|
251
251
|
|
|
252
252
|
### 2. 在线更新 (`onlineUpdate` / `updater`)
|
|
253
253
|
- **默认状态**:开启(`true`)
|
package/client.js
CHANGED
|
@@ -16,6 +16,7 @@ window.__ModuleLoader__.load({
|
|
|
16
16
|
const HostSegmentedTabs = primitives.SegmentedTabs;
|
|
17
17
|
const HostTooltip = primitives.Tooltip;
|
|
18
18
|
const PrimitiveSwitch = primitives.Switch;
|
|
19
|
+
const PrimitiveSegmentedControl = primitives.SegmentedControl;
|
|
19
20
|
// 宿主 Button 由 forwardRef 包成对象,typeof 是 object,不是 function。
|
|
20
21
|
function isHostComponent(component) {
|
|
21
22
|
return typeof component === "function" || (!!component && typeof component === "object" && typeof component.render === "function");
|
|
@@ -615,6 +616,7 @@ window.__ModuleLoader__.load({
|
|
|
615
616
|
"connection.next.connected": "可在原聊天发送消息验证收发;私聊仍需符合准入设置。", "connection.next.connecting": "请稍后再次检查;等待扫码时请完成手机确认。", "connection.next.reconnecting": "渠道正在尝试恢复,请稍后再次检查。", "connection.next.disconnected": "请重新连接;需要扫码的渠道可重新添加绑定。", "connection.next.stopped": "请点击重新连接以启动账号。", "connection.next.error": "请尝试重新连接;仍有异常时查看本机日志。", "connection.next.unknown": "暂时无法确认状态,请稍后再检查或查看本机日志。",
|
|
616
617
|
"settings.label": "IM助理", "settings.title": "IM助理", "settings.description": "管理各渠道账号。每个账号独立选择工作区、模型和权限,配置仅保存在本机。", "settings.viewProject": "GitHub", "settings.feedback": "问题反馈",
|
|
617
618
|
"sidebar.entry.title": "侧边栏入口", "sidebar.entry.desc": "在侧栏显示即时通讯管理入口。设置里的入口不变。", "sidebar.entry.toggle": "切换侧边栏入口",
|
|
619
|
+
"entry.location.title": "入口展示位置", "entry.location.desc": "选择即时通信功能在界面上的显示入口(侧边栏或设置页面)", "entry.location.both": "全部显示", "entry.location.sidebar": "仅侧边栏", "entry.location.settings": "仅设置",
|
|
618
620
|
"update.entry.title": "在线更新", "update.entry.desc": "允许检查并在线安装即时通讯插件的新版本。关闭后隐藏更新入口。", "update.entry.toggle": "切换在线更新", "error.update.disabled": "在线更新已被禁用",
|
|
619
621
|
"taskTreeSessions.entry.title": "在任务树显示 IM 会话", "taskTreeSessions.entry.desc": "在官方工作区任务树中显示各渠道会话。关闭后仅在侧栏「频道」页签中显示", "taskTreeSessions.entry.toggle": "切换在任务树显示 IM 会话",
|
|
620
622
|
"settings.aria": "IM助理", "settings.publicChatNotice": "未批准用户可以发起聊天,但不能批准工具调用。", "pending.notice": "有访问请求。批准后该用户才能驱动本机助手。", "action.approve": "批准", "action.deny": "拒绝", "loading": "加载中…",
|
|
@@ -647,6 +649,7 @@ window.__ModuleLoader__.load({
|
|
|
647
649
|
"connection.next.connected": "Send a message in the original chat to verify delivery. Private chats still follow access settings.", "connection.next.connecting": "Check again shortly. Complete confirmation on your phone if a QR scan is pending.", "connection.next.reconnecting": "The channel is attempting to recover. Check again shortly.", "connection.next.disconnected": "Reconnect the account. QR channels may need to be added again.", "connection.next.stopped": "Select Reconnect to start the account.", "connection.next.error": "Try reconnecting. If the issue persists, check the local logs.", "connection.next.unknown": "The current state could not be confirmed. Check again later or inspect the local logs.",
|
|
648
650
|
"settings.label": "IM Assistant", "settings.title": "IM Assistant", "settings.description": "Manage accounts across channels. Each account has its own workspace, model, and permission settings, stored only on this machine.", "settings.viewProject": "GitHub", "settings.feedback": "Issues",
|
|
649
651
|
"sidebar.entry.title": "Sidebar entry", "sidebar.entry.desc": "Show IM Connect in the sidebar. The Settings entry stays either way.", "sidebar.entry.toggle": "Toggle sidebar entry",
|
|
652
|
+
"entry.location.title": "Entry location", "entry.location.desc": "Choose where IM Connect is displayed (sidebar or Settings page)", "entry.location.both": "Both", "entry.location.sidebar": "Sidebar only", "entry.location.settings": "Settings only",
|
|
650
653
|
"update.entry.title": "Online updates", "update.entry.desc": "Allow checking and installing new versions online. Hides the update entry when disabled.", "update.entry.toggle": "Toggle online updates", "error.update.disabled": "Online updates are disabled",
|
|
651
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",
|
|
652
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…",
|
|
@@ -3667,6 +3670,8 @@ window.__ModuleLoader__.load({
|
|
|
3667
3670
|
enabled,
|
|
3668
3671
|
onToggle,
|
|
3669
3672
|
disabled,
|
|
3673
|
+
location,
|
|
3674
|
+
onLocationChange,
|
|
3670
3675
|
onlineUpdateEnabled = true,
|
|
3671
3676
|
onToggleOnlineUpdate,
|
|
3672
3677
|
onlineUpdateDisabled,
|
|
@@ -3677,19 +3682,48 @@ window.__ModuleLoader__.load({
|
|
|
3677
3682
|
} = props;
|
|
3678
3683
|
|
|
3679
3684
|
const SwitchComponent = PrimitiveSwitch || Switch;
|
|
3685
|
+
const SegmentedControlComponent = PrimitiveSegmentedControl;
|
|
3686
|
+
const currentLocation = location || (enabled ? 'both' : 'settings');
|
|
3687
|
+
const locationOptions = [
|
|
3688
|
+
{ label: t("entry.location.both"), value: "both" },
|
|
3689
|
+
{ label: t("entry.location.sidebar"), value: "sidebar" },
|
|
3690
|
+
{ label: t("entry.location.settings"), value: "settings" },
|
|
3691
|
+
];
|
|
3692
|
+
|
|
3680
3693
|
const rows = [
|
|
3681
|
-
|
|
3682
|
-
h("div", { className: "ima-bundle-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3694
|
+
SegmentedControlComponent
|
|
3695
|
+
? h("div", { key: "sidebar-entry", className: "ima-bundle-row" },
|
|
3696
|
+
h("div", { className: "ima-bundle-label-box" },
|
|
3697
|
+
h("span", { className: "ima-bundle-title" }, t("entry.location.title")),
|
|
3698
|
+
h("span", { className: "ima-bundle-desc" }, t("entry.location.desc"))
|
|
3699
|
+
),
|
|
3700
|
+
h(SegmentedControlComponent, {
|
|
3701
|
+
id: "ima-bundle-entry-location",
|
|
3702
|
+
value: currentLocation,
|
|
3703
|
+
options: locationOptions,
|
|
3704
|
+
label: t("entry.location.title"),
|
|
3705
|
+
onChange: (val) => {
|
|
3706
|
+
if (typeof onLocationChange === "function") {
|
|
3707
|
+
onLocationChange(val);
|
|
3708
|
+
} else if (typeof onToggle === "function") {
|
|
3709
|
+
onToggle(val !== "settings");
|
|
3710
|
+
}
|
|
3711
|
+
},
|
|
3712
|
+
disabled: disabled,
|
|
3713
|
+
})
|
|
3714
|
+
)
|
|
3715
|
+
: h("div", { key: "sidebar-entry", className: "ima-bundle-row" },
|
|
3716
|
+
h("div", { className: "ima-bundle-label-box" },
|
|
3717
|
+
h("span", { className: "ima-bundle-title" }, t("sidebar.entry.title")),
|
|
3718
|
+
h("span", { className: "ima-bundle-desc" }, t("sidebar.entry.desc"))
|
|
3719
|
+
),
|
|
3720
|
+
h(SwitchComponent, {
|
|
3721
|
+
checked: enabled,
|
|
3722
|
+
onChange: onToggle,
|
|
3723
|
+
label: t("sidebar.entry.toggle"),
|
|
3724
|
+
disabled: disabled,
|
|
3725
|
+
})
|
|
3726
|
+
),
|
|
3693
3727
|
];
|
|
3694
3728
|
|
|
3695
3729
|
if (typeof onToggleOnlineUpdate === "function") {
|
|
@@ -3733,6 +3767,7 @@ window.__ModuleLoader__.load({
|
|
|
3733
3767
|
}
|
|
3734
3768
|
|
|
3735
3769
|
function ImBundleConfigCardWrapper(props) {
|
|
3770
|
+
const [location, setLocation] = useState(props.getLocation ? props.getLocation : () => (props.getEnabled() ? 'both' : 'settings'));
|
|
3736
3771
|
const [enabled, setEnabled] = useState(props.getEnabled);
|
|
3737
3772
|
const [onlineUpdateEnabled, setOnlineUpdateEnabled] = useState(props.getOnlineUpdateEnabled ? props.getOnlineUpdateEnabled : () => true);
|
|
3738
3773
|
const [onlineUpdateLocked, setOnlineUpdateLocked] = useState(props.getOnlineUpdateLocked ? props.getOnlineUpdateLocked : () => false);
|
|
@@ -3742,6 +3777,7 @@ window.__ModuleLoader__.load({
|
|
|
3742
3777
|
const [savingTaskTreeSessions, setSavingTaskTreeSessions] = useState(false);
|
|
3743
3778
|
|
|
3744
3779
|
useEffect(() => {
|
|
3780
|
+
if (props.getLocation) setLocation(props.getLocation());
|
|
3745
3781
|
setEnabled(props.getEnabled());
|
|
3746
3782
|
if (props.getOnlineUpdateEnabled) {
|
|
3747
3783
|
setOnlineUpdateEnabled(props.getOnlineUpdateEnabled());
|
|
@@ -3753,6 +3789,7 @@ window.__ModuleLoader__.load({
|
|
|
3753
3789
|
setTaskTreeSessionsEnabled(props.getTaskTreeSessionsEnabled());
|
|
3754
3790
|
}
|
|
3755
3791
|
return props.subscribe(() => {
|
|
3792
|
+
if (props.getLocation) setLocation(props.getLocation());
|
|
3756
3793
|
setEnabled(props.getEnabled());
|
|
3757
3794
|
if (props.getOnlineUpdateEnabled) {
|
|
3758
3795
|
setOnlineUpdateEnabled(props.getOnlineUpdateEnabled());
|
|
@@ -3766,16 +3803,23 @@ window.__ModuleLoader__.load({
|
|
|
3766
3803
|
});
|
|
3767
3804
|
}, [props]);
|
|
3768
3805
|
|
|
3769
|
-
const
|
|
3806
|
+
const onLocationChange = (next) => {
|
|
3770
3807
|
setSavingSidebar(true);
|
|
3771
|
-
|
|
3772
|
-
|
|
3808
|
+
setLocation(next);
|
|
3809
|
+
setEnabled(next !== "settings");
|
|
3810
|
+
const p = props.setLocation ? props.setLocation(next) : props.setSidebar(next !== "settings");
|
|
3811
|
+
p.catch(() => {
|
|
3812
|
+
if (props.getLocation) setLocation(props.getLocation());
|
|
3773
3813
|
setEnabled(props.getEnabled());
|
|
3774
3814
|
}).finally(() => {
|
|
3775
3815
|
setSavingSidebar(false);
|
|
3776
3816
|
});
|
|
3777
3817
|
};
|
|
3778
3818
|
|
|
3819
|
+
const onToggleSidebar = (next) => {
|
|
3820
|
+
onLocationChange(next ? "both" : "settings");
|
|
3821
|
+
};
|
|
3822
|
+
|
|
3779
3823
|
const onToggleOnlineUpdate = props.setOnlineUpdate ? (next) => {
|
|
3780
3824
|
if (onlineUpdateLocked) return;
|
|
3781
3825
|
setSavingUpdate(true);
|
|
@@ -3803,6 +3847,8 @@ window.__ModuleLoader__.load({
|
|
|
3803
3847
|
|
|
3804
3848
|
return h(ImBundleConfigCard, {
|
|
3805
3849
|
t: props.t,
|
|
3850
|
+
location,
|
|
3851
|
+
onLocationChange,
|
|
3806
3852
|
enabled,
|
|
3807
3853
|
disabled: savingSidebar,
|
|
3808
3854
|
onToggle: onToggleSidebar,
|
|
@@ -3833,6 +3879,7 @@ window.__ModuleLoader__.load({
|
|
|
3833
3879
|
};
|
|
3834
3880
|
}
|
|
3835
3881
|
const { callApi, renderPanel, ns } = options;
|
|
3882
|
+
let entryLocation = "settings";
|
|
3836
3883
|
let sidebarEntryEnabled = false;
|
|
3837
3884
|
let sidebarSupported = false;
|
|
3838
3885
|
let offPanel = null;
|
|
@@ -3840,11 +3887,15 @@ window.__ModuleLoader__.load({
|
|
|
3840
3887
|
let epoch = 0;
|
|
3841
3888
|
let layoutService;
|
|
3842
3889
|
const listeners = new Set();
|
|
3890
|
+
const locationListeners = new Set();
|
|
3843
3891
|
|
|
3844
3892
|
const notify = () => {
|
|
3845
3893
|
for (const listener of listeners) {
|
|
3846
3894
|
try { listener(); } catch {}
|
|
3847
3895
|
}
|
|
3896
|
+
for (const listener of locationListeners) {
|
|
3897
|
+
try { listener(entryLocation); } catch {}
|
|
3898
|
+
}
|
|
3848
3899
|
};
|
|
3849
3900
|
|
|
3850
3901
|
const sync = () => {
|
|
@@ -3890,20 +3941,27 @@ window.__ModuleLoader__.load({
|
|
|
3890
3941
|
}
|
|
3891
3942
|
};
|
|
3892
3943
|
|
|
3893
|
-
const
|
|
3944
|
+
const setLocation = async (next) => {
|
|
3945
|
+
if (next !== "both" && next !== "sidebar" && next !== "settings") {
|
|
3946
|
+
throw new Error("location must be one of 'both', 'sidebar', or 'settings'");
|
|
3947
|
+
}
|
|
3948
|
+
const prevLocation = entryLocation;
|
|
3949
|
+
const prevEnabled = sidebarEntryEnabled;
|
|
3894
3950
|
const currentEpoch = ++epoch;
|
|
3895
|
-
|
|
3951
|
+
entryLocation = next;
|
|
3952
|
+
sidebarEntryEnabled = next !== "settings";
|
|
3896
3953
|
sync();
|
|
3897
3954
|
notify();
|
|
3898
3955
|
try {
|
|
3899
3956
|
await callApi("/sidebar-entry", {
|
|
3900
3957
|
method: "POST",
|
|
3901
|
-
body: JSON.stringify({
|
|
3958
|
+
body: JSON.stringify({ location: next }),
|
|
3902
3959
|
});
|
|
3903
3960
|
return next;
|
|
3904
3961
|
} catch (err) {
|
|
3905
3962
|
if (currentEpoch === epoch) {
|
|
3906
|
-
|
|
3963
|
+
entryLocation = prevLocation;
|
|
3964
|
+
sidebarEntryEnabled = prevEnabled;
|
|
3907
3965
|
sync();
|
|
3908
3966
|
notify();
|
|
3909
3967
|
}
|
|
@@ -3911,6 +3969,10 @@ window.__ModuleLoader__.load({
|
|
|
3911
3969
|
}
|
|
3912
3970
|
};
|
|
3913
3971
|
|
|
3972
|
+
const setEnabled = async (next) => {
|
|
3973
|
+
return (await setLocation(next ? "both" : "settings")) !== "settings";
|
|
3974
|
+
};
|
|
3975
|
+
|
|
3914
3976
|
let onlineUpdateEnabled = true;
|
|
3915
3977
|
let onlineUpdateLocked = false;
|
|
3916
3978
|
let updateEpoch = 0;
|
|
@@ -3948,8 +4010,14 @@ window.__ModuleLoader__.load({
|
|
|
3948
4010
|
const loadEpoch = epoch;
|
|
3949
4011
|
callApi("/sidebar-entry")
|
|
3950
4012
|
.then((res) => {
|
|
3951
|
-
if (epoch === loadEpoch && res
|
|
3952
|
-
|
|
4013
|
+
if (epoch === loadEpoch && res) {
|
|
4014
|
+
if (res.location === "both" || res.location === "sidebar" || res.location === "settings") {
|
|
4015
|
+
entryLocation = res.location;
|
|
4016
|
+
sidebarEntryEnabled = entryLocation !== "settings";
|
|
4017
|
+
} else if (typeof res.enabled === "boolean") {
|
|
4018
|
+
sidebarEntryEnabled = res.enabled;
|
|
4019
|
+
entryLocation = res.enabled ? "both" : "settings";
|
|
4020
|
+
}
|
|
3953
4021
|
sync();
|
|
3954
4022
|
notify();
|
|
3955
4023
|
}
|
|
@@ -4046,6 +4114,8 @@ window.__ModuleLoader__.load({
|
|
|
4046
4114
|
if (ownerProps && ownerProps.view === "summary") return null;
|
|
4047
4115
|
return h(ImBundleConfigCardWrapper, {
|
|
4048
4116
|
t: ctx.locale.bind(ns),
|
|
4117
|
+
getLocation: () => entryLocation,
|
|
4118
|
+
setLocation: setLocation,
|
|
4049
4119
|
getEnabled: () => sidebarEntryEnabled,
|
|
4050
4120
|
setSidebar: setEnabled,
|
|
4051
4121
|
getOnlineUpdateEnabled: () => onlineUpdateEnabled,
|
|
@@ -4062,6 +4132,13 @@ window.__ModuleLoader__.load({
|
|
|
4062
4132
|
});
|
|
4063
4133
|
|
|
4064
4134
|
return {
|
|
4135
|
+
getLocation: () => entryLocation,
|
|
4136
|
+
setLocation,
|
|
4137
|
+
isSettingsSectionEnabled: () => entryLocation !== "sidebar",
|
|
4138
|
+
onLocationChange: (fn) => {
|
|
4139
|
+
locationListeners.add(fn);
|
|
4140
|
+
return () => { locationListeners.delete(fn); };
|
|
4141
|
+
},
|
|
4065
4142
|
isEnabled: () => sidebarEntryEnabled,
|
|
4066
4143
|
isSupported: () => sidebarSupported,
|
|
4067
4144
|
setEnabled,
|
|
@@ -4294,21 +4371,58 @@ window.__ModuleLoader__.load({
|
|
|
4294
4371
|
|
|
4295
4372
|
installSettingsNavIcon(ctx, () => t("settings.label"));
|
|
4296
4373
|
|
|
4297
|
-
|
|
4374
|
+
let unregSettings = null;
|
|
4375
|
+
const mountSettingsSection = () => {
|
|
4376
|
+
if (unregSettings) return;
|
|
4377
|
+
const res = (ctx.slots.register({
|
|
4298
4378
|
name: "settings.section",
|
|
4299
4379
|
id: "im-assistant",
|
|
4300
4380
|
order: 40,
|
|
4301
4381
|
label: () => t("settings.label"),
|
|
4302
4382
|
icon: "chat",
|
|
4303
4383
|
locale: IM_LOCALE_NS,
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4384
|
+
inject: () => ({
|
|
4385
|
+
createWorkspace: typeof ctx.workspaces?.create === "function" ? (input) => ctx.workspaces.create(input) : undefined,
|
|
4386
|
+
pickDirectory: () => pickHostDirectory(ctx),
|
|
4387
|
+
permissionT,
|
|
4388
|
+
modelT,
|
|
4389
|
+
presetT,
|
|
4390
|
+
}),
|
|
4391
|
+
}, LocalizedSettingsPage));
|
|
4392
|
+
unregSettings = typeof res === "function" ? res : () => {};
|
|
4393
|
+
};
|
|
4394
|
+
|
|
4395
|
+
const unmountSettingsSection = () => {
|
|
4396
|
+
if (!unregSettings) return;
|
|
4397
|
+
try { unregSettings(); } catch {}
|
|
4398
|
+
unregSettings = null;
|
|
4399
|
+
};
|
|
4400
|
+
|
|
4401
|
+
let settingsSlotInjected = false;
|
|
4402
|
+
const syncSettingsSection = () => {
|
|
4403
|
+
if (!settingsSlotInjected) return;
|
|
4404
|
+
const shouldShow = sidebarController && typeof sidebarController.isSettingsSectionEnabled === "function"
|
|
4405
|
+
? sidebarController.isSettingsSectionEnabled()
|
|
4406
|
+
: true;
|
|
4407
|
+
if (shouldShow) {
|
|
4408
|
+
mountSettingsSection();
|
|
4409
|
+
} else {
|
|
4410
|
+
unmountSettingsSection();
|
|
4411
|
+
}
|
|
4412
|
+
};
|
|
4413
|
+
|
|
4414
|
+
ctx.slots.inject("settings.section", () => {
|
|
4415
|
+
settingsSlotInjected = true;
|
|
4416
|
+
syncSettingsSection();
|
|
4417
|
+
return () => {
|
|
4418
|
+
unmountSettingsSection();
|
|
4419
|
+
settingsSlotInjected = false;
|
|
4420
|
+
};
|
|
4421
|
+
});
|
|
4422
|
+
|
|
4423
|
+
if (sidebarController && typeof sidebarController.onLocationChange === "function") {
|
|
4424
|
+
sidebarController.onLocationChange(() => syncSettingsSection());
|
|
4425
|
+
}
|
|
4312
4426
|
|
|
4313
4427
|
ctx.slots.inject("sidebar.channels", () => ctx.slots.register({
|
|
4314
4428
|
name: "sidebar.channels",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telegram.d.ts","sourceRoot":"","sources":["../../src/channels/telegram.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAmC,MAAM,oBAAoB,CAAA;AAMzF,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE;QAAE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAA;IACrC,SAAS,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAkCD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjF;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAalG;
|
|
1
|
+
{"version":3,"file":"telegram.d.ts","sourceRoot":"","sources":["../../src/channels/telegram.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAmC,MAAM,oBAAoB,CAAA;AAMzF,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE;QAAE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAA;IACrC,SAAS,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAkCD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjF;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAalG;AAgBD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAkB1D;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMxE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,cAAc,GAAG,SAAS,CA6arH"}
|
package/lib/channels/telegram.js
CHANGED
|
@@ -34,6 +34,15 @@ export function parseTelegramChatId(chatId) {
|
|
|
34
34
|
threadId: /^[1-9]\d*$/.test(rawThread) ? Number(rawThread) : undefined,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* 状态表情要落在「用户那条消息」上,必须用 Telegram 的 message_id;
|
|
39
|
+
* 入站事件的 messageId 是 update_id(用于去重),拿它调 setMessageReaction
|
|
40
|
+
* 只会得到 Bad Request: message to react not found。
|
|
41
|
+
*/
|
|
42
|
+
function reactionMessageId(message) {
|
|
43
|
+
const id = Number(message.platformMessageId);
|
|
44
|
+
return Number.isSafeInteger(id) && id > 0 ? id : undefined;
|
|
45
|
+
}
|
|
37
46
|
const FENCE_LINE = /^\s{0,3}(?:`{3,}|~{3,})/;
|
|
38
47
|
/** 块级语法行:列表、标题、引用、表格都不需要也不应该补硬换行。 */
|
|
39
48
|
const BLOCK_LINE = /^\s{0,3}(?:#{1,6}\s|[-*+]\s|\d{1,9}[.)]\s|>|\|)/;
|
|
@@ -327,6 +336,7 @@ export function createTelegramChannel(config, log) {
|
|
|
327
336
|
kind: direct ? 'dm' : 'group',
|
|
328
337
|
addressed,
|
|
329
338
|
messageId: String(delivery.update_id),
|
|
339
|
+
platformMessageId: String(message.message_id),
|
|
330
340
|
});
|
|
331
341
|
}
|
|
332
342
|
}
|
|
@@ -433,21 +443,25 @@ export function createTelegramChannel(config, log) {
|
|
|
433
443
|
},
|
|
434
444
|
typingIntervalMs: 5000,
|
|
435
445
|
async addStatusReaction(message, state, _label, signal) {
|
|
436
|
-
|
|
446
|
+
const target = reactionMessageId(message);
|
|
447
|
+
if (target === undefined || state === 'cancelled')
|
|
437
448
|
return;
|
|
438
449
|
const route = parseTelegramChatId(message.chatId);
|
|
439
450
|
const emoji = (state === 'success' || state === 'ended') ? '👍' : state === 'error' ? '👎' : state === 'waiting' ? '🤔' : '👀';
|
|
440
451
|
await fileRequest(`${API}/bot${token}/setMessageReaction`, {
|
|
441
452
|
method: 'POST', headers: { 'content-type': 'application/json' }, signal,
|
|
442
|
-
body: JSON.stringify({ chat_id: route.chatId, message_id:
|
|
453
|
+
body: JSON.stringify({ chat_id: route.chatId, message_id: target, reaction: [{ type: 'emoji', emoji }] }),
|
|
443
454
|
}, fetchTelegram);
|
|
444
455
|
return emoji;
|
|
445
456
|
},
|
|
446
457
|
async removeStatusReaction(message, _reaction, signal) {
|
|
458
|
+
const target = reactionMessageId(message);
|
|
459
|
+
if (target === undefined)
|
|
460
|
+
return;
|
|
447
461
|
const route = parseTelegramChatId(message.chatId);
|
|
448
462
|
await fileRequest(`${API}/bot${token}/setMessageReaction`, {
|
|
449
463
|
method: 'POST', headers: { 'content-type': 'application/json' }, signal,
|
|
450
|
-
body: JSON.stringify({ chat_id: route.chatId, message_id:
|
|
464
|
+
body: JSON.stringify({ chat_id: route.chatId, message_id: target, reaction: [] }),
|
|
451
465
|
}, fetchTelegram);
|
|
452
466
|
},
|
|
453
467
|
async sendAction(chatId) {
|