Skip to content

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

Let the desktop app name the team folder, and move a copied team there

Fei2411004e897f9907
diff --git a/ds-bot/src/host/parts.js b/ds-bot/src/host/parts.js
index 04dcc6fa..e31fb7bc 100644
--- a/ds-bot/src/host/parts.js
+++ b/ds-bot/src/host/parts.js
@@ -1002,7 +1002,11 @@ export function install(rt) {
const cwd = agent.session.header?.cwd
if (place === undefined || cwd === undefined || (midTurn && place.roomId !== undefined) || Date.now() < (folderRetry.get(agent.id) ?? 0)) return undefined
const wanted = rt.workDirOf(place)
- const target = wanted !== undefined && await rt.isFolder(wanted) ? wanted : rt.teamFolder()
+ const usable = wanted !== undefined && await rt.isFolder(wanted)
+ // A team copied from another DSH_HOME has no team workspace here until one is made, and its
+ // Sessions still work in the old one.
+ if (!usable && rt.teamFolder() === undefined) await rt.ensureWorkspace()
+ const target = usable ? wanted : rt.teamFolder()
return target === undefined || target === cwd ? undefined : target
}
diff --git a/ds-bot/src/host/roster.js b/ds-bot/src/host/roster.js
index 1f1e69f0..65929010 100644
--- a/ds-bot/src/host/roster.js
+++ b/ds-bot/src/host/roster.js
@@ -23,7 +23,8 @@ export function install(rt) {
await keepTeamFolder()
return state.workspaceId
}
- const path = config.workspace ?? join(home, 'workspace')
+ // The desktop app names the folder the user chose for the Bots' files.
+ const path = config.workspace ?? (process.env.DS_BOT_WORKSPACE?.trim() || join(home, 'workspace'))
await mkdir(path, { recursive: true })
const workspace = await ctx.workspaceRegistry.resolveByPath(path) ?? await ctx.workspaceRegistry.create(path, 'DS Bot')
state.workspaceId = workspace.id
diff --git a/ds-bot/test/work-dir.test.js b/ds-bot/test/work-dir.test.js
index 9b960624..ecd34ba6 100644
--- a/ds-bot/test/work-dir.test.js
+++ b/ds-bot/test/work-dir.test.js
@@ -71,7 +71,11 @@ async function start({ services = {}, workspaces = [], llm, team: saved = TEAM }
get: id => registry.get(id),
list: () => [...registry.values()],
resolveByPath: async path => [...registry.values()].find(workspace => workspace.path === path),
- create: async path => ({ id: 'w-new', path }),
+ create: async (path) => {
+ const workspace = { id: 'w-new', path, title: 'DS Bot' }
+ registry.set(workspace.id, workspace)
+ return workspace
+ },
archiveSession: async () => {},
},
sessionController: {
@@ -544,6 +548,29 @@ test('a Bot whose folder is gone changes to the team folder before DSH checks it
assert.equal(sets.length, 1)
})
+test('a team copied from another DSH_HOME moves on to a fresh part in the folder the app names at its first turn', async (t) => {
+ const copied = { ...TEAM }
+ delete copied.workspaceId
+ const previous = process.env.DS_BOT_WORKSPACE
+ const root = realpathSync.native(mkdtempSync(join(tmpdir(), 'ds-bot-app-workspace-')))
+ process.env.DS_BOT_WORKSPACE = root
+ const { agentOf, created, state, preStep, stop } = await start({ team: copied })
+ t.after(() => {
+ stop()
+ if (previous === undefined) delete process.env.DS_BOT_WORKSPACE
+ else process.env.DS_BOT_WORKSPACE = previous
+ rmSync(root, { recursive: true, force: true })
+ })
+ const input = { id: 'm1', role: 'user', content: [{ type: 'text', text: 'Hello again' }], source: { kind: 'user' } }
+ assert.deepEqual(await preStep('b', [input]), { kind: 'reject' })
+ await until(() => state().bots.b.sessionId === 's1')
+ assert.equal(state().workspaceId, 'w-new')
+ assert.deepEqual(created, [{ workspaceId: 'w-new' }])
+ assert.equal(agentOf('s1').session.header.cwd, root)
+ 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('a team folder that was deleted is made again before DSH checks it', async (t) => {
const { sets, service } = folderService()
const { ctx, agentOf, team, stop } = await start({ services: { workingDirectory: service } })