@wso2/am-core-ui 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1784 @@
1
+ import { jsxs as S, jsx as n, Fragment as en } from "react/jsx-runtime";
2
+ import { c as de } from "react/compiler-runtime";
3
+ import { useParams as Ne, generatePath as Se, useNavigate as vt, Route as Et, Routes as tn } from "react-router-dom";
4
+ import { u as nn, g as ve, E as rn, I as an, P as Lt, o as gt, a as ln, b as Dt, s as te, c as on, _ as sn, l as zt, n as cn, d as dn, e as Rt, f as Vt, h as mn, i as pn, j as hn, k as un, m as fn, D as gn, p as yn, q as vn, G as bn, r as Sn, t as Wt, v as jt, B as Cn, w as Ft } from "./index-DXT-m_eH.js";
5
+ import { Form as C, Typography as O, Box as re, Divider as Gt, TextField as ne, Alert as we, Collapse as Ee, Card as Nn, CardContent as Pn, Button as Ce, DialogContent as xn, DialogTitle as kn, DialogActions as An, Dialog as _n, FormHelperText as $t, FormControl as En, MenuItem as Tt, CircularProgress as bt, Stack as ie, Select as wn, SearchBar as Tn, ListingTable as Ut, Tabs as In, Tooltip as Mt, Chip as Bt, Tab as Ln, Avatar as Vn, IconButton as Dn, AccordionSummary as Rn, AccordionDetails as $n, Accordion as Un, FormControlLabel as Mn, Checkbox as On } from "@wso2/oxygen-ui";
6
+ import "@tanstack/react-query";
7
+ import { useState as ce, useRef as zn, useMemo as It, useCallback as xe, useEffect as yt } from "react";
8
+ import { CheckCircle as Wn, Circle as qt, Plus as St, DoorClosedLocked as jn, Link as Zt, Search as Fn, Check as Gn, ChevronDown as Bn, Trash2 as qn, Rocket as Zn, UserPlus as Hn } from "@wso2/oxygen-ui-icons-react";
9
+ const Ot = (t) => {
10
+ const e = de(18), {
11
+ type: r,
12
+ title: a,
13
+ subheader: l,
14
+ icon: o,
15
+ onClick: h
16
+ } = t;
17
+ let y;
18
+ e[0] !== h || e[1] !== r ? (y = () => {
19
+ h(r);
20
+ }, e[0] = h, e[1] = r, e[2] = y) : y = e[2];
21
+ const v = y;
22
+ let s;
23
+ e[3] === Symbol.for("react.memo_cache_sentinel") ? (s = {
24
+ width: 450,
25
+ py: 2
26
+ }, e[3] = s) : s = e[3];
27
+ let m;
28
+ e[4] !== a ? (m = /* @__PURE__ */ n(O, { width: "100%", variant: "h4", textAlign: "center", children: a }), e[4] = a, e[5] = m) : m = e[5];
29
+ let c;
30
+ e[6] === Symbol.for("react.memo_cache_sentinel") ? (c = {
31
+ display: "flex",
32
+ justifyContent: "center",
33
+ alignItems: "flex-end",
34
+ height: 250,
35
+ mb: 10
36
+ }, e[6] = c) : c = e[6];
37
+ let d;
38
+ e[7] !== o ? (d = /* @__PURE__ */ n(re, { sx: c, children: o }), e[7] = o, e[8] = d) : d = e[8];
39
+ let p;
40
+ e[9] !== l ? (p = /* @__PURE__ */ n(O, { variant: "body2", textAlign: "center", children: l }), e[9] = l, e[10] = p) : p = e[10];
41
+ let g;
42
+ e[11] !== d || e[12] !== p ? (g = /* @__PURE__ */ S(C.CardContent, { children: [
43
+ d,
44
+ p
45
+ ] }), e[11] = d, e[12] = p, e[13] = g) : g = e[13];
46
+ let i;
47
+ return e[14] !== v || e[15] !== m || e[16] !== g ? (i = /* @__PURE__ */ S(C.CardButton, { onClick: v, sx: s, children: [
48
+ m,
49
+ g
50
+ ] }), e[14] = v, e[15] = m, e[16] = g, e[17] = i) : i = e[17], i;
51
+ }, Kn = (t) => {
52
+ const e = de(20), {
53
+ onSelect: r
54
+ } = t, {
55
+ orgId: a,
56
+ projectId: l
57
+ } = Ne(), o = a ?? "default", h = l ?? "default";
58
+ let y;
59
+ e[0] !== o || e[1] !== h ? (y = {
60
+ orgName: o,
61
+ projName: h
62
+ }, e[0] = o, e[1] = h, e[2] = y) : y = e[2];
63
+ const {
64
+ data: v
65
+ } = nn(y);
66
+ let s;
67
+ e[3] !== r ? (s = (E) => {
68
+ r(E);
69
+ }, e[3] = r, e[4] = s) : s = e[4];
70
+ const m = s, c = !!(v?.agents?.length && v?.agents?.length > 0);
71
+ let d;
72
+ e: {
73
+ if (!c) {
74
+ d = void 0;
75
+ break e;
76
+ }
77
+ const E = a ?? "", k = l ?? "default";
78
+ let x;
79
+ e[5] !== E || e[6] !== k ? (x = Se(ve.children.org.children.projects.path, {
80
+ orgId: E,
81
+ projectId: k
82
+ }), e[5] = E, e[6] = k, e[7] = x) : x = e[7], d = x;
83
+ }
84
+ const p = d;
85
+ let g;
86
+ e[8] === Symbol.for("react.memo_cache_sentinel") ? (g = /* @__PURE__ */ n(rn, { width: 150 }), e[8] = g) : g = e[8];
87
+ let i;
88
+ e[9] !== m ? (i = /* @__PURE__ */ n(Ot, { type: "existing", title: "Externally-Hosted Agent", subheader: "Connect an existing agent running outside the platform and enable observability and governance.", icon: g, onClick: m }), e[9] = m, e[10] = i) : i = e[10];
89
+ let N;
90
+ e[11] === Symbol.for("react.memo_cache_sentinel") ? (N = /* @__PURE__ */ n(an, { width: 150 }), e[11] = N) : N = e[11];
91
+ let b;
92
+ e[12] !== m ? (b = /* @__PURE__ */ n(Ot, { type: "new", title: "Platform-Hosted Agent", subheader: "Deploy and manage agents with full lifecycle support, including built-in CI/CD, scaling, observability, and governance.", icon: N, onClick: m }), e[12] = m, e[13] = b) : b = e[13];
93
+ let P;
94
+ e[14] !== i || e[15] !== b ? (P = /* @__PURE__ */ S(re, { display: "flex", flexDirection: "row", gap: 3, width: 1, children: [
95
+ i,
96
+ b
97
+ ] }), e[14] = i, e[15] = b, e[16] = P) : P = e[16];
98
+ let T;
99
+ return e[17] !== p || e[18] !== P ? (T = /* @__PURE__ */ n(Lt, { title: "Add a New Agent", description: "Choose how you want to get started. You can deploy an agent on the platform or register an agent that already runs elsewhere.", disableIcon: !0, backHref: p, backLabel: "Back to Projects Home", children: P }), e[17] = p, e[18] = P, e[19] = T) : T = e[19], T;
100
+ }, Ht = {
101
+ displayName: te().trim().min(1, "Name is required").min(3, "Name must be at least 3 characters").max(100, "Name must be at most 100 characters"),
102
+ name: te().trim().max(50, "Name must be at most 50 characters"),
103
+ description: te().trim().optional()
104
+ }, Yn = gt({
105
+ ...Ht,
106
+ deploymentType: zt("existing").optional()
107
+ }), Qn = gt({
108
+ ...Ht,
109
+ deploymentType: zt("new").optional(),
110
+ enableAutoInstrumentation: Dt().default(!0),
111
+ repositoryUrl: te().trim().min(1, "Repository URL is required").url("Must be a valid URL"),
112
+ branch: te().trim().min(1, "Branch is required"),
113
+ appPath: te().trim().min(1, "App path is required").refine((t) => t.startsWith("/"), {
114
+ message: "App path must start with /"
115
+ }).refine((t) => !/\.\./.test(t), {
116
+ message: "Path traversal is not allowed"
117
+ }).refine((t) => /^\/[A-Za-z0-9._\-/]*$/.test(t), {
118
+ message: "App path can only contain letters, numbers, ., _, -, and /"
119
+ }).refine((t) => t === "/" ? !0 : !t.endsWith("/"), {
120
+ message: "App path must be a valid path (use / for root directory)"
121
+ }),
122
+ gitSecretRef: te().trim().optional(),
123
+ runCommand: te().trim().optional(),
124
+ language: te().trim().min(1, "Language is required"),
125
+ languageVersion: te().trim().optional(),
126
+ dockerfilePath: te().trim().optional(),
127
+ interfaceType: sn(["DEFAULT", "CUSTOM"]),
128
+ port: on([cn(), te(), dn()]).transform((t) => {
129
+ if (!(t === "" || t === null || t === void 0))
130
+ return typeof t == "string" ? Number(t) : t;
131
+ }).optional(),
132
+ basePath: te().trim().optional(),
133
+ openApiPath: te().trim().optional(),
134
+ env: ln(gt({
135
+ key: te().trim().min(1, "Environment variable key is required").max(64, "Environment variable key must be at most 64 characters").regex(/^[A-Za-z_][A-Za-z0-9_]*$/, "Env keys must match /^[A-Za-z_][A-Za-z0-9_]*$/").optional(),
136
+ value: te().trim().max(2048, "Environment variable value must be at most 2048 characters").optional(),
137
+ isSensitive: Dt().default(!1)
138
+ })).max(50, "A maximum of 50 environment variables is allowed")
139
+ }).refine((t) => !(t.interfaceType === "CUSTOM" && !t.port), {
140
+ message: "Port is required when using custom interface",
141
+ path: ["port"]
142
+ }).refine((t) => !(t.interfaceType === "CUSTOM" && t.port !== void 0 && (!Number.isInteger(t.port) || t.port < 1 || t.port > 65535)), {
143
+ message: "Port must be between 1 and 65535",
144
+ path: ["port"]
145
+ }).refine((t) => !(t.interfaceType === "CUSTOM" && !t.basePath), {
146
+ message: "Base path is required when using custom interface",
147
+ path: ["basePath"]
148
+ }).refine((t) => !(t.interfaceType === "CUSTOM" && !t.openApiPath), {
149
+ message: "OpenAPI spec path is required when using custom interface",
150
+ path: ["openApiPath"]
151
+ }).refine((t) => !(t.language === "python" && !t.runCommand?.trim()), {
152
+ message: "Start Command is required for Python agents",
153
+ path: ["runCommand"]
154
+ }).refine((t) => !(t.language === "python" && !t.languageVersion?.trim()), {
155
+ message: "Python version is required for Python agents",
156
+ path: ["languageVersion"]
157
+ }).refine((t) => !(t.language === "docker" && !t.dockerfilePath?.trim()), {
158
+ message: "Dockerfile path is required for Docker agents",
159
+ path: ["dockerfilePath"]
160
+ }).refine((t) => !(t.language === "docker" && t.dockerfilePath?.trim() && !t.dockerfilePath.startsWith("/")), {
161
+ message: "Dockerfile path must start with /",
162
+ path: ["dockerfilePath"]
163
+ }), Jn = [{
164
+ label: "Chat Agent",
165
+ description: "Standard chat interface with /chat endpoint on port 8000",
166
+ default: !0,
167
+ value: "DEFAULT"
168
+ }, {
169
+ label: "Custom API Agent",
170
+ description: "Custom HTTP API with user-specified OpenAPI specification and port configuration",
171
+ default: !1,
172
+ value: "CUSTOM"
173
+ }], Xn = (t) => {
174
+ const e = de(57), {
175
+ formData: r,
176
+ setFormData: a,
177
+ errors: l,
178
+ setFieldError: o,
179
+ validateField: h
180
+ } = t;
181
+ let y;
182
+ e[0] !== o || e[1] !== a || e[2] !== h ? (y = (L, F) => {
183
+ let Q = null;
184
+ if (a((X) => (Q = {
185
+ ...X,
186
+ [L]: F
187
+ }, Q)), Q) {
188
+ const X = h(L, F, Q);
189
+ o(L, X);
190
+ }
191
+ }, e[0] = o, e[1] = a, e[2] = h, e[3] = y) : y = e[3];
192
+ const v = y;
193
+ let s;
194
+ e[4] !== o || e[5] !== a || e[6] !== h ? (s = (L) => {
195
+ a((F) => ({
196
+ ...F,
197
+ interfaceType: L,
198
+ ...L === "DEFAULT" ? {
199
+ openApiPath: "",
200
+ port: "",
201
+ basePath: "/"
202
+ } : {}
203
+ })), a((F) => {
204
+ const Q = h("interfaceType", L, F);
205
+ if (o("interfaceType", Q), L === "CUSTOM") {
206
+ const X = h("port", F.port, F);
207
+ o("port", X);
208
+ const be = h("openApiPath", F.openApiPath, F);
209
+ o("openApiPath", be);
210
+ const ae = h("basePath", F.basePath, F);
211
+ o("basePath", ae);
212
+ } else
213
+ o("port", void 0), o("openApiPath", void 0), o("basePath", void 0);
214
+ return F;
215
+ });
216
+ }, e[4] = o, e[5] = a, e[6] = h, e[7] = s) : s = e[7];
217
+ const m = s;
218
+ let c;
219
+ e[8] !== v ? (c = (L) => {
220
+ const F = L.target.value;
221
+ /^\d*$/.test(F) && v("port", F === "" ? "" : Number(F));
222
+ }, e[8] = v, e[9] = c) : c = e[9];
223
+ const d = c;
224
+ let p, g;
225
+ e[10] === Symbol.for("react.memo_cache_sentinel") ? (p = /* @__PURE__ */ n(C.Subheader, { children: "Agent Type" }), g = /* @__PURE__ */ n(O, { variant: "body2", color: "text.secondary", children: "How your agent receives requests" }), e[10] = p, e[11] = g) : (p = e[10], g = e[11]);
226
+ let i;
227
+ e[12] !== r.interfaceType || e[13] !== m ? (i = Jn.map((L) => /* @__PURE__ */ n(C.CardButton, { onClick: () => m(L.value), selected: r.interfaceType === L.value, sx: {
228
+ maxWidth: 500,
229
+ flexGrow: 1
230
+ }, children: /* @__PURE__ */ n(C.CardContent, { sx: {
231
+ height: "100%"
232
+ }, children: /* @__PURE__ */ S(re, { display: "flex", flexDirection: "row", alignItems: "center", height: "100%", gap: 1, children: [
233
+ /* @__PURE__ */ n(re, { children: r.interfaceType === L.value ? /* @__PURE__ */ n(Wn, { size: 16 }) : /* @__PURE__ */ n(qt, { size: 16 }) }),
234
+ /* @__PURE__ */ n(Gt, { orientation: "vertical", flexItem: !0 }),
235
+ /* @__PURE__ */ S(re, { children: [
236
+ /* @__PURE__ */ n(O, { variant: "h6", children: L.label }),
237
+ /* @__PURE__ */ n(O, { variant: "caption", children: L.description })
238
+ ] })
239
+ ] }) }) }, L.value)), e[12] = r.interfaceType, e[13] = m, e[14] = i) : i = e[14];
240
+ let N;
241
+ e[15] !== i ? (N = /* @__PURE__ */ n(re, { display: "flex", flexDirection: "row", gap: 1, children: i }), e[15] = i, e[16] = N) : N = e[16];
242
+ const b = r.interfaceType === "DEFAULT";
243
+ let P;
244
+ e[17] === Symbol.for("react.memo_cache_sentinel") ? (P = /* @__PURE__ */ n("strong", { children: "POST /chat" }), e[17] = P) : P = e[17];
245
+ let T, E;
246
+ e[18] === Symbol.for("react.memo_cache_sentinel") ? (T = /* @__PURE__ */ n("strong", { children: "8000" }), E = /* @__PURE__ */ n("br", {}), e[18] = T, e[19] = E) : (T = e[18], E = e[19]);
247
+ let k, x;
248
+ e[20] === Symbol.for("react.memo_cache_sentinel") ? (k = /* @__PURE__ */ n("code", { children: "{message: string, session_id: string, context: JSON}" }), x = /* @__PURE__ */ n("br", {}), e[20] = k, e[21] = x) : (k = e[20], x = e[21]);
249
+ let I;
250
+ e[22] === Symbol.for("react.memo_cache_sentinel") ? (I = /* @__PURE__ */ S(we, { severity: "info", children: [
251
+ "Uses the standard chat interface: ",
252
+ P,
253
+ " on port ",
254
+ T,
255
+ E,
256
+ "Request:",
257
+ " ",
258
+ k,
259
+ x,
260
+ "Response: ",
261
+ /* @__PURE__ */ n("code", { children: "{response: string}" })
262
+ ] }), e[22] = I) : I = e[22];
263
+ let V;
264
+ e[23] !== b ? (V = /* @__PURE__ */ n(Ee, { in: b, children: I }), e[23] = b, e[24] = V) : V = e[24];
265
+ const D = r.interfaceType === "CUSTOM", A = r.openApiPath || "";
266
+ let z;
267
+ e[25] !== v ? (z = (L) => v("openApiPath", L.target.value), e[25] = v, e[26] = z) : z = e[26];
268
+ const G = !!l.openApiPath, R = l.openApiPath || "Path to OpenAPI schema file in your repository";
269
+ let w;
270
+ e[27] !== A || e[28] !== z || e[29] !== G || e[30] !== R ? (w = /* @__PURE__ */ n(re, { display: "flex", flexDirection: "column", flexGrow: 1, children: /* @__PURE__ */ n(C.ElementWrapper, { label: "OpenAPI Spec Path", name: "openApiPath", children: /* @__PURE__ */ n(ne, { id: "openApiPath", placeholder: "/openapi.yaml", required: !0, value: A, onChange: z, error: G, helperText: R, fullWidth: !0 }) }) }), e[27] = A, e[28] = z, e[29] = G, e[30] = R, e[31] = w) : w = e[31];
271
+ const W = r.port ?? "", $ = !!l.port, j = l.port || (r.port ? void 0 : "Port is required");
272
+ let B;
273
+ e[32] !== d || e[33] !== W || e[34] !== $ || e[35] !== j ? (B = /* @__PURE__ */ n(re, { children: /* @__PURE__ */ n(C.ElementWrapper, { label: "Port", name: "port", children: /* @__PURE__ */ n(ne, { id: "port", placeholder: "8080", required: !0, value: W, onChange: d, type: "number", error: $, helperText: j }) }) }), e[32] = d, e[33] = W, e[34] = $, e[35] = j, e[36] = B) : B = e[36];
274
+ let f;
275
+ e[37] !== w || e[38] !== B ? (f = /* @__PURE__ */ S(C.Stack, { direction: "row", spacing: 2, children: [
276
+ w,
277
+ B
278
+ ] }), e[37] = w, e[38] = B, e[39] = f) : f = e[39];
279
+ const u = r.basePath || "";
280
+ let _;
281
+ e[40] !== v ? (_ = (L) => v("basePath", L.target.value), e[40] = v, e[41] = _) : _ = e[41];
282
+ const U = !!l.basePath, M = l.basePath || "API base path (e.g., / or /api/v1)";
283
+ let H;
284
+ e[42] !== u || e[43] !== _ || e[44] !== U || e[45] !== M ? (H = /* @__PURE__ */ n(C.ElementWrapper, { label: "Base Path", name: "basePath", children: /* @__PURE__ */ n(ne, { id: "basePath", placeholder: "/", required: !0, value: u, onChange: _, error: U, helperText: M, fullWidth: !0 }) }), e[42] = u, e[43] = _, e[44] = U, e[45] = M, e[46] = H) : H = e[46];
285
+ let K;
286
+ e[47] !== f || e[48] !== H ? (K = /* @__PURE__ */ S(C.Stack, { spacing: 2, children: [
287
+ f,
288
+ H
289
+ ] }), e[47] = f, e[48] = H, e[49] = K) : K = e[49];
290
+ let Z;
291
+ e[50] !== D || e[51] !== K ? (Z = /* @__PURE__ */ n(Ee, { in: D, children: K }), e[50] = D, e[51] = K, e[52] = Z) : Z = e[52];
292
+ let Y;
293
+ return e[53] !== V || e[54] !== Z || e[55] !== N ? (Y = /* @__PURE__ */ S(C.Section, { children: [
294
+ p,
295
+ g,
296
+ /* @__PURE__ */ S(C.Stack, { spacing: 2, children: [
297
+ N,
298
+ V,
299
+ Z
300
+ ] })
301
+ ] }), e[53] = V, e[54] = Z, e[55] = N, e[56] = Y) : Y = e[56], Y;
302
+ }, er = ({
303
+ formData: t,
304
+ setFormData: e,
305
+ llmReservedNames: r = /* @__PURE__ */ new Set()
306
+ }) => {
307
+ const a = t.env || [], l = a.some((s) => !s?.key || !s?.value), o = () => {
308
+ e((s) => ({
309
+ ...s,
310
+ env: [...s.env || [], {
311
+ key: "",
312
+ value: "",
313
+ isSensitive: !1
314
+ }]
315
+ }));
316
+ }, h = (s) => {
317
+ e((m) => ({
318
+ ...m,
319
+ env: m.env?.filter((c, d) => d !== s) || []
320
+ }));
321
+ }, y = (s, m, c) => {
322
+ e((d) => ({
323
+ ...d,
324
+ env: d.env?.map((p, g) => g === s ? {
325
+ ...p,
326
+ [m]: c
327
+ } : p) || []
328
+ }));
329
+ }, v = (s, m) => {
330
+ e((c) => {
331
+ const d = c.env || [];
332
+ return d.length > 0 ? {
333
+ ...c,
334
+ env: d.map((p, g) => g === 0 ? {
335
+ ...p,
336
+ [s]: m
337
+ } : p)
338
+ } : {
339
+ ...c,
340
+ env: [{
341
+ key: s === "key" ? m : "",
342
+ value: s === "value" ? m : "",
343
+ isSensitive: s === "isSensitive" ? m : !1
344
+ }]
345
+ };
346
+ });
347
+ };
348
+ return /* @__PURE__ */ n(Nn, { variant: "outlined", children: /* @__PURE__ */ S(Pn, { children: [
349
+ /* @__PURE__ */ n(re, { display: "flex", flexDirection: "row", alignItems: "center", gap: 1, children: /* @__PURE__ */ n(O, { variant: "h5", children: "Environment Variables (Optional)" }) }),
350
+ /* @__PURE__ */ n(re, { display: "flex", flexDirection: "column", py: 2, gap: 2, children: a.length ? a.map((s, m) => {
351
+ const c = new Set(a.flatMap((p, g) => g !== m && p.key ? [p.key] : [])), d = s.key && r.has(s.key) ? "Already used as an LLM provider variable" : s.key && c.has(s.key) ? "Duplicate key" : void 0;
352
+ return /* @__PURE__ */ n(Rt, { index: m, keyValue: s.key || "", valueValue: s.value || "", isSensitive: s.isSensitive || !1, onKeyChange: (p) => y(m, "key", p), onValueChange: (p) => y(m, "value", p), onSensitiveChange: (p) => y(m, "isSensitive", p), onRemove: () => h(m), keyError: d }, `env-${m}`);
353
+ }) : /* @__PURE__ */ n(Rt, { index: 0, keyValue: a?.[0]?.key || "", valueValue: a?.[0]?.value || "", isSensitive: a?.[0]?.isSensitive || !1, onKeyChange: (s) => v("key", s), onValueChange: (s) => v("value", s), onSensitiveChange: (s) => v("isSensitive", s), onRemove: () => h(0), keyError: a?.[0]?.key && r.has(a[0].key) ? "Already used as an LLM provider variable" : void 0 }, "env-0") }),
354
+ /* @__PURE__ */ n(Ce, { startIcon: /* @__PURE__ */ n(St, { fontSize: "small" }), disabled: l, variant: "outlined", color: "primary", size: "small", onClick: o, children: "Add" })
355
+ ] }) });
356
+ }, tr = gt({
357
+ name: te().trim().min(1, "Name is required").min(2, "Name must be at least 2 characters").max(25, "Name must be at most 25 characters").refine((t) => /^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$/.test(t) || t.length === 1, {
358
+ message: "Name must start and end with alphanumeric characters"
359
+ }),
360
+ username: te().trim().min(1, "Username is required"),
361
+ password: te().min(1, "Password/PAT is required")
362
+ }), wt = {
363
+ name: "",
364
+ username: "",
365
+ password: ""
366
+ }, nr = (t) => {
367
+ const e = de(59), {
368
+ open: r,
369
+ onClose: a,
370
+ onSecretCreated: l
371
+ } = t, {
372
+ orgId: o
373
+ } = Ne(), [h, y] = ce(wt), {
374
+ errors: v,
375
+ validateForm: s,
376
+ clearErrors: m,
377
+ clearFieldError: c
378
+ } = Vt(tr), {
379
+ mutate: d,
380
+ isPending: p,
381
+ error: g,
382
+ reset: i
383
+ } = mn();
384
+ let N;
385
+ e[0] !== c ? (N = (L, F) => {
386
+ y((Q) => ({
387
+ ...Q,
388
+ [L]: F
389
+ })), c(L);
390
+ }, e[0] = c, e[1] = N) : N = e[1];
391
+ const b = N;
392
+ let P;
393
+ e[2] !== d || e[3] !== h || e[4] !== l || e[5] !== o || e[6] !== s ? (P = () => {
394
+ s(h) && d({
395
+ params: {
396
+ orgName: o
397
+ },
398
+ body: {
399
+ name: h.name.trim(),
400
+ type: "basic-auth",
401
+ credentials: {
402
+ username: h.username.trim(),
403
+ password: h.password
404
+ }
405
+ }
406
+ }, {
407
+ onSuccess: () => {
408
+ l(h.name.trim()), y(wt);
409
+ }
410
+ });
411
+ }, e[2] = d, e[3] = h, e[4] = l, e[5] = o, e[6] = s, e[7] = P) : P = e[7];
412
+ const T = P;
413
+ let E;
414
+ e[8] !== m || e[9] !== p || e[10] !== a || e[11] !== i ? (E = () => {
415
+ p || (y(wt), m(), i(), a());
416
+ }, e[8] = m, e[9] = p, e[10] = a, e[11] = i, e[12] = E) : E = e[12];
417
+ const k = E;
418
+ let x;
419
+ e[13] === Symbol.for("react.memo_cache_sentinel") ? (x = /* @__PURE__ */ n(kn, { children: "Create Git Secret" }), e[13] = x) : x = e[13];
420
+ let I, V;
421
+ e[14] === Symbol.for("react.memo_cache_sentinel") ? (I = {
422
+ mt: 1
423
+ }, V = /* @__PURE__ */ n(O, { variant: "body2", color: "text.secondary", children: "Create a secret to authenticate with private Git repositories. This secret will be available for all projects in your organization." }), e[14] = I, e[15] = V) : (I = e[14], V = e[15]);
424
+ let D;
425
+ e[16] !== g ? (D = !!g && /* @__PURE__ */ n(we, { severity: "error", children: "Failed to create git secret. Please try again." }), e[16] = g, e[17] = D) : D = e[17];
426
+ let A;
427
+ e[18] !== b ? (A = (L) => b("name", L.target.value), e[18] = b, e[19] = A) : A = e[19];
428
+ const z = !!v.name, G = v.name || "A unique name for this secret";
429
+ let R;
430
+ e[20] !== h.name || e[21] !== G || e[22] !== A || e[23] !== z ? (R = /* @__PURE__ */ n(C.ElementWrapper, { label: "Secret Name", name: "name", children: /* @__PURE__ */ n(ne, { id: "name", placeholder: "e.g., my-github-pat", value: h.name, onChange: A, error: z, helperText: G, fullWidth: !0 }) }), e[20] = h.name, e[21] = G, e[22] = A, e[23] = z, e[24] = R) : R = e[24];
431
+ let w;
432
+ e[25] !== b ? (w = (L) => b("username", L.target.value), e[25] = b, e[26] = w) : w = e[26];
433
+ const W = !!v.username, $ = v.username || "Your Git username";
434
+ let j;
435
+ e[27] !== h.username || e[28] !== w || e[29] !== W || e[30] !== $ ? (j = /* @__PURE__ */ n(C.ElementWrapper, { label: "Username", name: "username", children: /* @__PURE__ */ n(ne, { id: "username", placeholder: "e.g., your-github-username", value: h.username, onChange: w, error: W, helperText: $, fullWidth: !0 }) }), e[27] = h.username, e[28] = w, e[29] = W, e[30] = $, e[31] = j) : j = e[31];
436
+ let B;
437
+ e[32] !== b ? (B = (L) => b("password", L.target.value), e[32] = b, e[33] = B) : B = e[33];
438
+ const f = !!v.password, u = v.password || "Your personal access token (PAT) with repo access";
439
+ let _;
440
+ e[34] !== h.password || e[35] !== B || e[36] !== f || e[37] !== u ? (_ = /* @__PURE__ */ n(C.ElementWrapper, { label: "Personal Access Token", name: "password", children: /* @__PURE__ */ n(ne, { id: "password", placeholder: "ghp_xxxxxxxxxxxx", type: "password", value: h.password, onChange: B, error: f, helperText: u, fullWidth: !0 }) }), e[34] = h.password, e[35] = B, e[36] = f, e[37] = u, e[38] = _) : _ = e[38];
441
+ let U;
442
+ e[39] !== R || e[40] !== j || e[41] !== _ || e[42] !== D ? (U = /* @__PURE__ */ n(xn, { children: /* @__PURE__ */ S(C.Stack, { spacing: 3, sx: I, children: [
443
+ V,
444
+ D,
445
+ R,
446
+ j,
447
+ _
448
+ ] }) }), e[39] = R, e[40] = j, e[41] = _, e[42] = D, e[43] = U) : U = e[43];
449
+ let M;
450
+ e[44] !== k || e[45] !== p ? (M = /* @__PURE__ */ n(Ce, { onClick: k, disabled: p, children: "Cancel" }), e[44] = k, e[45] = p, e[46] = M) : M = e[46];
451
+ const H = p ? "Creating..." : "Create Secret";
452
+ let K;
453
+ e[47] !== T || e[48] !== p || e[49] !== H ? (K = /* @__PURE__ */ n(Ce, { variant: "contained", onClick: T, disabled: p, children: H }), e[47] = T, e[48] = p, e[49] = H, e[50] = K) : K = e[50];
454
+ let Z;
455
+ e[51] !== M || e[52] !== K ? (Z = /* @__PURE__ */ S(An, { children: [
456
+ M,
457
+ K
458
+ ] }), e[51] = M, e[52] = K, e[53] = Z) : Z = e[53];
459
+ let Y;
460
+ return e[54] !== k || e[55] !== r || e[56] !== U || e[57] !== Z ? (Y = /* @__PURE__ */ S(_n, { open: r, onClose: k, maxWidth: "sm", fullWidth: !0, children: [
461
+ x,
462
+ U,
463
+ Z
464
+ ] }), e[54] = k, e[55] = r, e[56] = U, e[57] = Z, e[58] = Y) : Y = e[58], Y;
465
+ }, rr = (t) => {
466
+ const e = de(35), {
467
+ formData: r,
468
+ handleFieldChange: a,
469
+ errors: l
470
+ } = t, {
471
+ orgId: o
472
+ } = Ne(), [h, y] = ce(!1);
473
+ let v;
474
+ e[0] !== o ? (v = {
475
+ orgName: o
476
+ }, e[0] = o, e[1] = v) : v = e[1];
477
+ let s;
478
+ e[2] === Symbol.for("react.memo_cache_sentinel") ? (s = {
479
+ limit: 100
480
+ }, e[2] = s) : s = e[2];
481
+ const {
482
+ data: m,
483
+ isLoading: c,
484
+ refetch: d
485
+ } = pn(v, s);
486
+ let p;
487
+ e[3] !== m?.secrets ? (p = m?.secrets || [], e[3] = m?.secrets, e[4] = p) : p = e[4];
488
+ const g = p;
489
+ let i;
490
+ e[5] !== a ? (i = (W) => {
491
+ const $ = W.target.value;
492
+ if ($ === "__create_new__") {
493
+ y(!0);
494
+ return;
495
+ }
496
+ a("gitSecretRef", $ || void 0);
497
+ }, e[5] = a, e[6] = i) : i = e[6];
498
+ const N = i;
499
+ let b;
500
+ e[7] !== a || e[8] !== d ? (b = (W) => {
501
+ a("gitSecretRef", W), d(), y(!1);
502
+ }, e[7] = a, e[8] = d, e[9] = b) : b = e[9];
503
+ const P = b, T = !!l.gitSecretRef, E = r.gitSecretRef || "";
504
+ let k;
505
+ e[10] !== c ? (k = c ? /* @__PURE__ */ n(bt, { size: 20, sx: {
506
+ mr: 1
507
+ } }) : void 0, e[10] = c, e[11] = k) : k = e[11];
508
+ let x;
509
+ e[12] === Symbol.for("react.memo_cache_sentinel") ? (x = /* @__PURE__ */ n(Tt, { value: "", children: /* @__PURE__ */ n("em", { children: "Public Repo (None)" }) }), e[12] = x) : x = e[12];
510
+ let I;
511
+ e[13] !== g ? (I = g.map(ar), e[13] = g, e[14] = I) : I = e[14];
512
+ let V;
513
+ e[15] === Symbol.for("react.memo_cache_sentinel") ? (V = /* @__PURE__ */ n(Tt, { value: "__create_new__", children: /* @__PURE__ */ n(ie, { direction: "row", spacing: 1, alignItems: "center", children: /* @__PURE__ */ n(Ce, { variant: "text", size: "small", startIcon: /* @__PURE__ */ n(St, { size: 16 }), sx: {
514
+ textTransform: "none",
515
+ p: 0
516
+ }, children: "Create new git secret" }) }) }), e[15] = V) : V = e[15];
517
+ let D;
518
+ e[16] !== N || e[17] !== c || e[18] !== I || e[19] !== E || e[20] !== k ? (D = /* @__PURE__ */ S(wn, { id: "gitSecretRef", value: E, onChange: N, displayEmpty: !0, disabled: c, startAdornment: k, children: [
519
+ x,
520
+ I,
521
+ V
522
+ ] }), e[16] = N, e[17] = c, e[18] = I, e[19] = E, e[20] = k, e[21] = D) : D = e[21];
523
+ let A;
524
+ e[22] !== l.gitSecretRef ? (A = l.gitSecretRef ? /* @__PURE__ */ n($t, { error: !0, children: l.gitSecretRef }) : /* @__PURE__ */ n($t, { children: "Select a git secret for private repository authentication" }), e[22] = l.gitSecretRef, e[23] = A) : A = e[23];
525
+ let z;
526
+ e[24] !== D || e[25] !== A || e[26] !== T ? (z = /* @__PURE__ */ n(C.ElementWrapper, { label: "Git Secret (Optional)", name: "gitSecretRef", children: /* @__PURE__ */ S(En, { fullWidth: !0, error: T, children: [
527
+ D,
528
+ A
529
+ ] }) }), e[24] = D, e[25] = A, e[26] = T, e[27] = z) : z = e[27];
530
+ let G;
531
+ e[28] === Symbol.for("react.memo_cache_sentinel") ? (G = () => y(!1), e[28] = G) : G = e[28];
532
+ let R;
533
+ e[29] !== P || e[30] !== h ? (R = /* @__PURE__ */ n(nr, { open: h, onClose: G, onSecretCreated: P }), e[29] = P, e[30] = h, e[31] = R) : R = e[31];
534
+ let w;
535
+ return e[32] !== z || e[33] !== R ? (w = /* @__PURE__ */ S(en, { children: [
536
+ z,
537
+ R
538
+ ] }), e[32] = z, e[33] = R, e[34] = w) : w = e[34], w;
539
+ };
540
+ function ar(t) {
541
+ return /* @__PURE__ */ n(Tt, { value: t.name, children: /* @__PURE__ */ n(O, { children: t.name }) }, t.name);
542
+ }
543
+ function ir(t) {
544
+ return t?.length ? [...t].sort((e, r) => new Date(r.deployedAt ?? 0).getTime() - new Date(e.deployedAt ?? 0).getTime())[0] ?? null : null;
545
+ }
546
+ const Kt = (t) => {
547
+ const e = de(61), {
548
+ provider: r,
549
+ isSelected: a,
550
+ templateInfo: l,
551
+ fallbackLabel: o
552
+ } = t, h = o === void 0 ? "Select provider" : o, y = r?.deployments;
553
+ let v, s, m, c, d, p, g, i, N, b, P;
554
+ if (e[0] !== h || e[1] !== a || e[2] !== r || e[3] !== y || e[4] !== l) {
555
+ const R = ir(y);
556
+ s = ie, N = "row", b = 2, P = 1, m = "center";
557
+ const w = a ? "primary.main" : "secondary.main", W = a ? "common.white" : "text.secondary";
558
+ let $;
559
+ e[16] !== w || e[17] !== W ? ($ = {
560
+ height: 32,
561
+ width: 32,
562
+ backgroundColor: w,
563
+ color: W
564
+ }, e[16] = w, e[17] = W, e[18] = $) : $ = e[18];
565
+ let j;
566
+ e[19] !== a ? (j = a ? /* @__PURE__ */ n(Gn, { size: 16 }) : /* @__PURE__ */ n(qt, { size: 16 }), e[19] = a, e[20] = j) : j = e[20], e[21] !== $ || e[22] !== j ? (c = /* @__PURE__ */ n(Vn, { sx: $, children: j }), e[21] = $, e[22] = j, e[23] = c) : c = e[23], v = ie, d = 0.25, p = 1;
567
+ const B = r?.name ?? h;
568
+ let f;
569
+ e[24] !== B ? (f = /* @__PURE__ */ S(O, { variant: "h6", children: [
570
+ B,
571
+ "  "
572
+ ] }), e[24] = B, e[25] = f) : f = e[25];
573
+ let u;
574
+ e[26] !== r || e[27] !== l ? (u = r?.template && /* @__PURE__ */ n(Mt, { title: "Provider template", placement: "top", arrow: !0, children: /* @__PURE__ */ n(Bt, { label: l?.displayName ?? r.template, size: "small", variant: "outlined", icon: l?.logoUrl ? /* @__PURE__ */ n(re, { component: "img", src: l.logoUrl, alt: l.displayName, sx: {
575
+ width: 14,
576
+ height: 14,
577
+ borderRadius: "100%"
578
+ } }) : void 0 }) }), e[26] = r, e[27] = l, e[28] = u) : u = e[28], e[29] !== f || e[30] !== u ? (g = /* @__PURE__ */ S(ie, { direction: "row", spacing: 0.25, alignItems: "center", children: [
579
+ f,
580
+ u
581
+ ] }), e[29] = f, e[30] = u, e[31] = g) : g = e[31], i = R?.deployedAt && /* @__PURE__ */ S(O, { variant: "caption", color: "text.secondary", children: [
582
+ "Deployed ",
583
+ Sn(new Date(R.deployedAt), {
584
+ addSuffix: !0
585
+ })
586
+ ] }), e[0] = h, e[1] = a, e[2] = r, e[3] = y, e[4] = l, e[5] = v, e[6] = s, e[7] = m, e[8] = c, e[9] = d, e[10] = p, e[11] = g, e[12] = i, e[13] = N, e[14] = b, e[15] = P;
587
+ } else
588
+ v = e[5], s = e[6], m = e[7], c = e[8], d = e[9], p = e[10], g = e[11], i = e[12], N = e[13], b = e[14], P = e[15];
589
+ let T;
590
+ e[32] === Symbol.for("react.memo_cache_sentinel") ? (T = /* @__PURE__ */ n(Gt, { orientation: "vertical" }), e[32] = T) : T = e[32];
591
+ const E = r?.rateLimiting ? "text.primary" : "text.disabled";
592
+ let k;
593
+ e[33] !== r ? (k = r?.rateLimiting ? (() => {
594
+ const R = [], w = r.rateLimiting.providerLevel, W = r.rateLimiting.consumerLevel;
595
+ return w?.requestLimitCount && R.push(`${w.requestLimitCount} req/min`), w?.tokenLimitCount && R.push(`${w.tokenLimitCount} tokens/min`), W?.requestLimitCount && R.push(`Consumer: ${W.requestLimitCount} req/min`), R.length > 0 ? R.join(", ") : "Configured";
596
+ })() : "Not configured", e[33] = r, e[34] = k) : k = e[34];
597
+ let x;
598
+ e[35] !== E || e[36] !== k ? (x = /* @__PURE__ */ S(O, { variant: "caption", color: "text.secondary", children: [
599
+ "Rate Limiting:",
600
+ " ",
601
+ /* @__PURE__ */ n(O, { component: "span", variant: "body2", color: E, children: k })
602
+ ] }), e[35] = E, e[36] = k, e[37] = x) : x = e[37];
603
+ const I = r?.policies?.length ? "text.primary" : "text.disabled";
604
+ let V;
605
+ e[38] !== r ? (V = r?.policies?.length ? /* @__PURE__ */ S(ie, { direction: "row", spacing: 0.25, flexWrap: "wrap", alignItems: "center", children: [
606
+ r.policies.slice(0, 3).map(sr),
607
+ r.policies.length > 3 && /* @__PURE__ */ n(Mt, { title: r.policies.join(", "), placement: "top", arrow: !0, children: /* @__PURE__ */ n(O, { variant: "caption", color: "text.secondary", children: ` +${r.policies.length - 3} more..` }) })
608
+ ] }) : "None", e[38] = r, e[39] = V) : V = e[39];
609
+ let D;
610
+ e[40] !== I || e[41] !== V ? (D = /* @__PURE__ */ S(O, { variant: "caption", color: "text.secondary", children: [
611
+ "Guardrails:",
612
+ " ",
613
+ /* @__PURE__ */ n(O, { component: "span", variant: "body2", color: I, children: V })
614
+ ] }), e[40] = I, e[41] = V, e[42] = D) : D = e[42];
615
+ let A;
616
+ e[43] !== x || e[44] !== D ? (A = /* @__PURE__ */ S(ie, { direction: "column", spacing: 0.25, children: [
617
+ x,
618
+ D
619
+ ] }), e[43] = x, e[44] = D, e[45] = A) : A = e[45];
620
+ let z;
621
+ e[46] !== v || e[47] !== A || e[48] !== d || e[49] !== p || e[50] !== g || e[51] !== i ? (z = /* @__PURE__ */ S(v, { spacing: d, flexGrow: p, children: [
622
+ g,
623
+ i,
624
+ T,
625
+ A
626
+ ] }), e[46] = v, e[47] = A, e[48] = d, e[49] = p, e[50] = g, e[51] = i, e[52] = z) : z = e[52];
627
+ let G;
628
+ return e[53] !== s || e[54] !== m || e[55] !== c || e[56] !== z || e[57] !== N || e[58] !== b || e[59] !== P ? (G = /* @__PURE__ */ S(s, { direction: N, spacing: b, flexGrow: P, alignItems: m, children: [
629
+ c,
630
+ z
631
+ ] }), e[53] = s, e[54] = m, e[55] = c, e[56] = z, e[57] = N, e[58] = b, e[59] = P, e[60] = G) : G = e[60], G;
632
+ }, Fe = /^[A-Za-z_][A-Za-z0-9_]*$/, lr = (t) => {
633
+ const e = de(93), {
634
+ entry: r,
635
+ index: a,
636
+ providers: l,
637
+ templateMap: o,
638
+ environments: h,
639
+ agentNameUpper: y,
640
+ usedVarNames: v,
641
+ onOpenDrawer: s,
642
+ onRemove: m,
643
+ onUpdateEntry: c
644
+ } = t, [d, p] = ce(0), g = h[d]?.name ?? "", i = r.selectedProviderByEnv[g]?.uuid ?? null;
645
+ let N;
646
+ e[0] !== r.selectedProviderByEnv ? (N = Object.values(r.selectedProviderByEnv).find(cr), e[0] = r.selectedProviderByEnv, e[1] = N) : N = e[1];
647
+ const b = N;
648
+ let P;
649
+ e[2] !== b || e[3] !== a || e[4] !== l ? (P = (b ? l.find((J) => J.uuid === b.uuid)?.name : null) ?? `LLM Provider ${a + 1}`, e[2] = b, e[3] = a, e[4] = l, e[5] = P) : P = e[5];
650
+ const T = P;
651
+ let E;
652
+ e[6] === Symbol.for("react.memo_cache_sentinel") ? (E = (J, ee) => p(ee), e[6] = E) : E = e[6];
653
+ const k = E;
654
+ let x;
655
+ e[7] !== a || e[8] !== m ? (x = (J) => {
656
+ J.stopPropagation(), m(a);
657
+ }, e[7] = a, e[8] = m, e[9] = x) : x = e[9];
658
+ const I = x;
659
+ let V;
660
+ e[10] !== a || e[11] !== s || e[12] !== g ? (V = () => s(a, g), e[10] = a, e[11] = s, e[12] = g, e[13] = V) : V = e[13];
661
+ const D = V;
662
+ let A;
663
+ e[14] !== r || e[15] !== a || e[16] !== c ? (A = (J) => {
664
+ const ee = J.target.value;
665
+ ee !== "" && !Fe.test(ee) || c(a, {
666
+ ...r,
667
+ urlVarName: ee
668
+ });
669
+ }, e[14] = r, e[15] = a, e[16] = c, e[17] = A) : A = e[17];
670
+ const z = A;
671
+ let G;
672
+ e[18] !== r || e[19] !== a || e[20] !== c ? (G = (J) => {
673
+ const ee = J.target.value;
674
+ ee !== "" && !Fe.test(ee) || c(a, {
675
+ ...r,
676
+ apikeyVarName: ee
677
+ });
678
+ }, e[18] = r, e[19] = a, e[20] = c, e[21] = G) : G = e[21];
679
+ const R = G;
680
+ let w;
681
+ e[22] !== r || e[23] !== a || e[24] !== c ? (w = (J) => {
682
+ r.guardrails.some((ye) => ye.name === J.name && ye.version === J.version) || c(a, {
683
+ ...r,
684
+ guardrails: [...r.guardrails, J]
685
+ });
686
+ }, e[22] = r, e[23] = a, e[24] = c, e[25] = w) : w = e[25];
687
+ const W = w;
688
+ let $;
689
+ e[26] !== r || e[27] !== a || e[28] !== c ? ($ = (J) => {
690
+ c(a, {
691
+ ...r,
692
+ guardrails: r.guardrails.map((ee) => ee.name === J.name && ee.version === J.version ? J : ee)
693
+ });
694
+ }, e[26] = r, e[27] = a, e[28] = c, e[29] = $) : $ = e[29];
695
+ const j = $;
696
+ let B;
697
+ e[30] !== r || e[31] !== a || e[32] !== c ? (B = (J, ee) => {
698
+ c(a, {
699
+ ...r,
700
+ guardrails: r.guardrails.filter((ye) => !(ye.name === J && ye.version === ee))
701
+ });
702
+ }, e[30] = r, e[31] = a, e[32] = c, e[33] = B) : B = e[33];
703
+ const f = B;
704
+ let u;
705
+ e[34] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ n(Bn, { size: 18 }), e[34] = u) : u = e[34];
706
+ const _ = `llm-provider-${a}-content`, U = `llm-provider-${a}-header`;
707
+ let M;
708
+ e[35] !== T ? (M = /* @__PURE__ */ n(O, { variant: "subtitle2", children: T }), e[35] = T, e[36] = M) : M = e[36];
709
+ let H;
710
+ e[37] === Symbol.for("react.memo_cache_sentinel") ? (H = /* @__PURE__ */ n(qn, { size: 16 }), e[37] = H) : H = e[37];
711
+ let K;
712
+ e[38] !== I ? (K = /* @__PURE__ */ n(Dn, { size: "small", "aria-label": "Remove LLM provider", onClick: I, children: H }), e[38] = I, e[39] = K) : K = e[39];
713
+ let Z;
714
+ e[40] !== M || e[41] !== K ? (Z = /* @__PURE__ */ S(ie, { direction: "row", alignItems: "center", justifyContent: "space-between", flexGrow: 1, pr: 1, children: [
715
+ M,
716
+ K
717
+ ] }), e[40] = M, e[41] = K, e[42] = Z) : Z = e[42];
718
+ let Y;
719
+ e[43] !== _ || e[44] !== U || e[45] !== Z ? (Y = /* @__PURE__ */ n(Rn, { expandIcon: u, "aria-controls": _, id: U, children: Z }), e[43] = _, e[44] = U, e[45] = Z, e[46] = Y) : Y = e[46];
720
+ let L;
721
+ e[47] !== h || e[48] !== d ? (L = h.length > 1 && /* @__PURE__ */ n(In, { value: d, onChange: k, sx: {
722
+ mb: 1
723
+ }, children: h.map(dr) }), e[47] = h, e[48] = d, e[49] = L) : L = e[49];
724
+ let F;
725
+ e[50] !== i || e[51] !== h || e[52] !== D || e[53] !== l || e[54] !== d || e[55] !== g || e[56] !== o ? (F = /* @__PURE__ */ n(re, { children: i ? /* @__PURE__ */ n(C.CardButton, { onClick: D, selected: !0, children: /* @__PURE__ */ n(C.CardContent, { children: /* @__PURE__ */ n(Kt, { provider: l.find((J) => J.uuid === i) ?? null, isSelected: !0, templateInfo: o.get(l.find((J) => J.uuid === i)?.template ?? "") }) }) }) : /* @__PURE__ */ S(Ce, { variant: "outlined", size: "small", startIcon: /* @__PURE__ */ n(St, { size: 16 }), onClick: D, children: [
726
+ "Select Provider for ",
727
+ h[d]?.displayName ?? g
728
+ ] }) }), e[50] = i, e[51] = h, e[52] = D, e[53] = l, e[54] = d, e[55] = g, e[56] = o, e[57] = F) : F = e[57];
729
+ let Q;
730
+ e[58] === Symbol.for("react.memo_cache_sentinel") ? (Q = /* @__PURE__ */ n(O, { variant: "subtitle2", gutterBottom: !0, children: "Environment Variables" }), e[58] = Q) : Q = e[58];
731
+ const X = r.urlVarName ?? `${y}_${a + 1}_URL`, be = `${y}_${a + 1}_URL`;
732
+ let ae;
733
+ e[59] !== r.urlVarName || e[60] !== v ? (ae = r.urlVarName !== void 0 && !Fe.test(r.urlVarName) || r.urlVarName !== void 0 && v.has(r.urlVarName), e[59] = r.urlVarName, e[60] = v, e[61] = ae) : ae = e[61];
734
+ const ke = r.urlVarName !== void 0 && !Fe.test(r.urlVarName) ? "Must match /^[A-Za-z_][A-Za-z0-9_]*$/" : r.urlVarName !== void 0 && v.has(r.urlVarName) ? "Name is already used by another provider" : void 0;
735
+ let he;
736
+ e[62] !== z || e[63] !== X || e[64] !== be || e[65] !== ae || e[66] !== ke ? (he = /* @__PURE__ */ n(C.ElementWrapper, { label: "URL variable name", name: "urlVarName", children: /* @__PURE__ */ n(ne, { size: "small", fullWidth: !0, value: X, onChange: z, placeholder: be, error: ae, helperText: ke }) }), e[62] = z, e[63] = X, e[64] = be, e[65] = ae, e[66] = ke, e[67] = he) : he = e[67];
737
+ const ue = r.apikeyVarName ?? `${y}_${a + 1}_API_KEY`, Ae = `${y}_${a + 1}_API_KEY`;
738
+ let le;
739
+ e[68] !== r.apikeyVarName || e[69] !== v ? (le = r.apikeyVarName !== void 0 && !Fe.test(r.apikeyVarName) || r.apikeyVarName !== void 0 && v.has(r.apikeyVarName), e[68] = r.apikeyVarName, e[69] = v, e[70] = le) : le = e[70];
740
+ const _e = r.apikeyVarName !== void 0 && !Fe.test(r.apikeyVarName) ? "Must match /^[A-Za-z_][A-Za-z0-9_]*$/" : r.apikeyVarName !== void 0 && v.has(r.apikeyVarName) ? "Name is already used by another provider" : void 0;
741
+ let fe;
742
+ e[71] !== R || e[72] !== ue || e[73] !== Ae || e[74] !== le || e[75] !== _e ? (fe = /* @__PURE__ */ n(C.ElementWrapper, { label: "API key variable name", name: "apikeyVarName", children: /* @__PURE__ */ n(ne, { size: "small", fullWidth: !0, value: ue, onChange: R, placeholder: Ae, error: le, helperText: _e }) }), e[71] = R, e[72] = ue, e[73] = Ae, e[74] = le, e[75] = _e, e[76] = fe) : fe = e[76];
743
+ let oe;
744
+ e[77] !== he || e[78] !== fe ? (oe = /* @__PURE__ */ S(re, { children: [
745
+ Q,
746
+ /* @__PURE__ */ S(ie, { direction: "row", spacing: 2, children: [
747
+ he,
748
+ fe
749
+ ] })
750
+ ] }), e[77] = he, e[78] = fe, e[79] = oe) : oe = e[79];
751
+ let se;
752
+ e[80] !== r.guardrails || e[81] !== W || e[82] !== j || e[83] !== f ? (se = /* @__PURE__ */ n(bn, { guardrails: r.guardrails, onAddGuardrail: W, onEditGuardrail: j, onRemoveGuardrail: f }), e[80] = r.guardrails, e[81] = W, e[82] = j, e[83] = f, e[84] = se) : se = e[84];
753
+ let ge;
754
+ e[85] !== L || e[86] !== F || e[87] !== oe || e[88] !== se ? (ge = /* @__PURE__ */ n($n, { children: /* @__PURE__ */ S(ie, { spacing: 3, children: [
755
+ L,
756
+ F,
757
+ oe,
758
+ se
759
+ ] }) }), e[85] = L, e[86] = F, e[87] = oe, e[88] = se, e[89] = ge) : ge = e[89];
760
+ let me;
761
+ return e[90] !== Y || e[91] !== ge ? (me = /* @__PURE__ */ S(Un, { defaultExpanded: !0, children: [
762
+ Y,
763
+ ge
764
+ ] }), e[90] = Y, e[91] = ge, e[92] = me) : me = e[92], me;
765
+ }, or = ({
766
+ llmProviders: t,
767
+ setLLMProviders: e,
768
+ agentDisplayName: r,
769
+ externalEnvKeys: a = /* @__PURE__ */ new Set()
770
+ }) => {
771
+ const {
772
+ orgId: l
773
+ } = Ne(), [o, h] = ce(null), [y, v] = ce(""), [s, m] = ce(!1), [c, d] = ce(""), [p, g] = ce(""), i = zn(null), N = vt(), {
774
+ data: b = [],
775
+ isLoading: P
776
+ } = hn({
777
+ orgName: l
778
+ }), {
779
+ data: T,
780
+ isLoading: E
781
+ } = un({
782
+ orgName: l
783
+ }, {
784
+ limit: 50
785
+ }), {
786
+ data: k,
787
+ isLoading: x
788
+ } = fn({
789
+ orgName: l
790
+ }), I = E || x, V = It(() => {
791
+ const f = /* @__PURE__ */ new Map();
792
+ for (const u of k?.templates ?? [])
793
+ f.set(u.name, {
794
+ displayName: u.name,
795
+ logoUrl: u.metadata?.logoUrl
796
+ }), f.set(u.id, {
797
+ displayName: u.name,
798
+ logoUrl: u.metadata?.logoUrl
799
+ });
800
+ return f;
801
+ }, [k]), D = It(() => (T?.entries ?? []).map((f) => ({
802
+ uuid: f.uuid,
803
+ id: f.handle,
804
+ name: f.name,
805
+ version: f.version,
806
+ template: f.template,
807
+ deployments: f.deployments ?? [],
808
+ security: f.security,
809
+ rateLimiting: f.rateLimiting,
810
+ policies: f.policies ?? []
811
+ })), [T]), A = r ? r.toUpperCase().replace(/[^A-Z0-9]/g, "_") : "AGENT", z = o !== null ? t[o]?.selectedProviderByEnv[y]?.uuid ?? null : null, G = xe((f, u) => {
812
+ h(f), v(u), m(!0);
813
+ }, []), R = xe(() => {
814
+ h(null), m(!0);
815
+ }, []), w = xe(() => {
816
+ i.current && (clearTimeout(i.current), i.current = null), m(!1), d(""), g("");
817
+ }, []), W = xe((f, u) => {
818
+ e((_) => {
819
+ if (o === null) {
820
+ if (b.length === 0) return _;
821
+ const U = {};
822
+ for (const H of b)
823
+ U[H.name] = {
824
+ uuid: f,
825
+ handle: u
826
+ };
827
+ const M = _.length;
828
+ return [..._, {
829
+ selectedProviderByEnv: U,
830
+ urlVarName: `${A}_${M + 1}_URL`,
831
+ apikeyVarName: `${A}_${M + 1}_API_KEY`,
832
+ guardrails: []
833
+ }];
834
+ } else {
835
+ const U = [..._], M = U[o];
836
+ return M ? (U[o] = {
837
+ ...M,
838
+ selectedProviderByEnv: {
839
+ ...M.selectedProviderByEnv,
840
+ [y]: {
841
+ uuid: f,
842
+ handle: u
843
+ }
844
+ }
845
+ }, U) : _;
846
+ }
847
+ }), i.current && (clearTimeout(i.current), i.current = null), m(!1), d(""), g("");
848
+ }, [o, y, b, A, e]), $ = xe((f) => {
849
+ e((u) => u.filter((_, U) => U !== f));
850
+ }, [e]), j = xe((f, u) => {
851
+ e((_) => {
852
+ const U = [..._];
853
+ return U[f] = u, U;
854
+ });
855
+ }, [e]), B = xe((f) => {
856
+ const u = f.target.value;
857
+ d(u), i.current && clearTimeout(i.current), i.current = setTimeout(() => g(u), 250);
858
+ }, []);
859
+ return /* @__PURE__ */ S(C.Section, { children: [
860
+ /* @__PURE__ */ n(C.Subheader, { children: "LLM Providers (Optional)" }),
861
+ /* @__PURE__ */ S(ie, { spacing: 1, children: [
862
+ t.map((f, u) => {
863
+ const _ = /* @__PURE__ */ new Set([...t.flatMap((U, M) => M === u ? [] : [U.urlVarName ?? `${A}_${M + 1}_URL`, U.apikeyVarName ?? `${A}_${M + 1}_API_KEY`]), ...Array.from(a)]);
864
+ return /* @__PURE__ */ n(lr, { entry: f, index: u, providers: D, templateMap: V, environments: b, agentNameUpper: A, usedVarNames: _, onOpenDrawer: G, onRemove: $, onUpdateEntry: j }, u);
865
+ }),
866
+ /* @__PURE__ */ n(re, { sx: {
867
+ pt: t.length > 0 ? 1 : 0
868
+ }, children: /* @__PURE__ */ n(Ce, { variant: "outlined", size: "small", startIcon: /* @__PURE__ */ n(St, { size: 16 }), onClick: R, disabled: P || E, children: "Add" }) })
869
+ ] }),
870
+ /* @__PURE__ */ S(gn, { open: s, onClose: w, minWidth: 740, maxWidth: 740, children: [
871
+ /* @__PURE__ */ n(yn, { icon: /* @__PURE__ */ n(jn, { size: 24 }), title: "Select Provider", onClose: w }),
872
+ /* @__PURE__ */ n(vn, { children: /* @__PURE__ */ S(ie, { children: [
873
+ /* @__PURE__ */ n(O, { variant: "body2", color: "text.secondary", sx: {
874
+ mb: 1
875
+ }, children: o === null ? "Select a provider for this LLM configuration." : "Change the provider for this LLM configuration." }),
876
+ /* @__PURE__ */ n(Tn, { placeholder: "Search providers", size: "small", fullWidth: !0, value: c, onChange: B, sx: {
877
+ mb: 1
878
+ } }),
879
+ /* @__PURE__ */ n(ie, { spacing: 1, sx: {
880
+ flex: 1,
881
+ overflowY: "auto"
882
+ }, children: I ? /* @__PURE__ */ n(re, { sx: {
883
+ display: "flex",
884
+ justifyContent: "center",
885
+ py: 4
886
+ }, children: /* @__PURE__ */ n(bt, { size: 32 }) }) : (() => {
887
+ const f = D.filter((u) => {
888
+ if (!p.trim()) return !0;
889
+ const _ = p.toLowerCase();
890
+ return u.name.toLowerCase().includes(_) || (u.template ?? "").toLowerCase().includes(_) || (V.get(u.template ?? "")?.displayName ?? "").toLowerCase().includes(_);
891
+ });
892
+ if (f.length === 0) {
893
+ const u = !!p.trim();
894
+ return /* @__PURE__ */ n(Ut.Container, { children: /* @__PURE__ */ n(Ut.EmptyState, { illustration: /* @__PURE__ */ n(Fn, { size: 64 }), title: u ? "No LLM Service Providers match your search" : "No LLM Service Providers available", description: u ? "Try a different keyword or clear the search filter." : "No LLM Service Providers found in the catalog. Add LLM service providers from the organization LLM Service Providers page first.", action: !u && l ? /* @__PURE__ */ n(Ce, { variant: "contained", size: "small", startIcon: /* @__PURE__ */ n(Zt, { size: 16 }), onClick: () => N(Se(ve.children.org.children.llmProviders.children.add.path, {
895
+ orgId: l
896
+ })), children: "Add LLM Service Provider" }) : void 0 }) });
897
+ }
898
+ return f.map((u) => {
899
+ const _ = z === u.uuid, U = () => W(u.uuid, u.id);
900
+ return /* @__PURE__ */ n(C.CardButton, { onClick: U, selected: _, "aria-label": `${u.name}. ${_ ? "Selected" : "Click to select"}`, children: /* @__PURE__ */ n(C.CardContent, { children: /* @__PURE__ */ n(Kt, { provider: u, isSelected: _, templateInfo: V.get(u.template ?? "") }) }) }, u.uuid);
901
+ });
902
+ })() })
903
+ ] }) })
904
+ ] })
905
+ ] });
906
+ };
907
+ function sr(t) {
908
+ return /* @__PURE__ */ n(Bt, { label: t, size: "small", variant: "outlined" }, t);
909
+ }
910
+ function cr(t) {
911
+ return t != null;
912
+ }
913
+ function dr(t, e) {
914
+ return /* @__PURE__ */ n(Ln, { label: t.displayName ?? t.name, value: e }, t.name);
915
+ }
916
+ const mr = [{
917
+ label: "Python",
918
+ value: "python"
919
+ }, {
920
+ label: "Docker",
921
+ value: "docker"
922
+ }], pr = (t) => {
923
+ const e = de(179), {
924
+ formData: r,
925
+ setFormData: a,
926
+ errors: l,
927
+ setFieldError: o,
928
+ validateField: h,
929
+ llmProviders: y,
930
+ setLLMProviders: v
931
+ } = t, {
932
+ orgId: s,
933
+ projectId: m
934
+ } = Ne();
935
+ let c;
936
+ e[0] !== s ? (c = {
937
+ orgName: s
938
+ }, e[0] = s, e[1] = c) : c = e[1];
939
+ const {
940
+ mutate: d,
941
+ isPending: p
942
+ } = Wt(c);
943
+ let g;
944
+ e[2] !== o || e[3] !== a || e[4] !== h ? (g = (q, pe) => {
945
+ a((ut) => {
946
+ const Pe = {
947
+ ...ut,
948
+ [q]: pe
949
+ }, Jt = h(q, pe, Pe);
950
+ if (o(q, Jt), q === "language") {
951
+ if (pe === "python") {
952
+ o("dockerfilePath", void 0);
953
+ const _t = h("runCommand", Pe.runCommand, Pe), Xt = h("languageVersion", Pe.languageVersion, Pe);
954
+ o("runCommand", _t), o("languageVersion", Xt);
955
+ } else if (pe === "docker") {
956
+ o("runCommand", void 0), o("languageVersion", void 0);
957
+ const _t = h("dockerfilePath", Pe.dockerfilePath, Pe);
958
+ o("dockerfilePath", _t);
959
+ }
960
+ }
961
+ return Pe;
962
+ });
963
+ }, e[2] = o, e[3] = a, e[4] = h, e[5] = g) : g = e[5];
964
+ const i = g;
965
+ let N;
966
+ e[6] !== d || e[7] !== i || e[8] !== m ? (N = jt.debounce((q) => {
967
+ if (q.length < 3) {
968
+ i("name", "");
969
+ return;
970
+ }
971
+ d({
972
+ displayName: q,
973
+ resourceType: "agent",
974
+ projectName: m
975
+ }, {
976
+ onSuccess: (pe) => {
977
+ i("name", pe.name);
978
+ },
979
+ onError: hr
980
+ });
981
+ }, 500), e[6] = d, e[7] = i, e[8] = m, e[9] = N) : N = e[9];
982
+ const b = N;
983
+ let P, T;
984
+ e[10] !== b ? (P = () => () => {
985
+ b.cancel();
986
+ }, T = [b], e[10] = b, e[11] = P, e[12] = T) : (P = e[11], T = e[12]), yt(P, T);
987
+ let E, k;
988
+ e[13] !== b || e[14] !== r.displayName || e[15] !== i ? (E = () => {
989
+ r.displayName && r.displayName.length >= 3 ? b(r.displayName) : (b.cancel(), i("name", ""));
990
+ }, k = [r.displayName, i, b], e[13] = b, e[14] = r.displayName, e[15] = i, e[16] = E, e[17] = k) : (E = e[16], k = e[17]), yt(E, k);
991
+ let x;
992
+ e[18] === Symbol.for("react.memo_cache_sentinel") ? (x = /* @__PURE__ */ n(C.Subheader, { children: "Agent Details" }), e[18] = x) : x = e[18];
993
+ let I;
994
+ e[19] !== i ? (I = (q) => i("displayName", q.target.value), e[19] = i, e[20] = I) : I = e[20];
995
+ const V = !!l.displayName;
996
+ let D;
997
+ e[21] !== l.displayName || e[22] !== p ? (D = p ? /* @__PURE__ */ S(ie, { direction: "row", alignItems: "center", gap: 1, children: [
998
+ /* @__PURE__ */ n(bt, { size: 12 }),
999
+ /* @__PURE__ */ n(O, { variant: "caption", children: "Validating name..." })
1000
+ ] }) : l.displayName || "A name for your agent", e[21] = l.displayName, e[22] = p, e[23] = D) : D = e[23];
1001
+ let A;
1002
+ e[24] !== r.displayName || e[25] !== V || e[26] !== D || e[27] !== I ? (A = /* @__PURE__ */ n(C.ElementWrapper, { label: "Name", name: "displayName", children: /* @__PURE__ */ n(ne, { id: "displayName", placeholder: "e.g., Customer Support Agent", value: r.displayName, onChange: I, error: V, helperText: D, fullWidth: !0 }) }), e[24] = r.displayName, e[25] = V, e[26] = D, e[27] = I, e[28] = A) : A = e[28];
1003
+ const z = r.description || "";
1004
+ let G;
1005
+ e[29] !== i ? (G = (q) => i("description", q.target.value), e[29] = i, e[30] = G) : G = e[30];
1006
+ const R = !!l.description;
1007
+ let w;
1008
+ e[31] !== l.description || e[32] !== z || e[33] !== G || e[34] !== R ? (w = /* @__PURE__ */ n(C.ElementWrapper, { label: "Description (optional)", name: "description", children: /* @__PURE__ */ n(ne, { id: "description", placeholder: "Short description of what this agent does", multiline: !0, minRows: 2, maxRows: 6, value: z, onChange: G, error: R, helperText: l.description, fullWidth: !0 }) }), e[31] = l.description, e[32] = z, e[33] = G, e[34] = R, e[35] = w) : w = e[35];
1009
+ let W;
1010
+ e[36] !== A || e[37] !== w ? (W = /* @__PURE__ */ S(C.Section, { children: [
1011
+ x,
1012
+ /* @__PURE__ */ S(C.Stack, { spacing: 2, children: [
1013
+ A,
1014
+ w
1015
+ ] })
1016
+ ] }), e[36] = A, e[37] = w, e[38] = W) : W = e[38];
1017
+ let $;
1018
+ e[39] === Symbol.for("react.memo_cache_sentinel") ? ($ = /* @__PURE__ */ n(C.Subheader, { children: "Repository Details" }), e[39] = $) : $ = e[39];
1019
+ let j;
1020
+ e[40] !== i ? (j = (q) => i("repositoryUrl", q.target.value), e[40] = i, e[41] = j) : j = e[41];
1021
+ const B = !!l.repositoryUrl;
1022
+ let f;
1023
+ e[42] !== l.repositoryUrl || e[43] !== r.repositoryUrl || e[44] !== j || e[45] !== B ? (f = /* @__PURE__ */ n(C.ElementWrapper, { label: "GitHub Repository", name: "repositoryUrl", children: /* @__PURE__ */ n(ne, { id: "repositoryUrl", placeholder: "https://github.com/username/repo", value: r.repositoryUrl, onChange: j, error: B, helperText: l.repositoryUrl, fullWidth: !0 }) }), e[42] = l.repositoryUrl, e[43] = r.repositoryUrl, e[44] = j, e[45] = B, e[46] = f) : f = e[46];
1024
+ let u;
1025
+ e[47] !== l || e[48] !== r || e[49] !== i ? (u = /* @__PURE__ */ n(rr, { formData: r, handleFieldChange: i, errors: l }), e[47] = l, e[48] = r, e[49] = i, e[50] = u) : u = e[50];
1026
+ let _;
1027
+ e[51] !== i ? (_ = (q) => i("branch", q.target.value), e[51] = i, e[52] = _) : _ = e[52];
1028
+ const U = !!l.branch;
1029
+ let M;
1030
+ e[53] !== l.branch || e[54] !== r.branch || e[55] !== _ || e[56] !== U ? (M = /* @__PURE__ */ n(C.ElementWrapper, { label: "Branch", name: "branch", children: /* @__PURE__ */ n(ne, { id: "branch", placeholder: "main", value: r.branch, onChange: _, error: U, helperText: l.branch, fullWidth: !0 }) }), e[53] = l.branch, e[54] = r.branch, e[55] = _, e[56] = U, e[57] = M) : M = e[57];
1031
+ let H;
1032
+ e[58] !== i ? (H = (q) => i("appPath", q.target.value), e[58] = i, e[59] = H) : H = e[59];
1033
+ const K = !!l.appPath;
1034
+ let Z;
1035
+ e[60] !== l.appPath || e[61] !== r.appPath || e[62] !== H || e[63] !== K ? (Z = /* @__PURE__ */ n(C.ElementWrapper, { label: "Project Path", name: "appPath", children: /* @__PURE__ */ n(ne, { id: "appPath", placeholder: "my-agent", value: r.appPath, onChange: H, error: K, helperText: l.appPath, fullWidth: !0 }) }), e[60] = l.appPath, e[61] = r.appPath, e[62] = H, e[63] = K, e[64] = Z) : Z = e[64];
1036
+ let Y;
1037
+ e[65] !== M || e[66] !== Z ? (Y = /* @__PURE__ */ S(C.Stack, { direction: "row", spacing: 2, children: [
1038
+ M,
1039
+ Z
1040
+ ] }), e[65] = M, e[66] = Z, e[67] = Y) : Y = e[67];
1041
+ let L;
1042
+ e[68] !== f || e[69] !== u || e[70] !== Y ? (L = /* @__PURE__ */ S(C.Section, { children: [
1043
+ $,
1044
+ /* @__PURE__ */ S(C.Stack, { spacing: 2, children: [
1045
+ f,
1046
+ u,
1047
+ Y
1048
+ ] })
1049
+ ] }), e[68] = f, e[69] = u, e[70] = Y, e[71] = L) : L = e[71];
1050
+ let F;
1051
+ e[72] === Symbol.for("react.memo_cache_sentinel") ? (F = /* @__PURE__ */ n(C.Subheader, { children: "Build Details" }), e[72] = F) : F = e[72];
1052
+ let Q;
1053
+ e[73] !== r.language || e[74] !== i ? (Q = mr.map((q) => {
1054
+ const pe = r.language === q.value;
1055
+ return /* @__PURE__ */ n(C.CardButton, { onClick: () => i("language", q.value), selected: pe, children: /* @__PURE__ */ n(C.CardHeader, { title: /* @__PURE__ */ S(C.Stack, { direction: "row", spacing: 2, justifyContent: "center", alignItems: "center", children: [
1056
+ /* @__PURE__ */ n(Cn, { language: q.value }),
1057
+ /* @__PURE__ */ n(C.Body, { children: q.label })
1058
+ ] }) }) }, q.value);
1059
+ }), e[73] = r.language, e[74] = i, e[75] = Q) : Q = e[75];
1060
+ let X;
1061
+ e[76] !== Q ? (X = /* @__PURE__ */ n(C.Stack, { direction: "row", spacing: 2, children: Q }), e[76] = Q, e[77] = X) : X = e[77];
1062
+ const be = r.language === "python";
1063
+ let ae;
1064
+ e[78] !== i ? (ae = (q) => i("runCommand", q.target.value), e[78] = i, e[79] = ae) : ae = e[79];
1065
+ const ke = !!l.runCommand, he = l.runCommand || "Dependencies auto-install from package.json, requirements.txt, or pyproject.toml";
1066
+ let ue;
1067
+ e[80] !== r.runCommand || e[81] !== ae || e[82] !== ke || e[83] !== he ? (ue = /* @__PURE__ */ n(C.ElementWrapper, { label: "Start Command", name: "runCommand", children: /* @__PURE__ */ n(ne, { id: "runCommand", placeholder: "python main.py", value: r.runCommand, onChange: ae, error: ke, helperText: he, fullWidth: !0 }) }), e[80] = r.runCommand, e[81] = ae, e[82] = ke, e[83] = he, e[84] = ue) : ue = e[84];
1068
+ const Ae = r.languageVersion || "";
1069
+ let le;
1070
+ e[85] !== i ? (le = (q) => i("languageVersion", q.target.value), e[85] = i, e[86] = le) : le = e[86];
1071
+ const _e = !!l.languageVersion, fe = l.languageVersion || "e.g., 3.11, 20, 1.21";
1072
+ let oe;
1073
+ e[87] !== Ae || e[88] !== le || e[89] !== _e || e[90] !== fe ? (oe = /* @__PURE__ */ n(C.ElementWrapper, { label: "Language Version", name: "languageVersion", children: /* @__PURE__ */ n(ne, { id: "languageVersion", placeholder: "3.11", value: Ae, onChange: le, error: _e, helperText: fe, fullWidth: !0 }) }), e[87] = Ae, e[88] = le, e[89] = _e, e[90] = fe, e[91] = oe) : oe = e[91];
1074
+ let se;
1075
+ e[92] !== ue || e[93] !== oe ? (se = /* @__PURE__ */ S(C.Stack, { direction: "row", spacing: 2, children: [
1076
+ ue,
1077
+ oe
1078
+ ] }), e[92] = ue, e[93] = oe, e[94] = se) : se = e[94];
1079
+ const ge = r.enableAutoInstrumentation ?? !0;
1080
+ let me;
1081
+ e[95] !== i ? (me = (q) => i("enableAutoInstrumentation", q.target.checked), e[95] = i, e[96] = me) : me = e[96];
1082
+ let J;
1083
+ e[97] !== ge || e[98] !== me ? (J = /* @__PURE__ */ n(Mn, { control: /* @__PURE__ */ n(On, { checked: ge, onChange: me }), label: "Enable auto instrumentation" }), e[97] = ge, e[98] = me, e[99] = J) : J = e[99];
1084
+ const ee = r.enableAutoInstrumentation !== !1;
1085
+ let ye;
1086
+ e[100] === Symbol.for("react.memo_cache_sentinel") ? (ye = /* @__PURE__ */ n(O, { variant: "body2", color: "text.secondary", children: "Automatically adds OTEL tracing instrumentation to your agent for observability." }), e[100] = ye) : ye = e[100];
1087
+ let Te;
1088
+ e[101] !== ee ? (Te = /* @__PURE__ */ n(Ee, { in: ee, children: ye }), e[101] = ee, e[102] = Te) : Te = e[102];
1089
+ const Ct = r.enableAutoInstrumentation === !1;
1090
+ let Ge, Be;
1091
+ e[103] === Symbol.for("react.memo_cache_sentinel") ? (Ge = {
1092
+ mt: 1
1093
+ }, Be = /* @__PURE__ */ n(O, { variant: "subtitle2", children: "Tracing Support for Python Agents" }), e[103] = Ge, e[104] = Be) : (Ge = e[103], Be = e[104]);
1094
+ let qe;
1095
+ e[105] === Symbol.for("react.memo_cache_sentinel") ? (qe = /* @__PURE__ */ S(O, { variant: "body2", sx: {
1096
+ mt: 1
1097
+ }, children: [
1098
+ "With auto-instrumentation disabled, you can still manually instrument your Python agent using",
1099
+ " ",
1100
+ "your desired instrumentation library."
1101
+ ] }), e[105] = qe) : qe = e[105];
1102
+ let Ze;
1103
+ e[106] === Symbol.for("react.memo_cache_sentinel") ? (Ze = {
1104
+ mt: 1
1105
+ }, e[106] = Ze) : Ze = e[106];
1106
+ let He;
1107
+ e[107] === Symbol.for("react.memo_cache_sentinel") ? (He = /* @__PURE__ */ n(O, { component: "code", sx: {
1108
+ bgcolor: "action.hover",
1109
+ px: 0.5,
1110
+ borderRadius: 0.5
1111
+ }, children: "AMP_OTEL_ENDPOINT" }), e[107] = He) : He = e[107];
1112
+ let Ke;
1113
+ e[108] === Symbol.for("react.memo_cache_sentinel") ? (Ke = /* @__PURE__ */ S(O, { variant: "body2", sx: Ze, children: [
1114
+ "Environment variables provided:",
1115
+ " ",
1116
+ He,
1117
+ ", ",
1118
+ /* @__PURE__ */ n(O, { component: "code", sx: {
1119
+ bgcolor: "action.hover",
1120
+ px: 0.5,
1121
+ borderRadius: 0.5
1122
+ }, children: "AMP_AGENT_API_KEY" })
1123
+ ] }), e[108] = Ke) : Ke = e[108];
1124
+ let Ye;
1125
+ e[109] === Symbol.for("react.memo_cache_sentinel") ? (Ye = /* @__PURE__ */ n(O, { variant: "body2", sx: {
1126
+ mt: 1
1127
+ }, children: "Example configuration:" }), e[109] = Ye) : Ye = e[109];
1128
+ let Qe;
1129
+ e[110] === Symbol.for("react.memo_cache_sentinel") ? (Qe = {
1130
+ mt: 0.5,
1131
+ ml: 1
1132
+ }, e[110] = Qe) : Qe = e[110];
1133
+ let Je;
1134
+ e[111] === Symbol.for("react.memo_cache_sentinel") ? (Je = /* @__PURE__ */ S(O, { variant: "body2", component: "div", sx: Qe, children: [
1135
+ "• OTLP exporter endpoint =",
1136
+ " ",
1137
+ /* @__PURE__ */ n(O, { component: "code", sx: {
1138
+ bgcolor: "action.hover",
1139
+ px: 0.5,
1140
+ borderRadius: 0.5
1141
+ }, children: "AMP_OTEL_ENDPOINT" })
1142
+ ] }), e[111] = Je) : Je = e[111];
1143
+ let Xe;
1144
+ e[112] === Symbol.for("react.memo_cache_sentinel") ? (Xe = {
1145
+ ml: 1
1146
+ }, e[112] = Xe) : Xe = e[112];
1147
+ let et;
1148
+ e[113] === Symbol.for("react.memo_cache_sentinel") ? (et = /* @__PURE__ */ S(we, { severity: "info", sx: Ge, children: [
1149
+ Be,
1150
+ qe,
1151
+ Ke,
1152
+ Ye,
1153
+ Je,
1154
+ /* @__PURE__ */ S(O, { variant: "body2", component: "div", sx: Xe, children: [
1155
+ "• OTLP headers =",
1156
+ " ",
1157
+ /* @__PURE__ */ n(O, { component: "code", sx: {
1158
+ bgcolor: "action.hover",
1159
+ px: 0.5,
1160
+ borderRadius: 0.5
1161
+ }, children: '{"x-amp-api-key": AMP_AGENT_API_KEY}' })
1162
+ ] })
1163
+ ] }), e[113] = et) : et = e[113];
1164
+ let Ie;
1165
+ e[114] !== Ct ? (Ie = /* @__PURE__ */ n(Ee, { in: Ct, children: et }), e[114] = Ct, e[115] = Ie) : Ie = e[115];
1166
+ let Le;
1167
+ e[116] !== be || e[117] !== se || e[118] !== J || e[119] !== Te || e[120] !== Ie ? (Le = /* @__PURE__ */ S(Ee, { in: be, children: [
1168
+ se,
1169
+ J,
1170
+ Te,
1171
+ Ie
1172
+ ] }), e[116] = be, e[117] = se, e[118] = J, e[119] = Te, e[120] = Ie, e[121] = Le) : Le = e[121];
1173
+ const Nt = r.language === "docker", Pt = r.dockerfilePath || "";
1174
+ let Ve;
1175
+ e[122] !== i ? (Ve = (q) => i("dockerfilePath", q.target.value), e[122] = i, e[123] = Ve) : Ve = e[123];
1176
+ const xt = !!l.dockerfilePath, kt = l.dockerfilePath || "Path to Dockerfile in your repository";
1177
+ let De;
1178
+ e[124] !== Pt || e[125] !== Ve || e[126] !== xt || e[127] !== kt ? (De = /* @__PURE__ */ n(C.Stack, { direction: "row", spacing: 2, children: /* @__PURE__ */ n(C.ElementWrapper, { label: "Dockerfile Path", name: "dockerfilePath", children: /* @__PURE__ */ n(ne, { id: "dockerfilePath", placeholder: "e.g., ./Dockerfile", value: Pt, onChange: Ve, error: xt, helperText: kt, fullWidth: !0 }) }) }), e[124] = Pt, e[125] = Ve, e[126] = xt, e[127] = kt, e[128] = De) : De = e[128];
1179
+ let tt;
1180
+ e[129] === Symbol.for("react.memo_cache_sentinel") ? (tt = /* @__PURE__ */ n(O, { variant: "subtitle2", gutterBottom: !0, children: "Tracing Support for Docker-Based Agents" }), e[129] = tt) : tt = e[129];
1181
+ let nt;
1182
+ e[130] === Symbol.for("react.memo_cache_sentinel") ? (nt = /* @__PURE__ */ n(O, { component: "code", sx: {
1183
+ bgcolor: "action.hover",
1184
+ px: 0.5,
1185
+ borderRadius: 0.5
1186
+ }, children: "pip install amp-instrumentation" }), e[130] = nt) : nt = e[130];
1187
+ let rt;
1188
+ e[131] === Symbol.for("react.memo_cache_sentinel") ? (rt = /* @__PURE__ */ S(O, { variant: "body2", paragraph: !0, children: [
1189
+ "Docker-based agents require OTEL instrumentation to export traces. For Python, use",
1190
+ " ",
1191
+ nt,
1192
+ " ",
1193
+ "and run with",
1194
+ " ",
1195
+ /* @__PURE__ */ n(O, { component: "code", sx: {
1196
+ bgcolor: "action.hover",
1197
+ px: 0.5,
1198
+ borderRadius: 0.5
1199
+ }, children: "amp-instrument python your_script.py" }),
1200
+ " ",
1201
+ "for zero-code tracing."
1202
+ ] }), e[131] = rt) : rt = e[131];
1203
+ let at;
1204
+ e[132] === Symbol.for("react.memo_cache_sentinel") ? (at = /* @__PURE__ */ n(O, { component: "code", sx: {
1205
+ bgcolor: "action.hover",
1206
+ px: 0.5,
1207
+ borderRadius: 0.5
1208
+ }, children: "AMP_OTEL_ENDPOINT" }), e[132] = at) : at = e[132];
1209
+ let it;
1210
+ e[133] === Symbol.for("react.memo_cache_sentinel") ? (it = /* @__PURE__ */ S(O, { variant: "body2", gutterBottom: !0, children: [
1211
+ "Environment variables provided:",
1212
+ " ",
1213
+ at,
1214
+ ", ",
1215
+ /* @__PURE__ */ n(O, { component: "code", sx: {
1216
+ bgcolor: "action.hover",
1217
+ px: 0.5,
1218
+ borderRadius: 0.5
1219
+ }, children: "AMP_AGENT_API_KEY" })
1220
+ ] }), e[133] = it) : it = e[133];
1221
+ let lt;
1222
+ e[134] === Symbol.for("react.memo_cache_sentinel") ? (lt = /* @__PURE__ */ n(O, { variant: "body2", sx: {
1223
+ mt: 1
1224
+ }, children: "Example configuration:" }), e[134] = lt) : lt = e[134];
1225
+ let ot;
1226
+ e[135] === Symbol.for("react.memo_cache_sentinel") ? (ot = {
1227
+ mt: 0.5,
1228
+ ml: 1
1229
+ }, e[135] = ot) : ot = e[135];
1230
+ let st;
1231
+ e[136] === Symbol.for("react.memo_cache_sentinel") ? (st = /* @__PURE__ */ S(O, { variant: "body2", component: "div", sx: ot, children: [
1232
+ "• OTLP exporter endpoint =",
1233
+ " ",
1234
+ /* @__PURE__ */ n(O, { component: "code", sx: {
1235
+ bgcolor: "action.hover",
1236
+ px: 0.5,
1237
+ borderRadius: 0.5
1238
+ }, children: "AMP_OTEL_ENDPOINT" })
1239
+ ] }), e[136] = st) : st = e[136];
1240
+ let ct;
1241
+ e[137] === Symbol.for("react.memo_cache_sentinel") ? (ct = {
1242
+ ml: 1
1243
+ }, e[137] = ct) : ct = e[137];
1244
+ let dt;
1245
+ e[138] === Symbol.for("react.memo_cache_sentinel") ? (dt = /* @__PURE__ */ S(we, { severity: "info", children: [
1246
+ tt,
1247
+ rt,
1248
+ it,
1249
+ lt,
1250
+ st,
1251
+ /* @__PURE__ */ S(O, { variant: "body2", component: "div", sx: ct, children: [
1252
+ "• OTLP headers =",
1253
+ " ",
1254
+ /* @__PURE__ */ n(O, { component: "code", sx: {
1255
+ bgcolor: "action.hover",
1256
+ px: 0.5,
1257
+ borderRadius: 0.5
1258
+ }, children: '{"x-amp-api-key": AMP_AGENT_API_KEY}' })
1259
+ ] })
1260
+ ] }), e[138] = dt) : dt = e[138];
1261
+ let Re;
1262
+ e[139] !== De ? (Re = /* @__PURE__ */ S(ie, { spacing: 2, children: [
1263
+ De,
1264
+ dt
1265
+ ] }), e[139] = De, e[140] = Re) : Re = e[140];
1266
+ let $e;
1267
+ e[141] !== Nt || e[142] !== Re ? ($e = /* @__PURE__ */ n(Ee, { in: Nt, children: Re }), e[141] = Nt, e[142] = Re, e[143] = $e) : $e = e[143];
1268
+ let Ue;
1269
+ e[144] !== X || e[145] !== Le || e[146] !== $e ? (Ue = /* @__PURE__ */ S(C.Section, { children: [
1270
+ F,
1271
+ /* @__PURE__ */ S(C.Stack, { spacing: 2, children: [
1272
+ X,
1273
+ Le,
1274
+ $e
1275
+ ] })
1276
+ ] }), e[144] = X, e[145] = Le, e[146] = $e, e[147] = Ue) : Ue = e[147];
1277
+ let Me;
1278
+ e[148] !== l || e[149] !== r || e[150] !== o || e[151] !== a || e[152] !== h ? (Me = /* @__PURE__ */ n(Xn, { formData: r, setFormData: a, errors: l, setFieldError: o, validateField: h }), e[148] = l, e[149] = r, e[150] = o, e[151] = a, e[152] = h, e[153] = Me) : Me = e[153];
1279
+ let Oe;
1280
+ e[154] !== r.env ? (Oe = new Set((r.env ?? []).map(ur).filter(fr)), e[154] = r.env, e[155] = Oe) : Oe = e[155];
1281
+ let ze;
1282
+ e[156] !== r.displayName || e[157] !== y || e[158] !== v || e[159] !== Oe ? (ze = /* @__PURE__ */ n(or, { llmProviders: y, setLLMProviders: v, agentDisplayName: r.displayName, externalEnvKeys: Oe }), e[156] = r.displayName, e[157] = y, e[158] = v, e[159] = Oe, e[160] = ze) : ze = e[160];
1283
+ let mt;
1284
+ e[161] !== r.displayName ? (mt = r.displayName ? r.displayName.toUpperCase().replace(/[^A-Z0-9]/g, "_") : "AGENT", e[161] = r.displayName, e[162] = mt) : mt = e[162];
1285
+ const We = mt;
1286
+ let pt;
1287
+ if (e[163] !== We || e[164] !== y) {
1288
+ let q;
1289
+ e[166] !== We ? (q = (pe, ut) => [pe.urlVarName ?? `${We}_${ut + 1}_URL`, pe.apikeyVarName ?? `${We}_${ut + 1}_API_KEY`], e[166] = We, e[167] = q) : q = e[167], pt = new Set(y.flatMap(q)), e[163] = We, e[164] = y, e[165] = pt;
1290
+ } else
1291
+ pt = e[165];
1292
+ const At = pt;
1293
+ let je;
1294
+ e[168] !== r || e[169] !== a || e[170] !== At ? (je = /* @__PURE__ */ n(er, { formData: r, setFormData: a, llmReservedNames: At }), e[168] = r, e[169] = a, e[170] = At, e[171] = je) : je = e[171];
1295
+ let ht;
1296
+ return e[172] !== W || e[173] !== L || e[174] !== Ue || e[175] !== Me || e[176] !== ze || e[177] !== je ? (ht = /* @__PURE__ */ S(C.Stack, { spacing: 3, children: [
1297
+ W,
1298
+ L,
1299
+ Ue,
1300
+ Me,
1301
+ ze,
1302
+ je
1303
+ ] }), e[172] = W, e[173] = L, e[174] = Ue, e[175] = Me, e[176] = ze, e[177] = je, e[178] = ht) : ht = e[178], ht;
1304
+ };
1305
+ function hr(t) {
1306
+ console.error("Failed to generate name:", t);
1307
+ }
1308
+ function ur(t) {
1309
+ return t.key;
1310
+ }
1311
+ function fr(t) {
1312
+ return !!t;
1313
+ }
1314
+ const Yt = (t) => {
1315
+ const e = de(22), {
1316
+ lastSubmittedValidationErrors: r,
1317
+ isPending: a,
1318
+ onCancel: l,
1319
+ onSubmit: o,
1320
+ mode: h,
1321
+ isNameEmpty: y,
1322
+ hasLLMVarConflicts: v
1323
+ } = t, s = h === void 0 ? "deploy" : h, m = y === void 0 ? !1 : y, c = v === void 0 ? !1 : v, d = s === "connect";
1324
+ let p;
1325
+ e[0] !== r ? (p = Object.values(r), e[0] = r, e[1] = p) : p = e[1];
1326
+ const g = p, i = g.length > 0;
1327
+ let N;
1328
+ e[2] !== g ? (N = /* @__PURE__ */ n(we, { severity: "error", children: g.map(gr) }), e[2] = g, e[3] = N) : N = e[3];
1329
+ let b;
1330
+ e[4] !== i || e[5] !== N ? (b = /* @__PURE__ */ n(Ee, { in: i, timeout: "auto", unmountOnExit: !0, children: N }), e[4] = i, e[5] = N, e[6] = b) : b = e[6];
1331
+ let P;
1332
+ e[7] !== l ? (P = /* @__PURE__ */ n(Ce, { variant: "outlined", color: "primary", size: "medium", onClick: l, children: "Cancel" }), e[7] = l, e[8] = P) : P = e[8];
1333
+ let T;
1334
+ e[9] !== d ? (T = d ? /* @__PURE__ */ n(Zt, { size: 16 }) : /* @__PURE__ */ n(Zn, { size: 16 }), e[9] = d, e[10] = T) : T = e[10];
1335
+ const E = a || m || c, k = d ? "Register" : "Deploy";
1336
+ let x;
1337
+ e[11] !== o || e[12] !== k || e[13] !== T || e[14] !== E ? (x = /* @__PURE__ */ n(Ce, { variant: "contained", color: "primary", size: "medium", startIcon: T, onClick: o, disabled: E, children: k }), e[11] = o, e[12] = k, e[13] = T, e[14] = E, e[15] = x) : x = e[15];
1338
+ let I;
1339
+ e[16] !== x || e[17] !== P ? (I = /* @__PURE__ */ S(re, { display: "flex", flexDirection: "row", gap: 1, alignItems: "center", children: [
1340
+ P,
1341
+ x
1342
+ ] }), e[16] = x, e[17] = P, e[18] = I) : I = e[18];
1343
+ let V;
1344
+ return e[19] !== I || e[20] !== b ? (V = /* @__PURE__ */ S(re, { display: "flex", flexDirection: "column", gap: 3, children: [
1345
+ b,
1346
+ I
1347
+ ] }), e[19] = I, e[20] = b, e[21] = V) : V = e[21], V;
1348
+ };
1349
+ function gr(t, e) {
1350
+ return /* @__PURE__ */ n(re, { children: t }, e);
1351
+ }
1352
+ function yr(t) {
1353
+ const e = {};
1354
+ for (const [a, l] of Object.entries(t.selectedProviderByEnv))
1355
+ l && (e[a] = {
1356
+ providerName: l.handle,
1357
+ configuration: {
1358
+ policies: t.guardrails.length > 0 ? t.guardrails.map((o) => ({
1359
+ name: o.name,
1360
+ version: o.version,
1361
+ paths: [{
1362
+ path: "/*",
1363
+ methods: ["*"],
1364
+ params: o.settings ?? {}
1365
+ }]
1366
+ })) : void 0
1367
+ }
1368
+ });
1369
+ if (Object.keys(e).length === 0) return null;
1370
+ const r = [...t.urlVarName ? [{
1371
+ key: "url",
1372
+ name: t.urlVarName
1373
+ }] : [], ...t.apikeyVarName ? [{
1374
+ key: "apikey",
1375
+ name: t.apikeyVarName
1376
+ }] : []];
1377
+ return {
1378
+ envMappings: e,
1379
+ ...r.length > 0 ? {
1380
+ environmentVariables: r
1381
+ } : {}
1382
+ };
1383
+ }
1384
+ function ft(t) {
1385
+ if (!t.length) return;
1386
+ const e = t.map(yr).filter((r) => r !== null);
1387
+ return e.length > 0 ? e : void 0;
1388
+ }
1389
+ const Qt = (t, e, r = []) => t.deploymentType === "new" ? {
1390
+ params: e,
1391
+ body: {
1392
+ name: t.name,
1393
+ displayName: t.displayName,
1394
+ description: t.description?.trim() || void 0,
1395
+ provisioning: {
1396
+ type: "internal",
1397
+ repository: {
1398
+ url: t.repositoryUrl ?? "",
1399
+ branch: t.branch ?? "main",
1400
+ appPath: t.appPath?.trim() || "/",
1401
+ secretRef: t.gitSecretRef || null
1402
+ }
1403
+ },
1404
+ agentType: {
1405
+ type: "agent-api",
1406
+ subType: t.interfaceType === "CUSTOM" ? "custom-api" : "chat-api"
1407
+ },
1408
+ build: t.language === "docker" ? {
1409
+ type: "docker",
1410
+ docker: {
1411
+ dockerfilePath: t.dockerfilePath ?? "./Dockerfile"
1412
+ }
1413
+ } : {
1414
+ type: "buildpack",
1415
+ buildpack: {
1416
+ language: t.language ?? "python",
1417
+ languageVersion: t.languageVersion ?? "3.11",
1418
+ runCommand: t.runCommand ?? ""
1419
+ }
1420
+ },
1421
+ configurations: {
1422
+ env: t.env.filter((a) => a.key && a.value).map((a) => ({
1423
+ key: a.key.replace(/\s+/g, "_"),
1424
+ value: a.value,
1425
+ isSensitive: a.isSensitive || !1
1426
+ })),
1427
+ enableAutoInstrumentation: t.enableAutoInstrumentation
1428
+ },
1429
+ inputInterface: {
1430
+ type: "HTTP",
1431
+ ...t.interfaceType === "CUSTOM" ? {
1432
+ port: Number(t.port),
1433
+ basePath: t.basePath || "/",
1434
+ schema: {
1435
+ path: t.openApiPath ?? ""
1436
+ }
1437
+ } : {}
1438
+ },
1439
+ ...ft(r) ? {
1440
+ modelConfig: ft(r)
1441
+ } : {}
1442
+ }
1443
+ } : {
1444
+ params: e,
1445
+ body: {
1446
+ name: t.name,
1447
+ displayName: t.displayName,
1448
+ description: t.description,
1449
+ provisioning: {
1450
+ type: "external"
1451
+ },
1452
+ agentType: {
1453
+ type: "external-agent-api",
1454
+ subType: "custom-api"
1455
+ },
1456
+ ...ft(r) ? {
1457
+ modelConfig: ft(r)
1458
+ } : {}
1459
+ }
1460
+ }, vr = () => {
1461
+ const t = de(57), e = vt(), {
1462
+ orgId: r,
1463
+ projectId: a
1464
+ } = Ne();
1465
+ let l;
1466
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (l = {
1467
+ deploymentType: "new",
1468
+ enableAutoInstrumentation: !0,
1469
+ name: "",
1470
+ displayName: "",
1471
+ description: "",
1472
+ repositoryUrl: "",
1473
+ branch: "main",
1474
+ appPath: "/",
1475
+ runCommand: "python main.py",
1476
+ language: "python",
1477
+ languageVersion: "3.11",
1478
+ dockerfilePath: "/Dockerfile",
1479
+ interfaceType: "DEFAULT",
1480
+ port: "",
1481
+ basePath: "/",
1482
+ openApiPath: "",
1483
+ env: []
1484
+ }, t[0] = l) : l = t[0];
1485
+ const [o, h] = ce(l), {
1486
+ errors: y,
1487
+ validateForm: v,
1488
+ setFieldError: s,
1489
+ validateField: m
1490
+ } = Vt(Qn);
1491
+ let c;
1492
+ t[1] === Symbol.for("react.memo_cache_sentinel") ? (c = [], t[1] = c) : c = t[1];
1493
+ const [d, p] = ce(c), {
1494
+ mutate: g,
1495
+ isPending: i,
1496
+ error: N
1497
+ } = Ft(), b = r ?? "default", P = a ?? "default";
1498
+ let T;
1499
+ t[2] !== b || t[3] !== P ? (T = {
1500
+ orgName: b,
1501
+ projName: P
1502
+ }, t[2] = b, t[3] = P, t[4] = T) : T = t[4];
1503
+ const E = T;
1504
+ let k;
1505
+ t[5] !== e || t[6] !== r || t[7] !== a ? (k = () => {
1506
+ e(Se(ve.children.org.children.projects.path, {
1507
+ orgId: r ?? "",
1508
+ projectId: a ?? "default"
1509
+ }));
1510
+ }, t[5] = e, t[6] = r, t[7] = a, t[8] = k) : k = t[8];
1511
+ const x = k;
1512
+ let I;
1513
+ t[9] === Symbol.for("react.memo_cache_sentinel") ? (I = {}, t[9] = I) : I = t[9];
1514
+ const [V, D] = ce(I);
1515
+ let A;
1516
+ t[10] !== g || t[11] !== y || t[12] !== o || t[13] !== d || t[14] !== e || t[15] !== E || t[16] !== v ? (A = () => {
1517
+ if (v(o))
1518
+ D({});
1519
+ else {
1520
+ D(y);
1521
+ return;
1522
+ }
1523
+ const M = Qt(o, E, d);
1524
+ g(M, {
1525
+ onSuccess: () => {
1526
+ e(Se(ve.children.org.children.projects.children.agents.path, {
1527
+ orgId: E.orgName ?? "",
1528
+ projectId: E.projName ?? "",
1529
+ agentId: M.body.name
1530
+ }) + "?setup=true");
1531
+ },
1532
+ onError: br
1533
+ });
1534
+ }, t[10] = g, t[11] = y, t[12] = o, t[13] = d, t[14] = e, t[15] = E, t[16] = v, t[17] = A) : A = t[17];
1535
+ const z = A, G = r ?? "", R = a ?? "default";
1536
+ let w;
1537
+ t[18] !== G || t[19] !== R ? (w = Se(ve.children.org.children.projects.children.newAgent.path, {
1538
+ orgId: G,
1539
+ projectId: R
1540
+ }), t[18] = G, t[19] = R, t[20] = w) : w = t[20];
1541
+ const W = w;
1542
+ let $;
1543
+ t[21] !== y || t[22] !== o || t[23] !== d || t[24] !== s || t[25] !== m ? ($ = /* @__PURE__ */ n(pr, { formData: o, setFormData: h, errors: y, setFieldError: s, validateField: m, llmProviders: d, setLLMProviders: p }), t[21] = y, t[22] = o, t[23] = d, t[24] = s, t[25] = m, t[26] = $) : $ = t[26];
1544
+ let j;
1545
+ t[27] !== N ? (j = !!N && /* @__PURE__ */ n(we, { severity: "error", sx: {
1546
+ mt: 2
1547
+ }, children: N instanceof Error ? N.message : "Failed to create agent" }), t[27] = N, t[28] = j) : j = t[28];
1548
+ const B = !o.name.trim();
1549
+ let f;
1550
+ e: {
1551
+ let M;
1552
+ t[29] !== o.displayName ? (M = o.displayName ? o.displayName.toUpperCase().replace(/[^A-Z0-9]/g, "_") : "AGENT", t[29] = o.displayName, t[30] = M) : M = t[30];
1553
+ const H = M;
1554
+ let K, Z;
1555
+ if (t[31] !== H || t[32] !== d) {
1556
+ let F;
1557
+ t[35] !== H ? (F = (Q, X) => [Q.urlVarName ?? `${H}_${X + 1}_URL`, Q.apikeyVarName ?? `${H}_${X + 1}_API_KEY`], t[35] = H, t[36] = F) : F = t[36], K = d.flatMap(F), Z = new Set(K), t[31] = H, t[32] = d, t[33] = K, t[34] = Z;
1558
+ } else
1559
+ K = t[33], Z = t[34];
1560
+ const Y = Z;
1561
+ if (K.length !== Y.size) {
1562
+ f = !0;
1563
+ break e;
1564
+ }
1565
+ let L;
1566
+ if (t[37] !== o.env || t[38] !== Y) {
1567
+ const F = (o.env ?? []).map(Sr).filter(Cr);
1568
+ if (F.length !== new Set(F).size) {
1569
+ f = !0;
1570
+ break e;
1571
+ }
1572
+ let Q;
1573
+ t[41] !== Y ? (Q = (X) => Y.has(X), t[41] = Y, t[42] = Q) : Q = t[42], L = F.some(Q), t[37] = o.env, t[38] = Y, t[39] = L, t[40] = f;
1574
+ } else
1575
+ L = t[39], f = t[40];
1576
+ f = L;
1577
+ }
1578
+ let u;
1579
+ t[43] !== x || t[44] !== z || t[45] !== i || t[46] !== V || t[47] !== B || t[48] !== f ? (u = /* @__PURE__ */ n(Yt, { lastSubmittedValidationErrors: V, isPending: i, onCancel: x, onSubmit: z, isNameEmpty: B, mode: "deploy", hasLLMVarConflicts: f }), t[43] = x, t[44] = z, t[45] = i, t[46] = V, t[47] = B, t[48] = f, t[49] = u) : u = t[49];
1580
+ let _;
1581
+ t[50] !== $ || t[51] !== j || t[52] !== u ? (_ = /* @__PURE__ */ S(C.Stack, { spacing: 3, children: [
1582
+ $,
1583
+ j,
1584
+ u
1585
+ ] }), t[50] = $, t[51] = j, t[52] = u, t[53] = _) : _ = t[53];
1586
+ let U;
1587
+ return t[54] !== W || t[55] !== _ ? (U = /* @__PURE__ */ n(Lt, { title: "Create a Platform-Hosted Agent", description: "Specify the source repository, select the agent type, and deploy it on the platform.", disableIcon: !0, backHref: W, backLabel: "Back to Agent Hosting Options", children: _ }), t[54] = W, t[55] = _, t[56] = U) : U = t[56], U;
1588
+ };
1589
+ function br(t) {
1590
+ console.error("Failed to create agent:", t);
1591
+ }
1592
+ function Sr(t) {
1593
+ return t.key;
1594
+ }
1595
+ function Cr(t) {
1596
+ return !!t;
1597
+ }
1598
+ const Nr = ({
1599
+ formData: t,
1600
+ setFormData: e,
1601
+ errors: r,
1602
+ setFieldError: a,
1603
+ validateField: l
1604
+ }) => {
1605
+ const {
1606
+ orgId: o,
1607
+ projectId: h
1608
+ } = Ne(), {
1609
+ mutate: y,
1610
+ isPending: v
1611
+ } = Wt({
1612
+ orgName: o
1613
+ }), s = xe((c, d) => {
1614
+ e((p) => {
1615
+ const g = {
1616
+ ...p,
1617
+ [c]: d
1618
+ }, i = l(c, d, g);
1619
+ return a(c, i), g;
1620
+ });
1621
+ }, [e, l, a]), m = It(
1622
+ () => jt.debounce((c) => {
1623
+ if (c.length < 3) {
1624
+ s("name", "");
1625
+ return;
1626
+ }
1627
+ y({
1628
+ displayName: c,
1629
+ resourceType: "agent",
1630
+ projectName: h
1631
+ }, {
1632
+ onSuccess: (d) => {
1633
+ s("name", d.name);
1634
+ },
1635
+ onError: (d) => {
1636
+ console.error("Failed to generate name:", d);
1637
+ }
1638
+ });
1639
+ }, 500),
1640
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1641
+ [y, h, o, s]
1642
+ );
1643
+ return yt(() => () => {
1644
+ m.cancel();
1645
+ }, [m]), yt(() => {
1646
+ t.displayName && t.displayName.length >= 3 ? m(t.displayName) : (m.cancel(), s("name", ""));
1647
+ }, [t.displayName, m, s]), /* @__PURE__ */ n(C.Stack, { spacing: 3, children: /* @__PURE__ */ S(C.Section, { children: [
1648
+ /* @__PURE__ */ n(C.Subheader, { children: "Agent Details" }),
1649
+ /* @__PURE__ */ S(C.Stack, { spacing: 2, children: [
1650
+ /* @__PURE__ */ n(C.ElementWrapper, { label: "Name", name: "displayName", children: /* @__PURE__ */ n(ne, { id: "displayName", placeholder: "e.g., Customer Support", value: t.displayName, onChange: (c) => s("displayName", c.target.value), error: !!r.displayName, helperText: v ? /* @__PURE__ */ S(ie, { direction: "row", alignItems: "center", gap: 1, children: [
1651
+ /* @__PURE__ */ n(bt, { size: 12 }),
1652
+ /* @__PURE__ */ n(O, { variant: "caption", children: "Validating name..." })
1653
+ ] }) : r.displayName, fullWidth: !0 }) }),
1654
+ /* @__PURE__ */ n(C.ElementWrapper, { label: "Description (optional)", name: "description", children: /* @__PURE__ */ n(ne, { id: "description", placeholder: "Short description of what this agent does", multiline: !0, minRows: 2, maxRows: 6, value: t.description || "", onChange: (c) => s("description", c.target.value), error: !!r.description, helperText: r.description, fullWidth: !0 }) })
1655
+ ] })
1656
+ ] }) });
1657
+ }, Pr = () => {
1658
+ const t = de(41), e = vt(), {
1659
+ orgId: r,
1660
+ projectId: a
1661
+ } = Ne();
1662
+ let l;
1663
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (l = {
1664
+ deploymentType: "existing",
1665
+ name: "",
1666
+ displayName: "",
1667
+ description: ""
1668
+ }, t[0] = l) : l = t[0];
1669
+ const [o, h] = ce(l), {
1670
+ errors: y,
1671
+ validateForm: v,
1672
+ setFieldError: s,
1673
+ validateField: m
1674
+ } = Vt(Yn), {
1675
+ mutate: c,
1676
+ isPending: d,
1677
+ error: p
1678
+ } = Ft(), g = r ?? "default", i = a ?? "default";
1679
+ let N;
1680
+ t[1] !== g || t[2] !== i ? (N = {
1681
+ orgName: g,
1682
+ projName: i
1683
+ }, t[1] = g, t[2] = i, t[3] = N) : N = t[3];
1684
+ const b = N;
1685
+ let P;
1686
+ t[4] !== e || t[5] !== r || t[6] !== a ? (P = () => {
1687
+ e(Se(ve.children.org.children.projects.path, {
1688
+ orgId: r ?? "",
1689
+ projectId: a ?? "default"
1690
+ }));
1691
+ }, t[4] = e, t[5] = r, t[6] = a, t[7] = P) : P = t[7];
1692
+ const T = P;
1693
+ let E;
1694
+ t[8] !== c || t[9] !== e || t[10] !== b ? (E = (_) => {
1695
+ const U = Qt(_, b);
1696
+ c(U, {
1697
+ onSuccess: () => {
1698
+ e(Se(ve.children.org.children.projects.children.agents.path, {
1699
+ orgId: b.orgName ?? "",
1700
+ projectId: b.projName ?? "",
1701
+ agentId: U.body.name
1702
+ }) + "?setup=true");
1703
+ },
1704
+ onError: xr
1705
+ });
1706
+ }, t[8] = c, t[9] = e, t[10] = b, t[11] = E) : E = t[11];
1707
+ const k = E;
1708
+ let x;
1709
+ t[12] === Symbol.for("react.memo_cache_sentinel") ? (x = {}, t[12] = x) : x = t[12];
1710
+ const [I, V] = ce(x);
1711
+ let D;
1712
+ t[13] !== y || t[14] !== o || t[15] !== k || t[16] !== v ? (D = () => {
1713
+ if (v(o))
1714
+ V({});
1715
+ else {
1716
+ V(y);
1717
+ return;
1718
+ }
1719
+ k(o);
1720
+ }, t[13] = y, t[14] = o, t[15] = k, t[16] = v, t[17] = D) : D = t[17];
1721
+ const A = D, z = r ?? "", G = a ?? "default";
1722
+ let R;
1723
+ t[18] !== z || t[19] !== G ? (R = Se(ve.children.org.children.projects.children.newAgent.path, {
1724
+ orgId: z,
1725
+ projectId: G
1726
+ }), t[18] = z, t[19] = G, t[20] = R) : R = t[20];
1727
+ const w = R;
1728
+ let W;
1729
+ t[21] !== y || t[22] !== o || t[23] !== s || t[24] !== m ? (W = /* @__PURE__ */ n(Nr, { formData: o, setFormData: h, errors: y, setFieldError: s, validateField: m }), t[21] = y, t[22] = o, t[23] = s, t[24] = m, t[25] = W) : W = t[25];
1730
+ let $;
1731
+ t[26] !== p ? ($ = !!p && /* @__PURE__ */ n(we, { severity: "error", sx: {
1732
+ mt: 2
1733
+ }, children: p instanceof Error ? p.message : "Failed to register agent" }), t[26] = p, t[27] = $) : $ = t[27];
1734
+ const j = !o.name.trim();
1735
+ let B;
1736
+ t[28] !== T || t[29] !== A || t[30] !== d || t[31] !== I || t[32] !== j ? (B = /* @__PURE__ */ n(Yt, { lastSubmittedValidationErrors: I, isPending: d, onCancel: T, onSubmit: A, isNameEmpty: j, mode: "connect" }), t[28] = T, t[29] = A, t[30] = d, t[31] = I, t[32] = j, t[33] = B) : B = t[33];
1737
+ let f;
1738
+ t[34] !== W || t[35] !== $ || t[36] !== B ? (f = /* @__PURE__ */ S(C.Stack, { spacing: 3, children: [
1739
+ W,
1740
+ $,
1741
+ B
1742
+ ] }), t[34] = W, t[35] = $, t[36] = B, t[37] = f) : f = t[37];
1743
+ let u;
1744
+ return t[38] !== w || t[39] !== f ? (u = /* @__PURE__ */ n(Lt, { title: "Register an Externally-Hosted Agent", description: "Provide basic information to register your externally-hosted agent on the platform.", disableIcon: !0, backHref: w, backLabel: "Back to Agent Hosting Options", children: f }), t[38] = w, t[39] = f, t[40] = u) : u = t[40], u;
1745
+ };
1746
+ function xr(t) {
1747
+ console.error("Failed to register agent:", t);
1748
+ }
1749
+ const kr = () => {
1750
+ const t = de(10), e = vt(), {
1751
+ orgId: r,
1752
+ projectId: a
1753
+ } = Ne(), l = ve.children.org.children.projects.children.newAgent, o = l.children.create.path, h = l.children.connect.path;
1754
+ let y;
1755
+ t[0] !== e || t[1] !== r || t[2] !== a ? (y = (p) => {
1756
+ e(Se(p === "new" ? o : h, {
1757
+ orgId: r ?? "",
1758
+ projectId: a ?? "default"
1759
+ }));
1760
+ }, t[0] = e, t[1] = r, t[2] = a, t[3] = y) : y = t[3];
1761
+ const v = y;
1762
+ let s;
1763
+ t[4] !== v ? (s = /* @__PURE__ */ n(Et, { index: !0, element: /* @__PURE__ */ n(Kn, { onSelect: v }) }), t[4] = v, t[5] = s) : s = t[5];
1764
+ let m;
1765
+ t[6] === Symbol.for("react.memo_cache_sentinel") ? (m = /* @__PURE__ */ n(Et, { path: "create", element: /* @__PURE__ */ n(vr, {}) }), t[6] = m) : m = t[6];
1766
+ let c;
1767
+ t[7] === Symbol.for("react.memo_cache_sentinel") ? (c = /* @__PURE__ */ n(Et, { path: "connect", element: /* @__PURE__ */ n(Pr, {}) }), t[7] = c) : c = t[7];
1768
+ let d;
1769
+ return t[8] !== s ? (d = /* @__PURE__ */ S(tn, { children: [
1770
+ s,
1771
+ m,
1772
+ c
1773
+ ] }), t[8] = s, t[9] = d) : d = t[9], d;
1774
+ }, Dr = {
1775
+ title: "Add New Agent",
1776
+ description: "A page component for Add New Agent",
1777
+ icon: Hn,
1778
+ path: ve.children.org.children.projects.children.newAgent.path,
1779
+ component: kr
1780
+ };
1781
+ export {
1782
+ kr as AddNewAgent,
1783
+ Dr as metaData
1784
+ };