| 163 | } |
| 164 | |
| 165 | export function entryBody(commit: StreamCommit): RunEntryBody { |
| 166 | if (commit.summary) { |
| 167 | return RUN_ENTRY_NONE |
| 168 | } |
| 169 | |
| 170 | const raw = cleanRunText(commit.text) |
| 171 | |
| 172 | if (commit.kind === "user") { |
| 173 | return userBody(raw) |
| 174 | } |
| 175 | |
| 176 | if (commit.kind === "tool") { |
| 177 | return toolEntryBody(commit, raw) ?? RUN_ENTRY_NONE |
| 178 | } |
| 179 | |
| 180 | if (commit.kind === "assistant") { |
| 181 | if (commit.phase === "start") { |
| 182 | return RUN_ENTRY_NONE |
| 183 | } |
| 184 | |
| 185 | if (commit.phase === "final") { |
| 186 | return commit.interrupted ? textBody("assistant interrupted") : RUN_ENTRY_NONE |
| 187 | } |
| 188 | |
| 189 | return markdownBody(raw) |
| 190 | } |
| 191 | |
| 192 | if (commit.kind === "reasoning") { |
| 193 | if (commit.phase === "start") { |
| 194 | return RUN_ENTRY_NONE |
| 195 | } |
| 196 | |
| 197 | if (commit.phase === "final") { |
| 198 | return commit.interrupted ? textBody("reasoning interrupted") : RUN_ENTRY_NONE |
| 199 | } |
| 200 | |
| 201 | return reasoningBody(raw) |
| 202 | } |
| 203 | |
| 204 | return systemBody(raw, commit.phase) |
| 205 | } |