deepseek/agent/
options.rs1use std::sync::Arc;
4
5use crate::types::EffortLevel;
6
7use super::permissions::{PermissionMode, PreToolHook};
8
9#[derive(Clone)]
14pub struct RunOptions {
15 pub model: String,
16 pub system_prompt: String,
17 pub allowed_tools: Option<Vec<String>>,
20 pub disallowed_tools: Vec<String>,
22 pub max_turns: Option<u32>,
23 pub max_budget_usd: Option<f64>,
24 pub effort: EffortLevel,
25 pub permission_mode: PermissionMode,
26 pub pre_tool_hook: Option<Arc<dyn PreToolHook>>,
27 pub session_id: Option<String>,
28 pub base_url: String,
29}
30
31impl Default for RunOptions {
32 fn default() -> Self {
33 Self {
34 model: "deepseek-v4-pro".into(),
35 system_prompt: String::new(),
36 allowed_tools: None,
37 disallowed_tools: Vec::new(),
38 max_turns: None,
39 max_budget_usd: None,
40 effort: EffortLevel::default(),
41 permission_mode: PermissionMode::default(),
42 pre_tool_hook: None,
43 session_id: None,
44 base_url: "https://api.deepseek.com/v1".into(),
45 }
46 }
47}
48
49impl RunOptions {
50 pub fn new(model: impl Into<String>) -> Self {
51 Self {
52 model: model.into(),
53 ..Self::default()
54 }
55 }
56
57 pub fn system_prompt(mut self, p: impl Into<String>) -> Self {
58 self.system_prompt = p.into();
59 self
60 }
61
62 pub fn max_turns(mut self, n: u32) -> Self {
63 self.max_turns = Some(n);
64 self
65 }
66
67 pub fn max_budget_usd(mut self, b: f64) -> Self {
68 self.max_budget_usd = Some(b);
69 self
70 }
71
72 pub fn effort(mut self, e: EffortLevel) -> Self {
73 self.effort = e;
74 self
75 }
76
77 pub fn permission_mode(mut self, m: PermissionMode) -> Self {
78 self.permission_mode = m;
79 self
80 }
81
82 pub fn allowed_tools<I, S>(mut self, tools: I) -> Self
83 where
84 I: IntoIterator<Item = S>,
85 S: Into<String>,
86 {
87 self.allowed_tools = Some(tools.into_iter().map(Into::into).collect());
88 self
89 }
90
91 pub fn disallowed_tools<I, S>(mut self, tools: I) -> Self
92 where
93 I: IntoIterator<Item = S>,
94 S: Into<String>,
95 {
96 self.disallowed_tools = tools.into_iter().map(Into::into).collect();
97 self
98 }
99
100 pub fn pre_tool_hook(mut self, hook: Arc<dyn PreToolHook>) -> Self {
101 self.pre_tool_hook = Some(hook);
102 self
103 }
104
105 pub fn session_id(mut self, id: impl Into<String>) -> Self {
106 self.session_id = Some(id.into());
107 self
108 }
109
110 pub fn base_url(mut self, url: impl Into<String>) -> Self {
111 self.base_url = url.into().trim_end_matches('/').to_string();
112 self
113 }
114}