Function: getOrCreateSession()
Makaio Framework / services-core / getOrCreateSession
Function: getOrCreateSession()
Section titled “Function: 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.
Parameters
Section titled “Parameters”Makaio bus instance
providedSessionId
Section titled “providedSessionId”string
Session ID to look up
_sessionContext?
Section titled “_sessionContext?”Optional session context (scope fields removed in W1-A)
extractedContext?
Section titled “extractedContext?”unknown = ...
Structured context from compression (if hasCompression=true).
hasCompression?
Section titled “hasCompression?”boolean = ...
Whether compression is active (extractedContext present). If true, Agent should use fresh mode with compressed context.
hasConnectorSwap?
Section titled “hasConnectorSwap?”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.
hasNewTransforms?
Section titled “hasNewTransforms?”boolean = ...
Whether transforms have been applied since last turn. If true, Agent should use fresh mode (history changed).
isFirstTurn?
Section titled “isFirstTurn?”boolean = ...
Whether this is the first turn in the session. If true, no native history exists yet.
messageHistory?
Section titled “messageHistory?”object[] = ...
Curated message history assembled via getFullConversation(). Only used if Agent decides to inject (fresh mode).
turnContext?
Section titled “turnContext?”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().
originWindowId?
Section titled “originWindowId?”string
Window ID that initiated the session creation
Returns
Section titled “Returns”Promise<{ session: IMakaioSession; sessionId: string; }>
Session ID and session object