MCPcopy Create free account
hub / github.com/browserbase/stagehand / SessionStore

Interface SessionStore

packages/server-v3/src/lib/SessionStore.ts:100–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98 * This enables stateless pod architectures where any pod can handle any request.
99 */
100export interface SessionStore {
101 /**
102 * Start a new session.
103 *
104 * This is the main entry point for session creation. Implementations can:
105 * - Create platform-specific resources (e.g., Browserbase session)
106 * - Persist session config to storage
107 * - Check feature flags for availability
108 *
109 * @param params - Session configuration
110 * @returns Session ID and availability status
111 */
112 startSession(params: CreateSessionParams): Promise<SessionStartResult>;
113
114 /**
115 * End a session and cleanup all resources.
116 *
117 * This is the main entry point for session cleanup. Implementations can:
118 * - Close platform-specific resources (e.g., Browserbase session)
119 * - Evict V3 instance from cache
120 * - Update session status in storage
121 *
122 * @param sessionId - The session identifier
123 */
124 endSession(sessionId: string): Promise<void>;
125
126 /**
127 * Check if a session exists.
128 * @param sessionId - The session identifier
129 * @returns true if the session exists
130 */
131 hasSession(sessionId: string): Promise<boolean>;
132
133 /**
134 * Get or create a V3 instance for a session.
135 *
136 * This method handles:
137 * - Checking the cache for an existing V3 instance
138 * - On cache miss: loading config, creating V3, caching it
139 * - Updating the logger reference for streaming
140 *
141 * @param sessionId - The session identifier
142 * @param ctx - Request-time context containing values from headers
143 * @returns The V3 instance ready for use
144 * @throws Error if session not found
145 */
146 getOrCreateStagehand(sessionId: string, ctx: RequestContext): Promise<V3>;
147
148 /**
149 * Create a new session with the given parameters.
150 * Lower-level than startSession - just stores the config.
151 * @param sessionId - The session identifier
152 * @param params - Session configuration to persist
153 */
154 createSession(sessionId: string, params: CreateSessionParams): Promise<void>;
155
156 /**
157 * Delete a session from cache and close V3 instance.

Callers 15

start.tsFile · 0.65
start.tsFile · 0.65
end.tsFile · 0.65
extract.tsFile · 0.65
navigate.tsFile · 0.65
agentExecute.tsFile · 0.65
act.tsFile · 0.65
observe.tsFile · 0.65
end.tsFile · 0.65
start.tsFile · 0.65
createStreamingResponseFunction · 0.65
routeRequestFunction · 0.65

Implementers 1

InMemorySessionStorepackages/server-v3/src/lib/InMemorySes

Calls

no outgoing calls

Tested by

no test coverage detected