use super::*;
pub use crate::ontology::parse_openclaw_session_key;
use crate::ontology::Binding;
pub fn openclaw_agent_id_from_path(path: &std::path::Path) -> Option<String> {
let comps: Vec<String> = path
.components()
.map(|c| c.as_os_str().to_string_lossy().into_owned())
.collect();
comps
.windows(2)
.find(|w| w[0] == "agents")
.map(|w| w[1].clone())
}
impl Session {
pub fn from_openclaw_str(jsonl: &str) -> Result<Session> {
Self::from_pi_v3_dialect(jsonl, SessionSource::OpenClaw, true)
}
}
pub(crate) fn openclaw_capture_header_nouns(header: &Value, meta: &mut SessionMeta) {
let key = header
.get("sessionKey")
.or_else(|| header.get("__openclaw").and_then(|o| o.get("sessionKey")))
.and_then(Value::as_str);
let Some(key) = key else { return };
if let Some(binding) = Binding::from_openclaw_key(key, None, None, None) {
if meta.profile.is_none() {
meta.profile = binding.profile.clone();
}
meta.surface = Some(binding.key.clone());
meta.trigger = Some(binding.trigger);
meta.recurrence = binding.recurrence;
}
}