cookie_agent_engine/runtime_snapshot/
mod.rs1mod agents;
4pub(crate) mod projection;
5
6use std::{collections::BTreeMap, sync::Arc};
7
8use cookie_agent_models::CompiledModelRuntime;
9use cookie_agent_protocol::{RuntimeChangedNotification, RuntimeSnapshotResult};
10
11pub(crate) use agents::{AgentRegistry, ResolvedAgent, ResolvedAgentFallback, delegation_targets};
12pub(crate) use projection::build_runtime_snapshot;
13
14#[derive(Clone)]
16pub struct PublishedRuntime {
17 pub result: RuntimeSnapshotResult,
18 pub models: Arc<CompiledModelRuntime>,
19 pub agents: Arc<AgentRegistry>,
20 pub agent_presets: BTreeMap<String, Arc<AgentRegistry>>,
21 pub current_manifest: Arc<cookie_agent_protocol::ModelSnapshotManifestV1>,
22}
23
24impl PublishedRuntime {
25 pub(crate) fn agents_for_preset(
26 &self,
27 preset: Option<&str>,
28 ) -> Result<Arc<AgentRegistry>, crate::EngineError> {
29 match preset {
30 None => Ok(Arc::clone(&self.agents)),
31 Some(name) => self
32 .agent_presets
33 .get(name)
34 .cloned()
35 .ok_or_else(|| crate::EngineError::UnknownAgentPreset(name.to_owned())),
36 }
37 }
38}
39
40impl std::fmt::Debug for PublishedRuntime {
41 fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42 formatter
43 .debug_struct("PublishedRuntime")
44 .field("runtime_revision", &self.result.snapshot.runtime_revision)
45 .field("models", &self.result.snapshot.models.len())
46 .field("agents", &self.result.snapshot.agents.len())
47 .finish()
48 }
49}
50
51#[derive(Clone, Debug)]
52pub struct RuntimePublication {
53 pub runtime: Arc<PublishedRuntime>,
54 pub notification: RuntimeChangedNotification,
55}