fix(ai): preserve Dameng database and schema scopes

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-08-02 09:01:22 +08:00
1 parent 4511920d86
commit 61dc49ca4d
16 files changed
+634 -76

No files matched your search

+7
View File
@@ -92,6 +92,8 @@ pub struct AiAgentStreamRequest {
pub request: AiCompletionRequest,
pub connection_id: String,
pub database: String,
#[serde(default)]
pub schema: Option<String>,
pub db_type: String,
/// Agent mode: "ask" (read-only tools) or "agent" (all tools including execute_query).
/// Defaults to "ask" if not provided.
@@ -107,6 +109,8 @@ pub struct AiAgentStreamRequest {
pub confirmed_connection_id: Option<String>,
#[serde(default)]
pub confirmed_database: Option<String>,
#[serde(default)]
pub confirmed_schema: Option<String>,
}
fn default_agent_mode() -> String {
@@ -424,8 +428,10 @@ pub async fn ai_agent_stream(
body.confirmed_write_sql,
body.confirmed_connection_id,
body.confirmed_database,
body.confirmed_schema,
&body.connection_id,
&body.database,
body.schema.as_deref(),
);
// Writes are only allowed when a specific SQL statement was confirmed —
// an empty confirmed_write_sql is treated as "no confirmation" so the
@@ -439,6 +445,7 @@ pub async fn ai_agent_stream(
state: state.app.clone(),
connection_id: body.connection_id,
database: body.database,
schema: body.schema,
db_type: parsed_db_type,
cli_mcp_server_command: None,
sql_permissions,