@mariozechner/pi-web-ui 0.5.44 → 0.5.46
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/README.md +178 -99
- package/dist/ChatPanel.d.ts +15 -10
- package/dist/ChatPanel.d.ts.map +1 -1
- package/dist/ChatPanel.js +68 -100
- package/dist/ChatPanel.js.map +1 -1
- package/dist/{state/agent-session.d.ts → agent/agent.d.ts} +23 -19
- package/dist/agent/agent.d.ts.map +1 -0
- package/dist/{state/agent-session.js → agent/agent.js} +50 -32
- package/dist/agent/agent.js.map +1 -0
- package/dist/{state → agent}/transports/AppTransport.d.ts +1 -3
- package/dist/agent/transports/AppTransport.d.ts.map +1 -0
- package/dist/{state → agent}/transports/AppTransport.js +5 -4
- package/dist/{state → agent}/transports/AppTransport.js.map +1 -1
- package/dist/{state → agent}/transports/ProviderTransport.d.ts +1 -3
- package/dist/agent/transports/ProviderTransport.d.ts.map +1 -0
- package/dist/{state → agent}/transports/ProviderTransport.js +6 -7
- package/dist/agent/transports/ProviderTransport.js.map +1 -0
- package/dist/{state → agent}/transports/index.d.ts.map +1 -1
- package/dist/agent/transports/index.js.map +1 -0
- package/dist/{state → agent}/transports/proxy-types.d.ts.map +1 -1
- package/dist/agent/transports/proxy-types.js.map +1 -0
- package/dist/agent/transports/types.d.ts +12 -0
- package/dist/agent/transports/types.d.ts.map +1 -0
- package/dist/{state → agent}/transports/types.js.map +1 -1
- package/dist/{state → agent}/types.d.ts.map +1 -1
- package/dist/{state → agent}/types.js.map +1 -1
- package/dist/app.css +1 -1
- package/dist/components/AgentInterface.d.ts +7 -4
- package/dist/components/AgentInterface.d.ts.map +1 -1
- package/dist/components/AgentInterface.js +29 -17
- package/dist/components/AgentInterface.js.map +1 -1
- package/dist/components/ConsoleBlock.d.ts +1 -0
- package/dist/components/ConsoleBlock.d.ts.map +1 -1
- package/dist/components/ConsoleBlock.js +7 -1
- package/dist/components/ConsoleBlock.js.map +1 -1
- package/dist/components/ExpandableSection.d.ts +15 -0
- package/dist/components/ExpandableSection.d.ts.map +1 -0
- package/dist/components/ExpandableSection.js +63 -0
- package/dist/components/ExpandableSection.js.map +1 -0
- package/dist/components/MessageEditor.d.ts +8 -1
- package/dist/components/MessageEditor.d.ts.map +1 -1
- package/dist/components/MessageEditor.js +149 -6
- package/dist/components/MessageEditor.js.map +1 -1
- package/dist/components/MessageList.d.ts +3 -2
- package/dist/components/MessageList.d.ts.map +1 -1
- package/dist/components/MessageList.js +14 -1
- package/dist/components/MessageList.js.map +1 -1
- package/dist/components/Messages.d.ts +15 -6
- package/dist/components/Messages.d.ts.map +1 -1
- package/dist/components/Messages.js +17 -83
- package/dist/components/Messages.js.map +1 -1
- package/dist/components/ProviderKeyInput.d.ts.map +1 -1
- package/dist/components/ProviderKeyInput.js +6 -5
- package/dist/components/ProviderKeyInput.js.map +1 -1
- package/dist/components/SandboxedIframe.d.ts +29 -7
- package/dist/components/SandboxedIframe.d.ts.map +1 -1
- package/dist/components/SandboxedIframe.js +350 -282
- package/dist/components/SandboxedIframe.js.map +1 -1
- package/dist/components/message-renderer-registry.d.ts +12 -0
- package/dist/components/message-renderer-registry.d.ts.map +1 -0
- package/dist/components/message-renderer-registry.js +12 -0
- package/dist/components/message-renderer-registry.js.map +1 -0
- package/dist/components/sandbox/ArtifactsRuntimeProvider.d.ts +35 -0
- package/dist/components/sandbox/ArtifactsRuntimeProvider.d.ts.map +1 -0
- package/dist/components/sandbox/ArtifactsRuntimeProvider.js +189 -0
- package/dist/components/sandbox/ArtifactsRuntimeProvider.js.map +1 -0
- package/dist/components/sandbox/AttachmentsRuntimeProvider.d.ts +17 -0
- package/dist/components/sandbox/AttachmentsRuntimeProvider.d.ts.map +1 -0
- package/dist/components/sandbox/AttachmentsRuntimeProvider.js +64 -0
- package/dist/components/sandbox/AttachmentsRuntimeProvider.js.map +1 -0
- package/dist/components/sandbox/ConsoleRuntimeProvider.d.ts +42 -0
- package/dist/components/sandbox/ConsoleRuntimeProvider.d.ts.map +1 -0
- package/dist/components/sandbox/ConsoleRuntimeProvider.js +161 -0
- package/dist/components/sandbox/ConsoleRuntimeProvider.js.map +1 -0
- package/dist/components/sandbox/FileDownloadRuntimeProvider.d.ts +30 -0
- package/dist/components/sandbox/FileDownloadRuntimeProvider.d.ts.map +1 -0
- package/dist/components/sandbox/FileDownloadRuntimeProvider.js +97 -0
- package/dist/components/sandbox/FileDownloadRuntimeProvider.js.map +1 -0
- package/dist/components/sandbox/RuntimeMessageBridge.d.ts +19 -0
- package/dist/components/sandbox/RuntimeMessageBridge.d.ts.map +1 -0
- package/dist/components/sandbox/RuntimeMessageBridge.js +74 -0
- package/dist/components/sandbox/RuntimeMessageBridge.js.map +1 -0
- package/dist/components/sandbox/RuntimeMessageRouter.d.ts +65 -0
- package/dist/components/sandbox/RuntimeMessageRouter.d.ts.map +1 -0
- package/dist/components/sandbox/RuntimeMessageRouter.js +168 -0
- package/dist/components/sandbox/RuntimeMessageRouter.js.map +1 -0
- package/dist/components/sandbox/SandboxRuntimeProvider.d.ts +33 -0
- package/dist/components/sandbox/SandboxRuntimeProvider.d.ts.map +1 -0
- package/dist/components/sandbox/SandboxRuntimeProvider.js +2 -0
- package/dist/components/sandbox/SandboxRuntimeProvider.js.map +1 -0
- package/dist/dialogs/ApiKeyPromptDialog.d.ts.map +1 -1
- package/dist/dialogs/ApiKeyPromptDialog.js +2 -5
- package/dist/dialogs/ApiKeyPromptDialog.js.map +1 -1
- package/dist/dialogs/ModelSelector.js.map +1 -1
- package/dist/dialogs/PersistentStorageDialog.d.ts +17 -0
- package/dist/dialogs/PersistentStorageDialog.d.ts.map +1 -0
- package/dist/dialogs/PersistentStorageDialog.js +144 -0
- package/dist/dialogs/PersistentStorageDialog.js.map +1 -0
- package/dist/dialogs/SessionListDialog.d.ts +19 -0
- package/dist/dialogs/SessionListDialog.d.ts.map +1 -0
- package/dist/dialogs/SessionListDialog.js +152 -0
- package/dist/dialogs/SessionListDialog.js.map +1 -0
- package/dist/dialogs/SettingsDialog.d.ts.map +1 -1
- package/dist/dialogs/SettingsDialog.js +1 -0
- package/dist/dialogs/SettingsDialog.js.map +1 -1
- package/dist/index.d.ts +34 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -14
- package/dist/index.js.map +1 -1
- package/dist/prompts/prompts.d.ts +11 -0
- package/dist/prompts/prompts.d.ts.map +1 -0
- package/dist/prompts/prompts.js +272 -0
- package/dist/prompts/prompts.js.map +1 -0
- package/dist/storage/app-storage.d.ts +17 -12
- package/dist/storage/app-storage.d.ts.map +1 -1
- package/dist/storage/app-storage.js +13 -20
- package/dist/storage/app-storage.js.map +1 -1
- package/dist/storage/backends/indexeddb-storage-backend.d.ts +27 -0
- package/dist/storage/backends/indexeddb-storage-backend.d.ts.map +1 -0
- package/dist/storage/backends/indexeddb-storage-backend.js +166 -0
- package/dist/storage/backends/indexeddb-storage-backend.js.map +1 -0
- package/dist/storage/store.d.ts +23 -0
- package/dist/storage/store.d.ts.map +1 -0
- package/dist/storage/store.js +26 -0
- package/dist/storage/store.js.map +1 -0
- package/dist/storage/stores/provider-keys-store.d.ts +14 -0
- package/dist/storage/stores/provider-keys-store.d.ts.map +1 -0
- package/dist/storage/stores/provider-keys-store.js +27 -0
- package/dist/storage/stores/provider-keys-store.js.map +1 -0
- package/dist/storage/stores/sessions-store.d.ts +31 -0
- package/dist/storage/stores/sessions-store.d.ts.map +1 -0
- package/dist/storage/stores/sessions-store.js +113 -0
- package/dist/storage/stores/sessions-store.js.map +1 -0
- package/dist/storage/stores/settings-store.d.ts +14 -0
- package/dist/storage/stores/settings-store.d.ts.map +1 -0
- package/dist/storage/stores/settings-store.js +28 -0
- package/dist/storage/stores/settings-store.js.map +1 -0
- package/dist/storage/types.d.ts +156 -22
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/tools/artifacts/ArtifactElement.d.ts +0 -1
- package/dist/tools/artifacts/ArtifactElement.d.ts.map +1 -1
- package/dist/tools/artifacts/ArtifactElement.js +0 -1
- package/dist/tools/artifacts/ArtifactElement.js.map +1 -1
- package/dist/tools/artifacts/ArtifactPill.d.ts +4 -0
- package/dist/tools/artifacts/ArtifactPill.d.ts.map +1 -0
- package/dist/tools/artifacts/ArtifactPill.js +22 -0
- package/dist/tools/artifacts/ArtifactPill.js.map +1 -0
- package/dist/tools/artifacts/Console.d.ts +18 -0
- package/dist/tools/artifacts/Console.d.ts.map +1 -0
- package/dist/tools/artifacts/Console.js +95 -0
- package/dist/tools/artifacts/Console.js.map +1 -0
- package/dist/tools/artifacts/DocxArtifact.d.ts +22 -0
- package/dist/tools/artifacts/DocxArtifact.d.ts.map +1 -0
- package/dist/tools/artifacts/DocxArtifact.js +208 -0
- package/dist/tools/artifacts/DocxArtifact.js.map +1 -0
- package/dist/tools/artifacts/ExcelArtifact.d.ts +24 -0
- package/dist/tools/artifacts/ExcelArtifact.d.ts.map +1 -0
- package/dist/tools/artifacts/ExcelArtifact.js +216 -0
- package/dist/tools/artifacts/ExcelArtifact.js.map +1 -0
- package/dist/tools/artifacts/GenericArtifact.d.ts +19 -0
- package/dist/tools/artifacts/GenericArtifact.d.ts.map +1 -0
- package/dist/tools/artifacts/GenericArtifact.js +117 -0
- package/dist/tools/artifacts/GenericArtifact.js.map +1 -0
- package/dist/tools/artifacts/HtmlArtifact.d.ts +8 -11
- package/dist/tools/artifacts/HtmlArtifact.d.ts.map +1 -1
- package/dist/tools/artifacts/HtmlArtifact.js +56 -88
- package/dist/tools/artifacts/HtmlArtifact.js.map +1 -1
- package/dist/tools/artifacts/ImageArtifact.d.ts +20 -0
- package/dist/tools/artifacts/ImageArtifact.d.ts.map +1 -0
- package/dist/tools/artifacts/ImageArtifact.js +120 -0
- package/dist/tools/artifacts/ImageArtifact.js.map +1 -0
- package/dist/tools/artifacts/MarkdownArtifact.d.ts +0 -1
- package/dist/tools/artifacts/MarkdownArtifact.d.ts.map +1 -1
- package/dist/tools/artifacts/MarkdownArtifact.js +0 -4
- package/dist/tools/artifacts/MarkdownArtifact.js.map +1 -1
- package/dist/tools/artifacts/PdfArtifact.d.ts +25 -0
- package/dist/tools/artifacts/PdfArtifact.d.ts.map +1 -0
- package/dist/tools/artifacts/PdfArtifact.js +184 -0
- package/dist/tools/artifacts/PdfArtifact.js.map +1 -0
- package/dist/tools/artifacts/SvgArtifact.d.ts +0 -1
- package/dist/tools/artifacts/SvgArtifact.d.ts.map +1 -1
- package/dist/tools/artifacts/SvgArtifact.js +0 -4
- package/dist/tools/artifacts/SvgArtifact.js.map +1 -1
- package/dist/tools/artifacts/TextArtifact.d.ts +0 -1
- package/dist/tools/artifacts/TextArtifact.d.ts.map +1 -1
- package/dist/tools/artifacts/TextArtifact.js +0 -4
- package/dist/tools/artifacts/TextArtifact.js.map +1 -1
- package/dist/tools/artifacts/artifacts-tool-renderer.d.ts +11 -0
- package/dist/tools/artifacts/artifacts-tool-renderer.d.ts.map +1 -0
- package/dist/tools/artifacts/artifacts-tool-renderer.js +262 -0
- package/dist/tools/artifacts/artifacts-tool-renderer.js.map +1 -0
- package/dist/tools/artifacts/artifacts.d.ts +10 -13
- package/dist/tools/artifacts/artifacts.d.ts.map +1 -1
- package/dist/tools/artifacts/artifacts.js +166 -344
- package/dist/tools/artifacts/artifacts.js.map +1 -1
- package/dist/tools/artifacts/index.d.ts +1 -0
- package/dist/tools/artifacts/index.d.ts.map +1 -1
- package/dist/tools/artifacts/index.js +1 -0
- package/dist/tools/artifacts/index.js.map +1 -1
- package/dist/tools/extract-document.d.ts +24 -0
- package/dist/tools/extract-document.d.ts.map +1 -0
- package/dist/tools/extract-document.js +193 -0
- package/dist/tools/extract-document.js.map +1 -0
- package/dist/tools/index.d.ts +9 -7
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +17 -13
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/javascript-repl.d.ts +16 -15
- package/dist/tools/javascript-repl.d.ts.map +1 -1
- package/dist/tools/javascript-repl.js +101 -133
- package/dist/tools/javascript-repl.js.map +1 -1
- package/dist/tools/renderer-registry.d.ts +12 -0
- package/dist/tools/renderer-registry.d.ts.map +1 -1
- package/dist/tools/renderer-registry.js +78 -0
- package/dist/tools/renderer-registry.js.map +1 -1
- package/dist/tools/renderers/BashRenderer.d.ts +2 -4
- package/dist/tools/renderers/BashRenderer.d.ts.map +1 -1
- package/dist/tools/renderers/BashRenderer.js +30 -26
- package/dist/tools/renderers/BashRenderer.js.map +1 -1
- package/dist/tools/renderers/CalculateRenderer.d.ts +2 -4
- package/dist/tools/renderers/CalculateRenderer.d.ts.map +1 -1
- package/dist/tools/renderers/CalculateRenderer.js +32 -28
- package/dist/tools/renderers/CalculateRenderer.js.map +1 -1
- package/dist/tools/renderers/DefaultRenderer.d.ts +2 -4
- package/dist/tools/renderers/DefaultRenderer.d.ts.map +1 -1
- package/dist/tools/renderers/DefaultRenderer.js +78 -18
- package/dist/tools/renderers/DefaultRenderer.js.map +1 -1
- package/dist/tools/renderers/GetCurrentTimeRenderer.d.ts +2 -4
- package/dist/tools/renderers/GetCurrentTimeRenderer.d.ts.map +1 -1
- package/dist/tools/renderers/GetCurrentTimeRenderer.js +57 -21
- package/dist/tools/renderers/GetCurrentTimeRenderer.js.map +1 -1
- package/dist/tools/types.d.ts +5 -2
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/i18n.d.ts +424 -1
- package/dist/utils/i18n.d.ts.map +1 -1
- package/dist/utils/i18n.js +131 -7
- package/dist/utils/i18n.js.map +1 -1
- package/example/package.json +2 -1
- package/example/src/custom-messages.ts +112 -0
- package/example/src/main.ts +391 -38
- package/package.json +48 -43
- package/scripts/count-prompt-tokens.ts +88 -0
- package/src/ChatPanel.ts +93 -101
- package/src/{state/agent-session.ts → agent/agent.ts} +80 -55
- package/src/{state → agent}/transports/AppTransport.ts +6 -6
- package/src/{state → agent}/transports/ProviderTransport.ts +13 -7
- package/src/{state → agent}/transports/types.ts +8 -2
- package/src/components/AgentInterface.ts +32 -16
- package/src/components/ConsoleBlock.ts +5 -1
- package/src/components/ExpandableSection.ts +46 -0
- package/src/components/MessageEditor.ts +159 -5
- package/src/components/MessageList.ts +18 -3
- package/src/components/Messages.ts +48 -89
- package/src/components/ProviderKeyInput.ts +6 -5
- package/src/components/SandboxedIframe.ts +412 -321
- package/src/components/message-renderer-registry.ts +28 -0
- package/src/components/sandbox/ArtifactsRuntimeProvider.ts +219 -0
- package/src/components/sandbox/AttachmentsRuntimeProvider.ts +66 -0
- package/src/components/sandbox/ConsoleRuntimeProvider.ts +187 -0
- package/src/components/sandbox/FileDownloadRuntimeProvider.ts +110 -0
- package/src/components/sandbox/RuntimeMessageBridge.ts +82 -0
- package/src/components/sandbox/RuntimeMessageRouter.ts +216 -0
- package/src/components/sandbox/SandboxRuntimeProvider.ts +35 -0
- package/src/dialogs/ApiKeyPromptDialog.ts +2 -5
- package/src/dialogs/ModelSelector.ts +2 -2
- package/src/dialogs/PersistentStorageDialog.ts +141 -0
- package/src/dialogs/SessionListDialog.ts +148 -0
- package/src/dialogs/SettingsDialog.ts +1 -0
- package/src/index.ts +61 -20
- package/src/prompts/prompts.ts +282 -0
- package/src/storage/app-storage.ts +27 -24
- package/src/storage/backends/indexeddb-storage-backend.ts +193 -0
- package/src/storage/store.ts +33 -0
- package/src/storage/stores/provider-keys-store.ts +33 -0
- package/src/storage/stores/sessions-store.ts +130 -0
- package/src/storage/stores/settings-store.ts +34 -0
- package/src/storage/types.ts +182 -22
- package/src/tools/artifacts/ArtifactElement.ts +0 -1
- package/src/tools/artifacts/ArtifactPill.ts +25 -0
- package/src/tools/artifacts/Console.ts +93 -0
- package/src/tools/artifacts/DocxArtifact.ts +213 -0
- package/src/tools/artifacts/ExcelArtifact.ts +231 -0
- package/src/tools/artifacts/GenericArtifact.ts +117 -0
- package/src/tools/artifacts/HtmlArtifact.ts +64 -94
- package/src/tools/artifacts/ImageArtifact.ts +116 -0
- package/src/tools/artifacts/MarkdownArtifact.ts +0 -1
- package/src/tools/artifacts/PdfArtifact.ts +201 -0
- package/src/tools/artifacts/SvgArtifact.ts +0 -1
- package/src/tools/artifacts/TextArtifact.ts +0 -1
- package/src/tools/artifacts/artifacts-tool-renderer.ts +298 -0
- package/src/tools/artifacts/artifacts.ts +190 -366
- package/src/tools/artifacts/index.ts +1 -0
- package/src/tools/extract-document.ts +250 -0
- package/src/tools/index.ts +25 -14
- package/src/tools/javascript-repl.ts +138 -160
- package/src/tools/renderer-registry.ts +98 -0
- package/src/tools/renderers/BashRenderer.ts +33 -30
- package/src/tools/renderers/CalculateRenderer.ts +36 -31
- package/src/tools/renderers/DefaultRenderer.ts +84 -21
- package/src/tools/renderers/GetCurrentTimeRenderer.ts +68 -23
- package/src/tools/types.ts +10 -2
- package/src/utils/i18n.ts +203 -8
- package/dist/state/agent-session.d.ts.map +0 -1
- package/dist/state/agent-session.js.map +0 -1
- package/dist/state/transports/AppTransport.d.ts.map +0 -1
- package/dist/state/transports/ProviderTransport.d.ts.map +0 -1
- package/dist/state/transports/ProviderTransport.js.map +0 -1
- package/dist/state/transports/index.js.map +0 -1
- package/dist/state/transports/proxy-types.js.map +0 -1
- package/dist/state/transports/types.d.ts +0 -11
- package/dist/state/transports/types.d.ts.map +0 -1
- package/dist/storage/backends/chrome-storage-backend.d.ts +0 -18
- package/dist/storage/backends/chrome-storage-backend.d.ts.map +0 -1
- package/dist/storage/backends/chrome-storage-backend.js +0 -67
- package/dist/storage/backends/chrome-storage-backend.js.map +0 -1
- package/dist/storage/backends/indexeddb-backend.d.ts +0 -20
- package/dist/storage/backends/indexeddb-backend.d.ts.map +0 -1
- package/dist/storage/backends/indexeddb-backend.js +0 -89
- package/dist/storage/backends/indexeddb-backend.js.map +0 -1
- package/dist/storage/backends/local-storage-backend.d.ts +0 -18
- package/dist/storage/backends/local-storage-backend.d.ts.map +0 -1
- package/dist/storage/backends/local-storage-backend.js +0 -69
- package/dist/storage/backends/local-storage-backend.js.map +0 -1
- package/dist/storage/repositories/provider-keys-repository.d.ts +0 -34
- package/dist/storage/repositories/provider-keys-repository.d.ts.map +0 -1
- package/dist/storage/repositories/provider-keys-repository.js +0 -50
- package/dist/storage/repositories/provider-keys-repository.js.map +0 -1
- package/dist/storage/repositories/settings-repository.d.ts +0 -34
- package/dist/storage/repositories/settings-repository.d.ts.map +0 -1
- package/dist/storage/repositories/settings-repository.js +0 -46
- package/dist/storage/repositories/settings-repository.js.map +0 -1
- package/src/storage/backends/chrome-storage-backend.ts +0 -82
- package/src/storage/backends/indexeddb-backend.ts +0 -107
- package/src/storage/backends/local-storage-backend.ts +0 -74
- package/src/storage/repositories/provider-keys-repository.ts +0 -55
- package/src/storage/repositories/settings-repository.ts +0 -51
- /package/dist/{state → agent}/transports/index.d.ts +0 -0
- /package/dist/{state → agent}/transports/index.js +0 -0
- /package/dist/{state → agent}/transports/proxy-types.d.ts +0 -0
- /package/dist/{state → agent}/transports/proxy-types.js +0 -0
- /package/dist/{state → agent}/transports/types.js +0 -0
- /package/dist/{state → agent}/types.d.ts +0 -0
- /package/dist/{state → agent}/types.js +0 -0
- /package/src/{state → agent}/transports/index.ts +0 -0
- /package/src/{state → agent}/transports/proxy-types.ts +0 -0
- /package/src/{state → agent}/types.ts +0 -0
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { html, i18n } from "@mariozechner/mini-lit";
|
|
2
2
|
import { Type } from "@sinclair/typebox";
|
|
3
|
+
import { createRef, ref } from "lit/directives/ref.js";
|
|
4
|
+
import { Code } from "lucide";
|
|
3
5
|
import { SandboxIframe } from "../components/SandboxedIframe.js";
|
|
4
|
-
import {
|
|
6
|
+
import { JAVASCRIPT_REPL_TOOL_DESCRIPTION } from "../prompts/prompts.js";
|
|
7
|
+
import { registerToolRenderer, renderCollapsibleHeader, renderHeader } from "./renderer-registry.js";
|
|
5
8
|
// Execute JavaScript code with attachments using SandboxedIframe
|
|
6
|
-
export async function executeJavaScript(code,
|
|
9
|
+
export async function executeJavaScript(code, runtimeProviders, signal, sandboxUrlProvider) {
|
|
7
10
|
if (!code) {
|
|
8
11
|
throw new Error("Code parameter is required");
|
|
9
12
|
}
|
|
@@ -19,26 +22,34 @@ export async function executeJavaScript(code, attachments = [], signal, sandboxU
|
|
|
19
22
|
sandbox.style.display = "none";
|
|
20
23
|
document.body.appendChild(sandbox);
|
|
21
24
|
try {
|
|
22
|
-
const sandboxId = `repl-${Date.now()}`;
|
|
23
|
-
|
|
25
|
+
const sandboxId = `repl-${Date.now()}-${Math.random().toString(36).substring(7)}`;
|
|
26
|
+
// Pass providers to execute (router handles all message routing)
|
|
27
|
+
// No additional consumers needed - execute() has its own internal consumer
|
|
28
|
+
const result = await sandbox.execute(sandboxId, code, runtimeProviders, [], signal);
|
|
24
29
|
// Remove the sandbox iframe after execution
|
|
25
30
|
sandbox.remove();
|
|
26
|
-
// Return plain text output
|
|
27
|
-
if (!result.success) {
|
|
28
|
-
// Return error as plain text
|
|
29
|
-
return {
|
|
30
|
-
output: `Error: ${result.error?.message || "Unknown error"}\n${result.error?.stack || ""}`,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
31
|
// Build plain text response
|
|
34
32
|
let output = "";
|
|
35
33
|
// Add console output - result.console contains { type: string, text: string } from sandbox.js
|
|
36
34
|
if (result.console && result.console.length > 0) {
|
|
37
35
|
for (const entry of result.console) {
|
|
38
|
-
|
|
39
|
-
output += (prefix ? `${prefix} ` : "") + entry.text + "\n";
|
|
36
|
+
output += entry.text + "\n";
|
|
40
37
|
}
|
|
41
38
|
}
|
|
39
|
+
// Add error if execution failed
|
|
40
|
+
if (!result.success) {
|
|
41
|
+
if (output)
|
|
42
|
+
output += "\n";
|
|
43
|
+
output += `Error: ${result.error?.message || "Unknown error"}\n${result.error?.stack || ""}`;
|
|
44
|
+
// Throw error so tool call is marked as failed
|
|
45
|
+
throw new Error(output.trim());
|
|
46
|
+
}
|
|
47
|
+
// Add return value if present
|
|
48
|
+
if (result.returnValue !== undefined) {
|
|
49
|
+
if (output)
|
|
50
|
+
output += "\n";
|
|
51
|
+
output += `=> ${typeof result.returnValue === "object" ? JSON.stringify(result.returnValue, null, 2) : result.returnValue}`;
|
|
52
|
+
}
|
|
42
53
|
// Add file notifications
|
|
43
54
|
if (result.files && result.files.length > 0) {
|
|
44
55
|
output += `\n[Files returned: ${result.files.length}]\n`;
|
|
@@ -64,90 +75,26 @@ export async function executeJavaScript(code, attachments = [], signal, sandboxU
|
|
|
64
75
|
}
|
|
65
76
|
}
|
|
66
77
|
const javascriptReplSchema = Type.Object({
|
|
78
|
+
title: Type.String({
|
|
79
|
+
description: "Brief title describing what the code snippet tries to achieve in active form, e.g. 'Calculating sum'",
|
|
80
|
+
}),
|
|
67
81
|
code: Type.String({ description: "JavaScript code to execute" }),
|
|
68
82
|
});
|
|
69
83
|
export function createJavaScriptReplTool() {
|
|
70
84
|
return {
|
|
71
85
|
label: "JavaScript REPL",
|
|
72
86
|
name: "javascript_repl",
|
|
73
|
-
|
|
87
|
+
runtimeProvidersFactory: () => [], // default to empty array
|
|
74
88
|
sandboxUrlProvider: undefined, // optional, for browser extensions
|
|
75
|
-
description
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
- Fetch API for HTTP requests
|
|
81
|
-
|
|
82
|
-
Loading external libraries via dynamic imports (use esm.run):
|
|
83
|
-
- XLSX (Excel files): const XLSX = await import('https://esm.run/xlsx');
|
|
84
|
-
- Papa Parse (CSV): const Papa = (await import('https://esm.run/papaparse')).default;
|
|
85
|
-
- Lodash: const _ = await import('https://esm.run/lodash-es');
|
|
86
|
-
- D3.js: const d3 = await import('https://esm.run/d3');
|
|
87
|
-
- Chart.js: const Chart = (await import('https://esm.run/chart.js/auto')).default;
|
|
88
|
-
- Three.js: const THREE = await import('https://esm.run/three');
|
|
89
|
-
- Any npm package: await import('https://esm.run/package-name')
|
|
90
|
-
|
|
91
|
-
IMPORTANT for graphics/canvas:
|
|
92
|
-
- Use fixed dimensions like 400x400 or 800x600, NOT window.innerWidth/Height
|
|
93
|
-
- For Three.js: renderer.setSize(400, 400) and camera aspect ratio of 1
|
|
94
|
-
- For Chart.js: Set options: { responsive: false, animation: false } to ensure immediate rendering
|
|
95
|
-
- Web Storage (localStorage, sessionStorage, IndexedDB)
|
|
96
|
-
- Web Workers, WebAssembly, WebSockets
|
|
97
|
-
- Media APIs (Audio, Video, WebRTC)
|
|
98
|
-
- File APIs (Blob, FileReader, etc.)
|
|
99
|
-
- Crypto API for cryptography
|
|
100
|
-
- And much more - anything a modern browser supports!
|
|
101
|
-
|
|
102
|
-
Output:
|
|
103
|
-
- console.log() - All output is captured as text
|
|
104
|
-
- await returnFile(filename, content, mimeType?) - Create downloadable files (async function!)
|
|
105
|
-
* Always use await with returnFile
|
|
106
|
-
* REQUIRED: For Blob/Uint8Array binary content, you MUST supply a proper MIME type (e.g., "image/png").
|
|
107
|
-
If omitted, the REPL throws an Error with stack trace pointing to the offending line.
|
|
108
|
-
* Strings without a MIME default to text/plain.
|
|
109
|
-
* Objects are auto-JSON stringified and default to application/json unless a MIME is provided.
|
|
110
|
-
* Canvas images: Use toBlob() with await Promise wrapper
|
|
111
|
-
* Examples:
|
|
112
|
-
- await returnFile('data.txt', 'Hello World', 'text/plain')
|
|
113
|
-
- await returnFile('data.json', {key: 'value'}, 'application/json')
|
|
114
|
-
- await returnFile('data.csv', 'name,age\\nJohn,30', 'text/csv')
|
|
115
|
-
- Chart.js example:
|
|
116
|
-
const Chart = (await import('https://esm.run/chart.js/auto')).default;
|
|
117
|
-
const canvas = document.createElement('canvas');
|
|
118
|
-
canvas.width = 400; canvas.height = 300;
|
|
119
|
-
document.body.appendChild(canvas);
|
|
120
|
-
new Chart(canvas, {
|
|
121
|
-
type: 'line',
|
|
122
|
-
data: {
|
|
123
|
-
labels: ['Jan', 'Feb', 'Mar', 'Apr'],
|
|
124
|
-
datasets: [{ label: 'Sales', data: [10, 20, 15, 25], borderColor: 'blue' }]
|
|
89
|
+
get description() {
|
|
90
|
+
const runtimeProviderDescriptions = this.runtimeProvidersFactory?.()
|
|
91
|
+
.map((d) => d.getDescription())
|
|
92
|
+
.filter((d) => d.trim().length > 0) || [];
|
|
93
|
+
return JAVASCRIPT_REPL_TOOL_DESCRIPTION(runtimeProviderDescriptions);
|
|
125
94
|
},
|
|
126
|
-
options: { responsive: false, animation: false }
|
|
127
|
-
});
|
|
128
|
-
const blob = await new Promise(resolve => canvas.toBlob(resolve, 'image/png'));
|
|
129
|
-
await returnFile('chart.png', blob, 'image/png');
|
|
130
|
-
|
|
131
|
-
Global variables:
|
|
132
|
-
- attachments[] - Array of attachment objects from user messages
|
|
133
|
-
* Properties:
|
|
134
|
-
- id: string (unique identifier)
|
|
135
|
-
- fileName: string (e.g., "data.xlsx")
|
|
136
|
-
- mimeType: string (e.g., "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
|
137
|
-
- size: number (bytes)
|
|
138
|
-
* Helper functions:
|
|
139
|
-
- listFiles() - Returns array of {id, fileName, mimeType, size} for all attachments
|
|
140
|
-
- readTextFile(attachmentId) - Returns text content of attachment (for CSV, JSON, text files)
|
|
141
|
-
- readBinaryFile(attachmentId) - Returns Uint8Array of binary data (for images, Excel, etc.)
|
|
142
|
-
* Examples:
|
|
143
|
-
- const files = listFiles();
|
|
144
|
-
- const csvContent = readTextFile(files[0].id); // Read CSV as text
|
|
145
|
-
- const xlsxBytes = readBinaryFile(files[0].id); // Read Excel as binary
|
|
146
|
-
- All standard browser globals (window, document, fetch, etc.)`,
|
|
147
95
|
parameters: javascriptReplSchema,
|
|
148
96
|
execute: async function (_toolCallId, args, signal) {
|
|
149
|
-
const
|
|
150
|
-
const result = await executeJavaScript(args.code, attachments, signal, this.sandboxUrlProvider);
|
|
97
|
+
const result = await executeJavaScript(args.code, this.runtimeProvidersFactory?.() ?? [], signal, this.sandboxUrlProvider);
|
|
151
98
|
// Convert files to JSON-serializable with base64 payloads
|
|
152
99
|
const files = (result.files || []).map((f) => {
|
|
153
100
|
const toBase64 = (input) => {
|
|
@@ -196,55 +143,76 @@ Global variables:
|
|
|
196
143
|
// Export a default instance for backward compatibility
|
|
197
144
|
export const javascriptReplTool = createJavaScriptReplTool();
|
|
198
145
|
export const javascriptReplRenderer = {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
f.
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
catch (e) {
|
|
224
|
-
console.warn("Failed to decode base64 content for", f.fileName);
|
|
146
|
+
render(params, result, isStreaming) {
|
|
147
|
+
// Determine status
|
|
148
|
+
const state = result ? (result.isError ? "error" : "complete") : isStreaming ? "inprogress" : "complete";
|
|
149
|
+
// Create refs for collapsible code section
|
|
150
|
+
const codeContentRef = createRef();
|
|
151
|
+
const codeChevronRef = createRef();
|
|
152
|
+
// With result: show params + result
|
|
153
|
+
if (result && params) {
|
|
154
|
+
const output = result.output || "";
|
|
155
|
+
const files = result.details?.files || [];
|
|
156
|
+
const attachments = files.map((f, i) => {
|
|
157
|
+
// Decode base64 content for text files to show in overlay
|
|
158
|
+
let extractedText;
|
|
159
|
+
const isTextBased = f.mimeType?.startsWith("text/") ||
|
|
160
|
+
f.mimeType === "application/json" ||
|
|
161
|
+
f.mimeType === "application/javascript" ||
|
|
162
|
+
f.mimeType?.includes("xml");
|
|
163
|
+
if (isTextBased && f.contentBase64) {
|
|
164
|
+
try {
|
|
165
|
+
extractedText = atob(f.contentBase64);
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
console.warn("Failed to decode base64 content for", f.fileName);
|
|
169
|
+
}
|
|
225
170
|
}
|
|
226
|
-
|
|
171
|
+
return {
|
|
172
|
+
id: `repl-${Date.now()}-${i}`,
|
|
173
|
+
type: f.mimeType?.startsWith("image/") ? "image" : "document",
|
|
174
|
+
fileName: f.fileName || `file-${i}`,
|
|
175
|
+
mimeType: f.mimeType || "application/octet-stream",
|
|
176
|
+
size: f.size ?? 0,
|
|
177
|
+
content: f.contentBase64,
|
|
178
|
+
preview: f.mimeType?.startsWith("image/") ? f.contentBase64 : undefined,
|
|
179
|
+
extractedText,
|
|
180
|
+
};
|
|
181
|
+
});
|
|
227
182
|
return {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
183
|
+
content: html `
|
|
184
|
+
<div>
|
|
185
|
+
${renderCollapsibleHeader(state, Code, params.title ? params.title : i18n("Executing JavaScript"), codeContentRef, codeChevronRef, false)}
|
|
186
|
+
<div ${ref(codeContentRef)} class="max-h-0 overflow-hidden transition-all duration-300 space-y-3">
|
|
187
|
+
<code-block .code=${params.code || ""} language="javascript"></code-block>
|
|
188
|
+
${output ? html `<console-block .content=${output} .variant=${result.isError ? "error" : "default"}></console-block>` : ""}
|
|
189
|
+
</div>
|
|
190
|
+
${attachments.length
|
|
191
|
+
? html `<div class="flex flex-wrap gap-2 mt-3">
|
|
192
|
+
${attachments.map((att) => html `<attachment-tile .attachment=${att}></attachment-tile>`)}
|
|
193
|
+
</div>`
|
|
194
|
+
: ""}
|
|
195
|
+
</div>
|
|
196
|
+
`,
|
|
197
|
+
isCustom: false,
|
|
236
198
|
};
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
199
|
+
}
|
|
200
|
+
// Just params (streaming or waiting for result)
|
|
201
|
+
if (params) {
|
|
202
|
+
return {
|
|
203
|
+
content: html `
|
|
204
|
+
<div>
|
|
205
|
+
${renderCollapsibleHeader(state, Code, params.title ? params.title : i18n("Executing JavaScript"), codeContentRef, codeChevronRef, false)}
|
|
206
|
+
<div ${ref(codeContentRef)} class="max-h-0 overflow-hidden transition-all duration-300">
|
|
207
|
+
${params.code ? html `<code-block .code=${params.code} language="javascript"></code-block>` : ""}
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
`,
|
|
211
|
+
isCustom: false,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
// No params or result yet
|
|
215
|
+
return { content: renderHeader(state, Code, i18n("Preparing JavaScript...")), isCustom: false };
|
|
248
216
|
},
|
|
249
217
|
};
|
|
250
218
|
// Auto-register the renderer
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"javascript-repl.js","sourceRoot":"","sources":["../../src/tools/javascript-repl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"javascript-repl.js","sourceRoot":"","sources":["../../src/tools/javascript-repl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAe,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAoB,aAAa,EAAsB,MAAM,kCAAkC,CAAC;AAEvG,OAAO,EAAE,gCAAgC,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGrG,iEAAiE;AACjE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACtC,IAAY,EACZ,gBAA0C,EAC1C,MAAoB,EACpB,kBAAiC;IAEjC,IAAI,CAAC,IAAI,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAC/C,CAAC;IAED,kCAAkC;IAClC,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AAC,IAAI,CAAC,sBAAsB,CAAC,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,CAAC;aAClI,GAAG,CAAC,cAAc,CAAC;SACvB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA,qBAAqB,MAAM,CAAC,IAAI,sCAAsC,CAAC,CAAC,CAAC,EAAE;;;KAGjG;gBACD,QAAQ,EAAE,KAAK;aACf,CAAC;QACH,CAAC;QAED,0BAA0B;QAC1B,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,yBAAyB,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACjG,CAAC;CACD,CAAC;AAEF,6BAA6B;AAC7B,oBAAoB,CAAC,kBAAkB,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type TemplateResult } from "@mariozechner/mini-lit";
|
|
2
|
+
import type { Ref } from "lit/directives/ref.js";
|
|
1
3
|
import type { ToolRenderer } from "./types.js";
|
|
2
4
|
export declare const toolRenderers: Map<string, ToolRenderer<any, any>>;
|
|
3
5
|
/**
|
|
@@ -8,4 +10,14 @@ export declare function registerToolRenderer(toolName: string, renderer: ToolRen
|
|
|
8
10
|
* Get a tool renderer by name
|
|
9
11
|
*/
|
|
10
12
|
export declare function getToolRenderer(toolName: string): ToolRenderer | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Helper to render a header for tool renderers
|
|
15
|
+
* Shows icon on left when complete/error, spinner on right when in progress
|
|
16
|
+
*/
|
|
17
|
+
export declare function renderHeader(state: "inprogress" | "complete" | "error", toolIcon: any, text: string | TemplateResult): TemplateResult;
|
|
18
|
+
/**
|
|
19
|
+
* Helper to render a collapsible header for tool renderers
|
|
20
|
+
* Same as renderHeader but with a chevron button that toggles visibility of content
|
|
21
|
+
*/
|
|
22
|
+
export declare function renderCollapsibleHeader(state: "inprogress" | "complete" | "error", toolIcon: any, text: string | TemplateResult, contentRef: Ref<HTMLElement>, chevronRef: Ref<HTMLElement>, defaultExpanded?: boolean): TemplateResult;
|
|
11
23
|
//# sourceMappingURL=renderer-registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer-registry.d.ts","sourceRoot":"","sources":["../../src/tools/renderer-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,eAAO,MAAM,aAAa,qCAAkC,CAAC;AAE7D;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI,CAEnF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAE1E"}
|
|
1
|
+
{"version":3,"file":"renderer-registry.d.ts","sourceRoot":"","sources":["../../src/tools/renderer-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAGjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,eAAO,MAAM,aAAa,qCAAkC,CAAC;AAE7D;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI,CAEnF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAE1E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC3B,KAAK,EAAE,YAAY,GAAG,UAAU,GAAG,OAAO,EAC1C,QAAQ,EAAE,GAAG,EACb,IAAI,EAAE,MAAM,GAAG,cAAc,GAC3B,cAAc,CA8BhB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,YAAY,GAAG,UAAU,GAAG,OAAO,EAC1C,QAAQ,EAAE,GAAG,EACb,IAAI,EAAE,MAAM,GAAG,cAAc,EAC7B,UAAU,EAAE,GAAG,CAAC,WAAW,CAAC,EAC5B,UAAU,EAAE,GAAG,CAAC,WAAW,CAAC,EAC5B,eAAe,UAAQ,GACrB,cAAc,CAyChB"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { html, icon } from "@mariozechner/mini-lit";
|
|
2
|
+
import { ref } from "lit/directives/ref.js";
|
|
3
|
+
import { ChevronRight, Loader } from "lucide";
|
|
1
4
|
// Registry of tool renderers
|
|
2
5
|
export const toolRenderers = new Map();
|
|
3
6
|
/**
|
|
@@ -12,4 +15,79 @@ export function registerToolRenderer(toolName, renderer) {
|
|
|
12
15
|
export function getToolRenderer(toolName) {
|
|
13
16
|
return toolRenderers.get(toolName);
|
|
14
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Helper to render a header for tool renderers
|
|
20
|
+
* Shows icon on left when complete/error, spinner on right when in progress
|
|
21
|
+
*/
|
|
22
|
+
export function renderHeader(state, toolIcon, text) {
|
|
23
|
+
const statusIcon = (iconComponent, color) => html `<span class="inline-block ${color}">${icon(iconComponent, "sm")}</span>`;
|
|
24
|
+
switch (state) {
|
|
25
|
+
case "inprogress":
|
|
26
|
+
return html `
|
|
27
|
+
<div class="flex items-center justify-between gap-2 text-sm text-muted-foreground">
|
|
28
|
+
<div class="flex items-center gap-2">
|
|
29
|
+
${statusIcon(toolIcon, "text-foreground")}
|
|
30
|
+
${text}
|
|
31
|
+
</div>
|
|
32
|
+
${statusIcon(Loader, "text-foreground animate-spin")}
|
|
33
|
+
</div>
|
|
34
|
+
`;
|
|
35
|
+
case "complete":
|
|
36
|
+
return html `
|
|
37
|
+
<div class="flex items-center gap-2 text-sm text-muted-foreground">
|
|
38
|
+
${statusIcon(toolIcon, "text-green-600 dark:text-green-500")}
|
|
39
|
+
${text}
|
|
40
|
+
</div>
|
|
41
|
+
`;
|
|
42
|
+
case "error":
|
|
43
|
+
return html `
|
|
44
|
+
<div class="flex items-center gap-2 text-sm text-muted-foreground">
|
|
45
|
+
${statusIcon(toolIcon, "text-destructive")}
|
|
46
|
+
${text}
|
|
47
|
+
</div>
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Helper to render a collapsible header for tool renderers
|
|
53
|
+
* Same as renderHeader but with a chevron button that toggles visibility of content
|
|
54
|
+
*/
|
|
55
|
+
export function renderCollapsibleHeader(state, toolIcon, text, contentRef, chevronRef, defaultExpanded = false) {
|
|
56
|
+
const statusIcon = (iconComponent, color) => html `<span class="inline-block ${color}">${icon(iconComponent, "sm")}</span>`;
|
|
57
|
+
const toggleContent = (e) => {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
const content = contentRef.value;
|
|
60
|
+
const chevron = chevronRef.value;
|
|
61
|
+
if (content && chevron) {
|
|
62
|
+
const isCollapsed = content.classList.contains("max-h-0");
|
|
63
|
+
if (isCollapsed) {
|
|
64
|
+
content.classList.remove("max-h-0");
|
|
65
|
+
content.classList.add("max-h-[2000px]", "mt-3");
|
|
66
|
+
chevron.classList.add("rotate-90");
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
content.classList.remove("max-h-[2000px]", "mt-3");
|
|
70
|
+
content.classList.add("max-h-0");
|
|
71
|
+
chevron.classList.remove("rotate-90");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const toolIconColor = state === "complete"
|
|
76
|
+
? "text-green-600 dark:text-green-500"
|
|
77
|
+
: state === "error"
|
|
78
|
+
? "text-destructive"
|
|
79
|
+
: "text-foreground";
|
|
80
|
+
return html `
|
|
81
|
+
<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">
|
|
82
|
+
<div class="flex items-center gap-2">
|
|
83
|
+
${state === "inprogress" ? statusIcon(Loader, "text-foreground animate-spin") : ""}
|
|
84
|
+
${statusIcon(toolIcon, toolIconColor)}
|
|
85
|
+
${text}
|
|
86
|
+
</div>
|
|
87
|
+
<span class="inline-block text-muted-foreground transition-transform duration-300 ${defaultExpanded ? "rotate-90" : ""}" ${ref(chevronRef)}>
|
|
88
|
+
${icon(ChevronRight, "sm")}
|
|
89
|
+
</span>
|
|
90
|
+
</button>
|
|
91
|
+
`;
|
|
92
|
+
}
|
|
15
93
|
//# sourceMappingURL=renderer-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer-registry.js","sourceRoot":"","sources":["../../src/tools/renderer-registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderer-registry.js","sourceRoot":"","sources":["../../src/tools/renderer-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAuB,MAAM,wBAAwB,CAAC;AAEzE,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAG9C,6BAA6B;AAC7B,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAwB,CAAC;AAE7D;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB,EAAE,QAAsB;IAC5E,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC/C,OAAO,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC3B,KAA0C,EAC1C,QAAa,EACb,IAA6B;IAE7B,MAAM,UAAU,GAAG,CAAC,aAAkB,EAAE,KAAa,EAAE,EAAE,CACxD,IAAI,CAAA,6BAA6B,KAAK,KAAK,IAAI,CAAC,aAAa,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AAO,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YACpC,CAAC;iBAAM,CAAC;gBACP,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;gBACnD,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBACjC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YACvC,CAAC;QACF,CAAC;IACF,CAAC,CAAC;IAEF,MAAM,aAAa,GAClB,KAAK,KAAK,UAAU;QACnB,CAAC,CAAC,oCAAoC;QACtC,CAAC,CAAC,KAAK,KAAK,OAAO;YAClB,CAAC,CAAC,kBAAkB;YACpB,CAAC,CAAC,iBAAiB,CAAC;IAEvB,OAAO,IAAI,CAAA;mBACO,aAAa;;MAE1B,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAC,CAAC,CAAC,EAAE;MAChF,UAAU,CAAC,QAAQ,EAAE,aAAa,CAAC;MACnC,IAAI;;uFAE6E,eAAe,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,UAAU,CAAC;MACvI,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC;;;EAG5B,CAAC;AACH,CAAC"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { type TemplateResult } from "@mariozechner/mini-lit";
|
|
2
1
|
import type { ToolResultMessage } from "@mariozechner/pi-ai";
|
|
3
|
-
import type { ToolRenderer } from "../types.js";
|
|
2
|
+
import type { ToolRenderer, ToolRenderResult } from "../types.js";
|
|
4
3
|
interface BashParams {
|
|
5
4
|
command: string;
|
|
6
5
|
}
|
|
7
6
|
export declare class BashRenderer implements ToolRenderer<BashParams, undefined> {
|
|
8
|
-
|
|
9
|
-
renderResult(_params: BashParams, result: ToolResultMessage<undefined>): TemplateResult;
|
|
7
|
+
render(params: BashParams | undefined, result: ToolResultMessage<undefined> | undefined): ToolRenderResult;
|
|
10
8
|
}
|
|
11
9
|
export {};
|
|
12
10
|
//# sourceMappingURL=BashRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BashRenderer.d.ts","sourceRoot":"","sources":["../../../src/tools/renderers/BashRenderer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BashRenderer.d.ts","sourceRoot":"","sources":["../../../src/tools/renderers/BashRenderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAI7D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAElE,UAAU,UAAU;IACnB,OAAO,EAAE,MAAM,CAAC;CAChB;AAGD,qBAAa,YAAa,YAAW,YAAY,CAAC,UAAU,EAAE,SAAS,CAAC;IACvE,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,EAAE,MAAM,EAAE,iBAAiB,CAAC,SAAS,CAAC,GAAG,SAAS,GAAG,gBAAgB;CAkC1G"}
|
|
@@ -1,35 +1,39 @@
|
|
|
1
1
|
import { html } from "@mariozechner/mini-lit";
|
|
2
|
+
import { SquareTerminal } from "lucide";
|
|
2
3
|
import { i18n } from "../../utils/i18n.js";
|
|
4
|
+
import { renderHeader } from "../renderer-registry.js";
|
|
3
5
|
// Bash tool has undefined details (only uses output)
|
|
4
6
|
export class BashRenderer {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
render(params, result) {
|
|
8
|
+
const state = result ? (result.isError ? "error" : "complete") : "inprogress";
|
|
9
|
+
// With result: show command + output
|
|
10
|
+
if (result && params?.command) {
|
|
11
|
+
const output = result.output || "";
|
|
12
|
+
const combined = output ? `> ${params.command}\n\n${output}` : `> ${params.command}`;
|
|
13
|
+
return {
|
|
14
|
+
content: html `
|
|
15
|
+
<div class="space-y-3">
|
|
16
|
+
${renderHeader(state, SquareTerminal, i18n("Running command..."))}
|
|
17
|
+
<console-block .content=${combined} .variant=${result.isError ? "error" : "default"}></console-block>
|
|
18
|
+
</div>
|
|
19
|
+
`,
|
|
20
|
+
isCustom: false,
|
|
21
|
+
};
|
|
8
22
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return html `
|
|
21
|
-
<div class="text-sm">
|
|
22
|
-
<div class="text-destructive font-medium mb-1">${i18n("Command failed:")}</div>
|
|
23
|
-
<pre class="text-xs font-mono text-destructive bg-destructive/10 p-2 rounded overflow-x-auto">${output}</pre>
|
|
24
|
-
</div>
|
|
25
|
-
`;
|
|
23
|
+
// Just params (streaming or waiting)
|
|
24
|
+
if (params?.command) {
|
|
25
|
+
return {
|
|
26
|
+
content: html `
|
|
27
|
+
<div class="space-y-3">
|
|
28
|
+
${renderHeader(state, SquareTerminal, i18n("Running command..."))}
|
|
29
|
+
<console-block .content=${`> ${params.command}`}></console-block>
|
|
30
|
+
</div>
|
|
31
|
+
`,
|
|
32
|
+
isCustom: false,
|
|
33
|
+
};
|
|
26
34
|
}
|
|
27
|
-
//
|
|
28
|
-
return
|
|
29
|
-
<div class="text-sm">
|
|
30
|
-
<pre class="text-xs font-mono text-foreground bg-muted/50 p-2 rounded overflow-x-auto">${output}</pre>
|
|
31
|
-
</div>
|
|
32
|
-
`;
|
|
35
|
+
// No params yet
|
|
36
|
+
return { content: renderHeader(state, SquareTerminal, i18n("Waiting for command...")), isCustom: false };
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
//# sourceMappingURL=BashRenderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BashRenderer.js","sourceRoot":"","sources":["../../../src/tools/renderers/BashRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,
|
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C;gCACvC,KAAK,MAAM,CAAC,OAAO,EAAE;;KAEhD;gBACD,QAAQ,EAAE,KAAK;aACf,CAAC;QACH,CAAC;QAED,gBAAgB;QAChB,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,wBAAwB,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC1G,CAAC;CACD"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { type TemplateResult } from "@mariozechner/mini-lit";
|
|
2
1
|
import type { ToolResultMessage } from "@mariozechner/pi-ai";
|
|
3
|
-
import type { ToolRenderer } from "../types.js";
|
|
2
|
+
import type { ToolRenderer, ToolRenderResult } from "../types.js";
|
|
4
3
|
interface CalculateParams {
|
|
5
4
|
expression: string;
|
|
6
5
|
}
|
|
7
6
|
export declare class CalculateRenderer implements ToolRenderer<CalculateParams, undefined> {
|
|
8
|
-
|
|
9
|
-
renderResult(_params: CalculateParams, result: ToolResultMessage<undefined>): TemplateResult;
|
|
7
|
+
render(params: CalculateParams | undefined, result: ToolResultMessage<undefined> | undefined): ToolRenderResult;
|
|
10
8
|
}
|
|
11
9
|
export {};
|
|
12
10
|
//# sourceMappingURL=CalculateRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalculateRenderer.d.ts","sourceRoot":"","sources":["../../../src/tools/renderers/CalculateRenderer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CalculateRenderer.d.ts","sourceRoot":"","sources":["../../../src/tools/renderers/CalculateRenderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAI7D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAElE,UAAU,eAAe;IACxB,UAAU,EAAE,MAAM,CAAC;CACnB;AAGD,qBAAa,iBAAkB,YAAW,YAAY,CAAC,eAAe,EAAE,SAAS,CAAC;IACjF,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,EAAE,MAAM,EAAE,iBAAiB,CAAC,SAAS,CAAC,GAAG,SAAS,GAAG,gBAAgB;CAwC/G"}
|