| import { css, html, LitElement } from "lit"; |
| import { customElement, property } from "lit/decorators.js"; |
| import { ToolCall } from "../types"; |
| |
| @customElement("sketch-tool-card-browser-eval") |
| export class SketchToolCardBrowserEval extends LitElement { |
| @property() |
| toolCall: ToolCall; |
| |
| @property() |
| open: boolean; |
| |
| static styles = css` |
| .summary-text { |
| font-family: monospace; |
| color: #444; |
| word-break: break-all; |
| } |
| |
| .expression-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 expression |
| let expression = ""; |
| try { |
| if (this.toolCall?.input) { |
| const input = JSON.parse(this.toolCall.input); |
| expression = input.expression || ""; |
| } |
| } catch (e) { |
| console.error("Error parsing eval input:", e); |
| } |
| |
| // Truncate expression for summary if too long |
| const displayExpression = |
| expression.length > 50 ? expression.substring(0, 50) + "..." : expression; |
| |
| return html` |
| <sketch-tool-card .open=${this.open} .toolCall=${this.toolCall}> |
| <span slot="summary" class="summary-text"> |
| 📱 ${displayExpression} |
| </span> |
| <div slot="input"> |
| <div> |
| Evaluate: <span class="expression-input">${expression}</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-browser-eval": SketchToolCardBrowserEval; |
| } |
| } |