A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Merge remote-tracking branch 'origin/dev' into feat/group-chat-engine
Fei24110684593132e6
diff --cc ds-bot/client.jsindex 1213657e,92f40ed2..fd6c1720--- a/ds-bot/client.js+++ b/ds-bot/client.js@@@ -8540,8 -8645,8 +8641,8 @@@ function scanReplies(text, start, repli}}function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi, useWork }) {- const [live, setLive] = (0, import_react16.useState)({ replies: [], speaking: [] });- (0, import_react16.useEffect)(() => {- const [live, setLive] = (0, import_react17.useState)({ replies: [], speaking: null });++ const [live, setLive] = (0, import_react17.useState)({ replies: [], speaking: [] });+ (0, import_react17.useEffect)(() => {if (done) return void 0;let stop = false;let timer;@@@ -8570,16 -8675,14 +8671,16 @@@replies = parsed.replies.length ? parsed.replies : live.replies;broken = parsed.broken;}- const pending = done || !live.speaking ? [] : [live.speaking];- const speakerTool = useWork?.((work) => work.bots?.[live.speaking]?.tool) ?? void 0;- const speakerDoing = useWork?.((work) => work.bots?.[live.speaking]?.tool ? workPhrase(work.bots[live.speaking]) : void 0) ?? void 0;+ const pending = done ? [] : live.speaking;+ const doing = JSON.parse(useWork?.((work) => JSON.stringify(pending.map((id) => {+ const tool = work.bots?.[id]?.tool;+ return tool ? [tool, workPhrase(work.bots[id])] : [];+ }))) ?? "[]");if (replies.length === 0 && pending.length === 0) {- return broken ? (0, import_react16.createElement)("div", { className: "bt-group-replies" }, (0, import_react16.createElement)("div", { className: "bt-event" }, t("The group replies could not be shown"))) : null;+ return broken ? (0, import_react17.createElement)("div", { className: "bt-group-replies" }, (0, import_react17.createElement)("div", { className: "bt-event" }, t("The group replies could not be shown"))) : (0, import_react17.createElement)(CellEmpty);}const room2 = roster.roomsById[sessionId];- return (0, import_react16.createElement)(+ return (0, import_react17.createElement)("div",{ className: "bt-group-replies" },stackReplies(replies).map(({ reply, index, texts: texts2, time, duration }) => {@@@ -8617,10 -8720,11 +8718,10 @@@);}if (reply.kind === "paused") {- return (0, import_react16.createElement)(+ return (0, import_react17.createElement)("div",{ key: `paused-${index}`, className: "bt-event" },- (0, import_react17.createElement)("span", null, t("Paused after {count} Bot relays. Waiting: {names}", { count: reply.count, names: (reply.names ?? []).join(t(" and ")) })),- room2?.paused?.length > 0 ? (0, import_react17.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.continueRoom(sessionId) }, t("Continue")) : null+ t("Paused after {count} Bot relays. Waiting: {names}", { count: reply.count, names: (reply.names ?? []).join(t(" and ")) }));}if (reply.kind === "resumed") {@@@ -8642,22 -8746,21 +8743,22 @@@);}if (reply.kind === "stopped") {- return (0, import_react16.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("You stopped {name}'s work", { name: bot.name }));+ return (0, import_react17.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("You stopped {name}'s work", { name: bot.name }));}if (reply.kind === "done") {- return (0, import_react16.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("{name} finished its work", { name: bot.name }));+ return (0, import_react17.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("{name} finished its work", { name: bot.name }));}- return (0, import_react16.createElement)(GroupMessage, { key: `${reply.botId}-${index}`, bot, texts: texts2, room: room2, roster, actions, msgKey: callId ? `${sessionId}:${callId}:${index}` : void 0, useUi, time, duration });+ return (0, import_react17.createElement)(GroupMessage, { key: `${reply.botId}-${index}`, bot, texts: texts2, room: room2, roster, actions, msgKey: callId ? `${sessionId}:${callId}:${index}` : void 0, useUi, time, duration });}),- pending.map((id) => {+ pending.map((id, at) => {const bot = roster.byId[id];if (!bot) return null;+ const [tool, phrase] = doing[at] ?? [];- return (0, import_react16.createElement)(+ return (0, import_react17.createElement)("div",{ key: `pending-${id}`, className: "bt-activity" },- (0, import_react16.createElement)(BotMark, { bot, size: 22, state: tool ? toolState(tool) : "thinking" }),- (0, import_react16.createElement)(Shimmer, null, phrase ? `${bot.name} · ${phrase}…` : t("{name} is typing…", { name: bot.name }))- (0, import_react17.createElement)(BotMark, { bot, size: 22, state: speakerTool ? toolState(speakerTool) : "thinking" }),- (0, import_react17.createElement)(Shimmer, null, speakerDoing ? `${bot.name} · ${speakerDoing}…` : t("{name} is typing…", { name: bot.name }))++ (0, import_react17.createElement)(BotMark, { bot, size: 22, state: tool ? toolState(tool) : "thinking" }),++ (0, import_react17.createElement)(Shimmer, null, phrase ? `${bot.name} · ${phrase}…` : t("{name} is typing…", { name: bot.name })));}));@@@ -14559,21 -14753,22 +14712,21 @@@ function GroupSettingsForm({ room: roomif (mode !== id) void update({ mode: id });}}, t(label)))),- (0, import_react36.createElement)("span", { key: mode, className: "bt-set-hint bt-veil" }, `${t(modeHint)} ${t("@mentions always pick who answers.")}`)+ (0, import_react37.createElement)("span", { key: mode, className: "bt-set-hint bt-veil" }, `${t(modeHint)} ${t("@mentions always pick who answers.")}`)- ),- (0, import_react37.createElement)(RelayLimitRow, { room: room2, update })+ )),- (0, import_react36.createElement)(+ (0, import_react37.createElement)(Card2,{ title: t("Working folder") },- (0, import_react36.createElement)(+ (0, import_react37.createElement)("div",{ className: "bt-set-row bt-bs-row" },- (0, import_react36.createElement)("span", { className: "bt-set-copy" }, (0, import_react36.createElement)("span", { className: "bt-bs-label" }, t("Folder"))),- (0, import_react36.createElement)(FolderMenu, { value: room2.workDir, group: true, actions, run: run2, onPick: (workDir) => update({ workDir }) })+ (0, import_react37.createElement)("span", { className: "bt-set-copy" }, (0, import_react37.createElement)("span", { className: "bt-bs-label" }, t("Folder"))),+ (0, import_react37.createElement)(FolderMenu, { value: room2.workDir, group: true, actions, run: run2, onPick: (workDir) => update({ workDir }) }))),- (0, import_react36.createElement)(GroupPermission, { room: room2, catalog: roster.permissions, update }),- (0, import_react36.createElement)(+ (0, import_react37.createElement)(GroupPermission, { room: room2, catalog: roster.permissions, update }),+ (0, import_react37.createElement)(Card2,{ title: t("Members · {count}", { count: members.length }) },members.map((member) => {diff --cc ds-bot/src/host/groups.jsindex ab8364d8,c6103ec2..c1c83da9--- a/ds-bot/src/host/groups.js+++ b/ds-bot/src/host/groups.js@@@ -797,9 -574,9 +797,9 @@@ export function install(rt)}}- ctx.tools.register(defineTool({+ rt.teamTools.push(defineTool({name: 'group_relay',- description: 'Group chat relay only. Deliver the latest user message to the Bots in this group chat, one at a time, and collect their replies.',+ description: 'Group chat relay only. Deliver the latest user message to the Bots it calls in this group chat, and collect their replies.',parameters: {},output: { schema: { type: 'string' }, render: (_args, value) => [{ type: 'text', text: String(value) }] },async execute(_args, exec) {diff --cc ds-bot/src/host/turns.jsindex 3a6cc69d,eabd7ac5..b3b57be4--- a/ds-bot/src/host/turns.js+++ b/ds-bot/src/host/turns.js@@@ -85,14 -86,19 +86,25 @@@ export const stripWrittenCalls = text =// Under DSH's PTC presentation the model calls only this tool; the program's sub-calls// are the tools it really runs.const PROGRAM_TOOL = 'run_code'+ // DSH's delegation tools, named by the tool instance: a spawn child and a fork.+ const SUBAGENT_TOOLS = new Set(['subagent', 'subagent_fork'])+ // A settled child's closing text, or why it ended without one. A child that did+ // not finish says so: output it left behind can be partial, so the reason it+ // ended is part of its result.+ const subEndText = (data) => {+ const text = textOf(data?.lastAssistantMessage)+ const reason = typeof data?.stopReason === 'string' ? data.stopReason : ''+ if (text === '') return `subagent ended${reason === '' ? '' : ` (${reason})`} without a closing message.`+ return reason === '' || reason === 'completed' ? text : `subagent ended (${reason}) before it finished. What it had written:\n${text}`+ }const RETRY_TEXT = 'Your last reply wrote a tool call as plain text (<tool_call>…), so it did not run and nothing happened. Call the tool through the tool interface now, then reply as you meant to.'+const RETRY_PROMISE_TEXT = 'Your last reply said you would start working, but you ended the turn without calling any tool, so nothing ran. Call the tools you need and complete the task now, or state your final answer if no tool is needed.'++// A reply that only promises to start investigating/checking/running tools now without+// actually calling a tool or handing off with @Name (#469).+const PROMISED_WORK = /(?:^(?:收到|好的|明白|好|行|没问题|了解)[,,、。.!!:\s]*(?:我(?:现在|这就|先|马上|立刻|去|来)?(?:开始|着手|去|来|准备)?(?:排查|检查|调查|查看|看看|搜索|搜一下|分析|处理|执行|运行|跑一下|修改|修复|实现|编写|整理|验证|测试|读一下|翻一下)|(?:现在|马上|立刻)?(?:开始|着手)(?:执行|处理|排查|检查|调查|干活|开工)|开工(?:[。!!,,\s]|$))|^(?:开工(?:[。!!,,\s]|$)|我(?:现在|这就|先|马上|立刻)(?:开始|着手|去)(?:排查|检查|调查|查看|搜索|分析|处理|执行|运行|修改|修复|实现|编写|整理|验证|测试))|\b(?:(?:i\s+will|i'll|let\s+me|going\s+to)\s+(?:start|begin|check|look\s+into|investigate|search|run|inspect|read|fix|implement|work\s+on)\b|(?:starting|beginning)\s+(?:the\s+)?(?:investigation|check|search|work|execution|analysis)\b|^on\s+it[,.\s!]+(?:i'll|i\s+will|let\s+me|starting|checking)\b))/i+export const promisesWork = text => typeof text === 'string' && text.trim().length <= 240 && PROMISED_WORK.test(text.trim())export function install(rt) {const { ctx, state } = rtdiff --cc ds-bot/test/install.test.jsindex 58741014,1a5c82ab..2eb38b4d--- a/ds-bot/test/install.test.js+++ b/ds-bot/test/install.test.js@@@ -39,13 -40,12 +40,14 @@@ test('apply registers listeners and eff'on llm/adapters-updated','on credentials/reference-updated','on settings/document-updated',+ 'on subagent/start',+ 'on subagent/end','on session/event',+ 'on subagent/start',+ 'on subagent/end',+ 'on tools/result','on session/event','on tools/execute',- 'effect ds-bot: agent tool restrict retry',- 'on agent/created','effect ds-bot: identity section','prompt bot-identity 640','on agent/pre-step (prepend)',