Skip to content

feat: JSON streaming and JsonLineEvent #3

@joshrotenberg

Description

@joshrotenberg

Summary

Parse codex's --json NDJSON output for structured event handling.

  • CodexWrapper.JsonLineEvent struct: event_type, data (map), raw (string)
  • CodexWrapper.Exec.execute_json/2 returns list of parsed events
  • CodexWrapper.Exec.stream/2 returns lazy Stream of JsonLineEvent via Port
  • Port-based streaming with line-by-line NDJSON parsing

Event types from codex --json

  • thread.started, turn.started, item.completed, turn.completed, etc.

Acceptance criteria

  • JsonLineEvent struct with parse/1 from JSON string
  • JsonLineEvent accessor functions (event_type, data fields)
  • Exec.execute_json/2 collects all events from --json run
  • Exec.stream/2 returns lazy Stream via Port (like claude_wrapper's stream)
  • Tests for event parsing

Depends on

Reference

  • codex-wrapper (Rust): JsonLineEvent in exec.rs
  • claude_wrapper: lib/claude_wrapper/stream_event.ex, Query.stream/2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions