SessionManager
Defined in: src/session/session-manager.ts:57
Manages session persistence for agents, enabling conversation state to be saved and restored across invocations using pluggable storage backends.
Example
Section titled “Example”import { SessionManager, FileStorage } from '@strands-agents/sdk'
const session = new SessionManager({ sessionId: 'my-session', storage: { snapshot: new FileStorage() },})const agent = new Agent({ sessionManager: session })Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SessionManager(config): SessionManager;Defined in: src/session/session-manager.ts:70
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
config | SessionManagerConfig |
Returns
Section titled “Returns”SessionManager
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get name(): string;Defined in: src/session/session-manager.ts:66
Unique identifier for this plugin.
Returns
Section titled “Returns”string
A stable string identifier for the plugin. Used for logging, duplicate detection, and plugin management.
For strands-vended plugins, names should be prefixed with strands:.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”initAgent()
Section titled “initAgent()”initAgent(agent): void;Defined in: src/session/session-manager.ts:78
Initializes the plugin by registering lifecycle hook callbacks.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
agent | AgentData |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”saveSnapshot()
Section titled “saveSnapshot()”saveSnapshot(params): Promise<void>;Defined in: src/session/session-manager.ts:101
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
params | { target: Agent; isLatest: boolean; } |
params.target | Agent |
params.isLatest | boolean |
Returns
Section titled “Returns”Promise<void>
deleteSession()
Section titled “deleteSession()”deleteSession(): Promise<void>;Defined in: src/session/session-manager.ts:113
Deletes all snapshots and manifests for this session from storage.
Returns
Section titled “Returns”Promise<void>
restoreSnapshot()
Section titled “restoreSnapshot()”restoreSnapshot(params): Promise<boolean>;Defined in: src/session/session-manager.ts:118
Loads a snapshot from storage and restores it into the target agent. Returns false if no snapshot exists.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
params | { target: Agent; snapshotId?: string; } |
params.target | Agent |
params.snapshotId? | string |
Returns
Section titled “Returns”Promise<boolean>