MarshalErrorJSONL renders one stable JSONL error frame for agent CLI streaming commands.
(err error)
| 149 | |
| 150 | // MarshalErrorJSONL renders one stable JSONL error frame for agent CLI streaming commands. |
| 151 | func MarshalErrorJSONL(err error) ([]byte, error) { |
| 152 | frame, marshalErr := json.Marshal(struct { |
| 153 | Type string `json:"type"` |
| 154 | Error ErrorPayload `json:"error"` |
| 155 | }{ |
| 156 | Type: "error", |
| 157 | Error: ErrorPayloadFor(err), |
| 158 | }) |
| 159 | if marshalErr != nil { |
| 160 | return nil, marshalErr |
| 161 | } |
| 162 | return append(frame, '\n'), nil |
| 163 | } |
| 164 | |
| 165 | // ExitCodeForError maps agent identity and command errors to deterministic CLI exit codes. |
| 166 | func ExitCodeForError(err error) int { |