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/254-message-time
Fei241168c4570601ed
diff --cc ds-bot/client.jsindex fd7b5673,1783c49c..168aef38--- a/ds-bot/client.js+++ b/ds-bot/client.js@@@ -4443,27 -4551,24 +4568,27 @@@ function EventLine({ prefix, bots, joinbot.name));});- return (0, import_react7.createElement)("div", { className: "bt-event" }, parts);+ return (0, import_react8.createElement)("div", { className: "bt-event" }, parts);}-function GroupMessage({ bot, text, texts: texts2 = [text], room: room2, roster, actions, msgKey, useUi, whole }) {+function GroupMessage({ bot, text, texts: texts2 = [text], room: room2, roster, actions, msgKey, useUi, whole, time, duration }) {- const lead = (0, import_react7.createElement)(+ const lead = (0, import_react8.createElement)("button",{ type: "button", className: "bt-lead", "aria-label": t("Open {name}'s chat", { name: bot.name }), onClick: () => actions.openSession(bot.id) },- (0, import_react7.createElement)(BotMark, { bot, size: 22 })+ (0, import_react8.createElement)(BotMark, { bot, size: 22 }));+ const took = Number.isFinite(duration) ? elapsedLabel(duration) : void 0;- return (0, import_react7.createElement)(+ return (0, import_react8.createElement)("div",{ className: "bt-group-msg" },- (0, import_react7.createElement)(+ (0, import_react8.createElement)("span",{ className: "bt-group-name", style: { color: inkText(colorOf(bot)) } },bot.name,- room2?.admin === bot.id ? (0, import_react7.createElement)("span", { className: "bt-group-role" }, t("Admin")) : null,- Number.isFinite(time) ? (0, import_react7.createElement)("span", { className: "bt-group-time", title: clockLabel(time) }, messageClock(time)) : null,- took ? (0, import_react7.createElement)("span", { className: "bt-group-took", title: t("Ran for {duration}", { duration: took }) }, took) : null- room2?.admin === bot.id ? (0, import_react8.createElement)("span", { className: "bt-group-role" }, t("Admin")) : null++ room2?.admin === bot.id ? (0, import_react8.createElement)("span", { className: "bt-group-role" }, t("Admin")) : null,++ Number.isFinite(time) ? (0, import_react8.createElement)("span", { className: "bt-group-time", title: clockLabel(time) }, messageClock(time)) : null,++ took ? (0, import_react8.createElement)("span", { className: "bt-group-took", title: t("Ran for {duration}", { duration: took }) }, took) : null),- (0, import_react7.createElement)(Bubbles, { texts: texts2, roster, selfId: bot.id, actions, sessionId: room2?.id, msgKey, useUi, lead, whole })+ (0, import_react8.createElement)(Bubbles, { texts: texts2, roster, selfId: bot.id, actions, sessionId: room2?.id, msgKey, useUi, lead, whole }));}function stackReplies(replies) {@@@ -4900,16 -5011,16 +5025,16 @@@ function GroupReplies({ sessionId, callconst 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_react7.createElement)(+ return (0, import_react8.createElement)("div",{ className: "bt-group-replies" },- stackReplies(replies).map(({ reply, index, texts: texts2 }) => {+ stackReplies(replies).map(({ reply, index, texts: texts2, time, duration }) => {const bot = roster.byId[reply.botId] ?? { id: reply.botId, name: reply.name, color: reply.color ?? "gray" };if (reply.kind === "user") {- return (0, import_react7.createElement)("div", { key: `user-${index}`, className: "bt-urow" }, (0, import_react7.createElement)(+ return (0, import_react8.createElement)("div", { key: `user-${index}`, className: "bt-urow" }, (0, import_react8.createElement)("div",{ className: "bt-ububble" },- (0, import_react7.createElement)(import_dsh_client_ui_primitives.MarkdownText, { text: reply.text, labels: mdLabels(), variant: "compact" })+ (0, import_react8.createElement)(import_dsh_client_ui_primitives.MarkdownText, { text: reply.text, labels: mdLabels(), variant: "compact" })));}if (reply.kind === "failed") {@@@ -4948,12 -5059,12 +5073,12 @@@);}if (reply.kind === "stopped") {- return (0, import_react7.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("You stopped {name}'s work", { name: bot.name }));+ return (0, import_react8.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_react7.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("{name} finished its work", { name: bot.name }));+ return (0, import_react8.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("{name} finished its work", { name: bot.name }));}- return (0, import_react7.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_react8.createElement)(GroupMessage, { key: `${reply.botId}-${index}`, bot, texts: texts2, room: room2, roster, actions, msgKey: callId ? `${sessionId}:${callId}:${index}` : void 0, useUi });++ return (0, import_react8.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) => {const bot = roster.byId[id];@@@ -14177,27 -14373,25 +14387,27 @@@ function UserMessageCell({ node, sessioconst referenceLabels = data.referenceLabels ?? [];const references = openFile && openSkill ? { openFile, openSkill } : void 0;const steering = node.kind === "steering";+ const groupTime = roster.roomsById?.[sessionId] && Number.isFinite(data.time) ? messageClock(data.time) : void 0;const { shown, folded, control } = useFold(text, { markdown: false });- const body = (0, import_react37.createElement)(UserText, { text: shown, bots: mentionableBots(roster, sessionId), referenceLabels, skillNames: data.skillNames ?? [], references, actions });- return (0, import_react37.createElement)(+ const body = (0, import_react38.createElement)(UserText, { text: shown, bots: mentionableBots(roster, sessionId), referenceLabels, skillNames: data.skillNames ?? [], references, actions });+ return (0, import_react38.createElement)("div",{ className: "bt-umsg", "data-steering": steering || void 0 },- (0, import_react37.createElement)(+ (0, import_react38.createElement)("div",{ className: "bt-ustack" },- attachments.length > 0 ? (0, import_react37.createElement)(Attachments, { attachments, renderMessageImages }) : null,- text !== "" || rest.length > 0 ? (0, import_react37.createElement)(+ attachments.length > 0 ? (0, import_react38.createElement)(Attachments, { attachments, renderMessageImages }) : null,+ text !== "" || rest.length > 0 ? (0, import_react38.createElement)("div",{ className: "bt-ubody", title: clock3(data.time), "data-folded": folded || void 0 },- control ? (0, import_react37.createElement)("div", { className: "bt-fold-body" }, body) : body,+ control ? (0, import_react38.createElement)("div", { className: "bt-fold-body" }, body) : body,control,- rest.map((block, index) => ui.JsonBlock ? (0, import_react37.createElement)(ui.JsonBlock, { key: index, label: t("Content"), payload: block }) : null)+ rest.map((block, index) => ui.JsonBlock ? (0, import_react38.createElement)(ui.JsonBlock, { key: index, label: t("Content"), payload: block }) : null)) : null,- referenceLabels.length > 0 ? (0, import_react37.createElement)("div", { className: "bt-urefs" }, t("Referenced {labels}", { labels: referenceLabels.join(t(", ")) })) : null,- groupTime ? (0, import_react37.createElement)("div", { className: "bt-utime", title: clockLabel(data.time) }, groupTime) : null- referenceLabels.length > 0 ? (0, import_react38.createElement)("div", { className: "bt-urefs" }, t("Referenced {labels}", { labels: referenceLabels.join(t(", ")) })) : null++ referenceLabels.length > 0 ? (0, import_react38.createElement)("div", { className: "bt-urefs" }, t("Referenced {labels}", { labels: referenceLabels.join(t(", ")) })) : null,++ groupTime ? (0, import_react38.createElement)("div", { className: "bt-utime", title: clockLabel(data.time) }, groupTime) : null),- text === "" ? null : (0, import_react37.createElement)("div", { className: "bt-utools" }, (0, import_react37.createElement)(CopyButton, { text }))+ text === "" ? null : (0, import_react38.createElement)("div", { className: "bt-utools" }, (0, import_react38.createElement)(CopyButton, { text })));}var USER_MESSAGE_CSS = `diff --cc ds-bot/src/client/cells.jsindex 91787e18,97259661..38fb23cc--- a/ds-bot/src/client/cells.js+++ b/ds-bot/src/client/cells.js@@@ -7,13 -7,13 +7,15 @@@ import { SmileIcon, ReplyIcon, DotsIconimport { colorOf, toolState, BotMark, RoomAvatar } from './mark.js'import { AnsweredCell, SettledQuestion, PendingQuestion } from './questions.js'import { SecretToolCell } from './secret-card.js'- import { t } from './i18n.js'+ import { dateLocale, t } from './i18n.js'+ import { call } from './api.js'import { failureLabel } from './diagnostics.js'- import { turnReasoning } from './turn-reasoning.js'+ import { turnReasoning, thinkingStep } from './turn-reasoning.js'import { FOLD_AT, FOLD_HUGE, stripLongNote, useFold } from './fold.js'+ import { heldCardKey } from './sources.js'+export { clockLabel }+// -------------------------------------------------------------------------// Chat cellsdiff --cc ds-bot/test/tool-cells.test.jsindex 8ec3fb2c,f60792db..595ac39c--- a/ds-bot/test/tool-cells.test.js+++ b/ds-bot/test/tool-cells.test.js@@@ -89,74 -89,16 +89,75 @@@ const program = (subCalls, over = {}) =test('a member\'s messages in a row stack under its name, and an event line starts a new block', () => {const replies = [- { botId: 'writer', text: 'a' }, { botId: 'writer', text: 'b' }, { kind: 'working', botId: 'writer' },- { botId: 'writer', text: 'c' }, { botId: 'chief', text: 'd' }, { botId: 'writer', text: 'e' },+ { botId: 'writer', text: 'a', time: 10, duration: 1000 }, { botId: 'writer', text: 'b', time: 20, duration: 2000 },+ { kind: 'working', botId: 'writer', time: 30 },+ { botId: 'writer', text: 'c', time: 40, duration: 4000 }, { botId: 'chief', text: 'd', time: 50, duration: 5000 },+ { botId: 'writer', text: 'e', time: 60, duration: 6000 },]assert.deepEqual(JSON.parse(JSON.stringify(stackReplies(replies).map(item => [item.index, item.texts]))), [[0, ['a', 'b']], [2, []], [3, ['c']], [4, ['d']], [5, ['e']]])+ // A stacked block carries its last message's time and how long that turn ran.+ const [stacked, event, single] = stackReplies(replies)+ assert.deepEqual([stacked.time, stacked.duration], [20, 2000])+ assert.deepEqual([event.time, event.duration], [30, undefined])+ assert.deepEqual([single.time, single.duration], [40, 4000])+})++// A time in the machine's own zone, some days back, so the test does not depend on the zone.+const at = (daysAgo, hour, minute) => {+ const today = new Date()+ return new Date(today.getFullYear(), today.getMonth(), today.getDate() - daysAgo, hour, minute).getTime()+}+const clockOf = ms => new Date(ms).toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' })+const findAll = (node, match) => {+ const found = []+ const visit = (entry) => {+ if (Array.isArray(entry)) { entry.forEach(visit); return }+ if (!entry || typeof entry !== 'object') return+ if (match(entry)) found.push(entry)+ visit(entry.props?.children)+ }+ visit(node)+ return found+}++test('a group reply shows its time, and how long its turn ran', () => {+ const today = at(0, 14, 5)+ const yesterday = at(1, 9, 3)+ const replies = [+ { botId: 'writer', text: 'Draft is up.', time: today, duration: 68_000 },+ { botId: 'chief', text: 'Looks good.', time: yesterday, duration: 2_000 },+ ]+ const out = show(call('group_relay', 'direct', { content: { replies } }), { sessionId: 'room' })+ const times = findAll(out, node => node.props?.className === 'bt-group-time')+ const tooks = findAll(out, node => node.props?.className === 'bt-group-took')+ assert.deepEqual(times.map(text), [clockOf(today), `Yesterday ${clockOf(yesterday)}`])+ assert.deepEqual(times.map(node => node.props.title), [`Today ${clockOf(today)}`, `Yesterday ${clockOf(yesterday)}`])+ assert.deepEqual(tooks.map(text), ['1m 8s', '2s'])+ assert.deepEqual(tooks.map(node => node.props.title), ['Ran for 1m 8s', 'Ran for 2s'])+})++// 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)+ const node = {+ key: 'trigger', kind: 'turn-trigger', location: { turn: { turn: 1 } },+ data: { seq: 7, time, content: text$('Draft is up.'), source: { kind: 'bot', role: 'post', senderSessionId: 'writer', senderName: 'Writer' } },+ }+ const out = expand(TriggerCell({+ node, sessionId: 'room', actions: {},+ useRoster: select => select(team()), useSessions: select => select({ byId: {} }),+ useTurnClock: select => select({}), useUi: select => select({ visits: {}, reactions: {} }),+ }))+ const stamps = findAll(out, entry => entry.props?.className === 'bt-group-time')+ assert.equal(stamps.length, 1)+ assert.equal(text(stamps[0]), clockOf(time))+ effects = []})- const props = (root, { sessionId = chief.id, roster = team(), actions = {}, turn = 1 } = {}) => ({+ const props = (root, { sessionId = chief.id, roster = team(), actions = {}, turn = 1, held = {} } = {}) => ({node: { key: 'node', data: { root }, location: { turn: { turn } } }, sessionId,useRoster: select => select(roster), useUi: select => select({ reactions: {}, visits: {} }), actions,+ useHeldCards: select => select(held),})const show = (root, options) => {const out = expand(ToolCell(props(root, options)))