aigency 0.0.1rc15474277__py3-none-any.whl → 0.0.1rc62012314__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,42 @@
1
+ """Agent skill definition and configuration schema.
2
+
3
+ This module defines the Skill Pydantic model for representing specific capabilities
4
+ or skills that an agent possesses within the Aigency framework. Skills define
5
+ what an agent can do and provide structured metadata about the agent's abilities.
6
+
7
+ Skills serve as descriptive components that help categorize and communicate an
8
+ agent's capabilities to other agents and systems in the A2A ecosystem.
9
+
10
+ Example:
11
+ Defining agent skills:
12
+
13
+ >>> skill = Skill(
14
+ ... name="data_analysis",
15
+ ... description="Analyze datasets and generate insights",
16
+ ... tags=["analytics"]
17
+ ... )
18
+
19
+ Attributes:
20
+ None: This module contains only Pydantic model definitions.
21
+ """
22
+
23
+ from pydantic import BaseModel
24
+ from typing import List
25
+
26
+
27
+ class Skill(BaseModel):
28
+ """Define a specific skill of the agent.
29
+
30
+ Attributes:
31
+ id (str): Unique identifier for the skill.
32
+ name (str): Human-readable name of the skill.
33
+ description (str): Detailed description of what the skill does.
34
+ tags (List[str]): List of tags for categorizing the skill.
35
+ examples (List[str]): List of usage examples for the skill.
36
+ """
37
+
38
+ id: str
39
+ name: str
40
+ description: str
41
+ tags: List[str]
42
+ examples: List[str]
@@ -0,0 +1,126 @@
1
+ """Tool configuration schemas for agent capabilities.
2
+
3
+ This module defines comprehensive Pydantic models for configuring various types
4
+ of tools that agents can use within the Aigency framework. It supports multiple
5
+ tool types including MCP (Model Context Protocol) tools and function-based tools,
6
+ with specific configuration schemas for each type.
7
+
8
+ The module provides a flexible and extensible tool configuration system that
9
+ allows agents to integrate with different tool providers and execution environments,
10
+ enabling rich agent capabilities through external tool integration.
11
+
12
+ Example:
13
+ Configuring different tool types:
14
+
15
+ >>> function_tool = FunctionTool(
16
+ ... type=ToolType.FUNCTION,
17
+ ... name="calculator",
18
+ ... module_path="math_tools",
19
+ ... function_name="add"
20
+ ... )
21
+ >>> mcp_tool = McpTool(
22
+ ... type=ToolType.MCP,
23
+ ... name="file_manager",
24
+ ... mcp_config=McpTypeStdio(command="file-server")
25
+ ... )
26
+
27
+ Attributes:
28
+ None: This module contains only Pydantic model definitions and enums.
29
+ """
30
+
31
+ from enum import Enum
32
+ from typing import Dict, List, Optional, TypeAlias
33
+
34
+ from pydantic import BaseModel
35
+
36
+
37
+ class ToolType(str, Enum):
38
+ """Enum for tool types.
39
+
40
+ Defines the available types of tools that can be used by agents.
41
+
42
+ Attributes:
43
+ MCP: MCP (Model Context Protocol) based tools.
44
+ FUNCTION: Function-based tools loaded from Python modules.
45
+ """
46
+
47
+ MCP = "mcp"
48
+ FUNCTION = "function"
49
+
50
+
51
+ class BaseTool(BaseModel):
52
+ """Define an external tool that the agent can use.
53
+
54
+ Base class for all tool configurations containing common attributes.
55
+
56
+ Attributes:
57
+ type (ToolType): The type of tool (MCP or FUNCTION).
58
+ name (str): Name identifier for the tool.
59
+ description (str): Human-readable description of what the tool does.
60
+ """
61
+
62
+ type: ToolType
63
+ name: str
64
+ description: str
65
+
66
+
67
+ class FunctionTool(BaseTool):
68
+ """Configuration for function-based tools.
69
+
70
+ Tools that are loaded from Python functions in specified modules.
71
+
72
+ Attributes:
73
+ module_path (str): Python module path containing the function.
74
+ function_name (str): Name of the function to load from the module.
75
+ """
76
+
77
+ module_path: str
78
+ function_name: str
79
+
80
+
81
+ class McpTypeStreamable(BaseModel):
82
+ """Model for streamable tool type.
83
+
84
+ Configuration for MCP tools that communicate via HTTP streaming.
85
+
86
+ Attributes:
87
+ url (str): Base URL for the MCP server.
88
+ port (int): Port number for the MCP server.
89
+ path (str): URL path for the MCP endpoint. Defaults to "/".
90
+ """
91
+
92
+ url: str
93
+ port: int
94
+ path: str = "/"
95
+
96
+
97
+ class McpTypeStdio(BaseModel):
98
+ """Model for stdio tool type.
99
+
100
+ Configuration for MCP tools that communicate via standard input/output.
101
+
102
+ Attributes:
103
+ command (str): Command to execute for the MCP server.
104
+ args (List[str]): Command line arguments for the MCP server.
105
+ env (Dict[str, str], optional): Environment variables for the MCP server.
106
+ """
107
+
108
+ command: str
109
+ args: List[str]
110
+ env: Optional[Dict[str, str]] = None
111
+
112
+
113
+ class McpTool(BaseTool):
114
+ """Configuration for MCP-based tools.
115
+
116
+ Tools that use the Model Context Protocol for communication.
117
+
118
+ Attributes:
119
+ mcp_config (McpTypeStreamable | McpTypeStdio): Configuration for the MCP
120
+ connection, either streamable HTTP or stdio based.
121
+ """
122
+
123
+ mcp_config: McpTypeStreamable | McpTypeStdio
124
+
125
+
126
+ Tool: TypeAlias = FunctionTool | McpTool
@@ -0,0 +1,48 @@
1
+ """Root configuration model for Aigency agents.
2
+
3
+ This module defines the main configuration schema for Aigency agents using Pydantic
4
+ models. It provides a comprehensive structure that encompasses all aspects of agent
5
+ configuration including metadata, service settings, agent logic, and observability.
6
+
7
+ The AigencyConfig class serves as the root model that validates and structures
8
+ agent configurations loaded from YAML files, ensuring type safety and proper
9
+ validation of all configuration parameters.
10
+
11
+ Example:
12
+ Loading and using agent configuration:
13
+
14
+ >>> config_data = yaml.safe_load(open("agent.yaml"))
15
+ >>> config = AigencyConfig(**config_data)
16
+ >>> agent_name = config.metadata.name
17
+ >>> model_name = config.agent.model.name
18
+
19
+ Attributes:
20
+ None: This module contains only Pydantic model definitions.
21
+ """
22
+
23
+ from pydantic import BaseModel
24
+ from typing import Optional
25
+ from aigency.schemas.observability.observability import Observability
26
+ from aigency.schemas.metadata.metadata import Metadata
27
+ from aigency.schemas.agent.agent import Agent
28
+ from aigency.schemas.service.service import Service
29
+
30
+
31
+ class AigencyConfig(BaseModel):
32
+ """Root Pydantic model for complete agent configuration.
33
+
34
+ This is the main configuration model that encompasses all aspects of an
35
+ agent's setup including metadata, service configuration, agent logic,
36
+ and observability settings.
37
+
38
+ Attributes:
39
+ metadata (Metadata): Descriptive information about the agent.
40
+ service (Service): Network and communication configuration.
41
+ agent (Agent): Core agent logic, model, and capabilities.
42
+ observability (Observability, optional): Monitoring and observability settings.
43
+ """
44
+
45
+ metadata: Metadata
46
+ service: Service
47
+ agent: Agent
48
+ observability: Optional[Observability] = None
@@ -0,0 +1,38 @@
1
+ """Agent metadata and descriptive information schema.
2
+
3
+ This module defines the Metadata Pydantic model for storing descriptive information
4
+ about agents in the Aigency framework. It provides structured metadata that helps
5
+ identify, categorize, and describe agents within the system.
6
+
7
+ The metadata includes essential information such as agent names, descriptions,
8
+ versions, and other descriptive attributes that facilitate agent discovery,
9
+ management, and documentation.
10
+
11
+ Example:
12
+ Creating agent metadata:
13
+
14
+ >>> metadata = Metadata(
15
+ ... name="data_analyst",
16
+ ... description="Analyzes data and generates reports",
17
+ ... version="1.0.0",
18
+ ... )
19
+
20
+ Attributes:
21
+ None: This module contains only Pydantic model definitions.
22
+ """
23
+
24
+ from pydantic import BaseModel
25
+
26
+
27
+ class Metadata(BaseModel):
28
+ """Descriptive metadata of the agent.
29
+
30
+ Attributes:
31
+ name (str): Name of the agent.
32
+ version (str): Version identifier of the agent.
33
+ description (str): Human-readable description of the agent's purpose.
34
+ """
35
+
36
+ name: str
37
+ version: str
38
+ description: str
@@ -0,0 +1,45 @@
1
+ """Observability and monitoring configuration schemas.
2
+
3
+ This module defines Pydantic models for configuring observability and monitoring
4
+ capabilities within the Aigency framework. It provides structured configuration
5
+ for various monitoring systems and observability tools that help track agent
6
+ performance, behavior, and system health.
7
+
8
+ The observability configuration enables comprehensive monitoring of agent
9
+ operations, including metrics collection, logging, tracing, and integration
10
+ with external monitoring platforms.
11
+
12
+ Example:
13
+ Configuring observability settings:
14
+
15
+ >>> monitoring = Monitoring(phoenix=Phoenix(enabled=True, metrics_endpoint="/metrics"))
16
+ >>> observability = Observability(
17
+ ... monitoring=monitoring
18
+ ... )
19
+
20
+ Attributes:
21
+ None: This module contains only Pydantic model definitions.
22
+ """
23
+
24
+ from pydantic import BaseModel
25
+ from aigency.schemas.observability.phoenix import Phoenix
26
+
27
+
28
+ class Monitoring(BaseModel):
29
+ """Configuration for monitoring tools.
30
+
31
+ Attributes:
32
+ phoenix (Phoenix): Phoenix monitoring configuration.
33
+ """
34
+
35
+ phoenix: Phoenix
36
+
37
+
38
+ class Observability(BaseModel):
39
+ """Groups all observability configurations.
40
+
41
+ Attributes:
42
+ monitoring (Monitoring): Monitoring tools configuration.
43
+ """
44
+
45
+ monitoring: Monitoring
@@ -0,0 +1,36 @@
1
+ """Phoenix monitoring system configuration schema.
2
+
3
+ This module defines the Phoenix Pydantic model for configuring Phoenix monitoring
4
+ integration within the Aigency framework. Phoenix is a monitoring and observability
5
+ platform that provides insights into agent behavior, performance metrics, and
6
+ system health monitoring.
7
+
8
+ The Phoenix configuration enables agents to integrate with Phoenix monitoring
9
+ services, allowing for comprehensive tracking and analysis of agent operations
10
+ in production environments.
11
+
12
+ Example:
13
+ Configuring Phoenix monitoring:
14
+
15
+ >>> phoenix = Phoenix(
16
+ ... host="phoenix",
17
+ ... port=6006
18
+ ... )
19
+
20
+ Attributes:
21
+ None: This module contains only Pydantic model definitions.
22
+ """
23
+
24
+ from pydantic import BaseModel
25
+
26
+
27
+ class Phoenix(BaseModel):
28
+ """Configuration for Phoenix monitor.
29
+
30
+ Attributes:
31
+ host (str): Hostname or IP address for Phoenix monitoring service.
32
+ port (int): Port number for Phoenix monitoring service.
33
+ """
34
+
35
+ host: str
36
+ port: int
@@ -0,0 +1,32 @@
1
+ """Service capability configuration schema.
2
+
3
+ This module defines the Capabilities Pydantic model for configuring service
4
+ capabilities within the Aigency framework. It provides structured configuration
5
+ for defining what capabilities a service or agent can provide to other components
6
+ in the system.
7
+
8
+ The capabilities configuration helps establish service contracts and enables
9
+ proper service discovery and integration within the distributed agent ecosystem.
10
+
11
+ Example:
12
+ Configuring service capabilities:
13
+
14
+ >>> capabilities = Capabilities(
15
+ ... streaming=True
16
+ ... )
17
+
18
+ Attributes:
19
+ None: This module contains only Pydantic model definitions.
20
+ """
21
+
22
+ from pydantic import BaseModel
23
+
24
+
25
+ class Capabilities(BaseModel):
26
+ """Technical capabilities of the agent service.
27
+
28
+ Attributes:
29
+ streaming (bool): Whether the agent supports streaming responses.
30
+ """
31
+
32
+ streaming: bool
@@ -0,0 +1,37 @@
1
+ """Service interface configuration schema.
2
+
3
+ This module defines the Interface Pydantic model for configuring service
4
+ interfaces within the Aigency framework. It provides structured configuration
5
+ for defining how services expose their functionality and communicate with
6
+ other components in the system.
7
+
8
+ The interface configuration establishes the communication protocols, endpoints,
9
+ and interaction patterns that services use to integrate with the broader
10
+ agent ecosystem.
11
+
12
+ Example:
13
+ Configuring service interface:
14
+
15
+ >>> interface = Interface(
16
+ ... default_input_modes=["text/plain"],
17
+ ... default_output_modes=["text/plain"]
18
+ ... )
19
+
20
+ Attributes:
21
+ None: This module contains only Pydantic model definitions.
22
+ """
23
+
24
+ from typing import List
25
+ from pydantic import BaseModel
26
+
27
+
28
+ class Interface(BaseModel):
29
+ """Define the agent's communication modes.
30
+
31
+ Attributes:
32
+ default_input_modes (List[str]): List of supported input communication modes.
33
+ default_output_modes (List[str]): List of supported output communication modes.
34
+ """
35
+
36
+ default_input_modes: List[str]
37
+ default_output_modes: List[str]
@@ -0,0 +1,42 @@
1
+ """Service network and communication configuration schema.
2
+
3
+ This module defines the Service Pydantic model for configuring service-level
4
+ settings within the Aigency framework. It provides structured configuration
5
+ for network communication, service discovery, and integration parameters
6
+ that enable agents to operate as distributed services.
7
+
8
+ The service configuration encompasses network settings, communication protocols,
9
+ and service-specific parameters that facilitate agent deployment and operation
10
+ in distributed environments.
11
+
12
+ Example:
13
+ Configuring service settings:
14
+
15
+ >>> service = Service(
16
+ ... interface=Interface(default_input_modes=["text/plain"]),
17
+ ... capabilities=Capabilities(streaming=True),
18
+ ... host="0.0.0.0",
19
+ ... port=8080
20
+ ... )
21
+
22
+ Attributes:
23
+ None: This module contains only Pydantic model definitions.
24
+ """
25
+
26
+ from pydantic import BaseModel
27
+ from aigency.schemas.service.interface import Interface
28
+ from aigency.schemas.service.capabilities import Capabilities
29
+
30
+
31
+ class Service(BaseModel):
32
+ """Network and communication configuration of the agent.
33
+
34
+ Attributes:
35
+ url (str): Base URL where the agent service is accessible.
36
+ interface (Interface): Communication interface configuration.
37
+ capabilities (Capabilities): Technical capabilities of the service.
38
+ """
39
+
40
+ url: str
41
+ interface: Interface
42
+ capabilities: Capabilities
@@ -1,7 +1,24 @@
1
- """Tool Factory for dynamically loading and managing agent tools.
1
+ """Tool factory for dynamically loading and managing agent tools.
2
2
 
3
3
  This module provides a flexible way to load different types of tools based on
4
- configuration. It uses the Strategy pattern and Pydantic for validation.
4
+ configuration using the Strategy pattern and Pydantic for validation. It supports
5
+ both MCP (Model Context Protocol) tools and function-based tools, handling their
6
+ instantiation and configuration automatically.
7
+
8
+ The ToolGenerator class uses a strategy-based approach to delegate tool creation
9
+ to specialized loading functions based on the tool type, providing a clean and
10
+ extensible architecture for tool management.
11
+
12
+ Example:
13
+ Creating tools from configuration:
14
+
15
+ >>> tool_config = FunctionTool(type=ToolType.FUNCTION, name="calculator",
16
+ ... module_path="math_tools", function_name="add")
17
+ >>> tool = ToolGenerator.create_tool(tool_config)
18
+ >>> result = tool(2, 3)
19
+
20
+ Attributes:
21
+ None: This module contains only class definitions and strategy mappings.
5
22
  """
6
23
 
7
24
  import importlib
@@ -14,7 +31,7 @@ from google.adk.tools.mcp_tool.mcp_toolset import (
14
31
  StreamableHTTPConnectionParams,
15
32
  )
16
33
 
17
- from aigency.models.tools import (
34
+ from aigency.schemas.agent.tools import (
18
35
  FunctionTool,
19
36
  McpTool,
20
37
  McpTypeStdio,
@@ -26,11 +43,32 @@ from aigency.utils.utils import expand_env_vars
26
43
 
27
44
 
28
45
  class ToolGenerator:
29
- """Generator for creating tools based on configuration."""
46
+ """Generator for creating tools based on configuration.
47
+
48
+ This class provides static methods to dynamically load and create different
49
+ types of tools (MCP and Function tools) based on their configuration using
50
+ the Strategy pattern.
51
+
52
+ Attributes:
53
+ STRATEGIES (dict): Dictionary mapping tool types to their loading functions.
54
+ """
30
55
 
31
56
  @staticmethod
32
57
  def load_function_tool(config: FunctionTool) -> Any:
33
- """Load a function tool from configuration."""
58
+ """Load a function tool from configuration.
59
+
60
+ Dynamically imports a Python module and retrieves the specified function
61
+ to use as a tool.
62
+
63
+ Args:
64
+ config (FunctionTool): Configuration containing module path and function name.
65
+
66
+ Returns:
67
+ Any: The loaded function object.
68
+
69
+ Raises:
70
+ ValueError: If the module cannot be imported or function not found.
71
+ """
34
72
  try:
35
73
  module = importlib.import_module(config.module_path)
36
74
  return getattr(module, config.function_name)
@@ -39,15 +77,20 @@ class ToolGenerator:
39
77
 
40
78
  @staticmethod
41
79
  def load_mcp_tool(config: McpTool) -> Any:
42
- """Load an MCP tool from configuration."""
80
+ """Load an MCP tool from configuration.
81
+
82
+ Creates an MCP toolset based on the connection type (streamable HTTP or stdio).
83
+
84
+ Args:
85
+ config (McpTool): Configuration containing MCP connection details.
86
+
87
+ Returns:
88
+ Any: The created MCPToolset instance.
89
+ """
43
90
 
44
91
  if isinstance(config.mcp_config, McpTypeStreamable):
45
92
  url = f"http://{config.mcp_config.url}:{config.mcp_config.port}{config.mcp_config.path}"
46
- return MCPToolset(
47
- connection_params=StreamableHTTPConnectionParams(
48
- url=url
49
- )
50
- )
93
+ return MCPToolset(connection_params=StreamableHTTPConnectionParams(url=url))
51
94
  elif isinstance(config.mcp_config, McpTypeStdio):
52
95
  command = config.mcp_config.command
53
96
  args = config.mcp_config.args
@@ -65,19 +108,23 @@ class ToolGenerator:
65
108
  ToolType.MCP: load_mcp_tool,
66
109
  ToolType.FUNCTION: load_function_tool,
67
110
  }
68
-
111
+
69
112
  @staticmethod
70
113
  def create_tool(tool: Tool) -> Optional[Any]:
71
114
  """Create a tool based on its configuration.
72
115
 
116
+ Uses the Strategy pattern to delegate tool creation to the appropriate
117
+ loading function based on the tool type.
118
+
73
119
  Args:
74
- tool: Tool configuration
120
+ tool (Tool): Tool configuration (FunctionTool or McpTool).
75
121
 
76
122
  Returns:
77
- The created tool or None if creation failed
123
+ Any | None: The created tool instance or None if creation failed.
78
124
 
79
125
  Raises:
80
- ValueError: If tool type is not supported or config is invalid
126
+ ValueError: If tool type is not supported or config is invalid.
127
+ KeyError: If tool type is not found in STRATEGIES.
81
128
  """
82
129
 
83
130
  return ToolGenerator.STRATEGIES[tool.type](tool)