@oh-my-pi/pi-web-ui 1.341.0 → 2.0.1337
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 +4 -0
- package/example/package.json +2 -1
- package/example/src/main.ts +1 -1
- package/package.json +3 -2
- package/scripts/count-prompt-tokens.ts +1 -1
- package/src/ChatPanel.ts +8 -8
- package/src/components/AgentInterface.ts +9 -9
- package/src/components/AttachmentTile.ts +3 -3
- package/src/components/ConsoleBlock.ts +1 -1
- package/src/components/CustomProviderCard.ts +1 -1
- package/src/components/Input.ts +1 -1
- package/src/components/MessageEditor.ts +2 -2
- package/src/components/MessageList.ts +1 -1
- package/src/components/Messages.ts +4 -4
- package/src/components/ProviderKeyInput.ts +3 -3
- package/src/components/SandboxedIframe.ts +4 -4
- package/src/components/sandbox/ArtifactsRuntimeProvider.ts +2 -2
- package/src/components/sandbox/AttachmentsRuntimeProvider.ts +3 -3
- package/src/components/sandbox/ConsoleRuntimeProvider.ts +1 -1
- package/src/components/sandbox/FileDownloadRuntimeProvider.ts +1 -1
- package/src/components/sandbox/RuntimeMessageRouter.ts +1 -1
- package/src/dialogs/ApiKeyPromptDialog.ts +2 -2
- package/src/dialogs/AttachmentOverlay.ts +2 -2
- package/src/dialogs/CustomProviderDialog.ts +3 -3
- package/src/dialogs/ModelSelector.ts +6 -6
- package/src/dialogs/PersistentStorageDialog.ts +1 -1
- package/src/dialogs/ProvidersModelsTab.ts +5 -5
- package/src/dialogs/SessionListDialog.ts +4 -4
- package/src/dialogs/SettingsDialog.ts +1 -1
- package/src/index.ts +62 -62
- package/src/storage/app-storage.ts +5 -5
- package/src/storage/backends/indexeddb-storage-backend.ts +1 -1
- package/src/storage/store.ts +1 -1
- package/src/storage/stores/custom-providers-store.ts +2 -2
- package/src/storage/stores/provider-keys-store.ts +2 -2
- package/src/storage/stores/sessions-store.ts +2 -2
- package/src/storage/stores/settings-store.ts +2 -2
- package/src/tools/artifacts/ArtifactPill.ts +1 -1
- package/src/tools/artifacts/Console.ts +1 -1
- package/src/tools/artifacts/DocxArtifact.ts +2 -2
- package/src/tools/artifacts/ExcelArtifact.ts +2 -2
- package/src/tools/artifacts/GenericArtifact.ts +2 -2
- package/src/tools/artifacts/HtmlArtifact.ts +6 -6
- package/src/tools/artifacts/ImageArtifact.ts +2 -2
- package/src/tools/artifacts/MarkdownArtifact.ts +2 -2
- package/src/tools/artifacts/PdfArtifact.ts +2 -2
- package/src/tools/artifacts/SvgArtifact.ts +2 -2
- package/src/tools/artifacts/TextArtifact.ts +2 -2
- package/src/tools/artifacts/artifacts-tool-renderer.ts +5 -5
- package/src/tools/artifacts/artifacts.ts +17 -17
- package/src/tools/artifacts/index.ts +7 -7
- package/src/tools/extract-document.ts +5 -5
- package/src/tools/index.ts +4 -4
- package/src/tools/javascript-repl.ts +6 -6
- package/src/tools/renderer-registry.ts +1 -1
- package/src/tools/renderers/BashRenderer.ts +3 -3
- package/src/tools/renderers/CalculateRenderer.ts +3 -3
- package/src/tools/renderers/DefaultRenderer.ts +3 -3
- package/src/tools/renderers/GetCurrentTimeRenderer.ts +3 -3
- package/src/utils/attachment-utils.ts +1 -1
- package/src/utils/auth-token.ts +1 -1
package/CHANGELOG.md
CHANGED
package/example/package.json
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"build": "vite build",
|
|
9
9
|
"preview": "vite preview",
|
|
10
10
|
"clean": "rm -rf dist",
|
|
11
|
-
"check": "biome check --write . && tsgo --noEmit"
|
|
11
|
+
"check": "biome check --write . && tsgo --noEmit",
|
|
12
|
+
"fix": "biome check --write --unsafe ."
|
|
12
13
|
},
|
|
13
14
|
"dependencies": {
|
|
14
15
|
"@mariozechner/mini-lit": "^0.2.0",
|
package/example/src/main.ts
CHANGED
|
@@ -25,7 +25,7 @@ import "./app.css";
|
|
|
25
25
|
import { icon } from "@mariozechner/mini-lit";
|
|
26
26
|
import { Button } from "@mariozechner/mini-lit/dist/Button.js";
|
|
27
27
|
import { Input } from "@mariozechner/mini-lit/dist/Input.js";
|
|
28
|
-
import { createSystemNotification, customConvertToLlm, registerCustomMessageRenderers } from "./custom-messages
|
|
28
|
+
import { createSystemNotification, customConvertToLlm, registerCustomMessageRenderers } from "./custom-messages";
|
|
29
29
|
|
|
30
30
|
// Register custom message renderers
|
|
31
31
|
registerCustomMessageRenderers();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oh-my-pi/pi-web-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1337",
|
|
4
4
|
"description": "Reusable web UI components for AI chat interfaces powered by @oh-my-pi/pi-ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"dev:example": "bun --cwd=example run dev",
|
|
15
15
|
"dev": "bun run dev:css & bun run dev:example",
|
|
16
16
|
"build:css": "tailwindcss -i ./src/app.css -o ./dist/app.css --minify",
|
|
17
|
-
"check": "biome check --write . && tsgo --noEmit && bun --cwd=example run check"
|
|
17
|
+
"check": "biome check --write . && tsgo --noEmit && bun --cwd=example run check",
|
|
18
|
+
"fix": "biome check --write --unsafe . && bun --cwd=example run fix"
|
|
18
19
|
},
|
|
19
20
|
"dependencies": {
|
|
20
21
|
"@lmstudio/sdk": "^1.5.0",
|
package/src/ChatPanel.ts
CHANGED
|
@@ -3,14 +3,14 @@ import { html, LitElement } from "lit";
|
|
|
3
3
|
import { customElement, state } from "lit/decorators.js";
|
|
4
4
|
import "./components/AgentInterface.js";
|
|
5
5
|
import type { Agent, AgentTool } from "@oh-my-pi/pi-agent-core";
|
|
6
|
-
import type { AgentInterface } from "./components/AgentInterface
|
|
7
|
-
import { ArtifactsRuntimeProvider } from "./components/sandbox/ArtifactsRuntimeProvider
|
|
8
|
-
import { AttachmentsRuntimeProvider } from "./components/sandbox/AttachmentsRuntimeProvider
|
|
9
|
-
import type { SandboxRuntimeProvider } from "./components/sandbox/SandboxRuntimeProvider
|
|
10
|
-
import { ArtifactsPanel, ArtifactsToolRenderer } from "./tools/artifacts/index
|
|
11
|
-
import { registerToolRenderer } from "./tools/renderer-registry
|
|
12
|
-
import type { Attachment } from "./utils/attachment-utils
|
|
13
|
-
import { i18n } from "./utils/i18n
|
|
6
|
+
import type { AgentInterface } from "./components/AgentInterface";
|
|
7
|
+
import { ArtifactsRuntimeProvider } from "./components/sandbox/ArtifactsRuntimeProvider";
|
|
8
|
+
import { AttachmentsRuntimeProvider } from "./components/sandbox/AttachmentsRuntimeProvider";
|
|
9
|
+
import type { SandboxRuntimeProvider } from "./components/sandbox/SandboxRuntimeProvider";
|
|
10
|
+
import { ArtifactsPanel, ArtifactsToolRenderer } from "./tools/artifacts/index";
|
|
11
|
+
import { registerToolRenderer } from "./tools/renderer-registry";
|
|
12
|
+
import type { Attachment } from "./utils/attachment-utils";
|
|
13
|
+
import { i18n } from "./utils/i18n";
|
|
14
14
|
|
|
15
15
|
const BREAKPOINT = 800; // px - switch between overlay and side-by-side
|
|
16
16
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { streamSimple, type ToolResultMessage, type Usage } from "@oh-my-pi/pi-ai";
|
|
2
2
|
import { html, LitElement } from "lit";
|
|
3
3
|
import { customElement, property, query } from "lit/decorators.js";
|
|
4
|
-
import { ModelSelector } from "../dialogs/ModelSelector
|
|
5
|
-
import type { MessageEditor } from "./MessageEditor
|
|
4
|
+
import { ModelSelector } from "../dialogs/ModelSelector";
|
|
5
|
+
import type { MessageEditor } from "./MessageEditor";
|
|
6
6
|
import "./MessageEditor.js";
|
|
7
7
|
import "./MessageList.js";
|
|
8
8
|
import "./Messages.js"; // Import for side effects to register the custom elements
|
|
9
|
-
import { getAppStorage } from "../storage/app-storage
|
|
9
|
+
import { getAppStorage } from "../storage/app-storage";
|
|
10
10
|
import "./StreamingMessageContainer.js";
|
|
11
11
|
import type { Agent, AgentEvent } from "@oh-my-pi/pi-agent-core";
|
|
12
|
-
import type { Attachment } from "../utils/attachment-utils
|
|
13
|
-
import { formatUsage } from "../utils/format
|
|
14
|
-
import { i18n } from "../utils/i18n
|
|
15
|
-
import { createStreamFn } from "../utils/proxy-utils
|
|
16
|
-
import type { UserMessageWithAttachments } from "./Messages
|
|
17
|
-
import type { StreamingMessageContainer } from "./StreamingMessageContainer
|
|
12
|
+
import type { Attachment } from "../utils/attachment-utils";
|
|
13
|
+
import { formatUsage } from "../utils/format";
|
|
14
|
+
import { i18n } from "../utils/i18n";
|
|
15
|
+
import { createStreamFn } from "../utils/proxy-utils";
|
|
16
|
+
import type { UserMessageWithAttachments } from "./Messages";
|
|
17
|
+
import type { StreamingMessageContainer } from "./StreamingMessageContainer";
|
|
18
18
|
|
|
19
19
|
@customElement("agent-interface")
|
|
20
20
|
export class AgentInterface extends LitElement {
|
|
@@ -3,9 +3,9 @@ import { LitElement } from "lit";
|
|
|
3
3
|
import { customElement, property } from "lit/decorators.js";
|
|
4
4
|
import { html } from "lit/html.js";
|
|
5
5
|
import { FileSpreadsheet, FileText, X } from "lucide";
|
|
6
|
-
import { AttachmentOverlay } from "../dialogs/AttachmentOverlay
|
|
7
|
-
import type { Attachment } from "../utils/attachment-utils
|
|
8
|
-
import { i18n } from "../utils/i18n
|
|
6
|
+
import { AttachmentOverlay } from "../dialogs/AttachmentOverlay";
|
|
7
|
+
import type { Attachment } from "../utils/attachment-utils";
|
|
8
|
+
import { i18n } from "../utils/i18n";
|
|
9
9
|
|
|
10
10
|
@customElement("attachment-tile")
|
|
11
11
|
export class AttachmentTile extends LitElement {
|
|
@@ -3,7 +3,7 @@ import { LitElement } from "lit";
|
|
|
3
3
|
import { property, state } from "lit/decorators.js";
|
|
4
4
|
import { html } from "lit/html.js";
|
|
5
5
|
import { Check, Copy } from "lucide";
|
|
6
|
-
import { i18n } from "../utils/i18n
|
|
6
|
+
import { i18n } from "../utils/i18n";
|
|
7
7
|
|
|
8
8
|
export class ConsoleBlock extends LitElement {
|
|
9
9
|
@property() content: string = "";
|
|
@@ -2,7 +2,7 @@ import { i18n } from "@mariozechner/mini-lit";
|
|
|
2
2
|
import { Button } from "@mariozechner/mini-lit/dist/Button.js";
|
|
3
3
|
import { html, LitElement, type TemplateResult } from "lit";
|
|
4
4
|
import { customElement, property } from "lit/decorators.js";
|
|
5
|
-
import type { CustomProvider } from "../storage/stores/custom-providers-store
|
|
5
|
+
import type { CustomProvider } from "../storage/stores/custom-providers-store";
|
|
6
6
|
|
|
7
7
|
@customElement("custom-provider-card")
|
|
8
8
|
export class CustomProviderCard extends LitElement {
|
package/src/components/Input.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type BaseComponentProps, fc } from "@mariozechner/mini-lit/dist/mini.js";
|
|
2
2
|
import { html } from "lit";
|
|
3
3
|
import { type Ref, ref } from "lit/directives/ref.js";
|
|
4
|
-
import { i18n } from "../utils/i18n
|
|
4
|
+
import { i18n } from "../utils/i18n";
|
|
5
5
|
|
|
6
6
|
export type InputType = "text" | "email" | "password" | "number" | "url" | "tel" | "search";
|
|
7
7
|
export type InputSize = "sm" | "md" | "lg";
|
|
@@ -6,8 +6,8 @@ import { html, LitElement } from "lit";
|
|
|
6
6
|
import { customElement, property, state } from "lit/decorators.js";
|
|
7
7
|
import { createRef, ref } from "lit/directives/ref.js";
|
|
8
8
|
import { Brain, Loader2, Paperclip, Send, Sparkles, Square } from "lucide";
|
|
9
|
-
import { type Attachment, loadAttachment } from "../utils/attachment-utils
|
|
10
|
-
import { i18n } from "../utils/i18n
|
|
9
|
+
import { type Attachment, loadAttachment } from "../utils/attachment-utils";
|
|
10
|
+
import { i18n } from "../utils/i18n";
|
|
11
11
|
import "./AttachmentTile.js";
|
|
12
12
|
import type { ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
|
13
13
|
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
import { html, LitElement, type TemplateResult } from "lit";
|
|
7
7
|
import { property } from "lit/decorators.js";
|
|
8
8
|
import { repeat } from "lit/directives/repeat.js";
|
|
9
|
-
import { renderMessage } from "./message-renderer-registry
|
|
9
|
+
import { renderMessage } from "./message-renderer-registry";
|
|
10
10
|
|
|
11
11
|
export class MessageList extends LitElement {
|
|
12
12
|
@property({ type: Array }) messages: AgentMessage[] = [];
|
|
@@ -8,10 +8,10 @@ import type {
|
|
|
8
8
|
} from "@oh-my-pi/pi-ai";
|
|
9
9
|
import { html, LitElement, type TemplateResult } from "lit";
|
|
10
10
|
import { customElement, property } from "lit/decorators.js";
|
|
11
|
-
import { renderTool } from "../tools/index
|
|
12
|
-
import type { Attachment } from "../utils/attachment-utils
|
|
13
|
-
import { formatUsage } from "../utils/format
|
|
14
|
-
import { i18n } from "../utils/i18n
|
|
11
|
+
import { renderTool } from "../tools/index";
|
|
12
|
+
import type { Attachment } from "../utils/attachment-utils";
|
|
13
|
+
import { formatUsage } from "../utils/format";
|
|
14
|
+
import { i18n } from "../utils/i18n";
|
|
15
15
|
import "./ThinkingBlock.js";
|
|
16
16
|
import type { AgentTool } from "@oh-my-pi/pi-agent-core";
|
|
17
17
|
|
|
@@ -4,9 +4,9 @@ import { Button } from "@mariozechner/mini-lit/dist/Button.js";
|
|
|
4
4
|
import { type Context, complete, getModel } from "@oh-my-pi/pi-ai";
|
|
5
5
|
import { html, LitElement } from "lit";
|
|
6
6
|
import { customElement, property, state } from "lit/decorators.js";
|
|
7
|
-
import { getAppStorage } from "../storage/app-storage
|
|
8
|
-
import { applyProxyIfNeeded } from "../utils/proxy-utils
|
|
9
|
-
import { Input } from "./Input
|
|
7
|
+
import { getAppStorage } from "../storage/app-storage";
|
|
8
|
+
import { applyProxyIfNeeded } from "../utils/proxy-utils";
|
|
9
|
+
import { Input } from "./Input";
|
|
10
10
|
|
|
11
11
|
// Test models for each provider
|
|
12
12
|
const TEST_MODELS: Record<string, string> = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
2
|
import { customElement, property } from "lit/decorators.js";
|
|
3
|
-
import { ConsoleRuntimeProvider } from "./sandbox/ConsoleRuntimeProvider
|
|
4
|
-
import { RuntimeMessageBridge } from "./sandbox/RuntimeMessageBridge
|
|
5
|
-
import { type MessageConsumer, RUNTIME_MESSAGE_ROUTER } from "./sandbox/RuntimeMessageRouter
|
|
6
|
-
import type { SandboxRuntimeProvider } from "./sandbox/SandboxRuntimeProvider
|
|
3
|
+
import { ConsoleRuntimeProvider } from "./sandbox/ConsoleRuntimeProvider";
|
|
4
|
+
import { RuntimeMessageBridge } from "./sandbox/RuntimeMessageBridge";
|
|
5
|
+
import { type MessageConsumer, RUNTIME_MESSAGE_ROUTER } from "./sandbox/RuntimeMessageRouter";
|
|
6
|
+
import type { SandboxRuntimeProvider } from "./sandbox/SandboxRuntimeProvider";
|
|
7
7
|
|
|
8
8
|
export interface SandboxFile {
|
|
9
9
|
fileName: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ARTIFACTS_RUNTIME_PROVIDER_DESCRIPTION_RO,
|
|
3
3
|
ARTIFACTS_RUNTIME_PROVIDER_DESCRIPTION_RW,
|
|
4
|
-
} from "../../prompts/prompts
|
|
5
|
-
import type { SandboxRuntimeProvider } from "./SandboxRuntimeProvider
|
|
4
|
+
} from "../../prompts/prompts";
|
|
5
|
+
import type { SandboxRuntimeProvider } from "./SandboxRuntimeProvider";
|
|
6
6
|
|
|
7
7
|
// Define minimal interface for ArtifactsPanel to avoid circular dependencies
|
|
8
8
|
interface ArtifactsPanelLike {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ATTACHMENTS_RUNTIME_DESCRIPTION } from "../../prompts/prompts
|
|
2
|
-
import type { Attachment } from "../../utils/attachment-utils
|
|
3
|
-
import type { SandboxRuntimeProvider } from "./SandboxRuntimeProvider
|
|
1
|
+
import { ATTACHMENTS_RUNTIME_DESCRIPTION } from "../../prompts/prompts";
|
|
2
|
+
import type { Attachment } from "../../utils/attachment-utils";
|
|
3
|
+
import type { SandboxRuntimeProvider } from "./SandboxRuntimeProvider";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Attachments Runtime Provider
|
|
@@ -3,8 +3,8 @@ import "../components/ProviderKeyInput.js";
|
|
|
3
3
|
import { DialogContent, DialogHeader } from "@mariozechner/mini-lit/dist/Dialog.js";
|
|
4
4
|
import { DialogBase } from "@mariozechner/mini-lit/dist/DialogBase.js";
|
|
5
5
|
import { html } from "lit";
|
|
6
|
-
import { getAppStorage } from "../storage/app-storage
|
|
7
|
-
import { i18n } from "../utils/i18n
|
|
6
|
+
import { getAppStorage } from "../storage/app-storage";
|
|
7
|
+
import { i18n } from "../utils/i18n";
|
|
8
8
|
|
|
9
9
|
@customElement("api-key-prompt-dialog")
|
|
10
10
|
export class ApiKeyPromptDialog extends DialogBase {
|
|
@@ -7,8 +7,8 @@ import { state } from "lit/decorators.js";
|
|
|
7
7
|
import { Download, X } from "lucide";
|
|
8
8
|
import * as pdfjsLib from "pdfjs-dist";
|
|
9
9
|
import * as XLSX from "xlsx";
|
|
10
|
-
import type { Attachment } from "../utils/attachment-utils
|
|
11
|
-
import { i18n } from "../utils/i18n
|
|
10
|
+
import type { Attachment } from "../utils/attachment-utils";
|
|
11
|
+
import { i18n } from "../utils/i18n";
|
|
12
12
|
|
|
13
13
|
type FileType = "image" | "pdf" | "docx" | "pptx" | "excel" | "text";
|
|
14
14
|
|
|
@@ -7,9 +7,9 @@ import { Select } from "@mariozechner/mini-lit/dist/Select.js";
|
|
|
7
7
|
import type { Model } from "@oh-my-pi/pi-ai";
|
|
8
8
|
import { html, type TemplateResult } from "lit";
|
|
9
9
|
import { state } from "lit/decorators.js";
|
|
10
|
-
import { getAppStorage } from "../storage/app-storage
|
|
11
|
-
import type { CustomProvider, CustomProviderType } from "../storage/stores/custom-providers-store
|
|
12
|
-
import { discoverModels } from "../utils/model-discovery
|
|
10
|
+
import { getAppStorage } from "../storage/app-storage";
|
|
11
|
+
import type { CustomProvider, CustomProviderType } from "../storage/stores/custom-providers-store";
|
|
12
|
+
import { discoverModels } from "../utils/model-discovery";
|
|
13
13
|
|
|
14
14
|
export class CustomProviderDialog extends DialogBase {
|
|
15
15
|
private provider?: CustomProvider;
|
|
@@ -8,12 +8,12 @@ import { html, type PropertyValues, type TemplateResult } from "lit";
|
|
|
8
8
|
import { customElement, state } from "lit/decorators.js";
|
|
9
9
|
import { createRef, ref } from "lit/directives/ref.js";
|
|
10
10
|
import { Brain, Image as ImageIcon } from "lucide";
|
|
11
|
-
import { Input } from "../components/Input
|
|
12
|
-
import { getAppStorage } from "../storage/app-storage
|
|
13
|
-
import type { AutoDiscoveryProviderType } from "../storage/stores/custom-providers-store
|
|
14
|
-
import { formatModelCost } from "../utils/format
|
|
15
|
-
import { i18n } from "../utils/i18n
|
|
16
|
-
import { discoverModels } from "../utils/model-discovery
|
|
11
|
+
import { Input } from "../components/Input";
|
|
12
|
+
import { getAppStorage } from "../storage/app-storage";
|
|
13
|
+
import type { AutoDiscoveryProviderType } from "../storage/stores/custom-providers-store";
|
|
14
|
+
import { formatModelCost } from "../utils/format";
|
|
15
|
+
import { i18n } from "../utils/i18n";
|
|
16
|
+
import { discoverModels } from "../utils/model-discovery";
|
|
17
17
|
|
|
18
18
|
@customElement("agent-model-selector")
|
|
19
19
|
export class ModelSelector extends DialogBase {
|
|
@@ -3,7 +3,7 @@ import { DialogContent, DialogHeader } from "@mariozechner/mini-lit/dist/Dialog.
|
|
|
3
3
|
import { DialogBase } from "@mariozechner/mini-lit/dist/DialogBase.js";
|
|
4
4
|
import { html } from "lit";
|
|
5
5
|
import { customElement, state } from "lit/decorators.js";
|
|
6
|
-
import { i18n } from "../utils/i18n
|
|
6
|
+
import { i18n } from "../utils/i18n";
|
|
7
7
|
|
|
8
8
|
@customElement("persistent-storage-dialog")
|
|
9
9
|
export class PersistentStorageDialog extends DialogBase {
|
|
@@ -5,15 +5,15 @@ import { html, type TemplateResult } from "lit";
|
|
|
5
5
|
import { customElement, state } from "lit/decorators.js";
|
|
6
6
|
import "../components/CustomProviderCard.js";
|
|
7
7
|
import "../components/ProviderKeyInput.js";
|
|
8
|
-
import { getAppStorage } from "../storage/app-storage
|
|
8
|
+
import { getAppStorage } from "../storage/app-storage";
|
|
9
9
|
import type {
|
|
10
10
|
AutoDiscoveryProviderType,
|
|
11
11
|
CustomProvider,
|
|
12
12
|
CustomProviderType,
|
|
13
|
-
} from "../storage/stores/custom-providers-store
|
|
14
|
-
import { discoverModels } from "../utils/model-discovery
|
|
15
|
-
import { CustomProviderDialog } from "./CustomProviderDialog
|
|
16
|
-
import { SettingsTab } from "./SettingsDialog
|
|
13
|
+
} from "../storage/stores/custom-providers-store";
|
|
14
|
+
import { discoverModels } from "../utils/model-discovery";
|
|
15
|
+
import { CustomProviderDialog } from "./CustomProviderDialog";
|
|
16
|
+
import { SettingsTab } from "./SettingsDialog";
|
|
17
17
|
|
|
18
18
|
@customElement("providers-models-tab")
|
|
19
19
|
export class ProvidersModelsTab extends SettingsTab {
|
|
@@ -2,10 +2,10 @@ import { DialogContent, DialogHeader } from "@mariozechner/mini-lit/dist/Dialog.
|
|
|
2
2
|
import { DialogBase } from "@mariozechner/mini-lit/dist/DialogBase.js";
|
|
3
3
|
import { html } from "lit";
|
|
4
4
|
import { customElement, state } from "lit/decorators.js";
|
|
5
|
-
import { getAppStorage } from "../storage/app-storage
|
|
6
|
-
import type { SessionMetadata } from "../storage/types
|
|
7
|
-
import { formatUsage } from "../utils/format
|
|
8
|
-
import { i18n } from "../utils/i18n
|
|
5
|
+
import { getAppStorage } from "../storage/app-storage";
|
|
6
|
+
import type { SessionMetadata } from "../storage/types";
|
|
7
|
+
import { formatUsage } from "../utils/format";
|
|
8
|
+
import { i18n } from "../utils/i18n";
|
|
9
9
|
|
|
10
10
|
@customElement("session-list-dialog")
|
|
11
11
|
export class SessionListDialog extends DialogBase {
|
|
@@ -7,7 +7,7 @@ import { getProviders } from "@oh-my-pi/pi-ai";
|
|
|
7
7
|
import { html, LitElement, type TemplateResult } from "lit";
|
|
8
8
|
import { customElement, property, state } from "lit/decorators.js";
|
|
9
9
|
import "../components/ProviderKeyInput.js";
|
|
10
|
-
import { getAppStorage } from "../storage/app-storage
|
|
10
|
+
import { getAppStorage } from "../storage/app-storage";
|
|
11
11
|
|
|
12
12
|
// Base class for settings tabs
|
|
13
13
|
export abstract class SettingsTab extends LitElement {
|
package/src/index.ts
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
export type { Agent, AgentMessage, AgentState, ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
|
4
4
|
export type { Model } from "@oh-my-pi/pi-ai";
|
|
5
|
-
export { ChatPanel } from "./ChatPanel
|
|
5
|
+
export { ChatPanel } from "./ChatPanel";
|
|
6
6
|
// Components
|
|
7
|
-
export { AgentInterface } from "./components/AgentInterface
|
|
8
|
-
export { AttachmentTile } from "./components/AttachmentTile
|
|
9
|
-
export { ConsoleBlock } from "./components/ConsoleBlock
|
|
10
|
-
export { ExpandableSection } from "./components/ExpandableSection
|
|
11
|
-
export { Input } from "./components/Input
|
|
12
|
-
export { MessageEditor } from "./components/MessageEditor
|
|
13
|
-
export { MessageList } from "./components/MessageList
|
|
7
|
+
export { AgentInterface } from "./components/AgentInterface";
|
|
8
|
+
export { AttachmentTile } from "./components/AttachmentTile";
|
|
9
|
+
export { ConsoleBlock } from "./components/ConsoleBlock";
|
|
10
|
+
export { ExpandableSection } from "./components/ExpandableSection";
|
|
11
|
+
export { Input } from "./components/Input";
|
|
12
|
+
export { MessageEditor } from "./components/MessageEditor";
|
|
13
|
+
export { MessageList } from "./components/MessageList";
|
|
14
14
|
// Message components
|
|
15
|
-
export type { ArtifactMessage, UserMessageWithAttachments } from "./components/Messages
|
|
15
|
+
export type { ArtifactMessage, UserMessageWithAttachments } from "./components/Messages";
|
|
16
16
|
export {
|
|
17
17
|
AssistantMessage,
|
|
18
18
|
convertAttachments,
|
|
@@ -21,7 +21,7 @@ export {
|
|
|
21
21
|
isUserMessageWithAttachments,
|
|
22
22
|
ToolMessage,
|
|
23
23
|
UserMessage,
|
|
24
|
-
} from "./components/Messages
|
|
24
|
+
} from "./components/Messages";
|
|
25
25
|
// Message renderer registry
|
|
26
26
|
export {
|
|
27
27
|
getMessageRenderer,
|
|
@@ -29,53 +29,53 @@ export {
|
|
|
29
29
|
type MessageRole,
|
|
30
30
|
registerMessageRenderer,
|
|
31
31
|
renderMessage,
|
|
32
|
-
} from "./components/message-renderer-registry
|
|
32
|
+
} from "./components/message-renderer-registry";
|
|
33
33
|
export {
|
|
34
34
|
type SandboxFile,
|
|
35
35
|
SandboxIframe,
|
|
36
36
|
type SandboxResult,
|
|
37
37
|
type SandboxUrlProvider,
|
|
38
|
-
} from "./components/SandboxedIframe
|
|
39
|
-
export { StreamingMessageContainer } from "./components/StreamingMessageContainer
|
|
38
|
+
} from "./components/SandboxedIframe";
|
|
39
|
+
export { StreamingMessageContainer } from "./components/StreamingMessageContainer";
|
|
40
40
|
// Sandbox Runtime Providers
|
|
41
|
-
export { ArtifactsRuntimeProvider } from "./components/sandbox/ArtifactsRuntimeProvider
|
|
42
|
-
export { AttachmentsRuntimeProvider } from "./components/sandbox/AttachmentsRuntimeProvider
|
|
43
|
-
export { type ConsoleLog, ConsoleRuntimeProvider } from "./components/sandbox/ConsoleRuntimeProvider
|
|
41
|
+
export { ArtifactsRuntimeProvider } from "./components/sandbox/ArtifactsRuntimeProvider";
|
|
42
|
+
export { AttachmentsRuntimeProvider } from "./components/sandbox/AttachmentsRuntimeProvider";
|
|
43
|
+
export { type ConsoleLog, ConsoleRuntimeProvider } from "./components/sandbox/ConsoleRuntimeProvider";
|
|
44
44
|
export {
|
|
45
45
|
type DownloadableFile,
|
|
46
46
|
FileDownloadRuntimeProvider,
|
|
47
|
-
} from "./components/sandbox/FileDownloadRuntimeProvider
|
|
48
|
-
export { RuntimeMessageBridge } from "./components/sandbox/RuntimeMessageBridge
|
|
49
|
-
export { RUNTIME_MESSAGE_ROUTER } from "./components/sandbox/RuntimeMessageRouter
|
|
50
|
-
export type { SandboxRuntimeProvider } from "./components/sandbox/SandboxRuntimeProvider
|
|
51
|
-
export { ThinkingBlock } from "./components/ThinkingBlock
|
|
52
|
-
export { ApiKeyPromptDialog } from "./dialogs/ApiKeyPromptDialog
|
|
53
|
-
export { AttachmentOverlay } from "./dialogs/AttachmentOverlay
|
|
47
|
+
} from "./components/sandbox/FileDownloadRuntimeProvider";
|
|
48
|
+
export { RuntimeMessageBridge } from "./components/sandbox/RuntimeMessageBridge";
|
|
49
|
+
export { RUNTIME_MESSAGE_ROUTER } from "./components/sandbox/RuntimeMessageRouter";
|
|
50
|
+
export type { SandboxRuntimeProvider } from "./components/sandbox/SandboxRuntimeProvider";
|
|
51
|
+
export { ThinkingBlock } from "./components/ThinkingBlock";
|
|
52
|
+
export { ApiKeyPromptDialog } from "./dialogs/ApiKeyPromptDialog";
|
|
53
|
+
export { AttachmentOverlay } from "./dialogs/AttachmentOverlay";
|
|
54
54
|
// Dialogs
|
|
55
|
-
export { ModelSelector } from "./dialogs/ModelSelector
|
|
56
|
-
export { PersistentStorageDialog } from "./dialogs/PersistentStorageDialog
|
|
57
|
-
export { ProvidersModelsTab } from "./dialogs/ProvidersModelsTab
|
|
58
|
-
export { SessionListDialog } from "./dialogs/SessionListDialog
|
|
59
|
-
export { ApiKeysTab, ProxyTab, SettingsDialog, SettingsTab } from "./dialogs/SettingsDialog
|
|
55
|
+
export { ModelSelector } from "./dialogs/ModelSelector";
|
|
56
|
+
export { PersistentStorageDialog } from "./dialogs/PersistentStorageDialog";
|
|
57
|
+
export { ProvidersModelsTab } from "./dialogs/ProvidersModelsTab";
|
|
58
|
+
export { SessionListDialog } from "./dialogs/SessionListDialog";
|
|
59
|
+
export { ApiKeysTab, ProxyTab, SettingsDialog, SettingsTab } from "./dialogs/SettingsDialog";
|
|
60
60
|
// Prompts
|
|
61
61
|
export {
|
|
62
62
|
ARTIFACTS_RUNTIME_PROVIDER_DESCRIPTION_RO,
|
|
63
63
|
ARTIFACTS_RUNTIME_PROVIDER_DESCRIPTION_RW,
|
|
64
64
|
ATTACHMENTS_RUNTIME_DESCRIPTION,
|
|
65
|
-
} from "./prompts/prompts
|
|
65
|
+
} from "./prompts/prompts";
|
|
66
66
|
// Storage
|
|
67
|
-
export { AppStorage, getAppStorage, setAppStorage } from "./storage/app-storage
|
|
68
|
-
export { IndexedDBStorageBackend } from "./storage/backends/indexeddb-storage-backend
|
|
69
|
-
export { Store } from "./storage/store
|
|
67
|
+
export { AppStorage, getAppStorage, setAppStorage } from "./storage/app-storage";
|
|
68
|
+
export { IndexedDBStorageBackend } from "./storage/backends/indexeddb-storage-backend";
|
|
69
|
+
export { Store } from "./storage/store";
|
|
70
70
|
export type {
|
|
71
71
|
AutoDiscoveryProviderType,
|
|
72
72
|
CustomProvider,
|
|
73
73
|
CustomProviderType,
|
|
74
|
-
} from "./storage/stores/custom-providers-store
|
|
75
|
-
export { CustomProvidersStore } from "./storage/stores/custom-providers-store
|
|
76
|
-
export { ProviderKeysStore } from "./storage/stores/provider-keys-store
|
|
77
|
-
export { SessionsStore } from "./storage/stores/sessions-store
|
|
78
|
-
export { SettingsStore } from "./storage/stores/settings-store
|
|
74
|
+
} from "./storage/stores/custom-providers-store";
|
|
75
|
+
export { CustomProvidersStore } from "./storage/stores/custom-providers-store";
|
|
76
|
+
export { ProviderKeysStore } from "./storage/stores/provider-keys-store";
|
|
77
|
+
export { SessionsStore } from "./storage/stores/sessions-store";
|
|
78
|
+
export { SettingsStore } from "./storage/stores/settings-store";
|
|
79
79
|
export type {
|
|
80
80
|
IndexConfig,
|
|
81
81
|
IndexedDBConfig,
|
|
@@ -84,32 +84,32 @@ export type {
|
|
|
84
84
|
StorageBackend,
|
|
85
85
|
StorageTransaction,
|
|
86
86
|
StoreConfig,
|
|
87
|
-
} from "./storage/types
|
|
87
|
+
} from "./storage/types";
|
|
88
88
|
// Artifacts
|
|
89
|
-
export { ArtifactElement } from "./tools/artifacts/ArtifactElement
|
|
90
|
-
export { ArtifactPill } from "./tools/artifacts/ArtifactPill
|
|
91
|
-
export { type Artifact, ArtifactsPanel, type ArtifactsParams } from "./tools/artifacts/artifacts
|
|
92
|
-
export { ArtifactsToolRenderer } from "./tools/artifacts/artifacts-tool-renderer
|
|
93
|
-
export { HtmlArtifact } from "./tools/artifacts/HtmlArtifact
|
|
94
|
-
export { ImageArtifact } from "./tools/artifacts/ImageArtifact
|
|
95
|
-
export { MarkdownArtifact } from "./tools/artifacts/MarkdownArtifact
|
|
96
|
-
export { SvgArtifact } from "./tools/artifacts/SvgArtifact
|
|
97
|
-
export { TextArtifact } from "./tools/artifacts/TextArtifact
|
|
98
|
-
export { createExtractDocumentTool, extractDocumentTool } from "./tools/extract-document
|
|
89
|
+
export { ArtifactElement } from "./tools/artifacts/ArtifactElement";
|
|
90
|
+
export { ArtifactPill } from "./tools/artifacts/ArtifactPill";
|
|
91
|
+
export { type Artifact, ArtifactsPanel, type ArtifactsParams } from "./tools/artifacts/artifacts";
|
|
92
|
+
export { ArtifactsToolRenderer } from "./tools/artifacts/artifacts-tool-renderer";
|
|
93
|
+
export { HtmlArtifact } from "./tools/artifacts/HtmlArtifact";
|
|
94
|
+
export { ImageArtifact } from "./tools/artifacts/ImageArtifact";
|
|
95
|
+
export { MarkdownArtifact } from "./tools/artifacts/MarkdownArtifact";
|
|
96
|
+
export { SvgArtifact } from "./tools/artifacts/SvgArtifact";
|
|
97
|
+
export { TextArtifact } from "./tools/artifacts/TextArtifact";
|
|
98
|
+
export { createExtractDocumentTool, extractDocumentTool } from "./tools/extract-document";
|
|
99
99
|
// Tools
|
|
100
|
-
export { getToolRenderer, registerToolRenderer, renderTool, setShowJsonMode } from "./tools/index
|
|
101
|
-
export { createJavaScriptReplTool, javascriptReplTool } from "./tools/javascript-repl
|
|
102
|
-
export { renderCollapsibleHeader, renderHeader } from "./tools/renderer-registry
|
|
103
|
-
export { BashRenderer } from "./tools/renderers/BashRenderer
|
|
104
|
-
export { CalculateRenderer } from "./tools/renderers/CalculateRenderer
|
|
100
|
+
export { getToolRenderer, registerToolRenderer, renderTool, setShowJsonMode } from "./tools/index";
|
|
101
|
+
export { createJavaScriptReplTool, javascriptReplTool } from "./tools/javascript-repl";
|
|
102
|
+
export { renderCollapsibleHeader, renderHeader } from "./tools/renderer-registry";
|
|
103
|
+
export { BashRenderer } from "./tools/renderers/BashRenderer";
|
|
104
|
+
export { CalculateRenderer } from "./tools/renderers/CalculateRenderer";
|
|
105
105
|
// Tool renderers
|
|
106
|
-
export { DefaultRenderer } from "./tools/renderers/DefaultRenderer
|
|
107
|
-
export { GetCurrentTimeRenderer } from "./tools/renderers/GetCurrentTimeRenderer
|
|
108
|
-
export type { ToolRenderer, ToolRenderResult } from "./tools/types
|
|
109
|
-
export type { Attachment } from "./utils/attachment-utils
|
|
106
|
+
export { DefaultRenderer } from "./tools/renderers/DefaultRenderer";
|
|
107
|
+
export { GetCurrentTimeRenderer } from "./tools/renderers/GetCurrentTimeRenderer";
|
|
108
|
+
export type { ToolRenderer, ToolRenderResult } from "./tools/types";
|
|
109
|
+
export type { Attachment } from "./utils/attachment-utils";
|
|
110
110
|
// Utils
|
|
111
|
-
export { loadAttachment } from "./utils/attachment-utils
|
|
112
|
-
export { clearAuthToken, getAuthToken } from "./utils/auth-token
|
|
113
|
-
export { formatCost, formatModelCost, formatTokenCount, formatUsage } from "./utils/format
|
|
114
|
-
export { i18n, setLanguage, translations } from "./utils/i18n
|
|
115
|
-
export { applyProxyIfNeeded, createStreamFn, isCorsError, shouldUseProxyForProvider } from "./utils/proxy-utils
|
|
111
|
+
export { loadAttachment } from "./utils/attachment-utils";
|
|
112
|
+
export { clearAuthToken, getAuthToken } from "./utils/auth-token";
|
|
113
|
+
export { formatCost, formatModelCost, formatTokenCount, formatUsage } from "./utils/format";
|
|
114
|
+
export { i18n, setLanguage, translations } from "./utils/i18n";
|
|
115
|
+
export { applyProxyIfNeeded, createStreamFn, isCorsError, shouldUseProxyForProvider } from "./utils/proxy-utils";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { CustomProvidersStore } from "./stores/custom-providers-store
|
|
2
|
-
import type { ProviderKeysStore } from "./stores/provider-keys-store
|
|
3
|
-
import type { SessionsStore } from "./stores/sessions-store
|
|
4
|
-
import type { SettingsStore } from "./stores/settings-store
|
|
5
|
-
import type { StorageBackend } from "./types
|
|
1
|
+
import type { CustomProvidersStore } from "./stores/custom-providers-store";
|
|
2
|
+
import type { ProviderKeysStore } from "./stores/provider-keys-store";
|
|
3
|
+
import type { SessionsStore } from "./stores/sessions-store";
|
|
4
|
+
import type { SettingsStore } from "./stores/settings-store";
|
|
5
|
+
import type { StorageBackend } from "./types";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* High-level storage API providing access to all storage operations.
|
package/src/storage/store.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Model } from "@oh-my-pi/pi-ai";
|
|
2
|
-
import { Store } from "../store
|
|
3
|
-
import type { StoreConfig } from "../types
|
|
2
|
+
import { Store } from "../store";
|
|
3
|
+
import type { StoreConfig } from "../types";
|
|
4
4
|
|
|
5
5
|
export type AutoDiscoveryProviderType = "ollama" | "llama.cpp" | "vllm" | "lmstudio";
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentState } from "@oh-my-pi/pi-agent-core";
|
|
2
|
-
import { Store } from "../store
|
|
3
|
-
import type { SessionData, SessionMetadata, StoreConfig } from "../types
|
|
2
|
+
import { Store } from "../store";
|
|
3
|
+
import type { SessionData, SessionMetadata, StoreConfig } from "../types";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Store for chat sessions (data and metadata).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { icon } from "@mariozechner/mini-lit";
|
|
2
2
|
import { html, type TemplateResult } from "lit";
|
|
3
3
|
import { FileCode2 } from "lucide";
|
|
4
|
-
import type { ArtifactsPanel } from "./artifacts
|
|
4
|
+
import type { ArtifactsPanel } from "./artifacts";
|
|
5
5
|
|
|
6
6
|
export function ArtifactPill(filename: string, artifactsPanel?: ArtifactsPanel): TemplateResult {
|
|
7
7
|
const handleClick = (e: Event) => {
|
|
@@ -5,7 +5,7 @@ import { customElement, property, state } from "lit/decorators.js";
|
|
|
5
5
|
import { createRef, type Ref, ref } from "lit/directives/ref.js";
|
|
6
6
|
import { repeat } from "lit/directives/repeat.js";
|
|
7
7
|
import { ChevronDown, ChevronRight, ChevronsDown, Lock } from "lucide";
|
|
8
|
-
import { i18n } from "../../utils/i18n
|
|
8
|
+
import { i18n } from "../../utils/i18n";
|
|
9
9
|
|
|
10
10
|
interface LogEntry {
|
|
11
11
|
type: "log" | "error";
|
|
@@ -2,8 +2,8 @@ import { DownloadButton } from "@mariozechner/mini-lit/dist/DownloadButton.js";
|
|
|
2
2
|
import { renderAsync } from "docx-preview";
|
|
3
3
|
import { html, type TemplateResult } from "lit";
|
|
4
4
|
import { customElement, property, state } from "lit/decorators.js";
|
|
5
|
-
import { i18n } from "../../utils/i18n
|
|
6
|
-
import { ArtifactElement } from "./ArtifactElement
|
|
5
|
+
import { i18n } from "../../utils/i18n";
|
|
6
|
+
import { ArtifactElement } from "./ArtifactElement";
|
|
7
7
|
|
|
8
8
|
@customElement("docx-artifact")
|
|
9
9
|
export class DocxArtifact extends ArtifactElement {
|
|
@@ -2,8 +2,8 @@ import { DownloadButton } from "@mariozechner/mini-lit/dist/DownloadButton.js";
|
|
|
2
2
|
import { html, type TemplateResult } from "lit";
|
|
3
3
|
import { customElement, property, state } from "lit/decorators.js";
|
|
4
4
|
import * as XLSX from "xlsx";
|
|
5
|
-
import { i18n } from "../../utils/i18n
|
|
6
|
-
import { ArtifactElement } from "./ArtifactElement
|
|
5
|
+
import { i18n } from "../../utils/i18n";
|
|
6
|
+
import { ArtifactElement } from "./ArtifactElement";
|
|
7
7
|
|
|
8
8
|
@customElement("excel-artifact")
|
|
9
9
|
export class ExcelArtifact extends ArtifactElement {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DownloadButton } from "@mariozechner/mini-lit/dist/DownloadButton.js";
|
|
2
2
|
import { html, type TemplateResult } from "lit";
|
|
3
3
|
import { customElement, property } from "lit/decorators.js";
|
|
4
|
-
import { i18n } from "../../utils/i18n
|
|
5
|
-
import { ArtifactElement } from "./ArtifactElement
|
|
4
|
+
import { i18n } from "../../utils/i18n";
|
|
5
|
+
import { ArtifactElement } from "./ArtifactElement";
|
|
6
6
|
|
|
7
7
|
@customElement("generic-artifact")
|
|
8
8
|
export class GenericArtifact extends ArtifactElement {
|
|
@@ -4,13 +4,13 @@ import { customElement, property, state } from "lit/decorators.js";
|
|
|
4
4
|
import { createRef, type Ref, ref } from "lit/directives/ref.js";
|
|
5
5
|
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
6
6
|
import { RefreshCw } from "lucide";
|
|
7
|
-
import type { SandboxIframe } from "../../components/SandboxedIframe
|
|
8
|
-
import { type MessageConsumer, RUNTIME_MESSAGE_ROUTER } from "../../components/sandbox/RuntimeMessageRouter
|
|
9
|
-
import type { SandboxRuntimeProvider } from "../../components/sandbox/SandboxRuntimeProvider
|
|
10
|
-
import { i18n } from "../../utils/i18n
|
|
7
|
+
import type { SandboxIframe } from "../../components/SandboxedIframe";
|
|
8
|
+
import { type MessageConsumer, RUNTIME_MESSAGE_ROUTER } from "../../components/sandbox/RuntimeMessageRouter";
|
|
9
|
+
import type { SandboxRuntimeProvider } from "../../components/sandbox/SandboxRuntimeProvider";
|
|
10
|
+
import { i18n } from "../../utils/i18n";
|
|
11
11
|
import "../../components/SandboxedIframe.js";
|
|
12
|
-
import { ArtifactElement } from "./ArtifactElement
|
|
13
|
-
import type { Console } from "./Console
|
|
12
|
+
import { ArtifactElement } from "./ArtifactElement";
|
|
13
|
+
import type { Console } from "./Console";
|
|
14
14
|
import "./Console.js";
|
|
15
15
|
import { icon } from "@mariozechner/mini-lit";
|
|
16
16
|
import { Button } from "@mariozechner/mini-lit/dist/Button.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DownloadButton } from "@mariozechner/mini-lit/dist/DownloadButton.js";
|
|
2
2
|
import { html, type TemplateResult } from "lit";
|
|
3
3
|
import { customElement, property } from "lit/decorators.js";
|
|
4
|
-
import { i18n } from "../../utils/i18n
|
|
5
|
-
import { ArtifactElement } from "./ArtifactElement
|
|
4
|
+
import { i18n } from "../../utils/i18n";
|
|
5
|
+
import { ArtifactElement } from "./ArtifactElement";
|
|
6
6
|
|
|
7
7
|
@customElement("image-artifact")
|
|
8
8
|
export class ImageArtifact extends ArtifactElement {
|
|
@@ -2,12 +2,12 @@ import hljs from "highlight.js";
|
|
|
2
2
|
import { html } from "lit";
|
|
3
3
|
import { customElement, property, state } from "lit/decorators.js";
|
|
4
4
|
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
5
|
-
import { i18n } from "../../utils/i18n
|
|
5
|
+
import { i18n } from "../../utils/i18n";
|
|
6
6
|
import "@mariozechner/mini-lit/dist/MarkdownBlock.js";
|
|
7
7
|
import { CopyButton } from "@mariozechner/mini-lit/dist/CopyButton.js";
|
|
8
8
|
import { DownloadButton } from "@mariozechner/mini-lit/dist/DownloadButton.js";
|
|
9
9
|
import { PreviewCodeToggle } from "@mariozechner/mini-lit/dist/PreviewCodeToggle.js";
|
|
10
|
-
import { ArtifactElement } from "./ArtifactElement
|
|
10
|
+
import { ArtifactElement } from "./ArtifactElement";
|
|
11
11
|
|
|
12
12
|
@customElement("markdown-artifact")
|
|
13
13
|
export class MarkdownArtifact extends ArtifactElement {
|
|
@@ -2,8 +2,8 @@ import { DownloadButton } from "@mariozechner/mini-lit/dist/DownloadButton.js";
|
|
|
2
2
|
import { html, type TemplateResult } from "lit";
|
|
3
3
|
import { customElement, property, state } from "lit/decorators.js";
|
|
4
4
|
import * as pdfjsLib from "pdfjs-dist";
|
|
5
|
-
import { i18n } from "../../utils/i18n
|
|
6
|
-
import { ArtifactElement } from "./ArtifactElement
|
|
5
|
+
import { i18n } from "../../utils/i18n";
|
|
6
|
+
import { ArtifactElement } from "./ArtifactElement";
|
|
7
7
|
|
|
8
8
|
// Configure PDF.js worker
|
|
9
9
|
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL("pdfjs-dist/build/pdf.worker.min.mjs", import.meta.url).toString();
|
|
@@ -5,8 +5,8 @@ import hljs from "highlight.js";
|
|
|
5
5
|
import { html } from "lit";
|
|
6
6
|
import { customElement, property, state } from "lit/decorators.js";
|
|
7
7
|
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
8
|
-
import { i18n } from "../../utils/i18n
|
|
9
|
-
import { ArtifactElement } from "./ArtifactElement
|
|
8
|
+
import { i18n } from "../../utils/i18n";
|
|
9
|
+
import { ArtifactElement } from "./ArtifactElement";
|
|
10
10
|
|
|
11
11
|
@customElement("svg-artifact")
|
|
12
12
|
export class SvgArtifact extends ArtifactElement {
|
|
@@ -4,8 +4,8 @@ import hljs from "highlight.js";
|
|
|
4
4
|
import { html } from "lit";
|
|
5
5
|
import { customElement, property } from "lit/decorators.js";
|
|
6
6
|
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
7
|
-
import { i18n } from "../../utils/i18n
|
|
8
|
-
import { ArtifactElement } from "./ArtifactElement
|
|
7
|
+
import { i18n } from "../../utils/i18n";
|
|
8
|
+
import { ArtifactElement } from "./ArtifactElement";
|
|
9
9
|
|
|
10
10
|
// Known code file extensions for highlighting
|
|
11
11
|
const CODE_EXTENSIONS = [
|
|
@@ -5,11 +5,11 @@ import { FileCode2 } from "lucide";
|
|
|
5
5
|
import "../../components/ConsoleBlock.js";
|
|
6
6
|
import { Diff } from "@mariozechner/mini-lit/dist/Diff.js";
|
|
7
7
|
import { html, type TemplateResult } from "lit";
|
|
8
|
-
import { i18n } from "../../utils/i18n
|
|
9
|
-
import { renderCollapsibleHeader, renderHeader } from "../renderer-registry
|
|
10
|
-
import type { ToolRenderer, ToolRenderResult } from "../types
|
|
11
|
-
import { ArtifactPill } from "./ArtifactPill
|
|
12
|
-
import type { ArtifactsPanel, ArtifactsParams } from "./artifacts
|
|
8
|
+
import { i18n } from "../../utils/i18n";
|
|
9
|
+
import { renderCollapsibleHeader, renderHeader } from "../renderer-registry";
|
|
10
|
+
import type { ToolRenderer, ToolRenderResult } from "../types";
|
|
11
|
+
import { ArtifactPill } from "./ArtifactPill";
|
|
12
|
+
import type { ArtifactsPanel, ArtifactsParams } from "./artifacts";
|
|
13
13
|
|
|
14
14
|
// Helper to extract text from content blocks
|
|
15
15
|
function getTextOutput(result: ToolResultMessage<any> | undefined): string {
|
|
@@ -8,27 +8,27 @@ import { html, LitElement, type TemplateResult } from "lit";
|
|
|
8
8
|
import { customElement, property, state } from "lit/decorators.js";
|
|
9
9
|
import { createRef, type Ref, ref } from "lit/directives/ref.js";
|
|
10
10
|
import { X } from "lucide";
|
|
11
|
-
import type { ArtifactMessage } from "../../components/Messages
|
|
12
|
-
import { ArtifactsRuntimeProvider } from "../../components/sandbox/ArtifactsRuntimeProvider
|
|
13
|
-
import { AttachmentsRuntimeProvider } from "../../components/sandbox/AttachmentsRuntimeProvider
|
|
14
|
-
import type { SandboxRuntimeProvider } from "../../components/sandbox/SandboxRuntimeProvider
|
|
11
|
+
import type { ArtifactMessage } from "../../components/Messages";
|
|
12
|
+
import { ArtifactsRuntimeProvider } from "../../components/sandbox/ArtifactsRuntimeProvider";
|
|
13
|
+
import { AttachmentsRuntimeProvider } from "../../components/sandbox/AttachmentsRuntimeProvider";
|
|
14
|
+
import type { SandboxRuntimeProvider } from "../../components/sandbox/SandboxRuntimeProvider";
|
|
15
15
|
import {
|
|
16
16
|
ARTIFACTS_RUNTIME_PROVIDER_DESCRIPTION_RO,
|
|
17
17
|
ARTIFACTS_TOOL_DESCRIPTION,
|
|
18
18
|
ATTACHMENTS_RUNTIME_DESCRIPTION,
|
|
19
|
-
} from "../../prompts/prompts
|
|
20
|
-
import type { Attachment } from "../../utils/attachment-utils
|
|
21
|
-
import { i18n } from "../../utils/i18n
|
|
22
|
-
import type { ArtifactElement } from "./ArtifactElement
|
|
23
|
-
import { DocxArtifact } from "./DocxArtifact
|
|
24
|
-
import { ExcelArtifact } from "./ExcelArtifact
|
|
25
|
-
import { GenericArtifact } from "./GenericArtifact
|
|
26
|
-
import { HtmlArtifact } from "./HtmlArtifact
|
|
27
|
-
import { ImageArtifact } from "./ImageArtifact
|
|
28
|
-
import { MarkdownArtifact } from "./MarkdownArtifact
|
|
29
|
-
import { PdfArtifact } from "./PdfArtifact
|
|
30
|
-
import { SvgArtifact } from "./SvgArtifact
|
|
31
|
-
import { TextArtifact } from "./TextArtifact
|
|
19
|
+
} from "../../prompts/prompts";
|
|
20
|
+
import type { Attachment } from "../../utils/attachment-utils";
|
|
21
|
+
import { i18n } from "../../utils/i18n";
|
|
22
|
+
import type { ArtifactElement } from "./ArtifactElement";
|
|
23
|
+
import { DocxArtifact } from "./DocxArtifact";
|
|
24
|
+
import { ExcelArtifact } from "./ExcelArtifact";
|
|
25
|
+
import { GenericArtifact } from "./GenericArtifact";
|
|
26
|
+
import { HtmlArtifact } from "./HtmlArtifact";
|
|
27
|
+
import { ImageArtifact } from "./ImageArtifact";
|
|
28
|
+
import { MarkdownArtifact } from "./MarkdownArtifact";
|
|
29
|
+
import { PdfArtifact } from "./PdfArtifact";
|
|
30
|
+
import { SvgArtifact } from "./SvgArtifact";
|
|
31
|
+
import { TextArtifact } from "./TextArtifact";
|
|
32
32
|
|
|
33
33
|
// Simple artifact model
|
|
34
34
|
export interface Artifact {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { ArtifactElement } from "./ArtifactElement
|
|
2
|
-
export { type Artifact, ArtifactsPanel, type ArtifactsParams } from "./artifacts
|
|
3
|
-
export { ArtifactsToolRenderer } from "./artifacts-tool-renderer
|
|
4
|
-
export { HtmlArtifact } from "./HtmlArtifact
|
|
5
|
-
export { MarkdownArtifact } from "./MarkdownArtifact
|
|
6
|
-
export { SvgArtifact } from "./SvgArtifact
|
|
7
|
-
export { TextArtifact } from "./TextArtifact
|
|
1
|
+
export { ArtifactElement } from "./ArtifactElement";
|
|
2
|
+
export { type Artifact, ArtifactsPanel, type ArtifactsParams } from "./artifacts";
|
|
3
|
+
export { ArtifactsToolRenderer } from "./artifacts-tool-renderer";
|
|
4
|
+
export { HtmlArtifact } from "./HtmlArtifact";
|
|
5
|
+
export { MarkdownArtifact } from "./MarkdownArtifact";
|
|
6
|
+
export { SvgArtifact } from "./SvgArtifact";
|
|
7
|
+
export { TextArtifact } from "./TextArtifact";
|
|
@@ -4,11 +4,11 @@ import { type Static, Type } from "@sinclair/typebox";
|
|
|
4
4
|
import { html } from "lit";
|
|
5
5
|
import { createRef, ref } from "lit/directives/ref.js";
|
|
6
6
|
import { FileText } from "lucide";
|
|
7
|
-
import { EXTRACT_DOCUMENT_DESCRIPTION } from "../prompts/prompts
|
|
8
|
-
import { loadAttachment } from "../utils/attachment-utils
|
|
9
|
-
import { isCorsError } from "../utils/proxy-utils
|
|
10
|
-
import { registerToolRenderer, renderCollapsibleHeader, renderHeader } from "./renderer-registry
|
|
11
|
-
import type { ToolRenderer, ToolRenderResult } from "./types
|
|
7
|
+
import { EXTRACT_DOCUMENT_DESCRIPTION } from "../prompts/prompts";
|
|
8
|
+
import { loadAttachment } from "../utils/attachment-utils";
|
|
9
|
+
import { isCorsError } from "../utils/proxy-utils";
|
|
10
|
+
import { registerToolRenderer, renderCollapsibleHeader, renderHeader } from "./renderer-registry";
|
|
11
|
+
import type { ToolRenderer, ToolRenderResult } from "./types";
|
|
12
12
|
|
|
13
13
|
// ============================================================================
|
|
14
14
|
// TYPES
|
package/src/tools/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ToolResultMessage } from "@oh-my-pi/pi-ai";
|
|
2
2
|
import "./javascript-repl.js"; // Auto-registers the renderer
|
|
3
3
|
import "./extract-document.js"; // Auto-registers the renderer
|
|
4
|
-
import { getToolRenderer, registerToolRenderer } from "./renderer-registry
|
|
5
|
-
import { BashRenderer } from "./renderers/BashRenderer
|
|
6
|
-
import { DefaultRenderer } from "./renderers/DefaultRenderer
|
|
7
|
-
import type { ToolRenderResult } from "./types
|
|
4
|
+
import { getToolRenderer, registerToolRenderer } from "./renderer-registry";
|
|
5
|
+
import { BashRenderer } from "./renderers/BashRenderer";
|
|
6
|
+
import { DefaultRenderer } from "./renderers/DefaultRenderer";
|
|
7
|
+
import type { ToolRenderResult } from "./types";
|
|
8
8
|
|
|
9
9
|
// Register all built-in tool renderers
|
|
10
10
|
registerToolRenderer("bash", new BashRenderer());
|
|
@@ -5,12 +5,12 @@ import { type Static, Type } from "@sinclair/typebox";
|
|
|
5
5
|
import { html } from "lit";
|
|
6
6
|
import { createRef, ref } from "lit/directives/ref.js";
|
|
7
7
|
import { Code } from "lucide";
|
|
8
|
-
import { type SandboxFile, SandboxIframe, type SandboxResult } from "../components/SandboxedIframe
|
|
9
|
-
import type { SandboxRuntimeProvider } from "../components/sandbox/SandboxRuntimeProvider
|
|
10
|
-
import { JAVASCRIPT_REPL_TOOL_DESCRIPTION } from "../prompts/prompts
|
|
11
|
-
import type { Attachment } from "../utils/attachment-utils
|
|
12
|
-
import { registerToolRenderer, renderCollapsibleHeader, renderHeader } from "./renderer-registry
|
|
13
|
-
import type { ToolRenderer, ToolRenderResult } from "./types
|
|
8
|
+
import { type SandboxFile, SandboxIframe, type SandboxResult } from "../components/SandboxedIframe";
|
|
9
|
+
import type { SandboxRuntimeProvider } from "../components/sandbox/SandboxRuntimeProvider";
|
|
10
|
+
import { JAVASCRIPT_REPL_TOOL_DESCRIPTION } from "../prompts/prompts";
|
|
11
|
+
import type { Attachment } from "../utils/attachment-utils";
|
|
12
|
+
import { registerToolRenderer, renderCollapsibleHeader, renderHeader } from "./renderer-registry";
|
|
13
|
+
import type { ToolRenderer, ToolRenderResult } from "./types";
|
|
14
14
|
|
|
15
15
|
// Execute JavaScript code with attachments using SandboxedIframe
|
|
16
16
|
export async function executeJavaScript(
|
|
@@ -3,7 +3,7 @@ import { html, type TemplateResult } from "lit";
|
|
|
3
3
|
import type { Ref } from "lit/directives/ref.js";
|
|
4
4
|
import { ref } from "lit/directives/ref.js";
|
|
5
5
|
import { ChevronsUpDown, ChevronUp, Loader } from "lucide";
|
|
6
|
-
import type { ToolRenderer } from "./types
|
|
6
|
+
import type { ToolRenderer } from "./types";
|
|
7
7
|
|
|
8
8
|
// Registry of tool renderers
|
|
9
9
|
export const toolRenderers = new Map<string, ToolRenderer>();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ToolResultMessage } from "@oh-my-pi/pi-ai";
|
|
2
2
|
import { html } from "lit";
|
|
3
3
|
import { SquareTerminal } from "lucide";
|
|
4
|
-
import { i18n } from "../../utils/i18n
|
|
5
|
-
import { renderHeader } from "../renderer-registry
|
|
6
|
-
import type { ToolRenderer, ToolRenderResult } from "../types
|
|
4
|
+
import { i18n } from "../../utils/i18n";
|
|
5
|
+
import { renderHeader } from "../renderer-registry";
|
|
6
|
+
import type { ToolRenderer, ToolRenderResult } from "../types";
|
|
7
7
|
|
|
8
8
|
interface BashParams {
|
|
9
9
|
command: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ToolResultMessage } from "@oh-my-pi/pi-ai";
|
|
2
2
|
import { html } from "lit";
|
|
3
3
|
import { Calculator } from "lucide";
|
|
4
|
-
import { i18n } from "../../utils/i18n
|
|
5
|
-
import { renderHeader } from "../renderer-registry
|
|
6
|
-
import type { ToolRenderer, ToolRenderResult } from "../types
|
|
4
|
+
import { i18n } from "../../utils/i18n";
|
|
5
|
+
import { renderHeader } from "../renderer-registry";
|
|
6
|
+
import type { ToolRenderer, ToolRenderResult } from "../types";
|
|
7
7
|
|
|
8
8
|
interface CalculateParams {
|
|
9
9
|
expression: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ToolResultMessage } from "@oh-my-pi/pi-ai";
|
|
2
2
|
import { html } from "lit";
|
|
3
3
|
import { Code } from "lucide";
|
|
4
|
-
import { i18n } from "../../utils/i18n
|
|
5
|
-
import { renderHeader } from "../renderer-registry
|
|
6
|
-
import type { ToolRenderer, ToolRenderResult } from "../types
|
|
4
|
+
import { i18n } from "../../utils/i18n";
|
|
5
|
+
import { renderHeader } from "../renderer-registry";
|
|
6
|
+
import type { ToolRenderer, ToolRenderResult } from "../types";
|
|
7
7
|
|
|
8
8
|
export class DefaultRenderer implements ToolRenderer {
|
|
9
9
|
render(params: any | undefined, result: ToolResultMessage | undefined, isStreaming?: boolean): ToolRenderResult {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ToolResultMessage } from "@oh-my-pi/pi-ai";
|
|
2
2
|
import { html } from "lit";
|
|
3
3
|
import { Clock } from "lucide";
|
|
4
|
-
import { i18n } from "../../utils/i18n
|
|
5
|
-
import { renderHeader } from "../renderer-registry
|
|
6
|
-
import type { ToolRenderer, ToolRenderResult } from "../types
|
|
4
|
+
import { i18n } from "../../utils/i18n";
|
|
5
|
+
import { renderHeader } from "../renderer-registry";
|
|
6
|
+
import type { ToolRenderer, ToolRenderResult } from "../types";
|
|
7
7
|
|
|
8
8
|
interface GetCurrentTimeParams {
|
|
9
9
|
timezone?: string;
|
|
@@ -3,7 +3,7 @@ import JSZip from "jszip";
|
|
|
3
3
|
import type { PDFDocumentProxy } from "pdfjs-dist";
|
|
4
4
|
import * as pdfjsLib from "pdfjs-dist";
|
|
5
5
|
import * as XLSX from "xlsx";
|
|
6
|
-
import { i18n } from "./i18n
|
|
6
|
+
import { i18n } from "./i18n";
|
|
7
7
|
|
|
8
8
|
// Configure PDF.js worker - we'll need to bundle this
|
|
9
9
|
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL("pdfjs-dist/build/pdf.worker.min.mjs", import.meta.url).toString();
|
package/src/utils/auth-token.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import PromptDialog from "@mariozechner/mini-lit/dist/PromptDialog.js";
|
|
2
|
-
import { i18n } from "./i18n
|
|
2
|
+
import { i18n } from "./i18n";
|
|
3
3
|
|
|
4
4
|
export async function getAuthToken(): Promise<string | undefined> {
|
|
5
5
|
let authToken: string | undefined = localStorage.getItem(`auth-token`) || "";
|