Update ConnectAI codebase

This commit is contained in:
g1nation
2026-05-18 08:15:01 +09:00
parent 88664c7c6e
commit 86cacaeb03
38 changed files with 1043 additions and 99 deletions
@@ -98,6 +98,18 @@ interface SettingsState {
connectedAt?: string;
lastIcalFetchAt?: string;
};
/**
* Cloud LLM providers (OpenRouter / Anthropic / Gemini). API key 자체는 echo 안 함 —
* hasApiKey boolean 만 전송. enabled 와 defaultModel 은 settings 에서 직접 읽음.
*/
providers: {
openrouter: { enabled: boolean; hasApiKey: boolean; defaultModel: string };
anthropic: { enabled: boolean; hasApiKey: boolean; defaultModel: string };
gemini: { enabled: boolean; hasApiKey: boolean; defaultModel: string };
};
devilAgent: {
enabled: boolean;
};
/** Sectional banner shown when config.update fails (e.g. reload required). */
bannerError?: string;
}
@@ -238,6 +250,12 @@ export class SettingsPanelProvider implements vscode.WebviewViewProvider {
case 'google.icalRefresh':
await this._handleGoogleIcalRefresh();
return;
case 'providers.update':
await this._handleProvidersUpdate(msg);
return;
case 'devilAgent.toggle':
await this._safeConfigUpdate('devilAgent.enabled', !!msg.enabled);
return;
case 'openVscodeSettings':
await vscode.commands.executeCommand('workbench.action.openSettings', 'g1nation');
return;
@@ -509,6 +527,36 @@ export class SettingsPanelProvider implements vscode.WebviewViewProvider {
await this._refreshState();
}
// ────────────── Cloud LLM Providers ──────────────
// OpenRouter / Anthropic / Gemini API key + enable 토글. API key 는 Secret Storage 만.
// settings 패널은 *값 자체는 안 보여줌* (hasApiKey boolean 만). 사용자가 새로 입력 시 덮어씀.
private async _buildProvidersState(): Promise<SettingsState['providers']> {
const { readProviderStatus } = require('../providers') as typeof import('../providers');
const ctx = this._deps.context;
const [or, an, ge] = await Promise.all([
readProviderStatus(ctx, 'openrouter'),
readProviderStatus(ctx, 'anthropic'),
readProviderStatus(ctx, 'gemini'),
]);
return { openrouter: or, anthropic: an, gemini: ge };
}
private async _handleProvidersUpdate(msg: any): Promise<void> {
const { writeProviderConfig } = require('../providers') as typeof import('../providers');
const id = msg.providerId;
if (id !== 'openrouter' && id !== 'anthropic' && id !== 'gemini') return;
const patch: any = {};
if (typeof msg.enabled === 'boolean') patch.enabled = msg.enabled;
if (typeof msg.apiKey === 'string') patch.apiKey = msg.apiKey;
if (typeof msg.defaultModel === 'string') patch.defaultModel = msg.defaultModel;
if (Object.keys(patch).length === 0) return;
await writeProviderConfig(this._deps.context, id, patch);
this._lastSuccess = `${id} 저장 완료`;
this._lastError = undefined;
await this._refreshState();
}
private async _handleAdvancedUpdate(msg: any): Promise<void> {
if (typeof msg.dryRun === 'boolean') {
await this._safeConfigUpdate('dryRun', msg.dryRun);
@@ -573,6 +621,8 @@ export class SettingsPanelProvider implements vscode.WebviewViewProvider {
maxContextSize: cfg.get<number>('maxContextSize', 32000) ?? 32000,
},
google: this._buildGoogleState(),
providers: await this._buildProvidersState(),
devilAgent: { enabled: cfg.get<boolean>('devilAgent.enabled', false) },
bannerError: this._bannerError,
};
const payload = { type: 'state', value: state };