1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! Interceptors around A2A v1 operations, as a2a-go's call interceptors offer them.
//!
//! An interceptor sees every operation the server handles, on either binding or called
//! directly: `before` the operation it may change the params, answer the call itself, or
//! refuse it; `after` it may change the result, and on a stream (`SendStreamingMessage`,
//! `SubscribeToTask`) it sees each event. Params and results are the operation's JSON
//! shapes (the JSON-RPC `params` and `result`). Interceptors run `before` in the order they
//! were added and `after` in reverse, as layered middleware does.
//!
//! ```rust,ignore
//! struct Audit;
//!
//! #[async_trait::async_trait]
//! impl CallInterceptor for Audit {
//! async fn before(&self, call: &CallContext, params: &mut serde_json::Value)
//! -> Result<Option<serde_json::Value>, A2aError> {
//! tracing::info!(method = call.method, user = ?call.caller.as_ref().map(|c| &c.user_id));
//! Ok(None)
//! }
//! }
//!
//! let server = A2aV1Server::builder(runner_config, base_url).interceptor(Arc::new(Audit)).build();
//! ```
use async_trait;
use Value;
use A2aError;
use crateRequestContext;
/// The operation an interceptor sees.
/// Runs around each A2A v1 operation; see the [module documentation](self). Both methods
/// default to passing the call through.