first pass of merging in warp (doesn't build)
This commit is contained in:
+105
-25
@@ -3,40 +3,38 @@ mod convert_from;
|
||||
mod convert_to;
|
||||
mod r#impl;
|
||||
|
||||
use std::path::Path;
|
||||
use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub use ai::agent::convert::ConvertToAPITypeError;
|
||||
use ai::api_keys::ApiKeyManager;
|
||||
pub use convert_from::{
|
||||
user_inputs_from_messages, ConversionParams, ConvertAPIMessageToClientOutputMessage,
|
||||
MaybeAIAgentOutputMessage, MessageToAIAgentOutputMessageError,
|
||||
};
|
||||
|
||||
pub use r#impl::generate_multi_agent_output;
|
||||
|
||||
use futures_lite::Stream;
|
||||
use mcp::TemplatableMCPServerInfo;
|
||||
pub use r#impl::generate_multi_agent_output;
|
||||
use serde::Serialize;
|
||||
use galaxy_core::channel::ChannelState;
|
||||
use galaxy_core::execution_mode::AppExecutionMode;
|
||||
use galaxy_core::features::FeatureFlag;
|
||||
use serde::Serialize;
|
||||
use std::path::Path;
|
||||
use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::ai::agent::conversation::AIConversationId;
|
||||
use crate::ai::ambient_agents::AmbientAgentTaskId;
|
||||
use crate::{
|
||||
ai::{blocklist::SessionContext, llms::LLMId},
|
||||
server::server_api::AIApiError,
|
||||
};
|
||||
use galaxy_core::user_preferences::GetUserPreferences;
|
||||
use galaxyui::{AppContext, EntityId, SingletonEntity as _};
|
||||
|
||||
use super::{AIAgentInput, MCPContext, MCPServer, RequestMetadata, Suggestions};
|
||||
use crate::ai::blocklist::{BlocklistAIPermissions, RequestInput};
|
||||
use crate::ai::mcp::templatable_manager::TemplatableMCPServerInfo;
|
||||
use crate::ai::agent::conversation::AIConversationId;
|
||||
use crate::ai::ambient_agents::AmbientAgentTaskId;
|
||||
use crate::ai::blocklist::{BlocklistAIPermissions, RequestInput, SessionContext};
|
||||
use crate::ai::execution_profiles::profiles::AIExecutionProfilesModel;
|
||||
use crate::ai::execution_profiles::AIExecutionProfileAppExt;
|
||||
use crate::ai::llms::{LLMId, LLMPreferences};
|
||||
use crate::ai::mcp::TemplatableMCPServerManager;
|
||||
use crate::server::server_api::AIApiError;
|
||||
use crate::settings::AISettings;
|
||||
use crate::terminal::safe_mode_settings::get_secret_obfuscation_mode;
|
||||
use crate::workspaces::user_workspaces::UserWorkspaces;
|
||||
use galaxy_core::user_preferences::GetUserPreferences;
|
||||
use galaxyui::{AppContext, EntityId, SingletonEntity as _};
|
||||
|
||||
/// Unique, server-generated conversation-scoped token to be roundtripped to the API when sending
|
||||
/// requests that follow-up within a given conversation.
|
||||
@@ -109,13 +107,21 @@ pub struct RequestParams {
|
||||
pub computer_use_model: LLMId,
|
||||
pub is_memory_enabled: bool,
|
||||
pub warp_drive_context_enabled: bool,
|
||||
pub context_window_limit: Option<u32>,
|
||||
pub mcp_context: Option<MCPContext>,
|
||||
pub planning_enabled: bool,
|
||||
should_redact_secrets: bool,
|
||||
|
||||
/// User-provided API keys for AI providers (BYO API Key).
|
||||
pub api_keys: Option<warp_multi_agent_api::request::settings::ApiKeys>,
|
||||
pub allow_use_of_warp_credits_with_byok: bool,
|
||||
/// User-provided custom model providers (BYOK endpoints).
|
||||
pub custom_model_providers:
|
||||
Option<warp_multi_agent_api::request::settings::CustomModelProviders>,
|
||||
/// User-defined custom model routers referenced by the current selection. Mirrors
|
||||
/// `custom_model_providers`: the selected model's `config_key` indexes into this
|
||||
/// registry. `None` when no custom router is selected.
|
||||
pub custom_model_routers: Option<warp_multi_agent_api::request::settings::CustomModelRouters>,
|
||||
pub allow_use_of_warp_credits: bool,
|
||||
pub autonomy_level: warp_multi_agent_api::AutonomyLevel,
|
||||
pub isolation_level: warp_multi_agent_api::IsolationLevel,
|
||||
pub web_search_enabled: bool,
|
||||
@@ -170,6 +176,44 @@ pub struct ConversationData {
|
||||
}
|
||||
|
||||
impl RequestParams {
|
||||
#[cfg(test)]
|
||||
pub fn new_for_test() -> Self {
|
||||
Self {
|
||||
input: vec![],
|
||||
conversation_token: None,
|
||||
forked_from_conversation_token: None,
|
||||
ambient_agent_task_id: None,
|
||||
tasks: vec![],
|
||||
existing_suggestions: None,
|
||||
metadata: None,
|
||||
session_context: SessionContext::new_for_test(),
|
||||
model: LLMId::from("test-model"),
|
||||
coding_model: LLMId::from("test-model"),
|
||||
cli_agent_model: LLMId::from("test-model"),
|
||||
computer_use_model: LLMId::from("test-model"),
|
||||
is_memory_enabled: false,
|
||||
warp_drive_context_enabled: false,
|
||||
context_window_limit: None,
|
||||
mcp_context: None,
|
||||
planning_enabled: false,
|
||||
should_redact_secrets: false,
|
||||
api_keys: None,
|
||||
custom_model_providers: None,
|
||||
custom_model_routers: None,
|
||||
allow_use_of_warp_credits: false,
|
||||
autonomy_level: Default::default(),
|
||||
isolation_level: Default::default(),
|
||||
web_search_enabled: false,
|
||||
computer_use_enabled: false,
|
||||
ask_user_question_enabled: false,
|
||||
research_agent_enabled: false,
|
||||
orchestration_enabled: false,
|
||||
supported_tools_override: None,
|
||||
parent_agent_id: None,
|
||||
agent_name: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(
|
||||
terminal_view_id: Option<EntityId>,
|
||||
session_context: SessionContext,
|
||||
@@ -251,12 +295,31 @@ impl RequestParams {
|
||||
let should_redact_secrets = get_secret_obfuscation_mode(app).should_redact_secret();
|
||||
|
||||
let user_workspaces = UserWorkspaces::as_ref(app);
|
||||
let api_keys = ApiKeyManager::as_ref(app).api_keys_for_request(
|
||||
user_workspaces.is_byo_api_key_enabled(),
|
||||
user_workspaces.is_bedrock_enabled(app),
|
||||
let api_key_manager = ApiKeyManager::as_ref(app);
|
||||
let is_byo_enabled = user_workspaces.is_byo_api_key_enabled(app);
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
let geap_binding = crate::ai::geap_credentials::current_geap_policy(app).mint_binding();
|
||||
#[cfg(target_family = "wasm")]
|
||||
let geap_binding: Option<::ai::api_keys::GeapMintBinding> = None;
|
||||
let api_keys = api_key_manager.api_keys_for_request(
|
||||
is_byo_enabled,
|
||||
user_workspaces.is_aws_bedrock_credentials_enabled(app),
|
||||
geap_binding,
|
||||
);
|
||||
let allow_use_of_warp_credits_with_byok =
|
||||
*AISettings::as_ref(app).can_use_warp_credits_with_byok;
|
||||
let is_custom_inference_enabled = user_workspaces.is_custom_inference_enabled(app);
|
||||
let custom_model_providers = FeatureFlag::CustomInferenceEndpoints
|
||||
.is_enabled()
|
||||
.then(|| {
|
||||
api_key_manager.custom_model_providers_for_request(is_custom_inference_enabled)
|
||||
})
|
||||
.flatten();
|
||||
let custom_model_routers = FeatureFlag::CustomModelRouters.is_enabled().then(|| {
|
||||
LLMPreferences::as_ref(app).custom_model_routers_for_request(
|
||||
&request_input.model_id,
|
||||
&request_input.coding_model_id,
|
||||
)
|
||||
});
|
||||
let allow_use_of_warp_credits = *AISettings::as_ref(app).can_use_warp_credits_for_fallback;
|
||||
|
||||
let app_execution_mode = AppExecutionMode::as_ref(app);
|
||||
let autonomy_level = if app_execution_mode.is_autonomous() {
|
||||
@@ -292,11 +355,25 @@ impl RequestParams {
|
||||
!= crate::ai::execution_profiles::AskUserQuestionPermission::Never;
|
||||
|
||||
let orchestration_enabled = ai_settings.is_orchestration_enabled(app)
|
||||
&& BlocklistAIPermissions::as_ref(app)
|
||||
.get_run_agents_setting(app, terminal_view_id)
|
||||
.is_enabled()
|
||||
&& session_context
|
||||
.session_type()
|
||||
.as_ref()
|
||||
.is_none_or(|t| matches!(t, crate::terminal::model::session::SessionType::Local));
|
||||
|
||||
// Reconcile the persisted override against the active base model's
|
||||
// current `LLMContextWindow` instead of trusting whatever was stored
|
||||
// last. If the active model isn't configurable or has been removed
|
||||
// server-side, drop the override; otherwise clamp it to the model's
|
||||
// current `[min, max]` range. This closes the window between an
|
||||
// in-flight model metadata refresh and the next request.
|
||||
let context_window_limit = AIExecutionProfilesModel::as_ref(app)
|
||||
.active_profile(terminal_view_id, app)
|
||||
.data()
|
||||
.context_window_limit_for_request(app);
|
||||
|
||||
Self {
|
||||
input: request_input.all_inputs().cloned().collect(),
|
||||
conversation_token: conversation.server_conversation_token,
|
||||
@@ -304,6 +381,7 @@ impl RequestParams {
|
||||
ambient_agent_task_id: conversation.ambient_agent_task_id,
|
||||
tasks: conversation.tasks,
|
||||
existing_suggestions: conversation.existing_suggestions,
|
||||
context_window_limit,
|
||||
metadata,
|
||||
session_context,
|
||||
model: request_input.model_id.clone(),
|
||||
@@ -316,7 +394,9 @@ impl RequestParams {
|
||||
planning_enabled: true,
|
||||
should_redact_secrets,
|
||||
api_keys,
|
||||
allow_use_of_warp_credits_with_byok,
|
||||
custom_model_providers,
|
||||
custom_model_routers,
|
||||
allow_use_of_warp_credits,
|
||||
autonomy_level,
|
||||
isolation_level,
|
||||
web_search_enabled,
|
||||
|
||||
Reference in New Issue
Block a user