{
  "_contract_version": "0.15.0",
  "_provenance": "Issue #16 INV-008 — server-side proxy serialization shape. One entry per Event type defined in ratatoskr.sse_client. The JS presenter in static/index.html renders against the `data` shape; if either side changes, both must update in lockstep.",

  "worker_phase": {
    "event_type": "worker_phase",
    "data": {
      "sse_id": "42:3",
      "phase": "BuildingPrompt",
      "turn_id": 42
    }
  },

  "thinking": {
    "event_type": "thinking",
    "data": {
      "sse_id": "42:5",
      "content": "Let me think..."
    }
  },

  "text": {
    "event_type": "text",
    "data": {
      "sse_id": "42:7",
      "content": "Hello there"
    }
  },

  "text_boundary": {
    "event_type": "text_boundary",
    "data": {
      "sse_id": "42:8",
      "kind": "sentence",
      "char_offset": 11,
      "ts": "2026-05-28T00:00:00Z"
    }
  },

  "tool_start": {
    "event_type": "tool_start",
    "data": {
      "sse_id": "42:9",
      "name": "search",
      "arguments": {"q": "ratatoskr"}
    }
  },

  "tool_result": {
    "event_type": "tool_result",
    "data": {
      "sse_id": "42:10",
      "name": "search",
      "result": {"n": 1},
      "duration_ms": 12
    }
  },

  "done": {
    "event_type": "done",
    "data": {
      "sse_id": "42:11",
      "phase": "succeeded",
      "response": "Hello there",
      "model": "qwen3.6-35-a3b",
      "duration_ms": 1234,
      "usage": {
        "prompt_tokens": 100,
        "completion_tokens": 50,
        "total_tokens": 150,
        "cached_input_tokens": 0
      }
    }
  },

  "error": {
    "event_type": "error",
    "data": {
      "sse_id": "42:11",
      "phase": "failed",
      "message": "llm output invalid",
      "error_code": "llm_output_invalid"
    }
  },

  "cancelled": {
    "event_type": "cancelled",
    "data": {
      "sse_id": "42:11",
      "phase": "cancelled",
      "turn_id": 42,
      "reason": "user_cancel",
      "partial_message_id": null
    }
  },

  "affect_update": {
    "event_type": "affect_update",
    "data": {
      "sse_id": "42:1",
      "status": "current",
      "turn_id": 42,
      "snapshot": {
        "agent_id": "mimir",
        "pad": {"pleasure": 0.52, "arousal": 0.47, "dominance": 0.50},
        "dominant_emotion": "curiosity",
        "emotions_active": [
          {"type": "curiosity", "intensity": 0.6, "decay_remaining_s": 202.7}
        ],
        "baseline_pad": {"pleasure": 0.50, "arousal": 0.40, "dominance": 0.50},
        "mood_drift": {"valence_delta": 0.02, "arousal_delta": 0.07},
        "last_updated_at": "2026-05-28T00:00:00+00:00"
      }
    }
  },

  "awaiting_llm_first_token": {
    "event_type": "awaiting_llm_first_token",
    "data": {
      "sse_id": "42:2",
      "turn_id": 42,
      "elapsed_ms_since_building_prompt": 5012.3
    }
  }
}
