A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Scope group member status to the group, surface the real prompt rejection
Fei24111056ef9b6d91
diff --git a/ds-bot/client.js b/ds-bot/client.jsindex 57d20937..7452491c 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -4332,7 +4332,7 @@ var HANDOFF_CSS = `.bt-handoff .bt-q-foot{flex-wrap:wrap}`;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/ui.js+// node_modules/deep-view/src/react/ui.jsvar import_react7 = require("react");var FallbackMarkdown = ({ text }) => (0, import_react7.createElement)("span", null, String(text ?? ""));var ViewUi = (0, import_react7.createContext)({ t: (key) => key, Markdown: FallbackMarkdown });@@ -4399,7 +4399,7 @@ function useOptionKeys2(count, onPick, ownRef) {return count > 0 && listening <= 1;}-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/core/formula.js+// node_modules/deep-view/src/core/formula.jsvar FUNCTIONS = {min: { args: [1, Infinity], run: (...values) => Math.min(...values.map(num)) },max: { args: [1, Infinity], run: (...values) => Math.max(...values.map(num)) },@@ -4680,7 +4680,7 @@ function evaluate(tree, lookup) {}}-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/core/views.js+// node_modules/deep-view/src/core/views.jsvar LAYOUT = ["stack", "row"];var DISPLAY = ["text", "metric", "table", "chart", "progress", "callout", "sources", "html"];var INPUT_TYPES = ["slider", "choice", "toggle", "number"];@@ -5300,7 +5300,7 @@ function validateForm(node, values) {return { fields };}-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/chart.js+// node_modules/deep-view/src/react/chart.jsvar import_react8 = require("react");var PALETTE = ["var(--dv-accent)", "var(--dv-ink-tangerine)", "var(--dv-ink-green)", "var(--dv-ink-violet)", "var(--dv-ink-sky)", "var(--dv-ink-rose)", "var(--dv-ink-yellow)", "var(--dv-ink-cyan)", "var(--dv-ink-magenta)"];var colorAt = (index) => PALETTE[index % PALETTE.length];@@ -5739,7 +5739,7 @@ var CHART_CSS = `@media (prefers-reduced-motion:reduce){.dv-chart-mark,.dv-chart-dot{transition:none}.dv-chart-tip{animation:none}}`;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/frame.js+// node_modules/deep-view/src/react/frame.jsvar import_react9 = require("react");var THEME_VARS = [["--view-ink", "--bt-ink", "--dv-ink"],@@ -5821,7 +5821,7 @@ var HTML_CSS = `.dv-view-frame-stopped{margin:0;font-size:13px;line-height:18px;color:var(--dv-ink-2)}`;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/card.js+// node_modules/deep-view/src/react/card.jsvar import_react10 = require("react");var mdLabels = (ui2) => ({ code: { copyLabel: ui2.t("Copy"), copiedLabel: ui2.t("Copied") }, footnotes: ui2.t("Footnotes") });var TONES2 = ["good", "warn", "bad"];@@ -6490,7 +6490,7 @@ ${CHART_CSS}${HTML_CSS}`;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/styles.js+// node_modules/deep-view/src/react/styles.jsvar THEME_CSS = `body{--dv-ink:var(--dsw-alias-label-primary);@@ -6587,10 +6587,10 @@ button.dv-q-opt:active{background:var(--dv-active)}@media (prefers-reduced-motion:reduce){.dv-q,.dv-view-bare,.dv-q-submit,.dv-menu,.dv-q-check{animation:none}}`;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/index.js+// node_modules/deep-view/src/react/index.jsvar DEEP_VIEW_CSS = THEME_CSS + QUESTION_CSS + WIDGET_CSS;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/core/reply.js+// node_modules/deep-view/src/core/reply.jsvar REPLY_KIND = "user-question-reply";function viewCardText(args) {let card = args;@@ -17045,7 +17045,7 @@ function memberWork(room2, work = NO_WORK) {return room2.members.map((id) => {const approvals = (work.approvals ?? []).filter((entry) => entry.botId === id);const local = here.find((entry) => entry.botId === id);- const doing = local ? { ...local, roomId: room2.id } : work.bots?.[id];+ const doing = local ? { ...local, roomId: room2.id } : void 0;return { id, approvals, doing, here: local !== void 0, state: approvals.length > 0 ? "ask" : doing ? "work" : "idle" };});}@@ -17174,11 +17174,10 @@ function ApprovalCard({ approval, bot, actions }) {));}-function MemberState({ entry, bot, room: room2, roster }) {+function MemberState({ entry, bot }) {if (entry?.state === "ask") return stateLine("bt-member-state bt-mw-ask", entry.approvals[0].at, t("Waiting for your approval"));if (entry?.state !== "work") return bot.role ? stateLine("bt-member-state", void 0, bot.role) : null;- const where = entry.doing.roomId === room2.id ? "" : entry.doing.roomId ? t("in {name}", { name: roster.roomsById[entry.doing.roomId]?.name ?? t("a group chat") }) : t("in its own chat");- return stateLine("bt-member-state", entry.doing.since, (0, import_react46.createElement)(Shimmer, null, `${workPhrase(entry.doing)}…`), where ? ` ${where}` : "");+ return stateLine("bt-member-state", entry.doing.since, (0, import_react46.createElement)(Shimmer, null, `${workPhrase(entry.doing)}…`));}function StopMemberWork({ entry, bot, room: room2, actions }) {const [stopping, setStopping] = (0, import_react46.useState)(false);diff --git a/ds-bot/office.js b/ds-bot/office.jsindex a4aab41b..ada743e1 100644--- a/ds-bot/office.js+++ b/ds-bot/office.js@@ -34,9 +34,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__gemod));-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/conventions.js+// node_modules/@xmldom/xmldom/lib/conventions.jsvar require_conventions = __commonJS({- "../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/conventions.js"(exports) {+ "node_modules/@xmldom/xmldom/lib/conventions.js"(exports) {"use strict";function find(list, predicate, ac) {if (ac === void 0) {@@ -243,9 +243,9 @@ var require_conventions = __commonJS({}});-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/errors.js+// node_modules/@xmldom/xmldom/lib/errors.jsvar require_errors = __commonJS({- "../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/errors.js"(exports) {+ "node_modules/@xmldom/xmldom/lib/errors.js"(exports) {"use strict";var conventions = require_conventions();function extendError(constructor, writableName) {@@ -402,9 +402,9 @@ var require_errors = __commonJS({}});-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/grammar.js+// node_modules/@xmldom/xmldom/lib/grammar.jsvar require_grammar = __commonJS({- "../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/grammar.js"(exports) {+ "node_modules/@xmldom/xmldom/lib/grammar.js"(exports) {"use strict";function detectUnicodeSupport(RegExpImpl) {try {@@ -609,9 +609,9 @@ var require_grammar = __commonJS({}});-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/dom.js+// node_modules/@xmldom/xmldom/lib/dom.jsvar require_dom = __commonJS({- "../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/dom.js"(exports) {+ "node_modules/@xmldom/xmldom/lib/dom.js"(exports) {"use strict";var conventions = require_conventions();var find = conventions.find;@@ -3276,9 +3276,9 @@ var require_dom = __commonJS({}});-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/entities.js+// node_modules/@xmldom/xmldom/lib/entities.jsvar require_entities = __commonJS({- "../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/entities.js"(exports) {+ "node_modules/@xmldom/xmldom/lib/entities.js"(exports) {"use strict";var freeze = require_conventions().freeze;exports.XML_ENTITIES = freeze({@@ -5419,9 +5419,9 @@ var require_entities = __commonJS({}});-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/sax.js+// node_modules/@xmldom/xmldom/lib/sax.jsvar require_sax = __commonJS({- "../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/sax.js"(exports) {+ "node_modules/@xmldom/xmldom/lib/sax.js"(exports) {"use strict";var conventions = require_conventions();var g = require_grammar();@@ -6201,9 +6201,9 @@ var require_sax = __commonJS({}});-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/dom-parser.js+// node_modules/@xmldom/xmldom/lib/dom-parser.jsvar require_dom_parser = __commonJS({- "../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/dom-parser.js"(exports) {+ "node_modules/@xmldom/xmldom/lib/dom-parser.js"(exports) {"use strict";var conventions = require_conventions();var dom = require_dom();@@ -6469,9 +6469,9 @@ var require_dom_parser = __commonJS({}});-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/index.js+// node_modules/@xmldom/xmldom/lib/index.jsvar require_lib = __commonJS({- "../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/index.js"(exports) {+ "node_modules/@xmldom/xmldom/lib/index.js"(exports) {"use strict";var conventions = require_conventions();exports.assign = conventions.assign;diff --git a/ds-bot/src/client/member-status.js b/ds-bot/src/client/member-status.jsindex 018478e2..401f2ecb 100644--- a/ds-bot/src/client/member-status.js+++ b/ds-bot/src/client/member-status.js@@ -14,13 +14,14 @@ const NO_WORK = { bots: {}, rooms: {}, approvals: [] }const FACES_MAX = 3const DOCK_EXIT_MS = 160-// Work in this group wins over the Bot's own chat or another group.+// Only work in this group counts here; work elsewhere shows on the Bot's own chat+// (its 'in {group}' capsule and sidebar group tag), not in every group it is in (#473).export function memberWork(room, work = NO_WORK) {const here = work.rooms?.[room.id] ?? []return room.members.map((id) => {const approvals = (work.approvals ?? []).filter(entry => entry.botId === id)const local = here.find(entry => entry.botId === id)- const doing = local ? { ...local, roomId: room.id } : work.bots?.[id]+ const doing = local ? { ...local, roomId: room.id } : undefinedreturn { id, approvals, doing, here: local !== undefined, state: approvals.length > 0 ? 'ask' : doing ? 'work' : 'idle' }})}@@ -149,14 +150,11 @@ function ApprovalCard({ approval, bot, actions }) {h('button', { type: 'button', className: 'bt-q-btn', onClick: () => actions.openSession(bot.id) }, t("Open {name}'s chat", { name: bot.name }))))}-// A member's second line in the group's details: what it is doing and where, or its role.-export function MemberState({ entry, bot, room, roster }) {+// A member's second line in the group's details: what it is doing here, or its role.+export function MemberState({ entry, bot }) {if (entry?.state === 'ask') return stateLine('bt-member-state bt-mw-ask', entry.approvals[0].at, t('Waiting for your approval'))if (entry?.state !== 'work') return bot.role ? stateLine('bt-member-state', undefined, bot.role) : null- const where = entry.doing.roomId === room.id ? ''- : entry.doing.roomId ? t('in {name}', { name: roster.roomsById[entry.doing.roomId]?.name ?? t('a group chat') })- : t('in its own chat')- return stateLine('bt-member-state', entry.doing.since, h(Shimmer, null, `${workPhrase(entry.doing)}…`), where ? ` ${where}` : '')+ return stateLine('bt-member-state', entry.doing.since, h(Shimmer, null, `${workPhrase(entry.doing)}…`))}// Work in this group can be stopped from its details, since the user cannot reach thediff --git a/ds-bot/src/host/turns.js b/ds-bot/src/host/turns.jsindex a4c375ec..59a34207 100644--- a/ds-bot/src/host/turns.js+++ b/ds-bot/src/host/turns.js@@ -888,5 +888,41 @@ export function install(rt) {if (entry?.turn !== undefined) entry.cut = { texts: entry.texts.length }}+ // DSH's prompt admission wraps any unexpected failure as 'session/agent-busy' and+ // keeps the real cause in details.reason, which the window never shows and the log+ // never saw (#424). For a Session this team owns, the reason is written to the+ // diagnostics and put into the error the user reads.+ const prompt = ctx.sessionController?.prompt+ if (typeof prompt === 'function') {+ const controller = ctx.sessionController+ const admitted = async function (request, ...rest) {+ try {+ return await prompt.call(this, request, ...rest)+ } catch (error) {+ const id = request?.sessionId+ if (id === undefined || (rt.roomOf(id) === undefined && !rt.isBotSession(id))) throw error+ const reason = typeof error?.details?.reason === 'string' && error.details.reason !== '' ? error.details.reason : undefined+ rt.noteFailure({+ source: 'prompt',+ text: `prompt rejected for ${placeOf(id)}${reason === undefined ? '' : `: ${reason}`}`,+ code: error?.code,+ where: placeOf(id),+ sessionId: id,+ })+ if (reason !== undefined) {+ const enriched = new Error(`${error?.message ?? 'prompt rejected'} — ${reason}`)+ enriched.code = error.code+ enriched.details = error.details+ throw enriched+ }+ throw error+ }+ }+ ctx.effect(() => {+ controller.prompt = admitted+ return () => { if (controller.prompt === admitted) controller.prompt = prompt }+ }, 'ds-bot: prompt rejection reasons')+ }+Object.assign(rt, { live, liveOf, roomWaiters, roomProgress, roomInbox, activityView, workView, roomWorkView, turnsView, steeredView, callDetail, doingOf, stopRoomTurn, releaseBot, markSteerCut, hasSubagents, stopSubagents })}diff --git a/ds-bot/test/member-status.test.js b/ds-bot/test/member-status.test.jsindex aacddd16..f0ba0e18 100644--- a/ds-bot/test/member-status.test.js+++ b/ds-bot/test/member-status.test.js@@ -39,9 +39,10 @@ const capsuleOf = (node) => {test('the members line names who waits for an approval first, then who is at work', () => {const names = { a: 'Anvil', b: 'Flint', c: 'Prism', d: 'Quill', e: 'King', f: 'Comet' }const roster = { byId: Object.fromEntries(Object.entries(names).map(([id, name]) => [id, { id, name }])) }- const room = { members: ['e', 'd', 'a', 'b', 'c', 'f'] }+ const room = { id: 'r1', members: ['e', 'd', 'a', 'b', 'c', 'f'] }const work = {bots: { d: { since: 1, tool: 'edit' }, a: { since: 1, tool: 'pwsh' }, f: { since: 1 } },+ rooms: { r1: [{ botId: 'd', since: 1, tool: 'edit' }, { botId: 'f', since: 1 }] },approvals: [{ botId: 'a' }, { botId: 'b' }, { botId: 'c' }],}const busy = busyMembers(room, work, roster)@@ -134,12 +135,13 @@ const dock = (sessionId, work) => {test('one capsule names who waits and who works, without the round\'s speaker, and opens the details', () => {const work = {- // Anvil runs in its own chat too; its work here wins.+ // Anvil runs in its own chat too; its work here wins. Coral's work in r2 shows+ // there and on its own chat, not here (#473).bots: { a: { since: 1, tool: 'pwsh' }, b: { since: 1, roomId: 'r2', tool: 'edit' } },rooms: { r1: [{ botId: 'a', since: 1, tool: 'write' }, { botId: 'd', since: 1, speaking: true }], r2: [{ botId: 'b', since: 1, tool: 'edit' }] },approvals: [{ botId: 'c', roomId: 'r1' }],}- assert.deepEqual(plain(dock('r1', work)), { label: 'Prism is waiting for your approval · Anvil · Writing changes… +1', calls: [['details', 'r1']] })+ assert.deepEqual(plain(dock('r1', work)), { label: 'Prism is waiting for your approval · Anvil · Writing changes…', calls: [['details', 'r1']] })assert.equal(dock('r1', { bots: {}, rooms: { r1: [{ botId: 'd', since: 1, speaking: true }] }, approvals: [] }), null)})@@ -165,7 +167,6 @@ test('a member\'s line runs a clock from its turn\'s start or its approval\'s',: node.props.at !== undefined ? `{${node.props.at}}` : node.children.map(flat).join(''))const stateText = entry => flat(MemberState({ entry, bot: { id: 'a', name: 'Anvil' }, room: { id: 'r1' }, roster: team }))assert.equal(stateText({ state: 'work', doing: { roomId: 'r1', tool: 'pwsh', since: 1_000 } }), 'Running shell commands…{1000}')- assert.equal(stateText({ state: 'work', doing: { roomId: 'r2', tool: 'pwsh', since: 1_000 } }), 'Running shell commands… in Docs{1000}')assert.equal(stateText({ state: 'ask', approvals: [{ at: 2_000 }] }), 'Waiting for your approval{2000}')assert.equal(flat(MemberState({ entry: { state: 'idle' }, bot: { id: 'a', name: 'Anvil', role: 'Writer' }, room: { id: 'r1' }, roster: team })), 'Writer')})diff --git a/ds-bot/test/work-dir.test.js b/ds-bot/test/work-dir.test.jsindex b4360a88..75ed8d35 100644--- a/ds-bot/test/work-dir.test.js+++ b/ds-bot/test/work-dir.test.js@@ -87,6 +87,7 @@ async function start({ services = {}, workspaces = [], llm, team: saved = TEAM,cwds.set(sessionId, options.cwd ?? registry.get(options.workspaceId)?.path)return { sessionId }},+ prompt: async () => { if (ctx.__promptError !== undefined) throw ctx.__promptError; return { accepted: true } },resolveAgent: async sessionId => ({ agent: agentOf(sessionId) }),selectModel: async () => {},page: async () => ({ records: [], hasMore: false }),@@ -607,6 +608,19 @@ test('the user moves the team workspace, and Bots without a folder of their ownassert.equal(state().bots.a.workDir, project)})+// #424: DSH's prompt admission wraps any unexpected failure as 'session/agent-busy'+// with the cause in details.reason. For a Session this team owns the reason reaches+// the user and the diagnostics log.+test('a prompt rejected with a hidden reason shows the reason and logs it', async (t) => {+ const { ctx, call, stop } = await start()+ t.after(stop)+ ctx.__promptError = Object.assign(new Error('prompt rejected'), { code: 'session/agent-busy', details: { reason: 'Error: Could not load the "sharp" module' } })+ const denied = await ctx.sessionController.prompt({ sessionId: 'r1', content: [] }).then(() => 'ok', error => `${error.message} (${error.code})`)+ assert.match(denied, /prompt rejected — Error: Could not load the "sharp" module \(session\/agent-busy\)/)+ const log = (await call('diagnostics-log', {})).value+ assert.match(log, /sharp/)+})+test('the team workspace holds no DeepSeek Harness data, apart from the plugin\'s own default', async (t) => {const { root, dsh, home, team, state, call, stop } = await start()t.after(stop)