Skip to main content

Crate thulp_workspace

Crate thulp_workspace 

Source
Expand description

§thulp-workspace

Workspace and session management for thulp.

This crate provides functionality for managing agent workspaces, including context, state, and session persistence.

§Features

  • Workspace Management: Create, load, and manage workspaces with metadata and context
  • Session Management: Track conversation history, tool calls, and skill executions
  • Turn Counting: Monitor conversation turns with configurable limits
  • Persistence: File-based storage for sessions with in-memory caching
  • Filtering: Query sessions by status, type, tags, and timestamps

§Example

use thulp_workspace::{Workspace, SessionManager, SessionType, SessionFilter};
use std::path::PathBuf;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a workspace
    let workspace = Workspace::new("my-workspace", "My Workspace", PathBuf::from("."));

    // Create a session manager
    let manager = SessionManager::new(&workspace).await?;

    // Create a session
    let session = manager.create_session("Chat Session", SessionType::Conversation {
        purpose: "User assistance".to_string(),
    }).await?;

    // Add entries
    manager.add_entry(
        session.id(),
        EntryType::UserMessage,
        serde_json::json!({"text": "Hello!"}),
    ).await?;

    // Query sessions
    let active_sessions = manager.find_by_status(SessionStatus::Active).await?;

    Ok(())
}

Re-exports§

pub use filter::SessionFilter;
pub use session::EntryType;
pub use session::LimitAction;
pub use session::LimitCheck;
pub use session::LimitExceeded;
pub use session::Session;
pub use session::SessionConfig;
pub use session::SessionEntry;
pub use session::SessionId;
pub use session::SessionMetadata;
pub use session::SessionStatus;
pub use session::SessionType;
pub use session::Timestamp;
pub use session_manager::SessionManager;

Modules§

filter
Session filtering for queries.
session
Session types and management for thulp.
session_manager
Session manager for persisting and managing sessions.

Structs§

Workspace
A workspace for an agent session
WorkspaceManager
Manager for multiple workspaces

Enums§

WorkspaceError
Errors that can occur in workspace operations

Type Aliases§

Result
Result type for workspace operations