- 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
53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
"use strict";
|
|
module.exports = asPromise;
|
|
|
|
/**
|
|
* Callback as used by {@link util.asPromise}.
|
|
* @typedef asPromiseCallback
|
|
* @type {function}
|
|
* @param {Error|null} error Error, if any
|
|
* @param {...*} params Additional arguments
|
|
* @returns {undefined}
|
|
*/
|
|
|
|
/**
|
|
* Returns a promise from a node-style callback function.
|
|
* @memberof util
|
|
* @param {asPromiseCallback} fn Function to call
|
|
* @param {*} ctx Function context
|
|
* @param {...*} params Function arguments
|
|
* @returns {Promise<*>} Promisified function
|
|
*/
|
|
function asPromise(fn, ctx/*, varargs */) {
|
|
var params = new Array(arguments.length - 1),
|
|
offset = 0,
|
|
index = 2,
|
|
pending = true;
|
|
while (index < arguments.length)
|
|
params[offset++] = arguments[index++];
|
|
return new Promise(function executor(resolve, reject) {
|
|
params[offset] = function callback(err/*, varargs */) {
|
|
if (pending) {
|
|
pending = false;
|
|
if (err)
|
|
reject(err);
|
|
else {
|
|
var params = new Array(arguments.length - 1),
|
|
offset = 0;
|
|
while (offset < params.length)
|
|
params[offset++] = arguments[offset];
|
|
resolve.apply(null, params);
|
|
}
|
|
}
|
|
};
|
|
try {
|
|
fn.apply(ctx || null, params);
|
|
} catch (err) {
|
|
if (pending) {
|
|
pending = false;
|
|
reject(err);
|
|
}
|
|
}
|
|
});
|
|
}
|