/** * @module registries/discovery * @description High-level agent and tool discovery registry. * * Abstracts the raw PDA-level indexing + fetching into a single * developer-friendly interface for finding agents, tools, and * services across the SAP network. * * Use cases: * - "Find all agents that support Jupiter swaps" * - "Find all Swap tools across all agents" * - "Get the full profile of agent X (identity + stats + tools)" * - "Get network-wide statistics" * * @category Registries * @since v0.1.0 * * @example * ```ts * const discovery = client.discovery; * * // Find agents that support Jupiter protocol * const agents = await discovery.findAgentsByProtocol("jupiter"); * * // Get full agent profile (identity + stats + attestations) * const profile = await discovery.getAgentProfile(agentWallet); * * // Find all Swap tools across the network * const tools = await discovery.findToolsByCategory("Swap"); * * // Network overview * const stats = await discovery.getNetworkOverview(); * ``` */ import type { PublicKey } from "@solana/web3.js"; import type { SapProgram } from "../modules/base"; import { TOOL_CATEGORY_VALUES } from "../constants"; import type { AgentAccountData, AgentStatsData, ToolDescriptorData } from "../types"; /** * @interface DiscoveredAgent * @name DiscoveredAgent * @description Compact agent identity returned by discovery queries. * Contains the agent PDA, optional identity data, and optional stats. * Returned by {@link DiscoveryRegistry.findAgentsByCapability}, * {@link DiscoveryRegistry.findAgentsByProtocol}, and * {@link DiscoveryRegistry.findAgentsByCapabilities}. * @category Registries * @since v0.1.0 */ export interface DiscoveredAgent { /** Agent PDA address. */ readonly pda: PublicKey; /** Agent identity data (null if account not found). */ readonly identity: AgentAccountData | null; /** Agent stats (null if account not found). */ readonly stats: AgentStatsData | null; } /** * @interface AgentProfile * @name AgentProfile * @description Full agent profile with all discoverable data. * Combines identity, stats, and computed fields into a single * display-ready structure. Returned by {@link DiscoveryRegistry.getAgentProfile}. * @category Registries * @since v0.1.0 */ export interface AgentProfile { /** Agent PDA. */ readonly pda: PublicKey; /** Agent identity (name, description, capabilities, pricing, etc.). */ readonly identity: AgentAccountData; /** Lightweight metrics (total calls, active status). */ readonly stats: AgentStatsData | null; /** Computed fields for display. */ readonly computed: { /** Is the agent currently active? */ readonly isActive: boolean; /** Total calls served (from stats or identity fallback). */ readonly totalCalls: string; /** Reputation score (0-1000). */ readonly reputationScore: number; /** Has x402 endpoint configured? */ readonly hasX402: boolean; /** Number of capabilities. */ readonly capabilityCount: number; /** Number of pricing tiers. */ readonly pricingTierCount: number; /** Protocol list. */ readonly protocols: string[]; }; } /** * @interface DiscoveredTool * @name DiscoveredTool * @description Discovered tool with agent context. * Contains the tool PDA and optional descriptor data. * Returned by {@link DiscoveryRegistry.findToolsByCategory}. * @category Registries * @since v0.1.0 */ export interface DiscoveredTool { /** Tool PDA address. */ readonly pda: PublicKey; /** Tool descriptor data (null if not found). */ readonly descriptor: ToolDescriptorData | null; } /** * @interface NetworkOverview * @name NetworkOverview * @description Network-wide statistics aggregated from the GlobalRegistry account. * Provides counts of agents, tools, vaults, attestations, and more. * Returned by {@link DiscoveryRegistry.getNetworkOverview}. * @category Registries * @since v0.1.0 */ export interface NetworkOverview { /** Total registered agents. */ readonly totalAgents: string; /** Currently active agents. */ readonly activeAgents: string; /** Total feedback entries. */ readonly totalFeedbacks: string; /** Total registered tools. */ readonly totalTools: number; /** Total memory vaults. */ readonly totalVaults: number; /** Total attestations. */ readonly totalAttestations: number; /** Total capability indexes. */ readonly totalCapabilities: number; /** Total protocol indexes. */ readonly totalProtocols: number; /** Protocol authority. */ readonly authority: PublicKey; } /** * @typedef {string} ToolCategoryName * @name ToolCategoryName * @description Tool category string literal type derived from `TOOL_CATEGORY_VALUES`. * Valid values are: `Swap`, `Lend`, `Stake`, `Nft`, `Payment`, `Data`, * `Governance`, `Bridge`, `Analytics`, and `Custom`. * @category Registries * @since v0.1.0 * @see {@link DiscoveryRegistry.findToolsByCategory} */ export type ToolCategoryName = keyof typeof TOOL_CATEGORY_VALUES; /** * @name DiscoveryRegistry * @description High-level agent and tool discovery registry for the SAP network. * * Provides a developer-friendly API for finding agents by capability, * protocol, or tool category, fetching full agent profiles, and * retrieving network-wide statistics. * * @category Registries * @since v0.1.0 * * @example * ```ts * const discovery = client.discovery; * * // Find agents by capability * const swapAgents = await discovery.findAgentsByCapability("jupiter:swap"); * * // Get agent profile * const profile = await discovery.getAgentProfile(agentWallet); * * // Network statistics * const overview = await discovery.getNetworkOverview(); * ``` */ export declare class DiscoveryRegistry { private readonly program; constructor(program: SapProgram); /** * @name findAgentsByCapability * @description Find all agent PDAs registered for a specific capability. * Hashes the capability ID with SHA-256 and looks up the capability index PDA. * * @param capabilityId - The capability identifier string (e.g. `"jupiter:swap"`). * @param opts - Optional settings. * @param opts.hydrate - If `false`, returns only PDAs without fetching identity/stats. Defaults to `true`. * @returns An array of {@link DiscoveredAgent} matching the capability. * @since v0.1.0 * * @example * ```ts * const agents = await discovery.findAgentsByCapability("jupiter:swap"); * ``` */ findAgentsByCapability(capabilityId: string, opts?: { hydrate?: boolean; }): Promise; /** * @name findAgentsByProtocol * @description Find all agent PDAs registered for a specific protocol. * Hashes the protocol ID with SHA-256 and looks up the protocol index PDA. * * @param protocolId - The protocol identifier string (e.g. `"jupiter"`). * @param opts - Optional settings. * @param opts.hydrate - If `false`, returns only PDAs without fetching identity/stats. Defaults to `true`. * @returns An array of {@link DiscoveredAgent} matching the protocol. * @since v0.1.0 * * @example * ```ts * const agents = await discovery.findAgentsByProtocol("jupiter"); * ``` */ findAgentsByProtocol(protocolId: string, opts?: { hydrate?: boolean; }): Promise; /** * @name findToolsByCategory * @description Find all tool PDAs registered in a specific category. * Accepts either a category name string or a numeric category value. * * @param category - Tool category name (e.g. `"Swap"`) or numeric category value. * @param opts - Optional settings. * @param opts.hydrate - If `false`, returns only PDAs without fetching descriptors. Defaults to `true`. * @returns An array of {@link DiscoveredTool} matching the category. * @since v0.1.0 * * @example * ```ts * const tools = await discovery.findToolsByCategory("Swap"); * const tools = await discovery.findToolsByCategory(0); // numeric * ``` */ findToolsByCategory(category: ToolCategoryName | number, opts?: { hydrate?: boolean; }): Promise; /** * @name getAgentProfile * @description Get the full profile of an agent by wallet address. * Combines identity + stats into a single response with computed fields * for easy display (active status, total calls, reputation, etc.). * * @param wallet - The agent owner's wallet public key. * @returns The full {@link AgentProfile}, or `null` if the agent does not exist. * @since v0.1.0 * * @example * ```ts * const profile = await discovery.getAgentProfile(agentWallet); * console.log(profile.identity.name); * console.log(profile.computed.isActive); * console.log(profile.computed.totalCalls); * ``` */ getAgentProfile(wallet: PublicKey): Promise; /** * @name isAgentActive * @description Check if an agent exists and is currently active. * Reads the agent stats account to determine active status. * * @param wallet - The agent owner's wallet public key. * @returns `true` if the agent exists and is active, `false` otherwise. * @since v0.1.0 */ isAgentActive(wallet: PublicKey): Promise; /** * @name getNetworkOverview * @description Get network-wide statistics from the GlobalRegistry account. * Returns aggregated counts and metadata for the entire SAP network. * * @returns A {@link NetworkOverview} with all network-level statistics. * @since v0.1.0 */ getNetworkOverview(): Promise; /** * @name findAgentsByCapabilities * @description Search across multiple capability IDs at once. * Returns deduplicated agent PDAs aggregated from all matching capability indexes. * * @param capabilityIds - Array of capability identifier strings to search. * @param opts - Optional settings. * @param opts.hydrate - If `false`, returns only PDAs without fetching identity/stats. Defaults to `true`. * @returns A deduplicated array of {@link DiscoveredAgent} matching any of the capabilities. * @since v0.1.0 */ findAgentsByCapabilities(capabilityIds: string[], opts?: { hydrate?: boolean; }): Promise; /** * @name getToolCategorySummary * @description Search across all 10 tool categories and return a summary. * Lists each category with its name, numeric value, and tool count. * * @returns An array of category summary objects with `category`, `categoryNum`, and `toolCount`. * @since v0.1.0 */ getToolCategorySummary(): Promise>; /** * @name hydrateAgents * @description Hydrate an array of agent PDAs by fetching identity and stats data. * @param agentPdas - Array of agent PDA public keys. * @returns An array of {@link DiscoveredAgent} with populated identity and stats fields. * @private */ private hydrateAgents; /** * @name hydrateTools * @description Hydrate an array of tool PDAs by fetching descriptor data. * @param toolPdas - Array of tool PDA public keys. * @returns An array of {@link DiscoveredTool} with populated descriptor fields. * @private */ private hydrateTools; /** * @name fetch * @description Fetch an on-chain account by name and PDA. Throws if not found. * @param name - Anchor account discriminator name. * @param pda - Account public key to fetch. * @returns The deserialized account data. * @throws If the account does not exist. * @private */ private fetch; /** * @name fetchNullable * @description Fetch an on-chain account by name and PDA. Returns `null` if not found. * @param name - Anchor account discriminator name. * @param pda - Account public key to fetch. * @returns The deserialized account data, or `null` if the account does not exist. * @private */ private fetchNullable; } //# sourceMappingURL=discovery.d.ts.map