@stack-spot/ai-chat-widget 1.27.1 → 1.28.1-beta.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 (100) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/app-metadata.json +3 -3
  3. package/dist/chat-interceptors/quick-commands.d.ts.map +1 -1
  4. package/dist/chat-interceptors/quick-commands.js +19 -1
  5. package/dist/chat-interceptors/quick-commands.js.map +1 -1
  6. package/dist/components/AgentCard/dictionary.d.ts +4 -2
  7. package/dist/components/AgentCard/dictionary.d.ts.map +1 -1
  8. package/dist/components/AgentCard/dictionary.js +4 -2
  9. package/dist/components/AgentCard/dictionary.js.map +1 -1
  10. package/dist/components/Selector/index.d.ts +2 -2
  11. package/dist/components/Selector/index.d.ts.map +1 -1
  12. package/dist/components/Selector/index.js +2 -2
  13. package/dist/components/Selector/index.js.map +1 -1
  14. package/dist/layout.css +17 -0
  15. package/dist/state/types.d.ts +1 -1
  16. package/dist/state/types.d.ts.map +1 -1
  17. package/dist/utils/tools.d.ts +2 -2
  18. package/dist/utils/tools.d.ts.map +1 -1
  19. package/dist/utils/tools.js +3 -6
  20. package/dist/utils/tools.js.map +1 -1
  21. package/dist/utils/upload/UploadManager.d.ts +2 -0
  22. package/dist/utils/upload/UploadManager.d.ts.map +1 -1
  23. package/dist/utils/upload/UploadManager.js +32 -25
  24. package/dist/utils/upload/UploadManager.js.map +1 -1
  25. package/dist/utils/upload/use-paste-upload.d.ts +8 -0
  26. package/dist/utils/upload/use-paste-upload.d.ts.map +1 -0
  27. package/dist/utils/upload/use-paste-upload.js +19 -0
  28. package/dist/utils/upload/use-paste-upload.js.map +1 -0
  29. package/dist/views/Agents/AgentDescription.d.ts +2 -9
  30. package/dist/views/Agents/AgentDescription.d.ts.map +1 -1
  31. package/dist/views/Agents/AgentDescription.js +12 -9
  32. package/dist/views/Agents/AgentDescription.js.map +1 -1
  33. package/dist/views/Agents/AgentsPanel.d.ts.map +1 -1
  34. package/dist/views/Agents/AgentsPanel.js +11 -11
  35. package/dist/views/Agents/AgentsPanel.js.map +1 -1
  36. package/dist/views/Agents/AgentsTab.d.ts +2 -2
  37. package/dist/views/Agents/AgentsTab.d.ts.map +1 -1
  38. package/dist/views/Agents/AgentsTab.js +6 -6
  39. package/dist/views/Agents/AgentsTab.js.map +1 -1
  40. package/dist/views/Agents/useAgentFavorites.d.ts +1 -1
  41. package/dist/views/Agents/useAgentFavorites.js +4 -4
  42. package/dist/views/Agents/useAgentFavorites.js.map +1 -1
  43. package/dist/views/Chat/ChatMessage.d.ts.map +1 -1
  44. package/dist/views/Chat/ChatMessage.js +3 -3
  45. package/dist/views/Chat/ChatMessage.js.map +1 -1
  46. package/dist/views/ChatHistory/HistoryItem.d.ts.map +1 -1
  47. package/dist/views/ChatHistory/HistoryItem.js +8 -5
  48. package/dist/views/ChatHistory/HistoryItem.js.map +1 -1
  49. package/dist/views/ChatHistory/utils.d.ts +0 -6
  50. package/dist/views/ChatHistory/utils.d.ts.map +1 -1
  51. package/dist/views/ChatHistory/utils.js +1 -16
  52. package/dist/views/ChatHistory/utils.js.map +1 -1
  53. package/dist/views/Home/CustomAgent.js +3 -3
  54. package/dist/views/Home/CustomAgent.js.map +1 -1
  55. package/dist/views/MessageInput/AgentSelector.js +4 -4
  56. package/dist/views/MessageInput/AgentSelector.js.map +1 -1
  57. package/dist/views/MessageInput/ButtonAgent.js +2 -2
  58. package/dist/views/MessageInput/ButtonAgent.js.map +1 -1
  59. package/dist/views/MessageInput/QuickCommandSelector.js +4 -4
  60. package/dist/views/MessageInput/QuickCommandSelector.js.map +1 -1
  61. package/dist/views/MessageInput/UploadDragNDrop.d.ts +14 -0
  62. package/dist/views/MessageInput/UploadDragNDrop.d.ts.map +1 -0
  63. package/dist/views/MessageInput/UploadDragNDrop.js +52 -0
  64. package/dist/views/MessageInput/UploadDragNDrop.js.map +1 -0
  65. package/dist/views/MessageInput/dictionary.d.ts +1 -1
  66. package/dist/views/MessageInput/dictionary.d.ts.map +1 -1
  67. package/dist/views/MessageInput/dictionary.js +9 -0
  68. package/dist/views/MessageInput/dictionary.js.map +1 -1
  69. package/dist/views/MessageInput/index.d.ts.map +1 -1
  70. package/dist/views/MessageInput/index.js +13 -1
  71. package/dist/views/MessageInput/index.js.map +1 -1
  72. package/dist/views/Tools.js +3 -3
  73. package/dist/views/Tools.js.map +1 -1
  74. package/dist/views/Workspaces/WorkspacesTab.js +1 -1
  75. package/package.json +2 -2
  76. package/src/app-metadata.json +3 -3
  77. package/src/chat-interceptors/quick-commands.ts +25 -3
  78. package/src/components/AgentCard/dictionary.ts +4 -2
  79. package/src/components/Selector/index.tsx +4 -5
  80. package/src/layout.css +17 -0
  81. package/src/state/types.ts +1 -1
  82. package/src/utils/tools.ts +5 -7
  83. package/src/utils/upload/UploadManager.ts +32 -23
  84. package/src/utils/upload/use-paste-upload.tsx +30 -0
  85. package/src/views/Agents/AgentDescription.tsx +19 -25
  86. package/src/views/Agents/AgentsPanel.tsx +11 -12
  87. package/src/views/Agents/AgentsTab.tsx +12 -17
  88. package/src/views/Agents/useAgentFavorites.ts +4 -4
  89. package/src/views/Chat/ChatMessage.tsx +3 -4
  90. package/src/views/ChatHistory/HistoryItem.tsx +10 -5
  91. package/src/views/ChatHistory/utils.ts +1 -18
  92. package/src/views/Home/CustomAgent.tsx +4 -4
  93. package/src/views/MessageInput/AgentSelector.tsx +4 -4
  94. package/src/views/MessageInput/ButtonAgent.tsx +2 -2
  95. package/src/views/MessageInput/QuickCommandSelector.tsx +4 -4
  96. package/src/views/MessageInput/UploadDragNDrop.tsx +83 -0
  97. package/src/views/MessageInput/dictionary.ts +9 -0
  98. package/src/views/MessageInput/index.tsx +17 -1
  99. package/src/views/Tools.tsx +4 -3
  100. package/src/views/Workspaces/WorkspacesTab.tsx +1 -1
@@ -8,6 +8,7 @@ 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'
11
12
  import { AgentSelector } from './AgentSelector'
12
13
  import { ButtonAgent } from './ButtonAgent'
13
14
  import { ButtonBar } from './ButtonBar'
@@ -17,6 +18,7 @@ import { useMessageInputDictionary } from './dictionary'
17
18
  import { QuickCommandSelector } from './QuickCommandSelector'
18
19
  import { MAX_INPUT_HEIGHT, MessageInputBox, MIN_INPUT_HEIGHT } from './styled'
19
20
  import { UploadBar } from './UploadBar'
21
+ import { UploadDragNDrop, useUploadDragDrop } from './UploadDragNDrop'
20
22
 
21
23
  /**
22
24
  * This renders the MessageInput part of the layout which includes the progress bar, the actual textarea, the badges telling what is
@@ -36,6 +38,13 @@ export const MessageInput = () => {
36
38
  const agentLabel = useCurrentChatState('agent')?.label
37
39
  const { handleKeyDown, handleKeyUp } = useUserEntryHistoryShortcut()
38
40
  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
+ })
39
48
 
40
49
  const checkSendRequirements = useCallback(() => {
41
50
  if (chat.uploadManager.status === 'error') {
@@ -112,7 +121,13 @@ export const MessageInput = () => {
112
121
  <ButtonAgent />
113
122
  <AdaptiveTextArea
114
123
  ref={textAreaRef}
115
- placeholder={agentLabel && interpolate(t.placeholder, agentLabel)}
124
+ placeholder={
125
+ isDragging
126
+ ? t.uploadDragging
127
+ : agentLabel
128
+ ? interpolate(t.placeholder, agentLabel)
129
+ : t.typing
130
+ }
116
131
  onChange={e => chat.set('nextMessage', e.target.value)}
117
132
  value={value}
118
133
  onFocus={() => setFocused(true)}
@@ -130,6 +145,7 @@ export const MessageInput = () => {
130
145
  <ContextBar />
131
146
  {chat.get('features').upload && <UploadBar />}
132
147
  <ButtonBar onSend={onSend} isLoading={isLoading} />
148
+ <UploadDragNDrop isDragging={isDragging} onDrop={handleDrop} onDragLeave={handleDragLeave} />
133
149
  </MessageInputBox>
134
150
  </UploadProvider>
135
151
  )
@@ -1,4 +1,4 @@
1
- import { agentClient } from '@stack-spot/portal-network'
1
+ import { agentToolsClient } 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,8 +40,9 @@ 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
- 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])
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])
45
46
 
46
47
  return !!tools?.length && (
47
48
  <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 })