- 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
30 lines
1.2 KiB
JavaScript
30 lines
1.2 KiB
JavaScript
import { EndpointError } from "../types";
|
|
import { customEndpointFunctions } from "./customEndpointFunctions";
|
|
import { endpointFunctions } from "./endpointFunctions";
|
|
import { evaluateTemplate } from "./evaluateTemplate";
|
|
import { getReferenceValue } from "./getReferenceValue";
|
|
export const evaluateExpression = (obj, keyName, options) => {
|
|
if (typeof obj === "string") {
|
|
return evaluateTemplate(obj, options);
|
|
}
|
|
else if (obj["fn"]) {
|
|
return group.callFunction(obj, options);
|
|
}
|
|
else if (obj["ref"]) {
|
|
return getReferenceValue(obj, options);
|
|
}
|
|
throw new EndpointError(`'${keyName}': ${String(obj)} is not a string, function or reference.`);
|
|
};
|
|
export const callFunction = ({ fn, argv }, options) => {
|
|
const evaluatedArgs = argv.map((arg) => ["boolean", "number"].includes(typeof arg) ? arg : group.evaluateExpression(arg, "arg", options));
|
|
const fnSegments = fn.split(".");
|
|
if (fnSegments[0] in customEndpointFunctions && fnSegments[1] != null) {
|
|
return customEndpointFunctions[fnSegments[0]][fnSegments[1]](...evaluatedArgs);
|
|
}
|
|
return endpointFunctions[fn](...evaluatedArgs);
|
|
};
|
|
export const group = {
|
|
evaluateExpression,
|
|
callFunction,
|
|
};
|