mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-11-05 23:29:44 +08:00
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.
27 lines
709 B
Java
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);
|
|
}
|
|
}
|
|
}
|