pub struct SessionStartHandler {
context_builder: Option<ContextBuilderService>,
max_context_tokens: usize,
guidance_level: GuidanceLevel,
context_timeout_ms: u64,
}Expand description
Handles SessionStart hook events.
Injects relevant context at the start of a Claude Code session.
Fields§
§context_builder: Option<ContextBuilderService>Context builder service.
max_context_tokens: usizeMaximum tokens for context.
guidance_level: GuidanceLevelGuidance level for context injection.
context_timeout_ms: u64Timeout for context loading in milliseconds (PERF-M3).
Implementations§
Source§impl SessionStartHandler
impl SessionStartHandler
Sourcepub fn with_context_builder(self, builder: ContextBuilderService) -> Self
pub fn with_context_builder(self, builder: ContextBuilderService) -> Self
Sets the context builder service.
Sourcepub const fn with_max_tokens(self, tokens: usize) -> Self
pub const fn with_max_tokens(self, tokens: usize) -> Self
Sets the maximum context tokens.
Sourcepub const fn with_guidance_level(self, level: GuidanceLevel) -> Self
pub const fn with_guidance_level(self, level: GuidanceLevel) -> Self
Sets the guidance level.
Sourcepub const fn with_context_timeout_ms(self, timeout_ms: u64) -> Self
pub const fn with_context_timeout_ms(self, timeout_ms: u64) -> Self
Sets the context loading timeout in milliseconds (PERF-M3).
If context loading takes longer than this timeout, the handler will return minimal context instead of blocking session start.
Sourcefn build_context_from_builder(
&self,
max_tokens: usize,
start: Instant,
deadline: Duration,
) -> Result<(Option<String>, Option<MemoryStatistics>, usize)>
fn build_context_from_builder( &self, max_tokens: usize, start: Instant, deadline: Duration, ) -> Result<(Option<String>, Option<MemoryStatistics>, usize)>
Helper to build context from the builder service (PERF-M3).
Returns a tuple of (context string, statistics, memory count).
Sourcefn add_guidance(&self, context_parts: &mut Vec<String>)
fn add_guidance(&self, context_parts: &mut Vec<String>)
Helper to add guidance based on level (PERF-M3).
Sourcefn build_session_context(
&self,
session_id: &str,
cwd: &str,
) -> Result<SessionContext>
fn build_session_context( &self, session_id: &str, cwd: &str, ) -> Result<SessionContext>
Builds context for the session with inline timeout checking (PERF-M3).
Monitors elapsed time and returns early with minimal context if approaching the timeout. This provides timeout safety without requiring thread spawning.
Sourcefn format_statistics(stats: &MemoryStatistics) -> String
fn format_statistics(stats: &MemoryStatistics) -> String
Formats memory statistics as single-line XML for context injection.
Sourcefn standard_guidance() -> String
fn standard_guidance() -> String
Returns standard guidance as single-line XML.
Sourcefn detailed_guidance() -> String
fn detailed_guidance() -> String
Returns detailed guidance as single-line XML.
Sourcefn is_first_session(&self) -> bool
fn is_first_session(&self) -> bool
Checks if this is the first session (no user memories).
Trait Implementations§
Source§impl Default for SessionStartHandler
impl Default for SessionStartHandler
Source§impl HookHandler for SessionStartHandler
impl HookHandler for SessionStartHandler
Auto Trait Implementations§
impl !Freeze for SessionStartHandler
impl !RefUnwindSafe for SessionStartHandler
impl Send for SessionStartHandler
impl Sync for SessionStartHandler
impl Unpin for SessionStartHandler
impl !UnwindSafe for SessionStartHandler
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].