@elyracode/web-ui 0.9.10 → 0.9.12
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.
- package/CHANGELOG.md +7 -0
- package/dist/ChatPanel.d.ts +1 -1
- package/dist/ChatPanel.d.ts.map +1 -1
- package/dist/app.css +1 -1
- package/dist/components/AgentInterface.d.ts +1 -1
- package/dist/components/AgentInterface.d.ts.map +1 -1
- package/dist/components/AgentInterface.js +1 -1
- package/dist/components/AgentInterface.js.map +1 -1
- package/dist/components/MessageEditor.d.ts +2 -2
- package/dist/components/MessageEditor.d.ts.map +1 -1
- package/dist/components/Messages.d.ts +3 -3
- package/dist/components/Messages.d.ts.map +1 -1
- package/dist/components/Messages.js.map +1 -1
- package/dist/components/ProviderKeyInput.js +2 -2
- package/dist/components/ProviderKeyInput.js.map +1 -1
- package/dist/components/SandboxedIframe.d.ts +1 -1
- package/dist/components/SandboxedIframe.d.ts.map +1 -1
- package/dist/components/SandboxedIframe.js +1 -1
- package/dist/components/SandboxedIframe.js.map +1 -1
- package/dist/components/message-renderer-registry.js.map +1 -1
- package/dist/components/sandbox/ArtifactsRuntimeProvider.d.ts +4 -3
- package/dist/components/sandbox/ArtifactsRuntimeProvider.d.ts.map +1 -1
- package/dist/components/sandbox/ArtifactsRuntimeProvider.js +31 -31
- package/dist/components/sandbox/ArtifactsRuntimeProvider.js.map +1 -1
- package/dist/components/sandbox/AttachmentsRuntimeProvider.d.ts +1 -1
- package/dist/components/sandbox/AttachmentsRuntimeProvider.d.ts.map +1 -1
- package/dist/components/sandbox/AttachmentsRuntimeProvider.js +6 -5
- package/dist/components/sandbox/AttachmentsRuntimeProvider.js.map +1 -1
- package/dist/components/sandbox/ConsoleRuntimeProvider.d.ts +3 -2
- package/dist/components/sandbox/ConsoleRuntimeProvider.d.ts.map +1 -1
- package/dist/components/sandbox/ConsoleRuntimeProvider.js +12 -11
- package/dist/components/sandbox/ConsoleRuntimeProvider.js.map +1 -1
- package/dist/components/sandbox/FileDownloadRuntimeProvider.d.ts +3 -2
- package/dist/components/sandbox/FileDownloadRuntimeProvider.d.ts.map +1 -1
- package/dist/components/sandbox/FileDownloadRuntimeProvider.js +6 -4
- package/dist/components/sandbox/FileDownloadRuntimeProvider.js.map +1 -1
- package/dist/components/sandbox/RuntimeMessageRouter.d.ts +2 -1
- package/dist/components/sandbox/RuntimeMessageRouter.d.ts.map +1 -1
- package/dist/components/sandbox/RuntimeMessageRouter.js.map +1 -1
- package/dist/components/sandbox/SandboxRuntimeProvider.d.ts +3 -2
- package/dist/components/sandbox/SandboxRuntimeProvider.d.ts.map +1 -1
- package/dist/components/sandbox/runtime-messages.d.ts +140 -0
- package/dist/components/sandbox/runtime-messages.d.ts.map +1 -0
- package/dist/components/sandbox/runtime-messages.js +9 -0
- package/dist/components/sandbox/runtime-messages.js.map +1 -0
- package/dist/dialogs/AttachmentOverlay.d.ts.map +1 -1
- package/dist/dialogs/AttachmentOverlay.js +4 -4
- package/dist/dialogs/AttachmentOverlay.js.map +1 -1
- package/dist/dialogs/ModelSelector.d.ts +3 -3
- package/dist/dialogs/ModelSelector.d.ts.map +1 -1
- package/dist/dialogs/ModelSelector.js.map +1 -1
- package/dist/storage/stores/custom-providers-store.d.ts +2 -2
- package/dist/storage/stores/custom-providers-store.d.ts.map +1 -1
- package/dist/storage/types.d.ts +2 -2
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/tools/artifacts/DocxArtifact.js +1 -1
- package/dist/tools/artifacts/DocxArtifact.js.map +1 -1
- package/dist/tools/artifacts/ExcelArtifact.js +1 -1
- package/dist/tools/artifacts/ExcelArtifact.js.map +1 -1
- package/dist/tools/artifacts/HtmlArtifact.js.map +1 -1
- package/dist/tools/artifacts/PdfArtifact.d.ts.map +1 -1
- package/dist/tools/artifacts/PdfArtifact.js +1 -1
- package/dist/tools/artifacts/PdfArtifact.js.map +1 -1
- package/dist/tools/artifacts/artifacts-tool-renderer.d.ts.map +1 -1
- package/dist/tools/artifacts/artifacts-tool-renderer.js.map +1 -1
- package/dist/tools/artifacts/artifacts.js.map +1 -1
- package/dist/tools/extract-document.js +1 -1
- package/dist/tools/extract-document.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/javascript-repl.js.map +1 -1
- package/dist/tools/renderer-registry.d.ts +4 -3
- package/dist/tools/renderer-registry.d.ts.map +1 -1
- package/dist/tools/renderer-registry.js.map +1 -1
- package/dist/tools/renderers/BashRenderer.d.ts.map +1 -1
- package/dist/tools/renderers/BashRenderer.js.map +1 -1
- package/dist/tools/renderers/CalculateRenderer.d.ts.map +1 -1
- package/dist/tools/renderers/CalculateRenderer.js.map +1 -1
- package/dist/tools/renderers/DefaultRenderer.d.ts +1 -1
- package/dist/tools/renderers/DefaultRenderer.d.ts.map +1 -1
- package/dist/tools/renderers/DefaultRenderer.js.map +1 -1
- package/dist/tools/renderers/GetCurrentTimeRenderer.d.ts.map +1 -1
- package/dist/tools/renderers/GetCurrentTimeRenderer.js.map +1 -1
- package/dist/tools/types.d.ts +1 -1
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/attachment-utils.js +1 -1
- package/dist/utils/attachment-utils.js.map +1 -1
- package/dist/utils/format.d.ts +2 -2
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/model-discovery.d.ts +6 -6
- package/dist/utils/model-discovery.d.ts.map +1 -1
- package/dist/utils/model-discovery.js +3 -3
- package/dist/utils/model-discovery.js.map +1 -1
- package/dist/utils/proxy-utils.d.ts +1 -1
- package/example/package.json +1 -1
- package/package.json +5 -5
- package/src/ChatPanel.ts +1 -1
- package/src/components/AgentInterface.ts +5 -5
- package/src/components/MessageEditor.ts +2 -2
- package/src/components/Messages.ts +6 -6
- package/src/components/ProviderKeyInput.ts +3 -3
- package/src/components/SandboxedIframe.ts +7 -6
- package/src/components/message-renderer-registry.ts +1 -1
- package/src/components/sandbox/ArtifactsRuntimeProvider.ts +40 -44
- package/src/components/sandbox/AttachmentsRuntimeProvider.ts +9 -7
- package/src/components/sandbox/ConsoleRuntimeProvider.ts +19 -17
- package/src/components/sandbox/FileDownloadRuntimeProvider.ts +11 -7
- package/src/components/sandbox/RuntimeMessageRouter.ts +7 -8
- package/src/components/sandbox/SandboxRuntimeProvider.ts +4 -2
- package/src/components/sandbox/runtime-messages.ts +146 -0
- package/src/dialogs/AttachmentOverlay.ts +12 -11
- package/src/dialogs/CustomProviderDialog.ts +2 -2
- package/src/dialogs/ModelSelector.ts +11 -11
- package/src/storage/stores/custom-providers-store.ts +2 -2
- package/src/storage/types.ts +2 -2
- package/src/tools/artifacts/DocxArtifact.ts +2 -2
- package/src/tools/artifacts/ExcelArtifact.ts +3 -3
- package/src/tools/artifacts/HtmlArtifact.ts +1 -1
- package/src/tools/artifacts/PdfArtifact.ts +5 -4
- package/src/tools/artifacts/artifacts-tool-renderer.ts +4 -4
- package/src/tools/artifacts/artifacts.ts +4 -4
- package/src/tools/extract-document.ts +6 -6
- package/src/tools/index.ts +1 -1
- package/src/tools/javascript-repl.ts +3 -3
- package/src/tools/renderer-registry.ts +5 -5
- package/src/tools/renderers/BashRenderer.ts +3 -3
- package/src/tools/renderers/CalculateRenderer.ts +3 -3
- package/src/tools/renderers/DefaultRenderer.ts +5 -5
- package/src/tools/renderers/GetCurrentTimeRenderer.ts +5 -5
- package/src/tools/types.ts +1 -1
- package/src/utils/attachment-utils.ts +10 -3
- package/src/utils/format.ts +2 -2
- package/src/utils/model-discovery.ts +35 -22
- package/src/utils/proxy-utils.ts +1 -1
|
@@ -26,7 +26,7 @@ export async function discoverOllamaModels(baseUrl, _apiKey) {
|
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
28
|
// Extract model info
|
|
29
|
-
const modelInfo = details.model_info || {};
|
|
29
|
+
const modelInfo = (details.model_info || {});
|
|
30
30
|
// Get context window size - look for architecture-specific keys
|
|
31
31
|
const architecture = modelInfo["general.architecture"] || "";
|
|
32
32
|
const contextKey = `${architecture}.context_length`;
|
|
@@ -87,7 +87,7 @@ export async function discoverLlamaCppModels(baseUrl, apiKey) {
|
|
|
87
87
|
if (!response.ok) {
|
|
88
88
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
89
89
|
}
|
|
90
|
-
const data = await response.json();
|
|
90
|
+
const data = (await response.json());
|
|
91
91
|
if (!data.data || !Array.isArray(data.data)) {
|
|
92
92
|
throw new Error("Invalid response format from llama.cpp server");
|
|
93
93
|
}
|
|
@@ -141,7 +141,7 @@ export async function discoverVLLMModels(baseUrl, apiKey) {
|
|
|
141
141
|
if (!response.ok) {
|
|
142
142
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
143
143
|
}
|
|
144
|
-
const data = await response.json();
|
|
144
|
+
const data = (await response.json());
|
|
145
145
|
if (!data.data || !Array.isArray(data.data)) {
|
|
146
146
|
throw new Error("Invalid response format from vLLM server");
|
|
147
147
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-discovery.js","sourceRoot":"","sources":["../../src/utils/model-discovery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"model-discovery.js","sourceRoot":"","sources":["../../src/utils/model-discovery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAexC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAAe,EAAE,OAAgB;IAC3E,IAAI,CAAC;QACJ,uBAAuB;QACvB,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAE7C,+BAA+B;QAC/B,M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E,CAAC,CAAC;IACpG,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,IAAkD,EAClD,OAAe,EACf,MAAe;IAEf,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,QAAQ;YACZ,OAAO,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC9C,KAAK,WAAW;YACf,OAAO,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAChD,KAAK,MAAM;YACV,OAAO,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5C,KAAK,UAAU;YACd,OAAO,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC;AACF,CAAC"}
|
|
@@ -41,5 +41,5 @@ export declare function isCorsError(error: unknown): boolean;
|
|
|
41
41
|
* @param getProxyUrl - Async function to get current proxy URL (or undefined if disabled)
|
|
42
42
|
* @returns A streamFn compatible with Agent's streamFn option
|
|
43
43
|
*/
|
|
44
|
-
export declare function createStreamFn(getProxyUrl: () => Promise<string | undefined>): (model: Model<
|
|
44
|
+
export declare function createStreamFn(getProxyUrl: () => Promise<string | undefined>): (model: Model<Api>, context: Context, options?: SimpleStreamOptions) => Promise<import("@elyracode/ai").AssistantMessageEventStream>;
|
|
45
45
|
//# sourceMappingURL=proxy-utils.d.ts.map
|
package/example/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elyracode/web-ui",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.12",
|
|
4
4
|
"description": "Reusable web UI components for AI chat interfaces powered by @elyra/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"check": "biome check --write --error-on-warnings . && tsc --noEmit && cd example && biome check --write --error-on-warnings . && tsc --noEmit"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@elyracode/ai": "^0.9.
|
|
21
|
-
"@elyracode/tui": "^0.9.
|
|
20
|
+
"@elyracode/ai": "^0.9.12",
|
|
21
|
+
"@elyracode/tui": "^0.9.12",
|
|
22
22
|
"@lmstudio/sdk": "^1.5.0",
|
|
23
23
|
"docx-preview": "^0.3.7",
|
|
24
24
|
"jszip": "^3.10.1",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@elyracode/mini-lit": "^0.9.
|
|
32
|
+
"@elyracode/mini-lit": "^0.9.12",
|
|
33
33
|
"lit": "^3.3.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@elyracode/mini-lit": "^0.9.
|
|
36
|
+
"@elyracode/mini-lit": "^0.9.12",
|
|
37
37
|
"@tailwindcss/cli": "^4.0.0-beta.14",
|
|
38
38
|
"concurrently": "^10.0.3",
|
|
39
39
|
"typescript": "^6.0.3"
|
package/src/ChatPanel.ts
CHANGED
|
@@ -29,7 +29,7 @@ export class AgentInterface extends LitElement {
|
|
|
29
29
|
// Optional callback called before sending a message
|
|
30
30
|
@property({ attribute: false }) onBeforeSend?: () => void | Promise<void>;
|
|
31
31
|
// Optional callback called before executing a tool call - return false to prevent execution
|
|
32
|
-
@property({ attribute: false }) onBeforeToolCall?: (toolName: string, args:
|
|
32
|
+
@property({ attribute: false }) onBeforeToolCall?: (toolName: string, args: unknown) => boolean | Promise<boolean>;
|
|
33
33
|
// Optional callback called when cost display is clicked
|
|
34
34
|
@property({ attribute: false }) onCostClick?: () => void;
|
|
35
35
|
// Optional callback to override model selector behavior
|
|
@@ -186,7 +186,7 @@ export class AgentInterface extends LitElement {
|
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
private _handleScroll = (_ev:
|
|
189
|
+
private _handleScroll = (_ev: Event) => {
|
|
190
190
|
if (!this._scrollContainer) return;
|
|
191
191
|
|
|
192
192
|
const currentScrollTop = this._scrollContainer.scrollTop;
|
|
@@ -266,7 +266,7 @@ export class AgentInterface extends LitElement {
|
|
|
266
266
|
return html`<div class="p-4 text-center text-muted-foreground">${i18n("No session available")}</div>`;
|
|
267
267
|
const state = this.session.state;
|
|
268
268
|
// Build a map of tool results to allow inline rendering in assistant messages
|
|
269
|
-
const toolResultsById = new Map<string, ToolResultMessage
|
|
269
|
+
const toolResultsById = new Map<string, ToolResultMessage>();
|
|
270
270
|
for (const message of state.messages) {
|
|
271
271
|
if (message.role === "toolResult") {
|
|
272
272
|
toolResultsById.set(message.toolCallId, message);
|
|
@@ -303,8 +303,8 @@ export class AgentInterface extends LitElement {
|
|
|
303
303
|
const totals = state.messages
|
|
304
304
|
.filter((m) => m.role === "assistant")
|
|
305
305
|
.reduce(
|
|
306
|
-
(acc, msg
|
|
307
|
-
const usage = msg.usage;
|
|
306
|
+
(acc, msg) => {
|
|
307
|
+
const usage = "usage" in msg ? msg.usage : undefined;
|
|
308
308
|
if (usage) {
|
|
309
309
|
acc.input += usage.input;
|
|
310
310
|
acc.output += usage.output;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Model } from "@elyracode/ai";
|
|
1
|
+
import type { Api, Model } from "@elyracode/ai";
|
|
2
2
|
import { icon } from "@elyracode/mini-lit";
|
|
3
3
|
import { Button } from "@elyracode/mini-lit/dist/Button.js";
|
|
4
4
|
import { Select, type SelectOption } from "@elyracode/mini-lit/dist/Select.js";
|
|
@@ -28,7 +28,7 @@ export class MessageEditor extends LitElement {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
@property() isStreaming = false;
|
|
31
|
-
@property() currentModel?: Model<
|
|
31
|
+
@property() currentModel?: Model<Api>;
|
|
32
32
|
@property() thinkingLevel: ThinkingLevel = "off";
|
|
33
33
|
@property() showAttachmentButton = true;
|
|
34
34
|
@property() showModelSelector = true;
|
|
@@ -84,7 +84,7 @@ export class UserMessage extends LitElement {
|
|
|
84
84
|
@customElement("assistant-message")
|
|
85
85
|
export class AssistantMessage extends LitElement {
|
|
86
86
|
@property({ type: Object }) message!: AssistantMessageType;
|
|
87
|
-
@property({ type: Array }) tools?: AgentTool
|
|
87
|
+
@property({ type: Array }) tools?: AgentTool[];
|
|
88
88
|
@property({ type: Object }) pendingToolCalls?: ReadonlySet<string>;
|
|
89
89
|
@property({ type: Boolean }) hideToolCalls = false;
|
|
90
90
|
@property({ type: Object }) toolResultsById?: Map<string, ToolResultMessageType>;
|
|
@@ -169,7 +169,7 @@ export class AssistantMessage extends LitElement {
|
|
|
169
169
|
|
|
170
170
|
@customElement("tool-message-debug")
|
|
171
171
|
export class ToolMessageDebugView extends LitElement {
|
|
172
|
-
@property({ type: Object }) callArgs:
|
|
172
|
+
@property({ type: Object }) callArgs: unknown;
|
|
173
173
|
@property({ type: Object }) result?: ToolResultMessageType;
|
|
174
174
|
@property({ type: Boolean }) hasResult: boolean = false;
|
|
175
175
|
|
|
@@ -197,8 +197,8 @@ export class ToolMessageDebugView extends LitElement {
|
|
|
197
197
|
override render() {
|
|
198
198
|
const textOutput =
|
|
199
199
|
this.result?.content
|
|
200
|
-
?.filter((c) => c.type === "text")
|
|
201
|
-
.map((c
|
|
200
|
+
?.filter((c): c is TextContent => c.type === "text")
|
|
201
|
+
.map((c) => c.text)
|
|
202
202
|
.join("\n") || "";
|
|
203
203
|
const output = this.pretty(textOutput);
|
|
204
204
|
const details = this.pretty(this.result?.details);
|
|
@@ -226,7 +226,7 @@ export class ToolMessageDebugView extends LitElement {
|
|
|
226
226
|
@customElement("tool-message")
|
|
227
227
|
export class ToolMessage extends LitElement {
|
|
228
228
|
@property({ type: Object }) toolCall!: ToolCall;
|
|
229
|
-
@property({ type: Object }) tool?: AgentTool
|
|
229
|
+
@property({ type: Object }) tool?: AgentTool;
|
|
230
230
|
@property({ type: Object }) result?: ToolResultMessageType;
|
|
231
231
|
@property({ type: Boolean }) pending: boolean = false;
|
|
232
232
|
@property({ type: Boolean }) aborted: boolean = false;
|
|
@@ -245,7 +245,7 @@ export class ToolMessage extends LitElement {
|
|
|
245
245
|
const toolName = this.tool?.name || this.toolCall.name;
|
|
246
246
|
|
|
247
247
|
// Render tool content (renderer handles errors and styling)
|
|
248
|
-
const result: ToolResultMessageType
|
|
248
|
+
const result: ToolResultMessageType | undefined = this.aborted
|
|
249
249
|
? {
|
|
250
250
|
role: "toolResult",
|
|
251
251
|
isError: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Context, complete,
|
|
1
|
+
import { type Context, complete, getModels, type KnownProvider } from "@elyracode/ai";
|
|
2
2
|
import { i18n } from "@elyracode/mini-lit";
|
|
3
3
|
import { Badge } from "@elyracode/mini-lit/dist/Badge.js";
|
|
4
4
|
import { Button } from "@elyracode/mini-lit/dist/Button.js";
|
|
@@ -54,7 +54,7 @@ export class ProviderKeyInput extends LitElement {
|
|
|
54
54
|
// Returning true here for Ollama and friends. Can' know which model to use for testing
|
|
55
55
|
if (!modelId) return true;
|
|
56
56
|
|
|
57
|
-
let model =
|
|
57
|
+
let model = getModels(provider as KnownProvider).find((m) => m.id === modelId);
|
|
58
58
|
if (!model) return false;
|
|
59
59
|
|
|
60
60
|
// Get proxy URL from settings (if available)
|
|
@@ -71,7 +71,7 @@ export class ProviderKeyInput extends LitElement {
|
|
|
71
71
|
const result = await complete(model, context, {
|
|
72
72
|
apiKey,
|
|
73
73
|
maxTokens: 200,
|
|
74
|
-
}
|
|
74
|
+
});
|
|
75
75
|
|
|
76
76
|
return result.stopReason === "stop";
|
|
77
77
|
} catch (error) {
|
|
@@ -3,6 +3,7 @@ import { customElement, property } from "lit/decorators.js";
|
|
|
3
3
|
import { ConsoleRuntimeProvider } from "./sandbox/ConsoleRuntimeProvider.js";
|
|
4
4
|
import { RuntimeMessageBridge } from "./sandbox/RuntimeMessageBridge.js";
|
|
5
5
|
import { type MessageConsumer, RUNTIME_MESSAGE_ROUTER } from "./sandbox/RuntimeMessageRouter.js";
|
|
6
|
+
import type { ChromeApi, RuntimeMessage } from "./sandbox/runtime-messages.js";
|
|
6
7
|
import type { SandboxRuntimeProvider } from "./sandbox/SandboxRuntimeProvider.js";
|
|
7
8
|
|
|
8
9
|
export interface SandboxFile {
|
|
@@ -16,7 +17,7 @@ export interface SandboxResult {
|
|
|
16
17
|
console: Array<{ type: string; text: string }>;
|
|
17
18
|
files?: SandboxFile[];
|
|
18
19
|
error?: { message: string; stack: string };
|
|
19
|
-
returnValue?:
|
|
20
|
+
returnValue?: unknown;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
/**
|
|
@@ -150,7 +151,7 @@ export class SandboxIframe extends LitElement {
|
|
|
150
151
|
const externalUrlHandler = (e: MessageEvent) => {
|
|
151
152
|
if (e.data.type === "open-external-url" && e.source === this.iframe?.contentWindow) {
|
|
152
153
|
// Use chrome.tabs API to open in new tab
|
|
153
|
-
const chromeAPI = (globalThis as
|
|
154
|
+
const chromeAPI = (globalThis as { chrome?: ChromeApi }).chrome;
|
|
154
155
|
if (chromeAPI?.tabs) {
|
|
155
156
|
chromeAPI.tabs.create({ url: e.data.url });
|
|
156
157
|
} else {
|
|
@@ -265,7 +266,7 @@ export class SandboxIframe extends LitElement {
|
|
|
265
266
|
return new Promise((resolve, reject) => {
|
|
266
267
|
// 4. Create execution consumer for lifecycle messages
|
|
267
268
|
const executionConsumer: MessageConsumer = {
|
|
268
|
-
async handleMessage(message:
|
|
269
|
+
async handleMessage(message: RuntimeMessage): Promise<void> {
|
|
269
270
|
if (message.type === "file-returned") {
|
|
270
271
|
files.push({
|
|
271
272
|
fileName: message.fileName,
|
|
@@ -424,8 +425,8 @@ export class SandboxIframe extends LitElement {
|
|
|
424
425
|
}
|
|
425
426
|
|
|
426
427
|
return null;
|
|
427
|
-
} catch (error
|
|
428
|
-
return error.message
|
|
428
|
+
} catch (error) {
|
|
429
|
+
return error instanceof Error ? error.message : "Unknown validation error";
|
|
429
430
|
}
|
|
430
431
|
}
|
|
431
432
|
|
|
@@ -533,7 +534,7 @@ export class SandboxIframe extends LitElement {
|
|
|
533
534
|
isStandalone: boolean = false,
|
|
534
535
|
): string {
|
|
535
536
|
// Collect all data from providers
|
|
536
|
-
const allData: Record<string,
|
|
537
|
+
const allData: Record<string, unknown> = {};
|
|
537
538
|
for (const provider of providers) {
|
|
538
539
|
Object.assign(allData, provider.getData());
|
|
539
540
|
}
|
|
@@ -10,7 +10,7 @@ export interface MessageRenderer<TMessage extends AgentMessage = AgentMessage> {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
// Registry of custom message renderers by role
|
|
13
|
-
const messageRenderers = new Map<MessageRole, MessageRenderer
|
|
13
|
+
const messageRenderers = new Map<MessageRole, MessageRenderer>();
|
|
14
14
|
|
|
15
15
|
export function registerMessageRenderer<TRole extends MessageRole>(
|
|
16
16
|
role: TRole,
|
|
@@ -3,13 +3,14 @@ import {
|
|
|
3
3
|
ARTIFACTS_RUNTIME_PROVIDER_DESCRIPTION_RO,
|
|
4
4
|
ARTIFACTS_RUNTIME_PROVIDER_DESCRIPTION_RW,
|
|
5
5
|
} from "../../prompts/prompts.js";
|
|
6
|
+
import type { RuntimeMessage, RuntimeResponse, SandboxRuntimeWindow } from "./runtime-messages.js";
|
|
6
7
|
import type { SandboxRuntimeProvider } from "./SandboxRuntimeProvider.js";
|
|
7
8
|
|
|
8
9
|
// Define minimal interface for ArtifactsPanel to avoid circular dependencies
|
|
9
10
|
interface ArtifactsPanelLike {
|
|
10
11
|
artifacts: Map<string, { content: string }>;
|
|
11
12
|
tool: {
|
|
12
|
-
execute(toolCallId: string, args: { command: string; filename: string; content?: string }): Promise<
|
|
13
|
+
execute(toolCallId: string, args: { command: string; filename: string; content?: string }): Promise<unknown>;
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -41,7 +42,7 @@ export class ArtifactsRuntimeProvider implements SandboxRuntimeProvider {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
getData(): Record<string,
|
|
45
|
+
getData(): Record<string, unknown> {
|
|
45
46
|
// Inject artifact snapshot for offline mode
|
|
46
47
|
const snapshot: Record<string, string> = {};
|
|
47
48
|
this.artifactsPanel.artifacts.forEach((artifact, filename) => {
|
|
@@ -53,44 +54,45 @@ export class ArtifactsRuntimeProvider implements SandboxRuntimeProvider {
|
|
|
53
54
|
getRuntime(): (sandboxId: string) => void {
|
|
54
55
|
// This function will be stringified, so no external references!
|
|
55
56
|
return (_sandboxId: string) => {
|
|
57
|
+
const win = window as unknown as SandboxRuntimeWindow;
|
|
56
58
|
// Auto-parse/stringify for .json files
|
|
57
59
|
const isJsonFile = (filename: string) => filename.endsWith(".json");
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
win.listArtifacts = async (): Promise<string[]> => {
|
|
60
62
|
// Online: ask extension
|
|
61
|
-
if (
|
|
62
|
-
const response = await
|
|
63
|
+
if (win.sendRuntimeMessage) {
|
|
64
|
+
const response = await win.sendRuntimeMessage({
|
|
63
65
|
type: "artifact-operation",
|
|
64
66
|
action: "list",
|
|
65
67
|
});
|
|
66
68
|
if (!response.success) throw new Error(response.error);
|
|
67
|
-
return response.result;
|
|
69
|
+
return response.result as string[];
|
|
68
70
|
}
|
|
69
71
|
// Offline: return snapshot keys
|
|
70
72
|
else {
|
|
71
|
-
return Object.keys(
|
|
73
|
+
return Object.keys(win.artifacts || {});
|
|
72
74
|
}
|
|
73
75
|
};
|
|
74
76
|
|
|
75
|
-
|
|
77
|
+
win.getArtifact = async (filename: string): Promise<unknown> => {
|
|
76
78
|
let content: string;
|
|
77
79
|
|
|
78
80
|
// Online: ask extension
|
|
79
|
-
if (
|
|
80
|
-
const response = await
|
|
81
|
+
if (win.sendRuntimeMessage) {
|
|
82
|
+
const response = await win.sendRuntimeMessage({
|
|
81
83
|
type: "artifact-operation",
|
|
82
84
|
action: "get",
|
|
83
85
|
filename,
|
|
84
86
|
});
|
|
85
87
|
if (!response.success) throw new Error(response.error);
|
|
86
|
-
content = response.result;
|
|
88
|
+
content = response.result as string;
|
|
87
89
|
}
|
|
88
90
|
// Offline: read snapshot
|
|
89
91
|
else {
|
|
90
|
-
if (!
|
|
92
|
+
if (!win.artifacts?.[filename]) {
|
|
91
93
|
throw new Error(`Artifact not found (offline mode): ${filename}`);
|
|
92
94
|
}
|
|
93
|
-
content =
|
|
95
|
+
content = win.artifacts[filename];
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
// Auto-parse .json files
|
|
@@ -104,12 +106,8 @@ export class ArtifactsRuntimeProvider implements SandboxRuntimeProvider {
|
|
|
104
106
|
return content;
|
|
105
107
|
};
|
|
106
108
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
content: any,
|
|
110
|
-
mimeType?: string,
|
|
111
|
-
): Promise<void> => {
|
|
112
|
-
if (!(window as any).sendRuntimeMessage) {
|
|
109
|
+
win.createOrUpdateArtifact = async (filename: string, content: unknown, mimeType?: string): Promise<void> => {
|
|
110
|
+
if (!win.sendRuntimeMessage) {
|
|
113
111
|
throw new Error("Cannot create/update artifacts in offline mode (read-only)");
|
|
114
112
|
}
|
|
115
113
|
|
|
@@ -121,7 +119,7 @@ export class ArtifactsRuntimeProvider implements SandboxRuntimeProvider {
|
|
|
121
119
|
finalContent = JSON.stringify(content, null, 2);
|
|
122
120
|
}
|
|
123
121
|
|
|
124
|
-
const response = await
|
|
122
|
+
const response = await win.sendRuntimeMessage({
|
|
125
123
|
type: "artifact-operation",
|
|
126
124
|
action: "createOrUpdate",
|
|
127
125
|
filename,
|
|
@@ -131,12 +129,12 @@ export class ArtifactsRuntimeProvider implements SandboxRuntimeProvider {
|
|
|
131
129
|
if (!response.success) throw new Error(response.error);
|
|
132
130
|
};
|
|
133
131
|
|
|
134
|
-
|
|
135
|
-
if (!
|
|
132
|
+
win.deleteArtifact = async (filename: string): Promise<void> => {
|
|
133
|
+
if (!win.sendRuntimeMessage) {
|
|
136
134
|
throw new Error("Cannot delete artifacts in offline mode (read-only)");
|
|
137
135
|
}
|
|
138
136
|
|
|
139
|
-
const response = await
|
|
137
|
+
const response = await win.sendRuntimeMessage({
|
|
140
138
|
type: "artifact-operation",
|
|
141
139
|
action: "delete",
|
|
142
140
|
filename,
|
|
@@ -146,15 +144,13 @@ export class ArtifactsRuntimeProvider implements SandboxRuntimeProvider {
|
|
|
146
144
|
};
|
|
147
145
|
}
|
|
148
146
|
|
|
149
|
-
async handleMessage(message:
|
|
147
|
+
async handleMessage(message: RuntimeMessage, respond: (response: RuntimeResponse) => void): Promise<void> {
|
|
150
148
|
if (message.type !== "artifact-operation") {
|
|
151
149
|
return;
|
|
152
150
|
}
|
|
153
151
|
|
|
154
|
-
const { action, filename, content } = message;
|
|
155
|
-
|
|
156
152
|
try {
|
|
157
|
-
switch (action) {
|
|
153
|
+
switch (message.action) {
|
|
158
154
|
case "list": {
|
|
159
155
|
const filenames = Array.from(this.artifactsPanel.artifacts.keys());
|
|
160
156
|
respond({ success: true, result: filenames });
|
|
@@ -162,9 +158,9 @@ export class ArtifactsRuntimeProvider implements SandboxRuntimeProvider {
|
|
|
162
158
|
}
|
|
163
159
|
|
|
164
160
|
case "get": {
|
|
165
|
-
const artifact = this.artifactsPanel.artifacts.get(filename);
|
|
161
|
+
const artifact = this.artifactsPanel.artifacts.get(message.filename);
|
|
166
162
|
if (!artifact) {
|
|
167
|
-
respond({ success: false, error: `Artifact not found: ${filename}` });
|
|
163
|
+
respond({ success: false, error: `Artifact not found: ${message.filename}` });
|
|
168
164
|
} else {
|
|
169
165
|
respond({ success: true, result: artifact.content });
|
|
170
166
|
}
|
|
@@ -173,26 +169,26 @@ export class ArtifactsRuntimeProvider implements SandboxRuntimeProvider {
|
|
|
173
169
|
|
|
174
170
|
case "createOrUpdate": {
|
|
175
171
|
try {
|
|
176
|
-
const exists = this.artifactsPanel.artifacts.has(filename);
|
|
172
|
+
const exists = this.artifactsPanel.artifacts.has(message.filename);
|
|
177
173
|
const command = exists ? "rewrite" : "create";
|
|
178
174
|
const action = exists ? "update" : "create";
|
|
179
175
|
|
|
180
176
|
await this.artifactsPanel.tool.execute("", {
|
|
181
177
|
command,
|
|
182
|
-
filename,
|
|
183
|
-
content,
|
|
178
|
+
filename: message.filename,
|
|
179
|
+
content: message.content,
|
|
184
180
|
});
|
|
185
181
|
this.pushAgentMessage({
|
|
186
182
|
role: "artifact",
|
|
187
183
|
action,
|
|
188
|
-
filename,
|
|
189
|
-
content,
|
|
190
|
-
...(action === "create" && { title: filename }),
|
|
184
|
+
filename: message.filename,
|
|
185
|
+
content: message.content,
|
|
186
|
+
...(action === "create" && { title: message.filename }),
|
|
191
187
|
timestamp: new Date().toISOString(),
|
|
192
188
|
});
|
|
193
189
|
respond({ success: true });
|
|
194
|
-
} catch (err
|
|
195
|
-
respond({ success: false, error: err.message });
|
|
190
|
+
} catch (err) {
|
|
191
|
+
respond({ success: false, error: err instanceof Error ? err.message : String(err) });
|
|
196
192
|
}
|
|
197
193
|
break;
|
|
198
194
|
}
|
|
@@ -201,26 +197,26 @@ export class ArtifactsRuntimeProvider implements SandboxRuntimeProvider {
|
|
|
201
197
|
try {
|
|
202
198
|
await this.artifactsPanel.tool.execute("", {
|
|
203
199
|
command: "delete",
|
|
204
|
-
filename,
|
|
200
|
+
filename: message.filename,
|
|
205
201
|
});
|
|
206
202
|
this.pushAgentMessage({
|
|
207
203
|
role: "artifact",
|
|
208
204
|
action: "delete",
|
|
209
|
-
filename,
|
|
205
|
+
filename: message.filename,
|
|
210
206
|
timestamp: new Date().toISOString(),
|
|
211
207
|
});
|
|
212
208
|
respond({ success: true });
|
|
213
|
-
} catch (err
|
|
214
|
-
respond({ success: false, error: err.message });
|
|
209
|
+
} catch (err) {
|
|
210
|
+
respond({ success: false, error: err instanceof Error ? err.message : String(err) });
|
|
215
211
|
}
|
|
216
212
|
break;
|
|
217
213
|
}
|
|
218
214
|
|
|
219
215
|
default:
|
|
220
|
-
respond({ success: false, error:
|
|
216
|
+
respond({ success: false, error: "Unknown artifact action" });
|
|
221
217
|
}
|
|
222
|
-
} catch (error
|
|
223
|
-
respond({ success: false, error: error.message });
|
|
218
|
+
} catch (error) {
|
|
219
|
+
respond({ success: false, error: error instanceof Error ? error.message : String(error) });
|
|
224
220
|
}
|
|
225
221
|
}
|
|
226
222
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ATTACHMENTS_RUNTIME_DESCRIPTION } from "../../prompts/prompts.js";
|
|
2
2
|
import type { Attachment } from "../../utils/attachment-utils.js";
|
|
3
|
+
import type { SandboxAttachment, SandboxRuntimeWindow } from "./runtime-messages.js";
|
|
3
4
|
import type { SandboxRuntimeProvider } from "./SandboxRuntimeProvider.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -12,7 +13,7 @@ import type { SandboxRuntimeProvider } from "./SandboxRuntimeProvider.js";
|
|
|
12
13
|
export class AttachmentsRuntimeProvider implements SandboxRuntimeProvider {
|
|
13
14
|
constructor(private attachments: Attachment[]) {}
|
|
14
15
|
|
|
15
|
-
getData(): Record<string,
|
|
16
|
+
getData(): Record<string, unknown> {
|
|
16
17
|
const attachmentsData = this.attachments.map((a) => ({
|
|
17
18
|
id: a.id,
|
|
18
19
|
fileName: a.fileName,
|
|
@@ -30,16 +31,17 @@ export class AttachmentsRuntimeProvider implements SandboxRuntimeProvider {
|
|
|
30
31
|
// These functions read directly from window.attachments
|
|
31
32
|
// Works both online AND offline (no messaging needed!)
|
|
32
33
|
return (_sandboxId: string) => {
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
const win = window as unknown as SandboxRuntimeWindow;
|
|
35
|
+
win.listAttachments = () =>
|
|
36
|
+
(win.attachments || []).map((a: SandboxAttachment) => ({
|
|
35
37
|
id: a.id,
|
|
36
38
|
fileName: a.fileName,
|
|
37
39
|
mimeType: a.mimeType,
|
|
38
40
|
size: a.size,
|
|
39
41
|
}));
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
const a = (
|
|
43
|
+
win.readTextAttachment = (attachmentId: string) => {
|
|
44
|
+
const a = (win.attachments || []).find((x: SandboxAttachment) => x.id === attachmentId);
|
|
43
45
|
if (!a) throw new Error(`Attachment not found: ${attachmentId}`);
|
|
44
46
|
if (a.extractedText) return a.extractedText;
|
|
45
47
|
try {
|
|
@@ -49,8 +51,8 @@ export class AttachmentsRuntimeProvider implements SandboxRuntimeProvider {
|
|
|
49
51
|
}
|
|
50
52
|
};
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
const a = (
|
|
54
|
+
win.readBinaryAttachment = (attachmentId: string) => {
|
|
55
|
+
const a = (win.attachments || []).find((x: SandboxAttachment) => x.id === attachmentId);
|
|
54
56
|
if (!a) throw new Error(`Attachment not found: ${attachmentId}`);
|
|
55
57
|
const bin = atob(a.content);
|
|
56
58
|
const bytes = new Uint8Array(bin.length);
|