yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
agent_editor.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_AGENT_AGENT_EDITOR_H_
2#define YAZE_APP_EDITOR_AGENT_AGENT_EDITOR_H_
3
4#include <memory>
5#include <optional>
6#include <string>
7#include <filesystem>
8#include <vector>
9
10#include "absl/status/status.h"
11#include "absl/status/statusor.h"
12#include "app/editor/editor.h"
15
16namespace yaze {
17
18class Rom;
19
20namespace editor {
21
22class ToastManager;
23class ProposalDrawer;
24class AgentChatWidget;
25class AgentCollaborationCoordinator;
26
27#ifdef YAZE_WITH_GRPC
28class NetworkCollaborationCoordinator;
29#endif
30
50class AgentEditor : public Editor {
51 public:
53 ~AgentEditor() override;
54
55 // Editor interface implementation
56 void Initialize() override;
57 absl::Status Load() override;
58 absl::Status Save() override;
59 absl::Status Update() override;
60 absl::Status Cut() override { return absl::UnimplementedError("Not applicable"); }
61 absl::Status Copy() override { return absl::UnimplementedError("Not applicable"); }
62 absl::Status Paste() override { return absl::UnimplementedError("Not applicable"); }
63 absl::Status Undo() override { return absl::UnimplementedError("Not applicable"); }
64 absl::Status Redo() override { return absl::UnimplementedError("Not applicable"); }
65 absl::Status Find() override { return absl::UnimplementedError("Not applicable"); }
66
67 // Initialization with dependencies
68 void InitializeWithDependencies(ToastManager* toast_manager,
69 ProposalDrawer* proposal_drawer,
70 Rom* rom);
71 void SetRomContext(Rom* rom);
72
73
74 // Main rendering (called by Update())
75 void DrawDashboard();
76
77 // Bot Configuration & Profile Management
78 struct BotProfile {
79 std::string name = "Default Bot";
80 std::string description;
81 std::string provider = "mock";
82 std::string model;
83 std::string ollama_host = "http://localhost:11434";
84 std::string gemini_api_key;
85 std::string system_prompt;
86 bool verbose = false;
87 bool show_reasoning = true;
90 std::vector<std::string> tags;
91 absl::Time created_at = absl::Now();
92 absl::Time modified_at = absl::Now();
93 };
94
95 // Legacy support
96 struct AgentConfig {
97 std::string provider = "mock";
98 std::string model;
99 std::string ollama_host = "http://localhost:11434";
100 std::string gemini_api_key;
101 bool verbose = false;
102 bool show_reasoning = true;
104 };
105
106 // Retro hacker animation state
107 float pulse_animation_ = 0.0f;
108 float scanline_offset_ = 0.0f;
109 float glitch_timer_ = 0.0f;
111
113 void ApplyConfig(const AgentConfig& config);
114
115 // Bot Profile Management
116 absl::Status SaveBotProfile(const BotProfile& profile);
117 absl::Status LoadBotProfile(const std::string& name);
118 absl::Status DeleteBotProfile(const std::string& name);
119 std::vector<BotProfile> GetAllProfiles() const;
121 void SetCurrentProfile(const BotProfile& profile);
122 absl::Status ExportProfile(const BotProfile& profile, const std::filesystem::path& path);
123 absl::Status ImportProfile(const std::filesystem::path& path);
124
125 // Chat widget access (for EditorManager)
127 bool IsChatActive() const;
128 void SetChatActive(bool active);
129 void ToggleChat();
130 void OpenChatWindow();
131
132 // Collaboration and session management
133 enum class CollaborationMode {
134 kLocal, // Filesystem-based collaboration
135 kNetwork // WebSocket-based collaboration
136 };
137
138 struct SessionInfo {
139 std::string session_id;
140 std::string session_name;
141 std::vector<std::string> participants;
142 };
143
144 absl::StatusOr<SessionInfo> HostSession(const std::string& session_name,
146 absl::StatusOr<SessionInfo> JoinSession(const std::string& session_code,
148 absl::Status LeaveSession();
149 absl::StatusOr<SessionInfo> RefreshSession();
150
160
161 absl::Status CaptureSnapshot(std::filesystem::path* output_path,
162 const CaptureConfig& config);
163 absl::Status SendToGemini(const std::filesystem::path& image_path,
164 const std::string& prompt);
165
166#ifdef YAZE_WITH_GRPC
167 absl::Status ConnectToServer(const std::string& server_url);
168 void DisconnectFromServer();
169 bool IsConnectedToServer() const;
170#endif
171
172 bool IsInSession() const;
174 std::optional<SessionInfo> GetCurrentSession() const;
175
176 // Access to underlying components
178#ifdef YAZE_WITH_GRPC
179 NetworkCollaborationCoordinator* GetNetworkCoordinator() { return network_coordinator_.get(); }
180#endif
181
182 private:
183 // Dashboard panel rendering
185 void DrawStatusPanel();
186 void DrawMetricsPanel();
193
194 // Setup callbacks
197
198 // Bot profile helpers
199 std::filesystem::path GetProfilesDirectory() const;
200 absl::Status EnsureProfilesDirectory();
201 std::string ProfileToJson(const BotProfile& profile) const;
202 absl::StatusOr<BotProfile> JsonToProfile(const std::string& json) const;
203
204 // Internal state
205 std::unique_ptr<AgentChatWidget> chat_widget_; // Owned by AgentEditor
206 std::unique_ptr<AgentCollaborationCoordinator> local_coordinator_;
207#ifdef YAZE_WITH_GRPC
208 std::unique_ptr<NetworkCollaborationCoordinator> network_coordinator_;
209#endif
210
213 Rom* rom_ = nullptr;
214
215 // Configuration state (legacy)
217
218 // Bot Profile System
220 std::vector<BotProfile> loaded_profiles_;
221
222 // System Prompt Editor
223 std::unique_ptr<TextEditor> prompt_editor_;
224 std::unique_ptr<TextEditor> common_tiles_editor_;
227 std::string active_prompt_file_ = "system_prompt_v3.txt";
228 char new_prompt_name_[128] = {};
229
230 // Collaboration state
232 bool in_session_ = false;
235 std::vector<std::string> current_participants_;
236
237 // UI state
240 bool show_bot_profiles_ = false;
241 bool show_chat_history_ = false;
243 int selected_tab_ = 0; // 0=Config, 1=Prompts, 2=Bots, 3=History, 4=Metrics
244
245 // Chat history viewer state
246 std::vector<cli::agent::ChatMessage> cached_history_;
248};
249
250} // namespace editor
251} // namespace yaze
252
253#endif // YAZE_APP_EDITOR_AGENT_AGENT_EDITOR_H_
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:71
Modern AI chat widget with comprehensive z3ed and yaze-server integration.
Comprehensive AI Agent Platform & Bot Creator.
std::unique_ptr< AgentChatWidget > chat_widget_
void SetCurrentProfile(const BotProfile &profile)
void ApplyConfig(const AgentConfig &config)
void InitializeWithDependencies(ToastManager *toast_manager, ProposalDrawer *proposal_drawer, Rom *rom)
absl::StatusOr< SessionInfo > JoinSession(const std::string &session_code, CollaborationMode mode=CollaborationMode::kLocal)
void SetChatActive(bool active)
absl::StatusOr< BotProfile > JsonToProfile(const std::string &json) const
absl::Status Find() override
absl::StatusOr< SessionInfo > RefreshSession()
absl::Status ImportProfile(const std::filesystem::path &path)
absl::Status Copy() override
void Initialize() override
ProposalDrawer * proposal_drawer_
absl::Status Redo() override
std::vector< cli::agent::ChatMessage > cached_history_
absl::Status Save() override
AgentChatWidget * GetChatWidget()
std::string current_session_name_
CollaborationMode GetCurrentMode() const
absl::Status SendToGemini(const std::filesystem::path &image_path, const std::string &prompt)
AgentCollaborationCoordinator * GetLocalCoordinator()
absl::Status EnsureProfilesDirectory()
BotProfile GetCurrentProfile() const
absl::Status Undo() override
absl::Status Paste() override
absl::Status ExportProfile(const BotProfile &profile, const std::filesystem::path &path)
CollaborationMode current_mode_
absl::Status SaveBotProfile(const BotProfile &profile)
absl::Status DeleteBotProfile(const std::string &name)
std::filesystem::path GetProfilesDirectory() const
ToastManager * toast_manager_
AgentConfig GetCurrentConfig() const
std::unique_ptr< TextEditor > common_tiles_editor_
absl::StatusOr< SessionInfo > HostSession(const std::string &session_name, CollaborationMode mode=CollaborationMode::kLocal)
std::string ProfileToJson(const BotProfile &profile) const
std::unique_ptr< TextEditor > prompt_editor_
std::unique_ptr< AgentCollaborationCoordinator > local_coordinator_
absl::Status CaptureSnapshot(std::filesystem::path *output_path, const CaptureConfig &config)
absl::Status Load() override
absl::Status LoadBotProfile(const std::string &name)
std::vector< BotProfile > GetAllProfiles() const
std::vector< std::string > current_participants_
absl::Status Update() override
std::vector< BotProfile > loaded_profiles_
absl::Status Cut() override
std::optional< SessionInfo > GetCurrentSession() const
Interface for editor classes.
Definition editor.h:82
ImGui drawer for displaying and managing agent proposals.
Main namespace for the application.
std::vector< std::string > tags
std::vector< std::string > participants