21 : scroll_to_bottom_(false),
23 show_timestamps_(true),
24 show_reasoning_(false),
25 message_spacing_(12.0f),
37#ifdef Z3ED_AI_AVAILABLE
38 agent_service_ = std::make_unique<cli::agent::ConversationalAgentService>();
54#ifndef Z3ED_AI_AVAILABLE
55 ImGui::Begin(
"Agent Chat", p_open);
57 "AI features not available");
59 "Build with -DZ3ED_AI=ON to enable the conversational agent.");
64 ImGui::SetNextWindowSize(ImVec2(600, 500), ImGuiCond_FirstUseEver);
65 if (!ImGui::Begin(
"Z3ED Agent Chat", p_open)) {
75 ImGui::BeginChild(
"ChatHistory",
76 ImVec2(0, -ImGui::GetFrameHeightWithSpacing() - 60),
78 ImGuiWindowFlags_AlwaysVerticalScrollbar);
83 ImGui::SetScrollHereY(1.0f);
188 if (ImGui::BeginTable(
"ToolResultTable", table.
headers.size(),
189 ImGuiTableFlags_Borders |
190 ImGuiTableFlags_RowBg |
191 ImGuiTableFlags_ScrollY)) {
193 for (
const auto& header : table.
headers) {
194 ImGui::TableSetupColumn(header.c_str());
196 ImGui::TableHeadersRow();
199 for (
const auto& row : table.
rows) {
200 ImGui::TableNextRow();
201 for (
size_t col = 0; col < std::min(row.size(), table.
headers.size()); ++col) {
202 ImGui::TableSetColumnIndex(col);
203 ImGui::TextWrapped(
"%s", row[col].c_str());
263#if defined(Z3ED_AI_AVAILABLE) && defined(YAZE_WITH_JSON)
265 return absl::FailedPreconditionError(
"Agent service not initialized");
268 std::ifstream file(filepath);
269 if (!file.is_open()) {
270 return absl::NotFoundError(
271 absl::StrFormat(
"Could not open file: %s", filepath));
282 return absl::OkStatus();
283 }
catch (
const nlohmann::json::exception& e) {
284 return absl::InvalidArgumentError(
285 absl::StrFormat(
"Failed to parse JSON: %s", e.what()));
288 return absl::UnimplementedError(
"AI features not available");
293#if defined(Z3ED_AI_AVAILABLE) && defined(YAZE_WITH_JSON)
295 return absl::FailedPreconditionError(
"Agent service not initialized");
298 std::ofstream file(filepath);
299 if (!file.is_open()) {
300 return absl::InternalError(
301 absl::StrFormat(
"Could not create file: %s", filepath));
309 j[
"messages"] = nlohmann::json::array();
311 for (
const auto& msg : history) {
312 nlohmann::json msg_json;
315 msg_json[
"message"] = msg.message;
316 msg_json[
"timestamp"] = absl::FormatTime(msg.timestamp);
317 j[
"messages"].push_back(msg_json);
322 return absl::OkStatus();
323 }
catch (
const nlohmann::json::exception& e) {
324 return absl::InternalError(
325 absl::StrFormat(
"Failed to serialize JSON: %s", e.what()));
328 return absl::UnimplementedError(
"AI features not available");