Skip to content

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

Follow the team workspace in the group relay Session, refuse oversized notices, join registered workspaces

Fei24114e77eb43cab7
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 57d20937..635817ca 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.js
var 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.js
var 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.js
var 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.js
var 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.js
var 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.js
var 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.js
var 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.js
var 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.js
var REPLY_KIND = "user-question-reply";
function viewCardText(args) {
let card = args;
@@ -8630,6 +8630,9 @@ function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi
)
);
}
+ if (reply.kind === "folder") {
+ return (0, import_react16.createElement)("div", { key: `folder-${index}`, className: "bt-event" }, reply.text);
+ }
if (reply.kind === "stopped") {
return (0, import_react16.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("You stopped {name}'s work", { name: bot.name }));
}
diff --git a/ds-bot/office.js b/ds-bot/office.js
index 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(__ge
mod
));
-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/conventions.js
+// node_modules/@xmldom/xmldom/lib/conventions.js
var 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.js
var 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.js
var 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.js
var 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.js
var 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.js
var 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.js
var 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.js
var 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/cells.js b/ds-bot/src/client/cells.js
index 834e30d2..95c3b950 100644
--- a/ds-bot/src/client/cells.js
+++ b/ds-bot/src/client/cells.js
@@ -946,6 +946,9 @@ function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi
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', { key: `folder-${index}`, className: 'bt-event' }, reply.text)
+ }
if (reply.kind === 'stopped') {
return h('div', { key: `${reply.botId}-${index}`, className: 'bt-event' }, t("You stopped {name}'s work", { name: bot.name }))
}
diff --git a/ds-bot/src/host/groups.js b/ds-bot/src/host/groups.js
index ab8364d8..9821adda 100644
--- a/ds-bot/src/host/groups.js
+++ b/ds-bot/src/host/groups.js
@@ -76,6 +76,7 @@ const noticeText = (line) => {
if (line.reason === 'missed') return `${(line.names ?? []).join(' and ')} did not answer within ${line.minutes} minutes, so this round moved on without it. If it is still working, it posts its result later as a late reply; if it is urgent, the user can write here or the admin can follow up.`
if (line.reason === 'paused') return `Paused: Bots have called each other ${line.limit} times since the user last wrote here. The calls to @${(line.names ?? []).join(' and @')} wait until the user continues or writes here; do not call them again.`
if (line.reason === 'admin-passed') return `${(line.names ?? []).join(' and ') || 'The admin'} did not answer or call anyone; call a member with @Name.`
+ if (line.reason === 'folder') return `The group's folder ${line.path} is gone, so its members work in the team workspace; set the group's folder again in the group's settings.`
return line.text ?? ''
}
// `text` is what to show of a message line, by default what the log keeps of it.
@@ -206,6 +207,23 @@ export function install(rt) {
}
Object.assign(rt, { keepGroupLine, dropGroupLines })
+ // The folder a group was set to work in is gone: its members' Sessions move on in
+ // the team workspace (parts.js), and the group is told once per folder, so a later
+ // round does not say it again. Changing the folder clears the mark (updateRoom).
+ async function roomFolderNotice(roomId, folder) {
+ const room = rt.roomOf(roomId)
+ if (room === undefined || folder === undefined || room.workDir !== folder || room.folderNotice === folder) return
+ ensureRoomLog(room)
+ room.folderNotice = folder
+ appendRoom(room, { who: 'DS Bot', kind: 'notice', reason: 'folder', path: folder })
+ const text = noticeText({ reason: 'folder', path: folder })
+ for (const round of rt.roomProgress.values()) {
+ if (round.roomId === room.id) round.replies.push({ kind: 'folder', text, time: Date.now() })
+ }
+ await rt.save()
+ }
+ rt.roomFolderNotice = roomFolderNotice
+
// A member's group Session, created on its first turn there. A new one starts with
// a fresh look at the log and a brief of the member's own chat; the brief is the
// first message, so it stays fixed and the prefix stays cacheable.
diff --git a/ds-bot/src/host/parts.js b/ds-bot/src/host/parts.js
index ca25a9d4..00742018 100644
--- a/ds-bot/src/host/parts.js
+++ b/ds-bot/src/host/parts.js
@@ -1082,13 +1082,29 @@ export function install(rt) {
const folders = ctx.get?.('workingDirectory')
if (agent === undefined || typeof folders?.get !== 'function' || readOnly()) return next()
const current = folders.get(agent.session)
- if (current === undefined || await rt.isFolder(current)) return next()
+ if (current === undefined) return next()
await rt.load()
+ // A group's own Session only relays, so it stays in the team workspace. It has no
+ // fresh part to move to, so a stale or gone folder is corrected in place; without
+ // this every round failed with 'directory does not exist' (#710).
+ if (rt.roomOf(agent.id) !== undefined) {
+ if (current === rt.teamFolder()) return next()
+ const team = await rt.keepTeamFolder()
+ if (team === undefined) return next()
+ await folders.set(agent, team, context.signal)
+ .catch(error => rt.warn('ds-bot: the group chat works in %s and could not change to %s: %s', current, team, error))
+ return next()
+ }
+ if (await rt.isFolder(current)) return next()
const team = await rt.keepTeamFolder()
if (current === team || !rt.isBotSession(agent.id)) return next()
const place = placeOf(agent.id)
const wanted = rt.workDirOf(place)
- const target = wanted !== undefined && await rt.isFolder(wanted) ? wanted : team
+ const usable = wanted !== undefined && await rt.isFolder(wanted)
+ // A member whose group's folder went away works on in the team workspace; the
+ // group is told once, so every round is not told again.
+ if (!usable) await rt.roomFolderNotice?.(place?.roomId, wanted)
+ const target = usable ? wanted : team
if (target !== undefined) {
await folders.set(agent, target, context.signal)
.catch(error => rt.warn('ds-bot: %s works in %s, which is gone, and could not change to %s: %s', rt.botOf(place?.botId)?.name ?? agent.id, current, target, error))
diff --git a/ds-bot/src/host/roster.js b/ds-bot/src/host/roster.js
index a7b33e4e..3a3ed70c 100644
--- a/ds-bot/src/host/roster.js
+++ b/ds-bot/src/host/roster.js
@@ -75,7 +75,8 @@ export function install(rt) {
}
// `dir` is a working folder outside the team workspace. Such a Session is made by cwd
- // alone, so it joins no DSH workspace and the user's own project lists stay as they are.
+ // alone, so it joins no DSH workspace and the user's own project lists stay as they are —
+ // unless the folder is already registered as a workspace, which it then joins (#710).
async function createSession(title, { dir } = {}) {
// A Bot's tools run here too; while another dsh holds the team, a new Session would
// belong to no saved Bot.
@@ -83,7 +84,8 @@ export function install(rt) {
if (readOnly !== undefined) throw new Error(readOnly)
const usable = dir !== undefined && await rt.isFolder(dir)
if (dir !== undefined && !usable) rt.warn('ds-bot: the working folder %s is gone; %s starts in the team workspace', dir, title)
- const place = usable ? { cwd: dir } : { workspaceId: await ensureWorkspace() }
+ const known = usable ? await ctx.workspaceRegistry.resolveByPath(dir) : undefined
+ const place = known !== undefined ? { workspaceId: known.id } : usable ? { cwd: dir } : { workspaceId: await ensureWorkspace() }
const { sessionId } = await ctx.sessionController.create({ ...place, ...await botPreset() })
const agent = await rt.resolveAgent(sessionId)
await ctx.sessionTitle.rename(agent.session, title)
@@ -377,7 +379,12 @@ export function install(rt) {
const roomBusy = id => [...rt.roomProgress.values()].some(round => round.roomId === id)
const autoRoomName = members => ['You', ...members.map(id => rt.botOf(id)?.name).filter(Boolean)].join(', ')
- const cleanNotice = text => String(text ?? '').trim().slice(0, ROOM_NOTICE_MAX)
+ // A notice past the limit is refused rather than silently cut (#710).
+ const cleanNotice = (text) => {
+ const notice = String(text ?? '').trim()
+ if (notice.length > ROOM_NOTICE_MAX) throw new Error(`A group's notice can hold at most ${ROOM_NOTICE_MAX} characters; this one has ${notice.length}`)
+ return notice
+ }
function cleanRoomName(text, selfId) {
const next = unquote(text).replace(/\s+/g, ' ').slice(0, ROOM_NAME_MAX)
@@ -537,6 +544,7 @@ export function install(rt) {
}
// Members' group conversations move on to the folder at their next turn there.
if (moving && workDir !== room.workDir) {
+ delete room.folderNotice
if (workDir === undefined) delete room.workDir
else room.workDir = workDir
changes.push(workDir ? `every member now works in ${workDir} here` : 'every member works in its own folder again')
diff --git a/ds-bot/src/host/tools.js b/ds-bot/src/host/tools.js
index c8a3a7e9..bebcb82e 100644
--- a/ds-bot/src/host/tools.js
+++ b/ds-bot/src/host/tools.js
@@ -453,7 +453,7 @@ export function install(rt) {
parameters: {
members: { type: 'array', required: true, items: { type: 'string' }, description: 'Exact names of the other Bots to add; you are added automatically' },
name: { type: 'string', description: 'Group name; defaults to the member names' },
- notice: { type: 'string', description: 'Shared instructions every member reads before speaking in this group' },
+ notice: { type: 'string', description: 'Shared instructions every member reads before speaking in this group; at most 2000 characters' },
admin: { type: 'string', description: 'Member who leads the group; defaults to you' },
mode: MODE_PARAM,
},
@@ -482,7 +482,7 @@ export function install(rt) {
parameters: {
group: GROUP_REF,
name: { type: 'string', description: 'New group name; an empty string names it after its members again' },
- notice: { type: 'string', description: 'Replacement notice, the shared instructions every member reads; an empty string clears it' },
+ notice: { type: 'string', description: 'Replacement notice, the shared instructions every member reads; an empty string clears it; at most 2000 characters' },
add_members: { type: 'array', items: { type: 'string' }, description: 'Exact names of Bots to add' },
remove_members: { type: 'array', items: { type: 'string' }, description: 'Exact names of Bots to remove' },
admin: { type: 'string', description: 'Member to make the admin; "none" leaves the group without one (Main Bots only)' },
diff --git a/ds-bot/test/work-dir.test.js b/ds-bot/test/work-dir.test.js
index b4360a88..96dce517 100644
--- a/ds-bot/test/work-dir.test.js
+++ b/ds-bot/test/work-dir.test.js
@@ -607,6 +607,66 @@ test('the user moves the team workspace, and Bots without a folder of their own
assert.equal(state().bots.a.workDir, project)
})
+// #710: the group's own Session only relays and has no fresh part to move to; it
+// follows the team workspace in place, so a moved and deleted workspace no longer
+// fails every round.
+test("a group chat's own Session follows the team workspace it was made in", async (t) => {
+ const { sets, service } = folderService()
+ const { ctx, root, call, agentOf, team, stop } = await start({ services: { workingDirectory: service } })
+ t.after(stop)
+ const moved = join(root, 'moved')
+ assert.deepEqual((await call('team-workspace', { path: moved })).value, { team: moved })
+ rmSync(team, { recursive: true, force: true })
+ assert.equal(await assemble(ctx, agentOf('r1')), true)
+ assert.deepEqual(sets, [['r1', moved]])
+ // Already in the current team workspace: nothing changes.
+ assert.equal(await assemble(ctx, agentOf('r1')), true)
+ assert.deepEqual(sets, [['r1', moved]])
+})
+
+// #710: a member whose group's folder went away works on in the team workspace, and
+// the group is told once, not on every round.
+test('a group whose folder is gone works on in the team workspace and is told once', async (t) => {
+ const { sets, service } = folderService()
+ const { ctx, call, agentOf, team, project, state, stop } = await start({ services: { workingDirectory: service } })
+ t.after(stop)
+ assert.equal((await call('update-room', { id: 'r1', workDir: project })).ok, true)
+ agentOf('gb').session.header.cwd = project
+ rmSync(project, { recursive: true, force: true })
+ assert.equal(await assemble(ctx, agentOf('gb')), true)
+ assert.deepEqual(sets, [['gb', team]])
+ const notice = () => (state().rooms.r1.log ?? []).filter(line => line.kind === 'notice' && line.reason === 'folder')
+ assert.equal(notice().length, 1)
+ assert.equal(notice()[0].path, project)
+ assert.equal(await assemble(ctx, agentOf('gb')), true)
+ assert.equal(notice().length, 1)
+ // Clearing or setting the folder clears the mark.
+ assert.equal((await call('update-room', { id: 'r1', workDir: '' })).ok, true)
+ assert.equal(state().rooms.r1.folderNotice, undefined)
+})
+
+// #710: a Session made for a folder that is registered as a workspace joins it, so it
+// does not stay ungrouped.
+test('a Bot whose working folder is a registered workspace joins it', async (t) => {
+ const { ctx, call, project, state, created, stop } = await start()
+ t.after(stop)
+ await ctx.workspaceRegistry.create(project)
+ assert.equal((await call('update-bot', { id: 'b', workDir: project })).ok, true)
+ await until(() => state().bots.b.sessionId === 's1')
+ assert.deepEqual(created.at(-1), { workspaceId: 'w-new' })
+})
+
+// #710: a notice past the limit is refused, not silently cut.
+test('a group notice past the limit is refused, not cut', async (t) => {
+ const { call, tool, state, stop } = await start()
+ t.after(stop)
+ const long = 'x'.repeat(2001)
+ assert.match((await call('update-room', { id: 'r1', notice: long })).error?.message, /at most 2000 characters/)
+ assert.match(await tool('update_group', { group: 'r1', notice: long }, 'a'), /at most 2000 characters/)
+ assert.match(await tool('create_group', { members: ['Writer'], notice: long }, 'a'), /at most 2000 characters/)
+ assert.equal(state().rooms.r1.notice ?? '', '')
+})
+
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)