sessions / Exports
sessions
Table of contents
References
Enumerations
Classes
- ChatInstanceImpl
- SessionOperationError
- StateTransitionError
- ValidationError
- EnhancedConversationHistoryImpl
- SimpleConversationHistory
- ConversationServiceImpl
- MultiProviderAdapterManager
- BasicSessionStore
- SessionManagerImpl
- SessionImpl
- SystemMessageManagerImpl
- LoggerFactory
- MetricsCollectorFactory
- SimpleLoggerImpl
- SimpleMetricsCollector
- SimplePromptTemplate
Interfaces
- ContextManager
- ProviderConfig
- ProviderManager
- ConversationHistoryInterface
- ConversationHistoryOptions
- StateTransition
- TransitionResult
- ChatMetadata
- ChatInstance
- ChatStats
- SessionConfig
- SessionInfo
- ChatConfig
- ChatInfo
- SessionManagerConfig
- SessionManager
- SessionManagerStats
- SessionMetadata
- Session
- SessionStats
Type Aliases
Variables
Functions
- getErrorMessage
- createSessionError
- isValidTransition
- attemptTransition
- getPossibleTransitions
- isFinalState
- isActiveState
- allowsModifications
- getStateDescription
- validateTransitionChain
- generateId
- generateDefaultSessionName
- validateSessionConfig
- mergeWithDefaults
- createInitialMetadata
- updateTimestamps
- calculateSessionStats
- findNextActiveChat
- wouldExceedChatLimit
- formatUptime
- isSessionModifiable
- isSessionActive
References
ConversationHistory
Renames and re-exports SimpleConversationHistory
Context
Renames and re-exports AIProvider
ModelResponse
Renames and re-exports AIProvider
StreamingResponseChunk
Renames and re-exports AIProvider
Type Aliases
MessageContent
Ƭ MessageContent: string
| { [key: string]
: any
; text?
: string
; image?
: string
; file?
: string
}
Defined in
packages/sessions/src/types/chat.ts:16
Variables
AIProvider
• AIProvider: any
ValidationConstraints
• Const
ValidationConstraints: Object
Common validation constraints
Type declaration
Name | Type |
---|---|
required | (field : string ) => string |
minLength | (field : string , min : number ) => string |
maxLength | (field : string , max : number ) => string |
positive | (field : string ) => string |
range | (field : string , min : number , max : number ) => string |
Defined in
packages/sessions/src/constants/error-messages.ts:133
DEFAULT_SESSION_CONFIG
• Const
DEFAULT_SESSION_CONFIG: DefaultSessionConfig
Default session configuration
Defined in
packages/sessions/src/utils/session-utils.ts:30
Functions
getErrorMessage
▸ getErrorMessage(key
, params?
): string
Get formatted error message
Parameters
Name | Type | Description |
---|---|---|
key | SessionErrorKey | Error message key |
params | Record <string , any > | Message parameters for substitution |
Returns
string
Formatted error message
Defined in
packages/sessions/src/constants/error-messages.ts:47
createSessionError
▸ createSessionError(key
, params?
): Error
Create session error with formatted message
Parameters
Name | Type | Description |
---|---|---|
key | SessionErrorKey | Error message key |
params | Record <string , any > | Message parameters |
Returns
Error
Error instance
Defined in
packages/sessions/src/constants/error-messages.ts:65
isValidTransition
▸ isValidTransition(currentState
, targetState
, action
, context?
): boolean
Check if a state transition is valid
Parameters
Name | Type | Description |
---|---|---|
currentState | SessionState | Current session state |
targetState | SessionState | Target session state |
action | string | Action being performed |
context? | any | Optional context for condition checking |
Returns
boolean
True if transition is valid
Defined in
packages/sessions/src/state/session-state-machine.ts:61
attemptTransition
▸ attemptTransition(currentState
, targetState
, action
, context?
): TransitionResult
Attempt to transition to a new state
Parameters
Name | Type | Description |
---|---|---|
currentState | SessionState | Current session state |
targetState | SessionState | Target session state |
action | string | Action being performed |
context? | any | Optional context for condition checking |
Returns
Transition result
Defined in
packages/sessions/src/state/session-state-machine.ts:99
getPossibleTransitions
▸ getPossibleTransitions(currentState
): { state
: SessionState
; action
: string
}[]
Get all possible next states from current state
Parameters
Name | Type | Description |
---|---|---|
currentState | SessionState | Current session state |
Returns
{ state
: SessionState
; action
: string
}[]
Array of possible next states with their actions
Defined in
packages/sessions/src/state/session-state-machine.ts:124
isFinalState
▸ isFinalState(state
): boolean
Check if a state is a final state (no transitions possible)
Parameters
Name | Type | Description |
---|---|---|
state | SessionState | State to check |
Returns
boolean
True if state is final
Defined in
packages/sessions/src/state/session-state-machine.ts:136
isActiveState
▸ isActiveState(state
): boolean
Check if a state allows active operations
Parameters
Name | Type | Description |
---|---|---|
state | SessionState | State to check |
Returns
boolean
True if state allows active operations
Defined in
packages/sessions/src/state/session-state-machine.ts:146
allowsModifications
▸ allowsModifications(state
): boolean
Check if a state allows modifications
Parameters
Name | Type | Description |
---|---|---|
state | SessionState | State to check |
Returns
boolean
True if state allows modifications
Defined in
packages/sessions/src/state/session-state-machine.ts:156
getStateDescription
▸ getStateDescription(state
): string
Get human-readable state description
Parameters
Name | Type | Description |
---|---|---|
state | SessionState | Session state |
Returns
string
Human-readable description
Defined in
packages/sessions/src/state/session-state-machine.ts:166
validateTransitionChain
▸ validateTransitionChain(transitions
): Object
Validate state transition chain
Parameters
Name | Type | Description |
---|---|---|
transitions | { from : SessionState ; to : SessionState ; action : string }[] | Array of state transitions to validate |
Returns
Object
Validation result with any errors
Name | Type |
---|---|
valid | boolean |
errors | string [] |
Defined in
packages/sessions/src/state/session-state-machine.ts:183
generateId
▸ generateId(): string
Returns
string
Defined in
packages/sessions/src/utils/id.ts:3
generateDefaultSessionName
▸ generateDefaultSessionName(timestamp?
): string
Generate default session name based on timestamp
Parameters
Name | Type | Description |
---|---|---|
timestamp? | Date | Optional timestamp (defaults to current time) |
Returns
string
Generated session name
Defined in
packages/sessions/src/utils/session-utils.ts:45
validateSessionConfig
▸ validateSessionConfig(config
): Object
Validate session configuration
Parameters
Name | Type | Description |
---|---|---|
config | SessionConfig | Configuration to validate |
Returns
Object
Validation result
Name | Type |
---|---|
valid | boolean |
errors | ValidationError [] |
Defined in
packages/sessions/src/utils/session-utils.ts:56
mergeWithDefaults
▸ mergeWithDefaults(config
): DefaultSessionConfig
Merge session configuration with defaults
Parameters
Name | Type | Description |
---|---|---|
config | SessionConfig | User provided configuration |
Returns
DefaultSessionConfig
Merged configuration with all required fields
Defined in
packages/sessions/src/utils/session-utils.ts:116
createInitialMetadata
▸ createInitialMetadata(sessionId
, userId
, config
): SessionMetadata
Create initial session metadata
Parameters
Name | Type | Description |
---|---|---|
sessionId | string | Unique session ID |
userId | string | User ID |
config | DefaultSessionConfig | Session configuration |
Returns
Initial metadata
Defined in
packages/sessions/src/utils/session-utils.ts:135
updateTimestamps
▸ updateTimestamps(metadata
): SessionMetadata
Update metadata timestamps
Parameters
Name | Type | Description |
---|---|---|
metadata | SessionMetadata | Current metadata |
Returns
Updated metadata with new timestamps
Defined in
packages/sessions/src/utils/session-utils.ts:162
calculateSessionStats
▸ calculateSessionStats(metadata
, chats
, startTime
): SessionStats
Calculate session statistics
Parameters
Name | Type | Description |
---|---|---|
metadata | SessionMetadata | Session metadata |
chats | ChatInstance [] | All chat instances |
startTime | Date | Session start time |
Returns
Calculated statistics
Defined in
packages/sessions/src/utils/session-utils.ts:179
findNextActiveChat
▸ findNextActiveChat(chats
, removedChatId
, currentActiveChatId?
): string
| undefined
Find next active chat when current one is removed
Parameters
Name | Type | Description |
---|---|---|
chats | Map <string , ChatInstance > | Map of chat instances |
removedChatId | string | ID of chat being removed |
currentActiveChatId? | string | Current active chat ID |
Returns
string
| undefined
ID of next chat to activate, or undefined if none
Defined in
packages/sessions/src/utils/session-utils.ts:209
wouldExceedChatLimit
▸ wouldExceedChatLimit(currentCount
, maxChats
): boolean
Check if chat limit would be exceeded
Parameters
Name | Type | Description |
---|---|---|
currentCount | number | Current number of chats |
maxChats | number | Maximum allowed chats |
Returns
boolean
True if limit would be exceeded
Defined in
packages/sessions/src/utils/session-utils.ts:233
formatUptime
▸ formatUptime(uptimeMs
): string
Format uptime duration in human-readable format
Parameters
Name | Type | Description |
---|---|---|
uptimeMs | number | Uptime in milliseconds |
Returns
string
Formatted duration string
Defined in
packages/sessions/src/utils/session-utils.ts:243
isSessionModifiable
▸ isSessionModifiable(state
): boolean
Check if session is in a modifiable state
Parameters
Name | Type | Description |
---|---|---|
state | SessionState | Current session state |
Returns
boolean
True if session allows modifications
Defined in
packages/sessions/src/utils/session-utils.ts:266
isSessionActive
▸ isSessionActive(state
): boolean
Check if session is active and ready for operations
Parameters
Name | Type | Description |
---|---|---|
state | SessionState | Current session state |
Returns
boolean
True if session is active