Rename Session -> HookSession

The hook's Session is not the same as poc-agent's session concept.
Rename to avoid confusion now that poc-agent will create HookSessions
to call into the agent cycle.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-02 00:42:25 -04:00
parent a0245c1279
commit 55a037f4c7
5 changed files with 19 additions and 19 deletions

View file

@ -602,7 +602,7 @@ fn resolve(
/// Reads POC_SESSION_ID to find the transcript, extracts the last
/// segment (post-compaction), returns the tail (~100K chars).
fn resolve_conversation(budget: Option<usize>) -> String {
let session = crate::session::Session::from_env();
let session = crate::session::HookSession::from_env();
let transcript = session.as_ref()
.map(|s| s.transcript())
.unwrap_or_else(crate::session::TranscriptInfo::empty);
@ -698,7 +698,7 @@ fn resolve_memory_ratio() -> String {
let state_dir = crate::store::memory_dir().join("sessions");
// Get post-compaction transcript size
let session = crate::session::Session::from_env();
let session = crate::session::HookSession::from_env();
let transcript = session.as_ref()
.map(|s| s.transcript())
.unwrap_or_else(crate::session::TranscriptInfo::empty);

View file

@ -17,11 +17,11 @@ use std::time::{Duration, Instant, SystemTime};
/// Max bytes per context chunk (hook output limit is ~10K chars)
const CHUNK_SIZE: usize = 9000;
pub use crate::session::Session;
pub use crate::session::HookSession;
/// Run the hook logic on parsed JSON input. Returns output to inject.
pub fn run_hook(input: &str) -> String {
let Some(session) = Session::from_json(input) else { return String::new() };
let Some(session) = HookSession::from_json(input) else { return String::new() };
hook(&session)
}
@ -137,7 +137,7 @@ pub struct AgentCycleOutput {
/// Run all agent cycles: surface-observe, reflect, journal.
/// Returns surfaced memory keys and any reflection text.
/// Caller decides how to render and inject the output.
pub fn run_agent_cycles(session: &Session) -> AgentCycleOutput {
pub fn run_agent_cycles(session: &HookSession) -> AgentCycleOutput {
let log_dir = dirs::home_dir().unwrap_or_default().join(".consciousness/logs");
fs::create_dir_all(&log_dir).ok();
let log_path = log_dir.join(format!("hook-{}", session.session_id));
@ -189,7 +189,7 @@ pub fn format_agent_output(output: &AgentCycleOutput) -> String {
/// Surface-observe cycle: read surfaced keys, manage agent lifecycle.
/// Returns (surfaced keys, optional sleep duration).
fn surface_observe_cycle(session: &Session, log_f: &mut File) -> (Vec<String>, Option<f64>) {
fn surface_observe_cycle(session: &HookSession, log_f: &mut File) -> (Vec<String>, Option<f64>) {
let state_dir = crate::store::memory_dir()
.join("agent-output")
.join("surface-observe");
@ -275,7 +275,7 @@ fn surface_observe_cycle(session: &Session, log_f: &mut File) -> (Vec<String>, O
}
/// Reflection cycle: spawn reflect agent, return any pending reflection.
fn reflection_cycle(session: &Session, log_f: &mut File) -> Option<String> {
fn reflection_cycle(session: &HookSession, log_f: &mut File) -> Option<String> {
let state_dir = crate::store::memory_dir()
.join("agent-output")
.join("reflect");
@ -324,7 +324,7 @@ fn reflection_cycle(session: &Session, log_f: &mut File) -> Option<String> {
}
/// Journal cycle: fire and forget.
fn journal_cycle(session: &Session, log_f: &mut File) {
fn journal_cycle(session: &HookSession, log_f: &mut File) {
let state_dir = crate::store::memory_dir()
.join("agent-output")
.join("journal");
@ -371,7 +371,7 @@ fn cleanup_stale_files(dir: &Path, max_age: Duration) {
}
}
fn hook(session: &Session) -> String {
fn hook(session: &HookSession) -> String {
let start_time = Instant::now();
let mut out = String::new();