diff --git a/plugins/acpPlugin/src/acpClient.ts b/plugins/acpPlugin/src/acpClient.ts index 81073c51..7debf5a0 100644 --- a/plugins/acpPlugin/src/acpClient.ts +++ b/plugins/acpPlugin/src/acpClient.ts @@ -66,6 +66,31 @@ export class AcpClient { })); } + async queryAgent(address: string) { + const baseUrl = + this.agentRepoUrl || "https://acpx-staging.virtuals.io/api/agents"; + + let url = `${baseUrl}?filters[walletAddress][$eq]=${address}`; + + const response = await fetch(url); + if (!response.ok) { + throw new Error( + `Failed to query agent: ${response.status} ${response.statusText}` + ); + } + + const responseJson = await response.json(); + const agents = (responseJson.data as AcpAgent[]).map((agent) => ({ + id: agent.id, + name: agent.name, + description: agent.description, + walletAddress: agent.walletAddress, + twitterHandler: agent.twitterHandle, + offerings: agent.offerings, + })); + return agents.length > 0 ? agents[0] : undefined; + } + async createJob( providerAddress: string, evaluatorAddress: string, diff --git a/plugins/acpPlugin/src/acpPlugin.ts b/plugins/acpPlugin/src/acpPlugin.ts index ecaf3a35..4d9fd876 100644 --- a/plugins/acpPlugin/src/acpPlugin.ts +++ b/plugins/acpPlugin/src/acpPlugin.ts @@ -187,6 +187,10 @@ class AcpPlugin { return serverState; } + public async getAcpClient() { + return this.acpClient; + } + public getWorker(data?: { functions?: GameFunction[]; getEnvironment?: () => Promise>;