Skip to content

Interface: SessionHookContext

Makaio Framework


Makaio Framework / hooks / SessionHookContext

Defined in: ../../../packages/hooks/src/types/hook-context.ts:70

Session enrichment props shared across session-aware hooks.

Hooks that operate within a session context (PreUserMessage, PostTurn, etc.) can extend this interface to get access to session and history data.

Enrichment is optional - fields may be undefined if sessionId wasn’t available or if the lookup failed (graceful degradation).

Host code augments this interface via declaration merging to add host-owned fields (e.g., project, worktree) contributed by a SessionSubjects.enrichContext handler.

[key: string]: unknown

readonly bus: IMakaioBus

Defined in: ../../../packages/hooks/src/types/hook-context.ts:76

Bus instance for making requests


readonly contextExtensions: Record<string, unknown>

Defined in: ../../../packages/hooks/src/types/hook-context.ts:82

Arbitrary context extensions contributed by the host-registered SessionSubjects.enrichContext handler. Framework spreads these onto the context object at hook-call time. Empty object in OSS mode.


readonly recentHistory: object[]

Defined in: ../../../packages/hooks/src/types/hook-context.ts:74

Recent turn history, oldest first (up to 10 turns)

optional completedAt?: number

Turn completion timestamp (Unix ms)

optional error?: string

Error message if status is ‘error’

sessionId: string

Session this turn belongs to

startedAt: number

Turn start timestamp (Unix ms)

status: "error" | "completed" | "active" = TurnStatusSchema

Turn status

turnId: string

Unique turn identifier

turnNumber: number

Monotonic per-session ordinal (1-based), assigned by turn storage at creation.

optional usage?: object

Aggregated usage/cost for this turn. Populated on turn completion.

optional byAgent?: Record<string, { cost?: number; inputTokens: number; outputTokens: number; }>

Optional per-agent breakdown (for multi-agent turns)

total: object = UsageMetricsSchema

Total aggregated usage across all agents

optional cost?: number

Computed cost in USD (optional, requires pricing data)

inputTokens: number

Input tokens consumed

outputTokens: number

Output tokens generated


readonly optional session?: IMakaioSession

Defined in: ../../../packages/hooks/src/types/hook-context.ts:72

Session object (populated when sessionId is available)