Files
zn-ai/electron/gateway/launch-strategy.ts
DEV_DSW 71bcc3b3c5 feat: implement telemetry system for application usage tracking
- Added telemetry utility to capture application events and metrics.
- Integrated PostHog for event tracking with distinct user identification.
- Implemented telemetry initialization, event capturing, and shutdown procedures.

feat: add UV environment setup for Python management

- Created utilities to manage Python installation and configuration.
- Implemented network optimization checks for Python installation mirrors.
- Added functions to set up managed Python environments with error handling.

feat: enhance host API communication with token management

- Introduced host API token retrieval and management for secure requests.
- Updated host API fetch functions to include token in headers.
- Added support for creating event sources with authentication.

test: add comprehensive tests for gateway protocol and startup helpers

- Implemented unit tests for gateway protocol helpers, event dispatching, and state management.
- Added tests for startup recovery strategies and process policies.
- Ensured coverage for connection monitoring and restart governance logic.
2026-04-23 17:21:57 +08:00

37 lines
881 B
TypeScript

export type GatewayLaunchStrategy = 'utility-process' | 'node-runtime';
function normalizeForcedStrategy(
forced: string | undefined,
): GatewayLaunchStrategy | null {
const normalized = forced?.trim().toLowerCase();
switch (normalized) {
case 'utility':
case 'utility-process':
return 'utility-process';
case 'node-runtime':
case 'node':
case 'cli':
case 'electron-run-as-node':
return 'node-runtime';
default:
return null;
}
}
export function resolveGatewayLaunchStrategy(options: {
platform: NodeJS.Platform;
mode: 'dev' | 'packaged';
forced?: string | undefined;
}): GatewayLaunchStrategy {
const forced = normalizeForcedStrategy(options.forced);
if (forced) {
return forced;
}
if (options.platform === 'win32' && options.mode === 'dev') {
return 'node-runtime';
}
return 'utility-process';
}