aiecs 1.0.8__tar.gz → 1.1.1__tar.gz

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 (125) hide show
  1. {aiecs-1.0.8/aiecs.egg-info → aiecs-1.1.1}/PKG-INFO +1 -1
  2. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/__init__.py +1 -1
  3. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/aiecs_client.py +159 -1
  4. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/config/config.py +4 -0
  5. aiecs-1.1.1/aiecs/domain/context/__init__.py +53 -0
  6. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/main.py +20 -2
  7. aiecs-1.1.1/aiecs/scripts/aid/VERSION_MANAGEMENT.md +97 -0
  8. aiecs-1.1.1/aiecs/scripts/aid/__init__.py +15 -0
  9. aiecs-1.1.1/aiecs/scripts/aid/version_manager.py +224 -0
  10. aiecs-1.1.1/aiecs/scripts/dependance_check/__init__.py +18 -0
  11. {aiecs-1.0.8/aiecs/scripts → aiecs-1.1.1/aiecs/scripts/dependance_check}/download_nlp_data.py +50 -8
  12. aiecs-1.1.1/aiecs/scripts/dependance_patch/__init__.py +8 -0
  13. aiecs-1.1.1/aiecs/scripts/dependance_patch/fix_weasel/__init__.py +12 -0
  14. aiecs-1.1.1/aiecs/scripts/tools_develop/README.md +340 -0
  15. aiecs-1.1.1/aiecs/scripts/tools_develop/__init__.py +16 -0
  16. aiecs-1.1.1/aiecs/scripts/tools_develop/check_type_annotations.py +263 -0
  17. aiecs-1.1.1/aiecs/scripts/tools_develop/validate_tool_schemas.py +346 -0
  18. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/__init__.py +53 -34
  19. aiecs-1.1.1/aiecs/tools/docs/__init__.py +106 -0
  20. aiecs-1.1.1/aiecs/tools/docs/ai_document_orchestrator.py +543 -0
  21. aiecs-1.1.1/aiecs/tools/docs/ai_document_writer_orchestrator.py +2199 -0
  22. aiecs-1.1.1/aiecs/tools/docs/content_insertion_tool.py +1214 -0
  23. aiecs-1.1.1/aiecs/tools/docs/document_creator_tool.py +1161 -0
  24. aiecs-1.1.1/aiecs/tools/docs/document_layout_tool.py +1090 -0
  25. aiecs-1.1.1/aiecs/tools/docs/document_parser_tool.py +904 -0
  26. aiecs-1.1.1/aiecs/tools/docs/document_writer_tool.py +1583 -0
  27. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/langchain_adapter.py +102 -51
  28. aiecs-1.1.1/aiecs/tools/schema_generator.py +265 -0
  29. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/task_tools/image_tool.py +1 -1
  30. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/task_tools/office_tool.py +9 -0
  31. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/task_tools/scraper_tool.py +1 -1
  32. {aiecs-1.0.8 → aiecs-1.1.1/aiecs.egg-info}/PKG-INFO +1 -1
  33. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs.egg-info/SOURCES.txt +31 -12
  34. aiecs-1.1.1/aiecs.egg-info/entry_points.txt +10 -0
  35. {aiecs-1.0.8 → aiecs-1.1.1}/pyproject.toml +9 -6
  36. aiecs-1.0.8/aiecs/domain/context/__init__.py +0 -29
  37. aiecs-1.0.8/aiecs.egg-info/entry_points.txt +0 -7
  38. {aiecs-1.0.8 → aiecs-1.1.1}/LICENSE +0 -0
  39. {aiecs-1.0.8 → aiecs-1.1.1}/MANIFEST.in +0 -0
  40. {aiecs-1.0.8 → aiecs-1.1.1}/README.md +0 -0
  41. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/__main__.py +0 -0
  42. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/application/__init__.py +0 -0
  43. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/application/executors/__init__.py +0 -0
  44. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/application/executors/operation_executor.py +0 -0
  45. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/config/__init__.py +0 -0
  46. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/config/registry.py +0 -0
  47. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/core/__init__.py +0 -0
  48. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/core/interface/__init__.py +0 -0
  49. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/core/interface/execution_interface.py +0 -0
  50. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/core/interface/storage_interface.py +0 -0
  51. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/domain/__init__.py +0 -0
  52. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/domain/community/collaborative_workflow.py +0 -0
  53. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/domain/community/community_integration.py +0 -0
  54. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/domain/community/community_manager.py +0 -0
  55. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/domain/community/decision_engine.py +0 -0
  56. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/domain/community/models/community_models.py +0 -0
  57. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/domain/community/resource_manager.py +0 -0
  58. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/domain/context/context_engine.py +0 -0
  59. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/domain/context/conversation_models.py +0 -0
  60. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/domain/execution/__init__.py +0 -0
  61. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/domain/execution/model.py +0 -0
  62. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/domain/task/__init__.py +0 -0
  63. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/domain/task/dsl_processor.py +0 -0
  64. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/domain/task/model.py +0 -0
  65. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/domain/task/task_context.py +0 -0
  66. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/infrastructure/__init__.py +0 -0
  67. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/infrastructure/messaging/__init__.py +0 -0
  68. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/infrastructure/messaging/celery_task_manager.py +0 -0
  69. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/infrastructure/messaging/websocket_manager.py +0 -0
  70. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/infrastructure/monitoring/__init__.py +0 -0
  71. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/infrastructure/monitoring/executor_metrics.py +0 -0
  72. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/infrastructure/monitoring/structured_logger.py +0 -0
  73. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/infrastructure/monitoring/tracing_manager.py +0 -0
  74. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/infrastructure/persistence/__init__.py +0 -0
  75. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/infrastructure/persistence/context_engine_client.py +0 -0
  76. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/infrastructure/persistence/database_manager.py +0 -0
  77. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/infrastructure/persistence/file_storage.py +0 -0
  78. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/infrastructure/persistence/redis_client.py +0 -0
  79. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/llm/__init__.py +0 -0
  80. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/llm/base_client.py +0 -0
  81. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/llm/client_factory.py +0 -0
  82. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/llm/custom_callbacks.py +0 -0
  83. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/llm/googleai_client.py +0 -0
  84. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/llm/openai_client.py +0 -0
  85. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/llm/vertex_client.py +0 -0
  86. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/llm/xai_client.py +0 -0
  87. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/scripts/__init__.py +0 -0
  88. {aiecs-1.0.8/aiecs/scripts → aiecs-1.1.1/aiecs/scripts/dependance_check}/DEPENDENCY_SYSTEM_SUMMARY.md +0 -0
  89. {aiecs-1.0.8/aiecs/scripts → aiecs-1.1.1/aiecs/scripts/dependance_check}/README_DEPENDENCY_CHECKER.md +0 -0
  90. {aiecs-1.0.8/aiecs/scripts → aiecs-1.1.1/aiecs/scripts/dependance_check}/dependency_checker.py +0 -0
  91. {aiecs-1.0.8/aiecs/scripts → aiecs-1.1.1/aiecs/scripts/dependance_check}/dependency_fixer.py +0 -0
  92. {aiecs-1.0.8/aiecs/scripts → aiecs-1.1.1/aiecs/scripts/dependance_check}/quick_dependency_check.py +0 -0
  93. {aiecs-1.0.8/aiecs/scripts → aiecs-1.1.1/aiecs/scripts/dependance_check}/setup_nlp_data.sh +0 -0
  94. {aiecs-1.0.8/aiecs/scripts → aiecs-1.1.1/aiecs/scripts/dependance_patch/fix_weasel}/README_WEASEL_PATCH.md +0 -0
  95. {aiecs-1.0.8/aiecs/scripts → aiecs-1.1.1/aiecs/scripts/dependance_patch/fix_weasel}/fix_weasel_validator.py +0 -0
  96. {aiecs-1.0.8/aiecs/scripts → aiecs-1.1.1/aiecs/scripts/dependance_patch/fix_weasel}/fix_weasel_validator.sh +0 -0
  97. {aiecs-1.0.8/aiecs/scripts → aiecs-1.1.1/aiecs/scripts/dependance_patch/fix_weasel}/patch_weasel_library.sh +0 -0
  98. {aiecs-1.0.8/aiecs/scripts → aiecs-1.1.1/aiecs/scripts/dependance_patch/fix_weasel}/run_weasel_patch.sh +0 -0
  99. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tasks/__init__.py +0 -0
  100. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tasks/worker.py +0 -0
  101. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/base_tool.py +0 -0
  102. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/task_tools/__init__.py +0 -0
  103. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/task_tools/chart_tool.py +0 -0
  104. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/task_tools/classfire_tool.py +0 -0
  105. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/task_tools/pandas_tool.py +0 -0
  106. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/task_tools/report_tool.py +0 -0
  107. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/task_tools/research_tool.py +0 -0
  108. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/task_tools/search_api.py +0 -0
  109. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/task_tools/stats_tool.py +0 -0
  110. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/temp_file_manager.py +0 -0
  111. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/tool_executor/__init__.py +0 -0
  112. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/tools/tool_executor/tool_executor.py +0 -0
  113. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/utils/LLM_output_structor.py +0 -0
  114. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/utils/__init__.py +0 -0
  115. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/utils/base_callback.py +0 -0
  116. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/utils/execution_utils.py +0 -0
  117. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/utils/logging.py +0 -0
  118. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/utils/prompt_loader.py +0 -0
  119. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/utils/token_usage_repository.py +0 -0
  120. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/ws/__init__.py +0 -0
  121. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs/ws/socket_server.py +0 -0
  122. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs.egg-info/dependency_links.txt +0 -0
  123. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs.egg-info/requires.txt +0 -0
  124. {aiecs-1.0.8 → aiecs-1.1.1}/aiecs.egg-info/top_level.txt +0 -0
  125. {aiecs-1.0.8 → aiecs-1.1.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiecs
3
- Version: 1.0.8
3
+ Version: 1.1.1
4
4
  Summary: AI Execute Services - A middleware framework for AI-powered task execution and tool orchestration
5
5
  Author-email: AIECS Team <iretbl@gmail.com>
6
6
  License-Expression: MIT
@@ -5,7 +5,7 @@ A powerful Python middleware framework for building AI-powered applications
5
5
  with tool orchestration, task execution, and multi-provider LLM support.
6
6
  """
7
7
 
8
- __version__ = "1.0.8"
8
+ __version__ = "1.1.1"
9
9
  __author__ = "AIECS Team"
10
10
  __email__ = "iretbl@gmail.com"
11
11
 
@@ -11,7 +11,8 @@ from contextlib import asynccontextmanager
11
11
  from aiecs.config.config import get_settings, validate_required_settings
12
12
  from aiecs.domain.task.task_context import TaskContext
13
13
  from aiecs.tools import discover_tools, list_tools, get_tool
14
- from aiecs.llm.client_factory import LLMClientFactory
14
+ from aiecs.llm.client_factory import LLMClientFactory, LLMClientManager, AIProvider
15
+ from aiecs.llm.base_client import LLMMessage
15
16
 
16
17
  logger = logging.getLogger(__name__)
17
18
 
@@ -46,6 +47,7 @@ class AIECS:
46
47
  self.db_manager = None
47
48
  self.task_manager = None
48
49
  self.operation_executor = None
50
+ self.llm_manager = None
49
51
 
50
52
  # State
51
53
  self._initialized = False
@@ -65,6 +67,10 @@ class AIECS:
65
67
  self._tools_discovered = True
66
68
  logger.info("Tools discovered and registered")
67
69
 
70
+ # Initialize LLM manager (available in both modes)
71
+ self.llm_manager = LLMClientManager()
72
+ logger.info("LLM manager initialized")
73
+
68
74
  if self.mode == "simple":
69
75
  # Simple mode: only tools, no database/Celery
70
76
  logger.info("Simple mode: tools only")
@@ -210,6 +216,158 @@ class AIECS:
210
216
 
211
217
  return get_tool(tool_name)
212
218
 
219
+ def process_task(self, task_context: TaskContext) -> Dict[str, Any]:
220
+ """
221
+ Process a task synchronously (for compatibility with synchronous tool calls)
222
+
223
+ Args:
224
+ task_context: TaskContext containing the task data
225
+
226
+ Returns:
227
+ Task processing result with AI-generated response
228
+ """
229
+ # Run the async method in a new event loop if needed
230
+ try:
231
+ loop = asyncio.get_event_loop()
232
+ if loop.is_running():
233
+ # If called from async context, create a new thread
234
+ import concurrent.futures
235
+ with concurrent.futures.ThreadPoolExecutor() as executor:
236
+ future = executor.submit(
237
+ asyncio.run,
238
+ self.process_task_async(task_context)
239
+ )
240
+ return future.result()
241
+ else:
242
+ # Run in current event loop
243
+ return loop.run_until_complete(self.process_task_async(task_context))
244
+ except RuntimeError:
245
+ # No event loop, create one
246
+ return asyncio.run(self.process_task_async(task_context))
247
+
248
+ async def process_task_async(self, task_context: TaskContext) -> Dict[str, Any]:
249
+ """
250
+ Process a task asynchronously using AI providers
251
+
252
+ Args:
253
+ task_context: TaskContext containing the task data
254
+
255
+ Returns:
256
+ Task processing result with AI-generated response
257
+ """
258
+ if not self._initialized:
259
+ await self.initialize()
260
+
261
+ if not self.llm_manager:
262
+ raise RuntimeError("LLM manager not initialized")
263
+
264
+ try:
265
+ # Extract data from TaskContext
266
+ context_dict = task_context.to_dict()
267
+ metadata = context_dict.get("metadata", {})
268
+
269
+ # Get AI provider preference from metadata
270
+ ai_preference = metadata.get("aiPreference", "default")
271
+ provider = None
272
+ model = None
273
+
274
+ # Parse AI preference
275
+ if isinstance(ai_preference, str):
276
+ # Simple string preference
277
+ if ai_preference.lower() != "default":
278
+ try:
279
+ provider = AIProvider(ai_preference)
280
+ except ValueError:
281
+ logger.warning(f"Unknown AI provider: {ai_preference}, using default")
282
+ elif isinstance(ai_preference, dict):
283
+ # Dictionary with provider and model
284
+ provider_str = ai_preference.get("provider")
285
+ if provider_str:
286
+ try:
287
+ provider = AIProvider(provider_str)
288
+ except ValueError:
289
+ logger.warning(f"Unknown AI provider: {provider_str}, using default")
290
+ model = ai_preference.get("model")
291
+
292
+ # Build prompt from context data
293
+ # The prompt could come from various sources in the context
294
+ prompt = None
295
+
296
+ # Check for direct prompt in metadata
297
+ if "prompt" in metadata:
298
+ prompt = metadata["prompt"]
299
+ # Check for input_data (common in document generation)
300
+ elif "input_data" in context_dict:
301
+ input_data = context_dict["input_data"]
302
+ if isinstance(input_data, dict) and "prompt" in input_data:
303
+ prompt = input_data["prompt"]
304
+ elif isinstance(input_data, str):
305
+ prompt = input_data
306
+
307
+ if not prompt:
308
+ # Fallback: construct a simple prompt from available data
309
+ prompt = f"Task: {context_dict.get('task_type', 'general')}\nData: {context_dict}"
310
+
311
+ # Get temperature and other parameters from metadata
312
+ temperature = metadata.get("temperature", 0.7)
313
+ max_tokens = metadata.get("max_tokens", 2000)
314
+
315
+ # Generate text using LLM manager
316
+ messages = [LLMMessage(role="user", content=prompt)]
317
+
318
+ response = await self.llm_manager.generate_text(
319
+ messages=messages,
320
+ provider=provider,
321
+ model=model,
322
+ context=context_dict,
323
+ temperature=temperature,
324
+ max_tokens=max_tokens
325
+ )
326
+
327
+ # Track model usage in context
328
+ if hasattr(task_context, 'track_model_usage'):
329
+ task_context.track_model_usage(
330
+ model_id=response.model,
331
+ provider_id=response.provider,
332
+ mode="generate"
333
+ )
334
+
335
+ # Return result in expected format
336
+ return {
337
+ "status": "completed",
338
+ "response": response.content,
339
+ "provider": response.provider,
340
+ "model": response.model,
341
+ "tokens_used": response.tokens_used,
342
+ "cost_estimate": response.cost_estimate,
343
+ "context_id": context_dict.get("chat_id", "unknown")
344
+ }
345
+
346
+ except Exception as e:
347
+ logger.error(f"Task processing failed: {e}", exc_info=True)
348
+
349
+ # For testing/development, provide a mock response when AI provider is unavailable
350
+ error_str = str(e).lower()
351
+ if "api key not configured" in error_str or "providernotavailable" in error_str:
352
+ logger.warning("AI provider unavailable, using mock response for testing")
353
+ mock_content = f"Mock AI-generated content for prompt: {prompt[:100] if len(prompt) > 100 else prompt}..."
354
+ return {
355
+ "status": "completed",
356
+ "response": mock_content,
357
+ "provider": "mock",
358
+ "model": "mock-model",
359
+ "tokens_used": len(mock_content.split()),
360
+ "cost_estimate": 0.0,
361
+ "context_id": context_dict.get("chat_id", "unknown"),
362
+ "mock": True
363
+ }
364
+
365
+ return {
366
+ "status": "failed",
367
+ "error": str(e),
368
+ "context_id": task_context.chat_id if hasattr(task_context, 'chat_id') else "unknown"
369
+ }
370
+
213
371
  async def _wait_for_task_completion(self, task_id: str, timeout: int = 300) -> Dict[str, Any]:
214
372
  """
215
373
  Wait for task completion with timeout
@@ -40,6 +40,10 @@ class Settings(BaseSettings):
40
40
  # Vector store backend selection (Qdrant deprecated, using Vertex AI by default)
41
41
  vector_store_backend: str = Field("vertex", alias="VECTOR_STORE_BACKEND") # "vertex" (qdrant deprecated)
42
42
 
43
+ # Development/Server Configuration
44
+ reload: bool = Field(default=False, alias="RELOAD")
45
+ port: int = Field(default=8000, alias="PORT")
46
+
43
47
  model_config = ConfigDict(env_file=".env", env_file_encoding="utf-8")
44
48
 
45
49
  @property
@@ -0,0 +1,53 @@
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
+ Usage:
13
+ # For creating ContextEngine instances directly:
14
+ from aiecs.domain.context import ContextEngine
15
+ engine = ContextEngine(use_existing_redis=True)
16
+ await engine.initialize()
17
+
18
+ # For using the global singleton instance (recommended):
19
+ from aiecs.infrastructure.persistence import (
20
+ get_context_engine,
21
+ initialize_context_engine,
22
+ close_context_engine
23
+ )
24
+
25
+ # The global instance is automatically initialized in main.py lifespan
26
+ context_engine = get_context_engine()
27
+ if context_engine:
28
+ await context_engine.add_conversation_message(...)
29
+
30
+ Architecture Note:
31
+ - This package contains DOMAIN layer classes (business logic)
32
+ - Global instance management is in INFRASTRUCTURE layer:
33
+ aiecs.infrastructure.persistence.context_engine_client
34
+ - This separation follows Clean Architecture / DDD principles
35
+ """
36
+
37
+ from .context_engine import ContextEngine, SessionMetrics, ConversationMessage
38
+ from .conversation_models import (
39
+ ConversationParticipant, ConversationSession, AgentCommunicationMessage,
40
+ create_session_key, validate_conversation_isolation_pattern
41
+ )
42
+
43
+ __all__ = [
44
+ 'ContextEngine',
45
+ 'SessionMetrics',
46
+ 'ConversationMessage',
47
+ 'ConversationParticipant',
48
+ 'ConversationSession',
49
+ 'AgentCommunicationMessage',
50
+ 'create_session_key',
51
+ 'validate_conversation_isolation_pattern'
52
+ ]
53
+
@@ -23,6 +23,10 @@ from aiecs.ws.socket_server import sio
23
23
 
24
24
  # Import infrastructure
25
25
  from aiecs.infrastructure.persistence.database_manager import DatabaseManager
26
+ from aiecs.infrastructure.persistence import (
27
+ initialize_context_engine,
28
+ close_context_engine
29
+ )
26
30
  from aiecs.infrastructure.messaging.celery_task_manager import CeleryTaskManager
27
31
  from aiecs.infrastructure.monitoring.structured_logger import setup_structured_logging
28
32
 
@@ -82,6 +86,13 @@ async def lifespan(app: FastAPI):
82
86
  logger.error(f"Failed to discover tools: {e}")
83
87
  raise
84
88
 
89
+ # Initialize ContextEngine (optional, graceful degradation)
90
+ try:
91
+ await initialize_context_engine()
92
+ logger.info("ContextEngine initialized")
93
+ except Exception as e:
94
+ logger.warning(f"ContextEngine initialization failed (continuing without it): {e}")
95
+
85
96
  # Application startup complete
86
97
  logger.info("AIECS startup complete")
87
98
 
@@ -90,6 +101,13 @@ async def lifespan(app: FastAPI):
90
101
  # Shutdown
91
102
  logger.info("Shutting down AIECS...")
92
103
 
104
+ # Close ContextEngine
105
+ try:
106
+ await close_context_engine()
107
+ logger.info("ContextEngine closed")
108
+ except Exception as e:
109
+ logger.warning(f"Error closing ContextEngine: {e}")
110
+
93
111
  # Close database connection
94
112
  if db_manager:
95
113
  await db_manager.disconnect()
@@ -106,7 +124,7 @@ async def lifespan(app: FastAPI):
106
124
  app = FastAPI(
107
125
  title="AIECS - AI Execute Services",
108
126
  description="Middleware service for AI-powered task execution and tool orchestration",
109
- version="1.0.5",
127
+ version="1.1.1",
110
128
  lifespan=lifespan
111
129
  )
112
130
 
@@ -131,7 +149,7 @@ async def health_check():
131
149
  return {
132
150
  "status": "healthy",
133
151
  "service": "aiecs",
134
- "version": "1.0.8"
152
+ "version": "1.1.1"
135
153
  }
136
154
 
137
155
 
@@ -0,0 +1,97 @@
1
+ # AIECS 版本管理
2
+
3
+ AIECS 提供了一个统一的版本管理工具,可以同时更新项目中所有相关文件的版本号。
4
+
5
+ ## 支持的文件
6
+
7
+ 版本管理工具会自动更新以下文件中的版本号:
8
+
9
+ 1. **`aiecs/__init__.py`** - 更新 `__version__` 变量
10
+ 2. **`aiecs/main.py`** - 更新 FastAPI 应用版本和健康检查端点版本
11
+ 3. **`pyproject.toml`** - 更新项目版本
12
+
13
+ ## 使用方法
14
+
15
+ ### 1. 显示当前版本
16
+
17
+ ```bash
18
+ poetry run python -m aiecs.scripts.aid.version_manager --show
19
+ ```
20
+
21
+ ### 2. 设置特定版本
22
+
23
+ ```bash
24
+ poetry run python -m aiecs.scripts.aid.version_manager --version 1.2.0
25
+ ```
26
+
27
+ ### 3. 自动递增版本
28
+
29
+ #### 补丁版本 (Patch)
30
+ ```bash
31
+ poetry run python -m aiecs.scripts.aid.version_manager --bump patch
32
+ # 1.1.0 -> 1.1.1
33
+ ```
34
+
35
+ #### 次版本 (Minor)
36
+ ```bash
37
+ poetry run python -m aiecs.scripts.aid.version_manager --bump minor
38
+ # 1.1.0 -> 1.2.0
39
+ ```
40
+
41
+ #### 主版本 (Major)
42
+ ```bash
43
+ poetry run python -m aiecs.scripts.aid.version_manager --bump major
44
+ # 1.1.0 -> 2.0.0
45
+ ```
46
+
47
+ ## 版本号格式
48
+
49
+ 版本号遵循 [语义化版本控制](https://semver.org/) 规范:
50
+
51
+ - **主版本号 (Major)**: 不兼容的API修改
52
+ - **次版本号 (Minor)**: 向下兼容的功能性新增
53
+ - **补丁版本号 (Patch)**: 向下兼容的问题修正
54
+
55
+ 格式:`X.Y.Z` (例如:1.2.3)
56
+
57
+ ## 命令行选项
58
+
59
+ - `--version, -v`: 设置特定版本号
60
+ - `--bump, -b`: 自动递增版本 (major/minor/patch)
61
+ - `--show, -s`: 显示当前版本
62
+ - `--help, -h`: 显示帮助信息
63
+
64
+ ## 示例
65
+
66
+ ```bash
67
+ # 查看当前版本
68
+ poetry run python -m aiecs.scripts.aid.version_manager --show
69
+
70
+ # 发布补丁版本
71
+ poetry run python -m aiecs.scripts.aid.version_manager --bump patch
72
+
73
+ # 发布新功能版本
74
+ poetry run python -m aiecs.scripts.aid.version_manager --bump minor
75
+
76
+ # 发布重大更新版本
77
+ poetry run python -m aiecs.scripts.aid.version_manager --bump major
78
+
79
+ # 手动设置版本
80
+ poetry run python -m aiecs.scripts.aid.version_manager --version 2.1.0
81
+ ```
82
+
83
+ ## 注意事项
84
+
85
+ 1. 版本管理工具会自动验证版本号格式
86
+ 2. 所有相关文件会同时更新,确保版本号一致性
87
+ 3. 更新前建议先提交当前更改到版本控制系统
88
+ 4. 工具会显示详细的更新日志,确认所有文件都已正确更新
89
+
90
+ ## 故障排除
91
+
92
+ 如果遇到问题,请检查:
93
+
94
+ 1. 确保在项目根目录下运行命令
95
+ 2. 确保所有目标文件存在且可写
96
+ 3. 检查版本号格式是否正确 (X.Y.Z)
97
+ 4. 确保没有其他进程正在编辑这些文件
@@ -0,0 +1,15 @@
1
+ """
2
+ AIECS Development Tools (AID)
3
+
4
+ This module contains development and maintenance tools for the AIECS project.
5
+ """
6
+
7
+ # Lazy import to avoid circular import issues
8
+ def get_version_manager_main():
9
+ """Get the version manager main function"""
10
+ from .version_manager import main
11
+ return main
12
+
13
+ __all__ = [
14
+ 'get_version_manager_main',
15
+ ]
@@ -0,0 +1,224 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ AIECS Version Manager
4
+
5
+ A script to manage version numbers across multiple files in the AIECS project.
6
+ Updates version numbers in:
7
+ - aiecs/__init__.py (__version__)
8
+ - aiecs/main.py (FastAPI app version and health check version)
9
+ - pyproject.toml (project version)
10
+
11
+ Usage:
12
+ aiecs-version --version 1.2.0
13
+ aiecs-version --bump patch
14
+ aiecs-version --bump minor
15
+ aiecs-version --bump major
16
+ aiecs-version --show
17
+ """
18
+
19
+ import argparse
20
+ import re
21
+ import sys
22
+ from pathlib import Path
23
+ from typing import Optional, Tuple
24
+
25
+
26
+ class VersionManager:
27
+ """Manages version numbers across AIECS project files"""
28
+
29
+ def __init__(self, project_root: Optional[Path] = None):
30
+ """Initialize the version manager with project root path"""
31
+ if project_root is None:
32
+ # Find project root by looking for pyproject.toml
33
+ current = Path(__file__).parent
34
+ while current != current.parent:
35
+ if (current / "pyproject.toml").exists():
36
+ project_root = current
37
+ break
38
+ current = current.parent
39
+
40
+ if project_root is None:
41
+ raise RuntimeError("Could not find project root (pyproject.toml)")
42
+
43
+ self.project_root = project_root
44
+ self.files = {
45
+ 'init': project_root / "aiecs" / "__init__.py",
46
+ 'main': project_root / "aiecs" / "main.py",
47
+ 'pyproject': project_root / "pyproject.toml"
48
+ }
49
+
50
+ def get_current_version(self) -> str:
51
+ """Get the current version from __init__.py"""
52
+ init_file = self.files['init']
53
+ if not init_file.exists():
54
+ raise FileNotFoundError(f"Could not find {init_file}")
55
+
56
+ content = init_file.read_text(encoding='utf-8')
57
+ match = re.search(r'__version__\s*=\s*["\']([^"\']+)["\']', content)
58
+ if not match:
59
+ raise ValueError("Could not find __version__ in __init__.py")
60
+
61
+ return match.group(1)
62
+
63
+ def parse_version(self, version: str) -> Tuple[int, int, int]:
64
+ """Parse version string into major, minor, patch components"""
65
+ match = re.match(r'^(\d+)\.(\d+)\.(\d+)$', version)
66
+ if not match:
67
+ raise ValueError(f"Invalid version format: {version}. Expected format: X.Y.Z")
68
+
69
+ return int(match.group(1)), int(match.group(2)), int(match.group(3))
70
+
71
+ def bump_version(self, current_version: str, bump_type: str) -> str:
72
+ """Bump version based on type (major, minor, patch)"""
73
+ major, minor, patch = self.parse_version(current_version)
74
+
75
+ if bump_type == 'major':
76
+ major += 1
77
+ minor = 0
78
+ patch = 0
79
+ elif bump_type == 'minor':
80
+ minor += 1
81
+ patch = 0
82
+ elif bump_type == 'patch':
83
+ patch += 1
84
+ else:
85
+ raise ValueError(f"Invalid bump type: {bump_type}. Use 'major', 'minor', or 'patch'")
86
+
87
+ return f"{major}.{minor}.{patch}"
88
+
89
+ def update_init_file(self, new_version: str) -> None:
90
+ """Update version in aiecs/__init__.py"""
91
+ init_file = self.files['init']
92
+ content = init_file.read_text(encoding='utf-8')
93
+
94
+ # Update __version__ line
95
+ content = re.sub(
96
+ r'(__version__\s*=\s*["\'])([^"\']+)(["\'])',
97
+ rf'\g<1>{new_version}\g<3>',
98
+ content
99
+ )
100
+
101
+ init_file.write_text(content, encoding='utf-8')
102
+ print(f"✓ Updated {init_file.relative_to(self.project_root)}: __version__ = \"{new_version}\"")
103
+
104
+ def update_main_file(self, new_version: str) -> None:
105
+ """Update version in aiecs/main.py"""
106
+ main_file = self.files['main']
107
+ content = main_file.read_text(encoding='utf-8')
108
+
109
+ # Update FastAPI app version
110
+ content = re.sub(
111
+ r'(version=")([^"]+)(")',
112
+ rf'\g<1>{new_version}\g<3>',
113
+ content
114
+ )
115
+
116
+ # Update health check version
117
+ content = re.sub(
118
+ r'("version":\s*")([^"]+)(")',
119
+ rf'\g<1>{new_version}\g<3>',
120
+ content
121
+ )
122
+
123
+ main_file.write_text(content, encoding='utf-8')
124
+ print(f"✓ Updated {main_file.relative_to(self.project_root)}: FastAPI version and health check version")
125
+
126
+ def update_pyproject_file(self, new_version: str) -> None:
127
+ """Update version in pyproject.toml"""
128
+ pyproject_file = self.files['pyproject']
129
+ content = pyproject_file.read_text(encoding='utf-8')
130
+
131
+ # Update project version (only in [project] section, not in [project.scripts])
132
+ # Use a more specific pattern to avoid updating script entry points
133
+ content = re.sub(
134
+ r'^(\s*version\s*=\s*")([^"]+)(")',
135
+ rf'\g<1>{new_version}\g<3>',
136
+ content,
137
+ flags=re.MULTILINE
138
+ )
139
+
140
+ pyproject_file.write_text(content, encoding='utf-8')
141
+ print(f"✓ Updated {pyproject_file.relative_to(self.project_root)}: project version")
142
+
143
+ def update_version(self, new_version: str) -> None:
144
+ """Update version in all files"""
145
+ # Validate version format
146
+ self.parse_version(new_version)
147
+
148
+ print(f"Updating version to {new_version}...")
149
+ print()
150
+
151
+ # Update all files
152
+ self.update_init_file(new_version)
153
+ self.update_main_file(new_version)
154
+ self.update_pyproject_file(new_version)
155
+
156
+ print()
157
+ print(f"✓ Successfully updated version to {new_version} in all files!")
158
+
159
+ def show_version(self) -> None:
160
+ """Show current version"""
161
+ try:
162
+ version = self.get_current_version()
163
+ print(f"Current version: {version}")
164
+ except Exception as e:
165
+ print(f"Error getting current version: {e}", file=sys.stderr)
166
+ sys.exit(1)
167
+
168
+
169
+ def main():
170
+ """Main entry point for the version manager"""
171
+ parser = argparse.ArgumentParser(
172
+ description="AIECS Version Manager - Update version numbers across project files",
173
+ formatter_class=argparse.RawDescriptionHelpFormatter,
174
+ epilog="""
175
+ Examples:
176
+ aiecs-version --version 1.2.0 # Set specific version
177
+ aiecs-version --bump patch # Bump patch version (1.1.0 -> 1.1.1)
178
+ aiecs-version --bump minor # Bump minor version (1.1.0 -> 1.2.0)
179
+ aiecs-version --bump major # Bump major version (1.1.0 -> 2.0.0)
180
+ aiecs-version --show # Show current version
181
+ """
182
+ )
183
+
184
+ # Create mutually exclusive group for version options
185
+ version_group = parser.add_mutually_exclusive_group(required=True)
186
+ version_group.add_argument(
187
+ '--version', '-v',
188
+ type=str,
189
+ help='Set specific version (e.g., 1.2.0)'
190
+ )
191
+ version_group.add_argument(
192
+ '--bump', '-b',
193
+ choices=['major', 'minor', 'patch'],
194
+ help='Bump version: major (X.0.0), minor (X.Y.0), or patch (X.Y.Z)'
195
+ )
196
+ version_group.add_argument(
197
+ '--show', '-s',
198
+ action='store_true',
199
+ help='Show current version'
200
+ )
201
+
202
+ args = parser.parse_args()
203
+
204
+ try:
205
+ manager = VersionManager()
206
+
207
+ if args.show:
208
+ manager.show_version()
209
+ elif args.version:
210
+ manager.update_version(args.version)
211
+ elif args.bump:
212
+ current_version = manager.get_current_version()
213
+ new_version = manager.bump_version(current_version, args.bump)
214
+ print(f"Bumping {args.bump} version: {current_version} -> {new_version}")
215
+ print()
216
+ manager.update_version(new_version)
217
+
218
+ except Exception as e:
219
+ print(f"Error: {e}", file=sys.stderr)
220
+ sys.exit(1)
221
+
222
+
223
+ if __name__ == '__main__':
224
+ main()
@@ -0,0 +1,18 @@
1
+ """
2
+ 依赖检查和修复工具
3
+
4
+ 提供 AIECS 系统依赖的检查、修复和 NLP 数据下载功能。
5
+ """
6
+
7
+ from .dependency_checker import main as dependency_checker_main
8
+ from .dependency_fixer import main as dependency_fixer_main
9
+ from .quick_dependency_check import main as quick_dependency_check_main
10
+ from .download_nlp_data import main as download_nlp_data_main
11
+
12
+ __all__ = [
13
+ 'dependency_checker_main',
14
+ 'dependency_fixer_main',
15
+ 'quick_dependency_check_main',
16
+ 'download_nlp_data_main',
17
+ ]
18
+