返回 CodeWhale
runtime.rs
根目录 / crates / memory / src / 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.
3 use crate::{Access, Result, Scope, Store, protocol::ToolServer};
4 use std::path::PathBuf;
5
6 #[derive(Debug, Clone)]
7 pub 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.
15 pub 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 }
33
33 lines RUST