Skip to content

adapter:piSdk

FieldValue
Prefixadapter:piSdk
Namespace constantPiSdkNamespace
Subjects constantPiSdkSubjects
Kindadapter
Schema recordpiSdkSchemas
Tierframework
Package@makaio/adapter-pi-sdk
Defined inadapters/implementations/pi-sdk/src/namespaces/index.ts
KeyWireTypeSchema
agent_completeadapter:piSdk.agent_completeevent
agent_startedadapter:piSdk.agent_startedevent
auto_retry_endedadapter:piSdk.auto_retry_endedevent
auto_retry_startedadapter:piSdk.auto_retry_startedevent
compaction_endedadapter:piSdk.compaction_endedevent
compaction_startedadapter:piSdk.compaction_startedevent
erroradapter:piSdk.errorevent
message_completeadapter:piSdk.message_completeevent
queue_updateadapter:piSdk.queue_updateevent
sdk.eventadapter:piSdk.sdk.eventevent
text_completeadapter:piSdk.text_completeevent
text_deltaadapter:piSdk.text_deltaevent
thinking_completeadapter:piSdk.thinking_completeevent
thinking_deltaadapter:piSdk.thinking_deltaevent
tool_approvaladapter:piSdk.tool_approvalrpctool-approval.ts
tool_completedadapter:piSdk.tool_completedevent
tool_startedadapter:piSdk.tool_startedevent
turn.state_changedadapter:piSdk.turn.state_changedeventturn-state.ts
turn.step_finishedadapter:piSdk.turn.step_finishedeventturn-state.ts
turn.step_startedadapter:piSdk.turn.step_startedeventturn-state.ts
turn.turn_finishedadapter:piSdk.turn.turn_finishedeventturn-state.ts
turn.turn_startedadapter:piSdk.turn.turn_startedeventturn-state.ts
usageadapter:piSdk.usageevent

Agent has finished a full prompt run. Mapped from Pi’s agent_end event.

NOTE: Pi’s agent_end carries the full conversation messages array via event.messages, which differs from the shared AgentCompleteEventSchema (message: string | undefined). A Pi-specific schema preserves the full payload. Field: messages (unknown[]).

Subject: adapter:piSdk.agent_complete Type: Event

FieldTypeRequired
eventType"agent_complete"yes
messagesunknown[]yes
textstring | undefinedno

Agent has started processing a prompt. Mapped from Pi’s agent_start event.

Subject: adapter:piSdk.agent_started Type: Event

FieldTypeRequired
eventType"agent_started"yes
modelstring | undefinedno

Automatic retry has ended (either succeeded or exhausted retries). Mapped from Pi’s auto_retry_end event.

Subject: adapter:piSdk.auto_retry_ended Type: Event

FieldTypeRequired
eventType"auto_retry_ended"yes

Automatic retry of a failed API call has started. Pi SDK retries transiently failed requests automatically. Mapped from Pi’s auto_retry_start event.

Subject: adapter:piSdk.auto_retry_started Type: Event

FieldTypeRequired
eventType"auto_retry_started"yes

Context compaction has finished. Mapped from Pi’s compaction_end event.

Subject: adapter:piSdk.compaction_ended Type: Event

FieldTypeRequired
eventType"compaction_ended"yes

Context compaction has started. Pi SDK compacts the conversation history when the context window fills. Mapped from Pi’s compaction_start event.

Subject: adapter:piSdk.compaction_started Type: Event

FieldTypeRequired
eventType"compaction_started"yes

An error occurred during processing.

NOTE: Pi SDK surfaces structured error objects rather than plain error strings. error is typed as unknown rather than using the shared ErrorEventSchema’s message: string field to avoid data loss. Field: error (unknown).

Subject: adapter:piSdk.error Type: Event

FieldTypeRequired
errorunknownyes
eventType"error"yes

Full message object emitted when a single message finishes. Mapped from Pi’s message_end event.

Pi’s message shape: { role, content, usage, stopReason, errorMessage }

Subject: adapter:piSdk.message_complete Type: Event

FieldTypeRequired
eventType"message_complete"yes
messageunknownyes

Queue position or status update from the Pi SDK. Mapped from Pi’s queue_update event.

Subject: adapter:piSdk.queue_update Type: Event

FieldTypeRequired
eventType"queue_update"yes

Loose schema for raw Pi SDK events from session.subscribe().

Uses loose object mode to avoid coupling to Pi SDK’s exact internal types while retaining the type discriminator for observability routing. Semantic subjects below carry normalized, framework-conventional payloads.

Subject: adapter:piSdk.sdk.event Type: Event

FieldTypeRequired
typestringyes

Text generation complete for the current message. Mapped from Pi’s message_update when assistantMessageEvent.type === ‘text_end’.

Subject: adapter:piSdk.text_complete Type: Event

FieldTypeRequired
eventType"text_complete"yes
textstringyes

Streaming text delta from the model’s current response message. Mapped from Pi’s message_update when assistantMessageEvent.type === ‘text_delta’.

Subject: adapter:piSdk.text_delta Type: Event

FieldTypeRequired
deltastringyes
eventType"text_delta"yes

Thinking/reasoning complete for the current message. Mapped from Pi’s message_update when assistantMessageEvent.type === ‘thinking_end’.

Subject: adapter:piSdk.thinking_complete Type: Event

FieldTypeRequired
eventType"thinking_complete"yes
textstringyes

Streaming thinking/reasoning delta from the model’s internal chain-of-thought. Mapped from Pi’s message_update when assistantMessageEvent.type === ‘thinking_delta’.

Subject: adapter:piSdk.thinking_delta Type: Event

FieldTypeRequired
deltastringyes
eventType"thinking_delta"yes

Scoped tool approval schema for adapter connector buses.

sessionId is optional here because the connector emits the approval request before the agent layer has enriched it. The agent’s wireToolApprovalRpc (or equivalent) injects sessionId from its own context before forwarding to the global AgentSubjects.toolApprove subject, where sessionId is required.

Adapters with a genuinely different wire format (e.g., gemini-sdk’s callId/name) should define their own schema rather than extending this one.

Subject: adapter:piSdk.tool_approval Type: Request (RPC)

Request:

FieldTypeRequired
adapterIdstringyes
adapterNamestringyes
adapterSessionIdstringyes
agentIdstringyes
argsRecord<string, unknown> | undefinedno
clientIdstring | undefinedno
messageIdstring | undefinedno
occurredAtnumber | undefinedno
providerConfigIdstring | undefinedno
reasoningstring | undefinedno
sessionIdstring | undefinedno
toolCallIdstringyes
toolNamestring | undefinedno
turnIdstring | undefinedno

Response:

FieldTypeRequired
action"allow" | "deny"yes

Tool execution has completed (success or error). Mapped from Pi’s tool_execution_end event.

NOTE: This intentionally deviates from the shared ToolCompletedEventSchema (result: z.string(), success: boolean). Pi SDK surfaces a structured result object and an isError flag; serializing to a plain string would be lossy. Fields: toolName, toolCallId, result (unknown), isError.

Subject: adapter:piSdk.tool_completed Type: Event

FieldTypeRequired
eventType"tool_completed"yes
isErrorbooleanyes
resultunknownyes
toolCallIdstringyes
toolNamestringyes

Tool execution has started. Mapped from Pi’s tool_execution_start event.

Subject: adapter:piSdk.tool_started Type: Event

FieldTypeRequired
argsRecord<string, unknown> | undefinedno
eventType"tool_started"yes
toolCallIdstringyes
toolNamestringyes

Schema for a turn state change event. Emitted by adapters whenever the turn state machine transitions.

Subject: adapter:piSdk.turn.state_changed Type: Event

FieldTypeRequired
adapterIdstringyes
agentIdstringyes
newState"idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished"yes
oldState"idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished"yes
timestampnumberyes

Schema for a turn state change event. Emitted by adapters whenever the turn state machine transitions.

Subject: adapter:piSdk.turn.step_finished Type: Event

FieldTypeRequired
adapterIdstringyes
agentIdstringyes
newState"idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished"yes
oldState"idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished"yes
timestampnumberyes

Schema for a turn state change event. Emitted by adapters whenever the turn state machine transitions.

Subject: adapter:piSdk.turn.step_started Type: Event

FieldTypeRequired
adapterIdstringyes
agentIdstringyes
newState"idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished"yes
oldState"idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished"yes
timestampnumberyes

Schema for a turn state change event. Emitted by adapters whenever the turn state machine transitions.

Subject: adapter:piSdk.turn.turn_finished Type: Event

FieldTypeRequired
adapterIdstringyes
agentIdstringyes
newState"idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished"yes
oldState"idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished"yes
timestampnumberyes

Schema for a turn state change event. Emitted by adapters whenever the turn state machine transitions.

Subject: adapter:piSdk.turn.turn_started Type: Event

FieldTypeRequired
adapterIdstringyes
agentIdstringyes
newState"idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished"yes
oldState"idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished"yes
timestampnumberyes

Token usage summary for a completed message or turn. Pi SDK emits usage data within message_end’s message payload.

Pi’s usage shape: input, output, cacheRead, cacheWrite, totalTokens, cost

Subject: adapter:piSdk.usage Type: Event

FieldTypeRequired
eventType"usage"yes
usageunknownyes

Auto-generated by yarn docs:bus. Do not edit manually.