| 405 | } |
| 406 | |
| 407 | func (p *OpenCodeProvider) parseSSEEvent(data string) sseEvent { |
| 408 | var result sseEvent |
| 409 | |
| 410 | // Try format A: { type, properties } |
| 411 | if err := json.Unmarshal([]byte(data), &result); err == nil && result.Type != "" { |
| 412 | return result |
| 413 | } |
| 414 | |
| 415 | // Try format B: { directory, payload: { type, properties } } |
| 416 | var wrapped struct { |
| 417 | Payload json.RawMessage `json:"payload"` |
| 418 | } |
| 419 | if err := json.Unmarshal([]byte(data), &wrapped); err == nil && len(wrapped.Payload) > 0 { |
| 420 | json.Unmarshal(wrapped.Payload, &result) |
| 421 | } |
| 422 | |
| 423 | return result |
| 424 | } |
| 425 | |
| 426 | func (p *OpenCodeProvider) setAuth(req *http.Request) { |
| 427 | if p.apiKey != "" { |