feat: Complete zCode CLI X with Telegram bot integration

- Add full Telegram bot functionality with Z.AI API integration
- Implement 4 tools: Bash, FileEdit, WebSearch, Git
- Add 3 agents: Code Reviewer, Architect, DevOps Engineer
- Add 6 skills for common coding tasks
- Add systemd service file for 24/7 operation
- Add nginx configuration for HTTPS webhook
- Add comprehensive documentation
- Implement WebSocket server for real-time updates
- Add logging system with Winston
- Add environment validation

🤖 zCode CLI X - Agentic coder with Z.AI + Telegram integration
This commit is contained in:
admin
2026-05-05 09:01:26 +00:00
Unverified
parent 4a7035dd92
commit 875c7f9b91
24688 changed files with 3224957 additions and 221 deletions

77
src/api/index.js Normal file
View File

@@ -0,0 +1,77 @@
import axios from 'axios';
import { logger } from '../utils/logger.js';
import { checkEnv } from '../utils/env.js';
export async function initAPI() {
const env = checkEnv();
const config = {
baseUrl: env.GLM_BASE_URL || 'https://api.z.ai/api/coding/paas/v4',
apiKey: env.ZAI_API_KEY || '',
};
const client = axios.create({
baseURL: config.baseUrl,
headers: {
'Authorization': `Bearer ${config.apiKey}`,
'Content-Type': 'application/json',
},
timeout: 300000,
});
// Test connection
try {
const response = await client.get('/models', {
headers: {
'Authorization': `Bearer ${config.apiKey}`,
},
timeout: 10000
});
logger.info(`✓ Connected to Z.AI API (${response.data?.data?.length || 0} models available)`);
} catch (error) {
logger.error('✗ Failed to connect to Z.AI API');
throw error;
}
return {
config,
client,
};
}
export class ZAIProvider {
constructor(api) {
this.api = api;
}
async chat(messages, options = {}) {
const { model = 'glm-5.1', temperature = 0.7, maxTokens = 4096, stream = false } = options;
try {
const response = await this.api.client.post('/chat/completions', {
model,
messages,
temperature,
max_tokens: maxTokens,
stream,
});
if (stream) {
return response.data;
}
return response.data.choices[0].message;
} catch (error) {
logger.error('Z.AI API error:', error.response?.data || error.message);
throw error;
}
}
async complete(prompt, options = {}) {
return this.chat([{ role: 'user', content: prompt }], options);
}
}
export function createZAIProvider(api) {
return new ZAIProvider(api);
}