Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
chore: rename Simplex and Co-Workspace identifiers to Linger
jeffrey4a4a7bc04454
diff --git a/apps/computer/local-daemon/internal/computerconfig/environment.go b/apps/computer/local-daemon/internal/computerconfig/environment.goindex f768f4d1..61f17943 100644--- a/apps/computer/local-daemon/internal/computerconfig/environment.go+++ b/apps/computer/local-daemon/internal/computerconfig/environment.go@@ -31,7 +31,7 @@ func RuntimeEnvironment(source map[string]string, gatewayToken string) map[strinresult := make(map[string]string)for key, value := range source {upperKey := strings.ToUpper(key)- if (gatewayToken != "" && value == gatewayToken) || strings.HasPrefix(upperKey, "LINGER_") || strings.HasPrefix(upperKey, "SIMPLEX") || strings.HasPrefix(upperKey, "RUNNER_GATEWAY_") || strings.HasPrefix(upperKey, "MIRROR_") || strings.HasPrefix(upperKey, "TEAMHUB_") || upperKey == "SERVICE_TOKEN" {+ if (gatewayToken != "" && value == gatewayToken) || strings.HasPrefix(upperKey, "LINGER_") || strings.HasPrefix(upperKey, "RUNNER_GATEWAY_") || strings.HasPrefix(upperKey, "MIRROR_") || strings.HasPrefix(upperKey, "TEAMHUB_") || upperKey == "SERVICE_TOKEN" {continue}result[key] = valuediff --git a/apps/computer/local-daemon/internal/linger/transport/transport.go b/apps/computer/local-daemon/internal/linger/transport/transport.goindex 834db164..2ec80357 100644--- a/apps/computer/local-daemon/internal/linger/transport/transport.go+++ b/apps/computer/local-daemon/internal/linger/transport/transport.go@@ -31,6 +31,8 @@ type Hello struct {func IdentityProofPayload(hello Hello) []byte {return bytes.Join([][]byte{+ // Frozen wire constant: daemons and Agent Services of any version must+ // sign and verify the same label, so it keeps its original name.[]byte("simplex-computer-daemon-identity-v1"),[]byte(hello.RunnerID),[]byte(hello.ConnectionNonce),diff --git a/apps/computer/local-daemon/internal/provider/model_invoke.go b/apps/computer/local-daemon/internal/provider/model_invoke.goindex 0aac2865..5e8fff0a 100644--- a/apps/computer/local-daemon/internal/provider/model_invoke.go+++ b/apps/computer/local-daemon/internal/provider/model_invoke.go@@ -419,7 +419,7 @@ func modelInvokeEnvironment(source map[string]string, scratch string) map[stringenvironment := make(map[string]string, len(source)+3)for key, value := range source {upper := strings.ToUpper(key)- if strings.HasPrefix(upper, "LINGER_") || strings.HasPrefix(upper, "SIMPLEX") ||+ if strings.HasPrefix(upper, "LINGER_") ||strings.HasPrefix(upper, "TEAMHUB_") || strings.HasPrefix(upper, "RUNNER_GATEWAY_") {continue}diff --git a/apps/desktop/AGENTS.md b/apps/desktop/AGENTS.mdindex e8224864..4409a1cd 100644--- a/apps/desktop/AGENTS.md+++ b/apps/desktop/AGENTS.md@@ -153,6 +153,24 @@ Gateway and runs Agents. The daemon exits with the app.and every step from another page, go through TeamHub to the daemon.- `src/main/computer-credential.ts`: the Gateway credential in`<userData>/computer/credential.json` (0600).+- Installs from before the product was renamed Linger move once on start.+ `index.ts` renames the packaged app's data folder from `<appData>/Simplex`+ to `<appData>/Linger` before `app.setPath("userData")`. A `Linger` folder+ that already holds `computer/credential.json` wins and the old folder stays+ (logged as `desktop.legacy_user_data_kept`); one without a credential is set+ aside as `Linger.before-move-<time>`, so the Computer keeps its identity.+ LocalServer runs `installer.js --migrate` when an instance record still+ carries a `simplex-` project name, before it reads+ `desktop/local-server.json`+ (`packages/local-installation/src/legacy-migration.ts`). A failed migration+ puts LocalServer in the failed state with the installer's error, which names+ each instance that is still legacy; Retry runs the migration again. There is+ no downgrade path: an older build reads neither the converted instances nor+ the moved data folder. The bundle ID and+ Windows AppUserModelID are `com.simplexai.linger.desktop.preview`. The+ Windows setup installs into `%LOCALAPPDATA%\Programs\Linger`; on upgrade it+ closes and removes `%LOCALAPPDATA%\Programs\Simplex` and moves the+ "Open at login" Run value from `ai.simplex.desktop.preview` to the new id.- `src/main/legacy-migration.ts`: on start, stops a bridge an older versionleft running and moves its credential and the Desktop 0.16 daemon identityinto the daemon layout, so the computer keeps its id.@@ -373,8 +391,8 @@ Intel Macs have none of this and install from the network.- `LINGER_BRIDGE_STATE_DIR`: where an older version's bridge kept its state,for the one-time migration.- `LINGER_CODEX_PATH`, `LINGER_CLAUDE_PATH`, `LINGER_PI_PATH`: absolute- runtime paths for the daemon config. Other `LINGER_*`, the retired `SIMPLEX*` and- `ELECTRON_*` variables do not reach the daemon. The config's+ runtime paths for the daemon config. Other `LINGER_*` and `ELECTRON_*`+ variables do not reach the daemon. The config's`runtimeEnvironment` (the local server's runtime: these paths plus`CODEX_HOME`, `CLAUDE_CONFIG_DIR`, `PI_CODING_AGENT_DIR`) replaces them,names compared case-insensitively for Windows.diff --git a/apps/desktop/packaging/mac/package.py b/apps/desktop/packaging/mac/package.pyindex 473ae553..3a2a658d 100644--- a/apps/desktop/packaging/mac/package.py+++ b/apps/desktop/packaging/mac/package.py@@ -52,7 +52,7 @@ HERE = os.path.dirname(os.path.abspath(__file__))DESKTOP = os.path.dirname(os.path.dirname(HERE))sys.path.insert(0, os.path.dirname(HERE))from native_bundle import check_runtime, check_teamhub, refresh # noqa: E402-BUNDLE_ID = "ai.simplex.desktop.preview"+BUNDLE_ID = "com.simplexai.linger.desktop.preview"# Prompt text for the privacy permissions tasks need. Without# NSAppleEventsUsageDescription macOS refuses Apple Events without asking.PRIVACY_USAGE = {diff --git a/apps/desktop/packaging/win/installer.nsi b/apps/desktop/packaging/win/installer.nsiindex d38b2ab1..7092a99d 100644--- a/apps/desktop/packaging/win/installer.nsi+++ b/apps/desktop/packaging/win/installer.nsi@@ -7,7 +7,13 @@ Unicode trueName "Linger"OutFile "${OUTPUT}"-InstallDir "$LOCALAPPDATA\Programs\Simplex"+InstallDir "$LOCALAPPDATA\Programs\Linger"+; Where installs from before the rename put the app, and the app id they+; named "Open at login" after. Only the upgrade below reads them.+!define LEGACY_INSTDIR "$LOCALAPPDATA\Programs\Simplex"+!define LEGACY_APP_ID "ai.simplex.desktop.preview"+!define APP_ID "com.simplexai.linger.desktop.preview"+!define RUN_KEY "Software\Microsoft\Windows\CurrentVersion\Run"RequestExecutionLevel userSetCompressor /SOLID lzma!define UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\Linger"@@ -46,9 +52,31 @@ FunctionEnd!insertmacro CLOSE_LINGER ""!insertmacro CLOSE_LINGER "un."+; An install from before the rename lives in another folder: close it and+; remove that folder (the app's data is elsewhere), and carry "Open at login"+; over to the new app id and folder.+Function RemoveLegacyInstall+ retry:+ ClearErrors+ IfFileExists "${LEGACY_INSTDIR}\Linger.exe" 0 removed+ Delete "${LEGACY_INSTDIR}\Linger.exe"+ IfErrors 0 removed+ MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "Linger is running. Quit it from its icon in the notification area, then select Retry." IDRETRY retry+ Abort+ removed:+ RMDir /r "${LEGACY_INSTDIR}"+ ClearErrors+ ReadRegStr $0 HKCU "${RUN_KEY}" "${LEGACY_APP_ID}"+ IfErrors done+ WriteRegStr HKCU "${RUN_KEY}" "${APP_ID}" '"$INSTDIR\Linger.exe" --background'+ DeleteRegValue HKCU "${RUN_KEY}" "${LEGACY_APP_ID}"+ done:+FunctionEnd+Section "Linger"SetOutPath "$INSTDIR"Call CloseLinger+ Call RemoveLegacyInstall; An update replaces the whole app folder.RMDir /r "$INSTDIR\resources"File /r "${STAGE}\*"@@ -72,5 +100,5 @@ Section "Uninstall"RMDir /r "$INSTDIR"DeleteRegKey HKCU "${UNINSTALL_KEY}"; "Open at login", named after the app id (index.ts).- DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "ai.simplex.desktop.preview"+ DeleteRegValue HKCU "${RUN_KEY}" "${APP_ID}"SectionEnddiff --git a/apps/desktop/packaging/win/package.py b/apps/desktop/packaging/win/package.pyindex 0c2ec6be..2b7d2127 100644--- a/apps/desktop/packaging/win/package.py+++ b/apps/desktop/packaging/win/package.py@@ -10,7 +10,7 @@ Tools: the `wintool` image from ./Dockerfile (NSIS, ImageMagick, resedit).python3 packaging/win/package.py [--out DIR]The setup program installs for the current user into-%LOCALAPPDATA%\\Programs\\Simplex without administrator rights, adds a Start+%LOCALAPPDATA%\\Programs\\Linger without administrator rights, adds a Startmenu shortcut and an entry under Installed apps. The zip holds the samefolder for running without installing.diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.tsindex 2d39451e..d806b7f9 100644--- a/apps/desktop/src/main/index.ts+++ b/apps/desktop/src/main/index.ts@@ -1,4 +1,4 @@-import { existsSync } from "node:fs";+import { existsSync, renameSync } from "node:fs";import os from "node:os";import path from "node:path";import { fileURLToPath } from "node:url";@@ -15,6 +15,8 @@ import {systemPreferences,} from "electron";+import { lingerHome } from "@linger/local-installation/home";+import { CredentialStore } from "./computer-credential.js";import {ComputerDaemonModule,@@ -56,17 +58,32 @@ declare const __SOURCE_DEPENDENCIES__: SourceDependencies | null;const VERSION = __DESKTOP_VERSION__;const here = path.dirname(fileURLToPath(import.meta.url));+let userDataMove: UserDataMove | undefined;// Development overrides; installed builds use the platform defaults.if (process.env.LINGER_DESKTOP_USER_DATA)app.setPath("userData", path.resolve(process.env.LINGER_DESKTOP_USER_DATA));-// The installed app keeps the data folder it had as Simplex: the Computer's-// credential, identity and enrollment live there.-else if (app.isPackaged)- app.setPath("userData", path.join(app.getPath("appData"), "Simplex"));+// The installed app's data folder holds the Computer's credential, identity+// and enrollment. Installs from before the rename move theirs here once.+else if (app.isPackaged) {+ const userData = path.join(app.getPath("appData"), "Linger");+ try {+ userDataMove = moveLegacyUserData(+ path.join(app.getPath("appData"), "Simplex"),+ userData,+ );+ } catch (error) {+ dialog.showErrorBox(+ "Linger could not start",+ `Could not move the app data folder to ${userData}: ${error instanceof Error ? error.message : String(error)}`,+ );+ app.exit(1);+ }+ app.setPath("userData", userData);+}// Windows shows notifications only for an app id that a Start menu shortcut// carries. The installer makes the shortcut; the app writes the id into it.-const APP_USER_MODEL_ID = "ai.simplex.desktop.preview";+const APP_USER_MODEL_ID = "com.simplexai.linger.desktop.preview";if (process.platform === "win32") app.setAppUserModelId(APP_USER_MODEL_ID);if (!app.requestSingleInstanceLock()) {@@ -82,6 +99,17 @@ async function main(): Promise<void> {const log = fileLogger(path.join(userData, "logs"), {stderr: !app.isPackaged,});+ if (userDataMove?.outcome === "kept")+ log.warn("desktop.legacy_user_data_kept", {+ legacy: userDataMove.legacy,+ user_data: userDataMove.userData,+ });+ else if (userDataMove)+ log.info("desktop.legacy_user_data_moved", {+ legacy: userDataMove.legacy,+ user_data: userDataMove.userData,+ ...(userDataMove.setAside ? { set_aside: userDataMove.setAside } : {}),+ });if (process.platform === "win32" && app.isPackaged) markStartMenuShortcut();const background = process.argv.includes("--background");const envServer = parseServerUrl(process.env.LINGER_SERVER_URL ?? "");@@ -151,10 +179,9 @@ async function main(): Promise<void> {: undefined;};// The default LINGER_HOME of the installer.- const lingerHome =- process.env.LINGER_HOME || path.join(os.homedir(), ".simplexai");+ const home = lingerHome();const localServer = new LocalServerModule({- home: lingerHome,+ home,installerDirectory: path.join(here, "../installer"),...(__SOURCE_ARCHIVE__ ? { sourceArchive: __SOURCE_ARCHIVE__ } : {}),...(__SOURCE_DEPENDENCIES__@@ -242,7 +269,7 @@ async function main(): Promise<void> {});return result.canceled ? undefined : result.filePaths[0];},- defaultDirectory: path.join(app.getPath("home"), "Simplex"),+ defaultDirectory: path.join(app.getPath("home"), "Linger"),}),new ComputerDaemonModule({spawn: spawnDaemon(@@ -268,7 +295,7 @@ async function main(): Promise<void> {new DiagnosticsModule({userData,logs: path.join(userData, "logs"),- home: lingerHome,+ home,version: VERSION,output: () => app.getPath("downloads"),openFolder: (folder) => shell.openPath(folder),@@ -398,8 +425,7 @@ async function daemonEnv(log: Logger): Promise<Record<string, string>> {for (const [name, value] of Object.entries(withLoginShell(process.env as Record<string, string>, login),)) {- if (value === undefined || /^(ELECTRON_|LINGER_|SIMPLEX)/i.test(name))- continue;+ if (value === undefined || /^(ELECTRON_|LINGER_)/i.test(name)) continue;env[name] = value;}for (const name of [@@ -412,3 +438,36 @@ async function daemonEnv(log: Logger): Promise<Record<string, string>> {}return env;}++interface UserDataMove {+ readonly outcome: "moved" | "kept";+ readonly legacy: string;+ readonly userData: string;+ /** Where a Linger folder without a Computer credential was set aside. */+ readonly setAside?: string;+}++// The data folder of the app as it was named before the rename moves once to+// its Linger name. A Linger folder that already holds a Computer credential+// wins and the old one stays; one without a credential is set aside, so the+// Computer keeps its identity instead of enrolling again under a new id.+function moveLegacyUserData(+ legacy: string,+ userData: string,+): UserDataMove | undefined {+ if (!existsSync(legacy)) return undefined;+ if (existsSync(path.join(userData, "computer", "credential.json")))+ return { outcome: "kept", legacy, userData };+ let setAside: string | undefined;+ if (existsSync(userData)) {+ setAside = `${userData}.before-move-${Date.now()}`;+ renameSync(userData, setAside);+ }+ renameSync(legacy, userData);+ return {+ outcome: "moved",+ legacy,+ userData,+ ...(setAside ? { setAside } : {}),+ };+}diff --git a/apps/desktop/src/main/legacy-bridge.test.ts b/apps/desktop/src/main/legacy-bridge.test.tsindex 28cdb1f2..132502b9 100644--- a/apps/desktop/src/main/legacy-bridge.test.ts+++ b/apps/desktop/src/main/legacy-bridge.test.ts@@ -105,9 +105,9 @@ describe.skipIf(process.platform === "win32")("legacy bridge socket", () => {});describe("defaultBridgeStateDirectory", () => {- it("matches the 0.16 bridge layout", () => {+ it("matches the 0.16 bridge layout after the data folder moved", () => {expect(defaultBridgeStateDirectory("darwin", {}, "/Users/a")).toBe(- "/Users/a/Library/Application Support/Simplex/bridge",+ "/Users/a/Library/Application Support/Linger/bridge",);expect(defaultBridgeStateDirectory("linux", {}, "/home/a")).toBe("/home/a/.local/state/simplex/bridge",diff --git a/apps/desktop/src/main/legacy-bridge.ts b/apps/desktop/src/main/legacy-bridge.tsindex 963615fe..8fc932ba 100644--- a/apps/desktop/src/main/legacy-bridge.ts+++ b/apps/desktop/src/main/legacy-bridge.ts@@ -18,12 +18,16 @@ export const defaultBridgeStateDirectory = (): string => {if (env.LINGER_BRIDGE_STATE_DIR)return path.resolve(env.LINGER_BRIDGE_STATE_DIR);+ // The bridge kept its state under the app's name before the rename. On+ // macOS that folder is the app's data folder, which index.ts moves to its+ // Linger name before this runs; elsewhere the bridge's own folder keeps the+ // old name, which names only the migration source here.if (platform === "darwin") {return path.join(home,"Library","Application Support",- "Simplex",+ "Linger","bridge",);}diff --git a/apps/desktop/src/main/local-server.test.ts b/apps/desktop/src/main/local-server.test.tsindex 27e9614d..07dc7ed7 100644--- a/apps/desktop/src/main/local-server.test.ts+++ b/apps/desktop/src/main/local-server.test.ts@@ -1660,7 +1660,7 @@ describe("LocalServerModule install location", () => {mkdirSync(picked);writeFileSync(path.join(picked, "notes.txt"), "");await f.module.chooseLocation(picked);- const home = path.join(picked, "Simplex");+ const home = path.join(picked, "Linger");expect(f.module.status().location).toEqual({ path: home, custom: true });await f.module.begin();@@ -1709,7 +1709,7 @@ describe("LocalServerModule install location", () => {await f.host.stop("quit");});- it("installs into an empty folder or one that holds Simplex", async () => {+ it("installs into an empty folder or one that holds Linger", async () => {const root = tempDirectory();expect(await installLocation(root)).toBe(root);writeFileSync(path.join(root, ".DS_Store"), "");@@ -1719,7 +1719,7 @@ describe("LocalServerModule install location", () => {expect(await installLocation(root)).toBe(root);const other = tempDirectory();writeFileSync(path.join(other, "notes.txt"), "");- expect(await installLocation(other)).toBe(path.join(other, "Simplex"));+ expect(await installLocation(other)).toBe(path.join(other, "Linger"));});it("asks for free space on the folder's disk", async () => {@@ -1822,7 +1822,7 @@ describe("LocalServerModule after a restart", () => {});it("starts the services again in the folder they were installed in", async () => {- const elsewhere = path.join(tempDirectory(), "Simplex");+ const elsewhere = path.join(tempDirectory(), "Linger");const f = fixture({}, { serverUrl: "http://localhost:3000" }, (home) => {mkdirSync(path.join(home, "desktop"), { recursive: true });writeFileSync(diff --git a/apps/desktop/src/main/local-server.ts b/apps/desktop/src/main/local-server.tsindex cc740af1..84616dc9 100644--- a/apps/desktop/src/main/local-server.ts+++ b/apps/desktop/src/main/local-server.ts@@ -22,6 +22,7 @@ import { createZstdDecompress } from "node:zlib";import { readLocalLogin } from "@linger/local-installation/account";import { downloadVerified } from "@linger/local-installation/download";+import { legacyMigrationPending } from "@linger/local-installation/home";import {removeRetrying,renameRetrying,@@ -334,11 +335,20 @@ export class LocalServerModule implements Module {async start(ctx: ModuleContext): Promise<void> {this.#ctx = ctx;+ const migrationFailure = await this.#migrateLegacyHome(ctx);// After a reboot the local services are gone; start them again while the// window still points at them.const record = await this.#readRecord();if (record) this.#home = record.home;- if (record && ctx.config.get().serverUrl === record.origin)+ if (migrationFailure) {+ // Resume would fail on the legacy record with a less useful error;+ // Retry resumes, and the installer migrates again first.+ this.#set("failed", migrationFailure);+ if (record && ctx.config.get().serverUrl === record.origin)+ ctx+ .get<WindowManagerModule>("WindowManager")+ ?.showStartFailed(migrationFailure);+ } else if (record && ctx.config.get().serverUrl === record.origin)void this.#resume(record, this.#abort.signal);this.#offDaemon = ctx.bus.on("computer.failed", (reason) => {this.#daemonFailure = reason;@@ -916,6 +926,51 @@ export class LocalServerModule implements Module {return `${this.#options.platform ?? process.platform}-${this.#options.arch ?? process.arch}`;}+ // An install from before the rename keeps legacy names in its instance+ // records; the bundled installer converts them once, before a record is+ // read. Returns why it failed, for the person to see.+ async #migrateLegacyHome(ctx: ModuleContext): Promise<string | undefined> {+ if (+ !(await legacyMigrationPending(this.#options.home)) ||+ !existsSync(this.#installerScript())+ )+ return undefined;+ const outcome = await new Promise<{ code: number | null; error: string }>(+ (resolve) => {+ const child = spawn(+ process.execPath,+ [this.#installerScript(), "--home", this.#options.home, "--migrate"],+ {+ stdio: ["ignore", "ignore", "pipe"],+ windowsHide: true,+ env: {+ ...process.env,+ ELECTRON_RUN_AS_NODE: "1",+ LINGER_HOME: this.#options.home,+ },+ },+ );+ let error = "";+ child.stderr.on("data", (chunk: Buffer) => {+ error = (error + chunk.toString("utf8")).slice(-2000);+ });+ child.once("error", (failure) =>+ resolve({ code: null, error: failure.message }),+ );+ child.once("close", (code) => resolve({ code, error }));+ },+ );+ if (outcome.code === 0) {+ ctx.log.info("local_server.home_migrated", {});+ return undefined;+ }+ const error =+ outcome.error.trim().slice(-500) ||+ `The installer exited with code ${outcome.code}.`;+ ctx.log.warn("local_server.home_migration_failed", { error });+ return error;+ }+#installerScript(): string {return path.join(this.#options.installerDirectory, "installer.js");}@@ -2390,7 +2445,7 @@ export const installLocation = async (picked: string): Promise<string> => {entries.includes("instances") ||entries.includes("installer")? picked- : path.join(picked, "Simplex");+ : path.join(picked, "Linger");};// Why Linger cannot install into `directory`, or undefined when it can: thediff --git a/apps/linger-installer/AGENTS.md b/apps/linger-installer/AGENTS.mdindex 82a67abd..07328003 100644--- a/apps/linger-installer/AGENTS.md+++ b/apps/linger-installer/AGENTS.md@@ -21,6 +21,10 @@ after a reboot and reads the outcome from the single JSON line on stdout. Italso restarts running services when the instance's `user.env` no longermatches the configuration they started with.+Every mode first converts an install from before the rename to Linger+(`migrateLegacyInstallation`); `--migrate` does only that and exits, for the+desktop client.+Run `make check-installer`; verify UI process behavior with an isolatedbrowser context and retain masked evidence. Never stop a user's existing stackor global Computer to run acceptance.diff --git a/apps/linger-installer/src/main.test.ts b/apps/linger-installer/src/main.test.tsindex b84c8149..e8edd69f 100644--- a/apps/linger-installer/src/main.test.ts+++ b/apps/linger-installer/src/main.test.ts@@ -128,3 +128,12 @@ it("saves keys in the instance's user.env without echoing their values", async (error: "Invalid keys",});});++it("migrates without a source checkout", async () => {+ const { parseInstallerArguments } = await import("./main.js");+ const home = path.join(os.tmpdir(), "linger-migrate-home");+ expect(parseInstallerArguments(["--home", home, "--migrate"])).toMatchObject({+ home,+ migrate: true,+ });+});diff --git a/apps/linger-installer/src/main.ts b/apps/linger-installer/src/main.tsindex 1fd108f0..59564731 100644--- a/apps/linger-installer/src/main.ts+++ b/apps/linger-installer/src/main.ts@@ -1,5 +1,5 @@import path from "node:path";-import { homedir } from "node:os";+import { lingerHome } from "@linger/local-installation/home";import { fileURLToPath } from "node:url";import { launchInstaller } from "./server/launch.js";export { startInstallerServer } from "./server/server.js";@@ -15,8 +15,9 @@ export function parseInstallerArguments(args: string[]) {resume?: boolean;inspect?: boolean;userKeys?: boolean;+ migrate?: boolean;} = {- home: process.env.LINGER_HOME ?? path.join(homedir(), ".simplexai"),+ home: lingerHome(),};for (let i = 0; i < args.length; i++) {const flag = args[i];@@ -32,6 +33,10 @@ export function parseInstallerArguments(args: string[]) {options.inspect = true;continue;}+ if (flag === "--migrate") {+ options.migrate = true;+ continue;+ }if (flag === "--user-keys") {options.userKeys = true;continue;@@ -60,7 +65,12 @@ export function parseInstallerArguments(args: string[]) {options.port = port;}}- if (!options.sourceRepo && !options.inspect && !options.userKeys)+ if (+ !options.sourceRepo &&+ !options.inspect &&+ !options.userKeys &&+ !options.migrate+ )throw new Error("The installer needs a source checkout (--source-repo).");if (options.resume && !options.instanceName)throw new Error("Resume needs a source checkout and an instance.");@@ -218,7 +228,19 @@ if (} catch (error) {failedToStart(error);}- if (options?.userKeys) await userKeys(options);+ // Installs from before the rename move to the Linger home once, before+ // any mode opens it; --migrate does only that, for the desktop client.+ if (options)+ await import("@linger/local-installation/legacy-migration")+ .then(({ migrateLegacyInstallation }) =>+ migrateLegacyInstallation({ home: options!.home }),+ )+ .catch((error: unknown) => {+ failedToStart(error);+ options = undefined;+ });+ if (options?.migrate) process.exit(0);+ else if (options?.userKeys) await userKeys(options);else if (options?.inspect) await inspect(options);else if (options?.resume) await resume(options);else if (options) await serve(options).catch(failedToStart);diff --git a/apps/node-services/src/agent/runner-gateway/daemon-identity-verifier.ts b/apps/node-services/src/agent/runner-gateway/daemon-identity-verifier.tsindex 93615d37..cd7f1951 100644--- a/apps/node-services/src/agent/runner-gateway/daemon-identity-verifier.ts+++ b/apps/node-services/src/agent/runner-gateway/daemon-identity-verifier.ts@@ -120,6 +120,8 @@ export const computerDaemonIdentityProofPayload = (): Buffer =>Buffer.from([+ // Frozen wire constant: daemons and Agent Services of any version must+ // sign and verify the same label, so it keeps its original name."simplex-computer-daemon-identity-v1",hello.runner_id,hello.connection_nonce,diff --git a/contracts/generated/typescript/src/generated/runner-gateway/schema.ts b/contracts/generated/typescript/src/generated/runner-gateway/schema.tsindex ca949e4a..bb36be74 100644--- a/contracts/generated/typescript/src/generated/runner-gateway/schema.ts+++ b/contracts/generated/typescript/src/generated/runner-gateway/schema.ts@@ -1,7 +1,7 @@/** Generated Runner Gateway JSON Schema. Do not edit. */export const runnerGatewayEnvelopeSchema = {$schema: "https://json-schema.org/draft/2020-12/schema",- $id: "https://simplex.ai/contracts/runner-gateway/v2/envelope.schema.json",+ $id: "https://simplexai.com/contracts/runner-gateway/v2/envelope.schema.json",title: "RunnerGatewayEnvelope",type: "object",oneOf: [diff --git a/contracts/runner-gateway/envelope.schema.json b/contracts/runner-gateway/envelope.schema.jsonindex 73f4be70..5a5f556c 100644--- a/contracts/runner-gateway/envelope.schema.json+++ b/contracts/runner-gateway/envelope.schema.json@@ -1,6 +1,6 @@{"$schema": "https://json-schema.org/draft/2020-12/schema",- "$id": "https://simplex.ai/contracts/runner-gateway/v2/envelope.schema.json",+ "$id": "https://simplexai.com/contracts/runner-gateway/v2/envelope.schema.json","title": "RunnerGatewayEnvelope","type": "object","oneOf": [diff --git a/packages/local-installation/AGENTS.md b/packages/local-installation/AGENTS.mdindex 305150b3..47b97d2c 100644--- a/packages/local-installation/AGENTS.md+++ b/packages/local-installation/AGENTS.md@@ -26,6 +26,20 @@ Every update or recreate path stops node-services on its own, right beforeTeamHub restarts (natively: for a changed configuration) and while TeamHub isstill up, so its graceful shutdown requeues in-flight Agent Runs.+The home is `LINGER_HOME`, else `~/.simplexai` (`home.ts`). Installs from+before the product was renamed Linger convert once in+`legacy-migration.ts`, which the installer runs before it opens the home and+the desktop runs through `installer.js --migrate`. Under each instance's lock+it stops the instance's Computer and native services, renames `SIMPLEX_*`+keys in the generated env files, and gives the instance its+`linger-<name>-<hash>` project name. The legacy project name in+`instance.json` marks an instance as not yet converted, so it is written last+and a rerun after a crash converges. A damaged record is skipped, and a+failing instance does not stop the others; the migration then throws one+error naming each failed instance, and the installer does not start. The+cache markers `.simplex-files.json` and `.simplex-model-package.json` keep+their names.+Move a freshly downloaded or unpacked file or folder into place with`renameRetrying` from `fs-retry.ts`: on Windows antivirus and indexing holdnew files for a moment, and a plain rename then fails with EPERM.diff --git a/packages/local-installation/src/home.ts b/packages/local-installation/src/home.tsnew file mode 100644index 00000000..2da04ec9--- /dev/null+++ b/packages/local-installation/src/home.ts@@ -0,0 +1,52 @@+import { readFile, readdir } from "node:fs/promises";+import { homedir } from "node:os";+import path from "node:path";++// Folder names the installer accepts as instances; legacy-migration.ts skips+// the rest, so they never make a migration pending.+export const INSTANCE_NAME = /^[a-z][a-z0-9-]{0,39}$/;++/** The installation home: LINGER_HOME, else ~/.simplexai. */+export function lingerHome(+ environment: NodeJS.ProcessEnv = process.env,+ userHome: string = homedir(),+): string {+ return path.resolve(+ environment.LINGER_HOME || path.join(userHome, ".simplexai"),+ );+}++/**+ * Whether an instance under `home` still carries the project name of an+ * install from before the rename, so legacy-migration.ts has work to do.+ * Reads only each instance's record, so the desktop can ask before it starts+ * the installer to migrate.+ */+export async function legacyMigrationPending(home: string): Promise<boolean> {+ const directory = path.join(home, "instances");+ const names = await readdir(directory).catch(+ (error: NodeJS.ErrnoException) => {+ if (error.code === "ENOENT" || error.code === "ENOTDIR") return [];+ throw error;+ },+ );+ for (const name of names) {+ if (!INSTANCE_NAME.test(name)) continue;+ const record = await readFile(+ path.join(directory, name, "instance.json"),+ "utf8",+ ).catch(() => undefined);+ if (record === undefined) continue;+ let project: unknown;+ try {+ project = (JSON.parse(record) as { project?: unknown }).project;+ } catch {+ // A damaged record is not the migration's to judge; the installer+ // reports it when it reads the instance.+ continue;+ }+ if (typeof project === "string" && project.startsWith("simplex-"))+ return true;+ }+ return false;+}diff --git a/packages/local-installation/src/instance.ts b/packages/local-installation/src/instance.tsindex 83ceba8a..0a918234 100644--- a/packages/local-installation/src/instance.ts+++ b/packages/local-installation/src/instance.ts@@ -7,7 +7,7 @@ import {privateDirectory,readPrivate,} from "./private-files.js";-import { homedir } from "node:os";+import { lingerHome } from "./home.js";import path from "node:path";import { DatabaseSync } from "node:sqlite";import { parseEnv } from "node:util";@@ -46,8 +46,8 @@ interface InstanceOptions {// Generated once per instance and never rewritten: the database, the service// credentials and the Composio key TeamHub saves are bound to these values.const credentials: Record<string, () => string> = {- SIMPLEX_POSTGRES_PASSWORD: () => randomBytes(32).toString("hex"),- SIMPLEX_SECRET_SEED: () => randomBytes(32).toString("hex"),+ LINGER_POSTGRES_PASSWORD: () => randomBytes(32).toString("hex"),+ LINGER_SECRET_SEED: () => randomBytes(32).toString("hex"),// TeamHub requires 32 bytes in standard base64.TEAMHUB_SECRET_ENCRYPTION_KEY: () => randomBytes(32).toString("base64"),};@@ -63,17 +63,13 @@ export function instanceRoot(options: { name: string; home?: string }): string {"Invalid instance name; use lowercase letters, numbers and hyphens",);return path.join(- path.resolve(- options.home ??- process.env.LINGER_HOME ??- path.join(homedir(), ".simplexai"),- ),+ path.resolve(options.home ?? lingerHome()),"instances",options.name,);}-function composeProject(root: string, name: string): string {- return `simplex-${name}-${createHash("sha256").update(root).digest("hex").slice(0, 12)}`;+export function composeProject(root: string, name: string): string {+ return `linger-${name}-${createHash("sha256").update(root).digest("hex").slice(0, 12)}`;}export async function loadInstance(options: {name: string;diff --git a/packages/local-installation/src/legacy-migration.test.ts b/packages/local-installation/src/legacy-migration.test.tsnew file mode 100644index 00000000..98be2b22--- /dev/null+++ b/packages/local-installation/src/legacy-migration.test.ts@@ -0,0 +1,191 @@+import { createHash } from "node:crypto";+import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";+import { tmpdir } from "node:os";+import path from "node:path";+import { afterEach, describe, expect, it, vi } from "vitest";+import { loadInstance, withInstanceLock, type Instance } from "./instance.js";+import { migrateLegacyInstallation } from "./legacy-migration.js";+import { legacyMigrationPending } from "./home.js";++const roots: string[] = [];+afterEach(async () => {+ await Promise.all(+ roots.splice(0).map((root) => rm(root, { recursive: true, force: true })),+ );+});++async function temporary(): Promise<string> {+ const root = await mkdtemp(path.join(tmpdir(), "linger-legacy-"));+ roots.push(root);+ return root;+}++async function put(file: string, contents: string): Promise<void> {+ await mkdir(path.dirname(file), { recursive: true, mode: 0o700 });+ await writeFile(file, contents, { mode: 0o600 });+}++// An instance as an install from before the rename left it.+async function legacyInstance(+ home: string,+ name: string,+ mode: Instance["mode"] = "source-native",+): Promise<Instance> {+ const root = path.join(home, "instances", name);+ const instance: Instance = {+ schemaVersion: 1,+ name,+ mode,+ root,+ project: `simplex-${name}-${createHash("sha256").update(root).digest("hex").slice(0, 12)}`,+ origin: "http://localhost:3999",+ port: 3999,+ releaseDir: path.join(home, "releases", "1"),+ computerConfig: path.join(root, "computer", "config.json"),+ computerExecutable: "linger-computer",+ ...(mode === "source-native"+ ? {+ releaseDir: "/checkout",+ source: {+ repo: "/checkout",+ ports: {+ web: 3999,+ teamhub: 4001,+ nodeServices: 4002,+ document: 4003,+ postgres: 4004,+ },+ },+ }+ : {}),+ };+ await put(path.join(root, "instance.json"), JSON.stringify(instance));+ await put(+ path.join(root, "services.env"),+ "SIMPLEX_POSTGRES_PASSWORD=pw\nSIMPLEX_SECRET_SEED=seed\nTEAMHUB_SECRET_ENCRYPTION_KEY=key\n",+ );+ await put(+ path.join(root, "computer", "config.json"),+ JSON.stringify({ state: path.join(root, "computer", "state") }),+ );+ return instance;+}++describe("migrateLegacyInstallation", () => {+ it("gives each instance its Linger names once", async () => {+ const home = await temporary();+ await legacyInstance(home, "desktop");+ const stopped: string[] = [];+ const options = {+ home,+ stopInstance: vi.fn(async (instance: Instance) => {+ stopped.push(instance.name);+ }),+ };+ expect(await legacyMigrationPending(home)).toBe(true);++ await migrateLegacyInstallation(options);++ const instance = (await loadInstance({ name: "desktop", home }))!;+ expect(instance.project).toMatch(/^linger-desktop-[a-f0-9]{12}$/);+ expect(+ await readFile(path.join(instance.root, "services.env"), "utf8"),+ ).toBe(+ "LINGER_POSTGRES_PASSWORD=pw\nLINGER_SECRET_SEED=seed\nTEAMHUB_SECRET_ENCRYPTION_KEY=key\n",+ );+ expect(stopped).toEqual(["desktop"]);+ expect(await legacyMigrationPending(home)).toBe(false);++ await migrateLegacyInstallation(options);+ expect(stopped).toEqual(["desktop"]);+ });++ it("skips a damaged record and converts the other instances", async () => {+ const home = await temporary();+ await put(path.join(home, "instances", "broken", "instance.json"), "{");+ await legacyInstance(home, "desktop");+ const stopInstance = vi.fn(async () => {});++ await migrateLegacyInstallation({ home, stopInstance });++ expect(stopInstance).toHaveBeenCalledTimes(1);+ expect((await loadInstance({ name: "desktop", home }))!.project).toMatch(+ /^linger-desktop-/,+ );+ });++ it("converts the other instances when one fails, then names it", async () => {+ const home = await temporary();+ await legacyInstance(home, "alpha");+ await legacyInstance(home, "beta");+ const stopInstance = vi.fn(async (instance: Instance) => {+ if (instance.name === "alpha")+ throw new Error("Instance busy: active operations are running");+ });++ await expect(+ migrateLegacyInstallation({ home, stopInstance }),+ ).rejects.toThrow(/alpha: Instance busy: active operations are running/);++ expect(stopInstance).toHaveBeenCalledTimes(2);+ expect((await loadInstance({ name: "beta", home }))!.project).toMatch(+ /^linger-beta-/,+ );+ expect(await legacyMigrationPending(home)).toBe(true);++ stopInstance.mockImplementation(async () => {});+ await migrateLegacyInstallation({ home, stopInstance });+ expect((await loadInstance({ name: "alpha", home }))!.project).toMatch(+ /^linger-alpha-/,+ );+ expect(await legacyMigrationPending(home)).toBe(false);+ });++ it("reports an instance whose lock another installer holds", async () => {+ const home = await temporary();+ const instance = await legacyInstance(home, "desktop");+ const stopInstance = vi.fn(async () => {});++ await withInstanceLock(instance, () =>+ expect(migrateLegacyInstallation({ home, stopInstance })).rejects.toThrow(+ /desktop: Instance busy/,+ ),+ );++ expect(stopInstance).not.toHaveBeenCalled();+ expect(await legacyMigrationPending(home)).toBe(true);+ });++ it("converges after a crash that renamed only some keys", async () => {+ const home = await temporary();+ const instance = await legacyInstance(home, "desktop");+ // The state a crash leaves between the env rewrite and instance.json.+ await put(+ path.join(instance.root, "services.env"),+ "LINGER_POSTGRES_PASSWORD=pw\nSIMPLEX_SECRET_SEED=seed\n",+ );+ const stopInstance = vi.fn(async () => {});++ await migrateLegacyInstallation({ home, stopInstance });++ expect(stopInstance).toHaveBeenCalledTimes(1);+ expect(+ await readFile(path.join(instance.root, "services.env"), "utf8"),+ ).toBe("LINGER_POSTGRES_PASSWORD=pw\nLINGER_SECRET_SEED=seed\n");+ expect(await legacyMigrationPending(home)).toBe(false);+ });++ it("leaves a home without legacy instances untouched", async () => {+ const home = await temporary();+ const stopInstance = vi.fn(async () => {});+ await migrateLegacyInstallation({ home, stopInstance });+ expect(stopInstance).not.toHaveBeenCalled();+ expect(await legacyMigrationPending(home)).toBe(false);+ });++ it("does not count a damaged instance record as pending", async () => {+ const home = await temporary();+ await put(path.join(home, "instances", "broken", "instance.json"), "{");+ expect(await legacyMigrationPending(home)).toBe(false);+ });+});diff --git a/packages/local-installation/src/legacy-migration.ts b/packages/local-installation/src/legacy-migration.tsnew file mode 100644index 00000000..ae726c63--- /dev/null+++ b/packages/local-installation/src/legacy-migration.ts@@ -0,0 +1,117 @@+import { readdir } from "node:fs/promises";+import path from "node:path";+import { stopComputer } from "./computer.js";+import { INSTANCE_NAME, lingerHome } from "./home.js";+import { composeProject, withInstanceLock, type Instance } from "./instance.js";+import { stopModelGateway } from "./model-gateway.js";+import { stopNativeProcess } from "./native-process.js";+import { nativeServices } from "./native-source.js";+import { atomicPrivate, readPrivate } from "./private-files.js";++// Names that installs made while the product was named Simplex still carry.+// They identify what this one-time migration converts; nothing reads them+// after it.+const LEGACY_PROJECT_PREFIX = "simplex-";+const LEGACY_ENVIRONMENT_PREFIX = /^SIMPLEX_/gm;+// Generated instance files whose keys carried the legacy prefix. user.env is+// the person's own file and never held them.+const ENVIRONMENT_FILES = ["services.env", "livekit.env", "native.env"];++export interface LegacyMigrationOptions {+ /** The home to migrate; LINGER_HOME or ~/.simplexai by default. */+ readonly home?: string;+ /** Stops an instance's processes before its names change. */+ readonly stopInstance?: (instance: Instance) => Promise<void>;+}++/**+ * Converts an installation made while the product was named Simplex, once:+ * each instance gets its Linger project name and LINGER_* environment keys.+ * An instance that fails does not hold back the others; one error at the end+ * names every instance that is still legacy and why.+ */+export async function migrateLegacyInstallation(+ options: LegacyMigrationOptions = {},+): Promise<void> {+ const home = path.resolve(options.home ?? lingerHome());+ const stop = options.stopInstance ?? stopLegacyInstance;+ const directory = path.join(home, "instances");+ const failures: string[] = [];+ for (const name of await children(directory)) {+ if (!INSTANCE_NAME.test(name)) continue;+ const root = path.join(directory, name);+ try {+ // Converted instances are left unlocked: an installer job may hold+ // their lock while this runs at the next start.+ if (!isLegacy(await readInstance(root))) continue;+ await withInstanceLock({ root } as Instance, () =>+ migrateInstance(root, name, stop),+ );+ } catch (error) {+ failures.push(+ `${name}: ${error instanceof Error ? error.message : String(error)}`,+ );+ }+ }+ if (failures.length > 0)+ throw new Error(+ `Could not convert these instances to Linger names. Stop any task running in them and start Linger again.\n${failures.join("\n")}`,+ );+}++async function children(directory: string): Promise<string[]> {+ return readdir(directory).catch((error: NodeJS.ErrnoException) => {+ if (error.code === "ENOENT" || error.code === "ENOTDIR") return [];+ throw error;+ });+}++// A damaged record is not this migration's to judge, as in+// legacyMigrationPending; the installer reports it when it loads the instance.+async function readInstance(root: string): Promise<Instance | undefined> {+ const text = await readPrivate(path.join(root, "instance.json"));+ if (text === undefined) return undefined;+ try {+ return JSON.parse(text) as Instance;+ } catch {+ return undefined;+ }+}++function isLegacy(instance: Instance | undefined): instance is Instance {+ return instance?.project?.startsWith(LEGACY_PROJECT_PREFIX) ?? false;+}++/** Stops what an instance runs from its folder, using its stored settings. */+async function stopLegacyInstance(instance: Instance): Promise<void> {+ await stopComputer(instance);+ for (const name of nativeServices)+ await stopNativeProcess(instance.root, name);+ await stopModelGateway(instance, undefined);+}++async function migrateInstance(+ root: string,+ name: string,+ stop: (instance: Instance) => Promise<void>,+): Promise<void> {+ const instance = await readInstance(root);+ if (!isLegacy(instance)) return;+ await stop(instance);+ for (const file of ENVIRONMENT_FILES) {+ const location = path.join(root, file);+ const text = await readPrivate(location);+ const renamed = text?.replace(LEGACY_ENVIRONMENT_PREFIX, "LINGER_");+ if (renamed !== text) await atomicPrivate(location, renamed!);+ }+ // Written last: the legacy project name is what marks the instance as+ // not yet migrated.+ await atomicPrivate(+ path.join(root, "instance.json"),+ JSON.stringify(+ { ...instance, project: composeProject(root, name) },+ null,+ 2,+ ) + "\n",+ );+}diff --git a/packages/local-installation/src/native-database.test.ts b/packages/local-installation/src/native-database.test.tsindex 129b3754..5aee4f45 100644--- a/packages/local-installation/src/native-database.test.ts+++ b/packages/local-installation/src/native-database.test.ts@@ -8,7 +8,7 @@ vi.mock("./native-process.js", () => ({vi.mock("./instance.js", () => ({privateDirectory: vi.fn(async () => {}),atomicPrivate: vi.fn(async () => {}),- readPrivate: vi.fn(async () => "SIMPLEX_POSTGRES_PASSWORD=secret\n"),+ readPrivate: vi.fn(async () => "LINGER_POSTGRES_PASSWORD=secret\n"),}));import path from "node:path";import { afterEach, describe, expect, it, vi } from "vitest";diff --git a/packages/local-installation/src/native-database.ts b/packages/local-installation/src/native-database.tsindex 2761e0d6..255c957a 100644--- a/packages/local-installation/src/native-database.ts+++ b/packages/local-installation/src/native-database.ts@@ -63,7 +63,7 @@ export async function prepareNativeDatabase(options: {await privateDirectory(data);const password = parseEnv((await readPrivate(path.join(instance.root, "services.env")))!,- ).SIMPLEX_POSTGRES_PASSWORD!;+ ).LINGER_POSTGRES_PASSWORD!;await atomicPrivate(passwordFile, `${password}\n`);let initialized = false;try {diff --git a/packages/local-installation/src/native-source.ts b/packages/local-installation/src/native-source.tsindex 1a8d8546..7517bd8b 100644--- a/packages/local-installation/src/native-source.ts+++ b/packages/local-installation/src/native-source.ts@@ -58,7 +58,7 @@ import {} from "./apple-developer-tools.js";import type { InstallOutcome, InstallerEvent, InstallStage } from "./events.js";-const nativeServices = [+export const nativeServices = ["web","node-services","teamhub",diff --git a/packages/local-installation/src/source-checkout.ts b/packages/local-installation/src/source-checkout.tsindex da245371..25bdf54b 100644--- a/packages/local-installation/src/source-checkout.ts+++ b/packages/local-installation/src/source-checkout.ts@@ -204,9 +204,9 @@ export async function prepareSourceConfiguration(POSTGRES_PORT: String(ports.postgres),WEB_PUBLIC_ORIGIN: instance.origin,AGENT_RUNNER_PUBLIC_GATEWAY_URL: `ws://127.0.0.1:${ports.nodeServices}/v1/runner-gateway`,- LINGER_SECRET_SEED: secrets.SIMPLEX_SECRET_SEED!,+ LINGER_SECRET_SEED: secrets.LINGER_SECRET_SEED!,TEAMHUB_SECRET_ENCRYPTION_KEY: secrets.TEAMHUB_SECRET_ENCRYPTION_KEY!,- TEAMHUB_DATABASE_URL: `postgres://simplexai:${encodeURIComponent(secrets.SIMPLEX_POSTGRES_PASSWORD!)}@127.0.0.1:${ports.postgres}/simplexai?sslmode=disable`,+ TEAMHUB_DATABASE_URL: `postgres://simplexai:${encodeURIComponent(secrets.LINGER_POSTGRES_PASSWORD!)}@127.0.0.1:${ports.postgres}/simplexai?sslmode=disable`,TEAMHUB_HTTP_ADDRESS: `127.0.0.1:${ports.teamhub}`,TEAMHUB_BASE_URL: `http://127.0.0.1:${ports.teamhub}`,TEAMHUB_CLI_BASE_URL: `http://127.0.0.1:${ports.teamhub}`,diff --git a/packages/local-installation/src/user-environment.test.ts b/packages/local-installation/src/user-environment.test.tsindex f15ec348..367f9c15 100644--- a/packages/local-installation/src/user-environment.test.ts+++ b/packages/local-installation/src/user-environment.test.ts@@ -40,7 +40,7 @@ describe("readUserEnvironment", () => {const directory = await root();await writeFile(userEnvironmentFile(directory),- "LINGER_SECRET_SEED=override\nSIMPLEX_HTTP_PORT=1\nXAI_API_KEY=xai\n",+ "LINGER_SECRET_SEED=override\nLINGER_HTTP_PORT=1\nXAI_API_KEY=xai\n",{ mode: 0o600 },);const warnings: string[] = [];