Skip to content

Interface: PostStepContext

Makaio Framework


Makaio Framework / hooks / PostStepContext

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

PostStep context with step completion data.

Intercepts: AgentSubjects.step.finished event

Provides access to step type, metadata, and optional filtering. Enriches with session, recentHistory, and project when available.

Use stepType to filter for specific step types:

  • ‘reasoning’: Thinking/reasoning blocks (extended thinking enabled)
  • ‘tool_use’: Tool calls
  • ‘text’: Regular text message blocks

[key: string]: unknown

readonly adapterId: string

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

Adapter instance


readonly adapterName: string

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

Adapter type name


readonly agentId: string

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

Agent that completed the step


readonly blockIndex: number

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

Content block index


readonly bus: IMakaioBus

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

Bus instance for making requests

SessionHookContext.bus


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.

SessionHookContext.contextExtensions


readonly optional correlationId?: string

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

Correlation identifier for tracing


readonly hookEvent: "PostStep"

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


readonly optional messageId?: string

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

Message ID being processed


readonly payload: object

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

Full step.finished payload for advanced use

adapterId: string

Adapter instance identifier (required)

adapterName: string

Adapter type name (e.g., ‘claude-code’) (required)

adapterSessionId: string

Provider’s native session ID (e.g., Claude conversation ID)

agentId: string

Unique agent identifier (required)

blockIndex: number

Content block index in the turn

optional clientId?: string

Client identifier for the owning application/runtime when known.

content: { content: string; type: "text"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "image"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "attachment"; } | { content: string; metadata?: Record<string, unknown>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; } = SessionMessageBlockSchema

Step content for PostStep hooks (text, reasoning, tool_call, or tool_output)

{ content: string; type: "text"; }


{ source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "image"; }


{ source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "document"; }


{ attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "attachment"; }

attachmentType: "file" | "directory" = AttachmentTypeSchema

Whether the attachment is a file or directory

optional displayName?: string

Optional human-readable display name override

fileName: string

Original filename with extension (e.g. “api-spec.yaml”) — for display and type inference

filePath: string

Server-side file path — always populated before message reaches adapters

source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; } = ContentSourceSchema

Inline content — base64 for binary, raw string for text

type: "attachment"


{ content: string; metadata?: Record<string, unknown>; type: "reasoning"; }

content: string

optional metadata?: Record<string, unknown>

Optional provider/runtime metadata for reasoning blocks.

type: "reasoning"


{ args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; }


{ isError?: boolean; output: string; toolCallId: string; type: "tool_output"; }

optional messageId?: string

Message ID being processed

optional occurredAt?: number

Event occurrence timestamp in epoch milliseconds when known.

optional providerConfigId?: string

Resolved provider configuration identifier when known.

optional sessionId?: string

Makaio session ID (NOT provider’s native session ID)

stepType: "text" | "reasoning" | "tool_use" = StepTypeSchema

Step type (content block type)

optional turnId?: string

Turn ID from the session orchestrator. Optional for backward compatibility.


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

SessionHookContext.recentHistory


readonly optional session?: IMakaioSession

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

Session object (populated when sessionId is available)

SessionHookContext.session


readonly optional sessionId?: string

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

Session ID where step completed


readonly optional stepContent?: { content: string; type: "text"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "image"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "attachment"; } | { content: string; metadata?: Record<string, unknown>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; }

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

Step content block (if available).

Fetched from message storage with retry logic. May be undefined if:

  • messageId not available
  • Message not yet persisted (timing window)
  • Block index out of range

Contains actual content: reasoning text, tool args, or message text.

{ content: string; type: "text"; }


{ source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "image"; }


{ source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "document"; }


{ attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "attachment"; }

attachmentType: "file" | "directory" = AttachmentTypeSchema

Whether the attachment is a file or directory

optional displayName?: string

Optional human-readable display name override

fileName: string

Original filename with extension (e.g. “api-spec.yaml”) — for display and type inference

filePath: string

Server-side file path — always populated before message reaches adapters

source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; } = ContentSourceSchema

Inline content — base64 for binary, raw string for text

type: "attachment"


{ content: string; metadata?: Record<string, unknown>; type: "reasoning"; }

content: string

optional metadata?: Record<string, unknown>

Optional provider/runtime metadata for reasoning blocks.

type: "reasoning"


{ args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; }


{ isError?: boolean; output: string; toolCallId: string; type: "tool_output"; }


readonly stepType: "text" | "reasoning" | "tool_use"

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

Step type (reasoning, tool_use, text)

next(): Promise<void>

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

Continue to the next interceptor in the chain.

Promise<void>


stopPropagation(): void

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

Stop propagation of this event.

void