A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Unpack sharp companion libraries in desktop packages
klarkxy39a257535892
diff --git a/app/electron-builder.yml b/app/electron-builder.ymlindex 16b1312d..e1ae8934 100644--- a/app/electron-builder.yml+++ b/app/electron-builder.yml@@ -11,6 +11,8 @@ files:# The Host runs pnpm as a separate Node process to install plugins, so it must be a plain file.asarUnpack:- node_modules/pnpm/**+ # Automatic unpacking misses versioned Linux libraries such as libvips-cpp.so.8.18.7.+ - node_modules/@img/sharp*/**# node-pty, sharp and koffi ship prebuilt binaries for each platform. A rebuild would compile# node-pty from source and needs a C++ toolchain.npmRebuild: falsediff --git a/app/scripts/check-packed.mjs b/app/scripts/check-packed.mjsindex 9e22f315..8764a5a8 100644--- a/app/scripts/check-packed.mjs+++ b/app/scripts/check-packed.mjs@@ -1,4 +1,4 @@-// Check a packaged app: start it on throwaway folders with the ds-bot mock model, choose a model,+// Check a packaged app: process an image with its sharp, then start it on throwaway folders with the ds-bot mock model, choose a model,// send a message, wait for the reply, then close the window the way a user does and wait until// the app has exited. Fails on a page error or a non-zero exit.// Usage: node scripts/check-packed.mjs [app executable] [screenshot.png]@@ -60,6 +60,31 @@ function outsideCheckout(file) {return join(copy, relative(appDir, file))}+function checkSharp(app) {+ const resources = process.platform === 'darwin' ? resolve(app, '..', '..', 'Resources') : join(dirname(app), 'resources')+ const script = `+ const assert = require('node:assert/strict')+ const { createRequire } = require('node:module')+ const appRequire = createRequire(${JSON.stringify(join(resources, 'app.asar', 'package.json'))})+ const sharp = appRequire('sharp')+ ;(async () => {+ const image = await sharp({ create: { width: 4, height: 4, channels: 3, background: '#ff0000' } }).png().toBuffer()+ const { data, info } = await sharp(image).resize(2, 2).removeAlpha().raw().toBuffer({ resolveWithObject: true })+ assert.equal(info.width, 2)+ assert.equal(info.height, 2)+ assert.deepEqual([...data], Array.from({ length: 4 }, () => [255, 0, 0]).flat())+ console.log('check-packed: sharp image processing passed (libvips ' + sharp.versions.vips + ')')+ })().catch(error => { console.error(error); process.exitCode = 1 })+ `+ // Use the shipped Electron and dependencies outside the checkout, just like the Host.+ const result = spawnSync(app, ['-e', script], {+ cwd: work, env: { ...process.env, ELECTRON_RUN_AS_NODE: '1', NODE_PATH: '' },+ encoding: 'utf8', timeout: 30_000,+ })+ if (result.error || result.status !== 0) throw new Error(`packaged sharp failed (exit ${String(result.status)}, signal ${String(result.signal)}): ${result.error?.message ?? ''}\n${result.stderr ?? ''}`)+ console.log(result.stdout.trim())+}+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'],@@ -225,6 +250,8 @@ async function chat(cdp) {let failed = falseconst problems = []try {+ const packedApp = outsideCheckout(resolve(executable))+ checkSharp(packedApp)const modelUrl = await startMock()const port = 9300 + Math.floor(Math.random() * 600)// A terminal inside an Electron-based editor may set ELECTRON_RUN_AS_NODE, which turns the app into plain Node.@@ -233,7 +260,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(outsideCheckout(resolve(executable)), [`--remote-debugging-port=${String(port)}`], { stdio: 'inherit', env })+ const app = spawn(packedApp, [`--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)diff --git a/app/test/package.test.mjs b/app/test/package.test.mjsindex 668275e9..57bba5a4 100644--- a/app/test/package.test.mjs+++ b/app/test/package.test.mjs@@ -1,6 +1,9 @@import assert from 'node:assert/strict'import { readFileSync } from 'node:fs'import { test } from 'node:test'+import { join, resolve } from 'node:path'+import { FileMatcher } from 'app-builder-lib/out/fileMatcher.js'+import { parse } from 'yaml'// npm installs the peers that the DSH packages ask for, but electron-builder packs only the// dependencies it finds through `dependencies` and `optionalDependencies`. A package that npm@@ -13,6 +16,24 @@ test('every package that the app runs on is a dependency, not only a peer', () =assert.deepEqual(peerOnly, [], `add these to "dependencies" in app/package.json: ${peerOnly.join(' ')}`)})+test('sharp native modules and versioned libvips libraries are unpacked together', () => {+ const config = parse(readFileSync(new URL('../electron-builder.yml', import.meta.url), 'utf8'))+ const root = resolve('app-fixture')+ const filter = new FileMatcher(root, root, value => value, config.asarUnpack).createFilter()+ const stat = { isDirectory: () => false }+ for (const file of [+ '@img/sharp-linux-x64/lib/sharp-linux-x64-0.35.5.node',+ '@img/sharp-libvips-linux-x64/lib/libvips-cpp.so.8.18.7',+ '@img/sharp-linux-arm64/lib/sharp-linux-arm64.node',+ '@img/sharp-libvips-linux-arm64/lib/libvips-cpp.so.8.18.7',+ '@img/sharp-libvips-linuxmusl-x64/lib/libvips-cpp.so.8.18.7',+ '@img/sharp-libvips-darwin-arm64/lib/libvips-cpp.8.18.7.dylib',+ '@img/sharp-win32-x64/lib/libvips-42.dll',+ 'pnpm/bin/pnpm.cjs',+ ]) assert.equal(filter(join(root, 'node_modules', file), stat), true, file)+ assert.equal(filter(join(root, 'node_modules/yaml/dist/index.js'), stat), false)+})+// A release is tagged with the version of ds-bot, and the installed apps compare their own// version with the one in the release's latest.yml.test('the app has the version of ds-bot', () => {