Class: SessionOrchestrator
Makaio Framework / services-core / SessionOrchestrator
Class: SessionOrchestrator
Section titled “Class: SessionOrchestrator”Defined in: ../../../packages/services/core/src/session/session-orchestrator.ts:81
Slim framework session orchestrator.
Composes with SessionTurnManager (turn lifecycle, usage accumulation,
completion), AdapterRegistry (adapterName to adapterId mapping), and the
adapter-subsystem reverse lookup for canonical adapterId to adapterName
validation when callers select a direct adapter instance.
Registers the core session.sendMessage handler only:
- Get or create session (via
getOrCreateSession) - Start agent if session has no agents — resolves the canonical
adapterNamefrom direct selections, usesadapterIddirectly when provided, otherwise resolves it viaAdapterRegistry, then calls bareAdapterSubjects.startAgent - Resolve target agents (via
resolveTargetAgents) - Verify agent liveness and build recovery context for dead agents
(requestOptional
AdapterSubjects.getAgent+buildRecoveryContext) - Get or create turn (via
SessionTurnManager) - Generate message ID and store user message + routing records (requestOptional, fire-and-forget)
- Emit
session.turn.started+session.user_message.sent - Route to agents (via
routeToAgentsCore, single shared context) - Return result with
messageId,turnId,sessionId
Host-specific features (personas, MCP, execution targets, container spawn, connector swap, CWD/model enforcement, fork context, TurnContextEnricher) are handled by a host-provided orchestrator.
Example
Section titled “Example”const orchestrator = new SessionOrchestrator(MakaioBus, 'machine-id');
const { messageId, turnId, sessionId } = await MakaioBus.request( SessionSubjects.sendMessage, { sessionId: crypto.randomUUID(), adapterName: 'openai-node', message: 'Hello!' },);Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SessionOrchestrator(
bus?,_machineId):SessionOrchestrator
Defined in: ../../../packages/services/core/src/session/session-orchestrator.ts:92
Parameters
Section titled “Parameters”IMakaioBus = MakaioBus
Event bus used for handler registration and message routing
_machineId
Section titled “_machineId”string
Machine identifier (reserved for future routing use)
Returns
Section titled “Returns”SessionOrchestrator
Methods
Section titled “Methods”destroy()
Section titled “destroy()”destroy():
void
Defined in: ../../../packages/services/core/src/session/session-orchestrator.ts:368
Stop the orchestrator and clean up all subscriptions and composition utilities.
Returns
Section titled “Returns”void