diff --git a/engine/common/thread.h b/engine/common/thread.h index 60f408635..480c0ba78 100644 --- a/engine/common/thread.h +++ b/engine/common/thread.h @@ -156,6 +156,19 @@ struct Thread : JsonSerializable { } json["metadata"] = metadata_json; + if (assistants.has_value()) { + Json::Value assistants_json(Json::arrayValue); + for (auto& assistant : assistants.value()) { + auto assistant_result = assistant.ToJson(); + if (assistant_result.has_error()) { + return cpp::fail("Failed to serialize assistant: " + + assistant_result.error()); + } + assistants_json.append(assistant_result.value()); + } + json["assistants"] = assistants_json; + } + return json; } catch (const std::exception& e) { return cpp::fail(std::string("ToJson failed: ") + e.what()); diff --git a/engine/controllers/hardware.cc b/engine/controllers/hardware.cc index 4f5cc2879..39a109750 100644 --- a/engine/controllers/hardware.cc +++ b/engine/controllers/hardware.cc @@ -1,8 +1,6 @@ #include "hardware.h" -#include "common/hardware_config.h" #include "utils/cortex_utils.h" -#include "utils/file_manager_utils.h" -#include "utils/scope_exit.h" +#include "utils/logging_utils.h" void Hardware::GetHardwareInfo( const HttpRequestPtr& req, @@ -73,4 +71,4 @@ void Hardware::Activate( callback(resp); app().quit(); #endif -} \ No newline at end of file +} diff --git a/engine/controllers/threads.cc b/engine/controllers/threads.cc index 1cd3aaeef..e130dad88 100644 --- a/engine/controllers/threads.cc +++ b/engine/controllers/threads.cc @@ -25,6 +25,7 @@ void Threads::ListThreads( Json::Value msg_arr(Json::arrayValue); for (auto& msg : res.value()) { if (auto it = msg.ToJson(); it.has_value()) { + it->removeMember("assistants"); msg_arr.append(it.value()); } else { CTL_WRN("Failed to convert message to json: " + it.error()); @@ -114,8 +115,9 @@ void Threads::RetrieveThread( resp->setStatusCode(k400BadRequest); callback(resp); } else { + thread_to_json->removeMember("assistants"); auto resp = - cortex_utils::CreateCortexHttpJsonResponse(res->ToJson().value()); + cortex_utils::CreateCortexHttpJsonResponse(thread_to_json.value()); resp->setStatusCode(k200OK); callback(resp); } diff --git a/engine/database/hardware.cc b/engine/database/hardware.cc index ee68749d5..ff2eb853a 100644 --- a/engine/database/hardware.cc +++ b/engine/database/hardware.cc @@ -1,14 +1,13 @@ #include "hardware.h" #include "database.h" +#include "utils/logging_utils.h" #include "utils/scope_exit.h" namespace cortex::db { -Hardwares::Hardwares() : db_(cortex::db::Database::GetInstance().db()) { -} +Hardwares::Hardwares() : db_(cortex::db::Database::GetInstance().db()) {} -Hardwares::Hardwares(SQLite::Database& db) : db_(db) { -} +Hardwares::Hardwares(SQLite::Database& db) : db_(db) {} Hardwares::~Hardwares() {} @@ -94,4 +93,4 @@ cpp::result Hardwares::DeleteHardwareEntry( return cpp::fail(e.what()); } } -} // namespace cortex::db \ No newline at end of file +} // namespace cortex::db diff --git a/engine/database/models.cc b/engine/database/models.cc index fb2128396..8c8be9eaf 100644 --- a/engine/database/models.cc +++ b/engine/database/models.cc @@ -2,6 +2,7 @@ #include #include #include "database.h" +#include "utils/logging_utils.h" #include "utils/result.hpp" #include "utils/scope_exit.h" @@ -339,4 +340,4 @@ bool Models::HasModel(const std::string& identifier) const { } } -} // namespace cortex::db \ No newline at end of file +} // namespace cortex::db diff --git a/engine/test/components/test_cortex_config.cc b/engine/test/components/test_cortex_config.cc index 04f3ddf33..f4bb7c1dc 100644 --- a/engine/test/components/test_cortex_config.cc +++ b/engine/test/components/test_cortex_config.cc @@ -1,3 +1,7 @@ +#include +#include +#include +#include #include "gtest/gtest.h" #include "utils/config_yaml_utils.h" diff --git a/engine/test/components/test_cortex_upd_cmd.cc b/engine/test/components/test_cortex_upd_cmd.cc index 772889fbd..06eff4a98 100644 --- a/engine/test/components/test_cortex_upd_cmd.cc +++ b/engine/test/components/test_cortex_upd_cmd.cc @@ -1,4 +1,5 @@ -#include "cli/commands/cortex_upd_cmd.h" +#include +#include #include "gtest/gtest.h" namespace { diff --git a/engine/test/components/test_file_manager_config_yaml_utils.cc b/engine/test/components/test_file_manager_config_yaml_utils.cc index f2c8c4075..ccbc92ec8 100644 --- a/engine/test/components/test_file_manager_config_yaml_utils.cc +++ b/engine/test/components/test_file_manager_config_yaml_utils.cc @@ -1,6 +1,7 @@ #include #include #include +#include #include "utils/config_yaml_utils.h" #include "utils/file_manager_utils.h" diff --git a/engine/utils/config_yaml_utils.cc b/engine/utils/config_yaml_utils.cc index 4d6f47ebe..af671d9e6 100644 --- a/engine/utils/config_yaml_utils.cc +++ b/engine/utils/config_yaml_utils.cc @@ -1,4 +1,9 @@ #include "config_yaml_utils.h" +#include +#include +#include +#include "utils/logging_utils.h" +#include "yaml-cpp/yaml.h" namespace config_yaml_utils { cpp::result CortexConfigMgr::DumpYamlConfig( @@ -174,4 +179,4 @@ CortexConfig CortexConfigMgr::FromYaml(const std::string& path, } } -} // namespace config_yaml_utils \ No newline at end of file +} // namespace config_yaml_utils diff --git a/engine/utils/config_yaml_utils.h b/engine/utils/config_yaml_utils.h index aa1b4027e..ffb3a31fa 100644 --- a/engine/utils/config_yaml_utils.h +++ b/engine/utils/config_yaml_utils.h @@ -1,13 +1,9 @@ #pragma once -#include -#include -#include #include #include -#include "utils/logging_utils.h" +#include #include "utils/result.hpp" -#include "yaml-cpp/yaml.h" namespace config_yaml_utils {