@wso2/am-core-ui 0.0.17 → 0.0.19
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-DtFI2YMG.js +118 -0
- package/dist/CodeBlock-mB_Loq7I.js +21736 -0
- package/dist/EnvironmentCard-09h1XRxx.js +310 -0
- package/dist/EnvironmentSelector-B7Bl93s2.js +48 -0
- package/dist/MCPLogo-D9IJzzl7.js +30 -0
- package/dist/PolicyListSection-o4k9e8XO.js +2475 -0
- package/dist/ResourceListShell-Cx6mdeqv.js +463 -0
- package/dist/SwaggerSpecViewer-BvkhoKsi.js +106 -0
- package/dist/clipboard-YAzStmkw.js +23 -0
- package/dist/debounce-BV83M53b.js +208 -0
- package/dist/format-BEZZRyE2.js +29 -0
- package/dist/formatDistanceToNow-TErllcH8.js +100 -0
- package/dist/gatewayScripts-D8O45W8u.js +72 -0
- package/dist/highlight-BsUzxSR3.js +454 -0
- package/dist/index-B52h3RHg.js +1290 -0
- package/dist/index-BP5drcF2.js +1265 -0
- package/dist/index-BZ4vxviI.js +7981 -0
- package/dist/index-B_Z0MwXk.js +25012 -0
- package/dist/index-BfjzUWDa.js +1397 -0
- package/dist/{index-CDm_burV.js → index-BnV-PkwM.js} +22 -20
- package/dist/index-CGDYgUCH.js +711 -0
- package/dist/index-COt7nJIf.js +2286 -0
- package/dist/index-CWZjOy1h.js +2247 -0
- package/dist/index-CezvogTQ.js +116 -0
- package/dist/index-CgCWbWzN.js +2342 -0
- package/dist/index-CjCkcuuI.js +322 -0
- package/dist/index-CjXvuf9m.js +1354 -0
- package/dist/index-DD4qF7gq.js +2340 -0
- package/dist/index-DeQ-9KTC.js +737 -0
- package/dist/index-Df6OBy4E.js +3041 -0
- package/dist/index-KRsV2L4V.js +1564 -0
- package/dist/index-PUuASE1F.js +2507 -0
- package/dist/index-PWsNvJB-.js +546 -0
- package/dist/index-UqDmyMSA.js +119 -0
- package/dist/index-_0Pj_ZtW.js +459 -0
- package/dist/{index-DJABKRWO.js → index-sr-mWz4T.js} +31 -30
- package/dist/index.d.ts +496 -200
- package/dist/index.js +462 -439
- package/dist/llmProviderPayload-CzihkdNa.js +332 -0
- package/dist/schemas-DFScWdSL.js +2969 -0
- package/package.json +1 -1
- package/dist/index-B0d-vovv.js +0 -236
- package/dist/index-CCmLfbLS.js +0 -80707
- package/dist/index-qanXZe0s.js +0 -3037
|
@@ -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 J, 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 U } 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 { i as Z, aH as ke, aI as fe, aJ as me, I as de, H as Ce, c as Ne, P as he, N as Ee } from "./index-B_Z0MwXk.js";
|
|
7
|
+
import "@tanstack/react-query";
|
|
8
|
+
import { useParams as ee } from "react-router-dom";
|
|
9
|
+
import { E as ue } from "./EnvironmentSelector-B7Bl93s2.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(J, { 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(J, { 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 z;
|
|
90
|
+
return e[44] !== i || e[45] !== S ? (z = /* @__PURE__ */ t(b, { display: "flex", justifyContent: i, width: "100%", sx: E, children: S }), e[44] = i, e[45] = S, e[46] = z) : z = e[46], z;
|
|
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 O = await X();
|
|
179
|
+
if (O === null) {
|
|
180
|
+
P(!0);
|
|
181
|
+
try {
|
|
182
|
+
await new Promise((m) => setTimeout(m, Re)), O = await X();
|
|
183
|
+
} finally {
|
|
184
|
+
P(!1);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (O === 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 = O.headers.get("content-type");
|
|
193
|
+
if (ie && ie.includes("application/json") ? W = await O.json() : W = await O.text(), O.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 ${O.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((O) => [...O, X]);
|
|
222
|
+
} finally {
|
|
223
|
+
E(!1);
|
|
224
|
+
}
|
|
225
|
+
}, z = (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
|
+
}, H = /* @__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(J, { 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(J, { variant: "h5", children: "Start a conversation" }),
|
|
249
|
+
/* @__PURE__ */ t(J, { 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
|
+
H,
|
|
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: z, 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(J, { 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
|
+
H,
|
|
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: z, 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-BnV-PkwM.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 z = () => 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 z();
|
|
344
|
+
const H = await fetch(A, S);
|
|
345
|
+
return H.status === 401 && c("unauthorized"), H;
|
|
346
|
+
} catch (F) {
|
|
347
|
+
if (!(F instanceof TypeError))
|
|
348
|
+
throw F;
|
|
349
|
+
await z();
|
|
350
|
+
try {
|
|
351
|
+
return await fetch(A, S);
|
|
352
|
+
} catch (H) {
|
|
353
|
+
throw c("unauthorized"), H;
|
|
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(U, { 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(U, { variant: "rounded", height: 500 }), children: [
|
|
370
|
+
i && /* @__PURE__ */ t(N, { severity: "info", sx: {
|
|
371
|
+
mb: 2
|
|
372
|
+
}, children: /* @__PURE__ */ k(J, { 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(U, { variant: "circular", width: 80, height: 80 }), r = /* @__PURE__ */ t(U, { variant: "text", width: 250, height: 32 }), s = /* @__PURE__ */ t(U, { 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(U, { 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
|
+
}, Je = {
|
|
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
|
+
Je as metaData
|
|
459
|
+
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsx as i, jsxs as N } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback as
|
|
3
|
-
import { Alert as
|
|
4
|
-
import { useParams as $, useNavigate as J, generatePath as
|
|
5
|
-
import {
|
|
2
|
+
import { useCallback as R, useMemo as A, useEffect as M, useState as B } from "react";
|
|
3
|
+
import { Alert as O, Box as L, Collapse as D, Button as T, Form as b, TextField as F, Stack as z, CircularProgress as G, Typography as C, Select as H, MenuItem as k } from "@wso2/oxygen-ui";
|
|
4
|
+
import { useParams as $, useNavigate as J, generatePath as V } from "react-router-dom";
|
|
5
|
+
import { ck as K, y as Q, z as U, aV as X, r as Y, A as Z, cu as _, g as I, P as ee } from "./index-B_Z0MwXk.js";
|
|
6
|
+
import { o as te, s as w } from "./schemas-DFScWdSL.js";
|
|
6
7
|
import { c as W } from "react/compiler-runtime";
|
|
7
8
|
import "@tanstack/react-query";
|
|
8
9
|
import { Link as ne, PackagePlus as ie, FolderPlus as ae } from "@wso2/oxygen-ui-icons-react";
|
|
9
|
-
const re =
|
|
10
|
+
const re = te({
|
|
10
11
|
displayName: w().trim().min(1, "Display name is required").min(3, "Display name must be at least 3 characters").max(100, "Display name must be at most 100 characters"),
|
|
11
12
|
name: w().trim().max(50, "Name must be at most 50 characters"),
|
|
12
13
|
description: w().trim().optional(),
|
|
@@ -24,7 +25,7 @@ const re = K({
|
|
|
24
25
|
e[0] !== t ? (y = Object.values(t), e[0] = t, e[1] = y) : y = e[1];
|
|
25
26
|
const u = y, v = u.length > 0;
|
|
26
27
|
let g;
|
|
27
|
-
e[2] !== u ? (g = /* @__PURE__ */ i(
|
|
28
|
+
e[2] !== u ? (g = /* @__PURE__ */ i(O, { severity: "error", children: u.map(le) }), e[2] = u, e[3] = g) : g = e[3];
|
|
28
29
|
let h;
|
|
29
30
|
e[4] !== v || e[5] !== g ? (h = /* @__PURE__ */ i(D, { in: v, timeout: "auto", unmountOnExit: !0, children: g }), e[4] = v, e[5] = g, e[6] = h) : h = e[6];
|
|
30
31
|
let n;
|
|
@@ -64,7 +65,7 @@ function se(a) {
|
|
|
64
65
|
let o;
|
|
65
66
|
e[5] !== s ? (o = s && /* @__PURE__ */ i(C, { variant: "caption", color: "text.disabled", children: s }), e[5] = s, e[6] = o) : o = e[6];
|
|
66
67
|
let p;
|
|
67
|
-
return e[7] !== l || e[8] !== o ? (p = /* @__PURE__ */ N(
|
|
68
|
+
return e[7] !== l || e[8] !== o ? (p = /* @__PURE__ */ N(z, { direction: "row", alignItems: "center", spacing: 1, children: [
|
|
68
69
|
l,
|
|
69
70
|
o
|
|
70
71
|
] }), e[7] = l, e[8] = o, e[9] = p) : p = e[9], p;
|
|
@@ -82,7 +83,7 @@ function ce(a) {
|
|
|
82
83
|
let o;
|
|
83
84
|
e[5] !== s ? (o = s && /* @__PURE__ */ i(C, { variant: "caption", color: "text.disbaled", children: s }), e[5] = s, e[6] = o) : o = e[6];
|
|
84
85
|
let p;
|
|
85
|
-
return e[7] !== l || e[8] !== o ? (p = /* @__PURE__ */ N(
|
|
86
|
+
return e[7] !== l || e[8] !== o ? (p = /* @__PURE__ */ N(z, { children: [
|
|
86
87
|
l,
|
|
87
88
|
o
|
|
88
89
|
] }), e[7] = l, e[8] = o, e[9] = p) : p = e[9], p;
|
|
@@ -97,7 +98,7 @@ const de = ({
|
|
|
97
98
|
}) => {
|
|
98
99
|
const {
|
|
99
100
|
orgId: l
|
|
100
|
-
} = $(), o =
|
|
101
|
+
} = $(), o = R((n, r) => {
|
|
101
102
|
const m = {
|
|
102
103
|
...a,
|
|
103
104
|
[n]: r
|
|
@@ -108,22 +109,22 @@ const de = ({
|
|
|
108
109
|
}, [a, e, s, d, c]), {
|
|
109
110
|
mutate: p,
|
|
110
111
|
isPending: E
|
|
111
|
-
} =
|
|
112
|
+
} = K({
|
|
112
113
|
orgName: l
|
|
113
114
|
}), {
|
|
114
115
|
data: P,
|
|
115
116
|
isLoading: y
|
|
116
|
-
} =
|
|
117
|
+
} = Q({
|
|
117
118
|
orgName: l
|
|
118
119
|
}), u = P?.deploymentPipelines ?? [], {
|
|
119
120
|
data: v
|
|
120
|
-
} =
|
|
121
|
+
} = U({
|
|
121
122
|
orgName: l
|
|
122
123
|
}), g = A(() => {
|
|
123
124
|
const n = /* @__PURE__ */ new Map();
|
|
124
125
|
return (v ?? []).forEach((r) => n.set(r.name, r.displayName ?? r.name)), n;
|
|
125
126
|
}, [v]);
|
|
126
|
-
|
|
127
|
+
M(() => {
|
|
127
128
|
if (!a.deploymentPipeline && u.length > 0) {
|
|
128
129
|
const n = u[0].name;
|
|
129
130
|
e((r) => {
|
|
@@ -136,7 +137,7 @@ const de = ({
|
|
|
136
137
|
}
|
|
137
138
|
}, [u, a.deploymentPipeline, e, s]);
|
|
138
139
|
const h = A(
|
|
139
|
-
() =>
|
|
140
|
+
() => X.debounce((n) => {
|
|
140
141
|
if (n.length < 3) {
|
|
141
142
|
o("name", "");
|
|
142
143
|
return;
|
|
@@ -162,9 +163,9 @@ const de = ({
|
|
|
162
163
|
// 500ms delay
|
|
163
164
|
[p, e, s]
|
|
164
165
|
);
|
|
165
|
-
return
|
|
166
|
+
return M(() => () => {
|
|
166
167
|
h.cancel();
|
|
167
|
-
}, [h]),
|
|
168
|
+
}, [h]), M(() => {
|
|
168
169
|
a.displayName && a.displayName.length >= 3 ? h(a.displayName) : (h.cancel(), e((n) => ({
|
|
169
170
|
...n,
|
|
170
171
|
name: ""
|
|
@@ -172,8 +173,8 @@ const de = ({
|
|
|
172
173
|
}, [a.displayName, e, h]), /* @__PURE__ */ i(b.Stack, { spacing: 3, children: /* @__PURE__ */ N(b.Section, { children: [
|
|
173
174
|
/* @__PURE__ */ i(b.Subheader, { children: "Project Details" }),
|
|
174
175
|
/* @__PURE__ */ N(b.Stack, { spacing: 2, children: [
|
|
175
|
-
/* @__PURE__ */ i(b.ElementWrapper, { label: "Name", name: "displayName", children: /* @__PURE__ */ i(F, { id: "displayName", value: a.displayName, onChange: (n) => o("displayName", n.target.value), placeholder: "e.g., Customer Support Platform", error: !!t.displayName, helperText: E ? /* @__PURE__ */ N(
|
|
176
|
-
/* @__PURE__ */ i(
|
|
176
|
+
/* @__PURE__ */ i(b.ElementWrapper, { label: "Name", name: "displayName", children: /* @__PURE__ */ i(F, { id: "displayName", value: a.displayName, onChange: (n) => o("displayName", n.target.value), placeholder: "e.g., Customer Support Platform", error: !!t.displayName, helperText: E ? /* @__PURE__ */ N(z, { direction: "row", alignItems: "center", gap: 1, children: [
|
|
177
|
+
/* @__PURE__ */ i(G, { size: 12 }),
|
|
177
178
|
/* @__PURE__ */ i(C, { variant: "caption", children: "Validating name..." })
|
|
178
179
|
] }) : t.displayName, fullWidth: !0 }) }),
|
|
179
180
|
/* @__PURE__ */ i(b.ElementWrapper, { label: "Description (optional)", name: "description", children: /* @__PURE__ */ i(F, { id: "description", value: a.description, onChange: (n) => o("description", n.target.value), placeholder: "Short description of this project", multiline: !0, minRows: 2, maxRows: 6, error: !!t.description, helperText: t.description, fullWidth: !0 }) }),
|
|
@@ -181,8 +182,8 @@ const de = ({
|
|
|
181
182
|
const r = u.find((m) => m.name === n);
|
|
182
183
|
return r ? /* @__PURE__ */ i(se, { pipeline: r, envDisplayNameMap: g }) : n;
|
|
183
184
|
}, fullWidth: !0, children: [
|
|
184
|
-
y && /* @__PURE__ */ i(k, { value: "", disabled: !0, children: /* @__PURE__ */ N(
|
|
185
|
-
/* @__PURE__ */ i(
|
|
185
|
+
y && /* @__PURE__ */ i(k, { value: "", disabled: !0, children: /* @__PURE__ */ N(z, { direction: "row", alignItems: "center", gap: 1, children: [
|
|
186
|
+
/* @__PURE__ */ i(G, { size: 12 }),
|
|
186
187
|
/* @__PURE__ */ i(C, { variant: "caption", children: "Loading pipelines..." })
|
|
187
188
|
] }) }),
|
|
188
189
|
!y && u.length === 0 && /* @__PURE__ */ i(k, { value: "", disabled: !0, children: "No deployment pipelines available" }),
|
|
@@ -204,20 +205,20 @@ const de = ({
|
|
|
204
205
|
validateForm: l,
|
|
205
206
|
clearErrors: o,
|
|
206
207
|
setFieldError: p
|
|
207
|
-
} =
|
|
208
|
+
} = Y(re), {
|
|
208
209
|
checkDirty: E,
|
|
209
210
|
resetDirty: P
|
|
210
|
-
} =
|
|
211
|
+
} = Z(t), y = A(() => ({
|
|
211
212
|
orgName: e ?? "default"
|
|
212
213
|
}), [e]), {
|
|
213
214
|
mutate: u,
|
|
214
215
|
isPending: v,
|
|
215
216
|
error: g
|
|
216
|
-
} =
|
|
217
|
-
a(
|
|
217
|
+
} = _(y), h = R(() => {
|
|
218
|
+
a(V(I.children.org.path, {
|
|
218
219
|
orgId: e ?? ""
|
|
219
220
|
}));
|
|
220
|
-
}, [a, e]), [n, r] = B({}), m =
|
|
221
|
+
}, [a, e]), [n, r] = B({}), m = R(() => {
|
|
221
222
|
if (l(t))
|
|
222
223
|
r({});
|
|
223
224
|
else {
|
|
@@ -231,7 +232,7 @@ const de = ({
|
|
|
231
232
|
deploymentPipeline: t.deploymentPipeline
|
|
232
233
|
}, {
|
|
233
234
|
onSuccess: () => {
|
|
234
|
-
P(), o(), a(
|
|
235
|
+
P(), o(), a(V(I.children.org.children.projects.path, {
|
|
235
236
|
orgId: y.orgName ?? "",
|
|
236
237
|
projectId: t.name
|
|
237
238
|
}));
|
|
@@ -241,16 +242,16 @@ const de = ({
|
|
|
241
242
|
}
|
|
242
243
|
});
|
|
243
244
|
}, [t, l, u, a, y.orgName, P, o, c]);
|
|
244
|
-
return /* @__PURE__ */ i(
|
|
245
|
+
return /* @__PURE__ */ i(ee, { title: "Create a New Project", description: "Create a new project to organize and manage your agents.", disableIcon: !0, backHref: V(I.children.org.path, {
|
|
245
246
|
orgId: e ?? ""
|
|
246
247
|
}), backLabel: "Back to Organization", children: /* @__PURE__ */ N(L, { display: "flex", flexDirection: "column", gap: 2, children: [
|
|
247
248
|
/* @__PURE__ */ i(de, { formData: t, setFormData: d, errors: c, validateField: s, setFieldError: p, checkDirty: E }),
|
|
248
|
-
!!g && /* @__PURE__ */ i(
|
|
249
|
+
!!g && /* @__PURE__ */ i(O, { severity: "error", sx: {
|
|
249
250
|
mt: 2
|
|
250
251
|
}, children: g instanceof Error ? g.message : "Failed to create project" }),
|
|
251
252
|
/* @__PURE__ */ i(oe, { lastSubmittedValidationErrors: n, isPending: v, onCancel: h, onSubmit: m, isNameEmpty: !t.name.trim(), mode: "deploy" })
|
|
252
253
|
] }) });
|
|
253
|
-
},
|
|
254
|
+
}, be = {
|
|
254
255
|
title: "Add New Project",
|
|
255
256
|
description: "A page component for Add New Project",
|
|
256
257
|
icon: ae,
|
|
@@ -259,5 +260,5 @@ const de = ({
|
|
|
259
260
|
};
|
|
260
261
|
export {
|
|
261
262
|
pe as AddNewProject,
|
|
262
|
-
|
|
263
|
+
be as metaData
|
|
263
264
|
};
|