@solidxai/core-ui 0.1.19-beta.0 → 0.1.19
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 +19 -0
- package/dist/components/common/SolidPopupContainer.d.ts.map +1 -1
- package/dist/components/common/SolidPopupContainer.js +3 -2
- package/dist/components/common/SolidPopupContainer.js.map +1 -1
- package/dist/components/common/SolidPopupContainer.tsx +3 -2
- package/dist/components/common/SolidSettings/LlmSettings/AiModelConfigTab.d.ts.map +1 -1
- package/dist/components/common/SolidSettings/LlmSettings/AiModelConfigTab.js +4 -1
- package/dist/components/common/SolidSettings/LlmSettings/AiModelConfigTab.js.map +1 -1
- package/dist/components/common/SolidSettings/LlmSettings/AiModelConfigTab.tsx +11 -5
- package/dist/components/core/chatter/SolidChatter.d.ts.map +1 -1
- package/dist/components/core/chatter/SolidChatter.js +2 -1
- package/dist/components/core/chatter/SolidChatter.js.map +1 -1
- package/dist/components/core/chatter/SolidChatter.tsx +2 -0
- package/dist/components/core/chatter/SolidChatterMessageBox.d.ts +2 -0
- package/dist/components/core/chatter/SolidChatterMessageBox.d.ts.map +1 -1
- package/dist/components/core/chatter/SolidChatterMessageBox.js +7 -4
- package/dist/components/core/chatter/SolidChatterMessageBox.js.map +1 -1
- package/dist/components/core/chatter/SolidChatterMessageBox.tsx +8 -3
- package/dist/components/core/chatter/SolidChatterMessageWidget.d.ts +5 -0
- package/dist/components/core/chatter/SolidChatterMessageWidget.d.ts.map +1 -0
- package/dist/components/core/chatter/SolidChatterMessageWidget.js +85 -0
- package/dist/components/core/chatter/SolidChatterMessageWidget.js.map +1 -0
- package/dist/components/core/chatter/SolidChatterMessageWidget.tsx +59 -0
- package/dist/components/core/common/SolidGlobalSearchElement.d.ts.map +1 -1
- package/dist/components/core/common/SolidGlobalSearchElement.js +6 -5
- package/dist/components/core/common/SolidGlobalSearchElement.js.map +1 -1
- package/dist/components/core/common/SolidGlobalSearchElement.tsx +6 -5
- package/dist/components/core/extension/solid-core/agentEvent/list/AgentEventOutcomeListWidget.d.ts +11 -0
- package/dist/components/core/extension/solid-core/agentEvent/list/AgentEventOutcomeListWidget.d.ts.map +1 -0
- package/dist/components/core/extension/solid-core/agentEvent/list/AgentEventOutcomeListWidget.js +102 -0
- package/dist/components/core/extension/solid-core/agentEvent/list/AgentEventOutcomeListWidget.js.map +1 -0
- package/dist/components/core/extension/solid-core/agentEvent/list/AgentEventOutcomeListWidget.tsx +129 -0
- package/dist/components/core/extension/solid-core/agentRegistry/card/AgentRegistryCardWidget.d.ts +4 -0
- package/dist/components/core/extension/solid-core/agentRegistry/card/AgentRegistryCardWidget.d.ts.map +1 -0
- package/dist/components/core/extension/solid-core/agentRegistry/card/AgentRegistryCardWidget.js +29 -0
- package/dist/components/core/extension/solid-core/agentRegistry/card/AgentRegistryCardWidget.js.map +1 -0
- package/dist/components/core/extension/solid-core/agentRegistry/card/AgentRegistryCardWidget.module.css +226 -0
- package/dist/components/core/extension/solid-core/agentRegistry/card/AgentRegistryCardWidget.tsx +57 -0
- package/dist/components/core/extension/solid-core/agentRegistry/card/AgentResourceCardWidget.d.ts +4 -0
- package/dist/components/core/extension/solid-core/agentRegistry/card/AgentResourceCardWidget.d.ts.map +1 -0
- package/dist/components/core/extension/solid-core/agentRegistry/card/AgentResourceCardWidget.js +33 -0
- package/dist/components/core/extension/solid-core/agentRegistry/card/AgentResourceCardWidget.js.map +1 -0
- package/dist/components/core/extension/solid-core/agentRegistry/card/AgentResourceCardWidget.tsx +47 -0
- package/dist/components/core/extension/solid-core/agentToolRegistry/AgentProcessesPanel.d.ts +5 -0
- package/dist/components/core/extension/solid-core/agentToolRegistry/AgentProcessesPanel.d.ts.map +1 -0
- package/dist/components/core/extension/solid-core/agentToolRegistry/AgentProcessesPanel.js +59 -0
- package/dist/components/core/extension/solid-core/agentToolRegistry/AgentProcessesPanel.js.map +1 -0
- package/dist/components/core/extension/solid-core/agentToolRegistry/AgentProcessesPanel.tsx +82 -0
- package/dist/components/core/extension/solid-core/agentToolRegistry/AgentToolSessionsPanel.d.ts +17 -0
- package/dist/components/core/extension/solid-core/agentToolRegistry/AgentToolSessionsPanel.d.ts.map +1 -0
- package/dist/components/core/extension/solid-core/agentToolRegistry/AgentToolSessionsPanel.js +258 -0
- package/dist/components/core/extension/solid-core/agentToolRegistry/AgentToolSessionsPanel.js.map +1 -0
- package/dist/components/core/extension/solid-core/agentToolRegistry/AgentToolSessionsPanel.tsx +286 -0
- package/dist/components/core/extension/solid-core/modelMetadata/list/DeleteModelRowAction.d.ts.map +1 -1
- package/dist/components/core/extension/solid-core/modelMetadata/list/DeleteModelRowAction.js +102 -62
- package/dist/components/core/extension/solid-core/modelMetadata/list/DeleteModelRowAction.js.map +1 -1
- package/dist/components/core/extension/solid-core/modelMetadata/list/DeleteModelRowAction.tsx +116 -106
- package/dist/components/core/extension/solid-core/mqMessage/MqMessageSelectedRecordsSummaryHeaderAction.d.ts +6 -0
- package/dist/components/core/extension/solid-core/mqMessage/MqMessageSelectedRecordsSummaryHeaderAction.d.ts.map +1 -0
- package/dist/components/core/extension/solid-core/mqMessage/MqMessageSelectedRecordsSummaryHeaderAction.js +37 -0
- package/dist/components/core/extension/solid-core/mqMessage/MqMessageSelectedRecordsSummaryHeaderAction.js.map +1 -0
- package/dist/components/core/extension/solid-core/mqMessage/MqMessageSelectedRecordsSummaryHeaderAction.tsx +89 -0
- package/dist/components/core/extension/solid-core/mqMessage/kanban/MqMessageDetailsKanbanCardAction.d.ts +3 -0
- package/dist/components/core/extension/solid-core/mqMessage/kanban/MqMessageDetailsKanbanCardAction.d.ts.map +1 -0
- package/dist/components/core/extension/solid-core/mqMessage/kanban/MqMessageDetailsKanbanCardAction.js +18 -0
- package/dist/components/core/extension/solid-core/mqMessage/kanban/MqMessageDetailsKanbanCardAction.js.map +1 -0
- package/dist/components/core/extension/solid-core/mqMessage/kanban/MqMessageDetailsKanbanCardAction.tsx +51 -0
- package/dist/components/core/extension/solid-core/mqMessage/kanban/MqMessageKanbanQuickFilterHeaderAction.d.ts +10 -0
- package/dist/components/core/extension/solid-core/mqMessage/kanban/MqMessageKanbanQuickFilterHeaderAction.d.ts.map +1 -0
- package/dist/components/core/extension/solid-core/mqMessage/kanban/MqMessageKanbanQuickFilterHeaderAction.js +63 -0
- package/dist/components/core/extension/solid-core/mqMessage/kanban/MqMessageKanbanQuickFilterHeaderAction.js.map +1 -0
- package/dist/components/core/extension/solid-core/mqMessage/kanban/MqMessageKanbanQuickFilterHeaderAction.tsx +111 -0
- package/dist/components/core/field/FieldListViewData.d.ts.map +1 -1
- package/dist/components/core/field/FieldListViewData.js +29 -9
- package/dist/components/core/field/FieldListViewData.js.map +1 -1
- package/dist/components/core/field/FieldListViewData.tsx +7 -6
- package/dist/components/core/form/SolidFormView.d.ts +1 -0
- package/dist/components/core/form/SolidFormView.d.ts.map +1 -1
- package/dist/components/core/form/SolidFormView.js +49 -48
- package/dist/components/core/form/SolidFormView.js.map +1 -1
- package/dist/components/core/form/SolidFormView.tsx +4 -3
- package/dist/components/core/form/fields/SolidPasswordField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidPasswordField.js +13 -1
- package/dist/components/core/form/fields/SolidPasswordField.js.map +1 -1
- package/dist/components/core/form/fields/SolidPasswordField.tsx +14 -3
- package/dist/components/core/kanban/KanbanBoard.d.ts +1 -1
- package/dist/components/core/kanban/KanbanBoard.d.ts.map +1 -1
- package/dist/components/core/kanban/KanbanBoard.js +2 -2
- package/dist/components/core/kanban/KanbanBoard.js.map +1 -1
- package/dist/components/core/kanban/KanbanBoard.tsx +5 -1
- package/dist/components/core/kanban/KanbanCard.d.ts +3 -0
- package/dist/components/core/kanban/KanbanCard.d.ts.map +1 -1
- package/dist/components/core/kanban/KanbanCard.js +5 -4
- package/dist/components/core/kanban/KanbanCard.js.map +1 -1
- package/dist/components/core/kanban/KanbanCard.tsx +31 -11
- package/dist/components/core/kanban/KanbanColumn.d.ts +5 -1
- package/dist/components/core/kanban/KanbanColumn.d.ts.map +1 -1
- package/dist/components/core/kanban/KanbanColumn.js +14 -3
- package/dist/components/core/kanban/KanbanColumn.js.map +1 -1
- package/dist/components/core/kanban/KanbanColumn.tsx +43 -3
- package/dist/components/core/kanban/SolidKanbanView.d.ts +2 -0
- package/dist/components/core/kanban/SolidKanbanView.d.ts.map +1 -1
- package/dist/components/core/kanban/SolidKanbanView.js +90 -52
- package/dist/components/core/kanban/SolidKanbanView.js.map +1 -1
- package/dist/components/core/kanban/SolidKanbanView.tsx +93 -13
- package/dist/components/core/list/SolidDataTable.d.ts +2 -1
- package/dist/components/core/list/SolidDataTable.d.ts.map +1 -1
- package/dist/components/core/list/SolidDataTable.js +2 -2
- package/dist/components/core/list/SolidDataTable.js.map +1 -1
- package/dist/components/core/list/SolidDataTable.tsx +3 -0
- package/dist/components/core/list/SolidListView.d.ts.map +1 -1
- package/dist/components/core/list/SolidListView.js +114 -57
- package/dist/components/core/list/SolidListView.js.map +1 -1
- package/dist/components/core/list/SolidListView.tsx +71 -7
- package/dist/components/core/list/SolidListViewHeaderContextMenuButton.d.ts.map +1 -1
- package/dist/components/core/list/SolidListViewHeaderContextMenuButton.js +14 -0
- package/dist/components/core/list/SolidListViewHeaderContextMenuButton.js.map +1 -1
- package/dist/components/core/list/SolidListViewHeaderContextMenuButton.tsx +13 -0
- package/dist/components/core/list/widgets/AgentProcessNeedsRestartListWidget.d.ts +3 -0
- package/dist/components/core/list/widgets/AgentProcessNeedsRestartListWidget.d.ts.map +1 -0
- package/dist/components/core/list/widgets/AgentProcessNeedsRestartListWidget.js +51 -0
- package/dist/components/core/list/widgets/AgentProcessNeedsRestartListWidget.js.map +1 -0
- package/dist/components/core/list/widgets/AgentProcessNeedsRestartListWidget.tsx +60 -0
- package/dist/components/core/list/widgets/SolidIconNameListViewWidget.d.ts +4 -0
- package/dist/components/core/list/widgets/SolidIconNameListViewWidget.d.ts.map +1 -0
- package/dist/components/core/list/widgets/SolidIconNameListViewWidget.js +24 -0
- package/dist/components/core/list/widgets/SolidIconNameListViewWidget.js.map +1 -0
- package/dist/components/core/list/widgets/SolidIconNameListViewWidget.tsx +32 -0
- package/dist/components/core/model/ModelListViewData.d.ts.map +1 -1
- package/dist/components/core/model/ModelListViewData.js +6 -23
- package/dist/components/core/model/ModelListViewData.js.map +1 -1
- package/dist/components/core/model/ModelListViewData.tsx +1 -48
- package/dist/components/core/solid-agent/AgentModelIndicator.d.ts +5 -0
- package/dist/components/core/solid-agent/AgentModelIndicator.d.ts.map +1 -0
- package/dist/components/core/solid-agent/AgentModelIndicator.js +14 -0
- package/dist/components/core/solid-agent/AgentModelIndicator.js.map +1 -0
- package/dist/components/core/solid-agent/AgentModelIndicator.tsx +40 -0
- package/dist/components/core/solid-agent/AgentSignIn.d.ts +12 -0
- package/dist/components/core/solid-agent/AgentSignIn.d.ts.map +1 -0
- package/dist/components/core/solid-agent/AgentSignIn.js +82 -0
- package/dist/components/core/solid-agent/AgentSignIn.js.map +1 -0
- package/dist/components/core/solid-agent/AgentSignIn.tsx +91 -0
- package/dist/components/core/solid-agent/SolidAgent.module.css +596 -0
- package/dist/components/core/solid-agent/SolidAgentChat.d.ts +30 -0
- package/dist/components/core/solid-agent/SolidAgentChat.d.ts.map +1 -0
- package/dist/components/core/solid-agent/SolidAgentChat.js +300 -0
- package/dist/components/core/solid-agent/SolidAgentChat.js.map +1 -0
- package/dist/components/core/solid-agent/SolidAgentChat.tsx +451 -0
- package/dist/components/core/solid-agent/SolidAgentEmbedded.d.ts +44 -0
- package/dist/components/core/solid-agent/SolidAgentEmbedded.d.ts.map +1 -0
- package/dist/components/core/solid-agent/SolidAgentEmbedded.js +46 -0
- package/dist/components/core/solid-agent/SolidAgentEmbedded.js.map +1 -0
- package/dist/components/core/solid-agent/SolidAgentEmbedded.tsx +87 -0
- package/dist/components/core/solid-agent/SolidAgentHost.d.ts +8 -0
- package/dist/components/core/solid-agent/SolidAgentHost.d.ts.map +1 -0
- package/dist/components/core/solid-agent/SolidAgentHost.js +152 -0
- package/dist/components/core/solid-agent/SolidAgentHost.js.map +1 -0
- package/dist/components/core/solid-agent/SolidAgentHost.tsx +164 -0
- package/dist/components/core/solid-agent/SolidAgentMarkdown.d.ts +16 -0
- package/dist/components/core/solid-agent/SolidAgentMarkdown.d.ts.map +1 -0
- package/dist/components/core/solid-agent/SolidAgentMarkdown.js +161 -0
- package/dist/components/core/solid-agent/SolidAgentMarkdown.js.map +1 -0
- package/dist/components/core/solid-agent/SolidAgentMarkdown.tsx +133 -0
- package/dist/components/core/solid-agent/SolidAgentMount.d.ts +3 -0
- package/dist/components/core/solid-agent/SolidAgentMount.d.ts.map +1 -0
- package/dist/components/core/solid-agent/SolidAgentMount.js +62 -0
- package/dist/components/core/solid-agent/SolidAgentMount.js.map +1 -0
- package/dist/components/core/solid-agent/SolidAgentMount.tsx +31 -0
- package/dist/components/core/solid-agent/SolidXAIIcon.d.ts +5 -0
- package/dist/components/core/solid-agent/SolidXAIIcon.d.ts.map +1 -0
- package/dist/components/core/solid-agent/SolidXAIIcon.js +7 -0
- package/dist/components/core/solid-agent/SolidXAIIcon.js.map +1 -0
- package/dist/components/core/solid-agent/SolidXAIIcon.tsx +6 -0
- package/dist/components/core/solid-agent/agentAttachments.d.ts +20 -0
- package/dist/components/core/solid-agent/agentAttachments.d.ts.map +1 -0
- package/dist/components/core/solid-agent/agentAttachments.js +184 -0
- package/dist/components/core/solid-agent/agentAttachments.js.map +1 -0
- package/dist/components/core/solid-agent/agentAttachments.ts +119 -0
- package/dist/components/core/solid-agent/agentEvents.d.ts +34 -0
- package/dist/components/core/solid-agent/agentEvents.d.ts.map +1 -0
- package/dist/components/core/solid-agent/agentEvents.js +282 -0
- package/dist/components/core/solid-agent/agentEvents.js.map +1 -0
- package/dist/components/core/solid-agent/agentEvents.ts +292 -0
- package/dist/components/core/solid-agent/agentFormat.d.ts +18 -0
- package/dist/components/core/solid-agent/agentFormat.d.ts.map +1 -0
- package/dist/components/core/solid-agent/agentFormat.js +179 -0
- package/dist/components/core/solid-agent/agentFormat.js.map +1 -0
- package/dist/components/core/solid-agent/agentFormat.ts +160 -0
- package/dist/components/core/solid-agent/client/agentAttachmentMedia.d.ts +9 -0
- package/dist/components/core/solid-agent/client/agentAttachmentMedia.d.ts.map +1 -0
- package/dist/components/core/solid-agent/client/agentAttachmentMedia.js +129 -0
- package/dist/components/core/solid-agent/client/agentAttachmentMedia.js.map +1 -0
- package/dist/components/core/solid-agent/client/agentAttachmentMedia.ts +69 -0
- package/dist/components/core/solid-agent/client/agentAuth.d.ts +63 -0
- package/dist/components/core/solid-agent/client/agentAuth.d.ts.map +1 -0
- package/dist/components/core/solid-agent/client/agentAuth.js +307 -0
- package/dist/components/core/solid-agent/client/agentAuth.js.map +1 -0
- package/dist/components/core/solid-agent/client/agentAuth.ts +222 -0
- package/dist/components/core/solid-agent/client/agentRest.d.ts +30 -0
- package/dist/components/core/solid-agent/client/agentRest.d.ts.map +1 -0
- package/dist/components/core/solid-agent/client/agentRest.js +178 -0
- package/dist/components/core/solid-agent/client/agentRest.js.map +1 -0
- package/dist/components/core/solid-agent/client/agentRest.ts +100 -0
- package/dist/components/core/solid-agent/client/agentRuntime.d.ts +48 -0
- package/dist/components/core/solid-agent/client/agentRuntime.d.ts.map +1 -0
- package/dist/components/core/solid-agent/client/agentRuntime.js +406 -0
- package/dist/components/core/solid-agent/client/agentRuntime.js.map +1 -0
- package/dist/components/core/solid-agent/client/agentRuntime.ts +226 -0
- package/dist/components/core/solid-agent/client/agentSocket.d.ts +46 -0
- package/dist/components/core/solid-agent/client/agentSocket.d.ts.map +1 -0
- package/dist/components/core/solid-agent/client/agentSocket.js +535 -0
- package/dist/components/core/solid-agent/client/agentSocket.js.map +1 -0
- package/dist/components/core/solid-agent/client/agentSocket.ts +276 -0
- package/dist/components/core/solid-agent/client/agentUrls.d.ts +11 -0
- package/dist/components/core/solid-agent/client/agentUrls.d.ts.map +1 -0
- package/dist/components/core/solid-agent/client/agentUrls.js +18 -0
- package/dist/components/core/solid-agent/client/agentUrls.js.map +1 -0
- package/dist/components/core/solid-agent/client/agentUrls.ts +19 -0
- package/dist/components/core/solid-agent/composer/AgentComposer.d.ts +21 -0
- package/dist/components/core/solid-agent/composer/AgentComposer.d.ts.map +1 -0
- package/dist/components/core/solid-agent/composer/AgentComposer.js +219 -0
- package/dist/components/core/solid-agent/composer/AgentComposer.js.map +1 -0
- package/dist/components/core/solid-agent/composer/AgentComposer.tsx +241 -0
- package/dist/components/core/solid-agent/embed/AgentEmbeddingPanel.d.ts +8 -0
- package/dist/components/core/solid-agent/embed/AgentEmbeddingPanel.d.ts.map +1 -0
- package/dist/components/core/solid-agent/embed/AgentEmbeddingPanel.js +87 -0
- package/dist/components/core/solid-agent/embed/AgentEmbeddingPanel.js.map +1 -0
- package/dist/components/core/solid-agent/embed/AgentEmbeddingPanel.tsx +58 -0
- package/dist/components/core/solid-agent/embed/agentEmbedProtocol.d.ts +20 -0
- package/dist/components/core/solid-agent/embed/agentEmbedProtocol.d.ts.map +1 -0
- package/dist/components/core/solid-agent/embed/agentEmbedProtocol.js +103 -0
- package/dist/components/core/solid-agent/embed/agentEmbedProtocol.js.map +1 -0
- package/dist/components/core/solid-agent/embed/agentEmbedProtocol.ts +60 -0
- package/dist/components/core/solid-agent/embed/agentEmbedSamples.d.ts +11 -0
- package/dist/components/core/solid-agent/embed/agentEmbedSamples.d.ts.map +1 -0
- package/dist/components/core/solid-agent/embed/agentEmbedSamples.js +21 -0
- package/dist/components/core/solid-agent/embed/agentEmbedSamples.js.map +1 -0
- package/dist/components/core/solid-agent/embed/agentEmbedSamples.ts +266 -0
- package/dist/components/core/solid-agent/processes/agentHubProcessApi.d.ts +15 -0
- package/dist/components/core/solid-agent/processes/agentHubProcessApi.d.ts.map +1 -0
- package/dist/components/core/solid-agent/processes/agentHubProcessApi.js +122 -0
- package/dist/components/core/solid-agent/processes/agentHubProcessApi.js.map +1 -0
- package/dist/components/core/solid-agent/processes/agentHubProcessApi.ts +64 -0
- package/dist/components/core/solid-agent/sdk/solidAgent.d.ts +39 -0
- package/dist/components/core/solid-agent/sdk/solidAgent.d.ts.map +1 -0
- package/dist/components/core/solid-agent/sdk/solidAgent.js +44 -0
- package/dist/components/core/solid-agent/sdk/solidAgent.js.map +1 -0
- package/dist/components/core/solid-agent/sdk/solidAgent.ts +56 -0
- package/dist/components/core/solid-agent/thread/AgentThread.d.ts +17 -0
- package/dist/components/core/solid-agent/thread/AgentThread.d.ts.map +1 -0
- package/dist/components/core/solid-agent/thread/AgentThread.js +166 -0
- package/dist/components/core/solid-agent/thread/AgentThread.js.map +1 -0
- package/dist/components/core/solid-agent/thread/AgentThread.tsx +248 -0
- package/dist/components/core/solid-agent/thread/SolidAgentChatItem.d.ts +36 -0
- package/dist/components/core/solid-agent/thread/SolidAgentChatItem.d.ts.map +1 -0
- package/dist/components/core/solid-agent/thread/SolidAgentChatItem.js +148 -0
- package/dist/components/core/solid-agent/thread/SolidAgentChatItem.js.map +1 -0
- package/dist/components/core/solid-agent/thread/SolidAgentChatItem.tsx +116 -0
- package/dist/components/core/solid-agent/thread/inlineWidget.d.ts +8 -0
- package/dist/components/core/solid-agent/thread/inlineWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/thread/inlineWidget.js +30 -0
- package/dist/components/core/solid-agent/thread/inlineWidget.js.map +1 -0
- package/dist/components/core/solid-agent/thread/inlineWidget.ts +27 -0
- package/dist/components/core/solid-agent/types.d.ts +155 -0
- package/dist/components/core/solid-agent/types.d.ts.map +1 -0
- package/dist/components/core/solid-agent/types.js +31 -0
- package/dist/components/core/solid-agent/types.js.map +1 -0
- package/dist/components/core/solid-agent/types.ts +148 -0
- package/dist/components/core/solid-agent/useAdminInputContext.d.ts +4 -0
- package/dist/components/core/solid-agent/useAdminInputContext.d.ts.map +1 -0
- package/dist/components/core/solid-agent/useAdminInputContext.js +49 -0
- package/dist/components/core/solid-agent/useAdminInputContext.js.map +1 -0
- package/dist/components/core/solid-agent/useAdminInputContext.ts +52 -0
- package/dist/components/core/solid-agent/useAgentAuth.d.ts +14 -0
- package/dist/components/core/solid-agent/useAgentAuth.d.ts.map +1 -0
- package/dist/components/core/solid-agent/useAgentAuth.js +88 -0
- package/dist/components/core/solid-agent/useAgentAuth.js.map +1 -0
- package/dist/components/core/solid-agent/useAgentAuth.ts +40 -0
- package/dist/components/core/solid-agent/useAgentAvailability.d.ts +19 -0
- package/dist/components/core/solid-agent/useAgentAvailability.d.ts.map +1 -0
- package/dist/components/core/solid-agent/useAgentAvailability.js +109 -0
- package/dist/components/core/solid-agent/useAgentAvailability.js.map +1 -0
- package/dist/components/core/solid-agent/useAgentAvailability.ts +80 -0
- package/dist/components/core/solid-agent/useAgentChat.d.ts +22 -0
- package/dist/components/core/solid-agent/useAgentChat.d.ts.map +1 -0
- package/dist/components/core/solid-agent/useAgentChat.js +45 -0
- package/dist/components/core/solid-agent/useAgentChat.js.map +1 -0
- package/dist/components/core/solid-agent/useAgentChat.ts +57 -0
- package/dist/components/core/solid-agent/widgets/DefaultAssistantMessageChatWidget.d.ts +7 -0
- package/dist/components/core/solid-agent/widgets/DefaultAssistantMessageChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/DefaultAssistantMessageChatWidget.js +15 -0
- package/dist/components/core/solid-agent/widgets/DefaultAssistantMessageChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/DefaultAssistantMessageChatWidget.tsx +24 -0
- package/dist/components/core/solid-agent/widgets/DefaultErrorChatWidget.d.ts +7 -0
- package/dist/components/core/solid-agent/widgets/DefaultErrorChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/DefaultErrorChatWidget.js +15 -0
- package/dist/components/core/solid-agent/widgets/DefaultErrorChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/DefaultErrorChatWidget.tsx +28 -0
- package/dist/components/core/solid-agent/widgets/DefaultNoticeChatWidget.d.ts +4 -0
- package/dist/components/core/solid-agent/widgets/DefaultNoticeChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/DefaultNoticeChatWidget.js +20 -0
- package/dist/components/core/solid-agent/widgets/DefaultNoticeChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/DefaultNoticeChatWidget.tsx +8 -0
- package/dist/components/core/solid-agent/widgets/DefaultThinkingChatWidget.d.ts +7 -0
- package/dist/components/core/solid-agent/widgets/DefaultThinkingChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/DefaultThinkingChatWidget.js +11 -0
- package/dist/components/core/solid-agent/widgets/DefaultThinkingChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/DefaultThinkingChatWidget.tsx +16 -0
- package/dist/components/core/solid-agent/widgets/DefaultToolCallChatWidget.d.ts +7 -0
- package/dist/components/core/solid-agent/widgets/DefaultToolCallChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/DefaultToolCallChatWidget.js +67 -0
- package/dist/components/core/solid-agent/widgets/DefaultToolCallChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/DefaultToolCallChatWidget.tsx +135 -0
- package/dist/components/core/solid-agent/widgets/DefaultUnknownChatWidget.d.ts +7 -0
- package/dist/components/core/solid-agent/widgets/DefaultUnknownChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/DefaultUnknownChatWidget.js +24 -0
- package/dist/components/core/solid-agent/widgets/DefaultUnknownChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/DefaultUnknownChatWidget.tsx +17 -0
- package/dist/components/core/solid-agent/widgets/DefaultUserMessageChatWidget.d.ts +8 -0
- package/dist/components/core/solid-agent/widgets/DefaultUserMessageChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/DefaultUserMessageChatWidget.js +30 -0
- package/dist/components/core/solid-agent/widgets/DefaultUserMessageChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/DefaultUserMessageChatWidget.tsx +77 -0
- package/dist/components/core/solid-agent/widgets/SolidChecklistChatWidget.d.ts +7 -0
- package/dist/components/core/solid-agent/widgets/SolidChecklistChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidChecklistChatWidget.js +40 -0
- package/dist/components/core/solid-agent/widgets/SolidChecklistChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidChecklistChatWidget.tsx +57 -0
- package/dist/components/core/solid-agent/widgets/SolidCodeChatWidget.d.ts +4 -0
- package/dist/components/core/solid-agent/widgets/SolidCodeChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidCodeChatWidget.js +13 -0
- package/dist/components/core/solid-agent/widgets/SolidCodeChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidCodeChatWidget.tsx +19 -0
- package/dist/components/core/solid-agent/widgets/SolidDiffListChatWidget.d.ts +7 -0
- package/dist/components/core/solid-agent/widgets/SolidDiffListChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidDiffListChatWidget.js +55 -0
- package/dist/components/core/solid-agent/widgets/SolidDiffListChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidDiffListChatWidget.tsx +81 -0
- package/dist/components/core/solid-agent/widgets/SolidGalleryChatWidget.d.ts +4 -0
- package/dist/components/core/solid-agent/widgets/SolidGalleryChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidGalleryChatWidget.js +15 -0
- package/dist/components/core/solid-agent/widgets/SolidGalleryChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidGalleryChatWidget.tsx +30 -0
- package/dist/components/core/solid-agent/widgets/SolidJsonChatWidget.d.ts +4 -0
- package/dist/components/core/solid-agent/widgets/SolidJsonChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidJsonChatWidget.js +15 -0
- package/dist/components/core/solid-agent/widgets/SolidJsonChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidJsonChatWidget.tsx +21 -0
- package/dist/components/core/solid-agent/widgets/SolidLinkCardChatWidget.d.ts +7 -0
- package/dist/components/core/solid-agent/widgets/SolidLinkCardChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidLinkCardChatWidget.js +21 -0
- package/dist/components/core/solid-agent/widgets/SolidLinkCardChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidLinkCardChatWidget.tsx +33 -0
- package/dist/components/core/solid-agent/widgets/SolidMarkdownChatWidget.d.ts +4 -0
- package/dist/components/core/solid-agent/widgets/SolidMarkdownChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidMarkdownChatWidget.js +11 -0
- package/dist/components/core/solid-agent/widgets/SolidMarkdownChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidMarkdownChatWidget.tsx +9 -0
- package/dist/components/core/solid-agent/widgets/SolidProgressChatWidget.d.ts +15 -0
- package/dist/components/core/solid-agent/widgets/SolidProgressChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidProgressChatWidget.js +26 -0
- package/dist/components/core/solid-agent/widgets/SolidProgressChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidProgressChatWidget.tsx +42 -0
- package/dist/components/core/solid-agent/widgets/SolidQuestionChatWidget.d.ts +7 -0
- package/dist/components/core/solid-agent/widgets/SolidQuestionChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidQuestionChatWidget.js +41 -0
- package/dist/components/core/solid-agent/widgets/SolidQuestionChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidQuestionChatWidget.tsx +69 -0
- package/dist/components/core/solid-agent/widgets/SolidStatusChatWidget.d.ts +7 -0
- package/dist/components/core/solid-agent/widgets/SolidStatusChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidStatusChatWidget.js +23 -0
- package/dist/components/core/solid-agent/widgets/SolidStatusChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidStatusChatWidget.tsx +40 -0
- package/dist/components/core/solid-agent/widgets/SolidTableChatWidget.d.ts +4 -0
- package/dist/components/core/solid-agent/widgets/SolidTableChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidTableChatWidget.js +32 -0
- package/dist/components/core/solid-agent/widgets/SolidTableChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidTableChatWidget.tsx +55 -0
- package/dist/components/core/solid-agent/widgets/SolidToolActivityChatWidget.d.ts +7 -0
- package/dist/components/core/solid-agent/widgets/SolidToolActivityChatWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidToolActivityChatWidget.js +17 -0
- package/dist/components/core/solid-agent/widgets/SolidToolActivityChatWidget.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/SolidToolActivityChatWidget.tsx +31 -0
- package/dist/components/core/solid-agent/widgets/chatWidgetUtils.d.ts +12 -0
- package/dist/components/core/solid-agent/widgets/chatWidgetUtils.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/chatWidgetUtils.js +17 -0
- package/dist/components/core/solid-agent/widgets/chatWidgetUtils.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/chatWidgetUtils.ts +19 -0
- package/dist/components/core/solid-agent/widgets/solidChatWidgets.module.css +909 -0
- package/dist/components/core/solid-ai/SolidAiChat.js +1 -1
- package/dist/components/core/solid-ai/SolidAiChat.js.map +1 -1
- package/dist/components/core/solid-ai/SolidAiChat.tsx +2 -2
- package/dist/components/layout/AdminLayout.d.ts.map +1 -1
- package/dist/components/layout/AdminLayout.js +2 -1
- package/dist/components/layout/AdminLayout.js.map +1 -1
- package/dist/components/layout/AdminLayout.tsx +2 -0
- package/dist/components/shad-cn-ui/SolidAutocomplete.d.ts.map +1 -1
- package/dist/components/shad-cn-ui/SolidAutocomplete.js +2 -2
- package/dist/components/shad-cn-ui/SolidAutocomplete.js.map +1 -1
- package/dist/components/shad-cn-ui/SolidAutocomplete.tsx +19 -15
- package/dist/components/shad-cn-ui/SolidDialog.d.ts +2 -1
- package/dist/components/shad-cn-ui/SolidDialog.d.ts.map +1 -1
- package/dist/components/shad-cn-ui/SolidDialog.js +2 -2
- package/dist/components/shad-cn-ui/SolidDialog.js.map +1 -1
- package/dist/components/shad-cn-ui/SolidDialog.tsx +3 -0
- package/dist/components/shad-cn-ui/SolidIconPicker.d.ts +7 -0
- package/dist/components/shad-cn-ui/SolidIconPicker.d.ts.map +1 -0
- package/dist/components/shad-cn-ui/SolidIconPicker.js +43 -0
- package/dist/components/shad-cn-ui/SolidIconPicker.js.map +1 -0
- package/dist/components/shad-cn-ui/SolidIconPicker.tsx +73 -0
- package/dist/components/shad-cn-ui/index.d.ts +1 -0
- package/dist/components/shad-cn-ui/index.d.ts.map +1 -1
- package/dist/components/shad-cn-ui/index.js +1 -0
- package/dist/components/shad-cn-ui/index.js.map +1 -1
- package/dist/components/shad-cn-ui/index.ts +1 -0
- package/dist/constants/allowed-ai-models.d.ts +8 -0
- package/dist/constants/allowed-ai-models.d.ts.map +1 -0
- package/dist/constants/allowed-ai-models.js +33 -0
- package/dist/constants/allowed-ai-models.js.map +1 -0
- package/dist/constants/allowed-ai-models.ts +39 -0
- package/dist/helpers/hydrateRelationRules.d.ts.map +1 -1
- package/dist/helpers/hydrateRelationRules.js +3 -1
- package/dist/helpers/hydrateRelationRules.js.map +1 -1
- package/dist/helpers/hydrateRelationRules.ts +5 -1
- package/dist/helpers/registry.d.ts +4 -2
- package/dist/helpers/registry.d.ts.map +1 -1
- package/dist/helpers/registry.js +75 -12
- package/dist/helpers/registry.js.map +1 -1
- package/dist/helpers/registry.ts +73 -16
- package/dist/helpers/updatePasswordField.d.ts.map +1 -1
- package/dist/helpers/updatePasswordField.js +21 -15
- package/dist/helpers/updatePasswordField.js.map +1 -1
- package/dist/helpers/updatePasswordField.ts +6 -1
- package/dist/index.d.ts +21 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/dist/index.ts +34 -3
- package/dist/redux/api/fieldApi.js +1 -1
- package/dist/redux/api/fieldApi.js.map +1 -1
- package/dist/redux/api/fieldApi.ts +2 -2
- package/dist/redux/api/modelApi.d.ts +13 -13
- package/dist/redux/api/modelApi.d.ts.map +1 -1
- package/dist/redux/api/modelApi.js +15 -15
- package/dist/redux/api/modelApi.js.map +1 -1
- package/dist/redux/api/modelApi.ts +12 -15
- package/dist/redux/features/agentSlice.d.ts +34 -0
- package/dist/redux/features/agentSlice.d.ts.map +1 -0
- package/dist/redux/features/agentSlice.js +92 -0
- package/dist/redux/features/agentSlice.js.map +1 -0
- package/dist/redux/features/agentSlice.ts +119 -0
- package/dist/redux/store/defaultStoreConfig.d.ts +11 -10
- package/dist/redux/store/defaultStoreConfig.d.ts.map +1 -1
- package/dist/redux/store/defaultStoreConfig.js +2 -0
- package/dist/redux/store/defaultStoreConfig.js.map +1 -1
- package/dist/redux/store/defaultStoreConfig.ts +2 -0
- package/dist/redux/store/solidEntityApiPool.d.ts.map +1 -1
- package/dist/redux/store/solidEntityApiPool.js +7 -0
- package/dist/redux/store/solidEntityApiPool.js.map +1 -1
- package/dist/redux/store/solidEntityApiPool.ts +6 -0
- package/dist/resources/globals.css +109 -1
- package/dist/resources/solid-custom.css +295 -0
- package/dist/resources/solid-tailwind-generated.css +1 -1
- package/dist/routes/pages/admin/core/AgentRegistryAuditPanel.css +47 -0
- package/dist/routes/pages/admin/core/AgentRegistryAuditPanel.d.ts +12 -0
- package/dist/routes/pages/admin/core/AgentRegistryAuditPanel.d.ts.map +1 -0
- package/dist/routes/pages/admin/core/AgentRegistryAuditPanel.js +80 -0
- package/dist/routes/pages/admin/core/AgentRegistryAuditPanel.js.map +1 -0
- package/dist/routes/pages/admin/core/AgentRegistryAuditPanel.tsx +123 -0
- package/dist/routes/pages/admin/core/AgentRegistryEditorPage.css +110 -0
- package/dist/routes/pages/admin/core/AgentRegistryEditorPage.d.ts +3 -0
- package/dist/routes/pages/admin/core/AgentRegistryEditorPage.d.ts.map +1 -0
- package/dist/routes/pages/admin/core/AgentRegistryEditorPage.js +702 -0
- package/dist/routes/pages/admin/core/AgentRegistryEditorPage.js.map +1 -0
- package/dist/routes/pages/admin/core/AgentRegistryEditorPage.tsx +630 -0
- package/dist/routes/pages/admin/core/AgentSkillRegistryEditorPage.css +303 -0
- package/dist/routes/pages/admin/core/AgentSkillRegistryEditorPage.d.ts +3 -0
- package/dist/routes/pages/admin/core/AgentSkillRegistryEditorPage.d.ts.map +1 -0
- package/dist/routes/pages/admin/core/AgentSkillRegistryEditorPage.js +330 -0
- package/dist/routes/pages/admin/core/AgentSkillRegistryEditorPage.js.map +1 -0
- package/dist/routes/pages/admin/core/AgentSkillRegistryEditorPage.tsx +460 -0
- package/dist/routes/pages/admin/core/AgentToolRegistryEditorPage.css +125 -0
- package/dist/routes/pages/admin/core/AgentToolRegistryEditorPage.d.ts +3 -0
- package/dist/routes/pages/admin/core/AgentToolRegistryEditorPage.d.ts.map +1 -0
- package/dist/routes/pages/admin/core/AgentToolRegistryEditorPage.js +295 -0
- package/dist/routes/pages/admin/core/AgentToolRegistryEditorPage.js.map +1 -0
- package/dist/routes/pages/admin/core/AgentToolRegistryEditorPage.tsx +275 -0
- package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.js +11 -11
- package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.js.map +1 -1
- package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.tsx +15 -15
- package/dist/routes/pages/embed/AgentEmbedPage.d.ts +3 -0
- package/dist/routes/pages/embed/AgentEmbedPage.d.ts.map +1 -0
- package/dist/routes/pages/embed/AgentEmbedPage.js +170 -0
- package/dist/routes/pages/embed/AgentEmbedPage.js.map +1 -0
- package/dist/routes/pages/embed/AgentEmbedPage.module.css +195 -0
- package/dist/routes/pages/embed/AgentEmbedPage.tsx +169 -0
- package/dist/routes/solidRoutes.d.ts.map +1 -1
- package/dist/routes/solidRoutes.js +8 -0
- package/dist/routes/solidRoutes.js.map +1 -1
- package/dist/routes/solidRoutes.tsx +8 -0
- package/dist/types/extension-registry.d.ts +4 -0
- package/dist/types/extension-registry.d.ts.map +1 -1
- package/dist/types/extension-registry.js +7 -0
- package/dist/types/extension-registry.js.map +1 -1
- package/dist/types/extension-registry.ts +7 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/list-row-action.d.ts +2 -0
- package/dist/types/list-row-action.d.ts.map +1 -1
- package/dist/types/list-row-action.js.map +1 -1
- package/dist/types/list-row-action.ts +3 -0
- package/dist/types/solid-core.d.ts +36 -0
- package/package.json +1 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import ReactMarkdown from "react-markdown";
|
|
3
|
+
import remarkGfm from "remark-gfm";
|
|
4
|
+
import { Check, Copy } from "lucide-react";
|
|
5
|
+
import styles from "./SolidAgent.module.css";
|
|
6
|
+
import widgetStyles from "./widgets/solidChatWidgets.module.css";
|
|
7
|
+
|
|
8
|
+
/** Only http(s), mailto and in-app paths are followed; anything else (javascript:, data:) is dropped. */
|
|
9
|
+
export function safeHref(href?: string): string | undefined {
|
|
10
|
+
if (!href) return undefined;
|
|
11
|
+
if (/^(https?:|mailto:)/i.test(href) || href.startsWith("/") || href.startsWith("#")) return href;
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function copyText(text: string, done: () => void) {
|
|
16
|
+
try {
|
|
17
|
+
await navigator.clipboard.writeText(text);
|
|
18
|
+
done();
|
|
19
|
+
} catch {
|
|
20
|
+
// Clipboard blocked; the text stays selectable.
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Icon-only copy button (toolbar style), used by the code / diff widgets. */
|
|
25
|
+
export function SolidAgentCopyButton({ text, label }: { text: string; label?: string }) {
|
|
26
|
+
const [copied, setCopied] = useState(false);
|
|
27
|
+
return (
|
|
28
|
+
<button
|
|
29
|
+
type="button"
|
|
30
|
+
className={styles.iconBtn}
|
|
31
|
+
aria-label={label ?? "Copy"}
|
|
32
|
+
title={copied ? "Copied" : label ?? "Copy"}
|
|
33
|
+
onClick={(event) => {
|
|
34
|
+
event.stopPropagation();
|
|
35
|
+
void copyText(text, () => {
|
|
36
|
+
setCopied(true);
|
|
37
|
+
setTimeout(() => setCopied(false), 1600);
|
|
38
|
+
});
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
{copied ? <Check size={14} /> : <Copy size={14} />}
|
|
42
|
+
</button>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Small copy button shown under a message bubble on hover. */
|
|
47
|
+
export function SolidAgentMessageCopyButton({ text }: { text: string }) {
|
|
48
|
+
const [copied, setCopied] = useState(false);
|
|
49
|
+
return (
|
|
50
|
+
<button
|
|
51
|
+
type="button"
|
|
52
|
+
className={widgetStyles.CopyBtn}
|
|
53
|
+
title="Copy"
|
|
54
|
+
aria-label="Copy message"
|
|
55
|
+
onClick={(event) => {
|
|
56
|
+
event.stopPropagation();
|
|
57
|
+
void copyText(text, () => {
|
|
58
|
+
setCopied(true);
|
|
59
|
+
setTimeout(() => setCopied(false), 2000);
|
|
60
|
+
});
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{copied ? <Check size={11} /> : <Copy size={11} />}
|
|
64
|
+
</button>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function CodeBlock({ className, children }: { className?: string; children?: React.ReactNode }) {
|
|
69
|
+
const [copied, setCopied] = useState(false);
|
|
70
|
+
const code = String(children ?? "").replace(/\n$/, "");
|
|
71
|
+
const lang = className?.replace("language-", "") ?? "";
|
|
72
|
+
return (
|
|
73
|
+
<div className={widgetStyles.CodeBlockWrapper}>
|
|
74
|
+
<div className={widgetStyles.CodeBlockHeader}>
|
|
75
|
+
<span className={widgetStyles.CodeLang}>{lang || "code"}</span>
|
|
76
|
+
<button
|
|
77
|
+
type="button"
|
|
78
|
+
className={widgetStyles.CodeCopyBtn}
|
|
79
|
+
onClick={() =>
|
|
80
|
+
void copyText(code, () => {
|
|
81
|
+
setCopied(true);
|
|
82
|
+
setTimeout(() => setCopied(false), 2000);
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
>
|
|
86
|
+
{copied ? <Check size={11} /> : <Copy size={11} />}
|
|
87
|
+
{copied ? "Copied" : "Copy"}
|
|
88
|
+
</button>
|
|
89
|
+
</div>
|
|
90
|
+
<pre className={widgetStyles.CodePre}><code>{code}</code></pre>
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const markdownComponents = {
|
|
96
|
+
code({ className, children, ...rest }: any) {
|
|
97
|
+
// Only named fenced blocks (```lang) become a code block; everything else is inline code.
|
|
98
|
+
if (!/language-/.test(className || "")) return <code className={widgetStyles.InlineCode} {...rest}>{children}</code>;
|
|
99
|
+
return <CodeBlock className={className}>{children}</CodeBlock>;
|
|
100
|
+
},
|
|
101
|
+
pre({ children }: any) {
|
|
102
|
+
return <>{children}</>;
|
|
103
|
+
},
|
|
104
|
+
table({ children }: any) {
|
|
105
|
+
return <div className={widgetStyles.MarkdownTableWrapper}><table>{children}</table></div>;
|
|
106
|
+
},
|
|
107
|
+
a({ href, children }: any) {
|
|
108
|
+
const safe = safeHref(href);
|
|
109
|
+
if (!safe) return <span>{children}</span>;
|
|
110
|
+
const external = /^https?:/i.test(safe);
|
|
111
|
+
return (
|
|
112
|
+
<a
|
|
113
|
+
href={safe}
|
|
114
|
+
className={widgetStyles.MarkdownLink}
|
|
115
|
+
target={external ? "_blank" : undefined}
|
|
116
|
+
rel={external ? "noopener noreferrer" : undefined}
|
|
117
|
+
>
|
|
118
|
+
{children}
|
|
119
|
+
</a>
|
|
120
|
+
);
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/** Markdown for agent text. Raw HTML in the source is never rendered (react-markdown default). */
|
|
125
|
+
export function SolidAgentMarkdown({ text }: { text: string }) {
|
|
126
|
+
return (
|
|
127
|
+
<div className={widgetStyles.MarkdownRoot}>
|
|
128
|
+
<ReactMarkdown remarkPlugins={[remarkGfm]} components={markdownComponents}>
|
|
129
|
+
{text}
|
|
130
|
+
</ReactMarkdown>
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolidAgentMount.d.ts","sourceRoot":"","sources":["../../../../src/components/core/solid-agent/SolidAgentMount.tsx"],"names":[],"mappings":"AAqBA,iGAAiG;AACjG,wBAAgB,eAAe,4CAQ9B"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
import React, { Suspense } from "react";
|
|
18
|
+
var SolidAgentHost = React.lazy(function () { return import("./SolidAgentHost"); });
|
|
19
|
+
/** If the agent UI fails (render error or chunk load), hide it and leave the admin app untouched. */
|
|
20
|
+
var AgentHostBoundary = /** @class */ (function (_super) {
|
|
21
|
+
__extends(AgentHostBoundary, _super);
|
|
22
|
+
function AgentHostBoundary() {
|
|
23
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
Object.defineProperty(_this, "state", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: { failed: false }
|
|
29
|
+
});
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
Object.defineProperty(AgentHostBoundary, "getDerivedStateFromError", {
|
|
33
|
+
enumerable: false,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: function () {
|
|
37
|
+
return { failed: true };
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(AgentHostBoundary.prototype, "componentDidCatch", {
|
|
41
|
+
enumerable: false,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true,
|
|
44
|
+
value: function (error) {
|
|
45
|
+
console.error("[solidAgent] the agent launcher failed and was hidden", error);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(AgentHostBoundary.prototype, "render", {
|
|
49
|
+
enumerable: false,
|
|
50
|
+
configurable: true,
|
|
51
|
+
writable: true,
|
|
52
|
+
value: function () {
|
|
53
|
+
return this.state.failed ? null : this.props.children;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return AgentHostBoundary;
|
|
57
|
+
}(React.Component));
|
|
58
|
+
/** Lazy, isolated mount point for the SolidX Agent launcher. Render once in the admin layout. */
|
|
59
|
+
export function SolidAgentMount() {
|
|
60
|
+
return (_jsx(AgentHostBoundary, { children: _jsx(Suspense, { fallback: null, children: _jsx(SolidAgentHost, {}) }) }));
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=SolidAgentMount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolidAgentMount.js","sourceRoot":"","sources":["../../../../src/components/core/solid-agent/SolidAgentMount.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExC,IAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,cAAM,OAAA,MAAM,CAAC,kBAAkB,CAAC,EAA1B,CAA0B,CAAC,CAAC;AAEpE,qGAAqG;AACrG;IAAgC,qCAAmE;IAAnG;QAAA,qEAcC;QAbG;;;;mBAAQ,EAAE,MAAM,EAAE,KAAK,EAAE;WAAC;;IAa9B,CAAC;;;;;eAXG;YACI,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QAC5B,CAAC;;;;;;eAED,UAAkB,KAAY;YAC1B,OAAO,CAAC,KAAK,CAAC,uDAAuD,EAAE,KAAK,CAAC,CAAC;QAClF,CAAC;;;;;;eAED;YACI,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC1D,CAAC;;IACL,wBAAC;AAAD,CAAC,AAdD,CAAgC,KAAK,CAAC,SAAS,GAc9C;AAED,iGAAiG;AACjG,MAAM,UAAU,eAAe;IAC3B,OAAO,CACH,KAAC,iBAAiB,cACd,KAAC,QAAQ,IAAC,QAAQ,EAAE,IAAI,YACpB,KAAC,cAAc,KAAG,GACX,GACK,CACvB,CAAC;AACN,CAAC","sourcesContent":["import React, { Suspense } from \"react\";\n\nconst SolidAgentHost = React.lazy(() => import(\"./SolidAgentHost\"));\n\n/** If the agent UI fails (render error or chunk load), hide it and leave the admin app untouched. */\nclass AgentHostBoundary extends React.Component<{ children: React.ReactNode }, { failed: boolean }> {\n state = { failed: false };\n\n static getDerivedStateFromError() {\n return { failed: true };\n }\n\n componentDidCatch(error: Error) {\n console.error(\"[solidAgent] the agent launcher failed and was hidden\", error);\n }\n\n render() {\n return this.state.failed ? null : this.props.children;\n }\n}\n\n/** Lazy, isolated mount point for the SolidX Agent launcher. Render once in the admin layout. */\nexport function SolidAgentMount() {\n return (\n <AgentHostBoundary>\n <Suspense fallback={null}>\n <SolidAgentHost />\n </Suspense>\n </AgentHostBoundary>\n );\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { Suspense } from "react";
|
|
2
|
+
|
|
3
|
+
const SolidAgentHost = React.lazy(() => import("./SolidAgentHost"));
|
|
4
|
+
|
|
5
|
+
/** If the agent UI fails (render error or chunk load), hide it and leave the admin app untouched. */
|
|
6
|
+
class AgentHostBoundary extends React.Component<{ children: React.ReactNode }, { failed: boolean }> {
|
|
7
|
+
state = { failed: false };
|
|
8
|
+
|
|
9
|
+
static getDerivedStateFromError() {
|
|
10
|
+
return { failed: true };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
componentDidCatch(error: Error) {
|
|
14
|
+
console.error("[solidAgent] the agent launcher failed and was hidden", error);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
render() {
|
|
18
|
+
return this.state.failed ? null : this.props.children;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Lazy, isolated mount point for the SolidX Agent launcher. Render once in the admin layout. */
|
|
23
|
+
export function SolidAgentMount() {
|
|
24
|
+
return (
|
|
25
|
+
<AgentHostBoundary>
|
|
26
|
+
<Suspense fallback={null}>
|
|
27
|
+
<SolidAgentHost />
|
|
28
|
+
</Suspense>
|
|
29
|
+
</AgentHostBoundary>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolidXAIIcon.d.ts","sourceRoot":"","sources":["../../../../src/components/core/solid-agent/SolidXAIIcon.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,eAAO,MAAM,YAAY;;6CAIxB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/** The SolidX agent mark (same glyph as the SolidX agent-ui). Uses currentColor. */
|
|
3
|
+
export var SolidXAIIcon = function (_a) {
|
|
4
|
+
var _b = _a.size, size = _b === void 0 ? 16 : _b;
|
|
5
|
+
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 309.6 300.99", fill: "currentColor", "aria-hidden": "true", children: _jsx("path", { d: "M192.59,156.74l-.06.06-.18-.18-.04-.05.05-.05.04.04.19.18,94.92-98.27c10.7-10.96,10.49-28.52-.47-39.22L267.32,0l-114.34,117.15-.1.11L36.01,2.42l-19.31,19.66c-10.73,10.93-10.58,28.48.35,39.22l97.21,95.5L0,273.86l19.72,19.25c10.96,10.69,28.52,10.48,39.21-.48l94.19-96.48,101.72,97.82c8.9,8.72,23.19,8.57,31.9-.33l22.86-23.34-117.01-113.56ZM186.84,160.69l-28.53,29.23c-2.5,2.56-6.6,2.61-9.16.11l-29.23-28.53c-2.56-2.5-2.61-6.59-.11-9.15l28.53-29.23c2.5-2.56,6.6-2.61,9.16-.11l29.23,28.53c2.56,2.5,2.61,6.6.11,9.15Z" }) }));
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=SolidXAIIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolidXAIIcon.js","sourceRoot":"","sources":["../../../../src/components/core/solid-agent/SolidXAIIcon.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,MAAM,CAAC,IAAM,YAAY,GAAG,UAAC,EAAgC;QAA9B,YAAS,EAAT,IAAI,mBAAG,EAAE,KAAA;IAA0B,OAAA,CAC9D,cAAK,KAAK,EAAC,4BAA4B,EAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAC,kBAAkB,EAAC,IAAI,EAAC,cAAc,iBAAa,MAAM,YAChI,eAAM,CAAC,EAAC,igBAAigB,GAAG,GAC1gB,CACT;AAJiE,CAIjE,CAAC","sourcesContent":["/** The SolidX agent mark (same glyph as the SolidX agent-ui). Uses currentColor. */\nexport const SolidXAIIcon = ({ size = 16 }: { size?: number }) => (\n <svg xmlns=\"http://www.w3.org/2000/svg\" width={size} height={size} viewBox=\"0 0 309.6 300.99\" fill=\"currentColor\" aria-hidden=\"true\">\n <path d=\"M192.59,156.74l-.06.06-.18-.18-.04-.05.05-.05.04.04.19.18,94.92-98.27c10.7-10.96,10.49-28.52-.47-39.22L267.32,0l-114.34,117.15-.1.11L36.01,2.42l-19.31,19.66c-10.73,10.93-10.58,28.48.35,39.22l97.21,95.5L0,273.86l19.72,19.25c10.96,10.69,28.52,10.48,39.21-.48l94.19-96.48,101.72,97.82c8.9,8.72,23.19,8.57,31.9-.33l22.86-23.34-117.01-113.56ZM186.84,160.69l-28.53,29.23c-2.5,2.56-6.6,2.61-9.16.11l-29.23-28.53c-2.56-2.5-2.61-6.59-.11-9.15l28.53-29.23c2.5-2.56,6.6-2.61,9.16-.11l29.23,28.53c2.56,2.5,2.61,6.6.11,9.15Z\" />\n </svg>\n);\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** The SolidX agent mark (same glyph as the SolidX agent-ui). Uses currentColor. */
|
|
2
|
+
export const SolidXAIIcon = ({ size = 16 }: { size?: number }) => (
|
|
3
|
+
<svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 309.6 300.99" fill="currentColor" aria-hidden="true">
|
|
4
|
+
<path d="M192.59,156.74l-.06.06-.18-.18-.04-.05.05-.05.04.04.19.18,94.92-98.27c10.7-10.96,10.49-28.52-.47-39.22L267.32,0l-114.34,117.15-.1.11L36.01,2.42l-19.31,19.66c-10.73,10.93-10.58,28.48.35,39.22l97.21,95.5L0,273.86l19.72,19.25c10.96,10.69,28.52,10.48,39.21-.48l94.19-96.48,101.72,97.82c8.9,8.72,23.19,8.57,31.9-.33l22.86-23.34-117.01-113.56ZM186.84,160.69l-28.53,29.23c-2.5,2.56-6.6,2.61-9.16.11l-29.23-28.53c-2.56-2.5-2.61-6.59-.11-9.15l28.53-29.23c2.5-2.56,6.6-2.61,9.16-.11l29.23,28.53c2.56,2.5,2.61,6.6.11,9.15Z" />
|
|
5
|
+
</svg>
|
|
6
|
+
);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AgentAttachment } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Reading chat attachments in the browser. Limits match the agent (server/attachments.py)
|
|
4
|
+
* so problems are reported before sending.
|
|
5
|
+
*/
|
|
6
|
+
export declare const MAX_AGENT_ATTACHMENTS = 5;
|
|
7
|
+
export declare const MAX_AGENT_ATTACHMENT_BYTES: number;
|
|
8
|
+
export declare const MAX_AGENT_ATTACHMENTS_TOTAL_BYTES: number;
|
|
9
|
+
/** Value for the file input's `accept` attribute. */
|
|
10
|
+
export declare const AGENT_ATTACHMENT_ACCEPT: string;
|
|
11
|
+
export declare function formatFileSize(bytes: number): string;
|
|
12
|
+
/**
|
|
13
|
+
* Validates `files` against what is already attached and reads the accepted ones.
|
|
14
|
+
* Returns the new attachments plus one message per rejected file.
|
|
15
|
+
*/
|
|
16
|
+
export declare function readAgentAttachments(files: File[], existing: AgentAttachment[]): Promise<{
|
|
17
|
+
added: AgentAttachment[];
|
|
18
|
+
errors: string[];
|
|
19
|
+
}>;
|
|
20
|
+
//# sourceMappingURL=agentAttachments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentAttachments.d.ts","sourceRoot":"","sources":["../../../../src/components/core/solid-agent/agentAttachments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;GAGG;AAEH,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,0BAA0B,QAAkB,CAAC;AAC1D,eAAO,MAAM,iCAAiC,QAAmB,CAAC;AA+BlE,qDAAqD;AACrD,eAAO,MAAM,uBAAuB,QAAkG,CAAC;AAEvI,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIpD;AAoBD;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,eAAe,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA+C9I"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
+
if (ar || !(i in from)) {
|
|
40
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
+
ar[i] = from[i];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Reading chat attachments in the browser. Limits match the agent (server/attachments.py)
|
|
48
|
+
* so problems are reported before sending.
|
|
49
|
+
*/
|
|
50
|
+
export var MAX_AGENT_ATTACHMENTS = 5;
|
|
51
|
+
export var MAX_AGENT_ATTACHMENT_BYTES = 5 * 1024 * 1024;
|
|
52
|
+
export var MAX_AGENT_ATTACHMENTS_TOTAL_BYTES = 10 * 1024 * 1024;
|
|
53
|
+
var IMAGE_TYPES = new Set(["image/png", "image/jpeg", "image/gif", "image/webp"]);
|
|
54
|
+
/** Text files by extension; browsers often report "" (or odd types, e.g. .ts → video/mp2t). */
|
|
55
|
+
var TEXT_EXTENSIONS = {
|
|
56
|
+
txt: "text/plain",
|
|
57
|
+
log: "text/plain",
|
|
58
|
+
md: "text/markdown",
|
|
59
|
+
csv: "text/csv",
|
|
60
|
+
tsv: "text/tab-separated-values",
|
|
61
|
+
html: "text/html",
|
|
62
|
+
css: "text/css",
|
|
63
|
+
json: "application/json",
|
|
64
|
+
xml: "application/xml",
|
|
65
|
+
yaml: "application/yaml",
|
|
66
|
+
yml: "application/yaml",
|
|
67
|
+
js: "application/javascript",
|
|
68
|
+
jsx: "application/javascript",
|
|
69
|
+
mjs: "application/javascript",
|
|
70
|
+
ts: "application/typescript",
|
|
71
|
+
tsx: "application/typescript",
|
|
72
|
+
sql: "application/sql",
|
|
73
|
+
sh: "application/x-sh",
|
|
74
|
+
py: "text/x-python",
|
|
75
|
+
java: "text/x-java",
|
|
76
|
+
env: "text/plain",
|
|
77
|
+
ini: "text/plain",
|
|
78
|
+
toml: "text/plain",
|
|
79
|
+
};
|
|
80
|
+
/** Value for the file input's `accept` attribute. */
|
|
81
|
+
export var AGENT_ATTACHMENT_ACCEPT = __spreadArray(__spreadArray([], Array.from(IMAGE_TYPES), true), Object.keys(TEXT_EXTENSIONS).map(function (ext) { return ".".concat(ext); }), true).join(",");
|
|
82
|
+
export function formatFileSize(bytes) {
|
|
83
|
+
if (bytes < 1024)
|
|
84
|
+
return "".concat(bytes, " B");
|
|
85
|
+
if (bytes < 1024 * 1024)
|
|
86
|
+
return "".concat((bytes / 1024).toFixed(bytes < 10 * 1024 ? 1 : 0), " KB");
|
|
87
|
+
return "".concat((bytes / (1024 * 1024)).toFixed(1), " MB");
|
|
88
|
+
}
|
|
89
|
+
function resolveKind(file) {
|
|
90
|
+
if (IMAGE_TYPES.has(file.type))
|
|
91
|
+
return { kind: "image", mimeType: file.type };
|
|
92
|
+
var ext = file.name.includes(".") ? file.name.split(".").pop().toLowerCase() : "";
|
|
93
|
+
if (TEXT_EXTENSIONS[ext])
|
|
94
|
+
return { kind: "text", mimeType: TEXT_EXTENSIONS[ext] };
|
|
95
|
+
if (file.type.startsWith("text/"))
|
|
96
|
+
return { kind: "text", mimeType: file.type };
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
function readAs(file, mode) {
|
|
100
|
+
return new Promise(function (resolve, reject) {
|
|
101
|
+
var reader = new FileReader();
|
|
102
|
+
reader.onload = function () { var _a; return resolve(String((_a = reader.result) !== null && _a !== void 0 ? _a : "")); };
|
|
103
|
+
reader.onerror = function () { var _a; return reject((_a = reader.error) !== null && _a !== void 0 ? _a : new Error("read failed")); };
|
|
104
|
+
if (mode === "text")
|
|
105
|
+
reader.readAsText(file);
|
|
106
|
+
else
|
|
107
|
+
reader.readAsDataURL(file);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Validates `files` against what is already attached and reads the accepted ones.
|
|
112
|
+
* Returns the new attachments plus one message per rejected file.
|
|
113
|
+
*/
|
|
114
|
+
export function readAgentAttachments(files, existing) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
+
var added, errors, count, total, _i, files_1, file, kind, dataUrl, text, _a;
|
|
117
|
+
return __generator(this, function (_b) {
|
|
118
|
+
switch (_b.label) {
|
|
119
|
+
case 0:
|
|
120
|
+
added = [];
|
|
121
|
+
errors = [];
|
|
122
|
+
count = existing.length;
|
|
123
|
+
total = existing.reduce(function (sum, item) { return sum + item.meta.size; }, 0);
|
|
124
|
+
_i = 0, files_1 = files;
|
|
125
|
+
_b.label = 1;
|
|
126
|
+
case 1:
|
|
127
|
+
if (!(_i < files_1.length)) return [3 /*break*/, 9];
|
|
128
|
+
file = files_1[_i];
|
|
129
|
+
kind = resolveKind(file);
|
|
130
|
+
if (!kind) {
|
|
131
|
+
errors.push("\u201C".concat(file.name, "\u201D: this file type is not supported (images and text files only)."));
|
|
132
|
+
return [3 /*break*/, 8];
|
|
133
|
+
}
|
|
134
|
+
if (count >= MAX_AGENT_ATTACHMENTS) {
|
|
135
|
+
errors.push("You can attach up to ".concat(MAX_AGENT_ATTACHMENTS, " files per message."));
|
|
136
|
+
return [3 /*break*/, 9];
|
|
137
|
+
}
|
|
138
|
+
if (file.size > MAX_AGENT_ATTACHMENT_BYTES) {
|
|
139
|
+
errors.push("\u201C".concat(file.name, "\u201D is larger than ").concat(formatFileSize(MAX_AGENT_ATTACHMENT_BYTES), "."));
|
|
140
|
+
return [3 /*break*/, 8];
|
|
141
|
+
}
|
|
142
|
+
if (total + file.size > MAX_AGENT_ATTACHMENTS_TOTAL_BYTES) {
|
|
143
|
+
errors.push("Attachments can't exceed ".concat(formatFileSize(MAX_AGENT_ATTACHMENTS_TOTAL_BYTES), " in total."));
|
|
144
|
+
return [3 /*break*/, 8];
|
|
145
|
+
}
|
|
146
|
+
_b.label = 2;
|
|
147
|
+
case 2:
|
|
148
|
+
_b.trys.push([2, 7, , 8]);
|
|
149
|
+
if (!(kind.kind === "image")) return [3 /*break*/, 4];
|
|
150
|
+
return [4 /*yield*/, readAs(file, "dataUrl")];
|
|
151
|
+
case 3:
|
|
152
|
+
dataUrl = _b.sent();
|
|
153
|
+
added.push({
|
|
154
|
+
payload: { name: file.name, mimeType: kind.mimeType, size: file.size, encoding: "base64", content: dataUrl.slice(dataUrl.indexOf(",") + 1) },
|
|
155
|
+
meta: { name: file.name, mimeType: kind.mimeType, size: file.size, previewUrl: dataUrl },
|
|
156
|
+
file: file,
|
|
157
|
+
});
|
|
158
|
+
return [3 /*break*/, 6];
|
|
159
|
+
case 4: return [4 /*yield*/, readAs(file, "text")];
|
|
160
|
+
case 5:
|
|
161
|
+
text = _b.sent();
|
|
162
|
+
added.push({
|
|
163
|
+
payload: { name: file.name, mimeType: kind.mimeType, size: file.size, encoding: "text", content: text },
|
|
164
|
+
meta: { name: file.name, mimeType: kind.mimeType, size: file.size },
|
|
165
|
+
file: file,
|
|
166
|
+
});
|
|
167
|
+
_b.label = 6;
|
|
168
|
+
case 6:
|
|
169
|
+
count += 1;
|
|
170
|
+
total += file.size;
|
|
171
|
+
return [3 /*break*/, 8];
|
|
172
|
+
case 7:
|
|
173
|
+
_a = _b.sent();
|
|
174
|
+
errors.push("\u201C".concat(file.name, "\u201D could not be read."));
|
|
175
|
+
return [3 /*break*/, 8];
|
|
176
|
+
case 8:
|
|
177
|
+
_i++;
|
|
178
|
+
return [3 /*break*/, 1];
|
|
179
|
+
case 9: return [2 /*return*/, { added: added, errors: errors }];
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=agentAttachments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentAttachments.js","sourceRoot":"","sources":["../../../../src/components/core/solid-agent/agentAttachments.ts"],"names":[],"mappings":"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","sourcesContent":["import type { AgentAttachment } from \"./types\";\n\n/**\n * Reading chat attachments in the browser. Limits match the agent (server/attachments.py)\n * so problems are reported before sending.\n */\n\nexport const MAX_AGENT_ATTACHMENTS = 5;\nexport const MAX_AGENT_ATTACHMENT_BYTES = 5 * 1024 * 1024;\nexport const MAX_AGENT_ATTACHMENTS_TOTAL_BYTES = 10 * 1024 * 1024;\n\nconst IMAGE_TYPES = new Set([\"image/png\", \"image/jpeg\", \"image/gif\", \"image/webp\"]);\n\n/** Text files by extension; browsers often report \"\" (or odd types, e.g. .ts → video/mp2t). */\nconst TEXT_EXTENSIONS: Record<string, string> = {\n txt: \"text/plain\",\n log: \"text/plain\",\n md: \"text/markdown\",\n csv: \"text/csv\",\n tsv: \"text/tab-separated-values\",\n html: \"text/html\",\n css: \"text/css\",\n json: \"application/json\",\n xml: \"application/xml\",\n yaml: \"application/yaml\",\n yml: \"application/yaml\",\n js: \"application/javascript\",\n jsx: \"application/javascript\",\n mjs: \"application/javascript\",\n ts: \"application/typescript\",\n tsx: \"application/typescript\",\n sql: \"application/sql\",\n sh: \"application/x-sh\",\n py: \"text/x-python\",\n java: \"text/x-java\",\n env: \"text/plain\",\n ini: \"text/plain\",\n toml: \"text/plain\",\n};\n\n/** Value for the file input's `accept` attribute. */\nexport const AGENT_ATTACHMENT_ACCEPT = [...Array.from(IMAGE_TYPES), ...Object.keys(TEXT_EXTENSIONS).map((ext) => `.${ext}`)].join(\",\");\n\nexport function formatFileSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(bytes < 10 * 1024 ? 1 : 0)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\nfunction resolveKind(file: File): { kind: \"image\" | \"text\"; mimeType: string } | null {\n if (IMAGE_TYPES.has(file.type)) return { kind: \"image\", mimeType: file.type };\n const ext = file.name.includes(\".\") ? file.name.split(\".\").pop()!.toLowerCase() : \"\";\n if (TEXT_EXTENSIONS[ext]) return { kind: \"text\", mimeType: TEXT_EXTENSIONS[ext] };\n if (file.type.startsWith(\"text/\")) return { kind: \"text\", mimeType: file.type };\n return null;\n}\n\nfunction readAs(file: File, mode: \"text\" | \"dataUrl\"): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => resolve(String(reader.result ?? \"\"));\n reader.onerror = () => reject(reader.error ?? new Error(\"read failed\"));\n if (mode === \"text\") reader.readAsText(file);\n else reader.readAsDataURL(file);\n });\n}\n\n/**\n * Validates `files` against what is already attached and reads the accepted ones.\n * Returns the new attachments plus one message per rejected file.\n */\nexport async function readAgentAttachments(files: File[], existing: AgentAttachment[]): Promise<{ added: AgentAttachment[]; errors: string[] }> {\n const added: AgentAttachment[] = [];\n const errors: string[] = [];\n let count = existing.length;\n let total = existing.reduce((sum, item) => sum + item.meta.size, 0);\n\n for (const file of files) {\n const kind = resolveKind(file);\n if (!kind) {\n errors.push(`“${file.name}”: this file type is not supported (images and text files only).`);\n continue;\n }\n if (count >= MAX_AGENT_ATTACHMENTS) {\n errors.push(`You can attach up to ${MAX_AGENT_ATTACHMENTS} files per message.`);\n break;\n }\n if (file.size > MAX_AGENT_ATTACHMENT_BYTES) {\n errors.push(`“${file.name}” is larger than ${formatFileSize(MAX_AGENT_ATTACHMENT_BYTES)}.`);\n continue;\n }\n if (total + file.size > MAX_AGENT_ATTACHMENTS_TOTAL_BYTES) {\n errors.push(`Attachments can't exceed ${formatFileSize(MAX_AGENT_ATTACHMENTS_TOTAL_BYTES)} in total.`);\n continue;\n }\n try {\n if (kind.kind === \"image\") {\n const dataUrl = await readAs(file, \"dataUrl\");\n added.push({\n payload: { name: file.name, mimeType: kind.mimeType, size: file.size, encoding: \"base64\", content: dataUrl.slice(dataUrl.indexOf(\",\") + 1) },\n meta: { name: file.name, mimeType: kind.mimeType, size: file.size, previewUrl: dataUrl },\n file,\n });\n } else {\n const text = await readAs(file, \"text\");\n added.push({\n payload: { name: file.name, mimeType: kind.mimeType, size: file.size, encoding: \"text\", content: text },\n meta: { name: file.name, mimeType: kind.mimeType, size: file.size },\n file,\n });\n }\n count += 1;\n total += file.size;\n } catch {\n errors.push(`“${file.name}” could not be read.`);\n }\n }\n return { added, errors };\n}\n"]}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { AgentAttachment } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Reading chat attachments in the browser. Limits match the agent (server/attachments.py)
|
|
5
|
+
* so problems are reported before sending.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const MAX_AGENT_ATTACHMENTS = 5;
|
|
9
|
+
export const MAX_AGENT_ATTACHMENT_BYTES = 5 * 1024 * 1024;
|
|
10
|
+
export const MAX_AGENT_ATTACHMENTS_TOTAL_BYTES = 10 * 1024 * 1024;
|
|
11
|
+
|
|
12
|
+
const IMAGE_TYPES = new Set(["image/png", "image/jpeg", "image/gif", "image/webp"]);
|
|
13
|
+
|
|
14
|
+
/** Text files by extension; browsers often report "" (or odd types, e.g. .ts → video/mp2t). */
|
|
15
|
+
const TEXT_EXTENSIONS: Record<string, string> = {
|
|
16
|
+
txt: "text/plain",
|
|
17
|
+
log: "text/plain",
|
|
18
|
+
md: "text/markdown",
|
|
19
|
+
csv: "text/csv",
|
|
20
|
+
tsv: "text/tab-separated-values",
|
|
21
|
+
html: "text/html",
|
|
22
|
+
css: "text/css",
|
|
23
|
+
json: "application/json",
|
|
24
|
+
xml: "application/xml",
|
|
25
|
+
yaml: "application/yaml",
|
|
26
|
+
yml: "application/yaml",
|
|
27
|
+
js: "application/javascript",
|
|
28
|
+
jsx: "application/javascript",
|
|
29
|
+
mjs: "application/javascript",
|
|
30
|
+
ts: "application/typescript",
|
|
31
|
+
tsx: "application/typescript",
|
|
32
|
+
sql: "application/sql",
|
|
33
|
+
sh: "application/x-sh",
|
|
34
|
+
py: "text/x-python",
|
|
35
|
+
java: "text/x-java",
|
|
36
|
+
env: "text/plain",
|
|
37
|
+
ini: "text/plain",
|
|
38
|
+
toml: "text/plain",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** Value for the file input's `accept` attribute. */
|
|
42
|
+
export const AGENT_ATTACHMENT_ACCEPT = [...Array.from(IMAGE_TYPES), ...Object.keys(TEXT_EXTENSIONS).map((ext) => `.${ext}`)].join(",");
|
|
43
|
+
|
|
44
|
+
export function formatFileSize(bytes: number): string {
|
|
45
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
46
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(bytes < 10 * 1024 ? 1 : 0)} KB`;
|
|
47
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function resolveKind(file: File): { kind: "image" | "text"; mimeType: string } | null {
|
|
51
|
+
if (IMAGE_TYPES.has(file.type)) return { kind: "image", mimeType: file.type };
|
|
52
|
+
const ext = file.name.includes(".") ? file.name.split(".").pop()!.toLowerCase() : "";
|
|
53
|
+
if (TEXT_EXTENSIONS[ext]) return { kind: "text", mimeType: TEXT_EXTENSIONS[ext] };
|
|
54
|
+
if (file.type.startsWith("text/")) return { kind: "text", mimeType: file.type };
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function readAs(file: File, mode: "text" | "dataUrl"): Promise<string> {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
const reader = new FileReader();
|
|
61
|
+
reader.onload = () => resolve(String(reader.result ?? ""));
|
|
62
|
+
reader.onerror = () => reject(reader.error ?? new Error("read failed"));
|
|
63
|
+
if (mode === "text") reader.readAsText(file);
|
|
64
|
+
else reader.readAsDataURL(file);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Validates `files` against what is already attached and reads the accepted ones.
|
|
70
|
+
* Returns the new attachments plus one message per rejected file.
|
|
71
|
+
*/
|
|
72
|
+
export async function readAgentAttachments(files: File[], existing: AgentAttachment[]): Promise<{ added: AgentAttachment[]; errors: string[] }> {
|
|
73
|
+
const added: AgentAttachment[] = [];
|
|
74
|
+
const errors: string[] = [];
|
|
75
|
+
let count = existing.length;
|
|
76
|
+
let total = existing.reduce((sum, item) => sum + item.meta.size, 0);
|
|
77
|
+
|
|
78
|
+
for (const file of files) {
|
|
79
|
+
const kind = resolveKind(file);
|
|
80
|
+
if (!kind) {
|
|
81
|
+
errors.push(`“${file.name}”: this file type is not supported (images and text files only).`);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (count >= MAX_AGENT_ATTACHMENTS) {
|
|
85
|
+
errors.push(`You can attach up to ${MAX_AGENT_ATTACHMENTS} files per message.`);
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
if (file.size > MAX_AGENT_ATTACHMENT_BYTES) {
|
|
89
|
+
errors.push(`“${file.name}” is larger than ${formatFileSize(MAX_AGENT_ATTACHMENT_BYTES)}.`);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (total + file.size > MAX_AGENT_ATTACHMENTS_TOTAL_BYTES) {
|
|
93
|
+
errors.push(`Attachments can't exceed ${formatFileSize(MAX_AGENT_ATTACHMENTS_TOTAL_BYTES)} in total.`);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
if (kind.kind === "image") {
|
|
98
|
+
const dataUrl = await readAs(file, "dataUrl");
|
|
99
|
+
added.push({
|
|
100
|
+
payload: { name: file.name, mimeType: kind.mimeType, size: file.size, encoding: "base64", content: dataUrl.slice(dataUrl.indexOf(",") + 1) },
|
|
101
|
+
meta: { name: file.name, mimeType: kind.mimeType, size: file.size, previewUrl: dataUrl },
|
|
102
|
+
file,
|
|
103
|
+
});
|
|
104
|
+
} else {
|
|
105
|
+
const text = await readAs(file, "text");
|
|
106
|
+
added.push({
|
|
107
|
+
payload: { name: file.name, mimeType: kind.mimeType, size: file.size, encoding: "text", content: text },
|
|
108
|
+
meta: { name: file.name, mimeType: kind.mimeType, size: file.size },
|
|
109
|
+
file,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
count += 1;
|
|
113
|
+
total += file.size;
|
|
114
|
+
} catch {
|
|
115
|
+
errors.push(`“${file.name}” could not be read.`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return { added, errors };
|
|
119
|
+
}
|