agentcrew-ai 0.9.0__py3-none-any.whl → 0.9.2__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.
- AgentCrew/__init__.py +1 -1
- AgentCrew/app.py +12 -1
- AgentCrew/modules/a2a/common/client/card_resolver.py +27 -8
- AgentCrew/modules/a2a/server.py +5 -0
- AgentCrew/modules/a2a/task_manager.py +1 -0
- AgentCrew/modules/chat/message/conversation.py +18 -1
- AgentCrew/modules/code_analysis/service.py +50 -7
- AgentCrew/modules/code_analysis/tool.py +9 -8
- AgentCrew/modules/console/completers.py +4 -0
- AgentCrew/modules/console/console_ui.py +17 -0
- AgentCrew/modules/console/display_handlers.py +4 -0
- AgentCrew/modules/console/visual_mode/__init__.py +5 -0
- AgentCrew/modules/console/visual_mode/viewer.py +41 -0
- AgentCrew/modules/console/visual_mode/viewer_input_handler.py +315 -0
- AgentCrew/modules/console/visual_mode/viewer_ui.py +608 -0
- AgentCrew/modules/gui/components/menu_components.py +8 -7
- AgentCrew/modules/gui/themes/style_provider.py +3 -1
- AgentCrew/modules/gui/widgets/configs/global_settings.py +1 -0
- AgentCrew/modules/gui/widgets/history_sidebar.py +8 -1
- AgentCrew/modules/llm/constants.py +15 -5
- AgentCrew/modules/mcpclient/service.py +0 -1
- AgentCrew/modules/memory/base_service.py +13 -0
- AgentCrew/modules/memory/chroma_service.py +50 -0
- {agentcrew_ai-0.9.0.dist-info → agentcrew_ai-0.9.2.dist-info}/METADATA +1 -1
- {agentcrew_ai-0.9.0.dist-info → agentcrew_ai-0.9.2.dist-info}/RECORD +29 -25
- {agentcrew_ai-0.9.0.dist-info → agentcrew_ai-0.9.2.dist-info}/WHEEL +0 -0
- {agentcrew_ai-0.9.0.dist-info → agentcrew_ai-0.9.2.dist-info}/entry_points.txt +0 -0
- {agentcrew_ai-0.9.0.dist-info → agentcrew_ai-0.9.2.dist-info}/licenses/LICENSE +0 -0
- {agentcrew_ai-0.9.0.dist-info → agentcrew_ai-0.9.2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
"""Input handler for visual mode viewer."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, Optional, Callable
|
|
6
|
+
|
|
7
|
+
from prompt_toolkit import PromptSession
|
|
8
|
+
from prompt_toolkit.key_binding import KeyBindings
|
|
9
|
+
from prompt_toolkit.keys import Keys
|
|
10
|
+
|
|
11
|
+
from loguru import logger
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from .viewer_ui import VisualModeUI
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class VisualModeInputHandler:
|
|
18
|
+
"""Handles keyboard input for the visual mode viewer."""
|
|
19
|
+
|
|
20
|
+
def __init__(
|
|
21
|
+
self,
|
|
22
|
+
ui: VisualModeUI,
|
|
23
|
+
on_copy: Optional[Callable[[str], None]] = None,
|
|
24
|
+
):
|
|
25
|
+
self._ui = ui
|
|
26
|
+
self._running = False
|
|
27
|
+
self._g_pressed = False
|
|
28
|
+
self._on_copy = on_copy
|
|
29
|
+
|
|
30
|
+
def _create_key_bindings(self) -> KeyBindings:
|
|
31
|
+
kb = KeyBindings()
|
|
32
|
+
|
|
33
|
+
@kb.add(Keys.Up)
|
|
34
|
+
@kb.add("k")
|
|
35
|
+
def _(event):
|
|
36
|
+
if self._ui._search_mode:
|
|
37
|
+
return
|
|
38
|
+
self._g_pressed = False
|
|
39
|
+
if self._ui.move_cursor("up"):
|
|
40
|
+
self._ui.render()
|
|
41
|
+
|
|
42
|
+
@kb.add(Keys.Down)
|
|
43
|
+
@kb.add("j")
|
|
44
|
+
def _(event):
|
|
45
|
+
if self._ui._search_mode:
|
|
46
|
+
return
|
|
47
|
+
self._g_pressed = False
|
|
48
|
+
if self._ui.move_cursor("down"):
|
|
49
|
+
self._ui.render()
|
|
50
|
+
|
|
51
|
+
@kb.add(Keys.Left)
|
|
52
|
+
@kb.add("h")
|
|
53
|
+
def _(event):
|
|
54
|
+
if self._ui._search_mode:
|
|
55
|
+
return
|
|
56
|
+
self._g_pressed = False
|
|
57
|
+
if self._ui.move_cursor("left"):
|
|
58
|
+
self._ui.render()
|
|
59
|
+
|
|
60
|
+
@kb.add(Keys.Right)
|
|
61
|
+
@kb.add("l")
|
|
62
|
+
def _(event):
|
|
63
|
+
if self._ui._search_mode:
|
|
64
|
+
return
|
|
65
|
+
self._g_pressed = False
|
|
66
|
+
if self._ui.move_cursor("right"):
|
|
67
|
+
self._ui.render()
|
|
68
|
+
|
|
69
|
+
@kb.add("w")
|
|
70
|
+
def _(event):
|
|
71
|
+
if self._ui._search_mode:
|
|
72
|
+
self._ui.append_search_char("w")
|
|
73
|
+
self._ui.render()
|
|
74
|
+
return
|
|
75
|
+
self._g_pressed = False
|
|
76
|
+
if self._ui.move_cursor("word_forward"):
|
|
77
|
+
self._ui.render()
|
|
78
|
+
|
|
79
|
+
@kb.add("b")
|
|
80
|
+
def _(event):
|
|
81
|
+
if self._ui._search_mode:
|
|
82
|
+
self._ui.append_search_char("b")
|
|
83
|
+
self._ui.render()
|
|
84
|
+
return
|
|
85
|
+
self._g_pressed = False
|
|
86
|
+
if self._ui.move_cursor("word_backward"):
|
|
87
|
+
self._ui.render()
|
|
88
|
+
|
|
89
|
+
@kb.add("0")
|
|
90
|
+
def _(event):
|
|
91
|
+
if self._ui._search_mode:
|
|
92
|
+
self._ui.append_search_char("0")
|
|
93
|
+
self._ui.render()
|
|
94
|
+
return
|
|
95
|
+
self._g_pressed = False
|
|
96
|
+
if self._ui.move_cursor("line_start"):
|
|
97
|
+
self._ui.render()
|
|
98
|
+
|
|
99
|
+
@kb.add("$")
|
|
100
|
+
def _(event):
|
|
101
|
+
if self._ui._search_mode:
|
|
102
|
+
self._ui.append_search_char("$")
|
|
103
|
+
self._ui.render()
|
|
104
|
+
return
|
|
105
|
+
self._g_pressed = False
|
|
106
|
+
if self._ui.move_cursor("line_end"):
|
|
107
|
+
self._ui.render()
|
|
108
|
+
|
|
109
|
+
@kb.add("g")
|
|
110
|
+
def _(event):
|
|
111
|
+
if self._ui._search_mode:
|
|
112
|
+
self._ui.append_search_char("g")
|
|
113
|
+
self._ui.render()
|
|
114
|
+
return
|
|
115
|
+
if self._g_pressed:
|
|
116
|
+
self._g_pressed = False
|
|
117
|
+
if self._ui.move_cursor("top"):
|
|
118
|
+
self._ui.render()
|
|
119
|
+
else:
|
|
120
|
+
self._g_pressed = True
|
|
121
|
+
|
|
122
|
+
@kb.add("G")
|
|
123
|
+
def _(event):
|
|
124
|
+
if self._ui._search_mode:
|
|
125
|
+
self._ui.append_search_char("G")
|
|
126
|
+
self._ui.render()
|
|
127
|
+
return
|
|
128
|
+
self._g_pressed = False
|
|
129
|
+
if self._ui.move_cursor("bottom"):
|
|
130
|
+
self._ui.render()
|
|
131
|
+
|
|
132
|
+
@kb.add(Keys.ControlU)
|
|
133
|
+
def _(event):
|
|
134
|
+
if self._ui._search_mode:
|
|
135
|
+
return
|
|
136
|
+
self._g_pressed = False
|
|
137
|
+
if self._ui.move_cursor("half_up"):
|
|
138
|
+
self._ui.render()
|
|
139
|
+
|
|
140
|
+
@kb.add(Keys.ControlD)
|
|
141
|
+
def _(event):
|
|
142
|
+
if self._ui._search_mode:
|
|
143
|
+
return
|
|
144
|
+
self._g_pressed = False
|
|
145
|
+
if self._ui.move_cursor("half_down"):
|
|
146
|
+
self._ui.render()
|
|
147
|
+
|
|
148
|
+
@kb.add(Keys.PageUp)
|
|
149
|
+
def _(event):
|
|
150
|
+
if self._ui._search_mode:
|
|
151
|
+
return
|
|
152
|
+
self._g_pressed = False
|
|
153
|
+
if self._ui.move_cursor("page_up"):
|
|
154
|
+
self._ui.render()
|
|
155
|
+
|
|
156
|
+
@kb.add(Keys.PageDown)
|
|
157
|
+
def _(event):
|
|
158
|
+
if self._ui._search_mode:
|
|
159
|
+
return
|
|
160
|
+
self._g_pressed = False
|
|
161
|
+
if self._ui.move_cursor("page_down"):
|
|
162
|
+
self._ui.render()
|
|
163
|
+
|
|
164
|
+
@kb.add("v")
|
|
165
|
+
def _(event):
|
|
166
|
+
if self._ui._search_mode:
|
|
167
|
+
self._ui.append_search_char("v")
|
|
168
|
+
self._ui.render()
|
|
169
|
+
return
|
|
170
|
+
self._g_pressed = False
|
|
171
|
+
self._ui.toggle_visual_mode()
|
|
172
|
+
self._ui.render()
|
|
173
|
+
|
|
174
|
+
@kb.add("y")
|
|
175
|
+
def _(event):
|
|
176
|
+
if self._ui._search_mode:
|
|
177
|
+
self._ui.append_search_char("y")
|
|
178
|
+
self._ui.render()
|
|
179
|
+
return
|
|
180
|
+
self._g_pressed = False
|
|
181
|
+
text = self._ui.get_selected_text()
|
|
182
|
+
if text and self._on_copy:
|
|
183
|
+
self._on_copy(text)
|
|
184
|
+
if self._ui._visual_mode:
|
|
185
|
+
self._ui.toggle_visual_mode()
|
|
186
|
+
self._ui.render()
|
|
187
|
+
|
|
188
|
+
@kb.add("Y")
|
|
189
|
+
def _(event):
|
|
190
|
+
if self._ui._search_mode:
|
|
191
|
+
self._ui.append_search_char("Y")
|
|
192
|
+
self._ui.render()
|
|
193
|
+
return
|
|
194
|
+
self._g_pressed = False
|
|
195
|
+
if 0 <= self._ui._cursor_line < len(self._ui._lines):
|
|
196
|
+
line_text = self._ui._lines[self._ui._cursor_line][0]
|
|
197
|
+
if self._on_copy:
|
|
198
|
+
self._on_copy(line_text)
|
|
199
|
+
|
|
200
|
+
@kb.add("/")
|
|
201
|
+
def _(event):
|
|
202
|
+
if self._ui._search_mode:
|
|
203
|
+
self._ui.append_search_char("/")
|
|
204
|
+
self._ui.render()
|
|
205
|
+
return
|
|
206
|
+
self._g_pressed = False
|
|
207
|
+
self._ui.start_search_mode()
|
|
208
|
+
self._ui.render()
|
|
209
|
+
|
|
210
|
+
@kb.add("n")
|
|
211
|
+
def _(event):
|
|
212
|
+
if self._ui._search_mode:
|
|
213
|
+
self._ui.append_search_char("n")
|
|
214
|
+
self._ui.render()
|
|
215
|
+
return
|
|
216
|
+
self._g_pressed = False
|
|
217
|
+
self._ui.next_search_match()
|
|
218
|
+
self._ui.render()
|
|
219
|
+
|
|
220
|
+
@kb.add("N")
|
|
221
|
+
def _(event):
|
|
222
|
+
if self._ui._search_mode:
|
|
223
|
+
self._ui.append_search_char("N")
|
|
224
|
+
self._ui.render()
|
|
225
|
+
return
|
|
226
|
+
self._g_pressed = False
|
|
227
|
+
self._ui.prev_search_match()
|
|
228
|
+
self._ui.render()
|
|
229
|
+
|
|
230
|
+
@kb.add(Keys.Enter)
|
|
231
|
+
def _(event):
|
|
232
|
+
if self._ui._search_mode:
|
|
233
|
+
self._ui.exit_search_mode(clear_results=False)
|
|
234
|
+
self._ui.render()
|
|
235
|
+
|
|
236
|
+
@kb.add(Keys.Backspace)
|
|
237
|
+
def _(event):
|
|
238
|
+
if self._ui._search_mode:
|
|
239
|
+
self._ui.backspace_search()
|
|
240
|
+
self._ui.render()
|
|
241
|
+
|
|
242
|
+
@kb.add(Keys.Escape)
|
|
243
|
+
def _(event):
|
|
244
|
+
self._g_pressed = False
|
|
245
|
+
if self._ui._visual_mode:
|
|
246
|
+
self._ui.toggle_visual_mode()
|
|
247
|
+
self._ui.render()
|
|
248
|
+
elif self._ui._search_mode:
|
|
249
|
+
self._ui.exit_search_mode(clear_results=True)
|
|
250
|
+
self._ui.render()
|
|
251
|
+
else:
|
|
252
|
+
event.app.exit()
|
|
253
|
+
|
|
254
|
+
@kb.add("q")
|
|
255
|
+
def _(event):
|
|
256
|
+
if self._ui._search_mode:
|
|
257
|
+
self._ui.append_search_char("q")
|
|
258
|
+
self._ui.render()
|
|
259
|
+
return
|
|
260
|
+
self._g_pressed = False
|
|
261
|
+
event.app.exit()
|
|
262
|
+
|
|
263
|
+
@kb.add(Keys.ControlC)
|
|
264
|
+
def _(event):
|
|
265
|
+
self._g_pressed = False
|
|
266
|
+
if self._ui._visual_mode:
|
|
267
|
+
text = self._ui.get_selected_text()
|
|
268
|
+
if text and self._on_copy:
|
|
269
|
+
self._on_copy(text)
|
|
270
|
+
self._ui.toggle_visual_mode()
|
|
271
|
+
self._ui.render()
|
|
272
|
+
elif self._ui._search_mode:
|
|
273
|
+
self._ui.exit_search_mode(clear_results=True)
|
|
274
|
+
self._ui.render()
|
|
275
|
+
else:
|
|
276
|
+
event.app.exit()
|
|
277
|
+
|
|
278
|
+
@kb.add(Keys.Any)
|
|
279
|
+
def _(event):
|
|
280
|
+
if self._ui._search_mode:
|
|
281
|
+
char = event.data
|
|
282
|
+
if char and char.isprintable():
|
|
283
|
+
self._ui.append_search_char(char)
|
|
284
|
+
self._ui.render()
|
|
285
|
+
return
|
|
286
|
+
self._g_pressed = False
|
|
287
|
+
|
|
288
|
+
return kb
|
|
289
|
+
|
|
290
|
+
def run(self):
|
|
291
|
+
self._running = True
|
|
292
|
+
self._g_pressed = False
|
|
293
|
+
|
|
294
|
+
self._ui.start_live()
|
|
295
|
+
|
|
296
|
+
kb = self._create_key_bindings()
|
|
297
|
+
|
|
298
|
+
try:
|
|
299
|
+
session = PromptSession(key_bindings=kb)
|
|
300
|
+
session.prompt("")
|
|
301
|
+
except (KeyboardInterrupt, EOFError):
|
|
302
|
+
pass
|
|
303
|
+
except Exception as e:
|
|
304
|
+
logger.error(f"Error in visual mode input handler: {e}")
|
|
305
|
+
finally:
|
|
306
|
+
self._ui.stop_live()
|
|
307
|
+
|
|
308
|
+
self._running = False
|
|
309
|
+
|
|
310
|
+
@property
|
|
311
|
+
def is_running(self) -> bool:
|
|
312
|
+
return self._running
|
|
313
|
+
|
|
314
|
+
def stop(self):
|
|
315
|
+
self._running = False
|