@stack-spot/ai-chat-widget 1.13.2-beta.0 → 1.13.2
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 +35 -0
- package/dist/StackspotAIWidget.d.ts.map +1 -1
- package/dist/StackspotAIWidget.js +5 -2
- package/dist/StackspotAIWidget.js.map +1 -1
- package/dist/app-metadata.json +3 -3
- package/dist/chat-interceptors/send-message.d.ts.map +1 -1
- package/dist/chat-interceptors/send-message.js +2 -0
- package/dist/chat-interceptors/send-message.js.map +1 -1
- package/dist/components/Markdown.d.ts.map +1 -1
- package/dist/components/Markdown.js +1 -1
- package/dist/components/Markdown.js.map +1 -1
- package/dist/components/StackedBadge.d.ts +14 -0
- package/dist/components/StackedBadge.d.ts.map +1 -0
- package/dist/components/StackedBadge.js +56 -0
- package/dist/components/StackedBadge.js.map +1 -0
- package/dist/components/ToolBadge.d.ts +14 -0
- package/dist/components/ToolBadge.d.ts.map +1 -0
- package/dist/components/ToolBadge.js +108 -0
- package/dist/components/ToolBadge.js.map +1 -0
- package/dist/state/ChatEntry.d.ts +9 -16
- package/dist/state/ChatEntry.d.ts.map +1 -1
- package/dist/state/ChatEntry.js.map +1 -1
- package/dist/state/ChatState.d.ts +0 -1
- package/dist/state/ChatState.d.ts.map +1 -1
- package/dist/state/WidgetState.d.ts +3 -4
- package/dist/state/WidgetState.d.ts.map +1 -1
- package/dist/state/WidgetState.js +1 -12
- package/dist/state/WidgetState.js.map +1 -1
- package/dist/utils/check-is-trial.d.ts +2 -0
- package/dist/utils/check-is-trial.d.ts.map +1 -0
- package/dist/utils/check-is-trial.js +6 -0
- package/dist/utils/check-is-trial.js.map +1 -0
- package/dist/utils/tools.d.ts +7 -0
- package/dist/utils/tools.d.ts.map +1 -0
- package/dist/utils/tools.js +9 -0
- package/dist/utils/tools.js.map +1 -0
- package/dist/views/Agents/AgentDescription.d.ts.map +1 -1
- package/dist/views/Agents/AgentDescription.js +11 -1
- 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 +13 -6
- package/dist/views/Agents/AgentsPanel.js.map +1 -1
- package/dist/views/Agents/AgentsTab.d.ts.map +1 -1
- package/dist/views/Agents/AgentsTab.js +10 -8
- package/dist/views/Agents/AgentsTab.js.map +1 -1
- package/dist/views/Agents/dictionary.d.ts +1 -1
- package/dist/views/Agents/dictionary.d.ts.map +1 -1
- package/dist/views/Agents/dictionary.js +2 -0
- package/dist/views/Agents/dictionary.js.map +1 -1
- package/dist/views/Agents/styled.js +1 -1
- package/dist/views/Chat/AgentInfo.js +3 -3
- package/dist/views/Chat/AgentInfo.js.map +1 -1
- package/dist/views/Chat/ChatMessage.d.ts.map +1 -1
- package/dist/views/Chat/ChatMessage.js +19 -4
- package/dist/views/Chat/ChatMessage.js.map +1 -1
- package/dist/views/Chat/StepsList.d.ts +2 -2
- package/dist/views/Chat/StepsList.d.ts.map +1 -1
- package/dist/views/Chat/StepsList.js +2 -2
- package/dist/views/Chat/StepsList.js.map +1 -1
- package/dist/views/Chat/styled.d.ts.map +1 -1
- package/dist/views/Chat/styled.js +21 -12
- package/dist/views/Chat/styled.js.map +1 -1
- package/dist/views/ChatTabSelection.d.ts.map +1 -1
- package/dist/views/ChatTabSelection.js +16 -2
- package/dist/views/ChatTabSelection.js.map +1 -1
- package/dist/views/KnowledgeSources.d.ts.map +1 -1
- package/dist/views/KnowledgeSources.js +10 -5
- package/dist/views/KnowledgeSources.js.map +1 -1
- package/dist/views/MessageInput/AgentSelector.d.ts +2 -1
- package/dist/views/MessageInput/AgentSelector.d.ts.map +1 -1
- package/dist/views/MessageInput/AgentSelector.js +15 -8
- package/dist/views/MessageInput/AgentSelector.js.map +1 -1
- package/dist/views/MessageInput/QuickCommandSelector.d.ts +2 -1
- package/dist/views/MessageInput/QuickCommandSelector.d.ts.map +1 -1
- package/dist/views/MessageInput/QuickCommandSelector.js +2 -2
- package/dist/views/MessageInput/QuickCommandSelector.js.map +1 -1
- package/dist/views/MessageInput/index.d.ts.map +1 -1
- package/dist/views/MessageInput/index.js +4 -2
- package/dist/views/MessageInput/index.js.map +1 -1
- package/dist/views/Stacks.d.ts.map +1 -1
- package/dist/views/Stacks.js +10 -5
- package/dist/views/Stacks.js.map +1 -1
- package/dist/views/{Tools → Steps}/FlowChart/HandleGroup.d.ts.map +1 -1
- package/dist/views/{Tools → Steps}/FlowChart/HandleGroup.js.map +1 -1
- package/dist/views/{Tools → Steps}/FlowChart/NodeStep.d.ts.map +1 -1
- package/dist/views/Steps/FlowChart/NodeStep.js +13 -0
- package/dist/views/Steps/FlowChart/NodeStep.js.map +1 -0
- package/dist/views/Steps/FlowChart/index.d.ts +10 -0
- package/dist/views/Steps/FlowChart/index.d.ts.map +1 -0
- package/dist/views/{Tools → Steps}/FlowChart/index.js +1 -5
- package/dist/views/{Tools → Steps}/FlowChart/index.js.map +1 -1
- package/dist/views/{Tools → Steps}/FlowChart/layout.d.ts.map +1 -1
- package/dist/views/{Tools → Steps}/FlowChart/layout.js.map +1 -1
- package/dist/views/{Tools → Steps}/FlowChart/styled.d.ts.map +1 -1
- package/dist/views/{Tools → Steps}/FlowChart/styled.js +0 -49
- package/dist/views/{Tools → Steps}/FlowChart/styled.js.map +1 -1
- package/dist/views/{Tools → Steps}/FlowChart/types.d.ts +3 -3
- package/dist/views/Steps/FlowChart/types.d.ts.map +1 -0
- package/dist/views/Steps/FlowChart/types.js.map +1 -0
- package/dist/views/Steps/StepModal.d.ts +9 -0
- package/dist/views/Steps/StepModal.d.ts.map +1 -0
- package/dist/views/Steps/StepModal.js +124 -0
- package/dist/views/Steps/StepModal.js.map +1 -0
- package/dist/views/Steps/StepsPanel.d.ts +6 -0
- package/dist/views/Steps/StepsPanel.d.ts.map +1 -0
- package/dist/views/{Tools/ToolsPanel.js → Steps/StepsPanel.js} +3 -3
- package/dist/views/{Tools/ToolsPanel.js.map → Steps/StepsPanel.js.map} +1 -1
- package/dist/views/{Tools → Steps}/dictionary.d.ts +9 -11
- package/dist/views/Steps/dictionary.d.ts.map +1 -0
- package/dist/views/{Tools → Steps}/dictionary.js +9 -11
- package/dist/views/Steps/dictionary.js.map +1 -0
- package/dist/views/{Tools → Steps}/index.d.ts +1 -1
- package/dist/views/Steps/index.d.ts.map +1 -0
- package/dist/views/{Tools → Steps}/index.js +10 -10
- package/dist/views/{Tools → Steps}/index.js.map +1 -1
- package/dist/views/Steps/utils.d.ts +6 -0
- package/dist/views/Steps/utils.d.ts.map +1 -0
- package/dist/views/{Tools → Steps}/utils.js.map +1 -1
- package/dist/views/Tools.d.ts +2 -0
- package/dist/views/Tools.d.ts.map +1 -0
- package/dist/views/Tools.js +51 -0
- package/dist/views/Tools.js.map +1 -0
- package/package.json +2 -2
- package/src/StackspotAIWidget.tsx +8 -3
- package/src/app-metadata.json +3 -3
- package/src/chat-interceptors/send-message.ts +2 -0
- package/src/components/Markdown.tsx +1 -0
- package/src/components/StackedBadge.tsx +77 -0
- package/src/components/ToolBadge.tsx +146 -0
- package/src/state/ChatEntry.ts +9 -17
- package/src/state/ChatState.ts +1 -1
- package/src/state/WidgetState.ts +4 -16
- package/src/utils/check-is-trial.ts +6 -0
- package/src/utils/tools.ts +11 -0
- package/src/views/Agents/AgentDescription.tsx +14 -0
- package/src/views/Agents/AgentsPanel.tsx +11 -3
- package/src/views/Agents/AgentsTab.tsx +11 -10
- package/src/views/Agents/dictionary.ts +2 -0
- package/src/views/Agents/styled.ts +1 -1
- package/src/views/Chat/AgentInfo.tsx +4 -4
- package/src/views/Chat/ChatMessage.tsx +30 -4
- package/src/views/Chat/StepsList.tsx +6 -6
- package/src/views/Chat/styled.ts +21 -12
- package/src/views/ChatTabSelection.tsx +22 -4
- package/src/views/KnowledgeSources.tsx +9 -3
- package/src/views/MessageInput/AgentSelector.tsx +19 -8
- package/src/views/MessageInput/QuickCommandSelector.tsx +3 -2
- package/src/views/MessageInput/index.tsx +5 -4
- package/src/views/Stacks.tsx +10 -4
- package/src/views/{Tools → Steps}/FlowChart/NodeStep.tsx +11 -23
- package/src/views/{Tools → Steps}/FlowChart/index.tsx +3 -7
- package/src/views/{Tools → Steps}/FlowChart/styled.ts +0 -49
- package/src/views/{Tools → Steps}/FlowChart/types.ts +3 -3
- package/src/views/Steps/StepModal.tsx +216 -0
- package/src/views/{Tools/ToolsPanel.tsx → Steps/StepsPanel.tsx} +2 -2
- package/src/views/{Tools → Steps}/dictionary.ts +9 -11
- package/src/views/{Tools → Steps}/index.tsx +10 -10
- package/src/views/{Tools → Steps}/utils.tsx +4 -4
- package/src/views/Tools.tsx +71 -0
- package/dist/utils/agent.d.ts +0 -2
- package/dist/utils/agent.d.ts.map +0 -1
- package/dist/utils/agent.js +0 -2
- package/dist/utils/agent.js.map +0 -1
- package/dist/views/Tools/FlowChart/NodeStep.js +0 -15
- package/dist/views/Tools/FlowChart/NodeStep.js.map +0 -1
- package/dist/views/Tools/FlowChart/index.d.ts +0 -9
- package/dist/views/Tools/FlowChart/index.d.ts.map +0 -1
- package/dist/views/Tools/FlowChart/types.d.ts.map +0 -1
- package/dist/views/Tools/FlowChart/types.js.map +0 -1
- package/dist/views/Tools/StepModal.d.ts +0 -9
- package/dist/views/Tools/StepModal.d.ts.map +0 -1
- package/dist/views/Tools/StepModal.js +0 -156
- package/dist/views/Tools/StepModal.js.map +0 -1
- package/dist/views/Tools/ToolsPanel.d.ts +0 -6
- package/dist/views/Tools/ToolsPanel.d.ts.map +0 -1
- package/dist/views/Tools/dictionary.d.ts.map +0 -1
- package/dist/views/Tools/dictionary.js.map +0 -1
- package/dist/views/Tools/index.d.ts.map +0 -1
- package/dist/views/Tools/utils.d.ts +0 -6
- package/dist/views/Tools/utils.d.ts.map +0 -1
- package/src/utils/agent.ts +0 -1
- package/src/views/Tools/StepModal.tsx +0 -247
- /package/dist/views/{Tools → Steps}/FlowChart/HandleGroup.d.ts +0 -0
- /package/dist/views/{Tools → Steps}/FlowChart/HandleGroup.js +0 -0
- /package/dist/views/{Tools → Steps}/FlowChart/NodeStep.d.ts +0 -0
- /package/dist/views/{Tools → Steps}/FlowChart/layout.d.ts +0 -0
- /package/dist/views/{Tools → Steps}/FlowChart/layout.js +0 -0
- /package/dist/views/{Tools → Steps}/FlowChart/styled.d.ts +0 -0
- /package/dist/views/{Tools → Steps}/FlowChart/types.js +0 -0
- /package/dist/views/{Tools → Steps}/utils.js +0 -0
- /package/src/views/{Tools → Steps}/FlowChart/HandleGroup.tsx +0 -0
- /package/src/views/{Tools → Steps}/FlowChart/layout.ts +0 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Flex, Text } from '@citric/core';
|
|
3
|
+
import { ChevronLeft, ChevronRight } from '@citric/icons';
|
|
4
|
+
import { Badge, IconButton } from '@citric/ui';
|
|
5
|
+
import { theme } from '@stack-spot/portal-theme';
|
|
6
|
+
import { useMemo, useState } from 'react';
|
|
7
|
+
import { styled } from 'styled-components';
|
|
8
|
+
import { Code } from '../../components/Code.js';
|
|
9
|
+
import { Markdown } from '../../components/Markdown.js';
|
|
10
|
+
import { Modal } from '../../components/Modal.js';
|
|
11
|
+
import { ToolBadge } from '../../components/ToolBadge.js';
|
|
12
|
+
import { useChatEntry } from '../../context/hooks.js';
|
|
13
|
+
import { useStepsDictionary } from './dictionary.js';
|
|
14
|
+
import { getTitle, toPrecision } from './utils.js';
|
|
15
|
+
const StyledSection = styled.section `
|
|
16
|
+
padding: 18px 14px;
|
|
17
|
+
border-bottom: 1px solid var(--light-600);
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
gap: 12px;
|
|
21
|
+
align-items: start;
|
|
22
|
+
|
|
23
|
+
&:last-child {
|
|
24
|
+
border-bottom: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&.restrict-image-size img {
|
|
28
|
+
max-width: 100%;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.markdown p {
|
|
32
|
+
margin-top: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.tool {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
align-items: start;
|
|
39
|
+
align-self: stretch;
|
|
40
|
+
gap: 6px;
|
|
41
|
+
background-color: ${theme.color.light[500]};
|
|
42
|
+
border-radius: 5px;
|
|
43
|
+
padding: 6px;
|
|
44
|
+
|
|
45
|
+
&:not(:last-child) {
|
|
46
|
+
border-bottom: 1px solid ${theme.color.light[500]};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.tool-input {
|
|
50
|
+
align-self: stretch;
|
|
51
|
+
&, .highlighter {
|
|
52
|
+
background: ${theme.color.light[300]} !important;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
p {
|
|
58
|
+
line-height: 20px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
ul.steps {
|
|
62
|
+
margin: 0;
|
|
63
|
+
padding: 0;
|
|
64
|
+
list-style: none;
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
gap: 8px;
|
|
68
|
+
|
|
69
|
+
> li {
|
|
70
|
+
padding: 8px 12px;
|
|
71
|
+
background-color: ${theme.color.light[500]};
|
|
72
|
+
border-radius: 6px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.step-description {
|
|
76
|
+
color: ${theme.color.light[700]};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
ul.side-by-side-tools {
|
|
81
|
+
margin: 14px 0 0 0;
|
|
82
|
+
padding: 0;
|
|
83
|
+
list-style: none;
|
|
84
|
+
display: flex;
|
|
85
|
+
gap: 10px;
|
|
86
|
+
flex-wrap: wrap;
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
const ExecutionBox = styled.div `
|
|
90
|
+
border-radius: 4px;
|
|
91
|
+
background-color: ${theme.color.light[500]};
|
|
92
|
+
color: ${theme.color.light[700]};
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
.time {
|
|
96
|
+
padding: 6px 8px;
|
|
97
|
+
border-right: 1px solid ${theme.color.light[600]};
|
|
98
|
+
}
|
|
99
|
+
.navigator {
|
|
100
|
+
display: flex;
|
|
101
|
+
gap: 4px;
|
|
102
|
+
align-items: center;
|
|
103
|
+
padding: 2px 8px;
|
|
104
|
+
button {
|
|
105
|
+
width: 12px;
|
|
106
|
+
height: 12px;
|
|
107
|
+
padding: 0;
|
|
108
|
+
}
|
|
109
|
+
small {
|
|
110
|
+
line-height: 0.75rem;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
export const StepModal = ({ message, stepId, onClose }) => {
|
|
115
|
+
const t = useStepsDictionary();
|
|
116
|
+
const entry = useChatEntry(message);
|
|
117
|
+
const [attempt, setAttempt] = useState(0);
|
|
118
|
+
const stepIndex = useMemo(() => entry.steps?.findIndex(s => s.id === stepId) ?? -1, [entry, stepId]);
|
|
119
|
+
const step = entry.steps?.[stepIndex];
|
|
120
|
+
const tools = step?.type === 'step' ? step.attempts[attempt]?.tools?.map(tool => (_jsxs("div", { className: "tool", children: [_jsx(ToolBadge, { name: tool.name, duration: tool.duration, image: tool.image, description: tool.description }), tool.input && _jsxs(_Fragment, { children: [_jsxs(Text, { appearance: "microtext1", colorScheme: "light.700", children: [t.input, ":"] }), _jsx(Code, { language: "json", className: "tool-input", showLineNumbers: false, showActionBar: true, children: tool.input })] }), tool.output && _jsxs(_Fragment, { children: [_jsxs(Text, { appearance: "microtext1", colorScheme: "light.700", children: [t.response, ":"] }), _jsx(Code, { language: "json", className: "tool-input", showLineNumbers: false, showActionBar: true, children: tool.output })] })] }, tool.id))) : undefined;
|
|
121
|
+
const title = (_jsxs(Flex, { flex: 1, justifyContent: "space-between", alignItems: "center", children: [_jsx(Text, { appearance: "h6", children: getTitle(t, step, stepIndex) }), _jsxs(ExecutionBox, { children: [_jsxs(Text, { className: "time", appearance: "microtext1", children: [step?.status === 'running' && t.running, step?.status === 'pending' && t.pending, step?.status === 'success' && `${t.executionTime}: ${step?.duration ? `${toPrecision(step?.duration)}s` : t.unknown}`] }), step?.type === 'step' && step.attempts.length > 1 && _jsxs("div", { className: "navigator", children: [attempt > 0 && (_jsx(IconButton, { size: "xs", appearance: "text", title: t.previousAttempt, "aria-label": t.previousAttempt, onClick: () => setAttempt(attempt - 1), children: _jsx(ChevronLeft, {}) })), _jsxs(Text, { appearance: "microtext1", children: [attempt + 1, "/", step.attempts.length] }), attempt < step.attempts.length - 1 && (_jsx(IconButton, { size: "xs", appearance: "text", title: t.nextAttempt, "aria-label": t.nextAttempt, onClick: () => setAttempt(attempt + 1), children: _jsx(ChevronRight, {}) }))] })] })] }));
|
|
122
|
+
return (_jsxs(Modal, { open: !!step, onClose: onClose, title: title, children: [step?.type === 'answer' && _jsx(StyledSection, { className: "restrict-image-size", children: entry.type === 'md' ? _jsx(Markdown, { children: entry.content }) : _jsx(Text, { children: entry.content }) }), step?.type === 'planning' && _jsxs(StyledSection, { style: { alignItems: 'stretch' }, children: [_jsx(Badge, { appearance: "square", palette: "blue", style: { alignSelf: 'start' }, children: "Prompt" }), _jsx(Text, { children: step.goal }), _jsx("ul", { className: "steps", children: entry.steps?.filter(s => s.type === 'step').map((s, index) => (_jsxs("li", { children: [_jsx(Flex, { mb: 2, children: _jsxs(Text, { children: [t.step, " ", index + 1, ": ", _jsx("span", { className: "step-description", children: s.input })] }) }), !!s.attempts[0].tools?.length && _jsx("ul", { className: "side-by-side-tools", children: s.attempts[0].tools.map((tool) => (_jsx("li", { children: _jsx(ToolBadge, { name: tool.name, image: tool.image, appearance: "round" }) }, tool.id))) })] }, index))) })] }), step?.type === 'step' && step?.input && _jsxs(StyledSection, { children: [_jsx(Badge, { appearance: "square", palette: "blue", children: "Prompt" }), _jsx(Text, { children: step.input })] }), !!tools?.length && _jsx(StyledSection, { children: tools })] }));
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=StepModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepModal.js","sourceRoot":"","sources":["../../../src/views/Steps/StepModal.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAQ/C,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0BZ,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;;;;;iCAKb,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;;;;;;sBAMjC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;0BAmBlB,KAAK,CAAC,KAAK,CAA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AAC,MAAM,uBAAe,EACxD,KAAC,IAAI,cAAE,IAAI,CAAC,KAAK,GAAQ,IACX,EACf,CAAC,CAAC,KAAK,EAAE,MAAM,IAAI,KAAC,aAAa,cAAE,KAAK,GAAiB,IACpD,CACT,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepsPanel.d.ts","sourceRoot":"","sources":["../../../src/views/Steps/StepsPanel.tsx"],"names":[],"mappings":"AAOA,QAAA,MAAM,UAAU,GAAI,uBAAuB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,mDAc/E,CAAA;AAED,eAAe,UAAU,CAAA"}
|
|
@@ -4,11 +4,11 @@ import { useMemo, useState } from 'react';
|
|
|
4
4
|
import { useWidget } from '../../context/hooks.js';
|
|
5
5
|
import { FlowChart } from './FlowChart/index.js';
|
|
6
6
|
import { StepModal } from './StepModal.js';
|
|
7
|
-
const
|
|
7
|
+
const StepsPanel = ({ chatId, messageId }) => {
|
|
8
8
|
const [currentStepId, setCurrentStepId] = useState();
|
|
9
9
|
const widget = useWidget();
|
|
10
10
|
const message = useMemo(() => widget.chatTabs.getAll().find(c => c.id === chatId)?.getMessages().find(m => m.id === messageId), [chatId, messageId]);
|
|
11
11
|
return message ? (_jsxs(_Fragment, { children: [_jsx(FlowChart, { message: message, onClick: (step) => setCurrentStepId(step.id) }), _jsx(StepModal, { message: message, stepId: currentStepId, onClose: () => setCurrentStepId(undefined) })] })) : null;
|
|
12
12
|
};
|
|
13
|
-
export default
|
|
14
|
-
//# sourceMappingURL=
|
|
13
|
+
export default StepsPanel;
|
|
14
|
+
//# sourceMappingURL=StepsPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"StepsPanel.js","sourceRoot":"","sources":["../../../src/views/Steps/StepsPanel.tsx"],"names":[],"mappings":";AAAA,6CAA6C;AAE7C,OAA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5
|
step: string;
|
|
5
6
|
response: string;
|
|
6
7
|
tools: string;
|
|
@@ -10,15 +11,15 @@ export declare const dictionary: {
|
|
|
10
11
|
unknown: string;
|
|
11
12
|
running: string;
|
|
12
13
|
pending: string;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
thoughtFor: string;
|
|
14
|
+
nextAttempt: string;
|
|
15
|
+
previousAttempt: string;
|
|
16
16
|
open: string;
|
|
17
17
|
close: string;
|
|
18
18
|
input: string;
|
|
19
19
|
};
|
|
20
20
|
pt: {
|
|
21
|
-
|
|
21
|
+
stepsPanelDescription: string;
|
|
22
|
+
steps: string;
|
|
22
23
|
step: string;
|
|
23
24
|
response: string;
|
|
24
25
|
tools: string;
|
|
@@ -28,14 +29,11 @@ export declare const dictionary: {
|
|
|
28
29
|
unknown: string;
|
|
29
30
|
running: string;
|
|
30
31
|
pending: string;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
thoughtFor: string;
|
|
34
|
-
open: string;
|
|
35
|
-
close: string;
|
|
32
|
+
nextAttempt: string;
|
|
33
|
+
previousAttempt: string;
|
|
36
34
|
input: string;
|
|
37
35
|
};
|
|
38
36
|
};
|
|
39
|
-
export declare function
|
|
37
|
+
export declare function useStepsDictionary(): Record<"input" | "step" | "steps" | "tools" | "answer" | "pending" | "running" | "planning" | "unknown" | "stepsPanelDescription" | "response" | "executionTime" | "nextAttempt" | "previousAttempt", string>;
|
|
40
38
|
export type ToolsDictionary = typeof dictionary['en'];
|
|
41
39
|
//# sourceMappingURL=dictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../../src/views/Steps/dictionary.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCD,CAAA;AAEtB,wBAAgB,kBAAkB,kNAEjC;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useTranslate } from '@stack-spot/portal-translate';
|
|
2
2
|
export const dictionary = {
|
|
3
3
|
en: {
|
|
4
|
-
|
|
4
|
+
stepsPanelDescription: 'The steps and tools used to reach the answer',
|
|
5
|
+
steps: 'Steps',
|
|
5
6
|
step: 'Step',
|
|
6
7
|
response: 'Response',
|
|
7
8
|
tools: 'Tools',
|
|
@@ -11,15 +12,15 @@ export const dictionary = {
|
|
|
11
12
|
unknown: 'unknown',
|
|
12
13
|
running: 'Running',
|
|
13
14
|
pending: 'Pending',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
thoughtFor: 'Thought for $0 seconds',
|
|
15
|
+
nextAttempt: 'Next execution',
|
|
16
|
+
previousAttempt: 'Previous execution',
|
|
17
17
|
open: 'Open',
|
|
18
18
|
close: 'Close',
|
|
19
19
|
input: 'Input',
|
|
20
20
|
},
|
|
21
21
|
pt: {
|
|
22
|
-
|
|
22
|
+
stepsPanelDescription: 'Os passos e ferramentas usados para chegar na resposta',
|
|
23
|
+
steps: 'Passos',
|
|
23
24
|
step: 'Passo',
|
|
24
25
|
response: 'Resposta',
|
|
25
26
|
tools: 'Ferramentas',
|
|
@@ -29,15 +30,12 @@ export const dictionary = {
|
|
|
29
30
|
unknown: 'desconhecido',
|
|
30
31
|
running: 'Executando',
|
|
31
32
|
pending: 'Aguardando',
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
thoughtFor: 'Pensado por $0 segundos',
|
|
35
|
-
open: 'Open',
|
|
36
|
-
close: 'Close',
|
|
33
|
+
nextAttempt: 'Próxima execução',
|
|
34
|
+
previousAttempt: 'Execução anterior',
|
|
37
35
|
input: 'Entrada',
|
|
38
36
|
},
|
|
39
37
|
};
|
|
40
|
-
export function
|
|
38
|
+
export function useStepsDictionary() {
|
|
41
39
|
return useTranslate(dictionary);
|
|
42
40
|
}
|
|
43
41
|
//# sourceMappingURL=dictionary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dictionary.js","sourceRoot":"","sources":["../../../src/views/Steps/dictionary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAEvE,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,EAAE,EAAE;QACF,qBAAqB,EAAE,8CAA8C;QACrE,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,UAAU;QACpB,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,cAAc;QACtB,aAAa,EAAE,MAAM;QACrB,OAAO,EAAE,SAAS;QAClB,OAAO,EAAE,SAAS;QAClB,OAAO,EAAE,SAAS;QAClB,WAAW,EAAE,gBAAgB;QAC7B,eAAe,EAAE,oBAAoB;QACrC,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,OAAO;KACf;IACD,EAAE,EAAE;QACF,qBAAqB,EAAE,wDAAwD;QAC/E,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,UAAU;QACpB,KAAK,EAAE,aAAa;QACpB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,gBAAgB;QACxB,aAAa,EAAE,OAAO;QACtB,OAAO,EAAE,cAAc;QACvB,OAAO,EAAE,YAAY;QACrB,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,kBAAkB;QAC/B,eAAe,EAAE,mBAAmB;QACpC,KAAK,EAAE,SAAS;KACjB;CACmB,CAAA;AAEtB,MAAM,UAAU,kBAAkB;IAChC,OAAO,YAAY,CAAC,UAAU,CAAC,CAAA;AACjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Steps/index.tsx"],"names":[],"mappings":"AASA;;GAEG;AACH,eAAO,MAAM,KAAK,YAwBjB,CAAA"}
|
|
@@ -4,25 +4,25 @@ import { LoadingCircular } from '@citric/ui';
|
|
|
4
4
|
import { lazy, Suspense, useEffect } from 'react';
|
|
5
5
|
import { useWidget, useWidgetState } from '../../context/hooks.js';
|
|
6
6
|
import { useRightPanel } from '../../right-panel/hooks.js';
|
|
7
|
-
import {
|
|
8
|
-
const
|
|
7
|
+
import { useStepsDictionary } from './dictionary.js';
|
|
8
|
+
const LazyStepsPanel = lazy(() => import('./StepsPanel.js'));
|
|
9
9
|
/**
|
|
10
10
|
* Renders the Stack selection form in the Right Panel if this is the panel that is currently opened.
|
|
11
11
|
*/
|
|
12
|
-
export const
|
|
13
|
-
const t =
|
|
12
|
+
export const Steps = () => {
|
|
13
|
+
const t = useStepsDictionary();
|
|
14
14
|
const panel = useWidgetState('panel');
|
|
15
|
-
const message = useWidgetState('
|
|
15
|
+
const message = useWidgetState('currentMessageInPanel');
|
|
16
16
|
const { open } = useRightPanel();
|
|
17
17
|
const widget = useWidget();
|
|
18
18
|
useEffect(() => {
|
|
19
|
-
if (panel === '
|
|
20
|
-
open(_jsx(Suspense, { fallback: _jsx(Flex, { alignItems: "center", justifyContent: "center", flex: 1, children: _jsx(LoadingCircular, {}) }), children: _jsx(
|
|
21
|
-
title: t.
|
|
22
|
-
description: t.
|
|
19
|
+
if (panel === 'steps' && message)
|
|
20
|
+
open(_jsx(Suspense, { fallback: _jsx(Flex, { alignItems: "center", justifyContent: "center", flex: 1, children: _jsx(LoadingCircular, {}) }), children: _jsx(LazyStepsPanel, { chatId: message.chatId, messageId: message.messageId }, message.messageId) }), {
|
|
21
|
+
title: t.steps,
|
|
22
|
+
description: t.stepsPanelDescription,
|
|
23
23
|
onClose: () => {
|
|
24
24
|
widget.set('panel', undefined);
|
|
25
|
-
widget.set('
|
|
25
|
+
widget.set('currentMessageInPanel', undefined);
|
|
26
26
|
},
|
|
27
27
|
});
|
|
28
28
|
}, [panel, t, message]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js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,EAAE,CAAC,CAAC,KAAK;gBACd,WAAW,EAAE,CAAC,CAAC,qBAAqB;gBACpC,OAAO,EAAE,GAAG,EAAE;oBACZ,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;oBAC9B,MAAM,CAAC,GAAG,CAAC,uBAAuB,EAAE,SAAS,CAAC,CAAA;gBAChD,CAAC;aACF,CACF,CAAA;IACH,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAA;IAEvB,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ChatStep } from '@stack-spot/portal-network';
|
|
2
|
+
export declare function getStatusIcon(status: ChatStep['status']): import("react/jsx-runtime").JSX.Element | null;
|
|
3
|
+
export declare function getTypeIcon(type: ChatStep['type']): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function getTitle(translation: Record<'planning' | 'step' | 'answer', string>, step: ChatStep | undefined, index: number): string;
|
|
5
|
+
export declare function toPrecision(n: number, precisionDigits?: number): number;
|
|
6
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/views/Steps/utils.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAErD,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,kDAOvD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,2CAKjD;AAED,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,QAAQ,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,UAO9H;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,SAAI,UAGzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/views/
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/views/Steps/utils.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAG5C,MAAM,UAAU,aAAa,CAAC,MAA0B;IACtD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,SAAS,CAAC,CAAC,OAAO,KAAC,OAAO,IAAC,SAAS,EAAC,aAAa,YAAC,KAAC,eAAe,KAAG,GAAU,CAAA;QACrF,KAAK,OAAO,CAAC,CAAC,OAAO,KAAC,OAAO,IAAC,SAAS,EAAC,YAAY,YAAC,KAAC,eAAe,KAAG,GAAU,CAAA;QAClF,KAAK,SAAS,CAAC,CAAC,OAAO,KAAC,eAAe,IAAC,WAAW,EAAC,SAAS,EAAC,IAAI,EAAC,IAAI,GAAG,CAAA;QAC1E,OAAO,CAAC,CAAC,OAAO,IAAI,CAAA;IACtB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAsB;IAChD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,UAAU,CAAC,CAAC,OAAO,KAAC,aAAa,KAAG,CAAA;QACzC,OAAO,CAAC,CAAC,OAAO,KAAC,QAAQ,KAAG,CAAA;IAC9B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,WAA2D,EAAE,IAA0B,EAAE,KAAa;IAC7H,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAA;IACpB,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,UAAU,CAAC,CAAC,OAAO,WAAW,CAAC,QAAQ,CAAA;QAC5C,KAAK,MAAM,CAAC,CAAC,OAAO,GAAG,WAAW,CAAC,IAAI,IAAI,KAAK,EAAE,CAAA;QAClD,KAAK,QAAQ,CAAC,CAAC,OAAO,WAAW,CAAC,MAAM,CAAA;IAC1C,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,CAAS,EAAE,eAAe,GAAG,CAAC;IACxD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,eAAe,CAAC,CAAA;IAC5C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,MAAM,CAAA;AACxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tools.d.ts","sourceRoot":"","sources":["../../src/views/Tools.tsx"],"names":[],"mappings":"AAkBA,eAAO,MAAM,KAAK,YAejB,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { agentClient } from '@stack-spot/portal-network';
|
|
3
|
+
import { useTranslate } from '@stack-spot/portal-translate';
|
|
4
|
+
import { useEffect, useMemo } from 'react';
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import { ToolBadge } from '../components/ToolBadge.js';
|
|
7
|
+
import { useWidget, useWidgetState } from '../context/hooks.js';
|
|
8
|
+
import { useRightPanel } from '../right-panel/hooks.js';
|
|
9
|
+
import { toolById } from '../utils/tools.js';
|
|
10
|
+
const ToolList = styled.ul `
|
|
11
|
+
margin: 0;
|
|
12
|
+
padding: 0;
|
|
13
|
+
list-style: none;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
gap: 8px;
|
|
17
|
+
`;
|
|
18
|
+
export const Tools = () => {
|
|
19
|
+
const t = useTranslate(dictionary);
|
|
20
|
+
const panel = useWidgetState('panel');
|
|
21
|
+
const message = useWidgetState('currentMessageInPanel');
|
|
22
|
+
const { open } = useRightPanel();
|
|
23
|
+
const widget = useWidget();
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (panel === 'tools' && message)
|
|
26
|
+
open(_jsx(ToolsPanel, {}, message.messageId), { title: t.title, description: t.description, onClose: () => widget.set('panel', undefined) });
|
|
27
|
+
}, [panel, t]);
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
const ToolsPanel = () => {
|
|
31
|
+
const { chatId, messageId } = useWidgetState('currentMessageInPanel') ?? {};
|
|
32
|
+
const widget = useWidget();
|
|
33
|
+
const message = useMemo(() => {
|
|
34
|
+
const chat = widget.chatTabs.getAll().find(c => c.id === chatId);
|
|
35
|
+
return chat?.getMessages().find(m => m.id === messageId)?.getValue();
|
|
36
|
+
}, [messageId]);
|
|
37
|
+
const [agent] = agentClient.agent.useStatefulQuery({ agentId: message?.agent?.id ?? '' }, { enabled: !!message?.agent?.id });
|
|
38
|
+
const tools = useMemo(() => message?.tools?.map(id => toolById(id, agent?.toolkits) ?? { id }), [messageId, agent]);
|
|
39
|
+
return !!tools?.length && (_jsx(ToolList, { children: tools.map((tool) => (_jsx("li", { children: _jsx(ToolBadge, { name: tool.name || tool.id, image: tool.image, description: tool.description, backgroundColor: "light.500" }) }, tool.id))) }));
|
|
40
|
+
};
|
|
41
|
+
const dictionary = {
|
|
42
|
+
en: {
|
|
43
|
+
title: 'Tools',
|
|
44
|
+
description: 'The tools used to generate the answer.',
|
|
45
|
+
},
|
|
46
|
+
pt: {
|
|
47
|
+
title: 'Ferramentas',
|
|
48
|
+
description: 'As ferramentas usadas para gerar a resposta.',
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=Tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tools.js","sourceRoot":"","sources":["../../src/views/Tools.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAc,YAAY,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AW,GAC3B,IANK,IAAI,CAAC,EAAE,CAOX,CACN,CAAC,GACO,CACZ,CAAA;AACH,CAAC,CAAA;AAED,MAAM,UAAU,GAAG;IACjB,EAAE,EAAE;QACF,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,wCAAwC;KACtD;IACD,EAAE,EAAE;QACF,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,8CAA8C;KAC5D;CACmB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stack-spot/ai-chat-widget",
|
|
3
|
-
"version": "1.13.2
|
|
3
|
+
"version": "1.13.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@citric/icons": "^5.9.0",
|
|
15
15
|
"@citric/ui": "^6.7.0",
|
|
16
16
|
"@stack-spot/portal-components": "^2.8.1",
|
|
17
|
-
"@stack-spot/portal-network": "^0.
|
|
17
|
+
"@stack-spot/portal-network": "^0.114.0",
|
|
18
18
|
"@stack-spot/portal-theme": "^1.0.0",
|
|
19
19
|
"@stack-spot/portal-translate": "^1.1.0",
|
|
20
20
|
"lodash": "^4.17.0",
|
|
@@ -6,6 +6,7 @@ import './layout.css'
|
|
|
6
6
|
import { RightPanel } from './right-panel/RightPanel'
|
|
7
7
|
import { RightPanelProvider } from './right-panel/RightPanelProvider'
|
|
8
8
|
import { MinimizedActions } from './types'
|
|
9
|
+
import { checkIsTrial } from './utils/check-is-trial'
|
|
9
10
|
import { Agents } from './views/Agents'
|
|
10
11
|
import { Chat } from './views/Chat'
|
|
11
12
|
import { ChatHistory } from './views/ChatHistory'
|
|
@@ -17,6 +18,7 @@ import { KSDocument } from './views/KSDocument'
|
|
|
17
18
|
import { MessageInput } from './views/MessageInput'
|
|
18
19
|
import { MinimizedHeader } from './views/MinimizedHeader'
|
|
19
20
|
import { Stacks } from './views/Stacks'
|
|
21
|
+
import { Steps } from './views/Steps'
|
|
20
22
|
import { Tools } from './views/Tools'
|
|
21
23
|
import { Workspaces } from './views/Workspaces'
|
|
22
24
|
|
|
@@ -47,14 +49,16 @@ export interface AIWidgetProps extends WithStyle {
|
|
|
47
49
|
* Renders a Chat Widget according to the closest model found in the React tree (AIWidgetProvider). If no model is found, a global version
|
|
48
50
|
* of the Chat Widget will be instantiated and used.
|
|
49
51
|
*/
|
|
50
|
-
export const StackspotAIWidget = ({ username, minimizedActions = {}, prefix,
|
|
52
|
+
export const StackspotAIWidget = ({ username, minimizedActions = {}, prefix,
|
|
53
|
+
children, className, style, hasHeader = true }:
|
|
51
54
|
AIWidgetProps) => {
|
|
52
55
|
const rightPanelRef = useRef<HTMLDivElement>(null)
|
|
53
56
|
const chatWindowRef = useRef<HTMLDivElement>(null)
|
|
54
57
|
const currentChat = useCurrentChatMessages()
|
|
55
58
|
const isMinimized = useWidgetState('isMinimized')
|
|
56
59
|
const isCurrentChatEmpty = currentChat.length === 0
|
|
57
|
-
|
|
60
|
+
const isTrial = checkIsTrial()
|
|
61
|
+
|
|
58
62
|
return useMemo(() => (
|
|
59
63
|
<TooltipProvider>
|
|
60
64
|
<RightPanelProvider chatWindow={chatWindowRef} panel={rightPanelRef}>
|
|
@@ -76,12 +80,13 @@ export const StackspotAIWidget = ({ username, minimizedActions = {}, prefix, chi
|
|
|
76
80
|
</div>
|
|
77
81
|
</div>
|
|
78
82
|
<Stacks />
|
|
79
|
-
<Workspaces />
|
|
83
|
+
{!isTrial && <Workspaces />}
|
|
80
84
|
<KnowledgeSources />
|
|
81
85
|
<KSDocument />
|
|
82
86
|
<Agents />
|
|
83
87
|
<Editor />
|
|
84
88
|
<ChatHistory />
|
|
89
|
+
<Steps />
|
|
85
90
|
<Tools />
|
|
86
91
|
<div className="chat-right-panel" ref={rightPanelRef}><RightPanel /></div>
|
|
87
92
|
</div>
|
package/src/app-metadata.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stack-spot/ai-chat-widget",
|
|
3
|
-
"version": "1.13.2
|
|
4
|
-
"date": "
|
|
3
|
+
"version": "1.13.2",
|
|
4
|
+
"date": "Fri Apr 11 2025 20:03:32 GMT+0000 (Coordinated Universal Time)",
|
|
5
5
|
"dependencies": [
|
|
6
6
|
{
|
|
7
7
|
"name": "@stack-spot/app-metadata",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
115
|
"name": "@stack-spot/portal-network",
|
|
116
|
-
"version": "0.
|
|
116
|
+
"version": "0.114.0(@stack-spot/auth@5.3.3)(@stack-spot/opa@2.6.1(@stack-spot/auth@5.3.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@stack-spot/portal-translate@1.1.0(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@tanstack/react-query@5.69.0(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)"
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
119
|
"name": "@stack-spot/portal-theme",
|
|
@@ -12,6 +12,7 @@ import { genericSourcesToKnowledgeSources } from '../utils/knowledge-source'
|
|
|
12
12
|
* @param response the original response.
|
|
13
13
|
* @param knowledgeSources the knowledge sources already in format used by the chat.
|
|
14
14
|
* @param agent the current chat agent.
|
|
15
|
+
* @param tools the tools for the current chat agent.
|
|
15
16
|
* @param includeDate whether or not to include the date in the chat entry.
|
|
16
17
|
* @returns the TextChatEntry to build a ChatEntry.
|
|
17
18
|
*/
|
|
@@ -30,6 +31,7 @@ function createEntryValueFromChatResponse(
|
|
|
30
31
|
agent: agent,
|
|
31
32
|
updated: includeDate ? new Date().toISOString() : undefined,
|
|
32
33
|
steps: response.steps,
|
|
34
|
+
tools: response.tools,
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { IconBox, Text } from '@citric/core'
|
|
2
|
+
import { theme } from '@stack-spot/portal-theme'
|
|
3
|
+
import { DetailedHTMLProps, HTMLAttributes } from 'react'
|
|
4
|
+
import { styled } from 'styled-components'
|
|
5
|
+
import { FastOmit } from 'styled-components/dist/types'
|
|
6
|
+
|
|
7
|
+
interface Props extends FastOmit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> {
|
|
8
|
+
label: string,
|
|
9
|
+
images: { key?: React.Key, name: string, url?: string, icon?: React.ReactElement }[],
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Styled = styled.div`
|
|
13
|
+
border-radius: 25px;
|
|
14
|
+
background-color: ${theme.color.light[600]};
|
|
15
|
+
border: 1px solid ${theme.color.light[500]};
|
|
16
|
+
color: ${theme.color.light[700]};
|
|
17
|
+
padding: 2px 7px;
|
|
18
|
+
display: flex;
|
|
19
|
+
gap: 5px;
|
|
20
|
+
align-items: center;
|
|
21
|
+
|
|
22
|
+
small {
|
|
23
|
+
line-height: 0.75rem;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
ul {
|
|
27
|
+
list-style: none;
|
|
28
|
+
margin: 0;
|
|
29
|
+
padding: 0;
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: row;
|
|
32
|
+
|
|
33
|
+
li {
|
|
34
|
+
border: 1px solid ${theme.color.light[600]};
|
|
35
|
+
background-color: ${theme.color.light[400]};
|
|
36
|
+
border-radius: 50%;
|
|
37
|
+
width: 16px;
|
|
38
|
+
height: 16px;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
justify-content: center;
|
|
43
|
+
|
|
44
|
+
&:not(:first-child) {
|
|
45
|
+
margin-left: -12px;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
i {
|
|
50
|
+
width: 12px;
|
|
51
|
+
height: 12px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
img, svg {
|
|
55
|
+
width: 100%;
|
|
56
|
+
height: 100%;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`
|
|
60
|
+
|
|
61
|
+
export const StackedBadge = ({ label, images, ...props }: Props) => (
|
|
62
|
+
<Styled {...props}>
|
|
63
|
+
<Text appearance="microtext1">{label}</Text>
|
|
64
|
+
<ul>
|
|
65
|
+
{images.map(
|
|
66
|
+
({ key, name, url, icon }, i) => (
|
|
67
|
+
<li key={key || i}>
|
|
68
|
+
{url
|
|
69
|
+
? <img alt={name} aria-label={name} title={name} src={url} />
|
|
70
|
+
: <IconBox size="xs" aria-label={name} title={name}>{icon}</IconBox>
|
|
71
|
+
}
|
|
72
|
+
</li>
|
|
73
|
+
),
|
|
74
|
+
)}
|
|
75
|
+
</ul>
|
|
76
|
+
</Styled>
|
|
77
|
+
)
|