| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 1 | import { html } from "lit"; |
| Josh Bleecher Snyder | 2d08119 | 2025-05-29 13:46:04 +0000 | [diff] [blame] | 2 | import { customElement, property } from "lit/decorators.js"; |
| 3 | import { ToolCall } from "../types"; |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 4 | import { SketchTailwindElement } from "./sketch-tailwind-element"; |
| 5 | import "./sketch-tool-card-base"; |
| Josh Bleecher Snyder | 2d08119 | 2025-05-29 13:46:04 +0000 | [diff] [blame] | 6 | |
| 7 | @customElement("sketch-tool-card-browser-navigate") |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 8 | export class SketchToolCardBrowserNavigate extends SketchTailwindElement { |
| Josh Bleecher Snyder | 2d08119 | 2025-05-29 13:46:04 +0000 | [diff] [blame] | 9 | @property() |
| 10 | toolCall: ToolCall; |
| 11 | |
| 12 | @property() |
| 13 | open: boolean; |
| 14 | |
| Josh Bleecher Snyder | 2d08119 | 2025-05-29 13:46:04 +0000 | [diff] [blame] | 15 | render() { |
| 16 | // Parse the input to get URL |
| 17 | let url = ""; |
| 18 | try { |
| 19 | if (this.toolCall?.input) { |
| 20 | const input = JSON.parse(this.toolCall.input); |
| 21 | url = input.url || ""; |
| 22 | } |
| 23 | } catch (e) { |
| 24 | console.error("Error parsing navigate input:", e); |
| 25 | } |
| 26 | |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 27 | const summaryContent = html`<span class="font-mono text-gray-700 break-all"> |
| 28 | 🌐 ${url} |
| 29 | </span>`; |
| 30 | const inputContent = html`<div> |
| 31 | Navigate to: |
| 32 | <span |
| 33 | class="font-mono bg-black/[0.05] px-2 py-1 rounded inline-block break-all" |
| 34 | >${url}</span |
| 35 | > |
| 36 | </div>`; |
| 37 | const resultContent = this.toolCall?.result_message?.tool_result |
| 38 | ? html`<pre |
| 39 | class="bg-gray-200 text-black p-2 rounded whitespace-pre-wrap break-words max-w-full w-full box-border" |
| 40 | > |
| 41 | ${this.toolCall.result_message.tool_result}</pre |
| 42 | >` |
| 43 | : ""; |
| 44 | |
| Josh Bleecher Snyder | 2d08119 | 2025-05-29 13:46:04 +0000 | [diff] [blame] | 45 | return html` |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 46 | <sketch-tool-card-base |
| 47 | .open=${this.open} |
| 48 | .toolCall=${this.toolCall} |
| 49 | .summaryContent=${summaryContent} |
| 50 | .inputContent=${inputContent} |
| 51 | .resultContent=${resultContent} |
| 52 | > |
| 53 | </sketch-tool-card-base> |
| Josh Bleecher Snyder | 2d08119 | 2025-05-29 13:46:04 +0000 | [diff] [blame] | 54 | `; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | declare global { |
| 59 | interface HTMLElementTagNameMap { |
| 60 | "sketch-tool-card-browser-navigate": SketchToolCardBrowserNavigate; |
| 61 | } |
| 62 | } |