Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ http = "1"
log = "0.4"
futures = "0.3"
rand = "0.8"
data-studio-agent = { git = "https://github.com/geek-fun/data-studio-agent.git", branch = "feat/unified-capability-types" }
data-studio-agent = { git = "https://github.com/geek-fun/data-studio-agent.git", branch = "feat/mcp-permissions" }

# Archive extraction (JRE downloads)
flate2 = "1.0"
Expand Down
25 changes: 25 additions & 0 deletions src-tauri/src/agent_adapters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use std::collections::HashMap;
use std::sync::Arc;

use crate::mcp_bridge::McpConfig;
use data_studio_agent as lib;
use data_studio_agent::storage;
use data_studio_agent::traits::{CancelMap, ConfirmMap, EventEmitter};
Expand Down Expand Up @@ -64,6 +65,29 @@ pub async fn run_agent_loop(
.unwrap_or(false)
};

let app_data_dir = app.path().app_data_dir().map_err(|e| e.to_string())?;
let policy = McpConfig::load(&app_data_dir).policy;
let should_deny = move |tool_name: &str, conn_id: Option<&str>| -> bool {
match data_studio_agent::capabilities::registry::registry().get(tool_name) {
Some(cap) => {
// Allowlist set but no connection specified: a DB capability would
// fall back to the default connection, bypassing the allowlist.
// AppLocal tools (list_connections etc.) need no connection.
if !policy.allowed_connection_ids.is_empty()
&& conn_id.is_none()
&& !matches!(
cap.source_kind,
data_studio_agent::capabilities::types::SourceKind::AppLocal
)
{
return true;
}
!policy.allows(cap.risk_level, conn_id)
}
None => false,
}
};

lib::loop_runner::run_agent_loop(
&session_id,
&user_message,
Expand All @@ -76,6 +100,7 @@ pub async fn run_agent_loop(
&confirm_map,
&cancel_map,
&is_parallel_ok,
&should_deny,
)
.await
}
Expand Down
Loading
Loading