Skip to content

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

Merge remote-tracking branch 'origin/feat/group-chat-engine' into fix/710-group-folder

Fei24118be355c3389a
diff --cc ds-bot/client.js
index 635817ca,fd6c1720..c8ec27b6
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@@ -8630,16 -8742,13 +8742,16 @@@ function GroupReplies({ sessionId, call
)
);
}
+ if (reply.kind === "folder") {
- return (0, import_react16.createElement)("div", { key: `folder-${index}`, className: "bt-event" }, reply.text);
++ return (0, import_react17.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 }));
+ return (0, import_react17.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_react16.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("{name} finished its work", { name: bot.name }));
+ return (0, import_react17.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("{name} finished its work", { name: bot.name }));
}
- return (0, import_react16.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_react17.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, at) => {
const bot = roster.byId[id];
diff --cc ds-bot/test/work-dir.test.js
index 2e793794,154e8fc7..c54d8544
--- a/ds-bot/test/work-dir.test.js
+++ b/ds-bot/test/work-dir.test.js
@@@ -607,96 -614,54 +614,144 @@@ test('the user moves the team workspace
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: the group's own Session sits in the team workspace; when that folder itself is
+// deleted it is made again, as for any other Session.
+test("a group chat's own Session makes a deleted team workspace again", async (t) => {
+ const { sets, service } = folderService()
+ const { ctx, agentOf, team, stop } = await start({ services: { workingDirectory: service } })
+ t.after(stop)
+ rmSync(team, { recursive: true, force: true })
+ assert.equal(await assemble(ctx, agentOf('r1')), true)
+ assert.equal(existsSync(team), true)
+ assert.deepEqual(sets, [])
+})
+
+// #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 member still in the team workspace when the group's folder went away needs
+// no correction, but the group is still told once.
+test("a member that never reached the group's folder still brings the one-time notice", async (t) => {
+ const { sets, service } = folderService()
+ const { ctx, call, agentOf, project, state, stop } = await start({ services: { workingDirectory: service } })
+ t.after(stop)
+ assert.equal((await call('update-room', { id: 'r1', workDir: project })).ok, true)
+ rmSync(project, { recursive: true, force: true })
+ // 'gb' was made in the team workspace and never moved to the group's folder.
+ assert.equal(await assemble(ctx, agentOf('gb')), true)
+ assert.deepEqual(sets, [])
+ 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)
+})
+
+// #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 ?? '', '')
+})
+
+ // The handoff note takes a while; the move waits in `runMaintenance` until the test releases it.
+ const holdMove = (agent) => {
+ const run = agent.runMaintenance
+ let release
+ const held = new Promise(resolve => { release = resolve })
+ agent.runMaintenance = async (job) => { await held; return run.call(agent, job) }
+ return release
+ }
+
+ test('a folder move that a first message starts is flagged in the work view until the part moves on', async (t) => {
+ const { root, agentOf, call, state, preStep, stop } = await start()
+ t.after(stop)
+ const moved = join(root, 'moved')
+ await call('team-workspace', { path: moved })
+ const release = holdMove(agentOf('b'))
+ const input = { id: 'm1', role: 'user', content: [{ type: 'text', text: 'Hello again' }], source: { kind: 'user' } }
+ assert.deepEqual(await preStep('b', [input]), { kind: 'enter', messages: [] })
+ const work = (await call('state', {})).value.work.bots.b
+ assert.deepEqual([work.switching, work.folder], [true, true])
+ release()
+ await until(() => state().bots.b.sessionId === 's1')
+ await until(() => agentOf('s1').calls.length >= 2)
+ assert.deepEqual(agentOf('s1').calls.map(([kind, message]) => [kind, message.source.role ?? textOf(message)]), [['followup', 'handoff'], ['followup', 'Hello again']])
+ })
+
+ test('input that arrives while a switch runs ends its turn as completed and goes on to the new part', async (t) => {
+ const { root, agentOf, call, state, preStep, stop } = await start()
+ t.after(stop)
+ await call('team-workspace', { path: join(root, 'moved') })
+ const release = holdMove(agentOf('b'))
+ const said = text => ({ role: 'user', content: [{ type: 'text', text }], source: { kind: 'user' } })
+ assert.deepEqual(await preStep('b', [said('Hello again')]), { kind: 'enter', messages: [] })
+ assert.deepEqual(await preStep('b', [said('and one more')]), { kind: 'enter', messages: [] })
+ release()
+ await until(() => state().bots.b.sessionId === 's1')
+ await until(() => agentOf('s1').calls.length >= 3)
+ assert.deepEqual(agentOf('s1').calls.map(([kind, message]) => [kind, message.source.role ?? textOf(message)]), [['followup', 'handoff'], ['followup', 'Hello again'], ['followup', 'and one more']])
+ })
+
+ test('a switch that starts mid-turn still rejects its step, the only way DSH ends a step there', async (t) => {
+ const { root, state, call, preStep, stop } = await start()
+ t.after(stop)
+ await call('team-workspace', { path: join(root, 'moved') })
+ const input = { id: 'm1', role: 'user', content: [{ type: 'text', text: 'Hello again' }], source: { kind: 'user' } }
+ assert.deepEqual(await preStep('b', [input], 2), { kind: 'reject' })
+ await until(() => state().bots.b.sessionId === 's1')
+ })
+
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)