@wso2/am-core-ui 0.0.18 → 0.0.20
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/dist/APIKeysManager-C0phJriD.js +241 -0
- package/dist/CatalogKindListing-DvUuZEpc.js +137 -0
- package/dist/CodeBlock-B2Ecl916.js +21736 -0
- package/dist/EnvironmentCard-CIXhDhlZ.js +319 -0
- package/dist/EnvironmentSelector-D8S6nO9u.js +48 -0
- package/dist/IsolationTierIndicator-cf90kgjL.js +81 -0
- package/dist/LabelChips-7rA7_yre.js +139 -0
- package/dist/MCPLogo-D9IJzzl7.js +30 -0
- package/dist/PolicyListSection-D6aVSKwP.js +1143 -0
- package/dist/ResourceListShell-DFisKftq.js +463 -0
- package/dist/SwaggerSpecViewer-DzjR6U6W.js +106 -0
- package/dist/clipboard-YAzStmkw.js +23 -0
- package/dist/debounce-D17ObVdG.js +208 -0
- package/dist/format-wlHhWjGo.js +29 -0
- package/dist/formatDistanceToNow-DyjnT7l9.js +100 -0
- package/dist/gatewayScripts-D4ZDEDPS.js +72 -0
- package/dist/highlight-BsUzxSR3.js +454 -0
- package/dist/{index-CnXsN5I3.js → index-3K-zqdp-.js} +34 -33
- package/dist/index-6liAPSDn.js +1564 -0
- package/dist/index-B3ASENUJ.js +1290 -0
- package/dist/index-B7Pf4oPq.js +3069 -0
- package/dist/index-BNO3FhZK.js +2304 -0
- package/dist/index-BUZSfCl5.js +335 -0
- package/dist/index-BXiG1r_o.js +1409 -0
- package/dist/index-BYy7Iaam.js +459 -0
- package/dist/index-BbB_yx4V.js +1397 -0
- package/dist/index-BjWJ95lH.js +2728 -0
- package/dist/index-ByEInFlf.js +26408 -0
- package/dist/index-C8WIhzyz.js +123 -0
- package/dist/index-CnzvaT6b.js +2368 -0
- package/dist/index-CrnCf-hJ.js +763 -0
- package/dist/index-Cvsho9xg.js +2346 -0
- package/dist/index-CxnAo1_c.js +119 -0
- package/dist/{index-DYV1jEai.js → index-Cz7-AZwE.js} +22 -20
- package/dist/index-DBdRFjxm.js +1264 -0
- package/dist/index-DFsSvmMZ.js +7981 -0
- package/dist/index-DslzOSGN.js +2549 -0
- package/dist/index-DvpYvchM.js +2341 -0
- package/dist/index-PWsNvJB-.js +546 -0
- package/dist/index.d.ts +1398 -481
- package/dist/index.js +539 -438
- package/dist/js-yaml-CvhD-clg.js +1335 -0
- package/dist/llmProviderPayload-BPzWDy7n.js +332 -0
- package/dist/schemas-DFScWdSL.js +2969 -0
- package/package.json +1 -1
- package/dist/index-B47EJCom.js +0 -236
- package/dist/index-Bl1Y7Sro.js +0 -3037
- package/dist/index-DlS9Lybj.js +0 -80691
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
import { jsx as t, jsxs as k, Fragment as ge } from "react/jsx-runtime";
|
|
2
|
+
import { c as se } from "react/compiler-runtime";
|
|
3
|
+
import { useState as $, useMemo as Q, useRef as pe, useEffect as oe, lazy as we, Suspense as be } from "react";
|
|
4
|
+
import { Typography as H, Box as b, CardContent as xe, Stack as ve, Card as Ie, Alert as N, Button as q, TextField as le, CircularProgress as re, Skeleton as J } from "@wso2/oxygen-ui";
|
|
5
|
+
import { MessageCircle as Te, Send as ce, Rocket as Ae, FlaskConical as Se } from "@wso2/oxygen-ui-icons-react";
|
|
6
|
+
import { o as Z, aM as ke, aN as fe, aO as me, O as de, M as Ce, c as Ne, P as he, N as Ee } from "./index-ByEInFlf.js";
|
|
7
|
+
import "@tanstack/react-query";
|
|
8
|
+
import { useParams as ee } from "react-router-dom";
|
|
9
|
+
import { E as ue } from "./EnvironmentSelector-D8S6nO9u.js";
|
|
10
|
+
function Ke(n) {
|
|
11
|
+
const e = se(47), {
|
|
12
|
+
role: r,
|
|
13
|
+
content: s
|
|
14
|
+
} = n, {
|
|
15
|
+
orgId: l,
|
|
16
|
+
projectId: x,
|
|
17
|
+
agentId: v
|
|
18
|
+
} = ee();
|
|
19
|
+
let C;
|
|
20
|
+
e[0] !== v || e[1] !== l || e[2] !== x ? (C = {
|
|
21
|
+
orgName: l,
|
|
22
|
+
projName: x,
|
|
23
|
+
agentName: v
|
|
24
|
+
}, e[0] = v, e[1] = l, e[2] = x, e[3] = C) : C = e[3];
|
|
25
|
+
const {
|
|
26
|
+
data: a
|
|
27
|
+
} = Z(C), i = r === "user" ? "flex-end" : "flex-start";
|
|
28
|
+
let E;
|
|
29
|
+
e[4] === Symbol.for("react.memo_cache_sentinel") ? (E = {
|
|
30
|
+
mb: 0.5
|
|
31
|
+
}, e[4] = E) : E = e[4];
|
|
32
|
+
const B = r === "user" ? "row-reverse" : "row", P = r !== "user" ? 0 : 16, g = r === "user" ? 0 : 16, p = r === "user" ? "primary.main" : "background.paper";
|
|
33
|
+
let o;
|
|
34
|
+
e[5] !== p ? (o = {
|
|
35
|
+
minWidth: 300,
|
|
36
|
+
backgroundColor: p
|
|
37
|
+
}, e[5] = p, e[6] = o) : o = e[6];
|
|
38
|
+
let f;
|
|
39
|
+
e[7] !== P || e[8] !== g || e[9] !== o ? (f = {
|
|
40
|
+
borderBottomLeftRadius: P,
|
|
41
|
+
borderBottomRightRadius: g,
|
|
42
|
+
"& .MuiCardContent-root": o
|
|
43
|
+
}, e[7] = P, e[8] = g, e[9] = o, e[10] = f) : f = e[10];
|
|
44
|
+
let c;
|
|
45
|
+
e[11] !== a?.displayName || e[12] !== r ? (c = r !== "user" && /* @__PURE__ */ t(H, { variant: "caption", children: a?.displayName }), e[11] = a?.displayName, e[12] = r, e[13] = c) : c = e[13];
|
|
46
|
+
let u;
|
|
47
|
+
e[14] !== r ? (u = r === "user" && /* @__PURE__ */ t(H, { variant: "caption", color: "primary.contrastText", children: "You" }), e[14] = r, e[15] = u) : u = e[15];
|
|
48
|
+
const D = r === "user" ? "primary.contrastText" : "text.primary";
|
|
49
|
+
let I;
|
|
50
|
+
e[16] !== D ? (I = {
|
|
51
|
+
color: D
|
|
52
|
+
}, e[16] = D, e[17] = I) : I = e[17];
|
|
53
|
+
const R = r === "user" ? "primary.contrastText" : "text.secondary";
|
|
54
|
+
let j;
|
|
55
|
+
e[18] !== R ? (j = {
|
|
56
|
+
color: R
|
|
57
|
+
}, e[18] = R, e[19] = j) : j = e[19];
|
|
58
|
+
const _ = r === "user" ? "rgba(255, 255, 255, 0.2)" : "action.hover";
|
|
59
|
+
let d;
|
|
60
|
+
e[20] !== _ ? (d = {
|
|
61
|
+
backgroundColor: _
|
|
62
|
+
}, e[20] = _, e[21] = d) : d = e[21];
|
|
63
|
+
const T = r === "user" ? "rgba(255, 255, 255, 0.2)" : "action.hover";
|
|
64
|
+
let w;
|
|
65
|
+
e[22] !== T ? (w = {
|
|
66
|
+
backgroundColor: T
|
|
67
|
+
}, e[22] = T, e[23] = w) : w = e[23];
|
|
68
|
+
let y;
|
|
69
|
+
e[24] !== I || e[25] !== j || e[26] !== d || e[27] !== w ? (y = {
|
|
70
|
+
"& .MuiTypography-root": I,
|
|
71
|
+
"& p": j,
|
|
72
|
+
"& code": d,
|
|
73
|
+
"& pre": w
|
|
74
|
+
}, e[24] = I, e[25] = j, e[26] = d, e[27] = w, e[28] = y) : y = e[28];
|
|
75
|
+
let L;
|
|
76
|
+
e[29] !== s ? (L = /* @__PURE__ */ t(ke, { content: s }), e[29] = s, e[30] = L) : L = e[30];
|
|
77
|
+
let M;
|
|
78
|
+
e[31] !== y || e[32] !== L ? (M = /* @__PURE__ */ t(b, { sx: y, children: L }), e[31] = y, e[32] = L, e[33] = M) : M = e[33];
|
|
79
|
+
let K;
|
|
80
|
+
e[34] !== c || e[35] !== u || e[36] !== M ? (K = /* @__PURE__ */ t(xe, { children: /* @__PURE__ */ k(ve, { spacing: 1, children: [
|
|
81
|
+
c,
|
|
82
|
+
u,
|
|
83
|
+
M
|
|
84
|
+
] }) }), e[34] = c, e[35] = u, e[36] = M, e[37] = K) : K = e[37];
|
|
85
|
+
let A;
|
|
86
|
+
e[38] !== K || e[39] !== f ? (A = /* @__PURE__ */ t(Ie, { variant: "outlined", sx: f, children: K }), e[38] = K, e[39] = f, e[40] = A) : A = e[40];
|
|
87
|
+
let S;
|
|
88
|
+
e[41] !== A || e[42] !== B ? (S = /* @__PURE__ */ t(b, { display: "flex", gap: 1.5, maxWidth: 500, flexDirection: B, alignItems: "flex-start", children: A }), e[41] = A, e[42] = B, e[43] = S) : S = e[43];
|
|
89
|
+
let O;
|
|
90
|
+
return e[44] !== i || e[45] !== S ? (O = /* @__PURE__ */ t(b, { display: "flex", justifyContent: i, width: "100%", sx: E, children: S }), e[44] = i, e[45] = S, e[46] = O) : O = e[46], O;
|
|
91
|
+
}
|
|
92
|
+
const Re = 2e3;
|
|
93
|
+
function je() {
|
|
94
|
+
const [n, e] = $(""), [r, s] = $(""), l = Q(() => ({
|
|
95
|
+
session_id: `session-${Math.floor(Math.random() * 1e3)}`,
|
|
96
|
+
message: "Hi, How can you help me?",
|
|
97
|
+
context: {}
|
|
98
|
+
}), []), [x, v] = $([]), [C, a] = $(null), [i, E] = $(!1), [B, P] = $(!1), [g, p] = $(null), [o, f] = $(!1), c = pe(null), {
|
|
99
|
+
agentId: u,
|
|
100
|
+
orgId: D,
|
|
101
|
+
projectId: I,
|
|
102
|
+
envId: R
|
|
103
|
+
} = ee(), {
|
|
104
|
+
data: j,
|
|
105
|
+
isLoading: _
|
|
106
|
+
} = fe({
|
|
107
|
+
projName: I,
|
|
108
|
+
orgName: D,
|
|
109
|
+
agentName: u
|
|
110
|
+
}, {
|
|
111
|
+
environment: R ?? ""
|
|
112
|
+
}), {
|
|
113
|
+
data: d
|
|
114
|
+
} = Z({
|
|
115
|
+
orgName: D,
|
|
116
|
+
projName: I,
|
|
117
|
+
agentName: u
|
|
118
|
+
}), T = d?.configurations?.enableApiKeySecurity ?? !0, w = !!(d?.configurations?.enableOAuthSecurity && !d?.configurations?.enableApiKeySecurity), {
|
|
119
|
+
data: y,
|
|
120
|
+
isLoading: L,
|
|
121
|
+
error: M,
|
|
122
|
+
refetch: K
|
|
123
|
+
} = me({
|
|
124
|
+
orgName: D,
|
|
125
|
+
projName: I,
|
|
126
|
+
agentName: u,
|
|
127
|
+
envId: R
|
|
128
|
+
}, {
|
|
129
|
+
enabled: T && !w
|
|
130
|
+
}), A = Q(() => Object.entries(j ?? {}).map(([h, Y]) => ({
|
|
131
|
+
label: h,
|
|
132
|
+
value: Y.url
|
|
133
|
+
})), [j]);
|
|
134
|
+
oe(() => {
|
|
135
|
+
A.length > 0 && e(A[0].value + "/chat");
|
|
136
|
+
}, [A]), oe(() => {
|
|
137
|
+
c.current?.scrollIntoView({
|
|
138
|
+
behavior: "smooth"
|
|
139
|
+
});
|
|
140
|
+
}, [x]);
|
|
141
|
+
const S = async () => {
|
|
142
|
+
if (!r.trim() || i || w) return;
|
|
143
|
+
if (T && !y?.apiKey) {
|
|
144
|
+
a("API key security is enabled, but a test API key is not available yet.");
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const h = {
|
|
148
|
+
id: Date.now().toString(),
|
|
149
|
+
role: "user",
|
|
150
|
+
content: r.trim(),
|
|
151
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
152
|
+
};
|
|
153
|
+
v((Y) => [...Y, h]), s(""), a(null), p(null), E(!0);
|
|
154
|
+
try {
|
|
155
|
+
const Y = {
|
|
156
|
+
...l,
|
|
157
|
+
message: h.content
|
|
158
|
+
}, V = (m) => {
|
|
159
|
+
const G = {
|
|
160
|
+
"Content-Type": "application/json"
|
|
161
|
+
};
|
|
162
|
+
return T && m && (G["X-API-Key"] = m), fetch(n, {
|
|
163
|
+
method: "POST",
|
|
164
|
+
headers: G,
|
|
165
|
+
body: JSON.stringify(Y),
|
|
166
|
+
referrerPolicy: ""
|
|
167
|
+
});
|
|
168
|
+
}, X = async () => {
|
|
169
|
+
try {
|
|
170
|
+
const m = await V(y?.apiKey);
|
|
171
|
+
return T && m.status === 401 ? null : m;
|
|
172
|
+
} catch (m) {
|
|
173
|
+
if (T && m instanceof TypeError)
|
|
174
|
+
return null;
|
|
175
|
+
throw m;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
let z = await X();
|
|
179
|
+
if (z === null) {
|
|
180
|
+
P(!0);
|
|
181
|
+
try {
|
|
182
|
+
await new Promise((m) => setTimeout(m, Re)), z = await X();
|
|
183
|
+
} finally {
|
|
184
|
+
P(!1);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (z === null) {
|
|
188
|
+
v((m) => m.filter((G) => G.id !== h.id)), s(h.content), y?.gatewayConnected !== !1 && p("unauthorized");
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
let W;
|
|
192
|
+
const ie = z.headers.get("content-type");
|
|
193
|
+
if (ie && ie.includes("application/json") ? W = await z.json() : W = await z.text(), z.ok) {
|
|
194
|
+
const m = typeof W?.response == "string" ? W.response : JSON.stringify(W?.result, null, 4), G = {
|
|
195
|
+
id: (Date.now() + 1).toString(),
|
|
196
|
+
role: "assistant",
|
|
197
|
+
content: m,
|
|
198
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
199
|
+
};
|
|
200
|
+
v((ne) => [...ne, G]);
|
|
201
|
+
} else {
|
|
202
|
+
const m = typeof W == "string" ? W : JSON.stringify(W, null, 2);
|
|
203
|
+
a(`Request failed with status ${z.status}: ${m}`);
|
|
204
|
+
const G = {
|
|
205
|
+
id: (Date.now() + 1).toString(),
|
|
206
|
+
role: "assistant",
|
|
207
|
+
content: `Error: ${m}`,
|
|
208
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
209
|
+
};
|
|
210
|
+
v((ne) => [...ne, G]);
|
|
211
|
+
}
|
|
212
|
+
} catch (Y) {
|
|
213
|
+
const V = Y instanceof Error ? Y.message : "An error occurred while making the request";
|
|
214
|
+
a(V);
|
|
215
|
+
const X = {
|
|
216
|
+
id: (Date.now() + 1).toString(),
|
|
217
|
+
role: "assistant",
|
|
218
|
+
content: `Error: ${V}`,
|
|
219
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
220
|
+
};
|
|
221
|
+
v((z) => [...z, X]);
|
|
222
|
+
} finally {
|
|
223
|
+
E(!1);
|
|
224
|
+
}
|
|
225
|
+
}, O = (h) => {
|
|
226
|
+
h.key === "Enter" && !h.shiftKey && (h.preventDefault(), S());
|
|
227
|
+
}, F = async () => {
|
|
228
|
+
f(!0);
|
|
229
|
+
try {
|
|
230
|
+
await K(), p("refreshed");
|
|
231
|
+
} finally {
|
|
232
|
+
f(!1);
|
|
233
|
+
}
|
|
234
|
+
}, U = /* @__PURE__ */ k(ge, { children: [
|
|
235
|
+
T && y?.gatewayConnected === !1 && /* @__PURE__ */ t(N, { severity: "warning", sx: {
|
|
236
|
+
borderRadius: 1
|
|
237
|
+
}, children: "The gateway is not connected to the control plane right now. The test API key has been stored but will only work once the gateway reconnects." }),
|
|
238
|
+
g === "unauthorized" && /* @__PURE__ */ t(N, { severity: "error", action: /* @__PURE__ */ t(q, { color: "inherit", size: "small", onClick: F, disabled: o, children: o ? "Refreshing..." : "Refresh test key" }), sx: {
|
|
239
|
+
borderRadius: 1
|
|
240
|
+
}, children: "The request was not authorized. The test API key may not be active on the gateway yet." }),
|
|
241
|
+
g === "refreshed" && /* @__PURE__ */ t(N, { severity: "info", onClose: () => p(null), sx: {
|
|
242
|
+
borderRadius: 1
|
|
243
|
+
}, children: "Test key refreshed. Send your message again." })
|
|
244
|
+
] }), te = w || i || _ || L || T && !y?.apiKey, ae = te || !r.trim();
|
|
245
|
+
return w ? /* @__PURE__ */ t(N, { severity: "info", children: /* @__PURE__ */ t(H, { variant: "caption", children: "Testing is unavailable while OAuth is enabled. Test this endpoint out-of-band with a valid token." }) }) : x.length === 0 ? /* @__PURE__ */ t(de, { children: /* @__PURE__ */ k(b, { display: "flex", justifyContent: "center", alignItems: "center", width: "100%", flexDirection: "column", minHeight: "calc(100vh - 550px)", gap: 2, children: [
|
|
246
|
+
/* @__PURE__ */ k(b, { display: "flex", flexDirection: "column", gap: 1, alignItems: "center", children: [
|
|
247
|
+
/* @__PURE__ */ t(Te, { size: 40 }),
|
|
248
|
+
/* @__PURE__ */ t(H, { variant: "h5", children: "Start a conversation" }),
|
|
249
|
+
/* @__PURE__ */ t(H, { variant: "body2", children: "Send a message to begin chatting with the agent" })
|
|
250
|
+
] }),
|
|
251
|
+
/* @__PURE__ */ k(b, { width: "100%", maxWidth: 600, display: "flex", flexDirection: "column", gap: 1, children: [
|
|
252
|
+
U,
|
|
253
|
+
/* @__PURE__ */ k(b, { width: "100%", display: "flex", justifyContent: "flex-end", alignItems: "center", gap: 1, children: [
|
|
254
|
+
/* @__PURE__ */ t(le, { fullWidth: !0, value: r, onChange: (h) => s(h.target.value), onKeyDown: O, placeholder: "Type your message...", variant: "outlined", disabled: te }),
|
|
255
|
+
/* @__PURE__ */ t(q, { variant: "contained", color: "primary", onClick: S, disabled: ae, startIcon: i || _ ? /* @__PURE__ */ t(re, { size: 16 }) : /* @__PURE__ */ t(ce, { size: 16 }), children: i ? "Sending" : "Send" })
|
|
256
|
+
] })
|
|
257
|
+
] })
|
|
258
|
+
] }) }) : /* @__PURE__ */ t(de, { children: /* @__PURE__ */ k(b, { display: "flex", flexDirection: "column", height: "calc(100vh - 320px)", width: "100%", children: [
|
|
259
|
+
/* @__PURE__ */ k(b, { flex: 1, display: "flex", flexDirection: "column", justifyContent: "flex-end", gap: 2, p: 2, sx: {
|
|
260
|
+
flexGrow: 1
|
|
261
|
+
}, children: [
|
|
262
|
+
x.map((h) => /* @__PURE__ */ t(Ke, { id: h.id, role: h.role, content: h.content }, h.id)),
|
|
263
|
+
i && /* @__PURE__ */ t(b, { display: "flex", justifyContent: "flex-start", width: "100%", children: /* @__PURE__ */ k(b, { display: "flex", gap: 1, alignItems: "flex-start", children: [
|
|
264
|
+
/* @__PURE__ */ t(re, { size: 16 }),
|
|
265
|
+
/* @__PURE__ */ t(H, { variant: "body2", color: "text.secondary", sx: {
|
|
266
|
+
fontSize: "0.875rem"
|
|
267
|
+
}, children: B ? "Waiting for the test API key to become active..." : "Loading..." })
|
|
268
|
+
] }) }),
|
|
269
|
+
/* @__PURE__ */ t("div", { ref: c })
|
|
270
|
+
] }),
|
|
271
|
+
U,
|
|
272
|
+
C && /* @__PURE__ */ t(N, { severity: "error", onClose: () => a(null), sx: {
|
|
273
|
+
borderRadius: 1
|
|
274
|
+
}, children: C }),
|
|
275
|
+
!!M && /* @__PURE__ */ t(N, { severity: "error", sx: {
|
|
276
|
+
borderRadius: 1
|
|
277
|
+
}, children: "Failed to obtain a test API key. Send may fail until this is resolved." }),
|
|
278
|
+
/* @__PURE__ */ k(b, { display: "flex", justifyContent: "flex-end", alignItems: "center", gap: 1, py: 2, children: [
|
|
279
|
+
/* @__PURE__ */ t(le, { fullWidth: !0, value: r, onChange: (h) => s(h.target.value), onKeyDown: O, placeholder: "Type your message...", variant: "outlined", size: "small", disabled: te }),
|
|
280
|
+
/* @__PURE__ */ t(q, { variant: "contained", color: "primary", onClick: S, disabled: ae, startIcon: i || _ ? /* @__PURE__ */ t(re, { size: 16 }) : /* @__PURE__ */ t(ce, { size: 16 }), children: i || _ ? "Sending" : "Send" })
|
|
281
|
+
] })
|
|
282
|
+
] }) });
|
|
283
|
+
}
|
|
284
|
+
const Pe = we(() => import("./index-Cz7-AZwE.js")), De = 2e3, _e = {
|
|
285
|
+
statePlugins: {
|
|
286
|
+
spec: {
|
|
287
|
+
wrapSelectors: {
|
|
288
|
+
servers: () => () => [],
|
|
289
|
+
schemes: () => () => []
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
wrapComponents: {
|
|
294
|
+
info: () => () => null
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
function Le() {
|
|
298
|
+
const {
|
|
299
|
+
orgId: n,
|
|
300
|
+
projectId: e,
|
|
301
|
+
agentId: r,
|
|
302
|
+
envId: s
|
|
303
|
+
} = ee(), {
|
|
304
|
+
data: l,
|
|
305
|
+
isLoading: x,
|
|
306
|
+
error: v
|
|
307
|
+
} = fe({
|
|
308
|
+
agentName: r,
|
|
309
|
+
orgName: n,
|
|
310
|
+
projName: e
|
|
311
|
+
}, {
|
|
312
|
+
environment: s ?? ""
|
|
313
|
+
}), {
|
|
314
|
+
data: C
|
|
315
|
+
} = Z({
|
|
316
|
+
orgName: n,
|
|
317
|
+
projName: e,
|
|
318
|
+
agentName: r
|
|
319
|
+
}), a = !!C?.configurations?.enableApiKeySecurity, i = !!(C?.configurations?.enableOAuthSecurity && !C?.configurations?.enableApiKeySecurity), {
|
|
320
|
+
data: E,
|
|
321
|
+
isLoading: B,
|
|
322
|
+
isError: P,
|
|
323
|
+
error: g,
|
|
324
|
+
refetch: p
|
|
325
|
+
} = me({
|
|
326
|
+
orgName: n,
|
|
327
|
+
projName: e,
|
|
328
|
+
agentName: r,
|
|
329
|
+
envId: s
|
|
330
|
+
}, {
|
|
331
|
+
enabled: a && !i
|
|
332
|
+
}), o = E?.apiKey, [f, c] = $(null), [u, D] = $(!1), I = E?.gatewayConnected === !1, R = Q(() => Object.keys(l ?? {})?.[0] ?? "", [l]), j = Q(() => (d) => {
|
|
333
|
+
const T = l?.[R]?.url;
|
|
334
|
+
if (!T)
|
|
335
|
+
return d;
|
|
336
|
+
const w = new URL(d.url, window.location.origin), y = new URL(T), L = y.pathname.replace(/\/+$/, ""), M = w.pathname.replace(/^\/+/, ""), K = [L, M].filter(Boolean).join("/");
|
|
337
|
+
return y.pathname = K.startsWith("/") ? K : `/${K}`, y.search = w.search, y.hash = w.hash, d.url = y.toString(), a && o && (d.headers = d.headers ?? {}, d.headers["X-API-Key"] = o), a && !I && (d.userFetch = async (A, S) => {
|
|
338
|
+
const O = () => new Promise((F) => setTimeout(F, De));
|
|
339
|
+
try {
|
|
340
|
+
const F = await fetch(A, S);
|
|
341
|
+
if (F.status !== 401)
|
|
342
|
+
return F;
|
|
343
|
+
await O();
|
|
344
|
+
const U = await fetch(A, S);
|
|
345
|
+
return U.status === 401 && c("unauthorized"), U;
|
|
346
|
+
} catch (F) {
|
|
347
|
+
if (!(F instanceof TypeError))
|
|
348
|
+
throw F;
|
|
349
|
+
await O();
|
|
350
|
+
try {
|
|
351
|
+
return await fetch(A, S);
|
|
352
|
+
} catch (U) {
|
|
353
|
+
throw c("unauthorized"), U;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}), d;
|
|
357
|
+
}, [l, R, a, o, I]), _ = async () => {
|
|
358
|
+
D(!0);
|
|
359
|
+
try {
|
|
360
|
+
await p(), c("refreshed");
|
|
361
|
+
} finally {
|
|
362
|
+
D(!1);
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
return x || a && B ? /* @__PURE__ */ t(J, { variant: "rounded", height: 500 }) : v ? /* @__PURE__ */ t(N, { severity: "error", children: Ce(v) }) : a && P ? /* @__PURE__ */ k(N, { severity: "error", children: [
|
|
366
|
+
"Failed to fetch test API key",
|
|
367
|
+
g instanceof Error ? `: ${g.message}` : "",
|
|
368
|
+
"."
|
|
369
|
+
] }) : l?.[R]?.schema?.content ? /* @__PURE__ */ k(be, { fallback: /* @__PURE__ */ t(J, { variant: "rounded", height: 500 }), children: [
|
|
370
|
+
i && /* @__PURE__ */ t(N, { severity: "info", sx: {
|
|
371
|
+
mb: 2
|
|
372
|
+
}, children: /* @__PURE__ */ k(H, { variant: "caption", children: [
|
|
373
|
+
"OAuth is enabled — test this endpoint out-of-band with an",
|
|
374
|
+
" ",
|
|
375
|
+
/* @__PURE__ */ t("code", { children: "Authorization: Bearer <token>" }),
|
|
376
|
+
" header."
|
|
377
|
+
] }) }),
|
|
378
|
+
a && I && /* @__PURE__ */ t(N, { severity: "warning", sx: {
|
|
379
|
+
mb: 2
|
|
380
|
+
}, children: "The gateway is not connected to the control plane right now. The test API key has been stored but will only work once the gateway reconnects." }),
|
|
381
|
+
f === "unauthorized" && /* @__PURE__ */ t(N, { severity: "error", action: /* @__PURE__ */ t(q, { color: "inherit", size: "small", onClick: _, disabled: u, children: u ? "Refreshing..." : "Refresh test key" }), sx: {
|
|
382
|
+
mb: 2
|
|
383
|
+
}, children: "The test API key is not authorized on the gateway yet. Execute the request again, or refresh the test key." }),
|
|
384
|
+
f === "refreshed" && /* @__PURE__ */ t(N, { severity: "info", onClose: () => c(null), sx: {
|
|
385
|
+
mb: 2
|
|
386
|
+
}, children: "Test key refreshed. Execute the request again." }),
|
|
387
|
+
/* @__PURE__ */ t(b, { sx: {
|
|
388
|
+
"& .swagger-ui .wrapper": {
|
|
389
|
+
padding: 0
|
|
390
|
+
}
|
|
391
|
+
}, children: /* @__PURE__ */ t(Pe, { spec: l?.[R].schema.content, layout: "BaseLayout", plugins: [_e], docExpansion: "list", requestInterceptor: j, supportedSubmitMethods: i ? [] : void 0 }) })
|
|
392
|
+
] }) : /* @__PURE__ */ t(N, { severity: "warning", children: "No API schema available for this endpoint." });
|
|
393
|
+
}
|
|
394
|
+
const Me = () => {
|
|
395
|
+
const n = se(4);
|
|
396
|
+
let e, r, s;
|
|
397
|
+
n[0] === Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ t(J, { variant: "circular", width: 80, height: 80 }), r = /* @__PURE__ */ t(J, { variant: "text", width: 250, height: 32 }), s = /* @__PURE__ */ t(J, { variant: "text", width: 350, height: 20 }), n[0] = e, n[1] = r, n[2] = s) : (e = n[0], r = n[1], s = n[2]);
|
|
398
|
+
let l;
|
|
399
|
+
return n[3] === Symbol.for("react.memo_cache_sentinel") ? (l = /* @__PURE__ */ k(b, { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", gap: 2, height: "60vh", children: [
|
|
400
|
+
e,
|
|
401
|
+
r,
|
|
402
|
+
s,
|
|
403
|
+
/* @__PURE__ */ t(J, { variant: "rounded", width: 500, height: 48, sx: {
|
|
404
|
+
mt: 2
|
|
405
|
+
} })
|
|
406
|
+
] }), n[3] = l) : l = n[3], l;
|
|
407
|
+
}, ye = () => {
|
|
408
|
+
const n = se(18), {
|
|
409
|
+
orgId: e,
|
|
410
|
+
projectId: r,
|
|
411
|
+
agentId: s,
|
|
412
|
+
envId: l
|
|
413
|
+
} = ee();
|
|
414
|
+
let x;
|
|
415
|
+
n[0] !== s || n[1] !== e || n[2] !== r ? (x = {
|
|
416
|
+
orgName: e,
|
|
417
|
+
projName: r,
|
|
418
|
+
agentName: s
|
|
419
|
+
}, n[0] = s, n[1] = e, n[2] = r, n[3] = x) : x = n[3];
|
|
420
|
+
const {
|
|
421
|
+
data: v,
|
|
422
|
+
isLoading: C
|
|
423
|
+
} = Z(x), a = v?.agentType?.subType === "chat-api";
|
|
424
|
+
let i;
|
|
425
|
+
n[4] !== s || n[5] !== e || n[6] !== r ? (i = {
|
|
426
|
+
orgName: e,
|
|
427
|
+
projName: r,
|
|
428
|
+
agentName: s
|
|
429
|
+
}, n[4] = s, n[5] = e, n[6] = r, n[7] = i) : i = n[7];
|
|
430
|
+
const {
|
|
431
|
+
data: E,
|
|
432
|
+
isLoading: B
|
|
433
|
+
} = Ne(i), P = E?.[l ?? ""], g = B || C;
|
|
434
|
+
if (!g && P?.status !== "active") {
|
|
435
|
+
let c;
|
|
436
|
+
n[8] === Symbol.for("react.memo_cache_sentinel") ? (c = /* @__PURE__ */ t(ue, {}), n[8] = c) : c = n[8];
|
|
437
|
+
let u;
|
|
438
|
+
return n[9] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ t(he, { title: "Try your agent", disableIcon: !0, actions: c, children: /* @__PURE__ */ t(b, { height: "50vh", display: "flex", justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ t(Ee, { iconElement: Ae, disableBackground: !0, message: "Agent is not deployed", subtitle: "Deploy your agent to try it out. You can deploy your agent by clicking the deploy button in the deploy tab." }) }) }), n[9] = u) : u = n[9], u;
|
|
439
|
+
}
|
|
440
|
+
let p;
|
|
441
|
+
n[10] === Symbol.for("react.memo_cache_sentinel") ? (p = /* @__PURE__ */ t(ue, {}), n[10] = p) : p = n[10];
|
|
442
|
+
let o;
|
|
443
|
+
n[11] !== s || n[12] !== a || n[13] !== g ? (o = g ? /* @__PURE__ */ t(Me, {}) : /* @__PURE__ */ t(ge, { children: a ? /* @__PURE__ */ t(je, {}, s) : /* @__PURE__ */ t(Le, {}, s) }), n[11] = s, n[12] = a, n[13] = g, n[14] = o) : o = n[14];
|
|
444
|
+
let f;
|
|
445
|
+
return n[15] !== g || n[16] !== o ? (f = /* @__PURE__ */ t(he, { title: "Try your agent", disableIcon: !0, isLoading: g, actions: p, children: o }), n[15] = g, n[16] = o, n[17] = f) : f = n[17], f;
|
|
446
|
+
}, He = {
|
|
447
|
+
title: "Try It",
|
|
448
|
+
description: "A page component for Try It",
|
|
449
|
+
icon: Se,
|
|
450
|
+
path: "/test",
|
|
451
|
+
component: ye,
|
|
452
|
+
levels: {
|
|
453
|
+
component: ye
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
export {
|
|
457
|
+
ye as TestComponent,
|
|
458
|
+
He as metaData
|
|
459
|
+
};
|