Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions plugins/acpPlugin/src/acpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions plugins/acpPlugin/src/acpPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ class AcpPlugin {
return serverState;
}

public async getAcpClient() {
return this.acpClient;
}

public getWorker(data?: {
functions?: GameFunction<any>[];
getEnvironment?: () => Promise<Record<string, any>>;
Expand Down