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.
feat(desktop): build in the hosted diagnostics receiver from the release pipeline
claude-opus-5-5-mediumaeaa80626165
diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.ymlindex f0bdf3bd..f42d6a1f 100644--- a/.github/workflows/desktop-release.yml+++ b/.github/workflows/desktop-release.yml@@ -153,6 +153,10 @@ jobs:echo "WINDOWS_SIGNING_PASSWORD_FILE=$keys/authenticode.password" >>"$GITHUB_ENV"fi- run: scripts/ci/desktop-release.sh build ${{ matrix.target }}+ env:+ # The hosted diagnostics receiver this build carries; a secret so+ # the address stays masked. Without it Send Diagnostics is hidden.+ LINGER_DIAGNOSTICS_UPLOAD_URL: ${{ secrets.LINGER_DIAGNOSTICS_UPLOAD_URL }}- name: Remove signing filesif: always()run: rm -rf "$RUNNER_TEMP/signing"diff --git a/apps/desktop/AGENTS.md b/apps/desktop/AGENTS.mdindex 22200ffe..7d5ea872 100644--- a/apps/desktop/AGENTS.md+++ b/apps/desktop/AGENTS.md@@ -207,8 +207,9 @@ Gateway and runs Agents. The daemon exits with the app.platform.- `src/main/diagnostics-upload.ts`: "Send Diagnostics" on the same threesurfaces, shown only while a receiver is set up (`diagnosticsUploadUrl` in- `config.json`, else `HOSTED_DIAGNOSTICS_UPLOAD_URL`, a placeholder that is- unset until the hosted receiver runs). `DiagnosticsSender` builds the zip+ `config.json`, else `HOSTED_DIAGNOSTICS_UPLOAD_URL`, which `build.mjs` bakes+ in from the release pipeline's `LINGER_DIAGNOSTICS_UPLOAD_URL` secret and+ leaves unset in other builds). `DiagnosticsSender` builds the zipinto `<userData>/diagnostics-outbox`, waits for consent showing every file,the size and the host, uploads it with the[`linger.diagnostics-upload/v1`](../../docs/diagnostics-upload.md)diff --git a/apps/desktop/build.mjs b/apps/desktop/build.mjsindex 796af8a7..71e08c3d 100644--- a/apps/desktop/build.mjs+++ b/apps/desktop/build.mjs@@ -10,6 +10,7 @@ import path from "node:path";import { build } from "esbuild";import { buildDaemon } from "./scripts/build-daemon.mjs";+import { hostedDiagnosticsUploadUrl } from "./scripts/diagnostics-upload-url.mjs";import { buildTeamhub, TEAMHUB_TARGETS } from "./scripts/build-teamhub.mjs";import {buildRuntime,@@ -89,6 +90,9 @@ const common = {__DESKTOP_VERSION__: JSON.stringify(version),__SOURCE_ARCHIVE__: JSON.stringify(sourceArchive),__SOURCE_DEPENDENCIES__: JSON.stringify(sourceDependencies),+ __HOSTED_DIAGNOSTICS_UPLOAD_URL__: JSON.stringify(+ hostedDiagnosticsUploadUrl(process.env.LINGER_DIAGNOSTICS_UPLOAD_URL),+ ),},logLevel: "warning",};diff --git a/apps/desktop/scripts/diagnostics-upload-url.d.mts b/apps/desktop/scripts/diagnostics-upload-url.d.mtsnew file mode 100644index 00000000..07a7275d--- /dev/null+++ b/apps/desktop/scripts/diagnostics-upload-url.d.mts@@ -0,0 +1,3 @@+export function hostedDiagnosticsUploadUrl(+ value: string | undefined,+): string | null;diff --git a/apps/desktop/scripts/diagnostics-upload-url.mjs b/apps/desktop/scripts/diagnostics-upload-url.mjsnew file mode 100644index 00000000..4406f1b4--- /dev/null+++ b/apps/desktop/scripts/diagnostics-upload-url.mjs@@ -0,0 +1,20 @@+// The hosted diagnostics receiver a build carries, from+// LINGER_DIAGNOSTICS_UPLOAD_URL. The release pipeline provides it; forks,+// local builds and self-hosted builds have none, so Send Diagnostics stays+// hidden unless config.json names a receiver. The error never repeats the+// value, which comes from a secret.+export function hostedDiagnosticsUploadUrl(value) {+ const url = value?.trim();+ if (!url) return null;+ let parsed;+ try {+ parsed = new URL(url);+ } catch {+ parsed = undefined;+ }+ if (parsed?.protocol !== "https:" || parsed.username || parsed.password)+ throw new Error(+ "LINGER_DIAGNOSTICS_UPLOAD_URL must be an https URL without a user name or password",+ );+ return url;+}diff --git a/apps/desktop/src/main/diagnostics-upload.test.ts b/apps/desktop/src/main/diagnostics-upload.test.tsindex 139f0d77..5c021dd5 100644--- a/apps/desktop/src/main/diagnostics-upload.test.ts+++ b/apps/desktop/src/main/diagnostics-upload.test.ts@@ -3,15 +3,20 @@ import { existsSync, writeFileSync } from "node:fs";import http from "node:http";import type { AddressInfo } from "node:net";import path from "node:path";+import { pathToFileURL } from "node:url";+import { build } from "esbuild";import { afterEach, describe, expect, it, vi } from "vitest";+import { hostedDiagnosticsUploadUrl } from "../../scripts/diagnostics-upload-url.mjs";+import type { SetupDiagnosticsSend } from "../shared/setup.js";import { ConfigStore } from "./config.js";import {DIAGNOSTICS_UPLOAD_SCHEMA,DiagnosticsSender,DiagnosticsUploadError,+ HOSTED_DIAGNOSTICS_UPLOAD_URL,MAX_DIAGNOSTICS_UPLOAD_BYTES,consentText,diagnosticsUploadUrl,@@ -66,6 +71,73 @@ describe("diagnosticsUploadUrl in config.json", () => {});});+describe("hosted receiver from the build", () => {+ const hosted = "https://diagnostics.example.com/v1/reports";++ it("is none without LINGER_DIAGNOSTICS_UPLOAD_URL", () => {+ expect(hostedDiagnosticsUploadUrl(undefined)).toBeNull();+ expect(hostedDiagnosticsUploadUrl("")).toBeNull();+ expect(hostedDiagnosticsUploadUrl(" ")).toBeNull();+ expect(HOSTED_DIAGNOSTICS_UPLOAD_URL).toBeUndefined();+ });++ it("keeps an https URL", () => {+ expect(hostedDiagnosticsUploadUrl(` ${hosted}\n`)).toBe(hosted);+ });++ it.each([+ "http://diagnostics.example.com/v1/reports",+ "https://user:[email protected]/v1/reports",+ "not a url",+ ])("fails the build for %s without repeating it", (value) => {+ expect(() => hostedDiagnosticsUploadUrl(value)).toThrow(+ /^LINGER_DIAGNOSTICS_UPLOAD_URL must be an https URL/,+ );+ try {+ hostedDiagnosticsUploadUrl(value);+ } catch (error) {+ expect((error as Error).message).not.toContain(value);+ }+ });++ it("falls back to it after config.json", () => {+ expect(diagnosticsUploadUrl({}, undefined)).toBeUndefined();+ expect(diagnosticsUploadUrl({}, hosted)).toBe(hosted);+ expect(+ diagnosticsUploadUrl(+ { diagnosticsUploadUrl: "https://self.example.com/reports" },+ hosted,+ ),+ ).toBe("https://self.example.com/reports");+ });++ // The same define build.mjs passes, so the bundle carries the value or none.+ it.each([+ [hosted, hosted],+ [undefined, undefined],+ ])("bundles %s as the hosted receiver", async (value, expected) => {+ const outfile = path.join(tempDirectory(), "diagnostics-upload.mjs");+ await build({+ entryPoints: [path.join(import.meta.dirname, "diagnostics-upload.ts")],+ outfile,+ bundle: true,+ platform: "node",+ format: "esm",+ logLevel: "silent",+ define: {+ __HOSTED_DIAGNOSTICS_UPLOAD_URL__: JSON.stringify(+ hostedDiagnosticsUploadUrl(value),+ ),+ },+ });+ const bundled = (await import(+ pathToFileURL(outfile).href+ )) as typeof import("./diagnostics-upload.js");+ expect(bundled.HOSTED_DIAGNOSTICS_UPLOAD_URL).toBe(expected);+ expect(bundled.diagnosticsUploadUrl({})).toBe(expected);+ });+});+interface Received {ticket?: Record<string, unknown>;put?: { headers: http.IncomingHttpHeaders; body: Buffer };diff --git a/apps/desktop/src/main/diagnostics-upload.ts b/apps/desktop/src/main/diagnostics-upload.tsindex c9f53303..e2a43097 100644--- a/apps/desktop/src/main/diagnostics-upload.ts+++ b/apps/desktop/src/main/diagnostics-upload.ts@@ -13,11 +13,15 @@ import type { SetupDiagnosticsSend } from "../shared/setup.js";export const DIAGNOSTICS_UPLOAD_SCHEMA = "linger.diagnostics-upload/v1";-// The hosted receiver. Placeholder: no hosted receiver runs yet, so Send-// Diagnostics shows only when config.json names one in-// diagnosticsUploadUrl. Set this to the receiver's https URL once it is-// live.-export const HOSTED_DIAGNOSTICS_UPLOAD_URL: string | undefined = undefined;+// The hosted receiver, which the release pipeline provides at build time+// (LINGER_DIAGNOSTICS_UPLOAD_URL, see build.mjs). Builds without it (forks,+// local and self-hosted builds) and tests have none, so Send Diagnostics+// shows only when config.json names a receiver in diagnosticsUploadUrl.+declare const __HOSTED_DIAGNOSTICS_UPLOAD_URL__: string | null | undefined;+export const HOSTED_DIAGNOSTICS_UPLOAD_URL: string | undefined =+ (typeof __HOSTED_DIAGNOSTICS_UPLOAD_URL__ === "undefined"+ ? undefined+ : __HOSTED_DIAGNOSTICS_UPLOAD_URL__) ?? undefined;// Receivers may accept less; this keeps a runaway log from leaving at all.export const MAX_DIAGNOSTICS_UPLOAD_BYTES = 50 * 1024 * 1024;@@ -42,10 +46,10 @@ export const isUploadUrl = (value: string): boolean => {};// The receiver this app sends to, or none: then Send Diagnostics is hidden.-export const diagnosticsUploadUrl = (config: {- readonly diagnosticsUploadUrl?: string | undefined;-}): string | undefined =>- config.diagnosticsUploadUrl ?? HOSTED_DIAGNOSTICS_UPLOAD_URL;+export const diagnosticsUploadUrl = (+ config: { readonly diagnosticsUploadUrl?: string | undefined },+ hosted: string | undefined = HOSTED_DIAGNOSTICS_UPLOAD_URL,+): string | undefined => config.diagnosticsUploadUrl ?? hosted;const uploadTicket = z.object({schema: z.literal(DIAGNOSTICS_UPLOAD_SCHEMA),diff --git a/docs/desktop-release.md b/docs/desktop-release.mdindex b1a1c6c9..329dd581 100644--- a/docs/desktop-release.md+++ b/docs/desktop-release.md@@ -68,17 +68,18 @@ folder, read only by the signing tools and removed after the build.Set these under Settings → Secrets and variables → Actions of the repositorythat runs the workflow:-| Name | Kind | Required | Purpose |-| ------------------------------- | -------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |-| `LINGER_NATIVE_DEPS_URL` | secret (or variable) | no | Folder serving the archives `apps/desktop/distribution/*.json` pins; the `native-deps` prerelease when unset. Each download is checked against its pin. |-| `RELEASE_REPO` | variable | no | `owner/name` that receives the release; `simplexai-labs/linger` when unset. |-| `LINGER_RELEASE_TOKEN` | secret | when `RELEASE_REPO` is another repository | Fine-grained token for `RELEASE_REPO` only, with Contents: read and write. Not needed in simplexai-labs/linger itself. |-| `MACOS_DEVELOPER_ID_P12_BASE64` | secret | no | Base64 of the Developer ID `.p12`. Without it the app is signed ad hoc. |-| `MACOS_DEVELOPER_ID_PASSWORD` | secret | with the `.p12` | Password of that `.p12`. |-| `MACOS_NOTARY_KEY_JSON` | secret | no | App Store Connect API key JSON; needs the Developer ID. |-| `DESKTOP_UPDATE_KEY_PEM` | secret | for auto-update | Ed25519 private key (PEM) that signs `manifest.json`. Without it the release has no manifest and installed apps are not offered it. |-| `WINDOWS_SIGNING_P12_BASE64` | secret | no | Base64 of an Authenticode `.p12`. Without it the setup program is unsigned. |-| `WINDOWS_SIGNING_PASSWORD` | secret | with the `.p12` | Password of that `.p12`. |+| Name | Kind | Required | Purpose |+| ------------------------------- | -------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| `LINGER_NATIVE_DEPS_URL` | secret (or variable) | no | Folder serving the archives `apps/desktop/distribution/*.json` pins; the `native-deps` prerelease when unset. Each download is checked against its pin. |+| `LINGER_DIAGNOSTICS_UPLOAD_URL` | secret | no | https URL of the hosted diagnostics receiver ([diagnostics-upload.md](diagnostics-upload.md)) that the build carries. A secret, so the address stays masked in logs. Without it Send Diagnostics is hidden unless `config.json` names a receiver. |+| `RELEASE_REPO` | variable | no | `owner/name` that receives the release; `simplexai-labs/linger` when unset. |+| `LINGER_RELEASE_TOKEN` | secret | when `RELEASE_REPO` is another repository | Fine-grained token for `RELEASE_REPO` only, with Contents: read and write. Not needed in simplexai-labs/linger itself. |+| `MACOS_DEVELOPER_ID_P12_BASE64` | secret | no | Base64 of the Developer ID `.p12`. Without it the app is signed ad hoc. |+| `MACOS_DEVELOPER_ID_PASSWORD` | secret | with the `.p12` | Password of that `.p12`. |+| `MACOS_NOTARY_KEY_JSON` | secret | no | App Store Connect API key JSON; needs the Developer ID. |+| `DESKTOP_UPDATE_KEY_PEM` | secret | for auto-update | Ed25519 private key (PEM) that signs `manifest.json`. Without it the release has no manifest and installed apps are not offered it. |+| `WINDOWS_SIGNING_P12_BASE64` | secret | no | Base64 of an Authenticode `.p12`. Without it the setup program is unsigned. |+| `WINDOWS_SIGNING_PASSWORD` | secret | with the `.p12` | Password of that `.p12`. |### Bundled archivesdiff --git a/docs/diagnostics-upload.md b/docs/diagnostics-upload.mdindex d45150f5..378d788e 100644--- a/docs/diagnostics-upload.md+++ b/docs/diagnostics-upload.md@@ -21,8 +21,10 @@ once sent or declined.The receiver is `diagnosticsUploadUrl` in the desktop `config.json` (in theapp's user data folder). It must be `https`, or `http` to `localhost`,`127.0.0.1` or `[::1]` while developing a receiver; any other value is-ignored. Without it, the app uses its built-in hosted receiver, and when it-has none, Send Diagnostics is hidden.+ignored. Without it, the app uses the hosted receiver that the release+pipeline builds in (`LINGER_DIAGNOSTICS_UPLOAD_URL`, see+[desktop-release.md](desktop-release.md)); a build without one, such as a+fork's, a local or a self-hosted build, hides Send Diagnostics.```json{ "diagnosticsUploadUrl": "https://diagnostics.example.com/v1/reports" }diff --git a/scripts/ci/desktop-release.sh b/scripts/ci/desktop-release.shindex 33ac638e..790f31b2 100755--- a/scripts/ci/desktop-release.sh+++ b/scripts/ci/desktop-release.sh@@ -30,6 +30,9 @@ set -euo pipefail# (~/.cache/linger-desktop)# LINGER_NATIVE_DEPS_URL folder serving those archives by file name; in a GitLab# CI job it defaults to the project's linger-native-deps package+# LINGER_DIAGNOSTICS_UPLOAD_URL+# hosted diagnostics receiver that build.mjs builds in (https);+# without it Send Diagnostics is hidden# RELEASE_OUT output root (.linger-runtime/desktop-release); release# files go to $RELEASE_OUT/assets/# RCODESIGN rcodesign executable for darwin-arm64 (PATH)