pub struct ClaudeCodeStorage { /* private fields */ }Expand description
Storage layer for ClaudeCode sessions
Implementations§
Source§impl ClaudeCodeStorage
impl ClaudeCodeStorage
Sourcepub async fn new(
config: ClaudeCodeStorageConfig,
arbor: Arc<ArborStorage>,
) -> Result<Self, ClaudeCodeError>
pub async fn new( config: ClaudeCodeStorageConfig, arbor: Arc<ArborStorage>, ) -> Result<Self, ClaudeCodeError>
Create a new ClaudeCode storage instance with a shared Arbor storage
Sourcepub fn arbor(&self) -> &ArborStorage
pub fn arbor(&self) -> &ArborStorage
Get access to the underlying arbor storage
Sourcepub async fn session_create(
&self,
name: String,
working_dir: String,
model: Model,
system_prompt: Option<String>,
mcp_config: Option<Value>,
loopback_enabled: bool,
metadata: Option<Value>,
) -> Result<ClaudeCodeConfig, ClaudeCodeError>
pub async fn session_create( &self, name: String, working_dir: String, model: Model, system_prompt: Option<String>, mcp_config: Option<Value>, loopback_enabled: bool, metadata: Option<Value>, ) -> Result<ClaudeCodeConfig, ClaudeCodeError>
Create a new ClaudeCode session with a new conversation tree
Sourcepub async fn session_get(
&self,
session_id: &ClaudeCodeId,
) -> Result<ClaudeCodeConfig, ClaudeCodeError>
pub async fn session_get( &self, session_id: &ClaudeCodeId, ) -> Result<ClaudeCodeConfig, ClaudeCodeError>
Get a session by ID
Sourcepub async fn session_get_by_name(
&self,
name: &str,
) -> Result<ClaudeCodeConfig, ClaudeCodeError>
pub async fn session_get_by_name( &self, name: &str, ) -> Result<ClaudeCodeConfig, ClaudeCodeError>
Get a session by name (supports partial matching)
Sourcepub async fn session_list(&self) -> Result<Vec<ClaudeCodeInfo>, ClaudeCodeError>
pub async fn session_list(&self) -> Result<Vec<ClaudeCodeInfo>, ClaudeCodeError>
List all sessions
Sourcepub async fn session_update_head(
&self,
session_id: &ClaudeCodeId,
new_head: NodeId,
claude_session_id: Option<String>,
) -> Result<(), ClaudeCodeError>
pub async fn session_update_head( &self, session_id: &ClaudeCodeId, new_head: NodeId, claude_session_id: Option<String>, ) -> Result<(), ClaudeCodeError>
Update session’s canonical head and optionally the Claude session ID
Sourcepub async fn session_update(
&self,
session_id: &ClaudeCodeId,
name: Option<String>,
model: Option<Model>,
system_prompt: Option<Option<String>>,
mcp_config: Option<Value>,
metadata: Option<Value>,
) -> Result<(), ClaudeCodeError>
pub async fn session_update( &self, session_id: &ClaudeCodeId, name: Option<String>, model: Option<Model>, system_prompt: Option<Option<String>>, mcp_config: Option<Value>, metadata: Option<Value>, ) -> Result<(), ClaudeCodeError>
Update session configuration
Sourcepub async fn session_delete(
&self,
session_id: &ClaudeCodeId,
) -> Result<(), ClaudeCodeError>
pub async fn session_delete( &self, session_id: &ClaudeCodeId, ) -> Result<(), ClaudeCodeError>
Delete a session (does not delete the arbor tree)
Sourcepub async fn message_create(
&self,
session_id: &ClaudeCodeId,
role: MessageRole,
content: String,
model_id: Option<String>,
input_tokens: Option<i64>,
output_tokens: Option<i64>,
cost_usd: Option<f64>,
) -> Result<Message, ClaudeCodeError>
pub async fn message_create( &self, session_id: &ClaudeCodeId, role: MessageRole, content: String, model_id: Option<String>, input_tokens: Option<i64>, output_tokens: Option<i64>, cost_usd: Option<f64>, ) -> Result<Message, ClaudeCodeError>
Create a message and return it
Sourcepub async fn message_create_ephemeral(
&self,
session_id: &ClaudeCodeId,
role: MessageRole,
content: String,
model_id: Option<String>,
input_tokens: Option<i64>,
output_tokens: Option<i64>,
cost_usd: Option<f64>,
) -> Result<Message, ClaudeCodeError>
pub async fn message_create_ephemeral( &self, session_id: &ClaudeCodeId, role: MessageRole, content: String, model_id: Option<String>, input_tokens: Option<i64>, output_tokens: Option<i64>, cost_usd: Option<f64>, ) -> Result<Message, ClaudeCodeError>
Create an ephemeral message (marked for deletion) and return it
Sourcepub async fn message_get(
&self,
message_id: &MessageId,
) -> Result<Message, ClaudeCodeError>
pub async fn message_get( &self, message_id: &MessageId, ) -> Result<Message, ClaudeCodeError>
Get a message by ID
Sourcepub async fn resolve_message_handle(
&self,
identifier: &str,
) -> Result<Message, ClaudeCodeError>
pub async fn resolve_message_handle( &self, identifier: &str, ) -> Result<Message, ClaudeCodeError>
Resolve a message handle identifier to a Message Handle format: “msg-{message_id}:{role}:{name}”
Sourcepub fn message_to_handle(message: &Message, name: &str) -> Handle
pub fn message_to_handle(message: &Message, name: &str) -> Handle
Create a handle for a message
Format: {plugin_id}@1.0.0::chat:msg-{id}:{role}:{name}
Uses ClaudeCodeHandle enum for type-safe handle creation.
Sourcepub async fn unknown_event_store(
&self,
session_id: Option<&ClaudeCodeId>,
event_type: &str,
data: &Value,
) -> Result<String, ClaudeCodeError>
pub async fn unknown_event_store( &self, session_id: Option<&ClaudeCodeId>, event_type: &str, data: &Value, ) -> Result<String, ClaudeCodeError>
Store an unknown event and return its ID (handle)
Sourcepub async fn unknown_event_get(
&self,
id: &str,
) -> Result<(String, Value), ClaudeCodeError>
pub async fn unknown_event_get( &self, id: &str, ) -> Result<(String, Value), ClaudeCodeError>
Retrieve an unknown event by ID
Sourcepub async fn unknown_events_by_type(
&self,
event_type: &str,
) -> Result<Vec<(String, Value)>, ClaudeCodeError>
pub async fn unknown_events_by_type( &self, event_type: &str, ) -> Result<Vec<(String, Value)>, ClaudeCodeError>
List unknown events by type (for analysis/debugging)
Sourcepub async fn stream_create(
&self,
session_id: ClaudeCodeId,
) -> Result<StreamId, ClaudeCodeError>
pub async fn stream_create( &self, session_id: ClaudeCodeId, ) -> Result<StreamId, ClaudeCodeError>
Create a new stream buffer for async chat
Sourcepub async fn stream_set_user_position(
&self,
stream_id: &StreamId,
position: Position,
) -> Result<(), ClaudeCodeError>
pub async fn stream_set_user_position( &self, stream_id: &StreamId, position: Position, ) -> Result<(), ClaudeCodeError>
Set the user position for a stream (called after user message is created)
Sourcepub async fn stream_push_event(
&self,
stream_id: &StreamId,
event: ChatEvent,
) -> Result<u64, ClaudeCodeError>
pub async fn stream_push_event( &self, stream_id: &StreamId, event: ChatEvent, ) -> Result<u64, ClaudeCodeError>
Push an event to a stream buffer
Sourcepub async fn stream_set_status(
&self,
stream_id: &StreamId,
status: StreamStatus,
error: Option<String>,
) -> Result<(), ClaudeCodeError>
pub async fn stream_set_status( &self, stream_id: &StreamId, status: StreamStatus, error: Option<String>, ) -> Result<(), ClaudeCodeError>
Update stream status
Sourcepub async fn stream_get_info(
&self,
stream_id: &StreamId,
) -> Result<StreamInfo, ClaudeCodeError>
pub async fn stream_get_info( &self, stream_id: &StreamId, ) -> Result<StreamInfo, ClaudeCodeError>
Get stream info
Sourcepub async fn stream_poll(
&self,
stream_id: &StreamId,
from_seq: Option<u64>,
limit: Option<usize>,
) -> Result<(StreamInfo, Vec<BufferedEvent>), ClaudeCodeError>
pub async fn stream_poll( &self, stream_id: &StreamId, from_seq: Option<u64>, limit: Option<usize>, ) -> Result<(StreamInfo, Vec<BufferedEvent>), ClaudeCodeError>
Poll events from a stream
Returns events starting from from_seq up to limit events
Sourcepub async fn stream_list(&self) -> Vec<StreamInfo>
pub async fn stream_list(&self) -> Vec<StreamInfo>
List all active streams
Sourcepub async fn stream_list_for_session(
&self,
session_id: &ClaudeCodeId,
) -> Vec<StreamInfo>
pub async fn stream_list_for_session( &self, session_id: &ClaudeCodeId, ) -> Vec<StreamInfo>
List active streams for a session
Sourcepub async fn stream_cleanup(&self, stream_id: &StreamId) -> Option<StreamInfo>
pub async fn stream_cleanup(&self, stream_id: &StreamId) -> Option<StreamInfo>
Remove a completed/failed stream from memory Returns the final stream info if found
Sourcepub async fn stream_exists(&self, stream_id: &StreamId) -> bool
pub async fn stream_exists(&self, stream_id: &StreamId) -> bool
Check if a stream exists
Sourcepub async fn render_messages(
&self,
tree_id: &TreeId,
start: &NodeId,
end: &NodeId,
) -> Result<Vec<ClaudeMessage>, ClaudeCodeError>
pub async fn render_messages( &self, tree_id: &TreeId, start: &NodeId, end: &NodeId, ) -> Result<Vec<ClaudeMessage>, ClaudeCodeError>
Render arbor tree path into Claude API messages format
Walks from start to end node, parsing NodeEvent JSON from each node, and groups into Claude messages array.
§Algorithm
- Get path from start to end via arbor
- Parse each node’s content as NodeEvent
- Group into messages based on event type
- Return messages array
Auto Trait Implementations§
impl !Freeze for ClaudeCodeStorage
impl !RefUnwindSafe for ClaudeCodeStorage
impl Send for ClaudeCodeStorage
impl Sync for ClaudeCodeStorage
impl Unpin for ClaudeCodeStorage
impl UnsafeUnpin for ClaudeCodeStorage
impl !UnwindSafe for ClaudeCodeStorage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more