@toolplex/client
Version:
The official ToolPlex client for AI agent tool discovery and execution
54 lines (53 loc) • 1.91 kB
TypeScript
import { StdioServerManagerClient } from "../shared/stdioServerManagerClient.js";
type ServerInfo = {
server_id: string;
server_name: string;
description: string;
};
/**
* An in-memory cache that tracks currently installed servers.
* Maintains a set of server IDs for quick lookup of installed servers.
* Can be refreshed by querying server manager clients for their current server lists.
*/
export declare class ServersCache {
private _serverIds;
constructor();
/**
* Initialize the cache with a list of servers, e.g. from initialize() succeeded list.
* Only tracks server IDs.
*/
init(servers: ServerInfo[]): void;
/**
* Update the cache with a new list of servers, e.g. after calling listServersHandler.
* This does not imply initialization, but is meant to refresh the cache with the latest list.
* Only tracks server IDs.
*/
updateServers(servers: ServerInfo[]): void;
/**
* Returns true if the server is installed (present in the cache).
* Throws an error if the cache is not initialized.
*/
isInstalled(serverId: string): boolean;
/**
* Get all cached server IDs.
*/
getServerIds(): string[];
/**
* Refresh the cache by calling list_servers on all server manager clients.
* This follows the pattern in handleListServers (listServersHandler.ts):
* - Use sendRequest('list_servers', {}) on each client.
* - Validate/parse the response with ListServersResultSchema.
* - Collect all servers from all runtimes.
* @param serverManagerClients - Record of server manager clients (e.g. from Registry)
*/
refreshCache(serverManagerClients: Record<string, StdioServerManagerClient>): Promise<void>;
/**
* Check if the cache is initialized
*/
isInitialized(): boolean;
/**
* Reset the cache
*/
reset(): void;
}
export {};