daita-agents 0.2.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.
Files changed (69) hide show
  1. daita/__init__.py +216 -0
  2. daita/agents/__init__.py +33 -0
  3. daita/agents/base.py +743 -0
  4. daita/agents/substrate.py +1141 -0
  5. daita/cli/__init__.py +145 -0
  6. daita/cli/__main__.py +7 -0
  7. daita/cli/ascii_art.py +44 -0
  8. daita/cli/core/__init__.py +0 -0
  9. daita/cli/core/create.py +254 -0
  10. daita/cli/core/deploy.py +473 -0
  11. daita/cli/core/deployments.py +309 -0
  12. daita/cli/core/import_detector.py +219 -0
  13. daita/cli/core/init.py +481 -0
  14. daita/cli/core/logs.py +239 -0
  15. daita/cli/core/managed_deploy.py +709 -0
  16. daita/cli/core/run.py +648 -0
  17. daita/cli/core/status.py +421 -0
  18. daita/cli/core/test.py +239 -0
  19. daita/cli/core/webhooks.py +172 -0
  20. daita/cli/main.py +588 -0
  21. daita/cli/utils.py +541 -0
  22. daita/config/__init__.py +62 -0
  23. daita/config/base.py +159 -0
  24. daita/config/settings.py +184 -0
  25. daita/core/__init__.py +262 -0
  26. daita/core/decision_tracing.py +701 -0
  27. daita/core/exceptions.py +480 -0
  28. daita/core/focus.py +251 -0
  29. daita/core/interfaces.py +76 -0
  30. daita/core/plugin_tracing.py +550 -0
  31. daita/core/relay.py +779 -0
  32. daita/core/reliability.py +381 -0
  33. daita/core/scaling.py +459 -0
  34. daita/core/tools.py +554 -0
  35. daita/core/tracing.py +770 -0
  36. daita/core/workflow.py +1144 -0
  37. daita/display/__init__.py +1 -0
  38. daita/display/console.py +160 -0
  39. daita/execution/__init__.py +58 -0
  40. daita/execution/client.py +856 -0
  41. daita/execution/exceptions.py +92 -0
  42. daita/execution/models.py +317 -0
  43. daita/llm/__init__.py +60 -0
  44. daita/llm/anthropic.py +291 -0
  45. daita/llm/base.py +530 -0
  46. daita/llm/factory.py +101 -0
  47. daita/llm/gemini.py +355 -0
  48. daita/llm/grok.py +219 -0
  49. daita/llm/mock.py +172 -0
  50. daita/llm/openai.py +220 -0
  51. daita/plugins/__init__.py +141 -0
  52. daita/plugins/base.py +37 -0
  53. daita/plugins/base_db.py +167 -0
  54. daita/plugins/elasticsearch.py +849 -0
  55. daita/plugins/mcp.py +481 -0
  56. daita/plugins/mongodb.py +520 -0
  57. daita/plugins/mysql.py +362 -0
  58. daita/plugins/postgresql.py +342 -0
  59. daita/plugins/redis_messaging.py +500 -0
  60. daita/plugins/rest.py +537 -0
  61. daita/plugins/s3.py +770 -0
  62. daita/plugins/slack.py +729 -0
  63. daita/utils/__init__.py +18 -0
  64. daita_agents-0.2.0.dist-info/METADATA +409 -0
  65. daita_agents-0.2.0.dist-info/RECORD +69 -0
  66. daita_agents-0.2.0.dist-info/WHEEL +5 -0
  67. daita_agents-0.2.0.dist-info/entry_points.txt +2 -0
  68. daita_agents-0.2.0.dist-info/licenses/LICENSE +56 -0
  69. daita_agents-0.2.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,167 @@
1
+ """
2
+ Base class for database plugins.
3
+
4
+ Provides common connection management, error handling, and context manager
5
+ support for all database plugins in the Daita framework.
6
+ """
7
+ import logging
8
+ from abc import ABC, abstractmethod
9
+ from typing import Any, Dict, List, Optional, TYPE_CHECKING
10
+ from ..core.exceptions import PluginError, ConnectionError as DaitaConnectionError, ValidationError
11
+
12
+ if TYPE_CHECKING:
13
+ from ..core.tools import AgentTool
14
+
15
+ logger = logging.getLogger(__name__)
16
+
17
+ class BaseDatabasePlugin(ABC):
18
+ """
19
+ Base class for all database plugins with common connection management.
20
+
21
+ This class provides:
22
+ - Standardized connection/disconnection lifecycle
23
+ - Context manager support for automatic cleanup
24
+ - Common error handling patterns
25
+ - Consistent configuration patterns
26
+
27
+ Database-specific plugins should inherit from this class and implement
28
+ the abstract methods for their specific database requirements.
29
+ """
30
+
31
+ def __init__(self, **kwargs):
32
+ """
33
+ Initialize base database plugin.
34
+
35
+ Args:
36
+ **kwargs: Database-specific configuration parameters
37
+ """
38
+ # Common connection state
39
+ self._connection = None
40
+ self._pool = None
41
+ self._client = None
42
+ self._db = None
43
+
44
+ # Connection configuration
45
+ self.config = kwargs
46
+ self.timeout = kwargs.get('timeout', 30)
47
+ self.max_retries = kwargs.get('max_retries', 3)
48
+
49
+ logger.debug(f"{self.__class__.__name__} initialized with config keys: {list(kwargs.keys())}")
50
+
51
+ @abstractmethod
52
+ async def connect(self) -> None:
53
+ """
54
+ Connect to the database.
55
+
56
+ This method must be implemented by each database plugin to handle
57
+ the specific connection logic for that database type.
58
+ """
59
+ pass
60
+
61
+ @abstractmethod
62
+ async def disconnect(self) -> None:
63
+ """
64
+ Disconnect from the database and clean up resources.
65
+
66
+ This method must be implemented by each database plugin to handle
67
+ the specific disconnection and cleanup logic for that database type.
68
+ """
69
+ pass
70
+
71
+ @property
72
+ def is_connected(self) -> bool:
73
+ """
74
+ Check if the database connection is active.
75
+
76
+ Returns:
77
+ True if connected, False otherwise
78
+ """
79
+ return (
80
+ self._connection is not None or
81
+ self._pool is not None or
82
+ self._client is not None
83
+ )
84
+
85
+ async def __aenter__(self):
86
+ """Async context manager entry - automatically connect."""
87
+ await self.connect()
88
+ return self
89
+
90
+ async def __aexit__(self, exc_type, exc_val, exc_tb):
91
+ """Async context manager exit - automatically disconnect."""
92
+ await self.disconnect()
93
+
94
+ def _validate_connection(self) -> None:
95
+ """
96
+ Validate that the database connection is available.
97
+
98
+ Raises:
99
+ ValidationError: If not connected to database
100
+ """
101
+ if not self.is_connected:
102
+ raise ValidationError(
103
+ f"{self.__class__.__name__} is not connected to database",
104
+ field="connection_state"
105
+ )
106
+
107
+ def _handle_connection_error(self, error: Exception, operation: str) -> None:
108
+ """
109
+ Handle database connection errors with consistent logging.
110
+
111
+ Args:
112
+ error: The exception that occurred
113
+ operation: Description of the operation that failed
114
+
115
+ Raises:
116
+ PluginError: Wrapped database error with context
117
+ """
118
+ error_msg = f"{self.__class__.__name__} {operation} failed: {str(error)}"
119
+ logger.error(error_msg)
120
+
121
+ # Choose appropriate exception type based on the original error
122
+ if isinstance(error, ImportError):
123
+ # Missing dependency - permanent error
124
+ raise PluginError(
125
+ error_msg,
126
+ plugin_name=self.__class__.__name__,
127
+ retry_hint="permanent",
128
+ context={"operation": operation, "original_error": str(error)}
129
+ ) from error
130
+ else:
131
+ # Connection issues - typically transient
132
+ raise DaitaConnectionError(
133
+ error_msg,
134
+ context={"plugin": self.__class__.__name__, "operation": operation}
135
+ ) from error
136
+
137
+ def get_tools(self) -> List['AgentTool']:
138
+ """
139
+ Get agent-usable tools from this database plugin.
140
+
141
+ Override in subclasses to expose database operations as LLM tools.
142
+
143
+ Returns:
144
+ List of AgentTool instances
145
+ """
146
+ return []
147
+
148
+ @property
149
+ def has_tools(self) -> bool:
150
+ """Check if plugin exposes any tools"""
151
+ return len(self.get_tools()) > 0
152
+
153
+ @property
154
+ def info(self) -> Dict[str, Any]:
155
+ """
156
+ Get information about the database plugin.
157
+
158
+ Returns:
159
+ Dictionary with plugin information
160
+ """
161
+ return {
162
+ 'plugin_type': self.__class__.__name__,
163
+ 'connected': self.is_connected,
164
+ 'timeout': self.timeout,
165
+ 'max_retries': self.max_retries,
166
+ 'config_keys': list(self.config.keys())
167
+ }