@stack-spot/ai-chat-widget 1.9.0 → 1.10.0
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 +7 -0
- package/dist/StackspotAIWidget.d.ts.map +1 -1
- package/dist/StackspotAIWidget.js +2 -1
- package/dist/StackspotAIWidget.js.map +1 -1
- package/dist/app-metadata.json +11 -3
- package/dist/chat-interceptors/send-message.d.ts.map +1 -1
- package/dist/chat-interceptors/send-message.js +3 -1
- package/dist/chat-interceptors/send-message.js.map +1 -1
- package/dist/components/AnimatedOpacity.d.ts +8 -0
- package/dist/components/AnimatedOpacity.d.ts.map +1 -0
- package/dist/components/AnimatedOpacity.js +46 -0
- package/dist/components/AnimatedOpacity.js.map +1 -0
- package/dist/components/Code.d.ts +2 -1
- package/dist/components/Code.d.ts.map +1 -1
- package/dist/components/Code.js +4 -4
- package/dist/components/Code.js.map +1 -1
- package/dist/components/Modal.d.ts +9 -0
- package/dist/components/Modal.d.ts.map +1 -0
- package/dist/components/Modal.js +58 -0
- package/dist/components/Modal.js.map +1 -0
- package/dist/layout.css +21 -0
- package/dist/state/ChatEntry.d.ts +21 -2
- package/dist/state/ChatEntry.d.ts.map +1 -1
- package/dist/state/ChatEntry.js.map +1 -1
- package/dist/state/WidgetState.d.ts +8 -1
- package/dist/state/WidgetState.d.ts.map +1 -1
- package/dist/state/WidgetState.js.map +1 -1
- package/dist/utils/error.d.ts +2 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +54 -0
- package/dist/utils/error.js.map +1 -0
- package/dist/views/Chat/ChatMessage.d.ts +1 -1
- package/dist/views/Chat/ChatMessage.d.ts.map +1 -1
- package/dist/views/Chat/ChatMessage.js +2 -1
- package/dist/views/Chat/ChatMessage.js.map +1 -1
- package/dist/views/Chat/StepsList.d.ts +9 -0
- package/dist/views/Chat/StepsList.d.ts.map +1 -0
- package/dist/views/Chat/StepsList.js +51 -0
- package/dist/views/Chat/StepsList.js.map +1 -0
- package/dist/views/Chat/styled.d.ts +3 -1
- package/dist/views/Chat/styled.d.ts.map +1 -1
- package/dist/views/Chat/styled.js +56 -0
- package/dist/views/Chat/styled.js.map +1 -1
- package/dist/views/Stacks.js +1 -0
- package/dist/views/Stacks.js.map +1 -1
- package/dist/views/Tools/FlowChart/HandleGroup.d.ts +7 -0
- package/dist/views/Tools/FlowChart/HandleGroup.d.ts.map +1 -0
- package/dist/views/Tools/FlowChart/HandleGroup.js +4 -0
- package/dist/views/Tools/FlowChart/HandleGroup.js.map +1 -0
- package/dist/views/Tools/FlowChart/NodeStep.d.ts +7 -0
- package/dist/views/Tools/FlowChart/NodeStep.d.ts.map +1 -0
- package/dist/views/Tools/FlowChart/NodeStep.js +15 -0
- package/dist/views/Tools/FlowChart/NodeStep.js.map +1 -0
- package/dist/views/Tools/FlowChart/index.d.ts +9 -0
- package/dist/views/Tools/FlowChart/index.d.ts.map +1 -0
- package/dist/views/Tools/FlowChart/index.js +52 -0
- package/dist/views/Tools/FlowChart/index.js.map +1 -0
- package/dist/views/Tools/FlowChart/layout.d.ts +17 -0
- package/dist/views/Tools/FlowChart/layout.d.ts.map +1 -0
- package/dist/views/Tools/FlowChart/layout.js +40 -0
- package/dist/views/Tools/FlowChart/layout.js.map +1 -0
- package/dist/views/Tools/FlowChart/styled.d.ts +15 -0
- package/dist/views/Tools/FlowChart/styled.d.ts.map +1 -0
- package/dist/views/Tools/FlowChart/styled.js +181 -0
- package/dist/views/Tools/FlowChart/styled.js.map +1 -0
- package/dist/views/Tools/FlowChart/types.d.ts +13 -0
- package/dist/views/Tools/FlowChart/types.d.ts.map +1 -0
- package/dist/views/Tools/FlowChart/types.js +2 -0
- package/dist/views/Tools/FlowChart/types.js.map +1 -0
- package/dist/views/Tools/StepModal.d.ts +9 -0
- package/dist/views/Tools/StepModal.d.ts.map +1 -0
- package/dist/views/Tools/StepModal.js +156 -0
- package/dist/views/Tools/StepModal.js.map +1 -0
- package/dist/views/Tools/ToolsPanel.d.ts +6 -0
- package/dist/views/Tools/ToolsPanel.d.ts.map +1 -0
- package/dist/views/Tools/ToolsPanel.js +14 -0
- package/dist/views/Tools/ToolsPanel.js.map +1 -0
- package/dist/views/Tools/dictionary.d.ts +41 -0
- package/dist/views/Tools/dictionary.d.ts.map +1 -0
- package/dist/views/Tools/dictionary.js +43 -0
- package/dist/views/Tools/dictionary.js.map +1 -0
- package/dist/views/Tools/index.d.ts +5 -0
- package/dist/views/Tools/index.d.ts.map +1 -0
- package/dist/views/Tools/index.js +31 -0
- package/dist/views/Tools/index.js.map +1 -0
- package/dist/views/Tools/utils.d.ts +6 -0
- package/dist/views/Tools/utils.d.ts.map +1 -0
- package/dist/views/Tools/utils.js +32 -0
- package/dist/views/Tools/utils.js.map +1 -0
- package/package.json +5 -3
- package/src/StackspotAIWidget.tsx +2 -0
- package/src/app-metadata.json +11 -3
- package/src/chat-interceptors/send-message.ts +8 -3
- package/src/components/AnimatedOpacity.tsx +55 -0
- package/src/components/Code.tsx +5 -3
- package/src/components/Modal.tsx +87 -0
- package/src/layout.css +21 -0
- package/src/state/ChatEntry.ts +25 -1
- package/src/state/WidgetState.ts +5 -1
- package/src/utils/error.ts +56 -0
- package/src/views/Chat/ChatMessage.tsx +5 -3
- package/src/views/Chat/StepsList.tsx +97 -0
- package/src/views/Chat/styled.ts +62 -1
- package/src/views/Stacks.tsx +1 -0
- package/src/views/Tools/FlowChart/HandleGroup.tsx +12 -0
- package/src/views/Tools/FlowChart/NodeStep.tsx +57 -0
- package/src/views/Tools/FlowChart/index.tsx +71 -0
- package/src/views/Tools/FlowChart/layout.ts +49 -0
- package/src/views/Tools/FlowChart/styled.ts +182 -0
- package/src/views/Tools/FlowChart/types.ts +14 -0
- package/src/views/Tools/StepModal.tsx +247 -0
- package/src/views/Tools/ToolsPanel.tsx +24 -0
- package/src/views/Tools/dictionary.ts +46 -0
- package/src/views/Tools/index.tsx +37 -0
- package/src/views/Tools/utils.tsx +34 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Flex } from '@citric/core'
|
|
2
|
+
import { LoadingCircular } from '@citric/ui'
|
|
3
|
+
import { lazy, Suspense, useEffect } from 'react'
|
|
4
|
+
import { useWidget, useWidgetState } from '../../context/hooks'
|
|
5
|
+
import { useRightPanel } from '../../right-panel/hooks'
|
|
6
|
+
import { useToolsDictionary } from './dictionary'
|
|
7
|
+
|
|
8
|
+
const LazyToolsPanel = lazy(() => import('./ToolsPanel'))
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Renders the Stack selection form in the Right Panel if this is the panel that is currently opened.
|
|
12
|
+
*/
|
|
13
|
+
export const Tools = () => {
|
|
14
|
+
const t = useToolsDictionary()
|
|
15
|
+
const panel = useWidgetState('panel')
|
|
16
|
+
const message = useWidgetState('currentMessageInToolsPanel')
|
|
17
|
+
const { open } = useRightPanel()
|
|
18
|
+
const widget = useWidget()
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (panel === 'tools' && message) open(
|
|
22
|
+
<Suspense fallback={<Flex alignItems="center" justifyContent="center" flex={1}><LoadingCircular /></Flex>}>
|
|
23
|
+
<LazyToolsPanel key={message.messageId} chatId={message.chatId} messageId={message.messageId} />
|
|
24
|
+
</Suspense>,
|
|
25
|
+
{
|
|
26
|
+
title: t.tools,
|
|
27
|
+
description: t.toolsDescription,
|
|
28
|
+
onClose: () => {
|
|
29
|
+
widget.set('panel', undefined)
|
|
30
|
+
widget.set('currentMessageInToolsPanel', undefined)
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
)
|
|
34
|
+
}, [panel, t, message])
|
|
35
|
+
|
|
36
|
+
return null
|
|
37
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IconBox } from '@citric/core'
|
|
2
|
+
import { CheckCircleFill, ListUnordered, PlayFill, TimesCircleFill } from '@citric/icons'
|
|
3
|
+
import { LoadingCircular } from '@citric/ui'
|
|
4
|
+
import { ChatEntryStep } from '../../state/ChatEntry'
|
|
5
|
+
|
|
6
|
+
export function getStatusIcon(status: ChatEntryStep['status']) {
|
|
7
|
+
switch (status) {
|
|
8
|
+
case 'success': return <IconBox colorIcon="success.500"><CheckCircleFill /></IconBox>
|
|
9
|
+
case 'error': return <IconBox colorIcon="danger.500"><TimesCircleFill /></IconBox>
|
|
10
|
+
case 'running': return <LoadingCircular colorScheme="inverse" size="xs" />
|
|
11
|
+
default: return null
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getTypeIcon(type: ChatEntryStep['type']) {
|
|
16
|
+
switch (type) {
|
|
17
|
+
case 'planning': return <ListUnordered />
|
|
18
|
+
default: return <PlayFill />
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getTitle(translation: Record<'planning' | 'step' | 'answer', string>, step: ChatEntryStep | undefined, index: number) {
|
|
23
|
+
if (!step) return ''
|
|
24
|
+
switch (step.type) {
|
|
25
|
+
case 'planning': return translation.planning
|
|
26
|
+
case 'step': return `${translation.step} ${index}`
|
|
27
|
+
case 'answer': return translation.answer
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function toPrecision(n: number, precisionDigits = 1) {
|
|
32
|
+
const factor = Math.pow(10, precisionDigits)
|
|
33
|
+
return Math.round(n * factor) / factor
|
|
34
|
+
}
|