Skip to main content

elizaos_plugin_roblox/
lib.rs

1//! Roblox integration for elizaOS.
2//!
3//! This crate provides:
4//! - A [`RobloxClient`] for calling Roblox Open Cloud APIs.
5//! - Configuration via [`RobloxConfig`], including a convenience constructor
6//!   [`create_client_from_env`] for local development and deployment.
7//!
8//! ## Feature flags
9//! - `native` (default): Enables Tokio-based services/actions/providers.
10//! - `wasm`: Enables WASM bindings.
11#![warn(missing_docs)]
12#![deny(unsafe_code)]
13
14/// Roblox Open Cloud API client.
15pub mod client;
16/// Configuration and environment-variable loading for the Roblox client.
17pub mod config;
18/// Error types and result alias for this crate.
19pub mod error;
20/// Data types used by the client and services.
21pub mod types;
22
23/// Primary HTTP client for interacting with Roblox Open Cloud APIs.
24pub use client::RobloxClient;
25/// Configuration for connecting to Roblox Open Cloud APIs.
26pub use config::RobloxConfig;
27/// Common result type returned by this crate.
28pub use error::{Result, RobloxError};
29
30#[cfg(feature = "native")]
31/// Native (Tokio) service integration.
32pub mod service;
33
34#[cfg(feature = "native")]
35/// Native (Tokio) actions exposed by the plugin.
36pub mod actions;
37
38#[cfg(feature = "native")]
39/// Native (Tokio) runtime providers for the plugin.
40pub mod providers;
41
42#[cfg(feature = "wasm")]
43/// WASM bindings and helpers.
44pub mod wasm;
45
46/// Create a [`RobloxClient`] using environment variables.
47///
48/// This loads variables from the current process environment and (when present)
49/// a local `.env` file via `dotenvy`.
50///
51/// Required variables:
52/// - `ROBLOX_API_KEY`
53/// - `ROBLOX_UNIVERSE_ID`
54///
55/// Optional variables:
56/// - `ROBLOX_PLACE_ID`
57/// - `ROBLOX_WEBHOOK_SECRET`
58/// - `ROBLOX_MESSAGING_TOPIC` (defaults to [`defaults::MESSAGING_TOPIC`])
59/// - `ROBLOX_POLL_INTERVAL` (defaults to [`defaults::POLL_INTERVAL`])
60/// - `ROBLOX_DRY_RUN` (`true`/`false`, defaults to `false`)
61pub fn create_client_from_env() -> Result<RobloxClient> {
62    let config = RobloxConfig::from_env()?;
63    RobloxClient::new(config)
64}
65
66/// Stable plugin identifier used by elizaOS registries.
67pub const PLUGIN_NAME: &str = "roblox";
68/// Human-readable description of this plugin.
69pub const PLUGIN_DESCRIPTION: &str =
70    "Roblox integration for elizaOS - game communication via Open Cloud API";
71/// Plugin version, sourced from the crate version.
72pub const PLUGIN_VERSION: &str = env!("CARGO_PKG_VERSION");
73/// Service name used when registering the Roblox integration.
74pub const ROBLOX_SERVICE_NAME: &str = "roblox";
75/// Event/source identifier used in logs and message metadata.
76pub const ROBLOX_SOURCE: &str = "roblox";
77
78/// Default values for optional configuration fields.
79pub mod defaults {
80    /// Default Roblox MessagingService topic used for agent/game communication.
81    pub const MESSAGING_TOPIC: &str = "eliza-agent";
82    /// Default polling interval (in seconds) used by native services.
83    pub const POLL_INTERVAL: u64 = 30;
84}