aiecs 1.0.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 aiecs might be problematic. Click here for more details.

Files changed (90) hide show
  1. aiecs/__init__.py +75 -0
  2. aiecs/__main__.py +41 -0
  3. aiecs/aiecs_client.py +295 -0
  4. aiecs/application/__init__.py +10 -0
  5. aiecs/application/executors/__init__.py +10 -0
  6. aiecs/application/executors/operation_executor.py +341 -0
  7. aiecs/config/__init__.py +15 -0
  8. aiecs/config/config.py +117 -0
  9. aiecs/config/registry.py +19 -0
  10. aiecs/core/__init__.py +46 -0
  11. aiecs/core/interface/__init__.py +34 -0
  12. aiecs/core/interface/execution_interface.py +150 -0
  13. aiecs/core/interface/storage_interface.py +214 -0
  14. aiecs/domain/__init__.py +20 -0
  15. aiecs/domain/context/__init__.py +28 -0
  16. aiecs/domain/context/content_engine.py +982 -0
  17. aiecs/domain/context/conversation_models.py +306 -0
  18. aiecs/domain/execution/__init__.py +12 -0
  19. aiecs/domain/execution/model.py +49 -0
  20. aiecs/domain/task/__init__.py +13 -0
  21. aiecs/domain/task/dsl_processor.py +460 -0
  22. aiecs/domain/task/model.py +50 -0
  23. aiecs/domain/task/task_context.py +257 -0
  24. aiecs/infrastructure/__init__.py +26 -0
  25. aiecs/infrastructure/messaging/__init__.py +13 -0
  26. aiecs/infrastructure/messaging/celery_task_manager.py +341 -0
  27. aiecs/infrastructure/messaging/websocket_manager.py +289 -0
  28. aiecs/infrastructure/monitoring/__init__.py +12 -0
  29. aiecs/infrastructure/monitoring/executor_metrics.py +138 -0
  30. aiecs/infrastructure/monitoring/structured_logger.py +50 -0
  31. aiecs/infrastructure/monitoring/tracing_manager.py +376 -0
  32. aiecs/infrastructure/persistence/__init__.py +12 -0
  33. aiecs/infrastructure/persistence/database_manager.py +286 -0
  34. aiecs/infrastructure/persistence/file_storage.py +671 -0
  35. aiecs/infrastructure/persistence/redis_client.py +162 -0
  36. aiecs/llm/__init__.py +54 -0
  37. aiecs/llm/base_client.py +99 -0
  38. aiecs/llm/client_factory.py +339 -0
  39. aiecs/llm/custom_callbacks.py +228 -0
  40. aiecs/llm/openai_client.py +125 -0
  41. aiecs/llm/vertex_client.py +186 -0
  42. aiecs/llm/xai_client.py +184 -0
  43. aiecs/main.py +351 -0
  44. aiecs/scripts/DEPENDENCY_SYSTEM_SUMMARY.md +241 -0
  45. aiecs/scripts/README_DEPENDENCY_CHECKER.md +309 -0
  46. aiecs/scripts/README_WEASEL_PATCH.md +126 -0
  47. aiecs/scripts/__init__.py +3 -0
  48. aiecs/scripts/dependency_checker.py +825 -0
  49. aiecs/scripts/dependency_fixer.py +348 -0
  50. aiecs/scripts/download_nlp_data.py +348 -0
  51. aiecs/scripts/fix_weasel_validator.py +121 -0
  52. aiecs/scripts/fix_weasel_validator.sh +82 -0
  53. aiecs/scripts/patch_weasel_library.sh +188 -0
  54. aiecs/scripts/quick_dependency_check.py +269 -0
  55. aiecs/scripts/run_weasel_patch.sh +41 -0
  56. aiecs/scripts/setup_nlp_data.sh +217 -0
  57. aiecs/tasks/__init__.py +2 -0
  58. aiecs/tasks/worker.py +111 -0
  59. aiecs/tools/__init__.py +196 -0
  60. aiecs/tools/base_tool.py +202 -0
  61. aiecs/tools/langchain_adapter.py +361 -0
  62. aiecs/tools/task_tools/__init__.py +82 -0
  63. aiecs/tools/task_tools/chart_tool.py +704 -0
  64. aiecs/tools/task_tools/classfire_tool.py +901 -0
  65. aiecs/tools/task_tools/image_tool.py +397 -0
  66. aiecs/tools/task_tools/office_tool.py +600 -0
  67. aiecs/tools/task_tools/pandas_tool.py +565 -0
  68. aiecs/tools/task_tools/report_tool.py +499 -0
  69. aiecs/tools/task_tools/research_tool.py +363 -0
  70. aiecs/tools/task_tools/scraper_tool.py +548 -0
  71. aiecs/tools/task_tools/search_api.py +7 -0
  72. aiecs/tools/task_tools/stats_tool.py +513 -0
  73. aiecs/tools/temp_file_manager.py +126 -0
  74. aiecs/tools/tool_executor/__init__.py +35 -0
  75. aiecs/tools/tool_executor/tool_executor.py +518 -0
  76. aiecs/utils/LLM_output_structor.py +409 -0
  77. aiecs/utils/__init__.py +23 -0
  78. aiecs/utils/base_callback.py +50 -0
  79. aiecs/utils/execution_utils.py +158 -0
  80. aiecs/utils/logging.py +1 -0
  81. aiecs/utils/prompt_loader.py +13 -0
  82. aiecs/utils/token_usage_repository.py +279 -0
  83. aiecs/ws/__init__.py +0 -0
  84. aiecs/ws/socket_server.py +41 -0
  85. aiecs-1.0.0.dist-info/METADATA +610 -0
  86. aiecs-1.0.0.dist-info/RECORD +90 -0
  87. aiecs-1.0.0.dist-info/WHEEL +5 -0
  88. aiecs-1.0.0.dist-info/entry_points.txt +7 -0
  89. aiecs-1.0.0.dist-info/licenses/LICENSE +225 -0
  90. aiecs-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,150 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any, Dict, List, Optional, Callable
3
+ from aiecs.domain.execution.model import TaskStepResult
4
+
5
+
6
+ class IToolProvider(ABC):
7
+ """Tool provider interface - Domain layer abstraction"""
8
+
9
+ @abstractmethod
10
+ def get_tool(self, tool_name: str) -> Any:
11
+ """Get tool instance"""
12
+ pass
13
+
14
+ @abstractmethod
15
+ def has_tool(self, tool_name: str) -> bool:
16
+ """Check if tool exists"""
17
+ pass
18
+
19
+
20
+ class IToolExecutor(ABC):
21
+ """Tool executor interface - Domain layer abstraction"""
22
+
23
+ @abstractmethod
24
+ def execute(self, tool: Any, operation_name: str, **params) -> Any:
25
+ """Execute tool operation synchronously"""
26
+ pass
27
+
28
+ @abstractmethod
29
+ async def execute_async(self, tool: Any, operation_name: str, **params) -> Any:
30
+ """Execute tool operation asynchronously"""
31
+ pass
32
+
33
+
34
+ class ICacheProvider(ABC):
35
+ """Cache provider interface - Domain layer abstraction"""
36
+
37
+ @abstractmethod
38
+ def generate_cache_key(self, operation_type: str, user_id: str, task_id: str,
39
+ args: tuple, kwargs: Dict[str, Any]) -> str:
40
+ """Generate cache key"""
41
+ pass
42
+
43
+ @abstractmethod
44
+ def get_from_cache(self, cache_key: str) -> Optional[Any]:
45
+ """Get data from cache"""
46
+ pass
47
+
48
+ @abstractmethod
49
+ def add_to_cache(self, cache_key: str, value: Any) -> None:
50
+ """Add data to cache"""
51
+ pass
52
+
53
+
54
+ class IOperationExecutor(ABC):
55
+ """Operation executor interface - Domain layer abstraction"""
56
+
57
+ @abstractmethod
58
+ async def execute_operation(self, operation_spec: str, params: Dict[str, Any]) -> Any:
59
+ """Execute single operation"""
60
+ pass
61
+
62
+ @abstractmethod
63
+ async def batch_execute_operations(self, operations: List[Dict[str, Any]]) -> List[Any]:
64
+ """Batch execute operations"""
65
+ pass
66
+
67
+ @abstractmethod
68
+ async def execute_operations_sequence(self, operations: List[Dict[str, Any]],
69
+ user_id: str, task_id: str,
70
+ stop_on_failure: bool = False,
71
+ save_callback: Optional[Callable] = None) -> List[TaskStepResult]:
72
+ """Execute operations sequence sequentially"""
73
+ pass
74
+
75
+ @abstractmethod
76
+ async def execute_parallel_operations(self, operations: List[Dict[str, Any]]) -> List[TaskStepResult]:
77
+ """Execute operations in parallel"""
78
+ pass
79
+
80
+
81
+ class ExecutionInterface(ABC):
82
+ """
83
+ Unified execution interface that defines standard methods for service and tool execution.
84
+ Supports plugin-based execution engines, allowing future introduction of new executors without modifying upper-level code.
85
+ """
86
+
87
+ @abstractmethod
88
+ async def execute_operation(self, operation_spec: str, params: Dict[str, Any]) -> Any:
89
+ """
90
+ Execute a single operation (e.g., tool operation or service subtask).
91
+
92
+ Args:
93
+ operation_spec (str): Operation specification, format as 'tool_name.operation_name' or other identifier
94
+ params (Dict[str, Any]): Operation parameters
95
+
96
+ Returns:
97
+ Any: Operation result
98
+ """
99
+ pass
100
+
101
+ @abstractmethod
102
+ async def execute_task(self, task_name: str, input_data: Dict[str, Any], context: Dict[str, Any]) -> Any:
103
+ """
104
+ Execute a single task (e.g., service task).
105
+
106
+ Args:
107
+ task_name (str): Task name
108
+ input_data (Dict[str, Any]): Input data
109
+ context (Dict[str, Any]): Context information
110
+
111
+ Returns:
112
+ Any: Task result
113
+ """
114
+ pass
115
+
116
+ @abstractmethod
117
+ async def batch_execute_operations(self, operations: List[Dict[str, Any]]) -> List[Any]:
118
+ """
119
+ Batch execute multiple operations.
120
+
121
+ Args:
122
+ operations (List[Dict[str, Any]]): List of operations, each containing 'operation' and 'params'
123
+
124
+ Returns:
125
+ List[Any]: List of operation results
126
+ """
127
+ pass
128
+
129
+ @abstractmethod
130
+ async def batch_execute_tasks(self, tasks: List[Dict[str, Any]]) -> List[Any]:
131
+ """
132
+ Batch execute multiple tasks.
133
+
134
+ Args:
135
+ tasks (List[Dict[str, Any]]): List of tasks, each containing 'task_name', 'input_data', 'context'
136
+
137
+ Returns:
138
+ List[Any]: List of task results
139
+ """
140
+ pass
141
+
142
+ def register_executor(self, executor_type: str, executor_instance: Any) -> None:
143
+ """
144
+ Register new executor type, supporting plugin-based extension.
145
+
146
+ Args:
147
+ executor_type (str): Executor type identifier
148
+ executor_instance (Any): Executor instance
149
+ """
150
+ raise NotImplementedError("Executor registration is not implemented in this interface")
@@ -0,0 +1,214 @@
1
+ """
2
+ Storage interfaces for the middleware architecture.
3
+
4
+ This module defines the core storage abstractions following the same pattern
5
+ as other core interfaces, enabling dependency inversion and clean architecture.
6
+ """
7
+
8
+ from abc import ABC, abstractmethod
9
+ from typing import Dict, Any, Optional, List
10
+ from datetime import datetime
11
+
12
+
13
+ class ISessionStorage(ABC):
14
+ """Session storage interface - Domain layer abstraction"""
15
+
16
+ @abstractmethod
17
+ async def create_session(
18
+ self,
19
+ session_id: str,
20
+ user_id: str,
21
+ metadata: Dict[str, Any] = None
22
+ ) -> Dict[str, Any]:
23
+ """Create a new session."""
24
+ pass
25
+
26
+ @abstractmethod
27
+ async def get_session(self, session_id: str) -> Optional[Dict[str, Any]]:
28
+ """Get session by ID."""
29
+ pass
30
+
31
+ @abstractmethod
32
+ async def update_session(
33
+ self,
34
+ session_id: str,
35
+ updates: Dict[str, Any] = None,
36
+ increment_requests: bool = False,
37
+ add_processing_time: float = 0.0,
38
+ mark_error: bool = False
39
+ ) -> bool:
40
+ """Update session with activity and metrics."""
41
+ pass
42
+
43
+ @abstractmethod
44
+ async def end_session(self, session_id: str, status: str = "completed") -> bool:
45
+ """End a session and update metrics."""
46
+ pass
47
+
48
+
49
+ class IConversationStorage(ABC):
50
+ """Conversation storage interface - Domain layer abstraction"""
51
+
52
+ @abstractmethod
53
+ async def add_conversation_message(
54
+ self,
55
+ session_id: str,
56
+ role: str,
57
+ content: str,
58
+ metadata: Dict[str, Any] = None
59
+ ) -> bool:
60
+ """Add message to conversation history."""
61
+ pass
62
+
63
+ @abstractmethod
64
+ async def get_conversation_history(
65
+ self,
66
+ session_id: str,
67
+ limit: int = 50
68
+ ) -> List[Dict[str, Any]]:
69
+ """Get conversation history for a session."""
70
+ pass
71
+
72
+
73
+ class ICheckpointStorage(ABC):
74
+ """Checkpoint storage interface - Domain layer abstraction"""
75
+
76
+ @abstractmethod
77
+ async def store_checkpoint(
78
+ self,
79
+ thread_id: str,
80
+ checkpoint_id: str,
81
+ checkpoint_data: Dict[str, Any],
82
+ metadata: Dict[str, Any] = None
83
+ ) -> bool:
84
+ """Store checkpoint data."""
85
+ pass
86
+
87
+ @abstractmethod
88
+ async def get_checkpoint(
89
+ self,
90
+ thread_id: str,
91
+ checkpoint_id: str = None
92
+ ) -> Optional[Dict[str, Any]]:
93
+ """Get checkpoint data. If checkpoint_id is None, get the latest."""
94
+ pass
95
+
96
+ @abstractmethod
97
+ async def list_checkpoints(
98
+ self,
99
+ thread_id: str,
100
+ limit: int = 10
101
+ ) -> List[Dict[str, Any]]:
102
+ """List checkpoints for a thread, ordered by creation time."""
103
+ pass
104
+
105
+
106
+ class ITaskContextStorage(ABC):
107
+ """Task context storage interface - Domain layer abstraction"""
108
+
109
+ @abstractmethod
110
+ async def get_task_context(self, session_id: str) -> Optional[Any]:
111
+ """Get TaskContext for a session."""
112
+ pass
113
+
114
+ @abstractmethod
115
+ async def store_task_context(self, session_id: str, context: Any) -> bool:
116
+ """Store TaskContext for a session."""
117
+ pass
118
+
119
+
120
+ class IStorageBackend(
121
+ ISessionStorage,
122
+ IConversationStorage,
123
+ ICheckpointStorage,
124
+ ITaskContextStorage
125
+ ):
126
+ """
127
+ Unified storage backend interface - Domain layer abstraction
128
+
129
+ This interface combines all storage capabilities and follows the same
130
+ pattern as other core interfaces in the middleware architecture.
131
+ """
132
+
133
+ @abstractmethod
134
+ async def initialize(self) -> bool:
135
+ """Initialize the storage backend."""
136
+ pass
137
+
138
+ @abstractmethod
139
+ async def close(self):
140
+ """Close the storage backend."""
141
+ pass
142
+
143
+ @abstractmethod
144
+ async def health_check(self) -> Dict[str, Any]:
145
+ """Perform health check."""
146
+ pass
147
+
148
+ @abstractmethod
149
+ async def get_metrics(self) -> Dict[str, Any]:
150
+ """Get comprehensive metrics."""
151
+ pass
152
+
153
+ @abstractmethod
154
+ async def cleanup_expired_sessions(self, max_idle_hours: int = 24) -> int:
155
+ """Clean up expired sessions and associated data."""
156
+ pass
157
+
158
+
159
+ class ICheckpointerBackend(ABC):
160
+ """
161
+ Checkpointer backend interface for LangGraph integration.
162
+
163
+ This interface defines the minimal contract needed by BaseServiceCheckpointer
164
+ to work with any storage backend, following dependency inversion principle.
165
+ """
166
+
167
+ @abstractmethod
168
+ async def put_checkpoint(
169
+ self,
170
+ thread_id: str,
171
+ checkpoint_id: str,
172
+ checkpoint_data: Dict[str, Any],
173
+ metadata: Dict[str, Any] = None
174
+ ) -> bool:
175
+ """Store a checkpoint for LangGraph workflows."""
176
+ pass
177
+
178
+ @abstractmethod
179
+ async def get_checkpoint(
180
+ self,
181
+ thread_id: str,
182
+ checkpoint_id: str = None
183
+ ) -> Optional[Dict[str, Any]]:
184
+ """Retrieve a checkpoint for LangGraph workflows."""
185
+ pass
186
+
187
+ @abstractmethod
188
+ async def list_checkpoints(
189
+ self,
190
+ thread_id: str,
191
+ limit: int = 10
192
+ ) -> List[Dict[str, Any]]:
193
+ """List checkpoints for LangGraph workflows."""
194
+ pass
195
+
196
+ @abstractmethod
197
+ async def put_writes(
198
+ self,
199
+ thread_id: str,
200
+ checkpoint_id: str,
201
+ task_id: str,
202
+ writes_data: List[tuple]
203
+ ) -> bool:
204
+ """Store intermediate writes for a checkpoint."""
205
+ pass
206
+
207
+ @abstractmethod
208
+ async def get_writes(
209
+ self,
210
+ thread_id: str,
211
+ checkpoint_id: str
212
+ ) -> List[tuple]:
213
+ """Get intermediate writes for a checkpoint."""
214
+ pass
@@ -0,0 +1,20 @@
1
+ """Domain layer module
2
+
3
+ Contains business logic and domain models.
4
+ """
5
+
6
+ from .execution.model import TaskStepResult, TaskStatus, ErrorCode
7
+ from .task.model import TaskContext, DSLStep
8
+ from .task.dsl_processor import DSLProcessor
9
+
10
+ __all__ = [
11
+ # Execution domain
12
+ "TaskStepResult",
13
+ "TaskStatus",
14
+ "ErrorCode",
15
+
16
+ # Task domain
17
+ "TaskContext",
18
+ "DSLStep",
19
+ "DSLProcessor",
20
+ ]
@@ -0,0 +1,28 @@
1
+ """
2
+ Context Management Domain
3
+
4
+ This module provides advanced context and session management capabilities
5
+ for the Python middleware application.
6
+
7
+ Components:
8
+ - ContextEngine: Advanced context and session management with Redis backend
9
+ - Integration with TaskContext for enhanced functionality
10
+ - Support for BaseServiceCheckpointer and LangGraph workflows
11
+ """
12
+
13
+ from .context_engine import ContextEngine, SessionMetrics, ConversationMessage
14
+ from .conversation_models import (
15
+ ConversationParticipant, ConversationSession, AgentCommunicationMessage,
16
+ create_session_key, validate_conversation_isolation_pattern
17
+ )
18
+
19
+ __all__ = [
20
+ 'ContextEngine',
21
+ 'SessionMetrics',
22
+ 'ConversationMessage',
23
+ 'ConversationParticipant',
24
+ 'ConversationSession',
25
+ 'AgentCommunicationMessage',
26
+ 'create_session_key',
27
+ 'validate_conversation_isolation_pattern'
28
+ ]