adapter:piSdk
adapter:piSdk
Section titled “adapter:piSdk”| Field | Value |
|---|---|
| Prefix | adapter:piSdk |
| Namespace constant | PiSdkNamespace |
| Subjects constant | PiSdkSubjects |
| Kind | adapter |
| Schema record | piSdkSchemas |
| Tier | framework |
| Package | @makaio/adapter-pi-sdk |
| Defined in | adapters/implementations/pi-sdk/src/namespaces/index.ts |
Subjects
Section titled “Subjects”Subject Details
Section titled “Subject Details”adapter:piSdk.agent_complete (event)
Section titled “adapter:piSdk.agent_complete (event)”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
| Field | Type | Required |
|---|---|---|
eventType | "agent_complete" | yes |
messages | unknown[] | yes |
text | string | undefined | no |
adapter:piSdk.agent_started (event)
Section titled “adapter:piSdk.agent_started (event)”Agent has started processing a prompt. Mapped from Pi’s agent_start event.
Subject: adapter:piSdk.agent_started
Type: Event
| Field | Type | Required |
|---|---|---|
eventType | "agent_started" | yes |
model | string | undefined | no |
adapter:piSdk.auto_retry_ended (event)
Section titled “adapter:piSdk.auto_retry_ended (event)”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
| Field | Type | Required |
|---|---|---|
eventType | "auto_retry_ended" | yes |
adapter:piSdk.auto_retry_started (event)
Section titled “adapter:piSdk.auto_retry_started (event)”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
| Field | Type | Required |
|---|---|---|
eventType | "auto_retry_started" | yes |
adapter:piSdk.compaction_ended (event)
Section titled “adapter:piSdk.compaction_ended (event)”Context compaction has finished. Mapped from Pi’s compaction_end event.
Subject: adapter:piSdk.compaction_ended
Type: Event
| Field | Type | Required |
|---|---|---|
eventType | "compaction_ended" | yes |
adapter:piSdk.compaction_started (event)
Section titled “adapter:piSdk.compaction_started (event)”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
| Field | Type | Required |
|---|---|---|
eventType | "compaction_started" | yes |
adapter:piSdk.error (event)
Section titled “adapter:piSdk.error (event)”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
| Field | Type | Required |
|---|---|---|
error | unknown | yes |
eventType | "error" | yes |
adapter:piSdk.message_complete (event)
Section titled “adapter:piSdk.message_complete (event)”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
| Field | Type | Required |
|---|---|---|
eventType | "message_complete" | yes |
message | unknown | yes |
adapter:piSdk.queue_update (event)
Section titled “adapter:piSdk.queue_update (event)”Queue position or status update from the Pi SDK. Mapped from Pi’s queue_update event.
Subject: adapter:piSdk.queue_update
Type: Event
| Field | Type | Required |
|---|---|---|
eventType | "queue_update" | yes |
adapter:piSdk.sdk.event (event)
Section titled “adapter:piSdk.sdk.event (event)”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
| Field | Type | Required |
|---|---|---|
type | string | yes |
adapter:piSdk.text_complete (event)
Section titled “adapter:piSdk.text_complete (event)”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
| Field | Type | Required |
|---|---|---|
eventType | "text_complete" | yes |
text | string | yes |
adapter:piSdk.text_delta (event)
Section titled “adapter:piSdk.text_delta (event)”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
| Field | Type | Required |
|---|---|---|
delta | string | yes |
eventType | "text_delta" | yes |
adapter:piSdk.thinking_complete (event)
Section titled “adapter:piSdk.thinking_complete (event)”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
| Field | Type | Required |
|---|---|---|
eventType | "thinking_complete" | yes |
text | string | yes |
adapter:piSdk.thinking_delta (event)
Section titled “adapter:piSdk.thinking_delta (event)”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
| Field | Type | Required |
|---|---|---|
delta | string | yes |
eventType | "thinking_delta" | yes |
adapter:piSdk.tool_approval (rpc)
Section titled “adapter:piSdk.tool_approval (rpc)”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:
| Field | Type | Required |
|---|---|---|
adapterId | string | yes |
adapterName | string | yes |
adapterSessionId | string | yes |
agentId | string | yes |
args | Record<string, unknown> | undefined | no |
clientId | string | undefined | no |
messageId | string | undefined | no |
occurredAt | number | undefined | no |
providerConfigId | string | undefined | no |
reasoning | string | undefined | no |
sessionId | string | undefined | no |
toolCallId | string | yes |
toolName | string | undefined | no |
turnId | string | undefined | no |
Response:
| Field | Type | Required |
|---|---|---|
action | "allow" | "deny" | yes |
adapter:piSdk.tool_completed (event)
Section titled “adapter:piSdk.tool_completed (event)”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
| Field | Type | Required |
|---|---|---|
eventType | "tool_completed" | yes |
isError | boolean | yes |
result | unknown | yes |
toolCallId | string | yes |
toolName | string | yes |
adapter:piSdk.tool_started (event)
Section titled “adapter:piSdk.tool_started (event)”Tool execution has started. Mapped from Pi’s tool_execution_start event.
Subject: adapter:piSdk.tool_started
Type: Event
| Field | Type | Required |
|---|---|---|
args | Record<string, unknown> | undefined | no |
eventType | "tool_started" | yes |
toolCallId | string | yes |
toolName | string | yes |
adapter:piSdk.turn.state_changed (event)
Section titled “adapter:piSdk.turn.state_changed (event)”Schema for a turn state change event. Emitted by adapters whenever the turn state machine transitions.
Subject: adapter:piSdk.turn.state_changed
Type: Event
| Field | Type | Required |
|---|---|---|
adapterId | string | yes |
agentId | string | yes |
newState | "idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished" | yes |
oldState | "idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished" | yes |
timestamp | number | yes |
adapter:piSdk.turn.step_finished (event)
Section titled “adapter:piSdk.turn.step_finished (event)”Schema for a turn state change event. Emitted by adapters whenever the turn state machine transitions.
Subject: adapter:piSdk.turn.step_finished
Type: Event
| Field | Type | Required |
|---|---|---|
adapterId | string | yes |
agentId | string | yes |
newState | "idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished" | yes |
oldState | "idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished" | yes |
timestamp | number | yes |
adapter:piSdk.turn.step_started (event)
Section titled “adapter:piSdk.turn.step_started (event)”Schema for a turn state change event. Emitted by adapters whenever the turn state machine transitions.
Subject: adapter:piSdk.turn.step_started
Type: Event
| Field | Type | Required |
|---|---|---|
adapterId | string | yes |
agentId | string | yes |
newState | "idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished" | yes |
oldState | "idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished" | yes |
timestamp | number | yes |
adapter:piSdk.turn.turn_finished (event)
Section titled “adapter:piSdk.turn.turn_finished (event)”Schema for a turn state change event. Emitted by adapters whenever the turn state machine transitions.
Subject: adapter:piSdk.turn.turn_finished
Type: Event
| Field | Type | Required |
|---|---|---|
adapterId | string | yes |
agentId | string | yes |
newState | "idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished" | yes |
oldState | "idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished" | yes |
timestamp | number | yes |
adapter:piSdk.turn.turn_started (event)
Section titled “adapter:piSdk.turn.turn_started (event)”Schema for a turn state change event. Emitted by adapters whenever the turn state machine transitions.
Subject: adapter:piSdk.turn.turn_started
Type: Event
| Field | Type | Required |
|---|---|---|
adapterId | string | yes |
agentId | string | yes |
newState | "idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished" | yes |
oldState | "idle" | "turn_started" | "step_started" | "step_finished" | "turn_finished" | yes |
timestamp | number | yes |
adapter:piSdk.usage (event)
Section titled “adapter:piSdk.usage (event)”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
| Field | Type | Required |
|---|---|---|
eventType | "usage" | yes |
usage | unknown | yes |
Auto-generated by yarn docs:bus. Do not edit manually.