@ouhuang/pi-web-ui 0.65.1

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