Skip to main content

codewhale_memory/
runtime.rs

1//! Host-side opt-in gate. No store, index, or model tools are opened when off.
2//! Construct this from trusted application configuration, not tool arguments.
3use crate::{Access, Result, Scope, Store, protocol::ToolServer};
4use std::path::PathBuf;
5
6#[derive(Debug, Clone)]
7pub struct RuntimeOptions {
8    pub enabled: bool,
9    pub database: PathBuf,
10    pub workspace_root: Option<PathBuf>,
11}
12
13/// Own this synchronous adapter on a blocking worker. Expose its catalog only
14/// when Some is returned. Review and destructive controls stay with the host.
15pub fn open_tools(
16    options: RuntimeOptions,
17    access: Access,
18    write_scope: Scope,
19    checkpoint_scope: Option<Scope>,
20) -> Result<Option<ToolServer>> {
21    if !options.enabled {
22        return Ok(None);
23    }
24    let store = Store::open(&options.database)?;
25    Ok(Some(ToolServer::new(
26        store,
27        access,
28        write_scope,
29        checkpoint_scope,
30        options.workspace_root,
31    )?))
32}