@stack-spot/ai-chat-widget 1.29.1-beta.0 → 1.29.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.
- package/CHANGELOG.md +22 -0
- package/dist/StackspotAIWidget.d.ts.map +1 -1
- package/dist/StackspotAIWidget.js +2 -3
- package/dist/StackspotAIWidget.js.map +1 -1
- package/dist/app-metadata.json +3 -3
- package/dist/components/AdaptiveTextArea.d.ts +1 -1
- package/dist/components/AdaptiveTextArea.d.ts.map +1 -1
- package/dist/components/AdaptiveTextArea.js +3 -3
- package/dist/components/AdaptiveTextArea.js.map +1 -1
- package/dist/components/AgentCard/dictionary.d.ts +2 -4
- package/dist/components/AgentCard/dictionary.d.ts.map +1 -1
- package/dist/components/AgentCard/dictionary.js +2 -4
- package/dist/components/AgentCard/dictionary.js.map +1 -1
- package/dist/components/Selector/index.d.ts +2 -2
- package/dist/components/Selector/index.d.ts.map +1 -1
- package/dist/components/Selector/index.js +3 -3
- package/dist/components/Selector/index.js.map +1 -1
- package/dist/components/Selector/styled.d.ts +1 -1
- package/dist/components/Selector/styled.d.ts.map +1 -1
- package/dist/components/Selector/styled.js +1 -1
- package/dist/components/Selector/styled.js.map +1 -1
- package/dist/layout.css +4 -2
- package/dist/state/types.d.ts +1 -1
- package/dist/state/types.d.ts.map +1 -1
- package/dist/utils/tools.d.ts +2 -2
- package/dist/utils/tools.d.ts.map +1 -1
- package/dist/utils/tools.js +6 -3
- package/dist/utils/tools.js.map +1 -1
- package/dist/views/Agents/AgentDescription.d.ts +9 -2
- package/dist/views/Agents/AgentDescription.d.ts.map +1 -1
- package/dist/views/Agents/AgentDescription.js +9 -12
- package/dist/views/Agents/AgentDescription.js.map +1 -1
- package/dist/views/Agents/AgentsPanel.d.ts.map +1 -1
- package/dist/views/Agents/AgentsPanel.js +11 -11
- package/dist/views/Agents/AgentsPanel.js.map +1 -1
- package/dist/views/Agents/AgentsTab.d.ts +2 -2
- package/dist/views/Agents/AgentsTab.d.ts.map +1 -1
- package/dist/views/Agents/AgentsTab.js +6 -6
- package/dist/views/Agents/AgentsTab.js.map +1 -1
- package/dist/views/Agents/useAgentFavorites.d.ts +1 -1
- package/dist/views/Agents/useAgentFavorites.js +4 -4
- package/dist/views/Agents/useAgentFavorites.js.map +1 -1
- package/dist/views/Chat/ChatMessage.js +3 -3
- package/dist/views/Chat/ChatMessage.js.map +1 -1
- package/dist/views/ChatHistory/HistoryItem.d.ts.map +1 -1
- package/dist/views/ChatHistory/HistoryItem.js +5 -8
- package/dist/views/ChatHistory/HistoryItem.js.map +1 -1
- package/dist/views/ChatHistory/utils.d.ts +6 -0
- package/dist/views/ChatHistory/utils.d.ts.map +1 -1
- package/dist/views/ChatHistory/utils.js +16 -1
- package/dist/views/ChatHistory/utils.js.map +1 -1
- package/dist/views/Home/CustomAgent.js +3 -3
- package/dist/views/Home/CustomAgent.js.map +1 -1
- package/dist/views/MessageInput/AgentSelector.js +4 -4
- package/dist/views/MessageInput/AgentSelector.js.map +1 -1
- package/dist/views/MessageInput/ButtonAgent.js +2 -2
- package/dist/views/MessageInput/ButtonAgent.js.map +1 -1
- package/dist/views/MessageInput/UploadDragNDrop.d.ts.map +1 -1
- package/dist/views/MessageInput/UploadDragNDrop.js +2 -2
- package/dist/views/MessageInput/UploadDragNDrop.js.map +1 -1
- package/dist/views/MessageInput/dictionary.d.ts +1 -1
- package/dist/views/MessageInput/dictionary.d.ts.map +1 -1
- package/dist/views/MessageInput/dictionary.js +3 -2
- package/dist/views/MessageInput/dictionary.js.map +1 -1
- package/dist/views/MessageInput/index.d.ts +2 -2
- package/dist/views/MessageInput/index.d.ts.map +1 -1
- package/dist/views/MessageInput/index.js +2 -2
- package/dist/views/MessageInput/index.js.map +1 -1
- package/dist/views/Tools.js +3 -3
- package/dist/views/Tools.js.map +1 -1
- package/dist/views/Workspaces/WorkspacesTab.js +1 -1
- package/package.json +2 -2
- package/src/StackspotAIWidget.tsx +2 -3
- package/src/app-metadata.json +3 -3
- package/src/components/AdaptiveTextArea.tsx +5 -5
- package/src/components/AgentCard/dictionary.ts +2 -4
- package/src/components/Selector/index.tsx +6 -5
- package/src/components/Selector/styled.ts +2 -2
- package/src/layout.css +4 -2
- package/src/state/types.ts +1 -1
- package/src/utils/tools.ts +7 -5
- package/src/views/Agents/AgentDescription.tsx +25 -19
- package/src/views/Agents/AgentsPanel.tsx +12 -11
- package/src/views/Agents/AgentsTab.tsx +17 -12
- package/src/views/Agents/useAgentFavorites.ts +4 -4
- package/src/views/Chat/ChatMessage.tsx +3 -3
- package/src/views/ChatHistory/HistoryItem.tsx +5 -10
- package/src/views/ChatHistory/utils.ts +18 -1
- package/src/views/Home/CustomAgent.tsx +4 -4
- package/src/views/MessageInput/AgentSelector.tsx +4 -4
- package/src/views/MessageInput/ButtonAgent.tsx +2 -2
- package/src/views/MessageInput/UploadDragNDrop.tsx +1 -2
- package/src/views/MessageInput/dictionary.ts +3 -2
- package/src/views/MessageInput/index.tsx +2 -2
- package/src/views/Tools.tsx +3 -4
- package/src/views/Workspaces/WorkspacesTab.tsx +1 -1
|
@@ -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 {
|
|
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
|
-
|
|
94
|
+
getAllAgents(),
|
|
97
95
|
])
|
|
98
|
-
const
|
|
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:
|
|
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 {
|
|
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] =
|
|
15
|
+
const [agent] = agentClient.agent.useStatefulQuery({ agentId: id! })
|
|
16
16
|
const chat = useCurrentChat()
|
|
17
|
-
const suggestions = useMemo(() => agent?.
|
|
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?.
|
|
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 {
|
|
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
|
|
56
|
+
return agentClient.allAgents.useQuery({ visibilities: ['PERSONAL', 'BUILT-IN'] })
|
|
57
57
|
}
|
|
58
|
-
return
|
|
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', '
|
|
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 {
|
|
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 =
|
|
12
|
+
const agentDefault = agentClient.agentDefault.useQuery({})
|
|
13
13
|
const widget = useWidget()
|
|
14
14
|
const chat = useCurrentChat()
|
|
15
15
|
const agent = useCurrentChatState('agent')
|
|
@@ -60,18 +60,17 @@ export const UploadDragNDrop = ({ isDragging, onDrop, onDragLeave }: UploadDragN
|
|
|
60
60
|
return (
|
|
61
61
|
<div
|
|
62
62
|
className="upload-drag-drop"
|
|
63
|
-
data-active={isDragging}
|
|
64
63
|
role="dialog"
|
|
65
64
|
aria-modal="true"
|
|
66
65
|
aria-labelledby="upload-drag-drop-title"
|
|
67
66
|
aria-describedby="upload-drag-drop-description"
|
|
67
|
+
tabIndex={-1}
|
|
68
68
|
onDrop={onDrop}
|
|
69
69
|
onDragLeave={onDragLeave}
|
|
70
70
|
onDragOver={e => {
|
|
71
71
|
e.preventDefault()
|
|
72
72
|
e.stopPropagation()
|
|
73
73
|
}}
|
|
74
|
-
tabIndex={-1}
|
|
75
74
|
>
|
|
76
75
|
<IconBox size="lg" aria-hidden={true}>
|
|
77
76
|
<Document />
|
|
@@ -25,8 +25,9 @@ const dictionary = {
|
|
|
25
25
|
uploadItemLimitError: 'The following files were not added because no more than $1 items may be uploaded at a time:',
|
|
26
26
|
uploadError: 'An error occurred while uploading the file "$0".',
|
|
27
27
|
uploadDragging: 'Drop the file here to upload',
|
|
28
|
-
uploadDragDropTitle: '
|
|
29
|
-
uploadDragDropDescription: '
|
|
28
|
+
uploadDragDropTitle: 'Drop your files here',
|
|
29
|
+
uploadDragDropDescription: 'Drag or drop files to share in the conversation',
|
|
30
|
+
unknownUploadError: 'An error occurred while uploading the files.',
|
|
30
31
|
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
32
|
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
33
|
cantSendBecauseOfEmptyContent: 'You can\'t send empty messages. Please write some text or upload a file.',
|
|
@@ -25,7 +25,7 @@ import { UploadDragNDrop, useUploadDragDrop } from './UploadDragNDrop'
|
|
|
25
25
|
* going to be used for the question and the buttons to send, cancel, set the workspace, among others. This also includes the Quick
|
|
26
26
|
* Commands panel for auto completing.
|
|
27
27
|
*/
|
|
28
|
-
export const MessageInput = ({
|
|
28
|
+
export const MessageInput = ({ chatWindowRef }: { chatWindowRef?: React.RefObject<HTMLElement> }) => {
|
|
29
29
|
const t = useMessageInputDictionary()
|
|
30
30
|
const [focused, setFocused] = useState(false)
|
|
31
31
|
const [, setExpanded] = useState(true)
|
|
@@ -119,7 +119,7 @@ export const MessageInput = ({ containerRef }: { containerRef?: React.RefObject<
|
|
|
119
119
|
<div className={listToClass(['action-box', focused && 'focused', isLoading && 'disabled'])}>
|
|
120
120
|
<ButtonAgent />
|
|
121
121
|
<AdaptiveTextArea
|
|
122
|
-
|
|
122
|
+
chatWindowRef={chatWindowRef}
|
|
123
123
|
ref={textAreaRef}
|
|
124
124
|
placeholder={
|
|
125
125
|
agentLabel
|
package/src/views/Tools.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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: '
|
|
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 })
|