janito 2.1.1__py3-none-any.whl → 2.3.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 (137) hide show
  1. janito/__init__.py +6 -6
  2. janito/agent/setup_agent.py +14 -5
  3. janito/agent/templates/profiles/system_prompt_template_main.txt.j2 +3 -1
  4. janito/cli/chat_mode/bindings.py +6 -0
  5. janito/cli/chat_mode/session.py +16 -0
  6. janito/cli/chat_mode/shell/autocomplete.py +21 -21
  7. janito/cli/chat_mode/shell/commands/__init__.py +3 -2
  8. janito/cli/chat_mode/shell/commands/clear.py +12 -12
  9. janito/cli/chat_mode/shell/commands/exec.py +27 -0
  10. janito/cli/chat_mode/shell/commands/multi.py +51 -51
  11. janito/cli/chat_mode/shell/commands/tools.py +17 -6
  12. janito/cli/chat_mode/shell/input_history.py +62 -62
  13. janito/cli/chat_mode/shell/session/manager.py +1 -0
  14. janito/cli/chat_mode/toolbar.py +3 -1
  15. janito/cli/cli_commands/list_models.py +35 -35
  16. janito/cli/cli_commands/list_providers.py +9 -9
  17. janito/cli/cli_commands/list_tools.py +53 -53
  18. janito/cli/cli_commands/model_selection.py +50 -50
  19. janito/cli/cli_commands/model_utils.py +13 -2
  20. janito/cli/cli_commands/set_api_key.py +19 -19
  21. janito/cli/cli_commands/show_config.py +51 -51
  22. janito/cli/cli_commands/show_system_prompt.py +62 -62
  23. janito/cli/config.py +2 -1
  24. janito/cli/core/__init__.py +4 -4
  25. janito/cli/core/event_logger.py +59 -59
  26. janito/cli/core/getters.py +3 -1
  27. janito/cli/core/runner.py +27 -6
  28. janito/cli/core/setters.py +5 -1
  29. janito/cli/core/unsetters.py +54 -54
  30. janito/cli/main_cli.py +12 -1
  31. janito/cli/prompt_core.py +5 -2
  32. janito/cli/rich_terminal_reporter.py +22 -3
  33. janito/cli/single_shot_mode/__init__.py +6 -6
  34. janito/cli/single_shot_mode/handler.py +11 -1
  35. janito/cli/verbose_output.py +1 -1
  36. janito/config.py +5 -5
  37. janito/config_manager.py +2 -0
  38. janito/driver_events.py +14 -0
  39. janito/drivers/anthropic/driver.py +113 -113
  40. janito/drivers/azure_openai/driver.py +38 -3
  41. janito/drivers/driver_registry.py +0 -2
  42. janito/drivers/openai/driver.py +196 -36
  43. janito/formatting_token.py +54 -54
  44. janito/i18n/__init__.py +35 -35
  45. janito/i18n/messages.py +23 -23
  46. janito/i18n/pt.py +47 -47
  47. janito/llm/__init__.py +5 -5
  48. janito/llm/agent.py +443 -443
  49. janito/llm/auth.py +1 -0
  50. janito/llm/driver.py +7 -1
  51. janito/llm/driver_config.py +1 -0
  52. janito/llm/driver_config_builder.py +34 -34
  53. janito/llm/driver_input.py +12 -12
  54. janito/llm/message_parts.py +60 -60
  55. janito/llm/model.py +38 -38
  56. janito/llm/provider.py +196 -196
  57. janito/provider_config.py +7 -3
  58. janito/provider_registry.py +29 -5
  59. janito/providers/__init__.py +1 -0
  60. janito/providers/anthropic/model_info.py +22 -22
  61. janito/providers/anthropic/provider.py +2 -2
  62. janito/providers/azure_openai/model_info.py +7 -6
  63. janito/providers/azure_openai/provider.py +44 -2
  64. janito/providers/deepseek/__init__.py +1 -1
  65. janito/providers/deepseek/model_info.py +16 -16
  66. janito/providers/deepseek/provider.py +91 -91
  67. janito/providers/google/model_info.py +21 -29
  68. janito/providers/google/provider.py +49 -38
  69. janito/providers/mistralai/provider.py +2 -2
  70. janito/providers/openai/model_info.py +0 -11
  71. janito/providers/openai/provider.py +1 -1
  72. janito/providers/provider_static_info.py +2 -3
  73. janito/providers/registry.py +26 -26
  74. janito/tools/adapters/__init__.py +1 -1
  75. janito/tools/adapters/local/__init__.py +62 -62
  76. janito/tools/adapters/local/adapter.py +33 -11
  77. janito/tools/adapters/local/ask_user.py +102 -102
  78. janito/tools/adapters/local/copy_file.py +84 -84
  79. janito/tools/adapters/local/create_directory.py +69 -69
  80. janito/tools/adapters/local/create_file.py +82 -82
  81. janito/tools/adapters/local/delete_text_in_file.py +4 -7
  82. janito/tools/adapters/local/fetch_url.py +97 -97
  83. janito/tools/adapters/local/find_files.py +138 -140
  84. janito/tools/adapters/local/get_file_outline/__init__.py +1 -1
  85. janito/tools/adapters/local/get_file_outline/core.py +117 -151
  86. janito/tools/adapters/local/get_file_outline/java_outline.py +40 -0
  87. janito/tools/adapters/local/get_file_outline/markdown_outline.py +14 -14
  88. janito/tools/adapters/local/get_file_outline/python_outline.py +303 -303
  89. janito/tools/adapters/local/get_file_outline/python_outline_v2.py +156 -156
  90. janito/tools/adapters/local/get_file_outline/search_outline.py +33 -33
  91. janito/tools/adapters/local/move_file.py +3 -13
  92. janito/tools/adapters/local/open_html_in_browser.py +24 -29
  93. janito/tools/adapters/local/open_url.py +3 -2
  94. janito/tools/adapters/local/python_code_run.py +166 -166
  95. janito/tools/adapters/local/python_command_run.py +164 -164
  96. janito/tools/adapters/local/python_file_run.py +163 -163
  97. janito/tools/adapters/local/remove_directory.py +6 -17
  98. janito/tools/adapters/local/remove_file.py +9 -15
  99. janito/tools/adapters/local/replace_text_in_file.py +6 -9
  100. janito/tools/adapters/local/run_bash_command.py +176 -176
  101. janito/tools/adapters/local/run_powershell_command.py +219 -219
  102. janito/tools/adapters/local/search_text/__init__.py +1 -1
  103. janito/tools/adapters/local/search_text/core.py +201 -201
  104. janito/tools/adapters/local/search_text/match_lines.py +1 -1
  105. janito/tools/adapters/local/search_text/pattern_utils.py +73 -73
  106. janito/tools/adapters/local/search_text/traverse_directory.py +145 -145
  107. janito/tools/adapters/local/validate_file_syntax/__init__.py +1 -1
  108. janito/tools/adapters/local/validate_file_syntax/core.py +106 -106
  109. janito/tools/adapters/local/validate_file_syntax/css_validator.py +35 -35
  110. janito/tools/adapters/local/validate_file_syntax/html_validator.py +93 -93
  111. janito/tools/adapters/local/validate_file_syntax/js_validator.py +27 -27
  112. janito/tools/adapters/local/validate_file_syntax/json_validator.py +6 -6
  113. janito/tools/adapters/local/validate_file_syntax/markdown_validator.py +109 -109
  114. janito/tools/adapters/local/validate_file_syntax/ps1_validator.py +32 -32
  115. janito/tools/adapters/local/validate_file_syntax/python_validator.py +5 -5
  116. janito/tools/adapters/local/validate_file_syntax/xml_validator.py +11 -11
  117. janito/tools/adapters/local/validate_file_syntax/yaml_validator.py +6 -6
  118. janito/tools/adapters/local/view_file.py +167 -167
  119. janito/tools/inspect_registry.py +17 -17
  120. janito/tools/tool_base.py +105 -105
  121. janito/tools/tool_events.py +58 -58
  122. janito/tools/tool_run_exception.py +12 -12
  123. janito/tools/tool_use_tracker.py +81 -81
  124. janito/tools/tool_utils.py +45 -45
  125. janito/tools/tools_adapter.py +78 -6
  126. janito/tools/tools_schema.py +104 -104
  127. janito/version.py +4 -4
  128. {janito-2.1.1.dist-info → janito-2.3.0.dist-info}/METADATA +388 -232
  129. janito-2.3.0.dist-info/RECORD +181 -0
  130. janito-2.3.0.dist-info/licenses/LICENSE +21 -0
  131. janito/cli/chat_mode/shell/commands/last.py +0 -137
  132. janito/drivers/google_genai/driver.py +0 -54
  133. janito/drivers/google_genai/schema_generator.py +0 -67
  134. janito-2.1.1.dist-info/RECORD +0 -181
  135. {janito-2.1.1.dist-info → janito-2.3.0.dist-info}/WHEEL +0 -0
  136. {janito-2.1.1.dist-info → janito-2.3.0.dist-info}/entry_points.txt +0 -0
  137. {janito-2.1.1.dist-info → janito-2.3.0.dist-info}/top_level.txt +0 -0
@@ -1,104 +1,104 @@
1
- import inspect
2
- import typing
3
- import re
4
-
5
-
6
- class ToolSchemaBase:
7
- def parse_param_section(self, lines, param_section_headers):
8
- param_descs = {}
9
- in_params = False
10
- for line in lines:
11
- stripped_line = line.strip()
12
- if any(
13
- stripped_line.lower().startswith(h + ":") or stripped_line.lower() == h
14
- for h in param_section_headers
15
- ):
16
- in_params = True
17
- continue
18
- if in_params:
19
- m = re.match(
20
- r"([a-zA-Z_][a-zA-Z0-9_]*)\s*(?:\(([^)]+)\))?\s*[:\-]?\s*(.+)",
21
- stripped_line,
22
- )
23
- if m:
24
- param, _, desc = m.groups()
25
- param_descs[param] = desc.strip()
26
- elif stripped_line and stripped_line[0] != "-":
27
- if param_descs:
28
- last = list(param_descs)[-1]
29
- param_descs[last] += " " + stripped_line
30
- if (
31
- stripped_line.lower().startswith("returns:")
32
- or stripped_line.lower() == "returns"
33
- ):
34
- break
35
- return param_descs
36
-
37
- def parse_return_section(self, lines):
38
- in_returns = False
39
- return_desc = ""
40
- for line in lines:
41
- stripped_line = line.strip()
42
- if (
43
- stripped_line.lower().startswith("returns:")
44
- or stripped_line.lower() == "returns"
45
- ):
46
- in_returns = True
47
- continue
48
- if in_returns:
49
- if stripped_line:
50
- return_desc += (" " if return_desc else "") + stripped_line
51
- return return_desc
52
-
53
- def parse_docstring(self, docstring: str):
54
- if not docstring:
55
- return "", {}, ""
56
- lines = docstring.strip().split("\n")
57
- summary = lines[0].strip()
58
- param_section_headers = ("args", "arguments", "params", "parameters")
59
- param_descs = self.parse_param_section(lines[1:], param_section_headers)
60
- return_desc = self.parse_return_section(lines[1:])
61
- return summary, param_descs, return_desc
62
-
63
- def validate_tool_class(self, tool_class):
64
- if not hasattr(tool_class, "tool_name") or not isinstance(
65
- tool_class.tool_name, str
66
- ):
67
- raise ValueError(
68
- "Tool class must have a class-level 'tool_name' attribute (str) for registry and schema generation."
69
- )
70
- if not hasattr(tool_class, "run") or not callable(getattr(tool_class, "run")):
71
- raise ValueError("Tool class must have a callable 'run' method.")
72
- func = tool_class.run
73
- tool_name = tool_class.tool_name
74
- sig = inspect.signature(func)
75
- if sig.return_annotation is inspect._empty or sig.return_annotation is not str:
76
- raise ValueError(
77
- f"Tool '{tool_name}' must have an explicit return type of 'str'. Found: {sig.return_annotation}"
78
- )
79
- missing_type_hints = [
80
- name
81
- for name, param in sig.parameters.items()
82
- if name != "self" and param.annotation is inspect._empty
83
- ]
84
- if missing_type_hints:
85
- raise ValueError(
86
- f"Tool '{tool_name}' is missing type hints for parameter(s): {', '.join(missing_type_hints)}.\nAll parameters must have explicit type hints for schema generation."
87
- )
88
- class_doc = (
89
- tool_class.__doc__.strip() if tool_class and tool_class.__doc__ else ""
90
- )
91
- summary, param_descs, return_desc = self.parse_docstring(class_doc)
92
- description = summary
93
- if return_desc:
94
- description += f"\n\nReturns: {return_desc}"
95
- undocumented = [
96
- name
97
- for name, param in sig.parameters.items()
98
- if name != "self" and name not in param_descs
99
- ]
100
- if undocumented:
101
- raise ValueError(
102
- f"Tool '{tool_name}' is missing docstring documentation for parameter(s): {', '.join(undocumented)}.\nParameter documentation must be provided in the Tool class docstring, not the method docstring."
103
- )
104
- return func, tool_name, sig, summary, param_descs, return_desc, description
1
+ import inspect
2
+ import typing
3
+ import re
4
+
5
+
6
+ class ToolSchemaBase:
7
+ def parse_param_section(self, lines, param_section_headers):
8
+ param_descs = {}
9
+ in_params = False
10
+ for line in lines:
11
+ stripped_line = line.strip()
12
+ if any(
13
+ stripped_line.lower().startswith(h + ":") or stripped_line.lower() == h
14
+ for h in param_section_headers
15
+ ):
16
+ in_params = True
17
+ continue
18
+ if in_params:
19
+ m = re.match(
20
+ r"([a-zA-Z_][a-zA-Z0-9_]*)\s*(?:\(([^)]+)\))?\s*[:\-]?\s*(.+)",
21
+ stripped_line,
22
+ )
23
+ if m:
24
+ param, _, desc = m.groups()
25
+ param_descs[param] = desc.strip()
26
+ elif stripped_line and stripped_line[0] != "-":
27
+ if param_descs:
28
+ last = list(param_descs)[-1]
29
+ param_descs[last] += " " + stripped_line
30
+ if (
31
+ stripped_line.lower().startswith("returns:")
32
+ or stripped_line.lower() == "returns"
33
+ ):
34
+ break
35
+ return param_descs
36
+
37
+ def parse_return_section(self, lines):
38
+ in_returns = False
39
+ return_desc = ""
40
+ for line in lines:
41
+ stripped_line = line.strip()
42
+ if (
43
+ stripped_line.lower().startswith("returns:")
44
+ or stripped_line.lower() == "returns"
45
+ ):
46
+ in_returns = True
47
+ continue
48
+ if in_returns:
49
+ if stripped_line:
50
+ return_desc += (" " if return_desc else "") + stripped_line
51
+ return return_desc
52
+
53
+ def parse_docstring(self, docstring: str):
54
+ if not docstring:
55
+ return "", {}, ""
56
+ lines = docstring.strip().split("\n")
57
+ summary = lines[0].strip()
58
+ param_section_headers = ("args", "arguments", "params", "parameters")
59
+ param_descs = self.parse_param_section(lines[1:], param_section_headers)
60
+ return_desc = self.parse_return_section(lines[1:])
61
+ return summary, param_descs, return_desc
62
+
63
+ def validate_tool_class(self, tool_class):
64
+ if not hasattr(tool_class, "tool_name") or not isinstance(
65
+ tool_class.tool_name, str
66
+ ):
67
+ raise ValueError(
68
+ "Tool class must have a class-level 'tool_name' attribute (str) for registry and schema generation."
69
+ )
70
+ if not hasattr(tool_class, "run") or not callable(getattr(tool_class, "run")):
71
+ raise ValueError("Tool class must have a callable 'run' method.")
72
+ func = tool_class.run
73
+ tool_name = tool_class.tool_name
74
+ sig = inspect.signature(func)
75
+ if sig.return_annotation is inspect._empty or sig.return_annotation is not str:
76
+ raise ValueError(
77
+ f"Tool '{tool_name}' must have an explicit return type of 'str'. Found: {sig.return_annotation}"
78
+ )
79
+ missing_type_hints = [
80
+ name
81
+ for name, param in sig.parameters.items()
82
+ if name != "self" and param.annotation is inspect._empty
83
+ ]
84
+ if missing_type_hints:
85
+ raise ValueError(
86
+ f"Tool '{tool_name}' is missing type hints for parameter(s): {', '.join(missing_type_hints)}.\nAll parameters must have explicit type hints for schema generation."
87
+ )
88
+ class_doc = (
89
+ tool_class.__doc__.strip() if tool_class and tool_class.__doc__ else ""
90
+ )
91
+ summary, param_descs, return_desc = self.parse_docstring(class_doc)
92
+ description = summary
93
+ if return_desc:
94
+ description += f"\n\nReturns: {return_desc}"
95
+ undocumented = [
96
+ name
97
+ for name, param in sig.parameters.items()
98
+ if name != "self" and name not in param_descs
99
+ ]
100
+ if undocumented:
101
+ raise ValueError(
102
+ f"Tool '{tool_name}' is missing docstring documentation for parameter(s): {', '.join(undocumented)}.\nParameter documentation must be provided in the Tool class docstring, not the method docstring."
103
+ )
104
+ return func, tool_name, sig, summary, param_descs, return_desc, description
janito/version.py CHANGED
@@ -1,4 +1,4 @@
1
- # janito/version.py
2
- """Single source of truth for the janito package version."""
3
-
4
- __version__ = "2.1.1"
1
+ # janito/version.py
2
+ """Single source of truth for the janito package version."""
3
+
4
+ __version__ = "2.3.0"