@draht/web-ui 2026.3.2-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (372) hide show
  1. package/CHANGELOG.md +276 -0
  2. package/README.md +601 -0
  3. package/dist/ChatPanel.d.ts +28 -0
  4. package/dist/ChatPanel.d.ts.map +1 -0
  5. package/dist/ChatPanel.js +193 -0
  6. package/dist/ChatPanel.js.map +1 -0
  7. package/dist/app.css +2 -0
  8. package/dist/components/AgentInterface.d.ts +39 -0
  9. package/dist/components/AgentInterface.d.ts.map +1 -0
  10. package/dist/components/AgentInterface.js +384 -0
  11. package/dist/components/AgentInterface.js.map +1 -0
  12. package/dist/components/AttachmentTile.d.ts +12 -0
  13. package/dist/components/AttachmentTile.d.ts.map +1 -0
  14. package/dist/components/AttachmentTile.js +110 -0
  15. package/dist/components/AttachmentTile.js.map +1 -0
  16. package/dist/components/ConsoleBlock.d.ts +12 -0
  17. package/dist/components/ConsoleBlock.d.ts.map +1 -0
  18. package/dist/components/ConsoleBlock.js +81 -0
  19. package/dist/components/ConsoleBlock.js.map +1 -0
  20. package/dist/components/CustomProviderCard.d.ts +17 -0
  21. package/dist/components/CustomProviderCard.d.ts.map +1 -0
  22. package/dist/components/CustomProviderCard.js +112 -0
  23. package/dist/components/CustomProviderCard.js.map +1 -0
  24. package/dist/components/ExpandableSection.d.ts +15 -0
  25. package/dist/components/ExpandableSection.d.ts.map +1 -0
  26. package/dist/components/ExpandableSection.js +61 -0
  27. package/dist/components/ExpandableSection.js.map +1 -0
  28. package/dist/components/Input.d.ts +26 -0
  29. package/dist/components/Input.d.ts.map +1 -0
  30. package/dist/components/Input.js +57 -0
  31. package/dist/components/Input.js.map +1 -0
  32. package/dist/components/MessageEditor.d.ts +44 -0
  33. package/dist/components/MessageEditor.d.ts.map +1 -0
  34. package/dist/components/MessageEditor.js +418 -0
  35. package/dist/components/MessageEditor.js.map +1 -0
  36. package/dist/components/MessageList.d.ts +14 -0
  37. package/dist/components/MessageList.d.ts.map +1 -0
  38. package/dist/components/MessageList.js +104 -0
  39. package/dist/components/MessageList.js.map +1 -0
  40. package/dist/components/Messages.d.ts +95 -0
  41. package/dist/components/Messages.d.ts.map +1 -0
  42. package/dist/components/Messages.js +363 -0
  43. package/dist/components/Messages.js.map +1 -0
  44. package/dist/components/ProviderKeyInput.d.ts +16 -0
  45. package/dist/components/ProviderKeyInput.d.ts.map +1 -0
  46. package/dist/components/ProviderKeyInput.js +168 -0
  47. package/dist/components/ProviderKeyInput.js.map +1 -0
  48. package/dist/components/SandboxedIframe.d.ts +85 -0
  49. package/dist/components/SandboxedIframe.d.ts.map +1 -0
  50. package/dist/components/SandboxedIframe.js +518 -0
  51. package/dist/components/SandboxedIframe.js.map +1 -0
  52. package/dist/components/StreamingMessageContainer.d.ts +19 -0
  53. package/dist/components/StreamingMessageContainer.d.ts.map +1 -0
  54. package/dist/components/StreamingMessageContainer.js +117 -0
  55. package/dist/components/StreamingMessageContainer.js.map +1 -0
  56. package/dist/components/ThinkingBlock.d.ts +11 -0
  57. package/dist/components/ThinkingBlock.d.ts.map +1 -0
  58. package/dist/components/ThinkingBlock.js +56 -0
  59. package/dist/components/ThinkingBlock.js.map +1 -0
  60. package/dist/components/message-renderer-registry.d.ts +12 -0
  61. package/dist/components/message-renderer-registry.d.ts.map +1 -0
  62. package/dist/components/message-renderer-registry.js +12 -0
  63. package/dist/components/message-renderer-registry.js.map +1 -0
  64. package/dist/components/sandbox/ArtifactsRuntimeProvider.d.ts +35 -0
  65. package/dist/components/sandbox/ArtifactsRuntimeProvider.d.ts.map +1 -0
  66. package/dist/components/sandbox/ArtifactsRuntimeProvider.js +192 -0
  67. package/dist/components/sandbox/ArtifactsRuntimeProvider.js.map +1 -0
  68. package/dist/components/sandbox/AttachmentsRuntimeProvider.d.ts +17 -0
  69. package/dist/components/sandbox/AttachmentsRuntimeProvider.d.ts.map +1 -0
  70. package/dist/components/sandbox/AttachmentsRuntimeProvider.js +65 -0
  71. package/dist/components/sandbox/AttachmentsRuntimeProvider.js.map +1 -0
  72. package/dist/components/sandbox/ConsoleRuntimeProvider.d.ts +42 -0
  73. package/dist/components/sandbox/ConsoleRuntimeProvider.d.ts.map +1 -0
  74. package/dist/components/sandbox/ConsoleRuntimeProvider.js +159 -0
  75. package/dist/components/sandbox/ConsoleRuntimeProvider.js.map +1 -0
  76. package/dist/components/sandbox/FileDownloadRuntimeProvider.d.ts +30 -0
  77. package/dist/components/sandbox/FileDownloadRuntimeProvider.d.ts.map +1 -0
  78. package/dist/components/sandbox/FileDownloadRuntimeProvider.js +95 -0
  79. package/dist/components/sandbox/FileDownloadRuntimeProvider.js.map +1 -0
  80. package/dist/components/sandbox/RuntimeMessageBridge.d.ts +19 -0
  81. package/dist/components/sandbox/RuntimeMessageBridge.d.ts.map +1 -0
  82. package/dist/components/sandbox/RuntimeMessageBridge.js +74 -0
  83. package/dist/components/sandbox/RuntimeMessageBridge.js.map +1 -0
  84. package/dist/components/sandbox/RuntimeMessageRouter.d.ts +65 -0
  85. package/dist/components/sandbox/RuntimeMessageRouter.d.ts.map +1 -0
  86. package/dist/components/sandbox/RuntimeMessageRouter.js +166 -0
  87. package/dist/components/sandbox/RuntimeMessageRouter.js.map +1 -0
  88. package/dist/components/sandbox/SandboxRuntimeProvider.d.ts +48 -0
  89. package/dist/components/sandbox/SandboxRuntimeProvider.d.ts.map +1 -0
  90. package/dist/components/sandbox/SandboxRuntimeProvider.js +2 -0
  91. package/dist/components/sandbox/SandboxRuntimeProvider.js.map +1 -0
  92. package/dist/dialogs/ApiKeyPromptDialog.d.ts +15 -0
  93. package/dist/dialogs/ApiKeyPromptDialog.d.ts.map +1 -0
  94. package/dist/dialogs/ApiKeyPromptDialog.js +77 -0
  95. package/dist/dialogs/ApiKeyPromptDialog.js.map +1 -0
  96. package/dist/dialogs/AttachmentOverlay.d.ts +32 -0
  97. package/dist/dialogs/AttachmentOverlay.d.ts.map +1 -0
  98. package/dist/dialogs/AttachmentOverlay.js +576 -0
  99. package/dist/dialogs/AttachmentOverlay.js.map +1 -0
  100. package/dist/dialogs/CustomProviderDialog.d.ts +25 -0
  101. package/dist/dialogs/CustomProviderDialog.d.ts.map +1 -0
  102. package/dist/dialogs/CustomProviderDialog.js +270 -0
  103. package/dist/dialogs/CustomProviderDialog.js.map +1 -0
  104. package/dist/dialogs/ModelSelector.d.ts +27 -0
  105. package/dist/dialogs/ModelSelector.d.ts.map +1 -0
  106. package/dist/dialogs/ModelSelector.js +320 -0
  107. package/dist/dialogs/ModelSelector.js.map +1 -0
  108. package/dist/dialogs/PersistentStorageDialog.d.ts +17 -0
  109. package/dist/dialogs/PersistentStorageDialog.d.ts.map +1 -0
  110. package/dist/dialogs/PersistentStorageDialog.js +144 -0
  111. package/dist/dialogs/PersistentStorageDialog.js.map +1 -0
  112. package/dist/dialogs/ProvidersModelsTab.d.ts +20 -0
  113. package/dist/dialogs/ProvidersModelsTab.d.ts.map +1 -0
  114. package/dist/dialogs/ProvidersModelsTab.js +188 -0
  115. package/dist/dialogs/ProvidersModelsTab.js.map +1 -0
  116. package/dist/dialogs/SessionListDialog.d.ts +19 -0
  117. package/dist/dialogs/SessionListDialog.d.ts.map +1 -0
  118. package/dist/dialogs/SessionListDialog.js +152 -0
  119. package/dist/dialogs/SessionListDialog.js.map +1 -0
  120. package/dist/dialogs/SettingsDialog.d.ts +30 -0
  121. package/dist/dialogs/SettingsDialog.d.ts.map +1 -0
  122. package/dist/dialogs/SettingsDialog.js +222 -0
  123. package/dist/dialogs/SettingsDialog.js.map +1 -0
  124. package/dist/index.d.ts +67 -0
  125. package/dist/index.d.ts.map +1 -0
  126. package/dist/index.js +70 -0
  127. package/dist/index.js.map +1 -0
  128. package/dist/prompts/prompts.d.ts +11 -0
  129. package/dist/prompts/prompts.d.ts.map +1 -0
  130. package/dist/prompts/prompts.js +272 -0
  131. package/dist/prompts/prompts.js.map +1 -0
  132. package/dist/storage/app-storage.d.ts +33 -0
  133. package/dist/storage/app-storage.d.ts.map +1 -0
  134. package/dist/storage/app-storage.js +43 -0
  135. package/dist/storage/app-storage.js.map +1 -0
  136. package/dist/storage/backends/indexeddb-storage-backend.d.ts +27 -0
  137. package/dist/storage/backends/indexeddb-storage-backend.d.ts.map +1 -0
  138. package/dist/storage/backends/indexeddb-storage-backend.js +167 -0
  139. package/dist/storage/backends/indexeddb-storage-backend.js.map +1 -0
  140. package/dist/storage/store.d.ts +23 -0
  141. package/dist/storage/store.d.ts.map +1 -0
  142. package/dist/storage/store.js +24 -0
  143. package/dist/storage/store.js.map +1 -0
  144. package/dist/storage/stores/custom-providers-store.d.ts +25 -0
  145. package/dist/storage/stores/custom-providers-store.d.ts.map +1 -0
  146. package/dist/storage/stores/custom-providers-store.js +35 -0
  147. package/dist/storage/stores/custom-providers-store.js.map +1 -0
  148. package/dist/storage/stores/provider-keys-store.d.ts +14 -0
  149. package/dist/storage/stores/provider-keys-store.d.ts.map +1 -0
  150. package/dist/storage/stores/provider-keys-store.js +27 -0
  151. package/dist/storage/stores/provider-keys-store.js.map +1 -0
  152. package/dist/storage/stores/sessions-store.d.ts +32 -0
  153. package/dist/storage/stores/sessions-store.d.ts.map +1 -0
  154. package/dist/storage/stores/sessions-store.js +113 -0
  155. package/dist/storage/stores/sessions-store.js.map +1 -0
  156. package/dist/storage/stores/settings-store.d.ts +14 -0
  157. package/dist/storage/stores/settings-store.d.ts.map +1 -0
  158. package/dist/storage/stores/settings-store.js +28 -0
  159. package/dist/storage/stores/settings-store.js.map +1 -0
  160. package/dist/storage/types.d.ts +176 -0
  161. package/dist/storage/types.d.ts.map +1 -0
  162. package/dist/storage/types.js +2 -0
  163. package/dist/storage/types.js.map +1 -0
  164. package/dist/tools/artifacts/ArtifactElement.d.ts +9 -0
  165. package/dist/tools/artifacts/ArtifactElement.d.ts.map +1 -0
  166. package/dist/tools/artifacts/ArtifactElement.js +8 -0
  167. package/dist/tools/artifacts/ArtifactElement.js.map +1 -0
  168. package/dist/tools/artifacts/ArtifactPill.d.ts +4 -0
  169. package/dist/tools/artifacts/ArtifactPill.d.ts.map +1 -0
  170. package/dist/tools/artifacts/ArtifactPill.js +23 -0
  171. package/dist/tools/artifacts/ArtifactPill.js.map +1 -0
  172. package/dist/tools/artifacts/Console.d.ts +18 -0
  173. package/dist/tools/artifacts/Console.d.ts.map +1 -0
  174. package/dist/tools/artifacts/Console.js +92 -0
  175. package/dist/tools/artifacts/Console.js.map +1 -0
  176. package/dist/tools/artifacts/DocxArtifact.d.ts +22 -0
  177. package/dist/tools/artifacts/DocxArtifact.d.ts.map +1 -0
  178. package/dist/tools/artifacts/DocxArtifact.js +205 -0
  179. package/dist/tools/artifacts/DocxArtifact.js.map +1 -0
  180. package/dist/tools/artifacts/ExcelArtifact.d.ts +24 -0
  181. package/dist/tools/artifacts/ExcelArtifact.d.ts.map +1 -0
  182. package/dist/tools/artifacts/ExcelArtifact.js +213 -0
  183. package/dist/tools/artifacts/ExcelArtifact.js.map +1 -0
  184. package/dist/tools/artifacts/GenericArtifact.d.ts +19 -0
  185. package/dist/tools/artifacts/GenericArtifact.d.ts.map +1 -0
  186. package/dist/tools/artifacts/GenericArtifact.js +114 -0
  187. package/dist/tools/artifacts/GenericArtifact.js.map +1 -0
  188. package/dist/tools/artifacts/HtmlArtifact.d.ts +27 -0
  189. package/dist/tools/artifacts/HtmlArtifact.d.ts.map +1 -0
  190. package/dist/tools/artifacts/HtmlArtifact.js +187 -0
  191. package/dist/tools/artifacts/HtmlArtifact.js.map +1 -0
  192. package/dist/tools/artifacts/ImageArtifact.d.ts +20 -0
  193. package/dist/tools/artifacts/ImageArtifact.d.ts.map +1 -0
  194. package/dist/tools/artifacts/ImageArtifact.js +117 -0
  195. package/dist/tools/artifacts/ImageArtifact.js.map +1 -0
  196. package/dist/tools/artifacts/MarkdownArtifact.d.ts +19 -0
  197. package/dist/tools/artifacts/MarkdownArtifact.d.ts.map +1 -0
  198. package/dist/tools/artifacts/MarkdownArtifact.js +79 -0
  199. package/dist/tools/artifacts/MarkdownArtifact.js.map +1 -0
  200. package/dist/tools/artifacts/PdfArtifact.d.ts +25 -0
  201. package/dist/tools/artifacts/PdfArtifact.d.ts.map +1 -0
  202. package/dist/tools/artifacts/PdfArtifact.js +181 -0
  203. package/dist/tools/artifacts/PdfArtifact.js.map +1 -0
  204. package/dist/tools/artifacts/SvgArtifact.d.ts +18 -0
  205. package/dist/tools/artifacts/SvgArtifact.d.ts.map +1 -0
  206. package/dist/tools/artifacts/SvgArtifact.js +75 -0
  207. package/dist/tools/artifacts/SvgArtifact.js.map +1 -0
  208. package/dist/tools/artifacts/TextArtifact.d.ts +19 -0
  209. package/dist/tools/artifacts/TextArtifact.d.ts.map +1 -0
  210. package/dist/tools/artifacts/TextArtifact.js +141 -0
  211. package/dist/tools/artifacts/TextArtifact.js.map +1 -0
  212. package/dist/tools/artifacts/artifacts-tool-renderer.d.ts +11 -0
  213. package/dist/tools/artifacts/artifacts-tool-renderer.d.ts.map +1 -0
  214. package/dist/tools/artifacts/artifacts-tool-renderer.js +273 -0
  215. package/dist/tools/artifacts/artifacts-tool-renderer.js.map +1 -0
  216. package/dist/tools/artifacts/artifacts.d.ts +63 -0
  217. package/dist/tools/artifacts/artifacts.d.ts.map +1 -0
  218. package/dist/tools/artifacts/artifacts.js +664 -0
  219. package/dist/tools/artifacts/artifacts.js.map +1 -0
  220. package/dist/tools/artifacts/index.d.ts +8 -0
  221. package/dist/tools/artifacts/index.d.ts.map +1 -0
  222. package/dist/tools/artifacts/index.js +8 -0
  223. package/dist/tools/artifacts/index.js.map +1 -0
  224. package/dist/tools/extract-document.d.ts +24 -0
  225. package/dist/tools/extract-document.d.ts.map +1 -0
  226. package/dist/tools/extract-document.js +216 -0
  227. package/dist/tools/extract-document.js.map +1 -0
  228. package/dist/tools/index.d.ts +16 -0
  229. package/dist/tools/index.d.ts.map +1 -0
  230. package/dist/tools/index.js +33 -0
  231. package/dist/tools/index.js.map +1 -0
  232. package/dist/tools/javascript-repl.d.ts +44 -0
  233. package/dist/tools/javascript-repl.d.ts.map +1 -0
  234. package/dist/tools/javascript-repl.js +224 -0
  235. package/dist/tools/javascript-repl.js.map +1 -0
  236. package/dist/tools/renderer-registry.d.ts +23 -0
  237. package/dist/tools/renderer-registry.d.ts.map +1 -0
  238. package/dist/tools/renderer-registry.js +107 -0
  239. package/dist/tools/renderer-registry.js.map +1 -0
  240. package/dist/tools/renderers/BashRenderer.d.ts +10 -0
  241. package/dist/tools/renderers/BashRenderer.d.ts.map +1 -0
  242. package/dist/tools/renderers/BashRenderer.js +42 -0
  243. package/dist/tools/renderers/BashRenderer.js.map +1 -0
  244. package/dist/tools/renderers/CalculateRenderer.d.ts +10 -0
  245. package/dist/tools/renderers/CalculateRenderer.d.ts.map +1 -0
  246. package/dist/tools/renderers/CalculateRenderer.js +45 -0
  247. package/dist/tools/renderers/CalculateRenderer.js.map +1 -0
  248. package/dist/tools/renderers/DefaultRenderer.d.ts +6 -0
  249. package/dist/tools/renderers/DefaultRenderer.d.ts.map +1 -0
  250. package/dist/tools/renderers/DefaultRenderer.js +94 -0
  251. package/dist/tools/renderers/DefaultRenderer.js.map +1 -0
  252. package/dist/tools/renderers/GetCurrentTimeRenderer.d.ts +10 -0
  253. package/dist/tools/renderers/GetCurrentTimeRenderer.d.ts.map +1 -0
  254. package/dist/tools/renderers/GetCurrentTimeRenderer.js +72 -0
  255. package/dist/tools/renderers/GetCurrentTimeRenderer.js.map +1 -0
  256. package/dist/tools/types.d.ts +10 -0
  257. package/dist/tools/types.d.ts.map +1 -0
  258. package/dist/tools/types.js +2 -0
  259. package/dist/tools/types.js.map +1 -0
  260. package/dist/utils/attachment-utils.d.ts +19 -0
  261. package/dist/utils/attachment-utils.d.ts.map +1 -0
  262. package/dist/utils/attachment-utils.js +415 -0
  263. package/dist/utils/attachment-utils.js.map +1 -0
  264. package/dist/utils/auth-token.d.ts +3 -0
  265. package/dist/utils/auth-token.d.ts.map +1 -0
  266. package/dist/utils/auth-token.js +19 -0
  267. package/dist/utils/auth-token.js.map +1 -0
  268. package/dist/utils/format.d.ts +6 -0
  269. package/dist/utils/format.d.ts.map +1 -0
  270. package/dist/utils/format.js +47 -0
  271. package/dist/utils/format.js.map +1 -0
  272. package/dist/utils/i18n.d.ts +636 -0
  273. package/dist/utils/i18n.d.ts.map +1 -0
  274. package/dist/utils/i18n.js +418 -0
  275. package/dist/utils/i18n.js.map +1 -0
  276. package/dist/utils/model-discovery.d.ts +38 -0
  277. package/dist/utils/model-discovery.d.ts.map +1 -0
  278. package/dist/utils/model-discovery.js +243 -0
  279. package/dist/utils/model-discovery.js.map +1 -0
  280. package/dist/utils/proxy-utils.d.ts +45 -0
  281. package/dist/utils/proxy-utils.d.ts.map +1 -0
  282. package/dist/utils/proxy-utils.js +116 -0
  283. package/dist/utils/proxy-utils.js.map +1 -0
  284. package/dist/utils/test-sessions.d.ts +359 -0
  285. package/dist/utils/test-sessions.d.ts.map +1 -0
  286. package/dist/utils/test-sessions.js +2325 -0
  287. package/dist/utils/test-sessions.js.map +1 -0
  288. package/example/README.md +61 -0
  289. package/example/index.html +13 -0
  290. package/example/package.json +25 -0
  291. package/example/src/app.css +1 -0
  292. package/example/src/custom-messages.ts +99 -0
  293. package/example/src/env.d.ts +1 -0
  294. package/example/src/main.ts +421 -0
  295. package/example/tsconfig.json +23 -0
  296. package/example/vite.config.ts +6 -0
  297. package/package.json +53 -0
  298. package/scripts/count-prompt-tokens.ts +88 -0
  299. package/src/ChatPanel.ts +207 -0
  300. package/src/app.css +68 -0
  301. package/src/components/AgentInterface.ts +388 -0
  302. package/src/components/AttachmentTile.ts +107 -0
  303. package/src/components/ConsoleBlock.ts +72 -0
  304. package/src/components/CustomProviderCard.ts +100 -0
  305. package/src/components/ExpandableSection.ts +46 -0
  306. package/src/components/Input.ts +113 -0
  307. package/src/components/MessageEditor.ts +400 -0
  308. package/src/components/MessageList.ts +95 -0
  309. package/src/components/Messages.ts +383 -0
  310. package/src/components/ProviderKeyInput.ts +153 -0
  311. package/src/components/SandboxedIframe.ts +626 -0
  312. package/src/components/StreamingMessageContainer.ts +103 -0
  313. package/src/components/ThinkingBlock.ts +43 -0
  314. package/src/components/message-renderer-registry.ts +28 -0
  315. package/src/components/sandbox/ArtifactsRuntimeProvider.ts +219 -0
  316. package/src/components/sandbox/AttachmentsRuntimeProvider.ts +66 -0
  317. package/src/components/sandbox/ConsoleRuntimeProvider.ts +186 -0
  318. package/src/components/sandbox/FileDownloadRuntimeProvider.ts +110 -0
  319. package/src/components/sandbox/RuntimeMessageBridge.ts +82 -0
  320. package/src/components/sandbox/RuntimeMessageRouter.ts +216 -0
  321. package/src/components/sandbox/SandboxRuntimeProvider.ts +52 -0
  322. package/src/dialogs/ApiKeyPromptDialog.ts +75 -0
  323. package/src/dialogs/AttachmentOverlay.ts +636 -0
  324. package/src/dialogs/CustomProviderDialog.ts +274 -0
  325. package/src/dialogs/ModelSelector.ts +313 -0
  326. package/src/dialogs/PersistentStorageDialog.ts +144 -0
  327. package/src/dialogs/ProvidersModelsTab.ts +212 -0
  328. package/src/dialogs/SessionListDialog.ts +150 -0
  329. package/src/dialogs/SettingsDialog.ts +214 -0
  330. package/src/index.ts +119 -0
  331. package/src/prompts/prompts.ts +282 -0
  332. package/src/storage/app-storage.ts +60 -0
  333. package/src/storage/backends/indexeddb-storage-backend.ts +193 -0
  334. package/src/storage/store.ts +33 -0
  335. package/src/storage/stores/custom-providers-store.ts +62 -0
  336. package/src/storage/stores/provider-keys-store.ts +33 -0
  337. package/src/storage/stores/sessions-store.ts +136 -0
  338. package/src/storage/stores/settings-store.ts +34 -0
  339. package/src/storage/types.ts +206 -0
  340. package/src/tools/artifacts/ArtifactElement.ts +14 -0
  341. package/src/tools/artifacts/ArtifactPill.ts +26 -0
  342. package/src/tools/artifacts/Console.ts +93 -0
  343. package/src/tools/artifacts/DocxArtifact.ts +213 -0
  344. package/src/tools/artifacts/ExcelArtifact.ts +231 -0
  345. package/src/tools/artifacts/GenericArtifact.ts +117 -0
  346. package/src/tools/artifacts/HtmlArtifact.ts +195 -0
  347. package/src/tools/artifacts/ImageArtifact.ts +116 -0
  348. package/src/tools/artifacts/MarkdownArtifact.ts +82 -0
  349. package/src/tools/artifacts/PdfArtifact.ts +201 -0
  350. package/src/tools/artifacts/SvgArtifact.ts +78 -0
  351. package/src/tools/artifacts/TextArtifact.ts +148 -0
  352. package/src/tools/artifacts/artifacts-tool-renderer.ts +310 -0
  353. package/src/tools/artifacts/artifacts.ts +713 -0
  354. package/src/tools/artifacts/index.ts +7 -0
  355. package/src/tools/extract-document.ts +275 -0
  356. package/src/tools/index.ts +46 -0
  357. package/src/tools/javascript-repl.ts +293 -0
  358. package/src/tools/renderer-registry.ts +130 -0
  359. package/src/tools/renderers/BashRenderer.ts +52 -0
  360. package/src/tools/renderers/CalculateRenderer.ts +58 -0
  361. package/src/tools/renderers/DefaultRenderer.ts +103 -0
  362. package/src/tools/renderers/GetCurrentTimeRenderer.ts +92 -0
  363. package/src/tools/types.ts +15 -0
  364. package/src/utils/attachment-utils.ts +472 -0
  365. package/src/utils/auth-token.ts +22 -0
  366. package/src/utils/format.ts +42 -0
  367. package/src/utils/i18n.ts +653 -0
  368. package/src/utils/model-discovery.ts +277 -0
  369. package/src/utils/proxy-utils.ts +134 -0
  370. package/src/utils/test-sessions.ts +2357 -0
  371. package/tsconfig.build.json +20 -0
  372. package/tsconfig.json +7 -0
@@ -0,0 +1,664 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { icon } from "@mariozechner/mini-lit";
8
+ import "@mariozechner/mini-lit/dist/MarkdownBlock.js";
9
+ import { StringEnum } from "@draht/ai";
10
+ import { Button } from "@mariozechner/mini-lit/dist/Button.js";
11
+ import { Type } from "@sinclair/typebox";
12
+ import { html, LitElement } from "lit";
13
+ import { customElement, property, state } from "lit/decorators.js";
14
+ import { createRef, ref } from "lit/directives/ref.js";
15
+ import { X } from "lucide";
16
+ import { ArtifactsRuntimeProvider } from "../../components/sandbox/ArtifactsRuntimeProvider.js";
17
+ import { AttachmentsRuntimeProvider } from "../../components/sandbox/AttachmentsRuntimeProvider.js";
18
+ import { ARTIFACTS_RUNTIME_PROVIDER_DESCRIPTION_RO, ARTIFACTS_TOOL_DESCRIPTION, ATTACHMENTS_RUNTIME_DESCRIPTION, } from "../../prompts/prompts.js";
19
+ import { i18n } from "../../utils/i18n.js";
20
+ import { DocxArtifact } from "./DocxArtifact.js";
21
+ import { ExcelArtifact } from "./ExcelArtifact.js";
22
+ import { GenericArtifact } from "./GenericArtifact.js";
23
+ import { HtmlArtifact } from "./HtmlArtifact.js";
24
+ import { ImageArtifact } from "./ImageArtifact.js";
25
+ import { MarkdownArtifact } from "./MarkdownArtifact.js";
26
+ import { PdfArtifact } from "./PdfArtifact.js";
27
+ import { SvgArtifact } from "./SvgArtifact.js";
28
+ import { TextArtifact } from "./TextArtifact.js";
29
+ // JSON-schema friendly parameters object (LLM-facing)
30
+ const artifactsParamsSchema = Type.Object({
31
+ command: StringEnum(["create", "update", "rewrite", "get", "delete", "logs"], {
32
+ description: "The operation to perform",
33
+ }),
34
+ filename: Type.String({ description: "Filename including extension (e.g., 'index.html', 'script.js')" }),
35
+ content: Type.Optional(Type.String({ description: "File content" })),
36
+ old_str: Type.Optional(Type.String({ description: "String to replace (for update command)" })),
37
+ new_str: Type.Optional(Type.String({ description: "Replacement string (for update command)" })),
38
+ });
39
+ let ArtifactsPanel = class ArtifactsPanel extends LitElement {
40
+ _artifacts = new Map();
41
+ _activeFilename = null;
42
+ // Programmatically managed artifact elements
43
+ artifactElements = new Map();
44
+ contentRef = createRef();
45
+ // Agent reference (needed to get attachments for HTML artifacts)
46
+ agent;
47
+ // Sandbox URL provider for browser extensions (optional)
48
+ sandboxUrlProvider;
49
+ // Callbacks
50
+ onArtifactsChange;
51
+ onClose;
52
+ onOpen;
53
+ // Collapsed mode: hides panel content but can show a floating reopen pill
54
+ collapsed = false;
55
+ // Overlay mode: when true, panel renders full-screen overlay (mobile)
56
+ overlay = false;
57
+ // Public getter for artifacts
58
+ get artifacts() {
59
+ return this._artifacts;
60
+ }
61
+ // Get runtime providers for HTML artifacts (read-only: attachments + artifacts)
62
+ getHtmlArtifactRuntimeProviders() {
63
+ const providers = [];
64
+ // Get attachments from agent messages
65
+ if (this.agent) {
66
+ const attachments = [];
67
+ for (const message of this.agent.state.messages) {
68
+ if (message.role === "user-with-attachments" && message.attachments) {
69
+ attachments.push(...message.attachments);
70
+ }
71
+ }
72
+ if (attachments.length > 0) {
73
+ providers.push(new AttachmentsRuntimeProvider(attachments));
74
+ }
75
+ }
76
+ // Add read-only artifacts provider
77
+ providers.push(new ArtifactsRuntimeProvider(this, this.agent, false));
78
+ return providers;
79
+ }
80
+ createRenderRoot() {
81
+ return this; // light DOM for shared styles
82
+ }
83
+ connectedCallback() {
84
+ super.connectedCallback();
85
+ this.style.display = "block";
86
+ this.style.height = "100%";
87
+ // Reattach existing artifact elements when panel is re-inserted into the DOM
88
+ requestAnimationFrame(() => {
89
+ const container = this.contentRef.value;
90
+ if (!container)
91
+ return;
92
+ // Ensure we have an active filename
93
+ if (!this._activeFilename && this._artifacts.size > 0) {
94
+ this._activeFilename = Array.from(this._artifacts.keys())[0];
95
+ }
96
+ this.artifactElements.forEach((element, name) => {
97
+ if (!element.parentElement)
98
+ container.appendChild(element);
99
+ element.style.display = name === this._activeFilename ? "block" : "none";
100
+ });
101
+ });
102
+ }
103
+ disconnectedCallback() {
104
+ super.disconnectedCallback();
105
+ // Do not tear down artifact elements; keep them to restore on next mount
106
+ }
107
+ // Helper to determine file type from extension
108
+ getFileType(filename) {
109
+ const ext = filename.split(".").pop()?.toLowerCase();
110
+ if (ext === "html")
111
+ return "html";
112
+ if (ext === "svg")
113
+ return "svg";
114
+ if (ext === "md" || ext === "markdown")
115
+ return "markdown";
116
+ if (ext === "pdf")
117
+ return "pdf";
118
+ if (ext === "xlsx" || ext === "xls")
119
+ return "excel";
120
+ if (ext === "docx")
121
+ return "docx";
122
+ if (ext === "png" ||
123
+ ext === "jpg" ||
124
+ ext === "jpeg" ||
125
+ ext === "gif" ||
126
+ ext === "webp" ||
127
+ ext === "bmp" ||
128
+ ext === "ico")
129
+ return "image";
130
+ // Text files
131
+ if (ext === "txt" ||
132
+ ext === "json" ||
133
+ ext === "xml" ||
134
+ ext === "yaml" ||
135
+ ext === "yml" ||
136
+ ext === "csv" ||
137
+ ext === "js" ||
138
+ ext === "ts" ||
139
+ ext === "jsx" ||
140
+ ext === "tsx" ||
141
+ ext === "py" ||
142
+ ext === "java" ||
143
+ ext === "c" ||
144
+ ext === "cpp" ||
145
+ ext === "h" ||
146
+ ext === "css" ||
147
+ ext === "scss" ||
148
+ ext === "sass" ||
149
+ ext === "less" ||
150
+ ext === "sh")
151
+ return "text";
152
+ // Everything else gets generic fallback
153
+ return "generic";
154
+ }
155
+ // Get or create artifact element
156
+ getOrCreateArtifactElement(filename, content) {
157
+ let element = this.artifactElements.get(filename);
158
+ if (!element) {
159
+ const type = this.getFileType(filename);
160
+ if (type === "html") {
161
+ element = new HtmlArtifact();
162
+ element.runtimeProviders = this.getHtmlArtifactRuntimeProviders();
163
+ if (this.sandboxUrlProvider) {
164
+ element.sandboxUrlProvider = this.sandboxUrlProvider;
165
+ }
166
+ }
167
+ else if (type === "svg") {
168
+ element = new SvgArtifact();
169
+ }
170
+ else if (type === "markdown") {
171
+ element = new MarkdownArtifact();
172
+ }
173
+ else if (type === "image") {
174
+ element = new ImageArtifact();
175
+ }
176
+ else if (type === "pdf") {
177
+ element = new PdfArtifact();
178
+ }
179
+ else if (type === "excel") {
180
+ element = new ExcelArtifact();
181
+ }
182
+ else if (type === "docx") {
183
+ element = new DocxArtifact();
184
+ }
185
+ else if (type === "text") {
186
+ element = new TextArtifact();
187
+ }
188
+ else {
189
+ element = new GenericArtifact();
190
+ }
191
+ element.filename = filename;
192
+ element.content = content;
193
+ element.style.display = "none";
194
+ element.style.height = "100%";
195
+ // Store element
196
+ this.artifactElements.set(filename, element);
197
+ // Add to DOM - try immediately if container exists, otherwise schedule
198
+ const newElement = element;
199
+ if (this.contentRef.value) {
200
+ this.contentRef.value.appendChild(newElement);
201
+ }
202
+ else {
203
+ requestAnimationFrame(() => {
204
+ if (this.contentRef.value && !newElement.parentElement) {
205
+ this.contentRef.value.appendChild(newElement);
206
+ }
207
+ });
208
+ }
209
+ }
210
+ else {
211
+ // Just update content
212
+ element.content = content;
213
+ if (element instanceof HtmlArtifact) {
214
+ element.runtimeProviders = this.getHtmlArtifactRuntimeProviders();
215
+ }
216
+ }
217
+ return element;
218
+ }
219
+ // Show/hide artifact elements
220
+ showArtifact(filename) {
221
+ // Ensure the active element is in the DOM
222
+ requestAnimationFrame(() => {
223
+ this.artifactElements.forEach((element, name) => {
224
+ if (this.contentRef.value && !element.parentElement) {
225
+ this.contentRef.value.appendChild(element);
226
+ }
227
+ element.style.display = name === filename ? "block" : "none";
228
+ });
229
+ });
230
+ this._activeFilename = filename;
231
+ this.requestUpdate(); // Only for tab bar update
232
+ // Scroll the active tab into view after render
233
+ requestAnimationFrame(() => {
234
+ const activeButton = this.querySelector(`button[data-filename="${filename}"]`);
235
+ if (activeButton) {
236
+ activeButton.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "center" });
237
+ }
238
+ });
239
+ }
240
+ // Open panel and focus an artifact tab by filename
241
+ openArtifact(filename) {
242
+ if (this._artifacts.has(filename)) {
243
+ this.showArtifact(filename);
244
+ // Ask host to open panel (AgentInterface demo listens to onOpen)
245
+ this.onOpen?.();
246
+ }
247
+ }
248
+ // Build the AgentTool (no details payload; return only output strings)
249
+ get tool() {
250
+ return {
251
+ label: "Artifacts",
252
+ name: "artifacts",
253
+ get description() {
254
+ // HTML artifacts have read-only access to attachments and artifacts
255
+ const runtimeProviderDescriptions = [
256
+ ATTACHMENTS_RUNTIME_DESCRIPTION,
257
+ ARTIFACTS_RUNTIME_PROVIDER_DESCRIPTION_RO,
258
+ ];
259
+ return ARTIFACTS_TOOL_DESCRIPTION(runtimeProviderDescriptions);
260
+ },
261
+ parameters: artifactsParamsSchema,
262
+ // Execute mutates our local store and returns a plain output
263
+ execute: async (_toolCallId, args, _signal) => {
264
+ const output = await this.executeCommand(args);
265
+ return { content: [{ type: "text", text: output }], details: undefined };
266
+ },
267
+ };
268
+ }
269
+ // Re-apply artifacts by scanning a message list (optional utility)
270
+ async reconstructFromMessages(messages) {
271
+ const toolCalls = new Map();
272
+ const artifactToolName = "artifacts";
273
+ // 1) Collect tool calls from assistant messages
274
+ for (const message of messages) {
275
+ if (message.role === "assistant") {
276
+ for (const block of message.content) {
277
+ if (block.type === "toolCall" && block.name === artifactToolName) {
278
+ toolCalls.set(block.id, block);
279
+ }
280
+ }
281
+ }
282
+ }
283
+ // 2) Build an ordered list of successful artifact operations
284
+ const operations = [];
285
+ for (const m of messages) {
286
+ if (m.role === "artifact") {
287
+ const artifactMsg = m;
288
+ switch (artifactMsg.action) {
289
+ case "create":
290
+ operations.push({
291
+ command: "create",
292
+ filename: artifactMsg.filename,
293
+ content: artifactMsg.content,
294
+ });
295
+ break;
296
+ case "update":
297
+ operations.push({
298
+ command: "rewrite",
299
+ filename: artifactMsg.filename,
300
+ content: artifactMsg.content,
301
+ });
302
+ break;
303
+ case "delete":
304
+ operations.push({
305
+ command: "delete",
306
+ filename: artifactMsg.filename,
307
+ });
308
+ break;
309
+ }
310
+ }
311
+ // Handle tool result messages (from artifacts tool calls)
312
+ else if (m.role === "toolResult" && m.toolName === artifactToolName && !m.isError) {
313
+ const toolCallId = m.toolCallId;
314
+ const call = toolCalls.get(toolCallId);
315
+ if (!call)
316
+ continue;
317
+ const params = call.arguments;
318
+ if (params.command === "get" || params.command === "logs")
319
+ continue; // no state change
320
+ operations.push(params);
321
+ }
322
+ }
323
+ // 3) Compute final state per filename by simulating operations in-memory
324
+ const finalArtifacts = new Map();
325
+ for (const op of operations) {
326
+ const filename = op.filename;
327
+ switch (op.command) {
328
+ case "create": {
329
+ if (op.content) {
330
+ finalArtifacts.set(filename, op.content);
331
+ }
332
+ break;
333
+ }
334
+ case "rewrite": {
335
+ if (op.content) {
336
+ finalArtifacts.set(filename, op.content);
337
+ }
338
+ break;
339
+ }
340
+ case "update": {
341
+ let existing = finalArtifacts.get(filename);
342
+ if (!existing)
343
+ break; // skip invalid update (shouldn't happen for successful results)
344
+ if (op.old_str !== undefined && op.new_str !== undefined) {
345
+ existing = existing.replace(op.old_str, op.new_str);
346
+ finalArtifacts.set(filename, existing);
347
+ }
348
+ break;
349
+ }
350
+ case "delete": {
351
+ finalArtifacts.delete(filename);
352
+ break;
353
+ }
354
+ case "get":
355
+ case "logs":
356
+ // Ignored above, just for completeness
357
+ break;
358
+ }
359
+ }
360
+ // 4) Reset current UI state before bulk create
361
+ this._artifacts.clear();
362
+ this.artifactElements.forEach((el) => {
363
+ el.remove();
364
+ });
365
+ this.artifactElements.clear();
366
+ this._activeFilename = null;
367
+ this._artifacts = new Map(this._artifacts);
368
+ // 5) Create artifacts in a single pass without waiting for iframe execution or tab switching
369
+ for (const [filename, content] of finalArtifacts.entries()) {
370
+ const createParams = { command: "create", filename, content };
371
+ try {
372
+ await this.createArtifact(createParams, { skipWait: true, silent: true });
373
+ }
374
+ catch {
375
+ // Ignore failures during reconstruction
376
+ }
377
+ }
378
+ // 6) Show first artifact if any exist, and notify listeners once
379
+ if (!this._activeFilename && this._artifacts.size > 0) {
380
+ this.showArtifact(Array.from(this._artifacts.keys())[0]);
381
+ }
382
+ this.onArtifactsChange?.();
383
+ this.requestUpdate();
384
+ }
385
+ // Core command executor
386
+ async executeCommand(params, options = {}) {
387
+ switch (params.command) {
388
+ case "create":
389
+ return await this.createArtifact(params, options);
390
+ case "update":
391
+ return await this.updateArtifact(params, options);
392
+ case "rewrite":
393
+ return await this.rewriteArtifact(params, options);
394
+ case "get":
395
+ return this.getArtifact(params);
396
+ case "delete":
397
+ return this.deleteArtifact(params);
398
+ case "logs":
399
+ return this.getLogs(params);
400
+ default:
401
+ // Should never happen with TypeBox validation
402
+ return `Error: Unknown command ${params.command}`;
403
+ }
404
+ }
405
+ // Wait for HTML artifact execution and get logs
406
+ async waitForHtmlExecution(filename) {
407
+ const element = this.artifactElements.get(filename);
408
+ if (!(element instanceof HtmlArtifact)) {
409
+ return "";
410
+ }
411
+ return new Promise((resolve) => {
412
+ // Fallback timeout - just get logs after execution should complete
413
+ setTimeout(() => {
414
+ // Get whatever logs we have
415
+ const logs = element.getLogs();
416
+ resolve(logs);
417
+ }, 1500);
418
+ });
419
+ }
420
+ // Reload all HTML artifacts (called when any artifact changes)
421
+ reloadAllHtmlArtifacts() {
422
+ this.artifactElements.forEach((element) => {
423
+ if (element instanceof HtmlArtifact && element.sandboxIframeRef.value) {
424
+ // Update runtime providers with latest artifact state
425
+ element.runtimeProviders = this.getHtmlArtifactRuntimeProviders();
426
+ // Re-execute the HTML content
427
+ element.executeContent(element.content);
428
+ }
429
+ });
430
+ }
431
+ async createArtifact(params, options = {}) {
432
+ if (!params.filename || !params.content) {
433
+ return "Error: create command requires filename and content";
434
+ }
435
+ if (this._artifacts.has(params.filename)) {
436
+ return `Error: File ${params.filename} already exists`;
437
+ }
438
+ const artifact = {
439
+ filename: params.filename,
440
+ content: params.content,
441
+ createdAt: new Date(),
442
+ updatedAt: new Date(),
443
+ };
444
+ this._artifacts.set(params.filename, artifact);
445
+ this._artifacts = new Map(this._artifacts);
446
+ // Create or update element
447
+ this.getOrCreateArtifactElement(params.filename, params.content);
448
+ if (!options.silent) {
449
+ this.showArtifact(params.filename);
450
+ this.onArtifactsChange?.();
451
+ this.requestUpdate();
452
+ }
453
+ // Reload all HTML artifacts since they might depend on this new artifact
454
+ this.reloadAllHtmlArtifacts();
455
+ // For HTML files, wait for execution
456
+ let result = `Created file ${params.filename}`;
457
+ if (this.getFileType(params.filename) === "html" && !options.skipWait) {
458
+ const logs = await this.waitForHtmlExecution(params.filename);
459
+ result += `\n${logs}`;
460
+ }
461
+ return result;
462
+ }
463
+ async updateArtifact(params, options = {}) {
464
+ const artifact = this._artifacts.get(params.filename);
465
+ if (!artifact) {
466
+ const files = Array.from(this._artifacts.keys());
467
+ if (files.length === 0)
468
+ return `Error: File ${params.filename} not found. No files have been created yet.`;
469
+ return `Error: File ${params.filename} not found. Available files: ${files.join(", ")}`;
470
+ }
471
+ if (!params.old_str || params.new_str === undefined) {
472
+ return "Error: update command requires old_str and new_str";
473
+ }
474
+ if (!artifact.content.includes(params.old_str)) {
475
+ return `Error: String not found in file. Here is the full content:\n\n${artifact.content}`;
476
+ }
477
+ artifact.content = artifact.content.replace(params.old_str, params.new_str);
478
+ artifact.updatedAt = new Date();
479
+ this._artifacts.set(params.filename, artifact);
480
+ // Update element
481
+ this.getOrCreateArtifactElement(params.filename, artifact.content);
482
+ if (!options.silent) {
483
+ this.onArtifactsChange?.();
484
+ this.requestUpdate();
485
+ }
486
+ // Show the artifact
487
+ this.showArtifact(params.filename);
488
+ // Reload all HTML artifacts since they might depend on this updated artifact
489
+ this.reloadAllHtmlArtifacts();
490
+ // For HTML files, wait for execution
491
+ let result = `Updated file ${params.filename}`;
492
+ if (this.getFileType(params.filename) === "html" && !options.skipWait) {
493
+ const logs = await this.waitForHtmlExecution(params.filename);
494
+ result += `\n${logs}`;
495
+ }
496
+ return result;
497
+ }
498
+ async rewriteArtifact(params, options = {}) {
499
+ const artifact = this._artifacts.get(params.filename);
500
+ if (!artifact) {
501
+ const files = Array.from(this._artifacts.keys());
502
+ if (files.length === 0)
503
+ return `Error: File ${params.filename} not found. No files have been created yet.`;
504
+ return `Error: File ${params.filename} not found. Available files: ${files.join(", ")}`;
505
+ }
506
+ if (!params.content) {
507
+ return "Error: rewrite command requires content";
508
+ }
509
+ artifact.content = params.content;
510
+ artifact.updatedAt = new Date();
511
+ this._artifacts.set(params.filename, artifact);
512
+ // Update element
513
+ this.getOrCreateArtifactElement(params.filename, artifact.content);
514
+ if (!options.silent) {
515
+ this.onArtifactsChange?.();
516
+ }
517
+ // Show the artifact
518
+ this.showArtifact(params.filename);
519
+ // Reload all HTML artifacts since they might depend on this rewritten artifact
520
+ this.reloadAllHtmlArtifacts();
521
+ // For HTML files, wait for execution
522
+ let result = "";
523
+ if (this.getFileType(params.filename) === "html" && !options.skipWait) {
524
+ const logs = await this.waitForHtmlExecution(params.filename);
525
+ result += `\n${logs}`;
526
+ }
527
+ return result;
528
+ }
529
+ getArtifact(params) {
530
+ const artifact = this._artifacts.get(params.filename);
531
+ if (!artifact) {
532
+ const files = Array.from(this._artifacts.keys());
533
+ if (files.length === 0)
534
+ return `Error: File ${params.filename} not found. No files have been created yet.`;
535
+ return `Error: File ${params.filename} not found. Available files: ${files.join(", ")}`;
536
+ }
537
+ return artifact.content;
538
+ }
539
+ deleteArtifact(params) {
540
+ const artifact = this._artifacts.get(params.filename);
541
+ if (!artifact) {
542
+ const files = Array.from(this._artifacts.keys());
543
+ if (files.length === 0)
544
+ return `Error: File ${params.filename} not found. No files have been created yet.`;
545
+ return `Error: File ${params.filename} not found. Available files: ${files.join(", ")}`;
546
+ }
547
+ this._artifacts.delete(params.filename);
548
+ this._artifacts = new Map(this._artifacts);
549
+ // Remove element
550
+ const element = this.artifactElements.get(params.filename);
551
+ if (element) {
552
+ element.remove();
553
+ this.artifactElements.delete(params.filename);
554
+ }
555
+ // Show another artifact if this was active
556
+ if (this._activeFilename === params.filename) {
557
+ const remaining = Array.from(this._artifacts.keys());
558
+ if (remaining.length > 0) {
559
+ this.showArtifact(remaining[0]);
560
+ }
561
+ else {
562
+ this._activeFilename = null;
563
+ this.requestUpdate();
564
+ }
565
+ }
566
+ this.onArtifactsChange?.();
567
+ this.requestUpdate();
568
+ // Reload all HTML artifacts since they might have depended on this deleted artifact
569
+ this.reloadAllHtmlArtifacts();
570
+ return `Deleted file ${params.filename}`;
571
+ }
572
+ getLogs(params) {
573
+ const element = this.artifactElements.get(params.filename);
574
+ if (!element) {
575
+ const files = Array.from(this._artifacts.keys());
576
+ if (files.length === 0)
577
+ return `Error: File ${params.filename} not found. No files have been created yet.`;
578
+ return `Error: File ${params.filename} not found. Available files: ${files.join(", ")}`;
579
+ }
580
+ if (!(element instanceof HtmlArtifact)) {
581
+ return `Error: File ${params.filename} is not an HTML file. Logs are only available for HTML files.`;
582
+ }
583
+ return element.getLogs();
584
+ }
585
+ render() {
586
+ const artifacts = Array.from(this._artifacts.values());
587
+ // Panel is hidden when collapsed OR when there are no artifacts
588
+ const showPanel = artifacts.length > 0 && !this.collapsed;
589
+ return html `
590
+ <div
591
+ class="${showPanel ? "" : "hidden"} ${this.overlay ? "fixed inset-0 z-40 pointer-events-auto backdrop-blur-sm bg-background/95" : "relative"} h-full flex flex-col bg-background text-card-foreground ${!this.overlay ? "border-l border-border" : ""} overflow-hidden shadow-xl"
592
+ >
593
+ <!-- Tab bar (always shown when there are artifacts) -->
594
+ <div class="flex items-center justify-between border-b border-border bg-background">
595
+ <div class="flex overflow-x-auto">
596
+ ${artifacts.map((a) => {
597
+ const isActive = a.filename === this._activeFilename;
598
+ const activeClass = isActive
599
+ ? "border-primary text-primary"
600
+ : "border-transparent text-muted-foreground hover:text-foreground";
601
+ return html `
602
+ <button
603
+ class="px-3 py-2 whitespace-nowrap border-b-2 ${activeClass}"
604
+ data-filename="${a.filename}"
605
+ @click=${() => this.showArtifact(a.filename)}
606
+ >
607
+ <span class="font-mono text-xs">${a.filename}</span>
608
+ </button>
609
+ `;
610
+ })}
611
+ </div>
612
+ <div class="flex items-center gap-1 px-2">
613
+ ${(() => {
614
+ const active = this._activeFilename ? this.artifactElements.get(this._activeFilename) : undefined;
615
+ return active ? active.getHeaderButtons() : "";
616
+ })()}
617
+ ${Button({
618
+ variant: "ghost",
619
+ size: "sm",
620
+ onClick: () => this.onClose?.(),
621
+ title: i18n("Close artifacts"),
622
+ children: icon(X, "sm"),
623
+ })}
624
+ </div>
625
+ </div>
626
+
627
+ <!-- Content area where artifact elements are added programmatically -->
628
+ <div class="flex-1 overflow-hidden" ${ref(this.contentRef)}></div>
629
+ </div>
630
+ `;
631
+ }
632
+ };
633
+ __decorate([
634
+ state()
635
+ ], ArtifactsPanel.prototype, "_artifacts", void 0);
636
+ __decorate([
637
+ state()
638
+ ], ArtifactsPanel.prototype, "_activeFilename", void 0);
639
+ __decorate([
640
+ property({ attribute: false })
641
+ ], ArtifactsPanel.prototype, "agent", void 0);
642
+ __decorate([
643
+ property({ attribute: false })
644
+ ], ArtifactsPanel.prototype, "sandboxUrlProvider", void 0);
645
+ __decorate([
646
+ property({ attribute: false })
647
+ ], ArtifactsPanel.prototype, "onArtifactsChange", void 0);
648
+ __decorate([
649
+ property({ attribute: false })
650
+ ], ArtifactsPanel.prototype, "onClose", void 0);
651
+ __decorate([
652
+ property({ attribute: false })
653
+ ], ArtifactsPanel.prototype, "onOpen", void 0);
654
+ __decorate([
655
+ property({ type: Boolean })
656
+ ], ArtifactsPanel.prototype, "collapsed", void 0);
657
+ __decorate([
658
+ property({ type: Boolean })
659
+ ], ArtifactsPanel.prototype, "overlay", void 0);
660
+ ArtifactsPanel = __decorate([
661
+ customElement("artifacts-panel")
662
+ ], ArtifactsPanel);
663
+ export { ArtifactsPanel };
664
+ //# sourceMappingURL=artifacts.js.map