@burdenoff/microfe-botmanor 2026.1124.1 → 2026.1127.1

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,10 +1,12 @@
1
1
  import { CreateKnowledgeBaseDocument as e, DeleteKnowledgeBaseDocument as t, GetKnowledgeBaseDocument as n, GetKnowledgeBaseUsageDocument as r, ListBotmanorKnowledgeBasesPageDocument as i, ListKnowledgeDocumentsDocument as a, RebuildKnowledgeBaseIndexDocument as o, RemoveKnowledgeDocumentDocument as s, UpdateKnowledgeBaseDocument as c } from "../../generated/wspace-operations.js";
2
- import { useAllPagesQuery as l } from "./internal/allPages.js";
3
- import { buildMutationInput as u, fieldsOf as d } from "./internal/mutationInput.js";
4
- import { useWorkspaceClient as f, useWorkspaceId as p, useWorkspaceMutation as m, useWorkspaceQuery as h } from "./internal/workspaceGateway.js";
5
- import { useCallback as g, useMemo as _ } from "react";
2
+ import { useBotlit as l } from "../providers/BotlitProvider.js";
3
+ import { useAllPagesQuery as u } from "./internal/allPages.js";
4
+ import { buildMutationInput as d, fieldsOf as f } from "./internal/mutationInput.js";
5
+ import { toError as p, useWorkspaceClient as m, useWorkspaceId as h, useWorkspaceMutation as g, useWorkspaceQuery as _ } from "./internal/workspaceGateway.js";
6
+ import { useCallback as v, useMemo as y } from "react";
7
+ import { useQuery as b } from "@tanstack/react-query";
6
8
  // src/botlit/hooks/useKnowledgeBases.ts
7
- var v = 100, y = d({
9
+ var x = 100, S = 50, C = "Failed to load knowledge documents", w = f({
8
10
  chunkOverlap: !0,
9
11
  chunkSize: !0,
10
12
  chunkingStrategy: !0,
@@ -15,62 +17,103 @@ var v = 100, y = d({
15
17
  name: !0,
16
18
  vectorStoreDriver: !0,
17
19
  workspaceId: !0
18
- }), b = d({
20
+ }), T = f({
19
21
  chunkOverlap: !0,
20
22
  chunkSize: !0,
21
23
  chunkingStrategy: !0,
22
24
  description: !0,
23
25
  metadata: !0,
24
26
  name: !0
25
- }), x = [], S = [];
26
- function C(e) {
27
+ }), E = [], D = [];
28
+ function O(e) {
27
29
  return e?.getKnowledgeBase ?? null;
28
30
  }
29
- function w(e) {
30
- return e?.listKnowledgeDocuments ?? S;
31
- }
32
- function T(e) {
33
- let t = p(), n = e?.search, r = _(() => ({ filters: {
31
+ var k = {
32
+ all: ["knowledgeBases"],
33
+ lists: () => [...k.all, "list"],
34
+ list: (e) => [...k.lists(), e],
35
+ details: () => [...k.all, "detail"],
36
+ detail: (e) => [...k.details(), e],
37
+ documents: (e) => [...k.detail(e), "documents"]
38
+ };
39
+ function A(e) {
40
+ let t = h(), n = e?.search, r = y(() => ({ filters: {
34
41
  workspaceId: t,
35
42
  search: n || void 0
36
43
  } }), [t, n]);
37
- return l({
44
+ return u({
38
45
  document: i,
39
46
  variables: r,
40
- pageSize: v,
41
- extractRows: (e) => e?.listBotmanorKnowledgeBasesPage.items ?? x,
47
+ pageSize: x,
48
+ extractRows: (e) => e?.listBotmanorKnowledgeBasesPage.items ?? E,
42
49
  extractNextOffset: (e) => e?.listBotmanorKnowledgeBasesPage.nextOffset ?? null,
43
- fallback: x,
50
+ fallback: E,
44
51
  enabled: !!t,
45
52
  errorMessage: "Failed to load knowledge bases"
46
53
  });
47
54
  }
48
- function E(e) {
49
- let t = _(() => ({ id: e ?? "" }), [e]);
50
- return h({
55
+ function j(e) {
56
+ let t = y(() => ({ id: e ?? "" }), [e]);
57
+ return _({
51
58
  document: n,
52
59
  variables: t,
53
- select: C,
60
+ select: O,
54
61
  fallback: null,
55
62
  enabled: !!e,
56
63
  errorMessage: "Failed to load knowledge base"
57
64
  });
58
65
  }
59
- function D(e) {
60
- let t = _(() => ({ knowledgeBaseId: e ?? "" }), [e]);
61
- return l({
62
- document: a,
63
- variables: t,
64
- pageSize: v,
65
- extractRows: w,
66
- fallback: S,
67
- enabled: !!e,
68
- errorMessage: "Failed to load knowledge documents"
66
+ function M(e) {
67
+ let { workspaceId: t, currentUser: n } = l(), r = m(), i = !!(t && e), o = b({
68
+ queryKey: [
69
+ ...k.documents(e ?? ""),
70
+ t,
71
+ n?.id
72
+ ],
73
+ enabled: i,
74
+ refetchOnMount: "always",
75
+ retry: !1,
76
+ queryFn: async ({ signal: n }) => {
77
+ if (!e || !t) throw Error(C);
78
+ let i = [], o = /* @__PURE__ */ new Set(), s = null;
79
+ try {
80
+ for (;;) {
81
+ n.throwIfAborted();
82
+ let t = {
83
+ knowledgeBaseId: e,
84
+ first: S,
85
+ after: s
86
+ }, c = await r.query({
87
+ query: a,
88
+ variables: t,
89
+ fetchPolicy: "no-cache",
90
+ context: { queryDeduplication: !1 }
91
+ });
92
+ if (n.throwIfAborted(), c.error) throw c.error;
93
+ let l = c.data?.listBotmanorKnowledgeDocumentsConnection;
94
+ if (!l) throw Error(C);
95
+ if (i.push(...l.edges.map(({ node: e }) => e)), !l.pageInfo.hasNextPage) return i;
96
+ let u = l.edges.at(-1)?.cursor;
97
+ if (!u || o.has(u)) throw Error(C);
98
+ o.add(u), s = u;
99
+ }
100
+ } catch (e) {
101
+ throw p(e, C);
102
+ }
103
+ }
69
104
  });
105
+ return {
106
+ data: o.error ? D : o.data ?? D,
107
+ loading: o.isFetching,
108
+ error: o.error ?? void 0,
109
+ refetch: async () => {
110
+ i && await o.refetch();
111
+ }
112
+ };
70
113
  }
71
- function O() {
72
- let e = f();
73
- return g(async (t) => {
114
+ function N() {
115
+ let e = m();
116
+ return v(async (t) => {
74
117
  let n = await e.query({
75
118
  query: r,
76
119
  variables: { id: t },
@@ -80,53 +123,53 @@ function O() {
80
123
  return n.data?.getKnowledgeBaseUsage ?? { agents: [] };
81
124
  }, [e]);
82
125
  }
83
- function k() {
84
- return m({
126
+ function P() {
127
+ return g({
85
128
  document: s,
86
129
  variables: (e) => ({ id: e }),
87
130
  select: (e) => e?.removeKnowledgeDocument,
88
131
  errorMessage: "Failed to remove the document"
89
132
  });
90
133
  }
91
- function A() {
92
- let t = p(), n = g((e) => ({ input: u({
134
+ function F() {
135
+ let t = h(), n = v((e) => ({ input: d({
93
136
  ...e,
94
137
  workspaceId: t
95
- }, y) }), [t]);
96
- return m({
138
+ }, w) }), [t]);
139
+ return g({
97
140
  document: e,
98
141
  variables: n,
99
142
  select: (e) => e?.createKnowledgeBase,
100
143
  errorMessage: "Failed to create knowledge base"
101
144
  });
102
145
  }
103
- function j() {
104
- return m({
146
+ function I() {
147
+ return g({
105
148
  document: c,
106
149
  variables: ({ kbId: e, input: t }) => ({
107
150
  id: e,
108
- input: u(t, b)
151
+ input: d(t, T)
109
152
  }),
110
153
  select: (e) => e?.updateKnowledgeBase,
111
154
  errorMessage: "Failed to update knowledge base"
112
155
  });
113
156
  }
114
- function M() {
115
- return m({
157
+ function L() {
158
+ return g({
116
159
  document: o,
117
160
  variables: (e) => ({ knowledgeBaseId: e }),
118
161
  select: (e) => e?.rebuildKnowledgeBaseIndex,
119
162
  errorMessage: "Failed to rebuild the knowledge base index"
120
163
  });
121
164
  }
122
- function N() {
123
- return m({
165
+ function R() {
166
+ return g({
124
167
  document: t,
125
168
  variables: (e) => ({ id: e }),
126
169
  select: (e) => e?.deleteKnowledgeBase,
127
170
  errorMessage: "Failed to delete knowledge base"
128
171
  });
129
172
  }
130
- export { A as useCreateKnowledgeBase, N as useDeleteKnowledgeBase, E as useKnowledgeBase, T as useKnowledgeBases, D as useKnowledgeDocuments, O as useLoadKnowledgeBaseUsage, M as useRebuildKnowledgeBaseIndex, k as useRemoveKnowledgeDocument, j as useUpdateKnowledgeBase };
173
+ export { k as knowledgeBaseKeys, F as useCreateKnowledgeBase, R as useDeleteKnowledgeBase, j as useKnowledgeBase, A as useKnowledgeBases, M as useKnowledgeDocuments, N as useLoadKnowledgeBaseUsage, L as useRebuildKnowledgeBaseIndex, P as useRemoveKnowledgeDocument, I as useUpdateKnowledgeBase };
131
174
 
132
175
  //# sourceMappingURL=useKnowledgeBases.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useKnowledgeBases.js","names":["LIST_LIMIT","CREATE_KB_FIELDS","fieldsOf","UPDATE_KB_FIELDS","NO_KNOWLEDGE_BASES","NO_DOCUMENTS","selectKnowledgeBase","data","selectDocuments","useKnowledgeBases","workspaceId","useWorkspaceId","search","filter","variables","useMemo","useAllPagesQuery","ListBotmanorKnowledgeBasesPageDocument","useKnowledgeBase","kbId","useWorkspaceQuery","GetKnowledgeBaseDocument","useKnowledgeDocuments","ListKnowledgeDocumentsDocument","useLoadKnowledgeBaseUsage","client","useWorkspaceClient","useCallback","result","GetKnowledgeBaseUsageDocument","operationError","useRemoveKnowledgeDocument","useWorkspaceMutation","RemoveKnowledgeDocumentDocument","documentId","useCreateKnowledgeBase","buildMutationInput","input","CreateKnowledgeBaseDocument","useUpdateKnowledgeBase","UpdateKnowledgeBaseDocument","useRebuildKnowledgeBaseIndex","RebuildKnowledgeBaseIndexDocument","useDeleteKnowledgeBase","DeleteKnowledgeBaseDocument"],"sources":["../../../src/botlit/hooks/useKnowledgeBases.ts"],"sourcesContent":["/**\n * Knowledge Bases Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listBotmanorKnowledgeBasesPage` / `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 GetKnowledgeBaseUsageDocument,\n ListBotmanorKnowledgeBasesPageDocument,\n ListKnowledgeDocumentsDocument,\n RebuildKnowledgeBaseIndexDocument,\n RemoveKnowledgeDocumentDocument,\n UpdateKnowledgeBaseDocument,\n type CreateKnowledgeBaseMutation,\n type DeleteKnowledgeBaseMutation,\n type GetKnowledgeBaseQuery,\n type ListBotmanorKnowledgeBasesPageQuery,\n type ListKnowledgeDocumentsQuery,\n type GetKnowledgeBaseUsageQuery,\n type RebuildKnowledgeBaseIndexMutation,\n type RemoveKnowledgeDocumentMutation,\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 { useAllPagesQuery } from './internal/allPages';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceClient,\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 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 }),\n [workspaceId, search]\n );\n\n // Every page: pickers and lookups need the whole list, not the first 100.\n return useAllPagesQuery<ListBotmanorKnowledgeBasesPageQuery, KnowledgeBaseRecord>({\n document: ListBotmanorKnowledgeBasesPageDocument,\n variables,\n pageSize: LIST_LIMIT,\n extractRows: (data) => data?.listBotmanorKnowledgeBasesPage.items ?? NO_KNOWLEDGE_BASES,\n extractNextOffset: (data) => data?.listBotmanorKnowledgeBasesPage.nextOffset ?? null,\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\n/** Every document of a knowledge base: all pages, `loading` until the last one is in. */\nexport function useKnowledgeDocuments(\n kbId: string | undefined\n): QueryResult<KnowledgeDocumentRecord[]> {\n const variables = useMemo(() => ({ knowledgeBaseId: kbId ?? '' }), [kbId]);\n\n return useAllPagesQuery<ListKnowledgeDocumentsQuery, KnowledgeDocumentRecord>({\n document: ListKnowledgeDocumentsDocument,\n variables,\n pageSize: LIST_LIMIT,\n extractRows: selectDocuments,\n fallback: NO_DOCUMENTS,\n enabled: Boolean(kbId),\n errorMessage: 'Failed to load knowledge documents',\n });\n}\n\n/** What still uses a knowledge base: the live agents that have it attached (BOFF-12472). */\nexport interface KnowledgeBaseUsage {\n agents: Array<{ id: string; name: string; status: string }>;\n}\n\n/** Returns a function that reads what uses a knowledge base, fresh each time: a delete is about to rely on it. */\nexport function useLoadKnowledgeBaseUsage() {\n const client = useWorkspaceClient();\n\n return useCallback(\n async (kbId: string): Promise<KnowledgeBaseUsage> => {\n const result = await client.query<GetKnowledgeBaseUsageQuery>({\n query: GetKnowledgeBaseUsageDocument,\n variables: { id: kbId },\n fetchPolicy: 'network-only',\n });\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw operationError instanceof Error\n ? operationError\n : new Error('Failed to load what uses this knowledge base');\n }\n return result.data?.getKnowledgeBaseUsage ?? { agents: [] };\n },\n [client]\n );\n}\n\n/** Removes one document and its vectors (`removeKnowledgeDocument`). */\nexport function useRemoveKnowledgeDocument() {\n return useWorkspaceMutation<RemoveKnowledgeDocumentMutation, string, boolean>({\n document: RemoveKnowledgeDocumentDocument,\n variables: (documentId) => ({ id: documentId }),\n select: (data) => data?.removeKnowledgeDocument,\n errorMessage: 'Failed to remove the document',\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":";;;;;;AA6CA,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;A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_LOAD_ERROR","CREATE_KB_FIELDS","fieldsOf","UPDATE_KB_FIELDS","NO_KNOWLEDGE_BASES","NO_DOCUMENTS","selectKnowledgeBase","data","knowledgeBaseKeys","filter","id","kbId","useKnowledgeBases","workspaceId","useWorkspaceId","search","variables","useMemo","useAllPagesQuery","ListBotmanorKnowledgeBasesPageDocument","useKnowledgeBase","useWorkspaceQuery","GetKnowledgeBaseDocument","useKnowledgeDocuments","useBotlit","client","useWorkspaceClient","enabled","query","useQuery","currentUser","documents","continuations","after","result","ListKnowledgeDocumentsDocument","signal","page","node","next","cause","toError","useLoadKnowledgeBaseUsage","useCallback","GetKnowledgeBaseUsageDocument","operationError","useRemoveKnowledgeDocument","useWorkspaceMutation","RemoveKnowledgeDocumentDocument","documentId","useCreateKnowledgeBase","buildMutationInput","input","CreateKnowledgeBaseDocument","useUpdateKnowledgeBase","UpdateKnowledgeBaseDocument","useRebuildKnowledgeBaseIndex","RebuildKnowledgeBaseIndexDocument","useDeleteKnowledgeBase","DeleteKnowledgeBaseDocument"],"sources":["../../../src/botlit/hooks/useKnowledgeBases.ts"],"sourcesContent":["/**\n * Knowledge Bases Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listBotmanorKnowledgeBasesPage` / `getKnowledgeBase` /\n * `listKnowledgeDocuments` operations and the create/update/delete mutations on\n * wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport type { ApolloClient } from '@apollo/client';\nimport { useQuery } from '@tanstack/react-query';\nimport {\n CreateKnowledgeBaseDocument,\n DeleteKnowledgeBaseDocument,\n GetKnowledgeBaseDocument,\n GetKnowledgeBaseUsageDocument,\n ListBotmanorKnowledgeBasesPageDocument,\n ListKnowledgeDocumentsDocument,\n RebuildKnowledgeBaseIndexDocument,\n RemoveKnowledgeDocumentDocument,\n UpdateKnowledgeBaseDocument,\n type CreateKnowledgeBaseMutation,\n type DeleteKnowledgeBaseMutation,\n type GetKnowledgeBaseQuery,\n type ListBotmanorKnowledgeBasesPageQuery,\n type ListKnowledgeDocumentsQuery,\n type ListKnowledgeDocumentsQueryVariables,\n type GetKnowledgeBaseUsageQuery,\n type RebuildKnowledgeBaseIndexMutation,\n type RemoveKnowledgeDocumentMutation,\n type UpdateKnowledgeBaseMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreateKnowledgeBaseInput,\n UpdateKnowledgeBaseInput,\n} from '../../generated/wspace-types';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport type { BaseFilter } from '../types';\nimport { useAllPagesQuery } from './internal/allPages';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n toError,\n useWorkspaceClient,\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 100;\nconst DOCUMENT_PAGE_SIZE = 50;\nconst DOCUMENT_LOAD_ERROR = 'Failed to load knowledge documents';\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 selectKnowledgeBase(data: GetKnowledgeBaseQuery | undefined): KnowledgeBaseRecord | null {\n return data?.getKnowledgeBase ?? null;\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 }),\n [workspaceId, search]\n );\n\n // Every page: pickers and lookups need the whole list, not the first 100.\n return useAllPagesQuery<ListBotmanorKnowledgeBasesPageQuery, KnowledgeBaseRecord>({\n document: ListBotmanorKnowledgeBasesPageDocument,\n variables,\n pageSize: LIST_LIMIT,\n extractRows: (data) => data?.listBotmanorKnowledgeBasesPage.items ?? NO_KNOWLEDGE_BASES,\n extractNextOffset: (data) => data?.listBotmanorKnowledgeBasesPage.nextOffset ?? null,\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\n/** Every document of a knowledge base: all pages, `loading` until the last one is in. */\nexport function useKnowledgeDocuments(\n kbId: string | undefined\n): QueryResult<KnowledgeDocumentRecord[]> {\n const { workspaceId, currentUser } = useBotlit();\n const client = useWorkspaceClient();\n const enabled = Boolean(workspaceId && kbId);\n const query = useQuery({\n queryKey: [...knowledgeBaseKeys.documents(kbId ?? ''), workspaceId, currentUser?.id],\n enabled,\n // A reopened knowledge base may have changed after indexing finished elsewhere.\n refetchOnMount: 'always',\n retry: false,\n queryFn: async ({ signal }) => {\n if (!kbId || !workspaceId) throw new Error(DOCUMENT_LOAD_ERROR);\n const documents: KnowledgeDocumentRecord[] = [];\n const continuations = new Set<string>();\n let after: string | null = null;\n\n try {\n while (true) {\n signal.throwIfAborted();\n const variables: ListKnowledgeDocumentsQueryVariables = {\n knowledgeBaseId: kbId,\n first: DOCUMENT_PAGE_SIZE,\n after,\n };\n const result: ApolloClient.QueryResult<ListKnowledgeDocumentsQuery> = await client.query<\n ListKnowledgeDocumentsQuery,\n ListKnowledgeDocumentsQueryVariables\n >({\n query: ListKnowledgeDocumentsDocument,\n variables,\n fetchPolicy: 'no-cache',\n context: { queryDeduplication: false },\n });\n signal.throwIfAborted();\n if (result.error) throw result.error;\n const page = result.data?.listBotmanorKnowledgeDocumentsConnection;\n if (!page) throw new Error(DOCUMENT_LOAD_ERROR);\n documents.push(...page.edges.map(({ node }) => node));\n if (!page.pageInfo.hasNextPage) return documents;\n\n const next = page.edges.at(-1)?.cursor;\n if (!next || continuations.has(next)) throw new Error(DOCUMENT_LOAD_ERROR);\n continuations.add(next);\n after = next;\n }\n } catch (cause) {\n throw toError(cause, DOCUMENT_LOAD_ERROR);\n }\n },\n });\n\n return {\n data: query.error ? NO_DOCUMENTS : (query.data ?? NO_DOCUMENTS),\n loading: query.isFetching,\n error: query.error ?? undefined,\n refetch: async () => {\n if (enabled) await query.refetch();\n },\n };\n}\n\n/** What still uses a knowledge base: the live agents that have it attached (BOFF-12472). */\nexport interface KnowledgeBaseUsage {\n agents: Array<{ id: string; name: string; status: string }>;\n}\n\n/** Returns a function that reads what uses a knowledge base, fresh each time: a delete is about to rely on it. */\nexport function useLoadKnowledgeBaseUsage() {\n const client = useWorkspaceClient();\n\n return useCallback(\n async (kbId: string): Promise<KnowledgeBaseUsage> => {\n const result = await client.query<GetKnowledgeBaseUsageQuery>({\n query: GetKnowledgeBaseUsageDocument,\n variables: { id: kbId },\n fetchPolicy: 'network-only',\n });\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw operationError instanceof Error\n ? operationError\n : new Error('Failed to load what uses this knowledge base');\n }\n return result.data?.getKnowledgeBaseUsage ?? { agents: [] };\n },\n [client]\n );\n}\n\n/** Removes one document and its vectors (`removeKnowledgeDocument`). */\nexport function useRemoveKnowledgeDocument() {\n return useWorkspaceMutation<RemoveKnowledgeDocumentMutation, string, boolean>({\n document: RemoveKnowledgeDocumentDocument,\n variables: (documentId) => ({ id: documentId }),\n select: (data) => data?.removeKnowledgeDocument,\n errorMessage: 'Failed to remove the document',\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":";;;;;;;;AAkDA,IAAMA,IAAa,KACbC,IAAqB,IACrBC,IAAsB,sCAoDtBC,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,EAAoB,GAAqE;CAChG,OAAOC,GAAM,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,IAAIW,KAAkB,MACpB,MAAMA,aAA0B,QAC5BA,IACA,gBAAI,MAAM,8CAA8C;EAE9D,OAAOX,EAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,EAAE;CAC5D,GACA,CAACT,CAAM,CACT;AACF;AAGA,SAAgBqB,IAA6B;CAC3C,OAAOC,EAAuE;EAC5E,UAAUC;EACV,YAAY,OAAgB,EAAE,IAAIC,EAAW;EAC7C,SAAS,MAAS1C,GAAM;EACxB,cAAc;CAChB,CAAC;AACH;AAEA,SAAgB2C,IAAyB;CACvC,IAAMrC,IAAcC,EAAe,GAE7BE,IAAY2B,GACf,OAAyC,EACxC,OAAOQ,EAAmB;EAAE,GAAGC;EAAO;CAAY,GAAGnD,CAAgB,EACvE,IACA,CAACY,CAAW,CACd;CAEA,OAAOkC,EAIL;EACA,UAAUM;EACV;EACA,SAAS,MAAS9C,GAAM;EACxB,cAAc;CAChB,CAAC;AACH;AAEA,SAAgB+C,IAAyB;CACvC,OAAOP,EAIL;EACA,UAAUQ;EACV,YAAY,EAAE,SAAM,gBAAa;GAC/B,IAAI5C;GACJ,OAAOwC,EAAmBC,GAAOjD,CAAgB;EACnD;EACA,SAAS,MAASI,GAAM;EACxB,cAAc;CAChB,CAAC;AACH;AAGA,SAAgBiD,IAA+B;CAC7C,OAAOT,EAAyE;EAC9E,UAAUU;EACV,YAAY,OAAU,EAAE,iBAAiB9C,EAAK;EAC9C,SAAS,MAASJ,GAAM;EACxB,cAAc;CAChB,CAAC;AACH;AAEA,SAAgBmD,IAAyB;CACvC,OAAOX,EAAmE;EACxE,UAAUY;EACV,YAAY,OAAU,EAAE,IAAIhD,EAAK;EACjC,SAAS,MAASJ,GAAM;EACxB,cAAc;CAChB,CAAC;AACH"}
@@ -12,6 +12,12 @@ import * as Types from './wspace-types';
12
12
  import * as Apollo from '../../node_modules/@apollo/client';
13
13
  import * as ApolloReactHooks from '../../node_modules/@apollo/client/react';
14
14
  export type A2ACardVerificationStatus = 'FAILED' | 'UNVERIFIED' | 'VERIFIED';
15
+ export type A2AConnectionFilterInput = {
16
+ isActive?: boolean | null | undefined;
17
+ senderAgentId?: string | number | null | undefined;
18
+ targetAgentId?: string | number | null | undefined;
19
+ workspaceId?: string | number | null | undefined;
20
+ };
15
21
  export type A2ARegistryEntryFilterInput = {
16
22
  bucketId?: string | number | null | undefined;
17
23
  status?: EntityStatus | null | undefined;
@@ -43,7 +49,9 @@ export type BotAppFilterInput = {
43
49
  export type BotAppStatus = 'ACTIVE' | 'ARCHIVED' | 'DRAFT' | 'PAUSED';
44
50
  export type BotAppType = 'ANALYST' | 'ASSISTANT' | 'AUTOMATION' | 'SPECIALIST';
45
51
  export type BotAppVisibility = 'PRIVATE' | 'PUBLIC' | 'WORKSPACE';
46
- export type BotmanorAgentCapability = 'A2A' | 'CODE_EXECUTION' | 'MCP_TOOLS' | 'MEMORY' | 'MULTIMODAL' | 'RAG' | 'REASONING' | 'WEB_BROWSING';
52
+ export type BotmanorAgentCapability = 'A2A' | 'CODE_EXECUTION'
53
+ /** Operates a desk (browser, cloud VM or the owner's machine) as a Steward. */
54
+ | 'COMPUTER_USE' | 'MCP_TOOLS' | 'MEMORY' | 'MULTIMODAL' | 'RAG' | 'REASONING' | 'WEB_BROWSING';
47
55
  /**
48
56
  * `AgentFilterInput` with the BotManor enums (BOFF-9561). Filters exactly like the
49
57
  * legacy input; `listBotmanorAgents` takes it in place of `AgentFilterInput`.
@@ -1012,34 +1020,54 @@ export type GetA2ARegistryEntryQuery = {
1012
1020
  };
1013
1021
  export type ListA2ARegistryEntriesQueryVariables = Exact<{
1014
1022
  filters?: Types.A2ARegistryEntryFilterInput | null | undefined;
1015
- pagination?: Types.PaginationInput | null | undefined;
1023
+ pagination?: Types.BotmanorOffsetPaginationInput | null | undefined;
1016
1024
  }>;
1017
1025
  export type ListA2ARegistryEntriesQuery = {
1018
- listA2ARegistryEntries: Array<{
1019
- agentCard: Record<string, unknown>;
1020
- bucketId: string | null;
1021
- cardSigned: boolean;
1022
- createdAt: string;
1023
- createdById: string;
1024
- description: string | null;
1025
- entitlements: Record<string, unknown>;
1026
- id: string;
1027
- metadata: Record<string, unknown> | null;
1028
- name: string;
1029
- requestedTrustLevel: Types.A2ATrustLevel;
1030
- revision: number;
1031
- status: Types.EntityStatus;
1032
- tags: Array<string>;
1033
- trustLevel: Types.A2ATrustLevel;
1034
- updatedAt: string;
1035
- updatedById: string;
1036
- verificationError: string | null;
1037
- verificationStatus: Types.A2ACardVerificationStatus;
1038
- verifiedAt: string | null;
1039
- visibility: Types.Visibility;
1040
- wellKnownUrl: string | null;
1041
- workspaceId: string;
1042
- }>;
1026
+ listBotmanorA2ARegistryEntriesPage: {
1027
+ nextOffset: number | null;
1028
+ items: Array<{
1029
+ agentCard: Record<string, unknown>;
1030
+ bucketId: string | null;
1031
+ cardSigned: boolean;
1032
+ createdAt: string;
1033
+ createdById: string;
1034
+ description: string | null;
1035
+ entitlements: Record<string, unknown>;
1036
+ id: string;
1037
+ metadata: Record<string, unknown> | null;
1038
+ name: string;
1039
+ requestedTrustLevel: Types.A2ATrustLevel;
1040
+ revision: number;
1041
+ status: Types.EntityStatus;
1042
+ tags: Array<string>;
1043
+ trustLevel: Types.A2ATrustLevel;
1044
+ updatedAt: string;
1045
+ updatedById: string;
1046
+ verificationError: string | null;
1047
+ verificationStatus: Types.A2ACardVerificationStatus;
1048
+ verifiedAt: string | null;
1049
+ visibility: Types.Visibility;
1050
+ wellKnownUrl: string | null;
1051
+ workspaceId: string;
1052
+ }>;
1053
+ };
1054
+ };
1055
+ export type ListAgentA2AConnectionsQueryVariables = Exact<{
1056
+ filters?: Types.A2AConnectionFilterInput | null | undefined;
1057
+ pagination?: Types.BotmanorOffsetPaginationInput | null | undefined;
1058
+ }>;
1059
+ export type ListAgentA2AConnectionsQuery = {
1060
+ listBotmanorA2AConnectionsPage: {
1061
+ nextOffset: number | null;
1062
+ items: Array<{
1063
+ id: string;
1064
+ name: string;
1065
+ senderAgentId: string;
1066
+ targetAgentId: string;
1067
+ isActive: boolean;
1068
+ createdAt: string;
1069
+ }>;
1070
+ };
1043
1071
  };
1044
1072
  export type CreateA2ARegistryEntryMutationVariables = Exact<{
1045
1073
  input: Types.CreateA2ARegistryEntryInput;
@@ -2582,22 +2610,31 @@ export type GetKnowledgeBaseQuery = {
2582
2610
  };
2583
2611
  export type ListKnowledgeDocumentsQueryVariables = Exact<{
2584
2612
  knowledgeBaseId: string | number;
2585
- pagination?: Types.PaginationInput | null | undefined;
2613
+ first: number;
2614
+ after?: string | null | undefined;
2586
2615
  }>;
2587
2616
  export type ListKnowledgeDocumentsQuery = {
2588
- listKnowledgeDocuments: Array<{
2589
- id: string;
2590
- knowledgeBaseId: string;
2591
- title: string;
2592
- fileId: string;
2593
- status: Types.DocumentStatus;
2594
- chunkCount: number;
2595
- processingError: string | null;
2596
- processedAt: string | null;
2597
- addedAt: string;
2598
- addedById: string;
2599
- updatedAt: string;
2600
- }>;
2617
+ listBotmanorKnowledgeDocumentsConnection: {
2618
+ edges: Array<{
2619
+ cursor: string;
2620
+ node: {
2621
+ id: string;
2622
+ knowledgeBaseId: string;
2623
+ title: string;
2624
+ fileId: string;
2625
+ status: Types.DocumentStatus;
2626
+ chunkCount: number;
2627
+ processingError: string | null;
2628
+ processedAt: string | null;
2629
+ addedAt: string;
2630
+ addedById: string;
2631
+ updatedAt: string;
2632
+ };
2633
+ }>;
2634
+ pageInfo: {
2635
+ hasNextPage: boolean;
2636
+ };
2637
+ };
2601
2638
  };
2602
2639
  export type CreateKnowledgeBaseMutationVariables = Exact<{
2603
2640
  input: Types.CreateKnowledgeBaseInput;
@@ -4560,6 +4597,32 @@ export type ListA2ARegistryEntriesQueryHookResult = ReturnType<typeof useListA2A
4560
4597
  export type ListA2ARegistryEntriesLazyQueryHookResult = ReturnType<typeof useListA2ARegistryEntriesLazyQuery>;
4561
4598
  export type ListA2ARegistryEntriesSuspenseQueryHookResult = ReturnType<typeof useListA2ARegistryEntriesSuspenseQuery>;
4562
4599
  export type ListA2ARegistryEntriesQueryResult = Apollo.QueryResult<Types.ListA2ARegistryEntriesQuery, Types.ListA2ARegistryEntriesQueryVariables>;
4600
+ export declare const ListAgentA2AConnectionsDocument: Apollo.DocumentNode;
4601
+ /**
4602
+ * __useListAgentA2AConnectionsQuery__
4603
+ *
4604
+ * To run a query within a React component, call `useListAgentA2AConnectionsQuery` and pass it any options that fit your needs.
4605
+ * When your component renders, `useListAgentA2AConnectionsQuery` returns an object from Apollo Client that contains loading, error, and data properties
4606
+ * you can use to render your UI.
4607
+ *
4608
+ * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
4609
+ *
4610
+ * @example
4611
+ * const { data, loading, error } = useListAgentA2AConnectionsQuery({
4612
+ * variables: {
4613
+ * filters: // value for 'filters'
4614
+ * pagination: // value for 'pagination'
4615
+ * },
4616
+ * });
4617
+ */
4618
+ export declare function useListAgentA2AConnectionsQuery(baseOptions?: ApolloReactHooks.QueryHookOptions<Types.ListAgentA2AConnectionsQuery, Types.ListAgentA2AConnectionsQueryVariables>): ApolloReactHooks.useQuery.Result<Types.ListAgentA2AConnectionsQuery, Types.ListAgentA2AConnectionsQueryVariables, "empty" | "complete" | "streaming", Types.ListAgentA2AConnectionsQueryVariables, undefined>;
4619
+ export declare function useListAgentA2AConnectionsLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions<Types.ListAgentA2AConnectionsQuery, Types.ListAgentA2AConnectionsQueryVariables>): ApolloReactHooks.useLazyQuery.ResultTuple<Types.ListAgentA2AConnectionsQuery, Types.ListAgentA2AConnectionsQueryVariables, "empty" | "complete" | "streaming", undefined>;
4620
+ export declare function useListAgentA2AConnectionsSuspenseQuery(baseOptions?: ApolloReactHooks.SuspenseQueryHookOptions<Types.ListAgentA2AConnectionsQuery, Types.ListAgentA2AConnectionsQueryVariables>): ApolloReactHooks.UseSuspenseQueryResult<Types.ListAgentA2AConnectionsQuery, Types.ListAgentA2AConnectionsQueryVariables>;
4621
+ export declare function useListAgentA2AConnectionsSuspenseQuery(baseOptions?: ApolloReactHooks.SkipToken | ApolloReactHooks.SuspenseQueryHookOptions<Types.ListAgentA2AConnectionsQuery, Types.ListAgentA2AConnectionsQueryVariables>): ApolloReactHooks.UseSuspenseQueryResult<Types.ListAgentA2AConnectionsQuery | undefined, Types.ListAgentA2AConnectionsQueryVariables>;
4622
+ export type ListAgentA2AConnectionsQueryHookResult = ReturnType<typeof useListAgentA2AConnectionsQuery>;
4623
+ export type ListAgentA2AConnectionsLazyQueryHookResult = ReturnType<typeof useListAgentA2AConnectionsLazyQuery>;
4624
+ export type ListAgentA2AConnectionsSuspenseQueryHookResult = ReturnType<typeof useListAgentA2AConnectionsSuspenseQuery>;
4625
+ export type ListAgentA2AConnectionsQueryResult = Apollo.QueryResult<Types.ListAgentA2AConnectionsQuery, Types.ListAgentA2AConnectionsQueryVariables>;
4563
4626
  export declare const CreateA2ARegistryEntryDocument: Apollo.DocumentNode;
4564
4627
  export type CreateA2ARegistryEntryMutationFn = Apollo.MutationFunction<Types.CreateA2ARegistryEntryMutation, Types.CreateA2ARegistryEntryMutationVariables>;
4565
4628
  /**
@@ -6509,7 +6572,8 @@ export declare const ListKnowledgeDocumentsDocument: Apollo.DocumentNode;
6509
6572
  * const { data, loading, error } = useListKnowledgeDocumentsQuery({
6510
6573
  * variables: {
6511
6574
  * knowledgeBaseId: // value for 'knowledgeBaseId'
6512
- * pagination: // value for 'pagination'
6575
+ * first: // value for 'first'
6576
+ * after: // value for 'after'
6513
6577
  * },
6514
6578
  * });
6515
6579
  */