- 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
48 lines
2.0 KiB
JavaScript
48 lines
2.0 KiB
JavaScript
export const createAggregatedClient = (commands, Client, options) => {
|
|
for (const [command, CommandCtor] of Object.entries(commands)) {
|
|
const methodImpl = async function (args, optionsOrCb, cb) {
|
|
const command = new CommandCtor(args);
|
|
if (typeof optionsOrCb === "function") {
|
|
this.send(command, optionsOrCb);
|
|
}
|
|
else if (typeof cb === "function") {
|
|
if (typeof optionsOrCb !== "object")
|
|
throw new Error(`Expected http options but got ${typeof optionsOrCb}`);
|
|
this.send(command, optionsOrCb || {}, cb);
|
|
}
|
|
else {
|
|
return this.send(command, optionsOrCb);
|
|
}
|
|
};
|
|
const methodName = (command[0].toLowerCase() + command.slice(1)).replace(/Command$/, "");
|
|
Client.prototype[methodName] = methodImpl;
|
|
}
|
|
const { paginators = {}, waiters = {} } = options ?? {};
|
|
for (const [paginatorName, paginatorFn] of Object.entries(paginators)) {
|
|
if (Client.prototype[paginatorName] === void 0) {
|
|
Client.prototype[paginatorName] = function (commandInput = {}, paginationConfiguration, ...rest) {
|
|
return paginatorFn({
|
|
...paginationConfiguration,
|
|
client: this,
|
|
}, commandInput, ...rest);
|
|
};
|
|
}
|
|
}
|
|
for (const [waiterName, waiterFn] of Object.entries(waiters)) {
|
|
if (Client.prototype[waiterName] === void 0) {
|
|
Client.prototype[waiterName] = async function (commandInput = {}, waiterConfiguration, ...rest) {
|
|
let config = waiterConfiguration;
|
|
if (typeof waiterConfiguration === "number") {
|
|
config = {
|
|
maxWaitTime: waiterConfiguration,
|
|
};
|
|
}
|
|
return waiterFn({
|
|
...config,
|
|
client: this,
|
|
}, commandInput, ...rest);
|
|
};
|
|
}
|
|
}
|
|
};
|