Skip to content

7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.

TypeScript

feat(desktop): add Intel macOS release builds (#1236)

Tashfeen4ce383f423be
diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml
index 5148c0c5..9072f52d 100644
--- a/.github/workflows/desktop-release.yml
+++ b/.github/workflows/desktop-release.yml
@@ -46,10 +46,22 @@ jobs:
desktop/dist-electron/*.blockmap
desktop/dist-electron/latest.yml
- os: macos-latest
+ arch: arm64
ebArgs: --mac --arm64
- artifact: macos-dmg
+ artifact: macos-installer-arm64
glob: |
desktop/dist-electron/*.dmg
+ desktop/dist-electron/*.zip
+ desktop/dist-electron/*.blockmap
+ desktop/dist-electron/latest-mac.yml
+ # Build and exercise better-sqlite3 natively on Intel (#1232).
+ - os: macos-15-intel
+ arch: x64
+ ebArgs: --mac --x64
+ artifact: macos-installer-x64
+ glob: |
+ desktop/dist-electron/*.dmg
+ desktop/dist-electron/*.zip
desktop/dist-electron/*.blockmap
desktop/dist-electron/latest-mac.yml
- os: ubuntu-latest
@@ -116,7 +128,7 @@ jobs:
- name: Validate macOS signing credentials
id: maccreds
- if: matrix.os == 'macos-latest' && startsWith(github.ref, 'refs/tags/')
+ if: runner.os == 'macOS' && startsWith(github.ref, 'refs/tags/')
shell: bash
env:
CSC_LINK: ${{ secrets.MACOS_CSC_LINK }}
@@ -248,7 +260,7 @@ jobs:
# returns as soon as it is set, so leaving that pair configured would
# silently shadow the API key — the two cannot coexist. The API key
# also does not expire the way an app-specific password does.
- CSC_IDENTITY_AUTODISCOVERY: ${{ matrix.os == 'macos-latest' && startsWith(github.ref, 'refs/tags/') && steps.maccreds.outputs.signed == 'true' && 'true' || 'false' }}
+ CSC_IDENTITY_AUTO_DISCOVERY: ${{ runner.os == 'macOS' && startsWith(github.ref, 'refs/tags/') && steps.maccreds.outputs.signed == 'true' && 'true' || 'false' }}
# No CSC_LINK / CSC_KEY_PASSWORD: the step above imported the
# certificate into a keychain of our own and exported CSC_KEYCHAIN +
# CSC_NAME through $GITHUB_ENV. Setting CSC_LINK here would send
@@ -285,6 +297,19 @@ jobs:
# uploads. The "Attach installer to release" step below owns publishing.
npx --no-install electron-builder ${{ matrix.ebArgs }} --publish never
+ - name: Smoke-test packaged macOS backend
+ if: runner.os == 'macOS'
+ shell: bash
+ env:
+ EXPECTED_ARCH: ${{ matrix.arch }}
+ run: |
+ set -euo pipefail
+ app_dir=desktop/dist-electron/mac
+ if [ "$EXPECTED_ARCH" = arm64 ]; then app_dir="$app_dir-arm64"; fi
+ app="$app_dir/FreeLLMAPI.app"
+ ELECTRON_RUN_AS_NODE=1 "$app/Contents/MacOS/FreeLLMAPI" \
+ desktop/scripts/smoke-mac-package.mjs "$app" "$EXPECTED_ARCH"
+
# electron-builder notarizes and staples the .app, then wraps it in a DMG
# it never submits. The DMG is the file users download, so it is the file
# macOS quarantines and assesses — until it carries its own stapled
@@ -347,7 +372,8 @@ jobs:
# installers. So upload directly and leave the release metadata, which this
# job has no business rewriting, exactly as the release author left it.
- name: Attach installer to release
- if: startsWith(github.ref, 'refs/tags/')
+ # The macOS finalizer uploads both architectures and ONE manifest.
+ if: runner.os != 'macOS' && startsWith(github.ref, 'refs/tags/')
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -373,3 +399,46 @@ jobs:
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --generate-notes
fi
gh release upload "$GITHUB_REF_NAME" "${files[@]}" --clobber
+
+ macos-release:
+ name: Verify and combine macOS artifacts
+ needs: build
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
+ with:
+ node-version: '20'
+ - name: Install metadata tooling
+ run: npm --prefix desktop ci --ignore-scripts
+ - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
+ with:
+ pattern: macos-installer-*
+ path: artifacts
+ - name: Verify artifacts and merge update metadata
+ run: |
+ node desktop/scripts/merge-mac-update-metadata.mjs \
+ artifacts/macos-installer-arm64 artifacts/macos-installer-x64 \
+ artifacts/latest-mac.yml
+ - name: Upload combined update metadata
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: macos-update-metadata
+ path: artifacts/latest-mac.yml
+ if-no-files-found: error
+ - name: Attach both macOS installers to release
+ if: startsWith(github.ref, 'refs/tags/')
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ shell: bash
+ run: |
+ set -euo pipefail
+ if ! gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
+ gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --generate-notes
+ fi
+ # Upload payloads first, then the manifest that advertises them.
+ gh release upload "$GITHUB_REF_NAME" \
+ artifacts/macos-installer-*/*.dmg \
+ artifacts/macos-installer-*/*.zip \
+ artifacts/macos-installer-*/*.blockmap --clobber
+ gh release upload "$GITHUB_REF_NAME" artifacts/latest-mac.yml --clobber
diff --git a/README.md b/README.md
index 0e781053..b0630147 100644
--- a/README.md
+++ b/README.md
@@ -198,6 +198,8 @@ A native menu-bar app lives in [`desktop/`](./desktop): the entire router + dash
**[Download from Releases](https://github.com/tashfeenahmed/freellmapi/releases/latest)** — the macOS `.dmg` and the Windows `.exe` installer are attached to every release. No account or password to set up: the only credential you need is the unified API key from the tray popover. Build-from-source steps and where your data lives: [docs/en/install/01-install.md#desktop-app](docs/en/install/01-install.md#desktop-app).
+For macOS 12 Monterey or later, choose **arm64 (Apple Silicon)** or **x64 (Intel)**. Both Mac builds also include a ZIP download.
+
## Works with OpenAI-compatible clients
Anything that can target an OpenAI-compatible base URL works: set it to `http://localhost:3001/v1` with the unified key from the dashboard. **Claude Code**, **Codex CLI**, **Cline / Roo Code**, **Continue** (including inline autocomplete), **Aider**, **opencode**, and **Cursor** each have a short recipe in **[docs/en/clients/01-agent-clients.md](docs/en/clients/01-agent-clients.md)** — and the router doubles as an MCP server your agents can introspect mid-session.
diff --git a/README.zh-cn.md b/README.zh-cn.md
index 8e0a8af3..0cf577ed 100644
--- a/README.zh-cn.md
+++ b/README.zh-cn.md
@@ -187,6 +187,8 @@ curl -fsSL https://freellmapi.co/install.sh | bash
**[从 Releases 下载](https://github.com/tashfeenahmed/freellmapi/releases/latest)** —— 每个版本都附带 macOS 的 `.dmg` 和 Windows 的 `.exe` 安装包。不需要注册账号或设置密码:你唯一需要的凭据就是托盘悬浮窗里的统一 API 密钥。从源码构建的步骤,以及数据存放位置,见 [docs/zh-cn/install/01-install.md#桌面应用](docs/zh-cn/install/01-install.md#桌面应用)。
+macOS 要求 12 Monterey 或更高版本;Apple Silicon 请选择 **arm64**,Intel 请选择 **x64**。两种 Mac 构建都提供 ZIP 下载。
+
## 兼容 OpenAI 的客户端
任何能指定 OpenAI 兼容 base URL 的东西都能用:把它设成 `http://localhost:3001/v1`,配上仪表盘里的统一密钥。**Claude Code**、**Codex CLI**、**Cline / Roo Code**、**Continue**(含行内补全)、**Aider**、**opencode** 和 **Cursor** 在 **[docs/zh-cn/clients/01-agent-clients.md](docs/zh-cn/clients/01-agent-clients.md)** 里各有一段简短配方。此外路由器本身还兼作 MCP 服务,你的智能体可以在会话中随时查询它。
diff --git a/desktop/README.md b/desktop/README.md
index 6c2cf108..4d5fb8d1 100644
--- a/desktop/README.md
+++ b/desktop/README.md
@@ -5,15 +5,18 @@ runs the whole router locally on `127.0.0.1:31415`, with a dark-glass tray
popover (live 24h request chart, quick stats, copy URL/key) and the full
dashboard in a native-feeling window.
-The app lives in the main repo (`desktop/`) and builds against the server and
-client sources in the same checkout — no extra setup, no published binaries:
-**you build it yourself** (a few minutes, commands below).
+Download an installer from [Releases](https://github.com/tashfeenahmed/freellmapi/releases/latest),
+or build against the server and client sources in this checkout.
+
+On macOS, choose **arm64** for Apple Silicon (M-series) or **x64** for Intel.
+Both require **macOS 12 Monterey or later**. Each architecture has a DMG
+installer and a ZIP containing the app.
## Prerequisites
- Node.js 20+
- A native build toolchain for `better-sqlite3`:
- - **macOS** — Xcode Command Line Tools (`xcode-select --install`)
+ - **macOS** — Xcode Command Line Tools (`xcode-select --install`) and Python 3
- **Windows** — Visual Studio Build Tools ("Desktop development with C++")
## Build it yourself
@@ -24,9 +27,16 @@ From the **repo root** (one-time client build + package):
npm install
npm install --prefix desktop # install desktop dependencies
npm run desktop:dist # macOS → desktop/dist-electron/FreeLLMAPI-…-arm64.dmg
+npm run desktop:dist:mac:x64 # Intel Mac → desktop/dist-electron/FreeLLMAPI-…-x64.dmg
npm run desktop:dist:win # Windows → desktop/dist-electron/FreeLLMAPI-…-x64 installer
```
+Both Mac commands also produce a ZIP. Prefer building on the matching Mac
+architecture so `better-sqlite3` can be rebuilt and tested natively. The release
+workflow does this in separate Apple Silicon and Intel jobs, signs/notarizes
+both, then verifies their final checksums and publishes one combined
+`latest-mac.yml`.
+
> Locally built apps don't carry the macOS quarantine attribute or Windows
> Mark-of-the-Web, so they launch without Gatekeeper/SmartScreen warnings —
> no code signing needed.
diff --git a/desktop/electron-builder.yml b/desktop/electron-builder.yml
index 511c6177..e17960a4 100644
--- a/desktop/electron-builder.yml
+++ b/desktop/electron-builder.yml
@@ -29,6 +29,7 @@ extraResources:
- from: client-dist
to: client-dist
mac:
+ artifactName: "${productName}-${version}-${arch}.${ext}"
category: public.app-category.developer-tools
icon: assets/icon.icns
hardenedRuntime: true
@@ -36,10 +37,12 @@ mac:
entitlements: assets/entitlements.mac.plist
entitlementsInherit: assets/entitlements.mac.inherit.plist
notarize: true
+ # Select the architecture with --arm64 or --x64 in the build command.
+ # Per-target arch lists override that selection and make each CI job build
+ # both architectures, including the native SQLite module for the other CPU.
target:
- target: dmg
- arch:
- - arm64
+ - target: zip
extendInfo:
LSUIElement: 1
# The DMG is the file people actually download, so it is the file macOS
diff --git a/desktop/package-lock.json b/desktop/package-lock.json
index 266f3238..629ff18c 100644
--- a/desktop/package-lock.json
+++ b/desktop/package-lock.json
@@ -17,6 +17,7 @@
"electron": "^38.8.6",
"electron-builder": "^25.1.8",
"esbuild": "^0.24.0",
+ "js-yaml": "^4.2.0",
"typescript": "^5.8.0",
"vitest": "^3.2.4"
}
diff --git a/desktop/package.json b/desktop/package.json
index 995058ab..4eabf94e 100644
--- a/desktop/package.json
+++ b/desktop/package.json
@@ -20,6 +20,7 @@
"rebuild:native": "electron-rebuild -f -w better-sqlite3",
"dev": "npm run build:all && electron .",
"dist": "npm run build:all && npm run stage:client && electron-builder --mac --arm64 --publish never",
+ "dist:mac:x64": "npm run build:all && npm run stage:client && electron-builder --mac --x64 --publish never",
"dist:win": "npm run build:all && npm run stage:client && electron-builder --win --x64 --publish never",
"dist:linux": "npm run build:all && npm run stage:client && electron-builder --linux --x64 --publish never",
"test": "vitest run"
@@ -34,6 +35,7 @@
"electron": "^38.8.6",
"electron-builder": "^25.1.8",
"esbuild": "^0.24.0",
+ "js-yaml": "^4.2.0",
"typescript": "^5.8.0",
"vitest": "^3.2.4"
}
diff --git a/desktop/scripts/merge-mac-update-metadata.mjs b/desktop/scripts/merge-mac-update-metadata.mjs
new file mode 100644
index 00000000..00fde930
--- /dev/null
+++ b/desktop/scripts/merge-mac-update-metadata.mjs
@@ -0,0 +1,60 @@
+// Each macOS job hashes its final (including stapling) artifacts independently.
+// Publish one manifest only after both jobs finish, otherwise --clobber makes
+// the last job erase the other architecture's update entries.
+import { readFileSync, statSync, writeFileSync } from 'node:fs';
+import { basename, join, resolve } from 'node:path';
+import { pathToFileURL } from 'node:url';
+import yaml from 'js-yaml';
+import { hashFile } from './refresh-mac-update-metadata.mjs';
+
+export function mergeMacUpdateMetadata(arm64Directory, x64Directory) {
+ const manifests = [];
+ const files = [];
+ for (const [arch, directory] of [['arm64', arm64Directory], ['x64', x64Directory]]) {
+ const manifest = yaml.load(readFileSync(join(directory, 'latest-mac.yml'), 'utf8'), {
+ schema: yaml.JSON_SCHEMA,
+ });
+ if (!manifest || typeof manifest.version !== 'string' || !Array.isArray(manifest.files)) {
+ throw new Error(`Invalid ${arch} update manifest`);
+ }
+ if (manifests.length && manifest.version !== manifests[0].version) {
+ throw new Error('macOS update manifests have different versions');
+ }
+ const extensions = new Set();
+ for (const file of manifest.files) {
+ const name = file?.url;
+ if (typeof name !== 'string' || basename(name) !== name ||
+ (!name.endsWith(`-${arch}.dmg`) && !name.endsWith(`-${arch}.zip`))) {
+ throw new Error(`Unexpected ${arch} artifact: ${name}`);
+ }
+ if (files.some((entry) => entry.url === name)) {
+ throw new Error(`Duplicate macOS artifact: ${name}`);
+ }
+ const artifactPath = join(directory, name);
+ if (statSync(artifactPath).size !== file.size || hashFile(artifactPath) !== file.sha512) {
+ throw new Error(`Hash or size mismatch for ${name}; refresh metadata after stapling`);
+ }
+ extensions.add(name.endsWith('.dmg') ? 'dmg' : 'zip');
+ files.push(file);
+ }
+ if (!extensions.has('dmg') || !extensions.has('zip')) {
+ throw new Error(`Missing ${arch} DMG or ZIP`);
+ }
+ if (!manifest.files.some((file) => file.url === manifest.path && file.sha512 === manifest.sha512)) {
+ throw new Error(`Invalid ${arch} legacy path/sha512`);
+ }
+ manifests.push(manifest);
+ }
+ // Preserve the existing arm64 legacy fields. Modern clients select their
+ // architecture from files[], which now contains both architectures.
+ return yaml.dump({ ...manifests[0], files }, { lineWidth: -1 });
+}
+
+if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
+ const [arm64Directory, x64Directory, outputPath] = process.argv.slice(2);
+ if (!arm64Directory || !x64Directory || !outputPath) {
+ throw new Error('usage: merge-mac-update-metadata.mjs <arm64 directory> <x64 directory> <output.yml>');
+ }
+ writeFileSync(outputPath, mergeMacUpdateMetadata(arm64Directory, x64Directory));
+ console.log(`Merged and verified macOS update metadata: ${outputPath}`);
+}
diff --git a/desktop/scripts/smoke-mac-package.mjs b/desktop/scripts/smoke-mac-package.mjs
new file mode 100644
index 00000000..4bf330e3
--- /dev/null
+++ b/desktop/scripts/smoke-mac-package.mjs
@@ -0,0 +1,71 @@
+// Run with the PACKAGED Electron executable and ELECTRON_RUN_AS_NODE=1.
+// This exercises its Electron ABI, bundled server, native SQLite module and
+// HTTP API without opening windows or using the developer's app data.
+import assert from 'node:assert/strict';
+import { execFileSync } from 'node:child_process';
+import { mkdtempSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join, resolve } from 'node:path';
+import { pathToFileURL } from 'node:url';
+
+const [appPath, expectedArch] = process.argv.slice(2);
+assert.ok(appPath && ['arm64', 'x64'].includes(expectedArch), 'usage: smoke-mac-package.mjs <app> <arm64|x64>');
+assert.equal(process.platform, 'darwin');
+assert.ok(process.versions.electron, 'Must run under the packaged Electron executable');
+assert.equal(process.arch, expectedArch);
+const resources = resolve(appPath, 'Contents/Resources');
+const sqliteBinary = join(resources, 'app.asar.unpacked/node_modules/better-sqlite3/build/Release/better_sqlite3.node');
+const nativeArch = expectedArch === 'x64' ? 'x86_64' : 'arm64';
+for (const binary of [process.execPath, sqliteBinary]) {
+ assert.equal(execFileSync('lipo', ['-archs', binary], { encoding: 'utf8' }).trim(), nativeArch);
+}
+
+const directory = mkdtempSync(join(tmpdir(), 'freellmapi-package-smoke-'));
+// Never load repository .env settings or start catalog downloads in this test.
+process.chdir(directory);
+process.env.FREEAPI_ENV_PATH = join(directory, '.env');
+process.env.CATALOG_SYNC_DISABLED = '1';
+let server;
+let db;
+const timeout = setTimeout(() => {
+ console.error('Packaged macOS backend smoke test timed out');
+ process.exit(1);
+}, 60_000);
+let exitCode = 1;
+try {
+ const backend = await import(pathToFileURL(join(resources, 'app.asar/build/server.mjs')).href);
+ ({ server } = await backend.startServer({
+ dbPath: join(directory, 'smoke.db'),
+ clientDist: join(resources, 'client-dist'),
+ host: '127.0.0.1',
+ preferredPort: 0,
+ }));
+ db = backend.getDb();
+ db.exec('CREATE TABLE package_smoke (value TEXT NOT NULL)');
+ db.prepare('INSERT INTO package_smoke VALUES (?)').run(expectedArch);
+ assert.equal(db.prepare('SELECT value FROM package_smoke').get().value, expectedArch);
+ assert.ok(backend.ensureSessionToken());
+ const baseUrl = `http://127.0.0.1:${server.address().port}`;
+ const dashboard = await fetch(baseUrl, { signal: AbortSignal.timeout(10_000) });
+ assert.equal(dashboard.status, 200);
+ assert.match(await dashboard.text(), /<html/i);
+ const models = await fetch(`${baseUrl}/v1/models`, {
+ headers: { Authorization: `Bearer ${backend.getUnifiedApiKey()}` },
+ signal: AbortSignal.timeout(10_000),
+ });
+ assert.equal(models.status, 200);
+ assert.ok(Array.isArray((await models.json()).data));
+ console.log(`Packaged ${expectedArch} backend passed: SQLite, session, dashboard and /v1/models`);
+ exitCode = 0;
+} catch (error) {
+ console.error(error);
+} finally {
+ clearTimeout(timeout);
+ server?.closeAllConnections();
+ if (server) await new Promise((done) => server.close(done));
+ db?.close();
+ process.chdir(tmpdir());
+ rmSync(directory, { recursive: true, force: true });
+ // The production backend starts recurring maintenance timers.
+ process.exit(exitCode);
+}
diff --git a/desktop/src/__tests__/merge-mac-update-metadata.test.ts b/desktop/src/__tests__/merge-mac-update-metadata.test.ts
new file mode 100644
index 00000000..05f2626c
--- /dev/null
+++ b/desktop/src/__tests__/merge-mac-update-metadata.test.ts
@@ -0,0 +1,110 @@
+import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+import { createRequire } from 'node:module';
+// @ts-expect-error -- plain .mjs build script, no types
+import { mergeMacUpdateMetadata } from '../../scripts/merge-mac-update-metadata.mjs';
+// @ts-expect-error -- plain .mjs build script, no types
+import { hashFile, rewriteUpdateMetadata } from '../../scripts/refresh-mac-update-metadata.mjs';
+
+const yaml = createRequire(import.meta.url)('js-yaml');
+
+describe('macOS release metadata', () => {
+ let directory: string;
+ let arm64: string;
+ let x64: string;
+
+ function fixture(arch: string) {
+ const dir = join(directory, arch);
+ mkdirSync(dir);
+ const files = ['zip', 'dmg'].map((extension) => {
+ const url = `FreeLLMAPI-0.10.0-${arch}.${extension}`;
+ const bytes = Buffer.from(`${arch} ${extension} package`);
+ writeFileSync(join(dir, url), bytes);
+ return { url, sha512: hashFile(join(dir, url)), size: bytes.length };
+ });
+ writeFileSync(join(dir, 'latest-mac.yml'), yaml.dump({
+ version: '0.10.0', files, path: files[0].url, sha512: files[0].sha512,
+ releaseDate: '2026-09-15T12:00:00.000Z',
+ }, { lineWidth: -1 }));
+ return dir;
+ }
+
+ function changeManifest(dir: string, update: (manifest: any) => void) {
+ const path = join(dir, 'latest-mac.yml');
+ const manifest = yaml.load(readFileSync(path, 'utf8'));
+ update(manifest);
+ writeFileSync(path, yaml.dump(manifest, { lineWidth: -1 }));
+ }
+
+ beforeEach(() => {
+ directory = mkdtempSync(join(tmpdir(), 'mac-metadata-test-'));
+ arm64 = fixture('arm64');
+ x64 = fixture('x64');
+ });
+ afterEach(() => rmSync(directory, { recursive: true, force: true }));
+
+ it('includes both architectures without losing the legacy ZIP or release date', () => {
+ const merged: any = yaml.load(mergeMacUpdateMetadata(arm64, x64));
+ expect(merged.files.map((file: any) => file.url)).toEqual([
+ 'FreeLLMAPI-0.10.0-arm64.zip', 'FreeLLMAPI-0.10.0-arm64.dmg',
+ 'FreeLLMAPI-0.10.0-x64.zip', 'FreeLLMAPI-0.10.0-x64.dmg',
+ ]);
+ expect(merged.path).toBe('FreeLLMAPI-0.10.0-arm64.zip');
+ expect(merged.sha512).toBe(merged.files[0].sha512);
+ expect(merged.releaseDate).toBe('2026-09-15T12:00:00.000Z');
+ });
+
+ it('accepts a stapled DMG only after its hash and size have been refreshed', () => {
+ const fileName = 'FreeLLMAPI-0.10.0-x64.dmg';
+ const bytes = Buffer.from('Intel DMG with its new notarization ticket');
+ const path = join(x64, fileName);
+ writeFileSync(path, bytes);
+ expect(() => mergeMacUpdateMetadata(arm64, x64)).toThrow('Hash or size mismatch');
+ const manifestPath = join(x64, 'latest-mac.yml');
+ const sha512 = hashFile(path);
+ writeFileSync(manifestPath, rewriteUpdateMetadata(readFileSync(manifestPath, 'utf8'), {
+ fileName, sha512, size: bytes.length,
+ }));
+ const merged: any = yaml.load(mergeMacUpdateMetadata(arm64, x64));
+ expect(merged.files.find((file: any) => file.url === fileName)).toEqual({
+ url: fileName, sha512, size: bytes.length,
+ });
+ });
+
+ it('rejects a checksum mismatch even when the file length is unchanged', () => {
+ const path = join(x64, 'FreeLLMAPI-0.10.0-x64.zip');
+ writeFileSync(path, Buffer.alloc(readFileSync(path).length));
+ expect(() => mergeMacUpdateMetadata(arm64, x64)).toThrow('Hash or size mismatch');
+ });
+
+ it('rejects mismatched releases', () => {
+ changeManifest(x64, (manifest) => { manifest.version = '0.9.9'; });
+ expect(() => mergeMacUpdateMetadata(arm64, x64)).toThrow('different versions');
+ });
+
+ it('requires a ZIP and DMG for each architecture', () => {
+ changeManifest(x64, (manifest) => { manifest.files.pop(); });
+ expect(() => mergeMacUpdateMetadata(arm64, x64)).toThrow('Missing x64 DMG or ZIP');
+ });
+
+ it('rejects duplicate artifacts', () => {
+ changeManifest(x64, (manifest) => { manifest.files.push(manifest.files[0]); });
+ expect(() => mergeMacUpdateMetadata(arm64, x64)).toThrow('Duplicate macOS artifact');
+ });
+
+ it('rejects a manifest from the wrong architecture', () => {
+ expect(() => mergeMacUpdateMetadata(arm64, arm64)).toThrow('Unexpected x64 artifact');
+ });
+
+ it('requires the legacy checksum to match its artifact', () => {
+ changeManifest(arm64, (manifest) => { manifest.sha512 = 'stale'; });
+ expect(() => mergeMacUpdateMetadata(arm64, x64)).toThrow('Invalid arm64 legacy path/sha512');
+ });
+
+ it('fails when an architecture was not downloaded', () => {
+ rmSync(join(x64, 'latest-mac.yml'));
+ expect(() => mergeMacUpdateMetadata(arm64, x64)).toThrow();
+ });
+});
diff --git a/docs/en/desktop/01-desktop-app.md b/docs/en/desktop/01-desktop-app.md
index 633e3f1e..461ef823 100644
--- a/docs/en/desktop/01-desktop-app.md
+++ b/docs/en/desktop/01-desktop-app.md
@@ -4,7 +4,7 @@
## Package manifest
-`desktop/package.json` `[email protected]` — Electron `38.8.6`, `[email protected]`, `[email protected]`, `[email protected]`. Entry `build/main.mjs` (`type: module`). AppId `com.freellmapi.desktop`, publish `github:tashfeenahmed/freellmapi` (`desktop/electron-builder.yml`). `asar` + `client-dist` in `extraResources`; per-OS signing targets (mac `dmg` `arm64` signed/notarized/stapled via `refresh-mac-update-metadata.mjs`, win `nsis`+`zip` `x64`, linux `AppImage`+`deb`+`tar.xz`+`rpm` `x64` since #981 `d8fae97`).
+`desktop/package.json` `[email protected]` — Electron `38.8.6`, `[email protected]`, `[email protected]`, `[email protected]`. Entry `build/main.mjs` (`type: module`). AppId `com.freellmapi.desktop`, publish `github:tashfeenahmed/freellmapi` (`desktop/electron-builder.yml`). `asar` + `client-dist` in `extraResources`; per-OS signing targets (mac `dmg`+`zip` `arm64`+`x64` signed/notarized/stapled via `refresh-mac-update-metadata.mjs`, win `nsis`+`zip` `x64`, linux `AppImage`+`deb`+`tar.xz`+`rpm` `x64` since #981 `d8fae97`).
## Build pipeline
diff --git a/docs/en/install/01-install.md b/docs/en/install/01-install.md
index fa2111ab..efc9f946 100644
--- a/docs/en/install/01-install.md
+++ b/docs/en/install/01-install.md
@@ -260,12 +260,15 @@ request stats.
**[Download from Releases](https://github.com/tashfeenahmed/freellmapi/releases/latest)** — the macOS `.dmg` and the Windows `.exe` installer are built and attached to every release by the [`desktop-release`](../../../.github/workflows/desktop-release.yml) workflow. Or build it from this repo in a few minutes:
+**Mac downloads:** choose `arm64` for Apple Silicon or `x64` for Intel. Both require macOS 12 Monterey or later and include DMG and ZIP downloads.
+
> **Note for Windows users building from source:** Building the desktop app requires compiling native SQLite modules for Electron. You must have [Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) installed (specifically the "Desktop development with C++" workload) and Python installed before running `npm install`.
```bash
npm install
npm install --prefix desktop # install desktop dependencies
npm run desktop:dist # macOS → desktop/dist-electron/FreeLLMAPI-…-arm64.dmg
+npm run desktop:dist:mac:x64 # Intel Mac → desktop/dist-electron/FreeLLMAPI-…-x64.dmg
npm run desktop:dist:win # Windows → "desktop/dist-electron/FreeLLMAPI Setup ….exe"
```
diff --git a/docs/zh-cn/desktop/01-desktop-app.md b/docs/zh-cn/desktop/01-desktop-app.md
index 247387d9..b9726e4d 100644
--- a/docs/zh-cn/desktop/01-desktop-app.md
+++ b/docs/zh-cn/desktop/01-desktop-app.md
@@ -4,7 +4,7 @@
## 包清单
-`desktop/package.json` `[email protected]` —— Electron `38.8.6`、`[email protected]`、`[email protected]`、`[email protected]`。入口 `build/main.mjs`(`type: module`)。AppId `com.freellmapi.desktop`,发布 `github:tashfeenahmed/freellmapi`(`desktop/electron-builder.yml`)。`asar` + `client-dist` 位于 `extraResources`;按系统划分的签名目标(mac `dmg` `arm64` 经 `refresh-mac-update-metadata.mjs` 签名/公证/钉装、win `nsis`+`zip` `x64`、linux `AppImage`+`deb`+`tar.xz`+`rpm` `x64` 自 #981 `d8fae97` 起)。
+`desktop/package.json` `[email protected]` —— Electron `38.8.6`、`[email protected]`、`[email protected]`、`[email protected]`。入口 `build/main.mjs`(`type: module`)。AppId `com.freellmapi.desktop`,发布 `github:tashfeenahmed/freellmapi`(`desktop/electron-builder.yml`)。`asar` + `client-dist` 位于 `extraResources`;按系统划分的签名目标(mac `dmg`+`zip` `arm64`+`x64` 经 `refresh-mac-update-metadata.mjs` 签名/公证/钉装、win `nsis`+`zip` `x64`、linux `AppImage`+`deb`+`tar.xz`+`rpm` `x64` 自 #981 `d8fae97` 起)。
## 构建流水线
diff --git a/docs/zh-cn/install/01-install.md b/docs/zh-cn/install/01-install.md
index e9368c4e..143fc853 100644
--- a/docs/zh-cn/install/01-install.md
+++ b/docs/zh-cn/install/01-install.md
@@ -229,12 +229,15 @@ FREEAPI_DB_BACKUP_INTERVAL_MS=300000
**[从 Releases 下载](https://github.com/tashfeenahmed/freellmapi/releases/latest)** —— macOS 的 `.dmg` 和 Windows 的 `.exe` 安装包由 [`desktop-release`](../../../.github/workflows/desktop-release.yml) 工作流在每个版本发布时构建并附带。你也可以花几分钟从本仓库自己构建:
+**Mac 下载:** Apple Silicon 请选择 `arm64`,Intel 请选择 `x64`。两者都要求 macOS 12 Monterey 或更高版本,并提供 DMG 和 ZIP 下载。
+
> **Windows 用户从源码构建的注意事项:** 构建桌面应用需要为 Electron 编译原生 SQLite 模块。在执行 `npm install` 之前,你必须先装好 [Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/)(具体来说是「使用 C++ 的桌面开发」工作负载)以及 Python。
```bash
npm install
npm install --prefix desktop # 安装桌面端依赖
npm run desktop:dist # macOS → desktop/dist-electron/FreeLLMAPI-…-arm64.dmg
+npm run desktop:dist:mac:x64 # Intel Mac → desktop/dist-electron/FreeLLMAPI-…-x64.dmg
npm run desktop:dist:win # Windows → "desktop/dist-electron/FreeLLMAPI Setup ….exe"
```
diff --git a/package.json b/package.json
index 8416991a..958e1dbc 100644
--- a/package.json
+++ b/package.json
@@ -19,6 +19,7 @@
"test:migrations": "npm run test:migrations -w server",
"desktop:dev": "npm run build -w client && npm --prefix desktop run dev",
"desktop:dist": "npm run build -w client && npm --prefix desktop run dist",
+ "desktop:dist:mac:x64": "npm run build -w client && npm --prefix desktop run dist:mac:x64",
"desktop:dist:win": "npm run build -w client && npm --prefix desktop run dist:win",
"desktop:dist:linux": "npm run build -w client && npm --prefix desktop run dist:linux",
"db:migration:up": "npm run db:migration:up -w server",