@burdenoff/microfe-botmanor 2026.1120.5 → 2026.1120.7
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/components/AssistantChannelPanel.js +3 -3
- package/dist/botlit/components/AssistantChannelPanel.js.map +1 -1
- package/dist/botlit/components/ChannelRoutesPanel.d.ts +9 -0
- package/dist/botlit/components/ChannelRoutesPanel.js +275 -0
- package/dist/botlit/components/ChannelRoutesPanel.js.map +1 -0
- package/dist/botlit/components/CreateChannelRouteDialog.d.ts +13 -0
- package/dist/botlit/components/CreateChannelRouteDialog.js +188 -0
- package/dist/botlit/components/CreateChannelRouteDialog.js.map +1 -0
- package/dist/botlit/hooks/index.d.ts +3 -3
- package/dist/botlit/hooks/index.js +19 -19
- package/dist/botlit/hooks/useAssistantChat.d.ts +32 -0
- package/dist/botlit/hooks/useAssistantChat.js +98 -0
- package/dist/botlit/hooks/useAssistantChat.js.map +1 -0
- package/dist/botlit/hooks/useBots.d.ts +5 -0
- package/dist/botlit/hooks/useBots.js +63 -50
- package/dist/botlit/hooks/useBots.js.map +1 -1
- package/dist/botlit/hooks/useChannels.d.ts +49 -23
- package/dist/botlit/hooks/useChannels.js +141 -135
- package/dist/botlit/hooks/useChannels.js.map +1 -1
- package/dist/botlit/pages/BotChannelsTab.js +12 -3
- package/dist/botlit/pages/BotChannelsTab.js.map +1 -1
- package/dist/botlit/pages/ChannelDetailPage.js +642 -776
- package/dist/botlit/pages/ChannelDetailPage.js.map +1 -1
- package/dist/botlit/pages/ChannelRoutesPage.js +22 -208
- package/dist/botlit/pages/ChannelRoutesPage.js.map +1 -1
- package/dist/botlit/pages/ChannelsPage.js +314 -251
- package/dist/botlit/pages/ChannelsPage.js.map +1 -1
- package/dist/botlit/pages/ChatPage.js +207 -83
- package/dist/botlit/pages/ChatPage.js.map +1 -1
- package/dist/botlit/utils/assistantAvailability.d.ts +34 -0
- package/dist/botlit/utils/assistantAvailability.js +24 -0
- package/dist/botlit/utils/assistantAvailability.js.map +1 -0
- package/dist/botlit/utils/channelConnectors.d.ts +13 -0
- package/dist/botlit/utils/channelConnectors.js +21 -1
- package/dist/botlit/utils/channelConnectors.js.map +1 -1
- package/dist/botlit/utils/errors.d.ts +8 -0
- package/dist/botlit/utils/errors.js +21 -1
- package/dist/botlit/utils/errors.js.map +1 -1
- package/dist/generated/wspace-operations.d.ts +200 -12
- package/dist/generated/wspace-operations.js +153 -110
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +40 -0
- package/dist/generated/wspace-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateChannelRouteDialog.js","names":["selectClassName","CreateChannelRouteDialog","props","CreateChannelRouteForm","t","useTr","idPrefix","useId","blank","useMemo","connectorId","form","setForm","useState","showErrors","setShowErrors","submitError","setSubmitError","connectors","useAllChannelConnectors","bots","useAllBots","createRoute","createState","useCreateChannelRoute","location","errors","hasErrors","isDirty","close","confirmAction","onOpenChange","submit","event","connector","row","bot","route","toast","onCreated","err","graphqlErrorMessage","fieldId","name","visibleError","ResponsiveDialog","next","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","FormField","Input","ResponsiveDialogFooter","Button"],"sources":["../../../src/botlit/components/CreateChannelRouteDialog.tsx"],"sourcesContent":["/**\n * Create Channel Route dialog (BOFF-12562)\n * @module botlit/components\n *\n * One create-route flow for every \"Create Route\" / \"Add Route\" entry point:\n * the Routes page, the Routes tab on /channels and a connector's detail page\n * (which passes its own connector). The user picks a connector, the location\n * on it (or `*` for every location) and the bot that answers there.\n *\n * It is a real form: Enter submits, missing values are named inline, the\n * service's own message (unknown bot, duplicate location) is shown in an\n * alert, and closing with typed values asks first.\n */\n\nimport type { FC, FormEvent } from 'react';\nimport { useId, useMemo, useState } from 'react';\nimport {\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n} from '@burdenoff/fe-libs/ui';\nimport { toast } from 'sonner';\nimport { useTr } from '../../shared/hooks/useTr';\nimport {\n useAllBots,\n useAllChannelConnectors,\n useCreateChannelRoute,\n type ChannelRouteRecord,\n} from '../hooks';\nimport { confirmAction } from '../utils/confirmAction';\nimport { graphqlErrorMessage } from '../utils/errors';\nimport { Button } from './Button';\nimport { FormField, Input } from './Input';\n\n/** The service stores at most this many characters for a location. */\nexport const ROUTE_LOCATION_MAX_LENGTH = 500;\n\ninterface RouteForm {\n connectorId: string;\n locationId: string;\n locationName: string;\n botId: string;\n isActive: boolean;\n}\n\ninterface CreateChannelRouteDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Set when the dialog is opened from one connector: the route is for it. */\n connectorId?: string;\n onCreated?: (route: ChannelRouteRecord) => void;\n}\n\nconst selectClassName =\n 'flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm';\n\nexport const CreateChannelRouteDialog: FC<CreateChannelRouteDialogProps> = (props) =>\n // Mounted only while open, so every opening starts from a blank form.\n props.open ? <CreateChannelRouteForm {...props} /> : null;\n\nconst CreateChannelRouteForm: FC<CreateChannelRouteDialogProps> = ({\n onOpenChange,\n connectorId,\n onCreated,\n}) => {\n const t = useTr();\n const idPrefix = useId();\n const blank = useMemo<RouteForm>(\n () => ({\n connectorId: connectorId ?? '',\n locationId: '*',\n locationName: '',\n botId: '',\n isActive: true,\n }),\n [connectorId]\n );\n const [form, setForm] = useState<RouteForm>(blank);\n const [showErrors, setShowErrors] = useState(false);\n const [submitError, setSubmitError] = useState<string | null>(null);\n const connectors = useAllChannelConnectors();\n const bots = useAllBots();\n const [createRoute, createState] = useCreateChannelRoute();\n\n const location = form.locationId.trim();\n const errors: Partial<Record<keyof RouteForm, string>> = {};\n if (!form.connectorId) {\n errors.connectorId = t(\n 'botlit.channelRoutes.create.errors.connectorRequired',\n 'Choose the channel connector this route belongs to.'\n );\n }\n if (!location) {\n errors.locationId = t(\n 'botlit.channelRoutes.create.errors.locationRequired',\n 'Enter the location this route answers, or * for every location.'\n );\n } else if (location.length > ROUTE_LOCATION_MAX_LENGTH) {\n errors.locationId = t(\n 'botlit.channelRoutes.create.errors.locationTooLong',\n 'The location can be at most {{max}} characters.',\n { max: ROUTE_LOCATION_MAX_LENGTH }\n );\n }\n if (!form.botId) {\n errors.botId = t(\n 'botlit.channelRoutes.create.errors.botRequired',\n 'Choose the bot that answers messages on this location.'\n );\n }\n const hasErrors = Object.keys(errors).length > 0;\n const isDirty = JSON.stringify(form) !== JSON.stringify(blank);\n\n const close = async () => {\n if (isDirty && !createState.loading) {\n const discard = await confirmAction({\n title: t('botlit.channelRoutes.create.discard.title', 'Discard this route?'),\n message: t(\n 'botlit.channelRoutes.create.discard.message',\n 'The route has not been created. Close the form and lose what you entered?'\n ),\n confirmLabel: t('botlit.common.discard', 'Discard'),\n cancelLabel: t('botlit.common.keepEditing', 'Keep editing'),\n });\n if (!discard) return;\n }\n onOpenChange(false);\n };\n\n const submit = async (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n setShowErrors(true);\n setSubmitError(null);\n if (hasErrors || createState.loading) return;\n const connector = connectors.data.find((row) => row.id === form.connectorId);\n const bot = bots.data.find((row) => row.id === form.botId);\n try {\n const route = await createRoute({\n connectorId: form.connectorId,\n locationId: location,\n appId: form.botId,\n isActive: form.isActive,\n metadata: {\n locationName: form.locationName.trim() || location,\n appName: bot?.name,\n connectorName: connector?.name,\n },\n });\n toast.success(\n t('botlit.channelRoutes.create.success', 'Route created: {{location}} goes to {{bot}}', {\n location: form.locationName.trim() || location,\n bot: bot?.name ?? form.botId,\n })\n );\n onOpenChange(false);\n if (route) onCreated?.(route);\n } catch (err) {\n setSubmitError(\n graphqlErrorMessage(\n err,\n t('botlit.channelRoutes.create.errors.failed', 'The route could not be created.')\n )\n );\n }\n };\n\n const fieldId = (name: string) => `${idPrefix}-${name}`;\n const visibleError = (name: keyof RouteForm) => (showErrors ? errors[name] : undefined);\n\n return (\n <ResponsiveDialog open onOpenChange={(next) => (next ? undefined : void close())}>\n <ResponsiveDialogContent>\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>\n {t('botlit.channelRoutes.create.title', 'Create route')}\n </ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n {t(\n 'botlit.channelRoutes.create.description',\n 'Choose which bot answers messages that arrive at a location on a channel connector.'\n )}\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n <form noValidate className=\"space-y-4\" onSubmit={(event) => void submit(event)}>\n {connectorId === undefined && (\n <FormField\n label={t('botlit.channelRoutes.create.connector', 'Channel connector')}\n htmlFor={fieldId('connector')}\n required\n error={visibleError('connectorId')}\n >\n <select\n id={fieldId('connector')}\n className={selectClassName}\n value={form.connectorId}\n aria-invalid={Boolean(visibleError('connectorId'))}\n onChange={(e) => setForm({ ...form, connectorId: e.target.value })}\n >\n <option value=\"\">\n {connectors.loading\n ? t('botlit.common.loading', 'Loading...')\n : connectors.data.length > 0\n ? t(\n 'botlit.channelRoutes.create.connectorPlaceholder',\n 'Select a connector...'\n )\n : t(\n 'botlit.channelRoutes.create.noConnectors',\n 'No connectors yet. Add a channel first.'\n )}\n </option>\n {connectors.data.map((connector) => (\n <option key={connector.id} value={connector.id}>\n {connector.name}\n </option>\n ))}\n </select>\n </FormField>\n )}\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <FormField\n label={t('botlit.channelRoutes.create.location', 'Location ID')}\n htmlFor={fieldId('location')}\n description={t(\n 'botlit.channelRoutes.create.locationHint',\n '* for every location, or a platform channel ID'\n )}\n required\n error={visibleError('locationId')}\n >\n <Input\n id={fieldId('location')}\n value={form.locationId}\n maxLength={ROUTE_LOCATION_MAX_LENGTH}\n aria-invalid={Boolean(visibleError('locationId'))}\n onChange={(e) => setForm({ ...form, locationId: e.target.value })}\n />\n </FormField>\n <FormField\n label={t('botlit.channelRoutes.create.locationName', 'Location name')}\n htmlFor={fieldId('location-name')}\n description={t('botlit.channelRoutes.create.locationNameHint', 'Optional label')}\n >\n <Input\n id={fieldId('location-name')}\n value={form.locationName}\n maxLength={200}\n onChange={(e) => setForm({ ...form, locationName: e.target.value })}\n />\n </FormField>\n </div>\n <FormField\n label={t('botlit.channelRoutes.create.bot', 'Bot')}\n htmlFor={fieldId('bot')}\n required\n error={visibleError('botId')}\n >\n <select\n id={fieldId('bot')}\n className={selectClassName}\n value={form.botId}\n aria-invalid={Boolean(visibleError('botId'))}\n onChange={(e) => setForm({ ...form, botId: e.target.value })}\n >\n <option value=\"\">\n {bots.loading\n ? t('botlit.common.loading', 'Loading...')\n : bots.data.length > 0\n ? t('botlit.channelRoutes.create.botPlaceholder', 'Select a bot...')\n : t('botlit.channelRoutes.create.noBots', 'No bots yet. Create a bot first.')}\n </option>\n {bots.data.map((bot) => (\n <option key={bot.id} value={bot.id}>\n {bot.name}\n </option>\n ))}\n </select>\n </FormField>\n <label className=\"flex items-start gap-2 text-sm\">\n <input\n type=\"checkbox\"\n className=\"mt-1\"\n checked={form.isActive}\n onChange={(e) => setForm({ ...form, isActive: e.target.checked })}\n />\n <span>\n <span className=\"font-medium\">\n {t('botlit.channelRoutes.create.active', 'Turn the route on now')}\n </span>\n <span className=\"block text-text-secondary\">\n {t(\n 'botlit.channelRoutes.create.activeHint',\n 'A route that is off is ignored until you turn it on.'\n )}\n </span>\n </span>\n </label>\n {(connectors.error || bots.error) && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {t(\n 'botlit.channelRoutes.create.errors.optionsUnavailable',\n 'Connectors or bots could not be loaded. Close the form and try again.'\n )}\n </p>\n )}\n {submitError && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {submitError}\n </p>\n )}\n {showErrors && hasErrors && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {t(\n 'botlit.channelRoutes.create.errors.summary',\n 'Fill in the highlighted fields to create the route.'\n )}\n </p>\n )}\n <ResponsiveDialogFooter>\n <Button type=\"button\" variant=\"outline\" onClick={() => void close()}>\n {t('botlit.common.cancel', 'Cancel')}\n </Button>\n <Button type=\"submit\" isLoading={createState.loading}>\n {t('botlit.channelRoutes.create.submit', 'Create route')}\n </Button>\n </ResponsiveDialogFooter>\n </form>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAwDA,IAAMA,IACJ,4FAEWC,KAA+D,MAE1EC,EAAM,OAAO,kBAACC,GAAD,EAAwB,GAAID,EAAQ,CAAA,IAAI,MAEjDC,KAA6D,EACjE,iBACA,gBACA,mBACI;CACJ,IAAMC,IAAIC,EAAM,GACVC,IAAWC,EAAM,GACjBC,IAAQC,SACL;EACL,aAAaC,KAAe;EAC5B,YAAY;EACZ,cAAc;EACd,OAAO;EACP,UAAU;CACZ,IACA,CAACA,CAAW,CACd,GACM,CAACC,GAAMC,KAAWC,EAAoBL,CAAK,GAC3C,CAACM,GAAYC,KAAiBF,EAAS,EAAK,GAC5C,CAACG,GAAaC,KAAkBJ,EAAwB,IAAI,GAC5DK,IAAaC,EAAwB,GACrCC,IAAOC,EAAW,GAClB,CAACC,GAAaC,KAAeC,EAAsB,GAEnDC,IAAWd,EAAK,WAAW,KAAK,GAChCe,IAAmD,CAAC;CAmB1D,AAlBKf,EAAK,gBACR,EAAO,cAAcP,EACnB,wDACA,qDACF,IAEGqB,IAKMA,EAAS,SAAA,QAClB,EAAO,aAAarB,EAClB,sDACA,mDACA,EAAE,KAAA,IAA+B,CACnC,KATA,EAAO,aAAaA,EAClB,uDACA,iEACF,GAQGO,EAAK,UACR,EAAO,QAAQP,EACb,kDACA,wDACF;CAEF,IAAMuB,IAAY,OAAO,KAAKD,CAAM,CAAC,CAAC,SAAS,GACzCE,IAAU,KAAK,UAAUjB,CAAI,MAAM,KAAK,UAAUH,CAAK,GAEvDqB,IAAQ,YAAY;EACxB,CAAI,MAAYN,EAAY,WAUrB,MATiBO,EAA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AAuB;KAC5D,CAAA,GACN,kBAAC,QAAD;MAAM,WAAU;MACb,UAAAA,EACC,0CACA,sDACF;KACI,CAAA,CACF,EAAA,CAAA,CACD;;KACLc,EAAW,SAASE,EAAK,UACzB,kBAAC,KAAD;KAAG,MAAK;KAAQ,WAAU;KACvB,UAAAhB,EACC,yDACA,uEACF;IACC,CAAA;IAEJY,KACC,kBAAC,KAAD;KAAG,MAAK;KAAQ,WAAU;KACvB,UAAAA;IACA,CAAA;IAEJF,KAAca,KACb,kBAAC,KAAD;KAAG,MAAK;KAAQ,WAAU;KACvB,UAAAvB,EACC,8CACA,qDACF;IACC,CAAA;IAEL,kBAACiD,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD;KAAQ,MAAK;KAAS,SAAQ;KAAU,eAAe,KAAKzB,EAAM;KAC/D,UAAAzB,EAAE,wBAAwB,QAAQ;IAC7B,CAAA,GACR,kBAACkD,GAAD;KAAQ,MAAK;KAAS,WAAW/B,EAAY;KAC1C,UAAAnB,EAAE,sCAAsC,cAAc;IACjD,CAAA,CACc,EAAA,CAAA;GACpB;EACiB,CAAA,CAAA,EAAA,CAAA;CACT,CAAA;AAEtB"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Hooks Index
|
|
3
3
|
* @module botlit/hooks
|
|
4
4
|
*/
|
|
5
|
-
export { useBots, useBotAppCounts, useBot, useCreateBot, useUpdateBot, useDeleteBot, botKeys, } from './useBots';
|
|
5
|
+
export { useBots, useAllBots, useBotAppCounts, useBot, useCreateBot, useUpdateBot, useDeleteBot, botKeys, } from './useBots';
|
|
6
6
|
export { useAgents, useAgentCounts, useAgent, useCreateAgent, useUpdateAgent, useDeleteAgent, agentKeys, } from './useAgents';
|
|
7
7
|
export { useKnowledgeBases, useKnowledgeBase, useKnowledgeDocuments, useCreateKnowledgeBase, useUpdateKnowledgeBase, useDeleteKnowledgeBase, useRebuildKnowledgeBaseIndex, knowledgeBaseKeys, } from './useKnowledgeBases';
|
|
8
8
|
export type { KnowledgeBaseRecord, KnowledgeDocumentRecord } from './useKnowledgeBases';
|
|
@@ -12,8 +12,8 @@ export { useMCPServers, useMCPServer, useMCPResources, useMCPTools, useCreateMCP
|
|
|
12
12
|
export type { MCPServerRecord, MCPToolRecord, MCPResourceRecord } from './useMCPServers';
|
|
13
13
|
export { useA2AAgents, useA2AAgent, useRegisterA2AAgent, useUpdateA2AAgent, useDeleteA2AAgent, useValidateA2AAgent, validateAgentCard, a2aAgentSkillCount, a2aKeys, } from './useA2A';
|
|
14
14
|
export type { A2AAgentRecord } from './useA2A';
|
|
15
|
-
export { useChannelConnectors, useAllChannelConnectors, useChannelConnector, useCreateChannelConnector, useUpdateChannelConnector, useDeleteChannelConnector, useFindChannelConnector, useChannelRoutes, useBotChannelRoutes, useChannelRoute, useCreateChannelRoute, useUpdateChannelRoute, useDeleteChannelRoute, routeMetadataString, channelKeys, } from './useChannels';
|
|
16
|
-
export type { ChannelConnectorRecord, ChannelRouteRecord } from './useChannels';
|
|
15
|
+
export { useChannelConnectors, useAllChannelConnectors, useChannelConnector, useCreateChannelConnector, useUpdateChannelConnector, useDeleteChannelConnector, useFindChannelConnector, useChannelRoutes, useAllChannelRoutes, useChannelOverview, useBotChannelRoutes, useChannelRoute, useCreateChannelRoute, useUpdateChannelRoute, useDeleteChannelRoute, routeMetadataString, channelKeys, } from './useChannels';
|
|
16
|
+
export type { ChannelConnectorRecord, ChannelRouteRecord, ChannelOverview, ChannelRouteListFilter, } from './useChannels';
|
|
17
17
|
export { PLATFORM_CREDENTIALS, connectorPlatform, generateSigningSecret, validateCredentials, useActiveOrganizationId, useInboundChannel, useProvisionChannel, } from './useChannelSetup';
|
|
18
18
|
export type { CredentialFieldDefinition, PlatformCredentialDefinition, InboundChannelData, } from './useChannelSetup';
|
|
19
19
|
export { usePolicies, usePolicy, useCreatePolicy, useUpdatePolicy, useDeletePolicy, usePoliciesByType, policyKeys, } from './usePolicies';
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useAgents as
|
|
1
|
+
import { useAllBots as e, useBots as t } from "./useBots.js";
|
|
2
|
+
import { useAgents as n } from "./useAgents.js";
|
|
3
3
|
import "./useKnowledgeBases.js";
|
|
4
|
-
import { useRetrievalProfiles as
|
|
5
|
-
import { isMCPServerHealthy as
|
|
6
|
-
import { a2aAgentSkillCount as
|
|
7
|
-
import { routeMetadataString as
|
|
8
|
-
import { PLATFORM_CREDENTIALS as
|
|
9
|
-
import { useCreatePolicy as
|
|
10
|
-
import { useApplyRetention as
|
|
11
|
-
import { useCreateSkill as
|
|
12
|
-
import { promptTemplateVariables as
|
|
13
|
-
import { useAgentBindings as
|
|
14
|
-
import { summariseExecutions as
|
|
15
|
-
import { buildBucketTree as
|
|
16
|
-
import { storePackageDescription as
|
|
4
|
+
import { useRetrievalProfiles as r } from "./useRetrievalProfiles.js";
|
|
5
|
+
import { isMCPServerHealthy as i, mcpServerDescription as a, mcpServerEndpoint as o, useCreateMCPServer as s, useDeleteMCPServer as c, useMCPResources as l, useMCPServer as u, useMCPTools as d, useTestMCPConnection as f, useUpdateMCPServer as p, useUpdateMCPTool as m } from "./useMCPServers.js";
|
|
6
|
+
import { a2aAgentSkillCount as h, useA2AAgents as g } from "./useA2A.js";
|
|
7
|
+
import { routeMetadataString as _, useAllChannelConnectors as v, useAllChannelRoutes as y, useBotChannelRoutes as b, useChannelConnector as x, useChannelConnectors as S, useChannelOverview as C, useChannelRoutes as w, useCreateChannelConnector as T, useCreateChannelRoute as E, useDeleteChannelConnector as D, useDeleteChannelRoute as O, useFindChannelConnector as k, useUpdateChannelConnector as A, useUpdateChannelRoute as j } from "./useChannels.js";
|
|
8
|
+
import { PLATFORM_CREDENTIALS as M, connectorPlatform as N, useActiveOrganizationId as P, useInboundChannel as F, useProvisionChannel as I, validateCredentials as L } from "./useChannelSetup.js";
|
|
9
|
+
import { useCreatePolicy as R, useDeletePolicy as z, usePolicies as B, usePolicy as V, useUpdatePolicy as H } from "./usePolicies.js";
|
|
10
|
+
import { useApplyRetention as U, useRetentionStatus as W } from "./useRetention.js";
|
|
11
|
+
import { useCreateSkill as G, useDeleteSkill as K, useSkill as q, useSkills as J, useUpdateSkill as Y } from "./useSkills.js";
|
|
12
|
+
import { promptTemplateVariables as X, useCreatePromptTemplate as Z, useDeletePromptTemplate as Q, usePromptTemplate as $, usePromptTemplates as ee, useRenderPromptTemplate as te, useUpdatePromptTemplate as ne } from "./usePromptTemplates.js";
|
|
13
|
+
import { useAgentBindings as re, usePromptTemplateVersions as ie, useSavePromptTemplateVersion as ae, useSetAgentBindings as oe, useTestPromptTemplate as se } from "./useAgentBindings.js";
|
|
14
|
+
import { summariseExecutions as ce, useExecutions as le } from "./useExecutions.js";
|
|
15
|
+
import { buildBucketTree as ue, searchTreeRows as de, useAllBuckets as fe, useBucket as pe, useBucketBranch as me, useBucketContents as he, useBucketCount as ge, useBucketSearch as _e, useBuckets as ve, useChildBuckets as ye, useCreateBucket as be, useDeleteBucket as xe, useUpdateBucket as Se } from "./useBuckets.js";
|
|
16
|
+
import { storePackageDescription as Ce, storePackageName as we, useInstallPackage as Te, useInstalledPackageCount as Ee, useInstalledPackages as De, usePinPackageVersion as Oe, useStorePackage as ke, useStorePackageCount as Ae, useStorePackages as je, useUninstallPackage as Me, useUpdateInstalledPackage as Ne } from "./useStore.js";
|
|
17
17
|
import "./useLLMProviders.js";
|
|
18
|
-
import { useGlobalChannels as
|
|
19
|
-
import { useConfigureSupervisor as
|
|
20
|
-
import { useAcceptHandoff as
|
|
21
|
-
export {
|
|
18
|
+
import { useGlobalChannels as Pe, useInitiateSlackConnect as Fe, useLinkIntegrationConnection as Ie, useMyUserPlatformConnection as Le, useRevokeSlackConnection as Re, useToggleSlackNotifications as ze } from "./useUserPlatformConnection.js";
|
|
19
|
+
import { useConfigureSupervisor as Be, useRunSupervisorNow as Ve, useSupervisorConfig as He, useSupervisorRuns as Ue } from "./useAiOperations.js";
|
|
20
|
+
import { useAcceptHandoff as We, useHandoffConfig as Ge, useHandoffQueue as Ke, useRejectHandoff as qe, useReleaseHandoff as Je, useResolveHandoff as Ye, useUpsertHandoffConfig as Xe } from "./useHandoffs.js";
|
|
21
|
+
export { M as PLATFORM_CREDENTIALS, h as a2aAgentSkillCount, ue as buildBucketTree, N as connectorPlatform, i as isMCPServerHealthy, a as mcpServerDescription, o as mcpServerEndpoint, X as promptTemplateVariables, _ as routeMetadataString, de as searchTreeRows, Ce as storePackageDescription, we as storePackageName, ce as summariseExecutions, g as useA2AAgents, We as useAcceptHandoff, P as useActiveOrganizationId, re as useAgentBindings, n as useAgents, e as useAllBots, fe as useAllBuckets, v as useAllChannelConnectors, y as useAllChannelRoutes, U as useApplyRetention, b as useBotChannelRoutes, t as useBots, pe as useBucket, me as useBucketBranch, he as useBucketContents, ge as useBucketCount, _e as useBucketSearch, ve as useBuckets, x as useChannelConnector, S as useChannelConnectors, C as useChannelOverview, w as useChannelRoutes, ye as useChildBuckets, Be as useConfigureSupervisor, be as useCreateBucket, T as useCreateChannelConnector, E as useCreateChannelRoute, s as useCreateMCPServer, R as useCreatePolicy, Z as useCreatePromptTemplate, G as useCreateSkill, xe as useDeleteBucket, D as useDeleteChannelConnector, O as useDeleteChannelRoute, c as useDeleteMCPServer, z as useDeletePolicy, Q as useDeletePromptTemplate, K as useDeleteSkill, le as useExecutions, k as useFindChannelConnector, Pe as useGlobalChannels, Ge as useHandoffConfig, Ke as useHandoffQueue, F as useInboundChannel, Fe as useInitiateSlackConnect, Te as useInstallPackage, Ee as useInstalledPackageCount, De as useInstalledPackages, Ie as useLinkIntegrationConnection, l as useMCPResources, u as useMCPServer, d as useMCPTools, Le as useMyUserPlatformConnection, Oe as usePinPackageVersion, B as usePolicies, V as usePolicy, $ as usePromptTemplate, ie as usePromptTemplateVersions, ee as usePromptTemplates, I as useProvisionChannel, qe as useRejectHandoff, Je as useReleaseHandoff, te as useRenderPromptTemplate, Ye as useResolveHandoff, W as useRetentionStatus, r as useRetrievalProfiles, Re as useRevokeSlackConnection, Ve as useRunSupervisorNow, ae as useSavePromptTemplateVersion, oe as useSetAgentBindings, q as useSkill, J as useSkills, ke as useStorePackage, Ae as useStorePackageCount, je as useStorePackages, He as useSupervisorConfig, Ue as useSupervisorRuns, f as useTestMCPConnection, se as useTestPromptTemplate, ze as useToggleSlackNotifications, Me as useUninstallPackage, Se as useUpdateBucket, A as useUpdateChannelConnector, j as useUpdateChannelRoute, Ne as useUpdateInstalledPackage, p as useUpdateMCPServer, m as useUpdateMCPTool, H as useUpdatePolicy, ne as useUpdatePromptTemplate, Y as useUpdateSkill, Xe as useUpsertHandoffConfig, L as validateCredentials };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ChatAssistantsQuery } from '../../generated/wspace-operations';
|
|
2
|
+
import { QueryResult } from './internal/workspaceGateway';
|
|
3
|
+
/** The product id saved BotManor agent chats are stored under. */
|
|
4
|
+
export declare const BOTMANOR_ASSISTANT_PRODUCT_ID = "botmanor";
|
|
5
|
+
export type ChatAssistantRecord = ChatAssistantsQuery['listBotmanorAgents'][number];
|
|
6
|
+
/**
|
|
7
|
+
* Every agent in the workspace, with the fields that decide whether a saved
|
|
8
|
+
* chat can use it. Not filtered by status, so an inactive agent still reaches
|
|
9
|
+
* the picker's "not available" group with its reason.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useChatAssistants(): QueryResult<ChatAssistantRecord[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Days after which the caller's saved conversations are retired: a number,
|
|
14
|
+
* null when no period applies, or undefined until the server has answered.
|
|
15
|
+
* Undefined is never shown as "no period" (BOFF-12699).
|
|
16
|
+
*/
|
|
17
|
+
export declare function useMyAssistantRetention(): QueryResult<number | null | undefined>;
|
|
18
|
+
export interface AssistantConversationSummary {
|
|
19
|
+
clientConversationId: string;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The caller's own saved conversations with one agent, newest first. Follows
|
|
24
|
+
* `nextCursor` until the last page, so older conversations can be deleted too.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useMyAssistantConversations(agentId: string | undefined): QueryResult<AssistantConversationSummary[]>;
|
|
27
|
+
/** Deletes one of the caller's saved conversations. Resolves only when the server confirmed it. */
|
|
28
|
+
export declare function useDeleteMyAssistantConversation(): {
|
|
29
|
+
remove: (clientConversationId: string) => Promise<void>;
|
|
30
|
+
deletingId: string | null;
|
|
31
|
+
error: Error | undefined;
|
|
32
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ChatAssistantsDocument as e, MyAssistantConversationRetentionDocument as t, MyAssistantWorkflowConversationsDocument as n, RetireMyAssistantConversationDocument as r } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { useWorkspaceAllPagesQuery as i, useWorkspaceClient as a, useWorkspaceId as o, useWorkspaceMutation as s, useWorkspaceQuery as c } from "./internal/workspaceGateway.js";
|
|
3
|
+
import { useCallback as l, useEffect as u, useMemo as d, useState as f } from "react";
|
|
4
|
+
// src/botlit/hooks/useAssistantChat.ts
|
|
5
|
+
var p = "botmanor", m = {}, h = 100, g = [];
|
|
6
|
+
function _() {
|
|
7
|
+
let t = o(), n = d(() => ({ filters: { workspaceId: t } }), [t]);
|
|
8
|
+
return i({
|
|
9
|
+
document: e,
|
|
10
|
+
variables: n,
|
|
11
|
+
pageSize: h,
|
|
12
|
+
extractRows: (e) => e?.listBotmanorAgents ?? [],
|
|
13
|
+
select: (e) => e,
|
|
14
|
+
fallback: g,
|
|
15
|
+
enabled: !!t,
|
|
16
|
+
errorMessage: "Failed to load assistants"
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function v() {
|
|
20
|
+
let e = o();
|
|
21
|
+
return c({
|
|
22
|
+
document: t,
|
|
23
|
+
variables: m,
|
|
24
|
+
select: (e) => e ? e.myAssistantConversationRetention.conversationRetentionDays ?? null : void 0,
|
|
25
|
+
fallback: void 0,
|
|
26
|
+
enabled: !!e,
|
|
27
|
+
errorMessage: "Failed to load the conversation retention"
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
var y = [], b = 50;
|
|
31
|
+
function x(e) {
|
|
32
|
+
let t = o(), r = a(), i = !!(t && e), [s, c] = f(y), [d, p] = f(i), [m, h] = f(), g = l(async () => {
|
|
33
|
+
if (!i) c(y), h(void 0), p(!1);
|
|
34
|
+
else {
|
|
35
|
+
p(!0), h(void 0);
|
|
36
|
+
try {
|
|
37
|
+
let t = [], i = null;
|
|
38
|
+
for (let a = 0; a < b; a += 1) {
|
|
39
|
+
let a = await r.query({
|
|
40
|
+
query: n,
|
|
41
|
+
variables: {
|
|
42
|
+
agentId: e,
|
|
43
|
+
after: i
|
|
44
|
+
},
|
|
45
|
+
fetchPolicy: "network-only"
|
|
46
|
+
});
|
|
47
|
+
if (a.error) throw a.error;
|
|
48
|
+
let o = a.data?.myAssistantWorkflowConversations;
|
|
49
|
+
if (!o) throw Error("Failed to load your conversations");
|
|
50
|
+
if (t.push(...o.nodes), i = o.nextCursor ?? null, !i) break;
|
|
51
|
+
}
|
|
52
|
+
c(t);
|
|
53
|
+
} catch (e) {
|
|
54
|
+
h(e instanceof Error ? e : Error("Failed to load your conversations", { cause: e }));
|
|
55
|
+
} finally {
|
|
56
|
+
p(!1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, [
|
|
60
|
+
r,
|
|
61
|
+
i,
|
|
62
|
+
e
|
|
63
|
+
]);
|
|
64
|
+
return u(() => {
|
|
65
|
+
g();
|
|
66
|
+
}, [g]), {
|
|
67
|
+
data: s,
|
|
68
|
+
loading: d,
|
|
69
|
+
error: m,
|
|
70
|
+
refetch: g
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function S() {
|
|
74
|
+
let [e, t] = s({
|
|
75
|
+
document: r,
|
|
76
|
+
variables: (e) => ({
|
|
77
|
+
productId: p,
|
|
78
|
+
clientConversationId: e
|
|
79
|
+
}),
|
|
80
|
+
select: (e) => e?.retireMyGroundedAssistantConversation,
|
|
81
|
+
errorMessage: "Failed to delete the conversation"
|
|
82
|
+
}), [n, i] = f(null);
|
|
83
|
+
return {
|
|
84
|
+
remove: l(async (t) => {
|
|
85
|
+
i(t);
|
|
86
|
+
try {
|
|
87
|
+
if (!await e(t)) throw Error("Failed to delete the conversation");
|
|
88
|
+
} finally {
|
|
89
|
+
i(null);
|
|
90
|
+
}
|
|
91
|
+
}, [e]),
|
|
92
|
+
deletingId: n,
|
|
93
|
+
error: t.error
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export { p as BOTMANOR_ASSISTANT_PRODUCT_ID, _ as useChatAssistants, S as useDeleteMyAssistantConversation, x as useMyAssistantConversations, v as useMyAssistantRetention };
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=useAssistantChat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAssistantChat.js","names":["BOTMANOR_ASSISTANT_PRODUCT_ID","NO_VARIABLES","PAGE_SIZE","NO_ASSISTANTS","useChatAssistants","workspaceId","useWorkspaceId","variables","useMemo","useWorkspaceAllPagesQuery","ChatAssistantsDocument","data","rows","useMyAssistantRetention","useWorkspaceQuery","MyAssistantConversationRetentionDocument","NO_CONVERSATIONS","MAX_CONVERSATION_PAGES","useMyAssistantConversations","client","useWorkspaceClient","enabled","agentId","setData","useState","loading","setLoading","error","setError","refetch","useCallback","after","page","result","MyAssistantWorkflowConversationsDocument","connection","cause","useEffect","useDeleteMyAssistantConversation","retire","state","useWorkspaceMutation","RetireMyAssistantConversationDocument","deletingId","setDeletingId","clientConversationId"],"sources":["../../../src/botlit/hooks/useAssistantChat.ts"],"sourcesContent":["/**\n * AI Chat page hooks (BOFF-12695)\n * @module botlit/hooks\n *\n * The assistants a saved chat can use, the retention that applies to the\n * caller's saved conversations, and the caller's own conversations so they\n * can be deleted. Conversations are owner-scoped on the server: the caller\n * only ever sees and deletes their own.\n */\n\nimport { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport {\n ChatAssistantsDocument,\n MyAssistantConversationRetentionDocument,\n MyAssistantWorkflowConversationsDocument,\n RetireMyAssistantConversationDocument,\n type ChatAssistantsQuery,\n type MyAssistantConversationRetentionQuery,\n type MyAssistantWorkflowConversationsQuery,\n type RetireMyAssistantConversationMutation,\n} from '../../generated/wspace-operations';\nimport {\n useWorkspaceAllPagesQuery,\n useWorkspaceClient,\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\n/** The product id saved BotManor agent chats are stored under. */\nexport const BOTMANOR_ASSISTANT_PRODUCT_ID = 'botmanor';\n\nconst NO_VARIABLES: Record<string, unknown> = {};\nconst PAGE_SIZE = 100;\n\nexport type ChatAssistantRecord = ChatAssistantsQuery['listBotmanorAgents'][number];\n\nconst NO_ASSISTANTS: ChatAssistantRecord[] = [];\n\n/**\n * Every agent in the workspace, with the fields that decide whether a saved\n * chat can use it. Not filtered by status, so an inactive agent still reaches\n * the picker's \"not available\" group with its reason.\n */\nexport function useChatAssistants(): QueryResult<ChatAssistantRecord[]> {\n const workspaceId = useWorkspaceId();\n const variables = useMemo(() => ({ filters: { workspaceId } }), [workspaceId]);\n return useWorkspaceAllPagesQuery<ChatAssistantsQuery, ChatAssistantRecord, ChatAssistantRecord[]>(\n {\n document: ChatAssistantsDocument,\n variables,\n pageSize: PAGE_SIZE,\n extractRows: (data) => data?.listBotmanorAgents ?? [],\n select: (rows) => rows,\n fallback: NO_ASSISTANTS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load assistants',\n }\n );\n}\n\n/**\n * Days after which the caller's saved conversations are retired: a number,\n * null when no period applies, or undefined until the server has answered.\n * Undefined is never shown as \"no period\" (BOFF-12699).\n */\nexport function useMyAssistantRetention(): QueryResult<number | null | undefined> {\n const workspaceId = useWorkspaceId();\n return useWorkspaceQuery<MyAssistantConversationRetentionQuery, number | null | undefined>({\n document: MyAssistantConversationRetentionDocument,\n variables: NO_VARIABLES,\n select: (data) =>\n data ? (data.myAssistantConversationRetention.conversationRetentionDays ?? null) : undefined,\n fallback: undefined,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load the conversation retention',\n });\n}\n\nexport interface AssistantConversationSummary {\n clientConversationId: string;\n createdAt: string;\n}\n\nconst NO_CONVERSATIONS: AssistantConversationSummary[] = [];\n\n/** Upper bound on pages followed, so a misbehaving cursor cannot loop forever. */\nconst MAX_CONVERSATION_PAGES = 50;\n\n/**\n * The caller's own saved conversations with one agent, newest first. Follows\n * `nextCursor` until the last page, so older conversations can be deleted too.\n */\nexport function useMyAssistantConversations(\n agentId: string | undefined\n): QueryResult<AssistantConversationSummary[]> {\n const workspaceId = useWorkspaceId();\n const client = useWorkspaceClient();\n const enabled = Boolean(workspaceId && agentId);\n const [data, setData] = useState<AssistantConversationSummary[]>(NO_CONVERSATIONS);\n const [loading, setLoading] = useState(enabled);\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!enabled) {\n setData(NO_CONVERSATIONS);\n setError(undefined);\n setLoading(false);\n return;\n }\n setLoading(true);\n setError(undefined);\n try {\n const rows: AssistantConversationSummary[] = [];\n let after: string | null = null;\n for (let page = 0; page < MAX_CONVERSATION_PAGES; page += 1) {\n const result: { data?: MyAssistantWorkflowConversationsQuery; error?: Error } =\n await client.query<MyAssistantWorkflowConversationsQuery>({\n query: MyAssistantWorkflowConversationsDocument,\n variables: { agentId, after },\n fetchPolicy: 'network-only',\n });\n if (result.error) throw result.error;\n const connection:\n MyAssistantWorkflowConversationsQuery['myAssistantWorkflowConversations'] | undefined =\n result.data?.myAssistantWorkflowConversations;\n if (!connection) throw new Error('Failed to load your conversations');\n rows.push(...connection.nodes);\n after = connection.nextCursor ?? null;\n if (!after) break;\n }\n setData(rows);\n } catch (cause) {\n setError(\n cause instanceof Error ? cause : new Error('Failed to load your conversations', { cause })\n );\n } finally {\n setLoading(false);\n }\n }, [client, enabled, agentId]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\n/** Deletes one of the caller's saved conversations. Resolves only when the server confirmed it. */\nexport function useDeleteMyAssistantConversation() {\n const [retire, state] = useWorkspaceMutation<\n RetireMyAssistantConversationMutation,\n string,\n boolean\n >({\n document: RetireMyAssistantConversationDocument,\n variables: (clientConversationId) => ({\n productId: BOTMANOR_ASSISTANT_PRODUCT_ID,\n clientConversationId,\n }),\n select: (data) => data?.retireMyGroundedAssistantConversation,\n errorMessage: 'Failed to delete the conversation',\n });\n const [deletingId, setDeletingId] = useState<string | null>(null);\n const remove = useCallback(\n async (clientConversationId: string) => {\n setDeletingId(clientConversationId);\n try {\n const deleted = await retire(clientConversationId);\n if (!deleted) throw new Error('Failed to delete the conversation');\n } finally {\n setDeletingId(null);\n }\n },\n [retire]\n );\n return { remove, deletingId, error: state.error };\n}\n"],"mappings":";;;;AAgCA,IAAaA,IAAgC,YAEvCC,IAAwC,CAAC,GACzCC,IAAY,KAIZC,IAAuC,CAAC;AAO9C,SAAgBC,IAAwD;CACtE,IAAMC,IAAcC,EAAe,GAC7BC,IAAYC,SAAe,EAAE,SAAS,EAAE,eAAY,EAAE,IAAI,CAACH,CAAW,CAAC;CAC7E,OAAOI,EACL;EACE,UAAUC;EACV;EACA,UAAUR;EACV,cAAc,MAASS,GAAM,sBAAsB,CAAC;EACpD,SAAS,MAASC;EAClB,UAAUT;EACV,SAAS,EAAQE;EACjB,cAAc;CAChB,CACF;AACF;AAOA,SAAgBQ,IAAkE;CAChF,IAAMR,IAAcC,EAAe;CACnC,OAAOQ,EAAoF;EACzF,UAAUC;EACV,WAAWd;EACX,SAAS,MACPU,IAAQA,EAAK,iCAAiC,6BAA6B,OAAQ,KAAA;EACrF,UAAU,KAAA;EACV,SAAS,EAAQN;EACjB,cAAc;CAChB,CAAC;AACH;AAOA,IAAMW,IAAmD,CAAC,GAGpDC,IAAyB;AAM/B,SAAgBC,EACd,GAC6C;CAC7C,IAAMb,IAAcC,EAAe,GAC7Ba,IAASC,EAAm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AAYC,KAAiBpB,EAAwB,IAAI;CAahE,OAAO;EAAE,QAZMM,EACb,OAAO,MAAiC;GACtC,EAAce,CAAoB;GAClC,IAAI;IAEF,IAAI,CAAC,MADiBN,EAAOM,CAAoB,GACnC,MAAU,MAAM,mCAAmC;GACnE,UAAU;IACR,EAAc,IAAI;GACpB;EACF,GACA,CAACN,CAAM,CAEA;EAAQ;EAAY,OAAOC,EAAM;CAAM;AAClD"}
|
|
@@ -55,6 +55,11 @@ export declare const botKeys: {
|
|
|
55
55
|
detail: (id: string) => readonly ["bots", "detail", string];
|
|
56
56
|
};
|
|
57
57
|
export declare function useBots(filter?: BaseFilter): PaginatedQueryResult<BotAppRecord[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Every bot of the workspace, all pages. For pickers that must offer each bot
|
|
60
|
+
* (a route can point at any of them), where `useBots` stops at one page.
|
|
61
|
+
*/
|
|
62
|
+
export declare function useAllBots(): QueryResult<BotAppRecord[]>;
|
|
58
63
|
/**
|
|
59
64
|
* Exact bot counts by status for the workspace (BOFF-12426). Unlike `useBots`
|
|
60
65
|
* this is not capped at one page, so it is the source for dashboard totals.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useBotlit as e } from "../providers/BotlitProvider.js";
|
|
2
2
|
import { buildMutationInput as t, fieldsOf as n } from "./internal/mutationInput.js";
|
|
3
|
-
import {
|
|
4
|
-
import { useCallback as
|
|
5
|
-
import { gql as
|
|
6
|
-
import { useGatewayClient as
|
|
3
|
+
import { useWorkspaceAllPagesQuery as r, useWorkspacePaginatedQuery as i, useWorkspaceQuery as a } from "./internal/workspaceGateway.js";
|
|
4
|
+
import { useCallback as o, useEffect as s, useMemo as c, useState as l } from "react";
|
|
5
|
+
import { gql as u } from "@apollo/client";
|
|
6
|
+
import { useGatewayClient as d } from "@burdenoff/fe-libs/shared/graphql";
|
|
7
7
|
// src/botlit/hooks/useBots.ts
|
|
8
|
-
var
|
|
8
|
+
var f = u`
|
|
9
9
|
query ListBotApps($filters: BotAppFilterInput, $pagination: PaginationInput) {
|
|
10
10
|
listBotApps(filters: $filters, pagination: $pagination) {
|
|
11
11
|
id
|
|
@@ -32,7 +32,7 @@ var d = l`
|
|
|
32
32
|
workspaceId
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
`,
|
|
35
|
+
`, p = u`
|
|
36
36
|
query GetBotApp($id: ID!) {
|
|
37
37
|
getBotApp(id: $id) {
|
|
38
38
|
id
|
|
@@ -59,7 +59,7 @@ var d = l`
|
|
|
59
59
|
workspaceId
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
`,
|
|
62
|
+
`, m = u`
|
|
63
63
|
mutation CreateBotApp($input: CreateBotAppInput!) {
|
|
64
64
|
createBotApp(input: $input) {
|
|
65
65
|
id
|
|
@@ -80,7 +80,7 @@ var d = l`
|
|
|
80
80
|
workspaceId
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
`,
|
|
83
|
+
`, h = u`
|
|
84
84
|
mutation UpdateBotApp($id: ID!, $input: UpdateBotAppInput!) {
|
|
85
85
|
updateBotApp(id: $id, input: $input) {
|
|
86
86
|
id
|
|
@@ -103,11 +103,11 @@ var d = l`
|
|
|
103
103
|
workspaceId
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
`,
|
|
106
|
+
`, g = u`
|
|
107
107
|
mutation DeleteBotApp($id: ID!) {
|
|
108
108
|
deleteBotApp(id: $id)
|
|
109
109
|
}
|
|
110
|
-
`,
|
|
110
|
+
`, _ = 100, v = [], y = n({
|
|
111
111
|
bucketId: !0,
|
|
112
112
|
context: !0,
|
|
113
113
|
defaultAgentId: !0,
|
|
@@ -126,10 +126,10 @@ var d = l`
|
|
|
126
126
|
welcomeMessage: !0,
|
|
127
127
|
workflowId: !0
|
|
128
128
|
});
|
|
129
|
-
function
|
|
129
|
+
function b(e) {
|
|
130
130
|
return e;
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function x(e, t) {
|
|
133
133
|
if (e || t) return {
|
|
134
134
|
workspaceId: e,
|
|
135
135
|
search: t?.search,
|
|
@@ -138,20 +138,33 @@ function b(e, t) {
|
|
|
138
138
|
bucketId: t?.bucketId
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
let { workspaceId: n } = e(),
|
|
143
|
-
return
|
|
144
|
-
document:
|
|
145
|
-
variables:
|
|
146
|
-
pageSize:
|
|
141
|
+
function S(t) {
|
|
142
|
+
let { workspaceId: n } = e(), r = c(() => ({ filters: x(n, t) }), [t, n]);
|
|
143
|
+
return i({
|
|
144
|
+
document: f,
|
|
145
|
+
variables: r,
|
|
146
|
+
pageSize: _,
|
|
147
147
|
extractRows: (e) => e?.listBotApps ?? [],
|
|
148
148
|
select: (e) => e,
|
|
149
|
-
fallback:
|
|
149
|
+
fallback: v,
|
|
150
150
|
enabled: !!n,
|
|
151
151
|
errorMessage: "Failed to load bots"
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
|
-
|
|
154
|
+
function C() {
|
|
155
|
+
let { workspaceId: t } = e(), n = c(() => ({ filters: x(t) }), [t]);
|
|
156
|
+
return r({
|
|
157
|
+
document: f,
|
|
158
|
+
variables: n,
|
|
159
|
+
pageSize: _,
|
|
160
|
+
extractRows: (e) => e?.listBotApps ?? [],
|
|
161
|
+
select: (e) => e,
|
|
162
|
+
fallback: v,
|
|
163
|
+
enabled: !!t,
|
|
164
|
+
errorMessage: "Failed to load bots"
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
var w = u`
|
|
155
168
|
query GetBotAppCounts {
|
|
156
169
|
getBotAppCounts {
|
|
157
170
|
total
|
|
@@ -162,10 +175,10 @@ var S = l`
|
|
|
162
175
|
}
|
|
163
176
|
}
|
|
164
177
|
`;
|
|
165
|
-
function
|
|
166
|
-
let { workspaceId: n } = e(), r =
|
|
167
|
-
return
|
|
168
|
-
document:
|
|
178
|
+
function T(t = !0) {
|
|
179
|
+
let { workspaceId: n } = e(), r = c(() => ({}), []);
|
|
180
|
+
return a({
|
|
181
|
+
document: w,
|
|
169
182
|
variables: r,
|
|
170
183
|
select: (e) => e?.getBotAppCounts ?? null,
|
|
171
184
|
fallback: null,
|
|
@@ -173,42 +186,42 @@ function C(t = !0) {
|
|
|
173
186
|
errorMessage: "Failed to load bot counts"
|
|
174
187
|
});
|
|
175
188
|
}
|
|
176
|
-
function
|
|
177
|
-
let t =
|
|
178
|
-
if (!e) r(null),
|
|
189
|
+
function E(e) {
|
|
190
|
+
let t = b(d("workspace")), [n, r] = l(null), [i, a] = l(!!e), [c, u] = l(), f = o(async () => {
|
|
191
|
+
if (!e) r(null), a(!1);
|
|
179
192
|
else {
|
|
180
|
-
|
|
193
|
+
a(!0), u(void 0);
|
|
181
194
|
try {
|
|
182
195
|
let n = await t.query({
|
|
183
|
-
query:
|
|
196
|
+
query: p,
|
|
184
197
|
variables: { id: e },
|
|
185
198
|
fetchPolicy: "network-only"
|
|
186
199
|
}), i = n.error;
|
|
187
200
|
if (i != null) throw i instanceof Error ? i : /* @__PURE__ */ Error("Failed to load bot");
|
|
188
201
|
r(n.data?.getBotApp ?? null);
|
|
189
202
|
} catch (e) {
|
|
190
|
-
r(null),
|
|
203
|
+
r(null), u(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load bot"));
|
|
191
204
|
} finally {
|
|
192
|
-
|
|
205
|
+
a(!1);
|
|
193
206
|
}
|
|
194
207
|
}
|
|
195
208
|
}, [e, t]);
|
|
196
|
-
return
|
|
197
|
-
|
|
198
|
-
}, [
|
|
209
|
+
return s(() => {
|
|
210
|
+
f();
|
|
211
|
+
}, [f]), {
|
|
199
212
|
data: n,
|
|
200
213
|
loading: i,
|
|
201
|
-
error:
|
|
202
|
-
refetch:
|
|
214
|
+
error: c,
|
|
215
|
+
refetch: f
|
|
203
216
|
};
|
|
204
217
|
}
|
|
205
|
-
function
|
|
206
|
-
let e =
|
|
218
|
+
function D() {
|
|
219
|
+
let e = b(d("workspace")), [t, n] = l({
|
|
207
220
|
data: void 0,
|
|
208
221
|
loading: !1,
|
|
209
222
|
error: void 0
|
|
210
223
|
});
|
|
211
|
-
return [
|
|
224
|
+
return [o(async (t) => {
|
|
212
225
|
n({
|
|
213
226
|
data: void 0,
|
|
214
227
|
loading: !0,
|
|
@@ -216,7 +229,7 @@ function T() {
|
|
|
216
229
|
});
|
|
217
230
|
try {
|
|
218
231
|
let r = (await e.mutate({
|
|
219
|
-
mutation:
|
|
232
|
+
mutation: m,
|
|
220
233
|
variables: { input: t }
|
|
221
234
|
})).data?.createBotApp;
|
|
222
235
|
if (!r) throw Error("Failed to create bot");
|
|
@@ -235,13 +248,13 @@ function T() {
|
|
|
235
248
|
}
|
|
236
249
|
}, [e]), t];
|
|
237
250
|
}
|
|
238
|
-
function
|
|
239
|
-
let e =
|
|
251
|
+
function O() {
|
|
252
|
+
let e = b(d("workspace")), [n, r] = l({
|
|
240
253
|
data: void 0,
|
|
241
254
|
loading: !1,
|
|
242
255
|
error: void 0
|
|
243
256
|
});
|
|
244
|
-
return [
|
|
257
|
+
return [o(async ({ botId: n, input: i }) => {
|
|
245
258
|
r({
|
|
246
259
|
data: void 0,
|
|
247
260
|
loading: !0,
|
|
@@ -249,10 +262,10 @@ function E() {
|
|
|
249
262
|
});
|
|
250
263
|
try {
|
|
251
264
|
let a = (await e.mutate({
|
|
252
|
-
mutation:
|
|
265
|
+
mutation: h,
|
|
253
266
|
variables: {
|
|
254
267
|
id: n,
|
|
255
|
-
input: t(i,
|
|
268
|
+
input: t(i, y)
|
|
256
269
|
}
|
|
257
270
|
})).data?.updateBotApp;
|
|
258
271
|
if (!a) throw Error("Failed to update bot");
|
|
@@ -271,13 +284,13 @@ function E() {
|
|
|
271
284
|
}
|
|
272
285
|
}, [e]), n];
|
|
273
286
|
}
|
|
274
|
-
function
|
|
275
|
-
let e =
|
|
287
|
+
function k() {
|
|
288
|
+
let e = b(d("workspace")), [t, n] = l({
|
|
276
289
|
data: void 0,
|
|
277
290
|
loading: !1,
|
|
278
291
|
error: void 0
|
|
279
292
|
});
|
|
280
|
-
return [
|
|
293
|
+
return [o(async (t) => {
|
|
281
294
|
n({
|
|
282
295
|
data: void 0,
|
|
283
296
|
loading: !0,
|
|
@@ -285,7 +298,7 @@ function D() {
|
|
|
285
298
|
});
|
|
286
299
|
try {
|
|
287
300
|
let r = (await e.mutate({
|
|
288
|
-
mutation:
|
|
301
|
+
mutation: g,
|
|
289
302
|
variables: { id: t }
|
|
290
303
|
})).data?.deleteBotApp ?? !1;
|
|
291
304
|
return n({
|
|
@@ -303,6 +316,6 @@ function D() {
|
|
|
303
316
|
}
|
|
304
317
|
}, [e]), t];
|
|
305
318
|
}
|
|
306
|
-
export {
|
|
319
|
+
export { C as useAllBots, E as useBot, T as useBotAppCounts, S as useBots, D as useCreateBot, k as useDeleteBot, O as useUpdateBot };
|
|
307
320
|
|
|
308
321
|
//# sourceMappingURL=useBots.js.map
|