-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgemini-cli.cjs
More file actions
69 lines (57 loc) · 1.73 KB
/
Copy pathgemini-cli.cjs
File metadata and controls
69 lines (57 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env node
// Gemini CLI converted to CommonJS file that is compatible with the project's "type": "module" setting.
// It dynamically imports the ES-module logger at runtime.
const GeminiCliAgent = require('./src/lib/agents/GeminiCliAgent.cjs');
const dotenv = require('dotenv');
dotenv.config();
// Fallback logging until the real logger is available
function earlyError(...args) {
// eslint-disable-next-line no-console
console.error(...args);
}
function earlyInfo(...args) {
// eslint-disable-next-line no-console
console.info(...args);
}
if (!process.env.GEMINI_API_KEY) {
earlyError('❌ Error: GEMINI_API_KEY environment variable is required');
earlyInfo('💡 Please set your Gemini API key in the .env file:');
earlyInfo(' GEMINI_API_KEY=your_api_key_here');
process.exit(1);
}
let logger;
async function getLogger() {
if (!logger) {
const mod = await import('./src/logger.js');
logger = mod.default;
}
return logger;
}
async function main() {
const log = await getLogger();
log.info('🌟 Smart MCP Server - Gemini CLI Assistant');
log.info('='.repeat(50));
const agent = new GeminiCliAgent();
try {
await agent.initialize();
} catch (error) {
const log = await getLogger();
log.error('❌ Failed to start Gemini CLI Agent:', error.message);
process.exit(1);
}
}
process.on('SIGINT', async () => {
const log = await getLogger();
log.info('\n👋 Shutting down gracefully...');
process.exit(0);
});
process.on('SIGTERM', async () => {
const log = await getLogger();
log.info('\n👋 Shutting down gracefully...');
process.exit(0);
});
main().catch(async (error) => {
const log = await getLogger();
log.error('❌ Unexpected error:', error);
process.exit(1);
});