janito 3.5.0__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.
Files changed (78) hide show
  1. janito/README.md +4 -4
  2. janito/cli/cli_commands/list_tools.py +6 -1
  3. janito/cli/main_cli.py +1 -1
  4. janito/cli/rich_terminal_reporter.py +2 -2
  5. janito/data/blocked.txt +96 -0
  6. janito/docs/GETTING_STARTED.md +8 -9
  7. janito/plugins/core/system/tools/run_bash_command.py +23 -2
  8. janito/plugins/core/system/tools/run_powershell_command.py +16 -0
  9. janito/plugins/tools/__init__.py +34 -5
  10. janito/plugins/tools/core/__init__.py +65 -0
  11. janito/plugins/tools/{ask_user.py → core/ask_user.py} +1 -1
  12. janito/plugins/tools/{copy_file.py → core/copy_file.py} +1 -1
  13. janito/plugins/tools/{create_directory.py → core/create_directory.py} +1 -1
  14. janito/plugins/tools/{create_file.py → core/create_file.py} +2 -2
  15. janito/plugins/tools/{delete_text_in_file.py → core/delete_text_in_file.py} +2 -2
  16. janito/plugins/tools/{fetch_url.py → core/fetch_url.py} +18 -21
  17. janito/plugins/tools/{find_files.py → core/find_files.py} +1 -1
  18. janito/plugins/tools/{get_file_outline → core/get_file_outline}/core.py +1 -1
  19. janito/plugins/tools/{move_file.py → core/move_file.py} +1 -1
  20. janito/plugins/tools/{open_html_in_browser.py → core/open_html_in_browser.py} +1 -1
  21. janito/plugins/tools/{open_url.py → core/open_url.py} +1 -1
  22. janito/plugins/tools/{python_code_run.py → core/python_code_run.py} +21 -5
  23. janito/plugins/tools/{python_command_run.py → core/python_command_run.py} +19 -3
  24. janito/plugins/tools/{python_file_run.py → core/python_file_run.py} +19 -3
  25. janito/plugins/tools/{read_chart.py → core/read_chart.py} +1 -1
  26. janito/plugins/tools/{read_files.py → core/read_files.py} +1 -1
  27. janito/plugins/tools/{remove_directory.py → core/remove_directory.py} +1 -1
  28. janito/plugins/tools/{remove_file.py → core/remove_file.py} +1 -1
  29. janito/plugins/tools/{replace_text_in_file.py → core/replace_text_in_file.py} +2 -2
  30. janito/plugins/tools/{run_bash_command.py → core/run_bash_command.py} +1 -1
  31. janito/plugins/tools/{run_powershell_command.py → core/run_powershell_command.py} +1 -1
  32. janito/plugins/tools/{search_text → core/search_text}/core.py +1 -1
  33. janito/plugins/tools/{show_image.py → core/show_image.py} +1 -1
  34. janito/plugins/tools/{show_image_grid.py → core/show_image_grid.py} +1 -1
  35. janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/core.py +1 -1
  36. janito/plugins/tools/{view_file.py → core/view_file.py} +1 -1
  37. janito/plugins/web/webtools/__init__.py +1 -11
  38. janito/providers/moonshot/model_info.py +15 -4
  39. janito/providers/moonshot/provider.py +1 -1
  40. janito/tools/__init__.py +14 -4
  41. janito/tools/adapters/local/copy_file.py +0 -0
  42. janito/tools/adapters/local/create_file.py +0 -0
  43. janito/tools/adapters/local/move_file.py +0 -0
  44. janito/tools/adapters/local/remove_file.py +0 -0
  45. janito/tools/adapters/local/view_file.py +0 -0
  46. janito/tools/blocked_sites.py +74 -0
  47. {janito-3.5.0.dist-info → janito-3.6.1.dist-info}/METADATA +7 -8
  48. {janito-3.5.0.dist-info → janito-3.6.1.dist-info}/RECORD +73 -70
  49. janito/plugins/dev/pythondev/tools/python_code_run.py +0 -172
  50. janito/plugins/dev/pythondev/tools/python_command_run.py +0 -171
  51. janito/plugins/dev/pythondev/tools/python_file_run.py +0 -172
  52. janito/plugins/tools/core_tools_plugin.py +0 -87
  53. janito/plugins/web/webtools/tools/fetch_url.py +0 -458
  54. /janito/plugins/tools/{decorators.py → core/decorators.py} +0 -0
  55. /janito/plugins/tools/{get_file_outline → core/get_file_outline}/__init__.py +0 -0
  56. /janito/plugins/tools/{get_file_outline → core/get_file_outline}/java_outline.py +0 -0
  57. /janito/plugins/tools/{get_file_outline → core/get_file_outline}/markdown_outline.py +0 -0
  58. /janito/plugins/tools/{get_file_outline → core/get_file_outline}/python_outline.py +0 -0
  59. /janito/plugins/tools/{get_file_outline → core/get_file_outline}/search_outline.py +0 -0
  60. /janito/plugins/tools/{search_text → core/search_text}/__init__.py +0 -0
  61. /janito/plugins/tools/{search_text → core/search_text}/match_lines.py +0 -0
  62. /janito/plugins/tools/{search_text → core/search_text}/pattern_utils.py +0 -0
  63. /janito/plugins/tools/{search_text → core/search_text}/traverse_directory.py +0 -0
  64. /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/__init__.py +0 -0
  65. /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/css_validator.py +0 -0
  66. /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/html_validator.py +0 -0
  67. /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/jinja2_validator.py +0 -0
  68. /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/js_validator.py +0 -0
  69. /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/json_validator.py +0 -0
  70. /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/markdown_validator.py +0 -0
  71. /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/ps1_validator.py +0 -0
  72. /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/python_validator.py +0 -0
  73. /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/xml_validator.py +0 -0
  74. /janito/plugins/tools/{validate_file_syntax → core/validate_file_syntax}/yaml_validator.py +0 -0
  75. {janito-3.5.0.dist-info → janito-3.6.1.dist-info}/WHEEL +0 -0
  76. {janito-3.5.0.dist-info → janito-3.6.1.dist-info}/entry_points.txt +0 -0
  77. {janito-3.5.0.dist-info → janito-3.6.1.dist-info}/licenses/LICENSE +0 -0
  78. {janito-3.5.0.dist-info → janito-3.6.1.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,4 @@
1
- janito/README.md,sha256=Wrt6pMVT9UaXsFpoE3m9hgn28OAHWhkZ_vwWTNcSH8Q,4947
1
+ janito/README.md,sha256=F66-ZwvrjEkv7QELHKNeGh85vCc1h800oBXpUhpNbG4,4950
2
2
  janito/__init__.py,sha256=a0pFui3A_AfWJiUfg93yE-Vf4868bqG3y9yg2fkTIuY,244
3
3
  janito/__main__.py,sha256=lPQ8kAyYfyeS1KopmJ8EVY5g1YswlIqCS615mM_B_rM,70
4
4
  janito/_version.py,sha256=PtAVr2K9fOS5sv6aXzmcb7UaR5NLGMFOofL7Ndjh75o,2344
@@ -30,11 +30,11 @@ janito/cli/__init__.py,sha256=xaPDOrWphBbCR63Xpcx_yfpXSJIlCaaICc4j2qpWqrM,194
30
30
  janito/cli/config.py,sha256=HkZ14701HzIqrvaNyDcDhGlVHfpX_uHlLp2rHmhRm_k,872
31
31
  janito/cli/console.py,sha256=gJolqzWL7jEPLxeuH-CwBDRFpXt976KdZOEAB2tdBDs,64
32
32
  janito/cli/main.py,sha256=s5odou0txf8pzTf1ADk2yV7T5m8B6cejJ81e7iu776U,312
33
- janito/cli/main_cli.py,sha256=_OOQqeLiqvmYeB_928Av920Gk43rbXecMIOTL6JeT0Y,16674
33
+ janito/cli/main_cli.py,sha256=pRAID5NyKjKClVIhXhDVPs36F2_lTnfFbK2DmG1OLdQ,16676
34
34
  janito/cli/prompt_core.py,sha256=AiSoZGcyuf1sl8hKQ1kExcg-kMvO4XPN2PFHmcPGPBI,13299
35
35
  janito/cli/prompt_handler.py,sha256=SnPTlL64noeAMGlI08VBDD5IDD8jlVMIYA4-fS8zVLg,215
36
36
  janito/cli/prompt_setup.py,sha256=s48gvNfZhKjsEhf4EzL1tKIGm4wDidPMDvlM6TAPYes,2116
37
- janito/cli/rich_terminal_reporter.py,sha256=9woxYd6FTEnd-yhLYRTtTAu3V5CGAIWj4vjyEoEbYvI,6808
37
+ janito/cli/rich_terminal_reporter.py,sha256=EWVUt6A8Mx1UnzFqnI4EGlHHHc6VpXIk8p7wC9nI3-k,6822
38
38
  janito/cli/utils.py,sha256=plCQiDKIf3V8mFhhX5H9-MF2W86i-xRdWf8Xi117Z0w,677
39
39
  janito/cli/verbose_output.py,sha256=wY_B4of5e8Vv7w1fRwOZzNGU2JqbMdcFnGjtEr4hLus,7686
40
40
  janito/cli/chat_mode/bindings.py,sha256=lQYk1dJrHt4ec_RphuPlPYMG2QRoLp8Bl0mcGZqhMZE,2906
@@ -87,7 +87,7 @@ janito/cli/cli_commands/list_plugins.py,sha256=s9lZYhy8UANMj7j6c-l-nP4kJIfM_VYsG
87
87
  janito/cli/cli_commands/list_profiles.py,sha256=O4k6U9iCEeNH3lM-NP_XX_E9W0h__hheLSn23241dkA,3538
88
88
  janito/cli/cli_commands/list_providers.py,sha256=oilrBjNL5mot1nz45XQQY6oeiSxoNvphhQYspNcEJpw,391
89
89
  janito/cli/cli_commands/list_providers_region.py,sha256=qrMj_gtgEMty8UH0P_O5SgWCVJ9ZKxGUp_GdsE4_EH4,2548
90
- janito/cli/cli_commands/list_tools.py,sha256=JFRdlhPeA3BzhJ2PkjIt3u137IJoNc-vYSjUuPlaOXw,3593
90
+ janito/cli/cli_commands/list_tools.py,sha256=fljJ_0aYbsMVfQ1GBHVefSSZTwIRkKOak6kXug5g7VQ,3786
91
91
  janito/cli/cli_commands/model_selection.py,sha256=ANWtwC5glZkGMdaNtARDbEG3QmuBUcDLVxzzC5jeBNo,1643
92
92
  janito/cli/cli_commands/model_utils.py,sha256=4t2ZN8DYA8jxluXHiiliV8gMbF_90nKGtgU9VO4-gMg,5088
93
93
  janito/cli/cli_commands/ping_providers.py,sha256=hetZAKKZzQYRpRDT5OvRTOe4jYUVNZGjo8gFoyeRA3I,1921
@@ -103,7 +103,8 @@ janito/cli/core/setters.py,sha256=zjSUxy6iUzcrmEunFk7dA90KqbMaq2O7LTGP8wn2HxA,53
103
103
  janito/cli/core/unsetters.py,sha256=FEw9gCt0vRvoCt0kRSNfVB2tzi_TqppJIx2nHPP59-k,2012
104
104
  janito/cli/single_shot_mode/__init__.py,sha256=Ct99pKe9tINzVW6oedZJfzfZQKWpXz-weSSCn0hrwHY,115
105
105
  janito/cli/single_shot_mode/handler.py,sha256=d251ObY-5bkUyccV9NYkKDF0VCKrQTrGEnwt3mtj61w,5529
106
- janito/docs/GETTING_STARTED.md,sha256=Yx3vi1LQWyDWlE_JYuz4V9EL-Gh4WU6cOBqCr8XidF4,4960
106
+ janito/data/blocked.txt,sha256=3Xq5kil19cbBEkvz95w0PcfyzmLWnIwz1_GQpouuGvQ,2434
107
+ janito/docs/GETTING_STARTED.md,sha256=tzJkRRD-902jn6Mh7vy9r70dTpK1iIMkyIddB7-ScNc,4895
107
108
  janito/drivers/dashscope.bak.zip,sha256=9Pv4Xyciju8jO1lEMFVgYXexoZkxmDO3Ig6vw3ODfL8,4936
108
109
  janito/drivers/openai_responses.bak.zip,sha256=E43eDCHGa2tCtdjzj_pMnWDdnsOZzj8BJTR5tJp8wcM,13352
109
110
  janito/drivers/azure_openai/driver.py,sha256=L2rQOl1d0BHaDChHLtZszAeuWNoyYIgwuYuahE1qJps,4152
@@ -192,70 +193,66 @@ janito/plugins/core/imagedisplay/tools/__init__.py,sha256=z4xyfhiLUYaHBzus1AxaAW
192
193
  janito/plugins/core/imagedisplay/tools/show_image.py,sha256=NpQTCMfBZ4NM6DpMe0lTJYH4NHkBCruUR11E4SdLCUw,3095
193
194
  janito/plugins/core/imagedisplay/tools/show_image_grid.py,sha256=ZsTbDCBr38xYXbbAJBgRKTLuAOw-_C8799LwHA-1yYQ,3078
194
195
  janito/plugins/core/system/__init__.py,sha256=tuaUFus8jTljReloESjdYFWXIEfSEYDct59I-4gZAyc,584
195
- janito/plugins/core/system/tools/run_bash_command.py,sha256=7fABqAeAu7WJwzzwHmT54_m5OSwPMcgpQ74lQhPG7TA,7955
196
- janito/plugins/core/system/tools/run_powershell_command.py,sha256=uQSJVQe40wSGbesyvZxDmIKJthAbDJFaxXm1dEN3gBs,9313
196
+ janito/plugins/core/system/tools/run_bash_command.py,sha256=oxDbsLHkznN7WhW4WzIblABk27onJ5EgpAlzyrJ3AfU,9020
197
+ janito/plugins/core/system/tools/run_powershell_command.py,sha256=gWviIUtZvRUgde9TN_kUqYeseyVpsFmOJPMWLOb9_Nw,10152
197
198
  janito/plugins/dev/__init__.py,sha256=V7wIaP_LMGBtg6ldz5fmiWf0eL-lSz4vcFgZjKcHAZo,136
198
199
  janito/plugins/dev/pythondev/__init__.py,sha256=qAO8Ub1lwBAMcfIt6oX0clTTB2msjIIJNHBRZczhHy8,991
199
- janito/plugins/dev/pythondev/tools/python_code_run.py,sha256=HdDuiRb7Fd7WC6bFS292XnSI1EYhn9XKlh8Hs_4Cz8E,6981
200
- janito/plugins/dev/pythondev/tools/python_command_run.py,sha256=BT9emL3PsNGupkENNfUymPECiQEAm9tBhniCaOuatj0,6935
201
- janito/plugins/dev/pythondev/tools/python_file_run.py,sha256=p0iOoxByCoKqW7QqfxTdHbPbRzEd_KWyZqnzrSb1qLQ,6859
202
200
  janito/plugins/dev/visualization/__init__.py,sha256=2zJuePRWKBzuC1_XHg3cguh-JGh4GcvkdENUV3xplz4,547
203
201
  janito/plugins/dev/visualization/tools/read_chart.py,sha256=qQebp_MEE_x2AL_pl85uA58A4lbhLQsyGl7wiG_Cjhc,10411
204
- janito/plugins/tools/__init__.py,sha256=vNqUVWA0guwAYuPgdmiDsjmgibj9siP0e61pfTHZ8-8,271
205
- janito/plugins/tools/ask_user.py,sha256=7Wgl_9XEPWty3qTG_xcQdwJWypXRorMv3WYM_AZDrBY,4050
206
- janito/plugins/tools/copy_file.py,sha256=A0LxkN9b4eDBD7Ww_4LO412kldbx-DlrUELUB-27jOk,3672
207
- janito/plugins/tools/core_tools_plugin.py,sha256=QgRE3KcbF-KgRR5y-ADYeuTTLDlenxuKM-68wliVfbs,2683
208
- janito/plugins/tools/create_directory.py,sha256=f8fccqwRR3xj_IJ7KZacsxBo2k754bLgVyAefC4jsnI,2574
209
- janito/plugins/tools/create_file.py,sha256=C8w_CLMOvoxzwlsGuRKchFfbMCEgqQ-qLIxRf1j_dtc,6419
210
- janito/plugins/tools/decorators.py,sha256=BRAjjo4NF4_JxwPPVrrF2wtzsJXuZJkwv_QhZgPFMS4,382
211
- janito/plugins/tools/delete_text_in_file.py,sha256=nZb-QuJopA3NDfOW3BEsG6Aj9EaMlfpuEYiG9aGp4z4,5070
212
- janito/plugins/tools/fetch_url.py,sha256=hqtllaqx5rgZ-5wAih6-R1tvX5sIFUHy3DTP68JImQM,18202
213
- janito/plugins/tools/find_files.py,sha256=S4CLC-WmifyEIO7B1Mk52TAEpy4fIFr9GW9QVQeEE4E,6240
214
- janito/plugins/tools/move_file.py,sha256=IgBTH2V3z83K3HT0cHWxAag-E5FoUTKS5nJa-_akvvs,4685
215
- janito/plugins/tools/open_html_in_browser.py,sha256=82ONg0OSo_8puznWbrgaiZSyBK_G-TejYgsDQM8a2KU,2091
216
- janito/plugins/tools/open_url.py,sha256=X-fdPCTkJ5WBkNDAjV_XVUh3MDEuDGcv-5PbvfC8y68,1542
217
- janito/plugins/tools/python_code_run.py,sha256=mepw0_VsP-iE1uN6QoxfiRKp6jEkFLWNiGjRwUi0rDk,6971
218
- janito/plugins/tools/python_command_run.py,sha256=SxmamLHqmv6JX0VtOzM_JM2NXqHi3TM0g0duNtC8Hr4,6925
219
- janito/plugins/tools/python_file_run.py,sha256=y6oj636Ue0c5ybylDu4l7n-heLhegMGn1CP_B0_hc-M,6849
220
- janito/plugins/tools/read_chart.py,sha256=8KT-Zzfpdp68QN6Pl8enDLPrKRBY2lhcKsJ8scS6i3o,10401
221
- janito/plugins/tools/read_files.py,sha256=7RVj4qescT__VHe1k_VdnpHKHY5YeG0fqPiNIopd3Is,2319
222
- janito/plugins/tools/remove_directory.py,sha256=jmY0pSrOJVQqR-_P7OuZijovAKkNB5cDk8BAAKVvvLI,1903
223
- janito/plugins/tools/remove_file.py,sha256=tWjCx96O2cFW3XIpx8U5W2JUzbfsoXY5zn8k3jr4AIA,2083
224
- janito/plugins/tools/replace_text_in_file.py,sha256=F7RvMdA0EM9xDtM7lB_0DrMjDeYa8exn73_15SQ0iug,10949
225
- janito/plugins/tools/run_bash_command.py,sha256=r-zjfDmw7z2H08cNqKHxXov1_KvfmjPeL5IEg4ZDTxQ,7945
226
- janito/plugins/tools/run_powershell_command.py,sha256=3CWvSr9IkCX6yJ3P_cP80QYUZg30m5TREAPOpzzqYrM,9303
227
- janito/plugins/tools/show_image.py,sha256=v-vEP5LG2-YjrcoWTfgXQ8jSlXfslXjWVV6Uaq7N4IA,3052
228
- janito/plugins/tools/show_image_grid.py,sha256=eS9PGcGrIqazX1fBSu39N3RaQlFoeIdVc75z2ruhWeI,3118
229
- janito/plugins/tools/view_file.py,sha256=SlTfdKyEnaqhDnPc7gpBC51JWIkdc3WvYsTq3amEN4g,7369
230
- janito/plugins/tools/get_file_outline/__init__.py,sha256=po2B4UWf4qvw3yisWkiW1VeeFl1SGvm4xhs1kNbNyCc,110
231
- janito/plugins/tools/get_file_outline/core.py,sha256=KHZwnRdgRzyEJe0IjKzjxs8TQBJdU7xYTDWnqQgZVhM,4590
232
- janito/plugins/tools/get_file_outline/java_outline.py,sha256=_UeUY5JoQEUdlHcK8aqGTqYJl0T2KxIFXPTdwum9gKQ,1825
233
- janito/plugins/tools/get_file_outline/markdown_outline.py,sha256=bXEBg0D93tEBDNy8t-wh4i7WxsxfpQ2C3dX1_rmtj08,434
234
- janito/plugins/tools/get_file_outline/python_outline.py,sha256=RAcf9Vxec08lA06drYaNre5HCJ2lTzrRAskZ3rlyE-U,10326
235
- janito/plugins/tools/get_file_outline/search_outline.py,sha256=bski24TpnJVf3L0TNzkx3HfvaXwttQl4EVkwk2POQOw,1348
236
- janito/plugins/tools/search_text/__init__.py,sha256=pZo-65KTw9y0oFBCBXEyxACbS10QvAXa21icXuRyh34,101
237
- janito/plugins/tools/search_text/core.py,sha256=bjXWCkGEkCnX-q60N3prU_EYiN5i8Sw_7ArTvq18pco,7856
238
- janito/plugins/tools/search_text/match_lines.py,sha256=RLR8fZFP-Q57rY0fTENbMItmt3dJZiYX0otmGHVRjfw,2131
239
- janito/plugins/tools/search_text/pattern_utils.py,sha256=D7vtAr8oT0tGV0C_UUarAXS9XQtP-MTYmmc8Yg8iVTg,2362
240
- janito/plugins/tools/search_text/traverse_directory.py,sha256=EpL1qywAV0H29pm8-QsHrjKchKP4i4sRUOENVuNptCo,4000
241
- janito/plugins/tools/validate_file_syntax/__init__.py,sha256=1Fp7sHG_ndTJi9xbUzpFSp9TSW-DpwN2n_psZM8mXmw,128
242
- janito/plugins/tools/validate_file_syntax/core.py,sha256=E8g67nRv5x_PomKm8IlUdQlYyjC3l3IdSTBlODKPn6Y,3705
243
- janito/plugins/tools/validate_file_syntax/css_validator.py,sha256=jE5d26C_fU9k9azujbGVISn2WIRL-Ys6de4dsCq30bo,1351
244
- janito/plugins/tools/validate_file_syntax/html_validator.py,sha256=VV93BRcAeUraXHc9dUyH1cs9gRwRwO84K1-L5zbJnYU,3207
245
- janito/plugins/tools/validate_file_syntax/jinja2_validator.py,sha256=lfM0SsKsFygiEp1IuLNr5jdS7XJyjCLOPw2yo9vl-pY,1763
246
- janito/plugins/tools/validate_file_syntax/js_validator.py,sha256=42LvgyMVhG9c2EAaSz3J9pu-yuh1oyIvRp0wN2rHiDQ,998
247
- janito/plugins/tools/validate_file_syntax/json_validator.py,sha256=muCB0-bdxk9zNulzH1It3hWpYzJC3hD8LbxCnE0P5is,150
248
- janito/plugins/tools/validate_file_syntax/markdown_validator.py,sha256=k4UT88fXvtclygz-nFhCMHJL5sk5WlGD-fP_cWqWMyU,3511
249
- janito/plugins/tools/validate_file_syntax/ps1_validator.py,sha256=TeIkPt08t_-w2JiKksXHHK9lJNT348ZDkWoSTzMtRrI,1152
250
- janito/plugins/tools/validate_file_syntax/python_validator.py,sha256=BfCO_K18qy92m-2ZVvHsbEU5e11OPo1pO9Vz4G4616E,130
251
- janito/plugins/tools/validate_file_syntax/xml_validator.py,sha256=AijlsP_PgNuC8ZbGsC5vOTt3Jur76otQzkd_7qR0QFY,284
252
- janito/plugins/tools/validate_file_syntax/yaml_validator.py,sha256=TgyI0HRL6ug_gBcWEm5TGJJuA4E34ZXcIzMpAbv3oJs,155
202
+ janito/plugins/tools/__init__.py,sha256=ZNAIrOSWmpF05ATQ91lT9esapWt-DeFVC9mLkXVflhU,842
203
+ janito/plugins/tools/core/__init__.py,sha256=u6glCTNvcaT_CJb8vr62gZVUzI8QkYMe7PVfWywtZZA,1961
204
+ janito/plugins/tools/core/ask_user.py,sha256=AEJUExJ7yVNMT3AyC-Qn-EU1kcPI5h5KfiLm66rNTgc,4030
205
+ janito/plugins/tools/core/copy_file.py,sha256=PdqGfIIl3LyR7fwO2rbyyT4pHnBhn__xyduSA13BmvU,3652
206
+ janito/plugins/tools/core/create_directory.py,sha256=63cfJD-yR5ovj3cLI_M4RlaxTdLKj2BYL5OBo7RgR14,2554
207
+ janito/plugins/tools/core/create_file.py,sha256=xG1IlOdWjofUDeLgCq-TBFkMNRb2x5VfCx0Wf5iTT5o,6379
208
+ janito/plugins/tools/core/decorators.py,sha256=BRAjjo4NF4_JxwPPVrrF2wtzsJXuZJkwv_QhZgPFMS4,382
209
+ janito/plugins/tools/core/delete_text_in_file.py,sha256=eLv5CuBIS_bWioNdFcTafJVdRyrqnT29MylW4ziB3Jc,5030
210
+ janito/plugins/tools/core/fetch_url.py,sha256=uvVLP3p5WKJA04x9lMZtqKCUCI25Zo-AQ_UVzuaxweQ,18346
211
+ janito/plugins/tools/core/find_files.py,sha256=CXBoWA00SYUbHE0Sb7_L3UEcGWClhbTOx7eCyslCi0s,6220
212
+ janito/plugins/tools/core/move_file.py,sha256=dcyVJjzRG7ooGzbSyg13hTWhJGyb8yL5dH9EZsi9zPg,4665
213
+ janito/plugins/tools/core/open_html_in_browser.py,sha256=sq2hyxL5KIKWkMcPr0xt7_Bb3-ledZvxThuHJLJJMAc,2071
214
+ janito/plugins/tools/core/open_url.py,sha256=HNHODd_NujeJCgdME1icazyHLMDlEJc_Wqj2uj7-jP4,1522
215
+ janito/plugins/tools/core/python_code_run.py,sha256=6eR3Ne4bAYtlHXU4tfEafR3kkxPbkrsjbfSD3yMSgEs,7695
216
+ janito/plugins/tools/core/python_command_run.py,sha256=jkYxtDyNwv57PZMP-nc3r-g32840jWR7ok1UghSZxUY,7625
217
+ janito/plugins/tools/core/python_file_run.py,sha256=KdQokh1y6yBIThAprdYRfe-sNFdsZeutrtmjWh9vHV8,7549
218
+ janito/plugins/tools/core/read_chart.py,sha256=eTPTQCpSVtMtfZJvU5DL0-73ytJJ16C3PRk7mHMbvY8,10381
219
+ janito/plugins/tools/core/read_files.py,sha256=q61N1PHO08-holujVpUElpMS9x4DqmTRTQuxM70Pa48,2299
220
+ janito/plugins/tools/core/remove_directory.py,sha256=OGcccTXG7JkWLBKFBqzpxhUx0kGi9LyyOmGVg6sT-P4,1883
221
+ janito/plugins/tools/core/remove_file.py,sha256=o6bTaG3nbyMOBNPgCXUgczVtxnius7C12Z4vCeOtILg,2063
222
+ janito/plugins/tools/core/replace_text_in_file.py,sha256=BIctL2LQXYE6OLuNjJuh8FKwZHZ1iwRIZOBd0PWhpSc,10909
223
+ janito/plugins/tools/core/run_bash_command.py,sha256=yGCxf17pb9UNKg4X6PUkvHl9myYgsCkOY_zxLSKtM3s,7925
224
+ janito/plugins/tools/core/run_powershell_command.py,sha256=hUvBTgjwzbX5h1V7FyaZZWebhQCKdkjxCyU28vG7Klg,9283
225
+ janito/plugins/tools/core/show_image.py,sha256=Eb8UjwDjO0TWwrRzYxkOFQi25Yql3vzammQe45yI0iw,3032
226
+ janito/plugins/tools/core/show_image_grid.py,sha256=rW8c5WPn6zY-G2MsCsoJXIe0LwLyH2fUBqcpoSiCVqw,3098
227
+ janito/plugins/tools/core/view_file.py,sha256=8Q0s_GgVWE_Bholtv0YyHIB_v1v_jHg9JGQAI3jUsgI,7349
228
+ janito/plugins/tools/core/get_file_outline/__init__.py,sha256=po2B4UWf4qvw3yisWkiW1VeeFl1SGvm4xhs1kNbNyCc,110
229
+ janito/plugins/tools/core/get_file_outline/core.py,sha256=55miu8PS1Xx03U_bZgPuMy2XTM4Y1op6tr5kHudh578,4571
230
+ janito/plugins/tools/core/get_file_outline/java_outline.py,sha256=_UeUY5JoQEUdlHcK8aqGTqYJl0T2KxIFXPTdwum9gKQ,1825
231
+ janito/plugins/tools/core/get_file_outline/markdown_outline.py,sha256=bXEBg0D93tEBDNy8t-wh4i7WxsxfpQ2C3dX1_rmtj08,434
232
+ janito/plugins/tools/core/get_file_outline/python_outline.py,sha256=RAcf9Vxec08lA06drYaNre5HCJ2lTzrRAskZ3rlyE-U,10326
233
+ janito/plugins/tools/core/get_file_outline/search_outline.py,sha256=bski24TpnJVf3L0TNzkx3HfvaXwttQl4EVkwk2POQOw,1348
234
+ janito/plugins/tools/core/search_text/__init__.py,sha256=pZo-65KTw9y0oFBCBXEyxACbS10QvAXa21icXuRyh34,101
235
+ janito/plugins/tools/core/search_text/core.py,sha256=x4A3A_NWGa-ddix_wvZLL6DJjC3HJfQb_ktYjA9-Pvg,7837
236
+ janito/plugins/tools/core/search_text/match_lines.py,sha256=RLR8fZFP-Q57rY0fTENbMItmt3dJZiYX0otmGHVRjfw,2131
237
+ janito/plugins/tools/core/search_text/pattern_utils.py,sha256=D7vtAr8oT0tGV0C_UUarAXS9XQtP-MTYmmc8Yg8iVTg,2362
238
+ janito/plugins/tools/core/search_text/traverse_directory.py,sha256=EpL1qywAV0H29pm8-QsHrjKchKP4i4sRUOENVuNptCo,4000
239
+ janito/plugins/tools/core/validate_file_syntax/__init__.py,sha256=1Fp7sHG_ndTJi9xbUzpFSp9TSW-DpwN2n_psZM8mXmw,128
240
+ janito/plugins/tools/core/validate_file_syntax/core.py,sha256=9JUd62fSYzB2C74pWiCckzPtUIhbe2xW4BX4ahxLApA,3686
241
+ janito/plugins/tools/core/validate_file_syntax/css_validator.py,sha256=jE5d26C_fU9k9azujbGVISn2WIRL-Ys6de4dsCq30bo,1351
242
+ janito/plugins/tools/core/validate_file_syntax/html_validator.py,sha256=VV93BRcAeUraXHc9dUyH1cs9gRwRwO84K1-L5zbJnYU,3207
243
+ janito/plugins/tools/core/validate_file_syntax/jinja2_validator.py,sha256=lfM0SsKsFygiEp1IuLNr5jdS7XJyjCLOPw2yo9vl-pY,1763
244
+ janito/plugins/tools/core/validate_file_syntax/js_validator.py,sha256=42LvgyMVhG9c2EAaSz3J9pu-yuh1oyIvRp0wN2rHiDQ,998
245
+ janito/plugins/tools/core/validate_file_syntax/json_validator.py,sha256=muCB0-bdxk9zNulzH1It3hWpYzJC3hD8LbxCnE0P5is,150
246
+ janito/plugins/tools/core/validate_file_syntax/markdown_validator.py,sha256=k4UT88fXvtclygz-nFhCMHJL5sk5WlGD-fP_cWqWMyU,3511
247
+ janito/plugins/tools/core/validate_file_syntax/ps1_validator.py,sha256=TeIkPt08t_-w2JiKksXHHK9lJNT348ZDkWoSTzMtRrI,1152
248
+ janito/plugins/tools/core/validate_file_syntax/python_validator.py,sha256=BfCO_K18qy92m-2ZVvHsbEU5e11OPo1pO9Vz4G4616E,130
249
+ janito/plugins/tools/core/validate_file_syntax/xml_validator.py,sha256=AijlsP_PgNuC8ZbGsC5vOTt3Jur76otQzkd_7qR0QFY,284
250
+ janito/plugins/tools/core/validate_file_syntax/yaml_validator.py,sha256=TgyI0HRL6ug_gBcWEm5TGJJuA4E34ZXcIzMpAbv3oJs,155
253
251
  janito/plugins/ui/__init__.py,sha256=V3bXCQO9YyWc6oiPKyXRP6YqJT_LT9330b3uukSzJ_8,122
254
252
  janito/plugins/ui/userinterface/__init__.py,sha256=kmno20y5PuZvv_eqDWPKEcN6Zo_vlyt-WZv-4A5e8UI,352
255
253
  janito/plugins/ui/userinterface/tools/ask_user.py,sha256=4xY8SUndw_OYAPzeIRxugmihxxn7Y-b2v9xYT_LGdkY,3941
256
254
  janito/plugins/web/__init__.py,sha256=gVPBgz06iQgBUlqHJt3TpWQErkbH_Cx_6BX6XVSYtcY,118
257
- janito/plugins/web/webtools/__init__.py,sha256=vGFtbZvV2DnooPmw4B8hHd0UgpVfNugLs8uK0sI9N2w,847
258
- janito/plugins/web/webtools/tools/fetch_url.py,sha256=VjB89FjLNrqLmOVL6wm1RHyixB3n-RViC0DJjW33iRM,17804
255
+ janito/plugins/web/webtools/__init__.py,sha256=akymnsZCF1a9260obArMxt8qgbGpkAJTQCudqdMJivs,556
259
256
  janito/plugins/web/webtools/tools/open_html_in_browser.py,sha256=XqICIwVx5vEE77gHkaNAC-bAeEEy0DBmDksATiL-sRY,2101
260
257
  janito/plugins/web/webtools/tools/open_url.py,sha256=V3Sv7iLynUreLjVl5-bl-XFH_LzpTeBrS8-cvzp_7rM,1552
261
258
  janito/providers/__init__.py,sha256=LZcyllhmGyOXQ8duQA2Qbg0fSrahog5ATNZppNOxFK0,571
@@ -285,8 +282,8 @@ janito/providers/mistral/__init__.py,sha256=jFHSvtQro8BnHajv7M0Zf9vssXyTzLxyN2J-
285
282
  janito/providers/mistral/model_info.py,sha256=yeCg30ZjJ-HL4QaH7YjADKReINkDMmA3Cj28g7MyMP0,2268
286
283
  janito/providers/mistral/provider.py,sha256=rBFrwT40vnPi-whNCMI8o-OurIdCRxm3tkgPXBDB3Gk,4775
287
284
  janito/providers/moonshot/__init__.py,sha256=QBirGjijujOZuJ1UZ8c7MflSy5EHjWnuBmAr3AupbH0,29
288
- janito/providers/moonshot/model_info.py,sha256=PpdUkmuR7g6SyiEzS9nePskPjn5xI1ZM2RbHSHpyK3w,712
289
- janito/providers/moonshot/provider.py,sha256=LJxNoC7Oo-ZoFKs2ulK2lXzUEx7kV-79HJ8JG4J-UWU,3856
285
+ janito/providers/moonshot/model_info.py,sha256=vkMQGMhp3BbKL336n4M-GTHOySc3WrBD1K85Z7hCLzo,1014
286
+ janito/providers/moonshot/provider.py,sha256=vkZ7sqL4yN5o5a_YbI_Q0CXNrcQGegviLZXhQ0Js4_I,3847
290
287
  janito/providers/openai/__init__.py,sha256=f0m16-sIqScjL9Mp4A0CQBZx6H3PTEy0cnE08jeaB5U,38
291
288
  janito/providers/openai/model_info.py,sha256=VTkq3xcx2vk0tXlFVHQxKeFzl-DL1T1J2elVOEwCdHI,4265
292
289
  janito/providers/openai/provider.py,sha256=PPr_qmSe5GyysnZCxhjeUVhE2LWKjKOSRel-8aaxq_U,4761
@@ -304,8 +301,9 @@ janito/regions/geo_utils.py,sha256=nLJ2x0tx1xMNI0_cMEiji-X8denynsaPYmXR9gGg8uk,5
304
301
  janito/regions/provider_regions.py,sha256=QJdbsdgjg-WcTRqPLGtm3pHJAm2o0-Y9MgE_vNzENEk,4619
305
302
  janito/tools/DOCSTRING_STANDARD.txt,sha256=VLPwNgjxRVD_xZSSVvUZ4H-4bBwM-VKh_RyfzYQsYSs,1735
306
303
  janito/tools/README.md,sha256=5HkLpF5k4PENJER7SlDPRXj0yo9mpHvAHW4uuzhq4ak,115
307
- janito/tools/__init__.py,sha256=PoMIw_JgsEGP5SO77mqsZFl0Z-p2W2WnyHaaAKSnirk,1961
304
+ janito/tools/__init__.py,sha256=_B8-Q2jdfwPPxGoKUXxSbpJgcq1Sc74RsMTb9nCB_Tw,2377
308
305
  janito/tools/base.py,sha256=R38A9xWYh3JRYZMDSom2d1taNDy9J7HpLbZo9X2wH_o,316
306
+ janito/tools/blocked_sites.py,sha256=SPq8XznJkDaJ_NIHFHPfsRb1KzySk4W_NVyGGlaRZf0,2721
309
307
  janito/tools/cli_initializer.py,sha256=KJbUL6_iAsaeBZl_AVrdtczSZRQBJ9RPZufHJVKwAtU,2632
310
308
  janito/tools/disabled_tools.py,sha256=Tx__16wtMWZ9z34cYLdH1gukwot5MCL-9kLjd5MPX6Y,2110
311
309
  janito/tools/initialize.py,sha256=BSwzCPCmis2n4q5W3tWBEr4MgVS4tAwBjfKoNM4CefI,2002
@@ -328,9 +326,14 @@ janito/tools/url_whitelist.py,sha256=0CPLkHTp5HgnwgjxwgXnJmwPeZQ30q4j3YjW59hiUUE
328
326
  janito/tools/adapters/__init__.py,sha256=H25uYM2ETMLKpKPPEPAu9-AFjxkKfSyfx3pnoXSQlVA,255
329
327
  janito/tools/adapters/local/__init__.py,sha256=1DVnka4iEQp8Xrs7rJVVx45fPpuVahjTFmuJhv-gN8s,249
330
328
  janito/tools/adapters/local/adapter.py,sha256=u4nLHTaYdwZXMi1J8lsKvlG6rOmdq9xjey_3zeyCG4k,8707
331
- janito-3.5.0.dist-info/licenses/LICENSE,sha256=dXV4fOF2ZErugtN8l_Nrj5tsRTYgtjE3cgiya0UfBio,11356
332
- janito-3.5.0.dist-info/METADATA,sha256=voeu6zQPSo_wytQfWnCUoe6wYviDtAxgX_f9ktc6N_g,6093
333
- janito-3.5.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
334
- janito-3.5.0.dist-info/entry_points.txt,sha256=wIo5zZxbmu4fC-ZMrsKD0T0vq7IqkOOLYhrqRGypkx4,48
335
- janito-3.5.0.dist-info/top_level.txt,sha256=m0NaVCq0-ivxbazE2-ND0EA9Hmuijj_OGkmCbnBcCig,7
336
- janito-3.5.0.dist-info/RECORD,,
329
+ janito/tools/adapters/local/copy_file.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
330
+ janito/tools/adapters/local/create_file.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
331
+ janito/tools/adapters/local/move_file.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
332
+ janito/tools/adapters/local/remove_file.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
333
+ janito/tools/adapters/local/view_file.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
334
+ janito-3.6.1.dist-info/licenses/LICENSE,sha256=dXV4fOF2ZErugtN8l_Nrj5tsRTYgtjE3cgiya0UfBio,11356
335
+ janito-3.6.1.dist-info/METADATA,sha256=RYuWCoaMdEUxuCs94DyZ90cb6sStUHdCs8rM8p5755s,6071
336
+ janito-3.6.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
337
+ janito-3.6.1.dist-info/entry_points.txt,sha256=wIo5zZxbmu4fC-ZMrsKD0T0vq7IqkOOLYhrqRGypkx4,48
338
+ janito-3.6.1.dist-info/top_level.txt,sha256=m0NaVCq0-ivxbazE2-ND0EA9Hmuijj_OGkmCbnBcCig,7
339
+ janito-3.6.1.dist-info/RECORD,,
@@ -1,172 +0,0 @@
1
- import subprocess
2
- import os
3
- import sys
4
- import tempfile
5
- import threading
6
- from janito.tools.tool_base import ToolBase, ToolPermissions
7
- from janito.report_events import ReportAction
8
- from janito.tools.adapters.local.adapter import register_local_tool
9
- from janito.i18n import tr
10
-
11
-
12
- @register_local_tool
13
- class PythonCodeRunTool(ToolBase):
14
- """
15
- Tool to execute Python code by passing it to the interpreter via standard input (stdin).
16
-
17
- Args:
18
- code (str): The Python code to execute as a string.
19
- timeout (int): Timeout in seconds for the command. Defaults to 60.
20
- silent (bool): If True, suppresses progress and status messages. Defaults to False.
21
-
22
- Returns:
23
- str: Output and status message, or file paths/line counts if output is large.
24
- """
25
-
26
- permissions = ToolPermissions(execute=True)
27
- tool_name = "python_code_run"
28
-
29
- def run(self, code: str, timeout: int = 60, silent: bool = False) -> str:
30
- if not code.strip():
31
- self.report_warning(tr("ℹ️ Empty code provided."), ReportAction.EXECUTE)
32
- return tr("Warning: Empty code provided. Operation skipped.")
33
- if not silent:
34
- self.report_action(
35
- tr("⚡ Running: python (stdin mode) ...\n{code}\n", code=code),
36
- ReportAction.EXECUTE,
37
- )
38
- self.report_stdout("\n")
39
- else:
40
- self.report_action(tr("⚡ Executing..."), ReportAction.EXECUTE)
41
- try:
42
- with (
43
- tempfile.NamedTemporaryFile(
44
- mode="w+",
45
- prefix="python_stdin_stdout_",
46
- delete=False,
47
- encoding="utf-8",
48
- ) as stdout_file,
49
- tempfile.NamedTemporaryFile(
50
- mode="w+",
51
- prefix="python_stdin_stderr_",
52
- delete=False,
53
- encoding="utf-8",
54
- ) as stderr_file,
55
- ):
56
- process = subprocess.Popen(
57
- [sys.executable],
58
- stdin=subprocess.PIPE,
59
- stdout=subprocess.PIPE,
60
- stderr=subprocess.PIPE,
61
- text=True,
62
- bufsize=1,
63
- universal_newlines=True,
64
- encoding="utf-8",
65
- env={**os.environ, "PYTHONIOENCODING": "utf-8"},
66
- )
67
- stdout_lines, stderr_lines = self._stream_process_output(
68
- process, stdout_file, stderr_file, code
69
- )
70
- return_code = self._wait_for_process(process, timeout)
71
- if return_code is None:
72
- return tr(
73
- "Code timed out after {timeout} seconds.", timeout=timeout
74
- )
75
- stdout_file.flush()
76
- stderr_file.flush()
77
- if not silent:
78
- self.report_success(
79
- tr("✅ Return code {return_code}", return_code=return_code),
80
- ReportAction.EXECUTE,
81
- )
82
- return self._format_result(
83
- stdout_file.name, stderr_file.name, return_code
84
- )
85
- except Exception as e:
86
- self.report_error(tr("❌ Error: {error}", error=e), ReportAction.EXECUTE)
87
- return tr("Error running code via stdin: {error}", error=e)
88
-
89
- def _stream_process_output(self, process, stdout_file, stderr_file, code):
90
- stdout_lines = 0
91
- stderr_lines = 0
92
-
93
- def stream_output(stream, file_obj, report_func, count_func):
94
- nonlocal stdout_lines, stderr_lines
95
- for line in stream:
96
- file_obj.write(line)
97
- file_obj.flush()
98
- report_func(line.rstrip("\r\n"))
99
- if count_func == "stdout":
100
- stdout_lines += 1
101
- else:
102
- stderr_lines += 1
103
-
104
- stdout_thread = threading.Thread(
105
- target=stream_output,
106
- args=(process.stdout, stdout_file, self.report_stdout, "stdout"),
107
- )
108
- stderr_thread = threading.Thread(
109
- target=stream_output,
110
- args=(process.stderr, stderr_file, self.report_stderr, "stderr"),
111
- )
112
- stdout_thread.start()
113
- stderr_thread.start()
114
- process.stdin.write(code)
115
- process.stdin.close()
116
- stdout_thread.join()
117
- stderr_thread.join()
118
- return stdout_lines, stderr_lines
119
-
120
- def _wait_for_process(self, process, timeout):
121
- try:
122
- return process.wait(timeout=timeout)
123
- except subprocess.TimeoutExpired:
124
- process.kill()
125
- self.report_error(
126
- tr("❌ Timed out after {timeout} seconds.", timeout=timeout),
127
- ReportAction.EXECUTE,
128
- )
129
- return None
130
-
131
- def _format_result(self, stdout_file_name, stderr_file_name, return_code):
132
- with open(stdout_file_name, "r", encoding="utf-8", errors="replace") as out_f:
133
- stdout_content = out_f.read()
134
- with open(stderr_file_name, "r", encoding="utf-8", errors="replace") as err_f:
135
- stderr_content = err_f.read()
136
- max_lines = 100
137
- stdout_lines = stdout_content.count("\n")
138
- stderr_lines = stderr_content.count("\n")
139
-
140
- def head_tail(text, n=10):
141
- lines = text.splitlines()
142
- if len(lines) <= 2 * n:
143
- return "\n".join(lines)
144
- return "\n".join(
145
- lines[:n]
146
- + ["... ({} lines omitted) ...".format(len(lines) - 2 * n)]
147
- + lines[-n:]
148
- )
149
-
150
- if stdout_lines <= max_lines and stderr_lines <= max_lines:
151
- result = f"Return code: {return_code}\n--- python_code_run: STDOUT ---\n{stdout_content}"
152
- if stderr_content.strip():
153
- result += f"\n--- python_code_run: STDERR ---\n{stderr_content}"
154
- return result
155
- else:
156
- result = f"stdout_file: {stdout_file_name} (lines: {stdout_lines})\n"
157
- if stderr_lines > 0 and stderr_content.strip():
158
- result += f"stderr_file: {stderr_file_name} (lines: {stderr_lines})\n"
159
- result += f"returncode: {return_code}\n"
160
- result += (
161
- "--- python_code_run: STDOUT (head/tail) ---\n"
162
- + head_tail(stdout_content)
163
- + "\n"
164
- )
165
- if stderr_content.strip():
166
- result += (
167
- "--- python_code_run: STDERR (head/tail) ---\n"
168
- + head_tail(stderr_content)
169
- + "\n"
170
- )
171
- result += "Use the view_file tool to inspect the contents of these files when needed."
172
- return result
@@ -1,171 +0,0 @@
1
- import subprocess
2
- import os
3
- import sys
4
- import tempfile
5
- import threading
6
- from janito.tools.tool_base import ToolBase, ToolPermissions
7
- from janito.report_events import ReportAction
8
- from janito.tools.adapters.local.adapter import register_local_tool
9
- from janito.i18n import tr
10
-
11
-
12
- @register_local_tool
13
- class PythonCommandRunTool(ToolBase):
14
- """
15
- Tool to execute Python code using the `python -c` command-line flag.
16
-
17
- Args:
18
- code (str): The Python code to execute as a string.
19
- timeout (int): Timeout in seconds for the command. Defaults to 60.
20
- silent (bool): If True, suppresses progress and status messages. Defaults to False.
21
-
22
- Returns:
23
- str: Output and status message, or file paths/line counts if output is large.
24
- """
25
-
26
- permissions = ToolPermissions(execute=True)
27
- tool_name = "python_command_run"
28
-
29
- def run(self, code: str, timeout: int = 60, silent: bool = False) -> str:
30
- if not code.strip():
31
- self.report_warning(tr("ℹ️ Empty code provided."), ReportAction.EXECUTE)
32
- return tr("Warning: Empty code provided. Operation skipped.")
33
- if not silent:
34
- self.report_action(
35
- tr("🐍 Running: python -c ...\n{code}\n", code=code),
36
- ReportAction.EXECUTE,
37
- )
38
- self.report_stdout("\n")
39
- else:
40
- self.report_action(tr("⚡ Executing..."), ReportAction.EXECUTE)
41
- try:
42
- with (
43
- tempfile.NamedTemporaryFile(
44
- mode="w+",
45
- prefix="python_cmd_stdout_",
46
- delete=False,
47
- encoding="utf-8",
48
- ) as stdout_file,
49
- tempfile.NamedTemporaryFile(
50
- mode="w+",
51
- prefix="python_cmd_stderr_",
52
- delete=False,
53
- encoding="utf-8",
54
- ) as stderr_file,
55
- ):
56
- process = subprocess.Popen(
57
- [sys.executable, "-c", code],
58
- stdout=subprocess.PIPE,
59
- stderr=subprocess.PIPE,
60
- text=True,
61
- bufsize=1,
62
- universal_newlines=True,
63
- encoding="utf-8",
64
- env={**os.environ, "PYTHONIOENCODING": "utf-8"},
65
- )
66
- stdout_lines, stderr_lines = self._stream_process_output(
67
- process, stdout_file, stderr_file
68
- )
69
- return_code = self._wait_for_process(process, timeout)
70
- if return_code is None:
71
- return tr(
72
- "Code timed out after {timeout} seconds.", timeout=timeout
73
- )
74
- stdout_file.flush()
75
- stderr_file.flush()
76
- if not silent:
77
- self.report_success(
78
- tr("✅ Return code {return_code}", return_code=return_code),
79
- ReportAction.EXECUTE,
80
- )
81
- return self._format_result(
82
- stdout_file.name, stderr_file.name, return_code
83
- )
84
- except Exception as e:
85
- self.report_error(tr("❌ Error: {error}", error=e), ReportAction.EXECUTE)
86
- return tr("Error running code: {error}", error=e)
87
-
88
- def _stream_process_output(self, process, stdout_file, stderr_file):
89
- stdout_lines = 0
90
- stderr_lines = 0
91
-
92
- def stream_output(stream, file_obj, report_func, count_func):
93
- nonlocal stdout_lines, stderr_lines
94
- for line in stream:
95
- file_obj.write(line)
96
- file_obj.flush()
97
- from janito.tools.tool_base import ReportAction
98
-
99
- report_func(line.rstrip("\r\n"), ReportAction.EXECUTE)
100
- if count_func == "stdout":
101
- stdout_lines += 1
102
- else:
103
- stderr_lines += 1
104
-
105
- stdout_thread = threading.Thread(
106
- target=stream_output,
107
- args=(process.stdout, stdout_file, self.report_stdout, "stdout"),
108
- )
109
- stderr_thread = threading.Thread(
110
- target=stream_output,
111
- args=(process.stderr, stderr_file, self.report_stderr, "stderr"),
112
- )
113
- stdout_thread.start()
114
- stderr_thread.start()
115
- stdout_thread.join()
116
- stderr_thread.join()
117
- return stdout_lines, stderr_lines
118
-
119
- def _wait_for_process(self, process, timeout):
120
- try:
121
- return process.wait(timeout=timeout)
122
- except subprocess.TimeoutExpired:
123
- process.kill()
124
- self.report_error(
125
- tr("❌ Timed out after {timeout} seconds.", timeout=timeout),
126
- ReportAction.EXECUTE,
127
- )
128
- return None
129
-
130
- def _format_result(self, stdout_file_name, stderr_file_name, return_code):
131
- with open(stdout_file_name, "r", encoding="utf-8", errors="replace") as out_f:
132
- stdout_content = out_f.read()
133
- with open(stderr_file_name, "r", encoding="utf-8", errors="replace") as err_f:
134
- stderr_content = err_f.read()
135
- max_lines = 100
136
- stdout_lines = stdout_content.count("\n")
137
- stderr_lines = stderr_content.count("\n")
138
-
139
- def head_tail(text, n=10):
140
- lines = text.splitlines()
141
- if len(lines) <= 2 * n:
142
- return "\n".join(lines)
143
- return "\n".join(
144
- lines[:n]
145
- + ["... ({} lines omitted) ...".format(len(lines) - 2 * n)]
146
- + lines[-n:]
147
- )
148
-
149
- if stdout_lines <= max_lines and stderr_lines <= max_lines:
150
- result = f"Return code: {return_code}\n--- python_command_run: STDOUT ---\n{stdout_content}"
151
- if stderr_content.strip():
152
- result += f"\n--- python_command_run: STDERR ---\n{stderr_content}"
153
- return result
154
- else:
155
- result = f"stdout_file: {stdout_file_name} (lines: {stdout_lines})\n"
156
- if stderr_lines > 0 and stderr_content.strip():
157
- result += f"stderr_file: {stderr_file_name} (lines: {stderr_lines})\n"
158
- result += f"returncode: {return_code}\n"
159
- result += (
160
- "--- python_command_run: STDOUT (head/tail) ---\n"
161
- + head_tail(stdout_content)
162
- + "\n"
163
- )
164
- if stderr_content.strip():
165
- result += (
166
- "--- python_command_run: STDERR (head/tail) ---\n"
167
- + head_tail(stderr_content)
168
- + "\n"
169
- )
170
- result += "Use the view_file tool to inspect the contents of these files when needed."
171
- return result