feat(orchestrator): file-based orchestrator request watcher (§14.3)

- domain: OrchestratorRequest/Command parse-don't-validate + OrchestratorRequestProcessed event
- application: OrchestratorService dispatching spawn/stop/update_agent_context
- infrastructure: request watcher over .ideai/requests/, writes .response.json
- app-tauri: relay OrchestratorRequestProcessed to the frontend DTO

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-07 11:12:04 +02:00
parent 9736c42424
commit 480e7c7bbe
14 changed files with 1908 additions and 3 deletions

View File

@ -10,7 +10,7 @@ use std::collections::HashMap;
use std::sync::Mutex;
use domain::ports::PtyHandle;
use domain::{SessionId, TerminalSession};
use domain::{AgentId, SessionId, SessionKind, TerminalSession};
/// A registered, live terminal: its PTY handle plus the domain snapshot.
#[derive(Debug, Clone)]
@ -59,6 +59,21 @@ impl TerminalSessions {
.and_then(|m| m.get(id).map(|e| e.session.clone()))
}
/// Returns the [`SessionId`] of the live session hosting a given agent, if any.
///
/// An agent runs in a session tagged [`SessionKind::Agent`]; this is the
/// mapping the orchestrator's `stop_agent` uses to translate an agent id into
/// the [`SessionId`] that `CloseTerminal` expects. Returns `None` when the
/// agent has no live session (already stopped / never launched).
#[must_use]
pub fn session_for_agent(&self, agent_id: &AgentId) -> Option<SessionId> {
self.entries.lock().ok().and_then(|m| {
m.values()
.find(|e| matches!(e.session.kind, SessionKind::Agent { agent_id: a } if &a == agent_id))
.map(|e| e.session.id)
})
}
/// Returns the [`PtyHandle`]s of every currently-registered session.
///
/// Used at application shutdown to kill all live PTYs cleanly (the