deepseek/agent/
options.rs1use std::sync::Arc;
4
5use crate::types::EffortLevel;
6
7use super::permissions::{PermissionMode, PreToolHook};
8
9#[derive(Clone, Debug)]
34pub struct CompactionConfig {
35 pub threshold_prompt_tokens: u32,
37 pub keep_recent_turns: u32,
43 pub compactor_model: String,
46 pub max_summary_tokens: u32,
48}
49
50impl Default for CompactionConfig {
51 fn default() -> Self {
52 Self {
53 threshold_prompt_tokens: 32_000,
54 keep_recent_turns: 3,
55 compactor_model: "deepseek-chat".into(),
56 max_summary_tokens: 512,
57 }
58 }
59}
60
61#[derive(Clone)]
66pub struct RunOptions {
67 pub model: String,
68 pub system_prompt: String,
69 pub allowed_tools: Option<Vec<String>>,
72 pub disallowed_tools: Vec<String>,
74 pub max_turns: Option<u32>,
75 pub max_budget_usd: Option<f64>,
76 pub effort: EffortLevel,
77 pub permission_mode: PermissionMode,
78 pub pre_tool_hook: Option<Arc<dyn PreToolHook>>,
79 pub session_id: Option<String>,
80 pub base_url: String,
81 pub compaction: Option<CompactionConfig>,
84}
85
86impl Default for RunOptions {
87 fn default() -> Self {
88 Self {
89 model: "deepseek-v4-pro".into(),
90 system_prompt: String::new(),
91 allowed_tools: None,
92 disallowed_tools: Vec::new(),
93 max_turns: None,
94 max_budget_usd: None,
95 effort: EffortLevel::default(),
96 permission_mode: PermissionMode::default(),
97 pre_tool_hook: None,
98 session_id: None,
99 base_url: "https://api.deepseek.com/v1".into(),
100 compaction: None,
101 }
102 }
103}
104
105impl RunOptions {
106 pub fn new(model: impl Into<String>) -> Self {
107 Self {
108 model: model.into(),
109 ..Self::default()
110 }
111 }
112
113 pub fn system_prompt(mut self, p: impl Into<String>) -> Self {
114 self.system_prompt = p.into();
115 self
116 }
117
118 pub fn max_turns(mut self, n: u32) -> Self {
119 self.max_turns = Some(n);
120 self
121 }
122
123 pub fn max_budget_usd(mut self, b: f64) -> Self {
124 self.max_budget_usd = Some(b);
125 self
126 }
127
128 pub fn effort(mut self, e: EffortLevel) -> Self {
129 self.effort = e;
130 self
131 }
132
133 pub fn permission_mode(mut self, m: PermissionMode) -> Self {
134 self.permission_mode = m;
135 self
136 }
137
138 pub fn allowed_tools<I, S>(mut self, tools: I) -> Self
139 where
140 I: IntoIterator<Item = S>,
141 S: Into<String>,
142 {
143 self.allowed_tools = Some(tools.into_iter().map(Into::into).collect());
144 self
145 }
146
147 pub fn disallowed_tools<I, S>(mut self, tools: I) -> Self
148 where
149 I: IntoIterator<Item = S>,
150 S: Into<String>,
151 {
152 self.disallowed_tools = tools.into_iter().map(Into::into).collect();
153 self
154 }
155
156 pub fn pre_tool_hook(mut self, hook: Arc<dyn PreToolHook>) -> Self {
157 self.pre_tool_hook = Some(hook);
158 self
159 }
160
161 pub fn session_id(mut self, id: impl Into<String>) -> Self {
162 self.session_id = Some(id.into());
163 self
164 }
165
166 pub fn base_url(mut self, url: impl Into<String>) -> Self {
167 self.base_url = url.into().trim_end_matches('/').to_string();
168 self
169 }
170
171 pub fn compaction(mut self, cfg: CompactionConfig) -> Self {
173 self.compaction = Some(cfg);
174 self
175 }
176}