55from datetime import datetime
66
77from threading import Thread , Lock , Semaphore
8- from PyQt5 .QtWidgets import *
9- from PyQt5 .QtGui import *
10- from PyQt5 .QtCore import *
118
12- from grpcClient import *
9+ from PyQt6 .QtCore import Qt , QEvent , QTimer , pyqtSignal
10+ from PyQt6 .QtGui import QFont , QTextCursor , QStandardItem , QStandardItemModel , QShortcut
11+ from PyQt6 .QtWidgets import (
12+ QCompleter ,
13+ QLineEdit ,
14+ QPlainTextEdit ,
15+ QVBoxLayout ,
16+ QWidget ,
17+ )
18+
19+ from .grpcClient import TeamServerApi_pb2
1320
1421import openai
1522from openai import OpenAI
@@ -35,7 +42,7 @@ def __init__(self, parent, grpcClient):
3542 # self.logFileName=LogFileName
3643
3744 self .editorOutput = QPlainTextEdit ()
38- self .editorOutput .setFont (QFont ("Courier " ));
45+ self .editorOutput .setFont (QFont ("JetBrainsMono Nerd Font " ))
3946 self .editorOutput .setReadOnly (True )
4047 self .layout .addWidget (self .editorOutput , 8 )
4148
@@ -80,7 +87,7 @@ def nextCompletion(self):
8087
8188 def sessionAssistantMethod (self , action , beaconHash , listenerHash , hostname , username , arch , privilege , os , lastProofOfLife , killed ):
8289 if action == "start" :
83- print ("sessionAssistantMethod" , action , beaconHash )
90+ # print("sessionAssistantMethod", action, beaconHash)
8491 self .messages .append ({"role" : "user" , "content" : "New session stared: beaconHash={}, listenerHash={}, hostname={}, username={}, privilege={}, os={}." .format (beaconHash , listenerHash , hostname , username , privilege , os ) })
8592 elif action == "stop" :
8693 toto = 1
@@ -89,7 +96,7 @@ def sessionAssistantMethod(self, action, beaconHash, listenerHash, hostname, use
8996
9097
9198 def listenerAssistantMethod (self , action , hash , str3 , str4 ):
92- print ("listenerAssistantMethod" , action , hash )
99+ # print("listenerAssistantMethod", action, hash)
93100 if action == "start" :
94101 toto = 1
95102 elif action == "stop" :
@@ -98,14 +105,14 @@ def listenerAssistantMethod(self, action, hash, str3, str4):
98105
99106 def consoleAssistantMethod (self , action , beaconHash , listenerHash , context , cmd , result ):
100107 if action == "receive" :
101- print ("consoleAssistantMethod" , "-Context:\n " + context + "\n \n -Command sent:\n " + cmd + "\n \n -Response:\n " + result )
108+ # print("consoleAssistantMethod", "-Context:\n" + context + "\n\n-Command sent:\n" + cmd + "\n\n-Response:\n" + result)
102109 self .messages .append ({"role" : "user" , "content" : cmd + "\n " + result })
103110 elif action == "send" :
104111 toto = 1
105112
106113
107114 def event (self , event ):
108- if event .type () == QEvent .KeyPress and event .key () == Qt .Key_Tab :
115+ if event .type () == QEvent .Type . KeyPress and event .key () == Qt . Key .Key_Tab :
109116 self .tabPressed .emit ()
110117 return True
111118 return super ().event (event )
@@ -279,13 +286,13 @@ def runCommand(self):
279286 self .printInTerminal ("User:" , commandLine )
280287
281288 message = response .choices [0 ].message
282- print (message )
289+ # print(message)
283290
284291 function_call = message .function_call
285292 if function_call :
286293 name = function_call .name
287294 args = json .loads (function_call .arguments )
288- print (f"Model wants to call `{ name } ` with arguments: { args } " )
295+ # print(f"Model wants to call `{name}` with arguments: {args}")
289296
290297 self .printInTerminal ("Analysis:" , f"Model wants to call `{ name } ` with arguments: { args } " )
291298
@@ -381,7 +388,7 @@ def executeCmd(self, cmd, args):
381388 # setCursorEditorAtEnd
382389 def setCursorEditorAtEnd (self ):
383390 cursor = self .editorOutput .textCursor ()
384- cursor .movePosition (QTextCursor .End , )
391+ cursor .movePosition (QTextCursor .MoveOperation . End )
385392 self .editorOutput .setTextCursor (cursor )
386393
387394
@@ -393,8 +400,8 @@ class CommandEditor(QLineEdit):
393400 def __init__ (self , parent = None ):
394401 super ().__init__ (parent )
395402
396- QShortcut (Qt .Key_Up , self , self .historyUp )
397- QShortcut (Qt .Key_Down , self , self .historyDown )
403+ QShortcut (Qt .Key . Key_Up , self , self .historyUp )
404+ QShortcut (Qt .Key . Key_Down , self , self .historyDown )
398405
399406 # self.codeCompleter = CodeCompleter(completerData, self)
400407 # # needed to clear the completer after activation
@@ -410,7 +417,7 @@ def nextCompletion(self):
410417 self .codeCompleter .setCurrentRow (0 )
411418
412419 def event (self , event ):
413- if event .type () == QEvent .KeyPress and event .key () == Qt .Key_Tab :
420+ if event .type () == QEvent .Type . KeyPress and event .key () == Qt . Key .Key_Tab :
414421 self .tabPressed .emit ()
415422 return True
416423 return super ().event (event )
@@ -441,7 +448,7 @@ def onActivated(self):
441448
442449
443450class CodeCompleter (QCompleter ):
444- ConcatenationRole = Qt .UserRole + 1
451+ ConcatenationRole = Qt .ItemDataRole . UserRole + 1
445452
446453 def __init__ (self , data , parent = None ):
447454 super ().__init__ (parent )
0 commit comments