Skip to content

Function: getOrCreateSession()

Makaio Framework


Makaio Framework / services-core / getOrCreateSession

getOrCreateSession(bus, providedSessionId, _sessionContext?, originWindowId?): Promise<{ session: IMakaioSession; sessionId: string; }>

Defined in: ../../../packages/services/core/src/session/utils/session-utils.ts:13

Get existing session or create a new one.

IMakaioBus

Makaio bus instance

string

Session ID to look up

Optional session context (scope fields removed in W1-A)

unknown = ...

Structured context from compression (if hasCompression=true).

boolean = ...

Whether compression is active (extractedContext present). If true, Agent should use fresh mode with compressed context.

boolean = ...

Whether a connector swap occurred before this message (e.g., cwd/model change). If true, native resume is infeasible and adapters should use fresh mode.

boolean = ...

Whether transforms have been applied since last turn. If true, Agent should use fresh mode (history changed).

boolean = ...

Whether this is the first turn in the session. If true, no native history exists yet.

object[] = ...

Curated message history assembled via getFullConversation(). Only used if Agent decides to inject (fresh mode).

Record<string, JsonValue> = ...

Turn-scoped context assembled by PreUserMessage hooks and the orchestrator. Keys are plugin-defined (e.g., ‘skillCatalog’, ‘skills’, ‘predictedTools’). Adapters consume this to prepend context blocks.

Constrained to JSON-safe types to ensure serialization succeeds.

ADAPTER CONTRACT: Every adapter MUST materialize turnContext into the LLM-facing message using serializeTurnContext().

string

Window ID that initiated the session creation

Promise<{ session: IMakaioSession; sessionId: string; }>

Session ID and session object