MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / serializeSession

Function serializeSession

server/src/training-agent/state.ts:229–241  ·  view source on GitHub ↗

* Serialize a SessionState via the SDK's `structuredSerialize` (tagged * envelopes for Map/Date). Returns a JSON-safe Record.

(session: SessionState, key?: string)

Source from the content-addressed store, hash-verified

227 * envelopes for Map/Date). Returns a JSON-safe Record.
228 */
229function serializeSession(session: SessionState, key?: string): Record<string, unknown> {
230 const persisted = {
231 ...session,
232 ...(key && { __sessionKey: key }),
233 // `products` is deterministic from the catalog — dropped from persistence
234 // so callers re-derive on the next request. Only `proposals` (session-
235 // specific drafts from refine workflows) ride along.
236 lastGetProductsContext: session.lastGetProductsContext?.proposals?.length
237 ? { proposals: session.lastGetProductsContext.proposals }
238 : undefined,
239 };
240 return structuredSerialize(persisted) as Record<string, unknown>;
241}
242
243/**
244 * Hydrate a stored doc back into a SessionState.

Callers 3

flushDirtySessionsFunction · 0.85
getSessionFunction · 0.85
findSessionMatchingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected