A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Package the desktop app for Linux: one AppImage and a deb
klarkxyae1b3349e378
diff --git a/app/electron-builder.yml b/app/electron-builder.ymlindex 34c1699f..16b1312d 100644--- a/app/electron-builder.yml+++ b/app/electron-builder.yml@@ -37,6 +37,23 @@ mac:hardenedRuntime: falseicon: assets/icon.pngcategory: public.app-category.productivity+linux:+ # One AppImage runs on every distribution and updates itself; the deb is for Debian/Ubuntu,+ # where it avoids Ubuntu 24.04's AppArmor question of an AppImage and adds a menu entry.+ target:+ - target: AppImage+ arch: [x64]+ - target: deb+ arch: [x64]+ # The binary and the deb's menu entry take this name; productName has a space, which a+ # terminal command should not have.+ executableName: deepseek-bot+ # A deb needs a maintainer; package.json's author has no email, so it goes here.+ maintainer: Fei2411 <https://github.com/Fei2411>+ # Links the running window to the menu entry (WM_CLASS = app id).+ syncDesktopName: true+ icon: assets/icon.png+ category: Utility# Where the installed app looks for updates (app-update.yml in the package). The build writes# latest.yml beside the installer; the release workflow attaches both to the GitHub release,# so the build itself never publishes (--publish never).diff --git a/app/package.json b/app/package.jsonindex 01dfc0af..06b6f46e 100644--- a/app/package.json+++ b/app/package.json@@ -5,6 +5,8 @@"private": true,"description": "DeepSeek Bot desktop app: the ds-bot team on its own pinned DeepSeek Harness.","author": "Fei2411",+ "homepage": "https://github.com/Fei2411/DeepSeek-Bot",+ "desktopName": "deepseek-bot.desktop","license": "Apache-2.0","type": "module","main": "src/main.mjs",diff --git a/app/scripts/check-packed.mjs b/app/scripts/check-packed.mjsindex 96f96d78..246cfe99 100644--- a/app/scripts/check-packed.mjs+++ b/app/scripts/check-packed.mjs@@ -17,6 +17,8 @@ const executable = given || packedExecutable()function packedExecutable() {const out = join(root, 'dist-pack')if (process.platform === 'win32') return join(out, 'win-unpacked', 'DeepSeek Bot.exe')+ // executableName in electron-builder.yml.+ if (process.platform === 'linux') return join(out, 'linux-unpacked', 'deepseek-bot')const dir = ['mac-arm64', 'mac'].find(name => existsSync(join(out, name))) ?? 'mac'return join(out, dir, 'DeepSeek Bot.app', 'Contents', 'MacOS', 'DeepSeek Bot')}diff --git a/app/scripts/check-update.mjs b/app/scripts/check-update.mjsindex 11e56664..a500dd3c 100644--- a/app/scripts/check-update.mjs+++ b/app/scripts/check-update.mjs@@ -1,7 +1,7 @@-// Check a packaged app's update on throwaway folders. Windows downloads and installs a feed;-// macOS reads the latest release and opens no browser.-// Usage: node scripts/check-update.mjs <app executable> <feed folder> [--kill] (Windows)-// node scripts/check-update.mjs <app executable> <version> (macOS)+// Check a packaged app's update on throwaway folders. Windows and a Linux AppImage download and+// install a feed; macOS and a Linux deb read the latest release and open no browser.+// Usage: node scripts/check-update.mjs <app executable> <feed folder with latest.yml or latest-linux.yml> [--kill]+// node scripts/check-update.mjs <app executable> <version> (macOS, a Linux deb)import { spawn, spawnSync } from 'node:child_process'import { createReadStream, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync } from 'node:fs'import { createServer } from 'node:http'@@ -11,20 +11,29 @@ import { setTimeout as sleep } from 'node:timers/promises'const [executable, source, mode] = process.argv.slice(2)const mac = process.platform === 'darwin'+// An AppImage updates itself, as on Windows; any other Linux executable (a deb's) only hears+// of the release, as on macOS.+const releasePage = mac || (process.platform === 'linux' && !executable?.endsWith('.AppImage'))+const manifest = process.platform === 'linux' ? 'latest-linux.yml' : 'latest.yml'+// The asset the fake release lists: what this install's update check waits for. The deb's file+// name uses the Debian architecture (x64 → amd64).+const asset = mac+ ? version => `DeepSeek-Bot-${version}-mac-${process.arch}.zip`+ : version => `DeepSeek-Bot-${version}-linux-${{ x64: 'amd64' }[process.arch] ?? process.arch}.deb`if (!executable || !source || !existsSync(executable)- || (mac ? mode !== undefined : !existsSync(join(source, 'latest.yml')))) {- console.error(`check-update: usage: ${mac+ || (releasePage ? mode !== undefined : !existsSync(join(source, manifest)))) {+ console.error(`check-update: usage: ${releasePage? 'node scripts/check-update.mjs <app executable> <version>'- : 'node scripts/check-update.mjs <app executable> <feed folder with latest.yml> [--kill]'}`)+ : `node scripts/check-update.mjs <app executable> <feed folder with ${manifest}> [--kill]`}`)process.exit(2)}-const version = mac ? source : /^version:\s*(\S+)/mu.exec(readFileSync(join(source, 'latest.yml'), 'utf8'))?.[1]+const version = releasePage ? source : /^version:\s*(\S+)/mu.exec(readFileSync(join(source, manifest), 'utf8'))?.[1]const work = mkdtempSync(join(tmpdir(), 'ds-bot-update-'))mkdirSync(join(work, 'home'))const served = []const server = createServer((request, response) => {- if (mac) {+ if (releasePage) {const pathname = new URL(request.url, 'http://feed/').pathnameif (request.method !== 'GET' || pathname !== '/') { response.writeHead(404).end(); return }served.push(pathname)@@ -33,7 +42,7 @@ const server = createServer((request, response) => {html_url: `https://github.com/Fei2411/DeepSeek-Bot/releases/tag/v${version}`,draft: false,prerelease: false,- assets: [{ name: `DeepSeek-Bot-${version}-mac-${process.arch}.zip` }],+ assets: [{ name: asset(version) }],}]))return}@@ -89,6 +98,13 @@ async function closeWindow(port, waitForReady = false) {socket.send(JSON.stringify({ id: 1, method: 'Runtime.evaluate', params: { expression: 'window.close()' } }))}+// taskkill /T takes the Host and Electron's helpers along; a unix kill ends the tree's root,+// and the app's own children go with it.+function killApp() {+ if (process.platform === 'win32') spawnSync('taskkill', ['/pid', String(app.pid), '/T', '/F'], { stdio: 'ignore' })+ else app?.kill()+}+let failed = falselet apptry {@@ -103,29 +119,29 @@ try {stream.setEncoding('utf8')stream.on('data', (chunk) => { output += chunk; process.stdout.write(chunk) })}- const updateLine = `DeepSeek Bot: update ${String(version)} ${mac ? 'available' : 'downloaded'}`- const end = Date.now() + (mac ? 3 : 5) * 60_000+ const updateLine = `DeepSeek Bot: update ${String(version)} ${releasePage ? 'available' : 'downloaded'}`+ const end = Date.now() + (releasePage ? 3 : 5) * 60_000while (!output.includes(updateLine)) {- if (mac ? /DeepSeek Bot: update check failed/u.test(output) : /DeepSeek Bot: update failed/u.test(output)) {+ if (releasePage ? /DeepSeek Bot: update check failed/u.test(output) : /DeepSeek Bot: update failed/u.test(output)) {throw new Error('the app reported a failed update')}if (app.exitCode !== null) {- const status = mac ? 'the update was found' : 'the update was downloaded'+ const status = releasePage ? 'the update was found' : 'the update was downloaded'throw new Error(`the app exited (code ${String(app.exitCode)}) before ${status}`)}- if (Date.now() > end) throw new Error(mac ? 'the update was not found within 3 minutes' : 'the update was not downloaded within 5 minutes')+ if (Date.now() > end) throw new Error(releasePage ? 'the update was not found within 3 minutes' : 'the update was not downloaded within 5 minutes')await sleep(500)}- if (mac && !served.includes('/')) throw new Error('the release feed was not requested')+ if (releasePage && !served.includes('/')) throw new Error('the release feed was not requested')console.log(`check-update: ${updateLine}; the feed served ${served.join(', ')}`)- if (mac) {+ if (releasePage) {await closeWindow(port, true)const code = await Promise.race([exited, sleep(60_000).then(() => 'timeout')])if (code === 'timeout') throw new Error('the app did not exit after its window closed')if (code !== 0) throw new Error(`the app exited with code ${String(code)}`)console.log('check-update: the app closed without installing')} else if (mode === '--kill') {- spawnSync('taskkill', ['/pid', String(app.pid), '/T', '/F'], { stdio: 'ignore' })+ killApp()await exitedconsole.log('check-update: ended the app, so nothing was installed')} else {@@ -139,10 +155,7 @@ try {} catch (error) {failed = trueconsole.error(`check-update: FAILED: ${error instanceof Error ? error.message : String(error)}`)- if (app?.exitCode === null) {- if (mac) app.kill()- else spawnSync('taskkill', ['/pid', String(app.pid), '/T', '/F'], { stdio: 'ignore' })- }+ if (app?.exitCode === null) killApp()}server.close()await sleep(500)diff --git a/app/src/main.mjs b/app/src/main.mjsindex b08aff3f..c43b7a85 100644--- a/app/src/main.mjs+++ b/app/src/main.mjs@@ -304,8 +304,8 @@ async function moveData(workspace) {const notePage = message => `data:text/html;charset=utf-8,${encodeURIComponent(`<!doctype html><meta charset="utf-8"><meta name="color-scheme" content="light dark"><body style="margin:0;height:100vh;display:grid;place-items:center;font:14px system-ui,sans-serif;background:Canvas;color:CanvasText">${message.replace(/[&<>]/gu, char => `&#${String(char.charCodeAt(0))};`)}</body>`)}`-// Windows updates itself; macOS asks to download the new version. Throwaway runs check only a-// given feed and never ask.+// Windows and a Linux AppImage update themselves; macOS and a Linux deb ask to download the new+// version. Throwaway runs check only a given feed and never ask.function startUpdates() {const feed = process.env.DS_BOT_UPDATE_URL || undefinedconst throwaway = Boolean(process.env.DS_BOT_HOME)@@ -315,7 +315,17 @@ function startUpdates() {current: app.getVersion(), arch: process.arch, feed, ask: throwaway ? undefined : askDownload, open: url => shell.openExternal(url),})}- if (process.platform === 'win32') {+ // electron-updater's Linux updater works only from inside an AppImage (APPIMAGE is set there);+ // a deb cannot update itself and points at the release page instead, as on macOS. The deb's+ // file name uses the Debian architecture (x64 → amd64).+ if (process.platform === 'linux' && process.env.APPIMAGE === undefined) {+ const debArch = { x64: 'amd64', arm64: 'arm64' }[process.arch] ?? process.arch+ return watchReleases({+ current: app.getVersion(), arch: process.arch, feed, ask: throwaway ? undefined : askDownload, open: url => shell.openExternal(url),+ asset: version => `DeepSeek-Bot-${version}-linux-${debArch}.deb`,+ })+ }+ if (process.platform === 'win32' || process.platform === 'linux') {return watchUpdates({ updater: electronUpdater.autoUpdater, feed, ask: throwaway ? undefined : askRestart, beforeInstall: stopHost })}return undefineddiff --git a/app/src/updates.mjs b/app/src/updates.mjsindex 97a34484..76ee31d4 100644--- a/app/src/updates.mjs+++ b/app/src/updates.mjs@@ -1,4 +1,5 @@-// Windows downloads and installs updates; macOS asks before opening the release page.+// Windows and a Linux AppImage download and install updates; macOS and a Linux deb ask before+// opening the release page.export const UPDATE_TEXT = {en: {@@ -73,7 +74,10 @@ function isHttpsPage(page) {}}-export function watchReleases({ current, arch, fetch = globalThis.fetch, ask, open, feed = RELEASES_URL, log = console }) {+// `asset` names the release asset of this install (default: the macOS zip); a release without+// it does not count.+export function watchReleases({ current, arch, fetch = globalThis.fetch, ask, open, feed = RELEASES_URL, log = console, asset }) {+ const assetName = asset ?? (version => `DeepSeek-Bot-${version}-mac-${arch}.zip`)let askedlet latest = Promise.resolve(null)const check = () => {@@ -99,7 +103,7 @@ export function watchReleases({ current, arch, fetch = globalThis.fetch, ask, op|| (release.prerelease === true && !allowPrerelease)) continueconst version = typeof release.tag_name === 'string' ? release.tag_name.replace(/^v/u, '') : ''if (!isNewer(version, current)) continue- if (!Array.isArray(release.assets) || !release.assets.some(asset => asset?.name === `DeepSeek-Bot-${version}-mac-${arch}.zip`)) continue+ if (!Array.isArray(release.assets) || !release.assets.some(entry => entry?.name === assetName(version))) continueif (!isHttpsPage(release.html_url)) {log.error('DeepSeek Bot: update check failed: release page URL is not HTTPS')continuediff --git a/app/test/updates.test.mjs b/app/test/updates.test.mjsindex 27a7bc30..637ed761 100644--- a/app/test/updates.test.mjs+++ b/app/test/updates.test.mjs@@ -212,6 +212,27 @@ describe('watchReleases', () => {assert.deepEqual(asked, ['0.1.9'])})+ test('a given asset replaces the mac zip: the deb of a Linux install', async (t) => {+ const page = 'https://github.com/Fei2411/DeepSeek-Bot/releases/tag/v0.1.9'+ // The deb's file name uses the Debian architecture (x64 → amd64).+ const deb = version => `DeepSeek-Bot-${version}-linux-amd64.deb`+ // A release with only the mac zip does not count for a deb install.+ const misses = watchReleases({+ current: '0.1.7', arch: 'x64', asset: deb,+ fetch: async () => releaseResponse([release('0.1.9', { page })]), log: quietLog(),+ })+ t.after(misses.stop)+ assert.equal(await misses.latest(), null)++ const hits = watchReleases({+ current: '0.1.7', arch: 'x64', asset: deb,+ fetch: async () => releaseResponse([release('0.1.9', { page, assets: [{ name: 'DeepSeek-Bot-0.1.9-linux-amd64.deb' }] })]),+ log: quietLog(),+ })+ t.after(hits.stop)+ assert.deepEqual(await hits.latest(), { version: '0.1.9', page })+ })+test('ignores prereleases for a stable installation', async (t) => {const updates = watchReleases({current: '0.1.7', arch: 'arm64',