{
  "_meta": {
    "description": "Canonical pi SDK events — emitted by AgentSession.subscribe(). Used to test server-side event translation (session-protocol.ts translatePiEvent).",
    "generated": "2026-02-21T02:30:00Z",
    "eventCount": 31
  },
  "events": [
    {
      "_label": "agent_start: pi begins processing a prompt",
      "type": "agent_start"
    },
    {
      "_label": "turn_start: new turn begins within agent run",
      "type": "turn_start"
    },
    {
      "_label": "message_start: assistant message begins",
      "type": "message_start",
      "message": {
        "role": "assistant",
        "content": []
      }
    },
    {
      "_label": "message_update start: stream initialization",
      "type": "message_update",
      "assistantMessageEvent": {
        "type": "start",
        "partial": { "role": "assistant", "content": [] }
      }
    },
    {
      "_label": "message_update text_start: text block begins",
      "type": "message_update",
      "assistantMessageEvent": {
        "type": "text_start",
        "contentIndex": 0,
        "partial": { "role": "assistant", "content": [] }
      }
    },
    {
      "_label": "message_update text_delta: streaming assistant text",
      "type": "message_update",
      "assistantMessageEvent": {
        "type": "text_delta",
        "delta": "Let me help you with that. "
      }
    },
    {
      "_label": "message_update thinking_delta: streaming thinking content",
      "type": "message_update",
      "assistantMessageEvent": {
        "type": "thinking_delta",
        "delta": "I need to analyze the code structure first..."
      }
    },
    {
      "_label": "message_update text_end: text block finishes",
      "type": "message_update",
      "assistantMessageEvent": {
        "type": "text_end",
        "contentIndex": 0,
        "content": "Let me help you with that. ",
        "partial": { "role": "assistant", "content": [{ "type": "text", "text": "Let me help you with that. " }] }
      }
    },
    {
      "_label": "message_update thinking_start: thinking block begins",
      "type": "message_update",
      "assistantMessageEvent": {
        "type": "thinking_start",
        "contentIndex": 1,
        "partial": { "role": "assistant", "content": [] }
      }
    },
    {
      "_label": "message_update thinking_end: thinking block finishes",
      "type": "message_update",
      "assistantMessageEvent": {
        "type": "thinking_end",
        "contentIndex": 1,
        "content": "I need to analyze the code structure first...",
        "partial": { "role": "assistant", "content": [] }
      }
    },
    {
      "_label": "message_update toolcall_start: tool call streaming begins",
      "type": "message_update",
      "assistantMessageEvent": {
        "type": "toolcall_start",
        "contentIndex": 2,
        "partial": { "role": "assistant", "content": [] }
      }
    },
    {
      "_label": "message_update toolcall_delta: tool call args streaming",
      "type": "message_update",
      "assistantMessageEvent": {
        "type": "toolcall_delta",
        "contentIndex": 2,
        "delta": "{\"command\":\"npm test\"}",
        "partial": { "role": "assistant", "content": [] }
      }
    },
    {
      "_label": "message_update toolcall_end: tool call args complete",
      "type": "message_update",
      "assistantMessageEvent": {
        "type": "toolcall_end",
        "contentIndex": 2,
        "toolCall": { "id": "tc-replay-001", "name": "bash", "args": "{\"command\":\"npm test\"}" },
        "partial": { "role": "assistant", "content": [] }
      }
    },
    {
      "_label": "message_update done: stream completed normally",
      "type": "message_update",
      "assistantMessageEvent": {
        "type": "done",
        "reason": "stop",
        "message": { "role": "assistant", "content": [{ "type": "text", "text": "Done." }] }
      }
    },
    {
      "_label": "message_update error: stream error (aborted/rate-limit)",
      "type": "message_update",
      "assistantMessageEvent": {
        "type": "error",
        "reason": "aborted",
        "error": { "role": "assistant", "content": "Request aborted by user" }
      }
    },
    {
      "_label": "tool_execution_start: pi begins a tool call",
      "type": "tool_execution_start",
      "toolName": "bash",
      "toolCallId": "tc-replay-001",
      "args": {
        "command": "npm test"
      }
    },
    {
      "_label": "tool_execution_update: partial tool output (replace semantics)",
      "type": "tool_execution_update",
      "toolName": "bash",
      "toolCallId": "tc-replay-001",
      "partialResult": {
        "content": [{ "type": "text", "text": "Running tests...\n" }]
      }
    },
    {
      "_label": "tool_execution_update: more partial output",
      "type": "tool_execution_update",
      "toolName": "bash",
      "toolCallId": "tc-replay-001",
      "partialResult": {
        "content": [{ "type": "text", "text": "Running tests...\n42 tests passed\n" }]
      }
    },
    {
      "_label": "tool_execution_end: tool call completes with details",
      "type": "tool_execution_end",
      "toolName": "bash",
      "toolCallId": "tc-replay-001",
      "result": {
        "content": [{ "type": "text", "text": "Running tests...\n42 tests passed\n" }],
        "details": { "exitCode": 0, "durationMs": 1234 }
      },
      "isError": false
    },
    {
      "_label": "tool_execution_end: error tool call with details",
      "type": "tool_execution_end",
      "toolName": "bash",
      "toolCallId": "tc-replay-err",
      "result": {
        "content": [{ "type": "text", "text": "command not found: foobar" }],
        "details": { "exitCode": 127, "durationMs": 50 }
      },
      "isError": true
    },
    {
      "_label": "tool_execution_end: extension tool with structured details",
      "type": "tool_execution_end",
      "toolName": "remember",
      "toolCallId": "tc-replay-ext",
      "result": {
        "content": [{ "type": "text", "text": "Saved to journal: 2026-02-18-session.md" }],
        "details": { "file": "2026-02-18-session.md", "redacted": false }
      },
      "isError": false
    },
    {
      "_label": "tool_execution_end: bare (no result) — legacy compat",
      "type": "tool_execution_end",
      "toolName": "bash",
      "toolCallId": "tc-replay-bare"
    },
    {
      "_label": "message_end assistant: turn completes with usage stats",
      "type": "message_end",
      "message": {
        "role": "assistant",
        "content": [
          { "type": "text", "text": "All 42 tests passed!" }
        ],
        "usage": {
          "input": 1200,
          "output": 350,
          "cacheRead": 800,
          "cacheWrite": 100,
          "cost": { "total": 0.0045 }
        }
      }
    },
    {
      "_label": "turn_end: turn completes (tool results delivered)",
      "type": "turn_end",
      "message": {
        "role": "assistant",
        "content": [{ "type": "text", "text": "Done." }]
      },
      "toolResults": []
    },
    {
      "_label": "agent_end: pi finishes processing",
      "type": "agent_end"
    },
    {
      "_label": "response success: RPC response with correlation id",
      "type": "response",
      "id": "rpc-123",
      "success": true,
      "command": "get_state",
      "data": {
        "sessionFile": "/tmp/pi-sessions/test.jsonl",
        "sessionId": "uuid-test-456",
        "sessionName": "My Session",
        "model": { "provider": "anthropic", "id": "claude-sonnet-4-0" },
        "thinkingLevel": "medium"
      }
    },
    {
      "_label": "response error: failed RPC with correlation id",
      "type": "response",
      "id": "rpc-124",
      "success": false,
      "command": "set_model",
      "error": "Unknown model: fake-model"
    },
    {
      "_label": "auto_compaction_start: pi begins auto-compaction",
      "type": "auto_compaction_start",
      "reason": "Context window 90% full"
    },
    {
      "_label": "auto_compaction_end: compaction completes",
      "type": "auto_compaction_end",
      "aborted": false,
      "willRetry": false,
      "summary": "Compacted from 180k to 95k tokens",
      "tokensBefore": 180000
    },
    {
      "_label": "auto_retry_start: pi begins auto-retry after error",
      "type": "auto_retry_start",
      "attempt": 1,
      "maxAttempts": 3,
      "delayMs": 5000,
      "errorMessage": "API overloaded"
    },
    {
      "_label": "auto_retry_end: retry succeeds",
      "type": "auto_retry_end",
      "success": true,
      "attempt": 2
    },
    {
      "_label": "extension_error: extension raised an error",
      "type": "extension_error",
      "extensionName": "permission-gate",
      "error": "Gate connection refused"
    },
    {
      "_label": "extension_ui_request: dialog from extension",
      "type": "extension_ui_request",
      "id": "ext-ui-001",
      "method": "select",
      "title": "Choose option",
      "options": [{ "label": "Option A" }, { "label": "Option B" }],
      "message": "Pick one",
      "timeout": 30000
    },
    {
      "_label": "tool_execution_start read: file read tool",
      "type": "tool_execution_start",
      "toolName": "read",
      "toolCallId": "tc-replay-002",
      "args": {
        "path": "src/main.ts",
        "offset": 1,
        "limit": 50
      }
    }
  ]
}
