@kadaliao/dsh-bots 0.3.3 → 0.4.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/README.md CHANGED
@@ -80,7 +80,7 @@ A bot is an ordinary Harness conversation, so everything Harness can do, a bot c
80
80
  | Category | Apps (🔑 = needs a key) |
81
81
  | --- | --- |
82
82
  | Sales & payments | Stripe 🔑, HubSpot CRM 🔑 |
83
- | Team & office | Feishu / Lark 🔑, Notion 🔑, Slack 🔑, Memory |
83
+ | Team & office | Telegram 🔑 and Discord 🔑 (chat apps, below), Feishu / Lark 🔑, Notion 🔑, Slack 🔑, Memory |
84
84
  | Build & ship | GitHub 🔑, Git, Supabase 🔑, Sentry 🔑, Context7 Docs |
85
85
  | Research & content | Exa, Tavily 🔑, Brave 🔑, Firecrawl 🔑 |
86
86
  | Computer & browser | Open Computer Use (operate macOS apps), Playwright |
@@ -90,6 +90,60 @@ A bot is an ordinary Harness conversation, so everything Harness can do, a bot c
90
90
 
91
91
  - **Schedules** are ordinary Harness scheduled tasks, also on the Automation page.
92
92
  - **AI avatars**: with the [Images plugin](../images), draw a bot's avatar from its persona.
93
+ - **Logos**: each app in the gallery shows its vendor's own logo (the App Store icon where there is an app,
94
+ otherwise the logo from the vendor's site or repository). The logos are their owners' trademarks and
95
+ only identify each service.
96
+
97
+ ## Message your team from Telegram or Discord
98
+
99
+ Add **Telegram** or **Discord** to a bot (normally the dispatcher) in its **Apps** tab, and you can hand out
100
+ work from your phone: what you send the chat bot goes to the team as if you typed it in the panel, and
101
+ the replies come back to the chat, including the dispatcher's report once its teammates have answered.
102
+
103
+ > **You, in Telegram**: Get the release organised for next week.
104
+ >
105
+ > **Atlas**: On it: Forge takes the three P1 bugs, Echo drafts the launch post.
106
+ >
107
+ > **Atlas** (later): Bugs fixed and merged; the launch draft is ready for your review.
108
+
109
+ ### Telegram
110
+
111
+ 1. In Telegram, open [@BotFather](https://t.me/BotFather), send `/newbot`, pick a name and a username
112
+ ending in `bot`. Make a new bot just for this team.
113
+ 2. In Bots, open the dispatcher → **Apps** → **Telegram** → paste the token BotFather gave you → **Add**.
114
+ It connects at once and shows **Connected as @yourbot**.
115
+ 3. Pair yourself: the panel shows a one-time code (it works once, for 10 minutes). Click **Open in
116
+ Telegram** and press **Start**, or send the code to your bot. The bot answers "Paired".
117
+ 4. Message the bot. Start a message with `@handle` to reach another bot directly (`@forge fix the login bug`).
118
+ In a group, add the bot and @mention it (or reply to it); it ignores the rest of the conversation.
119
+
120
+ ### Discord
121
+
122
+ 1. In the [Developer Portal](https://discord.com/developers/applications): **New Application** → **Bot** →
123
+ **Reset Token** and copy it. On the same page turn on **Message Content Intent** (without it the bot
124
+ cannot read messages, and the panel says so).
125
+ 2. Add **Discord** to the dispatcher with that token. Once connected, use **Invite the bot to a server**
126
+ (any server you are in, a private one is fine): Discord only lets you DM a bot you share a server with.
127
+ 3. DM the bot the pairing code, then DM it your requests, or @mention it in a channel.
128
+
129
+ ### What else to know
130
+
131
+ - **Who can talk to it**: only people you paired. Anyone else is ignored; in a private chat they get at
132
+ most one "this bot is private" line a day. Pairing happens only in a private chat, with the current
133
+ code, and a few wrong guesses lock a person out until the next code. You can pair more people (each
134
+ needs a new code) and remove anyone from the panel; the panel also counts ignored messages.
135
+ - **Treat a pairing like your own login**: a paired person can ask the bots for anything you could,
136
+ including whatever their abilities and apps allow on this Mac. Pair only yourself or people you trust,
137
+ and turn off risky abilities on the bot that owns the channel if others are paired.
138
+ - **Where replies go**: to the chat your latest request came from. Write in the panel and the conversation
139
+ is back in the panel. Telegram gets plain text (Markdown markers removed); Discord keeps its Markdown.
140
+ - **Scheduled reports**: a scheduled task of the bot that owns the channel reports to the first paired
141
+ person (switch it off in the panel), so "every weekday at nine Atlas briefs you" lands on your phone.
142
+ - **One token, one place**: a chat bot token can be connected on one bot of one Harness at a time. If
143
+ another program uses the same Telegram token, the panel says so.
144
+ - The token is stored with the bot like other app keys, never shown back in the panel, and kept out of
145
+ logs and error messages. Harness must be running for the bot to answer; Telegram holds messages for up
146
+ to 24 hours, and a message is never run twice after a restart.
93
147
 
94
148
  ## How it works
95
149
 
@@ -102,6 +156,9 @@ A bot is an ordinary Harness conversation, so everything Harness can do, a bot c
102
156
  most 16 messages in 10 minutes, so conversations end.
103
157
  - Every conversation gets `bot_list`, `bot_create`, `bot_update`, `bot_delete`, `bot_send_message`
104
158
  and `bot_schedule` to manage bots.
159
+ - A chat app is not an MCP server: the Host keeps one connection per Telegram or Discord app (long polling
160
+ for Telegram, the gateway for Discord), starts and stops it as you add, change, switch off or remove the
161
+ app, and hands paired people's messages to the bot as user prompts headed `[Telegram · Name]`.
105
162
 
106
163
  ## Open Computer Use
107
164
 
@@ -111,10 +168,13 @@ permission and restart it.
111
168
 
112
169
  ## What it stores and sends
113
170
 
114
- - `~/.dsh/cache/bots/`: `bots.json` (bots, including keys entered for apps), `messages.jsonl`
115
- (timeline), `avatars/`, `skills/` (skills imported from GitHub).
171
+ - `~/.dsh/cache/bots/`: `bots.json` (bots, including keys and chat bot tokens entered for apps),
172
+ `messages.jsonl` (timeline), `channels.json` (paired people per chat app, and the last message handled
173
+ per chat), `avatars/`, `skills/` (skills imported from GitHub).
116
174
  - Nothing leaves your machine except through the bots' own conversations (your configured model), the
117
- apps you connect, the image model when you generate an avatar, and GitHub when you import skills.
175
+ apps you connect, the image model when you generate an avatar, GitHub when you import skills, and the
176
+ Telegram or Discord API when you connect a chat app (the bots' replies to paired people, typing
177
+ indicators, and the one-line note to strangers).
118
178
 
119
179
  ## Install
120
180
 
package/README.zh-CN.md CHANGED
@@ -68,7 +68,7 @@ Bot 就是一个普通的 Harness 会话,所以 Harness 能做的它都能做
68
68
  | 分类 | 应用(🔑 = 需要 Key) |
69
69
  | --- | --- |
70
70
  | 销售与收款 | Stripe 收款 🔑、HubSpot 客户管理 🔑 |
71
- | 团队与办公 | 飞书 🔑、Notion 🔑、Slack 🔑、长期记忆 |
71
+ | 团队与办公 | Telegram 🔑、Discord 🔑(聊天应用,见下文)、飞书 🔑、Notion 🔑、Slack 🔑、长期记忆 |
72
72
  | 研发与交付 | GitHub 🔑、Git 仓库、Supabase 🔑、Sentry 🔑、Context7 文档 |
73
73
  | 调研与内容 | Exa、Tavily 🔑、Brave 🔑、Firecrawl 🔑 |
74
74
  | 电脑与浏览器 | Open Computer Use(操控 macOS 应用)、Playwright 浏览器 |
@@ -78,6 +78,54 @@ Bot 就是一个普通的 Harness 会话,所以 Harness 能做的它都能做
78
78
 
79
79
  - **定时任务**:就是 Harness 的定时任务,也出现在「自动化」页面;
80
80
  - **AI 头像**:装了 [图片插件](../images) 就能按 bot 的人设生成头像。
81
+ - **图标**:应用库里每个应用都用它自己的官方 logo(有 App 的用 App Store 图标,没有的用官网或官方仓库里的 logo)。
82
+ 这些 logo 是各自所有者的商标,只用来标明是哪个服务。
83
+
84
+ ## 在 Telegram 或 Discord 里给团队发消息
85
+
86
+ 在某个 bot(一般是调度员)的**应用**页加上 **Telegram** 或 **Discord**,就能用手机派活:你发给聊天 Bot 的话,
87
+ 会像在面板里输入一样交给团队;回复会回到聊天里,包括队友回复之后调度员的汇总汇报。
88
+
89
+ > **你(在 Telegram 里)**:把下周的发布安排一下。
90
+ >
91
+ > **Atlas**:收到:Forge 处理三个 P1 bug,Echo 起草发布文案。
92
+ >
93
+ > **Atlas**(稍后):bug 已修好并合并;发布文案已备好,等你过目。
94
+
95
+ ### Telegram
96
+
97
+ 1. 在 Telegram 里打开 [@BotFather](https://t.me/BotFather),发送 `/newbot`,起一个名字和以 `bot` 结尾的用户名。
98
+ 请专门给这个团队新建一个 Bot。
99
+ 2. 在 Bots 里打开调度员 → **应用** → **Telegram** → 粘贴 BotFather 给你的 Token → **添加**。
100
+ 它会立刻连接,显示**已连接:@你的bot**。
101
+ 3. 配对你自己:面板上会显示一个一次性配对码(10 分钟内有效,只能用一次)。点**在 Telegram 中打开**再点
102
+ **Start**,或者直接把配对码发给你的 Bot。Bot 回复「配对成功」。
103
+ 4. 给 Bot 发消息即可。消息以 `@handle` 开头可以直接找其他 bot(例如 `@forge 修一下登录 bug`)。
104
+ 在群里,把 Bot 拉进群并 @ 它(或回复它);群里的其他对话它一概不理。
105
+
106
+ ### Discord
107
+
108
+ 1. 在 [开发者后台](https://discord.com/developers/applications):**New Application** → **Bot** → **Reset Token**,复制 Token。
109
+ 在同一页打开 **Message Content Intent**(不开就读不到消息,面板也会提示)。
110
+ 2. 用这个 Token 给调度员添加 **Discord**。连上后点**把 Bot 邀请进你所在的服务器**(任何你在的服务器都行,私人服务器也可以):
111
+ Discord 只允许你私信和你同在一个服务器的 Bot。
112
+ 3. 私信 Bot 发送配对码,之后直接私信它派活,或在频道里 @ 它。
113
+
114
+ ### 其他须知
115
+
116
+ - **谁能和它说话**:只有你配对过的人。其他人一律忽略;在私聊里最多每天收到一句「这是私人 Bot」。
117
+ 配对只能在私聊里用当前配对码完成,猜错几次就会被锁定,直到生成新码。可以配对多个人(每人需要一个新码),
118
+ 也可以在面板里移除任何人;面板还会统计被忽略的消息数。
119
+ - **配对等同于你自己的登录**:配对的人能让 bot 做你能做的任何事,包括它们的能力和应用在这台 Mac 上允许的操作。
120
+ 只配对你自己或你信任的人;如果配对了别人,请在拥有该聊天应用的 bot 上关掉有风险的能力。
121
+ - **回复发到哪里**:发到你最近一次请求来自的那个聊天。在面板里发消息,对话就回到面板。
122
+ Telegram 收到纯文本(去掉 Markdown 标记);Discord 保留 Markdown。
123
+ - **定时汇报**:拥有聊天应用的 bot 的定时任务会把结果发给第一个配对的人(可在面板里关闭),
124
+ 于是「工作日早上九点 Atlas 给你做简报」会直接出现在你手机上。
125
+ - **一个 Token 只能在一处使用**:同一个聊天 Bot Token 同时只能连在一个 Harness 的一个 bot 上。
126
+ 如果有别的程序在用同一个 Telegram Token,面板会提示。
127
+ - Token 和其他应用的 Key 一样保存在 bot 里,面板里不会再显示出来,也不会出现在日志和错误信息里。
128
+ Harness 运行时 Bot 才会回复;Telegram 最多替你保存 24 小时内的消息,重启后同一条消息不会被执行两次。
81
129
 
82
130
  ## 原理
83
131
 
@@ -86,6 +134,8 @@ Bot 就是一个普通的 Harness 会话,所以 Harness 能做的它都能做
86
134
  修改即时生效;新增或修改应用在下次会话启动时连接。
87
135
  - `bot_send_message` 把消息放进对方的收件箱并唤醒它;同一对 bot 10 分钟内最多互发 16 条,防止无限对话。
88
136
  - 所有会话都能用 `bot_list`、`bot_create`、`bot_update`、`bot_delete`、`bot_send_message`、`bot_schedule` 管理 bot。
137
+ - 聊天应用不是 MCP 服务:Host 为每个 Telegram / Discord 应用保持一个连接(Telegram 用长轮询,Discord 用 Gateway),
138
+ 随你添加、修改、关闭或删除应用而启动和停止,并把配对者的消息作为用户提示交给 bot,开头标着 `[Telegram · 名字]`。
89
139
 
90
140
  ## Open Computer Use
91
141
 
@@ -94,8 +144,10 @@ Bot 就是一个普通的 Harness 会话,所以 Harness 能做的它都能做
94
144
 
95
145
  ## 存储与外发
96
146
 
97
- - `~/.dsh/cache/bots/`:`bots.json`(bot,含应用里填的 Key)、`messages.jsonl`(时间线)、`avatars/`、`skills/`(从 GitHub 导入的技能)。
98
- - 除了 bot 自身会话(你配置的模型)、你连接的应用、生成头像时的图片模型、导入技能时访问 GitHub,不向外发送任何内容。
147
+ - `~/.dsh/cache/bots/`:`bots.json`(bot,含应用里填的 Key 和聊天 Bot Token)、`messages.jsonl`(时间线)、
148
+ `channels.json`(每个聊天应用的配对者,以及每个聊天处理过的最后一条消息)、`avatars/`、`skills/`(从 GitHub 导入的技能)。
149
+ - 除了 bot 自身会话(你配置的模型)、你连接的应用、生成头像时的图片模型、导入技能时访问 GitHub,
150
+ 以及连接聊天应用后访问 Telegram / Discord 的 API(给配对者的回复、正在输入提示、给陌生人的那一句提示),不向外发送任何内容。
99
151
 
100
152
  ## 安装
101
153
 
package/client.js CHANGED
@@ -1112,7 +1112,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
1112
1112
  );
1113
1113
  }
1114
1114
  const prev = items[i - 1];
1115
- const grouped = prev && prev.from === m.from && prev.to === m.to && prev.kind === m.kind && at - toMs(prev.at) < 5 * 60_000;
1115
+ const grouped = prev && prev.from === m.from && prev.to === m.to && prev.kind === m.kind && prev.via === m.via && at - toMs(prev.at) < 5 * 60_000;
1116
1116
  rows.push(h(MessageRow, { key: m.id ?? i, t, m, botId, grouped }));
1117
1117
  });
1118
1118
  return h('div', { style: { display: 'flex', flexDirection: 'column', gap: 4, padding: '8px 0', maxWidth: 880, margin: '0 auto' } }, rows, h('div', { ref: end }));
@@ -1152,7 +1152,14 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
1152
1152
  return h(
1153
1153
  'div',
1154
1154
  { 'data-dsh-bots-msg': 'user', className: 'dshb-fade', style: { display: 'flex', flexDirection: 'column', alignItems: 'flex-end', gap: 3, marginTop: grouped ? 0 : 6 } },
1155
- grouped ? null : h('span', { style: { fontSize: TINY, color: C.faint } }, m.to !== botId && to.kind === 'bot' ? `${t('toName', { name: to.name })} · ${time}` : time),
1155
+ grouped
1156
+ ? null
1157
+ : h(
1158
+ 'span',
1159
+ { style: { fontSize: TINY, color: C.faint, display: 'inline-flex', alignItems: 'center', gap: 6 } },
1160
+ m.via ? h(Badge, { color: CHANNEL_COLORS[m.via] ?? C.muted, 'data-dsh-bots-via': m.via }, t('viaChannel', { app: channelName(m.via), who: str(m.who) || t('you') })) : null,
1161
+ m.to !== botId && to.kind === 'bot' ? `${t('toName', { name: to.name })} · ${time}` : time,
1162
+ ),
1156
1163
  h('div', { style: { maxWidth: '78%', padding: '8px 12px', borderRadius: '14px 14px 4px 14px', background: C.label, color: '#fff', fontSize: FONT } }, h(Clamp, { t, text: m.text, lines: 14, light: true })),
1157
1164
  h('div', { style: { width: 'min(480px, 78%)', display: 'flex', justifyContent: 'flex-end' } }, h(LinkCards, { t, text: m.text, align: 'flex-end' })),
1158
1165
  );
@@ -1173,6 +1180,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
1173
1180
  from.kind === 'bot' ? h('span', { style: { color: C.faint } }, `@${from.bot.handle}`) : null,
1174
1181
  m.to !== 'user' && to.kind === 'bot' && m.to !== botId ? h('span', { style: { color: C.faint } }, `→ ${to.name}`) : null,
1175
1182
  h('span', { style: { color: C.faint } }, time),
1183
+ m.via ? h(Badge, { color: CHANNEL_COLORS[m.via] ?? C.muted, title: t('sentToChannel', { app: channelName(m.via) }), 'data-dsh-bots-via': m.via }, `→ ${channelName(m.via)}`) : null,
1176
1184
  ),
1177
1185
  h('div', { style: { padding: '8px 12px', borderRadius: '4px 14px 14px 14px', background: C.layer2, border: `1px solid ${C.border1}`, fontSize: FONT, minWidth: 0 } }, h(Clamp, { t, text: m.text, lines: 24 })),
1178
1186
  h(LinkCards, { t, text: m.text }),
@@ -1866,6 +1874,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
1866
1874
  h('span', { style: { color: C.faint, display: 'inline-flex' } }, Icon.arrow(11)),
1867
1875
  h('span', { style: { fontWeight: 600 } }, to.name),
1868
1876
  h(Badge, { color: m.kind === 'dm' ? C.label : m.kind === 'system' ? C.warn : C.muted }, t(`kind_${m.kind}`) || m.kind),
1877
+ m.via ? h(Badge, { color: CHANNEL_COLORS[m.via] ?? C.muted, 'data-dsh-bots-via': m.via }, m.from === 'user' && m.who ? `${channelName(m.via)} · ${str(m.who)}` : channelName(m.via)) : null,
1869
1878
  h('span', { style: { marginLeft: 'auto', color: C.faint, fontSize: TINY }, title: fmtDate(toMs(m.at)) }, fmtAgo(t, m.at)),
1870
1879
  ),
1871
1880
  h(Clamp, { t, text: m.text, lines: 3, style: { fontSize: SMALL, color: C.muted } }),
@@ -2462,7 +2471,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2462
2471
  },
2463
2472
  style: { flex: '1 1 260px', flexDirection: 'row', alignItems: 'center', gap: 12, cursor: 'pointer', textAlign: 'left', font: 'inherit', color: 'inherit', background: `linear-gradient(135deg, ${tint('#d97706', 10)}, ${C.layer1} 70%)` },
2464
2473
  },
2465
- h(AppIcon, { entry: { icon: 'A', color: '#c2410c' }, size: 38 }),
2474
+ h(AppIcon, { entry: { icon: 'A', color: '#c2410c', logo: src.logo }, size: 38 }),
2466
2475
  h(
2467
2476
  'span',
2468
2477
  { style: { display: 'flex', flexDirection: 'column', gap: 2, minWidth: 0, flex: 1 } },
@@ -2954,8 +2963,31 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2954
2963
  return n;
2955
2964
  }
2956
2965
 
2957
- /** A coloured rounded square with the app's letters (or one CJK character) in white. */
2966
+ /** The app's logo, or a coloured rounded square with its letters (or one CJK character) in white. */
2958
2967
  function AppIcon({ entry, size = 36 }) {
2968
+ const logo = str(entry?.logo);
2969
+ const [broken, setBroken] = useState('');
2970
+ if (logo && broken !== logo) {
2971
+ return h(
2972
+ 'span',
2973
+ {
2974
+ 'data-dsh-bots-app-icon': entry?.id ?? true,
2975
+ 'data-dsh-bots-app-logo': logo,
2976
+ style: {
2977
+ width: size,
2978
+ height: size,
2979
+ borderRadius: Math.round(size * 0.26),
2980
+ display: 'inline-flex',
2981
+ flex: 'none',
2982
+ overflow: 'hidden',
2983
+ background: '#fff',
2984
+ boxShadow: '0 0 0 1px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.12)',
2985
+ userSelect: 'none',
2986
+ },
2987
+ },
2988
+ h('img', { src: `${R}logo/${encodeURIComponent(logo)}.png`, alt: '', draggable: false, onError: () => setBroken(logo), style: { width: '100%', height: '100%', display: 'block', objectFit: 'cover' } }),
2989
+ );
2990
+ }
2959
2991
  const icon = str(entry?.icon) || '?';
2960
2992
  const color = str(entry?.color) || '#475569';
2961
2993
  const n = [...icon].length;
@@ -2991,6 +3023,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2991
3023
  const RUNTIME_WORD = { node: 'npx', uv: 'uvx' };
2992
3024
  function runtimeLabel(t, entry) {
2993
3025
  if (!entry) return '';
3026
+ if (isChannelEntry(entry)) return t('chatChannel');
2994
3027
  if (entry.transport === 'streamable-http') return t('runtimeRemote');
2995
3028
  return RUNTIME_WORD[entry.runtime] ?? (entry.runtime === 'binary' ? t('runtimeBinary') : str(entry.command));
2996
3029
  }
@@ -3004,6 +3037,120 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
3004
3037
  }
3005
3038
  return out;
3006
3039
  }
3040
+ // --- chat channels (Telegram, Discord): apps people message the team from -----------------
3041
+
3042
+ const CHANNEL_NAMES = { telegram: 'Telegram', discord: 'Discord' };
3043
+ const CHANNEL_COLORS = { telegram: '#229ED9', discord: '#5865F2' };
3044
+ const channelName = (kind) => CHANNEL_NAMES[kind] ?? str(kind);
3045
+ const isChannelEntry = (entry) => entry?.kind === 'channel';
3046
+
3047
+ /** Under a chat channel's row: whether it is connected, the pairing code, and who is paired. */
3048
+ function ChannelPanel({ t, bot, app, entry, view, toast }) {
3049
+ const [working, setWorking] = useState('');
3050
+ const v = view && typeof view === 'object' ? view : { state: 'connecting', paired: [] };
3051
+ const kind = str(v.kind || entry?.channel);
3052
+ const appName = channelName(kind);
3053
+ const handle = v.account?.username ? `@${v.account.username}` : appName;
3054
+ const paired = Array.isArray(v.paired) ? v.paired : [];
3055
+ const call = (path, body, okText) => {
3056
+ setWorking(path);
3057
+ return postJson(path, { botId: bot.id, appId: app.id, ...body })
3058
+ .then((r) => {
3059
+ if (r?.ok) {
3060
+ if (okText) toast(okText);
3061
+ void refreshState();
3062
+ } else toast(r?.reason || t('actionFailed'), 'error');
3063
+ return r;
3064
+ })
3065
+ .finally(() => setWorking(''));
3066
+ };
3067
+ const state = str(v.state) || 'connecting';
3068
+ const hintText = v.hint ? t(`channelHint_${v.hint}`, { app: appName }) : '';
3069
+ const dot = (color) => h('span', { style: { width: 8, height: 8, borderRadius: '50%', background: color, flex: 'none' } });
3070
+ const statusLine =
3071
+ state === 'connected'
3072
+ ? [dot(C.ok), h('span', { key: 's', style: { fontWeight: 600 } }, t('channelConnected', { handle }))]
3073
+ : state === 'connecting'
3074
+ ? [h('span', { key: 'sp', className: 'dshb-spinner', style: { width: 12, height: 12 } }), h('span', { key: 's' }, t('channelConnecting', { app: appName }))]
3075
+ : state === 'error'
3076
+ ? [h('span', { key: 'i', style: { color: C.error, display: 'inline-flex' } }, Icon.alert(13)), h('span', { key: 's', style: { color: C.error, fontWeight: 600 } }, hintText || str(v.detail) || t('channelError'))]
3077
+ : state === 'off'
3078
+ ? [dot(C.faint), h('span', { key: 's', style: { color: C.muted } }, t('channelOff'))]
3079
+ : [dot('#d97706'), h('span', { key: 's', style: { color: C.muted } }, t('channelMissing', { app: appName }))];
3080
+ const live = state !== 'off' && state !== 'missing';
3081
+ const step = kind === 'telegram' ? t('pairStepTelegram', { handle }) : kind === 'discord' ? t('pairStepDiscord', { handle }) : t('pairStep', { handle, app: appName });
3082
+ return h(
3083
+ 'div',
3084
+ { 'data-dsh-bots-channel': app.id, 'data-state': state, style: { display: 'flex', flexDirection: 'column', gap: 10, margin: '0 14px 12px 62px', padding: '10px 12px', borderRadius: 10, background: C.base, border: `1px solid ${C.border1}`, fontSize: SMALL } },
3085
+ h(
3086
+ 'div',
3087
+ { 'data-dsh-bots-channel-status': state, style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' }, title: str(v.detail) || undefined },
3088
+ statusLine,
3089
+ h('span', { style: { flex: 1 } }),
3090
+ state === 'error' || state === 'connecting'
3091
+ ? h(Btn, { size: 'sm', kind: 'ghost', icon: Icon.refresh(12), disabled: Boolean(working), onClick: () => void call('channels/reconnect', {}), 'data-dsh-bots-channel-reconnect': app.id }, t('reconnect'))
3092
+ : null,
3093
+ ),
3094
+ state === 'error' && hintText && v.detail ? h('div', { style: { fontSize: TINY, color: C.faint, marginTop: -6 } }, str(v.detail)) : null,
3095
+ live
3096
+ ? h(
3097
+ 'div',
3098
+ { style: { display: 'flex', flexDirection: 'column', gap: 6 } },
3099
+ h('div', { style: { fontSize: TINY, fontWeight: 700, color: C.muted, textTransform: 'uppercase', letterSpacing: '.02em' } }, t('pairedPeople', { n: paired.length })),
3100
+ paired.length === 0
3101
+ ? h('div', { style: { color: C.faint } }, t('nobodyPaired', { app: appName }))
3102
+ : paired.map((p, i) =>
3103
+ h(
3104
+ 'div',
3105
+ { key: p.id, 'data-dsh-bots-paired': p.id, style: { display: 'flex', alignItems: 'center', gap: 8 } },
3106
+ h('span', { style: { color: C.muted, display: 'inline-flex' } }, Icon.user(13)),
3107
+ h('span', { style: { fontWeight: 600 } }, str(p.name) || str(p.id)),
3108
+ i === 0 ? h(Badge, { color: C.muted }, t('pairedFirst')) : null,
3109
+ h('span', { style: { color: C.faint, fontSize: TINY } }, t('pairedSince', { when: fmtDate(toMs(p.at)) })),
3110
+ h('span', { style: { flex: 1 } }),
3111
+ h(Btn, { size: 'sm', kind: 'ghost', className: 'dshb-btn dshb-btn-sm dshb-btn-ghost dshb-btn-danger', disabled: Boolean(working), onClick: () => void call('channels/unpair', { userId: p.id }, t('unpaired', { name: str(p.name) })), 'data-dsh-bots-unpair': p.id }, t('remove')),
3112
+ ),
3113
+ ),
3114
+ )
3115
+ : null,
3116
+ live && v.code
3117
+ ? h(
3118
+ 'div',
3119
+ { 'data-dsh-bots-pairing': app.id, style: { display: 'flex', flexDirection: 'column', gap: 6, padding: '8px 10px', borderRadius: 9, background: tint(CHANNEL_COLORS[kind] ?? C.label, 8), border: `1px solid ${tint(CHANNEL_COLORS[kind] ?? C.label, 25)}` } },
3120
+ h('div', { style: { color: C.muted, lineHeight: 1.5 } }, step),
3121
+ h(
3122
+ 'div',
3123
+ { style: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' } },
3124
+ h('span', { className: 'dshb-mono', 'data-dsh-bots-pair-code': str(v.code.code), style: { fontSize: 20, fontWeight: 700, letterSpacing: '.18em', color: C.primary } }, str(v.code.code)),
3125
+ h(Btn, { size: 'sm', kind: 'ghost', onClick: () => (copyText(kind === 'telegram' ? `/start ${v.code.code}` : str(v.code.code)), toast(t('copied'))) }, t('copy')),
3126
+ v.link ? h(ExtLink, { href: v.link, 'data-dsh-bots-pair-link': true }, t('openIn', { app: appName })) : null,
3127
+ h('span', { style: { flex: 1 } }),
3128
+ h('span', { style: { fontSize: TINY, color: C.faint } }, t('codeExpires', { when: fmtAgo(t, v.code.expiresAt) })),
3129
+ h(Btn, { size: 'sm', disabled: Boolean(working), onClick: () => void call('channels/code', {}), 'data-dsh-bots-new-code': app.id }, t('newCode')),
3130
+ ),
3131
+ )
3132
+ : live
3133
+ ? h(
3134
+ 'div',
3135
+ { style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
3136
+ h(Btn, { size: 'sm', kind: paired.length ? 'default' : 'primary', icon: Icon.plus(12), disabled: Boolean(working) || state !== 'connected', onClick: () => void call('channels/code', {}), 'data-dsh-bots-new-code': app.id }, paired.length ? t('pairAnother') : t('pairSomeone')),
3137
+ state !== 'connected' ? h('span', { style: { fontSize: TINY, color: C.faint } }, t('pairWhenConnected')) : null,
3138
+ )
3139
+ : null,
3140
+ live && v.invite ? h('div', null, h(ExtLink, { href: v.invite, 'data-dsh-bots-invite': true }, t('inviteDiscord'))) : null,
3141
+ live && paired.length
3142
+ ? h(
3143
+ 'div',
3144
+ { style: { display: 'flex', alignItems: 'center', gap: 8 } },
3145
+ h(Switch, { on: v.scheduleReplies !== false, disabled: Boolean(working), title: t('channelSchedules', { name: str(paired[0].name), app: appName }), onChange: (on) => void call('channels/options', { scheduleReplies: on }), 'data-dsh-bots-channel-schedules': app.id }),
3146
+ h('span', { style: { color: C.muted } }, t('channelSchedules', { name: str(paired[0].name), app: appName })),
3147
+ )
3148
+ : null,
3149
+ live && v.ignored?.count ? h('div', { 'data-dsh-bots-ignored': v.ignored.count, style: { fontSize: TINY, color: C.faint } }, t('channelIgnored', { n: v.ignored.count, name: str(v.ignored.lastName) })) : null,
3150
+ h('div', { style: { fontSize: TINY, color: C.faint, lineHeight: 1.5 } }, t('channelPrivate', { app: appName })),
3151
+ );
3152
+ }
3153
+
3007
3154
  const missingFields = (entry, values) => (entry?.fields ?? []).filter((f) => f.required && str(values?.[f.key]).trim() === '').map((f) => f.key);
3008
3155
  const needsForm = (entry) => (entry?.fields ?? []).some((f) => f.required);
3009
3156
 
@@ -3151,10 +3298,11 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
3151
3298
  const entry = entryOf(app);
3152
3299
  const issue = str(issues[app.id]);
3153
3300
  const custom = !entry || entry.custom;
3301
+ const channel = isChannelEntry(entry);
3154
3302
  const detail = custom ? (isHttp(app, entry) ? str(app.config?.url) : [app.config?.command, ...(app.config?.args ?? [])].filter(Boolean).join(' ')) : pick(entry.description, lang);
3155
- return h(
3303
+ const row = h(
3156
3304
  'div',
3157
- { key: app.id, 'data-dsh-bots-app': app.id, style: { display: 'flex', alignItems: 'center', gap: 12, padding: '11px 14px', borderTop: i ? `1px solid ${C.border1}` : 'none', opacity: app.enabled === false ? 0.6 : 1 } },
3305
+ { key: app.id, 'data-dsh-bots-app': app.id, style: { display: 'flex', alignItems: 'center', gap: 12, padding: '11px 14px', borderTop: i && !channel ? `1px solid ${C.border1}` : 'none', opacity: app.enabled === false ? 0.6 : 1 } },
3158
3306
  h(AppIcon, { entry: entry ?? { icon: '{ }', color: '#475569' }, size: 36 }),
3159
3307
  h(
3160
3308
  'div',
@@ -3163,7 +3311,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
3163
3311
  'div',
3164
3312
  { style: { display: 'flex', alignItems: 'center', gap: 8, minWidth: 0, flexWrap: 'wrap' } },
3165
3313
  h('span', { style: { fontWeight: 600 } }, nameOf(app, entry)),
3166
- h('span', { className: 'dshb-mono', style: { fontSize: 11.5, color: C.faint } }, `mcp__${app.serverName}__*`),
3314
+ channel ? h(Badge, { color: entry.color || C.label }, Icon.chat(10), t('chatChannel')) : h('span', { className: 'dshb-mono', style: { fontSize: 11.5, color: C.faint } }, `mcp__${app.serverName}__*`),
3167
3315
  issue ? h(Badge, { color: '#d97706', title: issue, 'data-dsh-bots-app-issue': app.id }, Icon.alert(11), t('needsSetup')) : null,
3168
3316
  ),
3169
3317
  issue
@@ -3174,6 +3322,13 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
3174
3322
  h(Btn, { size: 'sm', kind: issue ? 'primary' : 'default', icon: Icon.edit(12), onClick: () => configure(app), 'data-dsh-bots-configure': app.id }, t('configure')),
3175
3323
  h(Btn, { size: 'sm', kind: 'ghost', icon: Icon.trash(12), title: t('remove'), className: 'dshb-btn dshb-btn-sm dshb-btn-icon dshb-btn-ghost dshb-btn-danger', onClick: () => setConfirm(app) }),
3176
3324
  );
3325
+ if (!channel) return row;
3326
+ return h(
3327
+ 'div',
3328
+ { key: app.id, style: { borderTop: i ? `1px solid ${C.border1}` : 'none' } },
3329
+ row,
3330
+ h(ChannelPanel, { t, bot, app, entry, view: bot.channels?.[app.id], toast }),
3331
+ );
3177
3332
  }),
3178
3333
  ),
3179
3334
  ),
@@ -3332,7 +3487,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
3332
3487
  h(
3333
3488
  'div',
3334
3489
  { style: { display: 'flex', alignItems: 'center', gap: 10, marginTop: 'auto' } },
3335
- entry.keyUrl ? h(ExtLink, { href: entry.keyUrl }, t('getKey')) : entry.homepage ? h(ExtLink, { href: entry.homepage, style: { color: C.faint } }, t('docs')) : null,
3490
+ entry.keyUrl ? h(ExtLink, { href: entry.keyUrl }, isChannelEntry(entry) ? t('createChatBot') : t('getKey')) : entry.homepage ? h(ExtLink, { href: entry.homepage, style: { color: C.faint } }, t('docs')) : null,
3336
3491
  h('span', { style: { flex: 1 } }),
3337
3492
  h(
3338
3493
  Btn,
@@ -3399,6 +3554,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
3399
3554
  const fields = Array.isArray(entry.fields) ? entry.fields : [];
3400
3555
  const setV = (key, v) => onChange({ ...value, values: { ...value.values, [key]: v } });
3401
3556
  const missing = missingFields(entry, value.values);
3557
+ const channel = isChannelEntry(entry);
3402
3558
  const sErr = value.serverName && !SERVER_RE.test(value.serverName) ? t('serverNameInvalid') : '';
3403
3559
  return h(
3404
3560
  Modal,
@@ -3408,7 +3564,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
3408
3564
  width: 560,
3409
3565
  onClose,
3410
3566
  footer: [
3411
- h('span', { key: 'n', style: { flex: 1, fontSize: TINY, color: C.faint, alignSelf: 'center' } }, t('appsNote')),
3567
+ h('span', { key: 'n', style: { flex: 1, fontSize: TINY, color: C.faint, alignSelf: 'center' } }, channel ? t('channelSaveNote') : t('appsNote')),
3412
3568
  h(Btn, { key: 'c', onClick: onClose }, t('cancel')),
3413
3569
  h(Btn, { key: 's', kind: 'primary', disabled: busy || missing.length > 0 || Boolean(sErr), onClick: onSave, 'data-dsh-bots-app-save': true }, busy ? t('saving') : app ? t('save') : t('add')),
3414
3570
  ],
@@ -3421,9 +3577,10 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
3421
3577
  'div',
3422
3578
  { style: { flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 4 } },
3423
3579
  h('div', { style: { fontSize: SMALL, color: C.muted, lineHeight: 1.55 } }, pick(entry.description, lang)),
3424
- h('div', { style: { display: 'flex', gap: 14, flexWrap: 'wrap' } }, h(ExtLink, { href: entry.homepage }, t('docs')), h(ExtLink, { href: entry.keyUrl }, t('getKey'))),
3580
+ h('div', { style: { display: 'flex', gap: 14, flexWrap: 'wrap' } }, h(ExtLink, { href: entry.homepage }, t('docs')), h(ExtLink, { href: entry.keyUrl }, channel ? t('createChatBot') : t('getKey'))),
3425
3581
  ),
3426
3582
  ),
3583
+ channel ? h('div', { 'data-dsh-bots-channel-how': entry.id, style: { fontSize: SMALL, color: C.muted, lineHeight: 1.6, padding: '9px 11px', borderRadius: 9, background: tint(entry.color || C.label, 8) } }, t('channelHow', { app: pick(entry.name, lang) })) : null,
3427
3584
  fields.length === 0 ? h('div', { style: { fontSize: SMALL, color: C.faint } }, t('noSettings')) : null,
3428
3585
  fields.map((f) => {
3429
3586
  const v = str(value.values[f.key]);
@@ -3452,7 +3609,9 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
3452
3609
  else control = h(Input, { ...common, mono: f.kind === 'path' });
3453
3610
  return h(Field, { key: f.key, label, hint: pick(f.help, lang) || (f.kind === 'path' && !f.multi ? t('pathHint') : '') }, control);
3454
3611
  }),
3455
- h(
3612
+ channel
3613
+ ? null
3614
+ : h(
3456
3615
  'details',
3457
3616
  { style: { fontSize: SMALL, color: C.muted } },
3458
3617
  h('summary', { style: { cursor: 'pointer', userSelect: 'none' } }, t('advanced')),
@@ -4759,7 +4918,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
4759
4918
  installedApps: 'Installed apps ({n})',
4760
4919
  noApps: 'No apps yet. Add one from the gallery below.',
4761
4920
  appGallery: 'App gallery',
4762
- appGalleryHint: '{n} apps. Apps are MCP servers; their tools appear to this bot only.',
4921
+ appGalleryHint: '{n} apps. Most are MCP servers whose tools appear to this bot only; chat apps (Telegram, Discord) let you message the team from your phone.',
4763
4922
  noTemplates: 'No templates.',
4764
4923
  featured: 'Featured',
4765
4924
  allApps: 'All',
@@ -4946,6 +5105,43 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
4946
5105
  suggest_b1: "Introduce yourself: what can you do for me, and what do you need from me?",
4947
5106
  suggest_b2: "Look at what is on your plate and suggest the first thing to do today.",
4948
5107
  suggest_b3: "Show me which of your skills and apps are ready, and which still need setup.",
5108
+ // chat channels
5109
+ chatChannel: 'chat app',
5110
+ createChatBot: 'Create a bot',
5111
+ channelHow: 'Add it to your dispatcher. Once it connects, pair yourself with the one-time code shown here; then message the bot in {app} to hand out work, and the replies come back to the chat.',
5112
+ channelSaveNote: 'It connects as soon as you save.',
5113
+ channelConnected: 'Connected as {handle}',
5114
+ channelConnecting: 'Connecting to {app}…',
5115
+ channelError: 'Not connected',
5116
+ channelOff: 'Off. Turn it on to connect.',
5117
+ channelMissing: 'Paste the bot token to connect to {app}.',
5118
+ channelHint_token: '{app} rejected the bot token. Copy it again and save.',
5119
+ channelHint_intent: 'Turn on Message Content Intent: Developer Portal → your app → Bot → Privileged Gateway Intents. Then reconnect.',
5120
+ channelHint_conflict: 'Another program is using this bot token. Stop it, or create a separate bot for the team.',
5121
+ channelHint_duplicate: 'This token is already connected on another bot; one token can run in one place.',
5122
+ reconnect: 'Reconnect',
5123
+ pairedPeople: 'Paired people ({n})',
5124
+ nobodyPaired: 'Nobody yet. Until someone is paired, the bot answers no one in {app}.',
5125
+ pairedFirst: 'gets scheduled reports',
5126
+ pairedSince: 'since {when}',
5127
+ unpaired: '{name} removed.',
5128
+ pairStepTelegram: 'From your own Telegram account, send this code to {handle}, or open the link and press Start. It works once.',
5129
+ pairStepDiscord: 'From your own Discord account, send this code to {handle} in a direct message. It works once.',
5130
+ pairStep: 'From your own {app} account, send this code to {handle}. It works once.',
5131
+ copy: 'Copy',
5132
+ copied: 'Copied.',
5133
+ openIn: 'Open in {app}',
5134
+ codeExpires: 'expires {when}',
5135
+ newCode: 'New code',
5136
+ pairSomeone: 'Pair yourself',
5137
+ pairAnother: 'Pair another person',
5138
+ pairWhenConnected: 'Pairing starts once it is connected.',
5139
+ inviteDiscord: 'Invite the bot to a server you are in (needed before you can DM it)',
5140
+ channelSchedules: 'Scheduled reports also go to {name} in {app}',
5141
+ channelIgnored: 'Ignored {n} messages from people who are not paired (last: {name}).',
5142
+ channelPrivate: 'Only paired people reach the team. Anyone else is ignored (at most a one-line "this bot is private" a day). In a group the bot only answers when @mentioned or replied to.',
5143
+ viaChannel: '{app} · {who}',
5144
+ sentToChannel: 'Also sent to {app}',
4949
5145
  },
4950
5146
  zh: {
4951
5147
  lang: 'zh',
@@ -5204,7 +5400,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
5204
5400
  installedApps: '已安装的应用({n})',
5205
5401
  noApps: '还没有应用。从下方的应用库添加一个。',
5206
5402
  appGallery: '应用库',
5207
- appGalleryHint: '共 {n} 个应用。应用就是 MCP 服务器,它们的工具只对这个 Bot 可见。',
5403
+ appGalleryHint: '共 {n} 个应用。大多是 MCP 服务器,工具只对这个 Bot 可见;聊天应用(Telegram、Discord)让你用手机给团队发消息。',
5208
5404
  noTemplates: '没有模板。',
5209
5405
  featured: '推荐',
5210
5406
  allApps: '全部',
@@ -5390,6 +5586,43 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
5390
5586
  suggest_b1: "介绍一下你自己:你能帮我做什么?需要我提供什么?",
5391
5587
  suggest_b2: "看看你手上有什么事,建议今天先做哪一件。",
5392
5588
  suggest_b3: "告诉我你的技能和应用哪些已经可用,哪些还需要配置。",
5589
+ // chat channels
5590
+ chatChannel: '聊天应用',
5591
+ createChatBot: '创建 Bot',
5592
+ channelHow: '把它加到调度者身上。连上以后,用这里显示的一次性配对码把你自己配对上;之后在 {app} 里给 Bot 发消息就能派活,回复会回到聊天里。',
5593
+ channelSaveNote: '保存后立即连接。',
5594
+ channelConnected: '已连接:{handle}',
5595
+ channelConnecting: '正在连接 {app}…',
5596
+ channelError: '未连接',
5597
+ channelOff: '已关闭。打开后才会连接。',
5598
+ channelMissing: '粘贴 Bot Token 后即可连接 {app}。',
5599
+ channelHint_token: '{app} 拒绝了这个 Bot Token。请重新复制并保存。',
5600
+ channelHint_intent: '请打开 Message Content Intent:开发者后台 → 你的应用 → Bot → Privileged Gateway Intents,然后重新连接。',
5601
+ channelHint_conflict: '另一个程序正在使用这个 Bot Token。请停掉它,或给团队单独建一个 Bot。',
5602
+ channelHint_duplicate: '这个 Token 已经在另一个 Bot 上连接了;一个 Token 只能在一处运行。',
5603
+ reconnect: '重新连接',
5604
+ pairedPeople: '已配对的人({n})',
5605
+ nobodyPaired: '还没有人。配对之前,Bot 在 {app} 里不回复任何人。',
5606
+ pairedFirst: '接收定时汇报',
5607
+ pairedSince: '配对于 {when}',
5608
+ unpaired: '已移除 {name}。',
5609
+ pairStepTelegram: '用你自己的 Telegram 账号把这个配对码发给 {handle},或打开链接后点 Start。只能用一次。',
5610
+ pairStepDiscord: '用你自己的 Discord 账号私信 {handle},发送这个配对码。只能用一次。',
5611
+ pairStep: '用你自己的 {app} 账号把这个配对码发给 {handle}。只能用一次。',
5612
+ copy: '复制',
5613
+ copied: '已复制。',
5614
+ openIn: '在 {app} 中打开',
5615
+ codeExpires: '{when}过期',
5616
+ newCode: '换一个',
5617
+ pairSomeone: '配对我自己',
5618
+ pairAnother: '再配对一个人',
5619
+ pairWhenConnected: '连接成功后才能配对。',
5620
+ inviteDiscord: '把 Bot 邀请进你所在的服务器(私信它之前必须先这样做)',
5621
+ channelSchedules: '定时汇报也发给 {app} 里的 {name}',
5622
+ channelIgnored: '忽略了 {n} 条未配对的人发来的消息(最近:{name})。',
5623
+ channelPrivate: '只有配对过的人能找到团队,其他人一律忽略(每天最多回一句“这是私人 Bot”)。在群里,只有 @ 它或回复它时才会回答。',
5624
+ viaChannel: '{app} · {who}',
5625
+ sentToChannel: '也已发到 {app}',
5393
5626
  },
5394
5627
  };
5395
5628