- 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
37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
import { ProviderError } from "@smithy/property-provider";
|
|
import { Buffer } from "buffer";
|
|
import { request } from "http";
|
|
export function httpRequest(options) {
|
|
return new Promise((resolve, reject) => {
|
|
const req = request({
|
|
method: "GET",
|
|
...options,
|
|
hostname: options.hostname?.replace(/^\[(.+)\]$/, "$1"),
|
|
});
|
|
req.on("error", (err) => {
|
|
reject(Object.assign(new ProviderError("Unable to connect to instance metadata service"), err));
|
|
req.destroy();
|
|
});
|
|
req.on("timeout", () => {
|
|
reject(new ProviderError("TimeoutError from instance metadata service"));
|
|
req.destroy();
|
|
});
|
|
req.on("response", (res) => {
|
|
const { statusCode = 400 } = res;
|
|
if (statusCode < 200 || 300 <= statusCode) {
|
|
reject(Object.assign(new ProviderError("Error response received from instance metadata service"), { statusCode }));
|
|
req.destroy();
|
|
}
|
|
const chunks = [];
|
|
res.on("data", (chunk) => {
|
|
chunks.push(chunk);
|
|
});
|
|
res.on("end", () => {
|
|
resolve(Buffer.concat(chunks));
|
|
req.destroy();
|
|
});
|
|
});
|
|
req.end();
|
|
});
|
|
}
|