Skip to content

reviveSession

function reviveSession(raw): Session;

Restores a Session from its serialized form.

Revives Date instances nested in:

  • top-level createdAt / updatedAt
  • handoffHistory[].timestamp
  • metadata.createdAt / metadata.lastActiveAt
  • metadata.handoffHistory[].timestamp
  • agentStates[*].lastActive

Adapter packages (postgres-store, redis-store, upstash-store, etc.) must import this instead of re-implementing their own revival logic.

The input may be a JSON string (e.g. from a Redis GET) or an already-parsed object (e.g. a JSONB column from Postgres). Other shapes pass through untouched in the key fields — callers are expected to have validated shape.

Parameter Type

raw

unknown

Session