import { html, type TemplateResult } from "@mariozechner/mini-lit"; import type { ToolResultMessage } from "@mariozechner/pi-ai"; import { i18n } from "../../utils/i18n.js"; import type { ToolRenderer } from "../types.js"; interface BashParams { command: string; } // Bash tool has undefined details (only uses output) export class BashRenderer implements ToolRenderer { renderParams(params: BashParams, isStreaming?: boolean): TemplateResult { if (isStreaming && (!params.command || params.command.length === 0)) { return html`
${i18n("Writing command...")}
`; } return html`
${i18n("Running command:")} ${params.command}
`; } renderResult(_params: BashParams, result: ToolResultMessage): TemplateResult { const output = result.output || ""; const isError = result.isError === true; if (isError) { return html`
${i18n("Command failed:")}
${output}
`; } // Display the command output return html`
${output}
`; } }