1use std::sync::Arc;
42
43use aidaemon_core::Tool;
44
45pub mod backend;
46pub mod background_deliverable;
47pub mod backoff;
48pub mod check_environment;
49mod checklist;
50#[cfg(feature = "checkpoints")]
51pub mod checkpoints;
52pub mod cli_agent_flags;
53pub mod command_effects;
54pub mod command_risk;
55pub mod config_file;
56pub mod daemon_guard;
57pub mod duration_format;
58mod exec;
59pub mod execution;
60pub mod file_delivery;
61mod fs;
62pub mod fs_utils;
63pub mod http_request;
64pub mod internal_markers;
65pub mod local_backend;
66pub mod local_sites;
67pub mod outcome;
68pub mod owner_answers;
69pub mod path_class;
70pub mod permission_bypass;
71pub mod platform_shell;
72pub mod process_control;
73pub mod result_spill;
74pub mod sanitize;
75mod search;
76mod search_files;
77pub mod semantics;
78pub mod services;
79mod shell;
80pub mod shown;
81pub mod status;
82pub mod stt_setup;
83pub mod system;
84#[cfg(any(test, feature = "testing"))]
85pub mod testing;
86pub mod text;
87pub mod tls;
88mod util;
89pub mod web;
90pub mod web_search;
91mod workspace;
92
93#[cfg(test)]
94mod testutil;
95
96pub use backend::{
97 BackendDirEntry, BackendFileType, BackendKind, BackendMetadata, BackendPath, CommandSpec,
98 ExecutionBackend, ExecutionOutput, ExecutionRequest, LexicalPaths, ProcessHandle,
99 SpawnedProcess, WriteMode, shell_quote,
100};
101pub use checklist::{Checklist, ChecklistGate, ChecklistItem, ChecklistState, ItemStatus};
102pub use exec::{
103 BubblewrapSandbox, BubblewrapScope, CommandOutput, DockerSandbox, ExecError, HOME_SECRET_PATHS,
104 LocalSandbox, SANDBOX_ENV, Sandbox, SandboxCommand, SandboxKind, SandboxSelection,
105 SeatbeltSandbox, TerminalConfinement, best_available_sandbox, default_deny_read,
106 home_secret_paths, sandbox_preference_from_env, select_sandbox,
107};
108pub use fs::{
109 DEFAULT_IGNORE_DIRS, EditFile, FilePolicy, HostFilePolicy, HostFilePolicySettings,
110 MAX_READ_CHARS, ProtectedPathGuard, ReadFile, ToolText, WorkspaceBackend, WorkspaceFilePolicy,
111 WriteFile, format_with_line_numbers, render_read_file_output, render_read_file_output_within,
112};
113pub use outcome::{
114 CallValidator, KernelAdapter, NothingSentError, OutcomeRunner, OutcomeTool, TargetNotFound,
115 ToolTimedOut, failed_without_effect, timed_out,
116};
117pub use path_class::PathClassifier;
118pub use search::{Glob, Grep};
119pub use search_files::SearchFiles;
120pub use shell::{DEFAULT_ENV_ALLOWLIST, Shell};
121pub use util::sniff_image_mime;
122pub use web::{NetworkGuard, WebFetch};
123pub use workspace::{PathError, Workspace};
124
125pub fn default_tools(workspace: Workspace) -> Vec<Arc<dyn Tool>> {
132 default_tools_with_sandbox(workspace, best_available_sandbox())
133}
134
135pub fn default_tools_with_sandbox(
138 workspace: Workspace,
139 sandbox: Arc<dyn Sandbox>,
140) -> Vec<Arc<dyn Tool>> {
141 vec![
142 Arc::new(ReadFile::new(workspace.clone())),
143 Arc::new(WriteFile::new(workspace.clone())),
144 Arc::new(EditFile::new(workspace.clone())),
145 Arc::new(Glob::new(workspace.clone())),
146 Arc::new(Grep::new(workspace.clone())),
147 Arc::new(Shell::new(workspace, sandbox)),
148 Arc::new(WebFetch::new()),
149 ]
150}
151
152#[cfg(test)]
153mod tests {
154 use super::*;
155
156 #[test]
157 fn default_set_has_strict_unique_specs() {
158 let (_d, ws) = testutil::ws();
159 let tools = default_tools(ws);
160 let mut names: Vec<String> = tools.iter().map(|t| t.spec().name).collect();
161 names.push(Checklist::default().spec().name);
162 let mut sorted = names.clone();
163 sorted.sort();
164 sorted.dedup();
165 assert_eq!(sorted.len(), names.len());
166 for tool in tools
167 .iter()
168 .cloned()
169 .chain([Arc::new(Checklist::default()) as Arc<dyn Tool>])
170 {
171 let spec = tool.spec();
172 assert!(!spec.description.is_empty(), "{}", spec.name);
173 assert_eq!(spec.parameters["type"], "object", "{}", spec.name);
174 assert_eq!(
175 spec.parameters["additionalProperties"],
176 serde_json::json!(false),
177 "{}",
178 spec.name
179 );
180 for key in spec.parameters["required"].as_array().unwrap() {
182 assert!(
183 spec.parameters["properties"]
184 .get(key.as_str().unwrap())
185 .is_some(),
186 "{}: {key}",
187 spec.name
188 );
189 }
190 }
191 let read_only: Vec<bool> = tools.iter().map(|t| t.annotations().read_only).collect();
192 assert_eq!(read_only, [true, false, false, true, true, false, true]);
193 }
194}