praisonAI 2.3.43__tar.gz → 2.3.44__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.
- {praisonai-2.3.43 → praisonai-2.3.44}/PKG-INFO +1 -1
- {praisonai-2.3.43 → praisonai-2.3.44}/PraisonAI.egg-info/PKG-INFO +1 -1
- {praisonai-2.3.43 → praisonai-2.3.44}/PraisonAI.egg-info/SOURCES.txt +6 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/__init__.py +5 -0
- praisonai-2.3.44/praisonai/cli/features/external_agents.py +231 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/deploy.py +1 -1
- praisonai-2.3.44/praisonai/integrations/base.py +300 -0
- praisonai-2.3.44/praisonai/integrations/claude_code.py +270 -0
- praisonai-2.3.44/praisonai/integrations/codex_cli.py +252 -0
- praisonai-2.3.44/praisonai/integrations/cursor_cli.py +192 -0
- praisonai-2.3.44/praisonai/integrations/gemini_cli.py +222 -0
- praisonai-2.3.44/praisonai/version.py +1 -0
- praisonai-2.3.43/praisonai/version.py +0 -1
- {praisonai-2.3.43 → praisonai-2.3.44}/PraisonAI.egg-info/dependency_links.txt +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/PraisonAI.egg-info/entry_points.txt +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/PraisonAI.egg-info/requires.txt +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/PraisonAI.egg-info/top_level.txt +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/README.md +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/__init__.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/__main__.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/agents_generator.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/api/call.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/auto.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/chainlit_ui.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/__init__.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/auto_memory.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/base.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/fast_context.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/flow_display.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/guardrail.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/handoff.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/image.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/knowledge.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/mcp.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/metrics.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/n8n.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/router.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/session.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/telemetry.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/todo.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/tools.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/features/workflow.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/cli/main.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/code/__init__.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/code/agent_tools.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/code/diff/__init__.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/code/diff/diff_strategy.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/code/tools/__init__.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/code/tools/apply_diff.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/code/tools/execute_command.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/code/tools/list_files.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/code/tools/read_file.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/code/tools/search_replace.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/code/tools/write_file.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/code/utils/__init__.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/code/utils/file_utils.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/code/utils/ignore_utils.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/code/utils/text_utils.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/inbuilt_tools/__init__.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/inbuilt_tools/autogen_tools.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/inc/__init__.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/inc/config.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/inc/models.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/integrations/__init__.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/scheduler.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/setup/__init__.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/setup/build.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/setup/post_install.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/setup/setup_conda_env.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/setup.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/test.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/train.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/train_vision.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/ui/agents.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/ui/callbacks.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/ui/chat.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/ui/code.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/ui/colab.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/ui/colab_chainlit.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/ui/components/aicoder.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/ui/context.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/ui/database_config.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/ui/db.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/ui/realtime.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/ui/realtimeclient/__init__.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/ui/realtimeclient/tools.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/ui/sql_alchemy.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/praisonai/upload_vision.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/pyproject.toml +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/setup.cfg +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/tests/test.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/tests/test_agents_playbook.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/tests/test_basic.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/tests/test_cli_features.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/tests/test_custom_tools_fix.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/tests/test_double_api_fix.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/tests/test_n8n_integration.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/tests/test_phase2_refactor.py +0 -0
- {praisonai-2.3.43 → praisonai-2.3.44}/tests/test_runner.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PraisonAI
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.44
|
|
4
4
|
Summary: PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human-agent collaboration.
|
|
5
5
|
Author: Mervin Praison
|
|
6
6
|
License: MIT
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PraisonAI
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.44
|
|
4
4
|
Summary: PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human-agent collaboration.
|
|
5
5
|
Author: Mervin Praison
|
|
6
6
|
License: MIT
|
|
@@ -25,6 +25,7 @@ praisonai/cli/main.py
|
|
|
25
25
|
praisonai/cli/features/__init__.py
|
|
26
26
|
praisonai/cli/features/auto_memory.py
|
|
27
27
|
praisonai/cli/features/base.py
|
|
28
|
+
praisonai/cli/features/external_agents.py
|
|
28
29
|
praisonai/cli/features/fast_context.py
|
|
29
30
|
praisonai/cli/features/flow_display.py
|
|
30
31
|
praisonai/cli/features/guardrail.py
|
|
@@ -61,6 +62,11 @@ praisonai/inc/__init__.py
|
|
|
61
62
|
praisonai/inc/config.py
|
|
62
63
|
praisonai/inc/models.py
|
|
63
64
|
praisonai/integrations/__init__.py
|
|
65
|
+
praisonai/integrations/base.py
|
|
66
|
+
praisonai/integrations/claude_code.py
|
|
67
|
+
praisonai/integrations/codex_cli.py
|
|
68
|
+
praisonai/integrations/cursor_cli.py
|
|
69
|
+
praisonai/integrations/gemini_cli.py
|
|
64
70
|
praisonai/setup/__init__.py
|
|
65
71
|
praisonai/setup/build.py
|
|
66
72
|
praisonai/setup/post_install.py
|
|
@@ -21,6 +21,7 @@ Features:
|
|
|
21
21
|
- flow_display: Visual workflow tracking
|
|
22
22
|
- workflow: YAML workflow management
|
|
23
23
|
- n8n: Export workflows to n8n visual editor
|
|
24
|
+
- external_agents: External AI CLI tool integrations (Claude, Gemini, Codex, Cursor)
|
|
24
25
|
"""
|
|
25
26
|
|
|
26
27
|
# Type hints available for IDE support
|
|
@@ -43,6 +44,7 @@ __all__ = [
|
|
|
43
44
|
'FlowDisplayHandler',
|
|
44
45
|
'WorkflowHandler',
|
|
45
46
|
'N8nHandler',
|
|
47
|
+
'ExternalAgentsHandler',
|
|
46
48
|
]
|
|
47
49
|
|
|
48
50
|
def __getattr__(name):
|
|
@@ -95,4 +97,7 @@ def __getattr__(name):
|
|
|
95
97
|
elif name == 'N8nHandler':
|
|
96
98
|
from .n8n import N8nHandler
|
|
97
99
|
return N8nHandler
|
|
100
|
+
elif name == 'ExternalAgentsHandler':
|
|
101
|
+
from .external_agents import ExternalAgentsHandler
|
|
102
|
+
return ExternalAgentsHandler
|
|
98
103
|
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"""
|
|
2
|
+
External Agents Handler for CLI.
|
|
3
|
+
|
|
4
|
+
Provides integration with external AI coding CLI tools:
|
|
5
|
+
- Claude Code CLI
|
|
6
|
+
- Gemini CLI
|
|
7
|
+
- OpenAI Codex CLI
|
|
8
|
+
- Cursor CLI
|
|
9
|
+
|
|
10
|
+
Usage:
|
|
11
|
+
praisonai "Refactor the code" --external-agent claude
|
|
12
|
+
praisonai "Analyze codebase" --external-agent gemini
|
|
13
|
+
praisonai "Fix bugs" --external-agent codex
|
|
14
|
+
praisonai "Add tests" --external-agent cursor
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from typing import Dict, Any, List, Optional, Tuple
|
|
18
|
+
|
|
19
|
+
from .base import FlagHandler
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ExternalAgentsHandler(FlagHandler):
|
|
23
|
+
"""
|
|
24
|
+
Handler for --external-agent flag.
|
|
25
|
+
|
|
26
|
+
Integrates external AI coding CLI tools as agent tools.
|
|
27
|
+
|
|
28
|
+
Example:
|
|
29
|
+
praisonai "Refactor the auth module" --external-agent claude
|
|
30
|
+
praisonai "Analyze this codebase" --external-agent gemini
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
# Mapping of integration names to their module paths
|
|
34
|
+
INTEGRATIONS = {
|
|
35
|
+
"claude": "claude_code.ClaudeCodeIntegration",
|
|
36
|
+
"gemini": "gemini_cli.GeminiCLIIntegration",
|
|
37
|
+
"codex": "codex_cli.CodexCLIIntegration",
|
|
38
|
+
"cursor": "cursor_cli.CursorCLIIntegration",
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
def __init__(self, verbose: bool = False):
|
|
42
|
+
"""Initialize the handler."""
|
|
43
|
+
super().__init__(verbose)
|
|
44
|
+
self._integration_cache: Dict[str, Any] = {}
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def feature_name(self) -> str:
|
|
48
|
+
"""Return the feature name."""
|
|
49
|
+
return "external_agents"
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def flag_name(self) -> str:
|
|
53
|
+
"""Return the flag name."""
|
|
54
|
+
return "external-agent"
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def flag_help(self) -> str:
|
|
58
|
+
"""Return the flag help text."""
|
|
59
|
+
return "External AI CLI tool to use (claude, gemini, codex, cursor)"
|
|
60
|
+
|
|
61
|
+
def check_dependencies(self) -> Tuple[bool, str]:
|
|
62
|
+
"""Check if integrations module is available."""
|
|
63
|
+
try:
|
|
64
|
+
import importlib.util
|
|
65
|
+
if importlib.util.find_spec("praisonai.integrations") is not None:
|
|
66
|
+
return True, ""
|
|
67
|
+
return False, "Integrations module not available"
|
|
68
|
+
except ImportError:
|
|
69
|
+
return False, "Integrations module not available"
|
|
70
|
+
|
|
71
|
+
def get_integration(self, name: str, **options):
|
|
72
|
+
"""
|
|
73
|
+
Get an integration instance by name.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
name: Integration name (claude, gemini, codex, cursor)
|
|
77
|
+
**options: Options to pass to the integration
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
Integration instance
|
|
81
|
+
|
|
82
|
+
Raises:
|
|
83
|
+
ValueError: If integration name is invalid
|
|
84
|
+
"""
|
|
85
|
+
if name not in self.INTEGRATIONS:
|
|
86
|
+
raise ValueError(f"Unknown integration: {name}. Available: {list(self.INTEGRATIONS.keys())}")
|
|
87
|
+
|
|
88
|
+
# Check cache first
|
|
89
|
+
cache_key = f"{name}_{hash(frozenset(options.items()))}"
|
|
90
|
+
if cache_key in self._integration_cache:
|
|
91
|
+
return self._integration_cache[cache_key]
|
|
92
|
+
|
|
93
|
+
# Lazy import the integration
|
|
94
|
+
module_path = self.INTEGRATIONS[name]
|
|
95
|
+
module_name, class_name = module_path.rsplit(".", 1)
|
|
96
|
+
|
|
97
|
+
import importlib
|
|
98
|
+
module = importlib.import_module(f"praisonai.integrations.{module_name}")
|
|
99
|
+
integration_class = getattr(module, class_name)
|
|
100
|
+
|
|
101
|
+
# Create instance with options
|
|
102
|
+
integration = integration_class(**options)
|
|
103
|
+
|
|
104
|
+
# Cache it
|
|
105
|
+
self._integration_cache[cache_key] = integration
|
|
106
|
+
|
|
107
|
+
return integration
|
|
108
|
+
|
|
109
|
+
def list_integrations(self) -> List[str]:
|
|
110
|
+
"""
|
|
111
|
+
List all available integration names.
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
List of integration names
|
|
115
|
+
"""
|
|
116
|
+
return list(self.INTEGRATIONS.keys())
|
|
117
|
+
|
|
118
|
+
def check_availability(self) -> Dict[str, bool]:
|
|
119
|
+
"""
|
|
120
|
+
Check availability of all integrations.
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
Dict mapping integration name to availability
|
|
124
|
+
"""
|
|
125
|
+
availability = {}
|
|
126
|
+
for name in self.INTEGRATIONS:
|
|
127
|
+
try:
|
|
128
|
+
integration = self.get_integration(name)
|
|
129
|
+
availability[name] = integration.is_available
|
|
130
|
+
except Exception:
|
|
131
|
+
availability[name] = False
|
|
132
|
+
return availability
|
|
133
|
+
|
|
134
|
+
def apply_to_agent_config(self, config: Dict[str, Any], flag_value: Any) -> Dict[str, Any]:
|
|
135
|
+
"""
|
|
136
|
+
Apply external agent configuration to agent config.
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
config: Agent configuration dictionary
|
|
140
|
+
flag_value: Integration name or dict with name and options
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
Modified configuration with external agent tool
|
|
144
|
+
"""
|
|
145
|
+
if not flag_value:
|
|
146
|
+
return config
|
|
147
|
+
|
|
148
|
+
# Handle both string and dict formats
|
|
149
|
+
if isinstance(flag_value, str):
|
|
150
|
+
name = flag_value
|
|
151
|
+
options = {}
|
|
152
|
+
elif isinstance(flag_value, dict):
|
|
153
|
+
name = flag_value.get("name", "")
|
|
154
|
+
options = {k: v for k, v in flag_value.items() if k != "name"}
|
|
155
|
+
else:
|
|
156
|
+
return config
|
|
157
|
+
|
|
158
|
+
try:
|
|
159
|
+
integration = self.get_integration(name, **options)
|
|
160
|
+
|
|
161
|
+
if integration.is_available:
|
|
162
|
+
# Add tool to existing tools
|
|
163
|
+
existing_tools = config.get("tools", [])
|
|
164
|
+
if isinstance(existing_tools, list):
|
|
165
|
+
existing_tools.append(integration.as_tool())
|
|
166
|
+
else:
|
|
167
|
+
existing_tools = [integration.as_tool()]
|
|
168
|
+
config["tools"] = existing_tools
|
|
169
|
+
|
|
170
|
+
self.print_status(f"🔌 External agent connected: {name}", "success")
|
|
171
|
+
else:
|
|
172
|
+
self.print_status(f"⚠️ External agent not available: {name}", "warning")
|
|
173
|
+
|
|
174
|
+
except ValueError as e:
|
|
175
|
+
self.print_status(str(e), "error")
|
|
176
|
+
except Exception as e:
|
|
177
|
+
self.print_status(f"Failed to connect external agent: {e}", "error")
|
|
178
|
+
|
|
179
|
+
return config
|
|
180
|
+
|
|
181
|
+
def execute(
|
|
182
|
+
self,
|
|
183
|
+
integration_name: str = None,
|
|
184
|
+
**options
|
|
185
|
+
) -> Optional[Any]:
|
|
186
|
+
"""
|
|
187
|
+
Execute external agent setup.
|
|
188
|
+
|
|
189
|
+
Args:
|
|
190
|
+
integration_name: Name of the integration
|
|
191
|
+
**options: Options for the integration
|
|
192
|
+
|
|
193
|
+
Returns:
|
|
194
|
+
Integration instance or None
|
|
195
|
+
"""
|
|
196
|
+
if not integration_name:
|
|
197
|
+
# List available integrations
|
|
198
|
+
self.print_status("\n🔧 Available External Agents:", "info")
|
|
199
|
+
self.print_status("-" * 40, "info")
|
|
200
|
+
|
|
201
|
+
availability = self.check_availability()
|
|
202
|
+
for name, available in availability.items():
|
|
203
|
+
status = "✅ Available" if available else "❌ Not installed"
|
|
204
|
+
self.print_status(f" {name}: {status}", "info")
|
|
205
|
+
|
|
206
|
+
return None
|
|
207
|
+
|
|
208
|
+
try:
|
|
209
|
+
integration = self.get_integration(integration_name, **options)
|
|
210
|
+
|
|
211
|
+
if integration.is_available:
|
|
212
|
+
self.print_status(f"🔌 External agent ready: {integration_name}", "success")
|
|
213
|
+
return integration
|
|
214
|
+
else:
|
|
215
|
+
self.print_status(f"⚠️ External agent not installed: {integration_name}", "warning")
|
|
216
|
+
self.print_status(f" Install with: {self._get_install_instructions(integration_name)}", "info")
|
|
217
|
+
return None
|
|
218
|
+
|
|
219
|
+
except ValueError as e:
|
|
220
|
+
self.print_status(str(e), "error")
|
|
221
|
+
return None
|
|
222
|
+
|
|
223
|
+
def _get_install_instructions(self, name: str) -> str:
|
|
224
|
+
"""Get installation instructions for an integration."""
|
|
225
|
+
instructions = {
|
|
226
|
+
"claude": "npm install -g @anthropic-ai/claude-code",
|
|
227
|
+
"gemini": "npm install -g @anthropic-ai/gemini-cli",
|
|
228
|
+
"codex": "npm install -g @openai/codex",
|
|
229
|
+
"cursor": "Download from cursor.com",
|
|
230
|
+
}
|
|
231
|
+
return instructions.get(name, "See documentation")
|
|
@@ -57,7 +57,7 @@ class CloudDeployer:
|
|
|
57
57
|
file.write("FROM python:3.11-slim\n")
|
|
58
58
|
file.write("WORKDIR /app\n")
|
|
59
59
|
file.write("COPY . .\n")
|
|
60
|
-
file.write("RUN pip install flask praisonai==2.3.
|
|
60
|
+
file.write("RUN pip install flask praisonai==2.3.44 gunicorn markdown\n")
|
|
61
61
|
file.write("EXPOSE 8080\n")
|
|
62
62
|
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
|
|
63
63
|
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Base class for external CLI tool integrations.
|
|
3
|
+
|
|
4
|
+
Provides a consistent interface for integrating with AI coding CLI tools
|
|
5
|
+
like Claude Code, Gemini CLI, Codex CLI, and Cursor CLI.
|
|
6
|
+
|
|
7
|
+
Features:
|
|
8
|
+
- Lazy availability checking with caching
|
|
9
|
+
- Async subprocess execution
|
|
10
|
+
- Tool wrapper for agent integration
|
|
11
|
+
- Timeout handling
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from abc import ABC, abstractmethod
|
|
15
|
+
from typing import AsyncIterator, Optional, Dict, Any, Tuple, List
|
|
16
|
+
import asyncio
|
|
17
|
+
import shutil
|
|
18
|
+
import os
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class BaseCLIIntegration(ABC):
|
|
22
|
+
"""
|
|
23
|
+
Abstract base class for external CLI tool integrations.
|
|
24
|
+
|
|
25
|
+
Provides:
|
|
26
|
+
- Lazy availability checking with class-level caching
|
|
27
|
+
- Async subprocess execution with timeout handling
|
|
28
|
+
- Tool wrapper for PraisonAI agent integration
|
|
29
|
+
|
|
30
|
+
Subclasses must implement:
|
|
31
|
+
- cli_command property: The CLI command name
|
|
32
|
+
- execute method: Execute the CLI and return result
|
|
33
|
+
- stream method: Stream output from the CLI
|
|
34
|
+
|
|
35
|
+
Example:
|
|
36
|
+
class MyIntegration(BaseCLIIntegration):
|
|
37
|
+
@property
|
|
38
|
+
def cli_command(self) -> str:
|
|
39
|
+
return "my-cli"
|
|
40
|
+
|
|
41
|
+
async def execute(self, prompt: str, **options) -> str:
|
|
42
|
+
return await self.execute_async(["my-cli", "-p", prompt])
|
|
43
|
+
|
|
44
|
+
async def stream(self, prompt: str, **options):
|
|
45
|
+
async for line in self.stream_async(["my-cli", "-p", prompt]):
|
|
46
|
+
yield line
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
# Class-level cache for availability checks (shared across instances)
|
|
50
|
+
_availability_cache: Dict[str, bool] = {}
|
|
51
|
+
|
|
52
|
+
def __init__(self, workspace: str = ".", timeout: int = 300):
|
|
53
|
+
"""
|
|
54
|
+
Initialize the CLI integration.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
workspace: Working directory for CLI execution (default: current dir)
|
|
58
|
+
timeout: Default timeout in seconds for CLI execution (default: 300)
|
|
59
|
+
"""
|
|
60
|
+
self.workspace = workspace
|
|
61
|
+
self.timeout = timeout
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
@abstractmethod
|
|
65
|
+
def cli_command(self) -> str:
|
|
66
|
+
"""
|
|
67
|
+
Return the CLI command name.
|
|
68
|
+
|
|
69
|
+
This is used for availability checking and tool naming.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
str: The CLI command (e.g., "claude", "gemini", "codex", "cursor-agent")
|
|
73
|
+
"""
|
|
74
|
+
pass
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def is_available(self) -> bool:
|
|
78
|
+
"""
|
|
79
|
+
Check if the CLI tool is installed and available.
|
|
80
|
+
|
|
81
|
+
Uses class-level caching to avoid repeated filesystem checks.
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
bool: True if the CLI is available, False otherwise
|
|
85
|
+
"""
|
|
86
|
+
if self.cli_command not in self._availability_cache:
|
|
87
|
+
self._availability_cache[self.cli_command] = shutil.which(self.cli_command) is not None
|
|
88
|
+
return self._availability_cache[self.cli_command]
|
|
89
|
+
|
|
90
|
+
@abstractmethod
|
|
91
|
+
async def execute(self, prompt: str, **options) -> str:
|
|
92
|
+
"""
|
|
93
|
+
Execute the CLI tool and return the result.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
prompt: The prompt/query to send to the CLI
|
|
97
|
+
**options: Additional options for the CLI
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
str: The CLI output
|
|
101
|
+
"""
|
|
102
|
+
pass
|
|
103
|
+
|
|
104
|
+
@abstractmethod
|
|
105
|
+
async def stream(self, prompt: str, **options) -> AsyncIterator[Dict[str, Any]]:
|
|
106
|
+
"""
|
|
107
|
+
Stream output from the CLI tool.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
prompt: The prompt/query to send to the CLI
|
|
111
|
+
**options: Additional options for the CLI
|
|
112
|
+
|
|
113
|
+
Yields:
|
|
114
|
+
dict: Parsed output events from the CLI
|
|
115
|
+
"""
|
|
116
|
+
pass
|
|
117
|
+
|
|
118
|
+
async def execute_async(self, cmd: List[str], timeout: Optional[int] = None) -> str:
|
|
119
|
+
"""
|
|
120
|
+
Execute a command asynchronously and return stdout.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
cmd: Command and arguments as a list
|
|
124
|
+
timeout: Timeout in seconds (uses self.timeout if not specified)
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
str: The command's stdout
|
|
128
|
+
|
|
129
|
+
Raises:
|
|
130
|
+
TimeoutError: If the command times out
|
|
131
|
+
"""
|
|
132
|
+
timeout = timeout or self.timeout
|
|
133
|
+
|
|
134
|
+
proc = await asyncio.create_subprocess_exec(
|
|
135
|
+
*cmd,
|
|
136
|
+
stdout=asyncio.subprocess.PIPE,
|
|
137
|
+
stderr=asyncio.subprocess.PIPE,
|
|
138
|
+
cwd=self.workspace
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
try:
|
|
142
|
+
stdout, stderr = await asyncio.wait_for(
|
|
143
|
+
proc.communicate(),
|
|
144
|
+
timeout=timeout
|
|
145
|
+
)
|
|
146
|
+
return stdout.decode()
|
|
147
|
+
except asyncio.TimeoutError:
|
|
148
|
+
proc.kill()
|
|
149
|
+
await proc.wait()
|
|
150
|
+
raise TimeoutError(f"Command timed out after {timeout}s: {' '.join(cmd)}")
|
|
151
|
+
|
|
152
|
+
async def execute_async_with_stderr(
|
|
153
|
+
self,
|
|
154
|
+
cmd: List[str],
|
|
155
|
+
timeout: Optional[int] = None
|
|
156
|
+
) -> Tuple[str, str]:
|
|
157
|
+
"""
|
|
158
|
+
Execute a command asynchronously and return both stdout and stderr.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
cmd: Command and arguments as a list
|
|
162
|
+
timeout: Timeout in seconds (uses self.timeout if not specified)
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
Tuple[str, str]: (stdout, stderr)
|
|
166
|
+
|
|
167
|
+
Raises:
|
|
168
|
+
TimeoutError: If the command times out
|
|
169
|
+
"""
|
|
170
|
+
timeout = timeout or self.timeout
|
|
171
|
+
|
|
172
|
+
proc = await asyncio.create_subprocess_exec(
|
|
173
|
+
*cmd,
|
|
174
|
+
stdout=asyncio.subprocess.PIPE,
|
|
175
|
+
stderr=asyncio.subprocess.PIPE,
|
|
176
|
+
cwd=self.workspace
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
try:
|
|
180
|
+
stdout, stderr = await asyncio.wait_for(
|
|
181
|
+
proc.communicate(),
|
|
182
|
+
timeout=timeout
|
|
183
|
+
)
|
|
184
|
+
return stdout.decode(), stderr.decode()
|
|
185
|
+
except asyncio.TimeoutError:
|
|
186
|
+
proc.kill()
|
|
187
|
+
await proc.wait()
|
|
188
|
+
raise TimeoutError(f"Command timed out after {timeout}s: {' '.join(cmd)}")
|
|
189
|
+
|
|
190
|
+
async def stream_async(
|
|
191
|
+
self,
|
|
192
|
+
cmd: List[str],
|
|
193
|
+
timeout: Optional[int] = None
|
|
194
|
+
) -> AsyncIterator[str]:
|
|
195
|
+
"""
|
|
196
|
+
Stream stdout lines from a command asynchronously.
|
|
197
|
+
|
|
198
|
+
Args:
|
|
199
|
+
cmd: Command and arguments as a list
|
|
200
|
+
timeout: Timeout in seconds for the entire operation
|
|
201
|
+
|
|
202
|
+
Yields:
|
|
203
|
+
str: Each line of output
|
|
204
|
+
"""
|
|
205
|
+
timeout = timeout or self.timeout
|
|
206
|
+
|
|
207
|
+
proc = await asyncio.create_subprocess_exec(
|
|
208
|
+
*cmd,
|
|
209
|
+
stdout=asyncio.subprocess.PIPE,
|
|
210
|
+
stderr=asyncio.subprocess.PIPE,
|
|
211
|
+
cwd=self.workspace
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
try:
|
|
215
|
+
async def read_lines():
|
|
216
|
+
while True:
|
|
217
|
+
line = await proc.stdout.readline()
|
|
218
|
+
if not line:
|
|
219
|
+
break
|
|
220
|
+
yield line.decode().rstrip('\n')
|
|
221
|
+
|
|
222
|
+
async for line in read_lines():
|
|
223
|
+
yield line
|
|
224
|
+
|
|
225
|
+
except asyncio.TimeoutError:
|
|
226
|
+
proc.kill()
|
|
227
|
+
await proc.wait()
|
|
228
|
+
raise TimeoutError(f"Stream timed out after {timeout}s")
|
|
229
|
+
finally:
|
|
230
|
+
if proc.returncode is None:
|
|
231
|
+
proc.kill()
|
|
232
|
+
await proc.wait()
|
|
233
|
+
|
|
234
|
+
def as_tool(self) -> callable:
|
|
235
|
+
"""
|
|
236
|
+
Return a callable suitable for use as a PraisonAI agent tool.
|
|
237
|
+
|
|
238
|
+
The returned function is synchronous and wraps the async execute method.
|
|
239
|
+
Uses asyncio.run() for proper event loop handling (Python 3.7+).
|
|
240
|
+
|
|
241
|
+
Returns:
|
|
242
|
+
callable: A function that can be used as an agent tool
|
|
243
|
+
"""
|
|
244
|
+
# Capture self for closure
|
|
245
|
+
integration = self
|
|
246
|
+
|
|
247
|
+
def tool_func(query: str) -> str:
|
|
248
|
+
"""Execute the CLI tool with the given query."""
|
|
249
|
+
# Use asyncio.run() for clean event loop management
|
|
250
|
+
# This creates a new event loop, runs the coroutine, and closes it
|
|
251
|
+
try:
|
|
252
|
+
# Check if we're already in an async context
|
|
253
|
+
asyncio.get_running_loop()
|
|
254
|
+
# If we're in an async context, use ThreadPoolExecutor to avoid nested loop
|
|
255
|
+
import concurrent.futures
|
|
256
|
+
with concurrent.futures.ThreadPoolExecutor() as executor:
|
|
257
|
+
future = executor.submit(asyncio.run, integration.execute(query))
|
|
258
|
+
return future.result()
|
|
259
|
+
except RuntimeError:
|
|
260
|
+
# No running loop, safe to use asyncio.run()
|
|
261
|
+
return asyncio.run(integration.execute(query))
|
|
262
|
+
|
|
263
|
+
# Set function metadata for agent tool registration
|
|
264
|
+
tool_func.__name__ = f"{self.cli_command}_tool"
|
|
265
|
+
tool_func.__doc__ = f"Execute {self.cli_command} for coding tasks."
|
|
266
|
+
|
|
267
|
+
return tool_func
|
|
268
|
+
|
|
269
|
+
def get_env(self) -> Dict[str, str]:
|
|
270
|
+
"""
|
|
271
|
+
Get environment variables for CLI execution.
|
|
272
|
+
|
|
273
|
+
Subclasses can override this to add tool-specific environment variables.
|
|
274
|
+
|
|
275
|
+
Returns:
|
|
276
|
+
dict: Environment variables to pass to the CLI
|
|
277
|
+
"""
|
|
278
|
+
return dict(os.environ)
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def get_available_integrations() -> Dict[str, bool]:
|
|
282
|
+
"""
|
|
283
|
+
Get a dictionary of all integrations and their availability status.
|
|
284
|
+
|
|
285
|
+
Returns:
|
|
286
|
+
dict: Mapping of integration name to availability (True/False)
|
|
287
|
+
"""
|
|
288
|
+
from .claude_code import ClaudeCodeIntegration
|
|
289
|
+
from .gemini_cli import GeminiCLIIntegration
|
|
290
|
+
from .codex_cli import CodexCLIIntegration
|
|
291
|
+
from .cursor_cli import CursorCLIIntegration
|
|
292
|
+
|
|
293
|
+
integrations = {
|
|
294
|
+
'claude': ClaudeCodeIntegration(),
|
|
295
|
+
'gemini': GeminiCLIIntegration(),
|
|
296
|
+
'codex': CodexCLIIntegration(),
|
|
297
|
+
'cursor': CursorCLIIntegration(),
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return {name: integration.is_available for name, integration in integrations.items()}
|