Event-Driven Architecture
// RECOMMENDED: Use event callbacks for responsive agents
const acpClient = new AcpClient({
acpContractClient: await AcpContractClient.build(/* ... */),
onNewTask: async (job) => {
// Store job state in persistent storage
await storeJobState(job);
// Handle job based on phase
switch (job.phase) {
case AcpJobPhases.NEGOTIATION:
await handleNegotiation(job);
break;
case AcpJobPhases.TRANSACTION:
await handleTransaction(job);
break;
// Handle other phases...
}
}
});Last updated