MCPcopy Create free account
hub / github.com/GCWing/BitFun / ensure_session

Method ensure_session

src/apps/cli/src/agent/core_adapter.rs:182–208  ·  view source on GitHub ↗
(&self, agent_type: &str)

Source from the content-addressed store, hash-verified

180#[async_trait::async_trait]
181impl Agent for CoreAgentAdapter {
182 async fn ensure_session(&self, agent_type: &str) -> Result<String> {
183 let mut session_id_guard = self.session_id.lock().await;
184
185 if let Some(ref id) = *session_id_guard {
186 self.ensure_backend_session_alive(id, agent_type).await?;
187 return Ok(id.clone());
188 }
189
190 let session = self
191 .coordinator
192 .create_session(
193 Self::build_default_session_name(),
194 agent_type.to_string(),
195 SessionConfig {
196 workspace_path: Some(self.workspace_path_string()),
197 ..Default::default()
198 },
199 )
200 .await?;
201
202 let id = session.session_id.clone();
203
204 *session_id_guard = Some(id.clone());
205 tracing::info!("Created core session: {}", id);
206
207 Ok(id)
208 }
209
210 async fn send_message(&self, message: String, agent_type: &str) -> Result<String> {
211 let session_id = self.ensure_session(agent_type).await?;

Callers 3

send_messageMethod · 0.80
runMethod · 0.80
prepare_sessionMethod · 0.80

Calls 4

workspace_path_stringMethod · 0.80
cloneMethod · 0.45
create_sessionMethod · 0.45

Tested by

no test coverage detected