Interface: PostTurnContext
Makaio Framework / hooks / PostTurnContext
Interface: PostTurnContext
Section titled “Interface: PostTurnContext”Defined in: ../../../packages/hooks/src/types/hook-context.ts:179
PostTurn context with turn completion data.
Intercepts: SessionSubjects.turn.completed event
Provides access to turn outcome (success/error) and identifiers. Useful for semantic extraction, analytics, and post-processing.
Extends SessionHookContext for optional session enrichment (session, recentHistory, project) when available.
Extends
Section titled “Extends”Indexable
Section titled “Indexable”[
key:string]:unknown
Properties
Section titled “Properties”
readonlybus:IMakaioBus
Defined in: ../../../packages/hooks/src/types/hook-context.ts:76
Bus instance for making requests
Inherited from
Section titled “Inherited from”contextExtensions
Section titled “contextExtensions”
readonlycontextExtensions: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.
Inherited from
Section titled “Inherited from”SessionHookContext.contextExtensions
correlationId?
Section titled “correlationId?”
readonlyoptionalcorrelationId?:string
Defined in: ../../../packages/hooks/src/types/hook-context.ts:194
Correlation identifier for tracing
error?
Section titled “error?”
readonlyoptionalerror?:string
Defined in: ../../../packages/hooks/src/types/hook-context.ts:188
Error message if any agent failed
hookEvent
Section titled “hookEvent”
readonlyhookEvent:"PostTurn"
Defined in: ../../../packages/hooks/src/types/hook-context.ts:180
messageId
Section titled “messageId”
readonlymessageId:string
Defined in: ../../../packages/hooks/src/types/hook-context.ts:192
Message identifier for correlation
payload
Section titled “payload”
readonlypayload:object
Defined in: ../../../packages/hooks/src/types/hook-context.ts:190
Full turn.completed payload for advanced use
error?
Section titled “error?”
optionalerror?:string
Error message if any agent failed
initiator?
Section titled “initiator?”
optionalinitiator?:object
Origin of the turn (for loop prevention and audit)
initiator.source
Section titled “initiator.source”source:
"user"|"extension"|"system"
Origin category
initiator.sourceId?
Section titled “initiator.sourceId?”
optionalsourceId?:string
Identifier for the specific origin.
Examples: 'routine:validation', 'loop', 'subagent:xyz'.
sessionId
Section titled “sessionId”sessionId:
string
Makaio session ID
success
Section titled “success”success:
boolean
Whether all agents completed successfully
turnId
Section titled “turnId”turnId:
string
Turn identifier (UUID)
turnNumber
Section titled “turnNumber”turnNumber:
number
Monotonic per-session ordinal (1-based).
recentHistory
Section titled “recentHistory”
readonlyrecentHistory:object[]
Defined in: ../../../packages/hooks/src/types/hook-context.ts:74
Recent turn history, oldest first (up to 10 turns)
completedAt?
Section titled “completedAt?”
optionalcompletedAt?:number
Turn completion timestamp (Unix ms)
error?
Section titled “error?”
optionalerror?:string
Error message if status is ‘error’
sessionId
Section titled “sessionId”sessionId:
string
Session this turn belongs to
startedAt
Section titled “startedAt”startedAt:
number
Turn start timestamp (Unix ms)
status
Section titled “status”status:
"error"|"completed"|"active"=TurnStatusSchema
Turn status
turnId
Section titled “turnId”turnId:
string
Unique turn identifier
turnNumber
Section titled “turnNumber”turnNumber:
number
Monotonic per-session ordinal (1-based), assigned by turn storage at creation.
usage?
Section titled “usage?”
optionalusage?:object
Aggregated usage/cost for this turn. Populated on turn completion.
usage.byAgent?
Section titled “usage.byAgent?”
optionalbyAgent?:Record<string, {cost?:number;inputTokens:number;outputTokens:number; }>
Optional per-agent breakdown (for multi-agent turns)
usage.total
Section titled “usage.total”total:
object=UsageMetricsSchema
Total aggregated usage across all agents
usage.total.cost?
Section titled “usage.total.cost?”
optionalcost?:number
Computed cost in USD (optional, requires pricing data)
usage.total.inputTokens
Section titled “usage.total.inputTokens”inputTokens:
number
Input tokens consumed
usage.total.outputTokens
Section titled “usage.total.outputTokens”outputTokens:
number
Output tokens generated
Inherited from
Section titled “Inherited from”SessionHookContext.recentHistory
session?
Section titled “session?”
readonlyoptionalsession?:IMakaioSession
Defined in: ../../../packages/hooks/src/types/hook-context.ts:72
Session object (populated when sessionId is available)
Inherited from
Section titled “Inherited from”sessionId
Section titled “sessionId”
readonlysessionId:string
Defined in: ../../../packages/hooks/src/types/hook-context.ts:182
Session ID where turn completed
success
Section titled “success”
readonlysuccess:boolean
Defined in: ../../../packages/hooks/src/types/hook-context.ts:186
Whether all agents completed successfully
turnId
Section titled “turnId”
readonlyturnId:string
Defined in: ../../../packages/hooks/src/types/hook-context.ts:184
Turn identifier
Methods
Section titled “Methods”next()
Section titled “next()”next():
Promise<void>
Defined in: ../../../packages/hooks/src/types/hook-context.ts:198
Continue to the next interceptor in the chain.
Returns
Section titled “Returns”Promise<void>
stopPropagation()
Section titled “stopPropagation()”stopPropagation():
void
Defined in: ../../../packages/hooks/src/types/hook-context.ts:203
Stop propagation of this event. Subsequent interceptors and handlers will NOT be called.
Returns
Section titled “Returns”void