A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Explain a sole admin pass
klarkxyb8daa8699862
diff --git a/ds-bot/client.js b/ds-bot/client.jsindex 433f1439..6822b185 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -621,6 +621,7 @@ var ZH = {"{name} looked up its own chat for “{text}”": "{name} 在自己的对话里查找「{text}」","{name} is typing…": "{name} 正在输入…","{name} didn't answer in time": "{name} 没有及时回应",+ "{name} did not answer or call anyone; call a member with @Name": "{name} 没有回答,也没有叫谁;用 @名字 叫一个成员来回答","Paused after {count} Bot relays. Waiting: {names}": "Bot 之间已接力 {count} 次,先停下了。还在等:{names}","Continue": "继续","{name} paused for your approval": "{name} 停下来等你批准",@@ -7881,6 +7882,13 @@ function GroupReplies({ sessionId, callId, done, content, roster, actions, useUiif (reply.kind === "missed") {return (0, import_react12.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("{name} didn't answer in time", { name: bot.name }));}+ if (reply.kind === "admin-passed") {+ return (0, import_react12.createElement)(+ "div",+ { key: `${reply.botId}-${index}`, className: "bt-event" },+ t("{name} did not answer or call anyone; call a member with @Name", { name: bot.name })+ );+ }if (reply.kind === "paused") {return (0, import_react12.createElement)("div",diff --git a/ds-bot/src/client/cells.js b/ds-bot/src/client/cells.jsindex 81377b96..892c46c7 100644--- a/ds-bot/src/client/cells.js+++ b/ds-bot/src/client/cells.js@@ -858,6 +858,10 @@ function GroupReplies({ sessionId, callId, done, content, roster, actions, useUiif (reply.kind === 'missed') {return h('div', { key: `${reply.botId}-${index}`, className: 'bt-event' }, t("{name} didn't answer in time", { name: bot.name }))}+ if (reply.kind === 'admin-passed') {+ return h('div', { key: `${reply.botId}-${index}`, className: 'bt-event' },+ t('{name} did not answer or call anyone; call a member with @Name', { name: bot.name }))+ }if (reply.kind === 'paused') {return h('div', { key: `paused-${index}`, className: 'bt-event' },h('span', null, t('Paused after {count} Bot relays. Waiting: {names}', { count: reply.count, names: (reply.names ?? []).join(t(' and ')) })),diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.jsindex e6fc9fb5..6329026d 100644--- a/ds-bot/src/client/i18n.js+++ b/ds-bot/src/client/i18n.js@@ -566,6 +566,7 @@ const ZH = {'{name} looked up its own chat for “{text}”': '{name} 在自己的对话里查找「{text}」','{name} is typing…': '{name} 正在输入…',"{name} didn't answer in time": '{name} 没有及时回应',+ '{name} did not answer or call anyone; call a member with @Name': '{name} 没有回答,也没有叫谁;用 @名字 叫一个成员来回答','Paused after {count} Bot relays. Waiting: {names}': 'Bot 之间已接力 {count} 次,先停下了。还在等:{names}','Continue': '继续','{name} paused for your approval': '{name} 停下来等你批准',diff --git a/ds-bot/src/host/groups.js b/ds-bot/src/host/groups.jsindex 223913d8..01e5dc14 100644--- a/ds-bot/src/host/groups.js+++ b/ds-bot/src/host/groups.js@@ -61,6 +61,7 @@ const unseenLines = (room, memberId) => {const noticeText = (line) => {if (line.reason === 'missed') return `${(line.names ?? []).join(' and ')} did not answer within ${line.minutes} minutes, so this round moved on without it. If it is still working, it posts its result later as a late reply; if it is urgent, the user can write here or the admin can follow up.`if (line.reason === 'paused') return `Paused: Bots have called each other ${line.limit} times since the user last wrote here. The calls to @${(line.names ?? []).join(' and @')} wait until the user continues or writes here; do not call them again.`+ if (line.reason === 'admin-passed') return `${(line.names ?? []).join(' and ') || 'The admin'} did not answer or call anyone; call a member with @Name.`return line.text ?? ''}// `text` is what to show of a message line, by default what the log keeps of it.@@ -545,6 +546,17 @@ export function install(rt) {const callees = leads && all ? [...found, ...others.filter(other => !found.includes(other))] : foundcallMembers(round, index, callees, `${member.name} mentioned you`, member.id, 'bot')}+ // The admin was alone with the user's message and passed: the round ends with+ // nothing said. The group says so once, so the user knows to call a member.+ const alone = round.soleAdmin !== undefined && round.slots.find(slot => slot.id === round.soleAdmin.id)?.status === 'passed'+ // An answer that came, or is still coming, means the round is not left silent.+ const answered = round.slots.some(slot => ['posted', 'working', 'waiting-approval'].includes(slot.status))+ if (alone && !answered) {+ appendRoom(room, { who: 'DS Bot', kind: 'notice', reason: 'admin-passed', names: [round.soleAdmin.name] })+ // The round the user watched shows the same notice as one line of its replies.+ round.replies.push({ kind: 'admin-passed', botId: round.soleAdmin.id, name: round.soleAdmin.name, color: round.soleAdmin.color, time: Date.now() })+ await rt.save()+ }// A round that ended with parked calls says so once, to the group and to the// user: the log's "@Name" lines are real calls that wait, not drops in silence.if (round.parked !== undefined) {@@ -600,19 +612,26 @@ export function install(rt) {const references = posts.flatMap(post => post.references ?? [])// A member a Bot's post calls by name works for that Bot.const named = opener.botId === undefined ? [] : mentionsIn(opener.text ?? '', room.members.map(rt.botOf).filter(Boolean)).found+ const speakers = openingSpeakers(room, opener)+ // The admin alone with the user's message: when it passes, the round ends with+ // nothing said, and the group says so once.+ const admin = room.members.map(rt.botOf).filter(Boolean).find(bot => rt.isAdminOf(room, bot.id))+ const soleAdmin = opener.botId === undefined && !opener.kickoff && room.mode === 'admin' && admin !== undefined+ && speakers.length === 1 && speakers[0].id === admin.idconst round = {roomId: room.id,members: room.members,startSeq,...(opener.kickoff ? { kickoff: true } : {}),...(references.length > 0 ? { references, shown: [] } : {}),- slots: openingSpeakers(room, opener).map(member => ({+ slots: speakers.map(member => ({id: member.id, name: member.name, status: 'waiting',origin: opener.botId === undefined ? 'user' : 'bot',...(opener.kickoff ? { note: 'the group was just created' } : {}),...(named.includes(member) ? { by: opener.botId } : {}),...(opener.done ? { note: `${opener.name ?? 'a member'} finished the work you asked for` } : {}),})),+ ...(soleAdmin ? { soleAdmin: { id: admin.id, name: admin.name, color: admin.color } } : {}),speaking: null,replies: [],passed: [],diff --git a/ds-bot/test/rounds.test.js b/ds-bot/test/rounds.test.jsindex 0b38aa40..7726311d 100644--- a/ds-bot/test/rounds.test.js+++ b/ds-bot/test/rounds.test.js@@ -873,6 +873,97 @@ test('a member the reply timeout cut short is told to the group, not left as silassert.match(lineText(notices[0]), /late reply/)})+// #512: in admin mode the user's message goes to the admin alone. When the admin+// passes, the round ends with nothing said, so the group says what to do about it.+test('in admin mode a sole admin that passes leaves the group a notice', async (t) => {+ const { call, emit, userMessage, relay, answer, stop, sent, rt } = start()+ t.after(stop)+ const room = await team(call, sent)+ const chief = (await call('state', {})).value.mainBotId+ await call('update-room', { id: room.id, mode: 'admin' })++ // The user names a member without "@": nobody is called, the admin alone answers.+ await emit(room.id, userMessage('Writer, what do you think?'))+ const running = relay(room.id, 'relay')+ const first = await turnFor(sent)+ assert.ok(first, 'the admin gets the turn alone')+ await answer(first.sessionId, first.message.source.exchangeId, '[PASS]', 1)+ const result = JSON.parse(await running)+ assert.deepEqual(result.passed, ['Chief'])+ assert.equal(result.replies.filter(reply => reply.kind === undefined).length, 0, 'the round ends without an answer')++ // The user sees the notice in the round, not only the log.+ const events = result.replies.filter(reply => reply.kind === 'admin-passed')+ assert.equal(events.length, 1, 'the round shows the notice once')+ assert.deepEqual({ botId: events[0].botId, name: events[0].name },+ { botId: chief, name: 'Chief' })++ const notices = rt.state.rooms[room.id].log.filter(line => line.kind === 'notice')+ assert.equal(notices.length, 1, 'the group is told once')+ assert.deepEqual({ reason: notices[0].reason, names: notices[0].names },+ { reason: 'admin-passed', names: ['Chief'] })+ assert.match(lineText(notices[0]), /did not answer or call anyone/)+ assert.match(lineText(notices[0]), /@Name/)++ // The notice is in the group: the next member to speak reads it.+ await emit(room.id, userMessage('Anyone there?'))+ const next = relay(room.id, 'relay-2')+ const turn = await turnFor(sent, first)+ assert.match(turn.message.content[0].text, /did not answer or call anyone/)+ await answer(turn.sessionId, turn.message.source.exchangeId, 'Here.', 2)+ await next+})++test('in admin mode an admin that answers leaves the group no notice', async (t) => {+ const { call, emit, userMessage, relay, answer, stop, sent, rt } = start()+ t.after(stop)+ const room = await team(call, sent)+ await call('update-room', { id: room.id, mode: 'admin' })++ await emit(room.id, userMessage('Writer, what do you think?'))+ const running = relay(room.id, 'relay')+ const first = await turnFor(sent)+ await answer(first.sessionId, first.message.source.exchangeId, 'On it.', 1)+ const result = JSON.parse(await running)+ assert.deepEqual(result.replies.map(reply => reply.name ?? 'User'), ['Chief'])+ assert.equal(result.replies.filter(reply => reply.kind === 'admin-passed').length, 0)+ assert.deepEqual(rt.state.rooms[room.id].log.filter(line => line.kind === 'notice'), [])+})++test('in admin mode a member the user called alone is not the admin, and the group says nothing', async (t) => {+ const { call, emit, userMessage, relay, answer, stop, sent, rt } = start()+ t.after(stop)+ const room = await team(call, sent)+ await call('update-room', { id: room.id, mode: 'admin' })++ await emit(room.id, userMessage('@Writer your take'))+ const running = relay(room.id, 'relay')+ const first = await turnFor(sent)+ assert.ok(first, 'the member the user called answers')+ await answer(first.sessionId, first.message.source.exchangeId, '[PASS]', 1)+ const result = JSON.parse(await running)+ assert.deepEqual(result.passed, ['Writer'])+ assert.deepEqual(result.replies, [], 'the member passed, and the admin was not alone')+ assert.deepEqual(rt.state.rooms[room.id].log.filter(line => line.kind === 'notice'), [])+})++test('a group where everyone answers says nothing when the admin passes', async (t) => {+ const { call, emit, userMessage, relay, answer, stop, sent, rt } = start()+ t.after(stop)+ const room = await team(call, sent)++ await emit(room.id, userMessage('Start'))+ const running = relay(room.id, 'relay')+ const first = await turnFor(sent)+ await answer(first.sessionId, first.message.source.exchangeId, '[PASS]', 1)+ const second = await turnFor(sent, first)+ await answer(second.sessionId, second.message.source.exchangeId, 'Writer here.', 2)+ const result = JSON.parse(await running)+ assert.deepEqual(result.replies.map(reply => reply.name ?? 'User'), ['Writer'])+ assert.equal(result.replies.filter(reply => reply.kind === 'admin-passed').length, 0)+ assert.deepEqual(rt.state.rooms[room.id].log.filter(line => line.kind === 'notice'), [])+})+test('a member still at work is shown with the group messages it has not read yet', async (t) => {const { call, emit, userMessage, relay, answer, stop, sent, rt } = start()t.after(stop)diff --git a/ds-bot/test/tool-cells.test.js b/ds-bot/test/tool-cells.test.jsindex 3af2be17..77bae419 100644--- a/ds-bot/test/tool-cells.test.js+++ b/ds-bot/test/tool-cells.test.js@@ -176,6 +176,15 @@ test('a paused group shows the wait, and Continue releases it while calls are paassert.deepEqual(clicked, ['room'])})+// The admin was alone with the user's message and passed: the round shows the+// notice, so the user sees why nothing was answered.+test('a group whose admin passed alone shows the notice', () => {+ const replies = [{ kind: 'admin-passed', botId: 'chief', name: 'Chief', time: at(0, 14, 5) }]+ const out = show(call('group_relay', 'direct', { content: { replies } }), { sessionId: 'room' })+ const events = findAll(out, node => node.props?.className === 'bt-event').map(text)+ assert.deepEqual(events, ['Chief did not answer or call anyone; call a member with @Name'])+})+// The trigger of a post in a group chat carries the event's time, not the post's.test('a group post drawn from its trigger shows the time it came in', () => {const time = at(0, 16, 42)