32 lines
835 B
TypeScript
32 lines
835 B
TypeScript
|
|
import * as plugins from '../plugins.js';
|
||
|
|
|
||
|
|
export class AgentRegistry {
|
||
|
|
private agents = [...plugins.shxAgents.referenceAgents];
|
||
|
|
private statuses: plugins.shxInterfaces.data.IAgentStatus[] = this.agents.map((agentArg) => ({
|
||
|
|
agentId: agentArg.id,
|
||
|
|
actionsToday: 0,
|
||
|
|
runningToolIds: [],
|
||
|
|
}));
|
||
|
|
|
||
|
|
public listAgents() {
|
||
|
|
return this.agents.filter((agentArg) => agentArg.enabled);
|
||
|
|
}
|
||
|
|
|
||
|
|
public getAgentById(agentIdArg: string) {
|
||
|
|
return this.agents.find((agentArg) => agentArg.id === agentIdArg);
|
||
|
|
}
|
||
|
|
|
||
|
|
public listStatuses() {
|
||
|
|
return [...this.statuses];
|
||
|
|
}
|
||
|
|
|
||
|
|
public recordAction(agentIdArg: string, latestArg: string) {
|
||
|
|
const status = this.statuses.find((statusArg) => statusArg.agentId === agentIdArg);
|
||
|
|
if (!status) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
status.actionsToday++;
|
||
|
|
status.latest = latestArg;
|
||
|
|
}
|
||
|
|
}
|