@budibase/frontend-core 3.39.18 → 3.39.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@budibase/frontend-core",
3
- "version": "3.39.18",
3
+ "version": "3.39.20",
4
4
  "description": "Budibase frontend core libraries used in builder and client",
5
5
  "author": "Budibase",
6
6
  "license": "MPL-2.0",
@@ -23,5 +23,5 @@
23
23
  "devDependencies": {
24
24
  "vitest": "^4.1.0"
25
25
  },
26
- "gitHead": "2fd13ac0af55769a85500ddea137c056d858ceb8"
26
+ "gitHead": "20794a65fa61d7d5fe90dd923aebc037a68af4d4"
27
27
  }
@@ -42,7 +42,8 @@ export interface ChatAppEndpoints {
42
42
  fetchChatAppAgentFileUrl: (
43
43
  chatAppId: string,
44
44
  agentId: string,
45
- fileId: string
45
+ fileId: string,
46
+ operationId: string
46
47
  ) => Promise<FetchAgentFileUrlResponse>
47
48
  createChatConversation: (
48
49
  chat: CreateChatConversationRequest,
@@ -190,10 +191,14 @@ export const buildChatAppEndpoints = (
190
191
  fetchChatAppAgentFileUrl: async (
191
192
  chatAppId: string,
192
193
  agentId: string,
193
- fileId: string
194
+ fileId: string,
195
+ operationId: string
194
196
  ) => {
197
+ if (!operationId) {
198
+ throw new Error("operationId is required to fetch a chat app agent file")
199
+ }
195
200
  return await API.get<FetchAgentFileUrlResponse>({
196
- url: `/api/chatapps/${chatAppId}/agents/${agentId}/files/${fileId}/url`,
201
+ url: `/api/chatapps/${chatAppId}/agents/${agentId}/operations/${operationId}/files/${fileId}/url`,
197
202
  })
198
203
  },
199
204
 
@@ -18,7 +18,6 @@
18
18
  name?: string
19
19
  icon?: string
20
20
  iconColor?: string
21
- allowKnowledgeSourceDownload?: boolean
22
21
  }
23
22
 
24
23
  export let selectedAgentId: string | null = null
@@ -80,10 +79,6 @@
80
79
 
81
80
  $: readOnlyReason = getReadOnlyReason(agentAvailability)
82
81
 
83
- $: allowKnowledgeSourceDownload = enabledAgentList.find(
84
- agent => agent.agentId === selectedAgentId
85
- )?.allowKnowledgeSourceDownload
86
-
87
82
  const selectAgent = (agentId: string) => {
88
83
  dispatch("agentSelected", { agentId })
89
84
  }
@@ -132,7 +127,6 @@
132
127
  {workspaceId}
133
128
  {conversationStarters}
134
129
  {initialPrompt}
135
- {allowKnowledgeSourceDownload}
136
130
  readOnly={Boolean(readOnlyReason)}
137
131
  {readOnlyReason}
138
132
  onchatsaved={event => dispatch("chatSaved", event.detail)}
@@ -39,10 +39,8 @@
39
39
  detail: { chatId?: string; chat: ChatConversationLike }
40
40
  }) => void
41
41
  isAgentPreviewChat?: boolean
42
- operationId?: string
43
42
  readOnly?: boolean
44
43
  readOnlyReason?: "disabled" | "deleted" | "offline"
45
- allowKnowledgeSourceDownload?: boolean
46
44
  }
47
45
 
48
46
  let {
@@ -53,10 +51,8 @@
53
51
  initialPrompt = "",
54
52
  onchatsaved,
55
53
  isAgentPreviewChat = false,
56
- operationId,
57
54
  readOnly = false,
58
55
  readOnlyReason,
59
- allowKnowledgeSourceDownload = true,
60
56
  }: Props = $props()
61
57
 
62
58
  let API = $state(
@@ -85,9 +81,14 @@
85
81
  }
86
82
 
87
83
  const openRagSource = async (
84
+ message: UIMessage<AgentMessageMetadata>,
88
85
  source: NonNullable<AgentMessageMetadata["ragSources"]>[number]
89
86
  ) => {
90
- if (!allowKnowledgeSourceDownload) {
87
+ const selectedOperationId = message.metadata?.selectedOperationId
88
+ const messageAllowsDownload =
89
+ message.metadata?.allowKnowledgeSourceDownload === true
90
+
91
+ if (!messageAllowsDownload) {
91
92
  notifications.error("Source downloads are disabled for this agent")
92
93
  return
93
94
  }
@@ -97,19 +98,23 @@
97
98
 
98
99
  try {
99
100
  const resolvedUrl =
100
- !isAgentPreviewChat && chat?.chatAppId && chat?.agentId
101
+ !isAgentPreviewChat &&
102
+ chat?.chatAppId &&
103
+ chat?.agentId &&
104
+ selectedOperationId
101
105
  ? (
102
106
  await API.fetchChatAppAgentFileUrl(
103
107
  chat.chatAppId,
104
108
  chat.agentId,
105
- source.fileId
109
+ source.fileId,
110
+ selectedOperationId
106
111
  )
107
112
  ).url
108
- : isAgentPreviewChat && chat?.agentId && operationId
113
+ : isAgentPreviewChat && chat?.agentId && selectedOperationId
109
114
  ? (
110
115
  await API.fetchOperationFileUrl(
111
116
  chat.agentId,
112
- operationId,
117
+ selectedOperationId,
113
118
  source.fileId
114
119
  )
115
120
  ).url
@@ -137,6 +142,10 @@
137
142
  .map(p => p.text)
138
143
  .join("")
139
144
 
145
+ const canDownloadSource = (message: UIMessage<AgentMessageMetadata>) =>
146
+ message.metadata?.allowKnowledgeSourceDownload === true &&
147
+ !!message.metadata?.selectedOperationId
148
+
140
149
  const getCachedReasoningText = (message: UIMessage<AgentMessageMetadata>) =>
141
150
  reasoningTextByMessageId[message.id] || getReasoningText(message)
142
151
 
@@ -781,11 +790,11 @@
781
790
  <ul>
782
791
  {#each getVisibleRagSources(message) as source (source.fileId)}
783
792
  <li class="source-item">
784
- {#if allowKnowledgeSourceDownload}
793
+ {#if canDownloadSource(message)}
785
794
  <button
786
795
  type="button"
787
796
  class="source-link"
788
- onclick={() => openRagSource(source)}
797
+ onclick={() => openRagSource(message, source)}
789
798
  >
790
799
  {source.filename}
791
800
  </button>