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 fix/238-group-folder-scope
Fei2411439e2bb5ea88
diff --cc ds-bot/client.jsindex 4df51537,c6f4318c..ec520f75--- a/ds-bot/client.js+++ b/ds-bot/client.js@@@ -8667,63 -8591,54 +8667,66 @@@ function useLiveNote(actions, sessionIdreturn () => actions.noteLive(sessionId, id, null);}, [sessionId, id, key]);}-var RELAY_LIST = /"replies"\s*:\s*\[/;-var PRUNE_MARKER = /\[\.\.\. tool result middle pruned \.\.\.\]/;-function parseReplies(text) {- try {- return { replies: JSON.parse(text).replies ?? [], broken: false };- } catch {+function RelayEvent({ reply, bot, sessionId, actions }) {+ if (reply.kind === "failed") {+ return (0, import_react17.createElement)(+ "div",+ { className: "bt-event bt-event-error", role: "status", title: [reply.code, reply.status, reply.text].filter(Boolean).join(" · ") },+ t("{name} could not answer: {reason}", { name: bot.name, reason: failureLabel(reply.code, reply.text) })+ );}- const replies = [];- const head = RELAY_LIST.exec(text);- if (head) {- for (const piece of text.slice(head.index + head[0].length).split(PRUNE_MARKER)) {- const first = piece.indexOf('{"');- if (first !== -1) scanReplies(piece, first, replies);- }+ if (reply.kind === "lookup") {+ return (0, import_react17.createElement)(+ "div",+ { className: "bt-event" },+ reply.text ? t("{name} looked up its own chat for “{text}”", { name: bot.name, text: reply.text }) : t("{name} looked up its own chat", { name: bot.name })+ );}- return { replies, broken: true };-}-function scanReplies(text, start, replies) {- let depth = 0;- let from = -1;- let inString = false;- let escaped = false;- for (let i = start; i < text.length; i += 1) {- const ch = text[i];- if (inString) {- if (escaped) escaped = false;- else if (ch === "\\") escaped = true;- else if (ch === '"') inString = false;- continue;- }- if (ch === '"') {- inString = true;- continue;- }- if (ch === "{") {- if (depth === 0) from = i;- depth += 1;- } else if (ch === "}") {- depth -= 1;- if (depth === 0 && from >= 0) {- try {- replies.push(JSON.parse(text.slice(from, i + 1)));- } catch {- }- from = -1;- }- } else if (ch === "]" && depth === 0) break;+ if (reply.kind === "missed") {+ return (0, import_react17.createElement)("div", { className: "bt-event" }, t("{name} didn't answer in time", { name: bot.name }));}+ if (reply.kind === "admin-passed") {+ return (0, import_react17.createElement)(+ "div",+ { 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_react17.createElement)(+ "div",+ { className: "bt-event" },+ t("Paused after {count} Bot relays. Waiting: {names}", { count: reply.count, names: (reply.names ?? []).join(t(" and ")) })+ );+ }+ if (reply.kind === "resumed") {+ return (0, import_react17.createElement)("div", { className: "bt-event" }, t("{name} was cut off by a restart and picked its work back up", { name: bot.name }));+ }+ if (reply.kind === "cut") {+ return (0, import_react17.createElement)("div", { className: "bt-event" }, t("{name} was cut off by a restart again and stopped", { name: bot.name }));+ }+ if (reply.kind === "approval" || reply.kind === "working") {+ return (0, import_react17.createElement)(+ "div",+ { className: "bt-event" },+ (0, import_react17.createElement)(+ "button",+ { type: "button", className: "bt-event-whole", onClick: () => actions.showDetails(sessionId) },+ (0, import_react17.createElement)(BotMark, { bot, size: 16 }),+ (0, import_react17.createElement)("span", { className: "bt-event-name" }, t(reply.kind === "working" ? "{name} started on it" : "{name} paused for your approval", { name: bot.name }))+ )+ );+ }++ if (reply.kind === "folder") {++ return (0, import_react17.createElement)("div", { className: "bt-event" }, reply.text);++ }+ if (reply.kind === "stopped") {+ return (0, import_react17.createElement)("div", { className: "bt-event" }, t("You stopped {name}'s work", { name: bot.name }));+ }+ if (reply.kind === "done") {+ return (0, import_react17.createElement)("div", { className: "bt-event" }, t("{name} finished its work", { name: bot.name }));+ }+ return null;}function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi, useWork }) {const [live, setLive] = (0, import_react17.useState)({ replies: [], speaking: [] });diff --cc ds-bot/src/client/cells.jsindex 64163a9b,f61be2b1..6575a1ba--- a/ds-bot/src/client/cells.js+++ b/ds-bot/src/client/cells.js@@@ -854,48 -849,54 +854,51 @@@ function useLiveNote(actions, sessionId}, [sessionId, id, key])}-// Reads the replies of a settled group_relay result. Compaction can prune the-// middle of a long tool result, which leaves invalid JSON: then every complete-// reply object that survived is recovered so the turn still draws what it can.-const RELAY_LIST = /"replies"\s*:\s*\[/-// Compaction marks a pruned span with a literal bracketed note like-// "[... tool result middle pruned ...]". Its "]" looks like the end of the-// replies array to a naive scan, so the text is split on the marker first.-const PRUNE_MARKER = /\[\.\.\. tool result middle pruned \.\.\.\]/-function parseReplies(text) {- try { return { replies: JSON.parse(text).replies ?? [], broken: false } } catch { /* fall through */ }- const replies = []- const head = RELAY_LIST.exec(text)- if (head) {- for (const piece of text.slice(head.index + head[0].length).split(PRUNE_MARKER)) {- // The cut can start inside a string, leaving a fragment that keeps the- // scanner inside quotes: restart at the first complete reply instead.- const first = piece.indexOf('{"')- if (first !== -1) scanReplies(piece, first, replies)- }+// One non-message row of a group round: the same event line the live view draws+// for a reply that is not a member's message or the user's own line. `bot` is the+// resolved member the reply names.+function RelayEvent({ reply, bot, sessionId, actions }) {+ if (reply.kind === 'failed') {+ return h('div', { className: 'bt-event bt-event-error', role: 'status', title: [reply.code, reply.status, reply.text].filter(Boolean).join(' · ') },+ t('{name} could not answer: {reason}', { name: bot.name, reason: failureLabel(reply.code, reply.text) }))}- return { replies, broken: true }-}--function scanReplies(text, start, replies) {- let depth = 0- let from = -1- let inString = false- let escaped = false- for (let i = start; i < text.length; i += 1) {- const ch = text[i]- if (inString) {- if (escaped) escaped = false- else if (ch === '\\') escaped = true- else if (ch === '"') inString = false- continue- }- if (ch === '"') { inString = true; continue }- if (ch === '{') {- if (depth === 0) from = i- depth += 1- } else if (ch === '}') {- depth -= 1- if (depth === 0 && from >= 0) {- try { replies.push(JSON.parse(text.slice(from, i + 1))) } catch { /* partial object */ }- from = -1- }- } else if (ch === ']' && depth === 0) break+ if (reply.kind === 'lookup') {+ return h('div', { className: 'bt-event' },+ reply.text ? t('{name} looked up its own chat for “{text}”', { name: bot.name, text: reply.text }) : t('{name} looked up its own chat', { name: bot.name }))+ }+ if (reply.kind === 'missed') {+ return h('div', { className: 'bt-event' }, t("{name} didn't answer in time", { name: bot.name }))+ }+ if (reply.kind === 'admin-passed') {+ return h('div', { className: 'bt-event' },+ t('{name} did not answer or call anyone; call a member with @Name', { name: bot.name }))+ }+ // LEGACY: rounds from when groups paused at a relay limit.+ if (reply.kind === 'paused') {+ return h('div', { className: 'bt-event' },+ t('Paused after {count} Bot relays. Waiting: {names}', { count: reply.count, names: (reply.names ?? []).join(t(' and ')) }))+ }+ if (reply.kind === 'resumed') {+ return h('div', { className: 'bt-event' }, t('{name} was cut off by a restart and picked its work back up', { name: bot.name }))}+ if (reply.kind === 'cut') {+ return h('div', { className: 'bt-event' }, t('{name} was cut off by a restart again and stopped', { name: bot.name }))+ }+ if (reply.kind === 'approval' || reply.kind === 'working') {+ return h('div', { className: 'bt-event' },+ h('button', { type: 'button', className: 'bt-event-whole', onClick: () => actions.showDetails(sessionId) },+ h(BotMark, { bot, size: 16 }), h('span', { className: 'bt-event-name' }, t(reply.kind === 'working' ? '{name} started on it' : '{name} paused for your approval', { name: bot.name }))))+ }++ if (reply.kind === 'folder') {++ return h('div', { className: 'bt-event' }, reply.text)++ }+ if (reply.kind === 'stopped') {+ return h('div', { className: 'bt-event' }, t("You stopped {name}'s work", { name: bot.name }))+ }+ if (reply.kind === 'done') {+ return h('div', { className: 'bt-event' }, t('{name} finished its work', { name: bot.name }))+ }+ return null}function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi, useWork }) {diff --cc ds-bot/src/host/roster.jsindex 1505a1b1,39e772cc..0aa22ea1--- a/ds-bot/src/host/roster.js+++ b/ds-bot/src/host/roster.js@@@ -537,16 -544,12 +544,17 @@@ export function install(rt)room.notice = noticechanges.push(notice ? 'updated the notice' : 'cleared the notice')}- // Members' group conversations move on to the folder at their next turn there.+ // Members' group conversations move on to the folder at their next turn there;+ // the group's own Session moves the same way, now when it is idle.if (moving && workDir !== room.workDir) {+ delete room.folderNoticeif (workDir === undefined) delete room.workDirelse room.workDir = workDir+ // A member's own pick for this group gives way to the group's folder, and a+ // cleared one does not bring it back.+ delete room.memberDirschanges.push(workDir ? `every member now works in ${workDir} here` : 'every member works in its own folder again')+ void rt.followFolder({ roomId: room.id })}const before = room.nameif (name !== undefined) {