@elyracode/web-ui 0.9.58 → 1.0.0

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 +13 -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,130 +0,0 @@
1
- import { icon } from "@elyracode/mini-lit";
2
- import { html, type TemplateResult } from "lit";
3
- import type { Ref } from "lit/directives/ref.js";
4
- import { ref } from "lit/directives/ref.js";
5
- import { ChevronsUpDown, ChevronUp, type IconNode, Loader } from "lucide";
6
- import type { ToolRenderer } from "./types.js";
7
-
8
- // Registry of tool renderers
9
- export const toolRenderers = new Map<string, ToolRenderer>();
10
-
11
- /**
12
- * Register a custom tool renderer
13
- */
14
- export function registerToolRenderer(toolName: string, renderer: ToolRenderer): void {
15
- toolRenderers.set(toolName, renderer);
16
- }
17
-
18
- /**
19
- * Get a tool renderer by name
20
- */
21
- export function getToolRenderer(toolName: string): ToolRenderer | undefined {
22
- return toolRenderers.get(toolName);
23
- }
24
-
25
- /**
26
- * Helper to render a header for tool renderers
27
- * Shows icon on left when complete/error, spinner on right when in progress
28
- */
29
- export function renderHeader(
30
- state: "inprogress" | "complete" | "error",
31
- toolIcon: IconNode,
32
- text: string | TemplateResult,
33
- ): TemplateResult {
34
- const statusIcon = (iconComponent: IconNode, color: string) =>
35
- html`<span class="inline-block ${color}">${icon(iconComponent, "sm")}</span>`;
36
-
37
- switch (state) {
38
- case "inprogress":
39
- return html`
40
- <div class="flex items-center justify-between gap-2 text-sm text-muted-foreground">
41
- <div class="flex items-center gap-2">
42
- ${statusIcon(toolIcon, "text-foreground")}
43
- ${text}
44
- </div>
45
- ${statusIcon(Loader, "text-foreground animate-spin")}
46
- </div>
47
- `;
48
- case "complete":
49
- return html`
50
- <div class="flex items-center gap-2 text-sm text-muted-foreground">
51
- ${statusIcon(toolIcon, "text-green-600 dark:text-green-500")}
52
- ${text}
53
- </div>
54
- `;
55
- case "error":
56
- return html`
57
- <div class="flex items-center gap-2 text-sm text-muted-foreground">
58
- ${statusIcon(toolIcon, "text-destructive")}
59
- ${text}
60
- </div>
61
- `;
62
- }
63
- }
64
-
65
- /**
66
- * Helper to render a collapsible header for tool renderers
67
- * Same as renderHeader but with a chevron button that toggles visibility of content
68
- */
69
- export function renderCollapsibleHeader(
70
- state: "inprogress" | "complete" | "error",
71
- toolIcon: IconNode,
72
- text: string | TemplateResult,
73
- contentRef: Ref<HTMLElement>,
74
- chevronRef: Ref<HTMLElement>,
75
- defaultExpanded = false,
76
- ): TemplateResult {
77
- const statusIcon = (iconComponent: IconNode, color: string) =>
78
- html`<span class="inline-block ${color}">${icon(iconComponent, "sm")}</span>`;
79
-
80
- const toggleContent = (e: Event) => {
81
- e.preventDefault();
82
- const content = contentRef.value;
83
- const chevron = chevronRef.value;
84
- if (content && chevron) {
85
- const isCollapsed = content.classList.contains("max-h-0");
86
- if (isCollapsed) {
87
- content.classList.remove("max-h-0");
88
- content.classList.add("max-h-[2000px]", "mt-3");
89
- // Show ChevronUp, hide ChevronsUpDown
90
- const upIcon = chevron.querySelector(".chevron-up");
91
- const downIcon = chevron.querySelector(".chevrons-up-down");
92
- if (upIcon && downIcon) {
93
- upIcon.classList.remove("hidden");
94
- downIcon.classList.add("hidden");
95
- }
96
- } else {
97
- content.classList.remove("max-h-[2000px]", "mt-3");
98
- content.classList.add("max-h-0");
99
- // Show ChevronsUpDown, hide ChevronUp
100
- const upIcon = chevron.querySelector(".chevron-up");
101
- const downIcon = chevron.querySelector(".chevrons-up-down");
102
- if (upIcon && downIcon) {
103
- upIcon.classList.add("hidden");
104
- downIcon.classList.remove("hidden");
105
- }
106
- }
107
- }
108
- };
109
-
110
- const toolIconColor =
111
- state === "complete"
112
- ? "text-green-600 dark:text-green-500"
113
- : state === "error"
114
- ? "text-destructive"
115
- : "text-foreground";
116
-
117
- return html`
118
- <button @click=${toggleContent} class="flex items-center justify-between gap-2 text-sm text-muted-foreground w-full text-left hover:text-foreground transition-colors cursor-pointer">
119
- <div class="flex items-center gap-2">
120
- ${state === "inprogress" ? statusIcon(Loader, "text-foreground animate-spin") : ""}
121
- ${statusIcon(toolIcon, toolIconColor)}
122
- ${text}
123
- </div>
124
- <span class="inline-block text-muted-foreground" ${ref(chevronRef)}>
125
- <span class="chevron-up ${defaultExpanded ? "" : "hidden"}">${icon(ChevronUp, "sm")}</span>
126
- <span class="chevrons-up-down ${defaultExpanded ? "hidden" : ""}">${icon(ChevronsUpDown, "sm")}</span>
127
- </span>
128
- </button>
129
- `;
130
- }
@@ -1,52 +0,0 @@
1
- import type { TextContent, ToolResultMessage } from "@elyracode/ai";
2
- import { html } from "lit";
3
- import { SquareTerminal } from "lucide";
4
- import { i18n } from "../../utils/i18n.js";
5
- import { renderHeader } from "../renderer-registry.js";
6
- import type { ToolRenderer, ToolRenderResult } from "../types.js";
7
-
8
- interface BashParams {
9
- command: string;
10
- }
11
-
12
- // Bash tool has undefined details (only uses output)
13
- export class BashRenderer implements ToolRenderer<BashParams, undefined> {
14
- render(params: BashParams | undefined, result: ToolResultMessage<undefined> | undefined): ToolRenderResult {
15
- const state = result ? (result.isError ? "error" : "complete") : "inprogress";
16
-
17
- // With result: show command + output
18
- if (result && params?.command) {
19
- const output =
20
- result.content
21
- ?.filter((c): c is TextContent => c.type === "text")
22
- .map((c) => c.text)
23
- .join("\n") || "";
24
- const combined = output ? `> ${params.command}\n\n${output}` : `> ${params.command}`;
25
- return {
26
- content: html`
27
- <div class="space-y-3">
28
- ${renderHeader(state, SquareTerminal, i18n("Running command..."))}
29
- <console-block .content=${combined} .variant=${result.isError ? "error" : "default"}></console-block>
30
- </div>
31
- `,
32
- isCustom: false,
33
- };
34
- }
35
-
36
- // Just params (streaming or waiting)
37
- if (params?.command) {
38
- return {
39
- content: html`
40
- <div class="space-y-3">
41
- ${renderHeader(state, SquareTerminal, i18n("Running command..."))}
42
- <console-block .content=${`> ${params.command}`}></console-block>
43
- </div>
44
- `,
45
- isCustom: false,
46
- };
47
- }
48
-
49
- // No params yet
50
- return { content: renderHeader(state, SquareTerminal, i18n("Waiting for command...")), isCustom: false };
51
- }
52
- }
@@ -1,58 +0,0 @@
1
- import type { TextContent, ToolResultMessage } from "@elyracode/ai";
2
- import { html } from "lit";
3
- import { Calculator } from "lucide";
4
- import { i18n } from "../../utils/i18n.js";
5
- import { renderHeader } from "../renderer-registry.js";
6
- import type { ToolRenderer, ToolRenderResult } from "../types.js";
7
-
8
- interface CalculateParams {
9
- expression: string;
10
- }
11
-
12
- // Calculate tool has undefined details (only uses output)
13
- export class CalculateRenderer implements ToolRenderer<CalculateParams, undefined> {
14
- render(params: CalculateParams | undefined, result: ToolResultMessage<undefined> | undefined): ToolRenderResult {
15
- const state = result ? (result.isError ? "error" : "complete") : "inprogress";
16
-
17
- // Full params + full result
18
- if (result && params?.expression) {
19
- const output =
20
- result.content
21
- ?.filter((c): c is TextContent => c.type === "text")
22
- .map((c) => c.text)
23
- .join("\n") || "";
24
-
25
- // Error: show expression in header, error below
26
- if (result.isError) {
27
- return {
28
- content: html`
29
- <div class="space-y-3">
30
- ${renderHeader(state, Calculator, params.expression)}
31
- <div class="text-sm text-destructive">${output}</div>
32
- </div>
33
- `,
34
- isCustom: false,
35
- };
36
- }
37
-
38
- // Success: show expression = result in header
39
- return { content: renderHeader(state, Calculator, `${params.expression} = ${output}`), isCustom: false };
40
- }
41
-
42
- // Full params, no result: just show header with expression in it
43
- if (params?.expression) {
44
- return {
45
- content: renderHeader(state, Calculator, `${i18n("Calculating")} ${params.expression}`),
46
- isCustom: false,
47
- };
48
- }
49
-
50
- // Partial params (empty expression), no result
51
- if (params && !params.expression) {
52
- return { content: renderHeader(state, Calculator, i18n("Writing expression...")), isCustom: false };
53
- }
54
-
55
- // No params, no result
56
- return { content: renderHeader(state, Calculator, i18n("Waiting for expression...")), isCustom: false };
57
- }
58
- }
@@ -1,103 +0,0 @@
1
- import type { TextContent, ToolResultMessage } from "@elyracode/ai";
2
- import { html } from "lit";
3
- import { Code } from "lucide";
4
- import { i18n } from "../../utils/i18n.js";
5
- import { renderHeader } from "../renderer-registry.js";
6
- import type { ToolRenderer, ToolRenderResult } from "../types.js";
7
-
8
- export class DefaultRenderer implements ToolRenderer {
9
- render(params: unknown | undefined, result: ToolResultMessage | undefined, isStreaming?: boolean): ToolRenderResult {
10
- const state = result ? (result.isError ? "error" : "complete") : isStreaming ? "inprogress" : "complete";
11
-
12
- // Format params as JSON
13
- let paramsJson = "";
14
- if (params) {
15
- try {
16
- paramsJson = JSON.stringify(JSON.parse(params as string), null, 2);
17
- } catch {
18
- try {
19
- paramsJson = JSON.stringify(params, null, 2);
20
- } catch {
21
- paramsJson = String(params);
22
- }
23
- }
24
- }
25
-
26
- // With result: show header + params + result
27
- if (result) {
28
- let outputJson =
29
- result.content
30
- ?.filter((c): c is TextContent => c.type === "text")
31
- .map((c) => c.text)
32
- .join("\n") || i18n("(no output)");
33
- let outputLanguage = "text";
34
-
35
- // Try to parse and pretty-print if it's valid JSON
36
- try {
37
- const parsed = JSON.parse(outputJson);
38
- outputJson = JSON.stringify(parsed, null, 2);
39
- outputLanguage = "json";
40
- } catch {
41
- // Not valid JSON, leave as-is and use text highlighting
42
- }
43
-
44
- return {
45
- content: html`
46
- <div class="space-y-3">
47
- ${renderHeader(state, Code, "Tool Call")}
48
- ${
49
- paramsJson
50
- ? html`<div>
51
- <div class="text-xs font-medium mb-1 text-muted-foreground">${i18n("Input")}</div>
52
- <code-block .code=${paramsJson} language="json"></code-block>
53
- </div>`
54
- : ""
55
- }
56
- <div>
57
- <div class="text-xs font-medium mb-1 text-muted-foreground">${i18n("Output")}</div>
58
- <code-block .code=${outputJson} language="${outputLanguage}"></code-block>
59
- </div>
60
- </div>
61
- `,
62
- isCustom: false,
63
- };
64
- }
65
-
66
- // Just params (streaming or waiting for result)
67
- if (params) {
68
- if (isStreaming && (!paramsJson || paramsJson === "{}" || paramsJson === "null")) {
69
- return {
70
- content: html`
71
- <div>
72
- ${renderHeader(state, Code, "Preparing tool parameters...")}
73
- </div>
74
- `,
75
- isCustom: false,
76
- };
77
- }
78
-
79
- return {
80
- content: html`
81
- <div class="space-y-3">
82
- ${renderHeader(state, Code, "Tool Call")}
83
- <div>
84
- <div class="text-xs font-medium mb-1 text-muted-foreground">${i18n("Input")}</div>
85
- <code-block .code=${paramsJson} language="json"></code-block>
86
- </div>
87
- </div>
88
- `,
89
- isCustom: false,
90
- };
91
- }
92
-
93
- // No params or result yet
94
- return {
95
- content: html`
96
- <div>
97
- ${renderHeader(state, Code, "Preparing tool...")}
98
- </div>
99
- `,
100
- isCustom: false,
101
- };
102
- }
103
- }
@@ -1,92 +0,0 @@
1
- import type { TextContent, ToolResultMessage } from "@elyracode/ai";
2
- import { html } from "lit";
3
- import { Clock } from "lucide";
4
- import { i18n } from "../../utils/i18n.js";
5
- import { renderHeader } from "../renderer-registry.js";
6
- import type { ToolRenderer, ToolRenderResult } from "../types.js";
7
-
8
- interface GetCurrentTimeParams {
9
- timezone?: string;
10
- }
11
-
12
- // GetCurrentTime tool has undefined details (only uses output)
13
- export class GetCurrentTimeRenderer implements ToolRenderer<GetCurrentTimeParams, undefined> {
14
- render(
15
- params: GetCurrentTimeParams | undefined,
16
- result: ToolResultMessage<undefined> | undefined,
17
- ): ToolRenderResult {
18
- const state = result ? (result.isError ? "error" : "complete") : "inprogress";
19
-
20
- // Full params + full result
21
- if (result && params) {
22
- const output =
23
- result.content
24
- ?.filter((c): c is TextContent => c.type === "text")
25
- .map((c) => c.text)
26
- .join("\n") || "";
27
- const headerText = params.timezone
28
- ? `${i18n("Getting current time in")} ${params.timezone}`
29
- : i18n("Getting current date and time");
30
-
31
- // Error: show header, error below
32
- if (result.isError) {
33
- return {
34
- content: html`
35
- <div class="space-y-3">
36
- ${renderHeader(state, Clock, headerText)}
37
- <div class="text-sm text-destructive">${output}</div>
38
- </div>
39
- `,
40
- isCustom: false,
41
- };
42
- }
43
-
44
- // Success: show time in header
45
- return { content: renderHeader(state, Clock, `${headerText}: ${output}`), isCustom: false };
46
- }
47
-
48
- // Full result, no params
49
- if (result) {
50
- const output =
51
- result.content
52
- ?.filter((c): c is TextContent => c.type === "text")
53
- .map((c) => c.text)
54
- .join("\n") || "";
55
-
56
- // Error: show header, error below
57
- if (result.isError) {
58
- return {
59
- content: html`
60
- <div class="space-y-3">
61
- ${renderHeader(state, Clock, i18n("Getting current date and time"))}
62
- <div class="text-sm text-destructive">${output}</div>
63
- </div>
64
- `,
65
- isCustom: false,
66
- };
67
- }
68
-
69
- // Success: show time in header
70
- return {
71
- content: renderHeader(state, Clock, `${i18n("Getting current date and time")}: ${output}`),
72
- isCustom: false,
73
- };
74
- }
75
-
76
- // Full params, no result: show timezone info in header
77
- if (params?.timezone) {
78
- return {
79
- content: renderHeader(state, Clock, `${i18n("Getting current time in")} ${params.timezone}`),
80
- isCustom: false,
81
- };
82
- }
83
-
84
- // Partial params (no timezone) or empty params, no result
85
- if (params) {
86
- return { content: renderHeader(state, Clock, i18n("Getting current date and time")), isCustom: false };
87
- }
88
-
89
- // No params, no result
90
- return { content: renderHeader(state, Clock, i18n("Getting time...")), isCustom: false };
91
- }
92
- }
@@ -1,15 +0,0 @@
1
- import type { ToolResultMessage } from "@elyracode/ai";
2
- import type { TemplateResult } from "lit";
3
-
4
- export interface ToolRenderResult {
5
- content: TemplateResult;
6
- isCustom: boolean; // true = no card wrapper, false = wrap in card
7
- }
8
-
9
- export interface ToolRenderer<TParams = unknown, TDetails = unknown> {
10
- render(
11
- params: TParams | undefined,
12
- result: ToolResultMessage<TDetails> | undefined,
13
- isStreaming?: boolean,
14
- ): ToolRenderResult;
15
- }