Skip to main content

CallContext

Struct CallContext 

Source
#[non_exhaustive]
pub struct CallContext { pub cwd: PathBuf, pub max_output_bytes: usize, pub call_id: Ulid, pub deadline: Option<Instant>, pub read_tracker: Option<Arc<ReadTracker>>, pub capabilities: Arc<CapabilitySet>, pub tier: ToolTier, pub caller_id: Option<String>, pub secrets: Option<Arc<SecretBundle>>, pub cursor_issuer: Option<Arc<CursorIssuer>>, }

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§cwd: PathBuf

Working directory for relative-path tools (Read / Bash / Glob / …).

§max_output_bytes: usize

Advisory truncation budget. Tools should respect this and return truncation markers when producing larger output. In SP-12 this is derived from the tool’s tier via TierPolicy::max_output.

§call_id: Ulid

Unique id for tracing/logging; not emitted on the wire.

§deadline: Option<Instant>

Absolute deadline. Tools that wrap long operations in tokio::time::timeout should pass remaining_time() as the budget.

§read_tracker: Option<Arc<ReadTracker>>

Shared-per-connection read tracker. None in isolated unit tests; server always attaches one via Arc::clone in per-connection state.

§capabilities: Arc<CapabilitySet>

Connection-scoped capability allow-list. Populated from the Hello handshake; shared across all calls on a single connection. Tools that gate side effects on caller authority may read this, though dispatch already enforces required_capabilities before invocation.

§tier: ToolTier

Tier the current call resolved to. Informational for tools; dispatch uses the tier to pick the deadline / max_output budget above.

§caller_id: Option<String>

Optional per-call agent identity. Populated from the Hello.client_id handshake; None for unit tests and in-process dispatch with no client-id source. Audit events copy this field into CallEvent.caller_id.

§secrets: Option<Arc<SecretBundle>>

Optional per-call secret bundle resolved by ServerConfig::token_broker (SP-token-broker-phase1). None means either (a) no broker is configured on this server, or (b) the broker returned Ok(None) for this caller — both cases pass through to the tool’s existing fallback (env vars, saved file, etc.). Tools that need a secret access via ctx.secrets(). Audit CallEvent.secrets_resolved is true iff this is Some(_).

§cursor_issuer: Option<Arc<CursorIssuer>>

SP-pagination-v1 — cursor issuer for tools that override Tool::call_paginated. None for non-paginating dispatch paths (test fixtures, listeners that haven’t wired pagination). Tools use ctx.cursor_issuer().issue(payload) to mint a next_cursor.

Implementations§

Source§

impl CallContext

Source

pub fn new( cwd: PathBuf, max_output_bytes: usize, call_id: Ulid, deadline: Option<Instant>, read_tracker: Option<Arc<ReadTracker>>, capabilities: Arc<CapabilitySet>, tier: ToolTier, caller_id: Option<String>, secrets: Option<Arc<SecretBundle>>, ) -> Self

Construct a CallContext from its required fields. This is the stable constructor across crate boundaries — the type is #[non_exhaustive], so adding new fields in the future means callers migrate through CallContext::new(...) (or a future CallContextBuilder), not via struct-literal breakage.

Source

pub fn with_cursor_issuer(self, issuer: Arc<CursorIssuer>) -> Self

Builder-style attach of the cursor issuer. Call after new from dispatch code that wants to enable pagination for the call.

Source

pub fn cursor_issuer(&self) -> Option<&CursorIssuer>

Convenience accessor for paginating tools. Returns the issuer if one was attached by dispatch; tools that override call_paginated but find this None must fall back to returning next_cursor: None (or error if cursors are mandatory).

Source

pub fn remaining_time(&self) -> Option<Duration>

Source

pub fn secrets(&self) -> Option<&SecretBundle>

Returns the resolved secret bundle, if any. None when no broker is configured on the server, or when the broker returned None for this caller.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
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