openfunctions_rs/core/builder.rs
1//! Build system for creating executable artifacts from tools and agents.
2
3use crate::core::Config;
4use anyhow::Result;
5use tracing::info;
6
7/// Builder for compiling tools and agents into executable formats.
8///
9/// The `Builder` is responsible for taking source files (like scripts) and
10/// creating runnable artifacts in the configured output directory.
11pub struct Builder {
12 #[allow(dead_code)]
13 config: Config,
14}
15
16impl Builder {
17 /// Creates a new `Builder` with the given configuration.
18 pub fn new(config: Config) -> Self {
19 Self { config }
20 }
21
22 /// Builds all tools and agents found in the configured directories.
23 pub async fn build_all(&self) -> Result<()> {
24 self.build_all_tools().await?;
25 self.build_all_agents().await?;
26 Ok(())
27 }
28
29 /// Builds all tools.
30 ///
31 /// This function will scan the tool directories specified in the configuration,
32 /// and then process each tool to create a build artifact.
33 pub async fn build_all_tools(&self) -> Result<()> {
34 info!("Building all tools...");
35 // TODO: Implement logic to load all tools from `self.config.tool_dirs`
36 // and build each one.
37 Ok(())
38 }
39
40 /// Builds all agents.
41 ///
42 /// This function will scan the agent directories specified in the configuration,
43 /// and then process each agent to create a build artifact.
44 pub async fn build_all_agents(&self) -> Result<()> {
45 info!("Building all agents...");
46 // TODO: Implement logic to load all agents from `self.config.agent_dirs`
47 // and build each one.
48 Ok(())
49 }
50
51 /// Builds a specific target, which can be a tool or an agent.
52 pub async fn build_target(&self, target: &str) -> Result<()> {
53 info!("Building target: {}", target);
54 // TODO: Implement logic to find whether the target is a tool or an agent,
55 // then load it and build it.
56 Ok(())
57 }
58}