Skip to main content

par_term_acp/protocol/
initialize.rs

1//! Initialize handshake types for the ACP protocol.
2//!
3//! Covers the `initialize` request/response exchange between host and agent.
4
5use serde::{Deserialize, Serialize};
6
7/// Parameters for the `initialize` request sent from host to agent.
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct InitializeParams {
11    pub protocol_version: u32,
12    pub client_capabilities: ClientCapabilities,
13    pub client_info: ClientInfo,
14}
15
16/// Capabilities the host advertises to the agent.
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(rename_all = "camelCase")]
19pub struct ClientCapabilities {
20    pub fs: FsCapabilities,
21    pub terminal: bool,
22    /// Whether the host supports the `config/update` RPC call.
23    #[serde(default)]
24    pub config: bool,
25}
26
27/// File-system capabilities exposed by the host.
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(rename_all = "camelCase")]
30pub struct FsCapabilities {
31    pub read_text_file: bool,
32    pub write_text_file: bool,
33    #[serde(default)]
34    pub list_directory: bool,
35    #[serde(default)]
36    pub find: bool,
37}
38
39/// Identifying information about the host client.
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(rename_all = "camelCase")]
42pub struct ClientInfo {
43    pub name: String,
44    pub title: String,
45    pub version: String,
46}
47
48/// Result returned by the agent in response to `initialize`.
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(rename_all = "camelCase")]
51pub struct InitializeResult {
52    pub protocol_version: u32,
53    #[serde(skip_serializing_if = "Option::is_none")]
54    pub agent_capabilities: Option<AgentCapabilities>,
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub auth_methods: Option<Vec<AuthMethod>>,
57}
58
59/// Capabilities the agent advertises back to the host.
60#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(rename_all = "camelCase")]
62pub struct AgentCapabilities {
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub load_session: Option<bool>,
65    #[serde(skip_serializing_if = "Option::is_none")]
66    pub prompt_capabilities: Option<PromptCapabilities>,
67}
68
69/// Content modalities the agent can handle in prompts.
70#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(rename_all = "camelCase")]
72pub struct PromptCapabilities {
73    #[serde(skip_serializing_if = "Option::is_none")]
74    pub audio: Option<bool>,
75    #[serde(skip_serializing_if = "Option::is_none")]
76    pub embedded_content: Option<bool>,
77    #[serde(skip_serializing_if = "Option::is_none")]
78    pub image: Option<bool>,
79}
80
81/// An authentication method the agent supports.
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(rename_all = "camelCase")]
84pub struct AuthMethod {
85    pub id: String,
86    pub name: String,
87    #[serde(skip_serializing_if = "Option::is_none")]
88    pub description: Option<String>,
89}