diff --git a/crates/mind-body/src/projection/agent.rs b/crates/mind-body/src/projection/agent.rs index 10f133a..80762e2 100644 --- a/crates/mind-body/src/projection/agent.rs +++ b/crates/mind-body/src/projection/agent.rs @@ -34,10 +34,10 @@ use super::narrate::{Failed, KitModel, Spent, StepRequest, Stepped, ToolCall}; use super::tuning::{AgentTuning, CACHE_MARGIN_S}; use crate::persona::Trace; -pub mod read; -pub mod request_tool; -pub mod say; -pub mod shell; +pub(crate) mod read; +pub(crate) mod request_tool; +pub(crate) mod say; +pub(crate) mod shell; /// The connector, as the loop calls it: `KitModel` live, a script in a test. pub trait Steps { @@ -151,7 +151,7 @@ pub(crate) fn arguments(call: &ToolCall) -> std: /// What a fresh session is seeded with beyond the wake's input (ruling `candidate-actions-lived`): her live intentions that are /// ready and unexpired, one line each, or nothing. A kept session already carries what she meant; nothing checks them afterwards. -pub fn ready_intentions(state: &Value, now: DateTime) -> String { +pub(crate) fn ready_intentions(state: &Value, now: DateTime) -> String { let lines: Vec = state["candidateActions"]["actions"] .as_array() .into_iter() diff --git a/crates/mind-body/src/sandbox.rs b/crates/mind-body/src/sandbox.rs index 8dfc91d..07ff949 100644 --- a/crates/mind-body/src/sandbox.rs +++ b/crates/mind-body/src/sandbox.rs @@ -19,7 +19,7 @@ use crate::self_run::CONFIG_DIR_NAME; /// The commons data dirs her box writes: shared hand-offs and the cast's art. The rest of `/opt/commons` is read-only to her. pub const COMMONS_RW: [&str; 2] = ["/opt/commons/handoff", "/opt/commons/cast-art"]; /// The longest a command may run. -pub const TIMEOUT_MAX_S: u64 = 120; +pub(crate) const TIMEOUT_MAX_S: u64 = 120; /// How much of each output stream the receipt keeps: its tail. const TAIL_BYTES: usize = 4096; /// The most paths the receipt lists as written, and the most entries a walk for them visits. @@ -86,7 +86,7 @@ pub(crate) fn box_argv(paths: &BoxPaths<'_>, command: &str) -> Vec { /// answer is the receipt the connection gets back: `{tool: shell, status: ok|error, exit, duration_ms, stdout_tail, /// stderr_tail, wrote}`. `ok` is a command that ran and exited 0; anything else is `error` with why. `wrote` lists the files /// under the writable binds modified while it ran. -pub fn run_box(request: &[u8], paths: &BoxPaths<'_>) -> Value { +pub(crate) fn run_box(request: &[u8], paths: &BoxPaths<'_>) -> Value { let error = |why: String| json!({ "tool": "shell", "status": "error", "why": why }); let request: BoxRequest = match serde_json::from_slice(request) { Ok(request) => request, diff --git a/crates/mind-body/tests/public_surface.txt b/crates/mind-body/tests/public_surface.txt index 8f5242a..cc3d02f 100644 --- a/crates/mind-body/tests/public_surface.txt +++ b/crates/mind-body/tests/public_surface.txt @@ -9,6 +9,7 @@ mind_body: mod lease_client mind_body: mod persona mind_body: mod projection mind_body: mod queue +mind_body: mod sandbox mind_body: mod self_run mind_body: mod tempo mind_body::address: impl Addressee @@ -245,7 +246,7 @@ mind_body::persona: pub trait Trace : TraceView { fn record (& self , key : & st mind_body::persona: pub trait TraceView { fn records (& self) -> Result < Vec < Value > > ; } mind_body::persona: struct Config # [derive (Clone , Debug , PartialEq , Eq)] pub-fields[rooms: Vec < String >, operators: Vec < String >, minds: Vec < String >, own_sender: String, model: String, review_room: Option < String >] mind_body::persona: struct FileTrace pub-fields[] -mind_body::persona: struct Start< C : Chat > pub-fields[config: Config, persona: Box < dyn PersonaStore >, chat: C, trace: Box < dyn Trace >, addressing: Option < Box < dyn HeartbeatView > >, model: Box < dyn Model >, domain: Option < Box < dyn DomainSource > >, reads: Option < Box < dyn ReadSource > >, tuning: PathBuf, clock: Box < dyn Fn () -> DateTime < Utc > >] +mind_body::persona: struct Start< C : Chat > pub-fields[config: Config, persona: Box < dyn PersonaStore >, chat: C, trace: Box < dyn Trace >, addressing: Option < Box < dyn HeartbeatView > >, model: Box < dyn Model >, agent: Box < dyn Steps >, domain: Option < Box < dyn DomainSource > >, reads: Option < Box < dyn ReadSource > >, tuning: PathBuf, session: PathBuf, box_socket: PathBuf, clock: Box < dyn Fn () -> DateTime < Utc > >] mind_body::persona: struct TraceSnapshot pub-fields[] mind_body::persona: struct TurnRecord # [derive (Clone , Debug , PartialEq , DatabaseEntry)] pub-fields[value: Value] mind_body::projection: # [derive (Clone , Copy , Debug , Default , PartialEq , Eq , serde :: Deserialize)] # [serde (rename_all = "snake_case")] pub enum Through { # [default] Projector , Persona , } @@ -267,7 +268,7 @@ mind_body::projection: pub use select :: TurnKind ; mind_body::projection: pub use tuning :: { TUNING_FILE , TUNING_ROOT } ; mind_body::projection: struct HuginnPersonaSource pub-fields[] mind_body::projection: struct Organs< 'a > pub-fields[persona: Option < & 'a dyn PersonaSource >, chat: Option < & 'a dyn MouthReader >, addressing: Option < & 'a dyn HeartbeatView >, model: Option < & 'a dyn Model >, domain: Option < & 'a dyn DomainSource >, reads: Option < & 'a dyn ReadSource >] -mind_body::projection: struct Request # [derive (Clone)] pub-fields[instance: String, kind: TurnKind, state: Option < Value >, rooms: Vec < String >, seed: u64, renders: Option < usize >, judge_against: Option < Value >, operators: Vec < String >, minds: Vec < String >, own_sender: String, tuning: PathBuf, through: Through, last_heard: Vec < (String , u64) >, recent: Vec < Vec < String > >, own_rooms: Vec < String >, woken_for: Vec < String >, last_outcome: Option < Value >, last_wake: Option < DateTime < Utc > >, records: Vec < Value >] +mind_body::projection: struct Request # [derive (Clone)] pub-fields[instance: String, kind: TurnKind, state: Option < Value >, rooms: Vec < String >, seed: u64, renders: Option < usize >, judge_against: Option < Value >, operators: Vec < String >, minds: Vec < String >, own_sender: String, tuning: PathBuf, through: Through, last_heard: Vec < (String , u64) >, recent: Vec < Vec < String > >, own_rooms: Vec < String >, woken_for: Vec < String >, told: Vec < Value >, tools: Vec < String >, last_wake: Option < DateTime < Utc > >, records: Vec < Value >] mind_body::projection::agent: # [derive (Clone , Copy , Debug , PartialEq , Eq , Serialize)] # [serde (rename_all = "snake_case")] pub enum Status { Ok , Refused , Error , Unknown , NotSent , Cap , } mind_body::projection::agent: # [derive (Clone , Copy , Debug , PartialEq , Eq)] pub enum Cap { ToolCalls , ModelCalls , WakeSpend , DaySpend , } mind_body::projection::agent: # [derive (Clone , Debug , PartialEq , Eq)] pub enum Ended { EndTurn , Cap (Cap) , Failed (Failed) , } @@ -290,6 +291,7 @@ mind_body::projection::agent: impl Run < '_ > mind_body::projection::agent: impl Steps for KitModel mind_body::projection::agent: impl TraceLedger < 'a >: fn new (trace : & 'a dyn Trace , stem : impl Into < String >) -> Self mind_body::projection::agent: impl< 'a > TraceLedger < 'a > +mind_body::projection::agent: impl< T : Steps + ? Sized > Steps for std :: rc :: Rc < T > mind_body::projection::agent: pub trait Executor { fn definitions (& self) -> Vec < ToolDefinition > ; fn run (& self , call : & ToolCall) -> Receipt ; } mind_body::projection::agent: pub trait Ledger { fn rows (& self) -> Result < Vec < Value > > ; fn append (& self , row : Value) -> Result < u64 > ; } mind_body::projection::agent: pub trait Steps { fn step (& self , request : StepRequest < '_ >) -> std :: result :: Result < Stepped , Failed > ; } @@ -299,7 +301,17 @@ mind_body::projection::agent: struct Receipt # [derive (Clone , Debug , PartialE mind_body::projection::agent: struct Session # [derive (Clone , Debug , PartialEq , Serialize , Deserialize)] pub-fields[items: Vec < InputItem >, digest: String, retention: CacheRetention, created_at: DateTime < Utc >, last_call_at: DateTime < Utc >, last_usage: Option < Spent >] mind_body::projection::agent: struct TraceLedger< 'a > pub-fields[] mind_body::projection::agent: struct Turn # [derive (Clone , Debug , PartialEq)] pub-fields[ended: Ended, text: String, receipts: Vec < Receipt >, model_calls: usize, tool_calls: usize, usd: f64] -mind_body::projection::agent: struct Wake< 'a > pub-fields[id: & 'a str, instructions: & 'a str, input: & 'a str] +mind_body::projection::agent: struct Wake< 'a > pub-fields[id: & 'a str, instructions: & 'a str, input: & 'a str, fresh: & 'a str] +mind_body::projection::agent::read: impl Executor for Read < '_ > +mind_body::projection::agent::read: struct Read< 'a > pub-fields[source: Option < & 'a dyn ReadSource >, since: DateTime < Utc >] +mind_body::projection::agent::request_tool: impl Executor for RequestTool +mind_body::projection::agent::request_tool: struct RequestTool pub-fields[] +mind_body::projection::agent::say: impl Executor for Say < '_ > +mind_body::projection::agent::say: impl Mouth < '_ > +mind_body::projection::agent::say: impl Say < '_ > +mind_body::projection::agent::say: struct Say< 'a > pub-fields[] +mind_body::projection::agent::shell: impl Executor for Shell +mind_body::projection::agent::shell: struct Shell pub-fields[socket: PathBuf] mind_body::projection::commit: impl Commit < '_ > mind_body::projection::commit: impl Heard mind_body::projection::domain: impl DomainSource for DomainFacts @@ -337,6 +349,7 @@ mind_body::projection::narrate: impl KitModel: fn open (endpoint : SocketAddr , mind_body::projection::narrate: impl KitModel: fn step (& self , request : StepRequest < '_ >) -> std :: result :: Result < Stepped , Failed > mind_body::projection::narrate: impl Model for KitModel mind_body::projection::narrate: impl std :: fmt :: Display for Failed +mind_body::projection::narrate: impl< T : Model + ? Sized > Model for std :: rc :: Rc < T > mind_body::projection::narrate: pub trait Model { fn ask (& self , request_id : & str , model : & str , prompt : & str , schema : Option < & str >) -> std :: result :: Result < Answer , Failed > ; } mind_body::projection::narrate: struct Answer # [derive (Clone , Debug , PartialEq , Eq)] pub-fields[text: String, usage: Option < Spent >] mind_body::projection::narrate: struct Failed # [derive (Clone , Debug , PartialEq , Eq)] pub-fields[reason: String, outage: bool, usage: Option < Spent >] @@ -347,7 +360,6 @@ mind_body::projection::narrate: struct Stepped # [derive (Clone , Debug , Partia mind_body::projection::narrate: struct ToolCall # [derive (Clone , Debug , PartialEq , Eq)] pub-fields[call_id: String, name: String, arguments: String] mind_body::projection::outcome: impl Outcome mind_body::projection::outcome: impl Part -mind_body::projection::outcome: impl Refusal mind_body::projection::outcome::form: impl EventPhrase mind_body::projection::outcome::form: impl Form < '_ > mind_body::projection::outcome::form: impl Name @@ -360,8 +372,8 @@ mind_body::projection::read: impl LiveReads mind_body::projection::read: impl LiveReads: fn new (client : HuginnClient , forge : Option < HttpForge >) -> Self mind_body::projection::read: impl ReadFailure mind_body::projection::read: impl ReadFixture -mind_body::projection::read: impl ReadRefusal mind_body::projection::read: impl ReadRequest +mind_body::projection::read: impl ReadRequest: fn from_target (kind : & str , target : & str) -> Result < Self , String > mind_body::projection::read: impl ReadSource for LiveReads mind_body::projection::read: impl ReadSource for ReadFixture mind_body::projection::read: pub trait ReadSource { fn read (& self , request : & ReadRequest , since : DateTime < Utc >) -> Result < String , ReadFailure > ; } @@ -420,6 +432,9 @@ mind_body::queue: impl< 'a > HuginnMind < 'a > mind_body::queue: pub trait MindPort { fn instance (& self) -> & Slug ; fn query (& self , selection : & Selection) -> Result < PipelineSelectionPage > ; fn query_near (& self , _selection : & Selection , _text : & str , _top_k : u32) -> Result < PipelineSelectionPage > { bail ! ("this mind port has no semantic index") } fn stewarded_activity (& self , _repos : & [OrgRepo] , _after : Option < u64 >) -> Result < RepoActivity > { bail ! ("this mind port has no forge to read") } fn roots_touched (& self) -> Result < Vec < RootTouched > > { bail ! ("this mind port has no roots to read") } fn admit (& self , agent : & str , session : & str , documents : Vec < PipelineDocument >) -> Result < PipelineAdmissionOutcome > ; } mind_body::queue: struct Held # [derive (Clone , Debug , PartialEq , Eq)] pub-fields[] mind_body::queue: struct HuginnMind< 'a > pub-fields[] +mind_body::sandbox: const COMMONS_RW : [& str ; 2] +mind_body::sandbox: fn serve_box (mut input : impl Read , mut output : impl Write , paths : & BoxPaths < '_ >) -> std :: io :: Result < () > +mind_body::sandbox: struct BoxPaths< 'a > pub-fields[home: & 'a Path, scratch: & 'a Path, extra_rw: & 'a [& 'a Path]] mind_body::self_run: # [derive (Clone , Copy , Debug , PartialEq , Eq , PartialOrd , Ord)] pub enum Stop { Interrupt , Terminate , Kill , } mind_body::self_run: # [derive (Clone , Copy , Debug , PartialEq , Eq)] pub enum Cause { Own , FlushRequested , Signalled (Stop) , Unstoppable , } mind_body::self_run: # [derive (Clone , Debug , PartialEq , Eq)] pub enum Read { Line (String) , Timeout , Eof , Exited (Option < i32 >) , } @@ -453,7 +468,6 @@ mind_body::self_run: fn start_message (instance : & Slug , run : & PipelineRef , mind_body::self_run: fn writes_hour_cache (line : & str) -> Option < bool > mind_body::self_run: impl Child for ClaudeProcess mind_body::self_run: impl ClaudeSpawner -mind_body::self_run: impl ClaudeSpawner: fn in_sandbox (unit_environment : impl IntoIterator < Item = (OsString , OsString) > , seed_variable : & str , sandbox : Option < PathBuf >) -> Result < Self > mind_body::self_run: impl ClaudeSpawner: fn new (unit_environment : impl IntoIterator < Item = (OsString , OsString) >) -> Result < Self > mind_body::self_run: impl Drop for FreshConfig mind_body::self_run: impl FreshConfig