Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/dim-app-server/src/agents/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ async fn process_startup_and_restart_follow_rows_becoming_active() {
let (completed, _) = tokio::sync::watch::channel(0);
for step in 0..4 {
let completed = completed.clone();
builder.plugin(move |names| {
builder.plugin(move |_| {
Ok(Box::new(ProgressingProcess {
name: format!("test.process-progress-{step}"),
hub: names.key()?,
hub: rutis::host::Key::of(),
step,
completed: completed.clone(),
}))
Expand Down Expand Up @@ -272,10 +272,10 @@ async fn a_stored_agent_creation_timeout_settles_during_progressing_startup() {
let mut held = HeldCreation::new(&stored.default_agent);
let mut progressing = builder();
let (completed, _) = tokio::sync::watch::channel(0);
progressing.plugin(move |names| {
progressing.plugin(move |_| {
Ok(Box::new(ProgressingProcess {
name: "test.stored-owner-progress".into(),
hub: names.key()?,
hub: rutis::host::Key::of(),
step: 0,
completed: completed.clone(),
}))
Expand Down
6 changes: 3 additions & 3 deletions crates/dim-app-server/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2226,7 +2226,7 @@ impl ConnectionPlugin {
pub fn new(names: &Names<'_>, config: Arc<ServerConfig>) -> rutis::Result<Self> {
Ok(Self {
config,
control: names.key()?,
control: Key::of(),
ui: names.key()?,
clients: names.key()?,
parts: names.key()?,
Expand Down Expand Up @@ -2469,8 +2469,8 @@ impl RpcPlugin {
root,
index: names.key()?,
collaboration: names.key()?,
hub: names.key()?,
control: names.key()?,
hub: Key::of(),
control: Key::of(),
loader: names.key()?,
management: names.key()?,
callers: Key::of(),
Expand Down
12 changes: 4 additions & 8 deletions crates/dim-app-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,8 +1036,8 @@ pub async fn serve(mut builder: AgentBuilder, mut config: ServerConfig) -> Resul
}
None => None,
};
if let Some(home) = plugin_home {
let configuration = ui_extensions::Configuration::new(home.join("ui-cache"));
if let (Some(home), Some(state)) = (plugin_home, &plugins) {
let configuration = ui_extensions::Configuration::new(home.join("ui-cache"), state.clone());
rows.push(register_part(
&mut builtins,
builder.catalog(),
Expand Down Expand Up @@ -1426,7 +1426,6 @@ pub async fn serve(mut builder: AgentBuilder, mut config: ServerConfig) -> Resul
pub(crate) fn register_names(catalog: &mut dim_agent_runtime::names::ServiceCatalog) {
use dim_agent_capabilities::host::SelectableModelsHost;
use dim_agent_runtime::{SESSION_GROUP, names::register};
register::<ServerControl>(catalog, None);
register::<ProcessActivity>(catalog, None);
register::<storage::SqliteStorage>(catalog, None);
catalog.register_shared("sqliteStorage");
Expand All @@ -1439,10 +1438,11 @@ pub(crate) fn register_names(catalog: &mut dim_agent_runtime::names::ServiceCata
catalog.register_shared(dim_agent_runtime::names::name_of::<
collaboration::CollaborationDirectory,
>());
register::<ConnectionHub>(catalog, None);
catalog.register_shared(dim_agent_runtime::names::name_of::<ListenAddresses>());
register::<ui_host::UiHost>(catalog, None);
catalog.register_shared("uiHost");
register::<ui_extensions::UiExtensions>(catalog, None);
catalog.register_shared("uiExtensions");
register::<ui_extensions::UiResources>(catalog, Some(SESSION_GROUP));
register::<settings::SettingsService>(catalog, None);
register::<settings::Settings>(catalog, None);
Expand Down Expand Up @@ -1490,7 +1490,6 @@ pub fn register_faces(builder: &mut dim_agent_runtime::AgentBuilder) {
("compactionStrategyHost", "hot-path"),
("configurationPublisher", "hot-path"),
("configureControl", "hot-path"),
("connectionHub", "control"),
("contextModelHost", "hot-path"),
("contextPreparation", "hot-path"),
("contextUsage", "hot-path"),
Expand All @@ -1512,7 +1511,6 @@ pub fn register_faces(builder: &mut dim_agent_runtime::AgentBuilder) {
("prompt", "hot-path"),
("providerConnectionResolver", "host-resource"),
("providerService", "secret"),
("serverControl", "control"),
("sessionLoader", "control"),
("sessionStore", "owner-api"),
("settingsService", "owner-api"),
Expand All @@ -1522,8 +1520,6 @@ pub fn register_faces(builder: &mut dim_agent_runtime::AgentBuilder) {
("timelineTreeControl", "owner-api"),
("toolBinding", "hot-path"),
("toolExecutor", "hot-path"),
("uiExtensions", "control"),
("uiHost", "control"),
] {
builder.internal_name(name, reason);
}
Expand Down
29 changes: 24 additions & 5 deletions crates/dim-app-server/src/plugin_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::hooks_settings::HooksService;
use crate::mcp::{McpError, McpServiceBinding};
use crate::methods::ManagementMethods;
use crate::settings::{Settings, SettingsError, SourceDeclaration};
use crate::ui_extensions::UiExtensions;
use crate::ui_extensions::{UiExtensionPlugin, UiExtensionRegistration, UiExtensions};
use acquire::PluginsDir;
use dim_agent_capabilities::methods::{Interruption, MethodCall, MethodDecl, Progress, RpcError};
use dim_agent_capabilities::skills::{SkillIssue, SkillsCatalogBinding};
Expand Down Expand Up @@ -188,6 +188,17 @@ pub(crate) struct StartupLayer {
}

impl State {
pub(crate) fn package_by_id(&self, id: &str) -> Option<(String, PathBuf)> {
let record = self.record.lock().unwrap();
if let Some(entry) = record.installed(id) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem: package_by_id returns any installed entry or default directory without checking the selected and enabled state. using() is the state check: it returns None for an off name and the chosen candidate otherwise (crates/dim-app-server/src/plugin_manager.rs:577-605). This lookup never calls it. UiExtensions::register publishes whatever it returns (crates/dim-app-server/src/ui_extensions/mod.rs:140-180), so the face accepts a plugin the user turned off.

Failure scenario: install plugin X (install selects it: crates/dim-app-server/src/plugin_manager.rs:1246, 1342-1349) and let PluginManager register its UI. Disable X, or install a second copy Y and select it; PluginManager withdraws X's UI (crates/dim-app-server/src/plugin_manager.rs:2060-2065, 441-445; docs/design/client-ui-extensions.md:77). A trusted row that injects uiExtensions, as runtime/fixtures/ui-owner.ts:8,35-38 does, calls uiExtensions.register({plugin:'X', manifest:{version:1, root:'ui', panels:[...]}}). package_by_id still returns X's install directory, prepare copies the root, and ui.extensions.list and ui.extensions.read serve a plugin that is off or replaced. A default plugin name has the same problem after the name switches to an installed copy, because defaults.plugins.get(id) ignores the choice. This contradicts client-ui-extensions.md:69 and client-ui-extensions.md:433.

Evidence: crates/dim-app-server/src/plugin_manager.rs:191-200, 577-605, 1246, 1342-1349, 2060-2065; crates/dim-app-server/src/ui_extensions/mod.rs:140-180; runtime/fixtures/ui-owner.ts:8,35-38; docs/design/client-ui-extensions.md:69,77,433; docs/design/contracts/process-owner-operations.md:30.

Fix: require the id to be the candidate using() returns for its name (Use::Installed(id) for an installed entry, Use::Default for a default). Normal callers already pass that id (crates/dim-app-server/src/plugin_manager.rs:416-433, 2071-2096), and the Node test still passes because install defaults enable=true and records use_ (crates/dim-app-server/src/plugin_manager.rs:1246, 1342-1349). Add a test that registers a disabled id and expects Unknown plugin ID with no catalog entry. If any trusted caller may republish disabled content is intended, update client-ui-extensions.md:69, 77 and 433 and add that test.

return Some((entry.name.clone(), entry.dir.clone()));
}
self.defaults
.plugins
.get(id)
.map(|dir| (id.to_owned(), dir.clone()))
}

/// Startup (§3.1), first part: reads `plugins.json` and the default
/// configuration file, deletes the copies no entry names (§7), and
/// registers the `instanceNames` and process names of the plugins that
Expand Down Expand Up @@ -836,7 +847,7 @@ impl Owners {
if kinds.contains(&Kind::Ui)
&& let Some(ui) = self.ctx.get_at(&self.ui)
{
held.extend(ui.plugins());
held.extend(ui.plugins(crate::protocol::Empty {}));
}
held
}
Expand All @@ -857,7 +868,10 @@ impl Owners {
match self.ctx.get_at(&self.ui) {
Some(ui) => {
if let Err(error) = ui
.register(plugin, &manifest.name, manifest.ui.as_ref())
.register(UiExtensionRegistration {
plugin: plugin.into(),
manifest: manifest.ui.clone(),
})
.await
{
outcome.refused.push(refused(Kind::Ui, error));
Expand Down Expand Up @@ -963,7 +977,10 @@ impl Owners {
if kinds.contains(&Kind::Ui)
&& let Some(ui) = self.ctx.get_at(&self.ui)
{
ui.withdraw(plugin).await;
ui.withdraw(UiExtensionPlugin {
plugin: plugin.into(),
})
.await;
}
for kind in kinds {
self.clear_refusal(plugin, *kind);
Expand Down Expand Up @@ -1014,7 +1031,9 @@ impl Owners {
async fn refused(&self, plugin: &str, manifest: &Manifest) -> Vec<Refusal> {
let mut found = Vec::new();
if let Some(ui) = self.ctx.get_at(&self.ui)
&& let Some(error) = ui.plugin_refusal(plugin)
&& let Some(error) = ui.refusal(UiExtensionPlugin {
plugin: plugin.into(),
})
{
found.push(refused(Kind::Ui, error));
}
Expand Down
8 changes: 2 additions & 6 deletions crates/dim-app-server/src/plugin_manager/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ pub struct Manifest {
pub skills: Option<PathBuf>,
pub mcp: Option<PathBuf>,
pub hooks: Option<PathBuf>,
pub ui: Option<crate::ui_extensions::manifest::Package>,
pub ui: Option<Value>,
}

/// The rutis row fields of a plugin's code, with `entry` resolved.
Expand Down Expand Up @@ -417,11 +417,7 @@ impl Manifest {
skills: path(file.skills, "skills")?,
mcp: path(file.mcp, "mcp")?,
hooks: path(file.hooks, "hooks")?,
ui: file.ui.map(|value| {
crate::ui_extensions::manifest::Package::read(dir, value).unwrap_or_else(
|message| crate::ui_extensions::manifest::Package::Rejected { message },
)
}),
ui: file.ui,
})
}

Expand Down
4 changes: 2 additions & 2 deletions crates/dim-app-server/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ impl TransportPlugin {
/// The database lock is a dependency only with native storage.
pub fn new(names: &Names<'_>, config: Arc<ServerConfig>) -> rutis::Result<Self> {
Ok(Self {
hub: names.key()?,
control: names.key()?,
hub: Key::of(),
control: Key::of(),
storage: config
.database_path
.is_some()
Expand Down
4 changes: 2 additions & 2 deletions crates/dim-app-server/src/ui_extensions/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ pub struct Panel {
pub methods: Vec<Method>,
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "camelCase", deny_unknown_fields)]
pub enum Package {
Supported { root: PathBuf, panels: Vec<Panel> },
Unsupported { version: u64 },
Rejected { message: String },
}

#[derive(Deserialize)]
Expand Down
Loading