cargo_adk/template.rs
1//! Agent template definitions for the composable scaffolding engine.
2//!
3//! Templates define the *agent structure* — the core agent type and its construction code.
4
5/// Category of a template in the registry.
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum TemplateCategory {
8 /// A core agent type (llm, sequential, parallel, etc.)
9 AgentType,
10 /// An enterprise-grade pre-composed pattern
11 EnterprisePattern,
12 /// A legacy template preserved for backward compatibility
13 Legacy,
14}
15
16/// A file to be generated as part of the scaffold.
17#[derive(Debug, Clone)]
18pub struct FileFragment {
19 /// Relative path within the generated project.
20 pub path: &'static str,
21 /// File content to write.
22 pub content: &'static str,
23}
24
25/// Code fragments that define the agent's structure in `main.rs`.
26#[derive(Debug, Clone)]
27pub struct AgentCodeFragments {
28 /// Import statements needed at the top of `main.rs`.
29 pub imports: Vec<&'static str>,
30 /// The agent construction code (e.g., `LlmAgent::builder()...`).
31 pub agent_construction: &'static str,
32 /// Additional files to generate beyond `main.rs`.
33 pub additional_files: Vec<FileFragment>,
34}
35
36/// Defines an agent type template (e.g., llm, sequential, graph).
37#[derive(Debug, Clone)]
38pub struct AgentTemplate {
39 /// Template name used in CLI (e.g., "llm", "sequential").
40 pub name: &'static str,
41 /// Human-readable description.
42 pub description: &'static str,
43 /// Category for grouping in display.
44 pub category: TemplateCategory,
45 /// Default LLM provider for this template.
46 pub default_provider: &'static str,
47 /// Cargo features required by this template.
48 pub required_features: Vec<&'static str>,
49 /// Addons that are incompatible with this template.
50 pub incompatible_addons: Vec<&'static str>,
51 /// Code fragments for generating the agent.
52 pub code_fragments: AgentCodeFragments,
53}