pub struct Context { /* private fields */ }Expand description
Runtime context available to a code-defined capability tool.
This is a narrow projection: identity, locale, progress, and cancellation.
Backend stores, credentials, tenant objects, registries, and host
extensions intentionally remain host implementation details. Hosts build
one per call via Context::new and the with_* seams; tests can do the
same without any runtime.
Implementations§
Source§impl Context
impl Context
Sourcepub fn new(
tool_name: impl Into<String>,
session_id: impl Into<String>,
workspace_id: impl Into<String>,
) -> Self
pub fn new( tool_name: impl Into<String>, session_id: impl Into<String>, workspace_id: impl Into<String>, ) -> Self
Create a context with no-op progress and a never-cancelled signal.
Sourcepub fn with_locale(self, locale: Option<String>) -> Self
pub fn with_locale(self, locale: Option<String>) -> Self
Set the resolved BCP 47 locale.
Sourcepub fn with_progress_sink(self, sink: Arc<dyn ProgressSink>) -> Self
pub fn with_progress_sink(self, sink: Arc<dyn ProgressSink>) -> Self
Attach the host’s progress delivery seam.
Sourcepub fn with_cancellation_signal(
self,
signal: Arc<dyn CancellationSignal>,
) -> Self
pub fn with_cancellation_signal( self, signal: Arc<dyn CancellationSignal>, ) -> Self
Attach the host’s call-scoped cancellation signal.
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
Opaque session identifier for correlation and application-side scoping.
Sourcepub fn workspace_id(&self) -> &str
pub fn workspace_id(&self) -> &str
Opaque identifier of the workspace attached to this session.
Sourcepub fn cancellation(&self) -> &CallCancellation
pub fn cancellation(&self) -> &CallCancellation
Call-scoped cancellation signal for work that may outlive execute.