janito 3.16.1__py3-none-any.whl → 3.16.3__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/agent/setup_agent.py +373 -382
- janito/agent/templates/profiles/system_prompt_template_Developer_with_Python_Tools.txt.j2 +95 -100
- janito/agent/templates/profiles/system_prompt_template_developer.txt.j2 +85 -90
- janito/agent/templates/profiles/system_prompt_template_market_analyst.txt.j2 +113 -119
- janito/agent/templates/profiles/system_prompt_template_model_conversation_without_tools_or_context.txt.j2 +1 -7
- janito/cli/cli_commands/show_system_prompt.py +169 -170
- janito/cli/main_cli.py +528 -534
- janito/cli/rich_terminal_reporter.py +182 -168
- {janito-3.16.1.dist-info → janito-3.16.3.dist-info}/METADATA +1 -1
- {janito-3.16.1.dist-info → janito-3.16.3.dist-info}/RECORD +14 -14
- {janito-3.16.1.dist-info → janito-3.16.3.dist-info}/WHEEL +0 -0
- {janito-3.16.1.dist-info → janito-3.16.3.dist-info}/entry_points.txt +0 -0
- {janito-3.16.1.dist-info → janito-3.16.3.dist-info}/licenses/LICENSE +0 -0
- {janito-3.16.1.dist-info → janito-3.16.3.dist-info}/top_level.txt +0 -0
@@ -1,168 +1,182 @@
|
|
1
|
-
from rich.console import Console
|
2
|
-
from rich.markdown import Markdown
|
3
|
-
from rich.pretty import Pretty
|
4
|
-
from rich.panel import Panel
|
5
|
-
from rich.text import Text
|
6
|
-
from janito.event_bus.handler import EventHandlerBase
|
7
|
-
import janito.driver_events as driver_events
|
8
|
-
from janito.report_events import ReportSubtype, ReportAction
|
9
|
-
from janito.event_bus.bus import event_bus
|
10
|
-
from janito.llm import message_parts
|
11
|
-
import janito.agent_events as agent_events
|
12
|
-
|
13
|
-
|
14
|
-
import sys
|
15
|
-
|
16
|
-
|
17
|
-
class RichTerminalReporter(EventHandlerBase):
|
18
|
-
"""
|
19
|
-
Handles UI rendering for janito events using Rich.
|
20
|
-
|
21
|
-
- For ResponseReceived events, iterates over the 'parts' field and displays each part appropriately:
|
22
|
-
- TextMessagePart: rendered as Markdown (uses 'content' field)
|
23
|
-
- Other MessageParts: displayed using Pretty or a suitable Rich representation
|
24
|
-
- For RequestFinished events, output is printed only if raw mode is enabled (using Pretty formatting).
|
25
|
-
- Report events (info, success, error, etc.) are always printed with appropriate styling.
|
26
|
-
"""
|
27
|
-
|
28
|
-
def __init__(self, raw_mode=False):
|
29
|
-
from janito.cli.console import shared_console
|
30
|
-
|
31
|
-
self.console = shared_console
|
32
|
-
self.raw_mode = raw_mode
|
33
|
-
import janito.report_events as report_events
|
34
|
-
|
35
|
-
import janito.tools.tool_events as tool_events
|
36
|
-
|
37
|
-
super().__init__(driver_events, report_events, tool_events, agent_events)
|
38
|
-
self._waiting_printed = False
|
39
|
-
|
40
|
-
def on_RequestStarted(self, event):
|
41
|
-
# Print waiting message with provider and model name
|
42
|
-
provider = None
|
43
|
-
model = None
|
44
|
-
if hasattr(event, "payload") and isinstance(event.payload, dict):
|
45
|
-
provider = event.payload.get("provider_name")
|
46
|
-
model = event.payload.get("model") or event.payload.get("model_name")
|
47
|
-
if not provider:
|
48
|
-
provider = getattr(event, "provider_name", None)
|
49
|
-
if not provider:
|
50
|
-
provider = getattr(event, "driver_name", None)
|
51
|
-
if not provider:
|
52
|
-
provider = "LLM"
|
53
|
-
if not model:
|
54
|
-
model = getattr(event, "model", None)
|
55
|
-
if not model:
|
56
|
-
model = getattr(event, "model_name", None)
|
57
|
-
if not model:
|
58
|
-
model = "?"
|
59
|
-
self.console.print(
|
60
|
-
f"[bold cyan]Waiting for {provider} (model: {model})...[/bold cyan]", end=""
|
61
|
-
)
|
62
|
-
self._waiting_printed = True
|
63
|
-
|
64
|
-
def on_AgentWaitingForResponse(self, event):
|
65
|
-
# Agent waiting - set flag but don't print anything
|
66
|
-
self._waiting_printed = True
|
67
|
-
|
68
|
-
def on_ResponseReceived(self, event):
|
69
|
-
parts = event.parts if hasattr(event, "parts") else None
|
70
|
-
if not parts:
|
71
|
-
self.console.print("[No response parts to display]")
|
72
|
-
self.console.file.flush()
|
73
|
-
return
|
74
|
-
for part in parts:
|
75
|
-
if isinstance(part, message_parts.TextMessagePart):
|
76
|
-
self.console.print(Markdown(part.content))
|
77
|
-
self.console.file.flush()
|
78
|
-
|
79
|
-
def delete_current_line(self):
|
80
|
-
"""
|
81
|
-
Clears the entire current line in the terminal and returns the cursor to column 1.
|
82
|
-
"""
|
83
|
-
# Use raw ANSI escape sequences but write directly to the underlying file
|
84
|
-
# to bypass Rich's escaping/interpretation
|
85
|
-
if hasattr(self.console,
|
86
|
-
self.console.file.write("\r\033[2K")
|
87
|
-
self.console.file.flush()
|
88
|
-
else:
|
89
|
-
# Fallback to sys.stdout if console.file is not available
|
90
|
-
import sys
|
91
|
-
|
92
|
-
sys.stdout.
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
self.
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
if
|
110
|
-
self.
|
111
|
-
self.
|
112
|
-
|
113
|
-
def
|
114
|
-
#
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
if
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
self.console.print(msg)
|
168
|
-
self.console.file.flush()
|
1
|
+
from rich.console import Console
|
2
|
+
from rich.markdown import Markdown
|
3
|
+
from rich.pretty import Pretty
|
4
|
+
from rich.panel import Panel
|
5
|
+
from rich.text import Text
|
6
|
+
from janito.event_bus.handler import EventHandlerBase
|
7
|
+
import janito.driver_events as driver_events
|
8
|
+
from janito.report_events import ReportSubtype, ReportAction
|
9
|
+
from janito.event_bus.bus import event_bus
|
10
|
+
from janito.llm import message_parts
|
11
|
+
import janito.agent_events as agent_events
|
12
|
+
|
13
|
+
|
14
|
+
import sys
|
15
|
+
|
16
|
+
|
17
|
+
class RichTerminalReporter(EventHandlerBase):
|
18
|
+
"""
|
19
|
+
Handles UI rendering for janito events using Rich.
|
20
|
+
|
21
|
+
- For ResponseReceived events, iterates over the 'parts' field and displays each part appropriately:
|
22
|
+
- TextMessagePart: rendered as Markdown (uses 'content' field)
|
23
|
+
- Other MessageParts: displayed using Pretty or a suitable Rich representation
|
24
|
+
- For RequestFinished events, output is printed only if raw mode is enabled (using Pretty formatting).
|
25
|
+
- Report events (info, success, error, etc.) are always printed with appropriate styling.
|
26
|
+
"""
|
27
|
+
|
28
|
+
def __init__(self, raw_mode=False):
|
29
|
+
from janito.cli.console import shared_console
|
30
|
+
|
31
|
+
self.console = shared_console
|
32
|
+
self.raw_mode = raw_mode
|
33
|
+
import janito.report_events as report_events
|
34
|
+
|
35
|
+
import janito.tools.tool_events as tool_events
|
36
|
+
|
37
|
+
super().__init__(driver_events, report_events, tool_events, agent_events)
|
38
|
+
self._waiting_printed = False
|
39
|
+
|
40
|
+
def on_RequestStarted(self, event):
|
41
|
+
# Print waiting message with provider and model name
|
42
|
+
provider = None
|
43
|
+
model = None
|
44
|
+
if hasattr(event, "payload") and isinstance(event.payload, dict):
|
45
|
+
provider = event.payload.get("provider_name")
|
46
|
+
model = event.payload.get("model") or event.payload.get("model_name")
|
47
|
+
if not provider:
|
48
|
+
provider = getattr(event, "provider_name", None)
|
49
|
+
if not provider:
|
50
|
+
provider = getattr(event, "driver_name", None)
|
51
|
+
if not provider:
|
52
|
+
provider = "LLM"
|
53
|
+
if not model:
|
54
|
+
model = getattr(event, "model", None)
|
55
|
+
if not model:
|
56
|
+
model = getattr(event, "model_name", None)
|
57
|
+
if not model:
|
58
|
+
model = "?"
|
59
|
+
self.console.print(
|
60
|
+
f"[bold cyan]Waiting for {provider} (model: {model})...[/bold cyan]", end=""
|
61
|
+
)
|
62
|
+
self._waiting_printed = True
|
63
|
+
|
64
|
+
def on_AgentWaitingForResponse(self, event):
|
65
|
+
# Agent waiting - set flag but don't print anything
|
66
|
+
self._waiting_printed = True
|
67
|
+
|
68
|
+
def on_ResponseReceived(self, event):
|
69
|
+
parts = event.parts if hasattr(event, "parts") else None
|
70
|
+
if not parts:
|
71
|
+
self.console.print("[No response parts to display]")
|
72
|
+
self.console.file.flush()
|
73
|
+
return
|
74
|
+
for part in parts:
|
75
|
+
if isinstance(part, message_parts.TextMessagePart):
|
76
|
+
self.console.print(Markdown(part.content))
|
77
|
+
self.console.file.flush()
|
78
|
+
|
79
|
+
def delete_current_line(self):
|
80
|
+
"""
|
81
|
+
Clears the entire current line in the terminal and returns the cursor to column 1.
|
82
|
+
"""
|
83
|
+
# Use raw ANSI escape sequences but write directly to the underlying file
|
84
|
+
# to bypass Rich's escaping/interpretation
|
85
|
+
if hasattr(self.console, "file") and hasattr(self.console.file, "write"):
|
86
|
+
self.console.file.write("\r\033[2K")
|
87
|
+
self.console.file.flush()
|
88
|
+
else:
|
89
|
+
# Fallback to sys.stdout if console.file is not available
|
90
|
+
import sys
|
91
|
+
|
92
|
+
sys.stdout.write("\r\033[2K")
|
93
|
+
sys.stdout.flush()
|
94
|
+
|
95
|
+
def on_RequestFinished(self, event):
|
96
|
+
# Check if this is an error status and display the error message
|
97
|
+
status = getattr(event, "status", None)
|
98
|
+
if status == driver_events.RequestStatus.ERROR:
|
99
|
+
error_msg = getattr(event, "error", "Unknown error occurred")
|
100
|
+
self.console.print(f"[bold red]Request Error:[/bold red] {error_msg}")
|
101
|
+
|
102
|
+
# Optionally print the traceback if available and in raw mode
|
103
|
+
if self.raw_mode:
|
104
|
+
traceback = getattr(event, "traceback", None)
|
105
|
+
if traceback:
|
106
|
+
self.console.print("[bold yellow]Traceback:[/bold yellow]")
|
107
|
+
self.console.print(traceback)
|
108
|
+
|
109
|
+
if self._waiting_printed:
|
110
|
+
self.delete_current_line()
|
111
|
+
self._waiting_printed = False
|
112
|
+
|
113
|
+
def on_AgentReceivedResponse(self, event):
|
114
|
+
# Clear any waiting message when agent receives response
|
115
|
+
if self._waiting_printed:
|
116
|
+
self.delete_current_line()
|
117
|
+
self._waiting_printed = False
|
118
|
+
|
119
|
+
def on_ToolCallError(self, event):
|
120
|
+
# Optionally handle tool call errors in a user-friendly way
|
121
|
+
error = getattr(event, "error", None)
|
122
|
+
tool = getattr(event, "tool_name", None)
|
123
|
+
if error and tool:
|
124
|
+
self.console.print(f"[bold red]Tool Error ({tool}):[/] {error}")
|
125
|
+
self.console.file.flush()
|
126
|
+
|
127
|
+
def on_ReportEvent(self, event):
|
128
|
+
# Special handling for security-related report events
|
129
|
+
subtype = getattr(event, "subtype", None)
|
130
|
+
msg = getattr(event, "message", None)
|
131
|
+
action = getattr(event, "action", None)
|
132
|
+
tool = getattr(event, "tool", None)
|
133
|
+
context = getattr(event, "context", None)
|
134
|
+
if (
|
135
|
+
subtype == ReportSubtype.ERROR
|
136
|
+
and msg
|
137
|
+
and "[SECURITY] Path access denied" in msg
|
138
|
+
):
|
139
|
+
# Highlight security errors with a distinct style
|
140
|
+
self.console.print(
|
141
|
+
Panel(f"{msg}", title="[red]SECURITY VIOLATION[/red]", style="bold red")
|
142
|
+
)
|
143
|
+
self.console.file.flush()
|
144
|
+
return
|
145
|
+
|
146
|
+
msg = event.message if hasattr(event, "message") else None
|
147
|
+
subtype = event.subtype if hasattr(event, "subtype") else None
|
148
|
+
if not msg or not subtype:
|
149
|
+
return
|
150
|
+
if subtype == ReportSubtype.ACTION_INFO:
|
151
|
+
# Clear any waiting message before showing action info
|
152
|
+
if self._waiting_printed:
|
153
|
+
self.delete_current_line()
|
154
|
+
self._waiting_printed = False
|
155
|
+
# Use orange for all write/modification actions
|
156
|
+
modification_actions = (
|
157
|
+
getattr(ReportAction, "UPDATE", None),
|
158
|
+
getattr(ReportAction, "WRITE", None),
|
159
|
+
getattr(ReportAction, "DELETE", None),
|
160
|
+
getattr(ReportAction, "CREATE", None),
|
161
|
+
)
|
162
|
+
style = (
|
163
|
+
"orange1"
|
164
|
+
if getattr(event, "action", None) in modification_actions
|
165
|
+
else "cyan"
|
166
|
+
)
|
167
|
+
self.console.print(Text(msg, style=style), end="")
|
168
|
+
self.console.file.flush()
|
169
|
+
elif subtype in (
|
170
|
+
ReportSubtype.SUCCESS,
|
171
|
+
ReportSubtype.ERROR,
|
172
|
+
ReportSubtype.WARNING,
|
173
|
+
):
|
174
|
+
self.console.print(msg)
|
175
|
+
self.console.file.flush()
|
176
|
+
elif subtype == ReportSubtype.STDOUT:
|
177
|
+
print(msg)
|
178
|
+
elif subtype == ReportSubtype.STDERR:
|
179
|
+
print(msg, file=sys.stderr)
|
180
|
+
else:
|
181
|
+
self.console.print(msg)
|
182
|
+
self.console.file.flush()
|
@@ -21,20 +21,20 @@ janito/provider_registry.py,sha256=IRNB35Cjn4PSXMWOxKBjPg0DfUEOoL4vh63OSPxhMtk,6
|
|
21
21
|
janito/report_events.py,sha256=q4OR_jTZNfcqaQF_fzTjgqo6_VlUIxSGWfhpT4nJWcw,938
|
22
22
|
janito/shell.bak.zip,sha256=hznHbmgfkAkjuQDJ3w73XPQh05yrtUZQxLmtGbanbYU,22
|
23
23
|
janito/utils.py,sha256=eXSsMgM69YyzahgCNrJQLcEbB8ssLI1MQqaa20ONxbE,376
|
24
|
-
janito/agent/setup_agent.py,sha256=
|
25
|
-
janito/agent/templates/profiles/system_prompt_template_Developer_with_Python_Tools.txt.j2,sha256=
|
26
|
-
janito/agent/templates/profiles/system_prompt_template_developer.txt.j2,sha256=
|
27
|
-
janito/agent/templates/profiles/system_prompt_template_market_analyst.txt.j2,sha256=
|
28
|
-
janito/agent/templates/profiles/system_prompt_template_model_conversation_without_tools_or_context.txt.j2,sha256=
|
24
|
+
janito/agent/setup_agent.py,sha256=NZmbIZfFyRW7B1DYa57q2ylM-cC-Y9vkkjrXU702gKY,12973
|
25
|
+
janito/agent/templates/profiles/system_prompt_template_Developer_with_Python_Tools.txt.j2,sha256=70AntMlMV2a4mzQXM4ieWpPJc3ydtZU-KKqmmn7YMJI,3823
|
26
|
+
janito/agent/templates/profiles/system_prompt_template_developer.txt.j2,sha256=gN1DCJmHCdQ7PQZzl2slDArhMaBhEIgGdU8biu9jgzU,3506
|
27
|
+
janito/agent/templates/profiles/system_prompt_template_market_analyst.txt.j2,sha256=4py-FjgNggjjz9f0ckOHKfgp3cdynq0HlMi1NLzH2EA,3985
|
28
|
+
janito/agent/templates/profiles/system_prompt_template_model_conversation_without_tools_or_context.txt.j2,sha256=hkTtdc012FOyPPrZLAj6YL3rrnhWcAbm-CzsoEA4DiQ,1389
|
29
29
|
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=dWOa6mbfCQd46wVwwZfeYBxroCxdqvnAZQQ80j89qYA,70
|
32
32
|
janito/cli/main.py,sha256=s5odou0txf8pzTf1ADk2yV7T5m8B6cejJ81e7iu776U,312
|
33
|
-
janito/cli/main_cli.py,sha256=
|
33
|
+
janito/cli/main_cli.py,sha256=dpHK84e_pIrkfJa2jRENQB9Y46Zn-Z9VJJmfv6NWJA4,17543
|
34
34
|
janito/cli/prompt_core.py,sha256=x1RcX1p4wCL4YzXS76T6BZ8nt5cGiXCAB3QOlC6BJQQ,14937
|
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=
|
37
|
+
janito/cli/rich_terminal_reporter.py,sha256=jZAOsOzFZRBId1rTGv7WwfLQ3tz5YwBUsCJ3Wg6RL0c,7397
|
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=odjc5_-YW1t2FRhBUNRNoBMoQIg5sMz3ktV7xG0ADFU,975
|
@@ -94,7 +94,7 @@ janito/cli/cli_commands/model_utils.py,sha256=4t2ZN8DYA8jxluXHiiliV8gMbF_90nKGtg
|
|
94
94
|
janito/cli/cli_commands/ping_providers.py,sha256=hetZAKKZzQYRpRDT5OvRTOe4jYUVNZGjo8gFoyeRA3I,1921
|
95
95
|
janito/cli/cli_commands/set_api_key.py,sha256=IR_hUcLjK-2oJmiIVdjc8epPsQAzqEN9MS7lSTVqmKM,1060
|
96
96
|
janito/cli/cli_commands/show_config.py,sha256=ammzVEqJQCAdWFRrhI1zjjmzgTCH2l38REoT4gYJPP0,3467
|
97
|
-
janito/cli/cli_commands/show_system_prompt.py,sha256=
|
97
|
+
janito/cli/cli_commands/show_system_prompt.py,sha256=on3olqfmPNAD9kfl5dAbl7BLFks57dni66QT-ke8kJI,6429
|
98
98
|
janito/cli/core/__init__.py,sha256=YH95fhgY9yBX8RgqX9dSrEkl4exjV0T4rbmJ6xUpG-Y,196
|
99
99
|
janito/cli/core/event_logger.py,sha256=1X6lR0Ax7AgF8HlPWFoY5Ystuu7Bh4ooTo78vXzeGB0,2008
|
100
100
|
janito/cli/core/getters.py,sha256=opmcSz86J-I95Klsh0c4y6lsYvNakrvRqvuA0o5ARWI,2869
|
@@ -266,9 +266,9 @@ janito/tools/tool_utils.py,sha256=alPm9DvtXSw_zPRKvP5GjbebPRf_nfvmWk2TNlL5Cws,12
|
|
266
266
|
janito/tools/tools_adapter.py,sha256=3Phjw34mOqG0KvXzQpZKIWigfSgZWRvdYuSdvV7Dj4M,21965
|
267
267
|
janito/tools/tools_schema.py,sha256=bv7jQfjh6yCbiRNPJykmbCTBgZZrOV2z_WqWQOjeY5o,4324
|
268
268
|
janito/tools/url_whitelist.py,sha256=0CPLkHTp5HgnwgjxwgXnJmwPeZQ30q4j3YjW59hiUUE,4295
|
269
|
-
janito-3.16.
|
270
|
-
janito-3.16.
|
271
|
-
janito-3.16.
|
272
|
-
janito-3.16.
|
273
|
-
janito-3.16.
|
274
|
-
janito-3.16.
|
269
|
+
janito-3.16.3.dist-info/licenses/LICENSE,sha256=dXV4fOF2ZErugtN8l_Nrj5tsRTYgtjE3cgiya0UfBio,11356
|
270
|
+
janito-3.16.3.dist-info/METADATA,sha256=CfsM8gUX4A0-ohWhRhshVu1z-QcU2r6jwMIULoLvOPo,1722
|
271
|
+
janito-3.16.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
272
|
+
janito-3.16.3.dist-info/entry_points.txt,sha256=wIo5zZxbmu4fC-ZMrsKD0T0vq7IqkOOLYhrqRGypkx4,48
|
273
|
+
janito-3.16.3.dist-info/top_level.txt,sha256=m0NaVCq0-ivxbazE2-ND0EA9Hmuijj_OGkmCbnBcCig,7
|
274
|
+
janito-3.16.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|