Skip to content

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

Keep the merge's lazy module loading intact

Fei2411dd5dcc217657
diff --git a/app/src/main.mjs b/app/src/main.mjs
index 217c11ca..0f3e0201 100644
--- a/app/src/main.mjs
+++ b/app/src/main.mjs
@@ -15,12 +15,8 @@ import { fileURLToPath } from 'node:url'
import { canonicalExecPath } from './canonical-path.mjs'
import { configureIdentity } from './legacy.mjs'
import { hostPort } from './host-port.mjs'
-import { HostProcess } from './host-process.mjs'
-import { copySessions, findTeam, importTeam, restoreSessions, teamInUse, userDshHome } from './import.mjs'
import { captureStdio, LogFile } from './logs.mjs'
-import { copyData, moveProblem } from './move-data.mjs'
import { currentRootOf, driveOf, formatBytes, freeSpace, isEmptyTree, pickFrom, placeOf, rootOf } from './place.mjs'
-import { CHECK_PROFILE, PROFILE } from './profile.mjs'
import { createShell, SHELL_TEXT } from './shell.mjs'
import { readStartFrame, writeStartFrame } from './start-frame.mjs'
import { explainOf, StartWindow } from './start-window.mjs'
@@ -70,7 +66,7 @@ const frameFile = join(app.getPath('userData'), 'start-frame.json')
// Loaded once the start window is up (loadModules).
let BotBrowserGuests, partitionOf, BotViews, isBotId, importFromBrowser, listSources, applyCookies, CookieImports, parseCookieFile
let downloadSaver, chooseLocations, defaultPlaces, pickRoot, programFolder, saveLocations, teamIn, teamsAt, tx, HostProcess
-let copySessions, findTeam, importTeam, teamInUse, userDshHome, copyData, moveProblem, CHECK_PROFILE, PROFILE
+let copySessions, findTeam, importTeam, restoreSessions, teamInUse, userDshHome, copyData, moveProblem, CHECK_PROFILE, PROFILE
let watchReleases, watchUpdates, getDshRuntimeVersion, electronUpdater
let mainWindow
@@ -267,7 +263,7 @@ async function loadModules() {
;({ downloadSaver } = downloads)
;({ chooseLocations, defaultPlaces, pickRoot, programFolder, saveLocations, teamIn, teamsAt, tx } = firstRun)
;({ HostProcess } = hostProcess)
- ;({ copySessions, findTeam, importTeam, teamInUse, userDshHome } = imports)
+ ;({ copySessions, findTeam, importTeam, restoreSessions, teamInUse, userDshHome } = imports)
;({ copyData, moveProblem } = moves)
;({ CHECK_PROFILE, PROFILE } = profile)
;({ watchReleases, watchUpdates } = updatesModule)
@@ -522,26 +518,28 @@ async function startEngine(mine) {
updates = startUpdates()
updates?.subscribe((state) => { mainWindow?.webContents.send(IPC.appUpdateChanged, state) })
- // Before the Host, which reads the Sessions.
- await restoreSessions(where.dataDir).then(({ copied, newer }) => {
- if (copied.length > 0) console.log(`DS Bot: copied ${copied.join(', ')}, which the import left out`)
- if (newer.length > 0) console.warn(`DS Bot: this DSH cannot read ${newer.join(', ')}, which the import left out`)
- }, (error) => { console.error('DS Bot: the Sessions the import left out were not copied:', error) })
- host = newHost()
- host.onMessage(message => {
- if (message?.type !== 'ds-bot:browser-endpoint' || typeof message.id !== 'string' || !isBotId(message.botId)) return
- const downloadRoots = message.downloadRoots
- if (!Array.isArray(downloadRoots) || downloadRoots.length > 4 || !Array.from(downloadRoots).every(root => typeof root === 'string' && isAbsolute(root))) {
- host?.send({ type: 'ds-bot:browser-endpoint-response', id: message.id, error: 'Could not create the browser endpoint.' })
- return
- }
- void botViews.endpoint(message.botId, { downloadRoots }).then(url => {
- host?.send({ type: 'ds-bot:browser-endpoint-response', id: message.id, url })
- }).catch(() => host?.send({ type: 'ds-bot:browser-endpoint-response', id: message.id, error: 'Could not create the browser endpoint.' }))
- })
- return host.start()
- })()
- ready.catch(fail)
+ }
+ // Before the Host, which reads the Sessions.
+ await restoreSessions(places.dataDir).then(({ copied, newer }) => {
+ if (copied.length > 0) console.log(`DS Bot: copied ${copied.join(', ')}, which the import left out`)
+ if (newer.length > 0) console.warn(`DS Bot: this DSH cannot read ${newer.join(', ')}, which the import left out`)
+ }, (error) => { console.error('DS Bot: the Sessions the import left out were not copied:', error) })
+ host = newHost()
+ host.onMessage(message => {
+ if (message?.type !== 'ds-bot:browser-endpoint' || typeof message.id !== 'string' || !isBotId(message.botId)) return
+ const downloadRoots = message.downloadRoots
+ if (!Array.isArray(downloadRoots) || downloadRoots.length > 4 || !Array.from(downloadRoots).every(root => typeof root === 'string' && isAbsolute(root))) {
+ host?.send({ type: 'ds-bot:browser-endpoint-response', id: message.id, error: 'Could not create the browser endpoint.' })
+ return
+ }
+ void botViews.endpoint(message.botId, { downloadRoots }).then(url => {
+ host?.send({ type: 'ds-bot:browser-endpoint-response', id: message.id, url })
+ }).catch(() => host?.send({ type: 'ds-bot:browser-endpoint-response', id: message.id, error: 'Could not create the browser endpoint.' }))
+ })
+ return host.start()
+}
+
+function handleIpc() {
// A throwaway run (DS_BOT_HOME) keeps its folders where it was told.
const fixed = Boolean(process.env.DS_BOT_HOME)