@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
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized tool prompts/descriptions.
|
|
3
|
+
* Each prompt is either a string constant or a template function.
|
|
4
|
+
*/
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// JavaScript REPL Tool
|
|
7
|
+
// ============================================================================
|
|
8
|
+
export const JAVASCRIPT_REPL_TOOL_DESCRIPTION = (runtimeProviderDescriptions) => `# JavaScript REPL
|
|
9
|
+
|
|
10
|
+
## Purpose
|
|
11
|
+
Execute JavaScript code in a sandboxed browser environment with full Web APIs.
|
|
12
|
+
|
|
13
|
+
## When to Use
|
|
14
|
+
- Quick calculations or data transformations
|
|
15
|
+
- Testing JavaScript code snippets in isolation
|
|
16
|
+
- Processing data with libraries (XLSX, CSV, etc.)
|
|
17
|
+
- Creating artifacts from data
|
|
18
|
+
|
|
19
|
+
## Environment
|
|
20
|
+
- ES2023+ JavaScript (async/await, optional chaining, nullish coalescing, etc.)
|
|
21
|
+
- All browser APIs: DOM, Canvas, WebGL, Fetch, Web Workers, WebSockets, Crypto, etc.
|
|
22
|
+
- Import any npm package: await import('https://esm.run/package-name')
|
|
23
|
+
|
|
24
|
+
## Common Libraries
|
|
25
|
+
- XLSX: const XLSX = await import('https://esm.run/xlsx');
|
|
26
|
+
- CSV: const Papa = (await import('https://esm.run/papaparse')).default;
|
|
27
|
+
- Chart.js: const Chart = (await import('https://esm.run/chart.js/auto')).default;
|
|
28
|
+
- Three.js: const THREE = await import('https://esm.run/three');
|
|
29
|
+
|
|
30
|
+
## Persistence between tool calls
|
|
31
|
+
- Objects stored on global scope do not persist between calls.
|
|
32
|
+
- Use artifacts as a key-value JSON object store:
|
|
33
|
+
- Use createOrUpdateArtifact(filename, content) to persist data between calls. JSON objects are auto-stringified.
|
|
34
|
+
- Use listArtifacts() and getArtifact(filename) to read persisted data. JSON files are auto-parsed to objects.
|
|
35
|
+
- Prefer to use a single artifact throughout the session to store intermediate data (e.g. 'data.json').
|
|
36
|
+
|
|
37
|
+
## Input
|
|
38
|
+
- You have access to the user's attachments via listAttachments(), readTextAttachment(id), and readBinaryAttachment(id)
|
|
39
|
+
- You have access to previously created artifacts via listArtifacts() and getArtifact(filename)
|
|
40
|
+
|
|
41
|
+
## Output
|
|
42
|
+
- All console.log() calls are captured for you to inspect. The user does not see these logs.
|
|
43
|
+
- Create artifacts for file results (images, JSON, CSV, etc.) which persiste throughout the
|
|
44
|
+
session and are accessible to you and the user.
|
|
45
|
+
|
|
46
|
+
## Example
|
|
47
|
+
const data = [10, 20, 15, 25];
|
|
48
|
+
const sum = data.reduce((a, b) => a + b, 0);
|
|
49
|
+
const avg = sum / data.length;
|
|
50
|
+
console.log('Sum:', sum, 'Average:', avg);
|
|
51
|
+
|
|
52
|
+
## Important Notes
|
|
53
|
+
- Graphics: Use fixed dimensions (800x600), NOT window.innerWidth/Height
|
|
54
|
+
- Chart.js: Set options: { responsive: false, animation: false }
|
|
55
|
+
- Three.js: renderer.setSize(800, 600) with matching aspect ratio
|
|
56
|
+
|
|
57
|
+
## Helper Functions (Automatically Available)
|
|
58
|
+
|
|
59
|
+
These functions are injected into the execution environment and available globally:
|
|
60
|
+
|
|
61
|
+
${runtimeProviderDescriptions.join("\n\n")}
|
|
62
|
+
`;
|
|
63
|
+
// ============================================================================
|
|
64
|
+
// Artifacts Tool
|
|
65
|
+
// ============================================================================
|
|
66
|
+
export const ARTIFACTS_TOOL_DESCRIPTION = (runtimeProviderDescriptions) => `# Artifacts
|
|
67
|
+
|
|
68
|
+
Create and manage persistent files that live alongside the conversation.
|
|
69
|
+
|
|
70
|
+
## When to Use - Artifacts Tool vs REPL
|
|
71
|
+
|
|
72
|
+
**Use artifacts tool when YOU are the author:**
|
|
73
|
+
- Writing research summaries, analysis, ideas, documentation
|
|
74
|
+
- Creating markdown notes for user to read
|
|
75
|
+
- Building HTML applications/visualizations that present data
|
|
76
|
+
- Creating HTML artifacts that render charts from programmatically generated data
|
|
77
|
+
|
|
78
|
+
**Use repl + artifact storage functions when CODE processes data:**
|
|
79
|
+
- Scraping workflows that extract and store data
|
|
80
|
+
- Processing CSV/Excel files programmatically
|
|
81
|
+
- Data transformation pipelines
|
|
82
|
+
- Binary file generation requiring libraries (PDF, DOCX)
|
|
83
|
+
|
|
84
|
+
**Pattern: REPL generates data → Artifacts tool creates HTML that visualizes it**
|
|
85
|
+
Example: repl scrapes products → stores products.json → you author dashboard.html that reads products.json and renders Chart.js visualizations
|
|
86
|
+
|
|
87
|
+
## Input
|
|
88
|
+
- { action: "create", filename: "notes.md", content: "..." } - Create new file
|
|
89
|
+
- { action: "update", filename: "notes.md", old_str: "...", new_str: "..." } - Update part of file (PREFERRED)
|
|
90
|
+
- { action: "rewrite", filename: "notes.md", content: "..." } - Replace entire file (LAST RESORT)
|
|
91
|
+
- { action: "get", filename: "data.json" } - Retrieve file content
|
|
92
|
+
- { action: "delete", filename: "old.csv" } - Delete file
|
|
93
|
+
- { action: "htmlArtifactLogs", filename: "app.html" } - Get console logs from HTML artifact
|
|
94
|
+
|
|
95
|
+
## Returns
|
|
96
|
+
Depends on action:
|
|
97
|
+
- create/update/rewrite/delete: Success status or error
|
|
98
|
+
- get: File content
|
|
99
|
+
- htmlArtifactLogs: Console logs and errors
|
|
100
|
+
|
|
101
|
+
## Supported File Types
|
|
102
|
+
✅ Text-based files you author: .md, .txt, .html, .js, .css, .json, .csv, .svg
|
|
103
|
+
❌ Binary files requiring libraries (use repl): .pdf, .docx
|
|
104
|
+
|
|
105
|
+
## Critical - Prefer Update Over Rewrite
|
|
106
|
+
❌ NEVER: get entire file + rewrite to change small sections
|
|
107
|
+
✅ ALWAYS: update for targeted edits (token efficient)
|
|
108
|
+
✅ Ask: Can I describe the change as old_str → new_str? Use update.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## HTML Artifacts
|
|
113
|
+
|
|
114
|
+
Interactive HTML applications that can visualize data from other artifacts.
|
|
115
|
+
|
|
116
|
+
### Data Access
|
|
117
|
+
- Can read artifacts created by repl and user attachments
|
|
118
|
+
- Use to build dashboards, visualizations, interactive tools
|
|
119
|
+
- See Helper Functions section below for available functions
|
|
120
|
+
|
|
121
|
+
### Requirements
|
|
122
|
+
- Self-contained single file
|
|
123
|
+
- Import ES modules from esm.sh: <script type="module">import X from 'https://esm.sh/pkg';</script>
|
|
124
|
+
- Use Tailwind CDN: <script src="https://cdn.tailwindcss.com"></script>
|
|
125
|
+
- Can embed images from any domain: <img src="https://example.com/image.jpg">
|
|
126
|
+
- MUST set background color explicitly (avoid transparent)
|
|
127
|
+
- Inline CSS or Tailwind utility classes
|
|
128
|
+
- No localStorage/sessionStorage
|
|
129
|
+
|
|
130
|
+
### Styling
|
|
131
|
+
- Use Tailwind utility classes for clean, functional designs
|
|
132
|
+
- Ensure responsive layout (iframe may be resized)
|
|
133
|
+
- Avoid purple gradients, AI aesthetic clichés, and emojis
|
|
134
|
+
|
|
135
|
+
### Helper Functions (Automatically Available)
|
|
136
|
+
|
|
137
|
+
These functions are injected into HTML artifact sandbox:
|
|
138
|
+
|
|
139
|
+
${runtimeProviderDescriptions.join("\n\n")}
|
|
140
|
+
`;
|
|
141
|
+
// ============================================================================
|
|
142
|
+
// Artifacts Runtime Provider
|
|
143
|
+
// ============================================================================
|
|
144
|
+
export const ARTIFACTS_RUNTIME_PROVIDER_DESCRIPTION_RW = `
|
|
145
|
+
### Artifacts Storage
|
|
146
|
+
|
|
147
|
+
Create, read, update, and delete files in artifacts storage.
|
|
148
|
+
|
|
149
|
+
#### When to Use
|
|
150
|
+
- Store intermediate results between tool calls
|
|
151
|
+
- Save generated files (images, CSVs, processed data) for user to view and download
|
|
152
|
+
|
|
153
|
+
#### Do NOT Use For
|
|
154
|
+
- Content you author directly, like summaries of content you read (use artifacts tool instead)
|
|
155
|
+
|
|
156
|
+
#### Functions
|
|
157
|
+
- listArtifacts() - List all artifact filenames, returns Promise<string[]>
|
|
158
|
+
- getArtifact(filename) - Read artifact content, returns Promise<string | object>. JSON files auto-parse to objects, binary files return base64 string
|
|
159
|
+
- createOrUpdateArtifact(filename, content, mimeType?) - Create or update artifact, returns Promise<void>. JSON files auto-stringify objects, binary requires base64 string with mimeType
|
|
160
|
+
- deleteArtifact(filename) - Delete artifact, returns Promise<void>
|
|
161
|
+
|
|
162
|
+
#### Example
|
|
163
|
+
JSON workflow:
|
|
164
|
+
\`\`\`javascript
|
|
165
|
+
// Fetch and save
|
|
166
|
+
const response = await fetch('https://api.example.com/products');
|
|
167
|
+
const products = await response.json();
|
|
168
|
+
await createOrUpdateArtifact('products.json', products);
|
|
169
|
+
|
|
170
|
+
// Later: read and filter
|
|
171
|
+
const all = await getArtifact('products.json');
|
|
172
|
+
const cheap = all.filter(p => p.price < 100);
|
|
173
|
+
await createOrUpdateArtifact('cheap.json', cheap);
|
|
174
|
+
\`\`\`
|
|
175
|
+
|
|
176
|
+
Binary file (image):
|
|
177
|
+
\`\`\`javascript
|
|
178
|
+
const canvas = document.createElement('canvas');
|
|
179
|
+
canvas.width = 800; canvas.height = 600;
|
|
180
|
+
const ctx = canvas.getContext('2d');
|
|
181
|
+
ctx.fillStyle = 'blue';
|
|
182
|
+
ctx.fillRect(0, 0, 800, 600);
|
|
183
|
+
// Remove data:image/png;base64, prefix
|
|
184
|
+
const base64 = canvas.toDataURL().split(',')[1];
|
|
185
|
+
await createOrUpdateArtifact('chart.png', base64, 'image/png');
|
|
186
|
+
\`\`\`
|
|
187
|
+
`;
|
|
188
|
+
export const ARTIFACTS_RUNTIME_PROVIDER_DESCRIPTION_RO = `
|
|
189
|
+
### Artifacts Storage
|
|
190
|
+
|
|
191
|
+
Read files from artifacts storage.
|
|
192
|
+
|
|
193
|
+
#### When to Use
|
|
194
|
+
- Read artifacts created by REPL or artifacts tool
|
|
195
|
+
- Access data from other HTML artifacts
|
|
196
|
+
- Load configuration or data files
|
|
197
|
+
|
|
198
|
+
#### Do NOT Use For
|
|
199
|
+
- Creating new artifacts (not available in HTML artifacts)
|
|
200
|
+
- Modifying artifacts (read-only access)
|
|
201
|
+
|
|
202
|
+
#### Functions
|
|
203
|
+
- listArtifacts() - List all artifact filenames, returns Promise<string[]>
|
|
204
|
+
- getArtifact(filename) - Read artifact content, returns Promise<string | object>. JSON files auto-parse to objects, binary files return base64 string
|
|
205
|
+
|
|
206
|
+
#### Example
|
|
207
|
+
JSON data:
|
|
208
|
+
\`\`\`javascript
|
|
209
|
+
const products = await getArtifact('products.json');
|
|
210
|
+
const html = products.map(p => \`<div>\${p.name}: $\${p.price}</div>\`).join('');
|
|
211
|
+
document.body.innerHTML = html;
|
|
212
|
+
\`\`\`
|
|
213
|
+
|
|
214
|
+
Binary image:
|
|
215
|
+
\`\`\`javascript
|
|
216
|
+
const base64 = await getArtifact('chart.png');
|
|
217
|
+
const img = document.createElement('img');
|
|
218
|
+
img.src = 'data:image/png;base64,' + base64;
|
|
219
|
+
document.body.appendChild(img);
|
|
220
|
+
\`\`\`
|
|
221
|
+
`;
|
|
222
|
+
// ============================================================================
|
|
223
|
+
// Attachments Runtime Provider
|
|
224
|
+
// ============================================================================
|
|
225
|
+
export const ATTACHMENTS_RUNTIME_DESCRIPTION = `
|
|
226
|
+
### User Attachments
|
|
227
|
+
|
|
228
|
+
Read files the user uploaded to the conversation.
|
|
229
|
+
|
|
230
|
+
#### When to Use
|
|
231
|
+
- Process user-uploaded files (CSV, JSON, Excel, images, PDFs)
|
|
232
|
+
|
|
233
|
+
#### Functions
|
|
234
|
+
- listAttachments() - List all attachments, returns array of {id, fileName, mimeType, size}
|
|
235
|
+
- readTextAttachment(id) - Read attachment as text, returns string
|
|
236
|
+
- readBinaryAttachment(id) - Read attachment as binary data, returns Uint8Array
|
|
237
|
+
|
|
238
|
+
#### Example
|
|
239
|
+
CSV file:
|
|
240
|
+
\`\`\`javascript
|
|
241
|
+
const files = listAttachments();
|
|
242
|
+
const csvFile = files.find(f => f.fileName.endsWith('.csv'));
|
|
243
|
+
const csvData = readTextAttachment(csvFile.id);
|
|
244
|
+
const rows = csvData.split('\\n').map(row => row.split(','));
|
|
245
|
+
\`\`\`
|
|
246
|
+
|
|
247
|
+
Excel file:
|
|
248
|
+
\`\`\`javascript
|
|
249
|
+
const XLSX = await import('https://esm.run/xlsx');
|
|
250
|
+
const files = listAttachments();
|
|
251
|
+
const xlsxFile = files.find(f => f.fileName.endsWith('.xlsx'));
|
|
252
|
+
const bytes = readBinaryAttachment(xlsxFile.id);
|
|
253
|
+
const workbook = XLSX.read(bytes);
|
|
254
|
+
const data = XLSX.utils.sheet_to_json(workbook.Sheets[workbook.SheetNames[0]]);
|
|
255
|
+
\`\`\`
|
|
256
|
+
`;
|
|
257
|
+
// ============================================================================
|
|
258
|
+
// Extract Document Tool
|
|
259
|
+
// ============================================================================
|
|
260
|
+
export const EXTRACT_DOCUMENT_DESCRIPTION = `# Extract Document
|
|
261
|
+
|
|
262
|
+
Extract plain text from documents on the web (PDF, DOCX, XLSX, PPTX).
|
|
263
|
+
|
|
264
|
+
## When to Use
|
|
265
|
+
User wants you to read a document at a URL.
|
|
266
|
+
|
|
267
|
+
## Input
|
|
268
|
+
- { url: "https://example.com/document.pdf" } - URL to PDF, DOCX, XLSX, or PPTX
|
|
269
|
+
|
|
270
|
+
## Returns
|
|
271
|
+
Structured plain text with page/sheet/slide delimiters.`;
|
|
272
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/prompts/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,2BAAqC,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqDzF,2BAA2B,CAAC,IAAI,CAAC,MAAM,CAAC;CACzC,CAAC;AAEF,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,2BAAqC,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyEnF,2BAA2B,CAAC,IAAI,CAAC,MAAM,CAAC;CACzC,CAAC;AAEF,+EAA+E;AAC/E,6BAA6B;AAC7B,+EAA+E;AAE/E,MAAM,CAAC,MAAM,yCAAyC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CxD,CAAC;AAEF,MAAM,CAAC,MAAM,yCAAyC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCxD,CAAC;AAEF,+EAA+E;AAC/E,+BAA+B;AAC/B,+EAA+E;AAE/E,MAAM,CAAC,MAAM,+BAA+B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+B9C,CAAC;AAEF,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,4BAA4B,GAAG;;;;;;;;;;;wDAWY,CAAC"}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
1
|
+
import type { ProviderKeysStore } from "./stores/provider-keys-store.js";
|
|
2
|
+
import type { SessionsStore } from "./stores/sessions-store.js";
|
|
3
|
+
import type { SettingsStore } from "./stores/settings-store.js";
|
|
4
|
+
import type { StorageBackend } from "./types.js";
|
|
4
5
|
/**
|
|
5
|
-
* High-level storage API
|
|
6
|
-
*
|
|
6
|
+
* High-level storage API providing access to all storage operations.
|
|
7
|
+
* Subclasses can extend this to add domain-specific stores.
|
|
7
8
|
*/
|
|
8
9
|
export declare class AppStorage {
|
|
9
|
-
readonly
|
|
10
|
-
readonly
|
|
11
|
-
|
|
10
|
+
readonly backend: StorageBackend;
|
|
11
|
+
readonly settings: SettingsStore;
|
|
12
|
+
readonly providerKeys: ProviderKeysStore;
|
|
13
|
+
readonly sessions: SessionsStore;
|
|
14
|
+
constructor(settings: SettingsStore, providerKeys: ProviderKeysStore, sessions: SessionsStore, backend: StorageBackend);
|
|
15
|
+
getQuotaInfo(): Promise<{
|
|
16
|
+
usage: number;
|
|
17
|
+
quota: number;
|
|
18
|
+
percent: number;
|
|
19
|
+
}>;
|
|
20
|
+
requestPersistence(): Promise<boolean>;
|
|
12
21
|
}
|
|
13
22
|
/**
|
|
14
23
|
* Get the global AppStorage instance.
|
|
@@ -19,8 +28,4 @@ export declare function getAppStorage(): AppStorage;
|
|
|
19
28
|
* Set the global AppStorage instance.
|
|
20
29
|
*/
|
|
21
30
|
export declare function setAppStorage(storage: AppStorage): void;
|
|
22
|
-
/**
|
|
23
|
-
* Initialize AppStorage with default configuration if not already set.
|
|
24
|
-
*/
|
|
25
|
-
export declare function initAppStorage(config?: AppStorageConfig): AppStorage;
|
|
26
31
|
//# sourceMappingURL=app-storage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-storage.d.ts","sourceRoot":"","sources":["../../src/storage/app-storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app-storage.d.ts","sourceRoot":"","sources":["../../src/storage/app-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;GAGG;AACH,qBAAa,UAAU;IACtB,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,iBAAiB,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;gBAGhC,QAAQ,EAAE,aAAa,EACvB,YAAY,EAAE,iBAAiB,EAC/B,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,cAAc;IAQlB,YAAY,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAI1E,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;CAG5C;AAKD;;;GAGG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAK1C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAEvD"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { LocalStorageBackend } from "./backends/local-storage-backend.js";
|
|
2
|
-
import { ProviderKeysRepository } from "./repositories/provider-keys-repository.js";
|
|
3
|
-
import { SettingsRepository } from "./repositories/settings-repository.js";
|
|
4
1
|
/**
|
|
5
|
-
* High-level storage API
|
|
6
|
-
*
|
|
2
|
+
* High-level storage API providing access to all storage operations.
|
|
3
|
+
* Subclasses can extend this to add domain-specific stores.
|
|
7
4
|
*/
|
|
8
5
|
export class AppStorage {
|
|
9
|
-
constructor(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.
|
|
14
|
-
|
|
6
|
+
constructor(settings, providerKeys, sessions, backend) {
|
|
7
|
+
this.settings = settings;
|
|
8
|
+
this.providerKeys = providerKeys;
|
|
9
|
+
this.sessions = sessions;
|
|
10
|
+
this.backend = backend;
|
|
11
|
+
}
|
|
12
|
+
async getQuotaInfo() {
|
|
13
|
+
return this.backend.getQuotaInfo();
|
|
14
|
+
}
|
|
15
|
+
async requestPersistence() {
|
|
16
|
+
return this.backend.requestPersistence();
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
// Global instance management
|
|
@@ -32,13 +34,4 @@ export function getAppStorage() {
|
|
|
32
34
|
export function setAppStorage(storage) {
|
|
33
35
|
globalAppStorage = storage;
|
|
34
36
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Initialize AppStorage with default configuration if not already set.
|
|
37
|
-
*/
|
|
38
|
-
export function initAppStorage(config = {}) {
|
|
39
|
-
if (!globalAppStorage) {
|
|
40
|
-
globalAppStorage = new AppStorage(config);
|
|
41
|
-
}
|
|
42
|
-
return globalAppStorage;
|
|
43
|
-
}
|
|
44
37
|
//# sourceMappingURL=app-storage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-storage.js","sourceRoot":"","sources":["../../src/storage/app-storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app-storage.js","sourceRoot":"","sources":["../../src/storage/app-storage.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,OAAO,UAAU;IAMtB,YACC,QAAuB,EACvB,YAA+B,EAC/B,QAAuB,EACvB,OAAuB;QAEvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,YAAY;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,kBAAkB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAC1C,CAAC;CACD;AAED,6BAA6B;AAC7B,IAAI,gBAAgB,GAAsB,IAAI,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC5B,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,gBAAgB,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAAmB;IAChD,gBAAgB,GAAG,OAAO,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { IndexedDBConfig, StorageBackend, StorageTransaction } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* IndexedDB implementation of StorageBackend.
|
|
4
|
+
* Provides multi-store key-value storage with transactions and quota management.
|
|
5
|
+
*/
|
|
6
|
+
export declare class IndexedDBStorageBackend implements StorageBackend {
|
|
7
|
+
private config;
|
|
8
|
+
private dbPromise;
|
|
9
|
+
constructor(config: IndexedDBConfig);
|
|
10
|
+
private getDB;
|
|
11
|
+
private promisifyRequest;
|
|
12
|
+
get<T = unknown>(storeName: string, key: string): Promise<T | null>;
|
|
13
|
+
set<T = unknown>(storeName: string, key: string, value: T): Promise<void>;
|
|
14
|
+
delete(storeName: string, key: string): Promise<void>;
|
|
15
|
+
keys(storeName: string, prefix?: string): Promise<string[]>;
|
|
16
|
+
getAllFromIndex<T = unknown>(storeName: string, indexName: string, direction?: "asc" | "desc"): Promise<T[]>;
|
|
17
|
+
clear(storeName: string): Promise<void>;
|
|
18
|
+
has(storeName: string, key: string): Promise<boolean>;
|
|
19
|
+
transaction<T>(storeNames: string[], mode: "readonly" | "readwrite", operation: (tx: StorageTransaction) => Promise<T>): Promise<T>;
|
|
20
|
+
getQuotaInfo(): Promise<{
|
|
21
|
+
usage: number;
|
|
22
|
+
quota: number;
|
|
23
|
+
percent: number;
|
|
24
|
+
}>;
|
|
25
|
+
requestPersistence(): Promise<boolean>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=indexeddb-storage-backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexeddb-storage-backend.d.ts","sourceRoot":"","sources":["../../../src/storage/backends/indexeddb-storage-backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEvF;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,cAAc;IAGjD,OAAO,CAAC,MAAM;IAF1B,OAAO,CAAC,SAAS,CAAqC;gBAElC,MAAM,EAAE,eAAe;YAE7B,KAAK;IAoCnB,OAAO,CAAC,gBAAgB;IAOlB,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAQnE,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAazE,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOrD,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAgB3D,eAAe,CAAC,CAAC,GAAG,OAAO,EAChC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,KAAK,GAAG,MAAc,GAC/B,OAAO,CAAC,CAAC,EAAE,CAAC;IAwBT,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOvC,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQrD,WAAW,CAAC,CAAC,EAClB,UAAU,EAAE,MAAM,EAAE,EACpB,IAAI,EAAE,UAAU,GAAG,WAAW,EAC9B,SAAS,EAAE,CAAC,EAAE,EAAE,kBAAkB,KAAK,OAAO,CAAC,CAAC,CAAC,GAC/C,OAAO,CAAC,CAAC,CAAC;IA6BP,YAAY,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAY1E,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;CAM5C"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IndexedDB implementation of StorageBackend.
|
|
3
|
+
* Provides multi-store key-value storage with transactions and quota management.
|
|
4
|
+
*/
|
|
5
|
+
export class IndexedDBStorageBackend {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.config = config;
|
|
8
|
+
this.dbPromise = null;
|
|
9
|
+
}
|
|
10
|
+
async getDB() {
|
|
11
|
+
if (!this.dbPromise) {
|
|
12
|
+
this.dbPromise = new Promise((resolve, reject) => {
|
|
13
|
+
const request = indexedDB.open(this.config.dbName, this.config.version);
|
|
14
|
+
request.onerror = () => reject(request.error);
|
|
15
|
+
request.onsuccess = () => resolve(request.result);
|
|
16
|
+
request.onupgradeneeded = (_event) => {
|
|
17
|
+
const db = request.result;
|
|
18
|
+
// Create object stores from config
|
|
19
|
+
for (const storeConfig of this.config.stores) {
|
|
20
|
+
if (!db.objectStoreNames.contains(storeConfig.name)) {
|
|
21
|
+
const store = db.createObjectStore(storeConfig.name, {
|
|
22
|
+
keyPath: storeConfig.keyPath,
|
|
23
|
+
autoIncrement: storeConfig.autoIncrement,
|
|
24
|
+
});
|
|
25
|
+
// Create indices
|
|
26
|
+
if (storeConfig.indices) {
|
|
27
|
+
for (const indexConfig of storeConfig.indices) {
|
|
28
|
+
store.createIndex(indexConfig.name, indexConfig.keyPath, {
|
|
29
|
+
unique: indexConfig.unique,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return this.dbPromise;
|
|
39
|
+
}
|
|
40
|
+
promisifyRequest(request) {
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
request.onsuccess = () => resolve(request.result);
|
|
43
|
+
request.onerror = () => reject(request.error);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async get(storeName, key) {
|
|
47
|
+
const db = await this.getDB();
|
|
48
|
+
const tx = db.transaction(storeName, "readonly");
|
|
49
|
+
const store = tx.objectStore(storeName);
|
|
50
|
+
const result = await this.promisifyRequest(store.get(key));
|
|
51
|
+
return result ?? null;
|
|
52
|
+
}
|
|
53
|
+
async set(storeName, key, value) {
|
|
54
|
+
const db = await this.getDB();
|
|
55
|
+
const tx = db.transaction(storeName, "readwrite");
|
|
56
|
+
const store = tx.objectStore(storeName);
|
|
57
|
+
// If store has keyPath, only pass value (in-line key)
|
|
58
|
+
// Otherwise pass both value and key (out-of-line key)
|
|
59
|
+
if (store.keyPath) {
|
|
60
|
+
await this.promisifyRequest(store.put(value));
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
await this.promisifyRequest(store.put(value, key));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async delete(storeName, key) {
|
|
67
|
+
const db = await this.getDB();
|
|
68
|
+
const tx = db.transaction(storeName, "readwrite");
|
|
69
|
+
const store = tx.objectStore(storeName);
|
|
70
|
+
await this.promisifyRequest(store.delete(key));
|
|
71
|
+
}
|
|
72
|
+
async keys(storeName, prefix) {
|
|
73
|
+
const db = await this.getDB();
|
|
74
|
+
const tx = db.transaction(storeName, "readonly");
|
|
75
|
+
const store = tx.objectStore(storeName);
|
|
76
|
+
if (prefix) {
|
|
77
|
+
// Use IDBKeyRange for efficient prefix filtering
|
|
78
|
+
const range = IDBKeyRange.bound(prefix, prefix + "\uffff", false, false);
|
|
79
|
+
const keys = await this.promisifyRequest(store.getAllKeys(range));
|
|
80
|
+
return keys.map((k) => String(k));
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const keys = await this.promisifyRequest(store.getAllKeys());
|
|
84
|
+
return keys.map((k) => String(k));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async getAllFromIndex(storeName, indexName, direction = "asc") {
|
|
88
|
+
const db = await this.getDB();
|
|
89
|
+
const tx = db.transaction(storeName, "readonly");
|
|
90
|
+
const store = tx.objectStore(storeName);
|
|
91
|
+
const index = store.index(indexName);
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
const results = [];
|
|
94
|
+
const request = index.openCursor(null, direction === "desc" ? "prev" : "next");
|
|
95
|
+
request.onsuccess = () => {
|
|
96
|
+
const cursor = request.result;
|
|
97
|
+
if (cursor) {
|
|
98
|
+
results.push(cursor.value);
|
|
99
|
+
cursor.continue();
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
resolve(results);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
request.onerror = () => reject(request.error);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async clear(storeName) {
|
|
109
|
+
const db = await this.getDB();
|
|
110
|
+
const tx = db.transaction(storeName, "readwrite");
|
|
111
|
+
const store = tx.objectStore(storeName);
|
|
112
|
+
await this.promisifyRequest(store.clear());
|
|
113
|
+
}
|
|
114
|
+
async has(storeName, key) {
|
|
115
|
+
const db = await this.getDB();
|
|
116
|
+
const tx = db.transaction(storeName, "readonly");
|
|
117
|
+
const store = tx.objectStore(storeName);
|
|
118
|
+
const result = await this.promisifyRequest(store.getKey(key));
|
|
119
|
+
return result !== undefined;
|
|
120
|
+
}
|
|
121
|
+
async transaction(storeNames, mode, operation) {
|
|
122
|
+
const db = await this.getDB();
|
|
123
|
+
const idbTx = db.transaction(storeNames, mode);
|
|
124
|
+
const storageTx = {
|
|
125
|
+
get: async (storeName, key) => {
|
|
126
|
+
const store = idbTx.objectStore(storeName);
|
|
127
|
+
const result = await this.promisifyRequest(store.get(key));
|
|
128
|
+
return (result ?? null);
|
|
129
|
+
},
|
|
130
|
+
set: async (storeName, key, value) => {
|
|
131
|
+
const store = idbTx.objectStore(storeName);
|
|
132
|
+
// If store has keyPath, only pass value (in-line key)
|
|
133
|
+
// Otherwise pass both value and key (out-of-line key)
|
|
134
|
+
if (store.keyPath) {
|
|
135
|
+
await this.promisifyRequest(store.put(value));
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
await this.promisifyRequest(store.put(value, key));
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
delete: async (storeName, key) => {
|
|
142
|
+
const store = idbTx.objectStore(storeName);
|
|
143
|
+
await this.promisifyRequest(store.delete(key));
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
return operation(storageTx);
|
|
147
|
+
}
|
|
148
|
+
async getQuotaInfo() {
|
|
149
|
+
if (navigator.storage?.estimate) {
|
|
150
|
+
const estimate = await navigator.storage.estimate();
|
|
151
|
+
return {
|
|
152
|
+
usage: estimate.usage || 0,
|
|
153
|
+
quota: estimate.quota || 0,
|
|
154
|
+
percent: estimate.quota ? ((estimate.usage || 0) / estimate.quota) * 100 : 0,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return { usage: 0, quota: 0, percent: 0 };
|
|
158
|
+
}
|
|
159
|
+
async requestPersistence() {
|
|
160
|
+
if (navigator.storage?.persist) {
|
|
161
|
+
return await navigator.storage.persist();
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=indexeddb-storage-backend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexeddb-storage-backend.js","sourceRoot":"","sources":["../../../src/storage/backends/indexeddb-storage-backend.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAGnC,YAAoB,MAAuB;QAAvB,WAAM,GAAN,MAAM,CAAiB;QAFnC,cAAS,GAAgC,IAAI,CAAC;IAER,CAAC;IAEvC,KAAK,CAAC,KAAK;QAClB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACrB,IAAI,CAAC,SAAS,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBAChD,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAExE,OAAO,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBAC9C,OAAO,CAAC,SAAS,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBAElD,OAAO,CAAC,eAAe,GAAG,CAAC,MAAM,EAAE,EAAE;oBACpC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;oBAE1B,mCAAmC;oBACnC,KAAK,MAAM,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;wBAC9C,IA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CAAC;QAEF,OAAO,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,YAAY;QACjB,IAAI,SAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC;YACjC,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACpD,OAAO;gBACN,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,CAAC;gBAC1B,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,CAAC;gBAC1B,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;aAC5E,CAAC;QACH,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,kBAAkB;QACvB,IAAI,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;YAChC,OAAO,MAAM,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC1C,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { StorageBackend, StoreConfig } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Base class for all storage stores.
|
|
4
|
+
* Each store defines its IndexedDB schema and provides domain-specific methods.
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class Store {
|
|
7
|
+
private backend;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the IndexedDB configuration for this store.
|
|
10
|
+
* Defines store name, key path, and indices.
|
|
11
|
+
*/
|
|
12
|
+
abstract getConfig(): StoreConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Sets the storage backend. Called by AppStorage after backend creation.
|
|
15
|
+
*/
|
|
16
|
+
setBackend(backend: StorageBackend): void;
|
|
17
|
+
/**
|
|
18
|
+
* Gets the storage backend. Throws if backend not set.
|
|
19
|
+
* Concrete stores must use this to access the backend.
|
|
20
|
+
*/
|
|
21
|
+
protected getBackend(): StorageBackend;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/storage/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D;;;GAGG;AACH,8BAAsB,KAAK;IAC1B,OAAO,CAAC,OAAO,CAA+B;IAE9C;;;OAGG;IACH,QAAQ,CAAC,SAAS,IAAI,WAAW;IAEjC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAIzC;;;OAGG;IACH,SAAS,CAAC,UAAU,IAAI,cAAc;CAMtC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for all storage stores.
|
|
3
|
+
* Each store defines its IndexedDB schema and provides domain-specific methods.
|
|
4
|
+
*/
|
|
5
|
+
export class Store {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.backend = null;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Sets the storage backend. Called by AppStorage after backend creation.
|
|
11
|
+
*/
|
|
12
|
+
setBackend(backend) {
|
|
13
|
+
this.backend = backend;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Gets the storage backend. Throws if backend not set.
|
|
17
|
+
* Concrete stores must use this to access the backend.
|
|
18
|
+
*/
|
|
19
|
+
getBackend() {
|
|
20
|
+
if (!this.backend) {
|
|
21
|
+
throw new Error(`Backend not set on ${this.constructor.name}`);
|
|
22
|
+
}
|
|
23
|
+
return this.backend;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/storage/store.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAgB,KAAK;IAA3B;QACS,YAAO,GAA0B,IAAI,CAAC;IAyB/C,CAAC;IAjBA;;OAEG;IACH,UAAU,CAAC,OAAuB;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAED;;;OAGG;IACO,UAAU;QACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;CACD"}
|