a3c20eb4d4
Agent worktrees now get a .mcp.json written with the correct port from the running server. AgentPool receives the port at construction and passes it through to create_worktree, which writes .mcp.json on both new creation and reuse. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
36 lines
1.1 KiB
Rust
36 lines
1.1 KiB
Rust
use crate::agents::AgentPool;
|
|
use crate::state::SessionState;
|
|
use crate::store::JsonFileStore;
|
|
use crate::workflow::WorkflowState;
|
|
use poem::http::StatusCode;
|
|
use std::sync::Arc;
|
|
|
|
#[derive(Clone)]
|
|
pub struct AppContext {
|
|
pub state: Arc<SessionState>,
|
|
pub store: Arc<JsonFileStore>,
|
|
pub workflow: Arc<std::sync::Mutex<WorkflowState>>,
|
|
pub agents: Arc<AgentPool>,
|
|
}
|
|
|
|
#[cfg(test)]
|
|
impl AppContext {
|
|
pub fn new_test(project_root: std::path::PathBuf) -> Self {
|
|
let state = SessionState::default();
|
|
*state.project_root.lock().unwrap() = Some(project_root.clone());
|
|
let store_path = project_root.join(".story_kit_store.json");
|
|
Self {
|
|
state: Arc::new(state),
|
|
store: Arc::new(JsonFileStore::new(store_path).unwrap()),
|
|
workflow: Arc::new(std::sync::Mutex::new(WorkflowState::default())),
|
|
agents: Arc::new(AgentPool::new(3001)),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub type OpenApiResult<T> = poem::Result<T>;
|
|
|
|
pub fn bad_request(message: String) -> poem::Error {
|
|
poem::Error::from_string(message, StatusCode::BAD_REQUEST)
|
|
}
|