src / peers.ts
/**
* Peer plugin detection for research-plugin.
*
* If altra/web-search is installed, search_sources and read_source are omitted
* from this plugin's tool registration — the web-search-plugin handles those.
* The session is held at module scope to keep it alive for the plugin lifetime.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let _webPeerSession: any = null;
let _peerStatus: boolean | null = null;
export async function detectWebPeer(ctl: { client: any }): Promise<boolean> {
try {
_webPeerSession = await ctl.client.plugins.pluginTools("altra/web-search");
_peerStatus = Array.isArray(_webPeerSession?.tools) && _webPeerSession.tools.length > 0;
return _peerStatus;
} catch {
_peerStatus = false;
return false;
}
}
/** Returns null if detection hasn't run yet, true/false after toolsProvider init. */
export function webPeerStatus(): boolean | null {
return _peerStatus;
}