Add hub package
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user