pub struct HeadlessRuntime { /* private fields */ }Expand description
Reusable application service for one-shot tasks.
It owns the existing provider-neutral Agent Engine state but starts no
channel, Web server, or scheduler. Both microclaw run and MicroClaw Code call this
service instead of assembling or copying an Agent Loop.
Implementations§
Source§impl HeadlessRuntime
impl HeadlessRuntime
Sourcepub fn skill_catalog(&self, include_unavailable: bool) -> Vec<SkillAvailability>
pub fn skill_catalog(&self, include_unavailable: bool) -> Vec<SkillAvailability>
Return the Skills visible to this runtime, including availability diagnostics when requested. Embedding facades use this to present a catalog without exposing runtime state.
Sourcepub fn reload_skill_catalog(
&self,
include_unavailable: bool,
) -> Vec<SkillAvailability>
pub fn reload_skill_catalog( &self, include_unavailable: bool, ) -> Vec<SkillAvailability>
Invalidate cached integrity verdicts and rebuild the runtime’s Skill catalog.
Sourcepub fn set_skill_enabled(&self, name: &str, enabled: bool) -> Result<(), String>
pub fn set_skill_enabled(&self, name: &str, enabled: bool) -> Result<(), String>
Change runtime-scoped Skill enablement without rewriting the Skill package.
Sourcepub async fn install_skill(
&self,
reference: &str,
) -> Result<SkillInstallOutcome, String>
pub async fn install_skill( &self, reference: &str, ) -> Result<SkillInstallOutcome, String>
Install or update a Skill through the shared governed package path.
Sourcepub fn archive_skill(&self, name: &str) -> Result<PathBuf, String>
pub fn archive_skill(&self, name: &str) -> Result<PathBuf, String>
Recoverably remove a Skill and return its archive location.
Sourcepub fn subagent_runs(
&self,
session: &str,
limit: usize,
) -> Result<Vec<HeadlessSubagentRun>>
pub fn subagent_runs( &self, session: &str, limit: usize, ) -> Result<Vec<HeadlessSubagentRun>>
List durable Subagent runs belonging to a named embedded session.
Sourcepub fn session_messages(
&self,
session: &str,
limit: usize,
) -> Result<Vec<HeadlessSessionMessage>>
pub fn session_messages( &self, session: &str, limit: usize, ) -> Result<Vec<HeadlessSessionMessage>>
The most recent limit stored messages of a named embedded session,
oldest first: user prompts (including steering) and final replies.
Empty for a session that never ran.
Sourcepub async fn checkpoint_session(
&self,
channel: &str,
session: &str,
label: &str,
) -> Result<Option<HeadlessCheckpoint>>
pub async fn checkpoint_session( &self, channel: &str, session: &str, label: &str, ) -> Result<Option<HeadlessCheckpoint>>
Snapshot the session’s working directory now and return the checkpoint
that holds its current state (a new one, or the latest when nothing
changed since). Requires checkpoints_enabled.
Sourcepub async fn session_checkpoints(
&self,
channel: &str,
session: &str,
limit: usize,
) -> Result<Vec<HeadlessCheckpoint>>
pub async fn session_checkpoints( &self, channel: &str, session: &str, limit: usize, ) -> Result<Vec<HeadlessCheckpoint>>
Recent checkpoints of the session’s working directory, newest first.
Sourcepub async fn restore_session_checkpoint(
&self,
channel: &str,
session: &str,
commit: &str,
) -> Result<Option<HeadlessCheckpoint>>
pub async fn restore_session_checkpoint( &self, channel: &str, session: &str, commit: &str, ) -> Result<Option<HeadlessCheckpoint>>
Restore the session’s working directory to commit. The current
state is checkpointed first, so a restore can itself be undone.
Sourcepub async fn session_usage(&self, session: &str) -> Result<HeadlessUsage>
pub async fn session_usage(&self, session: &str) -> Result<HeadlessUsage>
Token usage recorded for a session.
Sourcepub async fn session_model(
&self,
channel: &str,
session: &str,
) -> Result<String>
pub async fn session_model( &self, channel: &str, session: &str, ) -> Result<String>
The model the next run of this session uses.
Sourcepub async fn set_session_model(
&self,
channel: &str,
session: &str,
model: Option<&str>,
) -> Result<String>
pub async fn set_session_model( &self, channel: &str, session: &str, model: Option<&str>, ) -> Result<String>
Override the model for one session (None clears the override).
Runtime-only, like /model here. Returns the effective model.
Sourcepub async fn session_mark(&self, session: &str) -> Result<SessionMark>
pub async fn session_mark(&self, session: &str) -> Result<SessionMark>
The current end of a session’s conversation, to return to later with
Self::rewind_session_to.
Sourcepub async fn rewind_session_to(
&self,
channel: &str,
session: &str,
mark: &SessionMark,
) -> Result<usize>
pub async fn rewind_session_to( &self, channel: &str, session: &str, mark: &SessionMark, ) -> Result<usize>
Cut a session’s conversation back to mark, dropping everything
after it (the whole conversation is archived first). Fails when the
conversation no longer starts with what it held at the mark, for
example after a compaction. Returns how many messages were removed.
Sourcepub async fn compact_session(
&self,
channel: &str,
session: &str,
keep_recent: usize,
focus: Option<&str>,
) -> Result<HeadlessCompaction>
pub async fn compact_session( &self, channel: &str, session: &str, keep_recent: usize, focus: Option<&str>, ) -> Result<HeadlessCompaction>
Summarize older messages of a session now (the same compaction a long
session gets automatically, but always summarizing). focus steers
what the summary keeps.
Sourcepub async fn context_usage(
&self,
channel: &str,
session: &str,
) -> Result<HeadlessContextUsage>
pub async fn context_usage( &self, channel: &str, session: &str, ) -> Result<HeadlessContextUsage>
How full a session’s context is: the model’s window and compaction threshold, the last request’s size and where the conversation’s tokens go.
Sourcepub async fn fork_session(&self, from: &str, to: &str) -> Result<()>
pub async fn fork_session(&self, from: &str, to: &str) -> Result<()>
Copy a session’s conversation (agent context and stored messages)
into a new session. Fails when to already has a conversation.
Sourcepub async fn handoff_session(
&self,
channel: &str,
from: &str,
to: &str,
goal: &str,
) -> Result<usize>
pub async fn handoff_session( &self, channel: &str, from: &str, to: &str, goal: &str, ) -> Result<usize>
Start session to from a summary of session from focused on
goal (the original session is unchanged). Returns the estimated
tokens of the seeded context.
Sourcepub fn cancel_subagent(&self, session: &str, run_id: &str) -> Result<bool>
pub fn cancel_subagent(&self, session: &str, run_id: &str) -> Result<bool>
Persist and promptly signal cancellation for one Subagent owned by the session.
Sourcepub fn background_jobs(
&self,
caller_channel: &str,
session: &str,
) -> Result<Vec<BackgroundJob>>
pub fn background_jobs( &self, caller_channel: &str, session: &str, ) -> Result<Vec<BackgroundJob>>
Background shell processes of a session, oldest first.
Sourcepub fn detach_foreground_commands(
&self,
caller_channel: &str,
session: &str,
) -> Result<Vec<String>>
pub fn detach_foreground_commands( &self, caller_channel: &str, session: &str, ) -> Result<Vec<String>>
Move the session’s running foreground shell commands to the background. Returns their ids.
Sourcepub fn background_job_output(
&self,
caller_channel: &str,
session: &str,
id: &str,
max_bytes: usize,
) -> Result<String>
pub fn background_job_output( &self, caller_channel: &str, session: &str, id: &str, max_bytes: usize, ) -> Result<String>
The last max_bytes of a background process’s output.
Sourcepub async fn kill_background_job(
&self,
caller_channel: &str,
session: &str,
id: &str,
) -> Result<String>
pub async fn kill_background_job( &self, caller_channel: &str, session: &str, id: &str, ) -> Result<String>
Stop a background process. Returns its status line.
Sourcepub async fn load(config: Config) -> Result<Self>
pub async fn load(config: Config) -> Result<Self>
Build a standalone runtime from a loaded product config.
This is the Code/headless bootstrap path. It intentionally initializes no chat adapters, Web routes, scheduler, or gateway.
pub fn new( config: Config, db: Database, memory: MemoryManager, skills: SkillManager, mcp_manager: McpManager, ) -> Self
Sourcepub fn into_embedded_runtime(
self,
caller_channel: impl Into<String>,
max_concurrent_runs: usize,
) -> Result<Runtime, RuntimeBuildError>
pub fn into_embedded_runtime( self, caller_channel: impl Into<String>, max_concurrent_runs: usize, ) -> Result<Runtime, RuntimeBuildError>
Build the public embeddable Runtime over this configured Agent Engine.
pub async fn run( &self, request: HeadlessRunRequest, event_tx: Option<UnboundedSender<RuntimeEventEnvelope>>, ) -> Result<HeadlessRunResult>
pub async fn run_with_profile( &self, request: HeadlessRunRequest, profile: AgentProfile, event_tx: Option<UnboundedSender<RuntimeEventEnvelope>>, ) -> Result<HeadlessRunResult>
Sourcepub async fn cancel_session(&self, session: &str) -> Result<usize>
pub async fn cancel_session(&self, session: &str) -> Result<usize>
Cancel active work for a named headless session.
This delegates to the same run-control registry used by chat, Web, and scheduler adapters, so callers stop the real Agent Engine rather than merely hiding its output.
pub async fn cancel_code_session(&self, session: &str) -> Result<usize>
Sourcepub async fn steer_session(&self, session: &str, content: &str) -> Result<bool>
pub async fn steer_session(&self, session: &str, content: &str) -> Result<bool>
Add a user update to an active named session.
The shared Agent Engine drains this queue at its normal tool/end-turn
breakpoints. Returning false means the run ended before the update
could be queued; callers must not report it as accepted.
pub async fn steer_code_session( &self, session: &str, content: &str, ) -> Result<bool>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for HeadlessRuntime
impl !UnwindSafe for HeadlessRuntime
impl Forget for HeadlessRuntime
impl Freeze for HeadlessRuntime
impl Move for HeadlessRuntime
impl Send for HeadlessRuntime
impl Sync for HeadlessRuntime
impl Unpin for HeadlessRuntime
impl UnsafeUnpin for HeadlessRuntime
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T, C> ComponentsInto<C> for T
impl<T, C> ComponentsInto<C> for T
Source§fn components_into(self) -> C
fn components_into(self) -> C
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
fn into_option(self) -> Option<T>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<T> StrictAs for T
impl<T> StrictAs for T
Source§fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
Source§impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
Source§fn strict_cast_from(src: Src) -> Dst
fn strict_cast_from(src: Src) -> Dst
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.Source§impl<U, T> ToOwnedTable<U> for Twhere
U: FromTableRef<T>,
impl<U, T> ToOwnedTable<U> for Twhere
U: FromTableRef<T>,
fn to_owned_table(&self) -> U
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more