plugin runtime

This commit is contained in:
leookun committed 2026-08-30 13:35:03 +08:00
1 parent e5bfcdd202
commit 1609b57433
20 files changed
+1417 -26

No files matched your search

+7
View File
@@ -4,6 +4,7 @@ mod calls;
mod harness;
mod models;
mod overview;
mod plugins;
mod service;
mod settings;
@@ -136,6 +137,12 @@ pub fn api_router(service: ControlService) -> Router {
)
.route("/__byok-api__/api/llm-calls", get(calls::list))
.route("/__byok-api__/api/llm-calls/{call_id}", get(calls::detail))
.route(
"/__byok-api__/api/plugins/runtime",
get(plugins::runtime_status)
.post(plugins::initialize_runtime)
.delete(plugins::cancel_runtime_initialization),
)
.route(
"/__byok-api__/api/settings/observability",
get(settings::get).put(settings::update),
+24
View File
@@ -0,0 +1,24 @@
//! Exposes plugin runtime initialization and status endpoints.
use axum::{extract::State, Json};
use crate::{plugin::PluginRuntimeStatus, Result};
use super::ControlService;
pub async fn runtime_status(
State(service): State<ControlService>,
) -> Result<Json<PluginRuntimeStatus>> {
Ok(Json(service.plugin_runtime_status()))
}
pub async fn initialize_runtime(
State(service): State<ControlService>,
) -> Result<Json<PluginRuntimeStatus>> {
Ok(Json(service.initialize_plugin_runtime()))
}
pub async fn cancel_runtime_initialization(
State(service): State<ControlService>,
) -> Result<Json<PluginRuntimeStatus>> {
Ok(Json(service.cancel_plugin_runtime_initialization()))
}
+15
View File
@@ -25,6 +25,7 @@ use crate::{
ModelRequest, ModelSpec, ModelType, Overview, ProjectedContent, ProjectedMessage,
PromptSpec, ProviderType, Role,
},
plugin::{PluginRuntime, PluginRuntimeStatus},
provider::{is_valid_response_event, ModelEvent, Provider},
store::{
DesktopSettings, PortSettings, ProxySettings, ProxySettingsInput, StatisticsStorage, Store,
@@ -38,6 +39,7 @@ pub struct ControlService {
store: Store,
cursor_harness: CursorHarness,
provider: Arc<dyn Provider>,
plugin_runtime: PluginRuntime,
model_tests: Arc<Mutex<BTreeMap<String, CancellationToken>>>,
}
@@ -148,6 +150,7 @@ impl ControlService {
cursor_harness: CursorHarness::new(store.clone())?,
store,
provider,
plugin_runtime: PluginRuntime::managed()?,
model_tests: Arc::new(Mutex::new(BTreeMap::new())),
})
}
@@ -156,6 +159,18 @@ impl ControlService {
&self.cursor_harness
}
pub fn plugin_runtime_status(&self) -> PluginRuntimeStatus {
self.plugin_runtime.status()
}
pub fn initialize_plugin_runtime(&self) -> PluginRuntimeStatus {
self.plugin_runtime.initialize(self.store.clone())
}
pub fn cancel_plugin_runtime_initialization(&self) -> PluginRuntimeStatus {
self.plugin_runtime.cancel_initialization()
}
pub(super) async fn ads(
&self,
disabled_ad_ids: Option<&str>,