73 lines
3.0 KiB
C++
73 lines
3.0 KiB
C++
#pragma once
|
|
#include "runtime/Gallery_Runtime.hpp"
|
|
#include <event/Event.hpp>
|
|
#include <frame_policy/rely_facade.h>
|
|
#include <nlohmann/json.hpp>
|
|
#include <cstdint>
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
namespace aethera::mcp {
|
|
|
|
struct Gallery_Output {
|
|
std::uint32_t width{720};
|
|
std::uint32_t height{420};
|
|
/*
|
|
* Creates the concrete Sink proxy owned by each Plot Frame Policy. The proxy
|
|
* decides ownership; borrowed captures must cover asynchronous policy stop.
|
|
*/
|
|
std::function<proxy<frame_policy::Sink>(std::string_view)> make_sink{};
|
|
};
|
|
|
|
enum struct Tool_Call_Result : std::uint8_t {
|
|
ok, /* Tool completed with a business value. */
|
|
unknown_tool, /* Tool name is not registered. */
|
|
invalid_arguments, /* Protocol input could not be decoded or validated. */
|
|
unknown_plot, /* Plot identifier is not registered. */
|
|
rejected /* A known business constraint rejected the request. */
|
|
};
|
|
|
|
struct Tool_Call_Output {
|
|
Tool_Call_Result result{Tool_Call_Result::ok}; /* 调用的已知业务结果。 */
|
|
nlohmann::json content{}; /* 成功值或结构化错误细节。 */
|
|
std::string message{}; /* 供协议适配器显示的简短说明。 */
|
|
};
|
|
|
|
struct Control_Service final {
|
|
static std::shared_ptr<Control_Service> create(Gallery_Output output = {});
|
|
~Control_Service();
|
|
Control_Service(const Control_Service&) = delete;
|
|
Control_Service& operator=(const Control_Service&) = delete;
|
|
|
|
[[nodiscard]] bool contains_plot(std::string_view id) const noexcept;
|
|
/* Starts one asynchronous shutdown. completion runs after every plot Entry and its publisher copy have been destroyed. */
|
|
void stop(std::function<void()> completion);
|
|
void submit_input(std::string_view id, std::unique_ptr<Event> event);
|
|
void request_frame(std::string_view id, web::Gallery_Frame_Request request);
|
|
[[nodiscard]] nlohmann::json plot_schema(std::string_view id) const;
|
|
[[nodiscard]] nlohmann::json write_plot_property(
|
|
std::string_view id, std::string_view component,
|
|
std::string_view key, const nlohmann::json& value);
|
|
[[nodiscard]] nlohmann::json plot_component_state(
|
|
std::string_view id, std::string_view component) const;
|
|
[[nodiscard]] nlohmann::json generate_plot_data(
|
|
std::string_view id, const nlohmann::json& input);
|
|
[[nodiscard]] nlohmann::json plot_diagnostics(std::string_view id) const;
|
|
void reset_plot_diagnostics(std::string_view id);
|
|
void request_plot_taskflow_trace(std::string_view id, std::size_t frame_count);
|
|
[[nodiscard]] nlohmann::json plot_taskflow_trace(std::string_view id) const;
|
|
[[nodiscard]] nlohmann::json plot_catalog() const;
|
|
[[nodiscard]] nlohmann::json tool_catalog() const;
|
|
[[nodiscard]] Tool_Call_Output call_tool(
|
|
std::string_view name, const nlohmann::json& arguments);
|
|
|
|
private:
|
|
Control_Service();
|
|
struct Private;
|
|
std::unique_ptr<Private> d;
|
|
};
|
|
|
|
}
|