21 : scroll_to_bottom_(false),
23 show_timestamps_(true),
24 show_reasoning_(false),
25 message_spacing_(12.0f),
38 agent_service_ = std::make_unique<cli::agent::ConversationalAgentService>();
55 ImGui::Begin(
"Agent Chat", p_open);
58 "Build with -DZ3ED_AI=ON to enable the conversational agent.");
63 ImGui::SetNextWindowSize(ImVec2(600, 500), ImGuiCond_FirstUseEver);
64 if (!ImGui::Begin(
"Z3ED Agent Chat", p_open)) {
74 ImGui::BeginChild(
"ChatHistory",
75 ImVec2(0, -ImGui::GetFrameHeightWithSpacing() - 60),
true,
76 ImGuiWindowFlags_AlwaysVerticalScrollbar);
81 (
auto_scroll_ && ImGui::GetScrollY() >= ImGui::GetScrollMaxY())) {
82 ImGui::SetScrollHereY(1.0f);
192 if (ImGui::BeginTable(
"ToolResultTable", table.
headers.size(),
193 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg |
194 ImGuiTableFlags_ScrollY)) {
196 for (
const auto& header : table.
headers) {
197 ImGui::TableSetupColumn(header.c_str());
199 ImGui::TableHeadersRow();
202 for (
const auto& row : table.
rows) {
203 ImGui::TableNextRow();
204 for (
size_t col = 0; col < std::min(row.size(), table.
headers.size());
206 ImGui::TableSetColumnIndex(col);
207 ImGui::TextWrapped(
"%s", row[col].c_str());
265#if defined(Z3ED_AI) && defined(YAZE_WITH_JSON)
267 return absl::FailedPreconditionError(
"Agent service not initialized");
270 std::ifstream file(filepath);
271 if (!file.is_open()) {
272 return absl::NotFoundError(
273 absl::StrFormat(
"Could not open file: %s", filepath));
284 return absl::OkStatus();
285 }
catch (
const nlohmann::json::exception& e) {
286 return absl::InvalidArgumentError(
287 absl::StrFormat(
"Failed to parse JSON: %s", e.what()));
290 return absl::UnimplementedError(
"AI features not available");
295#if defined(Z3ED_AI) && defined(YAZE_WITH_JSON)
297 return absl::FailedPreconditionError(
"Agent service not initialized");
300 std::ofstream file(filepath);
301 if (!file.is_open()) {
302 return absl::InternalError(
303 absl::StrFormat(
"Could not create file: %s", filepath));
311 j[
"messages"] = nlohmann::json::array();
313 for (
const auto& msg : history) {
314 nlohmann::json msg_json;
318 msg_json[
"message"] = msg.message;
319 msg_json[
"timestamp"] = absl::FormatTime(msg.timestamp);
320 j[
"messages"].push_back(msg_json);
325 return absl::OkStatus();
326 }
catch (
const nlohmann::json::exception& e) {
327 return absl::InternalError(
328 absl::StrFormat(
"Failed to serialize JSON: %s", e.what()));
331 return absl::UnimplementedError(
"AI features not available");