* chore(release): stop publishing legacy Windows update packages * feat(agents): support OpenCode Desktop across platforms Detect CLI and desktop installations on Windows, macOS, and Linux, and add separate launch and restart controls. Closes #156 * fix(codex): align model display names and show total session count - preserve runtime model identity in generated catalogs - count distinct sessions across database and rollout sources - update session count labels in all supported languages * fix(codex): keep config and auth files in sync - generate auth.json for API key configuration - preserve and validate OAuth credentials - include auth.json in transactional updates and rollback - retain compatibility with legacy Codex configuration states * fix(cpa-gui): update version to 0.2.59 in Cargo files * fix(codex): preserve OAuth mode after closing configuration * feat(config): add TLS management and protocol-aware local URLs - add TLS controls to advanced settings - persist certificate and private key paths - restart the core after TLS changes - switch WebUI, API and management URLs between HTTP and HTTPS - synchronize agent configurations and detection with the active protocol * refactor(config): reorganize network, routing, and TLS settings - split network settings and session routing into separate tabs - move TLS configuration into network settings - preserve TLS restart and HTTPS URL synchronization behavior * feat(config): add independent network settings and custom listen IP * fix(navigation): allow access to usage records while core is stopped * refactor(home): show a single API URL based on the configured listen IP * feat(config): add file pickers for TLS certificate and private key
63 lines
1.7 KiB
TypeScript
63 lines
1.7 KiB
TypeScript
import { getCurrentLocale, translate } from '../i18n';
|
|
|
|
export type ClientApiProfile = {
|
|
id: 'openai' | 'claude' | 'gemini';
|
|
name: string;
|
|
description: string;
|
|
baseUrl: string;
|
|
};
|
|
|
|
const safeLocalPort = (port: number) =>
|
|
Number.isInteger(port) && port >= 1 && port <= 65535 ? port : 8317;
|
|
|
|
const normalizedConnectHost = (listenHost: string) => {
|
|
const host = listenHost.trim().replace(/^\[|\]$/g, '');
|
|
if (!host || host === '0.0.0.0') return '127.0.0.1';
|
|
if (host === '::') return '::1';
|
|
return host;
|
|
};
|
|
|
|
const urlHost = (host: string) => host.includes(':') ? `[${host}]` : host;
|
|
|
|
export function webUiManagementUrl(
|
|
port: number,
|
|
tlsEnabled = false,
|
|
listenHost = '127.0.0.1',
|
|
): string {
|
|
const scheme = tlsEnabled ? 'https' : 'http';
|
|
const host = urlHost(normalizedConnectHost(listenHost));
|
|
return `${scheme}://${host}:${safeLocalPort(port)}/management.html#/login`;
|
|
}
|
|
|
|
export function clientApiProfiles(
|
|
port: number,
|
|
tlsEnabled = false,
|
|
listenHost = '127.0.0.1',
|
|
): ClientApiProfile[] {
|
|
const safePort = safeLocalPort(port);
|
|
const scheme = tlsEnabled ? 'https' : 'http';
|
|
const connectHost = normalizedConnectHost(listenHost);
|
|
const origin = `${scheme}://${urlHost(connectHost)}:${safePort}`;
|
|
|
|
return [
|
|
{
|
|
id: 'openai',
|
|
name: 'OpenAI',
|
|
description: translate(getCurrentLocale(), 'kernel.access.openaiDescription'),
|
|
baseUrl: `${origin}/v1`,
|
|
},
|
|
{
|
|
id: 'claude',
|
|
name: 'Claude',
|
|
description: translate(getCurrentLocale(), 'kernel.access.claudeDescription'),
|
|
baseUrl: origin,
|
|
},
|
|
{
|
|
id: 'gemini',
|
|
name: 'Gemini',
|
|
description: translate(getCurrentLocale(), 'kernel.access.geminiDescription'),
|
|
baseUrl: origin,
|
|
},
|
|
];
|
|
}
|