Use explicit ACP v1 namespace aliases

This commit is contained in:
Ben Brandt
2026-09-24 21:57:15 +02:00
parent 3ab0b5df18
commit b166b0c52d
9 changed files with 2038 additions and 1903 deletions
File diff suppressed because it is too large Load Diff
+81 -71
View File
@@ -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<Self>,
_session_id: acp::SessionId,
_session_id: acp_v1::SessionId,
_project: Entity<Project>,
_work_dirs: PathList,
_title: Option<SharedString>,
@@ -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<Self>,
_session_id: &acp::SessionId,
_session_id: &acp_v1::SessionId,
_cx: &mut App,
) -> Task<Result<()>> {
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<Self>,
_session_id: acp::SessionId,
_session_id: acp_v1::SessionId,
_project: Entity<Project>,
_work_dirs: PathList,
_title: Option<SharedString>,
@@ -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<Task<Result<SpawnInTerminal>>> {
None
}
fn authenticate(&self, method: acp::AuthMethodId, cx: &mut App) -> Task<Result<()>>;
fn authenticate(&self, method: acp_v1::AuthMethodId, cx: &mut App) -> Task<Result<()>>;
fn supports_logout(&self) -> bool {
false
@@ -192,14 +192,21 @@ pub trait AgentConnection {
None
}
fn prompt(&self, params: acp::PromptRequest, cx: &mut App)
-> Task<Result<acp::PromptResponse>>;
fn prompt(
&self,
params: acp_v1::PromptRequest,
cx: &mut App,
) -> Task<Result<acp_v1::PromptResponse>>;
fn retry(&self, _session_id: &acp::SessionId, _cx: &App) -> Option<Rc<dyn AgentSessionRetry>> {
fn retry(
&self,
_session_id: &acp_v1::SessionId,
_cx: &App,
) -> Option<Rc<dyn AgentSessionRetry>> {
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<Rc<dyn AgentSessionTruncate>> {
None
@@ -218,7 +225,7 @@ pub trait AgentConnection {
fn set_title(
&self,
_session_id: &acp::SessionId,
_session_id: &acp_v1::SessionId,
_cx: &App,
) -> Option<Rc<dyn AgentSessionSetTitle>> {
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<Rc<dyn AgentModelSelector>> {
fn model_selector(
&self,
_session_id: &acp_v1::SessionId,
) -> Option<Rc<dyn AgentModelSelector>> {
None
}
@@ -238,7 +248,7 @@ pub trait AgentConnection {
fn session_modes(
&self,
_session_id: &acp::SessionId,
_session_id: &acp_v1::SessionId,
_cx: &App,
) -> Option<Rc<dyn AgentSessionModes>> {
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<Rc<dyn AgentSessionConfigOptions>> {
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<Result<acp::PromptResponse>>;
) -> Task<Result<acp_v1::PromptResponse>>;
}
pub trait AgentSessionRetry {
fn run(&self, cx: &mut App) -> Task<Result<acp::PromptResponse>>;
fn run(&self, cx: &mut App) -> Task<Result<acp_v1::PromptResponse>>;
}
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<Result<serde_json::Value>>;
}
pub trait AgentSessionModes {
fn current_mode(&self) -> acp::SessionModeId;
fn current_mode(&self) -> acp_v1::SessionModeId;
fn all_modes(&self) -> Vec<acp::SessionMode>;
fn all_modes(&self) -> Vec<acp_v1::SessionMode>;
fn set_mode(&self, mode: acp::SessionModeId, cx: &mut App) -> Task<Result<()>>;
fn set_mode(&self, mode: acp_v1::SessionModeId, cx: &mut App) -> Task<Result<()>>;
}
pub trait AgentSessionConfigOptions {
/// Get all current config options with their state
fn config_options(&self) -> Vec<acp::SessionConfigOption>;
fn config_options(&self) -> Vec<acp_v1::SessionConfigOption>;
/// 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<Result<Vec<acp::SessionConfigOption>>>;
) -> Task<Result<Vec<acp_v1::SessionConfigOption>>>;
/// 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<PathBuf>,
pub cursor: Option<String>,
pub meta: Option<acp::Meta>,
pub meta: Option<acp_v1::Meta>,
}
#[derive(Debug, Clone)]
pub struct AgentSessionListResponse {
pub sessions: Vec<AgentSessionInfo>,
pub next_cursor: Option<String>,
pub meta: Option<acp::Meta>,
pub meta: Option<acp_v1::Meta>,
}
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<PathList>,
pub title: Option<SharedString>,
pub updated_at: Option<DateTime<Utc>>,
pub created_at: Option<DateTime<Utc>>,
pub meta: Option<acp::Meta>,
pub meta: Option<acp_v1::Meta>,
}
impl AgentSessionInfo {
pub fn new(session_id: impl Into<acp::SessionId>) -> Self {
pub fn new(session_id: impl Into<acp_v1::SessionId>) -> 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<Result<()>> {
fn delete_session(&self, _session_id: &acp_v1::SessionId, _cx: &mut App) -> Task<Result<()>> {
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<String>,
}
@@ -578,7 +588,7 @@ pub struct PermissionPattern {
#[derive(Debug, Clone)]
pub enum PermissionOptions {
Flat(Vec<acp::PermissionOption>),
Flat(Vec<acp_v1::PermissionOption>),
Dropdown(Vec<PermissionOptionChoice>),
DropdownWithPatterns {
choices: Vec<PermissionOptionChoice>,
@@ -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<acp::PermissionOptionId> {
self.first_option_of_kind(acp::PermissionOptionKind::AllowOnce)
pub fn allow_once_option_id(&self) -> Option<acp_v1::PermissionOptionId> {
self.first_option_of_kind(acp_v1::PermissionOptionKind::AllowOnce)
.map(|option| option.option_id.clone())
}
pub fn deny_once_option_id(&self) -> Option<acp::PermissionOptionId> {
self.first_option_of_kind(acp::PermissionOptionKind::RejectOnce)
pub fn deny_once_option_id(&self) -> Option<acp_v1::PermissionOptionId> {
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<Mutex<HashMap<acp::SessionId, Session>>>,
permission_requests: HashMap<acp::ToolCallId, PermissionOptions>,
next_prompt_updates: Arc<Mutex<Vec<acp::SessionUpdate>>>,
sessions: Arc<Mutex<HashMap<acp_v1::SessionId, Session>>>,
permission_requests: HashMap<acp_v1::ToolCallId, PermissionOptions>,
next_prompt_updates: Arc<Mutex<Vec<acp_v1::SessionUpdate>>>,
supports_load_session: bool,
supports_session_additional_directories: bool,
agent_id: AgentId,
@@ -765,7 +775,7 @@ mod test_support {
struct Session {
thread: WeakEntity<AcpThread>,
response_tx: Option<oneshot::Sender<acp::StopReason>>,
response_tx: Option<oneshot::Sender<acp_v1::StopReason>>,
}
impl Default for StubAgentConnection {
@@ -787,13 +797,13 @@ mod test_support {
}
}
pub fn set_next_prompt_updates(&self, updates: Vec<acp::SessionUpdate>) {
pub fn set_next_prompt_updates(&self, updates: Vec<acp_v1::SessionUpdate>) {
*self.next_prompt_updates.lock() = updates;
}
pub fn with_permission_requests(
mut self,
permission_requests: HashMap<acp::ToolCallId, PermissionOptions>,
permission_requests: HashMap<acp_v1::ToolCallId, PermissionOptions>,
) -> Self {
self.permission_requests = permission_requests;
self
@@ -824,7 +834,7 @@ mod test_support {
fn create_session(
self: Rc<Self>,
session_id: acp::SessionId,
session_id: acp_v1::SessionId,
project: Entity<Project>,
work_dirs: PathList,
title: Option<SharedString>,
@@ -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<Rc<dyn AgentModelSelector>> {
Some(self.model_selector_impl())
}
@@ -920,7 +930,7 @@ mod test_support {
work_dirs: PathList,
cx: &mut gpui::App,
) -> Task<gpui::Result<Entity<AcpThread>>> {
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<Self>,
session_id: acp::SessionId,
session_id: acp_v1::SessionId,
project: Entity<Project>,
work_dirs: PathList,
title: Option<SharedString>,
@@ -951,7 +961,7 @@ mod test_support {
fn authenticate(
&self,
_method_id: acp::AuthMethodId,
_method_id: acp_v1::AuthMethodId,
_cx: &mut App,
) -> Task<gpui::Result<()>> {
unimplemented!()
@@ -959,9 +969,9 @@ mod test_support {
fn prompt(
&self,
params: acp::PromptRequest,
params: acp_v1::PromptRequest,
cx: &mut App,
) -> Task<gpui::Result<acp::PromptResponse>> {
) -> Task<gpui::Result<acp_v1::PromptResponse>> {
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<Rc<dyn AgentSessionSetTitle>> {
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<Rc<dyn AgentSessionTruncate>> {
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<Result<acp::PromptResponse>> {
) -> Task<Result<acp_v1::PromptResponse>> {
self.connection.prompt(params, cx)
}
}
+120 -118
View File
@@ -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<Vec<acp::ContentBlock>> {
fn draft_prompt(&self, cx: &App) -> Option<Vec<acp_v1::ContentBlock>> {
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<acp::SessionId, Session>,
pending_sessions: HashMap<acp::SessionId, PendingSession>,
sessions: HashMap<acp_v1::SessionId, Session>,
pending_sessions: HashMap<acp_v1::SessionId, PendingSession>,
thread_store: Entity<ThreadStore>,
/// Project-specific state keyed by project EntityId
projects: HashMap<EntityId, ProjectState>,
@@ -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<acp::AvailableCommand> {
) -> Vec<acp_v1::AvailableCommand> {
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<Project>,
cx: &mut Context<Self>,
) -> Task<Result<Entity<Thread>>> {
@@ -1678,7 +1678,7 @@ impl NativeAgent {
pub fn open_thread(
&mut self,
id: acp::SessionId,
id: acp_v1::SessionId,
project: Entity<Project>,
cx: &mut Context<Self>,
) -> Task<Result<Entity<AcpThread>>> {
@@ -1748,7 +1748,7 @@ impl NativeAgent {
pub fn thread_summary(
&mut self,
id: acp::SessionId,
id: acp_v1::SessionId,
project: Entity<Project>,
cx: &mut Context<Self>,
) -> Task<Result<SharedString>> {
@@ -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<Vec<acp::ContentBlock>>,
draft_prompt: Option<Vec<acp_v1::ContentBlock>>,
cx: &mut Context<Self>,
) {
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<Vec<acp::ContentBlock>>,
id: &acp_v1::SessionId,
draft_prompt: Option<Vec<acp_v1::ContentBlock>>,
cx: &mut Context<Self>,
) {
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<Mutex<Option<PendingThreadSave>>>,
database_future: Shared<Task<Result<Arc<ThreadsDatabase>, Arc<anyhow::Error>>>>,
@@ -1874,9 +1874,9 @@ impl NativeAgent {
fn thread_save_payload(
&self,
session: &Session,
draft_prompt: Option<Vec<acp::ContentBlock>>,
draft_prompt: Option<Vec<acp_v1::ContentBlock>>,
cx: &mut App,
) -> Option<(acp::SessionId, PathList, Task<DbThread>)> {
) -> Option<(acp_v1::SessionId, PathList, Task<DbThread>)> {
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<String, String>,
original_content: Vec<acp::ContentBlock>,
original_content: Vec<acp_v1::ContentBlock>,
cx: &mut Context<Self>,
) -> Task<Result<acp::PromptResponse>> {
) -> Task<Result<acp_v1::PromptResponse>> {
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<Self>,
) -> Task<Result<acp::PromptResponse>> {
) -> Task<Result<acp_v1::PromptResponse>> {
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<acp::ContentBlock>,
original_content: Vec<acp_v1::ContentBlock>,
cx: &mut Context<Self>,
) -> Task<Result<acp::PromptResponse>> {
) -> Task<Result<acp_v1::PromptResponse>> {
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<NativeAgent>);
impl NativeAgentConnection {
pub fn thread(&self, session_id: &acp::SessionId, cx: &App) -> Option<Entity<Thread>> {
pub fn thread(&self, session_id: &acp_v1::SessionId, cx: &App) -> Option<Entity<Thread>> {
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<NativeAvailableSkill> {
self.0
@@ -2242,7 +2242,7 @@ impl NativeAgentConnection {
pub fn load_thread(
&self,
id: acp::SessionId,
id: acp_v1::SessionId,
project: Entity<Project>,
cx: &mut App,
) -> Task<Result<Entity<Thread>>> {
@@ -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<Thread>, &mut App) -> Result<mpsc::UnboundedReceiver<Result<ThreadEvent>>>,
) -> Task<Result<acp::PromptResponse>> {
) -> Task<Result<acp_v1::PromptResponse>> {
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<AcpThread>,
connection: Option<NativeAgentConnection>,
cx: &App,
) -> Task<Result<acp::PromptResponse>> {
) -> Task<Result<acp_v1::PromptResponse>> {
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<Self> {
let acp::ContentBlock::Text(text_content) = prompt.first()? else {
fn parse(prompt: &'a [acp_v1::ContentBlock]) -> Option<Self> {
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<Self>,
session_id: acp::SessionId,
session_id: acp_v1::SessionId,
project: Entity<Project>,
_work_dirs: PathList,
_title: Option<SharedString>,
@@ -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<Result<()>> {
fn authenticate(&self, _method: acp_v1::AuthMethodId, _cx: &mut App) -> Task<Result<()>> {
Task::ready(Ok(()))
}
fn model_selector(&self, session_id: &acp::SessionId) -> Option<Rc<dyn AgentModelSelector>> {
fn model_selector(&self, session_id: &acp_v1::SessionId) -> Option<Rc<dyn AgentModelSelector>> {
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<Result<acp::PromptResponse>> {
) -> Task<Result<acp_v1::PromptResponse>> {
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<Rc<dyn acp_thread::AgentSessionRetry>> {
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<Rc<dyn acp_thread::AgentSessionTruncate>> {
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<Rc<dyn acp_thread::AgentSessionSetTitle>> {
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<Result<acp::PromptResponse>> {
) -> Task<Result<acp_v1::PromptResponse>> {
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<Result<serde_json::Value>> {
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<Result<()>> {
fn delete_session(&self, session_id: &acp_v1::SessionId, cx: &mut App) -> Task<Result<()>> {
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<Result<acp::PromptResponse>> {
fn run(&self, cx: &mut App) -> Task<Result<acp_v1::PromptResponse>> {
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<Rc<dyn SubagentHandle>> {
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<Thread>,
acp_thread: Entity<acp_thread::AcpThread>,
) -> Result<Rc<dyn SubagentHandle>> {
@@ -3350,7 +3350,7 @@ impl ThreadEnvironment for NativeThreadEnvironment {
fn create_terminal(
&self,
command: String,
extra_env: Vec<acp::EnvVariable>,
extra_env: Vec<acp_v1::EnvVariable>,
cwd: Option<PathBuf>,
output_byte_limit: Option<u64>,
sandbox_wrap: Option<acp_thread::SandboxWrap>,
@@ -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<Rc<dyn SubagentHandle>> {
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<Thread>,
subagent_thread: Entity<Thread>,
acp_thread: Entity<acp_thread::AcpThread>,
@@ -3512,7 +3512,7 @@ pub struct NativeSubagentHandle {
impl NativeSubagentHandle {
fn new(
session_id: acp::SessionId,
session_id: acp_v1::SessionId,
subagent_thread: Entity<Thread>,
acp_thread: Entity<acp_thread::AcpThread>,
parent_thread_entity: Entity<Thread>,
@@ -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<acp::TerminalId> {
fn id(&self, cx: &AsyncApp) -> Result<acp_v1::TerminalId> {
Ok(self.terminal.read_with(cx, |term, _cx| term.id().clone()))
}
fn wait_for_exit(&self, cx: &AsyncApp) -> Result<Shared<Task<acp::TerminalExitStatus>>> {
fn wait_for_exit(&self, cx: &AsyncApp) -> Result<Shared<Task<acp_v1::TerminalExitStatus>>> {
self.terminal
.read_with(cx, |term, _cx| term.wait_for_exit())
}
fn current_output(&self, cx: &AsyncApp) -> Result<acp::TerminalOutputResponse> {
fn current_output(&self, cx: &AsyncApp) -> Result<acp_v1::TerminalOutputResponse> {
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<NativeAgent>,
session_id: &acp::SessionId,
session_id: &acp_v1::SessionId,
cx: &App,
) -> Entity<Thread> {
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<NativeAgent>,
Rc<NativeAgentConnection>,
Entity<Project>,
acp::SessionId,
acp_v1::SessionId,
Arc<FakeLanguageModelProvider>,
) {
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<ThreadStore>,
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<NativeAgent>,
acp_thread: &Entity<AcpThread>,
thread: &Entity<Thread>,
draft: Vec<acp::ContentBlock>,
draft: Vec<acp_v1::ContentBlock>,
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)
}
}
}
File diff suppressed because it is too large Load Diff
@@ -7,7 +7,7 @@ pub struct QueueEntryId(usize);
pub struct QueueEntry {
pub id: QueueEntryId,
pub content: Vec<acp::ContentBlock>,
pub content: Vec<acp_v1::ContentBlock>,
pub tracked_buffers: Vec<Entity<Buffer>>,
/// When true, this message interrupts the agent at the next turn boundary
/// instead of waiting for generation to fully complete. Only the front
@@ -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,
);
@@ -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<acp::SessionId>,
pub session_id: acp_v1::SessionId,
pub parent_session_id: Option<acp_v1::SessionId>,
pub thread: Entity<AcpThread>,
pub(crate) conversation: Entity<super::Conversation>,
pub server_view: WeakEntity<ConversationView>,
@@ -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<acp::ToolCallId>,
collapsed_sandbox_authorization_details: HashSet<acp::ToolCallId>,
collapsed_sandbox_network_details: HashSet<acp::ToolCallId>,
pub expanded_tool_call_raw_inputs: HashSet<acp_v1::ToolCallId>,
collapsed_sandbox_authorization_details: HashSet<acp_v1::ToolCallId>,
collapsed_sandbox_network_details: HashSet<acp_v1::ToolCallId>,
/// 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<acp::ToolCallId>,
pub subagent_scroll_handles: RefCell<HashMap<acp::SessionId, ScrollHandle>>,
acknowledged_confusable_warnings: HashSet<acp_v1::ToolCallId>,
pub subagent_scroll_handles: RefCell<HashMap<acp_v1::SessionId, ScrollHandle>>,
pub edits_expanded: bool,
pub plan_expanded: bool,
pub queue_expanded: bool,
@@ -607,18 +607,18 @@ pub struct ThreadView {
pub editing_message: Option<usize>,
pub message_queue: MessageQueue,
pub turn_fields: TurnFields,
pub discarded_partial_edits: HashSet<acp::ToolCallId>,
pub discarded_partial_edits: HashSet<acp_v1::ToolCallId>,
pub is_loading_contents: bool,
pub new_server_version_available: Option<SharedString>,
pub resumed_without_history: bool,
pub(crate) permission_selections: HashMap<acp::ToolCallId, PermissionSelection>,
pub(crate) permission_selections: HashMap<acp_v1::ToolCallId, PermissionSelection>,
elicitation_form_states: HashMap<ElicitationEntryId, ElicitationFormState>,
pub _cancel_task: Option<Task<()>>,
_save_task: Option<Task<()>>,
_draft_resolve_task: Option<Task<()>>,
_sandbox_status_refresh_task: Option<Task<()>>,
pub hovered_edited_file_buttons: Option<usize>,
pub in_flight_prompt: Option<Vec<acp::ContentBlock>>,
pub in_flight_prompt: Option<Vec<acp_v1::ContentBlock>>,
pub _subscriptions: Vec<Subscription>,
pub message_editor: Entity<MessageEditor>,
pub add_context_menu_handle: PopoverMenuHandle<ContextMenu>,
@@ -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<MessageEditor>,
cx: &mut App,
) -> Task<Result<(Vec<acp::ContentBlock>, Vec<Entity<Buffer>>)>> {
) -> Task<Result<(Vec<acp_v1::ContentBlock>, Vec<Entity<Buffer>>)>> {
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<anyhow::Result<Option<(Vec<acp::ContentBlock>, Vec<Entity<Buffer>>)>>>,
contents_task: Task<
anyhow::Result<Option<(Vec<acp_v1::ContentBlock>, Vec<Entity<Buffer>>)>>,
>,
is_native_command: bool,
window: &mut Window,
cx: &mut Context<Self>,
@@ -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<acp::ContentBlock>,
content: Vec<acp_v1::ContentBlock>,
tracked_buffers: Vec<Entity<Buffer>>,
window: &mut Window,
cx: &mut Context<Self>,
@@ -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<Self>,
@@ -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<Self>) {
@@ -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<Self>,
) -> 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<Self>,
) {
let session_id = self.session_id.clone();
@@ -2769,14 +2771,14 @@ impl ThreadView {
window: &mut Window,
cx: &mut Context<Self>,
) {
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<Self>,
) {
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<Self>,
) {
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<Self>,
@@ -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<acp_thread::Terminal>,
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<Self>,
@@ -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<unicode_confusables::SuspiciousChar>)],
window: &Window,
cx: &Context<Self>,
@@ -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<Self>,
@@ -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<Self>,
@@ -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<Self>,
) -> 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<Self>,
) -> Div {
let mut seen_kinds: ArrayVec<acp::PermissionOptionKind, 3, u8> = ArrayVec::new();
let mut seen_kinds: ArrayVec<acp_v1::PermissionOptionKind, 3, u8> = 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<Self>,
) -> 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<Self>,
@@ -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<Self>,
) -> AnyElement {
let uri: SharedString = resource_link.uri.clone().into();
@@ -10567,7 +10569,7 @@ impl ThreadView {
&self,
entry_ix: usize,
image: Arc<gpui::Image>,
location: Option<acp::ToolCallLocation>,
location: Option<acp_v1::ToolCallLocation>,
card_layout: bool,
cx: &Context<Self>,
) -> 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<acp::SessionId>,
subagent_session_id: Option<acp_v1::SessionId>,
focus_handle: &FocusHandle,
window: &Window,
cx: &Context<Self>,
@@ -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<ThreadView>>,
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<String> {
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,
))
}
+21 -21
View File
@@ -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<usize>,
expanded_tool_calls: HashSet<acp::ToolCallId>,
expanded_tool_calls: HashSet<acp_v1::ToolCallId>,
}
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<MessageEditor>, 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,
);
+108 -102
View File
@@ -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<acp::AvailableCommand>,
prompt_capabilities: acp_v1::PromptCapabilities,
available_commands: Vec<acp_v1::AvailableCommand>,
available_skills: Vec<AvailableSkill>,
}
impl SessionCapabilities {
pub fn new(
prompt_capabilities: acp::PromptCapabilities,
available_commands: Vec<acp::AvailableCommand>,
prompt_capabilities: acp_v1::PromptCapabilities,
available_commands: Vec<acp_v1::AvailableCommand>,
available_skills: Vec<AvailableSkill>,
) -> Self {
Self {
@@ -66,8 +66,8 @@ impl SessionCapabilities {
}
pub fn from_acp_commands(
prompt_capabilities: acp::PromptCapabilities,
available_commands: Vec<acp::AvailableCommand>,
prompt_capabilities: acp_v1::PromptCapabilities,
available_commands: Vec<acp_v1::AvailableCommand>,
) -> 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<acp::AvailableCommand>) {
pub fn set_available_commands(&mut self, available_commands: Vec<acp_v1::AvailableCommand>) {
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<SharedString>,
window: &mut Window,
cx: &mut Context<Self>,
@@ -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 `/:<name>`.
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<Self>,
) -> Task<Result<(Vec<acp::ContentBlock>, Vec<Entity<Buffer>>)>> {
) -> Task<Result<(Vec<acp_v1::ContentBlock>, Vec<Entity<Buffer>>)>> {
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<Self>) -> Task<Result<Vec<acp::ContentBlock>>> {
pub fn draft_contents(
&self,
cx: &mut Context<Self>,
) -> Task<Result<Vec<acp_v1::ContentBlock>>> {
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<Self>,
) -> Task<Result<(Vec<acp::ContentBlock>, Vec<Entity<Buffer>>)>> {
) -> Task<Result<(Vec<acp_v1::ContentBlock>, Vec<Entity<Buffer>>)>> {
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<acp::ContentBlock> {
pub fn draft_content_blocks_snapshot(&self, cx: &App) -> Vec<acp_v1::ContentBlock> {
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<acp::ContentBlock>,
message: Vec<acp_v1::ContentBlock>,
window: &mut Window,
cx: &mut Context<Self>,
) {
@@ -1694,7 +1697,7 @@ impl MessageEditor {
pub fn append_message(
&mut self,
message: Vec<acp::ContentBlock>,
message: Vec<acp_v1::ContentBlock>,
separator: Option<&str>,
window: &mut Window,
cx: &mut Context<Self>,
@@ -1717,7 +1720,7 @@ impl MessageEditor {
fn insert_message_blocks(
&mut self,
message: Vec<acp::ContentBlock>,
message: Vec<acp_v1::ContentBlock>,
append_to_existing: bool,
window: &mut Window,
cx: &mut Context<Self>,
@@ -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<Mention>)>,
) -> (Vec<acp::ContentBlock>, Vec<Entity<Buffer>>) {
) -> (Vec<acp_v1::ContentBlock>, Vec<Entity<Buffer>>) {
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<Entity<Buffer>>,
) -> 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 {
// `/:<name>`); 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(
"<name>",
)),
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("<name>"),
),
),
],
)));
@@ -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,