Skip to main content

vtcode_a2a/
lib.rs

1#![allow(missing_docs, clippy::expect_used, dead_code, unused_imports)]
2//! Agent2Agent (A2A) Protocol support for VT Code.
3
4pub mod agent_card;
5pub mod cli;
6pub mod client;
7pub mod errors;
8pub mod rpc;
9pub mod task_manager;
10pub mod types;
11pub mod webhook;
12
13#[cfg(feature = "a2a-server")]
14pub mod server;
15
16/// Wait for a process shutdown signal and log listener errors.
17#[cfg(feature = "a2a-server")]
18pub async fn shutdown_signal_logged(context: &'static str) {
19    let result = {
20        #[cfg(unix)]
21        {
22            use tokio::signal::unix::{SignalKind, signal};
23            match signal(SignalKind::terminate()) {
24                Ok(mut terminate) => {
25                    tokio::select! {
26                        ctrl_c_result = tokio::signal::ctrl_c() => ctrl_c_result,
27                        _ = terminate.recv() => Ok(()),
28                    }
29                }
30                Err(err) => {
31                    tracing::warn!("Failed to register SIGTERM handler: {err}; falling back to Ctrl-C only");
32                    tokio::signal::ctrl_c().await
33                }
34            }
35        }
36        #[cfg(not(unix))]
37        {
38            tokio::signal::ctrl_c().await
39        }
40    };
41    if let Err(err) = result {
42        tracing::warn!("Failed to listen for {context} shutdown signal: {err}");
43    }
44}
45
46// Re-exports for convenience
47pub use agent_card::{AgentCapabilities, AgentCard, AgentProvider, AgentSkill};
48pub use client::A2aClient;
49pub use errors::{A2aError, A2aErrorCode, A2aResult};
50pub use rpc::{
51    JsonRpcError, JsonRpcRequest, JsonRpcResponse, SendStreamingMessageResponse, StreamingEvent,
52    TaskPushNotificationConfig,
53};
54pub use task_manager::TaskManager;
55pub use types::{Artifact, FileContent, Message, MessageRole, Part, Task, TaskState, TaskStatus};
56pub use webhook::{WebhookError, WebhookNotifier};