yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
conversational_agent_service.h
Go to the documentation of this file.
1#ifndef YAZE_SRC_CLI_SERVICE_AGENT_CONVERSATIONAL_AGENT_SERVICE_H_
2#define YAZE_SRC_CLI_SERVICE_AGENT_CONVERSATIONAL_AGENT_SERVICE_H_
3
4#include <filesystem>
5#include <optional>
6#include <string>
7#include <vector>
8
9#include "absl/status/status.h"
10#include "absl/status/statusor.h"
11#include "absl/time/time.h"
15// Advanced features (only available when Z3ED_AI=ON)
16#ifdef Z3ED_AI
21#endif
22
23#ifdef SendMessage
24#undef SendMessage
25#endif
26
27namespace yaze {
28
29class Rom;
30
31namespace cli {
32namespace agent {
33
35 enum class Sender { kUser, kAgent };
36 struct TableData {
37 std::vector<std::string> headers;
38 std::vector<std::vector<std::string>> rows;
39 };
41 std::string id;
42 int change_count = 0;
44 std::filesystem::path sandbox_rom_path;
45 std::filesystem::path proposal_json_path;
46 };
48 std::string message;
49 absl::Time timestamp;
50 std::optional<std::string> json_pretty;
51 std::optional<TableData> table_data;
52 bool is_internal = false; // True for tool results and other messages not meant for user display
63 std::optional<SessionMetrics> metrics;
64 std::optional<ProposalSummary> proposal;
65};
66
71 kJson
72};
73
75 int max_tool_iterations = 4; // Maximum number of tool calling iterations
76 int max_retry_attempts = 3; // Maximum retries on errors
77 bool verbose = false; // Enable verbose diagnostic output
78 bool show_reasoning = true; // Show LLM reasoning in output
79 size_t max_history_messages = 50; // Maximum stored history messages per session
80 bool trim_history = true; // Whether to trim history beyond the limit
81 bool enable_vim_mode = false; // Enable vim-style line editing in simple-chat
83};
84
86 public:
88 explicit ConversationalAgentService(const AgentConfig& config);
89
90 // Send a message from the user and get the agent's response.
91 absl::StatusOr<ChatMessage> SendMessage(const std::string& message);
92
93 // Get the full chat history.
94 const std::vector<ChatMessage>& GetHistory() const;
95
96 // Provide the service with a ROM context for tool execution.
97 void SetRomContext(Rom* rom);
98
99 // Clear the current conversation history, preserving ROM/tool context.
100 void ResetConversation();
101
102 // Configuration
103 void SetConfig(const AgentConfig& config) { config_ = config; }
104 const AgentConfig& GetConfig() const { return config_; }
105
107
108 void ReplaceHistory(std::vector<ChatMessage> history);
109
110#ifdef Z3ED_AI
111 // Advanced Features Access (only when Z3ED_AI=ON)
112 LearnedKnowledgeService& learned_knowledge() { return learned_knowledge_; }
113 TodoManager& todo_manager() { return todo_manager_; }
114
115 // Inject learned context into next message
116 void EnableContextInjection(bool enable) { inject_learned_context_ = enable; }
117 void EnablePretraining(bool enable) { inject_pretraining_ = enable; }
118#endif
119
120 private:
124 int tool_calls = 0;
128 absl::Duration total_latency = absl::ZeroDuration();
129 };
130
131 void TrimHistoryIfNeeded();
134
135#ifdef Z3ED_AI
136 // Context enhancement (only when Z3ED_AI=ON)
137 std::string BuildEnhancedPrompt(const std::string& user_message);
138 std::string InjectLearnedContext(const std::string& message);
139 std::string InjectPretraining();
140
141 // Response enhancement
142 ChatMessage EnhanceResponse(const ChatMessage& response, const std::string& user_message);
143#endif
144
145 std::vector<ChatMessage> history_;
146 std::unique_ptr<AIService> ai_service_;
148 Rom* rom_context_ = nullptr;
151
152#ifdef Z3ED_AI
153 // Advanced features (only when Z3ED_AI=ON)
154 LearnedKnowledgeService learned_knowledge_;
155 TodoManager todo_manager_;
156 bool inject_learned_context_ = true;
157 bool inject_pretraining_ = false; // One-time injection on first message
158 bool pretraining_injected_ = false;
159#endif
160};
161
162} // namespace agent
163} // namespace cli
164} // namespace yaze
165
166#endif // YAZE_SRC_CLI_SERVICE_AGENT_CONVERSATIONAL_AGENT_SERVICE_H_
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:74
absl::StatusOr< ChatMessage > SendMessage(const std::string &message)
const std::vector< ChatMessage > & GetHistory() const
void ReplaceHistory(std::vector< ChatMessage > history)
Manages persistent learned information across agent sessions.
Manages TODO lists for z3ed agent task execution.
Main namespace for the application.
Definition controller.cc:20
std::vector< std::vector< std::string > > rows
std::optional< std::string > json_pretty
std::optional< ProposalSummary > proposal
std::optional< SessionMetrics > metrics