A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Add asset-aware macOS release updates
Fei241176b7e65d4f7b
diff --git a/app/README.md b/app/README.mdindex c2049702..ac13f9ac 100644--- a/app/README.md+++ b/app/README.md@@ -19,7 +19,7 @@ npm installs `ds-bot` from `../ds-bot` as a copy of its package files (`install-| `DS_BOT_HOME` | The data location: the `DSH_HOME` of the app. When it is set, the app asks nothing at its first start and imports nothing | The folder chosen at the first start || `DS_BOT_WORKSPACE` | With `DS_BOT_HOME`: the folder for the files that Bots make | `bot/workspace` in the data location || `DS_BOT_SHELL_DATA` | The app's own data (window, Chromium storage, `locations.json`) | Electron's `userData` (Windows: `%APPDATA%\DeepSeek Bot`; macOS: `~/Library/Application Support/DeepSeek Bot`) |-| `DS_BOT_UPDATE_URL` | Windows: a folder URL with `latest.yml` and its installer. macOS: a URL returning JSON like `releases/latest`, with `tag_name` and `html_url` (see [Updates](#updates)). With `DS_BOT_HOME`, the app checks only when this is set | The newest GitHub release |+| `DS_BOT_UPDATE_URL` | Windows: a folder URL with `latest.yml` and its installer. macOS: a URL returning a JSON list like GitHub's `releases` API; a release counts only when this Mac's DMG is attached. Prereleases count only for prerelease installs (see [Updates](#updates)). With `DS_BOT_HOME`, the app checks only when this is set | The newest GitHub release |On macOS, Electron's default `userData` directory for `productName` "DeepSeek Bot" is `~/Library/Application Support/DeepSeek Bot`.@@ -81,7 +81,7 @@ The installed app on Windows updates itself with electron-updater (`src/updates.The checks start before the Host (after a first start's import), so that a version whose Host does not start can still update. When the start fails, the app waits up to 15 seconds for the newest check. When it found a newer version, the error box says so; after the box the app waits for the download, then installs it and opens again.-On macOS, the app checks GitHub's latest release at start and every 4 hours. It asks once per version. Download opens the release page; Later closes the dialog. The app does not install the update itself. `DS_BOT_UPDATE_URL` on macOS points to JSON like the `releases/latest` API response, with `tag_name` and an HTTPS `html_url`.+On macOS, the app checks GitHub's releases at start and every 4 hours. It asks once per version, after that release's DMG for this Mac is attached. Stable installs ignore prereleases; prerelease installs can see them. Download opens the release page; Later closes the dialog. The app does not install the update itself. `DS_BOT_UPDATE_URL` on macOS points to a JSON list like the `releases` API response. A release needs `tag_name`, an HTTPS `html_url`, and the matching architecture's DMG in `assets`.On Windows, `app-update.yml` tells the app where its releases are; `npm run dist` writes it from `publish` in `electron-builder.yml`, together with `latest.yml` beside the installer (`npm run pack` writes neither). Neither command publishes. The release workflow (`.github/workflows/release.yml`) builds the installer when a release is published and attaches the installer, its `.blockmap` and `latest.yml` to the release. The release tag is the version of `ds-bot`, and `npm test` checks that the app has the same version. The macOS release job builds each DMG on a matching-architecture runner and attaches only the DMG.diff --git a/app/scripts/check-update.mjs b/app/scripts/check-update.mjsindex 2db07771..042e678b 100644--- a/app/scripts/check-update.mjs+++ b/app/scripts/check-update.mjs@@ -28,10 +28,13 @@ const server = createServer((request, response) => {const pathname = new URL(request.url, 'http://feed/').pathnameif (request.method !== 'GET' || pathname !== '/') { response.writeHead(404).end(); return }served.push(pathname)- response.writeHead(200, { 'content-type': 'application/json' }).end(JSON.stringify({+ response.writeHead(200, { 'content-type': 'application/json' }).end(JSON.stringify([{tag_name: `v${version}`,html_url: `https://github.com/Fei2411/DeepSeek-Bot/releases/tag/v${version}`,- }))+ draft: false,+ prerelease: false,+ assets: [{ name: `DeepSeek-Bot-${version}-mac-${process.arch}.dmg` }],+ }]))return}const name = basename(decodeURIComponent(new URL(request.url, 'http://feed/').pathname))diff --git a/app/src/main.mjs b/app/src/main.mjsindex d4d77087..8becab73 100644--- a/app/src/main.mjs+++ b/app/src/main.mjs@@ -147,7 +147,7 @@ function startUpdates() {if (!app.isPackaged || (throwaway && feed === undefined)) return undefinedif (process.platform === 'darwin') {return watchReleases({- current: app.getVersion(), feed, ask: throwaway ? undefined : askDownload, open: url => shell.openExternal(url),+ current: app.getVersion(), arch: process.arch, feed, ask: throwaway ? undefined : askDownload, open: url => shell.openExternal(url),})}if (process.platform === 'win32') {diff --git a/app/src/updates.mjs b/app/src/updates.mjsindex c57875f6..7321a715 100644--- a/app/src/updates.mjs+++ b/app/src/updates.mjs@@ -24,7 +24,7 @@ export const UPDATE_TEXT = {}const CHECK_EVERY_MS = 4 * 60 * 60_000-export const RELEASES_URL = 'https://api.github.com/repos/Fei2411/DeepSeek-Bot/releases/latest'+export const RELEASES_URL = 'https://api.github.com/repos/Fei2411/DeepSeek-Bot/releases?per_page=20'function parseVersion(version) {if (typeof version !== 'string') return null@@ -64,7 +64,16 @@ export function isNewer(candidate, current) {return false}-export function watchReleases({ current, fetch = globalThis.fetch, ask, open, feed = RELEASES_URL, log = console }) {+function isHttpsPage(page) {+ if (typeof page !== 'string') return false+ try {+ return new URL(page).protocol === 'https:'+ } catch {+ return false+ }+}++export function watchReleases({ current, arch, fetch = globalThis.fetch, ask, open, feed = RELEASES_URL, log = console }) {let askedlet latest = Promise.resolve(null)const check = () => {@@ -77,17 +86,33 @@ export function watchReleases({ current, fetch = globalThis.fetch, ask, open, felog.error(`DeepSeek Bot: update check failed: HTTP ${String(response.status)}`)return null}- const { tag_name, html_url: page } = await response.json()- const version = typeof tag_name === 'string' ? tag_name.replace(/^v/u, '') : ''- if (!isNewer(version, current)) return null- if (typeof page !== 'string' || new URL(page).protocol !== 'https:') throw new Error('release page URL is not HTTPS')- const found = { version, page }- log.info(`DeepSeek Bot: update ${version} available`)- if (ask !== undefined && asked !== version) {- asked = version- void Promise.resolve().then(() => ask(version))- .then(yes => (yes ? open(page) : undefined))- .catch((error) => { log.error(`DeepSeek Bot: update ${version} not opened: ${error instanceof Error ? error.message : String(error)}`) })+ const releases = await response.json()+ if (!Array.isArray(releases)) {+ log.error('DeepSeek Bot: update check failed: releases response is not an array')+ return null+ }+ const currentVersion = parseVersion(current)+ const allowPrerelease = currentVersion !== null && currentVersion.pre !== null+ let found+ for (const release of releases) {+ if (release === null || typeof release !== 'object' || release.draft === true+ || (release.prerelease === true && !allowPrerelease)) continue+ const 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}.dmg`)) continue+ if (!isHttpsPage(release.html_url)) {+ log.error('DeepSeek Bot: update check failed: release page URL is not HTTPS')+ continue+ }+ if (found === undefined || isNewer(version, found.version)) found = { version, page: release.html_url }+ }+ if (found === undefined) return null+ log.info(`DeepSeek Bot: update ${found.version} available`)+ if (ask !== undefined && asked !== found.version) {+ asked = found.version+ void Promise.resolve().then(() => ask(found.version))+ .then(yes => (yes ? open(found.page) : undefined))+ .catch((error) => { log.error(`DeepSeek Bot: update ${found.version} not opened: ${error instanceof Error ? error.message : String(error)}`) })}return found} catch (error) {diff --git a/app/test/updates.test.mjs b/app/test/updates.test.mjsindex 6b0de65c..26145192 100644--- a/app/test/updates.test.mjs+++ b/app/test/updates.test.mjs@@ -32,9 +32,16 @@ const quietLog = () => {return { lines, info: (line) => { lines.push(line) }, error: (line) => { lines.push(line) } }}-const release = (version, page = 'https://github.com/Fei2411/DeepSeek-Bot/releases/tag/v0.1.9') => ({- tag_name: `v${version}`, html_url: page,-})+const release = (version, options = {}) => {+ const arch = options.arch ?? 'arm64'+ return {+ tag_name: `v${version}`,+ html_url: options.page ?? `https://github.com/Fei2411/DeepSeek-Bot/releases/tag/v${version}`,+ draft: options.draft ?? false,+ prerelease: options.prerelease ?? false,+ assets: options.assets ?? [{ name: `DeepSeek-Bot-${version}-mac-${arch}.dmg` }],+ }+}const releaseResponse = (body, status = 200) => ({ok: status >= 200 && status < 300,@@ -65,9 +72,9 @@ describe('watchReleases', () => {const calls = []const fetch = async (url, options) => {calls.push({ url, options })- return releaseResponse(release('0.1.7'))+ return releaseResponse([release('0.1.7')])}- const updates = watchReleases({ current: '0.1.7', fetch, log: quietLog() })+ const updates = watchReleases({ current: '0.1.7', arch: 'arm64', fetch, log: quietLog() })t.after(updates.stop)assert.equal(await updates.latest(), null)assert.deepEqual(calls[0], {@@ -76,7 +83,7 @@ describe('watchReleases', () => {})const feed = 'http://127.0.0.1:8080/'- const custom = watchReleases({ current: '0.1.7', fetch, feed, log: quietLog() })+ const custom = watchReleases({ current: '0.1.7', arch: 'arm64', fetch, feed, log: quietLog() })t.after(custom.stop)await custom.latest()assert.equal(calls[1].url, feed)@@ -88,7 +95,7 @@ describe('watchReleases', () => {const asked = []const opened = []const updates = watchReleases({- current: '0.1.7', fetch: async () => releaseResponse(release('0.1.9', page)), log: quietLog(),+ current: '0.1.7', arch: 'arm64', fetch: async () => releaseResponse([release('0.1.9', { page })]), log: quietLog(),ask: async version => { asked.push(version); return accepted },open: url => { opened.push(url) },})@@ -104,7 +111,7 @@ describe('watchReleases', () => {for (const version of ['0.1.7', '0.1.6']) {const asked = []const updates = watchReleases({- current: '0.1.7', fetch: async () => releaseResponse(release(version)), log: quietLog(),+ current: '0.1.7', arch: 'arm64', fetch: async () => releaseResponse([release(version)]), log: quietLog(),ask: async value => { asked.push(value); return true }, open: () => {},})t.after(updates.stop)@@ -120,7 +127,8 @@ describe('watchReleases', () => {const asked = []const updates = watchReleases({current: '0.1.7',- fetch: async () => { checks += 1; return releaseResponse(release(version)) },+ arch: 'arm64',+ fetch: async () => { checks += 1; return releaseResponse([release(version)]) },ask: async value => { asked.push(value); return false },open: () => {},log: quietLog(),@@ -144,7 +152,7 @@ describe('watchReleases', () => {test('reports releases without asking in throwaway runs', async (t) => {let opens = 0const updates = watchReleases({- current: '0.1.7', fetch: async () => releaseResponse(release('0.1.9')),+ current: '0.1.7', arch: 'arm64', fetch: async () => releaseResponse([release('0.1.9')]),ask: undefined, open: () => { opens += 1 }, log: quietLog(),})t.after(updates.stop)@@ -157,17 +165,97 @@ describe('watchReleases', () => {[async () => releaseResponse({}, 403), 'DeepSeek Bot: update check failed: HTTP 403'],[async () => { throw new Error('offline') }, 'DeepSeek Bot: update check failed: offline'],[async () => ({ ok: true, status: 200, json: async () => { throw new Error('bad JSON') } }), 'DeepSeek Bot: update check failed: bad JSON'],- [async () => releaseResponse(release('0.1.9', 'http://github.com/Fei2411/DeepSeek-Bot')), 'DeepSeek Bot: update check failed: release page URL is not HTTPS'],+ [async () => releaseResponse([release('0.1.9', { page: 'http://github.com/Fei2411/DeepSeek-Bot' })]), 'DeepSeek Bot: update check failed: release page URL is not HTTPS'],]for (const [fetch, message] of cases) {const log = quietLog()- const updates = watchReleases({ current: '0.1.7', fetch, log })+ const updates = watchReleases({ current: '0.1.7', arch: 'arm64', fetch, log })t.after(updates.stop)assert.equal(await updates.latest(), null)assert.deepEqual(log.lines, [message])}})+ test('logs a non-array release response once', async (t) => {+ const log = quietLog()+ const updates = watchReleases({+ current: '0.1.7', arch: 'arm64', fetch: async () => releaseResponse({ releases: [] }), log,+ })+ t.after(updates.stop)+ assert.equal(await updates.latest(), null)+ assert.deepEqual(log.lines, ['DeepSeek Bot: update check failed: releases response is not an array'])+ })++ test('waits for the matching-architecture DMG before asking', async (t) => {+ t.mock.timers.enable({ apis: ['setInterval'] })+ let attached = false+ const asked = []+ const updates = watchReleases({+ current: '0.1.7',+ arch: 'arm64',+ fetch: async () => releaseResponse([release('0.1.9', { arch: attached ? 'arm64' : 'x64' })]),+ ask: async version => { asked.push(version); return false },+ open: () => {},+ log: quietLog(),+ })+ t.after(updates.stop)++ assert.equal(await updates.latest(), null)+ await sleep(0)+ assert.deepEqual(asked, [])+ attached = true+ t.mock.timers.tick(4 * 60 * 60_000)+ assert.deepEqual(await updates.latest(), {+ version: '0.1.9', page: 'https://github.com/Fei2411/DeepSeek-Bot/releases/tag/v0.1.9',+ })+ await sleep(0)+ assert.deepEqual(asked, ['0.1.9'])+ })++ test('ignores prereleases for a stable installation', async (t) => {+ const updates = watchReleases({+ current: '0.1.7', arch: 'arm64',+ fetch: async () => releaseResponse([release('0.2.0-rc.2', { prerelease: true })]),+ log: quietLog(),+ })+ t.after(updates.stop)+ assert.equal(await updates.latest(), null)+ })++ test('includes prereleases when the installed version is a prerelease', async (t) => {+ const updates = watchReleases({+ current: '0.2.0-rc.1', arch: 'arm64',+ fetch: async () => releaseResponse([release('0.2.0-rc.2', { prerelease: true })]),+ log: quietLog(),+ })+ t.after(updates.stop)+ assert.deepEqual(await updates.latest(), {+ version: '0.2.0-rc.2', page: 'https://github.com/Fei2411/DeepSeek-Bot/releases/tag/v0.2.0-rc.2',+ })+ })++ test('ignores draft releases', async (t) => {+ const updates = watchReleases({+ current: '0.1.7', arch: 'arm64',+ fetch: async () => releaseResponse([release('0.1.9', { draft: true })]),+ log: quietLog(),+ })+ t.after(updates.stop)+ assert.equal(await updates.latest(), null)+ })++ test('chooses the highest newer release with a matching DMG', async (t) => {+ const updates = watchReleases({+ current: '0.1.7', arch: 'arm64',+ fetch: async () => releaseResponse([release('0.1.9'), release('0.1.10'), release('0.1.8')]),+ log: quietLog(),+ })+ t.after(updates.stop)+ assert.deepEqual(await updates.latest(), {+ version: '0.1.10', page: 'https://github.com/Fei2411/DeepSeek-Bot/releases/tag/v0.1.10',+ })+ })+test('logs a rejected prompt without an unhandled rejection', async (t) => {const unhandled = []const note = error => { unhandled.push(error) }@@ -175,7 +263,7 @@ describe('watchReleases', () => {t.after(() => { process.off('unhandledRejection', note) })const log = quietLog()const updates = watchReleases({- current: '0.1.7', fetch: async () => releaseResponse(release('0.1.9')),+ current: '0.1.7', arch: 'arm64', fetch: async () => releaseResponse([release('0.1.9')]),ask: async () => { throw new Error('dialog failed') }, open: () => {}, log,})t.after(updates.stop)@@ -189,7 +277,8 @@ describe('watchReleases', () => {t.mock.timers.enable({ apis: ['setInterval'] })let checks = 0const updates = watchReleases({- current: '0.1.7', fetch: async () => { checks += 1; return releaseResponse(release('0.1.7')) }, log: quietLog(),+ current: '0.1.7', arch: 'arm64',+ fetch: async () => { checks += 1; return releaseResponse([release('0.1.7')]) }, log: quietLog(),})await updates.latest()updates.stop()diff --git a/docs/plans/2026-10-16-desktop-app.md b/docs/plans/2026-10-16-desktop-app.mdindex 6f57d509..c705871a 100644--- a/docs/plans/2026-10-16-desktop-app.md+++ b/docs/plans/2026-10-16-desktop-app.md@@ -104,4 +104,4 @@- 2026-10-18:自己的界面先停下,窗口换回 DSH 的网页前端和系统标题栏;引擎的 profile 换回 `dsh-base`、`dsh-web-app`、`ds-bot`,PR #323。- 2026-10-18:首次启动选两个位置、从用户 DSH 导入团队的细节,PR #324。- 2026-10-19:Windows 自动更新的细节;发 Release 时传 Windows 安装包;应用里的插件不再自己查更新,PR #329。-- 2026-10-19:macOS 出两个 dmg(Apple 芯片 arm64、Intel x64),各在同架构的 runner 上打包;ad-hoc 签名(不签名的话下载后会显示"已损坏");有新版时弹框,点「下载」打开发布页,不自动安装;CI 和发版都打包并检查。+- 2026-10-19:macOS 出两个 dmg(Apple 芯片 arm64、Intel x64),各在同架构的 runner 上打包;ad-hoc 签名(不签名的话下载后会显示"已损坏");有新版时弹框,点「下载」打开发布页,不自动安装;新版的 dmg 传上去以后才提示;CI 和发版都打包并检查。