Skip to main content

systemprompt_models/execution/context/
caller_purpose.rs

1//! Caller purpose carried on a request so the credential broker can see why a
2//! credential is being asked for. It is set by a credential's issuer, never
3//! by its bearer.
4//!
5//! Only an issuer-bound source may bind the caller purpose: an API key's
6//! `purpose`, a JWT's `purpose` claim, or in-process code. It is never set from
7//! a request header.
8//!
9//! Copyright (c) systemprompt.io — Business Source License 1.1.
10//! See <https://systemprompt.io> for licensing details.
11
12use super::RequestContext;
13
14impl RequestContext {
15    pub fn with_caller_purpose(mut self, purpose: String) -> Self {
16        self.execution.caller_purpose = Some(purpose);
17        self
18    }
19
20    pub fn caller_purpose(&self) -> Option<&str> {
21        self.execution.caller_purpose.as_deref()
22    }
23}