Skip to content

Function: createAndLinkImportedSession()

Makaio Framework


Makaio Framework / services-core / createAndLinkImportedSession

createAndLinkImportedSession(params): Promise<CreateAndLinkResult>

Defined in: ../../../packages/services/core/src/session/adapter-sessions/handlers.ts:273

Unified helper that creates and links a Makaio session for an adapter session.

Consolidates both the discovery path (registerSessionDiscoveredHandler) and the import path into a single authoritative flow:

  1. Early-exit if the adapter session is already linked (idempotent).
  2. Eagerly resolve parentSessionId/rootSessionId via resolveLineage.
  3. Create the Makaio session record via SessionStorageSubjects.set with ifAbsent.
  4. Link, emit SessionSubjects.created, and clean up on failure via linkAndEmit.

CreateAndLinkParams

Parameters for the unified session creation/linking flow.

Promise<CreateAndLinkResult>

The session ID and whether a new record was created.