@kadaliao/dsh-bots 0.10.0 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kada Liao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -17,7 +17,7 @@ It is built for two situations:
17
17
  - **Work that is naturally split between roles**: code needs a builder, a tester and a reviewer; content
18
18
  needs a researcher, a writer and a designer; research needs a skeptic.
19
19
 
20
- ![Team templates](docs/en-teams.png)
20
+ ![Team templates](https://raw.githubusercontent.com/kadaliao/dsh-bots/main/docs/en-teams.png)
21
21
 
22
22
  ## Hire a whole team in one click
23
23
 
@@ -41,7 +41,7 @@ Hiring:
41
41
  - adds the team's scheduled tasks and makes its lead the dispatcher;
42
42
  - offers to send the lead a kickoff message, so the team starts working right away.
43
43
 
44
- ![Chat](docs/en-chat.png)
44
+ ![Chat](https://raw.githubusercontent.com/kadaliao/dsh-bots/main/docs/en-chat.png)
45
45
 
46
46
  ## An example (one-person company)
47
47
 
@@ -157,15 +157,21 @@ for you. You don't open tasks yourself: you ask the dispatcher (or any bot), and
157
157
  The dispatcher works in one of two ways, chosen under **How it works** on its **Profile** tab, for the whole team:
158
158
 
159
159
  - **Router** (the default): it understands the request, hands the work out and keeps track of it. It does not run
160
- commands, write or edit files, search the web, use sub-agents and workflows, draw images or make Office files; it can
161
- still read files and use its skills. Work that needs any of those goes to a teammate, never to itself (0.9 handed
162
- it to itself when no teammate fit; 0.10 doesn't), while its own conversation stays free for you. Its **Abilities** section marks what Router mode turns off, and **Turn
163
- back on** gives an ability back (even then it may not `sleep`, and a command must finish within 30 seconds or run in
164
- the background). It never waits for a teammate: it ends its turn and is woken when something needs it, so a new
160
+ commands, write or edit files, search the web, use sub-agents and workflows, draw images, make Office files or put
161
+ question cards to you (a card holds every message after it until you answer); it can still read files and use its
162
+ skills. Work that needs any of those goes to a teammate, never to itself (0.9 handed it to itself when no teammate
163
+ fit; 0.10 doesn't), while its own conversation stays free for you. When you say "ask me which tone before you
164
+ write", it hands the work out with that request and the teammate asks you in its task; when it must know something
165
+ itself before it can hand a request out, it asks in one line of its reply, and your next message is the answer. Its
166
+ **Abilities** section lists what Router mode turns off and marks it: switch a whole ability back on, or use **Turn
167
+ back on** for the part of one that is off (writing and editing under Files). Even then it may not `sleep`, a
168
+ command must finish within 30 seconds or run in the background, and with question cards back on it takes no new
169
+ message until a card is answered. It never waits for a teammate: it ends its turn and is woken when something needs it, so a new
165
170
  request is not stuck behind work in progress, and messages that arrive while it is busy are taken together at its
166
171
  next step, and each one gets its answer. Since it only routes, a light, fast model is enough for it; its **Model** section says so, and Bots does
167
172
  not change the model for you. In Router mode every bot that hands work to a teammate opens a task, not only the
168
- dispatcher.
173
+ dispatcher; but nobody opens one for the dispatcher: a teammate's message to it goes into its own conversation,
174
+ and it tells you what you should know and hands out what is work.
169
175
  - **Hands-on**: how 0.7 worked. The dispatcher also does small jobs itself, and a message from one bot's own
170
176
  conversation to another bot goes into that bot's own conversation instead of opening a task. Tasks already open keep
171
177
  going and report as before.
@@ -269,8 +275,10 @@ A bot works in ordinary Harness conversations, so everything Harness can do, a b
269
275
  | Maps & local | Amap 🔑, Baidu Maps 🔑 |
270
276
  | Custom | Any local (stdio) or remote (Streamable HTTP) MCP server |
271
277
 
272
- - **Schedules** are ordinary Harness scheduled tasks, also on the Automation page.
273
- - **AI avatars**: with the [Images plugin](../images), draw a bot's avatar from its persona. A bot can do it too:
278
+ - **Schedules** are ordinary Harness scheduled tasks, also on the Automation page. A scheduled task missed while
279
+ Harness was closed runs when it starts again, once (its latest occurrence): that is Harness's rule, and Bots adds
280
+ no runs of its own. A team with many schedules can open several tasks at once after a start, and use many tokens.
281
+ - **AI avatars**: with the [Images plugin](https://github.com/kadaliao/dsh-images), draw a bot's avatar from its persona. A bot can do it too:
274
282
  ask the dispatcher to give the team new avatars and describe the look, or point it at an image file. A bot's
275
283
  drawing runs in the background, so it goes on answering you: a ring turns around the avatar while the picture is
276
284
  drawn, the new one shows when it is ready, and the bot hears that it is ready (or why it failed) and tells you. A restart of
@@ -294,7 +302,7 @@ model's thinking levels when it has them. Besides the models Harness already has
294
302
  tokens, and neither signs the other out. Claude Code's login is shown but not offered: Anthropic allows a
295
303
  Claude subscription only in Claude Code and claude.ai, so add Claude with an API key instead.
296
304
 
297
- ![Model sources](docs/en-model-sources.png)
305
+ ![Model sources](https://raw.githubusercontent.com/kadaliao/dsh-bots/main/docs/en-model-sources.png)
298
306
 
299
307
  ## Topics: conversations that don't grow forever
300
308
 
@@ -328,7 +336,9 @@ Every bot keeps **notes** that outlast its topics, and the team shares one more
328
336
  lines and tasks of that task, the task that asked for it and its sub-tasks, and no digests.
329
337
  - **Every night** (03:00 by default) memory is **consolidated**: each bot's notes are merged, corrected
330
338
  and trimmed with its recent journal, the shared notes too, and the day's work is written up as the
331
- team's **daily digest**. **Consolidate now** runs it at once.
339
+ team's **daily digest**. **Consolidate now** runs it at once. Notes and digests are written in the
340
+ language you write to the bots in, judged from your recent messages; a note left in another language
341
+ is rewritten in it.
332
342
  - A bot reads its notes, the team notes, its last few journal lines and the latest digest when a topic
333
343
  or a task's conversation starts, and again at the next run after you edit memory or the nightly
334
344
  consolidation ran. Within a topic the memory part of its prompt stays the same, so the model's prompt
@@ -340,9 +350,9 @@ Every bot keeps **notes** that outlast its topics, and the team shares one more
340
350
  or token is never stored.
341
351
  - Memory work runs on each bot's own model unless Settings names a cheaper one.
342
352
 
343
- ![A bot's memory](docs/en-memory.png)
353
+ ![A bot's memory](https://raw.githubusercontent.com/kadaliao/dsh-bots/main/docs/en-memory.png)
344
354
 
345
- ![Team memory](docs/en-team-memory.png)
355
+ ![Team memory](https://raw.githubusercontent.com/kadaliao/dsh-bots/main/docs/en-team-memory.png)
346
356
 
347
357
  ## Usage
348
358
 
@@ -354,7 +364,7 @@ takes one run or more, **By task** adds them up, and a task's own page shows its
354
364
  estimates from your own prices or LiteLLM's public price list (**Prices**); a model with no price shows its
355
365
  tokens only.
356
366
 
357
- ![Usage](docs/en-usage.png)
367
+ ![Usage](https://raw.githubusercontent.com/kadaliao/dsh-bots/main/docs/en-usage.png)
358
368
 
359
369
  ## Message your team from Feishu, Telegram, Slack or Discord
360
370
 
@@ -494,7 +504,9 @@ one connection. If you change scopes later, reinstall the app to the workspace a
494
504
  task it is, who asked, and how to report. Edits apply at once; a new or changed app connects the next
495
505
  time the conversation starts.
496
506
  - In Router mode, `bot_send_message` from a bot's own conversation opens a task and returns at once; from
497
- a task's conversation it reports to whoever asked (with a status) or opens a sub-task. In Hands-on mode,
507
+ a task's conversation it reports to whoever asked (with a status) or opens a sub-task. A message to the
508
+ dispatcher opens no task: it goes into the dispatcher's own conversation (one sent from a task names it, and the
509
+ dispatcher's answer is added to that task). In Hands-on mode,
498
510
  from a bot's own conversation, it puts the text into the other bot's inbox and wakes it, as in 0.7. Two
499
511
  bots may exchange at most 16 messages in 10 minutes (new tasks and messages added to tasks count), so
500
512
  conversations end.
@@ -503,7 +515,7 @@ one connection. If you change scopes later, reinstall the app to the workspace a
503
515
  `memory_forget` and `memory_search`. `bot_reply` sends an answer to a named chat; `bot_recall` reads a
504
516
  task, its reports or its conversation, or a chat thread, a page at a time, so a bot looks things up
505
517
  instead of guessing; `bot_ticket` stops, closes or retries a task the bot asked for, or asks it for a
506
- status report. [API.md](API.md) lists their parameters. A sub-agent started in a bot's or a task's
518
+ status report. [API.md](https://github.com/kadaliao/dsh-bots/blob/main/API.md) lists their parameters. A sub-agent started in a bot's or a task's
507
519
  conversation uses them as that bot or task; one that cannot be traced back to where it started (that
508
520
  conversation is gone) is refused.
509
521
  - A bot's memory is a section of its system prompt, read when a topic or a task's conversation starts
@@ -547,7 +559,7 @@ permission and restart it.
547
559
 
548
560
  ## Install
549
561
 
550
- Add this repository's index in DeepSeek Harness (**Plugins → Discover → Sources**):
562
+ Add the [DSH Plugins](https://github.com/kadaliao/dsh-plugins) index in DeepSeek Harness (**Plugins → Discover → Sources**):
551
563
 
552
564
  ```
553
565
  https://raw.githubusercontent.com/kadaliao/dsh-plugins/main/marketplace.json
@@ -556,13 +568,15 @@ https://raw.githubusercontent.com/kadaliao/dsh-plugins/main/marketplace.json
556
568
  then install **Bots**. The Discover tab is part of the experimental **Custom plugin markets**
557
569
  feature; turn it on under **Plugins → Experimental plugins** if you don't see it.
558
570
 
559
- Without Discover, paste the Git spec into the plugin manager:
571
+ Without Discover, paste the package name into the plugin manager:
560
572
 
561
573
  ```
562
- git+https://github.com/kadaliao/dsh-plugins.git#main&path:/plugins/bots
574
+ @kadaliao/dsh-bots
563
575
  ```
564
576
 
565
- Refresh the page once after installing. For AI avatars, install [Images](../images) too.
577
+ For the latest unreleased code, use the Git spec `git+https://github.com/kadaliao/dsh-bots.git#main` instead.
578
+
579
+ Refresh the page once after installing. For AI avatars, install [Images](https://github.com/kadaliao/dsh-images) too.
566
580
 
567
581
  ## Upgrading from 0.9
568
582
 
package/README.zh-CN.md CHANGED
@@ -13,7 +13,7 @@ bot 在它的**讨论串**里回答,只看得到这条消息和它之前的内
13
13
  - **一人公司(OPC)**:一个人经营业务,需要一整个「员工团队」——研发、增长、客户、财务,再加一个每天早上给你简报的幕僚长。
14
14
  - **需要分工协作的工作**:开发要有人写、有人测、有人审;内容要有人调研、有人写、有人做图;研究要有人挑刺。
15
15
 
16
- ![团队模板](docs/teams.png)
16
+ ![团队模板](https://raw.githubusercontent.com/kadaliao/dsh-bots/main/docs/teams.png)
17
17
 
18
18
  ## 一键雇用一支团队
19
19
 
@@ -35,7 +35,7 @@ bot 在它的**讨论串**里回答,只看得到这条消息和它之前的内
35
35
  - 建好定时任务,让负责人成为调度员;
36
36
  - 最后可以一键把「开场任务」发给负责人,团队就开始干活了。
37
37
 
38
- ![聊天](docs/chat.png)
38
+ ![聊天](https://raw.githubusercontent.com/kadaliao/dsh-bots/main/docs/chat.png)
39
39
 
40
40
  ## 一段示例(一人公司)
41
41
 
@@ -123,12 +123,16 @@ bot 默认用你说话的语言回答;中文提问就是中文协作。
123
123
  调度员有两种工作方式,在它的 **资料** 页 **调度方式** 里选,对整个团队生效:
124
124
 
125
125
  - **只调度**(默认):听懂需求、把工作分派出去、跟进进度,自己不动手。这时它不执行命令、不写不改文件、不联网搜索、
126
- 不用子代理和工作流、不作图、不做 Office 文档,但仍能读文件、使用技能。需要这些能力的事都交给队友,
127
- 从不派给自己(0.9 时没有合适的队友它会派给自己,0.10 起不再这样),它自己的会话始终空着等你。**能力** 一栏会标出只调度时关掉的项,
128
- 点 **重新打开** 可以逐项放回(即使放回了命令,它也不能 `sleep`,命令要么在 30 秒内跑完,要么放到后台跑)。
126
+ 不用子代理和工作流、不作图、不做 Office 文档,也不弹提问卡片(一张卡片没答之前,后面的消息都得排队),但仍能读文件、使用技能。
127
+ 需要这些能力的事都交给队友,从不派给自己(0.9 时没有合适的队友它会派给自己,0.10 起不再这样),它自己的会话始终空着等你。
128
+ 你说「动笔前先问我」这类话,它把这个要求连同工作一起交给队友,由队友在任务里问你;它自己得先弄清楚才能分派的事,
129
+ 就在回复里用一句话问你,你的下一条消息就是答案。**能力** 一栏会列出只调度时关掉的项并标出来:整项关掉的,打开开关就放回;
130
+ 只关掉一部分的(比如读写文件里的写和改),点 **重新打开** 放回(即使放回了命令,它也不能 `sleep`,命令要么在 30 秒内跑完,
131
+ 要么放到后台跑;放回提问卡片的话,卡片没答之前它也接不了新消息)。
129
132
  它从不等队友:分派完就结束这一轮,有事需要它时会自动唤醒,所以新请求不会被手上的活堵住;
130
133
  它忙的时候进来的消息,会在下一步一起处理,每一条都得到回应。既然只管调度,用轻量、快速的模型就够了,
131
- **模型** 一栏也会这样提示;Bots 不会替你换模型。只调度时,任何 bot 把工作交给队友都会开任务,不只调度员。
134
+ **模型** 一栏也会这样提示;Bots 不会替你换模型。只调度时,任何 bot 把工作交给队友都会开任务,不只调度员;
135
+ 但没有人给调度员开任务:队友发给它的消息直接进它自己的会话,由它转告你该知道的、把该做的活分派出去。
132
136
  - **亲自动手**:0.7 的做法。调度员小事自己顺手做掉;bot 在自己的会话里给队友发消息,消息直接进队友自己的会话,不开任务。
133
137
  已经开出的任务照常进行、照常汇报。
134
138
 
@@ -206,8 +210,9 @@ Bot 在普通的 Harness 会话里工作,所以 Harness 能做的它都能做
206
210
  | 地图与本地 | 高德地图 🔑、百度地图 🔑 |
207
211
  | 自定义 | 任意本地(stdio)或远程(Streamable HTTP)MCP 服务 |
208
212
 
209
- - **定时任务**:就是 Harness 的定时任务,也出现在「自动化」页面;
210
- - **AI 头像**:装了 [图片插件](../images) 就能按 bot 的人设生成头像。bot 自己也能做:让调度员给团队换一批头像,
213
+ - **定时任务**:就是 Harness 的定时任务,也出现在「自动化」页面。Harness 没开着时错过的定时任务,下次启动时由 Harness 补跑,
214
+ 每个只补最近的那一次(这是 Harness 的规则,Bots 不另外补);团队的定时任务多时,启动后会一下子开出好几个任务、用掉不少 token。
215
+ - **AI 头像**:装了 [图片插件](https://github.com/kadaliao/dsh-images) 就能按 bot 的人设生成头像。bot 自己也能做:让调度员给团队换一批头像,
211
216
  说清楚想要的样子就行,也可以指给它一张本地图片。bot 画头像是在后台进行的,不耽误它回你的话:画的时候头像上有一圈在转,
212
217
  画好就换上;画好了(或没画成、为什么)bot 会收到通知并告诉你。Harness 重启会丢掉正在画的头像。
213
218
  - **图标**:应用库里每个应用都用它自己的官方 logo(有 App 的用 App Store 图标,没有的用官网或官方仓库里的 logo)。
@@ -226,7 +231,7 @@ Bot 在普通的 Harness 会话里工作,所以 Harness 能做的它都能做
226
231
  另一边都会拿到新令牌,谁也不会把谁踢下线。Claude Code 的登录会显示出来但不提供:Anthropic 只允许
227
232
  在 Claude Code 和 claude.ai 里使用 Claude 订阅,请改用 API Key 添加 Claude。
228
233
 
229
- ![模型来源](docs/model-sources.png)
234
+ ![模型来源](https://raw.githubusercontent.com/kadaliao/dsh-bots/main/docs/model-sources.png)
230
235
 
231
236
  ## 话题:对话不会无限变长
232
237
 
@@ -255,7 +260,8 @@ bot 知道的事靠记忆延续。下面几种情况会开新话题:
255
260
  用 `memory_search` 查笔记、团队工作日志、每日摘要和任务(标题和汇报)。在任务的会话里,除了笔记,
256
261
  只查得到这个任务、它的所属任务和子任务的工作日志与任务,查不到每日摘要。
257
262
  - **每天夜里**(默认 03:00)**整理**一次:结合最近的工作日志,合并、更正、精简每个 bot 的笔记和共享笔记,
258
- 并把当天的工作写成团队的**每日摘要**。**立即整理** 可以马上运行。
263
+ 并把当天的工作写成团队的**每日摘要**。**立即整理** 可以马上运行。笔记和摘要用你和 bot 说话的语言写(看你最近的
264
+ 消息判断),写成别的语言的笔记会被改写过来。
259
265
  - 话题或任务的会话开始时,bot 会读到自己的笔记、团队笔记、最近几条工作日志和最新的每日摘要;
260
266
  你在面板里改了记忆、或每晚整理之后,下一个回合会重新读一次。同一个话题里,提示词中的记忆部分保持不变,模型对整段对话的
261
267
  提示缓存照常命中(话题里学到的东西本来就在这段对话里)。很短的往来(一句确认、给队友的一行回复)只记一行
@@ -264,9 +270,9 @@ bot 知道的事靠记忆延续。下面几种情况会开新话题:
264
270
  置顶的笔记不会被自动整理改动;看起来像 Key 或 Token 的内容一律不存。
265
271
  - 记忆工作默认使用各 bot 自己的模型,也可以在设置里指定一个更便宜的。
266
272
 
267
- ![bot 的记忆](docs/memory.png)
273
+ ![bot 的记忆](https://raw.githubusercontent.com/kadaliao/dsh-bots/main/docs/memory.png)
268
274
 
269
- ![团队记忆](docs/team-memory.png)
275
+ ![团队记忆](https://raw.githubusercontent.com/kadaliao/dsh-bots/main/docs/team-memory.png)
270
276
 
271
277
  ## 用量
272
278
 
@@ -276,7 +282,7 @@ bot 知道的事靠记忆延续。下面几种情况会开新话题:
276
282
  直到 bot 重新空闲);一个任务有一个或多个回合,**按任务** 把它们加在一起,任务详情页里也有它自己的用量。
277
283
  费用是估算:用你填的价格,或 LiteLLM 公开价格表(**价格**);没有价格的模型只显示 tokens。
278
284
 
279
- ![用量](docs/usage.png)
285
+ ![用量](https://raw.githubusercontent.com/kadaliao/dsh-bots/main/docs/usage.png)
280
286
 
281
287
  ## 在飞书、Telegram、Slack 或 Discord 里给团队发消息
282
288
 
@@ -395,12 +401,13 @@ Slack 走 Socket Mode:由 Harness 主动连到 Slack,电脑不需要公网
395
401
  - 会话运行时,bot 的人设和团队名单加入系统提示词;它自己的技能、能力限制和应用只作用于它自己的会话。
396
402
  任务的会话里,提示词还会说明这是哪个任务、谁发起的、怎么汇报。修改即时生效;新增或修改应用在下次会话启动时连接。
397
403
  - 「只调度」模式下,`bot_send_message` 在 bot 自己的会话里调用就开一个任务并立刻返回;在任务的会话里调用,
398
- 要么带状态向发起方汇报,要么开一个子任务。「亲自动手」模式下,从 bot 自己的会话发出的消息放进对方的收件箱并唤醒它,
404
+ 要么带状态向发起方汇报,要么开一个子任务。发给调度员的不开任务,放进它自己的会话(从任务里发的会注明是哪个任务,
405
+ 调度员回话时追加到那个任务)。「亲自动手」模式下,从 bot 自己的会话发出的消息放进对方的收件箱并唤醒它,
399
406
  和 0.7 一样。同一对 bot 10 分钟内最多互发 16 条(新开的任务和追加给任务的消息都算),防止无限对话。
400
407
  - 所有会话都能用 `bot_list`、`bot_create`、`bot_update`、`bot_delete`、`bot_send_message`、`bot_reply`、`bot_recall`、
401
408
  `bot_ticket`、`bot_schedule` 管理 bot 和任务,以及 `memory_save`、`memory_forget`、`memory_search`。
402
409
  `bot_reply` 把答复发到指定的聊天;`bot_recall` 分页读取任务、任务的汇报或会话,以及聊天讨论串,让 bot 去查而不是猜;
403
- `bot_ticket` 停止、关闭或重试自己发起的任务,或者请它汇报进度。参数见 [API.md](API.md)。
410
+ `bot_ticket` 停止、关闭或重试自己发起的任务,或者请它汇报进度。参数见 [API.md](https://github.com/kadaliao/dsh-bots/blob/main/API.md)。
404
411
  在 bot 或任务的会话里启动的子代理,以那个 bot 或任务的身份使用这些工具;追溯不到来源(启动它的会话已经不在)的子代理会被拒绝。
405
412
  - bot 的记忆是它系统提示词里的一段,在话题或任务的会话开始时读取(面板里改了记忆或每晚整理后,在下一个回合开始时重读),
406
413
  回合进行中不会变。bot 的 Agent 空闲时回合结束;记忆总结读的是这个回合的过程(提示、回复、工具调用和简短的工具结果),
@@ -430,7 +437,7 @@ Slack 走 Socket Mode:由 Harness 主动连到 Slack,电脑不需要公网
430
437
 
431
438
  ## 安装
432
439
 
433
- 在 DeepSeek Harness 里加入本仓库的索引(**Plugins → Discover → Sources**):
440
+ 在 DeepSeek Harness 里加入 [DSH Plugins](https://github.com/kadaliao/dsh-plugins) 的索引(**Plugins → Discover → Sources**):
434
441
 
435
442
  ```
436
443
  https://raw.githubusercontent.com/kadaliao/dsh-plugins/main/marketplace.json
@@ -439,13 +446,15 @@ https://raw.githubusercontent.com/kadaliao/dsh-plugins/main/marketplace.json
439
446
  然后安装 **Bots**。Discover 标签属于实验性的 **Custom plugin markets** 功能;看不到的话先在
440
447
  **Plugins → Experimental plugins** 里打开。
441
448
 
442
- 不用 Discover 的话,把 Git 地址填进插件管理器:
449
+ 不用 Discover 的话,把包名贴进插件管理器:
443
450
 
444
451
  ```
445
- git+https://github.com/kadaliao/dsh-plugins.git#main&path:/plugins/bots
452
+ @kadaliao/dsh-bots
446
453
  ```
447
454
 
448
- 安装后刷新一次页面。想要 AI 头像,再装上[图片插件](../images)。
455
+ 想用还没发布的最新代码,改用 Git spec `git+https://github.com/kadaliao/dsh-bots.git#main`。
456
+
457
+ 安装后刷新一次页面。想要 AI 头像,再装上[图片插件](https://github.com/kadaliao/dsh-images)。
449
458
 
450
459
  ## 从 0.9 升级
451
460
 
package/client.js CHANGED
@@ -21,7 +21,7 @@ window.__ModuleLoader__.load({
21
21
  const NS = 'bots';
22
22
  const PANEL_ID = 'bots';
23
23
  /** The Bots this page is (package.json): the Host says which one it runs, and a stale Host is pointed out. */
24
- const BOTS_VERSION = '0.10.0';
24
+ const BOTS_VERSION = '0.10.2';
25
25
  /** How close to a new topic Harness closing the panel counts as caused by it (it archived the conversation behind). */
26
26
  const ROTATE_WINDOW_MS = 3000;
27
27
  const R = '/__dsh_bots/';
@@ -8501,7 +8501,7 @@ button.dshb-qline-light:hover{color:inherit;opacity:1}
8501
8501
  modeSavedHandsOn: '{name} does small things itself again.',
8502
8502
  routerModelHint: 'In Router mode it only understands, hands out and reports, so a light, fast model is enough, and every request stays quick and cheap.',
8503
8503
  routerWaiting: 'Router mode starts once the team has another bot; until then {name} does the work itself.',
8504
- abilitiesRouterHint: 'What {name} can do with the Harness’s built-in tools. In Router mode it does not run commands, write files, use sub-agents, draw or make Office files; turn one back on below if it needs it.',
8504
+ abilitiesRouterHint: 'What {name} can do with the Harness’s built-in tools. In Router mode it does not search the web, run commands, write files, use sub-agents, draw, make Office files or put question cards to you (a card holds every message after it until you answer); turn one back on below if it needs it.',
8505
8505
  routerOff: 'Off in Router mode',
8506
8506
  teamOff: 'Off for the dispatcher',
8507
8507
  teamOffHint: 'The dispatcher hands work in parallel to its teammates, so the panel shows it as their tasks. The other bots keep sub-agents.',
@@ -9388,7 +9388,7 @@ button.dshb-qline-light:hover{color:inherit;opacity:1}
9388
9388
  modeSavedHandsOn: '{name} 又会自己做小事了。',
9389
9389
  routerModelHint: '只调度时它只负责听懂、分派、汇报,用轻量、快速的模型就够了,每次请求都更快、更省。',
9390
9390
  routerWaiting: '团队里再有一个 Bot 后才开始只调度,在此之前 {name} 自己动手。',
9391
- abilitiesRouterHint: '{name} 能用 Harness 内置工具做哪些事。只调度时它不执行命令、不写文件、不用子代理、不作图也不做 Office 文档;确实需要时可以在下面逐项打开。',
9391
+ abilitiesRouterHint: '{name} 能用 Harness 内置工具做哪些事。只调度时它不联网、不执行命令、不写文件、不用子代理、不作图、不做 Office 文档,也不弹提问卡片(卡片没答之前,后面的消息都得排队);确实需要时可以在下面逐项打开。',
9392
9392
  routerOff: '只调度时关闭',
9393
9393
  teamOff: '调度员不用',
9394
9394
  teamOffHint: '调度员把要并行的活交给队友,面板里能看到他们各自的任务;其他 bot 照常可以用子代理。',
package/index.js CHANGED
@@ -58,7 +58,7 @@ import { createSlots, createTickets, parkedOf, REPORT_STATUSES, sessionIdOf, sta
58
58
  import { assignmentText, clip, discussionNoteText, failedNoticeText, followUpNoticeText, NEWS_MESSAGES, nudgeText, panelHeaderText, PREVIEW_CHARS, readResource, recoveryNoteText, reminderText, reportRelayText, retryText, shownNoticeText, stalledNoticeText, threadNewsText } from './lib/cards.mjs';
59
59
  import { checkTickets, isTransient, requesterReminders, retryDelay } from './lib/watchdog.mjs';
60
60
  import { isLiveSubscriber, isPanelThread, isTopicThread, panelThreadKey, panelTopicOf, parseThreadKey, threadLabel, toThreadKey } from './lib/threads.mjs';
61
- import { createMemory, dreamBotPrompt, dreamTeamPrompt, KINDS as MEMORY_KINDS, looksSecret, parseJsonReply, reflectionPrompt, searchTickets } from './lib/memory.mjs';
61
+ import { createMemory, dreamBotPrompt, dreamTeamPrompt, KINDS as MEMORY_KINDS, languageOf, looksSecret, parseJsonReply, reflectionPrompt, searchTickets } from './lib/memory.mjs';
62
62
  import { createTopics, rotationReason } from './lib/topics.mjs';
63
63
  import { chatMessageRef, createDiscussions, forkPoint, messageRef, seqByTime } from './lib/discussions.mjs';
64
64
  import { API_KINDS, CODEX_ROUTE, PI_SCOPE, ROUTE_PREFIX, codexAuthFile, createCodexSync, detectLogins, discoverModels, endpointView, keyRefFor, profileFor, readCodexAuth, codexCredential } from './lib/models.mjs';
@@ -359,6 +359,38 @@ export function apply(ctx, config, deps = {}) {
359
359
  // --- applying a bot to its Agent ----------------------------------------------------
360
360
  /** sessionId → {agent, signature, disposers[]} */
361
361
  const installed = new Map();
362
+ /**
363
+ * The first sentence of each Harness tool's description, by name, as a bot's conversation has it
364
+ * before Bots limits it: noted when a conversation is set up (before its limits apply) and when the
365
+ * catalog is read. A router home's own view lacks `bash` or `web_search`; the profile still lists
366
+ * them, marked off in Router mode (0.10.1).
367
+ */
368
+ const toolInfo = new Map();
369
+ const toolLine = (d) => String(d?.description ?? '').split(/(?<=\.)\s/)[0].slice(0, 200);
370
+ /** Note the definitions `scope` sees; returns their names. */
371
+ function noteTools(scope) {
372
+ const names = [];
373
+ try {
374
+ for (const d of ctx.tools?.definitions?.(scope) ?? []) {
375
+ toolInfo.set(d.name, toolLine(d));
376
+ names.push(d.name);
377
+ }
378
+ } catch {
379
+ // No registry view.
380
+ }
381
+ return names;
382
+ }
383
+ /** The tools `scope` would have with no limits: what it sees, and the names a limit hides (Harness `restrictableNames`). */
384
+ function unlimitedTools(scope) {
385
+ const names = new Set(noteTools(scope));
386
+ try {
387
+ const hidden = ctx.tools?.view?.(scope)?.restrictableNames;
388
+ if (hidden instanceof Set) for (const n of hidden) names.add(n);
389
+ } catch {
390
+ // A Harness without the view lists what the scope sees.
391
+ }
392
+ return [...names];
393
+ }
362
394
 
363
395
  const isChannel = (app) => Boolean(channelEntry(app, templates()));
364
396
  // Chat channels run outside the Agent; changing one does not restart the bot's MCP clients.
@@ -480,6 +512,8 @@ export function apply(ctx, config, deps = {}) {
480
512
  ctx.logger?.warn?.(`bots: memory for @${bot.handle}: ${error?.message ?? error}`);
481
513
  }
482
514
  }
515
+ // What this conversation has before any limit below: the profile lists the denied tools too.
516
+ noteTools(scopeOf(actx));
483
517
  // A router home is also denied the tools that do the work, except those the user gave back; a team's dispatcher starts no sub-agents.
484
518
  const allowed = new Set(bot.tools.routerAllow ?? []);
485
519
  const wanted = [...new Set([...bot.tools.deny, ...(router ? ROUTER_DENY.filter((n) => !allowed.has(n)) : []), ...(noSubagents(bot) ? SUBAGENT_TOOLS : [])])];
@@ -848,6 +882,15 @@ export function apply(ctx, config, deps = {}) {
848
882
  : task.trigger === 'chat'
849
883
  ? `a ${task.via ?? 'chat'} message from the user`
850
884
  : 'a message from the user';
885
+ /**
886
+ * The language the person writes to the bots in (`zh` | `en`), for memory written without them
887
+ * in view: their last messages (panel and chat apps), else `material` (the memory itself), else
888
+ * this machine's language.
889
+ */
890
+ function userLanguage(material = []) {
891
+ const said = store.messages({ limit: 2000, roots: false }).filter((m) => m.from === 'user').slice(-40).map((m) => m.text);
892
+ return languageOf(said) || languageOf(material) || (zh ? 'zh' : 'en');
893
+ }
851
894
  async function reflect(bot, task) {
852
895
  // A bot deleted while its summary waited keeps nothing.
853
896
  if (!store.get(bot.id)) return;
@@ -859,7 +902,7 @@ export function apply(ctx, config, deps = {}) {
859
902
  let summary = '';
860
903
  if (sel) {
861
904
  try {
862
- const p = reflectionPrompt({ bot, notes: memory.notes(bot.id), team: memory.notes('team'), transcript, trigger: triggerWords(task) });
905
+ const p = reflectionPrompt({ bot, notes: memory.notes(bot.id), team: memory.notes('team'), transcript, trigger: triggerWords(task), language: userLanguage([transcript]) });
863
906
  const r = await complete(sel, p.system, p.user, { purpose: 'bots-memory', sessionId: task.s });
864
907
  ledger.record(usageRow({ botId: bot.id, sessionId: task.s, taskId: task.id, ticketId: task.ticket, kind: 'memory', provider: sel.provider, model: sel.model, usage: r.usage }));
865
908
  const parsed = parseJsonReply(r.text) ?? {};
@@ -877,6 +920,12 @@ export function apply(ctx, config, deps = {}) {
877
920
  }
878
921
 
879
922
  let dreaming = null;
923
+ /**
924
+ * Output budget of a consolidation call. A thinking model spends most of it reasoning (DeepSeek
925
+ * Flash: ~2–3K tokens on a 5-bot team), and rewriting notes left in another language adds to the
926
+ * answer; 4000 came back empty now and then.
927
+ */
928
+ const DREAM_TOKENS = 16_000;
880
929
  /** Consolidate every bot's notes and write the team digest (the daily "dream"). */
881
930
  function dream({ reason = 'schedule' } = {}) {
882
931
  if (dreaming) return dreaming;
@@ -887,6 +936,7 @@ export function apply(ctx, config, deps = {}) {
887
936
  const since = Number(before.lastAt) || now - DAY_MS;
888
937
  const bots = store.list();
889
938
  const result = { at: now, reason, bots: [], digest: null, errors: [] };
939
+ const language = userLanguage(memory.journal({ since: now - 7 * DAY_MS, limit: 300 }).map((j) => j.summary || j.title));
890
940
  for (const bot of bots) {
891
941
  const journal = memory.journal({ bot: bot.id, since: now - 7 * DAY_MS, limit: 300 });
892
942
  const fresh = journal.some((j) => j.at >= since);
@@ -895,8 +945,8 @@ export function apply(ctx, config, deps = {}) {
895
945
  const sel = memoryModelOf(bot);
896
946
  if (!sel) continue;
897
947
  try {
898
- const p = dreamBotPrompt({ bot, notes, journal, tz });
899
- const r = await complete(sel, p.system, p.user, { purpose: 'bots-dream', maxTokens: 4000, timeoutMs: 180_000 });
948
+ const p = dreamBotPrompt({ bot, notes, journal, tz, language });
949
+ const r = await complete(sel, p.system, p.user, { purpose: 'bots-dream', maxTokens: DREAM_TOKENS, timeoutMs: 180_000 });
900
950
  ledger.record(usageRow({ botId: bot.id, kind: 'dream', provider: sel.provider, model: sel.model, usage: r.usage }));
901
951
  const parsed = parseJsonReply(r.text);
902
952
  if (!parsed) throw new Error('the model did not answer with JSON');
@@ -912,8 +962,8 @@ export function apply(ctx, config, deps = {}) {
912
962
  const date = memory.dayOf(journal[journal.length - 1].at, tz);
913
963
  if (sel) {
914
964
  try {
915
- const p = dreamTeamPrompt({ bots, team: memory.notes('team'), journal, date, tz });
916
- const r = await complete(sel, p.system, p.user, { purpose: 'bots-dream', maxTokens: 4000, timeoutMs: 180_000 });
965
+ const p = dreamTeamPrompt({ bots, team: memory.notes('team'), journal, date, tz, language });
966
+ const r = await complete(sel, p.system, p.user, { purpose: 'bots-dream', maxTokens: DREAM_TOKENS, timeoutMs: 180_000 });
917
967
  ledger.record(usageRow({ botId: lead?.id ?? 'team', kind: 'dream', provider: sel.provider, model: sel.model, usage: r.usage }));
918
968
  const parsed = parseJsonReply(r.text);
919
969
  if (!parsed) throw new Error('the model did not answer with JSON');
@@ -1145,7 +1195,9 @@ export function apply(ctx, config, deps = {}) {
1145
1195
  * without `inject` gets nothing for an 'inject' (`dropped`): such a note never wakes a turn.
1146
1196
  * - `key`: makes the message id `bots:<key>`; a message with that id already pending or delivered
1147
1197
  * is not delivered again, so a retried request is harmless.
1148
- * @returns {{message: object, mode: string, skipped: boolean, dropped?: true}}
1198
+ * An 'inject' for a conversation in the middle of a turn is held until it is idle (`held`, see
1199
+ * `holdNote`).
1200
+ * @returns {{message: object, mode: string, skipped: boolean, dropped?: true, held?: true}}
1149
1201
  */
1150
1202
  async function sendTo(agent, { content: blocks, source, mode = 'followup', key }) {
1151
1203
  // Providers that take a message as one string join its blocks with nothing in between:
@@ -1157,15 +1209,55 @@ export function apply(ctx, config, deps = {}) {
1157
1209
  if (key) await loadHistory(agent.session?.id);
1158
1210
  if (key && holds(agent, message.id)) return { message, mode, skipped: true };
1159
1211
  const how = mode === 'inject' ? 'inject' : mode !== 'followup' && typeof agent.steer === 'function' ? 'steer' : 'followup';
1212
+ if (how === 'inject' && agent.status === 'running') {
1213
+ holdNote(agent, message);
1214
+ if (key) noteDelivered(agent.session?.id, message.id);
1215
+ return { message, mode: how, skipped: false, held: true };
1216
+ }
1160
1217
  agent[how](message);
1161
1218
  if (key) noteDelivered(agent.session?.id, message.id);
1162
1219
  await flush(agent);
1163
1220
  return { message, mode: how, skipped: false };
1164
1221
  }
1222
+ /**
1223
+ * Notes ("[Shown]", "[follow_up]", "[Closed]") for conversations that were working when they came,
1224
+ * by Session: `{agent, messages}`. Injected into a running turn, a note is the newest input of its
1225
+ * next step, and the model answers it, to the person ("[已展示]: nothing for me to do…", 0.10.1).
1226
+ * They need no answer, so they wait for the turn's end and go in then, waking nothing. In memory
1227
+ * only: a note lost with the process was only good to know.
1228
+ */
1229
+ const heldNotes = new Map();
1230
+ function holdNote(agent, message) {
1231
+ const sid = agent.session?.id;
1232
+ if (!sid) return;
1233
+ const held = heldNotes.get(sid) ?? { agent, messages: [] };
1234
+ held.agent = agent;
1235
+ held.messages.push(message);
1236
+ heldNotes.set(sid, held);
1237
+ }
1238
+ /** The conversation `sessionId` went idle: its held notes go in now, in the order they came. */
1239
+ function releaseNotes(sessionId, agent) {
1240
+ const held = heldNotes.get(sessionId);
1241
+ if (!held) return;
1242
+ heldNotes.delete(sessionId);
1243
+ const to = agent ?? held.agent;
1244
+ for (const m of held.messages) {
1245
+ try {
1246
+ to.inject(m);
1247
+ } catch (error) {
1248
+ ctx.logger?.info?.(`bots: a held note did not reach ${sessionId}: ${error?.message ?? error}`);
1249
+ }
1250
+ }
1251
+ void flush(to);
1252
+ }
1165
1253
  /** How a bot's home takes new input: a router steers (backlog is handled together), every other home as in 0.7. */
1166
1254
  const homeMode = (bot) => (isRouter(store.get(bot.id) ?? bot) ? 'steer' : 'followup');
1167
1255
 
1168
- /** A DM from `sender` (a bot, or null for the user) to `target`'s home: 0.7's bot-to-bot message. */
1256
+ /**
1257
+ * A DM from `sender` (a bot, or null for the user) to `target`'s home: 0.7's bot-to-bot message,
1258
+ * and (0.10.1) a teammate's message to the router dispatcher. One sent from a task names it, so the
1259
+ * answer goes to that task. Its id (`bots:dm:…`) keeps it a message, not a report on the sender's task.
1260
+ */
1169
1261
  async function deliver(sender, target, text, senderSessionId) {
1170
1262
  const body = String(text ?? '').trim();
1171
1263
  if (body === '') throw new Error('text must not be empty');
@@ -1174,13 +1266,15 @@ export function apply(ctx, config, deps = {}) {
1174
1266
  // A teammate's message may answer this bot's own question: only a long quiet starts a new topic here.
1175
1267
  await autoTopic(store.get(target.id) ?? target, sender ? 'dm' : 'user');
1176
1268
  const agent = await agentOf(store.get(target.id) ?? target);
1269
+ const fromTask = sender ? ticketOf(senderSessionId) : undefined;
1177
1270
  await sendTo(agent, {
1178
1271
  content: [
1179
- { type: 'text', text: dmHeader(sender) },
1180
- { type: 'text', text: dmBody(body, sender) },
1272
+ { type: 'text', text: dmHeader(sender, fromTask) },
1273
+ { type: 'text', text: dmBody(body, sender, fromTask) },
1181
1274
  ],
1182
1275
  source: senderSessionId ? { kind: 'agent-message', form: 'relay', senderSessionId } : { kind: 'user' },
1183
1276
  mode: homeMode(target),
1277
+ key: `dm:${randomUUID()}`,
1184
1278
  });
1185
1279
  store.log({ from: sender ? sender.id : 'user', to: target.id, text: body, kind: 'dm' });
1186
1280
  return agent.session.id;
@@ -1979,6 +2073,8 @@ export function apply(ctx, config, deps = {}) {
1979
2073
  : 'a bot cannot message itself',
1980
2074
  );
1981
2075
  }
2076
+ // Nor does it take tasks from its teammates (0.10.1): their messages go into its conversation (bot_send_message).
2077
+ if (isRouter(target)) throw new Error(`@${target.handle} is the dispatcher and takes no tasks; message it without a task, or give the work to the teammate who does it`);
1982
2078
  if (!service(ctx, 'sessionController')) throw new Error('tasks need the Web profile (no session controller here)');
1983
2079
  const parent = ticketOf(senderSessionId);
1984
2080
  const { origin, thread } = originOfTurn(senderSessionId, chosen);
@@ -2559,6 +2655,7 @@ export function apply(ctx, config, deps = {}) {
2559
2655
  answered.delete(sessionId);
2560
2656
  turnState.delete(sessionId);
2561
2657
  activity.clear(sessionId);
2658
+ heldNotes.delete(sessionId);
2562
2659
  }
2563
2660
  /** Kinds of user message that start (or join) a task. */
2564
2661
  const TASK_KINDS = new Set(['user', 'schedule', 'agent-message']);
@@ -2775,6 +2872,7 @@ export function apply(ctx, config, deps = {}) {
2775
2872
  ctx.on('agent/status', (payload) => {
2776
2873
  try {
2777
2874
  const sid = payload?.agent?.session?.id;
2875
+ if (sid && payload.status === 'idle') releaseNotes(sid, payload.agent);
2778
2876
  if (sid && payload.status === 'idle') activity.clear(sid);
2779
2877
  if (sid && payload.status === 'idle' && openTasks.has(sid)) settleSoon(sid, 300);
2780
2878
  else if (sid && payload.status === 'idle' && memoStale.delete(sid)) memoText.delete(sid);
@@ -3537,7 +3635,7 @@ export function apply(ctx, config, deps = {}) {
3537
3635
  'Message another bot, or report on the task this conversation works on. Make the text self-contained: the other bot cannot see this conversation. Do not reply to acknowledgements.',
3538
3636
  "- To delegate: `to` (the bot's @handle) and `text`. Depending on how the team works, this opens a task (ticket) that the bot works on in a conversation of its own, or drops the text into that bot's own conversation; the result says which. Either way the call returns at once and the answer (a report, or a bot message) arrives here by itself: never wait or poll for it.",
3539
3637
  '- When this turn involves several topics or chats, name the one a new task is for with `thread` (as its message header shows it), so its answer goes there.',
3540
- '- The dispatcher may name itself in `to`: it then does the work in a task conversation of its own, with all its tools.',
3638
+ '- When the dispatcher only routes, a message to it opens no task: it goes into its own conversation, and it passes on to the person what they should know. Work goes to the teammate who does it.',
3541
3639
  '- A task from a topic or chat answers the person there itself; pass `report_to: "me"` to get its reports back instead (to combine several results).',
3542
3640
  '- To add to an open task you asked for (an answer to its question, a change, a message of the person\'s that continues it): `ticket` (its id) and `text`.',
3543
3641
  '- In a task conversation, to report to whoever asked: leave out `to`, give `text` and a `status` (progress, done, blocked, question).',
@@ -3603,6 +3701,18 @@ export function apply(ctx, config, deps = {}) {
3603
3701
  }
3604
3702
  if (!named) throw new Error(mine ? 'say which bot with `to`, or leave it out and give a `status` to report on your task' : 'say which bot with `to`');
3605
3703
 
3704
+ // A teammate's message to the router dispatcher (0.10.1): no task for it (it does no work itself),
3705
+ // the text goes into its own conversation, where its router limits hold and it routes it.
3706
+ if (sender && named.id !== sender.id && isRouter(named)) {
3707
+ await deliver(sender, named, args.text, sessionId);
3708
+ return {
3709
+ ok: true,
3710
+ text: `Delivered to @${named.handle}, the dispatcher, in its own conversation: it does no work itself, so this opens no task. It tells the person what they should know; if it answers you, the answer ${mine ? 'arrives here' : 'reaches you'} by itself (do not wait for it). Work you need done goes to the teammate who does it.`,
3711
+ to: face(named),
3712
+ from: face(sender),
3713
+ };
3714
+ }
3715
+
3606
3716
  // A new ticket: from a task conversation (a sub-task), or from a bot's home when tasks are on.
3607
3717
  if (sender && sessionId && (mine || (ticketsOn() && isHomeOf(sender, sessionId)))) {
3608
3718
  const relay = String(args.report_to ?? '').trim().toLowerCase() === 'me';
@@ -3934,9 +4044,10 @@ export function apply(ctx, config, deps = {}) {
3934
4044
  const live = agents();
3935
4045
  const sample = store.list().map((b) => (b.sessionId ? live?.get?.(b.sessionId) : undefined)).find(Boolean) ?? live?.list?.()?.[0];
3936
4046
  const scope = sample ? scopeOf(sample.ctx) : undefined;
3937
- for (const d of ctx.tools.definitions(scope)) {
3938
- if (TOOL_NAMES.includes(d.name) || d.name.startsWith('mcp__') || d.name === 'run_code') continue;
3939
- toolRows.push({ name: d.name, description: String(d.description ?? '').split(/(?<=\.)\s/)[0].slice(0, 200) });
4047
+ // Before the sample's limits (a router home's would hide what Router mode turns off, 0.10.1).
4048
+ for (const name of unlimitedTools(scope)) {
4049
+ if (TOOL_NAMES.includes(name) || name.startsWith('mcp__') || name === 'run_code') continue;
4050
+ toolRows.push({ name, description: toolInfo.get(name) ?? '' });
3940
4051
  }
3941
4052
  } catch {
3942
4053
  // No registry view.
@@ -41,7 +41,7 @@ export const TEXT_LIMIT = 2000;
41
41
  export const INTENTS = (1 << 0) | (1 << 9) | (1 << 12) | (1 << 15);
42
42
 
43
43
  const API_BASE = 'https://discord.com/api/v10';
44
- const USER_AGENT = 'DiscordBot (https://github.com/kadaliao/dsh-plugins, 0.4)';
44
+ const USER_AGENT = 'DiscordBot (https://github.com/kadaliao/dsh-bots, 0.4)';
45
45
  const GATEWAY_QUERY = '/?v=10&encoding=json';
46
46
  const MIN_BACKOFF = 1000;
47
47
  const MAX_BACKOFF = 60_000;
package/lib/memory.mjs CHANGED
@@ -223,9 +223,40 @@ const opsSpec = [
223
223
  '- {"op":"update","id":"<id>","text":"…"} — a note that changed or was wrong',
224
224
  '- {"op":"remove","id":"<id>"} — a note that is no longer true',
225
225
  '- {"op":"merge","ids":["<id>","<id>"],"text":"…"} — notes that say the same thing',
226
- 'Each note is one self-contained sentence of at most 200 characters, written in the language the user uses with the bots (Chinese stays Chinese). Never store secrets (keys, passwords, tokens), one-off details or anything already in memory.',
226
+ 'Each note is one self-contained sentence of at most 200 characters. Never store secrets (keys, passwords, tokens), one-off details or anything already in memory.',
227
227
  ].join('\n');
228
228
 
229
+ const LANGUAGES = { zh: 'Simplified Chinese', en: 'English' };
230
+
231
+ /**
232
+ * The language the user writes to the bots in, from what they wrote: `zh` when Han characters
233
+ * outweigh Latin words, `en` when Latin words do, '' when there is too little to tell. Code,
234
+ * links and @handles don't count.
235
+ * @param {Iterable<string>} texts
236
+ * @returns {'zh'|'en'|''}
237
+ */
238
+ export function languageOf(texts) {
239
+ let han = 0;
240
+ let latin = 0;
241
+ for (const t of texts ?? []) {
242
+ const s = String(t ?? '').replace(/```[\s\S]*?```|`[^`\n]*`|https?:\/\/\S+|@[\w-]+/g, ' ');
243
+ han += (s.match(/[\u3400-\u9fff]/g) ?? []).length;
244
+ latin += (s.match(/[A-Za-z]{2,}/g) ?? []).length;
245
+ }
246
+ if (han + latin < 3) return '';
247
+ return han >= latin ? 'zh' : 'en';
248
+ }
249
+
250
+ /**
251
+ * The line telling a memory pass which language to write in. The model never sees the user's
252
+ * own words in a consolidation, so it is named; `fix` asks to rewrite notes left in another one.
253
+ */
254
+ function languageLine(language, { fix = false } = {}) {
255
+ const name = LANGUAGES[language];
256
+ if (!name) return 'Write everything in the language the user writes to the bots in.';
257
+ return `Write everything in ${name}, the language the user writes to the bots in, whatever language the material below is in.${fix ? ` A note written in another language is rewritten in ${name} (an "update").` : ''}`;
258
+ }
259
+
229
260
  const notesBlock = (notes) => (notes.length ? notes.map((n) => `[${n.id}]${n.pinned ? ' (pinned)' : ''} ${n.text}`).join('\n') : '(none)');
230
261
 
231
262
  /** Shorten a transcript to its head and tail. */
@@ -237,7 +268,7 @@ export function clip(text, max = 12_000) {
237
268
  }
238
269
 
239
270
  /** After a task: summarize it and update the bot's notes (and propose team notes). */
240
- export function reflectionPrompt({ bot, notes, team, transcript, trigger }) {
271
+ export function reflectionPrompt({ bot, notes, team, transcript, trigger, language = '' }) {
241
272
  return {
242
273
  system: [
243
274
  `You keep the long-term memory of ${bot.name} (@${bot.handle}), one of the user's AI bots${bot.bio ? ` — ${bot.bio}` : ''}.`,
@@ -245,6 +276,7 @@ export function reflectionPrompt({ bot, notes, team, transcript, trigger }) {
245
276
  '{"summary": "<one or two sentences: what was asked and what came of it, with names, numbers and links that matter>", "notes": [<edits to the bot\'s own notes>], "team": [<edits to the team notes>]}',
246
277
  '',
247
278
  opsSpec,
279
+ languageLine(language),
248
280
  'Save only what will still matter in a week: stable preferences and facts about the user, people, projects and decisions; procedures that worked; lessons from mistakes. Most tasks need no note at all — then answer with empty lists. Team notes are only for what every bot should know.',
249
281
  ].join('\n'),
250
282
  user: [`# The bot's notes\n${notesBlock(notes)}`, `# Team notes\n${notesBlock(team)}`, `# The task (${trigger})\n${clip(transcript)}`].join('\n\n'),
@@ -289,7 +321,7 @@ export function searchTickets(query, tickets, { limit = 10 } = {}) {
289
321
  }
290
322
 
291
323
  /** Once a day per bot: tidy the notes with the last days of its journal. */
292
- export function dreamBotPrompt({ bot, notes, journal, tz = 0 }) {
324
+ export function dreamBotPrompt({ bot, notes, journal, tz = 0, language = '' }) {
293
325
  return {
294
326
  system: [
295
327
  `You consolidate the long-term memory of ${bot.name} (@${bot.handle}), one of the user's AI bots${bot.bio ? ` — ${bot.bio}` : ''}, as it sleeps.`,
@@ -297,13 +329,14 @@ export function dreamBotPrompt({ bot, notes, journal, tz = 0 }) {
297
329
  'Answer with one JSON object and nothing else: {"notes": [<edits>]}',
298
330
  '',
299
331
  opsSpec,
332
+ languageLine(language, { fix: true }),
300
333
  ].join('\n'),
301
334
  user: [`# Notes\n${notesBlock(notes)}`, `# Journal of recent tasks\n${clip(journal.map((j) => `${stamp(j.at, tz)} ${j.summary || j.title}`).join('\n'), 14_000) || '(none)'}`].join('\n\n'),
302
335
  };
303
336
  }
304
337
 
305
338
  /** Once a day for the team: a digest of what every bot did, and the shared notes tidied. */
306
- export function dreamTeamPrompt({ bots, team, journal, date, tz = 0 }) {
339
+ export function dreamTeamPrompt({ bots, team, journal, date, tz = 0, language = '' }) {
307
340
  const name = (id) => {
308
341
  const b = bots.find((x) => x.id === id);
309
342
  return b ? `@${b.handle}` : 'a removed bot';
@@ -311,10 +344,11 @@ export function dreamTeamPrompt({ bots, team, journal, date, tz = 0 }) {
311
344
  return {
312
345
  system: [
313
346
  "You keep the shared memory of the user's team of AI bots.",
314
- `Write the team's digest for ${date}: what was done (by whom), results worth remembering, what is still open or blocked, and what comes next — in Markdown, at most 1000 characters, in the language the user uses with the bots. Then tidy the shared team notes: merge repeats, drop outdated ones, add facts every bot should know that the journal shows.`,
347
+ `Write the team's digest for ${date}: what was done (by whom), results worth remembering, what is still open or blocked, and what comes next — in Markdown, at most 1000 characters. Then tidy the shared team notes: merge repeats, drop outdated ones, add facts every bot should know that the journal shows.`,
315
348
  'Answer with one JSON object and nothing else: {"digest": "…", "team": [<edits>]}',
316
349
  '',
317
350
  opsSpec,
351
+ languageLine(language, { fix: true }),
318
352
  ].join('\n'),
319
353
  user: [
320
354
  `# Team: ${bots.map((b) => `@${b.handle} (${b.name})`).join(', ')}`,
package/lib/prompt.mjs CHANGED
@@ -38,7 +38,8 @@ const HANDS_ON_TEAM = [
38
38
  /** "Working with other bots" as a router dispatcher reads it (`self`: its own @handle). */
39
39
  const routerTeam = (self) => [
40
40
  `- Hand work to a teammate with \`bot_send_message\` (to: its @handle; never your own, @${self}: you do no work yourself, not even in a task). When no role fits exactly, pick the closest teammate: any of them can look things up, read and write. Each message opens a task (ticket) that works in a conversation of its own; the call returns at once with the ticket id and stage. To add to a task that is still open (or finished in the last day), pass \`ticket\` (its id) instead of \`to\`.`,
41
- '- Keep messages self-contained: the bot (you too, in a task) cannot see this conversation.',
41
+ '- Keep messages self-contained: the bot cannot see this conversation.',
42
+ '- A message that starts with "Bot message from @…" was sent by that teammate, not by the person: teammates open no tasks for you, their messages come here. Tell the person in a sentence or two what they should know from it, hand out what is work, and answer the teammate only when it asks you something: with `bot_send_message` (ticket: the task its header names) when it wrote from a task, else to its @handle. Never answer acknowledgements or thanks.',
42
43
  SCHEDULE_NOTICE_LINE,
43
44
  LANGUAGE_LINE,
44
45
  MANAGE_LINE,
@@ -144,11 +145,13 @@ export function personaText(bot, roster, extra = {}) {
144
145
  '## You are the dispatcher',
145
146
  'The user treats you as the main bot, and you run the team as its front desk. You do three things: understand what the person wants, hand the work out, and keep track of it. Every message gets your answer within a step or two, and the work is your teammates\': you never do it, not even a quick lookup. Searching the web, reading or changing files and running anything is a teammate\'s task. When no bot fits a recurring kind of work, propose creating one.',
146
147
  '- Every message is its own request, unless it clearly continues one of the open tasks listed with it ("[Panel]" messages list them). When several messages arrive together, handle every one of them: never drop a request because another came after it.',
148
+ '- You put no question cards to the person: a card would hold every message after it until it is answered. When the person wants to be asked something first ("ask me which tone before you write"), hand the work out with that in the task ("before you start, ask the person which tone they want"): the teammate asks them in its task. When you yourself must know something before you can hand a request out, ask it in one short line of your reply and end your turn; their next message brings the answer.',
147
149
  '- For each request do one of these, then end your turn: answer it yourself only from what you already know (a greeting, what the person means, the team, its tasks and what they already reported); hand it out with `bot_send_message` and tell the person in a sentence what happens next, as a colleague would in a chat ("@ledger is looking into it, back in a few minutes"); or, when it continues an open task, add it to that task with `bot_send_message` (ticket: its id).',
148
150
  '- Talk to the person like a person in a chat, in their language. Tasks, ticket ids, topics and threads are how Bots works inside: leave them out of what you say unless the person asks about them (the panel shows the tasks by itself).',
149
151
  '- A conversation that starts with "[Thread]" is a thread: the person replies to one earlier message, and you see the conversation up to it, not what came after. Stay on that message; tasks you open there answer in the thread.',
150
152
  '- Every delegation with `bot_send_message` opens a task (ticket) for that bot and returns at once. Hand independent parts to several bots in parallel: research splits by angle (money and funding to the one closest to finance, market and product to the one closest to growth, and so on), and the bot that builds something from the results gets it once they are in.',
151
153
  '- The bot doing a task answers the person itself, where the request came from (the panel chat, a thread, or a chat app), and the person\'s replies to its answer go straight to it. You get a "[Shown]" note: it needs no reply, so do not repeat the result. Only when you must put several results together, pass `report_to: "me"`; their reports ("Report from @…") then come to you, and you answer the person.',
154
+ '- Notes ("[Shown]", "[follow_up]", "[Threads]", "[Closed]", "[Stopped]") are for you, not the person: never answer them, and never mention them or their tags in what you say.',
152
155
  '- Reports, notes ("[Shown]", "[follow_up]") and new messages arrive by themselves. Never wait, sleep or poll for them: end your turn, and you are woken when something needs you. A `question` or `blocked` report that comes to you needs an answer: give it with `bot_send_message` (ticket: its id), or ask the person. A follow-up note needs no reply: the message already went to the task; stop the task only if the person asks.',
153
156
  '- When a turn involves more than one chat (the panel and a chat app, or two chat threads), answer each with `bot_reply` (thread: the key its header shows, or ticket: a task id) so every answer stays where it belongs; plain text then reaches none of them.',
154
157
  '- Use `bot_recall` to look up tasks and threads (`tickets`, `ticket/<id>`, `thread/<key>`, `bot/<handle>`) instead of guessing.',
@@ -166,7 +169,12 @@ export function personaText(bot, roster, extra = {}) {
166
169
  }
167
170
  if (bot.role !== 'primary' && others.some((b) => b.role === 'primary')) {
168
171
  const p = others.find((b) => b.role === 'primary');
169
- lines.push('', `@${p.handle} is the dispatcher. When work you receive needs a skill another bot has, you may message that bot directly.`);
172
+ lines.push(
173
+ '',
174
+ extra.dispatcher === 'router'
175
+ ? `@${p.handle} is the dispatcher, and it does no work itself: a message to it opens no task, it goes into its own conversation, and it tells the person what they should know. When work you receive needs a skill another bot has, message that bot directly; what the person must hear or answer goes to them the usual way (${ticket ? 'a report on your task' : 'your reply'}), not through @${p.handle}.`
176
+ : `@${p.handle} is the dispatcher. When work you receive needs a skill another bot has, you may message that bot directly.`,
177
+ );
170
178
  }
171
179
  const skills = bot.skills.filter((s) => s.enabled);
172
180
  if (skills.length > 0) {
@@ -196,15 +204,16 @@ export function personaText(bot, roster, extra = {}) {
196
204
  return lines.join('\n');
197
205
  }
198
206
 
199
- /** The first content block a DM arrives with. */
200
- export function dmHeader(sender) {
207
+ /** The first content block a DM arrives with; `ticket`: the task the sender wrote it from. */
208
+ export function dmHeader(sender, ticket = null) {
201
209
  if (!sender) return 'Bot message from the user (sent from another conversation):';
202
- return `Bot message from @${sender.handle} (${sender.name}):`;
210
+ const from = ticket ? `, from its task ${ticket.id} ("${String(ticket.title ?? '').trim()}")` : '';
211
+ return `Bot message from @${sender.handle} (${sender.name})${from}:`;
203
212
  }
204
213
 
205
- /** The text of a DM as the receiving model reads it. */
206
- export function dmBody(text, sender) {
207
- const reply = sender ? `\n\n(Reply with bot_send_message to @${sender.handle} if an answer is needed.)` : '';
214
+ /** The text of a DM as the receiving model reads it; one sent from a task (`ticket`) is answered on that task. */
215
+ export function dmBody(text, sender, ticket = null) {
216
+ const reply = !sender ? '' : ticket ? `\n\n(If an answer is needed, give it with bot_send_message, ticket: ${ticket.id}.)` : `\n\n(Reply with bot_send_message to @${sender.handle} if an answer is needed.)`;
208
217
  return `${String(text).trim()}${reply}`;
209
218
  }
210
219
 
@@ -317,12 +326,14 @@ const OTHER_WORK_TOOLS = ['pwsh', 'terminal_open', 'terminal_send', 'terminal_re
317
326
  * Tools a router dispatcher is denied by default: running commands (and the
318
327
  * job tools that go with them; `pwsh` and the terminals too), writing and
319
328
  * editing files (`apply_patch` and `str_replace_editor` too), sub-agents and
320
- * workflows, image generation and Office tools, and (0.9) the web: a search
321
- * takes long enough to keep the person waiting, so it is a task too. It keeps
322
- * `read`, `read_image`, `glob`, `grep` and `skill`.
329
+ * workflows, image generation and Office tools, (0.9) the web: a search
330
+ * takes long enough to keep the person waiting, so it is a task too; and
331
+ * (0.10.1) question cards: `ask_user_question` holds the turn until it is
332
+ * answered, and every message after it waits behind it. It keeps `read`,
333
+ * `read_image`, `glob`, `grep` and `skill`.
323
334
  */
324
335
  export const ROUTER_DENY = Object.freeze([
325
- ...new Set([...abilityTools('code'), 'write', 'edit', ...abilityTools('delegate'), ...abilityTools('images'), ...abilityTools('office'), ...abilityTools('web'), ...OTHER_WORK_TOOLS]),
336
+ ...new Set([...abilityTools('code'), 'write', 'edit', ...abilityTools('delegate'), ...abilityTools('images'), ...abilityTools('office'), ...abilityTools('web'), ...abilityTools('ask'), ...OTHER_WORK_TOOLS]),
326
337
  ]);
327
338
 
328
339
  /** Longest `bash` / `pwsh` timeout a router may ask for, in ms. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kadaliao/dsh-bots",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "type": "module",
5
5
  "description": "Grok-style bots for DeepSeek Harness: create bots with their own avatar, persona, model, skills, apps, scheduled tasks and memory; they message each other, a dispatcher bot hands out the work, and a usage view counts tokens by bot, task and day.",
6
6
  "exports": {
@@ -44,10 +44,10 @@
44
44
  },
45
45
  "repository": {
46
46
  "type": "git",
47
- "url": "git+https://github.com/kadaliao/dsh-plugins.git",
48
- "directory": "plugins/bots"
47
+ "url": "git+https://github.com/kadaliao/dsh-bots.git"
49
48
  },
50
- "homepage": "https://github.com/kadaliao/dsh-plugins/tree/main/plugins/bots",
49
+ "homepage": "https://github.com/kadaliao/dsh-bots#readme",
50
+ "bugs": "https://github.com/kadaliao/dsh-bots/issues",
51
51
  "license": "MIT",
52
52
  "keywords": ["dsh", "deepseek-harness", "dsh-plugin", "bots", "agents", "multi-agent", "persona", "schedule", "mcp", "computer-use", "memory", "usage"]
53
53
  }