janito 2.3.1__py3-none-any.whl → 2.5.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/__init__.py +1 -1
- janito/_version.py +57 -0
- janito/agent/setup_agent.py +95 -21
- janito/agent/templates/profiles/system_prompt_template_assistant.txt.j2 +1 -0
- janito/agent/templates/profiles/system_prompt_template_developer.txt.j2 +44 -0
- janito/cli/chat_mode/bindings.py +21 -2
- janito/cli/chat_mode/chat_entry.py +2 -3
- janito/cli/chat_mode/prompt_style.py +5 -0
- janito/cli/chat_mode/script_runner.py +153 -0
- janito/cli/chat_mode/session.py +128 -122
- janito/cli/chat_mode/session_profile_select.py +80 -0
- janito/cli/chat_mode/shell/commands/__init__.py +19 -9
- janito/cli/chat_mode/shell/commands/_priv_check.py +5 -0
- janito/cli/chat_mode/shell/commands/bang.py +36 -0
- janito/cli/chat_mode/shell/commands/conversation_restart.py +31 -24
- janito/cli/chat_mode/shell/commands/execute.py +42 -0
- janito/cli/chat_mode/shell/commands/help.py +7 -4
- janito/cli/chat_mode/shell/commands/model.py +28 -0
- janito/cli/chat_mode/shell/commands/prompt.py +0 -8
- janito/cli/chat_mode/shell/commands/read.py +37 -0
- janito/cli/chat_mode/shell/commands/tools.py +45 -18
- janito/cli/chat_mode/shell/commands/write.py +37 -0
- janito/cli/chat_mode/shell/commands.bak.zip +0 -0
- janito/cli/chat_mode/shell/input_history.py +1 -1
- janito/cli/chat_mode/shell/session/manager.py +0 -68
- janito/cli/chat_mode/shell/session.bak.zip +0 -0
- janito/cli/chat_mode/toolbar.py +44 -27
- janito/cli/cli_commands/list_tools.py +44 -11
- janito/cli/cli_commands/model_utils.py +95 -95
- janito/cli/cli_commands/show_system_prompt.py +57 -14
- janito/cli/config.py +5 -6
- janito/cli/core/getters.py +33 -33
- janito/cli/core/runner.py +27 -20
- janito/cli/core/setters.py +10 -1
- janito/cli/main_cli.py +40 -10
- janito/cli/prompt_core.py +18 -2
- janito/cli/prompt_setup.py +56 -0
- janito/cli/rich_terminal_reporter.py +21 -6
- janito/cli/single_shot_mode/handler.py +24 -77
- janito/cli/verbose_output.py +1 -1
- janito/config_manager.py +125 -112
- janito/drivers/dashscope.bak.zip +0 -0
- janito/drivers/driver_registry.py +0 -2
- janito/drivers/openai/README.md +20 -0
- janito/drivers/openai_responses.bak.zip +0 -0
- janito/event_bus/event.py +2 -2
- janito/formatting_token.py +7 -6
- janito/i18n/pt.py +0 -1
- janito/llm/README.md +23 -0
- janito/llm/agent.py +80 -16
- janito/llm/auth.py +63 -63
- janito/llm/driver.py +8 -0
- janito/provider_registry.py +178 -176
- janito/providers/__init__.py +0 -2
- janito/providers/azure_openai/model_info.py +16 -16
- janito/providers/dashscope.bak.zip +0 -0
- janito/providers/provider_static_info.py +0 -3
- janito/providers/registry.py +26 -26
- janito/shell.bak.zip +0 -0
- janito/tools/DOCSTRING_STANDARD.txt +33 -0
- janito/tools/README.md +3 -0
- janito/tools/__init__.py +20 -6
- janito/tools/adapters/local/__init__.py +65 -62
- janito/tools/adapters/local/adapter.py +18 -35
- janito/tools/adapters/local/ask_user.py +3 -4
- janito/tools/adapters/local/copy_file.py +2 -2
- janito/tools/adapters/local/create_directory.py +2 -2
- janito/tools/adapters/local/create_file.py +2 -2
- janito/tools/adapters/local/delete_text_in_file.py +2 -2
- janito/tools/adapters/local/fetch_url.py +2 -2
- janito/tools/adapters/local/find_files.py +2 -1
- janito/tools/adapters/local/get_file_outline/core.py +2 -2
- janito/tools/adapters/local/get_file_outline/search_outline.py +2 -2
- janito/tools/adapters/local/move_file.py +2 -2
- janito/tools/adapters/local/open_html_in_browser.py +2 -1
- janito/tools/adapters/local/open_url.py +2 -2
- janito/tools/adapters/local/python_code_run.py +3 -3
- janito/tools/adapters/local/python_command_run.py +3 -3
- janito/tools/adapters/local/python_file_run.py +3 -3
- janito/tools/adapters/local/remove_directory.py +2 -2
- janito/tools/adapters/local/remove_file.py +2 -2
- janito/tools/adapters/local/replace_text_in_file.py +2 -2
- janito/tools/adapters/local/run_bash_command.py +3 -3
- janito/tools/adapters/local/run_powershell_command.py +3 -3
- janito/tools/adapters/local/search_text/core.py +2 -2
- janito/tools/adapters/local/validate_file_syntax/core.py +3 -3
- janito/tools/adapters/local/view_file.py +2 -1
- janito/tools/outline_file.bak.zip +0 -0
- janito/tools/permissions.py +45 -0
- janito/tools/permissions_parse.py +12 -0
- janito/tools/tool_base.py +14 -11
- janito/tools/tool_utils.py +4 -6
- janito/tools/tools_adapter.py +25 -20
- {janito-2.3.1.dist-info → janito-2.5.0.dist-info}/METADATA +46 -24
- {janito-2.3.1.dist-info → janito-2.5.0.dist-info}/RECORD +99 -82
- janito/agent/templates/profiles/system_prompt_template_base_pt.txt.j2 +0 -13
- janito/agent/templates/profiles/system_prompt_template_main.txt.j2 +0 -37
- janito/cli/chat_mode/shell/commands/edit.py +0 -25
- janito/cli/chat_mode/shell/commands/exec.py +0 -27
- janito/cli/chat_mode/shell/commands/termweb_log.py +0 -92
- janito/cli/termweb_starter.py +0 -122
- janito/termweb/app.py +0 -95
- janito/version.py +0 -4
- {janito-2.3.1.dist-info → janito-2.5.0.dist-info}/WHEEL +0 -0
- {janito-2.3.1.dist-info → janito-2.5.0.dist-info}/entry_points.txt +0 -0
- {janito-2.3.1.dist-info → janito-2.5.0.dist-info}/licenses/LICENSE +0 -0
- {janito-2.3.1.dist-info → janito-2.5.0.dist-info}/top_level.txt +0 -0
@@ -3,7 +3,7 @@ import os
|
|
3
3
|
import sys
|
4
4
|
import tempfile
|
5
5
|
import threading
|
6
|
-
from janito.tools.tool_base import ToolBase
|
6
|
+
from janito.tools.tool_base import ToolBase, ToolPermissions
|
7
7
|
from janito.report_events import ReportAction
|
8
8
|
from janito.tools.adapters.local.adapter import register_local_tool
|
9
9
|
from janito.i18n import tr
|
@@ -14,14 +14,14 @@ class PythonFileRunTool(ToolBase):
|
|
14
14
|
"""
|
15
15
|
Tool to execute a specified Python script file.
|
16
16
|
|
17
|
-
|
17
|
+
Args:
|
18
18
|
file_path (str): Path to the Python script file to execute.
|
19
19
|
timeout (int): Timeout in seconds for the command. Defaults to 60.
|
20
20
|
|
21
21
|
Returns:
|
22
22
|
str: Output and status message, or file paths/line counts if output is large.
|
23
23
|
"""
|
24
|
-
|
24
|
+
permissions = ToolPermissions(execute=True)
|
25
25
|
tool_name = "python_file_run"
|
26
26
|
|
27
27
|
def run(self, file_path: str, timeout: int = 60) -> str:
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from janito.tools.tool_base import ToolBase
|
1
|
+
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
3
|
from janito.tools.adapters.local.adapter import register_local_tool
|
4
4
|
from janito.tools.tool_utils import pluralize, display_path
|
@@ -21,7 +21,7 @@ class RemoveDirectoryTool(ToolBase):
|
|
21
21
|
- "Directory removed: /path/to/dir"
|
22
22
|
- "Error removing directory: <error message>"
|
23
23
|
"""
|
24
|
-
|
24
|
+
permissions = ToolPermissions(write=True)
|
25
25
|
tool_name = "remove_directory"
|
26
26
|
|
27
27
|
def run(self, file_path: str, recursive: bool = False) -> str:
|
@@ -3,7 +3,7 @@ import shutil
|
|
3
3
|
from janito.tools.adapters.local.adapter import register_local_tool
|
4
4
|
|
5
5
|
from janito.tools.tool_utils import display_path
|
6
|
-
from janito.tools.tool_base import ToolBase
|
6
|
+
from janito.tools.tool_base import ToolBase, ToolPermissions
|
7
7
|
from janito.report_events import ReportAction
|
8
8
|
from janito.i18n import tr
|
9
9
|
|
@@ -21,7 +21,7 @@ class RemoveFileTool(ToolBase):
|
|
21
21
|
- " Successfully removed the file at ..."
|
22
22
|
- " Cannot remove file: ..."
|
23
23
|
"""
|
24
|
-
|
24
|
+
permissions = ToolPermissions(write=True)
|
25
25
|
tool_name = "remove_file"
|
26
26
|
|
27
27
|
def run(self, file_path: str, backup: bool = False) -> str:
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from janito.tools.tool_base import ToolBase
|
1
|
+
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
3
|
from janito.tools.adapters.local.adapter import register_local_tool
|
4
4
|
from janito.i18n import tr
|
@@ -28,7 +28,7 @@ class ReplaceTextInFileTool(ToolBase):
|
|
28
28
|
- "No changes made. [Warning: Search text not found in file] Please review the original file."
|
29
29
|
- "Error replacing text: <error message>"
|
30
30
|
"""
|
31
|
-
|
31
|
+
permissions = ToolPermissions(read=True, write=True)
|
32
32
|
tool_name = "replace_text_in_file"
|
33
33
|
|
34
34
|
def run(
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from janito.tools.tool_base import ToolBase
|
1
|
+
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
3
|
from janito.tools.adapters.local.adapter import register_local_tool
|
4
4
|
from janito.i18n import tr
|
@@ -15,7 +15,7 @@ class RunBashCommandTool(ToolBase):
|
|
15
15
|
Execute a non-interactive command using the bash shell and capture live output.
|
16
16
|
This tool explicitly invokes the 'bash' shell (not just the system default shell), so it requires bash to be installed and available in the system PATH. On Windows, this will only work if bash is available (e.g., via WSL, Git Bash, or similar).
|
17
17
|
|
18
|
-
|
18
|
+
Args:
|
19
19
|
command (str): The bash command to execute.
|
20
20
|
timeout (int): Timeout in seconds for the command. Defaults to 60.
|
21
21
|
require_confirmation (bool): If True, require user confirmation before running. Defaults to False.
|
@@ -24,7 +24,7 @@ class RunBashCommandTool(ToolBase):
|
|
24
24
|
Returns:
|
25
25
|
str: File paths and line counts for stdout and stderr.
|
26
26
|
"""
|
27
|
-
|
27
|
+
permissions = ToolPermissions(execute=True)
|
28
28
|
tool_name = "run_bash_command"
|
29
29
|
|
30
30
|
def _stream_output(self, stream, file_obj, report_func, count_func, counter):
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from janito.tools.tool_base import ToolBase
|
1
|
+
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
3
|
from janito.tools.adapters.local.adapter import register_local_tool
|
4
4
|
from janito.i18n import tr
|
@@ -17,7 +17,7 @@ class RunPowershellCommandTool(ToolBase):
|
|
17
17
|
$OutputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8;
|
18
18
|
For file output, it is recommended to use -Encoding utf8 in your PowerShell commands (e.g., Out-File -Encoding utf8) to ensure correct file encoding.
|
19
19
|
|
20
|
-
|
20
|
+
Args:
|
21
21
|
command (str): The PowerShell command to execute. This string is passed directly to PowerShell using the --Command argument (not as a script file).
|
22
22
|
timeout (int): Timeout in seconds for the command. Defaults to 60.
|
23
23
|
require_confirmation (bool): If True, require user confirmation before running. Defaults to False.
|
@@ -26,7 +26,7 @@ class RunPowershellCommandTool(ToolBase):
|
|
26
26
|
Returns:
|
27
27
|
str: Output and status message, or file paths/line counts if output is large.
|
28
28
|
"""
|
29
|
-
|
29
|
+
permissions = ToolPermissions(execute=True)
|
30
30
|
tool_name = "run_powershell_command"
|
31
31
|
|
32
32
|
def _confirm_and_warn(self, command, require_confirmation, requires_user_input):
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from janito.tools.tool_base import ToolBase
|
1
|
+
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
3
|
from janito.tools.adapters.local.adapter import register_local_tool
|
4
4
|
from janito.tools.tool_utils import pluralize, display_path
|
@@ -29,7 +29,7 @@ class SearchTextTool(ToolBase):
|
|
29
29
|
If count_only is True, returns per-file and total match counts.
|
30
30
|
If max_results is reached, appends a note to the output.
|
31
31
|
"""
|
32
|
-
|
32
|
+
permissions = ToolPermissions(read=True)
|
33
33
|
tool_name = "search_text"
|
34
34
|
|
35
35
|
def _handle_file(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import os
|
2
2
|
from janito.i18n import tr
|
3
|
-
from janito.tools.tool_base import ToolBase
|
3
|
+
from janito.tools.tool_base import ToolBase, ToolPermissions
|
4
4
|
from janito.report_events import ReportAction
|
5
5
|
from janito.tools.adapters.local.adapter import register_local_tool
|
6
6
|
from janito.tools.tool_utils import display_path
|
@@ -82,7 +82,7 @@ class ValidateFileSyntaxTool(ToolBase):
|
|
82
82
|
- "⚠️ Warning: Syntax error: <error message>"
|
83
83
|
- "⚠️ Warning: Unsupported file extension: <ext>"
|
84
84
|
"""
|
85
|
-
|
85
|
+
permissions = ToolPermissions(read=True)
|
86
86
|
tool_name = "validate_file_syntax"
|
87
87
|
|
88
88
|
def run(self, file_path: str) -> str:
|
@@ -96,7 +96,7 @@ class ValidateFileSyntaxTool(ToolBase):
|
|
96
96
|
)
|
97
97
|
result = validate_file_syntax(
|
98
98
|
file_path,
|
99
|
-
|
99
|
+
|
100
100
|
report_warning=self.report_warning,
|
101
101
|
report_success=self.report_success,
|
102
102
|
)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from janito.tools.tool_base import ToolBase
|
1
|
+
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
3
|
from janito.tools.adapters.local.adapter import register_local_tool
|
4
4
|
from janito.tools.tool_utils import pluralize
|
@@ -25,6 +25,7 @@ class ViewFileTool(ToolBase):
|
|
25
25
|
- "❗ not found"
|
26
26
|
"""
|
27
27
|
|
28
|
+
permissions = ToolPermissions(read=True)
|
28
29
|
tool_name = "view_file"
|
29
30
|
|
30
31
|
def run(self, file_path: str, from_line: int = None, to_line: int = None) -> str:
|
Binary file
|
@@ -0,0 +1,45 @@
|
|
1
|
+
from janito.tools.tool_base import ToolPermissions
|
2
|
+
|
3
|
+
class AllowedPermissionsState:
|
4
|
+
_instance = None
|
5
|
+
_permissions = ToolPermissions(read=False, write=False, execute=False)
|
6
|
+
_default_permissions = None
|
7
|
+
|
8
|
+
def __new__(cls):
|
9
|
+
if cls._instance is None:
|
10
|
+
cls._instance = super().__new__(cls)
|
11
|
+
return cls._instance
|
12
|
+
|
13
|
+
@classmethod
|
14
|
+
def get_permissions(cls):
|
15
|
+
return cls._permissions
|
16
|
+
|
17
|
+
@classmethod
|
18
|
+
def set_permissions(cls, permissions):
|
19
|
+
if not isinstance(permissions, ToolPermissions):
|
20
|
+
raise ValueError("permissions must be a ToolPermissions instance")
|
21
|
+
cls._permissions = permissions
|
22
|
+
|
23
|
+
@classmethod
|
24
|
+
def set_default_permissions(cls, permissions):
|
25
|
+
if not isinstance(permissions, ToolPermissions):
|
26
|
+
raise ValueError("permissions must be a ToolPermissions instance")
|
27
|
+
cls._default_permissions = permissions
|
28
|
+
|
29
|
+
@classmethod
|
30
|
+
def get_default_permissions(cls):
|
31
|
+
return cls._default_permissions
|
32
|
+
|
33
|
+
# Convenience functions
|
34
|
+
|
35
|
+
def get_global_allowed_permissions():
|
36
|
+
return AllowedPermissionsState.get_permissions()
|
37
|
+
|
38
|
+
def set_global_allowed_permissions(permissions):
|
39
|
+
AllowedPermissionsState.set_permissions(permissions)
|
40
|
+
|
41
|
+
def set_default_allowed_permissions(permissions):
|
42
|
+
AllowedPermissionsState.set_default_permissions(permissions)
|
43
|
+
|
44
|
+
def get_default_allowed_permissions():
|
45
|
+
return AllowedPermissionsState.get_default_permissions()
|
@@ -0,0 +1,12 @@
|
|
1
|
+
from janito.tools.tool_base import ToolPermissions
|
2
|
+
|
3
|
+
def parse_permissions_string(perm_str: str) -> ToolPermissions:
|
4
|
+
"""
|
5
|
+
Parse a string like 'rwx', 'rw', 'r', etc. into a ToolPermissions object.
|
6
|
+
"""
|
7
|
+
perm_str = perm_str.lower()
|
8
|
+
return ToolPermissions(
|
9
|
+
read='r' in perm_str,
|
10
|
+
write='w' in perm_str,
|
11
|
+
execute='x' in perm_str,
|
12
|
+
)
|
janito/tools/tool_base.py
CHANGED
@@ -2,14 +2,27 @@ from janito.report_events import ReportEvent, ReportSubtype, ReportAction
|
|
2
2
|
from janito.event_bus.bus import event_bus as default_event_bus
|
3
3
|
|
4
4
|
|
5
|
+
from collections import namedtuple
|
6
|
+
|
7
|
+
class ToolPermissions(namedtuple('ToolPermissions', ['read', 'write', 'execute'])):
|
8
|
+
__slots__ = ()
|
9
|
+
def __new__(cls, read=False, write=False, execute=False):
|
10
|
+
return super().__new__(cls, read, write, execute)
|
11
|
+
|
12
|
+
def __repr__(self):
|
13
|
+
return f"ToolPermissions(read={self.read}, write={self.write}, execute={self.execute})"
|
14
|
+
|
15
|
+
|
5
16
|
class ToolBase:
|
6
17
|
"""
|
7
18
|
Base class for all tools in the janito project.
|
8
19
|
Extend this class to implement specific tool functionality.
|
9
20
|
"""
|
10
|
-
|
21
|
+
permissions: 'ToolPermissions' = None # Required: must be set by subclasses
|
11
22
|
|
12
23
|
def __init__(self, name=None, event_bus=None):
|
24
|
+
if self.permissions is None or not isinstance(self.permissions, ToolPermissions):
|
25
|
+
raise ValueError(f"Tool '{self.__class__.__name__}' must define a 'permissions' attribute of type ToolPermissions.")
|
13
26
|
self.name = name or self.__class__.__name__
|
14
27
|
self._event_bus = event_bus or default_event_bus
|
15
28
|
|
@@ -35,16 +48,6 @@ class ToolBase:
|
|
35
48
|
)
|
36
49
|
)
|
37
50
|
|
38
|
-
def report_info(self, message: str, context: dict = None):
|
39
|
-
self._event_bus.publish(
|
40
|
-
ReportEvent(
|
41
|
-
subtype=ReportSubtype.ACTION_INFO,
|
42
|
-
message=message,
|
43
|
-
action=None,
|
44
|
-
tool=self.name,
|
45
|
-
context=context,
|
46
|
-
)
|
47
|
-
)
|
48
51
|
|
49
52
|
def report_error(self, message: str, context: dict = None):
|
50
53
|
self._event_bus.publish(
|
janito/tools/tool_utils.py
CHANGED
@@ -20,9 +20,8 @@ def display_path(path):
|
|
20
20
|
Returns:
|
21
21
|
str: Display path, as an ANSI hyperlink.
|
22
22
|
"""
|
23
|
-
|
24
|
-
|
25
|
-
port = get_termweb_port()
|
23
|
+
|
24
|
+
port = 8088
|
26
25
|
if os.path.isabs(path):
|
27
26
|
cwd = os.path.abspath(os.getcwd())
|
28
27
|
abs_path = os.path.abspath(path)
|
@@ -33,9 +32,8 @@ def display_path(path):
|
|
33
32
|
disp = path
|
34
33
|
else:
|
35
34
|
disp = os.path.relpath(path)
|
36
|
-
|
37
|
-
|
38
|
-
return f"[link={url}]{disp}[/link]"
|
35
|
+
# URL injection removed; just return display path
|
36
|
+
return disp
|
39
37
|
|
40
38
|
|
41
39
|
def pluralize(word: str, count: int) -> str:
|
janito/tools/tools_adapter.py
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
from janito.tools.tool_base import ToolBase
|
2
2
|
from janito.tools.tool_events import ToolCallStarted, ToolCallFinished, ToolCallError
|
3
3
|
from janito.exceptions import ToolCallException
|
4
|
-
from
|
5
|
-
|
4
|
+
from janito.tools.tool_base import ToolPermissions
|
6
5
|
|
7
6
|
class ToolsAdapterBase:
|
8
7
|
"""
|
@@ -13,11 +12,10 @@ class ToolsAdapterBase:
|
|
13
12
|
"""
|
14
13
|
|
15
14
|
def __init__(
|
16
|
-
self, tools=None, event_bus=None
|
15
|
+
self, tools=None, event_bus=None
|
17
16
|
):
|
18
17
|
self._tools = tools or []
|
19
18
|
self._event_bus = event_bus # event bus can be set on all adapters
|
20
|
-
self._enabled_tools = set(enabled_tools) if enabled_tools is not None else None
|
21
19
|
self.verbose_tools = False
|
22
20
|
|
23
21
|
def set_verbose_tools(self, value: bool):
|
@@ -31,11 +29,28 @@ class ToolsAdapterBase:
|
|
31
29
|
def event_bus(self, bus):
|
32
30
|
self._event_bus = bus
|
33
31
|
|
32
|
+
def is_tool_allowed(self, tool):
|
33
|
+
"""Check if a tool is allowed based on current global AllowedPermissionsState."""
|
34
|
+
from janito.tools.permissions import get_global_allowed_permissions
|
35
|
+
allowed_permissions = get_global_allowed_permissions()
|
36
|
+
perms = tool.permissions # permissions are mandatory and type-checked
|
37
|
+
# If all permissions are False, block all tools
|
38
|
+
if not (allowed_permissions.read or allowed_permissions.write or allowed_permissions.execute):
|
39
|
+
return False
|
40
|
+
for perm in ['read', 'write', 'execute']:
|
41
|
+
if getattr(perms, perm) and not getattr(allowed_permissions, perm):
|
42
|
+
return False
|
43
|
+
return True
|
44
|
+
|
34
45
|
def get_tools(self):
|
35
|
-
"""Return the list of enabled tools managed by this provider."""
|
36
|
-
|
37
|
-
|
38
|
-
|
46
|
+
"""Return the list of enabled tools managed by this provider, filtered by allowed permissions."""
|
47
|
+
tools = [tool for tool in self._tools if self.is_tool_allowed(tool)]
|
48
|
+
return tools
|
49
|
+
|
50
|
+
def set_allowed_permissions(self, allowed_permissions):
|
51
|
+
"""Set the allowed permissions at runtime. This now updates the global AllowedPermissionsState only."""
|
52
|
+
from janito.tools.permissions import set_global_allowed_permissions
|
53
|
+
set_global_allowed_permissions(allowed_permissions)
|
39
54
|
|
40
55
|
def add_tool(self, tool):
|
41
56
|
self._tools.append(tool)
|
@@ -231,18 +246,8 @@ class ToolsAdapterBase:
|
|
231
246
|
)
|
232
247
|
|
233
248
|
def _check_tool_permissions(self, tool_name, request_id, arguments):
|
234
|
-
|
235
|
-
|
236
|
-
if self._event_bus:
|
237
|
-
self._event_bus.publish(
|
238
|
-
ToolCallError(
|
239
|
-
tool_name=tool_name,
|
240
|
-
request_id=request_id,
|
241
|
-
error=error_msg,
|
242
|
-
arguments=arguments,
|
243
|
-
)
|
244
|
-
)
|
245
|
-
raise ToolCallException(tool_name, error_msg, arguments=arguments)
|
249
|
+
# No enabled_tools check anymore; permission checks are handled by is_tool_allowed
|
250
|
+
pass
|
246
251
|
|
247
252
|
def _ensure_tool_exists(self, tool, tool_name, request_id, arguments):
|
248
253
|
if tool is None:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: janito
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.5.0
|
4
4
|
Summary: A new Python package called janito.
|
5
5
|
Author-email: João Pinto <lamego.pinto@gmail.com>
|
6
6
|
Project-URL: Homepage, https://github.com/janito-dev/janito
|
@@ -17,7 +17,7 @@ Requires-Dist: prompt_toolkit>=3.0.51
|
|
17
17
|
Requires-Dist: lxml>=5.4.0
|
18
18
|
Requires-Dist: requests>=2.32.4
|
19
19
|
Requires-Dist: bs4>=0.0.2
|
20
|
-
Requires-Dist:
|
20
|
+
Requires-Dist: questionary>=2.0.1
|
21
21
|
Provides-Extra: dev
|
22
22
|
Requires-Dist: pytest; extra == "dev"
|
23
23
|
Requires-Dist: pre-commit; extra == "dev"
|
@@ -25,7 +25,8 @@ Requires-Dist: ruff==0.11.9; extra == "dev"
|
|
25
25
|
Requires-Dist: detect-secrets==1.4.0; extra == "dev"
|
26
26
|
Requires-Dist: codespell==2.4.1; extra == "dev"
|
27
27
|
Requires-Dist: black; extra == "dev"
|
28
|
-
Requires-Dist:
|
28
|
+
Requires-Dist: questionary>=2.0.1; extra == "dev"
|
29
|
+
Requires-Dist: setuptools_scm>=8.0; extra == "dev"
|
29
30
|
Dynamic: license-file
|
30
31
|
|
31
32
|
# Janito
|
@@ -106,6 +107,21 @@ janito -set provider=PROVIDER
|
|
106
107
|
|
107
108
|
After installation, use the `janito` command in your terminal.
|
108
109
|
|
110
|
+
Janito supports both general-purpose and specialized assistance through the use of **profiles**. Profiles allow you to select a specific system prompt template and behavior for the agent, enabling workflows tailored to different roles or tasks (e.g., developer, writer, data analyst), or to use Janito as a generic AI assistant.
|
111
|
+
|
112
|
+
### Profiles: General-Purpose and Specialized Assistance
|
113
|
+
|
114
|
+
- By default, Janito acts as a general-purpose assistant.
|
115
|
+
- You can select a specialized profile using the `--profile` option:
|
116
|
+
```bash
|
117
|
+
janito --profile developer "Refactor this code for better readability."
|
118
|
+
janito --profile writer "Draft a blog post about AI in healthcare."
|
119
|
+
```
|
120
|
+
- Profiles change the system prompt and agent behavior to suit the selected role or workflow.
|
121
|
+
- To see available profiles or customize them, refer to the documentation or the `agent/templates/profiles/` directory.
|
122
|
+
|
123
|
+
> **Tip:** Use `--profile` for targeted workflows, or omit it for a general-purpose assistant.
|
124
|
+
|
109
125
|
Janito has configuration options, like `--set api-key API_KEY` and `--set provider=PROVIDER`, that create durable configurations and single shoot options, like `-p PROVIDER` and `-m MODEL`, that are active for the single run of the command or session.
|
110
126
|
|
111
127
|
### Basic Commands
|
@@ -151,27 +167,27 @@ Janito has configuration options, like `--set api-key API_KEY` and `--set provid
|
|
151
167
|
|
152
168
|
### Advanced Options
|
153
169
|
|
154
|
-
- **Enable
|
155
|
-
|
156
|
-
By default, Janito can open referenced files in a browser-based viewer when you click on file links in supported terminals. To enable this feature for your session, use the `-w` or `--web` flag:
|
170
|
+
- **Enable Execution Tools (Code/Shell Execution)**
|
157
171
|
|
158
|
-
|
159
|
-
janito -w
|
160
|
-
```
|
172
|
+
By default, **all tool privileges (read, write, execute)** are disabled for safety. This means Janito starts with no permissions to run tools that read, write, or execute code/shell commands unless you explicitly enable them.
|
161
173
|
|
162
|
-
|
163
|
-
|
164
|
-
|
174
|
+
- To enable **read** tools (e.g., file reading, searching): add `-r` or `--read`
|
175
|
+
- To enable **write** tools (e.g., file editing): add `-w` or `--write`
|
176
|
+
- To enable **execution** tools (code/shell execution): add `-x` or `--exec`
|
165
177
|
|
178
|
+
You can combine these flags as needed. For example, to enable both read and write tools:
|
166
179
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
180
|
+
```bash
|
181
|
+
janito -r -w "Read and update this file: ..."
|
182
|
+
```
|
183
|
+
|
184
|
+
To enable all permissions (read, write, execute):
|
185
|
+
|
186
|
+
```bash
|
187
|
+
janito -r -w -x "Run this code: print('Hello, world!')"
|
188
|
+
```
|
189
|
+
|
190
|
+
> **Warning:** Enabling execution tools allows running arbitrary code or shell commands. Only use `--exec` if you trust your prompt and environment.
|
175
191
|
|
176
192
|
- **Set a System Prompt**
|
177
193
|
```bash
|
@@ -203,7 +219,7 @@ Janito has configuration options, like `--set api-key API_KEY` and `--set provid
|
|
203
219
|
### Core CLI Options
|
204
220
|
| Option | Description |
|
205
221
|
|------------------------|-----------------------------------------------------------------------------|
|
206
|
-
|
222
|
+
|
207
223
|
| `--version` | Show program version |
|
208
224
|
| `--list-tools` | List all registered tools |
|
209
225
|
| `--list-providers` | List all supported LLM providers |
|
@@ -212,7 +228,7 @@ Janito has configuration options, like `--set api-key API_KEY` and `--set provid
|
|
212
228
|
| `--set provider=name` | Set the current LLM provider (e.g., `janito --set provider=openai`) |
|
213
229
|
| `--set PROVIDER.model=MODEL` or `--set model=MODEL` | Set the default model for the current/selected provider, or globally. (e.g., `janito --set openai.model=gpt-3.5-turbo`) |
|
214
230
|
| `-s`, `--system` | Set a system prompt (e.g., `janito -s path/to/system_prompt.txt "Your prompt here"`) |
|
215
|
-
|
231
|
+
|
216
232
|
| `-p`, `--provider` | Select LLM provider (overrides config) (e.g., `janito -p openai "Your prompt here"`) |
|
217
233
|
| `-m`, `--model` | Select model for the provider (e.g., `janito -m gpt-3.5-turbo "Your prompt here"`) |
|
218
234
|
| `-v`, `--verbose` | Print extra information before answering |
|
@@ -246,8 +262,8 @@ Once inside the interactive chat mode, you can use these slash commands:
|
|
246
262
|
| Command | Description |
|
247
263
|
|----------------------|----------------------------------------------|
|
248
264
|
| `/tools` | List available tools |
|
249
|
-
|
|
250
|
-
|
|
265
|
+
| `/-status` | Show status of server |
|
266
|
+
| `/-logs` | Show last lines of logs |
|
251
267
|
| `/livelogs` | Show live updates from server log file |
|
252
268
|
| `/edit <filename>` | Open file in browser-based editor |
|
253
269
|
|
@@ -274,6 +290,12 @@ See [docs/supported-providers-models.md](docs/supported-providers-models.md) for
|
|
274
290
|
|
275
291
|
Contributions are welcome! Please see the `CONTRIBUTING.md` (if available) or open an issue to get started.
|
276
292
|
|
293
|
+
---
|
294
|
+
|
295
|
+
## Developer Documentation
|
296
|
+
|
297
|
+
For developer-specific setup, versioning, and contribution guidelines, see [README-dev.md](./README-dev.md).
|
298
|
+
|
277
299
|
## License
|
278
300
|
|
279
301
|
This project is licensed under the terms of the MIT license.
|