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 <filesystem>
5#include <functional>
6#include <memory>
7#include <optional>
8#include <string>
9#include <vector>
10
11#include "absl/status/status.h"
12#include "absl/status/statusor.h"
14#include "app/editor/editor.h"
17#ifdef YAZE_WITH_GRPC
19#endif
20
21namespace yaze {
22
23class Rom;
24
25namespace editor {
26
27class ToastManager;
28class ProposalDrawer;
29class AgentChat;
30class AgentCollaborationCoordinator;
31
32#ifdef YAZE_WITH_GRPC
33class NetworkCollaborationCoordinator;
34#endif
35
55class AgentEditor : public Editor {
56 public:
58 ~AgentEditor() override;
59
60 // Editor interface implementation
61 void Initialize() override;
62 absl::Status Load() override;
63 absl::Status Save() override;
64 absl::Status Update() override;
65 absl::Status Cut() override {
66 return absl::UnimplementedError("Not applicable");
67 }
68 absl::Status Copy() override {
69 return absl::UnimplementedError("Not applicable");
70 }
71 absl::Status Paste() override {
72 return absl::UnimplementedError("Not applicable");
73 }
74 absl::Status Undo() override {
75 return absl::UnimplementedError("Not applicable");
76 }
77 absl::Status Redo() override {
78 return absl::UnimplementedError("Not applicable");
79 }
80 absl::Status Find() override {
81 return absl::UnimplementedError("Not applicable");
82 }
83
84 // Initialization with dependencies
85 void InitializeWithDependencies(ToastManager* toast_manager,
86 ProposalDrawer* proposal_drawer, Rom* rom);
87 void SetRomContext(Rom* rom);
88
89 // Main rendering (called by Update())
90 void DrawDashboard();
91
92 // Bot Configuration & Profile Management
93 struct BotProfile {
94 std::string name = "Default Bot";
95 std::string description;
96 std::string provider = "mock";
97 std::string model;
98 std::string ollama_host = "http://localhost:11434";
99 std::string gemini_api_key;
100 std::string openai_api_key;
101 std::string system_prompt;
102 bool verbose = false;
103 bool show_reasoning = true;
106 float temperature = 0.25f;
107 float top_p = 0.95f;
109 bool stream_responses = false;
110 std::vector<std::string> tags;
111 absl::Time created_at = absl::Now();
112 absl::Time modified_at = absl::Now();
113 };
114
115 // Profile accessor for external sync (used by AgentUiController)
118
119 // Legacy support
120 struct AgentConfig {
121 std::string provider = "mock";
122 std::string model;
123 std::string ollama_host = "http://localhost:11434";
124 std::string gemini_api_key;
125 std::string openai_api_key;
126 bool verbose = false;
127 bool show_reasoning = true;
130 float temperature = 0.25f;
131 float top_p = 0.95f;
133 bool stream_responses = false;
134 };
135
137 struct Stage {
138 std::string name;
139 std::string summary;
140 bool completed = false;
141 };
142 std::vector<Stage> stages;
144 std::vector<std::string> goals;
145 std::string persona_notes;
146 struct ToolPlan {
147 bool resources = true;
148 bool dungeon = true;
149 bool overworld = true;
150 bool dialogue = true;
151 bool gui = false;
152 bool music = false;
153 bool sprite = false;
154 bool emulator = false;
156 bool auto_run_tests = false;
157 bool auto_sync_rom = true;
159 std::string blueprint_path;
160 bool ready_for_e2e = false;
161 };
162
163 // Retro hacker animation state
164 float pulse_animation_ = 0.0f;
165 float scanline_offset_ = 0.0f;
166 float glitch_timer_ = 0.0f;
168
170 void ApplyConfig(const AgentConfig& config);
171
172 // Bot Profile Management
173 absl::Status SaveBotProfile(const BotProfile& profile);
174 absl::Status LoadBotProfile(const std::string& name);
175 absl::Status DeleteBotProfile(const std::string& name);
176 std::vector<BotProfile> GetAllProfiles() const;
177 void SetCurrentProfile(const BotProfile& profile);
178 absl::Status ExportProfile(const BotProfile& profile,
179 const std::filesystem::path& path);
180 absl::Status ImportProfile(const std::filesystem::path& path);
181
182 // Chat widget access (for EditorManager)
183 AgentChat* GetAgentChat() { return agent_chat_.get(); }
184 bool IsChatActive() const;
185 void SetChatActive(bool active);
186 void ToggleChat();
187 void OpenChatWindow();
188
189 // Knowledge panel callback (set by AgentUiController)
190 using KnowledgePanelCallback = std::function<void()>;
192 knowledge_panel_callback_ = std::move(callback);
193 }
194
195 // Collaboration and session management
196 enum class CollaborationMode {
197 kLocal, // Filesystem-based collaboration
198 kNetwork // WebSocket-based collaboration
199 };
200
201 struct SessionInfo {
202 std::string session_id;
203 std::string session_name;
204 std::vector<std::string> participants;
205 };
206
207 absl::StatusOr<SessionInfo> HostSession(
208 const std::string& session_name,
210 absl::StatusOr<SessionInfo> JoinSession(
211 const std::string& session_code,
213 absl::Status LeaveSession();
214 absl::StatusOr<SessionInfo> RefreshSession();
215
221
222 absl::Status CaptureSnapshot(std::filesystem::path* output_path,
223 const CaptureConfig& config);
224 absl::Status SendToGemini(const std::filesystem::path& image_path,
225 const std::string& prompt);
226
227#ifdef YAZE_WITH_GRPC
228 absl::Status ConnectToServer(const std::string& server_url);
229 void DisconnectFromServer();
230 bool IsConnectedToServer() const;
231#endif
232
233 bool IsInSession() const;
235 std::optional<SessionInfo> GetCurrentSession() const;
236
237 // Access to underlying components
241#ifdef YAZE_WITH_GRPC
242 NetworkCollaborationCoordinator* GetNetworkCoordinator() {
243 return network_coordinator_.get();
244 }
245#endif
246
247 private:
248 // Dashboard panel rendering
250 void DrawStatusPanel();
251 void DrawMetricsPanel();
259
260 // Setup callbacks
263
264 // Bot profile helpers
265 std::filesystem::path GetProfilesDirectory() const;
266 absl::Status EnsureProfilesDirectory();
267 std::string ProfileToJson(const BotProfile& profile) const;
268 absl::StatusOr<BotProfile> JsonToProfile(const std::string& json) const;
269 absl::Status SaveBuilderBlueprint(const std::filesystem::path& path);
270 absl::Status LoadBuilderBlueprint(const std::filesystem::path& path);
271
272 // Internal state
273 std::unique_ptr<AgentChat> agent_chat_; // Owned by AgentEditor
274 std::unique_ptr<AgentCollaborationCoordinator> local_coordinator_;
275#ifdef YAZE_WITH_GRPC
276 std::unique_ptr<NetworkCollaborationCoordinator> network_coordinator_;
277 AutomationBridge harness_telemetry_bridge_;
278#endif
279
282 Rom* rom_ = nullptr;
283 // Note: Config syncing is managed by AgentUiController
284
285 // Configuration state (legacy)
287
288 // Bot Profile System
290 std::vector<BotProfile> loaded_profiles_;
292
293 // System Prompt Editor
294 std::unique_ptr<TextEditor> prompt_editor_;
295 std::unique_ptr<TextEditor> common_tiles_editor_;
298 std::string active_prompt_file_ = "system_prompt_v3.txt";
299 char new_prompt_name_[128] = {};
300
301 // Collaboration state
303 bool in_session_ = false;
306 std::vector<std::string> current_participants_;
307
308 // UI state (legacy)
311 bool show_bot_profiles_ = false;
312 bool show_chat_history_ = false;
314 int selected_tab_ = 0; // 0=Config, 1=Prompts, 2=Bots, 3=History, 4=Metrics
315
316 // Panel-based UI visibility flags
317 bool show_config_card_ = true;
318 bool show_status_card_ = true;
321 bool show_history_card_ = false;
322 bool show_metrics_card_ = false;
323 bool show_builder_card_ = false;
324 bool show_chat_card_ = true;
325
326 // Panel registration helper
327 void RegisterPanels();
328
329 // Chat history viewer state
330 std::vector<cli::agent::ChatMessage> cached_history_;
332
333 // Knowledge panel callback (set by AgentUiController)
335};
336
337} // namespace editor
338} // namespace yaze
339
340#endif // YAZE_APP_EDITOR_AGENT_AGENT_EDITOR_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:24
Unified Agent Chat Component.
Definition agent_chat.h:31
Comprehensive AI Agent Platform & Bot Creator.
void SetKnowledgePanelCallback(KnowledgePanelCallback callback)
void SetCurrentProfile(const BotProfile &profile)
void ApplyConfig(const AgentConfig &config)
void InitializeWithDependencies(ToastManager *toast_manager, ProposalDrawer *proposal_drawer, Rom *rom)
absl::Status SaveBuilderBlueprint(const std::filesystem::path &path)
absl::StatusOr< SessionInfo > JoinSession(const std::string &session_code, CollaborationMode mode=CollaborationMode::kLocal)
BotProfile & GetCurrentProfile()
void SetChatActive(bool active)
KnowledgePanelCallback knowledge_panel_callback_
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_
AgentBuilderState builder_state_
absl::Status Save() override
std::string current_session_name_
CollaborationMode GetCurrentMode() const
const BotProfile & GetCurrentProfile() const
absl::Status SendToGemini(const std::filesystem::path &image_path, const std::string &prompt)
AgentCollaborationCoordinator * GetLocalCoordinator()
absl::Status EnsureProfilesDirectory()
absl::Status Undo() override
absl::Status LoadBuilderBlueprint(const std::filesystem::path &path)
std::function< void()> KnowledgePanelCallback
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_
std::unique_ptr< AgentChat > agent_chat_
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:179
Rom * rom() const
Definition editor.h:227
ImGui drawer for displaying and managing agent proposals.
struct yaze::editor::AgentEditor::AgentBuilderState::ToolPlan tools
std::vector< std::string > tags
std::vector< std::string > participants