#pragma once #include #include #include #include #include #include #include namespace Echoion::Standalone { struct ManagedCoreStartupSelection { std::filesystem::path corePath; std::optional archivedStore; bool runtimeBaselineChanged = false; }; // Installed runtime releases own their bundled Core baseline. A runtime // version change archives the previous managed store; Core-only updates // remain active across ordinary restarts of the same runtime. [[nodiscard]] Api::Result selectManagedCoreForStartup( const std::filesystem::path& stateDirectory, const std::filesystem::path& bundledCore, std::optional installedRuntimeVersion); // Roll back any uncommitted managed-plugin activation before Core loads and // discovers plugin `current` links. This must run before PluginHost // startup. [[nodiscard]] Api::Result reconcileManagedPluginUpdates( const std::filesystem::path& stateDirectory); // Host-owned update coordinator. Core only forwards authenticated RPC // requests across the append-only host interface; all trust, download, // staging and activation decisions remain in the long-lived daemon. class UpdateService final { public: struct Options { std::filesystem::path configPath; std::filesystem::path stateDirectory; std::filesystem::path installRoot; std::filesystem::path runningExecutable; std::filesystem::path currentCore; std::filesystem::path releaseManifestPath; std::string officialFeedUrl; std::string officialPublicKeysJson = "[]"; std::string runtimeVersion; std::string apiVersion; std::string toolchainAbi; // Trusted administrator drop directory for file:// // feeds/artifacts. Empty selects stateDirectory / // "incoming". std::filesystem::path incomingDirectory; }; struct Hooks { std::function( const std::filesystem::path&)> replaceCore; std::function(const std::string&)> managePlugins; std::function(const std::string&)> manageRuntime; std::function playbackActive; std::function coreVersion; }; UpdateService(Options options, Hooks hooks); ~UpdateService(); UpdateService(const UpdateService&) = delete; UpdateService& operator=(const UpdateService&) = delete; UpdateService(UpdateService&&) noexcept; UpdateService& operator=(UpdateService&&) noexcept; [[nodiscard]] Api::Result start(); void stop() noexcept; // Execute host mutations which must not run on the Core RPC stack. // The daemon calls this from its polling loop after an RPC has // returned. void processPendingHostActions(); // Methods are the internal `updates.*` names forwarded by Core. // Requests and successful responses are JSON documents matching the // web contract. [[nodiscard]] Api::Result handle(const std::string& method, const std::string& requestJson); private: class Impl; std::unique_ptr impl_; }; } // namespace Echoion::Standalone