mateclaw/mateclaw-server/src/main/java/vip/mate/interop/a2a/A2aTaskSweeper.java
matevip 1159dcdbf3 feat(a2a): add agent interoperability protocol support
Add an A2A JSON-RPC endpoint with authenticated message/send, message/stream, tasks/get, and tasks/cancel handling. Expose anonymous minimal Agent Cards while keeping the enabled-agent skills list behind existing Bearer authentication.

Bridge inbound calls into the existing agent runtime, add an in-memory task store with duplicate task rejection, JSON-RPC idempotency snapshots, terminal TTL cleanup, and SSE status/artifact event streaming with heartbeat comments.

Add the call_a2a_agent tool and peer adapter with Agent Card discovery fallback, blocking task polling through tasks/get, event-boundary SSE parsing, response caps, timeout limits, redirect refusal, and private-network SSRF protection.

Wire mateclaw.a2a configuration, document deployment settings in English and Chinese, mirror bundled docs, and cover task storage, JSON-RPC validation, card privacy, lifecycle/cancel behavior, SSE parsing, and outbound guardrails with focused tests.
2026-08-19 05:36:51 -04:00

27 lines
709 B
Java

package vip.mate.interop.a2a;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Slf4j
@Component
@RequiredArgsConstructor
public class A2aTaskSweeper {
private final A2aProperties properties;
private final A2aTaskStore store;
@Scheduled(fixedDelayString = "${mateclaw.a2a.sweep-interval-ms:60000}")
public void sweep() {
if (!properties.isEnabled()) {
return;
}
int removed = store.sweepExpired();
if (removed > 0) {
log.debug("A2A task sweep removed {} expired task(s)", removed);
}
}
}