pub struct ToolContext {
config: Arc<Config>,
}Expand description
Context bridge for tool execution.
Provides tools with access to the Context Harness knowledge base during execution. Created by the server for each tool invocation.
All methods delegate to the same core functions used by the CLI and HTTP server, ensuring tools have identical capabilities.
Fields§
§config: Arc<Config>Implementations§
Source§impl ToolContext
impl ToolContext
Sourcepub async fn search(
&self,
query: &str,
opts: SearchOptions,
) -> Result<Vec<SearchResultItem>>
pub async fn search( &self, query: &str, opts: SearchOptions, ) -> Result<Vec<SearchResultItem>>
Search the knowledge base.
Equivalent to POST /tools/search or ctx search.
§Example
let results = ctx.search("deployment runbook", SearchOptions {
mode: Some("hybrid".to_string()),
limit: Some(5),
..Default::default()
}).await?;Sourcepub async fn get(&self, id: &str) -> Result<DocumentResponse>
pub async fn get(&self, id: &str) -> Result<DocumentResponse>
Retrieve a document by UUID.
Equivalent to POST /tools/get or ctx get.
Sourcepub fn sources(&self) -> Result<Vec<SourceStatus>>
pub fn sources(&self) -> Result<Vec<SourceStatus>>
List all configured connectors and their status.
Equivalent to GET /tools/sources or ctx sources.
Auto Trait Implementations§
impl Freeze for ToolContext
impl RefUnwindSafe for ToolContext
impl Send for ToolContext
impl Sync for ToolContext
impl Unpin for ToolContext
impl UnwindSafe for ToolContext
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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