MCPcopy Index your code
hub / github.com/AI45Lab/Code / submit

Method submit

core/src/session_lane_queue.rs:326–373  ·  view source on GitHub ↗

Submit a command to a specific lane

(
        &self,
        lane: SessionLane,
        command: Box<dyn SessionCommand>,
    )

Source from the content-addressed store, hash-verified

324
325 /// Submit a command to a specific lane
326 pub async fn submit(
327 &self,
328 lane: SessionLane,
329 command: Box<dyn SessionCommand>,
330 ) -> oneshot::Receiver<Result<Value>> {
331 let (result_tx, result_rx) = oneshot::channel();
332 let handler_config = self.get_lane_handler(lane).await;
333
334 // Fast task ID generation using atomic counter instead of UUID
335 let task_id = format!(
336 "{}-{}",
337 self.session_id,
338 self.task_id_counter
339 .fetch_add(1, std::sync::atomic::Ordering::Relaxed)
340 );
341
342 let adapter = SessionCommandAdapter::new(
343 command,
344 task_id,
345 handler_config.mode,
346 self.session_id.clone(),
347 lane,
348 handler_config.timeout_ms,
349 Arc::clone(&self.external_tasks),
350 self.event_tx.clone(),
351 );
352 match self.manager.submit(lane.lane_id(), Box::new(adapter)).await {
353 Ok(lane_rx) => {
354 tokio::spawn(async move {
355 match lane_rx.await {
356 Ok(Ok(value)) => {
357 let _ = result_tx.send(Ok(value));
358 }
359 Ok(Err(e)) => {
360 let _ = result_tx.send(Err(anyhow::anyhow!("{}", e)));
361 }
362 Err(_) => {
363 let _ = result_tx.send(Err(anyhow::anyhow!("Channel closed")));
364 }
365 }
366 });
367 }
368 Err(e) => {
369 let _ = result_tx.send(Err(e.into()));
370 }
371 }
372 result_rx
373 }
374
375 pub async fn submit_by_tool(
376 &self,

Callers 2

submit_by_toolMethod · 0.80
test_submit_and_executeFunction · 0.80

Calls 4

get_lane_handlerMethod · 0.80
lane_idMethod · 0.80
cloneMethod · 0.45
sendMethod · 0.45

Tested by 1

test_submit_and_executeFunction · 0.64