pub trait CodeModeHandler: Send + Sync {
Show 13 methods
// Required methods
fn server_name(&self) -> &str;
fn is_enabled(&self) -> bool;
fn code_format(&self) -> &str;
fn validate_code_impl<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
code: &'life1 str,
variables: Option<&'life2 Value>,
dry_run: bool,
user_id: &'life3 str,
session_id: &'life4 str,
) -> Pin<Box<dyn Future<Output = Result<ValidationResponse, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait;
fn execute_code_impl<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
code: &'life1 str,
approval_token: &'life2 str,
variables: Option<&'life3 Value>,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
// Provided methods
fn is_policy_configured(&self) -> bool { ... }
fn is_avp_configured(&self) -> bool { ... }
fn pre_handle_hook<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<(Value, bool)>, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn is_code_mode_tool(&self, name: &str) -> bool { ... }
fn get_tools(&self) -> Vec<ToolInfo> { ... }
fn handle_tool<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
name: &'life1 str,
arguments: Value,
user_id: &'life2 str,
session_id: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(Value, bool), String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
fn handle_validate_code<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
arguments: Value,
user_id: &'life1 str,
session_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(Value, bool), String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn handle_execute_code<'life0, 'async_trait>(
&'life0 self,
arguments: Value,
) -> Pin<Box<dyn Future<Output = Result<(Value, bool), String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Code Mode handler trait with policy check and standard tool handling.
Required Methods§
Sourcefn server_name(&self) -> &str
fn server_name(&self) -> &str
Get the server name/ID for identification.
Sourcefn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Check if Code Mode is enabled in the configuration.
Sourcefn code_format(&self) -> &str
fn code_format(&self) -> &str
Get the code format for this server (e.g., “graphql”, “javascript”, “sql”).
Sourcefn validate_code_impl<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
code: &'life1 str,
variables: Option<&'life2 Value>,
dry_run: bool,
user_id: &'life3 str,
session_id: &'life4 str,
) -> Pin<Box<dyn Future<Output = Result<ValidationResponse, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn validate_code_impl<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
code: &'life1 str,
variables: Option<&'life2 Value>,
dry_run: bool,
user_id: &'life3 str,
session_id: &'life4 str,
) -> Pin<Box<dyn Future<Output = Result<ValidationResponse, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Validate code and return a validation response.
Sourcefn execute_code_impl<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
code: &'life1 str,
approval_token: &'life2 str,
variables: Option<&'life3 Value>,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn execute_code_impl<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
code: &'life1 str,
approval_token: &'life2 str,
variables: Option<&'life3 Value>,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Execute validated code and return the result.
Provided Methods§
Sourcefn is_policy_configured(&self) -> bool
fn is_policy_configured(&self) -> bool
Check if a policy evaluator is configured.
The default returns true for backward compatibility with tests.
Production implementations MUST override this.
Sourcefn is_avp_configured(&self) -> bool
fn is_avp_configured(&self) -> bool
Deprecated alias for is_policy_configured().
Sourcefn pre_handle_hook<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<(Value, bool)>, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn pre_handle_hook<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<(Value, bool)>, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Pre-handle hook for checks before tool execution.
Override this to implement soft-disable checks (e.g., DynamoDB toggle).
Return Ok(Some((response, is_error))) to short-circuit with a response.
Return Ok(None) to proceed normally.
Sourcefn is_code_mode_tool(&self, name: &str) -> bool
fn is_code_mode_tool(&self, name: &str) -> bool
Check if this is a Code Mode tool.
Sourcefn handle_tool<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
name: &'life1 str,
arguments: Value,
user_id: &'life2 str,
session_id: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(Value, bool), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn handle_tool<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
name: &'life1 str,
arguments: Value,
user_id: &'life2 str,
session_id: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(Value, bool), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Handle a Code Mode tool call with policy and pre-handle checks.
Sourcefn handle_validate_code<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
arguments: Value,
user_id: &'life1 str,
session_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(Value, bool), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle_validate_code<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
arguments: Value,
user_id: &'life1 str,
session_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(Value, bool), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Handle validate_code tool call.