Skip to content

Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.

feat(release): the signed update manifest, its editor, and the desktop release workflow

Salman Qureshi8b075e42ee62
diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml
new file mode 100644
index 00000000..7955dbf0
--- /dev/null
+++ b/.github/workflows/desktop-release.yml
@@ -0,0 +1,91 @@
+name: Desktop release
+
+# Builds signed Mercury Desktop bundles and the updater's latest.json into a
+# DRAFT GitHub release (desktop-v<version>). Run by hand only. Nothing reaches
+# users until a person publishes the draft and runs
+# `node scripts/promote-desktop-release.mjs <version>` (which copies latest.json
+# to website/static/desktop/ and records the release in the update manifest).
+#
+# Secrets: TAURI_SIGNING_PRIVATE_KEY, TAURI_SIGNING_PRIVATE_KEY_PASSWORD (the
+# updater key, docs/updates.md). Optional macOS signing: APPLE_CERTIFICATE,
+# APPLE_CERTIFICATE_PASSWORD, APPLE_SIGNING_IDENTITY, APPLE_ID, APPLE_PASSWORD,
+# APPLE_TEAM_ID.
+
+on:
+ workflow_dispatch:
+ inputs:
+ runtime_tag:
+ description: 'Runtime release the app installs on a fresh computer (empty = latest)'
+ required: false
+ default: ''
+
+permissions:
+ contents: write
+
+jobs:
+ bundle:
+ name: Bundle (${{ matrix.label }})
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - { os: macos-14, label: macOS arm64, args: '--target aarch64-apple-darwin', rust: aarch64-apple-darwin }
+ - { os: macos-14, label: macOS x64, args: '--target x86_64-apple-darwin', rust: x86_64-apple-darwin }
+ - { os: ubuntu-22.04, label: Linux x64, args: '', rust: '' }
+ - { os: windows-latest, label: Windows x64, args: '', rust: '' }
+ runs-on: ${{ matrix.os }}
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 22
+ cache: npm
+ cache-dependency-path: |
+ ui/package-lock.json
+ apps/desktop/package-lock.json
+ - name: Linux system libraries
+ if: runner.os == 'Linux'
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf libdbus-1-dev pkg-config
+ - uses: dtolnay/rust-toolchain@stable
+ with:
+ targets: ${{ matrix.rust }}
+ - uses: Swatinem/rust-cache@v2
+ with:
+ workspaces: apps/desktop/src-tauri
+ - run: npm ci --no-audit --no-fund
+ working-directory: ui
+ - run: npm ci --no-audit --no-fund
+ working-directory: apps/desktop
+ - name: Check the updater key is set
+ shell: bash
+ env:
+ TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
+ run: |
+ if [ -z "$TAURI_SIGNING_PRIVATE_KEY" ]; then
+ echo "::error::TAURI_SIGNING_PRIVATE_KEY is not set: updates could not be verified. Add it in the repository secrets."
+ exit 1
+ fi
+ - uses: tauri-apps/tauri-action@v0
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
+ TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
+ MERCURY_RUNTIME_TAG: ${{ inputs.runtime_tag }}
+ APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
+ APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
+ APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
+ APPLE_ID: ${{ secrets.APPLE_ID }}
+ APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
+ APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
+ with:
+ projectPath: apps/desktop
+ tagName: desktop-v__VERSION__
+ releaseName: Mercury Desktop __VERSION__
+ releaseBody: 'Draft: write the notes, publish, then run `node scripts/promote-desktop-release.mjs __VERSION__`.'
+ releaseDraft: true
+ prerelease: false
+ includeUpdaterJson: true
+ updaterJsonPreferNsis: true
+ args: ${{ matrix.args }} --config src-tauri/tauri.release.conf.json
diff --git a/.gitignore b/.gitignore
index f537d5a5..9d7f72a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,4 @@ website/static/install.ps1
# plugin-system tests (src/plugins/test-fixtures.ts)
.vitest-tmp/
+.desktop-notes.tmp.md
diff --git a/DECISIONS.md b/DECISIONS.md
index 1c12eea5..2a81bc0a 100644
--- a/DECISIONS.md
+++ b/DECISIONS.md
@@ -359,3 +359,13 @@
- **Hardening**: file endpoints follow symlinks and refuse Mercury's credentials always and keys/shell start-up files for remote callers; Mercury's own file and shell tools can't touch its login files; sign-in is limited per client on both endpoints (this computer never locked out), bcrypt is async with no username timing signal; sessions are stored hashed and cookies are `Secure` over https; cookie-authenticated changes need a same-origin Origin; nosniff/Referrer-Policy everywhere and `frame-ancestors 'none'` on pages; 64 KB body limit on sign-in; generic 500s; the provider check never sends the saved key to a different base URL; Discord and Slack approval buttons check who clicked.
- **Owner tools**: `/server` (terminal chat; also Mercury Desktop and attached terminals on this computer), `mercury server` (through the running Mercury when it's up, directly otherwise), `mercury doctor --security` and a one-line summary on every doctor run, the security log `~/.mercury/security/audit.jsonl`, and `/api/security/*`. Feature flag `security.remote`.
- **Consequence**: Through a tunnel, a remote device can do what the owner does in chat (subject to the permission mode), but it can't escalate, persist past revocation, or read secrets without the owner saying yes on a device they hold. Pairing a new device takes one tap. Known limits: a proxy that adds no forwarding header and rewrites Host to localhost looks local (the attach token still guards the most sensitive operations, and the docs/security check say to configure forwarding headers); an IP allow-list needs a tunnel that passes the client address; Ask Me prompts are answered by whoever is using the session, so a paired device is trusted like the owner while paired. Follow-ups: a Security section in Mercury Desktop's settings, QR pairing, per-device scopes (read-only devices), and the full remote-access docs.
+
+## ADR-036: One signed update manifest; updates that never leave you broken and never nag
+
+- **Context**: Before launch, Mercury needs to update itself and Mercury Desktop the way users expect from Chrome or VS Code, and sometimes must insist (a security fix). The old `mercury upgrade` removed the npm package before installing the new one, kept no backup, didn't restart and didn't check the result; the desktop updater was configured but never used; the server's update check was CLI-only and disagreed with `upgrade` about where "latest" comes from; nothing could tell people something after a release.
+- **Decision**:
+ - **One manifest** (`website/static/updates/manifest.json` + `.sig`, served at `mercuryagent.sh/updates/`, mirrored on GitHub raw): latest server (stable/dev) and desktop versions with notes, a `minimum` per app (`security` | `required`, with the reason people read), and `messages` (id, level, apps, version range, dates, link, dismissible). Signed with minisign using the desktop updater key, so one key covers both; verified by the runtime (Node, `src/updates/minisign.ts`) and the desktop (Rust, `minisign-verify`). Unverified, or older than one already seen (anti-replay `issuedAt`), means ignored. Offline or blocked means fail open, never blocked. Edited only with `scripts/update-manifest.mjs`, which refuses a required version nobody can install yet.
+ - **Server updates** (`src/updates/`, `GET/POST /api/updates…`): wait for running work (10 min, or "now"), download resumably with checksums, back up the binary/web assets and Mercury's top-level settings, then a detached worker stops Mercury, installs, starts it and checks `/api/health` reports the new version within 90 s; otherwise it restores the old version and settings and starts that. npm installs never remove the old package first. A version whose files aren't published yet is "not available yet", not a failure. Three real failures at one version stop all automatic offers for it. A remote device starting a server update needs the owner (ADR-035). `mercury upgrade` uses the same engine in the terminal.
+ - **Desktop**: Tauri updater for discovery, our own resumable download (Range/If-Range, retries, stall detection) with the package verified before it counts as ready; install on "Restart to update" or on quit. A Chrome-style top-right button whose colour rises with age (red at once for security), a panel with notes before you update and progress for the app and every connected server, "Later" for 24 h. A force-update screen for a verified minimum that only a ticked risk checklist gets past, until the next launch or 24 h, while the button stays red. "What's new" toasts after any update, once per version. Manifest messages as one toast (info) or a banner (warning/critical).
+ - **Releases**: `.github/workflows/desktop-release.yml` (manual) builds signed bundles and `latest.json` into a draft; `scripts/promote-desktop-release.mjs` copies `latest.json` to the website and records the release in the manifest. `scripts/publish.sh` reminds to record server releases.
+- **Consequence**: An update either finishes or puts you back where you were; nothing pops up uninvited except a verified required update; one key (`~/.tauri/mercury-updates.key` + password, also needed as GitHub secrets) controls what every install trusts, so losing it means desktop updates stop and must be replaced by a manual reinstall.
diff --git a/docs/updates.md b/docs/updates.md
new file mode 100644
index 00000000..7c1ef84c
--- /dev/null
+++ b/docs/updates.md
@@ -0,0 +1,134 @@
+# Updates: how Mercury and Mercury Desktop update (contract)
+
+One signed file says what's current, what's required and what to tell people.
+The server and the desktop app each read it, update themselves without breaking,
+and roll back on their own when the new version doesn't come up.
+
+## 1. The update manifest
+
+`https://mercuryagent.sh/updates/manifest.json` (source: `website/static/updates/manifest.json`)
+and its signature `manifest.json.sig` beside it. Fallback mirror:
+`https://raw.githubusercontent.com/cosmicstack-labs/mercury-agent/main/website/static/updates/manifest.json` (+ `.sig`).
+
+The signature is a minisign signature in the exact format `tauri signer sign` writes
+(base64 of the `.minisig` text), made with the same key that signs desktop update
+packages. The public key is the `plugins.updater.pubkey` of
+`apps/desktop/src-tauri/tauri.conf.json`; the runtime has the same string in
+`src/updates/public-key.ts`.
+
+Rules for readers:
+- A manifest whose signature doesn't verify is **ignored** (fall back to the plain
+ version look-ups: GitHub releases / npm). Never trust an unsigned "required".
+- Anti-replay: keep the highest `issuedAt` seen; a manifest with an older `issuedAt`
+ is ignored.
+- Fail open: no manifest (offline, blocked) never blocks the app.
+- Cache: refetch at most every 6 hours (a manual "Check for updates" bypasses it, at most once a minute).
+
+```jsonc
+{
+ "schema": 1,
+ "issuedAt": "2026-11-03T12:00:00Z",
+ "server": {
+ "channels": {
+ "stable": {
+ "version": "1.5.0",
+ "date": "2026-11-04",
+ "notes": "markdown — what's new, shown before and after updating",
+ "notesUrl": "https://github.com/cosmicstack-labs/mercury-agent/releases/tag/v1.5.0"
+ },
+ "dev": null
+ },
+ // Below this version you must update. null = nothing required.
+ "minimum": { "version": "1.4.2", "severity": "security", "reason": "Fixes …", "since": "2026-11-03" }
+ },
+ "desktop": {
+ "channels": { "stable": { "version": "0.2.0", "date": "…", "notes": "…", "notesUrl": "…" } },
+ "minimum": null
+ },
+ "messages": [
+ {
+ "id": "2026-11-launch", // dismissals are remembered by id
+ "title": "Mercury 1.5 is here",
+ "body": "markdown",
+ "level": "info", // info | warning | critical
+ "apps": ["desktop", "server"], // who shows it
+ "versions": "<1.5.0", // optional; space-separated comparators (>=, >, <=, <, =), all must hold
+ "startsAt": null, "endsAt": null, // optional ISO dates
+ "link": { "label": "Read more", "url": "https://…" },
+ "dismissible": true // false only for critical
+ }
+ ]
+}
+```
+
+`severity`: `security` | `required`. A "required" update is a **force update**: the
+app shows a full screen that can't be dismissed, with a way out that takes
+ticking every risk box (desktop); the server shows it in the CLI, doctor and on
+every client.
+
+## 2. Server update API (runtime)
+
+Feature flag `updates` in `/api/health` `features`.
+
+`GET /api/updates` (any signed-in client):
+```ts
+{
+ current: string, // running version
+ channel: 'stable' | 'dev',
+ install: 'binary' | 'npm' | 'source' | 'unknown',
+ canSelfUpdate: boolean, // false for source checkouts / unknown installs
+ cannotReason?: string,
+ latest: { version, date?, notes?, notesUrl? } | null,
+ updateAvailable: boolean,
+ required: { version, severity: 'security'|'required', reason } | null, // current < minimum
+ manifestVerified: boolean,
+ checkedAt: number | null,
+ job: UpdateJob | null, // the running or last job
+ blocked: { version, failures, lastError } | null, // 3 failed attempts at this version: stop retrying on our own
+ justUpdated: { from, to, at } | null, // set after a successful update, for "what's new"
+ messages: Message[], // server-audience messages that apply to this version
+}
+```
+
+`POST /api/updates/check` → same body, refreshed (rate limited to once a minute).
+
+`POST /api/updates/server` `{ version?: string, now?: boolean }` → 202 `{ job }`.
+This computer: allowed. Remote device: owner approval (428, `requireOwner` id
+`server.update`). 409 `{ job }` while a job runs. `now: true` skips waiting for
+running work to finish.
+
+`POST /api/updates/server/cancel` → only before the old version is stopped.
+
+```ts
+type UpdateJob = {
+ id: string,
+ from: string, to: string,
+ state: 'waiting-idle' | 'downloading' | 'verifying' | 'backing-up' | 'stopping'
+ | 'installing' | 'starting' | 'checking'
+ | 'done' | 'rolled-back' | 'failed' | 'cancelled',
+ percent: number | null, // overall 0–100
+ bytes?: number, total?: number, // download
+ message: string, // human sentence for the current step
+ startedAt: number, updatedAt: number,
+ error?: string,
+ log: string[], // last 40 lines
+ attempt: number,
+}
+```
+
+The daemon waits for running work (up to 10 minutes; `now` skips), downloads
+(resumable, verified), backs up, then hands over to a detached worker process
+that stops the daemon, installs, starts it and checks `/api/health` reports the
+new version. Health doesn't come back in 90 s → restore the old version and
+config, start it, `rolled-back`. The job lives in `~/.mercury/updates/job.json`
+so the new (or restored) daemon serves it; clients poll `GET /api/updates`
+(the daemon is down for a few seconds in between — keep polling `/api/health`).
+
+## 3. Desktop app
+
+The desktop checks itself (Tauri updater, resumable download in Rust, minisign
+verified), reads the manifest (verified in Rust), and asks every connection's
+`GET /api/updates`. Top-right **Update** button (Chrome-style: colour rises
+with age; red and permanent when required), an updates panel with notes before
+you update, a force-update screen, a "What's new" toast after any update, and
+manifest messages.
diff --git a/scripts/promote-desktop-release.mjs b/scripts/promote-desktop-release.mjs
new file mode 100644
index 00000000..1f7e69ed
--- /dev/null
+++ b/scripts/promote-desktop-release.mjs
@@ -0,0 +1,71 @@
+#!/usr/bin/env node
+/**
+ * After publishing a Mercury Desktop release on GitHub (desktop-v<version>),
+ * point the apps at it:
+ *
+ * node scripts/promote-desktop-release.mjs 0.2.0 [--notes notes.md]
+ *
+ * 1. downloads latest.json from the release and checks every platform entry
+ * has a url and a signature (the updater rejects the whole file otherwise);
+ * 2. writes it to website/static/desktop/latest.json (the updater endpoint);
+ * 3. records the release in the update manifest and re-signs it.
+ *
+ * Nothing goes live until the website deploys. A draft release has no public
+ * latest.json, so this fails until the release is published.
+ */
+import { execFileSync } from 'node:child_process';
+import { mkdirSync, writeFileSync } from 'node:fs';
+import { dirname, join, resolve } from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
+const REPO = 'cosmicstack-labs/mercury-agent';
+const version = process.argv[2];
+const notesAt = process.argv.indexOf('--notes');
+const notes = notesAt > 0 ? process.argv[notesAt + 1] : undefined;
+
+if (!/^\d+\.\d+\.\d+$/.test(version ?? '')) {
+ console.error('Usage: node scripts/promote-desktop-release.mjs <version> [--notes file.md]');
+ process.exit(1);
+}
+
+const url = `https://github.com/${REPO}/releases/download/desktop-v${version}/latest.json`;
+const res = await fetch(url);
+if (!res.ok) {
+ console.error(`✗ ${url} → ${res.status}. Publish the draft release first.`);
+ process.exit(1);
+}
+const latest = await res.json();
+if (latest.version?.replace(/^v/, '') !== version) {
+ console.error(`✗ latest.json says ${latest.version}, not ${version}.`);
+ process.exit(1);
+}
+const platforms = Object.entries(latest.platforms ?? {});
+if (!platforms.length) { console.error('✗ latest.json lists no platforms.'); process.exit(1); }
+for (const [name, p] of platforms) {
+ if (!p?.url || !p?.signature) { console.error(`✗ ${name} has no url or signature.`); process.exit(1); }
+}
+
+// The release body is the notes people read before and after updating.
+let body = latest.notes ?? '';
+if (!notes) {
+ try {
+ const rel = await (await fetch(`https://api.github.com/repos/${REPO}/releases/tags/desktop-v${version}`, { headers: { Accept: 'application/vnd.github+json' } })).json();
+ if (rel?.body) body = rel.body;
+ } catch { /* keep latest.json's */ }
+}
+latest.notes = body;
+
+const out = join(ROOT, 'website/static/desktop/latest.json');
+mkdirSync(dirname(out), { recursive: true });
+writeFileSync(out, `${JSON.stringify(latest, null, 2)}\n`);
+console.log(`✓ ${out.replace(`${ROOT}/`, '')}: ${platforms.map(([n]) => n).join(', ')}`);
+
+const notesFile = notes ?? join(ROOT, '.desktop-notes.tmp.md');
+if (!notes) writeFileSync(notesFile, body);
+try {
+ execFileSync(process.execPath, [join(ROOT, 'scripts/update-manifest.mjs'), 'release', 'desktop', version, '--notes', notesFile], { stdio: 'inherit' });
+} finally {
+ if (!notes) try { (await import('node:fs')).unlinkSync(notesFile); } catch { /* gone */ }
+}
+console.log('Commit website/static/desktop/latest.json and website/static/updates/, then deploy the website.');
diff --git a/scripts/publish.sh b/scripts/publish.sh
index 172f5af8..749b5b8d 100755
--- a/scripts/publish.sh
+++ b/scripts/publish.sh
@@ -40,4 +40,7 @@ echo "✓ Published ${PKG_NAME}@${PKG_VERSION}"
echo "Tagging git..."
git tag -a "v${PKG_VERSION}" -m "v${PKG_VERSION}"
-echo "Done. Push with: git push origin main --tags"
\ No newline at end of file
+echo "Done. Push with: git push origin main --tags"echo ""
+echo "Apps learn about the release from the signed update manifest (docs/updates.md)."
+echo "Once the GitHub release and its binaries are up, record it and deploy the website:"
+echo " node scripts/update-manifest.mjs release server ${PKG_VERSION} --notes RELEASE.md"
diff --git a/scripts/update-manifest.mjs b/scripts/update-manifest.mjs
new file mode 100644
index 00000000..8e9f1f5c
--- /dev/null
+++ b/scripts/update-manifest.mjs
@@ -0,0 +1,187 @@
+#!/usr/bin/env node
+/**
+ * Edit and sign the update manifest (docs/updates.md):
+ * website/static/updates/manifest.json + manifest.json.sig.
+ *
+ * node scripts/update-manifest.mjs show
+ * node scripts/update-manifest.mjs release server 1.5.0 --notes RELEASE.md [--channel dev] [--url …]
+ * node scripts/update-manifest.mjs release desktop 0.2.0 --notes notes.md
+ * node scripts/update-manifest.mjs require server 1.4.2 --reason "Fixes …" [--severity security|required]
+ * node scripts/update-manifest.mjs require server none
+ * node scripts/update-manifest.mjs message add --id 2026-11-launch --title "…" --body notes.md
+ * [--level info|warning|critical] [--apps desktop,server] [--versions "<1.5.0"]
+ * [--ends 2026-12-01] [--link-label "Read more" --link-url https://…] [--sticky]
+ * node scripts/update-manifest.mjs message remove 2026-11-launch
+ * node scripts/update-manifest.mjs sign (re-sign without changes)
+ * node scripts/update-manifest.mjs verify
+ *
+ * Every change re-signs. The key is the desktop updater key:
+ * TAURI_SIGNING_PRIVATE_KEY_PATH (default ~/.tauri/mercury-updates.key) and
+ * TAURI_SIGNING_PRIVATE_KEY_PASSWORD (default: the .password file beside it).
+ * Nothing is published: the files change in the repo and go live when the
+ * website deploys.
+ */
+import { execFileSync } from 'node:child_process';
+import { existsSync, readFileSync, writeFileSync, mkdirSync, unlinkSync } from 'node:fs';
+import { homedir } from 'node:os';
+import { dirname, join, resolve } from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
+const FILE = join(ROOT, 'website/static/updates/manifest.json');
+const SIG = `${FILE}.sig`;
+const TAURI = join(ROOT, 'apps/desktop/node_modules/.bin/tauri');
+const REPO = 'cosmicstack-labs/mercury-agent';
+const VERSION_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
+
+const die = (msg) => { console.error(`✗ ${msg}`); process.exit(1); };
+
+function parseArgs(argv) {
+ const pos = []; const opts = {};
+ for (let i = 0; i < argv.length; i++) {
+ const a = argv[i];
+ if (a.startsWith('--')) {
+ const key = a.slice(2);
+ const next = argv[i + 1];
+ if (next === undefined || next.startsWith('--')) opts[key] = true;
+ else { opts[key] = next; i++; }
+ } else pos.push(a);
+ }
+ return { pos, opts };
+}
+
+function load() {
+ if (!existsSync(FILE)) {
+ return { schema: 1, issuedAt: null, server: { channels: { stable: null, dev: null }, minimum: null }, desktop: { channels: { stable: null }, minimum: null }, messages: [] };
+ }
+ return JSON.parse(readFileSync(FILE, 'utf-8'));
+}
+
+/** A file's text, or the value itself when it isn't a file. */
+const textOf = (v) => (typeof v === 'string' && existsSync(v) ? readFileSync(v, 'utf-8').trim() : typeof v === 'string' ? v : '');
+
+const app = (name) => (name === 'server' || name === 'desktop' ? name : die(`Say server or desktop, not "${name}".`));
+const version = (v) => (VERSION_RE.test(String(v)) ? String(v) : die(`"${v}" is not a version like 1.5.0.`));
+const isoDay = (v) => (v ? (Number.isNaN(Date.parse(v)) ? die(`"${v}" is not a date.`) : new Date(v).toISOString()) : null);
+
+function keyPaths() {
+ const key = process.env.TAURI_SIGNING_PRIVATE_KEY_PATH || join(homedir(), '.tauri/mercury-updates.key');
+ if (!existsSync(key)) die(`No signing key at ${key}. Set TAURI_SIGNING_PRIVATE_KEY_PATH.`);
+ let password = process.env.TAURI_SIGNING_PRIVATE_KEY_PASSWORD;
+ if (password === undefined && existsSync(`${key}.password`)) password = readFileSync(`${key}.password`, 'utf-8').trim();
+ return { key, password: password ?? '' };
+}
+
+function sign() {
+ if (!existsSync(TAURI)) die('Install the desktop dependencies first (cd apps/desktop && npm ci): signing uses the Tauri CLI.');
+ const { key, password } = keyPaths();
+ if (existsSync(SIG)) unlinkSync(SIG);
+ execFileSync(TAURI, ['signer', 'sign', '-f', key, '-p', password, FILE], { stdio: ['ignore', 'ignore', 'inherit'] });
+ if (!existsSync(SIG)) die('Signing wrote no signature.');
+ console.log(`✓ Signed ${FILE.replace(`${ROOT}/`, '')}`);
+}
+
+function save(m) {
+ m.issuedAt = new Date().toISOString().replace(/\.\d{3}Z$/, 'Z');
+ mkdirSync(dirname(FILE), { recursive: true });
+ writeFileSync(FILE, `${JSON.stringify(m, null, 2)}\n`);
+ sign();
+}
+
+function verify() {
+ // The runtime's verifier is the one clients use; run it on the committed files.
+ const out = execFileSync(process.execPath, ['--import', 'tsx', '-e', `
+ import { readFileSync } from 'node:fs';
+ import { verifyMinisign } from ${JSON.stringify(join(ROOT, 'src/updates/minisign.ts'))};
+ import { UPDATE_PUBLIC_KEY } from ${JSON.stringify(join(ROOT, 'src/updates/public-key.ts'))};
+ const ok = verifyMinisign(readFileSync(${JSON.stringify(FILE)}), readFileSync(${JSON.stringify(SIG)}, 'utf-8').trim(), UPDATE_PUBLIC_KEY);
+ console.log(ok ? 'ok' : 'bad');
+ `], { cwd: ROOT, encoding: 'utf-8' }).trim();
+ if (!out.endsWith('ok')) die('The signature does not match the manifest.');
+ console.log('✓ Signature verifies with the public key clients have.');
+}
+
+function show(m) {
+ const line = (label, ch) => ch ? `${label} ${ch.version}${ch.date ? ` (${ch.date})` : ''}` : `${label} —`;
+ console.log(`Issued ${m.issuedAt ?? 'never'}`);
+ for (const a of ['server', 'desktop']) {
+ const chans = Object.entries(m[a].channels).map(([k, v]) => line(k, v)).join(' · ');
+ const min = m[a].minimum ? `required ≥ ${m[a].minimum.version} (${m[a].minimum.severity}): ${m[a].minimum.reason}` : 'nothing required';
+ console.log(`${a.padEnd(8)} ${chans} · ${min}`);
+ }
+ for (const msg of m.messages) console.log(`message ${msg.id} [${msg.level}] ${msg.title} → ${msg.apps.join(',')}${msg.versions ? ` ${msg.versions}` : ''}`);
+}
+
+const { pos, opts } = parseArgs(process.argv.slice(2));
+const [cmd, ...rest] = pos;
+const m = load();
+
+switch (cmd) {
+ case 'show': show(m); break;
+ case 'sign': sign(); break;
+ case 'verify': verify(); break;
+ case 'release': {
+ const a = app(rest[0]); const v = version(rest[1]);
+ const channel = opts.channel || 'stable';
+ if (a === 'desktop' && channel !== 'stable') die('Mercury Desktop has only the stable channel.');
+ const tag = a === 'server' ? `v${v}` : `desktop-v${v}`;
+ m[a].channels[channel] = {
+ version: v,
+ date: (opts.date ? isoDay(opts.date) : new Date().toISOString()).slice(0, 10),
+ // A release-notes file's own title ("# Release v1.5.0") repeats what the app already shows.
+ notes: textOf(opts.notes).replace(/^# .*\n+/, ''),
+ notesUrl: opts.url || `https://github.com/${REPO}/releases/tag/${tag}`,
+ };
+ if (m[a].minimum && !(compare(m[a].minimum.version, v) <= 0)) die(`The required version (${m[a].minimum.version}) is newer than this release.`);
+ save(m); show(m); break;
+ }
+ case 'require': {
+ const a = app(rest[0]);
+ if (rest[1] === 'none') { m[a].minimum = null; save(m); show(m); break; }
+ const v = version(rest[1]);
+ const latest = m[a].channels.stable?.version;
+ if (!latest || compare(v, latest) > 0) die(`Release ${v} first: a required version must be one people can install.`);
+ if (!opts.reason || opts.reason === true) die('Say why (--reason): people read it on the force-update screen.');
+ const severity = opts.severity || 'required';
+ if (!['security', 'required'].includes(severity)) die('--severity is security or required.');
+ m[a].minimum = { version: v, severity, reason: String(opts.reason), since: new Date().toISOString().slice(0, 10) };
+ save(m); show(m); break;
+ }
+ case 'message': {
+ const sub = rest[0];
+ if (sub === 'remove') {
+ const before = m.messages.length;
+ m.messages = m.messages.filter((x) => x.id !== rest[1]);
+ if (m.messages.length === before) die(`No message "${rest[1]}".`);
+ save(m); show(m); break;
+ }
+ if (sub !== 'add') die('message add | message remove <id>');
+ if (!opts.id || !opts.title) die('A message needs --id and --title.');
+ if (!/^[a-z0-9][a-z0-9._-]{2,63}$/i.test(opts.id)) die('--id: letters, digits, dot, dash; 3–64 characters. People\'s dismissals are kept by it.');
+ const level = opts.level || 'info';
+ if (!['info', 'warning', 'critical'].includes(level)) die('--level is info, warning or critical.');
+ const apps = String(opts.apps || 'desktop,server').split(',').map((s) => s.trim());
+ if (!apps.every((x) => x === 'desktop' || x === 'server')) die('--apps lists desktop and/or server.');
+ if (opts.sticky && level !== 'critical') die('Only a critical message can be undismissable (--sticky).');
+ const msg = {
+ id: opts.id, title: String(opts.title), body: textOf(opts.body), level, apps,
+ versions: opts.versions ? String(opts.versions) : undefined,
+ startsAt: isoDay(opts.starts), endsAt: isoDay(opts.ends),
+ link: opts['link-url'] ? { label: String(opts['link-label'] || 'Read more'), url: String(opts['link-url']) } : undefined,
+ dismissible: !opts.sticky,
+ };
+ m.messages = [...m.messages.filter((x) => x.id !== msg.id), JSON.parse(JSON.stringify(msg))];
+ save(m); show(m); break;
+ }
+ default:
+ console.log(readFileSync(fileURLToPath(import.meta.url), 'utf-8').split('\n').slice(1, 22).map((l) => l.replace(/^ \*\/?\s?/, '')).join('\n'));
+}
+
+function compare(a, b) {
+ const parse = (v) => v.split(/[.-]/).map((p) => (/^\d+$/.test(p) ? Number(p) : p));
+ const pa = parse(a); const pb = parse(b);
+ for (let i = 0; i < 3; i++) if (pa[i] !== pb[i]) return pa[i] - pb[i];
+ const preA = a.includes('-'); const preB = b.includes('-');
+ if (preA !== preB) return preA ? -1 : 1;
+ return a === b ? 0 : a < b ? -1 : 1;
+}
diff --git a/website/static/updates/manifest.json b/website/static/updates/manifest.json
new file mode 100644
index 00000000..84a27f4e
--- /dev/null
+++ b/website/static/updates/manifest.json
@@ -0,0 +1,23 @@
+{
+ "schema": 1,
+ "issuedAt": "2026-11-03T05:23:59Z",
+ "server": {
+ "channels": {
+ "stable": {
+ "version": "1.4.2",
+ "date": "2026-10-31",
+ "notes": "## ☿ Mercury Agent v1.4.2\n\nWeb search finds things again, with no key and with any model, and the research prompt now asks only when you actually want a research article.\n\n### Web search\n- **Three sources that answer.** `web_search` asks [Parallel's public search](https://search.parallel.ai/mcp) first (keyless, built for agents, about a second, with excerpts and dates), then DuckDuckGo's html page, then its lite page. Bing's web feed, which had started returning unrelated pages, and the engines that refuse automated requests are gone.\n- **DuckDuckGo read exactly.** Both pages are parsed from their real markup: the title, the real address behind DuckDuckGo's redirect, and the snippet. Ads are dropped, a bot challenge is retried once, and a page Mercury can't read is reported instead of looking empty.\n- **News links open the article.** News comes from Parallel's article links, then Bing News with its redirects unwrapped to the publisher, then Google News and Hacker News.\n- **Never the model's own search.** Results come only from Mercury's search tools, so search works the same whichever model you use.\n- **You can see what happened.** Every result ends with a `Searched:` trail, such as `Parallel: timed out → DuckDuckGo: 8 results`, so \"nothing found\" and \"every source was blocked\" read differently.\n- The built-in `web-search` skill (1.3.0) describes the sources. An installed skill that scraped DuckDuckGo directly is replaced, and your copy is kept as `SKILL.md.replaced.bak`.\n\n### Chat\n- **The research prompt asks only when you mean it.** It used to fire on words like \"latest\" or \"explain\", so instructions such as \"convert the latest epub\" got a research question. One short model call now decides; instructions, quick questions and today's news never get the prompt.\n- **Quick answer comes first**, so an accidental Enter never starts a long research run.\n\n### Upgrade\n\n**npm:**\n```\nnpm install -g @cosmicstack/[email protected]\nmercury restart\n```\n\n**Standalone binary:** `mercury upgrade`, or re-run the one-line installer from mercuryagent.sh.\n\nNo config changes needed.\n\n**Full Changelog**: https://github.com/cosmicstack-labs/mercury-agent/compare/v1.4.1...v1.4.2",
+ "notesUrl": "https://github.com/cosmicstack-labs/mercury-agent/releases/tag/v1.4.2"
+ },
+ "dev": null
+ },
+ "minimum": null
+ },
+ "desktop": {
+ "channels": {
+ "stable": null
+ },
+ "minimum": null
+ },
+ "messages": []
+}
diff --git a/website/static/updates/manifest.json.sig b/website/static/updates/manifest.json.sig
new file mode 100644
index 00000000..80494083
--- /dev/null
+++ b/website/static/updates/manifest.json.sig
@@ -0,0 +1 @@
+dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVUV2VUTlRLNTFvNjdndUpSMHBZOFZ2a2U0SmdxVW1scTd0UU5sZHMzM0NPQ0d6d0FFeTJvOG5ldERhTVZ0V0YxeXZZRW1DenhqZTZTcVJlcmUreFRVbTFUaU9TcHFmTXdVPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzkzNjgzNDM5CWZpbGU6bWFuaWZlc3QuanNvbgp3TzFyMFczTlpIT0xzYmlsVW12TGZxenRoNzEzSmplQ3dJYWpxSVZYck9rRzVVZnV6eXhYbjUvcXBvLzNIZmJ4RzI0WW80SDFrNlN5ZGVzbFZPUEhCdz09Cg==
\ No newline at end of file