| import { css, html, LitElement } from "lit"; |
| import { customElement, property } from "lit/decorators.js"; |
| import { ToolCall } from "../types"; |
| |
| @customElement("sketch-tool-card-read-image") |
| export class SketchToolCardReadImage extends LitElement { |
| @property() |
| toolCall: ToolCall; |
| |
| @property() |
| open: boolean; |
| |
| static styles = css` |
| .summary-text { |
| font-family: monospace; |
| color: #444; |
| word-break: break-all; |
| } |
| |
| .path-input { |
| font-family: monospace; |
| background: rgba(0, 0, 0, 0.05); |
| padding: 4px 8px; |
| border-radius: 4px; |
| display: inline-block; |
| word-break: break-all; |
| } |
| `; |
| |
| render() { |
| // Parse the input to get path |
| let path = ""; |
| try { |
| if (this.toolCall?.input) { |
| const input = JSON.parse(this.toolCall.input); |
| path = input.path || ""; |
| } |
| } catch (e) { |
| console.error("Error parsing read image input:", e); |
| } |
| |
| // Show just the filename in summary |
| const filename = path.split("/").pop() || path; |
| |
| return html` |
| <sketch-tool-card .open=${this.open} .toolCall=${this.toolCall}> |
| <span slot="summary" class="summary-text"> 🖼️ ${filename} </span> |
| <div slot="input"> |
| <div>Read image: <span class="path-input">${path}</span></div> |
| </div> |
| <div slot="result"> |
| ${this.toolCall?.result_message?.tool_result |
| ? html`<pre>${this.toolCall.result_message.tool_result}</pre>` |
| : ""} |
| </div> |
| </sketch-tool-card> |
| `; |
| } |
| } |
| |
| declare global { |
| interface HTMLElementTagNameMap { |
| "sketch-tool-card-read-image": SketchToolCardReadImage; |
| } |
| } |