@burdenoff/microfe-botmanor 2026.1108.1 → 2026.1109.2
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/dist/botlit/BotlitRoutes.d.ts +2 -0
- package/dist/botlit/BotlitRoutes.js +40 -52
- package/dist/botlit/BotlitRoutes.js.map +1 -1
- package/dist/botlit/BotmanorRoot.d.ts +3 -0
- package/dist/botlit/BotmanorRoot.js +1 -2
- package/dist/botlit/BotmanorRoot.js.map +1 -1
- package/dist/botlit/BotmanorRootInner.d.ts +3 -0
- package/dist/botlit/BotmanorRootInner.js +9 -10
- package/dist/botlit/BotmanorRootInner.js.map +1 -1
- package/dist/botlit/components/AgentApprovalPanel.d.ts +20 -0
- package/dist/botlit/components/AgentApprovalPanel.js +49 -50
- package/dist/botlit/components/AgentApprovalPanel.js.map +1 -1
- package/dist/botlit/components/AiOperationsPanel.d.ts +14 -0
- package/dist/botlit/components/AiOperationsPanel.js +54 -55
- package/dist/botlit/components/AiOperationsPanel.js.map +1 -1
- package/dist/botlit/components/AssistantChannelPanel.d.ts +3 -0
- package/dist/botlit/components/AssistantChannelPanel.js +12 -13
- package/dist/botlit/components/AssistantChannelPanel.js.map +1 -1
- package/dist/botlit/components/AssistantRuntimeSetupPanel.d.ts +4 -0
- package/dist/botlit/components/AssistantRuntimeSetupPanel.js +14 -14
- package/dist/botlit/components/AssistantRuntimeSetupPanel.js.map +1 -1
- package/dist/botlit/components/AssistantWebsitePanel.d.ts +5 -0
- package/dist/botlit/components/AssistantWebsitePanel.js +15 -16
- package/dist/botlit/components/AssistantWebsitePanel.js.map +1 -1
- package/dist/botlit/components/Badge.d.ts +9 -0
- package/dist/botlit/components/Badge.js +1 -2
- package/dist/botlit/components/Badge.js.map +1 -1
- package/dist/botlit/components/Button.d.ts +10 -0
- package/dist/botlit/components/Button.js +1 -2
- package/dist/botlit/components/Button.js.map +1 -1
- package/dist/botlit/components/Card.d.ts +16 -0
- package/dist/botlit/components/Card.js +1 -2
- package/dist/botlit/components/Card.js.map +1 -1
- package/dist/botlit/components/ChannelSelectorSheet.d.ts +23 -0
- package/dist/botlit/components/ChannelSelectorSheet.js +1 -2
- package/dist/botlit/components/ChannelSelectorSheet.js.map +1 -1
- package/dist/botlit/components/EmptyState.d.ts +12 -0
- package/dist/botlit/components/EmptyState.js +1 -2
- package/dist/botlit/components/EmptyState.js.map +1 -1
- package/dist/botlit/components/ErrorState.d.ts +10 -0
- package/dist/botlit/components/ErrorState.js +5 -6
- package/dist/botlit/components/ErrorState.js.map +1 -1
- package/dist/botlit/components/Input.d.ts +27 -0
- package/dist/botlit/components/Input.js +1 -2
- package/dist/botlit/components/Input.js.map +1 -1
- package/dist/botlit/components/KnowledgeSourceImportPanel.d.ts +3 -0
- package/dist/botlit/components/KnowledgeSourceImportPanel.js +12 -13
- package/dist/botlit/components/KnowledgeSourceImportPanel.js.map +1 -1
- package/dist/botlit/components/ModelRegistrationPanel.d.ts +5 -0
- package/dist/botlit/components/ModelRegistrationPanel.js +1 -2
- package/dist/botlit/components/ModelRegistrationPanel.js.map +1 -1
- package/dist/botlit/components/PageLayout.d.ts +12 -0
- package/dist/botlit/components/PageLayout.js +1 -2
- package/dist/botlit/components/PageLayout.js.map +1 -1
- package/dist/botlit/components/QuotaExhaustedDialog.d.ts +9 -0
- package/dist/botlit/components/QuotaExhaustedDialog.js +1 -2
- package/dist/botlit/components/QuotaExhaustedDialog.js.map +1 -1
- package/dist/botlit/components/RetentionStatusPanel.d.ts +2 -0
- package/dist/botlit/components/RetentionStatusPanel.js +18 -19
- package/dist/botlit/components/RetentionStatusPanel.js.map +1 -1
- package/dist/botlit/components/RouteLoader.d.ts +23 -0
- package/dist/botlit/components/RouteLoader.js +1 -2
- package/dist/botlit/components/RouteLoader.js.map +1 -1
- package/dist/botlit/components/VersionHistoryPanel.d.ts +12 -0
- package/dist/botlit/components/VersionHistoryPanel.js +23 -24
- package/dist/botlit/components/VersionHistoryPanel.js.map +1 -1
- package/dist/botlit/components/WorkspaceRequired.d.ts +18 -0
- package/dist/botlit/components/WorkspaceRequired.js +1 -2
- package/dist/botlit/components/WorkspaceRequired.js.map +1 -1
- package/dist/botlit/components/index.d.ts +14 -0
- package/dist/botlit/hooks/index.d.ts +35 -0
- package/dist/botlit/hooks/index.js +16 -16
- package/dist/botlit/hooks/internal/mutationInput.d.ts +56 -0
- package/dist/botlit/hooks/internal/mutationInput.js +1 -2
- package/dist/botlit/hooks/internal/mutationInput.js.map +1 -1
- package/dist/botlit/hooks/internal/workspaceGateway.d.ts +54 -0
- package/dist/botlit/hooks/internal/workspaceGateway.js +17 -19
- package/dist/botlit/hooks/internal/workspaceGateway.js.map +1 -1
- package/dist/botlit/hooks/useA2A.d.ts +104 -0
- package/dist/botlit/hooks/useA2A.js +45 -45
- package/dist/botlit/hooks/useA2A.js.map +1 -1
- package/dist/botlit/hooks/useAgentApprovals.d.ts +62 -0
- package/dist/botlit/hooks/useAgentApprovals.js +38 -39
- package/dist/botlit/hooks/useAgentApprovals.js.map +1 -1
- package/dist/botlit/hooks/useAgents.d.ts +105 -0
- package/dist/botlit/hooks/useAgents.js +53 -54
- package/dist/botlit/hooks/useAgents.js.map +1 -1
- package/dist/botlit/hooks/useAiOperations.d.ts +95 -0
- package/dist/botlit/hooks/useAiOperations.js +20 -19
- package/dist/botlit/hooks/useAiOperations.js.map +1 -1
- package/dist/botlit/hooks/useAssistantChannels.d.ts +16 -0
- package/dist/botlit/hooks/useAssistantChannels.js +1 -2
- package/dist/botlit/hooks/useAssistantChannels.js.map +1 -1
- package/dist/botlit/hooks/useAssistantRuntimeSetup.d.ts +17 -0
- package/dist/botlit/hooks/useAssistantRuntimeSetup.js +1 -2
- package/dist/botlit/hooks/useAssistantRuntimeSetup.js.map +1 -1
- package/dist/botlit/hooks/useAssistantWebsites.d.ts +18 -0
- package/dist/botlit/hooks/useAssistantWebsites.js +1 -2
- package/dist/botlit/hooks/useAssistantWebsites.js.map +1 -1
- package/dist/botlit/hooks/useBotWorkflow.d.ts +22 -0
- package/dist/botlit/hooks/useBotWorkflow.js +1 -2
- package/dist/botlit/hooks/useBotWorkflow.js.map +1 -1
- package/dist/botlit/hooks/useBots.d.ts +68 -0
- package/dist/botlit/hooks/useBots.js +32 -33
- package/dist/botlit/hooks/useBots.js.map +1 -1
- package/dist/botlit/hooks/useBuckets.d.ts +62 -0
- package/dist/botlit/hooks/useBuckets.js +91 -58
- package/dist/botlit/hooks/useBuckets.js.map +1 -1
- package/dist/botlit/hooks/useChannels.d.ts +87 -0
- package/dist/botlit/hooks/useChannels.js +73 -73
- package/dist/botlit/hooks/useChannels.js.map +1 -1
- package/dist/botlit/hooks/useExecutions.d.ts +87 -0
- package/dist/botlit/hooks/useExecutions.js +37 -37
- package/dist/botlit/hooks/useExecutions.js.map +1 -1
- package/dist/botlit/hooks/useKnowledgeBases.d.ts +79 -0
- package/dist/botlit/hooks/useKnowledgeBases.js +40 -39
- package/dist/botlit/hooks/useKnowledgeBases.js.map +1 -1
- package/dist/botlit/hooks/useKnowledgeSourceImports.d.ts +21 -0
- package/dist/botlit/hooks/useKnowledgeSourceImports.js +1 -2
- package/dist/botlit/hooks/useKnowledgeSourceImports.js.map +1 -1
- package/dist/botlit/hooks/useLLMProviders.d.ts +66 -0
- package/dist/botlit/hooks/useLLMProviders.js +25 -26
- package/dist/botlit/hooks/useLLMProviders.js.map +1 -1
- package/dist/botlit/hooks/useMCPServers.d.ts +71 -0
- package/dist/botlit/hooks/useMCPServers.js +40 -38
- package/dist/botlit/hooks/useMCPServers.js.map +1 -1
- package/dist/botlit/hooks/usePolicies.d.ts +60 -0
- package/dist/botlit/hooks/usePolicies.js +49 -49
- package/dist/botlit/hooks/usePolicies.js.map +1 -1
- package/dist/botlit/hooks/usePromptTemplates.d.ts +88 -0
- package/dist/botlit/hooks/usePromptTemplates.js +57 -57
- package/dist/botlit/hooks/usePromptTemplates.js.map +1 -1
- package/dist/botlit/hooks/useRetention.d.ts +26 -0
- package/dist/botlit/hooks/useRetention.js +3 -3
- package/dist/botlit/hooks/useRetention.js.map +1 -1
- package/dist/botlit/hooks/useRetrievalProfiles.d.ts +75 -0
- package/dist/botlit/hooks/useRetrievalProfiles.js +47 -47
- package/dist/botlit/hooks/useRetrievalProfiles.js.map +1 -1
- package/dist/botlit/hooks/useSkills.d.ts +64 -0
- package/dist/botlit/hooks/useSkills.js +53 -53
- package/dist/botlit/hooks/useSkills.js.map +1 -1
- package/dist/botlit/hooks/useStore.d.ts +112 -0
- package/dist/botlit/hooks/useStore.js +55 -55
- package/dist/botlit/hooks/useStore.js.map +1 -1
- package/dist/botlit/hooks/useUserPlatformConnection.d.ts +80 -0
- package/dist/botlit/hooks/useUserPlatformConnection.js +19 -19
- package/dist/botlit/hooks/useUserPlatformConnection.js.map +1 -1
- package/dist/botlit/index.d.ts +15 -0
- package/dist/botlit/index.js +11 -11
- package/dist/botlit/pages/A2AAgentDetailPage.d.ts +6 -0
- package/dist/botlit/pages/A2AAgentDetailPage.js +171 -178
- package/dist/botlit/pages/A2AAgentDetailPage.js.map +1 -1
- package/dist/botlit/pages/A2ARegistryPage.d.ts +2 -0
- package/dist/botlit/pages/A2ARegistryPage.js +25 -26
- package/dist/botlit/pages/A2ARegistryPage.js.map +1 -1
- package/dist/botlit/pages/AgentApprovalsPage.d.ts +2 -0
- package/dist/botlit/pages/AgentApprovalsPage.js +32 -33
- package/dist/botlit/pages/AgentApprovalsPage.js.map +1 -1
- package/dist/botlit/pages/AgentBuilderPage.d.ts +2 -0
- package/dist/botlit/pages/AgentBuilderPage.js +59 -60
- package/dist/botlit/pages/AgentBuilderPage.js.map +1 -1
- package/dist/botlit/pages/AgentDetailPage.d.ts +2 -0
- package/dist/botlit/pages/AgentDetailPage.js +83 -84
- package/dist/botlit/pages/AgentDetailPage.js.map +1 -1
- package/dist/botlit/pages/AgentsListPage.d.ts +2 -0
- package/dist/botlit/pages/AgentsListPage.js +71 -72
- package/dist/botlit/pages/AgentsListPage.js.map +1 -1
- package/dist/botlit/pages/AiOperationsPage.d.ts +2 -0
- package/dist/botlit/pages/AiOperationsPage.js +52 -53
- package/dist/botlit/pages/AiOperationsPage.js.map +1 -1
- package/dist/botlit/pages/BotChannelsTab.d.ts +7 -0
- package/dist/botlit/pages/BotChannelsTab.js +120 -122
- package/dist/botlit/pages/BotChannelsTab.js.map +1 -1
- package/dist/botlit/pages/BotDetailPage.d.ts +7 -0
- package/dist/botlit/pages/BotDetailPage.js +353 -358
- package/dist/botlit/pages/BotDetailPage.js.map +1 -1
- package/dist/botlit/pages/BotWorkflowTab.d.ts +11 -0
- package/dist/botlit/pages/BotWorkflowTab.js +20 -21
- package/dist/botlit/pages/BotWorkflowTab.js.map +1 -1
- package/dist/botlit/pages/BotsListPage.d.ts +2 -0
- package/dist/botlit/pages/BotsListPage.js +52 -53
- package/dist/botlit/pages/BotsListPage.js.map +1 -1
- package/dist/botlit/pages/BucketDetailPage.d.ts +2 -0
- package/dist/botlit/pages/BucketDetailPage.js +251 -0
- package/dist/botlit/pages/BucketDetailPage.js.map +1 -0
- package/dist/botlit/pages/BucketsPage.d.ts +2 -0
- package/dist/botlit/pages/BucketsPage.js +260 -261
- package/dist/botlit/pages/BucketsPage.js.map +1 -1
- package/dist/botlit/pages/ChannelDetailPage.d.ts +6 -0
- package/dist/botlit/pages/ChannelDetailPage.js +97 -96
- package/dist/botlit/pages/ChannelDetailPage.js.map +1 -1
- package/dist/botlit/pages/ChannelRoutesPage.d.ts +2 -0
- package/dist/botlit/pages/ChannelRoutesPage.js +23 -24
- package/dist/botlit/pages/ChannelRoutesPage.js.map +1 -1
- package/dist/botlit/pages/ChannelsPage.d.ts +2 -0
- package/dist/botlit/pages/ChannelsPage.js +44 -45
- package/dist/botlit/pages/ChannelsPage.js.map +1 -1
- package/dist/botlit/pages/ChatPage.d.ts +1 -0
- package/dist/botlit/pages/ChatPage.js +10 -11
- package/dist/botlit/pages/ChatPage.js.map +1 -1
- package/dist/botlit/pages/DashboardPage.d.ts +2 -0
- package/dist/botlit/pages/DashboardPage.js +37 -38
- package/dist/botlit/pages/DashboardPage.js.map +1 -1
- package/dist/botlit/pages/ExecutionDetailPage.d.ts +2 -0
- package/dist/botlit/pages/ExecutionDetailPage.js +47 -48
- package/dist/botlit/pages/ExecutionDetailPage.js.map +1 -1
- package/dist/botlit/pages/ExecutionsPage.d.ts +2 -0
- package/dist/botlit/pages/ExecutionsPage.js +72 -70
- package/dist/botlit/pages/ExecutionsPage.js.map +1 -1
- package/dist/botlit/pages/InstalledPackagesPage.d.ts +2 -0
- package/dist/botlit/pages/InstalledPackagesPage.js +77 -78
- package/dist/botlit/pages/InstalledPackagesPage.js.map +1 -1
- package/dist/botlit/pages/KnowledgeBaseDetailPage.d.ts +6 -0
- package/dist/botlit/pages/KnowledgeBaseDetailPage.js +171 -181
- package/dist/botlit/pages/KnowledgeBaseDetailPage.js.map +1 -1
- package/dist/botlit/pages/KnowledgeBasesPage.d.ts +2 -0
- package/dist/botlit/pages/KnowledgeBasesPage.js +30 -31
- package/dist/botlit/pages/KnowledgeBasesPage.js.map +1 -1
- package/dist/botlit/pages/MCPServerDetailPage.d.ts +6 -0
- package/dist/botlit/pages/MCPServerDetailPage.js +82 -83
- package/dist/botlit/pages/MCPServerDetailPage.js.map +1 -1
- package/dist/botlit/pages/MCPServersPage.d.ts +2 -0
- package/dist/botlit/pages/MCPServersPage.js +54 -55
- package/dist/botlit/pages/MCPServersPage.js.map +1 -1
- package/dist/botlit/pages/PoliciesPage.d.ts +2 -0
- package/dist/botlit/pages/PoliciesPage.js +25 -26
- package/dist/botlit/pages/PoliciesPage.js.map +1 -1
- package/dist/botlit/pages/PolicyDetailPage.d.ts +6 -0
- package/dist/botlit/pages/PolicyDetailPage.js +257 -259
- package/dist/botlit/pages/PolicyDetailPage.js.map +1 -1
- package/dist/botlit/pages/PromptStudioPage.d.ts +2 -0
- package/dist/botlit/pages/PromptStudioPage.js +35 -35
- package/dist/botlit/pages/PromptStudioPage.js.map +1 -1
- package/dist/botlit/pages/PromptTemplateDetailPage.d.ts +6 -0
- package/dist/botlit/pages/PromptTemplateDetailPage.js +363 -362
- package/dist/botlit/pages/PromptTemplateDetailPage.js.map +1 -1
- package/dist/botlit/pages/PromptTemplatesPage.d.ts +2 -0
- package/dist/botlit/pages/PromptTemplatesPage.js +26 -27
- package/dist/botlit/pages/PromptTemplatesPage.js.map +1 -1
- package/dist/botlit/pages/RetrievalProfileDetailPage.d.ts +6 -0
- package/dist/botlit/pages/RetrievalProfileDetailPage.js +150 -158
- package/dist/botlit/pages/RetrievalProfileDetailPage.js.map +1 -1
- package/dist/botlit/pages/RetrievalProfilesPage.d.ts +2 -0
- package/dist/botlit/pages/RetrievalProfilesPage.js +24 -25
- package/dist/botlit/pages/RetrievalProfilesPage.js.map +1 -1
- package/dist/botlit/pages/SettingsPage.d.ts +2 -0
- package/dist/botlit/pages/SettingsPage.js +124 -125
- package/dist/botlit/pages/SettingsPage.js.map +1 -1
- package/dist/botlit/pages/SkillDetailPage.d.ts +6 -0
- package/dist/botlit/pages/SkillDetailPage.js +216 -217
- package/dist/botlit/pages/SkillDetailPage.js.map +1 -1
- package/dist/botlit/pages/SkillsPage.d.ts +2 -0
- package/dist/botlit/pages/SkillsPage.js +24 -25
- package/dist/botlit/pages/SkillsPage.js.map +1 -1
- package/dist/botlit/pages/StorePackageDetailPage.d.ts +2 -0
- package/dist/botlit/pages/StorePackageDetailPage.js +38 -39
- package/dist/botlit/pages/StorePackageDetailPage.js.map +1 -1
- package/dist/botlit/pages/StorePage.d.ts +2 -0
- package/dist/botlit/pages/StorePage.js +135 -136
- package/dist/botlit/pages/StorePage.js.map +1 -1
- package/dist/botlit/pages/index.d.ts +38 -0
- package/dist/botlit/permissions/PermissionRequired.d.ts +20 -0
- package/dist/botlit/permissions/PermissionRequired.js +10 -11
- package/dist/botlit/permissions/PermissionRequired.js.map +1 -1
- package/dist/botlit/permissions/botmanorPermissions.d.ts +82 -0
- package/dist/botlit/permissions/botmanorPermissions.js +1 -2
- package/dist/botlit/permissions/botmanorPermissions.js.map +1 -1
- package/dist/botlit/permissions/index.d.ts +7 -0
- package/dist/botlit/permissions/index.js +4 -3
- package/dist/botlit/permissions/useBotmanorPermissions.d.ts +41 -0
- package/dist/botlit/permissions/useBotmanorPermissions.js +1 -2
- package/dist/botlit/permissions/useBotmanorPermissions.js.map +1 -1
- package/dist/botlit/providers/BotlitProvider.d.ts +14 -0
- package/dist/botlit/providers/BotlitProvider.js +3 -3
- package/dist/botlit/providers/BotlitProvider.js.map +1 -1
- package/dist/botlit/store/botlitStore.d.ts +85 -0
- package/dist/botlit/store/botlitStore.js +1 -2
- package/dist/botlit/store/botlitStore.js.map +1 -1
- package/dist/botlit/store/renamedKeyStorage.d.ts +13 -0
- package/dist/botlit/store/renamedKeyStorage.js +1 -2
- package/dist/botlit/store/renamedKeyStorage.js.map +1 -1
- package/dist/botlit/types/index.d.ts +1008 -0
- package/dist/botlit/utils/cn.d.ts +2 -0
- package/dist/botlit/utils/cn.js +1 -2
- package/dist/botlit/utils/cn.js.map +1 -1
- package/dist/botlit/utils/embedding-models.d.ts +9 -0
- package/dist/botlit/utils/embedding-models.js +1 -2
- package/dist/botlit/utils/embedding-models.js.map +1 -1
- package/dist/botlit/utils/errors.d.ts +19 -0
- package/dist/botlit/utils/errors.js +1 -2
- package/dist/botlit/utils/errors.js.map +1 -1
- package/dist/botlit/utils/formatters.d.ts +38 -0
- package/dist/botlit/utils/formatters.js +0 -1
- package/dist/botlit/utils/formatters.js.map +1 -1
- package/dist/botlit/utils/navigation.d.ts +19 -0
- package/dist/botlit/utils/navigation.js +1 -2
- package/dist/botlit/utils/navigation.js.map +1 -1
- package/dist/botlit/utils/policyConfig.d.ts +68 -0
- package/dist/botlit/utils/policyConfig.js +2 -3
- package/dist/botlit/utils/policyConfig.js.map +1 -1
- package/dist/botlit/utils/unions.d.ts +25 -0
- package/dist/botlit/utils/unions.js +1 -2
- package/dist/botlit/utils/unions.js.map +1 -1
- package/dist/dev/App.d.ts +2 -0
- package/dist/dev/main.d.ts +0 -0
- package/dist/generated/global-operations.d.ts +197 -0
- package/dist/generated/global-operations.js +1 -2
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/generated/global-types.d.ts +27678 -0
- package/dist/generated/global-types.js +1 -2
- package/dist/generated/global-types.js.map +1 -1
- package/dist/generated/wspace-operations.d.ts +5489 -0
- package/dist/generated/wspace-operations.js +88 -84
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +152017 -0
- package/dist/generated/wspace-types.js +1 -2
- package/dist/generated/wspace-types.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -6
- package/dist/shared/hooks/useTr.d.ts +16 -0
- package/dist/shared/hooks/useTr.js +1 -2
- package/dist/shared/hooks/useTr.js.map +1 -1
- package/dist/stories/Badge.stories.d.ts +11 -0
- package/dist/stories/Button.stories.d.ts +13 -0
- package/dist/stories/EmptyState.stories.d.ts +8 -0
- package/dist/stories/StatusBadge.stories.d.ts +9 -0
- package/dist/test/fixtures.d.ts +39 -0
- package/dist/test/happydom.d.ts +1 -0
- package/dist/test/renderPage.d.ts +18 -0
- package/dist/test/setup.d.ts +9 -0
- package/dist/utils/nativeBridge.d.ts +2 -0
- package/dist/utils/nativeBridge.js +1 -2
- package/package.json +87 -60
- package/dist/botlit/hooks/useConversations.js +0 -64
- package/dist/botlit/hooks/useConversations.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CreateKnowledgeBaseDocument as e, GetKnowledgeBaseDocument as t, ListKnowledgeBasesDocument as n, ListKnowledgeDocumentsDocument as r, RebuildKnowledgeBaseIndexDocument as i, UpdateKnowledgeBaseDocument as a } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { buildMutationInput as o, fieldsOf as s } from "./internal/mutationInput.js";
|
|
3
3
|
import { useWorkspaceId as c, useWorkspaceMutation as l, useWorkspaceQuery as u } from "./internal/workspaceGateway.js";
|
|
4
4
|
import { useCallback as d, useMemo as f } from "react";
|
|
5
|
-
|
|
6
|
-
var p = 100, m =
|
|
5
|
+
// src/botlit/hooks/useKnowledgeBases.ts
|
|
6
|
+
var p = 100, m = s({
|
|
7
7
|
chunkOverlap: !0,
|
|
8
8
|
chunkSize: !0,
|
|
9
9
|
chunkingStrategy: !0,
|
|
@@ -14,7 +14,7 @@ var p = 100, m = t({
|
|
|
14
14
|
name: !0,
|
|
15
15
|
vectorStoreDriver: !0,
|
|
16
16
|
workspaceId: !0
|
|
17
|
-
}), h =
|
|
17
|
+
}), h = s({
|
|
18
18
|
chunkOverlap: !0,
|
|
19
19
|
chunkSize: !0,
|
|
20
20
|
chunkingStrategy: !0,
|
|
@@ -32,19 +32,19 @@ function b(e) {
|
|
|
32
32
|
return e?.listKnowledgeDocuments ?? _;
|
|
33
33
|
}
|
|
34
34
|
function x(e) {
|
|
35
|
-
let t = c(),
|
|
35
|
+
let t = c(), r = e?.search, i = f(() => ({
|
|
36
|
+
filters: {
|
|
37
|
+
workspaceId: t,
|
|
38
|
+
search: r || void 0
|
|
39
|
+
},
|
|
40
|
+
pagination: {
|
|
41
|
+
limit: p,
|
|
42
|
+
offset: 0
|
|
43
|
+
}
|
|
44
|
+
}), [t, r]);
|
|
36
45
|
return u({
|
|
37
|
-
document:
|
|
38
|
-
variables:
|
|
39
|
-
filters: {
|
|
40
|
-
workspaceId: t,
|
|
41
|
-
search: n || void 0
|
|
42
|
-
},
|
|
43
|
-
pagination: {
|
|
44
|
-
limit: p,
|
|
45
|
-
offset: 0
|
|
46
|
-
}
|
|
47
|
-
}), [t, n]),
|
|
46
|
+
document: n,
|
|
47
|
+
variables: i,
|
|
48
48
|
select: v,
|
|
49
49
|
fallback: g,
|
|
50
50
|
enabled: !!t,
|
|
@@ -52,9 +52,10 @@ function x(e) {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
function S(e) {
|
|
55
|
+
let n = f(() => ({ id: e ?? "" }), [e]);
|
|
55
56
|
return u({
|
|
56
|
-
document:
|
|
57
|
-
variables:
|
|
57
|
+
document: t,
|
|
58
|
+
variables: n,
|
|
58
59
|
select: y,
|
|
59
60
|
fallback: null,
|
|
60
61
|
enabled: !!e,
|
|
@@ -62,15 +63,16 @@ function S(e) {
|
|
|
62
63
|
});
|
|
63
64
|
}
|
|
64
65
|
function C(e) {
|
|
66
|
+
let t = f(() => ({
|
|
67
|
+
knowledgeBaseId: e ?? "",
|
|
68
|
+
pagination: {
|
|
69
|
+
limit: p,
|
|
70
|
+
offset: 0
|
|
71
|
+
}
|
|
72
|
+
}), [e]);
|
|
65
73
|
return u({
|
|
66
|
-
document:
|
|
67
|
-
variables:
|
|
68
|
-
knowledgeBaseId: e ?? "",
|
|
69
|
-
pagination: {
|
|
70
|
-
limit: p,
|
|
71
|
-
offset: 0
|
|
72
|
-
}
|
|
73
|
-
}), [e]),
|
|
74
|
+
document: r,
|
|
75
|
+
variables: t,
|
|
74
76
|
select: b,
|
|
75
77
|
fallback: _,
|
|
76
78
|
enabled: !!e,
|
|
@@ -78,23 +80,23 @@ function C(e) {
|
|
|
78
80
|
});
|
|
79
81
|
}
|
|
80
82
|
function w() {
|
|
81
|
-
let t = c()
|
|
83
|
+
let t = c(), n = d((e) => ({ input: o({
|
|
84
|
+
...e,
|
|
85
|
+
workspaceId: t
|
|
86
|
+
}, m) }), [t]);
|
|
82
87
|
return l({
|
|
83
|
-
document:
|
|
84
|
-
variables:
|
|
85
|
-
...n,
|
|
86
|
-
workspaceId: t
|
|
87
|
-
}, m) }), [t]),
|
|
88
|
+
document: e,
|
|
89
|
+
variables: n,
|
|
88
90
|
select: (e) => e?.createKnowledgeBase,
|
|
89
91
|
errorMessage: "Failed to create knowledge base"
|
|
90
92
|
});
|
|
91
93
|
}
|
|
92
94
|
function T() {
|
|
93
95
|
return l({
|
|
94
|
-
document:
|
|
95
|
-
variables: ({ kbId:
|
|
96
|
-
id:
|
|
97
|
-
input:
|
|
96
|
+
document: a,
|
|
97
|
+
variables: ({ kbId: e, input: t }) => ({
|
|
98
|
+
id: e,
|
|
99
|
+
input: o(t, h)
|
|
98
100
|
}),
|
|
99
101
|
select: (e) => e?.updateKnowledgeBase,
|
|
100
102
|
errorMessage: "Failed to update knowledge base"
|
|
@@ -102,13 +104,12 @@ function T() {
|
|
|
102
104
|
}
|
|
103
105
|
function E() {
|
|
104
106
|
return l({
|
|
105
|
-
document:
|
|
107
|
+
document: i,
|
|
106
108
|
variables: (e) => ({ knowledgeBaseId: e }),
|
|
107
109
|
select: (e) => e?.rebuildKnowledgeBaseIndex,
|
|
108
110
|
errorMessage: "Failed to rebuild the knowledge base index"
|
|
109
111
|
});
|
|
110
112
|
}
|
|
111
|
-
//#endregion
|
|
112
113
|
export { w as useCreateKnowledgeBase, S as useKnowledgeBase, x as useKnowledgeBases, C as useKnowledgeDocuments, E as useRebuildKnowledgeBaseIndex, T as useUpdateKnowledgeBase };
|
|
113
114
|
|
|
114
115
|
//# sourceMappingURL=useKnowledgeBases.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKnowledgeBases.js","names":[],"sources":["../../../src/botlit/hooks/useKnowledgeBases.ts"],"sourcesContent":["/**\n * Knowledge Bases Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listKnowledgeBases` / `getKnowledgeBase` /\n * `listKnowledgeDocuments` operations and the create/update/delete mutations on\n * wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateKnowledgeBaseDocument,\n DeleteKnowledgeBaseDocument,\n GetKnowledgeBaseDocument,\n ListKnowledgeBasesDocument,\n ListKnowledgeDocumentsDocument,\n RebuildKnowledgeBaseIndexDocument,\n UpdateKnowledgeBaseDocument,\n type CreateKnowledgeBaseMutation,\n type DeleteKnowledgeBaseMutation,\n type GetKnowledgeBaseQuery,\n type ListKnowledgeBasesQuery,\n type ListKnowledgeDocumentsQuery,\n type RebuildKnowledgeBaseIndexMutation,\n type UpdateKnowledgeBaseMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreateKnowledgeBaseInput,\n UpdateKnowledgeBaseInput,\n} from '../../generated/wspace-types';\nimport type { BaseFilter } from '../types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 100;\n\nexport interface KnowledgeBaseRecord {\n id: string;\n name: string;\n description?: string | null;\n indexStatus: string;\n embeddingModel: string;\n embeddingDimensions: number;\n chunkingStrategy: string;\n chunkSize: number;\n chunkOverlap: number;\n totalDocuments: number;\n totalChunks: number;\n vectorCount: number;\n lastIndexedAt?: string | null;\n metadata?: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\nexport interface KnowledgeDocumentRecord {\n id: string;\n knowledgeBaseId: string;\n title: string;\n fileId: string;\n status: string;\n chunkCount: number;\n processingError?: string | null;\n processedAt?: string | null;\n addedAt: string;\n addedById: string;\n updatedAt: string;\n}\n\n/**\n * `CreateKnowledgeBaseInput` minus the `workspaceId` the hook supplies.\n * `embeddingModel`/`embeddingDimensions` are required by the service.\n */\nexport type CreateKnowledgeBaseVariables = Omit<\n GraphQLInput<CreateKnowledgeBaseInput>,\n 'workspaceId'\n>;\n\nexport interface UpdateKnowledgeBaseVariables {\n kbId: string;\n input: GraphQLInput<UpdateKnowledgeBaseInput>;\n}\n\nconst CREATE_KB_FIELDS = fieldsOf<CreateKnowledgeBaseInput>({\n chunkOverlap: true,\n chunkSize: true,\n chunkingStrategy: true,\n description: true,\n embeddingDimensions: true,\n embeddingModel: true,\n metadata: true,\n name: true,\n // Optional: the service picks the environment default when omitted.\n vectorStoreDriver: true,\n workspaceId: true,\n});\n\nconst UPDATE_KB_FIELDS = fieldsOf<UpdateKnowledgeBaseInput>({\n chunkOverlap: true,\n chunkSize: true,\n chunkingStrategy: true,\n description: true,\n metadata: true,\n name: true,\n});\n\nconst NO_KNOWLEDGE_BASES: KnowledgeBaseRecord[] = [];\nconst NO_DOCUMENTS: KnowledgeDocumentRecord[] = [];\n\nfunction selectKnowledgeBases(data: ListKnowledgeBasesQuery | undefined): KnowledgeBaseRecord[] {\n return data?.listKnowledgeBases ?? NO_KNOWLEDGE_BASES;\n}\n\nfunction selectKnowledgeBase(data: GetKnowledgeBaseQuery | undefined): KnowledgeBaseRecord | null {\n return data?.getKnowledgeBase ?? null;\n}\n\nfunction selectDocuments(data: ListKnowledgeDocumentsQuery | undefined): KnowledgeDocumentRecord[] {\n return data?.listKnowledgeDocuments ?? NO_DOCUMENTS;\n}\n\nexport const knowledgeBaseKeys = {\n all: ['knowledgeBases'] as const,\n lists: () => [...knowledgeBaseKeys.all, 'list'] as const,\n list: (filter?: BaseFilter) => [...knowledgeBaseKeys.lists(), filter] as const,\n details: () => [...knowledgeBaseKeys.all, 'detail'] as const,\n detail: (id: string) => [...knowledgeBaseKeys.details(), id] as const,\n documents: (kbId: string) => [...knowledgeBaseKeys.detail(kbId), 'documents'] as const,\n};\n\nexport function useKnowledgeBases(filter?: BaseFilter): QueryResult<KnowledgeBaseRecord[]> {\n const workspaceId = useWorkspaceId();\n const search = filter?.search;\n\n const variables = useMemo(\n () => ({\n filters: { workspaceId, search: search || undefined },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, search]\n );\n\n return useWorkspaceQuery<ListKnowledgeBasesQuery, KnowledgeBaseRecord[]>({\n document: ListKnowledgeBasesDocument,\n variables,\n select: selectKnowledgeBases,\n fallback: NO_KNOWLEDGE_BASES,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load knowledge bases',\n });\n}\n\nexport function useKnowledgeBase(\n kbId: string | undefined\n): QueryResult<KnowledgeBaseRecord | null> {\n const variables = useMemo(() => ({ id: kbId ?? '' }), [kbId]);\n\n return useWorkspaceQuery<GetKnowledgeBaseQuery, KnowledgeBaseRecord | null>({\n document: GetKnowledgeBaseDocument,\n variables,\n select: selectKnowledgeBase,\n fallback: null,\n enabled: Boolean(kbId),\n errorMessage: 'Failed to load knowledge base',\n });\n}\n\nexport function useKnowledgeDocuments(\n kbId: string | undefined\n): QueryResult<KnowledgeDocumentRecord[]> {\n const variables = useMemo(\n () => ({ knowledgeBaseId: kbId ?? '', pagination: { limit: LIST_LIMIT, offset: 0 } }),\n [kbId]\n );\n\n return useWorkspaceQuery<ListKnowledgeDocumentsQuery, KnowledgeDocumentRecord[]>({\n document: ListKnowledgeDocumentsDocument,\n variables,\n select: selectDocuments,\n fallback: NO_DOCUMENTS,\n enabled: Boolean(kbId),\n errorMessage: 'Failed to load knowledge documents',\n });\n}\n\nexport function useCreateKnowledgeBase() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreateKnowledgeBaseVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_KB_FIELDS),\n }),\n [workspaceId]\n );\n\n return useWorkspaceMutation<\n CreateKnowledgeBaseMutation,\n CreateKnowledgeBaseVariables,\n { id: string; name: string; workspaceId: string }\n >({\n document: CreateKnowledgeBaseDocument,\n variables,\n select: (data) => data?.createKnowledgeBase,\n errorMessage: 'Failed to create knowledge base',\n });\n}\n\nexport function useUpdateKnowledgeBase() {\n return useWorkspaceMutation<\n UpdateKnowledgeBaseMutation,\n UpdateKnowledgeBaseVariables,\n { id: string; name: string; indexStatus: string }\n >({\n document: UpdateKnowledgeBaseDocument,\n variables: ({ kbId, input }) => ({\n id: kbId,\n input: buildMutationInput(input, UPDATE_KB_FIELDS),\n }),\n select: (data) => data?.updateKnowledgeBase,\n errorMessage: 'Failed to update knowledge base',\n });\n}\n\n/** Re-indexes every document in the knowledge base (`rebuildKnowledgeBaseIndex`). */\nexport function useRebuildKnowledgeBaseIndex() {\n return useWorkspaceMutation<RebuildKnowledgeBaseIndexMutation, string, boolean>({\n document: RebuildKnowledgeBaseIndexDocument,\n variables: (kbId) => ({ knowledgeBaseId: kbId }),\n select: (data) => data?.rebuildKnowledgeBaseIndex,\n errorMessage: 'Failed to rebuild the knowledge base index',\n });\n}\n\nexport function useDeleteKnowledgeBase() {\n return useWorkspaceMutation<DeleteKnowledgeBaseMutation, string, boolean>({\n document: DeleteKnowledgeBaseDocument,\n variables: (kbId) => ({ id: kbId }),\n select: (data) => data?.deleteKnowledgeBase,\n errorMessage: 'Failed to delete knowledge base',\n });\n}\n"],"mappings":";;;;;AAuCA,IAAM,IAAa,KAoDb,IAAmB,EAAmC;CAC1D,cAAc;CACd,WAAW;CACX,kBAAkB;CAClB,aAAa;CACb,qBAAqB;CACrB,gBAAgB;CAChB,UAAU;CACV,MAAM;CAEN,mBAAmB;CACnB,aAAa;CACd,CAAC,EAEI,IAAmB,EAAmC;CAC1D,cAAc;CACd,WAAW;CACX,kBAAkB;CAClB,aAAa;CACb,UAAU;CACV,MAAM;CACP,CAAC,EAEI,IAA4C,EAAE,EAC9C,IAA0C,EAAE;AAElD,SAAS,EAAqB,GAAkE;AAC9F,QAAO,GAAM,sBAAsB;;AAGrC,SAAS,EAAoB,GAAqE;AAChG,QAAO,GAAM,oBAAoB;;AAGnC,SAAS,EAAgB,GAA0E;AACjG,QAAO,GAAM,0BAA0B;;AAYzC,SAAgB,EAAkB,GAAyD;CACzF,IAAM,IAAc,GAAgB,EAC9B,IAAS,GAAQ;AAUvB,QAAO,EAAkE;EACvE,UAAU;EACV,WAVgB,SACT;GACL,SAAS;IAAE;IAAa,QAAQ,KAAU,KAAA;IAAW;GACrD,YAAY;IAAE,OAAO;IAAY,QAAQ;IAAG;GAC7C,GACD,CAAC,GAAa,EAAO,CACtB;EAKC,QAAQ;EACR,UAAU;EACV,SAAS,EAAQ;EACjB,cAAc;EACf,CAAC;;AAGJ,SAAgB,EACd,GACyC;AAGzC,QAAO,EAAqE;EAC1E,UAAU;EACV,WAJgB,SAAe,EAAE,IAAI,KAAQ,IAAI,GAAG,CAAC,EAAK,CAAC;EAK3D,QAAQ;EACR,UAAU;EACV,SAAS,EAAQ;EACjB,cAAc;EACf,CAAC;;AAGJ,SAAgB,EACd,GACwC;AAMxC,QAAO,EAA0E;EAC/E,UAAU;EACV,WAPgB,SACT;GAAE,iBAAiB,KAAQ;GAAI,YAAY;IAAE,OAAO;IAAY,QAAQ;IAAG;GAAE,GACpF,CAAC,EAAK,CACP;EAKC,QAAQ;EACR,UAAU;EACV,SAAS,EAAQ;EACjB,cAAc;EACf,CAAC;;AAGJ,SAAgB,IAAyB;CACvC,IAAM,IAAc,GAAgB;AASpC,QAAO,EAIL;EACA,UAAU;EACV,WAbgB,GACf,OAAyC,EACxC,OAAO,EAAmB;GAAE,GAAG;GAAO;GAAa,EAAE,EAAiB,EACvE,GACD,CAAC,EAAY,CACd;EASC,SAAS,MAAS,GAAM;EACxB,cAAc;EACf,CAAC;;AAGJ,SAAgB,IAAyB;AACvC,QAAO,EAIL;EACA,UAAU;EACV,YAAY,EAAE,SAAM,gBAAa;GAC/B,IAAI;GACJ,OAAO,EAAmB,GAAO,EAAiB;GACnD;EACD,SAAS,MAAS,GAAM;EACxB,cAAc;EACf,CAAC;;AAIJ,SAAgB,IAA+B;AAC7C,QAAO,EAAyE;EAC9E,UAAU;EACV,YAAY,OAAU,EAAE,iBAAiB,GAAM;EAC/C,SAAS,MAAS,GAAM;EACxB,cAAc;EACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"useKnowledgeBases.js","names":["LIST_LIMIT","CREATE_KB_FIELDS","fieldsOf","UPDATE_KB_FIELDS","NO_KNOWLEDGE_BASES","NO_DOCUMENTS","selectKnowledgeBases","data","selectKnowledgeBase","selectDocuments","useKnowledgeBases","workspaceId","useWorkspaceId","search","filter","variables","useMemo","useWorkspaceQuery","ListKnowledgeBasesDocument","useKnowledgeBase","kbId","GetKnowledgeBaseDocument","useKnowledgeDocuments","ListKnowledgeDocumentsDocument","useCreateKnowledgeBase","useCallback","buildMutationInput","input","useWorkspaceMutation","CreateKnowledgeBaseDocument","useUpdateKnowledgeBase","UpdateKnowledgeBaseDocument","useRebuildKnowledgeBaseIndex","RebuildKnowledgeBaseIndexDocument"],"sources":["../../../src/botlit/hooks/useKnowledgeBases.ts"],"sourcesContent":["/**\n * Knowledge Bases Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listKnowledgeBases` / `getKnowledgeBase` /\n * `listKnowledgeDocuments` operations and the create/update/delete mutations on\n * wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateKnowledgeBaseDocument,\n DeleteKnowledgeBaseDocument,\n GetKnowledgeBaseDocument,\n ListKnowledgeBasesDocument,\n ListKnowledgeDocumentsDocument,\n RebuildKnowledgeBaseIndexDocument,\n UpdateKnowledgeBaseDocument,\n type CreateKnowledgeBaseMutation,\n type DeleteKnowledgeBaseMutation,\n type GetKnowledgeBaseQuery,\n type ListKnowledgeBasesQuery,\n type ListKnowledgeDocumentsQuery,\n type RebuildKnowledgeBaseIndexMutation,\n type UpdateKnowledgeBaseMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreateKnowledgeBaseInput,\n UpdateKnowledgeBaseInput,\n} from '../../generated/wspace-types';\nimport type { BaseFilter } from '../types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 100;\n\nexport interface KnowledgeBaseRecord {\n id: string;\n name: string;\n description?: string | null;\n indexStatus: string;\n embeddingModel: string;\n embeddingDimensions: number;\n chunkingStrategy: string;\n chunkSize: number;\n chunkOverlap: number;\n totalDocuments: number;\n totalChunks: number;\n vectorCount: number;\n lastIndexedAt?: string | null;\n metadata?: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\nexport interface KnowledgeDocumentRecord {\n id: string;\n knowledgeBaseId: string;\n title: string;\n fileId: string;\n status: string;\n chunkCount: number;\n processingError?: string | null;\n processedAt?: string | null;\n addedAt: string;\n addedById: string;\n updatedAt: string;\n}\n\n/**\n * `CreateKnowledgeBaseInput` minus the `workspaceId` the hook supplies.\n * `embeddingModel`/`embeddingDimensions` are required by the service.\n */\nexport type CreateKnowledgeBaseVariables = Omit<\n GraphQLInput<CreateKnowledgeBaseInput>,\n 'workspaceId'\n>;\n\nexport interface UpdateKnowledgeBaseVariables {\n kbId: string;\n input: GraphQLInput<UpdateKnowledgeBaseInput>;\n}\n\nconst CREATE_KB_FIELDS = fieldsOf<CreateKnowledgeBaseInput>({\n chunkOverlap: true,\n chunkSize: true,\n chunkingStrategy: true,\n description: true,\n embeddingDimensions: true,\n embeddingModel: true,\n metadata: true,\n name: true,\n // Optional: the service picks the environment default when omitted.\n vectorStoreDriver: true,\n workspaceId: true,\n});\n\nconst UPDATE_KB_FIELDS = fieldsOf<UpdateKnowledgeBaseInput>({\n chunkOverlap: true,\n chunkSize: true,\n chunkingStrategy: true,\n description: true,\n metadata: true,\n name: true,\n});\n\nconst NO_KNOWLEDGE_BASES: KnowledgeBaseRecord[] = [];\nconst NO_DOCUMENTS: KnowledgeDocumentRecord[] = [];\n\nfunction selectKnowledgeBases(data: ListKnowledgeBasesQuery | undefined): KnowledgeBaseRecord[] {\n return data?.listKnowledgeBases ?? NO_KNOWLEDGE_BASES;\n}\n\nfunction selectKnowledgeBase(data: GetKnowledgeBaseQuery | undefined): KnowledgeBaseRecord | null {\n return data?.getKnowledgeBase ?? null;\n}\n\nfunction selectDocuments(data: ListKnowledgeDocumentsQuery | undefined): KnowledgeDocumentRecord[] {\n return data?.listKnowledgeDocuments ?? NO_DOCUMENTS;\n}\n\nexport const knowledgeBaseKeys = {\n all: ['knowledgeBases'] as const,\n lists: () => [...knowledgeBaseKeys.all, 'list'] as const,\n list: (filter?: BaseFilter) => [...knowledgeBaseKeys.lists(), filter] as const,\n details: () => [...knowledgeBaseKeys.all, 'detail'] as const,\n detail: (id: string) => [...knowledgeBaseKeys.details(), id] as const,\n documents: (kbId: string) => [...knowledgeBaseKeys.detail(kbId), 'documents'] as const,\n};\n\nexport function useKnowledgeBases(filter?: BaseFilter): QueryResult<KnowledgeBaseRecord[]> {\n const workspaceId = useWorkspaceId();\n const search = filter?.search;\n\n const variables = useMemo(\n () => ({\n filters: { workspaceId, search: search || undefined },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, search]\n );\n\n return useWorkspaceQuery<ListKnowledgeBasesQuery, KnowledgeBaseRecord[]>({\n document: ListKnowledgeBasesDocument,\n variables,\n select: selectKnowledgeBases,\n fallback: NO_KNOWLEDGE_BASES,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load knowledge bases',\n });\n}\n\nexport function useKnowledgeBase(\n kbId: string | undefined\n): QueryResult<KnowledgeBaseRecord | null> {\n const variables = useMemo(() => ({ id: kbId ?? '' }), [kbId]);\n\n return useWorkspaceQuery<GetKnowledgeBaseQuery, KnowledgeBaseRecord | null>({\n document: GetKnowledgeBaseDocument,\n variables,\n select: selectKnowledgeBase,\n fallback: null,\n enabled: Boolean(kbId),\n errorMessage: 'Failed to load knowledge base',\n });\n}\n\nexport function useKnowledgeDocuments(\n kbId: string | undefined\n): QueryResult<KnowledgeDocumentRecord[]> {\n const variables = useMemo(\n () => ({ knowledgeBaseId: kbId ?? '', pagination: { limit: LIST_LIMIT, offset: 0 } }),\n [kbId]\n );\n\n return useWorkspaceQuery<ListKnowledgeDocumentsQuery, KnowledgeDocumentRecord[]>({\n document: ListKnowledgeDocumentsDocument,\n variables,\n select: selectDocuments,\n fallback: NO_DOCUMENTS,\n enabled: Boolean(kbId),\n errorMessage: 'Failed to load knowledge documents',\n });\n}\n\nexport function useCreateKnowledgeBase() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreateKnowledgeBaseVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_KB_FIELDS),\n }),\n [workspaceId]\n );\n\n return useWorkspaceMutation<\n CreateKnowledgeBaseMutation,\n CreateKnowledgeBaseVariables,\n { id: string; name: string; workspaceId: string }\n >({\n document: CreateKnowledgeBaseDocument,\n variables,\n select: (data) => data?.createKnowledgeBase,\n errorMessage: 'Failed to create knowledge base',\n });\n}\n\nexport function useUpdateKnowledgeBase() {\n return useWorkspaceMutation<\n UpdateKnowledgeBaseMutation,\n UpdateKnowledgeBaseVariables,\n { id: string; name: string; indexStatus: string }\n >({\n document: UpdateKnowledgeBaseDocument,\n variables: ({ kbId, input }) => ({\n id: kbId,\n input: buildMutationInput(input, UPDATE_KB_FIELDS),\n }),\n select: (data) => data?.updateKnowledgeBase,\n errorMessage: 'Failed to update knowledge base',\n });\n}\n\n/** Re-indexes every document in the knowledge base (`rebuildKnowledgeBaseIndex`). */\nexport function useRebuildKnowledgeBaseIndex() {\n return useWorkspaceMutation<RebuildKnowledgeBaseIndexMutation, string, boolean>({\n document: RebuildKnowledgeBaseIndexDocument,\n variables: (kbId) => ({ knowledgeBaseId: kbId }),\n select: (data) => data?.rebuildKnowledgeBaseIndex,\n errorMessage: 'Failed to rebuild the knowledge base index',\n });\n}\n\nexport function useDeleteKnowledgeBase() {\n return useWorkspaceMutation<DeleteKnowledgeBaseMutation, string, boolean>({\n document: DeleteKnowledgeBaseDocument,\n variables: (kbId) => ({ id: kbId }),\n select: (data) => data?.deleteKnowledgeBase,\n errorMessage: 'Failed to delete knowledge base',\n });\n}\n"],"mappings":";;;;;AAuCA,IAAMA,IAAa,KAoDbC,IAAmBC,EAAmC;CAC1D,cAAc;CACd,WAAW;CACX,kBAAkB;CAClB,aAAa;CACb,qBAAqB;CACrB,gBAAgB;CAChB,UAAU;CACV,MAAM;CAEN,mBAAmB;CACnB,aAAa;AACf,CAAC,GAEKC,IAAmBD,EAAmC;CAC1D,cAAc;CACd,WAAW;CACX,kBAAkB;CAClB,aAAa;CACb,UAAU;CACV,MAAM;AACR,CAAC,GAEKE,IAA4C,CAAC,GAC7CC,IAA0C,CAAC;AAEjD,SAASC,EAAqB,GAAkE;CAC9F,OAAOC,GAAM,sBAAsBH;AACrC;AAEA,SAASI,EAAoB,GAAqE;CAChG,OAAOD,GAAM,oBAAoB;AACnC;AAEA,SAASE,EAAgB,GAA0E;CACjG,OAAOF,GAAM,0BAA0BF;AACzC;AAWA,SAAgBK,EAAkB,GAAyD;CACzF,IAAMC,IAAcC,EAAe,GAC7BC,IAASC,GAAQ,QAEjBC,IAAYC,SACT;EACL,SAAS;GAAE;GAAa,QAAQH,KAAU,KAAA;EAAU;EACpD,YAAY;GAAE,OAAOb;GAAY,QAAQ;EAAE;CAC7C,IACA,CAACW,GAAaE,CAAM,CACtB;CAEA,OAAOI,EAAkE;EACvE,UAAUC;EACV;EACA,QAAQZ;EACR,UAAUF;EACV,SAAS,EAAQO;EACjB,cAAc;CAChB,CAAC;AACH;AAEA,SAAgBQ,EACd,GACyC;CACzC,IAAMJ,IAAYC,SAAe,EAAE,IAAII,KAAQ,GAAG,IAAI,CAACA,CAAI,CAAC;CAE5D,OAAOH,EAAqE;EAC1E,UAAUI;EACV;EACA,QAAQb;EACR,UAAU;EACV,SAAS,EAAQY;EACjB,cAAc;CAChB,CAAC;AACH;AAEA,SAAgBE,EACd,GACwC;CACxC,IAAMP,IAAYC,SACT;EAAE,iBAAiBI,KAAQ;EAAI,YAAY;GAAE,OAAOpB;GAAY,QAAQ;EAAE;CAAE,IACnF,CAACoB,CAAI,CACP;CAEA,OAAOH,EAA0E;EAC/E,UAAUM;EACV;EACA,QAAQd;EACR,UAAUJ;EACV,SAAS,EAAQe;EACjB,cAAc;CAChB,CAAC;AACH;AAEA,SAAgBI,IAAyB;CACvC,IAAMb,IAAcC,EAAe,GAE7BG,IAAYU,GACf,OAAyC,EACxC,OAAOC,EAAmB;EAAE,GAAGC;EAAO;CAAY,GAAG1B,CAAgB,EACvE,IACA,CAACU,CAAW,CACd;CAEA,OAAOiB,EAIL;EACA,UAAUC;EACV;EACA,SAAS,MAAStB,GAAM;EACxB,cAAc;CAChB,CAAC;AACH;AAEA,SAAgBuB,IAAyB;CACvC,OAAOF,EAIL;EACA,UAAUG;EACV,YAAY,EAAE,SAAM,gBAAa;GAC/B,IAAIX;GACJ,OAAOM,EAAmBC,GAAOxB,CAAgB;EACnD;EACA,SAAS,MAASI,GAAM;EACxB,cAAc;CAChB,CAAC;AACH;AAGA,SAAgByB,IAA+B;CAC7C,OAAOJ,EAAyE;EAC9E,UAAUK;EACV,YAAY,OAAU,EAAE,iBAAiBb,EAAK;EAC9C,SAAS,MAASb,GAAM;EACxB,cAAc;CAChB,CAAC;AACH"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface SourceImport {
|
|
2
|
+
id: string;
|
|
3
|
+
knowledgeBaseId: string;
|
|
4
|
+
title: string;
|
|
5
|
+
status: string;
|
|
6
|
+
failureCount: number;
|
|
7
|
+
errorCode: string | null;
|
|
8
|
+
documentId: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface SourceImportInput {
|
|
11
|
+
clientRequestId: string;
|
|
12
|
+
title: string;
|
|
13
|
+
sourceUrl?: string;
|
|
14
|
+
content?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function useKnowledgeSourceImports(knowledgeBaseId: string): {
|
|
17
|
+
imports: import('@tanstack/react-query').UseQueryResult<SourceImport[], Error>;
|
|
18
|
+
queue: import('@tanstack/react-query').UseMutationResult<SourceImport, Error, SourceImportInput, unknown>;
|
|
19
|
+
retry: import('@tanstack/react-query').UseMutationResult<void, Error, string, unknown>;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import { useBotlit as e } from "../providers/BotlitProvider.js";
|
|
|
2
2
|
import { gql as t } from "@apollo/client";
|
|
3
3
|
import { useGatewayClient as n } from "@burdenoff/fe-libs/shared/graphql";
|
|
4
4
|
import { useMutation as r, useQuery as i, useQueryClient as a } from "@tanstack/react-query";
|
|
5
|
-
|
|
5
|
+
// src/botlit/hooks/useKnowledgeSourceImports.ts
|
|
6
6
|
var o = t`
|
|
7
7
|
query KnowledgeSourceImports($knowledgeBaseId: ID!) {
|
|
8
8
|
knowledgeSourceImports(knowledgeBaseId: $knowledgeBaseId) {
|
|
@@ -80,7 +80,6 @@ function l(t) {
|
|
|
80
80
|
})
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
//#endregion
|
|
84
83
|
export { l as useKnowledgeSourceImports };
|
|
85
84
|
|
|
86
85
|
//# sourceMappingURL=useKnowledgeSourceImports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKnowledgeSourceImports.js","names":[],"sources":["../../../src/botlit/hooks/useKnowledgeSourceImports.ts"],"sourcesContent":["import { gql } from '@apollo/client';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\nimport { useBotlit } from '../providers/BotlitProvider';\n\ninterface SourceImport {\n id: string;\n knowledgeBaseId: string;\n title: string;\n status: string;\n failureCount: number;\n errorCode: string | null;\n documentId: string | null;\n}\nexport interface SourceImportInput {\n clientRequestId: string;\n title: string;\n sourceUrl?: string;\n content?: string;\n}\nconst LIST = gql`\n query KnowledgeSourceImports($knowledgeBaseId: ID!) {\n knowledgeSourceImports(knowledgeBaseId: $knowledgeBaseId) {\n id\n knowledgeBaseId\n title\n status\n failureCount\n errorCode\n documentId\n }\n }\n`;\nconst QUEUE = gql`\n mutation QueueKnowledgeSource($input: QueueKnowledgeSourceInput!) {\n queueKnowledgeSource(input: $input) {\n id\n knowledgeBaseId\n title\n status\n failureCount\n errorCode\n documentId\n }\n }\n`;\nconst RETRY = gql`\n mutation RetryKnowledgeSourceImport($id: ID!) {\n retryKnowledgeSourceImport(id: $id)\n }\n`;\nexport function useKnowledgeSourceImports(knowledgeBaseId: string) {\n const client = useGatewayClient('workspace'),\n cache = useQueryClient(),\n { workspaceId, currentUser } = useBotlit();\n const key = ['botmanor-knowledge-source-imports', workspaceId, currentUser?.id, knowledgeBaseId];\n const imports = useQuery({\n queryKey: key,\n enabled: Boolean(workspaceId && currentUser?.id && knowledgeBaseId),\n retry: false,\n refetchInterval: (query) =>\n query.state.data?.some((row) => ['READY', 'PROCESSING'].includes(row.status)) ? 5000 : false,\n queryFn: async () => {\n const response = await client.query<{ knowledgeSourceImports: SourceImport[] }>({\n query: LIST,\n variables: { knowledgeBaseId },\n fetchPolicy: 'no-cache',\n });\n const rows = response.data?.knowledgeSourceImports;\n if (!rows || rows.length > 100 || rows.some((row) => row.knowledgeBaseId !== knowledgeBaseId))\n throw new Error('Knowledge imports unavailable');\n return rows;\n },\n });\n const queue = useMutation({\n mutationFn: async (input: SourceImportInput) => {\n const response = await client.mutate<{ queueKnowledgeSource: SourceImport }>({\n mutation: QUEUE,\n variables: { input: { ...input, knowledgeBaseId } },\n });\n const row = response.data?.queueKnowledgeSource;\n if (!row || row.knowledgeBaseId !== knowledgeBaseId)\n throw new Error('Knowledge admission unavailable');\n return row;\n },\n onSuccess: () => cache.invalidateQueries({ queryKey: key }),\n });\n const retry = useMutation({\n mutationFn: async (id: string) => {\n const response = await client.mutate<{ retryKnowledgeSourceImport: boolean }>({\n mutation: RETRY,\n variables: { id },\n });\n if (!response.data?.retryKnowledgeSourceImport)\n throw new Error('Knowledge recovery unavailable');\n },\n onSuccess: () => cache.invalidateQueries({ queryKey: key }),\n });\n return { imports, queue, retry };\n}\n"],"mappings":";;;;;AAoBA,
|
|
1
|
+
{"version":3,"file":"useKnowledgeSourceImports.js","names":["LIST","QUEUE","RETRY","useKnowledgeSourceImports","client","useGatewayClient","cache","useQueryClient","useBotlit","key","workspaceId","currentUser","knowledgeBaseId","useQuery","query","row","rows","useMutation","input"],"sources":["../../../src/botlit/hooks/useKnowledgeSourceImports.ts"],"sourcesContent":["import { gql } from '@apollo/client';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\nimport { useBotlit } from '../providers/BotlitProvider';\n\ninterface SourceImport {\n id: string;\n knowledgeBaseId: string;\n title: string;\n status: string;\n failureCount: number;\n errorCode: string | null;\n documentId: string | null;\n}\nexport interface SourceImportInput {\n clientRequestId: string;\n title: string;\n sourceUrl?: string;\n content?: string;\n}\nconst LIST = gql`\n query KnowledgeSourceImports($knowledgeBaseId: ID!) {\n knowledgeSourceImports(knowledgeBaseId: $knowledgeBaseId) {\n id\n knowledgeBaseId\n title\n status\n failureCount\n errorCode\n documentId\n }\n }\n`;\nconst QUEUE = gql`\n mutation QueueKnowledgeSource($input: QueueKnowledgeSourceInput!) {\n queueKnowledgeSource(input: $input) {\n id\n knowledgeBaseId\n title\n status\n failureCount\n errorCode\n documentId\n }\n }\n`;\nconst RETRY = gql`\n mutation RetryKnowledgeSourceImport($id: ID!) {\n retryKnowledgeSourceImport(id: $id)\n }\n`;\nexport function useKnowledgeSourceImports(knowledgeBaseId: string) {\n const client = useGatewayClient('workspace'),\n cache = useQueryClient(),\n { workspaceId, currentUser } = useBotlit();\n const key = ['botmanor-knowledge-source-imports', workspaceId, currentUser?.id, knowledgeBaseId];\n const imports = useQuery({\n queryKey: key,\n enabled: Boolean(workspaceId && currentUser?.id && knowledgeBaseId),\n retry: false,\n refetchInterval: (query) =>\n query.state.data?.some((row) => ['READY', 'PROCESSING'].includes(row.status)) ? 5000 : false,\n queryFn: async () => {\n const response = await client.query<{ knowledgeSourceImports: SourceImport[] }>({\n query: LIST,\n variables: { knowledgeBaseId },\n fetchPolicy: 'no-cache',\n });\n const rows = response.data?.knowledgeSourceImports;\n if (!rows || rows.length > 100 || rows.some((row) => row.knowledgeBaseId !== knowledgeBaseId))\n throw new Error('Knowledge imports unavailable');\n return rows;\n },\n });\n const queue = useMutation({\n mutationFn: async (input: SourceImportInput) => {\n const response = await client.mutate<{ queueKnowledgeSource: SourceImport }>({\n mutation: QUEUE,\n variables: { input: { ...input, knowledgeBaseId } },\n });\n const row = response.data?.queueKnowledgeSource;\n if (!row || row.knowledgeBaseId !== knowledgeBaseId)\n throw new Error('Knowledge admission unavailable');\n return row;\n },\n onSuccess: () => cache.invalidateQueries({ queryKey: key }),\n });\n const retry = useMutation({\n mutationFn: async (id: string) => {\n const response = await client.mutate<{ retryKnowledgeSourceImport: boolean }>({\n mutation: RETRY,\n variables: { id },\n });\n if (!response.data?.retryKnowledgeSourceImport)\n throw new Error('Knowledge recovery unavailable');\n },\n onSuccess: () => cache.invalidateQueries({ queryKey: key }),\n });\n return { imports, queue, retry };\n}\n"],"mappings":";;;;;AAoBA,IAAMA,IAAO,CAAG;;;;;;;;;;;;GAaVC,IAAQ,CAAG;;;;;;;;;;;;GAaXC,IAAQ,CAAG;;;;;AAKjB,SAAgBC,EAA0B,GAAyB;CACjE,IAAMC,IAASC,EAAiB,WAAW,GACzCC,IAAQC,EAAe,GACvB,EAAE,gBAAa,mBAAgBC,EAAU,GACrCC,IAAM;EAAC;EAAqCC;EAAaC,GAAa;EAAIC;CAAe;CA2C/F,OAAO;EAAE,SA1COC,EAAS;GACvB,UAAUJ;GACV,SAAS,GAAQC,KAAeC,GAAa,MAAMC;GACnD,OAAO;GACP,kBAAkB,MAChBE,EAAM,MAAM,MAAM,MAAM,MAAQ,CAAC,SAAS,YAAY,CAAC,CAAC,SAASC,EAAI,MAAM,CAAC,IAAI,MAAO;GACzF,SAAS,YAAY;IAMnB,IAAMC,KAAO,MALUZ,EAAO,MAAkD;KAC9E,OAAOJ;KACP,WAAW,EAAE,mBAAgB;KAC7B,aAAa;IACf,CAAC,EAAA,CACqB,MAAM;IAC5B,IAAI,CAACgB,KAAQA,EAAK,SAAS,OAAOA,EAAK,MAAM,MAAQD,EAAI,oBAAoBH,CAAe,GAC1F,MAAU,MAAM,+BAA+B;IACjD,OAAOI;GACT;EACF,CAyBS;EAAS,OAxBJC,EAAY;GACxB,YAAY,OAAO,MAA6B;IAK9C,IAAMF,KAAM,MAJWX,EAAO,OAA+C;KAC3E,UAAUH;KACV,WAAW,EAAE,OAAO;MAAE,GAAGiB;MAAO;KAAgB,EAAE;IACpD,CAAC,EAAA,CACoB,MAAM;IAC3B,IAAI,CAACH,KAAOA,EAAI,oBAAoBH,GAClC,MAAU,MAAM,iCAAiC;IACnD,OAAOG;GACT;GACA,iBAAiBT,EAAM,kBAAkB,EAAE,UAAUG,EAAI,CAAC;EAC5D,CAYkB;EAAO,OAXXQ,EAAY;GACxB,YAAY,OAAO,MAAe;IAKhC,IAAI,EAAC,MAJkBb,EAAO,OAAgD;KAC5E,UAAUF;KACV,WAAW,EAAE,MAAG;IAClB,CAAC,EAAA,CACa,MAAM,4BAClB,MAAU,MAAM,gCAAgC;GACpD;GACA,iBAAiBI,EAAM,kBAAkB,EAAE,UAAUG,EAAI,CAAC;EAC5D,CACyB;CAAM;AACjC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { CreateBotmanorLlmModelInput, CreateBotmanorLlmProviderInput } from '../../generated/wspace-types';
|
|
2
|
+
import { GraphQLInput } from './internal/mutationInput';
|
|
3
|
+
import { QueryResult } from './internal/workspaceGateway';
|
|
4
|
+
export interface LLMProviderRecord {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
type: string;
|
|
8
|
+
isActive: boolean;
|
|
9
|
+
apiEndpoint?: string | null;
|
|
10
|
+
credentialsHash?: string | null;
|
|
11
|
+
connectionId?: string | null;
|
|
12
|
+
metadata?: Record<string, unknown> | null;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
workspaceId: string;
|
|
16
|
+
}
|
|
17
|
+
export interface LLMModelRecord {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
modelId: string;
|
|
21
|
+
providerId: string;
|
|
22
|
+
contextWindow: number;
|
|
23
|
+
maxOutputTokens: number;
|
|
24
|
+
inputPricePerMToken: number;
|
|
25
|
+
outputPricePerMToken: number;
|
|
26
|
+
isActive: boolean;
|
|
27
|
+
supportsStreaming: boolean;
|
|
28
|
+
supportsFunctionCalling: boolean;
|
|
29
|
+
supportsVision: boolean;
|
|
30
|
+
metadata?: Record<string, unknown> | null;
|
|
31
|
+
createdAt: string;
|
|
32
|
+
updatedAt: string;
|
|
33
|
+
}
|
|
34
|
+
/** `CreateBotmanorLLMProviderInput` minus the `workspaceId` the hook supplies. */
|
|
35
|
+
export type ConfigureLLMProviderVariables = Omit<GraphQLInput<CreateBotmanorLlmProviderInput>, 'workspaceId'> & {
|
|
36
|
+
isActive?: boolean;
|
|
37
|
+
};
|
|
38
|
+
export declare const llmProviderKeys: {
|
|
39
|
+
all: readonly ["llmProviders"];
|
|
40
|
+
lists: () => readonly ["llmProviders", "list"];
|
|
41
|
+
details: () => readonly ["llmProviders", "detail"];
|
|
42
|
+
detail: (id: string) => readonly ["llmProviders", "detail", string];
|
|
43
|
+
};
|
|
44
|
+
export declare function useLLMProviders(): QueryResult<LLMProviderRecord[]>;
|
|
45
|
+
export declare function useLLMProvider(providerId: string | undefined): QueryResult<LLMProviderRecord | null>;
|
|
46
|
+
export declare function useLLMModels(filters?: {
|
|
47
|
+
providerId?: string;
|
|
48
|
+
}): QueryResult<LLMModelRecord[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a provider, or updates the one whose id the caller passes.
|
|
51
|
+
* `UpdateBotmanorLLMProviderInput` has no `type`/`workspaceId`, so the update
|
|
52
|
+
* payload is projected onto the fields that input actually declares.
|
|
53
|
+
*/
|
|
54
|
+
export declare function useConfigureLLMProvider(): {
|
|
55
|
+
configureProvider: (input: ConfigureLLMProviderVariables, existingId?: string) => Promise<LLMProviderRecord>;
|
|
56
|
+
isConfiguring: boolean;
|
|
57
|
+
error: Error | undefined;
|
|
58
|
+
};
|
|
59
|
+
export declare function useDeleteLLMProvider(): readonly [(input: string) => Promise<boolean>, import('./internal/workspaceGateway').MutationState<boolean>];
|
|
60
|
+
export declare function useTestLLMConnection(): readonly [(input: string) => Promise<boolean>, import('./internal/workspaceGateway').MutationState<boolean>];
|
|
61
|
+
/** Register models through the same authenticated workspace gateway as providers. */
|
|
62
|
+
export declare function useCreateLLMModel(): {
|
|
63
|
+
createModel: (input: CreateBotmanorLlmModelInput) => Promise<LLMModelRecord>;
|
|
64
|
+
isCreating: boolean;
|
|
65
|
+
error: Error | undefined;
|
|
66
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useBotlit as e } from "../providers/BotlitProvider.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { CreateBotmanorLlmModelDocument as t, CreateBotmanorLlmProviderDocument as n, ListBotmanorLlmModelsDocument as r, ListBotmanorLlmProvidersDocument as i, UpdateBotmanorLlmProviderDocument as a } from "../../generated/wspace-operations.js";
|
|
3
|
+
import { buildMutationInput as o, fieldsOf as s } from "./internal/mutationInput.js";
|
|
4
4
|
import { useWorkspaceClient as c, useWorkspaceId as l, useWorkspaceMutation as u } from "./internal/workspaceGateway.js";
|
|
5
5
|
import { useCallback as d } from "react";
|
|
6
6
|
import { useQuery as f } from "@tanstack/react-query";
|
|
7
|
-
|
|
8
|
-
var p = 50, m = [], h = [], g =
|
|
7
|
+
// src/botlit/hooks/useLLMProviders.ts
|
|
8
|
+
var p = 50, m = [], h = [], g = s({
|
|
9
9
|
apiEndpoint: !0,
|
|
10
10
|
connectionId: !0,
|
|
11
11
|
credentials: !0,
|
|
@@ -13,7 +13,7 @@ var p = 50, m = [], h = [], g = n({
|
|
|
13
13
|
name: !0,
|
|
14
14
|
type: !0,
|
|
15
15
|
workspaceId: !0
|
|
16
|
-
}), _ =
|
|
16
|
+
}), _ = s({
|
|
17
17
|
apiEndpoint: !0,
|
|
18
18
|
connectionId: !0,
|
|
19
19
|
credentials: !0,
|
|
@@ -64,42 +64,42 @@ function v(t, n, r, i, a) {
|
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
function y() {
|
|
67
|
-
return v(
|
|
67
|
+
return v(i, "providers", (e) => e?.listBotmanorLLMProviders ?? m, m);
|
|
68
68
|
}
|
|
69
69
|
function b(e) {
|
|
70
|
-
return v(
|
|
70
|
+
return v(r, "models", (e) => e?.listBotmanorLLMModels ?? h, h, e?.providerId);
|
|
71
71
|
}
|
|
72
72
|
function x() {
|
|
73
|
-
let e = l(), [
|
|
74
|
-
document:
|
|
75
|
-
variables: (
|
|
76
|
-
...
|
|
73
|
+
let e = l(), [t, r] = u({
|
|
74
|
+
document: n,
|
|
75
|
+
variables: (t) => ({ input: o({
|
|
76
|
+
...t,
|
|
77
77
|
workspaceId: e
|
|
78
78
|
}, g) }),
|
|
79
79
|
select: (e) => e?.createBotmanorLLMProvider,
|
|
80
80
|
errorMessage: "Failed to create the LLM provider"
|
|
81
|
-
}), [
|
|
82
|
-
document:
|
|
83
|
-
variables: ({ providerId: e, input:
|
|
81
|
+
}), [i, s] = u({
|
|
82
|
+
document: a,
|
|
83
|
+
variables: ({ providerId: e, input: t }) => ({
|
|
84
84
|
id: e,
|
|
85
|
-
input: t
|
|
85
|
+
input: o(t, _)
|
|
86
86
|
}),
|
|
87
87
|
select: (e) => e?.updateBotmanorLLMProvider,
|
|
88
88
|
errorMessage: "Failed to update the LLM provider"
|
|
89
89
|
});
|
|
90
90
|
return {
|
|
91
|
-
configureProvider: d(async (e,
|
|
92
|
-
providerId:
|
|
91
|
+
configureProvider: d(async (e, n) => n ? i({
|
|
92
|
+
providerId: n,
|
|
93
93
|
input: e
|
|
94
|
-
}) :
|
|
95
|
-
isConfiguring: r.loading ||
|
|
96
|
-
error: r.error ??
|
|
94
|
+
}) : t(e), [t, i]),
|
|
95
|
+
isConfiguring: r.loading || s.loading,
|
|
96
|
+
error: r.error ?? s.error
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
function S() {
|
|
100
|
-
let [e,
|
|
101
|
-
document:
|
|
102
|
-
variables: (e) => ({ input:
|
|
100
|
+
let [e, n] = u({
|
|
101
|
+
document: t,
|
|
102
|
+
variables: (e) => ({ input: o(e, s({
|
|
103
103
|
providerId: !0,
|
|
104
104
|
name: !0,
|
|
105
105
|
modelId: !0,
|
|
@@ -117,11 +117,10 @@ function S() {
|
|
|
117
117
|
});
|
|
118
118
|
return {
|
|
119
119
|
createModel: e,
|
|
120
|
-
isCreating:
|
|
121
|
-
error:
|
|
120
|
+
isCreating: n.loading,
|
|
121
|
+
error: n.error
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
-
//#endregion
|
|
125
124
|
export { x as useConfigureLLMProvider, S as useCreateLLMModel, b as useLLMModels, y as useLLMProviders };
|
|
126
125
|
|
|
127
126
|
//# sourceMappingURL=useLLMProviders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLLMProviders.js","names":[],"sources":["../../../src/botlit/hooks/useLLMProviders.ts"],"sourcesContent":["/**\n * LLM Providers Hooks\n * @module botlit/hooks\n *\n * These go through the shell's workspace gateway client like every other BotManor\n * hook. They deliberately do NOT use the generated `useQuery`/`useMutation`\n * wrappers: `BotmanorRoot` only mounts an `<ApolloProvider>` in standalone mode,\n * so an Apollo React hook throws \"Could not find client in the context\" the\n * moment the MFE is mounted by an app shell — which is every production route.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport type { DocumentNode } from 'graphql';\nimport { useQuery } from '@tanstack/react-query';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport {\n CreateBotmanorLlmProviderDocument,\n CreateBotmanorLlmModelDocument,\n DeleteLlmProviderDocument,\n GetBotmanorLlmProviderDocument,\n ListBotmanorLlmModelsDocument,\n ListBotmanorLlmProvidersDocument,\n TestLlmConnectionDocument,\n UpdateBotmanorLlmProviderDocument,\n type CreateBotmanorLlmProviderMutation,\n type CreateBotmanorLlmModelMutation,\n type DeleteLlmProviderMutation,\n type GetBotmanorLlmProviderQuery,\n type ListBotmanorLlmModelsQuery,\n type ListBotmanorLlmProvidersQuery,\n type TestLlmConnectionMutation,\n type UpdateBotmanorLlmProviderMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreateBotmanorLlmModelInput,\n CreateBotmanorLlmProviderInput,\n UpdateBotmanorLlmProviderInput,\n} from '../../generated/wspace-types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceClient,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 50;\n\nexport interface LLMProviderRecord {\n id: string;\n name: string;\n type: string;\n isActive: boolean;\n apiEndpoint?: string | null;\n credentialsHash?: string | null;\n connectionId?: string | null;\n metadata?: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n workspaceId: string;\n}\n\nexport interface LLMModelRecord {\n id: string;\n name: string;\n modelId: string;\n providerId: string;\n contextWindow: number;\n maxOutputTokens: number;\n inputPricePerMToken: number;\n outputPricePerMToken: number;\n isActive: boolean;\n supportsStreaming: boolean;\n supportsFunctionCalling: boolean;\n supportsVision: boolean;\n metadata?: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\n/** `CreateBotmanorLLMProviderInput` minus the `workspaceId` the hook supplies. */\nexport type ConfigureLLMProviderVariables = Omit<\n GraphQLInput<CreateBotmanorLlmProviderInput>,\n 'workspaceId'\n> & { isActive?: boolean };\n\nconst NO_PROVIDERS: LLMProviderRecord[] = [];\nconst NO_MODELS: LLMModelRecord[] = [];\n\nconst CREATE_PROVIDER_FIELDS = fieldsOf<CreateBotmanorLlmProviderInput>({\n apiEndpoint: true,\n connectionId: true,\n credentials: true,\n metadata: true,\n name: true,\n type: true,\n workspaceId: true,\n});\n\nconst UPDATE_PROVIDER_FIELDS = fieldsOf<UpdateBotmanorLlmProviderInput>({\n apiEndpoint: true,\n connectionId: true,\n credentials: true,\n isActive: true,\n metadata: true,\n name: true,\n});\n\nexport const llmProviderKeys = {\n all: ['llmProviders'] as const,\n lists: () => [...llmProviderKeys.all, 'list'] as const,\n details: () => [...llmProviderKeys.all, 'detail'] as const,\n detail: (id: string) => [...llmProviderKeys.details(), id] as const,\n};\n\nfunction useLLMList<TData, TRecord>(\n document: DocumentNode,\n kind: string,\n select: (data: TData | undefined) => TRecord[],\n fallback: TRecord[],\n providerId?: string\n): QueryResult<TRecord[]> {\n const client = useWorkspaceClient();\n const { workspaceId, currentUser } = useBotlit();\n const query = useQuery({\n queryKey: ['botmanor-llm-catalog', workspaceId, currentUser?.id, kind, providerId],\n enabled: Boolean(workspaceId),\n retry: false,\n queryFn: async () => {\n const records: TRecord[] = [];\n for (let offset = 0; offset < 10000; offset += LIST_LIMIT) {\n const result = await client.query<TData>({\n query: document,\n fetchPolicy: 'network-only',\n variables: {\n filters: providerId ? { providerId } : undefined,\n pagination: { limit: LIST_LIMIT, offset },\n },\n });\n if (!result.data) throw new Error('Model catalog unavailable');\n const page = select(result.data);\n if (!Array.isArray(page) || page.length > LIST_LIMIT)\n throw new Error('Model catalog unavailable');\n records.push(...page);\n if (page.length < LIST_LIMIT) return records;\n }\n throw new Error('Model catalog exceeds the supported limit');\n },\n });\n return {\n data: query.data ?? fallback,\n loading: query.isFetching,\n error: query.error ?? undefined,\n refetch: async () => {\n await query.refetch();\n },\n };\n}\n\nexport function useLLMProviders(): QueryResult<LLMProviderRecord[]> {\n return useLLMList<ListBotmanorLlmProvidersQuery, LLMProviderRecord>(\n ListBotmanorLlmProvidersDocument,\n 'providers',\n (data) => data?.listBotmanorLLMProviders ?? NO_PROVIDERS,\n NO_PROVIDERS\n );\n}\n\nexport function useLLMProvider(\n providerId: string | undefined\n): QueryResult<LLMProviderRecord | null> {\n const variables = useMemo(() => ({ id: providerId ?? '' }), [providerId]);\n\n return useWorkspaceQuery<GetBotmanorLlmProviderQuery, LLMProviderRecord | null>({\n document: GetBotmanorLlmProviderDocument,\n variables,\n select: (data) => data?.getBotmanorLLMProvider ?? null,\n fallback: null,\n enabled: Boolean(providerId),\n errorMessage: 'Failed to load LLM provider',\n });\n}\n\nexport function useLLMModels(filters?: { providerId?: string }): QueryResult<LLMModelRecord[]> {\n return useLLMList<ListBotmanorLlmModelsQuery, LLMModelRecord>(\n ListBotmanorLlmModelsDocument,\n 'models',\n (data) => data?.listBotmanorLLMModels ?? NO_MODELS,\n NO_MODELS,\n filters?.providerId\n );\n}\n\n/**\n * Creates a provider, or updates the one whose id the caller passes.\n * `UpdateBotmanorLLMProviderInput` has no `type`/`workspaceId`, so the update\n * payload is projected onto the fields that input actually declares.\n */\nexport function useConfigureLLMProvider() {\n const workspaceId = useWorkspaceId();\n\n const [create, createState] = useWorkspaceMutation<\n CreateBotmanorLlmProviderMutation,\n ConfigureLLMProviderVariables,\n LLMProviderRecord\n >({\n document: CreateBotmanorLlmProviderDocument,\n variables: (input) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_PROVIDER_FIELDS),\n }),\n select: (data) => data?.createBotmanorLLMProvider,\n errorMessage: 'Failed to create the LLM provider',\n });\n\n const [update, updateState] = useWorkspaceMutation<\n UpdateBotmanorLlmProviderMutation,\n { providerId: string; input: ConfigureLLMProviderVariables },\n LLMProviderRecord\n >({\n document: UpdateBotmanorLlmProviderDocument,\n variables: ({ providerId, input }) => ({\n id: providerId,\n input: buildMutationInput(input, UPDATE_PROVIDER_FIELDS),\n }),\n select: (data) => data?.updateBotmanorLLMProvider,\n errorMessage: 'Failed to update the LLM provider',\n });\n\n const configureProvider = useCallback(\n async (input: ConfigureLLMProviderVariables, existingId?: string) =>\n existingId ? update({ providerId: existingId, input }) : create(input),\n [create, update]\n );\n\n return {\n configureProvider,\n isConfiguring: createState.loading || updateState.loading,\n error: createState.error ?? updateState.error,\n };\n}\n\nexport function useDeleteLLMProvider() {\n return useWorkspaceMutation<DeleteLlmProviderMutation, string, boolean>({\n document: DeleteLlmProviderDocument,\n variables: (providerId) => ({ id: providerId }),\n select: (data) => data?.deleteLLMProvider,\n errorMessage: 'Failed to delete the LLM provider',\n });\n}\n\nexport function useTestLLMConnection() {\n return useWorkspaceMutation<TestLlmConnectionMutation, string, boolean>({\n document: TestLlmConnectionDocument,\n variables: (providerId) => ({ id: providerId }),\n select: (data) => data?.testLlmConnection,\n errorMessage: 'Failed to test the LLM connection',\n });\n}\n\n/** Register models through the same authenticated workspace gateway as providers. */\nexport function useCreateLLMModel() {\n const [createModel, state] = useWorkspaceMutation<\n CreateBotmanorLlmModelMutation,\n CreateBotmanorLlmModelInput,\n LLMModelRecord\n >({\n document: CreateBotmanorLlmModelDocument,\n variables: (input) => ({\n input: buildMutationInput(\n input,\n fieldsOf<CreateBotmanorLlmModelInput>({\n providerId: true,\n name: true,\n modelId: true,\n contextWindow: true,\n maxOutputTokens: true,\n inputPricePerMToken: true,\n outputPricePerMToken: true,\n supportsStreaming: true,\n supportsFunctionCalling: true,\n supportsVision: true,\n metadata: true,\n })\n ),\n }),\n select: (data) => data?.createBotmanorLLMModel,\n errorMessage: 'Failed to register the model',\n });\n return { createModel, isCreating: state.loading, error: state.error };\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"useLLMProviders.js","names":["LIST_LIMIT","NO_PROVIDERS","NO_MODELS","CREATE_PROVIDER_FIELDS","fieldsOf","UPDATE_PROVIDER_FIELDS","useLLMList","client","useWorkspaceClient","useBotlit","query","useQuery","workspaceId","currentUser","kind","providerId","records","offset","result","document","page","select","fallback","useLLMProviders","ListBotmanorLlmProvidersDocument","data","useLLMModels","ListBotmanorLlmModelsDocument","filters","useConfigureLLMProvider","useWorkspaceId","create","createState","useWorkspaceMutation","CreateBotmanorLlmProviderDocument","buildMutationInput","input","update","updateState","UpdateBotmanorLlmProviderDocument","useCallback","existingId","useCreateLLMModel","createModel","state","CreateBotmanorLlmModelDocument"],"sources":["../../../src/botlit/hooks/useLLMProviders.ts"],"sourcesContent":["/**\n * LLM Providers Hooks\n * @module botlit/hooks\n *\n * These go through the shell's workspace gateway client like every other BotManor\n * hook. They deliberately do NOT use the generated `useQuery`/`useMutation`\n * wrappers: `BotmanorRoot` only mounts an `<ApolloProvider>` in standalone mode,\n * so an Apollo React hook throws \"Could not find client in the context\" the\n * moment the MFE is mounted by an app shell — which is every production route.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport type { DocumentNode } from 'graphql';\nimport { useQuery } from '@tanstack/react-query';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport {\n CreateBotmanorLlmProviderDocument,\n CreateBotmanorLlmModelDocument,\n DeleteLlmProviderDocument,\n GetBotmanorLlmProviderDocument,\n ListBotmanorLlmModelsDocument,\n ListBotmanorLlmProvidersDocument,\n TestLlmConnectionDocument,\n UpdateBotmanorLlmProviderDocument,\n type CreateBotmanorLlmProviderMutation,\n type CreateBotmanorLlmModelMutation,\n type DeleteLlmProviderMutation,\n type GetBotmanorLlmProviderQuery,\n type ListBotmanorLlmModelsQuery,\n type ListBotmanorLlmProvidersQuery,\n type TestLlmConnectionMutation,\n type UpdateBotmanorLlmProviderMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreateBotmanorLlmModelInput,\n CreateBotmanorLlmProviderInput,\n UpdateBotmanorLlmProviderInput,\n} from '../../generated/wspace-types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceClient,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 50;\n\nexport interface LLMProviderRecord {\n id: string;\n name: string;\n type: string;\n isActive: boolean;\n apiEndpoint?: string | null;\n credentialsHash?: string | null;\n connectionId?: string | null;\n metadata?: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n workspaceId: string;\n}\n\nexport interface LLMModelRecord {\n id: string;\n name: string;\n modelId: string;\n providerId: string;\n contextWindow: number;\n maxOutputTokens: number;\n inputPricePerMToken: number;\n outputPricePerMToken: number;\n isActive: boolean;\n supportsStreaming: boolean;\n supportsFunctionCalling: boolean;\n supportsVision: boolean;\n metadata?: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\n/** `CreateBotmanorLLMProviderInput` minus the `workspaceId` the hook supplies. */\nexport type ConfigureLLMProviderVariables = Omit<\n GraphQLInput<CreateBotmanorLlmProviderInput>,\n 'workspaceId'\n> & { isActive?: boolean };\n\nconst NO_PROVIDERS: LLMProviderRecord[] = [];\nconst NO_MODELS: LLMModelRecord[] = [];\n\nconst CREATE_PROVIDER_FIELDS = fieldsOf<CreateBotmanorLlmProviderInput>({\n apiEndpoint: true,\n connectionId: true,\n credentials: true,\n metadata: true,\n name: true,\n type: true,\n workspaceId: true,\n});\n\nconst UPDATE_PROVIDER_FIELDS = fieldsOf<UpdateBotmanorLlmProviderInput>({\n apiEndpoint: true,\n connectionId: true,\n credentials: true,\n isActive: true,\n metadata: true,\n name: true,\n});\n\nexport const llmProviderKeys = {\n all: ['llmProviders'] as const,\n lists: () => [...llmProviderKeys.all, 'list'] as const,\n details: () => [...llmProviderKeys.all, 'detail'] as const,\n detail: (id: string) => [...llmProviderKeys.details(), id] as const,\n};\n\nfunction useLLMList<TData, TRecord>(\n document: DocumentNode,\n kind: string,\n select: (data: TData | undefined) => TRecord[],\n fallback: TRecord[],\n providerId?: string\n): QueryResult<TRecord[]> {\n const client = useWorkspaceClient();\n const { workspaceId, currentUser } = useBotlit();\n const query = useQuery({\n queryKey: ['botmanor-llm-catalog', workspaceId, currentUser?.id, kind, providerId],\n enabled: Boolean(workspaceId),\n retry: false,\n queryFn: async () => {\n const records: TRecord[] = [];\n for (let offset = 0; offset < 10000; offset += LIST_LIMIT) {\n const result = await client.query<TData>({\n query: document,\n fetchPolicy: 'network-only',\n variables: {\n filters: providerId ? { providerId } : undefined,\n pagination: { limit: LIST_LIMIT, offset },\n },\n });\n if (!result.data) throw new Error('Model catalog unavailable');\n const page = select(result.data);\n if (!Array.isArray(page) || page.length > LIST_LIMIT)\n throw new Error('Model catalog unavailable');\n records.push(...page);\n if (page.length < LIST_LIMIT) return records;\n }\n throw new Error('Model catalog exceeds the supported limit');\n },\n });\n return {\n data: query.data ?? fallback,\n loading: query.isFetching,\n error: query.error ?? undefined,\n refetch: async () => {\n await query.refetch();\n },\n };\n}\n\nexport function useLLMProviders(): QueryResult<LLMProviderRecord[]> {\n return useLLMList<ListBotmanorLlmProvidersQuery, LLMProviderRecord>(\n ListBotmanorLlmProvidersDocument,\n 'providers',\n (data) => data?.listBotmanorLLMProviders ?? NO_PROVIDERS,\n NO_PROVIDERS\n );\n}\n\nexport function useLLMProvider(\n providerId: string | undefined\n): QueryResult<LLMProviderRecord | null> {\n const variables = useMemo(() => ({ id: providerId ?? '' }), [providerId]);\n\n return useWorkspaceQuery<GetBotmanorLlmProviderQuery, LLMProviderRecord | null>({\n document: GetBotmanorLlmProviderDocument,\n variables,\n select: (data) => data?.getBotmanorLLMProvider ?? null,\n fallback: null,\n enabled: Boolean(providerId),\n errorMessage: 'Failed to load LLM provider',\n });\n}\n\nexport function useLLMModels(filters?: { providerId?: string }): QueryResult<LLMModelRecord[]> {\n return useLLMList<ListBotmanorLlmModelsQuery, LLMModelRecord>(\n ListBotmanorLlmModelsDocument,\n 'models',\n (data) => data?.listBotmanorLLMModels ?? NO_MODELS,\n NO_MODELS,\n filters?.providerId\n );\n}\n\n/**\n * Creates a provider, or updates the one whose id the caller passes.\n * `UpdateBotmanorLLMProviderInput` has no `type`/`workspaceId`, so the update\n * payload is projected onto the fields that input actually declares.\n */\nexport function useConfigureLLMProvider() {\n const workspaceId = useWorkspaceId();\n\n const [create, createState] = useWorkspaceMutation<\n CreateBotmanorLlmProviderMutation,\n ConfigureLLMProviderVariables,\n LLMProviderRecord\n >({\n document: CreateBotmanorLlmProviderDocument,\n variables: (input) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_PROVIDER_FIELDS),\n }),\n select: (data) => data?.createBotmanorLLMProvider,\n errorMessage: 'Failed to create the LLM provider',\n });\n\n const [update, updateState] = useWorkspaceMutation<\n UpdateBotmanorLlmProviderMutation,\n { providerId: string; input: ConfigureLLMProviderVariables },\n LLMProviderRecord\n >({\n document: UpdateBotmanorLlmProviderDocument,\n variables: ({ providerId, input }) => ({\n id: providerId,\n input: buildMutationInput(input, UPDATE_PROVIDER_FIELDS),\n }),\n select: (data) => data?.updateBotmanorLLMProvider,\n errorMessage: 'Failed to update the LLM provider',\n });\n\n const configureProvider = useCallback(\n async (input: ConfigureLLMProviderVariables, existingId?: string) =>\n existingId ? update({ providerId: existingId, input }) : create(input),\n [create, update]\n );\n\n return {\n configureProvider,\n isConfiguring: createState.loading || updateState.loading,\n error: createState.error ?? updateState.error,\n };\n}\n\nexport function useDeleteLLMProvider() {\n return useWorkspaceMutation<DeleteLlmProviderMutation, string, boolean>({\n document: DeleteLlmProviderDocument,\n variables: (providerId) => ({ id: providerId }),\n select: (data) => data?.deleteLLMProvider,\n errorMessage: 'Failed to delete the LLM provider',\n });\n}\n\nexport function useTestLLMConnection() {\n return useWorkspaceMutation<TestLlmConnectionMutation, string, boolean>({\n document: TestLlmConnectionDocument,\n variables: (providerId) => ({ id: providerId }),\n select: (data) => data?.testLlmConnection,\n errorMessage: 'Failed to test the LLM connection',\n });\n}\n\n/** Register models through the same authenticated workspace gateway as providers. */\nexport function useCreateLLMModel() {\n const [createModel, state] = useWorkspaceMutation<\n CreateBotmanorLlmModelMutation,\n CreateBotmanorLlmModelInput,\n LLMModelRecord\n >({\n document: CreateBotmanorLlmModelDocument,\n variables: (input) => ({\n input: buildMutationInput(\n input,\n fieldsOf<CreateBotmanorLlmModelInput>({\n providerId: true,\n name: true,\n modelId: true,\n contextWindow: true,\n maxOutputTokens: true,\n inputPricePerMToken: true,\n outputPricePerMToken: true,\n supportsStreaming: true,\n supportsFunctionCalling: true,\n supportsVision: true,\n metadata: true,\n })\n ),\n }),\n select: (data) => data?.createBotmanorLLMModel,\n errorMessage: 'Failed to register the model',\n });\n return { createModel, isCreating: state.loading, error: state.error };\n}\n"],"mappings":";;;;;;;AA+CA,IAAMA,IAAa,IAwCbC,IAAoC,CAAC,GACrCC,IAA8B,CAAC,GAE/BC,IAAyBC,EAAyC;CACtE,aAAa;CACb,cAAc;CACd,aAAa;CACb,UAAU;CACV,MAAM;CACN,MAAM;CACN,aAAa;AACf,CAAC,GAEKC,IAAyBD,EAAyC;CACtE,aAAa;CACb,cAAc;CACd,aAAa;CACb,UAAU;CACV,UAAU;CACV,MAAM;AACR,CAAC;AASD,SAASE,EACP,GACA,GACA,GACA,GACA,GACwB;CACxB,IAAMC,IAASC,EAAmB,GAC5B,EAAE,gBAAa,mBAAgBC,EAAU,GACzCC,IAAQC,EAAS;EACrB,UAAU;GAAC;GAAwBC;GAAaC,GAAa;GAAIC;GAAMC;EAAU;EACjF,SAAS,EAAQH;EACjB,OAAO;EACP,SAAS,YAAY;GACnB,IAAMI,IAAqB,CAAC;GAC5B,KAAK,IAAIC,IAAS,GAAGA,IAAS,KAAO,KAAUjB,GAAY;IACzD,IAAMkB,IAAS,MAAMX,EAAO,MAAa;KACvC,OAAOY;KACP,aAAa;KACb,WAAW;MACT,SAASJ,IAAa,EAAE,cAAW,IAAI,KAAA;MACvC,YAAY;OAAE,OAAOf;OAAY;MAAO;KAC1C;IACF,CAAC;IACD,IAAI,CAACkB,EAAO,MAAM,MAAU,MAAM,2BAA2B;IAC7D,IAAME,IAAOC,EAAOH,EAAO,IAAI;IAC/B,IAAI,CAAC,MAAM,QAAQE,CAAI,KAAKA,EAAK,SAASpB,GACxC,MAAU,MAAM,2BAA2B;IAE7C,IADAgB,EAAQ,KAAK,GAAGI,CAAI,GAChBA,EAAK,SAASpB,GAAY,OAAOgB;GACvC;GACA,MAAU,MAAM,2CAA2C;EAC7D;CACF,CAAC;CACD,OAAO;EACL,MAAMN,EAAM,QAAQY;EACpB,SAASZ,EAAM;EACf,OAAOA,EAAM,SAAS,KAAA;EACtB,SAAS,YAAY;GACnB,MAAMA,EAAM,QAAQ;EACtB;CACF;AACF;AAEA,SAAgBa,IAAoD;CAClE,OAAOjB,EACLkB,GACA,cACC,MAASC,GAAM,4BAA4BxB,GAC5CA,CACF;AACF;AAiBA,SAAgByB,EAAa,GAAkE;CAC7F,OAAOpB,EACLqB,GACA,WACC,MAASF,GAAM,yBAAyBvB,GACzCA,GACA0B,GAAS,UACX;AACF;AAOA,SAAgBC,IAA0B;CACxC,IAAMjB,IAAckB,EAAe,GAE7B,CAACC,GAAQC,KAAeC,EAI5B;EACA,UAAUC;EACV,YAAY,OAAW,EACrB,OAAOC,EAAmB;GAAE,GAAGC;GAAO;EAAY,GAAGjC,CAAsB,EAC7E;EACA,SAAS,MAASsB,GAAM;EACxB,cAAc;CAChB,CAAC,GAEK,CAACY,GAAQC,KAAeL,EAI5B;EACA,UAAUM;EACV,YAAY,EAAE,eAAY,gBAAa;GACrC,IAAIxB;GACJ,OAAOoB,EAAmBC,GAAO/B,CAAsB;EACzD;EACA,SAAS,MAASoB,GAAM;EACxB,cAAc;CAChB,CAAC;CAQD,OAAO;EACL,mBAPwBe,EACxB,OAAO,GAAsC,MAC3CC,IAAaJ,EAAO;GAAE,YAAYI;GAAY;EAAM,CAAC,IAAIV,EAAOK,CAAK,GACvE,CAACL,GAAQM,CAAM,CAIf;EACA,eAAeL,EAAY,WAAWM,EAAY;EAClD,OAAON,EAAY,SAASM,EAAY;CAC1C;AACF;AAqBA,SAAgBI,IAAoB;CAClC,IAAM,CAACC,GAAaC,KAASX,EAI3B;EACA,UAAUY;EACV,YAAY,OAAW,EACrB,OAAOV,EACLC,GACAhC,EAAsC;GACpC,YAAY;GACZ,MAAM;GACN,SAAS;GACT,eAAe;GACf,iBAAiB;GACjB,qBAAqB;GACrB,sBAAsB;GACtB,mBAAmB;GACnB,yBAAyB;GACzB,gBAAgB;GAChB,UAAU;EACZ,CAAC,CACH,EACF;EACA,SAAS,MAASqB,GAAM;EACxB,cAAc;CAChB,CAAC;CACD,OAAO;EAAE;EAAa,YAAYmB,EAAM;EAAS,OAAOA,EAAM;CAAM;AACtE"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { CreateMcpConnectionInput, McpToolRiskLevel, UpdateMcpConnectionInput, UpdateMcpToolInput } from '../../generated/wspace-types';
|
|
2
|
+
import { BaseFilter } from '../types';
|
|
3
|
+
import { GraphQLInput } from './internal/mutationInput';
|
|
4
|
+
import { QueryResult } from './internal/workspaceGateway';
|
|
5
|
+
export interface MCPServerRecord {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
/** Transport / server kind, e.g. `HTTP_JSON`. */
|
|
9
|
+
type: string;
|
|
10
|
+
status: string;
|
|
11
|
+
config: Record<string, unknown>;
|
|
12
|
+
credentialsHash?: string | null;
|
|
13
|
+
errorMessage?: string | null;
|
|
14
|
+
lastConnectedAt?: string | null;
|
|
15
|
+
lastErrorAt?: string | null;
|
|
16
|
+
deletedAt?: string | null;
|
|
17
|
+
metadata?: Record<string, unknown> | null;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
updatedAt: string;
|
|
20
|
+
createdById: string;
|
|
21
|
+
updatedById: string;
|
|
22
|
+
workspaceId: string;
|
|
23
|
+
}
|
|
24
|
+
export interface MCPToolRecord {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
inputSchema: Record<string, unknown>;
|
|
29
|
+
riskLevel: McpToolRiskLevel;
|
|
30
|
+
}
|
|
31
|
+
export interface MCPResourceRecord {
|
|
32
|
+
name: string;
|
|
33
|
+
uri: string;
|
|
34
|
+
description?: string | null;
|
|
35
|
+
mimeType?: string | null;
|
|
36
|
+
}
|
|
37
|
+
/** `CreateMCPConnectionInput` minus the `workspaceId` the hook supplies. */
|
|
38
|
+
export type CreateMCPServerVariables = Omit<GraphQLInput<CreateMcpConnectionInput>, 'workspaceId'>;
|
|
39
|
+
export interface UpdateMCPServerVariables {
|
|
40
|
+
serverId: string;
|
|
41
|
+
input: GraphQLInput<UpdateMcpConnectionInput>;
|
|
42
|
+
}
|
|
43
|
+
export interface UpdateMCPToolVariables {
|
|
44
|
+
toolId: string;
|
|
45
|
+
input: GraphQLInput<UpdateMcpToolInput>;
|
|
46
|
+
}
|
|
47
|
+
/** `CONNECTED` is the only status that means the server is usable right now. */
|
|
48
|
+
export declare function isMCPServerHealthy(status: string | null | undefined): boolean;
|
|
49
|
+
export declare function isMCPServerUnhealthy(status: string | null | undefined): boolean;
|
|
50
|
+
/** Endpoint the connection points at — the service stores it on the free-form config. */
|
|
51
|
+
export declare function mcpServerEndpoint(server: Pick<MCPServerRecord, 'config'>): string | undefined;
|
|
52
|
+
/** Optional human description the UI stores alongside the endpoint. */
|
|
53
|
+
export declare function mcpServerDescription(server: Pick<MCPServerRecord, 'config'>): string | undefined;
|
|
54
|
+
export declare const mcpServerKeys: {
|
|
55
|
+
all: readonly ["mcpServers"];
|
|
56
|
+
lists: () => readonly ["mcpServers", "list"];
|
|
57
|
+
list: (filter?: BaseFilter) => readonly ["mcpServers", "list", BaseFilter | undefined];
|
|
58
|
+
details: () => readonly ["mcpServers", "detail"];
|
|
59
|
+
detail: (id: string) => readonly ["mcpServers", "detail", string];
|
|
60
|
+
resources: (serverId?: string) => readonly ["mcpServers", "resources", string | undefined];
|
|
61
|
+
tools: (serverId?: string) => readonly ["mcpServers", "tools", string | undefined];
|
|
62
|
+
};
|
|
63
|
+
export declare function useMCPServers(filter?: BaseFilter): QueryResult<MCPServerRecord[]>;
|
|
64
|
+
export declare function useMCPServer(serverId: string | undefined): QueryResult<MCPServerRecord | null>;
|
|
65
|
+
export declare function useMCPTools(serverId: string | undefined): QueryResult<MCPToolRecord[]>;
|
|
66
|
+
export declare function useMCPResources(serverId: string | undefined): QueryResult<MCPResourceRecord[]>;
|
|
67
|
+
export declare function useCreateMCPServer(): readonly [(input: CreateMCPServerVariables) => Promise<MCPServerRecord>, import('./internal/workspaceGateway').MutationState<MCPServerRecord>];
|
|
68
|
+
export declare function useUpdateMCPServer(): readonly [(input: UpdateMCPServerVariables) => Promise<MCPServerRecord>, import('./internal/workspaceGateway').MutationState<MCPServerRecord>];
|
|
69
|
+
export declare function useDeleteMCPServer(): readonly [(input: string) => Promise<boolean>, import('./internal/workspaceGateway').MutationState<boolean>];
|
|
70
|
+
export declare function useTestMCPConnection(): readonly [(input: string) => Promise<boolean>, import('./internal/workspaceGateway').MutationState<boolean>];
|
|
71
|
+
export declare function useUpdateMCPTool(): readonly [(input: UpdateMCPToolVariables) => Promise<MCPToolRecord>, import('./internal/workspaceGateway').MutationState<MCPToolRecord>];
|