janito 3.5.1__py3-none-any.whl → 3.6.1__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/README.md +4 -4
- janito/cli/cli_commands/list_tools.py +6 -1
- janito/cli/main_cli.py +1 -1
- janito/cli/rich_terminal_reporter.py +2 -2
- janito/data/blocked.txt +96 -0
- janito/docs/GETTING_STARTED.md +8 -9
- janito/plugins/tools/__init__.py +34 -5
- janito/plugins/tools/core/__init__.py +65 -0
- janito/plugins/tools/{ask_user.py → core/ask_user.py} +1 -1
- janito/plugins/tools/{copy_file.py → core/copy_file.py} +1 -1
- janito/plugins/tools/{create_directory.py → core/create_directory.py} +1 -1
- janito/plugins/tools/{create_file.py → core/create_file.py} +2 -2
- janito/plugins/tools/{delete_text_in_file.py → core/delete_text_in_file.py} +2 -2
- janito/plugins/tools/{fetch_url.py → core/fetch_url.py} +18 -21
- janito/plugins/tools/{find_files.py → core/find_files.py} +1 -1
- janito/plugins/tools/{get_file_outline → core/get_file_outline}/core.py +1 -1
- janito/plugins/tools/{move_file.py → core/move_file.py} +1 -1
- janito/plugins/tools/{open_html_in_browser.py → core/open_html_in_browser.py} +1 -1
- janito/plugins/tools/{open_url.py → core/open_url.py} +1 -1
- janito/plugins/tools/{python_code_run.py → core/python_code_run.py} +1 -1
- janito/plugins/tools/{python_command_run.py → core/python_command_run.py} +1 -1
- janito/plugins/tools/{python_file_run.py → core/python_file_run.py} +1 -1
- janito/plugins/tools/{read_chart.py → core/read_chart.py} +1 -1
- janito/plugins/tools/{read_files.py → core/read_files.py} +1 -1
- janito/plugins/tools/{remove_directory.py → core/remove_directory.py} +1 -1
- janito/plugins/tools/{remove_file.py → core/remove_file.py} +1 -1
- janito/plugins/tools/{replace_text_in_file.py → core/replace_text_in_file.py} +2 -2
- janito/plugins/tools/{run_bash_command.py → core/run_bash_command.py} +1 -1
- janito/plugins/tools/{run_powershell_command.py → core/run_powershell_command.py} +1 -1
- janito/plugins/tools/{search_text → core/search_text}/core.py +1 -1
- janito/plugins/tools/{show_image.py → core/show_image.py} +1 -1
- janito/plugins/tools/{show_image_grid.py → core/show_image_grid.py} +1 -1
- janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/core.py +1 -1
- janito/plugins/tools/{view_file.py → core/view_file.py} +1 -1
- janito/plugins/web/webtools/__init__.py +1 -11
- janito/providers/moonshot/model_info.py +15 -4
- janito/providers/moonshot/provider.py +1 -1
- janito/tools/__init__.py +14 -4
- janito/tools/adapters/local/copy_file.py +0 -0
- janito/tools/adapters/local/create_file.py +0 -0
- janito/tools/adapters/local/move_file.py +0 -0
- janito/tools/adapters/local/remove_file.py +0 -0
- janito/tools/adapters/local/view_file.py +0 -0
- janito/tools/blocked_sites.py +74 -0
- {janito-3.5.1.dist-info → janito-3.6.1.dist-info}/METADATA +7 -8
- {janito-3.5.1.dist-info → janito-3.6.1.dist-info}/RECORD +71 -65
- janito/plugins/tools/core_tools_plugin.py +0 -87
- janito/plugins/web/webtools/tools/fetch_url.py +0 -458
- /janito/plugins/tools/{decorators.py → core/decorators.py} +0 -0
- /janito/plugins/tools/{get_file_outline → core/get_file_outline}/__init__.py +0 -0
- /janito/plugins/tools/{get_file_outline → core/get_file_outline}/java_outline.py +0 -0
- /janito/plugins/tools/{get_file_outline → core/get_file_outline}/markdown_outline.py +0 -0
- /janito/plugins/tools/{get_file_outline → core/get_file_outline}/python_outline.py +0 -0
- /janito/plugins/tools/{get_file_outline → core/get_file_outline}/search_outline.py +0 -0
- /janito/plugins/tools/{search_text → core/search_text}/__init__.py +0 -0
- /janito/plugins/tools/{search_text → core/search_text}/match_lines.py +0 -0
- /janito/plugins/tools/{search_text → core/search_text}/pattern_utils.py +0 -0
- /janito/plugins/tools/{search_text → core/search_text}/traverse_directory.py +0 -0
- /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/__init__.py +0 -0
- /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/css_validator.py +0 -0
- /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/html_validator.py +0 -0
- /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/jinja2_validator.py +0 -0
- /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/js_validator.py +0 -0
- /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/json_validator.py +0 -0
- /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/markdown_validator.py +0 -0
- /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/ps1_validator.py +0 -0
- /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/python_validator.py +0 -0
- /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/xml_validator.py +0 -0
- /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/yaml_validator.py +0 -0
- {janito-3.5.1.dist-info → janito-3.6.1.dist-info}/WHEEL +0 -0
- {janito-3.5.1.dist-info → janito-3.6.1.dist-info}/entry_points.txt +0 -0
- {janito-3.5.1.dist-info → janito-3.6.1.dist-info}/licenses/LICENSE +0 -0
- {janito-3.5.1.dist-info → janito-3.6.1.dist-info}/top_level.txt +0 -0
janito/README.md
CHANGED
@@ -26,7 +26,7 @@ pip install janito
|
|
26
26
|
janito "Create a Python script that reads a CSV file"
|
27
27
|
|
28
28
|
# Using a specific Moonshot model
|
29
|
-
janito -m kimi-
|
29
|
+
janito -m kimi-k2-0905 "Explain quantum computing"
|
30
30
|
```
|
31
31
|
|
32
32
|
**Other Providers**
|
@@ -72,14 +72,14 @@ In chat mode, you can:
|
|
72
72
|
Set default provider and model:
|
73
73
|
```bash
|
74
74
|
janito --set provider=moonshot
|
75
|
-
janito --set model=kimi-
|
75
|
+
janito --set model=kimi-k2-0905
|
76
76
|
```
|
77
77
|
|
78
78
|
## Providers
|
79
79
|
|
80
80
|
### Moonshot (Recommended)
|
81
81
|
|
82
|
-
- **Models**: kimi-
|
82
|
+
- **Models**: kimi-k2-0905, kimi-k2-turbo-preview, kimi-k2-0711-preview
|
83
83
|
- **Strengths**: Excellent Chinese/English support, competitive pricing, fast responses
|
84
84
|
- **Setup**: Get API key from [Moonshot AI Platform](https://platform.moonshot.cn/)
|
85
85
|
|
@@ -133,7 +133,7 @@ You can also configure via environment variables:
|
|
133
133
|
```bash
|
134
134
|
export MOONSHOT_API_KEY=your_key_here
|
135
135
|
export JANITO_PROVIDER=moonshot
|
136
|
-
export JANITO_MODEL=kimi-
|
136
|
+
export JANITO_MODEL=kimi-k2-0905
|
137
137
|
```
|
138
138
|
|
139
139
|
**OpenAI:**
|
@@ -76,7 +76,12 @@ def handle_list_tools(args=None):
|
|
76
76
|
DisabledToolsState.set_disabled_tools(disabled_str)
|
77
77
|
disabled_tools = DisabledToolsState.get_disabled_tools()
|
78
78
|
|
79
|
-
|
79
|
+
# Ensure tools are initialized
|
80
|
+
from janito.tools import get_local_tools_adapter
|
81
|
+
registry = get_local_tools_adapter()
|
82
|
+
if registry is None:
|
83
|
+
print("No tools available - tools initialization failed.")
|
84
|
+
return
|
80
85
|
tools = registry.list_tools()
|
81
86
|
if tools:
|
82
87
|
from rich.console import Console
|
janito/cli/main_cli.py
CHANGED
@@ -292,7 +292,7 @@ class JanitoCLI:
|
|
292
292
|
|
293
293
|
self.parser = argparse.ArgumentParser(
|
294
294
|
description="Janito CLI - A tool for running LLM-powered workflows from the command line."
|
295
|
-
"\n\nExample usage: janito -p moonshot -m kimi-
|
295
|
+
"\n\nExample usage: janito -p moonshot -m kimi-k2-0905 'Your prompt here'\n\n"
|
296
296
|
"Use -m or --model to set the model for the session.",
|
297
297
|
)
|
298
298
|
self._define_args()
|
@@ -74,8 +74,8 @@ class RichTerminalReporter(EventHandlerBase):
|
|
74
74
|
"""
|
75
75
|
Clears the entire current line in the terminal and returns the cursor to column 1.
|
76
76
|
"""
|
77
|
-
|
78
|
-
|
77
|
+
self.console.file.write("\033[2K\r")
|
78
|
+
self.console.file.flush()
|
79
79
|
|
80
80
|
def on_RequestFinished(self, event):
|
81
81
|
self.delete_current_line()
|
janito/data/blocked.txt
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# Sites known to be unexplorable due to authentication/paywall restrictions
|
2
|
+
# This list helps identify URLs that should be skipped during automated exploration
|
3
|
+
|
4
|
+
# News sites with paywalls
|
5
|
+
https://www.reuters.com
|
6
|
+
https://www.wsj.com
|
7
|
+
https://www.ft.com
|
8
|
+
https://www.thetimes.co.uk
|
9
|
+
https://www.nytimes.com
|
10
|
+
https://www.washingtonpost.com
|
11
|
+
https://www.economist.com
|
12
|
+
https://www.bloomberg.com
|
13
|
+
https://www.thestreet.com
|
14
|
+
https://www.marketwatch.com
|
15
|
+
|
16
|
+
# Academic/research databases
|
17
|
+
https://www.jstor.org
|
18
|
+
https://academic.oup.com
|
19
|
+
https://www.sciencedirect.com
|
20
|
+
https://ieeexplore.ieee.org
|
21
|
+
https://dl.acm.org
|
22
|
+
https://pubs.acs.org
|
23
|
+
https://www.nature.com
|
24
|
+
https://www.science.org
|
25
|
+
https://link.springer.com
|
26
|
+
https://onlinelibrary.wiley.com
|
27
|
+
|
28
|
+
# Social media platforms (require login)
|
29
|
+
https://www.facebook.com
|
30
|
+
https://www.twitter.com
|
31
|
+
https://www.instagram.com
|
32
|
+
https://www.linkedin.com
|
33
|
+
https://www.tiktok.com
|
34
|
+
https://www.snapchat.com
|
35
|
+
https://www.threads.net
|
36
|
+
|
37
|
+
# Streaming services
|
38
|
+
https://www.netflix.com
|
39
|
+
https://www.hulu.com
|
40
|
+
https://www.disneyplus.com
|
41
|
+
https://www.primevideo.com
|
42
|
+
https://www.hbomax.com
|
43
|
+
https://www.spotify.com
|
44
|
+
https://music.apple.com
|
45
|
+
|
46
|
+
# Cloud services requiring authentication
|
47
|
+
https://drive.google.com
|
48
|
+
https://www.dropbox.com
|
49
|
+
https://onedrive.live.com
|
50
|
+
https://www.icloud.com
|
51
|
+
https://github.com (private repos)
|
52
|
+
https://gitlab.com (private repos)
|
53
|
+
|
54
|
+
# Financial services
|
55
|
+
https://www.paypal.com
|
56
|
+
https://www.venmo.com
|
57
|
+
https://www.cash.app
|
58
|
+
https://www.zellepay.com
|
59
|
+
https://www.robinhood.com
|
60
|
+
https://www.coinbase.com
|
61
|
+
|
62
|
+
# Government services requiring login
|
63
|
+
https://www.irs.gov
|
64
|
+
https://www.ssa.gov
|
65
|
+
https://www.medicare.gov
|
66
|
+
https://www.dmv.ca.gov
|
67
|
+
https://www.gov.uk
|
68
|
+
|
69
|
+
# Shopping sites requiring accounts
|
70
|
+
https://www.amazon.com (account areas)
|
71
|
+
https://www.ebay.com (account areas)
|
72
|
+
https://www.etsy.com (account areas)
|
73
|
+
|
74
|
+
# Professional tools
|
75
|
+
https://slack.com
|
76
|
+
https://zoom.us
|
77
|
+
https://teams.microsoft.com
|
78
|
+
https://www.notion.so
|
79
|
+
https://trello.com
|
80
|
+
https://asana.com
|
81
|
+
|
82
|
+
# Dating apps
|
83
|
+
https://tinder.com
|
84
|
+
https://www.bumble.com
|
85
|
+
https://www.okcupid.com
|
86
|
+
https://match.com
|
87
|
+
https://eharmony.com
|
88
|
+
|
89
|
+
# Gaming platforms
|
90
|
+
https://www.steamcommunity.com
|
91
|
+
https://www.xbox.com
|
92
|
+
https://www.playstation.com
|
93
|
+
https://www.nintendo.com
|
94
|
+
|
95
|
+
# Note: These URLs are generally inaccessible without proper authentication
|
96
|
+
# Some may allow limited public access, but core functionality requires login
|
janito/docs/GETTING_STARTED.md
CHANGED
@@ -14,7 +14,7 @@ pip install janito
|
|
14
14
|
Janito supports multiple AI providers. Choose one to get started:
|
15
15
|
|
16
16
|
**Moonshot (Recommended for Chinese users)**
|
17
|
-
1. Go to [Moonshot AI Platform](https://platform.moonshot.
|
17
|
+
1. Go to [Moonshot AI Platform](https://platform.moonshot.ai)
|
18
18
|
2. Sign up for an account
|
19
19
|
3. Navigate to API Keys section
|
20
20
|
4. Create a new API key
|
@@ -67,7 +67,7 @@ janito "Hello, can you introduce yourself?"
|
|
67
67
|
janito "Create a Python script to calculate fibonacci numbers"
|
68
68
|
|
69
69
|
# With specific model
|
70
|
-
janito -m kimi-
|
70
|
+
janito -m kimi-k2-0905 "Explain machine learning in simple terms"
|
71
71
|
|
72
72
|
# Interactive chat mode
|
73
73
|
janito --chat
|
@@ -88,7 +88,7 @@ janito -W ./my_project "Create a REST API with FastAPI"
|
|
88
88
|
```bash
|
89
89
|
# Make your chosen provider the permanent default
|
90
90
|
janito --set provider=moonshot # or openai, ibm, etc.
|
91
|
-
janito --set model=kimi-
|
91
|
+
janito --set model=kimi-k2-0905 # or gpt-5, ibm/granite-3-8b-instruct, etc.
|
92
92
|
```
|
93
93
|
|
94
94
|
### Environment Variables
|
@@ -98,7 +98,7 @@ You can also use environment variables:
|
|
98
98
|
```bash
|
99
99
|
export MOONSHOT_API_KEY=your_key_here
|
100
100
|
export JANITO_PROVIDER=moonshot
|
101
|
-
export JANITO_MODEL=kimi-
|
101
|
+
export JANITO_MODEL=kimi-k2-0905
|
102
102
|
```
|
103
103
|
|
104
104
|
**OpenAI:**
|
@@ -120,11 +120,10 @@ export JANITO_MODEL=ibm/granite-3-3-8b-instruct
|
|
120
120
|
## Available Models by Provider
|
121
121
|
|
122
122
|
### Moonshot Models
|
123
|
-
|
124
|
-
- **kimi-
|
125
|
-
- **kimi-
|
126
|
-
- **kimi-k2-
|
127
|
-
- **kimi-k2-turbo-preview**: Turbo version of the advanced reasoning model
|
123
|
+
|
124
|
+
- **kimi-k2-0905**: Latest flagship model with 256k context and enhanced coding
|
125
|
+
- **kimi-k2-turbo-preview**: Turbo version with 128k context window
|
126
|
+
- **kimi-k2-0711-preview**: Previous preview version with 128k context window
|
128
127
|
|
129
128
|
### OpenAI Models
|
130
129
|
- **gpt-5**: Latest GPT model with advanced capabilities
|
janito/plugins/tools/__init__.py
CHANGED
@@ -1,10 +1,39 @@
|
|
1
1
|
"""
|
2
|
-
Core tools
|
2
|
+
Core tools package for janito.
|
3
3
|
|
4
|
-
This
|
5
|
-
and system interactions that are core to janito's functionality.
|
4
|
+
This package contains the essential tools for file operations, code execution,
|
5
|
+
web scraping, and system interactions that are core to janito's functionality.
|
6
6
|
"""
|
7
7
|
|
8
|
-
from .
|
8
|
+
from .core import *
|
9
9
|
|
10
|
-
__all__ = [
|
10
|
+
__all__ = [
|
11
|
+
'FetchUrl',
|
12
|
+
'AskUser',
|
13
|
+
'CopyFile',
|
14
|
+
'CreateDirectory',
|
15
|
+
'CreateFile',
|
16
|
+
'DeleteTextInFile',
|
17
|
+
'FindFiles',
|
18
|
+
'MoveFile',
|
19
|
+
'OpenHtmlInBrowser',
|
20
|
+
'OpenUrl',
|
21
|
+
'PythonCodeRun',
|
22
|
+
'PythonCommandRun',
|
23
|
+
'PythonFileRun',
|
24
|
+
'ReadChart',
|
25
|
+
'ReadFiles',
|
26
|
+
'RemoveDirectory',
|
27
|
+
'RemoveFile',
|
28
|
+
'ReplaceTextInFile',
|
29
|
+
'RunBashCommand',
|
30
|
+
'RunPowershellCommand',
|
31
|
+
'ShowImage',
|
32
|
+
'ShowImageGrid',
|
33
|
+
'ViewFile',
|
34
|
+
'ValidateFileSyntax',
|
35
|
+
'GetFileOutline',
|
36
|
+
'SearchText',
|
37
|
+
'get_core_tools',
|
38
|
+
'register_core_tool',
|
39
|
+
]
|
@@ -0,0 +1,65 @@
|
|
1
|
+
"""
|
2
|
+
Core tools for janito.
|
3
|
+
|
4
|
+
This package contains the essential tools that provide basic functionality
|
5
|
+
for file operations, code execution, web scraping, and system interactions.
|
6
|
+
"""
|
7
|
+
|
8
|
+
from .fetch_url import FetchUrl
|
9
|
+
from .ask_user import AskUser
|
10
|
+
from .copy_file import CopyFile
|
11
|
+
from .create_directory import CreateDirectory
|
12
|
+
from .create_file import CreateFile
|
13
|
+
from .delete_text_in_file import DeleteTextInFile
|
14
|
+
from .find_files import FindFiles
|
15
|
+
from .move_file import MoveFile
|
16
|
+
from .open_html_in_browser import OpenHtmlInBrowser
|
17
|
+
from .open_url import OpenUrl
|
18
|
+
from .python_code_run import PythonCodeRun
|
19
|
+
from .python_command_run import PythonCommandRun
|
20
|
+
from .python_file_run import PythonFileRun
|
21
|
+
from .read_chart import ReadChart
|
22
|
+
from .read_files import ReadFiles
|
23
|
+
from .remove_directory import RemoveDirectory
|
24
|
+
from .remove_file import RemoveFile
|
25
|
+
from .replace_text_in_file import ReplaceTextInFile
|
26
|
+
from .run_bash_command import RunBashCommand
|
27
|
+
from .run_powershell_command import RunPowershellCommand
|
28
|
+
from .show_image import ShowImage
|
29
|
+
from .show_image_grid import ShowImageGrid
|
30
|
+
from .view_file import ViewFile
|
31
|
+
from .validate_file_syntax.core import ValidateFileSyntax
|
32
|
+
from .get_file_outline.core import GetFileOutline
|
33
|
+
from .search_text.core import SearchText
|
34
|
+
from .decorators import get_core_tools, register_core_tool
|
35
|
+
|
36
|
+
__all__ = [
|
37
|
+
'FetchUrl',
|
38
|
+
'AskUser',
|
39
|
+
'CopyFile',
|
40
|
+
'CreateDirectory',
|
41
|
+
'CreateFile',
|
42
|
+
'DeleteTextInFile',
|
43
|
+
'FindFiles',
|
44
|
+
'MoveFile',
|
45
|
+
'OpenHtmlInBrowser',
|
46
|
+
'OpenUrl',
|
47
|
+
'PythonCodeRun',
|
48
|
+
'PythonCommandRun',
|
49
|
+
'PythonFileRun',
|
50
|
+
'ReadChart',
|
51
|
+
'ReadFiles',
|
52
|
+
'RemoveDirectory',
|
53
|
+
'RemoveFile',
|
54
|
+
'ReplaceTextInFile',
|
55
|
+
'RunBashCommand',
|
56
|
+
'RunPowershellCommand',
|
57
|
+
'ShowImage',
|
58
|
+
'ShowImageGrid',
|
59
|
+
'ViewFile',
|
60
|
+
'ValidateFileSyntax',
|
61
|
+
'GetFileOutline',
|
62
|
+
'SearchText',
|
63
|
+
'get_core_tools',
|
64
|
+
'register_core_tool',
|
65
|
+
]
|
@@ -1,5 +1,5 @@
|
|
1
1
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
|
-
from
|
2
|
+
from .decorators import register_core_tool
|
3
3
|
from janito.tools.loop_protection_decorator import protect_against_loops
|
4
4
|
|
5
5
|
from rich import print as rich_print
|
@@ -2,7 +2,7 @@ import os
|
|
2
2
|
from janito.tools.path_utils import expand_path
|
3
3
|
import shutil
|
4
4
|
from typing import List, Union
|
5
|
-
from
|
5
|
+
from .decorators import register_core_tool
|
6
6
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
7
7
|
from janito.tools.tool_utils import display_path
|
8
8
|
from janito.report_events import ReportAction
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import os
|
2
2
|
from janito.tools.path_utils import expand_path
|
3
|
-
from
|
3
|
+
from .decorators import register_core_tool
|
4
4
|
|
5
5
|
from janito.tools.tool_utils import display_path
|
6
6
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
@@ -8,7 +8,7 @@ from janito.report_events import ReportAction
|
|
8
8
|
from janito.i18n import tr
|
9
9
|
from janito.tools.loop_protection_decorator import protect_against_loops
|
10
10
|
|
11
|
-
from
|
11
|
+
from .validate_file_syntax.core import validate_file_syntax
|
12
12
|
|
13
13
|
|
14
14
|
@register_core_tool
|
@@ -1,9 +1,9 @@
|
|
1
1
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
|
-
from
|
3
|
+
from .decorators import register_core_tool
|
4
4
|
from janito.i18n import tr
|
5
5
|
import shutil
|
6
|
-
from
|
6
|
+
from .validate_file_syntax.core import validate_file_syntax
|
7
7
|
|
8
8
|
|
9
9
|
@register_core_tool
|
@@ -5,7 +5,7 @@ import json
|
|
5
5
|
from pathlib import Path
|
6
6
|
from bs4 import BeautifulSoup
|
7
7
|
from typing import Dict, Any, Optional
|
8
|
-
from
|
8
|
+
from .decorators import register_core_tool
|
9
9
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
10
10
|
from janito.report_events import ReportAction
|
11
11
|
from janito.i18n import tr
|
@@ -190,11 +190,23 @@ class FetchUrl(ToolBase):
|
|
190
190
|
|
191
191
|
Also implements URL whitelist checking and browser-like behavior.
|
192
192
|
"""
|
193
|
-
# Check URL whitelist
|
193
|
+
# Check URL whitelist and blocked sites
|
194
194
|
from janito.tools.url_whitelist import get_url_whitelist_manager
|
195
|
+
from janito.tools.blocked_sites import get_blocked_sites_manager
|
195
196
|
|
196
197
|
whitelist_manager = get_url_whitelist_manager()
|
198
|
+
blocked_manager = get_blocked_sites_manager()
|
197
199
|
|
200
|
+
# Check blocked sites first
|
201
|
+
if blocked_manager.is_url_blocked(url):
|
202
|
+
error_message = tr("Blocked: Site is in blocked list")
|
203
|
+
self.report_error(
|
204
|
+
tr("❗ Blocked: Site is in blocked list"),
|
205
|
+
ReportAction.READ,
|
206
|
+
)
|
207
|
+
return error_message
|
208
|
+
|
209
|
+
# Then check whitelist
|
198
210
|
if not whitelist_manager.is_url_allowed(url):
|
199
211
|
error_message = tr("Blocked")
|
200
212
|
self.report_error(
|
@@ -245,7 +257,7 @@ class FetchUrl(ToolBase):
|
|
245
257
|
self.session_cache[url] = content
|
246
258
|
return content
|
247
259
|
except requests.exceptions.HTTPError as http_err:
|
248
|
-
status_code = http_err.response.status_code if http_err.response else None
|
260
|
+
status_code = http_err.response.status_code if http_err.response is not None else None
|
249
261
|
|
250
262
|
# Map status codes to descriptions
|
251
263
|
status_descriptions = {
|
@@ -291,14 +303,7 @@ class FetchUrl(ToolBase):
|
|
291
303
|
return error_message
|
292
304
|
else:
|
293
305
|
status_code_str = str(status_code) if status_code else "Error"
|
294
|
-
description = status_descriptions.get(
|
295
|
-
status_code,
|
296
|
-
(
|
297
|
-
"Server Error"
|
298
|
-
if status_code and status_code >= 500
|
299
|
-
else "Client Error"
|
300
|
-
),
|
301
|
-
)
|
306
|
+
description = status_descriptions.get(status_code, "Error")
|
302
307
|
self.report_error(
|
303
308
|
f"❗ HTTP {status_code_str} {description}",
|
304
309
|
ReportAction.READ,
|
@@ -401,11 +406,7 @@ class FetchUrl(ToolBase):
|
|
401
406
|
cookies=cookies,
|
402
407
|
follow_redirects=follow_redirects,
|
403
408
|
)
|
404
|
-
if (
|
405
|
-
html_content.startswith("HTTP Error ")
|
406
|
-
or html_content == "Error"
|
407
|
-
or html_content == "Blocked"
|
408
|
-
):
|
409
|
+
if html_content.startswith("HTTP") or "Error" in html_content or html_content == "Blocked":
|
409
410
|
return html_content
|
410
411
|
|
411
412
|
try:
|
@@ -434,11 +435,7 @@ class FetchUrl(ToolBase):
|
|
434
435
|
cookies=cookies,
|
435
436
|
follow_redirects=follow_redirects,
|
436
437
|
)
|
437
|
-
if (
|
438
|
-
html_content.startswith("HTTP Error ")
|
439
|
-
or html_content == "Error"
|
440
|
-
or html_content == "Blocked"
|
441
|
-
):
|
438
|
+
if html_content.startswith("HTTP") or "Error" in html_content or html_content == "Blocked":
|
442
439
|
return html_content
|
443
440
|
|
444
441
|
# Extract and clean text
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
|
-
from
|
3
|
+
from .decorators import register_core_tool
|
4
4
|
from janito.tools.tool_utils import pluralize, display_path
|
5
5
|
from janito.dir_walk_utils import walk_dir_with_gitignore
|
6
6
|
from janito.i18n import tr
|
@@ -10,7 +10,7 @@ from janito.report_events import ReportAction
|
|
10
10
|
from janito.tools.tool_utils import display_path, pluralize
|
11
11
|
from janito.i18n import tr
|
12
12
|
|
13
|
-
from
|
13
|
+
from ..decorators import register_core_tool
|
14
14
|
from janito.tools.loop_protection_decorator import protect_against_loops
|
15
15
|
|
16
16
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import os
|
2
2
|
from janito.tools.path_utils import expand_path
|
3
3
|
import shutil
|
4
|
-
from
|
4
|
+
from .decorators import register_core_tool
|
5
5
|
from janito.tools.tool_utils import display_path
|
6
6
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
7
7
|
from janito.report_events import ReportAction
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import os
|
2
2
|
import webbrowser
|
3
|
-
from
|
3
|
+
from .decorators import register_core_tool
|
4
4
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
5
5
|
from janito.report_events import ReportAction
|
6
6
|
from janito.i18n import tr
|
@@ -5,7 +5,7 @@ import tempfile
|
|
5
5
|
import threading
|
6
6
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
7
7
|
from janito.report_events import ReportAction
|
8
|
-
from
|
8
|
+
from .decorators import register_core_tool
|
9
9
|
from janito.i18n import tr
|
10
10
|
|
11
11
|
|
@@ -5,7 +5,7 @@ import tempfile
|
|
5
5
|
import threading
|
6
6
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
7
7
|
from janito.report_events import ReportAction
|
8
|
-
from
|
8
|
+
from .decorators import register_core_tool
|
9
9
|
from janito.i18n import tr
|
10
10
|
|
11
11
|
|
@@ -5,7 +5,7 @@ import tempfile
|
|
5
5
|
import threading
|
6
6
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
7
7
|
from janito.report_events import ReportAction
|
8
|
-
from
|
8
|
+
from .decorators import register_core_tool
|
9
9
|
from janito.i18n import tr
|
10
10
|
|
11
11
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
|
-
from
|
3
|
+
from .decorators import register_core_tool
|
4
4
|
from janito.tools.tool_utils import display_path
|
5
5
|
from janito.i18n import tr
|
6
6
|
import json
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
|
-
from
|
3
|
+
from .decorators import register_core_tool
|
4
4
|
from janito.tools.tool_utils import pluralize
|
5
5
|
from janito.i18n import tr
|
6
6
|
from janito.tools.loop_protection_decorator import protect_against_loops
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
|
-
from
|
3
|
+
from .decorators import register_core_tool
|
4
4
|
from janito.tools.tool_utils import pluralize, display_path
|
5
5
|
from janito.i18n import tr
|
6
6
|
import shutil
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import os
|
2
2
|
from janito.tools.path_utils import expand_path
|
3
3
|
import shutil
|
4
|
-
from
|
4
|
+
from .decorators import register_core_tool
|
5
5
|
|
6
6
|
from janito.tools.tool_utils import display_path
|
7
7
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
@@ -1,10 +1,10 @@
|
|
1
1
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
|
-
from
|
3
|
+
from .decorators import register_core_tool
|
4
4
|
from janito.i18n import tr
|
5
5
|
import shutil
|
6
6
|
import re
|
7
|
-
from
|
7
|
+
from .validate_file_syntax.core import validate_file_syntax
|
8
8
|
|
9
9
|
|
10
10
|
@register_core_tool
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
|
-
from
|
3
|
+
from .decorators import register_core_tool
|
4
4
|
from janito.i18n import tr
|
5
5
|
import subprocess
|
6
6
|
import tempfile
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
|
-
from
|
3
|
+
from .decorators import register_core_tool
|
4
4
|
from janito.i18n import tr
|
5
5
|
import subprocess
|
6
6
|
import os
|
@@ -11,7 +11,7 @@ from .traverse_directory import traverse_directory
|
|
11
11
|
from janito.tools.loop_protection_decorator import protect_against_loops
|
12
12
|
|
13
13
|
|
14
|
-
from
|
14
|
+
from ..decorators import register_core_tool
|
15
15
|
|
16
16
|
|
17
17
|
@register_core_tool
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
|
-
from
|
3
|
+
from .decorators import register_core_tool
|
4
4
|
from janito.i18n import tr
|
5
5
|
from janito.tools.loop_protection_decorator import protect_against_loops
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
|
-
from
|
3
|
+
from .decorators import register_core_tool
|
4
4
|
from janito.i18n import tr
|
5
5
|
from janito.tools.loop_protection_decorator import protect_against_loops
|
6
6
|
from typing import Sequence
|
@@ -5,7 +5,7 @@ from janito.tools.tool_base import ToolBase, ToolPermissions
|
|
5
5
|
from janito.report_events import ReportAction
|
6
6
|
from janito.tools.adapters.local.adapter import register_local_tool
|
7
7
|
from janito.tools.tool_utils import display_path
|
8
|
-
from
|
8
|
+
from ..decorators import register_core_tool as register_tool
|
9
9
|
|
10
10
|
from .python_validator import validate_python
|
11
11
|
from .json_validator import validate_json
|