Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

feat(switchdash): set up a Switch-core server on a remote host over SSH (CHOO-1432) (#32)

Louis Amaudruz5120ad2a0354
diff --git a/dash/apps/switchdash-desktop/drizzle/0038_remote_managed_servers.sql b/dash/apps/switchdash-desktop/drizzle/0038_remote_managed_servers.sql
new file mode 100644
index 000000000..74741f93a
--- /dev/null
+++ b/dash/apps/switchdash-desktop/drizzle/0038_remote_managed_servers.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `switch_servers` ADD `management_kind` text;--> statement-breakpoint
+ALTER TABLE `switch_servers` ADD `ssh_host` text;
\ No newline at end of file
diff --git a/dash/apps/switchdash-desktop/drizzle/meta/0038_snapshot.json b/dash/apps/switchdash-desktop/drizzle/meta/0038_snapshot.json
new file mode 100644
index 000000000..606d66664
--- /dev/null
+++ b/dash/apps/switchdash-desktop/drizzle/meta/0038_snapshot.json
@@ -0,0 +1,703 @@
+{
+ "version": "6",
+ "dialect": "sqlite",
+ "id": "acf382fa-be55-4705-8814-fed45fe863f0",
+ "prevId": "97250cdb-a224-488f-9f38-73595cc25ba1",
+ "tables": {
+ "agents": {
+ "name": "agents",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "location_id": {
+ "name": "location_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "switch_agent_id": {
+ "name": "switch_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "api_endpoint": {
+ "name": "api_endpoint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "server_id": {
+ "name": "server_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "idx_agents_location_id": {
+ "name": "idx_agents_location_id",
+ "columns": ["location_id"],
+ "isUnique": false
+ },
+ "idx_agents_server_id": {
+ "name": "idx_agents_server_id",
+ "columns": ["server_id"],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "agents_location_id_locations_id_fk": {
+ "name": "agents_location_id_locations_id_fk",
+ "tableFrom": "agents",
+ "tableTo": "locations",
+ "columnsFrom": ["location_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "agents_server_id_switch_servers_id_fk": {
+ "name": "agents_server_id_switch_servers_id_fk",
+ "tableFrom": "agents",
+ "tableTo": "switch_servers",
+ "columnsFrom": ["server_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "app_secrets": {
+ "name": "app_secrets",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "secret": {
+ "name": "secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "idx_app_secrets_key": {
+ "name": "idx_app_secrets_key",
+ "columns": ["key"],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "app_settings": {
+ "name": "app_settings",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "idx_app_settings_key": {
+ "name": "idx_app_settings_key",
+ "columns": ["key"],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "kv": {
+ "name": "kv",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "idx_kv_key": {
+ "name": "idx_kv_key",
+ "columns": ["key"],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "location_settings": {
+ "name": "location_settings",
+ "columns": {
+ "location_id": {
+ "name": "location_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "base_settings_json": {
+ "name": "base_settings_json",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'{}'"
+ },
+ "shareable_settings_json": {
+ "name": "shareable_settings_json",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'{}'"
+ },
+ "legacy_config_migrated_at": {
+ "name": "legacy_config_migrated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "location_settings_location_id_locations_id_fk": {
+ "name": "location_settings_location_id_locations_id_fk",
+ "tableFrom": "location_settings",
+ "tableTo": "locations",
+ "columnsFrom": ["location_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "locations": {
+ "name": "locations",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ssh_host": {
+ "name": "ssh_host",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "dir": {
+ "name": "dir",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "idx_locations_host_dir": {
+ "name": "idx_locations_host_dir",
+ "columns": ["ssh_host", "dir"],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "messages": {
+ "name": "messages",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "sender": {
+ "name": "sender",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "timestamp": {
+ "name": "timestamp",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "idx_messages_session_id": {
+ "name": "idx_messages_session_id",
+ "columns": ["session_id"],
+ "isUnique": false
+ },
+ "idx_messages_timestamp": {
+ "name": "idx_messages_timestamp",
+ "columns": ["timestamp"],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "messages_session_id_sessions_id_fk": {
+ "name": "messages_session_id_sessions_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "sessions",
+ "columnsFrom": ["session_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "remote_hosts": {
+ "name": "remote_hosts",
+ "columns": {
+ "ssh_host": {
+ "name": "ssh_host",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "sessions": {
+ "name": "sessions",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "config": {
+ "name": "config",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "shell_id": {
+ "name": "shell_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'system'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "agent_status": {
+ "name": "agent_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "agent_status_seen": {
+ "name": "agent_status_seen",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 1
+ },
+ "is_initial_session": {
+ "name": "is_initial_session",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "is_pinned": {
+ "name": "is_pinned",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "last_interacted_at": {
+ "name": "last_interacted_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "status_changed_at": {
+ "name": "status_changed_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "idx_sessions_agent_id": {
+ "name": "idx_sessions_agent_id",
+ "columns": ["agent_id"],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "sessions_agent_id_agents_id_fk": {
+ "name": "sessions_agent_id_agents_id_fk",
+ "tableFrom": "sessions",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "switch_servers": {
+ "name": "switch_servers",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "gateway_url": {
+ "name": "gateway_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "api_url": {
+ "name": "api_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "managed": {
+ "name": "managed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "management_kind": {
+ "name": "management_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ssh_host": {
+ "name": "ssh_host",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "idx_switch_servers_gateway_url": {
+ "name": "idx_switch_servers_gateway_url",
+ "columns": ["gateway_url"],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ }
+ },
+ "views": {},
+ "enums": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ },
+ "internal": {
+ "indexes": {}
+ }
+}
diff --git a/dash/apps/switchdash-desktop/drizzle/meta/_journal.json b/dash/apps/switchdash-desktop/drizzle/meta/_journal.json
index 3a537df8e..4d3af7920 100644
--- a/dash/apps/switchdash-desktop/drizzle/meta/_journal.json
+++ b/dash/apps/switchdash-desktop/drizzle/meta/_journal.json
@@ -267,6 +267,13 @@
"when": 1784456381313,
"tag": "0037_curvy_madame_masque",
"breakpoints": true
+ },
+ {
+ "idx": 38,
+ "version": "6",
+ "when": 1784635106895,
+ "tag": "0038_remote_managed_servers",
+ "breakpoints": true
}
]
}
diff --git a/dash/apps/switchdash-desktop/package.json b/dash/apps/switchdash-desktop/package.json
index a8037eb63..3c3743da1 100644
--- a/dash/apps/switchdash-desktop/package.json
+++ b/dash/apps/switchdash-desktop/package.json
@@ -106,7 +106,7 @@
"date-fns": "^4.1.0",
"devicon": "^2.17.0",
"dotenv": "^17.4.2",
- "drizzle-kit": "^0.24.2",
+ "drizzle-kit": "^0.31.10",
"electron": "40.8.5",
"electron-builder": "^26.8.1",
"electron-vite": "^5.0.0",
diff --git a/dash/apps/switchdash-desktop/src/main/core/agents/onboard-agent.ts b/dash/apps/switchdash-desktop/src/main/core/agents/onboard-agent.ts
index 4fa2349df..b93bafdaa 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agents/onboard-agent.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agents/onboard-agent.ts
@@ -11,6 +11,7 @@ import type {
OnboardAgentParams,
OnboardAgentResult,
} from '@shared/core/agents/onboarding';
+import type { SwitchServer } from '@shared/core/switch-servers/switch-servers';
import { basenameFromAnyPath } from '@shared/path-name';
import { agentEvents } from './agent-events';
import { createAgent } from './createAgent';
@@ -57,6 +58,27 @@ async function verifyAgentOnServer(
}
}
+/**
+ * Enforce that an agent's run location can actually reach a switchdash-managed
+ * server: a remote-managed server only from this computer or its own host (the
+ * desktop reaches it via the SSH forward; the host on loopback — nothing else
+ * has a route); a local-managed server only from this computer. External servers
+ * are unconstrained. Returns an error message for an out-of-policy pairing, else
+ * null. Mirrors the add-agent modal's picker constraint as a bypass-proof gate.
+ */
+function managedServerLocationError(server: SwitchServer, sshHost: string | null): string | null {
+ if (server.managementKind === 'remote') {
+ if (sshHost !== null && sshHost !== server.sshHost) {
+ return `This server runs on ${server.sshHost}; its agents can only run on this computer or on ${server.sshHost}.`;
+ }
+ return null;
+ }
+ if (server.managementKind === 'local' && sshHost !== null) {
+ return 'This server runs on this computer; its agents can only run on this computer.';
+ }
+ return null;
+}
+
/**
* Onboard an agent: resolve the Switch identity already configured in the
* working dir (locally or over SSH), verify it on the chosen server, and
@@ -92,6 +114,14 @@ export async function onboardAgent(params: OnboardAgentParams): Promise<OnboardA
const serverError = await verifyAgentOnServer(params.serverId, switchAgent.agentId, params.dir);
if (serverError) return err(serverError);
+ const server = await getServer(params.serverId);
+ if (server) {
+ const locationError = managedServerLocationError(server, sshHost);
+ if (locationError) {
+ return err({ type: 'invalid-directory', dir: params.dir, message: locationError });
+ }
+ }
+
const location = await ensureLocation({ sshHost, dir: params.dir, name: params.name });
const agent = await createAgent({
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/bundled-compose.ts b/dash/apps/switchdash-desktop/src/main/core/local-switch-server/bundled-compose.ts
deleted file mode 100644
index c1fbfac71..000000000
--- a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/bundled-compose.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { mkdir, writeFile } from 'node:fs/promises';
-import { dirname } from 'node:path';
-import { composeFilePath } from './paths';
-import composeYaml from './resources/standalone-docker-compose.pinned.yml?raw';
-
-/** The standalone compose bundled into the app (pinned to
- * COMPATIBLE_SWITCH_VERSION), inlined at build time. */
-export function bundledComposeYaml(): string {
- return composeYaml;
-}
-
-/** Write the bundled compose to disk so `docker compose -f <path>` can run it,
- * returning the path. Docker cannot read a file inside the packaged app bundle,
- * so it is materialised into the user-data dir on every start (cheap, and keeps
- * the on-disk copy in lockstep with the app version). */
-export async function materialiseComposeFile(): Promise<string> {
- const path = composeFilePath();
- await mkdir(dirname(path), { recursive: true });
- await writeFile(path, composeYaml, 'utf8');
- return path;
-}
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/compose.ts b/dash/apps/switchdash-desktop/src/main/core/local-switch-server/compose.ts
deleted file mode 100644
index 733c4f905..000000000
--- a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/compose.ts
+++ /dev/null
@@ -1,115 +0,0 @@
-import { execFile, spawn } from 'node:child_process';
-import { promisify } from 'node:util';
-import { log } from '@main/lib/logger';
-import { LOCAL_SERVER_PROFILES, LOCAL_SERVER_PROJECT_NAME } from './constants';
-import { DOCKER_EXECUTABLE } from './docker';
-import { composeFilePath, envFilePath, localServerDir } from './paths';
-
-const execFileAsync = promisify(execFile);
-
-/** Pulls can take minutes on a cold machine; give compose a generous ceiling. */
-const COMPOSE_TIMEOUT_MS = 20 * 60 * 1000;
-
-function profileArgs(): string[] {
- return LOCAL_SERVER_PROFILES.flatMap((p) => ['--profile', p]);
-}
-
-/** Base args that scope every invocation to the managed project + env file. */
-function baseArgs(): string[] {
- return [
- 'compose',
- '-f',
- composeFilePath(),
- '--env-file',
- envFilePath(),
- '--project-name',
- LOCAL_SERVER_PROJECT_NAME,
- ...profileArgs(),
- ];
-}
-
-async function runCompose(args: string[], timeout: number): Promise<string> {
- try {
- const { stdout } = await execFileAsync(DOCKER_EXECUTABLE, args, {
- cwd: localServerDir(),
- timeout,
- maxBuffer: 32 * 1024 * 1024,
- });
- return stdout;
- } catch (error) {
- const stderr = (error as { stderr?: string } | undefined)?.stderr;
- const message = stderr?.trim() || (error instanceof Error ? error.message : String(error));
- throw new Error(`docker ${args.join(' ')} failed: ${message}`);
- }
-}
-
-/**
- * Bring the stack up in the background (`up -d`), streaming each line of output
- * to `onLog` so the UI can show a live tail during the (slow) image pull.
- * Assumes the compose file and `.env` are written and GHCR login has run. docker
- * compose emits pull/startup progress on stderr, so both streams are forwarded.
- */
-export function composeUp(onLog: (line: string) => void): Promise<void> {
- log.info('local-switch-server: docker compose up');
- return new Promise((resolve, reject) => {
- const args = [...baseArgs(), 'up', '-d'];
- const child = spawn(DOCKER_EXECUTABLE, args, { cwd: localServerDir() });
- let stderrTail = '';
-
- const emitLines = (chunk: Buffer) => {
- for (const raw of chunk.toString('utf8').split('\n')) {
- const line = raw.replace(/\r$/, '');
- if (line.length > 0) onLog(line);
- }
- };
-
- const timer = setTimeout(() => {
- child.kill('SIGTERM');
- reject(new Error(`docker compose up timed out after ${COMPOSE_TIMEOUT_MS}ms`));
- }, COMPOSE_TIMEOUT_MS);
-
- child.stdout.on('data', emitLines);
- child.stderr.on('data', (chunk: Buffer) => {
- stderrTail = (stderrTail + chunk.toString('utf8')).slice(-4000);
- emitLines(chunk);
- });
- child.on('error', (err) => {
- clearTimeout(timer);
- reject(err);
- });
- child.on('close', (code) => {
- clearTimeout(timer);
- if (code === 0) resolve();
- else reject(new Error(`docker compose up failed (exit ${code}): ${stderrTail.trim()}`));
- });
- });
-}
-
-/** Stop and remove the stack's containers. `removeVolumes` also destroys the
- * data volumes (the reset path) — irreversible. */
-export async function composeDown(removeVolumes: boolean): Promise<void> {
- log.info(`local-switch-server: docker compose down${removeVolumes ? ' -v' : ''}`);
- await runCompose([...baseArgs(), 'down', ...(removeVolumes ? ['-v'] : [])], 5 * 60 * 1000);
-}
-
-/** Service names currently in the `running` state for the managed project. */
-export async function runningServices(): Promise<string[]> {
- try {
- const stdout = await runCompose(
- [...baseArgs(), 'ps', '--status', 'running', '--services'],
- 60_000
- );
- return stdout
- .split('\n')
- .map((s) => s.trim())
- .filter(Boolean);
- } catch (error) {
- log.warn('local-switch-server: `compose ps` failed; treating stack as down', { error });
- return [];
- }
-}
-
-/** Whether the core `switch` service is up — our proxy for "the stack is up". */
-export async function isStackRunning(): Promise<boolean> {
- return (await runningServices()).includes('switch');
-}
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/local-server-service.ts b/dash/apps/switchdash-desktop/src/main/core/local-switch-server/local-server-service.ts
deleted file mode 100644
index abb840902..000000000
--- a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/local-server-service.ts
+++ /dev/null
@@ -1,219 +0,0 @@
-import { resolveAgentServers } from '@main/core/agents/resolve-servers';
-import { passwordLogin } from '@main/core/switch-servers/auth';
-import {
- ensureManagedServer,
- getManagedServer,
- setActiveServerId,
-} from '@main/core/switch-servers/servers-store';
-import { events } from '@main/lib/events';
-import { log } from '@main/lib/logger';
-import { COMPATIBLE_SWITCH_VERSION, RELEASE_REPO_OWNER } from '@shared/app-identity';
-import type {
- DockerAvailability,
- LocalServerStatus,
- StartLocalServerResult,
-} from '@shared/core/local-switch-server/local-switch-server';
-import {
- localServerLogChannel,
- localServerStatusChannel,
-} from '@shared/events/localSwitchServerEvents';
-import { materialiseComposeFile } from './bundled-compose';
-import { composeDown, composeUp, isStackRunning } from './compose';
-import { GHCR_REGISTRY, LOCAL_SERVER_ADMIN_EMAIL, LOCAL_SERVER_NAME } from './constants';
-import { detectDocker } from './docker';
-import { buildEnvFile, writeEnvFile } from './env-file';
-import { apiUrlFor, gatewayUrlFor } from './free-port';
-import { ensureGhcrLogin } from './ghcr-auth';
-import { waitForHealth } from './health';
-import { envFilePath } from './paths';
-import { clearPorts, resolvePorts } from './ports';
-import { clearSecrets, loadOrCreateSecrets } from './secrets';
-
-/**
- * Supervises the managed local Switch stack: Docker detection, config
- * generation, `docker compose` lifecycle, health-gated registration, and
- * stop/reset. One operation runs at a time (`busy`); every state transition is
- * pushed to the renderer over `localServerStatusChannel`.
- *
- * Deliberately does NOT stop the containers on app quit — the local stack keeps
- * running so its rooms stay live while switchdash is closed, matching the remote
- * sidecar model. `dispose()` only aborts an in-flight health wait.
- */
-class LocalServerService {
- private status: LocalServerStatus = {
- phase: 'stopped',
- serverId: null,
- version: COMPATIBLE_SWITCH_VERSION,
- message: null,
- error: null,
- };
-
- private busy = false;
- private startAbort: AbortController | null = null;
-
- getStatus(): LocalServerStatus {
- return this.status;
- }
-
- detectDocker(): Promise<DockerAvailability> {
- return detectDocker();
- }
-
- private setStatus(patch: Partial<LocalServerStatus>): void {
- this.status = { ...this.status, ...patch };
- events.emit(localServerStatusChannel, this.status);
- }
-
- /** Reconcile status at boot so a stack that survived the last quit shows as
- * running without the user re-starting it. The managed server's URLs are the
- * per-machine ones persisted at first start, so we reflect the existing record
- * rather than recomputing — the containers are bound to those ports. */
- async initialize(): Promise<void> {
- try {
- const managed = await getManagedServer();
- if (managed && (await isStackRunning())) {
- this.setStatus({ phase: 'running', serverId: managed.id, message: null, error: null });
- }
- } catch (error) {
- log.warn('local-switch-server: boot status reconcile failed', { error });
- }
- }
-
- async start(): Promise<StartLocalServerResult> {
- if (this.busy) {
- return { kind: 'error', message: 'A local-server operation is already in progress.' };
- }
- this.busy = true;
- this.startAbort = new AbortController();
- try {
- this.setStatus({ phase: 'starting', error: null, message: 'Checking Docker…' });
- const docker = await detectDocker();
- if (!docker.available) {
- this.setStatus({ phase: 'error', error: docker.detail });
- return { kind: 'docker-unavailable', reason: docker.reason, detail: docker.detail };
- }
-
- this.setStatus({ message: 'Authenticating to image registry…' });
- await ensureGhcrLogin();
-
- this.setStatus({ message: 'Preparing configuration…' });
- await materialiseComposeFile();
- const secrets = await loadOrCreateSecrets();
- // Pick free host ports for this machine (persisted + reused) so the stack
- // never collides with a dev's existing services on 8000 / 5432 / 3000.
- const ports = await resolvePorts();
- const gatewayUrl = gatewayUrlFor(ports);
- const apiUrl = apiUrlFor(ports);
- await writeEnvFile(
- envFilePath(),
- buildEnvFile({
- version: COMPATIBLE_SWITCH_VERSION,
- registry: GHCR_REGISTRY,
- namespace: RELEASE_REPO_OWNER,
- ports,
- secrets,
- })
- );
-
- this.setStatus({ message: 'Starting containers (pulling images if needed)…' });
- await composeUp((line) => events.emit(localServerLogChannel, { line }));
-
- this.setStatus({ message: 'Waiting for the server to become healthy…' });
- // Probe via the gateway URL (nginx → switch-core), the same path switchdash's
- // management calls take, so we only register once that whole path answers.
- const healthy = await waitForHealth(gatewayUrl, {
- signal: this.startAbort.signal,
- });
- if (!healthy) {
- const error = 'The local server did not become healthy in time.';
- this.setStatus({ phase: 'error', error });
- return { kind: 'error', message: error };
- }
-
- const server = await ensureManagedServer({
- name: LOCAL_SERVER_NAME,
- gatewayUrl,
- apiUrl,
- });
- await setActiveServerId(server.id);
-
- // switchdash generated the admin password, so sign in on the user's behalf
- // rather than showing a login wall for a secret they never saw. A failure
- // here does not fail the start — the stack is healthy; the server view just
- // falls back to its sign-in panel.
- this.setStatus({ message: 'Signing in…' });
- const login = await passwordLogin(
- server,
- LOCAL_SERVER_ADMIN_EMAIL,
- secrets.gatewayAdminPassword
- );
- if (!login.success) {
- log.warn('local-switch-server: auto sign-in failed; server will show a sign-in prompt', {
- error: login.error,
- });
- }
-
- await resolveAgentServers();
-
- this.setStatus({ phase: 'running', serverId: server.id, message: null, error: null });
- return { kind: 'started', serverId: server.id };
- } catch (error) {
- const message = error instanceof Error ? error.message : String(error);
- log.error('local-switch-server: start failed', { error });
- this.setStatus({ phase: 'error', error: message });
- return { kind: 'error', message };
- } finally {
- this.busy = false;
- this.startAbort = null;
- }
- }
-
- async stop(): Promise<void> {
- if (this.busy) throw new Error('A local-server operation is already in progress.');
- this.busy = true;
- try {
- this.setStatus({ phase: 'stopping', message: 'Stopping containers…' });
- await composeDown(false);
- this.setStatus({ phase: 'stopped', message: null, error: null });
- } catch (error) {
- this.setStatus({
- phase: 'error',
- error: error instanceof Error ? error.message : String(error),
- });
- throw error;
- } finally {
- this.busy = false;
- }
- }
-
- /** Destroy the stack AND its data volumes, and drop the stored secrets so the
- * next start is a clean install. Irreversible — the caller must confirm. The
- * caller (renderer) removes the managed server's agents first, since their
- * server-side identity is wiped here. */
- async reset(): Promise<void> {
- if (this.busy) throw new Error('A local-server operation is already in progress.');
- this.busy = true;
- try {
- this.setStatus({ phase: 'stopping', message: 'Destroying containers and data…' });
- await composeDown(true);
- await clearSecrets();
- await clearPorts();
- this.setStatus({ phase: 'stopped', message: null, error: null });
- } catch (error) {
- this.setStatus({
- phase: 'error',
- error: error instanceof Error ? error.message : String(error),
- });
- throw error;
- } finally {
- this.busy = false;
- }
- }
-
- dispose(): void {
- this.startAbort?.abort();
- this.startAbort = null;
- }
-}
-
-export const localServerService = new LocalServerService();
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/paths.ts b/dash/apps/switchdash-desktop/src/main/core/local-switch-server/paths.ts
deleted file mode 100644
index 0dae6ad22..000000000
--- a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/paths.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { join } from 'node:path';
-import { app } from 'electron';
-
-/** Root for the managed stack's on-disk runtime artifacts (compose file + env),
- * under the app's user-data dir so it is per-install and easy to locate. */
-export function localServerDir(): string {
- return join(app.getPath('userData'), 'local-switch-server');
-}
-
-/** Where the bundled compose is written so `docker compose -f <path>` can run
- * it. Docker cannot read a file inside the app bundle, so we materialise it. */
-export function composeFilePath(): string {
- return join(localServerDir(), 'standalone-docker-compose.yml');
-}
-
-/** The generated `.env` docker compose interpolates. Secrets originate in the
- * encrypted store; this file is a derived runtime artifact (written 0600). */
-export function envFilePath(): string {
- return join(localServerDir(), '.env');
-}
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/ports.ts b/dash/apps/switchdash-desktop/src/main/core/local-switch-server/ports.ts
deleted file mode 100644
index 5d61764ea..000000000
--- a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/ports.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import { mkdir, readFile, writeFile } from 'node:fs/promises';
-import { dirname, join } from 'node:path';
-import { isPorts, type LocalServerPorts, pickFreePorts } from './free-port';
-import { localServerDir } from './paths';
-
-function portsFilePath(): string {
- return join(localServerDir(), 'ports.json');
-}
-
-async function loadPersisted(): Promise<LocalServerPorts | null> {
- try {
- const parsed: unknown = JSON.parse(await readFile(portsFilePath(), 'utf8'));
- return isPorts(parsed) ? parsed : null;
- } catch {
- return null;
- }
-}
-
-async function persist(ports: LocalServerPorts): Promise<void> {
- await mkdir(dirname(portsFilePath()), { recursive: true });
- await writeFile(portsFilePath(), JSON.stringify(ports, null, 2), 'utf8');
-}
-
-/**
- * The ports the managed stack should publish on. Reuses the persisted choice if
- * present — the running containers are already bound to those, and reusing keeps
- * the server's URLs stable across restarts — otherwise picks free ports once and
- * persists them.
- */
-export async function resolvePorts(): Promise<LocalServerPorts> {
- const existing = await loadPersisted();
- if (existing) return existing;
- const chosen = await pickFreePorts();
- await persist(chosen);
- return chosen;
-}
-
-/** Drop the persisted choice so the next start picks fresh ports (reset path). */
-export async function clearPorts(): Promise<void> {
- try {
- await writeFile(portsFilePath(), JSON.stringify({}), 'utf8');
- } catch {
- // Best-effort: a missing file is already the desired state.
- }
-}
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/secrets.ts b/dash/apps/switchdash-desktop/src/main/core/local-switch-server/secrets.ts
deleted file mode 100644
index 8f2bfd5a5..000000000
--- a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/secrets.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { encryptedAppSecretsStore } from '@main/core/secrets/encrypted-app-secrets-store';
-import { generateSecrets, type LocalServerSecrets } from './secret-values';
-
-/** Encrypted-store key holding the local stack's secret bundle (JSON). */
-const SECRETS_KEY = 'local-switch-server:secrets';
-
-/**
- * Return the stored secret bundle, generating and persisting one on first use.
- * Reusing the same secrets across restarts is required — the Postgres volume was
- * initialised with the first `DB_PASSWORD`, so regenerating it would lock the
- * stack out of its own database.
- */
-export async function loadOrCreateSecrets(): Promise<LocalServerSecrets> {
- const existing = await encryptedAppSecretsStore.getSecret(SECRETS_KEY);
- if (existing) {
- try {
- return JSON.parse(existing) as LocalServerSecrets;
- } catch {
- // Corrupt bundle — fall through and regenerate.
- }
- }
- const fresh = generateSecrets();
- await encryptedAppSecretsStore.setSecret(SECRETS_KEY, JSON.stringify(fresh));
- return fresh;
-}
-
-/** Drop the secret bundle so the next start generates fresh credentials. Only
- * safe to call after the data volumes have been destroyed (reset). */
-export async function clearSecrets(): Promise<void> {
- await encryptedAppSecretsStore.deleteSecret(SECRETS_KEY);
-}
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/bundled-compose.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/bundled-compose.ts
new file mode 100644
index 000000000..3eeb10d69
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/bundled-compose.ts
@@ -0,0 +1,10 @@
+import composeYaml from './resources/standalone-docker-compose.pinned.yml?raw';
+
+/** The standalone compose bundled into the app (pinned to
+ * COMPATIBLE_SWITCH_VERSION), inlined at build time. Written to the host working
+ * dir on every start (via `ServerHost.writeFile`) so `docker compose -f <name>`
+ * can run it — Docker cannot read a file inside the packaged app bundle, and a
+ * remote host cannot read the desktop's filesystem at all. */
+export function bundledComposeYaml(): string {
+ return composeYaml;
+}
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/compose.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/compose.ts
new file mode 100644
index 000000000..6eab0d4d7
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/compose.ts
@@ -0,0 +1,86 @@
+import { log } from '@main/lib/logger';
+import { COMPOSE_FILE_NAME, ENV_FILE_NAME, LOCAL_SERVER_PROFILES } from './constants';
+import type { ServerHost } from './host/types';
+
+/** Pulls can take minutes on a cold machine; give compose a generous ceiling. */
+const COMPOSE_TIMEOUT_MS = 20 * 60 * 1000;
+
+function profileArgs(): string[] {
+ return LOCAL_SERVER_PROFILES.flatMap((p) => ['--profile', p]);
+}
+
+/** Base args that scope every invocation to the managed project + env file.
+ * Relative file names resolve against the host working dir (the ctx root). */
+function baseArgs(host: ServerHost): string[] {
+ return [
+ 'compose',
+ '-f',
+ COMPOSE_FILE_NAME,
+ '--env-file',
+ ENV_FILE_NAME,
+ '--project-name',
+ host.composeProjectName,
+ ...profileArgs(),
+ ];
+}
+
+async function runCompose(host: ServerHost, args: string[], timeout: number): Promise<string> {
+ const full = [host.dockerBin, ...args];
+ try {
+ const { stdout } = await host.ctx.exec(host.dockerBin, args, {
+ timeout,
+ maxBuffer: 32 * 1024 * 1024,
+ });
+ return stdout;
+ } catch (error) {
+ const stderr = (error as { stderr?: string } | undefined)?.stderr;
+ const message = stderr?.trim() || (error instanceof Error ? error.message : String(error));
+ throw new Error(`${full.join(' ')} failed: ${message}`);
+ }
+}
+
+/**
+ * Bring the stack up in the background (`up -d`), streaming each line of output
+ * to `onLog` so the UI can show a live tail during the (slow) image pull.
+ * Assumes the compose file and `.env` are written and GHCR login has run.
+ */
+export function composeUp(host: ServerHost, onLog: (line: string) => void): Promise<void> {
+ log.info(`local-switch-server: docker compose up (${host.label})`);
+ return host.streamCommand(host.dockerBin, [...baseArgs(host), 'up', '-d'], onLog, {
+ timeoutMs: COMPOSE_TIMEOUT_MS,
+ });
+}
+
+/** Stop and remove the stack's containers. `removeVolumes` also destroys the
+ * data volumes (the reset path) — irreversible. */
+export async function composeDown(host: ServerHost, removeVolumes: boolean): Promise<void> {
+ log.info(`local-switch-server: docker compose down${removeVolumes ? ' -v' : ''} (${host.label})`);
+ await runCompose(
+ host,
+ [...baseArgs(host), 'down', ...(removeVolumes ? ['-v'] : [])],
+ 5 * 60 * 1000
+ );
+}
+
+/** Service names currently in the `running` state for the managed project. */
+export async function runningServices(host: ServerHost): Promise<string[]> {
+ try {
+ const stdout = await runCompose(
+ host,
+ [...baseArgs(host), 'ps', '--status', 'running', '--services'],
+ 60_000
+ );
+ return stdout
+ .split('\n')
+ .map((s) => s.trim())
+ .filter(Boolean);
+ } catch (error) {
+ log.warn('local-switch-server: `compose ps` failed; treating stack as down', { error });
+ return [];
+ }
+}
+
+/** Whether the core `switch` service is up — our proxy for "the stack is up". */
+export async function isStackRunning(host: ServerHost): Promise<boolean> {
+ return (await runningServices(host)).includes('switch');
+}
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/constants.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/constants.ts
similarity index 71%
rename from dash/apps/switchdash-desktop/src/main/core/local-switch-server/constants.ts
rename to dash/apps/switchdash-desktop/src/main/core/managed-switch-server/constants.ts
index b6a46281b..8da6e71d7 100644
--- a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/constants.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/constants.ts
@@ -5,10 +5,21 @@
* switchdash addresses the resulting server.
*/
-/** `docker compose --project-name` for the managed stack, so its containers and
- * volumes are isolated and discoverable across app restarts. */
+/** `docker compose --project-name` for the managed stack on this machine, so its
+ * containers and volumes are isolated and discoverable across app restarts. */
export const LOCAL_SERVER_PROJECT_NAME = 'switchdash-local';
+/** `docker compose --project-name` for a managed stack on a remote host. Each
+ * remote host runs its own Docker daemon, so a single fixed name is enough to
+ * isolate + rediscover the stack there. */
+export const REMOTE_SERVER_PROJECT_NAME = 'switchdash-remote';
+
+/** File names of the compose file and generated `.env` inside the host working
+ * dir. Kept relative so `docker compose -f <name>` resolves against the working
+ * dir on either host, independent of its absolute path. */
+export const COMPOSE_FILE_NAME = 'standalone-docker-compose.yml';
+export const ENV_FILE_NAME = '.env';
+
/** Display name of the auto-registered server record. */
export const LOCAL_SERVER_NAME = 'Local Switch server';
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/controller.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/controller.ts
similarity index 90%
rename from dash/apps/switchdash-desktop/src/main/core/local-switch-server/controller.ts
rename to dash/apps/switchdash-desktop/src/main/core/managed-switch-server/controller.ts
index 74d1a56a3..d66cd53c2 100644
--- a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/controller.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/controller.ts
@@ -2,7 +2,7 @@ import type {
DockerAvailability,
LocalServerStatus,
StartLocalServerResult,
-} from '@shared/core/local-switch-server/local-switch-server';
+} from '@shared/core/managed-switch-server/managed-switch-server';
import { createRPCController } from '@shared/lib/ipc/rpc';
import { localServerService } from './local-server-service';
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/docker.test.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/docker.test.ts
similarity index 100%
rename from dash/apps/switchdash-desktop/src/main/core/local-switch-server/docker.test.ts
rename to dash/apps/switchdash-desktop/src/main/core/managed-switch-server/docker.test.ts
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/docker.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/docker.ts
similarity index 96%
rename from dash/apps/switchdash-desktop/src/main/core/local-switch-server/docker.ts
rename to dash/apps/switchdash-desktop/src/main/core/managed-switch-server/docker.ts
index 3497dc56e..39b1f44f5 100644
--- a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/docker.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/docker.ts
@@ -2,7 +2,7 @@ import { execFile } from 'node:child_process';
import fs from 'node:fs';
import { promisify } from 'node:util';
import { log } from '@main/lib/logger';
-import type { DockerAvailability } from '@shared/core/local-switch-server/local-switch-server';
+import type { DockerAvailability } from '@shared/core/managed-switch-server/managed-switch-server';
const execFileAsync = promisify(execFile);
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/env-file.test.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/env-file.test.ts
similarity index 100%
rename from dash/apps/switchdash-desktop/src/main/core/local-switch-server/env-file.test.ts
rename to dash/apps/switchdash-desktop/src/main/core/managed-switch-server/env-file.test.ts
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/env-file.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/env-file.ts
similarity index 83%
rename from dash/apps/switchdash-desktop/src/main/core/local-switch-server/env-file.ts
rename to dash/apps/switchdash-desktop/src/main/core/managed-switch-server/env-file.ts
index 3d5b76c22..1cf8ad14d 100644
--- a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/env-file.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/env-file.ts
@@ -1,5 +1,3 @@
-import { chmod, mkdir, writeFile } from 'node:fs/promises';
-import { dirname } from 'node:path';
import { LOCAL_SERVER_ADMIN_EMAIL, LOCAL_SERVER_BIND_ADDR } from './constants';
import type { LocalServerPorts } from './free-port';
import type { LocalServerSecrets } from './secret-values';
@@ -62,11 +60,3 @@ export function buildEnvFile(params: LocalServerEnvParams): string {
'',
].join('\n');
}
-
-/** Write the `.env` with owner-only permissions (it holds the stack secrets). */
-export async function writeEnvFile(path: string, content: string): Promise<void> {
- await mkdir(dirname(path), { recursive: true });
- await writeFile(path, content, { encoding: 'utf8', mode: 0o600 });
- // writeFile only applies `mode` when creating; enforce it on rewrite too.
- await chmod(path, 0o600);
-}
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/free-port.test.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/free-port.test.ts
similarity index 100%
rename from dash/apps/switchdash-desktop/src/main/core/local-switch-server/free-port.test.ts
rename to dash/apps/switchdash-desktop/src/main/core/managed-switch-server/free-port.test.ts
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/free-port.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/free-port.ts
similarity index 100%
rename from dash/apps/switchdash-desktop/src/main/core/local-switch-server/free-port.ts
rename to dash/apps/switchdash-desktop/src/main/core/managed-switch-server/free-port.ts
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/ghcr-auth.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/ghcr-auth.ts
similarity index 61%
rename from dash/apps/switchdash-desktop/src/main/core/local-switch-server/ghcr-auth.ts
rename to dash/apps/switchdash-desktop/src/main/core/managed-switch-server/ghcr-auth.ts
index 0830db2f9..fa057e3a1 100644
--- a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/ghcr-auth.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/ghcr-auth.ts
@@ -21,6 +21,20 @@ async function getGithubLogin(): Promise<string | null> {
}
}
+/** The desktop's GitHub identity (username + token) from the `gh` CLI, or null
+ * when unavailable. Used both for the local `docker login` and to forward
+ * credentials to a remote host that has no `gh` of its own. */
+export async function getLocalGithubIdentity(): Promise<{
+ username: string;
+ token: string;
+} | null> {
+ const token = await getGithubTokenFromGhCli();
+ if (!token) return null;
+ const username = await getGithubLogin();
+ if (!username) return null;
+ return { username, token };
+}
+
/** `docker login <registry> -u <user> --password-stdin`, feeding the token over
* stdin so it never lands in the process argv / command history. */
function dockerLoginWithToken(registry: string, username: string, token: string): Promise<void> {
@@ -42,25 +56,21 @@ function dockerLoginWithToken(registry: string, username: string, token: string)
}
/**
- * Authenticate Docker to GHCR using the user's existing `gh` login, so private
- * release images pull before the public-repo flip (CHOO-1260). When no gh token
- * is available we warn and proceed: if the images are already public this is a
- * no-op, and if they are private the subsequent `docker compose up` fails loudly
- * on the pull — which surfaces the real problem rather than hiding it here.
+ * Authenticate the local Docker to GHCR using the user's existing `gh` login, so
+ * private release images pull before the public-repo flip (CHOO-1260). When no
+ * gh token is available we warn and proceed: if the images are already public
+ * this is a no-op, and if they are private the subsequent `docker compose up`
+ * fails loudly on the pull — which surfaces the real problem rather than hiding
+ * it here.
*/
-export async function ensureGhcrLogin(): Promise<void> {
- const token = await getGithubTokenFromGhCli();
- if (!token) {
+export async function ensureLocalGhcrLogin(): Promise<void> {
+ const identity = await getLocalGithubIdentity();
+ if (!identity) {
log.warn(
- 'local-switch-server: no gh CLI token; skipping GHCR login (private image pulls will fail)'
+ 'local-switch-server: no gh CLI token/login; skipping GHCR login (private image pulls will fail)'
);
return;
}
- const username = await getGithubLogin();
- if (!username) {
- log.warn('local-switch-server: could not resolve GitHub login; skipping GHCR login');
- return;
- }
- await dockerLoginWithToken(GHCR_REGISTRY, username, token);
+ await dockerLoginWithToken(GHCR_REGISTRY, identity.username, identity.token);
log.info('local-switch-server: authenticated Docker to GHCR');
}
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/health.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/health.ts
similarity index 100%
rename from dash/apps/switchdash-desktop/src/main/core/local-switch-server/health.ts
rename to dash/apps/switchdash-desktop/src/main/core/managed-switch-server/health.ts
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/host-for-server.test.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/host-for-server.test.ts
new file mode 100644
index 000000000..20a6b73d4
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/host-for-server.test.ts
@@ -0,0 +1,44 @@
+import { describe, expect, it } from 'vitest';
+import type { SwitchServer } from '@shared/core/switch-servers/switch-servers';
+import { managedServerSecretsKey } from './host-for-server';
+
+function server(overrides: Partial<SwitchServer>): SwitchServer {
+ return {
+ id: 'id',
+ name: 'name',
+ gatewayUrl: 'http://localhost:1',
+ apiUrl: 'http://localhost:2',
+ managed: true,
+ managementKind: 'local',
+ sshHost: null,
+ createdAt: '',
+ updatedAt: '',
+ ...overrides,
+ };
+}
+
+describe('managedServerSecretsKey', () => {
+ it('uses the single local key for a local-managed server', () => {
+ expect(managedServerSecretsKey(server({ managementKind: 'local' }))).toBe(
+ 'local-switch-server:secrets'
+ );
+ });
+
+ it('treats a legacy managed server (null kind) as local', () => {
+ expect(managedServerSecretsKey(server({ managementKind: null }))).toBe(
+ 'local-switch-server:secrets'
+ );
+ });
+
+ it('uses a per-host key for a remote-managed server', () => {
+ expect(managedServerSecretsKey(server({ managementKind: 'remote', sshHost: 'prod-box' }))).toBe(
+ 'remote-switch-server:prod-box:secrets'
+ );
+ });
+
+ it('falls back to the local key if a remote row is missing its host', () => {
+ expect(managedServerSecretsKey(server({ managementKind: 'remote', sshHost: null }))).toBe(
+ 'local-switch-server:secrets'
+ );
+ });
+});
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/host-for-server.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/host-for-server.ts
new file mode 100644
index 000000000..106cb171e
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/host-for-server.ts
@@ -0,0 +1,20 @@
+import type { SwitchServer } from '@shared/core/switch-servers/switch-servers';
+import { remoteSecretsKey } from './remote-identity';
+
+/** Local host's fixed secrets-store key. */
+const LOCAL_SECRETS_KEY = 'local-switch-server:secrets';
+
+/**
+ * The encrypted-store key holding a managed server's stack secret bundle.
+ * Resolves from the server's management kind: the single local key for a
+ * local-managed server, or a per-host key for a remote-managed one (so a local
+ * stack and any number of remote stacks keep separate credentials). Callers
+ * that only need to read the secrets (e.g. silent re-login) use this rather than
+ * constructing a full {@link ServerHost} (which, for remote, would open SSH).
+ */
+export function managedServerSecretsKey(server: SwitchServer): string {
+ if (server.managementKind === 'remote' && server.sshHost) {
+ return remoteSecretsKey(server.sshHost);
+ }
+ return LOCAL_SECRETS_KEY;
+}
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/local-host.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/local-host.ts
new file mode 100644
index 000000000..078d2627e
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/local-host.ts
@@ -0,0 +1,101 @@
+import { spawn } from 'node:child_process';
+import { chmod, mkdir, writeFile } from 'node:fs/promises';
+import { dirname, join } from 'node:path';
+import { LocalExecutionContext } from '@main/core/execution-context/local-execution-context';
+import type { IExecutionContext } from '@main/core/execution-context/types';
+import type { DockerAvailability } from '@shared/core/managed-switch-server/managed-switch-server';
+import { LOCAL_SERVER_PROJECT_NAME } from '../constants';
+import { DOCKER_EXECUTABLE, detectDocker } from '../docker';
+import { type LocalServerPorts, pickFreePorts } from '../free-port';
+import { ensureLocalGhcrLogin } from '../ghcr-auth';
+import { localServerDir } from '../paths';
+import type { ServerHost } from './types';
+
+/**
+ * The managed stack running on this machine's Docker daemon — the CHOO-1428
+ * behaviour, now expressed through {@link ServerHost}. Commands run via a local
+ * spawn rooted at the user-data working dir; the published ports are already on
+ * loopback, so there is no networking to establish.
+ */
+export class LocalServerHost implements ServerHost {
+ readonly kind = 'local' as const;
+ readonly dockerBin = DOCKER_EXECUTABLE;
+ readonly composeProjectName = LOCAL_SERVER_PROJECT_NAME;
+ readonly workingDir = localServerDir();
+ readonly stateDir = localServerDir();
+ readonly secretsKey = 'local-switch-server:secrets';
+ readonly label = 'this computer';
+ readonly ctx: IExecutionContext = new LocalExecutionContext({ root: this.workingDir });
+
+ async writeFile(relPath: string, content: string, mode?: number): Promise<void> {
+ const path = join(this.workingDir, relPath);
+ await mkdir(dirname(path), { recursive: true });
+ await writeFile(path, content, mode !== undefined ? { encoding: 'utf8', mode } : 'utf8');
+ // writeFile only applies `mode` when creating; enforce it on rewrite too.
+ if (mode !== undefined) await chmod(path, mode);
+ }
+
+ streamCommand(
+ command: string,
+ args: string[],
+ onLine: (line: string) => void,
+ opts: { timeoutMs?: number } = {}
+ ): Promise<void> {
+ return new Promise((resolve, reject) => {
+ const child = spawn(command, args, { cwd: this.workingDir });
+ let stderrTail = '';
+
+ const emitLines = (chunk: Buffer) => {
+ for (const raw of chunk.toString('utf8').split('\n')) {
+ const line = raw.replace(/\r$/, '');
+ if (line.length > 0) onLine(line);
+ }
+ };
+
+ const timer =
+ opts.timeoutMs !== undefined
+ ? setTimeout(() => {
+ child.kill('SIGTERM');
+ reject(new Error(`${command} timed out after ${opts.timeoutMs}ms`));
+ }, opts.timeoutMs)
+ : undefined;
+
+ child.stdout.on('data', emitLines);
+ child.stderr.on('data', (chunk: Buffer) => {
+ stderrTail = (stderrTail + chunk.toString('utf8')).slice(-4000);
+ emitLines(chunk);
+ });
+ child.on('error', (err) => {
+ if (timer) clearTimeout(timer);
+ reject(err);
+ });
+ child.on('close', (code) => {
+ if (timer) clearTimeout(timer);
+ if (code === 0) resolve();
+ else reject(new Error(`${command} failed (exit ${code}): ${stderrTail.trim()}`));
+ });
+ });
+ }
+
+ detectDocker(): Promise<DockerAvailability> {
+ return detectDocker();
+ }
+
+ ensureGhcrLogin(): Promise<void> {
+ return ensureLocalGhcrLogin();
+ }
+
+ pickFreePorts(): Promise<LocalServerPorts> {
+ return pickFreePorts();
+ }
+
+ async establishNetworking(): Promise<void> {
+ // Local ports are already published on 127.0.0.1 — nothing to forward.
+ }
+
+ async teardownNetworking(): Promise<void> {}
+
+ dispose(): void {
+ this.ctx.dispose();
+ }
+}
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/port-forward.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/port-forward.ts
new file mode 100644
index 000000000..28efc9520
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/port-forward.ts
@@ -0,0 +1,91 @@
+import { createServer, type Server, type Socket } from 'node:net';
+import type { SshClientProxy } from '@main/core/ssh/lifecycle/ssh-client-proxy';
+import { log } from '@main/lib/logger';
+
+/**
+ * A persistent local→remote loopback bridge over the SSH connection.
+ *
+ * For each port it opens a listener on the desktop's `127.0.0.1:<port>` and,
+ * for every incoming connection, opens a direct-tcpip channel to the SAME port
+ * on the remote host's loopback (via {@link SshClientProxy.forwardOut}) and
+ * pipes the two together. Because the port number is mirrored, a single
+ * `http://localhost:<port>` URL resolves to the same server whether the caller
+ * runs on the desktop (through this bridge) or on the remote host (directly on
+ * its loopback).
+ *
+ * The listeners are long-lived: they survive SSH reconnects because each
+ * connection opens a fresh channel off the (stable) proxy at connect time — a
+ * drop only kills in-flight connections, which reconnect on the next request.
+ */
+export class PortForwarder {
+ private servers: Server[] = [];
+
+ constructor(
+ private readonly proxy: SshClientProxy,
+ private readonly label: string
+ ) {}
+
+ /**
+ * Start a mirrored listener for each port. Rejects (and tears down any
+ * already-started listeners) if a local port cannot be bound — better to fail
+ * the start loudly than register a URL that will not resolve.
+ */
+ async start(ports: number[]): Promise<void> {
+ try {
+ for (const port of ports) {
+ await this.listen(port);
+ }
+ } catch (error) {
+ this.stop();
+ throw error;
+ }
+ }
+
+ private listen(port: number): Promise<void> {
+ const server = createServer((socket) => this.bridge(socket, port));
+ this.servers.push(server);
+ return new Promise((resolve, reject) => {
+ const onError = (err: Error) =>
+ reject(new Error(`cannot bind local port ${port} for ${this.label}: ${err.message}`));
+ server.once('error', onError);
+ server.listen(port, '127.0.0.1', () => {
+ server.removeListener('error', onError);
+ // Later listener errors are non-fatal — log rather than crash.
+ server.on('error', (err) =>
+ log.warn(`port-forward: listener error on :${port} (${this.label})`, { err })
+ );
+ resolve();
+ });
+ });
+ }
+
+ private bridge(socket: Socket, port: number): void {
+ socket.on('error', () => socket.destroy());
+ this.proxy
+ .forwardOut(port)
+ .then((channel) => {
+ channel.on('error', () => socket.destroy());
+ socket.on('close', () => channel.destroy());
+ socket.pipe(channel);
+ channel.pipe(socket);
+ })
+ .catch((err: unknown) => {
+ log.warn(`port-forward: could not open channel to remote :${port} (${this.label})`, {
+ err,
+ });
+ socket.destroy();
+ });
+ }
+
+ /** Close all listeners. Idempotent. In-flight bridged sockets close with them. */
+ stop(): void {
+ for (const server of this.servers) {
+ try {
+ server.close();
+ } catch {
+ // Already closed.
+ }
+ }
+ this.servers = [];
+ }
+}
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/remote-free-port.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/remote-free-port.ts
new file mode 100644
index 000000000..1b19de27e
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/remote-free-port.ts
@@ -0,0 +1,68 @@
+import type { IExecutionContext } from '@main/core/execution-context/types';
+import { listManagedServers } from '@main/core/switch-servers/servers-store';
+import { log } from '@main/lib/logger';
+import { findFreePort, type LocalServerPorts } from '../free-port';
+
+/**
+ * TCP ports currently in LISTEN state on the remote host, so a stack we bring up
+ * never tries to publish onto one already in use there. Best-effort: parses
+ * `ss`/`netstat` output; an empty set (tools missing / parse miss) just means we
+ * rely on the desktop-side free check plus a loud failure at `compose up`.
+ */
+export async function listRemoteListeningPorts(ctx: IExecutionContext): Promise<Set<number>> {
+ const ports = new Set<number>();
+ try {
+ const { stdout } = await ctx.exec('sh', [
+ '-c',
+ 'ss -ltnH 2>/dev/null || netstat -ltn 2>/dev/null',
+ ]);
+ for (const line of stdout.split('\n')) {
+ // Grab every `:<port>` on the line (the local address is `…:<port>`; the
+ // peer column is `*`/`:::*` with no bare number, so over-collection is
+ // harmless — it only makes us skip a few extra ports).
+ for (const m of line.matchAll(/:(\d{1,5})\b/g)) {
+ const port = Number.parseInt(m[1]!, 10);
+ if (port > 0 && port < 65536) ports.add(port);
+ }
+ }
+ } catch (error) {
+ log.warn('remote-switch-server: could not list remote listening ports', { error });
+ }
+ return ports;
+}
+
+/** Host ports already claimed by other managed servers (the local stack and any
+ * other remote hosts), parsed from their registered URLs. Mirrored remote ports
+ * are bound on the desktop loopback too, so two managed stacks must not share a
+ * number — this keeps the desktop listeners (and the unique gateway-URL index)
+ * from colliding. */
+async function reservedManagedPorts(): Promise<Set<number>> {
+ const reserved = new Set<number>();
+ for (const server of await listManagedServers()) {
+ for (const url of [server.gatewayUrl, server.apiUrl]) {
+ const port = Number.parseInt(new URL(url).port, 10);
+ if (Number.isFinite(port) && port > 0) reserved.add(port);
+ }
+ }
+ return reserved;
+}
+
+/**
+ * Pick a distinct port for each service, free on BOTH loopbacks: chosen free on
+ * the desktop (so the mirrored forward listener can bind it) and neither already
+ * listening on the remote host nor claimed by another managed server. The same
+ * number is then used on the remote (published) and the desktop (forwarded), so
+ * one URL works everywhere.
+ */
+export async function pickRemoteFreePorts(ctx: IExecutionContext): Promise<LocalServerPorts> {
+ const taken = new Set<number>([
+ ...(await reservedManagedPorts()),
+ ...(await listRemoteListeningPorts(ctx)),
+ ]);
+ return {
+ gateway: await findFreePort(taken),
+ api: await findFreePort(taken),
+ mattermost: await findFreePort(taken),
+ postgres: await findFreePort(taken),
+ };
+}
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/remote-ghcr-auth.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/remote-ghcr-auth.ts
new file mode 100644
index 000000000..bfa702558
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/remote-ghcr-auth.ts
@@ -0,0 +1,83 @@
+import type { IExecutionContext } from '@main/core/execution-context/types';
+import { log } from '@main/lib/logger';
+import { GHCR_REGISTRY } from '../constants';
+import { getLocalGithubIdentity } from '../ghcr-auth';
+
+/** The GitHub login of an authenticated `gh` on the remote host, or null when
+ * `gh` is missing or not signed in (`gh api user` needs an auth token). */
+async function remoteGhUsername(ctx: IExecutionContext): Promise<string | null> {
+ try {
+ const { stdout } = await ctx.exec('gh', ['api', 'user', '--jq', '.login'], { timeout: 15_000 });
+ const login = stdout.trim();
+ return login.length > 0 ? login : null;
+ } catch {
+ return null;
+ }
+}
+
+/** Forward the desktop's GitHub token to the remote `docker login`: write it to
+ * a 0600 temp file on the host, `docker login --password-stdin < file`, delete
+ * it. Keeps the token out of argv/history on the remote. */
+async function loginWithForwardedToken(
+ host: {
+ ctx: IExecutionContext;
+ writeFile: (relPath: string, content: string, mode?: number) => Promise<void>;
+ },
+ username: string,
+ token: string
+): Promise<void> {
+ const tokenFile = '.ghcr-token';
+ await host.writeFile(tokenFile, token, 0o600);
+ try {
+ await host.ctx.exec('sh', [
+ '-c',
+ `docker login ${GHCR_REGISTRY} -u ${username} --password-stdin < ${tokenFile}`,
+ ]);
+ } finally {
+ // Remove the token file whether or not the login succeeded.
+ await host.ctx.exec('rm', ['-f', tokenFile]).catch(() => {});
+ }
+}
+
+/**
+ * Authenticate a remote host's Docker to GHCR so private release images pull
+ * before the public-repo flip (CHOO-1260).
+ *
+ * Prefers the DESKTOP's `gh` identity (forwarded over the SSH connection): it is
+ * the identity the operator already uses to pull these images in local-server
+ * mode, so it is known to have read access to every release package. The remote
+ * host's own `gh` is only a fallback — a host may have `gh` logged in as a
+ * different or less-privileged account that lacks access to some package, which
+ * would 403 mid-pull. If neither is available we warn and proceed: a public
+ * image is a no-op, and a private one fails loudly on the subsequent pull.
+ */
+export async function ensureRemoteGhcrLogin(host: {
+ ctx: IExecutionContext;
+ writeFile: (relPath: string, content: string, mode?: number) => Promise<void>;
+ label: string;
+}): Promise<void> {
+ const { ctx, label } = host;
+
+ const identity = await getLocalGithubIdentity();
+ if (identity) {
+ await loginWithForwardedToken(host, identity.username, identity.token);
+ log.info(
+ `remote-switch-server: authenticated ${label} Docker to GHCR via forwarded desktop token`
+ );
+ return;
+ }
+
+ const remoteUser = await remoteGhUsername(ctx);
+ if (remoteUser) {
+ await ctx.exec('sh', [
+ '-c',
+ `gh auth token | docker login ${GHCR_REGISTRY} -u ${remoteUser} --password-stdin`,
+ ]);
+ log.info(`remote-switch-server: authenticated ${label} Docker to GHCR via its own gh login`);
+ return;
+ }
+
+ log.warn(
+ `remote-switch-server: no desktop gh token and no gh login on ${label}; skipping GHCR login (private image pulls will fail)`
+ );
+}
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/remote-host.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/remote-host.ts
new file mode 100644
index 000000000..fc80ce837
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/remote-host.ts
@@ -0,0 +1,227 @@
+import {
+ buildSshCommand,
+ SshExecutionContext,
+} from '@main/core/execution-context/ssh-execution-context';
+import type { IExecutionContext } from '@main/core/execution-context/types';
+import { SshFileSystem } from '@main/core/fs/impl/ssh-fs';
+import { sshConnectionIdForHost } from '@main/core/locations/location-transport';
+import { ensureSshConnected } from '@main/core/ssh/connect/connect-agent-ssh';
+import type { SshClientProxy } from '@main/core/ssh/lifecycle/ssh-client-proxy';
+import { log } from '@main/lib/logger';
+import type { DockerAvailability } from '@shared/core/managed-switch-server/managed-switch-server';
+import { REMOTE_SERVER_PROJECT_NAME } from '../constants';
+import type { LocalServerPorts } from '../free-port';
+import { remoteServerStateDir } from '../paths';
+import { PortForwarder } from './port-forward';
+import { pickRemoteFreePorts } from './remote-free-port';
+import { ensureRemoteGhcrLogin } from './remote-ghcr-auth';
+import { hostSlug, remoteSecretsKey } from './remote-identity';
+import type { ServerHost } from './types';
+
+/** Ports mirrored into a desktop-side forward so a single `localhost:<port>`
+ * URL reaches the stack from both the desktop and the remote host. Postgres is
+ * intentionally not forwarded — nothing on the desktop talks to it directly. */
+const FORWARDED_SERVICES: (keyof LocalServerPorts)[] = ['gateway', 'api', 'mattermost'];
+
+type RemoteHostDeps = {
+ sshHost: string;
+ proxy: SshClientProxy;
+ /** Execution context rooted at {@link workingDir}. */
+ ctx: SshExecutionContext;
+ workingDir: string;
+};
+
+/**
+ * A switchdash-managed Switch stack running on a remote host's Docker daemon
+ * over SSH. Commands run via `SshExecutionContext` (a login shell `cd`'d into
+ * the working dir); files are written over SFTP; ports are chosen free on both
+ * loopbacks and bridged with a persistent mirrored forward so the desktop and
+ * local agents reach `localhost:<port>` exactly as remote-host agents reach the
+ * stack's own loopback.
+ */
+export class RemoteServerHost implements ServerHost {
+ readonly kind = 'remote' as const;
+ readonly dockerBin = 'docker';
+ readonly composeProjectName = REMOTE_SERVER_PROJECT_NAME;
+ readonly workingDir: string;
+ readonly stateDir: string;
+ readonly secretsKey: string;
+ readonly label: string;
+ readonly ctx: IExecutionContext;
+
+ private readonly sshHost: string;
+ private readonly proxy: SshClientProxy;
+ private readonly fs: SshFileSystem;
+ private forwarder: PortForwarder | null = null;
+
+ constructor(deps: RemoteHostDeps) {
+ this.sshHost = deps.sshHost;
+ this.proxy = deps.proxy;
+ this.ctx = deps.ctx;
+ this.workingDir = deps.workingDir;
+ this.label = deps.sshHost;
+ this.stateDir = remoteServerStateDir(hostSlug(deps.sshHost));
+ this.secretsKey = remoteSecretsKey(deps.sshHost);
+ this.fs = new SshFileSystem(deps.proxy, deps.workingDir);
+ }
+
+ async writeFile(relPath: string, content: string, mode?: number): Promise<void> {
+ await this.fs.write(relPath, content);
+ if (mode !== undefined) {
+ // ctx is rooted at workingDir, so the relative path resolves there.
+ await this.ctx.exec('chmod', [mode.toString(8).padStart(3, '0'), relPath]);
+ }
+ }
+
+ streamCommand(
+ command: string,
+ args: string[],
+ onLine: (line: string) => void,
+ opts: { timeoutMs?: number } = {}
+ ): Promise<void> {
+ return new Promise((resolve, reject) => {
+ this.proxy
+ .getRemoteShellProfile()
+ .then((profile) => {
+ const full = buildSshCommand(this.workingDir, command, args, profile);
+ this.proxy.exec(full, (execErr, stream) => {
+ if (execErr) {
+ reject(execErr);
+ return;
+ }
+ let stderrTail = '';
+ let settled = false;
+ const emit = (buf: Buffer) => {
+ for (const raw of buf.toString('utf8').split('\n')) {
+ const line = raw.replace(/\r$/, '');
+ if (line.length > 0) onLine(line);
+ }
+ };
+ const settle = (fn: () => void) => {
+ if (settled) return;
+ settled = true;
+ if (timer) clearTimeout(timer);
+ fn();
+ };
+ const timer =
+ opts.timeoutMs !== undefined
+ ? setTimeout(() => {
+ settle(() => {
+ stream.destroy();
+ reject(new Error(`${command} timed out after ${opts.timeoutMs}ms`));
+ });
+ }, opts.timeoutMs)
+ : undefined;
+ stream.on('data', emit);
+ stream.stderr.on('data', (buf: Buffer) => {
+ stderrTail = (stderrTail + buf.toString('utf8')).slice(-4000);
+ emit(buf);
+ });
+ stream.on('close', (code: number | null) => {
+ settle(() => {
+ if ((code ?? 0) === 0) resolve();
+ else reject(new Error(`${command} failed (exit ${code}): ${stderrTail.trim()}`));
+ });
+ });
+ stream.on('error', (err: Error) => settle(() => reject(err)));
+ });
+ })
+ .catch(reject);
+ });
+ }
+
+ async detectDocker(): Promise<DockerAvailability> {
+ try {
+ const { stdout } = await this.ctx.exec(
+ 'docker',
+ ['version', '--format', '{{.Server.Version}}'],
+ { timeout: 20_000 }
+ );
+ const version = stdout.trim();
+ if (!version) {
+ return {
+ available: false,
+ reason: 'daemon-down',
+ detail: `Docker on ${this.label} reported no server version.`,
+ };
+ }
+ return { available: true, version };
+ } catch (error) {
+ const message = error instanceof Error ? error.message : String(error);
+ if (/not found|command not found|no such file/i.test(message)) {
+ return {
+ available: false,
+ reason: 'not-installed',
+ detail: `The Docker CLI was not found on ${this.label}.`,
+ };
+ }
+ if (
+ /cannot connect to the docker daemon|is the docker daemon running|permission denied/i.test(
+ message
+ )
+ ) {
+ return {
+ available: false,
+ reason: 'daemon-down',
+ detail: `Docker is installed on ${this.label} but its daemon is not reachable (start it, or add your user to the docker group).`,
+ };
+ }
+ return { available: false, reason: 'daemon-down', detail: message };
+ }
+ }
+
+ ensureGhcrLogin(): Promise<void> {
+ return ensureRemoteGhcrLogin({
+ ctx: this.ctx,
+ writeFile: (relPath, content, mode) => this.writeFile(relPath, content, mode),
+ label: this.label,
+ });
+ }
+
+ pickFreePorts(): Promise<LocalServerPorts> {
+ return pickRemoteFreePorts(this.ctx);
+ }
+
+ async establishNetworking(ports: LocalServerPorts): Promise<void> {
+ this.forwarder?.stop();
+ const forwarder = new PortForwarder(this.proxy, this.label);
+ await forwarder.start(FORWARDED_SERVICES.map((s) => ports[s]));
+ this.forwarder = forwarder;
+ log.info(
+ `remote-switch-server: forwarding ${FORWARDED_SERVICES.join(', ')} from ${this.label}`
+ );
+ }
+
+ async teardownNetworking(): Promise<void> {
+ this.forwarder?.stop();
+ this.forwarder = null;
+ }
+
+ dispose(): void {
+ this.forwarder?.stop();
+ this.forwarder = null;
+ this.fs.close();
+ this.ctx.dispose();
+ }
+}
+
+/**
+ * Connect to a remote host and build its {@link RemoteServerHost}. Ensures the
+ * pooled SSH connection is up, resolves the remote home, and creates the working
+ * dir so the rooted execution context and SFTP writes are valid from the first
+ * command.
+ */
+export async function createRemoteServerHost(sshHost: string): Promise<RemoteServerHost> {
+ const proxy = await ensureSshConnected(sshConnectionIdForHost(sshHost), sshHost);
+ const probe = new SshExecutionContext(proxy);
+ const { stdout } = await probe.exec('sh', ['-c', 'printf %s "$HOME"']);
+ const home = stdout.trim();
+ if (!home) {
+ throw new Error(`Could not resolve the home directory on ${sshHost}.`);
+ }
+ const workingDir = `${home}/.switchdash/switch-server`;
+ await probe.exec('mkdir', ['-p', workingDir]);
+ probe.dispose();
+ const ctx = new SshExecutionContext(proxy, { root: workingDir });
+ return new RemoteServerHost({ sshHost, proxy, ctx, workingDir });
+}
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/remote-identity.test.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/remote-identity.test.ts
new file mode 100644
index 000000000..c2286b28f
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/remote-identity.test.ts
@@ -0,0 +1,21 @@
+import { describe, expect, it } from 'vitest';
+import { hostSlug, remoteSecretsKey } from './remote-identity';
+
+describe('hostSlug', () => {
+ it('keeps safe characters and replaces the rest', () => {
+ expect(hostSlug('prod-box')).toBe('prod-box');
+ expect(hostSlug('[email protected]')).toBe('user_1.2.3.4');
+ expect(hostSlug('host with spaces/and:colons')).toBe('host_with_spaces_and_colons');
+ });
+});
+
+describe('remoteSecretsKey', () => {
+ it('namespaces the key per host slug', () => {
+ expect(remoteSecretsKey('prod-box')).toBe('remote-switch-server:prod-box:secrets');
+ expect(remoteSecretsKey('[email protected]')).toBe('remote-switch-server:user_1.2.3.4:secrets');
+ });
+
+ it('is distinct across hosts', () => {
+ expect(remoteSecretsKey('a')).not.toBe(remoteSecretsKey('b'));
+ });
+});
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/remote-identity.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/remote-identity.ts
new file mode 100644
index 000000000..38d358f8a
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/remote-identity.ts
@@ -0,0 +1,13 @@
+/**
+ * Deterministic, filesystem- and secret-key-safe slug for an SSH host alias, so
+ * a host's persisted metadata and secret bundle live at stable, collision-free
+ * paths/keys. (Aliases can contain characters not safe in a path or key.)
+ */
+export function hostSlug(sshHost: string): string {
+ return sshHost.replace(/[^A-Za-z0-9_.-]/g, '_');
+}
+
+/** Encrypted-store key holding a remote host's stack secret bundle. */
+export function remoteSecretsKey(sshHost: string): string {
+ return `remote-switch-server:${hostSlug(sshHost)}:secrets`;
+}
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/types.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/types.ts
new file mode 100644
index 000000000..d27688cb5
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/host/types.ts
@@ -0,0 +1,99 @@
+import type { IExecutionContext } from '@main/core/execution-context/types';
+import type { DockerAvailability } from '@shared/core/managed-switch-server/managed-switch-server';
+import type { LocalServerPorts } from '../free-port';
+
+/**
+ * A host that runs a switchdash-managed Switch stack via `docker compose`.
+ *
+ * Abstracts everything that differs between the local Docker daemon and a
+ * remote host's daemon reached over SSH, so the compose pipeline
+ * (compose up / health / register / stop / reset) is transport-agnostic:
+ *
+ * - `ctx` runs commands on the host (local spawn vs SSH exec), rooted at
+ * `workingDir` so `docker compose -f <relative>` resolves.
+ * - `writeFile` materialises the compose file and generated `.env` on the host.
+ * - `pickFreePorts` chooses host ports; the remote host additionally requires
+ * the same numbers to be free on the desktop's loopback (see remote host).
+ * - `establishNetworking` makes the published ports reachable from the desktop
+ * (a no-op locally; a persistent mirrored SSH forward remotely) so the same
+ * `http://localhost:<port>` URL works for the desktop and local agents.
+ *
+ * One host instance backs one start/stop/reset operation and is disposed after.
+ */
+export interface ServerHost {
+ readonly kind: 'local' | 'remote';
+
+ /** Execution context rooted at {@link workingDir}. */
+ readonly ctx: IExecutionContext;
+
+ /** Docker executable to invoke on the host (an absolute path locally; the
+ * bare `docker` resolved via the login shell remotely). */
+ readonly dockerBin: string;
+
+ /** `docker compose --project-name` scoping the managed stack's containers and
+ * volumes on the host's daemon. */
+ readonly composeProjectName: string;
+
+ /** Directory on the host holding the compose file + generated `.env`. */
+ readonly workingDir: string;
+
+ /** Local (desktop) directory where switchdash persists this host's own
+ * metadata — the chosen port set (`ports.json`). Equals {@link workingDir}
+ * for the local host; a per-host dir under user-data for a remote host, since
+ * its working dir lives on the remote machine. */
+ readonly stateDir: string;
+
+ /** Encrypted-store key under which this host's stack secret bundle is kept.
+ * Distinct per host so a local and one/more remote managed stacks never share
+ * (or clobber) each other's credentials. */
+ readonly secretsKey: string;
+
+ /** Human-readable label for the host, used in log lines ("this computer" /
+ * the SSH alias). */
+ readonly label: string;
+
+ /** Write `content` to `relPath` under {@link workingDir}, creating parent
+ * directories. `mode` (e.g. 0o600 for the secret-bearing `.env`) is enforced
+ * when provided. */
+ writeFile(relPath: string, content: string, mode?: number): Promise<void>;
+
+ /**
+ * Run a command on the host streaming merged stdout+stderr line-by-line to
+ * `onLine`, rooted at {@link workingDir}. Used for the slow `compose up`
+ * (docker emits pull/startup progress on stderr, so both streams are
+ * forwarded for the UI tail). Rejects on non-zero exit or timeout.
+ */
+ streamCommand(
+ command: string,
+ args: string[],
+ onLine: (line: string) => void,
+ opts?: { timeoutMs?: number }
+ ): Promise<void>;
+
+ /** Whether Docker is usable on the host (CLI resolves AND daemon answers). */
+ detectDocker(): Promise<DockerAvailability>;
+
+ /** Authenticate the host's Docker to GHCR so the private release images pull
+ * before the public-repo flip (CHOO-1260). Best-effort: warns and proceeds
+ * when no credentials are available, so a public image is a no-op and a
+ * private one fails loudly on the subsequent pull. */
+ ensureGhcrLogin(): Promise<void>;
+
+ /** Free host ports for the stack to publish on the host's loopback. The
+ * remote host picks numbers free on BOTH the remote and the desktop loopback,
+ * so the same number can be mirrored by the local forward. */
+ pickFreePorts(): Promise<LocalServerPorts>;
+
+ /** Make the published ports reachable from the desktop at
+ * `http://localhost:<port>`. Local: no-op (already on loopback). Remote:
+ * start persistent mirrored port-forward listeners (same number both sides)
+ * over the SSH connection, kept alive across reconnects. */
+ establishNetworking(ports: LocalServerPorts): Promise<void>;
+
+ /** Tear down any networking started by {@link establishNetworking}. Called on
+ * stop/reset and disposal. Idempotent. */
+ teardownNetworking(): Promise<void>;
+
+ /** Release resources (execution context, forwards). Idempotent. */
+ dispose(): void;
+}
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/local-server-service.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/local-server-service.ts
new file mode 100644
index 000000000..a99ad8c7f
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/local-server-service.ts
@@ -0,0 +1,155 @@
+import { getManagedServer } from '@main/core/switch-servers/servers-store';
+import { events } from '@main/lib/events';
+import { log } from '@main/lib/logger';
+import { COMPATIBLE_SWITCH_VERSION } from '@shared/app-identity';
+import type {
+ DockerAvailability,
+ LocalServerStatus,
+ StartLocalServerResult,
+} from '@shared/core/managed-switch-server/managed-switch-server';
+import {
+ localServerLogChannel,
+ localServerStatusChannel,
+} from '@shared/events/localSwitchServerEvents';
+import { isStackRunning } from './compose';
+import { LOCAL_SERVER_NAME } from './constants';
+import { LocalServerHost } from './host/local-host';
+import type { ServerHost } from './host/types';
+import { resetStack, startStack, stopStack } from './pipeline';
+
+/**
+ * Supervises the managed local Switch stack via the shared {@link startStack}
+ * pipeline on a {@link LocalServerHost}. One operation runs at a time (`busy`);
+ * every state transition is pushed to the renderer over
+ * `localServerStatusChannel`.
+ *
+ * Deliberately does NOT stop the containers on app quit — the local stack keeps
+ * running so its rooms stay live while switchdash is closed, matching the remote
+ * sidecar model. `dispose()` only aborts an in-flight health wait.
+ */
+class LocalServerService {
+ private status: LocalServerStatus = {
+ phase: 'stopped',
+ serverId: null,
+ version: COMPATIBLE_SWITCH_VERSION,
+ message: null,
+ error: null,
+ };
+
+ private busy = false;
+ private startAbort: AbortController | null = null;
+
+ getStatus(): LocalServerStatus {
+ return this.status;
+ }
+
+ detectDocker(): Promise<DockerAvailability> {
+ return new LocalServerHost().detectDocker();
+ }
+
+ private setStatus(patch: Partial<LocalServerStatus>): void {
+ this.status = { ...this.status, ...patch };
+ events.emit(localServerStatusChannel, this.status);
+ }
+
+ /** Reconcile status at boot so a stack that survived the last quit shows as
+ * running without the user re-starting it. */
+ async initialize(): Promise<void> {
+ try {
+ const managed = await getManagedServer();
+ if (managed && (await isStackRunning(new LocalServerHost()))) {
+ this.setStatus({ phase: 'running', serverId: managed.id, message: null, error: null });
+ }
+ } catch (error) {
+ log.warn('local-switch-server: boot status reconcile failed', { error });
+ }
+ }
+
+ async start(): Promise<StartLocalServerResult> {
+ if (this.busy) {
+ return { kind: 'error', message: 'A local-server operation is already in progress.' };
+ }
+ this.busy = true;
+ this.startAbort = new AbortController();
+ const host: ServerHost = new LocalServerHost();
+ try {
+ this.setStatus({ phase: 'starting', error: null, message: 'Checking Docker…' });
+ const result = await startStack({
+ host,
+ ref: { kind: 'local' },
+ serverName: LOCAL_SERVER_NAME,
+ onMessage: (message) => this.setStatus({ message }),
+ onLog: (line) => events.emit(localServerLogChannel, { line }),
+ signal: this.startAbort.signal,
+ });
+ if (result.kind === 'docker-unavailable') {
+ this.setStatus({ phase: 'error', error: result.detail });
+ } else if (result.kind === 'error') {
+ this.setStatus({ phase: 'error', error: result.message });
+ } else {
+ this.setStatus({ phase: 'running', serverId: result.serverId, message: null, error: null });
+ }
+ return result;
+ } catch (error) {
+ const message = error instanceof Error ? error.message : String(error);
+ log.error('local-switch-server: start failed', { error });
+ this.setStatus({ phase: 'error', error: message });
+ return { kind: 'error', message };
+ } finally {
+ host.dispose();
+ this.busy = false;
+ this.startAbort = null;
+ }
+ }
+
+ async stop(): Promise<void> {
+ if (this.busy) throw new Error('A local-server operation is already in progress.');
+ this.busy = true;
+ const host: ServerHost = new LocalServerHost();
+ try {
+ this.setStatus({ phase: 'stopping', message: 'Stopping containers…' });
+ await stopStack(host);
+ this.setStatus({ phase: 'stopped', message: null, error: null });
+ } catch (error) {
+ this.setStatus({
+ phase: 'error',
+ error: error instanceof Error ? error.message : String(error),
+ });
+ throw error;
+ } finally {
+ host.dispose();
+ this.busy = false;
+ }
+ }
+
+ /** Destroy the stack AND its data volumes, and drop the stored secrets so the
+ * next start is a clean install. Irreversible — the caller must confirm. The
+ * caller (renderer) removes the managed server's agents first, since their
+ * server-side identity is wiped here. */
+ async reset(): Promise<void> {
+ if (this.busy) throw new Error('A local-server operation is already in progress.');
+ this.busy = true;
+ const host: ServerHost = new LocalServerHost();
+ try {
+ this.setStatus({ phase: 'stopping', message: 'Destroying containers and data…' });
+ await resetStack(host);
+ this.setStatus({ phase: 'stopped', message: null, error: null });
+ } catch (error) {
+ this.setStatus({
+ phase: 'error',
+ error: error instanceof Error ? error.message : String(error),
+ });
+ throw error;
+ } finally {
+ host.dispose();
+ this.busy = false;
+ }
+ }
+
+ dispose(): void {
+ this.startAbort?.abort();
+ this.startAbort = null;
+ }
+}
+
+export const localServerService = new LocalServerService();
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/paths.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/paths.ts
new file mode 100644
index 000000000..fb28bf3b6
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/paths.ts
@@ -0,0 +1,16 @@
+import { join } from 'node:path';
+import { app } from 'electron';
+
+/** Root for the local managed stack's on-disk runtime artifacts (compose file +
+ * env) and persisted metadata (ports.json), under the app's user-data dir so it
+ * is per-install and easy to locate. */
+export function localServerDir(): string {
+ return join(app.getPath('userData'), 'local-switch-server');
+}
+
+/** Root for a remote managed host's DESKTOP-side metadata (ports.json), kept
+ * per SSH host under user-data. The stack's compose file + `.env` live on the
+ * remote host itself, not here. */
+export function remoteServerStateDir(hostSlug: string): string {
+ return join(app.getPath('userData'), 'remote-switch-server', hostSlug);
+}
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/pipeline.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/pipeline.ts
new file mode 100644
index 000000000..6b0495982
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/pipeline.ts
@@ -0,0 +1,125 @@
+import { resolveAgentServers } from '@main/core/agents/resolve-servers';
+import { passwordLogin } from '@main/core/switch-servers/auth';
+import { ensureManagedServer, setActiveServerId } from '@main/core/switch-servers/servers-store';
+import { log } from '@main/lib/logger';
+import { COMPATIBLE_SWITCH_VERSION, RELEASE_REPO_OWNER } from '@shared/app-identity';
+import type { StartLocalServerResult } from '@shared/core/managed-switch-server/managed-switch-server';
+import type { ManagedServerRef } from '@shared/core/switch-servers/switch-servers';
+import { bundledComposeYaml } from './bundled-compose';
+import { composeDown, composeUp } from './compose';
+import {
+ COMPOSE_FILE_NAME,
+ ENV_FILE_NAME,
+ GHCR_REGISTRY,
+ LOCAL_SERVER_ADMIN_EMAIL,
+} from './constants';
+import { buildEnvFile } from './env-file';
+import { apiUrlFor, gatewayUrlFor } from './free-port';
+import { waitForHealth } from './health';
+import type { ServerHost } from './host/types';
+import { clearPorts, resolvePorts } from './ports';
+import { clearSecrets, loadOrCreateSecrets } from './secrets';
+
+/**
+ * The transport-agnostic lifecycle for a switchdash-managed Switch stack, run
+ * against a {@link ServerHost}. Shared by the local-server service (a single
+ * local host) and the remote-server service (one host per SSH alias); each wraps
+ * these with its own phase/status bookkeeping.
+ */
+
+export type StartStackOptions = {
+ host: ServerHost;
+ /** Which managed record to upsert (local, or a specific remote host). */
+ ref: ManagedServerRef;
+ /** Display name for the registered server record. */
+ serverName: string;
+ /** Coarse step messages for the UI ("Pulling images…"). */
+ onMessage: (message: string) => void;
+ /** Live compose output lines for the UI log tail. */
+ onLog: (line: string) => void;
+ /** Aborts an in-flight health wait (stop/cancel/quit). */
+ signal: AbortSignal;
+};
+
+/**
+ * Full start pipeline: detect Docker → GHCR login → materialise compose + `.env`
+ * → `compose up` → establish networking → health-gate → register + activate →
+ * silent admin sign-in → reconcile agent servers. Returns without registering
+ * anything if Docker is unavailable or the stack never turns healthy.
+ */
+export async function startStack(opts: StartStackOptions): Promise<StartLocalServerResult> {
+ const { host, ref, serverName, onMessage, onLog, signal } = opts;
+
+ const docker = await host.detectDocker();
+ if (!docker.available) {
+ return { kind: 'docker-unavailable', reason: docker.reason, detail: docker.detail };
+ }
+
+ onMessage('Authenticating to image registry…');
+ await host.ensureGhcrLogin();
+
+ onMessage('Preparing configuration…');
+ await host.writeFile(COMPOSE_FILE_NAME, bundledComposeYaml());
+ const secrets = await loadOrCreateSecrets(host);
+ const ports = await resolvePorts(host);
+ const gatewayUrl = gatewayUrlFor(ports);
+ const apiUrl = apiUrlFor(ports);
+ await host.writeFile(
+ ENV_FILE_NAME,
+ buildEnvFile({
+ version: COMPATIBLE_SWITCH_VERSION,
+ registry: GHCR_REGISTRY,
+ namespace: RELEASE_REPO_OWNER,
+ ports,
+ secrets,
+ }),
+ 0o600
+ );
+
+ onMessage('Starting containers (pulling images if needed)…');
+ await composeUp(host, onLog);
+
+ // Make the published ports reachable from the desktop (no-op locally; a
+ // mirrored SSH forward remotely) BEFORE the health probe, so the probe takes
+ // the same path clients will.
+ await host.establishNetworking(ports);
+
+ onMessage('Waiting for the server to become healthy…');
+ const healthy = await waitForHealth(gatewayUrl, { signal });
+ if (!healthy) {
+ return { kind: 'error', message: 'The server did not become healthy in time.' };
+ }
+
+ const server = await ensureManagedServer({ name: serverName, gatewayUrl, apiUrl }, ref);
+ await setActiveServerId(server.id);
+
+ // switchdash generated the admin password, so sign in on the user's behalf
+ // rather than showing a login wall for a secret they never saw. A failure here
+ // does not fail the start — the stack is healthy; the server view falls back
+ // to its sign-in panel.
+ onMessage('Signing in…');
+ const login = await passwordLogin(server, LOCAL_SERVER_ADMIN_EMAIL, secrets.gatewayAdminPassword);
+ if (!login.success) {
+ log.warn('managed-switch-server: auto sign-in failed; server will show a sign-in prompt', {
+ error: login.error,
+ });
+ }
+
+ await resolveAgentServers();
+ return { kind: 'started', serverId: server.id };
+}
+
+/** Stop the stack's containers and tear down networking (leaves data + config). */
+export async function stopStack(host: ServerHost): Promise<void> {
+ await composeDown(host, false);
+ await host.teardownNetworking();
+}
+
+/** Destroy the stack, its data volumes, stored secrets, and port choice — the
+ * irreversible clean-slate reset. */
+export async function resetStack(host: ServerHost): Promise<void> {
+ await composeDown(host, true);
+ await host.teardownNetworking();
+ await clearSecrets(host);
+ await clearPorts(host);
+}
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/ports.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/ports.ts
new file mode 100644
index 000000000..c31dd4357
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/ports.ts
@@ -0,0 +1,55 @@
+import { mkdir, readFile, writeFile } from 'node:fs/promises';
+import { dirname, join } from 'node:path';
+import { isPorts, type LocalServerPorts } from './free-port';
+import type { ServerHost } from './host/types';
+
+function portsFilePath(host: ServerHost): string {
+ return join(host.stateDir, 'ports.json');
+}
+
+async function loadPersisted(host: ServerHost): Promise<LocalServerPorts | null> {
+ try {
+ const parsed: unknown = JSON.parse(await readFile(portsFilePath(host), 'utf8'));
+ return isPorts(parsed) ? parsed : null;
+ } catch {
+ return null;
+ }
+}
+
+async function persist(host: ServerHost, ports: LocalServerPorts): Promise<void> {
+ await mkdir(dirname(portsFilePath(host)), { recursive: true });
+ await writeFile(portsFilePath(host), JSON.stringify(ports, null, 2), 'utf8');
+}
+
+/**
+ * The ports the managed stack should publish on. Reuses the persisted choice if
+ * present — the running containers are already bound to those, and reusing keeps
+ * the server's URLs stable across restarts (so an API-URL cascade to agents is
+ * not needed every start) — otherwise picks free ports once (via the host, which
+ * for a remote host ensures the numbers are free on both loopbacks) and
+ * persists them.
+ */
+export async function resolvePorts(host: ServerHost): Promise<LocalServerPorts> {
+ const existing = await loadPersisted(host);
+ if (existing) return existing;
+ const chosen = await host.pickFreePorts();
+ await persist(host, chosen);
+ return chosen;
+}
+
+/** The persisted port choice for a host, or null if none has been chosen yet.
+ * Used at boot to re-establish a remote forward only when we know the ports the
+ * running containers are actually bound to (picking fresh here would forward to
+ * the wrong ports). */
+export function readPersistedPorts(host: ServerHost): Promise<LocalServerPorts | null> {
+ return loadPersisted(host);
+}
+
+/** Drop the persisted choice so the next start picks fresh ports (reset path). */
+export async function clearPorts(host: ServerHost): Promise<void> {
+ try {
+ await writeFile(portsFilePath(host), JSON.stringify({}), 'utf8');
+ } catch {
+ // Best-effort: a missing file is already the desired state.
+ }
+}
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/remote-controller.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/remote-controller.ts
new file mode 100644
index 000000000..be1e02144
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/remote-controller.ts
@@ -0,0 +1,22 @@
+import type {
+ DockerAvailability,
+ StartLocalServerResult,
+} from '@shared/core/managed-switch-server/managed-switch-server';
+import type { RemoteServerStatus } from '@shared/events/remoteSwitchServerEvents';
+import { createRPCController } from '@shared/lib/ipc/rpc';
+import { remoteServerService } from './remote-server-service';
+
+export const remoteSwitchServerController = createRPCController({
+ getStatuses: (): Promise<RemoteServerStatus[]> =>
+ Promise.resolve(remoteServerService.getStatuses()),
+
+ detectDocker: (sshHost: string): Promise<DockerAvailability> =>
+ remoteServerService.detectDocker(sshHost),
+
+ start: (params: { sshHost: string; name: string }): Promise<StartLocalServerResult> =>
+ remoteServerService.start(params.sshHost, params.name),
+
+ stop: (sshHost: string): Promise<void> => remoteServerService.stop(sshHost),
+
+ reset: (sshHost: string): Promise<void> => remoteServerService.reset(sshHost),
+});
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/remote-server-service.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/remote-server-service.ts
new file mode 100644
index 000000000..cc65cf762
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/remote-server-service.ts
@@ -0,0 +1,215 @@
+import { listManagedServers } from '@main/core/switch-servers/servers-store';
+import { events } from '@main/lib/events';
+import { log } from '@main/lib/logger';
+import { COMPATIBLE_SWITCH_VERSION } from '@shared/app-identity';
+import type {
+ DockerAvailability,
+ StartLocalServerResult,
+} from '@shared/core/managed-switch-server/managed-switch-server';
+import {
+ type RemoteServerStatus,
+ remoteServerLogChannel,
+ remoteServerStatusChannel,
+} from '@shared/events/remoteSwitchServerEvents';
+import { isStackRunning } from './compose';
+import { createRemoteServerHost, type RemoteServerHost } from './host/remote-host';
+import { resetStack, startStack, stopStack } from './pipeline';
+import { readPersistedPorts } from './ports';
+
+function initialStatus(sshHost: string): RemoteServerStatus {
+ return {
+ sshHost,
+ phase: 'stopped',
+ serverId: null,
+ version: COMPATIBLE_SWITCH_VERSION,
+ message: null,
+ error: null,
+ };
+}
+
+/**
+ * Supervises switchdash-managed Switch stacks on remote hosts (one per SSH
+ * alias), via the shared {@link startStack} pipeline on a {@link
+ * RemoteServerHost}. Unlike the local service, a started host is KEPT ALIVE in
+ * `hosts` because it owns the persistent port-forward that makes the stack
+ * reachable from the desktop; it is disposed only on stop/reset/quit. The
+ * containers themselves run detached, so a remote stack (and its remote-host
+ * agents) stays up while switchdash is closed — only the desktop-side forward
+ * goes away.
+ */
+class RemoteServerService {
+ private readonly statuses = new Map<string, RemoteServerStatus>();
+ private readonly hosts = new Map<string, RemoteServerHost>();
+ private readonly busy = new Set<string>();
+ private readonly startAborts = new Map<string, AbortController>();
+
+ getStatuses(): RemoteServerStatus[] {
+ return [...this.statuses.values()];
+ }
+
+ getStatus(sshHost: string): RemoteServerStatus {
+ return this.statuses.get(sshHost) ?? initialStatus(sshHost);
+ }
+
+ private setStatus(sshHost: string, patch: Partial<RemoteServerStatus>): void {
+ const next = { ...this.getStatus(sshHost), ...patch, sshHost };
+ this.statuses.set(sshHost, next);
+ events.emit(remoteServerStatusChannel, next);
+ }
+
+ async detectDocker(sshHost: string): Promise<DockerAvailability> {
+ const host = await createRemoteServerHost(sshHost);
+ try {
+ return await host.detectDocker();
+ } finally {
+ host.dispose();
+ }
+ }
+
+ /** Re-establish forwards + status for remote stacks that survived the last
+ * quit, so their desktop reachability is restored on launch. Best-effort per
+ * host: an unreachable host is left `stopped` rather than failing boot. */
+ async initialize(): Promise<void> {
+ const remotes = (await listManagedServers()).filter(
+ (s) => s.managementKind === 'remote' && s.sshHost
+ );
+ for (const server of remotes) {
+ const sshHost = server.sshHost!;
+ this.statuses.set(sshHost, initialStatus(sshHost));
+ let host: RemoteServerHost | null = null;
+ try {
+ host = await createRemoteServerHost(sshHost);
+ if (!(await isStackRunning(host))) {
+ host.dispose();
+ continue;
+ }
+ const ports = await readPersistedPorts(host);
+ if (!ports) {
+ // Running but we don't know its ports — leave it stopped; the user can
+ // restart to re-derive them rather than forward to the wrong ports.
+ host.dispose();
+ continue;
+ }
+ await host.establishNetworking(ports);
+ this.hosts.set(sshHost, host);
+ this.setStatus(sshHost, { phase: 'running', serverId: server.id });
+ } catch (error) {
+ host?.dispose();
+ log.warn(`remote-switch-server: boot reconcile failed for ${sshHost}`, { error });
+ }
+ }
+ }
+
+ async start(sshHost: string, serverName: string): Promise<StartLocalServerResult> {
+ if (this.busy.has(sshHost)) {
+ return { kind: 'error', message: `An operation is already in progress for ${sshHost}.` };
+ }
+ this.busy.add(sshHost);
+ const abort = new AbortController();
+ this.startAborts.set(sshHost, abort);
+ // Replace any prior live host (and its forward) for this alias.
+ this.hosts.get(sshHost)?.dispose();
+ this.hosts.delete(sshHost);
+ let host: RemoteServerHost | null = null;
+ try {
+ this.setStatus(sshHost, {
+ phase: 'starting',
+ error: null,
+ message: `Connecting to ${sshHost}…`,
+ });
+ host = await createRemoteServerHost(sshHost);
+ this.setStatus(sshHost, { message: 'Checking Docker…' });
+ const result = await startStack({
+ host,
+ ref: { kind: 'remote', sshHost },
+ serverName,
+ onMessage: (message) => this.setStatus(sshHost, { message }),
+ onLog: (line) => events.emit(remoteServerLogChannel, { sshHost, line }),
+ signal: abort.signal,
+ });
+ if (result.kind === 'docker-unavailable') {
+ this.setStatus(sshHost, { phase: 'error', error: result.detail });
+ host.dispose();
+ } else if (result.kind === 'error') {
+ this.setStatus(sshHost, { phase: 'error', error: result.message });
+ host.dispose();
+ } else {
+ // Keep the host alive — it owns the port-forward.
+ this.hosts.set(sshHost, host);
+ this.setStatus(sshHost, {
+ phase: 'running',
+ serverId: result.serverId,
+ message: null,
+ error: null,
+ });
+ }
+ return result;
+ } catch (error) {
+ host?.dispose();
+ const message = error instanceof Error ? error.message : String(error);
+ log.error(`remote-switch-server: start failed for ${sshHost}`, { error });
+ this.setStatus(sshHost, { phase: 'error', error: message });
+ return { kind: 'error', message };
+ } finally {
+ this.busy.delete(sshHost);
+ this.startAborts.delete(sshHost);
+ }
+ }
+
+ async stop(sshHost: string): Promise<void> {
+ if (this.busy.has(sshHost))
+ throw new Error(`An operation is already in progress for ${sshHost}.`);
+ this.busy.add(sshHost);
+ const host = this.hosts.get(sshHost) ?? (await createRemoteServerHost(sshHost));
+ try {
+ this.setStatus(sshHost, { phase: 'stopping', message: 'Stopping containers…' });
+ await stopStack(host);
+ this.setStatus(sshHost, { phase: 'stopped', message: null, error: null });
+ } catch (error) {
+ this.setStatus(sshHost, {
+ phase: 'error',
+ error: error instanceof Error ? error.message : String(error),
+ });
+ throw error;
+ } finally {
+ host.dispose();
+ this.hosts.delete(sshHost);
+ this.busy.delete(sshHost);
+ }
+ }
+
+ /** Destroy the remote stack, its data volumes, and stored secrets. The caller
+ * removes the server's agents first (their server-side identity is wiped). */
+ async reset(sshHost: string): Promise<void> {
+ if (this.busy.has(sshHost))
+ throw new Error(`An operation is already in progress for ${sshHost}.`);
+ this.busy.add(sshHost);
+ const host = this.hosts.get(sshHost) ?? (await createRemoteServerHost(sshHost));
+ try {
+ this.setStatus(sshHost, { phase: 'stopping', message: 'Destroying containers and data…' });
+ await resetStack(host);
+ this.setStatus(sshHost, { phase: 'stopped', message: null, error: null });
+ } catch (error) {
+ this.setStatus(sshHost, {
+ phase: 'error',
+ error: error instanceof Error ? error.message : String(error),
+ });
+ throw error;
+ } finally {
+ host.dispose();
+ this.hosts.delete(sshHost);
+ this.busy.delete(sshHost);
+ }
+ }
+
+ /** Abort in-flight health waits and drop all forwards (app quit). The remote
+ * containers keep running; only the desktop-side tunnels close. */
+ dispose(): void {
+ for (const abort of this.startAborts.values()) abort.abort();
+ this.startAborts.clear();
+ for (const host of this.hosts.values()) host.dispose();
+ this.hosts.clear();
+ }
+}
+
+export const remoteServerService = new RemoteServerService();
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/resources/standalone-docker-compose.pinned.yml b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/resources/standalone-docker-compose.pinned.yml
similarity index 100%
rename from dash/apps/switchdash-desktop/src/main/core/local-switch-server/resources/standalone-docker-compose.pinned.yml
rename to dash/apps/switchdash-desktop/src/main/core/managed-switch-server/resources/standalone-docker-compose.pinned.yml
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/secret-values.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/secret-values.ts
similarity index 100%
rename from dash/apps/switchdash-desktop/src/main/core/local-switch-server/secret-values.ts
rename to dash/apps/switchdash-desktop/src/main/core/managed-switch-server/secret-values.ts
diff --git a/dash/apps/switchdash-desktop/src/main/core/local-switch-server/secrets.test.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/secrets.test.ts
similarity index 100%
rename from dash/apps/switchdash-desktop/src/main/core/local-switch-server/secrets.test.ts
rename to dash/apps/switchdash-desktop/src/main/core/managed-switch-server/secrets.test.ts
diff --git a/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/secrets.ts b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/secrets.ts
new file mode 100644
index 000000000..382adf056
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/main/core/managed-switch-server/secrets.ts
@@ -0,0 +1,32 @@
+import { encryptedAppSecretsStore } from '@main/core/secrets/encrypted-app-secrets-store';
+import type { ServerHost } from './host/types';
+import { generateSecrets, type LocalServerSecrets } from './secret-values';
+
+/**
+ * Return the host's stored secret bundle, generating and persisting one on first
+ * use. Reusing the same secrets across restarts is required — the Postgres
+ * volume was initialised with the first `DB_PASSWORD`, so regenerating it would
+ * lock the stack out of its own database. Keyed per host (`host.secretsKey`) so
+ * local and remote managed stacks keep separate credentials.
+ */
+export async function loadOrCreateSecrets(
+ host: Pick<ServerHost, 'secretsKey'>
+): Promise<LocalServerSecrets> {
+ const existing = await encryptedAppSecretsStore.getSecret(host.secretsKey);
+ if (existing) {
+ try {
+ return JSON.parse(existing) as LocalServerSecrets;
+ } catch {
+ // Corrupt bundle — fall through and regenerate.
+ }
+ }
+ const fresh = generateSecrets();
+ await encryptedAppSecretsStore.setSecret(host.secretsKey, JSON.stringify(fresh));
+ return fresh;
+}
+
+/** Drop the host's secret bundle so the next start generates fresh credentials.
+ * Only safe to call after the data volumes have been destroyed (reset). */
+export async function clearSecrets(host: Pick<ServerHost, 'secretsKey'>): Promise<void> {
+ await encryptedAppSecretsStore.deleteSecret(host.secretsKey);
+}
diff --git a/dash/apps/switchdash-desktop/src/main/core/switch-servers/auth.ts b/dash/apps/switchdash-desktop/src/main/core/switch-servers/auth.ts
index df0c201f5..9ab978644 100644
--- a/dash/apps/switchdash-desktop/src/main/core/switch-servers/auth.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/switch-servers/auth.ts
@@ -1,8 +1,9 @@
import { randomUUID } from 'node:crypto';
import { err, ok, type Result } from '@switchdash/shared';
import { BrowserWindow, session as electronSession } from 'electron';
-import { LOCAL_SERVER_ADMIN_EMAIL } from '@main/core/local-switch-server/constants';
-import { loadOrCreateSecrets } from '@main/core/local-switch-server/secrets';
+import { LOCAL_SERVER_ADMIN_EMAIL } from '@main/core/managed-switch-server/constants';
+import { managedServerSecretsKey } from '@main/core/managed-switch-server/host/host-for-server';
+import { loadOrCreateSecrets } from '@main/core/managed-switch-server/secrets';
import { log } from '@main/lib/logger';
import type { SwitchServer, SwitchUser } from '@shared/core/switch-servers/switch-servers';
import { getSessionCookie, setSessionCookie } from './servers-store';
@@ -145,7 +146,7 @@ export async function refreshSession(
*/
export async function reauthenticateManagedServer(server: SwitchServer): Promise<string | null> {
if (!server.managed) return null;
- const secrets = await loadOrCreateSecrets();
+ const secrets = await loadOrCreateSecrets({ secretsKey: managedServerSecretsKey(server) });
const result = await passwordLogin(
server,
LOCAL_SERVER_ADMIN_EMAIL,
diff --git a/dash/apps/switchdash-desktop/src/main/core/switch-servers/servers-store.ts b/dash/apps/switchdash-desktop/src/main/core/switch-servers/servers-store.ts
index cb268a00a..fa35a601b 100644
--- a/dash/apps/switchdash-desktop/src/main/core/switch-servers/servers-store.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/switch-servers/servers-store.ts
@@ -1,10 +1,11 @@
import { randomUUID } from 'node:crypto';
-import { desc, eq, sql } from 'drizzle-orm';
+import { and, desc, eq, isNull, ne, or, sql } from 'drizzle-orm';
import { encryptedAppSecretsStore } from '@main/core/secrets/encrypted-app-secrets-store';
import { db } from '@main/db/client';
import { agents, kv, type SwitchServerRow, switchServers } from '@main/db/schema';
import type {
AddServerParams,
+ ManagedServerRef,
SwitchServer,
UpdateServerParams,
} from '@shared/core/switch-servers/switch-servers';
@@ -16,12 +17,21 @@ function cookieSecretKey(serverId: string): string {
}
function mapRow(row: SwitchServerRow): SwitchServer {
+ // A legacy managed row predating the discriminator has a null kind — read it
+ // as `local`, the only managed kind that existed then.
+ const managementKind = row.managed
+ ? row.managementKind === 'remote'
+ ? 'remote'
+ : 'local'
+ : null;
return {
id: row.id,
name: row.name,
gatewayUrl: row.gatewayUrl,
apiUrl: row.apiUrl,
managed: row.managed,
+ managementKind,
+ sshHost: row.sshHost ?? null,
createdAt: row.createdAt,
updatedAt: row.updatedAt,
};
@@ -68,28 +78,63 @@ export async function getServer(id: string): Promise<SwitchServer | null> {
return row ? mapRow(row) : null;
}
-/** The single server switchdash runs itself (local-server mode), or null. */
+/** The single LOCAL managed server switchdash runs on this machine, or null.
+ * Legacy managed rows with no kind count as local. */
export async function getManagedServer(): Promise<SwitchServer | null> {
const [row] = await db
.select()
.from(switchServers)
- .where(eq(switchServers.managed, true))
+ .where(
+ and(
+ eq(switchServers.managed, true),
+ // A null kind is a legacy local row; only 'remote' is excluded.
+ or(isNull(switchServers.managementKind), ne(switchServers.managementKind, 'remote'))
+ )
+ )
.limit(1);
return row ? mapRow(row) : null;
}
+/** The managed server switchdash runs on a given remote host, or null. */
+export async function getRemoteManagedServer(sshHost: string): Promise<SwitchServer | null> {
+ const [row] = await db
+ .select()
+ .from(switchServers)
+ .where(
+ and(
+ eq(switchServers.managed, true),
+ eq(switchServers.managementKind, 'remote'),
+ eq(switchServers.sshHost, sshHost)
+ )
+ )
+ .limit(1);
+ return row ? mapRow(row) : null;
+}
+
+/** Every server switchdash runs itself (local + all remote hosts). */
+export async function listManagedServers(): Promise<SwitchServer[]> {
+ const rows = await db.select().from(switchServers).where(eq(switchServers.managed, true));
+ return rows.map(mapRow);
+}
+
/**
- * Upsert the single managed local server record. Reuses the existing managed row
- * if there is one (updating its URLs, which can change across app versions),
- * else adopts a row already at this gateway URL (e.g. added by hand), else
- * inserts. Keeps exactly one managed row rather than duplicating on URL changes.
+ * Upsert a managed server record for the given target (the single local stack,
+ * or the stack on a specific remote host). Reuses the existing row for that
+ * target if there is one (updating its URLs, which change when ports are
+ * repicked), else adopts a row already at this gateway URL, else inserts. Keeps
+ * exactly one row per managed target rather than duplicating on URL changes.
*/
-export async function ensureManagedServer(params: AddServerParams): Promise<SwitchServer> {
+export async function ensureManagedServer(
+ params: AddServerParams,
+ ref: ManagedServerRef
+): Promise<SwitchServer> {
const gatewayUrl = normaliseUrl(params.gatewayUrl);
const apiUrl = normaliseUrl(params.apiUrl);
- // Prefer the single existing managed row (its URLs may have changed across app
- // versions), then any row already at this gateway URL; otherwise insert.
- const existing = (await getManagedServer()) ?? (await getServerByGatewayUrl(gatewayUrl));
+ const managementKind = ref.kind;
+ const sshHost = ref.kind === 'remote' ? ref.sshHost : null;
+ const existingForTarget =
+ ref.kind === 'remote' ? await getRemoteManagedServer(ref.sshHost) : await getManagedServer();
+ const existing = existingForTarget ?? (await getServerByGatewayUrl(gatewayUrl));
if (existing) {
const [row] = await db
.update(switchServers)
@@ -98,6 +143,8 @@ export async function ensureManagedServer(params: AddServerParams): Promise<Swit
gatewayUrl,
apiUrl,
managed: true,
+ managementKind,
+ sshHost,
updatedAt: sql`CURRENT_TIMESTAMP`,
})
.where(eq(switchServers.id, existing.id))
@@ -112,6 +159,8 @@ export async function ensureManagedServer(params: AddServerParams): Promise<Swit
gatewayUrl,
apiUrl,
managed: true,
+ managementKind,
+ sshHost,
updatedAt: sql`CURRENT_TIMESTAMP`,
})
.returning();
diff --git a/dash/apps/switchdash-desktop/src/main/db/schema.ts b/dash/apps/switchdash-desktop/src/main/db/schema.ts
index 3612e8d9a..b0f653197 100644
--- a/dash/apps/switchdash-desktop/src/main/db/schema.ts
+++ b/dash/apps/switchdash-desktop/src/main/db/schema.ts
@@ -104,9 +104,15 @@ export const switchServers = sqliteTable(
*/
apiUrl: text('api_url').notNull(),
/** True when switchdash provisions and runs this server itself via
- * local-server mode (`docker compose`). Managed servers get lifecycle
- * controls (start/stop/reset) and are not user-editable connection records. */
+ * docker compose. Managed servers get lifecycle controls (start/stop/reset)
+ * and are not user-editable connection records. */
managed: integer('managed', { mode: 'boolean' }).notNull().default(false),
+ /** Where a managed server runs: `local` (this computer) or `remote` (an SSH
+ * host). Null for external servers; a legacy managed row with a null kind is
+ * read as `local`. */
+ managementKind: text('management_kind'),
+ /** SSH alias of the host a remote-managed server runs on; null otherwise. */
+ sshHost: text('ssh_host'),
createdAt: text('created_at')
.notNull()
.default(sql`CURRENT_TIMESTAMP`),
diff --git a/dash/apps/switchdash-desktop/src/main/index.ts b/dash/apps/switchdash-desktop/src/main/index.ts
index d11a33da2..f772333ed 100644
--- a/dash/apps/switchdash-desktop/src/main/index.ts
+++ b/dash/apps/switchdash-desktop/src/main/index.ts
@@ -14,9 +14,10 @@ import { initializeRemoteDiscovery, initializeRemoteWatchers } from './core/agen
import { resolveAgentServers } from './core/agents/resolve-servers';
import { appService } from './core/app/service';
import { localDependencyManager } from './core/dependencies/dependency-managers';
-import { localServerService } from './core/local-switch-server/local-server-service';
import { locationManager } from './core/locations/location-manager';
import { locationSettingsService } from './core/locations/settings/location-settings-service';
+import { localServerService } from './core/managed-switch-server/local-server-service';
+import { remoteServerService } from './core/managed-switch-server/remote-server-service';
import { promptLibraryService } from './core/prompt-library/service';
import {
reconcileResourceSampler,
@@ -130,6 +131,9 @@ void app.whenReady().then(async () => {
// Reflect a managed local Switch stack that survived the last quit, so the UI
// shows it running without the user restarting it.
void localServerService.initialize();
+ // Re-establish desktop-side forwards for remote-managed stacks that survived
+ // the last quit, restoring their reachability from this machine.
+ void remoteServerService.initialize();
const dependenciesReady = localDependencyManager.probeAll().catch((e: unknown) => {
log.error('Failed to probe dependencies:', e);
@@ -197,6 +201,7 @@ app.on('before-quit', (event) => {
agentHookService.dispose();
stopResourceSampler();
localServerService.dispose();
+ remoteServerService.dispose();
updateService.dispose();
void locationManager.dispose().catch((e) => {
log.error('Failed to shutdown location manager:', e);
diff --git a/dash/apps/switchdash-desktop/src/main/rpc.ts b/dash/apps/switchdash-desktop/src/main/rpc.ts
index 0da55dc26..120b7eeea 100644
--- a/dash/apps/switchdash-desktop/src/main/rpc.ts
+++ b/dash/apps/switchdash-desktop/src/main/rpc.ts
@@ -2,9 +2,10 @@ import { createRPCNamespace, createRPCRouter } from '../shared/lib/ipc/rpc';
import { agentsController } from './core/agents/controller';
import { appController } from './core/app/controller';
import { filesController } from './core/fs/controller';
-import { localSwitchServerController } from './core/local-switch-server/controller';
import { locationsController } from './core/locations/controller';
import { locationRuntimeSettingsController } from './core/locations/location-runtime-settings-controller';
+import { localSwitchServerController } from './core/managed-switch-server/controller';
+import { remoteSwitchServerController } from './core/managed-switch-server/remote-controller';
import { promptLibraryController } from './core/prompt-library/controller';
import { providersController } from './core/providers/controller';
import { ptyController } from './core/pty/controller';
@@ -41,6 +42,7 @@ export const rpcRouter = createRPCRouter({
switchServers: switchServersController,
switchSetup: switchSetupController,
localSwitchServer: localSwitchServerController,
+ remoteSwitchServer: remoteSwitchServerController,
remoteHosts: remoteHostsController,
fs: createRPCNamespace({
watch: filesController,
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsx b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsx
index 3074b51c7..b3d9a479d 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsx
@@ -1,7 +1,7 @@
import { useQuery } from '@tanstack/react-query';
import { CheckCircle2, CircleAlert } from 'lucide-react';
import { observer } from 'mobx-react-lite';
-import { useCallback, useEffect, useRef, useState } from 'react';
+import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import type {
AgentOnboardingError,
ModeData as AgentOnboardingModeData,
@@ -75,7 +75,7 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc
queryKey: ['remote-hosts'],
queryFn: () => rpc.remoteHosts.listHosts(),
});
- const onboardedHosts = remoteHosts ?? [];
+ const onboardedHosts = useMemo(() => remoteHosts ?? [], [remoteHosts]);
const isRemoteRun = runHost !== LOCAL_RUN_LOCATION;
const remoteRunValid = !isRemoteRun || remoteRepoDir.trim().length > 0;
@@ -102,6 +102,31 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc
}
}, [targetServerId, pickedServerId, setServerId]);
+ // A managed server is only reachable from certain run locations, so constrain
+ // the picker to them: a remote-managed server from this computer or its own
+ // host (the desktop reaches it through the SSH forward; the host reaches it on
+ // loopback — nothing else has a route); a local-managed server from this
+ // computer only. External servers are unconstrained — the user owns their
+ // reachability.
+ const targetServer = switchServersStore.servers.find((s) => s.id === targetServerId) ?? null;
+ const targetKind = targetServer?.managementKind ?? null;
+ const targetHost = targetServer?.sshHost ?? null;
+ const allowedHosts = useMemo(
+ () =>
+ onboardedHosts.filter((host) =>
+ targetKind === 'remote' ? host.sshHost === targetHost : targetKind !== 'local'
+ ),
+ [onboardedHosts, targetKind, targetHost]
+ );
+ const runLocationConstrained = targetServer?.managed ?? false;
+ // If the current choice falls outside what the target server allows (e.g. the
+ // server changed), snap back to local.
+ useEffect(() => {
+ if (runHost !== LOCAL_RUN_LOCATION && !allowedHosts.some((h) => h.sshHost === runHost)) {
+ setRunHost(LOCAL_RUN_LOCATION);
+ }
+ }, [allowedHosts, runHost]);
+
// The subagents the user chose to onboard alongside the parent. Held in a ref
// (not state) so the section can report changes without re-rendering the modal.
const subagentSelectionRef = useRef<SubagentSelection>([]);
@@ -496,13 +521,20 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc
</SelectTrigger>
<SelectContent>
<SelectItem value={LOCAL_RUN_LOCATION}>Local (this machine)</SelectItem>
- {onboardedHosts.map((host) => (
+ {allowedHosts.map((host) => (
<SelectItem key={host.sshHost} value={host.sshHost}>
{host.name} ({host.sshHost})
</SelectItem>
))}
</SelectContent>
</Select>
+ {runLocationConstrained && (
+ <p className="text-xs text-foreground-muted">
+ {targetServer?.managementKind === 'remote'
+ ? `This server runs on ${targetServer.sshHost}, so its agents run on this computer or on ${targetServer.sshHost}.`
+ : 'This server runs on this computer, so its agents run here too.'}
+ </p>
+ )}
{isRemoteRun && (
<Input
value={remoteRepoDir}
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/AddServerModal.tsx b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/AddServerModal.tsx
index 1819ac519..cb823022d 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/AddServerModal.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/AddServerModal.tsx
@@ -1,7 +1,8 @@
-import { CircleCheck, HardDrive, Server, TriangleAlert } from 'lucide-react';
+import { CircleCheck, Globe, HardDrive, Server, TriangleAlert } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { useCallback, useEffect, useRef, useState } from 'react';
import { toast } from '@renderer/lib/hooks/use-toast';
+import { rpc } from '@renderer/lib/ipc';
import { type BaseModalProps } from '@renderer/lib/modal/modal-provider';
import { Alert, AlertDescription, AlertTitle } from '@renderer/lib/ui/alert';
import { Button } from '@renderer/lib/ui/button';
@@ -17,6 +18,7 @@ import { Input } from '@renderer/lib/ui/input';
import { Spinner } from '@renderer/lib/ui/spinner';
import type { ServerApiUrlPropagation } from '@shared/core/switch-servers/switch-servers';
import { localServerStore } from './local-server-store';
+import { remoteServerStore } from './remote-server-store';
import { switchServersStore } from './switch-servers-store';
/**
@@ -56,21 +58,23 @@ type Props = BaseModalProps<void> & {
initialName?: string;
/** When set, the modal edits this existing server instead of adding one. */
serverId?: string;
- /** Jump straight to a step, skipping the local/remote chooser. */
- mode?: 'local' | 'remote';
+ /** Jump straight to a step, skipping the chooser. `external` is the
+ * connect-by-URL form; `remoteHost` sets up a managed stack on an SSH host. */
+ mode?: 'local' | 'remoteHost' | 'external';
};
-type Step = 'choose' | 'local' | 'remote';
+type Step = 'choose' | 'local' | 'remoteHost' | 'external';
export const AddServerModal = observer(function AddServerModal(props: Props) {
const isEdit = props.serverId != null;
- const [step, setStep] = useState<Step>(isEdit ? 'remote' : (props.mode ?? 'choose'));
+ const [step, setStep] = useState<Step>(isEdit ? 'external' : (props.mode ?? 'choose'));
if (step === 'choose') {
return (
<ChooseStep
onLocal={() => setStep('local')}
- onRemote={() => setStep('remote')}
+ onRemoteHost={() => setStep('remoteHost')}
+ onExternal={() => setStep('external')}
onClose={props.onClose}
/>
);
@@ -84,8 +88,17 @@ export const AddServerModal = observer(function AddServerModal(props: Props) {
/>
);
}
+ if (step === 'remoteHost') {
+ return (
+ <RemoteHostSetupStep
+ onBack={() => setStep('choose')}
+ onSuccess={props.onSuccess}
+ onClose={props.onClose}
+ />
+ );
+ }
return (
- <RemoteServerStep
+ <ExternalServerStep
{...props}
isEdit={isEdit}
onBack={isEdit ? undefined : () => setStep('choose')}
@@ -94,16 +107,18 @@ export const AddServerModal = observer(function AddServerModal(props: Props) {
});
// ---------------------------------------------------------------------------
-// Step 1 — choose local vs remote
+// Step 1 — choose where the server lives
// ---------------------------------------------------------------------------
function ChooseStep({
onLocal,
- onRemote,
+ onRemoteHost,
+ onExternal,
onClose,
}: {
onLocal: () => void;
- onRemote: () => void;
+ onRemoteHost: () => void;
+ onExternal: () => void;
onClose: () => void;
}) {
return (
@@ -115,15 +130,21 @@ function ChooseStep({
<div className="grid gap-3">
<ChoiceCard
icon={<HardDrive className="size-5" />}
- title="Local server"
- description="Run the full Switch stack on this machine with Docker. Best for trying Switch out."
+ title="Run a server on this computer"
+ description="switchdash sets up and runs the full Switch stack here with Docker. Best for trying Switch out."
onClick={onLocal}
/>
<ChoiceCard
icon={<Server className="size-5" />}
- title="Remote server"
- description="Connect to an existing Switch gateway by URL."
- onClick={onRemote}
+ title="Run a server on a remote host"
+ description="switchdash sets it up over SSH on a host you've onboarded. Stays running when switchdash is closed."
+ onClick={onRemoteHost}
+ />
+ <ChoiceCard
+ icon={<Globe className="size-5" />}
+ title="Connect to an existing server"
+ description="Point switchdash at a Switch gateway someone else runs, by URL."
+ onClick={onExternal}
/>
</div>
</DialogContentArea>
@@ -207,7 +228,7 @@ const LocalSetupStep = observer(function LocalSetupStep({
return (
<>
<DialogHeader showCloseButton={false}>
- <DialogTitle>Set up a local server</DialogTitle>
+ <DialogTitle>Set up a server on this computer</DialogTitle>
</DialogHeader>
<DialogContentArea className="space-y-4 pt-0">
<div className="flex items-center gap-3">
@@ -215,9 +236,9 @@ const LocalSetupStep = observer(function LocalSetupStep({
<HardDrive className="size-5" />
</div>
<div className="min-w-0">
- <p className="text-sm font-medium text-foreground">Local Switch server</p>
+ <p className="text-sm font-medium text-foreground">Switch server · this computer</p>
<p className="truncate text-xs text-foreground-muted">
- switch-core {store.status?.version ?? ''} · runs on this machine via Docker
+ switch-core {store.status?.version ?? ''} · runs on this computer via Docker
</p>
</div>
</div>
@@ -355,7 +376,193 @@ function LogTail({ lines }: { lines: string[] }) {
}
// ---------------------------------------------------------------------------
-// Step 2b — remote server form (also the edit form)
+// Step 2b — remote-host managed setup (pick an onboarded SSH host → start)
+// ---------------------------------------------------------------------------
+
+const RemoteHostSetupStep = observer(function RemoteHostSetupStep({
+ onBack,
+ onSuccess,
+ onClose,
+}: {
+ onBack: () => void;
+ onSuccess: () => void;
+ onClose: () => void;
+}) {
+ const store = remoteServerStore;
+ const [hosts, setHosts] = useState<{ sshHost: string; name: string }[] | null>(null);
+ const [sshHost, setSshHost] = useState<string | null>(null);
+ const [name, setName] = useState('');
+
+ useEffect(() => {
+ void store.init();
+ void rpc.remoteHosts.listHosts().then((list) => {
+ setHosts(list);
+ if (list.length === 1) {
+ setSshHost(list[0]!.sshHost);
+ setName(`${list[0]!.name} Switch server`);
+ }
+ });
+ }, [store]);
+
+ useEffect(() => {
+ if (sshHost) void store.checkDocker(sshHost);
+ }, [store, sshHost]);
+
+ const running = sshHost ? store.isRunning(sshHost) : false;
+ const starting = sshHost ? store.isTransitioning(sshHost) : false;
+ const docker = sshHost ? store.dockerFor(sshHost) : null;
+ const dockerReady = docker?.available ?? false;
+ const dockerUnavailable = docker && !docker.available ? docker : null;
+ const status = sshHost ? store.statusFor(sshHost) : null;
+ const logs = sshHost ? store.logsFor(sshHost) : [];
+
+ const canStart = !!sshHost && name.trim().length > 0 && dockerReady && !starting;
+ const primaryLabel = running ? 'Done' : status?.phase === 'error' ? 'Retry' : 'Start';
+ const onPrimary = () => {
+ if (running) onSuccess();
+ else if (sshHost) void store.start(sshHost, name.trim());
+ };
+
+ return (
+ <>
+ <DialogHeader showCloseButton={false}>
+ <DialogTitle>Set up a server on a remote host</DialogTitle>
+ </DialogHeader>
+ <DialogContentArea className="space-y-4 pt-0">
+ {hosts === null ? (
+ <div className="flex items-center gap-2 text-sm text-foreground-muted">
+ <Spinner className="size-3.5" />
+ <span>Loading onboarded hosts…</span>
+ </div>
+ ) : hosts.length === 0 ? (
+ <Alert>
+ <TriangleAlert className="size-4" />
+ <AlertTitle>No onboarded hosts</AlertTitle>
+ <AlertDescription>
+ Onboard a remote host first (in Remote hosts settings), then come back to run a server
+ on it.
+ </AlertDescription>
+ </Alert>
+ ) : (
+ <>
+ <Field>
+ <FieldLabel>Host</FieldLabel>
+ <div className="grid gap-2">
+ {hosts.map((h) => (
+ <button
+ key={h.sshHost}
+ type="button"
+ disabled={starting}
+ onClick={() => {
+ setSshHost(h.sshHost);
+ if (!name.trim()) setName(`${h.name} Switch server`);
+ }}
+ className={`flex items-center gap-2 rounded-md border p-2.5 text-left text-sm ${
+ sshHost === h.sshHost
+ ? 'border-primary bg-background-tertiary-2'
+ : 'border-border hover:bg-background-tertiary-2'
+ }`}
+ >
+ <Server className="size-4 shrink-0 text-foreground-muted" />
+ <span className="min-w-0">
+ <span className="block truncate text-foreground">{h.name}</span>
+ <span className="block truncate text-xs text-foreground-muted">
+ {h.sshHost}
+ </span>
+ </span>
+ </button>
+ ))}
+ </div>
+ </Field>
+
+ {sshHost && (
+ <Field>
+ <FieldLabel>Name</FieldLabel>
+ <Input
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ placeholder="Team Switch server"
+ disabled={starting}
+ />
+ </Field>
+ )}
+
+ {sshHost && !running && (
+ <div className="bg-card space-y-2 rounded-lg border border-border p-3">
+ <p className="text-xs font-medium text-foreground-muted">Starting will:</p>
+ <ul className="space-y-1.5 text-xs text-foreground-muted">
+ <SetupStepItem>
+ Pull the Switch images from GHCR on {sshHost} (first run downloads a few GB)
+ </SetupStepItem>
+ <SetupStepItem>
+ Run the stack in Docker on the host, bound to its loopback
+ </SetupStepItem>
+ <SetupStepItem>
+ Bridge it to this computer over SSH so local agents can reach it too
+ </SetupStepItem>
+ </ul>
+ </div>
+ )}
+
+ {sshHost && !running && (
+ <DockerStatus
+ ready={dockerReady}
+ unavailable={dockerUnavailable}
+ checking={!docker}
+ />
+ )}
+
+ {running && (
+ <Alert>
+ <CircleCheck className="size-4" />
+ <AlertTitle>Server is running on {sshHost}</AlertTitle>
+ <AlertDescription>
+ It's in your servers list, reachable from this computer while switchdash is open.
+ </AlertDescription>
+ </Alert>
+ )}
+
+ {store.error && !dockerUnavailable && !running && (
+ <Alert variant="destructive">
+ <AlertTitle>Setup failed</AlertTitle>
+ <AlertDescription>{store.error}</AlertDescription>
+ </Alert>
+ )}
+
+ {(starting || logs.length > 0) && !running && (
+ <div className="space-y-1.5">
+ {status?.message && starting && (
+ <div className="flex items-center gap-2 text-sm text-foreground">
+ <Spinner className="size-3.5" />
+ <span>{status.message}</span>
+ </div>
+ )}
+ <LogTail lines={logs} />
+ </div>
+ )}
+ </>
+ )}
+ </DialogContentArea>
+ <DialogFooter>
+ {!starting ? (
+ <Button variant="outline" onClick={onBack}>
+ Back
+ </Button>
+ ) : (
+ <Button variant="outline" onClick={onClose} disabled>
+ Cancel
+ </Button>
+ )}
+ <ConfirmButton onClick={onPrimary} disabled={!running && !canStart}>
+ {starting ? 'Starting…' : primaryLabel}
+ </ConfirmButton>
+ </DialogFooter>
+ </>
+ );
+});
+
+// ---------------------------------------------------------------------------
+// Step 2c — external server form (connect by URL; also the edit form)
// ---------------------------------------------------------------------------
function looksLikeUrl(value: string): boolean {
@@ -367,7 +574,7 @@ function looksLikeUrl(value: string): boolean {
}
}
-const RemoteServerStep = observer(function RemoteServerStep({
+const ExternalServerStep = observer(function ExternalServerStep({
onSuccess,
onClose,
onBack,
@@ -430,7 +637,7 @@ const RemoteServerStep = observer(function RemoteServerStep({
return (
<>
<DialogHeader showCloseButton={false}>
- <DialogTitle>{isEdit ? 'Edit Switch server' : 'Add a remote server'}</DialogTitle>
+ <DialogTitle>{isEdit ? 'Edit Switch server' : 'Connect to an existing server'}</DialogTitle>
</DialogHeader>
<DialogContentArea className="pt-0">
<FieldGroup>
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/LocalServerControls.tsx b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/LocalServerControls.tsx
index f8336a658..bfc501d60 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/LocalServerControls.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/LocalServerControls.tsx
@@ -37,9 +37,9 @@ export const LocalServerControls = observer(function LocalServerControls() {
<div className={`${card} space-y-4`}>
<div className="flex items-start justify-between gap-3">
<div className="space-y-1">
- <h3 className="text-sm font-medium text-foreground">Local server</h3>
+ <h3 className="text-sm font-medium text-foreground">Managed server</h3>
<p className="text-xs text-foreground-muted">
- Runs the full Switch stack on this machine with Docker (switch-core{' '}
+ Runs the full Switch stack on this computer with Docker (switch-core{' '}
{store.status?.version ?? ''}).
</p>
</div>
@@ -142,11 +142,11 @@ const ResetDialog = observer(function ResetDialog({
<DialogContent>
<DialogHeader>
<TriangleAlert className="size-4 text-red-500" />
- <DialogTitle>Reset local server</DialogTitle>
+ <DialogTitle>Reset server on this computer</DialogTitle>
</DialogHeader>
<DialogContentArea>
<DialogDescription>
- This permanently deletes the local server and everything on it — all rooms, messages,
+ This permanently deletes this managed server and everything on it — all rooms, messages,
and{' '}
<strong className="text-foreground">every agent you've configured against it</strong>.
This can't be undone. A fresh Start rebuilds an empty stack from scratch.
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/RemoteServerControls.tsx b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/RemoteServerControls.tsx
new file mode 100644
index 000000000..7cb683062
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/RemoteServerControls.tsx
@@ -0,0 +1,210 @@
+import { CircleStop, Play, TriangleAlert } from 'lucide-react';
+import { observer } from 'mobx-react-lite';
+import { useEffect, useState } from 'react';
+import { Alert, AlertDescription, AlertTitle } from '@renderer/lib/ui/alert';
+import { Button } from '@renderer/lib/ui/button';
+import {
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogContentArea,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@renderer/lib/ui/dialog';
+import { Spinner } from '@renderer/lib/ui/spinner';
+import { remoteServerStore } from './remote-server-store';
+
+const card = 'rounded-lg border border-border bg-card p-4';
+
+/**
+ * Lifecycle controls for a switchdash-managed Switch stack running on a remote
+ * host: live status, Docker guidance, start / stop / reset — driven over the
+ * host's SSH connection. Rendered inside the managed remote server's page.
+ */
+export const RemoteServerControls = observer(function RemoteServerControls({
+ sshHost,
+ serverId,
+ name,
+}: {
+ sshHost: string;
+ serverId: string;
+ /** The registered server's name, reused when restarting so the record's name
+ * is preserved (not blanked). */
+ name: string;
+}) {
+ const store = remoteServerStore;
+ const [resetOpen, setResetOpen] = useState(false);
+
+ useEffect(() => {
+ void store.init();
+ void store.checkDocker(sshHost);
+ }, [store, sshHost]);
+
+ const status = store.statusFor(sshHost);
+ const transitioning = store.isTransitioning(sshHost);
+ const running = store.isRunning(sshHost);
+ const docker = store.dockerFor(sshHost);
+ const dockerUnavailable = docker && !docker.available ? docker : null;
+
+ return (
+ <div className={`${card} space-y-4`}>
+ <div className="flex items-start justify-between gap-3">
+ <div className="space-y-1">
+ <h3 className="text-sm font-medium text-foreground">Managed server</h3>
+ <p className="text-xs text-foreground-muted">
+ Runs the full Switch stack in Docker on {sshHost}, bridged to this computer over SSH.
+ </p>
+ </div>
+ <PhaseBadge sshHost={sshHost} />
+ </div>
+
+ {status.message && transitioning && (
+ <div className="flex items-center gap-2 text-sm text-foreground-muted">
+ <Spinner className="size-3.5" />
+ <span>{status.message}</span>
+ </div>
+ )}
+
+ {dockerUnavailable && (
+ <Alert variant="destructive">
+ <TriangleAlert className="size-4" />
+ <AlertTitle>
+ {dockerUnavailable.reason === 'not-installed'
+ ? 'Docker is not installed on the host'
+ : 'Docker is not running on the host'}
+ </AlertTitle>
+ <AlertDescription>{dockerUnavailable.detail}</AlertDescription>
+ </Alert>
+ )}
+
+ {store.error && !dockerUnavailable && (
+ <Alert variant="destructive">
+ <AlertTitle>Something went wrong</AlertTitle>
+ <AlertDescription>{store.error}</AlertDescription>
+ </Alert>
+ )}
+
+ <div className="flex items-center gap-2">
+ {running ? (
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={transitioning}
+ onClick={() => void store.stop(sshHost)}
+ >
+ <CircleStop className="size-4" />
+ Stop
+ </Button>
+ ) : (
+ <Button
+ size="sm"
+ disabled={transitioning}
+ onClick={() => void store.start(sshHost, name)}
+ >
+ <Play className="size-4" />
+ {status.phase === 'error' ? 'Retry' : 'Start'}
+ </Button>
+ )}
+ </div>
+
+ <p className="text-xs text-foreground-tertiary-passive">
+ The stack keeps running on {sshHost} when you close switchdash. Remote-host agents stay
+ connected; agents on this computer can reach it while switchdash is open.
+ </p>
+
+ <div className="mt-1 flex items-center justify-between gap-3 border-t border-border pt-4">
+ <div className="space-y-0.5">
+ <p className="text-xs font-medium text-foreground">Reset</p>
+ <p className="text-xs text-foreground-tertiary-passive">
+ Permanently deletes the stack's data and every agent configured against it.
+ </p>
+ </div>
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={transitioning}
+ className="shrink-0 border-red-500/40 text-red-500 hover:bg-red-500/10 hover:text-red-500"
+ onClick={() => setResetOpen(true)}
+ >
+ Reset…
+ </Button>
+ </div>
+
+ <ResetDialog
+ sshHost={sshHost}
+ open={resetOpen}
+ onOpenChange={setResetOpen}
+ disabled={transitioning}
+ onConfirm={() => {
+ setResetOpen(false);
+ void store.reset(sshHost, serverId);
+ }}
+ />
+ </div>
+ );
+});
+
+const ResetDialog = observer(function ResetDialog({
+ sshHost,
+ open,
+ onOpenChange,
+ disabled,
+ onConfirm,
+}: {
+ sshHost: string;
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ disabled: boolean;
+ onConfirm: () => void;
+}) {
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent>
+ <DialogHeader>
+ <TriangleAlert className="size-4 text-red-500" />
+ <DialogTitle>Reset server on {sshHost}</DialogTitle>
+ </DialogHeader>
+ <DialogContentArea>
+ <DialogDescription>
+ This permanently deletes this managed server and everything on it — all rooms, messages,
+ and{' '}
+ <strong className="text-foreground">every agent you've configured against it</strong>.
+ This can't be undone. A fresh Start rebuilds an empty stack from scratch.
+ </DialogDescription>
+ </DialogContentArea>
+ <DialogFooter>
+ <DialogClose render={<Button variant="outline" size="sm" />}>Cancel</DialogClose>
+ <Button variant="destructive" size="sm" disabled={disabled} onClick={onConfirm}>
+ Reset and delete all agents
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+});
+
+const PhaseBadge = observer(function PhaseBadge({ sshHost }: { sshHost: string }) {
+ const phase = remoteServerStore.phaseFor(sshHost);
+ const label: Record<typeof phase, string> = {
+ stopped: 'Stopped',
+ starting: 'Starting',
+ running: 'Running',
+ stopping: 'Stopping',
+ error: 'Error',
+ };
+ const dot: Record<typeof phase, string> = {
+ stopped: 'bg-foreground-muted',
+ starting: 'bg-amber-500',
+ running: 'bg-green-500',
+ stopping: 'bg-amber-500',
+ error: 'bg-red-500',
+ };
+ return (
+ <span className="flex items-center gap-1.5 text-xs text-foreground-muted">
+ <span aria-hidden className={`inline-block size-2 rounded-full ${dot[phase]}`} />
+ {label[phase]}
+ </span>
+ );
+});
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/ServersSidebarSection.tsx b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/ServersSidebarSection.tsx
index 13212c84e..2df478849 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/ServersSidebarSection.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/ServersSidebarSection.tsx
@@ -1,4 +1,4 @@
-import { ChevronDown, ChevronRight, HardDrive, Plus, Server } from 'lucide-react';
+import { ChevronDown, ChevronRight, Globe, HardDrive, Plus, Server } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { useEffect } from 'react';
import {
@@ -13,8 +13,10 @@ import { MicroLabel } from '@renderer/lib/ui/label';
import { Spinner } from '@renderer/lib/ui/spinner';
import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';
import { cn } from '@renderer/utils/utils';
+import type { SwitchServer } from '@shared/core/switch-servers/switch-servers';
import { SidebarMenu, SidebarMenuButton } from '../sidebar/sidebar-primitives';
import { localServerStore } from './local-server-store';
+import { remoteServerStore } from './remote-server-store';
import { switchServersStore } from './switch-servers-store';
export const ServersSidebarSection = observer(function ServersSidebarSection() {
@@ -24,11 +26,13 @@ export const ServersSidebarSection = observer(function ServersSidebarSection() {
useEffect(() => {
void store.init();
void localServerStore.init();
+ void remoteServerStore.init();
const onFocus = () => void store.refreshAllStatuses();
window.addEventListener('focus', onFocus);
return () => {
window.removeEventListener('focus', onFocus);
localServerStore.dispose();
+ remoteServerStore.dispose();
};
}, [store]);
@@ -102,7 +106,7 @@ export const ServersSidebarSection = observer(function ServersSidebarSection() {
onClick={() => showAddServerModal({})}
className="w-full px-3 py-1.5 text-left text-xs text-foreground-tertiary-passive hover:text-foreground-tertiary"
>
- Add a remote server…
+ Add a server…
</button>
)}
</SidebarMenu>
@@ -135,6 +139,13 @@ const LocalServerPendingEntry = observer(function LocalServerPendingEntry({
);
});
+function ServerIcon({ server, isScoped }: { server: SwitchServer; isScoped: boolean }) {
+ const className = cn('size-4 shrink-0', isScoped && 'text-foreground');
+ if (server.managementKind === 'remote') return <Server className={className} />;
+ if (server.managed) return <HardDrive className={className} />;
+ return <Globe className={className} />;
+}
+
const ServerEntry = observer(function ServerEntry({ serverId }: { serverId: string }) {
const store = switchServersStore;
const { navigate } = useNavigate();
@@ -150,6 +161,16 @@ const ServerEntry = observer(function ServerEntry({ serverId }: { serverId: stri
// a server makes it active and opens its page.
const isScoped = store.activeServerId === serverId;
+ // A managed server that isn't running has no gateway to reach, so it can't be
+ // signed into — show it as dormant (grey dot, no sign-in) until it's started.
+ const managedRunning = !server.managed
+ ? true
+ : server.managementKind === 'remote' && server.sshHost
+ ? remoteServerStore.isRunning(server.sshHost)
+ : localServerStore.isRunning;
+ const dormant = server.managed && !managedRunning;
+ const needsSignIn = !dormant && !connected;
+
return (
<SidebarMenuButton
isActive={isViewing}
@@ -160,28 +181,24 @@ const ServerEntry = observer(function ServerEntry({ serverId }: { serverId: stri
className="justify-between"
>
<span className="flex min-w-0 items-center gap-2">
- {server.managed ? (
- <HardDrive className={cn('size-4 shrink-0', isScoped && 'text-foreground')} />
- ) : (
- <Server className={cn('size-4 shrink-0', isScoped && 'text-foreground')} />
- )}
+ <ServerIcon server={server} isScoped={isScoped} />
<span className={cn('truncate', isScoped && 'font-medium text-foreground')}>
{server.name}
</span>
{server.managed && (
<span className="shrink-0 rounded bg-background-tertiary px-1 py-px text-[10px] font-medium tracking-wide text-foreground-muted uppercase">
- Local
+ {server.managementKind === 'remote' ? (server.sshHost ?? 'Remote') : 'This computer'}
</span>
)}
<span
aria-hidden
className={cn(
'size-1.5 shrink-0 rounded-full',
- connected ? 'bg-green-500' : 'bg-amber-500'
+ dormant ? 'bg-foreground-muted' : connected ? 'bg-green-500' : 'bg-amber-500'
)}
/>
</span>
- {!connected && (
+ {needsSignIn && (
<span
role="button"
tabIndex={0}
@@ -189,7 +206,7 @@ const ServerEntry = observer(function ServerEntry({ serverId }: { serverId: stri
e.stopPropagation();
navigate('server', { serverId });
}}
- className="shrink-0 rounded px-1.5 py-0.5 text-xs text-foreground-muted hover:bg-background-tertiary-2 hover:text-foreground"
+ className="shrink-0 rounded border border-red-500/40 px-1.5 py-0.5 text-xs font-medium text-red-500 hover:bg-red-500/10"
>
Sign in
</span>
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/local-server-store.ts b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/local-server-store.ts
index 28da153a6..1cc838aa3 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/local-server-store.ts
+++ b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/local-server-store.ts
@@ -5,7 +5,7 @@ import { events, rpc } from '@renderer/lib/ipc';
import type {
DockerAvailability,
LocalServerStatus,
-} from '@shared/core/local-switch-server/local-switch-server';
+} from '@shared/core/managed-switch-server/managed-switch-server';
import {
localServerLogChannel,
localServerStatusChannel,
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/remote-server-store.ts b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/remote-server-store.ts
new file mode 100644
index 000000000..3d0515656
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/remote-server-store.ts
@@ -0,0 +1,189 @@
+import { makeAutoObservable, runInAction } from 'mobx';
+import { agentsStore } from '@renderer/features/locations/stores/agents-store';
+import { getLocationManagerStore } from '@renderer/features/locations/stores/location-selectors';
+import { events, rpc } from '@renderer/lib/ipc';
+import type { DockerAvailability } from '@shared/core/managed-switch-server/managed-switch-server';
+import {
+ type RemoteServerStatus,
+ remoteServerLogChannel,
+ remoteServerStatusChannel,
+} from '@shared/events/remoteSwitchServerEvents';
+import { switchServersStore } from './switch-servers-store';
+
+const MAX_LOG_LINES = 400;
+
+function defaultStatus(sshHost: string): RemoteServerStatus {
+ return { sshHost, phase: 'stopped', serverId: null, version: '', message: null, error: null };
+}
+
+/**
+ * Renderer store for remote-managed servers — one switchdash-run stack per SSH
+ * host. Mirrors the main-process supervisor's per-host status (streamed over
+ * `remoteServerStatusChannel`) and exposes the lifecycle actions keyed by host.
+ * Structurally a per-host version of {@link LocalServerStore}.
+ */
+export class RemoteServerStore {
+ private readonly statuses = new Map<string, RemoteServerStatus>();
+ private readonly logsByHost = new Map<string, string[]>();
+ private readonly dockerByHost = new Map<string, DockerAvailability>();
+ private readonly busyHosts = new Set<string>();
+ error: string | null = null;
+
+ private off: (() => void) | null = null;
+ private offLog: (() => void) | null = null;
+
+ constructor() {
+ makeAutoObservable(this);
+ }
+
+ statusFor(sshHost: string): RemoteServerStatus {
+ return this.statuses.get(sshHost) ?? defaultStatus(sshHost);
+ }
+
+ phaseFor(sshHost: string): RemoteServerStatus['phase'] {
+ return this.statusFor(sshHost).phase;
+ }
+
+ isRunning(sshHost: string): boolean {
+ return this.phaseFor(sshHost) === 'running';
+ }
+
+ isTransitioning(sshHost: string): boolean {
+ const phase = this.phaseFor(sshHost);
+ return this.busyHosts.has(sshHost) || phase === 'starting' || phase === 'stopping';
+ }
+
+ logsFor(sshHost: string): string[] {
+ return this.logsByHost.get(sshHost) ?? [];
+ }
+
+ dockerFor(sshHost: string): DockerAvailability | null {
+ return this.dockerByHost.get(sshHost) ?? null;
+ }
+
+ async init(): Promise<void> {
+ if (!this.off) {
+ this.off = events.on(remoteServerStatusChannel, (status) => {
+ runInAction(() => this.statuses.set(status.sshHost, status));
+ });
+ }
+ if (!this.offLog) {
+ this.offLog = events.on(remoteServerLogChannel, ({ sshHost, line }) => {
+ runInAction(() => {
+ const lines = this.logsByHost.get(sshHost) ?? [];
+ lines.push(line);
+ if (lines.length > MAX_LOG_LINES) lines.splice(0, lines.length - MAX_LOG_LINES);
+ this.logsByHost.set(sshHost, lines);
+ });
+ });
+ }
+ try {
+ const statuses = await rpc.remoteSwitchServer.getStatuses();
+ runInAction(() => {
+ for (const status of statuses) this.statuses.set(status.sshHost, status);
+ });
+ } catch (cause) {
+ this.setError(cause);
+ }
+ }
+
+ dispose(): void {
+ this.off?.();
+ this.off = null;
+ this.offLog?.();
+ this.offLog = null;
+ }
+
+ async checkDocker(sshHost: string): Promise<void> {
+ try {
+ const docker = await rpc.remoteSwitchServer.detectDocker(sshHost);
+ runInAction(() => this.dockerByHost.set(sshHost, docker));
+ } catch (cause) {
+ this.setError(cause);
+ }
+ }
+
+ async start(sshHost: string, name: string): Promise<void> {
+ runInAction(() => {
+ this.busyHosts.add(sshHost);
+ this.error = null;
+ this.logsByHost.set(sshHost, []);
+ });
+ try {
+ const result = await rpc.remoteSwitchServer.start({ sshHost, name });
+ if (result.kind === 'docker-unavailable') {
+ runInAction(() => {
+ this.dockerByHost.set(sshHost, {
+ available: false,
+ reason: result.reason,
+ detail: result.detail,
+ });
+ this.error = result.detail;
+ });
+ } else if (result.kind === 'error') {
+ runInAction(() => {
+ this.error = result.message;
+ });
+ } else {
+ await switchServersStore.init();
+ }
+ } catch (cause) {
+ this.setError(cause);
+ } finally {
+ runInAction(() => this.busyHosts.delete(sshHost));
+ }
+ }
+
+ async stop(sshHost: string): Promise<void> {
+ runInAction(() => {
+ this.busyHosts.add(sshHost);
+ this.error = null;
+ });
+ try {
+ await rpc.remoteSwitchServer.stop(sshHost);
+ } catch (cause) {
+ this.setError(cause);
+ } finally {
+ runInAction(() => this.busyHosts.delete(sshHost));
+ }
+ }
+
+ async reset(sshHost: string, serverId: string): Promise<void> {
+ runInAction(() => {
+ this.busyHosts.add(sshHost);
+ this.error = null;
+ });
+ try {
+ // Remove the server's agents first (their server-side identity is wiped by
+ // the reset), then destroy the stack.
+ await this.removeManagedAgents(serverId);
+ await rpc.remoteSwitchServer.reset(sshHost);
+ await switchServersStore.init();
+ } catch (cause) {
+ this.setError(cause);
+ } finally {
+ runInAction(() => this.busyHosts.delete(sshHost));
+ }
+ }
+
+ private async removeManagedAgents(serverId: string): Promise<void> {
+ await agentsStore.load();
+ const locationIds = new Set<string>();
+ for (const [locationId, agents] of agentsStore.byLocation) {
+ if (agents.some((a) => a.serverId === serverId)) locationIds.add(locationId);
+ }
+ const manager = getLocationManagerStore();
+ for (const locationId of locationIds) {
+ await manager.removeLocation(locationId);
+ }
+ await agentsStore.load();
+ }
+
+ private setError(cause: unknown): void {
+ runInAction(() => {
+ this.error = cause instanceof Error ? cause.message : String(cause);
+ });
+ }
+}
+
+export const remoteServerStore = new RemoteServerStore();
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/view.tsx b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/view.tsx
index 01869a04e..5cc305561 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/view.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/view.tsx
@@ -12,10 +12,29 @@ import { Button } from '@renderer/lib/ui/button';
import { Input } from '@renderer/lib/ui/input';
import { Label } from '@renderer/lib/ui/label';
import { Spinner } from '@renderer/lib/ui/spinner';
+import type { SwitchServer } from '@shared/core/switch-servers/switch-servers';
import { localServerStore } from './local-server-store';
import { LocalServerControls } from './LocalServerControls';
+import { remoteServerStore } from './remote-server-store';
+import { RemoteServerControls } from './RemoteServerControls';
import { switchServersStore } from './switch-servers-store';
+/** Short badge label for where a server lives (see CHOO-1432 terminology). */
+function serverLocationLabel(server: SwitchServer): string | null {
+ if (server.managementKind === 'remote') return server.sshHost ?? 'Remote host';
+ if (server.managed) return 'This computer';
+ return 'External';
+}
+
+/** Whether a managed server's stack is currently running (via the store that
+ * owns its lifecycle). Non-managed servers are always "reachable". */
+function isManagedRunning(server: SwitchServer): boolean {
+ if (server.managementKind === 'remote' && server.sshHost) {
+ return remoteServerStore.isRunning(server.sshHost);
+ }
+ return localServerStore.isRunning;
+}
+
const card = 'rounded-lg border border-border bg-card p-4';
function useServerId(): string {
@@ -45,7 +64,7 @@ const ServerMainPanel = observer(function ServerMainPanel() {
// A managed server that isn't running has no gateway to reach — its
// connection status, sign-in, and web-app links are meaningless until it's up,
// so we neither fetch nor render them (only the Start/Reset controls show).
- const detailsVisible = !server?.managed || localServerStore.isRunning;
+ const detailsVisible = !server?.managed || isManagedRunning(server);
useEffect(() => {
if (!detailsVisible) return;
@@ -72,7 +91,9 @@ const ServerMainPanel = observer(function ServerMainPanel() {
<div className="min-w-0 space-y-1">
<div className="flex items-center gap-2">
<h2 className="text-xl text-foreground">{server.name}</h2>
- {server.managed && <Badge variant="secondary">Local</Badge>}
+ {serverLocationLabel(server) && (
+ <Badge variant="secondary">{serverLocationLabel(server)}</Badge>
+ )}
</div>
<p className="truncate text-sm text-foreground-muted">{server.gatewayUrl}</p>
<p className="truncate text-xs text-foreground-tertiary-passive">
@@ -106,7 +127,16 @@ const ServerMainPanel = observer(function ServerMainPanel() {
</Alert>
)}
- {server.managed && <LocalServerControls />}
+ {server.managed &&
+ (server.managementKind === 'remote' && server.sshHost ? (
+ <RemoteServerControls
+ sshHost={server.sshHost}
+ serverId={server.id}
+ name={server.name}
+ />
+ ) : (
+ <LocalServerControls />
+ ))}
{detailsVisible && (
<>
diff --git a/dash/apps/switchdash-desktop/src/shared/app-identity.ts b/dash/apps/switchdash-desktop/src/shared/app-identity.ts
index 13f2c5453..f0e322810 100644
--- a/dash/apps/switchdash-desktop/src/shared/app-identity.ts
+++ b/dash/apps/switchdash-desktop/src/shared/app-identity.ts
@@ -25,6 +25,6 @@ export const RELEASE_REPO_NAME = 'switch';
// The switch-core release this app build is compatible with. Local-server mode
// pulls this version's images and bundles this version's standalone compose
// artifact. Bump it in lockstep with the bundled compose
-// (src/main/core/local-switch-server/resources/standalone-docker-compose.pinned.yml)
+// (src/main/core/managed-switch-server/resources/standalone-docker-compose.pinned.yml)
// so a switchdash release pins a known-good switch-core stack.
export const COMPATIBLE_SWITCH_VERSION = '0.3.0';
diff --git a/dash/apps/switchdash-desktop/src/shared/core/local-switch-server/local-switch-server.ts b/dash/apps/switchdash-desktop/src/shared/core/managed-switch-server/managed-switch-server.ts
similarity index 100%
rename from dash/apps/switchdash-desktop/src/shared/core/local-switch-server/local-switch-server.ts
rename to dash/apps/switchdash-desktop/src/shared/core/managed-switch-server/managed-switch-server.ts
diff --git a/dash/apps/switchdash-desktop/src/shared/core/switch-servers/switch-servers.ts b/dash/apps/switchdash-desktop/src/shared/core/switch-servers/switch-servers.ts
index 14b01ce50..14447e1eb 100644
--- a/dash/apps/switchdash-desktop/src/shared/core/switch-servers/switch-servers.ts
+++ b/dash/apps/switchdash-desktop/src/shared/core/switch-servers/switch-servers.ts
@@ -20,9 +20,16 @@ export type SwitchServer = {
* `https://switch-api.example.com` — what an agent's `SWITCH_API_ENDPOINT`
* points at, and what an onboarded agent is matched to its server by. */
apiUrl: string;
- /** True when switchdash runs this server itself (local-server mode). Managed
+ /** True when switchdash runs this server itself (docker compose). Managed
* servers are driven by the lifecycle controls, not the add/edit-server UI. */
managed: boolean;
+ /** Where a managed server runs: `local` (this computer's Docker) or `remote`
+ * (a host's Docker over SSH). Null for external (non-managed) servers. Legacy
+ * managed rows with no kind are read as `local`. */
+ managementKind: 'local' | 'remote' | null;
+ /** SSH alias of the host a remote-managed server runs on. Null for local and
+ * external servers. */
+ sshHost: string | null;
createdAt: string;
updatedAt: string;
};
@@ -33,6 +40,10 @@ export type AddServerParams = {
apiUrl: string;
};
+/** Identifies which managed server to upsert/look up: the single local stack,
+ * or the remote stack on a given SSH host. */
+export type ManagedServerRef = { kind: 'local' } | { kind: 'remote'; sshHost: string };
+
export type UpdateServerParams = {
id: string;
name: string;
diff --git a/dash/apps/switchdash-desktop/src/shared/events/localSwitchServerEvents.ts b/dash/apps/switchdash-desktop/src/shared/events/localSwitchServerEvents.ts
index a152aeacd..01c86b20c 100644
--- a/dash/apps/switchdash-desktop/src/shared/events/localSwitchServerEvents.ts
+++ b/dash/apps/switchdash-desktop/src/shared/events/localSwitchServerEvents.ts
@@ -1,4 +1,4 @@
-import type { LocalServerStatus } from '@shared/core/local-switch-server/local-switch-server';
+import type { LocalServerStatus } from '@shared/core/managed-switch-server/managed-switch-server';
import { defineEvent } from '@shared/lib/ipc/events';
export const localServerStatusChannel = defineEvent<LocalServerStatus>(
diff --git a/dash/apps/switchdash-desktop/src/shared/events/remoteSwitchServerEvents.ts b/dash/apps/switchdash-desktop/src/shared/events/remoteSwitchServerEvents.ts
new file mode 100644
index 000000000..cda92be77
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/shared/events/remoteSwitchServerEvents.ts
@@ -0,0 +1,16 @@
+import type { LocalServerStatus } from '@shared/core/managed-switch-server/managed-switch-server';
+import { defineEvent } from '@shared/lib/ipc/events';
+
+/** Status of a remote-managed stack, tagged with the SSH host it runs on (the
+ * renderer keeps one entry per host). Reuses the local status shape. */
+export type RemoteServerStatus = LocalServerStatus & { sshHost: string };
+
+export const remoteServerStatusChannel = defineEvent<RemoteServerStatus>(
+ 'remote-switch-server:status'
+);
+
+/** A line of `docker compose` output during a remote start, tagged with its
+ * host so the UI routes it to the right log tail. */
+export const remoteServerLogChannel = defineEvent<{ sshHost: string; line: string }>(
+ 'remote-switch-server:log'
+);
diff --git a/dash/pnpm-lock.yaml b/dash/pnpm-lock.yaml
index fd7bb6126..a3ebf1bb6 100644
--- a/dash/pnpm-lock.yaml
+++ b/dash/pnpm-lock.yaml
@@ -94,7 +94,7 @@ importers:
'@tailwindcss/vite':
specifier: ^4.2.1
'@tanstack/react-form':
specifier: ^1.28.4
@@ -136,16 +136,16 @@ importers:
version: 1.15.5
'@vitejs/plugin-react':
specifier: ^4.7.0
'@vitest/browser':
specifier: ^4.1.0
'@vitest/browser-playwright':
specifier: ^4.1.0
'@vitest/browser-preview':
specifier: ^4.1.0
'@xterm/addon-web-links':
specifier: ^0.12.0
version: 0.12.0
@@ -177,8 +177,8 @@ importers:
specifier: ^17.4.2
version: 17.4.2
drizzle-kit:
- specifier: ^0.24.2
- version: 0.24.2
+ specifier: ^0.31.10
+ version: 0.31.10
electron:
specifier: 40.8.5
version: 40.8.5
@@ -187,7 +187,7 @@ importers:
version: 26.15.2([email protected])
electron-vite:
specifier: ^5.0.0
framer-motion:
specifier: ^12.33.0
@@ -280,10 +280,10 @@ importers:
version: 6.0.3
vite:
specifier: ^6.4.1
vitest:
specifier: ^4.1.0
vitest-browser-react:
specifier: ^2.1.0
@@ -317,10 +317,10 @@ importers:
version: 7.0.0-dev.20260609.1
tsdown:
specifier: ^0.22.2
- version: 0.22.2(@typescript/[email protected])([email protected])
vitest:
specifier: ^4.1.0
packages/plugins:
dependencies:
@@ -345,10 +345,10 @@ importers:
version: 1.69.0([email protected])
tsdown:
specifier: ^0.22.2
- version: 0.22.2(@typescript/[email protected])([email protected])
vitest:
specifier: ^3.1.4
packages/shared:
devDependencies:
@@ -360,10 +360,10 @@ importers:
version: 7.0.0-dev.20260609.1
tsdown:
specifier: ^0.22.2
- version: 0.22.2(@typescript/[email protected])([email protected])
vitest:
specifier: ^4.1.0
packages:
@@ -657,14 +657,14 @@ packages:
resolution: {integrity: sha512-FxEMIkJKnodyA1OaCUoEvbYRkoZlLZ4d/eXFu9Fh8CbBBgP5EmZxrfTRyN0qpXZ4vOvqnE5YdRdcrmUUXuU+dA==}
deprecated: 'Merged into tsx: https://tsx.hirok.io'
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==}
+ engines: {node: '>=18'}
cpu: [ppc64]
os: [aix]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-Svl7tq8k/08+p6CXPpRjQ1fKX+1odH/BQbb48fV6fj3CWHhsoIOoY87w1oHXm0qEpkIK3ZfVgp0hed3XBXzXMQ==}
engines: {node: '>=18'}
cpu: [ppc64]
os: [aix]
@@ -675,14 +675,14 @@ packages:
cpu: [arm64]
os: [android]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==}
+ engines: {node: '>=18'}
cpu: [arm64]
os: [android]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-34EGEbCIAgosYz6goLcopX6Mo7NyGv9tfwEM2/7Ce2VcVRk568iSvniGWcUXIy7wEDR1wzolcxcriFVrWYcwBg==}
engines: {node: '>=18'}
cpu: [arm64]
os: [android]
@@ -693,14 +693,14 @@ packages:
cpu: [arm]
os: [android]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==}
+ engines: {node: '>=18'}
cpu: [arm]
os: [android]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-0k2F129Xdio1TdJfzJ8sy1Q47vUD2NnwdhiAf7drUN1EBTfPf4hsFCtmMgu/6m8JSzsBrlmVjudMBQqOfG8usQ==}
engines: {node: '>=18'}
cpu: [arm]
os: [android]
@@ -711,14 +711,14 @@ packages:
cpu: [x64]
os: [android]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==}
+ engines: {node: '>=18'}
cpu: [x64]
os: [android]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-dbwY7ltSMDWsRatcRpCnES4F+im88OCUgGZjy52shC7GqHRE/cYlxNbB4Z4UpJswpcc4Qxd2oE/ufM0p61IKng==}
engines: {node: '>=18'}
cpu: [x64]
os: [android]
@@ -729,14 +729,14 @@ packages:
cpu: [arm64]
os: [darwin]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==}
+ engines: {node: '>=18'}
cpu: [arm64]
os: [darwin]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-TZbWkQY7kvTAXbXUT7uVACR5cMHsDiSz9z7ZKAX/RTq/WJEk3QyRr0wZpNhBDX+/0CtdqUIJlOiodQcta6tY3Q==}
engines: {node: '>=18'}
cpu: [arm64]
os: [darwin]
@@ -747,14 +747,14 @@ packages:
cpu: [x64]
os: [darwin]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==}
+ engines: {node: '>=18'}
cpu: [x64]
os: [darwin]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-zfdzgK9ACBNZLI/CyHTOx81SyNbM6YXn7rxSgX97VjyiPl9W1i4Ka4fgKECEoFCKGpvBj5qArWIGgQjOwkgskQ==}
engines: {node: '>=18'}
cpu: [x64]
os: [darwin]
@@ -765,14 +765,14 @@ packages:
cpu: [arm64]
os: [freebsd]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==}
+ engines: {node: '>=18'}
cpu: [arm64]
os: [freebsd]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-wG2EA8ENdEI0qhkSZMjfqrdY+ziCYCPMmtZjjIwOmXFjmyzEHn+UUxk5of+SYsjtfs3VpnlC7QLzSI5hY/rOAw==}
engines: {node: '>=18'}
cpu: [arm64]
os: [freebsd]
@@ -783,14 +783,14 @@ packages:
cpu: [x64]
os: [freebsd]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==}
+ engines: {node: '>=18'}
cpu: [x64]
os: [freebsd]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-i7dZ9vQgnvSCzi/rYCXNgtF/U+eKZNJBzu3eTQbRgHnM7tNSizLOkRFAl3qzVc/Op/u5YkHHa4pf/3DOYHthLQ==}
engines: {node: '>=18'}
cpu: [x64]
os: [freebsd]
@@ -801,14 +801,14 @@ packages:
cpu: [arm64]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==}
+ engines: {node: '>=18'}
cpu: [arm64]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-yHs+0uc8+nvEAfAfxrWQKK5peSNzBc4PegcMO0EJ2hT71uA7vB8Ihg2e77R2P7SG5uYjPbHlLLmve4LLLRCf0g==}
engines: {node: '>=18'}
cpu: [arm64]
os: [linux]
@@ -819,14 +819,14 @@ packages:
cpu: [arm]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==}
+ engines: {node: '>=18'}
cpu: [arm]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-qVXBOHQS+d5Y722GwJzJUtOLlX7km3CraOaGormF1pDtPd2C/l1SHRPgjLunLGe51Sh5YYWKMFDyV4SxgMQYTQ==}
engines: {node: '>=18'}
cpu: [arm]
os: [linux]
@@ -837,14 +837,14 @@ packages:
cpu: [ia32]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==}
+ engines: {node: '>=18'}
cpu: [ia32]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-d1z4ZuP0ajrfz/FhGT4vv278rX8KnPPJx8i5+AtK7TYbx9Le9F1hyzurZpkEyjkGa9dUGhQow4C1NmeGvqxN2w==}
engines: {node: '>=18'}
cpu: [ia32]
os: [linux]
@@ -855,14 +855,14 @@ packages:
cpu: [loong64]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==}
+ engines: {node: '>=18'}
cpu: [loong64]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-M5sRjUVZrkm1OAPR3dlOYzNmN+loZKGVi1VUQGrwuqLcbR6qeAz+famMhjASeH3YVKvZz+zT1jlh/keC3Rj/lg==}
engines: {node: '>=18'}
cpu: [loong64]
os: [linux]
@@ -873,14 +873,14 @@ packages:
cpu: [mips64el]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==}
+ engines: {node: '>=18'}
cpu: [mips64el]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-mRObBZeHh2OxcBFPWE/FjylkRgZdYuiTR3vaTozquCGOH14iP9oN4x4Ge81CoIDYQrXmIxpFumJBu5MtZpnQJQ==}
engines: {node: '>=18'}
cpu: [mips64el]
os: [linux]
@@ -891,14 +891,14 @@ packages:
cpu: [ppc64]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==}
+ engines: {node: '>=18'}
cpu: [ppc64]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-slScBsMAb3GFDcdrCgLwZtPYRoH2H/youv10QiZyRjmsP48fznoveWytSgCI/R0ZcUgpc0ZhIUEx6LHts8yrfQ==}
engines: {node: '>=18'}
cpu: [ppc64]
os: [linux]
@@ -909,14 +909,14 @@ packages:
cpu: [riscv64]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==}
+ engines: {node: '>=18'}
cpu: [riscv64]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-kw0owk1o0GFETUJyW0jc0G4Yzs0BHZn0JDZ8JRT088vjJYX777BAs1fDGxAC+q831qOs2DTC96mNsG2opdfyyQ==}
engines: {node: '>=18'}
cpu: [riscv64]
os: [linux]
@@ -927,14 +927,14 @@ packages:
cpu: [s390x]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==}
+ engines: {node: '>=18'}
cpu: [s390x]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-/lAIjX8aYFRByhh6L5rYtPEDRqa9de/4V/juOXcta5frjvzXO4/sqEtyytse0g3zZFuWu5cDN0MkLz2qRDD2Ag==}
engines: {node: '>=18'}
cpu: [s390x]
os: [linux]
@@ -945,14 +945,14 @@ packages:
cpu: [x64]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==}
+ engines: {node: '>=18'}
cpu: [x64]
os: [linux]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-u/anNYF2mmVOEDwLtnQ1wOr3EZ9sTNGLWrsYGYwHWzGA3Si84IOkHXlbWTD1NB+9/1lcnweYKO54uhxZydNzfA==}
engines: {node: '>=18'}
cpu: [x64]
os: [linux]
@@ -963,20 +963,26 @@ packages:
cpu: [arm64]
os: [netbsd]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-oks0DYbLwWMmaakTsCb+zL4E+aHRVLom9IJZOAthMQEPiQmydXHkziYEsGYRx0uNV/IjEKGAV941JzH02pflqw==}
+ engines: {node: '>=18'}
+ cpu: [arm64]
+ os: [netbsd]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==}
engines: {node: '>=12'}
cpu: [x64]
os: [netbsd]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==}
+ engines: {node: '>=18'}
cpu: [x64]
os: [netbsd]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-aeL6lAnN89Hz43Mlh1G8ARasbuoYvSITDEx0tHh5b7jJnHcssqgjy9Yx430GDpmCa6OyrKoS0aNRjKundRizGg==}
engines: {node: '>=18'}
cpu: [x64]
os: [netbsd]
@@ -987,20 +993,26 @@ packages:
cpu: [arm64]
os: [openbsd]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-MEFJe5C3R8pwXdZ5Y21oo6m7ePiS0d9pWucn99O/wvyJZChoIQKrQDxKrGeW8F5+T0okTHesAmDeiHDTIq0V/Q==}
+ engines: {node: '>=18'}
+ cpu: [arm64]
+ os: [openbsd]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==}
engines: {node: '>=12'}
cpu: [x64]
os: [openbsd]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==}
+ engines: {node: '>=18'}
cpu: [x64]
os: [openbsd]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-i/ZLIOafE0Z8cI/XANJAixoJL/uRAoS2xOA3rb0xN+KK0K177cMAsQYkzHtBrtMXAKuAc7HGgcWiZ/sRC1Nxgw==}
engines: {node: '>=18'}
cpu: [x64]
os: [openbsd]
@@ -1011,20 +1023,26 @@ packages:
cpu: [arm64]
os: [openharmony]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==}
+ engines: {node: '>=18'}
+ cpu: [arm64]
+ os: [openharmony]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [sunos]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==}
+ engines: {node: '>=18'}
cpu: [x64]
os: [sunos]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-BEjgtECkL3vY+SaSQ6nzVfiALUeFxpawyp8Jmf5PtYhf1Ug40N1h/hxlhts+f1FvSvarEigdxS3BlSMI2PJLcQ==}
engines: {node: '>=18'}
cpu: [x64]
os: [sunos]
@@ -1035,14 +1053,14 @@ packages:
cpu: [arm64]
os: [win32]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==}
+ engines: {node: '>=18'}
cpu: [arm64]
os: [win32]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-lCv9eK/H6ZJWbE7bh2nw54CZ9M2nupBxJcTsdk/QQnWkdSjKGuxmmH8/GWrlT1eMmZfn4dGcCjRte397WqfQXA==}
engines: {node: '>=18'}
cpu: [arm64]
os: [win32]
@@ -1053,14 +1071,14 @@ packages:
cpu: [ia32]
os: [win32]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==}
+ engines: {node: '>=18'}
cpu: [ia32]
os: [win32]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-zvb/mB2bSCoJOpoCBgYKKpX6YM6mJBlBUVUtVj41DlZJVEB6/0CKlRYxP5wWl1C1ILiCoAU5wZZ4q1P3qeS6Eg==}
engines: {node: '>=18'}
cpu: [ia32]
os: [win32]
@@ -1071,14 +1089,14 @@ packages:
cpu: [x64]
os: [win32]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==}
- engines: {node: '>=12'}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==}
+ engines: {node: '>=18'}
cpu: [x64]
os: [win32]
- '@esbuild/[email protected]':
- resolution: {integrity: sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==}
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-bm4Mowrv+GXMlpWX++EcXw/iLyd1o3+bJkC2DkWXYVvgZCqD/bSj9ctZeAMC3cIxgjRVR2Dufaiu4YPxr5gW1A==}
engines: {node: '>=18'}
cpu: [x64]
os: [win32]
@@ -3126,8 +3144,8 @@ packages:
resolution: {integrity: sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==}
engines: {node: '>=12'}
- resolution: {integrity: sha512-nXOaTSFiuIaTMhS8WJC2d4EBeIcN9OSt2A2cyFbQYBAZbi7lRsVGJNqDpEwPqYfJz38yxbY/UtbvBBahBfnExQ==}
+ resolution: {integrity: sha512-7OZcmQUrdGI+DUNNsKBn1aW8qSoKuTH7d0mYgSP8bAzdFzKoovxEFnoGQp2dVs82EOJeYycqRtciopszwUf8bw==}
hasBin: true
@@ -3341,26 +3359,21 @@ packages:
resolution: {integrity: sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==}
- resolution: {integrity: sha512-H2/S7Pm8a9CL1uhp9OvjwrBh5Pvx0H8qVOxNu8Wed9Y7qv56MPtq+GGM8RJpq6glYJn9Wspr8uw7l55uyinNeg==}
- peerDependencies:
- esbuild: '>=0.12 <1'
-
resolution: {integrity: sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==}
engines: {node: '>=12'}
hasBin: true
- resolution: {integrity: sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==}
- engines: {node: '>=12'}
- hasBin: true
-
resolution: {integrity: sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==}
engines: {node: '>=18'}
hasBin: true
+ resolution: {integrity: sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==}
+ engines: {node: '>=18'}
+ hasBin: true
+
resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==}
engines: {node: '>=6'}
@@ -5020,6 +5033,11 @@ packages:
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
+ resolution: {integrity: sha512-GQHnkIfxyx1wYCOS/wonik5MVRZU9hi1TEZmzGZSCJB1y9YgoZ8H6itNE/u4suE+yLmOzuE4E5S4TZ/ZX2wcWQ==}
+ engines: {node: '>=18.0.0'}
+ hasBin: true
+
resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==}
@@ -5768,219 +5786,228 @@ snapshots:
'@esbuild-kit/core-utils': 3.3.2
get-tsconfig: 4.14.0
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
- '@esbuild/[email protected]':
+ '@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
optionalDependencies:
'@noble/hashes': 2.2.0
@@ -6633,12 +6660,12 @@ snapshots:
'@tailwindcss/oxide-win32-arm64-msvc': 4.3.0
'@tailwindcss/oxide-win32-x64-msvc': 4.3.0
dependencies:
'@tailwindcss/node': 4.3.0
'@tailwindcss/oxide': 4.3.0
tailwindcss: 4.3.0
'@tanstack/[email protected]': {}
@@ -7017,7 +7044,7 @@ snapshots:
d3-selection: 3.0.0
d3-transition: 3.0.1([email protected])
dependencies:
'@babel/core': 7.29.7
'@babel/plugin-transform-react-jsx-self': 7.29.7(@babel/[email protected])
@@ -7025,45 +7052,45 @@ snapshots:
'@rolldown/pluginutils': 1.0.0-beta.27
'@types/babel__core': 7.20.5
react-refresh: 0.17.0
transitivePeerDependencies:
- supports-color
dependencies:
playwright: 1.60.0
tinyrainbow: 3.1.0
transitivePeerDependencies:
- bufferutil
- msw
- utf-8-validate
- vite
dependencies:
'@testing-library/dom': 10.4.1
'@testing-library/user-event': 14.6.1(@testing-library/[email protected])
transitivePeerDependencies:
- bufferutil
- msw
- utf-8-validate
- vite
dependencies:
'@blazediff/core': 1.9.1
'@vitest/utils': 4.1.8
magic-string: 0.30.21
pngjs: 7.0.0
sirv: 3.0.2
tinyrainbow: 3.1.0
ws: 8.21.0
transitivePeerDependencies:
- bufferutil
@@ -7088,21 +7115,21 @@ snapshots:
chai: 6.2.2
tinyrainbow: 3.1.0
dependencies:
'@vitest/spy': 3.2.6
estree-walker: 3.0.3
magic-string: 0.30.21
optionalDependencies:
dependencies:
'@vitest/spy': 4.1.8
estree-walker: 3.0.3
magic-string: 0.30.21
optionalDependencies:
'@vitest/[email protected]':
dependencies:
@@ -7847,14 +7874,12 @@ snapshots:
dependencies:
'@drizzle-team/brocli': 0.10.2
'@esbuild-kit/esm-loader': 2.6.5
- esbuild: 0.19.12
- esbuild-register: 3.6.0([email protected])
- transitivePeerDependencies:
- - supports-color
+ esbuild: 0.25.12
+ tsx: 4.23.1
optionalDependencies:
@@ -7933,7 +7958,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@babel/core': 7.29.7
'@babel/plugin-transform-arrow-functions': 7.29.7(@babel/[email protected])
@@ -7941,7 +7966,7 @@ snapshots:
esbuild: 0.25.12
magic-string: 0.30.21
picocolors: 1.1.1
transitivePeerDependencies:
- supports-color
@@ -8010,13 +8035,6 @@ snapshots:
optional: true
- dependencies:
- debug: 4.4.3
- esbuild: 0.19.12
- transitivePeerDependencies:
- - supports-color
-
optionalDependencies:
'@esbuild/android-arm': 0.18.20
@@ -8042,32 +8060,6 @@ snapshots:
'@esbuild/win32-ia32': 0.18.20
'@esbuild/win32-x64': 0.18.20
- optionalDependencies:
- '@esbuild/aix-ppc64': 0.19.12
- '@esbuild/android-arm': 0.19.12
- '@esbuild/android-arm64': 0.19.12
- '@esbuild/android-x64': 0.19.12
- '@esbuild/darwin-arm64': 0.19.12
- '@esbuild/darwin-x64': 0.19.12
- '@esbuild/freebsd-arm64': 0.19.12
- '@esbuild/freebsd-x64': 0.19.12
- '@esbuild/linux-arm': 0.19.12
- '@esbuild/linux-arm64': 0.19.12
- '@esbuild/linux-ia32': 0.19.12
- '@esbuild/linux-loong64': 0.19.12
- '@esbuild/linux-mips64el': 0.19.12
- '@esbuild/linux-ppc64': 0.19.12
- '@esbuild/linux-riscv64': 0.19.12
- '@esbuild/linux-s390x': 0.19.12
- '@esbuild/linux-x64': 0.19.12
- '@esbuild/netbsd-x64': 0.19.12
- '@esbuild/openbsd-x64': 0.19.12
- '@esbuild/sunos-x64': 0.19.12
- '@esbuild/win32-arm64': 0.19.12
- '@esbuild/win32-ia32': 0.19.12
- '@esbuild/win32-x64': 0.19.12
-
optionalDependencies:
'@esbuild/aix-ppc64': 0.25.12
@@ -8097,6 +8089,35 @@ snapshots:
'@esbuild/win32-ia32': 0.25.12
'@esbuild/win32-x64': 0.25.12
+ optionalDependencies:
+ '@esbuild/aix-ppc64': 0.28.1
+ '@esbuild/android-arm': 0.28.1
+ '@esbuild/android-arm64': 0.28.1
+ '@esbuild/android-x64': 0.28.1
+ '@esbuild/darwin-arm64': 0.28.1
+ '@esbuild/darwin-x64': 0.28.1
+ '@esbuild/freebsd-arm64': 0.28.1
+ '@esbuild/freebsd-x64': 0.28.1
+ '@esbuild/linux-arm': 0.28.1
+ '@esbuild/linux-arm64': 0.28.1
+ '@esbuild/linux-ia32': 0.28.1
+ '@esbuild/linux-loong64': 0.28.1
+ '@esbuild/linux-mips64el': 0.28.1
+ '@esbuild/linux-ppc64': 0.28.1
+ '@esbuild/linux-riscv64': 0.28.1
+ '@esbuild/linux-s390x': 0.28.1
+ '@esbuild/linux-x64': 0.28.1
+ '@esbuild/netbsd-arm64': 0.28.1
+ '@esbuild/netbsd-x64': 0.28.1
+ '@esbuild/openbsd-arm64': 0.28.1
+ '@esbuild/openbsd-x64': 0.28.1
+ '@esbuild/openharmony-arm64': 0.28.1
+ '@esbuild/sunos-x64': 0.28.1
+ '@esbuild/win32-arm64': 0.28.1
+ '@esbuild/win32-ia32': 0.28.1
+ '@esbuild/win32-x64': 0.28.1
+
@@ -8184,7 +8205,6 @@ snapshots:
graceful-fs: 4.2.11
jsonfile: 6.2.1
universalify: 2.0.1
- optional: true
dependencies:
@@ -10066,7 +10086,7 @@ snapshots:
dependencies:
ansis: 4.3.1
cac: 7.0.0
@@ -10084,6 +10104,7 @@ snapshots:
tree-kill: 1.2.2
unconfig-core: 7.5.0
optionalDependencies:
+ tsx: 4.23.1
typescript: 6.0.3
transitivePeerDependencies:
- '@ts-macro/tsc'
@@ -10093,6 +10114,12 @@ snapshots:
+ dependencies:
+ esbuild: 0.28.1
+ optionalDependencies:
+ fsevents: 2.3.3
+
dependencies:
safe-buffer: 5.2.1
@@ -10229,13 +10256,13 @@ snapshots:
'@types/unist': 3.0.3
vfile-message: 4.0.3
dependencies:
cac: 6.7.14
debug: 4.4.3
es-module-lexer: 1.7.0
pathe: 2.0.3
transitivePeerDependencies:
- '@types/node'
- jiti
@@ -10250,7 +10277,7 @@ snapshots:
- tsx
- yaml
dependencies:
esbuild: 0.25.12
fdir: 6.5.0([email protected])
@@ -10263,9 +10290,10 @@ snapshots:
fsevents: 2.3.3
jiti: 2.7.0
lightningcss: 1.32.0
+ tsx: 4.23.1
yaml: 2.9.0
dependencies:
esbuild: 0.25.12
fdir: 6.5.0([email protected])
@@ -10278,22 +10306,23 @@ snapshots:
fsevents: 2.3.3
jiti: 2.7.0
lightningcss: 1.32.0
+ tsx: 4.23.1
yaml: 2.9.0
dependencies:
react: 19.2.7
react-dom: 19.2.7([email protected])
optionalDependencies:
'@types/react': 19.2.17
'@types/react-dom': 19.2.3(@types/[email protected])
dependencies:
'@types/chai': 5.2.3
'@vitest/expect': 3.2.6
'@vitest/pretty-format': 3.2.6
'@vitest/runner': 3.2.6
'@vitest/snapshot': 3.2.6
@@ -10311,8 +10340,8 @@ snapshots:
tinyglobby: 0.2.17
tinypool: 1.1.1
tinyrainbow: 2.0.0
why-is-node-running: 2.3.0
optionalDependencies:
'@types/debug': 4.1.13
@@ -10332,10 +10361,10 @@ snapshots:
- tsx
- yaml
dependencies:
'@vitest/expect': 4.1.8
'@vitest/pretty-format': 4.1.8
'@vitest/runner': 4.1.8
'@vitest/snapshot': 4.1.8
@@ -10352,12 +10381,12 @@ snapshots:
tinyexec: 1.2.4
tinyglobby: 0.2.17
tinyrainbow: 3.1.0
why-is-node-running: 2.3.0
optionalDependencies:
'@types/node': 20.19.42
jsdom: 29.1.1(@noble/[email protected])
transitivePeerDependencies:
- msw