(params: {
command: string
stdout: string
stderr: string | null
exitCode: number
cwd: string
setMessages: RouterParams['setMessages']
})
| 217 | * Note: This is UI-only; we no longer send these commands to the AI context. |
| 218 | */ |
| 219 | export function addBashMessageToHistory(params: { |
| 220 | command: string |
| 221 | stdout: string |
| 222 | stderr: string | null |
| 223 | exitCode: number |
| 224 | cwd: string |
| 225 | setMessages: RouterParams['setMessages'] |
| 226 | }) { |
| 227 | const { command, stdout, stderr, exitCode, cwd, setMessages } = params |
| 228 | const toolResultOutput = createRunTerminalToolResult({ |
| 229 | command, |
| 230 | cwd, |
| 231 | stdout: stdout || null, |
| 232 | stderr: stderr ?? null, |
| 233 | exitCode, |
| 234 | }) |
| 235 | const toolCallId = crypto.randomUUID() |
| 236 | const outputJson = JSON.stringify(toolResultOutput) |
| 237 | const { assistantMessage } = buildBashHistoryMessages({ |
| 238 | command, |
| 239 | cwd, |
| 240 | toolCallId, |
| 241 | output: outputJson, |
| 242 | isComplete: true, |
| 243 | }) |
| 244 | |
| 245 | setMessages((prev) => [...prev, assistantMessage]) |
| 246 | } |
| 247 | |
| 248 | export async function routeUserPrompt( |
| 249 | params: RouterParams, |
no test coverage detected