Skip to main content

AppService

Struct AppService 

Source
pub struct AppService { /* private fields */ }

Implementations§

Source§

impl AppService

Source

pub async fn eval( &self, scenario: Option<String>, scenario_file: Option<String>, scenario_name: Option<String>, strategy: &str, strategy_opts: Option<Value>, ) -> Result<String, String>

Run an evalframe evaluation suite.

Accepts a scenario (bindings + cases) and a strategy name. Automatically wires the strategy as the provider and executes the evalframe suite, returning the report (summary, scores, failures).

Injects a std global (mlua-batteries compatible shim) so evalframe’s std.lua can resolve json/fs/time from algocline’s built-in primitives.

§Security: strategy is not sanitized

strategy is interpolated into a Lua string literal without escaping. This is intentional — same rationale as [make_require_code]: algocline runs Lua in the caller’s own process with full ambient authority, so Lua injection does not cross a trust boundary.

Source

pub fn eval_history( &self, strategy: Option<&str>, limit: usize, ) -> Result<String, String>

List eval history, optionally filtered by strategy.

Source

pub fn eval_detail(&self, eval_id: &str) -> Result<String, String>

View a specific eval result by ID.

Source

pub async fn eval_compare( &self, eval_id_a: &str, eval_id_b: &str, ) -> Result<String, String>

Compare two eval results with statistical significance testing.

Delegates to evalframe’s stats.welch_t (single source of truth for t-distribution table and test logic). Reads persisted aggregated.scores from each eval result — no re-computation of descriptive statistics.

The comparison result is persisted to ~/.algocline/evals/ so repeated lookups of the same pair are file reads only.

Source§

impl AppService

Source

pub async fn init(&self, project_root: Option<String>) -> Result<String, String>

Source§

impl AppService

Source

pub async fn add_note( &self, session_id: &str, content: &str, title: Option<&str>, ) -> Result<String, String>

Append a note to a session’s log file.

Source

pub async fn log_view( &self, session_id: Option<&str>, limit: Option<usize>, max_chars: Option<usize>, ) -> Result<String, String>

View session logs.

Source

pub fn info(&self) -> String

Return diagnostic info about the current configuration (mise doctor style).

Source

pub fn stats( &self, strategy_filter: Option<&str>, days: Option<u64>, ) -> Result<String, String>

Aggregate stats across all logged sessions.

Scans .meta.json files (with .json fallback for legacy logs). Optional filters: strategy (exact match), days (last N days).

§Legacy log compatibility

Token fields (prompt_tokens, response_tokens) were introduced in v0.12. Logs written by earlier versions lack these fields entirely. When absent, the aggregation treats them as 0 (via unwrap_or(0)) — the same pattern used for other numeric fields (elapsed_ms, total_prompt_chars, etc.). This means per-strategy total_tokens may under-report if the dataset includes pre-v0.12 sessions.

Source§

impl AppService

Source

pub async fn migrate( &self, project_root: Option<String>, ) -> Result<String, String>

Source§

impl AppService

Source

pub async fn pkg_install( &self, url: String, name: Option<String>, ) -> Result<String, String>

Install a package from a Git URL or local path.

Source§

impl AppService

Source

pub async fn pkg_list( &self, project_root: Option<String>, ) -> Result<String, String>

List installed packages with metadata, showing the full override chain.

When project_root is provided (or resolvable), project-local packages from alc.toml are prepended with scope: "project", merged with version/source info from alc.lock. Global packages carry scope: "global". If a project package and a global package share the same name, the project one is active: true and the global one active: false.

Source§

impl AppService

Source

pub async fn pkg_remove( &self, name: &str, project_root: Option<String>, version: Option<String>, ) -> Result<String, String>

Remove a package declaration from alc.toml and alc.lock.

Requires an alc.toml to be found via project_root or ancestor walk. Physical files in ~/.algocline/packages/ are not deleted.

  • name: package name to remove.
  • project_root: optional explicit project root.
  • version: optional version constraint (when specified, only removes the matching alc.lock entry; omit to remove any version).
Source§

impl AppService

Link a local directory as a package by creating a symlink in the cache.

path: source directory to link (absolute or cwd-relative). name: optional package name override (single package mode only). force: if true, overwrite an existing real directory at the destination. Existing symlinks (including dangling) are always overwritten.

Source§

impl AppService

Remove a symlinked package from the global cache.

  • If ~/.algocline/packages/{name} is a symlink: removes it.
  • If it is a real directory: returns an error directing to pkg_remove.
  • If it does not exist: returns an error.
Source§

impl AppService

Source

pub async fn run( &self, code: Option<String>, code_file: Option<String>, ctx: Option<Value>, project_root: Option<String>, ) -> Result<String, String>

Execute Lua code with optional JSON context.

project_root — optional absolute path to the project root containing alc.lock. Falls back to ALC_PROJECT_ROOT env or ancestor walk.

Source

pub async fn advice( &self, strategy: &str, task: Option<String>, opts: Option<Value>, project_root: Option<String>, ) -> Result<String, String>

Apply a built-in strategy to a task.

If the requested package is not installed, automatically installs the bundled package collection from GitHub before executing.

project_root — optional absolute path to the project root containing alc.lock. Falls back to ALC_PROJECT_ROOT env or ancestor walk.

Source

pub async fn continue_batch( &self, session_id: &str, responses: Vec<QueryResponse>, ) -> Result<String, String>

Continue a paused execution — batch feed.

Source

pub async fn continue_single( &self, session_id: &str, response: String, query_id: Option<&str>, usage: Option<TokenUsage>, ) -> Result<String, String>

Continue a paused execution — single response (with optional query_id).

Source§

impl AppService

Source

pub fn scenario_list(&self) -> Result<String, String>

List available scenarios in ~/.algocline/scenarios/.

Per-entry I/O errors are collected in "failures" rather than aborting.

Source

pub fn scenario_show(&self, name: &str) -> Result<String, String>

Show the content of a named scenario.

Source

pub async fn scenario_install(&self, url: String) -> Result<String, String>

Install scenarios from a Git URL or local path into ~/.algocline/scenarios/.

Expects the source to contain .lua files (at root or in a scenarios/ subdirectory).

Source§

impl AppService

Source

pub async fn status(&self, session_id: Option<&str>) -> Result<String, String>

Snapshot of all active sessions for external observation.

Returns JSON with session status, metrics, progress, and strategy name. Only includes sessions currently held in the registry (paused, awaiting host LLM responses). Completed sessions are not listed here — use alc_log_view for historical data.

Source§

impl AppService

Source

pub async fn update( &self, project_root: Option<String>, ) -> Result<String, String>

Source§

impl AppService

Source

pub fn new( executor: Arc<Executor>, log_config: AppConfig, search_paths: Vec<SearchPath>, ) -> Self

Trait Implementations§

Source§

impl Clone for AppService

Source§

fn clone(&self) -> AppService

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl EngineApi for AppService

Delegates each EngineApi method to the corresponding AppService inherent method via fully-qualified syntax (AppService::method(self, …)).

This avoids ambiguity between the trait method and the inherent method of the same name, preventing accidental infinite recursion if the inherent method is ever removed or renamed.

Source§

fn run<'life0, 'async_trait>( &'life0 self, code: Option<String>, code_file: Option<String>, ctx: Option<Value>, project_root: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute Lua code with optional JSON context.
Source§

fn advice<'life0, 'life1, 'async_trait>( &'life0 self, strategy: &'life1 str, task: Option<String>, opts: Option<Value>, project_root: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Apply an installed strategy package. Task is optional.
Source§

fn continue_single<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: &'life1 str, response: String, query_id: Option<&'life2 str>, usage: Option<TokenUsage>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Continue a paused execution — single response (with optional query_id).
Source§

fn continue_batch<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, responses: Vec<QueryResponse>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Continue a paused execution — batch feed.
Source§

fn status<'life0, 'life1, 'async_trait>( &'life0 self, session_id: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Query active session status.
Source§

fn eval<'life0, 'life1, 'async_trait>( &'life0 self, scenario: Option<String>, scenario_file: Option<String>, scenario_name: Option<String>, strategy: &'life1 str, strategy_opts: Option<Value>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Run an evalframe evaluation suite.
Source§

fn eval_history<'life0, 'life1, 'async_trait>( &'life0 self, strategy: Option<&'life1 str>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List eval history, optionally filtered by strategy.
Source§

fn eval_detail<'life0, 'life1, 'async_trait>( &'life0 self, eval_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

View a specific eval result by ID.
Source§

fn eval_compare<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, eval_id_a: &'life1 str, eval_id_b: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Compare two eval results with statistical significance testing.
Source§

fn scenario_list<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List available scenarios.
Source§

fn scenario_show<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Show the content of a named scenario.
Source§

fn scenario_install<'life0, 'async_trait>( &'life0 self, url: String, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Install scenarios from a Git URL or local path.
Link a local directory as a project-local package (symlink to cache). Read more
Remove a symlinked package from ~/.algocline/packages/. Read more
Source§

fn pkg_list<'life0, 'async_trait>( &'life0 self, project_root: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List installed packages with metadata. Read more
Source§

fn pkg_install<'life0, 'async_trait>( &'life0 self, url: String, name: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Install a package from a Git URL or local path.
Source§

fn pkg_remove<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, project_root: Option<String>, version: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a package declaration from alc.toml and alc.lock. Read more
Source§

fn add_note<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, session_id: &'life1 str, content: &'life2 str, title: Option<&'life3 str>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Append a note to a session’s log file.
Source§

fn log_view<'life0, 'life1, 'async_trait>( &'life0 self, session_id: Option<&'life1 str>, limit: Option<usize>, max_chars: Option<usize>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

View session logs.
Source§

fn stats<'life0, 'life1, 'async_trait>( &'life0 self, strategy_filter: Option<&'life1 str>, days: Option<u64>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Aggregate stats across all logged sessions.
Source§

fn init<'life0, 'async_trait>( &'life0 self, project_root: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Initialize alc.toml in the given project root. Read more
Source§

fn update<'life0, 'async_trait>( &'life0 self, project_root: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Re-resolve all alc.toml entries and rewrite alc.lock. Read more
Source§

fn migrate<'life0, 'async_trait>( &'life0 self, project_root: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Migrate a legacy alc.lock to alc.toml + new alc.lock format. Read more
Source§

fn info<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Show server configuration and diagnostic info.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> MaybeSend for T
where T: Send,