Skip to main content

opencode_cloud_core/
lib.rs

1//! opencode-cloud-core - Core library for opencode-cloud
2//!
3//! This library provides the shared functionality for both the Rust CLI
4//! and Node.js bindings via NAPI-RS.
5
6pub mod config;
7pub mod docker;
8pub mod host;
9pub mod platform;
10pub mod singleton;
11pub mod version;
12
13// Re-export version functions for Rust consumers
14pub use version::{get_version, get_version_long};
15
16// Re-export config types and functions
17pub use config::{Config, get_hosts_path, load_config, save_config};
18
19// Re-export singleton types
20pub use singleton::{InstanceLock, SingletonError};
21
22// Re-export docker types
23pub use docker::{CONTAINER_NAME, DockerClient, DockerError, OPENCODE_WEB_PORT};
24
25// Re-export platform types
26pub use platform::{
27    InstallResult, ServiceConfig, ServiceManager, get_service_manager,
28    is_service_registration_supported,
29};
30
31// Re-export host types
32pub use host::{
33    DistroFamily, DistroInfo, HostConfig, HostError, HostsFile, SshConfigMatch, SshTunnel,
34    detect_distro, get_docker_install_commands, get_ssh_config_path, host_exists_in_ssh_config,
35    install_docker, load_hosts, query_ssh_config, save_hosts, test_connection,
36    verify_docker_installed, write_ssh_config_entry,
37};
38
39// Re-export bollard to ensure all crates use the same version
40pub use bollard;
41
42// NAPI bindings for Node.js consumers (only when napi feature is enabled)
43#[cfg(feature = "napi")]
44use napi_derive::napi;
45
46/// Get the version string for Node.js consumers
47#[cfg(feature = "napi")]
48#[napi]
49pub fn get_version_js() -> String {
50    get_version()
51}
52
53/// Get the long version string with build info for Node.js consumers
54#[cfg(feature = "napi")]
55#[napi]
56pub fn get_version_long_js() -> String {
57    get_version_long()
58}