janito 2.33.0__py3-none-any.whl → 3.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. janito/cli/cli_commands/check_tools.py +212 -0
  2. janito/cli/cli_commands/list_plugins.py +52 -43
  3. janito/cli/core/getters.py +3 -0
  4. janito/cli/main_cli.py +9 -12
  5. janito/drivers/openai/driver.py +1 -0
  6. janito/drivers/zai/driver.py +1 -0
  7. janito/llm/auth_utils.py +14 -5
  8. janito/plugin_system/__init__.py +10 -0
  9. janito/{plugins → plugin_system}/base.py +5 -2
  10. janito/{plugins/core_loader_fixed.py → plugin_system/core_loader.py} +45 -26
  11. janito/plugin_system/core_loader_fixed.py +149 -0
  12. janito/plugins/__init__.py +31 -12
  13. janito/plugins/auto_loader_fixed.py +12 -11
  14. janito/plugins/builtin.py +15 -1
  15. janito/plugins/core/__init__.py +7 -0
  16. janito/plugins/core/codeanalyzer/__init__.py +43 -0
  17. janito/plugins/core/filemanager/__init__.py +124 -0
  18. janito/plugins/core/filemanager/tools/create_file.py +87 -0
  19. janito/plugins/core/filemanager/tools/replace_text_in_file.py +270 -0
  20. janito/plugins/core/imagedisplay/__init__.py +14 -0
  21. janito/plugins/core/imagedisplay/plugin.py +51 -0
  22. janito/plugins/core/imagedisplay/tools/__init__.py +1 -0
  23. janito/plugins/core/imagedisplay/tools/show_image.py +83 -0
  24. janito/{tools/adapters/local → plugins/core/imagedisplay/tools}/show_image_grid.py +13 -5
  25. janito/plugins/core/system/__init__.py +23 -0
  26. janito/plugins/core_adapter.py +11 -9
  27. janito/plugins/dev/__init__.py +7 -0
  28. janito/plugins/dev/pythondev/__init__.py +37 -0
  29. janito/plugins/dev/visualization/__init__.py +23 -0
  30. janito/plugins/discovery.py +5 -5
  31. janito/plugins/example_plugin.py +108 -0
  32. janito/plugins/manager.py +1 -1
  33. janito/plugins/tools/__init__.py +10 -0
  34. janito/{tools/adapters/local → plugins/tools}/ask_user.py +3 -3
  35. janito/plugins/tools/copy_file.py +87 -0
  36. janito/plugins/tools/core_tools_plugin.py +88 -0
  37. janito/plugins/tools/create_directory.py +70 -0
  38. janito/{tools/adapters/local → plugins/tools}/create_file.py +4 -4
  39. janito/plugins/tools/decorators.py +19 -0
  40. janito/plugins/tools/delete_text_in_file.py +134 -0
  41. janito/{tools/adapters/local → plugins/tools}/fetch_url.py +3 -3
  42. janito/plugins/tools/find_files.py +143 -0
  43. janito/plugins/tools/get_file_outline/__init__.py +7 -0
  44. janito/plugins/tools/get_file_outline/core.py +122 -0
  45. janito/plugins/tools/get_file_outline/java_outline.py +47 -0
  46. janito/plugins/tools/get_file_outline/markdown_outline.py +14 -0
  47. janito/plugins/tools/get_file_outline/python_outline.py +303 -0
  48. janito/plugins/tools/get_file_outline/search_outline.py +36 -0
  49. janito/plugins/tools/move_file.py +131 -0
  50. janito/plugins/tools/open_html_in_browser.py +51 -0
  51. janito/plugins/tools/open_url.py +37 -0
  52. janito/plugins/tools/python_code_run.py +172 -0
  53. janito/plugins/tools/python_command_run.py +171 -0
  54. janito/plugins/tools/python_file_run.py +172 -0
  55. janito/plugins/tools/read_chart.py +259 -0
  56. janito/plugins/tools/read_files.py +58 -0
  57. janito/plugins/tools/remove_directory.py +55 -0
  58. janito/plugins/tools/remove_file.py +58 -0
  59. janito/{tools/adapters/local → plugins/tools}/replace_text_in_file.py +4 -4
  60. janito/plugins/tools/run_bash_command.py +183 -0
  61. janito/plugins/tools/run_powershell_command.py +218 -0
  62. janito/plugins/tools/search_text/__init__.py +7 -0
  63. janito/plugins/tools/search_text/core.py +205 -0
  64. janito/plugins/tools/search_text/match_lines.py +67 -0
  65. janito/plugins/tools/search_text/pattern_utils.py +73 -0
  66. janito/plugins/tools/search_text/traverse_directory.py +145 -0
  67. janito/{tools/adapters/local → plugins/tools}/show_image.py +15 -6
  68. janito/plugins/tools/show_image_grid.py +85 -0
  69. janito/plugins/tools/validate_file_syntax/__init__.py +7 -0
  70. janito/plugins/tools/validate_file_syntax/core.py +114 -0
  71. janito/plugins/tools/validate_file_syntax/css_validator.py +35 -0
  72. janito/plugins/tools/validate_file_syntax/html_validator.py +100 -0
  73. janito/plugins/tools/validate_file_syntax/jinja2_validator.py +50 -0
  74. janito/plugins/tools/validate_file_syntax/js_validator.py +27 -0
  75. janito/plugins/tools/validate_file_syntax/json_validator.py +6 -0
  76. janito/plugins/tools/validate_file_syntax/markdown_validator.py +109 -0
  77. janito/plugins/tools/validate_file_syntax/ps1_validator.py +32 -0
  78. janito/plugins/tools/validate_file_syntax/python_validator.py +5 -0
  79. janito/plugins/tools/validate_file_syntax/xml_validator.py +11 -0
  80. janito/plugins/tools/validate_file_syntax/yaml_validator.py +6 -0
  81. janito/plugins/tools/view_file.py +172 -0
  82. janito/plugins/ui/__init__.py +7 -0
  83. janito/plugins/ui/userinterface/__init__.py +16 -0
  84. janito/plugins/ui/userinterface/tools/ask_user.py +110 -0
  85. janito/plugins/web/__init__.py +7 -0
  86. janito/plugins/web/webtools/__init__.py +33 -0
  87. janito/plugins/web/webtools/tools/fetch_url.py +458 -0
  88. janito/tools/__init__.py +31 -7
  89. janito/tools/adapters/__init__.py +6 -1
  90. janito/tools/adapters/local/__init__.py +7 -70
  91. janito/tools/cli_initializer.py +88 -0
  92. janito/tools/function_adapter.py +93 -16
  93. janito/tools/initialize.py +70 -0
  94. {janito-2.33.0.dist-info → janito-3.0.0.dist-info}/METADATA +1 -2
  95. {janito-2.33.0.dist-info → janito-3.0.0.dist-info}/RECORD +139 -71
  96. janito/plugins/core_loader.py +0 -120
  97. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/__init__.py +0 -0
  98. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/core.py +0 -0
  99. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/java_outline.py +0 -0
  100. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/markdown_outline.py +0 -0
  101. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/python_outline.py +0 -0
  102. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/search_outline.py +0 -0
  103. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/search_text/__init__.py +0 -0
  104. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/search_text/core.py +0 -0
  105. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/search_text/match_lines.py +0 -0
  106. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/search_text/pattern_utils.py +0 -0
  107. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/search_text/traverse_directory.py +0 -0
  108. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/copy_file.py +0 -0
  109. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/create_directory.py +0 -0
  110. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/delete_text_in_file.py +0 -0
  111. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/find_files.py +0 -0
  112. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/move_file.py +0 -0
  113. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/read_files.py +0 -0
  114. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/remove_directory.py +0 -0
  115. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/remove_file.py +0 -0
  116. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/__init__.py +0 -0
  117. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/core.py +0 -0
  118. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/css_validator.py +0 -0
  119. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/html_validator.py +0 -0
  120. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/jinja2_validator.py +0 -0
  121. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/js_validator.py +0 -0
  122. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/json_validator.py +0 -0
  123. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/markdown_validator.py +0 -0
  124. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/ps1_validator.py +0 -0
  125. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/python_validator.py +0 -0
  126. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/xml_validator.py +0 -0
  127. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/yaml_validator.py +0 -0
  128. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/view_file.py +0 -0
  129. /janito/{tools/adapters/local → plugins/core/system/tools}/run_bash_command.py +0 -0
  130. /janito/{tools/adapters/local → plugins/core/system/tools}/run_powershell_command.py +0 -0
  131. /janito/{tools/adapters/local → plugins/dev/pythondev/tools}/python_code_run.py +0 -0
  132. /janito/{tools/adapters/local → plugins/dev/pythondev/tools}/python_command_run.py +0 -0
  133. /janito/{tools/adapters/local → plugins/dev/pythondev/tools}/python_file_run.py +0 -0
  134. /janito/{tools/adapters/local → plugins/dev/visualization/tools}/read_chart.py +0 -0
  135. /janito/{tools/adapters/local → plugins/web/webtools/tools}/open_html_in_browser.py +0 -0
  136. /janito/{tools/adapters/local → plugins/web/webtools/tools}/open_url.py +0 -0
  137. {janito-2.33.0.dist-info → janito-3.0.0.dist-info}/WHEEL +0 -0
  138. {janito-2.33.0.dist-info → janito-3.0.0.dist-info}/entry_points.txt +0 -0
  139. {janito-2.33.0.dist-info → janito-3.0.0.dist-info}/licenses/LICENSE +0 -0
  140. {janito-2.33.0.dist-info → janito-3.0.0.dist-info}/top_level.txt +0 -0
@@ -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 load_core_plugins, get_loaded_core_plugins, is_core_plugin
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.plugins.core_loader_fixed import get_core_plugins
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(Panel(
66
- "No plugins found in search paths\n"
67
- f"[dim]Search paths:[/dim]\n"
68
- f" {os.getcwd()}/plugins\n"
69
- f" • {os.path.expanduser('~')}/.janito/plugins",
70
- title="No Plugins Found",
71
- style="yellow"
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 'unknown'
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(f" • {config['name']}: {config['description']}")
126
-
127
- console.print(Panel(
128
- "\n".join(panel_content),
129
- title=f"{plugin_name} v{version}",
130
- style="cyan"
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(Panel(
134
- "No plugins are currently loaded.",
135
- title="No Plugin Resources",
136
- style="yellow"
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(Panel(
212
- "No plugins are currently loaded.",
213
- title="No Plugins Loaded",
214
- style="yellow"
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):
@@ -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)
@@ -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
@@ -174,6 +174,7 @@ class ZAIModelDriver(LLMDriver):
174
174
  is_insufficient_quota = (
175
175
  "insufficient_quota" in lower_err
176
176
  or "exceeded your current quota" in lower_err
177
+ or "exceeded_current_quota_error" in lower_err
177
178
  )
178
179
  is_rate_limit = (
179
180
  status_code == 429
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
- print(
17
- f"[ERROR] No API key found for provider '{provider_name}'. Please set the API key using:"
18
- )
19
- print(f" janito --set-api-key YOUR_API_KEY -p {provider_name}")
20
- print(f"Or set the {env_var_name} environment variable.")
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)
@@ -0,0 +1,10 @@
1
+ """
2
+ Plugin System Core Package
3
+
4
+ This package provides the foundational plugin system architecture.
5
+ It should not depend on any specific plugin implementations.
6
+ """
7
+
8
+ from .base import Plugin, PluginMetadata, PluginResource
9
+
10
+ __all__ = ["Plugin", "PluginMetadata", "PluginResource"]
@@ -5,7 +5,10 @@ Base classes for janito plugins.
5
5
  from abc import ABC, abstractmethod
6
6
  from dataclasses import dataclass
7
7
  from typing import Dict, Any, List, Optional, Type, Union
8
- from janito.tools.tool_base import ToolBase
8
+ from typing import TYPE_CHECKING
9
+
10
+ if TYPE_CHECKING:
11
+ from janito.tools.tool_base import ToolBase
9
12
 
10
13
 
11
14
  @dataclass
@@ -50,7 +53,7 @@ class Plugin(ABC):
50
53
  """Return metadata describing this plugin."""
51
54
  pass
52
55
 
53
- def get_tools(self) -> List[Type[ToolBase]]:
56
+ def get_tools(self) -> List[Type["ToolBase"]]:
54
57
  """
55
58
  Return a list of tool classes provided by this plugin.
56
59
 
@@ -5,26 +5,27 @@ This module provides a working implementation to load core plugins
5
5
  by directly using the Plugin base class properly.
6
6
  """
7
7
 
8
+ import importlib
8
9
  import importlib.util
9
10
  import sys
10
11
  from pathlib import Path
11
12
  from typing import Optional, List, Type
12
13
 
13
- from janito.plugins.base import Plugin, PluginMetadata
14
+ from janito.plugin_system.base import Plugin, PluginMetadata
14
15
  from janito.tools.function_adapter import create_function_tool
15
16
  from janito.tools.tool_base import ToolBase
16
17
 
17
18
 
18
19
  class CorePlugin(Plugin):
19
20
  """Working core plugin implementation."""
20
-
21
+
21
22
  def __init__(self, name: str, description: str, tools: list):
22
23
  self._plugin_name = name
23
24
  self._description = description
24
25
  self._tools = tools
25
26
  self._tool_classes = []
26
27
  super().__init__() # Call super after setting attributes
27
-
28
+
28
29
  def get_metadata(self) -> PluginMetadata:
29
30
  return PluginMetadata(
30
31
  name=self._plugin_name,
@@ -33,10 +34,10 @@ class CorePlugin(Plugin):
33
34
  author="Janito",
34
35
  license="MIT",
35
36
  )
36
-
37
+
37
38
  def get_tools(self) -> List[Type[ToolBase]]:
38
39
  return self._tool_classes
39
-
40
+
40
41
  def initialize(self):
41
42
  """Initialize by creating tool classes."""
42
43
  self._tool_classes = []
@@ -49,10 +50,10 @@ class CorePlugin(Plugin):
49
50
  def load_core_plugin(plugin_name: str) -> Optional[Plugin]:
50
51
  """
51
52
  Load a core plugin by name.
52
-
53
+
53
54
  Args:
54
55
  plugin_name: Name of the plugin (e.g., 'core.filemanager')
55
-
56
+
56
57
  Returns:
57
58
  Plugin instance if loaded successfully
58
59
  """
@@ -60,49 +61,67 @@ def load_core_plugin(plugin_name: str) -> Optional[Plugin]:
60
61
  # Parse plugin name
61
62
  if "." not in plugin_name:
62
63
  return None
63
-
64
+
64
65
  parts = plugin_name.split(".")
65
66
  if len(parts) != 2:
66
67
  return None
67
-
68
+
68
69
  package_name, submodule_name = parts
69
-
70
+
70
71
  # Handle imagedisplay specially
71
72
  if plugin_name == "core.imagedisplay":
72
73
  # Import the actual plugin class
73
74
  try:
74
- from plugins.core.imagedisplay.plugin import ImageDisplayPlugin
75
- return ImageDisplayPlugin()
76
- except ImportError:
77
- # If import fails, return None - don't return True
75
+ # Use dynamic import to avoid circular dependency
76
+ plugin_module = importlib.import_module(
77
+ "janito.plugins.core.imagedisplay.plugin"
78
+ )
79
+ return plugin_module.ImageDisplayPlugin()
80
+ except ImportError as e:
81
+ print(f"Failed to load imagedisplay: {e}")
78
82
  return None
79
-
83
+
80
84
  # Build path to plugin
81
- plugin_path = Path("plugins") / package_name / submodule_name / "__init__.py"
85
+ plugin_path = (
86
+ Path("janito/plugins") / package_name / submodule_name / "__init__.py"
87
+ )
82
88
  if not plugin_path.exists():
83
89
  return None
84
-
90
+
85
91
  # Load the module
86
92
  spec = importlib.util.spec_from_file_location(plugin_name, plugin_path)
87
93
  if spec is None or spec.loader is None:
88
94
  return None
89
-
95
+
90
96
  module = importlib.util.module_from_spec(spec)
91
97
  spec.loader.exec_module(module)
92
-
98
+
93
99
  # Get plugin info
94
100
  name = getattr(module, "__plugin_name__", plugin_name)
95
- description = getattr(module, "__plugin_description__", f"Core plugin: {plugin_name}")
101
+ description = getattr(
102
+ module, "__plugin_description__", f"Core plugin: {plugin_name}"
103
+ )
96
104
  tools = getattr(module, "__plugin_tools__", [])
97
-
105
+
98
106
  if not tools:
99
107
  return None
100
-
108
+
109
+ # Filter out None values and ensure all tools have tool_name
110
+ valid_tools = []
111
+ for tool in tools:
112
+ if tool is not None:
113
+ if not hasattr(tool, "tool_name"):
114
+ tool.tool_name = tool.__name__
115
+ valid_tools.append(tool)
116
+
117
+ if not valid_tools:
118
+ return None
119
+
101
120
  # Create plugin
102
- plugin = CorePlugin(name, description, tools)
121
+ plugin = CorePlugin(name, description, valid_tools)
103
122
  plugin.initialize()
104
123
  return plugin
105
-
124
+
106
125
  except Exception as e:
107
126
  print(f"Error loading core plugin {plugin_name}: {e}")
108
127
  return None
@@ -120,6 +139,6 @@ def get_core_plugins() -> list:
120
139
  "ui.userinterface",
121
140
  "web.webtools",
122
141
  ]
123
-
142
+
124
143
  # All core plugins are always available
125
- return core_plugins
144
+ return core_plugins