From b166b0c52d3d035f05fedea8a9fa92f83e3a79ed Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Thu, 24 Sep 2026 21:57:15 +0200 Subject: [PATCH] Use explicit ACP v1 namespace aliases --- crates/acp_thread/src/acp_thread.rs | 2074 +++++++++-------- crates/acp_thread/src/connection.rs | 152 +- crates/agent/src/agent.rs | 238 +- crates/agent_ui/src/conversation_view.rs | 999 ++++---- .../src/conversation_view/message_queue.rs | 2 +- .../conversation_view/thread_search_bar.rs | 4 +- .../src/conversation_view/thread_view.rs | 220 +- crates/agent_ui/src/entry_view_state.rs | 42 +- crates/agent_ui/src/message_editor.rs | 210 +- 9 files changed, 2038 insertions(+), 1903 deletions(-) diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rs index 993a30f3f90..9409a68d99f 100644 --- a/crates/acp_thread/src/acp_thread.rs +++ b/crates/acp_thread/src/acp_thread.rs @@ -4,7 +4,7 @@ mod mention; mod terminal; pub use ::terminal::HeadlessTerminal; use action_log::{ActionLog, ActionLogTelemetry}; -use agent_client_protocol::schema::{MaybeUndefined, v1 as acp}; +use agent_client_protocol::schema::{MaybeUndefined, v1 as acp_v1}; use agent_settings::AgentSettings; use anyhow::{Context as _, Result, anyhow}; use collections::HashSet; @@ -67,7 +67,7 @@ impl std::error::Error for MaxOutputTokensError {} pub const TOOL_NAME_META_KEY: &str = "tool_name"; /// Extracts a tool name from the legacy ACP metadata field. -pub fn tool_name_from_meta(meta: &Option) -> Option { +pub fn tool_name_from_meta(meta: &Option) -> Option { meta.as_ref() .and_then(|meta| meta.get(TOOL_NAME_META_KEY)) .and_then(|value| value.as_str()) @@ -75,8 +75,8 @@ pub fn tool_name_from_meta(meta: &Option) -> Option { } /// Creates ACP metadata containing the legacy tool-name field. -pub fn meta_with_tool_name(tool_name: &str) -> acp::Meta { - acp::Meta::from_iter([(TOOL_NAME_META_KEY.into(), tool_name.into())]) +pub fn meta_with_tool_name(tool_name: &str) -> acp_v1::Meta { + acp_v1::Meta::from_iter([(TOOL_NAME_META_KEY.into(), tool_name.into())]) } /// Key used in ACP `AvailableCommand` meta to record which source produced a @@ -111,11 +111,11 @@ impl CommandCategory { } } -pub fn meta_with_command_category(category: CommandCategory) -> acp::Meta { - acp::Meta::from_iter([(COMMAND_CATEGORY_META_KEY.into(), category.as_str().into())]) +pub fn meta_with_command_category(category: CommandCategory) -> acp_v1::Meta { + acp_v1::Meta::from_iter([(COMMAND_CATEGORY_META_KEY.into(), category.as_str().into())]) } -pub fn command_category_from_meta(meta: &Option) -> Option { +pub fn command_category_from_meta(meta: &Option) -> Option { meta.as_ref() .and_then(|m| m.get(COMMAND_CATEGORY_META_KEY)) .and_then(|v| v.as_str()) @@ -195,15 +195,15 @@ pub struct SandboxAuthorizationDetails { pub reason: String, } -pub fn meta_with_sandbox_authorization(details: SandboxAuthorizationDetails) -> acp::Meta { - acp::Meta::from_iter([( +pub fn meta_with_sandbox_authorization(details: SandboxAuthorizationDetails) -> acp_v1::Meta { + acp_v1::Meta::from_iter([( SANDBOX_AUTHORIZATION_META_KEY.into(), serde_json::to_value(details).unwrap_or_default(), )]) } pub fn sandbox_authorization_details_from_meta( - meta: &Option, + meta: &Option, ) -> Option { meta.as_ref() .and_then(|m| m.get(SANDBOX_AUTHORIZATION_META_KEY)) @@ -239,15 +239,15 @@ pub struct SandboxFallbackAuthorizationDetails { pub fn meta_with_sandbox_fallback_authorization( details: SandboxFallbackAuthorizationDetails, -) -> acp::Meta { - acp::Meta::from_iter([( +) -> acp_v1::Meta { + acp_v1::Meta::from_iter([( SANDBOX_FALLBACK_AUTHORIZATION_META_KEY.into(), serde_json::to_value(details).unwrap_or_default(), )]) } pub fn sandbox_fallback_authorization_details_from_meta( - meta: &Option, + meta: &Option, ) -> Option { meta.as_ref() .and_then(|m| m.get(SANDBOX_FALLBACK_AUTHORIZATION_META_KEY)) @@ -260,14 +260,16 @@ pub fn sandbox_fallback_authorization_details_from_meta( /// used to explain the situation to both the user and the agent. pub const SANDBOX_NOT_APPLIED_META_KEY: &str = "sandbox_not_applied"; -pub fn meta_with_sandbox_not_applied(reason: &SandboxNotAppliedReason) -> acp::Meta { - acp::Meta::from_iter([( +pub fn meta_with_sandbox_not_applied(reason: &SandboxNotAppliedReason) -> acp_v1::Meta { + acp_v1::Meta::from_iter([( SANDBOX_NOT_APPLIED_META_KEY.into(), serde_json::to_value(reason).unwrap_or_default(), )]) } -pub fn sandbox_not_applied_from_meta(meta: &Option) -> Option { +pub fn sandbox_not_applied_from_meta( + meta: &Option, +) -> Option { meta.as_ref() .and_then(|m| m.get(SANDBOX_NOT_APPLIED_META_KEY)) .and_then(|v| serde_json::from_value(v.clone()).ok()) @@ -276,7 +278,7 @@ pub fn sandbox_not_applied_from_meta(meta: &Option) -> Option) -> Option { +pub fn subagent_session_info_from_meta(meta: &Option) -> Option { meta.as_ref() .and_then(|m| m.get(SUBAGENT_SESSION_INFO_META_KEY)) .and_then(|v| serde_json::from_value(v.clone()).ok()) @@ -293,7 +295,7 @@ pub fn subagent_session_info_from_meta(meta: &Option) -> Option, + pub protocol_id: Option, pub client_id: Option, pub is_optimistic: bool, pub content: MessageContent, @@ -348,11 +350,11 @@ impl AssistantMessage { #[derive(Debug, PartialEq)] pub enum AssistantMessageChunk { Message { - id: Option, + id: Option, block: MessageContent, }, Thought { - id: Option, + id: Option, block: MessageContent, }, } @@ -381,8 +383,8 @@ impl AssistantMessageChunk { } fn can_merge_message_chunks( - existing: Option<&acp::MessageId>, - incoming: Option<&acp::MessageId>, + existing: Option<&acp_v1::MessageId>, + incoming: Option<&acp_v1::MessageId>, ) -> bool { match (existing, incoming) { (Some(existing), Some(incoming)) => existing == incoming, @@ -406,14 +408,14 @@ pub struct ElicitationEntryId(pub Arc); #[derive(Debug)] pub struct Elicitation { pub id: ElicitationEntryId, - pub request: acp::CreateElicitationRequest, + pub request: acp_v1::CreateElicitationRequest, pub status: ElicitationStatus, } #[derive(Debug)] pub enum ElicitationStatus { Pending { - respond_tx: oneshot::Sender, + respond_tx: oneshot::Sender, }, Accepted, Declined, @@ -446,19 +448,19 @@ impl ElicitationStore { &self.elicitations } - fn validate_request(request: &acp::CreateElicitationRequest) -> Result<(), acp::Error> { + fn validate_request(request: &acp_v1::CreateElicitationRequest) -> Result<(), acp_v1::Error> { match &request.mode { - acp::ElicitationMode::Form(_) => {} - acp::ElicitationMode::Url(mode) => { + acp_v1::ElicitationMode::Form(_) => {} + acp_v1::ElicitationMode::Url(mode) => { let url = url::Url::parse(&mode.url) - .map_err(|_| acp::Error::invalid_params().data("invalid elicitation URL"))?; + .map_err(|_| acp_v1::Error::invalid_params().data("invalid elicitation URL"))?; if !matches!(url.scheme(), "http" | "https") || url.host_str().is_none() { - return Err(acp::Error::invalid_params() + return Err(acp_v1::Error::invalid_params() .data("elicitation URL must use HTTP or HTTPS and include a host")); } } _ => { - return Err(acp::Error::invalid_params().data("unsupported elicitation mode")); + return Err(acp_v1::Error::invalid_params().data("unsupported elicitation mode")); } } @@ -467,10 +469,10 @@ impl ElicitationStore { fn insert_pending_elicitation( &mut self, - request: acp::CreateElicitationRequest, + request: acp_v1::CreateElicitationRequest, ) -> ( ElicitationEntryId, - oneshot::Receiver, + oneshot::Receiver, ) { let (respond_tx, response_rx) = oneshot::channel(); let id = ElicitationEntryId(Uuid::new_v4().to_string().into()); @@ -483,12 +485,12 @@ impl ElicitationStore { } fn response_task( - response_rx: oneshot::Receiver, + response_rx: oneshot::Receiver, cx: &App, - ) -> Task { + ) -> Task { cx.foreground_executor().spawn(async move { response_rx.await.unwrap_or_else(|oneshot::Canceled| { - acp::CreateElicitationResponse::new(acp::ElicitationAction::Cancel) + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Cancel) }) }) } @@ -502,7 +504,7 @@ impl ElicitationStore { fn respond_to_elicitation_entry( elicitation: &mut Elicitation, - response: acp::CreateElicitationResponse, + response: acp_v1::CreateElicitationResponse, ) -> bool { if !matches!(elicitation.status, ElicitationStatus::Pending { .. }) { return false; @@ -537,8 +539,8 @@ impl ElicitationStore { match mem::replace(&mut elicitation.status, ElicitationStatus::Canceled) { ElicitationStatus::Pending { respond_tx } => { if respond_tx - .send(acp::CreateElicitationResponse::new( - acp::ElicitationAction::Cancel, + .send(acp_v1::CreateElicitationResponse::new( + acp_v1::ElicitationAction::Cancel, )) .is_err() { @@ -547,7 +549,7 @@ impl ElicitationStore { Some(ElicitationChange::Responded) } ElicitationStatus::Accepted - if matches!(&elicitation.request.mode, acp::ElicitationMode::Url(_)) => + if matches!(&elicitation.request.mode, acp_v1::ElicitationMode::Url(_)) => { Some(ElicitationChange::Updated) } @@ -561,7 +563,7 @@ impl ElicitationStore { fn respond_to_elicitation_by_id( &mut self, id: &ElicitationEntryId, - response: acp::CreateElicitationResponse, + response: acp_v1::CreateElicitationResponse, ) -> bool { let Some((_, elicitation)) = self.elicitation_mut(id) else { return false; @@ -583,18 +585,18 @@ impl ElicitationStore { pub fn request_elicitation( &mut self, - request: acp::CreateElicitationRequest, + request: acp_v1::CreateElicitationRequest, cx: &mut Context, - ) -> Result, acp::Error> { + ) -> Result, acp_v1::Error> { self.request_elicitation_with_id(request, cx) .map(|(_, task)| task) } pub fn request_elicitation_with_id( &mut self, - request: acp::CreateElicitationRequest, + request: acp_v1::CreateElicitationRequest, cx: &mut Context, - ) -> Result<(ElicitationEntryId, Task), acp::Error> { + ) -> Result<(ElicitationEntryId, Task), acp_v1::Error> { Self::validate_request(&request)?; let (id, response_rx) = self.insert_pending_elicitation(request); cx.emit(ElicitationStoreEvent::ElicitationRequested(id.clone())); @@ -607,7 +609,7 @@ impl ElicitationStore { pub fn respond_to_elicitation( &mut self, id: &ElicitationEntryId, - response: acp::CreateElicitationResponse, + response: acp_v1::CreateElicitationResponse, cx: &mut Context, ) { if !self.respond_to_elicitation_by_id(id, response) { @@ -620,7 +622,7 @@ impl ElicitationStore { pub fn complete_url_elicitation( &mut self, - elicitation_id: &acp::ElicitationId, + elicitation_id: &acp_v1::ElicitationId, cx: &mut Context, ) { let Some(entry_id) = self.entry_id_for_url_elicitation(elicitation_id) else { @@ -665,7 +667,7 @@ impl ElicitationStore { let keep = matches!( (&elicitation.status, &elicitation.request.mode), (ElicitationStatus::Pending { .. }, _) - | (ElicitationStatus::Accepted, acp::ElicitationMode::Url(_)) + | (ElicitationStatus::Accepted, acp_v1::ElicitationMode::Url(_)) ); if !keep { cleared_ids.push(elicitation.id.clone()); @@ -683,11 +685,11 @@ impl ElicitationStore { cleared_ids } - pub fn cancel_request(&mut self, request_id: &acp::RequestId, cx: &mut Context) { + pub fn cancel_request(&mut self, request_id: &acp_v1::RequestId, cx: &mut Context) { let changes = self.cancel_pending(|elicitation| { matches!( elicitation.request.scope(), - acp::ElicitationScope::Request(scope) if &scope.request_id == request_id + acp_v1::ElicitationScope::Request(scope) if &scope.request_id == request_id ) }); for (id, change) in changes { @@ -708,10 +710,10 @@ impl ElicitationStore { fn entry_id_for_url_elicitation( &self, - elicitation_id: &acp::ElicitationId, + elicitation_id: &acp_v1::ElicitationId, ) -> Option { self.elicitations.iter().rev().find_map(|elicitation| { - if let acp::ElicitationMode::Url(mode) = &elicitation.request.mode + if let acp_v1::ElicitationMode::Url(mode) = &elicitation.request.mode && &mode.elicitation_id == elicitation_id { Some(elicitation.id.clone()) @@ -759,14 +761,14 @@ pub enum ContextCompactionStatus { Other(Arc), } -impl From for ContextCompactionStatus { - fn from(status: acp::CompactionStatus) -> Self { +impl From for ContextCompactionStatus { + fn from(status: acp_v1::CompactionStatus) -> Self { match status { - acp::CompactionStatus::InProgress => Self::InProgress, - acp::CompactionStatus::Completed => Self::Completed, - acp::CompactionStatus::Failed => Self::Failed, - acp::CompactionStatus::Cancelled => Self::Canceled, - acp::CompactionStatus::Other(status) => Self::Other(status.into()), + acp_v1::CompactionStatus::InProgress => Self::InProgress, + acp_v1::CompactionStatus::Completed => Self::Completed, + acp_v1::CompactionStatus::Failed => Self::Failed, + acp_v1::CompactionStatus::Cancelled => Self::Canceled, + acp_v1::CompactionStatus::Other(status) => Self::Other(status.into()), _ => Self::Other("unknown".into()), } } @@ -790,7 +792,7 @@ impl ContextCompaction { fn apply_update( &mut self, - update: acp::CompactionUpdate, + update: acp_v1::CompactionUpdate, language_registry: &Arc, cx: &mut App, ) { @@ -820,11 +822,11 @@ impl ContextCompaction { fn append_summary( &mut self, - content: acp::ContentBlock, + content: acp_v1::ContentBlock, language_registry: &Arc, cx: &mut App, ) { - if let acp::ContentBlock::Text(text) = &content + if let acp_v1::ContentBlock::Text(text) = &content && let Some(markdown) = self.summary.last().and_then(ContentBlock::plain_markdown) { markdown.update(cx, |markdown, cx| markdown.append(&text.text, cx)); @@ -916,7 +918,7 @@ impl AgentThreadEntry { } } - pub fn location(&self, ix: usize) -> Option<(acp::ToolCallLocation, AgentLocation)> { + pub fn location(&self, ix: usize) -> Option<(acp_v1::ToolCallLocation, AgentLocation)> { if let AgentThreadEntry::ToolCall(ToolCall { locations, resolved_locations, @@ -935,13 +937,13 @@ impl AgentThreadEntry { #[derive(Debug)] pub struct ToolCall { - pub id: acp::ToolCallId, + pub id: acp_v1::ToolCallId, pub label: Entity, title: Option, - pub kind: acp::ToolKind, + pub kind: acp_v1::ToolKind, pub content: Vec, pub status: ToolCallStatus, - pub locations: Vec, + pub locations: Vec, pub resolved_locations: Vec>, pub raw_input: Option, pub raw_input_markdown: Option>, @@ -958,10 +960,10 @@ pub struct ToolCall { impl ToolCall { fn from_acp( - tool_call: acp::ToolCall, + tool_call: acp_v1::ToolCall, status: ToolCallStatus, language_registry: Arc, - terminals: &HashMap>, + terminals: &HashMap>, cx: &mut App, ) -> Result { let title = @@ -1024,7 +1026,7 @@ impl ToolCall { fn label_text( title: Option<&SharedString>, tool_name: Option<&SharedString>, - kind: acp::ToolKind, + kind: acp_v1::ToolKind, ) -> SharedString { let Some(title) = title else { return tool_name @@ -1033,9 +1035,9 @@ impl ToolCall { .unwrap_or_else(|| "Tool call".into()); }; - if kind == acp::ToolKind::Execute { + if kind == acp_v1::ToolKind::Execute { title.clone() - } else if kind == acp::ToolKind::Edit { + } else if kind == acp_v1::ToolKind::Edit { MarkdownEscaped(title).to_string().into() } else if let Some((first_line, _)) = title.split_once('\n') { (first_line.to_owned() + "…").into() @@ -1047,13 +1049,13 @@ impl ToolCall { fn new_label( title: Option<&SharedString>, tool_name: Option<&SharedString>, - kind: acp::ToolKind, + kind: acp_v1::ToolKind, language_registry: Arc, cx: &mut App, ) -> Entity { let text = Self::label_text(title, tool_name, kind); cx.new(|cx| { - if title.is_none() || kind == acp::ToolKind::Execute { + if title.is_none() || kind == acp_v1::ToolKind::Execute { Markdown::new_text(text, cx) } else { Markdown::new(text, Some(language_registry), None, cx) @@ -1063,13 +1065,13 @@ impl ToolCall { fn update_fields( &mut self, - fields: acp::ToolCallUpdateFields, - meta: Option, + fields: acp_v1::ToolCallUpdateFields, + meta: Option, language_registry: Arc, - terminals: &HashMap>, + terminals: &HashMap>, cx: &mut App, ) -> Result<()> { - let acp::ToolCallUpdateFields { + let acp_v1::ToolCallUpdateFields { kind, status, title, @@ -1081,7 +1083,7 @@ impl ToolCall { .. } = fields; - let was_plain_text = self.title.is_none() || self.kind == acp::ToolKind::Execute; + let was_plain_text = self.title.is_none() || self.kind == acp_v1::ToolKind::Execute; let mut label_changed = title.is_some() || kind.is_some(); if let Some(kind) = kind { self.kind = kind; @@ -1120,7 +1122,7 @@ impl ToolCall { if let Some(title) = title { self.title = Some(SharedString::from(title)).filter(|title| !title.trim().is_empty()); - if self.kind == acp::ToolKind::Execute + if self.kind == acp_v1::ToolKind::Execute && let Some(title) = &self.title { // A missing tool title must not overwrite an actual terminal command. @@ -1132,7 +1134,7 @@ impl ToolCall { } } if label_changed { - let is_plain_text = self.title.is_none() || self.kind == acp::ToolKind::Execute; + let is_plain_text = self.title.is_none() || self.kind == acp_v1::ToolKind::Execute; if was_plain_text != is_plain_text { self.label = Self::new_label( self.title.as_ref(), @@ -1199,21 +1201,23 @@ impl ToolCall { fn update_status(&mut self, status: ToolCallStatus) { match status { - ToolCallStatus::Pending => self.update_acp_status(acp::ToolCallStatus::Pending), - ToolCallStatus::InProgress => self.update_acp_status(acp::ToolCallStatus::InProgress), - ToolCallStatus::Completed => self.update_acp_status(acp::ToolCallStatus::Completed), - ToolCallStatus::Failed => self.update_acp_status(acp::ToolCallStatus::Failed), + ToolCallStatus::Pending => self.update_acp_status(acp_v1::ToolCallStatus::Pending), + ToolCallStatus::InProgress => { + self.update_acp_status(acp_v1::ToolCallStatus::InProgress) + } + ToolCallStatus::Completed => self.update_acp_status(acp_v1::ToolCallStatus::Completed), + ToolCallStatus::Failed => self.update_acp_status(acp_v1::ToolCallStatus::Failed), status @ (ToolCallStatus::WaitingForConfirmation { .. } | ToolCallStatus::Rejected | ToolCallStatus::Canceled) => self.status = status, } } - fn update_acp_status(&mut self, status: acp::ToolCallStatus) { + fn update_acp_status(&mut self, status: acp_v1::ToolCallStatus) { if let ToolCallStatus::WaitingForConfirmation { current_status, .. } = &mut self.status && matches!( status, - acp::ToolCallStatus::Pending | acp::ToolCallStatus::InProgress + acp_v1::ToolCallStatus::Pending | acp_v1::ToolCallStatus::InProgress ) { *current_status = status; @@ -1259,7 +1263,7 @@ impl ToolCall { } async fn resolve_location( - location: acp::ToolCallLocation, + location: acp_v1::ToolCallLocation, project: WeakEntity, cx: &mut AsyncApp, ) -> Option { @@ -1334,13 +1338,16 @@ pub enum SelectedPermissionParams { #[derive(Debug, Clone)] pub struct SelectedPermissionOutcome { - pub option_id: acp::PermissionOptionId, - pub option_kind: acp::PermissionOptionKind, + pub option_id: acp_v1::PermissionOptionId, + pub option_kind: acp_v1::PermissionOptionKind, pub params: Option, } impl SelectedPermissionOutcome { - pub fn new(option_id: acp::PermissionOptionId, option_kind: acp::PermissionOptionKind) -> Self { + pub fn new( + option_id: acp_v1::PermissionOptionId, + option_kind: acp_v1::PermissionOptionKind, + ) -> Self { Self { option_id, option_kind, @@ -1354,7 +1361,7 @@ impl SelectedPermissionOutcome { } } -impl From for acp::SelectedPermissionOutcome { +impl From for acp_v1::SelectedPermissionOutcome { fn from(value: SelectedPermissionOutcome) -> Self { Self::new(value.option_id) } @@ -1367,7 +1374,7 @@ pub enum RequestPermissionOutcome { Selected(SelectedPermissionOutcome), } -impl From for acp::RequestPermissionOutcome { +impl From for acp_v1::RequestPermissionOutcome { fn from(value: RequestPermissionOutcome) -> Self { match value { RequestPermissionOutcome::Cancelled @@ -1400,7 +1407,7 @@ pub enum ToolCallStatus { Pending, /// The tool call is waiting for confirmation from the user. WaitingForConfirmation { - current_status: acp::ToolCallStatus, + current_status: acp_v1::ToolCallStatus, options: PermissionOptions, respond_tx: oneshot::Sender, kind: AuthorizationKind, @@ -1417,31 +1424,31 @@ pub enum ToolCallStatus { Canceled, } -impl From for ToolCallStatus { - fn from(status: acp::ToolCallStatus) -> Self { +impl From for ToolCallStatus { + fn from(status: acp_v1::ToolCallStatus) -> Self { match status { - acp::ToolCallStatus::Pending => Self::Pending, - acp::ToolCallStatus::InProgress => Self::InProgress, - acp::ToolCallStatus::Completed => Self::Completed, - acp::ToolCallStatus::Failed => Self::Failed, + acp_v1::ToolCallStatus::Pending => Self::Pending, + acp_v1::ToolCallStatus::InProgress => Self::InProgress, + acp_v1::ToolCallStatus::Completed => Self::Completed, + acp_v1::ToolCallStatus::Failed => Self::Failed, _ => Self::Pending, } } } impl ToolCallStatus { - fn as_acp_status(&self) -> Option { + fn as_acp_status(&self) -> Option { match self { - ToolCallStatus::Pending => Some(acp::ToolCallStatus::Pending), + ToolCallStatus::Pending => Some(acp_v1::ToolCallStatus::Pending), ToolCallStatus::WaitingForConfirmation { current_status, .. } => Some(*current_status), - ToolCallStatus::InProgress => Some(acp::ToolCallStatus::InProgress), - ToolCallStatus::Completed => Some(acp::ToolCallStatus::Completed), - ToolCallStatus::Failed => Some(acp::ToolCallStatus::Failed), + ToolCallStatus::InProgress => Some(acp_v1::ToolCallStatus::InProgress), + ToolCallStatus::Completed => Some(acp_v1::ToolCallStatus::Completed), + ToolCallStatus::Failed => Some(acp_v1::ToolCallStatus::Failed), ToolCallStatus::Rejected | ToolCallStatus::Canceled => None, } } - fn status_after_permission_grant(status: acp::ToolCallStatus) -> ToolCallStatus { + fn status_after_permission_grant(status: acp_v1::ToolCallStatus) -> ToolCallStatus { match ToolCallStatus::from(status) { ToolCallStatus::Pending => ToolCallStatus::InProgress, status => status, @@ -1467,18 +1474,20 @@ impl Display for ToolCallStatus { } } -fn elicitation_status_for_response(response: &acp::CreateElicitationResponse) -> ElicitationStatus { +fn elicitation_status_for_response( + response: &acp_v1::CreateElicitationResponse, +) -> ElicitationStatus { match &response.action { - acp::ElicitationAction::Accept(_) => ElicitationStatus::Accepted, - acp::ElicitationAction::Decline => ElicitationStatus::Declined, - acp::ElicitationAction::Cancel => ElicitationStatus::Canceled, + acp_v1::ElicitationAction::Accept(_) => ElicitationStatus::Accepted, + acp_v1::ElicitationAction::Decline => ElicitationStatus::Declined, + acp_v1::ElicitationAction::Cancel => ElicitationStatus::Canceled, _ => ElicitationStatus::Canceled, } } #[derive(Debug, Default, PartialEq)] pub struct MessageContent { - source_blocks: Vec, + source_blocks: Vec, blocks: Vec, } @@ -1490,7 +1499,7 @@ struct RenderedMessageBlock { impl MessageContent { pub fn new( - block: acp::ContentBlock, + block: acp_v1::ContentBlock, language_registry: &Arc, path_style: PathStyle, cx: &mut App, @@ -1501,7 +1510,7 @@ impl MessageContent { } /// Original content blocks, including text not yet revealed by streaming. - pub fn source_blocks(&self) -> &[acp::ContentBlock] { + pub fn source_blocks(&self) -> &[acp_v1::ContentBlock] { &self.source_blocks } @@ -1542,7 +1551,7 @@ impl MessageContent { pub fn append( &mut self, - block: acp::ContentBlock, + block: acp_v1::ContentBlock, language_registry: &Arc, path_style: PathStyle, cx: &mut App, @@ -1553,14 +1562,14 @@ impl MessageContent { fn append_rendered( &mut self, - block: &acp::ContentBlock, + block: &acp_v1::ContentBlock, language_registry: &Arc, path_style: PathStyle, cx: &mut App, ) { match block { - acp::ContentBlock::Text(text) => self.append_text(&text.text, language_registry, cx), - acp::ContentBlock::ResourceLink(resource) => { + acp_v1::ContentBlock::Text(text) => self.append_text(&text.text, language_registry, cx), + acp_v1::ContentBlock::ResourceLink(resource) => { let mut text = ContentBlock::resource_link_md(&resource.uri, path_style); if self.blocks.is_empty() { // Legacy leading links separated the next chunk. Include that separator @@ -1599,15 +1608,15 @@ impl MessageContent { } } - fn append_deferred_text(&mut self, text: acp::TextContent) -> usize { + fn append_deferred_text(&mut self, text: acp_v1::TextContent) -> usize { let index = self.source_blocks.len(); - self.source_blocks.push(acp::ContentBlock::Text(text)); + self.source_blocks.push(acp_v1::ContentBlock::Text(text)); index } fn append_prompt( &mut self, - block: acp::ContentBlock, + block: acp_v1::ContentBlock, language_registry: &Arc, path_style: PathStyle, cx: &mut App, @@ -1615,10 +1624,10 @@ impl MessageContent { // Prompt text resources are mentions, not output previews. Keep their text // inline while retaining the original payloads in the source blocks. match &block { - acp::ContentBlock::Resource(resource) + acp_v1::ContentBlock::Resource(resource) if matches!( resource.resource, - acp::EmbeddedResourceResource::TextResourceContents(_) + acp_v1::EmbeddedResourceResource::TextResourceContents(_) ) => { let text = ContentBlock::embedded_resource_string_contents(resource, path_style); @@ -1633,7 +1642,7 @@ impl MessageContent { #[derive(Debug, PartialEq, Clone)] pub struct ContentBlock { render: RenderBlock, - source: Option, + source: Option, } #[derive(Debug, PartialEq, Clone)] @@ -1657,7 +1666,7 @@ enum RenderBlock { #[derive(Clone, Copy)] pub struct ContentBlockView<'a> { render: &'a RenderBlock, - source: Option<&'a acp::ContentBlock>, + source: Option<&'a acp_v1::ContentBlock>, } impl ContentBlock { @@ -1676,17 +1685,17 @@ impl ContentBlock { } #[cfg(test)] - fn unsupported_content(&self) -> Option<&acp::ContentBlock> { + fn unsupported_content(&self) -> Option<&acp_v1::ContentBlock> { self.as_view().unsupported_content() } pub fn new_output( - block: acp::ContentBlock, + block: acp_v1::ContentBlock, language_registry: &Arc, cx: &mut App, ) -> Self { match block { - acp::ContentBlock::Text(text) => { + acp_v1::ContentBlock::Text(text) => { Self::create_markdown_block(text.text, language_registry, cx) } block => { @@ -1703,19 +1712,19 @@ impl ContentBlock { } fn render_from_source( - block: &acp::ContentBlock, + block: &acp_v1::ContentBlock, language_registry: &Arc, cx: &mut App, ) -> RenderBlock { match block { - acp::ContentBlock::Resource(resource) => { + acp_v1::ContentBlock::Resource(resource) => { if let Some((image, dimensions)) = Self::decode_embedded_resource_image(resource) { return RenderBlock::Image { image, dimensions }; } if matches!( &resource.resource, - acp::EmbeddedResourceResource::TextResourceContents(_) - | acp::EmbeddedResourceResource::BlobResourceContents(_) + acp_v1::EmbeddedResourceResource::TextResourceContents(_) + | acp_v1::EmbeddedResourceResource::BlobResourceContents(_) ) { let markdown = Self::embedded_resource_markdown(resource, language_registry, cx); @@ -1724,7 +1733,7 @@ impl ContentBlock { Self::unsupported(block, language_registry, cx) } } - acp::ContentBlock::Image(image) => { + acp_v1::ContentBlock::Image(image) => { if let Some((image, dimensions)) = Self::decode_image(image) { RenderBlock::Image { image, dimensions } } else { @@ -1737,8 +1746,8 @@ impl ContentBlock { } } } - acp::ContentBlock::ResourceLink(_) => RenderBlock::ResourceLink, - acp::ContentBlock::Text(text) => RenderBlock::Markdown { + acp_v1::ContentBlock::ResourceLink(_) => RenderBlock::ResourceLink, + acp_v1::ContentBlock::Text(text) => RenderBlock::Markdown { markdown: Self::create_markdown(text.text.clone(), language_registry, cx), }, _ => Self::unsupported(block, language_registry, cx), @@ -1746,11 +1755,11 @@ impl ContentBlock { } fn unsupported( - content: &acp::ContentBlock, + content: &acp_v1::ContentBlock, language_registry: &Arc, cx: &mut App, ) -> RenderBlock { - let description = if matches!(content, acp::ContentBlock::Audio(_)) { + let description = if matches!(content, acp_v1::ContentBlock::Audio(_)) { "Audio content is not supported." } else { "This content is not supported." @@ -1768,11 +1777,11 @@ impl ContentBlock { /// /// Recreating the entity on every streamed snapshot causes the rendered /// element to tear down and rebuild, which flickers badly. - pub fn update_text_in_place(&mut self, block: &acp::ContentBlock, cx: &mut App) -> bool { + pub fn update_text_in_place(&mut self, block: &acp_v1::ContentBlock, cx: &mut App) -> bool { let RenderBlock::Markdown { markdown } = &self.render else { return false; }; - let acp::ContentBlock::Text(text_content) = block else { + let acp_v1::ContentBlock::Text(text_content) = block else { return false; }; let new_content = &text_content.text; @@ -1788,15 +1797,16 @@ impl ContentBlock { } fn decode_image( - image_content: &acp::ImageContent, + image_content: &acp_v1::ImageContent, ) -> Option<(Arc, Option>)> { Self::decode_image_data(&image_content.data, &image_content.mime_type) } fn decode_embedded_resource_image( - resource: &acp::EmbeddedResource, + resource: &acp_v1::EmbeddedResource, ) -> Option<(Arc, Option>)> { - let acp::EmbeddedResourceResource::BlobResourceContents(blob) = &resource.resource else { + let acp_v1::EmbeddedResourceResource::BlobResourceContents(blob) = &resource.resource + else { return None; }; let mime_type = blob.mime_type.as_deref()?; @@ -1870,20 +1880,20 @@ impl ContentBlock { } fn embedded_resource_markdown( - resource: &acp::EmbeddedResource, + resource: &acp_v1::EmbeddedResource, language_registry: &Arc, cx: &mut App, ) -> Option> { match &resource.resource { - acp::EmbeddedResourceResource::TextResourceContents(text) => Some( + acp_v1::EmbeddedResourceResource::TextResourceContents(text) => Some( Self::create_markdown(Self::text_resource_markdown(text), language_registry, cx), ), - acp::EmbeddedResourceResource::BlobResourceContents(_) => None, + acp_v1::EmbeddedResourceResource::BlobResourceContents(_) => None, _ => None, } } - fn text_resource_markdown(resource: &acp::TextResourceContents) -> String { + fn text_resource_markdown(resource: &acp_v1::TextResourceContents) -> String { match text_resource_render_mode(resource.mime_type.as_deref()) { TextResourceRenderMode::Markdown => resource.text.clone(), TextResourceRenderMode::CodeBlock(language) => { @@ -1930,7 +1940,7 @@ impl ContentBlock { impl<'a> ContentBlockView<'a> { #[cfg(test)] - fn unsupported_content(&self) -> Option<&'a acp::ContentBlock> { + fn unsupported_content(&self) -> Option<&'a acp_v1::ContentBlock> { match self.render { RenderBlock::Unsupported { .. } => self.source, _ => None, @@ -1945,7 +1955,7 @@ impl<'a> ContentBlockView<'a> { RenderBlock::EmbeddedResource { .. } => { self.embedded_resource() .and_then(|(resource, _)| match &resource.resource { - acp::EmbeddedResourceResource::TextResourceContents(text) => { + acp_v1::EmbeddedResourceResource::TextResourceContents(text) => { Some(text.text.as_str()) } _ => None, @@ -1983,32 +1993,32 @@ impl ContentBlock { } fn embedded_resource_string_contents( - resource: &acp::EmbeddedResource, + resource: &acp_v1::EmbeddedResource, path_style: PathStyle, ) -> String { match &resource.resource { - acp::EmbeddedResourceResource::TextResourceContents(text) => { + acp_v1::EmbeddedResourceResource::TextResourceContents(text) => { Self::resource_link_md(&text.uri, path_style) } - acp::EmbeddedResourceResource::BlobResourceContents(blob) => { + acp_v1::EmbeddedResourceResource::BlobResourceContents(blob) => { Self::resource_link_md(&blob.uri, path_style) } _ => String::new(), } } - fn embedded_resource_text(resource: &acp::EmbeddedResource) -> &str { + fn embedded_resource_text(resource: &acp_v1::EmbeddedResource) -> &str { match &resource.resource { - acp::EmbeddedResourceResource::TextResourceContents(text) => &text.text, - acp::EmbeddedResourceResource::BlobResourceContents(blob) => &blob.uri, + acp_v1::EmbeddedResourceResource::TextResourceContents(text) => &text.text, + acp_v1::EmbeddedResourceResource::BlobResourceContents(blob) => &blob.uri, _ => "", } } - fn embedded_resource_label(resource: &acp::EmbeddedResource) -> &str { + fn embedded_resource_label(resource: &acp_v1::EmbeddedResource) -> &str { match &resource.resource { - acp::EmbeddedResourceResource::TextResourceContents(text) => &text.uri, - acp::EmbeddedResourceResource::BlobResourceContents(blob) => &blob.uri, + acp_v1::EmbeddedResourceResource::TextResourceContents(text) => &text.uri, + acp_v1::EmbeddedResourceResource::BlobResourceContents(blob) => &blob.uri, _ => "", } } @@ -2017,10 +2027,12 @@ impl ContentBlock { impl<'a> ContentBlockView<'a> { pub fn embedded_resource( &self, - ) -> Option<(&'a acp::EmbeddedResource, Option<&'a Entity>)> { + ) -> Option<(&'a acp_v1::EmbeddedResource, Option<&'a Entity>)> { match &self.render { RenderBlock::EmbeddedResource { markdown } => match self.source { - Some(acp::ContentBlock::Resource(resource)) => Some((resource, markdown.as_ref())), + Some(acp_v1::ContentBlock::Resource(resource)) => { + Some((resource, markdown.as_ref())) + } _ => None, }, _ => None, @@ -2059,7 +2071,7 @@ impl<'a> ContentBlockView<'a> { } } RenderBlock::ResourceLink => match self.source { - Some(acp::ContentBlock::ResourceLink(resource_link)) => &resource_link.uri, + Some(acp_v1::ContentBlock::ResourceLink(resource_link)) => &resource_link.uri, _ => "", }, RenderBlock::Image { .. } => "`Image`", @@ -2076,10 +2088,10 @@ impl<'a> ContentBlockView<'a> { } } - pub fn resource_link(&self) -> Option<&'a acp::ResourceLink> { + pub fn resource_link(&self) -> Option<&'a acp_v1::ResourceLink> { match &self.render { RenderBlock::ResourceLink => match self.source { - Some(acp::ContentBlock::ResourceLink(resource_link)) => Some(resource_link), + Some(acp_v1::ContentBlock::ResourceLink(resource_link)) => Some(resource_link), _ => None, }, _ => None, @@ -2158,16 +2170,16 @@ pub enum ToolCallContent { impl ToolCallContent { pub fn from_acp( - content: acp::ToolCallContent, + content: acp_v1::ToolCallContent, language_registry: Arc, - terminals: &HashMap>, + terminals: &HashMap>, cx: &mut App, ) -> Result> { match content { - acp::ToolCallContent::Content(acp::Content { content, .. }) => Ok(Some( + acp_v1::ToolCallContent::Content(acp_v1::Content { content, .. }) => Ok(Some( Self::ContentBlock(ContentBlock::new_output(content, &language_registry, cx)), )), - acp::ToolCallContent::Diff(diff) => Ok(Some(Self::Diff(cx.new(|cx| { + acp_v1::ToolCallContent::Diff(diff) => Ok(Some(Self::Diff(cx.new(|cx| { Diff::finalized( diff.path.to_string_lossy().into_owned(), diff.old_text, @@ -2176,7 +2188,7 @@ impl ToolCallContent { cx, ) })))), - acp::ToolCallContent::Terminal(acp::Terminal { terminal_id, .. }) => terminals + acp_v1::ToolCallContent::Terminal(acp_v1::Terminal { terminal_id, .. }) => terminals .get(&terminal_id) .cloned() .map(|terminal| Some(Self::Terminal(terminal))) @@ -2187,16 +2199,16 @@ impl ToolCallContent { pub fn update_from_acp( &mut self, - new: acp::ToolCallContent, + new: acp_v1::ToolCallContent, language_registry: Arc, - terminals: &HashMap>, + terminals: &HashMap>, cx: &mut App, ) -> Result { // Update streaming text in place so the rendered markdown element is // reused across snapshots instead of being recreated (which flickers). if let ( Self::ContentBlock(block), - acp::ToolCallContent::Content(acp::Content { content, .. }), + acp_v1::ToolCallContent::Content(acp_v1::Content { content, .. }), ) = (&mut *self, &new) && block.update_text_in_place(content, cx) { @@ -2204,7 +2216,7 @@ impl ToolCallContent { } let needs_update = match (&self, &new) { - (Self::Diff(old_diff), acp::ToolCallContent::Diff(new_diff)) => { + (Self::Diff(old_diff), acp_v1::ToolCallContent::Diff(new_diff)) => { old_diff.read(cx).needs_update( new_diff.old_text.as_deref().unwrap_or(""), &new_diff.new_text, @@ -2242,13 +2254,13 @@ impl ToolCallContent { #[derive(Debug, PartialEq)] pub enum ToolCallUpdate { - UpdateFields(acp::ToolCallUpdate), + UpdateFields(acp_v1::ToolCallUpdate), UpdateDiff(ToolCallUpdateDiff), UpdateTerminal(ToolCallUpdateTerminal), } impl ToolCallUpdate { - fn id(&self) -> &acp::ToolCallId { + fn id(&self) -> &acp_v1::ToolCallId { match self { Self::UpdateFields(update) => &update.tool_call_id, Self::UpdateDiff(diff) => &diff.id, @@ -2257,8 +2269,8 @@ impl ToolCallUpdate { } } -impl From for ToolCallUpdate { - fn from(update: acp::ToolCallUpdate) -> Self { +impl From for ToolCallUpdate { + fn from(update: acp_v1::ToolCallUpdate) -> Self { Self::UpdateFields(update) } } @@ -2271,7 +2283,7 @@ impl From for ToolCallUpdate { #[derive(Debug, PartialEq)] pub struct ToolCallUpdateDiff { - pub id: acp::ToolCallId, + pub id: acp_v1::ToolCallId, pub diff: Entity, } @@ -2283,7 +2295,7 @@ impl From for ToolCallUpdate { #[derive(Debug, PartialEq)] pub struct ToolCallUpdateTerminal { - pub id: acp::ToolCallId, + pub id: acp_v1::ToolCallId, pub terminal: Entity, } @@ -2313,14 +2325,14 @@ impl Plan { for entry in &self.entries { match &entry.status { - acp::PlanEntryStatus::Pending => { + acp_v1::PlanEntryStatus::Pending => { stats.pending += 1; } - acp::PlanEntryStatus::InProgress => { + acp_v1::PlanEntryStatus::InProgress => { stats.in_progress_entry = stats.in_progress_entry.or(Some(entry)); stats.pending += 1; } - acp::PlanEntryStatus::Completed => { + acp_v1::PlanEntryStatus::Completed => { stats.completed += 1; } _ => {} @@ -2334,12 +2346,12 @@ impl Plan { #[derive(Debug)] pub struct PlanEntry { pub content: Entity, - pub priority: acp::PlanEntryPriority, - pub status: acp::PlanEntryStatus, + pub priority: acp_v1::PlanEntryPriority, + pub status: acp_v1::PlanEntryStatus, } impl PlanEntry { - pub fn from_acp(entry: acp::PlanEntry, cx: &mut App) -> Self { + pub fn from_acp(entry: acp_v1::PlanEntry, cx: &mut App) -> Self { Self { content: cx.new(|cx| Markdown::new(entry.content.into(), None, None, cx)), priority: entry.priority, @@ -2403,16 +2415,16 @@ pub struct RetryStatus { pub max_attempts: usize, pub started_at: Instant, pub duration: Duration, - pub meta: Option, + pub meta: Option, } pub const REFUSAL_FALLBACK_MODEL_META_KEY: &str = "refusal_fallback_model"; -pub fn meta_with_refusal_fallback(model_name: &str) -> acp::Meta { - acp::Meta::from_iter([(REFUSAL_FALLBACK_MODEL_META_KEY.into(), model_name.into())]) +pub fn meta_with_refusal_fallback(model_name: &str) -> acp_v1::Meta { + acp_v1::Meta::from_iter([(REFUSAL_FALLBACK_MODEL_META_KEY.into(), model_name.into())]) } -pub fn refusal_fallback_model_from_meta(meta: &Option) -> Option { +pub fn refusal_fallback_model_from_meta(meta: &Option) -> Option { meta.as_ref() .and_then(|m| m.get(REFUSAL_FALLBACK_MODEL_META_KEY)) .and_then(|v| v.as_str()) @@ -2426,14 +2438,14 @@ struct RunningTurn { } pub struct AcpThread { - session_id: acp::SessionId, + session_id: acp_v1::SessionId, work_dirs: Option, - parent_session_id: Option, + parent_session_id: Option, title: Option, provisional_title: Option, entries: Vec, // Notices stay with the live session, but never enter conversation history or exports. - notices: Vec<(usize, acp::Notice)>, + notices: Vec<(usize, acp_v1::Notice)>, next_notice_id: usize, elicitations: ElicitationStore, plan: Plan, @@ -2447,16 +2459,16 @@ pub struct AcpThread { connection: Rc, token_usage: Option, cost: Option, - prompt_capabilities: acp::PromptCapabilities, - available_commands: Vec, + prompt_capabilities: acp_v1::PromptCapabilities, + available_commands: Vec, _observe_prompt_capabilities: Task>, _idle_sleep_subscriptions: Vec, - terminals: HashMap>, - pending_terminal_output: HashMap>>, - pending_terminal_exit: HashMap, + terminals: HashMap>, + pending_terminal_output: HashMap>>, + pending_terminal_exit: HashMap, had_error: bool, /// The user's unsent prompt text, persisted so it can be restored when reloading the thread. - draft_prompt: Option>, + draft_prompt: Option>, /// The initial scroll position for the thread view, set during session registration. ui_scroll_position: Option, /// A cursor over retained source, rather than a second text store, lets the UI @@ -2480,11 +2492,11 @@ struct TextCursor { } impl TextCursor { - fn take(&mut self, sources: &[acp::ContentBlock], max_bytes: usize) -> Option { + fn take(&mut self, sources: &[acp_v1::ContentBlock], max_bytes: usize) -> Option { let max_bytes = max_bytes.min(self.pending_bytes); let mut revealed = String::with_capacity(max_bytes); while revealed.len() < max_bytes { - let acp::ContentBlock::Text(text) = sources.get(self.source_index)? else { + let acp_v1::ContentBlock::Text(text) = sources.get(self.source_index)? else { return None; }; let pending = text.text.get(self.byte_offset..)?; @@ -2571,21 +2583,21 @@ pub enum AcpThreadEvent { TokenUsageUpdated, EntryUpdated(usize), EntriesRemoved(Range), - ToolAuthorizationRequested(acp::ToolCallId), - ToolAuthorizationReceived(acp::ToolCallId), + ToolAuthorizationRequested(acp_v1::ToolCallId), + ToolAuthorizationReceived(acp_v1::ToolCallId), ElicitationRequested(ElicitationEntryId), /// The request left `Pending`; this does not imply delivery to its response waiter. ElicitationResponded(ElicitationEntryId), Retry(RetryStatus), - SubagentSpawned(acp::SessionId), - Stopped(acp::StopReason), + SubagentSpawned(acp_v1::SessionId), + Stopped(acp_v1::StopReason), Error, LoadError(LoadError), PromptCapabilitiesUpdated, Refusal, - AvailableCommandsUpdated(Vec), - ModeUpdated(acp::SessionModeId), - ConfigOptionsUpdated(Vec), + AvailableCommandsUpdated(Vec), + ModeUpdated(acp_v1::SessionModeId), + ConfigOptionsUpdated(Vec), WorkingDirectoriesUpdated, } @@ -2594,39 +2606,39 @@ impl EventEmitter for AcpThread {} #[derive(Debug, Clone)] pub enum TerminalProviderEvent { Created { - terminal_id: acp::TerminalId, + terminal_id: acp_v1::TerminalId, label: String, cwd: Option, output_byte_limit: Option, terminal: Entity<::terminal::Terminal>, }, Output { - terminal_id: acp::TerminalId, + terminal_id: acp_v1::TerminalId, data: Vec, }, TitleChanged { - terminal_id: acp::TerminalId, + terminal_id: acp_v1::TerminalId, title: String, }, Exit { - terminal_id: acp::TerminalId, - status: acp::TerminalExitStatus, + terminal_id: acp_v1::TerminalId, + status: acp_v1::TerminalExitStatus, }, } #[derive(Debug, Clone)] pub enum TerminalProviderCommand { WriteInput { - terminal_id: acp::TerminalId, + terminal_id: acp_v1::TerminalId, bytes: Vec, }, Resize { - terminal_id: acp::TerminalId, + terminal_id: acp_v1::TerminalId, cols: u16, rows: u16, }, Close { - terminal_id: acp::TerminalId, + terminal_id: acp_v1::TerminalId, }, } @@ -2675,14 +2687,14 @@ impl Error for LoadError {} impl AcpThread { pub fn new( - parent_session_id: Option, + parent_session_id: Option, title: Option, work_dirs: Option, connection: Rc, project: Entity, action_log: Entity, - session_id: acp::SessionId, - mut prompt_capabilities_rx: watch::Receiver, + session_id: acp_v1::SessionId, + mut prompt_capabilities_rx: watch::Receiver, cx: &mut Context, ) -> Self { let prompt_capabilities = prompt_capabilities_rx.borrow().clone(); @@ -2779,15 +2791,15 @@ impl AcpThread { } } - pub fn parent_session_id(&self) -> Option<&acp::SessionId> { + pub fn parent_session_id(&self) -> Option<&acp_v1::SessionId> { self.parent_session_id.as_ref() } - pub fn prompt_capabilities(&self) -> acp::PromptCapabilities { + pub fn prompt_capabilities(&self) -> acp_v1::PromptCapabilities { self.prompt_capabilities.clone() } - pub fn available_commands(&self) -> &[acp::AvailableCommand] { + pub fn available_commands(&self) -> &[acp_v1::AvailableCommand] { &self.available_commands } @@ -2795,13 +2807,13 @@ impl AcpThread { self.entries().is_empty() } - pub fn draft_prompt(&self) -> Option<&[acp::ContentBlock]> { + pub fn draft_prompt(&self) -> Option<&[acp_v1::ContentBlock]> { self.draft_prompt.as_deref() } pub fn set_draft_prompt( &mut self, - prompt: Option>, + prompt: Option>, cx: &mut Context, ) { cx.emit(AcpThreadEvent::PromptUpdated); @@ -2842,7 +2854,7 @@ impl AcpThread { &self.entries } - pub fn notices(&self) -> &[(usize, acp::Notice)] { + pub fn notices(&self) -> &[(usize, acp_v1::Notice)] { &self.notices } @@ -2884,7 +2896,7 @@ impl AcpThread { } } - pub fn session_id(&self) -> &acp::SessionId { + pub fn session_id(&self) -> &acp_v1::SessionId { &self.session_id } @@ -3009,11 +3021,11 @@ impl AcpThread { pub fn handle_session_update( &mut self, - update: acp::SessionUpdate, + update: acp_v1::SessionUpdate, cx: &mut Context, - ) -> Result<(), acp::Error> { + ) -> Result<(), acp_v1::Error> { match update { - acp::SessionUpdate::UserMessageChunk(acp::ContentChunk { + acp_v1::SessionUpdate::UserMessageChunk(acp_v1::ContentChunk { content, message_id, .. @@ -3044,7 +3056,7 @@ impl AcpThread { self.push_user_content_block_from_agent(message_id, content, cx); } } - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk { + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk { content, message_id, .. @@ -3053,7 +3065,7 @@ impl AcpThread { message_id, content, false, false, cx, ); } - acp::SessionUpdate::AgentThoughtChunk(acp::ContentChunk { + acp_v1::SessionUpdate::AgentThoughtChunk(acp_v1::ContentChunk { content, message_id, .. @@ -3062,29 +3074,29 @@ impl AcpThread { message_id, content, true, false, cx, ); } - acp::SessionUpdate::ToolCall(tool_call) => { + acp_v1::SessionUpdate::ToolCall(tool_call) => { self.upsert_tool_call(tool_call, cx)?; } - acp::SessionUpdate::ToolCallUpdate(tool_call_update) => { + acp_v1::SessionUpdate::ToolCallUpdate(tool_call_update) => { self.update_tool_call(tool_call_update, cx)?; } - acp::SessionUpdate::CompactionUpdate(compaction_update) => { + acp_v1::SessionUpdate::CompactionUpdate(compaction_update) => { self.upsert_context_compaction_update(compaction_update, cx); } - acp::SessionUpdate::CompactionSummaryChunk(summary_chunk) => { + acp_v1::SessionUpdate::CompactionSummaryChunk(summary_chunk) => { self.append_context_compaction_summary(summary_chunk, cx); } - acp::SessionUpdate::Plan(plan) => { + acp_v1::SessionUpdate::Plan(plan) => { self.update_plan(plan, cx); } - acp::SessionUpdate::Notice(notice) => { + acp_v1::SessionUpdate::Notice(notice) => { let notice_id = self.next_notice_id; self.next_notice_id += 1; self.notices.push((notice_id, notice)); cx.emit(AcpThreadEvent::NoticesUpdated); cx.notify(); } - acp::SessionUpdate::SessionInfoUpdate(info_update) => { + acp_v1::SessionUpdate::SessionInfoUpdate(info_update) => { if let MaybeUndefined::Value(title) = info_update.title { let had_provisional = self.provisional_title.take().is_some(); let title: SharedString = title.into(); @@ -3096,22 +3108,22 @@ impl AcpThread { } } } - acp::SessionUpdate::AvailableCommandsUpdate(acp::AvailableCommandsUpdate { + acp_v1::SessionUpdate::AvailableCommandsUpdate(acp_v1::AvailableCommandsUpdate { available_commands, .. }) => { self.available_commands = available_commands.clone(); cx.emit(AcpThreadEvent::AvailableCommandsUpdated(available_commands)); } - acp::SessionUpdate::CurrentModeUpdate(acp::CurrentModeUpdate { + acp_v1::SessionUpdate::CurrentModeUpdate(acp_v1::CurrentModeUpdate { current_mode_id, .. }) => cx.emit(AcpThreadEvent::ModeUpdated(current_mode_id)), - acp::SessionUpdate::ConfigOptionUpdate(acp::ConfigOptionUpdate { + acp_v1::SessionUpdate::ConfigOptionUpdate(acp_v1::ConfigOptionUpdate { config_options, .. }) => cx.emit(AcpThreadEvent::ConfigOptionsUpdated(config_options)), - acp::SessionUpdate::UsageUpdate(update) => { + acp_v1::SessionUpdate::UsageUpdate(update) => { let usage = self.token_usage.get_or_insert_with(Default::default); usage.max_tokens = update.size; usage.used_tokens = update.used; @@ -3131,7 +3143,7 @@ impl AcpThread { pub fn push_user_content_block( &mut self, client_id: Option, - chunk: acp::ContentBlock, + chunk: acp_v1::ContentBlock, cx: &mut Context, ) { self.push_user_content_block_with_indent(client_id, chunk, false, cx) @@ -3140,7 +3152,7 @@ impl AcpThread { pub fn push_user_content_block_with_indent( &mut self, client_id: Option, - chunk: acp::ContentBlock, + chunk: acp_v1::ContentBlock, indented: bool, cx: &mut Context, ) { @@ -3156,8 +3168,8 @@ impl AcpThread { fn push_user_content_block_from_agent( &mut self, - id: Option, - chunk: acp::ContentBlock, + id: Option, + chunk: acp_v1::ContentBlock, cx: &mut Context, ) { self.push_user_content_block_with_protocol_id(None, false, id, chunk, false, cx) @@ -3167,8 +3179,8 @@ impl AcpThread { &mut self, incoming_client_id: Option, is_optimistic: bool, - protocol_id: Option, - chunk: acp::ContentBlock, + protocol_id: Option, + chunk: acp_v1::ContentBlock, indented: bool, cx: &mut Context, ) { @@ -3222,7 +3234,7 @@ impl AcpThread { pub fn push_assistant_content_block( &mut self, - chunk: acp::ContentBlock, + chunk: acp_v1::ContentBlock, is_thought: bool, cx: &mut Context, ) { @@ -3231,7 +3243,7 @@ impl AcpThread { pub fn push_assistant_content_block_with_indent( &mut self, - chunk: acp::ContentBlock, + chunk: acp_v1::ContentBlock, is_thought: bool, indented: bool, cx: &mut Context, @@ -3241,8 +3253,8 @@ impl AcpThread { fn push_assistant_content_block_with_message_id( &mut self, - message_id: Option, - chunk: acp::ContentBlock, + message_id: Option, + chunk: acp_v1::ContentBlock, is_thought: bool, indented: bool, cx: &mut Context, @@ -3252,7 +3264,7 @@ impl AcpThread { // For text chunks going to an existing Markdown block, buffer for smooth // streaming instead of appending all at once which may feel more choppy. let chunk = match chunk { - acp::ContentBlock::Text(text) => { + acp_v1::ContentBlock::Text(text) => { if let Some((content, target)) = self.streaming_content_target(message_id.as_ref(), is_thought, indented) { @@ -3262,7 +3274,7 @@ impl AcpThread { self.buffer_streaming_text(target, source_index, text_len, cx); return; } - acp::ContentBlock::Text(text) + acp_v1::ContentBlock::Text(text) } chunk => chunk, }; @@ -3342,7 +3354,7 @@ impl AcpThread { fn streaming_content_target( &mut self, - message_id: Option<&acp::MessageId>, + message_id: Option<&acp_v1::MessageId>, is_thought: bool, indented: bool, ) -> Option<(&mut MessageContent, StreamingTextTarget)> { @@ -3510,7 +3522,7 @@ impl AcpThread { fn upsert_context_compaction_update( &mut self, - update: acp::CompactionUpdate, + update: acp_v1::CompactionUpdate, cx: &mut Context, ) { let id = ContextCompactionId(update.compaction_id.0.clone()); @@ -3545,7 +3557,7 @@ impl AcpThread { fn append_context_compaction_summary( &mut self, - chunk: acp::CompactionSummaryChunk, + chunk: acp_v1::CompactionSummaryChunk, cx: &mut Context, ) { let language_registry = self.project.read(cx).languages().clone(); @@ -3590,7 +3602,7 @@ impl AcpThread { if !update.summary_delta.is_empty() { compaction.append_summary( - acp::ContentBlock::Text(acp::TextContent::new(update.summary_delta)), + acp_v1::ContentBlock::Text(acp_v1::TextContent::new(update.summary_delta)), &language_registry, cx, ); @@ -3631,7 +3643,7 @@ impl AcpThread { cx.emit(AcpThreadEvent::TitleUpdated); } - pub fn subagent_spawned(&mut self, session_id: acp::SessionId, cx: &mut Context) { + pub fn subagent_spawned(&mut self, session_id: acp_v1::SessionId, cx: &mut Context) { cx.emit(AcpThreadEvent::SubagentSpawned(session_id)); } @@ -3663,7 +3675,7 @@ impl AcpThread { id: update.id().clone(), label: cx.new(|cx| Markdown::new("Tool call not found".into(), None, None, cx)), title: Some("Tool call not found".into()), - kind: acp::ToolKind::Fetch, + kind: acp_v1::ToolKind::Fetch, content: vec![ToolCallContent::ContentBlock(ContentBlock::new_output( "Tool call not found".into(), &languages, @@ -3721,9 +3733,9 @@ impl AcpThread { /// Updates a tool call if id matches an existing entry, otherwise inserts a new one. pub fn upsert_tool_call( &mut self, - tool_call: acp::ToolCall, + tool_call: acp_v1::ToolCall, cx: &mut Context, - ) -> Result<(), acp::Error> { + ) -> Result<(), acp_v1::Error> { let status = tool_call.status.into(); self.upsert_tool_call_inner(tool_call.into(), status, cx) } @@ -3731,10 +3743,10 @@ impl AcpThread { /// Fails if id does not match an existing entry. pub fn upsert_tool_call_inner( &mut self, - update: acp::ToolCallUpdate, + update: acp_v1::ToolCallUpdate, status: ToolCallStatus, cx: &mut Context, - ) -> Result<(), acp::Error> { + ) -> Result<(), acp_v1::Error> { let language_registry = self.project.read(cx).languages().clone(); let id = update.tool_call_id.clone(); @@ -3769,7 +3781,7 @@ impl AcpThread { cx, ) { cx.emit(AcpThreadEvent::EntryUpdated(ix)); - return Err(acp::Error::from(error)); + return Err(acp_v1::Error::from(error)); } call.update_status(status); @@ -3789,7 +3801,7 @@ impl AcpThread { Ok(()) } - fn index_for_tool_call(&self, id: &acp::ToolCallId) -> Option { + fn index_for_tool_call(&self, id: &acp_v1::ToolCallId) -> Option { self.entries .iter() .enumerate() @@ -3805,7 +3817,7 @@ impl AcpThread { }) } - fn tool_call_mut(&mut self, id: &acp::ToolCallId) -> Option<(usize, &mut ToolCall)> { + fn tool_call_mut(&mut self, id: &acp_v1::ToolCallId) -> Option<(usize, &mut ToolCall)> { // The tool call we are looking for is typically the last one, or very close to the end. // At the moment, it doesn't seem like a hashmap would be a good fit for this use case. self.entries @@ -3823,7 +3835,7 @@ impl AcpThread { }) } - pub fn tool_call(&self, id: &acp::ToolCallId) -> Option<(usize, &ToolCall)> { + pub fn tool_call(&self, id: &acp_v1::ToolCallId) -> Option<(usize, &ToolCall)> { self.entries .iter() .enumerate() @@ -3839,7 +3851,7 @@ impl AcpThread { }) } - pub fn tool_call_for_subagent(&self, session_id: &acp::SessionId) -> Option<&ToolCall> { + pub fn tool_call_for_subagent(&self, session_id: &acp_v1::SessionId) -> Option<&ToolCall> { self.entries.iter().find_map(|entry| match entry { AgentThreadEntry::ToolCall(tool_call) => { if let Some(subagent_session_info) = &tool_call.subagent_session_info @@ -3854,7 +3866,7 @@ impl AcpThread { }) } - pub fn resolve_locations(&mut self, id: acp::ToolCallId, cx: &mut Context) { + pub fn resolve_locations(&mut self, id: acp_v1::ToolCallId, cx: &mut Context) { let project = self.project.clone(); let should_update_agent_location = self.parent_session_id.is_none(); let Some((_, tool_call)) = self.tool_call_mut(&id) else { @@ -3914,7 +3926,7 @@ impl AcpThread { pub fn request_tool_call_authorization( &mut self, - tool_call: acp::ToolCallUpdate, + tool_call: acp_v1::ToolCallUpdate, options: PermissionOptions, kind: AuthorizationKind, cx: &mut Context, @@ -3925,7 +3937,7 @@ impl AcpThread { .tool_call(&tool_call.tool_call_id) .and_then(|(_, tool_call)| tool_call.status.as_acp_status()) .or(tool_call.fields.status) - .unwrap_or(acp::ToolCallStatus::Pending); + .unwrap_or(acp_v1::ToolCallStatus::Pending); let status = ToolCallStatus::WaitingForConfirmation { current_status, options, @@ -3949,7 +3961,11 @@ impl AcpThread { })) } - pub fn cancel_tool_call_authorization(&mut self, id: &acp::ToolCallId, cx: &mut Context) { + pub fn cancel_tool_call_authorization( + &mut self, + id: &acp_v1::ToolCallId, + cx: &mut Context, + ) { let Some((ix, call)) = self.tool_call_mut(id) else { return; }; @@ -3964,7 +3980,7 @@ impl AcpThread { pub fn authorize_tool_call( &mut self, - id: acp::ToolCallId, + id: acp_v1::ToolCallId, outcome: SelectedPermissionOutcome, cx: &mut Context, ) { @@ -3972,31 +3988,30 @@ impl AcpThread { return; }; - let new_status = - match &call.status { - ToolCallStatus::WaitingForConfirmation { - kind: AuthorizationKind::ActionChoice, - .. - } => ToolCallStatus::InProgress, - ToolCallStatus::WaitingForConfirmation { current_status, .. } => { - match outcome.option_kind { - acp::PermissionOptionKind::RejectOnce - | acp::PermissionOptionKind::RejectAlways => ToolCallStatus::Rejected, - acp::PermissionOptionKind::AllowOnce - | acp::PermissionOptionKind::AllowAlways => { - ToolCallStatus::status_after_permission_grant(*current_status) - } - _ => ToolCallStatus::status_after_permission_grant(*current_status), + let new_status = match &call.status { + ToolCallStatus::WaitingForConfirmation { + kind: AuthorizationKind::ActionChoice, + .. + } => ToolCallStatus::InProgress, + ToolCallStatus::WaitingForConfirmation { current_status, .. } => { + match outcome.option_kind { + acp_v1::PermissionOptionKind::RejectOnce + | acp_v1::PermissionOptionKind::RejectAlways => ToolCallStatus::Rejected, + acp_v1::PermissionOptionKind::AllowOnce + | acp_v1::PermissionOptionKind::AllowAlways => { + ToolCallStatus::status_after_permission_grant(*current_status) } + _ => ToolCallStatus::status_after_permission_grant(*current_status), } - _ => match outcome.option_kind { - acp::PermissionOptionKind::RejectOnce - | acp::PermissionOptionKind::RejectAlways => ToolCallStatus::Rejected, - acp::PermissionOptionKind::AllowOnce - | acp::PermissionOptionKind::AllowAlways => ToolCallStatus::InProgress, - _ => ToolCallStatus::InProgress, - }, - }; + } + _ => match outcome.option_kind { + acp_v1::PermissionOptionKind::RejectOnce + | acp_v1::PermissionOptionKind::RejectAlways => ToolCallStatus::Rejected, + acp_v1::PermissionOptionKind::AllowOnce + | acp_v1::PermissionOptionKind::AllowAlways => ToolCallStatus::InProgress, + _ => ToolCallStatus::InProgress, + }, + }; let curr_status = mem::replace(&mut call.status, new_status); @@ -4011,18 +4026,18 @@ impl AcpThread { pub fn request_elicitation( &mut self, - request: acp::CreateElicitationRequest, + request: acp_v1::CreateElicitationRequest, cx: &mut Context, - ) -> Result, acp::Error> { + ) -> Result, acp_v1::Error> { self.request_elicitation_with_id(request, cx) .map(|(_, task)| task) } pub fn request_elicitation_with_id( &mut self, - request: acp::CreateElicitationRequest, + request: acp_v1::CreateElicitationRequest, cx: &mut Context, - ) -> Result<(ElicitationEntryId, Task), acp::Error> { + ) -> Result<(ElicitationEntryId, Task), acp_v1::Error> { ElicitationStore::validate_request(&request)?; let (id, response_rx) = self.elicitations.insert_pending_elicitation(request); @@ -4048,7 +4063,7 @@ impl AcpThread { pub fn respond_to_elicitation( &mut self, id: &ElicitationEntryId, - response: acp::CreateElicitationResponse, + response: acp_v1::CreateElicitationResponse, cx: &mut Context, ) { let Some(ix) = self.elicitation_entry_ix(id) else { @@ -4063,7 +4078,7 @@ impl AcpThread { pub fn complete_url_elicitation( &mut self, - elicitation_id: &acp::ElicitationId, + elicitation_id: &acp_v1::ElicitationId, cx: &mut Context, ) { let Some(entry_id) = self @@ -4114,7 +4129,7 @@ impl AcpThread { &self.plan } - pub fn update_plan(&mut self, request: acp::Plan, cx: &mut Context) { + pub fn update_plan(&mut self, request: acp_v1::Plan, cx: &mut Context) { let new_entries_len = request.entries.len(); let mut new_entries = request.entries.into_iter(); @@ -4149,7 +4164,7 @@ impl AcpThread { fn clear_completed_plan_entries(&mut self, cx: &mut Context) { self.plan .entries - .retain(|entry| !matches!(entry.status, acp::PlanEntryStatus::Completed)); + .retain(|entry| !matches!(entry.status, acp_v1::PlanEntryStatus::Completed)); cx.notify(); } @@ -4163,15 +4178,15 @@ impl AcpThread { &mut self, message: &str, cx: &mut Context, - ) -> BoxFuture<'static, Result>> { + ) -> BoxFuture<'static, Result>> { self.send(vec![message.into()], cx) } pub fn send( &mut self, - message: Vec, + message: Vec, cx: &mut Context, - ) -> BoxFuture<'static, Result>> { + ) -> BoxFuture<'static, Result>> { self.send_inner(message, true, cx) } @@ -4181,25 +4196,25 @@ impl AcpThread { /// typed command isn't sent to the model as an ordinary user turn. pub fn send_command( &mut self, - message: Vec, + message: Vec, cx: &mut Context, - ) -> BoxFuture<'static, Result>> { + ) -> BoxFuture<'static, Result>> { self.send_inner(message, false, cx) } fn send_inner( &mut self, - message: Vec, + message: Vec, push_user_message: bool, cx: &mut Context, - ) -> BoxFuture<'static, Result>> { + ) -> BoxFuture<'static, Result>> { let language_registry = self.project.read(cx).languages().clone(); let path_style = self.project.read(cx).path_style(cx); let mut block = MessageContent::default(); for chunk in &message { block.append_prompt(chunk.clone(), &language_registry, path_style, cx); } - let request = acp::PromptRequest::new(self.session_id.clone(), message); + let request = acp_v1::PromptRequest::new(self.session_id.clone(), message); let git_store = self.project.read(cx).git_store().clone(); let client_user_message_ids = self.connection.client_user_message_ids(cx); @@ -4258,7 +4273,7 @@ impl AcpThread { pub fn retry( &mut self, cx: &mut Context, - ) -> BoxFuture<'static, Result>> { + ) -> BoxFuture<'static, Result>> { self.run_turn(cx, async move |this, cx| { this.update(cx, |this, cx| { this.connection @@ -4273,8 +4288,8 @@ impl AcpThread { fn run_turn( &mut self, cx: &mut Context, - f: impl 'static + AsyncFnOnce(WeakEntity, &mut AsyncApp) -> Result, - ) -> BoxFuture<'static, Result>> { + f: impl 'static + AsyncFnOnce(WeakEntity, &mut AsyncApp) -> Result, + ) -> BoxFuture<'static, Result>> { self.clear_completed_plan_entries(cx); self.had_error = false; @@ -4348,7 +4363,7 @@ impl AcpThread { Ok(r) => { this.flush_streaming_text(cx); - if r.stop_reason == acp::StopReason::MaxTokens { + if r.stop_reason == acp_v1::StopReason::MaxTokens { if is_same_turn { cx.emit(AcpThreadEvent::StatusChanged); } @@ -4376,7 +4391,7 @@ impl AcpThread { return Err(anyhow!(MaxOutputTokensError)); } - let canceled = matches!(r.stop_reason, acp::StopReason::Cancelled); + let canceled = matches!(r.stop_reason, acp_v1::StopReason::Cancelled); if canceled && is_same_turn { this.cancel_pending_turn_entries(cx); } @@ -4386,7 +4401,7 @@ impl AcpThread { } // Handle refusal - distinguish between user prompt and tool call refusals - if let acp::StopReason::Refusal = r.stop_reason { + if let acp_v1::StopReason::Refusal = r.stop_reason { this.had_error = true; if let Some((user_msg_ix, _)) = this.last_user_message() { // Check if there's a completed tool call with results after the last user message @@ -4624,7 +4639,7 @@ impl AcpThread { this.flush_streaming_text(cx); if let Some((ix, _)) = this.user_message_mut(&client_id) { // Collect all terminals from entries that will be removed - let terminals_to_remove: Vec = this.entries[ix..] + let terminals_to_remove: Vec = this.entries[ix..] .iter() .flat_map(|entry| entry.terminals()) .filter_map(|terminal| terminal.read(cx).id().clone().into()) @@ -4809,7 +4824,7 @@ impl AcpThread { limit: Option, reuse_shared_snapshot: bool, cx: &mut Context, - ) -> Task> { + ) -> Task> { // Args are 1-based, move to 0-based let line = line.unwrap_or_default().saturating_sub(1); let limit = limit.unwrap_or(u32::MAX); @@ -4821,9 +4836,9 @@ impl AcpThread { let path = project .project_path_for_absolute_path(&path, cx) .ok_or_else(|| { - acp::Error::resource_not_found(Some(path.display().to_string())) + acp_v1::Error::resource_not_found(Some(path.display().to_string())) })?; - Ok::<_, acp::Error>(project.open_buffer(path, cx)) + Ok::<_, acp_v1::Error>(project.open_buffer(path, cx)) })?; let buffer = load.await?; @@ -4856,7 +4871,7 @@ impl AcpThread { let start_position = Point::new(line, 0); if start_position > max_point { - return Err(acp::Error::invalid_params().data(format!( + return Err(acp_v1::Error::invalid_params().data(format!( "Attempting to read beyond the end of the file, line {}:{}", max_point.row + 1, max_point.column @@ -4981,7 +4996,7 @@ impl AcpThread { &self, command: String, args: Vec, - extra_env: Vec, + extra_env: Vec, cwd: Option, output_byte_limit: Option, sandbox_wrap: Option, @@ -5014,7 +5029,7 @@ impl AcpThread { // without a PTY in that case. let headless = HeadlessTerminal::is_enabled(cx); - let terminal_id = acp::TerminalId::new(Uuid::new_v4().to_string()); + let terminal_id = acp_v1::TerminalId::new(Uuid::new_v4().to_string()); let terminal_task = cx.spawn({ let terminal_id = terminal_id.clone(); async move |_this, cx| { @@ -5135,7 +5150,7 @@ impl AcpThread { pub fn kill_terminal( &mut self, - terminal_id: acp::TerminalId, + terminal_id: acp_v1::TerminalId, cx: &mut Context, ) -> Result<()> { self.terminals @@ -5150,7 +5165,7 @@ impl AcpThread { pub fn release_terminal( &mut self, - terminal_id: acp::TerminalId, + terminal_id: acp_v1::TerminalId, cx: &mut Context, ) -> Result<()> { self.terminals @@ -5163,7 +5178,7 @@ impl AcpThread { Ok(()) } - pub fn terminal(&self, terminal_id: acp::TerminalId) -> Result> { + pub fn terminal(&self, terminal_id: acp_v1::TerminalId) -> Result> { self.terminals .get(&terminal_id) .context("Terminal not found") @@ -5192,7 +5207,7 @@ impl AcpThread { pub fn register_terminal_created( &mut self, - terminal_id: acp::TerminalId, + terminal_id: acp_v1::TerminalId, command_label: String, working_dir: Option, output_byte_limit: Option, @@ -5394,7 +5409,8 @@ mod tests { #[test] fn test_text_cursor_reads_source_on_utf8_boundaries() { - let sources = ["visible", "", "aé", "", "🦀b", "", "日本語"].map(acp::ContentBlock::from); + let sources = + ["visible", "", "aé", "", "🦀b", "", "日本語"].map(acp_v1::ContentBlock::from); let whole = "aé🦀b日本語"; for max_bytes in 1..=whole.len() + 1 { let mut cursor = TextCursor { @@ -5514,7 +5530,7 @@ mod tests { // Absent meta and unknown categories both decode to `None`. assert_eq!(command_category_from_meta(&None), None); let unknown = - acp::Meta::from_iter([(COMMAND_CATEGORY_META_KEY.into(), "future-category".into())]); + acp_v1::Meta::from_iter([(COMMAND_CATEGORY_META_KEY.into(), "future-category".into())]); assert_eq!(command_category_from_meta(&Some(unknown)), None); } @@ -5563,8 +5579,8 @@ mod tests { }); } - fn message_test_image() -> acp::ContentBlock { - acp::ContentBlock::Image(acp::ImageContent::new( + fn message_test_image() -> acp_v1::ContentBlock { + acp_v1::ContentBlock::Image(acp_v1::ImageContent::new( "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==", "image/png", )) @@ -5575,35 +5591,38 @@ mod tests { init_test(cx); cx.update(|cx| { let languages = Arc::new(LanguageRegistry::test(cx.background_executor().clone())); - let annotations = acp::Annotations::new().priority(0.5); + let annotations = acp_v1::Annotations::new().priority(0.5); let blocks = vec![ - acp::ContentBlock::Text( - acp::TextContent::new("") + acp_v1::ContentBlock::Text( + acp_v1::TextContent::new("") .annotations(annotations.clone()) - .meta(acp::Meta::from_iter([("empty".into(), json!(true))])), + .meta(acp_v1::Meta::from_iter([("empty".into(), json!(true))])), ), - acp::ContentBlock::Text( - acp::TextContent::new("hello ") - .meta(acp::Meta::from_iter([("part".into(), json!(1))])), + acp_v1::ContentBlock::Text( + acp_v1::TextContent::new("hello ") + .meta(acp_v1::Meta::from_iter([("part".into(), json!(1))])), ), - acp::ContentBlock::Text( - acp::TextContent::new("world") - .meta(acp::Meta::from_iter([("part".into(), json!(2))])), + acp_v1::ContentBlock::Text( + acp_v1::TextContent::new("world") + .meta(acp_v1::Meta::from_iter([("part".into(), json!(2))])), ), match message_test_image() { - acp::ContentBlock::Image(image) => acp::ContentBlock::Image( + acp_v1::ContentBlock::Image(image) => acp_v1::ContentBlock::Image( image .uri("file:///original.png".to_string()) .annotations(annotations) - .meta(acp::Meta::from_iter([("image".into(), json!(42))])), + .meta(acp_v1::Meta::from_iter([("image".into(), json!(42))])), ), _ => unreachable!("fixture is an image"), }, - acp::ContentBlock::ResourceLink( - acp::ResourceLink::new("original name", "https://example.com/file") + acp_v1::ContentBlock::ResourceLink( + acp_v1::ResourceLink::new("original name", "https://example.com/file") .description("original description".to_string()) .title("original title".to_string()) - .meta(acp::Meta::from_iter([("link".into(), json!("original"))])), + .meta(acp_v1::Meta::from_iter([( + "link".into(), + json!("original"), + )])), ), ]; let mut content = MessageContent::default(); @@ -5686,22 +5705,28 @@ mod tests { let mut content = MessageContent::default(); for chunk in [ "before".into(), - acp::ContentBlock::Resource(acp::EmbeddedResource::new( - acp::EmbeddedResourceResource::TextResourceContents( - acp::TextResourceContents::new("resource text", "tool://preview"), + acp_v1::ContentBlock::Resource(acp_v1::EmbeddedResource::new( + acp_v1::EmbeddedResourceResource::TextResourceContents( + acp_v1::TextResourceContents::new("resource text", "tool://preview"), ), )), - acp::ContentBlock::ResourceLink(acp::ResourceLink::new( + acp_v1::ContentBlock::ResourceLink(acp_v1::ResourceLink::new( "link", "https://example.com/resource", )), - acp::ContentBlock::Resource(acp::EmbeddedResource::new( - acp::EmbeddedResourceResource::BlobResourceContents( - acp::BlobResourceContents::new("private-blob-data", "tool://archive.bin"), + acp_v1::ContentBlock::Resource(acp_v1::EmbeddedResource::new( + acp_v1::EmbeddedResourceResource::BlobResourceContents( + acp_v1::BlobResourceContents::new( + "private-blob-data", + "tool://archive.bin", + ), ), )), - acp::ContentBlock::Image(acp::ImageContent::new("not-base64", "image/png")), - acp::ContentBlock::Audio(acp::AudioContent::new("private-audio-data", "audio/wav")), + acp_v1::ContentBlock::Image(acp_v1::ImageContent::new("not-base64", "image/png")), + acp_v1::ContentBlock::Audio(acp_v1::AudioContent::new( + "private-audio-data", + "audio/wav", + )), "after".into(), ] { content.append(chunk, &language_registry, PathStyle::local(), cx); @@ -5777,15 +5802,15 @@ mod tests { let source_blocks = [ "before".into(), - acp::ContentBlock::Text( - acp::TextContent::new(" image") - .meta(acp::Meta::from_iter([("sequence".into(), json!(2))])), + acp_v1::ContentBlock::Text( + acp_v1::TextContent::new(" image") + .meta(acp_v1::Meta::from_iter([("sequence".into(), json!(2))])), ), message_test_image(), "after".into(), - acp::ContentBlock::Text( - acp::TextContent::new(" image") - .meta(acp::Meta::from_iter([("sequence".into(), json!(5))])), + acp_v1::ContentBlock::Text( + acp_v1::TextContent::new(" image") + .meta(acp_v1::Meta::from_iter([("sequence".into(), json!(5))])), ), ]; let (before, after, image) = thread.update(cx, |thread, cx| { @@ -5888,16 +5913,19 @@ mod tests { for (content, preview) in [ ( - acp::ContentBlock::Resource(acp::EmbeddedResource::new( - acp::EmbeddedResourceResource::TextResourceContents( - acp::TextResourceContents::new("Resource preview", "tool://preview") + acp_v1::ContentBlock::Resource(acp_v1::EmbeddedResource::new( + acp_v1::EmbeddedResourceResource::TextResourceContents( + acp_v1::TextResourceContents::new("Resource preview", "tool://preview") .mime_type("text/markdown".to_string()), ), )), "Resource preview", ), ( - acp::ContentBlock::Audio(acp::AudioContent::new("private-audio-data", "audio/wav")), + acp_v1::ContentBlock::Audio(acp_v1::AudioContent::new( + "private-audio-data", + "audio/wav", + )), "Audio content is not supported.", ), ] { @@ -5939,7 +5967,7 @@ mod tests { let path_style = thread.project.read(cx).path_style(cx); let languages = thread.project.read(cx).languages().clone(); let uri = "file:///project/report.md"; - let link = acp::ContentBlock::ResourceLink(acp::ResourceLink::new("report", uri)); + let link = acp_v1::ContentBlock::ResourceLink(acp_v1::ResourceLink::new("report", uri)); let expected = format!( "{}\n## Details\n", ContentBlock::resource_link_md(uri, path_style), @@ -5988,16 +6016,16 @@ mod tests { .expect("session should be created"); let chunks = vec![ "read ".into(), - acp::ContentBlock::Resource(acp::EmbeddedResource::new( - acp::EmbeddedResourceResource::TextResourceContents( - acp::TextResourceContents::new( + acp_v1::ContentBlock::Resource(acp_v1::EmbeddedResource::new( + acp_v1::EmbeddedResourceResource::TextResourceContents( + acp_v1::TextResourceContents::new( "attached file contents", "https://example.com/file", ), ), )), " and ".into(), - acp::ContentBlock::ResourceLink(acp::ResourceLink::new( + acp_v1::ContentBlock::ResourceLink(acp_v1::ResourceLink::new( "link", "https://example.com/link", )), @@ -6038,35 +6066,37 @@ mod tests { #[test] fn text_resource_markdown_uses_mime_type_for_code_blocks() { - let shell = acp::TextResourceContents::new("echo 'hello from exec test'", "tool://preview") - .mime_type("text/x-shellscript".to_string()); + let shell = + acp_v1::TextResourceContents::new("echo 'hello from exec test'", "tool://preview") + .mime_type("text/x-shellscript".to_string()); assert_eq!( ContentBlock::text_resource_markdown(&shell), "```sh\necho 'hello from exec test'\n```" ); - let markdown = acp::TextResourceContents::new("**approval** requested", "tool://preview") - .mime_type("text/markdown".to_string()); + let markdown = + acp_v1::TextResourceContents::new("**approval** requested", "tool://preview") + .mime_type("text/markdown".to_string()); assert_eq!( ContentBlock::text_resource_markdown(&markdown), "**approval** requested" ); - let plain = acp::TextResourceContents::new("plain preview", "tool://preview") + let plain = acp_v1::TextResourceContents::new("plain preview", "tool://preview") .mime_type("text/plain".to_string()); assert_eq!( ContentBlock::text_resource_markdown(&plain), "```\nplain preview\n```" ); - let cpp = acp::TextResourceContents::new("int main() {}", "tool://preview") + let cpp = acp_v1::TextResourceContents::new("int main() {}", "tool://preview") .mime_type("text/x-c++; charset=utf-8".to_string()); assert_eq!( ContentBlock::text_resource_markdown(&cpp), "```cpp\nint main() {}\n```" ); - let untyped = acp::TextResourceContents::new("# plain preview", "tool://preview"); + let untyped = acp_v1::TextResourceContents::new("# plain preview", "tool://preview"); assert_eq!( ContentBlock::text_resource_markdown(&untyped), "```\n# plain preview\n```" @@ -6082,10 +6112,13 @@ mod tests { cx.update(|cx| { let language_registry = Arc::new(LanguageRegistry::test(cx.background_executor().clone())); - let content = acp::ContentBlock::Resource(acp::EmbeddedResource::new( - acp::EmbeddedResourceResource::TextResourceContents( - acp::TextResourceContents::new("echo 'hello from exec test'", "tool://preview") - .mime_type("text/x-shellscript".to_string()), + let content = acp_v1::ContentBlock::Resource(acp_v1::EmbeddedResource::new( + acp_v1::EmbeddedResourceResource::TextResourceContents( + acp_v1::TextResourceContents::new( + "echo 'hello from exec test'", + "tool://preview", + ) + .mime_type("text/x-shellscript".to_string()), ), )); @@ -6095,7 +6128,7 @@ mod tests { panic!("expected embedded resource block, got {block:?}"); }; match &resource.resource { - acp::EmbeddedResourceResource::TextResourceContents(text) => { + acp_v1::EmbeddedResourceResource::TextResourceContents(text) => { assert_eq!(text.text, "echo 'hello from exec test'"); assert_eq!(text.uri, "tool://preview"); assert_eq!(text.mime_type.as_deref(), Some("text/x-shellscript")); @@ -6117,9 +6150,9 @@ mod tests { assert_eq!(block.text_content(cx), Some("echo 'hello from exec test'")); let untyped = ContentBlock::new_output( - acp::ContentBlock::Resource(acp::EmbeddedResource::new( - acp::EmbeddedResourceResource::TextResourceContents( - acp::TextResourceContents::new("# plain preview", "tool://preview"), + acp_v1::ContentBlock::Resource(acp_v1::EmbeddedResource::new( + acp_v1::EmbeddedResourceResource::TextResourceContents( + acp_v1::TextResourceContents::new("# plain preview", "tool://preview"), ), )), &language_registry, @@ -6139,9 +6172,9 @@ mod tests { cx.update(|cx| { let language_registry = Arc::new(LanguageRegistry::test(cx.background_executor().clone())); - let image_blob = acp::ContentBlock::Resource(acp::EmbeddedResource::new( - acp::EmbeddedResourceResource::BlobResourceContents( - acp::BlobResourceContents::new( + let image_blob = acp_v1::ContentBlock::Resource(acp_v1::EmbeddedResource::new( + acp_v1::EmbeddedResourceResource::BlobResourceContents( + acp_v1::BlobResourceContents::new( "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==", "tool://preview.png", ) @@ -6177,9 +6210,9 @@ mod tests { cx.update(|cx| { let language_registry = Arc::new(LanguageRegistry::test(cx.background_executor().clone())); - let archive_blob = acp::ContentBlock::Resource(acp::EmbeddedResource::new( - acp::EmbeddedResourceResource::BlobResourceContents( - acp::BlobResourceContents::new("not an image", "tool://archive.bin") + let archive_blob = acp_v1::ContentBlock::Resource(acp_v1::EmbeddedResource::new( + acp_v1::EmbeddedResourceResource::BlobResourceContents( + acp_v1::BlobResourceContents::new("not an image", "tool://archive.bin") .mime_type("application/octet-stream".to_string()), ), )); @@ -6191,7 +6224,7 @@ mod tests { }; assert!(markdown.is_none()); match &resource.resource { - acp::EmbeddedResourceResource::BlobResourceContents(blob) => { + acp_v1::EmbeddedResourceResource::BlobResourceContents(blob) => { assert_eq!(blob.uri, "tool://archive.bin"); assert_eq!(blob.mime_type.as_deref(), Some("application/octet-stream")); } @@ -6200,9 +6233,9 @@ mod tests { assert_eq!(block.to_markdown(cx), "tool://archive.bin"); assert_eq!(block.text_content(cx), None); - let invalid_image_blob = acp::ContentBlock::Resource(acp::EmbeddedResource::new( - acp::EmbeddedResourceResource::BlobResourceContents( - acp::BlobResourceContents::new("not-base64", "tool://preview.png") + let invalid_image_blob = acp_v1::ContentBlock::Resource(acp_v1::EmbeddedResource::new( + acp_v1::EmbeddedResourceResource::BlobResourceContents( + acp_v1::BlobResourceContents::new("not-base64", "tool://preview.png") .mime_type("image/png".to_string()), ), )); @@ -6252,7 +6285,7 @@ mod tests { .await .unwrap(); - let terminal_id = acp::TerminalId::new(uuid::Uuid::new_v4().to_string()); + let terminal_id = acp_v1::TerminalId::new(uuid::Uuid::new_v4().to_string()); // Send Output BEFORE Created - should be buffered by acp_thread thread.update(cx, |thread, cx| { @@ -6321,7 +6354,7 @@ mod tests { .await .unwrap(); - let terminal_id = acp::TerminalId::new(uuid::Uuid::new_v4().to_string()); + let terminal_id = acp_v1::TerminalId::new(uuid::Uuid::new_v4().to_string()); let lower = cx.new(|cx| { let builder = ::terminal::TerminalBuilder::new_display_only( ::terminal::terminal_settings::CursorShape::default(), @@ -6391,7 +6424,7 @@ mod tests { thread.on_terminal_provider_event( TerminalProviderEvent::Exit { terminal_id: terminal_id.clone(), - status: acp::TerminalExitStatus::new().exit_code(7), + status: acp_v1::TerminalExitStatus::new().exit_code(7), }, cx, ); @@ -6443,7 +6476,7 @@ mod tests { thread.on_terminal_provider_event( TerminalProviderEvent::Exit { terminal_id: terminal_id.clone(), - status: acp::TerminalExitStatus::new().signal("SIGTERM"), + status: acp_v1::TerminalExitStatus::new().signal("SIGTERM"), }, cx, ); @@ -6495,7 +6528,7 @@ mod tests { .await .unwrap(); - let terminal_id = acp::TerminalId::new(uuid::Uuid::new_v4().to_string()); + let terminal_id = acp_v1::TerminalId::new(uuid::Uuid::new_v4().to_string()); // Send Output BEFORE Created thread.update(cx, |thread, cx| { @@ -6513,14 +6546,14 @@ mod tests { thread.on_terminal_provider_event( TerminalProviderEvent::Exit { terminal_id: terminal_id.clone(), - status: acp::TerminalExitStatus::new().signal("SIGTERM"), + status: acp_v1::TerminalExitStatus::new().signal("SIGTERM"), }, cx, ); thread.on_terminal_provider_event( TerminalProviderEvent::Exit { terminal_id: terminal_id.clone(), - status: acp::TerminalExitStatus::new().exit_code(0), + status: acp_v1::TerminalExitStatus::new().exit_code(0), }, cx, ); @@ -6620,7 +6653,7 @@ mod tests { .await .unwrap(); - let terminal_id = acp::TerminalId::new(uuid::Uuid::new_v4().to_string()); + let terminal_id = acp_v1::TerminalId::new(uuid::Uuid::new_v4().to_string()); // We use printf instead of echo and chain with && sleep to ensure proper execution let (program, args) = ShellBuilder::new(&Shell::System, false).build( @@ -6849,40 +6882,40 @@ mod tests { thread.update(cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::UserMessageChunk( - acp::ContentChunk::new("First ".into()).message_id("msg_user_1"), + acp_v1::SessionUpdate::UserMessageChunk( + acp_v1::ContentChunk::new("First ".into()).message_id("msg_user_1"), ), cx, ) .unwrap(); thread .handle_session_update( - acp::SessionUpdate::UserMessageChunk( - acp::ContentChunk::new("message".into()).message_id("msg_user_1"), + acp_v1::SessionUpdate::UserMessageChunk( + acp_v1::ContentChunk::new("message".into()).message_id("msg_user_1"), ), cx, ) .unwrap(); thread .handle_session_update( - acp::SessionUpdate::UserMessageChunk( - acp::ContentChunk::new("Second message".into()).message_id("msg_user_2"), + acp_v1::SessionUpdate::UserMessageChunk( + acp_v1::ContentChunk::new("Second message".into()).message_id("msg_user_2"), ), cx, ) .unwrap(); thread .handle_session_update( - acp::SessionUpdate::UserMessageChunk( - acp::ContentChunk::new("Echo".into()).message_id("msg_user_3"), + acp_v1::SessionUpdate::UserMessageChunk( + acp_v1::ContentChunk::new("Echo".into()).message_id("msg_user_3"), ), cx, ) .unwrap(); thread .handle_session_update( - acp::SessionUpdate::UserMessageChunk( - acp::ContentChunk::new("Echo".into()).message_id("msg_user_3"), + acp_v1::SessionUpdate::UserMessageChunk( + acp_v1::ContentChunk::new("Echo".into()).message_id("msg_user_3"), ), cx, ) @@ -6960,8 +6993,8 @@ mod tests { ); thread .handle_session_update( - acp::SessionUpdate::UserMessageChunk( - acp::ContentChunk::new("Agent user chunk".into()) + acp_v1::SessionUpdate::UserMessageChunk( + acp_v1::ContentChunk::new("Agent user chunk".into()) .message_id("agent_user_chunk"), ), cx, @@ -7015,24 +7048,24 @@ mod tests { thread.update(cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::AgentThoughtChunk( - acp::ContentChunk::new("Thinking ".into()).message_id("msg_thought_1"), + acp_v1::SessionUpdate::AgentThoughtChunk( + acp_v1::ContentChunk::new("Thinking ".into()).message_id("msg_thought_1"), ), cx, ) .unwrap(); thread .handle_session_update( - acp::SessionUpdate::AgentThoughtChunk( - acp::ContentChunk::new("hard".into()).message_id("msg_thought_1"), + acp_v1::SessionUpdate::AgentThoughtChunk( + acp_v1::ContentChunk::new("hard".into()).message_id("msg_thought_1"), ), cx, ) .unwrap(); thread .handle_session_update( - acp::SessionUpdate::AgentThoughtChunk( - acp::ContentChunk::new("A separate thought".into()) + acp_v1::SessionUpdate::AgentThoughtChunk( + acp_v1::ContentChunk::new("A separate thought".into()) .message_id("msg_thought_2"), ), cx, @@ -7040,24 +7073,24 @@ mod tests { .unwrap(); thread .handle_session_update( - acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("Answer ".into()).message_id("msg_agent_1"), + acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("Answer ".into()).message_id("msg_agent_1"), ), cx, ) .unwrap(); thread .handle_session_update( - acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("done".into()).message_id("msg_agent_1"), + acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("done".into()).message_id("msg_agent_1"), ), cx, ) .unwrap(); thread .handle_session_update( - acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("Follow-up".into()).message_id("msg_agent_2"), + acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("Follow-up".into()).message_id("msg_agent_2"), ), cx, ) @@ -7121,22 +7154,22 @@ mod tests { thread.update(&mut cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::AgentThoughtChunk(acp::ContentChunk::new( - "Thinking ".into(), - )), + acp_v1::SessionUpdate::AgentThoughtChunk( + acp_v1::ContentChunk::new("Thinking ".into()), + ), cx, ) .unwrap(); thread .handle_session_update( - acp::SessionUpdate::AgentThoughtChunk(acp::ContentChunk::new( - "hard!".into(), - )), + acp_v1::SessionUpdate::AgentThoughtChunk( + acp_v1::ContentChunk::new("hard!".into()), + ), cx, ) .unwrap(); })?; - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } .boxed_local() }, @@ -7188,7 +7221,7 @@ mod tests { move |request, thread, mut cx| { let received_prompt = received_prompt.clone(); async move { - if let Some(acp::ContentBlock::Text(text)) = request.prompt.first() { + if let Some(acp_v1::ContentBlock::Text(text)) = request.prompt.first() { *received_prompt.borrow_mut() = Some(text.text.clone()); } // Simulate a native command producing its own thread entry @@ -7204,7 +7237,7 @@ mod tests { cx, ); })?; - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } .boxed_local() } @@ -7265,15 +7298,15 @@ mod tests { thread.update(&mut cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::UserMessageChunk(acp::ContentChunk::new( - prompt, - )), + acp_v1::SessionUpdate::UserMessageChunk( + acp_v1::ContentChunk::new(prompt), + ), cx, ) .unwrap(); })?; - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } .boxed_local() }), @@ -7337,7 +7370,7 @@ mod tests { .unwrap() .await .unwrap(); - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } .boxed_local() }, @@ -7567,7 +7600,7 @@ mod tests { .await .unwrap_err(); - assert_eq!(err.code, acp::ErrorCode::ResourceNotFound); + assert_eq!(err.code, acp_v1::ErrorCode::ResourceNotFound); } #[gpui::test] @@ -7576,7 +7609,7 @@ mod tests { let fs = FakeFs::new(cx.executor()); let project = Project::test(fs, [], cx).await; - let id = acp::ToolCallId::new("test"); + let id = acp_v1::ToolCallId::new("test"); let connection = Rc::new(FakeAgentConnection::new().on_user_message({ let id = id.clone(); @@ -7586,17 +7619,17 @@ mod tests { thread .update(&mut cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCall( - acp::ToolCall::new(id.clone(), "Label") - .kind(acp::ToolKind::Fetch) - .status(acp::ToolCallStatus::InProgress), + acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new(id.clone(), "Label") + .kind(acp_v1::ToolKind::Fetch) + .status(acp_v1::ToolCallStatus::InProgress), ), cx, ) }) .unwrap() .unwrap(); - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } .boxed_local() } @@ -7640,9 +7673,10 @@ mod tests { thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate::new( + acp_v1::SessionUpdate::ToolCallUpdate(acp_v1::ToolCallUpdate::new( id, - acp::ToolCallUpdateFields::new().status(acp::ToolCallStatus::Completed), + acp_v1::ToolCallUpdateFields::new() + .status(acp_v1::ToolCallStatus::Completed), )), cx, ) @@ -7680,13 +7714,13 @@ mod tests { for summary in ["retained context", "replacement summary"] { thread .handle_session_update( - acp::SessionUpdate::CompactionUpdate( - acp::CompactionUpdate::new( + acp_v1::SessionUpdate::CompactionUpdate( + acp_v1::CompactionUpdate::new( "compaction", - acp::CompactionStatus::Completed, + acp_v1::CompactionStatus::Completed, ) - .summary(vec![acp::ContentBlock::Text( - acp::TextContent::new(summary), + .summary(vec![acp_v1::ContentBlock::Text( + acp_v1::TextContent::new(summary), )]), ), cx, @@ -7713,10 +7747,13 @@ mod tests { thread .handle_session_update( - acp::SessionUpdate::CompactionUpdate( - acp::CompactionUpdate::new("compaction", acp::CompactionStatus::Failed) - .summary(None::>) - .error("model unavailable"), + acp_v1::SessionUpdate::CompactionUpdate( + acp_v1::CompactionUpdate::new( + "compaction", + acp_v1::CompactionStatus::Failed, + ) + .summary(None::>) + .error("model unavailable"), ), cx, ) @@ -7751,9 +7788,12 @@ mod tests { }; thread .handle_session_update( - acp::SessionUpdate::CompactionUpdate( - acp::CompactionUpdate::new("compaction", acp::CompactionStatus::Failed) - .error(error), + acp_v1::SessionUpdate::CompactionUpdate( + acp_v1::CompactionUpdate::new( + "compaction", + acp_v1::CompactionStatus::Failed, + ) + .error(error), ), cx, ) @@ -7779,16 +7819,16 @@ mod tests { } for summary in [ - vec![acp::ContentBlock::Text(acp::TextContent::new(""))], + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new(""))], Vec::new(), ] { let expected_length = summary.len(); thread .handle_session_update( - acp::SessionUpdate::CompactionUpdate( - acp::CompactionUpdate::new( + acp_v1::SessionUpdate::CompactionUpdate( + acp_v1::CompactionUpdate::new( "compaction", - acp::CompactionStatus::Completed, + acp_v1::CompactionStatus::Completed, ) .summary(summary), ), @@ -7817,35 +7857,35 @@ mod tests { .expect("failed to create ACP thread"); let image_data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="; let text_resource = - acp::EmbeddedResource::new(acp::EmbeddedResourceResource::TextResourceContents( - acp::TextResourceContents::new("Retained resource text", "summary://context") + acp_v1::EmbeddedResource::new(acp_v1::EmbeddedResourceResource::TextResourceContents( + acp_v1::TextResourceContents::new("Retained resource text", "summary://context") .mime_type("text/markdown".to_string()), )); let blob_resource = - acp::EmbeddedResource::new(acp::EmbeddedResourceResource::BlobResourceContents( - acp::BlobResourceContents::new("c3VtbWFyeQ==", "summary://attachment") + acp_v1::EmbeddedResource::new(acp_v1::EmbeddedResourceResource::BlobResourceContents( + acp_v1::BlobResourceContents::new("c3VtbWFyeQ==", "summary://attachment") .mime_type("application/octet-stream".to_string()), )); - let audio = acp::ContentBlock::Audio(acp::AudioContent::new("YXVkaW8=", "audio/wav")); + let audio = acp_v1::ContentBlock::Audio(acp_v1::AudioContent::new("YXVkaW8=", "audio/wav")); let blocks = vec![ - acp::ContentBlock::Text(acp::TextContent::new("retained ")), - acp::ContentBlock::Text(acp::TextContent::new("context")), - acp::ContentBlock::Resource(text_resource.clone()), - acp::ContentBlock::Image(acp::ImageContent::new(image_data, "image/png")), - acp::ContentBlock::ResourceLink(acp::ResourceLink::new( + acp_v1::ContentBlock::Text(acp_v1::TextContent::new("retained ")), + acp_v1::ContentBlock::Text(acp_v1::TextContent::new("context")), + acp_v1::ContentBlock::Resource(text_resource.clone()), + acp_v1::ContentBlock::Image(acp_v1::ImageContent::new(image_data, "image/png")), + acp_v1::ContentBlock::ResourceLink(acp_v1::ResourceLink::new( "Reference", "https://example.com/context", )), audio.clone(), - acp::ContentBlock::Resource(blob_resource.clone()), + acp_v1::ContentBlock::Resource(blob_resource.clone()), ]; thread.update(cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::CompactionUpdate(acp::CompactionUpdate::new( + acp_v1::SessionUpdate::CompactionUpdate(acp_v1::CompactionUpdate::new( "compaction", - acp::CompactionStatus::InProgress, + acp_v1::CompactionStatus::InProgress, )), cx, ) @@ -7853,8 +7893,8 @@ mod tests { for block in &blocks { thread .handle_session_update( - acp::SessionUpdate::CompactionSummaryChunk( - acp::CompactionSummaryChunk::new("compaction", block.clone()), + acp_v1::SessionUpdate::CompactionSummaryChunk( + acp_v1::CompactionSummaryChunk::new("compaction", block.clone()), ), cx, ) @@ -7864,13 +7904,15 @@ mod tests { for replace_summary in [false, true] { thread.update(cx, |thread, cx| { - let mut update = - acp::CompactionUpdate::new("compaction", acp::CompactionStatus::Completed); + let mut update = acp_v1::CompactionUpdate::new( + "compaction", + acp_v1::CompactionStatus::Completed, + ); if replace_summary { update = update.summary(blocks.clone()); } thread - .handle_session_update(acp::SessionUpdate::CompactionUpdate(update), cx) + .handle_session_update(acp_v1::SessionUpdate::CompactionUpdate(update), cx) .expect("failed to complete compaction"); }); thread.read_with(cx, |thread, cx| { @@ -7933,9 +7975,12 @@ mod tests { thread.update(cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::CompactionUpdate( - acp::CompactionUpdate::new("compaction", acp::CompactionStatus::Completed) - .summary(vec![audio.clone()]), + acp_v1::SessionUpdate::CompactionUpdate( + acp_v1::CompactionUpdate::new( + "compaction", + acp_v1::CompactionStatus::Completed, + ) + .summary(vec![audio.clone()]), ), cx, ) @@ -7983,22 +8028,22 @@ mod tests { thread.update(cx, |thread, cx| { for update in [ - acp::SessionUpdate::CompactionUpdate(acp::CompactionUpdate::new( + acp_v1::SessionUpdate::CompactionUpdate(acp_v1::CompactionUpdate::new( "first", - acp::CompactionStatus::InProgress, + acp_v1::CompactionStatus::InProgress, )), - acp::SessionUpdate::ToolCall(acp::ToolCall::new("tool", "Unrelated tool")), - acp::SessionUpdate::CompactionUpdate(acp::CompactionUpdate::new( + acp_v1::SessionUpdate::ToolCall(acp_v1::ToolCall::new("tool", "Unrelated tool")), + acp_v1::SessionUpdate::CompactionUpdate(acp_v1::CompactionUpdate::new( "second", - acp::CompactionStatus::InProgress, + acp_v1::CompactionStatus::InProgress, )), - acp::SessionUpdate::CompactionUpdate(acp::CompactionUpdate::new( + acp_v1::SessionUpdate::CompactionUpdate(acp_v1::CompactionUpdate::new( "second", - acp::CompactionStatus::Completed, + acp_v1::CompactionStatus::Completed, )), - acp::SessionUpdate::CompactionSummaryChunk(acp::CompactionSummaryChunk::new( + acp_v1::SessionUpdate::CompactionSummaryChunk(acp_v1::CompactionSummaryChunk::new( "first", - acp::ContentBlock::Text(acp::TextContent::new("partial summary")), + acp_v1::ContentBlock::Text(acp_v1::TextContent::new("partial summary")), )), ] { thread @@ -8012,9 +8057,9 @@ mod tests { thread.update(cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::CompactionUpdate(acp::CompactionUpdate::new( + acp_v1::SessionUpdate::CompactionUpdate(acp_v1::CompactionUpdate::new( "first", - acp::CompactionStatus::Cancelled, + acp_v1::CompactionStatus::Cancelled, )), cx, ) @@ -8055,37 +8100,37 @@ mod tests { cx.update(|cx| Arc::new(LanguageRegistry::test(cx.background_executor().clone()))); for (call, expected, has_strong_text) in [ ( - acp::ToolCall::new("tool", "Reading **file**").name("read_file"), + acp_v1::ToolCall::new("tool", "Reading **file**").name("read_file"), "Reading **file**", true, ), - (acp::ToolCall::new("tool", ""), "Tool call", false), + (acp_v1::ToolCall::new("tool", ""), "Tool call", false), ( - acp::ToolCall::new("tool", "\n\t ").name(" \t"), + acp_v1::ToolCall::new("tool", "\n\t ").name(" \t"), "Tool call", false, ), ( - acp::ToolCall::new("tool", "").name("**mcp__tool**"), + acp_v1::ToolCall::new("tool", "").name("**mcp__tool**"), "**mcp__tool**", false, ), ( - acp::ToolCall::new("tool", "\n\t ") + acp_v1::ToolCall::new("tool", "\n\t ") .name("**mcp__tool**") - .kind(acp::ToolKind::Edit), + .kind(acp_v1::ToolKind::Edit), "**mcp__tool**", false, ), ( - acp::ToolCall::new("tool", "") + acp_v1::ToolCall::new("tool", "") .name("**mcp__tool**") - .kind(acp::ToolKind::Execute), + .kind(acp_v1::ToolKind::Execute), "**mcp__tool**", false, ), ( - acp::ToolCall::new("tool", "").meta(meta_with_tool_name("legacy_tool")), + acp_v1::ToolCall::new("tool", "").meta(meta_with_tool_name("legacy_tool")), "legacy_tool", false, ), @@ -8132,7 +8177,7 @@ mod tests { cx.update(|cx| Arc::new(LanguageRegistry::test(cx.background_executor().clone()))); let mut call = cx.update(|cx| { ToolCall::from_acp( - acp::ToolCall::new("tool", ""), + acp_v1::ToolCall::new("tool", ""), ToolCallStatus::Pending, languages.clone(), &HashMap::default(), @@ -8142,49 +8187,49 @@ mod tests { }); for (update, expected, has_strong_text) in [ ( - acp::ToolCallUpdateFields::new().name("**tool_name**"), + acp_v1::ToolCallUpdateFields::new().name("**tool_name**"), "**tool_name**", false, ), ( - acp::ToolCallUpdateFields::new().title("**Readable title**"), + acp_v1::ToolCallUpdateFields::new().title("**Readable title**"), "**Readable title**", true, ), ( - acp::ToolCallUpdateFields::new().name("renamed_tool"), + acp_v1::ToolCallUpdateFields::new().name("renamed_tool"), "**Readable title**", true, ), ( - acp::ToolCallUpdateFields::new().kind(acp::ToolKind::Execute), + acp_v1::ToolCallUpdateFields::new().kind(acp_v1::ToolKind::Execute), "**Readable title**", false, ), ( - acp::ToolCallUpdateFields::new().kind(acp::ToolKind::Read), + acp_v1::ToolCallUpdateFields::new().kind(acp_v1::ToolKind::Read), "**Readable title**", true, ), ( - acp::ToolCallUpdateFields::new().title("\n\t "), + acp_v1::ToolCallUpdateFields::new().title("\n\t "), "renamed_tool", false, ), ( - acp::ToolCallUpdateFields::new().name(" \t"), + acp_v1::ToolCallUpdateFields::new().name(" \t"), "Tool call", false, ), ( - acp::ToolCallUpdateFields::new() + acp_v1::ToolCallUpdateFields::new() .title("**same_name**") .name("**same_name**"), "**same_name**", true, ), ( - acp::ToolCallUpdateFields::new().name("different_name"), + acp_v1::ToolCallUpdateFields::new().name("different_name"), "**same_name**", true, ), @@ -8224,8 +8269,8 @@ mod tests { thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCall( - acp::ToolCall::new("tool-call", "Tool call") + acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new("tool-call", "Tool call") .name("first_class") .meta(meta_with_tool_name("legacy")), ), @@ -8244,8 +8289,8 @@ mod tests { thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCall( - acp::ToolCall::new("legacy-tool-call", "Legacy tool call") + acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new("legacy-tool-call", "Legacy tool call") .meta(meta_with_tool_name("legacy")), ), cx, @@ -8263,9 +8308,12 @@ mod tests { thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCallUpdate( - acp::ToolCallUpdate::new("tool-call", acp::ToolCallUpdateFields::new()) - .meta(meta_with_tool_name("legacy_update")), + acp_v1::SessionUpdate::ToolCallUpdate( + acp_v1::ToolCallUpdate::new( + "tool-call", + acp_v1::ToolCallUpdateFields::new(), + ) + .meta(meta_with_tool_name("legacy_update")), ), cx, ) @@ -8275,7 +8323,7 @@ mod tests { thread.read_with(cx, |thread, _| { let Some(tool_call) = thread.entries.iter().find_map(|entry| match entry { AgentThreadEntry::ToolCall(tool_call) - if tool_call.id == acp::ToolCallId::new("tool-call") => + if tool_call.id == acp_v1::ToolCallId::new("tool-call") => { Some(tool_call) } @@ -8289,10 +8337,10 @@ mod tests { thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCallUpdate( - acp::ToolCallUpdate::new( + acp_v1::SessionUpdate::ToolCallUpdate( + acp_v1::ToolCallUpdate::new( "legacy-tool-call", - acp::ToolCallUpdateFields::new().name("first_class_update"), + acp_v1::ToolCallUpdateFields::new().name("first_class_update"), ) .meta(meta_with_tool_name("ignored_legacy_update")), ), @@ -8304,7 +8352,7 @@ mod tests { thread.read_with(cx, |thread, _| { let Some(tool_call) = thread.entries.iter().find_map(|entry| match entry { AgentThreadEntry::ToolCall(tool_call) - if tool_call.id == acp::ToolCallId::new("legacy-tool-call") => + if tool_call.id == acp_v1::ToolCallId::new("legacy-tool-call") => { Some(tool_call) } @@ -8318,7 +8366,7 @@ mod tests { thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCall(acp::ToolCall::new( + acp_v1::SessionUpdate::ToolCall(acp_v1::ToolCall::new( "late-legacy-tool-call", "Late legacy tool call", )), @@ -8329,10 +8377,10 @@ mod tests { thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCallUpdate( - acp::ToolCallUpdate::new( + acp_v1::SessionUpdate::ToolCallUpdate( + acp_v1::ToolCallUpdate::new( "late-legacy-tool-call", - acp::ToolCallUpdateFields::new(), + acp_v1::ToolCallUpdateFields::new(), ) .meta(meta_with_tool_name("late_legacy")), ), @@ -8352,12 +8400,12 @@ mod tests { #[gpui::test] fn test_context_compaction_exports_status(cx: &mut App) { for (status, expected_label) in [ - (acp::CompactionStatus::InProgress, "In Progress"), - (acp::CompactionStatus::Completed, "Completed"), - (acp::CompactionStatus::Failed, "Failed"), - (acp::CompactionStatus::Cancelled, "Canceled"), + (acp_v1::CompactionStatus::InProgress, "In Progress"), + (acp_v1::CompactionStatus::Completed, "Completed"), + (acp_v1::CompactionStatus::Failed, "Failed"), + (acp_v1::CompactionStatus::Cancelled, "Canceled"), ( - acp::CompactionStatus::Other("interrupted".into()), + acp_v1::CompactionStatus::Other("interrupted".into()), "interrupted", ), ] { @@ -8397,11 +8445,11 @@ mod tests { thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCall( - acp::ToolCall::new("write_file", "Write SKILL.md") - .kind(acp::ToolKind::Edit) - .status(acp::ToolCallStatus::Completed) - .locations(vec![acp::ToolCallLocation::new(skill_path.clone())]), + acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new("write_file", "Write SKILL.md") + .kind(acp_v1::ToolKind::Edit) + .status(acp_v1::ToolCallStatus::Completed) + .locations(vec![acp_v1::ToolCallLocation::new(skill_path.clone())]), ), cx, ) @@ -8440,20 +8488,20 @@ mod tests { .await .unwrap(); - let tool_call_id = acp::ToolCallId::new("toolu_01duplicate"); - let allow_option_id = acp::PermissionOptionId::new("allow"); + let tool_call_id = acp_v1::ToolCallId::new("toolu_01duplicate"); + let allow_option_id = acp_v1::PermissionOptionId::new("allow"); let permission_task = thread .update(cx, |thread, cx| { thread.request_tool_call_authorization( - acp::ToolCall::new(tool_call_id.clone(), "Original title") - .kind(acp::ToolKind::Execute) - .status(acp::ToolCallStatus::Pending) + acp_v1::ToolCall::new(tool_call_id.clone(), "Original title") + .kind(acp_v1::ToolKind::Execute) + .status(acp_v1::ToolCallStatus::Pending) .content(vec!["original content".into()]) .into(), - PermissionOptions::Flat(vec![acp::PermissionOption::new( + PermissionOptions::Flat(vec![acp_v1::PermissionOption::new( allow_option_id.clone(), "Allow", - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionKind::AllowOnce, )]), AuthorizationKind::PermissionGrant, cx, @@ -8464,10 +8512,10 @@ mod tests { thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCall( - acp::ToolCall::new(tool_call_id.clone(), "Updated title") - .kind(acp::ToolKind::Execute) - .status(acp::ToolCallStatus::Pending) + acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new(tool_call_id.clone(), "Updated title") + .kind(acp_v1::ToolKind::Execute) + .status(acp_v1::ToolCallStatus::Pending) .content(vec!["updated content".into()]), ), cx, @@ -8491,10 +8539,10 @@ mod tests { thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate::new( + acp_v1::SessionUpdate::ToolCallUpdate(acp_v1::ToolCallUpdate::new( tool_call_id.clone(), - acp::ToolCallUpdateFields::new() - .status(acp::ToolCallStatus::InProgress) + acp_v1::ToolCallUpdateFields::new() + .status(acp_v1::ToolCallStatus::InProgress) .title("Updated again") .content(vec!["updated again".into()]), )), @@ -8518,7 +8566,7 @@ mod tests { let selected_outcome = SelectedPermissionOutcome::new( allow_option_id.clone(), - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionKind::AllowOnce, ); thread.update(cx, |thread, cx| { thread.authorize_tool_call(tool_call_id.clone(), selected_outcome, cx); @@ -8534,7 +8582,7 @@ mod tests { match permission_task.await { RequestPermissionOutcome::Selected(outcome) => { assert_eq!(outcome.option_id, allow_option_id); - assert_eq!(outcome.option_kind, acp::PermissionOptionKind::AllowOnce); + assert_eq!(outcome.option_kind, acp_v1::PermissionOptionKind::AllowOnce); } RequestPermissionOutcome::Cancelled | RequestPermissionOutcome::InterruptedByFollowUp => { @@ -8545,10 +8593,10 @@ mod tests { thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate::new( + acp_v1::SessionUpdate::ToolCallUpdate(acp_v1::ToolCallUpdate::new( tool_call_id.clone(), - acp::ToolCallUpdateFields::new() - .status(acp::ToolCallStatus::Completed) + acp_v1::ToolCallUpdateFields::new() + .status(acp_v1::ToolCallStatus::Completed) .title("Completed") .content(vec!["done".into()]), )), @@ -8582,18 +8630,18 @@ mod tests { .await .unwrap(); - let tool_call_id = acp::ToolCallId::new("toolu_01auto_resolve"); + let tool_call_id = acp_v1::ToolCallId::new("toolu_01auto_resolve"); let permission_task = thread .update(cx, |thread, cx| { thread.request_tool_call_authorization( - acp::ToolCall::new(tool_call_id.clone(), "Original title") - .kind(acp::ToolKind::Execute) - .status(acp::ToolCallStatus::Pending) + acp_v1::ToolCall::new(tool_call_id.clone(), "Original title") + .kind(acp_v1::ToolKind::Execute) + .status(acp_v1::ToolCallStatus::Pending) .into(), - PermissionOptions::Flat(vec![acp::PermissionOption::new( - acp::PermissionOptionId::new("allow"), + PermissionOptions::Flat(vec![acp_v1::PermissionOption::new( + acp_v1::PermissionOptionId::new("allow"), "Allow", - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionKind::AllowOnce, )]), AuthorizationKind::PermissionGrant, cx, @@ -8604,9 +8652,10 @@ mod tests { thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate::new( + acp_v1::SessionUpdate::ToolCallUpdate(acp_v1::ToolCallUpdate::new( tool_call_id.clone(), - acp::ToolCallUpdateFields::new().status(acp::ToolCallStatus::InProgress), + acp_v1::ToolCallUpdateFields::new() + .status(acp_v1::ToolCallStatus::InProgress), )), cx, ) @@ -8620,7 +8669,7 @@ mod tests { assert!(matches!( tool_call.status, ToolCallStatus::WaitingForConfirmation { - current_status: acp::ToolCallStatus::InProgress, + current_status: acp_v1::ToolCallStatus::InProgress, .. } )); @@ -8630,8 +8679,8 @@ mod tests { thread.authorize_tool_call( tool_call_id.clone(), SelectedPermissionOutcome::new( - acp::PermissionOptionId::new("allow"), - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionId::new("allow"), + acp_v1::PermissionOptionKind::AllowOnce, ), cx, ); @@ -8646,8 +8695,8 @@ mod tests { match permission_task.await { RequestPermissionOutcome::Selected(outcome) => { - assert_eq!(outcome.option_id, acp::PermissionOptionId::new("allow")); - assert_eq!(outcome.option_kind, acp::PermissionOptionKind::AllowOnce); + assert_eq!(outcome.option_id, acp_v1::PermissionOptionId::new("allow")); + assert_eq!(outcome.option_kind, acp_v1::PermissionOptionKind::AllowOnce); } RequestPermissionOutcome::Cancelled | RequestPermissionOutcome::InterruptedByFollowUp => { @@ -8672,14 +8721,14 @@ mod tests { .await .unwrap(); - let tool_call_id = acp::ToolCallId::new("toolu_01existing_permission"); + let tool_call_id = acp_v1::ToolCallId::new("toolu_01existing_permission"); thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCall( - acp::ToolCall::new(tool_call_id.clone(), "Running title") - .kind(acp::ToolKind::Execute) - .status(acp::ToolCallStatus::InProgress), + acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new(tool_call_id.clone(), "Running title") + .kind(acp_v1::ToolKind::Execute) + .status(acp_v1::ToolCallStatus::InProgress), ), cx, ) @@ -8689,14 +8738,14 @@ mod tests { let permission_task = thread .update(cx, |thread, cx| { thread.request_tool_call_authorization( - acp::ToolCall::new(tool_call_id.clone(), "Needs permission") - .kind(acp::ToolKind::Execute) - .status(acp::ToolCallStatus::Pending) + acp_v1::ToolCall::new(tool_call_id.clone(), "Needs permission") + .kind(acp_v1::ToolKind::Execute) + .status(acp_v1::ToolCallStatus::Pending) .into(), - PermissionOptions::Flat(vec![acp::PermissionOption::new( - acp::PermissionOptionId::new("allow"), + PermissionOptions::Flat(vec![acp_v1::PermissionOption::new( + acp_v1::PermissionOptionId::new("allow"), "Allow", - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionKind::AllowOnce, )]), AuthorizationKind::PermissionGrant, cx, @@ -8712,7 +8761,7 @@ mod tests { assert!(matches!( tool_call.status, ToolCallStatus::WaitingForConfirmation { - current_status: acp::ToolCallStatus::InProgress, + current_status: acp_v1::ToolCallStatus::InProgress, .. } )); @@ -8722,8 +8771,8 @@ mod tests { thread.authorize_tool_call( tool_call_id.clone(), SelectedPermissionOutcome::new( - acp::PermissionOptionId::new("allow"), - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionId::new("allow"), + acp_v1::PermissionOptionKind::AllowOnce, ), cx, ); @@ -8731,8 +8780,8 @@ mod tests { match permission_task.await { RequestPermissionOutcome::Selected(outcome) => { - assert_eq!(outcome.option_id, acp::PermissionOptionId::new("allow")); - assert_eq!(outcome.option_kind, acp::PermissionOptionKind::AllowOnce); + assert_eq!(outcome.option_id, acp_v1::PermissionOptionId::new("allow")); + assert_eq!(outcome.option_kind, acp_v1::PermissionOptionKind::AllowOnce); } RequestPermissionOutcome::Cancelled | RequestPermissionOutcome::InterruptedByFollowUp => { @@ -8757,18 +8806,18 @@ mod tests { .await .unwrap(); - let tool_call_id = acp::ToolCallId::new("toolu_01cancelled_permission"); + let tool_call_id = acp_v1::ToolCallId::new("toolu_01cancelled_permission"); let permission_task = thread .update(cx, |thread, cx| { thread.request_tool_call_authorization( - acp::ToolCall::new(tool_call_id.clone(), "Needs permission") - .kind(acp::ToolKind::Execute) - .status(acp::ToolCallStatus::Pending) + acp_v1::ToolCall::new(tool_call_id.clone(), "Needs permission") + .kind(acp_v1::ToolKind::Execute) + .status(acp_v1::ToolCallStatus::Pending) .into(), - PermissionOptions::Flat(vec![acp::PermissionOption::new( - acp::PermissionOptionId::new("allow"), + PermissionOptions::Flat(vec![acp_v1::PermissionOption::new( + acp_v1::PermissionOptionId::new("allow"), "Allow", - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionKind::AllowOnce, )]), AuthorizationKind::PermissionGrant, cx, @@ -8812,18 +8861,18 @@ mod tests { .await .unwrap(); - let tool_call_id = acp::ToolCallId::new("toolu_01completed_while_waiting"); + let tool_call_id = acp_v1::ToolCallId::new("toolu_01completed_while_waiting"); let permission_task = thread .update(cx, |thread, cx| { thread.request_tool_call_authorization( - acp::ToolCall::new(tool_call_id.clone(), "Needs permission") - .kind(acp::ToolKind::Execute) - .status(acp::ToolCallStatus::Pending) + acp_v1::ToolCall::new(tool_call_id.clone(), "Needs permission") + .kind(acp_v1::ToolKind::Execute) + .status(acp_v1::ToolCallStatus::Pending) .into(), - PermissionOptions::Flat(vec![acp::PermissionOption::new( - acp::PermissionOptionId::new("allow"), + PermissionOptions::Flat(vec![acp_v1::PermissionOption::new( + acp_v1::PermissionOptionId::new("allow"), "Allow", - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionKind::AllowOnce, )]), AuthorizationKind::PermissionGrant, cx, @@ -8834,9 +8883,10 @@ mod tests { thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate::new( + acp_v1::SessionUpdate::ToolCallUpdate(acp_v1::ToolCallUpdate::new( tool_call_id.clone(), - acp::ToolCallUpdateFields::new().status(acp::ToolCallStatus::Completed), + acp_v1::ToolCallUpdateFields::new() + .status(acp_v1::ToolCallStatus::Completed), )), cx, ) @@ -8872,21 +8922,20 @@ mod tests { thread .update(&mut cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCall( - acp::ToolCall::new("test", "Label") - .kind(acp::ToolKind::Edit) - .status(acp::ToolCallStatus::Completed) - .content(vec![acp::ToolCallContent::Diff(acp::Diff::new( - "/test/test.txt", - "foo", - ))]), + acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new("test", "Label") + .kind(acp_v1::ToolKind::Edit) + .status(acp_v1::ToolCallStatus::Completed) + .content(vec![acp_v1::ToolCallContent::Diff( + acp_v1::Diff::new("/test/test.txt", "foo"), + )]), ), cx, ) }) .unwrap() .unwrap(); - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } .boxed_local() } @@ -8935,20 +8984,20 @@ mod tests { fs.write(Path::new(&filename), b"").await?; } - let acp::ContentBlock::Text(content) = &request.prompt[0] else { + let acp_v1::ContentBlock::Text(content) = &request.prompt[0] else { panic!("expected text content block"); }; thread.update(&mut cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new( - content.text.to_uppercase().into(), - )), + acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new(content.text.to_uppercase().into()), + ), cx, ) .unwrap(); })?; - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } .boxed_local() } @@ -9145,7 +9194,7 @@ mod tests { finish_response_rx.await.ok(); } - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } .boxed_local() } @@ -9219,10 +9268,10 @@ mod tests { thread.update(&mut cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::ToolCall( - acp::ToolCall::new("tool1", "Test Tool") - .kind(acp::ToolKind::Fetch) - .status(acp::ToolCallStatus::Completed) + acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new("tool1", "Test Tool") + .kind(acp_v1::ToolKind::Fetch) + .status(acp_v1::ToolCallStatus::Completed) .raw_input(serde_json::json!({"query": "test"})) .raw_output(serde_json::json!({"result": "inappropriate content"})), ), @@ -9232,9 +9281,9 @@ mod tests { })?; // Now return refusal because of the tool result - Ok(acp::PromptResponse::new(acp::StopReason::Refusal)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::Refusal)) } else { - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } } .boxed_local() @@ -9310,10 +9359,10 @@ mod tests { let refuse_next = refuse_next.clone(); move |_request, _thread, _cx| { if refuse_next.load(SeqCst) { - async move { Ok(acp::PromptResponse::new(acp::StopReason::Refusal)) } + async move { Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::Refusal)) } .boxed_local() } else { - async move { Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) } + async move { Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } .boxed_local() } } @@ -9373,23 +9422,23 @@ mod tests { let refuse_next = refuse_next.clone(); async move { if refuse_next.load(SeqCst) { - return Ok(acp::PromptResponse::new(acp::StopReason::Refusal)); + return Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::Refusal)); } - let acp::ContentBlock::Text(content) = &request.prompt[0] else { + let acp_v1::ContentBlock::Text(content) = &request.prompt[0] else { panic!("expected text content block"); }; thread.update(&mut cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new( - content.text.to_uppercase().into(), - )), + acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new(content.text.to_uppercase().into()), + ), cx, ) .unwrap(); })?; - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } .boxed_local() } @@ -9489,10 +9538,10 @@ mod tests { let result = thread.update(cx, |thread, cx| { thread.request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationSessionScope::new(session_id), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationSessionScope::new(session_id), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -9515,16 +9564,16 @@ mod tests { enable_acp_beta(cx); let thread = new_test_thread(cx).await; let session_id = thread.read_with(cx, |thread, _| thread.session_id().clone()); - let tool_call_id = acp::ToolCallId::new("tool-1"); + let tool_call_id = acp_v1::ToolCallId::new("tool-1"); let response_task = thread.update(cx, |thread, cx| { thread .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationSessionScope::new(session_id.clone()) + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationSessionScope::new(session_id.clone()) .tool_call_id(tool_call_id.clone()), - acp::ElicitationSchema::new().string("name", true), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -9535,7 +9584,7 @@ mod tests { let elicitation_id = thread.read_with(cx, |thread, _| { let (elicitation_id, elicitation) = only_thread_elicitation(thread); - let acp::ElicitationScope::Session(scope) = elicitation.request.scope() else { + let acp_v1::ElicitationScope::Session(scope) = elicitation.request.scope() else { panic!("expected session-scoped elicitation"); }; assert_eq!(scope.tool_call_id.as_ref(), Some(&tool_call_id)); @@ -9544,13 +9593,13 @@ mod tests { let expected_content = std::collections::BTreeMap::from([( "name".to_string(), - acp::ElicitationContentValue::from("Ada"), + acp_v1::ElicitationContentValue::from("Ada"), )]); thread.update(cx, |thread, cx| { thread.respond_to_elicitation( &elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new().content(expected_content.clone()), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new().content(expected_content.clone()), )), cx, ); @@ -9559,8 +9608,8 @@ mod tests { let response = response_task.await; assert_eq!( response.action, - acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new().content(expected_content) + acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new().content(expected_content) ) ); thread.read_with(cx, |thread, _| { @@ -9577,14 +9626,14 @@ mod tests { enable_acp_beta(cx); let thread = new_test_thread(cx).await; let session_id = thread.read_with(cx, |thread, _| thread.session_id().clone()); - let url_elicitation_id = acp::ElicitationId::new("url-1"); + let url_elicitation_id = acp_v1::ElicitationId::new("url-1"); let response_task = thread.update(cx, |thread, cx| { thread .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationUrlMode::new( - acp::ElicitationSessionScope::new(session_id), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationUrlMode::new( + acp_v1::ElicitationSessionScope::new(session_id), url_elicitation_id.clone(), "https://example.com/complete", ), @@ -9615,15 +9664,15 @@ mod tests { thread.update(cx, |thread, cx| { thread.respond_to_elicitation( &entry_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new(), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new(), )), cx, ); }); assert!(matches!( response_task.await.action, - acp::ElicitationAction::Accept(_) + acp_v1::ElicitationAction::Accept(_) )); thread.update(cx, |thread, cx| { thread.complete_url_elicitation(&url_elicitation_id, cx); @@ -9642,14 +9691,14 @@ mod tests { enable_acp_beta(cx); let thread = new_test_thread(cx).await; let session_id = thread.read_with(cx, |thread, _| thread.session_id().clone()); - let url_elicitation_id = acp::ElicitationId::new("url-1"); + let url_elicitation_id = acp_v1::ElicitationId::new("url-1"); let response_task = thread.update(cx, |thread, cx| { thread .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationUrlMode::new( - acp::ElicitationSessionScope::new(session_id), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationUrlMode::new( + acp_v1::ElicitationSessionScope::new(session_id), url_elicitation_id.clone(), "https://example.com/complete", ), @@ -9668,15 +9717,15 @@ mod tests { thread.update(cx, |thread, cx| { thread.respond_to_elicitation( &entry_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new(), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new(), )), cx, ); }); assert!(matches!( response_task.await.action, - acp::ElicitationAction::Accept(_) + acp_v1::ElicitationAction::Accept(_) )); thread.update(cx, |thread, cx| { @@ -9706,14 +9755,14 @@ mod tests { enable_acp_beta(cx); let thread = new_test_thread(cx).await; let session_id = thread.read_with(cx, |thread, _| thread.session_id().clone()); - let url_elicitation_id = acp::ElicitationId::new("url-1"); + let url_elicitation_id = acp_v1::ElicitationId::new("url-1"); let response_task = thread.update(cx, |thread, cx| { thread .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationUrlMode::new( - acp::ElicitationSessionScope::new(session_id), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationUrlMode::new( + acp_v1::ElicitationSessionScope::new(session_id), url_elicitation_id.clone(), "https://example.com/complete", ), @@ -9732,15 +9781,15 @@ mod tests { thread.update(cx, |thread, cx| { thread.respond_to_elicitation( &entry_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new(), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new(), )), cx, ); }); assert!(matches!( response_task.await.action, - acp::ElicitationAction::Accept(_) + acp_v1::ElicitationAction::Accept(_) )); thread.read_with(cx, |thread, _| { let Some((_, elicitation)) = thread.elicitation(&entry_id) else { @@ -9785,15 +9834,15 @@ mod tests { let stop_reason = { let mut prompt_count = prompt_count.borrow_mut(); let stop_reason = if *prompt_count == 0 { - acp::StopReason::EndTurn + acp_v1::StopReason::EndTurn } else { - acp::StopReason::Cancelled + acp_v1::StopReason::Cancelled }; *prompt_count += 1; stop_reason }; - async move { Ok(acp::PromptResponse::new(stop_reason)) }.boxed_local() + async move { Ok(acp_v1::PromptResponse::new(stop_reason)) }.boxed_local() } })); let thread = cx @@ -9808,16 +9857,16 @@ mod tests { .await .expect("first turn should succeed") .expect("first turn should return a response"); - assert_eq!(response.stop_reason, acp::StopReason::EndTurn); + assert_eq!(response.stop_reason, acp_v1::StopReason::EndTurn); let session_id = thread.read_with(cx, |thread, _| thread.session_id().clone()); - let url_elicitation_id = acp::ElicitationId::new("url-1"); + let url_elicitation_id = acp_v1::ElicitationId::new("url-1"); let response_task = thread.update(cx, |thread, cx| { thread .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationUrlMode::new( - acp::ElicitationSessionScope::new(session_id), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationUrlMode::new( + acp_v1::ElicitationSessionScope::new(session_id), url_elicitation_id.clone(), "https://example.com/complete", ), @@ -9836,15 +9885,15 @@ mod tests { thread.update(cx, |thread, cx| { thread.respond_to_elicitation( &entry_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new(), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new(), )), cx, ); }); assert!(matches!( response_task.await.action, - acp::ElicitationAction::Accept(_) + acp_v1::ElicitationAction::Accept(_) )); let response = thread @@ -9852,7 +9901,7 @@ mod tests { .await .expect("second turn should succeed") .expect("second turn should return a response"); - assert_eq!(response.stop_reason, acp::StopReason::Cancelled); + assert_eq!(response.stop_reason, acp_v1::StopReason::Cancelled); thread.read_with(cx, |thread, _| { let Some((_, elicitation)) = thread.elicitation(&entry_id) else { panic!("missing elicitation entry"); @@ -9880,10 +9929,10 @@ mod tests { let response_task = store.update(cx, |store, cx| { store .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationRequestScope::new(acp::RequestId::Number(1)), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -9899,22 +9948,25 @@ mod tests { store.elicitations() ); }; - let acp::ElicitationScope::Request(scope) = elicitation.request.scope() else { + let acp_v1::ElicitationScope::Request(scope) = elicitation.request.scope() else { panic!("expected request-scoped elicitation"); }; - assert_eq!(scope.request_id, acp::RequestId::Number(1)); + assert_eq!(scope.request_id, acp_v1::RequestId::Number(1)); elicitation.id.clone() }); store.update(cx, |store, cx| { store.respond_to_elicitation( &elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Decline), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Decline), cx, ); }); - assert_eq!(response_task.await.action, acp::ElicitationAction::Decline); + assert_eq!( + response_task.await.action, + acp_v1::ElicitationAction::Decline + ); store.read_with(cx, |store, _| { let Some((_, elicitation)) = store.elicitation(&elicitation_id) else { panic!("missing elicitation entry"); @@ -9941,10 +9993,10 @@ mod tests { let response_task = store.update(cx, |store, cx| { store .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationRequestScope::new(acp::RequestId::Number(1)), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -9966,19 +10018,22 @@ mod tests { store.update(cx, |store, cx| { store.respond_to_elicitation( &elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Decline), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Decline), cx, ); store.respond_to_elicitation( &elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new(), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new(), )), cx, ); }); - assert_eq!(response_task.await.action, acp::ElicitationAction::Decline); + assert_eq!( + response_task.await.action, + acp_v1::ElicitationAction::Decline + ); assert_eq!( responded_ids.borrow().as_slice(), std::slice::from_ref(&elicitation_id) @@ -10001,10 +10056,10 @@ mod tests { let (elicitation_id, response_task) = thread.update(cx, |thread, cx| { thread .request_elicitation_with_id( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationSessionScope::new(session_id), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationSessionScope::new(session_id), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -10017,7 +10072,10 @@ mod tests { thread.cancel_elicitation(&elicitation_id, cx); }); - assert_eq!(response_task.await.action, acp::ElicitationAction::Cancel); + assert_eq!( + response_task.await.action, + acp_v1::ElicitationAction::Cancel + ); thread.read_with(cx, |thread, _| { let Some((_, elicitation)) = thread.elicitation(&elicitation_id) else { panic!("missing elicitation entry"); @@ -10036,10 +10094,10 @@ mod tests { let response_task = thread.update(cx, |thread, cx| { thread .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationSessionScope::new(session_id), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationSessionScope::new(session_id), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -10057,7 +10115,10 @@ mod tests { thread.cancel(cx).detach(); }); - assert_eq!(response_task.await.action, acp::ElicitationAction::Cancel); + assert_eq!( + response_task.await.action, + acp_v1::ElicitationAction::Cancel + ); thread.read_with(cx, |thread, _| { let Some((_, elicitation)) = thread.elicitation(&elicitation_id) else { panic!("missing elicitation entry"); @@ -10068,16 +10129,16 @@ mod tests { fn request_test_session_elicitation( thread: WeakEntity, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, cx: &mut AsyncApp, - ) -> Result> { + ) -> Result> { thread.update(cx, |thread, cx| { thread .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationSessionScope::new(session_id), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationSessionScope::new(session_id), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -10127,7 +10188,7 @@ mod tests { cx.run_until_parked(); assert_eq!( *elicitation_action.borrow(), - Some(acp::ElicitationAction::Cancel) + Some(acp_v1::ElicitationAction::Cancel) ); thread.read_with(cx, |thread, _| { let Some(elicitation) = thread.entries().iter().find_map(|entry| match entry { @@ -10162,7 +10223,7 @@ mod tests { }) .detach(); - Ok(acp::PromptResponse::new(acp::StopReason::MaxTokens)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::MaxTokens)) } .boxed_local() } @@ -10182,7 +10243,7 @@ mod tests { cx.run_until_parked(); assert_eq!( *elicitation_action.borrow(), - Some(acp::ElicitationAction::Cancel) + Some(acp_v1::ElicitationAction::Cancel) ); thread.read_with(cx, |thread, _| { let Some(elicitation) = thread.entries().iter().find_map(|entry| match entry { @@ -10206,10 +10267,10 @@ mod tests { let (elicitation_id, response_task) = store.update(cx, |store, cx| { store .request_elicitation_with_id( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationRequestScope::new(acp::RequestId::Number(1)), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -10222,7 +10283,10 @@ mod tests { store.cancel_elicitation(&elicitation_id, cx); }); - assert_eq!(response_task.await.action, acp::ElicitationAction::Cancel); + assert_eq!( + response_task.await.action, + acp_v1::ElicitationAction::Cancel + ); store.read_with(cx, |store, _| { let Some((_, elicitation)) = store.elicitation(&elicitation_id) else { panic!("missing elicitation entry"); @@ -10247,14 +10311,14 @@ mod tests { }) }); - let request_id = acp::RequestId::Number(1); + let request_id = acp_v1::RequestId::Number(1); let (elicitation_id, response_task) = store.update(cx, |store, cx| { store .request_elicitation_with_id( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationRequestScope::new(request_id.clone()), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationRequestScope::new(request_id.clone()), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -10287,10 +10351,10 @@ mod tests { let response_task = store.update(cx, |store, cx| { store .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationRequestScope::new(acp::RequestId::Number(1)), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -10303,7 +10367,10 @@ mod tests { store.cancel_all(cx); }); - assert_eq!(response_task.await.action, acp::ElicitationAction::Cancel); + assert_eq!( + response_task.await.action, + acp_v1::ElicitationAction::Cancel + ); } #[gpui::test] @@ -10317,10 +10384,10 @@ mod tests { let first_response_task = store.update(cx, |store, cx| { store .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationRequestScope::new(acp::RequestId::Number(1)), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -10331,10 +10398,10 @@ mod tests { let second_response_task = store.update(cx, |store, cx| { store .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationRequestScope::new(acp::RequestId::Number(2)), - acp::ElicitationSchema::new().string("account", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationRequestScope::new(acp_v1::RequestId::Number(2)), + acp_v1::ElicitationSchema::new().string("account", true), ), "Provide an account", ), @@ -10353,7 +10420,7 @@ mod tests { store.update(cx, |store, cx| { store.respond_to_elicitation( &first_elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Decline), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Decline), cx, ); store.clear(cx); @@ -10361,11 +10428,11 @@ mod tests { assert_eq!( first_response_task.await.action, - acp::ElicitationAction::Decline + acp_v1::ElicitationAction::Decline ); assert_eq!( second_response_task.await.action, - acp::ElicitationAction::Cancel + acp_v1::ElicitationAction::Cancel ); store.read_with(cx, |store, _| assert!(store.elicitations().is_empty())); } @@ -10377,15 +10444,15 @@ mod tests { init_test(cx); enable_acp_beta(cx); let store = cx.update(|cx| cx.new(|_| ElicitationStore::default())); - let url_elicitation_id = acp::ElicitationId::new("url-1"); + let url_elicitation_id = acp_v1::ElicitationId::new("url-1"); let accepted_response_task = store.update(cx, |store, cx| { store .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationRequestScope::new(acp::RequestId::Number(1)), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -10396,10 +10463,10 @@ mod tests { let pending_response_task = store.update(cx, |store, cx| { store .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationRequestScope::new(acp::RequestId::Number(2)), - acp::ElicitationSchema::new().string("account", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationRequestScope::new(acp_v1::RequestId::Number(2)), + acp_v1::ElicitationSchema::new().string("account", true), ), "Provide an account", ), @@ -10410,9 +10477,9 @@ mod tests { let accepted_url_response_task = store.update(cx, |store, cx| { store .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationUrlMode::new( - acp::ElicitationRequestScope::new(acp::RequestId::Number(3)), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationUrlMode::new( + acp_v1::ElicitationRequestScope::new(acp_v1::RequestId::Number(3)), url_elicitation_id, "https://example.com/complete", ), @@ -10440,26 +10507,26 @@ mod tests { store.update(cx, |store, cx| { store.respond_to_elicitation( &accepted_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new(), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new(), )), cx, ); store.respond_to_elicitation( &accepted_url_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new(), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new(), )), cx, ); }); assert!(matches!( accepted_response_task.await.action, - acp::ElicitationAction::Accept(_) + acp_v1::ElicitationAction::Accept(_) )); assert!(matches!( accepted_url_response_task.await.action, - acp::ElicitationAction::Accept(_) + acp_v1::ElicitationAction::Accept(_) )); let cleared_ids = store.update(cx, |store, cx| store.clear_resolved(cx)); @@ -10480,7 +10547,7 @@ mod tests { store.update(cx, |store, cx| store.clear(cx)); assert_eq!( pending_response_task.await.action, - acp::ElicitationAction::Cancel + acp_v1::ElicitationAction::Cancel ); } @@ -10489,14 +10556,14 @@ mod tests { init_test(cx); enable_acp_beta(cx); let store = cx.update(|cx| cx.new(|_| ElicitationStore::default())); - let url_elicitation_id = acp::ElicitationId::new("url-1"); + let url_elicitation_id = acp_v1::ElicitationId::new("url-1"); let response_task = store.update(cx, |store, cx| { store .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationUrlMode::new( - acp::ElicitationRequestScope::new(acp::RequestId::Number(1)), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationUrlMode::new( + acp_v1::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)), url_elicitation_id.clone(), "https://example.com/complete", ), @@ -10532,15 +10599,15 @@ mod tests { store.update(cx, |store, cx| { store.respond_to_elicitation( &entry_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new(), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new(), )), cx, ); }); assert!(matches!( response_task.await.action, - acp::ElicitationAction::Accept(_) + acp_v1::ElicitationAction::Accept(_) )); store.update(cx, |store, cx| { store.complete_url_elicitation(&url_elicitation_id, cx); @@ -10560,7 +10627,7 @@ mod tests { init_test(cx); enable_acp_beta(cx); let store = cx.update(|cx| cx.new(|_| ElicitationStore::default())); - let url_elicitation_id = acp::ElicitationId::new("url-1"); + let url_elicitation_id = acp_v1::ElicitationId::new("url-1"); let responded_ids = Rc::new(RefCell::new(Vec::new())); let _subscription = cx.update(|cx| { let responded_ids = responded_ids.clone(); @@ -10574,9 +10641,9 @@ mod tests { let response_task = store.update(cx, |store, cx| { store .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationUrlMode::new( - acp::ElicitationRequestScope::new(acp::RequestId::Number(1)), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationUrlMode::new( + acp_v1::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)), url_elicitation_id.clone(), "https://example.com/complete", ), @@ -10600,15 +10667,15 @@ mod tests { store.update(cx, |store, cx| { store.respond_to_elicitation( &entry_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new(), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new(), )), cx, ); }); assert!(matches!( response_task.await.action, - acp::ElicitationAction::Accept(_) + acp_v1::ElicitationAction::Accept(_) )); assert_eq!( responded_ids.borrow().as_slice(), @@ -10651,10 +10718,10 @@ mod tests { let response_task = thread.update(cx, |thread, cx| { thread .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationSessionScope::new(session_id), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationSessionScope::new(session_id), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -10671,13 +10738,16 @@ mod tests { thread.update(cx, |thread, cx| { thread.respond_to_elicitation( &elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Decline), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Decline), cx, ); thread.cancel(cx).detach(); }); - assert_eq!(response_task.await.action, acp::ElicitationAction::Decline); + assert_eq!( + response_task.await.action, + acp_v1::ElicitationAction::Decline + ); thread.read_with(cx, |thread, _| { let Some((_, elicitation)) = thread.elicitation(&elicitation_id) else { panic!("missing elicitation entry"); @@ -10696,10 +10766,10 @@ mod tests { let response_task = thread.update(cx, |thread, cx| { thread .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationSessionScope::new(session_id), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationSessionScope::new(session_id), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -10716,19 +10786,22 @@ mod tests { thread.update(cx, |thread, cx| { thread.respond_to_elicitation( &elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Decline), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Decline), cx, ); thread.respond_to_elicitation( &elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new(), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new(), )), cx, ); }); - assert_eq!(response_task.await.action, acp::ElicitationAction::Decline); + assert_eq!( + response_task.await.action, + acp_v1::ElicitationAction::Decline + ); thread.read_with(cx, |thread, _| { let Some((_, elicitation)) = thread.elicitation(&elicitation_id) else { panic!("missing elicitation entry"); @@ -10753,9 +10826,9 @@ mod tests { ] { let result = thread.update(cx, |thread, cx| { thread.request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationUrlMode::new( - acp::ElicitationSessionScope::new(session_id.clone()), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationUrlMode::new( + acp_v1::ElicitationSessionScope::new(session_id.clone()), "url-1", invalid_url, ), @@ -10768,7 +10841,7 @@ mod tests { let Err(error) = result else { panic!("{invalid_url} should not be accepted for URL elicitation"); }; - assert_eq!(error.code, acp::ErrorCode::InvalidParams); + assert_eq!(error.code, acp_v1::ErrorCode::InvalidParams); } thread.read_with(cx, |thread, _| assert!(thread.entries().is_empty())); } @@ -10781,10 +10854,10 @@ mod tests { let result = thread.update(cx, |thread, cx| { thread.request_elicitation( - acp::CreateElicitationRequest::new( - acp::OtherElicitationMode::new( + acp_v1::CreateElicitationRequest::new( + acp_v1::OtherElicitationMode::new( "future", - acp::ElicitationSessionScope::new(session_id), + acp_v1::ElicitationSessionScope::new(session_id), std::collections::BTreeMap::new(), ), "Use a future input mode", @@ -10796,7 +10869,7 @@ mod tests { let Err(error) = result else { panic!("unadvertised elicitation mode should be rejected"); }; - assert_eq!(error.code, acp::ErrorCode::InvalidParams); + assert_eq!(error.code, acp_v1::ErrorCode::InvalidParams); thread.read_with(cx, |thread, _| assert!(thread.entries().is_empty())); } @@ -10807,10 +10880,10 @@ mod tests { let result = store.update(cx, |store, cx| { store.request_elicitation( - acp::CreateElicitationRequest::new( - acp::OtherElicitationMode::new( + acp_v1::CreateElicitationRequest::new( + acp_v1::OtherElicitationMode::new( "future", - acp::ElicitationRequestScope::new(acp::RequestId::Number(1)), + acp_v1::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)), std::collections::BTreeMap::new(), ), "Use a future input mode", @@ -10822,7 +10895,7 @@ mod tests { let Err(error) = result else { panic!("unadvertised elicitation mode should be rejected"); }; - assert_eq!(error.code, acp::ErrorCode::InvalidParams); + assert_eq!(error.code, acp_v1::ErrorCode::InvalidParams); store.read_with(cx, |store, _| assert!(store.elicitations().is_empty())); } @@ -10855,17 +10928,18 @@ mod tests { #[derive(Clone, Default)] struct FakeAgentConnection { - auth_methods: Vec, + auth_methods: Vec, supports_truncate: bool, - sessions: Arc>>>, + sessions: Arc>>>, set_title_calls: Rc>>, on_user_message: Option< Rc< dyn Fn( - acp::PromptRequest, + acp_v1::PromptRequest, WeakEntity, AsyncApp, - ) -> LocalBoxFuture<'static, Result> + ) + -> LocalBoxFuture<'static, Result> + 'static, >, >, @@ -10888,7 +10962,7 @@ mod tests { } #[expect(unused)] - fn with_auth_methods(mut self, auth_methods: Vec) -> Self { + fn with_auth_methods(mut self, auth_methods: Vec) -> Self { self.auth_methods = auth_methods; self } @@ -10896,10 +10970,10 @@ mod tests { fn on_user_message( mut self, handler: impl Fn( - acp::PromptRequest, + acp_v1::PromptRequest, WeakEntity, AsyncApp, - ) -> LocalBoxFuture<'static, Result> + ) -> LocalBoxFuture<'static, Result> + 'static, ) -> Self { self.on_user_message.replace(Rc::new(handler)); @@ -10916,7 +10990,7 @@ mod tests { "fake".into() } - fn auth_methods(&self) -> &[acp::AuthMethod] { + fn auth_methods(&self) -> &[acp_v1::AuthMethod] { &self.auth_methods } @@ -10926,7 +11000,7 @@ mod tests { work_dirs: PathList, cx: &mut App, ) -> Task>> { - let session_id = acp::SessionId::new( + let session_id = acp_v1::SessionId::new( rand::rng() .sample_iter(&distr::Alphanumeric) .take(7) @@ -10944,7 +11018,7 @@ mod tests { action_log, session_id.clone(), watch::Receiver::constant( - acp::PromptCapabilities::new() + acp_v1::PromptCapabilities::new() .image(true) .audio(true) .embedded_context(true), @@ -10956,7 +11030,11 @@ mod tests { Task::ready(Ok(thread)) } - fn authenticate(&self, method: acp::AuthMethodId, _cx: &mut App) -> Task> { + fn authenticate( + &self, + method: acp_v1::AuthMethodId, + _cx: &mut App, + ) -> Task> { if self.auth_methods().iter().any(|m| m.id() == &method) { Task::ready(Ok(())) } else { @@ -10966,9 +11044,9 @@ mod tests { fn prompt( &self, - params: acp::PromptRequest, + params: acp_v1::PromptRequest, cx: &mut App, - ) -> Task> { + ) -> Task> { let sessions = self.sessions.lock(); let thread = sessions.get(¶ms.session_id).unwrap(); if let Some(handler) = &self.on_user_message { @@ -10976,7 +11054,7 @@ mod tests { let thread = thread.clone(); cx.spawn(async move |cx| handler(params, thread, cx.clone()).await) } else { - Task::ready(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + Task::ready(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) } } @@ -10991,11 +11069,11 @@ mod tests { }) } - fn cancel(&self, _session_id: &acp::SessionId, _cx: &mut App) {} + fn cancel(&self, _session_id: &acp_v1::SessionId, _cx: &mut App) {} fn truncate( &self, - session_id: &acp::SessionId, + session_id: &acp_v1::SessionId, _cx: &App, ) -> Option> { self.supports_truncate.then(|| { @@ -11007,7 +11085,7 @@ mod tests { fn set_title( &self, - _session_id: &acp::SessionId, + _session_id: &acp_v1::SessionId, _cx: &App, ) -> Option> { Some(Rc::new(FakeAgentSessionSetTitle { @@ -11032,7 +11110,7 @@ mod tests { } struct FakeAgentSessionEditor { - _session_id: acp::SessionId, + _session_id: acp_v1::SessionId, } impl AgentSessionTruncate for FakeAgentSessionEditor { @@ -11053,9 +11131,9 @@ mod tests { fn prompt( &self, _client_user_message_id: ClientUserMessageId, - params: acp::PromptRequest, + params: acp_v1::PromptRequest, cx: &mut App, - ) -> Task> { + ) -> Task> { self.connection.prompt(params, cx) } } @@ -11075,12 +11153,12 @@ mod tests { .unwrap(); // Try to update a tool call that doesn't exist - let nonexistent_id = acp::ToolCallId::new("nonexistent-tool-call"); + let nonexistent_id = acp_v1::ToolCallId::new("nonexistent-tool-call"); thread.update(cx, |thread, cx| { let result = thread.handle_session_update( - acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate::new( + acp_v1::SessionUpdate::ToolCallUpdate(acp_v1::ToolCallUpdate::new( nonexistent_id.clone(), - acp::ToolCallUpdateFields::new().status(acp::ToolCallStatus::Completed), + acp_v1::ToolCallUpdateFields::new().status(acp_v1::ToolCallStatus::Completed), )), cx, ); @@ -11095,7 +11173,7 @@ mod tests { if let AgentThreadEntry::ToolCall(tool_call) = &thread.entries[0] { assert_eq!(tool_call.id, nonexistent_id); assert!(matches!(tool_call.status, ToolCallStatus::Failed)); - assert_eq!(tool_call.kind, acp::ToolKind::Fetch); + assert_eq!(tool_call.kind, acp_v1::ToolKind::Fetch); // Check that the content contains the error message assert_eq!(tool_call.content.len(), 1); @@ -11150,7 +11228,7 @@ mod tests { .unwrap(); // Create 2 terminals BEFORE the checkpoint that have completed running - let terminal_id_1 = acp::TerminalId::new(uuid::Uuid::new_v4().to_string()); + let terminal_id_1 = acp_v1::TerminalId::new(uuid::Uuid::new_v4().to_string()); let mock_terminal_1 = cx.new(|cx| { let builder = ::terminal::TerminalBuilder::new_display_only( ::terminal::terminal_settings::CursorShape::default(), @@ -11190,13 +11268,13 @@ mod tests { thread.on_terminal_provider_event( TerminalProviderEvent::Exit { terminal_id: terminal_id_1.clone(), - status: acp::TerminalExitStatus::new().exit_code(0), + status: acp_v1::TerminalExitStatus::new().exit_code(0), }, cx, ); }); - let terminal_id_2 = acp::TerminalId::new(uuid::Uuid::new_v4().to_string()); + let terminal_id_2 = acp_v1::TerminalId::new(uuid::Uuid::new_v4().to_string()); let mock_terminal_2 = cx.new(|cx| { let builder = ::terminal::TerminalBuilder::new_display_only( ::terminal::terminal_settings::CursorShape::default(), @@ -11236,7 +11314,7 @@ mod tests { thread.on_terminal_provider_event( TerminalProviderEvent::Exit { terminal_id: terminal_id_2.clone(), - status: acp::TerminalExitStatus::new().exit_code(0), + status: acp_v1::TerminalExitStatus::new().exit_code(0), }, cx, ); @@ -11256,7 +11334,7 @@ mod tests { // Create a terminal AFTER the checkpoint we'll restore to. // This simulates the AI agent starting a long-running terminal command. - let terminal_id = acp::TerminalId::new(uuid::Uuid::new_v4().to_string()); + let terminal_id = acp_v1::TerminalId::new(uuid::Uuid::new_v4().to_string()); let mock_terminal = cx.new(|cx| { let builder = ::terminal::TerminalBuilder::new_display_only( ::terminal::terminal_settings::CursorShape::default(), @@ -11299,13 +11377,13 @@ mod tests { thread.update(cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::ToolCall( - acp::ToolCall::new("terminal-tool-1", "Running command") - .kind(acp::ToolKind::Execute) - .status(acp::ToolCallStatus::InProgress) - .content(vec![acp::ToolCallContent::Terminal(acp::Terminal::new( - terminal_id.clone(), - ))]) + acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new("terminal-tool-1", "Running command") + .kind(acp_v1::ToolKind::Execute) + .status(acp_v1::ToolCallStatus::InProgress) + .content(vec![acp_v1::ToolCallContent::Terminal( + acp_v1::Terminal::new(terminal_id.clone()), + )]) .raw_input(serde_json::json!({"command": "sleep 1000", "cd": "/test"})), ), cx, @@ -11432,7 +11510,8 @@ mod tests { let connection = Rc::new(FakeAgentConnection::new().on_user_message( move |_, _thread, _cx| { handler_done_clone.store(true, SeqCst); - async move { Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) }.boxed_local() + async move { Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } + .boxed_local() }, )); @@ -11511,7 +11590,7 @@ mod tests { if let Some(rx) = complete_rx { rx.await.ok(); } - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } .boxed_local() }, @@ -11583,10 +11662,9 @@ mod tests { let connection = Rc::new(FakeAgentConnection::new().on_user_message({ move |params, _thread, _cx| { let first_complete_rx = first_complete_rx.borrow_mut().take(); - let is_first = params - .prompt - .iter() - .any(|c| matches!(c, acp::ContentBlock::Text(t) if t.text.contains("first"))); + let is_first = params.prompt.iter().any( + |c| matches!(c, acp_v1::ContentBlock::Text(t) if t.text.contains("first")), + ); let second_complete_rx = if is_first { None } else { @@ -11604,7 +11682,7 @@ mod tests { .expect("second completion receiver should be available") .await?; } - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } .boxed_local() } @@ -11625,7 +11703,7 @@ mod tests { let permission_task = thread .update(cx, |thread, cx| { thread.request_tool_call_authorization( - acp::ToolCall::new("permission", "Needs permission").into(), + acp_v1::ToolCall::new("permission", "Needs permission").into(), PermissionOptions::Flat(Vec::new()), AuthorizationKind::PermissionGrant, cx, @@ -11705,7 +11783,7 @@ mod tests { } complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("turn should still be running"); request.await.expect("turn should complete"); assert_eq!(cx.active_idle_sleep_preventions(), 0); @@ -11734,7 +11812,7 @@ mod tests { move |params, thread, mut cx| { let first_complete_rx = first_complete_rx.borrow_mut().take(); let is_first = params.prompt.iter().any(|content| { - matches!(content, acp::ContentBlock::Text(text) if text.text.contains("first")) + matches!(content, acp_v1::ContentBlock::Text(text) if text.text.contains("first")) }); let compaction_id = compaction_id.clone(); @@ -11757,9 +11835,9 @@ mod tests { ); })?; - Ok(acp::PromptResponse::new(acp::StopReason::Cancelled)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::Cancelled)) } else { - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } } .boxed_local() @@ -11787,7 +11865,7 @@ mod tests { .await .expect("first request should complete") .expect("first request should have response"); - assert_eq!(response.stop_reason, acp::StopReason::Cancelled); + assert_eq!(response.stop_reason, acp_v1::StopReason::Cancelled); thread.read_with(cx, |thread, _| { let compaction = thread @@ -11860,13 +11938,13 @@ mod tests { thread .update(&mut cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCall( - acp::ToolCall::new( - acp::ToolCallId::new("test-tool"), + acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new( + acp_v1::ToolCallId::new("test-tool"), "Test Tool", ) - .kind(acp::ToolKind::Fetch) - .status(acp::ToolCallStatus::InProgress), + .kind(acp_v1::ToolKind::Fetch) + .status(acp_v1::ToolCallStatus::InProgress), ), cx, ) @@ -11874,7 +11952,7 @@ mod tests { .unwrap() .unwrap(); - Ok(acp::PromptResponse::new(acp::StopReason::Cancelled)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::Cancelled)) } .boxed_local() }, @@ -11896,7 +11974,7 @@ mod tests { .expect("should have response"); assert_eq!( response.stop_reason, - acp::StopReason::Cancelled, + acp_v1::StopReason::Cancelled, "response should have Cancelled stop_reason" ); @@ -12025,8 +12103,8 @@ mod tests { let result = thread.update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::SessionInfoUpdate( - acp::SessionInfoUpdate::new().title("Helping with Rust question"), + acp_v1::SessionUpdate::SessionInfoUpdate( + acp_v1::SessionInfoUpdate::new().title("Helping with Rust question"), ), cx, ) @@ -12080,28 +12158,29 @@ mod tests { }) }); - let warning = acp::Notice::new(acp::NoticeSeverity::Warning, "MCP server unavailable") - .description("Continuing without it."); + let warning = + acp_v1::Notice::new(acp_v1::NoticeSeverity::Warning, "MCP server unavailable") + .description("Continuing without it."); let notices = vec![ - acp::Notice::new(acp::NoticeSeverity::Info, "Using default configuration"), + acp_v1::Notice::new(acp_v1::NoticeSeverity::Info, "Using default configuration"), warning.clone(), warning.clone(), - acp::Notice::new(acp::NoticeSeverity::Error, "Optional integration failed"), - acp::Notice::new( - acp::NoticeSeverity::Other("critical".into()), + acp_v1::Notice::new(acp_v1::NoticeSeverity::Error, "Optional integration failed"), + acp_v1::Notice::new( + acp_v1::NoticeSeverity::Other("critical".into()), "Future severity", ), - acp::Notice::new( - acp::NoticeSeverity::Other("_custom".into()), + acp_v1::Notice::new( + acp_v1::NoticeSeverity::Other("_custom".into()), "**Plain text**, not Markdown", ) - .meta(acp::Meta::from_iter([("source".into(), "test".into())])), + .meta(acp_v1::Meta::from_iter([("source".into(), "test".into())])), ]; thread.update(cx, |thread, cx| { for notice in ¬ices { thread - .handle_session_update(acp::SessionUpdate::Notice(notice.clone()), cx) + .handle_session_update(acp_v1::SessionUpdate::Notice(notice.clone()), cx) .expect("notice should be accepted"); } assert_eq!( @@ -12141,7 +12220,7 @@ mod tests { } assert!(thread.notices().is_empty()); thread - .handle_session_update(acp::SessionUpdate::Notice(warning.clone()), cx) + .handle_session_update(acp_v1::SessionUpdate::Notice(warning.clone()), cx) .expect("a repeated notice is a new live event"); thread.dismiss_notice(1, cx); assert_eq!(thread.notices(), &[(notices.len(), warning)]); @@ -12165,9 +12244,9 @@ mod tests { let history_before_notice = thread.to_markdown(cx); let entry_count = thread.entries().len(); thread.handle_session_update( - acp::SessionUpdate::Notice( - acp::Notice::new( - acp::NoticeSeverity::Error, + acp_v1::SessionUpdate::Notice( + acp_v1::Notice::new( + acp_v1::NoticeSeverity::Error, "Optional integration failed", ) .description("Work will continue without the integration."), @@ -12179,13 +12258,13 @@ mod tests { assert_eq!(thread.entries().len(), entry_count); assert_eq!(thread.to_markdown(cx), history_before_notice); thread.handle_session_update( - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new( + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new( "The response continues.".into(), )), cx, ) })??; - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } .boxed_local() }, @@ -12233,8 +12312,8 @@ mod tests { thread.update(cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::UsageUpdate( - acp::UsageUpdate::new(5000, 10000).cost(acp::Cost::new(0.42, "USD")), + acp_v1::SessionUpdate::UsageUpdate( + acp_v1::UsageUpdate::new(5000, 10000).cost(acp_v1::Cost::new(0.42, "USD")), ), cx, ) @@ -12269,8 +12348,8 @@ mod tests { thread.update(cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::UsageUpdate( - acp::UsageUpdate::new(5000, 10000).cost(acp::Cost::new(0.42, "USD")), + acp_v1::SessionUpdate::UsageUpdate( + acp_v1::UsageUpdate::new(5000, 10000).cost(acp_v1::Cost::new(0.42, "USD")), ), cx, ) @@ -12303,7 +12382,7 @@ mod tests { thread.update(cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::UsageUpdate(acp::UsageUpdate::new(1000, 10000)), + acp_v1::SessionUpdate::UsageUpdate(acp_v1::UsageUpdate::new(1000, 10000)), cx, ) .unwrap(); @@ -12335,8 +12414,8 @@ mod tests { thread.update(cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::UsageUpdate( - acp::UsageUpdate::new(1000, 10000).cost(acp::Cost::new(0.10, "USD")), + acp_v1::SessionUpdate::UsageUpdate( + acp_v1::UsageUpdate::new(1000, 10000).cost(acp_v1::Cost::new(0.10, "USD")), ), cx, ) @@ -12344,7 +12423,7 @@ mod tests { thread .handle_session_update( - acp::SessionUpdate::UsageUpdate(acp::UsageUpdate::new(2000, 10000)), + acp_v1::SessionUpdate::UsageUpdate(acp_v1::UsageUpdate::new(2000, 10000)), cx, ) .unwrap(); @@ -12371,16 +12450,16 @@ mod tests { thread.update(&mut cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::UsageUpdate( - acp::UsageUpdate::new(3000, 10000) - .cost(acp::Cost::new(0.05, "EUR")), + acp_v1::SessionUpdate::UsageUpdate( + acp_v1::UsageUpdate::new(3000, 10000) + .cost(acp_v1::Cost::new(0.05, "EUR")), ), cx, ) .unwrap(); })?; - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn) - .usage(acp::Usage::new(500, 200, 300))) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn) + .usage(acp_v1::Usage::new(500, 200, 300))) } .boxed_local() }, @@ -12431,8 +12510,8 @@ mod tests { thread.update(cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::UsageUpdate( - acp::UsageUpdate::new(1000, 10000).cost(acp::Cost::new(0.25, "USD")), + acp_v1::SessionUpdate::UsageUpdate( + acp_v1::UsageUpdate::new(1000, 10000).cost(acp_v1::Cost::new(0.25, "USD")), ), cx, ) @@ -12468,7 +12547,7 @@ mod tests { // `f(this, cx).await` with `tx` still alive but unsent. let connection = Rc::new(FakeAgentConnection::new().on_user_message( |_params, _thread, _cx| { - async move { futures::future::pending::>().await } + async move { futures::future::pending::>().await } .boxed_local() }, )); @@ -12535,7 +12614,7 @@ mod tests { async move |_, _| { completion.await?; backend_finished.store(true, SeqCst); - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) } }) }); @@ -12577,22 +12656,22 @@ mod tests { cx.set_idle_sleep_prevention_delay(delay); for (backend_result, expected_result, expected_had_error) in [ ( - Ok(acp::StopReason::EndTurn), - Ok(acp::StopReason::EndTurn), + Ok(acp_v1::StopReason::EndTurn), + Ok(acp_v1::StopReason::EndTurn), false, ), ( - Ok(acp::StopReason::Cancelled), - Ok(acp::StopReason::Cancelled), + Ok(acp_v1::StopReason::Cancelled), + Ok(acp_v1::StopReason::Cancelled), false, ), ( - Ok(acp::StopReason::Refusal), - Ok(acp::StopReason::Refusal), + Ok(acp_v1::StopReason::Refusal), + Ok(acp_v1::StopReason::Refusal), true, ), ( - Ok(acp::StopReason::MaxTokens), + Ok(acp_v1::StopReason::MaxTokens), Err("output token limit reached"), true, ), @@ -12608,7 +12687,7 @@ mod tests { assert!(!thread.read_with(cx, |thread, _| thread.had_error())); complete - .send(backend_result.map(acp::PromptResponse::new)) + .send(backend_result.map(acp_v1::PromptResponse::new)) .expect("turn should still be running"); let result = request .await @@ -12652,8 +12731,8 @@ mod tests { connection, project, action_log, - acp::SessionId::new("subagent"), - watch::Receiver::constant(acp::PromptCapabilities::new()), + acp_v1::SessionId::new("subagent"), + watch::Receiver::constant(acp_v1::PromptCapabilities::new()), cx, ) }) @@ -12675,14 +12754,16 @@ mod tests { let parent_cancel = parent.update(cx, |thread, cx| thread.cancel(cx)); assert_eq!(cx.active_idle_sleep_preventions(), 2); parent_complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::Cancelled))) + .send(Ok(acp_v1::PromptResponse::new( + acp_v1::StopReason::Cancelled, + ))) .expect("parent backend should still be running"); parent_cancel.await; parent_request.await.expect("parent turn should complete"); assert_eq!(cx.active_idle_sleep_preventions(), 2); independent_complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("independent turn should still be running"); independent_request .await @@ -12694,7 +12775,7 @@ mod tests { ); subagent_complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("subagent should still be running"); subagent_request .await @@ -12736,7 +12817,7 @@ mod tests { }); complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("backend should still be running"); cancel.await; request.await.expect("turn should complete"); @@ -12782,7 +12863,7 @@ mod tests { }); complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("turn should still be running"); request.await.expect("turn should complete"); assert_eq!(cx.active_idle_sleep_preventions(), 0); @@ -12817,7 +12898,9 @@ mod tests { }); first_complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::Cancelled))) + .send(Ok(acp_v1::PromptResponse::new( + acp_v1::StopReason::Cancelled, + ))) .expect("first backend should still be running"); first_request.await.expect("first turn should complete"); cx.run_until_parked(); @@ -12831,7 +12914,7 @@ mod tests { }); second_complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("second backend should still be running"); second_request.await.expect("second turn should complete"); assert_eq!(cx.active_idle_sleep_preventions(), 0); @@ -12913,7 +12996,7 @@ mod tests { }); complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("turn should still be running"); request.await.expect("turn should complete"); assert_eq!(cx.active_idle_sleep_preventions(), 0); @@ -12947,7 +13030,7 @@ mod tests { None }; complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("backend should still be running"); if let Some(cancel) = cancel { cancel.await; @@ -12967,7 +13050,7 @@ mod tests { cx.run_until_parked(); assert_eq!(cx.active_idle_sleep_preventions(), 1); complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("next turn should still be running"); request.await.expect("next turn should complete"); assert_eq!(cx.active_idle_sleep_preventions(), 0); @@ -12982,8 +13065,8 @@ mod tests { cx.run_until_parked(); assert_eq!(cx.active_idle_sleep_preventions(), 1); - let first_id = acp::ToolCallId::new("first-permission"); - let second_id = acp::ToolCallId::new("second-permission"); + let first_id = acp_v1::ToolCallId::new("first-permission"); + let second_id = acp_v1::ToolCallId::new("second-permission"); let first_permission = request_test_permission(&thread, first_id.clone(), cx); assert_eq!(cx.active_idle_sleep_preventions(), 0); let second_permission = request_test_permission(&thread, second_id.clone(), cx); @@ -12999,9 +13082,10 @@ mod tests { thread.update(cx, |thread, cx| { thread .update_tool_call( - acp::ToolCallUpdate::new( + acp_v1::ToolCallUpdate::new( first_id.clone(), - acp::ToolCallUpdateFields::new().status(acp::ToolCallStatus::InProgress), + acp_v1::ToolCallUpdateFields::new() + .status(acp_v1::ToolCallStatus::InProgress), ), cx, ) @@ -13009,8 +13093,8 @@ mod tests { thread.authorize_tool_call( second_id, SelectedPermissionOutcome::new( - acp::PermissionOptionId::new("reject"), - acp::PermissionOptionKind::RejectOnce, + acp_v1::PermissionOptionId::new("reject"), + acp_v1::PermissionOptionKind::RejectOnce, ), cx, ); @@ -13018,7 +13102,7 @@ mod tests { assert!(matches!( second_permission.await, RequestPermissionOutcome::Selected(outcome) - if outcome.option_kind == acp::PermissionOptionKind::RejectOnce + if outcome.option_kind == acp_v1::PermissionOptionKind::RejectOnce )); cx.run_until_parked(); assert_eq!(cx.active_idle_sleep_preventions(), 0); @@ -13026,13 +13110,13 @@ mod tests { thread.update(cx, |thread, cx| { thread.respond_to_elicitation( &elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Decline), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Decline), cx, ); }); assert_eq!( elicitation_response.await.action, - acp::ElicitationAction::Decline + acp_v1::ElicitationAction::Decline ); cx.run_until_parked(); assert!(thread.read_with(cx, |thread, _| thread.is_waiting_for_confirmation())); @@ -13042,8 +13126,8 @@ mod tests { thread.authorize_tool_call( first_id, SelectedPermissionOutcome::new( - acp::PermissionOptionId::new("allow"), - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionId::new("allow"), + acp_v1::PermissionOptionKind::AllowOnce, ), cx, ); @@ -13051,14 +13135,14 @@ mod tests { assert!(matches!( first_permission.await, RequestPermissionOutcome::Selected(outcome) - if outcome.option_kind == acp::PermissionOptionKind::AllowOnce + if outcome.option_kind == acp_v1::PermissionOptionKind::AllowOnce )); cx.run_until_parked(); assert!(!thread.read_with(cx, |thread, _| thread.is_waiting_for_confirmation())); assert_eq!(cx.active_idle_sleep_preventions(), 1); complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("turn should still be running"); request.await.expect("turn should complete"); assert_eq!(cx.active_idle_sleep_preventions(), 0); @@ -13071,14 +13155,14 @@ mod tests { init_test(cx); for status in [ None, - Some(acp::ToolCallStatus::Completed), - Some(acp::ToolCallStatus::Failed), + Some(acp_v1::ToolCallStatus::Completed), + Some(acp_v1::ToolCallStatus::Failed), ] { let thread = new_test_thread(cx).await; let (complete, request) = start_test_turn(&thread, cx); cx.run_until_parked(); assert_eq!(cx.active_idle_sleep_preventions(), 1); - let tool_call_id = acp::ToolCallId::new("permission"); + let tool_call_id = acp_v1::ToolCallId::new("permission"); let permission = request_test_permission(&thread, tool_call_id.clone(), cx); cx.run_until_parked(); assert_eq!(cx.active_idle_sleep_preventions(), 0); @@ -13087,9 +13171,9 @@ mod tests { if let Some(status) = status { thread .handle_session_update( - acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate::new( + acp_v1::SessionUpdate::ToolCallUpdate(acp_v1::ToolCallUpdate::new( tool_call_id, - acp::ToolCallUpdateFields::new().status(status), + acp_v1::ToolCallUpdateFields::new().status(status), )), cx, ) @@ -13107,7 +13191,7 @@ mod tests { assert_eq!(cx.active_idle_sleep_preventions(), 1, "status: {status:?}"); complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("turn should still be running"); request.await.expect("turn should complete"); assert_eq!(cx.active_idle_sleep_preventions(), 0); @@ -13122,7 +13206,7 @@ mod tests { let (complete, request) = start_test_turn(&thread, cx); cx.run_until_parked(); cx.executor().advance_clock(Duration::from_secs(1)); - let tool_call_id = acp::ToolCallId::new("permission"); + let tool_call_id = acp_v1::ToolCallId::new("permission"); let permission = request_test_permission(&thread, tool_call_id.clone(), cx); cx.run_until_parked(); cx.executor().advance_clock(Duration::from_secs(1)); @@ -13140,8 +13224,8 @@ mod tests { thread.authorize_tool_call( tool_call_id, SelectedPermissionOutcome::new( - acp::PermissionOptionId::new("allow"), - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionId::new("allow"), + acp_v1::PermissionOptionKind::AllowOnce, ), cx, ); @@ -13159,7 +13243,7 @@ mod tests { assert_eq!(cx.active_idle_sleep_preventions(), 1); complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("turn should still be running"); request.await.expect("turn should complete"); assert_eq!(cx.active_idle_sleep_preventions(), 0); @@ -13198,7 +13282,7 @@ mod tests { ); complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("turn should still be running"); request.await.expect("turn should complete"); assert_eq!(cx.active_idle_sleep_preventions(), 0); @@ -13213,9 +13297,9 @@ mod tests { assert_eq!(cx.active_idle_sleep_preventions(), 1); for action in [ - acp::ElicitationAction::Accept(acp::ElicitationAcceptAction::new()), - acp::ElicitationAction::Decline, - acp::ElicitationAction::Cancel, + acp_v1::ElicitationAction::Accept(acp_v1::ElicitationAcceptAction::new()), + acp_v1::ElicitationAction::Decline, + acp_v1::ElicitationAction::Cancel, ] { let (elicitation_id, response) = request_test_form_elicitation(&thread, cx); cx.run_until_parked(); @@ -13228,7 +13312,7 @@ mod tests { thread.update(cx, |thread, cx| { thread.respond_to_elicitation( &elicitation_id, - acp::CreateElicitationResponse::new(action.clone()), + acp_v1::CreateElicitationResponse::new(action.clone()), cx, ); }); @@ -13240,7 +13324,7 @@ mod tests { thread.update(cx, |thread, cx| { thread.respond_to_elicitation( &elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Cancel), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Cancel), cx, ); }); @@ -13249,7 +13333,7 @@ mod tests { } complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("turn should still be running"); request.await.expect("turn should complete"); assert_eq!(cx.active_idle_sleep_preventions(), 0); @@ -13264,13 +13348,13 @@ mod tests { assert_eq!(cx.active_idle_sleep_preventions(), 1); for (url_id, accept) in [("accepted", true), ("canceled", false)] { - let url_id = acp::ElicitationId::new(url_id); + let url_id = acp_v1::ElicitationId::new(url_id); let (entry_id, response) = thread.update(cx, |thread, cx| { thread .request_elicitation_with_id( - acp::CreateElicitationRequest::new( - acp::ElicitationUrlMode::new( - acp::ElicitationSessionScope::new(thread.session_id().clone()), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationUrlMode::new( + acp_v1::ElicitationSessionScope::new(thread.session_id().clone()), url_id.clone(), "https://example.com/complete", ), @@ -13289,15 +13373,15 @@ mod tests { assert_eq!(cx.active_idle_sleep_preventions(), 0); let expected_action = if accept { - acp::ElicitationAction::Accept(acp::ElicitationAcceptAction::new()) + acp_v1::ElicitationAction::Accept(acp_v1::ElicitationAcceptAction::new()) } else { - acp::ElicitationAction::Cancel + acp_v1::ElicitationAction::Cancel }; thread.update(cx, |thread, cx| { if accept { thread.respond_to_elicitation( &entry_id, - acp::CreateElicitationResponse::new(expected_action.clone()), + acp_v1::CreateElicitationResponse::new(expected_action.clone()), cx, ); } else { @@ -13317,7 +13401,7 @@ mod tests { } complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("turn should still be running"); request.await.expect("turn should complete"); assert_eq!(cx.active_idle_sleep_preventions(), 0); @@ -13332,7 +13416,7 @@ mod tests { let (complete, request) = start_test_turn(&thread, cx); cx.run_until_parked(); assert_eq!(cx.active_idle_sleep_preventions(), 1); - let tool_call_id = acp::ToolCallId::new("permission"); + let tool_call_id = acp_v1::ToolCallId::new("permission"); let permission = request_test_permission(&thread, tool_call_id.clone(), cx); let (elicitation_id, elicitation_response) = request_test_form_elicitation(&thread, cx); cx.run_until_parked(); @@ -13345,21 +13429,21 @@ mod tests { )); assert_eq!( elicitation_response.await.action, - acp::ElicitationAction::Cancel + acp_v1::ElicitationAction::Cancel ); thread.update(cx, |thread, cx| { thread.authorize_tool_call( tool_call_id, SelectedPermissionOutcome::new( - acp::PermissionOptionId::new("allow"), - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionId::new("allow"), + acp_v1::PermissionOptionKind::AllowOnce, ), cx, ); thread.respond_to_elicitation( &elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new(), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new(), )), cx, ); @@ -13372,7 +13456,9 @@ mod tests { assert_eq!(cx.active_idle_sleep_preventions(), 0); complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::Cancelled))) + .send(Ok(acp_v1::PromptResponse::new( + acp_v1::StopReason::Cancelled, + ))) .expect("backend should still be running"); cancel.await; request.await.expect("turn should complete"); @@ -13381,7 +13467,7 @@ mod tests { #[gpui::test] async fn test_stale_refusal_does_not_affect_follow_up_turn(cx: &mut TestAppContext) { - assert_stale_completion_does_not_affect_follow_up_turn(Ok(acp::StopReason::Refusal), cx) + assert_stale_completion_does_not_affect_follow_up_turn(Ok(acp_v1::StopReason::Refusal), cx) .await; } @@ -13396,9 +13482,9 @@ mod tests { ) { init_test(cx); let thread = new_test_thread(cx).await; - let text = acp::ContentBlock::Text( - acp::TextContent::new("before") - .meta(acp::Meta::from_iter([("sequence".into(), json!(1))])), + let text = acp_v1::ContentBlock::Text( + acp_v1::TextContent::new("before") + .meta(acp_v1::Meta::from_iter([("sequence".into(), json!(1))])), ); let image = message_test_image(); @@ -13442,7 +13528,7 @@ mod tests { }); complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("turn should still be running"); request.await.expect("turn should complete"); thread.read_with(cx, |thread, cx| { @@ -13543,7 +13629,9 @@ mod tests { ); }); complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::Cancelled))) + .send(Ok(acp_v1::PromptResponse::new( + acp_v1::StopReason::Cancelled, + ))) .expect("backend should still be running"); cancel.await; request.await.expect("turn should complete"); @@ -13591,10 +13679,10 @@ mod tests { thread: &Entity, cx: &mut TestAppContext, ) -> ( - oneshot::Sender>, - BoxFuture<'static, Result>>, + oneshot::Sender>, + BoxFuture<'static, Result>>, ) { - let (complete, completion) = oneshot::channel::>(); + let (complete, completion) = oneshot::channel::>(); let request = thread.update(cx, |thread, cx| { thread.run_turn(cx, async move |_, _| completion.await?) }); @@ -13603,23 +13691,23 @@ mod tests { fn request_test_permission( thread: &Entity, - tool_call_id: acp::ToolCallId, + tool_call_id: acp_v1::ToolCallId, cx: &mut TestAppContext, ) -> Task { thread.update(cx, |thread, cx| { thread .request_tool_call_authorization( - acp::ToolCall::new(tool_call_id, "Needs permission").into(), + acp_v1::ToolCall::new(tool_call_id, "Needs permission").into(), PermissionOptions::Flat(vec![ - acp::PermissionOption::new( - acp::PermissionOptionId::new("allow"), + acp_v1::PermissionOption::new( + acp_v1::PermissionOptionId::new("allow"), "Allow", - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionKind::AllowOnce, ), - acp::PermissionOption::new( - acp::PermissionOptionId::new("reject"), + acp_v1::PermissionOption::new( + acp_v1::PermissionOptionId::new("reject"), "Reject", - acp::PermissionOptionKind::RejectOnce, + acp_v1::PermissionOptionKind::RejectOnce, ), ]), AuthorizationKind::PermissionGrant, @@ -13632,14 +13720,14 @@ mod tests { fn request_test_form_elicitation( thread: &Entity, cx: &mut TestAppContext, - ) -> (ElicitationEntryId, Task) { + ) -> (ElicitationEntryId, Task) { thread.update(cx, |thread, cx| { thread .request_elicitation_with_id( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationSessionScope::new(thread.session_id().clone()), - acp::ElicitationSchema::new().string("name", false), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationSessionScope::new(thread.session_id().clone()), + acp_v1::ElicitationSchema::new().string("name", false), ), "Provide a name", ), @@ -13660,7 +13748,7 @@ mod tests { } async fn assert_stale_completion_does_not_affect_follow_up_turn( - backend_result: Result, + backend_result: Result, cx: &mut TestAppContext, ) { init_test(cx); @@ -13683,7 +13771,7 @@ mod tests { first_complete .send( backend_result - .map(acp::PromptResponse::new) + .map(acp_v1::PromptResponse::new) .map_err(|message| anyhow!(message)), ) .expect("first backend should still be running"); @@ -13757,7 +13845,7 @@ mod tests { assert_eq!(cx.active_idle_sleep_preventions(), 1); second_complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("second backend should still be running"); second_request.await.expect("second turn should complete"); assert_eq!(cx.active_idle_sleep_preventions(), 0); @@ -13773,20 +13861,20 @@ mod tests { let (complete, request) = start_test_turn(&thread, cx); cx.run_until_parked(); assert_eq!(cx.active_idle_sleep_preventions(), 1); - let tool_call_id = acp::ToolCallId::new("permission"); + let tool_call_id = acp_v1::ToolCallId::new("permission"); let permission = request_test_permission(&thread, tool_call_id.clone(), cx); cx.run_until_parked(); assert!(thread.read_with(cx, |thread, _| thread.is_waiting_for_confirmation())); assert_eq!(cx.active_idle_sleep_preventions(), 0); thread.update(cx, |thread, cx| { - let update = acp::ToolCallUpdate::new( + let update = acp_v1::ToolCallUpdate::new( tool_call_id.clone(), - acp::ToolCallUpdateFields::new() - .status(acp::ToolCallStatus::Completed) - .content(vec![acp::ToolCallContent::Terminal(acp::Terminal::new( - acp::TerminalId::new("unknown-terminal"), - ))]), + acp_v1::ToolCallUpdateFields::new() + .status(acp_v1::ToolCallStatus::Completed) + .content(vec![acp_v1::ToolCallContent::Terminal( + acp_v1::Terminal::new(acp_v1::TerminalId::new("unknown-terminal")), + )]), ); if upsert { assert!( @@ -13811,7 +13899,7 @@ mod tests { .1 .status .as_acp_status(), - Some(acp::ToolCallStatus::Completed) + Some(acp_v1::ToolCallStatus::Completed) ); assert!(!thread.is_waiting_for_confirmation()); }); @@ -13832,7 +13920,7 @@ mod tests { }); complete - .send(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) .expect("backend should still be running"); request.await.expect("turn should complete"); assert_eq!(cx.active_idle_sleep_preventions(), 0); diff --git a/crates/acp_thread/src/connection.rs b/crates/acp_thread/src/connection.rs index 5f0cf69890d..e145f0e51df 100644 --- a/crates/acp_thread/src/connection.rs +++ b/crates/acp_thread/src/connection.rs @@ -1,5 +1,5 @@ use crate::{AcpThread, ElicitationStore}; -use agent_client_protocol::schema::v1 as acp; +use agent_client_protocol::schema::v1 as acp_v1; use anyhow::Result; use chrono::{DateTime, Utc}; use collections::{HashMap, HashSet, IndexMap}; @@ -112,7 +112,7 @@ pub trait AgentConnection { /// Load an existing session by ID. fn load_session( self: Rc, - _session_id: acp::SessionId, + _session_id: acp_v1::SessionId, _project: Entity, _work_dirs: PathList, _title: Option, @@ -129,7 +129,7 @@ pub trait AgentConnection { /// Close an existing session. Allows the agent to free the session from memory. fn close_session( self: Rc, - _session_id: &acp::SessionId, + _session_id: &acp_v1::SessionId, _cx: &mut App, ) -> Task> { Task::ready(Err(anyhow::Error::msg("Closing sessions is not supported"))) @@ -143,7 +143,7 @@ pub trait AgentConnection { /// Resume an existing session by ID without replaying previous messages. fn resume_session( self: Rc, - _session_id: acp::SessionId, + _session_id: acp_v1::SessionId, _project: Entity, _work_dirs: PathList, _title: Option, @@ -164,17 +164,17 @@ pub trait AgentConnection { false } - fn auth_methods(&self) -> &[acp::AuthMethod]; + fn auth_methods(&self) -> &[acp_v1::AuthMethod]; fn terminal_auth_task( &self, - _method: &acp::AuthMethodId, + _method: &acp_v1::AuthMethodId, _cx: &App, ) -> Option>> { None } - fn authenticate(&self, method: acp::AuthMethodId, cx: &mut App) -> Task>; + fn authenticate(&self, method: acp_v1::AuthMethodId, cx: &mut App) -> Task>; fn supports_logout(&self) -> bool { false @@ -192,14 +192,21 @@ pub trait AgentConnection { None } - fn prompt(&self, params: acp::PromptRequest, cx: &mut App) - -> Task>; + fn prompt( + &self, + params: acp_v1::PromptRequest, + cx: &mut App, + ) -> Task>; - fn retry(&self, _session_id: &acp::SessionId, _cx: &App) -> Option> { + fn retry( + &self, + _session_id: &acp_v1::SessionId, + _cx: &App, + ) -> Option> { None } - fn cancel(&self, session_id: &acp::SessionId, cx: &mut App); + fn cancel(&self, session_id: &acp_v1::SessionId, cx: &mut App); /// Request-scoped elicitations are connection-level because they can arrive before a session /// thread exists. Session-scoped elicitations stay in the thread timeline, but use @@ -210,7 +217,7 @@ pub trait AgentConnection { fn truncate( &self, - _session_id: &acp::SessionId, + _session_id: &acp_v1::SessionId, _cx: &App, ) -> Option> { None @@ -218,7 +225,7 @@ pub trait AgentConnection { fn set_title( &self, - _session_id: &acp::SessionId, + _session_id: &acp_v1::SessionId, _cx: &App, ) -> Option> { None @@ -228,7 +235,10 @@ pub trait AgentConnection { /// /// If the agent does not support model selection, returns [None]. /// This allows sharing the selector in UI components. - fn model_selector(&self, _session_id: &acp::SessionId) -> Option> { + fn model_selector( + &self, + _session_id: &acp_v1::SessionId, + ) -> Option> { None } @@ -238,7 +248,7 @@ pub trait AgentConnection { fn session_modes( &self, - _session_id: &acp::SessionId, + _session_id: &acp_v1::SessionId, _cx: &App, ) -> Option> { None @@ -246,7 +256,7 @@ pub trait AgentConnection { fn session_config_options( &self, - _session_id: &acp::SessionId, + _session_id: &acp_v1::SessionId, _cx: &App, ) -> Option> { None @@ -277,13 +287,13 @@ pub trait AgentSessionClientUserMessageIds { fn prompt( &self, client_user_message_id: ClientUserMessageId, - params: acp::PromptRequest, + params: acp_v1::PromptRequest, cx: &mut App, - ) -> Task>; + ) -> Task>; } pub trait AgentSessionRetry { - fn run(&self, cx: &mut App) -> Task>; + fn run(&self, cx: &mut App) -> Task>; } pub trait AgentSessionSetTitle { @@ -295,31 +305,31 @@ pub trait AgentTelemetry { /// storage with telemetry events. fn thread_data( &self, - session_id: &acp::SessionId, + session_id: &acp_v1::SessionId, cx: &mut App, ) -> Task>; } pub trait AgentSessionModes { - fn current_mode(&self) -> acp::SessionModeId; + fn current_mode(&self) -> acp_v1::SessionModeId; - fn all_modes(&self) -> Vec; + fn all_modes(&self) -> Vec; - fn set_mode(&self, mode: acp::SessionModeId, cx: &mut App) -> Task>; + fn set_mode(&self, mode: acp_v1::SessionModeId, cx: &mut App) -> Task>; } pub trait AgentSessionConfigOptions { /// Get all current config options with their state - fn config_options(&self) -> Vec; + fn config_options(&self) -> Vec; /// Set a config option value /// Returns the full updated list of config options fn set_config_option( &self, - config_id: acp::SessionConfigId, - value: acp::SessionConfigOptionValue, + config_id: acp_v1::SessionConfigId, + value: acp_v1::SessionConfigOptionValue, cx: &mut App, - ) -> Task>>; + ) -> Task>>; /// Whenever the config options are updated the receiver will be notified. /// Optional for agents that don't update their config options dynamically. @@ -332,14 +342,14 @@ pub trait AgentSessionConfigOptions { pub struct AgentSessionListRequest { pub cwd: Option, pub cursor: Option, - pub meta: Option, + pub meta: Option, } #[derive(Debug, Clone)] pub struct AgentSessionListResponse { pub sessions: Vec, pub next_cursor: Option, - pub meta: Option, + pub meta: Option, } impl AgentSessionListResponse { @@ -354,16 +364,16 @@ impl AgentSessionListResponse { #[derive(Debug, Clone, PartialEq)] pub struct AgentSessionInfo { - pub session_id: acp::SessionId, + pub session_id: acp_v1::SessionId, pub work_dirs: Option, pub title: Option, pub updated_at: Option>, pub created_at: Option>, - pub meta: Option, + pub meta: Option, } impl AgentSessionInfo { - pub fn new(session_id: impl Into) -> Self { + pub fn new(session_id: impl Into) -> Self { Self { session_id: session_id.into(), work_dirs: None, @@ -379,8 +389,8 @@ impl AgentSessionInfo { pub enum SessionListUpdate { Refresh, SessionInfo { - session_id: acp::SessionId, - update: acp::SessionInfoUpdate, + session_id: acp_v1::SessionId, + update: acp_v1::SessionInfoUpdate, }, } @@ -395,7 +405,7 @@ pub trait AgentSessionList { false } - fn delete_session(&self, _session_id: &acp::SessionId, _cx: &mut App) -> Task> { + fn delete_session(&self, _session_id: &acp_v1::SessionId, _cx: &mut App) -> Task> { Task::ready(Err(anyhow::anyhow!("delete_session not supported"))) } @@ -536,8 +546,8 @@ impl AgentModelList { #[derive(Debug, Clone)] pub struct PermissionOptionChoice { - pub allow: acp::PermissionOption, - pub deny: acp::PermissionOption, + pub allow: acp_v1::PermissionOption, + pub deny: acp_v1::PermissionOption, pub sub_patterns: Vec, } @@ -578,7 +588,7 @@ pub struct PermissionPattern { #[derive(Debug, Clone)] pub enum PermissionOptions { - Flat(Vec), + Flat(Vec), Dropdown(Vec), DropdownWithPatterns { choices: Vec, @@ -598,8 +608,8 @@ impl PermissionOptions { pub fn first_option_of_kind( &self, - kind: acp::PermissionOptionKind, - ) -> Option<&acp::PermissionOption> { + kind: acp_v1::PermissionOptionKind, + ) -> Option<&acp_v1::PermissionOption> { match self { PermissionOptions::Flat(options) => options.iter().find(|option| option.kind == kind), PermissionOptions::Dropdown(options) => options.iter().find_map(|choice| { @@ -625,13 +635,13 @@ impl PermissionOptions { } } - pub fn allow_once_option_id(&self) -> Option { - self.first_option_of_kind(acp::PermissionOptionKind::AllowOnce) + pub fn allow_once_option_id(&self) -> Option { + self.first_option_of_kind(acp_v1::PermissionOptionKind::AllowOnce) .map(|option| option.option_id.clone()) } - pub fn deny_once_option_id(&self) -> Option { - self.first_option_of_kind(acp::PermissionOptionKind::RejectOnce) + pub fn deny_once_option_id(&self) -> Option { + self.first_option_of_kind(acp_v1::PermissionOptionKind::RejectOnce) .map(|option| option.option_id.clone()) } @@ -754,9 +764,9 @@ mod test_support { #[derive(Clone)] pub struct StubAgentConnection { - sessions: Arc>>, - permission_requests: HashMap, - next_prompt_updates: Arc>>, + sessions: Arc>>, + permission_requests: HashMap, + next_prompt_updates: Arc>>, supports_load_session: bool, supports_session_additional_directories: bool, agent_id: AgentId, @@ -765,7 +775,7 @@ mod test_support { struct Session { thread: WeakEntity, - response_tx: Option>, + response_tx: Option>, } impl Default for StubAgentConnection { @@ -787,13 +797,13 @@ mod test_support { } } - pub fn set_next_prompt_updates(&self, updates: Vec) { + pub fn set_next_prompt_updates(&self, updates: Vec) { *self.next_prompt_updates.lock() = updates; } pub fn with_permission_requests( mut self, - permission_requests: HashMap, + permission_requests: HashMap, ) -> Self { self.permission_requests = permission_requests; self @@ -824,7 +834,7 @@ mod test_support { fn create_session( self: Rc, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, project: Entity, work_dirs: PathList, title: Option, @@ -841,7 +851,7 @@ mod test_support { action_log, session_id.clone(), watch::Receiver::constant( - acp::PromptCapabilities::new() + acp_v1::PromptCapabilities::new() .image(true) .audio(true) .embedded_context(true), @@ -861,8 +871,8 @@ mod test_support { pub fn send_update( &self, - session_id: acp::SessionId, - update: acp::SessionUpdate, + session_id: acp_v1::SessionId, + update: acp_v1::SessionUpdate, cx: &mut App, ) { assert!( @@ -881,7 +891,7 @@ mod test_support { .unwrap(); } - pub fn end_turn(&self, session_id: acp::SessionId, stop_reason: acp::StopReason) { + pub fn end_turn(&self, session_id: acp_v1::SessionId, stop_reason: acp_v1::StopReason) { self.sessions .lock() .get_mut(&session_id) @@ -903,13 +913,13 @@ mod test_support { self.telemetry_id.clone() } - fn auth_methods(&self) -> &[acp::AuthMethod] { + fn auth_methods(&self) -> &[acp_v1::AuthMethod] { &[] } fn model_selector( &self, - _session_id: &acp::SessionId, + _session_id: &acp_v1::SessionId, ) -> Option> { Some(self.model_selector_impl()) } @@ -920,7 +930,7 @@ mod test_support { work_dirs: PathList, cx: &mut gpui::App, ) -> Task>> { - let session_id = acp::SessionId::new(StubSessionCounter::next(cx).to_string()); + let session_id = acp_v1::SessionId::new(StubSessionCounter::next(cx).to_string()); let thread = self.create_session(session_id, project, work_dirs, None, cx); Task::ready(Ok(thread)) } @@ -935,7 +945,7 @@ mod test_support { fn load_session( self: Rc, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, project: Entity, work_dirs: PathList, title: Option, @@ -951,7 +961,7 @@ mod test_support { fn authenticate( &self, - _method_id: acp::AuthMethodId, + _method_id: acp_v1::AuthMethodId, _cx: &mut App, ) -> Task> { unimplemented!() @@ -959,9 +969,9 @@ mod test_support { fn prompt( &self, - params: acp::PromptRequest, + params: acp_v1::PromptRequest, cx: &mut App, - ) -> Task> { + ) -> Task> { let mut sessions = self.sessions.lock(); let Session { thread, @@ -973,13 +983,13 @@ mod test_support { response_tx.replace(tx); cx.spawn(async move |_| { let stop_reason = rx.await?; - Ok(acp::PromptResponse::new(stop_reason)) + Ok(acp_v1::PromptResponse::new(stop_reason)) }) } else { for update in self.next_prompt_updates.lock().drain(..) { let thread = thread.clone(); let update = update.clone(); - let permission_request = if let acp::SessionUpdate::ToolCall(tool_call) = + let permission_request = if let acp_v1::SessionUpdate::ToolCall(tool_call) = &update && let Some(options) = self.permission_requests.get(&tool_call.tool_call_id) { @@ -1010,7 +1020,7 @@ mod test_support { cx.spawn(async move |_| { try_join_all(tasks).await?; - Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) }) } } @@ -1024,7 +1034,7 @@ mod test_support { })) } - fn cancel(&self, session_id: &acp::SessionId, _cx: &mut App) { + fn cancel(&self, session_id: &acp_v1::SessionId, _cx: &mut App) { if let Some(end_turn_tx) = self .sessions .lock() @@ -1033,13 +1043,13 @@ mod test_support { .response_tx .take() { - end_turn_tx.send(acp::StopReason::Cancelled).unwrap(); + end_turn_tx.send(acp_v1::StopReason::Cancelled).unwrap(); } } fn set_title( &self, - _session_id: &acp::SessionId, + _session_id: &acp_v1::SessionId, _cx: &App, ) -> Option> { Some(Rc::new(StubAgentSessionSetTitle)) @@ -1047,7 +1057,7 @@ mod test_support { fn truncate( &self, - _session_id: &acp::SessionId, + _session_id: &acp_v1::SessionId, _cx: &App, ) -> Option> { Some(Rc::new(StubAgentSessionEditor)) @@ -1074,9 +1084,9 @@ mod test_support { fn prompt( &self, _client_user_message_id: ClientUserMessageId, - params: acp::PromptRequest, + params: acp_v1::PromptRequest, cx: &mut App, - ) -> Task> { + ) -> Task> { self.connection.prompt(params, cx) } } diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rs index d64f350a7ba..0f22991990e 100644 --- a/crates/agent/src/agent.rs +++ b/crates/agent/src/agent.rs @@ -33,7 +33,7 @@ use acp_thread::{ AcpThread, AgentModelId, AgentModelSelector, AgentSessionInfo, AgentSessionList, AgentSessionListRequest, AgentSessionListResponse, ClientUserMessageId, TokenUsageRatio, }; -use agent_client_protocol::schema::v1 as acp; +use agent_client_protocol::schema::v1 as acp_v1; use agent_skills::{ AGENTS_DIR_NAME, MAX_SKILL_DESCRIPTIONS_SIZE, MAX_SKILL_FILE_SIZE, ProjectSkillGroup, SKILL_FILE_NAME, Skill, SkillIndex, SkillLoadError, SkillLoadWarning, SkillScopeId, @@ -240,7 +240,7 @@ struct Session { } impl Session { - fn draft_prompt(&self, cx: &App) -> Option> { + fn draft_prompt(&self, cx: &App) -> Option> { match self.acp_thread.upgrade() { Some(acp_thread) => acp_thread.read(cx).draft_prompt().map(Vec::from), None => self.thread.read(cx).draft_prompt().map(Vec::from), @@ -439,8 +439,8 @@ pub trait SiblingThreadHost { pub struct NativeAgent { /// Session ID -> Session mapping - sessions: HashMap, - pending_sessions: HashMap, + sessions: HashMap, + pending_sessions: HashMap, thread_store: Entity, /// Project-specific state keyed by project EntityId projects: HashMap, @@ -991,7 +991,7 @@ impl NativeAgent { ); } - fn session_project_state(&self, session_id: &acp::SessionId) -> Option<&ProjectState> { + fn session_project_state(&self, session_id: &acp_v1::SessionId) -> Option<&ProjectState> { self.sessions .get(session_id) .and_then(|session| self.projects.get(&session.project_id)) @@ -1559,8 +1559,8 @@ impl NativeAgent { .update(cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::AvailableCommandsUpdate( - acp::AvailableCommandsUpdate::new(available_commands.clone()), + acp_v1::SessionUpdate::AvailableCommandsUpdate( + acp_v1::AvailableCommandsUpdate::new(available_commands.clone()), ), cx, ) @@ -1573,11 +1573,11 @@ impl NativeAgent { fn build_available_commands_for_project( project_state: Option<&ProjectState>, cx: &App, - ) -> Vec { + ) -> Vec { let Some(state) = project_state else { return Vec::new(); }; - let compact_command = acp::AvailableCommand::new( + let compact_command = acp_v1::AvailableCommand::new( COMPACT_COMMAND_NAME, "Summarize the conversation so far to free up context", ) @@ -1607,7 +1607,7 @@ impl NativeAgent { }; let mut command = - acp::AvailableCommand::new(name, prompt.description.clone().unwrap_or_default()) + acp_v1::AvailableCommand::new(name, prompt.description.clone().unwrap_or_default()) .meta(acp_thread::meta_with_command_category( acp_thread::CommandCategory::Mcp, )); @@ -1616,8 +1616,8 @@ impl NativeAgent { Some([arg]) => { let hint = format!("<{}>", arg.name); - command = command.input(acp::AvailableCommandInput::Unstructured( - acp::UnstructuredCommandInput::new(hint), + command = command.input(acp_v1::AvailableCommandInput::Unstructured( + acp_v1::UnstructuredCommandInput::new(hint), )); } Some([]) | None => {} @@ -1637,7 +1637,7 @@ impl NativeAgent { pub fn load_thread( &mut self, - id: acp::SessionId, + id: acp_v1::SessionId, project: Entity, cx: &mut Context, ) -> Task>> { @@ -1678,7 +1678,7 @@ impl NativeAgent { pub fn open_thread( &mut self, - id: acp::SessionId, + id: acp_v1::SessionId, project: Entity, cx: &mut Context, ) -> Task>> { @@ -1748,7 +1748,7 @@ impl NativeAgent { pub fn thread_summary( &mut self, - id: acp::SessionId, + id: acp_v1::SessionId, project: Entity, cx: &mut Context, ) -> Task> { @@ -1773,9 +1773,9 @@ impl NativeAgent { fn release_session( &mut self, - session_id: &acp::SessionId, + session_id: &acp_v1::SessionId, acp_thread_id: EntityId, - draft_prompt: Option>, + draft_prompt: Option>, cx: &mut Context, ) { let Some(session) = self.sessions.get(session_id) else { @@ -1810,8 +1810,8 @@ impl NativeAgent { fn enqueue_save( &mut self, - id: &acp::SessionId, - draft_prompt: Option>, + id: &acp_v1::SessionId, + draft_prompt: Option>, cx: &mut Context, ) { let Some(session) = self.sessions.get(id) else { @@ -1834,7 +1834,7 @@ impl NativeAgent { } async fn run_save_worker( - id: acp::SessionId, + id: acp_v1::SessionId, mut wake: watch::Receiver<()>, pending_save: Arc>>, database_future: Shared, Arc>>>, @@ -1874,9 +1874,9 @@ impl NativeAgent { fn thread_save_payload( &self, session: &Session, - draft_prompt: Option>, + draft_prompt: Option>, cx: &mut App, - ) -> Option<(acp::SessionId, PathList, Task)> { + ) -> Option<(acp_v1::SessionId, PathList, Task)> { if session.thread.read(cx).is_empty() { return None; } @@ -1934,13 +1934,13 @@ impl NativeAgent { fn send_mcp_prompt( &self, client_user_message_id: ClientUserMessageId, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, prompt_name: String, server_id: ContextServerId, arguments: HashMap, - original_content: Vec, + original_content: Vec, cx: &mut Context, - ) -> Task> { + ) -> Task> { let Some(state) = self.session_project_state(&session_id) else { return Task::ready(Err(anyhow!("Project state not found for session"))); }; @@ -2045,9 +2045,9 @@ impl NativeAgent { fn send_compact_command( &self, client_user_message_id: ClientUserMessageId, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, cx: &mut Context, - ) -> Task> { + ) -> Task> { cx.spawn(async move |this, cx| { let (acp_thread, thread) = this.update(cx, |this, _cx| { let session = this @@ -2091,11 +2091,11 @@ impl NativeAgent { fn send_skill_invocation( &self, client_user_message_id: ClientUserMessageId, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, skill: Skill, - original_content: Vec, + original_content: Vec, cx: &mut Context, - ) -> Task> { + ) -> Task> { let Some(state) = self.session_project_state(&session_id) else { return Task::ready(Err(anyhow!("Project state not found for session"))); }; @@ -2137,10 +2137,10 @@ impl NativeAgent { })? }; let envelope = crate::tools::render_skill_envelope(&skill, &body); - let envelope_block = acp::ContentBlock::Text(acp::TextContent::new(envelope)); + let envelope_block = acp_v1::ContentBlock::Text(acp_v1::TextContent::new(envelope)); let mut user_blocks = original_content; - if let Some(acp::ContentBlock::Text(text_content)) = user_blocks.first_mut() { + if let Some(acp_v1::ContentBlock::Text(text_content)) = user_blocks.first_mut() { let stripped = strip_slash_command_prefix(&text_content.text); if stripped.trim().is_empty() { user_blocks.remove(0); @@ -2194,7 +2194,7 @@ impl NativeAgent { pub struct NativeAgentConnection(pub Entity); impl NativeAgentConnection { - pub fn thread(&self, session_id: &acp::SessionId, cx: &App) -> Option> { + pub fn thread(&self, session_id: &acp_v1::SessionId, cx: &App) -> Option> { self.0 .read(cx) .sessions @@ -2224,7 +2224,7 @@ impl NativeAgentConnection { pub fn available_skills( &self, - session_id: &acp::SessionId, + session_id: &acp_v1::SessionId, cx: &App, ) -> Vec { self.0 @@ -2242,7 +2242,7 @@ impl NativeAgentConnection { pub fn load_thread( &self, - id: acp::SessionId, + id: acp_v1::SessionId, project: Entity, cx: &mut App, ) -> Task>> { @@ -2252,11 +2252,11 @@ impl NativeAgentConnection { fn run_turn( &self, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, cx: &mut App, f: impl 'static + FnOnce(Entity, &mut App) -> Result>>, - ) -> Task> { + ) -> Task> { let Some((thread, acp_thread)) = self.0.update(cx, |agent, _cx| { let session = agent.sessions.get(&session_id)?; Some((session.thread.clone(), session.acp_thread.clone())) @@ -2278,7 +2278,7 @@ impl NativeAgentConnection { acp_thread: WeakEntity, connection: Option, cx: &App, - ) -> Task> { + ) -> Task> { cx.spawn(async move |cx| { // Handle response stream and forward to session.acp_thread while let Some(result) = events.next().await { @@ -2325,10 +2325,10 @@ impl NativeAgentConnection { acp_thread::RequestPermissionOutcome::Selected(outcome) => outcome, acp_thread::RequestPermissionOutcome::InterruptedByFollowUp => { acp_thread::SelectedPermissionOutcome::new( - acp::PermissionOptionId::new( + acp_v1::PermissionOptionId::new( FOLLOW_UP_PERMISSION_DENIED_OPTION_ID, ), - acp::PermissionOptionKind::RejectOnce, + acp_v1::PermissionOptionKind::RejectOnce, ) } acp_thread::RequestPermissionOutcome::Cancelled => return, @@ -2355,12 +2355,12 @@ impl NativeAgentConnection { response, }) => { let request_result = acp_thread.update(cx, |thread, cx| { - let scope = acp::ElicitationSessionScope::new( + let scope = acp_v1::ElicitationSessionScope::new( thread.session_id().clone(), ) .tool_call_id(tool_call_id); - let request = acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new(scope, schema), + let request = acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new(scope, schema), message, ); thread.request_elicitation(request, cx) @@ -2384,8 +2384,8 @@ impl NativeAgentConnection { // doesn't hang waiting on a form that will // never render. response - .send(acp::CreateElicitationResponse::new( - acp::ElicitationAction::Cancel, + .send(acp_v1::CreateElicitationResponse::new( + acp_v1::ElicitationAction::Cancel, )) .ok(); } @@ -2434,7 +2434,7 @@ impl NativeAgentConnection { } ThreadEvent::Stop(stop_reason) => { log::debug!("Assistant message complete: {:?}", stop_reason); - return Ok(acp::PromptResponse::new(stop_reason)); + return Ok(acp_v1::PromptResponse::new(stop_reason)); } } } @@ -2446,7 +2446,7 @@ impl NativeAgentConnection { } log::debug!("Response stream completed"); - anyhow::Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) + anyhow::Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)) }) } } @@ -2474,8 +2474,8 @@ impl<'a> Command<'a> { && self.skill_scope.is_none() } - fn parse(prompt: &'a [acp::ContentBlock]) -> Option { - let acp::ContentBlock::Text(text_content) = prompt.first()? else { + fn parse(prompt: &'a [acp_v1::ContentBlock]) -> Option { + let acp_v1::ContentBlock::Text(text_content) = prompt.first()? else { return None; }; let text = text_content.text.trim(); @@ -2545,7 +2545,7 @@ fn strip_slash_command_prefix(text: &str) -> String { } struct NativeAgentModelSelector { - session_id: acp::SessionId, + session_id: acp_v1::SessionId, connection: NativeAgentConnection, } @@ -2794,7 +2794,7 @@ impl acp_thread::AgentConnection for NativeAgentConnection { fn load_session( self: Rc, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, project: Entity, _work_dirs: PathList, _title: Option, @@ -2804,15 +2804,15 @@ impl acp_thread::AgentConnection for NativeAgentConnection { .update(cx, |agent, cx| agent.open_thread(session_id, project, cx)) } - fn auth_methods(&self) -> &[acp::AuthMethod] { + fn auth_methods(&self) -> &[acp_v1::AuthMethod] { &[] // No auth for in-process } - fn authenticate(&self, _method: acp::AuthMethodId, _cx: &mut App) -> Task> { + fn authenticate(&self, _method: acp_v1::AuthMethodId, _cx: &mut App) -> Task> { Task::ready(Ok(())) } - fn model_selector(&self, session_id: &acp::SessionId) -> Option> { + fn model_selector(&self, session_id: &acp_v1::SessionId) -> Option> { Some(Rc::new(NativeAgentModelSelector { session_id: session_id.clone(), connection: self.clone(), @@ -2829,9 +2829,9 @@ impl acp_thread::AgentConnection for NativeAgentConnection { fn prompt( &self, - params: acp::PromptRequest, + params: acp_v1::PromptRequest, cx: &mut App, - ) -> Task> { + ) -> Task> { acp_thread::AgentSessionClientUserMessageIds::prompt( self, acp_thread::AgentSessionClientUserMessageIds::new_id(self), @@ -2842,7 +2842,7 @@ impl acp_thread::AgentConnection for NativeAgentConnection { fn retry( &self, - session_id: &acp::SessionId, + session_id: &acp_v1::SessionId, _cx: &App, ) -> Option> { Some(Rc::new(NativeAgentSessionRetry { @@ -2851,7 +2851,7 @@ impl acp_thread::AgentConnection for NativeAgentConnection { }) as _) } - fn cancel(&self, session_id: &acp::SessionId, cx: &mut App) { + fn cancel(&self, session_id: &acp_v1::SessionId, cx: &mut App) { log::info!("Cancelling on session: {}", session_id); self.0.update(cx, |agent, cx| { if let Some(session) = agent.sessions.get(session_id) { @@ -2865,7 +2865,7 @@ impl acp_thread::AgentConnection for NativeAgentConnection { fn truncate( &self, - session_id: &acp::SessionId, + session_id: &acp_v1::SessionId, cx: &App, ) -> Option> { self.0.read_with(cx, |agent, _cx| { @@ -2880,7 +2880,7 @@ impl acp_thread::AgentConnection for NativeAgentConnection { fn set_title( &self, - session_id: &acp::SessionId, + session_id: &acp_v1::SessionId, cx: &App, ) -> Option> { self.0.read_with(cx, |agent, _cx| { @@ -2914,9 +2914,9 @@ impl acp_thread::AgentSessionClientUserMessageIds for NativeAgentConnection { fn prompt( &self, client_user_message_id: acp_thread::ClientUserMessageId, - params: acp::PromptRequest, + params: acp_v1::PromptRequest, cx: &mut App, - ) -> Task> { + ) -> Task> { let session_id = params.session_id.clone(); log::info!("Received prompt request for session: {}", session_id); log::debug!("Prompt blocks count: {}", params.prompt.len()); @@ -3074,7 +3074,7 @@ impl acp_thread::AgentSessionClientUserMessageIds for NativeAgentConnection { impl acp_thread::AgentTelemetry for NativeAgentConnection { fn thread_data( &self, - session_id: &acp::SessionId, + session_id: &acp_v1::SessionId, cx: &mut App, ) -> Task> { let Some(session) = self.0.read(cx).sessions.get(session_id) else { @@ -3136,7 +3136,7 @@ impl AgentSessionList for NativeAgentSessionList { true } - fn delete_session(&self, session_id: &acp::SessionId, cx: &mut App) -> Task> { + fn delete_session(&self, session_id: &acp_v1::SessionId, cx: &mut App) -> Task> { self.thread_store .update(cx, |store, cx| store.delete_thread(session_id.clone(), cx)) } @@ -3194,11 +3194,11 @@ impl acp_thread::AgentSessionTruncate for NativeAgentSessionTruncate { struct NativeAgentSessionRetry { connection: NativeAgentConnection, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, } impl acp_thread::AgentSessionRetry for NativeAgentSessionRetry { - fn run(&self, cx: &mut App) -> Task> { + fn run(&self, cx: &mut App) -> Task> { self.connection .run_turn(self.session_id.clone(), cx, |thread, cx| { thread.update(cx, |thread, cx| thread.resume(cx)) @@ -3298,7 +3298,7 @@ impl NativeThreadEnvironment { pub(crate) fn resume_subagent_thread( &self, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, cx: &mut App, ) -> Result> { let (subagent_thread, acp_thread) = self.agent.update(cx, |agent, _cx| { @@ -3330,7 +3330,7 @@ impl NativeThreadEnvironment { fn prompt_subagent( &self, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, subagent_thread: Entity, acp_thread: Entity, ) -> Result> { @@ -3350,7 +3350,7 @@ impl ThreadEnvironment for NativeThreadEnvironment { fn create_terminal( &self, command: String, - extra_env: Vec, + extra_env: Vec, cwd: Option, output_byte_limit: Option, sandbox_wrap: Option, @@ -3399,9 +3399,9 @@ impl ThreadEnvironment for NativeThreadEnvironment { let temp_dir = temp_dir.canonicalize().unwrap_or(temp_dir); let temp_dir_string = temp_dir.to_string_lossy().into_owned(); extra_env.extend([ - acp::EnvVariable::new("TMPDIR", &temp_dir_string), - acp::EnvVariable::new("TMP", &temp_dir_string), - acp::EnvVariable::new("TEMP", &temp_dir_string), + acp_v1::EnvVariable::new("TMPDIR", &temp_dir_string), + acp_v1::EnvVariable::new("TMP", &temp_dir_string), + acp_v1::EnvVariable::new("TEMP", &temp_dir_string), ]); // The command's `$TMPDIR` must live inside the sandbox's // writable scope. The per-thread temp directory is owned @@ -3462,7 +3462,7 @@ impl ThreadEnvironment for NativeThreadEnvironment { fn resume_subagent( &self, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, cx: &mut App, ) -> Result> { self.resume_subagent_thread(session_id, cx) @@ -3504,7 +3504,7 @@ impl ThreadEnvironment for NativeThreadEnvironment { } pub struct NativeSubagentHandle { - session_id: acp::SessionId, + session_id: acp_v1::SessionId, parent_thread: WeakEntity, subagent_thread: Entity, acp_thread: Entity, @@ -3512,7 +3512,7 @@ pub struct NativeSubagentHandle { impl NativeSubagentHandle { fn new( - session_id: acp::SessionId, + session_id: acp_v1::SessionId, subagent_thread: Entity, acp_thread: Entity, parent_thread_entity: Entity, @@ -3527,7 +3527,7 @@ impl NativeSubagentHandle { } impl SubagentHandle for NativeSubagentHandle { - fn id(&self) -> acp::SessionId { + fn id(&self) -> acp_v1::SessionId { self.session_id.clone() } @@ -3590,15 +3590,15 @@ impl SubagentHandle for NativeSubagentHandle { }; let discard_partial_output = matches!( &response, - Ok(Some(response)) if response.stop_reason == acp::StopReason::Cancelled - || response.stop_reason == acp::StopReason::Refusal + Ok(Some(response)) if response.stop_reason == acp_v1::StopReason::Cancelled + || response.stop_reason == acp_v1::StopReason::Refusal ); let result = match response { Ok(Some(response)) => match response.stop_reason { - acp::StopReason::Cancelled => Err(anyhow!("User canceled")), - acp::StopReason::MaxTokens => Err(anyhow!("The agent reached the maximum number of tokens.")), - acp::StopReason::MaxTurnRequests => Err(anyhow!("The agent reached the maximum number of allowed requests between user turns. Try prompting again.")), - acp::StopReason::Refusal => Err(anyhow!("The agent refused to process that prompt. Try again.")), + acp_v1::StopReason::Cancelled => Err(anyhow!("User canceled")), + acp_v1::StopReason::MaxTokens => Err(anyhow!("The agent reached the maximum number of tokens.")), + acp_v1::StopReason::MaxTurnRequests => Err(anyhow!("The agent reached the maximum number of allowed requests between user turns. Try prompting again.")), + acp_v1::StopReason::Refusal => Err(anyhow!("The agent refused to process that prompt. Try again.")), _ => thread.read_with(cx, |thread, _cx| { thread .last_message() @@ -3652,16 +3652,16 @@ pub struct AcpTerminalHandle { } impl TerminalHandle for AcpTerminalHandle { - fn id(&self, cx: &AsyncApp) -> Result { + fn id(&self, cx: &AsyncApp) -> Result { Ok(self.terminal.read_with(cx, |term, _cx| term.id().clone())) } - fn wait_for_exit(&self, cx: &AsyncApp) -> Result>> { + fn wait_for_exit(&self, cx: &AsyncApp) -> Result>> { self.terminal .read_with(cx, |term, _cx| term.wait_for_exit()) } - fn current_output(&self, cx: &AsyncApp) -> Result { + fn current_output(&self, cx: &AsyncApp) -> Result { Ok(self .terminal .read_with(cx, |term, cx| term.current_output(cx))) @@ -4081,8 +4081,8 @@ mod internal_tests { authorization .response .send(acp_thread::SelectedPermissionOutcome::new( - acp::PermissionOptionId::new("allow"), - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionId::new("allow"), + acp_v1::PermissionOptionKind::AllowOnce, )) .expect("authorization response should send"); @@ -4092,7 +4092,7 @@ mod internal_tests { .iter() .flatten() .find_map(|content| match content { - acp::ToolCallContent::Terminal(terminal) => Some(terminal.terminal_id.clone()), + acp_v1::ToolCallContent::Terminal(terminal) => Some(terminal.terminal_id.clone()), _ => None, }) .expect("terminal tool should announce its real terminal"); @@ -4175,7 +4175,7 @@ mod internal_tests { fn native_thread_for_session( agent: &Entity, - session_id: &acp::SessionId, + session_id: &acp_v1::SessionId, cx: &App, ) -> Entity { agent.read_with(cx, |agent, _cx| { @@ -4256,7 +4256,7 @@ mod internal_tests { thread.set_model(model.clone(), cx); thread.push_acp_user_block( old_message_id, - [acp::ContentBlock::from("old user")], + [acp_v1::ContentBlock::from("old user")], path_style, cx, ); @@ -4270,7 +4270,7 @@ mod internal_tests { acp_thread::AgentSessionClientUserMessageIds::prompt( connection.as_ref(), compact_message_id, - acp::PromptRequest::new(session_id.clone(), vec!["/compact".into()]), + acp_v1::PromptRequest::new(session_id.clone(), vec!["/compact".into()]), cx, ) }); @@ -4412,7 +4412,7 @@ mod internal_tests { items: vec![json!({"type": "compaction", "encrypted_content": "opaque state"})], }, ))); - let restored_session_id = acp::SessionId::new("provider-native-compaction"); + let restored_session_id = acp_v1::SessionId::new("provider-native-compaction"); let database = cx .update(|cx| ThreadsDatabase::connect(cx)) .await @@ -4478,7 +4478,7 @@ mod internal_tests { acp_thread::AgentSessionClientUserMessageIds::prompt( connection.as_ref(), ClientUserMessageId::new(), - acp::PromptRequest::new(session_id.clone(), vec!["old user".into()]), + acp_v1::PromptRequest::new(session_id.clone(), vec!["old user".into()]), cx, ) }); @@ -4506,7 +4506,7 @@ mod internal_tests { acp_thread::AgentSessionClientUserMessageIds::prompt( connection.as_ref(), ClientUserMessageId::new(), - acp::PromptRequest::new(session_id, vec!["new user".into()]), + acp_v1::PromptRequest::new(session_id, vec!["new user".into()]), cx, ) }); @@ -4628,7 +4628,7 @@ mod internal_tests { thread.set_model(model.clone(), cx); thread.push_acp_user_block( ClientUserMessageId::new(), - [acp::ContentBlock::from("old user")], + [acp_v1::ContentBlock::from("old user")], path_style, cx, ); @@ -4679,7 +4679,7 @@ mod internal_tests { .expect("canceled compaction events should be bridged"); assert_eq!( response.stop_reason, - acp::StopReason::Cancelled, + acp_v1::StopReason::Cancelled, "{scenario}" ); @@ -4748,7 +4748,7 @@ mod internal_tests { acp_thread::AgentSessionClientUserMessageIds::prompt( connection.as_ref(), ClientUserMessageId::new(), - acp::PromptRequest::new(session_id.clone(), vec!["use a tool".into()]), + acp_v1::PromptRequest::new(session_id.clone(), vec!["use a tool".into()]), cx, ) }); @@ -4871,14 +4871,16 @@ mod internal_tests { thread.update(cx, |thread, cx| { thread.push_acp_user_block( ClientUserMessageId::new(), - [acp::ContentBlock::from("hello from the user")], + [acp_v1::ContentBlock::from("hello from the user")], path_style, cx, ); }); acp_thread.update(cx, |acp_thread, cx| { - acp_thread - .set_draft_prompt(Some(vec![acp::ContentBlock::from("draft in progress")]), cx); + acp_thread.set_draft_prompt( + Some(vec![acp_v1::ContentBlock::from("draft in progress")]), + cx, + ); }); }); cx.run_until_parked(); @@ -4913,7 +4915,7 @@ mod internal_tests { ); assert_eq!( restored.draft_prompt, - Some(vec![acp::ContentBlock::from("draft in progress")]), + Some(vec![acp_v1::ContentBlock::from("draft in progress")]), "the current draft prompt should be captured by the quit flush" ); assert!( @@ -4947,17 +4949,17 @@ mod internal_tests { #[test] fn test_qualified_compact_commands_are_not_native_compact() { - let unqualified_blocks = [acp::ContentBlock::from("/compact")]; + let unqualified_blocks = [acp_v1::ContentBlock::from("/compact")]; let unqualified = Command::parse(&unqualified_blocks).unwrap(); assert!(unqualified.is_unqualified("compact")); - let mcp_blocks = [acp::ContentBlock::from("/server.compact")]; + let mcp_blocks = [acp_v1::ContentBlock::from("/server.compact")]; let mcp_qualified = Command::parse(&mcp_blocks).unwrap(); assert_eq!(mcp_qualified.prompt_name, "compact"); assert_eq!(mcp_qualified.explicit_server_id, Some("server")); assert!(!mcp_qualified.is_unqualified("compact")); - let skill_blocks = [acp::ContentBlock::from("/:compact")]; + let skill_blocks = [acp_v1::ContentBlock::from("/:compact")]; let skill_qualified = Command::parse(&skill_blocks).unwrap(); assert_eq!(skill_qualified.prompt_name, "compact"); assert_eq!(skill_qualified.skill_scope, Some("")); @@ -7049,7 +7051,7 @@ mod internal_tests { Entity, Rc, Entity, - acp::SessionId, + acp_v1::SessionId, Arc, ) { let fs = FakeFs::new(cx.executor()); @@ -7293,7 +7295,7 @@ mod internal_tests { thread.send( vec![ "What does ".into(), - acp::ContentBlock::ResourceLink(acp::ResourceLink::new( + acp_v1::ContentBlock::ResourceLink(acp_v1::ResourceLink::new( "b.md", MentionUri::File { abs_path: path!("/a/b.md").into(), @@ -7350,9 +7352,9 @@ mod internal_tests { // AFTER run_until_parked, so the only save that captures these // changes is the one performed by close_session itself. let draft_blocks = vec![ - acp::ContentBlock::Text(acp::TextContent::new("Check out ")), - acp::ContentBlock::ResourceLink(acp::ResourceLink::new("b.md", uri.to_string())), - acp::ContentBlock::Text(acp::TextContent::new(" please")), + acp_v1::ContentBlock::Text(acp_v1::TextContent::new("Check out ")), + acp_v1::ContentBlock::ResourceLink(acp_v1::ResourceLink::new("b.md", uri.to_string())), + acp_v1::ContentBlock::Text(acp_v1::TextContent::new(" please")), ]; acp_thread.update(cx, |thread, cx| { thread.set_draft_prompt(Some(draft_blocks.clone()), cx); @@ -7477,7 +7479,7 @@ mod internal_tests { // This means no observe-triggered save has run for this change. // The only way this data gets persisted is if close_session // itself performs the save. - let draft_blocks = vec![acp::ContentBlock::Text(acp::TextContent::new( + let draft_blocks = vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "unsaved draft", ))]; acp_thread.update(cx, |thread, cx| { @@ -7639,7 +7641,7 @@ mod internal_tests { let database = cx.update(|cx| ThreadsDatabase::connect(cx)).await.unwrap(); let [first_draft, second_draft, third_draft] = ["draft one", "draft two", "draft three"] - .map(|text| vec![acp::ContentBlock::Text(acp::TextContent::new(text))]); + .map(|text| vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new(text))]); let (first_gate_tx, first_gate_rx) = oneshot::channel(); database.set_write_gate(first_gate_rx); @@ -7967,7 +7969,7 @@ mod internal_tests { fn thread_entries( thread_store: &Entity, cx: &mut TestAppContext, - ) -> Vec<(acp::SessionId, String)> { + ) -> Vec<(acp_v1::SessionId, String)> { thread_store.read_with(cx, |store, _| { store .entries() @@ -8031,7 +8033,7 @@ mod internal_tests { agent: &Entity, acp_thread: &Entity, thread: &Entity, - draft: Vec, + draft: Vec, cx: &mut TestAppContext, ) { acp_thread.update(cx, |acp_thread, cx| { @@ -8045,7 +8047,7 @@ mod internal_tests { fn mcp_message_content_to_acp_content_block( content: context_server::types::MessageContent, -) -> acp::ContentBlock { +) -> acp_v1::ContentBlock { match content { context_server::types::MessageContent::Text { text, @@ -8055,22 +8057,22 @@ fn mcp_message_content_to_acp_content_block( data, mime_type, annotations: _, - } => acp::ContentBlock::Image(acp::ImageContent::new(data, mime_type)), + } => acp_v1::ContentBlock::Image(acp_v1::ImageContent::new(data, mime_type)), context_server::types::MessageContent::Audio { data, mime_type, annotations: _, - } => acp::ContentBlock::Audio(acp::AudioContent::new(data, mime_type)), + } => acp_v1::ContentBlock::Audio(acp_v1::AudioContent::new(data, mime_type)), context_server::types::MessageContent::Resource { resource, annotations: _, } => { let mut link = - acp::ResourceLink::new(resource.uri.to_string(), resource.uri.to_string()); + acp_v1::ResourceLink::new(resource.uri.to_string(), resource.uri.to_string()); if let Some(mime_type) = resource.mime_type { link = link.mime_type(mime_type); } - acp::ContentBlock::ResourceLink(link) + acp_v1::ContentBlock::ResourceLink(link) } } } diff --git a/crates/agent_ui/src/conversation_view.rs b/crates/agent_ui/src/conversation_view.rs index 4811335886b..6e53713a66e 100644 --- a/crates/agent_ui/src/conversation_view.rs +++ b/crates/agent_ui/src/conversation_view.rs @@ -8,7 +8,7 @@ use acp_thread::{ use acp_thread::{AgentConnection, Plan}; use action_log::{ActionLog, ActionLogTelemetry, DiffStats}; use agent::{NativeAgentServer, NoModelConfiguredError, ThreadStore}; -use agent_client_protocol::schema::v1 as acp; +use agent_client_protocol::schema::v1 as acp_v1; #[cfg(test)] use agent_servers::AgentServerDelegate; use agent_servers::{AgentServer, GEMINI_TERMINAL_AUTH_METHOD_ID}; @@ -168,8 +168,8 @@ impl From for ThreadError { Self::MaxOutputTokens } else if error.is::() { Self::NoModelSelected - } else if let Some(acp_error) = error.downcast_ref::() - && acp_error.code == acp::ErrorCode::AuthRequired + } else if let Some(acp_error) = error.downcast_ref::() + && acp_error.code == acp_v1::ErrorCode::AuthRequired { Self::AuthenticationRequired(acp_error.message.clone().into()) } else if let Some(lm_error) = error.downcast_ref::() { @@ -237,7 +237,7 @@ impl From for ThreadError { // Extract ACP error code if available let acp_error_code = error - .downcast_ref::() + .downcast_ref::() .map(|acp_error| SharedString::from(acp_error.code.to_string())); Self::Other { @@ -284,9 +284,9 @@ impl ProfileProvider for Entity { #[derive(Default)] pub(crate) struct Conversation { - threads: HashMap>, - permission_requests: IndexMap>, - elicitation_requests: IndexMap>, + threads: HashMap>, + permission_requests: IndexMap>, + elicitation_requests: IndexMap>, subscriptions: Vec, updated_at: Option, } @@ -364,8 +364,8 @@ impl Conversation { fn add_permission_request( &mut self, - session_id: &acp::SessionId, - tool_call_id: &acp::ToolCallId, + session_id: &acp_v1::SessionId, + tool_call_id: &acp_v1::ToolCallId, ) { let requests = self .permission_requests @@ -378,8 +378,8 @@ impl Conversation { pub fn permission_options_for_tool_call<'a>( &'a self, - session_id: &acp::SessionId, - tool_call_id: acp::ToolCallId, + session_id: &acp_v1::SessionId, + tool_call_id: acp_v1::ToolCallId, cx: &'a App, ) -> Option<&'a PermissionOptions> { let thread = self.threads.get(session_id)?; @@ -392,9 +392,9 @@ impl Conversation { pub fn pending_tool_call<'a>( &'a self, - session_id: &acp::SessionId, + session_id: &acp_v1::SessionId, cx: &'a App, - ) -> Option<(acp::SessionId, acp::ToolCallId, &'a PermissionOptions)> { + ) -> Option<(acp_v1::SessionId, acp_v1::ToolCallId, &'a PermissionOptions)> { let thread = self.threads.get(session_id)?; let is_subagent = thread.read(cx).parent_session_id().is_some(); let (result_session_id, thread, tool_id) = if is_subagent { @@ -414,7 +414,7 @@ impl Conversation { Some((result_session_id, tool_id.clone(), options)) } - pub fn subagents_awaiting_permission(&self, cx: &App) -> Vec<(acp::SessionId, usize)> { + pub fn subagents_awaiting_permission(&self, cx: &App) -> Vec<(acp_v1::SessionId, usize)> { self.permission_requests .iter() .filter_map(|(session_id, tool_call_ids)| { @@ -433,9 +433,9 @@ impl Conversation { /// request for non-subagent sessions. pub fn pending_tool_call_for_session( &self, - session_id: &acp::SessionId, + session_id: &acp_v1::SessionId, cx: &App, - ) -> Option { + ) -> Option { let thread = self.threads.get(session_id)?; let tool_call_id = self.permission_requests.get(session_id)?.iter().next()?; let (_, tool_call) = thread.read(cx).tool_call(tool_call_id)?; @@ -448,7 +448,7 @@ impl Conversation { Some(tool_call_id.clone()) } - pub fn pending_tool_call_count_for_session(&self, session_id: &acp::SessionId) -> usize { + pub fn pending_tool_call_count_for_session(&self, session_id: &acp_v1::SessionId) -> usize { self.permission_requests .get(session_id) .map(|tool_call_ids| tool_call_ids.len()) @@ -457,9 +457,9 @@ impl Conversation { pub fn respond_to_elicitation( &mut self, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, elicitation_id: ElicitationEntryId, - response: acp::CreateElicitationResponse, + response: acp_v1::CreateElicitationResponse, cx: &mut Context, ) -> Option<()> { let thread = self.threads.get(&session_id)?.clone(); @@ -471,8 +471,8 @@ impl Conversation { pub fn authorize_pending_tool_call( &mut self, - session_id: &acp::SessionId, - kind: acp::PermissionOptionKind, + session_id: &acp_v1::SessionId, + kind: acp_v1::PermissionOptionKind, cx: &mut Context, ) -> Option<()> { let (authorize_session_id, tool_call_id, options) = @@ -489,8 +489,8 @@ impl Conversation { pub fn authorize_with_granularity( &mut self, - session_id: acp::SessionId, - tool_call_id: acp::ToolCallId, + session_id: acp_v1::SessionId, + tool_call_id: acp_v1::ToolCallId, selection: Option<&thread_view::PermissionSelection>, is_allow: bool, cx: &mut Context, @@ -504,8 +504,8 @@ impl Conversation { pub fn authorize_tool_call( &mut self, - session_id: acp::SessionId, - tool_call_id: acp::ToolCallId, + session_id: acp_v1::SessionId, + tool_call_id: acp_v1::ToolCallId, outcome: SelectedPermissionOutcome, cx: &mut Context, ) { @@ -543,9 +543,9 @@ impl EventEmitter for ConversationView {} fn permission_option_for_action( options: &PermissionOptions, - kind: acp::PermissionOptionKind, -) -> Option<&acp::PermissionOption> { - if kind == acp::PermissionOptionKind::AllowAlways + kind: acp_v1::PermissionOptionKind, +) -> Option<&acp_v1::PermissionOption> { + if kind == acp_v1::PermissionOptionKind::AllowAlways && let PermissionOptions::Flat(options) = options && let Some(option) = options.iter().find(|option| { option.option_id.0.as_ref() == acp_thread::SandboxPermission::AllowAlways.as_id() @@ -571,9 +571,9 @@ fn resolve_outcome_from_selection( PermissionOptions::DropdownWithPatterns { choices, .. } => choices.as_slice(), PermissionOptions::Flat(_) => { let kind = if is_allow { - acp::PermissionOptionKind::AllowOnce + acp_v1::PermissionOptionKind::AllowOnce } else { - acp::PermissionOptionKind::RejectOnce + acp_v1::PermissionOptionKind::RejectOnce }; let option = options.first_option_of_kind(kind)?; return Some(SelectedPermissionOutcome::new( @@ -642,7 +642,7 @@ pub struct ConversationView { project: Entity, thread_store: Option>, pub(crate) thread_id: ThreadId, - pub(crate) root_session_id: Option, + pub(crate) root_session_id: Option, server_state: ServerState, focus_handle: FocusHandle, notifications: Vec>, @@ -683,7 +683,7 @@ impl ConversationView { pub fn pending_tool_call<'a>( &'a self, cx: &'a App, - ) -> Option<(acp::SessionId, acp::ToolCallId, &'a PermissionOptions)> { + ) -> Option<(acp_v1::SessionId, acp_v1::ToolCallId, &'a PermissionOptions)> { let session_id = self.active_thread()?.read(cx).session_id.clone(); self.as_connected()? .conversation @@ -716,7 +716,7 @@ impl ConversationView { .and_then(|id| self.thread_view(id)) } - pub fn thread_view(&self, session_id: &acp::SessionId) -> Option> { + pub fn thread_view(&self, session_id: &acp_v1::SessionId) -> Option> { let connected = self.as_connected()?; connected.threads.get(session_id).cloned() } @@ -742,7 +742,7 @@ impl ConversationView { pub fn navigate_to_thread( &mut self, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, window: &mut Window, cx: &mut Context, ) { @@ -783,8 +783,8 @@ enum ServerState { // hashmap of threads, current becomes session_id pub struct ConnectedServerState { auth_state: AuthState, - active_id: Option, - pub(crate) threads: HashMap>, + active_id: Option, + pub(crate) threads: HashMap>, connection: Rc, conversation: Entity, _connection_entry_subscription: Subscription, @@ -795,7 +795,7 @@ enum AuthState { Ok, Unauthenticated { description: Option>, - pending_auth_method: Option, + pending_auth_method: Option, }, } @@ -819,7 +819,7 @@ impl ConnectedServerState { .map_or(false, |view| view.read(cx).thread_error.is_some()) } - pub fn navigate_to_thread(&mut self, session_id: acp::SessionId) { + pub fn navigate_to_thread(&mut self, session_id: acp_v1::SessionId) { if self.threads.contains_key(&session_id) { self.active_id = Some(session_id); } @@ -846,7 +846,7 @@ impl ConversationView { agent: Rc, connection_store: Entity, connection_key: Agent, - resume_session_id: Option, + resume_session_id: Option, thread_id: Option, work_dirs: Option, title: Option, @@ -1078,7 +1078,7 @@ impl ConversationView { agent: Rc, connection_store: Entity, connection_key: Agent, - resume_session_id: Option, + resume_session_id: Option, work_dirs: Option, title: Option, project: Entity, @@ -1725,7 +1725,7 @@ impl ConversationView { }); } if is_subagent { - if *stop_reason == acp::StopReason::EndTurn { + if *stop_reason == acp_v1::StopReason::EndTurn { thread.update(cx, |thread, cx| { thread.mark_as_subagent_output(cx); }); @@ -1935,7 +1935,7 @@ impl ConversationView { if !thread.is_draft_thread() { return None; } - let snapshot: Vec = thread + let snapshot: Vec = thread .draft_prompt() .map(|p| p.to_vec()) .unwrap_or_default(); @@ -1953,7 +1953,7 @@ impl ConversationView { fn authenticate( &mut self, - method: acp::AuthMethodId, + method: acp_v1::AuthMethodId, window: &mut Window, cx: &mut Context, ) { @@ -2093,8 +2093,8 @@ impl ConversationView { fn load_subagent_session( &mut self, - subagent_id: acp::SessionId, - parent_session_id: acp::SessionId, + subagent_id: acp_v1::SessionId, + parent_session_id: acp_v1::SessionId, window: &mut Window, cx: &mut Context, ) { @@ -2153,7 +2153,7 @@ impl ConversationView { login: task::SpawnInTerminal, workspace: Entity, project: Entity, - method: acp::AuthMethodId, + method: acp_v1::AuthMethodId, previous_attempt: bool, window: &mut Window, cx: &mut App, @@ -2292,7 +2292,7 @@ impl ConversationView { &self, connection: &Rc, description: Option<&Entity>, - pending_auth_method: Option<&acp::AuthMethodId>, + pending_auth_method: Option<&acp_v1::AuthMethodId>, window: &mut Window, cx: &Context, ) -> impl IntoElement { @@ -2339,7 +2339,7 @@ impl ConversationView { ); this.authenticate( - acp::AuthMethodId::new(method_id.clone()), + acp_v1::AuthMethodId::new(method_id.clone()), window, cx, ) @@ -2409,7 +2409,7 @@ impl ConversationView { .map(|elicitation| { let is_pending = matches!(elicitation.status, ElicitationStatus::Pending { .. }); let schema = match &elicitation.request.mode { - acp::ElicitationMode::Form(mode) => Some(mode.requested_schema.clone()), + acp_v1::ElicitationMode::Form(mode) => Some(mode.requested_schema.clone()), _ => None, }; (elicitation.id.clone(), is_pending, schema) @@ -2589,7 +2589,7 @@ impl ConversationView { }; match mode { - acp::ElicitationMode::Form(mode) => { + acp_v1::ElicitationMode::Form(mode) => { let Some(state) = self .request_elicitation_form_states .get_mut(&elicitation_id) @@ -2622,9 +2622,9 @@ impl ConversationView { Ok(content) => { this.respond_to_request_elicitation( elicitation_id, - acp::CreateElicitationResponse::new( - acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new().content(content), + acp_v1::CreateElicitationResponse::new( + acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new().content(content), ), ), cx, @@ -2643,11 +2643,11 @@ impl ConversationView { }) .detach(); } - acp::ElicitationMode::Url(_) => { + acp_v1::ElicitationMode::Url(_) => { self.respond_to_request_elicitation( elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new(), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new(), )), cx, ); @@ -2664,7 +2664,7 @@ impl ConversationView { ) { self.respond_to_request_elicitation( elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Decline), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Decline), cx, ); } @@ -2677,7 +2677,7 @@ impl ConversationView { ) { self.respond_to_request_elicitation( elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Cancel), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Cancel), cx, ); } @@ -2699,7 +2699,7 @@ impl ConversationView { fn respond_to_request_elicitation( &mut self, elicitation_id: ElicitationEntryId, - response: acp::CreateElicitationResponse, + response: acp_v1::CreateElicitationResponse, cx: &mut Context, ) { self.request_elicitation_form_states.remove(&elicitation_id); @@ -3352,7 +3352,7 @@ fn loading_contents_spinner(size: IconSize) -> AnyElement { fn native_available_skills( native_connection: &agent::NativeAgentConnection, - session_id: &acp::SessionId, + session_id: &acp_v1::SessionId, cx: &App, ) -> Vec { native_connection @@ -3405,7 +3405,7 @@ impl ConversationView { impl ConversationView { /// Expands a tool call so its content is visible. /// This is primarily useful for visual testing. - pub fn expand_tool_call(&mut self, tool_call_id: acp::ToolCallId, cx: &mut Context) { + pub fn expand_tool_call(&mut self, tool_call_id: acp_v1::ToolCallId, cx: &mut Context) { if let Some(active) = self.active_thread() { active.update(cx, |active, cx| { active.entry_view_state.update(cx, |state, _cx| { @@ -3701,7 +3701,7 @@ impl AgentCodeSpanResolver { } fn plan_label_markdown_style( - status: &acp::PlanEntryStatus, + status: &acp_v1::PlanEntryStatus, window: &Window, cx: &App, ) -> MarkdownStyle { @@ -3710,7 +3710,7 @@ fn plan_label_markdown_style( MarkdownStyle { base_text_style: TextStyle { color: cx.theme().colors().text_muted, - strikethrough: if matches!(status, acp::PlanEntryStatus::Completed) { + strikethrough: if matches!(status, acp_v1::PlanEntryStatus::Completed) { Some(gpui::StrikethroughStyle { thickness: px(1.), color: Some(cx.theme().colors().text_muted.opacity(0.8)), @@ -3894,7 +3894,7 @@ pub(crate) mod tests { cx.run_until_parked(); assert!(matches!( response.lock().as_ref(), - Some(acp::ElicitationAction::Cancel) + Some(acp_v1::ElicitationAction::Cancel) )); } @@ -3949,7 +3949,7 @@ pub(crate) mod tests { cx.run_until_parked(); assert!(matches!( response.lock().as_ref(), - Some(acp::ElicitationAction::Cancel) + Some(acp_v1::ElicitationAction::Cancel) )); } @@ -3969,8 +3969,8 @@ pub(crate) mod tests { response: response.clone(), }; let (conversation_view, cx) = setup_conversation_view(server, cx).await; - let first_request_id = acp::RequestId::Number(1); - let second_request_id = acp::RequestId::Number(2); + let first_request_id = acp_v1::RequestId::Number(1); + let second_request_id = acp_v1::RequestId::Number(2); let first_elicitation_id = store.read_with(cx, |store, _cx| { assert_eq!( store.elicitations().len(), @@ -3981,7 +3981,8 @@ pub(crate) mod tests { .elicitations() .iter() .find_map(|elicitation| { - let acp::ElicitationScope::Request(scope) = elicitation.request.scope() else { + let acp_v1::ElicitationScope::Request(scope) = elicitation.request.scope() + else { return None; }; (&scope.request_id == &first_request_id).then(|| elicitation.id.clone()) @@ -3992,8 +3993,8 @@ pub(crate) mod tests { store.update(cx, |store, cx| { store.respond_to_elicitation( &first_elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new(), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new(), )), cx, ); @@ -4002,7 +4003,7 @@ pub(crate) mod tests { assert!(matches!( response.lock().as_ref(), - Some(acp::ElicitationAction::Accept(_)) + Some(acp_v1::ElicitationAction::Accept(_)) )); conversation_view.read_with(cx, |view, _cx| { let connected = view @@ -4020,7 +4021,7 @@ pub(crate) mod tests { store.elicitations() ); }; - let acp::ElicitationScope::Request(scope) = remaining.request.scope() else { + let acp_v1::ElicitationScope::Request(scope) = remaining.request.scope() else { panic!("expected request-scoped elicitation"); }; assert_eq!(scope.request_id, second_request_id); @@ -4217,7 +4218,7 @@ pub(crate) mod tests { active_thread(&conversation_view, cx).update_in(cx, |thread, window, cx| { thread.add_to_queue( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "queued".to_string(), ))], vec![], @@ -4232,12 +4233,12 @@ pub(crate) mod tests { cx.update(|_, cx| { connection.send_update( session_id.clone(), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new( + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new( "first response".into(), )), cx, ); - connection.end_turn(session_id, acp::StopReason::EndTurn); + connection.end_turn(session_id, acp_v1::StopReason::EndTurn); }); cx.run_until_parked(); @@ -4262,7 +4263,7 @@ pub(crate) mod tests { let id = active_thread(&conversation_view, cx).update_in(cx, |thread, window, cx| { thread.add_to_queue( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "queued".to_string(), ))], vec![], @@ -4313,7 +4314,7 @@ pub(crate) mod tests { // Queue a follow-up while the agent is generating. active_thread(&conversation_view, cx).update_in(cx, |thread, window, cx| { thread.add_to_queue( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "queued".to_string(), ))], vec![], @@ -4351,7 +4352,7 @@ pub(crate) mod tests { // When this generation completes, the queued message should be picked // up automatically (regression test for the "frozen queue" bug). - connection.end_turn(session_id, acp::StopReason::EndTurn); + connection.end_turn(session_id, acp_v1::StopReason::EndTurn); cx.run_until_parked(); let queue_len = active_thread(&conversation_view, cx) @@ -4398,12 +4399,13 @@ pub(crate) mod tests { add_to_workspace_with_size(conversation_view.clone(), true, cx); let thread_view = active_thread(&conversation_view, cx); let thread = thread_view.read_with(cx, |view, _| view.thread.clone()); - let notice = acp::Notice::new(acp::NoticeSeverity::Error, "Optional integration failed") - .description("**Plain text**, not Markdown. Work continues."); + let notice = + acp_v1::Notice::new(acp_v1::NoticeSeverity::Error, "Optional integration failed") + .description("**Plain text**, not Markdown. Work continues."); thread.update(cx, |thread, cx| { for _ in 0..2 { thread - .handle_session_update(acp::SessionUpdate::Notice(notice.clone()), cx) + .handle_session_update(acp_v1::SessionUpdate::Notice(notice.clone()), cx) .expect("notice should be accepted"); } }); @@ -4456,7 +4458,7 @@ pub(crate) mod tests { let root_thread = active_thread(&conversation_view, cx).read_with(cx, |view, _| view.thread.clone()); let root_session_id = root_thread.read_with(cx, |thread, _| thread.session_id().clone()); - let other_session_id = acp::SessionId::new("other-session"); + let other_session_id = acp_v1::SessionId::new("other-session"); conversation_view.update_in(cx, |view, window, cx| { view.load_subagent_session( other_session_id.clone(), @@ -4487,8 +4489,8 @@ pub(crate) mod tests { cx.update(|_, cx| { connection.send_update( root_session_id.clone(), - acp::SessionUpdate::Notice(acp::Notice::new( - acp::NoticeSeverity::Error, + acp_v1::SessionUpdate::Notice(acp_v1::Notice::new( + acp_v1::NoticeSeverity::Error, "Optional integration failed", )), cx, @@ -4550,9 +4552,9 @@ pub(crate) mod tests { for index in 0..8 { thread .handle_session_update( - acp::SessionUpdate::Notice( - acp::Notice::new( - acp::NoticeSeverity::Other("_advisory".into()), + acp_v1::SessionUpdate::Notice( + acp_v1::Notice::new( + acp_v1::NoticeSeverity::Other("_advisory".into()), "The optional documentation integration is unavailable", ) .description(if index == 0 { @@ -4600,7 +4602,7 @@ pub(crate) mod tests { thread.update(cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new( + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new( "Work is continuing.".into(), )), cx, @@ -4706,7 +4708,7 @@ pub(crate) mod tests { Rc::new(StubAgentServer::new(ResumeOnlyAgentConnection)), connection_store, Agent::Custom { id: "Test".into() }, - Some(acp::SessionId::new("resume-session")), + Some(acp_v1::SessionId::new("resume-session")), None, None, None, @@ -4752,7 +4754,7 @@ pub(crate) mod tests { self, project, "RestoredAvailableCommandsConnection", - acp::SessionId::new("new-session"), + acp_v1::SessionId::new("new-session"), cx, ); Task::ready(Ok(thread)) @@ -4764,7 +4766,7 @@ pub(crate) mod tests { fn load_session( self: Rc, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, project: Entity, _work_dirs: PathList, _title: Option, @@ -4781,10 +4783,10 @@ pub(crate) mod tests { thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::AvailableCommandsUpdate( - acp::AvailableCommandsUpdate::new(vec![acp::AvailableCommand::new( - "help", "Get help", - )]), + acp_v1::SessionUpdate::AvailableCommandsUpdate( + acp_v1::AvailableCommandsUpdate::new(vec![ + acp_v1::AvailableCommand::new("help", "Get help"), + ]), ), cx, ) @@ -4794,13 +4796,13 @@ pub(crate) mod tests { Task::ready(Ok(thread)) } - fn auth_methods(&self) -> &[acp::AuthMethod] { + fn auth_methods(&self) -> &[acp_v1::AuthMethod] { &[] } fn authenticate( &self, - _method_id: acp::AuthMethodId, + _method_id: acp_v1::AuthMethodId, _cx: &mut App, ) -> Task> { Task::ready(Ok(())) @@ -4808,13 +4810,13 @@ pub(crate) mod tests { fn prompt( &self, - _params: acp::PromptRequest, + _params: acp_v1::PromptRequest, _cx: &mut App, - ) -> Task> { - Task::ready(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + ) -> Task> { + Task::ready(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) } - fn cancel(&self, _session_id: &acp::SessionId, _cx: &mut App) {} + fn cancel(&self, _session_id: &acp_v1::SessionId, _cx: &mut App) {} fn into_any(self: Rc) -> Rc { self @@ -4841,7 +4843,7 @@ pub(crate) mod tests { Rc::new(StubAgentServer::new(RestoredAvailableCommandsConnection)), connection_store, Agent::Custom { id: "Test".into() }, - Some(acp::SessionId::new("restored-session")), + Some(acp_v1::SessionId::new("restored-session")), None, None, None, @@ -4922,7 +4924,7 @@ pub(crate) mod tests { Rc::new(StubAgentServer::new(connection)), connection_store, Agent::Custom { id: "Test".into() }, - Some(acp::SessionId::new("session-1")), + Some(acp_v1::SessionId::new("session-1")), None, Some(PathList::new(&[PathBuf::from("/project/subdir")])), None, @@ -5028,7 +5030,7 @@ pub(crate) mod tests { cx.update(|_window, cx| cx.new(|cx| AgentConnectionStore::new(project.clone(), cx))); // Simulate a previous run that persisted metadata for this session. - let resume_session_id = acp::SessionId::new("persistent-session"); + let resume_session_id = acp_v1::SessionId::new("persistent-session"); let stored_title: SharedString = "Persistent chat".into(); cx.update(|_window, cx| { ThreadMetadataStore::global(cx).update(cx, |store, cx| { @@ -5172,7 +5174,7 @@ pub(crate) mod tests { // then on success triggers reset() -> new_session() which now succeeds. conversation_view.update_in(cx, |view, window, cx| { view.authenticate( - acp::AuthMethodId::new(AuthGatedAgentConnection::AUTH_METHOD_ID), + acp_v1::AuthMethodId::new(AuthGatedAgentConnection::AUTH_METHOD_ID), window, cx, ); @@ -5242,21 +5244,21 @@ pub(crate) mod tests { async fn test_notification_for_tool_authorization(cx: &mut TestAppContext) { init_test(cx); - let tool_call_id = acp::ToolCallId::new("1"); - let tool_call = acp::ToolCall::new(tool_call_id.clone(), "Label") - .kind(acp::ToolKind::Edit) + let tool_call_id = acp_v1::ToolCallId::new("1"); + let tool_call = acp_v1::ToolCall::new(tool_call_id.clone(), "Label") + .kind(acp_v1::ToolKind::Edit) .content(vec!["hi".into()]); let connection = StubAgentConnection::new().with_permission_requests(HashMap::from_iter([( tool_call_id, - PermissionOptions::Flat(vec![acp::PermissionOption::new( + PermissionOptions::Flat(vec![acp_v1::PermissionOption::new( "1", "Allow", - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionKind::AllowOnce, )]), )])); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall(tool_call)]); + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::ToolCall(tool_call)]); let (conversation_view, cx) = setup_conversation_view(StubAgentServer::new(connection), cx).await; @@ -5952,8 +5954,8 @@ pub(crate) mod tests { setup_conversation_view_with_initial_content_opt(agent, None, cx).await } - fn png_image() -> acp::ContentBlock { - acp::ContentBlock::Image(acp::ImageContent::new( + fn png_image() -> acp_v1::ContentBlock { + acp_v1::ContentBlock::Image(acp_v1::ImageContent::new( "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==", "image/png", )) @@ -6001,10 +6003,10 @@ pub(crate) mod tests { cx.update(|_, cx| { connection.send_update( session_id.clone(), - acp::SessionUpdate::Plan(acp::Plan::new(vec![acp::PlanEntry::new( + acp_v1::SessionUpdate::Plan(acp_v1::Plan::new(vec![acp_v1::PlanEntry::new( "Do the thing", - acp::PlanEntryPriority::Medium, - acp::PlanEntryStatus::InProgress, + acp_v1::PlanEntryPriority::Medium, + acp_v1::PlanEntryStatus::InProgress, )])), cx, ); @@ -6017,10 +6019,10 @@ pub(crate) mod tests { cx.update(|_, cx| { connection.send_update( session_id.clone(), - acp::SessionUpdate::Plan(acp::Plan::new(vec![acp::PlanEntry::new( + acp_v1::SessionUpdate::Plan(acp_v1::Plan::new(vec![acp_v1::PlanEntry::new( "Do the thing", - acp::PlanEntryPriority::Medium, - acp::PlanEntryStatus::Completed, + acp_v1::PlanEntryPriority::Medium, + acp_v1::PlanEntryStatus::Completed, )])), cx, ); @@ -6030,7 +6032,7 @@ pub(crate) mod tests { assert_thread_list_item_count_matches_entries(view, cx); }); - connection.end_turn(session_id, acp::StopReason::EndTurn); + connection.end_turn(session_id, acp_v1::StopReason::EndTurn); cx.run_until_parked(); active_thread(&conversation_view, cx).read_with(cx, |view, cx| { assert_thread_list_item_count_matches_entries(view, cx); @@ -6170,8 +6172,8 @@ pub(crate) mod tests { impl StubAgentServer { pub(crate) fn default_response() -> Self { let conn = StubAgentConnection::new(); - conn.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("Default response".into()), + conn.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("Default response".into()), )]); Self::new(conn) } @@ -6289,7 +6291,7 @@ pub(crate) mod tests { connection: Rc, project: Entity, name: &'static str, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, cx: &mut App, ) -> Entity { let action_log = cx.new(|_| ActionLog::new(project.clone())); @@ -6303,7 +6305,7 @@ pub(crate) mod tests { action_log, session_id, watch::Receiver::constant( - acp::PromptCapabilities::new() + acp_v1::PromptCapabilities::new() .image(true) .audio(true) .embedded_context(true), @@ -6333,7 +6335,7 @@ pub(crate) mod tests { _work_dirs: PathList, cx: &mut App, ) -> Task>> { - let session_id = acp::SessionId::new("new-session"); + let session_id = acp_v1::SessionId::new("new-session"); let thread = build_test_thread( self.clone(), project, @@ -6344,10 +6346,10 @@ pub(crate) mod tests { thread.update(cx, |thread, cx| { thread .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationSessionScope::new(session_id), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationSessionScope::new(session_id), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -6369,13 +6371,13 @@ pub(crate) mod tests { Task::ready(Ok(thread)) } - fn auth_methods(&self) -> &[acp::AuthMethod] { + fn auth_methods(&self) -> &[acp_v1::AuthMethod] { &[] } fn authenticate( &self, - _method_id: acp::AuthMethodId, + _method_id: acp_v1::AuthMethodId, _cx: &mut App, ) -> Task> { Task::ready(Ok(())) @@ -6383,13 +6385,13 @@ pub(crate) mod tests { fn prompt( &self, - _params: acp::PromptRequest, + _params: acp_v1::PromptRequest, _cx: &mut App, - ) -> Task> { - Task::ready(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + ) -> Task> { + Task::ready(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) } - fn cancel(&self, _session_id: &acp::SessionId, _cx: &mut App) {} + fn cancel(&self, _session_id: &acp_v1::SessionId, _cx: &mut App) {} fn into_any(self: Rc) -> Rc { self @@ -6398,7 +6400,7 @@ pub(crate) mod tests { struct SessionCreationRequestElicitationServer { store: Entity, - response: Arc>>, + response: Arc>>, } impl AgentServer for SessionCreationRequestElicitationServer { @@ -6430,7 +6432,7 @@ pub(crate) mod tests { struct SessionCreationRequestElicitationConnection { store: Entity, - response: Arc>>, + response: Arc>>, } impl AgentConnection for SessionCreationRequestElicitationConnection { @@ -6452,16 +6454,16 @@ pub(crate) mod tests { self.clone(), project, "SessionCreationRequestElicitationConnection", - acp::SessionId::new("session-creation-request-elicitation-session"), + acp_v1::SessionId::new("session-creation-request-elicitation-session"), cx, ); let first_response_task = self.store.update(cx, |store, cx| { store .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationRequestScope::new(acp::RequestId::Number(1)), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -6473,10 +6475,12 @@ pub(crate) mod tests { .update(cx, |store, cx| { store .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationRequestScope::new(acp::RequestId::Number(2)), - acp::ElicitationSchema::new().string("account", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationRequestScope::new( + acp_v1::RequestId::Number(2), + ), + acp_v1::ElicitationSchema::new().string("account", true), ), "Provide an account", ), @@ -6498,13 +6502,13 @@ pub(crate) mod tests { Some(self.store.clone()) } - fn auth_methods(&self) -> &[acp::AuthMethod] { + fn auth_methods(&self) -> &[acp_v1::AuthMethod] { &[] } fn authenticate( &self, - _method_id: acp::AuthMethodId, + _method_id: acp_v1::AuthMethodId, _cx: &mut App, ) -> Task> { Task::ready(Ok(())) @@ -6512,13 +6516,13 @@ pub(crate) mod tests { fn prompt( &self, - _params: acp::PromptRequest, + _params: acp_v1::PromptRequest, _cx: &mut App, - ) -> Task> { - Task::ready(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + ) -> Task> { + Task::ready(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) } - fn cancel(&self, _session_id: &acp::SessionId, _cx: &mut App) {} + fn cancel(&self, _session_id: &acp_v1::SessionId, _cx: &mut App) {} fn into_any(self: Rc) -> Rc { self @@ -6526,7 +6530,7 @@ pub(crate) mod tests { } struct ReleaseRequestElicitationServer { - response: Arc>>, + response: Arc>>, } impl AgentServer for ReleaseRequestElicitationServer { @@ -6558,7 +6562,7 @@ pub(crate) mod tests { struct ReleaseRequestElicitationConnection { store: Entity, - response: Arc>>, + response: Arc>>, } impl AgentConnection for ReleaseRequestElicitationConnection { @@ -6580,16 +6584,16 @@ pub(crate) mod tests { self.clone(), project, "ReleaseRequestElicitationConnection", - acp::SessionId::new("release-request-elicitation-session"), + acp_v1::SessionId::new("release-request-elicitation-session"), cx, ); let response_task = self.store.update(cx, |store, cx| { store .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationRequestScope::new(acp::RequestId::Number(1)), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -6610,13 +6614,13 @@ pub(crate) mod tests { Some(self.store.clone()) } - fn auth_methods(&self) -> &[acp::AuthMethod] { + fn auth_methods(&self) -> &[acp_v1::AuthMethod] { &[] } fn authenticate( &self, - _method_id: acp::AuthMethodId, + _method_id: acp_v1::AuthMethodId, _cx: &mut App, ) -> Task> { Task::ready(Ok(())) @@ -6624,13 +6628,13 @@ pub(crate) mod tests { fn prompt( &self, - _params: acp::PromptRequest, + _params: acp_v1::PromptRequest, _cx: &mut App, - ) -> Task> { - Task::ready(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + ) -> Task> { + Task::ready(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) } - fn cancel(&self, _session_id: &acp::SessionId, _cx: &mut App) {} + fn cancel(&self, _session_id: &acp_v1::SessionId, _cx: &mut App) {} fn into_any(self: Rc) -> Rc { self @@ -6659,7 +6663,7 @@ pub(crate) mod tests { self, project, "ResumeOnlyAgentConnection", - acp::SessionId::new("new-session"), + acp_v1::SessionId::new("new-session"), cx, ); Task::ready(Ok(thread)) @@ -6671,7 +6675,7 @@ pub(crate) mod tests { fn resume_session( self: Rc, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, project: Entity, _work_dirs: PathList, _title: Option, @@ -6682,13 +6686,13 @@ pub(crate) mod tests { Task::ready(Ok(thread)) } - fn auth_methods(&self) -> &[acp::AuthMethod] { + fn auth_methods(&self) -> &[acp_v1::AuthMethod] { &[] } fn authenticate( &self, - _method_id: acp::AuthMethodId, + _method_id: acp_v1::AuthMethodId, _cx: &mut App, ) -> Task> { Task::ready(Ok(())) @@ -6696,13 +6700,13 @@ pub(crate) mod tests { fn prompt( &self, - _params: acp::PromptRequest, + _params: acp_v1::PromptRequest, _cx: &mut App, - ) -> Task> { - Task::ready(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + ) -> Task> { + Task::ready(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) } - fn cancel(&self, _session_id: &acp::SessionId, _cx: &mut App) {} + fn cancel(&self, _session_id: &acp_v1::SessionId, _cx: &mut App) {} fn into_any(self: Rc) -> Rc { self @@ -6715,7 +6719,7 @@ pub(crate) mod tests { #[derive(Clone)] struct AuthGatedAgentConnection { authenticated: Arc>, - auth_method: acp::AuthMethod, + auth_method: acp_v1::AuthMethod, } impl AuthGatedAgentConnection { @@ -6724,7 +6728,7 @@ pub(crate) mod tests { fn new() -> Self { Self { authenticated: Arc::new(Mutex::new(false)), - auth_method: acp::AuthMethod::Agent(acp::AuthMethodAgent::new( + auth_method: acp_v1::AuthMethod::Agent(acp_v1::AuthMethodAgent::new( Self::AUTH_METHOD_ID, "Test Login", )), @@ -6753,7 +6757,7 @@ pub(crate) mod tests { .into())); } - let session_id = acp::SessionId::new("auth-gated-session"); + let session_id = acp_v1::SessionId::new("auth-gated-session"); let action_log = cx.new(|_| ActionLog::new(project.clone())); Task::ready(Ok(cx.new(|cx| { AcpThread::new( @@ -6765,7 +6769,7 @@ pub(crate) mod tests { action_log, session_id, watch::Receiver::constant( - acp::PromptCapabilities::new() + acp_v1::PromptCapabilities::new() .image(true) .audio(true) .embedded_context(true), @@ -6775,13 +6779,13 @@ pub(crate) mod tests { }))) } - fn auth_methods(&self) -> &[acp::AuthMethod] { + fn auth_methods(&self) -> &[acp_v1::AuthMethod] { std::slice::from_ref(&self.auth_method) } fn authenticate( &self, - method_id: acp::AuthMethodId, + method_id: acp_v1::AuthMethodId, _cx: &mut App, ) -> Task> { if &method_id == self.auth_method.id() { @@ -6803,13 +6807,13 @@ pub(crate) mod tests { fn prompt( &self, - _params: acp::PromptRequest, + _params: acp_v1::PromptRequest, _cx: &mut App, - ) -> Task> { + ) -> Task> { unimplemented!() } - fn cancel(&self, _session_id: &acp::SessionId, _cx: &mut App) { + fn cancel(&self, _session_id: &acp_v1::SessionId, _cx: &mut App) { unimplemented!() } @@ -6846,9 +6850,9 @@ pub(crate) mod tests { self, project, action_log, - acp::SessionId::new("test"), + acp_v1::SessionId::new("test"), watch::Receiver::constant( - acp::PromptCapabilities::new() + acp_v1::PromptCapabilities::new() .image(true) .audio(true) .embedded_context(true), @@ -6858,13 +6862,13 @@ pub(crate) mod tests { }))) } - fn auth_methods(&self) -> &[acp::AuthMethod] { + fn auth_methods(&self) -> &[acp_v1::AuthMethod] { &[] } fn authenticate( &self, - _method_id: acp::AuthMethodId, + _method_id: acp_v1::AuthMethodId, _cx: &mut App, ) -> Task> { unimplemented!() @@ -6872,13 +6876,13 @@ pub(crate) mod tests { fn prompt( &self, - _params: acp::PromptRequest, + _params: acp_v1::PromptRequest, _cx: &mut App, - ) -> Task> { - Task::ready(Ok(acp::PromptResponse::new(acp::StopReason::Refusal))) + ) -> Task> { + Task::ready(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::Refusal))) } - fn cancel(&self, _session_id: &acp::SessionId, _cx: &mut App) { + fn cancel(&self, _session_id: &acp_v1::SessionId, _cx: &mut App) { unimplemented!() } @@ -6925,9 +6929,9 @@ pub(crate) mod tests { self.clone(), project, action_log, - acp::SessionId::new("new-session"), + acp_v1::SessionId::new("new-session"), watch::Receiver::constant( - acp::PromptCapabilities::new() + acp_v1::PromptCapabilities::new() .image(true) .audio(true) .embedded_context(true), @@ -6944,7 +6948,7 @@ pub(crate) mod tests { fn load_session( self: Rc, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, project: Entity, work_dirs: PathList, _title: Option, @@ -6962,7 +6966,7 @@ pub(crate) mod tests { action_log, session_id, watch::Receiver::constant( - acp::PromptCapabilities::new() + acp_v1::PromptCapabilities::new() .image(true) .audio(true) .embedded_context(true), @@ -6973,13 +6977,13 @@ pub(crate) mod tests { Task::ready(Ok(thread)) } - fn auth_methods(&self) -> &[acp::AuthMethod] { + fn auth_methods(&self) -> &[acp_v1::AuthMethod] { &[] } fn authenticate( &self, - _method_id: acp::AuthMethodId, + _method_id: acp_v1::AuthMethodId, _cx: &mut App, ) -> Task> { Task::ready(Ok(())) @@ -6987,13 +6991,13 @@ pub(crate) mod tests { fn prompt( &self, - _params: acp::PromptRequest, + _params: acp_v1::PromptRequest, _cx: &mut App, - ) -> Task> { - Task::ready(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + ) -> Task> { + Task::ready(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) } - fn cancel(&self, _session_id: &acp::SessionId, _cx: &mut App) {} + fn cancel(&self, _session_id: &acp_v1::SessionId, _cx: &mut App) {} fn into_any(self: Rc) -> Rc { self @@ -7102,12 +7106,13 @@ pub(crate) mod tests { .unwrap(); // First user message - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall( - acp::ToolCall::new("tool1", "Edit file 1") - .kind(acp::ToolKind::Edit) - .status(acp::ToolCallStatus::Completed) - .content(vec![acp::ToolCallContent::Diff( - acp::Diff::new("/project/test1.txt", "new content 1").old_text("old content 1"), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new("tool1", "Edit file 1") + .kind(acp_v1::ToolKind::Edit) + .status(acp_v1::ToolCallStatus::Completed) + .content(vec![acp_v1::ToolCallContent::Diff( + acp_v1::Diff::new("/project/test1.txt", "new content 1") + .old_text("old content 1"), )]), )]); @@ -7139,12 +7144,13 @@ pub(crate) mod tests { }); // Second user message - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall( - acp::ToolCall::new("tool2", "Edit file 2") - .kind(acp::ToolKind::Edit) - .status(acp::ToolCallStatus::Completed) - .content(vec![acp::ToolCallContent::Diff( - acp::Diff::new("/project/test2.txt", "new content 2").old_text("old content 2"), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new("tool2", "Edit file 2") + .kind(acp_v1::ToolKind::Edit) + .status(acp_v1::ToolCallStatus::Completed) + .content(vec![acp_v1::ToolCallContent::Diff( + acp_v1::Diff::new("/project/test2.txt", "new content 2") + .old_text("old content 2"), )]), )]); @@ -7277,11 +7283,11 @@ pub(crate) mod tests { // First turn: a subagent tool call. Subagent edits never appear as // diffs in the parent thread's entries; they are only forwarded to the // parent's action log through the linked-log mechanism. - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall( - acp::ToolCall::new("spawn1", "Subagent task") + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new("spawn1", "Subagent task") .name("spawn_agent") - .kind(acp::ToolKind::Other) - .status(acp::ToolCallStatus::Completed), + .kind(acp_v1::ToolKind::Other) + .status(acp_v1::ToolCallStatus::Completed), )]); thread @@ -7325,8 +7331,8 @@ pub(crate) mod tests { }); // Second turn: a plain follow-up. - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("Response".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("Response".into()), )]); thread .update(cx, |thread, cx| thread.send_raw("Follow-up", cx)) @@ -7359,8 +7365,8 @@ pub(crate) mod tests { editor.set_text("Edited follow-up", window, cx); }); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("New response".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("New response".into()), )]); active_thread(&conversation_view, cx).update_in(cx, |view, window, cx| { view.regenerate(follow_up_ix, user_message_editor.clone(), window, cx); @@ -7402,8 +7408,8 @@ pub(crate) mod tests { let connection = StubAgentConnection::new(); // Each user prompt will result in a user message entry plus an agent message entry. - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("Response 1".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("Response 1".into()), )]); let (conversation_view, cx) = @@ -7421,8 +7427,8 @@ pub(crate) mod tests { .unwrap(); cx.run_until_parked(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("Response 2".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("Response 2".into()), )]); thread @@ -7477,8 +7483,8 @@ pub(crate) mod tests { init_test(cx); let connection = StubAgentConnection::new(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new( + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new( "Yes, you can substitute banana for plantain in this recipe.".into(), ), )]); @@ -7497,8 +7503,8 @@ pub(crate) mod tests { .unwrap(); cx.run_until_parked(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new( + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new( "Banana yogurt also works as a topping; whisk the banana smooth first.".into(), ), )]); @@ -7576,13 +7582,13 @@ pub(crate) mod tests { let connection = StubAgentConnection::new(); connection.set_next_prompt_updates(vec![ - acp::SessionUpdate::AgentThoughtChunk(acp::ContentChunk::new( + acp_v1::SessionUpdate::AgentThoughtChunk(acp_v1::ContentChunk::new( "Hidden papaya reasoning.".into(), )), - acp::SessionUpdate::AgentThoughtChunk(acp::ContentChunk::new( - acp::ContentBlock::Resource(acp::EmbeddedResource::new( - acp::EmbeddedResourceResource::TextResourceContents( - acp::TextResourceContents::new( + acp_v1::SessionUpdate::AgentThoughtChunk(acp_v1::ContentChunk::new( + acp_v1::ContentBlock::Resource(acp_v1::EmbeddedResource::new( + acp_v1::EmbeddedResourceResource::TextResourceContents( + acp_v1::TextResourceContents::new( "A second hidden papaya.", "thought://details", ) @@ -7590,7 +7596,7 @@ pub(crate) mod tests { ), )), )), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new( + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new( "Final answer without that fruit.".into(), )), ]); @@ -7666,8 +7672,8 @@ pub(crate) mod tests { init_test(cx); let connection = StubAgentConnection::new(); connection.set_next_prompt_updates(vec![ - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new("".into())), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new(png_image())), + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new("".into())), + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new(png_image())), ]); let (_conversation_view, cx) = setup_full_size_conversation_and_send(connection, "Show an image", cx).await; @@ -7686,9 +7692,9 @@ pub(crate) mod tests { init_test(cx); let image = png_image(); - let resource = acp::ContentBlock::Resource(acp::EmbeddedResource::new( - acp::EmbeddedResourceResource::TextResourceContents( - acp::TextResourceContents::new( + let resource = acp_v1::ContentBlock::Resource(acp_v1::EmbeddedResource::new( + acp_v1::EmbeddedResourceResource::TextResourceContents( + acp_v1::TextResourceContents::new( "Resource needle follows the image.", "memory://ordered", ) @@ -7697,14 +7703,18 @@ pub(crate) mod tests { )); let connection = StubAgentConnection::new(); connection.set_next_prompt_updates(vec![ - acp::SessionUpdate::AgentThoughtChunk(acp::ContentChunk::new( + acp_v1::SessionUpdate::AgentThoughtChunk(acp_v1::ContentChunk::new( "Private needle must not be copied.".into(), )), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new("Before needle.".into())), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new(image.clone())), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new("After needle.".into())), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new(image)), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new(resource)), + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new( + "Before needle.".into(), + )), + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new(image.clone())), + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new( + "After needle.".into(), + )), + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new(image)), + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new(resource)), ]); let (conversation_view, cx) = @@ -7810,7 +7820,7 @@ pub(crate) mod tests { #[gpui::test] async fn test_message_context_menu_uses_clicked_content(cx: &mut TestAppContext) { init_test(cx); - let acp::ContentBlock::Image(image) = png_image() else { + let acp_v1::ContentBlock::Image(image) = png_image() else { panic!("expected image fixture"); }; let linked_image = format!( @@ -7819,11 +7829,13 @@ pub(crate) mod tests { ); let connection = StubAgentConnection::new(); connection.set_next_prompt_updates(vec![ - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new( + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new( "[first](https://one.example/)".into(), )), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new(png_image())), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new(linked_image.into())), + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new(png_image())), + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new( + linked_image.into(), + )), ]); let (conversation_view, cx) = setup_conversation_view(StubAgentServer::new(connection), cx).await; @@ -7891,9 +7903,9 @@ pub(crate) mod tests { init_test(cx); let connection = StubAgentConnection::new(); connection.set_next_prompt_updates(vec![ - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new("**first**".into())), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new(png_image())), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new("*second*".into())), + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new("**first**".into())), + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new(png_image())), + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new("*second*".into())), ]); let (conversation_view, cx) = setup_conversation_view(StubAgentServer::new(connection), cx).await; @@ -7951,12 +7963,12 @@ pub(crate) mod tests { async fn test_thread_search_includes_expanded_tool_call_content(cx: &mut TestAppContext) { init_test(cx); - let tool_call_id = acp::ToolCallId::new("search-tool-content"); + let tool_call_id = acp_v1::ToolCallId::new("search-tool-content"); let connection = StubAgentConnection::new(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall( - acp::ToolCall::new(tool_call_id.clone(), "Inspect output") - .kind(acp::ToolKind::Other) - .status(acp::ToolCallStatus::Completed) + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new(tool_call_id.clone(), "Inspect output") + .kind(acp_v1::ToolKind::Other) + .status(acp_v1::ToolCallStatus::Completed) .content(vec!["Tool output mentions papaya once.".into()]), )]); @@ -8012,18 +8024,18 @@ pub(crate) mod tests { thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate::new( + acp_v1::SessionUpdate::ToolCallUpdate(acp_v1::ToolCallUpdate::new( "search-tool-content", - acp::ToolCallUpdateFields::new().content(vec![ - acp::ToolCallContent::Content(acp::Content::new( - acp::ContentBlock::Text(acp::TextContent::new( + acp_v1::ToolCallUpdateFields::new().content(vec![ + acp_v1::ToolCallContent::Content(acp_v1::Content::new( + acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "Replacement contains mango.", )), )), - acp::ToolCallContent::Content(acp::Content::new( - acp::ContentBlock::Resource(acp::EmbeddedResource::new( - acp::EmbeddedResourceResource::TextResourceContents( - acp::TextResourceContents::new( + acp_v1::ToolCallContent::Content(acp_v1::Content::new( + acp_v1::ContentBlock::Resource(acp_v1::EmbeddedResource::new( + acp_v1::EmbeddedResourceResource::TextResourceContents( + acp_v1::TextResourceContents::new( "Resource mango output.", "tool://replacement", ) @@ -8066,8 +8078,8 @@ pub(crate) mod tests { init_test(cx); let connection = StubAgentConnection::new(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("First reply, no fruit here.".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("First reply, no fruit here.".into()), )]); let (conversation_view, cx) = @@ -8081,8 +8093,8 @@ pub(crate) mod tests { .await .unwrap(); cx.run_until_parked(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("Second reply, still no fruit.".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("Second reply, still no fruit.".into()), )]); thread .update(cx, |thread, cx| thread.send_raw("Where is the papaya?", cx)) @@ -8138,8 +8150,8 @@ pub(crate) mod tests { init_test(cx); let connection = StubAgentConnection::new(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("First reply, no fruit here.".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("First reply, no fruit here.".into()), )]); let (conversation_view, cx) = @@ -8153,8 +8165,8 @@ pub(crate) mod tests { .await .unwrap(); cx.run_until_parked(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("Second reply, still no fruit.".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("Second reply, still no fruit.".into()), )]); thread .update(cx, |thread, cx| thread.send_raw("Where is the papaya?", cx)) @@ -8221,8 +8233,8 @@ pub(crate) mod tests { init_test(cx); let connection = StubAgentConnection::new(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("Mango is a tropical fruit.".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("Mango is a tropical fruit.".into()), )]); let (conversation_view, cx) = @@ -8271,8 +8283,8 @@ pub(crate) mod tests { init_test(cx); let connection = StubAgentConnection::new(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("Mango is a tropical fruit.".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("Mango is a tropical fruit.".into()), )]); let (conversation_view, cx) = @@ -8358,30 +8370,30 @@ pub(crate) mod tests { .read_with(cx, |view, _| view.thread_search_bar.clone()) .expect("thread search bar should be open"); let resource = - acp::EmbeddedResource::new(acp::EmbeddedResourceResource::TextResourceContents( - acp::TextResourceContents::new("retained resource details", "summary://context") + acp_v1::EmbeddedResource::new(acp_v1::EmbeddedResourceResource::TextResourceContents( + acp_v1::TextResourceContents::new("retained resource details", "summary://context") .mime_type("text/markdown".to_string()), )); for (update, query) in [ ( - acp::CompactionUpdate::new("failed", acp::CompactionStatus::Failed) + acp_v1::CompactionUpdate::new("failed", acp_v1::CompactionStatus::Failed) .error("model *still* unavailable
"), "model *still* unavailable
", ), ( - acp::CompactionUpdate::new("completed", acp::CompactionStatus::Completed).summary( - vec![ - acp::ContentBlock::Text(acp::TextContent::new("Retained summary")), - acp::ContentBlock::Resource(resource), - ], - ), + acp_v1::CompactionUpdate::new("completed", acp_v1::CompactionStatus::Completed) + .summary(vec![ + acp_v1::ContentBlock::Text(acp_v1::TextContent::new("Retained summary")), + acp_v1::ContentBlock::Resource(resource), + ]), "retained resource details", ), ] { thread .update(cx, |thread, cx| { - thread.handle_session_update(acp::SessionUpdate::CompactionUpdate(update), cx) + thread + .handle_session_update(acp_v1::SessionUpdate::CompactionUpdate(update), cx) }) .expect("failed to receive compaction details"); cx.run_until_parked(); @@ -8461,24 +8473,24 @@ pub(crate) mod tests { for (update, expected_count) in [ ( - acp::SessionUpdate::ToolCall( - acp::ToolCall::new("tool", "") + acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new("tool", "") .name("mcp__search_tool") - .status(acp::ToolCallStatus::Completed), + .status(acp_v1::ToolCallStatus::Completed), ), 1, ), ( - acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate::new( + acp_v1::SessionUpdate::ToolCallUpdate(acp_v1::ToolCallUpdate::new( "tool", - acp::ToolCallUpdateFields::new().title("Reading **file**"), + acp_v1::ToolCallUpdateFields::new().title("Reading **file**"), )), 0, ), ( - acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate::new( + acp_v1::SessionUpdate::ToolCallUpdate(acp_v1::ToolCallUpdate::new( "tool", - acp::ToolCallUpdateFields::new().title("\n\t "), + acp_v1::ToolCallUpdateFields::new().title("\n\t "), )), 1, ), @@ -8496,7 +8508,7 @@ pub(crate) mod tests { ); thread.read_with(cx, |thread, cx| { let (_, call) = thread - .tool_call(&acp::ToolCallId::new("tool")) + .tool_call(&acp_v1::ToolCallId::new("tool")) .expect("tool call should exist"); assert_eq!( !call.label.read(cx).search_highlights().is_empty(), @@ -8511,8 +8523,8 @@ pub(crate) mod tests { init_test(cx); let connection = StubAgentConnection::new(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("First reply mentions banana once.".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("First reply mentions banana once.".into()), )]); let (conversation_view, cx) = @@ -8560,8 +8572,8 @@ pub(crate) mod tests { ); // Advance past the debounced thread-update rescan. - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("Banana banana: two more banana hits here.".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("Banana banana: two more banana hits here.".into()), )]); thread .update(cx, |thread, cx| thread.send_raw("More banana please", cx)) @@ -8594,8 +8606,8 @@ pub(crate) mod tests { init_test(cx); let connection = StubAgentConnection::new(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new( + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new( "Banana banana banana, the banana fits the banana bread.".into(), ), )]); @@ -8660,8 +8672,8 @@ pub(crate) mod tests { init_test(cx); let connection = StubAgentConnection::new(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("Sure, I can help with that.".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("Sure, I can help with that.".into()), )]); let (conversation_view, cx) = @@ -8802,8 +8814,8 @@ pub(crate) mod tests { }); let connection = StubAgentConnection::new(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new( + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new( "Banana banana banana, multiple banana mentions in this reply.".into(), ), )]); @@ -8902,8 +8914,8 @@ pub(crate) mod tests { }); let connection = StubAgentConnection::new(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new( + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new( "Banana banana banana, multiple banana mentions in this reply.".into(), ), )]); @@ -8984,8 +8996,8 @@ pub(crate) mod tests { let connection = StubAgentConnection::new(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("Response".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("Response".into()), )]); let (conversation_view, cx) = @@ -9097,8 +9109,8 @@ pub(crate) mod tests { let connection = StubAgentConnection::new(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("Response".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("Response".into()), )]); let (conversation_view, cx) = @@ -9152,8 +9164,8 @@ pub(crate) mod tests { }); // Send - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("New Response".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("New Response".into()), )]); user_message_editor.update_in(cx, |_editor, window, cx| { @@ -9265,10 +9277,12 @@ pub(crate) mod tests { cx.update(|_, cx| { connection.send_update( session_id.clone(), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new("Response".into())), + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new( + "Response".into(), + )), cx, ); - connection.end_turn(session_id, acp::StopReason::EndTurn); + connection.end_turn(session_id, acp_v1::StopReason::EndTurn); }); conversation_view.read_with(cx, |view, cx| { @@ -9393,7 +9407,7 @@ pub(crate) mod tests { cx.update(|_, cx| { connection.send_update( session_id.clone(), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new( + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new( "Response chunk".into(), )), cx, @@ -9524,7 +9538,7 @@ pub(crate) mod tests { cx.update(|_, cx| { connection.send_update( session_id.clone(), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new( + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new( "Message 1 resp".into(), )), cx, @@ -9559,7 +9573,7 @@ pub(crate) mod tests { // Simulate a response sent after beginning to cancel connection.send_update( session_id.clone(), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new("onse".into())), + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new("onse".into())), cx, ); }); @@ -9590,12 +9604,12 @@ pub(crate) mod tests { cx.update(|_, cx| { connection.send_update( session_id.clone(), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new( + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new( "Message 2 response".into(), )), cx, ); - connection.end_turn(session_id.clone(), acp::StopReason::EndTurn); + connection.end_turn(session_id.clone(), acp_v1::StopReason::EndTurn); }); cx.run_until_parked(); @@ -9630,8 +9644,8 @@ pub(crate) mod tests { init_test(cx); let connection = StubAgentConnection::new(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("Response".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("Response".into()), )]); let (conversation_view, cx) = @@ -9732,8 +9746,8 @@ pub(crate) mod tests { init_test(cx); let connection = StubAgentConnection::new(); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk::new("Response".into()), + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::AgentMessageChunk( + acp_v1::ContentChunk::new("Response".into()), )]); let (conversation_view, cx) = @@ -9804,15 +9818,15 @@ pub(crate) mod tests { init_test(cx); for (exit_status, failure_selector) in [ ( - acp::TerminalExitStatus::new().exit_code(7), + acp_v1::TerminalExitStatus::new().exit_code(7), "terminal-tool-failed-Some(7)", ), ( - acp::TerminalExitStatus::new().signal("SIGTERM"), + acp_v1::TerminalExitStatus::new().signal("SIGTERM"), "terminal-tool-failed-None", ), ( - acp::TerminalExitStatus::new().exit_code(u32::MAX), + acp_v1::TerminalExitStatus::new().exit_code(u32::MAX), "terminal-tool-failed-Some(4294967295)", ), ] { @@ -9821,8 +9835,8 @@ pub(crate) mod tests { add_to_workspace_with_size(conversation_view.clone(), true, cx); let thread_view = active_thread(&conversation_view, cx); let thread = thread_view.read_with(cx, |view, _| view.thread.clone()); - let terminal_id = acp::TerminalId::new("provider-terminal"); - let tool_id = acp::ToolCallId::new("provider-tool"); + let terminal_id = acp_v1::TerminalId::new("provider-terminal"); + let tool_id = acp_v1::ToolCallId::new("provider-tool"); let terminal = cx.new(|cx| { terminal::TerminalBuilder::new_display_only( Default::default(), @@ -9848,13 +9862,13 @@ pub(crate) mod tests { ); thread .handle_session_update( - acp::SessionUpdate::ToolCall( - acp::ToolCall::new(tool_id.clone(), "provider command") - .kind(acp::ToolKind::Execute) - .status(acp::ToolCallStatus::InProgress) - .content(vec![acp::ToolCallContent::Terminal(acp::Terminal::new( - terminal_id.clone(), - ))]), + acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new(tool_id.clone(), "provider command") + .kind(acp_v1::ToolKind::Execute) + .status(acp_v1::ToolCallStatus::InProgress) + .content(vec![acp_v1::ToolCallContent::Terminal( + acp_v1::Terminal::new(terminal_id.clone()), + )]), ), cx, ) @@ -9913,9 +9927,10 @@ pub(crate) mod tests { thread.update(cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate::new( + acp_v1::SessionUpdate::ToolCallUpdate(acp_v1::ToolCallUpdate::new( tool_id.clone(), - acp::ToolCallUpdateFields::new().status(acp::ToolCallStatus::Completed), + acp_v1::ToolCallUpdateFields::new() + .status(acp_v1::ToolCallStatus::Completed), )), cx, ) @@ -9951,8 +9966,8 @@ pub(crate) mod tests { add_to_workspace_with_size(conversation_view.clone(), true, cx); let thread_view = active_thread(&conversation_view, cx); let thread = thread_view.read_with(cx, |view, _| view.thread.clone()); - let terminal_id = acp::TerminalId::new("acp-owned-terminal"); - let tool_id = acp::ToolCallId::new("acp-owned-tool"); + let terminal_id = acp_v1::TerminalId::new("acp-owned-terminal"); + let tool_id = acp_v1::ToolCallId::new("acp-owned-tool"); let lower_terminal = cx.new(|cx| { terminal::TerminalBuilder::new_display_only( Default::default(), @@ -9977,13 +9992,13 @@ pub(crate) mod tests { ); thread .handle_session_update( - acp::SessionUpdate::ToolCall( - acp::ToolCall::new(tool_id.clone(), "client-owned command") - .kind(acp::ToolKind::Execute) - .status(acp::ToolCallStatus::InProgress) - .content(vec![acp::ToolCallContent::Terminal(acp::Terminal::new( - terminal_id, - ))]), + acp_v1::SessionUpdate::ToolCall( + acp_v1::ToolCall::new(tool_id.clone(), "client-owned command") + .kind(acp_v1::ToolKind::Execute) + .status(acp_v1::ToolCallStatus::InProgress) + .content(vec![acp_v1::ToolCallContent::Terminal( + acp_v1::Terminal::new(terminal_id), + )]), ), cx, ) @@ -10026,9 +10041,9 @@ pub(crate) mod tests { async fn test_tool_permission_buttons_terminal_with_pattern(cx: &mut TestAppContext) { init_test(cx); - let tool_call_id = acp::ToolCallId::new("terminal-1"); - let tool_call = acp::ToolCall::new(tool_call_id.clone(), "Run `cargo build --release`") - .kind(acp::ToolKind::Edit); + let tool_call_id = acp_v1::ToolCallId::new("terminal-1"); + let tool_call = acp_v1::ToolCall::new(tool_call_id.clone(), "Run `cargo build --release`") + .kind(acp_v1::ToolKind::Edit); let permission_options = ToolPermissionContext::new( TerminalTool::NAME, @@ -10042,7 +10057,7 @@ pub(crate) mod tests { permission_options, )])); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall(tool_call)]); + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::ToolCall(tool_call)]); let (conversation_view, cx) = setup_conversation_view(StubAgentServer::new(connection), cx).await; @@ -10138,9 +10153,9 @@ pub(crate) mod tests { async fn test_tool_permission_buttons_edit_file_with_path_pattern(cx: &mut TestAppContext) { init_test(cx); - let tool_call_id = acp::ToolCallId::new("edit-file-1"); - let tool_call = acp::ToolCall::new(tool_call_id.clone(), "Edit `src/main.rs`") - .kind(acp::ToolKind::Edit); + let tool_call_id = acp_v1::ToolCallId::new("edit-file-1"); + let tool_call = acp_v1::ToolCall::new(tool_call_id.clone(), "Edit `src/main.rs`") + .kind(acp_v1::ToolKind::Edit); let permission_options = ToolPermissionContext::new(EditFileTool::NAME, vec!["src/main.rs".to_string()]) @@ -10152,7 +10167,7 @@ pub(crate) mod tests { permission_options, )])); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall(tool_call)]); + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::ToolCall(tool_call)]); let (conversation_view, cx) = setup_conversation_view(StubAgentServer::new(connection), cx).await; @@ -10228,9 +10243,9 @@ pub(crate) mod tests { async fn test_tool_permission_buttons_fetch_with_domain_pattern(cx: &mut TestAppContext) { init_test(cx); - let tool_call_id = acp::ToolCallId::new("fetch-1"); - let tool_call = acp::ToolCall::new(tool_call_id.clone(), "Fetch `https://docs.rs/gpui`") - .kind(acp::ToolKind::Fetch); + let tool_call_id = acp_v1::ToolCallId::new("fetch-1"); + let tool_call = acp_v1::ToolCall::new(tool_call_id.clone(), "Fetch `https://docs.rs/gpui`") + .kind(acp_v1::ToolKind::Fetch); let permission_options = ToolPermissionContext::new(FetchTool::NAME, vec!["https://docs.rs/gpui".to_string()]) @@ -10242,7 +10257,7 @@ pub(crate) mod tests { permission_options, )])); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall(tool_call)]); + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::ToolCall(tool_call)]); let (conversation_view, cx) = setup_conversation_view(StubAgentServer::new(connection), cx).await; @@ -10318,9 +10333,10 @@ pub(crate) mod tests { async fn test_tool_permission_buttons_without_pattern(cx: &mut TestAppContext) { init_test(cx); - let tool_call_id = acp::ToolCallId::new("terminal-no-pattern-1"); - let tool_call = acp::ToolCall::new(tool_call_id.clone(), "Run `./deploy.sh --production`") - .kind(acp::ToolKind::Edit); + let tool_call_id = acp_v1::ToolCallId::new("terminal-no-pattern-1"); + let tool_call = + acp_v1::ToolCall::new(tool_call_id.clone(), "Run `./deploy.sh --production`") + .kind(acp_v1::ToolKind::Edit); // No pattern button since ./deploy.sh doesn't match the alphanumeric pattern let permission_options = ToolPermissionContext::new( @@ -10335,7 +10351,7 @@ pub(crate) mod tests { permission_options, )])); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall(tool_call)]); + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::ToolCall(tool_call)]); let (conversation_view, cx) = setup_conversation_view(StubAgentServer::new(connection), cx).await; @@ -10422,9 +10438,9 @@ pub(crate) mod tests { async fn test_authorize_tool_call_action_triggers_authorization(cx: &mut TestAppContext) { init_test(cx); - let tool_call_id = acp::ToolCallId::new("action-test-1"); - let tool_call = - acp::ToolCall::new(tool_call_id.clone(), "Run `cargo test`").kind(acp::ToolKind::Edit); + let tool_call_id = acp_v1::ToolCallId::new("action-test-1"); + let tool_call = acp_v1::ToolCall::new(tool_call_id.clone(), "Run `cargo test`") + .kind(acp_v1::ToolKind::Edit); let permission_options = ToolPermissionContext::new(TerminalTool::NAME, vec!["cargo test".to_string()]) @@ -10436,7 +10452,7 @@ pub(crate) mod tests { permission_options, )])); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall(tool_call)]); + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::ToolCall(tool_call)]); let (conversation_view, cx) = setup_conversation_view(StubAgentServer::new(connection), cx).await; @@ -10500,9 +10516,9 @@ pub(crate) mod tests { async fn test_authorize_tool_call_action_with_pattern_option(cx: &mut TestAppContext) { init_test(cx); - let tool_call_id = acp::ToolCallId::new("pattern-action-test-1"); - let tool_call = - acp::ToolCall::new(tool_call_id.clone(), "Run `npm install`").kind(acp::ToolKind::Edit); + let tool_call_id = acp_v1::ToolCallId::new("pattern-action-test-1"); + let tool_call = acp_v1::ToolCall::new(tool_call_id.clone(), "Run `npm install`") + .kind(acp_v1::ToolKind::Edit); let permission_options = ToolPermissionContext::new(TerminalTool::NAME, vec!["npm install".to_string()]) @@ -10514,7 +10530,7 @@ pub(crate) mod tests { permission_options.clone(), )])); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall(tool_call)]); + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::ToolCall(tool_call)]); let (conversation_view, cx) = setup_conversation_view(StubAgentServer::new(connection), cx).await; @@ -10579,9 +10595,9 @@ pub(crate) mod tests { async fn test_granularity_selection_updates_state(cx: &mut TestAppContext) { init_test(cx); - let tool_call_id = acp::ToolCallId::new("granularity-test-1"); - let tool_call = - acp::ToolCall::new(tool_call_id.clone(), "Run `cargo build`").kind(acp::ToolKind::Edit); + let tool_call_id = acp_v1::ToolCallId::new("granularity-test-1"); + let tool_call = acp_v1::ToolCall::new(tool_call_id.clone(), "Run `cargo build`") + .kind(acp_v1::ToolKind::Edit); let permission_options = ToolPermissionContext::new(TerminalTool::NAME, vec!["cargo build".to_string()]) @@ -10593,7 +10609,7 @@ pub(crate) mod tests { permission_options.clone(), )])); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall(tool_call)]); + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::ToolCall(tool_call)]); let (thread_view, cx) = setup_conversation_view(StubAgentServer::new(connection), cx).await; add_to_workspace(thread_view.clone(), cx); @@ -10657,9 +10673,9 @@ pub(crate) mod tests { async fn test_allow_button_uses_selected_granularity(cx: &mut TestAppContext) { init_test(cx); - let tool_call_id = acp::ToolCallId::new("allow-granularity-test-1"); - let tool_call = - acp::ToolCall::new(tool_call_id.clone(), "Run `npm install`").kind(acp::ToolKind::Edit); + let tool_call_id = acp_v1::ToolCallId::new("allow-granularity-test-1"); + let tool_call = acp_v1::ToolCall::new(tool_call_id.clone(), "Run `npm install`") + .kind(acp_v1::ToolKind::Edit); let permission_options = ToolPermissionContext::new(TerminalTool::NAME, vec!["npm install".to_string()]) @@ -10694,7 +10710,7 @@ pub(crate) mod tests { permission_options.clone(), )])); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall(tool_call)]); + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::ToolCall(tool_call)]); let (thread_view, cx) = setup_conversation_view(StubAgentServer::new(connection), cx).await; add_to_workspace(thread_view.clone(), cx); @@ -10754,9 +10770,9 @@ pub(crate) mod tests { async fn test_deny_button_uses_selected_granularity(cx: &mut TestAppContext) { init_test(cx); - let tool_call_id = acp::ToolCallId::new("deny-granularity-test-1"); - let tool_call = - acp::ToolCall::new(tool_call_id.clone(), "Run `git push`").kind(acp::ToolKind::Edit); + let tool_call_id = acp_v1::ToolCallId::new("deny-granularity-test-1"); + let tool_call = acp_v1::ToolCall::new(tool_call_id.clone(), "Run `git push`") + .kind(acp_v1::ToolKind::Edit); let permission_options = ToolPermissionContext::new(TerminalTool::NAME, vec!["git push".to_string()]) @@ -10768,7 +10784,7 @@ pub(crate) mod tests { permission_options.clone(), )])); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall(tool_call)]); + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::ToolCall(tool_call)]); let (conversation_view, cx) = setup_conversation_view(StubAgentServer::new(connection), cx).await; @@ -10870,40 +10886,40 @@ pub(crate) mod tests { fn flat_allow_deny_options() -> PermissionOptions { PermissionOptions::Flat(vec![ - acp::PermissionOption::new( - acp::PermissionOptionId::new("allow"), + acp_v1::PermissionOption::new( + acp_v1::PermissionOptionId::new("allow"), "Yes", - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionKind::AllowOnce, ), - acp::PermissionOption::new( - acp::PermissionOptionId::new("deny"), + acp_v1::PermissionOption::new( + acp_v1::PermissionOptionId::new("deny"), "No", - acp::PermissionOptionKind::RejectOnce, + acp_v1::PermissionOptionKind::RejectOnce, ), ]) } fn sandbox_permission_options() -> PermissionOptions { PermissionOptions::Flat(vec![ - acp::PermissionOption::new( - acp::PermissionOptionId::new("allow"), + acp_v1::PermissionOption::new( + acp_v1::PermissionOptionId::new("allow"), "Allow once", - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionKind::AllowOnce, ), - acp::PermissionOption::new( - acp::PermissionOptionId::new("allow_thread"), + acp_v1::PermissionOption::new( + acp_v1::PermissionOptionId::new("allow_thread"), "Allow for this thread", - acp::PermissionOptionKind::AllowAlways, + acp_v1::PermissionOptionKind::AllowAlways, ), - acp::PermissionOption::new( - acp::PermissionOptionId::new("allow_always"), + acp_v1::PermissionOption::new( + acp_v1::PermissionOptionId::new("allow_always"), "Allow always", - acp::PermissionOptionKind::AllowAlways, + acp_v1::PermissionOptionKind::AllowAlways, ), - acp::PermissionOption::new( - acp::PermissionOptionId::new("deny"), + acp_v1::PermissionOption::new( + acp_v1::PermissionOptionId::new("deny"), "Deny", - acp::PermissionOptionKind::RejectOnce, + acp_v1::PermissionOptionKind::RejectOnce, ), ]) } @@ -10912,9 +10928,11 @@ pub(crate) mod tests { fn permission_option_for_action_prefers_explicit_sandbox_allow_always() { let options = sandbox_permission_options(); - let option = - super::permission_option_for_action(&options, acp::PermissionOptionKind::AllowAlways) - .unwrap(); + let option = super::permission_option_for_action( + &options, + acp_v1::PermissionOptionKind::AllowAlways, + ) + .unwrap(); assert_eq!(option.option_id.0.as_ref(), "allow_always"); } @@ -10926,7 +10944,7 @@ pub(crate) mod tests { let outcome = super::resolve_outcome_from_selection(&options, None, true).unwrap(); assert_eq!(outcome.option_id.0.as_ref(), "allow"); - assert_eq!(outcome.option_kind, acp::PermissionOptionKind::AllowOnce); + assert_eq!(outcome.option_kind, acp_v1::PermissionOptionKind::AllowOnce); } #[test] @@ -10936,7 +10954,10 @@ pub(crate) mod tests { let outcome = super::resolve_outcome_from_selection(&options, None, false).unwrap(); assert_eq!(outcome.option_id.0.as_ref(), "deny"); - assert_eq!(outcome.option_kind, acp::PermissionOptionKind::RejectOnce); + assert_eq!( + outcome.option_kind, + acp_v1::PermissionOptionKind::RejectOnce + ); } #[test] @@ -10961,7 +10982,7 @@ pub(crate) mod tests { // Last choice is "Only this time" → option_id "allow". assert_eq!(outcome.option_id.0.as_ref(), "allow"); - assert_eq!(outcome.option_kind, acp::PermissionOptionKind::AllowOnce); + assert_eq!(outcome.option_kind, acp_v1::PermissionOptionKind::AllowOnce); } #[test] @@ -10976,7 +10997,10 @@ pub(crate) mod tests { // Choice 0 = "Always for terminal". assert!(outcome.option_id.0.contains("always_allow:terminal")); - assert_eq!(outcome.option_kind, acp::PermissionOptionKind::AllowAlways); + assert_eq!( + outcome.option_kind, + acp_v1::PermissionOptionKind::AllowAlways + ); } #[test] @@ -11015,7 +11039,7 @@ pub(crate) mod tests { super::resolve_outcome_from_selection(&options, Some(&selection), true).unwrap(); assert_eq!(outcome.option_id.0.as_ref(), "allow"); - assert_eq!(outcome.option_kind, acp::PermissionOptionKind::AllowOnce); + assert_eq!(outcome.option_kind, acp_v1::PermissionOptionKind::AllowOnce); } #[test] @@ -11034,7 +11058,10 @@ pub(crate) mod tests { let outcome = super::resolve_outcome_from_selection(&options, Some(&selection), true).unwrap(); - assert_eq!(outcome.option_kind, acp::PermissionOptionKind::AllowAlways); + assert_eq!( + outcome.option_kind, + acp_v1::PermissionOptionKind::AllowAlways + ); assert!( outcome.params.is_some(), "checked patterns should attach terminal params" @@ -11102,7 +11129,7 @@ pub(crate) mod tests { cx.run_until_parked(); cx.update(|_, _cx| { - connection.end_turn(session_id, acp::StopReason::MaxTokens); + connection.end_turn(session_id, acp_v1::StopReason::MaxTokens); }); cx.run_until_parked(); @@ -11119,7 +11146,7 @@ pub(crate) mod tests { } fn create_test_acp_thread( - parent_session_id: Option, + parent_session_id: Option, session_id: &str, connection: Rc, project: Entity, @@ -11134,8 +11161,8 @@ pub(crate) mod tests { connection, project, action_log, - acp::SessionId::new(session_id), - watch::Receiver::constant(acp::PromptCapabilities::new()), + acp_v1::SessionId::new(session_id), + watch::Receiver::constant(acp_v1::PromptCapabilities::new()), cx, ) }) @@ -11147,20 +11174,20 @@ pub(crate) mod tests { option_id: &str, cx: &mut TestAppContext, ) -> Task { - let tool_call_id = acp::ToolCallId::new(tool_call_id); + let tool_call_id = acp_v1::ToolCallId::new(tool_call_id); let label = format!("Tool {tool_call_id}"); - let option_id = acp::PermissionOptionId::new(option_id); + let option_id = acp_v1::PermissionOptionId::new(option_id); cx.update(|cx| { thread.update(cx, |thread, cx| { thread .request_tool_call_authorization( - acp::ToolCall::new(tool_call_id, label) - .kind(acp::ToolKind::Edit) + acp_v1::ToolCall::new(tool_call_id, label) + .kind(acp_v1::ToolKind::Edit) .into(), - PermissionOptions::Flat(vec![acp::PermissionOption::new( + PermissionOptions::Flat(vec![acp_v1::PermissionOption::new( option_id, "Allow", - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionKind::AllowOnce, )]), acp_thread::AuthorizationKind::PermissionGrant, cx, @@ -11178,7 +11205,7 @@ pub(crate) mod tests { let project = Project::test(fs, [], cx).await; let connection: Rc = Rc::new(StubAgentConnection::new()); - let session_id = acp::SessionId::new("session-1"); + let session_id = acp_v1::SessionId::new("session-1"); let (thread, conversation) = cx.update(|cx| { let thread = create_test_acp_thread(None, "session-1", connection.clone(), project.clone(), cx); @@ -11198,17 +11225,17 @@ pub(crate) mod tests { .read(cx) .pending_tool_call(&session_id, cx) .expect("Expected a pending tool call"); - assert_eq!(tool_call_id, acp::ToolCallId::new("tc-1")); + assert_eq!(tool_call_id, acp_v1::ToolCallId::new("tc-1")); }); cx.update(|cx| { conversation.update(cx, |conversation, cx| { conversation.authorize_tool_call( session_id.clone(), - acp::ToolCallId::new("tc-1"), + acp_v1::ToolCallId::new("tc-1"), SelectedPermissionOutcome::new( - acp::PermissionOptionId::new("allow-1"), - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionId::new("allow-1"), + acp_v1::PermissionOptionKind::AllowOnce, ), cx, ); @@ -11222,17 +11249,17 @@ pub(crate) mod tests { .read(cx) .pending_tool_call(&session_id, cx) .expect("Expected tc-2 to be pending after tc-1 was authorized"); - assert_eq!(tool_call_id, acp::ToolCallId::new("tc-2")); + assert_eq!(tool_call_id, acp_v1::ToolCallId::new("tc-2")); }); cx.update(|cx| { conversation.update(cx, |conversation, cx| { conversation.authorize_tool_call( session_id.clone(), - acp::ToolCallId::new("tc-2"), + acp_v1::ToolCallId::new("tc-2"), SelectedPermissionOutcome::new( - acp::PermissionOptionId::new("allow-2"), - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionId::new("allow-2"), + acp_v1::PermissionOptionKind::AllowOnce, ), cx, ); @@ -11260,13 +11287,13 @@ pub(crate) mod tests { let project = Project::test(fs, [], cx).await; let connection: Rc = Rc::new(StubAgentConnection::new()); - let parent_session_id = acp::SessionId::new("parent"); - let subagent_session_id = acp::SessionId::new("subagent"); + let parent_session_id = acp_v1::SessionId::new("parent"); + let subagent_session_id = acp_v1::SessionId::new("subagent"); let (parent_thread, subagent_thread, conversation) = cx.update(|cx| { let parent_thread = create_test_acp_thread(None, "parent", connection.clone(), project.clone(), cx); let subagent_thread = create_test_acp_thread( - Some(acp::SessionId::new("parent")), + Some(acp_v1::SessionId::new("parent")), "subagent", connection.clone(), project.clone(), @@ -11294,7 +11321,7 @@ pub(crate) mod tests { .pending_tool_call(&subagent_session_id, cx) .expect("Expected subagent's pending tool call"); assert_eq!(returned_session_id, subagent_session_id); - assert_eq!(tool_call_id, acp::ToolCallId::new("subagent-tc")); + assert_eq!(tool_call_id, acp_v1::ToolCallId::new("subagent-tc")); }); // Querying with the parent's session ID returns the first pending @@ -11305,7 +11332,7 @@ pub(crate) mod tests { .pending_tool_call(&parent_session_id, cx) .expect("Expected a pending tool call from parent query"); assert_eq!(returned_session_id, parent_session_id); - assert_eq!(tool_call_id, acp::ToolCallId::new("parent-tc")); + assert_eq!(tool_call_id, acp_v1::ToolCallId::new("parent-tc")); }); } @@ -11317,8 +11344,8 @@ pub(crate) mod tests { let fs = FakeFs::new(cx.executor()); let project = Project::test(fs, [], cx).await; let connection: Rc = Rc::new(StubAgentConnection::new()); - let parent_session_id = acp::SessionId::new("parent"); - let subagent_session_id = acp::SessionId::new("subagent"); + let parent_session_id = acp_v1::SessionId::new("parent"); + let subagent_session_id = acp_v1::SessionId::new("subagent"); let (subagent_thread, conversation) = cx.update(|cx| { let parent_thread = create_test_acp_thread(None, "parent", connection.clone(), project.clone(), cx); @@ -11341,10 +11368,10 @@ pub(crate) mod tests { request_test_tool_authorization(&subagent_thread, "resolved-tool", "allow-child", cx); subagent_thread.update(cx, |thread, cx| { thread.authorize_tool_call( - acp::ToolCallId::new("resolved-tool"), + acp_v1::ToolCallId::new("resolved-tool"), SelectedPermissionOutcome::new( - acp::PermissionOptionId::new("allow-child"), - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionId::new("allow-child"), + acp_v1::PermissionOptionKind::AllowOnce, ), cx, ); @@ -11357,11 +11384,11 @@ pub(crate) mod tests { let response = subagent_thread.update(cx, |thread, cx| { thread .request_tool_call_authorization( - acp::ToolCall::new("queued-tool", "Queued permission").into(), - PermissionOptions::Flat(vec![acp::PermissionOption::new( + acp_v1::ToolCall::new("queued-tool", "Queued permission").into(), + PermissionOptions::Flat(vec![acp_v1::PermissionOption::new( "allow-child", "Allow", - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionKind::AllowOnce, )]), acp_thread::AuthorizationKind::PermissionGrant, cx, @@ -11378,7 +11405,7 @@ pub(crate) mod tests { request_test_tool_authorization(&subagent_thread, "later-tool", "allow-child", cx); for (tool_id, pending_count) in [("child-tool", 3), ("queued-tool", 2), ("later-tool", 1)] { - let tool_id = acp::ToolCallId::new(tool_id); + let tool_id = acp_v1::ToolCallId::new(tool_id); conversation.read_with(cx, |conversation, cx| { assert_eq!( conversation.pending_tool_call_for_session(&subagent_session_id, cx), @@ -11399,8 +11426,8 @@ pub(crate) mod tests { subagent_session_id.clone(), tool_id, SelectedPermissionOutcome::new( - acp::PermissionOptionId::new("allow-child"), - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionId::new("allow-child"), + acp_v1::PermissionOptionKind::AllowOnce, ), cx, ); @@ -11427,8 +11454,8 @@ pub(crate) mod tests { let project = Project::test(fs, [], cx).await; let connection: Rc = Rc::new(StubAgentConnection::new()); - let session_id_a = acp::SessionId::new("thread-a"); - let session_id_b = acp::SessionId::new("thread-b"); + let session_id_a = acp_v1::SessionId::new("thread-a"); + let session_id_b = acp_v1::SessionId::new("thread-b"); let (thread_a, thread_b, conversation) = cx.update(|cx| { let thread_a = create_test_acp_thread(None, "thread-a", connection.clone(), project.clone(), cx); @@ -11454,7 +11481,7 @@ pub(crate) mod tests { .pending_tool_call(&session_id_a, cx) .expect("Expected a pending tool call"); assert_eq!(returned_session_id, session_id_a); - assert_eq!(tool_call_id, acp::ToolCallId::new("tc-a")); + assert_eq!(tool_call_id, acp_v1::ToolCallId::new("tc-a")); }); // Querying with thread-b also returns thread-a's tool call, @@ -11468,7 +11495,7 @@ pub(crate) mod tests { returned_session_id, session_id_a, "Non-subagent queries always return the first pending request in FIFO order" ); - assert_eq!(tool_call_id, acp::ToolCallId::new("tc-a")); + assert_eq!(tool_call_id, acp_v1::ToolCallId::new("tc-a")); }); // After authorizing thread-a's tool call, thread-b's becomes first @@ -11476,10 +11503,10 @@ pub(crate) mod tests { conversation.update(cx, |conversation, cx| { conversation.authorize_tool_call( session_id_a.clone(), - acp::ToolCallId::new("tc-a"), + acp_v1::ToolCallId::new("tc-a"), SelectedPermissionOutcome::new( - acp::PermissionOptionId::new("allow-a"), - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionId::new("allow-a"), + acp_v1::PermissionOptionKind::AllowOnce, ), cx, ); @@ -11494,7 +11521,7 @@ pub(crate) mod tests { .pending_tool_call(&session_id_b, cx) .expect("Expected thread-b's tool call after thread-a's was authorized"); assert_eq!(returned_session_id, session_id_b); - assert_eq!(tool_call_id, acp::ToolCallId::new("tc-b")); + assert_eq!(tool_call_id, acp_v1::ToolCallId::new("tc-b")); }); } @@ -11510,20 +11537,20 @@ pub(crate) mod tests { usize, &'a mut VisualTestContext, ) { - let tool_call_id_value = acp::ToolCallId::new(tool_call_id); - let tool_call = acp::ToolCall::new(tool_call_id_value.clone(), "Run something") - .kind(acp::ToolKind::Edit); + let tool_call_id_value = acp_v1::ToolCallId::new(tool_call_id); + let tool_call = acp_v1::ToolCall::new(tool_call_id_value.clone(), "Run something") + .kind(acp_v1::ToolKind::Edit); let connection = StubAgentConnection::new().with_permission_requests(HashMap::from_iter([( tool_call_id_value.clone(), - PermissionOptions::Flat(vec![acp::PermissionOption::new( + PermissionOptions::Flat(vec![acp_v1::PermissionOption::new( "allow", "Allow", - acp::PermissionOptionKind::AllowOnce, + acp_v1::PermissionOptionKind::AllowOnce, )]), )])); - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall(tool_call)]); + connection.set_next_prompt_updates(vec![acp_v1::SessionUpdate::ToolCall(tool_call)]); let (conversation_view, cx) = setup_conversation_view(StubAgentServer::new(connection), cx).await; @@ -11632,8 +11659,8 @@ pub(crate) mod tests { let project = Project::test(fs, [], cx).await; let connection: Rc = Rc::new(StubAgentConnection::new()); - let session_id_a = acp::SessionId::new("thread-a"); - let session_id_b = acp::SessionId::new("thread-b"); + let session_id_a = acp_v1::SessionId::new("thread-a"); + let session_id_b = acp_v1::SessionId::new("thread-b"); let (thread_a, thread_b, conversation) = cx.update(|cx| { let thread_a = create_test_acp_thread(None, "thread-a", connection.clone(), project.clone(), cx); @@ -11658,13 +11685,13 @@ pub(crate) mod tests { .read(cx) .pending_tool_call_for_session(&session_id_a, cx) .expect("Expected a pending tool call in thread A"); - assert_eq!(tool_call_id_a, acp::ToolCallId::new("tc-a")); + assert_eq!(tool_call_id_a, acp_v1::ToolCallId::new("tc-a")); let tool_call_id_b = conversation .read(cx) .pending_tool_call_for_session(&session_id_b, cx) .expect("Expected a pending tool call in thread B"); - assert_eq!(tool_call_id_b, acp::ToolCallId::new("tc-b")); + assert_eq!(tool_call_id_b, acp_v1::ToolCallId::new("tc-b")); }); } @@ -11735,11 +11762,11 @@ pub(crate) mod tests { thread.update(cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate::new( - acp::ToolCallId::new("perm-flicker"), - acp::ToolCallUpdateFields::new().content(vec![ - acp::ToolCallContent::Content(acp::Content::new( - acp::ContentBlock::Text(acp::TextContent::new( + acp_v1::SessionUpdate::ToolCallUpdate(acp_v1::ToolCallUpdate::new( + acp_v1::ToolCallId::new("perm-flicker"), + acp_v1::ToolCallUpdateFields::new().content(vec![ + acp_v1::ToolCallContent::Content(acp_v1::Content::new( + acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "Plan step\n\n".repeat(100), )), )), @@ -11797,7 +11824,7 @@ pub(crate) mod tests { let thread = thread_view.read_with(cx, |view, _cx| view.thread.clone()); thread.update(cx, |thread, cx| { let result = thread.handle_session_update( - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new( + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new( "More content".into(), )), cx, @@ -11981,7 +12008,7 @@ pub(crate) mod tests { // Add a plain-text message to the queue directly. active_thread(&conversation_view, cx).update_in(cx, |thread, window, cx| { thread.add_to_queue( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "queued message".to_string(), ))], vec![], @@ -12020,7 +12047,7 @@ pub(crate) mod tests { // Seed the main editor with existing content. message_editor(&conversation_view, cx).update_in(cx, |editor, window, cx| { editor.set_message( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "existing content".to_string(), ))], window, @@ -12031,7 +12058,7 @@ pub(crate) mod tests { // Add a plain-text message to the queue. active_thread(&conversation_view, cx).update_in(cx, |thread, window, cx| { thread.add_to_queue( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "queued message".to_string(), ))], vec![], @@ -12067,7 +12094,7 @@ pub(crate) mod tests { active_thread(&conversation_view, cx).update_in(cx, |thread, window, cx| { thread.add_to_queue( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "first queued".to_string(), ))], vec![], @@ -12075,7 +12102,7 @@ pub(crate) mod tests { cx, ); thread.add_to_queue( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "second queued".to_string(), ))], vec![], @@ -12184,9 +12211,9 @@ pub(crate) mod tests { thread .session_capabilities .write() - .set_prompt_capabilities(acp::PromptCapabilities::new().image(true)); + .set_prompt_capabilities(acp_v1::PromptCapabilities::new().image(true)); thread.add_to_queue( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "queued message".to_string(), ))], vec![], @@ -12359,7 +12386,7 @@ pub(crate) mod tests { #[derive(Clone)] struct CloseCapableConnection { - closed_sessions: Arc>>, + closed_sessions: Arc>>, } impl CloseCapableConnection { @@ -12394,9 +12421,9 @@ pub(crate) mod tests { self, project, action_log, - acp::SessionId::new("close-capable-session"), + acp_v1::SessionId::new("close-capable-session"), watch::Receiver::constant( - acp::PromptCapabilities::new() + acp_v1::PromptCapabilities::new() .image(true) .audio(true) .embedded_context(true), @@ -12413,20 +12440,20 @@ pub(crate) mod tests { fn close_session( self: Rc, - session_id: &acp::SessionId, + session_id: &acp_v1::SessionId, _cx: &mut App, ) -> Task> { self.closed_sessions.lock().push(session_id.clone()); Task::ready(Ok(())) } - fn auth_methods(&self) -> &[acp::AuthMethod] { + fn auth_methods(&self) -> &[acp_v1::AuthMethod] { &[] } fn authenticate( &self, - _method_id: acp::AuthMethodId, + _method_id: acp_v1::AuthMethodId, _cx: &mut App, ) -> Task> { Task::ready(Ok(())) @@ -12434,13 +12461,13 @@ pub(crate) mod tests { fn prompt( &self, - _params: acp::PromptRequest, + _params: acp_v1::PromptRequest, _cx: &mut App, - ) -> Task> { - Task::ready(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) + ) -> Task> { + Task::ready(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn))) } - fn cancel(&self, _session_id: &acp::SessionId, _cx: &mut App) {} + fn cancel(&self, _session_id: &acp_v1::SessionId, _cx: &mut App) {} fn into_any(self: Rc) -> Rc { self diff --git a/crates/agent_ui/src/conversation_view/message_queue.rs b/crates/agent_ui/src/conversation_view/message_queue.rs index 31f1a000235..b87c632264e 100644 --- a/crates/agent_ui/src/conversation_view/message_queue.rs +++ b/crates/agent_ui/src/conversation_view/message_queue.rs @@ -7,7 +7,7 @@ pub struct QueueEntryId(usize); pub struct QueueEntry { pub id: QueueEntryId, - pub content: Vec, + pub content: Vec, pub tracked_buffers: Vec>, /// When true, this message interrupts the agent at the next turn boundary /// instead of waiting for generation to fully complete. Only the front diff --git a/crates/agent_ui/src/conversation_view/thread_search_bar.rs b/crates/agent_ui/src/conversation_view/thread_search_bar.rs index b89a0f3f629..cf4f8072e65 100644 --- a/crates/agent_ui/src/conversation_view/thread_search_bar.rs +++ b/crates/agent_ui/src/conversation_view/thread_search_bar.rs @@ -948,7 +948,7 @@ mod tests { use acp_thread::{ ContentBlock, ContextCompaction, ContextCompactionId, ContextCompactionStatus, }; - use agent_client_protocol::schema::v1 as acp; + use agent_client_protocol::schema::v1 as acp_v1; use language::LanguageRegistry; #[gpui::test] @@ -957,7 +957,7 @@ mod tests { let error = cx.new(|cx| Markdown::new("error match".into(), None, None, cx)); let language_registry = Arc::new(LanguageRegistry::test(cx.background_executor().clone())); let unsupported_block = ContentBlock::new_output( - acp::ContentBlock::Audio(acp::AudioContent::new("YXVkaW8=", "audio/wav")), + acp_v1::ContentBlock::Audio(acp_v1::AudioContent::new("YXVkaW8=", "audio/wav")), &language_registry, cx, ); diff --git a/crates/agent_ui/src/conversation_view/thread_view.rs b/crates/agent_ui/src/conversation_view/thread_view.rs index f936430759a..6ef01f6e75b 100644 --- a/crates/agent_ui/src/conversation_view/thread_view.rs +++ b/crates/agent_ui/src/conversation_view/thread_view.rs @@ -5,7 +5,7 @@ use crate::{ open_abs_path_at_point, thread_metadata_store::{ThreadId, ThreadMetadataStore}, }; -use agent_client_protocol::schema::v1 as acp; +use agent_client_protocol::schema::v1 as acp_v1; use std::cell::RefCell; use acp_thread::{ @@ -565,8 +565,8 @@ impl PermissionSelection { pub struct ThreadView { pub(crate) root_thread_id: ThreadId, - pub session_id: acp::SessionId, - pub parent_session_id: Option, + pub session_id: acp_v1::SessionId, + pub parent_session_id: Option, pub thread: Entity, pub(crate) conversation: Entity, pub server_view: WeakEntity, @@ -591,14 +591,14 @@ pub struct ThreadView { thread_feedback: ThreadFeedbackState, pub list_state: ListState, pub session_capabilities: SharedSessionCapabilities, - pub expanded_tool_call_raw_inputs: HashSet, - collapsed_sandbox_authorization_details: HashSet, - collapsed_sandbox_network_details: HashSet, + pub expanded_tool_call_raw_inputs: HashSet, + collapsed_sandbox_authorization_details: HashSet, + collapsed_sandbox_network_details: HashSet, /// Sandbox escalation prompts whose "surprising Unicode" warning the user /// has explicitly acknowledged. Until a prompt's tool call is in this set, /// its allow buttons stay disabled. See [`Self::sandbox_confusable_findings`]. - acknowledged_confusable_warnings: HashSet, - pub subagent_scroll_handles: RefCell>, + acknowledged_confusable_warnings: HashSet, + pub subagent_scroll_handles: RefCell>, pub edits_expanded: bool, pub plan_expanded: bool, pub queue_expanded: bool, @@ -607,18 +607,18 @@ pub struct ThreadView { pub editing_message: Option, pub message_queue: MessageQueue, pub turn_fields: TurnFields, - pub discarded_partial_edits: HashSet, + pub discarded_partial_edits: HashSet, pub is_loading_contents: bool, pub new_server_version_available: Option, pub resumed_without_history: bool, - pub(crate) permission_selections: HashMap, + pub(crate) permission_selections: HashMap, elicitation_form_states: HashMap, pub _cancel_task: Option>, _save_task: Option>, _draft_resolve_task: Option>, _sandbox_status_refresh_task: Option>, pub hovered_edited_file_buttons: Option, - pub in_flight_prompt: Option>, + pub in_flight_prompt: Option>, pub _subscriptions: Vec, pub message_editor: Entity, pub add_context_menu_handle: PopoverMenuHandle, @@ -840,7 +840,7 @@ impl ThreadView { // SECURITY: Be explicit about not auto submitting prompt from external source. should_auto_submit = false; editor.set_message( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( prompt.into_string(), ))], window, @@ -1204,7 +1204,7 @@ impl ThreadView { &self, message_editor: &Entity, cx: &mut App, - ) -> Task, Vec>)>> { + ) -> Task, Vec>)>> { let expand = self.as_native_thread(cx).is_some_and(|thread| { let thread = thread.read(cx); AgentSettings::get_global(cx) @@ -1582,18 +1582,18 @@ impl ThreadView { // Strip the leading `/command` from the first text block; whatever // remains (including any later mention blocks) becomes the queued // follow-up message. - if let Some(acp::ContentBlock::Text(text_content)) = content.first_mut() { + if let Some(acp_v1::ContentBlock::Text(text_content)) = content.first_mut() { text_content.text = strip_leading_command(&text_content.text, &command_name); } if matches!( content.first(), - Some(acp::ContentBlock::Text(text)) if text.text.trim().is_empty() + Some(acp_v1::ContentBlock::Text(text)) if text.text.trim().is_empty() ) { content.remove(0); } let command_block = - acp::ContentBlock::Text(acp::TextContent::new(format!("/{command_name}"))); + acp_v1::ContentBlock::Text(acp_v1::TextContent::new(format!("/{command_name}"))); this.update_in(cx, |this, window, cx| { // Queue the remainder first, then start the command turn; the @@ -1657,7 +1657,9 @@ impl ThreadView { pub fn send_content( &mut self, - contents_task: Task, Vec>)>>>, + contents_task: Task< + anyhow::Result, Vec>)>>, + >, is_native_command: bool, window: &mut Window, cx: &mut Context, @@ -1717,8 +1719,8 @@ impl ThreadView { let text: String = contents .iter() .filter_map(|block| match block { - acp::ContentBlock::Text(text_content) => Some(text_content.text.clone()), - acp::ContentBlock::ResourceLink(resource_link) => { + acp_v1::ContentBlock::Text(text_content) => Some(text_content.text.clone()), + acp_v1::ContentBlock::ResourceLink(resource_link) => { Some(format!("@{}", resource_link.name)) } _ => None, @@ -2106,7 +2108,7 @@ impl ThreadView { pub fn add_to_queue( &mut self, - content: Vec, + content: Vec, tracked_buffers: Vec>, window: &mut Window, cx: &mut Context, @@ -2275,7 +2277,7 @@ impl ThreadView { let is_native_command = content .first() .and_then(|block| match block { - acp::ContentBlock::Text(text) => Some(text.text.as_str()), + acp_v1::ContentBlock::Text(text) => Some(text.text.as_str()), _ => None, }) .and_then(|text| { @@ -2481,8 +2483,8 @@ impl ThreadView { pub fn authorize_tool_call( &mut self, - session_id: acp::SessionId, - tool_call_id: acp::ToolCallId, + session_id: acp_v1::SessionId, + tool_call_id: acp_v1::ToolCallId, outcome: SelectedPermissionOutcome, window: &mut Window, cx: &mut Context, @@ -2504,7 +2506,7 @@ impl ThreadView { if self.pending_allow_blocked_by_confusables(cx) { return; } - self.authorize_pending_tool_call(acp::PermissionOptionKind::AllowAlways, window, cx); + self.authorize_pending_tool_call(acp_v1::PermissionOptionKind::AllowAlways, window, cx); } pub fn allow_once(&mut self, _: &AllowOnce, window: &mut Window, cx: &mut Context) { @@ -2541,7 +2543,7 @@ impl ThreadView { pub fn authorize_pending_tool_call( &mut self, - kind: acp::PermissionOptionKind, + kind: acp_v1::PermissionOptionKind, window: &mut Window, cx: &mut Context, ) -> Option<()> { @@ -2595,7 +2597,7 @@ impl ThreadView { elicitation_id.clone(), matches!(elicitation.status, ElicitationStatus::Pending { .. }), match &elicitation.request.mode { - acp::ElicitationMode::Form(mode) => Some(mode.requested_schema.clone()), + acp_v1::ElicitationMode::Form(mode) => Some(mode.requested_schema.clone()), _ => None, }, ) @@ -2645,7 +2647,7 @@ impl ThreadView { }; match mode { - acp::ElicitationMode::Form(mode) => { + acp_v1::ElicitationMode::Form(mode) => { let Some(state) = self.elicitation_form_states.get_mut(&elicitation_id) else { return; }; @@ -2675,9 +2677,9 @@ impl ThreadView { Ok(content) => { this.respond_to_elicitation( elicitation_id, - acp::CreateElicitationResponse::new( - acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new().content(content), + acp_v1::CreateElicitationResponse::new( + acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new().content(content), ), ), cx, @@ -2697,11 +2699,11 @@ impl ThreadView { }) .detach(); } - acp::ElicitationMode::Url(_) => { + acp_v1::ElicitationMode::Url(_) => { self.respond_to_elicitation( elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Accept( - acp::ElicitationAcceptAction::new(), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Accept( + acp_v1::ElicitationAcceptAction::new(), )), cx, ); @@ -2718,7 +2720,7 @@ impl ThreadView { ) { self.respond_to_elicitation( elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Decline), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Decline), cx, ); } @@ -2731,7 +2733,7 @@ impl ThreadView { ) { self.respond_to_elicitation( elicitation_id, - acp::CreateElicitationResponse::new(acp::ElicitationAction::Cancel), + acp_v1::CreateElicitationResponse::new(acp_v1::ElicitationAction::Cancel), cx, ); } @@ -2752,7 +2754,7 @@ impl ThreadView { fn respond_to_elicitation( &mut self, elicitation_id: ElicitationEntryId, - response: acp::CreateElicitationResponse, + response: acp_v1::CreateElicitationResponse, cx: &mut Context, ) { let session_id = self.session_id.clone(); @@ -2769,14 +2771,14 @@ impl ThreadView { window: &mut Window, cx: &mut Context, ) { - let tool_call_id = acp::ToolCallId::new(action.tool_call_id.clone()); - let option_id = acp::PermissionOptionId::new(action.option_id.clone()); + let tool_call_id = acp_v1::ToolCallId::new(action.tool_call_id.clone()); + let option_id = acp_v1::PermissionOptionId::new(action.option_id.clone()); let option_kind = match action.option_kind.as_str() { - "AllowOnce" => acp::PermissionOptionKind::AllowOnce, - "AllowAlways" => acp::PermissionOptionKind::AllowAlways, - "RejectOnce" => acp::PermissionOptionKind::RejectOnce, - "RejectAlways" => acp::PermissionOptionKind::RejectAlways, - _ => acp::PermissionOptionKind::AllowOnce, + "AllowOnce" => acp_v1::PermissionOptionKind::AllowOnce, + "AllowAlways" => acp_v1::PermissionOptionKind::AllowAlways, + "RejectOnce" => acp_v1::PermissionOptionKind::RejectOnce, + "RejectAlways" => acp_v1::PermissionOptionKind::RejectAlways, + _ => acp_v1::PermissionOptionKind::AllowOnce, }; let session_id = self.thread.read(cx).session_id().clone(); @@ -2795,7 +2797,7 @@ impl ThreadView { _window: &mut Window, cx: &mut Context, ) { - let tool_call_id = acp::ToolCallId::new(action.tool_call_id.clone()); + let tool_call_id = acp_v1::ToolCallId::new(action.tool_call_id.clone()); self.permission_selections .insert(tool_call_id, PermissionSelection::Choice(action.index)); @@ -2808,7 +2810,7 @@ impl ThreadView { _window: &mut Window, cx: &mut Context, ) { - let tool_call_id = acp::ToolCallId::new(action.tool_call_id.clone()); + let tool_call_id = acp_v1::ToolCallId::new(action.tool_call_id.clone()); match self.permission_selections.get_mut(&tool_call_id) { Some(PermissionSelection::SelectedPatterns(checked)) => { @@ -2869,8 +2871,8 @@ impl ThreadView { fn authorize_with_granularity( &mut self, - session_id: acp::SessionId, - tool_call_id: acp::ToolCallId, + session_id: acp_v1::SessionId, + tool_call_id: acp_v1::ToolCallId, is_allow: bool, window: &mut Window, cx: &mut Context, @@ -3426,7 +3428,7 @@ impl ThreadView { fn collect_subagent_items_for_sessions( entries: &[AgentThreadEntry], - awaiting_session_ids: &[acp::SessionId], + awaiting_session_ids: &[acp_v1::SessionId], cx: &App, ) -> Vec<(SharedString, usize)> { let tool_calls_by_session: HashMap<_, _> = entries @@ -3828,20 +3830,20 @@ impl ThreadView { .text_xs() .text_color(cx.theme().colors().text_muted) .child(match entry.status { - acp::PlanEntryStatus::InProgress => { + acp_v1::PlanEntryStatus::InProgress => { Icon::new(IconName::TodoProgress) .size(IconSize::Small) .color(Color::Accent) .with_rotate_animation(2) .into_any_element() } - acp::PlanEntryStatus::Completed => { + acp_v1::PlanEntryStatus::Completed => { Icon::new(IconName::TodoComplete) .size(IconSize::Small) .color(Color::Success) .into_any_element() } - acp::PlanEntryStatus::Pending | _ => { + acp_v1::PlanEntryStatus::Pending | _ => { Icon::new(IconName::TodoPending) .size(IconSize::Small) .color(Color::Muted) @@ -7779,7 +7781,7 @@ impl ThreadView { ToolCallStatus::InProgress | ToolCallStatus::Pending ) => { - if matches!(tool_call.kind, acp::ToolKind::Execute) { + if matches!(tool_call.kind, acp_v1::ToolKind::Execute) { has_running_terminal_call = true; } else { return false; @@ -7865,7 +7867,7 @@ impl ThreadView { fn render_terminal_tool_call( &self, - active_session_id: &acp::SessionId, + active_session_id: &acp_v1::SessionId, entry_ix: usize, terminal: &Entity, tool_call: &ToolCall, @@ -8124,8 +8126,8 @@ impl ThreadView { fn is_first_tool_call( &self, - active_session_id: &acp::SessionId, - tool_call_id: &acp::ToolCallId, + active_session_id: &acp_v1::SessionId, + tool_call_id: &acp_v1::ToolCallId, cx: &App, ) -> bool { self.conversation @@ -8139,7 +8141,7 @@ impl ThreadView { fn render_any_tool_call( &self, - active_session_id: &acp::SessionId, + active_session_id: &acp_v1::SessionId, entry_ix: usize, tool_call: &ToolCall, focus_handle: &FocusHandle, @@ -8206,7 +8208,7 @@ impl ThreadView { fn render_tool_call( &self, - active_session_id: &acp::SessionId, + active_session_id: &acp_v1::SessionId, entry_ix: usize, tool_call: &ToolCall, focus_handle: &FocusHandle, @@ -8226,10 +8228,10 @@ impl ThreadView { tool_call.status, ToolCallStatus::WaitingForConfirmation { .. } ); - let is_terminal_tool = matches!(tool_call.kind, acp::ToolKind::Execute); + let is_terminal_tool = matches!(tool_call.kind, acp_v1::ToolKind::Execute); let is_edit = - matches!(tool_call.kind, acp::ToolKind::Edit) || tool_call.diffs().next().is_some(); + matches!(tool_call.kind, acp_v1::ToolKind::Edit) || tool_call.diffs().next().is_some(); let is_cancelled_edit = is_edit && matches!(tool_call.status, ToolCallStatus::Canceled); let (has_revealed_diff, tool_call_output_focus, tool_call_output_focus_handle) = tool_call @@ -8752,7 +8754,7 @@ impl ThreadView { fn render_sandbox_authorization_details( &self, entry_ix: usize, - tool_call_id: &acp::ToolCallId, + tool_call_id: &acp_v1::ToolCallId, details: &SandboxAuthorizationDetails, window: &Window, cx: &Context, @@ -9102,7 +9104,7 @@ impl ThreadView { /// allow buttons. See [`Self::sandbox_confusables_block_allow`]. fn render_sandbox_confusable_warning( &self, - tool_call_id: &acp::ToolCallId, + tool_call_id: &acp_v1::ToolCallId, findings: &[(String, Vec)], window: &Window, cx: &Context, @@ -9408,11 +9410,11 @@ impl ThreadView { fn render_permission_buttons( &self, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, is_first: bool, options: &PermissionOptions, entry_ix: usize, - tool_call_id: acp::ToolCallId, + tool_call_id: acp_v1::ToolCallId, focus_handle: &FocusHandle, // When true, the "allow" choices are disabled (e.g. an unacknowledged // surprising-Unicode warning is showing). "Deny"/"Retry" stay enabled. @@ -9465,8 +9467,8 @@ impl ThreadView { choices: &[PermissionOptionChoice], patterns: Option<(&[PermissionPattern], &str)>, entry_ix: usize, - session_id: acp::SessionId, - tool_call_id: acp::ToolCallId, + session_id: acp_v1::SessionId, + tool_call_id: acp_v1::ToolCallId, focus_handle: &FocusHandle, allow_disabled: bool, cx: &Context, @@ -9593,7 +9595,7 @@ impl ThreadView { choices: &[PermissionOptionChoice], current_label: SharedString, entry_ix: usize, - tool_call_id: acp::ToolCallId, + tool_call_id: acp_v1::ToolCallId, selected_index: usize, is_first: bool, cx: &Context, @@ -9668,7 +9670,7 @@ impl ThreadView { _tool_name: &str, current_label: SharedString, entry_ix: usize, - tool_call_id: acp::ToolCallId, + tool_call_id: acp_v1::ToolCallId, is_first: bool, cx: &Context, ) -> AnyElement { @@ -9850,16 +9852,16 @@ impl ThreadView { fn render_permission_buttons_flat( &self, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, is_first: bool, - options: &[acp::PermissionOption], + options: &[acp_v1::PermissionOption], entry_ix: usize, - tool_call_id: acp::ToolCallId, + tool_call_id: acp_v1::ToolCallId, focus_handle: &FocusHandle, allow_disabled: bool, cx: &Context, ) -> Div { - let mut seen_kinds: ArrayVec = ArrayVec::new(); + let mut seen_kinds: ArrayVec = ArrayVec::new(); div() .p_1() @@ -9887,13 +9889,13 @@ impl ThreadView { ) } else { match option.kind { - acp::PermissionOptionKind::AllowOnce => ( + acp_v1::PermissionOptionKind::AllowOnce => ( Icon::new(IconName::Check) .size(IconSize::XSmall) .color(Color::Success), Some(&AllowOnce as &dyn Action), ), - acp::PermissionOptionKind::AllowAlways => ( + acp_v1::PermissionOptionKind::AllowAlways => ( Icon::new(IconName::CheckDouble) .size(IconSize::XSmall) .color(Color::Success), @@ -9905,13 +9907,13 @@ impl ThreadView { Some(&AllowAlways as &dyn Action) }, ), - acp::PermissionOptionKind::RejectOnce => ( + acp_v1::PermissionOptionKind::RejectOnce => ( Icon::new(IconName::Close) .size(IconSize::XSmall) .color(Color::Error), Some(&RejectOnce as &dyn Action), ), - acp::PermissionOptionKind::RejectAlways | _ => ( + acp_v1::PermissionOptionKind::RejectAlways | _ => ( Icon::new(IconName::Close) .size(IconSize::XSmall) .color(Color::Error), @@ -9924,8 +9926,8 @@ impl ThreadView { // warning is unacknowledged; "deny"/"retry" stay enabled. let is_allow = matches!( option.kind, - acp::PermissionOptionKind::AllowOnce - | acp::PermissionOptionKind::AllowAlways + acp_v1::PermissionOptionKind::AllowOnce + | acp_v1::PermissionOptionKind::AllowAlways ) && !is_retry; let disabled = allow_disabled && is_allow; @@ -10031,7 +10033,7 @@ impl ThreadView { cx: &Context, ) -> Div { let has_location = tool_call.locations.len() == 1; - let is_file = tool_call.kind == acp::ToolKind::Edit && has_location; + let is_file = tool_call.kind == acp_v1::ToolKind::Edit && has_location; let is_subagent_tool_call = tool_call.is_subagent(); let file_icon = if has_location { @@ -10070,16 +10072,16 @@ impl ThreadView { .into_any_element() } else { Icon::new(match tool_call.kind { - acp::ToolKind::Read => IconName::ToolSearch, - acp::ToolKind::Edit => IconName::ToolPencil, - acp::ToolKind::Delete => IconName::ToolDeleteFile, - acp::ToolKind::Move => IconName::ArrowRightLeft, - acp::ToolKind::Search => IconName::ToolSearch, - acp::ToolKind::Execute => IconName::ToolTerminal, - acp::ToolKind::Think => IconName::ToolThink, - acp::ToolKind::Fetch => IconName::ToolWeb, - acp::ToolKind::SwitchMode => IconName::ArrowRightLeft, - acp::ToolKind::Other | _ => IconName::ToolHammer, + acp_v1::ToolKind::Read => IconName::ToolSearch, + acp_v1::ToolKind::Edit => IconName::ToolPencil, + acp_v1::ToolKind::Delete => IconName::ToolDeleteFile, + acp_v1::ToolKind::Move => IconName::ArrowRightLeft, + acp_v1::ToolKind::Search => IconName::ToolSearch, + acp_v1::ToolKind::Execute => IconName::ToolTerminal, + acp_v1::ToolKind::Think => IconName::ToolThink, + acp_v1::ToolKind::Fetch => IconName::ToolWeb, + acp_v1::ToolKind::SwitchMode => IconName::ArrowRightLeft, + acp_v1::ToolKind::Other | _ => IconName::ToolHammer, }) .size(IconSize::Small) .color(Color::Muted) @@ -10250,7 +10252,7 @@ impl ThreadView { fn render_tool_call_content( &self, - session_id: &acp::SessionId, + session_id: &acp_v1::SessionId, entry_ix: usize, content: &ToolCallContent, context_ix: usize, @@ -10334,7 +10336,7 @@ impl ThreadView { fn render_embedded_resource_output( &self, - resource: &acp::EmbeddedResource, + resource: &acp_v1::EmbeddedResource, context_ix: usize, card_layout: bool, cx: &Context, @@ -10358,10 +10360,10 @@ impl ThreadView { .into_any_element() } - fn render_embedded_resource_label(&self, resource: &acp::EmbeddedResource) -> AnyElement { + fn render_embedded_resource_label(&self, resource: &acp_v1::EmbeddedResource) -> AnyElement { let uri = match &resource.resource { - acp::EmbeddedResourceResource::BlobResourceContents(blob) => blob.uri.as_str(), - acp::EmbeddedResourceResource::TextResourceContents(text) => text.uri.as_str(), + acp_v1::EmbeddedResourceResource::BlobResourceContents(blob) => blob.uri.as_str(), + acp_v1::EmbeddedResourceResource::TextResourceContents(text) => text.uri.as_str(), _ => "", }; if uri.is_empty() { @@ -10376,7 +10378,7 @@ impl ThreadView { fn render_resource_link( &self, - resource_link: &acp::ResourceLink, + resource_link: &acp_v1::ResourceLink, cx: &Context, ) -> AnyElement { let uri: SharedString = resource_link.uri.clone().into(); @@ -10567,7 +10569,7 @@ impl ThreadView { &self, entry_ix: usize, image: Arc, - location: Option, + location: Option, card_layout: bool, cx: &Context, ) -> AnyElement { @@ -10606,10 +10608,10 @@ impl ThreadView { fn render_subagent_tool_call( &self, - active_session_id: &acp::SessionId, + active_session_id: &acp_v1::SessionId, entry_ix: usize, tool_call: &ToolCall, - subagent_session_id: Option, + subagent_session_id: Option, focus_handle: &FocusHandle, window: &Window, cx: &Context, @@ -10636,7 +10638,7 @@ impl ThreadView { fn render_subagent_card( &self, - active_session_id: &acp::SessionId, + active_session_id: &acp_v1::SessionId, entry_ix: usize, thread_view: Option<&Entity>, tool_call: &ToolCall, @@ -12448,7 +12450,7 @@ impl Render for ThreadView { if let Some(config_options_view) = this.config_options_view.clone() { let handled = config_options_view.update(cx, |view, cx| { view.cycle_category_option( - acp::SessionConfigOptionCategory::ThoughtLevel, + acp_v1::SessionConfigOptionCategory::ThoughtLevel, false, cx, ) @@ -12467,7 +12469,7 @@ impl Render for ThreadView { if let Some(config_options_view) = this.config_options_view.clone() { let handled = config_options_view.update(cx, |view, cx| { view.toggle_category_picker( - acp::SessionConfigOptionCategory::ThoughtLevel, + acp_v1::SessionConfigOptionCategory::ThoughtLevel, window, cx, ) @@ -12515,7 +12517,7 @@ impl Render for ThreadView { if let Some(config_options_view) = this.config_options_view.clone() { let handled = config_options_view.update(cx, |view, cx| { view.toggle_category_picker( - acp::SessionConfigOptionCategory::Mode, + acp_v1::SessionConfigOptionCategory::Mode, window, cx, ) @@ -12538,7 +12540,7 @@ impl Render for ThreadView { if let Some(config_options_view) = this.config_options_view.clone() { let handled = config_options_view.update(cx, |view, cx| { view.cycle_category_option( - acp::SessionConfigOptionCategory::Mode, + acp_v1::SessionConfigOptionCategory::Mode, false, cx, ) @@ -12565,7 +12567,7 @@ impl Render for ThreadView { if let Some(config_options_view) = this.config_options_view.clone() { let handled = config_options_view.update(cx, |view, cx| { view.toggle_category_picker( - acp::SessionConfigOptionCategory::Model, + acp_v1::SessionConfigOptionCategory::Model, window, cx, ) @@ -12587,7 +12589,7 @@ impl Render for ThreadView { if let Some(config_options_view) = this.config_options_view.clone() { let handled = config_options_view.update(cx, |view, cx| { view.cycle_category_option( - acp::SessionConfigOptionCategory::Model, + acp_v1::SessionConfigOptionCategory::Model, true, cx, ) @@ -12796,7 +12798,7 @@ pub(crate) fn open_link( /// command is never echoed as a user message (see `send_command_queueing_remainder`). fn leading_native_command( text: &str, - available_commands: &[acp::AvailableCommand], + available_commands: &[acp_v1::AvailableCommand], ) -> Option { let rest = text.trim_start().strip_prefix('/')?; let name_end = rest.find(char::is_whitespace).unwrap_or(rest.len()); @@ -12856,14 +12858,14 @@ mod tests { } } - fn native_command(name: &str) -> acp::AvailableCommand { - acp::AvailableCommand::new(name, "").meta(acp_thread::meta_with_command_category( + fn native_command(name: &str) -> acp_v1::AvailableCommand { + acp_v1::AvailableCommand::new(name, "").meta(acp_thread::meta_with_command_category( acp_thread::CommandCategory::Native, )) } - fn mcp_command(name: &str) -> acp::AvailableCommand { - acp::AvailableCommand::new(name, "").meta(acp_thread::meta_with_command_category( + fn mcp_command(name: &str) -> acp_v1::AvailableCommand { + acp_v1::AvailableCommand::new(name, "").meta(acp_thread::meta_with_command_category( acp_thread::CommandCategory::Mcp, )) } diff --git a/crates/agent_ui/src/entry_view_state.rs b/crates/agent_ui/src/entry_view_state.rs index 9a22ead900d..f58657fcf7a 100644 --- a/crates/agent_ui/src/entry_view_state.rs +++ b/crates/agent_ui/src/entry_view_state.rs @@ -2,7 +2,7 @@ use std::{ops::Range, sync::Arc}; use acp_thread::{AcpThread, AgentThreadEntry, AssistantMessageChunk}; use agent::ThreadStore; -use agent_client_protocol::schema::v1 as acp; +use agent_client_protocol::schema::v1 as acp_v1; use agent_settings::AgentSettings; use collections::{HashMap, HashSet}; use editor::{ @@ -47,7 +47,7 @@ pub struct EntryViewState { auto_expanded_thinking_block: Option<(usize, usize)>, user_toggled_thinking_blocks: HashSet<(usize, usize)>, expanded_compactions: HashSet, - expanded_tool_calls: HashSet, + expanded_tool_calls: HashSet, } impl EntryViewState { @@ -73,19 +73,19 @@ impl EntryViewState { } } - pub(crate) fn is_tool_call_expanded(&self, tool_call_id: &acp::ToolCallId) -> bool { + pub(crate) fn is_tool_call_expanded(&self, tool_call_id: &acp_v1::ToolCallId) -> bool { self.expanded_tool_calls.contains(tool_call_id) } - pub(crate) fn expand_tool_call(&mut self, tool_call_id: acp::ToolCallId) { + pub(crate) fn expand_tool_call(&mut self, tool_call_id: acp_v1::ToolCallId) { self.expanded_tool_calls.insert(tool_call_id); } - pub(crate) fn collapse_tool_call(&mut self, tool_call_id: &acp::ToolCallId) { + pub(crate) fn collapse_tool_call(&mut self, tool_call_id: &acp_v1::ToolCallId) { self.expanded_tool_calls.remove(tool_call_id); } - pub(crate) fn toggle_tool_call_expansion(&mut self, tool_call_id: &acp::ToolCallId) { + pub(crate) fn toggle_tool_call_expansion(&mut self, tool_call_id: &acp_v1::ToolCallId) { if !self.expanded_tool_calls.remove(tool_call_id) { self.expanded_tool_calls.insert(tool_call_id.clone()); } @@ -497,9 +497,9 @@ pub struct EntryViewEvent { } pub enum ViewEvent { - NewDiff(acp::ToolCallId), - NewTerminal(acp::ToolCallId), - TerminalMovedToBackground(acp::ToolCallId), + NewDiff(acp_v1::ToolCallId), + NewTerminal(acp_v1::ToolCallId), + TerminalMovedToBackground(acp_v1::ToolCallId), MessageEditorEvent(Entity, MessageEditorEvent), OpenDiffLocation { path: String, @@ -716,7 +716,7 @@ mod tests { use std::sync::Arc; use acp_thread::{AgentConnection, StubAgentConnection}; - use agent_client_protocol::schema::v1 as acp; + use agent_client_protocol::schema::v1 as acp_v1; use buffer_diff::{DiffHunkStatus, DiffHunkStatusKind}; use editor::RowInfo; use fs::FakeFs; @@ -767,10 +767,10 @@ mod tests { cx.add_window_view(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx)); let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone()); - let tool_call = acp::ToolCall::new("tool", "Tool call") - .status(acp::ToolCallStatus::InProgress) - .content(vec![acp::ToolCallContent::Diff( - acp::Diff::new("/project/hello.txt", "hello world").old_text("hi world"), + let tool_call = acp_v1::ToolCall::new("tool", "Tool call") + .status(acp_v1::ToolCallStatus::InProgress) + .content(vec![acp_v1::ToolCallContent::Diff( + acp_v1::Diff::new("/project/hello.txt", "hello world").old_text("hi world"), )]); let connection = Rc::new(StubAgentConnection::new()); let thread = cx @@ -786,7 +786,7 @@ mod tests { let session_id = thread.update(cx, |thread, _| thread.session_id().clone()); cx.update(|_, cx| { - connection.send_update(session_id, acp::SessionUpdate::ToolCall(tool_call), cx) + connection.send_update(session_id, acp_v1::SessionUpdate::ToolCall(tool_call), cx) }); let thread_store = None; @@ -883,10 +883,10 @@ mod tests { let _response_task = thread.update(cx, |thread, cx| { thread .request_elicitation( - acp::CreateElicitationRequest::new( - acp::ElicitationFormMode::new( - acp::ElicitationSessionScope::new(session_id.clone()), - acp::ElicitationSchema::new().string("name", true), + acp_v1::CreateElicitationRequest::new( + acp_v1::ElicitationFormMode::new( + acp_v1::ElicitationSessionScope::new(session_id.clone()), + acp_v1::ElicitationSchema::new().string("name", true), ), "Provide a name", ), @@ -897,8 +897,8 @@ mod tests { cx.update(|_, cx| { connection.send_update( session_id, - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new( - acp::ContentBlock::Text(acp::TextContent::new("hello")), + acp_v1::SessionUpdate::AgentMessageChunk(acp_v1::ContentChunk::new( + acp_v1::ContentBlock::Text(acp_v1::TextContent::new("hello")), )), cx, ); diff --git a/crates/agent_ui/src/message_editor.rs b/crates/agent_ui/src/message_editor.rs index fe10a36cb95..a6eca45c6cd 100644 --- a/crates/agent_ui/src/message_editor.rs +++ b/crates/agent_ui/src/message_editor.rs @@ -11,7 +11,7 @@ use crate::{ }; use acp_thread::MentionUri; use agent::ThreadStore; -use agent_client_protocol::schema::v1 as acp; +use agent_client_protocol::schema::v1 as acp_v1; use anyhow::{Result, anyhow}; use base64::Engine as _; use editor::{ @@ -47,15 +47,15 @@ use zed_actions::agent::{Chat, PasteRaw}; #[derive(Default)] pub struct SessionCapabilities { - prompt_capabilities: acp::PromptCapabilities, - available_commands: Vec, + prompt_capabilities: acp_v1::PromptCapabilities, + available_commands: Vec, available_skills: Vec, } impl SessionCapabilities { pub fn new( - prompt_capabilities: acp::PromptCapabilities, - available_commands: Vec, + prompt_capabilities: acp_v1::PromptCapabilities, + available_commands: Vec, available_skills: Vec, ) -> Self { Self { @@ -66,8 +66,8 @@ impl SessionCapabilities { } pub fn from_acp_commands( - prompt_capabilities: acp::PromptCapabilities, - available_commands: Vec, + prompt_capabilities: acp_v1::PromptCapabilities, + available_commands: Vec, ) -> Self { Self::new(prompt_capabilities, available_commands, Vec::new()) } @@ -80,7 +80,7 @@ impl SessionCapabilities { self.prompt_capabilities.embedded_context } - pub fn available_commands(&self) -> &[acp::AvailableCommand] { + pub fn available_commands(&self) -> &[acp_v1::AvailableCommand] { &self.available_commands } @@ -125,11 +125,11 @@ impl SessionCapabilities { self.available_skills.clone() } - pub fn set_prompt_capabilities(&mut self, prompt_capabilities: acp::PromptCapabilities) { + pub fn set_prompt_capabilities(&mut self, prompt_capabilities: acp_v1::PromptCapabilities) { self.prompt_capabilities = prompt_capabilities; } - pub fn set_available_commands(&mut self, available_commands: Vec) { + pub fn set_available_commands(&mut self, available_commands: Vec) { self.available_commands = available_commands; } @@ -643,7 +643,7 @@ impl MessageEditor { .iter() .find(|available_command| available_command.name == command_name)?; - let acp::AvailableCommandInput::Unstructured(acp::UnstructuredCommandInput { + let acp_v1::AvailableCommandInput::Unstructured(acp_v1::UnstructuredCommandInput { mut hint, .. }) = available_command.input.clone()? @@ -676,7 +676,7 @@ impl MessageEditor { pub fn insert_thread_summary( &mut self, - session_id: acp::SessionId, + session_id: acp_v1::SessionId, title: Option, window: &mut Window, cx: &mut Context, @@ -750,7 +750,7 @@ impl MessageEditor { fn validate_slash_commands( text: &str, - available_commands: &[acp::AvailableCommand], + available_commands: &[acp_v1::AvailableCommand], available_skills: &[AvailableSkill], agent_id: &AgentId, ) -> Result<()> { @@ -824,7 +824,7 @@ impl MessageEditor { /// when both a global and a project-local skill share a name. /// Globals carry an empty scope and so render as `/:`. fn format_available_commands( - commands: &[acp::AvailableCommand], + commands: &[acp_v1::AvailableCommand], skills: &[AvailableSkill], ) -> String { if commands.is_empty() && skills.is_empty() { @@ -842,7 +842,7 @@ impl MessageEditor { &self, full_mention_content: bool, cx: &mut Context, - ) -> Task, Vec>)>> { + ) -> Task, Vec>)>> { let text = self.editor.read(cx).text(cx); let (available_commands, available_skills) = { let session_capabilities = self.session_capabilities.read(); @@ -865,7 +865,10 @@ impl MessageEditor { }) } - pub fn draft_contents(&self, cx: &mut Context) -> Task>> { + pub fn draft_contents( + &self, + cx: &mut Context, + ) -> Task>> { let build_task = self.build_content_blocks(false, cx); cx.spawn(async move |_, _cx| { let (blocks, _tracked_buffers) = build_task.await?; @@ -877,7 +880,7 @@ impl MessageEditor { &self, full_mention_content: bool, cx: &mut Context, - ) -> Task, Vec>)>> { + ) -> Task, Vec>)>> { let contents = self .mention_set .update(cx, |store, cx| store.contents(full_mention_content, cx)); @@ -908,7 +911,7 @@ impl MessageEditor { /// Snapshots the editor's current draft into a list of `ContentBlock`s /// without awaiting any pending mention resolution. - pub fn draft_content_blocks_snapshot(&self, cx: &App) -> Vec { + pub fn draft_content_blocks_snapshot(&self, cx: &App) -> Vec { let editor = self.editor.read(cx); let crease_snapshot = editor.display_map.read(cx).crease_snapshot(); let buffer_snapshot = editor.buffer().read(cx).snapshot(cx); @@ -1684,7 +1687,7 @@ impl MessageEditor { pub fn set_message( &mut self, - message: Vec, + message: Vec, window: &mut Window, cx: &mut Context, ) { @@ -1694,7 +1697,7 @@ impl MessageEditor { pub fn append_message( &mut self, - message: Vec, + message: Vec, separator: Option<&str>, window: &mut Window, cx: &mut Context, @@ -1717,7 +1720,7 @@ impl MessageEditor { fn insert_message_blocks( &mut self, - message: Vec, + message: Vec, append_to_existing: bool, window: &mut Window, cx: &mut Context, @@ -1736,11 +1739,11 @@ impl MessageEditor { for chunk in message { match chunk { - acp::ContentBlock::Text(text_content) => { + acp_v1::ContentBlock::Text(text_content) => { append_normalized(&mut text, text_content.text); } - acp::ContentBlock::Resource(acp::EmbeddedResource { - resource: acp::EmbeddedResourceResource::TextResourceContents(resource), + acp_v1::ContentBlock::Resource(acp_v1::EmbeddedResource { + resource: acp_v1::EmbeddedResourceResource::TextResourceContents(resource), .. }) => { let Some(mention_uri) = MentionUri::parse(&resource.uri, path_style).log_err() @@ -1759,7 +1762,7 @@ impl MessageEditor { }, )); } - acp::ContentBlock::ResourceLink(resource) => { + acp_v1::ContentBlock::ResourceLink(resource) => { if let Some(mention_uri) = MentionUri::parse(&resource.uri, path_style).log_err() { @@ -1769,7 +1772,7 @@ impl MessageEditor { mentions.push((start..end, mention_uri, Mention::Link)); } } - acp::ContentBlock::Image(acp::ImageContent { + acp_v1::ContentBlock::Image(acp_v1::ImageContent { uri, data, mime_type, @@ -2076,7 +2079,7 @@ fn build_chunks_from_creases( buffer_snapshot: &MultiBufferSnapshot, supports_embedded_context: bool, mut resolve: impl FnMut(&CreaseId) -> Option<(MentionUri, Option)>, -) -> (Vec, Vec>) { +) -> (Vec, Vec>) { let mut ix = text .char_indices() .find(|(_, c)| !c.is_whitespace()) @@ -2140,7 +2143,7 @@ fn mention_to_content_block( mention: Option<&Mention>, supports_embedded_context: bool, tracked_buffers: &mut Vec>, -) -> acp::ContentBlock { +) -> acp_v1::ContentBlock { match mention { Some(Mention::Text { content, @@ -2148,20 +2151,23 @@ fn mention_to_content_block( }) => { tracked_buffers.extend(mention_tracked_buffers.iter().cloned()); if supports_embedded_context { - acp::ContentBlock::Resource(acp::EmbeddedResource::new( - acp::EmbeddedResourceResource::TextResourceContents( - acp::TextResourceContents::new(content.clone(), uri.to_uri().to_string()), + acp_v1::ContentBlock::Resource(acp_v1::EmbeddedResource::new( + acp_v1::EmbeddedResourceResource::TextResourceContents( + acp_v1::TextResourceContents::new( + content.clone(), + uri.to_uri().to_string(), + ), ), )) } else { - acp::ContentBlock::ResourceLink(acp::ResourceLink::new( + acp_v1::ContentBlock::ResourceLink(acp_v1::ResourceLink::new( uri.name(), uri.to_uri().to_string(), )) } } - Some(Mention::Image(mention_image)) => acp::ContentBlock::Image( - acp::ImageContent::new(mention_image.data.clone(), mention_image.format.mime_type()) + Some(Mention::Image(mention_image)) => acp_v1::ContentBlock::Image( + acp_v1::ImageContent::new(mention_image.data.clone(), mention_image.format.mime_type()) .uri(match uri { MentionUri::File { .. } | MentionUri::PastedImage { .. } => { Some(uri.to_uri().to_string()) @@ -2172,7 +2178,7 @@ fn mention_to_content_block( } }), ), - _ => acp::ContentBlock::ResourceLink(acp::ResourceLink::new( + _ => acp_v1::ContentBlock::ResourceLink(acp_v1::ResourceLink::new( uri.name(), uri.to_uri().to_string(), )), @@ -2249,7 +2255,7 @@ mod tests { use super::PromptLocalCommand; use acp_thread::MentionUri; use agent::{ThreadStore, outline}; - use agent_client_protocol::schema::v1 as acp; + use agent_client_protocol::schema::v1 as acp_v1; use base64::Engine as _; use editor::{ AnchorRangeExt as _, Editor, EditorMode, MultiBufferOffset, SelectionEffects, @@ -2293,8 +2299,8 @@ mod tests { warning: None, }; let session_capabilities = SessionCapabilities::new( - acp::PromptCapabilities::default(), - vec![acp::AvailableCommand::new("help", "Get help")], + acp_v1::PromptCapabilities::default(), + vec![acp_v1::AvailableCommand::new("help", "Get help")], vec![skill], ); @@ -2308,17 +2314,17 @@ mod tests { #[test] fn test_completion_commands_derive_category_from_meta() { let session_capabilities = SessionCapabilities::new( - acp::PromptCapabilities::default(), + acp_v1::PromptCapabilities::default(), vec![ - acp::AvailableCommand::new("compact", "Built-in").meta( + acp_v1::AvailableCommand::new("compact", "Built-in").meta( acp_thread::meta_with_command_category(acp_thread::CommandCategory::Native), ), - acp::AvailableCommand::new("deploy", "MCP").meta( + acp_v1::AvailableCommand::new("deploy", "MCP").meta( acp_thread::meta_with_command_category(acp_thread::CommandCategory::Mcp), ), // No category meta: this is how external ACP agents' commands // arrive, and they should group on their own. - acp::AvailableCommand::new("help", "External"), + acp_v1::AvailableCommand::new("help", "External"), ], Vec::new(), ); @@ -2354,7 +2360,7 @@ mod tests { // `/:`); project-local skills carry their worktree root // name. The empty-scope encoding means a worktree literally // named `global` no longer collides with the global source. - let commands = vec![acp::AvailableCommand::new("help", "Get help")]; + let commands = vec![acp_v1::AvailableCommand::new("help", "Get help")]; let skills = vec![make_skill("deploy", ""), make_skill("deploy", "zed")]; let no_skills = Vec::new(); @@ -2613,7 +2619,7 @@ mod tests { .unwrap(); // We don't send a resource link for the deleted crease. - pretty_assertions::assert_matches!(content.as_slice(), [acp::ContentBlock::Text { .. }]); + pretty_assertions::assert_matches!(content.as_slice(), [acp_v1::ContentBlock::Text { .. }]); } #[gpui::test] @@ -2636,7 +2642,7 @@ mod tests { let project = Project::test(fs.clone(), ["/test".as_ref()], cx).await; let thread_store = None; let session_capabilities = Arc::new(RwLock::new(SessionCapabilities::from_acp_commands( - acp::PromptCapabilities::default(), + acp_v1::PromptCapabilities::default(), vec![], ))); @@ -2682,7 +2688,7 @@ mod tests { // Now simulate Claude providing its list of available commands (which doesn't include file) session_capabilities .write() - .set_available_commands(vec![acp::AvailableCommand::new("help", "Get help")]); + .set_available_commands(vec![acp_v1::AvailableCommand::new("help", "Get help")]); // Test that unsupported slash commands trigger an error when we have a list of available commands editor.update_in(cx, |editor, window, cx| { @@ -2722,7 +2728,7 @@ mod tests { .unwrap(); assert_eq!(content.len(), 1); - if let acp::ContentBlock::Text(text) = &content[0] { + if let acp_v1::ContentBlock::Text(text) = &content[0] { assert_eq!(text.text, "Hello Claude!"); } else { panic!("Expected ContentBlock::Text"); @@ -2740,7 +2746,7 @@ mod tests { .unwrap(); assert_eq!(content.len(), 1); - if let acp::ContentBlock::Text(text) = &content[0] { + if let acp_v1::ContentBlock::Text(text) = &content[0] { assert_eq!(text.text, "Check this @"); } else { panic!("Expected ContentBlock::Text"); @@ -2797,13 +2803,13 @@ mod tests { let thread_store = None; let session_capabilities = Arc::new(RwLock::new(SessionCapabilities::from_acp_commands( - acp::PromptCapabilities::default(), + acp_v1::PromptCapabilities::default(), vec![ - acp::AvailableCommand::new("quick-math", "2 + 2 = 4 - 1 = 3"), - acp::AvailableCommand::new("say-hello", "Say hello to whoever you want").input( - acp::AvailableCommandInput::Unstructured(acp::UnstructuredCommandInput::new( - "", - )), + acp_v1::AvailableCommand::new("quick-math", "2 + 2 = 4 - 1 = 3"), + acp_v1::AvailableCommand::new("say-hello", "Say hello to whoever you want").input( + acp_v1::AvailableCommandInput::Unstructured( + acp_v1::UnstructuredCommandInput::new(""), + ), ), ], ))); @@ -2968,7 +2974,7 @@ mod tests { let mut cx = VisualTestContext::from_window(window.into(), cx); let session_capabilities = Arc::new(RwLock::new(SessionCapabilities::from_acp_commands( - acp::PromptCapabilities::default(), + acp_v1::PromptCapabilities::default(), Vec::new(), ))); @@ -3082,8 +3088,8 @@ mod tests { let mut cx = VisualTestContext::from_window(window.into(), cx); let session_capabilities = Arc::new(RwLock::new(SessionCapabilities::from_acp_commands( - acp::PromptCapabilities::default(), - vec![acp::AvailableCommand::new("hello", "Say hello")], + acp_v1::PromptCapabilities::default(), + vec![acp_v1::AvailableCommand::new("hello", "Say hello")], ))); // Track every event emitted by the message editor across the @@ -3236,7 +3242,7 @@ mod tests { let thread_store = cx.new(|cx| ThreadStore::new(cx)); let session_capabilities = Arc::new(RwLock::new(SessionCapabilities::from_acp_commands( - acp::PromptCapabilities::default(), + acp_v1::PromptCapabilities::default(), vec![], ))); @@ -3295,7 +3301,7 @@ mod tests { message_editor.update(&mut cx, |editor, _cx| { editor.session_capabilities.write().set_prompt_capabilities( - acp::PromptCapabilities::new() + acp_v1::PromptCapabilities::new() .image(true) .audio(true) .embedded_context(true), @@ -3750,10 +3756,9 @@ mod tests { cx, ); // Enable embedded context so files are actually included - editor - .session_capabilities - .write() - .set_prompt_capabilities(acp::PromptCapabilities::new().embedded_context(true)); + editor.session_capabilities.write().set_prompt_capabilities( + acp_v1::PromptCapabilities::new().embedded_context(true), + ); editor }) }); @@ -3830,7 +3835,7 @@ mod tests { let thread_store = Some(cx.new(|cx| ThreadStore::new(cx))); - let session_id = acp::SessionId::new("thread-123"); + let session_id = acp_v1::SessionId::new("thread-123"); let title = Some("Previous Conversation".into()); let message_editor = cx.update(|window, cx| { @@ -3918,7 +3923,7 @@ mod tests { cx, ); editor.insert_thread_summary( - acp::SessionId::new("thread-123"), + acp_v1::SessionId::new("thread-123"), Some("Previous Conversation".into()), window, cx, @@ -3976,7 +3981,7 @@ mod tests { editor .session_capabilities .write() - .set_prompt_capabilities(acp::PromptCapabilities::new().embedded_context(true)); + .set_prompt_capabilities(acp_v1::PromptCapabilities::new().embedded_context(true)); }); let supported_modes = { @@ -4032,7 +4037,7 @@ mod tests { editor .session_capabilities .write() - .set_prompt_capabilities(acp::PromptCapabilities::new().embedded_context(true)); + .set_prompt_capabilities(acp_v1::PromptCapabilities::new().embedded_context(true)); }); let supported_modes = { @@ -4184,7 +4189,10 @@ mod tests { content, vec![ "What is in ".into(), - acp::ContentBlock::ResourceLink(acp::ResourceLink::new("main.rs", main_rs_uri)) + acp_v1::ContentBlock::ResourceLink(acp_v1::ResourceLink::new( + "main.rs", + main_rs_uri + )) ] ); @@ -4192,7 +4200,7 @@ mod tests { editor .session_capabilities .write() - .set_prompt_capabilities(acp::PromptCapabilities::new().embedded_context(true)) + .set_prompt_capabilities(acp_v1::PromptCapabilities::new().embedded_context(true)) }); let content = message_editor @@ -4206,9 +4214,9 @@ mod tests { content, vec![ "What is in ".into(), - acp::ContentBlock::Resource(acp::EmbeddedResource::new( - acp::EmbeddedResourceResource::TextResourceContents( - acp::TextResourceContents::new(file_content, main_rs_uri) + acp_v1::ContentBlock::Resource(acp_v1::EmbeddedResource::new( + acp_v1::EmbeddedResourceResource::TextResourceContents( + acp_v1::TextResourceContents::new(file_content, main_rs_uri) ) )) ] @@ -4891,27 +4899,26 @@ mod tests { editor .session_capabilities .write() - .set_prompt_capabilities(acp::PromptCapabilities::new().embedded_context(true)); + .set_prompt_capabilities(acp_v1::PromptCapabilities::new().embedded_context(true)); editor.draft_content_blocks_snapshot(cx) }); // Each selection mention must round-trip as a `Resource` block carrying // its URI and content, not as a `Text` block containing the fold // placeholder string. - let resource_uris: Vec<&str> = - blocks - .iter() - .filter_map(|block| match block { - acp::ContentBlock::Resource(acp::EmbeddedResource { - resource: - acp::EmbeddedResourceResource::TextResourceContents( - acp::TextResourceContents { uri, .. }, - ), - .. - }) => Some(uri.as_str()), - _ => None, - }) - .collect(); + let resource_uris: Vec<&str> = blocks + .iter() + .filter_map(|block| match block { + acp_v1::ContentBlock::Resource(acp_v1::EmbeddedResource { + resource: + acp_v1::EmbeddedResourceResource::TextResourceContents( + acp_v1::TextResourceContents { uri, .. }, + ), + .. + }) => Some(uri.as_str()), + _ => None, + }) + .collect(); assert_eq!( resource_uris.len(), 2, @@ -4919,7 +4926,7 @@ mod tests { ); assert!(resource_uris.contains(&fixture.first_uri.to_uri().to_string().as_str())); for block in &blocks { - if let acp::ContentBlock::Text(text) = block { + if let acp_v1::ContentBlock::Text(text) = block { assert!( !text.text.split_whitespace().any(|word| word == "selection"), "text block must not contain bare fold placeholder: {:?}", @@ -5321,7 +5328,7 @@ mod tests { message_editor .session_capabilities .write() - .set_prompt_capabilities(acp::PromptCapabilities::new().image(true)); + .set_prompt_capabilities(acp_v1::PromptCapabilities::new().image(true)); }); let temporary_image_path = write_test_png_file(None); @@ -5559,7 +5566,7 @@ mod tests { message_editor.update_in(cx, |editor, window, cx| { editor.set_message( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "hello world".to_string(), ))], window, @@ -5580,8 +5587,8 @@ mod tests { message_editor.update_in(cx, |editor, window, cx| { editor.set_message( vec![ - acp::ContentBlock::Text(acp::TextContent::new("before\r\n".to_string())), - acp::ContentBlock::ResourceLink(acp::ResourceLink::new( + acp_v1::ContentBlock::Text(acp_v1::TextContent::new("before\r\n".to_string())), + acp_v1::ContentBlock::ResourceLink(acp_v1::ResourceLink::new( "file.txt", "file:///project/file.txt", )), @@ -5607,7 +5614,7 @@ mod tests { // Set initial content. message_editor.update_in(cx, |editor, window, cx| { editor.set_message( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "old content".to_string(), ))], window, @@ -5618,7 +5625,7 @@ mod tests { // Replace with new content. message_editor.update_in(cx, |editor, window, cx| { editor.set_message( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "new content".to_string(), ))], window, @@ -5640,7 +5647,7 @@ mod tests { message_editor.update_in(cx, |editor, window, cx| { editor.append_message( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "appended".to_string(), ))], Some("\n\n"), @@ -5664,7 +5671,7 @@ mod tests { // Seed initial content. message_editor.update_in(cx, |editor, window, cx| { editor.set_message( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "initial".to_string(), ))], window, @@ -5675,7 +5682,7 @@ mod tests { // Append with separator. message_editor.update_in(cx, |editor, window, cx| { editor.append_message( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "appended".to_string(), ))], Some("\n\n"), @@ -5728,7 +5735,7 @@ mod tests { // Seed plain-text prefix so the editor is non-empty before appending. message_editor.update_in(cx, |editor, window, cx| { editor.set_message( - vec![acp::ContentBlock::Text(acp::TextContent::new( + vec![acp_v1::ContentBlock::Text(acp_v1::TextContent::new( "prefix text".to_string(), ))], window, @@ -5739,10 +5746,9 @@ mod tests { // Append a message that contains a ResourceLink mention. message_editor.update_in(cx, |editor, window, cx| { editor.append_message( - vec![acp::ContentBlock::ResourceLink(acp::ResourceLink::new( - "file.txt", - "file:///project/file.txt", - ))], + vec![acp_v1::ContentBlock::ResourceLink( + acp_v1::ResourceLink::new("file.txt", "file:///project/file.txt"), + )], Some("\n\n"), window, cx,