Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Put Bots in the composer's @ menu and reference chats from +

FeiZhuLulu805782f48031
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 83de4c1d..2aae488e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,10 +4,20 @@ All notable changes to DS Bot are listed here. The format follows [Keep a Change
## [Unreleased]
+### Added
+
+- In a Bot's chat or a group chat, `@` lists the Bots you can mention first: a group's members and **Everyone**, or the other Bots. Picking one writes `@Name`.
+- **Reference a chat** in the composer's **+** menu adds another Bot's chat, or a recent conversation outside the team, to your message as context.
+
### Changed
- Every Bot can change its own name, role, color, model and instructions; only a Main Bot changes other Bots.
+### Fixed
+
+- In a group chat, a conversation referenced in a message reached none of the members, and a reference whose title started with a member's name called that member. Now the members who answer the message get the referenced conversation.
+- In a group chat, typing `@` and a Bot's name and pressing Enter inserted a conversation reference instead of the Bot's name.
+
## [0.1.2] - 2026-10-11
### Added
diff --git a/README.md b/README.md
index f2e6d847..d0e9efc2 100644
--- a/README.md
+++ b/README.md
@@ -58,7 +58,7 @@ In short: have a question? Ask the main bot.
### Group chats
-DS Bot has group chats. A group chat is a great way to get several bots to work together, but it clearly costs more. So DS Bot does this: every group chat has an admin. The admin answers your messages by default and calls in the other bots for you. You can also @ a bot directly, and it answers you directly.
+DS Bot has group chats. A group chat is a great way to get several bots to work together, but it clearly costs more. So DS Bot does this: every group chat has an admin. The admin answers your messages by default and calls in the other bots for you. You can also @ a bot directly, and it answers you directly: type @ and pick the bot from the list. To give the bots another chat as context, use + → Reference a chat in the message box.
![Group chat: the admin, Chief, hands the work to Writer and Coder](docs/images/group.png)
diff --git a/README.zh.md b/README.zh.md
index 24544492..b4a28f3f 100644
--- a/README.zh.md
+++ b/README.zh.md
@@ -58,7 +58,7 @@ npx @deepseek-ai/[email protected] web
### 群聊
-ds bot 拥有群聊功能。群聊是非常好的多 bot 协作方式,但它会带来非常明显的费用问题。ds bot 为此特意做了优化:在一个群聊中,你需要设置一个管理员。你的消息默认由管理员回复,它会帮你调用其他 bot。你也可以直接 @ 你需要沟通的 bot,它会直接回应你。
+ds bot 拥有群聊功能。群聊是非常好的多 bot 协作方式,但它会带来非常明显的费用问题。ds bot 为此特意做了优化:在一个群聊中,你需要设置一个管理员。你的消息默认由管理员回复,它会帮你调用其他 bot。你也可以直接 @ 你需要沟通的 bot,它会直接回应你:输入 @,从列表里选 bot 就行。想让 bot 参考另一段对话,点输入框的 + → 引用对话。
![群聊:管理员 Chief 把活派给写手和程序员](docs/images/group.zh.png)
diff --git a/ds-bot/README.md b/ds-bot/README.md
index a3f329df..86c870a9 100644
--- a/ds-bot/README.md
+++ b/ds-bot/README.md
@@ -10,7 +10,7 @@ Tested with dsh `0.2.1-alpha.1` (Web and Desktop) on Linux.
- **Long-lived Bots**: each Bot is a dsh Session in the "DS Bot" workspace, with its own name, role, instructions and model.
- **Bots work together**: `message_bot` sends a message to another Bot, `create_bot` and `update_bot` add and set up Bots, and `ask_user` asks you a question without blocking the other Bots.
-- **Group chats**: members speak one at a time, and each one reads the latest messages first. A message can `@Name` a member to pass the turn on. A member with nothing new to add stays quiet (`[PASS]`). Each member has its own hidden Session per group, so a group never reads a Bot's private chat.
+- **Group chats**: members speak one at a time, and each one reads the latest messages first. A message can `@Name` a member to pass the turn on; type `@` to pick one from a list. **+ → Reference a chat** adds another Bot's chat to a message as context, and in a group the members who answer get it. A member with nothing new to add stays quiet (`[PASS]`). Each member has its own hidden Session per group, so a group never reads a Bot's private chat.
- **Roles and permissions**:
| Who | Can do |
diff --git a/ds-bot/client.js b/ds-bot/client.js
index acc2892d..af263a87 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -746,6 +746,8 @@ var ZH = {
"Its group conversation could not open": "它的群聊会话打不开",
// The composer's +
"Add files": "添加文件",
+ "Reference a chat": "引用对话",
+ "Chat with {name}": "与 {name} 的对话",
"Scheduled task": "定时任务",
"Send to": "发给",
"Scheduled task: {text}": "定时任务:{text}",
@@ -5472,7 +5474,16 @@ function ComposerVoice({ sessionId, inputActions, actions, useUi }) {
dictation.note ? (0, import_react10.createElement)("span", { className: "bt-mic-note", role: "status" }, dictation.note) : null
);
}
-function ComposerPlus({ sessionId, useRoster, actions }) {
+function menuIcons(roster) {
+ const marks = /* @__PURE__ */ new Map();
+ return (row) => {
+ if (!row.bot) return PeopleIcon;
+ const id = row.bot.id;
+ if (!marks.has(id)) marks.set(id, ({ size = 14 }) => (0, import_react10.createElement)(BotMark, { bot: roster.getSnapshot().byId[id] ?? row.bot, size }));
+ return marks.get(id);
+ };
+}
+function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {
const roster = useRoster((value) => value);
const [open, setOpen] = (0, import_react10.useState)(null);
const [shown, leaving] = useLinger(open, 120);
@@ -5514,6 +5525,11 @@ function ComposerPlus({ sessionId, useRoster, actions }) {
setOpen(null);
actions.openSettings("schedules", target);
};
+ const reference = () => {
+ setOpen(null);
+ actions.referenceChat(sessionId, inputActions?.captureInsertion?.());
+ };
+ const canReference = typeof inputActions?.captureInsertion === "function" && actions.canReferenceChat();
return (0, import_react10.createElement)(
import_react10.Fragment,
null,
@@ -5539,11 +5555,100 @@ function ComposerPlus({ sessionId, useRoster, actions }) {
"data-leaving": leaving || void 0
},
(0, import_react10.createElement)("button", { type: "button", role: "menuitem", onClick: attach }, (0, import_react10.createElement)(PaperclipIcon), (0, import_react10.createElement)("span", { className: "bt-menu-label" }, t("Add files"))),
+ canReference ? (0, import_react10.createElement)("button", { type: "button", role: "menuitem", onMouseDown: keepComposerFocus, onClick: reference }, (0, import_react10.createElement)(ChatsIcon), (0, import_react10.createElement)("span", { className: "bt-menu-label" }, t("Reference a chat"))) : null,
(0, import_react10.createElement)("button", { type: "button", role: "menuitem", onClick: schedule }, (0, import_react10.createElement)(ClockIcon), (0, import_react10.createElement)("span", { className: "bt-menu-label" }, t("Scheduled task")))
), document.body) : null
);
}
+// src/client/at-menu.js
+var BOTS_SOURCE = "ds-bot";
+var CHATS_SOURCE = "ds-bot-chats";
+var ROOM_ALL = ["all", "everyone", "所有人", "全体"];
+var OTHER_CHATS_MAX = 8;
+var conversationOf = (roster, sessionId) => {
+ if (!roster.ready) return null;
+ const room2 = roster.roomsById[sessionId];
+ if (room2) return { room: room2 };
+ const self2 = roster.byId[sessionId];
+ return self2 ? { self: self2 } : null;
+};
+function mentionRows(roster, sessionId, query = "") {
+ const here = conversationOf(roster, sessionId);
+ if (here === null) return null;
+ const bots = here.room ? here.room.members.map((id) => roster.byId[id]).filter(Boolean) : roster.bots.filter((bot) => bot.id !== here.self.id);
+ const needle = query.trim().toLowerCase();
+ const rows = bots.filter((bot) => bot.name.toLowerCase().includes(needle)).map((bot) => ({ bot, text: `@${bot.name} ` }));
+ const everyone = t("Everyone");
+ if (here.room && bots.length > 1 && [everyone, ...ROOM_ALL].some((word) => word.toLowerCase().startsWith(needle))) {
+ rows.push({ room: here.room, text: `@${everyone} ` });
+ }
+ return rows;
+}
+function chatRows(roster, list, sessionId) {
+ const here = conversationOf(roster, sessionId);
+ if (here === null) return [];
+ const byId = list?.byId ?? {};
+ const bots = roster.bots.filter((bot) => bot.id !== here.self?.id).map((bot) => {
+ const id = currentPart(bot);
+ return { sessionId: id, label: t("Chat with {name}", { name: bot.name }), bot, updatedAt: byId[id]?.updatedAt };
+ });
+ const team = /* @__PURE__ */ new Set([
+ ...roster.bots.flatMap((bot) => [bot.id, currentPart(bot), ...bot.parts ?? []]),
+ ...roster.rooms.flatMap((room2) => [room2.id, ...room2.parts ?? []])
+ ]);
+ const others = (list?.ids ?? []).map((id) => byId[id]).filter((row) => row !== void 0 && row.id !== sessionId && !team.has(row.id) && row.origin !== "subagent" && row.blank !== true).sort((a, b) => (b.updatedAt ?? 0) - (a.updatedAt ?? 0)).slice(0, OTHER_CHATS_MAX).map((row) => ({ sessionId: row.id, label: row.displayTitle || row.title || row.id, updatedAt: row.updatedAt }));
+ return [...bots, ...others];
+}
+function sessionMention(sessionId, label) {
+ let binary = "";
+ for (const byte of new TextEncoder().encode(JSON.stringify(sessionId))) binary += String.fromCharCode(byte);
+ const payload = btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
+ return `@[${label.replace(/[\\\]]/g, (mark) => `\\${mark}`)}](dsh-session:${payload})`;
+}
+function atSources({ roster, sessions, launched, iconFor }) {
+ const bots = {
+ trigger: "@",
+ name: BOTS_SOURCE,
+ order: -20,
+ showGroupTitle: false,
+ async candidates(session, { query }) {
+ return (mentionRows(roster.getSnapshot(), session.sessionId, query) ?? []).map((row) => ({
+ name: row.bot ? row.bot.name : t("Everyone"),
+ ...row.bot?.role ? { description: row.bot.role } : {},
+ ...row.room ? { description: t("{count} members", { count: row.room.members.length }) } : {},
+ icon: iconFor(row),
+ section: t("Bots"),
+ value: row.text
+ }));
+ },
+ onPick: ({ candidate }) => candidate.value ? { text: candidate.value } : void 0
+ };
+ const chats = {
+ trigger: "@",
+ name: CHATS_SOURCE,
+ order: -10,
+ showGroupTitle: false,
+ async candidates(session) {
+ if (!launched(session.sessionId)) return [];
+ return chatRows(roster.getSnapshot(), sessions.list.getSnapshot(), session.sessionId).map((row) => ({
+ name: row.bot ? row.bot.name : row.label,
+ ...row.updatedAt ? { description: relativeShort(row.updatedAt) } : {},
+ icon: row.bot ? iconFor(row) : "session",
+ section: row.bot ? t("Bots") : t("Conversations"),
+ value: JSON.stringify({ sessionId: row.sessionId, label: row.label })
+ }));
+ },
+ onPick({ candidate }) {
+ const { sessionId, label } = JSON.parse(candidate.value);
+ const mention = sessionMention(sessionId, label);
+ return { insert: { source: CHATS_SOURCE, ref: mention, label, appearance: "session", clipboardText: mention } };
+ },
+ codec: { clipboardText: (ref) => ref, serialize: (ref) => Promise.resolve(ref) }
+ };
+ return [bots, chats];
+}
+
// src/client/speech.js
var VOICE_BUNDLE = "@deepseek-ai/dsh-experimental-voice-input-bundle";
var USABLE = /* @__PURE__ */ new Set(["ready", "standby", "waking"]);
@@ -12679,6 +12784,32 @@ function apply(ctx) {
} };
};
const shadow = (name, options, component) => ctx.slots.inject(name, () => ctx.slots.register({ name, ...options }, component));
+ let atMenu = null;
+ const installAtMenu = () => {
+ const fiber = ctx.inject(["inputTriggers"], (scope) => {
+ scope.effect(() => {
+ const triggers = scope.inputTriggers;
+ const controllerOf = (sessionId) => {
+ const binding = ctx.sessions.binding(sessionId);
+ return binding === void 0 ? void 0 : triggers.sessionOf(binding.ctx);
+ };
+ const launched = (sessionId) => controllerOf(sessionId)?.launcher.getSnapshot() === CHATS_SOURCE;
+ const offs = atSources({ roster, sessions: ctx.sessions, launched, iconFor: menuIcons(roster) }).map((source) => triggers.registerSource(source));
+ atMenu = { controllerOf };
+ return () => {
+ atMenu = null;
+ for (const off of offs) off();
+ };
+ }, "ds-bot: @ menu");
+ });
+ return () => fiber.dispose();
+ };
+ actions.canReferenceChat = () => atMenu !== null;
+ actions.referenceChat = (sessionId, span) => {
+ const controller = atMenu?.controllerOf(sessionId);
+ if (controller === void 0 || span === void 0) return;
+ controller.toggleSource(CHATS_SOURCE, { trigger: "@", query: "", quoted: false, position: "inline", span });
+ };
const installShell = () => [
installCompiledStyles(SHELL_CSS, "shell"),
installCompiledStyles(SIDEBAR_CSS, "sidebar"),
@@ -12709,6 +12840,7 @@ function apply(ctx) {
installCompiledStyles(CONVERSATION_CSS, "conversation"),
installBubbleTokens(),
installMentions(),
+ installAtMenu(),
// Bot conversations are always flat, so the work-details mode is not a choice:
// the mode is held at `verbose` while this group is mounted.
holdFlatTranscript(ctx.configForms.get("ui-chat")),
diff --git a/ds-bot/src/client/at-menu.js b/ds-bot/src/client/at-menu.js
new file mode 100644
index 00000000..64d6cf05
--- /dev/null
+++ b/ds-bot/src/client/at-menu.js
@@ -0,0 +1,115 @@
+// -------------------------------------------------------------------------
+// The composer's "@" in a Bot's chat or a group chat: a Bot group that inserts
+// "@Name", and the chats that "+ → Reference a chat" opens in the same menu.
+// Both are sources of the shell's trigger menu; the shell's own file and session
+// rows stay beside them, because a source cannot be hidden for one Session.
+import { t } from './i18n.js'
+import { currentPart, relativeShort } from './text.js'
+
+export const BOTS_SOURCE = 'ds-bot'
+export const CHATS_SOURCE = 'ds-bot-chats'
+// The words the group host reads as "everyone" (groups.js ROOM_ALL).
+const ROOM_ALL = ['all', 'everyone', '所有人', '全体']
+const OTHER_CHATS_MAX = 8
+
+const conversationOf = (roster, sessionId) => {
+ if (!roster.ready) return null
+ const room = roster.roomsById[sessionId]
+ if (room) return { room }
+ const self = roster.byId[sessionId]
+ return self ? { self } : null
+}
+
+// What "@query" offers: a group's members and "everyone", or in a Bot's chat every
+// other Bot. Null outside the team, so a plain Session keeps the shell's menu alone.
+export function mentionRows(roster, sessionId, query = '') {
+ const here = conversationOf(roster, sessionId)
+ if (here === null) return null
+ const bots = here.room
+ ? here.room.members.map(id => roster.byId[id]).filter(Boolean)
+ : roster.bots.filter(bot => bot.id !== here.self.id)
+ const needle = query.trim().toLowerCase()
+ const rows = bots.filter(bot => bot.name.toLowerCase().includes(needle)).map(bot => ({ bot, text: `@${bot.name} ` }))
+ const everyone = t('Everyone')
+ if (here.room && bots.length > 1 && [everyone, ...ROOM_ALL].some(word => word.toLowerCase().startsWith(needle))) {
+ rows.push({ room: here.room, text: `@${everyone} ` })
+ }
+ return rows
+}
+
+// The chats a message here can reference: every other Bot's chat, then the latest
+// conversations outside the team. Group chats stay out: a group's Session holds only
+// the user's messages, so a snapshot of it would miss every Bot's reply.
+export function chatRows(roster, list, sessionId) {
+ const here = conversationOf(roster, sessionId)
+ if (here === null) return []
+ const byId = list?.byId ?? {}
+ const bots = roster.bots.filter(bot => bot.id !== here.self?.id).map((bot) => {
+ const id = currentPart(bot)
+ return { sessionId: id, label: t('Chat with {name}', { name: bot.name }), bot, updatedAt: byId[id]?.updatedAt }
+ })
+ const team = new Set([
+ ...roster.bots.flatMap(bot => [bot.id, currentPart(bot), ...(bot.parts ?? [])]),
+ ...roster.rooms.flatMap(room => [room.id, ...(room.parts ?? [])]),
+ ])
+ const others = (list?.ids ?? []).map(id => byId[id])
+ .filter(row => row !== undefined && row.id !== sessionId && !team.has(row.id) && row.origin !== 'subagent' && row.blank !== true)
+ .sort((a, b) => (b.updatedAt ?? 0) - (a.updatedAt ?? 0))
+ .slice(0, OTHER_CHATS_MAX)
+ .map(row => ({ sessionId: row.id, label: row.displayTitle || row.title || row.id, updatedAt: row.updatedAt }))
+ return [...bots, ...others]
+}
+
+// DSH's canonical session mention: `@[label](dsh-session:<base64url of the JSON id>)`.
+// The host turns it into "@label" plus a read-only snapshot of that Session.
+export function sessionMention(sessionId, label) {
+ let binary = ''
+ for (const byte of new TextEncoder().encode(JSON.stringify(sessionId))) binary += String.fromCharCode(byte)
+ const payload = btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')
+ return `@[${label.replace(/[\\\]]/g, mark => `\\${mark}`)}](dsh-session:${payload})`
+}
+
+// `launched(sessionId)`: whether "+ → Reference a chat" opened the menu, so the chats
+// never join a typed "@". `iconFor(row)` is the row's character mark.
+export function atSources({ roster, sessions, launched, iconFor }) {
+ const bots = {
+ trigger: '@',
+ name: BOTS_SOURCE,
+ order: -20,
+ showGroupTitle: false,
+ async candidates(session, { query }) {
+ return (mentionRows(roster.getSnapshot(), session.sessionId, query) ?? []).map(row => ({
+ name: row.bot ? row.bot.name : t('Everyone'),
+ ...(row.bot?.role ? { description: row.bot.role } : {}),
+ ...(row.room ? { description: t('{count} members', { count: row.room.members.length }) } : {}),
+ icon: iconFor(row),
+ section: t('Bots'),
+ value: row.text,
+ }))
+ },
+ onPick: ({ candidate }) => (candidate.value ? { text: candidate.value } : undefined),
+ }
+ const chats = {
+ trigger: '@',
+ name: CHATS_SOURCE,
+ order: -10,
+ showGroupTitle: false,
+ async candidates(session) {
+ if (!launched(session.sessionId)) return []
+ return chatRows(roster.getSnapshot(), sessions.list.getSnapshot(), session.sessionId).map(row => ({
+ name: row.bot ? row.bot.name : row.label,
+ ...(row.updatedAt ? { description: relativeShort(row.updatedAt) } : {}),
+ icon: row.bot ? iconFor(row) : 'session',
+ section: row.bot ? t('Bots') : t('Conversations'),
+ value: JSON.stringify({ sessionId: row.sessionId, label: row.label }),
+ }))
+ },
+ onPick({ candidate }) {
+ const { sessionId, label } = JSON.parse(candidate.value)
+ const mention = sessionMention(sessionId, label)
+ return { insert: { source: CHATS_SOURCE, ref: mention, label, appearance: 'session', clipboardText: mention } }
+ },
+ codec: { clipboardText: ref => ref, serialize: ref => Promise.resolve(ref) },
+ }
+ return [bots, chats]
+}
diff --git a/ds-bot/src/client/composer.js b/ds-bot/src/client/composer.js
index d9c97901..53fad47c 100644
--- a/ds-bot/src/client/composer.js
+++ b/ds-bot/src/client/composer.js
@@ -1,6 +1,7 @@
import { createElement as h, Fragment, useEffect, useRef, useState } from 'react'
import { createPortal } from 'react-dom'
-import { ClockIcon, MicIcon, PaperclipIcon, PlusIcon, WaveIcon } from './icons.js'
+import { ChatsIcon, ClockIcon, MicIcon, PaperclipIcon, PeopleIcon, PlusIcon, WaveIcon } from './icons.js'
+import { BotMark } from './mark.js'
import { useLinger } from './motion.js'
import { t } from './i18n.js'
@@ -88,11 +89,24 @@ export function ComposerVoice({ sessionId, inputActions, actions, useUi }) {
dictation.note ? h('span', { className: 'bt-mic-note', role: 'status' }, dictation.note) : null)
}
-// The composer's "+" in a Bot's chat or a group chat: add files, or set a scheduled
-// task for this chat. It stands in for the shell's command menu, whose plan,
-// permission, model and compact rows reach past what DS Bot keeps for its Bots; "/"
-// still opens that menu. Files go through the shell's own file input beside it.
-export function ComposerPlus({ sessionId, useRoster, actions }) {
+// Character marks for the "@" menu rows. Each Bot keeps one component, so the menu
+// does not remount its mark on every keystroke.
+export function menuIcons(roster) {
+ const marks = new Map()
+ return (row) => {
+ if (!row.bot) return PeopleIcon
+ const id = row.bot.id
+ if (!marks.has(id)) marks.set(id, ({ size = 14 }) => h(BotMark, { bot: roster.getSnapshot().byId[id] ?? row.bot, size }))
+ return marks.get(id)
+ }
+}
+
+// The composer's "+" in a Bot's chat or a group chat: add files, reference another
+// chat, or set a scheduled task for this chat. It stands in for the shell's command
+// menu, whose plan, permission, model and compact rows reach past what DS Bot keeps
+// for its Bots; "/" still opens that menu. Files go through the shell's own file
+// input beside it.
+export function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {
const roster = useRoster(value => value)
const [open, setOpen] = useState(null)
const [shown, leaving] = useLinger(open, 120)
@@ -121,6 +135,13 @@ export function ComposerPlus({ sessionId, useRoster, actions }) {
setOpen(null)
actions.openSettings('schedules', target)
}
+ // The chats open in the shell's "@" menu at the caret, so the pick lands where the
+ // user was typing.
+ const reference = () => {
+ setOpen(null)
+ actions.referenceChat(sessionId, inputActions?.captureInsertion?.())
+ }
+ const canReference = typeof inputActions?.captureInsertion === 'function' && actions.canReferenceChat()
return h(Fragment, null,
h('button', {
ref: button, type: 'button', className: 'bt-plus', 'aria-label': t('Add'), title: t('Add'),
@@ -131,5 +152,6 @@ export function ComposerPlus({ sessionId, useRoster, actions }) {
style: { left: shown.left, bottom: shown.bottom }, 'data-leaving': leaving || undefined,
},
h('button', { type: 'button', role: 'menuitem', onClick: attach }, h(PaperclipIcon), h('span', { className: 'bt-menu-label' }, t('Add files'))),
+ canReference ? h('button', { type: 'button', role: 'menuitem', onMouseDown: keepComposerFocus, onClick: reference }, h(ChatsIcon), h('span', { className: 'bt-menu-label' }, t('Reference a chat'))) : null,
h('button', { type: 'button', role: 'menuitem', onClick: schedule }, h(ClockIcon), h('span', { className: 'bt-menu-label' }, t('Scheduled task')))), document.body) : null)
}
diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.js
index a12a9390..0fc788c5 100644
--- a/ds-bot/src/client/i18n.js
+++ b/ds-bot/src/client/i18n.js
@@ -706,6 +706,8 @@ const ZH = {
'Its group conversation could not open': '它的群聊会话打不开',
// The composer's +
'Add files': '添加文件',
+ 'Reference a chat': '引用对话',
+ 'Chat with {name}': '与 {name} 的对话',
'Scheduled task': '定时任务',
'Send to': '发给',
'Scheduled task: {text}': '定时任务:{text}',
diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.js
index 6f8543fa..2e629852 100644
--- a/ds-bot/src/client/index.js
+++ b/ds-bot/src/client/index.js
@@ -8,7 +8,8 @@ import { SHELL_CSS, CONVERSATION_CSS, installStyles, installCompiledStyles } fro
import { lookOf } from './mark.js'
import { TeamSidebar, ConnectPlugins, YouAvatar, AccountLauncher, FooterAccount, BrandMark, BrandName, BotReturn, SIDEBAR_CSS, RETURN_CSS, holdShellShortcuts } from './sidebar.js'
import { HeaderPill } from './header.js'
-import { ComposerPlus, ComposerVoice } from './composer.js'
+import { ComposerPlus, ComposerVoice, menuIcons } from './composer.js'
+import { CHATS_SOURCE, atSources } from './at-menu.js'
import { VOICE_BUNDLE } from './speech.js'
import { sameVersion } from './dsh-offer.js'
import { AnsweredCell, QuestionCard, QuestionDock } from './questions.js'
@@ -694,6 +695,35 @@ export function apply(ctx) {
const shadow = (name, options, component) => ctx.slots.inject(name, () => ctx.slots.register({ name, ...options }, component))
+ // The "@" menu's Bot group and the chats "+" references. The composer's controller
+ // for a Session is the shell's own, so the chats open at its caret.
+ let atMenu = null
+ const installAtMenu = () => {
+ const fiber = ctx.inject(['inputTriggers'], (scope) => {
+ scope.effect(() => {
+ const triggers = scope.inputTriggers
+ const controllerOf = (sessionId) => {
+ const binding = ctx.sessions.binding(sessionId)
+ return binding === undefined ? undefined : triggers.sessionOf(binding.ctx)
+ }
+ const launched = sessionId => controllerOf(sessionId)?.launcher.getSnapshot() === CHATS_SOURCE
+ const offs = atSources({ roster, sessions: ctx.sessions, launched, iconFor: menuIcons(roster) }).map(source => triggers.registerSource(source))
+ atMenu = { controllerOf }
+ return () => {
+ atMenu = null
+ for (const off of offs) off()
+ }
+ }, 'ds-bot: @ menu')
+ })
+ return () => fiber.dispose()
+ }
+ actions.canReferenceChat = () => atMenu !== null
+ actions.referenceChat = (sessionId, span) => {
+ const controller = atMenu?.controllerOf(sessionId)
+ if (controller === undefined || span === undefined) return
+ controller.toggleSource(CHATS_SOURCE, { trigger: '@', query: '', quoted: false, position: 'inline', span })
+ }
+
// The shell group paints the team surface around the session; the conversation
// group re-skins the session itself. Every disposer comes from slots.inject, so a
// surface change withdraws the whole group and the outlets re-render.
@@ -727,6 +757,7 @@ export function apply(ctx) {
installCompiledStyles(CONVERSATION_CSS, 'conversation'),
installBubbleTokens(),
installMentions(),
+ installAtMenu(),
// Bot conversations are always flat, so the work-details mode is not a choice:
// the mode is held at `verbose` while this group is mounted.
holdFlatTranscript(ctx.configForms.get('ui-chat')),
diff --git a/ds-bot/src/host/constants.js b/ds-bot/src/host/constants.js
index 7ac2150f..bf0e0eb2 100644
--- a/ds-bot/src/host/constants.js
+++ b/ds-bot/src/host/constants.js
@@ -26,6 +26,9 @@ export const ROOM_REPLY_TIMEOUT_MS = 240_000
export const SOURCE_KIND = 'bot'
// An answer from a question card, in the shape DSH's own late question replies use.
export const REPLY_KIND = 'user-question-reply'
+// DSH's snapshot of a referenced conversation, logged right after the user's message
+// that cites it.
+export const REFERENCE_KIND = 'session-reference'
// `everyone`: every member answers a plain message in turn, admin first. `admin`: a
// plain message goes to the admin, who calls others with @mentions. New groups start
// in `admin` mode, because every extra speaker re-reads its whole context; a group
diff --git a/ds-bot/src/host/groups.js b/ds-bot/src/host/groups.js
index f8d414c5..c8a4052a 100644
--- a/ds-bot/src/host/groups.js
+++ b/ds-bot/src/host/groups.js
@@ -75,6 +75,18 @@ export const mentionsIn = (text, members) => {
return { all, found }
}
+// DSH writes a referenced conversation into the message as "@label"; that is not a
+// call, even when the label starts with a member's name.
+export const withoutReferences = (text, references = []) => references
+ .flatMap(reference => reference.labels)
+ .sort((a, b) => b.length - a.length)
+ .reduce((rest, label) => rest.split(`@${label}`).join(''), text)
+
+// What the user referenced in this round, for a member that has not been shown it yet.
+export const referenceNote = references => (references?.length
+ ? `Conversations the user referenced in this round:\n\n${references.map(reference => reference.text).join('\n\n')}`
+ : '')
+
const ROOM_REPLY = 'Reply with your message for the group: one or two short messages, no name prefix. Reply [PASS] to stay silent when you have nothing new to add or the message is for someone else.'
const slotLabel = (slot) => {
@@ -147,6 +159,7 @@ export function install(rt) {
current.length
? `This round so far${spokeThisRound ? ', since your last message' : ', starting with the new message'} (oldest first):\n${transcript(current)}`
: 'Nothing new in this round since your last message.',
+ round.shown?.includes(member.id) ? '' : referenceNote(round.references),
`Speaking order for this round: ${round.slots.map(slotLabel).join(' → ')}.`,
`You are number ${index + 1} of ${round.slots.length}. ${before === 0 ? 'Nobody spoke before you' : `${before} went before you`}${after === 0 ? ', and you are the last.' : `; ${after} after you will see your message.`}`,
ROOM_REPLY,
@@ -208,6 +221,7 @@ export function install(rt) {
continue
}
const prompt = roomPrompt(room, member, round)
+ round.shown?.push(member.id)
const text = session.brief === undefined ? prompt : `${session.brief}\n\n${prompt}`
const reply = await roomTurn(room, member, session.id, text, slot.note ?? 'your turn', signal)
round.speaking = null
@@ -274,11 +288,13 @@ export function install(rt) {
if (posts.some(post => !post.botId && !post.kickoff)) room.botRounds = 0
await rt.save()
const opener = posts.at(-1)
+ const references = posts.flatMap(post => post.references ?? [])
const round = {
roomId: room.id,
members: room.members,
startSeq,
...(opener.kickoff ? { kickoff: true } : {}),
+ ...(references.length > 0 ? { references, shown: [] } : {}),
slots: openingSpeakers(room, opener).map(member => ({ id: member.id, name: member.name, status: 'waiting', ...(opener.kickoff ? { note: 'the group was just created' } : {}) })),
speaking: null,
turns: 0,
@@ -382,7 +398,7 @@ export function install(rt) {
const members = room.members.map(rt.botOf).filter(bot => bot && bot.id !== opener.botId)
const admin = members.find(bot => rt.isAdminOf(room, bot.id))
if (opener.kickoff) return admin ? [admin] : []
- const { all, found } = mentionsIn(opener.text, members)
+ const { all, found } = mentionsIn(withoutReferences(opener.text, opener.references), members)
if (found.length > 0 && !all) return found
if (!all && room.mode === 'admin' && admin) return [admin]
return admin ? [admin, ...members.filter(bot => bot !== admin)] : members
diff --git a/ds-bot/src/host/turns.js b/ds-bot/src/host/turns.js
index ad2ed353..0ddb5e75 100644
--- a/ds-bot/src/host/turns.js
+++ b/ds-bot/src/host/turns.js
@@ -2,7 +2,7 @@
// triggered, the waiters and inboxes of group rounds, and routing a finished turn's reply.
//
// Turn tracking: which turns were triggered by another Bot, and what they said.
-import { REPLY_KIND, SOURCE_KIND } from './constants.js'
+import { REFERENCE_KIND, REPLY_KIND, SOURCE_KIND } from './constants.js'
import { textOf } from './text.js'
import { reminderText } from './schedules.js'
@@ -21,6 +21,16 @@ export function turnFailure(error) {
export const failureLine = failure => `${failure.code}${failure.status ? ` ${failure.status}` : ''}${failure.message ? `: ${failure.message.slice(0, 200)}` : ''}`
+// A group's own Session never reaches a model, so the snapshot DSH prepared there
+// rides with the user's queued message to the members who answer it.
+export function attachReference(queued, source, text) {
+ const post = queued?.findLast(item => item.botId === undefined && item.kickoff !== true)
+ if (post === undefined || text === '') return
+ const labels = (Array.isArray(source?.references) ? source.references : [])
+ .map(reference => reference?.label).filter(label => typeof label === 'string' && label !== '')
+ post.references = [...(post.references ?? []), { labels, text }]
+}
+
export function install(rt) {
const { ctx, state } = rt
@@ -30,7 +40,7 @@ export function install(rt) {
const roomWaiters = new Map()
/** @type {Map<string, {roomId:string, replies:any[], members:string[], speaking:string|null}>} */
const roomProgress = new Map()
- /** @type {Map<string, {text:string, botId?:string, name?:string, reportBack?:boolean, hop?:number, kickoff?:boolean}[]>} messages a room's next relay posts */
+ /** @type {Map<string, {text:string, botId?:string, name?:string, reportBack?:boolean, hop?:number, kickoff?:boolean, references?:{labels:string[], text:string}[]}[]>} messages a room's next relay posts */
const roomInbox = new Map()
const queueRoomMessage = (roomId, item) => roomInbox.set(roomId, [...(roomInbox.get(roomId) ?? []), item])
@@ -180,6 +190,8 @@ export function install(rt) {
} else if (source?.kind === 'schedule' && rt.roomOf(id)) {
// A group's scheduled task reaches the group as the user's message.
queueRoomMessage(id, { text: reminderText(textOf(event.data.content)) })
+ } else if (source?.kind === REFERENCE_KIND && rt.roomOf(id)) {
+ attachReference(roomInbox.get(id), source, textOf(event.data.content))
} else if (source?.kind === 'user' || source?.kind === REPLY_KIND) {
if (rt.roomOf(id) && source.kind === 'user') {
const images = (Array.isArray(event.data.content) ? event.data.content : [])
diff --git a/ds-bot/test/at-menu.test.js b/ds-bot/test/at-menu.test.js
new file mode 100644
index 00000000..adc54169
--- /dev/null
+++ b/ds-bot/test/at-menu.test.js
@@ -0,0 +1,78 @@
+import assert from 'node:assert/strict'
+import { test } from 'node:test'
+import { formatSessionReferenceMention, parseSessionReferenceText } from '@deepseek-ai/dsh-session-reference'
+import { BOTS_SOURCE, CHATS_SOURCE, atSources, chatRows, mentionRows, sessionMention } from '../src/client/at-menu.js'
+import { indexRoster } from '../src/client/sources.js'
+
+const roster = indexRoster({
+ bots: [
+ { id: 'chief', name: 'Chief', role: 'Lead', sessionId: 'chief-2', parts: ['chief'] },
+ { id: 'king', name: 'King', sessionId: 'king' },
+ { id: 'writer', name: 'Writer', sessionId: 'writer' },
+ ],
+ rooms: [{ id: 'room', name: 'Launch', members: ['chief', 'king'], parts: ['king-in-room'] }],
+})
+const names = rows => rows.map(row => row.bot?.name ?? 'everyone')
+
+test('a session mention is the one DSH writes and reads back', () => {
+ for (const [id, label] of [['s-1', 'Chat with King'], ['会话/ä"x', 'a ] b \\ c'], ['', '']]) {
+ const mention = sessionMention(id, label)
+ assert.equal(mention, formatSessionReferenceMention({ sessionId: id, label }))
+ assert.deepEqual(parseSessionReferenceText(`see ${mention}`), { text: `see @${label}`, references: [{ sessionId: id, label }] })
+ }
+})
+
+test('"@" offers a group\'s members and everyone, or every other Bot in a Bot\'s chat', () => {
+ assert.deepEqual(names(mentionRows(roster, 'room')), ['Chief', 'King', 'everyone'])
+ assert.deepEqual(names(mentionRows(roster, 'chief-2')), ['King', 'Writer'])
+ assert.deepEqual(names(mentionRows(roster, 'chief', 'wri')), ['Writer'])
+ assert.deepEqual(names(mentionRows(roster, 'room', 'ev')), ['everyone'])
+ assert.deepEqual(mentionRows(roster, 'room', 'k').map(row => row.text), ['@King '])
+ assert.equal(mentionRows(roster, 'plain'), null)
+ assert.equal(mentionRows(indexRoster({ bots: [], rooms: [] }), 'room'), null)
+})
+
+test('the chats are the other Bots\' current parts, then the latest Sessions outside the team', () => {
+ const list = {
+ ids: ['chief', 'chief-2', 'king', 'writer', 'room', 'king-in-room', 'old', 'new', 'child', 'blank'],
+ byId: {
+ king: { id: 'king', updatedAt: 5 },
+ old: { id: 'old', displayTitle: 'Old work', updatedAt: 1 },
+ new: { id: 'new', displayTitle: 'New work', updatedAt: 9 },
+ child: { id: 'child', displayTitle: 'Child', origin: 'subagent', updatedAt: 10 },
+ blank: { id: 'blank', displayTitle: 'Blank', blank: true, updatedAt: 11 },
+ },
+ }
+ assert.deepEqual(chatRows(roster, list, 'chief-2').map(row => [row.sessionId, row.label]), [
+ ['king', 'Chat with King'], ['writer', 'Chat with Writer'], ['new', 'New work'], ['old', 'Old work'],
+ ])
+ assert.deepEqual(chatRows(roster, list, 'room').map(row => row.sessionId), ['chief-2', 'king', 'writer', 'new', 'old'])
+ assert.deepEqual(chatRows(roster, list, 'new'), [])
+})
+
+test('the chats join only the menu that "+" opened, and a pick inserts a session reference', async () => {
+ let open = false
+ const [bots, chats] = atSources({
+ roster: { getSnapshot: () => roster },
+ sessions: { list: { getSnapshot: () => ({ ids: [], byId: {} }) } },
+ launched: () => open,
+ iconFor: () => 'session',
+ })
+ assert.deepEqual([bots.name, chats.name], [BOTS_SOURCE, CHATS_SOURCE])
+ assert.ok(bots.order < chats.order && chats.order < 0)
+ const session = { sessionId: 'chief-2' }
+ assert.deepEqual(await chats.candidates(session, { query: '' }), [])
+ open = true
+ const rows = await chats.candidates(session, { query: '' })
+ assert.deepEqual(rows.map(row => row.name), ['King', 'Writer'])
+ const picked = chats.onPick({ candidate: rows[0] })
+ assert.deepEqual(picked.insert, {
+ source: CHATS_SOURCE, ref: sessionMention('king', 'Chat with King'), label: 'Chat with King', appearance: 'session', clipboardText: sessionMention('king', 'Chat with King'),
+ })
+ assert.equal(await chats.codec.serialize(picked.insert.ref), picked.insert.ref)
+
+ const mentions = await bots.candidates({ sessionId: 'room' }, { query: '' })
+ assert.deepEqual(mentions.map(row => [row.name, row.description]), [['Chief', 'Lead'], ['King', undefined], ['Everyone', '2 members']])
+ assert.deepEqual(bots.onPick({ candidate: mentions[1] }), { text: '@King ' })
+ assert.deepEqual(await bots.candidates({ sessionId: 'plain' }, { query: '' }), [])
+})
diff --git a/ds-bot/test/groups.test.js b/ds-bot/test/groups.test.js
index 78d8bacf..31001831 100644
--- a/ds-bot/test/groups.test.js
+++ b/ds-bot/test/groups.test.js
@@ -1,6 +1,7 @@
import assert from 'node:assert/strict'
import { test } from 'node:test'
-import { isPass, mentionsIn, stripOwnName } from '../src/host/groups.js'
+import { isPass, mentionsIn, referenceNote, stripOwnName, withoutReferences } from '../src/host/groups.js'
+import { attachReference } from '../src/host/turns.js'
const members = [{ name: 'M' }, { name: 'Mx' }, { name: 'K' }, { name: 'Writer' }]
const names = ({ all, found }) => ({ all, found: found.map(member => member.name) })
@@ -27,3 +28,22 @@ test('stripOwnName drops an echoed "Name:" prefix', () => {
assert.equal(stripOwnName('A.b', 'Axb: x'), 'Axb: x')
assert.equal(stripOwnName('Writer', 'Coder: hi'), 'Coder: hi')
})
+
+test('a referenced conversation rides with the user\'s queued message, not a Bot\'s post', () => {
+ const queued = [{ text: 'first' }, { text: 'look @Chat with K', images: [] }, { text: 'post', botId: 'k' }]
+ attachReference(queued, { kind: 'session-reference', references: [{ label: 'Chat with K' }, { label: '' }] }, '## Referenced sessions\n…')
+ attachReference(queued, { kind: 'session-reference', references: [{ label: 'K notes' }] }, '## Referenced sessions\n2')
+ attachReference(queued, { kind: 'session-reference' }, '')
+ assert.equal(queued[0].references, undefined)
+ assert.deepEqual(queued[1].references, [{ labels: ['Chat with K'], text: '## Referenced sessions\n…' }, { labels: ['K notes'], text: '## Referenced sessions\n2' }])
+ assert.equal(queued[2].references, undefined)
+ attachReference(undefined, {}, 'x')
+})
+
+test('a reference label is not a call, even when it starts with a member\'s name', () => {
+ const references = [{ labels: ['K notes', 'K'] }]
+ assert.deepEqual(names(mentionsIn(withoutReferences('see @K notes, then @Writer', references), members)), { all: false, found: ['Writer'] })
+ assert.deepEqual(names(mentionsIn(withoutReferences('@K notes', undefined), members)), { all: false, found: ['K'] })
+ assert.equal(referenceNote([]), '')
+ assert.equal(referenceNote([{ text: 'A' }, { text: 'B' }]), 'Conversations the user referenced in this round:\n\nA\n\nB')
+})