pub struct SqzEngine { /* private fields */ }Expand description
Top-level facade that wires all sqz_engine modules together.
§Concurrency design
SqzEngine is designed for single-threaded use on the main thread.
The only cross-thread sharing happens during preset hot-reload: the
file-watcher callback runs on a background thread and needs to update
the preset, pipeline, and model router. These three fields are wrapped
in Arc<Mutex<>> specifically for that purpose. All other fields are
owned directly — no unnecessary synchronization.
Implementations§
Source§impl SqzEngine
impl SqzEngine
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new engine with the default preset and a persistent session store.
Sessions are stored in ~/.sqz/sessions.db for cross-session continuity.
Falls back to a temp-file store if the home directory is unavailable.
Sourcepub fn with_preset_and_store(preset: Preset, store_path: &Path) -> Result<Self>
pub fn with_preset_and_store(preset: Preset, store_path: &Path) -> Result<Self>
Create with a custom preset and a file-backed session store.
Opens a single SQLite connection for the session store. The cache manager and pin manager share the same store via separate connections (SQLite WAL mode supports concurrent readers).
Sourcepub fn compress(&self, input: &str) -> Result<CompressedContent>
pub fn compress(&self, input: &str) -> Result<CompressedContent>
Compress input text using the current preset.
Sourcepub fn export_ctx(&self, session_id: &str) -> Result<String>
pub fn export_ctx(&self, session_id: &str) -> Result<String>
Export a session to CTX format.
Sourcepub fn import_ctx(&self, ctx: &str) -> Result<SessionId>
pub fn import_ctx(&self, ctx: &str) -> Result<SessionId>
Import a CTX string and save as a new session.
Sourcepub fn pin(
&self,
session_id: &str,
turn_index: usize,
reason: &str,
tokens: u32,
) -> Result<PinEntry>
pub fn pin( &self, session_id: &str, turn_index: usize, reason: &str, tokens: u32, ) -> Result<PinEntry>
Pin a conversation turn.
Sourcepub fn unpin(&self, session_id: &str, turn_index: usize) -> Result<()>
pub fn unpin(&self, session_id: &str, turn_index: usize) -> Result<()>
Unpin a conversation turn.
Sourcepub fn search_sessions(&self, query: &str) -> Result<Vec<SessionSummary>>
pub fn search_sessions(&self, query: &str) -> Result<Vec<SessionSummary>>
Search sessions by keyword.
Sourcepub fn usage_report(&self, agent_id: &str) -> UsageReport
pub fn usage_report(&self, agent_id: &str) -> UsageReport
Get usage report for an agent.
Sourcepub fn cost_summary(&self, session_id: &str) -> Result<SessionCostSummary>
pub fn cost_summary(&self, session_id: &str) -> Result<SessionCostSummary>
Get cost summary for a session.
Sourcepub fn reload_preset(&mut self, toml: &str) -> Result<()>
pub fn reload_preset(&mut self, toml: &str) -> Result<()>
Reload the preset from a TOML string (hot-reload support).
Sourcepub fn watch_preset_file(&self, path: &Path) -> Result<RecommendedWatcher>
pub fn watch_preset_file(&self, path: &Path) -> Result<RecommendedWatcher>
Spawn a background thread that watches path for preset file changes.
Only the preset, pipeline, and model_router are shared with the watcher
thread (via Arc<Mutex<>>). All other engine state stays on the main thread.
Sourcepub fn session_store(&self) -> &SessionStore
pub fn session_store(&self) -> &SessionStore
Access the underlying SessionStore.
Sourcepub fn ast_parser(&self) -> &AstParser
pub fn ast_parser(&self) -> &AstParser
Access the AstParser.
Sourcepub fn terse_mode(&self) -> &TerseMode
pub fn terse_mode(&self) -> &TerseMode
Access the TerseMode helper.