| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 1 | import { html } from "lit"; |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 2 | import { unsafeHTML } from "lit/directives/unsafe-html.js"; |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 3 | import { customElement, property } from "lit/decorators.js"; |
| Autoformatter | 7e5fe3c | 2025-06-04 22:24:53 +0000 | [diff] [blame] | 4 | import { |
| 5 | ToolCall, |
| Autoformatter | 7e5fe3c | 2025-06-04 22:24:53 +0000 | [diff] [blame] | 6 | State, |
| 7 | } from "../types"; |
| philip.zeyliger | 26bc659 | 2025-06-30 20:15:30 -0700 | [diff] [blame] | 8 | import { marked } from "marked"; |
| Philip Zeyliger | 53ab245 | 2025-06-04 17:49:33 +0000 | [diff] [blame] | 9 | import DOMPurify from "dompurify"; |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 10 | import { SketchTailwindElement } from "./sketch-tailwind-element"; |
| 11 | import "./sketch-tool-card-base"; |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 12 | |
| Philip Zeyliger | 53ab245 | 2025-06-04 17:49:33 +0000 | [diff] [blame] | 13 | // Shared utility function for markdown rendering with DOMPurify sanitization |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 14 | function renderMarkdown(markdownContent: string): string { |
| 15 | try { |
| Philip Zeyliger | 53ab245 | 2025-06-04 17:49:33 +0000 | [diff] [blame] | 16 | // Parse markdown with default settings |
| 17 | const htmlOutput = marked.parse(markdownContent, { |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 18 | gfm: true, |
| 19 | breaks: true, |
| 20 | async: false, |
| 21 | }) as string; |
| Philip Zeyliger | 53ab245 | 2025-06-04 17:49:33 +0000 | [diff] [blame] | 22 | |
| 23 | // Sanitize the output HTML with DOMPurify |
| 24 | return DOMPurify.sanitize(htmlOutput, { |
| 25 | // Allow common safe HTML elements |
| 26 | ALLOWED_TAGS: [ |
| 27 | "p", |
| 28 | "br", |
| 29 | "strong", |
| 30 | "em", |
| 31 | "b", |
| 32 | "i", |
| 33 | "u", |
| 34 | "s", |
| 35 | "code", |
| 36 | "pre", |
| 37 | "h1", |
| 38 | "h2", |
| 39 | "h3", |
| 40 | "h4", |
| 41 | "h5", |
| 42 | "h6", |
| 43 | "ul", |
| 44 | "ol", |
| 45 | "li", |
| 46 | "blockquote", |
| 47 | "a", |
| 48 | ], |
| 49 | ALLOWED_ATTR: [ |
| 50 | "href", |
| 51 | "title", |
| 52 | "target", |
| 53 | "rel", // For links |
| 54 | "class", // For basic styling |
| 55 | ], |
| 56 | // Keep content formatting |
| 57 | KEEP_CONTENT: true, |
| 58 | }); |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 59 | } catch (error) { |
| 60 | console.error("Error rendering markdown:", error); |
| Philip Zeyliger | 53ab245 | 2025-06-04 17:49:33 +0000 | [diff] [blame] | 61 | // Fallback to sanitized plain text if markdown parsing fails |
| 62 | return DOMPurify.sanitize(markdownContent); |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 63 | } |
| 64 | } |
| 65 | |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 66 | // Shared utility function for creating Tailwind pre elements |
| 67 | function createPreElement(content: string, additionalClasses: string = "") { |
| 68 | return html`<pre |
| 69 | class="bg-gray-200 text-black p-2 rounded whitespace-pre-wrap break-words max-w-full w-full box-border overflow-wrap-break-word ${additionalClasses}" |
| 70 | > |
| 71 | ${content}</pre |
| 72 | >`; |
| Sean McCullough | ec3ad1a | 2025-04-18 13:55:16 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 75 | @customElement("sketch-tool-card-bash") |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 76 | export class SketchToolCardBash extends SketchTailwindElement { |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 77 | @property() toolCall: ToolCall; |
| 78 | @property() open: boolean; |
| 79 | |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 80 | render() { |
| 81 | const inputData = JSON.parse(this.toolCall?.input || "{}"); |
| 82 | const isBackground = inputData?.background === true; |
| Josh Bleecher Snyder | 17b2fd9 | 2025-07-09 22:47:13 +0000 | [diff] [blame] | 83 | const isSlowOk = inputData?.slow_ok === true; |
| Autoformatter | 9d9c812 | 2025-07-18 03:37:23 +0000 | [diff] [blame] | 84 | const backgroundIcon = isBackground |
| 85 | ? html`<span title="Running in background">🥷</span> ` |
| 86 | : ""; |
| 87 | const slowIcon = isSlowOk |
| 88 | ? html`<span title="Extended timeouts">🐢</span> ` |
| 89 | : ""; |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 90 | |
| Philip Zeyliger | e31d2a9 | 2025-05-11 15:22:35 -0700 | [diff] [blame] | 91 | // Truncate the command if it's too long to display nicely |
| 92 | const command = inputData?.command || ""; |
| 93 | const displayCommand = |
| 94 | command.length > 80 ? command.substring(0, 80) + "..." : command; |
| 95 | |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 96 | const summaryContent = html`<div |
| 97 | class="max-w-full overflow-hidden text-ellipsis whitespace-nowrap" |
| 98 | > |
| 99 | ${backgroundIcon}${slowIcon}${displayCommand} |
| 100 | </div>`; |
| 101 | |
| 102 | const inputContent = html`<div |
| 103 | class="flex w-full max-w-full flex-col overflow-wrap-break-word break-words" |
| 104 | > |
| 105 | <div class="w-full relative"> |
| Josh Bleecher Snyder | 4594388 | 2025-07-18 02:13:31 +0000 | [diff] [blame] | 106 | <pre |
| 107 | class="bg-gray-200 text-black p-2 rounded whitespace-pre-wrap break-words max-w-full w-full box-border overflow-wrap-break-word w-full mb-0 rounded-t rounded-b-none box-border" |
| 108 | > |
| Autoformatter | 9d9c812 | 2025-07-18 03:37:23 +0000 | [diff] [blame] | 109 | ${backgroundIcon}${slowIcon}${inputData?.command}</pre |
| 110 | > |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 111 | </div> |
| 112 | </div>`; |
| 113 | |
| 114 | const resultContent = this.toolCall?.result_message?.tool_result |
| 115 | ? html`<div class="w-full relative"> |
| 116 | ${createPreElement( |
| 117 | this.toolCall.result_message.tool_result, |
| 118 | "mt-0 text-gray-600 rounded-t-none rounded-b w-full box-border max-h-[300px] overflow-y-auto", |
| 119 | )} |
| 120 | </div>` |
| 121 | : ""; |
| 122 | |
| 123 | return html`<sketch-tool-card-base |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 124 | .open=${this.open} |
| 125 | .toolCall=${this.toolCall} |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 126 | .summaryContent=${summaryContent} |
| 127 | .inputContent=${inputContent} |
| 128 | .resultContent=${resultContent} |
| 129 | ></sketch-tool-card-base>`; |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 130 | } |
| 131 | } |
| 132 | |
| 133 | @customElement("sketch-tool-card-codereview") |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 134 | export class SketchToolCardCodeReview extends SketchTailwindElement { |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 135 | @property() toolCall: ToolCall; |
| 136 | @property() open: boolean; |
| 137 | |
| 138 | // Determine the status icon based on the content of the result message |
| 139 | getStatusIcon(resultText: string): string { |
| 140 | if (!resultText) return ""; |
| 141 | if (resultText === "OK") return "✔️"; |
| 142 | if (resultText.includes("# Errors")) return "⚠️"; |
| 143 | if (resultText.includes("# Info")) return "ℹ️"; |
| 144 | if (resultText.includes("uncommitted changes in repo")) return "🧹"; |
| 145 | if (resultText.includes("no new commits have been added")) return "🐣"; |
| 146 | if (resultText.includes("git repo is not clean")) return "🧼"; |
| 147 | return "❓"; |
| 148 | } |
| 149 | |
| 150 | render() { |
| 151 | const resultText = this.toolCall?.result_message?.tool_result || ""; |
| 152 | const statusIcon = this.getStatusIcon(resultText); |
| 153 | |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 154 | const summaryContent = html`<span>${statusIcon}</span>`; |
| 155 | const resultContent = resultText ? createPreElement(resultText) : ""; |
| 156 | |
| 157 | return html`<sketch-tool-card-base |
| 158 | .open=${this.open} |
| 159 | .toolCall=${this.toolCall} |
| 160 | .summaryContent=${summaryContent} |
| 161 | .resultContent=${resultContent} |
| 162 | ></sketch-tool-card-base>`; |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 163 | } |
| 164 | } |
| 165 | |
| 166 | @customElement("sketch-tool-card-done") |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 167 | export class SketchToolCardDone extends SketchTailwindElement { |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 168 | @property() toolCall: ToolCall; |
| 169 | @property() open: boolean; |
| 170 | |
| 171 | render() { |
| 172 | const doneInput = JSON.parse(this.toolCall.input); |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 173 | |
| 174 | const summaryContent = html`<span></span>`; |
| 175 | |
| 176 | const resultContent = html`<div> |
| 177 | ${Object.keys(doneInput.checklist_items).map((key) => { |
| 178 | const item = doneInput.checklist_items[key]; |
| 179 | let statusIcon = "〰️"; |
| 180 | if (item.status == "yes") { |
| 181 | statusIcon = "✅"; |
| 182 | } else if (item.status == "not applicable") { |
| 183 | statusIcon = "🤷"; |
| 184 | } |
| 185 | return html`<div class="mb-1"> |
| 186 | <span>${statusIcon}</span> ${key}:${item.status} |
| 187 | </div>`; |
| 188 | })} |
| 189 | </div>`; |
| 190 | |
| 191 | return html`<sketch-tool-card-base |
| 192 | .open=${this.open} |
| 193 | .toolCall=${this.toolCall} |
| 194 | .summaryContent=${summaryContent} |
| 195 | .resultContent=${resultContent} |
| 196 | ></sketch-tool-card-base>`; |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 197 | } |
| 198 | } |
| 199 | |
| 200 | @customElement("sketch-tool-card-patch") |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 201 | export class SketchToolCardPatch extends SketchTailwindElement { |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 202 | @property() toolCall: ToolCall; |
| 203 | @property() open: boolean; |
| 204 | |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 205 | render() { |
| 206 | const patchInput = JSON.parse(this.toolCall?.input); |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 207 | |
| 208 | const summaryContent = html`<span |
| 209 | class="text-gray-600 font-mono overflow-hidden text-ellipsis whitespace-nowrap rounded" |
| 210 | > |
| 211 | ${patchInput?.path}: ${patchInput.patches.length} |
| 212 | edit${patchInput.patches.length > 1 ? "s" : ""} |
| 213 | </span>`; |
| 214 | |
| 215 | const inputContent = html`<div> |
| 216 | ${patchInput.patches.map((patch) => { |
| 217 | return html`<div class="mb-2"> |
| 218 | Patch operation: <b>${patch.operation}</b> |
| 219 | ${createPreElement(patch.newText)} |
| 220 | </div>`; |
| 221 | })} |
| 222 | </div>`; |
| 223 | |
| 224 | const resultContent = this.toolCall?.result_message?.tool_result |
| 225 | ? createPreElement(this.toolCall.result_message.tool_result) |
| 226 | : ""; |
| 227 | |
| 228 | return html`<sketch-tool-card-base |
| 229 | .open=${this.open} |
| 230 | .toolCall=${this.toolCall} |
| 231 | .summaryContent=${summaryContent} |
| 232 | .inputContent=${inputContent} |
| 233 | .resultContent=${resultContent} |
| 234 | ></sketch-tool-card-base>`; |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 235 | } |
| 236 | } |
| 237 | |
| 238 | @customElement("sketch-tool-card-think") |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 239 | export class SketchToolCardThink extends SketchTailwindElement { |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 240 | @property() toolCall: ToolCall; |
| 241 | @property() open: boolean; |
| 242 | |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 243 | render() { |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 244 | const thoughts = JSON.parse(this.toolCall?.input)?.thoughts || ""; |
| 245 | |
| 246 | const summaryContent = html`<span |
| 247 | class="overflow-hidden text-ellipsis font-mono" |
| 248 | > |
| 249 | ${thoughts.split("\n")[0]} |
| 250 | </span>`; |
| 251 | |
| 252 | const inputContent = html`<div |
| 253 | class="overflow-x-auto mb-1 font-mono px-2 py-1 bg-gray-200 rounded select-text cursor-text text-sm leading-relaxed" |
| 254 | > |
| 255 | <div class="markdown-content"> |
| 256 | ${unsafeHTML(renderMarkdown(thoughts))} |
| 257 | </div> |
| 258 | </div>`; |
| 259 | |
| 260 | return html`<sketch-tool-card-base |
| 261 | .open=${this.open} |
| 262 | .toolCall=${this.toolCall} |
| 263 | .summaryContent=${summaryContent} |
| 264 | .inputContent=${inputContent} |
| 265 | ></sketch-tool-card-base>`; |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 266 | } |
| 267 | } |
| 268 | |
| Josh Bleecher Snyder | 19969a9 | 2025-06-05 14:34:02 -0700 | [diff] [blame] | 269 | @customElement("sketch-tool-card-commit-message-style") |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 270 | export class SketchToolCardCommitMessageStyle extends SketchTailwindElement { |
| Josh Bleecher Snyder | a2a3150 | 2025-05-07 12:37:18 +0000 | [diff] [blame] | 271 | @property() |
| 272 | toolCall: ToolCall; |
| 273 | |
| 274 | @property() |
| 275 | open: boolean; |
| 276 | |
| Philip Zeyliger | be7802a | 2025-06-04 20:15:25 +0000 | [diff] [blame] | 277 | @property() |
| 278 | state: State; |
| 279 | |
| Josh Bleecher Snyder | a2a3150 | 2025-05-07 12:37:18 +0000 | [diff] [blame] | 280 | constructor() { |
| 281 | super(); |
| 282 | } |
| 283 | |
| 284 | connectedCallback() { |
| 285 | super.connectedCallback(); |
| 286 | } |
| 287 | |
| 288 | disconnectedCallback() { |
| 289 | super.disconnectedCallback(); |
| 290 | } |
| 291 | |
| 292 | render() { |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 293 | return html`<sketch-tool-card-base |
| 294 | .open=${this.open} |
| 295 | .toolCall=${this.toolCall} |
| 296 | ></sketch-tool-card-base>`; |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 297 | } |
| 298 | } |
| 299 | |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 300 | |
| Josh Bleecher Snyder | 112b923 | 2025-05-23 11:26:33 -0700 | [diff] [blame] | 301 | @customElement("sketch-tool-card-todo-write") |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 302 | export class SketchToolCardTodoWrite extends SketchTailwindElement { |
| Josh Bleecher Snyder | 112b923 | 2025-05-23 11:26:33 -0700 | [diff] [blame] | 303 | @property() toolCall: ToolCall; |
| 304 | @property() open: boolean; |
| 305 | |
| Josh Bleecher Snyder | 112b923 | 2025-05-23 11:26:33 -0700 | [diff] [blame] | 306 | render() { |
| 307 | const inputData = JSON.parse(this.toolCall?.input || "{}"); |
| 308 | const tasks = inputData.tasks || []; |
| Josh Bleecher Snyder | 991164f | 2025-05-29 05:02:10 +0000 | [diff] [blame] | 309 | |
| Josh Bleecher Snyder | 112b923 | 2025-05-23 11:26:33 -0700 | [diff] [blame] | 310 | // Generate circles based on task status |
| Josh Bleecher Snyder | 991164f | 2025-05-29 05:02:10 +0000 | [diff] [blame] | 311 | const circles = tasks |
| 312 | .map((task) => { |
| 313 | switch (task.status) { |
| 314 | case "completed": |
| 315 | return "●"; // full circle |
| 316 | case "in-progress": |
| 317 | return "◐"; // half circle |
| 318 | case "queued": |
| 319 | default: |
| 320 | return "○"; // empty circle |
| 321 | } |
| 322 | }) |
| 323 | .join(" "); |
| 324 | |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 325 | const summaryContent = html`<span class="italic text-gray-600"> |
| 326 | ${circles} |
| 327 | </span>`; |
| 328 | const resultContent = this.toolCall?.result_message?.tool_result |
| 329 | ? createPreElement(this.toolCall.result_message.tool_result) |
| 330 | : ""; |
| 331 | |
| 332 | return html`<sketch-tool-card-base |
| 333 | .open=${this.open} |
| 334 | .toolCall=${this.toolCall} |
| 335 | .summaryContent=${summaryContent} |
| 336 | .resultContent=${resultContent} |
| 337 | ></sketch-tool-card-base>`; |
| Josh Bleecher Snyder | 991164f | 2025-05-29 05:02:10 +0000 | [diff] [blame] | 338 | } |
| 339 | } |
| 340 | |
| 341 | @customElement("sketch-tool-card-keyword-search") |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 342 | export class SketchToolCardKeywordSearch extends SketchTailwindElement { |
| Josh Bleecher Snyder | 991164f | 2025-05-29 05:02:10 +0000 | [diff] [blame] | 343 | @property() toolCall: ToolCall; |
| 344 | @property() open: boolean; |
| 345 | |
| Josh Bleecher Snyder | 991164f | 2025-05-29 05:02:10 +0000 | [diff] [blame] | 346 | render() { |
| 347 | const inputData = JSON.parse(this.toolCall?.input || "{}"); |
| 348 | const query = inputData.query || ""; |
| 349 | const searchTerms = inputData.search_terms || []; |
| 350 | |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 351 | const summaryContent = html`<div |
| 352 | class="flex flex-col gap-0.5 w-full max-w-full overflow-hidden" |
| 353 | > |
| 354 | <div |
| 355 | class="text-gray-800 text-xs normal-case whitespace-normal break-words leading-tight" |
| 356 | > |
| 357 | 🔍 ${query} |
| Josh Bleecher Snyder | 991164f | 2025-05-29 05:02:10 +0000 | [diff] [blame] | 358 | </div> |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 359 | <div |
| 360 | class="text-gray-600 text-xs normal-case whitespace-normal break-words leading-tight mt-px" |
| 361 | > |
| 362 | 🗝️ ${searchTerms.join(", ")} |
| Josh Bleecher Snyder | 991164f | 2025-05-29 05:02:10 +0000 | [diff] [blame] | 363 | </div> |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 364 | </div>`; |
| 365 | |
| 366 | const inputContent = html`<div> |
| 367 | <div><strong>Query:</strong> ${query}</div> |
| 368 | <div><strong>Search terms:</strong> ${searchTerms.join(", ")}</div> |
| 369 | </div>`; |
| 370 | |
| 371 | const resultContent = this.toolCall?.result_message?.tool_result |
| 372 | ? createPreElement(this.toolCall.result_message.tool_result) |
| 373 | : ""; |
| 374 | |
| 375 | return html`<sketch-tool-card-base |
| 376 | .open=${this.open} |
| 377 | .toolCall=${this.toolCall} |
| 378 | .summaryContent=${summaryContent} |
| 379 | .inputContent=${inputContent} |
| 380 | .resultContent=${resultContent} |
| 381 | ></sketch-tool-card-base>`; |
| Josh Bleecher Snyder | 112b923 | 2025-05-23 11:26:33 -0700 | [diff] [blame] | 382 | } |
| 383 | } |
| 384 | |
| 385 | @customElement("sketch-tool-card-todo-read") |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 386 | export class SketchToolCardTodoRead extends SketchTailwindElement { |
| Josh Bleecher Snyder | 112b923 | 2025-05-23 11:26:33 -0700 | [diff] [blame] | 387 | @property() toolCall: ToolCall; |
| 388 | @property() open: boolean; |
| 389 | |
| Josh Bleecher Snyder | 112b923 | 2025-05-23 11:26:33 -0700 | [diff] [blame] | 390 | render() { |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 391 | const summaryContent = html`<span class="italic text-gray-600"> |
| 392 | Read todo list |
| 393 | </span>`; |
| 394 | const resultContent = this.toolCall?.result_message?.tool_result |
| 395 | ? createPreElement(this.toolCall.result_message.tool_result) |
| 396 | : ""; |
| 397 | |
| 398 | return html`<sketch-tool-card-base |
| 399 | .open=${this.open} |
| 400 | .toolCall=${this.toolCall} |
| 401 | .summaryContent=${summaryContent} |
| 402 | .resultContent=${resultContent} |
| 403 | ></sketch-tool-card-base>`; |
| Josh Bleecher Snyder | 112b923 | 2025-05-23 11:26:33 -0700 | [diff] [blame] | 404 | } |
| 405 | } |
| 406 | |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 407 | @customElement("sketch-tool-card-generic") |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 408 | export class SketchToolCardGeneric extends SketchTailwindElement { |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 409 | @property() toolCall: ToolCall; |
| 410 | @property() open: boolean; |
| 411 | |
| 412 | render() { |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 413 | const summaryContent = html`<span |
| 414 | class="block whitespace-normal break-words max-w-full w-full" |
| 415 | > |
| 416 | ${this.toolCall?.input} |
| 417 | </span>`; |
| 418 | |
| 419 | const inputContent = html`<div class="max-w-full break-words"> |
| 420 | Input: |
| 421 | ${createPreElement( |
| 422 | this.toolCall?.input || "", |
| 423 | "max-w-full whitespace-pre-wrap break-words", |
| 424 | )} |
| 425 | </div>`; |
| 426 | |
| 427 | const resultContent = this.toolCall?.result_message?.tool_result |
| 428 | ? html`<div class="max-w-full break-words"> |
| 429 | Result: ${createPreElement(this.toolCall.result_message.tool_result)} |
| 430 | </div>` |
| 431 | : ""; |
| 432 | |
| 433 | return html`<sketch-tool-card-base |
| 434 | .open=${this.open} |
| 435 | .toolCall=${this.toolCall} |
| 436 | .summaryContent=${summaryContent} |
| 437 | .inputContent=${inputContent} |
| 438 | .resultContent=${resultContent} |
| 439 | ></sketch-tool-card-base>`; |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 440 | } |
| 441 | } |
| 442 | |
| Sean McCullough | ec3ad1a | 2025-04-18 13:55:16 -0700 | [diff] [blame] | 443 | declare global { |
| 444 | interface HTMLElementTagNameMap { |
| Pokey Rule | 7ac5ed0 | 2025-05-07 15:26:10 +0100 | [diff] [blame] | 445 | "sketch-tool-card-generic": SketchToolCardGeneric; |
| 446 | "sketch-tool-card-bash": SketchToolCardBash; |
| 447 | "sketch-tool-card-codereview": SketchToolCardCodeReview; |
| 448 | "sketch-tool-card-done": SketchToolCardDone; |
| 449 | "sketch-tool-card-patch": SketchToolCardPatch; |
| 450 | "sketch-tool-card-think": SketchToolCardThink; |
| Josh Bleecher Snyder | 19969a9 | 2025-06-05 14:34:02 -0700 | [diff] [blame] | 451 | "sketch-tool-card-commit-message-style": SketchToolCardCommitMessageStyle; |
| Josh Bleecher Snyder | 112b923 | 2025-05-23 11:26:33 -0700 | [diff] [blame] | 452 | "sketch-tool-card-todo-write": SketchToolCardTodoWrite; |
| 453 | "sketch-tool-card-todo-read": SketchToolCardTodoRead; |
| Josh Bleecher Snyder | 991164f | 2025-05-29 05:02:10 +0000 | [diff] [blame] | 454 | "sketch-tool-card-keyword-search": SketchToolCardKeywordSearch; |
| Sean McCullough | ec3ad1a | 2025-04-18 13:55:16 -0700 | [diff] [blame] | 455 | } |
| 456 | } |