daita-agents 0.1.0__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.
Potentially problematic release.
This version of daita-agents might be problematic. Click here for more details.
- daita/__init__.py +208 -0
- daita/agents/__init__.py +33 -0
- daita/agents/base.py +722 -0
- daita/agents/substrate.py +895 -0
- daita/cli/__init__.py +145 -0
- daita/cli/__main__.py +7 -0
- daita/cli/ascii_art.py +44 -0
- daita/cli/core/__init__.py +0 -0
- daita/cli/core/create.py +254 -0
- daita/cli/core/deploy.py +473 -0
- daita/cli/core/deployments.py +309 -0
- daita/cli/core/import_detector.py +219 -0
- daita/cli/core/init.py +382 -0
- daita/cli/core/logs.py +239 -0
- daita/cli/core/managed_deploy.py +709 -0
- daita/cli/core/run.py +648 -0
- daita/cli/core/status.py +421 -0
- daita/cli/core/test.py +239 -0
- daita/cli/core/webhooks.py +172 -0
- daita/cli/main.py +588 -0
- daita/cli/utils.py +541 -0
- daita/config/__init__.py +62 -0
- daita/config/base.py +159 -0
- daita/config/settings.py +184 -0
- daita/core/__init__.py +262 -0
- daita/core/decision_tracing.py +701 -0
- daita/core/exceptions.py +480 -0
- daita/core/focus.py +251 -0
- daita/core/interfaces.py +76 -0
- daita/core/plugin_tracing.py +550 -0
- daita/core/relay.py +695 -0
- daita/core/reliability.py +381 -0
- daita/core/scaling.py +444 -0
- daita/core/tools.py +402 -0
- daita/core/tracing.py +770 -0
- daita/core/workflow.py +1084 -0
- daita/display/__init__.py +1 -0
- daita/display/console.py +160 -0
- daita/execution/__init__.py +58 -0
- daita/execution/client.py +856 -0
- daita/execution/exceptions.py +92 -0
- daita/execution/models.py +317 -0
- daita/llm/__init__.py +60 -0
- daita/llm/anthropic.py +166 -0
- daita/llm/base.py +373 -0
- daita/llm/factory.py +101 -0
- daita/llm/gemini.py +152 -0
- daita/llm/grok.py +114 -0
- daita/llm/mock.py +135 -0
- daita/llm/openai.py +109 -0
- daita/plugins/__init__.py +141 -0
- daita/plugins/base.py +37 -0
- daita/plugins/base_db.py +167 -0
- daita/plugins/elasticsearch.py +844 -0
- daita/plugins/mcp.py +481 -0
- daita/plugins/mongodb.py +510 -0
- daita/plugins/mysql.py +351 -0
- daita/plugins/postgresql.py +331 -0
- daita/plugins/redis_messaging.py +500 -0
- daita/plugins/rest.py +529 -0
- daita/plugins/s3.py +761 -0
- daita/plugins/slack.py +729 -0
- daita/utils/__init__.py +18 -0
- daita_agents-0.1.0.dist-info/METADATA +350 -0
- daita_agents-0.1.0.dist-info/RECORD +69 -0
- daita_agents-0.1.0.dist-info/WHEEL +5 -0
- daita_agents-0.1.0.dist-info/entry_points.txt +2 -0
- daita_agents-0.1.0.dist-info/licenses/LICENSE +56 -0
- daita_agents-0.1.0.dist-info/top_level.txt +1 -0
daita/config/base.py
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Configuration models for Daita Agents.
|
|
3
|
+
|
|
4
|
+
Simplified configuration system focused on essential functionality for MVP.
|
|
5
|
+
Advanced features like complex retry policies and error analysis can be added later.
|
|
6
|
+
"""
|
|
7
|
+
import asyncio
|
|
8
|
+
from enum import Enum
|
|
9
|
+
from typing import Any, Dict, List, Optional, Union
|
|
10
|
+
from pydantic import BaseModel, Field, model_validator
|
|
11
|
+
|
|
12
|
+
class YamlSerializableMixin:
|
|
13
|
+
"""Mixin for YAML serialization support."""
|
|
14
|
+
|
|
15
|
+
def model_dump_yaml_safe(self) -> Dict[str, Any]:
|
|
16
|
+
"""Export to YAML-safe dictionary."""
|
|
17
|
+
return self.model_dump(mode='json', exclude_none=True)
|
|
18
|
+
|
|
19
|
+
class AgentType(str, Enum):
|
|
20
|
+
"""Types of agents available."""
|
|
21
|
+
SUBSTRATE = "substrate"
|
|
22
|
+
# Keep room for future agent types without forcing everything to be SUBSTRATE
|
|
23
|
+
|
|
24
|
+
class FocusType(str, Enum):
|
|
25
|
+
"""Types of focus selectors."""
|
|
26
|
+
COLUMN = "column"
|
|
27
|
+
JSONPATH = "jsonpath"
|
|
28
|
+
XPATH = "xpath"
|
|
29
|
+
CSS_SELECTOR = "css"
|
|
30
|
+
REGEX = "regex"
|
|
31
|
+
SEMANTIC = "semantic"
|
|
32
|
+
|
|
33
|
+
class RetryStrategy(str, Enum):
|
|
34
|
+
"""Retry strategy types - unified from core/reliability.py."""
|
|
35
|
+
FIXED = "fixed"
|
|
36
|
+
EXPONENTIAL = "exponential"
|
|
37
|
+
LINEAR = "linear"
|
|
38
|
+
# Legacy aliases for backward compatibility
|
|
39
|
+
EXPONENTIAL_BACKOFF = "exponential"
|
|
40
|
+
FIXED_DELAY = "fixed"
|
|
41
|
+
IMMEDIATE = "fixed"
|
|
42
|
+
|
|
43
|
+
class FocusConfig(YamlSerializableMixin, BaseModel):
|
|
44
|
+
"""Configuration for focus parameter."""
|
|
45
|
+
type: Optional[FocusType] = None
|
|
46
|
+
include: Optional[Union[List[str], str]] = None
|
|
47
|
+
exclude: Optional[Union[List[str], str]] = None
|
|
48
|
+
paths: Optional[List[str]] = None
|
|
49
|
+
description: Optional[str] = None
|
|
50
|
+
|
|
51
|
+
class RetryPolicy(YamlSerializableMixin, BaseModel):
|
|
52
|
+
"""Unified retry configuration compatible with core/reliability.py."""
|
|
53
|
+
|
|
54
|
+
# Core fields (compatible with dataclass version)
|
|
55
|
+
max_retries: int = Field(default=3, ge=0, le=20, description="Maximum number of retry attempts")
|
|
56
|
+
base_delay: float = Field(default=1.0, ge=0.1, le=60.0, description="Base delay in seconds")
|
|
57
|
+
max_delay: float = Field(default=60.0, ge=1.0, le=300.0, description="Maximum delay in seconds")
|
|
58
|
+
strategy: RetryStrategy = Field(default=RetryStrategy.EXPONENTIAL, description="Retry timing strategy")
|
|
59
|
+
jitter: bool = Field(default=True, description="Add jitter to prevent thundering herd")
|
|
60
|
+
|
|
61
|
+
# Additional fields for configuration support
|
|
62
|
+
permanent_errors: List[str] = Field(
|
|
63
|
+
default=[
|
|
64
|
+
"AuthenticationError",
|
|
65
|
+
"PermissionError",
|
|
66
|
+
"ValidationError",
|
|
67
|
+
"InvalidDataError",
|
|
68
|
+
"NotFoundError",
|
|
69
|
+
"BadRequestError",
|
|
70
|
+
"PermanentError"
|
|
71
|
+
],
|
|
72
|
+
description="Error types that should not be retried"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# Legacy compatibility field
|
|
76
|
+
initial_delay: Optional[float] = Field(default=None, description="Legacy field - use base_delay instead")
|
|
77
|
+
|
|
78
|
+
@model_validator(mode='after')
|
|
79
|
+
def handle_legacy_fields(self):
|
|
80
|
+
"""Handle legacy initial_delay field."""
|
|
81
|
+
if self.initial_delay is not None and hasattr(self, 'base_delay'):
|
|
82
|
+
self.base_delay = self.initial_delay
|
|
83
|
+
return self
|
|
84
|
+
|
|
85
|
+
def calculate_delay(self, attempt: int) -> float:
|
|
86
|
+
"""Calculate delay for given retry attempt."""
|
|
87
|
+
if self.strategy == RetryStrategy.FIXED:
|
|
88
|
+
delay = self.base_delay
|
|
89
|
+
elif self.strategy == RetryStrategy.LINEAR:
|
|
90
|
+
delay = self.base_delay * attempt
|
|
91
|
+
else: # EXPONENTIAL
|
|
92
|
+
delay = self.base_delay * (2 ** (attempt - 1))
|
|
93
|
+
|
|
94
|
+
# Apply max delay limit
|
|
95
|
+
delay = min(delay, self.max_delay)
|
|
96
|
+
|
|
97
|
+
# Add jitter to prevent thundering herd
|
|
98
|
+
if self.jitter:
|
|
99
|
+
import random
|
|
100
|
+
delay *= (0.5 + random.random() * 0.5)
|
|
101
|
+
|
|
102
|
+
return delay
|
|
103
|
+
|
|
104
|
+
async def execute_with_retry(
|
|
105
|
+
self,
|
|
106
|
+
func,
|
|
107
|
+
*args,
|
|
108
|
+
**kwargs
|
|
109
|
+
):
|
|
110
|
+
"""Execute function with retry policy."""
|
|
111
|
+
from typing import Callable, Any
|
|
112
|
+
last_error = None
|
|
113
|
+
|
|
114
|
+
for attempt in range(self.max_retries + 1):
|
|
115
|
+
try:
|
|
116
|
+
if asyncio.iscoroutinefunction(func):
|
|
117
|
+
return await func(*args, **kwargs)
|
|
118
|
+
else:
|
|
119
|
+
return func(*args, **kwargs)
|
|
120
|
+
except Exception as e:
|
|
121
|
+
last_error = e
|
|
122
|
+
|
|
123
|
+
if attempt < self.max_retries:
|
|
124
|
+
delay = self.calculate_delay(attempt + 1)
|
|
125
|
+
await asyncio.sleep(delay)
|
|
126
|
+
else:
|
|
127
|
+
break
|
|
128
|
+
|
|
129
|
+
# If we get here, all retries failed
|
|
130
|
+
raise last_error
|
|
131
|
+
|
|
132
|
+
class AgentConfig(YamlSerializableMixin, BaseModel):
|
|
133
|
+
"""Simplified agent configuration."""
|
|
134
|
+
name: str
|
|
135
|
+
type: AgentType = AgentType.SUBSTRATE
|
|
136
|
+
enabled: bool = True
|
|
137
|
+
settings: Dict[str, Any] = Field(default_factory=dict)
|
|
138
|
+
|
|
139
|
+
# Simple retry configuration - optional
|
|
140
|
+
enable_retry: bool = Field(default=False, description="Enable retry behavior (default: fail-fast)")
|
|
141
|
+
retry_policy: Optional[RetryPolicy] = Field(default=None, description="Retry policy - only used if enable_retry=True")
|
|
142
|
+
|
|
143
|
+
@model_validator(mode='after')
|
|
144
|
+
def setup_retry_policy(self):
|
|
145
|
+
"""Set up retry policy if retry is enabled but no policy provided."""
|
|
146
|
+
if self.enable_retry and self.retry_policy is None:
|
|
147
|
+
self.retry_policy = RetryPolicy()
|
|
148
|
+
return self
|
|
149
|
+
|
|
150
|
+
@property
|
|
151
|
+
def retry_enabled(self) -> bool:
|
|
152
|
+
"""Check if retry behavior is enabled."""
|
|
153
|
+
return self.enable_retry and self.retry_policy is not None
|
|
154
|
+
|
|
155
|
+
class DaitaConfig(YamlSerializableMixin, BaseModel):
|
|
156
|
+
"""Main configuration for Daita framework."""
|
|
157
|
+
version: str = "1.0.0"
|
|
158
|
+
agents: List[AgentConfig] = Field(default_factory=list)
|
|
159
|
+
settings: Dict[str, Any] = Field(default_factory=dict)
|
daita/config/settings.py
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Runtime settings management.
|
|
3
|
+
|
|
4
|
+
Simplified settings system focused on essential configuration.
|
|
5
|
+
"""
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any, Dict, Optional, List, ClassVar
|
|
9
|
+
from pydantic import BaseModel
|
|
10
|
+
from dotenv import load_dotenv
|
|
11
|
+
|
|
12
|
+
# Load environment variables
|
|
13
|
+
load_dotenv()
|
|
14
|
+
|
|
15
|
+
class Settings(BaseModel):
|
|
16
|
+
"""Runtime settings for Daita framework."""
|
|
17
|
+
|
|
18
|
+
# API settings (SECURE - from environment only)
|
|
19
|
+
api_key: Optional[str] = None
|
|
20
|
+
api_endpoint: str = "" # Must be set via DAITA_API_ENDPOINT env var
|
|
21
|
+
dashboard_url: str = "" # Must be set via DAITA_DASHBOARD_URL env var
|
|
22
|
+
|
|
23
|
+
# Deployment settings
|
|
24
|
+
deployment_id: Optional[str] = None
|
|
25
|
+
environment: str = "development"
|
|
26
|
+
|
|
27
|
+
# Local mode settings
|
|
28
|
+
local_mode: bool = True
|
|
29
|
+
cache_dir: Path = Path.home() / ".daita" / "cache"
|
|
30
|
+
log_level: str = "INFO"
|
|
31
|
+
|
|
32
|
+
# LLM Provider API Keys
|
|
33
|
+
openai_api_key: Optional[str] = None
|
|
34
|
+
anthropic_api_key: Optional[str] = None
|
|
35
|
+
google_api_key: Optional[str] = None
|
|
36
|
+
gemini_api_key: Optional[str] = None
|
|
37
|
+
xai_api_key: Optional[str] = None
|
|
38
|
+
grok_api_key: Optional[str] = None
|
|
39
|
+
|
|
40
|
+
# LLM settings
|
|
41
|
+
default_model: str = "gpt-4"
|
|
42
|
+
default_provider: str = "openai"
|
|
43
|
+
default_temperature: float = 0.7
|
|
44
|
+
|
|
45
|
+
def validate_endpoint(self, endpoint: str) -> str:
|
|
46
|
+
"""Validate API endpoint for security."""
|
|
47
|
+
if not endpoint:
|
|
48
|
+
raise ValueError("API endpoint cannot be empty")
|
|
49
|
+
|
|
50
|
+
if not endpoint.startswith('https://'):
|
|
51
|
+
raise ValueError("API endpoint must use HTTPS")
|
|
52
|
+
|
|
53
|
+
return endpoint
|
|
54
|
+
|
|
55
|
+
def __init__(self, **data):
|
|
56
|
+
# Override with environment variables
|
|
57
|
+
env_overrides = {}
|
|
58
|
+
|
|
59
|
+
# Lambda environment detection - use /tmp for cache
|
|
60
|
+
if os.getenv('AWS_LAMBDA_FUNCTION_NAME') or os.getenv('DAITA_RUNTIME') == 'lambda':
|
|
61
|
+
env_overrides["cache_dir"] = Path("/tmp/.daita/cache")
|
|
62
|
+
|
|
63
|
+
# Main Daita API key
|
|
64
|
+
if os.getenv("DAITA_API_KEY"):
|
|
65
|
+
env_overrides["api_key"] = os.getenv("DAITA_API_KEY")
|
|
66
|
+
|
|
67
|
+
# API endpoints - REQUIRED from environment
|
|
68
|
+
api_endpoint = os.getenv("DAITA_API_ENDPOINT")
|
|
69
|
+
if api_endpoint:
|
|
70
|
+
try:
|
|
71
|
+
self.validate_endpoint(api_endpoint)
|
|
72
|
+
env_overrides["api_endpoint"] = api_endpoint
|
|
73
|
+
except ValueError as e:
|
|
74
|
+
raise ValueError(f"Invalid DAITA_API_ENDPOINT environment variable: {e}")
|
|
75
|
+
|
|
76
|
+
dashboard_url = os.getenv("DAITA_DASHBOARD_URL")
|
|
77
|
+
if dashboard_url:
|
|
78
|
+
try:
|
|
79
|
+
self.validate_endpoint(dashboard_url)
|
|
80
|
+
env_overrides["dashboard_url"] = dashboard_url
|
|
81
|
+
except ValueError as e:
|
|
82
|
+
raise ValueError(f"Invalid DAITA_DASHBOARD_URL environment variable: {e}")
|
|
83
|
+
|
|
84
|
+
# Deployment settings
|
|
85
|
+
if os.getenv("DAITA_DEPLOYMENT_ID"):
|
|
86
|
+
env_overrides["deployment_id"] = os.getenv("DAITA_DEPLOYMENT_ID")
|
|
87
|
+
|
|
88
|
+
if os.getenv("DAITA_ENVIRONMENT"):
|
|
89
|
+
env_overrides["environment"] = os.getenv("DAITA_ENVIRONMENT")
|
|
90
|
+
|
|
91
|
+
# LLM Provider API Keys
|
|
92
|
+
if os.getenv("OPENAI_API_KEY"):
|
|
93
|
+
env_overrides["openai_api_key"] = os.getenv("OPENAI_API_KEY")
|
|
94
|
+
|
|
95
|
+
if os.getenv("ANTHROPIC_API_KEY"):
|
|
96
|
+
env_overrides["anthropic_api_key"] = os.getenv("ANTHROPIC_API_KEY")
|
|
97
|
+
|
|
98
|
+
if os.getenv("GOOGLE_API_KEY"):
|
|
99
|
+
env_overrides["google_api_key"] = os.getenv("GOOGLE_API_KEY")
|
|
100
|
+
|
|
101
|
+
if os.getenv("GEMINI_API_KEY"):
|
|
102
|
+
env_overrides["gemini_api_key"] = os.getenv("GEMINI_API_KEY")
|
|
103
|
+
|
|
104
|
+
if os.getenv("XAI_API_KEY"):
|
|
105
|
+
env_overrides["xai_api_key"] = os.getenv("XAI_API_KEY")
|
|
106
|
+
|
|
107
|
+
if os.getenv("GROK_API_KEY"):
|
|
108
|
+
env_overrides["grok_api_key"] = os.getenv("GROK_API_KEY")
|
|
109
|
+
|
|
110
|
+
# General settings
|
|
111
|
+
if os.getenv("DAITA_LOCAL_MODE"):
|
|
112
|
+
env_overrides["local_mode"] = os.getenv("DAITA_LOCAL_MODE").lower() == "true"
|
|
113
|
+
|
|
114
|
+
if os.getenv("DAITA_LOG_LEVEL"):
|
|
115
|
+
env_overrides["log_level"] = os.getenv("DAITA_LOG_LEVEL")
|
|
116
|
+
|
|
117
|
+
if os.getenv("DAITA_DEFAULT_MODEL"):
|
|
118
|
+
env_overrides["default_model"] = os.getenv("DAITA_DEFAULT_MODEL")
|
|
119
|
+
|
|
120
|
+
if os.getenv("DAITA_DEFAULT_PROVIDER"):
|
|
121
|
+
env_overrides["default_provider"] = os.getenv("DAITA_DEFAULT_PROVIDER")
|
|
122
|
+
|
|
123
|
+
if os.getenv("DAITA_DEFAULT_TEMPERATURE"):
|
|
124
|
+
try:
|
|
125
|
+
env_overrides["default_temperature"] = float(os.getenv("DAITA_DEFAULT_TEMPERATURE"))
|
|
126
|
+
except (ValueError, TypeError):
|
|
127
|
+
pass # Use default if invalid
|
|
128
|
+
|
|
129
|
+
# Merge with provided data
|
|
130
|
+
super().__init__(**{**data, **env_overrides})
|
|
131
|
+
|
|
132
|
+
# Ensure cache directory exists
|
|
133
|
+
self.cache_dir.mkdir(parents=True, exist_ok=True)
|
|
134
|
+
|
|
135
|
+
# SECURITY: Only validate endpoints in Lambda runtime
|
|
136
|
+
# Customer deployments use hardcoded production endpoints
|
|
137
|
+
if os.getenv('DAITA_RUNTIME') == 'lambda':
|
|
138
|
+
if not self.api_endpoint:
|
|
139
|
+
raise ValueError("DAITA_API_ENDPOINT environment variable required for Lambda runtime")
|
|
140
|
+
if not self.dashboard_url:
|
|
141
|
+
raise ValueError("DAITA_DASHBOARD_URL environment variable required for Lambda runtime")
|
|
142
|
+
|
|
143
|
+
def get_llm_api_key(self, provider: str) -> Optional[str]:
|
|
144
|
+
"""
|
|
145
|
+
Get API key for a specific LLM provider.
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
provider: Provider name (openai, anthropic, google, gemini, xai, grok)
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
API key for the provider or None if not set
|
|
152
|
+
"""
|
|
153
|
+
provider = provider.lower()
|
|
154
|
+
|
|
155
|
+
if provider == "openai":
|
|
156
|
+
return self.openai_api_key
|
|
157
|
+
elif provider == "anthropic":
|
|
158
|
+
return self.anthropic_api_key
|
|
159
|
+
elif provider in ["google", "gemini"]:
|
|
160
|
+
return self.google_api_key or self.gemini_api_key
|
|
161
|
+
elif provider in ["xai", "grok"]:
|
|
162
|
+
return self.xai_api_key or self.grok_api_key
|
|
163
|
+
|
|
164
|
+
return None
|
|
165
|
+
|
|
166
|
+
def get_daita_api_key(self) -> Optional[str]:
|
|
167
|
+
"""
|
|
168
|
+
Get Daita API key with fallback to provider keys.
|
|
169
|
+
|
|
170
|
+
Returns:
|
|
171
|
+
Daita API key or first available provider key
|
|
172
|
+
"""
|
|
173
|
+
return (
|
|
174
|
+
self.api_key or
|
|
175
|
+
self.openai_api_key or
|
|
176
|
+
self.anthropic_api_key or
|
|
177
|
+
self.google_api_key or
|
|
178
|
+
self.gemini_api_key or
|
|
179
|
+
self.xai_api_key or
|
|
180
|
+
self.grok_api_key
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
# Global settings instance
|
|
184
|
+
settings = Settings()
|
daita/core/__init__.py
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Core functionality for Daita Agents.
|
|
3
|
+
|
|
4
|
+
This module provides the essential building blocks for the Daita framework:
|
|
5
|
+
- Exception hierarchy with intelligent retry hints
|
|
6
|
+
- Core interfaces that define contracts for agents, LLM providers, and processors
|
|
7
|
+
- Focus system for data filtering and selection
|
|
8
|
+
- Relay system for agent-to-agent communication
|
|
9
|
+
- Workflow orchestration for multi-agent systems
|
|
10
|
+
- Unified tracing system for automatic observability
|
|
11
|
+
- Plugin tracing for tool execution monitoring
|
|
12
|
+
- Decision tracing for agent reasoning capture
|
|
13
|
+
|
|
14
|
+
The core module is designed to be imported by other framework components
|
|
15
|
+
and provides the foundational abstractions that everything else builds upon.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
# Exception hierarchy - Must be imported first to avoid circular imports
|
|
19
|
+
from .exceptions import (
|
|
20
|
+
# Base exceptions
|
|
21
|
+
DaitaError,
|
|
22
|
+
AgentError,
|
|
23
|
+
ConfigError,
|
|
24
|
+
LLMError,
|
|
25
|
+
PluginError,
|
|
26
|
+
WorkflowError,
|
|
27
|
+
|
|
28
|
+
# Retry-specific exceptions with built-in hints
|
|
29
|
+
TransientError,
|
|
30
|
+
RetryableError,
|
|
31
|
+
PermanentError,
|
|
32
|
+
|
|
33
|
+
# Specific transient errors
|
|
34
|
+
RateLimitError,
|
|
35
|
+
TimeoutError,
|
|
36
|
+
ConnectionError,
|
|
37
|
+
ServiceUnavailableError,
|
|
38
|
+
TemporaryError,
|
|
39
|
+
TooManyRequestsError,
|
|
40
|
+
|
|
41
|
+
# Specific retryable errors
|
|
42
|
+
ResourceBusyError,
|
|
43
|
+
DataInconsistencyError,
|
|
44
|
+
ProcessingQueueFullError,
|
|
45
|
+
|
|
46
|
+
# Specific permanent errors
|
|
47
|
+
AuthenticationError,
|
|
48
|
+
PermissionError,
|
|
49
|
+
ValidationError,
|
|
50
|
+
InvalidDataError,
|
|
51
|
+
NotFoundError,
|
|
52
|
+
BadRequestError,
|
|
53
|
+
|
|
54
|
+
# Circuit breaker errors
|
|
55
|
+
CircuitBreakerOpenError,
|
|
56
|
+
|
|
57
|
+
# Utility functions
|
|
58
|
+
classify_exception,
|
|
59
|
+
create_contextual_error
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# Core interfaces - Define contracts for framework components
|
|
63
|
+
from .interfaces import (
|
|
64
|
+
Agent,
|
|
65
|
+
LLMProvider,
|
|
66
|
+
DatabaseBackend,
|
|
67
|
+
DataProcessor
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# Focus system - For data filtering and selection
|
|
71
|
+
from .focus import apply_focus
|
|
72
|
+
|
|
73
|
+
# Unified Tracing System - NEW: Automatic observability for all operations
|
|
74
|
+
from .tracing import (
|
|
75
|
+
# Main tracing interface
|
|
76
|
+
get_trace_manager,
|
|
77
|
+
TraceManager,
|
|
78
|
+
|
|
79
|
+
# Trace types and status
|
|
80
|
+
TraceType,
|
|
81
|
+
TraceStatus,
|
|
82
|
+
|
|
83
|
+
# Core tracing components
|
|
84
|
+
TraceSpan,
|
|
85
|
+
TraceContext,
|
|
86
|
+
DashboardReporter
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
# Plugin Tracing System - NEW: Automatic tool execution monitoring
|
|
90
|
+
from .plugin_tracing import (
|
|
91
|
+
# Main plugin tracing function
|
|
92
|
+
trace_plugin,
|
|
93
|
+
|
|
94
|
+
# Traced plugin factories
|
|
95
|
+
traced_postgresql,
|
|
96
|
+
traced_mysql,
|
|
97
|
+
traced_mongodb,
|
|
98
|
+
traced_rest,
|
|
99
|
+
|
|
100
|
+
# Context managers for batch operations
|
|
101
|
+
traced_transaction,
|
|
102
|
+
traced_api_batch,
|
|
103
|
+
|
|
104
|
+
# Query and statistics functions
|
|
105
|
+
get_plugin_traces,
|
|
106
|
+
get_plugin_stats,
|
|
107
|
+
|
|
108
|
+
# Advanced plugin tracing class
|
|
109
|
+
TracedPlugin
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
# Decision Tracing System - NEW: Agent reasoning and confidence capture
|
|
113
|
+
from .decision_tracing import (
|
|
114
|
+
# Main decision tracing interfaces
|
|
115
|
+
record_decision_point,
|
|
116
|
+
trace_decision,
|
|
117
|
+
|
|
118
|
+
# Decision types
|
|
119
|
+
DecisionType,
|
|
120
|
+
|
|
121
|
+
# Helper functions for common decision patterns
|
|
122
|
+
record_classification_decision,
|
|
123
|
+
record_analysis_decision,
|
|
124
|
+
record_recommendation_decision,
|
|
125
|
+
|
|
126
|
+
# Query and analysis functions
|
|
127
|
+
get_recent_decisions,
|
|
128
|
+
get_decision_stats,
|
|
129
|
+
|
|
130
|
+
# Advanced decision tracing classes
|
|
131
|
+
DecisionRecorder,
|
|
132
|
+
DecisionContext
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# Export everything that other modules need
|
|
136
|
+
__all__ = [
|
|
137
|
+
# Exception hierarchy
|
|
138
|
+
"DaitaError",
|
|
139
|
+
"AgentError",
|
|
140
|
+
"ConfigError",
|
|
141
|
+
"LLMError",
|
|
142
|
+
"PluginError",
|
|
143
|
+
"WorkflowError",
|
|
144
|
+
|
|
145
|
+
# Retry-specific exceptions
|
|
146
|
+
"TransientError",
|
|
147
|
+
"RetryableError",
|
|
148
|
+
"PermanentError",
|
|
149
|
+
|
|
150
|
+
# Specific transient errors
|
|
151
|
+
"RateLimitError",
|
|
152
|
+
"TimeoutError",
|
|
153
|
+
"ConnectionError",
|
|
154
|
+
"ServiceUnavailableError",
|
|
155
|
+
"TemporaryError",
|
|
156
|
+
"TooManyRequestsError",
|
|
157
|
+
|
|
158
|
+
# Specific retryable errors
|
|
159
|
+
"ResourceBusyError",
|
|
160
|
+
"DataInconsistencyError",
|
|
161
|
+
"ProcessingQueueFullError",
|
|
162
|
+
|
|
163
|
+
# Specific permanent errors
|
|
164
|
+
"AuthenticationError",
|
|
165
|
+
"PermissionError",
|
|
166
|
+
"ValidationError",
|
|
167
|
+
"InvalidDataError",
|
|
168
|
+
"NotFoundError",
|
|
169
|
+
"BadRequestError",
|
|
170
|
+
|
|
171
|
+
# Circuit breaker errors
|
|
172
|
+
"CircuitBreakerOpenError",
|
|
173
|
+
|
|
174
|
+
# Exception utility functions
|
|
175
|
+
"classify_exception",
|
|
176
|
+
"create_contextual_error",
|
|
177
|
+
|
|
178
|
+
# Core interfaces
|
|
179
|
+
"Agent",
|
|
180
|
+
"LLMProvider",
|
|
181
|
+
"DatabaseBackend",
|
|
182
|
+
"DataProcessor",
|
|
183
|
+
|
|
184
|
+
# Focus system
|
|
185
|
+
"apply_focus",
|
|
186
|
+
|
|
187
|
+
# === NEW: Unified Tracing System ===
|
|
188
|
+
# Main tracing interface
|
|
189
|
+
"get_trace_manager",
|
|
190
|
+
"TraceManager",
|
|
191
|
+
|
|
192
|
+
# Trace types and status
|
|
193
|
+
"TraceType",
|
|
194
|
+
"TraceStatus",
|
|
195
|
+
|
|
196
|
+
# Core tracing components
|
|
197
|
+
"TraceSpan",
|
|
198
|
+
"TraceContext",
|
|
199
|
+
"DashboardReporter",
|
|
200
|
+
|
|
201
|
+
# === NEW: Plugin Tracing System ===
|
|
202
|
+
# Main plugin tracing
|
|
203
|
+
"trace_plugin",
|
|
204
|
+
|
|
205
|
+
# Traced plugin factories
|
|
206
|
+
"traced_postgresql",
|
|
207
|
+
"traced_mysql",
|
|
208
|
+
"traced_mongodb",
|
|
209
|
+
"traced_rest",
|
|
210
|
+
|
|
211
|
+
# Plugin batch operations
|
|
212
|
+
"traced_transaction",
|
|
213
|
+
"traced_api_batch",
|
|
214
|
+
|
|
215
|
+
# Plugin analytics
|
|
216
|
+
"get_plugin_traces",
|
|
217
|
+
"get_plugin_stats",
|
|
218
|
+
|
|
219
|
+
# Advanced plugin tracing
|
|
220
|
+
"TracedPlugin",
|
|
221
|
+
|
|
222
|
+
# === NEW: Decision Tracing System ===
|
|
223
|
+
# Main decision tracing
|
|
224
|
+
"record_decision_point",
|
|
225
|
+
"trace_decision",
|
|
226
|
+
|
|
227
|
+
# Decision types
|
|
228
|
+
"DecisionType",
|
|
229
|
+
|
|
230
|
+
# Decision helpers
|
|
231
|
+
"record_classification_decision",
|
|
232
|
+
"record_analysis_decision",
|
|
233
|
+
"record_recommendation_decision",
|
|
234
|
+
|
|
235
|
+
# Decision analytics
|
|
236
|
+
"get_recent_decisions",
|
|
237
|
+
"get_decision_stats",
|
|
238
|
+
|
|
239
|
+
# Advanced decision tracing
|
|
240
|
+
"DecisionRecorder",
|
|
241
|
+
"DecisionContext"
|
|
242
|
+
]
|
|
243
|
+
|
|
244
|
+
# Core module metadata
|
|
245
|
+
CORE_INFO = {
|
|
246
|
+
"components": [
|
|
247
|
+
"exceptions",
|
|
248
|
+
"interfaces",
|
|
249
|
+
"focus",
|
|
250
|
+
"tracing",
|
|
251
|
+
"plugin_tracing",
|
|
252
|
+
"decision_tracing"
|
|
253
|
+
],
|
|
254
|
+
"description": "Core abstractions and utilities for the Daita framework",
|
|
255
|
+
"stability": "stable"
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
def get_core_info() -> dict:
|
|
259
|
+
"""Get information about core module components."""
|
|
260
|
+
return CORE_INFO.copy()
|
|
261
|
+
|
|
262
|
+
__all__.append("get_core_info")
|