/** * AgenticTrust API Client * * Client for interacting with the AgenticTrust GraphQL API */ import { GraphQLClient } from 'graphql-request'; import type { ApiClientConfig } from '../lib/types'; import { AgentsAPI } from '../lib/agents'; import type { DiscoverAgentsOptions, ListAgentsResponse } from '../lib/agents'; import { A2AProtocolProviderAPI } from '../lib/a2aProtocolProvider'; import { VeramoAPI, type AuthChallenge, type ChallengeVerificationResult } from '../lib/veramo'; import { Agent } from '../lib/agent'; import type { AgentDetail } from '../models/agentDetail'; import { type CreateFeedbackAuthWithDelegationResult } from '../lib/agentFeedback'; import type { RequestAuthParams } from '../lib/agentFeedback'; type OwnerType = 'eoa' | 'smartAccount'; type ExecutionMode = 'auto' | 'server' | 'client'; type CreateAgentBaseParams = { agentName: string; agentAccount: `0x${string}`; agentCategory?: string; description?: string; image?: string; agentUrl?: string; supportedTrust?: string[]; endpoints?: Array<{ name: string; endpoint: string; version?: string; capabilities?: Record; }>; chainId?: number; }; type CreateAgentWithEOAOwnerUsingWalletResult = Awaited>; type CreateAgentWithEOAOwnerUsingPrivateKeyResult = Awaited>; type CreateAgentWithSmartAccountOwnerUsingWalletResult = Awaited>; type CreateAgentWithSmartAccountOwnerUsingPrivateKeyResult = Awaited>; type CreateAgentResult = CreateAgentWithEOAOwnerUsingWalletResult | CreateAgentWithEOAOwnerUsingPrivateKeyResult | CreateAgentWithSmartAccountOwnerUsingWalletResult | CreateAgentWithSmartAccountOwnerUsingPrivateKeyResult; export declare class AgenticTrustClient { private graphQLClient; private config; agents: AgentsAPI; a2aProtocolProvider: A2AProtocolProviderAPI; veramo: VeramoAPI; /** Resolves when async initialization (Veramo + optional reputation clients) is complete */ readonly ready: Promise; constructor(configOrParams: ApiClientConfig | { privateKey: string; chainId: number; rpcUrl: string; discoveryUrl?: string; discoveryApiKey?: string; identityRegistry?: `0x${string}`; reputationRegistry?: `0x${string}`; }); /** * Initialize the Veramo agent (internal method) * Called automatically during create() if not provided in config */ private initializeVeramoAgent; /** * Create a new AgenticTrust client instance */ static create(config: ApiClientConfig): Promise; /** @deprecated Use `new AgenticTrustClient({ privateKey, chainId, rpcUrl, ... })` instead. */ static createWithDefaults(params: { privateKey: string; chainId: number; rpcUrl: string; discoveryUrl?: string; discoveryApiKey?: string; identityRegistry?: `0x${string}`; reputationRegistry?: `0x${string}`; }): Promise; /** * High-level agent search API exposed directly on the AgenticTrustClient. * This is a thin wrapper around AgentsAPI.searchAgents so that apps can call * client.searchAgents(...) instead of client.agents.searchAgents(...). */ searchAgents(options?: DiscoverAgentsOptions | string): Promise; /** * High-level feedbackAuth helper exposed directly on AgenticTrustClient. * This delegates to the shared server-side createFeedbackAuth implementation, * which uses the ReputationClient singleton and IdentityRegistry checks. */ createFeedbackAuth(params: RequestAuthParams): Promise<`0x${string}`>; /** * Create a feedbackAuth and also produce a pre-signed ERC-8092 delegation association * payload (approver signature only). */ createFeedbackAuthWithDelegation(params: RequestAuthParams): Promise; /** * Fetch feedback entries for a given agent. * * Strategy: * 1. Try the discovery indexer's KB GraphQL API when available. * 2. If that fails or is not supported, fall back to on-chain * `readAllFeedback` on the ReputationRegistry via the ReputationClient. * * The return type is intentionally un-opinionated (`unknown[]`) so callers * can evolve their own view models without being tightly coupled to the * underlying indexer/contract schema. */ getAgentFeedback(params: { uaid: string; clientAddresses?: string[]; tag1?: string; tag2?: string; includeRevoked?: boolean; limit?: number; offset?: number; }): Promise; /** * Get aggregated reputation summary for an agentId from the on-chain * ReputationRegistry via the ReputationClient. */ getReputationSummary(params: { agentId: string; chainId?: number; clientAddresses?: string[]; tag1?: string; tag2?: string; }): Promise<{ count: bigint; averageScore: number; }>; /** * ENS helpers exposed via AgenticTrustClient so that apps do not talk to * the ENS singleton directly. */ isENSNameAvailable(ensName: string, chainId?: number): Promise; getENSInfo(ensName: string, chainId?: number): Promise<{ name: string; chainId?: number; available: boolean | null; account: `0x${string}` | string | null; image: string | null; url: string | null; description: string | null; }>; addAgentNameToL1Org(params: { agentName: string; orgName: string; agentAddress: `0x${string}`; agentUrl?: string; chainId?: number; }): Promise; addAgentNameToL2Org(params: { agentName: string; orgName: string; agentAddress: `0x${string}`; agentUrl?: string; agentDescription?: string; agentImage?: string; chainId?: number; }): Promise<{ calls: { to: `0x${string}`; data: `0x${string}`; value?: bigint; }[]; }>; /** * Set the token URI (registration tokenUri) for an existing agent NFT * in the IdentityRegistry. This delegates to the Admin Agents API and * requires AdminApp / admin permissions to be configured. */ setAgentTokenUri(params: { agentId: string | bigint; chainId?: number; tokenUri: string; }): Promise<{ txHash: string; }>; /** * Transfer an agent NFT to a new owner address. * Thin wrapper over AgentsAPI.admin.transferAgent. */ transferAgent(params: { agentId: string | bigint; to: `0x${string}`; chainId?: number; }): Promise<{ txHash: string; }>; /** * Update the on-chain metadata keys `agentName` and/or `agentAccount` * in the IdentityRegistry for an existing agent NFT. * * This is a thin wrapper over AgentsAPI.admin.updateAgent that builds the * appropriate metadata entries. Requires AdminApp / admin permissions. */ updateNameAndAccountMetadata(params: { agentId: string | bigint; chainId?: number; agentName?: string | null; agentAccount?: string | null; }): Promise<{ txHash: string; }>; /** * Prepare low-level calls for updating an agent's token URI and/or metadata, * suitable for client-side AA/bundler execution. Mirrors AgentsAPI.admin.prepareUpdateAgent. */ prepareUpdateAgent(params: { agentId: string | bigint; tokenUri?: string; metadata?: Array<{ key: string; value: string; }>; chainId?: number; }): Promise<{ chainId: number; identityRegistry: `0x${string}`; bundlerUrl: string; calls: Array<{ to: `0x${string}`; data: `0x${string}`; value?: bigint; }>; }>; prepareL1AgentNameInfoCalls(params: { agentAddress: `0x${string}`; orgName: string; agentName: string; agentUrl?: string; agentDescription?: string; chainId?: number; }): Promise<{ calls: { to: `0x${string}`; data: `0x${string}`; value?: bigint; }[]; }>; prepareL2AgentNameInfoCalls(params: { agentAddress: `0x${string}`; orgName: string; agentName: string; agentUrl?: string; agentDescription?: string; agentImage?: string; chainId?: number; }): Promise<{ calls: { to: `0x${string}`; data: `0x${string}`; value?: bigint; }[]; }>; /** * High-level createAgent helper that routes to the appropriate underlying * AgentsAPI method based on ownerType (EOA vs AA) and executionMode. * * - ownerType: 'eoa' | 'smartAccount' * - executionMode: * - 'auto' (default): use server if an admin/private key is configured, otherwise client * - 'server' : execute on server (requires admin/private key, otherwise falls back to 'client') * - 'client' : prepare transactions/calls for client-side signing/execution */ createAgent(params: { ownerType: OwnerType; executionMode?: ExecutionMode; } & CreateAgentBaseParams): Promise; /** * Get a single agent by ID. * Uses loadAgentDetail to get the latest data from the NFT contract, * with discovery data used as fallback for missing fields. */ getAgent(agentId: string, chainId?: number, options?: { includeRegistration?: boolean; }): Promise; /** * Resolve and load an agent by its registered name using the discovery indexer. * Returns an Agent instance bound to this client or null if not found. */ getAgentByName(agentName: string): Promise; /** * Get the on-chain owner (EOA or account) of an agentId from the IdentityRegistry. * Returns null if the owner cannot be resolved (e.g. token does not exist). */ getAgentOwner(agentId: string, chainId?: number): Promise<`0x${string}` | null>; /** * Check if a wallet address owns an agent. * Performs blockchain verification to determine ownership relationship. * Agent NFT → Agent Account (AA) → EOA (wallet) */ isOwner(did8004: string, walletAddress: `0x${string}`, chainId?: number): Promise; /** * Resolve and load an agent by did:8004 identifier. */ getAgentByDid(did8004: string): Promise; /** * Get a fully-hydrated AgentDetail for a given agentId and chainId. * This reuses the shared buildAgentDetail implementation so that * discovery, identity, and registration data are resolved consistently. */ getAgentDetails(agentId: string, chainId?: number): Promise; /** * Get a fully-hydrated AgentDetail for a given did:8004 identifier. */ getAgentDetailsByDid(did8004: string, options?: { includeRegistration?: boolean; }): Promise; /** * UAID-first detail lookup (KB v2). * Resolves UAID -> did:8004 via discovery, then reuses the existing did-based loader. */ getAgentDetailsByUaid(uaid: string, options?: { includeRegistration?: boolean; }): Promise; /** * UAID universal resolver: UAID -> target DID -> DID-method resolver. * * Policy: * - did:8004 -> use existing on-chain aware loader (loadAgentDetail) * - otherwise -> KB-first details (no on-chain), return empty on-chain sections */ getAgentDetailsByUaidUniversal(uaid: string, options?: { includeRegistration?: boolean; allowOnChain?: boolean; }): Promise; /** * Resolve an agent by its owner account address. * * Strategy: * 1. Try ENS reverse lookup via ENS client (getAgentIdentityByAccount) * 2. If not found, fall back to discovery search by account address * 3. If an agentId is resolved, return fully-hydrated AgentDetail * * Returns null if no agent can be resolved for the given account. */ getAgentByAccount(account: `0x${string}`, chainId?: number): Promise; /** * Extract an agentId from a transaction receipt using the on-chain IdentityRegistry. * Thin wrapper around AgentsAPI.extractAgentIdFromReceipt so apps can call * client.extractAgentIdFromReceipt(...) directly. */ extractAgentIdFromReceipt(receipt: any, chainId?: number): Promise; /** * Revoke a previously submitted feedback entry for an agent. * * This is a high-level helper that: * - resolves the ReputationClient singleton for the given chain * - converts the provided agentId/feedbackIndex into bigint * - calls the underlying ReputationRegistry.revokeFeedback(...) */ revokeFeedback(params: { agentId: string; feedbackIndex: string | number | bigint; chainId?: number; }): Promise<{ txHash: string; }>; /** * Append a response to an existing feedback entry for an agent. * * High-level helper that converts string/number inputs to bigint and delegates * to the ReputationClient's appendToFeedback implementation. */ appendToFeedback(params: { agentId: string; clientAddress: `0x${string}`; feedbackIndex: string | number | bigint; responseUri?: string; responseHash?: `0x${string}`; chainId?: number; }): Promise<{ txHash: string; }>; /** * Get the ENS client singleton * @returns The ENS client instance */ getENSClient(): Promise; getDiscoveryClient(): Promise; /** * Search validation requests for an agent by UAID (or legacy chainId+agentId) */ searchValidationRequestsAdvanced(params: { uaid?: string; chainId?: number; agentId?: string | number; limit?: number; offset?: number; orderBy?: string; orderDirection?: 'ASC' | 'DESC'; }): Promise<{ validationRequests: Array>; } | null>; /** * Search feedback/reviews for an agent by UAID (or legacy chainId+agentId) */ searchFeedbackAdvanced(params: { uaid?: string; chainId?: number; agentId?: string | number; limit?: number; offset?: number; orderBy?: string; orderDirection?: 'ASC' | 'DESC'; }): Promise<{ feedbacks: Array>; } | null>; /** * Verify a signed challenge * Handles all Veramo agent logic internally - no Veramo exposure at app level * * @param auth - The authentication challenge with signature * @param expectedAudience - Expected audience (provider URL) for validation * @returns Verification result with client address if valid */ verifyChallenge(auth: AuthChallenge, expectedAudience: string): Promise; /** * Initialize reputation client from session package * Uses environment variables only (no overrides allowed) * @internal */ private initializeReputationFromSessionPackage; /** * Initialize reputation client from top-level config (identityRegistry and reputationRegistry) * Uses the EOA (Externally Owned Account) derived from the private key * @internal */ private initializeClientReputationFromConfig; /** * Execute a GraphQL query */ query(query: string, variables?: Record): Promise; /** * Execute a GraphQL mutation */ mutate(mutation: string, variables?: Record): Promise; /** * Get the underlying GraphQL client (for advanced usage) */ getGraphQLClient(): GraphQLClient; /** * Update the API key and recreate the client */ setApiKey(apiKey: string): void; /** * Get current configuration */ getConfig(): Readonly; /** * Get the admin EOA address derived from AGENTIC_TRUST_ADMIN_PRIVATE_KEY * @returns The admin's Ethereum address * @throws Error if AGENTIC_TRUST_ADMIN_PRIVATE_KEY is not set or invalid */ getAdminEOAAddress(): Promise<`0x${string}`>; } export {}; //# sourceMappingURL=agenticTrustClient.d.ts.map