pub struct Context {
pub scope_value: Option<Value>,
pub scope_index: usize,
pub session_id: Option<String>,
pub stack_info: Option<StackInfo>,
pub prompts_dir: PathBuf,
/* private fields */
}Expand description
Tree-structured context that stores step outputs
Fields§
§scope_value: Option<Value>§scope_index: usize§session_id: Option<String>§stack_info: Option<StackInfo>Detected stack info for prompt resolution (Story 11.5/11.6)
prompts_dir: PathBufDirectory where prompt template files live (defaults to “prompts”)
Implementations§
Source§impl Context
impl Context
pub fn new(target: String, vars: HashMap<String, Value>) -> Self
Sourcepub fn store(&mut self, name: &str, output: StepOutput)
pub fn store(&mut self, name: &str, output: StepOutput)
Store a step output
Sourcepub fn get_step(&self, name: &str) -> Option<&StepOutput>
pub fn get_step(&self, name: &str) -> Option<&StepOutput>
Get a step output (looks in parent if not found locally)
Sourcepub fn insert_var(&mut self, name: impl Into<String>, value: Value)
pub fn insert_var(&mut self, name: impl Into<String>, value: Value)
Insert a variable into this context
Sourcepub fn get_session(&self) -> Option<&str>
pub fn get_session(&self) -> Option<&str>
Get session ID (searches parent chain)
Sourcepub fn store_parsed(&mut self, name: &str, parsed: ParsedValue)
pub fn store_parsed(&mut self, name: &str, parsed: ParsedValue)
Store a parsed value for a step
Sourcepub fn get_parsed(&self, name: &str) -> Option<&ParsedValue>
pub fn get_parsed(&self, name: &str) -> Option<&ParsedValue>
Get a parsed value for a step (looks in parent if not found locally)
Sourcepub fn child(
parent: Arc<Context>,
scope_value: Option<Value>,
index: usize,
) -> Self
pub fn child( parent: Arc<Context>, scope_value: Option<Value>, index: usize, ) -> Self
Create a child context for a scope
Sourcepub fn all_variables(&self) -> HashMap<String, Value>
pub fn all_variables(&self) -> HashMap<String, Value>
Get all variables (local + parent chain) merged into a flat HashMap
Sourcepub fn get_stack_info(&self) -> Option<&StackInfo>
pub fn get_stack_info(&self) -> Option<&StackInfo>
Get the stack_info from this context or any parent
Sourcepub fn get_from_value(&self, name: &str) -> Option<Value>
pub fn get_from_value(&self, name: &str) -> Option<Value>
Get the Tera-ready value for a step by name (used by from() preprocessing). Returns None if the step doesn’t exist in this context or any parent.
Sourcepub fn var_exists(&self, path: &str) -> bool
pub fn var_exists(&self, path: &str) -> bool
Check if a dotted path variable exists in this context (used for strict accessor)
Sourcepub fn get_chat_messages(&self, session: &str) -> Vec<ChatMessage>
pub fn get_chat_messages(&self, session: &str) -> Vec<ChatMessage>
Return all stored messages for a chat session (empty vec if session doesn’t exist)
Sourcepub fn append_chat_messages(&self, session: &str, messages: Vec<ChatMessage>)
pub fn append_chat_messages(&self, session: &str, messages: Vec<ChatMessage>)
Append messages to a chat session, creating the session if it doesn’t exist
Sourcepub fn to_tera_context(&self) -> Context
pub fn to_tera_context(&self) -> Context
Convert to Tera template context