Skip to content

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

Compare folders with the team workspace as real paths

Fei2411dcaab9bc8943
diff --git a/ds-bot/src/host/folders.js b/ds-bot/src/host/folders.js
index f908acaf..78fb1f5d 100644
--- a/ds-bot/src/host/folders.js
+++ b/ds-bot/src/host/folders.js
@@ -24,6 +24,11 @@ export function install(rt) {
const workDirOf = ({ botId, roomId } = {}) => rt.roomOf(roomId)?.workDir ?? rt.botOf(botId)?.workDir
const isFolder = path => stat(path).then(info => info.isDirectory(), () => false)
const real = path => realpath(path).catch(() => resolve(path))
+ // The registry keeps the team workspace as it was given; folders compare as real paths.
+ const realTeam = async () => {
+ const team = teamFolder()
+ return team === undefined ? undefined : real(team)
+ }
// Where `input` leads from `base`, as a real path, the way DSH's working_directory resolves
// a change; undefined when nothing is there.
const folderAt = (base, input) => realpath(resolve(base, input)).catch(() => undefined)
@@ -38,7 +43,7 @@ export function install(rt) {
// A Bot that could write where DSH or the team keeps its data could change its own
// permissions or the team, so neither those folders nor one that holds them is allowed.
async function guarded(path) {
- const team = teamFolder()
+ const team = await realTeam()
for (const root of [rt.dshHome, rt.home]) {
const data = await real(root)
if (within(data, path)) return true
@@ -67,7 +72,7 @@ export function install(rt) {
// A folder, as a real path, as a working folder: undefined for the team workspace.
async function workFolder(path) {
if (await guarded(path)) throw new Error(`${path} holds DeepSeek Harness data, so Bots cannot work there`)
- return path === teamFolder() ? undefined : path
+ return path === await realTeam() ? undefined : path
}
// Every Session of a Bot: its own chat and its conversation in each of its groups.
diff --git a/ds-bot/test/work-dir.test.js b/ds-bot/test/work-dir.test.js
index 04aaf812..a5e0167c 100644
--- a/ds-bot/test/work-dir.test.js
+++ b/ds-bot/test/work-dir.test.js
@@ -1,5 +1,5 @@
import assert from 'node:assert/strict'
-import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs'
+import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'
import { homedir, hostname, tmpdir } from 'node:os'
import { join, resolve } from 'node:path'
import { test } from 'node:test'
@@ -732,3 +732,20 @@ test('the folder is checked as DSH gets it, spaces and all', { skip: process.pla
assert.deepEqual(await changeDirectory(ctx, service, agentOf('b'), spaced), { error: `${JSON.stringify(spaced)} cannot be a working folder: its name starts or ends with a space or a quote mark.`, ran: false })
assert.equal(state().bots.b.workDir, undefined)
})
+
+test('a Bot changes back to the team workspace when the team workspace is known by a link', async (t) => {
+ const { service } = folderService()
+ const { requests, services } = approvalServices('allowed-once')
+ const { ctx, call, agentOf, root, team, project, state, stop } = await start({ services: { ...services, workingDirectory: service } })
+ t.after(stop)
+ const link = join(root, 'team-link')
+ symlinkSync(team, link, 'junction')
+ ctx.workspaceRegistry.get('w1').path = link
+ assert.equal((await call('update-bot', { id: 'b', workDir: project })).ok, true)
+ await until(() => state().bots.b.sessionId === 's1')
+ const back = await changeDirectory(ctx, service, agentOf('s1'), team)
+ assert.equal(back.ran, true)
+ assert.equal(state().bots.b.workDir, undefined)
+ // The user set the first folder, and the team workspace widens nothing, so nobody is asked.
+ assert.equal(requests.length, 0)
+})