Handle auth for claude (#36442)

We'll now use the anthropic provider to get credentials for `claude` and
embed its configuration view in the panel when they are not present.

Release Notes:

- N/A
This commit is contained in:
Agus Zubiaga 2025-08-18 17:40:59 -03:00 committed by GitHub
parent 50819a9d20
commit 8b89ea1a80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 400 additions and 124 deletions

View file

@ -1,8 +1,8 @@
use crate::{
AuthenticateError, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent,
LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId,
LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest,
LanguageModelToolChoice,
AuthenticateError, ConfigurationViewTargetAgent, LanguageModel, LanguageModelCompletionError,
LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider,
LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState,
LanguageModelRequest, LanguageModelToolChoice,
};
use futures::{FutureExt, StreamExt, channel::mpsc, future::BoxFuture, stream::BoxStream};
use gpui::{AnyView, App, AsyncApp, Entity, Task, Window};
@ -62,7 +62,12 @@ impl LanguageModelProvider for FakeLanguageModelProvider {
Task::ready(Ok(()))
}
fn configuration_view(&self, _window: &mut Window, _: &mut App) -> AnyView {
fn configuration_view(
&self,
_target_agent: ConfigurationViewTargetAgent,
_window: &mut Window,
_: &mut App,
) -> AnyView {
unimplemented!()
}

View file

@ -634,7 +634,12 @@ pub trait LanguageModelProvider: 'static {
}
fn is_authenticated(&self, cx: &App) -> bool;
fn authenticate(&self, cx: &mut App) -> Task<Result<(), AuthenticateError>>;
fn configuration_view(&self, window: &mut Window, cx: &mut App) -> AnyView;
fn configuration_view(
&self,
target_agent: ConfigurationViewTargetAgent,
window: &mut Window,
cx: &mut App,
) -> AnyView;
fn must_accept_terms(&self, _cx: &App) -> bool {
false
}
@ -648,6 +653,13 @@ pub trait LanguageModelProvider: 'static {
fn reset_credentials(&self, cx: &mut App) -> Task<Result<()>>;
}
#[derive(Default, Clone, Copy)]
pub enum ConfigurationViewTargetAgent {
#[default]
ZedAgent,
Other(&'static str),
}
#[derive(PartialEq, Eq)]
pub enum LanguageModelProviderTosView {
/// When there are some past interactions in the Agent Panel.

View file

@ -107,7 +107,7 @@ pub enum Event {
InlineAssistantModelChanged,
CommitMessageModelChanged,
ThreadSummaryModelChanged,
ProviderStateChanged,
ProviderStateChanged(LanguageModelProviderId),
AddedProvider(LanguageModelProviderId),
RemovedProvider(LanguageModelProviderId),
}
@ -148,8 +148,11 @@ impl LanguageModelRegistry {
) {
let id = provider.id();
let subscription = provider.subscribe(cx, |_, cx| {
cx.emit(Event::ProviderStateChanged);
let subscription = provider.subscribe(cx, {
let id = id.clone();
move |_, cx| {
cx.emit(Event::ProviderStateChanged(id.clone()));
}
});
if let Some(subscription) = subscription {
subscription.detach();