@elyracode/web-ui 0.9.58 → 1.0.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 (95) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/components/SandboxedIframe.d.ts +15 -1
  3. package/dist/components/SandboxedIframe.d.ts.map +1 -1
  4. package/dist/components/SandboxedIframe.js +129 -67
  5. package/dist/components/SandboxedIframe.js.map +1 -1
  6. package/dist/components/sandbox/RuntimeMessageRouter.d.ts +12 -2
  7. package/dist/components/sandbox/RuntimeMessageRouter.d.ts.map +1 -1
  8. package/dist/components/sandbox/RuntimeMessageRouter.js +26 -2
  9. package/dist/components/sandbox/RuntimeMessageRouter.js.map +1 -1
  10. package/package.json +18 -8
  11. package/example/README.md +0 -61
  12. package/example/index.html +0 -13
  13. package/example/package.json +0 -25
  14. package/example/src/app.css +0 -1
  15. package/example/src/css-modules.d.ts +0 -3
  16. package/example/src/custom-messages.ts +0 -99
  17. package/example/src/main.ts +0 -421
  18. package/example/tsconfig.json +0 -23
  19. package/example/vite.config.ts +0 -6
  20. package/scripts/count-prompt-tokens.ts +0 -88
  21. package/src/ChatPanel.ts +0 -209
  22. package/src/app.css +0 -68
  23. package/src/components/AgentInterface.ts +0 -403
  24. package/src/components/AttachmentTile.ts +0 -107
  25. package/src/components/ConsoleBlock.ts +0 -72
  26. package/src/components/CustomProviderCard.ts +0 -100
  27. package/src/components/ExpandableSection.ts +0 -46
  28. package/src/components/Input.ts +0 -113
  29. package/src/components/MessageEditor.ts +0 -405
  30. package/src/components/MessageList.ts +0 -98
  31. package/src/components/Messages.ts +0 -383
  32. package/src/components/ProviderKeyInput.ts +0 -153
  33. package/src/components/SandboxedIframe.ts +0 -627
  34. package/src/components/StreamingMessageContainer.ts +0 -103
  35. package/src/components/ThinkingBlock.ts +0 -43
  36. package/src/components/message-renderer-registry.ts +0 -28
  37. package/src/components/sandbox/ArtifactsRuntimeProvider.ts +0 -226
  38. package/src/components/sandbox/AttachmentsRuntimeProvider.ts +0 -68
  39. package/src/components/sandbox/ConsoleRuntimeProvider.ts +0 -188
  40. package/src/components/sandbox/FileDownloadRuntimeProvider.ts +0 -114
  41. package/src/components/sandbox/RuntimeMessageBridge.ts +0 -82
  42. package/src/components/sandbox/RuntimeMessageRouter.ts +0 -215
  43. package/src/components/sandbox/SandboxRuntimeProvider.ts +0 -54
  44. package/src/components/sandbox/runtime-messages.ts +0 -146
  45. package/src/dialogs/ApiKeyPromptDialog.ts +0 -75
  46. package/src/dialogs/AttachmentOverlay.ts +0 -637
  47. package/src/dialogs/CustomProviderDialog.ts +0 -274
  48. package/src/dialogs/ModelSelector.ts +0 -370
  49. package/src/dialogs/PersistentStorageDialog.ts +0 -144
  50. package/src/dialogs/ProvidersModelsTab.ts +0 -212
  51. package/src/dialogs/SessionListDialog.ts +0 -150
  52. package/src/dialogs/SettingsDialog.ts +0 -218
  53. package/src/index.ts +0 -120
  54. package/src/prompts/prompts.ts +0 -282
  55. package/src/storage/app-storage.ts +0 -60
  56. package/src/storage/backends/indexeddb-storage-backend.ts +0 -193
  57. package/src/storage/store.ts +0 -33
  58. package/src/storage/stores/custom-providers-store.ts +0 -62
  59. package/src/storage/stores/provider-keys-store.ts +0 -33
  60. package/src/storage/stores/sessions-store.ts +0 -136
  61. package/src/storage/stores/settings-store.ts +0 -34
  62. package/src/storage/types.ts +0 -206
  63. package/src/tools/artifacts/ArtifactElement.ts +0 -14
  64. package/src/tools/artifacts/ArtifactPill.ts +0 -26
  65. package/src/tools/artifacts/Console.ts +0 -93
  66. package/src/tools/artifacts/DocxArtifact.ts +0 -213
  67. package/src/tools/artifacts/ExcelArtifact.ts +0 -231
  68. package/src/tools/artifacts/GenericArtifact.ts +0 -117
  69. package/src/tools/artifacts/HtmlArtifact.ts +0 -195
  70. package/src/tools/artifacts/ImageArtifact.ts +0 -116
  71. package/src/tools/artifacts/MarkdownArtifact.ts +0 -82
  72. package/src/tools/artifacts/PdfArtifact.ts +0 -202
  73. package/src/tools/artifacts/SvgArtifact.ts +0 -119
  74. package/src/tools/artifacts/TextArtifact.ts +0 -148
  75. package/src/tools/artifacts/artifacts-tool-renderer.ts +0 -310
  76. package/src/tools/artifacts/artifacts.ts +0 -713
  77. package/src/tools/artifacts/index.ts +0 -7
  78. package/src/tools/extract-document.ts +0 -275
  79. package/src/tools/index.ts +0 -46
  80. package/src/tools/javascript-repl.ts +0 -293
  81. package/src/tools/renderer-registry.ts +0 -130
  82. package/src/tools/renderers/BashRenderer.ts +0 -52
  83. package/src/tools/renderers/CalculateRenderer.ts +0 -58
  84. package/src/tools/renderers/DefaultRenderer.ts +0 -103
  85. package/src/tools/renderers/GetCurrentTimeRenderer.ts +0 -92
  86. package/src/tools/types.ts +0 -15
  87. package/src/utils/attachment-utils.ts +0 -479
  88. package/src/utils/auth-token.ts +0 -22
  89. package/src/utils/format.ts +0 -42
  90. package/src/utils/i18n.ts +0 -653
  91. package/src/utils/model-discovery.ts +0 -290
  92. package/src/utils/proxy-utils.ts +0 -139
  93. package/src/utils/test-sessions.ts +0 -2357
  94. package/tsconfig.build.json +0 -20
  95. package/tsconfig.json +0 -7
@@ -1,403 +0,0 @@
1
- import { streamSimple, type ToolResultMessage, type Usage } from "@elyracode/ai";
2
- import { html, LitElement } from "lit";
3
- import { customElement, property, query } from "lit/decorators.js";
4
- import { ModelSelector } from "../dialogs/ModelSelector.js";
5
- import type { MessageEditor } from "./MessageEditor.js";
6
- import "./MessageEditor.js";
7
- import "./MessageList.js";
8
- import "./Messages.js"; // Import for side effects to register the custom elements
9
- import { getAppStorage } from "../storage/app-storage.js";
10
- import "./StreamingMessageContainer.js";
11
- import type { Agent, AgentEvent } from "@elyracode/agent-core";
12
- import type { Attachment } from "../utils/attachment-utils.js";
13
- import { formatUsage } from "../utils/format.js";
14
- import { i18n } from "../utils/i18n.js";
15
- import { createStreamFn } from "../utils/proxy-utils.js";
16
- import type { UserMessageWithAttachments } from "./Messages.js";
17
- import type { StreamingMessageContainer } from "./StreamingMessageContainer.js";
18
-
19
- @customElement("agent-interface")
20
- export class AgentInterface extends LitElement {
21
- // Optional external session: when provided, this component becomes a view over the session
22
- @property({ attribute: false }) session?: Agent;
23
- @property({ type: Boolean }) enableAttachments = true;
24
- @property({ type: Boolean }) enableModelSelector = true;
25
- @property({ type: Boolean }) enableThinkingSelector = true;
26
- @property({ type: Boolean }) showThemeToggle = false;
27
- // Optional custom API key prompt handler - if not provided, uses default dialog
28
- @property({ attribute: false }) onApiKeyRequired?: (provider: string) => Promise<boolean>;
29
- // Optional callback called before sending a message
30
- @property({ attribute: false }) onBeforeSend?: () => void | Promise<void>;
31
- // Optional callback called before executing a tool call - return false to prevent execution
32
- @property({ attribute: false }) onBeforeToolCall?: (toolName: string, args: unknown) => boolean | Promise<boolean>;
33
- // Optional callback called when cost display is clicked
34
- @property({ attribute: false }) onCostClick?: () => void;
35
- // Optional callback to override model selector behavior
36
- @property({ attribute: false }) onModelSelect?: () => void;
37
-
38
- // References
39
- @query("message-editor") private _messageEditor!: MessageEditor;
40
- @query("streaming-message-container") private _streamingContainer!: StreamingMessageContainer;
41
-
42
- private _autoScroll = true;
43
- private _lastScrollTop = 0;
44
- private _lastClientHeight = 0;
45
- private _scrollContainer?: HTMLElement;
46
- private _resizeObserver?: ResizeObserver;
47
- private _unsubscribeSession?: () => void;
48
-
49
- public setInput(text: string, attachments?: Attachment[]) {
50
- const update = () => {
51
- if (!this._messageEditor) requestAnimationFrame(update);
52
- else {
53
- this._messageEditor.value = text;
54
- this._messageEditor.attachments = attachments || [];
55
- }
56
- };
57
- update();
58
- }
59
-
60
- public setAutoScroll(enabled: boolean) {
61
- this._autoScroll = enabled;
62
- }
63
-
64
- protected override createRenderRoot(): HTMLElement | DocumentFragment {
65
- return this;
66
- }
67
-
68
- override willUpdate(changedProperties: Map<string, any>) {
69
- super.willUpdate(changedProperties);
70
-
71
- // Re-subscribe when session property changes
72
- if (changedProperties.has("session")) {
73
- this.setupSessionSubscription();
74
- }
75
- }
76
-
77
- override async connectedCallback() {
78
- super.connectedCallback();
79
-
80
- this.style.display = "flex";
81
- this.style.flexDirection = "column";
82
- this.style.height = "100%";
83
- this.style.minHeight = "0";
84
-
85
- // Wait for first render to get scroll container
86
- await this.updateComplete;
87
- this._scrollContainer = this.querySelector(".overflow-y-auto") as HTMLElement;
88
-
89
- if (this._scrollContainer) {
90
- // Set up ResizeObserver to detect content changes
91
- this._resizeObserver = new ResizeObserver(() => {
92
- if (this._autoScroll && this._scrollContainer) {
93
- this._scrollContainer.scrollTop = this._scrollContainer.scrollHeight;
94
- }
95
- });
96
-
97
- // Observe the content container inside the scroll container
98
- const contentContainer = this._scrollContainer.querySelector(".max-w-3xl");
99
- if (contentContainer) {
100
- this._resizeObserver.observe(contentContainer);
101
- }
102
-
103
- // Set up scroll listener with better detection
104
- this._scrollContainer.addEventListener("scroll", this._handleScroll);
105
- }
106
-
107
- // Subscribe to external session if provided
108
- this.setupSessionSubscription();
109
- }
110
-
111
- override disconnectedCallback() {
112
- super.disconnectedCallback();
113
-
114
- // Clean up observers and listeners
115
- if (this._resizeObserver) {
116
- this._resizeObserver.disconnect();
117
- this._resizeObserver = undefined;
118
- }
119
-
120
- if (this._scrollContainer) {
121
- this._scrollContainer.removeEventListener("scroll", this._handleScroll);
122
- }
123
-
124
- if (this._unsubscribeSession) {
125
- this._unsubscribeSession();
126
- this._unsubscribeSession = undefined;
127
- }
128
- }
129
-
130
- private setupSessionSubscription() {
131
- if (this._unsubscribeSession) {
132
- this._unsubscribeSession();
133
- this._unsubscribeSession = undefined;
134
- }
135
- if (!this.session) return;
136
-
137
- // Set default streamFn with proxy support if not already set
138
- if (this.session.streamFn === streamSimple) {
139
- this.session.streamFn = createStreamFn(async () => {
140
- const enabled = await getAppStorage().settings.get<boolean>("proxy.enabled");
141
- return enabled ? (await getAppStorage().settings.get<string>("proxy.url")) || undefined : undefined;
142
- });
143
- }
144
-
145
- // Set default getApiKey if not already set
146
- if (!this.session.getApiKey) {
147
- this.session.getApiKey = async (provider: string) => {
148
- const key = await getAppStorage().providerKeys.get(provider);
149
- return key ?? undefined;
150
- };
151
- }
152
-
153
- this._unsubscribeSession = this.session.subscribe(async (ev: AgentEvent) => {
154
- switch (ev.type) {
155
- case "message_start":
156
- case "turn_start":
157
- case "turn_end":
158
- case "agent_start":
159
- this.requestUpdate();
160
- break;
161
- case "message_end":
162
- // Clear streaming container when a message completes
163
- // to prevent duplicate rendering (stable list now has this message)
164
- if (this._streamingContainer) {
165
- this._streamingContainer.setMessage(null, true);
166
- }
167
- this.requestUpdate();
168
- break;
169
- case "agent_end":
170
- // Clear streaming container when agent finishes
171
- if (this._streamingContainer) {
172
- this._streamingContainer.isStreaming = false;
173
- this._streamingContainer.setMessage(null, true);
174
- }
175
- this.requestUpdate();
176
- break;
177
- case "message_update":
178
- if (this._streamingContainer) {
179
- const isStreaming = this.session?.state.isStreaming || false;
180
- this._streamingContainer.isStreaming = isStreaming;
181
- this._streamingContainer.setMessage(ev.message, !isStreaming);
182
- }
183
- this.requestUpdate();
184
- break;
185
- }
186
- });
187
- }
188
-
189
- private _handleScroll = (_ev: Event) => {
190
- if (!this._scrollContainer) return;
191
-
192
- const currentScrollTop = this._scrollContainer.scrollTop;
193
- const scrollHeight = this._scrollContainer.scrollHeight;
194
- const clientHeight = this._scrollContainer.clientHeight;
195
- const distanceFromBottom = scrollHeight - currentScrollTop - clientHeight;
196
-
197
- // Ignore relayout due to message editor getting pushed up by stats
198
- if (clientHeight < this._lastClientHeight) {
199
- this._lastClientHeight = clientHeight;
200
- return;
201
- }
202
-
203
- // Only disable auto-scroll if user scrolled UP or is far from bottom
204
- if (currentScrollTop !== 0 && currentScrollTop < this._lastScrollTop && distanceFromBottom > 50) {
205
- this._autoScroll = false;
206
- } else if (distanceFromBottom < 10) {
207
- // Re-enable if very close to bottom
208
- this._autoScroll = true;
209
- }
210
-
211
- this._lastScrollTop = currentScrollTop;
212
- this._lastClientHeight = clientHeight;
213
- };
214
-
215
- public async sendMessage(input: string, attachments?: Attachment[]) {
216
- if ((!input.trim() && attachments?.length === 0) || this.session?.state.isStreaming) return;
217
- const session = this.session;
218
- if (!session) throw new Error("No session set on AgentInterface");
219
- if (!session.state.model) throw new Error("No model set on AgentInterface");
220
-
221
- // Check if API key exists for the provider (only needed in direct mode)
222
- const provider = session.state.model.provider;
223
- const apiKey = await getAppStorage().providerKeys.get(provider);
224
-
225
- // If no API key, prompt for it
226
- if (!apiKey) {
227
- if (!this.onApiKeyRequired) {
228
- console.error("No API key configured and no onApiKeyRequired handler set");
229
- return;
230
- }
231
-
232
- const success = await this.onApiKeyRequired(provider);
233
-
234
- // If still no API key, abort the send
235
- if (!success) {
236
- return;
237
- }
238
- }
239
-
240
- // Call onBeforeSend hook before sending
241
- if (this.onBeforeSend) {
242
- await this.onBeforeSend();
243
- }
244
-
245
- // Only clear editor after we know we can send
246
- this._messageEditor.value = "";
247
- this._messageEditor.attachments = [];
248
- this._autoScroll = true; // Enable auto-scroll when sending a message
249
-
250
- // Compose message with attachments if any
251
- if (attachments && attachments.length > 0) {
252
- const message: UserMessageWithAttachments = {
253
- role: "user-with-attachments",
254
- content: input,
255
- attachments,
256
- timestamp: Date.now(),
257
- };
258
- await this.session?.prompt(message);
259
- } else {
260
- await this.session?.prompt(input);
261
- }
262
- }
263
-
264
- private renderMessages() {
265
- if (!this.session)
266
- return html`<div class="p-4 text-center text-muted-foreground">${i18n("No session available")}</div>`;
267
- const state = this.session.state;
268
- // Build a map of tool results to allow inline rendering in assistant messages
269
- const toolResultsById = new Map<string, ToolResultMessage>();
270
- for (const message of state.messages) {
271
- if (message.role === "toolResult") {
272
- toolResultsById.set(message.toolCallId, message);
273
- }
274
- }
275
- return html`
276
- <div class="flex flex-col gap-3">
277
- <!-- Stable messages list - won't re-render during streaming -->
278
- <message-list
279
- .messages=${this.session.state.messages}
280
- .tools=${state.tools}
281
- .pendingToolCalls=${this.session ? this.session.state.pendingToolCalls : new Set<string>()}
282
- .isStreaming=${state.isStreaming}
283
- .onCostClick=${this.onCostClick}
284
- ></message-list>
285
-
286
- <!-- Streaming message container - manages its own updates -->
287
- <streaming-message-container
288
- class="${state.isStreaming ? "" : "hidden"}"
289
- .tools=${state.tools}
290
- .isStreaming=${state.isStreaming}
291
- .pendingToolCalls=${state.pendingToolCalls}
292
- .toolResultsById=${toolResultsById}
293
- .onCostClick=${this.onCostClick}
294
- ></streaming-message-container>
295
- </div>
296
- `;
297
- }
298
-
299
- private renderStats() {
300
- if (!this.session) return html`<div class="text-xs h-5"></div>`;
301
-
302
- const state = this.session.state;
303
- const totals = state.messages
304
- .filter((m) => m.role === "assistant")
305
- .reduce(
306
- (acc, msg) => {
307
- const usage = "usage" in msg ? msg.usage : undefined;
308
- if (usage) {
309
- acc.input += usage.input;
310
- acc.output += usage.output;
311
- acc.cacheRead += usage.cacheRead;
312
- acc.cacheWrite += usage.cacheWrite;
313
- acc.cost.total += usage.cost.total;
314
- }
315
- return acc;
316
- },
317
- {
318
- input: 0,
319
- output: 0,
320
- cacheRead: 0,
321
- cacheWrite: 0,
322
- totalTokens: 0,
323
- cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
324
- } satisfies Usage,
325
- );
326
-
327
- const hasTotals = totals.input || totals.output || totals.cacheRead || totals.cacheWrite;
328
- const totalsText = hasTotals ? formatUsage(totals) : "";
329
-
330
- return html`
331
- <div class="text-xs text-muted-foreground flex justify-between items-center h-5">
332
- <div class="flex items-center gap-1">
333
- ${this.showThemeToggle ? html`<theme-toggle></theme-toggle>` : html``}
334
- </div>
335
- <div class="flex ml-auto items-center gap-3">
336
- ${
337
- totalsText
338
- ? this.onCostClick
339
- ? html`<span class="cursor-pointer hover:text-foreground transition-colors" @click=${this.onCostClick}>${totalsText}</span>`
340
- : html`<span>${totalsText}</span>`
341
- : ""
342
- }
343
- </div>
344
- </div>
345
- `;
346
- }
347
-
348
- override render() {
349
- if (!this.session)
350
- return html`<div class="p-4 text-center text-muted-foreground">${i18n("No session set")}</div>`;
351
-
352
- const session = this.session;
353
- const state = this.session.state;
354
- return html`
355
- <div class="flex flex-col h-full bg-background text-foreground">
356
- <!-- Messages Area -->
357
- <div class="flex-1 overflow-y-auto">
358
- <div class="max-w-3xl mx-auto p-4 pb-0">${this.renderMessages()}</div>
359
- </div>
360
-
361
- <!-- Input Area -->
362
- <div class="shrink-0">
363
- <div class="max-w-3xl mx-auto px-2">
364
- <message-editor
365
- .isStreaming=${state.isStreaming}
366
- .currentModel=${state.model}
367
- .thinkingLevel=${state.thinkingLevel}
368
- .showAttachmentButton=${this.enableAttachments}
369
- .showModelSelector=${this.enableModelSelector}
370
- .showThinkingSelector=${this.enableThinkingSelector}
371
- .onSend=${(input: string, attachments: Attachment[]) => {
372
- this.sendMessage(input, attachments);
373
- }}
374
- .onAbort=${() => session.abort()}
375
- .onModelSelect=${() => {
376
- if (this.onModelSelect) {
377
- this.onModelSelect();
378
- } else {
379
- ModelSelector.open(state.model, (model) => {
380
- session.state.model = model;
381
- });
382
- }
383
- }}
384
- .onThinkingChange=${
385
- this.enableThinkingSelector
386
- ? (level: "off" | "minimal" | "low" | "medium" | "high") => {
387
- session.state.thinkingLevel = level;
388
- }
389
- : undefined
390
- }
391
- ></message-editor>
392
- ${this.renderStats()}
393
- </div>
394
- </div>
395
- </div>
396
- `;
397
- }
398
- }
399
-
400
- // Register custom element with guard
401
- if (!customElements.get("agent-interface")) {
402
- customElements.define("agent-interface", AgentInterface);
403
- }
@@ -1,107 +0,0 @@
1
- import { icon } from "@elyracode/mini-lit/dist/icons.js";
2
- import { LitElement } from "lit";
3
- import { customElement, property } from "lit/decorators.js";
4
- import { html } from "lit/html.js";
5
- import { FileSpreadsheet, FileText, X } from "lucide";
6
- import { AttachmentOverlay } from "../dialogs/AttachmentOverlay.js";
7
- import type { Attachment } from "../utils/attachment-utils.js";
8
- import { i18n } from "../utils/i18n.js";
9
-
10
- @customElement("attachment-tile")
11
- export class AttachmentTile extends LitElement {
12
- @property({ type: Object }) attachment!: Attachment;
13
- @property({ type: Boolean }) showDelete = false;
14
- @property() onDelete?: () => void;
15
-
16
- protected override createRenderRoot(): HTMLElement | DocumentFragment {
17
- return this;
18
- }
19
-
20
- override connectedCallback(): void {
21
- super.connectedCallback();
22
- this.style.display = "block";
23
- this.classList.add("max-h-16");
24
- }
25
-
26
- private handleClick = () => {
27
- AttachmentOverlay.open(this.attachment);
28
- };
29
-
30
- override render() {
31
- const hasPreview = !!this.attachment.preview;
32
- const isImage = this.attachment.type === "image";
33
- const isPdf = this.attachment.mimeType === "application/pdf";
34
- const isExcel =
35
- this.attachment.mimeType?.includes("spreadsheetml") ||
36
- this.attachment.fileName.toLowerCase().endsWith(".xlsx") ||
37
- this.attachment.fileName.toLowerCase().endsWith(".xls");
38
-
39
- // Choose the appropriate icon
40
- const getDocumentIcon = () => {
41
- if (isExcel) return icon(FileSpreadsheet, "md");
42
- return icon(FileText, "md");
43
- };
44
-
45
- return html`
46
- <div class="relative group inline-block">
47
- ${
48
- hasPreview
49
- ? html`
50
- <div class="relative">
51
- <img
52
- src="data:${isImage ? this.attachment.mimeType : "image/png"};base64,${this.attachment.preview}"
53
- class="w-16 h-16 object-cover rounded-lg border border-input cursor-pointer hover:opacity-80 transition-opacity"
54
- alt="${this.attachment.fileName}"
55
- title="${this.attachment.fileName}"
56
- @click=${this.handleClick}
57
- />
58
- ${
59
- isPdf
60
- ? html`
61
- <!-- PDF badge overlay -->
62
- <div class="absolute bottom-0 left-0 right-0 bg-background/90 px-1 py-0.5 rounded-b-lg">
63
- <div class="text-[10px] text-muted-foreground text-center font-medium">${i18n("PDF")}</div>
64
- </div>
65
- `
66
- : ""
67
- }
68
- </div>
69
- `
70
- : html`
71
- <!-- Fallback: document icon + filename -->
72
- <div
73
- class="w-16 h-16 rounded-lg border border-input cursor-pointer hover:opacity-80 transition-opacity bg-muted text-muted-foreground flex flex-col items-center justify-center p-2"
74
- @click=${this.handleClick}
75
- title="${this.attachment.fileName}"
76
- >
77
- ${getDocumentIcon()}
78
- <div class="text-[10px] text-center truncate w-full">
79
- ${
80
- this.attachment.fileName.length > 10
81
- ? `${this.attachment.fileName.substring(0, 8)}...`
82
- : this.attachment.fileName
83
- }
84
- </div>
85
- </div>
86
- `
87
- }
88
- ${
89
- this.showDelete
90
- ? html`
91
- <button
92
- @click=${(e: Event) => {
93
- e.stopPropagation();
94
- this.onDelete?.();
95
- }}
96
- class="absolute -top-1 -right-1 w-5 h-5 bg-background hover:bg-muted text-muted-foreground hover:text-foreground rounded-full flex items-center justify-center opacity-100 hover:opacity-100 [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover:opacity-100 transition-opacity border border-input shadow-sm"
97
- title="${i18n("Remove")}"
98
- >
99
- ${icon(X, "xs")}
100
- </button>
101
- `
102
- : ""
103
- }
104
- </div>
105
- `;
106
- }
107
- }
@@ -1,72 +0,0 @@
1
- import { icon } from "@elyracode/mini-lit";
2
- import { LitElement } from "lit";
3
- import { property, state } from "lit/decorators.js";
4
- import { html } from "lit/html.js";
5
- import { Check, Copy } from "lucide";
6
- import { i18n } from "../utils/i18n.js";
7
-
8
- export class ConsoleBlock extends LitElement {
9
- @property() content: string = "";
10
- @property() variant: "default" | "error" = "default";
11
- @state() private copied = false;
12
-
13
- protected override createRenderRoot(): HTMLElement | DocumentFragment {
14
- return this;
15
- }
16
-
17
- override connectedCallback(): void {
18
- super.connectedCallback();
19
- this.style.display = "block";
20
- }
21
-
22
- private async copy() {
23
- try {
24
- await navigator.clipboard.writeText(this.content || "");
25
- this.copied = true;
26
- setTimeout(() => {
27
- this.copied = false;
28
- }, 1500);
29
- } catch (e) {
30
- console.error("Copy failed", e);
31
- }
32
- }
33
-
34
- override updated() {
35
- // Auto-scroll to bottom on content changes
36
- const container = this.querySelector(".console-scroll") as HTMLElement | null;
37
- if (container) {
38
- container.scrollTop = container.scrollHeight;
39
- }
40
- }
41
-
42
- override render() {
43
- const isError = this.variant === "error";
44
- const textClass = isError ? "text-destructive" : "text-foreground";
45
-
46
- return html`
47
- <div class="border border-border rounded-lg overflow-hidden">
48
- <div class="flex items-center justify-between px-3 py-1.5 bg-muted border-b border-border">
49
- <span class="text-xs text-muted-foreground font-mono">${i18n("console")}</span>
50
- <button
51
- @click=${() => this.copy()}
52
- class="flex items-center gap-1 px-2 py-0.5 text-xs rounded hover:bg-accent text-muted-foreground hover:text-accent-foreground transition-colors"
53
- title="${i18n("Copy output")}"
54
- >
55
- ${this.copied ? icon(Check, "sm") : icon(Copy, "sm")}
56
- ${this.copied ? html`<span>${i18n("Copied!")}</span>` : ""}
57
- </button>
58
- </div>
59
- <div class="console-scroll overflow-auto max-h-64">
60
- <pre class="!bg-background !border-0 !rounded-none m-0 p-3 text-xs ${textClass} font-mono whitespace-pre-wrap">
61
- ${this.content || ""}</pre
62
- >
63
- </div>
64
- </div>
65
- `;
66
- }
67
- }
68
-
69
- // Register custom element
70
- if (!customElements.get("console-block")) {
71
- customElements.define("console-block", ConsoleBlock);
72
- }
@@ -1,100 +0,0 @@
1
- import { i18n } from "@elyracode/mini-lit";
2
- import { Button } from "@elyracode/mini-lit/dist/Button.js";
3
- import { html, LitElement, type TemplateResult } from "lit";
4
- import { customElement, property } from "lit/decorators.js";
5
- import type { CustomProvider } from "../storage/stores/custom-providers-store.js";
6
-
7
- @customElement("custom-provider-card")
8
- export class CustomProviderCard extends LitElement {
9
- @property({ type: Object }) provider!: CustomProvider;
10
- @property({ type: Boolean }) isAutoDiscovery = false;
11
- @property({ type: Object }) status?: { modelCount: number; status: "connected" | "disconnected" | "checking" };
12
- @property() onRefresh?: (provider: CustomProvider) => void;
13
- @property() onEdit?: (provider: CustomProvider) => void;
14
- @property() onDelete?: (provider: CustomProvider) => void;
15
-
16
- protected createRenderRoot() {
17
- return this;
18
- }
19
-
20
- private renderStatus(): TemplateResult {
21
- if (!this.isAutoDiscovery) {
22
- return html`
23
- <div class="text-xs text-muted-foreground mt-1">
24
- ${i18n("Models")}: ${this.provider.models?.length || 0}
25
- </div>
26
- `;
27
- }
28
-
29
- if (!this.status) return html``;
30
-
31
- const statusIcon =
32
- this.status.status === "connected"
33
- ? html`<span class="text-green-500">●</span>`
34
- : this.status.status === "checking"
35
- ? html`<span class="text-yellow-500">●</span>`
36
- : html`<span class="text-red-500">●</span>`;
37
-
38
- const statusText =
39
- this.status.status === "connected"
40
- ? `${this.status.modelCount} ${i18n("models")}`
41
- : this.status.status === "checking"
42
- ? i18n("Checking...")
43
- : i18n("Disconnected");
44
-
45
- return html`
46
- <div class="text-xs text-muted-foreground mt-1 flex items-center gap-1">
47
- ${statusIcon} ${statusText}
48
- </div>
49
- `;
50
- }
51
-
52
- render(): TemplateResult {
53
- return html`
54
- <div class="border border-border rounded-lg p-4 space-y-2">
55
- <div class="flex items-center justify-between">
56
- <div class="flex-1">
57
- <div class="font-medium text-sm text-foreground">${this.provider.name}</div>
58
- <div class="text-xs text-muted-foreground mt-1">
59
- <span class="capitalize">${this.provider.type}</span>
60
- ${this.provider.baseUrl ? html` • ${this.provider.baseUrl}` : ""}
61
- </div>
62
- ${this.renderStatus()}
63
- </div>
64
- <div class="flex gap-2">
65
- ${
66
- this.isAutoDiscovery && this.onRefresh
67
- ? Button({
68
- onClick: () => this.onRefresh?.(this.provider),
69
- variant: "ghost",
70
- size: "sm",
71
- children: i18n("Refresh"),
72
- })
73
- : ""
74
- }
75
- ${
76
- this.onEdit
77
- ? Button({
78
- onClick: () => this.onEdit?.(this.provider),
79
- variant: "ghost",
80
- size: "sm",
81
- children: i18n("Edit"),
82
- })
83
- : ""
84
- }
85
- ${
86
- this.onDelete
87
- ? Button({
88
- onClick: () => this.onDelete?.(this.provider),
89
- variant: "ghost",
90
- size: "sm",
91
- children: i18n("Delete"),
92
- })
93
- : ""
94
- }
95
- </div>
96
- </div>
97
- </div>
98
- `;
99
- }
100
- }