Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/crates/aien-mcp/src/session.rs # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / crates / aien-mcp / src / session.rs` 86 lines ยท 2810 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 //! Enrollment owner. J-Space receives a [`crate::SpeculativeLane`], not this type. 17 18 use std::collections::HashMap; 19 use std::sync::Arc; 20 21 use aien_capability::{ProviderId, ToolEffects}; 22 use rmcp::service::RoleClient; 23 use rmcp::transport::IntoTransport; 24 25 use crate::transport::RmcpClientWire; 26 use crate::{ApprovalDesk, EffectLane, Error, McpBroker, McpWire, SpeculativeLane}; 27 28 /// Admits MCP providers and hands out the two lanes. 29 /// 30 /// `enroll` and `enroll_transport` are the only ways to attach a server. 31 /// [`SpeculativeLane`] can refresh a provider that is already here. It cannot dial. 32 #[derive(Clone)] 33 pub struct SessionManager { 34 broker: McpBroker, 35 } 36 37 impl SessionManager { 38 pub fn new() -> Self { 39 Self { 40 broker: McpBroker::new(), 41 } 42 } 43 44 pub fn speculative_lane(&self) -> SpeculativeLane { 45 SpeculativeLane::new(self.broker.clone()) 46 } 47 48 pub fn effect_lane(&self) -> EffectLane { 49 EffectLane::new(self.broker.clone()) 50 } 51 52 /// The approver's handle. Keep it away from callers of the effect lane. 53 pub fn approval_desk(&self) -> ApprovalDesk { 54 ApprovalDesk::new(self.broker.clone()) 55 } 56 57 /// Enroll a provider that is already on an [`McpWire`]. 58 pub async fn enroll(&self, provider: ProviderId, wire: Arc) -> Result<(), Error> { 59 self.broker.admit(provider, wire).await 60 } 61 62 /// Dial one `rmcp` transport and enroll it. 63 /// 64 /// `effects` is the capability-graph classification for tool names this 65 /// provider is allowed to advertise. A name missing from the map is not 66 /// given a class from the server. 67 pub async fn enroll_transport( 68 &self, 69 provider: ProviderId, 70 transport: T, 71 effects: HashMap, 72 ) -> Result<(), Error> 73 where 74 T: IntoTransport, 75 E: std::error::Error + Send + Sync + 'static, 76 { 77 let wire = RmcpClientWire::connect(transport, effects).await?; 78 self.enroll(provider, Arc::new(wire)).await 79 } 80 } 81 82 impl Default for SessionManager { 83 fn default() -> Self { 84 Self::new() 85 } 86 }