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/473-group-member-status
Fei2411bf0b6e35d65a
diff --cc ds-bot/client.jsindex 7452491c,fd6c1720..30452392--- a/ds-bot/client.js+++ b/ds-bot/client.js@@@ -17174,13 -17449,14 +17449,13 @@@ function ApprovalCard({ approval, bot,));}-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;- return stateLine("bt-member-state", entry.doing.since, (0, import_react46.createElement)(Shimmer, null, `${workPhrase(entry.doing)}…`));- 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_react47.createElement)(Shimmer, null, `${workPhrase(entry.doing)}…`), where ? ` ${where}` : "");++ return stateLine("bt-member-state", entry.doing.since, (0, import_react47.createElement)(Shimmer, null, `${workPhrase(entry.doing)}…`));}function StopMemberWork({ entry, bot, room: room2, actions }) {- const [stopping, setStopping] = (0, import_react46.useState)(false);+ const [stopping, setStopping] = (0, import_react47.useState)(false);if (!entry?.here || entry.state !== "work" && entry.state !== "ask") return null;const stop = () => {setStopping(true);diff --cc ds-bot/src/host/turns.jsindex fdb726b2,b3b57be4..2c61cdd4--- a/ds-bot/src/host/turns.js+++ b/ds-bot/src/host/turns.js@@@ -2,8 -2,9 +2,10 @@@// triggered, the waiters and inboxes of group rounds, and routing a finished turn's reply.//// Turn tracking: which turns were triggered by another Bot, and what they said.+ import { randomUUID } from 'node:crypto'+ import { carrierKeyOf } from '@deepseek-ai/dsh-scope'import { HANDOFF_ACK, MESSAGE_INLINE_MAX, REFERENCE_KIND, REPLY_KIND, SOURCE_KIND, STEER_CUT } from './constants.js'+import { cleanText } from './diagnostics.js'import { absoluteLinks } from './links.js'import { textOf } from './text.js'import { reminderText } from './schedules.js'diff --cc ds-bot/test/work-dir.test.jsindex dac7c8c6,154e8fc7..6bdcece9--- a/ds-bot/test/work-dir.test.js+++ b/ds-bot/test/work-dir.test.js@@@ -608,47 -614,54 +615,95 @@@ test('the user moves the team workspaceassert.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 — on the same error, so the gateway still sees a+// RemoteError and passes its code and details on instead of 'gateway/internal'.+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',+ isDSHRemoteError: true,+ details: { reason: 'Error: Could not load the "sharp" module', rest: 1 },+ })+ const failure = await ctx.sessionController.prompt({ sessionId: 'r1', content: [] }).then(() => undefined, error => error)+ assert.equal(failure, ctx.__promptError)+ assert.match(failure.message, /prompt rejected — Error: Could not load the "sharp" module/)+ assert.equal(failure.code, 'session/agent-busy')+ assert.deepEqual(failure.details, { reason: 'Error: Could not load the "sharp" module', rest: 1 })+ const log = (await call('diagnostics-log', {})).value+ assert.match(log, /sharp/)+})++// #424: the hidden reason can name a local path or carry a token; what reaches the+// user is cleaned like the diagnostics, not the raw reason.+test('a rejected prompt reason reaches the user cleaned of paths and tokens', async (t) => {+ const { ctx, call, stop } = await start()+ t.after(stop)+ ctx.__promptError = Object.assign(new Error('prompt rejected'), {+ code: 'session/attachment-invalid',+ isDSHRemoteError: true,+ details: { reason: `Cannot read ${join(homedir(), 'key.pem')} or https://hook.example/in?token=t0ken123` },+ })+ const failure = await ctx.sessionController.prompt({ sessionId: 'r1', content: [] }).then(() => undefined, error => error)+ assert.equal(failure.code, 'session/attachment-invalid')+ assert.ok(!failure.message.includes('t0ken123'), failure.message)+ assert.ok(!failure.message.includes(homedir()), failure.message)+ assert.match(failure.message, /token=\[hidden\]/)+ assert.equal(failure.details.reason, `Cannot read ~${join(homedir(), 'key.pem').slice(homedir().length)} or https://hook.example/in?token=[hidden]`)+ const log = (await call('diagnostics-log', {})).value+ assert.ok(!log.includes('t0ken123'), log)+})++ // 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)