pub struct SessionAsset {
pub id: String,
pub version: u32,
pub created_at_ms: u64,
pub updated_at_ms: u64,
pub history: ConversationHistory,
pub preferences: UserPreferences,
pub project_context: ProjectContext,
pub skill_configs: HashMap<String, SkillConfig>,
pub component_snapshots: HashMap<String, ComponentSnapshot>,
pub granted_commands: Vec<CommandGrant>,
pub metadata: HashMap<String, Value>,
}Expand description
SessionAsset - The accumulating value.
This is the core data structure that persists between sessions. It contains all the context and history that makes the assistant more useful over time.
§Example
use orcs_runtime::session::SessionAsset;
let mut asset = SessionAsset::new();
asset.project_context.name = Some("my-project".into());
// Save to JSON
let json = asset.to_json().expect("asset should serialize to JSON");Fields§
§id: StringAsset ID (UUID).
version: u32Session version for compatibility.
created_at_ms: u64Creation timestamp (milliseconds since epoch).
updated_at_ms: u64Last update timestamp (milliseconds since epoch).
history: ConversationHistoryConversation history.
preferences: UserPreferencesUser preferences.
project_context: ProjectContextProject context.
skill_configs: HashMap<String, SkillConfig>Skill configurations.
component_snapshots: HashMap<String, ComponentSnapshot>Component snapshots for resume.
granted_commands: Vec<CommandGrant>Granted command patterns (restored on session resume).
These are the commands that were approved via HIL during previous
sessions. On resume, they are restored into the GrantPolicy
so the user doesn’t need to re-approve the same commands.
metadata: HashMap<String, Value>Arbitrary metadata.
Implementations§
Source§impl SessionAsset
impl SessionAsset
Sourcepub fn for_project(path: impl Into<PathBuf>) -> Self
pub fn for_project(path: impl Into<PathBuf>) -> Self
Creates a session asset for a specific project.
Sourcepub fn add_turn(&mut self, turn: ConversationTurn)
pub fn add_turn(&mut self, turn: ConversationTurn)
Adds a conversation turn.
Sourcepub fn set_skill_config(
&mut self,
skill_id: impl Into<String>,
config: SkillConfig,
)
pub fn set_skill_config( &mut self, skill_id: impl Into<String>, config: SkillConfig, )
Updates a skill configuration.
Sourcepub fn save_snapshot(&mut self, snapshot: ComponentSnapshot)
pub fn save_snapshot(&mut self, snapshot: ComponentSnapshot)
Saves a component snapshot.
Sourcepub fn get_snapshot(&self, fqn: &str) -> Option<&ComponentSnapshot>
pub fn get_snapshot(&self, fqn: &str) -> Option<&ComponentSnapshot>
Retrieves a component snapshot by FQN.
Sourcepub fn remove_snapshot(&mut self, fqn: &str) -> Option<ComponentSnapshot>
pub fn remove_snapshot(&mut self, fqn: &str) -> Option<ComponentSnapshot>
Removes a component snapshot by FQN.
Sourcepub fn clear_snapshots(&mut self)
pub fn clear_snapshots(&mut self)
Clears all component snapshots.
Sourcepub fn snapshot_count(&self) -> usize
pub fn snapshot_count(&self) -> usize
Returns the number of saved snapshots.
Sourcepub fn save_grants(&mut self, grants: Vec<CommandGrant>)
pub fn save_grants(&mut self, grants: Vec<CommandGrant>)
Saves granted commands (replaces existing).
Call this before persisting the session to capture the current
grant state from a GrantPolicy.
Sourcepub fn granted_commands(&self) -> &[CommandGrant]
pub fn granted_commands(&self) -> &[CommandGrant]
Returns the saved granted commands.
Sourcepub fn grant_count(&self) -> usize
pub fn grant_count(&self) -> usize
Returns the number of saved grants.
Sourcepub fn created_at(&self) -> DateTime<Utc>
pub fn created_at(&self) -> DateTime<Utc>
Returns the creation time as a DateTime.
Sourcepub fn updated_at(&self) -> DateTime<Utc>
pub fn updated_at(&self) -> DateTime<Utc>
Returns the update time as a DateTime.
Trait Implementations§
Source§impl Clone for SessionAsset
impl Clone for SessionAsset
Source§fn clone(&self) -> SessionAsset
fn clone(&self) -> SessionAsset
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more