chore: sync connectai
This commit is contained in:
+13
-8
@@ -7,7 +7,10 @@ import {
|
||||
_getBrainDir,
|
||||
_isBrainDirExplicitlySet,
|
||||
findBrainFiles,
|
||||
SYSTEM_PROMPT
|
||||
SYSTEM_PROMPT,
|
||||
buildApiUrl,
|
||||
logError,
|
||||
logInfo
|
||||
} from './utils';
|
||||
import { AgentExecutor } from './agent';
|
||||
import { BridgeServer } from './bridge';
|
||||
@@ -17,7 +20,7 @@ import { SidebarChatProvider } from './sidebarProvider';
|
||||
* G1nation Extension Entry Point
|
||||
*/
|
||||
export async function activate(context: vscode.ExtensionContext) {
|
||||
console.log('G1nation extension activated.');
|
||||
logInfo('Connect AI extension activated.');
|
||||
|
||||
// 1. Ensure Brain Directory
|
||||
await _ensureBrainDir(context);
|
||||
@@ -35,9 +38,9 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
const bridge = new BridgeServer(provider);
|
||||
try {
|
||||
bridge.start();
|
||||
console.log('G1nation Bridge Server started on port 4825');
|
||||
logInfo('Bridge server started on port 4825.');
|
||||
} catch (err) {
|
||||
console.error('Failed to start Bridge Server:', err);
|
||||
logError('Failed to start bridge server.', err);
|
||||
}
|
||||
|
||||
// 5. Register Core Commands
|
||||
@@ -74,16 +77,17 @@ async function runInitialSetup(context: vscode.ExtensionContext) {
|
||||
let modelName = '';
|
||||
|
||||
try {
|
||||
const res = await fetch('http://127.0.0.1:1234/v1/models', { signal: AbortSignal.timeout(2000) });
|
||||
const res = await fetch(buildApiUrl('http://127.0.0.1:1234', 'lmstudio', 'models'), { signal: AbortSignal.timeout(2000) });
|
||||
const data = await res.json() as any;
|
||||
if (data?.data?.length > 0) {
|
||||
engineName = 'LM Studio';
|
||||
modelName = data.data[0].id;
|
||||
await vscode.workspace.getConfiguration('g1nation').update('ollamaUrl', 'http://127.0.0.1:1234', vscode.ConfigurationTarget.Global);
|
||||
await vscode.workspace.getConfiguration('g1nation').update('defaultModel', modelName, vscode.ConfigurationTarget.Global);
|
||||
logInfo('Initial setup detected LM Studio.', { modelName });
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[Setup] LM Studio not found:', err);
|
||||
logInfo('Initial setup could not reach LM Studio.', err);
|
||||
}
|
||||
|
||||
if (!engineName) {
|
||||
@@ -95,9 +99,10 @@ async function runInitialSetup(context: vscode.ExtensionContext) {
|
||||
modelName = data.models[0].name;
|
||||
await vscode.workspace.getConfiguration('g1nation').update('ollamaUrl', 'http://127.0.0.1:11434', vscode.ConfigurationTarget.Global);
|
||||
await vscode.workspace.getConfiguration('g1nation').update('defaultModel', modelName, vscode.ConfigurationTarget.Global);
|
||||
logInfo('Initial setup detected Ollama.', { modelName });
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[Setup] Ollama not found:', err);
|
||||
logInfo('Initial setup could not reach Ollama.', err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +111,7 @@ async function runInitialSetup(context: vscode.ExtensionContext) {
|
||||
vscode.window.showInformationMessage(`Setup Complete: ${engineName} detected with model ${modelName}`);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[Setup] Initial setup failed:', e);
|
||||
logError('Initial setup failed.', e);
|
||||
context.globalState.update('setupComplete', true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user