A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Check a new team workspace where it would be made, before making it
Fei241151ec7751bbb1
diff --git a/ds-bot/src/host/folders.js b/ds-bot/src/host/folders.jsindex 143f4ece..91f5e575 100644--- a/ds-bot/src/host/folders.js+++ b/ds-bot/src/host/folders.js@@ -4,7 +4,7 @@// part (parts.js).import { mkdir, realpath, stat } from 'node:fs/promises'import { homedir } from 'node:os'-import { basename, isAbsolute, join, resolve, sep } from 'node:path'+import { basename, dirname, isAbsolute, join, resolve, sep } from 'node:path'import { unquote } from './text.js'const PICK_TIMEOUT_MS = 10 * 60_000@@ -26,6 +26,16 @@ export function install(rt) {const workDirOf = ({ botId, roomId } = {}) => rt.roomOf(roomId)?.workDir ?? rt.botOf(botId)?.workDirconst isFolder = path => stat(path).then(info => info.isDirectory(), () => false)const real = path => realpath(path).catch(() => resolve(path))+ // The real path of the deepest part that exists, with the rest after it.+ const realBeyond = async (path) => {+ const rest = []+ for (let at = path; ; at = dirname(at)) {+ const found = await realpath(at).catch(() => undefined)+ if (found !== undefined) return join(found, ...rest)+ if (dirname(at) === at) return path+ rest.unshift(basename(at))+ }+ }// The registry keeps the team workspace as it was given; folders compare as real paths.const realTeam = async () => {const team = teamFolder()@@ -94,7 +104,8 @@ export function install(rt) {}return false}- if (await holdsData(resolve(expanded))) throw new Error(`${text} holds DeepSeek Harness data, so it cannot be the team workspace`)+ // A folder to be made counts where it would be made: a link above it can lead into the data.+ if (await holdsData(await realBeyond(resolve(expanded)))) throw new Error(`${text} holds DeepSeek Harness data, so it cannot be the team workspace`)await mkdir(expanded, { recursive: true })const path = await realpath(expanded)if (!(await isFolder(path))) throw new Error(`${text} is a file, not a folder`)diff --git a/ds-bot/test/work-dir.test.js b/ds-bot/test/work-dir.test.jsindex a5a98b60..0880e35f 100644--- a/ds-bot/test/work-dir.test.js+++ b/ds-bot/test/work-dir.test.js@@ -599,6 +599,10 @@ test('the team workspace holds no DeepSeek Harness data, apart from the plugin\'assert.match(await error(root), /holds DeepSeek Harness data/)assert.match(await error('relative'), /full path/)assert.equal(existsSync(join(dsh, 'inside')), false)+ // A folder to be made under a link into the data is refused before anything is made.+ symlinkSync(dsh, join(root, 'dsh-link'), process.platform === 'win32' ? 'junction' : 'dir')+ assert.match(await error(join(root, 'dsh-link', 'new')), /holds DeepSeek Harness data/)+ assert.equal(existsSync(join(dsh, 'new')), false)assert.equal(state().workspaceId, 'w1')await call('team-workspace', { path: join(root, 'moved') })assert.deepEqual((await call('team-workspace', { path: join(home, 'workspace') })).value, { team })