From 14e56289391ea95b493c2a20c87f8d88047aa051 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 15 Nov 2026 17:16:08 +0100 Subject: 0.6.0: transcript viewer, turn summary, yolo floor, model/version records - --show renders a session without locking it - status line summarises writes, commands and denials per turn - sessions record harness version; model switches are appended and listed - --yolo refuses $HOME and / unless AGENT686_ALLOW_HOME=1 --- src/session.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/session.rs') diff --git a/src/session.rs b/src/session.rs index 6416b56..d017eda 100644 --- a/src/session.rs +++ b/src/session.rs @@ -66,6 +66,8 @@ pub struct Session { pub model: String, /// Directory the session was started in; the system prompt is frozen with it. pub cwd: String, + /// Harness version that created the session, for prefix-change warnings. + pub version: String, path: PathBuf, file: File, } @@ -107,6 +109,7 @@ impl Session { "session": id, "model": model, "cwd": cwd, + "version": env!("CARGO_PKG_VERSION"), "created": now_ms(), "system": system, }); @@ -117,6 +120,7 @@ impl Session { id, model: model.to_string(), cwd, + version: env!("CARGO_PKG_VERSION").to_string(), path, file, }) @@ -133,6 +137,7 @@ impl Session { let mut system = Value::Null; let mut session_id = id.to_string(); let mut cwd = String::new(); + let mut version = String::new(); let mut messages = Vec::new(); for line in reader.lines() { @@ -159,6 +164,9 @@ impl Session { if let Some(c) = value.get("cwd").and_then(|c| c.as_str()) { cwd = c.to_string(); } + if let Some(v) = value.get("version").and_then(|v| v.as_str()) { + version = v.to_string(); + } } Some("msg") => { let mut message = value.clone(); @@ -185,6 +193,7 @@ impl Session { id: session_id, model, cwd, + version, path, file, }, @@ -213,6 +222,14 @@ impl Session { pub fn path(&self) -> &PathBuf { &self.path } + + /// Records a model switch so `--list` shows what the last turn used. Appending + /// is legal; the header itself is never rewritten. + pub fn record_model(&mut self, model: &str) -> Result<(), String> { + let line = json!({ "t": "model", "model": model, "at": now_ms() }); + writeln!(self.file, "{line}").map_err(|e| e.to_string())?; + self.file.flush().map_err(|e| e.to_string()) + } } pub fn exists(id: &str) -> bool { @@ -271,6 +288,11 @@ fn scan(path: &PathBuf) -> (String, usize) { } } Some("msg") => messages += 1, + Some("model") => { + if let Some(name) = value.get("model").and_then(|m| m.as_str()) { + model = name.to_string(); + } + } _ => {} } } -- cgit v1.2.3