1mod component_suffix;
7mod field_component;
8mod mcp;
9mod metadata;
10mod rust_syntax;
11mod value_change;
12
13pub use component_suffix::{
14 ComponentSuffix, ComponentSuffixError, component_suffix_from_suffix, is_valid_component_suffix,
15 validate_component_suffix,
16};
17pub use field_component::{ComponentFieldName, ComponentShapeUse};
18pub use mcp::{
19 McpInput, McpInputShape, McpPrimitiveKind, McpRangeBoundKind, McpToolMetadataError,
20 validate_mcp_tool_metadata_text, validate_mcp_tool_name,
21};
22pub use metadata::{
23 ComponentCapabilities, ComponentPrototyping, RenderCapability, ValueBindingCapability,
24};
25pub use rust_syntax::{RustExpr, RustPath, RustSyntaxError, RustSyntaxKind, RustType};
26pub use value_change::ValueChange;
27
28pub trait ComponentShapeMetadata {
30 const PROTOTYPING: ComponentPrototyping = ComponentPrototyping::new();
32 const CAPABILITIES: ComponentCapabilities = ComponentCapabilities::new();
34 const MCP_INPUT: McpInput = McpInput::unsupported();
36}
37
38pub trait DeclaredComponentShape: ComponentShapeMetadata {}
45
46pub trait ComponentShapeFor<Value>: ComponentShapeMetadata {
54 const MCP_INPUT: McpInput = <Self as ComponentShapeMetadata>::MCP_INPUT;
59}
60
61#[cfg(test)]
62mod tests {
63 use super::{
64 ComponentShapeFor, ComponentShapeMetadata, McpInput, McpInputShape, McpPrimitiveKind,
65 };
66
67 struct TextShape;
68
69 impl ComponentShapeMetadata for TextShape {
70 const MCP_INPUT: McpInput = McpInput::string();
71 }
72
73 impl ComponentShapeFor<String> for TextShape {}
74
75 impl ComponentShapeFor<Vec<String>> for TextShape {
76 const MCP_INPUT: McpInput = McpInput::string_list();
77 }
78
79 #[test]
80 fn component_shape_for_inherits_shape_level_mcp_input_by_default() {
81 assert_eq!(
82 <TextShape as ComponentShapeFor<String>>::MCP_INPUT.input_shape(),
83 McpInputShape::Scalar(McpPrimitiveKind::String)
84 );
85 }
86
87 #[test]
88 fn component_shape_for_can_override_value_specific_mcp_input() {
89 assert_eq!(
90 <TextShape as ComponentShapeFor<Vec<String>>>::MCP_INPUT.input_shape(),
91 McpInputShape::List(McpPrimitiveKind::String)
92 );
93 }
94}