hackagent 0.3.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.
- hackagent/__init__.py +12 -0
- hackagent/agent.py +214 -0
- hackagent/api/__init__.py +1 -0
- hackagent/api/agent/__init__.py +1 -0
- hackagent/api/agent/agent_create.py +347 -0
- hackagent/api/agent/agent_destroy.py +140 -0
- hackagent/api/agent/agent_list.py +242 -0
- hackagent/api/agent/agent_partial_update.py +361 -0
- hackagent/api/agent/agent_retrieve.py +235 -0
- hackagent/api/agent/agent_update.py +361 -0
- hackagent/api/apilogs/__init__.py +1 -0
- hackagent/api/apilogs/apilogs_list.py +170 -0
- hackagent/api/apilogs/apilogs_retrieve.py +162 -0
- hackagent/api/attack/__init__.py +1 -0
- hackagent/api/attack/attack_create.py +275 -0
- hackagent/api/attack/attack_destroy.py +146 -0
- hackagent/api/attack/attack_list.py +254 -0
- hackagent/api/attack/attack_partial_update.py +289 -0
- hackagent/api/attack/attack_retrieve.py +247 -0
- hackagent/api/attack/attack_update.py +289 -0
- hackagent/api/checkout/__init__.py +1 -0
- hackagent/api/checkout/checkout_create.py +225 -0
- hackagent/api/generate/__init__.py +1 -0
- hackagent/api/generate/generate_create.py +253 -0
- hackagent/api/judge/__init__.py +1 -0
- hackagent/api/judge/judge_create.py +253 -0
- hackagent/api/key/__init__.py +1 -0
- hackagent/api/key/key_create.py +179 -0
- hackagent/api/key/key_destroy.py +103 -0
- hackagent/api/key/key_list.py +170 -0
- hackagent/api/key/key_retrieve.py +162 -0
- hackagent/api/organization/__init__.py +1 -0
- hackagent/api/organization/organization_create.py +208 -0
- hackagent/api/organization/organization_destroy.py +104 -0
- hackagent/api/organization/organization_list.py +170 -0
- hackagent/api/organization/organization_me_retrieve.py +126 -0
- hackagent/api/organization/organization_partial_update.py +222 -0
- hackagent/api/organization/organization_retrieve.py +163 -0
- hackagent/api/organization/organization_update.py +222 -0
- hackagent/api/prompt/__init__.py +1 -0
- hackagent/api/prompt/prompt_create.py +171 -0
- hackagent/api/prompt/prompt_destroy.py +104 -0
- hackagent/api/prompt/prompt_list.py +185 -0
- hackagent/api/prompt/prompt_partial_update.py +185 -0
- hackagent/api/prompt/prompt_retrieve.py +163 -0
- hackagent/api/prompt/prompt_update.py +185 -0
- hackagent/api/result/__init__.py +1 -0
- hackagent/api/result/result_create.py +175 -0
- hackagent/api/result/result_destroy.py +106 -0
- hackagent/api/result/result_list.py +249 -0
- hackagent/api/result/result_partial_update.py +193 -0
- hackagent/api/result/result_retrieve.py +167 -0
- hackagent/api/result/result_trace_create.py +177 -0
- hackagent/api/result/result_update.py +189 -0
- hackagent/api/run/__init__.py +1 -0
- hackagent/api/run/run_create.py +187 -0
- hackagent/api/run/run_destroy.py +112 -0
- hackagent/api/run/run_list.py +291 -0
- hackagent/api/run/run_partial_update.py +201 -0
- hackagent/api/run/run_result_create.py +177 -0
- hackagent/api/run/run_retrieve.py +179 -0
- hackagent/api/run/run_run_tests_create.py +187 -0
- hackagent/api/run/run_update.py +201 -0
- hackagent/api/user/__init__.py +1 -0
- hackagent/api/user/user_create.py +212 -0
- hackagent/api/user/user_destroy.py +106 -0
- hackagent/api/user/user_list.py +174 -0
- hackagent/api/user/user_me_retrieve.py +126 -0
- hackagent/api/user/user_me_update.py +196 -0
- hackagent/api/user/user_partial_update.py +226 -0
- hackagent/api/user/user_retrieve.py +167 -0
- hackagent/api/user/user_update.py +226 -0
- hackagent/attacks/AdvPrefix/__init__.py +41 -0
- hackagent/attacks/AdvPrefix/completions.py +416 -0
- hackagent/attacks/AdvPrefix/config.py +259 -0
- hackagent/attacks/AdvPrefix/evaluation.py +745 -0
- hackagent/attacks/AdvPrefix/evaluators.py +564 -0
- hackagent/attacks/AdvPrefix/generate.py +711 -0
- hackagent/attacks/AdvPrefix/utils.py +307 -0
- hackagent/attacks/__init__.py +35 -0
- hackagent/attacks/advprefix.py +507 -0
- hackagent/attacks/base.py +106 -0
- hackagent/attacks/strategies.py +906 -0
- hackagent/cli/__init__.py +19 -0
- hackagent/cli/commands/__init__.py +20 -0
- hackagent/cli/commands/agent.py +100 -0
- hackagent/cli/commands/attack.py +417 -0
- hackagent/cli/commands/config.py +301 -0
- hackagent/cli/commands/results.py +327 -0
- hackagent/cli/config.py +249 -0
- hackagent/cli/main.py +515 -0
- hackagent/cli/tui/__init__.py +31 -0
- hackagent/cli/tui/actions_logger.py +200 -0
- hackagent/cli/tui/app.py +288 -0
- hackagent/cli/tui/base.py +137 -0
- hackagent/cli/tui/logger.py +318 -0
- hackagent/cli/tui/views/__init__.py +33 -0
- hackagent/cli/tui/views/agents.py +488 -0
- hackagent/cli/tui/views/attacks.py +624 -0
- hackagent/cli/tui/views/config.py +244 -0
- hackagent/cli/tui/views/dashboard.py +307 -0
- hackagent/cli/tui/views/results.py +1210 -0
- hackagent/cli/tui/widgets/__init__.py +24 -0
- hackagent/cli/tui/widgets/actions.py +346 -0
- hackagent/cli/tui/widgets/logs.py +435 -0
- hackagent/cli/utils.py +276 -0
- hackagent/client.py +286 -0
- hackagent/errors.py +37 -0
- hackagent/logger.py +83 -0
- hackagent/models/__init__.py +109 -0
- hackagent/models/agent.py +223 -0
- hackagent/models/agent_request.py +129 -0
- hackagent/models/api_token_log.py +184 -0
- hackagent/models/attack.py +154 -0
- hackagent/models/attack_request.py +82 -0
- hackagent/models/checkout_session_request_request.py +76 -0
- hackagent/models/checkout_session_response.py +59 -0
- hackagent/models/choice.py +81 -0
- hackagent/models/choice_message.py +67 -0
- hackagent/models/evaluation_status_enum.py +14 -0
- hackagent/models/generate_error_response.py +59 -0
- hackagent/models/generate_request_request.py +212 -0
- hackagent/models/generate_success_response.py +115 -0
- hackagent/models/generic_error_response.py +70 -0
- hackagent/models/message_request.py +67 -0
- hackagent/models/organization.py +102 -0
- hackagent/models/organization_minimal.py +68 -0
- hackagent/models/organization_request.py +71 -0
- hackagent/models/paginated_agent_list.py +123 -0
- hackagent/models/paginated_api_token_log_list.py +123 -0
- hackagent/models/paginated_attack_list.py +123 -0
- hackagent/models/paginated_organization_list.py +123 -0
- hackagent/models/paginated_prompt_list.py +123 -0
- hackagent/models/paginated_result_list.py +123 -0
- hackagent/models/paginated_run_list.py +123 -0
- hackagent/models/paginated_user_api_key_list.py +123 -0
- hackagent/models/paginated_user_profile_list.py +123 -0
- hackagent/models/patched_agent_request.py +128 -0
- hackagent/models/patched_attack_request.py +92 -0
- hackagent/models/patched_organization_request.py +71 -0
- hackagent/models/patched_prompt_request.py +125 -0
- hackagent/models/patched_result_request.py +237 -0
- hackagent/models/patched_run_request.py +138 -0
- hackagent/models/patched_user_profile_request.py +99 -0
- hackagent/models/prompt.py +220 -0
- hackagent/models/prompt_request.py +126 -0
- hackagent/models/result.py +294 -0
- hackagent/models/result_list_evaluation_status.py +14 -0
- hackagent/models/result_request.py +232 -0
- hackagent/models/run.py +233 -0
- hackagent/models/run_list_status.py +12 -0
- hackagent/models/run_request.py +133 -0
- hackagent/models/status_enum.py +12 -0
- hackagent/models/step_type_enum.py +14 -0
- hackagent/models/trace.py +121 -0
- hackagent/models/trace_request.py +94 -0
- hackagent/models/usage.py +75 -0
- hackagent/models/user_api_key.py +201 -0
- hackagent/models/user_api_key_request.py +73 -0
- hackagent/models/user_profile.py +135 -0
- hackagent/models/user_profile_minimal.py +76 -0
- hackagent/models/user_profile_request.py +99 -0
- hackagent/router/__init__.py +25 -0
- hackagent/router/adapters/__init__.py +20 -0
- hackagent/router/adapters/base.py +63 -0
- hackagent/router/adapters/google_adk.py +671 -0
- hackagent/router/adapters/litellm_adapter.py +524 -0
- hackagent/router/adapters/openai_adapter.py +426 -0
- hackagent/router/router.py +969 -0
- hackagent/router/types.py +54 -0
- hackagent/tracking/__init__.py +42 -0
- hackagent/tracking/context.py +163 -0
- hackagent/tracking/decorators.py +299 -0
- hackagent/tracking/tracker.py +441 -0
- hackagent/types.py +54 -0
- hackagent/utils.py +194 -0
- hackagent/vulnerabilities/__init__.py +13 -0
- hackagent/vulnerabilities/prompts.py +81 -0
- hackagent-0.3.1.dist-info/METADATA +122 -0
- hackagent-0.3.1.dist-info/RECORD +183 -0
- hackagent-0.3.1.dist-info/WHEEL +4 -0
- hackagent-0.3.1.dist-info/entry_points.txt +2 -0
- hackagent-0.3.1.dist-info/licenses/LICENSE +202 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Copyright 2025 - AI4I. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""
|
|
16
|
+
TUI Widgets
|
|
17
|
+
|
|
18
|
+
Reusable Textual widgets for the HackAgent TUI interface.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from hackagent.cli.tui.widgets.actions import AgentActionsViewer
|
|
22
|
+
from hackagent.cli.tui.widgets.logs import AttackLogViewer
|
|
23
|
+
|
|
24
|
+
__all__ = ["AttackLogViewer", "AgentActionsViewer"]
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
# Copyright 2025 - AI4I. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""
|
|
16
|
+
Agent Actions Viewer Component
|
|
17
|
+
|
|
18
|
+
A reusable Textual widget for displaying agent tool calls, function executions,
|
|
19
|
+
and web interactions in a structured, visual format.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
import json
|
|
23
|
+
from typing import Any, Dict, List, Optional
|
|
24
|
+
|
|
25
|
+
from textual.app import ComposeResult
|
|
26
|
+
from textual.containers import Container
|
|
27
|
+
from textual.widgets import Button, RichLog, Static
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class AgentActionsViewer(Container):
|
|
31
|
+
"""
|
|
32
|
+
A container widget for displaying agent actions (tool calls, HTTP requests, etc.)
|
|
33
|
+
in a visual, inspector-like format.
|
|
34
|
+
|
|
35
|
+
This component provides:
|
|
36
|
+
- Visual representation of tool/function calls
|
|
37
|
+
- HTTP request/response display
|
|
38
|
+
- Agent reasoning steps (for ADK agents)
|
|
39
|
+
- JSON payload inspector
|
|
40
|
+
- Collapsible action details
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
DEFAULT_CSS = """
|
|
44
|
+
AgentActionsViewer {
|
|
45
|
+
border: solid $primary;
|
|
46
|
+
padding: 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
AgentActionsViewer .actions-header {
|
|
50
|
+
dock: top;
|
|
51
|
+
height: 3;
|
|
52
|
+
background: $panel;
|
|
53
|
+
padding: 0 1;
|
|
54
|
+
content-align: center middle;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
AgentActionsViewer .actions-controls {
|
|
58
|
+
dock: top;
|
|
59
|
+
height: 3;
|
|
60
|
+
background: $surface;
|
|
61
|
+
padding: 0 1;
|
|
62
|
+
layout: horizontal;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
AgentActionsViewer RichLog {
|
|
66
|
+
background: $surface;
|
|
67
|
+
border: none;
|
|
68
|
+
padding: 1;
|
|
69
|
+
height: 1fr;
|
|
70
|
+
width: 100%;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
AgentActionsViewer Button {
|
|
74
|
+
margin: 0 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
AgentActionsViewer .action-card {
|
|
78
|
+
background: $panel;
|
|
79
|
+
border: solid $primary-darken-1;
|
|
80
|
+
padding: 1;
|
|
81
|
+
margin: 0 0 1 0;
|
|
82
|
+
}
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
def __init__(
|
|
86
|
+
self,
|
|
87
|
+
title: str = "Agent Actions Inspector",
|
|
88
|
+
show_controls: bool = True,
|
|
89
|
+
**kwargs,
|
|
90
|
+
):
|
|
91
|
+
"""
|
|
92
|
+
Initialize the actions viewer.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
title: Title to display in the header
|
|
96
|
+
show_controls: Whether to show control buttons
|
|
97
|
+
**kwargs: Additional keyword arguments for Container
|
|
98
|
+
"""
|
|
99
|
+
super().__init__(**kwargs)
|
|
100
|
+
self.actions_title = title
|
|
101
|
+
self.show_controls = show_controls
|
|
102
|
+
self._action_count = 0
|
|
103
|
+
self._actions_buffer: List[Dict[str, Any]] = []
|
|
104
|
+
|
|
105
|
+
def compose(self) -> ComposeResult:
|
|
106
|
+
"""Compose the actions viewer layout."""
|
|
107
|
+
# Header
|
|
108
|
+
yield Static(
|
|
109
|
+
f"[bold cyan]{self.actions_title}[/bold cyan]",
|
|
110
|
+
classes="actions-header",
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
# Control buttons (optional)
|
|
114
|
+
if self.show_controls:
|
|
115
|
+
with Container(classes="actions-controls"):
|
|
116
|
+
yield Button("Clear Actions", id="clear-actions", variant="default")
|
|
117
|
+
yield Static("", id="action-count")
|
|
118
|
+
|
|
119
|
+
# Actions display area
|
|
120
|
+
rich_log = RichLog(
|
|
121
|
+
highlight=True,
|
|
122
|
+
markup=True,
|
|
123
|
+
max_lines=1000,
|
|
124
|
+
wrap=False,
|
|
125
|
+
id="actions-display",
|
|
126
|
+
)
|
|
127
|
+
yield rich_log
|
|
128
|
+
|
|
129
|
+
def on_mount(self) -> None:
|
|
130
|
+
"""Called when the widget is mounted."""
|
|
131
|
+
self.update_action_count(0)
|
|
132
|
+
self.add_info_message("Waiting for agent actions...")
|
|
133
|
+
|
|
134
|
+
def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
135
|
+
"""Handle button press events."""
|
|
136
|
+
if event.button.id == "clear-actions":
|
|
137
|
+
self.clear_actions()
|
|
138
|
+
|
|
139
|
+
def add_info_message(self, message: str) -> None:
|
|
140
|
+
"""Add an informational message to the viewer."""
|
|
141
|
+
actions_widget = self.query_one("#actions-display", RichLog)
|
|
142
|
+
actions_widget.write(f"[dim italic]{message}[/dim italic]")
|
|
143
|
+
|
|
144
|
+
def add_http_request(
|
|
145
|
+
self,
|
|
146
|
+
method: str,
|
|
147
|
+
url: str,
|
|
148
|
+
headers: Optional[Dict[str, Any]] = None,
|
|
149
|
+
payload: Optional[Dict[str, Any]] = None,
|
|
150
|
+
step_number: Optional[int] = None,
|
|
151
|
+
) -> None:
|
|
152
|
+
"""
|
|
153
|
+
Add an HTTP request action to the viewer.
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
method: HTTP method (GET, POST, etc.)
|
|
157
|
+
url: Request URL
|
|
158
|
+
headers: Request headers
|
|
159
|
+
payload: Request payload
|
|
160
|
+
step_number: Optional step number
|
|
161
|
+
"""
|
|
162
|
+
actions_widget = self.query_one("#actions-display", RichLog)
|
|
163
|
+
|
|
164
|
+
self._action_count += 1
|
|
165
|
+
prefix = f"[{step_number}] " if step_number else f"[{self._action_count}] "
|
|
166
|
+
|
|
167
|
+
# Header
|
|
168
|
+
actions_widget.write(f"\n[bold yellow]{'─' * 80}[/bold yellow]")
|
|
169
|
+
actions_widget.write(
|
|
170
|
+
f"[bold cyan]{prefix}HTTP {method}[/bold cyan] [blue]{url}[/blue]"
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
# Headers
|
|
174
|
+
if headers:
|
|
175
|
+
actions_widget.write("[dim]Headers:[/dim]")
|
|
176
|
+
for key, value in list(headers.items())[:3]: # Show first 3 headers
|
|
177
|
+
actions_widget.write(f" [green]{key}:[/green] {value}")
|
|
178
|
+
if len(headers) > 3:
|
|
179
|
+
actions_widget.write(f" [dim]... and {len(headers) - 3} more[/dim]")
|
|
180
|
+
|
|
181
|
+
# Payload
|
|
182
|
+
if payload:
|
|
183
|
+
actions_widget.write("[dim]Payload:[/dim]")
|
|
184
|
+
payload_str = json.dumps(payload, indent=2)
|
|
185
|
+
# Truncate if too long
|
|
186
|
+
if len(payload_str) > 500:
|
|
187
|
+
payload_str = payload_str[:500] + "\n ..."
|
|
188
|
+
actions_widget.write(f"[yellow]{payload_str}[/yellow]")
|
|
189
|
+
|
|
190
|
+
actions_widget.write(f"[bold yellow]{'─' * 80}[/bold yellow]\n")
|
|
191
|
+
self.update_action_count(self._action_count)
|
|
192
|
+
|
|
193
|
+
def add_tool_call(
|
|
194
|
+
self,
|
|
195
|
+
tool_name: str,
|
|
196
|
+
arguments: Optional[Dict[str, Any]] = None,
|
|
197
|
+
result: Optional[str] = None,
|
|
198
|
+
step_number: Optional[int] = None,
|
|
199
|
+
) -> None:
|
|
200
|
+
"""
|
|
201
|
+
Add a tool/function call action to the viewer.
|
|
202
|
+
|
|
203
|
+
Args:
|
|
204
|
+
tool_name: Name of the tool/function
|
|
205
|
+
arguments: Tool arguments
|
|
206
|
+
result: Tool execution result
|
|
207
|
+
step_number: Optional step number
|
|
208
|
+
"""
|
|
209
|
+
actions_widget = self.query_one("#actions-display", RichLog)
|
|
210
|
+
|
|
211
|
+
self._action_count += 1
|
|
212
|
+
prefix = f"[{step_number}] " if step_number else f"[{self._action_count}] "
|
|
213
|
+
|
|
214
|
+
# Header
|
|
215
|
+
actions_widget.write(f"\n[bold magenta]{'─' * 80}[/bold magenta]")
|
|
216
|
+
actions_widget.write(
|
|
217
|
+
f"[bold green]{prefix}🔧 TOOL CALL:[/bold green] [bold cyan]{tool_name}[/bold cyan]"
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
# Arguments
|
|
221
|
+
if arguments:
|
|
222
|
+
actions_widget.write("[dim]Arguments:[/dim]")
|
|
223
|
+
args_str = json.dumps(arguments, indent=2)
|
|
224
|
+
if len(args_str) > 400:
|
|
225
|
+
args_str = args_str[:400] + "\n ..."
|
|
226
|
+
actions_widget.write(f"[yellow]{args_str}[/yellow]")
|
|
227
|
+
|
|
228
|
+
# Result
|
|
229
|
+
if result:
|
|
230
|
+
actions_widget.write("[dim]Result:[/dim]")
|
|
231
|
+
result_preview = str(result)[:300]
|
|
232
|
+
if len(str(result)) > 300:
|
|
233
|
+
result_preview += "..."
|
|
234
|
+
actions_widget.write(f"[green]{result_preview}[/green]")
|
|
235
|
+
|
|
236
|
+
actions_widget.write(f"[bold magenta]{'─' * 80}[/bold magenta]\n")
|
|
237
|
+
self.update_action_count(self._action_count)
|
|
238
|
+
|
|
239
|
+
def add_adk_event(
|
|
240
|
+
self,
|
|
241
|
+
event_type: str,
|
|
242
|
+
event_data: Dict[str, Any],
|
|
243
|
+
step_number: Optional[int] = None,
|
|
244
|
+
) -> None:
|
|
245
|
+
"""
|
|
246
|
+
Add an ADK agent event to the viewer.
|
|
247
|
+
|
|
248
|
+
Args:
|
|
249
|
+
event_type: Type of event (tool_call, tool_result, llm_response, etc.)
|
|
250
|
+
event_data: Event data dictionary
|
|
251
|
+
step_number: Optional step number
|
|
252
|
+
"""
|
|
253
|
+
actions_widget = self.query_one("#actions-display", RichLog)
|
|
254
|
+
|
|
255
|
+
self._action_count += 1
|
|
256
|
+
prefix = f"[{step_number}] " if step_number else f"[{self._action_count}] "
|
|
257
|
+
|
|
258
|
+
# Header
|
|
259
|
+
actions_widget.write(f"\n[bold blue]{'─' * 80}[/bold blue]")
|
|
260
|
+
|
|
261
|
+
if event_type == "tool_call":
|
|
262
|
+
tool_name = event_data.get("tool_name", "unknown")
|
|
263
|
+
tool_input = event_data.get("tool_input", {})
|
|
264
|
+
actions_widget.write(
|
|
265
|
+
f"[bold green]{prefix}🤖 ADK TOOL CALL:[/bold green] [bold cyan]{tool_name}[/bold cyan]"
|
|
266
|
+
)
|
|
267
|
+
if tool_input:
|
|
268
|
+
input_str = json.dumps(tool_input, indent=2)
|
|
269
|
+
if len(input_str) > 400:
|
|
270
|
+
input_str = input_str[:400] + "\n ..."
|
|
271
|
+
actions_widget.write(f"[yellow]{input_str}[/yellow]")
|
|
272
|
+
|
|
273
|
+
elif event_type == "tool_result":
|
|
274
|
+
tool_name = event_data.get("tool_name", "unknown")
|
|
275
|
+
result = event_data.get("result", "")
|
|
276
|
+
actions_widget.write(
|
|
277
|
+
f"[bold green]{prefix}📤 ADK TOOL RESULT:[/bold green] [bold cyan]{tool_name}[/bold cyan]"
|
|
278
|
+
)
|
|
279
|
+
result_preview = str(result)[:300]
|
|
280
|
+
if len(str(result)) > 300:
|
|
281
|
+
result_preview += "..."
|
|
282
|
+
actions_widget.write(f"[green]{result_preview}[/green]")
|
|
283
|
+
|
|
284
|
+
elif event_type == "llm_response":
|
|
285
|
+
content = event_data.get("content", "")
|
|
286
|
+
actions_widget.write(
|
|
287
|
+
f"[bold green]{prefix}💬 ADK LLM RESPONSE[/bold green]"
|
|
288
|
+
)
|
|
289
|
+
content_preview = str(content)[:400]
|
|
290
|
+
if len(str(content)) > 400:
|
|
291
|
+
content_preview += "..."
|
|
292
|
+
actions_widget.write(f"[cyan]{content_preview}[/cyan]")
|
|
293
|
+
|
|
294
|
+
else:
|
|
295
|
+
actions_widget.write(
|
|
296
|
+
f"[bold green]{prefix}📋 ADK EVENT:[/bold green] [cyan]{event_type}[/cyan]"
|
|
297
|
+
)
|
|
298
|
+
if "content" in event_data:
|
|
299
|
+
content_preview = str(event_data["content"])[:300]
|
|
300
|
+
actions_widget.write(f"[dim]{content_preview}[/dim]")
|
|
301
|
+
|
|
302
|
+
actions_widget.write(f"[bold blue]{'─' * 80}[/bold blue]\n")
|
|
303
|
+
self.update_action_count(self._action_count)
|
|
304
|
+
|
|
305
|
+
def add_step_separator(self, step_name: str, step_number: int = 0) -> None:
|
|
306
|
+
"""
|
|
307
|
+
Add a visual separator for pipeline steps.
|
|
308
|
+
|
|
309
|
+
Args:
|
|
310
|
+
step_name: Name of the step
|
|
311
|
+
step_number: Step number (0 for no number)
|
|
312
|
+
"""
|
|
313
|
+
actions_widget = self.query_one("#actions-display", RichLog)
|
|
314
|
+
|
|
315
|
+
separator = "═" * 80
|
|
316
|
+
if step_number > 0:
|
|
317
|
+
header = f"\n[bold bright_cyan]▌ STEP {step_number}: {step_name} [/bold bright_cyan]"
|
|
318
|
+
else:
|
|
319
|
+
header = f"\n[bold bright_cyan]▌ {step_name} [/bold bright_cyan]"
|
|
320
|
+
|
|
321
|
+
actions_widget.write(f"\n[bold blue]{separator}[/bold blue]")
|
|
322
|
+
actions_widget.write(header)
|
|
323
|
+
actions_widget.write(f"[bold blue]{separator}[/bold blue]\n")
|
|
324
|
+
|
|
325
|
+
def clear_actions(self) -> None:
|
|
326
|
+
"""Clear all actions from the viewer."""
|
|
327
|
+
actions_widget = self.query_one("#actions-display", RichLog)
|
|
328
|
+
actions_widget.clear()
|
|
329
|
+
self._action_count = 0
|
|
330
|
+
self._actions_buffer.clear()
|
|
331
|
+
self.update_action_count(0)
|
|
332
|
+
self.add_info_message("Actions cleared. Waiting for new agent actions...")
|
|
333
|
+
|
|
334
|
+
def update_action_count(self, count: int) -> None:
|
|
335
|
+
"""
|
|
336
|
+
Update the action count display.
|
|
337
|
+
|
|
338
|
+
Args:
|
|
339
|
+
count: Number of actions
|
|
340
|
+
"""
|
|
341
|
+
if self.show_controls:
|
|
342
|
+
try:
|
|
343
|
+
count_widget = self.query_one("#action-count", Static)
|
|
344
|
+
count_widget.update(f"[bold]Actions:[/bold] {count}")
|
|
345
|
+
except Exception:
|
|
346
|
+
pass
|