@stack-spot/ai-chat-widget 2.3.0-alpha.1 → 2.3.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.
Files changed (93) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/StackspotAIWidget.d.ts +1 -5
  3. package/dist/StackspotAIWidget.d.ts.map +1 -1
  4. package/dist/StackspotAIWidget.js +2 -2
  5. package/dist/StackspotAIWidget.js.map +1 -1
  6. package/dist/app-metadata.json +5 -5
  7. package/dist/chat-interceptors/send-message.d.ts.map +1 -1
  8. package/dist/chat-interceptors/send-message.js +125 -1
  9. package/dist/chat-interceptors/send-message.js.map +1 -1
  10. package/dist/state/ChatEntry.d.ts.map +1 -1
  11. package/dist/state/ChatState.d.ts +4 -0
  12. package/dist/state/ChatState.d.ts.map +1 -1
  13. package/dist/state/ChatState.js.map +1 -1
  14. package/dist/utils/check-is-trial.d.ts.map +1 -1
  15. package/dist/utils/check-is-trial.js +2 -6
  16. package/dist/utils/check-is-trial.js.map +1 -1
  17. package/dist/utils/planning-tool.d.ts +17 -0
  18. package/dist/utils/planning-tool.d.ts.map +1 -0
  19. package/dist/utils/planning-tool.js +32 -0
  20. package/dist/utils/planning-tool.js.map +1 -0
  21. package/dist/utils/update-tool-step.d.ts +3 -0
  22. package/dist/utils/update-tool-step.d.ts.map +1 -0
  23. package/dist/utils/update-tool-step.js +23 -0
  24. package/dist/utils/update-tool-step.js.map +1 -0
  25. package/dist/views/Agents/AgentsTab.d.ts.map +1 -1
  26. package/dist/views/Agents/AgentsTab.js +3 -4
  27. package/dist/views/Agents/AgentsTab.js.map +1 -1
  28. package/dist/views/Agents/useAgentFavorites.d.ts.map +1 -1
  29. package/dist/views/Agents/useAgentFavorites.js +1 -3
  30. package/dist/views/Agents/useAgentFavorites.js.map +1 -1
  31. package/dist/views/Chat/ChatMessage.d.ts +1 -1
  32. package/dist/views/Chat/ChatMessage.d.ts.map +1 -1
  33. package/dist/views/Chat/ChatMessage.js +21 -6
  34. package/dist/views/Chat/ChatMessage.js.map +1 -1
  35. package/dist/views/Chat/StepsList.d.ts +12 -2
  36. package/dist/views/Chat/StepsList.d.ts.map +1 -1
  37. package/dist/views/Chat/StepsList.js +155 -18
  38. package/dist/views/Chat/StepsList.js.map +1 -1
  39. package/dist/views/Chat/styled.d.ts.map +1 -1
  40. package/dist/views/Chat/styled.js +17 -10
  41. package/dist/views/Chat/styled.js.map +1 -1
  42. package/dist/views/MessageInput/AgentSelector.d.ts.map +1 -1
  43. package/dist/views/MessageInput/AgentSelector.js +2 -8
  44. package/dist/views/MessageInput/AgentSelector.js.map +1 -1
  45. package/dist/views/MessageInput/ButtonAgent.js +1 -1
  46. package/dist/views/MessageInput/ButtonAgent.js.map +1 -1
  47. package/dist/views/MessageInput/ButtonBar.d.ts +1 -2
  48. package/dist/views/MessageInput/ButtonBar.d.ts.map +1 -1
  49. package/dist/views/MessageInput/ButtonBar.js +2 -2
  50. package/dist/views/MessageInput/ButtonBar.js.map +1 -1
  51. package/dist/views/MessageInput/QuickCommandSelector.js +1 -1
  52. package/dist/views/MessageInput/QuickCommandSelector.js.map +1 -1
  53. package/dist/views/MessageInput/dictionary.d.ts +1 -1
  54. package/dist/views/MessageInput/index.d.ts +1 -2
  55. package/dist/views/MessageInput/index.d.ts.map +1 -1
  56. package/dist/views/MessageInput/index.js +2 -2
  57. package/dist/views/MessageInput/index.js.map +1 -1
  58. package/dist/views/Steps/FlowChart/NodeStep.js +1 -1
  59. package/dist/views/Steps/FlowChart/NodeStep.js.map +1 -1
  60. package/dist/views/Steps/FlowChart/layout.d.ts +1 -1
  61. package/dist/views/Steps/FlowChart/layout.d.ts.map +1 -1
  62. package/dist/views/Steps/FlowChart/layout.js +1 -0
  63. package/dist/views/Steps/FlowChart/layout.js.map +1 -1
  64. package/dist/views/Steps/FlowChart/types.d.ts +1 -1
  65. package/dist/views/Steps/FlowChart/types.d.ts.map +1 -1
  66. package/dist/views/Steps/StepModal.js +2 -2
  67. package/dist/views/Steps/StepModal.js.map +1 -1
  68. package/dist/views/Steps/dictionary.d.ts +1 -1
  69. package/dist/views/Steps/utils.d.ts +1 -1
  70. package/dist/views/Steps/utils.d.ts.map +1 -1
  71. package/package.json +3 -3
  72. package/src/StackspotAIWidget.tsx +1 -7
  73. package/src/app-metadata.json +5 -5
  74. package/src/chat-interceptors/send-message.ts +137 -2
  75. package/src/state/ChatEntry.ts +6 -6
  76. package/src/state/ChatState.ts +4 -0
  77. package/src/utils/check-is-trial.ts +2 -5
  78. package/src/utils/planning-tool.ts +41 -0
  79. package/src/utils/update-tool-step.tsx +27 -0
  80. package/src/views/Agents/AgentsTab.tsx +3 -4
  81. package/src/views/Agents/useAgentFavorites.ts +1 -3
  82. package/src/views/Chat/ChatMessage.tsx +25 -5
  83. package/src/views/Chat/StepsList.tsx +337 -44
  84. package/src/views/Chat/styled.ts +17 -10
  85. package/src/views/MessageInput/AgentSelector.tsx +2 -7
  86. package/src/views/MessageInput/ButtonAgent.tsx +1 -1
  87. package/src/views/MessageInput/ButtonBar.tsx +1 -3
  88. package/src/views/MessageInput/QuickCommandSelector.tsx +1 -1
  89. package/src/views/MessageInput/index.tsx +4 -4
  90. package/src/views/Steps/FlowChart/NodeStep.tsx +1 -1
  91. package/src/views/Steps/FlowChart/layout.ts +1 -0
  92. package/src/views/Steps/FlowChart/types.ts +1 -1
  93. package/src/views/Steps/StepModal.tsx +2 -2
@@ -243,20 +243,27 @@ export const ChatList: IStyledComponentBase<
243
243
  }
244
244
 
245
245
  .steps {
246
- ul {
246
+ .steps-list {
247
247
  list-style: none;
248
248
  margin: 0;
249
249
  padding: 0;
250
250
  display: flex;
251
251
  flex-direction: column;
252
252
  gap: 6px;
253
+ }
253
254
 
254
- li {
255
- display: flex;
256
- flex-direction: row;
257
- gap: 4px;
258
- align-items: center;
255
+ .tools-list {
256
+ list-style: disc;
257
+ margin: 0;
258
+ padding-left: 24px;
259
+ display: block;
260
+ ::marker {
261
+ color: ${theme.color.light.contrastText};
262
+ }
263
+ }
259
264
 
265
+ ul {
266
+ li {
260
267
  &[role="button"] {
261
268
  cursor: pointer;
262
269
  }
@@ -275,7 +282,6 @@ export const ChatList: IStyledComponentBase<
275
282
  }
276
283
 
277
284
  .step-title {
278
- line-height: 0.75rem;
279
285
  overflow: hidden;
280
286
  text-overflow: ellipsis;
281
287
  display: -webkit-box;
@@ -285,8 +291,10 @@ export const ChatList: IStyledComponentBase<
285
291
  }
286
292
  }
287
293
 
288
- .step-actions {
289
- margin-top: 8px;
294
+ }
295
+
296
+ .step-actions {
297
+ margin-top: 16px;
290
298
  display: flex;
291
299
  gap: 6px;
292
300
 
@@ -296,7 +304,6 @@ export const ChatList: IStyledComponentBase<
296
304
  align-items: center;
297
305
  }
298
306
  }
299
- }
300
307
 
301
308
  .markdown img {
302
309
  max-width: 70%;
@@ -56,20 +56,15 @@ export const AgentSelector = ({ inputRef, isTrial }: {
56
56
 
57
57
  const getAgents = () => {
58
58
  if (spotId) {
59
- return workspaceAiClient.getAgentFromWorkspaceAi.useQuery({ workspaceId: spotId }, {
60
- enabled: isAgentEnabled }) as AgentResponseWithBuiltIn[]
59
+ return workspaceAiClient.getAgentFromWorkspaceAi.useQuery({ workspaceId: spotId }) as AgentResponseWithBuiltIn[]
61
60
  }
62
61
 
63
62
  if (isTrial) {
64
- return agentToolsClient.allAgents.useQuery({ visibilities: ['personal', 'built_in', 'recently_used'] }, {
65
- enabled: isAgentEnabled,
66
- })
63
+ return agentToolsClient.allAgents.useQuery({ visibilities: ['personal', 'built_in', 'recently_used'] })
67
64
  }
68
65
 
69
66
  return agentToolsClient.allAgents.useQuery({
70
67
  visibilities: ['account', 'shared', 'personal', 'built_in', 'recently_used', 'workspace'],
71
- }, {
72
- enabled: isAgentEnabled,
73
68
  })
74
69
  }
75
70
 
@@ -8,11 +8,11 @@ import { useMessageInputDictionary } from './dictionary'
8
8
 
9
9
  export const ButtonAgent = () => {
10
10
  const t = useMessageInputDictionary()
11
+ const agentDefault = agentToolsClient.agentDefault.useQuery()
11
12
  const widget = useWidget()
12
13
  const chat = useCurrentChat()
13
14
  const agent = useCurrentChatState('agent')
14
15
  const features = useCurrentChatState('features')
15
- const [agentDefault] = agentToolsClient.agentDefault.useStatefulQuery({ enabled: features.agent })
16
16
 
17
17
  const setAgentDefault = () => {
18
18
  agentDefault && chat.set(
@@ -13,10 +13,9 @@ interface SelectionBarProps {
13
13
  * Whether or not the message is currently being sent. This is used to decide which button to show: send or cancel.
14
14
  */
15
15
  isLoading?: boolean,
16
- customButtonBarItems?: React.ReactNode,
17
16
  }
18
17
 
19
- export const ButtonBar = ({ onSend, isLoading, customButtonBarItems }: SelectionBarProps) => {
18
+ export const ButtonBar = ({ onSend, isLoading }: SelectionBarProps) => {
20
19
  const t = useMessageInputDictionary()
21
20
  const chat = useCurrentChat()
22
21
  const widget = useWidget()
@@ -29,7 +28,6 @@ export const ButtonBar = ({ onSend, isLoading, customButtonBarItems }: Selection
29
28
  {features.editor && (
30
29
  <IconButton icon="Code" appearance="square" aria-label={t.code} title={t.code} onClick={() => widget.set('panel', 'editor')} />
31
30
  )}
32
- {customButtonBarItems}
33
31
  </Row>
34
32
  {isLoading ? (
35
33
  <IconButton
@@ -14,7 +14,7 @@ export const QuickCommandSelector = ({ inputRef, isTrial }:
14
14
  const isQuickCommandEnabled = useCurrentChatState('features').quickCommands
15
15
  const spotId = useWidgetState('features')?.workspaceId
16
16
 
17
- const useFavorites = () => aiClient.allQuickCommands.useQuery({ visibility: 'favorite' }, { enabled: isQuickCommandEnabled })
17
+ const useFavorites = () => aiClient.allQuickCommands.useQuery({ visibility: 'favorite' })
18
18
  const [addFavorite, pendingAddFav] = aiClient.addFavoriteQuickCommand.useMutation()
19
19
  const [removeFavorite, pendingRemoveFav] = aiClient.removeFavoriteQuickCommand.useMutation()
20
20
 
@@ -24,8 +24,8 @@ import { UploadDragNDrop, useUploadDragDrop } from './UploadDragNDrop'
24
24
  * going to be used for the question and the buttons to send, cancel, set the workspace, among others. This also includes the Quick
25
25
  * Commands panel for auto completing.
26
26
  */
27
- export const MessageInput = ({ chatWindowRef, customInputMessage, customButtonBarItems }:
28
- { chatWindowRef?: React.RefObject<HTMLElement>, customInputMessage?: string, customButtonBarItems?: React.ReactNode}) => {
27
+ export const MessageInput = ({ chatWindowRef, customInputMessage }:
28
+ { chatWindowRef?: React.RefObject<HTMLElement>, customInputMessage?: string }) => {
29
29
  const t = useMessageInputDictionary()
30
30
  const [focused, setFocused] = useState(false)
31
31
  const [, setExpanded] = useState(true)
@@ -152,7 +152,7 @@ export const MessageInput = ({ chatWindowRef, customInputMessage, customButtonBa
152
152
  placeholder={
153
153
  agentLabel
154
154
  ? customInputMessage ?? interpolate(t.placeholder, agentLabel)
155
- : customInputMessage ?? t.typing
155
+ : t.typing
156
156
  }
157
157
  onChange={v => chat.set('nextMessage', v)}
158
158
  value={value}
@@ -168,7 +168,7 @@ export const MessageInput = ({ chatWindowRef, customInputMessage, customButtonBa
168
168
  <ProgressBar className="progress-bar" progress={isLoading ? undefined : (focused ? 100 : 0)} speed="fast" />
169
169
  <ContextBar />
170
170
  {chat.get('features').upload && <UploadBar />}
171
- <ButtonBar onSend={onSend} isLoading={isLoading} customButtonBarItems={customButtonBarItems} />
171
+ <ButtonBar onSend={onSend} isLoading={isLoading} />
172
172
  </MessageInputBox>
173
173
  <UploadDragNDrop isDragging={isDragging} onDrop={handleDrop} onDragLeave={handleDragLeave} />
174
174
  </UploadProvider>
@@ -37,7 +37,7 @@ export const NodeStep = ({ data: { step, index, nextStatus, onClick } }: Props)
37
37
  {!!step.attempts[0].tools?.length && <StackedBadge
38
38
  label={t.tools}
39
39
  images={step.attempts[0].tools?.slice(0, 3).map(
40
- tool => ({ key: tool.id, name: tool.name, url: tool.image, icon: <Icon icon="Cog" /> }),
40
+ tool => ({ key: tool.id, name: tool.name ?? '', url: tool.image, icon: <Icon icon="Cog" /> }),
41
41
  )}
42
42
  />}
43
43
  </div>}
@@ -8,6 +8,7 @@ const nodesSizes = {
8
8
  step: stepNodeSize,
9
9
  planning: planningNodeSize,
10
10
  answer: answerNodeSize,
11
+ tool: stepNodeSize,
11
12
  }
12
13
 
13
14
  export function useLayoutedElements(nodes: NodeWithoutLayout[], edges: Edge[]) {
@@ -9,6 +9,6 @@ export interface NodeData {
9
9
 
10
10
  export interface NodeWithoutLayout {
11
11
  id: string,
12
- type: 'step' | 'planning' | 'answer',
12
+ type: 'step' | 'planning' | 'answer' | 'tool',
13
13
  data?: NodeData,
14
14
  }
@@ -127,7 +127,7 @@ export const StepModal = ({ message, stepId, onClose }: Props) => {
127
127
 
128
128
  const tools = step?.type === 'step' ? step.attempts[attempt]?.tools?.map(tool => (
129
129
  <div className="tool" key={tool.id}>
130
- <ToolBadge name={tool.name} duration={tool.duration} image={tool.image} description={tool.description} />
130
+ <ToolBadge name={tool.name ?? ''} duration={tool.duration} image={tool.image} description={tool.description} />
131
131
  {tool.input && <>
132
132
  <Text appearance="microtext1" color="light.700">{t.input}:</Text>
133
133
  <Code language="json" className="tool-input" showLineNumbers={false} showActionBar>{tool.input}</Code>
@@ -191,7 +191,7 @@ export const StepModal = ({ message, stepId, onClose }: Props) => {
191
191
  {!!s.attempts[0].tools?.length && <ul className="side-by-side-tools">
192
192
  {s.attempts[0].tools.map((tool) => (
193
193
  <li key={tool.id}>
194
- <ToolBadge name={tool.name} image={tool.image} />
194
+ <ToolBadge name={tool.name ?? ''} image={tool.image} />
195
195
  </li>
196
196
  ))}
197
197
  </ul>}