@kadaliao/dsh-bots 0.10.0 → 0.10.1

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
@@ -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,7 +275,9 @@ 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.
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.
273
281
  - **AI avatars**: with the [Images plugin](../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
@@ -494,7 +502,9 @@ one connection. If you change scopes later, reinstall the app to the workspace a
494
502
  task it is, who asked, and how to report. Edits apply at once; a new or changed app connects the next
495
503
  time the conversation starts.
496
504
  - 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,
505
+ a task's conversation it reports to whoever asked (with a status) or opens a sub-task. A message to the
506
+ dispatcher opens no task: it goes into the dispatcher's own conversation (one sent from a task names it, and the
507
+ dispatcher's answer is added to that task). In Hands-on mode,
498
508
  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
509
  bots may exchange at most 16 messages in 10 minutes (new tasks and messages added to tasks count), so
500
510
  conversations end.
package/README.zh-CN.md CHANGED
@@ -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,7 +210,8 @@ Bot 在普通的 Harness 会话里工作,所以 Harness 能做的它都能做
206
210
  | 地图与本地 | 高德地图 🔑、百度地图 🔑 |
207
211
  | 自定义 | 任意本地(stdio)或远程(Streamable HTTP)MCP 服务 |
208
212
 
209
- - **定时任务**:就是 Harness 的定时任务,也出现在「自动化」页面;
213
+ - **定时任务**:就是 Harness 的定时任务,也出现在「自动化」页面。Harness 没开着时错过的定时任务,下次启动时由 Harness 补跑,
214
+ 每个只补最近的那一次(这是 Harness 的规则,Bots 不另外补);团队的定时任务多时,启动后会一下子开出好几个任务、用掉不少 token。
210
215
  - **AI 头像**:装了 [图片插件](../images) 就能按 bot 的人设生成头像。bot 自己也能做:让调度员给团队换一批头像,
211
216
  说清楚想要的样子就行,也可以指给它一张本地图片。bot 画头像是在后台进行的,不耽误它回你的话:画的时候头像上有一圈在转,
212
217
  画好就换上;画好了(或没画成、为什么)bot 会收到通知并告诉你。Harness 重启会丢掉正在画的头像。
@@ -395,7 +400,8 @@ Slack 走 Socket Mode:由 Harness 主动连到 Slack,电脑不需要公网
395
400
  - 会话运行时,bot 的人设和团队名单加入系统提示词;它自己的技能、能力限制和应用只作用于它自己的会话。
396
401
  任务的会话里,提示词还会说明这是哪个任务、谁发起的、怎么汇报。修改即时生效;新增或修改应用在下次会话启动时连接。
397
402
  - 「只调度」模式下,`bot_send_message` 在 bot 自己的会话里调用就开一个任务并立刻返回;在任务的会话里调用,
398
- 要么带状态向发起方汇报,要么开一个子任务。「亲自动手」模式下,从 bot 自己的会话发出的消息放进对方的收件箱并唤醒它,
403
+ 要么带状态向发起方汇报,要么开一个子任务。发给调度员的不开任务,放进它自己的会话(从任务里发的会注明是哪个任务,
404
+ 调度员回话时追加到那个任务)。「亲自动手」模式下,从 bot 自己的会话发出的消息放进对方的收件箱并唤醒它,
399
405
  和 0.7 一样。同一对 bot 10 分钟内最多互发 16 条(新开的任务和追加给任务的消息都算),防止无限对话。
400
406
  - 所有会话都能用 `bot_list`、`bot_create`、`bot_update`、`bot_delete`、`bot_send_message`、`bot_reply`、`bot_recall`、
401
407
  `bot_ticket`、`bot_schedule` 管理 bot 和任务,以及 `memory_save`、`memory_forget`、`memory_search`。
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.1';
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
@@ -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 : [])])];
@@ -1145,7 +1179,9 @@ export function apply(ctx, config, deps = {}) {
1145
1179
  * without `inject` gets nothing for an 'inject' (`dropped`): such a note never wakes a turn.
1146
1180
  * - `key`: makes the message id `bots:<key>`; a message with that id already pending or delivered
1147
1181
  * is not delivered again, so a retried request is harmless.
1148
- * @returns {{message: object, mode: string, skipped: boolean, dropped?: true}}
1182
+ * An 'inject' for a conversation in the middle of a turn is held until it is idle (`held`, see
1183
+ * `holdNote`).
1184
+ * @returns {{message: object, mode: string, skipped: boolean, dropped?: true, held?: true}}
1149
1185
  */
1150
1186
  async function sendTo(agent, { content: blocks, source, mode = 'followup', key }) {
1151
1187
  // Providers that take a message as one string join its blocks with nothing in between:
@@ -1157,15 +1193,55 @@ export function apply(ctx, config, deps = {}) {
1157
1193
  if (key) await loadHistory(agent.session?.id);
1158
1194
  if (key && holds(agent, message.id)) return { message, mode, skipped: true };
1159
1195
  const how = mode === 'inject' ? 'inject' : mode !== 'followup' && typeof agent.steer === 'function' ? 'steer' : 'followup';
1196
+ if (how === 'inject' && agent.status === 'running') {
1197
+ holdNote(agent, message);
1198
+ if (key) noteDelivered(agent.session?.id, message.id);
1199
+ return { message, mode: how, skipped: false, held: true };
1200
+ }
1160
1201
  agent[how](message);
1161
1202
  if (key) noteDelivered(agent.session?.id, message.id);
1162
1203
  await flush(agent);
1163
1204
  return { message, mode: how, skipped: false };
1164
1205
  }
1206
+ /**
1207
+ * Notes ("[Shown]", "[follow_up]", "[Closed]") for conversations that were working when they came,
1208
+ * by Session: `{agent, messages}`. Injected into a running turn, a note is the newest input of its
1209
+ * next step, and the model answers it, to the person ("[已展示]: nothing for me to do…", 0.10.1).
1210
+ * They need no answer, so they wait for the turn's end and go in then, waking nothing. In memory
1211
+ * only: a note lost with the process was only good to know.
1212
+ */
1213
+ const heldNotes = new Map();
1214
+ function holdNote(agent, message) {
1215
+ const sid = agent.session?.id;
1216
+ if (!sid) return;
1217
+ const held = heldNotes.get(sid) ?? { agent, messages: [] };
1218
+ held.agent = agent;
1219
+ held.messages.push(message);
1220
+ heldNotes.set(sid, held);
1221
+ }
1222
+ /** The conversation `sessionId` went idle: its held notes go in now, in the order they came. */
1223
+ function releaseNotes(sessionId, agent) {
1224
+ const held = heldNotes.get(sessionId);
1225
+ if (!held) return;
1226
+ heldNotes.delete(sessionId);
1227
+ const to = agent ?? held.agent;
1228
+ for (const m of held.messages) {
1229
+ try {
1230
+ to.inject(m);
1231
+ } catch (error) {
1232
+ ctx.logger?.info?.(`bots: a held note did not reach ${sessionId}: ${error?.message ?? error}`);
1233
+ }
1234
+ }
1235
+ void flush(to);
1236
+ }
1165
1237
  /** How a bot's home takes new input: a router steers (backlog is handled together), every other home as in 0.7. */
1166
1238
  const homeMode = (bot) => (isRouter(store.get(bot.id) ?? bot) ? 'steer' : 'followup');
1167
1239
 
1168
- /** A DM from `sender` (a bot, or null for the user) to `target`'s home: 0.7's bot-to-bot message. */
1240
+ /**
1241
+ * A DM from `sender` (a bot, or null for the user) to `target`'s home: 0.7's bot-to-bot message,
1242
+ * and (0.10.1) a teammate's message to the router dispatcher. One sent from a task names it, so the
1243
+ * answer goes to that task. Its id (`bots:dm:…`) keeps it a message, not a report on the sender's task.
1244
+ */
1169
1245
  async function deliver(sender, target, text, senderSessionId) {
1170
1246
  const body = String(text ?? '').trim();
1171
1247
  if (body === '') throw new Error('text must not be empty');
@@ -1174,13 +1250,15 @@ export function apply(ctx, config, deps = {}) {
1174
1250
  // A teammate's message may answer this bot's own question: only a long quiet starts a new topic here.
1175
1251
  await autoTopic(store.get(target.id) ?? target, sender ? 'dm' : 'user');
1176
1252
  const agent = await agentOf(store.get(target.id) ?? target);
1253
+ const fromTask = sender ? ticketOf(senderSessionId) : undefined;
1177
1254
  await sendTo(agent, {
1178
1255
  content: [
1179
- { type: 'text', text: dmHeader(sender) },
1180
- { type: 'text', text: dmBody(body, sender) },
1256
+ { type: 'text', text: dmHeader(sender, fromTask) },
1257
+ { type: 'text', text: dmBody(body, sender, fromTask) },
1181
1258
  ],
1182
1259
  source: senderSessionId ? { kind: 'agent-message', form: 'relay', senderSessionId } : { kind: 'user' },
1183
1260
  mode: homeMode(target),
1261
+ key: `dm:${randomUUID()}`,
1184
1262
  });
1185
1263
  store.log({ from: sender ? sender.id : 'user', to: target.id, text: body, kind: 'dm' });
1186
1264
  return agent.session.id;
@@ -1979,6 +2057,8 @@ export function apply(ctx, config, deps = {}) {
1979
2057
  : 'a bot cannot message itself',
1980
2058
  );
1981
2059
  }
2060
+ // Nor does it take tasks from its teammates (0.10.1): their messages go into its conversation (bot_send_message).
2061
+ 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
2062
  if (!service(ctx, 'sessionController')) throw new Error('tasks need the Web profile (no session controller here)');
1983
2063
  const parent = ticketOf(senderSessionId);
1984
2064
  const { origin, thread } = originOfTurn(senderSessionId, chosen);
@@ -2559,6 +2639,7 @@ export function apply(ctx, config, deps = {}) {
2559
2639
  answered.delete(sessionId);
2560
2640
  turnState.delete(sessionId);
2561
2641
  activity.clear(sessionId);
2642
+ heldNotes.delete(sessionId);
2562
2643
  }
2563
2644
  /** Kinds of user message that start (or join) a task. */
2564
2645
  const TASK_KINDS = new Set(['user', 'schedule', 'agent-message']);
@@ -2775,6 +2856,7 @@ export function apply(ctx, config, deps = {}) {
2775
2856
  ctx.on('agent/status', (payload) => {
2776
2857
  try {
2777
2858
  const sid = payload?.agent?.session?.id;
2859
+ if (sid && payload.status === 'idle') releaseNotes(sid, payload.agent);
2778
2860
  if (sid && payload.status === 'idle') activity.clear(sid);
2779
2861
  if (sid && payload.status === 'idle' && openTasks.has(sid)) settleSoon(sid, 300);
2780
2862
  else if (sid && payload.status === 'idle' && memoStale.delete(sid)) memoText.delete(sid);
@@ -3537,7 +3619,7 @@ export function apply(ctx, config, deps = {}) {
3537
3619
  '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
3620
  "- 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
3621
  '- 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.',
3622
+ '- 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
3623
  '- 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
3624
  '- 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
3625
  '- In a task conversation, to report to whoever asked: leave out `to`, give `text` and a `status` (progress, done, blocked, question).',
@@ -3603,6 +3685,18 @@ export function apply(ctx, config, deps = {}) {
3603
3685
  }
3604
3686
  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
3687
 
3688
+ // A teammate's message to the router dispatcher (0.10.1): no task for it (it does no work itself),
3689
+ // the text goes into its own conversation, where its router limits hold and it routes it.
3690
+ if (sender && named.id !== sender.id && isRouter(named)) {
3691
+ await deliver(sender, named, args.text, sessionId);
3692
+ return {
3693
+ ok: true,
3694
+ 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.`,
3695
+ to: face(named),
3696
+ from: face(sender),
3697
+ };
3698
+ }
3699
+
3606
3700
  // A new ticket: from a task conversation (a sub-task), or from a bot's home when tasks are on.
3607
3701
  if (sender && sessionId && (mine || (ticketsOn() && isHomeOf(sender, sessionId)))) {
3608
3702
  const relay = String(args.report_to ?? '').trim().toLowerCase() === 'me';
@@ -3934,9 +4028,10 @@ export function apply(ctx, config, deps = {}) {
3934
4028
  const live = agents();
3935
4029
  const sample = store.list().map((b) => (b.sessionId ? live?.get?.(b.sessionId) : undefined)).find(Boolean) ?? live?.list?.()?.[0];
3936
4030
  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) });
4031
+ // Before the sample's limits (a router home's would hide what Router mode turns off, 0.10.1).
4032
+ for (const name of unlimitedTools(scope)) {
4033
+ if (TOOL_NAMES.includes(name) || name.startsWith('mcp__') || name === 'run_code') continue;
4034
+ toolRows.push({ name, description: toolInfo.get(name) ?? '' });
3940
4035
  }
3941
4036
  } catch {
3942
4037
  // No registry view.
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.1",
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": {