Integrate AI Agent Services and Chat Interface

- Added support for AI agent services, including `ConversationalAgentService`, to facilitate user interactions through a chat interface.
- Implemented `ChatTUI` for a terminal-based chat experience, allowing users to send messages and receive responses from the AI agent.
- Updated `EditorManager` to include options for displaying the agent chat widget and performance dashboard.
- Enhanced CMake configurations to include new source files for AI services and chat interface components.

This commit significantly expands the functionality of the z3ed system, paving the way for a more interactive and user-friendly experience in ROM hacking.
This commit is contained in:
scawful
2025-10-03 12:39:48 -04:00
parent 655c5547b2
commit 208b9ade51
25 changed files with 689 additions and 242 deletions

57
src/cli/tui/chat_tui.cc Normal file
View File

@@ -0,0 +1,57 @@
#include "cli/tui/chat_tui.h"
#include <vector>
#include "ftxui/component/captured_mouse.hpp"
#include "ftxui/component/component.hpp"
#include "ftxui/component/component_base.hpp"
#include "ftxui/component/screen_interactive.hpp"
#include "ftxui/dom/elements.hpp"
namespace yaze {
namespace cli {
namespace tui {
using namespace ftxui;
ChatTUI::ChatTUI() = default;
void ChatTUI::Run() {
auto input = Input(&input_message_, "Enter your message...");
auto button = Button("Send", [this] { OnSubmit(); });
auto layout = Container::Vertical({
input,
button,
});
auto renderer = Renderer(layout, [this] {
std::vector<Element> messages;
for (const auto& msg : agent_service_.GetHistory()) {
std::string prefix =
msg.sender == agent::ChatMessage::Sender::kUser ? "You: " : "Agent: ";
messages.push_back(text(prefix + msg.message));
}
return vbox({
vbox(messages) | flex,
separator(),
hbox(text(" > "), text(input_message_)),
}) |
border;
});
screen_.Loop(renderer);
}
void ChatTUI::OnSubmit() {
if (input_message_.empty()) {
return;
}
(void)agent_service_.SendMessage(input_message_);
input_message_.clear();
}
} // namespace tui
} // namespace cli
} // namespace yaze

30
src/cli/tui/chat_tui.h Normal file
View File

@@ -0,0 +1,30 @@
#ifndef YAZE_SRC_CLI_TUI_CHAT_TUI_H_
#define YAZE_SRC_CLI_TUI_CHAT_TUI_H_
#include "ftxui/component/component.hpp"
#include "ftxui/component/screen_interactive.hpp"
#include "cli/service/agent/conversational_agent_service.h"
namespace yaze {
namespace cli {
namespace tui {
class ChatTUI {
public:
ChatTUI();
void Run();
private:
void Render();
void OnSubmit();
ftxui::ScreenInteractive screen_ = ftxui::ScreenInteractive::Fullscreen();
std::string input_message_;
agent::ConversationalAgentService agent_service_;
};
} // namespace tui
} // namespace cli
} // namespace yaze
#endif // YAZE_SRC_CLI_TUI_CHAT_TUI_H_