@backstage-community/plugin-mcp-chat 0.0.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/README.md +361 -0
- package/config.d.ts +47 -0
- package/dist/api/McpChatApi.esm.js +55 -0
- package/dist/api/McpChatApi.esm.js.map +1 -0
- package/dist/api/index.esm.js +8 -0
- package/dist/api/index.esm.js.map +1 -0
- package/dist/components/BotIcon/BotIcon.esm.js +57 -0
- package/dist/components/BotIcon/BotIcon.esm.js.map +1 -0
- package/dist/components/ChatContainer/ChatContainer.esm.js +246 -0
- package/dist/components/ChatContainer/ChatContainer.esm.js.map +1 -0
- package/dist/components/ChatContainer/ChatMessage.esm.js +466 -0
- package/dist/components/ChatContainer/ChatMessage.esm.js.map +1 -0
- package/dist/components/ChatContainer/QuickStart.esm.js +271 -0
- package/dist/components/ChatContainer/QuickStart.esm.js.map +1 -0
- package/dist/components/ChatContainer/TypingIndicator.esm.js +154 -0
- package/dist/components/ChatContainer/TypingIndicator.esm.js.map +1 -0
- package/dist/components/ChatPage/ChatPage.esm.js +142 -0
- package/dist/components/ChatPage/ChatPage.esm.js.map +1 -0
- package/dist/components/ChatPage/index.esm.js +2 -0
- package/dist/components/ChatPage/index.esm.js.map +1 -0
- package/dist/components/RightPane/ActiveMcpServers.esm.js +159 -0
- package/dist/components/RightPane/ActiveMcpServers.esm.js.map +1 -0
- package/dist/components/RightPane/ActiveTools.esm.js +308 -0
- package/dist/components/RightPane/ActiveTools.esm.js.map +1 -0
- package/dist/components/RightPane/ProviderStatus.esm.js +225 -0
- package/dist/components/RightPane/ProviderStatus.esm.js.map +1 -0
- package/dist/components/RightPane/RightPane.esm.js +242 -0
- package/dist/components/RightPane/RightPane.esm.js.map +1 -0
- package/dist/hooks/useAvailableTools.esm.js +33 -0
- package/dist/hooks/useAvailableTools.esm.js.map +1 -0
- package/dist/hooks/useMcpServers.esm.js +40 -0
- package/dist/hooks/useMcpServers.esm.js.map +1 -0
- package/dist/hooks/useProviderStatus.esm.js +22 -0
- package/dist/hooks/useProviderStatus.esm.js.map +1 -0
- package/dist/index.d.ts +150 -0
- package/dist/index.esm.js +3 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/plugin.esm.js +33 -0
- package/dist/plugin.esm.js.map +1 -0
- package/dist/routes.esm.js +8 -0
- package/dist/routes.esm.js.map +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useCallback, useMemo } from 'react';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import Typography from '@mui/material/Typography';
|
|
5
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
6
|
+
import Chip from '@mui/material/Chip';
|
|
7
|
+
import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord';
|
|
8
|
+
import CloudIcon from '@mui/icons-material/Cloud';
|
|
9
|
+
import { useTheme } from '@mui/material/styles';
|
|
10
|
+
|
|
11
|
+
const ProviderStatus = ({
|
|
12
|
+
providerStatusData,
|
|
13
|
+
isLoading,
|
|
14
|
+
error
|
|
15
|
+
}) => {
|
|
16
|
+
const theme = useTheme();
|
|
17
|
+
const primaryProvider = providerStatusData?.providers?.[0];
|
|
18
|
+
const connectionInfo = primaryProvider?.connection;
|
|
19
|
+
const isConnected = connectionInfo?.connected ?? false;
|
|
20
|
+
const isError = !isConnected && !isLoading;
|
|
21
|
+
const getBoxBackgroundColor = useCallback(() => {
|
|
22
|
+
return theme.palette.background.paper;
|
|
23
|
+
}, [theme.palette.background.paper]);
|
|
24
|
+
const getBorderColor = useCallback(() => {
|
|
25
|
+
if (isError) {
|
|
26
|
+
return theme.palette.error.main;
|
|
27
|
+
}
|
|
28
|
+
return theme.palette.divider;
|
|
29
|
+
}, [isError, theme.palette]);
|
|
30
|
+
const getChipBackgroundColor = useCallback(() => {
|
|
31
|
+
if (isLoading) {
|
|
32
|
+
return "transparent";
|
|
33
|
+
}
|
|
34
|
+
if (isConnected) {
|
|
35
|
+
return theme.palette.mode === "dark" ? theme.palette.background.paper : "transparent";
|
|
36
|
+
}
|
|
37
|
+
return "transparent";
|
|
38
|
+
}, [
|
|
39
|
+
isLoading,
|
|
40
|
+
isConnected,
|
|
41
|
+
theme.palette.mode,
|
|
42
|
+
theme.palette.background.paper
|
|
43
|
+
]);
|
|
44
|
+
const getChipColor = useCallback(() => {
|
|
45
|
+
if (isLoading) {
|
|
46
|
+
return theme.palette.warning.main;
|
|
47
|
+
}
|
|
48
|
+
if (isConnected) {
|
|
49
|
+
return theme.palette.mode === "dark" ? theme.palette.success.light : theme.palette.success.dark;
|
|
50
|
+
}
|
|
51
|
+
return theme.palette.error.main;
|
|
52
|
+
}, [isLoading, isConnected, theme.palette]);
|
|
53
|
+
const getChipBorder = useCallback(() => {
|
|
54
|
+
if (isLoading) {
|
|
55
|
+
return `2px solid ${theme.palette.warning.main}`;
|
|
56
|
+
}
|
|
57
|
+
if (isConnected) {
|
|
58
|
+
return `2px solid ${theme.palette.success.main}`;
|
|
59
|
+
}
|
|
60
|
+
return `2px solid ${theme.palette.error.main}`;
|
|
61
|
+
}, [isLoading, isConnected, theme.palette]);
|
|
62
|
+
const getDotColor = useCallback(() => {
|
|
63
|
+
if (isLoading) {
|
|
64
|
+
return theme.palette.warning.main;
|
|
65
|
+
}
|
|
66
|
+
if (isConnected) {
|
|
67
|
+
return theme.palette.success.main;
|
|
68
|
+
}
|
|
69
|
+
return theme.palette.error.main;
|
|
70
|
+
}, [isLoading, isConnected, theme.palette]);
|
|
71
|
+
const getStatusText = useCallback(() => {
|
|
72
|
+
if (isLoading) return "Testing...";
|
|
73
|
+
if (isConnected) return "Connected";
|
|
74
|
+
return "Disconnected";
|
|
75
|
+
}, [isLoading, isConnected]);
|
|
76
|
+
const getTooltipTitle = useCallback(() => {
|
|
77
|
+
if (isLoading) {
|
|
78
|
+
return "Testing provider connection...";
|
|
79
|
+
}
|
|
80
|
+
if (isConnected) {
|
|
81
|
+
const modelsText = connectionInfo?.models ? `${connectionInfo.models.length} models available.` : "";
|
|
82
|
+
return `Successfully connected. ${modelsText}`;
|
|
83
|
+
}
|
|
84
|
+
return `Connection failed: ${connectionInfo?.error || error || "Unknown error"}`;
|
|
85
|
+
}, [isLoading, isConnected, connectionInfo, error]);
|
|
86
|
+
const displayModel = useMemo(() => {
|
|
87
|
+
if (isLoading) return "Loading...";
|
|
88
|
+
if (error && !providerStatusData) return "Error";
|
|
89
|
+
return primaryProvider?.model || "Not available";
|
|
90
|
+
}, [isLoading, error, providerStatusData, primaryProvider?.model]);
|
|
91
|
+
const displayUrl = useMemo(() => {
|
|
92
|
+
if (isLoading) return "Loading...";
|
|
93
|
+
if (error && !providerStatusData) return "Error";
|
|
94
|
+
return primaryProvider?.baseUrl || "Not available";
|
|
95
|
+
}, [isLoading, error, providerStatusData, primaryProvider?.baseUrl]);
|
|
96
|
+
const errorMessage = connectionInfo?.error || error;
|
|
97
|
+
return /* @__PURE__ */ jsxs(
|
|
98
|
+
Box,
|
|
99
|
+
{
|
|
100
|
+
style: {
|
|
101
|
+
padding: "16px",
|
|
102
|
+
margin: "16px",
|
|
103
|
+
backgroundColor: getBoxBackgroundColor(),
|
|
104
|
+
borderRadius: "8px",
|
|
105
|
+
border: `1px solid ${getBorderColor()}`
|
|
106
|
+
},
|
|
107
|
+
children: [
|
|
108
|
+
/* @__PURE__ */ jsxs(
|
|
109
|
+
Box,
|
|
110
|
+
{
|
|
111
|
+
style: {
|
|
112
|
+
display: "flex",
|
|
113
|
+
justifyContent: "space-between",
|
|
114
|
+
alignItems: "center",
|
|
115
|
+
marginBottom: "8px"
|
|
116
|
+
},
|
|
117
|
+
children: [
|
|
118
|
+
/* @__PURE__ */ jsxs(Box, { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
|
|
119
|
+
/* @__PURE__ */ jsx(
|
|
120
|
+
CloudIcon,
|
|
121
|
+
{
|
|
122
|
+
style: { fontSize: "18px", color: theme.palette.text.secondary }
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
/* @__PURE__ */ jsx(
|
|
126
|
+
Typography,
|
|
127
|
+
{
|
|
128
|
+
variant: "subtitle2",
|
|
129
|
+
style: { fontWeight: 600, color: theme.palette.text.primary },
|
|
130
|
+
children: "Provider"
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
] }),
|
|
134
|
+
/* @__PURE__ */ jsx(Tooltip, { title: getTooltipTitle(), placement: "left", children: /* @__PURE__ */ jsx(
|
|
135
|
+
Chip,
|
|
136
|
+
{
|
|
137
|
+
label: getStatusText(),
|
|
138
|
+
size: "small",
|
|
139
|
+
icon: /* @__PURE__ */ jsx(
|
|
140
|
+
FiberManualRecordIcon,
|
|
141
|
+
{
|
|
142
|
+
sx: {
|
|
143
|
+
fill: getDotColor(),
|
|
144
|
+
fontSize: "10px !important",
|
|
145
|
+
marginLeft: "8px"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
sx: {
|
|
150
|
+
cursor: "help",
|
|
151
|
+
backgroundColor: getChipBackgroundColor(),
|
|
152
|
+
color: getChipColor(),
|
|
153
|
+
border: getChipBorder(),
|
|
154
|
+
fontSize: "0.75rem",
|
|
155
|
+
fontWeight: 600,
|
|
156
|
+
"& .MuiChip-icon": {
|
|
157
|
+
marginLeft: "8px",
|
|
158
|
+
marginRight: "4px"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
) })
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
/* @__PURE__ */ jsxs(
|
|
167
|
+
Typography,
|
|
168
|
+
{
|
|
169
|
+
variant: "caption",
|
|
170
|
+
style: {
|
|
171
|
+
color: theme.palette.text.primary,
|
|
172
|
+
lineHeight: 1.5,
|
|
173
|
+
fontSize: "0.8rem"
|
|
174
|
+
},
|
|
175
|
+
children: [
|
|
176
|
+
/* @__PURE__ */ jsx("strong", { children: "Model:" }),
|
|
177
|
+
" ",
|
|
178
|
+
displayModel,
|
|
179
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
180
|
+
/* @__PURE__ */ jsx("strong", { children: "URL:" }),
|
|
181
|
+
" ",
|
|
182
|
+
displayUrl
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
errorMessage && !isLoading && /* @__PURE__ */ jsx(
|
|
187
|
+
Box,
|
|
188
|
+
{
|
|
189
|
+
style: {
|
|
190
|
+
marginTop: "12px",
|
|
191
|
+
padding: "10px",
|
|
192
|
+
backgroundColor: theme.palette.background.paper,
|
|
193
|
+
borderRadius: "6px",
|
|
194
|
+
border: `1px solid ${theme.palette.error.main}`,
|
|
195
|
+
maxHeight: "80px",
|
|
196
|
+
overflowY: "auto"
|
|
197
|
+
},
|
|
198
|
+
children: /* @__PURE__ */ jsxs(
|
|
199
|
+
Typography,
|
|
200
|
+
{
|
|
201
|
+
variant: "caption",
|
|
202
|
+
style: {
|
|
203
|
+
color: theme.palette.text.primary,
|
|
204
|
+
fontSize: "0.75rem",
|
|
205
|
+
lineHeight: 1.4,
|
|
206
|
+
display: "block",
|
|
207
|
+
wordBreak: "break-word",
|
|
208
|
+
whiteSpace: "pre-wrap"
|
|
209
|
+
},
|
|
210
|
+
children: [
|
|
211
|
+
/* @__PURE__ */ jsx("strong", { children: "Error:" }),
|
|
212
|
+
" ",
|
|
213
|
+
errorMessage
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
)
|
|
217
|
+
}
|
|
218
|
+
)
|
|
219
|
+
]
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export { ProviderStatus };
|
|
225
|
+
//# sourceMappingURL=ProviderStatus.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProviderStatus.esm.js","sources":["../../../src/components/RightPane/ProviderStatus.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useMemo, useCallback } from 'react';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport Tooltip from '@mui/material/Tooltip';\nimport Chip from '@mui/material/Chip';\nimport FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord';\nimport CloudIcon from '@mui/icons-material/Cloud';\nimport { useTheme } from '@mui/material/styles';\nimport { ProviderStatusData } from '../../types';\n\ninterface ProviderStatusProps {\n providerStatusData: ProviderStatusData | null;\n isLoading: boolean;\n error: string | null;\n}\n\nexport const ProviderStatus = ({\n providerStatusData,\n isLoading,\n error,\n}: ProviderStatusProps) => {\n const theme = useTheme();\n\n const primaryProvider = providerStatusData?.providers?.[0];\n const connectionInfo = primaryProvider?.connection;\n const isConnected = connectionInfo?.connected ?? false;\n const isError = !isConnected && !isLoading;\n\n const getBoxBackgroundColor = useCallback(() => {\n return theme.palette.background.paper;\n }, [theme.palette.background.paper]);\n\n const getBorderColor = useCallback(() => {\n if (isError) {\n return theme.palette.error.main;\n }\n return theme.palette.divider;\n }, [isError, theme.palette]);\n\n const getChipBackgroundColor = useCallback(() => {\n if (isLoading) {\n return 'transparent';\n }\n if (isConnected) {\n return theme.palette.mode === 'dark'\n ? theme.palette.background.paper\n : 'transparent';\n }\n return 'transparent';\n }, [\n isLoading,\n isConnected,\n theme.palette.mode,\n theme.palette.background.paper,\n ]);\n\n const getChipColor = useCallback(() => {\n if (isLoading) {\n return theme.palette.warning.main;\n }\n if (isConnected) {\n return theme.palette.mode === 'dark'\n ? theme.palette.success.light\n : theme.palette.success.dark;\n }\n return theme.palette.error.main;\n }, [isLoading, isConnected, theme.palette]);\n\n const getChipBorder = useCallback(() => {\n if (isLoading) {\n return `2px solid ${theme.palette.warning.main}`;\n }\n if (isConnected) {\n return `2px solid ${theme.palette.success.main}`;\n }\n return `2px solid ${theme.palette.error.main}`;\n }, [isLoading, isConnected, theme.palette]);\n\n const getDotColor = useCallback(() => {\n if (isLoading) {\n return theme.palette.warning.main;\n }\n if (isConnected) {\n return theme.palette.success.main;\n }\n return theme.palette.error.main;\n }, [isLoading, isConnected, theme.palette]);\n\n const getStatusText = useCallback(() => {\n if (isLoading) return 'Testing...';\n if (isConnected) return 'Connected';\n return 'Disconnected';\n }, [isLoading, isConnected]);\n\n const getTooltipTitle = useCallback(() => {\n if (isLoading) {\n return 'Testing provider connection...';\n }\n if (isConnected) {\n const modelsText = connectionInfo?.models\n ? `${connectionInfo.models.length} models available.`\n : '';\n return `Successfully connected. ${modelsText}`;\n }\n return `Connection failed: ${\n connectionInfo?.error || error || 'Unknown error'\n }`;\n }, [isLoading, isConnected, connectionInfo, error]);\n\n const displayModel = useMemo(() => {\n if (isLoading) return 'Loading...';\n if (error && !providerStatusData) return 'Error';\n return primaryProvider?.model || 'Not available';\n }, [isLoading, error, providerStatusData, primaryProvider?.model]);\n\n const displayUrl = useMemo(() => {\n if (isLoading) return 'Loading...';\n if (error && !providerStatusData) return 'Error';\n return primaryProvider?.baseUrl || 'Not available';\n }, [isLoading, error, providerStatusData, primaryProvider?.baseUrl]);\n\n const errorMessage = connectionInfo?.error || error;\n\n return (\n <Box\n style={{\n padding: '16px',\n margin: '16px',\n backgroundColor: getBoxBackgroundColor(),\n borderRadius: '8px',\n border: `1px solid ${getBorderColor()}`,\n }}\n >\n <Box\n style={{\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n marginBottom: '8px',\n }}\n >\n <Box style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>\n <CloudIcon\n style={{ fontSize: '18px', color: theme.palette.text.secondary }}\n />\n <Typography\n variant=\"subtitle2\"\n style={{ fontWeight: 600, color: theme.palette.text.primary }}\n >\n Provider\n </Typography>\n </Box>\n <Tooltip title={getTooltipTitle()} placement=\"left\">\n <Chip\n label={getStatusText()}\n size=\"small\"\n icon={\n <FiberManualRecordIcon\n sx={{\n fill: getDotColor(),\n fontSize: '10px !important',\n marginLeft: '8px',\n }}\n />\n }\n sx={{\n cursor: 'help',\n backgroundColor: getChipBackgroundColor(),\n color: getChipColor(),\n border: getChipBorder(),\n fontSize: '0.75rem',\n fontWeight: 600,\n '& .MuiChip-icon': {\n marginLeft: '8px',\n marginRight: '4px',\n },\n }}\n />\n </Tooltip>\n </Box>\n <Typography\n variant=\"caption\"\n style={{\n color: theme.palette.text.primary,\n lineHeight: 1.5,\n fontSize: '0.8rem',\n }}\n >\n <strong>Model:</strong> {displayModel}\n <br />\n <strong>URL:</strong> {displayUrl}\n </Typography>\n {errorMessage && !isLoading && (\n <Box\n style={{\n marginTop: '12px',\n padding: '10px',\n backgroundColor: theme.palette.background.paper,\n borderRadius: '6px',\n border: `1px solid ${theme.palette.error.main}`,\n maxHeight: '80px',\n overflowY: 'auto',\n }}\n >\n <Typography\n variant=\"caption\"\n style={{\n color: theme.palette.text.primary,\n fontSize: '0.75rem',\n lineHeight: 1.4,\n display: 'block',\n wordBreak: 'break-word',\n whiteSpace: 'pre-wrap',\n }}\n >\n <strong>Error:</strong> {errorMessage}\n </Typography>\n </Box>\n )}\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AA+BO,MAAM,iBAAiB,CAAC;AAAA,EAC7B,kBAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAA,KAA2B;AACzB,EAAA,MAAM,QAAQ,QAAA,EAAS;AAEvB,EAAA,MAAM,eAAA,GAAkB,kBAAA,EAAoB,SAAA,GAAY,CAAC,CAAA;AACzD,EAAA,MAAM,iBAAiB,eAAA,EAAiB,UAAA;AACxC,EAAA,MAAM,WAAA,GAAc,gBAAgB,SAAA,IAAa,KAAA;AACjD,EAAA,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AW;AAAA,aACb;AAAA,YAEA,QAAA,kBAAA,IAAA;AAAA,cAAC,UAAA;AAAA,cAAA;AAAA,gBACC,OAAA,EAAQ,SAAA;AAAA,gBACR,KAAA,EAAO;AAAA,kBACL,KAAA,EAAO,KAAA,CAAM,OAAA,CAAQ,IAAA,CAAK,OAAA;AAAA,kBAC1B,QAAA,EAAU,SAAA;AAAA,kBACV,UAAA,EAAY,GAAA;AAAA,kBACZ,OAAA,EAAS,OAAA;AAAA,kBACT,SAAA,EAAW,YAAA;AAAA,kBACX,UAAA,EAAY;AAAA,iBACd;AAAA,gBAEA,QAAA,EAAA;AAAA,kCAAA,GAAA,CAAC,YAAO,QAAA,EAAA,QAAA,EAAM,CAAA;AAAA,kBAAS,GAAA;AAAA,kBAAE;AAAA;AAAA;AAAA;AAC3B;AAAA;AACF;AAAA;AAAA,GAEJ;AAEJ;;;;"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useTheme } from '@mui/material/styles';
|
|
3
|
+
import AddIcon from '@mui/icons-material/Add';
|
|
4
|
+
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
|
|
5
|
+
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
|
|
6
|
+
import MemoryIcon from '@mui/icons-material/Memory';
|
|
7
|
+
import Box from '@mui/material/Box';
|
|
8
|
+
import Button from '@mui/material/Button';
|
|
9
|
+
import IconButton from '@mui/material/IconButton';
|
|
10
|
+
import Typography from '@mui/material/Typography';
|
|
11
|
+
import { ActiveMcpServers } from './ActiveMcpServers.esm.js';
|
|
12
|
+
import { ActiveTools } from './ActiveTools.esm.js';
|
|
13
|
+
import { ProviderStatus } from './ProviderStatus.esm.js';
|
|
14
|
+
import { BotIcon } from '../BotIcon/BotIcon.esm.js';
|
|
15
|
+
import '@backstage/core-plugin-api';
|
|
16
|
+
import 'react-use/esm/useAsyncRetry';
|
|
17
|
+
import '../../api/index.esm.js';
|
|
18
|
+
import 'react';
|
|
19
|
+
import { useAvailableTools } from '../../hooks/useAvailableTools.esm.js';
|
|
20
|
+
|
|
21
|
+
const RightPane = ({
|
|
22
|
+
sidebarCollapsed,
|
|
23
|
+
onToggleSidebar,
|
|
24
|
+
onNewChat,
|
|
25
|
+
mcpServers,
|
|
26
|
+
onServerToggle,
|
|
27
|
+
providerStatus
|
|
28
|
+
}) => {
|
|
29
|
+
const theme = useTheme();
|
|
30
|
+
const { availableTools, isLoading: toolsLoading } = useAvailableTools(mcpServers);
|
|
31
|
+
return /* @__PURE__ */ jsxs(
|
|
32
|
+
Box,
|
|
33
|
+
{
|
|
34
|
+
sx: {
|
|
35
|
+
width: sidebarCollapsed ? 60 : 400,
|
|
36
|
+
backgroundColor: theme.palette.background.paper,
|
|
37
|
+
borderLeft: `1px solid ${theme.palette.divider}`,
|
|
38
|
+
display: "flex",
|
|
39
|
+
flexDirection: "column",
|
|
40
|
+
transition: "width 0.3s ease",
|
|
41
|
+
position: "absolute",
|
|
42
|
+
top: 0,
|
|
43
|
+
right: 0,
|
|
44
|
+
bottom: 0
|
|
45
|
+
},
|
|
46
|
+
children: [
|
|
47
|
+
!sidebarCollapsed && /* @__PURE__ */ jsx(
|
|
48
|
+
IconButton,
|
|
49
|
+
{
|
|
50
|
+
sx: {
|
|
51
|
+
position: "absolute",
|
|
52
|
+
top: theme.spacing(1),
|
|
53
|
+
left: -20,
|
|
54
|
+
backgroundColor: theme.palette.background.paper,
|
|
55
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
56
|
+
borderRadius: "50%",
|
|
57
|
+
width: 40,
|
|
58
|
+
height: 40,
|
|
59
|
+
zIndex: 2,
|
|
60
|
+
color: theme.palette.text.primary,
|
|
61
|
+
"&:hover": {
|
|
62
|
+
backgroundColor: theme.palette.action.hover
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
onClick: onToggleSidebar,
|
|
66
|
+
size: "small",
|
|
67
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, {})
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
/* @__PURE__ */ jsxs(
|
|
71
|
+
Box,
|
|
72
|
+
{
|
|
73
|
+
sx: {
|
|
74
|
+
padding: sidebarCollapsed ? theme.spacing(1) : theme.spacing(2),
|
|
75
|
+
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
76
|
+
display: "flex",
|
|
77
|
+
alignItems: "center",
|
|
78
|
+
justifyContent: "center",
|
|
79
|
+
minHeight: 64
|
|
80
|
+
},
|
|
81
|
+
children: [
|
|
82
|
+
!sidebarCollapsed && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
83
|
+
/* @__PURE__ */ jsx(BotIcon, { size: 25, color: theme.palette.text.primary }),
|
|
84
|
+
/* @__PURE__ */ jsx(
|
|
85
|
+
Typography,
|
|
86
|
+
{
|
|
87
|
+
variant: "h6",
|
|
88
|
+
sx: {
|
|
89
|
+
fontWeight: 600,
|
|
90
|
+
marginLeft: theme.spacing(1),
|
|
91
|
+
color: theme.palette.text.primary
|
|
92
|
+
},
|
|
93
|
+
children: "MCP Chat"
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
] }),
|
|
97
|
+
sidebarCollapsed && /* @__PURE__ */ jsx(
|
|
98
|
+
Box,
|
|
99
|
+
{
|
|
100
|
+
sx: {
|
|
101
|
+
display: "flex",
|
|
102
|
+
justifyContent: "center",
|
|
103
|
+
marginBottom: "8px"
|
|
104
|
+
},
|
|
105
|
+
children: /* @__PURE__ */ jsx(
|
|
106
|
+
IconButton,
|
|
107
|
+
{
|
|
108
|
+
size: "small",
|
|
109
|
+
onClick: onToggleSidebar,
|
|
110
|
+
sx: { color: theme.palette.text.primary },
|
|
111
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, {})
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
!sidebarCollapsed && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
120
|
+
/* @__PURE__ */ jsx(Box, { sx: { padding: "16px 16px 8px" }, children: /* @__PURE__ */ jsx(
|
|
121
|
+
Button,
|
|
122
|
+
{
|
|
123
|
+
variant: "contained",
|
|
124
|
+
startIcon: /* @__PURE__ */ jsx(AddIcon, {}),
|
|
125
|
+
sx: {
|
|
126
|
+
background: theme.palette.primary.main,
|
|
127
|
+
color: theme.palette.primary.contrastText,
|
|
128
|
+
"&:hover": {
|
|
129
|
+
background: theme.palette.primary.dark
|
|
130
|
+
},
|
|
131
|
+
borderRadius: theme.spacing(1),
|
|
132
|
+
textTransform: "none",
|
|
133
|
+
padding: theme.spacing(1, 2),
|
|
134
|
+
fontWeight: 600
|
|
135
|
+
},
|
|
136
|
+
size: "small",
|
|
137
|
+
fullWidth: true,
|
|
138
|
+
onClick: onNewChat,
|
|
139
|
+
children: "New chat"
|
|
140
|
+
}
|
|
141
|
+
) }),
|
|
142
|
+
/* @__PURE__ */ jsx(
|
|
143
|
+
ProviderStatus,
|
|
144
|
+
{
|
|
145
|
+
providerStatusData: providerStatus.providerStatusData,
|
|
146
|
+
isLoading: providerStatus.isLoading,
|
|
147
|
+
error: providerStatus.error
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
/* @__PURE__ */ jsx(
|
|
151
|
+
ActiveTools,
|
|
152
|
+
{
|
|
153
|
+
mcpServers,
|
|
154
|
+
availableTools,
|
|
155
|
+
toolsLoading
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
] }),
|
|
159
|
+
!sidebarCollapsed && /* @__PURE__ */ jsx(
|
|
160
|
+
ActiveMcpServers,
|
|
161
|
+
{
|
|
162
|
+
mcpServers,
|
|
163
|
+
onServerToggle
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
sidebarCollapsed && /* @__PURE__ */ jsxs(
|
|
167
|
+
Box,
|
|
168
|
+
{
|
|
169
|
+
sx: {
|
|
170
|
+
padding: "16px 8px",
|
|
171
|
+
display: "flex",
|
|
172
|
+
flexDirection: "column",
|
|
173
|
+
height: "100%"
|
|
174
|
+
},
|
|
175
|
+
children: [
|
|
176
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
|
|
177
|
+
Box,
|
|
178
|
+
{
|
|
179
|
+
sx: {
|
|
180
|
+
display: "flex",
|
|
181
|
+
justifyContent: "center",
|
|
182
|
+
marginBottom: "16px"
|
|
183
|
+
},
|
|
184
|
+
children: /* @__PURE__ */ jsx(
|
|
185
|
+
IconButton,
|
|
186
|
+
{
|
|
187
|
+
size: "small",
|
|
188
|
+
onClick: onNewChat,
|
|
189
|
+
sx: {
|
|
190
|
+
backgroundColor: theme.palette.primary.main,
|
|
191
|
+
color: theme.palette.primary.contrastText,
|
|
192
|
+
transition: "all 0.2s ease",
|
|
193
|
+
"&:hover": {
|
|
194
|
+
backgroundColor: theme.palette.primary.dark,
|
|
195
|
+
transform: "scale(1.05)"
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
children: /* @__PURE__ */ jsx(AddIcon, {})
|
|
199
|
+
}
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
) }),
|
|
203
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
204
|
+
/* @__PURE__ */ jsx(
|
|
205
|
+
Box,
|
|
206
|
+
{
|
|
207
|
+
sx: {
|
|
208
|
+
borderTop: `2px solid ${theme.palette.divider}`,
|
|
209
|
+
margin: "0 8px 16px 8px"
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
),
|
|
213
|
+
/* @__PURE__ */ jsx(
|
|
214
|
+
Box,
|
|
215
|
+
{
|
|
216
|
+
sx: {
|
|
217
|
+
display: "flex",
|
|
218
|
+
justifyContent: "center"
|
|
219
|
+
},
|
|
220
|
+
children: /* @__PURE__ */ jsx(
|
|
221
|
+
IconButton,
|
|
222
|
+
{
|
|
223
|
+
size: "medium",
|
|
224
|
+
title: "MCP Configuration",
|
|
225
|
+
onClick: onToggleSidebar,
|
|
226
|
+
sx: { color: theme.palette.text.primary },
|
|
227
|
+
children: /* @__PURE__ */ jsx(MemoryIcon, {})
|
|
228
|
+
}
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
)
|
|
232
|
+
] })
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
export { RightPane };
|
|
242
|
+
//# sourceMappingURL=RightPane.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RightPane.esm.js","sources":["../../../src/components/RightPane/RightPane.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { FC } from 'react';\nimport { useTheme } from '@mui/material/styles';\nimport AddIcon from '@mui/icons-material/Add';\nimport ChevronLeftIcon from '@mui/icons-material/ChevronLeft';\nimport ChevronRightIcon from '@mui/icons-material/ChevronRight';\nimport MemoryIcon from '@mui/icons-material/Memory';\nimport Box from '@mui/material/Box';\nimport Button from '@mui/material/Button';\nimport IconButton from '@mui/material/IconButton';\nimport Typography from '@mui/material/Typography';\nimport { ActiveMcpServers } from './ActiveMcpServers';\nimport { ActiveTools } from './ActiveTools';\nimport { ProviderStatus } from './ProviderStatus';\nimport { BotIcon } from '../BotIcon';\nimport { MCPServer } from '../../types';\nimport { UseProviderStatusReturn, useAvailableTools } from '../../hooks';\n\ninterface RightPaneProps {\n sidebarCollapsed: boolean;\n onToggleSidebar: () => void;\n onNewChat: () => void;\n mcpServers: MCPServer[];\n onServerToggle: (serverName: string) => void;\n providerStatus: UseProviderStatusReturn;\n}\n\nexport const RightPane: FC<RightPaneProps> = ({\n sidebarCollapsed,\n onToggleSidebar,\n onNewChat,\n mcpServers,\n onServerToggle,\n providerStatus,\n}: RightPaneProps) => {\n const theme = useTheme();\n const { availableTools, isLoading: toolsLoading } =\n useAvailableTools(mcpServers);\n\n return (\n <Box\n sx={{\n width: sidebarCollapsed ? 60 : 400,\n backgroundColor: theme.palette.background.paper,\n borderLeft: `1px solid ${theme.palette.divider}`,\n display: 'flex',\n flexDirection: 'column',\n transition: 'width 0.3s ease',\n position: 'absolute',\n top: 0,\n right: 0,\n bottom: 0,\n }}\n >\n {!sidebarCollapsed && (\n <IconButton\n sx={{\n position: 'absolute',\n top: theme.spacing(1),\n left: -20,\n backgroundColor: theme.palette.background.paper,\n border: `1px solid ${theme.palette.divider}`,\n borderRadius: '50%',\n width: 40,\n height: 40,\n zIndex: 2,\n color: theme.palette.text.primary,\n '&:hover': {\n backgroundColor: theme.palette.action.hover,\n },\n }}\n onClick={onToggleSidebar}\n size=\"small\"\n >\n <ChevronRightIcon />\n </IconButton>\n )}\n\n <Box\n sx={{\n padding: sidebarCollapsed ? theme.spacing(1) : theme.spacing(2),\n borderBottom: `1px solid ${theme.palette.divider}`,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 64,\n }}\n >\n {!sidebarCollapsed && (\n <>\n <BotIcon size={25} color={theme.palette.text.primary} />\n <Typography\n variant=\"h6\"\n sx={{\n fontWeight: 600,\n marginLeft: theme.spacing(1),\n color: theme.palette.text.primary,\n }}\n >\n MCP Chat\n </Typography>\n </>\n )}\n {sidebarCollapsed && (\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'center',\n marginBottom: '8px',\n }}\n >\n <IconButton\n size=\"small\"\n onClick={onToggleSidebar}\n sx={{ color: theme.palette.text.primary }}\n >\n <ChevronLeftIcon />\n </IconButton>\n </Box>\n )}\n </Box>\n\n {!sidebarCollapsed && (\n <>\n <Box sx={{ padding: '16px 16px 8px' }}>\n <Button\n variant=\"contained\"\n startIcon={<AddIcon />}\n sx={{\n background: theme.palette.primary.main,\n color: theme.palette.primary.contrastText,\n '&:hover': {\n background: theme.palette.primary.dark,\n },\n borderRadius: theme.spacing(1),\n textTransform: 'none',\n padding: theme.spacing(1, 2),\n fontWeight: 600,\n }}\n size=\"small\"\n fullWidth\n onClick={onNewChat}\n >\n New chat\n </Button>\n </Box>\n\n <ProviderStatus\n providerStatusData={providerStatus.providerStatusData}\n isLoading={providerStatus.isLoading}\n error={providerStatus.error}\n />\n\n {/* Active Tools Section - Now taking the main space */}\n <ActiveTools\n mcpServers={mcpServers}\n availableTools={availableTools}\n toolsLoading={toolsLoading}\n />\n </>\n )}\n\n {/* MCP Servers Section - Separate box at the bottom */}\n {!sidebarCollapsed && (\n <ActiveMcpServers\n mcpServers={mcpServers}\n onServerToggle={onServerToggle}\n />\n )}\n\n {sidebarCollapsed && (\n <Box\n sx={{\n padding: '16px 8px',\n display: 'flex',\n flexDirection: 'column',\n height: '100%',\n }}\n >\n {/* Top section - buttons that stay at top */}\n <Box>\n {/* Add button when collapsed */}\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'center',\n marginBottom: '16px',\n }}\n >\n <IconButton\n size=\"small\"\n onClick={onNewChat}\n sx={{\n backgroundColor: theme.palette.primary.main,\n color: theme.palette.primary.contrastText,\n transition: 'all 0.2s ease',\n '&:hover': {\n backgroundColor: theme.palette.primary.dark,\n transform: 'scale(1.05)',\n },\n }}\n >\n <AddIcon />\n </IconButton>\n </Box>\n </Box>\n\n {/* Bottom section - MCP Servers */}\n <Box>\n {/* Separator line */}\n <Box\n sx={{\n borderTop: `2px solid ${theme.palette.divider}`,\n margin: '0 8px 16px 8px',\n }}\n />\n\n {/* MCP Servers Section Icon */}\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'center',\n }}\n >\n <IconButton\n size=\"medium\"\n title=\"MCP Configuration\"\n onClick={onToggleSidebar}\n sx={{ color: theme.palette.text.primary }}\n >\n <MemoryIcon />\n </IconButton>\n </Box>\n </Box>\n </Box>\n )}\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAyCO,MAAM,YAAgC,CAAC;AAAA,EAC5C,gBAAA;AAAA,EACA,eAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAAA,KAAsB;AACpB,EAAA,MAAM,QAAQ,QAAA,EAAS;AACvB,EAAA,MAAM,EAAE,cAAA,EAAgB,SAAA,EAAW,YAAA,EAAa,GAC9C,kBAAkB,UAAU,CAAA;AAE9B,EAAA,uBACE,IAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,EAAA,EAAI;AAAA,QACF,KAAA,EAAO,mBAAmB,EAAA,GAAK,GAAA;AAAA,QAC/B,eAAA,EAAiB,KAAA,CAAM,OAAA,CAAQ,UAAA,CAAW,KAAA;AAAA,QAC1C,UAAA,EAAY,CAAA,UAAA,EAAa,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA,CAAA;AAAA,QAC9C,OAAA,EAAS,MAAA;AAAA,QACT,aAAA,EAAe,QAAA;AAAA,QACf,UAAA,EAAY,iBAAA;AAAA,QACZ,QAAA,EAAU,UAAA;AAAA,QACV,GAAA,EAAK,CAAA;AAAA,QACL,KAAA,EAAO,CAAA;AAAA,QACP,MAAA,EAAQ;AAAA,OACV;AAAA,MAEC,QAAA,EAAA;AAAA,QAAA,CAAC,gBAAA,oBACA,GAAA;AAAA,UAAC,UAAA;AAAA,UAAA;AAAA,YACC,EAAA,EAAI;AAAA,cACF,QAAA,EAAU,UAAA;AAAA,cACV,GAAA,EAAK,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA;AAAA,cACpB,IAAA,EAAM,GAAA;AAAA,cACN,eAAA,EAAiB,KAAA,CAAM,OAAA,CAAQ,UAAA,CAAW,KAAA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A;AAAA,GAEJ;AAEJ;;;;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useApi } from '@backstage/core-plugin-api';
|
|
2
|
+
import useAsyncRetry from 'react-use/esm/useAsyncRetry';
|
|
3
|
+
import { mcpChatApiRef } from '../api/index.esm.js';
|
|
4
|
+
|
|
5
|
+
const useAvailableTools = (mcpServers) => {
|
|
6
|
+
const mcpChatApi = useApi(mcpChatApiRef);
|
|
7
|
+
const {
|
|
8
|
+
value: availableTools,
|
|
9
|
+
loading: isLoading,
|
|
10
|
+
error,
|
|
11
|
+
retry: refetch
|
|
12
|
+
} = useAsyncRetry(async () => {
|
|
13
|
+
if (!mcpServers || mcpServers.length === 0) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
const toolsResponse = await mcpChatApi.getAvailableTools();
|
|
17
|
+
return toolsResponse.availableTools;
|
|
18
|
+
}, [mcpChatApi, mcpServers]);
|
|
19
|
+
const getErrorMessage = () => {
|
|
20
|
+
if (!error) return null;
|
|
21
|
+
if (error instanceof Error) return error.message;
|
|
22
|
+
return "Failed to fetch available tools";
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
availableTools: availableTools || [],
|
|
26
|
+
isLoading,
|
|
27
|
+
error: getErrorMessage(),
|
|
28
|
+
refetch
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useAvailableTools };
|
|
33
|
+
//# sourceMappingURL=useAvailableTools.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAvailableTools.esm.js","sources":["../../src/hooks/useAvailableTools.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useApi } from '@backstage/core-plugin-api';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\nimport { mcpChatApiRef } from '../api';\nimport { MCPServer, Tool } from '../types';\n\nexport interface UseAvailableToolsReturn {\n availableTools: Tool[];\n isLoading: boolean;\n error: string | null;\n refetch: () => void;\n}\n\nexport const useAvailableTools = (\n mcpServers: MCPServer[],\n): UseAvailableToolsReturn => {\n const mcpChatApi = useApi(mcpChatApiRef);\n\n const {\n value: availableTools,\n loading: isLoading,\n error,\n retry: refetch,\n } = useAsyncRetry(async () => {\n // Only fetch tools if there are MCP servers available\n if (!mcpServers || mcpServers.length === 0) {\n return [];\n }\n\n const toolsResponse = await mcpChatApi.getAvailableTools();\n return toolsResponse.availableTools;\n }, [mcpChatApi, mcpServers]);\n\n const getErrorMessage = () => {\n if (!error) return null;\n if (error instanceof Error) return error.message;\n return 'Failed to fetch available tools';\n };\n\n return {\n availableTools: availableTools || [],\n isLoading,\n error: getErrorMessage(),\n refetch,\n };\n};\n"],"names":[],"mappings":";;;;AA2BO,MAAM,iBAAA,GAAoB,CAC/B,UAAA,KAC4B;AAC5B,EAAA,MAAM,UAAA,GAAa,OAAO,aAAa,CAAA;AAEvC,EAAA,MAAM;AAAA,IACJ,KAAA,EAAO,cAAA;AAAA,IACP,OAAA,EAAS,SAAA;AAAA,IACT,KAAA;AAAA,IACA,KAAA,EAAO;AAAA,GACT,GAAI,cAAc,YAAY;AAE5B,IAAA,IAAI,CAAC,UAAA,IAAc,UAAA,CAAW,MAAA,KAAW,CAAA,EAAG;AAC1C,MAAA,OAAO,EAAC;AAAA;AAGV,IAAA,MAAM,aAAA,GAAgB,MAAM,UAAA,CAAW,iBAAA,EAAkB;AACzD,IAAA,OAAO,aAAA,CAAc,cAAA;AAAA,GACvB,EAAG,CAAC,UAAA,EAAY,UAAU,CAAC,CAAA;AAE3B,EAAA,MAAM,kBAAkB,MAAM;AAC5B,IAAA,IAAI,CAAC,OAAO,OAAO,IAAA;AACnB,IAAA,IAAI,KAAA,YAAiB,KAAA,EAAO,OAAO,KAAA,CAAM,OAAA;AACzC,IAAA,OAAO,iCAAA;AAAA,GACT;AAEA,EAAA,OAAO;AAAA,IACL,cAAA,EAAgB,kBAAkB,EAAC;AAAA,IACnC,SAAA;AAAA,IACA,OAAO,eAAA,EAAgB;AAAA,IACvB;AAAA,GACF;AACF;;;;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { useApi } from '@backstage/core-plugin-api';
|
|
3
|
+
import useAsyncRetry from 'react-use/esm/useAsyncRetry';
|
|
4
|
+
import { mcpChatApiRef } from '../api/index.esm.js';
|
|
5
|
+
|
|
6
|
+
const useMcpServers = () => {
|
|
7
|
+
const mcpChatApi = useApi(mcpChatApiRef);
|
|
8
|
+
const [mcpServers, setMcpServers] = useState([]);
|
|
9
|
+
const {
|
|
10
|
+
loading: isLoading,
|
|
11
|
+
error,
|
|
12
|
+
retry: refetch
|
|
13
|
+
} = useAsyncRetry(async () => {
|
|
14
|
+
const mcpServerStatus = await mcpChatApi.getMCPServerStatus();
|
|
15
|
+
const servers = mcpServerStatus.servers?.map((server) => ({
|
|
16
|
+
...server,
|
|
17
|
+
enabled: true
|
|
18
|
+
// Default all servers to enabled
|
|
19
|
+
})) || [];
|
|
20
|
+
setMcpServers(servers);
|
|
21
|
+
return servers;
|
|
22
|
+
}, [mcpChatApi]);
|
|
23
|
+
const handleServerToggle = useCallback((serverId) => {
|
|
24
|
+
setMcpServers(
|
|
25
|
+
(prev) => prev.map(
|
|
26
|
+
(server) => server.id === serverId ? { ...server, enabled: !server.enabled } : server
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
}, []);
|
|
30
|
+
return {
|
|
31
|
+
mcpServers,
|
|
32
|
+
isLoading,
|
|
33
|
+
error: error?.message || null,
|
|
34
|
+
refetch,
|
|
35
|
+
handleServerToggle
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { useMcpServers };
|
|
40
|
+
//# sourceMappingURL=useMcpServers.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMcpServers.esm.js","sources":["../../src/hooks/useMcpServers.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useState, useCallback } from 'react';\nimport { useApi } from '@backstage/core-plugin-api';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\nimport { MCPServer } from '../types';\nimport { mcpChatApiRef } from '../api';\n\nexport interface UseMcpServersReturn {\n mcpServers: MCPServer[];\n isLoading: boolean;\n error: string | null;\n refetch: () => void;\n handleServerToggle: (serverId: string) => void;\n}\n\nexport const useMcpServers = (): UseMcpServersReturn => {\n const mcpChatApi = useApi(mcpChatApiRef);\n const [mcpServers, setMcpServers] = useState<MCPServer[]>([]);\n\n const {\n loading: isLoading,\n error,\n retry: refetch,\n } = useAsyncRetry(async () => {\n const mcpServerStatus = await mcpChatApi.getMCPServerStatus();\n const servers =\n mcpServerStatus.servers?.map((server: MCPServer) => ({\n ...server,\n enabled: true, // Default all servers to enabled\n })) || [];\n setMcpServers(servers);\n return servers;\n }, [mcpChatApi]);\n\n const handleServerToggle = useCallback((serverId: string) => {\n setMcpServers(prev =>\n prev.map(server =>\n server.id === serverId\n ? { ...server, enabled: !server.enabled }\n : server,\n ),\n );\n }, []);\n\n return {\n mcpServers,\n isLoading,\n error: error?.message || null,\n refetch,\n handleServerToggle,\n };\n};\n"],"names":[],"mappings":";;;;;AA6BO,MAAM,gBAAgB,MAA2B;AACtD,EAAA,MAAM,UAAA,GAAa,OAAO,aAAa,CAAA;AACvC,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,QAAA,CAAsB,EAAE,CAAA;AAE5D,EAAA,MAAM;AAAA,IACJ,OAAA,EAAS,SAAA;AAAA,IACT,KAAA;AAAA,IACA,KAAA,EAAO;AAAA,GACT,GAAI,cAAc,YAAY;AAC5B,IAAA,MAAM,eAAA,GAAkB,MAAM,UAAA,CAAW,kBAAA,EAAmB;AAC5D,IAAA,MAAM,OAAA,GACJ,eAAA,CAAgB,OAAA,EAAS,GAAA,CAAI,CAAC,MAAA,MAAuB;AAAA,MACnD,GAAG,MAAA;AAAA,MACH,OAAA,EAAS;AAAA;AAAA,KACX,CAAE,KAAK,EAAC;AACV,IAAA,aAAA,CAAc,OAAO,CAAA;AACrB,IAAA,OAAO,OAAA;AAAA,GACT,EAAG,CAAC,UAAU,CAAC,CAAA;AAEf,EAAA,MAAM,kBAAA,GAAqB,WAAA,CAAY,CAAC,QAAA,KAAqB;AAC3D,IAAA,aAAA;AAAA,MAAc,UACZ,IAAA,CAAK,GAAA;AAAA,QAAI,CAAA,MAAA,KACP,MAAA,CAAO,EAAA,KAAO,QAAA,GACV,EAAE,GAAG,MAAA,EAAQ,OAAA,EAAS,CAAC,MAAA,CAAO,OAAA,EAAQ,GACtC;AAAA;AACN,KACF;AAAA,GACF,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO;AAAA,IACL,UAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA,EAAO,OAAO,OAAA,IAAW,IAAA;AAAA,IACzB,OAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useApi } from '@backstage/core-plugin-api';
|
|
2
|
+
import useAsyncRetry from 'react-use/esm/useAsyncRetry';
|
|
3
|
+
import { mcpChatApiRef } from '../api/index.esm.js';
|
|
4
|
+
|
|
5
|
+
const useProviderStatus = () => {
|
|
6
|
+
const mcpChatApi = useApi(mcpChatApiRef);
|
|
7
|
+
const {
|
|
8
|
+
value: providerStatusData,
|
|
9
|
+
loading: isLoading,
|
|
10
|
+
error,
|
|
11
|
+
retry: refetch
|
|
12
|
+
} = useAsyncRetry(async () => mcpChatApi.getProviderStatus(), [mcpChatApi]);
|
|
13
|
+
return {
|
|
14
|
+
providerStatusData: providerStatusData || null,
|
|
15
|
+
isLoading,
|
|
16
|
+
error: error?.message || null,
|
|
17
|
+
refetch
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { useProviderStatus };
|
|
22
|
+
//# sourceMappingURL=useProviderStatus.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useProviderStatus.esm.js","sources":["../../src/hooks/useProviderStatus.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useApi } from '@backstage/core-plugin-api';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\nimport { ProviderStatusData } from '../types';\nimport { mcpChatApiRef } from '../api';\n\nexport interface UseProviderStatusReturn {\n providerStatusData: ProviderStatusData | null;\n isLoading: boolean;\n error: string | null;\n refetch: () => void;\n}\n\nexport const useProviderStatus = (): UseProviderStatusReturn => {\n const mcpChatApi = useApi(mcpChatApiRef);\n\n const {\n value: providerStatusData,\n loading: isLoading,\n error,\n retry: refetch,\n } = useAsyncRetry(async () => mcpChatApi.getProviderStatus(), [mcpChatApi]);\n\n return {\n providerStatusData: providerStatusData || null,\n isLoading,\n error: error?.message || null,\n refetch,\n };\n};\n"],"names":[],"mappings":";;;;AA2BO,MAAM,oBAAoB,MAA+B;AAC9D,EAAA,MAAM,UAAA,GAAa,OAAO,aAAa,CAAA;AAEvC,EAAA,MAAM;AAAA,IACJ,KAAA,EAAO,kBAAA;AAAA,IACP,OAAA,EAAS,SAAA;AAAA,IACT,KAAA;AAAA,IACA,KAAA,EAAO;AAAA,GACT,GAAI,cAAc,YAAY,UAAA,CAAW,mBAAkB,EAAG,CAAC,UAAU,CAAC,CAAA;AAE1E,EAAA,OAAO;AAAA,IACL,oBAAoB,kBAAA,IAAsB,IAAA;AAAA,IAC1C,SAAA;AAAA,IACA,KAAA,EAAO,OAAO,OAAA,IAAW,IAAA;AAAA,IACzB;AAAA,GACF;AACF;;;;"}
|