@stack-spot/ai-chat-widget 1.31.2-beta.1 → 1.32.0-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.
- package/CHANGELOG.md +25 -7
- package/dist/app-metadata.json +3 -3
- package/dist/components/RightPanelContentList.d.ts +10 -0
- package/dist/components/RightPanelContentList.d.ts.map +1 -0
- package/dist/components/RightPanelContentList.js +7 -0
- package/dist/components/RightPanelContentList.js.map +1 -0
- package/dist/components/Selector/index.d.ts.map +1 -1
- package/dist/components/Selector/index.js +3 -2
- package/dist/components/Selector/index.js.map +1 -1
- package/dist/features.d.ts +15 -0
- package/dist/features.d.ts.map +1 -1
- package/dist/features.js +1 -0
- package/dist/features.js.map +1 -1
- package/dist/layout.css +4 -0
- package/dist/state/constants.js +1 -1
- package/dist/state/constants.js.map +1 -1
- package/dist/views/Agents/AgentDescription.js +1 -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 +24 -15
- package/dist/views/Agents/AgentsPanel.js.map +1 -1
- package/dist/views/Agents/AgentsTab.d.ts +1 -1
- package/dist/views/Agents/AgentsTab.d.ts.map +1 -1
- package/dist/views/Agents/dictionary.d.ts +1 -1
- package/dist/views/KSDocument.d.ts.map +1 -1
- package/dist/views/KSDocument.js +2 -1
- package/dist/views/KSDocument.js.map +1 -1
- package/dist/views/KnowledgeSources.d.ts +1 -1
- package/dist/views/KnowledgeSources.d.ts.map +1 -1
- package/dist/views/KnowledgeSources.js +24 -11
- package/dist/views/KnowledgeSources.js.map +1 -1
- package/dist/views/MessageInput/AgentSelector.d.ts.map +1 -1
- package/dist/views/MessageInput/AgentSelector.js +6 -2
- package/dist/views/MessageInput/AgentSelector.js.map +1 -1
- package/dist/views/MessageInput/QuickCommandSelector.d.ts.map +1 -1
- package/dist/views/MessageInput/QuickCommandSelector.js +9 -4
- package/dist/views/MessageInput/QuickCommandSelector.js.map +1 -1
- package/dist/views/Stacks.d.ts +1 -1
- package/dist/views/Stacks.d.ts.map +1 -1
- package/dist/views/Stacks.js +21 -11
- package/dist/views/Stacks.js.map +1 -1
- package/package.json +2 -2
- package/src/app-metadata.json +3 -3
- package/src/components/RightPanelContentList.tsx +15 -0
- package/src/components/Selector/index.tsx +8 -6
- package/src/features.ts +17 -0
- package/src/layout.css +4 -0
- package/src/state/constants.ts +1 -1
- package/src/views/Agents/AgentDescription.tsx +1 -1
- package/src/views/Agents/AgentsPanel.tsx +36 -17
- package/src/views/Agents/AgentsTab.tsx +1 -1
- package/src/views/KSDocument.tsx +2 -1
- package/src/views/KnowledgeSources.tsx +38 -14
- package/src/views/MessageInput/AgentSelector.tsx +9 -3
- package/src/views/MessageInput/QuickCommandSelector.tsx +18 -5
- package/src/views/Stacks.tsx +34 -14
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Flex, IconBox, Image } from '@citric/core';
|
|
3
3
|
import { Agent } from '@citric/icons';
|
|
4
|
-
import { agentToolsClient } from '@stack-spot/portal-network';
|
|
4
|
+
import { agentToolsClient, workspaceAiClient } from '@stack-spot/portal-network';
|
|
5
5
|
import { useCallback } from 'react';
|
|
6
6
|
import { Selector } from '../../components/Selector/index.js';
|
|
7
|
-
import { useCurrentChat, useCurrentChatState } from '../../context/hooks.js';
|
|
7
|
+
import { useCurrentChat, useCurrentChatState, useWidgetState } from '../../context/hooks.js';
|
|
8
8
|
import { agentRegex } from '../../regex.js';
|
|
9
9
|
import { useAgentFavorites } from '../Agents/useAgentFavorites.js';
|
|
10
10
|
const AgentItem = ({ avatar, name, spaceName }) => {
|
|
@@ -14,6 +14,7 @@ const AgentItem = ({ avatar, name, spaceName }) => {
|
|
|
14
14
|
export const AgentSelector = ({ inputRef, isTrial }) => {
|
|
15
15
|
const chat = useCurrentChat();
|
|
16
16
|
const isAgentEnabled = useCurrentChatState('features').agent;
|
|
17
|
+
const spotId = useWidgetState('features')?.workspaceId;
|
|
17
18
|
const { useFavorites, onAddFavorite, onRemoveFavorite } = useAgentFavorites();
|
|
18
19
|
const onSelectItem = useCallback(async (agent) => {
|
|
19
20
|
const newValue = `@${agent.slug}`;
|
|
@@ -32,6 +33,9 @@ export const AgentSelector = ({ inputRef, isTrial }) => {
|
|
|
32
33
|
inputRef.current.focus();
|
|
33
34
|
}, [chat, inputRef]);
|
|
34
35
|
const getAgents = () => {
|
|
36
|
+
if (spotId) {
|
|
37
|
+
return workspaceAiClient.getAgentFromWorkspaceAi.useQuery({ workspaceId: spotId });
|
|
38
|
+
}
|
|
35
39
|
if (isTrial) {
|
|
36
40
|
return agentToolsClient.allAgents.useQuery({ visibilities: ['personal', 'built_in'] });
|
|
37
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentSelector.js","sourceRoot":"","sources":["../../../src/views/MessageInput/AgentSelector.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAA4B,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"AgentSelector.js","sourceRoot":"","sources":["../../../src/views/MessageInput/AgentSelector.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAA4B,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC1G,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,cA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AG;YACb,IAAI,EAAE,KAAC,KAAK,KAAG;YACf,KAAK,EAAE,UAAU;YACjB,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,KAAK,EAAE,EAAE,EAAE;YAC7C,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAC;YACjI,mBAAmB,EAAE,SAAS;YAC9B,SAAS,EAAE,cAAc;YACzB,QAAQ,EAAE,YAAY;YACtB,OAAO,EAAE,SAAS;SACnB,GACD,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuickCommandSelector.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/QuickCommandSelector.tsx"],"names":[],"mappings":"AAUA,eAAO,MAAM,oBAAoB,0BAC/B;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,mBAAmB,GAAG,gBAAgB,CAAC,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"QuickCommandSelector.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/QuickCommandSelector.tsx"],"names":[],"mappings":"AAUA,eAAO,MAAM,oBAAoB,0BAC/B;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,mBAAmB,GAAG,gBAAgB,CAAC,CAAA;CAAE,4CAmHxF,CAAA"}
|
|
@@ -3,11 +3,12 @@ import { QuickCommand } from '@citric/icons';
|
|
|
3
3
|
import { aiClient, workspaceAiClient } from '@stack-spot/portal-network';
|
|
4
4
|
import { useCallback } from 'react';
|
|
5
5
|
import { Selector } from '../../components/Selector/index.js';
|
|
6
|
-
import { useCurrentChat, useCurrentChatState } from '../../context/hooks.js';
|
|
6
|
+
import { useCurrentChat, useCurrentChatState, useWidgetState } from '../../context/hooks.js';
|
|
7
7
|
import { quickCommandRegex } from '../../regex.js';
|
|
8
8
|
export const QuickCommandSelector = ({ inputRef, isTrial }) => {
|
|
9
9
|
const chat = useCurrentChat();
|
|
10
10
|
const isQuickCommandEnabled = useCurrentChatState('features').quickCommands;
|
|
11
|
+
const spotId = useWidgetState('features')?.workspaceId;
|
|
11
12
|
const useFavorites = () => aiClient.allQuickCommands.useQuery({ visibility: 'favorite' });
|
|
12
13
|
const [addFavorite, pendingAddFav] = aiClient.addFavoriteQuickCommand.useMutation();
|
|
13
14
|
const [removeFavorite, pendingRemoveFav] = aiClient.removeFavoriteQuickCommand.useMutation();
|
|
@@ -68,11 +69,15 @@ export const QuickCommandSelector = ({ inputRef, isTrial }) => {
|
|
|
68
69
|
inputRef.current.focus();
|
|
69
70
|
}, [chat, inputRef]);
|
|
70
71
|
const getQuickCommands = () => {
|
|
72
|
+
if (spotId) {
|
|
73
|
+
return workspaceAiClient.getQCFromWorkspaceAi.useQuery({ workspaceId: spotId });
|
|
74
|
+
}
|
|
71
75
|
const quickCommands = aiClient.allQuickCommands.useQuery({ order: 'a-to-z' });
|
|
72
76
|
const quickCommandsFiltered = quickCommands.filter((qc) => qc.visibility_level.toLowerCase() !== 'workspace');
|
|
73
|
-
const workspaceQuickCommands = workspaceAiClient.workspacesContentsByType.useQuery({
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
const workspaceQuickCommands = workspaceAiClient.workspacesContentsByType.useQuery({
|
|
78
|
+
contentType: 'quick_command',
|
|
79
|
+
});
|
|
80
|
+
const workspaceQuickCommandsWithWorkspaceName = workspaceQuickCommands.flatMap(({ qcs, space_name }) => qcs?.map((qc) => ({ ...qc, spaceName: space_name })));
|
|
76
81
|
return [...quickCommandsFiltered, ...workspaceQuickCommandsWithWorkspaceName];
|
|
77
82
|
};
|
|
78
83
|
const QuickCommandItem = ({ slug, description, spaceName }) => _jsxs(_Fragment, { children: [_jsx("p", { className: "selector-description", children: spaceName }), _jsxs("p", { className: "selector-title", children: ["/", slug?.toUpperCase()] }), _jsx("p", { className: "selector-description", children: description })] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuickCommandSelector.js","sourceRoot":"","sources":["../../../src/views/MessageInput/QuickCommandSelector.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"QuickCommandSelector.js","sourceRoot":"","sources":["../../../src/views/MessageInput/QuickCommandSelector.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAI/C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAE,QAAQ,EAAE,OAAO,EACiC,EAAE,EAAE;IAC3F,MAAM,IAAI,GAAG,cAAc,EAAE,CAAA;IAC7B,MAAM,qBAAqB,GAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC,aAAa,CAAA;IAC5E,MAAM,MAAM,GAAG,cAAc,CAAC,UAAU,CAAC,EAAE,W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,YAAY,KAAG;YACtB,UAAU,EAAE,MAAM;YAClB,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE;YAChD,KAAK,EAAE,iBAAiB;YACxB,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC;YACzG,SAAS,EAAE,qBAAqB;YAChC,QAAQ,EAAE,YAAY;YACtB,mBAAmB,EAAE,gBAAgB;YACrC,OAAO,EAAE,gBAAgB;SAC1B,GACD,CAAA;AACJ,CAAC,CAAA"}
|
package/dist/views/Stacks.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { ChatProperties } from '../state/ChatState.js';
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const Stacks: () => null;
|
|
7
7
|
export interface StacksTabProps {
|
|
8
|
-
visibility
|
|
8
|
+
visibility?: VisibilityLevelEnum;
|
|
9
9
|
workspaceId?: string;
|
|
10
10
|
stack: React.MutableRefObject<ChatProperties['stack']>;
|
|
11
11
|
showSubmitButton?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stacks.d.ts","sourceRoot":"","sources":["../../src/views/Stacks.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAsB,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"Stacks.d.ts","sourceRoot":"","sources":["../../src/views/Stacks.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAsB,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAc3F,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAKnD;;GAEG;AACH,eAAO,MAAM,MAAM,YAclB,CAAA;AA0CD,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC,gBAAgB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IACvD,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,eAAO,MAAM,SAAS,yDAAiE,cAAc,4CAgHpG,CAAA"}
|
package/dist/views/Stacks.js
CHANGED
|
@@ -8,6 +8,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
8
8
|
import { ButtonFavorite } from '../components/ButtonFavorite.js';
|
|
9
9
|
import { DescribedRadioGroup } from '../components/form/DescribedRadioGroup.js';
|
|
10
10
|
import { IconInput } from '../components/IconInput.js';
|
|
11
|
+
import { RightPanelContentList } from '../components/RightPanelContentList.js';
|
|
11
12
|
import { RightPanelTabs } from '../components/RightPanelTabs.js';
|
|
12
13
|
import { WorkspaceTabNavigator } from '../components/WorkspaceTabNavigator.js';
|
|
13
14
|
import { useCurrentChat, useWidget, useWidgetState } from '../context/hooks.js';
|
|
@@ -32,20 +33,29 @@ const StacksPanel = () => {
|
|
|
32
33
|
const chat = useCurrentChat();
|
|
33
34
|
const isTrial = checkIsTrial();
|
|
34
35
|
const stack = useRef(chat.get('stack'));
|
|
36
|
+
const features = useWidgetState('features');
|
|
37
|
+
const isGroupResourcesByScope = features?.groupResourcesByScope;
|
|
38
|
+
const scopes = features?.scopes ?? [];
|
|
39
|
+
const spotId = features?.workspaceId;
|
|
35
40
|
useEffect(() => {
|
|
36
41
|
stack.current = chat.get('stack');
|
|
37
42
|
}, [chat]);
|
|
38
|
-
const
|
|
39
|
-
{ title: t.favorites, content: _jsx(StacksTab, { visibility: "favorite", stack: stack }, "favorites") },
|
|
40
|
-
{ title: t.personal, content: _jsx(StacksTab, { visibility: "personal", stack: stack }, "personal") },
|
|
41
|
-
|
|
42
|
-
{ title: t.
|
|
43
|
-
{ title: t.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
const allTabsMap = {
|
|
44
|
+
favorite: { title: t.favorites, content: _jsx(StacksTab, { visibility: "favorite", stack: stack }, "favorites") },
|
|
45
|
+
personal: { title: t.personal, content: _jsx(StacksTab, { visibility: "personal", stack: stack }, "personal") },
|
|
46
|
+
shared: { title: t.shared, content: _jsx(StacksTab, { visibility: "shared", stack: stack }, "shared") },
|
|
47
|
+
workspace: { title: t.spots, content: _jsx(StacksTabWorkspace, { visibility: "workspace", stack: stack }, "workspace") },
|
|
48
|
+
account: { title: t.account, content: _jsx(StacksTab, { visibility: "account", stack: stack }, "account") },
|
|
49
|
+
};
|
|
50
|
+
const defaultScopes = ['favorite', 'personal', 'shared', 'workspace', 'account'];
|
|
51
|
+
const rawScopes = scopes?.length ? scopes : defaultScopes;
|
|
52
|
+
const scopesToRender = isTrial
|
|
53
|
+
? ['favorite', 'personal']
|
|
54
|
+
: rawScopes;
|
|
55
|
+
const tabs = scopesToRender
|
|
56
|
+
.map(scope => allTabsMap[scope])
|
|
57
|
+
.filter(Boolean);
|
|
58
|
+
return (isGroupResourcesByScope ? (_jsx(RightPanelTabs, { tabs: tabs }, chat.id)) : (_jsx(RightPanelContentList, { children: _jsx(StacksTab, { stack: stack, workspaceId: spotId }) })));
|
|
49
59
|
};
|
|
50
60
|
export const StacksTab = ({ visibility, workspaceId, stack, showSubmitButton = true }) => {
|
|
51
61
|
const t = useTranslate(dictionary);
|
package/dist/views/Stacks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stacks.js","sourceRoot":"","sources":["../../src/views/Stacks.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAA;AACvE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAGxE,OAAO,EAAc,YAAY,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AE,eAAe;QACvB,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,SAAS;QAChB,eAAe,EAAE,oCAAoC;QACrD,0BAA0B,EAAE,+BAA+B;QAC3D,MAAM,EAAE,sCAAsC;QAC9C,iBAAiB,EAAE,6FAA6F;QAChH,SAAS,EAAE,WAAW;QACtB,KAAK,EAAE,OAAO;KACf;CACmB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stack-spot/ai-chat-widget",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.32.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@citric/core": "^6.4.0",
|
|
14
14
|
"@stack-spot/portal-components": "^2.22.1",
|
|
15
15
|
"@citric/icons": "^5.13.0",
|
|
16
|
-
"@stack-spot/portal-network": "0.
|
|
16
|
+
"@stack-spot/portal-network": "^0.160.1",
|
|
17
17
|
"@citric/ui": "^6.10.2",
|
|
18
18
|
"@stack-spot/portal-theme": "^1.0.0",
|
|
19
19
|
"@stack-spot/portal-translate": "^1.1.0",
|
package/src/app-metadata.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stack-spot/ai-chat-widget",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"date": "
|
|
3
|
+
"version": "1.32.0-beta.1",
|
|
4
|
+
"date": "Fri Jul 25 2025 14:37:59 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.160.1(@stack-spot/auth@5.3.2)(@stack-spot/opa@2.5.0(@stack-spot/auth@5.3.2)(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.59.16(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",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactElement } from 'react'
|
|
2
|
+
import { RightPanelForm } from './RightPanelForm'
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
children: ReactElement,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* List content for the right panel.
|
|
10
|
+
*/
|
|
11
|
+
export const RightPanelContentList = ({ children }: Props) => (
|
|
12
|
+
<RightPanelForm>
|
|
13
|
+
{children}
|
|
14
|
+
</RightPanelForm>
|
|
15
|
+
)
|
|
@@ -5,7 +5,7 @@ import { useKeyboardControls } from '@stack-spot/portal-components'
|
|
|
5
5
|
import { AgentVisibilityLevel } from '@stack-spot/portal-network'
|
|
6
6
|
import { Dictionary, interpolate, useTranslate } from '@stack-spot/portal-translate'
|
|
7
7
|
import React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
8
|
-
import { useCurrentChatState } from '../../context/hooks'
|
|
8
|
+
import { useCurrentChatState, useWidgetState } from '../../context/hooks'
|
|
9
9
|
import { getUrlToStackSpotAI } from '../../utils/url'
|
|
10
10
|
import { ButtonFavorite } from '../ButtonFavorite'
|
|
11
11
|
import { Fading } from '../Fading'
|
|
@@ -112,7 +112,6 @@ const List = <T extends Item>({ selectorConfig, filter, visibility, onSelect, fa
|
|
|
112
112
|
const t = useTranslate(dictionary)
|
|
113
113
|
const items = selectorConfig.useData()
|
|
114
114
|
const favorites = favorite?.useFavorites?.()
|
|
115
|
-
|
|
116
115
|
const filtered = useMemo(() => {
|
|
117
116
|
if (!filter && !visibility) return [...items]
|
|
118
117
|
const lowerFilter = filter?.toLowerCase() ?? ''
|
|
@@ -152,6 +151,7 @@ const SelectorContent = ({ filter, onClose, selectorConfig, favorite }: ContentP
|
|
|
152
151
|
const t = useTranslate(dictionary)
|
|
153
152
|
const ref = useRef<HTMLDivElement>(null)
|
|
154
153
|
const [visibility, setVisibility] = useState<SectionVisibility | undefined>()
|
|
154
|
+
const isGroupResourcesByScope = useWidgetState('features')?.groupResourcesByScope
|
|
155
155
|
const { resourceName, icon, onSelect, sections } = selectorConfig
|
|
156
156
|
const onSelectItem = useCallback((slug: string) => {
|
|
157
157
|
onSelect(slug)
|
|
@@ -184,10 +184,12 @@ const SelectorContent = ({ filter, onClose, selectorConfig, favorite }: ContentP
|
|
|
184
184
|
<Text as="h3" className="uppercase"> {resourceName} </Text>
|
|
185
185
|
</header>
|
|
186
186
|
<div className="body">
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
{isGroupResourcesByScope && (
|
|
188
|
+
<ul className="tabs">
|
|
189
|
+
{createSectionItem()}
|
|
190
|
+
{sections.map(createSectionItem)}
|
|
191
|
+
</ul>
|
|
192
|
+
)}
|
|
191
193
|
<FallbackBoundary message={interpolate(t.error, selectorConfig.resourceName)} mini>
|
|
192
194
|
<List filter={filter} visibility={visibility} selectorConfig={selectorConfig} onSelect={onSelectItem} favorite={favorite} />
|
|
193
195
|
</FallbackBoundary>
|
package/src/features.ts
CHANGED
|
@@ -41,11 +41,27 @@ export interface ChatFeatures {
|
|
|
41
41
|
streaming: boolean,
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
export type Scope = 'favorite' | 'builtin' | 'personal' | 'shared' | 'workspace' | 'account'
|
|
45
|
+
|
|
44
46
|
export interface GlobalFeatures {
|
|
45
47
|
/**
|
|
46
48
|
* Enables the chat history.
|
|
47
49
|
*/
|
|
48
50
|
chatHistory: boolean,
|
|
51
|
+
/**
|
|
52
|
+
* When selecting a resource, they're separated by scope (account, personal, workspace, etc.).
|
|
53
|
+
*
|
|
54
|
+
* If this is set, only the scopes in this list will be enabled.
|
|
55
|
+
*/
|
|
56
|
+
scopes?: Scope[],
|
|
57
|
+
/**
|
|
58
|
+
* When set, only items(knowledge sources, agents, stacks ai, quick commands) from that workspace will be shown to the user.
|
|
59
|
+
*/
|
|
60
|
+
workspaceId?: string,
|
|
61
|
+
/**
|
|
62
|
+
* when set to false it does not show tab by scope, it shows a single list.
|
|
63
|
+
*/
|
|
64
|
+
groupResourcesByScope?: boolean,
|
|
49
65
|
}
|
|
50
66
|
|
|
51
67
|
export type AIWidgetFeatures = ChatFeatures & GlobalFeatures
|
|
@@ -68,6 +84,7 @@ export function getFeaturesWithDefaults(features?: Partial<AIWidgetFeatures>): A
|
|
|
68
84
|
upload: true,
|
|
69
85
|
streaming: true,
|
|
70
86
|
showSourcesInResponse: true,
|
|
87
|
+
groupResourcesByScope: true,
|
|
71
88
|
...features,
|
|
72
89
|
}
|
|
73
90
|
}
|
package/src/layout.css
CHANGED
package/src/state/constants.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FileSize } from './types'
|
|
2
2
|
|
|
3
3
|
export const acceptedFileTypes = [
|
|
4
|
-
'json', 'yaml', 'txt', 'md', 'json', 'yaml', 'pdf', /*'xls', 'xlsx'
|
|
4
|
+
'json', 'yaml', 'txt', 'md', 'json', 'yaml', 'pdf', /*'xls', 'xlsx',*/ 'csv', 'cbl', 'cpp', 'cxx', 'cc', 'c', 'hpp', 'hxx', 'hh', 'h',
|
|
5
5
|
'cs', 'go', 'html', 'htm', 'kt', 'kts', 'md', 'php', 'proto', 'py', 'java', 'js', 'jsx', 'ts', 'tsx', 'rst', 'rb', 'rs', 'scala', 'swift',
|
|
6
6
|
'sql', 'yaml', 'yml', 'tf', 'sh', 'ps1', 'psd1', 'psm1', 'bat', 'cmd', 'rego', 'f', 'for', 'r', 'pl', 'vb', 'dart', 'hs', 'lua',
|
|
7
7
|
'asm', 'groovy', 'gvy', 'gy', 'mat', 'clj', 'lisp', 'm', 'cls', 'css', 'scss', 'json', 'jpg', 'jpeg', 'png',
|
|
@@ -28,7 +28,7 @@ export const AgentDescription = ({ agentId }: { agentId?: string }) => {
|
|
|
28
28
|
}, [numberOfKnowledgeSources])
|
|
29
29
|
const tools = useMemo(() => {
|
|
30
30
|
const result: React.ReactElement[] = []
|
|
31
|
-
const builtInTools = agent?.toolkits?.builtin_toolkits?.[0]
|
|
31
|
+
const builtInTools = agent?.toolkits?.builtin_toolkits?.[0]?.tools
|
|
32
32
|
const customToolkits = agent?.toolkits?.custom_toolkits ?? []
|
|
33
33
|
for (const tool of builtInTools ?? []) {
|
|
34
34
|
const toolWithImage = toolById(tool.id, toolKits)
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { agentToolsClient } from '@stack-spot/portal-network'
|
|
2
|
-
import {
|
|
2
|
+
import { ReactElement, useEffect, useRef } from 'react'
|
|
3
|
+
import { RightPanelContentList } from '../../components/RightPanelContentList'
|
|
3
4
|
import { RightPanelTabs } from '../../components/RightPanelTabs'
|
|
4
|
-
import { useCurrentChat } from '../../context/hooks'
|
|
5
|
+
import { useCurrentChat, useWidgetState } from '../../context/hooks'
|
|
6
|
+
import { Scope } from '../../features'
|
|
5
7
|
import { checkIsTrial } from '../../utils/check-is-trial'
|
|
6
8
|
import { AgentsTab, AgentsTabWorkspace } from './AgentsTab'
|
|
7
9
|
import { useAgentsDictionary } from './dictionary'
|
|
8
10
|
|
|
11
|
+
type TabElement = { title: string, content: ReactElement }
|
|
12
|
+
|
|
9
13
|
/**
|
|
10
14
|
* Renders the Agent selection form in the Right Panel if this is the panel that is currently opened.
|
|
11
15
|
*/
|
|
@@ -14,6 +18,10 @@ export const AgentsPanel = () => {
|
|
|
14
18
|
const chat = useCurrentChat()
|
|
15
19
|
const isTrial = checkIsTrial()
|
|
16
20
|
const agent = useRef(chat.get('agent'))
|
|
21
|
+
const features = useWidgetState('features')
|
|
22
|
+
const isGroupResourcesByScope = features?.groupResourcesByScope
|
|
23
|
+
const scopes = features?.scopes ?? []
|
|
24
|
+
const spotId = features?.workspaceId
|
|
17
25
|
|
|
18
26
|
useEffect(() => {
|
|
19
27
|
if (agentToolsClient.agentDefaultSlug !== chat.get('agent')?.slug) {
|
|
@@ -21,19 +29,30 @@ export const AgentsPanel = () => {
|
|
|
21
29
|
}
|
|
22
30
|
}, [chat])
|
|
23
31
|
|
|
24
|
-
const
|
|
25
|
-
{ title: t.favorites, content: <AgentsTab key="favorite" visibility="favorite" agent={agent} /> },
|
|
26
|
-
{ title: t.builtin, content: <AgentsTab key="builtin" visibility="built_in" agent={agent} /> },
|
|
27
|
-
{ title: t.personal, content: <AgentsTab key="personal" visibility="personal" agent={agent} /> },
|
|
28
|
-
|
|
29
|
-
{ title: t.
|
|
30
|
-
{ title: t.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
const allTabsMap: Record<Scope, TabElement> = {
|
|
33
|
+
favorite: { title: t.favorites, content: <AgentsTab key="favorite" visibility="favorite" agent={agent} /> },
|
|
34
|
+
builtin: { title: t.builtin, content: <AgentsTab key="builtin" visibility="built_in" agent={agent} /> },
|
|
35
|
+
personal: { title: t.personal, content: <AgentsTab key="personal" visibility="personal" agent={agent} /> },
|
|
36
|
+
shared: { title: t.shared, content: <AgentsTab key="shared" visibility="shared" agent={agent} /> },
|
|
37
|
+
workspace: { title: t.spots, content: <AgentsTabWorkspace key="workspace" visibility="workspace" agent={agent} /> },
|
|
38
|
+
account: { title: t.account, content: <AgentsTab key="account" visibility="account" agent={agent} /> },
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const defaultScopes: Scope[] = ['favorite', 'builtin', 'personal', 'shared', 'workspace', 'account']
|
|
42
|
+
|
|
43
|
+
const rawScopes: Scope[] = scopes?.length ? scopes : defaultScopes
|
|
44
|
+
|
|
45
|
+
const scopesToRender: Scope[] = isTrial
|
|
46
|
+
? ['favorite', 'builtin', 'personal']
|
|
47
|
+
: rawScopes
|
|
48
|
+
|
|
49
|
+
const tabs = scopesToRender
|
|
50
|
+
.map(scope => allTabsMap[scope])
|
|
51
|
+
.filter(Boolean) as TabElement[]
|
|
52
|
+
|
|
53
|
+
return (isGroupResourcesByScope ? (
|
|
54
|
+
<RightPanelTabs key={chat.id} tabs={tabs} />
|
|
55
|
+
) : (
|
|
56
|
+
<RightPanelContentList><AgentsTab workspaceId={spotId} agent={agent} /></RightPanelContentList>
|
|
57
|
+
))
|
|
39
58
|
}
|
|
@@ -19,7 +19,7 @@ import { AgentLabel } from './styled'
|
|
|
19
19
|
import { useAgentFavorites } from './useAgentFavorites'
|
|
20
20
|
|
|
21
21
|
export interface AgentTabProps {
|
|
22
|
-
visibility
|
|
22
|
+
visibility?: AgentVisibilityLevel,
|
|
23
23
|
workspaceId?: string,
|
|
24
24
|
agent: React.MutableRefObject<ChatProperties['agent']>,
|
|
25
25
|
showSubmitButton?: boolean,
|
package/src/views/KSDocument.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { aiClient } from '@stack-spot/portal-network'
|
|
|
4
4
|
import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
|
|
5
5
|
import { useEffect } from 'react'
|
|
6
6
|
import { Code } from '../components/Code'
|
|
7
|
+
import { FallbackBoundary } from '../components/FallbackBoundary'
|
|
7
8
|
import { useWidget, useWidgetState } from '../context/hooks'
|
|
8
9
|
import { useRightPanel } from '../right-panel/hooks'
|
|
9
10
|
import { extractCodeFromKSDocument } from '../utils/knowledge-source'
|
|
@@ -20,7 +21,7 @@ export const KSDocument = () => {
|
|
|
20
21
|
|
|
21
22
|
useEffect(() => {
|
|
22
23
|
if (panel === 'ks-details' && ks) open(
|
|
23
|
-
<KSDocumentPanel documentId={ks.documentId} slug={ks.slug}
|
|
24
|
+
<FallbackBoundary><KSDocumentPanel documentId={ks.documentId} slug={ks.slug} /></FallbackBoundary>,
|
|
24
25
|
{
|
|
25
26
|
title: (
|
|
26
27
|
<Flex flexDirection="row" alignItems="center" flex="1">
|
|
@@ -6,26 +6,30 @@ import { KnowledgeSourceItemResponse, VisibilityLevelEnum } from '@stack-spot/po
|
|
|
6
6
|
import { WorkspaceResponse } from '@stack-spot/portal-network/api/workspace-ai'
|
|
7
7
|
import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
|
|
8
8
|
import { difference, uniqBy } from 'lodash'
|
|
9
|
-
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
9
|
+
import React, { ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
10
10
|
import { ButtonFavorite } from '../components/ButtonFavorite'
|
|
11
11
|
import { NavigationComponent } from '../components/ComponentNavigator'
|
|
12
12
|
import { DescribedCheckboxGroup } from '../components/form/DescribedCheckboxGroup'
|
|
13
13
|
import { IconInput } from '../components/IconInput'
|
|
14
|
+
import { RightPanelContentList } from '../components/RightPanelContentList'
|
|
14
15
|
import { RightPanelTabs } from '../components/RightPanelTabs'
|
|
15
16
|
import { WorkspaceTabNavigator } from '../components/WorkspaceTabNavigator'
|
|
16
17
|
import { useCurrentChat, useWidget, useWidgetState } from '../context/hooks'
|
|
18
|
+
import { Scope } from '../features'
|
|
17
19
|
import { useRightPanel } from '../right-panel/hooks'
|
|
18
20
|
import { ChatProperties } from '../state/ChatState'
|
|
19
21
|
import { checkIsTrial } from '../utils/check-is-trial'
|
|
20
22
|
|
|
21
23
|
export interface TabProps {
|
|
22
|
-
visibility
|
|
24
|
+
visibility?: VisibilityLevelEnum,
|
|
23
25
|
allKS: React.MutableRefObject<ChatProperties['knowledgeSources']>,
|
|
24
26
|
workspaceId?: string,
|
|
25
27
|
showSubmitButton?: boolean,
|
|
26
28
|
onSubmit?: () => void,
|
|
27
29
|
}
|
|
28
30
|
|
|
31
|
+
type TabElement = { title: string, content: ReactElement }
|
|
32
|
+
|
|
29
33
|
export const KnowledgeSources = () => {
|
|
30
34
|
const t = useTranslate(dictionary)
|
|
31
35
|
const panel = useWidgetState('panel')
|
|
@@ -51,6 +55,10 @@ const KnowledgeSourcesPanel = () => {
|
|
|
51
55
|
const allKS = useRef(chat.get('knowledgeSources') ?? [])
|
|
52
56
|
const { close } = useRightPanel()
|
|
53
57
|
const isTrial = checkIsTrial()
|
|
58
|
+
const features = useWidgetState('features')
|
|
59
|
+
const isGroupResourcesByScope = features?.groupResourcesByScope
|
|
60
|
+
const scopes = features?.scopes ?? []
|
|
61
|
+
const spotId = features?.workspaceId
|
|
54
62
|
|
|
55
63
|
const onSubmit = useCallback(() => {
|
|
56
64
|
chat.set('knowledgeSources', allKS.current)
|
|
@@ -61,18 +69,34 @@ const KnowledgeSourcesPanel = () => {
|
|
|
61
69
|
allKS.current = chat.get('knowledgeSources') ?? []
|
|
62
70
|
}, [chat])
|
|
63
71
|
|
|
64
|
-
const
|
|
65
|
-
{ title: t.favorites,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
{ title: t.
|
|
70
|
-
{ title: t.
|
|
71
|
-
|
|
72
|
-
{ title: t.account, content: <KnowledgeSourcesTab key="account" visibility="account" allKS={allKS} onSubmit={onSubmit} /> },
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
const allTabsMap: Partial<Record<Scope, TabElement>> = {
|
|
73
|
+
favorite: { title: t.favorites,
|
|
74
|
+
content: <KnowledgeSourcesTab key="favorite" visibility="favorite" allKS={allKS} onSubmit={onSubmit} /> },
|
|
75
|
+
personal: { title: t.personal,
|
|
76
|
+
content: <KnowledgeSourcesTab key="personal" visibility="personal" allKS={allKS} onSubmit={onSubmit} /> },
|
|
77
|
+
shared: { title: t.shared, content: <KnowledgeSourcesTab key="shared" visibility="shared" allKS={allKS} onSubmit={onSubmit} /> },
|
|
78
|
+
workspace: { title: t.spots,
|
|
79
|
+
content: <KnowledgeSourcesTabWorkspace key="workspace" visibility="workspace" allKS={allKS} onSubmit={onSubmit} /> },
|
|
80
|
+
account: { title: t.account, content: <KnowledgeSourcesTab key="account" visibility="account" allKS={allKS} onSubmit={onSubmit} /> },
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const defaultScopes: Scope[] = ['favorite', 'personal', 'shared', 'workspace', 'account']
|
|
84
|
+
|
|
85
|
+
const rawScopes: Scope[] = scopes?.length ? scopes : defaultScopes
|
|
86
|
+
|
|
87
|
+
const scopesToRender: Scope[] = isTrial
|
|
88
|
+
? ['favorite', 'personal']
|
|
89
|
+
: rawScopes
|
|
90
|
+
|
|
91
|
+
const tabs = scopesToRender
|
|
92
|
+
.map(scope => allTabsMap[scope])
|
|
93
|
+
.filter(Boolean) as TabElement[]
|
|
94
|
+
|
|
95
|
+
return (isGroupResourcesByScope ? (
|
|
96
|
+
<RightPanelTabs key={chat.id} tabs={tabs} />
|
|
97
|
+
) : (
|
|
98
|
+
<RightPanelContentList><KnowledgeSourcesTab allKS={allKS} onSubmit={onSubmit} workspaceId={spotId} /></RightPanelContentList>
|
|
99
|
+
))
|
|
76
100
|
}
|
|
77
101
|
|
|
78
102
|
export const KnowledgeSourcesTab = ({ visibility, allKS, onSubmit, workspaceId, showSubmitButton = true }: TabProps) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Flex, IconBox, Image } from '@citric/core'
|
|
2
2
|
import { Agent } from '@citric/icons'
|
|
3
|
-
import { AgentResponseWithBuiltIn, agentToolsClient } from '@stack-spot/portal-network'
|
|
3
|
+
import { AgentResponseWithBuiltIn, agentToolsClient, workspaceAiClient } from '@stack-spot/portal-network'
|
|
4
4
|
import { useCallback } from 'react'
|
|
5
5
|
import { Selector } from '../../components/Selector'
|
|
6
|
-
import { useCurrentChat, useCurrentChatState } from '../../context/hooks'
|
|
6
|
+
import { useCurrentChat, useCurrentChatState, useWidgetState } from '../../context/hooks'
|
|
7
7
|
import { agentRegex } from '../../regex'
|
|
8
8
|
import { useAgentFavorites } from '../Agents/useAgentFavorites'
|
|
9
9
|
|
|
@@ -27,7 +27,8 @@ export const AgentSelector = ({ inputRef, isTrial }: {
|
|
|
27
27
|
}) => {
|
|
28
28
|
const chat = useCurrentChat()
|
|
29
29
|
const isAgentEnabled = useCurrentChatState('features').agent
|
|
30
|
-
|
|
30
|
+
const spotId = useWidgetState('features')?.workspaceId
|
|
31
|
+
|
|
31
32
|
const { useFavorites, onAddFavorite, onRemoveFavorite } = useAgentFavorites()
|
|
32
33
|
|
|
33
34
|
const onSelectItem = useCallback(async (agent: AgentResponseWithBuiltIn) => {
|
|
@@ -52,9 +53,14 @@ export const AgentSelector = ({ inputRef, isTrial }: {
|
|
|
52
53
|
|
|
53
54
|
|
|
54
55
|
const getAgents = () => {
|
|
56
|
+
if (spotId) {
|
|
57
|
+
return workspaceAiClient.getAgentFromWorkspaceAi.useQuery({ workspaceId: spotId }) as AgentResponseWithBuiltIn[]
|
|
58
|
+
}
|
|
59
|
+
|
|
55
60
|
if (isTrial) {
|
|
56
61
|
return agentToolsClient.allAgents.useQuery({ visibilities: ['personal', 'built_in'] })
|
|
57
62
|
}
|
|
63
|
+
|
|
58
64
|
return agentToolsClient.allAgents.useQuery({ visibilities: ['account', 'shared', 'personal', 'built_in', 'workspace'] })
|
|
59
65
|
}
|
|
60
66
|
|