@burdenoff/microfe-botmanor 2026.1201.2 → 2026.1202.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.
Files changed (46) hide show
  1. package/dist/botlit/BotmanorRootInner.js +2 -1
  2. package/dist/botlit/BotmanorRootInner.js.map +1 -1
  3. package/dist/botlit/components/GettingStartedChecklist.js +1 -1
  4. package/dist/botlit/components/GettingStartedChecklist.js.map +1 -1
  5. package/dist/botlit/components/StewardApprovalsInbox.d.ts +4 -0
  6. package/dist/botlit/components/StewardApprovalsInbox.js +419 -0
  7. package/dist/botlit/components/StewardApprovalsInbox.js.map +1 -0
  8. package/dist/botlit/hooks/useAgentApprovals.js +28 -17
  9. package/dist/botlit/hooks/useAgentApprovals.js.map +1 -1
  10. package/dist/botlit/hooks/useBotAgents.js +15 -11
  11. package/dist/botlit/hooks/useBotAgents.js.map +1 -1
  12. package/dist/botlit/hooks/useBots.js +36 -62
  13. package/dist/botlit/hooks/useBots.js.map +1 -1
  14. package/dist/botlit/hooks/useBuckets.js +31 -24
  15. package/dist/botlit/hooks/useBuckets.js.map +1 -1
  16. package/dist/botlit/hooks/useChannels.js +44 -30
  17. package/dist/botlit/hooks/useChannels.js.map +1 -1
  18. package/dist/botlit/hooks/useLLMProviders.js +8 -6
  19. package/dist/botlit/hooks/useLLMProviders.js.map +1 -1
  20. package/dist/botlit/hooks/useMCPServers.js +21 -17
  21. package/dist/botlit/hooks/useMCPServers.js.map +1 -1
  22. package/dist/botlit/hooks/usePromptTemplates.js +5 -3
  23. package/dist/botlit/hooks/usePromptTemplates.js.map +1 -1
  24. package/dist/botlit/hooks/useStorePublishing.js +20 -10
  25. package/dist/botlit/hooks/useStorePublishing.js.map +1 -1
  26. package/dist/botlit/hooks/useTemplates.js +35 -29
  27. package/dist/botlit/hooks/useTemplates.js.map +1 -1
  28. package/dist/botlit/hooks/useToolApprovals.d.ts +38 -5
  29. package/dist/botlit/hooks/useToolApprovals.js +50 -31
  30. package/dist/botlit/hooks/useToolApprovals.js.map +1 -1
  31. package/dist/botlit/pages/ToolApprovalsPage.js +125 -106
  32. package/dist/botlit/pages/ToolApprovalsPage.js.map +1 -1
  33. package/dist/botlit/permissions/botmanorPermissions.d.ts +1 -0
  34. package/dist/botlit/permissions/botmanorPermissions.js +1 -0
  35. package/dist/botlit/permissions/botmanorPermissions.js.map +1 -1
  36. package/dist/botlit/utils/stewardApprovals.d.ts +80 -0
  37. package/dist/botlit/utils/stewardApprovals.js +90 -0
  38. package/dist/botlit/utils/stewardApprovals.js.map +1 -0
  39. package/dist/generated/global-types.d.ts +7580 -811
  40. package/dist/generated/global-types.js.map +1 -1
  41. package/dist/generated/wspace-operations.d.ts +522 -3
  42. package/dist/generated/wspace-operations.js +281 -15
  43. package/dist/generated/wspace-operations.js.map +1 -1
  44. package/dist/generated/wspace-types.d.ts +9369 -61
  45. package/dist/generated/wspace-types.js.map +1 -1
  46. package/package.json +1 -1
@@ -24,10 +24,13 @@ var o = "\n id\n agentId\n versionId\n status\n requestedById\n requestNot
24
24
  `, l = i`
25
25
  query ListBotmanorAgentApprovalRequests(
26
26
  $filter: BotmanorAgentApprovalFilterInput
27
- $pagination: PaginationInput
27
+ $pagination: BotmanorOffsetPaginationInput
28
28
  ) {
29
- listBotmanorAgentApprovalRequests(filter: $filter, pagination: $pagination) {
30
- ${o}
29
+ listBotmanorAgentApprovalRequestsPage(filter: $filter, pagination: $pagination) {
30
+ items {
31
+ ${o}
32
+ }
33
+ nextOffset
31
34
  }
32
35
  }
33
36
  `, u = i`
@@ -107,21 +110,29 @@ function g(i) {
107
110
  else {
108
111
  f(!0), h(void 0);
109
112
  try {
110
- let e = await o.query({
111
- query: l,
112
- variables: {
113
- filter: {
114
- agentId: g || void 0,
115
- status: _ || void 0
113
+ let e = [], t = 0;
114
+ for (; t < 1e4;) {
115
+ let n = (await o.query({
116
+ query: l,
117
+ variables: {
118
+ filter: {
119
+ agentId: g || void 0,
120
+ status: _ || void 0
121
+ },
122
+ pagination: {
123
+ limit: 50,
124
+ offset: t
125
+ }
116
126
  },
117
- pagination: {
118
- limit: 50,
119
- offset: 0
120
- }
121
- },
122
- fetchPolicy: "network-only"
123
- });
124
- u(e.data?.listBotmanorAgentApprovalRequests ?? []);
127
+ fetchPolicy: "network-only"
128
+ })).data?.listBotmanorAgentApprovalRequestsPage;
129
+ if (!n) break;
130
+ e.push(...n.items);
131
+ let r = n.nextOffset;
132
+ if (r === null || !Number.isSafeInteger(r) || r <= t) break;
133
+ t = r;
134
+ }
135
+ u(e);
125
136
  } catch (e) {
126
137
  h(m(e, "Failed to load activation requests"));
127
138
  } finally {
@@ -1 +1 @@
1
- {"version":3,"file":"useAgentApprovals.js","names":["APPROVAL_REQUEST_FIELDS","GET_SETTINGS_DOCUMENT","UPDATE_SETTINGS_DOCUMENT","LIST_REQUESTS_DOCUMENT","REQUEST_ACTIVATION_DOCUMENT","APPROVE_DOCUMENT","REJECT_DOCUMENT","CANCEL_DOCUMENT","toError","error","fallback","useAgentApprovalSettings","client","useGatewayClient","useBotlit","data","setData","useState","loading","setLoading","saving","setSaving","setError","refetch","useCallback","workspaceId","result","queryError","useEffect","next","mutationError","useAgentApprovalRequests","filter","agentId","status","useAgentApprovalActions","pending","setPending","action","required","value","kind"],"sources":["../../../src/botlit/hooks/useAgentApprovals.ts"],"sourcesContent":["/**\n * Agent activation approval hooks (BOFF-9682).\n *\n * A workspace can require reviewer approval before an agent goes live. Builders\n * request activation; reviewers holding `botmanor-agent:approve` approve\n * (which publishes the agent's draft and sets it ACTIVE) or reject with a\n * reason. These hooks wrap the `*BotmanorAgentApproval*` fields of\n * wspace-botmanor-svc.\n */\nimport { gql, type ApolloClient } from '@apollo/client';\nimport { useCallback, useEffect, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useBotlit } from '../providers/BotlitProvider';\n\nconst APPROVAL_REQUEST_FIELDS = `\n id\n agentId\n versionId\n status\n requestedById\n requestNote\n reviewerId\n decisionReason\n decidedAt\n isStale\n createdAt\n`;\n\nconst GET_SETTINGS_DOCUMENT = gql`\n query BotmanorAgentApprovalSettings {\n botmanorAgentApprovalSettings {\n workspaceId\n requireActivationApproval\n updatedAt\n updatedById\n }\n }\n`;\n\nconst UPDATE_SETTINGS_DOCUMENT = gql`\n mutation UpdateBotmanorAgentApprovalSettings($requireActivationApproval: Boolean!) {\n updateBotmanorAgentApprovalSettings(requireActivationApproval: $requireActivationApproval) {\n workspaceId\n requireActivationApproval\n updatedAt\n updatedById\n }\n }\n`;\n\nconst LIST_REQUESTS_DOCUMENT = gql`\n query ListBotmanorAgentApprovalRequests(\n $filter: BotmanorAgentApprovalFilterInput\n $pagination: PaginationInput\n ) {\n listBotmanorAgentApprovalRequests(filter: $filter, pagination: $pagination) {\n ${APPROVAL_REQUEST_FIELDS}\n }\n }\n`;\n\nconst REQUEST_ACTIVATION_DOCUMENT = gql`\n mutation RequestBotmanorAgentActivation($agentId: ID!, $note: String) {\n requestBotmanorAgentActivation(agentId: $agentId, note: $note) {\n ${APPROVAL_REQUEST_FIELDS}\n }\n }\n`;\n\nconst APPROVE_DOCUMENT = gql`\n mutation ApproveBotmanorAgentActivation($id: ID!, $reason: String) {\n approveBotmanorAgentActivation(id: $id, reason: $reason) {\n ${APPROVAL_REQUEST_FIELDS}\n }\n }\n`;\n\nconst REJECT_DOCUMENT = gql`\n mutation RejectBotmanorAgentActivation($id: ID!, $reason: String!) {\n rejectBotmanorAgentActivation(id: $id, reason: $reason) {\n ${APPROVAL_REQUEST_FIELDS}\n }\n }\n`;\n\nconst CANCEL_DOCUMENT = gql`\n mutation CancelBotmanorAgentActivationRequest($id: ID!) {\n cancelBotmanorAgentActivationRequest(id: $id) {\n ${APPROVAL_REQUEST_FIELDS}\n }\n }\n`;\n\nexport type AgentApprovalStatus = 'PENDING' | 'APPROVED' | 'REJECTED' | 'CANCELLED';\n\nexport interface AgentApprovalSettingsRecord {\n workspaceId: string;\n requireActivationApproval: boolean;\n updatedAt?: string | null;\n updatedById?: string | null;\n}\n\nexport interface AgentApprovalRequestRecord {\n id: string;\n agentId: string;\n versionId?: string | null;\n status: AgentApprovalStatus;\n requestedById: string;\n requestNote?: string | null;\n reviewerId?: string | null;\n decisionReason?: string | null;\n decidedAt?: string | null;\n isStale: boolean;\n createdAt: string;\n}\n\nexport interface AgentApprovalFilter {\n agentId?: string;\n status?: AgentApprovalStatus;\n}\n\nfunction toError(error: unknown, fallback: string): Error {\n return error instanceof Error ? error : new Error(fallback);\n}\n\n/** The workspace's approval requirement, with a setter for reviewers. */\nexport function useAgentApprovalSettings() {\n const client = useGatewayClient('workspace') as ApolloClient;\n const { workspaceId } = useBotlit();\n const [data, setData] = useState<AgentApprovalSettingsRecord | null>(null);\n const [loading, setLoading] = useState(false);\n const [saving, setSaving] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!workspaceId) {\n setData(null);\n return;\n }\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<{\n botmanorAgentApprovalSettings: AgentApprovalSettingsRecord;\n }>({\n query: GET_SETTINGS_DOCUMENT,\n fetchPolicy: 'network-only',\n });\n setData(result.data?.botmanorAgentApprovalSettings ?? null);\n } catch (queryError) {\n setError(toError(queryError, 'Failed to load approval settings'));\n } finally {\n setLoading(false);\n }\n }, [client, workspaceId]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n const update = useCallback(\n async (requireActivationApproval: boolean) => {\n setSaving(true);\n try {\n const result = await client.mutate<{\n updateBotmanorAgentApprovalSettings: AgentApprovalSettingsRecord;\n }>({\n mutation: UPDATE_SETTINGS_DOCUMENT,\n variables: { requireActivationApproval },\n });\n const next = result.data?.updateBotmanorAgentApprovalSettings;\n if (!next) throw new Error('Failed to update approval settings');\n setData(next);\n return next;\n } catch (mutationError) {\n throw toError(mutationError, 'Failed to update approval settings');\n } finally {\n setSaving(false);\n }\n },\n [client]\n );\n\n return { data, loading, saving, error, refetch, update };\n}\n\n/** Activation requests in the workspace, newest first. */\nexport function useAgentApprovalRequests(filter: AgentApprovalFilter) {\n const client = useGatewayClient('workspace') as ApolloClient;\n const { workspaceId } = useBotlit();\n const [data, setData] = useState<AgentApprovalRequestRecord[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n const { agentId, status } = filter;\n\n const refetch = useCallback(async () => {\n if (!workspaceId) {\n setData([]);\n return;\n }\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<{\n listBotmanorAgentApprovalRequests: AgentApprovalRequestRecord[];\n }>({\n query: LIST_REQUESTS_DOCUMENT,\n variables: {\n filter: { agentId: agentId || undefined, status: status || undefined },\n pagination: { limit: 50, offset: 0 },\n },\n fetchPolicy: 'network-only',\n });\n setData(result.data?.listBotmanorAgentApprovalRequests ?? []);\n } catch (queryError) {\n setError(toError(queryError, 'Failed to load activation requests'));\n } finally {\n setLoading(false);\n }\n }, [agentId, client, status, workspaceId]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\ntype ApprovalAction =\n | { kind: 'request'; agentId: string; note?: string }\n | { kind: 'approve'; id: string; reason?: string }\n | { kind: 'reject'; id: string; reason: string }\n | { kind: 'cancel'; id: string };\n\n/** Request, approve, reject or cancel an activation request. */\nexport function useAgentApprovalActions() {\n const client = useGatewayClient('workspace') as ApolloClient;\n const [pending, setPending] = useState<ApprovalAction['kind'] | null>(null);\n\n const run = useCallback(\n async (action: ApprovalAction): Promise<AgentApprovalRequestRecord> => {\n setPending(action.kind);\n try {\n switch (action.kind) {\n case 'request': {\n const result = await client.mutate<{\n requestBotmanorAgentActivation: AgentApprovalRequestRecord;\n }>({\n mutation: REQUEST_ACTIVATION_DOCUMENT,\n variables: { agentId: action.agentId, note: action.note?.trim() || undefined },\n });\n return required(result.data?.requestBotmanorAgentActivation, 'request');\n }\n case 'approve': {\n const result = await client.mutate<{\n approveBotmanorAgentActivation: AgentApprovalRequestRecord;\n }>({\n mutation: APPROVE_DOCUMENT,\n variables: { id: action.id, reason: action.reason?.trim() || undefined },\n });\n return required(result.data?.approveBotmanorAgentActivation, 'approve');\n }\n case 'reject': {\n const result = await client.mutate<{\n rejectBotmanorAgentActivation: AgentApprovalRequestRecord;\n }>({\n mutation: REJECT_DOCUMENT,\n variables: { id: action.id, reason: action.reason.trim() },\n });\n return required(result.data?.rejectBotmanorAgentActivation, 'reject');\n }\n case 'cancel': {\n const result = await client.mutate<{\n cancelBotmanorAgentActivationRequest: AgentApprovalRequestRecord;\n }>({\n mutation: CANCEL_DOCUMENT,\n variables: { id: action.id },\n });\n return required(result.data?.cancelBotmanorAgentActivationRequest, 'cancel');\n }\n }\n } catch (mutationError) {\n throw toError(mutationError, `Failed to ${action.kind} activation`);\n } finally {\n setPending(null);\n }\n },\n [client]\n );\n\n return { run, pending };\n}\n\nfunction required(\n value: AgentApprovalRequestRecord | undefined,\n kind: ApprovalAction['kind']\n): AgentApprovalRequestRecord {\n if (!value) throw new Error(`Failed to ${kind} activation`);\n return value;\n}\n"],"mappings":";;;;;AAeA,IAAMA,IAA0B,mJAc1BC,IAAwB,CAAG;;;;;;;;;GAW3BC,IAA2B,CAAG;;;;;;;;;GAW9BC,IAAyB,CAAG;;;;;;QAM1BH,EAAwB;;;GAK1BI,IAA8B,CAAG;;;QAG/BJ,EAAwB;;;GAK1BK,IAAmB,CAAG;;;QAGpBL,EAAwB;;;GAK1BM,IAAkB,CAAG;;;QAGnBN,EAAwB;;;GAK1BO,IAAkB,CAAG;;;QAGnBP,EAAwB;;;;AAiChC,SAASQ,EAAQ,GAAgB,GAAyB;CACxD,OAAOC,aAAiB,QAAQA,IAAY,MAAMC,CAAQ;AAC5D;AAGA,SAAgBC,IAA2B;CACzC,IAAMC,IAASC,EAAiB,WAAW,GACrC,EAAE,mBAAgBC,EAAU,GAC5B,CAACC,GAAMC,KAAWC,EAA6C,IAAI,GACnE,CAACC,GAASC,KAAcF,EAAS,EAAK,GACtC,C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AW;OAAE,IAAIgC,EAAO;OAAI,QAAQA,EAAO,OAAO,KAAK;MAAE;KAC3D,CAAC,EAAA,CACsB,MAAM,+BAA+B,QAAQ;KAEtE,KAAK,UAOH,OAAOC,GAAS,MANK3B,EAAO,OAEzB;MACD,UAAUL;MACV,WAAW,EAAE,IAAI+B,EAAO,GAAG;KAC7B,CAAC,EAAA,CACsB,MAAM,sCAAsC,QAAQ;IAE/E;GACF,SAASR,GAAe;IACtB,MAAMtB,EAAQsB,GAAe,aAAaQ,EAAO,KAAK,YAAY;GACpE,UAAU;IACR,EAAW,IAAI;GACjB;EACF,GACA,CAAC1B,CAAM,CAGA;EAAK;CAAQ;AACxB;AAEA,SAAS2B,EACP,GACA,GAC4B;CAC5B,IAAI,CAACC,GAAO,MAAU,MAAM,aAAaC,EAAK,YAAY;CAC1D,OAAOD;AACT"}
1
+ {"version":3,"file":"useAgentApprovals.js","names":["APPROVAL_REQUEST_FIELDS","GET_SETTINGS_DOCUMENT","UPDATE_SETTINGS_DOCUMENT","LIST_REQUESTS_DOCUMENT","REQUEST_ACTIVATION_DOCUMENT","APPROVE_DOCUMENT","REJECT_DOCUMENT","CANCEL_DOCUMENT","toError","error","fallback","useAgentApprovalSettings","client","useGatewayClient","useBotlit","data","setData","useState","loading","setLoading","saving","setSaving","setError","refetch","useCallback","workspaceId","result","queryError","useEffect","next","mutationError","useAgentApprovalRequests","filter","items","offset","page","agentId","status","nextOffset","useAgentApprovalActions","pending","setPending","action","required","value","kind"],"sources":["../../../src/botlit/hooks/useAgentApprovals.ts"],"sourcesContent":["/**\n * Agent activation approval hooks (BOFF-9682).\n *\n * A workspace can require reviewer approval before an agent goes live. Builders\n * request activation; reviewers holding `botmanor-agent:approve` approve\n * (which publishes the agent's draft and sets it ACTIVE) or reject with a\n * reason. These hooks wrap the `*BotmanorAgentApproval*` fields of\n * wspace-botmanor-svc.\n */\nimport { gql, type ApolloClient } from '@apollo/client';\nimport { useCallback, useEffect, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useBotlit } from '../providers/BotlitProvider';\n\nconst APPROVAL_REQUEST_FIELDS = `\n id\n agentId\n versionId\n status\n requestedById\n requestNote\n reviewerId\n decisionReason\n decidedAt\n isStale\n createdAt\n`;\n\nconst GET_SETTINGS_DOCUMENT = gql`\n query BotmanorAgentApprovalSettings {\n botmanorAgentApprovalSettings {\n workspaceId\n requireActivationApproval\n updatedAt\n updatedById\n }\n }\n`;\n\nconst UPDATE_SETTINGS_DOCUMENT = gql`\n mutation UpdateBotmanorAgentApprovalSettings($requireActivationApproval: Boolean!) {\n updateBotmanorAgentApprovalSettings(requireActivationApproval: $requireActivationApproval) {\n workspaceId\n requireActivationApproval\n updatedAt\n updatedById\n }\n }\n`;\n\nconst LIST_REQUESTS_DOCUMENT = gql`\n query ListBotmanorAgentApprovalRequests(\n $filter: BotmanorAgentApprovalFilterInput\n $pagination: BotmanorOffsetPaginationInput\n ) {\n listBotmanorAgentApprovalRequestsPage(filter: $filter, pagination: $pagination) {\n items {\n ${APPROVAL_REQUEST_FIELDS}\n }\n nextOffset\n }\n }\n`;\n\nconst REQUEST_ACTIVATION_DOCUMENT = gql`\n mutation RequestBotmanorAgentActivation($agentId: ID!, $note: String) {\n requestBotmanorAgentActivation(agentId: $agentId, note: $note) {\n ${APPROVAL_REQUEST_FIELDS}\n }\n }\n`;\n\nconst APPROVE_DOCUMENT = gql`\n mutation ApproveBotmanorAgentActivation($id: ID!, $reason: String) {\n approveBotmanorAgentActivation(id: $id, reason: $reason) {\n ${APPROVAL_REQUEST_FIELDS}\n }\n }\n`;\n\nconst REJECT_DOCUMENT = gql`\n mutation RejectBotmanorAgentActivation($id: ID!, $reason: String!) {\n rejectBotmanorAgentActivation(id: $id, reason: $reason) {\n ${APPROVAL_REQUEST_FIELDS}\n }\n }\n`;\n\nconst CANCEL_DOCUMENT = gql`\n mutation CancelBotmanorAgentActivationRequest($id: ID!) {\n cancelBotmanorAgentActivationRequest(id: $id) {\n ${APPROVAL_REQUEST_FIELDS}\n }\n }\n`;\n\nexport type AgentApprovalStatus = 'PENDING' | 'APPROVED' | 'REJECTED' | 'CANCELLED';\n\nexport interface AgentApprovalSettingsRecord {\n workspaceId: string;\n requireActivationApproval: boolean;\n updatedAt?: string | null;\n updatedById?: string | null;\n}\n\nexport interface AgentApprovalRequestRecord {\n id: string;\n agentId: string;\n versionId?: string | null;\n status: AgentApprovalStatus;\n requestedById: string;\n requestNote?: string | null;\n reviewerId?: string | null;\n decisionReason?: string | null;\n decidedAt?: string | null;\n isStale: boolean;\n createdAt: string;\n}\n\nexport interface AgentApprovalFilter {\n agentId?: string;\n status?: AgentApprovalStatus;\n}\n\nfunction toError(error: unknown, fallback: string): Error {\n return error instanceof Error ? error : new Error(fallback);\n}\n\n/** The workspace's approval requirement, with a setter for reviewers. */\nexport function useAgentApprovalSettings() {\n const client = useGatewayClient('workspace') as ApolloClient;\n const { workspaceId } = useBotlit();\n const [data, setData] = useState<AgentApprovalSettingsRecord | null>(null);\n const [loading, setLoading] = useState(false);\n const [saving, setSaving] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!workspaceId) {\n setData(null);\n return;\n }\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<{\n botmanorAgentApprovalSettings: AgentApprovalSettingsRecord;\n }>({\n query: GET_SETTINGS_DOCUMENT,\n fetchPolicy: 'network-only',\n });\n setData(result.data?.botmanorAgentApprovalSettings ?? null);\n } catch (queryError) {\n setError(toError(queryError, 'Failed to load approval settings'));\n } finally {\n setLoading(false);\n }\n }, [client, workspaceId]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n const update = useCallback(\n async (requireActivationApproval: boolean) => {\n setSaving(true);\n try {\n const result = await client.mutate<{\n updateBotmanorAgentApprovalSettings: AgentApprovalSettingsRecord;\n }>({\n mutation: UPDATE_SETTINGS_DOCUMENT,\n variables: { requireActivationApproval },\n });\n const next = result.data?.updateBotmanorAgentApprovalSettings;\n if (!next) throw new Error('Failed to update approval settings');\n setData(next);\n return next;\n } catch (mutationError) {\n throw toError(mutationError, 'Failed to update approval settings');\n } finally {\n setSaving(false);\n }\n },\n [client]\n );\n\n return { data, loading, saving, error, refetch, update };\n}\n\n/** Activation requests in the workspace, newest first. */\nexport function useAgentApprovalRequests(filter: AgentApprovalFilter) {\n const client = useGatewayClient('workspace') as ApolloClient;\n const { workspaceId } = useBotlit();\n const [data, setData] = useState<AgentApprovalRequestRecord[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n const { agentId, status } = filter;\n\n const refetch = useCallback(async () => {\n if (!workspaceId) {\n setData([]);\n return;\n }\n setLoading(true);\n setError(undefined);\n try {\n const items: AgentApprovalRequestRecord[] = [];\n let offset = 0;\n while (offset < 10000) {\n const result = await client.query<{\n listBotmanorAgentApprovalRequestsPage: {\n items: AgentApprovalRequestRecord[];\n nextOffset: number | null;\n };\n }>({\n query: LIST_REQUESTS_DOCUMENT,\n variables: {\n filter: { agentId: agentId || undefined, status: status || undefined },\n pagination: { limit: 50, offset },\n },\n fetchPolicy: 'network-only',\n });\n const page = result.data?.listBotmanorAgentApprovalRequestsPage;\n if (!page) break;\n items.push(...page.items);\n const nextOffset: number | null = page.nextOffset;\n if (nextOffset === null || !Number.isSafeInteger(nextOffset) || nextOffset <= offset) {\n break;\n }\n offset = nextOffset;\n }\n setData(items);\n } catch (queryError) {\n setError(toError(queryError, 'Failed to load activation requests'));\n } finally {\n setLoading(false);\n }\n }, [agentId, client, status, workspaceId]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\ntype ApprovalAction =\n | { kind: 'request'; agentId: string; note?: string }\n | { kind: 'approve'; id: string; reason?: string }\n | { kind: 'reject'; id: string; reason: string }\n | { kind: 'cancel'; id: string };\n\n/** Request, approve, reject or cancel an activation request. */\nexport function useAgentApprovalActions() {\n const client = useGatewayClient('workspace') as ApolloClient;\n const [pending, setPending] = useState<ApprovalAction['kind'] | null>(null);\n\n const run = useCallback(\n async (action: ApprovalAction): Promise<AgentApprovalRequestRecord> => {\n setPending(action.kind);\n try {\n switch (action.kind) {\n case 'request': {\n const result = await client.mutate<{\n requestBotmanorAgentActivation: AgentApprovalRequestRecord;\n }>({\n mutation: REQUEST_ACTIVATION_DOCUMENT,\n variables: { agentId: action.agentId, note: action.note?.trim() || undefined },\n });\n return required(result.data?.requestBotmanorAgentActivation, 'request');\n }\n case 'approve': {\n const result = await client.mutate<{\n approveBotmanorAgentActivation: AgentApprovalRequestRecord;\n }>({\n mutation: APPROVE_DOCUMENT,\n variables: { id: action.id, reason: action.reason?.trim() || undefined },\n });\n return required(result.data?.approveBotmanorAgentActivation, 'approve');\n }\n case 'reject': {\n const result = await client.mutate<{\n rejectBotmanorAgentActivation: AgentApprovalRequestRecord;\n }>({\n mutation: REJECT_DOCUMENT,\n variables: { id: action.id, reason: action.reason.trim() },\n });\n return required(result.data?.rejectBotmanorAgentActivation, 'reject');\n }\n case 'cancel': {\n const result = await client.mutate<{\n cancelBotmanorAgentActivationRequest: AgentApprovalRequestRecord;\n }>({\n mutation: CANCEL_DOCUMENT,\n variables: { id: action.id },\n });\n return required(result.data?.cancelBotmanorAgentActivationRequest, 'cancel');\n }\n }\n } catch (mutationError) {\n throw toError(mutationError, `Failed to ${action.kind} activation`);\n } finally {\n setPending(null);\n }\n },\n [client]\n );\n\n return { run, pending };\n}\n\nfunction required(\n value: AgentApprovalRequestRecord | undefined,\n kind: ApprovalAction['kind']\n): AgentApprovalRequestRecord {\n if (!value) throw new Error(`Failed to ${kind} activation`);\n return value;\n}\n"],"mappings":";;;;;AAeA,IAAMA,IAA0B,mJAc1BC,IAAwB,CAAG;;;;;;;;;GAW3BC,IAA2B,CAAG;;;;;;;;;GAW9BC,IAAyB,CAAG;;;;;;;UAOxBH,EAAwB;;;;;GAO5BI,IAA8B,CAAG;;;QAG/BJ,EAAwB;;;GAK1BK,IAAmB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entLinks($filters: AppAgentFilterInput, $pagination: PaginationInput) {
10
- listAppAgents(filters: $filters, pagination: $pagination) {
11
- id
12
- appId
13
- agentId
14
- isActive
15
- priority
16
- triggerKeywords
17
- intentPatterns
18
- fallbackAgentId
19
- timeout
10
+ listBotmanorAppAgentsPage(filters: $filters, pagination: $pagination) {
11
+ items {
12
+ id
13
+ appId
14
+ agentId
15
+ isActive
16
+ priority
17
+ triggerKeywords
18
+ intentPatterns
19
+ fallbackAgentId
20
+ timeout
21
+ }
22
+ nextOffset
20
23
  }
21
24
  }
22
25
  `, l = s`
@@ -61,7 +64,8 @@ function m(e) {
61
64
  document: c,
62
65
  variables: i,
63
66
  pageSize: f,
64
- extractRows: (e) => e?.listAppAgents ?? p,
67
+ extractRows: (e) => e?.listBotmanorAppAgentsPage?.items ?? p,
68
+ extractNextOffset: (e) => e?.listBotmanorAppAgentsPage?.nextOffset ?? null,
65
69
  fallback: p,
66
70
  enabled: !!(e && t),
67
71
  errorMessage: "Failed to load the agents linked to this bot"
@@ -1 +1 @@
1
- {"version":3,"file":"useBotAgents.js","names":["LIST_APP_AGENTS_DOCUMENT","CREATE_APP_AGENT_DOCUMENT","UPDATE_APP_AGENT_DOCUMENT","DELETE_APP_AGENT_DOCUMENT","LINK_PAGE_SIZE","NO_LINKS","useBotAgentLinks","workspaceId","useWorkspaceId","variables","useMemo","botId","useAllPagesQuery","data","useLinkAgentToBot","useWorkspaceMutation","routing","useUpdateBotAgentLink","input","linkId","useUnlinkAgentFromBot","useBotKnowledgeBaseIds","links","bot","useBot","agents","useAgents","agentsError","hasMore","loadingMore","loadMore","linked","link","ids","agent","kbId"],"sources":["../../../src/botlit/hooks/useBotAgents.ts"],"sourcesContent":["/**\n * Bot-agent links (BOFF-12452)\n * @module botlit/hooks\n *\n * A bot reaches its agents through `AppAgent` links plus an optional default\n * agent. These hooks list a bot's links and add or remove one, so the bot's\n * Agents page can show only that bot's agents and a create-from-bot flow can\n * link what it creates. Setting the default agent is `useUpdateBot`.\n */\n\nimport { gql } from '@apollo/client';\nimport { useEffect, useMemo } from 'react';\n\nimport { useAgents } from './useAgents';\nimport { useBot } from './useBots';\nimport { useAllPagesQuery } from './internal/allPages';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nexport interface BotAgentLink {\n id: string;\n appId: string;\n agentId: string;\n isActive: boolean;\n priority: number;\n /** Keywords that route a message to this agent (KEYWORD-style routing). */\n triggerKeywords?: string[] | null;\n /** Regular-expression intents that route a message to this agent. */\n intentPatterns?: string[] | null;\n /** Agent that answers when this one fails or times out. */\n fallbackAgentId?: string | null;\n /** Seconds before the agent is considered to have timed out. */\n timeout?: number | null;\n}\n\ninterface ListAppAgentsData {\n listAppAgents?: BotAgentLink[] | null;\n}\n\ninterface CreateAppAgentData {\n createAppAgent?: BotAgentLink | null;\n}\n\ninterface UpdateAppAgentData {\n updateAppAgent?: BotAgentLink | null;\n}\n\ninterface DeleteAppAgentData {\n deleteAppAgent?: boolean | null;\n}\n\nconst LIST_APP_AGENTS_DOCUMENT = gql`\n query ListBotAgentLinks($filters: AppAgentFilterInput, $pagination: PaginationInput) {\n listAppAgents(filters: $filters, pagination: $pagination) {\n id\n appId\n agentId\n isActive\n priority\n triggerKeywords\n intentPatterns\n fallbackAgentId\n timeout\n }\n }\n`;\n\nconst CREATE_APP_AGENT_DOCUMENT = gql`\n mutation LinkAgentToBot($input: CreateAppAgentInput!) {\n createAppAgent(input: $input) {\n id\n appId\n agentId\n isActive\n priority\n triggerKeywords\n intentPatterns\n fallbackAgentId\n timeout\n }\n }\n`;\n\nconst UPDATE_APP_AGENT_DOCUMENT = gql`\n mutation UpdateBotAgentLink($id: ID!, $input: UpdateAppAgentInput!) {\n updateAppAgent(id: $id, input: $input) {\n id\n appId\n agentId\n isActive\n priority\n triggerKeywords\n intentPatterns\n fallbackAgentId\n timeout\n }\n }\n`;\n\nconst DELETE_APP_AGENT_DOCUMENT = gql`\n mutation UnlinkAgentFromBot($id: ID!) {\n deleteAppAgent(id: $id)\n }\n`;\n\nconst LINK_PAGE_SIZE = 100;\nconst NO_LINKS: BotAgentLink[] = [];\n\n/**\n * Every agent linked to one bot. Disabled until there is a bot and a workspace.\n * It reads all pages (a bot can have more links than one page holds), and stays\n * `loading` until the last one is in, so a page never derives its list from a\n * partial set of links.\n */\nexport function useBotAgentLinks(botId: string | undefined): QueryResult<BotAgentLink[]> {\n const workspaceId = useWorkspaceId();\n const variables = useMemo(\n () => ({ filters: { appId: botId, workspaceId } }),\n [botId, workspaceId]\n );\n\n return useAllPagesQuery<ListAppAgentsData, BotAgentLink>({\n document: LIST_APP_AGENTS_DOCUMENT,\n variables,\n pageSize: LINK_PAGE_SIZE,\n extractRows: (data) => data?.listAppAgents ?? NO_LINKS,\n fallback: NO_LINKS,\n enabled: Boolean(botId && workspaceId),\n errorMessage: 'Failed to load the agents linked to this bot',\n });\n}\n\n/** Routing settings of one bot-agent link. */\nexport interface BotAgentRouting {\n priority?: number;\n triggerKeywords?: string[];\n intentPatterns?: string[];\n fallbackAgentId?: string | null;\n isActive?: boolean;\n}\n\nexport interface LinkAgentInput extends BotAgentRouting {\n botId: string;\n agentId: string;\n}\n\n/** Links an agent to a bot. */\nexport function useLinkAgentToBot() {\n const workspaceId = useWorkspaceId();\n return useWorkspaceMutation<CreateAppAgentData, LinkAgentInput, BotAgentLink>({\n document: CREATE_APP_AGENT_DOCUMENT,\n variables: ({ botId, agentId, ...routing }) => ({\n input: { appId: botId, agentId, workspaceId, ...routing },\n }),\n select: (data) => data?.createAppAgent ?? undefined,\n errorMessage: 'Failed to link the agent to the bot',\n });\n}\n\nexport interface UpdateLinkInput extends BotAgentRouting {\n linkId: string;\n}\n\n/** Changes the routing settings of a link. */\nexport function useUpdateBotAgentLink() {\n return useWorkspaceMutation<UpdateAppAgentData, UpdateLinkInput, BotAgentLink>({\n document: UPDATE_APP_AGENT_DOCUMENT,\n variables: ({ linkId, ...input }) => ({ id: linkId, input }),\n select: (data) => data?.updateAppAgent ?? undefined,\n errorMessage: 'Failed to update the agent routing',\n });\n}\n\n/** Removes a link (the agent itself is untouched). */\nexport function useUnlinkAgentFromBot() {\n return useWorkspaceMutation<DeleteAppAgentData, string, boolean>({\n document: DELETE_APP_AGENT_DOCUMENT,\n variables: (linkId) => ({ id: linkId }),\n select: (data) => data?.deleteAppAgent ?? undefined,\n errorMessage: 'Failed to remove the agent from the bot',\n });\n}\n\n/**\n * The knowledge bases a bot uses: the ones attached to the agents linked to it\n * (and to its default agent). A bot reaches knowledge only through its agents, so\n * this is what its knowledge page lists. Reads every page of agents, and is\n * `loading` until the links, the bot and every page are in.\n */\nexport function useBotKnowledgeBaseIds(botId: string | undefined): {\n ids: Set<string>;\n loading: boolean;\n error: Error | undefined;\n refetch: () => void;\n} {\n const links = useBotAgentLinks(botId);\n const bot = useBot(botId);\n // Only bot-scoped pages need the agents; the global list must not fetch them.\n const agents = useAgents(undefined, { enabled: Boolean(botId) });\n\n const { hasMore, loadingMore, loadMore, error: agentsError } = agents;\n useEffect(() => {\n if (botId && hasMore && !loadingMore && !agentsError) void loadMore();\n }, [botId, hasMore, loadingMore, agentsError, loadMore]);\n\n // Deactivated links are not used when the bot routes requests.\n const linked = new Set(links.data.filter((link) => link.isActive).map((link) => link.agentId));\n if (bot.data?.defaultAgentId) linked.add(bot.data.defaultAgentId);\n const ids = new Set<string>();\n for (const agent of agents.data) {\n if (linked.has(agent.id)) for (const kbId of agent.knowledgeBaseIds ?? []) ids.add(kbId);\n }\n\n return {\n ids,\n loading: links.loading || bot.loading || agents.loading || agents.loadingMore || agents.hasMore,\n error: links.error ?? bot.error ?? agents.error,\n refetch: () => {\n void links.refetch();\n void bot.refetch();\n void agents.refetch();\n },\n };\n}\n"],"mappings":";;;;;;;AAsDA,IAAMA,IAA2B,CAAG;;;;;;;;;;;;;;GAgB9BC,IAA4B,CAAG;;;;;;;;;;;;;;GAgB/BC,IAA4B,CAAG;;;;;;;;;;;;;;GAgB/BC,I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ACF,KAAaG,EAAc;CACtE,GAAG;EAACnB;EAAOiB;EAASC;EAAaF;EAAaG;CAAQ,CAAC;CAGvD,IAAMC,IAAS,IAAI,IAAIT,EAAM,KAAK,QAAQ,MAASU,EAAK,QAAQ,CAAC,CAAC,KAAK,MAASA,EAAK,OAAO,CAAC;CAC7F,AAAIT,EAAI,MAAM,kBAAgBQ,EAAO,IAAIR,EAAI,KAAK,cAAc;CAChE,IAAMU,oBAAM,IAAI,IAAY;CAC5B,KAAK,IAAMC,KAAST,EAAO,MACzB,IAAIM,EAAO,IAAIG,EAAM,EAAE,GAAG,KAAK,IAAMC,KAAQD,EAAM,oBAAoB,CAAC,GAAG,EAAI,IAAIC,CAAI;CAGzF,OAAO;EACL;EACA,SAASb,EAAM,WAAWC,EAAI,WAAWE,EAAO,WAAWA,EAAO,eAAeA,EAAO;EACxF,OAAOH,EAAM,SAASC,EAAI,SAASE,EAAO;EAC1C,eAAe;GAGb,AAFAH,EAAW,QAAQ,GACnBC,EAAS,QAAQ,GACjBE,EAAY,QAAQ;EACtB;CACF;AACF"}
1
+ {"version":3,"file":"useBotAgents.js","names":["LIST_APP_AGENTS_DOCUMENT","CREATE_APP_AGENT_DOCUMENT","UPDATE_APP_AGENT_DOCUMENT","DELETE_APP_AGENT_DOCUMENT","LINK_PAGE_SIZE","NO_LINKS","useBotAgentLinks","workspaceId","useWorkspaceId","variables","useMemo","botId","useAllPagesQuery","data","useLinkAgentToBot","useWorkspaceMutation","routing","useUpdateBotAgentLink","input","linkId","useUnlinkAgentFromBot","useBotKnowledgeBaseIds","links","bot","useBot","agents","useAgents","agentsError","hasMore","loadingMore","loadMore","linked","link","ids","agent","kbId"],"sources":["../../../src/botlit/hooks/useBotAgents.ts"],"sourcesContent":["/**\n * Bot-agent links (BOFF-12452)\n * @module botlit/hooks\n *\n * A bot reaches its agents through `AppAgent` links plus an optional default\n * agent. These hooks list a bot's links and add or remove one, so the bot's\n * Agents page can show only that bot's agents and a create-from-bot flow can\n * link what it creates. Setting the default agent is `useUpdateBot`.\n */\n\nimport { gql } from '@apollo/client';\nimport { useEffect, useMemo } from 'react';\n\nimport { useAgents } from './useAgents';\nimport { useBot } from './useBots';\nimport { useAllPagesQuery } from './internal/allPages';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nexport interface BotAgentLink {\n id: string;\n appId: string;\n agentId: string;\n isActive: boolean;\n priority: number;\n /** Keywords that route a message to this agent (KEYWORD-style routing). */\n triggerKeywords?: string[] | null;\n /** Regular-expression intents that route a message to this agent. */\n intentPatterns?: string[] | null;\n /** Agent that answers when this one fails or times out. */\n fallbackAgentId?: string | null;\n /** Seconds before the agent is considered to have timed out. */\n timeout?: number | null;\n}\n\ninterface ListAppAgentsData {\n listBotmanorAppAgentsPage?: {\n items: BotAgentLink[];\n nextOffset: number | null;\n } | null;\n}\n\ninterface CreateAppAgentData {\n createAppAgent?: BotAgentLink | null;\n}\n\ninterface UpdateAppAgentData {\n updateAppAgent?: BotAgentLink | null;\n}\n\ninterface DeleteAppAgentData {\n deleteAppAgent?: boolean | null;\n}\n\nconst LIST_APP_AGENTS_DOCUMENT = gql`\n query ListBotAgentLinks($filters: AppAgentFilterInput, $pagination: PaginationInput) {\n listBotmanorAppAgentsPage(filters: $filters, pagination: $pagination) {\n items {\n id\n appId\n agentId\n isActive\n priority\n triggerKeywords\n intentPatterns\n fallbackAgentId\n timeout\n }\n nextOffset\n }\n }\n`;\n\nconst CREATE_APP_AGENT_DOCUMENT = gql`\n mutation LinkAgentToBot($input: CreateAppAgentInput!) {\n createAppAgent(input: $input) {\n id\n appId\n agentId\n isActive\n priority\n triggerKeywords\n intentPatterns\n fallbackAgentId\n timeout\n }\n }\n`;\n\nconst UPDATE_APP_AGENT_DOCUMENT = gql`\n mutation UpdateBotAgentLink($id: ID!, $input: UpdateAppAgentInput!) {\n updateAppAgent(id: $id, input: $input) {\n id\n appId\n agentId\n isActive\n priority\n triggerKeywords\n intentPatterns\n fallbackAgentId\n timeout\n }\n }\n`;\n\nconst DELETE_APP_AGENT_DOCUMENT = gql`\n mutation UnlinkAgentFromBot($id: ID!) {\n deleteAppAgent(id: $id)\n }\n`;\n\nconst LINK_PAGE_SIZE = 100;\nconst NO_LINKS: BotAgentLink[] = [];\n\n/**\n * Every agent linked to one bot. Disabled until there is a bot and a workspace.\n * It reads all pages (a bot can have more links than one page holds), and stays\n * `loading` until the last one is in, so a page never derives its list from a\n * partial set of links.\n */\nexport function useBotAgentLinks(botId: string | undefined): QueryResult<BotAgentLink[]> {\n const workspaceId = useWorkspaceId();\n const variables = useMemo(\n () => ({ filters: { appId: botId, workspaceId } }),\n [botId, workspaceId]\n );\n\n return useAllPagesQuery<ListAppAgentsData, BotAgentLink>({\n document: LIST_APP_AGENTS_DOCUMENT,\n variables,\n pageSize: LINK_PAGE_SIZE,\n extractRows: (data) => data?.listBotmanorAppAgentsPage?.items ?? NO_LINKS,\n extractNextOffset: (data) => data?.listBotmanorAppAgentsPage?.nextOffset ?? null,\n fallback: NO_LINKS,\n enabled: Boolean(botId && workspaceId),\n errorMessage: 'Failed to load the agents linked to this bot',\n });\n}\n\n/** Routing settings of one bot-agent link. */\nexport interface BotAgentRouting {\n priority?: number;\n triggerKeywords?: string[];\n intentPatterns?: string[];\n fallbackAgentId?: string | null;\n isActive?: boolean;\n}\n\nexport interface LinkAgentInput extends BotAgentRouting {\n botId: string;\n agentId: string;\n}\n\n/** Links an agent to a bot. */\nexport function useLinkAgentToBot() {\n const workspaceId = useWorkspaceId();\n return useWorkspaceMutation<CreateAppAgentData, LinkAgentInput, BotAgentLink>({\n document: CREATE_APP_AGENT_DOCUMENT,\n variables: ({ botId, agentId, ...routing }) => ({\n input: { appId: botId, agentId, workspaceId, ...routing },\n }),\n select: (data) => data?.createAppAgent ?? undefined,\n errorMessage: 'Failed to link the agent to the bot',\n });\n}\n\nexport interface UpdateLinkInput extends BotAgentRouting {\n linkId: string;\n}\n\n/** Changes the routing settings of a link. */\nexport function useUpdateBotAgentLink() {\n return useWorkspaceMutation<UpdateAppAgentData, UpdateLinkInput, BotAgentLink>({\n document: UPDATE_APP_AGENT_DOCUMENT,\n variables: ({ linkId, ...input }) => ({ id: linkId, input }),\n select: (data) => data?.updateAppAgent ?? undefined,\n errorMessage: 'Failed to update the agent routing',\n });\n}\n\n/** Removes a link (the agent itself is untouched). */\nexport function useUnlinkAgentFromBot() {\n return useWorkspaceMutation<DeleteAppAgentData, string, boolean>({\n document: DELETE_APP_AGENT_DOCUMENT,\n variables: (linkId) => ({ id: linkId }),\n select: (data) => data?.deleteAppAgent ?? undefined,\n errorMessage: 'Failed to remove the agent from the bot',\n });\n}\n\n/**\n * The knowledge bases a bot uses: the ones attached to the agents linked to it\n * (and to its default agent). A bot reaches knowledge only through its agents, so\n * this is what its knowledge page lists. Reads every page of agents, and is\n * `loading` until the links, the bot and every page are in.\n */\nexport function useBotKnowledgeBaseIds(botId: string | undefined): {\n ids: Set<string>;\n loading: boolean;\n error: Error | undefined;\n refetch: () => void;\n} {\n const links = useBotAgentLinks(botId);\n const bot = useBot(botId);\n // Only bot-scoped pages need the agents; the global list must not fetch them.\n const agents = useAgents(undefined, { enabled: Boolean(botId) });\n\n const { hasMore, loadingMore, loadMore, error: agentsError } = agents;\n useEffect(() => {\n if (botId && hasMore && !loadingMore && !agentsError) void loadMore();\n }, [botId, hasMore, loadingMore, agentsError, loadMore]);\n\n // Deactivated links are not used when the bot routes requests.\n const linked = new Set(links.data.filter((link) => link.isActive).map((link) => link.agentId));\n if (bot.data?.defaultAgentId) linked.add(bot.data.defaultAgentId);\n const ids = new Set<string>();\n for (const agent of agents.data) {\n if (linked.has(agent.id)) for (const kbId of agent.knowledgeBaseIds ?? []) ids.add(kbId);\n }\n\n return {\n ids,\n loading: links.loading || bot.loading || agents.loading || agents.loadingMore || agents.hasMore,\n error: links.error ?? bot.error ?? agents.error,\n refetch: () => {\n void links.refetch();\n void bot.refetch();\n void agents.refetch();\n },\n };\n}\n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AAK,GAC9BY,IAAMC,EAAOb,CAAK,GAElBc,IAASC,EAAU,KAAA,GAAW,EAAE,SAAS,EAAQf,EAAO,CAAC,GAEzD,EAAE,YAAS,gBAAa,aAAU,OAAOgB,MAAgBF;CAC/D,QAAgB;EACd,AAAId,KAASiB,KAAW,CAACC,KAAe,CAACF,KAAaG,EAAc;CACtE,GAAG;EAACnB;EAAOiB;EAASC;EAAaF;EAAaG;CAAQ,CAAC;CAGvD,IAAMC,IAAS,IAAI,IAAIT,EAAM,KAAK,QAAQ,MAASU,EAAK,QAAQ,CAAC,CAAC,KAAK,MAASA,EAAK,OAAO,CAAC;CAC7F,AAAIT,EAAI,MAAM,kBAAgBQ,EAAO,IAAIR,EAAI,KAAK,cAAc;CAChE,IAAMU,oBAAM,IAAI,IAAY;CAC5B,KAAK,IAAMC,KAAST,EAAO,MACzB,IAAIM,EAAO,IAAIG,EAAM,EAAE,GAAG,KAAK,IAAMC,KAAQD,EAAM,oBAAoB,CAAC,GAAG,EAAI,IAAIC,CAAI;CAGzF,OAAO;EACL;EACA,SAASb,EAAM,WAAWC,EAAI,WAAWE,EAAO,WAAWA,EAAO,eAAeA,EAAO;EACxF,OAAOH,EAAM,SAASC,EAAI,SAASE,EAAO;EAC1C,eAAe;GAGb,AAFAH,EAAW,QAAQ,GACnBC,EAAS,QAAQ,GACjBE,EAAY,QAAQ;EACtB;CACF;AACF"}
@@ -7,33 +7,6 @@ import { gql as d } from "@apollo/client";
7
7
  import { useGatewayClient as f } from "@burdenoff/fe-libs/shared/graphql";
8
8
  // src/botlit/hooks/useBots.ts
9
9
  var p = d`
10
- query ListBotApps($filters: BotAppFilterInput, $pagination: PaginationInput) {
11
- listBotApps(filters: $filters, pagination: $pagination) {
12
- id
13
- name
14
- slug
15
- description
16
- icon
17
- type
18
- status
19
- visibility
20
- routingStrategy
21
- defaultAgentId
22
- welcomeMessage
23
- fallbackMessage
24
- workflowId
25
- executionCount
26
- lastExecutedAt
27
- tagIds
28
- tags
29
- createdAt
30
- updatedAt
31
- createdById
32
- updatedById
33
- workspaceId
34
- }
35
- }
36
- `, m = d`
37
10
  query GetBotApp($id: ID!) {
38
11
  getBotApp(id: $id) {
39
12
  id
@@ -60,7 +33,7 @@ var p = d`
60
33
  workspaceId
61
34
  }
62
35
  }
63
- `, h = d`
36
+ `, m = d`
64
37
  mutation CreateBotApp($input: CreateBotAppInput!) {
65
38
  createBotApp(input: $input) {
66
39
  id
@@ -81,7 +54,7 @@ var p = d`
81
54
  workspaceId
82
55
  }
83
56
  }
84
- `, g = d`
57
+ `, h = d`
85
58
  mutation UpdateBotApp($id: ID!, $input: UpdateBotAppInput!) {
86
59
  updateBotApp(id: $id, input: $input) {
87
60
  id
@@ -104,11 +77,11 @@ var p = d`
104
77
  workspaceId
105
78
  }
106
79
  }
107
- `, _ = d`
80
+ `, g = d`
108
81
  mutation DeleteBotApp($id: ID!) {
109
82
  deleteBotApp(id: $id)
110
83
  }
111
- `, v = 100, y = [], b = r({
84
+ `, _ = 100, v = [], y = r({
112
85
  bucketId: !0,
113
86
  context: !0,
114
87
  defaultAgentId: !0,
@@ -127,10 +100,10 @@ var p = d`
127
100
  welcomeMessage: !0,
128
101
  workflowId: !0
129
102
  });
130
- function x(e) {
103
+ function b(e) {
131
104
  return e;
132
105
  }
133
- function S(e, t) {
106
+ function x(e, t) {
134
107
  if (e || t) return {
135
108
  workspaceId: e,
136
109
  search: t?.search,
@@ -139,34 +112,35 @@ function S(e, t) {
139
112
  bucketId: t?.bucketId
140
113
  };
141
114
  }
142
- function C(n) {
143
- let { workspaceId: r } = t(), i = l(() => ({ filters: S(r, n) }), [n, r]);
115
+ function S(n) {
116
+ let { workspaceId: r } = t(), i = l(() => ({ filters: x(r, n) }), [n, r]);
144
117
  return a({
145
118
  document: e,
146
119
  variables: i,
147
- pageSize: v,
120
+ pageSize: _,
148
121
  extractRows: (e) => e?.listBotAppsPage.items ?? [],
149
122
  extractNextOffset: (e) => e?.listBotAppsPage.nextOffset ?? null,
150
123
  select: (e) => e,
151
- fallback: y,
124
+ fallback: v,
152
125
  enabled: !!r,
153
126
  errorMessage: "Failed to load bots"
154
127
  });
155
128
  }
156
- function w() {
157
- let { workspaceId: e } = t(), n = l(() => ({ filters: S(e) }), [e]);
129
+ function C() {
130
+ let { workspaceId: n } = t(), r = l(() => ({ filters: x(n) }), [n]);
158
131
  return i({
159
- document: p,
160
- variables: n,
161
- pageSize: v,
162
- extractRows: (e) => e?.listBotApps ?? [],
132
+ document: e,
133
+ variables: r,
134
+ pageSize: _,
135
+ extractRows: (e) => e?.listBotAppsPage.items ?? [],
136
+ extractNextOffset: (e) => e?.listBotAppsPage.nextOffset ?? null,
163
137
  select: (e) => e,
164
- fallback: y,
165
- enabled: !!e,
138
+ fallback: v,
139
+ enabled: !!n,
166
140
  errorMessage: "Failed to load bots"
167
141
  });
168
142
  }
169
- var T = d`
143
+ var w = d`
170
144
  query GetBotAppCounts {
171
145
  getBotAppCounts {
172
146
  total
@@ -177,10 +151,10 @@ var T = d`
177
151
  }
178
152
  }
179
153
  `;
180
- function E(e = !0) {
154
+ function T(e = !0) {
181
155
  let { workspaceId: n } = t(), r = l(() => ({}), []);
182
156
  return o({
183
- document: T,
157
+ document: w,
184
158
  variables: r,
185
159
  select: (e) => e?.getBotAppCounts ?? null,
186
160
  fallback: null,
@@ -188,14 +162,14 @@ function E(e = !0) {
188
162
  errorMessage: "Failed to load bot counts"
189
163
  });
190
164
  }
191
- function D(e) {
192
- let t = x(f("workspace")), [n, r] = u(null), [i, a] = u(!!e), [o, l] = u(), d = s(async () => {
165
+ function E(e) {
166
+ let t = b(f("workspace")), [n, r] = u(null), [i, a] = u(!!e), [o, l] = u(), d = s(async () => {
193
167
  if (!e) r(null), a(!1);
194
168
  else {
195
169
  a(!0), l(void 0);
196
170
  try {
197
171
  let n = await t.query({
198
- query: m,
172
+ query: p,
199
173
  variables: { id: e },
200
174
  fetchPolicy: "network-only"
201
175
  }), i = n.error;
@@ -217,8 +191,8 @@ function D(e) {
217
191
  refetch: d
218
192
  };
219
193
  }
220
- function O() {
221
- let e = x(f("workspace")), [t, n] = u({
194
+ function D() {
195
+ let e = b(f("workspace")), [t, n] = u({
222
196
  data: void 0,
223
197
  loading: !1,
224
198
  error: void 0
@@ -231,7 +205,7 @@ function O() {
231
205
  });
232
206
  try {
233
207
  let r = (await e.mutate({
234
- mutation: h,
208
+ mutation: m,
235
209
  variables: { input: t }
236
210
  })).data?.createBotApp;
237
211
  if (!r) throw Error("Failed to create bot");
@@ -250,8 +224,8 @@ function O() {
250
224
  }
251
225
  }, [e]), t];
252
226
  }
253
- function k() {
254
- let e = x(f("workspace")), [t, r] = u({
227
+ function O() {
228
+ let e = b(f("workspace")), [t, r] = u({
255
229
  data: void 0,
256
230
  loading: !1,
257
231
  error: void 0
@@ -264,10 +238,10 @@ function k() {
264
238
  });
265
239
  try {
266
240
  let a = (await e.mutate({
267
- mutation: g,
241
+ mutation: h,
268
242
  variables: {
269
243
  id: t,
270
- input: n(i, b)
244
+ input: n(i, y)
271
245
  }
272
246
  })).data?.updateBotApp;
273
247
  if (!a) throw Error("Failed to update bot");
@@ -286,8 +260,8 @@ function k() {
286
260
  }
287
261
  }, [e]), t];
288
262
  }
289
- function A() {
290
- let e = x(f("workspace")), [t, n] = u({
263
+ function k() {
264
+ let e = b(f("workspace")), [t, n] = u({
291
265
  data: void 0,
292
266
  loading: !1,
293
267
  error: void 0
@@ -300,7 +274,7 @@ function A() {
300
274
  });
301
275
  try {
302
276
  let r = (await e.mutate({
303
- mutation: _,
277
+ mutation: g,
304
278
  variables: { id: t }
305
279
  })).data?.deleteBotApp ?? !1;
306
280
  return n({
@@ -318,6 +292,6 @@ function A() {
318
292
  }
319
293
  }, [e]), t];
320
294
  }
321
- export { w as useAllBots, D as useBot, E as useBotAppCounts, C as useBots, O as useCreateBot, A as useDeleteBot, k as useUpdateBot };
295
+ export { C as useAllBots, E as useBot, T as useBotAppCounts, S as useBots, D as useCreateBot, k as useDeleteBot, O as useUpdateBot };
322
296
 
323
297
  //# sourceMappingURL=useBots.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useBots.js","names":["LIST_BOT_APPS_DOCUMENT","GET_BOT_APP_DOCUMENT","CREATE_BOT_APP_DOCUMENT","UPDATE_BOT_APP_DOCUMENT","DELETE_BOT_APP_DOCUMENT","LIST_PAGE_SIZE","NO_BOTS","UPDATE_BOT_APP_FIELDS","fieldsOf","getWorkspaceClient","client","buildBotFilter","workspaceId","filter","useBots","useBotlit","variables","useMemo","useWorkspacePaginatedQuery","ListBotAppsPageDocument","data","rows","useAllBots","useWorkspaceAllPagesQuery","GET_BOT_APP_COUNTS_DOCUMENT","useBotAppCounts","useWorkspaceQuery","enabled","useBot","useGatewayClient","setData","useState","loading","setLoading","botId","error","setError","refetch","useCallback","result","operationError","queryError","useEffect","useCreateBot","state","setState","createdBot","mutationError","useUpdateBot","updatedBot","buildMutationInput","input","useDeleteBot","deleted"],"sources":["../../../src/botlit/hooks/useBots.ts"],"sourcesContent":["import { gql, type ApolloClient } from '@apollo/client';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport {\n ListBotAppsPageDocument,\n type ListBotAppsPageQuery,\n} from '../../generated/wspace-operations';\nimport type { UpdateBotAppInput } from '../../generated/wspace-types';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport type { BaseFilter } from '../types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceAllPagesQuery,\n useWorkspacePaginatedQuery,\n useWorkspaceQuery,\n type PaginatedQueryResult,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_BOT_APPS_DOCUMENT = gql`\n query ListBotApps($filters: BotAppFilterInput, $pagination: PaginationInput) {\n listBotApps(filters: $filters, pagination: $pagination) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n executionCount\n lastExecutedAt\n tagIds\n tags\n createdAt\n updatedAt\n createdById\n updatedById\n workspaceId\n }\n }\n`;\n\nconst GET_BOT_APP_DOCUMENT = gql`\n query GetBotApp($id: ID!) {\n getBotApp(id: $id) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n executionCount\n lastExecutedAt\n tagIds\n tags\n createdAt\n updatedAt\n createdById\n updatedById\n workspaceId\n }\n }\n`;\n\nconst CREATE_BOT_APP_DOCUMENT = gql`\n mutation CreateBotApp($input: CreateBotAppInput!) {\n createBotApp(input: $input) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n workflowId\n tagIds\n tags\n createdAt\n updatedAt\n workspaceId\n }\n }\n`;\n\nconst UPDATE_BOT_APP_DOCUMENT = gql`\n mutation UpdateBotApp($id: ID!, $input: UpdateBotAppInput!) {\n updateBotApp(id: $id, input: $input) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n tagIds\n tags\n updatedAt\n updatedById\n workspaceId\n }\n }\n`;\n\nconst DELETE_BOT_APP_DOCUMENT = gql`\n mutation DeleteBotApp($id: ID!) {\n deleteBotApp(id: $id)\n }\n`;\n\ntype WorkspaceClient = ApolloClient;\n\nexport interface BotAppRecord {\n id: string;\n name: string;\n slug: string;\n description?: string | null;\n icon?: string | null;\n type: string;\n status: string;\n visibility?: string | null;\n routingStrategy?: string | null;\n defaultAgentId?: string | null;\n welcomeMessage?: string | null;\n fallbackMessage?: string | null;\n /** Bound FluidGrids workflow definition id — the bot's designed behaviour. */\n workflowId?: string | null;\n executionCount?: number | null;\n lastExecutedAt?: string | null;\n tagIds?: string[] | null;\n /** Entity-owned universal tag records (JSON). */\n tags?: unknown;\n createdAt?: string | null;\n updatedAt?: string | null;\n createdById?: string | null;\n updatedById?: string | null;\n workspaceId?: string | null;\n}\n\ninterface ListBotAppsData {\n listBotApps: BotAppRecord[];\n}\n\nconst LIST_PAGE_SIZE = 100;\nconst NO_BOTS: BotAppRecord[] = [];\n\ninterface GetBotAppData {\n getBotApp: BotAppRecord | null;\n}\n\ninterface CreateBotAppData {\n createBotApp: BotAppRecord;\n}\n\ninterface UpdateBotAppData {\n updateBotApp: BotAppRecord;\n}\n\ninterface DeleteBotAppData {\n deleteBotApp: boolean;\n}\n\ninterface BotMutationState<T> {\n data: T | undefined;\n loading: boolean;\n error: Error | undefined;\n}\n\ninterface CreateBotInput {\n workspaceId: string;\n name: string;\n slug?: string;\n type: string;\n routingStrategy?: string;\n visibility?: string;\n description?: string;\n icon?: string;\n}\n\ninterface UpdateBotInput {\n botId: string;\n input: GraphQLInput<UpdateBotAppInput>;\n}\n\nconst UPDATE_BOT_APP_FIELDS = fieldsOf<UpdateBotAppInput>({\n bucketId: true,\n context: true,\n defaultAgentId: true,\n description: true,\n fallbackMessage: true,\n icon: true,\n metadata: true,\n name: true,\n routingStrategy: true,\n slug: true,\n status: true,\n tagIds: true,\n tags: true,\n type: true,\n visibility: true,\n welcomeMessage: true,\n workflowId: true,\n});\n\nfunction getWorkspaceClient(client: unknown): WorkspaceClient {\n return client as WorkspaceClient;\n}\n\nfunction buildBotFilter(\n workspaceId: string | undefined,\n filter?: BaseFilter\n): Record<string, unknown> | undefined {\n if (!workspaceId && !filter) return undefined;\n\n return {\n workspaceId,\n search: filter?.search,\n status: filter?.status?.[0],\n visibility: filter?.visibility?.[0],\n bucketId: filter?.bucketId,\n };\n}\n\nexport const botKeys = {\n all: ['bots'] as const,\n lists: () => [...botKeys.all, 'list'] as const,\n list: (filter?: BaseFilter) => [...botKeys.lists(), filter] as const,\n details: () => [...botKeys.all, 'detail'] as const,\n detail: (id: string) => [...botKeys.details(), id] as const,\n};\n\nexport function useBots(filter?: BaseFilter): PaginatedQueryResult<BotAppRecord[]> {\n const { workspaceId } = useBotlit();\n\n const variables = useMemo(\n () => ({ filters: buildBotFilter(workspaceId, filter) }),\n [filter, workspaceId]\n );\n\n return useWorkspacePaginatedQuery<ListBotAppsPageQuery, BotAppRecord, BotAppRecord[]>({\n document: ListBotAppsPageDocument,\n variables,\n pageSize: LIST_PAGE_SIZE,\n extractRows: (data) => data?.listBotAppsPage.items ?? [],\n extractNextOffset: (data) => data?.listBotAppsPage.nextOffset ?? null,\n select: (rows) => rows,\n fallback: NO_BOTS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load bots',\n });\n}\n\n/**\n * Every bot of the workspace, all pages. For pickers that must offer each bot\n * (a route can point at any of them), where `useBots` stops at one page.\n */\nexport function useAllBots(): QueryResult<BotAppRecord[]> {\n const { workspaceId } = useBotlit();\n const variables = useMemo(() => ({ filters: buildBotFilter(workspaceId) }), [workspaceId]);\n\n return useWorkspaceAllPagesQuery<ListBotAppsData, BotAppRecord, BotAppRecord[]>({\n document: LIST_BOT_APPS_DOCUMENT,\n variables,\n pageSize: LIST_PAGE_SIZE,\n extractRows: (data) => data?.listBotApps ?? [],\n select: (rows) => rows,\n fallback: NO_BOTS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load bots',\n });\n}\n\n/**\n * Exact bot counts by status for the workspace (BOFF-12426). Unlike `useBots`\n * this is not capped at one page, so it is the source for dashboard totals.\n * `total` counts every status; the dashboard shows `total - archived`.\n */\nexport interface BotAppCounts {\n total: number;\n draft: number;\n active: number;\n paused: number;\n archived: number;\n}\n\ninterface BotAppCountsData {\n getBotAppCounts?: BotAppCounts | null;\n}\n\nconst GET_BOT_APP_COUNTS_DOCUMENT = gql`\n query GetBotAppCounts {\n getBotAppCounts {\n total\n draft\n active\n paused\n archived\n }\n }\n`;\n\nexport function useBotAppCounts(enabled = true): QueryResult<BotAppCounts | null> {\n const { workspaceId } = useBotlit();\n const variables = useMemo(() => ({}), []);\n\n return useWorkspaceQuery<BotAppCountsData, BotAppCounts | null>({\n document: GET_BOT_APP_COUNTS_DOCUMENT,\n variables,\n select: (data) => data?.getBotAppCounts ?? null,\n fallback: null,\n enabled: enabled && Boolean(workspaceId),\n errorMessage: 'Failed to load bot counts',\n });\n}\n\nexport function useBot(botId: string | undefined) {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [data, setData] = useState<BotAppRecord | null>(null);\n // Loading from the first render when there is a bot to read, so a page that\n // depends on the bot never acts on \"no bot yet\" for the frame before the read.\n const [loading, setLoading] = useState(Boolean(botId));\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!botId) {\n setData(null);\n setLoading(false);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<GetBotAppData>({\n query: GET_BOT_APP_DOCUMENT,\n variables: { id: botId },\n fetchPolicy: 'network-only',\n });\n // Apollo v4 resolves (not rejects) with `result.error` set on GraphQL errors.\n // Without this a FORBIDDEN read looked like \"bot not found\" (BOFF-12436).\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw operationError instanceof Error ? operationError : new Error('Failed to load bot');\n }\n setData(result.data?.getBotApp ?? null);\n } catch (queryError) {\n setData(null);\n setError(queryError instanceof Error ? queryError : new Error('Failed to load bot'));\n } finally {\n setLoading(false);\n }\n }, [botId, client]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\nexport function useCreateBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<BotAppRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const createBot = useCallback(\n async (input: CreateBotInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<CreateBotAppData>({\n mutation: CREATE_BOT_APP_DOCUMENT,\n variables: { input },\n });\n\n const createdBot = result.data?.createBotApp;\n if (!createdBot) {\n throw new Error('Failed to create bot');\n }\n\n setState({ data: createdBot, loading: false, error: undefined });\n return createdBot;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to create bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [createBot, state] as const;\n}\n\nexport function useUpdateBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<BotAppRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const updateBot = useCallback(\n async ({ botId, input }: UpdateBotInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<UpdateBotAppData>({\n mutation: UPDATE_BOT_APP_DOCUMENT,\n variables: { id: botId, input: buildMutationInput(input, UPDATE_BOT_APP_FIELDS) },\n });\n\n const updatedBot = result.data?.updateBotApp;\n if (!updatedBot) {\n throw new Error('Failed to update bot');\n }\n\n setState({ data: updatedBot, loading: false, error: undefined });\n return updatedBot;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to update bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [updateBot, state] as const;\n}\n\nexport function useDeleteBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<boolean>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const deleteBot = useCallback(\n async (botId: string) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<DeleteBotAppData>({\n mutation: DELETE_BOT_APP_DOCUMENT,\n variables: { id: botId },\n });\n\n const deleted = result.data?.deleteBotApp ?? false;\n setState({ data: deleted, loading: false, error: undefined });\n return deleted;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to delete bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [deleteBot, state] as const;\n}\n"],"mappings":";;;;;;;;AAoBA,IAAMA,IAAyB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6B5BC,IAAuB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6B1BC,IAA0B,CAAG;;;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EAAS;IAAE,MAAMI;IAAY,SAAS;IAAO,OAAO,KAAA;GAAU,CAAC,GACxDA;EACT,SAASF,GAAe;GACtB,IAAMZ,IACJY,aAAyB,QAAQA,IAAgB,gBAAI,MAAM,sBAAsB;GAEnF,MADAF,EAAS;IAAE,MAAM,KAAA;IAAW,SAAS;IAAO;GAAM,CAAC,GAC7CV;EACR;CACF,GACA,CAACzB,CAAM,CAGD,GAAWkC,CAAK;AAC1B;AAEA,SAAgBQ,IAAe;CAC7B,IAAM1C,IAASD,EAAmBoB,EAAiB,WAAW,CAAC,GACzD,CAACe,GAAOC,KAAYd,EAAoC;EAC5D,MAAM,KAAA;EACN,SAAS;EACT,OAAO,KAAA;CACT,CAAC;CAwBD,OAAO,CAtBWO,EAChB,OAAO,MAAkB;EACvB,EAAS;GAAE,MAAM,KAAA;GAAW,SAAS;GAAM,OAAO,KAAA;EAAU,CAAC;EAC7D,IAAI;GAMF,IAAMe,KAAU,MALK3C,EAAO,OAAyB;IACnD,UAAUN;IACV,WAAW,EAAE,IAAI8B,EAAM;GACzB,CAAC,EAAA,CAEsB,MAAM,gBAAgB;GAE7C,OADAW,EAAS;IAAE,MAAMQ;IAAS,SAAS;IAAO,OAAO,KAAA;GAAU,CAAC,GACrDA;EACT,SAASN,GAAe;GACtB,IAAMZ,IACJY,aAAyB,QAAQA,IAAgB,gBAAI,MAAM,sBAAsB;GAEnF,MADAF,EAAS;IAAE,MAAM,KAAA;IAAW,SAAS;IAAO;GAAM,CAAC,GAC7CV;EACR;CACF,GACA,CAACzB,CAAM,CAGD,GAAWkC,CAAK;AAC1B"}
1
+ {"version":3,"file":"useBots.js","names":["GET_BOT_APP_DOCUMENT","CREATE_BOT_APP_DOCUMENT","UPDATE_BOT_APP_DOCUMENT","DELETE_BOT_APP_DOCUMENT","LIST_PAGE_SIZE","NO_BOTS","UPDATE_BOT_APP_FIELDS","fieldsOf","getWorkspaceClient","client","buildBotFilter","workspaceId","filter","useBots","useBotlit","variables","useMemo","useWorkspacePaginatedQuery","ListBotAppsPageDocument","data","rows","useAllBots","useWorkspaceAllPagesQuery","GET_BOT_APP_COUNTS_DOCUMENT","useBotAppCounts","useWorkspaceQuery","enabled","useBot","useGatewayClient","setData","useState","loading","setLoading","botId","error","setError","refetch","useCallback","result","operationError","queryError","useEffect","useCreateBot","state","setState","createdBot","mutationError","useUpdateBot","updatedBot","buildMutationInput","input","useDeleteBot","deleted"],"sources":["../../../src/botlit/hooks/useBots.ts"],"sourcesContent":["import { gql, type ApolloClient } from '@apollo/client';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport {\n ListBotAppsPageDocument,\n type ListBotAppsPageQuery,\n} from '../../generated/wspace-operations';\nimport type { UpdateBotAppInput } from '../../generated/wspace-types';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport type { BaseFilter } from '../types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceAllPagesQuery,\n useWorkspacePaginatedQuery,\n useWorkspaceQuery,\n type PaginatedQueryResult,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst GET_BOT_APP_DOCUMENT = gql`\n query GetBotApp($id: ID!) {\n getBotApp(id: $id) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n executionCount\n lastExecutedAt\n tagIds\n tags\n createdAt\n updatedAt\n createdById\n updatedById\n workspaceId\n }\n }\n`;\n\nconst CREATE_BOT_APP_DOCUMENT = gql`\n mutation CreateBotApp($input: CreateBotAppInput!) {\n createBotApp(input: $input) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n workflowId\n tagIds\n tags\n createdAt\n updatedAt\n workspaceId\n }\n }\n`;\n\nconst UPDATE_BOT_APP_DOCUMENT = gql`\n mutation UpdateBotApp($id: ID!, $input: UpdateBotAppInput!) {\n updateBotApp(id: $id, input: $input) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n tagIds\n tags\n updatedAt\n updatedById\n workspaceId\n }\n }\n`;\n\nconst DELETE_BOT_APP_DOCUMENT = gql`\n mutation DeleteBotApp($id: ID!) {\n deleteBotApp(id: $id)\n }\n`;\n\ntype WorkspaceClient = ApolloClient;\n\nexport interface BotAppRecord {\n id: string;\n name: string;\n slug: string;\n description?: string | null;\n icon?: string | null;\n type: string;\n status: string;\n visibility?: string | null;\n routingStrategy?: string | null;\n defaultAgentId?: string | null;\n welcomeMessage?: string | null;\n fallbackMessage?: string | null;\n /** Bound FluidGrids workflow definition id — the bot's designed behaviour. */\n workflowId?: string | null;\n executionCount?: number | null;\n lastExecutedAt?: string | null;\n tagIds?: string[] | null;\n /** Entity-owned universal tag records (JSON). */\n tags?: unknown;\n createdAt?: string | null;\n updatedAt?: string | null;\n createdById?: string | null;\n updatedById?: string | null;\n workspaceId?: string | null;\n}\n\nconst LIST_PAGE_SIZE = 100;\nconst NO_BOTS: BotAppRecord[] = [];\n\ninterface GetBotAppData {\n getBotApp: BotAppRecord | null;\n}\n\ninterface CreateBotAppData {\n createBotApp: BotAppRecord;\n}\n\ninterface UpdateBotAppData {\n updateBotApp: BotAppRecord;\n}\n\ninterface DeleteBotAppData {\n deleteBotApp: boolean;\n}\n\ninterface BotMutationState<T> {\n data: T | undefined;\n loading: boolean;\n error: Error | undefined;\n}\n\ninterface CreateBotInput {\n workspaceId: string;\n name: string;\n slug?: string;\n type: string;\n routingStrategy?: string;\n visibility?: string;\n description?: string;\n icon?: string;\n}\n\ninterface UpdateBotInput {\n botId: string;\n input: GraphQLInput<UpdateBotAppInput>;\n}\n\nconst UPDATE_BOT_APP_FIELDS = fieldsOf<UpdateBotAppInput>({\n bucketId: true,\n context: true,\n defaultAgentId: true,\n description: true,\n fallbackMessage: true,\n icon: true,\n metadata: true,\n name: true,\n routingStrategy: true,\n slug: true,\n status: true,\n tagIds: true,\n tags: true,\n type: true,\n visibility: true,\n welcomeMessage: true,\n workflowId: true,\n});\n\nfunction getWorkspaceClient(client: unknown): WorkspaceClient {\n return client as WorkspaceClient;\n}\n\nfunction buildBotFilter(\n workspaceId: string | undefined,\n filter?: BaseFilter\n): Record<string, unknown> | undefined {\n if (!workspaceId && !filter) return undefined;\n\n return {\n workspaceId,\n search: filter?.search,\n status: filter?.status?.[0],\n visibility: filter?.visibility?.[0],\n bucketId: filter?.bucketId,\n };\n}\n\nexport const botKeys = {\n all: ['bots'] as const,\n lists: () => [...botKeys.all, 'list'] as const,\n list: (filter?: BaseFilter) => [...botKeys.lists(), filter] as const,\n details: () => [...botKeys.all, 'detail'] as const,\n detail: (id: string) => [...botKeys.details(), id] as const,\n};\n\nexport function useBots(filter?: BaseFilter): PaginatedQueryResult<BotAppRecord[]> {\n const { workspaceId } = useBotlit();\n\n const variables = useMemo(\n () => ({ filters: buildBotFilter(workspaceId, filter) }),\n [filter, workspaceId]\n );\n\n return useWorkspacePaginatedQuery<ListBotAppsPageQuery, BotAppRecord, BotAppRecord[]>({\n document: ListBotAppsPageDocument,\n variables,\n pageSize: LIST_PAGE_SIZE,\n extractRows: (data) => data?.listBotAppsPage.items ?? [],\n extractNextOffset: (data) => data?.listBotAppsPage.nextOffset ?? null,\n select: (rows) => rows,\n fallback: NO_BOTS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load bots',\n });\n}\n\n/**\n * Every bot of the workspace, all pages. For pickers that must offer each bot\n * (a route can point at any of them), where `useBots` stops at one page.\n */\nexport function useAllBots(): QueryResult<BotAppRecord[]> {\n const { workspaceId } = useBotlit();\n const variables = useMemo(() => ({ filters: buildBotFilter(workspaceId) }), [workspaceId]);\n\n return useWorkspaceAllPagesQuery<ListBotAppsPageQuery, BotAppRecord, BotAppRecord[]>({\n document: ListBotAppsPageDocument,\n variables,\n pageSize: LIST_PAGE_SIZE,\n extractRows: (data) => data?.listBotAppsPage.items ?? [],\n extractNextOffset: (data) => data?.listBotAppsPage.nextOffset ?? null,\n select: (rows) => rows,\n fallback: NO_BOTS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load bots',\n });\n}\n\n/**\n * Exact bot counts by status for the workspace (BOFF-12426). Unlike `useBots`\n * this is not capped at one page, so it is the source for dashboard totals.\n * `total` counts every status; the dashboard shows `total - archived`.\n */\nexport interface BotAppCounts {\n total: number;\n draft: number;\n active: number;\n paused: number;\n archived: number;\n}\n\ninterface BotAppCountsData {\n getBotAppCounts?: BotAppCounts | null;\n}\n\nconst GET_BOT_APP_COUNTS_DOCUMENT = gql`\n query GetBotAppCounts {\n getBotAppCounts {\n total\n draft\n active\n paused\n archived\n }\n }\n`;\n\nexport function useBotAppCounts(enabled = true): QueryResult<BotAppCounts | null> {\n const { workspaceId } = useBotlit();\n const variables = useMemo(() => ({}), []);\n\n return useWorkspaceQuery<BotAppCountsData, BotAppCounts | null>({\n document: GET_BOT_APP_COUNTS_DOCUMENT,\n variables,\n select: (data) => data?.getBotAppCounts ?? null,\n fallback: null,\n enabled: enabled && Boolean(workspaceId),\n errorMessage: 'Failed to load bot counts',\n });\n}\n\nexport function useBot(botId: string | undefined) {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [data, setData] = useState<BotAppRecord | null>(null);\n // Loading from the first render when there is a bot to read, so a page that\n // depends on the bot never acts on \"no bot yet\" for the frame before the read.\n const [loading, setLoading] = useState(Boolean(botId));\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!botId) {\n setData(null);\n setLoading(false);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<GetBotAppData>({\n query: GET_BOT_APP_DOCUMENT,\n variables: { id: botId },\n fetchPolicy: 'network-only',\n });\n // Apollo v4 resolves (not rejects) with `result.error` set on GraphQL errors.\n // Without this a FORBIDDEN read looked like \"bot not found\" (BOFF-12436).\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw operationError instanceof Error ? operationError : new Error('Failed to load bot');\n }\n setData(result.data?.getBotApp ?? null);\n } catch (queryError) {\n setData(null);\n setError(queryError instanceof Error ? queryError : new Error('Failed to load bot'));\n } finally {\n setLoading(false);\n }\n }, [botId, client]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\nexport function useCreateBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<BotAppRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const createBot = useCallback(\n async (input: CreateBotInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<CreateBotAppData>({\n mutation: CREATE_BOT_APP_DOCUMENT,\n variables: { input },\n });\n\n const createdBot = result.data?.createBotApp;\n if (!createdBot) {\n throw new Error('Failed to create bot');\n }\n\n setState({ data: createdBot, loading: false, error: undefined });\n return createdBot;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to create bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [createBot, state] as const;\n}\n\nexport function useUpdateBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<BotAppRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const updateBot = useCallback(\n async ({ botId, input }: UpdateBotInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<UpdateBotAppData>({\n mutation: UPDATE_BOT_APP_DOCUMENT,\n variables: { id: botId, input: buildMutationInput(input, UPDATE_BOT_APP_FIELDS) },\n });\n\n const updatedBot = result.data?.updateBotApp;\n if (!updatedBot) {\n throw new Error('Failed to update bot');\n }\n\n setState({ data: updatedBot, loading: false, error: undefined });\n return updatedBot;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to update bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [updateBot, state] as const;\n}\n\nexport function useDeleteBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<boolean>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const deleteBot = useCallback(\n async (botId: string) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<DeleteBotAppData>({\n mutation: DELETE_BOT_APP_DOCUMENT,\n variables: { id: botId },\n });\n\n const deleted = result.data?.deleteBotApp ?? false;\n setState({ data: deleted, loading: false, error: undefined });\n return deleted;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to delete bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [deleteBot, state] as const;\n}\n"],"mappings":";;;;;;;;AAoBA,IAAMA,IAAuB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6B1BC,IAA0B,CAAG;;;;;;;;;;;;;;;;;;;;;GAuB7BC,IAA0B,CAAG;;;;;;;;;;;;;;;;;;;;;;;GAyB7BC,IAA0B,CAAG;;;;GAmC7BC,IAAiB,KACjBC,IAA0B,CAAC,GAwC3BC,IAAwBC,EAA4B;CACxD,UAAU;CACV,SAAS;CACT,gBAAgB;CAChB,aAAa;CACb,iBAAiB;CACjB,MAAM;CACN,UAAU;CACV,MAAM;CACN,iBAAiB;CACjB,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,MAAM;CACN,YAAY;CACZ,gBAAgB;CAChB,YAAY;AACd,CAAC;AAED,SAASC,EAAmB,GAAkC;CAC5D,OAAOC;AACT;AAEA,SAASC,EACP,GACA,GACqC;CACrC,IAAKC,KAAgBC,GAErB,OAAO;EACL;EACA,QAAQA,GAAQ;EAChB,QAAQA,GAAQ,SAAS;EACzB,YAAYA,GAAQ,aAAa;EACjC,UAAUA,GAAQ;CACpB;AACF;AAUA,SAAgBC,EAAQ,GAA2D;CACjF,IAAM,EAAE,mBAAgBC,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