yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
agent_state.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_AGENT_AGENT_STATE_H_
2#define YAZE_APP_EDITOR_AGENT_AGENT_STATE_H_
3
4#include <filesystem>
5#include <functional>
6#include <optional>
7#include <string>
8#include <vector>
9
10#include "absl/status/status.h"
11#include "absl/status/statusor.h"
12#include "absl/time/time.h"
13#include "imgui/imgui.h"
14#include "core/project.h"
15#include "core/asar_wrapper.h"
16
17namespace yaze {
18
19class Rom;
20
21namespace editor {
22
23// ============================================================================
24// Collaboration State
25// ============================================================================
26
31 kLocal = 0, // Filesystem-based collaboration
32 kNetwork = 1 // WebSocket-based collaboration
33};
34
39 bool active = false;
41 std::string session_id;
42 std::string session_name;
43 std::string server_url = "ws://localhost:8765";
44 bool server_connected = false;
45 std::vector<std::string> participants;
46 absl::Time last_synced = absl::InfinitePast();
47};
48
49// ============================================================================
50// Multimodal State
51// ============================================================================
52
56enum class CaptureMode {
57 kFullWindow = 0,
58 kActiveEditor = 1,
61};
62
67 void* texture_id = nullptr; // ImTextureID
68 int width = 0;
69 int height = 0;
70 bool loaded = false;
71 float preview_scale = 1.0f;
72 bool show_preview = true;
73};
74
79 bool active = false;
80 bool dragging = false;
81 ImVec2 start_pos;
82 ImVec2 end_pos;
85};
86
99
100// ============================================================================
101// Automation State
102// ============================================================================
103
108 std::string test_id;
109 std::string name;
110 std::string status;
111 std::string message;
112 absl::Time updated_at = absl::InfinitePast();
113};
114
119 std::vector<AutomationTelemetry> recent_tests;
120 bool harness_connected = false;
121 absl::Time last_poll = absl::InfinitePast();
124 float pulse_animation = 0.0f;
125 float scanline_offset = 0.0f;
127 absl::Time last_connection_attempt = absl::InfinitePast();
128 std::string grpc_server_address = "localhost:50052";
129 bool auto_run_plan = false;
130 bool auto_sync_rom = true;
132};
133
134// ============================================================================
135// Agent Configuration
136// ============================================================================
137
142 std::string name;
143 std::string model;
144 std::string host;
145 std::vector<std::string> tags;
146 bool pinned = false;
147 absl::Time last_used = absl::InfinitePast();
148};
149
154 bool resources = true;
155 bool dungeon = true;
156 bool overworld = true;
157 bool dialogue = true;
158 bool messages = true;
159 bool gui = true;
160 bool music = true;
161 bool sprite = true;
162 bool emulator = true;
163};
164
168enum class ChainMode {
169 kDisabled = 0,
170 kRoundRobin = 1,
171 kConsensus = 2,
172};
173
178 std::string ai_provider = "mock"; // mock, ollama, gemini, openai
179 std::string ai_model;
180 std::string ollama_host = "http://localhost:11434";
181 std::string gemini_api_key;
182 std::string openai_api_key;
183 bool verbose = false;
184 bool show_reasoning = true;
187 float temperature = 0.25f;
188 float top_p = 0.95f;
190 bool stream_responses = false;
191 std::vector<std::string> favorite_models;
192 std::vector<std::string> model_chain;
194 std::vector<ModelPreset> model_presets;
196
197 // Input buffers for UI
198 char provider_buffer[32] = "mock";
199 char model_buffer[128] = {};
200 char ollama_host_buffer[256] = "http://localhost:11434";
201 char gemini_key_buffer[256] = {};
202 char openai_key_buffer[256] = {};
203};
204
205// ============================================================================
206// ROM Sync State
207// ============================================================================
208
213 std::string current_rom_hash;
214 absl::Time last_sync_time = absl::InfinitePast();
215 bool auto_sync_enabled = false;
217 std::vector<std::string> pending_syncs;
218};
219
220// ============================================================================
221// Z3ED Command State
222// ============================================================================
223
228 std::string last_command;
229 std::string command_output;
230 bool command_running = false;
231 char command_input_buffer[512] = {};
232};
233
234// ============================================================================
235// Knowledge Base State
236// ============================================================================
237
242 bool initialized = false;
245 absl::Time last_refresh = absl::InfinitePast();
246
247 // Cached stats for display
252};
253
254// ============================================================================
255// Tool Execution State
256// ============================================================================
257
262 std::string tool_name;
263 std::string arguments;
264 std::string result_preview;
265 double duration_ms = 0.0;
266 bool success = true;
267 absl::Time executed_at = absl::InfinitePast();
268};
269
274 std::vector<ToolExecutionEntry> recent_executions;
275 bool show_timeline = false;
276 int max_entries = 50;
277};
278
279// ============================================================================
280// Persona Profile
281// ============================================================================
282
287 std::string notes;
288 std::vector<std::string> goals;
289 absl::Time applied_at = absl::InfinitePast();
290 bool active = false;
291};
292
293// ============================================================================
294// Chat State
295// ============================================================================
296
300struct ChatState {
301 char input_buffer[1024] = {};
302 bool active = false;
304 float thinking_animation = 0.0f;
305 std::string pending_message;
307 bool history_loaded = false;
308 bool history_dirty = false;
309 bool history_supported = true;
311 std::filesystem::path history_path;
313 absl::Time last_persist_time = absl::InfinitePast();
314
315 // Session management
316 std::string active_session_id;
317 absl::Time last_shared_history_poll = absl::InfinitePast();
319
320 // UI state
321 int active_tab = 0; // 0=Chat, 1=Config, 2=Commands, etc.
322 bool scroll_to_bottom = false;
323};
324
325// ============================================================================
326// Proposal State
327// ============================================================================
328
343
344// ============================================================================
345// Unified Agent Context (for UI components)
346// ============================================================================
347
356 public:
357 AgentUIContext() = default;
358
359 // State accessors (mutable for UI updates)
361 const ChatState& chat_state() const { return chat_state_; }
362
367
370
373
375 const AgentConfigState& agent_config() const { return agent_config_; }
376
378 const RomSyncState& rom_sync_state() const { return rom_sync_state_; }
379
382 return z3ed_command_state_;
383 }
384
387
390
393
398
399 // ROM context
400 void SetRom(Rom* rom) { rom_ = rom; }
401 Rom* GetRom() const { return rom_; }
402 bool HasRom() const { return rom_ != nullptr; }
403
404 // Project context
405 void SetProject(project::YazeProject* project) { project_ = project; }
407 bool HasProject() const { return project_ != nullptr; }
408
409 // Asar wrapper context
410 void SetAsarWrapper(core::AsarWrapper* asar_wrapper) { asar_wrapper_ = asar_wrapper; }
412 bool HasAsarWrapper() const { return asar_wrapper_ != nullptr; }
413
414 // Change notification for observers
415 using ChangeCallback = std::function<void()>;
417 change_listeners_.push_back(std::move(callback));
418 }
420 for (auto& callback : change_listeners_) {
421 callback();
422 }
423 }
424
425 private:
437
438 Rom* rom_ = nullptr;
439 project::YazeProject* project_ = nullptr; // Project context
440 core::AsarWrapper* asar_wrapper_ = nullptr; // AsarWrapper context
441 std::vector<ChangeCallback> change_listeners_;
442};
443
444// ============================================================================
445// Callback Structures (for component communication)
446// ============================================================================
447
453 std::string session_id;
454 std::string session_name;
455 std::vector<std::string> participants;
456 };
457
458 std::function<absl::StatusOr<SessionContext>(const std::string&)>
460 std::function<absl::StatusOr<SessionContext>(const std::string&)>
462 std::function<absl::Status()> leave_session;
463 std::function<absl::StatusOr<SessionContext>()> refresh_session;
464};
465
470 std::function<absl::Status(std::filesystem::path*)> capture_snapshot;
471 std::function<absl::Status(const std::filesystem::path&, const std::string&)>
473};
474
479 std::function<void()> open_harness_dashboard;
480 std::function<void()> replay_last_plan;
481 std::function<void(const std::string&)> focus_proposal;
482 std::function<void()> show_active_tests;
483 std::function<void()> poll_status;
484};
485
490 std::function<absl::Status(const std::string&)> run_agent_task;
491 std::function<absl::StatusOr<std::string>(const std::string&)>
493 std::function<absl::StatusOr<std::string>(const std::string&)> diff_proposal;
494 std::function<absl::Status(const std::string&)> accept_proposal;
495 std::function<absl::Status(const std::string&)> reject_proposal;
496 std::function<absl::StatusOr<std::vector<std::string>>()> list_proposals;
497};
498
503 std::function<absl::StatusOr<std::string>()> generate_rom_diff;
504 std::function<absl::Status(const std::string&, const std::string&)>
506 std::function<std::string()> get_rom_hash;
507};
508
513 std::function<void(const std::string&)> focus_proposal;
514 std::function<absl::Status(const std::string&)> accept_proposal;
515 std::function<absl::Status(const std::string&)> reject_proposal;
516 std::function<void()> refresh_proposals;
517};
518
523 std::function<void(const std::string&)> send_message;
524 std::function<void()> clear_history;
525 std::function<void()> persist_history;
526 std::function<void(const std::string&)> switch_session;
527};
528
529} // namespace editor
530} // namespace yaze
531
532#endif // YAZE_APP_EDITOR_AGENT_AGENT_STATE_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
Modern C++ wrapper for Asar 65816 assembler integration.
Unified context for agent UI components.
const ProposalState & proposal_state() const
core::AsarWrapper * GetAsarWrapper() const
MultimodalState & multimodal_state()
Z3EDCommandState & z3ed_command_state()
project::YazeProject * GetProject() const
AutomationState & automation_state()
const MultimodalState & multimodal_state() const
AutomationState automation_state_
const Z3EDCommandState & z3ed_command_state() const
void SetProject(project::YazeProject *project)
std::function< void()> ChangeCallback
const AutomationState & automation_state() const
const KnowledgeState & knowledge_state() const
ToolExecutionState & tool_execution_state()
KnowledgeState & knowledge_state()
AgentConfigState & agent_config()
const CollaborationState & collaboration_state() const
RomSyncState & rom_sync_state()
CollaborationState & collaboration_state()
void AddChangeListener(ChangeCallback callback)
const PersonaProfile & persona_profile() const
ToolExecutionState tool_execution_state_
const ToolExecutionState & tool_execution_state() const
const RomSyncState & rom_sync_state() const
void SetAsarWrapper(core::AsarWrapper *asar_wrapper)
CollaborationState collaboration_state_
Z3EDCommandState z3ed_command_state_
core::AsarWrapper * asar_wrapper_
const AgentConfigState & agent_config() const
PersonaProfile & persona_profile()
PersonaProfile persona_profile_
KnowledgeState knowledge_state_
MultimodalState multimodal_state_
project::YazeProject * project_
std::vector< ChangeCallback > change_listeners_
AgentConfigState agent_config_
const ChatState & chat_state() const
ProposalState & proposal_state()
ChainMode
Model chain mode for multi-model responses.
CollaborationMode
Collaboration mode for multi-user sessions.
Definition agent_state.h:30
CaptureMode
Screenshot capture mode.
Definition agent_state.h:56
Agent configuration state.
std::vector< std::string > model_chain
std::vector< ModelPreset > model_presets
std::vector< std::string > favorite_models
Callbacks for automation operations.
std::function< void()> show_active_tests
std::function< void(const std::string &) focus_proposal)
std::function< void()> open_harness_dashboard
std::function< void()> replay_last_plan
std::function< void()> poll_status
State for automation/test harness integration.
std::vector< AutomationTelemetry > recent_tests
Telemetry from automation/test harness.
Callbacks for chat operations.
std::function< void(const std::string &) switch_session)
std::function< void(const std::string &) send_message)
std::function< void()> persist_history
std::function< void()> clear_history
State for chat UI and history.
std::string active_session_id
absl::Time last_shared_history_poll
std::filesystem::path history_path
std::string pending_message
Callbacks for collaboration operations.
std::function< absl::StatusOr< SessionContext >(const std::string &) join_session)
std::function< absl::Status()> leave_session
std::function< absl::StatusOr< SessionContext >(const std::string &) host_session)
std::function< absl::StatusOr< SessionContext >()> refresh_session
State for collaborative editing sessions.
Definition agent_state.h:38
std::vector< std::string > participants
Definition agent_state.h:45
State for learned knowledge management (CLI integration)
Model preset for quick switching.
std::vector< std::string > tags
Callbacks for multimodal/vision operations.
std::function< absl::Status(std::filesystem::path *) capture_snapshot)
std::function< absl::Status(const std::filesystem::path &, const std::string &) send_to_gemini)
State for multimodal/vision features.
Definition agent_state.h:90
ScreenshotPreviewState preview
Definition agent_state.h:96
std::optional< std::filesystem::path > last_capture_path
Definition agent_state.h:91
RegionSelectionState region_selection
Definition agent_state.h:97
User persona profile for personalized AI behavior.
std::vector< std::string > goals
Callbacks for proposal operations.
std::function< absl::Status(const std::string &) reject_proposal)
std::function< absl::Status(const std::string &) accept_proposal)
std::function< void(const std::string &) focus_proposal)
std::function< void()> refresh_proposals
State for proposal management.
std::string pending_focus_proposal_id
Region selection state for screenshot cropping.
Definition agent_state.h:78
Callbacks for ROM sync operations.
std::function< std::string()> get_rom_hash
std::function< absl::Status(const std::string &, const std::string &) apply_rom_diff)
std::function< absl::StatusOr< std::string >()> generate_rom_diff
State for ROM synchronization.
std::vector< std::string > pending_syncs
Preview state for captured screenshots.
Definition agent_state.h:66
Tool enablement configuration.
Single tool execution entry for timeline display.
State for tool execution timeline display.
std::vector< ToolExecutionEntry > recent_executions
Callbacks for Z3ED command operations.
std::function< absl::StatusOr< std::vector< std::string > >()> list_proposals
std::function< absl::Status(const std::string &) reject_proposal)
std::function< absl::Status(const std::string &) run_agent_task)
std::function< absl::Status(const std::string &) accept_proposal)
std::function< absl::StatusOr< std::string >(const std::string &) diff_proposal)
std::function< absl::StatusOr< std::string >(const std::string &) plan_agent_task)
State for Z3ED command palette.
Modern project structure with comprehensive settings consolidation.
Definition project.h:84