pub struct ExtensionContext {
pub cwd: PathBuf,
pub config: Value,
pub session_id: Option<String>,
/* private fields */
}Expand description
Context provided to extension lifecycle hooks and event handlers.
This is the primary interface through which extensions interact with the host application.
Fields§
§cwd: PathBufCurrent working directory.
config: ValueExtension-specific configuration (validated against manifest schema).
session_id: Option<String>Session ID for the current session (if any).
Implementations§
Source§impl ExtensionContext
impl ExtensionContext
Sourcepub fn new(
cwd: PathBuf,
settings: Arc<RwLock<Settings>>,
config: Value,
session_id: Option<String>,
idle: Arc<RwLock<bool>>,
tool_registrar: Arc<dyn Fn(Arc<dyn AgentTool>) + Send + Sync>,
message_sender: Arc<dyn Fn(&str) + Send + Sync>,
errors: Arc<RwLock<Vec<ExtensionErrorRecord>>>,
) -> Self
pub fn new( cwd: PathBuf, settings: Arc<RwLock<Settings>>, config: Value, session_id: Option<String>, idle: Arc<RwLock<bool>>, tool_registrar: Arc<dyn Fn(Arc<dyn AgentTool>) + Send + Sync>, message_sender: Arc<dyn Fn(&str) + Send + Sync>, errors: Arc<RwLock<Vec<ExtensionErrorRecord>>>, ) -> Self
Create a new extension context.
Most callers should use ExtensionContextBuilder instead.
Sourcepub fn register_tool(&self, tool: Arc<dyn AgentTool>)
pub fn register_tool(&self, tool: Arc<dyn AgentTool>)
Register a tool that the agent can call.
Sourcepub fn send_message(&self, text: &str)
pub fn send_message(&self, text: &str)
Send a text message to the agent / conversation.
Sourcepub fn record_error(&self, extension_name: &str, event: &str, error: &str)
pub fn record_error(&self, extension_name: &str, event: &str, error: &str)
Record an error that occurred inside an extension hook.
Sourcepub fn errors(&self) -> Vec<ExtensionErrorRecord>
pub fn errors(&self) -> Vec<ExtensionErrorRecord>
Get all recorded extension errors.
Sourcepub fn clear_errors(&self)
pub fn clear_errors(&self)
Clear all recorded extension errors.
Sourcepub fn config_get(&self, path: &str) -> Option<Value>
pub fn config_get(&self, path: &str) -> Option<Value>
Read the extension-specific configuration value at the given path.
Returns None if the path doesn’t exist.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExtensionContext
impl !RefUnwindSafe for ExtensionContext
impl Send for ExtensionContext
impl Sync for ExtensionContext
impl Unpin for ExtensionContext
impl UnsafeUnpin for ExtensionContext
impl !UnwindSafe for ExtensionContext
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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> 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>
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 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>
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