- 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
51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
export class EndpointCache {
|
|
capacity;
|
|
data = new Map();
|
|
parameters = [];
|
|
constructor({ size, params }) {
|
|
this.capacity = size ?? 50;
|
|
if (params) {
|
|
this.parameters = params;
|
|
}
|
|
}
|
|
get(endpointParams, resolver) {
|
|
const key = this.hash(endpointParams);
|
|
if (key === false) {
|
|
return resolver();
|
|
}
|
|
if (!this.data.has(key)) {
|
|
if (this.data.size > this.capacity + 10) {
|
|
const keys = this.data.keys();
|
|
let i = 0;
|
|
while (true) {
|
|
const { value, done } = keys.next();
|
|
this.data.delete(value);
|
|
if (done || ++i > 10) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
this.data.set(key, resolver());
|
|
}
|
|
return this.data.get(key);
|
|
}
|
|
size() {
|
|
return this.data.size;
|
|
}
|
|
hash(endpointParams) {
|
|
let buffer = "";
|
|
const { parameters } = this;
|
|
if (parameters.length === 0) {
|
|
return false;
|
|
}
|
|
for (const param of parameters) {
|
|
const val = String(endpointParams[param] ?? "");
|
|
if (val.includes("|;")) {
|
|
return false;
|
|
}
|
|
buffer += val + "|;";
|
|
}
|
|
return buffer;
|
|
}
|
|
}
|