atman_runtime/tools/
mod.rs1use std::sync::Arc;
2
3use crate::tool::ToolRegistry;
4
5pub mod agent_ctrl;
6pub mod anchor;
7pub mod anchor_fs;
8pub mod bash_bg;
9pub mod context;
10pub mod final_answer;
11pub mod flow_check;
12pub mod flow_list;
13pub mod flow_source;
14pub mod form;
15pub mod fs;
16pub mod git;
17pub mod git_branch;
18pub mod git_history;
19pub mod git_ops;
20pub mod git_workspace;
21pub mod git_worktree;
22pub mod help;
23pub mod hunk;
24pub mod image;
25pub mod llm_call;
26pub mod llm_classify;
27pub mod llm_extract;
28pub mod llm_generate_branches;
29pub mod mcp;
30pub mod memory;
31pub mod memory_stubs;
32pub mod permission;
33pub mod plan;
34pub mod preview;
35pub mod session;
36pub mod sleep;
37pub mod stdlib;
38pub mod task_ops;
39pub mod term;
40pub mod test;
41pub mod tool_output;
42pub mod web;
43
44pub fn register_tier_zero(reg: &ToolRegistry) {
45 register_tier_zero_with_rules(reg, memory_stubs::RuleFetch::new());
46}
47
48pub fn register_tier_zero_with_rules(reg: &ToolRegistry, rule_fetch: memory_stubs::RuleFetch) {
49 reg.register(Arc::new(anchor::AnchorRead));
50 reg.register(Arc::new(anchor::AnchorEdit));
51 reg.register(Arc::new(anchor::AnchorWrite));
52 reg.register(Arc::new(anchor::AnchorUndo));
53 reg.register(Arc::new(fs::FsRead));
54 reg.register(Arc::new(image::ImageRead));
55 reg.register(Arc::new(mcp::McpStatus));
56 reg.register(Arc::new(mcp::McpTools));
57 reg.register(Arc::new(mcp::McpAwait));
58 reg.register(Arc::new(mcp::McpCall));
59 reg.register(Arc::new(tool_output::OutputRead));
60 reg.register(Arc::new(fs::FsList));
61 reg.register(Arc::new(fs::FsWrite));
62 reg.register(Arc::new(fs::FsEdit));
63 reg.register(Arc::new(fs::FsGrep));
64 reg.register(Arc::new(rule_fetch));
65 reg.register(Arc::new(stdlib::ShellQuote));
66 reg.register(Arc::new(stdlib::ToJsonString));
67 reg.register(Arc::new(stdlib::ComposeEmailPreview));
68 reg.register(Arc::new(stdlib::RenderPromptXml));
69 reg.register(Arc::new(stdlib::RenderPromptMarkdown));
70 reg.register(Arc::new(stdlib::RenderPromptTerse));
71 reg.register(Arc::new(stdlib::EstimateTokens));
72 reg.register(Arc::new(stdlib::FindCompactRange));
73 reg.register(Arc::new(stdlib::ReplaceMessagesRange));
74 reg.register(Arc::new(stdlib::Len));
75 reg.register(Arc::new(stdlib::Head));
76 reg.register(Arc::new(stdlib::Tail));
77 reg.register(Arc::new(stdlib::IsEmpty));
78 reg.register(Arc::new(stdlib::Concat));
79 reg.register(Arc::new(stdlib::TextConcat));
80 reg.register(Arc::new(final_answer::FinalAnswer));
81 reg.register(Arc::new(final_answer::ExtractFinalAnswer));
82 reg.register(Arc::new(final_answer::FinalizeResponse));
83 reg.register(Arc::new(stdlib::ExtractToolUses));
84 reg.register(Arc::new(stdlib::DispatchAll));
85 reg.register(Arc::new(context::ContextRecordAppend));
86 reg.register(Arc::new(permission::PermissionList));
87 reg.register(Arc::new(permission::PermissionGet));
88 reg.register(Arc::new(permission::PermissionGroupTool));
89 reg.register(Arc::new(permission::PermissionUngroup));
90 reg.register(Arc::new(permission::PermissionApprove));
91 reg.register(Arc::new(permission::PermissionDeny));
92 reg.register(Arc::new(permission::PermissionDefer));
93 reg.register(Arc::new(permission::PermissionBatch));
94 reg.register(Arc::new(stdlib::MessageUser));
95 reg.register(Arc::new(stdlib::MessageAssistant));
96 reg.register(Arc::new(stdlib::MessageSystem));
97 reg.register(Arc::new(stdlib::MessageTool));
98 reg.register(Arc::new(git::GitDiff));
99 reg.register(Arc::new(git_ops::GitInit));
100 reg.register(Arc::new(git_ops::GitShow));
101 reg.register(Arc::new(git_ops::GitLog));
102 reg.register(Arc::new(git_ops::GitStatus));
103 reg.register(Arc::new(test::TestRun));
104 reg.register(Arc::new(hunk::FsEdit));
105 reg.register(Arc::new(hunk::HunkApply));
106 reg.register(Arc::new(hunk::HunkReview));
107 reg.register(Arc::new(agent_ctrl::AgentSpawn));
108 reg.register(Arc::new(agent_ctrl::AgentStatus));
109 reg.register(Arc::new(agent_ctrl::AgentOutput));
110 reg.register(Arc::new(agent_ctrl::AgentKill));
111 reg.register(Arc::new(agent_ctrl::FlowInterject));
112 reg.register(Arc::new(form::FormAsk));
113 reg.register(Arc::new(session::SessionPush));
114 reg.register(Arc::new(sleep::Sleep));
115 reg.register(Arc::new(help::HelpShow));
116 reg.register(Arc::new(flow_list::FlowList));
117 reg.register(Arc::new(flow_list::FlowInstances));
118 reg.register(Arc::new(flow_list::FlowSearch));
119 reg.register(Arc::new(flow_list::FlowDescribe));
120 reg.register(Arc::new(flow_check::FlowCheck));
121 reg.register(Arc::new(llm_call::LlmCallTool));
122 reg.register(Arc::new(llm_classify::LlmClassifyTool));
123 reg.register(Arc::new(llm_extract::LlmExtractTool));
124 reg.register(Arc::new(llm_generate_branches::LlmGenerateBranchesTool));
125}
126
127pub fn register_git_ops(reg: &ToolRegistry) {
128 reg.register(Arc::new(git_ops::GitAdd));
129 reg.register(Arc::new(git_ops::GitCommit));
130 reg.register(Arc::new(git_ops::GitFetch));
131 reg.register(Arc::new(git_ops::GitBranch));
132 reg.register(Arc::new(git_ops::GitPush));
133 reg.register(Arc::new(git_history::GitRestore));
134 reg.register(Arc::new(git_history::GitRevert));
135 reg.register(Arc::new(git_history::GitTagList));
136 reg.register(Arc::new(git_history::GitTagCreate));
137 reg.register(Arc::new(git_branch::GitBranchList));
138 reg.register(Arc::new(git_branch::GitBranchCreate));
139 reg.register(Arc::new(git_branch::GitBranchSwitch));
140 reg.register(Arc::new(git_branch::GitBranchRename));
141 reg.register(Arc::new(git_branch::GitBranchDelete));
142 reg.register(Arc::new(git_branch::GitRemoteList));
143 reg.register(Arc::new(git_worktree::GitWorktreeAdd));
144 reg.register(Arc::new(git_worktree::GitWorktreeList));
145 reg.register(Arc::new(git_worktree::GitWorktreeRemove));
146 reg.register(Arc::new(git_worktree::GitWorktreePrune));
147 reg.register(Arc::new(git_worktree::GitWorktreeLock));
148 reg.register(Arc::new(git_worktree::GitWorktreeUnlock));
149 reg.register(Arc::new(git_workspace::GitWorkspaceCreate));
150 reg.register(Arc::new(git_workspace::GitWorkspaceList));
151 reg.register(Arc::new(git_workspace::GitWorkspaceGet));
152 reg.register(Arc::new(git_workspace::GitWorkspaceRelease));
153 reg.register(Arc::new(git_workspace::GitWorkspaceRetain));
154 reg.register(Arc::new(git_workspace::GitWorkspacePrune));
155}
156
157pub fn register_watch(reg: &ToolRegistry) {
158 reg.register(Arc::new(crate::watch::Watch));
159 reg.register(Arc::new(crate::watch::WatcherList));
160 reg.register(Arc::new(crate::watch::WatcherUnwatch));
161 reg.register(Arc::new(crate::watch::WaitForWatcher));
162 reg.register(Arc::new(crate::watch::HasPendingInjections));
163}
164
165pub fn register_bash_bg(reg: &ToolRegistry) -> Arc<bash_bg::BgRegistry> {
166 let registry = Arc::new(bash_bg::BgRegistry::new());
167 reg.register(Arc::new(bash_bg::BashSpawn));
168 reg.register(Arc::new(bash_bg::BashStatus));
169 reg.register(Arc::new(bash_bg::BashOutput));
170 reg.register(Arc::new(bash_bg::BashKill));
171 reg.register(Arc::new(bash_bg::BashList));
172 registry
173}
174
175pub fn register_bash_bg_with_task_registry(
176 reg: &ToolRegistry,
177 task_registry: crate::task_registry::TaskRegistry,
178) -> Arc<bash_bg::BgRegistry> {
179 let registry = Arc::new(bash_bg::BgRegistry::new().with_task_registry(task_registry));
180 reg.register(Arc::new(bash_bg::BashSpawn));
181 reg.register(Arc::new(bash_bg::BashStatus));
182 reg.register(Arc::new(bash_bg::BashOutput));
183 reg.register(Arc::new(bash_bg::BashKill));
184 reg.register(Arc::new(bash_bg::BashList));
185 registry
186}
187
188pub fn register_web(reg: &ToolRegistry, config: web::WebConfig) {
189 reg.register(Arc::new(web::WebFetch::new(config)));
190}
191
192pub fn register_web_search(reg: &ToolRegistry, config: &web::SearchConfig) {
193 if let Some(provider) = web::build_search_provider(config) {
194 reg.register(Arc::new(web::WebSearch::new(provider)));
195 }
196}
197
198pub fn register_terminal(reg: &ToolRegistry) -> Arc<term::TermRegistry> {
199 let registry = Arc::new(term::TermRegistry::new());
200 reg.register(Arc::new(term::TermSpawn));
201 reg.register(Arc::new(term::TermInput));
202 reg.register(Arc::new(term::TermCapture));
203 reg.register(Arc::new(term::TermFind));
204 reg.register(Arc::new(term::TermResize));
205 reg.register(Arc::new(term::TermKill));
206 reg.register(Arc::new(term::TermList));
207 registry
208}
209
210pub fn register_terminal_with_task_registry(
211 reg: &ToolRegistry,
212 task_registry: crate::task_registry::TaskRegistry,
213) -> Arc<term::TermRegistry> {
214 let registry = Arc::new(term::TermRegistry::new().with_task_registry(task_registry));
215 reg.register(Arc::new(term::TermSpawn));
216 reg.register(Arc::new(term::TermInput));
217 reg.register(Arc::new(term::TermCapture));
218 reg.register(Arc::new(term::TermFind));
219 reg.register(Arc::new(term::TermResize));
220 reg.register(Arc::new(term::TermKill));
221 reg.register(Arc::new(term::TermList));
222 registry
223}
224
225pub fn register_preview(reg: &ToolRegistry, config: preview::PreviewConfig) {
226 reg.register(Arc::new(preview::PreviewPush::new(config)));
227}
228
229pub fn register_memory(
230 reg: &ToolRegistry,
231 todo_store: Arc<crate::memory::todo::TodoStore>,
232 confession_store: Arc<crate::memory::confession::ConfessionStore>,
233 goal_store: Arc<crate::memory::goal::GoalStore>,
234 plan_store: Arc<crate::memory::plan::PlanStore>,
235) {
236 reg.register(Arc::new(memory::MemoryTodoSet {
237 store: todo_store.clone(),
238 }));
239 reg.register(Arc::new(memory::MemoryTodoDone {
240 store: todo_store.clone(),
241 }));
242 reg.register(Arc::new(memory::MemoryTodoCancel {
243 store: todo_store.clone(),
244 }));
245 reg.register(Arc::new(memory::MemoryTodoDelete {
246 store: todo_store.clone(),
247 }));
248 reg.register(Arc::new(memory::MemoryTodoList { store: todo_store }));
249 reg.register(Arc::new(memory::MemoryConfess {
250 store: confession_store.clone(),
251 }));
252 reg.register(Arc::new(memory::MemoryFetchConfessions {
253 store: confession_store,
254 }));
255 reg.register(Arc::new(memory::MemoryGoalGet {
256 store: goal_store.clone(),
257 }));
258 reg.register(Arc::new(memory::MemoryGoalSet {
259 store: goal_store.clone(),
260 }));
261 reg.register(Arc::new(memory::MemoryGoalClear { store: goal_store }));
262 reg.register(Arc::new(memory::MemoryRecentTurns));
263 reg.register(Arc::new(memory::MemoryHistorySearch));
264 reg.register(Arc::new(memory::MemoryHistoryRead));
265 reg.register(Arc::new(memory::MemoryHistoryCount));
266 reg.register(Arc::new(plan::PlanWrite {
267 store: plan_store.clone(),
268 }));
269 reg.register(Arc::new(plan::PlanRead {
270 store: plan_store.clone(),
271 }));
272 reg.register(Arc::new(plan::PlanTick { store: plan_store }));
273}
274
275pub fn register_spec_memory(reg: &ToolRegistry, spec_store: Arc<crate::memory::spec::SpecStore>) {
276 reg.register(Arc::new(memory::MemorySpecStatus {
277 store: spec_store.clone(),
278 }));
279 reg.register(Arc::new(memory::MemorySpecRead {
280 store: spec_store.clone(),
281 }));
282 reg.register(Arc::new(memory::MemorySpecReview {
283 store: spec_store.clone(),
284 }));
285 reg.register(Arc::new(memory::MemorySpecMaterialize {
286 store: spec_store.clone(),
287 }));
288 reg.register(Arc::new(memory::MemorySpecUpdate {
289 store: spec_store.clone(),
290 }));
291 reg.register(Arc::new(memory::MemorySpecDeviate { store: spec_store }));
292}