Skip to main content

argentor_builtins/
lib.rs

1//! Built-in skills for the Argentor framework.
2//!
3//! Provides ready-to-use skills covering shell execution, file I/O, HTTP fetching,
4//! semantic memory, artifact storage, browser automation, Docker sandboxing,
5//! human-in-the-loop approval, and agent delegation.
6//!
7//! # Main entry points
8//!
9//! - [`register_builtins()`] — Register the standard set of built-in skills.
10//! - [`register_builtins_with_memory()`] — Register builtins including memory skills.
11//! - [`register_builtins_with_approval()`] — Register builtins with a custom approval channel.
12//! - [`register_all()`] — Register builtins with memory and approval.
13//! - [`register_orchestration_builtins()`] — Register orchestration-specific skills.
14//! - [`register_builtins_with_browser()`] — Register builtins with browser automation.
15
16/// Agent delegation skill for sub-agent spawning.
17pub mod agent_delegate;
18/// Artifact storage skill and backends.
19pub mod artifact_store;
20/// Simple browser skill (URL fetching).
21pub mod browser;
22/// WebDriver-based browser automation skill.
23pub mod browser_automation;
24/// Pure-math calculator skill for precise computations.
25pub mod calculator;
26/// Language-aware code analysis skill.
27pub mod code_analysis;
28/// Color conversion skill (Hex/RGB/HSL, contrast ratio, lighten/darken).
29pub mod color_converter;
30/// Computer-use skill: screenshot, mouse, keyboard, scroll via platform tools.
31#[cfg(feature = "computer-use")]
32pub mod computer_use;
33/// High-level computer-use agentic loop (screenshot → vision → action).
34#[cfg(feature = "computer-use")]
35pub mod computer_use_loop;
36/// Cron expression parsing, validation, and scheduling skill.
37pub mod cron_parser;
38/// CSV parsing, filtering, sorting, statistics, and format conversion.
39pub mod csv_processor;
40/// Data format validation skill.
41pub mod data_validator;
42/// Date/time operations skill.
43pub mod datetime_tool;
44/// Text diff generation and patching skill.
45pub mod diff_tool;
46/// DNS lookup, reverse resolution, and connectivity checks.
47pub mod dns_lookup;
48/// Docker-sandboxed shell execution.
49pub mod docker_sandbox;
50/// DOCX (Microsoft Word) document loader skill.
51pub mod docx_loader;
52/// Encoding/decoding skill (Base64, hex, URL, HTML, JWT).
53pub mod encode_decode;
54/// Environment variable management and .env file parsing skill.
55pub mod env_manager;
56/// EPUB ebook loader skill.
57pub mod epub_loader;
58/// Excel (XLSX) spreadsheet loader skill.
59pub mod excel_loader;
60/// File-system-based artifact backend for persistent storage.
61pub mod file_artifact_backend;
62/// File hashing skill (SHA-256, SHA-512, MD5, checksum verification).
63pub mod file_hasher;
64/// File read skill.
65pub mod file_read;
66/// File write skill.
67pub mod file_write;
68/// Git operations skill (libgit2-based, no shell commands).
69pub mod git;
70/// Cryptographic hashing skill (SHA-256, SHA-512, HMAC-SHA256).
71pub mod hash_tool;
72/// HTML document loader skill.
73pub mod html_loader;
74/// HTTP fetch skill.
75pub mod http_fetch;
76/// Human-in-the-loop approval skill and channels.
77pub mod human_approval;
78/// IP address tools skill (parsing, CIDR, subnet calculation).
79pub mod ip_tools;
80/// JSON query and manipulation skill.
81pub mod json_query;
82/// JWT inspection skill (decode, claims, expiry check).
83pub mod jwt_tool;
84/// Knowledge graph skill for entity-relationship operations.
85pub mod knowledge_graph_skill;
86/// Markdown processing skill (plain text, headings, links, TOC).
87pub mod markdown_renderer;
88/// Semantic memory store and search skills.
89pub mod memory;
90/// In-memory metrics collection skill (counters, gauges, histograms).
91pub mod metrics_collector;
92/// PDF document loader skill.
93pub mod pdf_loader;
94/// PowerPoint (PPTX) presentation loader skill.
95pub mod pptx_loader;
96/// Prompt injection detection and PII scanning skill.
97pub mod prompt_guard;
98/// Regex operations skill.
99pub mod regex_tool;
100/// RSS/Atom feed reader and search.
101pub mod rss_reader;
102/// SDK client code generator for Python and TypeScript.
103pub mod sdk_generator;
104/// Secret scanning skill for detecting leaked credentials.
105pub mod secret_scanner;
106/// Semantic versioning skill (parse, compare, bump, range matching).
107pub mod semver_tool;
108/// Shell command execution skill.
109pub mod shell;
110/// Stdin-based interactive approval channel.
111pub mod stdin_approval;
112/// Extractive text summarization skill.
113pub mod summarizer;
114/// Task status reporting skill.
115pub mod task_status;
116/// Simple template engine skill ({{variable}} rendering, conditionals, loops).
117pub mod template_engine;
118/// Test runner skill for multi-language test execution and result parsing.
119pub mod test_runner;
120/// Text transformation skill for string manipulation operations.
121pub mod text_transform;
122/// UUID generation and parsing skill.
123pub mod uuid_generator;
124/// Web browsing skills: fetch (text/html/markdown), DuckDuckGo search, CSS-selector extraction.
125pub mod web_browse;
126/// Web scraping skill for extracting text, links, metadata from web pages.
127pub mod web_scraper;
128/// Web search skill using DuckDuckGo HTML endpoint.
129pub mod web_search;
130/// XcapitSFF backend integration skills.
131pub mod xcapitsff_skills;
132/// YAML processing skill (parse, stringify, validate, merge, conversion).
133pub mod yaml_processor;
134/// Internal minimal ZIP archive reader for OOXML loaders.
135pub mod zip_reader;
136
137pub use agent_delegate::{AgentDelegateSkill, TaskInfo, TaskQueueHandle, TaskSummary};
138pub use artifact_store::{ArtifactBackend, ArtifactStoreSkill, InMemoryArtifactBackend};
139pub use browser::BrowserSkill;
140pub use browser_automation::{BrowserAction, BrowserAutomationSkill, BrowserConfig, BrowserResult};
141pub use calculator::CalculatorSkill;
142pub use code_analysis::CodeAnalysisSkill;
143pub use color_converter::ColorConverterSkill;
144pub use cron_parser::CronParserSkill;
145pub use csv_processor::CsvProcessorSkill;
146pub use data_validator::DataValidatorSkill;
147pub use datetime_tool::DateTimeSkill;
148pub use diff_tool::DiffSkill;
149pub use dns_lookup::DnsLookupSkill;
150pub use docx_loader::DocxLoaderSkill;
151pub use encode_decode::EncodeDecodeSkill;
152pub use env_manager::EnvManagerSkill;
153pub use epub_loader::EpubLoaderSkill;
154pub use excel_loader::ExcelLoaderSkill;
155pub use file_artifact_backend::FileArtifactBackend;
156pub use file_hasher::FileHasherSkill;
157pub use file_read::FileReadSkill;
158pub use file_write::FileWriteSkill;
159pub use git::GitSkill;
160pub use hash_tool::HashSkill;
161pub use html_loader::HtmlLoaderSkill;
162pub use http_fetch::HttpFetchSkill;
163pub use human_approval::{
164    ApprovalChannel, ApprovalDecision, ApprovalRequest, AutoApproveChannel,
165    CallbackApprovalChannel, HumanApprovalSkill, RiskLevel,
166};
167pub use ip_tools::IpToolsSkill;
168pub use json_query::JsonQuerySkill;
169pub use jwt_tool::JwtToolSkill;
170pub use knowledge_graph_skill::KnowledgeGraphSkill;
171pub use markdown_renderer::MarkdownRendererSkill;
172pub use memory::{MemorySearchSkill, MemoryStoreSkill};
173pub use metrics_collector::MetricsCollectorSkill;
174pub use pdf_loader::PdfLoaderSkill;
175pub use pptx_loader::PptxLoaderSkill;
176pub use prompt_guard::PromptGuardSkill;
177pub use regex_tool::RegexSkill;
178pub use rss_reader::RssReaderSkill;
179pub use sdk_generator::SdkGenerator;
180pub use secret_scanner::SecretScannerSkill;
181pub use semver_tool::SemverToolSkill;
182pub use shell::{CommandPolicy, ShellSkill};
183pub use stdin_approval::StdinApprovalChannel;
184pub use summarizer::SummarizerSkill;
185pub use task_status::TaskStatusSkill;
186pub use template_engine::TemplateEngineSkill;
187pub use test_runner::TestRunnerSkill;
188pub use text_transform::TextTransformSkill;
189pub use uuid_generator::UuidGeneratorSkill;
190#[cfg(feature = "web-browse")]
191pub use web_browse::WebExtractSkill;
192pub use web_browse::{WebBrowseSearchSkill, WebFetchSkill};
193
194#[cfg(feature = "computer-use")]
195pub use computer_use::{
196    ComputerUseConfig, ComputerUseSkill, LinuxController, MacOsController, ScreenController,
197    ScreenRegion,
198};
199#[cfg(feature = "computer-use")]
200pub use computer_use_loop::{ActionLogEntry, ComputerAction, ComputerUseAgent, ComputerUseResult};
201pub use web_scraper::WebScraperSkill;
202pub use web_search::{SearchProvider, WebSearchSkill};
203pub use xcapitsff_skills::{
204    register_xcapitsff_skills, XcapitCustomer360Skill, XcapitKbSearchSkill, XcapitLeadInfoSkill,
205    XcapitSearchSkill, XcapitTicketInfoSkill,
206};
207pub use yaml_processor::YamlProcessorSkill;
208
209pub use docker_sandbox::{DockerSandboxConfig, ExecResult};
210
211#[cfg(feature = "docker")]
212pub use docker_sandbox::{DockerSandbox, DockerShellSkill};
213
214#[cfg(feature = "browser")]
215pub use browser_automation::BrowserAutomation;
216
217use argentor_memory::{EmbeddingProvider, VectorStore};
218use argentor_skills::SkillRegistry;
219use std::sync::Arc;
220
221/// Register the 29 utility skills inspired by Vercel AI SDK, LangChain, CrewAI,
222/// AutoGPT, and Semantic Kernel. These are self-contained (no external API keys).
223///
224/// **Data & Text:** calculator, text_transform, json_query, regex_tool, data_validator,
225///   datetime_tool, csv_processor, yaml_processor, markdown_renderer, template_engine
226/// **Crypto & Encoding:** hash_tool, encode_decode, uuid_generator, jwt_tool, file_hasher
227/// **Versioning & Config:** semver_tool, env_manager, cron_parser
228/// **Web & Network:** web_search, web_scraper, rss_reader, dns_lookup, ip_tools
229/// **Security & AI:** prompt_guard, secret_scanner, diff_tool, summarizer
230/// **Observability:** metrics_collector, color_converter
231pub fn register_utility_skills(registry: &SkillRegistry) {
232    // Data & Text
233    registry.register(Arc::new(CalculatorSkill::default()));
234    registry.register(Arc::new(TextTransformSkill::default()));
235    registry.register(Arc::new(JsonQuerySkill::default()));
236    registry.register(Arc::new(RegexSkill::default()));
237    registry.register(Arc::new(DataValidatorSkill::default()));
238    registry.register(Arc::new(DateTimeSkill::default()));
239    registry.register(Arc::new(CsvProcessorSkill::default()));
240    registry.register(Arc::new(YamlProcessorSkill::default()));
241    registry.register(Arc::new(MarkdownRendererSkill::default()));
242    registry.register(Arc::new(TemplateEngineSkill::default()));
243    // Crypto & Encoding
244    registry.register(Arc::new(HashSkill::default()));
245    registry.register(Arc::new(EncodeDecodeSkill::default()));
246    registry.register(Arc::new(UuidGeneratorSkill::default()));
247    registry.register(Arc::new(JwtToolSkill::default()));
248    registry.register(Arc::new(FileHasherSkill::default()));
249    // Versioning & Config
250    registry.register(Arc::new(SemverToolSkill::default()));
251    registry.register(Arc::new(EnvManagerSkill::default()));
252    registry.register(Arc::new(CronParserSkill::default()));
253    // Web & Network
254    registry.register(Arc::new(WebFetchSkill::default()));
255    registry.register(Arc::new(WebBrowseSearchSkill::default()));
256    registry.register(Arc::new(WebSearchSkill::default()));
257    registry.register(Arc::new(WebScraperSkill::default()));
258    registry.register(Arc::new(RssReaderSkill::default()));
259    registry.register(Arc::new(DnsLookupSkill::default()));
260    registry.register(Arc::new(IpToolsSkill::default()));
261    // Security & AI
262    registry.register(Arc::new(PromptGuardSkill::default()));
263    registry.register(Arc::new(SecretScannerSkill::default()));
264    registry.register(Arc::new(DiffSkill::default()));
265    registry.register(Arc::new(SummarizerSkill::default()));
266    // Observability & Utilities
267    registry.register(Arc::new(MetricsCollectorSkill::new()));
268    registry.register(Arc::new(ColorConverterSkill::default()));
269    // Document Loaders (RAG)
270    registry.register(Arc::new(PdfLoaderSkill::default()));
271    registry.register(Arc::new(DocxLoaderSkill::default()));
272    registry.register(Arc::new(HtmlLoaderSkill::default()));
273    registry.register(Arc::new(EpubLoaderSkill::default()));
274    registry.register(Arc::new(ExcelLoaderSkill::default()));
275    registry.register(Arc::new(PptxLoaderSkill::default()));
276}
277
278/// Register all built-in skills into the given registry.
279/// Uses the provided vector store and embedding provider for memory skills.
280pub fn register_builtins_with_memory(
281    registry: &SkillRegistry,
282    store: Arc<dyn VectorStore>,
283    embedder: Arc<dyn EmbeddingProvider>,
284) {
285    registry.register(Arc::new(ShellSkill::new()));
286    registry.register(Arc::new(FileReadSkill::new()));
287    registry.register(Arc::new(FileWriteSkill::new()));
288    registry.register(Arc::new(HttpFetchSkill::new()));
289    registry.register(Arc::new(BrowserSkill::new()));
290    registry.register(Arc::new(GitSkill::new()));
291    registry.register(Arc::new(CodeAnalysisSkill::new()));
292    registry.register(Arc::new(TestRunnerSkill::new()));
293    registry.register(Arc::new(MemoryStoreSkill::new(
294        store.clone(),
295        embedder.clone(),
296    )));
297    registry.register(Arc::new(MemorySearchSkill::new(store, embedder)));
298    registry.register(Arc::new(HumanApprovalSkill::auto_approve()));
299    register_utility_skills(registry);
300}
301
302/// Register built-in skills without memory (backwards compatible).
303pub fn register_builtins(registry: &SkillRegistry) {
304    registry.register(Arc::new(ShellSkill::new()));
305    registry.register(Arc::new(FileReadSkill::new()));
306    registry.register(Arc::new(FileWriteSkill::new()));
307    registry.register(Arc::new(HttpFetchSkill::new()));
308    registry.register(Arc::new(BrowserSkill::new()));
309    registry.register(Arc::new(GitSkill::new()));
310    registry.register(Arc::new(CodeAnalysisSkill::new()));
311    registry.register(Arc::new(TestRunnerSkill::new()));
312    registry.register(Arc::new(HumanApprovalSkill::auto_approve()));
313    register_utility_skills(registry);
314}
315
316/// Register built-in skills with a custom approval channel for HITL.
317pub fn register_builtins_with_approval(
318    registry: &SkillRegistry,
319    approval_channel: Arc<dyn ApprovalChannel>,
320) {
321    registry.register(Arc::new(ShellSkill::new()));
322    registry.register(Arc::new(FileReadSkill::new()));
323    registry.register(Arc::new(FileWriteSkill::new()));
324    registry.register(Arc::new(HttpFetchSkill::new()));
325    registry.register(Arc::new(BrowserSkill::new()));
326    registry.register(Arc::new(GitSkill::new()));
327    registry.register(Arc::new(CodeAnalysisSkill::new()));
328    registry.register(Arc::new(TestRunnerSkill::new()));
329    registry.register(Arc::new(HumanApprovalSkill::new(approval_channel)));
330    register_utility_skills(registry);
331}
332
333/// Register all built-in skills including memory and a custom approval channel.
334pub fn register_all(
335    registry: &SkillRegistry,
336    store: Arc<dyn VectorStore>,
337    embedder: Arc<dyn EmbeddingProvider>,
338    approval_channel: Arc<dyn ApprovalChannel>,
339) {
340    registry.register(Arc::new(ShellSkill::new()));
341    registry.register(Arc::new(FileReadSkill::new()));
342    registry.register(Arc::new(FileWriteSkill::new()));
343    registry.register(Arc::new(HttpFetchSkill::new()));
344    registry.register(Arc::new(BrowserSkill::new()));
345    registry.register(Arc::new(GitSkill::new()));
346    registry.register(Arc::new(CodeAnalysisSkill::new()));
347    registry.register(Arc::new(TestRunnerSkill::new()));
348    registry.register(Arc::new(MemoryStoreSkill::new(
349        store.clone(),
350        embedder.clone(),
351    )));
352    registry.register(Arc::new(MemorySearchSkill::new(store, embedder)));
353    registry.register(Arc::new(HumanApprovalSkill::new(approval_channel)));
354    register_utility_skills(registry);
355}
356
357/// Register orchestration-specific skills (artifact_store, agent_delegate, task_status).
358/// These require a TaskQueueHandle and ArtifactBackend from the orchestrator.
359pub fn register_orchestration_builtins(
360    registry: &SkillRegistry,
361    queue: Arc<dyn TaskQueueHandle>,
362    artifact_backend: Arc<dyn ArtifactBackend>,
363) {
364    registry.register(Arc::new(ArtifactStoreSkill::new(artifact_backend)));
365    registry.register(Arc::new(AgentDelegateSkill::new(queue.clone())));
366    registry.register(Arc::new(TaskStatusSkill::new(queue)));
367}
368
369/// Register built-in skills plus the browser automation skill.
370///
371/// This registers all the standard builtins and adds `BrowserAutomationSkill`
372/// configured with the given `BrowserConfig`. The actual WebDriver connection
373/// is established lazily when the skill is first invoked, and only when the
374/// `browser` feature is enabled.
375pub fn register_builtins_with_browser(registry: &SkillRegistry, config: BrowserConfig) {
376    registry.register(Arc::new(ShellSkill::new()));
377    registry.register(Arc::new(FileReadSkill::new()));
378    registry.register(Arc::new(FileWriteSkill::new()));
379    registry.register(Arc::new(HttpFetchSkill::new()));
380    registry.register(Arc::new(BrowserSkill::new()));
381    registry.register(Arc::new(GitSkill::new()));
382    registry.register(Arc::new(CodeAnalysisSkill::new()));
383    registry.register(Arc::new(TestRunnerSkill::new()));
384    registry.register(Arc::new(HumanApprovalSkill::auto_approve()));
385    registry.register(Arc::new(BrowserAutomationSkill::new(config)));
386}