(params: {
command: string
cwd: string
toolCallId?: string
output?: string
isComplete?: boolean
})
| 36 | } |
| 37 | |
| 38 | export function buildBashHistoryMessages(params: { |
| 39 | command: string |
| 40 | cwd: string |
| 41 | toolCallId?: string |
| 42 | output?: string |
| 43 | isComplete?: boolean |
| 44 | }): { |
| 45 | assistantMessage: ChatMessage |
| 46 | toolCallId: string |
| 47 | } { |
| 48 | const { command, cwd, output = '...', isComplete = false } = params |
| 49 | const toolCallId = params.toolCallId ?? crypto.randomUUID() |
| 50 | |
| 51 | const toolBlock: ContentBlock = { |
| 52 | type: 'tool', |
| 53 | toolName: 'run_terminal_command', |
| 54 | toolCallId, |
| 55 | input: { command }, |
| 56 | output, |
| 57 | } |
| 58 | |
| 59 | const assistantMessage: ChatMessage = { |
| 60 | id: `bash-result-${toolCallId}`, |
| 61 | variant: 'ai', |
| 62 | content: '', |
| 63 | blocks: [toolBlock], |
| 64 | timestamp: formatTimestamp(), |
| 65 | isComplete, |
| 66 | metadata: { bashCwd: cwd }, |
| 67 | } |
| 68 | |
| 69 | return { assistantMessage, toolCallId } |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Format pending bash messages as context to prepend to the user's prompt. |
no test coverage detected