9#ifndef YAZE_SRC_CLI_SERVICE_AGENT_AGENT_CONTEXT_H_
10#define YAZE_SRC_CLI_SERVICE_AGENT_AGENT_CONTEXT_H_
58 auto age = std::chrono::system_clock::now() -
last_updated;
59 return std::chrono::duration_cast<std::chrono::minutes>(age).count() < 5;
79 auto age = std::chrono::system_clock::now() -
last_updated;
80 return std::chrono::duration_cast<std::chrono::minutes>(age).count() < 5;
165 return absl::FailedPreconditionError(
"No ROM loaded");
169 for (
size_t i = 0; i < edit.new_value.size(); ++i) {
176 return absl::OkStatus();
233 void SetVariable(
const std::string& key,
const std::string& value) {
240 std::optional<std::string>
GetVariable(
const std::string& key)
const {
327 std::ostringstream ss;
328 ss <<
"Agent Context Summary:\n";
329 ss <<
" ROM loaded: " << (
current_rom_ ?
"Yes" :
"No") <<
"\n";
331 ss <<
" ROM path: " <<
rom_path_ <<
"\n";
334 ss <<
" Tool calls in history: " <<
call_history_.size() <<
"\n";
335 ss <<
" Session variables: " <<
session_vars_.size() <<
"\n";
336 ss <<
" Dungeon cache valid: "
338 ss <<
" Overworld cache valid: "
354 std::chrono::system_clock::now();
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
absl::Status WriteByte(int addr, uint8_t value)
Agent context for maintaining state across tool calls.
void SetRom(Rom *rom)
Set the current ROM context.
std::vector< ToolCallRecord > call_history_
std::chrono::system_clock::time_point session_start_time_
std::vector< RomEdit > pending_edits_
bool HasRom() const
Check if a ROM is loaded.
bool HasVariable(const std::string &key) const
Check if a session variable exists.
void ClearVariables()
Clear all session variables.
bool HasPendingEdits() const
Check if there are pending edits.
void ResetSession()
Reset the session (clear all state except ROM)
void SetVariable(const std::string &key, const std::string &value)
Set a session variable.
std::map< std::string, std::string > session_vars_
std::chrono::system_clock::time_point GetSessionStartTime() const
Get session start time.
DungeonCache dungeon_cache_
Rom * GetRom() const
Get the current ROM context.
const DungeonCache & GetDungeonCache() const
std::string GenerateSummary() const
Generate a summary of the current context.
void SetRomPath(const std::string &path)
Set the current ROM path.
void InvalidateCaches()
Invalidate all caches.
void ClearPendingEdits()
Clear all pending edits.
OverworldCache & GetOverworldCache()
Get overworld cache.
absl::Status CommitPendingEdits()
Commit all pending edits to the ROM.
const std::vector< ToolCallRecord > & GetCallHistory() const
Get tool call history.
const std::vector< RomEdit > & GetPendingEdits() const
Get all pending edits.
void RollbackPendingEdits()
Rollback all pending edits.
void AddPendingEdit(const RomEdit &edit)
Record a pending ROM edit.
const OverworldCache & GetOverworldCache() const
OverworldCache overworld_cache_
const std::string & GetSessionId() const
Get session ID.
std::optional< std::string > GetVariable(const std::string &key) const
Get a session variable.
const std::string & GetRomPath() const
Get the current ROM path.
void RecordToolCall(const ToolCallRecord &record)
Record a tool call.
void ClearCallHistory()
Clear tool call history.
std::vector< ToolCallRecord > GetRecentCalls(size_t n) const
Get the last N tool calls.
const std::map< std::string, std::string > & GetAllVariables() const
Get all session variables.
void SetSessionId(const std::string &id)
Set session ID.
DungeonCache & GetDungeonCache()
Get dungeon cache.
Cached dungeon data for efficient access.
std::vector< int > visited_rooms
std::map< int, std::string > room_descriptions
std::chrono::system_clock::time_point last_updated
Cached overworld data for efficient access.
std::vector< int > visited_maps
std::map< int, std::string > map_descriptions
std::chrono::system_clock::time_point last_updated
Record of a ROM edit operation.
std::vector< uint8_t > new_value
std::chrono::system_clock::time_point timestamp
std::vector< uint8_t > old_value