Skip to content

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

Say what a Bot at work is doing in the words of its step

Fei24116229bf4637fe
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 2070f0ad..3dec7061 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -472,6 +472,7 @@ var ZH = {
"Moving ahead": "推进中",
"Taking care of it": "处理中",
"Making headway": "有进展了",
+ "Moving to a fresh conversation": "整理记忆,换到新对话",
"Searching online": "上网搜索",
"Reading a page": "阅读网页",
"Running shell commands": "运行命令",
@@ -4324,9 +4325,14 @@ function toolActivity(name, arg, findBot, self) {
return { label: phrase ? t(phrase) : null, state: toolState(name) };
}
}
-function workPhrase(tool) {
+function workPhrase(doing) {
+ const { tool, note, target, switching } = typeof doing === "string" ? { tool: doing } : doing ?? {};
+ if (switching) return t("Moving to a fresh conversation");
+ const own = note?.replace(/[\s.。…]+$/u, "");
+ if (own) return own;
if (!tool) return t("Thinking about it");
- return toolActivity(tool, () => void 0, () => void 0)?.label ?? t("On it");
+ const label = toolActivity(tool, () => void 0, () => void 0)?.label ?? t("On it");
+ return target ? `${label} · ${target}` : label;
}
function useLiveNote(actions, sessionId, id, entry) {
const key = entry ? JSON.stringify(entry) : "";
@@ -4370,6 +4376,7 @@ function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi
}
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;
if (replies.length === 0 && pending.length === 0) return null;
const room2 = roster.roomsById[sessionId];
return (0, import_react6.createElement)(
@@ -4431,7 +4438,7 @@ function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi
"div",
{ key: `pending-${id}`, className: "bt-activity" },
(0, import_react6.createElement)(BotMark, { bot, size: 22, state: speakerTool ? toolState(speakerTool) : "thinking" }),
- (0, import_react6.createElement)(Shimmer, null, speakerTool ? `${bot.name} · ${workPhrase(speakerTool)}…` : t("{name} is typing…", { name: bot.name }))
+ (0, import_react6.createElement)(Shimmer, null, speakerDoing ? `${bot.name} · ${speakerDoing}…` : t("{name} is typing…", { name: bot.name }))
);
})
);
@@ -4748,12 +4755,10 @@ function useMarkedUnread(id, active, marked, actions) {
}
var PinMark = () => (0, import_react8.createElement)("span", { className: "bt-pin", "aria-hidden": true }, (0, import_react8.createElement)(PinMarkIcon));
var useApproval = (useWork, match) => useWork ? useWork((work) => (work.approvals ?? []).some(match)) : false;
-var useGroupWork = (useWork, pick2) => useWork ? useWork((work) => pick2(work.rooms ?? {}).join(",")) : "";
-var workKeys = (text) => text === "" ? [] : text.split(",").map((key) => {
- const [id, tool] = key.split("|");
- return { id, tool: tool || void 0 };
-});
-var workLine = (lead, tool, more) => (0, import_react8.createElement)(Shimmer, null, `${lead} · ${workPhrase(tool)}…${more > 0 ? ` +${more}` : ""}`);
+var useGroupWork = (useWork, pick2) => useWork ? useWork((work) => JSON.stringify(pick2(work.rooms ?? {}))) : "[]";
+var workKeys = (text) => JSON.parse(text);
+var doingOf = ({ tool, note, target, switching }) => ({ tool, note, target, switching });
+var workLine = (lead, doing, more) => (0, import_react8.createElement)(Shimmer, null, `${lead} · ${workPhrase(doing)}…${more > 0 ? ` +${more}` : ""}`);
function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessionRetainInfo, useActivity, useWork, wide, marked }) {
const id = bot.id;
const part = currentPart(bot);
@@ -4767,10 +4772,10 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessio
const approval = useApproval(useWork, (entry) => entry.botId === id);
const alert = roster.questions?.[part] !== void 0 || approval;
const doing = useActivity((map) => map[id]);
- const groups = workKeys(useGroupWork(useWork, (rooms) => Object.entries(rooms).flatMap(([roomId, entries2]) => entries2.filter((entry) => entry.botId === id).map((entry) => `${roomId}|${entry.tool ?? ""}`))));
+ const groups = workKeys(useGroupWork(useWork, (rooms) => Object.entries(rooms).flatMap(([roomId, entries2]) => entries2.filter((entry) => entry.botId === id).map((entry) => ({ id: roomId, ...doingOf(entry) })))));
const away = !running && groups.length > 0;
const state = botState(running || away, doing, alert);
- const awayLine = away ? workLine(roster.roomsById[groups[0].id]?.name ?? t("a group chat"), groups[0].tool, groups.length - 1) : null;
+ const awayLine = away ? workLine(roster.roomsById[groups[0].id]?.name ?? t("a group chat"), groups[0], groups.length - 1) : null;
if (bot.hidden && !active && !main) return null;
const onContextMenu = (event) => {
event.preventDefault();
@@ -4827,9 +4832,9 @@ function RoomRow({ room: room2, roster, actions, useSessions, useSessionStatus,
const unread = useSessionStatus((map) => map.get(id)?.completionUnread === true) || marked && !active;
useMarkedUnread(id, active, marked, actions);
const approval = useApproval(useWork, (entry) => entry.roomId === id);
- const members = workKeys(useGroupWork(useWork, (rooms) => (rooms[id] ?? []).map((entry) => `${entry.botId}|${entry.tool ?? ""}`)));
+ const members = workKeys(useGroupWork(useWork, (rooms) => (rooms[id] ?? []).map((entry) => ({ id: entry.botId, ...doingOf(entry) }))));
const first = roster.byId[members[0]?.id];
- const workingLine = first ? workLine(first.name, members[0].tool, members.length - 1) : null;
+ const workingLine = first ? workLine(first.name, members[0], members.length - 1) : null;
if (room2.hidden && !active) return null;
const pinned = room2.pinned === true;
const label = [room2.name, pinned ? t("Pinned") : "", members.length > 0 ? t("Working") : "", approval ? t("Waiting for your approval") : ""].filter(Boolean).join(", ");
@@ -11070,7 +11075,7 @@ function botGroupWork(botId, work, roster) {
return Object.entries(work.rooms ?? {}).flatMap(([roomId, entries2]) => {
const entry = entries2.find((item) => item.botId === botId);
const room2 = roster.roomsById[roomId];
- return entry && room2 ? [{ room: room2, tool: entry.tool, since: entry.since }] : [];
+ return entry && room2 ? [{ room: room2, doing: entry, since: entry.since }] : [];
});
}
function summaryText(busy) {
@@ -11079,7 +11084,7 @@ function summaryText(busy) {
const names = asks.slice(0, 2).map((entry) => entry.bot.name);
const waiting = asks.length === 0 ? "" : asks.length === 1 ? t("{name} is waiting for your approval", { name: names[0] }) : asks.length === 2 ? t("{first} and {second} are waiting for your approval", { first: names[0], second: names[1] }) : t("{first}, {second} and {count} more are waiting for your approval", { first: names[0], second: names[1], count: asks.length - 2, total: asks.length });
const first = workers[0];
- const doing = first ? `${first.bot.name} · ${workPhrase(first.doing.tool)}…${workers.length > 1 ? ` +${workers.length - 1}` : ""}` : "";
+ const doing = first ? `${first.bot.name} · ${workPhrase(first.doing)}…${workers.length > 1 ? ` +${workers.length - 1}` : ""}` : "";
return { waiting, doing };
}
function Face({ entry, size }) {
@@ -11089,13 +11094,13 @@ function Face({ entry, size }) {
(0, import_react30.createElement)(BotMark, { bot: entry.bot, size, state: entry.state === "ask" ? "alert" : toolState(entry.doing?.tool ?? "") })
);
}
-function WorkRow({ bot, tool, label, at, now, onOpen }) {
- const text = `${label} · ${workPhrase(tool)}…`;
+function WorkRow({ bot, doing, label, at, now, onOpen }) {
+ const text = `${label} · ${workPhrase(doing)}…`;
const elapsed = typeof at === "number" && now - at >= 6e4 ? elapsedLabel(now - at) : "";
return (0, import_react30.createElement)(
"button",
- { type: "button", className: "bt-mw-row", "aria-label": [text, elapsed].filter(Boolean).join(" · "), onClick: onOpen },
- (0, import_react30.createElement)(BotMark, { bot, size: 22, state: toolState(tool ?? ""), live: true }),
+ { type: "button", className: "bt-mw-row", "aria-label": [text, elapsed].filter(Boolean).join(" · "), title: text, onClick: onOpen },
+ (0, import_react30.createElement)(BotMark, { bot, size: 22, state: doing?.switching ? "thinking" : toolState(doing?.tool ?? ""), live: true }),
(0, import_react30.createElement)("span", { className: "bt-mw-row-text" }, (0, import_react30.createElement)(Shimmer, null, text)),
elapsed ? (0, import_react30.createElement)("span", { className: "bt-mw-row-time" }, `· ${elapsed}`) : null
);
@@ -11134,14 +11139,14 @@ function MemberDock({ sessionId, useRoster, useWork, actions }) {
return (0, import_react30.createElement)(
"div",
{ ref, className: "bt-mw-dock-stack" },
- rows.map((entry) => (0, import_react30.createElement)(WorkRow, { key: entry.id, bot: entry.bot, tool: entry.doing.tool, label: entry.bot.name, at: entry.doing.since, now, onOpen: open })),
+ rows.map((entry) => (0, import_react30.createElement)(WorkRow, { key: entry.id, bot: entry.bot, doing: entry.doing, label: entry.bot.name, at: entry.doing.since, now, onOpen: open })),
rest.length > 0 ? (0, import_react30.createElement)(SummaryLine, { busy: rest, onOpen: open }) : null
);
}
return (0, import_react30.createElement)("div", { ref, className: "bt-mw-dock-stack" }, groups.slice(0, ROWS_MAX).map((item) => (0, import_react30.createElement)(WorkRow, {
key: item.room.id,
bot,
- tool: item.tool,
+ doing: item.doing,
label: t("in {name}", { name: item.room.name }),
at: item.since,
now,
@@ -11222,7 +11227,7 @@ function MemberWork({ entry, bot, room: room2, roster, actions, now }) {
(0, import_react30.createElement)(
"div",
{ className: "bt-mw-state bt-mw-work" },
- (0, import_react30.createElement)("span", null, (0, import_react30.createElement)(Shimmer, null, `${workPhrase(entry.doing.tool)}…`), where ? ` ${where}` : "", since(now, entry.doing.since)),
+ (0, import_react30.createElement)("span", null, (0, import_react30.createElement)(Shimmer, null, `${workPhrase(entry.doing)}…`), where ? ` ${where}` : "", since(now, entry.doing.since)),
entry.here ? (0, import_react30.createElement)("button", { type: "button", className: "bt-mw-stop", disabled: stopping, onClick: stop }, t("Stop")) : null
)
);
diff --git a/ds-bot/src/client/cells.js b/ds-bot/src/client/cells.js
index d125adad..0d404884 100644
--- a/ds-bot/src/client/cells.js
+++ b/ds-bot/src/client/cells.js
@@ -524,10 +524,16 @@ function toolActivity(name, arg, findBot, self) {
}
}
-// What a Bot busy elsewhere is doing, from its current tool alone.
-export function workPhrase(tool) {
+// What a Bot busy elsewhere is doing: its running call's own description, else the kind
+// of tool and what it works on. `doing` is a work entry, or just a tool name.
+export function workPhrase(doing) {
+ const { tool, note, target, switching } = typeof doing === 'string' ? { tool: doing } : doing ?? {}
+ if (switching) return t('Moving to a fresh conversation')
+ const own = note?.replace(/[\s.。…]+$/u, '')
+ if (own) return own
if (!tool) return t('Thinking about it')
- return toolActivity(tool, () => undefined, () => undefined)?.label ?? t('On it')
+ const label = toolActivity(tool, () => undefined, () => undefined)?.label ?? t('On it')
+ return target ? `${label} · ${target}` : label
}
// Transcript rows report what is in flight to the one activity row at the tail.
@@ -565,6 +571,7 @@ function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi
// Members speak one at a time, so only the current speaker is typing.
const pending = done || !live.speaking ? [] : [live.speaking]
const speakerTool = useWork?.(work => work.bots?.[live.speaking]?.tool) ?? undefined
+ const speakerDoing = useWork?.(work => (work.bots?.[live.speaking]?.tool ? workPhrase(work.bots[live.speaking]) : undefined)) ?? undefined
if (replies.length === 0 && pending.length === 0) return null
const room = roster.roomsById[sessionId]
return h('div', { className: 'bt-group-replies' },
@@ -606,7 +613,7 @@ function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi
if (!bot) return null
return h('div', { key: `pending-${id}`, className: 'bt-activity' },
h(BotMark, { bot: bot, size: 22, state: speakerTool ? toolState(speakerTool) : 'thinking' }),
- h(Shimmer, null, speakerTool ? `${bot.name} · ${workPhrase(speakerTool)}…` : t('{name} is typing…', { name: bot.name })))
+ h(Shimmer, null, speakerDoing ? `${bot.name} · ${speakerDoing}…` : t('{name} is typing…', { name: bot.name })))
}))
}
diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.js
index 6cf2df85..4013427e 100644
--- a/ds-bot/src/client/i18n.js
+++ b/ds-bot/src/client/i18n.js
@@ -416,6 +416,7 @@ const ZH = {
'Moving ahead': '推进中',
'Taking care of it': '处理中',
'Making headway': '有进展了',
+ 'Moving to a fresh conversation': '整理记忆,换到新对话',
'Searching online': '上网搜索',
'Reading a page': '阅读网页',
'Running shell commands': '运行命令',
diff --git a/ds-bot/src/client/member-status.js b/ds-bot/src/client/member-status.js
index d7eb2a86..9c76186b 100644
--- a/ds-bot/src/client/member-status.js
+++ b/ds-bot/src/client/member-status.js
@@ -44,7 +44,7 @@ export function botGroupWork(botId, work, roster) {
return Object.entries(work.rooms ?? {}).flatMap(([roomId, entries]) => {
const entry = entries.find(item => item.botId === botId)
const room = roster.roomsById[roomId]
- return entry && room ? [{ room, tool: entry.tool, since: entry.since }] : []
+ return entry && room ? [{ room, doing: entry, since: entry.since }] : []
})
}
@@ -57,7 +57,7 @@ export function summaryText(busy) {
: asks.length === 2 ? t('{first} and {second} are waiting for your approval', { first: names[0], second: names[1] })
: t('{first}, {second} and {count} more are waiting for your approval', { first: names[0], second: names[1], count: asks.length - 2, total: asks.length })
const first = workers[0]
- const doing = first ? `${first.bot.name} · ${workPhrase(first.doing.tool)}…${workers.length > 1 ? ` +${workers.length - 1}` : ''}` : ''
+ const doing = first ? `${first.bot.name} · ${workPhrase(first.doing)}…${workers.length > 1 ? ` +${workers.length - 1}` : ''}` : ''
return { waiting, doing }
}
@@ -67,11 +67,11 @@ function Face({ entry, size }) {
}
// One piece of work: the Bot's mark and what it is doing, like the activity row.
-function WorkRow({ bot, tool, label, at, now, onOpen }) {
- const text = `${label} · ${workPhrase(tool)}…`
+function WorkRow({ bot, doing, label, at, now, onOpen }) {
+ const text = `${label} · ${workPhrase(doing)}…`
const elapsed = typeof at === 'number' && now - at >= 60000 ? elapsedLabel(now - at) : ''
- return h('button', { type: 'button', className: 'bt-mw-row', 'aria-label': [text, elapsed].filter(Boolean).join(' · '), onClick: onOpen },
- h(BotMark, { bot, size: 22, state: toolState(tool ?? ''), live: true }),
+ return h('button', { type: 'button', className: 'bt-mw-row', 'aria-label': [text, elapsed].filter(Boolean).join(' · '), title: text, onClick: onOpen },
+ h(BotMark, { bot, size: 22, state: doing?.switching ? 'thinking' : toolState(doing?.tool ?? ''), live: true }),
h('span', { className: 'bt-mw-row-text' }, h(Shimmer, null, text)),
elapsed ? h('span', { className: 'bt-mw-row-time' }, `· ${elapsed}`) : null)
}
@@ -106,11 +106,11 @@ export function MemberDock({ sessionId, useRoster, useWork, actions }) {
const { rows, rest } = splitBusy(busy)
const open = () => actions.showDetails(sessionId)
return h('div', { ref, className: 'bt-mw-dock-stack' },
- rows.map(entry => h(WorkRow, { key: entry.id, bot: entry.bot, tool: entry.doing.tool, label: entry.bot.name, at: entry.doing.since, now, onOpen: open })),
+ rows.map(entry => h(WorkRow, { key: entry.id, bot: entry.bot, doing: entry.doing, label: entry.bot.name, at: entry.doing.since, now, onOpen: open })),
rest.length > 0 ? h(SummaryLine, { busy: rest, onOpen: open }) : null)
}
return h('div', { ref, className: 'bt-mw-dock-stack' }, groups.slice(0, ROWS_MAX).map(item => h(WorkRow, {
- key: item.room.id, bot, tool: item.tool, label: t('in {name}', { name: item.room.name }), at: item.since, now, onOpen: () => actions.openSession(item.room.id),
+ key: item.room.id, bot, doing: item.doing, label: t('in {name}', { name: item.room.name }), at: item.since, now, onOpen: () => actions.openSession(item.room.id),
})))
}
@@ -190,7 +190,7 @@ export function MemberWork({ entry, bot, room, roster, actions, now }) {
}
return h('div', { className: 'bt-mw-member' },
h('div', { className: 'bt-mw-state bt-mw-work' },
- h('span', null, h(Shimmer, null, `${workPhrase(entry.doing.tool)}…`), where ? ` ${where}` : '', since(now, entry.doing.since)),
+ h('span', null, h(Shimmer, null, `${workPhrase(entry.doing)}…`), where ? ` ${where}` : '', since(now, entry.doing.since)),
entry.here ? h('button', { type: 'button', className: 'bt-mw-stop', disabled: stopping, onClick: stop }, t('Stop')) : null))
}
diff --git a/ds-bot/src/client/sidebar.js b/ds-bot/src/client/sidebar.js
index 2b3ea08f..78355413 100644
--- a/ds-bot/src/client/sidebar.js
+++ b/ds-bot/src/client/sidebar.js
@@ -30,12 +30,11 @@ const useApproval = (useWork, match) => (useWork ? useWork(work => (work.approva
// Work running in group Sessions, as "botId|tool" keys so a row redraws only when it
// changes: the groups one Bot works in, or the members at work in one group.
-const useGroupWork = (useWork, pick) => (useWork ? useWork(work => pick(work.rooms ?? {}).join(',')) : '')
-const workKeys = text => (text === '' ? [] : text.split(',').map((key) => {
- const [id, tool] = key.split('|')
- return { id, tool: tool || undefined }
-}))
-const workLine = (lead, tool, more) => h(Shimmer, null, `${lead} · ${workPhrase(tool)}…${more > 0 ? ` +${more}` : ''}`)
+// Picked as text, so a row redraws only when what it shows changes.
+const useGroupWork = (useWork, pick) => (useWork ? useWork(work => JSON.stringify(pick(work.rooms ?? {}))) : '[]')
+const workKeys = text => JSON.parse(text)
+const doingOf = ({ tool, note, target, switching }) => ({ tool, note, target, switching })
+const workLine = (lead, doing, more) => h(Shimmer, null, `${lead} · ${workPhrase(doing)}…${more > 0 ? ` +${more}` : ''}`)
function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessionRetainInfo, useActivity, useWork, wide, marked }) {
const id = bot.id
@@ -51,10 +50,10 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessio
const alert = roster.questions?.[part] !== undefined || approval
const doing = useActivity(map => map[id])
// Work in a group runs in a Session of its own, so the Bot's chat stays idle meanwhile.
- const groups = workKeys(useGroupWork(useWork, rooms => Object.entries(rooms).flatMap(([roomId, entries]) => entries.filter(entry => entry.botId === id).map(entry => `${roomId}|${entry.tool ?? ''}`))))
+ const groups = workKeys(useGroupWork(useWork, rooms => Object.entries(rooms).flatMap(([roomId, entries]) => entries.filter(entry => entry.botId === id).map(entry => ({ id: roomId, ...doingOf(entry) })))))
const away = !running && groups.length > 0
const state = botState(running || away, doing, alert)
- const awayLine = away ? workLine(roster.roomsById[groups[0].id]?.name ?? t('a group chat'), groups[0].tool, groups.length - 1) : null
+ const awayLine = away ? workLine(roster.roomsById[groups[0].id]?.name ?? t('a group chat'), groups[0], groups.length - 1) : null
if (bot.hidden && !active && !main) return null
const onContextMenu = (event) => {
event.preventDefault()
@@ -91,9 +90,9 @@ function RoomRow({ room, roster, actions, useSessions, useSessionStatus, useSess
const unread = useSessionStatus(map => map.get(id)?.completionUnread === true) || (marked && !active)
useMarkedUnread(id, active, marked, actions)
const approval = useApproval(useWork, entry => entry.roomId === id)
- const members = workKeys(useGroupWork(useWork, rooms => (rooms[id] ?? []).map(entry => `${entry.botId}|${entry.tool ?? ''}`)))
+ const members = workKeys(useGroupWork(useWork, rooms => (rooms[id] ?? []).map(entry => ({ id: entry.botId, ...doingOf(entry) }))))
const first = roster.byId[members[0]?.id]
- const workingLine = first ? workLine(first.name, members[0].tool, members.length - 1) : null
+ const workingLine = first ? workLine(first.name, members[0], members.length - 1) : null
if (room.hidden && !active) return null
const pinned = room.pinned === true
const label = [room.name, pinned ? t('Pinned') : '', members.length > 0 ? t('Working') : '', approval ? t('Waiting for your approval') : ''].filter(Boolean).join(', ')
diff --git a/ds-bot/src/host/parts.js b/ds-bot/src/host/parts.js
index 73ab3ed5..c734aada 100644
--- a/ds-bot/src/host/parts.js
+++ b/ds-bot/src/host/parts.js
@@ -672,7 +672,7 @@ export function install(rt) {
function startSwitch(agent, { resume = false, carry = [], info, joined, overflow = false, failed, bare = false, folder = false, hard = overflow || folder } = {}) {
const place = placeOf(agent.id)
if (place === undefined || switches.has(agent.id) || readOnly()) return
- const job = { ...place, carry: [...carry], info, joined, resume, overflow, failed, bare, folder, hard }
+ const job = { ...place, carry: [...carry], info, joined, resume, overflow, failed, bare, folder, hard, since: Date.now() }
switches.set(agent.id, job)
void runSwitch(agent, job)
.catch(error => rt.warn('ds-bot: %s did not move on to a fresh part: %s', rt.botOf(job.botId)?.name ?? agent.id, error))
diff --git a/ds-bot/src/host/turns.js b/ds-bot/src/host/turns.js
index f062a5e8..bcd9f8e4 100644
--- a/ds-bot/src/host/turns.js
+++ b/ds-bot/src/host/turns.js
@@ -216,7 +216,25 @@ export function install(rt) {
return merged
}
- // Per Bot, the turn it is running and its current tool; its own chat wins over a group.
+ // What the newest running call does, in its own words: its description, else the
+ // file, search or site it works on.
+ const doingOf = (entry) => {
+ const call = [...(entry.calls?.values() ?? [])].at(-1)
+ if (call === undefined) return {}
+ let args
+ try { args = JSON.parse(call.args || '{}') } catch { args = {} }
+ const first = keys => keys.map(key => args?.[key]).find(value => typeof value === 'string' && value.trim() !== '')?.replace(/\s+/g, ' ').trim()
+ const note = first(['description', 'justification'])
+ const path = first(['file_path', 'path'])
+ const url = first(['url'])
+ let site
+ try { site = url && new URL(url).host } catch { site = undefined }
+ const target = path?.split(/[\\/]/).filter(Boolean).at(-1) ?? first(['query', 'pattern']) ?? site
+ return { tool: call.name, ...(note ? { note: note.slice(0, 120) } : {}), ...(target ? { target: target.slice(0, 80) } : {}) }
+ }
+
+ // Per Bot, the turn it is running and what it is doing; its own chat wins over a
+ // group. A Bot writing its handoff note shows that.
const workView = () => {
const bots = {}
for (const [id, entry] of live) {
@@ -224,25 +242,31 @@ export function install(rt) {
const owner = rt.groupOwners.get(id)
const botId = owner?.botId ?? rt.chatOwners.get(id)
if (botId === undefined || (owner !== undefined && bots[botId] !== undefined)) continue
- bots[botId] = { since: entry.since, ...(entry.tool ? { tool: entry.tool } : {}), ...(owner ? { roomId: owner.roomId } : {}) }
+ bots[botId] = { since: entry.since, ...doingOf(entry), ...(owner ? { roomId: owner.roomId } : {}) }
+ }
+ for (const job of rt.switchJobs()) {
+ const work = { since: job.since, switching: true, ...(job.roomId ? { roomId: job.roomId } : {}) }
+ if (job.roomId === undefined) bots[job.botId] = work
+ else bots[job.botId] ??= work
}
return bots
}
- // Per group, the members whose turn there is running; the round's current speaker is
- // marked, since its round shows it.
+ // Per group, the members whose turn there is running or who move on to a fresh part;
+ // the round's current speaker is marked, since its round shows it.
const roomWorkView = () => {
const speaking = new Set([...roomProgress.values()].map(round => `${round.roomId}:${round.speaking}`))
const rooms = {}
+ const add = (roomId, botId, work) => {
+ if (rooms[roomId]?.some(item => item.botId === botId)) return
+ rooms[roomId] = [...(rooms[roomId] ?? []), { botId, ...work, ...(speaking.has(`${roomId}:${botId}`) ? { speaking: true } : {}) }]
+ }
for (const [id, entry] of live) {
const owner = rt.groupOwners.get(id)
- if (entry.turn === undefined || owner === undefined) continue
- rooms[owner.roomId] = [...(rooms[owner.roomId] ?? []), {
- botId: owner.botId,
- since: entry.since,
- ...(entry.tool ? { tool: entry.tool } : {}),
- ...(speaking.has(`${owner.roomId}:${owner.botId}`) ? { speaking: true } : {}),
- }]
+ if (entry.turn !== undefined && owner !== undefined) add(owner.roomId, owner.botId, { since: entry.since, ...doingOf(entry) })
+ }
+ for (const job of rt.switchJobs()) {
+ if (job.roomId !== undefined) add(job.roomId, job.botId, { since: job.since, switching: true })
}
return rooms
}
diff --git a/ds-bot/test/group-work.test.js b/ds-bot/test/group-work.test.js
index b1ffa89e..12e13443 100644
--- a/ds-bot/test/group-work.test.js
+++ b/ds-bot/test/group-work.test.js
@@ -455,3 +455,14 @@ test('a private message to a group Session is answered privately, without steps
assert.match(text(host.agentOf('c').calls[0]), /我看一下。\n\n看过了,没问题。/)
assert.deepEqual(host.agentOf('r1').calls, [])
})
+
+test('the team view says what a member is doing in the call\'s own words', async (t) => {
+ const host = await start(t)
+ host.emit('gb', 'turn/start', { turn: 1 })
+ host.emit('gb', 'tool/call', { callId: 'k1', name: 'pwsh', arguments: JSON.stringify({ command: 'iwr https://example.com/x.zip', description: 'Download Ghidra 12.1.4\nand check its hash' }) })
+ host.emit('gc', 'turn/start', { turn: 1 })
+ host.emit('gc', 'tool/call', { callId: 'k2', name: 'read', arguments: JSON.stringify({ file_path: 'E:\\src\\tools\\dump.py' }) })
+ const { value } = await host.call('state', {})
+ assert.deepEqual(value.work.rooms.r1.map(entry => [entry.botId, entry.tool, entry.note, entry.target]), [['b', 'pwsh', 'Download Ghidra 12.1.4 and check its hash', undefined], ['c', 'read', undefined, 'dump.py']])
+ assert.equal(value.work.bots.b.note, 'Download Ghidra 12.1.4 and check its hash')
+})
diff --git a/ds-bot/test/member-status.test.js b/ds-bot/test/member-status.test.js
index e50afaac..66dbed42 100644
--- a/ds-bot/test/member-status.test.js
+++ b/ds-bot/test/member-status.test.js
@@ -82,3 +82,16 @@ test('a Bot\'s own chat shows the groups it is at work in, unless its own chat r
assert.deepEqual(rowLabels(dock('a', { ...away, bots: { a: { since: 1 } } })), [])
assert.equal(dock('b', away), null)
})
+
+test('a row says what a member does in its call\'s own words, and that it moves to a fresh conversation', () => {
+ const work = {
+ bots: {},
+ rooms: { r1: [
+ { botId: 'a', since: 1, tool: 'pwsh', note: 'Download Ghidra 12.1.4 and check its hash.' },
+ { botId: 'b', since: 1, tool: 'read', target: 'dump.py' },
+ { botId: 'c', since: 1, switching: true },
+ ] },
+ approvals: [],
+ }
+ assert.deepEqual(rowLabels(dock('r1', work)), ['Anvil · Download Ghidra 12.1.4 and check its hash…', 'Flint · Opening a file · dump.py…', 'Prism · Moving to a fresh conversation…'])
+})