claude_code_switcher/templates/
minimax.rs1use crate::{
4 settings::{ClaudeSettings, Permissions},
5 snapshots::SnapshotScope,
6 templates::Template,
7};
8use std::collections::HashMap;
9
10#[derive(Debug, Clone)]
12pub struct MiniMaxTemplate;
13
14impl Template for MiniMaxTemplate {
15 fn template_type(&self) -> crate::templates::TemplateType {
16 crate::templates::TemplateType::MiniMax
17 }
18
19 fn env_var_name(&self) -> &'static str {
20 "MINIMAX_API_KEY"
21 }
22
23 fn display_name(&self) -> &'static str {
24 "MiniMax"
25 }
26
27 fn description(&self) -> &'static str {
28 "MiniMax API (recommended) - High-performance AI with Anthropic compatibility"
29 }
30
31 fn create_settings(&self, api_key: &str, scope: &SnapshotScope) -> ClaudeSettings {
32 let mut settings = ClaudeSettings::new();
33
34 if matches!(scope, SnapshotScope::Common | SnapshotScope::All) {
35 settings.model = Some("MiniMax-M2".to_string());
36
37 settings.permissions = Some(Permissions {
38 allow: Some(vec![
39 "Bash".to_string(),
40 "Read".to_string(),
41 "Write".to_string(),
42 "Edit".to_string(),
43 "MultiEdit".to_string(),
44 "Glob".to_string(),
45 "Grep".to_string(),
46 "WebFetch".to_string(),
47 ]),
48 ask: None,
49 deny: Some(vec!["WebSearch".to_string()]),
50 additional_directories: None,
51 default_mode: None,
52 disable_bypass_permissions_mode: None,
53 });
54 }
55
56 if matches!(
57 scope,
58 SnapshotScope::Env | SnapshotScope::Common | SnapshotScope::All
59 ) {
60 let mut env = HashMap::new();
61 env.insert("ANTHROPIC_API_KEY".to_string(), api_key.to_string());
62 env.insert("ANTHROPIC_AUTH_TOKEN".to_string(), api_key.to_string());
63 env.insert(
64 "ANTHROPIC_BASE_URL".to_string(),
65 "https://api.minimax.io/anthropic".to_string(),
66 );
67 env.insert("ANTHROPIC_MODEL".to_string(), "MiniMax-M2".to_string());
68 env.insert(
69 "ANTHROPIC_SMALL_FAST_MODEL".to_string(),
70 "MiniMax-M2".to_string(),
71 );
72 env.insert(
73 "ANTHROPIC_DEFAULT_SONNET_MODEL".to_string(),
74 "MiniMax-M2".to_string(),
75 );
76 env.insert("API_TIMEOUT_MS".to_string(), "600000".to_string());
77 env.insert(
78 "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC".to_string(),
79 "1".to_string(),
80 );
81 settings.env = Some(env);
82 }
83
84 settings
85 }
86}
87
88pub fn create_minimax_template(api_key: &str, scope: &SnapshotScope) -> ClaudeSettings {
90 let template = MiniMaxTemplate;
91 template.create_settings(api_key, scope)
92}