Skip to main content

SqzEngine

Struct SqzEngine 

Source
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

Source

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.

Source

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).

Source

pub fn compress(&self, input: &str) -> Result<CompressedContent>

Compress input text using the current preset.

Source

pub fn export_ctx(&self, session_id: &str) -> Result<String>

Export a session to CTX format.

Source

pub fn import_ctx(&self, ctx: &str) -> Result<SessionId>

Import a CTX string and save as a new session.

Source

pub fn pin( &self, session_id: &str, turn_index: usize, reason: &str, tokens: u32, ) -> Result<PinEntry>

Pin a conversation turn.

Source

pub fn unpin(&self, session_id: &str, turn_index: usize) -> Result<()>

Unpin a conversation turn.

Source

pub fn search_sessions(&self, query: &str) -> Result<Vec<SessionSummary>>

Search sessions by keyword.

Source

pub fn usage_report(&self, agent_id: &str) -> UsageReport

Get usage report for an agent.

Source

pub fn cost_summary(&self, session_id: &str) -> Result<SessionCostSummary>

Get cost summary for a session.

Source

pub fn reload_preset(&mut self, toml: &str) -> Result<()>

Reload the preset from a TOML string (hot-reload support).

Source

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.

Source

pub fn session_store(&self) -> &SessionStore

Access the underlying SessionStore.

Source

pub fn ast_parser(&self) -> &AstParser

Access the AstParser.

Source

pub fn terse_mode(&self) -> &TerseMode

Access the TerseMode helper.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.