A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Wake the goal's admin when the group's work settles
Fei2411f56aba6f81bf
diff --git a/ds-bot/client.js b/ds-bot/client.jsindex 9c65597f..56548417 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -4930,7 +4930,7 @@ var HANDOFF_CSS = `.bt-handoff .bt-q-foot{flex-wrap:wrap}`;-// node_modules/deep-view/src/react/ui.js+// ../../dsb-group-goal/ds-bot/node_modules/deep-view/src/react/ui.jsvar import_react10 = require("react");var FallbackMarkdown = ({ text }) => (0, import_react10.createElement)("span", null, String(text ?? ""));var ViewUi = (0, import_react10.createContext)({ t: (key) => key, Markdown: FallbackMarkdown });@@ -4997,7 +4997,7 @@ function useOptionKeys2(count, onPick, ownRef) {return count > 0 && listening <= 1;}-// node_modules/deep-view/src/core/formula.js+// ../../dsb-group-goal/ds-bot/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)) },@@ -5278,7 +5278,7 @@ function evaluate(tree, lookup) {}}-// node_modules/deep-view/src/core/views.js+// ../../dsb-group-goal/ds-bot/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"];@@ -5898,7 +5898,7 @@ function validateForm(node, values) {return { fields };}-// node_modules/deep-view/src/react/chart.js+// ../../dsb-group-goal/ds-bot/node_modules/deep-view/src/react/chart.jsvar import_react11 = 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];@@ -6337,7 +6337,7 @@ var CHART_CSS = `@media (prefers-reduced-motion:reduce){.dv-chart-mark,.dv-chart-dot{transition:none}.dv-chart-tip{animation:none}}`;-// node_modules/deep-view/src/react/frame.js+// ../../dsb-group-goal/ds-bot/node_modules/deep-view/src/react/frame.jsvar import_react12 = require("react");var THEME_VARS = [["--view-ink", "--bt-ink", "--dv-ink"],@@ -6419,7 +6419,7 @@ var HTML_CSS = `.dv-view-frame-stopped{margin:0;font-size:13px;line-height:18px;color:var(--dv-ink-2)}`;-// node_modules/deep-view/src/react/card.js+// ../../dsb-group-goal/ds-bot/node_modules/deep-view/src/react/card.jsvar import_react13 = require("react");var mdLabels = (ui2) => ({ code: { copyLabel: ui2.t("Copy"), copiedLabel: ui2.t("Copied") }, footnotes: ui2.t("Footnotes") });var TONES2 = ["good", "warn", "bad"];@@ -7088,7 +7088,7 @@ ${CHART_CSS}${HTML_CSS}`;-// node_modules/deep-view/src/react/styles.js+// ../../dsb-group-goal/ds-bot/node_modules/deep-view/src/react/styles.jsvar THEME_CSS = `body{--dv-ink:var(--dsw-alias-label-primary);@@ -7185,10 +7185,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}}`;-// node_modules/deep-view/src/react/index.js+// ../../dsb-group-goal/ds-bot/node_modules/deep-view/src/react/index.jsvar DEEP_VIEW_CSS = THEME_CSS + QUESTION_CSS + WIDGET_CSS;-// node_modules/deep-view/src/core/reply.js+// ../../dsb-group-goal/ds-bot/node_modules/deep-view/src/core/reply.jsvar REPLY_KIND = "user-question-reply";function viewCardText(args) {let card = args;diff --git a/ds-bot/office.js b/ds-bot/office.jsindex ada743e1..139b9a73 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));-// node_modules/@xmldom/xmldom/lib/conventions.js+// ../../dsb-group-goal/ds-bot/node_modules/@xmldom/xmldom/lib/conventions.jsvar require_conventions = __commonJS({- "node_modules/@xmldom/xmldom/lib/conventions.js"(exports) {+ "../../dsb-group-goal/ds-bot/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({}});-// node_modules/@xmldom/xmldom/lib/errors.js+// ../../dsb-group-goal/ds-bot/node_modules/@xmldom/xmldom/lib/errors.jsvar require_errors = __commonJS({- "node_modules/@xmldom/xmldom/lib/errors.js"(exports) {+ "../../dsb-group-goal/ds-bot/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({}});-// node_modules/@xmldom/xmldom/lib/grammar.js+// ../../dsb-group-goal/ds-bot/node_modules/@xmldom/xmldom/lib/grammar.jsvar require_grammar = __commonJS({- "node_modules/@xmldom/xmldom/lib/grammar.js"(exports) {+ "../../dsb-group-goal/ds-bot/node_modules/@xmldom/xmldom/lib/grammar.js"(exports) {"use strict";function detectUnicodeSupport(RegExpImpl) {try {@@ -609,9 +609,9 @@ var require_grammar = __commonJS({}});-// node_modules/@xmldom/xmldom/lib/dom.js+// ../../dsb-group-goal/ds-bot/node_modules/@xmldom/xmldom/lib/dom.jsvar require_dom = __commonJS({- "node_modules/@xmldom/xmldom/lib/dom.js"(exports) {+ "../../dsb-group-goal/ds-bot/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({}});-// node_modules/@xmldom/xmldom/lib/entities.js+// ../../dsb-group-goal/ds-bot/node_modules/@xmldom/xmldom/lib/entities.jsvar require_entities = __commonJS({- "node_modules/@xmldom/xmldom/lib/entities.js"(exports) {+ "../../dsb-group-goal/ds-bot/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({}});-// node_modules/@xmldom/xmldom/lib/sax.js+// ../../dsb-group-goal/ds-bot/node_modules/@xmldom/xmldom/lib/sax.jsvar require_sax = __commonJS({- "node_modules/@xmldom/xmldom/lib/sax.js"(exports) {+ "../../dsb-group-goal/ds-bot/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({}});-// node_modules/@xmldom/xmldom/lib/dom-parser.js+// ../../dsb-group-goal/ds-bot/node_modules/@xmldom/xmldom/lib/dom-parser.jsvar require_dom_parser = __commonJS({- "node_modules/@xmldom/xmldom/lib/dom-parser.js"(exports) {+ "../../dsb-group-goal/ds-bot/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({}});-// node_modules/@xmldom/xmldom/lib/index.js+// ../../dsb-group-goal/ds-bot/node_modules/@xmldom/xmldom/lib/index.jsvar require_lib = __commonJS({- "node_modules/@xmldom/xmldom/lib/index.js"(exports) {+ "../../dsb-group-goal/ds-bot/node_modules/@xmldom/xmldom/lib/index.js"(exports) {"use strict";var conventions = require_conventions();exports.assign = conventions.assign;diff --git a/ds-bot/src/host/goals.js b/ds-bot/src/host/goals.jsindex 2316f226..85cbcd50 100644--- a/ds-bot/src/host/goals.js+++ b/ds-bot/src/host/goals.js@@ -627,6 +627,20 @@ export function install(rt) {await queueGoalRelay(room, 'nudge', '[Goal check]', 'DS Bot')}+ // Member work can outlive the round it grew out of; the round-end check then+ // skips the room, and nothing else would wake the admin when the last of it+ // settles. Settle — no round running, nobody working, no call batch, an+ // empty inbox — runs the same check once: the fake round's one worked slot+ // only says progress happened (the work that just ended), so the check gets+ // a fresh budget.+ const SETTLE_ROUND = Object.freeze({ stoppedOnly: false, slots: Object.freeze([{ id: '', worked: true }]) })++ async function goalSettled(room) {+ if (room === undefined) return+ if ([...rt.roomProgress.values()].some(round => round.roomId === room.id)) return+ await goalDrive(room, SETTLE_ROUND)+ }+// The user pressed stop in the group: the goal waits for them instead of// waking the admin through the stop-notice round.const goalUserStopped = (roomId) => {@@ -790,7 +804,7 @@ export function install(rt) {}))Object.assign(rt, {- goalBlock, goalLedger, goalDraft, goalControl, goalDrive, goalUserMessage, goalUserStopped,+ goalBlock, goalLedger, goalDraft, goalControl, goalDrive, goalSettled, goalUserMessage, goalUserStopped,goalTaskWorking: (roomId, botId) => mark(roomId, botId, 'pending', 'working'),goalTaskReported: (roomId, botId) => mark(roomId, botId, 'working', 'reported'),goalTaskReset: (roomId, botId, note) => mark(roomId, botId, 'working', 'pending', note),diff --git a/ds-bot/src/host/groups.js b/ds-bot/src/host/groups.jsindex f61e102b..498f0433 100644--- a/ds-bot/src/host/groups.js+++ b/ds-bot/src/host/groups.js@@ -442,7 +442,10 @@ export function install(rt) {memberBatch.delete(mKey)batch.pending.delete(botId)pruneBatchPending(room, batch)- if (batch.pending.size === 0) roomBatches.delete(batch.key)+ if (batch.pending.size === 0) {+ roomBatches.delete(batch.key)+ void rt.goalSettled?.(room).catch(error => rt.warn('ds-bot: goal settle in %s failed: %s', room.name, error))+ }return batch}diff --git a/ds-bot/src/host/turns.js b/ds-bot/src/host/turns.jsindex 69d234fb..78619e80 100644--- a/ds-bot/src/host/turns.js+++ b/ds-bot/src/host/turns.js@@ -528,6 +528,7 @@ export function install(rt) {})ctx.on?.('subagent/end', (info) => {noteSubagentEnd(info?.id)+ if (rt.groupOwners.has(info?.id)) void rt.goalSettled?.(rt.roomOf(rt.groupOwners.get(info.id).roomId)).catch(error => rt.warn('ds-bot: goal settle failed: %s', error))})ctx.on('session/event', (session, event) => {@@ -622,7 +623,10 @@ export function install(rt) {case 'user/message': {const source = event.data?.sourceif (source?.kind === 'subagent-settled' || source?.kind === 'agent-message') {- if (typeof source.senderSessionId === 'string') noteSubagentEnd(source.senderSessionId)+ if (typeof source.senderSessionId === 'string') {+ noteSubagentEnd(source.senderSessionId)+ if (rt.groupOwners.has(id)) void rt.goalSettled?.(rt.roomOf(rt.groupOwners.get(id).roomId)).catch(error => rt.warn('ds-bot: goal settle failed: %s', error))+ }if (stoppedSubagentParents.has(id) || (typeof source.senderSessionId === 'string' && stoppedSubagents.has(source.senderSessionId))) {entry.suppressedSubagent = truevoid rt.resolveAgent(id).then(agent => agent?.cancel({ kind: 'hook', reason: 'ds-bot/stopped' })).catch(() => {})@@ -956,6 +960,7 @@ export function install(rt) {deferred: true,}).catch(error => rt.warn('ds-bot: deferred request delivery failed: %s', error))}+ if (rt.groupOwners.has(id)) void rt.goalSettled?.(rt.roomOf(rt.groupOwners.get(id).roomId)).catch(error => rt.warn('ds-bot: goal settle in %s failed: %s', id, error))break}}diff --git a/ds-bot/test/group-goal.test.js b/ds-bot/test/group-goal.test.jsindex 251c7f63..00e034ef 100644--- a/ds-bot/test/group-goal.test.js+++ b/ds-bot/test/group-goal.test.js@@ -112,7 +112,7 @@ async function start(t, room, services, extraRooms) {return { content: post.content, source: post.source }}await tool('list_bots', {}, 'a')- return { home, ctx, agentOf, emit, tool, call, begin, finish, round, say, takePost, takeGoal }+ return { home, ctx, rt, agentOf, emit, tool, call, begin, finish, round, say, takePost, takeGoal }}const settle = async (check) => {@@ -670,3 +670,31 @@ test('a room on its second part relays on the current Session and blocks /goal tassert.equal(blocked[0].sessionId, 'r1p2')assert.equal(blocked[0].reason.message, 'Bot chats do not run /goal. To give a group a goal, use Set a goal in its + menu.')})++test('a member still working at round end wakes the admin when its work settles', async (t) => {+ const host = await start(t)+ await startGoal(host)+ // Member c's group turn is still running when the round ends — no check is queued.+ host.emit('gc', 'turn/start', { turn: 1 })+ const first = host.round('c1', host.say('@Chief go'))+ await settle(() => host.agentOf('ga').calls.length === 1)+ host.begin('ga')+ host.finish('ga', 'on it')+ await settle(() => first() !== undefined)+ assert.equal(host.takeGoal(), undefined)+ // The round is fully gone before c's work ends; the settle check then queues one goal check.+ await settle(async () => (await host.call('room-progress', { roomId: 'r1' })).value?.length === 0)+ host.emit('gc', 'assistant/message', { message: { content: [{ type: 'text', text: 'done' }] } })+ host.emit('gc', 'turn/end', { turn: 1, reason: { kind: 'completed' } })+ await settle(() => host.agentOf('r1').calls.some(call => call.source?.role === 'goal'))+ const nudge = host.takeGoal()+ assert.ok(nudge !== undefined)+ assert.match(text(nudge), /^\[Goal check\]$/)+ // A second settle with no new work queues nothing while a round is running.+ host.emit('gc', 'turn/start', { turn: 2 })+ host.emit('gc', 'turn/end', { turn: 2, reason: { kind: 'completed' } })+ await settle(async () => (await host.call('room-progress', { roomId: 'r1' })).value?.length === 0)+ const left = host.agentOf('r1').calls.filter(call => call.source?.role === 'goal')+ assert.ok(left.length <= 1, `settles queued ${left.length} extra checks`)+ assert.equal(host.takeGoal(), undefined)+})