11use std:: path:: PathBuf ;
22
3+ use bitfun_core:: BitFunResult ;
34use bitfun_runtime_ports:: AgentSessionWorkspaceBinding ;
45
56#[ derive( Debug , Clone , PartialEq , Eq ) ]
@@ -24,35 +25,42 @@ fn activation_target(
2425 } )
2526}
2627
27- pub ( crate ) async fn ensure_plugin_workspace_ready (
28- binding : & AgentSessionWorkspaceBinding ,
29- ) -> bitfun_core:: BitFunResult < ( ) > {
28+ pub ( crate ) async fn ensure_configured_plugin_execution_supported ( ) -> BitFunResult < bool > {
3029 // Plugin activation is optional. Isolated Runtime clients (including unit
3130 // tests) may create sessions before the process-level config service is
3231 // initialized; that must not make ordinary session creation fail.
3332 if !bitfun_core:: service:: config:: GlobalConfigManager :: is_initialized ( ) {
34- tracing:: debug!(
35- workspace_path = %binding. workspace_path,
36- "Configured plugin host activation skipped before global config initialization"
37- ) ;
33+ return Ok ( false ) ;
34+ }
35+
36+ let config_service = bitfun_core:: service:: config:: get_global_config_service ( ) . await ?;
37+ let config: bitfun_core:: service:: config:: GlobalConfig =
38+ config_service. get_config ( None ) . await ?;
39+ let has_configured_plugins = config. has_configured_plugins ( ) ;
40+ if has_configured_plugins
41+ && crate :: PLUGIN_HOST_LAUNCH_POLICY
42+ == bitfun_core:: plugin_host:: PluginHostLaunchPolicy :: Disabled
43+ {
44+ return Err ( bitfun_core:: BitFunError :: NotImplemented (
45+ "Configured Plugin Host execution is not enabled; plugin definitions were not imported or executed"
46+ . to_string ( ) ,
47+ ) ) ;
48+ }
49+ Ok ( has_configured_plugins)
50+ }
51+
52+ pub ( crate ) async fn ensure_plugin_workspace_ready (
53+ binding : & AgentSessionWorkspaceBinding ,
54+ ) -> BitFunResult < ( ) > {
55+ if !ensure_configured_plugin_execution_supported ( ) . await ? {
3856 return Ok ( ( ) ) ;
3957 }
4058
4159 let Some ( target) = activation_target ( binding) else {
42- let config_service = bitfun_core:: service:: config:: get_global_config_service ( ) . await ?;
43- let config: bitfun_core:: service:: config:: GlobalConfig =
44- config_service. get_config ( None ) . await ?;
45- if config. has_configured_plugins ( ) {
46- return Err ( bitfun_core:: BitFunError :: NotImplemented (
47- "Configured Plugin Host is unsupported for Remote CLI workspaces; no controller-local fallback was attempted"
48- . to_string ( ) ,
49- ) ) ;
50- }
51- tracing:: debug!(
52- workspace_path = %binding. workspace_path,
53- "Configured plugin host activation skipped for remote CLI workspace"
54- ) ;
55- return Ok ( ( ) ) ;
60+ return Err ( bitfun_core:: BitFunError :: NotImplemented (
61+ "Configured Plugin Host is unsupported for Remote CLI workspaces; no controller-local fallback was attempted"
62+ . to_string ( ) ,
63+ ) ) ;
5664 } ;
5765
5866 bitfun_core:: plugin_host:: ensure_configured_plugin_instance (
@@ -102,4 +110,12 @@ mod tests {
102110
103111 assert_eq ! ( activation_target( & binding) , None ) ;
104112 }
113+
114+ #[ test]
115+ fn cli_does_not_enable_unowned_plugin_execution ( ) {
116+ assert_eq ! (
117+ crate :: PLUGIN_HOST_LAUNCH_POLICY ,
118+ bitfun_core:: plugin_host:: PluginHostLaunchPolicy :: Disabled
119+ ) ;
120+ }
105121}
0 commit comments