use std::sync::Arc;
use aidaemon_core::Tool;
pub mod backend;
pub mod background_deliverable;
pub mod backoff;
pub mod check_environment;
mod checklist;
#[cfg(feature = "checkpoints")]
pub mod checkpoints;
pub mod cli_agent_flags;
pub mod command_effects;
pub mod command_risk;
pub mod config_file;
pub mod daemon_guard;
pub mod duration_format;
mod exec;
pub mod execution;
pub mod file_delivery;
mod fs;
pub mod fs_utils;
pub mod http_request;
pub mod internal_markers;
pub mod local_backend;
pub mod local_sites;
pub mod outcome;
pub mod owner_answers;
pub mod path_class;
pub mod permission_bypass;
pub mod platform_shell;
pub mod process_control;
pub mod result_spill;
pub mod sanitize;
mod search;
mod search_files;
pub mod semantics;
pub mod services;
mod shell;
pub mod shown;
pub mod status;
pub mod stt_setup;
pub mod system;
#[cfg(any(test, feature = "testing"))]
pub mod testing;
pub mod text;
pub mod tls;
mod util;
pub mod web;
pub mod web_search;
mod workspace;
#[cfg(test)]
mod testutil;
pub use backend::{
BackendDirEntry, BackendFileType, BackendKind, BackendMetadata, BackendPath, CommandSpec,
ExecutionBackend, ExecutionOutput, ExecutionRequest, LexicalPaths, ProcessHandle,
SpawnedProcess, WriteMode, shell_quote,
};
pub use checklist::{Checklist, ChecklistGate, ChecklistItem, ChecklistState, ItemStatus};
pub use exec::{
BubblewrapSandbox, BubblewrapScope, CommandOutput, DockerSandbox, ExecError, HOME_SECRET_PATHS,
LocalSandbox, SANDBOX_ENV, Sandbox, SandboxCommand, SandboxKind, SandboxSelection,
SeatbeltSandbox, TerminalConfinement, best_available_sandbox, default_deny_read,
home_secret_paths, sandbox_preference_from_env, select_sandbox,
};
pub use fs::{
DEFAULT_IGNORE_DIRS, EditFile, FilePolicy, HostFilePolicy, HostFilePolicySettings,
MAX_READ_CHARS, ProtectedPathGuard, ReadFile, ToolText, WorkspaceBackend, WorkspaceFilePolicy,
WriteFile, format_with_line_numbers, render_read_file_output, render_read_file_output_within,
};
pub use outcome::{
CallValidator, KernelAdapter, NothingSentError, OutcomeRunner, OutcomeTool, TargetNotFound,
ToolTimedOut, failed_without_effect, timed_out,
};
pub use path_class::PathClassifier;
pub use search::{Glob, Grep};
pub use search_files::SearchFiles;
pub use shell::{DEFAULT_ENV_ALLOWLIST, Shell};
pub use util::sniff_image_mime;
pub use web::{NetworkGuard, WebFetch};
pub use workspace::{PathError, Workspace};
pub fn default_tools(workspace: Workspace) -> Vec<Arc<dyn Tool>> {
default_tools_with_sandbox(workspace, best_available_sandbox())
}
pub fn default_tools_with_sandbox(
workspace: Workspace,
sandbox: Arc<dyn Sandbox>,
) -> Vec<Arc<dyn Tool>> {
vec![
Arc::new(ReadFile::new(workspace.clone())),
Arc::new(WriteFile::new(workspace.clone())),
Arc::new(EditFile::new(workspace.clone())),
Arc::new(Glob::new(workspace.clone())),
Arc::new(Grep::new(workspace.clone())),
Arc::new(Shell::new(workspace, sandbox)),
Arc::new(WebFetch::new()),
]
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn default_set_has_strict_unique_specs() {
let (_d, ws) = testutil::ws();
let tools = default_tools(ws);
let mut names: Vec<String> = tools.iter().map(|t| t.spec().name).collect();
names.push(Checklist::default().spec().name);
let mut sorted = names.clone();
sorted.sort();
sorted.dedup();
assert_eq!(sorted.len(), names.len());
for tool in tools
.iter()
.cloned()
.chain([Arc::new(Checklist::default()) as Arc<dyn Tool>])
{
let spec = tool.spec();
assert!(!spec.description.is_empty(), "{}", spec.name);
assert_eq!(spec.parameters["type"], "object", "{}", spec.name);
assert_eq!(
spec.parameters["additionalProperties"],
serde_json::json!(false),
"{}",
spec.name
);
for key in spec.parameters["required"].as_array().unwrap() {
assert!(
spec.parameters["properties"]
.get(key.as_str().unwrap())
.is_some(),
"{}: {key}",
spec.name
);
}
}
let read_only: Vec<bool> = tools.iter().map(|t| t.annotations().read_only).collect();
assert_eq!(read_only, [true, false, false, true, true, false, true]);
}
}