feat: enable extension from ui (#2117)
This commit is contained in:
@@ -365,16 +365,23 @@ async fn ask_handler(
|
||||
}))
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct ToolConfirmationRequest {
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
struct PermissionConfirmationRequest {
|
||||
id: String,
|
||||
confirmed: bool,
|
||||
#[serde(default = "default_principal_type")]
|
||||
principal_type: PrincipalType,
|
||||
action: String,
|
||||
}
|
||||
|
||||
fn default_principal_type() -> PrincipalType {
|
||||
PrincipalType::Tool
|
||||
}
|
||||
|
||||
async fn confirm_handler(
|
||||
State(state): State<AppState>,
|
||||
headers: HeaderMap,
|
||||
Json(request): Json<ToolConfirmationRequest>,
|
||||
Json(request): Json<PermissionConfirmationRequest>,
|
||||
) -> Result<Json<Value>, StatusCode> {
|
||||
// Verify secret key
|
||||
let secret_key = headers
|
||||
@@ -385,6 +392,10 @@ async fn confirm_handler(
|
||||
if secret_key != state.secret_key {
|
||||
return Err(StatusCode::UNAUTHORIZED);
|
||||
}
|
||||
tracing::info!(
|
||||
"Received confirmation request: {}",
|
||||
serde_json::to_string_pretty(&request).unwrap()
|
||||
);
|
||||
|
||||
let agent = state.agent.clone();
|
||||
let agent = agent.read().await;
|
||||
@@ -401,7 +412,7 @@ async fn confirm_handler(
|
||||
.handle_confirmation(
|
||||
request.id.clone(),
|
||||
PermissionConfirmation {
|
||||
principal_type: PrincipalType::Tool,
|
||||
principal_type: request.principal_type,
|
||||
permission,
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user