hyprstream_core/services/
mod.rs1mod core;
63mod types;
64use hyprstream_rpc_std::{discovery_client::DiscoveryClient, policy_client::PolicyClient};
65pub use hyprstream_inference::worktree_ext::StatResult;
69pub(crate) use hyprstream_inference::worktree_ext::WorktreeClientExt;
70#[cfg(feature = "rocksdb")]
72pub mod at9p_renewal;
73pub mod discovery;
74pub mod editing;
75pub mod factories;
76#[cfg(feature = "metrics")]
77pub mod flight;
78pub mod fs;
79pub mod generated;
80#[cfg(feature = "oci-image")]
81pub mod image_substrate;
82pub mod inference;
83pub mod kata_9p_backend;
84pub mod mcp_service;
85#[cfg(feature = "metrics")]
86pub mod metrics;
87pub mod model;
88pub mod namespace_builder;
89pub mod native_event_policy;
90pub mod ninep_bridge;
91pub mod oai;
92pub mod oauth;
93pub mod policy;
94pub mod public_repo;
95pub mod registry;
96pub mod remote_mount;
97pub mod remote_registry_mount;
98pub mod revocation;
99pub mod router;
100pub mod rpc_types;
101pub mod typed;
102pub mod worker;
103pub mod xet;
104pub mod xet_provenance;
105
106#[cfg(test)]
107pub(crate) mod restart_diag {
108 use std::sync::atomic::{AtomicBool, Ordering};
109 use std::sync::OnceLock;
110 use std::time::Instant;
111
112 static ENABLED: AtomicBool = AtomicBool::new(false);
113 static STARTED: OnceLock<Instant> = OnceLock::new();
114
115 pub(crate) fn enable() {
116 STARTED.get_or_init(Instant::now);
117 ENABLED.store(true, Ordering::Release);
118 }
119
120 pub(crate) fn phase(label: &'static str) {
121 if !ENABLED.load(Ordering::Acquire) {
122 return;
123 }
124 let elapsed_ms = STARTED
125 .get()
126 .map_or(0, |started| started.elapsed().as_millis());
127 let mut stderr = std::io::stderr().lock();
128 let _ = std::io::Write::write_fmt(
129 &mut stderr,
130 format_args!("RESTART_DIAG_PHASE={label} elapsed_ms={elapsed_ms}\n"),
131 );
132 let _ = std::io::Write::flush(&mut stderr);
133 }
134}
135
136#[cfg(feature = "pds-postgres")]
141pub(crate) mod pds_record_pg;
142#[cfg(feature = "rocksdb")]
146pub(crate) mod pds_record_rocksdb;
147
148#[cfg(feature = "ledger")]
152pub mod ledger;
153
154#[cfg(feature = "pay")]
157pub mod pay;
158
159pub use core::{Continuation, EnvelopeContext, RequestService};
160
161pub use types::{
163 FsDirEntryInfo, DEFAULT_IOUNIT, DMDIR, MAX_FDS_GLOBAL, MAX_FDS_PER_CLIENT, MAX_FS_IO_SIZE,
164 MAX_IOUNIT, ORCLOSE, ORDWR, OREAD, OTRUNC, OWRITE, QTDIR, QTFILE,
165};
166pub use discovery::DiscoveryService;
169#[cfg(feature = "metrics")]
170pub use flight::FlightService;
171#[cfg(feature = "oci-image")]
172pub use image_substrate::{
173 create_image_substrate_router, ImageSubstratePolicy, ImageSubstrateState,
174};
175pub use inference::{InferenceService, InferenceServiceConfig, INFERENCE_ENDPOINT};
176pub use model::{ModelService, ModelServiceConfig, StagingModelPin, MODEL_ENDPOINT};
177pub use namespace_builder::{build_standard_namespace, StandardNamespaceConfig};
178pub use oai::OAIService;
179#[cfg(test)]
180pub(crate) use oai::{
181 await_required_native_dependencies as oai_await_required_native_dependencies,
182 healthy_registry as oai_healthy_registry,
183 prove_model_reachability_denial as oai_prove_model_reachability_denial,
184};
185pub use oauth::OAuthService;
186pub use policy::PolicyService;
187pub use registry::RegistryService;
188pub use worker::build_authorize_fn;
189pub use xet::{XetService, XetState};
190
191pub fn policy_client_for_process(
193 signing_key: ed25519_dalek::SigningKey,
194 compatibility_key: ed25519_dalek::VerifyingKey,
195 token: Option<String>,
196) -> anyhow::Result<PolicyClient> {
197 if hyprstream_discovery::native_network_required() {
198 PolicyClient::from_provider(
199 &hyprstream_discovery::ProductionRpcClientProvider,
200 signing_key,
201 token,
202 )
203 } else {
204 PolicyClient::for_local_bootstrap(signing_key, compatibility_key, token)
205 }
206}
207
208pub fn discovery_client_for_process(
210 signing_key: ed25519_dalek::SigningKey,
211 compatibility_key: ed25519_dalek::VerifyingKey,
212 token: Option<String>,
213) -> anyhow::Result<DiscoveryClient> {
214 if hyprstream_discovery::native_network_required() {
215 DiscoveryClient::from_provider(
216 &hyprstream_discovery::ProductionRpcClientProvider,
217 signing_key,
218 token,
219 )
220 } else {
221 DiscoveryClient::for_local_bootstrap(signing_key, compatibility_key, token)
222 }
223}
224pub use mcp_service::{McpConfig, McpService};
225#[cfg(feature = "metrics")]
226pub use metrics::MetricsService;
227
228pub mod event_network;
230
231pub mod stream_network;