use std::path::PathBuf;
use std::sync::Arc;
use anyhow::Result;
use crate::runtime_storage::SessionRepository;
use crate::session_execution::SessionExecutionRegistry;
use theway_core::multiagent::graph::engine::DagEngine;
use theway_core::multiagent::jobs::SubagentJobRegistry;
mod collapse;
mod graph;
mod lifecycle;
mod metadata;
mod ops;
mod wire;
pub use collapse::collapse_session_for_command;
pub(crate) use metadata::read_session_metadata;
#[cfg(test)]
pub(crate) use metadata::{ROLLING_SUMMARY_COMPONENTS, render_rolling_summary};
pub type SessionFactory = Arc<
dyn Fn(
String,
) -> std::pin::Pin<
Box<
dyn std::future::Future<Output = Result<crate::orchestration::SessionRuntime>>
+ Send,
>,
> + Send
+ Sync,
>;
pub(crate) struct AppSessionOps {
repo: Arc<dyn SessionRepository>,
dag_engine: Arc<DagEngine>,
cwd: String,
session_execution: SessionExecutionRegistry,
subagent_registry: Option<SubagentJobRegistry>,
session_graph_path: Option<PathBuf>,
}
impl AppSessionOps {
#[allow(dead_code)] pub(crate) fn new(
repo: Arc<dyn SessionRepository>,
dag_engine: Arc<DagEngine>,
cwd: String,
session_execution: SessionExecutionRegistry,
) -> Self {
Self {
repo,
dag_engine,
cwd,
session_execution,
subagent_registry: None,
session_graph_path: None,
}
}
pub(crate) fn with_session_graph(
repo: Arc<dyn SessionRepository>,
dag_engine: Arc<DagEngine>,
cwd: String,
session_execution: SessionExecutionRegistry,
subagent_registry: SubagentJobRegistry,
session_graph_path: PathBuf,
) -> Self {
Self {
repo,
dag_engine,
cwd,
session_execution,
subagent_registry: Some(subagent_registry),
session_graph_path: Some(session_graph_path),
}
}
}
#[cfg(test)]
tests_bridge_macro::tests_bridge!("session_ops");