A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Merge main into devin/1791792833-mid-round-group-message
lulu feizhu6d3e0fc9dc6a
diff --cc CHANGELOG.mdindex 132776d2,2cec03f2..65baeb35--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -4,14 -4,32 +4,36 @@@ All notable changes to DS Bot are liste## [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+ - Bots give a brief progress message when starting a multi-step task in their own chat with the user, and at meaningful milestones on long tasks.- Every Bot can change its own name, role, color, model and instructions; only a Main Bot changes other Bots.+ - Updating a copy installed from GitHub uses the repository's current address.+ - The Usage page groups its statistics, chart, rankings and activity into one panel.+ - Hover over an Activity day to see its token count.++ ### Fixed++ - When DS Bot cannot save the Bot team, the change now fails with an error instead of being lost silently.+ - A Bot team file that cannot be read is no longer replaced by an empty team; a damaged file is kept as a backup.+ - Warnings in the host log hide keys and tokens.+ - Bots receive the current time on their first model step and refresh it after ten minutes, even when their DSH preset does not supply a clock.+ - 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.+ - Deleting a Bot or group chat also removes its scheduled tasks, including ones left on the Bot's earlier chat parts. Before, armed tasks stayed active and kept running the deleted Session; the archive that would have stopped them was refused and the failure was silent.+ - A long conversation's fresh part keeps the Bot's model and thinking level. Before, the new part fell back to the default model.+ - A provider adapter that cannot measure tokens no longer fails every turn. The context size is estimated instead, with one warning in the log.+ - The memory panel's summary works on models that think by default. The call asks for the model's lowest thinking level, and when the answer is cut off at the output limit it is written once more with a larger budget instead of failing or being saved half-written.+### Fixed++- A message sent to a group chat while a round is running shows at once and joins that round instead of waiting for it to end.+## [0.1.2] - 2026-10-11### Addeddiff --cc ds-bot/src/host/channel.jsindex 110370fb,60f59690..1aca05fe--- a/ds-bot/src/host/channel.js+++ b/ds-bot/src/host/channel.js@@@ -262,30 -254,12 +262,30 @@@ export function install(rt)// A Bot id or an earlier part of its own chat means the current part.const past = rt.pastOwners.get(body.sessionId)const sessionId = rt.botOf(body.sessionId) ? rt.chatOf(body.sessionId) : past && past.roomId === undefined ? rt.chatOf(past.botId) : body.sessionId- await ctx.sessionController.prompt({- requestId: randomUUID(),- sessionId,- mode: 'queue',- content: [{ type: 'text', text }],- }, AbortSignal.timeout(30_000))+ // While a group is mid-round its queued copy waits out the whole round;+ // record it for the running round too so the next speaker sees it now.+ const early = rt.roomOf(sessionId) !== undefined && rt.roomBusy(sessionId)+ ? rt.queueRoomMessage(sessionId, { text, early: true })+ : undefined+ try {+ await ctx.sessionController.prompt({+ requestId: randomUUID(),+ sessionId,+ mode: 'queue',+ content: [{ type: 'text', text }],+ }, AbortSignal.timeout(30_000))+ } catch (error) {+ // The round may have drained the record while prompt() was in flight;+ // then the message reached the room, so this send still succeeded.+ if (early !== undefined && early.posted === true) return ok(true)+ if (early !== undefined) {+ const inbox = rt.roomInbox.get(sessionId) ?? []+ const at = inbox.indexOf(early)+ if (at !== -1) inbox.splice(at, 1)- void rt.save()++ void rt.save().catch(() => {})+ }+ throw error+ }return ok(true)}case 'update-check': {diff --cc ds-bot/src/host/groups.jsindex 5a1785d7,6982950d..673bd48e--- a/ds-bot/src/host/groups.js+++ b/ds-bot/src/host/groups.js@@@ -180,48 -202,6 +202,52 @@@ export function install(rt)return stripOwnName(member.name, String(reply ?? '').trim())}+ // A called member moves up if it is still waiting, or gets one more turn if it+ // already spoke; either way it goes right after this slot. `cap` is the caller's+ // per-member turn bound for the round.+ function callMembers(room, round, turns, index, callees, callerName, cap) {+ let next = index + 1+ for (const peer of callees) {+ if ((turns.get(peer.id) ?? 0) >= cap) continue+ const waiting = round.slots.findIndex((other, at) => at > index && other.id === peer.id && other.status === 'waiting')+ const called = waiting === -1 ? { id: peer.id, name: peer.name, status: 'waiting' } : round.slots.splice(waiting, 1)[0]+ called.note = `${callerName} mentioned you`+ round.slots.splice(next, 0, called)+ next += 1+ }+ }++ const freshInbox = room => (rt.roomInbox.get(room.id) ?? [])+ .filter(item => item.early === true && item.posted !== true && item.consumed !== true)++ // Messages the user sent while this round is running post into the log between+ // speakers, so the members still to speak see them; a member they @ is called+ // right after this slot, as if the admin had called it.+ function drainRoomInbox(room, round, turns, index) {+ const fresh = freshInbox(room)+ if (fresh.length === 0) return+ const others = room.members.map(rt.botOf).filter(Boolean)+ for (const item of fresh) {+ item.posted = true+ appendRoom(room, { who: 'User', text: item.text })+ round.replies.push({ kind: 'user', text: item.text, time: Date.now() })- const { all, found } = mentionsIn(item.text, others)++ const { all, found } = mentionsIn(withoutReferences(item.text, item.references), others)+ const callees = all ? [...found, ...others.filter(other => !found.includes(other))] : found+ // The member next to speak is still waiting on this slot, not past it: a call+ // for it is a note on its own slot, not an extra turn.+ const next = round.slots[index]+ if (next?.status === 'waiting' && callees.some(peer => peer.id === next.id)) next.note = 'the user mentioned you'+ callMembers(room, round, turns, index, callees.filter(peer => peer.id !== next?.id), 'the user', ROOM_ADMIN_TURNS_EACH)++ if (item.references !== undefined) {++ round.references = [...(round.references ?? []), ...item.references]++ round.shown ??= []++ }+ }+ // The user spoke in this room, so Bots may start their own rounds again.+ room.botRounds = 0- void rt.save()++ void rt.save().catch(() => {})+ }+async function runRound(room, round, signal) {const limit = round.slots.length + ROOM_EXTRA_TURNS + (room.admin ? ROOM_ADMIN_EXTRA_TURNS : 0)const turns = new Map()@@@ -273,8 -250,10 +300,8 @@@slot.status = 'posted'appendRoom(room, { who: member.name, botId: member.id, text: reply })round.replies.push({ botId: member.id, name: member.name, color: member.color, text: reply, time: Date.now() })- void rt.save()+ void rt.save().catch(() => {})- // A called member moves up if it is still waiting, or gets one more turn if it- // already spoke; either way it goes right after this speaker. Only the admin's- // "@all" calls everyone, so a member cannot set off a storm.+ // Only the admin's "@all" calls everyone, so a member cannot set off a storm.const leads = rt.isAdminOf(room, member.id)const others = room.members.filter(id => id !== member.id).map(rt.botOf).filter(Boolean)const { all, found } = mentionsIn(reply, others)diff --cc ds-bot/src/host/turns.jsindex ebc19dde,4f8b639a..d2d0e59a--- a/ds-bot/src/host/turns.js+++ b/ds-bot/src/host/turns.js@@@ -30,12 -40,9 +40,12 @@@ 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])+ const queueRoomMessage = (roomId, item) => {+ roomInbox.set(roomId, [...(roomInbox.get(roomId) ?? []), item])+ return item+ }const liveOf = id => {let entry = live.get(id)@@@ -183,23 -196,13 +199,25 @@@} 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 text = textOf(event.data.content)const images = (Array.isArray(event.data.content) ? event.data.content : []).filter(block => block?.type === 'image' && !block.offloaded).map(block => block.attachment)- queueRoomMessage(id, { text: textOf(event.data.content), ...(images.length > 0 ? { images } : {}) })+ // A message recorded for a running round (`early`) reaches the Session+ // again once its queued prompt lands: keep the round's own posting and+ // treat this copy as consumed so it neither posts nor opens a round.+ const earlier = images.length === 0+ ? (rt.roomInbox.get(id) ?? []).find(item => item.early === true && item.claimed !== true && item.text === text)+ : undefined+ if (earlier !== undefined) {+ earlier.claimed = true+ queueRoomMessage(id, { text, consumed: true })+ } else {+ queueRoomMessage(id, { text, ...(images.length > 0 ? { images } : {}) })+ }}const own = rt.chatOwners.get(id)if (own !== undefined) rt.dropKickoff(own)