@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,88 +0,0 @@
1
- #!/usr/bin/env tsx
2
- /**
3
- * Count tokens in system prompts using Anthropic's token counter API
4
- */
5
-
6
- import * as prompts from "../src/prompts/prompts.js";
7
-
8
- const ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY;
9
-
10
- if (!ANTHROPIC_API_KEY) {
11
- console.error("Error: ANTHROPIC_API_KEY environment variable not set");
12
- process.exit(1);
13
- }
14
-
15
- interface TokenCountResponse {
16
- input_tokens: number;
17
- }
18
-
19
- async function countTokens(text: string): Promise<number> {
20
- const response = await fetch("https://api.anthropic.com/v1/messages/count_tokens", {
21
- method: "POST",
22
- headers: {
23
- "Content-Type": "application/json",
24
- "x-api-key": ANTHROPIC_API_KEY,
25
- "anthropic-version": "2023-06-01",
26
- },
27
- body: JSON.stringify({
28
- model: "claude-3-5-sonnet-20241022",
29
- messages: [
30
- {
31
- role: "user",
32
- content: text,
33
- },
34
- ],
35
- }),
36
- });
37
-
38
- if (!response.ok) {
39
- const error = await response.text();
40
- throw new Error(`API error: ${response.status} ${error}`);
41
- }
42
-
43
- const data = (await response.json()) as TokenCountResponse;
44
- return data.input_tokens;
45
- }
46
-
47
- async function main() {
48
- console.log("Counting tokens in prompts...\n");
49
-
50
- const promptsToCount: Array<{ name: string; content: string }> = [
51
- {
52
- name: "ARTIFACTS_RUNTIME_PROVIDER_DESCRIPTION_RW",
53
- content: prompts.ARTIFACTS_RUNTIME_PROVIDER_DESCRIPTION_RW,
54
- },
55
- {
56
- name: "ARTIFACTS_RUNTIME_PROVIDER_DESCRIPTION_RO",
57
- content: prompts.ARTIFACTS_RUNTIME_PROVIDER_DESCRIPTION_RO,
58
- },
59
- {
60
- name: "ATTACHMENTS_RUNTIME_DESCRIPTION",
61
- content: prompts.ATTACHMENTS_RUNTIME_DESCRIPTION,
62
- },
63
- {
64
- name: "JAVASCRIPT_REPL_TOOL_DESCRIPTION (without runtime providers)",
65
- content: prompts.JAVASCRIPT_REPL_TOOL_DESCRIPTION([]),
66
- },
67
- {
68
- name: "ARTIFACTS_TOOL_DESCRIPTION (without runtime providers)",
69
- content: prompts.ARTIFACTS_TOOL_DESCRIPTION([]),
70
- },
71
- ];
72
-
73
- let total = 0;
74
-
75
- for (const prompt of promptsToCount) {
76
- try {
77
- const tokens = await countTokens(prompt.content);
78
- total += tokens;
79
- console.log(`${prompt.name}: ${tokens.toLocaleString()} tokens`);
80
- } catch (error) {
81
- console.error(`Error counting tokens for ${prompt.name}:`, error);
82
- }
83
- }
84
-
85
- console.log(`\nTotal: ${total.toLocaleString()} tokens`);
86
- }
87
-
88
- main();
package/src/ChatPanel.ts DELETED
@@ -1,209 +0,0 @@
1
- import { Badge } from "@elyracode/mini-lit/dist/Badge.js";
2
- import { html, LitElement } from "lit";
3
- import { customElement, state } from "lit/decorators.js";
4
- import "./components/AgentInterface.js";
5
- import type { Agent, AgentTool } from "@elyracode/agent-core";
6
- import type { AgentInterface } from "./components/AgentInterface.js";
7
- import { ArtifactsRuntimeProvider } from "./components/sandbox/ArtifactsRuntimeProvider.js";
8
- import { AttachmentsRuntimeProvider } from "./components/sandbox/AttachmentsRuntimeProvider.js";
9
- import type { SandboxRuntimeProvider } from "./components/sandbox/SandboxRuntimeProvider.js";
10
- import { ArtifactsPanel, ArtifactsToolRenderer } from "./tools/artifacts/index.js";
11
- import { registerToolRenderer } from "./tools/renderer-registry.js";
12
- import type { Attachment } from "./utils/attachment-utils.js";
13
- import { i18n } from "./utils/i18n.js";
14
-
15
- const BREAKPOINT = 800; // px - switch between overlay and side-by-side
16
-
17
- @customElement("elyra-chat-panel")
18
- export class ChatPanel extends LitElement {
19
- @state() public agent?: Agent;
20
- @state() public agentInterface?: AgentInterface;
21
- @state() public artifactsPanel?: ArtifactsPanel;
22
- @state() private hasArtifacts = false;
23
- @state() private artifactCount = 0;
24
- @state() private showArtifactsPanel = false;
25
- @state() private windowWidth = 0;
26
-
27
- private resizeHandler = () => {
28
- this.windowWidth = window.innerWidth;
29
- this.requestUpdate();
30
- };
31
-
32
- createRenderRoot() {
33
- return this;
34
- }
35
-
36
- override connectedCallback() {
37
- super.connectedCallback();
38
- this.windowWidth = window.innerWidth; // Set initial width after connection
39
- window.addEventListener("resize", this.resizeHandler);
40
- this.style.display = "flex";
41
- this.style.flexDirection = "column";
42
- this.style.height = "100%";
43
- this.style.minHeight = "0";
44
- // Update width after initial render
45
- requestAnimationFrame(() => {
46
- this.windowWidth = window.innerWidth;
47
- this.requestUpdate();
48
- });
49
- }
50
-
51
- override disconnectedCallback() {
52
- super.disconnectedCallback();
53
- window.removeEventListener("resize", this.resizeHandler);
54
- }
55
-
56
- async setAgent(
57
- agent: Agent,
58
- config?: {
59
- onApiKeyRequired?: (provider: string) => Promise<boolean>;
60
- onBeforeSend?: () => void | Promise<void>;
61
- onCostClick?: () => void;
62
- onModelSelect?: () => void;
63
- sandboxUrlProvider?: () => string;
64
- toolsFactory?: (
65
- agent: Agent,
66
- agentInterface: AgentInterface,
67
- artifactsPanel: ArtifactsPanel,
68
- runtimeProvidersFactory: () => SandboxRuntimeProvider[],
69
- ) => AgentTool[];
70
- },
71
- ) {
72
- this.agent = agent;
73
-
74
- // Create AgentInterface
75
- this.agentInterface = document.createElement("agent-interface") as AgentInterface;
76
- this.agentInterface.session = agent;
77
- this.agentInterface.enableAttachments = true;
78
- this.agentInterface.enableModelSelector = true;
79
- this.agentInterface.enableThinkingSelector = true;
80
- this.agentInterface.showThemeToggle = false;
81
- this.agentInterface.onApiKeyRequired = config?.onApiKeyRequired;
82
- this.agentInterface.onModelSelect = config?.onModelSelect;
83
- this.agentInterface.onBeforeSend = config?.onBeforeSend;
84
- this.agentInterface.onCostClick = config?.onCostClick;
85
-
86
- // Set up artifacts panel
87
- this.artifactsPanel = new ArtifactsPanel();
88
- this.artifactsPanel.agent = agent; // Pass agent for HTML artifact runtime providers
89
- if (config?.sandboxUrlProvider) {
90
- this.artifactsPanel.sandboxUrlProvider = config.sandboxUrlProvider;
91
- }
92
- // Register the standalone tool renderer (not the panel itself)
93
- registerToolRenderer("artifacts", new ArtifactsToolRenderer(this.artifactsPanel));
94
-
95
- // Runtime providers factory for REPL tools (read-write access)
96
- const runtimeProvidersFactory = () => {
97
- const attachments: Attachment[] = [];
98
- for (const message of this.agent!.state.messages) {
99
- if (message.role === "user-with-attachments") {
100
- message.attachments?.forEach((a) => {
101
- attachments.push(a);
102
- });
103
- }
104
- }
105
- const providers: SandboxRuntimeProvider[] = [];
106
-
107
- // Add attachments provider if there are attachments
108
- if (attachments.length > 0) {
109
- providers.push(new AttachmentsRuntimeProvider(attachments));
110
- }
111
-
112
- // Add artifacts provider with read-write access (for REPL)
113
- providers.push(new ArtifactsRuntimeProvider(this.artifactsPanel!, this.agent!, true));
114
-
115
- return providers;
116
- };
117
-
118
- this.artifactsPanel.onArtifactsChange = () => {
119
- const count = this.artifactsPanel?.artifacts?.size ?? 0;
120
- const created = count > this.artifactCount;
121
- this.hasArtifacts = count > 0;
122
- this.artifactCount = count;
123
- if (this.hasArtifacts && created) {
124
- this.showArtifactsPanel = true;
125
- }
126
- this.requestUpdate();
127
- };
128
-
129
- this.artifactsPanel.onClose = () => {
130
- this.showArtifactsPanel = false;
131
- this.requestUpdate();
132
- };
133
-
134
- this.artifactsPanel.onOpen = () => {
135
- this.showArtifactsPanel = true;
136
- this.requestUpdate();
137
- };
138
-
139
- // Set tools on the agent
140
- // Pass runtimeProvidersFactory so consumers can configure their own REPL tools
141
- const additionalTools =
142
- config?.toolsFactory?.(agent, this.agentInterface, this.artifactsPanel, runtimeProvidersFactory) || [];
143
- const tools = [this.artifactsPanel.tool, ...additionalTools];
144
- this.agent.state.tools = tools;
145
-
146
- // Reconstruct artifacts from existing messages
147
- // Temporarily disable the onArtifactsChange callback to prevent auto-opening on load
148
- const originalCallback = this.artifactsPanel.onArtifactsChange;
149
- this.artifactsPanel.onArtifactsChange = undefined;
150
- await this.artifactsPanel.reconstructFromMessages(this.agent.state.messages);
151
- this.artifactsPanel.onArtifactsChange = originalCallback;
152
-
153
- this.hasArtifacts = this.artifactsPanel.artifacts.size > 0;
154
- this.artifactCount = this.artifactsPanel.artifacts.size;
155
-
156
- this.requestUpdate();
157
- }
158
-
159
- render() {
160
- if (!this.agent || !this.agentInterface) {
161
- return html`<div class="flex items-center justify-center h-full">
162
- <div class="text-muted-foreground">No agent set</div>
163
- </div>`;
164
- }
165
-
166
- const isMobile = this.windowWidth < BREAKPOINT;
167
-
168
- // Set panel props
169
- if (this.artifactsPanel) {
170
- this.artifactsPanel.collapsed = !this.showArtifactsPanel;
171
- this.artifactsPanel.overlay = isMobile;
172
- }
173
-
174
- return html`
175
- <div class="relative w-full h-full overflow-hidden flex">
176
- <div class="h-full" style="${!isMobile && this.showArtifactsPanel && this.hasArtifacts ? "width: 50%;" : "width: 100%;"}">
177
- ${this.agentInterface}
178
- </div>
179
-
180
- <!-- Floating pill when artifacts exist and panel is collapsed -->
181
- ${
182
- this.hasArtifacts && !this.showArtifactsPanel
183
- ? html`
184
- <button
185
- class="absolute z-30 top-4 left-1/2 -translate-x-1/2 pointer-events-auto"
186
- @click=${() => {
187
- this.showArtifactsPanel = true;
188
- this.requestUpdate();
189
- }}
190
- title=${i18n("Show artifacts")}
191
- >
192
- ${Badge(html`
193
- <span class="inline-flex items-center gap-1">
194
- <span>${i18n("Artifacts")}</span>
195
- <span class="text-[10px] leading-none bg-primary-foreground/20 text-primary-foreground rounded px-1 font-mono tabular-nums">${this.artifactCount}</span>
196
- </span>
197
- `)}
198
- </button>
199
- `
200
- : ""
201
- }
202
-
203
- <div class="h-full ${isMobile ? "absolute inset-0 pointer-events-none" : ""}" style="${!isMobile ? (!this.hasArtifacts || !this.showArtifactsPanel ? "display: none;" : "width: 50%;") : ""}">
204
- ${this.artifactsPanel}
205
- </div>
206
- </div>
207
- `;
208
- }
209
- }
package/src/app.css DELETED
@@ -1,68 +0,0 @@
1
- /* Import Claude theme from mini-lit */
2
- @import "@elyracode/mini-lit/styles/themes/default.css";
3
-
4
- /* Tell Tailwind to scan mini-lit components */
5
- /* biome-ignore lint/suspicious/noUnknownAtRules: Tailwind 4 source directive */
6
- @source "../../../node_modules/@elyracode/mini-lit/dist";
7
-
8
- /* Import Tailwind */
9
- /* biome-ignore lint/correctness/noInvalidPositionAtImportRule: fuck you */
10
- @import "tailwindcss";
11
-
12
- body {
13
- font-size: 16px;
14
- -webkit-font-smoothing: antialiased;
15
- }
16
-
17
- * {
18
- scrollbar-width: thin;
19
- scrollbar-color: var(--color-border) rgba(0, 0, 0, 0);
20
- }
21
-
22
- *::-webkit-scrollbar {
23
- width: 8px;
24
- height: 8px;
25
- }
26
-
27
- *::-webkit-scrollbar-track {
28
- background: transparent;
29
- }
30
-
31
- *::-webkit-scrollbar-thumb {
32
- background-color: var(--color-border);
33
- border-radius: 4px;
34
- }
35
-
36
- *::-webkit-scrollbar-thumb:hover {
37
- background-color: rgba(0, 0, 0, 0);
38
- }
39
-
40
- /* Fix cursor for dialog close buttons */
41
- .fixed.inset-0 button[aria-label*="Close"],
42
- .fixed.inset-0 button[type="button"] {
43
- cursor: pointer;
44
- }
45
-
46
- /* Shimmer animation for thinking text */
47
- @keyframes shimmer {
48
- 0% {
49
- background-position: -200% 0;
50
- }
51
- 100% {
52
- background-position: 200% 0;
53
- }
54
- }
55
-
56
- .animate-shimmer {
57
- animation: shimmer 2s ease-in-out infinite;
58
- }
59
-
60
- /* User message with fancy pill styling */
61
- .user-message-container {
62
- transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
63
- position: relative;
64
- background: linear-gradient(135deg, rgba(217, 79, 0, 0.12), rgba(255, 107, 0, 0.12), rgba(212, 165, 0, 0.12));
65
- border: 1px solid rgba(255, 107, 0, 0.25);
66
- backdrop-filter: blur(10px);
67
- max-width: 100%;
68
- }