A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Let a quit stop the team copy during its move-in
Fei2411a062b70ac228
diff --git a/app/src/import.mjs b/app/src/import.mjsindex deaab31d..7524f378 100644--- a/app/src/import.mjs+++ b/app/src/import.mjs@@ -191,19 +191,21 @@ export async function importTeam({ from, to, workspace, profile, dsh, signal })const rows = found.profiles.find(entry => entry.name === profile)?.rows ?? []if (rows.length > 0) await writeModelRows(to, rows)- signal?.throwIfAborted()for (const { id, group } of sessions) {+ signal?.throwIfAborted()await mkdir(join(to, 'sessions', group), { recursive: true })// A copy that stopped can have moved the Session in already.await rm(join(to, 'sessions', group, id), { recursive: true, force: true })await rename(join(stage, 'sessions', group, id), join(to, 'sessions', group, id))}+ signal?.throwIfAborted()if (existsSync(join(stage, 'attachments'))) await cp(join(stage, 'attachments'), join(to, 'attachments'), { recursive: true, force: false })const summary = {from, at: new Date().toISOString(), ...(dsh ? { dsh } : {}),bots: found.bots, rooms: found.rooms, sessions: sessions.length, missingSessions: missing,keys, modelSettings: rows.length > 0 ? profile : null,}+ signal?.throwIfAborted()await writeFile(join(stage, 'bot', 'imported.json'), `${JSON.stringify(summary, null, 2)}\n`)// Until this rename the data has no Bot team, so a copy that stopped can run again.await rm(join(to, 'bot'), { recursive: true, force: true })diff --git a/app/test/import.test.mjs b/app/test/import.test.mjsindex b02ad06e..090b0f4e 100644--- a/app/test/import.test.mjs+++ b/app/test/import.test.mjs@@ -162,6 +162,27 @@ describe('a copy that stopped', () => {await assert.rejects(importTeam({ from, to, workspace: join(root, 'stopped-files'), signal: AbortSignal.abort() }), { name: 'AbortError' })assert.equal(existsSync(join(to, 'bot')), false)})++ test('a quit during the move-in leaves no Bot team, and the next copy finishes', async () => {+ const { to, workspace } = newHome(join(root, 'mid'))+ const movedIn = join(to, 'sessions', '--team--', 'session-a')+ let stopped = false+ const signal = {+ get aborted() { return stopped },+ throwIfAborted() {+ if (existsSync(movedIn)) stopped = true+ if (stopped) throw Object.assign(new Error('stopped'), { name: 'AbortError' })+ },+ }+ await assert.rejects(importTeam({ from, to, workspace, signal }), { name: 'AbortError' })+ assert.equal(Object.keys(readJson(join(to, 'bot', 'state.json')).bots).length, 0)+ assert.equal(existsSync(movedIn), true)+ const summary = await importTeam({ from, to, workspace })+ assert.equal(summary.sessions, 5)+ assert.deepEqual(Object.keys(readJson(join(to, 'bot', 'state.json')).bots), ['session-a', 'session-b'])+ assert.equal(readFileSync(join(movedIn, 'session.v4.jsonl.zstd'), 'utf8'), 'session-a')+ assert.deepEqual(readdirSync(to).filter(name => /^\.import-\d+$/u.test(name)), [])+ })})describe('finding the team', () => {