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 })Extends
Section titled “Extends”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
Overrides
Section titled “Overrides”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
Overrides
Section titled “Overrides”Methods
Section titled “Methods”getTools()
Section titled “getTools()”getTools(): Tool[];Defined in: src/plugins/plugin.ts:82
Returns tools provided by this plugin for auto-registration. Override to provide plugin-specific tools.
Returns
Section titled “Returns”Tool[]
Array of tools to register with the agent
Inherited from
Section titled “Inherited from”initAgent()
Section titled “initAgent()”initAgent(agent): void;Defined in: src/session/session-manager.ts:79
Initializes the plugin by registering lifecycle hook callbacks.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
agent | AgentData |
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”saveSnapshot()
Section titled “saveSnapshot()”saveSnapshot(params): Promise<void>;Defined in: src/session/session-manager.ts:102
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:114
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:119
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>