@stack-spot/ai-chat-widget 1.28.1-beta.3 → 1.28.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 (103) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/app-metadata.json +3 -3
  3. package/dist/components/AdaptiveTextArea.js +1 -1
  4. package/dist/components/AdaptiveTextArea.js.map +1 -1
  5. package/dist/components/AgentCard/dictionary.d.ts +2 -4
  6. package/dist/components/AgentCard/dictionary.d.ts.map +1 -1
  7. package/dist/components/AgentCard/dictionary.js +2 -4
  8. package/dist/components/AgentCard/dictionary.js.map +1 -1
  9. package/dist/components/Selector/index.d.ts +2 -2
  10. package/dist/components/Selector/index.d.ts.map +1 -1
  11. package/dist/components/Selector/index.js +3 -3
  12. package/dist/components/Selector/index.js.map +1 -1
  13. package/dist/components/Selector/styled.d.ts +1 -1
  14. package/dist/components/Selector/styled.d.ts.map +1 -1
  15. package/dist/components/Selector/styled.js +1 -1
  16. package/dist/components/Selector/styled.js.map +1 -1
  17. package/dist/layout.css +0 -17
  18. package/dist/state/types.d.ts +1 -1
  19. package/dist/state/types.d.ts.map +1 -1
  20. package/dist/utils/tools.d.ts +2 -2
  21. package/dist/utils/tools.d.ts.map +1 -1
  22. package/dist/utils/tools.js +6 -3
  23. package/dist/utils/tools.js.map +1 -1
  24. package/dist/utils/upload/UploadManager.d.ts +0 -2
  25. package/dist/utils/upload/UploadManager.d.ts.map +1 -1
  26. package/dist/utils/upload/UploadManager.js +25 -32
  27. package/dist/utils/upload/UploadManager.js.map +1 -1
  28. package/dist/views/Agents/AgentDescription.d.ts +9 -2
  29. package/dist/views/Agents/AgentDescription.d.ts.map +1 -1
  30. package/dist/views/Agents/AgentDescription.js +9 -12
  31. package/dist/views/Agents/AgentDescription.js.map +1 -1
  32. package/dist/views/Agents/AgentsPanel.d.ts.map +1 -1
  33. package/dist/views/Agents/AgentsPanel.js +11 -11
  34. package/dist/views/Agents/AgentsPanel.js.map +1 -1
  35. package/dist/views/Agents/AgentsTab.d.ts +2 -2
  36. package/dist/views/Agents/AgentsTab.d.ts.map +1 -1
  37. package/dist/views/Agents/AgentsTab.js +6 -6
  38. package/dist/views/Agents/AgentsTab.js.map +1 -1
  39. package/dist/views/Agents/useAgentFavorites.d.ts +1 -1
  40. package/dist/views/Agents/useAgentFavorites.js +4 -4
  41. package/dist/views/Agents/useAgentFavorites.js.map +1 -1
  42. package/dist/views/Chat/ChatMessage.js +3 -3
  43. package/dist/views/Chat/ChatMessage.js.map +1 -1
  44. package/dist/views/ChatHistory/HistoryItem.d.ts.map +1 -1
  45. package/dist/views/ChatHistory/HistoryItem.js +5 -8
  46. package/dist/views/ChatHistory/HistoryItem.js.map +1 -1
  47. package/dist/views/ChatHistory/utils.d.ts +6 -0
  48. package/dist/views/ChatHistory/utils.d.ts.map +1 -1
  49. package/dist/views/ChatHistory/utils.js +16 -1
  50. package/dist/views/ChatHistory/utils.js.map +1 -1
  51. package/dist/views/Home/CustomAgent.js +3 -3
  52. package/dist/views/Home/CustomAgent.js.map +1 -1
  53. package/dist/views/MessageInput/AgentSelector.js +4 -4
  54. package/dist/views/MessageInput/AgentSelector.js.map +1 -1
  55. package/dist/views/MessageInput/ButtonAgent.js +2 -2
  56. package/dist/views/MessageInput/ButtonAgent.js.map +1 -1
  57. package/dist/views/MessageInput/dictionary.d.ts +1 -1
  58. package/dist/views/MessageInput/dictionary.d.ts.map +1 -1
  59. package/dist/views/MessageInput/dictionary.js +0 -9
  60. package/dist/views/MessageInput/dictionary.js.map +1 -1
  61. package/dist/views/MessageInput/index.d.ts.map +1 -1
  62. package/dist/views/MessageInput/index.js +1 -11
  63. package/dist/views/MessageInput/index.js.map +1 -1
  64. package/dist/views/MessageInput/styled.d.ts +1 -1
  65. package/dist/views/MessageInput/styled.js +1 -1
  66. package/dist/views/Tools.js +3 -3
  67. package/dist/views/Tools.js.map +1 -1
  68. package/dist/views/Workspaces/WorkspacesTab.js +1 -1
  69. package/package.json +2 -2
  70. package/src/app-metadata.json +3 -3
  71. package/src/components/AdaptiveTextArea.tsx +1 -1
  72. package/src/components/AgentCard/dictionary.ts +2 -4
  73. package/src/components/Selector/index.tsx +6 -5
  74. package/src/components/Selector/styled.ts +2 -2
  75. package/src/layout.css +0 -17
  76. package/src/state/types.ts +1 -1
  77. package/src/utils/tools.ts +7 -5
  78. package/src/utils/upload/UploadManager.ts +23 -32
  79. package/src/views/Agents/AgentDescription.tsx +25 -19
  80. package/src/views/Agents/AgentsPanel.tsx +12 -11
  81. package/src/views/Agents/AgentsTab.tsx +17 -12
  82. package/src/views/Agents/useAgentFavorites.ts +4 -4
  83. package/src/views/Chat/ChatMessage.tsx +3 -3
  84. package/src/views/ChatHistory/HistoryItem.tsx +5 -10
  85. package/src/views/ChatHistory/utils.ts +18 -1
  86. package/src/views/Home/CustomAgent.tsx +4 -4
  87. package/src/views/MessageInput/AgentSelector.tsx +4 -4
  88. package/src/views/MessageInput/ButtonAgent.tsx +2 -2
  89. package/src/views/MessageInput/dictionary.ts +0 -9
  90. package/src/views/MessageInput/index.tsx +1 -15
  91. package/src/views/MessageInput/styled.ts +1 -1
  92. package/src/views/Tools.tsx +3 -4
  93. package/src/views/Workspaces/WorkspacesTab.tsx +1 -1
  94. package/dist/utils/upload/use-paste-upload.d.ts +0 -8
  95. package/dist/utils/upload/use-paste-upload.d.ts.map +0 -1
  96. package/dist/utils/upload/use-paste-upload.js +0 -19
  97. package/dist/utils/upload/use-paste-upload.js.map +0 -1
  98. package/dist/views/MessageInput/UploadDragNDrop.d.ts +0 -14
  99. package/dist/views/MessageInput/UploadDragNDrop.d.ts.map +0 -1
  100. package/dist/views/MessageInput/UploadDragNDrop.js +0 -52
  101. package/dist/views/MessageInput/UploadDragNDrop.js.map +0 -1
  102. package/src/utils/upload/use-paste-upload.tsx +0 -30
  103. package/src/views/MessageInput/UploadDragNDrop.tsx +0 -83
@@ -1,7 +1,7 @@
1
1
  import { Box, Button, Checkbox, Flex, IconBox, Input, Label, Radio, Text } from '@citric/core'
2
2
  import { Check, Cog, Copy, Dislike, DislikeFill, Like, LikeFill, TimesCircle } from '@citric/icons'
3
3
  import { Badge, IconButton, Tooltip } from '@citric/ui'
4
- import { agentToolsClient } from '@stack-spot/portal-network'
4
+ import { agentClient } from '@stack-spot/portal-network'
5
5
  import { listToClass } from '@stack-spot/portal-theme'
6
6
  import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
7
7
  import { groupBy } from 'lodash'
@@ -193,7 +193,7 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Pr
193
193
  const widget = useWidget()
194
194
  const chat = useCurrentChat()
195
195
  const agentId = entry.agent?.id ?? ''
196
- const [toolKits] = agentToolsClient.tools.useStatefulQuery({}, { enabled: !!agentId })
196
+ const [agent] = agentClient.agentById.useStatefulQuery({ agentId, builtIn: !!entry?.agent?.builtIn }, { enabled: !!agentId })
197
197
  const [copied, setCopied] = useState(false)
198
198
  const [showUserButtonCopy, setShowUserButtonCopy] = useState(false)
199
199
 
@@ -348,7 +348,7 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Pr
348
348
  className="tools-badge"
349
349
  label={t.tools}
350
350
  images={entry.tools.slice(0, 3).map((id) => {
351
- const tool = toolById(id, toolKits)
351
+ const tool = toolById(id, agent?.toolkits)
352
352
  return { key: id, name: tool?.name || id, icon: <Cog />, url: tool?.image }
353
353
  })}
354
354
  onClick={openToolsPanel}
@@ -2,7 +2,7 @@ import { IconBox, Input } from '@citric/core'
2
2
  import { Check, Download, EllipsisHorizontal, Pencil, Trash } from '@citric/icons'
3
3
  import { IconButton, LoadingCircular } from '@citric/ui'
4
4
  import { focusNextIgnoringChildren } from '@stack-spot/portal-components'
5
- import { agentToolsClient, aiClient } from '@stack-spot/portal-network'
5
+ import { aiClient } from '@stack-spot/portal-network'
6
6
  import { ConversationResponse } from '@stack-spot/portal-network/api/ai'
7
7
  import { theme } from '@stack-spot/portal-theme'
8
8
  import { last } from 'lodash'
@@ -11,13 +11,12 @@ import { OverlayMenu } from '../../components/OverlayMenu'
11
11
  import { useWidget } from '../../context/hooks'
12
12
  import { ChatEntry } from '../../state/ChatEntry'
13
13
  import { ChatState } from '../../state/ChatState'
14
- import { LabeledAgent } from '../../state/types'
15
14
  import { ButtonAction } from '../../types'
16
15
  import { download } from '../../utils/download'
17
16
  import { genericSourcesToKnowledgeSources } from '../../utils/knowledge-source'
18
17
  import { useHistoryDictionary } from './dictionary'
19
18
  import { HistoryItemBox } from './styled'
20
- import { findStack, findWorkspace } from './utils'
19
+ import { findStack, findWorkspace, getAllAgents } from './utils'
21
20
 
22
21
  /**
23
22
  * Renders an item of the list of conversations (history).
@@ -89,16 +88,12 @@ export const HistoryItem = ({ item }: { item: ConversationResponse }) => {
89
88
  setLoading(true)
90
89
  try {
91
90
  const chat = await aiClient.chat.query({ conversationId: item.id })
92
- const historyAgentIds = chat.history?.map(item => item.custom_agent?.id).filter(Boolean) as string[] ?? []
93
91
  const [stack, workspace, agents] = await Promise.all([
94
92
  findStack(chat.ai_stack_id),
95
93
  findWorkspace(chat.workspace_id),
96
- agentToolsClient.agentsByIds.query({ searchAgentsRequest: { ids: historyAgentIds } }),
94
+ getAllAgents(),
97
95
  ])
98
- const agentsAsLabeledAgents: LabeledAgent[] = agents
99
- .map((a) => ({ ...a, label: a.name, image: a.avatar ?? '', builtIn: a.visibility_level === 'built_in' }))
100
-
101
- const agent = agentsAsLabeledAgents.find(a => a.id === last(chat.history)?.custom_agent?.id)
96
+ const agent = agents.find(a => a.id === last(chat.history)?.custom_agent?.id)
102
97
  const builtIn = !!last(chat.history ?? [])?.custom_agent?.built_in
103
98
  widget.chatTabs.add(new ChatState({
104
99
  id: chat.id,
@@ -108,7 +103,7 @@ export const HistoryItem = ({ item }: { item: ConversationResponse }) => {
108
103
  agentType: item.agent === 'USER' ? 'user' : 'bot',
109
104
  content: item.content,
110
105
  type: 'md',
111
- agent: agentsAsLabeledAgents.find(a => a.id === item.custom_agent?.id),
106
+ agent: agents.find(a => a.id === item.custom_agent?.id),
112
107
  messageId: item.message_id,
113
108
  knowledgeSources: item.agent === 'USER' ? undefined : genericSourcesToKnowledgeSources(item.sources),
114
109
  updated: item.updated,
@@ -1,5 +1,6 @@
1
- import { aiClient, workspaceClient } from '@stack-spot/portal-network'
1
+ import { agentClient, aiClient, workspaceClient } from '@stack-spot/portal-network'
2
2
  import { ChatProperties } from '../../state/ChatState'
3
+ import { LabeledWithImage } from '../../state/types'
3
4
 
4
5
  /**
5
6
  * Finds a stack by its id.
@@ -35,3 +36,19 @@ export async function findWorkspace(id: string | null): Promise<ChatProperties['
35
36
  return { id, label: id }
36
37
  }
37
38
  }
39
+
40
+
41
+ /**
42
+ * Finds all the agents, including common agents and public agents.
43
+ * @returns an array with every agent.
44
+ */
45
+ export async function getAllAgents(): Promise<LabeledWithImage[]> {
46
+ try {
47
+ const agents = await agentClient.allAgents.query({ visibilities: ['ALL'] })
48
+ return agents.map(a => ({ id: a.id, label: a.name, image: a.avatar, slug: a.slug, builtIn: a.builtIn }))
49
+ } catch (error) {
50
+ // eslint-disable-next-line no-console
51
+ console.error(error)
52
+ return []
53
+ }
54
+ }
@@ -1,6 +1,6 @@
1
1
  import { IconBox, Text } from '@citric/core'
2
2
  import { Agent } from '@citric/icons'
3
- import { agentToolsClient } from '@stack-spot/portal-network'
3
+ import { agentClient } from '@stack-spot/portal-network'
4
4
  import { useMemo } from 'react'
5
5
  import { QuickStartButton } from '../../components/QuickStartButton'
6
6
  import { useCurrentChat, useCurrentChatState } from '../../context/hooks'
@@ -12,15 +12,15 @@ import { HomeBox } from './styled'
12
12
  */
13
13
  export const CustomAgent = () => {
14
14
  const { id, label, image } = useCurrentChatState('agent') ?? {}
15
- const [agent] = agentToolsClient.agent.useStatefulQuery({ agentId: id! })
15
+ const [agent] = agentClient.agent.useStatefulQuery({ agentId: id! })
16
16
  const chat = useCurrentChat()
17
- const suggestions = useMemo(() => agent?.conversation_starter?.map((prompt, index) => (
17
+ const suggestions = useMemo(() => agent?.suggested_prompts?.map((prompt, index) => (
18
18
  <QuickStartButton
19
19
  key={index}
20
20
  label={prompt}
21
21
  onClick={() => send(prompt)}
22
22
  />
23
- )), [agent?.conversation_starter])
23
+ )), [agent?.suggested_prompts])
24
24
 
25
25
  function send(message: string) {
26
26
  chat.pushMessage(ChatEntry.createUserEntry(message))
@@ -1,6 +1,6 @@
1
1
  import { Flex, IconBox, Image } from '@citric/core'
2
2
  import { Agent } from '@citric/icons'
3
- import { AgentResponseWithBuiltIn, agentToolsClient } from '@stack-spot/portal-network'
3
+ import { agentClient, AgentResponseWithBuiltIn } from '@stack-spot/portal-network'
4
4
  import { useCallback } from 'react'
5
5
  import { Selector } from '../../components/Selector'
6
6
  import { useCurrentChat, useCurrentChatState } from '../../context/hooks'
@@ -53,9 +53,9 @@ export const AgentSelector = ({ inputRef, isTrial }: {
53
53
 
54
54
  const getAgents = () => {
55
55
  if (isTrial) {
56
- return agentToolsClient.allAgents.useQuery({ visibilities: ['personal', 'built_in'] })
56
+ return agentClient.allAgents.useQuery({ visibilities: ['PERSONAL', 'BUILT-IN'] })
57
57
  }
58
- return agentToolsClient.allAgents.useQuery({ visibilities: ['account', 'shared', 'personal', 'built_in', 'workspace'] })
58
+ return agentClient.allAgents.useQuery({ visibilities: ['ACCOUNT', 'SHARED', 'PERSONAL', 'BUILT-IN', 'WORKSPACE'] })
59
59
  }
60
60
 
61
61
  return <Selector
@@ -68,7 +68,7 @@ export const AgentSelector = ({ inputRef, isTrial }: {
68
68
  regex: agentRegex,
69
69
  urlBuilder: (agent) => `/agents/${agent?.id}`,
70
70
  searchProp: 'name',
71
- sections: isTrial ? ['favorite', 'personal', 'built_in'] : ['favorite', 'personal', 'workspace', 'account', 'shared', 'built_in'],
71
+ sections: isTrial ? ['favorite', 'personal', 'built-in'] : ['favorite', 'personal', 'workspace', 'account', 'shared', 'built-in'],
72
72
  renderComponentItem: AgentItem,
73
73
  isEnabled: isAgentEnabled,
74
74
  onSelect: onSelectItem,
@@ -2,14 +2,14 @@ import { Flex, IconBox } from '@citric/core'
2
2
  import { Agent, TimesMini } from '@citric/icons'
3
3
  import { IconButton, Tooltip } from '@citric/ui'
4
4
  import { MiniLogo } from '@stack-spot/portal-components/svg'
5
- import { agentToolsClient } from '@stack-spot/portal-network'
5
+ import { agentClient } from '@stack-spot/portal-network'
6
6
  import { useEffect } from 'react'
7
7
  import { useCurrentChat, useCurrentChatState, useWidget } from '../../context/hooks'
8
8
  import { useMessageInputDictionary } from './dictionary'
9
9
 
10
10
  export const ButtonAgent = () => {
11
11
  const t = useMessageInputDictionary()
12
- const agentDefault = agentToolsClient.agentDefault.useQuery()
12
+ const agentDefault = agentClient.agentDefault.useQuery({})
13
13
  const widget = useWidget()
14
14
  const chat = useCurrentChat()
15
15
  const agent = useCurrentChatState('agent')
@@ -9,7 +9,6 @@ const dictionary = {
9
9
  agent: 'Select agent',
10
10
  send: 'Send message',
11
11
  placeholder: 'Send a message to $0. For commands, use @ or /',
12
- typing: 'Type your message...',
13
12
  cancel: 'Cancel',
14
13
  removeConfig: 'Remove all the configuration',
15
14
  removeStack: 'Stop using the current stack',
@@ -23,10 +22,6 @@ const dictionary = {
23
22
  collapse: 'Collapse options',
24
23
  uploadSizeError: 'The following files were not added to the upload list because they\'re larger than $1:',
25
24
  uploadItemLimitError: 'The following files were not added because no more than $1 items may be uploaded at a time:',
26
- uploadError: 'An error occurred while uploading the file "$0".',
27
- uploadDragging: 'Drop the file here to upload',
28
- uploadDragDropTitle: 'Arraste e solte arquivos',
29
- uploadDragDropDescription: 'Solte arquivos aqui para enviá-los na conversa',
30
25
  cantSendBecauseOfUploadError: 'Can\'t send the message because one of the files in the upload list could not be uploaded. Please, retry it or remove it from the list.',
31
26
  cantSendBecauseOfUploadProgress: 'Please wait until all files are uploaded before sending the message. You can also cancel the upload by removing it from the list of uploads.',
32
27
  cantSendBecauseOfEmptyContent: 'You can\'t send empty messages. Please write some text or upload a file.',
@@ -40,7 +35,6 @@ const dictionary = {
40
35
  agent: 'Selecionar agente',
41
36
  send: 'Enviar mensagem',
42
37
  placeholder: 'Envie uma mensagem para $0. Para comandos, use @ ou /',
43
- typing: 'Digite sua mensagem...',
44
38
  cancel: 'Cancelar',
45
39
  removeConfig: 'Remover todas as configurações',
46
40
  removeStack: 'Parar de usar a stack atual',
@@ -55,9 +49,6 @@ const dictionary = {
55
49
  uploadSizeError: 'Os seguintes arquivos não foram adicionados à lista de upload porque eles são maiores que $0:',
56
50
  uploadItemLimitError: 'Os seguintes arquivos não foram adicionados à lista de upload porque é permitido enviar no máximo $0 arquivos por vez:',
57
51
  uploadError: 'Ocorreu um erro ao enviar o arquivo "$0".',
58
- uploadDragging: 'Solte o arquivo aqui para fazer upload',
59
- uploadDragDropTitle: 'Solte seus arquivos aqui',
60
- uploadDragDropDescription: 'Arraste ou solte arquivos para compartilhar na conversa',
61
52
  unknownUploadError: 'Ocorreu um erro ao enviar os arquivos.',
62
53
  cantSendBecauseOfUploadError: 'Não é possível enviar a mensagem, pois um dos arquivos na lista de uploads não pôde ser enviado. Por favor, tente enviá-lo novamente ou remova-o da lista.',
63
54
  cantSendBecauseOfUploadProgress: 'Por favor aguarde todos os uploads de arquivos antes de enviar a mensagem. Você pode cancelar o upload removendo o arquivo da lista de uploads.',
@@ -8,7 +8,6 @@ import { quickCommandRegex } from '../../regex'
8
8
  import { ChatEntry } from '../../state/ChatEntry'
9
9
  import { checkIsTrial } from '../../utils/check-is-trial'
10
10
  import { UploadProvider } from '../../utils/upload/context'
11
- import { usePasteUpload } from '../../utils/upload/use-paste-upload'
12
11
  import { AgentSelector } from './AgentSelector'
13
12
  import { ButtonAgent } from './ButtonAgent'
14
13
  import { ButtonBar } from './ButtonBar'
@@ -18,7 +17,6 @@ import { useMessageInputDictionary } from './dictionary'
18
17
  import { QuickCommandSelector } from './QuickCommandSelector'
19
18
  import { MAX_INPUT_HEIGHT, MessageInputBox, MIN_INPUT_HEIGHT } from './styled'
20
19
  import { UploadBar } from './UploadBar'
21
- import { UploadDragNDrop, useUploadDragDrop } from './UploadDragNDrop'
22
20
 
23
21
  /**
24
22
  * This renders the MessageInput part of the layout which includes the progress bar, the actual textarea, the badges telling what is
@@ -38,13 +36,6 @@ export const MessageInput = () => {
38
36
  const agentLabel = useCurrentChatState('agent')?.label
39
37
  const { handleKeyDown, handleKeyUp } = useUserEntryHistoryShortcut()
40
38
  const isTrial = checkIsTrial()
41
- const { isDragging, handleDrop, handleDragLeave } = useUploadDragDrop()
42
-
43
- usePasteUpload({
44
- textAreaRef,
45
- onUploadFiles: files => chat.uploadManager.add(files),
46
- enabled: !isLoading,
47
- })
48
39
 
49
40
  const checkSendRequirements = useCallback(() => {
50
41
  if (chat.uploadManager.status === 'error') {
@@ -121,11 +112,7 @@ export const MessageInput = () => {
121
112
  <ButtonAgent />
122
113
  <AdaptiveTextArea
123
114
  ref={textAreaRef}
124
- placeholder={
125
- agentLabel
126
- ? interpolate(t.placeholder, agentLabel)
127
- : t.typing
128
- }
115
+ placeholder={agentLabel && interpolate(t.placeholder, agentLabel)}
129
116
  onChange={e => chat.set('nextMessage', e.target.value)}
130
117
  value={value}
131
118
  onFocus={() => setFocused(true)}
@@ -144,7 +131,6 @@ export const MessageInput = () => {
144
131
  {chat.get('features').upload && <UploadBar />}
145
132
  <ButtonBar onSend={onSend} isLoading={isLoading} />
146
133
  </MessageInputBox>
147
- <UploadDragNDrop isDragging={isDragging} onDrop={handleDrop} onDragLeave={handleDragLeave} />
148
134
  </UploadProvider>
149
135
  )
150
136
  }
@@ -6,7 +6,7 @@ const CONTEXT_BAR_HEIGHT = 38
6
6
  const CONTEXT_BAR_DISPLACEMENT = 4
7
7
  const UPLOAD_BAR_HEIGHT = 60
8
8
  const UPLOAD_BAR_DISPLACEMENT = 4
9
- export const MAX_INPUT_HEIGHT = 300
9
+ export const MAX_INPUT_HEIGHT = 200
10
10
  export const MIN_INPUT_HEIGHT = 24
11
11
 
12
12
  export const SelectionBarWrapper = styled.div`
@@ -1,4 +1,4 @@
1
- import { agentToolsClient } from '@stack-spot/portal-network'
1
+ import { agentClient } from '@stack-spot/portal-network'
2
2
  import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
3
3
  import { useEffect, useMemo } from 'react'
4
4
  import styled from 'styled-components'
@@ -40,9 +40,8 @@ const ToolsPanel = () => {
40
40
  const chat = widget.chatTabs.getAll().find(c => c.id === chatId)
41
41
  return chat?.getMessages().find(m => m.id === messageId)?.getValue()
42
42
  }, [messageId])
43
-
44
- const [toolKits] = agentToolsClient.tools.useStatefulQuery({}, { enabled: !!message?.agent?.id })
45
- const tools = useMemo(() => message?.tools?.map(id => toolById(id, toolKits) ?? { id }), [messageId, toolKits])
43
+ const [agent] = agentClient.agent.useStatefulQuery({ agentId: message?.agent?.id ?? '' }, { enabled: !!message?.agent?.id })
44
+ const tools = useMemo(() => message?.tools?.map(id => toolById(id, agent?.toolkits) ?? { id }), [messageId, agent])
46
45
 
47
46
  return !!tools?.length && (
48
47
  <ToolList>
@@ -60,7 +60,7 @@ export const WorkspaceResources = ({ workspaceId, allKS, agent, stack }: Omit<Ta
60
60
  const handleNavigate = (resource: WorkspaceResource) => {
61
61
  startTransition(() => {
62
62
  if (resource.resourceType === 'agent')
63
- navigate({ component: 'agent', props: { visibility: 'workspace', agent, workspaceId, showSubmitButton }, fullScreen: true })
63
+ navigate({ component: 'agent', props: { visibility: 'WORKSPACE', agent, workspaceId, showSubmitButton }, fullScreen: true })
64
64
 
65
65
  if (resource.resourceType === 'ks')
66
66
  navigate({ component: 'ks', props: { visibility: 'workspace', allKS, workspaceId, showSubmitButton }, fullScreen: true })
@@ -1,8 +0,0 @@
1
- interface UsePasteUploadProps {
2
- textAreaRef: React.RefObject<HTMLTextAreaElement>;
3
- onUploadFiles: (files: File[]) => void;
4
- enabled?: boolean;
5
- }
6
- export declare const usePasteUpload: ({ textAreaRef, onUploadFiles, enabled, }: UsePasteUploadProps) => void;
7
- export {};
8
- //# sourceMappingURL=use-paste-upload.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-paste-upload.d.ts","sourceRoot":"","sources":["../../../src/utils/upload/use-paste-upload.tsx"],"names":[],"mappings":"AAEA,UAAU,mBAAmB;IAC3B,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;IAClD,aAAa,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,cAAc,6CAIxB,mBAAmB,SAiBrB,CAAA"}
@@ -1,19 +0,0 @@
1
- import { useEffect } from 'react';
2
- export const usePasteUpload = ({ textAreaRef, onUploadFiles, enabled = true, }) => {
3
- useEffect(() => {
4
- const textarea = textAreaRef.current;
5
- if (!textarea || !enabled)
6
- return;
7
- const handlePaste = (e) => {
8
- if (e.clipboardData?.files?.length) {
9
- onUploadFiles(Array.from(e.clipboardData.files));
10
- e.preventDefault();
11
- }
12
- };
13
- textarea.addEventListener('paste', handlePaste);
14
- return () => {
15
- textarea.removeEventListener('paste', handlePaste);
16
- };
17
- }, [onUploadFiles, textAreaRef, enabled]);
18
- };
19
- //# sourceMappingURL=use-paste-upload.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-paste-upload.js","sourceRoot":"","sources":["../../../src/utils/upload/use-paste-upload.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAQjC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAC7B,WAAW,EACX,aAAa,EACb,OAAO,GAAG,IAAI,GACM,EAAE,EAAE;IACxB,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAA;QACpC,IAAI,CAAC,QAAQ,IAAI,CAAC,OAAO;YAAE,OAAM;QAEjC,MAAM,WAAW,GAAG,CAAC,CAAiB,EAAE,EAAE;YACxC,IAAI,CAAC,CAAC,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;gBACnC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAA;gBAChD,CAAC,CAAC,cAAc,EAAE,CAAA;YACpB,CAAC;QACH,CAAC,CAAA;QAED,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;QAC/C,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;QACpD,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,aAAa,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAA;AAC3C,CAAC,CAAA"}
@@ -1,14 +0,0 @@
1
- import { DragEvent } from 'react';
2
- export declare function useUploadDragDrop(containerSelector?: string): {
3
- isDragging: boolean;
4
- handleDrop: (e: DragEvent) => void;
5
- handleDragLeave: (e: DragEvent) => void;
6
- };
7
- interface UploadDragNDropProps {
8
- isDragging?: boolean;
9
- onDrop?: (e: DragEvent) => void;
10
- onDragLeave?: (e: DragEvent) => void;
11
- }
12
- export declare const UploadDragNDrop: ({ isDragging, onDrop, onDragLeave }: UploadDragNDropProps) => import("react/jsx-runtime").JSX.Element | null;
13
- export {};
14
- //# sourceMappingURL=UploadDragNDrop.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UploadDragNDrop.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/UploadDragNDrop.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAoC,MAAM,OAAO,CAAA;AAInE,wBAAgB,iBAAiB,CAAC,iBAAiB,GAAE,MAA0B;;oBAI1C,SAAS;yBASJ,SAAS;EA2BlD;AAED,UAAU,oBAAoB;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;IAChC,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,eAAe,wCAAyC,oBAAoB,mDA4BxF,CAAA"}
@@ -1,52 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { IconBox } from '@citric/core';
3
- import { Document } from '@citric/icons';
4
- import { useCallback, useEffect, useState } from 'react';
5
- import { useCurrentChat } from '../../context/hooks.js';
6
- import { useMessageInputDictionary } from './dictionary.js';
7
- export function useUploadDragDrop(containerSelector = '.chat-container') {
8
- const [isDragging, setIsDragging] = useState(false);
9
- const chat = useCurrentChat();
10
- const handleDrop = useCallback((e) => {
11
- e.preventDefault();
12
- e.stopPropagation();
13
- setIsDragging(false);
14
- if (e.dataTransfer?.files?.length) {
15
- chat.uploadManager.add(Array.from(e.dataTransfer.files));
16
- }
17
- }, [chat]);
18
- const handleDragLeave = useCallback((e) => {
19
- e.preventDefault();
20
- if (e.currentTarget && !e.currentTarget.contains(e.relatedTarget)) {
21
- setIsDragging(false);
22
- }
23
- }, []);
24
- useEffect(() => {
25
- const container = document.querySelector(containerSelector);
26
- if (!container)
27
- return;
28
- const nativeHandleDragEnter = (e) => {
29
- e.preventDefault();
30
- setIsDragging(true);
31
- };
32
- container.addEventListener('dragenter', nativeHandleDragEnter);
33
- return () => {
34
- container.removeEventListener('dragenter', nativeHandleDragEnter);
35
- };
36
- }, [containerSelector]);
37
- return {
38
- isDragging,
39
- handleDrop,
40
- handleDragLeave,
41
- };
42
- }
43
- export const UploadDragNDrop = ({ isDragging, onDrop, onDragLeave }) => {
44
- const t = useMessageInputDictionary();
45
- if (!isDragging)
46
- return null;
47
- return (_jsxs("div", { className: "upload-drag-drop", "data-active": isDragging, role: "dialog", "aria-modal": "true", "aria-labelledby": "upload-drag-drop-title", "aria-describedby": "upload-drag-drop-description", onDrop: onDrop, onDragLeave: onDragLeave, onDragOver: e => {
48
- e.preventDefault();
49
- e.stopPropagation();
50
- }, tabIndex: -1, children: [_jsx(IconBox, { size: "lg", "aria-hidden": true, children: _jsx(Document, {}) }), _jsx("h2", { id: "upload-drag-drop-title", children: t.uploadDragDropTitle }), _jsx("p", { id: "upload-drag-drop-description", children: t.uploadDragDropDescription })] }));
51
- };
52
- //# sourceMappingURL=UploadDragNDrop.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UploadDragNDrop.js","sourceRoot":"","sources":["../../../src/views/MessageInput/UploadDragNDrop.tsx"],"names":[],"mappings":"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"}
@@ -1,30 +0,0 @@
1
- import { useEffect } from 'react'
2
-
3
- interface UsePasteUploadProps {
4
- textAreaRef: React.RefObject<HTMLTextAreaElement>,
5
- onUploadFiles: (files: File[]) => void,
6
- enabled?: boolean,
7
- }
8
-
9
- export const usePasteUpload = ({
10
- textAreaRef,
11
- onUploadFiles,
12
- enabled = true,
13
- }: UsePasteUploadProps) => {
14
- useEffect(() => {
15
- const textarea = textAreaRef.current
16
- if (!textarea || !enabled) return
17
-
18
- const handlePaste = (e: ClipboardEvent) => {
19
- if (e.clipboardData?.files?.length) {
20
- onUploadFiles(Array.from(e.clipboardData.files))
21
- e.preventDefault()
22
- }
23
- }
24
-
25
- textarea.addEventListener('paste', handlePaste)
26
- return () => {
27
- textarea.removeEventListener('paste', handlePaste)
28
- }
29
- }, [onUploadFiles, textAreaRef, enabled])
30
- }
@@ -1,83 +0,0 @@
1
- import { IconBox } from '@citric/core'
2
- import { Document } from '@citric/icons'
3
- import { DragEvent, useCallback, useEffect, useState } from 'react'
4
- import { useCurrentChat } from '../../context/hooks'
5
- import { useMessageInputDictionary } from './dictionary'
6
-
7
- export function useUploadDragDrop(containerSelector: string = '.chat-container') {
8
- const [isDragging, setIsDragging] = useState(false)
9
- const chat = useCurrentChat()
10
-
11
- const handleDrop = useCallback((e: DragEvent) => {
12
- e.preventDefault()
13
- e.stopPropagation()
14
- setIsDragging(false)
15
- if (e.dataTransfer?.files?.length) {
16
- chat.uploadManager.add(Array.from(e.dataTransfer.files))
17
- }
18
- }, [chat])
19
-
20
- const handleDragLeave = useCallback((e: DragEvent) => {
21
- e.preventDefault()
22
- if (e.currentTarget && !e.currentTarget.contains(e.relatedTarget as Node)) {
23
- setIsDragging(false)
24
- }
25
- }, [])
26
-
27
- useEffect(() => {
28
- const container = document.querySelector(containerSelector) as HTMLDivElement | null
29
- if (!container) return
30
-
31
- const nativeHandleDragEnter = (e: Event) => {
32
- e.preventDefault()
33
- setIsDragging(true)
34
- }
35
-
36
- container.addEventListener('dragenter', nativeHandleDragEnter)
37
- return () => {
38
- container.removeEventListener('dragenter', nativeHandleDragEnter)
39
- }
40
- }, [containerSelector])
41
-
42
- return {
43
- isDragging,
44
- handleDrop,
45
- handleDragLeave,
46
- }
47
- }
48
-
49
- interface UploadDragNDropProps {
50
- isDragging?: boolean,
51
- onDrop?: (e: DragEvent) => void,
52
- onDragLeave?: (e: DragEvent) => void,
53
- }
54
-
55
- export const UploadDragNDrop = ({ isDragging, onDrop, onDragLeave }: UploadDragNDropProps) => {
56
- const t = useMessageInputDictionary()
57
-
58
- if (!isDragging) return null
59
-
60
- return (
61
- <div
62
- className="upload-drag-drop"
63
- data-active={isDragging}
64
- role="dialog"
65
- aria-modal="true"
66
- aria-labelledby="upload-drag-drop-title"
67
- aria-describedby="upload-drag-drop-description"
68
- onDrop={onDrop}
69
- onDragLeave={onDragLeave}
70
- onDragOver={e => {
71
- e.preventDefault()
72
- e.stopPropagation()
73
- }}
74
- tabIndex={-1}
75
- >
76
- <IconBox size="lg" aria-hidden={true}>
77
- <Document />
78
- </IconBox>
79
- <h2 id="upload-drag-drop-title">{t.uploadDragDropTitle}</h2>
80
- <p id="upload-drag-drop-description">{t.uploadDragDropDescription}</p>
81
- </div>
82
- )
83
- }