Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-15 19:50:07 +03:00
1 parent 295542ab9e
commit 24075fbd52
11 files changed
+305 -133

No files matched your search

+8 -4
View File
@@ -72,7 +72,11 @@ target_include_directories(EchoionApiPlugin INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/echoion/api/plugin>
$<INSTALL_INTERFACE:include/echoion/api/plugin>
)
target_link_libraries(EchoionApiPlugin INTERFACE Echoion::ApiBase)
target_link_libraries(EchoionApiPlugin INTERFACE
Echoion::ApiBase
Echoion::ApiTrack
Void::Plugin
)
# 6. Config Types (depends on Network, Audio)
add_library(EchoionApiConfig INTERFACE)
@@ -163,7 +167,7 @@ target_include_directories(EchoionApiOpaque INTERFACE
)
target_link_libraries(EchoionApiOpaque INTERFACE Echoion::ApiBase)
# 12a. PluginInterface only (minimal - for Plugin to implement)
# 12a. Host interface used by Core and EchoionStandalone
add_library(EchoionApiPluginInterface INTERFACE)
add_library(Echoion::ApiPluginInterface ALIAS EchoionApiPluginInterface)
target_include_directories(EchoionApiPluginInterface INTERFACE
@@ -180,7 +184,7 @@ target_link_libraries(EchoionApiPluginInterface INTERFACE
Echoion::ApiOpaque
)
# 12b. CoreInterface (decoupled - for Plugin to call Core)
# 12b. CoreInterface (decoupled host boundary)
add_library(EchoionApiCoreInterface INTERFACE)
add_library(Echoion::ApiCoreInterface ALIAS EchoionApiCoreInterface)
target_include_directories(EchoionApiCoreInterface INTERFACE
@@ -194,7 +198,7 @@ target_link_libraries(EchoionApiCoreInterface INTERFACE
Echoion::ApiOpaque
)
# 12c. Legacy Interfaces (both)
# 12c. Combined host interfaces
add_library(EchoionApiInterfaces INTERFACE)
add_library(Echoion::ApiInterfaces ALIAS EchoionApiInterfaces)
target_link_libraries(EchoionApiInterfaces INTERFACE
+5 -4
View File
@@ -69,7 +69,7 @@ EchoionApi/include/echoion/api/
## Include Path Changes
### For Plugin (minimal):
### For a host adapter (minimal):
**Before:**
```cpp
@@ -83,7 +83,8 @@ EchoionApi/include/echoion/api/
#include <CoreInterface.hpp>
```
The CMake target `Echoion::ApiPlugin` will add the correct include paths.
The CMake target `Echoion::ApiPlugin` provides the event and host DTO include
paths retained for source compatibility.
### For Core:
@@ -101,9 +102,9 @@ The CMake target `Echoion::ApiEventBus` adds `eventbus/` to the include path.
## CMake Usage
### Plugin only needs:
### Standalone host needs:
```cmake
target_link_libraries(EchoionPlugin PRIVATE
target_link_libraries(EchoionStandalone PRIVATE
Echoion::ApiBase
Echoion::ApiPlugin
Echoion::ApiInterfaces
+1
View File
@@ -12,6 +12,7 @@
#include "api/network/NetworkInterface.hpp"
#include "api/network/NetworkTypes.hpp"
#include "api/plugin/PluginTypes.hpp"
#include "api/plugin/ExtensionPlugin.hpp"
#include "api/rpc/RpcTypes.hpp"
#include "api/track/TrackTypes.hpp"
#include "api/youtube/YouTubeTypes.hpp"
@@ -1,5 +1,4 @@
#pragma once
#ifndef PLUGIN
#include "ConfigTypes.hpp"
#include <atomic>
#include <filesystem>
@@ -93,5 +92,3 @@ namespace Echoion::Api
};
} // namespace Echoion::Api
#endif
+16 -15
View File
@@ -1,5 +1,4 @@
#pragma once
#ifndef PLUGIN
#include "AudioTypes.hpp"
#include "NetworkTypes.hpp"
#include "Types.hpp"
@@ -29,8 +28,8 @@ namespace Echoion::Api
struct BotConfig {
std::string botName = "Echoion";
std::string commandPrefix = "!";
// Default bot language ("en" or "ru"). Applies to users who have not
// picked a per-user language. Anything else normalises to "en".
// Default bot language ("en" or "ru"). Applies to users who have
// not picked a per-user language. Anything else normalises to "en".
std::string language = "en";
float defaultVolume = 0.5f;
uint32_t maxQueueSize = 100;
@@ -61,9 +60,9 @@ namespace Echoion::Api
std::string rpcBindAddress = "127.0.0.1";
};
// Browser web interface (EchoionWeb). Serves the static UI and hosts the
// independent sync-watch WebSocket. Bot control from the browser goes
// directly to the RPC server (network.rpcPort), not through this server.
// Browser web interface (EchoionWeb). Serves the public dashboard and
// same-origin RPC bridge. Watch Together is deployed independently and
// linked through watchUrl.
struct WebConfig {
bool enabled = false;
uint16_t port = 8080;
@@ -76,6 +75,9 @@ namespace Echoion::Api
// "https://bot.example.com"). Presentation only — !help links to
// it when set; serving is unaffected.
std::string publicUrl;
// External VoidWatch deployment. Echoion only presents this link
// and redirects the retired local /watch entrypoint to it.
std::string watchUrl;
// Allow the Now Playing view to show the current song's video
// (muted, synced). Users can still disable it locally; this is
// the server-wide off switch, surfaced through /config.json.
@@ -86,9 +88,9 @@ namespace Echoion::Api
// innertube YouTube path and Yandex Music first, then falls back to
// (optionally proxied) yt-dlp last.
struct SourcesConfig {
std::vector<std::string> order = {
"innertube", "yandex", "direct-url",
"ytdlp-direct", "ytdlp-proxied"};
std::vector<std::string> order = {"innertube", "yandex",
"direct-url", "ytdlp-direct",
"ytdlp-proxied"};
// How long a failing source is skipped before being retried.
std::chrono::milliseconds failureCooldown =
std::chrono::milliseconds(300000); // 5m
@@ -132,9 +134,9 @@ namespace Echoion::Api
std::chrono::milliseconds(3600000);
bool enableAuditLog = true;
std::optional<std::string> apiKey;
// Reserved, not currently honored: the web UI, /rpc bridge and /ws
// are all same-origin behind the web server, so no CORS headers are
// emitted anywhere.
// Reserved, not currently honored: the web UI and /rpc bridge are
// same-origin behind the web server, so no CORS headers are
// emitted.
bool allowCors = false;
std::vector<std::string> corsOrigins;
};
@@ -175,11 +177,11 @@ namespace Echoion::Api
// across plays and restarts).
bool cacheEnabled = true;
std::string cacheMaxSize = "1GB";
uint32_t cacheTTL = 86400; // seconds
uint32_t cacheTTL = 86400; // seconds
uint32_t tempCleanupInterval = 3600; // seconds
};
// ServerConfig for Plugin interface (mirrors PluginTypes.hpp version)
// Connection settings passed across the Echoion host interface.
struct ServerConfig {
std::string address;
uint16_t port = 0;
@@ -217,4 +219,3 @@ namespace Echoion::Api
};
} // namespace Echoion::Api
#endif
+1 -21
View File
@@ -229,31 +229,11 @@ namespace Echoion::Api
Api::Result<void> setKv(const std::string& key,
const std::string& value);
// ===== Custom emojis (web UI image emotes) =====
// Admin-managed image emotes referenced by :name: shortcodes in
// watch chat/reactions. `data` is base64-encoded image bytes.
struct CustomEmoji {
std::string name;
std::string mime;
std::string dataBase64;
std::string addedBy;
};
[[nodiscard]] Api::Result<std::vector<CustomEmoji>>
getCustomEmojis();
// Image (mime + base64 data) for one emoji name, or nullopt.
[[nodiscard]] Api::Result<std::optional<CustomEmoji>>
getCustomEmoji(const std::string& name);
Api::Result<void> addCustomEmoji(const std::string& name,
const std::string& mime,
const std::string& dataBase64,
const std::string& addedBy);
Api::Result<void> removeCustomEmoji(const std::string& name);
// ===== Cached avatars (web UI) =====
// TeamSpeak avatar images persisted by uid so the web UI can show
// them even when the client is offline or out of the bot's view
// (the live TS avatar cache only holds in-view clients). `data` is
// base64-encoded image bytes, like custom emojis.
// base64-encoded image bytes.
struct CachedAvatar {
std::string uid;
std::string mime;
@@ -21,7 +21,7 @@ namespace Echoion::Api
struct QueueEntry;
struct PlaylistInfo;
// Minimal PlaybackState for Plugin
// Minimal playback state for the host boundary.
struct PlaybackSummary {
std::optional<TrackSummary> currentTrack;
bool isPlaying = false;
@@ -42,7 +42,7 @@ namespace Echoion::Api
using CoreCreateFunc = std::function<CoreInterfacePtr()>;
using CoreDestroyFunc = std::function<void(ICoreInterface*)>;
// Core interface that the Plugin will use to communicate with the Core
// Core interface used by the standalone host to communicate with Core.
// MINIMAL VERSION - breaks dependencies on Core-specific types
class ICoreInterface
{
@@ -51,7 +51,7 @@ namespace Echoion::Api
virtual ~ICoreInterface() = default;
// Lifecycle
// Plugin passes config file path, Core loads config internally
// The host passes a config path; Core loads it internally.
virtual Result<void>
initialize(const std::filesystem::path& configPath) = 0;
virtual Result<void> shutdown() = 0;
@@ -71,7 +71,7 @@ namespace Echoion::Api
// call returns the path). Downloads run asynchronously.
[[nodiscard]] virtual Result<std::optional<std::string>>
requestClientAvatar(uint64_t /*clientId*/,
const std::string& /*destDir*/)
const std::string& /*destDir*/)
{
return std::optional<std::string>{};
}
@@ -79,12 +79,92 @@ namespace Echoion::Api
uint64_t channelId) = 0;
virtual Result<void> kickClient(uint64_t clientId,
const std::string& reason) = 0;
virtual Result<void>
kickClientFromChannel(uint64_t /*clientId*/,
const std::string& /*reason*/)
{
return fail(ErrorCode::NotSupported,
"channel kick is not supported by this host");
}
virtual Result<void> banClient(uint64_t /*clientId*/,
uint64_t /*durationSeconds*/,
const std::string& /*reason*/)
{
return fail(ErrorCode::NotSupported,
"bans are not supported by this host");
}
[[nodiscard]] virtual Result<std::vector<BanInfo>> getBans()
{
return fail(ErrorCode::NotSupported,
"ban listing is not supported by this host");
}
virtual Result<void> unban(uint64_t /*banId*/)
{
return fail(ErrorCode::NotSupported,
"unban is not supported by this host");
}
// Channel operations
[[nodiscard]] virtual Result<std::vector<ChannelInfo>>
getChannels() const = 0;
[[nodiscard]] virtual Result<std::optional<ChannelInfo>>
getChannel(uint64_t channelId) const = 0;
virtual Result<uint64_t>
createChannel(const ChannelCreateOptions& /*options*/)
{
return fail(ErrorCode::NotSupported,
"channel creation is not supported by this host");
}
virtual Result<void>
editChannel(uint64_t /*channelId*/,
const ChannelEditOptions& /*options*/)
{
return fail(ErrorCode::NotSupported,
"channel editing is not supported by this host");
}
virtual Result<void> reorderChannel(uint64_t /*channelId*/,
uint64_t /*parentId*/,
uint64_t /*orderAfterId*/)
{
return fail(ErrorCode::NotSupported,
"channel reordering is not supported by this host");
}
virtual Result<void> deleteChannel(uint64_t /*channelId*/,
bool /*force*/)
{
return fail(ErrorCode::NotSupported,
"channel deletion is not supported by this host");
}
// Server-group administration. Membership changes use TeamSpeak's
// stable client database id, not the connection-scoped client id.
[[nodiscard]] virtual Result<std::vector<ServerGroupInfo>>
getServerGroups()
{
return fail(ErrorCode::NotSupported,
"server groups are not supported by this host");
}
virtual Result<void>
addClientToServerGroup(uint64_t /*groupId*/,
uint64_t /*clientDatabaseId*/)
{
return fail(
ErrorCode::NotSupported,
"server-group membership is not supported by this host");
}
virtual Result<void>
removeClientFromServerGroup(uint64_t /*groupId*/,
uint64_t /*clientDatabaseId*/)
{
return fail(
ErrorCode::NotSupported,
"server-group membership is not supported by this host");
}
[[nodiscard]] virtual Result<ServerInfo> getTeamSpeakServerInfo()
{
return fail(ErrorCode::NotSupported,
"server information is not supported by this host");
}
// Messaging
virtual Result<void>
@@ -102,40 +182,6 @@ namespace Echoion::Api
virtual Result<void>
setWhisperList(const std::vector<uint64_t>& clientIds) = 0;
// Independent audio timelines. A TeamSpeak connection has one voice
// sequence, so hosts implement each stream with its own connection and
// encoder. The default methods preserve compatibility for hosts that only
// support the primary stream.
using AudioStreamId = uint64_t;
struct AudioStreamOptions {
std::string name;
ServerConfig server;
std::vector<uint64_t> recipients;
};
[[nodiscard]] virtual Result<AudioStreamId>
createAudioStream(const AudioStreamOptions&)
{
return fail(ErrorCode::NotSupported,
"independent audio streams are not supported by this host");
}
virtual Result<void> destroyAudioStream(AudioStreamId)
{
return fail(ErrorCode::NotSupported,
"independent audio streams are not supported by this host");
}
virtual Result<void> sendAudioDataToStream(
AudioStreamId, const std::span<const short>&)
{
return fail(ErrorCode::NotSupported,
"independent audio streams are not supported by this host");
}
virtual Result<void> setAudioStreamRecipients(
AudioStreamId, const std::vector<uint64_t>&)
{
return fail(ErrorCode::NotSupported,
"independent audio streams are not supported by this host");
}
// Server connection
// ServerConfig is defined in PluginTypes.hpp (self-contained)
virtual Result<void>
@@ -0,0 +1,111 @@
#pragma once
#include <PluginTypes.hpp>
#include <TrackTypes.hpp>
#include <Types.hpp>
#include <Void/Plugin/Plugin.hpp>
#include <cstdint>
#include <string>
#include <string_view>
#include <vector>
namespace Echoion::Api
{
struct ExtensionCommand {
std::string name;
std::vector<std::string> aliases;
std::string description;
std::string usage;
std::uint8_t category = 5;
bool adminOnly = false;
};
struct ExtensionRpc {
std::string name;
bool adminOnly = false;
};
struct ExtensionMediaSource {
std::string name;
bool supportsSearch = false;
};
struct ExtensionWebAsset {
std::string id;
std::string javascript;
std::string css;
};
struct ExtensionCommandRequest {
std::string command;
std::string arguments;
std::uint64_t clientId = 0;
std::string invokerName;
};
struct ExtensionRpcRequest {
std::string method;
std::string params;
std::uint64_t clientId = 0;
};
struct ExtensionStream {
std::string url;
bool localFile = false;
};
// Native, trusted Echoion extension contract. Calls are always made while
// the host holds a Void::Plugin::PluginHandle, so a hot reload cannot
// unmap code that is still executing.
class IExtensionPlugin : public Void::Plugin::IPlugin
{
public:
[[nodiscard]] virtual std::vector<ExtensionCommand> commands() const
{
return {};
}
[[nodiscard]] virtual std::vector<ExtensionRpc> rpcMethods() const
{
return {};
}
[[nodiscard]] virtual std::vector<ExtensionMediaSource> mediaSources() const
{
return {};
}
[[nodiscard]] virtual std::vector<ExtensionWebAsset> webAssets() const
{
return {};
}
virtual Result<std::string> executeCommand(
const ExtensionCommandRequest&)
{
return fail(ErrorCode::NotSupported, "extension command is not supported");
}
virtual Result<std::string> callRpc(const ExtensionRpcRequest&)
{
return fail(ErrorCode::NotSupported, "extension RPC is not supported");
}
virtual void onEvent(const PluginEvent&) {}
[[nodiscard]] virtual bool canHandleMedia(
std::string_view, const std::string&) const
{
return false;
}
virtual Result<SearchResult> searchMedia(
std::string_view, std::string_view)
{
return fail(ErrorCode::NotSupported, "extension search is not supported");
}
virtual Result<TrackInfo> resolveMedia(
std::string_view, const std::string&)
{
return fail(ErrorCode::NotSupported, "extension resolve is not supported");
}
virtual Result<ExtensionStream> streamMedia(
std::string_view, const TrackInfo&)
{
return fail(ErrorCode::NotSupported, "extension stream is not supported");
}
};
}
+46 -20
View File
@@ -1,7 +1,5 @@
#pragma once
#ifndef PLUGIN
#include <ConfigTypes.hpp>
#endif
#include <chrono>
#include <cstdint>
#include <functional>
@@ -41,10 +39,14 @@ namespace Echoion::Api
ConfigurationChanged,
// Appended: fired once the TeamSpeak connection is fully established
// (client list available), so the core can resolve online subscribers.
ConnectionEstablished
ConnectionEstablished,
// Appended for the authoritative TeamSpeak directory cache. Hosts may
// emit either event after refreshing their local topology mirror.
ClientUpdated,
ChannelUpdated
};
// Minimal track info for Plugin (no internal types)
// Minimal track info for the host boundary (no internal types)
struct TrackSummary {
std::string id;
std::string title;
@@ -69,12 +71,15 @@ namespace Echoion::Api
struct ClientInfo {
uint64_t id = 0;
std::optional<uint64_t> databaseId;
std::string nickname;
std::optional<std::string> uniqueIdentifier;
uint64_t channelId = 0;
bool isTalking = false;
bool isMuted = false;
bool isDeafened = false;
bool isAway = false;
bool isQuery = false;
std::vector<uint64_t> serverGroups;
};
@@ -84,11 +89,48 @@ namespace Echoion::Api
std::optional<uint64_t> parentId;
uint64_t order = 0;
bool isDefault = false;
bool isPermanent = false;
bool isSemiPermanent = false;
bool hasPassword = false;
uint32_t maxClients = 0;
uint32_t currentClients = 0;
};
struct ChannelCreateOptions {
std::string name;
std::optional<uint64_t> parentId;
std::optional<uint64_t> orderAfterId;
std::optional<std::string> topic;
std::optional<std::string> description;
std::optional<std::string> password;
uint32_t maxClients = 0;
bool permanent = true;
};
struct ChannelEditOptions {
std::optional<std::string> name;
std::optional<std::string> topic;
std::optional<std::string> description;
std::optional<std::string> password;
std::optional<uint32_t> maxClients;
std::optional<bool> permanent;
};
struct ServerGroupInfo {
uint64_t id = 0;
std::string name;
bool isDefault = false;
};
struct BanInfo {
uint64_t id = 0;
std::optional<std::string> uniqueIdentifier;
std::optional<std::string> nickname;
std::string reason;
uint64_t createdAt = 0;
uint64_t durationSeconds = 0; // 0 means permanent
};
struct ServerInfo {
uint64_t id = 0;
std::string name;
@@ -98,22 +140,6 @@ namespace Echoion::Api
uint64_t defaultChannelId = 0;
};
// ServerConfig is needed for Plugin's connectToServer()
// This is a minimal version without dependencies on AudioTypes, etc.
// Available to both Core and Plugin
#ifdef PLUGIN
struct ServerConfig {
std::string address;
uint16_t port = 0;
std::string serverPassword;
std::string nickname;
std::optional<std::string> defaultChannelId;
std::optional<std::string> channelPassword;
std::vector<uint64_t> adminGroups;
std::vector<uint64_t> djGroups;
std::vector<uint64_t> bannedGroups;
};
#endif
// ===== Callback Types =====
using EventCallback = std::function<void(const PluginEvent&)>;
+33 -28
View File
@@ -68,15 +68,15 @@ namespace Echoion::Api
// Library (appended)
GetPlaylist, // playlist contents by id
GetHistory, // recently played tracks
GetStats, // playback statistics
GetHistory, // recently played tracks
GetStats, // playback statistics
// Web UI (appended)
GetFavorites, // authenticated user's favorites
AddFavorite, // add a track to favorites
RemoveFavorite, // remove by track url
VoteSkip, // vote to skip the current track
Announce, // admin: broadcast an announcement
GetFavorites, // authenticated user's favorites
AddFavorite, // add a track to favorites
RemoveFavorite, // remove by track url
VoteSkip, // vote to skip the current track
Announce, // admin: broadcast an announcement
GetAggregateStats, // server-wide dashboard statistics
// Web UI round 2 (appended)
@@ -90,29 +90,34 @@ namespace Echoion::Api
SetUserPrefs, // update per-user preferences; keys shared with the
// chat commands (e.g. !lang) so both stay in sync
// Web UI round 4 (appended): custom emojis for watch chat/reactions
GetCustomEmojis, // list custom emoji names (+ mime)
AddCustomEmoji, // admin: add/replace a custom emoji (base64 image)
RemoveCustomEmoji, // admin: delete a custom emoji
// Values 49-51 are reserved for retired browser features.
// Web UI round 5 (appended): lyrics for the current track (lrclib)
GetLyrics, // plain + time-synced lyrics for the now-playing track
GetLyrics = 52, // plain + time-synced lyrics for the now-playing track
// Independent named TeamSpeak listening rooms.
ListListeningRooms,
CreateListeningRoom,
DeleteListeningRoom,
JoinListeningRoom,
LeaveListeningRoom,
PlayInListeningRoom,
PauseListeningRoom,
ResumeListeningRoom,
StopListeningRoom,
GetListeningRoomQueue,
SkipListeningRoom,
RemoveFromListeningRoomQueue,
MoveInListeningRoomQueue,
ClearListeningRoomQueue
// Values 53-66 belonged to the removed experimental TeamSpeak
// listening-room API. Keep later values stable for stored audit rows.
GetCapabilities = 67,
GetPluginExtensions,
PluginCall,
// Values 70-72 are reserved for retired browser features.
// TeamSpeak directory and administration; 53-66 stay reserved.
GetTeamSpeakDirectory = 73,
MoveTeamSpeakClient,
KickTeamSpeakClient,
BanTeamSpeakClient,
GetTeamSpeakBans,
UnbanTeamSpeakClient,
CreateTeamSpeakChannel,
EditTeamSpeakChannel,
ReorderTeamSpeakChannel,
DeleteTeamSpeakChannel,
GetTeamSpeakServerGroups,
AddTeamSpeakServerGroupMember,
RemoveTeamSpeakServerGroupMember,
SendTeamSpeakPrivateMessage,
SendTeamSpeakChannelMessage,
SendTeamSpeakServerMessage
};
struct RpcRequest {