@burdenoff/microfe-botmanor 2026.1112.1 → 2026.1112.3

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.
@@ -1,72 +1,73 @@
1
1
  import { BotlitProvider as e } from "./providers/BotlitProvider.js";
2
2
  import { BotlitRoutes as t } from "./BotlitRoutes.js";
3
3
  import { RouteLoader as n } from "./components/RouteLoader.js";
4
- import { WorkspaceRequired as r } from "./components/WorkspaceRequired.js";
5
- import { useEffect as i, useState as a } from "react";
6
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
7
- import { useGatewayClient as c } from "@burdenoff/fe-libs/shared/graphql";
8
- import { ApolloProvider as l } from "@apollo/client/react";
9
- import { QueryClient as u, QueryClientProvider as d } from "@tanstack/react-query";
10
- import { ErrorBoundary as f } from "@burdenoff/fe-libs/shared/components";
11
- import { FeatureFlagProvider as p } from "@burdenoff/fe-libs/shared/feature-flags";
4
+ import { useTr as r } from "../shared/hooks/useTr.js";
5
+ import { WorkspaceRequired as i } from "./components/WorkspaceRequired.js";
6
+ import { useEffect as a, useState as o } from "react";
7
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
8
+ import { useGatewayClient as l } from "@burdenoff/fe-libs/shared/graphql";
9
+ import { ApolloProvider as u } from "@apollo/client/react";
10
+ import { QueryClient as d, QueryClientProvider as f } from "@tanstack/react-query";
11
+ import { ErrorBoundary as p } from "@burdenoff/fe-libs/shared/components";
12
+ import { FeatureFlagProvider as m } from "@burdenoff/fe-libs/shared/feature-flags";
12
13
  // src/botlit/BotmanorRootInner.tsx
13
- var m = 1e4, h = 2e3, g = new u({ defaultOptions: { queries: {
14
+ var h = 1e4, g = 2e3, _ = new d({ defaultOptions: { queries: {
14
15
  staleTime: 3e5,
15
16
  retry: 1
16
- } } }), _ = (u) => {
17
- let _ = c("workspace"), v = !!_, [y, b] = a(null), [x, S] = a(!1);
18
- if (i(() => {
19
- if (v) return;
17
+ } } }), v = (d) => {
18
+ let v = r(), y = l("workspace"), b = !!y, [x, S] = o(!1), [C, w] = o(!1);
19
+ if (a(() => {
20
+ if (b) return;
20
21
  let e = setTimeout(() => {
21
- b("BotManor could not connect to the gateway. Please refresh the page or check your configuration.");
22
- }, m);
22
+ S(!0);
23
+ }, h);
23
24
  return () => clearTimeout(e);
24
- }, [v]), i(() => {
25
- if (u.workspaceId) return;
26
- let e = setTimeout(() => S(!0), h);
25
+ }, [b]), a(() => {
26
+ if (d.workspaceId) return;
27
+ let e = setTimeout(() => w(!0), g);
27
28
  return () => clearTimeout(e);
28
- }, [u.workspaceId]), !u.workspaceId) return x ? /* @__PURE__ */ o(r, {
29
- basePath: u.basePath,
30
- navigate: u.navigate
31
- }) : /* @__PURE__ */ o(n, { label: "Loading your workspace…" });
32
- if (!v) return y ? /* @__PURE__ */ o("div", {
29
+ }, [d.workspaceId]), !d.workspaceId) return C ? /* @__PURE__ */ s(i, {
30
+ basePath: d.basePath,
31
+ navigate: d.navigate
32
+ }) : /* @__PURE__ */ s(n, { label: v("botlit.root.loadingWorkspace", "Loading your workspace…") });
33
+ if (!b) return x ? /* @__PURE__ */ s("div", {
33
34
  className: "flex h-full min-h-[200px] w-full items-center justify-center p-6",
34
- children: /* @__PURE__ */ s("div", {
35
+ children: /* @__PURE__ */ c("div", {
35
36
  className: "text-center",
36
- children: [/* @__PURE__ */ o("p", {
37
+ children: [/* @__PURE__ */ s("p", {
37
38
  className: "mb-4 text-sm text-text-secondary",
38
- children: y
39
- }), /* @__PURE__ */ o("button", {
39
+ children: v("botlit.root.connectError", "BotManor could not connect to the gateway. Please refresh the page or check your configuration.")
40
+ }), /* @__PURE__ */ s("button", {
40
41
  type: "button",
41
42
  onClick: () => window.location.reload(),
42
43
  className: "rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg-hover",
43
- children: "Reload Page"
44
+ children: v("botlit.root.reload", "Reload Page")
44
45
  })]
45
46
  })
46
- }) : /* @__PURE__ */ o(n, {});
47
- let C = !!u.basePath, w = /* @__PURE__ */ o(e, {
48
- ...u,
49
- children: /* @__PURE__ */ o(t, {})
47
+ }) : /* @__PURE__ */ s(n, {});
48
+ let T = !!d.basePath, E = /* @__PURE__ */ s(e, {
49
+ ...d,
50
+ children: /* @__PURE__ */ s(t, {})
50
51
  });
51
- return /* @__PURE__ */ o(f, {
52
- fallback: /* @__PURE__ */ o("div", {
52
+ return /* @__PURE__ */ s(p, {
53
+ fallback: /* @__PURE__ */ s("div", {
53
54
  className: "p-6 text-center text-text-secondary",
54
- children: "Something went wrong loading BotManor. Please refresh the page."
55
+ children: v("botlit.root.loadFailed", "Something went wrong loading BotManor. Please refresh the page.")
55
56
  }),
56
- children: /* @__PURE__ */ o(p, {
57
+ children: /* @__PURE__ */ s(m, {
57
58
  workspaceId: null,
58
59
  gateway: "global",
59
60
  defaultEnabled: !0,
60
- children: /* @__PURE__ */ o(d, {
61
- client: g,
62
- children: C ? w : /* @__PURE__ */ o(l, {
63
- client: _,
64
- children: w
61
+ children: /* @__PURE__ */ s(f, {
62
+ client: _,
63
+ children: T ? E : /* @__PURE__ */ s(u, {
64
+ client: y,
65
+ children: E
65
66
  })
66
67
  })
67
68
  })
68
69
  });
69
70
  };
70
- export { _ as BotmanorRootInner };
71
+ export { v as BotmanorRootInner };
71
72
 
72
73
  //# sourceMappingURL=BotmanorRootInner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BotmanorRootInner.js","names":["CLIENT_READY_TIMEOUT_MS","WORKSPACE_SETTLE_MS","queryClient","QueryClient","BotmanorRootInner","workspaceClient","useGatewayClient","clientReady","clientError","setClientError","useState","workspaceSettled","setWorkspaceSettled","useEffect","timer","props","WorkspaceRequired","RouteLoader","isIntegrated","content","BotlitProvider","BotlitRoutes","ErrorBoundary","FeatureFlagProvider","QueryClientProvider","ApolloProvider"],"sources":["../../src/botlit/BotmanorRootInner.tsx"],"sourcesContent":["/**\n * BotManor Root — implementation\n * @module botlit\n *\n * Product pages live behind this lazy boundary. Workflow routes and SDK\n * lifecycle are owned by the app-shell WorkflowsRoot, shared with every host.\n */\n\nimport type { FC } from 'react';\nimport { useEffect, useState } from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ApolloProvider } from '@apollo/client/react';\nimport { ErrorBoundary } from '@burdenoff/fe-libs/shared/components';\nimport { BotlitProvider } from './providers/BotlitProvider';\nimport { FeatureFlagProvider } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { BotlitRoutes } from './BotlitRoutes';\nimport { RouteLoader } from './components/RouteLoader';\nimport { WorkspaceRequired } from './components/WorkspaceRequired';\nimport type { BotmanorRootProps } from './types';\n\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\n/** How long to wait for the shell's gateway clients before showing an error. */\nconst CLIENT_READY_TIMEOUT_MS = 10_000;\n\n/**\n * How long to keep showing the loading skeleton before concluding that the\n * shell really has no active workspace.\n *\n * The shell resolves org/workspace asynchronously and passes `workspaceId=\"\"`\n * until it lands, which is indistinguishable from \"this user has no\n * workspace\". Without this settle window the guided zero state would flash on\n * every cold load — a get-started screen appearing and vanishing reads as a\n * broken page, which is exactly what this component exists to avoid.\n */\nconst WORKSPACE_SETTLE_MS = 2_000;\n\n// Create a query client for this microfrontend\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 5 * 60 * 1000,\n retry: 1,\n },\n },\n});\n\nexport const BotmanorRootInner: FC<BotmanorRootProps> = (props) => {\n // NOTE: Navigation is now handled by the shell's NavRegistration.tsx\n // The shell manages all product submenu items in a centralized way\n\n // Product operations use the shell's authenticated workspace gateway client.\n const workspaceClient = useGatewayClient('workspace');\n const clientReady = Boolean(workspaceClient);\n const [clientError, setClientError] = useState<string | null>(null);\n const [workspaceSettled, setWorkspaceSettled] = useState(false);\n\n // Timeout fallback: if gateway clients are never provided (test env, shell\n // misconfiguration, auth failure before hydration), show an error rather than\n // spinning indefinitely.\n useEffect(() => {\n if (clientReady) return;\n const timer = setTimeout(() => {\n setClientError(\n 'BotManor could not connect to the gateway. Please refresh the page or check your configuration.'\n );\n }, CLIENT_READY_TIMEOUT_MS);\n return () => clearTimeout(timer);\n }, [clientReady]);\n\n // Give the shell a bounded window to resolve the active workspace before the\n // guided zero state is allowed to render. Cancelled the moment a workspace\n // arrives — a workspace that is already present never starts the timer.\n useEffect(() => {\n if (props.workspaceId) return;\n const timer = setTimeout(() => setWorkspaceSettled(true), WORKSPACE_SETTLE_MS);\n return () => clearTimeout(timer);\n }, [props.workspaceId]);\n\n // Without a workspace every BotManor query is unscoped and every write is\n // rejected — guide the user instead of rendering empty lists. Until the\n // settle window elapses we cannot tell \"still resolving\" from \"none\", so we\n // keep the same skeleton the shell was already showing.\n if (!props.workspaceId) {\n if (!workspaceSettled) {\n return <RouteLoader label=\"Loading your workspace…\" />;\n }\n return <WorkspaceRequired basePath={props.basePath} navigate={props.navigate} />;\n }\n\n // Don't render until clients are ready (same pattern as microfe-bigconsole)\n if (!clientReady) {\n if (clientError) {\n return (\n <div className=\"flex h-full min-h-[200px] w-full items-center justify-center p-6\">\n <div className=\"text-center\">\n <p className=\"mb-4 text-sm text-text-secondary\">{clientError}</p>\n <button\n type=\"button\"\n onClick={() => window.location.reload()}\n className=\"rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg-hover\"\n >\n Reload Page\n </button>\n </div>\n </div>\n );\n }\n // Same skeleton as the lazy-chunk fallback, so the content region never\n // switches loading idioms between first paint and the page rendering.\n return <RouteLoader />;\n }\n\n const isIntegrated = !!props.basePath;\n\n const content = (\n <BotlitProvider {...props}>\n <BotlitRoutes />\n </BotlitProvider>\n );\n\n return (\n <ErrorBoundary\n fallback={\n <div className=\"p-6 text-center text-text-secondary\">\n Something went wrong loading BotManor. Please refresh the page.\n </div>\n }\n >\n <FeatureFlagProvider workspaceId={null} gateway=\"global\" defaultEnabled={true}>\n <QueryClientProvider client={queryClient}>\n {isIntegrated ? (\n content\n ) : (\n <ApolloProvider client={workspaceClient}>{content}</ApolloProvider>\n )}\n </QueryClientProvider>\n </FeatureFlagProvider>\n </ErrorBoundary>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAuBA,IAAMA,IAA0B,KAY1BC,IAAsB,KAGtBC,IAAc,IAAIC,EAAY,EAClC,gBAAgB,EACd,SAAS;CACP,WAAW;CACX,OAAO;AACT,EACF,EACF,CAAC,GAEYC,KAA4C,MAAU;CAKjE,IAAMC,IAAkBC,EAAiB,WAAW,GAC9CC,IAAc,EAAQF,GACtB,CAACG,GAAaC,KAAkBC,EAAwB,IAAI,GAC5D,CAACC,GAAkBC,KAAuBF,EAAS,EAAK;CA4B9D,IAvBAG,QAAgB;EACd,IAAIN,GAAa;EACjB,IAAMO,IAAQ,iBAAiB;GAC7B,EACE,iGACF;EACF,GAAGd,CAAuB;EAC1B,aAAa,aAAac,CAAK;CACjC,GAAG,CAACP,CAAW,CAAC,GAKhBM,QAAgB;EACd,IAAIE,EAAM,aAAa;EACvB,IAAMD,IAAQ,iBAAiBF,EAAoB,EAAI,GAAGX,CAAmB;EAC7E,aAAa,aAAaa,CAAK;CACjC,GAAG,CAACC,EAAM,WAAW,CAAC,GAMlB,CAACA,EAAM,aAIT,OAHKJ,IAGE,kBAACK,GAAD;EAAmB,UAAUD,EAAM;EAAU,UAAUA,EAAM;CAAW,CAAA,IAFtE,kBAACE,GAAD,EAAa,OAAM,0BAA2B,CAAA;CAMzD,IAAI,CAACV,GAmBH,OAlBIC,IAEA,kBAAC,OAAD;EAAK,WAAU;EACb,UAAA,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAAC,KAAD;IAAG,WAAU;IAAoC,UAAAA;GAAe,CAAA,GAChE,kBAAC,UAAD;IACE,MAAK;IACL,eAAe,OAAO,SAAS,OAAO;IACtC,WAAU;IACX,UAAA;GAEO,CAAA,CACL;;CACF,CAAA,IAKF,kBAACS,GAAD,CAAc,CAAA;CAGvB,IAAMC,IAAe,CAAC,CAACH,EAAM,UAEvBI,IACJ,kBAACC,GAAD;EAAgB,GAAIL;EAClB,UAAA,kBAACM,GAAD,CAAe,CAAA;CACD,CAAA;CAGlB,OACE,kBAACC,GAAD;EACE,UACE,kBAAC,OAAD;GAAK,WAAU;GAAsC,UAAA;EAEhD,CAAA;EAGP,UAAA,kBAACC,GAAD;GAAqB,aAAa;GAAM,SAAQ;GAAS,gBAAgB;GACvE,UAAA,kBAACC,GAAD;IAAqB,QAAQtB;IAC1B,UAAAgB,IACCC,IAEA,kBAACM,GAAD;KAAgB,QAAQpB;KAAkB,UAAAc;IAAwB,CAAA;GAEjD,CAAA;EACF,CAAA;CACR,CAAA;AAEnB"}
1
+ {"version":3,"file":"BotmanorRootInner.js","names":["CLIENT_READY_TIMEOUT_MS","WORKSPACE_SETTLE_MS","queryClient","QueryClient","BotmanorRootInner","tr","useTr","workspaceClient","useGatewayClient","clientReady","clientTimedOut","setClientTimedOut","useState","workspaceSettled","setWorkspaceSettled","useEffect","timer","props","WorkspaceRequired","RouteLoader","isIntegrated","content","BotlitProvider","BotlitRoutes","ErrorBoundary","FeatureFlagProvider","QueryClientProvider","ApolloProvider"],"sources":["../../src/botlit/BotmanorRootInner.tsx"],"sourcesContent":["/**\n * BotManor Root — implementation\n * @module botlit\n *\n * Product pages live behind this lazy boundary. Workflow routes and SDK\n * lifecycle are owned by the app-shell WorkflowsRoot, shared with every host.\n */\n\nimport type { FC } from 'react';\nimport { useEffect, useState } from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ApolloProvider } from '@apollo/client/react';\nimport { ErrorBoundary } from '@burdenoff/fe-libs/shared/components';\nimport { BotlitProvider } from './providers/BotlitProvider';\nimport { FeatureFlagProvider } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { BotlitRoutes } from './BotlitRoutes';\nimport { RouteLoader } from './components/RouteLoader';\nimport { useTr } from '../shared/hooks/useTr';\nimport { WorkspaceRequired } from './components/WorkspaceRequired';\nimport type { BotmanorRootProps } from './types';\n\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\n/** How long to wait for the shell's gateway clients before showing an error. */\nconst CLIENT_READY_TIMEOUT_MS = 10_000;\n\n/**\n * How long to keep showing the loading skeleton before concluding that the\n * shell really has no active workspace.\n *\n * The shell resolves org/workspace asynchronously and passes `workspaceId=\"\"`\n * until it lands, which is indistinguishable from \"this user has no\n * workspace\". Without this settle window the guided zero state would flash on\n * every cold load — a get-started screen appearing and vanishing reads as a\n * broken page, which is exactly what this component exists to avoid.\n */\nconst WORKSPACE_SETTLE_MS = 2_000;\n\n// Create a query client for this microfrontend\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 5 * 60 * 1000,\n retry: 1,\n },\n },\n});\n\nexport const BotmanorRootInner: FC<BotmanorRootProps> = (props) => {\n // NOTE: Navigation is now handled by the shell's NavRegistration.tsx\n // The shell manages all product submenu items in a centralized way\n\n // Product operations use the shell's authenticated workspace gateway client.\n const tr = useTr();\n const workspaceClient = useGatewayClient('workspace');\n const clientReady = Boolean(workspaceClient);\n const [clientTimedOut, setClientTimedOut] = useState(false);\n const [workspaceSettled, setWorkspaceSettled] = useState(false);\n\n // Timeout fallback: if gateway clients are never provided (test env, shell\n // misconfiguration, auth failure before hydration), show an error rather than\n // spinning indefinitely.\n useEffect(() => {\n if (clientReady) return;\n const timer = setTimeout(() => {\n setClientTimedOut(true);\n }, CLIENT_READY_TIMEOUT_MS);\n return () => clearTimeout(timer);\n }, [clientReady]);\n\n // Give the shell a bounded window to resolve the active workspace before the\n // guided zero state is allowed to render. Cancelled the moment a workspace\n // arrives — a workspace that is already present never starts the timer.\n useEffect(() => {\n if (props.workspaceId) return;\n const timer = setTimeout(() => setWorkspaceSettled(true), WORKSPACE_SETTLE_MS);\n return () => clearTimeout(timer);\n }, [props.workspaceId]);\n\n // Without a workspace every BotManor query is unscoped and every write is\n // rejected — guide the user instead of rendering empty lists. Until the\n // settle window elapses we cannot tell \"still resolving\" from \"none\", so we\n // keep the same skeleton the shell was already showing.\n if (!props.workspaceId) {\n if (!workspaceSettled) {\n return <RouteLoader label={tr('botlit.root.loadingWorkspace', 'Loading your workspace…')} />;\n }\n return <WorkspaceRequired basePath={props.basePath} navigate={props.navigate} />;\n }\n\n // Don't render until clients are ready (same pattern as microfe-bigconsole)\n if (!clientReady) {\n if (clientTimedOut) {\n return (\n <div className=\"flex h-full min-h-[200px] w-full items-center justify-center p-6\">\n <div className=\"text-center\">\n <p className=\"mb-4 text-sm text-text-secondary\">\n {tr(\n 'botlit.root.connectError',\n 'BotManor could not connect to the gateway. Please refresh the page or check your configuration.'\n )}\n </p>\n <button\n type=\"button\"\n onClick={() => window.location.reload()}\n className=\"rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg-hover\"\n >\n {tr('botlit.root.reload', 'Reload Page')}\n </button>\n </div>\n </div>\n );\n }\n // Same skeleton as the lazy-chunk fallback, so the content region never\n // switches loading idioms between first paint and the page rendering.\n return <RouteLoader />;\n }\n\n const isIntegrated = !!props.basePath;\n\n const content = (\n <BotlitProvider {...props}>\n <BotlitRoutes />\n </BotlitProvider>\n );\n\n return (\n <ErrorBoundary\n fallback={\n <div className=\"p-6 text-center text-text-secondary\">\n {tr(\n 'botlit.root.loadFailed',\n 'Something went wrong loading BotManor. Please refresh the page.'\n )}\n </div>\n }\n >\n <FeatureFlagProvider workspaceId={null} gateway=\"global\" defaultEnabled={true}>\n <QueryClientProvider client={queryClient}>\n {isIntegrated ? (\n content\n ) : (\n <ApolloProvider client={workspaceClient}>{content}</ApolloProvider>\n )}\n </QueryClientProvider>\n </FeatureFlagProvider>\n </ErrorBoundary>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAwBA,IAAMA,IAA0B,KAY1BC,IAAsB,KAGtBC,IAAc,IAAIC,EAAY,EAClC,gBAAgB,EACd,SAAS;CACP,WAAW;CACX,OAAO;AACT,EACF,EACF,CAAC,GAEYC,KAA4C,MAAU;CAKjE,IAAMC,IAAKC,EAAM,GACXC,IAAkBC,EAAiB,WAAW,GAC9CC,IAAc,EAAQF,GACtB,CAACG,GAAgBC,KAAqBC,EAAS,EAAK,GACpD,CAACC,GAAkBC,KAAuBF,EAAS,EAAK;CA0B9D,IArBAG,QAAgB;EACd,IAAIN,GAAa;EACjB,IAAMO,IAAQ,iBAAiB;GAC7B,EAAkB,EAAI;EACxB,GAAGhB,CAAuB;EAC1B,aAAa,aAAagB,CAAK;CACjC,GAAG,CAACP,CAAW,CAAC,GAKhBM,QAAgB;EACd,IAAIE,EAAM,aAAa;EACvB,IAAMD,IAAQ,iBAAiBF,EAAoB,EAAI,GAAGb,CAAmB;EAC7E,aAAa,aAAae,CAAK;CACjC,GAAG,CAACC,EAAM,WAAW,CAAC,GAMlB,CAACA,EAAM,aAIT,OAHKJ,IAGE,kBAACK,GAAD;EAAmB,UAAUD,EAAM;EAAU,UAAUA,EAAM;CAAW,CAAA,IAFtE,kBAACE,GAAD,EAAa,OAAOd,EAAG,gCAAgC,yBAAyB,EAAI,CAAA;CAM/F,IAAI,CAACI,GAwBH,OAvBIC,IAEA,kBAAC,OAAD;EAAK,WAAU;EACb,UAAA,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAAC,KAAD;IAAG,WAAU;IACV,UAAAL,EACC,4BACA,iGACF;GACC,CAAA,GACH,kBAAC,UAAD;IACE,MAAK;IACL,eAAe,OAAO,SAAS,OAAO;IACtC,WAAU;IAET,UAAAA,EAAG,sBAAsB,aAAa;GACjC,CAAA,CACL;;CACF,CAAA,IAKF,kBAACc,GAAD,CAAc,CAAA;CAGvB,IAAMC,IAAe,CAAC,CAACH,EAAM,UAEvBI,IACJ,kBAACC,GAAD;EAAgB,GAAIL;EAClB,UAAA,kBAACM,GAAD,CAAe,CAAA;CACD,CAAA;CAGlB,OACE,kBAACC,GAAD;EACE,UACE,kBAAC,OAAD;GAAK,WAAU;GACZ,UAAAnB,EACC,0BACA,iEACF;EACG,CAAA;EAGP,UAAA,kBAACoB,GAAD;GAAqB,aAAa;GAAM,SAAQ;GAAS,gBAAgB;GACvE,UAAA,kBAACC,GAAD;IAAqB,QAAQxB;IAC1B,UAAAkB,IACCC,IAEA,kBAACM,GAAD;KAAgB,QAAQpB;KAAkB,UAAAc;IAAwB,CAAA;GAEjD,CAAA;EACF,CAAA;CACR,CAAA;AAEnB"}
@@ -2,8 +2,8 @@
2
2
  * Hooks Index
3
3
  * @module botlit/hooks
4
4
  */
5
- export { useBots, useBot, useCreateBot, useUpdateBot, useDeleteBot, botKeys } from './useBots';
6
- export { useAgents, useAgent, useCreateAgent, useUpdateAgent, useDeleteAgent, agentKeys, } from './useAgents';
5
+ export { useBots, useBotAppCounts, useBot, useCreateBot, useUpdateBot, useDeleteBot, botKeys, } from './useBots';
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';
9
9
  export { useRetrievalProfiles, useRetrievalProfile, useCreateRetrievalProfile, useUpdateRetrievalProfile, useDeleteRetrievalProfile, retrievalProfileKeys, } from './useRetrievalProfiles';
@@ -1,7 +1,7 @@
1
1
  import { UpdateBotmanorAgentInput } from '../../generated/wspace-types';
2
2
  import { BaseFilter } from '../types';
3
3
  import { GraphQLInput } from './internal/mutationInput';
4
- import { PaginatedQueryResult } from './internal/workspaceGateway';
4
+ import { PaginatedQueryResult, QueryResult } from './internal/workspaceGateway';
5
5
  export interface AgentRecord {
6
6
  id: string;
7
7
  name: string;
@@ -74,6 +74,20 @@ export declare const agentKeys: {
74
74
  detail: (id: string) => readonly ["agents", "detail", string];
75
75
  };
76
76
  export declare function useAgents(filter?: BaseFilter): PaginatedQueryResult<AgentRecord[]>;
77
+ /**
78
+ * Exact agent counts by status for the workspace (BOFF-12426). Unlike
79
+ * `useAgents` this is not capped at one page, so it is the source for
80
+ * dashboard totals. `total` counts every status.
81
+ */
82
+ export interface AgentCounts {
83
+ total: number;
84
+ draft: number;
85
+ active: number;
86
+ paused: number;
87
+ training: number;
88
+ archived: number;
89
+ }
90
+ export declare function useAgentCounts(enabled?: boolean): QueryResult<AgentCounts | null>;
77
91
  export declare function useAgent(agentId: string | undefined): {
78
92
  data: AgentRecord | null;
79
93
  loading: boolean;
@@ -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 { useWorkspacePaginatedQuery as r } from "./internal/workspaceGateway.js";
4
- import { useCallback as i, useEffect as a, useMemo as o, useState as s } from "react";
5
- import { gql as c } from "@apollo/client";
6
- import { useGatewayClient as l } from "@burdenoff/fe-libs/shared/graphql";
3
+ import { useWorkspacePaginatedQuery as r, useWorkspaceQuery as i } from "./internal/workspaceGateway.js";
4
+ import { useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
5
+ import { gql as l } from "@apollo/client";
6
+ import { useGatewayClient as u } from "@burdenoff/fe-libs/shared/graphql";
7
7
  // src/botlit/hooks/useAgents.ts
8
- var u = c`
8
+ var d = l`
9
9
  query ListBotmanorAgents($filters: BotmanorAgentFilterInput, $pagination: PaginationInput) {
10
10
  listBotmanorAgents(filters: $filters, pagination: $pagination) {
11
11
  id
@@ -29,7 +29,7 @@ var u = c`
29
29
  workspaceId
30
30
  }
31
31
  }
32
- `, d = c`
32
+ `, f = l`
33
33
  query GetBotmanorAgent($id: ID!) {
34
34
  getBotmanorAgent(id: $id) {
35
35
  id
@@ -63,7 +63,7 @@ var u = c`
63
63
  workspaceId
64
64
  }
65
65
  }
66
- `, f = c`
66
+ `, p = l`
67
67
  mutation CreateBotmanorAgent($input: CreateBotmanorAgentInput!) {
68
68
  createBotmanorAgent(input: $input) {
69
69
  id
@@ -85,7 +85,7 @@ var u = c`
85
85
  workspaceId
86
86
  }
87
87
  }
88
- `, p = c`
88
+ `, m = l`
89
89
  mutation UpdateBotmanorAgent($id: ID!, $input: UpdateBotmanorAgentInput!) {
90
90
  updateBotmanorAgent(id: $id, input: $input) {
91
91
  id
@@ -112,11 +112,11 @@ var u = c`
112
112
  workspaceId
113
113
  }
114
114
  }
115
- `, m = c`
115
+ `, h = l`
116
116
  mutation DeleteBotmanorAgent($id: ID!) {
117
117
  deleteBotmanorAgent(id: $id)
118
118
  }
119
- `, h = c`
119
+ `, g = l`
120
120
  query ListAgentVersions($agentId: ID!, $pagination: PaginationInput) {
121
121
  listAgentVersions(agentId: $agentId, pagination: $pagination) {
122
122
  id
@@ -131,7 +131,7 @@ var u = c`
131
131
  publishedAt
132
132
  }
133
133
  }
134
- `, g = c`
134
+ `, _ = l`
135
135
  mutation PublishAgentVersion($agentId: ID!, $versionId: ID!, $changelog: String) {
136
136
  publishAgentVersion(agentId: $agentId, versionId: $versionId, changelog: $changelog) {
137
137
  id
@@ -143,7 +143,7 @@ var u = c`
143
143
  publishedAt
144
144
  }
145
145
  }
146
- `, _ = c`
146
+ `, v = l`
147
147
  mutation RollbackAgentVersion($agentId: ID!, $targetVersionId: ID!) {
148
148
  rollbackAgentVersion(agentId: $agentId, targetVersionId: $targetVersionId) {
149
149
  id
@@ -155,7 +155,7 @@ var u = c`
155
155
  publishedAt
156
156
  }
157
157
  }
158
- `, v = 100, y = [], b = n({
158
+ `, y = 100, b = [], x = n({
159
159
  bucketId: !0,
160
160
  capabilities: !0,
161
161
  context: !0,
@@ -178,10 +178,10 @@ var u = c`
178
178
  visibility: !0,
179
179
  workflowIds: !0
180
180
  });
181
- function x(e) {
181
+ function S(e) {
182
182
  return e;
183
183
  }
184
- function S(e, t) {
184
+ function C(e, t) {
185
185
  if (e || t) return {
186
186
  workspaceId: e,
187
187
  search: t?.search,
@@ -190,54 +190,77 @@ function S(e, t) {
190
190
  bucketId: t?.bucketId
191
191
  };
192
192
  }
193
- function C(t) {
194
- let { workspaceId: n } = e(), i = o(() => ({ filters: S(n, t) }), [t, n]);
193
+ function w(t) {
194
+ let { workspaceId: n } = e(), i = s(() => ({ filters: C(n, t) }), [t, n]);
195
195
  return r({
196
- document: u,
196
+ document: d,
197
197
  variables: i,
198
- pageSize: v,
198
+ pageSize: y,
199
199
  extractRows: (e) => e?.listBotmanorAgents ?? [],
200
200
  select: (e) => e,
201
- fallback: y,
201
+ fallback: b,
202
202
  enabled: !!n,
203
203
  errorMessage: "Failed to load agents"
204
204
  });
205
205
  }
206
- function w(e) {
207
- let t = x(l("workspace")), [n, r] = s(null), [o, c] = s(!1), [u, f] = s(), p = i(async () => {
206
+ var T = l`
207
+ query GetBotmanorAgentCounts {
208
+ getBotmanorAgentCounts {
209
+ total
210
+ draft
211
+ active
212
+ paused
213
+ training
214
+ archived
215
+ }
216
+ }
217
+ `;
218
+ function E(t = !0) {
219
+ let { workspaceId: n } = e(), r = s(() => ({}), []);
220
+ return i({
221
+ document: T,
222
+ variables: r,
223
+ select: (e) => e?.getBotmanorAgentCounts ?? null,
224
+ fallback: null,
225
+ enabled: t && !!n,
226
+ errorMessage: "Failed to load agent counts"
227
+ });
228
+ }
229
+ function D(e) {
230
+ let t = S(u("workspace")), [n, r] = c(null), [i, s] = c(!1), [l, d] = c(), p = a(async () => {
208
231
  if (!e) r(null);
209
232
  else {
210
- c(!0), f(void 0);
233
+ s(!0), d(void 0);
211
234
  try {
212
235
  let n = await t.query({
213
- query: d,
236
+ query: f,
214
237
  variables: { id: e },
215
238
  fetchPolicy: "network-only"
216
239
  });
217
240
  r(n.data?.getBotmanorAgent ?? null);
218
241
  } catch (e) {
219
- f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load agent"));
242
+ d(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load agent"));
220
243
  } finally {
221
- c(!1);
244
+ s(!1);
222
245
  }
223
246
  }
224
247
  }, [e, t]);
225
- return a(() => {
248
+ return o(() => {
226
249
  p();
227
250
  }, [p]), {
228
251
  data: n,
229
- loading: o,
230
- error: u,
252
+ loading: i,
253
+ error: l,
231
254
  refetch: p
232
255
  };
233
256
  }
234
- function T() {
235
- let e = x(l("workspace")), [t, n] = s({
257
+ function O() {
258
+ let e = S(u("workspace")), [t, n] = c({
236
259
  data: void 0,
237
260
  loading: !1,
238
261
  error: void 0
239
262
  });
240
- return [i(async (t) => {
263
+ return [a(async (t) => {
241
264
  n({
242
265
  data: void 0,
243
266
  loading: !0,
@@ -245,7 +268,7 @@ function T() {
245
268
  });
246
269
  try {
247
270
  let r = (await e.mutate({
248
- mutation: f,
271
+ mutation: p,
249
272
  variables: { input: t }
250
273
  })).data?.createBotmanorAgent;
251
274
  if (!r) throw Error("Failed to create agent");
@@ -264,13 +287,13 @@ function T() {
264
287
  }
265
288
  }, [e]), t];
266
289
  }
267
- function E() {
268
- let e = x(l("workspace")), [n, r] = s({
290
+ function k() {
291
+ let e = S(u("workspace")), [n, r] = c({
269
292
  data: void 0,
270
293
  loading: !1,
271
294
  error: void 0
272
295
  });
273
- return [i(async ({ agentId: n, input: i }) => {
296
+ return [a(async ({ agentId: n, input: i }) => {
274
297
  r({
275
298
  data: void 0,
276
299
  loading: !0,
@@ -278,10 +301,10 @@ function E() {
278
301
  });
279
302
  try {
280
303
  let a = (await e.mutate({
281
- mutation: p,
304
+ mutation: m,
282
305
  variables: {
283
306
  id: n,
284
- input: t(i, b)
307
+ input: t(i, x)
285
308
  }
286
309
  })).data?.updateBotmanorAgent;
287
310
  if (!a) throw Error("Failed to update agent");
@@ -300,13 +323,13 @@ function E() {
300
323
  }
301
324
  }, [e]), n];
302
325
  }
303
- function D() {
304
- let e = x(l("workspace")), [t, n] = s({
326
+ function A() {
327
+ let e = S(u("workspace")), [t, n] = c({
305
328
  data: void 0,
306
329
  loading: !1,
307
330
  error: void 0
308
331
  });
309
- return [i(async (t) => {
332
+ return [a(async (t) => {
310
333
  n({
311
334
  data: void 0,
312
335
  loading: !0,
@@ -314,7 +337,7 @@ function D() {
314
337
  });
315
338
  try {
316
339
  let r = (await e.mutate({
317
- mutation: m,
340
+ mutation: h,
318
341
  variables: { id: t }
319
342
  })).data?.deleteBotmanorAgent ?? !1;
320
343
  return n({
@@ -332,14 +355,14 @@ function D() {
332
355
  }
333
356
  }, [e]), t];
334
357
  }
335
- function O(e) {
336
- let t = x(l("workspace")), [n, r] = s([]), [o, c] = s(!1), [u, d] = s(), f = i(async () => {
358
+ function j(e) {
359
+ let t = S(u("workspace")), [n, r] = c([]), [i, s] = c(!1), [l, d] = c(), f = a(async () => {
337
360
  if (!e) r([]);
338
361
  else {
339
- c(!0), d(void 0);
362
+ s(!0), d(void 0);
340
363
  try {
341
364
  let n = (await t.query({
342
- query: h,
365
+ query: g,
343
366
  variables: {
344
367
  agentId: e,
345
368
  pagination: {
@@ -353,26 +376,26 @@ function O(e) {
353
376
  } catch (e) {
354
377
  d(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load agent versions"));
355
378
  } finally {
356
- c(!1);
379
+ s(!1);
357
380
  }
358
381
  }
359
382
  }, [e, t]);
360
- return a(() => {
383
+ return o(() => {
361
384
  f();
362
385
  }, [f]), {
363
386
  data: n,
364
- loading: o,
365
- error: u,
387
+ loading: i,
388
+ error: l,
366
389
  refetch: f
367
390
  };
368
391
  }
369
- function k() {
370
- let e = x(l("workspace")), [t, n] = s({
392
+ function M() {
393
+ let e = S(u("workspace")), [t, n] = c({
371
394
  data: void 0,
372
395
  loading: !1,
373
396
  error: void 0
374
397
  });
375
- return [i(async ({ agentId: t, versionId: r, changelog: i }) => {
398
+ return [a(async ({ agentId: t, versionId: r, changelog: i }) => {
376
399
  n({
377
400
  data: void 0,
378
401
  loading: !0,
@@ -380,7 +403,7 @@ function k() {
380
403
  });
381
404
  try {
382
405
  let a = (await e.mutate({
383
- mutation: g,
406
+ mutation: _,
384
407
  variables: {
385
408
  agentId: t,
386
409
  versionId: r,
@@ -403,13 +426,13 @@ function k() {
403
426
  }
404
427
  }, [e]), t];
405
428
  }
406
- function A() {
407
- let e = x(l("workspace")), [t, n] = s({
429
+ function N() {
430
+ let e = S(u("workspace")), [t, n] = c({
408
431
  data: void 0,
409
432
  loading: !1,
410
433
  error: void 0
411
434
  });
412
- return [i(async ({ agentId: t, targetVersionId: r }) => {
435
+ return [a(async ({ agentId: t, targetVersionId: r }) => {
413
436
  n({
414
437
  data: void 0,
415
438
  loading: !0,
@@ -417,7 +440,7 @@ function A() {
417
440
  });
418
441
  try {
419
442
  let i = (await e.mutate({
420
- mutation: _,
443
+ mutation: v,
421
444
  variables: {
422
445
  agentId: t,
423
446
  targetVersionId: r
@@ -439,6 +462,6 @@ function A() {
439
462
  }
440
463
  }, [e]), t];
441
464
  }
442
- export { w as useAgent, O as useAgentVersions, C as useAgents, T as useCreateAgent, D as useDeleteAgent, k as usePublishAgentVersion, A as useRollbackAgentVersion, E as useUpdateAgent };
465
+ export { D as useAgent, E as useAgentCounts, j as useAgentVersions, w as useAgents, O as useCreateAgent, A as useDeleteAgent, M as usePublishAgentVersion, N as useRollbackAgentVersion, k as useUpdateAgent };
443
466
 
444
467
  //# sourceMappingURL=useAgents.js.map