janito 2.33.0__py3-none-any.whl → 3.1.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.
- janito/cli/chat_mode/bindings.py +26 -0
- janito/cli/chat_mode/session.py +7 -1
- janito/cli/cli_commands/check_tools.py +212 -0
- janito/cli/cli_commands/list_plugins.py +52 -43
- janito/cli/core/getters.py +3 -0
- janito/cli/main_cli.py +9 -12
- janito/cli/prompt_core.py +19 -9
- janito/drivers/openai/driver.py +1 -0
- janito/drivers/zai/driver.py +1 -0
- janito/llm/agent.py +30 -17
- janito/llm/auth_utils.py +14 -5
- janito/llm/cancellation_manager.py +62 -0
- janito/llm/driver.py +7 -0
- janito/llm/enter_cancellation.py +93 -0
- janito/plugin_system/__init__.py +10 -0
- janito/{plugins → plugin_system}/base.py +5 -2
- janito/{plugins/core_loader_fixed.py → plugin_system/core_loader.py} +45 -26
- janito/plugin_system/core_loader_fixed.py +149 -0
- janito/plugins/__init__.py +31 -12
- janito/plugins/auto_loader_fixed.py +12 -11
- janito/plugins/builtin.py +15 -1
- janito/plugins/core/__init__.py +7 -0
- janito/plugins/core/codeanalyzer/__init__.py +43 -0
- janito/plugins/core/filemanager/__init__.py +124 -0
- janito/plugins/core/filemanager/tools/create_file.py +87 -0
- janito/plugins/core/filemanager/tools/replace_text_in_file.py +270 -0
- janito/plugins/core/imagedisplay/__init__.py +14 -0
- janito/plugins/core/imagedisplay/plugin.py +51 -0
- janito/plugins/core/imagedisplay/tools/__init__.py +1 -0
- janito/plugins/core/imagedisplay/tools/show_image.py +83 -0
- janito/{tools/adapters/local → plugins/core/imagedisplay/tools}/show_image_grid.py +13 -5
- janito/plugins/core/system/__init__.py +23 -0
- janito/plugins/core_adapter.py +11 -9
- janito/plugins/dev/__init__.py +7 -0
- janito/plugins/dev/pythondev/__init__.py +37 -0
- janito/plugins/dev/visualization/__init__.py +23 -0
- janito/plugins/discovery.py +5 -5
- janito/plugins/example_plugin.py +108 -0
- janito/plugins/manager.py +1 -1
- janito/plugins/tools/__init__.py +10 -0
- janito/{tools/adapters/local → plugins/tools}/ask_user.py +3 -3
- janito/plugins/tools/copy_file.py +87 -0
- janito/plugins/tools/core_tools_plugin.py +88 -0
- janito/plugins/tools/create_directory.py +70 -0
- janito/{tools/adapters/local → plugins/tools}/create_file.py +4 -4
- janito/plugins/tools/decorators.py +19 -0
- janito/plugins/tools/delete_text_in_file.py +134 -0
- janito/{tools/adapters/local → plugins/tools}/fetch_url.py +3 -3
- janito/plugins/tools/find_files.py +143 -0
- janito/plugins/tools/get_file_outline/__init__.py +7 -0
- janito/plugins/tools/get_file_outline/core.py +122 -0
- janito/plugins/tools/get_file_outline/java_outline.py +47 -0
- janito/plugins/tools/get_file_outline/markdown_outline.py +14 -0
- janito/plugins/tools/get_file_outline/python_outline.py +303 -0
- janito/plugins/tools/get_file_outline/search_outline.py +36 -0
- janito/plugins/tools/move_file.py +131 -0
- janito/plugins/tools/open_html_in_browser.py +51 -0
- janito/plugins/tools/open_url.py +37 -0
- janito/plugins/tools/python_code_run.py +172 -0
- janito/plugins/tools/python_command_run.py +171 -0
- janito/plugins/tools/python_file_run.py +172 -0
- janito/plugins/tools/read_chart.py +259 -0
- janito/plugins/tools/read_files.py +58 -0
- janito/plugins/tools/remove_directory.py +55 -0
- janito/plugins/tools/remove_file.py +58 -0
- janito/{tools/adapters/local → plugins/tools}/replace_text_in_file.py +4 -4
- janito/plugins/tools/run_bash_command.py +183 -0
- janito/plugins/tools/run_powershell_command.py +218 -0
- janito/plugins/tools/search_text/__init__.py +7 -0
- janito/plugins/tools/search_text/core.py +205 -0
- janito/plugins/tools/search_text/match_lines.py +67 -0
- janito/plugins/tools/search_text/pattern_utils.py +73 -0
- janito/plugins/tools/search_text/traverse_directory.py +145 -0
- janito/{tools/adapters/local → plugins/tools}/show_image.py +15 -6
- janito/plugins/tools/show_image_grid.py +85 -0
- janito/plugins/tools/validate_file_syntax/__init__.py +7 -0
- janito/plugins/tools/validate_file_syntax/core.py +114 -0
- janito/plugins/tools/validate_file_syntax/css_validator.py +35 -0
- janito/plugins/tools/validate_file_syntax/html_validator.py +100 -0
- janito/plugins/tools/validate_file_syntax/jinja2_validator.py +50 -0
- janito/plugins/tools/validate_file_syntax/js_validator.py +27 -0
- janito/plugins/tools/validate_file_syntax/json_validator.py +6 -0
- janito/plugins/tools/validate_file_syntax/markdown_validator.py +109 -0
- janito/plugins/tools/validate_file_syntax/ps1_validator.py +32 -0
- janito/plugins/tools/validate_file_syntax/python_validator.py +5 -0
- janito/plugins/tools/validate_file_syntax/xml_validator.py +11 -0
- janito/plugins/tools/validate_file_syntax/yaml_validator.py +6 -0
- janito/plugins/tools/view_file.py +172 -0
- janito/plugins/ui/__init__.py +7 -0
- janito/plugins/ui/userinterface/__init__.py +16 -0
- janito/plugins/ui/userinterface/tools/ask_user.py +110 -0
- janito/plugins/web/__init__.py +7 -0
- janito/plugins/web/webtools/__init__.py +33 -0
- janito/plugins/web/webtools/tools/fetch_url.py +458 -0
- janito/tools/__init__.py +31 -7
- janito/tools/adapters/__init__.py +6 -1
- janito/tools/adapters/local/__init__.py +7 -70
- janito/tools/cli_initializer.py +88 -0
- janito/tools/function_adapter.py +93 -16
- janito/tools/initialize.py +70 -0
- {janito-2.33.0.dist-info → janito-3.1.0.dist-info}/METADATA +1 -2
- {janito-2.33.0.dist-info → janito-3.1.0.dist-info}/RECORD +146 -76
- janito/plugins/core_loader.py +0 -120
- /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/__init__.py +0 -0
- /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/core.py +0 -0
- /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/java_outline.py +0 -0
- /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/markdown_outline.py +0 -0
- /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/python_outline.py +0 -0
- /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/search_outline.py +0 -0
- /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/search_text/__init__.py +0 -0
- /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/search_text/core.py +0 -0
- /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/search_text/match_lines.py +0 -0
- /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/search_text/pattern_utils.py +0 -0
- /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/search_text/traverse_directory.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/copy_file.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/create_directory.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/delete_text_in_file.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/find_files.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/move_file.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/read_files.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/remove_directory.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/remove_file.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/__init__.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/core.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/css_validator.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/html_validator.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/jinja2_validator.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/js_validator.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/json_validator.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/markdown_validator.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/ps1_validator.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/python_validator.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/xml_validator.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/yaml_validator.py +0 -0
- /janito/{tools/adapters/local → plugins/core/filemanager/tools}/view_file.py +0 -0
- /janito/{tools/adapters/local → plugins/core/system/tools}/run_bash_command.py +0 -0
- /janito/{tools/adapters/local → plugins/core/system/tools}/run_powershell_command.py +0 -0
- /janito/{tools/adapters/local → plugins/dev/pythondev/tools}/python_code_run.py +0 -0
- /janito/{tools/adapters/local → plugins/dev/pythondev/tools}/python_command_run.py +0 -0
- /janito/{tools/adapters/local → plugins/dev/pythondev/tools}/python_file_run.py +0 -0
- /janito/{tools/adapters/local → plugins/dev/visualization/tools}/read_chart.py +0 -0
- /janito/{tools/adapters/local → plugins/web/webtools/tools}/open_html_in_browser.py +0 -0
- /janito/{tools/adapters/local → plugins/web/webtools/tools}/open_url.py +0 -0
- {janito-2.33.0.dist-info → janito-3.1.0.dist-info}/WHEEL +0 -0
- {janito-2.33.0.dist-info → janito-3.1.0.dist-info}/entry_points.txt +0 -0
- {janito-2.33.0.dist-info → janito-3.1.0.dist-info}/licenses/LICENSE +0 -0
- {janito-2.33.0.dist-info → janito-3.1.0.dist-info}/top_level.txt +0 -0
janito/cli/chat_mode/bindings.py
CHANGED
@@ -35,4 +35,30 @@ class KeyBindingsFactory:
|
|
35
35
|
buf.text = "Do It"
|
36
36
|
buf.validate_and_handle()
|
37
37
|
|
38
|
+
@bindings.add("enter", eager=True)
|
39
|
+
def _(event):
|
40
|
+
"""Handle Enter key to interrupt current request."""
|
41
|
+
import threading
|
42
|
+
|
43
|
+
# Get the current session context
|
44
|
+
from prompt_toolkit.application import get_app
|
45
|
+
app = get_app()
|
46
|
+
|
47
|
+
# Use global cancellation manager for robust cancellation
|
48
|
+
from janito.llm.cancellation_manager import get_cancellation_manager
|
49
|
+
cancel_manager = get_cancellation_manager()
|
50
|
+
|
51
|
+
cancelled = cancel_manager.cancel_current_request()
|
52
|
+
if cancelled:
|
53
|
+
# Provide user feedback
|
54
|
+
from rich.console import Console
|
55
|
+
console = Console()
|
56
|
+
console.print("[red]Request cancelled by Enter key[/red]")
|
57
|
+
|
58
|
+
# Prevent the Enter key from being processed as input
|
59
|
+
event.app.output.flush()
|
60
|
+
return
|
61
|
+
|
62
|
+
# If no active request to cancel, let normal Enter behavior proceed
|
63
|
+
|
38
64
|
return bindings
|
janito/cli/chat_mode/session.py
CHANGED
@@ -283,7 +283,13 @@ class ChatSession:
|
|
283
283
|
)
|
284
284
|
)
|
285
285
|
|
286
|
-
|
286
|
+
try:
|
287
|
+
self._prompt_handler.run_prompt(cmd_input)
|
288
|
+
finally:
|
289
|
+
# Ensure cancellation manager is cleared
|
290
|
+
cancel_manager = get_cancellation_manager()
|
291
|
+
cancel_manager.clear_current_request()
|
292
|
+
|
287
293
|
end_time = time.time()
|
288
294
|
elapsed = end_time - start_time
|
289
295
|
self.msg_count += 1
|
@@ -0,0 +1,212 @@
|
|
1
|
+
"""
|
2
|
+
CLI Command: Check all registered tools for signature validation and availability
|
3
|
+
"""
|
4
|
+
|
5
|
+
import inspect
|
6
|
+
import sys
|
7
|
+
from typing import Dict, List, Tuple, Any
|
8
|
+
|
9
|
+
|
10
|
+
def _validate_tool_signature(tool_instance) -> Tuple[bool, List[str]]:
|
11
|
+
"""Validate the signature of a tool's run method."""
|
12
|
+
errors = []
|
13
|
+
|
14
|
+
if not hasattr(tool_instance, "run"):
|
15
|
+
errors.append("Missing 'run' method")
|
16
|
+
return False, errors
|
17
|
+
|
18
|
+
try:
|
19
|
+
sig = inspect.signature(tool_instance.run)
|
20
|
+
except ValueError as e:
|
21
|
+
errors.append(f"Invalid signature: {e}")
|
22
|
+
return False, errors
|
23
|
+
|
24
|
+
# Basic signature validation - just check if it's callable
|
25
|
+
if not callable(getattr(tool_instance, "run")):
|
26
|
+
errors.append("'run' method is not callable")
|
27
|
+
|
28
|
+
return len(errors) == 0, errors
|
29
|
+
|
30
|
+
|
31
|
+
def _check_tool_availability(tool_instance) -> Tuple[bool, List[str]]:
|
32
|
+
"""Check if a tool is available for use."""
|
33
|
+
errors = []
|
34
|
+
|
35
|
+
# Check if tool has required attributes
|
36
|
+
required_attrs = ["tool_name"]
|
37
|
+
for attr in required_attrs:
|
38
|
+
if not hasattr(tool_instance, attr):
|
39
|
+
errors.append(f"Missing required attribute: {attr}")
|
40
|
+
|
41
|
+
# Check description (optional for now)
|
42
|
+
if not hasattr(tool_instance, "description"):
|
43
|
+
pass # Allow missing description
|
44
|
+
|
45
|
+
# Check permissions
|
46
|
+
if not hasattr(tool_instance, "permissions"):
|
47
|
+
# Function-based tools use permissions from function decorators
|
48
|
+
pass # Allow missing permissions for function-based tools
|
49
|
+
else:
|
50
|
+
perms = tool_instance.permissions
|
51
|
+
if (
|
52
|
+
not hasattr(perms, "read")
|
53
|
+
or not hasattr(perms, "write")
|
54
|
+
or not hasattr(perms, "execute")
|
55
|
+
):
|
56
|
+
errors.append("Invalid permissions structure")
|
57
|
+
|
58
|
+
return len(errors) == 0, errors
|
59
|
+
|
60
|
+
|
61
|
+
def _get_tool_status_summary(
|
62
|
+
tools: List[Any], disabled_tools: List[str]
|
63
|
+
) -> Dict[str, Any]:
|
64
|
+
"""Get a comprehensive status summary for all tools."""
|
65
|
+
summary = {
|
66
|
+
"total": len(tools),
|
67
|
+
"available": 0,
|
68
|
+
"disabled": 0,
|
69
|
+
"invalid": 0,
|
70
|
+
"details": [],
|
71
|
+
}
|
72
|
+
|
73
|
+
for tool in tools:
|
74
|
+
tool_name = getattr(tool, "tool_name", str(tool))
|
75
|
+
|
76
|
+
# Check if disabled
|
77
|
+
is_disabled = tool_name in disabled_tools
|
78
|
+
|
79
|
+
# Validate signature and availability
|
80
|
+
sig_valid, sig_errors = _validate_tool_signature(tool)
|
81
|
+
avail_valid, avail_errors = _check_tool_availability(tool)
|
82
|
+
|
83
|
+
status = {
|
84
|
+
"name": tool_name,
|
85
|
+
"disabled": is_disabled,
|
86
|
+
"signature_valid": sig_valid,
|
87
|
+
"available": avail_valid,
|
88
|
+
"signature_errors": sig_errors,
|
89
|
+
"availability_errors": avail_errors,
|
90
|
+
}
|
91
|
+
|
92
|
+
summary["details"].append(status)
|
93
|
+
|
94
|
+
if is_disabled:
|
95
|
+
summary["disabled"] += 1
|
96
|
+
elif not sig_valid or not avail_valid:
|
97
|
+
summary["invalid"] += 1
|
98
|
+
else:
|
99
|
+
summary["available"] += 1
|
100
|
+
|
101
|
+
return summary
|
102
|
+
|
103
|
+
|
104
|
+
def _print_check_results(console, summary: Dict[str, Any], verbose: bool = False):
|
105
|
+
"""Print the tool check results in a formatted way."""
|
106
|
+
from rich.table import Table
|
107
|
+
from rich.panel import Panel
|
108
|
+
from rich.text import Text
|
109
|
+
|
110
|
+
# Overall summary
|
111
|
+
summary_text = Text()
|
112
|
+
summary_text.append(f"Total tools: {summary['total']}", style="cyan")
|
113
|
+
summary_text.append(" | ")
|
114
|
+
summary_text.append(f"Available: {summary['available']}", style="green")
|
115
|
+
summary_text.append(" | ")
|
116
|
+
summary_text.append(f"Disabled: {summary['disabled']}", style="yellow")
|
117
|
+
summary_text.append(" | ")
|
118
|
+
summary_text.append(f"Invalid: {summary['invalid']}", style="red")
|
119
|
+
|
120
|
+
console.print(Panel(summary_text, title="Tool Check Summary", style="bold"))
|
121
|
+
|
122
|
+
# Always show the table for check-tools
|
123
|
+
table = Table(title="Tool Details", show_header=True, header_style="bold")
|
124
|
+
table.add_column("Tool", style="cyan", no_wrap=True)
|
125
|
+
table.add_column("Status", style="green")
|
126
|
+
table.add_column("Issues", style="red")
|
127
|
+
|
128
|
+
for detail in summary["details"]:
|
129
|
+
name = detail["name"]
|
130
|
+
|
131
|
+
if detail["disabled"]:
|
132
|
+
status = "[yellow]Disabled[/yellow]"
|
133
|
+
issues = "-"
|
134
|
+
elif not detail["available"] or not detail["signature_valid"]:
|
135
|
+
status = "[red]Invalid[/red]"
|
136
|
+
all_issues = detail["signature_errors"] + detail["availability_errors"]
|
137
|
+
issues = "\n".join(all_issues)
|
138
|
+
else:
|
139
|
+
status = "[green]Available[/green]"
|
140
|
+
issues = "-"
|
141
|
+
|
142
|
+
table.add_row(name, status, issues)
|
143
|
+
|
144
|
+
console.print(table)
|
145
|
+
|
146
|
+
|
147
|
+
def handle_check_tools(args=None):
|
148
|
+
"""Handle the --check-tools CLI command."""
|
149
|
+
from janito.tools.adapters.local.adapter import LocalToolsAdapter
|
150
|
+
import janito.tools # Ensure all tools are registered
|
151
|
+
|
152
|
+
# Load disabled tools from config
|
153
|
+
from janito.tools.disabled_tools import DisabledToolsState
|
154
|
+
from janito.config import config
|
155
|
+
|
156
|
+
disabled_str = config.get("disabled_tools", "")
|
157
|
+
if disabled_str:
|
158
|
+
DisabledToolsState.set_disabled_tools(disabled_str)
|
159
|
+
disabled_tools = DisabledToolsState.get_disabled_tools()
|
160
|
+
|
161
|
+
# Initialize tools properly using the same approach as list_tools.py
|
162
|
+
from janito.tools.adapters.local.adapter import LocalToolsAdapter
|
163
|
+
from janito.tools.tool_base import ToolPermissions
|
164
|
+
import janito.tools # Ensure all tools are registered
|
165
|
+
|
166
|
+
read = getattr(args, "read", False) if args else False
|
167
|
+
write = getattr(args, "write", False) if args else False
|
168
|
+
execute = getattr(args, "exec", False) if args else False
|
169
|
+
if not (read or write or execute):
|
170
|
+
read = write = execute = True
|
171
|
+
from janito.tools.permissions import set_global_allowed_permissions
|
172
|
+
|
173
|
+
set_global_allowed_permissions(
|
174
|
+
ToolPermissions(read=read, write=write, execute=execute)
|
175
|
+
)
|
176
|
+
|
177
|
+
# Load disabled tools from config
|
178
|
+
from janito.tools.disabled_tools import DisabledToolsState
|
179
|
+
from janito.config import config
|
180
|
+
|
181
|
+
disabled_str = config.get("disabled_tools", "")
|
182
|
+
if disabled_str:
|
183
|
+
DisabledToolsState.set_disabled_tools(disabled_str)
|
184
|
+
disabled_tools = DisabledToolsState.get_disabled_tools()
|
185
|
+
|
186
|
+
# Initialize tools using the same method as list_tools.py
|
187
|
+
from janito.tools.initialize import initialize_tools
|
188
|
+
|
189
|
+
registry = initialize_tools()
|
190
|
+
|
191
|
+
# Get actual tool instances
|
192
|
+
tool_instances = []
|
193
|
+
for name, tool_info in registry._tools.items():
|
194
|
+
if "instance" in tool_info:
|
195
|
+
tool_instances.append(tool_info["instance"])
|
196
|
+
|
197
|
+
if not tool_instances:
|
198
|
+
print("No tools registered.")
|
199
|
+
return
|
200
|
+
|
201
|
+
from rich.console import Console
|
202
|
+
|
203
|
+
console = Console()
|
204
|
+
|
205
|
+
verbose = getattr(args, "verbose", False) if args else False
|
206
|
+
|
207
|
+
summary = _get_tool_status_summary(tool_instances, disabled_tools)
|
208
|
+
_print_check_results(console, summary, verbose=verbose)
|
209
|
+
|
210
|
+
# Exit with error code if there are invalid tools
|
211
|
+
if summary["invalid"] > 0:
|
212
|
+
sys.exit(1)
|
@@ -8,7 +8,11 @@ from janito.plugins.discovery import list_available_plugins
|
|
8
8
|
import os
|
9
9
|
from janito.plugins.manager import PluginManager
|
10
10
|
from janito.plugins.builtin import BuiltinPluginRegistry
|
11
|
-
from janito.plugins.auto_loader_fixed import
|
11
|
+
from janito.plugins.auto_loader_fixed import (
|
12
|
+
load_core_plugins,
|
13
|
+
get_loaded_core_plugins,
|
14
|
+
is_core_plugin,
|
15
|
+
)
|
12
16
|
from rich.console import Console
|
13
17
|
from rich.table import Table
|
14
18
|
from rich.panel import Panel
|
@@ -51,7 +55,8 @@ def _list_available_plugins():
|
|
51
55
|
console.print(table)
|
52
56
|
|
53
57
|
# Show core plugins
|
54
|
-
from janito.
|
58
|
+
from janito.plugin_system.core_loader_fixed import get_core_plugins
|
59
|
+
|
55
60
|
core_plugins = get_core_plugins()
|
56
61
|
core_table = Table(title="Core Plugins (Enabled by Default)")
|
57
62
|
core_table.add_column("Plugin Name", style="cyan", no_wrap=True)
|
@@ -62,14 +67,16 @@ def _list_available_plugins():
|
|
62
67
|
|
63
68
|
console.print(core_table)
|
64
69
|
else:
|
65
|
-
console.print(
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
console.print(
|
71
|
+
Panel(
|
72
|
+
"No plugins found in search paths\n"
|
73
|
+
f"[dim]Search paths:[/dim]\n"
|
74
|
+
f" • {os.getcwd()}/plugins\n"
|
75
|
+
f" • {os.path.expanduser('~')}/.janito/plugins",
|
76
|
+
title="No Plugins Found",
|
77
|
+
style="yellow",
|
78
|
+
)
|
79
|
+
)
|
73
80
|
|
74
81
|
|
75
82
|
def _print_builtin_plugins(builtin_plugins):
|
@@ -92,7 +99,7 @@ def _print_external_plugins(available, builtin_plugins):
|
|
92
99
|
def _list_plugin_resources():
|
93
100
|
"""List all resources from loaded plugins using rich formatting."""
|
94
101
|
from janito.plugins.auto_loader_fixed import get_plugin_manager
|
95
|
-
|
102
|
+
|
96
103
|
console = Console()
|
97
104
|
manager = get_plugin_manager()
|
98
105
|
all_resources = manager.list_all_resources()
|
@@ -100,11 +107,11 @@ def _list_plugin_resources():
|
|
100
107
|
if all_resources:
|
101
108
|
for plugin_name, resources in all_resources.items():
|
102
109
|
metadata = manager.get_plugin_metadata(plugin_name)
|
103
|
-
version = metadata.version if metadata else
|
104
|
-
|
110
|
+
version = metadata.version if metadata else "unknown"
|
111
|
+
|
105
112
|
# Create panel for each plugin
|
106
113
|
panel_content = []
|
107
|
-
|
114
|
+
|
108
115
|
tools = [r for r in resources if r["type"] == "tool"]
|
109
116
|
commands = [r for r in resources if r["type"] == "command"]
|
110
117
|
configs = [r for r in resources if r["type"] == "config"]
|
@@ -122,19 +129,25 @@ def _list_plugin_resources():
|
|
122
129
|
if configs:
|
123
130
|
panel_content.append("[bold yellow]Configuration:[/bold yellow]")
|
124
131
|
for config in configs:
|
125
|
-
panel_content.append(
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
+
panel_content.append(
|
133
|
+
f" • {config['name']}: {config['description']}"
|
134
|
+
)
|
135
|
+
|
136
|
+
console.print(
|
137
|
+
Panel(
|
138
|
+
"\n".join(panel_content),
|
139
|
+
title=f"{plugin_name} v{version}",
|
140
|
+
style="cyan",
|
141
|
+
)
|
142
|
+
)
|
132
143
|
else:
|
133
|
-
console.print(
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
144
|
+
console.print(
|
145
|
+
Panel(
|
146
|
+
"No plugins are currently loaded.",
|
147
|
+
title="No Plugin Resources",
|
148
|
+
style="yellow",
|
149
|
+
)
|
150
|
+
)
|
138
151
|
|
139
152
|
|
140
153
|
def _print_resources_by_type(resources):
|
@@ -162,7 +175,7 @@ def _print_resources_by_type(resources):
|
|
162
175
|
def _list_loaded_plugins():
|
163
176
|
"""List loaded plugins using rich formatting."""
|
164
177
|
from janito.plugins.auto_loader_fixed import get_plugin_manager
|
165
|
-
|
178
|
+
|
166
179
|
console = Console()
|
167
180
|
manager = get_plugin_manager()
|
168
181
|
loaded = manager.list_plugins()
|
@@ -177,42 +190,38 @@ def _list_loaded_plugins():
|
|
177
190
|
|
178
191
|
core_plugins = []
|
179
192
|
other_plugins = []
|
180
|
-
|
193
|
+
|
181
194
|
for plugin_name in loaded:
|
182
195
|
if is_core_plugin(plugin_name):
|
183
196
|
core_plugins.append(plugin_name)
|
184
197
|
else:
|
185
198
|
other_plugins.append(plugin_name)
|
186
|
-
|
199
|
+
|
187
200
|
# Add core plugins
|
188
201
|
for plugin_name in core_plugins:
|
189
202
|
metadata = manager.get_plugin_metadata(plugin_name)
|
190
203
|
if metadata:
|
191
204
|
table.add_row(
|
192
|
-
metadata.name,
|
193
|
-
metadata.version,
|
194
|
-
metadata.description,
|
195
|
-
"🔵 Core"
|
205
|
+
metadata.name, metadata.version, metadata.description, "🔵 Core"
|
196
206
|
)
|
197
|
-
|
207
|
+
|
198
208
|
# Add other plugins
|
199
209
|
for plugin_name in other_plugins:
|
200
210
|
metadata = manager.get_plugin_metadata(plugin_name)
|
201
211
|
if metadata:
|
202
212
|
table.add_row(
|
203
|
-
metadata.name,
|
204
|
-
metadata.version,
|
205
|
-
metadata.description,
|
206
|
-
"🔶 External"
|
213
|
+
metadata.name, metadata.version, metadata.description, "🔶 External"
|
207
214
|
)
|
208
215
|
|
209
216
|
console.print(table)
|
210
217
|
else:
|
211
|
-
console.print(
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
218
|
+
console.print(
|
219
|
+
Panel(
|
220
|
+
"No plugins are currently loaded.",
|
221
|
+
title="No Plugins Loaded",
|
222
|
+
style="yellow",
|
223
|
+
)
|
224
|
+
)
|
216
225
|
|
217
226
|
|
218
227
|
def _print_plugin_details(manager, plugin_name):
|
janito/cli/core/getters.py
CHANGED
@@ -5,6 +5,7 @@ import sys
|
|
5
5
|
from janito.cli.cli_commands.list_providers import handle_list_providers
|
6
6
|
from janito.cli.cli_commands.list_models import handle_list_models
|
7
7
|
from janito.cli.cli_commands.list_tools import handle_list_tools
|
8
|
+
from janito.cli.cli_commands.check_tools import handle_check_tools
|
8
9
|
from janito.cli.cli_commands.show_config import handle_show_config
|
9
10
|
from janito.cli.cli_commands.list_config import handle_list_config
|
10
11
|
from janito.cli.cli_commands.list_drivers import handle_list_drivers
|
@@ -28,6 +29,7 @@ GETTER_KEYS = [
|
|
28
29
|
"list_plugins",
|
29
30
|
"list_plugins_available",
|
30
31
|
"list_resources",
|
32
|
+
"check_tools",
|
31
33
|
]
|
32
34
|
|
33
35
|
|
@@ -64,6 +66,7 @@ def handle_getter(args, config_mgr=None):
|
|
64
66
|
"list_plugins": partial(handle_list_plugins, args),
|
65
67
|
"list_plugins_available": partial(handle_list_plugins, args),
|
66
68
|
"list_resources": partial(handle_list_plugins, args),
|
69
|
+
"check_tools": partial(handle_check_tools, args),
|
67
70
|
}
|
68
71
|
for arg in GETTER_KEYS:
|
69
72
|
if getattr(args, arg, False) and arg in GETTER_DISPATCH:
|
janito/cli/main_cli.py
CHANGED
@@ -238,6 +238,13 @@ definition = [
|
|
238
238
|
"help": "List all resources (tools, commands, config) from loaded plugins",
|
239
239
|
},
|
240
240
|
),
|
241
|
+
(
|
242
|
+
["--check-tools"],
|
243
|
+
{
|
244
|
+
"action": "store_true",
|
245
|
+
"help": "Check all registered tools for signature validation and availability",
|
246
|
+
},
|
247
|
+
),
|
241
248
|
]
|
242
249
|
|
243
250
|
MODIFIER_KEYS = [
|
@@ -269,18 +276,7 @@ GETTER_KEYS = [
|
|
269
276
|
"region_info",
|
270
277
|
"list_providers_region",
|
271
278
|
"ping",
|
272
|
-
|
273
|
-
GETTER_KEYS = [
|
274
|
-
"show_config",
|
275
|
-
"list_providers",
|
276
|
-
"list_profiles",
|
277
|
-
"list_models",
|
278
|
-
"list_tools",
|
279
|
-
"list_config",
|
280
|
-
"list_drivers",
|
281
|
-
"region_info",
|
282
|
-
"list_providers_region",
|
283
|
-
"ping",
|
279
|
+
"check_tools",
|
284
280
|
]
|
285
281
|
|
286
282
|
|
@@ -406,6 +402,7 @@ class JanitoCLI:
|
|
406
402
|
or self.args.list_plugins_available
|
407
403
|
or self.args.list_resources
|
408
404
|
or self.args.ping
|
405
|
+
or self.args.check_tools
|
409
406
|
):
|
410
407
|
self._maybe_print_verbose_provider_model()
|
411
408
|
handle_getter(self.args)
|
janito/cli/prompt_core.py
CHANGED
@@ -207,15 +207,25 @@ class PromptHandler:
|
|
207
207
|
"""
|
208
208
|
try:
|
209
209
|
self._print_verbose_debug("Calling agent.chat()...")
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
210
|
+
|
211
|
+
# Use global cancellation manager
|
212
|
+
from janito.llm.cancellation_manager import get_cancellation_manager
|
213
|
+
cancel_manager = get_cancellation_manager()
|
214
|
+
driver_cancel_event = cancel_manager.start_new_request()
|
215
|
+
|
216
|
+
try:
|
217
|
+
final_event = self.agent.chat(prompt=user_prompt)
|
218
|
+
if hasattr(self.agent, "set_latest_event"):
|
219
|
+
self.agent.set_latest_event(final_event)
|
220
|
+
self.agent.last_event = final_event
|
221
|
+
self._print_verbose_debug(f"agent.chat() returned: {final_event}")
|
222
|
+
self._print_verbose_final_event(final_event)
|
223
|
+
if on_event and final_event is not None:
|
224
|
+
on_event(final_event)
|
225
|
+
global_event_bus.publish(final_event)
|
226
|
+
finally:
|
227
|
+
cancel_manager.clear_current_request()
|
228
|
+
|
219
229
|
except KeyboardInterrupt:
|
220
230
|
# Capture user interrupt / cancellation
|
221
231
|
self.console.print("[red]Interrupted by the user.[/red]")
|
janito/drivers/openai/driver.py
CHANGED
@@ -181,6 +181,7 @@ class OpenAIModelDriver(LLMDriver):
|
|
181
181
|
is_insufficient_quota = (
|
182
182
|
"insufficient_quota" in lower_err
|
183
183
|
or "exceeded your current quota" in lower_err
|
184
|
+
or "exceeded_current_quota_error" in lower_err
|
184
185
|
)
|
185
186
|
is_rate_limit = (
|
186
187
|
status_code == 429
|
janito/drivers/zai/driver.py
CHANGED
janito/llm/agent.py
CHANGED
@@ -318,23 +318,36 @@ class LLMAgent:
|
|
318
318
|
loop_count = 1
|
319
319
|
import threading
|
320
320
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
321
|
+
# Use global cancellation manager
|
322
|
+
from janito.llm.cancellation_manager import get_cancellation_manager
|
323
|
+
cancel_manager = get_cancellation_manager()
|
324
|
+
driver_cancel_event = cancel_manager.start_new_request()
|
325
|
+
|
326
|
+
# Store cancellation event on agent for external access
|
327
|
+
self.cancel_event = driver_cancel_event
|
328
|
+
|
329
|
+
try:
|
330
|
+
while True:
|
331
|
+
self._print_verbose_chat_loop(loop_count)
|
332
|
+
driver_input = self._prepare_driver_input(config, cancel_event=driver_cancel_event)
|
333
|
+
self.input_queue.put(driver_input)
|
334
|
+
try:
|
335
|
+
result, added_tool_results = self._process_next_response()
|
336
|
+
except KeyboardInterrupt:
|
337
|
+
cancel_manager.cancel_current_request()
|
338
|
+
raise
|
339
|
+
if getattr(self, "verbose_agent", False):
|
340
|
+
print(
|
341
|
+
f"[agent] [DEBUG] Returned from _process_next_response: result={result}, added_tool_results={added_tool_results}"
|
342
|
+
)
|
343
|
+
if self._should_exit_chat_loop(result, added_tool_results):
|
344
|
+
return result
|
345
|
+
loop_count += 1
|
346
|
+
finally:
|
347
|
+
cancel_manager.clear_current_request()
|
348
|
+
# Clean up cancellation event
|
349
|
+
if hasattr(self, 'cancel_event'):
|
350
|
+
delattr(self, 'cancel_event')
|
338
351
|
|
339
352
|
def _clear_driver_queues(self):
|
340
353
|
if hasattr(self, "driver") and self.driver:
|
janito/llm/auth_utils.py
CHANGED
@@ -13,9 +13,18 @@ def handle_missing_api_key(provider_name: str, env_var_name: str) -> None:
|
|
13
13
|
provider_name: Name of the provider (e.g., 'alibaba', 'openai')
|
14
14
|
env_var_name: Environment variable name (e.g., 'ALIBABA_API_KEY')
|
15
15
|
"""
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
if provider_name == "moonshot":
|
17
|
+
print(
|
18
|
+
f"[ERROR] You exceeded your current token quota for Moonshot. Please check your account balance at:"
|
19
|
+
)
|
20
|
+
print(f" https://platform.moonshot.ai/console/pay")
|
21
|
+
print()
|
22
|
+
print(f"To set a new API key, use:")
|
23
|
+
print(f" janito --set-api-key YOUR_NEW_API_KEY -p moonshot")
|
24
|
+
else:
|
25
|
+
print(
|
26
|
+
f"[ERROR] No API key found for provider '{provider_name}'. Please set the API key using:"
|
27
|
+
)
|
28
|
+
print(f" janito --set-api-key YOUR_API_KEY -p {provider_name}")
|
29
|
+
print(f"Or set the {env_var_name} environment variable.")
|
21
30
|
sys.exit(1)
|