feat(launcher): implement gated standard launch

Build the selected copy for its port, wait for the local server, and manage the game and server lifecycles. Keep standard launch disabled pending isolation verification.

Verified both type checks, the launcher build, and the launch lifecycle against a temporary copy and a stand-in executable.
This commit is contained in:
N0VAN0M4LY committed 2026-11-30 09:40:58 +08:00
1 parent 2a97b0d46c
commit c1dea23955
19 files changed
+522 -105

No files matched your search

+4 -1
View File
@@ -1,10 +1,13 @@
import { z } from 'zod';
import { APP_ERROR_CODES } from '../errors.ts';
// Enable only after isolation has been verified and the maintainer approves the change.
export const ORDINARY_LAUNCH_ENABLED = false;
export const LaunchStateSchema = z.object({
phase: z.enum([
'ready', 'checking', 'building', 'starting-server', 'starting-game', 'running',
'stopping', 'port-busy', 'version-changed', 'server-exited', 'failed',
'server-running', 'stopping', 'port-busy', 'version-changed', 'server-exited', 'failed',
]),
copyId: z.uuid().optional(),
port: z.number().int().min(1).max(65535).optional(),
@@ -1,11 +1,16 @@
import { z } from 'zod';
import { LANGUAGE_CHOICES } from '../languages.ts';
import { parseLaunchArguments } from '../launch-arguments.ts';
import { BACKGROUND_RANDOM, BackgroundChoiceSchema } from './background.ts';
const LanguageChoiceSchema = z.enum(LANGUAGE_CHOICES);
const WindowCloseSchema = z.enum(['quit', 'tray']);
const AfterGameStartsSchema = z.enum(['minimize', 'keep']);
const LabPathSchema = z.string().min(1).nullable();
const PortModeSchema = z.enum(['auto', 'fixed']);
const PortSchema = z.number().int().min(1).max(65535);
export const LAUNCH_ARGUMENTS_LIMIT = 4000;
const LaunchArgumentsSchema = z.string().max(LAUNCH_ARGUMENTS_LIMIT).refine((value) => parseLaunchArguments(value) !== null);
/** The launcher's own settings (not the game's, not the local service's tuning). */
export const SettingsSchema = z.object({
@@ -19,6 +24,10 @@ export const SettingsSchema = z.object({
windowClose: WindowCloseSchema.default('quit'),
afterGameStarts: AfterGameStartsSchema.default('minimize'),
autoSaveBackups: z.boolean().default(true),
launchPortMode: PortModeSchema.default('auto'),
launchPort: PortSchema.default(27015),
closeServerOnGameExit: z.boolean().default(true),
launchArguments: LaunchArgumentsSchema.default(''),
developerMode: z.boolean().default(true),
labStockPath: LabPathSchema.default(null),
labDataPath: LabPathSchema.default(null),
@@ -35,6 +44,10 @@ export const SettingsPatchSchema = z.object({
windowClose: WindowCloseSchema.optional(),
afterGameStarts: AfterGameStartsSchema.optional(),
autoSaveBackups: z.boolean().optional(),
launchPortMode: PortModeSchema.optional(),
launchPort: PortSchema.optional(),
closeServerOnGameExit: z.boolean().optional(),
launchArguments: LaunchArgumentsSchema.optional(),
developerMode: z.boolean().optional(),
labStockPath: LabPathSchema.optional(),
labDataPath: LabPathSchema.optional(),