A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Check the packaged app outside the checkout, with time limits
Fei2411c83d30825ca2
diff --git a/app/README.md b/app/README.mdindex f206ee35..62aa2e34 100644--- a/app/README.md+++ b/app/README.md@@ -35,7 +35,7 @@ At every start the Host puts these three bundles at the head of the profile's bu## Check a change-`npm test` checks the composition of the profile.+`npm test` checks the composition of the profile, and that every package the app runs on is a dependency (see [Package](#package)).`scripts/shot.mjs` starts the app on throwaway folders, saves a screenshot of its window, prints the page text, closes the window the way a user does and waits until the app exits. Build the window first (`npm run build`). Use the mock model of the plugin, `../ds-bot/dev/mock-llm.mjs` (`MOCK_PORT=<port> node ../ds-bot/dev/mock-llm.mjs`).@@ -58,7 +58,9 @@ npm run dist # the installer: dist-pack/DeepSeek-Bot-<version>-win-x64npm run check-packed # starts the packaged app on throwaway folders with the mock model, chats once, closes it```-`check-packed` takes another executable as its first argument, and a file for a screenshot of the window as its second.+`check-packed` takes another executable as its first argument, and a file for a screenshot of the window as its second. It runs an app that lies inside this checkout from a copy in its throwaway folder: from inside the checkout, Node would find a module that the package left out in the checkout's own `node_modules`.++electron-builder packs only the packages that it finds through `dependencies` and `optionalDependencies`. The DSH packages ask for many packages as peers, which npm installs but electron-builder would leave out, so `package.json` lists them as dependencies. `npm test` fails when one is missing and names it.The Windows installer installs for the current user only, without administrator rights, by default into `%LOCALAPPDATA%\Programs\DeepSeek Bot` (`build/installer.nsh` skips the page that asks for all users or only for the current one). The uninstaller removes the program and keeps the data location and the app's own data. CI builds the Windows installer on every pull request, checks the packaged app, then installs it, checks the installed app and uninstalls it.@@ -71,7 +73,7 @@ The Windows installer installs for the current user only, without administrator| `src/host.mjs` | The Host: boots the profile with `runProfile()` and reports the launch URL || `src/profile.mjs` | The profile: its name, its bundles, and its creation and update || `engine/` | The bundle `deepseek-bot-engine`: `cordis.patch.yml`, `preset-standard.patch.yml`, and `index.js`, which trades the launch token for the Host cookie |-| `test/` | `npm test`: the composition of the profile |+| `test/` | `npm test`: the composition of the profile, and the dependencies that the package needs || `src/web.mjs` | The window's files, the launch-token cookie exchange and the request forwarding || `ui/` | The window: React, built with Vite (`vite.config.js`) into `ui/dist`. It draws the plugin's own Bot views from `../ds-bot/src/client/` (sidebar, chat rows, docks, dialogs and their stylesheets) and puts its own Markdown in place of DSH's. It uses ds-bot's `api/bot` channel and its live feed `api/bot/feed` || `assets/` | The app icon: `icon.svg`, `icon.png` (1024 px) and `icon.ico` (Windows, 16 to 256 px). `npm run icon` (`scripts/icon.mjs`) draws them again from the Main Bot's whale in `../ds-bot` |diff --git a/app/scripts/check-packed.mjs b/app/scripts/check-packed.mjsindex 55451d27..122611a0 100644--- a/app/scripts/check-packed.mjs+++ b/app/scripts/check-packed.mjs@@ -4,9 +4,9 @@// Usage: node scripts/check-packed.mjs [app executable] [screenshot.png]// The executable defaults to the one that `npm run pack` or `npm run dist` writes into dist-pack/.import { spawn, spawnSync } from 'node:child_process'-import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'+import { cpSync, existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'import { tmpdir } from 'node:os'-import { dirname, join, resolve } from 'node:path'+import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path'import { setTimeout as sleep } from 'node:timers/promises'import { fileURLToPath } from 'node:url'@@ -30,6 +30,34 @@ const work = mkdtempSync(join(tmpdir(), 'ds-bot-packed-'))mkdirSync(join(work, 'home'))const children = []+function stopChildren() {+ for (const child of children) {+ if (child.exitCode !== null || child.signalCode !== null) continue+ // On Windows a plain kill ends only the main process; /T takes the Host and Electron's helpers along.+ if (process.platform === 'win32') spawnSync('taskkill', ['/pid', String(child.pid), '/T', '/F'], { stdio: 'ignore' })+ else child.kill()+ }+}++// An app that hangs, for example behind its error box, must not hold up CI.+setTimeout(() => {+ console.error('check-packed: FAILED: gave up after 8 minutes')+ stopChildren()+ process.exit(1)+}, 8 * 60_000).unref()++// Run from inside this checkout, the app would find a module that the build left out in the+// checkout's own node_modules, so the check runs a copy of the app from the throwaway folder.+function outsideCheckout(file) {+ const fromCheckout = relative(resolve(root, '..'), file)+ if (fromCheckout.startsWith('..') || isAbsolute(fromCheckout)) return file+ const appDir = process.platform === 'darwin' ? resolve(file, '..', '..', '..') : dirname(file)+ const copy = join(work, basename(appDir))+ cpSync(appDir, copy, { recursive: true, verbatimSymlinks: true })+ console.log(`check-packed: runs a copy of ${appDir} in ${work}`)+ return join(copy, relative(appDir, file))+}+function startMock() {const mock = spawn(process.execPath, [join(root, '..', 'ds-bot', 'dev', 'mock-llm.mjs')], {env: { ...process.env, MOCK_PORT: '0', MOCK_LOG: join(work, 'mock.log') }, stdio: ['ignore', 'pipe', 'inherit'],@@ -82,7 +110,12 @@ function devtools(url, problems) {})const call = (method, params = {}) => new Promise((done, reject) => {const id = next++- pending.set(id, { resolve: done, reject })+ const timer = setTimeout(() => {+ pending.delete(id)+ reject(new Error(`the window did not answer ${method}`))+ }, 30_000)+ const settle = action => (value) => { clearTimeout(timer); action(value) }+ pending.set(id, { resolve: settle(done), reject: settle(reject) })socket.send(JSON.stringify({ id, method, params }))})return { opened, call }@@ -125,7 +158,7 @@ try {DS_BOT_HOME: join(work, 'home'), DS_BOT_SHELL_DATA: join(work, 'shell'),DEEPSEEK_BASE_URL: modelUrl, DEEPSEEK_API_KEY: 'mock-key',})- const app = spawn(executable, [`--remote-debugging-port=${String(port)}`], { stdio: 'inherit', env })+ const app = spawn(outsideCheckout(resolve(executable)), [`--remote-debugging-port=${String(port)}`], { stdio: 'inherit', env })children.push(app)const exited = new Promise((done) => { app.once('exit', (code, signal) => { done({ code, signal }) }) })const cdp = devtools((await appPage(port, Date.now() + 120_000)).webSocketDebuggerUrl, problems)@@ -150,12 +183,7 @@ try {failed = trueconsole.error(`check-packed: FAILED: ${error instanceof Error ? error.message : String(error)}`)}-for (const child of children) {- if (child.exitCode !== null || child.signalCode !== null) continue- // On Windows a plain kill ends only the main process; /T takes the Host and Electron's helpers along.- if (process.platform === 'win32') spawnSync('taskkill', ['/pid', String(child.pid), '/T', '/F'], { stdio: 'ignore' })- else child.kill()-}+stopChildren()await sleep(500)rmSync(work, { recursive: true, force: true, maxRetries: 10, retryDelay: 500 })process.exit(failed ? 1 : 0)