yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::cli::agent::AgentContext Class Reference

Agent context for maintaining state across tool calls. More...

#include <agent_context.h>

Collaboration diagram for yaze::cli::agent::AgentContext:

Public Member Functions

 AgentContext ()=default
 
void SetRom (Rom *rom)
 Set the current ROM context.
 
RomGetRom () const
 Get the current ROM context.
 
bool HasRom () const
 Check if a ROM is loaded.
 
const std::string & GetRomPath () const
 Get the current ROM path.
 
void SetRomPath (const std::string &path)
 Set the current ROM path.
 
void AddPendingEdit (const RomEdit &edit)
 Record a pending ROM edit.
 
const std::vector< RomEdit > & GetPendingEdits () const
 Get all pending edits.
 
bool HasPendingEdits () const
 Check if there are pending edits.
 
void ClearPendingEdits ()
 Clear all pending edits.
 
absl::Status CommitPendingEdits ()
 Commit all pending edits to the ROM.
 
void RollbackPendingEdits ()
 Rollback all pending edits.
 
void RecordToolCall (const ToolCallRecord &record)
 Record a tool call.
 
const std::vector< ToolCallRecord > & GetCallHistory () const
 Get tool call history.
 
std::vector< ToolCallRecordGetRecentCalls (size_t n) const
 Get the last N tool calls.
 
void ClearCallHistory ()
 Clear tool call history.
 
void SetVariable (const std::string &key, const std::string &value)
 Set a session variable.
 
std::optional< std::string > GetVariable (const std::string &key) const
 Get a session variable.
 
bool HasVariable (const std::string &key) const
 Check if a session variable exists.
 
void ClearVariables ()
 Clear all session variables.
 
const std::map< std::string, std::string > & GetAllVariables () const
 Get all session variables.
 
DungeonCacheGetDungeonCache ()
 Get dungeon cache.
 
const DungeonCacheGetDungeonCache () const
 
OverworldCacheGetOverworldCache ()
 Get overworld cache.
 
const OverworldCacheGetOverworldCache () const
 
void InvalidateCaches ()
 Invalidate all caches.
 
const std::string & GetSessionId () const
 Get session ID.
 
void SetSessionId (const std::string &id)
 Set session ID.
 
std::chrono::system_clock::time_point GetSessionStartTime () const
 Get session start time.
 
void ResetSession ()
 Reset the session (clear all state except ROM)
 
std::string GenerateSummary () const
 Generate a summary of the current context.
 

Private Attributes

Romcurrent_rom_ = nullptr
 
std::string rom_path_
 
std::vector< RomEditpending_edits_
 
std::vector< ToolCallRecordcall_history_
 
std::map< std::string, std::string > session_vars_
 
std::string session_id_
 
std::chrono::system_clock::time_point session_start_time_
 
DungeonCache dungeon_cache_
 
OverworldCache overworld_cache_
 
size_t max_history_size_ = 100
 

Detailed Description

Agent context for maintaining state across tool calls.

Provides:

  • ROM state management
  • Pending edit tracking
  • Tool call history
  • Session variables
  • Caching for frequently accessed data

Definition at line 100 of file agent_context.h.

Constructor & Destructor Documentation

◆ AgentContext()

yaze::cli::agent::AgentContext::AgentContext ( )
default

Member Function Documentation

◆ SetRom()

void yaze::cli::agent::AgentContext::SetRom ( Rom * rom)
inline

Set the current ROM context.

Definition at line 111 of file agent_context.h.

References current_rom_, and InvalidateCaches().

Here is the call graph for this function:

◆ GetRom()

Rom * yaze::cli::agent::AgentContext::GetRom ( ) const
inline

Get the current ROM context.

Definition at line 119 of file agent_context.h.

References current_rom_.

◆ HasRom()

bool yaze::cli::agent::AgentContext::HasRom ( ) const
inline

Check if a ROM is loaded.

Definition at line 124 of file agent_context.h.

References current_rom_.

◆ GetRomPath()

const std::string & yaze::cli::agent::AgentContext::GetRomPath ( ) const
inline

Get the current ROM path.

Definition at line 129 of file agent_context.h.

References rom_path_.

◆ SetRomPath()

void yaze::cli::agent::AgentContext::SetRomPath ( const std::string & path)
inline

Set the current ROM path.

Definition at line 134 of file agent_context.h.

References rom_path_.

◆ AddPendingEdit()

void yaze::cli::agent::AgentContext::AddPendingEdit ( const RomEdit & edit)
inline

Record a pending ROM edit.

Definition at line 143 of file agent_context.h.

References pending_edits_.

◆ GetPendingEdits()

const std::vector< RomEdit > & yaze::cli::agent::AgentContext::GetPendingEdits ( ) const
inline

Get all pending edits.

Definition at line 148 of file agent_context.h.

References pending_edits_.

◆ HasPendingEdits()

bool yaze::cli::agent::AgentContext::HasPendingEdits ( ) const
inline

Check if there are pending edits.

Definition at line 153 of file agent_context.h.

References pending_edits_.

◆ ClearPendingEdits()

void yaze::cli::agent::AgentContext::ClearPendingEdits ( )
inline

Clear all pending edits.

Definition at line 158 of file agent_context.h.

References pending_edits_.

◆ CommitPendingEdits()

absl::Status yaze::cli::agent::AgentContext::CommitPendingEdits ( )
inline

Commit all pending edits to the ROM.

Definition at line 163 of file agent_context.h.

References current_rom_, InvalidateCaches(), pending_edits_, and yaze::Rom::WriteByte().

Here is the call graph for this function:

◆ RollbackPendingEdits()

void yaze::cli::agent::AgentContext::RollbackPendingEdits ( )
inline

Rollback all pending edits.

Definition at line 182 of file agent_context.h.

References pending_edits_.

◆ RecordToolCall()

void yaze::cli::agent::AgentContext::RecordToolCall ( const ToolCallRecord & record)
inline

Record a tool call.

Definition at line 194 of file agent_context.h.

References call_history_, and max_history_size_.

◆ GetCallHistory()

const std::vector< ToolCallRecord > & yaze::cli::agent::AgentContext::GetCallHistory ( ) const
inline

Get tool call history.

Definition at line 206 of file agent_context.h.

References call_history_.

◆ GetRecentCalls()

std::vector< ToolCallRecord > yaze::cli::agent::AgentContext::GetRecentCalls ( size_t n) const
inline

Get the last N tool calls.

Definition at line 213 of file agent_context.h.

References call_history_.

◆ ClearCallHistory()

void yaze::cli::agent::AgentContext::ClearCallHistory ( )
inline

Clear tool call history.

Definition at line 224 of file agent_context.h.

References call_history_.

◆ SetVariable()

void yaze::cli::agent::AgentContext::SetVariable ( const std::string & key,
const std::string & value )
inline

Set a session variable.

Definition at line 233 of file agent_context.h.

References session_vars_.

◆ GetVariable()

std::optional< std::string > yaze::cli::agent::AgentContext::GetVariable ( const std::string & key) const
inline

Get a session variable.

Definition at line 240 of file agent_context.h.

References session_vars_.

◆ HasVariable()

bool yaze::cli::agent::AgentContext::HasVariable ( const std::string & key) const
inline

Check if a session variable exists.

Definition at line 251 of file agent_context.h.

References session_vars_.

◆ ClearVariables()

void yaze::cli::agent::AgentContext::ClearVariables ( )
inline

Clear all session variables.

Definition at line 258 of file agent_context.h.

References session_vars_.

◆ GetAllVariables()

const std::map< std::string, std::string > & yaze::cli::agent::AgentContext::GetAllVariables ( ) const
inline

Get all session variables.

Definition at line 263 of file agent_context.h.

References session_vars_.

◆ GetDungeonCache() [1/2]

DungeonCache & yaze::cli::agent::AgentContext::GetDungeonCache ( )
inline

Get dungeon cache.

Definition at line 274 of file agent_context.h.

References dungeon_cache_.

◆ GetDungeonCache() [2/2]

const DungeonCache & yaze::cli::agent::AgentContext::GetDungeonCache ( ) const
inline

Definition at line 275 of file agent_context.h.

References dungeon_cache_.

◆ GetOverworldCache() [1/2]

OverworldCache & yaze::cli::agent::AgentContext::GetOverworldCache ( )
inline

Get overworld cache.

Definition at line 280 of file agent_context.h.

References overworld_cache_.

◆ GetOverworldCache() [2/2]

const OverworldCache & yaze::cli::agent::AgentContext::GetOverworldCache ( ) const
inline

Definition at line 281 of file agent_context.h.

References overworld_cache_.

◆ InvalidateCaches()

void yaze::cli::agent::AgentContext::InvalidateCaches ( )
inline

Invalidate all caches.

Definition at line 286 of file agent_context.h.

References dungeon_cache_, yaze::cli::agent::DungeonCache::Invalidate(), yaze::cli::agent::OverworldCache::Invalidate(), and overworld_cache_.

Referenced by CommitPendingEdits(), ResetSession(), and SetRom().

Here is the call graph for this function:

◆ GetSessionId()

const std::string & yaze::cli::agent::AgentContext::GetSessionId ( ) const
inline

Get session ID.

Definition at line 298 of file agent_context.h.

References session_id_.

◆ SetSessionId()

void yaze::cli::agent::AgentContext::SetSessionId ( const std::string & id)
inline

Set session ID.

Definition at line 303 of file agent_context.h.

References session_id_.

◆ GetSessionStartTime()

std::chrono::system_clock::time_point yaze::cli::agent::AgentContext::GetSessionStartTime ( ) const
inline

Get session start time.

Definition at line 308 of file agent_context.h.

References session_start_time_.

◆ ResetSession()

void yaze::cli::agent::AgentContext::ResetSession ( )
inline

Reset the session (clear all state except ROM)

Definition at line 315 of file agent_context.h.

References call_history_, InvalidateCaches(), pending_edits_, session_start_time_, and session_vars_.

Here is the call graph for this function:

◆ GenerateSummary()

std::string yaze::cli::agent::AgentContext::GenerateSummary ( ) const
inline

Generate a summary of the current context.

Definition at line 326 of file agent_context.h.

References call_history_, current_rom_, dungeon_cache_, yaze::cli::agent::DungeonCache::IsValid(), yaze::cli::agent::OverworldCache::IsValid(), overworld_cache_, pending_edits_, rom_path_, and session_vars_.

Here is the call graph for this function:

Member Data Documentation

◆ current_rom_

Rom* yaze::cli::agent::AgentContext::current_rom_ = nullptr
private

Definition at line 345 of file agent_context.h.

Referenced by CommitPendingEdits(), GenerateSummary(), GetRom(), HasRom(), and SetRom().

◆ rom_path_

std::string yaze::cli::agent::AgentContext::rom_path_
private

Definition at line 346 of file agent_context.h.

Referenced by GenerateSummary(), GetRomPath(), and SetRomPath().

◆ pending_edits_

std::vector<RomEdit> yaze::cli::agent::AgentContext::pending_edits_
private

◆ call_history_

std::vector<ToolCallRecord> yaze::cli::agent::AgentContext::call_history_
private

◆ session_vars_

std::map<std::string, std::string> yaze::cli::agent::AgentContext::session_vars_
private

◆ session_id_

std::string yaze::cli::agent::AgentContext::session_id_
private

Definition at line 352 of file agent_context.h.

Referenced by GetSessionId(), and SetSessionId().

◆ session_start_time_

std::chrono::system_clock::time_point yaze::cli::agent::AgentContext::session_start_time_
private
Initial value:
=
std::chrono::system_clock::now()

Definition at line 353 of file agent_context.h.

Referenced by GetSessionStartTime(), and ResetSession().

◆ dungeon_cache_

DungeonCache yaze::cli::agent::AgentContext::dungeon_cache_
private

◆ overworld_cache_

OverworldCache yaze::cli::agent::AgentContext::overworld_cache_
private

◆ max_history_size_

size_t yaze::cli::agent::AgentContext::max_history_size_ = 100
private

Definition at line 361 of file agent_context.h.

Referenced by RecordToolCall().


The documentation for this class was generated from the following file: