Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(desktop): release targets, GCS update feed, version bump and release manifest for three.ws Desktop
nirholas937f41165fb5
diff --git a/apps/desktop/assets/[email protected] b/apps/desktop/assets/[email protected]new file mode 100644index 000000000..33f7917e4Binary files /dev/null and b/apps/desktop/assets/[email protected] differdiff --git a/apps/desktop/build/entitlements.mac.plist b/apps/desktop/build/entitlements.mac.plistnew file mode 100644index 000000000..c12090cd0--- /dev/null+++ b/apps/desktop/build/entitlements.mac.plist@@ -0,0 +1,11 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+ <dict>+ <!-- V8 needs to write executable memory under the hardened runtime. -->+ <key>com.apple.security.cs.allow-jit</key>+ <true/>+ <key>com.apple.security.cs.allow-unsigned-executable-memory</key>+ <true/>+ </dict>+</plist>diff --git a/apps/desktop/electron-builder.config.cjs b/apps/desktop/electron-builder.config.cjsnew file mode 100644index 000000000..e019ed968--- /dev/null+++ b/apps/desktop/electron-builder.config.cjs@@ -0,0 +1,101 @@+// electron-builder configuration for three.ws Desktop.+//+// Targets: macOS universal .dmg and .zip, Windows NSIS installer and portable+// .exe, Linux .AppImage and .deb. Artifacts land in dist/ and are published to+// the release bucket behind the three.ws CDN by apps/desktop/cloudbuild.yaml+// (Linux and Windows) and apps/desktop/scripts/release-mac.sh (macOS, which+// needs a Mac to build a universal binary and to notarize).+//+// Signing is read from the environment the release scripts fill from Secret+// Manager. With no certificate present the build is still complete and+// installable, just unsigned:+// - macOS: ad-hoc signed (identity "-"), so Apple Silicon runs it after+// "Open Anyway" in System Settings > Privacy & Security.+// - Windows: unsigned, so SmartScreen asks for "More info" > "Run anyway".+// docs/ops/desktop-release.md lists the certificates and the secret names.++const FEED_URL = process.env.THREE_WS_RELEASE_FEED || 'https://three.ws/releases/desktop';++const macSigned = Boolean(process.env.CSC_LINK || process.env.CSC_NAME);+const macNotarize = macSigned && Boolean(process.env.APPLE_API_KEY && process.env.APPLE_API_KEY_ID && process.env.APPLE_API_ISSUER);++/** @type {import('electron-builder').Configuration} */+module.exports = {+ appId: 'ws.three.desktop',+ productName: 'three.ws Desktop',+ copyright: 'Copyright three.ws',+ artifactName: 'three.ws-Desktop-${version}-${os}-${arch}.${ext}',+ directories: { output: 'dist', buildResources: 'build' },+ files: ['src/**/*', 'assets/**/*', 'package.json', '!**/*.test.js'],+ asar: true,+ // The generic provider is a static directory of files. electron-builder+ // writes latest.yml / latest-mac.yml / latest-linux.yml next to the+ // artifacts and bakes this URL into the app as app-update.yml, which is+ // what src/main/updater.js reads.+ publish: [{ provider: 'generic', url: FEED_URL, channel: 'latest' }],+ mac: {+ category: 'public.app-category.productivity',+ icon: 'build/icon.png',+ target: [+ { target: 'dmg', arch: ['universal'] },+ { target: 'zip', arch: ['universal'] },+ ],+ minimumSystemVersion: '11.0',+ hardenedRuntime: true,+ gatekeeperAssess: false,+ entitlements: 'build/entitlements.mac.plist',+ entitlementsInherit: 'build/entitlements.mac.plist',+ // null lets electron-builder use the Developer ID from CSC_LINK; "-" is+ // an ad-hoc signature, the least a universal binary needs to launch.+ identity: macSigned ? undefined : '-',+ notarize: macNotarize,+ extendInfo: {+ LSUIElement: false,+ NSHumanReadableCopyright: 'three.ws',+ },+ },+ dmg: {+ sign: false,+ writeUpdateInfo: false,+ title: 'three.ws Desktop ${version}',+ },+ win: {+ icon: 'build/icon.png',+ target: [+ { target: 'nsis', arch: ['x64'] },+ { target: 'portable', arch: ['x64'] },+ ],+ publisherName: 'three.ws',+ },+ nsis: {+ oneClick: false,+ perMachine: false,+ allowToChangeInstallationDirectory: true,+ createDesktopShortcut: true,+ createStartMenuShortcut: true,+ shortcutName: 'three.ws Desktop',+ artifactName: 'three.ws-Desktop-${version}-win-${arch}-setup.${ext}',+ differentialPackage: true,+ },+ portable: {+ artifactName: 'three.ws-Desktop-${version}-win-${arch}-portable.${ext}',+ },+ linux: {+ icon: 'build/icon.png',+ category: 'Utility',+ target: [+ { target: 'AppImage', arch: ['x64'] },+ { target: 'deb', arch: ['x64'] },+ ],+ maintainer: 'three.ws <[email protected]>',+ vendor: 'three.ws',+ synopsis: 'Operate your three.ws agents from the desktop',+ description: 'Sign in, chat with your agents, follow runs step by step, approve what they want to spend, and wire three.ws into every coding client on the machine.',+ executableName: 'three-ws-desktop',+ desktop: { StartupWMClass: 'three.ws Desktop' },+ },+ deb: {+ packageName: 'three-ws-desktop',+ depends: ['libnotify4', 'libxtst6', 'libnss3', 'libsecret-1-0'],+ },+};diff --git a/apps/desktop/package-lock.json b/apps/desktop/package-lock.jsonindex 932305dc8..12307af71 100644--- a/apps/desktop/package-lock.json+++ b/apps/desktop/package-lock.json@@ -1,11 +1,11 @@{- "name": "three-ws-companion-desktop",+ "name": "three-ws-desktop","version": "0.1.0","lockfileVersion": 3,"requires": true,"packages": {"": {- "name": "three-ws-companion-desktop",+ "name": "three-ws-desktop","version": "0.1.0","license": "Apache-2.0","dependencies": {diff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex f17fbfa35..cf15bdf77 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -1,11 +1,11 @@{- "name": "three-ws-companion-desktop",- "productName": "three.ws Companion",+ "name": "three-ws-desktop",+ "productName": "three.ws Desktop","version": "0.1.0",- "description": "A 3D companion that lives on your desktop, walks across it, and tells you the things worth interrupting you for.",+ "description": "The three.ws agent console for macOS, Windows and Linux: sign in, chat with your agents, follow runs, approve what they spend, and keep the 3D companion on your desktop.","author": "three.ws <[email protected]> (https://three.ws)","license": "Apache-2.0",- "homepage": "https://three.ws/companion",+ "homepage": "https://three.ws/desktop","repository": {"type": "git","url": "git+https://github.com/nirholas/three.ws.git",@@ -17,10 +17,15 @@"scripts": {"start": "electron .","dev": "electron . --dev",- "dist": "electron-builder --publish never",- "dist:mac": "electron-builder --mac --publish never",- "dist:win": "electron-builder --win --publish never",- "dist:linux": "electron-builder --linux --publish never"+ "icons": "node scripts/make-icons.mjs",+ "bump": "node scripts/bump-version.mjs",+ "dist": "electron-builder --config electron-builder.config.cjs --publish never",+ "dist:mac": "electron-builder --config electron-builder.config.cjs --mac --publish never",+ "dist:win": "electron-builder --config electron-builder.config.cjs --win --publish never",+ "dist:linux": "electron-builder --config electron-builder.config.cjs --linux --publish never",+ "release:manifest": "node scripts/release-manifest.mjs",+ "release:mac": "bash scripts/release-mac.sh",+ "release:github": "node scripts/github-release.mjs"},"dependencies": {"@three-ws/companion": "file:../../packages/companion-sdk",@@ -32,36 +37,5 @@"devDependencies": {"electron": "^33.2.0","electron-builder": "^25.1.8"- },- "build": {- "appId": "ws.three.companion",- "productName": "three.ws Companion",- "files": [- "src/**/*",- "assets/**/*",- "node_modules/**/*"- ],- "mac": {- "category": "public.app-category.productivity",- "icon": "assets/icon.png",- "target": [- "dmg",- "zip"- ]- },- "win": {- "icon": "assets/icon.png",- "target": [- "nsis"- ]- },- "linux": {- "icon": "assets/icon.png",- "category": "Utility",- "target": [- "AppImage",- "deb"- ]- }}}diff --git a/apps/desktop/releases.json b/apps/desktop/releases.jsonnew file mode 100644index 000000000..44a2a1761--- /dev/null+++ b/apps/desktop/releases.json@@ -0,0 +1,4 @@+{+ "$comment": "Release history for three.ws Desktop, newest first. Written by scripts/bump-version.mjs, which collects the data/changelog.json entries tagged `desktop` since the previous release into `notes`. scripts/release-manifest.mjs copies the current version's notes into the published release.json that /desktop and the in-app updater show.",+ "releases": []+}diff --git a/apps/desktop/scripts/bump-version.mjs b/apps/desktop/scripts/bump-version.mjsnew file mode 100644index 000000000..68de8000e--- /dev/null+++ b/apps/desktop/scripts/bump-version.mjs@@ -0,0 +1,142 @@+#!/usr/bin/env node+// Cut a three.ws Desktop version: bump apps/desktop/package.json, collect the+// release notes, and write the public changelog entry that announces it.+//+// node apps/desktop/scripts/bump-version.mjs patch|minor|major|<x.y.z> [--dry-run] [--date YYYY-MM-DD]+//+// Release notes are every data/changelog.json entry tagged `desktop` dated on+// or after the previous release, minus the ones that release already carried+// and minus earlier release announcements. They are recorded in+// apps/desktop/releases.json (the history the release manifest reads), and+// one entry "three.ws Desktop <version>" is added to data/changelog.json so the+// community feed announces the release. Run it as the first step of a release+// (docs/ops/desktop-release.md), right before the builds, because the+// changelog entry goes out with the next deploy.++import { readFileSync, writeFileSync } from 'node:fs';+import { dirname, join, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';++const HERE = dirname(fileURLToPath(import.meta.url));+const APP = resolve(HERE, '..');+const REPO = resolve(APP, '../..');+export const PATHS = {+ pkg: join(APP, 'package.json'),+ lock: join(APP, 'package-lock.json'),+ history: join(APP, 'releases.json'),+ changelog: join(REPO, 'data/changelog.json'),+};++const RELEASE_TITLE = /^three\.ws Desktop \d+\.\d+\.\d+/;+const SEMVER = /^(\d+)\.(\d+)\.(\d+)$/;++export function nextVersion(current, bump) {+ const m = SEMVER.exec(String(current));+ if (!m) throw new Error(`Current version "${current}" is not x.y.z`);+ const [maj, min, pat] = m.slice(1).map(Number);+ if (bump === 'major') return `${maj + 1}.0.0`;+ if (bump === 'minor') return `${maj}.${min + 1}.0`;+ if (bump === 'patch') return `${maj}.${min}.${pat + 1}`;+ const t = SEMVER.exec(String(bump));+ if (!t) throw new Error(`Bump must be patch, minor, major or an explicit x.y.z (got "${bump}")`);+ const cmp = t.slice(1).map(Number);+ const cur = [maj, min, pat];+ const newer = cmp[0] !== cur[0] ? cmp[0] > cur[0] : cmp[1] !== cur[1] ? cmp[1] > cur[1] : cmp[2] > cur[2];+ if (!newer) throw new Error(`${bump} is not newer than ${current}`);+ return bump;+}++// The desktop-tagged entries a release should carry, oldest first so the notes+// read in the order the work landed.+export function collectNotes(entries, lastRelease) {+ const carried = new Set((lastRelease?.notes || []).map((n) => `${n.date}\u0000${n.title}`));+ return entries+ .filter((e) => Array.isArray(e.tags) && e.tags.includes('desktop'))+ .filter((e) => !RELEASE_TITLE.test(e.title))+ .filter((e) => !lastRelease || e.date >= lastRelease.date)+ .filter((e) => !carried.has(`${e.date}\u0000${e.title}`))+ .map((e) => ({ date: e.date, title: e.title, summary: e.summary, tags: e.tags.filter((t) => t !== 'desktop'), ...(e.link ? { link: e.link } : {}) }))+ .sort((a, b) => a.date.localeCompare(b.date));+}++export function releaseEntry(version, date, notes) {+ const tags = ['desktop'];+ if (notes.some((n) => n.tags.includes('feature'))) tags.unshift('feature');+ else if (notes.some((n) => n.tags.includes('improvement'))) tags.unshift('improvement');+ else if (notes.some((n) => n.tags.includes('fix'))) tags.unshift('fix');+ const list = notes.map((n) => n.title.replace(/[.\s]+$/, '')).join('; ');+ return {+ date,+ title: `three.ws Desktop ${version} is out`,+ summary: `A new version of the three.ws desktop app for macOS, Windows and Linux. Installed copies update themselves; new installs start at three.ws/desktop. In this release: ${list}.`,+ tags,+ link: '/desktop',+ };+}++function readJson(path) {+ return JSON.parse(readFileSync(path, 'utf8'));+}++function writeJson(path, value) {+ writeFileSync(path, `${JSON.stringify(value, null, '\t')}\n`);+}++function parseArgs(argv) {+ const out = { bump: null, dryRun: false, date: new Date().toISOString().slice(0, 10) };+ for (let i = 0; i < argv.length; i++) {+ const a = argv[i];+ if (a === '--dry-run') out.dryRun = true;+ else if (a === '--date') out.date = argv[++i];+ else if (!out.bump) out.bump = a;+ else throw new Error(`Unexpected argument: ${a}`);+ }+ if (!out.bump) throw new Error('Usage: bump-version.mjs patch|minor|major|<x.y.z> [--dry-run] [--date YYYY-MM-DD]');+ if (!/^\d{4}-\d{2}-\d{2}$/.test(out.date)) throw new Error(`--date must be YYYY-MM-DD (got "${out.date}")`);+ return out;+}++function main() {+ const args = parseArgs(process.argv.slice(2));+ const pkg = readJson(PATHS.pkg);+ const history = readJson(PATHS.history);+ const changelog = readJson(PATHS.changelog);+ const version = nextVersion(pkg.version, args.bump);+ if (history.releases.some((r) => r.version === version)) throw new Error(`${version} is already in releases.json`);+ const notes = collectNotes(changelog.entries, history.releases[0]);+ if (!notes.length) {+ throw new Error('No data/changelog.json entries tagged "desktop" since the last release. Add one for each user-visible change first, so the release has notes.');+ }+ const entry = releaseEntry(version, args.date, notes);++ console.log(`three.ws Desktop ${pkg.version} -> ${version} (${args.date})`);+ console.log(`Release notes (${notes.length}):`);+ for (const n of notes) console.log(` - ${n.date} ${n.title}`);+ console.log(`Changelog entry: "${entry.title}" [${entry.tags.join(', ')}]`);+ if (args.dryRun) {+ console.log('Dry run: nothing written.');+ return;+ }++ pkg.version = version;+ writeJson(PATHS.pkg, pkg);+ const lock = readJson(PATHS.lock);+ lock.version = version;+ if (lock.packages?.['']) lock.packages[''].version = version;+ writeJson(PATHS.lock, lock);+ history.releases.unshift({ version, date: args.date, notes });+ writeJson(PATHS.history, history);+ changelog.entries.unshift(entry);+ writeJson(PATHS.changelog, changelog);+ console.log('Wrote package.json, package-lock.json, releases.json and data/changelog.json.');+ console.log('Next: npm run build:pages, commit, then follow docs/ops/desktop-release.md from "Build".');+}++if (process.argv[1] && fileURLToPath(import.meta.url) === resolve(process.argv[1])) {+ try {+ main();+ } catch (err) {+ console.error(`[bump-version] ${err.message}`);+ process.exit(1);+ }+}diff --git a/apps/desktop/scripts/release-manifest.mjs b/apps/desktop/scripts/release-manifest.mjsnew file mode 100644index 000000000..d829cf398--- /dev/null+++ b/apps/desktop/scripts/release-manifest.mjs@@ -0,0 +1,151 @@+#!/usr/bin/env node+// Describe the built artifacts of one three.ws Desktop version as release.json,+// the file /desktop reads to list every download with its size and SHA-256.+//+// node apps/desktop/scripts/release-manifest.mjs [--dist dist] [--base-url URL]+// [--merge path/to/current-release.json] [--out dist/release.json]+//+// Builds happen in two places (Cloud Build for Linux and Windows, a Mac for+// macOS), so each run merges with the manifest already published: files for+// the platforms this run did not build are kept when the version matches, and+// dropped when the published manifest is for an older version.+//+// Signing state comes from the environment the release scripts set:+// THREE_WS_SIGNED_MAC=1 / THREE_WS_SIGNED_WIN=1 mark that platform's files+// signed; anything else marks them unsigned, which /desktop turns into the+// "Open Anyway" / "Run anyway" instructions.++import { createHash } from 'node:crypto';+import { createReadStream, existsSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';+import { dirname, join, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';++const HERE = dirname(fileURLToPath(import.meta.url));+const APP = resolve(HERE, '..');++export const DEFAULT_BASE_URL = 'https://three.ws/releases/desktop';++// What each platform needs, shown on /desktop. Electron 33 is Chromium 130:+// macOS 11 and Windows 10 are its floors, and its Linux floor is Chrome's.+export const MINIMUM_OS = {+ mac: 'macOS 11 Big Sur or later (Apple silicon and Intel)',+ win: 'Windows 10 or 11, 64-bit',+ linux: '64-bit Ubuntu 18.04+, Debian 10+, Fedora 39+ or another distribution with glibc 2.28+',+};++// Filename patterns electron-builder.config.cjs produces, most specific first.+const KINDS = [+ { re: /-mac-universal\.dmg$/, platform: 'mac', arch: 'universal', kind: 'dmg', label: 'Disk image (.dmg)', primary: true },+ { re: /-mac-universal\.zip$/, platform: 'mac', arch: 'universal', kind: 'zip', label: 'Zip archive (.zip)' },+ { re: /-win-(x64|arm64)-setup\.exe$/, platform: 'win', kind: 'nsis', label: 'Installer (.exe)', primary: true },+ { re: /-win-(x64|arm64)-portable\.exe$/, platform: 'win', kind: 'portable', label: 'Portable (.exe, no install)' },+ { re: /-linux-(x86_64|x64|arm64|aarch64)\.AppImage$/, platform: 'linux', kind: 'appimage', label: 'AppImage', primary: true },+ { re: /-linux-(amd64|x64|arm64)\.deb$/, platform: 'linux', kind: 'deb', label: 'Debian / Ubuntu (.deb)' },+];++const ARCH = { x86_64: 'x64', amd64: 'x64', x64: 'x64', arm64: 'arm64', aarch64: 'arm64', universal: 'universal' };++export function classify(name) {+ for (const k of KINDS) {+ const m = k.re.exec(name);+ if (!m) continue;+ const arch = ARCH[k.arch || m[1]] || m[1];+ return { platform: k.platform, arch, kind: k.kind, label: k.label, primary: Boolean(k.primary) };+ }+ return null;+}++export function sha256File(path) {+ return new Promise((resolvePromise, reject) => {+ const hash = createHash('sha256');+ createReadStream(path)+ .on('data', (chunk) => hash.update(chunk))+ .on('error', reject)+ .on('end', () => resolvePromise(hash.digest('hex')));+ });+}++export async function describeArtifacts(dist, { baseUrl = DEFAULT_BASE_URL, signed = {} } = {}) {+ const files = [];+ for (const name of readdirSync(dist).sort()) {+ const path = join(dist, name);+ if (!statSync(path).isFile()) continue;+ const c = classify(name);+ if (!c) continue;+ files.push({+ ...c,+ name,+ url: `${baseUrl.replace(/\/$/, '')}/${encodeURIComponent(name)}`,+ size: statSync(path).size,+ sha256: await sha256File(path),+ signed: Boolean(signed[c.platform]),+ });+ }+ return files;+}++// Keep the other platforms' files from the published manifest when it is the+// same version; this run's platforms always replace what was there.+export function mergeManifest({ version, date, notes, files }, previous) {+ const built = new Set(files.map((f) => f.platform));+ const carried = previous && previous.version === version ? (previous.files || []).filter((f) => !built.has(f.platform)) : [];+ const order = { mac: 0, win: 1, linux: 2 };+ const all = [...files, ...carried].sort((a, b) => order[a.platform] - order[b.platform] || Number(b.primary) - Number(a.primary) || a.name.localeCompare(b.name));+ return {+ schema: 1,+ product: 'three.ws Desktop',+ version,+ date: previous && previous.version === version && previous.date ? previous.date : date,+ notes,+ minimumOS: MINIMUM_OS,+ platforms: [...new Set(all.map((f) => f.platform))],+ files: all,+ };+}++function parseArgs(argv) {+ const out = { dist: join(APP, 'dist'), baseUrl: process.env.THREE_WS_RELEASE_FEED || DEFAULT_BASE_URL, merge: null, out: null };+ for (let i = 0; i < argv.length; i++) {+ const a = argv[i];+ if (a === '--dist') out.dist = resolve(argv[++i]);+ else if (a === '--base-url') out.baseUrl = argv[++i];+ else if (a === '--merge') out.merge = resolve(argv[++i]);+ else if (a === '--out') out.out = resolve(argv[++i]);+ else throw new Error(`Unknown argument: ${a}`);+ }+ out.out ||= join(out.dist, 'release.json');+ return out;+}++async function main() {+ const args = parseArgs(process.argv.slice(2));+ const pkg = JSON.parse(readFileSync(join(APP, 'package.json'), 'utf8'));+ const history = JSON.parse(readFileSync(join(APP, 'releases.json'), 'utf8'));+ const release = history.releases.find((r) => r.version === pkg.version);+ if (!release) throw new Error(`${pkg.version} has no entry in releases.json. Cut the version with scripts/bump-version.mjs first.`);+ if (!existsSync(args.dist)) throw new Error(`${args.dist} does not exist. Build first (npm run dist:<platform>).`);+ const files = await describeArtifacts(args.dist, {+ baseUrl: args.baseUrl,+ signed: { mac: process.env.THREE_WS_SIGNED_MAC === '1', win: process.env.THREE_WS_SIGNED_WIN === '1', linux: false },+ });+ if (!files.length) throw new Error(`No release artifacts found in ${args.dist}.`);+ let previous = null;+ if (args.merge && existsSync(args.merge)) {+ try {+ previous = JSON.parse(readFileSync(args.merge, 'utf8'));+ } catch {+ throw new Error(`${args.merge} is not valid JSON`);+ }+ }+ const manifest = mergeManifest({ version: pkg.version, date: release.date, notes: release.notes, files }, previous);+ writeFileSync(args.out, `${JSON.stringify(manifest, null, '\t')}\n`);+ console.log(`[release-manifest] ${manifest.product} ${manifest.version}: ${manifest.files.length} file(s) -> ${args.out}`);+ for (const f of manifest.files) console.log(` ${f.platform.padEnd(5)} ${f.kind.padEnd(8)} ${String(f.size).padStart(11)} ${f.sha256} ${f.name}${f.signed ? '' : ' (unsigned)'}`);+}++if (process.argv[1] && fileURLToPath(import.meta.url) === resolve(process.argv[1])) {+ main().catch((err) => {+ console.error(`[release-manifest] ${err.message}`);+ process.exit(1);+ });+}