Repository for persisting and retrieving AI agents.

class InMemoryAgentRepository implements AgentRepository {
private agents = new Map<string, AIAgent<any, any>>();

async findById(id: AgentId): Promise<AIAgent<any, any> | null> {
return this.agents.get(id.value) ?? null;
}

async save(agent: AIAgent<any, any>): Promise<void> {
this.agents.set(agent.id.value, agent);
}
}
interface AgentRepository {
    findById(id: AgentId): Promise<null | AIAgent<unknown, unknown>>;
    findByCapability(capability: string): Promise<AIAgent<unknown, unknown>[]>;
    findAll(): Promise<AIAgent<unknown, unknown>[]>;
    save(agent: AIAgent<unknown, unknown>): Promise<void>;
    delete(id: AgentId): Promise<void>;
    exists(id: AgentId): Promise<boolean>;
}

Methods

  • Finds all agents with a specific capability

    Parameters

    • capability: string

      The capability to search for

    Returns Promise<AIAgent<unknown, unknown>[]>

    Array of agents with the capability