aiecs 1.1.0__py3-none-any.whl → 1.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.

Potentially problematic release.


This version of aiecs might be problematic. Click here for more details.

Files changed (58) hide show
  1. aiecs/__init__.py +1 -1
  2. aiecs/config/config.py +2 -0
  3. aiecs/domain/__init__.py +95 -0
  4. aiecs/domain/community/__init__.py +159 -0
  5. aiecs/domain/community/agent_adapter.py +516 -0
  6. aiecs/domain/community/analytics.py +465 -0
  7. aiecs/domain/community/collaborative_workflow.py +99 -7
  8. aiecs/domain/community/communication_hub.py +649 -0
  9. aiecs/domain/community/community_builder.py +322 -0
  10. aiecs/domain/community/community_integration.py +365 -12
  11. aiecs/domain/community/community_manager.py +481 -5
  12. aiecs/domain/community/decision_engine.py +459 -13
  13. aiecs/domain/community/exceptions.py +238 -0
  14. aiecs/domain/community/models/__init__.py +36 -0
  15. aiecs/domain/community/resource_manager.py +1 -1
  16. aiecs/domain/community/shared_context_manager.py +621 -0
  17. aiecs/domain/context/context_engine.py +37 -33
  18. aiecs/main.py +2 -2
  19. aiecs/scripts/aid/VERSION_MANAGEMENT.md +97 -0
  20. aiecs/scripts/aid/__init__.py +15 -0
  21. aiecs/scripts/aid/version_manager.py +224 -0
  22. aiecs/scripts/dependance_check/download_nlp_data.py +1 -0
  23. aiecs/tools/__init__.py +23 -23
  24. aiecs/tools/docs/__init__.py +5 -2
  25. aiecs/tools/docs/ai_document_orchestrator.py +39 -26
  26. aiecs/tools/docs/ai_document_writer_orchestrator.py +61 -38
  27. aiecs/tools/docs/content_insertion_tool.py +48 -28
  28. aiecs/tools/docs/document_creator_tool.py +47 -29
  29. aiecs/tools/docs/document_layout_tool.py +35 -20
  30. aiecs/tools/docs/document_parser_tool.py +56 -36
  31. aiecs/tools/docs/document_writer_tool.py +115 -62
  32. aiecs/tools/schema_generator.py +56 -56
  33. aiecs/tools/statistics/__init__.py +82 -0
  34. aiecs/tools/statistics/ai_data_analysis_orchestrator.py +581 -0
  35. aiecs/tools/statistics/ai_insight_generator_tool.py +473 -0
  36. aiecs/tools/statistics/ai_report_orchestrator_tool.py +629 -0
  37. aiecs/tools/statistics/data_loader_tool.py +518 -0
  38. aiecs/tools/statistics/data_profiler_tool.py +599 -0
  39. aiecs/tools/statistics/data_transformer_tool.py +531 -0
  40. aiecs/tools/statistics/data_visualizer_tool.py +460 -0
  41. aiecs/tools/statistics/model_trainer_tool.py +470 -0
  42. aiecs/tools/statistics/statistical_analyzer_tool.py +426 -0
  43. aiecs/tools/task_tools/chart_tool.py +2 -1
  44. aiecs/tools/task_tools/image_tool.py +43 -43
  45. aiecs/tools/task_tools/office_tool.py +39 -36
  46. aiecs/tools/task_tools/pandas_tool.py +37 -33
  47. aiecs/tools/task_tools/report_tool.py +67 -56
  48. aiecs/tools/task_tools/research_tool.py +32 -31
  49. aiecs/tools/task_tools/scraper_tool.py +53 -46
  50. aiecs/tools/task_tools/search_tool.py +1123 -0
  51. aiecs/tools/task_tools/stats_tool.py +20 -15
  52. {aiecs-1.1.0.dist-info → aiecs-1.2.0.dist-info}/METADATA +5 -1
  53. {aiecs-1.1.0.dist-info → aiecs-1.2.0.dist-info}/RECORD +57 -36
  54. {aiecs-1.1.0.dist-info → aiecs-1.2.0.dist-info}/entry_points.txt +1 -0
  55. aiecs/tools/task_tools/search_api.py +0 -7
  56. {aiecs-1.1.0.dist-info → aiecs-1.2.0.dist-info}/WHEEL +0 -0
  57. {aiecs-1.1.0.dist-info → aiecs-1.2.0.dist-info}/licenses/LICENSE +0 -0
  58. {aiecs-1.1.0.dist-info → aiecs-1.2.0.dist-info}/top_level.txt +0 -0
@@ -7,14 +7,16 @@ providing seamless community-aware agent management and collaboration.
7
7
 
8
8
  import logging
9
9
  from typing import Dict, List, Any, Optional
10
- from datetime import datetime
10
+ from datetime import datetime, timedelta
11
+ from contextlib import asynccontextmanager
12
+ import asyncio
11
13
 
12
14
  from .community_manager import CommunityManager
13
15
  from .decision_engine import DecisionEngine, ConsensusAlgorithm
14
16
  from .resource_manager import ResourceManager
15
17
  from .collaborative_workflow import CollaborativeWorkflowEngine
16
18
  from .models.community_models import CommunityRole, GovernanceType
17
- from ..core.exceptions.task_exceptions import TaskValidationError
19
+ from .exceptions import CommunityValidationError as TaskValidationError
18
20
 
19
21
  logger = logging.getLogger(__name__)
20
22
 
@@ -82,9 +84,6 @@ class CommunityIntegration:
82
84
  Returns:
83
85
  Community ID
84
86
  """
85
- if not self.agent_manager:
86
- raise TaskValidationError("Agent manager not available")
87
-
88
87
  # Create the community
89
88
  community_id = await self.community_manager.create_community(
90
89
  name=name,
@@ -93,13 +92,17 @@ class CommunityIntegration:
93
92
  creator_agent_id=creator_agent_id
94
93
  )
95
94
 
96
- # Add agents to the community
97
- for role in agent_roles:
98
- # Get agents with this role from agent manager
99
- agents = self.agent_manager.agent_registry.get_agents_by_role(role)
100
-
101
- for agent in agents:
102
- await self._add_agent_to_community(community_id, agent.agent_id, role)
95
+ # Add agents to the community if agent_manager is available
96
+ if self.agent_manager:
97
+ for role in agent_roles:
98
+ # Get agents with this role from agent manager
99
+ agents = self.agent_manager.agent_registry.get_agents_by_role(role)
100
+
101
+ for agent in agents:
102
+ await self._add_agent_to_community(community_id, agent.agent_id, role)
103
+ else:
104
+ # For testing or when agent_manager is not available, just log the roles
105
+ logger.debug(f"Agent manager not available, community created without auto-adding agents for roles: {agent_roles}")
103
106
 
104
107
  logger.info(f"Created agent community '{name}' with {len(agent_roles)} role types")
105
108
  return community_id
@@ -437,3 +440,353 @@ class CommunityIntegration:
437
440
  }
438
441
 
439
442
  return status
443
+
444
+ # ========== Quick-Create Factory Methods ==========
445
+
446
+ async def create_temporary_community(
447
+ self,
448
+ name: str,
449
+ description: str,
450
+ agent_roles: List[str],
451
+ duration_minutes: int = 60,
452
+ auto_cleanup: bool = True,
453
+ governance_type: GovernanceType = GovernanceType.DEMOCRATIC,
454
+ creator_agent_id: Optional[str] = None
455
+ ) -> str:
456
+ """
457
+ Create a temporary community with automatic cleanup.
458
+
459
+ Args:
460
+ name: Name of the community
461
+ description: Description
462
+ agent_roles: List of agent roles to include
463
+ duration_minutes: Duration before auto-cleanup
464
+ auto_cleanup: Whether to automatically cleanup after duration
465
+ governance_type: Type of governance
466
+ creator_agent_id: ID of the creating agent
467
+
468
+ Returns:
469
+ Community ID
470
+ """
471
+ community_id = await self.create_agent_community(
472
+ name=name,
473
+ description=description,
474
+ agent_roles=agent_roles,
475
+ governance_type=governance_type,
476
+ creator_agent_id=creator_agent_id
477
+ )
478
+
479
+ # Mark as temporary
480
+ community = self.community_manager.communities[community_id]
481
+ community.metadata["temporary"] = True
482
+ community.metadata["created_for_duration"] = duration_minutes
483
+ community.metadata["cleanup_at"] = (datetime.utcnow() + timedelta(minutes=duration_minutes)).isoformat()
484
+
485
+ # Schedule cleanup if enabled
486
+ if auto_cleanup:
487
+ asyncio.create_task(self._cleanup_temporary_community(community_id, duration_minutes))
488
+
489
+ logger.info(f"Created temporary community {name} for {duration_minutes} minutes")
490
+ return community_id
491
+
492
+ async def _cleanup_temporary_community(self, community_id: str, duration_minutes: int) -> None:
493
+ """Cleanup temporary community after duration."""
494
+ await asyncio.sleep(duration_minutes * 60)
495
+
496
+ try:
497
+ community = self.community_manager.communities.get(community_id)
498
+ if community and community.metadata.get("temporary"):
499
+ # Mark as inactive
500
+ community.is_active = False
501
+ community.metadata["cleanup_completed"] = datetime.utcnow().isoformat()
502
+ logger.info(f"Cleaned up temporary community {community_id}")
503
+ except Exception as e:
504
+ logger.error(f"Error cleaning up temporary community {community_id}: {e}")
505
+
506
+ async def create_project_community(
507
+ self,
508
+ project_name: str,
509
+ project_description: str,
510
+ agent_roles: List[str],
511
+ project_goal: str,
512
+ project_deadline: Optional[datetime] = None,
513
+ creator_agent_id: Optional[str] = None
514
+ ) -> str:
515
+ """
516
+ Create a community pre-configured for project collaboration.
517
+
518
+ Args:
519
+ project_name: Name of the project
520
+ project_description: Project description
521
+ agent_roles: List of agent roles for the project
522
+ project_goal: Goal of the project
523
+ project_deadline: Optional project deadline
524
+ creator_agent_id: ID of the creating agent
525
+
526
+ Returns:
527
+ Community ID
528
+ """
529
+ community_id = await self.create_agent_community(
530
+ name=f"Project: {project_name}",
531
+ description=project_description,
532
+ agent_roles=agent_roles,
533
+ governance_type=GovernanceType.HIERARCHICAL, # Project-based governance
534
+ creator_agent_id=creator_agent_id
535
+ )
536
+
537
+ # Configure for project collaboration
538
+ community = self.community_manager.communities[community_id]
539
+ community.metadata["type"] = "project"
540
+ community.metadata["project_goal"] = project_goal
541
+ if project_deadline:
542
+ community.metadata["project_deadline"] = project_deadline.isoformat()
543
+
544
+ # Create initial project resources
545
+ if creator_agent_id:
546
+ # Find creator member
547
+ creator_member_id = None
548
+ for mid, member in self.community_manager.members.items():
549
+ if member.agent_id == creator_agent_id and mid in community.members:
550
+ creator_member_id = mid
551
+ break
552
+
553
+ if creator_member_id:
554
+ # Create project charter resource
555
+ await self.resource_manager.create_knowledge_resource(
556
+ community_id=community_id,
557
+ owner_member_id=creator_member_id,
558
+ title=f"{project_name} Charter",
559
+ content=f"Goal: {project_goal}\n\nDescription: {project_description}",
560
+ knowledge_type="project_charter",
561
+ tags=["project", "charter", project_name]
562
+ )
563
+
564
+ logger.info(f"Created project community: {project_name}")
565
+ return community_id
566
+
567
+ async def create_research_community(
568
+ self,
569
+ research_topic: str,
570
+ research_questions: List[str],
571
+ agent_roles: List[str],
572
+ methodologies: Optional[List[str]] = None,
573
+ creator_agent_id: Optional[str] = None
574
+ ) -> str:
575
+ """
576
+ Create a community pre-configured for research collaboration.
577
+
578
+ Args:
579
+ research_topic: Topic of research
580
+ research_questions: Research questions to explore
581
+ agent_roles: List of agent roles for research
582
+ methodologies: Optional research methodologies
583
+ creator_agent_id: ID of the creating agent
584
+
585
+ Returns:
586
+ Community ID
587
+ """
588
+ community_id = await self.create_agent_community(
589
+ name=f"Research: {research_topic}",
590
+ description=f"Collaborative research on {research_topic}",
591
+ agent_roles=agent_roles,
592
+ governance_type=GovernanceType.CONSENSUS, # Consensus-based for research
593
+ creator_agent_id=creator_agent_id
594
+ )
595
+
596
+ # Configure for research
597
+ community = self.community_manager.communities[community_id]
598
+ community.metadata["type"] = "research"
599
+ community.metadata["research_topic"] = research_topic
600
+ community.metadata["research_questions"] = research_questions
601
+ if methodologies:
602
+ community.metadata["methodologies"] = methodologies
603
+
604
+ # Create research resources
605
+ if creator_agent_id:
606
+ # Find creator member
607
+ creator_member_id = None
608
+ for mid, member in self.community_manager.members.items():
609
+ if member.agent_id == creator_agent_id and mid in community.members:
610
+ creator_member_id = mid
611
+ break
612
+
613
+ if creator_member_id:
614
+ # Create research plan resource
615
+ research_plan = {
616
+ "topic": research_topic,
617
+ "questions": research_questions,
618
+ "methodologies": methodologies or [],
619
+ "status": "planning"
620
+ }
621
+
622
+ await self.resource_manager.create_knowledge_resource(
623
+ community_id=community_id,
624
+ owner_member_id=creator_member_id,
625
+ title=f"{research_topic} Research Plan",
626
+ content=str(research_plan),
627
+ knowledge_type="research_plan",
628
+ tags=["research", "plan", research_topic]
629
+ )
630
+
631
+ logger.info(f"Created research community: {research_topic}")
632
+ return community_id
633
+
634
+ async def quick_brainstorm(
635
+ self,
636
+ topic: str,
637
+ agent_ids: List[str],
638
+ duration_minutes: int = 30,
639
+ auto_cleanup: bool = True
640
+ ) -> Dict[str, Any]:
641
+ """
642
+ Quick one-line brainstorming session with temporary community.
643
+
644
+ Args:
645
+ topic: Topic to brainstorm
646
+ agent_ids: List of agent IDs to participate
647
+ duration_minutes: Duration of the session
648
+ auto_cleanup: Whether to cleanup community after
649
+
650
+ Returns:
651
+ Session results and summary
652
+ """
653
+ # Create temporary community
654
+ community_id = await self.create_temporary_community(
655
+ name=f"Brainstorm: {topic}",
656
+ description=f"Quick brainstorming session on {topic}",
657
+ agent_roles=[], # Will add specific agents
658
+ duration_minutes=duration_minutes,
659
+ auto_cleanup=auto_cleanup,
660
+ governance_type=GovernanceType.DEMOCRATIC
661
+ )
662
+
663
+ # Add specific agents to community
664
+ for agent_id in agent_ids:
665
+ await self._add_agent_to_community(
666
+ community_id=community_id,
667
+ agent_id=agent_id,
668
+ agent_role="brainstormer",
669
+ community_role=CommunityRole.CONTRIBUTOR
670
+ )
671
+
672
+ # Start brainstorming session
673
+ session_id = await self.workflow_engine.start_collaborative_session(
674
+ community_id=community_id,
675
+ session_leader_id=agent_ids[0] if agent_ids else None,
676
+ session_type="brainstorming",
677
+ purpose=f"Brainstorm ideas for {topic}",
678
+ participants=[mid for mid in self.community_manager.communities[community_id].members],
679
+ duration_minutes=duration_minutes
680
+ )
681
+
682
+ # Wait for session to complete (simplified - in reality would be async)
683
+ await asyncio.sleep(2) # Simulate session time
684
+
685
+ # End session and get results
686
+ summary = await self.workflow_engine.end_session(session_id)
687
+
688
+ results = {
689
+ "topic": topic,
690
+ "community_id": community_id,
691
+ "session_id": session_id,
692
+ "participants": agent_ids,
693
+ "duration_minutes": duration_minutes,
694
+ "summary": summary
695
+ }
696
+
697
+ logger.info(f"Completed quick brainstorm on {topic}")
698
+ return results
699
+
700
+ # ========== Context Managers ==========
701
+
702
+ @asynccontextmanager
703
+ async def temporary_community(
704
+ self,
705
+ name: str,
706
+ agent_roles: List[str],
707
+ governance_type: GovernanceType = GovernanceType.DEMOCRATIC,
708
+ creator_agent_id: Optional[str] = None
709
+ ):
710
+ """
711
+ Context manager for temporary communities with automatic cleanup.
712
+
713
+ Args:
714
+ name: Name of the community
715
+ agent_roles: List of agent roles
716
+ governance_type: Type of governance
717
+ creator_agent_id: ID of the creating agent
718
+
719
+ Yields:
720
+ Community ID
721
+
722
+ Example:
723
+ async with integration.temporary_community("Quick Collab", ["analyst", "writer"]) as community_id:
724
+ # Use community
725
+ await integration.initiate_community_collaboration(...)
726
+ # Community automatically cleaned up
727
+ """
728
+ community_id = await self.create_agent_community(
729
+ name=name,
730
+ description=f"Temporary community: {name}",
731
+ agent_roles=agent_roles,
732
+ governance_type=governance_type,
733
+ creator_agent_id=creator_agent_id
734
+ )
735
+
736
+ try:
737
+ yield community_id
738
+ finally:
739
+ # Cleanup
740
+ community = self.community_manager.communities.get(community_id)
741
+ if community:
742
+ community.is_active = False
743
+ community.metadata["context_manager_cleanup"] = datetime.utcnow().isoformat()
744
+ logger.info(f"Context manager cleaned up community {community_id}")
745
+
746
+ @asynccontextmanager
747
+ async def collaborative_session(
748
+ self,
749
+ community_id: str,
750
+ session_type: str,
751
+ purpose: str,
752
+ leader_agent_id: Optional[str] = None,
753
+ participants: Optional[List[str]] = None
754
+ ):
755
+ """
756
+ Context manager for collaborative sessions with automatic cleanup.
757
+
758
+ Args:
759
+ community_id: ID of the community
760
+ session_type: Type of session
761
+ purpose: Purpose of the session
762
+ leader_agent_id: Optional leader agent ID
763
+ participants: Optional specific participants
764
+
765
+ Yields:
766
+ Session ID
767
+
768
+ Example:
769
+ async with integration.collaborative_session(
770
+ community_id, "brainstorming", "Generate ideas"
771
+ ) as session_id:
772
+ # Session is active
773
+ pass
774
+ # Session automatically ended
775
+ """
776
+ session_id = await self.initiate_community_collaboration(
777
+ community_id=community_id,
778
+ collaboration_type=session_type,
779
+ purpose=purpose,
780
+ leader_agent_id=leader_agent_id,
781
+ specific_participants=participants
782
+ )
783
+
784
+ try:
785
+ yield session_id
786
+ finally:
787
+ # End session
788
+ try:
789
+ summary = await self.workflow_engine.end_session(session_id)
790
+ logger.info(f"Context manager ended session {session_id}")
791
+ except Exception as e:
792
+ logger.error(f"Error ending session in context manager: {e}")