Return a bash snippet that emits JSONL events mimicking codex output.
(text: str, input_tokens: int = 0, output_tokens: int = 0)
| 22 | |
| 23 | |
| 24 | def _jsonl_response(text: str, input_tokens: int = 0, output_tokens: int = 0) -> str: |
| 25 | """Return a bash snippet that emits JSONL events mimicking codex output.""" |
| 26 | item_event = json.dumps( |
| 27 | { |
| 28 | "type": "item.completed", |
| 29 | "item": {"id": "item_0", "type": "agent_message", "text": text}, |
| 30 | } |
| 31 | ) |
| 32 | usage_event = json.dumps( |
| 33 | { |
| 34 | "type": "turn.completed", |
| 35 | "usage": {"input_tokens": input_tokens, "output_tokens": output_tokens}, |
| 36 | } |
| 37 | ) |
| 38 | return f"echo '{item_event}'\necho '{usage_event}'\n" |
| 39 | |
| 40 | |
| 41 | class TestParseJsonl(unittest.TestCase): |
no outgoing calls
no test coverage detected