@wso2/am-core-ui 0.0.1 → 0.0.2

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 nn } from "react/jsx-runtime";
2
+ import { c as he } from "react/compiler-runtime";
3
+ import { useParams as Ce, generatePath as be, useNavigate as bt, Route as Tt, Routes as rn } from "react-router-dom";
4
+ import { u as an, g as ve, E as ln, I as on, P as Dt, o as yt, a as sn, b as $t, s as te, c as cn, _ as dn, l as jt, n as mn, d as pn, e as Ut, f as Rt, h as hn, i as un, j as fn, k as gn, m as yn, D as vn, p as bn, q as Sn, G as Cn, r as Nn, t as Pn, v as Ft, w as Gt, B as xn, x as Bt } from "./index-DbDfhpO7.js";
5
+ import { Form as C, Typography as z, Box as re, Divider as qt, TextField as ne, Alert as we, Collapse as Ee, Card as kn, CardContent as An, Button as Se, DialogContent as _n, DialogTitle as En, DialogActions as wn, Dialog as Tn, FormHelperText as Mt, FormControl as In, MenuItem as Lt, CircularProgress as St, Stack as ie, Select as Ln, SearchBar as Vn, ListingTable as Ot, Tabs as Dn, Tooltip as zt, Chip as Zt, Tab as Rn, Avatar as $n, IconButton as Un, AccordionSummary as Mn, AccordionDetails as On, Accordion as zn, FormControlLabel as Wn, Checkbox as jn } from "@wso2/oxygen-ui";
6
+ import "@tanstack/react-query";
7
+ import { useState as de, useRef as Fn, useMemo as Vt, useCallback as Pe, useEffect as vt } from "react";
8
+ import { CheckCircle as Gn, Circle as Ht, Plus as Ct, DoorClosedLocked as Bn, Link as Kt, Search as qn, Check as Zn, ChevronDown as Hn, Trash2 as Kn, Rocket as Yn, UserPlus as Qn } from "@wso2/oxygen-ui-icons-react";
9
+ const Wt = (t) => {
10
+ const e = he(18), {
11
+ type: r,
12
+ title: a,
13
+ subheader: i,
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(z, { 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] !== i ? (p = /* @__PURE__ */ n(z, { variant: "body2", textAlign: "center", children: i }), e[9] = i, 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 b;
47
+ return e[14] !== v || e[15] !== m || e[16] !== g ? (b = /* @__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] = b) : b = e[17], b;
51
+ }, Jn = (t) => {
52
+ const e = he(20), {
53
+ onSelect: r
54
+ } = t, {
55
+ orgId: a,
56
+ projectId: i
57
+ } = Ce(), o = a ?? "default", h = i ?? "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
+ } = an(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 ?? "", A = i ?? "default";
78
+ let k;
79
+ e[5] !== E || e[6] !== A ? (k = be(ve.children.org.children.projects.path, {
80
+ orgId: E,
81
+ projectId: A
82
+ }), e[5] = E, e[6] = A, e[7] = k) : k = e[7], d = k;
83
+ }
84
+ const p = d;
85
+ let g;
86
+ e[8] === Symbol.for("react.memo_cache_sentinel") ? (g = /* @__PURE__ */ n(ln, { width: 150 }), e[8] = g) : g = e[8];
87
+ let b;
88
+ e[9] !== m ? (b = /* @__PURE__ */ n(Wt, { 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] = b) : b = e[10];
89
+ let N;
90
+ e[11] === Symbol.for("react.memo_cache_sentinel") ? (N = /* @__PURE__ */ n(on, { width: 150 }), e[11] = N) : N = e[11];
91
+ let l;
92
+ e[12] !== m ? (l = /* @__PURE__ */ n(Wt, { 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] = l) : l = e[13];
93
+ let P;
94
+ e[14] !== b || e[15] !== l ? (P = /* @__PURE__ */ S(re, { display: "flex", flexDirection: "row", gap: 3, width: 1, children: [
95
+ b,
96
+ l
97
+ ] }), e[14] = b, e[15] = l, e[16] = P) : P = e[16];
98
+ let x;
99
+ return e[17] !== p || e[18] !== P ? (x = /* @__PURE__ */ n(Dt, { 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] = x) : x = e[19], x;
100
+ }, Yt = {
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
+ }, Xn = yt({
105
+ ...Yt,
106
+ deploymentType: jt("existing").optional()
107
+ }), er = yt({
108
+ ...Yt,
109
+ deploymentType: jt("new").optional(),
110
+ enableAutoInstrumentation: $t().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: dn(["DEFAULT", "CUSTOM"]),
128
+ port: cn([mn(), te(), pn()]).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: sn(yt({
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: $t().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
+ }), tr = [{
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
+ }], nr = (t) => {
174
+ const e = he(57), {
175
+ formData: r,
176
+ setFormData: a,
177
+ errors: i,
178
+ setFieldError: o,
179
+ validateField: h
180
+ } = t;
181
+ let y;
182
+ e[0] !== o || e[1] !== a || e[2] !== h ? (y = (L, W) => {
183
+ let K = null;
184
+ if (a((ee) => (K = {
185
+ ...ee,
186
+ [L]: W
187
+ }, K)), K) {
188
+ const ee = h(L, W, K);
189
+ o(L, ee);
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((W) => ({
196
+ ...W,
197
+ interfaceType: L,
198
+ ...L === "DEFAULT" ? {
199
+ openApiPath: "",
200
+ port: "",
201
+ basePath: "/"
202
+ } : {}
203
+ })), a((W) => {
204
+ const K = h("interfaceType", L, W);
205
+ if (o("interfaceType", K), L === "CUSTOM") {
206
+ const ee = h("port", W.port, W);
207
+ o("port", ee);
208
+ const me = h("openApiPath", W.openApiPath, W);
209
+ o("openApiPath", me);
210
+ const ae = h("basePath", W.basePath, W);
211
+ o("basePath", ae);
212
+ } else
213
+ o("port", void 0), o("openApiPath", void 0), o("basePath", void 0);
214
+ return W;
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 W = L.target.value;
221
+ /^\d*$/.test(W) && v("port", W === "" ? "" : Number(W));
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(z, { 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 b;
227
+ e[12] !== r.interfaceType || e[13] !== m ? (b = tr.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(Gn, { size: 16 }) : /* @__PURE__ */ n(Ht, { size: 16 }) }),
234
+ /* @__PURE__ */ n(qt, { orientation: "vertical", flexItem: !0 }),
235
+ /* @__PURE__ */ S(re, { children: [
236
+ /* @__PURE__ */ n(z, { variant: "h6", children: L.label }),
237
+ /* @__PURE__ */ n(z, { variant: "caption", children: L.description })
238
+ ] })
239
+ ] }) }) }, L.value)), e[12] = r.interfaceType, e[13] = m, e[14] = b) : b = e[14];
240
+ let N;
241
+ e[15] !== b ? (N = /* @__PURE__ */ n(re, { display: "flex", flexDirection: "row", gap: 1, children: b }), e[15] = b, e[16] = N) : N = e[16];
242
+ const l = 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 x, E;
246
+ e[18] === Symbol.for("react.memo_cache_sentinel") ? (x = /* @__PURE__ */ n("strong", { children: "8000" }), E = /* @__PURE__ */ n("br", {}), e[18] = x, e[19] = E) : (x = e[18], E = e[19]);
247
+ let A, k;
248
+ e[20] === Symbol.for("react.memo_cache_sentinel") ? (A = /* @__PURE__ */ n("code", { children: "{message: string, session_id: string, context: JSON}" }), k = /* @__PURE__ */ n("br", {}), e[20] = A, e[21] = k) : (A = e[20], k = e[21]);
249
+ let V;
250
+ e[22] === Symbol.for("react.memo_cache_sentinel") ? (V = /* @__PURE__ */ S(we, { severity: "info", children: [
251
+ "Uses the standard chat interface: ",
252
+ P,
253
+ " on port ",
254
+ x,
255
+ E,
256
+ "Request:",
257
+ " ",
258
+ A,
259
+ k,
260
+ "Response: ",
261
+ /* @__PURE__ */ n("code", { children: "{response: string}" })
262
+ ] }), e[22] = V) : V = e[22];
263
+ let T;
264
+ e[23] !== l ? (T = /* @__PURE__ */ n(Ee, { in: l, children: V }), e[23] = l, e[24] = T) : T = e[24];
265
+ const D = r.interfaceType === "CUSTOM", I = r.openApiPath || "";
266
+ let $;
267
+ e[25] !== v ? ($ = (L) => v("openApiPath", L.target.value), e[25] = v, e[26] = $) : $ = e[26];
268
+ const G = !!i.openApiPath, U = i.openApiPath || "Path to OpenAPI schema file in your repository";
269
+ let w;
270
+ e[27] !== I || e[28] !== $ || e[29] !== G || e[30] !== U ? (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: I, onChange: $, error: G, helperText: U, fullWidth: !0 }) }) }), e[27] = I, e[28] = $, e[29] = G, e[30] = U, e[31] = w) : w = e[31];
271
+ const B = r.port ?? "", M = !!i.port, j = i.port || (r.port ? void 0 : "Port is required");
272
+ let F;
273
+ e[32] !== d || e[33] !== B || e[34] !== M || e[35] !== j ? (F = /* @__PURE__ */ n(re, { children: /* @__PURE__ */ n(C.ElementWrapper, { label: "Port", name: "port", children: /* @__PURE__ */ n(ne, { id: "port", placeholder: "8080", required: !0, value: B, onChange: d, type: "number", error: M, helperText: j }) }) }), e[32] = d, e[33] = B, e[34] = M, e[35] = j, e[36] = F) : F = e[36];
274
+ let u;
275
+ e[37] !== w || e[38] !== F ? (u = /* @__PURE__ */ S(C.Stack, { direction: "row", spacing: 2, children: [
276
+ w,
277
+ F
278
+ ] }), e[37] = w, e[38] = F, e[39] = u) : u = e[39];
279
+ const f = r.basePath || "";
280
+ let _;
281
+ e[40] !== v ? (_ = (L) => v("basePath", L.target.value), e[40] = v, e[41] = _) : _ = e[41];
282
+ const R = !!i.basePath, O = i.basePath || "API base path (e.g., / or /api/v1)";
283
+ let Y;
284
+ e[42] !== f || e[43] !== _ || e[44] !== R || e[45] !== O ? (Y = /* @__PURE__ */ n(C.ElementWrapper, { label: "Base Path", name: "basePath", children: /* @__PURE__ */ n(ne, { id: "basePath", placeholder: "/", required: !0, value: f, onChange: _, error: R, helperText: O, fullWidth: !0 }) }), e[42] = f, e[43] = _, e[44] = R, e[45] = O, e[46] = Y) : Y = e[46];
285
+ let Z;
286
+ e[47] !== u || e[48] !== Y ? (Z = /* @__PURE__ */ S(C.Stack, { spacing: 2, children: [
287
+ u,
288
+ Y
289
+ ] }), e[47] = u, e[48] = Y, e[49] = Z) : Z = e[49];
290
+ let H;
291
+ e[50] !== D || e[51] !== Z ? (H = /* @__PURE__ */ n(Ee, { in: D, children: Z }), e[50] = D, e[51] = Z, e[52] = H) : H = e[52];
292
+ let Q;
293
+ return e[53] !== T || e[54] !== H || e[55] !== N ? (Q = /* @__PURE__ */ S(C.Section, { children: [
294
+ p,
295
+ g,
296
+ /* @__PURE__ */ S(C.Stack, { spacing: 2, children: [
297
+ N,
298
+ T,
299
+ H
300
+ ] })
301
+ ] }), e[53] = T, e[54] = H, e[55] = N, e[56] = Q) : Q = e[56], Q;
302
+ }, rr = ({
303
+ formData: t,
304
+ setFormData: e,
305
+ llmReservedNames: r = /* @__PURE__ */ new Set()
306
+ }) => {
307
+ const a = t.env || [], i = 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(kn, { variant: "outlined", children: /* @__PURE__ */ S(An, { children: [
349
+ /* @__PURE__ */ n(re, { display: "flex", flexDirection: "row", alignItems: "center", gap: 1, children: /* @__PURE__ */ n(z, { 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(Ut, { 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(Ut, { 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(Se, { startIcon: /* @__PURE__ */ n(Ct, { fontSize: "small" }), disabled: i, variant: "outlined", color: "primary", size: "small", onClick: o, children: "Add" })
355
+ ] }) });
356
+ }, ar = yt({
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
+ }), It = {
363
+ name: "",
364
+ username: "",
365
+ password: ""
366
+ }, ir = (t) => {
367
+ const e = he(59), {
368
+ open: r,
369
+ onClose: a,
370
+ onSecretCreated: i
371
+ } = t, {
372
+ orgId: o
373
+ } = Ce(), [h, y] = de(It), {
374
+ errors: v,
375
+ validateForm: s,
376
+ clearErrors: m,
377
+ clearFieldError: c
378
+ } = Rt(ar), {
379
+ mutate: d,
380
+ isPending: p,
381
+ error: g,
382
+ reset: b
383
+ } = hn();
384
+ let N;
385
+ e[0] !== c ? (N = (L, W) => {
386
+ y((K) => ({
387
+ ...K,
388
+ [L]: W
389
+ })), c(L);
390
+ }, e[0] = c, e[1] = N) : N = e[1];
391
+ const l = N;
392
+ let P;
393
+ e[2] !== d || e[3] !== h || e[4] !== i || 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
+ i(h.name.trim()), y(It);
409
+ }
410
+ });
411
+ }, e[2] = d, e[3] = h, e[4] = i, e[5] = o, e[6] = s, e[7] = P) : P = e[7];
412
+ const x = P;
413
+ let E;
414
+ e[8] !== m || e[9] !== p || e[10] !== a || e[11] !== b ? (E = () => {
415
+ p || (y(It), m(), b(), a());
416
+ }, e[8] = m, e[9] = p, e[10] = a, e[11] = b, e[12] = E) : E = e[12];
417
+ const A = E;
418
+ let k;
419
+ e[13] === Symbol.for("react.memo_cache_sentinel") ? (k = /* @__PURE__ */ n(En, { children: "Create Git Secret" }), e[13] = k) : k = e[13];
420
+ let V, T;
421
+ e[14] === Symbol.for("react.memo_cache_sentinel") ? (V = {
422
+ mt: 1
423
+ }, T = /* @__PURE__ */ n(z, { 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] = V, e[15] = T) : (V = e[14], T = 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 I;
427
+ e[18] !== l ? (I = (L) => l("name", L.target.value), e[18] = l, e[19] = I) : I = e[19];
428
+ const $ = !!v.name, G = v.name || "A unique name for this secret";
429
+ let U;
430
+ e[20] !== h.name || e[21] !== G || e[22] !== I || e[23] !== $ ? (U = /* @__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: I, error: $, helperText: G, fullWidth: !0 }) }), e[20] = h.name, e[21] = G, e[22] = I, e[23] = $, e[24] = U) : U = e[24];
431
+ let w;
432
+ e[25] !== l ? (w = (L) => l("username", L.target.value), e[25] = l, e[26] = w) : w = e[26];
433
+ const B = !!v.username, M = v.username || "Your Git username";
434
+ let j;
435
+ e[27] !== h.username || e[28] !== w || e[29] !== B || e[30] !== M ? (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: B, helperText: M, fullWidth: !0 }) }), e[27] = h.username, e[28] = w, e[29] = B, e[30] = M, e[31] = j) : j = e[31];
436
+ let F;
437
+ e[32] !== l ? (F = (L) => l("password", L.target.value), e[32] = l, e[33] = F) : F = e[33];
438
+ const u = !!v.password, f = v.password || "Your personal access token (PAT) with repo access";
439
+ let _;
440
+ e[34] !== h.password || e[35] !== F || e[36] !== u || e[37] !== f ? (_ = /* @__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: F, error: u, helperText: f, fullWidth: !0 }) }), e[34] = h.password, e[35] = F, e[36] = u, e[37] = f, e[38] = _) : _ = e[38];
441
+ let R;
442
+ e[39] !== U || e[40] !== j || e[41] !== _ || e[42] !== D ? (R = /* @__PURE__ */ n(_n, { children: /* @__PURE__ */ S(C.Stack, { spacing: 3, sx: V, children: [
443
+ T,
444
+ D,
445
+ U,
446
+ j,
447
+ _
448
+ ] }) }), e[39] = U, e[40] = j, e[41] = _, e[42] = D, e[43] = R) : R = e[43];
449
+ let O;
450
+ e[44] !== A || e[45] !== p ? (O = /* @__PURE__ */ n(Se, { onClick: A, disabled: p, children: "Cancel" }), e[44] = A, e[45] = p, e[46] = O) : O = e[46];
451
+ const Y = p ? "Creating..." : "Create Secret";
452
+ let Z;
453
+ e[47] !== x || e[48] !== p || e[49] !== Y ? (Z = /* @__PURE__ */ n(Se, { variant: "contained", onClick: x, disabled: p, children: Y }), e[47] = x, e[48] = p, e[49] = Y, e[50] = Z) : Z = e[50];
454
+ let H;
455
+ e[51] !== O || e[52] !== Z ? (H = /* @__PURE__ */ S(wn, { children: [
456
+ O,
457
+ Z
458
+ ] }), e[51] = O, e[52] = Z, e[53] = H) : H = e[53];
459
+ let Q;
460
+ return e[54] !== A || e[55] !== r || e[56] !== R || e[57] !== H ? (Q = /* @__PURE__ */ S(Tn, { open: r, onClose: A, maxWidth: "sm", fullWidth: !0, children: [
461
+ k,
462
+ R,
463
+ H
464
+ ] }), e[54] = A, e[55] = r, e[56] = R, e[57] = H, e[58] = Q) : Q = e[58], Q;
465
+ }, lr = (t) => {
466
+ const e = he(35), {
467
+ formData: r,
468
+ handleFieldChange: a,
469
+ errors: i
470
+ } = t, {
471
+ orgId: o
472
+ } = Ce(), [h, y] = de(!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
+ } = un(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 b;
490
+ e[5] !== a ? (b = (B) => {
491
+ const M = B.target.value;
492
+ if (M === "__create_new__") {
493
+ y(!0);
494
+ return;
495
+ }
496
+ a("gitSecretRef", M || void 0);
497
+ }, e[5] = a, e[6] = b) : b = e[6];
498
+ const N = b;
499
+ let l;
500
+ e[7] !== a || e[8] !== d ? (l = (B) => {
501
+ a("gitSecretRef", B), d(), y(!1);
502
+ }, e[7] = a, e[8] = d, e[9] = l) : l = e[9];
503
+ const P = l, x = !!i.gitSecretRef, E = r.gitSecretRef || "";
504
+ let A;
505
+ e[10] !== c ? (A = c ? /* @__PURE__ */ n(St, { size: 20, sx: {
506
+ mr: 1
507
+ } }) : void 0, e[10] = c, e[11] = A) : A = e[11];
508
+ let k;
509
+ e[12] === Symbol.for("react.memo_cache_sentinel") ? (k = /* @__PURE__ */ n(Lt, { value: "", children: /* @__PURE__ */ n("em", { children: "Public Repo (None)" }) }), e[12] = k) : k = e[12];
510
+ let V;
511
+ e[13] !== g ? (V = g.map(or), e[13] = g, e[14] = V) : V = e[14];
512
+ let T;
513
+ e[15] === Symbol.for("react.memo_cache_sentinel") ? (T = /* @__PURE__ */ n(Lt, { value: "__create_new__", children: /* @__PURE__ */ n(ie, { direction: "row", spacing: 1, alignItems: "center", children: /* @__PURE__ */ n(Se, { variant: "text", size: "small", startIcon: /* @__PURE__ */ n(Ct, { size: 16 }), sx: {
514
+ textTransform: "none",
515
+ p: 0
516
+ }, children: "Create new git secret" }) }) }), e[15] = T) : T = e[15];
517
+ let D;
518
+ e[16] !== N || e[17] !== c || e[18] !== V || e[19] !== E || e[20] !== A ? (D = /* @__PURE__ */ S(Ln, { id: "gitSecretRef", value: E, onChange: N, displayEmpty: !0, disabled: c, startAdornment: A, children: [
519
+ k,
520
+ V,
521
+ T
522
+ ] }), e[16] = N, e[17] = c, e[18] = V, e[19] = E, e[20] = A, e[21] = D) : D = e[21];
523
+ let I;
524
+ e[22] !== i.gitSecretRef ? (I = i.gitSecretRef ? /* @__PURE__ */ n(Mt, { error: !0, children: i.gitSecretRef }) : /* @__PURE__ */ n(Mt, { children: "Select a git secret for private repository authentication" }), e[22] = i.gitSecretRef, e[23] = I) : I = e[23];
525
+ let $;
526
+ e[24] !== D || e[25] !== I || e[26] !== x ? ($ = /* @__PURE__ */ n(C.ElementWrapper, { label: "Git Secret (Optional)", name: "gitSecretRef", children: /* @__PURE__ */ S(In, { fullWidth: !0, error: x, children: [
527
+ D,
528
+ I
529
+ ] }) }), e[24] = D, e[25] = I, e[26] = x, e[27] = $) : $ = 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 U;
533
+ e[29] !== P || e[30] !== h ? (U = /* @__PURE__ */ n(ir, { open: h, onClose: G, onSecretCreated: P }), e[29] = P, e[30] = h, e[31] = U) : U = e[31];
534
+ let w;
535
+ return e[32] !== $ || e[33] !== U ? (w = /* @__PURE__ */ S(nn, { children: [
536
+ $,
537
+ U
538
+ ] }), e[32] = $, e[33] = U, e[34] = w) : w = e[34], w;
539
+ };
540
+ function or(t) {
541
+ return /* @__PURE__ */ n(Lt, { value: t.name, children: /* @__PURE__ */ n(z, { children: t.name }) }, t.name);
542
+ }
543
+ function sr(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 Qt = (t) => {
547
+ const e = he(61), {
548
+ provider: r,
549
+ isSelected: a,
550
+ templateInfo: i,
551
+ fallbackLabel: o
552
+ } = t, h = o === void 0 ? "Select provider" : o, y = r?.deployments;
553
+ let v, s, m, c, d, p, g, b, N, l, P;
554
+ if (e[0] !== h || e[1] !== a || e[2] !== r || e[3] !== y || e[4] !== i) {
555
+ const U = sr(y);
556
+ s = ie, N = "row", l = 2, P = 1, m = "center";
557
+ const w = a ? "primary.main" : "secondary.main", B = a ? "common.white" : "text.secondary";
558
+ let M;
559
+ e[16] !== w || e[17] !== B ? (M = {
560
+ height: 32,
561
+ width: 32,
562
+ backgroundColor: w,
563
+ color: B
564
+ }, e[16] = w, e[17] = B, e[18] = M) : M = e[18];
565
+ let j;
566
+ e[19] !== a ? (j = a ? /* @__PURE__ */ n(Zn, { size: 16 }) : /* @__PURE__ */ n(Ht, { size: 16 }), e[19] = a, e[20] = j) : j = e[20], e[21] !== M || e[22] !== j ? (c = /* @__PURE__ */ n($n, { sx: M, children: j }), e[21] = M, e[22] = j, e[23] = c) : c = e[23], v = ie, d = 0.25, p = 1;
567
+ const F = r?.name ?? h;
568
+ let u;
569
+ e[24] !== F ? (u = /* @__PURE__ */ S(z, { variant: "h6", children: [
570
+ F,
571
+ "  "
572
+ ] }), e[24] = F, e[25] = u) : u = e[25];
573
+ let f;
574
+ e[26] !== r || e[27] !== i ? (f = r?.template && /* @__PURE__ */ n(zt, { title: "Provider template", placement: "top", arrow: !0, children: /* @__PURE__ */ n(Zt, { label: i?.displayName ?? r.template, size: "small", variant: "outlined", icon: i?.logoUrl ? /* @__PURE__ */ n(re, { component: "img", src: i.logoUrl, alt: i.displayName, sx: {
575
+ width: 14,
576
+ height: 14,
577
+ borderRadius: "100%"
578
+ } }) : void 0 }) }), e[26] = r, e[27] = i, e[28] = f) : f = e[28], e[29] !== u || e[30] !== f ? (g = /* @__PURE__ */ S(ie, { direction: "row", spacing: 0.25, alignItems: "center", children: [
579
+ u,
580
+ f
581
+ ] }), e[29] = u, e[30] = f, e[31] = g) : g = e[31], b = U?.deployedAt && /* @__PURE__ */ S(z, { variant: "caption", color: "text.secondary", children: [
582
+ "Deployed ",
583
+ Nn(new Date(U.deployedAt), {
584
+ addSuffix: !0
585
+ })
586
+ ] }), e[0] = h, e[1] = a, e[2] = r, e[3] = y, e[4] = i, e[5] = v, e[6] = s, e[7] = m, e[8] = c, e[9] = d, e[10] = p, e[11] = g, e[12] = b, e[13] = N, e[14] = l, 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], b = e[12], N = e[13], l = e[14], P = e[15];
589
+ let x;
590
+ e[32] === Symbol.for("react.memo_cache_sentinel") ? (x = /* @__PURE__ */ n(qt, { orientation: "vertical" }), e[32] = x) : x = e[32];
591
+ const E = r?.rateLimiting ? "text.primary" : "text.disabled";
592
+ let A;
593
+ e[33] !== r ? (A = r?.rateLimiting ? (() => {
594
+ const U = [], w = r.rateLimiting.providerLevel, B = r.rateLimiting.consumerLevel;
595
+ return w?.requestLimitCount && U.push(`${w.requestLimitCount} req/min`), w?.tokenLimitCount && U.push(`${w.tokenLimitCount} tokens/min`), B?.requestLimitCount && U.push(`Consumer: ${B.requestLimitCount} req/min`), U.length > 0 ? U.join(", ") : "Configured";
596
+ })() : "Not configured", e[33] = r, e[34] = A) : A = e[34];
597
+ let k;
598
+ e[35] !== E || e[36] !== A ? (k = /* @__PURE__ */ S(z, { variant: "caption", color: "text.secondary", children: [
599
+ "Rate Limiting:",
600
+ " ",
601
+ /* @__PURE__ */ n(z, { component: "span", variant: "body2", color: E, children: A })
602
+ ] }), e[35] = E, e[36] = A, e[37] = k) : k = e[37];
603
+ const V = r?.policies?.length ? "text.primary" : "text.disabled";
604
+ let T;
605
+ e[38] !== r ? (T = r?.policies?.length ? /* @__PURE__ */ S(ie, { direction: "row", spacing: 0.25, flexWrap: "wrap", alignItems: "center", children: [
606
+ r.policies.slice(0, 3).map(mr),
607
+ r.policies.length > 3 && /* @__PURE__ */ n(zt, { title: r.policies.join(", "), placement: "top", arrow: !0, children: /* @__PURE__ */ n(z, { variant: "caption", color: "text.secondary", children: ` +${r.policies.length - 3} more..` }) })
608
+ ] }) : "None", e[38] = r, e[39] = T) : T = e[39];
609
+ let D;
610
+ e[40] !== V || e[41] !== T ? (D = /* @__PURE__ */ S(z, { variant: "caption", color: "text.secondary", children: [
611
+ "Guardrails:",
612
+ " ",
613
+ /* @__PURE__ */ n(z, { component: "span", variant: "body2", color: V, children: T })
614
+ ] }), e[40] = V, e[41] = T, e[42] = D) : D = e[42];
615
+ let I;
616
+ e[43] !== k || e[44] !== D ? (I = /* @__PURE__ */ S(ie, { direction: "column", spacing: 0.25, children: [
617
+ k,
618
+ D
619
+ ] }), e[43] = k, e[44] = D, e[45] = I) : I = e[45];
620
+ let $;
621
+ e[46] !== v || e[47] !== I || e[48] !== d || e[49] !== p || e[50] !== g || e[51] !== b ? ($ = /* @__PURE__ */ S(v, { spacing: d, flexGrow: p, children: [
622
+ g,
623
+ b,
624
+ x,
625
+ I
626
+ ] }), e[46] = v, e[47] = I, e[48] = d, e[49] = p, e[50] = g, e[51] = b, e[52] = $) : $ = e[52];
627
+ let G;
628
+ return e[53] !== s || e[54] !== m || e[55] !== c || e[56] !== $ || e[57] !== N || e[58] !== l || e[59] !== P ? (G = /* @__PURE__ */ S(s, { direction: N, spacing: l, flexGrow: P, alignItems: m, children: [
629
+ c,
630
+ $
631
+ ] }), e[53] = s, e[54] = m, e[55] = c, e[56] = $, e[57] = N, e[58] = l, e[59] = P, e[60] = G) : G = e[60], G;
632
+ }, Fe = /^[A-Za-z_][A-Za-z0-9_]*$/, cr = (t) => {
633
+ const e = he(93), {
634
+ entry: r,
635
+ index: a,
636
+ providers: i,
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] = de(0), g = h[d]?.name ?? "", b = r.selectedProviderByEnv[g]?.uuid ?? null;
645
+ let N;
646
+ e[0] !== r.selectedProviderByEnv ? (N = Object.values(r.selectedProviderByEnv).find(pr), e[0] = r.selectedProviderByEnv, e[1] = N) : N = e[1];
647
+ const l = N;
648
+ let P;
649
+ e[2] !== l || e[3] !== a || e[4] !== i ? (P = (l ? i.find((J) => J.uuid === l.uuid)?.name : null) ?? `LLM Provider ${a + 1}`, e[2] = l, e[3] = a, e[4] = i, e[5] = P) : P = e[5];
650
+ const x = P;
651
+ let E;
652
+ e[6] === Symbol.for("react.memo_cache_sentinel") ? (E = (J, X) => p(X), e[6] = E) : E = e[6];
653
+ const A = E;
654
+ let k;
655
+ e[7] !== a || e[8] !== m ? (k = (J) => {
656
+ J.stopPropagation(), m(a);
657
+ }, e[7] = a, e[8] = m, e[9] = k) : k = e[9];
658
+ const V = k;
659
+ let T;
660
+ e[10] !== a || e[11] !== s || e[12] !== g ? (T = () => s(a, g), e[10] = a, e[11] = s, e[12] = g, e[13] = T) : T = e[13];
661
+ const D = T;
662
+ let I;
663
+ e[14] !== r || e[15] !== a || e[16] !== c ? (I = (J) => {
664
+ const X = J.target.value;
665
+ X !== "" && !Fe.test(X) || c(a, {
666
+ ...r,
667
+ urlVarName: X
668
+ });
669
+ }, e[14] = r, e[15] = a, e[16] = c, e[17] = I) : I = e[17];
670
+ const $ = I;
671
+ let G;
672
+ e[18] !== r || e[19] !== a || e[20] !== c ? (G = (J) => {
673
+ const X = J.target.value;
674
+ X !== "" && !Fe.test(X) || c(a, {
675
+ ...r,
676
+ apikeyVarName: X
677
+ });
678
+ }, e[18] = r, e[19] = a, e[20] = c, e[21] = G) : G = e[21];
679
+ const U = G;
680
+ let w;
681
+ e[22] !== r || e[23] !== a || e[24] !== c ? (w = (J) => {
682
+ r.guardrails.some((pe) => pe.name === J.name && pe.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 B = w;
688
+ let M;
689
+ e[26] !== r || e[27] !== a || e[28] !== c ? (M = (J) => {
690
+ c(a, {
691
+ ...r,
692
+ guardrails: r.guardrails.map((X) => X.name === J.name && X.version === J.version ? J : X)
693
+ });
694
+ }, e[26] = r, e[27] = a, e[28] = c, e[29] = M) : M = e[29];
695
+ const j = M;
696
+ let F;
697
+ e[30] !== r || e[31] !== a || e[32] !== c ? (F = (J, X) => {
698
+ c(a, {
699
+ ...r,
700
+ guardrails: r.guardrails.filter((pe) => !(pe.name === J && pe.version === X))
701
+ });
702
+ }, e[30] = r, e[31] = a, e[32] = c, e[33] = F) : F = e[33];
703
+ const u = F;
704
+ let f;
705
+ e[34] === Symbol.for("react.memo_cache_sentinel") ? (f = /* @__PURE__ */ n(Hn, { size: 18 }), e[34] = f) : f = e[34];
706
+ const _ = `llm-provider-${a}-content`, R = `llm-provider-${a}-header`;
707
+ let O;
708
+ e[35] !== x ? (O = /* @__PURE__ */ n(z, { variant: "subtitle2", children: x }), e[35] = x, e[36] = O) : O = e[36];
709
+ let Y;
710
+ e[37] === Symbol.for("react.memo_cache_sentinel") ? (Y = /* @__PURE__ */ n(Kn, { size: 16 }), e[37] = Y) : Y = e[37];
711
+ let Z;
712
+ e[38] !== V ? (Z = /* @__PURE__ */ n(Un, { size: "small", "aria-label": "Remove LLM provider", onClick: V, children: Y }), e[38] = V, e[39] = Z) : Z = e[39];
713
+ let H;
714
+ e[40] !== O || e[41] !== Z ? (H = /* @__PURE__ */ S(ie, { direction: "row", alignItems: "center", justifyContent: "space-between", flexGrow: 1, pr: 1, children: [
715
+ O,
716
+ Z
717
+ ] }), e[40] = O, e[41] = Z, e[42] = H) : H = e[42];
718
+ let Q;
719
+ e[43] !== _ || e[44] !== R || e[45] !== H ? (Q = /* @__PURE__ */ n(Mn, { expandIcon: f, "aria-controls": _, id: R, children: H }), e[43] = _, e[44] = R, e[45] = H, e[46] = Q) : Q = e[46];
720
+ let L;
721
+ e[47] !== h || e[48] !== d ? (L = h.length > 1 && /* @__PURE__ */ n(Dn, { value: d, onChange: A, sx: {
722
+ mb: 1
723
+ }, children: h.map(hr) }), e[47] = h, e[48] = d, e[49] = L) : L = e[49];
724
+ let W;
725
+ e[50] !== b || e[51] !== h || e[52] !== D || e[53] !== i || e[54] !== d || e[55] !== g || e[56] !== o ? (W = /* @__PURE__ */ n(re, { children: b ? /* @__PURE__ */ n(C.CardButton, { onClick: D, selected: !0, children: /* @__PURE__ */ n(C.CardContent, { children: /* @__PURE__ */ n(Qt, { provider: i.find((J) => J.uuid === b) ?? null, isSelected: !0, templateInfo: o.get(i.find((J) => J.uuid === b)?.template ?? "") }) }) }) : /* @__PURE__ */ S(Se, { variant: "outlined", size: "small", startIcon: /* @__PURE__ */ n(Ct, { size: 16 }), onClick: D, children: [
726
+ "Select Provider for ",
727
+ h[d]?.displayName ?? g
728
+ ] }) }), e[50] = b, e[51] = h, e[52] = D, e[53] = i, e[54] = d, e[55] = g, e[56] = o, e[57] = W) : W = e[57];
729
+ let K;
730
+ e[58] === Symbol.for("react.memo_cache_sentinel") ? (K = /* @__PURE__ */ n(z, { variant: "subtitle2", gutterBottom: !0, children: "Environment Variables" }), e[58] = K) : K = e[58];
731
+ const ee = r.urlVarName ?? `${y}_${a + 1}_URL`, me = `${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 xe = 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 le;
736
+ e[62] !== $ || e[63] !== ee || e[64] !== me || e[65] !== ae || e[66] !== xe ? (le = /* @__PURE__ */ n(C.ElementWrapper, { label: "URL variable name", name: "urlVarName", children: /* @__PURE__ */ n(ne, { size: "small", fullWidth: !0, value: ee, onChange: $, placeholder: me, error: ae, helperText: xe }) }), e[62] = $, e[63] = ee, e[64] = me, e[65] = ae, e[66] = xe, e[67] = le) : le = e[67];
737
+ const ke = r.apikeyVarName ?? `${y}_${a + 1}_API_KEY`, Ae = `${y}_${a + 1}_API_KEY`;
738
+ let oe;
739
+ e[68] !== r.apikeyVarName || e[69] !== v ? (oe = 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] = oe) : oe = 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 se;
742
+ e[71] !== U || e[72] !== ke || e[73] !== Ae || e[74] !== oe || e[75] !== _e ? (se = /* @__PURE__ */ n(C.ElementWrapper, { label: "API key variable name", name: "apikeyVarName", children: /* @__PURE__ */ n(ne, { size: "small", fullWidth: !0, value: ke, onChange: U, placeholder: Ae, error: oe, helperText: _e }) }), e[71] = U, e[72] = ke, e[73] = Ae, e[74] = oe, e[75] = _e, e[76] = se) : se = e[76];
743
+ let ge;
744
+ e[77] !== le || e[78] !== se ? (ge = /* @__PURE__ */ S(re, { children: [
745
+ K,
746
+ /* @__PURE__ */ S(ie, { direction: "row", spacing: 2, children: [
747
+ le,
748
+ se
749
+ ] })
750
+ ] }), e[77] = le, e[78] = se, e[79] = ge) : ge = e[79];
751
+ let ye;
752
+ e[80] !== r.guardrails || e[81] !== B || e[82] !== j || e[83] !== u ? (ye = /* @__PURE__ */ n(Cn, { guardrails: r.guardrails, onAddGuardrail: B, onEditGuardrail: j, onRemoveGuardrail: u }), e[80] = r.guardrails, e[81] = B, e[82] = j, e[83] = u, e[84] = ye) : ye = e[84];
753
+ let ce;
754
+ e[85] !== L || e[86] !== W || e[87] !== ge || e[88] !== ye ? (ce = /* @__PURE__ */ n(On, { children: /* @__PURE__ */ S(ie, { spacing: 3, children: [
755
+ L,
756
+ W,
757
+ ge,
758
+ ye
759
+ ] }) }), e[85] = L, e[86] = W, e[87] = ge, e[88] = ye, e[89] = ce) : ce = e[89];
760
+ let ue;
761
+ return e[90] !== Q || e[91] !== ce ? (ue = /* @__PURE__ */ S(zn, { defaultExpanded: !0, children: [
762
+ Q,
763
+ ce
764
+ ] }), e[90] = Q, e[91] = ce, e[92] = ue) : ue = e[92], ue;
765
+ }, dr = ({
766
+ llmProviders: t,
767
+ setLLMProviders: e,
768
+ agentDisplayName: r,
769
+ externalEnvKeys: a = /* @__PURE__ */ new Set()
770
+ }) => {
771
+ const {
772
+ orgId: i
773
+ } = Ce(), [o, h] = de(null), [y, v] = de(""), [s, m] = de(!1), [c, d] = de(""), [p, g] = de(""), b = Fn(null), N = bt(), {
774
+ data: l = [],
775
+ isLoading: P
776
+ } = fn({
777
+ orgName: i
778
+ }), {
779
+ data: x,
780
+ isLoading: E
781
+ } = gn({
782
+ orgName: i
783
+ }, {
784
+ limit: 50
785
+ }), {
786
+ data: A,
787
+ isLoading: k
788
+ } = yn({
789
+ orgName: i
790
+ }), V = E || k, T = Vt(() => {
791
+ const u = /* @__PURE__ */ new Map();
792
+ for (const f of A?.templates ?? [])
793
+ u.set(f.name, {
794
+ displayName: f.name,
795
+ logoUrl: f.metadata?.logoUrl
796
+ }), u.set(f.id, {
797
+ displayName: f.name,
798
+ logoUrl: f.metadata?.logoUrl
799
+ });
800
+ return u;
801
+ }, [A]), D = Vt(() => (x?.entries ?? []).map((u) => ({
802
+ uuid: u.uuid,
803
+ id: u.handle,
804
+ name: u.name,
805
+ version: u.version,
806
+ template: u.template,
807
+ deployments: u.deployments ?? [],
808
+ security: u.security,
809
+ rateLimiting: u.rateLimiting,
810
+ policies: u.policies ?? []
811
+ })), [x]), I = r ? r.toUpperCase().replace(/[^A-Z0-9]/g, "_") : "AGENT", $ = o !== null ? t[o]?.selectedProviderByEnv[y]?.uuid ?? null : null, G = Pe((u, f) => {
812
+ h(u), v(f), m(!0);
813
+ }, []), U = Pe(() => {
814
+ h(null), m(!0);
815
+ }, []), w = Pe(() => {
816
+ b.current && (clearTimeout(b.current), b.current = null), m(!1), d(""), g("");
817
+ }, []), B = Pe((u, f) => {
818
+ e((_) => {
819
+ if (o === null) {
820
+ if (l.length === 0) return _;
821
+ const R = {};
822
+ for (const Y of l)
823
+ R[Y.name] = {
824
+ uuid: u,
825
+ handle: f
826
+ };
827
+ const O = _.length;
828
+ return [..._, {
829
+ selectedProviderByEnv: R,
830
+ urlVarName: `${I}_${O + 1}_URL`,
831
+ apikeyVarName: `${I}_${O + 1}_API_KEY`,
832
+ guardrails: []
833
+ }];
834
+ } else {
835
+ const R = [..._], O = R[o];
836
+ return O ? (R[o] = {
837
+ ...O,
838
+ selectedProviderByEnv: {
839
+ ...O.selectedProviderByEnv,
840
+ [y]: {
841
+ uuid: u,
842
+ handle: f
843
+ }
844
+ }
845
+ }, R) : _;
846
+ }
847
+ }), b.current && (clearTimeout(b.current), b.current = null), m(!1), d(""), g("");
848
+ }, [o, y, l, I, e]), M = Pe((u) => {
849
+ e((f) => f.filter((_, R) => R !== u));
850
+ }, [e]), j = Pe((u, f) => {
851
+ e((_) => {
852
+ const R = [..._];
853
+ return R[u] = f, R;
854
+ });
855
+ }, [e]), F = Pe((u) => {
856
+ const f = u.target.value;
857
+ d(f), b.current && clearTimeout(b.current), b.current = setTimeout(() => g(f), 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((u, f) => {
863
+ const _ = /* @__PURE__ */ new Set([...t.flatMap((R, O) => O === f ? [] : [R.urlVarName ?? `${I}_${O + 1}_URL`, R.apikeyVarName ?? `${I}_${O + 1}_API_KEY`]), ...Array.from(a)]);
864
+ return /* @__PURE__ */ n(cr, { entry: u, index: f, providers: D, templateMap: T, environments: l, agentNameUpper: I, usedVarNames: _, onOpenDrawer: G, onRemove: M, onUpdateEntry: j }, f);
865
+ }),
866
+ /* @__PURE__ */ n(re, { sx: {
867
+ pt: t.length > 0 ? 1 : 0
868
+ }, children: /* @__PURE__ */ n(Se, { variant: "outlined", size: "small", startIcon: /* @__PURE__ */ n(Ct, { size: 16 }), onClick: U, disabled: P || E, children: "Add" }) })
869
+ ] }),
870
+ /* @__PURE__ */ S(vn, { open: s, onClose: w, minWidth: 740, maxWidth: 740, children: [
871
+ /* @__PURE__ */ n(bn, { icon: /* @__PURE__ */ n(Bn, { size: 24 }), title: "Select Provider", onClose: w }),
872
+ /* @__PURE__ */ n(Sn, { children: /* @__PURE__ */ S(ie, { children: [
873
+ /* @__PURE__ */ n(z, { 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(Vn, { placeholder: "Search providers", size: "small", fullWidth: !0, value: c, onChange: F, sx: {
877
+ mb: 1
878
+ } }),
879
+ /* @__PURE__ */ n(ie, { spacing: 1, sx: {
880
+ flex: 1,
881
+ overflowY: "auto"
882
+ }, children: V ? /* @__PURE__ */ n(re, { sx: {
883
+ display: "flex",
884
+ justifyContent: "center",
885
+ py: 4
886
+ }, children: /* @__PURE__ */ n(St, { size: 32 }) }) : (() => {
887
+ const u = D.filter((f) => {
888
+ if (!p.trim()) return !0;
889
+ const _ = p.toLowerCase();
890
+ return f.name.toLowerCase().includes(_) || (f.template ?? "").toLowerCase().includes(_) || (T.get(f.template ?? "")?.displayName ?? "").toLowerCase().includes(_);
891
+ });
892
+ if (u.length === 0) {
893
+ const f = !!p.trim();
894
+ return /* @__PURE__ */ n(Ot.Container, { children: /* @__PURE__ */ n(Ot.EmptyState, { illustration: /* @__PURE__ */ n(qn, { size: 64 }), title: f ? "No LLM Service Providers match your search" : "No LLM Service Providers available", description: f ? "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: !f && i ? /* @__PURE__ */ n(Se, { variant: "contained", size: "small", startIcon: /* @__PURE__ */ n(Kt, { size: 16 }), onClick: () => N(be(ve.children.org.children.llmProviders.children.add.path, {
895
+ orgId: i
896
+ })), children: "Add LLM Service Provider" }) : void 0 }) });
897
+ }
898
+ return u.map((f) => {
899
+ const _ = $ === f.uuid, R = () => B(f.uuid, f.id);
900
+ return /* @__PURE__ */ n(C.CardButton, { onClick: R, selected: _, "aria-label": `${f.name}. ${_ ? "Selected" : "Click to select"}`, children: /* @__PURE__ */ n(C.CardContent, { children: /* @__PURE__ */ n(Qt, { provider: f, isSelected: _, templateInfo: T.get(f.template ?? "") }) }) }, f.uuid);
901
+ });
902
+ })() })
903
+ ] }) })
904
+ ] })
905
+ ] });
906
+ };
907
+ function mr(t) {
908
+ return /* @__PURE__ */ n(Zt, { label: t, size: "small", variant: "outlined" }, t);
909
+ }
910
+ function pr(t) {
911
+ return t != null;
912
+ }
913
+ function hr(t, e) {
914
+ return /* @__PURE__ */ n(Rn, { label: t.displayName ?? t.name, value: e }, t.name);
915
+ }
916
+ const ur = [{
917
+ label: "Python",
918
+ value: "python"
919
+ }, {
920
+ label: "Docker",
921
+ value: "docker"
922
+ }], fr = (t) => {
923
+ const e = he(180), {
924
+ formData: r,
925
+ setFormData: a,
926
+ errors: i,
927
+ setFieldError: o,
928
+ validateField: h,
929
+ llmProviders: y,
930
+ setLLMProviders: v
931
+ } = t, {
932
+ orgId: s,
933
+ projectId: m
934
+ } = Ce(), c = Pn("private-repo-support"), d = c.length === 0 || c[0]?.value?.enabled !== !1;
935
+ let p;
936
+ e[0] !== s ? (p = {
937
+ orgName: s
938
+ }, e[0] = s, e[1] = p) : p = e[1];
939
+ const {
940
+ mutate: g,
941
+ isPending: b
942
+ } = Ft(p);
943
+ let N;
944
+ e[2] !== o || e[3] !== a || e[4] !== h ? (N = (q, fe) => {
945
+ a((ft) => {
946
+ const Ne = {
947
+ ...ft,
948
+ [q]: fe
949
+ }, en = h(q, fe, Ne);
950
+ if (o(q, en), q === "language") {
951
+ if (fe === "python") {
952
+ o("dockerfilePath", void 0);
953
+ const wt = h("runCommand", Ne.runCommand, Ne), tn = h("languageVersion", Ne.languageVersion, Ne);
954
+ o("runCommand", wt), o("languageVersion", tn);
955
+ } else if (fe === "docker") {
956
+ o("runCommand", void 0), o("languageVersion", void 0);
957
+ const wt = h("dockerfilePath", Ne.dockerfilePath, Ne);
958
+ o("dockerfilePath", wt);
959
+ }
960
+ }
961
+ return Ne;
962
+ });
963
+ }, e[2] = o, e[3] = a, e[4] = h, e[5] = N) : N = e[5];
964
+ const l = N;
965
+ let P;
966
+ e[6] !== g || e[7] !== l || e[8] !== m ? (P = Gt.debounce((q) => {
967
+ if (q.length < 3) {
968
+ l("name", "");
969
+ return;
970
+ }
971
+ g({
972
+ displayName: q,
973
+ resourceType: "agent",
974
+ projectName: m
975
+ }, {
976
+ onSuccess: (fe) => {
977
+ l("name", fe.name);
978
+ },
979
+ onError: gr
980
+ });
981
+ }, 500), e[6] = g, e[7] = l, e[8] = m, e[9] = P) : P = e[9];
982
+ const x = P;
983
+ let E, A;
984
+ e[10] !== x ? (E = () => () => {
985
+ x.cancel();
986
+ }, A = [x], e[10] = x, e[11] = E, e[12] = A) : (E = e[11], A = e[12]), vt(E, A);
987
+ let k, V;
988
+ e[13] !== x || e[14] !== r.displayName || e[15] !== l ? (k = () => {
989
+ r.displayName && r.displayName.length >= 3 ? x(r.displayName) : (x.cancel(), l("name", ""));
990
+ }, V = [r.displayName, l, x], e[13] = x, e[14] = r.displayName, e[15] = l, e[16] = k, e[17] = V) : (k = e[16], V = e[17]), vt(k, V);
991
+ let T;
992
+ e[18] === Symbol.for("react.memo_cache_sentinel") ? (T = /* @__PURE__ */ n(C.Subheader, { children: "Agent Details" }), e[18] = T) : T = e[18];
993
+ let D;
994
+ e[19] !== l ? (D = (q) => l("displayName", q.target.value), e[19] = l, e[20] = D) : D = e[20];
995
+ const I = !!i.displayName;
996
+ let $;
997
+ e[21] !== i.displayName || e[22] !== b ? ($ = b ? /* @__PURE__ */ S(ie, { direction: "row", alignItems: "center", gap: 1, children: [
998
+ /* @__PURE__ */ n(St, { size: 12 }),
999
+ /* @__PURE__ */ n(z, { variant: "caption", children: "Validating name..." })
1000
+ ] }) : i.displayName || "A name for your agent", e[21] = i.displayName, e[22] = b, e[23] = $) : $ = e[23];
1001
+ let G;
1002
+ e[24] !== r.displayName || e[25] !== I || e[26] !== $ || e[27] !== D ? (G = /* @__PURE__ */ n(C.ElementWrapper, { label: "Name", name: "displayName", children: /* @__PURE__ */ n(ne, { id: "displayName", placeholder: "e.g., Customer Support Agent", value: r.displayName, onChange: D, error: I, helperText: $, fullWidth: !0 }) }), e[24] = r.displayName, e[25] = I, e[26] = $, e[27] = D, e[28] = G) : G = e[28];
1003
+ const U = r.description || "";
1004
+ let w;
1005
+ e[29] !== l ? (w = (q) => l("description", q.target.value), e[29] = l, e[30] = w) : w = e[30];
1006
+ const B = !!i.description;
1007
+ let M;
1008
+ e[31] !== i.description || e[32] !== U || e[33] !== w || e[34] !== B ? (M = /* @__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: U, onChange: w, error: B, helperText: i.description, fullWidth: !0 }) }), e[31] = i.description, e[32] = U, e[33] = w, e[34] = B, e[35] = M) : M = e[35];
1009
+ let j;
1010
+ e[36] !== G || e[37] !== M ? (j = /* @__PURE__ */ S(C.Section, { children: [
1011
+ T,
1012
+ /* @__PURE__ */ S(C.Stack, { spacing: 2, children: [
1013
+ G,
1014
+ M
1015
+ ] })
1016
+ ] }), e[36] = G, e[37] = M, e[38] = j) : j = e[38];
1017
+ let F;
1018
+ e[39] === Symbol.for("react.memo_cache_sentinel") ? (F = /* @__PURE__ */ n(C.Subheader, { children: "Repository Details" }), e[39] = F) : F = e[39];
1019
+ let u;
1020
+ e[40] !== l ? (u = (q) => l("repositoryUrl", q.target.value), e[40] = l, e[41] = u) : u = e[41];
1021
+ const f = !!i.repositoryUrl;
1022
+ let _;
1023
+ e[42] !== i.repositoryUrl || e[43] !== r.repositoryUrl || e[44] !== u || e[45] !== 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: u, error: f, helperText: i.repositoryUrl, fullWidth: !0 }) }), e[42] = i.repositoryUrl, e[43] = r.repositoryUrl, e[44] = u, e[45] = f, e[46] = _) : _ = e[46];
1024
+ let R;
1025
+ e[47] !== i || e[48] !== r || e[49] !== l || e[50] !== d ? (R = d && /* @__PURE__ */ n(lr, { formData: r, handleFieldChange: l, errors: i }), e[47] = i, e[48] = r, e[49] = l, e[50] = d, e[51] = R) : R = e[51];
1026
+ let O;
1027
+ e[52] !== l ? (O = (q) => l("branch", q.target.value), e[52] = l, e[53] = O) : O = e[53];
1028
+ const Y = !!i.branch;
1029
+ let Z;
1030
+ e[54] !== i.branch || e[55] !== r.branch || e[56] !== O || e[57] !== Y ? (Z = /* @__PURE__ */ n(C.ElementWrapper, { label: "Branch", name: "branch", children: /* @__PURE__ */ n(ne, { id: "branch", placeholder: "main", value: r.branch, onChange: O, error: Y, helperText: i.branch, fullWidth: !0 }) }), e[54] = i.branch, e[55] = r.branch, e[56] = O, e[57] = Y, e[58] = Z) : Z = e[58];
1031
+ let H;
1032
+ e[59] !== l ? (H = (q) => l("appPath", q.target.value), e[59] = l, e[60] = H) : H = e[60];
1033
+ const Q = !!i.appPath;
1034
+ let L;
1035
+ e[61] !== i.appPath || e[62] !== r.appPath || e[63] !== H || e[64] !== Q ? (L = /* @__PURE__ */ n(C.ElementWrapper, { label: "Project Path", name: "appPath", children: /* @__PURE__ */ n(ne, { id: "appPath", placeholder: "my-agent", value: r.appPath, onChange: H, error: Q, helperText: i.appPath, fullWidth: !0 }) }), e[61] = i.appPath, e[62] = r.appPath, e[63] = H, e[64] = Q, e[65] = L) : L = e[65];
1036
+ let W;
1037
+ e[66] !== Z || e[67] !== L ? (W = /* @__PURE__ */ S(C.Stack, { direction: "row", spacing: 2, children: [
1038
+ Z,
1039
+ L
1040
+ ] }), e[66] = Z, e[67] = L, e[68] = W) : W = e[68];
1041
+ let K;
1042
+ e[69] !== _ || e[70] !== R || e[71] !== W ? (K = /* @__PURE__ */ S(C.Section, { children: [
1043
+ F,
1044
+ /* @__PURE__ */ S(C.Stack, { spacing: 2, children: [
1045
+ _,
1046
+ R,
1047
+ W
1048
+ ] })
1049
+ ] }), e[69] = _, e[70] = R, e[71] = W, e[72] = K) : K = e[72];
1050
+ let ee;
1051
+ e[73] === Symbol.for("react.memo_cache_sentinel") ? (ee = /* @__PURE__ */ n(C.Subheader, { children: "Build Details" }), e[73] = ee) : ee = e[73];
1052
+ let me;
1053
+ e[74] !== r.language || e[75] !== l ? (me = ur.map((q) => {
1054
+ const fe = r.language === q.value;
1055
+ return /* @__PURE__ */ n(C.CardButton, { onClick: () => l("language", q.value), selected: fe, children: /* @__PURE__ */ n(C.CardHeader, { title: /* @__PURE__ */ S(C.Stack, { direction: "row", spacing: 2, justifyContent: "center", alignItems: "center", children: [
1056
+ /* @__PURE__ */ n(xn, { language: q.value }),
1057
+ /* @__PURE__ */ n(C.Body, { children: q.label })
1058
+ ] }) }) }, q.value);
1059
+ }), e[74] = r.language, e[75] = l, e[76] = me) : me = e[76];
1060
+ let ae;
1061
+ e[77] !== me ? (ae = /* @__PURE__ */ n(C.Stack, { direction: "row", spacing: 2, children: me }), e[77] = me, e[78] = ae) : ae = e[78];
1062
+ const xe = r.language === "python";
1063
+ let le;
1064
+ e[79] !== l ? (le = (q) => l("runCommand", q.target.value), e[79] = l, e[80] = le) : le = e[80];
1065
+ const ke = !!i.runCommand, Ae = i.runCommand || "Dependencies auto-install from package.json, requirements.txt, or pyproject.toml";
1066
+ let oe;
1067
+ e[81] !== r.runCommand || e[82] !== le || e[83] !== ke || e[84] !== Ae ? (oe = /* @__PURE__ */ n(C.ElementWrapper, { label: "Start Command", name: "runCommand", children: /* @__PURE__ */ n(ne, { id: "runCommand", placeholder: "python main.py", value: r.runCommand, onChange: le, error: ke, helperText: Ae, fullWidth: !0 }) }), e[81] = r.runCommand, e[82] = le, e[83] = ke, e[84] = Ae, e[85] = oe) : oe = e[85];
1068
+ const _e = r.languageVersion || "";
1069
+ let se;
1070
+ e[86] !== l ? (se = (q) => l("languageVersion", q.target.value), e[86] = l, e[87] = se) : se = e[87];
1071
+ const ge = !!i.languageVersion, ye = i.languageVersion || "e.g., 3.11, 20, 1.21";
1072
+ let ce;
1073
+ e[88] !== _e || e[89] !== se || e[90] !== ge || e[91] !== ye ? (ce = /* @__PURE__ */ n(C.ElementWrapper, { label: "Language Version", name: "languageVersion", children: /* @__PURE__ */ n(ne, { id: "languageVersion", placeholder: "3.11", value: _e, onChange: se, error: ge, helperText: ye, fullWidth: !0 }) }), e[88] = _e, e[89] = se, e[90] = ge, e[91] = ye, e[92] = ce) : ce = e[92];
1074
+ let ue;
1075
+ e[93] !== oe || e[94] !== ce ? (ue = /* @__PURE__ */ S(C.Stack, { direction: "row", spacing: 2, children: [
1076
+ oe,
1077
+ ce
1078
+ ] }), e[93] = oe, e[94] = ce, e[95] = ue) : ue = e[95];
1079
+ const J = r.enableAutoInstrumentation ?? !0;
1080
+ let X;
1081
+ e[96] !== l ? (X = (q) => l("enableAutoInstrumentation", q.target.checked), e[96] = l, e[97] = X) : X = e[97];
1082
+ let pe;
1083
+ e[98] !== J || e[99] !== X ? (pe = /* @__PURE__ */ n(Wn, { control: /* @__PURE__ */ n(jn, { checked: J, onChange: X }), label: "Enable auto instrumentation" }), e[98] = J, e[99] = X, e[100] = pe) : pe = e[100];
1084
+ const Nt = r.enableAutoInstrumentation !== !1;
1085
+ let Ge;
1086
+ e[101] === Symbol.for("react.memo_cache_sentinel") ? (Ge = /* @__PURE__ */ n(z, { variant: "body2", color: "text.secondary", children: "Automatically adds OTEL tracing instrumentation to your agent for observability." }), e[101] = Ge) : Ge = e[101];
1087
+ let Te;
1088
+ e[102] !== Nt ? (Te = /* @__PURE__ */ n(Ee, { in: Nt, children: Ge }), e[102] = Nt, e[103] = Te) : Te = e[103];
1089
+ const Pt = r.enableAutoInstrumentation === !1;
1090
+ let Be, qe;
1091
+ e[104] === Symbol.for("react.memo_cache_sentinel") ? (Be = {
1092
+ mt: 1
1093
+ }, qe = /* @__PURE__ */ n(z, { variant: "subtitle2", children: "Tracing Support for Python Agents" }), e[104] = Be, e[105] = qe) : (Be = e[104], qe = e[105]);
1094
+ let Ze;
1095
+ e[106] === Symbol.for("react.memo_cache_sentinel") ? (Ze = /* @__PURE__ */ S(z, { 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[106] = Ze) : Ze = e[106];
1102
+ let He;
1103
+ e[107] === Symbol.for("react.memo_cache_sentinel") ? (He = {
1104
+ mt: 1
1105
+ }, e[107] = He) : He = e[107];
1106
+ let Ke;
1107
+ e[108] === Symbol.for("react.memo_cache_sentinel") ? (Ke = /* @__PURE__ */ n(z, { component: "code", sx: {
1108
+ bgcolor: "action.hover",
1109
+ px: 0.5,
1110
+ borderRadius: 0.5
1111
+ }, children: "AMP_OTEL_ENDPOINT" }), e[108] = Ke) : Ke = e[108];
1112
+ let Ye;
1113
+ e[109] === Symbol.for("react.memo_cache_sentinel") ? (Ye = /* @__PURE__ */ S(z, { variant: "body2", sx: He, children: [
1114
+ "Environment variables provided:",
1115
+ " ",
1116
+ Ke,
1117
+ ", ",
1118
+ /* @__PURE__ */ n(z, { component: "code", sx: {
1119
+ bgcolor: "action.hover",
1120
+ px: 0.5,
1121
+ borderRadius: 0.5
1122
+ }, children: "AMP_AGENT_API_KEY" })
1123
+ ] }), e[109] = Ye) : Ye = e[109];
1124
+ let Qe;
1125
+ e[110] === Symbol.for("react.memo_cache_sentinel") ? (Qe = /* @__PURE__ */ n(z, { variant: "body2", sx: {
1126
+ mt: 1
1127
+ }, children: "Example configuration:" }), e[110] = Qe) : Qe = e[110];
1128
+ let Je;
1129
+ e[111] === Symbol.for("react.memo_cache_sentinel") ? (Je = {
1130
+ mt: 0.5,
1131
+ ml: 1
1132
+ }, e[111] = Je) : Je = e[111];
1133
+ let Xe;
1134
+ e[112] === Symbol.for("react.memo_cache_sentinel") ? (Xe = /* @__PURE__ */ S(z, { variant: "body2", component: "div", sx: Je, children: [
1135
+ "• OTLP exporter endpoint =",
1136
+ " ",
1137
+ /* @__PURE__ */ n(z, { component: "code", sx: {
1138
+ bgcolor: "action.hover",
1139
+ px: 0.5,
1140
+ borderRadius: 0.5
1141
+ }, children: "AMP_OTEL_ENDPOINT" })
1142
+ ] }), e[112] = Xe) : Xe = e[112];
1143
+ let et;
1144
+ e[113] === Symbol.for("react.memo_cache_sentinel") ? (et = {
1145
+ ml: 1
1146
+ }, e[113] = et) : et = e[113];
1147
+ let tt;
1148
+ e[114] === Symbol.for("react.memo_cache_sentinel") ? (tt = /* @__PURE__ */ S(we, { severity: "info", sx: Be, children: [
1149
+ qe,
1150
+ Ze,
1151
+ Ye,
1152
+ Qe,
1153
+ Xe,
1154
+ /* @__PURE__ */ S(z, { variant: "body2", component: "div", sx: et, children: [
1155
+ "• OTLP headers =",
1156
+ " ",
1157
+ /* @__PURE__ */ n(z, { 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[114] = tt) : tt = e[114];
1164
+ let Ie;
1165
+ e[115] !== Pt ? (Ie = /* @__PURE__ */ n(Ee, { in: Pt, children: tt }), e[115] = Pt, e[116] = Ie) : Ie = e[116];
1166
+ let Le;
1167
+ e[117] !== xe || e[118] !== ue || e[119] !== pe || e[120] !== Te || e[121] !== Ie ? (Le = /* @__PURE__ */ S(Ee, { in: xe, children: [
1168
+ ue,
1169
+ pe,
1170
+ Te,
1171
+ Ie
1172
+ ] }), e[117] = xe, e[118] = ue, e[119] = pe, e[120] = Te, e[121] = Ie, e[122] = Le) : Le = e[122];
1173
+ const xt = r.language === "docker", kt = r.dockerfilePath || "";
1174
+ let Ve;
1175
+ e[123] !== l ? (Ve = (q) => l("dockerfilePath", q.target.value), e[123] = l, e[124] = Ve) : Ve = e[124];
1176
+ const At = !!i.dockerfilePath, _t = i.dockerfilePath || "Path to Dockerfile in your repository";
1177
+ let De;
1178
+ e[125] !== kt || e[126] !== Ve || e[127] !== At || e[128] !== _t ? (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: kt, onChange: Ve, error: At, helperText: _t, fullWidth: !0 }) }) }), e[125] = kt, e[126] = Ve, e[127] = At, e[128] = _t, e[129] = De) : De = e[129];
1179
+ let nt;
1180
+ e[130] === Symbol.for("react.memo_cache_sentinel") ? (nt = /* @__PURE__ */ n(z, { variant: "subtitle2", gutterBottom: !0, children: "Tracing Support for Docker-Based Agents" }), e[130] = nt) : nt = e[130];
1181
+ let rt;
1182
+ e[131] === Symbol.for("react.memo_cache_sentinel") ? (rt = /* @__PURE__ */ n(z, { component: "code", sx: {
1183
+ bgcolor: "action.hover",
1184
+ px: 0.5,
1185
+ borderRadius: 0.5
1186
+ }, children: "pip install amp-instrumentation" }), e[131] = rt) : rt = e[131];
1187
+ let at;
1188
+ e[132] === Symbol.for("react.memo_cache_sentinel") ? (at = /* @__PURE__ */ S(z, { variant: "body2", paragraph: !0, children: [
1189
+ "Docker-based agents require OTEL instrumentation to export traces. For Python, use",
1190
+ " ",
1191
+ rt,
1192
+ " ",
1193
+ "and run with",
1194
+ " ",
1195
+ /* @__PURE__ */ n(z, { 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[132] = at) : at = e[132];
1203
+ let it;
1204
+ e[133] === Symbol.for("react.memo_cache_sentinel") ? (it = /* @__PURE__ */ n(z, { component: "code", sx: {
1205
+ bgcolor: "action.hover",
1206
+ px: 0.5,
1207
+ borderRadius: 0.5
1208
+ }, children: "AMP_OTEL_ENDPOINT" }), e[133] = it) : it = e[133];
1209
+ let lt;
1210
+ e[134] === Symbol.for("react.memo_cache_sentinel") ? (lt = /* @__PURE__ */ S(z, { variant: "body2", gutterBottom: !0, children: [
1211
+ "Environment variables provided:",
1212
+ " ",
1213
+ it,
1214
+ ", ",
1215
+ /* @__PURE__ */ n(z, { component: "code", sx: {
1216
+ bgcolor: "action.hover",
1217
+ px: 0.5,
1218
+ borderRadius: 0.5
1219
+ }, children: "AMP_AGENT_API_KEY" })
1220
+ ] }), e[134] = lt) : lt = e[134];
1221
+ let ot;
1222
+ e[135] === Symbol.for("react.memo_cache_sentinel") ? (ot = /* @__PURE__ */ n(z, { variant: "body2", sx: {
1223
+ mt: 1
1224
+ }, children: "Example configuration:" }), e[135] = ot) : ot = e[135];
1225
+ let st;
1226
+ e[136] === Symbol.for("react.memo_cache_sentinel") ? (st = {
1227
+ mt: 0.5,
1228
+ ml: 1
1229
+ }, e[136] = st) : st = e[136];
1230
+ let ct;
1231
+ e[137] === Symbol.for("react.memo_cache_sentinel") ? (ct = /* @__PURE__ */ S(z, { variant: "body2", component: "div", sx: st, children: [
1232
+ "• OTLP exporter endpoint =",
1233
+ " ",
1234
+ /* @__PURE__ */ n(z, { component: "code", sx: {
1235
+ bgcolor: "action.hover",
1236
+ px: 0.5,
1237
+ borderRadius: 0.5
1238
+ }, children: "AMP_OTEL_ENDPOINT" })
1239
+ ] }), e[137] = ct) : ct = e[137];
1240
+ let dt;
1241
+ e[138] === Symbol.for("react.memo_cache_sentinel") ? (dt = {
1242
+ ml: 1
1243
+ }, e[138] = dt) : dt = e[138];
1244
+ let mt;
1245
+ e[139] === Symbol.for("react.memo_cache_sentinel") ? (mt = /* @__PURE__ */ S(we, { severity: "info", children: [
1246
+ nt,
1247
+ at,
1248
+ lt,
1249
+ ot,
1250
+ ct,
1251
+ /* @__PURE__ */ S(z, { variant: "body2", component: "div", sx: dt, children: [
1252
+ "• OTLP headers =",
1253
+ " ",
1254
+ /* @__PURE__ */ n(z, { 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[139] = mt) : mt = e[139];
1261
+ let Re;
1262
+ e[140] !== De ? (Re = /* @__PURE__ */ S(ie, { spacing: 2, children: [
1263
+ De,
1264
+ mt
1265
+ ] }), e[140] = De, e[141] = Re) : Re = e[141];
1266
+ let $e;
1267
+ e[142] !== xt || e[143] !== Re ? ($e = /* @__PURE__ */ n(Ee, { in: xt, children: Re }), e[142] = xt, e[143] = Re, e[144] = $e) : $e = e[144];
1268
+ let Ue;
1269
+ e[145] !== ae || e[146] !== Le || e[147] !== $e ? (Ue = /* @__PURE__ */ S(C.Section, { children: [
1270
+ ee,
1271
+ /* @__PURE__ */ S(C.Stack, { spacing: 2, children: [
1272
+ ae,
1273
+ Le,
1274
+ $e
1275
+ ] })
1276
+ ] }), e[145] = ae, e[146] = Le, e[147] = $e, e[148] = Ue) : Ue = e[148];
1277
+ let Me;
1278
+ e[149] !== i || e[150] !== r || e[151] !== o || e[152] !== a || e[153] !== h ? (Me = /* @__PURE__ */ n(nr, { formData: r, setFormData: a, errors: i, setFieldError: o, validateField: h }), e[149] = i, e[150] = r, e[151] = o, e[152] = a, e[153] = h, e[154] = Me) : Me = e[154];
1279
+ let Oe;
1280
+ e[155] !== r.env ? (Oe = new Set((r.env ?? []).map(yr).filter(vr)), e[155] = r.env, e[156] = Oe) : Oe = e[156];
1281
+ let ze;
1282
+ e[157] !== r.displayName || e[158] !== y || e[159] !== v || e[160] !== Oe ? (ze = /* @__PURE__ */ n(dr, { llmProviders: y, setLLMProviders: v, agentDisplayName: r.displayName, externalEnvKeys: Oe }), e[157] = r.displayName, e[158] = y, e[159] = v, e[160] = Oe, e[161] = ze) : ze = e[161];
1283
+ let pt;
1284
+ e[162] !== r.displayName ? (pt = r.displayName ? r.displayName.toUpperCase().replace(/[^A-Z0-9]/g, "_") : "AGENT", e[162] = r.displayName, e[163] = pt) : pt = e[163];
1285
+ const We = pt;
1286
+ let ht;
1287
+ if (e[164] !== We || e[165] !== y) {
1288
+ let q;
1289
+ e[167] !== We ? (q = (fe, ft) => [fe.urlVarName ?? `${We}_${ft + 1}_URL`, fe.apikeyVarName ?? `${We}_${ft + 1}_API_KEY`], e[167] = We, e[168] = q) : q = e[168], ht = new Set(y.flatMap(q)), e[164] = We, e[165] = y, e[166] = ht;
1290
+ } else
1291
+ ht = e[166];
1292
+ const Et = ht;
1293
+ let je;
1294
+ e[169] !== r || e[170] !== a || e[171] !== Et ? (je = /* @__PURE__ */ n(rr, { formData: r, setFormData: a, llmReservedNames: Et }), e[169] = r, e[170] = a, e[171] = Et, e[172] = je) : je = e[172];
1295
+ let ut;
1296
+ return e[173] !== j || e[174] !== K || e[175] !== Ue || e[176] !== Me || e[177] !== ze || e[178] !== je ? (ut = /* @__PURE__ */ S(C.Stack, { spacing: 3, children: [
1297
+ j,
1298
+ K,
1299
+ Ue,
1300
+ Me,
1301
+ ze,
1302
+ je
1303
+ ] }), e[173] = j, e[174] = K, e[175] = Ue, e[176] = Me, e[177] = ze, e[178] = je, e[179] = ut) : ut = e[179], ut;
1304
+ };
1305
+ function gr(t) {
1306
+ console.error("Failed to generate name:", t);
1307
+ }
1308
+ function yr(t) {
1309
+ return t.key;
1310
+ }
1311
+ function vr(t) {
1312
+ return !!t;
1313
+ }
1314
+ const Jt = (t) => {
1315
+ const e = he(22), {
1316
+ lastSubmittedValidationErrors: r,
1317
+ isPending: a,
1318
+ onCancel: i,
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, b = g.length > 0;
1327
+ let N;
1328
+ e[2] !== g ? (N = /* @__PURE__ */ n(we, { severity: "error", children: g.map(br) }), e[2] = g, e[3] = N) : N = e[3];
1329
+ let l;
1330
+ e[4] !== b || e[5] !== N ? (l = /* @__PURE__ */ n(Ee, { in: b, timeout: "auto", unmountOnExit: !0, children: N }), e[4] = b, e[5] = N, e[6] = l) : l = e[6];
1331
+ let P;
1332
+ e[7] !== i ? (P = /* @__PURE__ */ n(Se, { variant: "outlined", color: "primary", size: "medium", onClick: i, children: "Cancel" }), e[7] = i, e[8] = P) : P = e[8];
1333
+ let x;
1334
+ e[9] !== d ? (x = d ? /* @__PURE__ */ n(Kt, { size: 16 }) : /* @__PURE__ */ n(Yn, { size: 16 }), e[9] = d, e[10] = x) : x = e[10];
1335
+ const E = a || m || c, A = d ? "Register" : "Deploy";
1336
+ let k;
1337
+ e[11] !== o || e[12] !== A || e[13] !== x || e[14] !== E ? (k = /* @__PURE__ */ n(Se, { variant: "contained", color: "primary", size: "medium", startIcon: x, onClick: o, disabled: E, children: A }), e[11] = o, e[12] = A, e[13] = x, e[14] = E, e[15] = k) : k = e[15];
1338
+ let V;
1339
+ e[16] !== k || e[17] !== P ? (V = /* @__PURE__ */ S(re, { display: "flex", flexDirection: "row", gap: 1, alignItems: "center", children: [
1340
+ P,
1341
+ k
1342
+ ] }), e[16] = k, e[17] = P, e[18] = V) : V = e[18];
1343
+ let T;
1344
+ return e[19] !== V || e[20] !== l ? (T = /* @__PURE__ */ S(re, { display: "flex", flexDirection: "column", gap: 3, children: [
1345
+ l,
1346
+ V
1347
+ ] }), e[19] = V, e[20] = l, e[21] = T) : T = e[21], T;
1348
+ };
1349
+ function br(t, e) {
1350
+ return /* @__PURE__ */ n(re, { children: t }, e);
1351
+ }
1352
+ function Sr(t) {
1353
+ const e = {};
1354
+ for (const [a, i] of Object.entries(t.selectedProviderByEnv))
1355
+ i && (e[a] = {
1356
+ providerName: i.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 gt(t) {
1385
+ if (!t.length) return;
1386
+ const e = t.map(Sr).filter((r) => r !== null);
1387
+ return e.length > 0 ? e : void 0;
1388
+ }
1389
+ const Xt = (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
+ ...gt(r) ? {
1440
+ modelConfig: gt(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
+ ...gt(r) ? {
1457
+ modelConfig: gt(r)
1458
+ } : {}
1459
+ }
1460
+ }, Cr = () => {
1461
+ const t = he(57), e = bt(), {
1462
+ orgId: r,
1463
+ projectId: a
1464
+ } = Ce();
1465
+ let i;
1466
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (i = {
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] = i) : i = t[0];
1485
+ const [o, h] = de(i), {
1486
+ errors: y,
1487
+ validateForm: v,
1488
+ setFieldError: s,
1489
+ validateField: m
1490
+ } = Rt(er);
1491
+ let c;
1492
+ t[1] === Symbol.for("react.memo_cache_sentinel") ? (c = [], t[1] = c) : c = t[1];
1493
+ const [d, p] = de(c), {
1494
+ mutate: g,
1495
+ isPending: b,
1496
+ error: N
1497
+ } = Bt(), l = r ?? "default", P = a ?? "default";
1498
+ let x;
1499
+ t[2] !== l || t[3] !== P ? (x = {
1500
+ orgName: l,
1501
+ projName: P
1502
+ }, t[2] = l, t[3] = P, t[4] = x) : x = t[4];
1503
+ const E = x;
1504
+ let A;
1505
+ t[5] !== e || t[6] !== r || t[7] !== a ? (A = () => {
1506
+ e(be(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] = A) : A = t[8];
1511
+ const k = A;
1512
+ let V;
1513
+ t[9] === Symbol.for("react.memo_cache_sentinel") ? (V = {}, t[9] = V) : V = t[9];
1514
+ const [T, D] = de(V);
1515
+ let I;
1516
+ t[10] !== g || t[11] !== y || t[12] !== o || t[13] !== d || t[14] !== e || t[15] !== E || t[16] !== v ? (I = () => {
1517
+ if (v(o))
1518
+ D({});
1519
+ else {
1520
+ D(y);
1521
+ return;
1522
+ }
1523
+ const O = Xt(o, E, d);
1524
+ g(O, {
1525
+ onSuccess: () => {
1526
+ e(be(ve.children.org.children.projects.children.agents.path, {
1527
+ orgId: E.orgName ?? "",
1528
+ projectId: E.projName ?? "",
1529
+ agentId: O.body.name
1530
+ }) + "?setup=true");
1531
+ },
1532
+ onError: Nr
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] = I) : I = t[17];
1535
+ const $ = I, G = r ?? "", U = a ?? "default";
1536
+ let w;
1537
+ t[18] !== G || t[19] !== U ? (w = be(ve.children.org.children.projects.children.newAgent.path, {
1538
+ orgId: G,
1539
+ projectId: U
1540
+ }), t[18] = G, t[19] = U, t[20] = w) : w = t[20];
1541
+ const B = w;
1542
+ let M;
1543
+ t[21] !== y || t[22] !== o || t[23] !== d || t[24] !== s || t[25] !== m ? (M = /* @__PURE__ */ n(fr, { 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] = M) : M = 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 F = !o.name.trim();
1549
+ let u;
1550
+ e: {
1551
+ let O;
1552
+ t[29] !== o.displayName ? (O = o.displayName ? o.displayName.toUpperCase().replace(/[^A-Z0-9]/g, "_") : "AGENT", t[29] = o.displayName, t[30] = O) : O = t[30];
1553
+ const Y = O;
1554
+ let Z, H;
1555
+ if (t[31] !== Y || t[32] !== d) {
1556
+ let W;
1557
+ t[35] !== Y ? (W = (K, ee) => [K.urlVarName ?? `${Y}_${ee + 1}_URL`, K.apikeyVarName ?? `${Y}_${ee + 1}_API_KEY`], t[35] = Y, t[36] = W) : W = t[36], Z = d.flatMap(W), H = new Set(Z), t[31] = Y, t[32] = d, t[33] = Z, t[34] = H;
1558
+ } else
1559
+ Z = t[33], H = t[34];
1560
+ const Q = H;
1561
+ if (Z.length !== Q.size) {
1562
+ u = !0;
1563
+ break e;
1564
+ }
1565
+ let L;
1566
+ if (t[37] !== o.env || t[38] !== Q) {
1567
+ const W = (o.env ?? []).map(Pr).filter(xr);
1568
+ if (W.length !== new Set(W).size) {
1569
+ u = !0;
1570
+ break e;
1571
+ }
1572
+ let K;
1573
+ t[41] !== Q ? (K = (ee) => Q.has(ee), t[41] = Q, t[42] = K) : K = t[42], L = W.some(K), t[37] = o.env, t[38] = Q, t[39] = L, t[40] = u;
1574
+ } else
1575
+ L = t[39], u = t[40];
1576
+ u = L;
1577
+ }
1578
+ let f;
1579
+ t[43] !== k || t[44] !== $ || t[45] !== b || t[46] !== T || t[47] !== F || t[48] !== u ? (f = /* @__PURE__ */ n(Jt, { lastSubmittedValidationErrors: T, isPending: b, onCancel: k, onSubmit: $, isNameEmpty: F, mode: "deploy", hasLLMVarConflicts: u }), t[43] = k, t[44] = $, t[45] = b, t[46] = T, t[47] = F, t[48] = u, t[49] = f) : f = t[49];
1580
+ let _;
1581
+ t[50] !== M || t[51] !== j || t[52] !== f ? (_ = /* @__PURE__ */ S(C.Stack, { spacing: 3, children: [
1582
+ M,
1583
+ j,
1584
+ f
1585
+ ] }), t[50] = M, t[51] = j, t[52] = f, t[53] = _) : _ = t[53];
1586
+ let R;
1587
+ return t[54] !== B || t[55] !== _ ? (R = /* @__PURE__ */ n(Dt, { title: "Create a Platform-Hosted Agent", description: "Specify the source repository, select the agent type, and deploy it on the platform.", disableIcon: !0, backHref: B, backLabel: "Back to Agent Hosting Options", children: _ }), t[54] = B, t[55] = _, t[56] = R) : R = t[56], R;
1588
+ };
1589
+ function Nr(t) {
1590
+ console.error("Failed to create agent:", t);
1591
+ }
1592
+ function Pr(t) {
1593
+ return t.key;
1594
+ }
1595
+ function xr(t) {
1596
+ return !!t;
1597
+ }
1598
+ const kr = ({
1599
+ formData: t,
1600
+ setFormData: e,
1601
+ errors: r,
1602
+ setFieldError: a,
1603
+ validateField: i
1604
+ }) => {
1605
+ const {
1606
+ orgId: o,
1607
+ projectId: h
1608
+ } = Ce(), {
1609
+ mutate: y,
1610
+ isPending: v
1611
+ } = Ft({
1612
+ orgName: o
1613
+ }), s = Pe((c, d) => {
1614
+ e((p) => {
1615
+ const g = {
1616
+ ...p,
1617
+ [c]: d
1618
+ }, b = i(c, d, g);
1619
+ return a(c, b), g;
1620
+ });
1621
+ }, [e, i, a]), m = Vt(
1622
+ () => Gt.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 vt(() => () => {
1644
+ m.cancel();
1645
+ }, [m]), vt(() => {
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(St, { size: 12 }),
1652
+ /* @__PURE__ */ n(z, { 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
+ }, Ar = () => {
1658
+ const t = he(41), e = bt(), {
1659
+ orgId: r,
1660
+ projectId: a
1661
+ } = Ce();
1662
+ let i;
1663
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (i = {
1664
+ deploymentType: "existing",
1665
+ name: "",
1666
+ displayName: "",
1667
+ description: ""
1668
+ }, t[0] = i) : i = t[0];
1669
+ const [o, h] = de(i), {
1670
+ errors: y,
1671
+ validateForm: v,
1672
+ setFieldError: s,
1673
+ validateField: m
1674
+ } = Rt(Xn), {
1675
+ mutate: c,
1676
+ isPending: d,
1677
+ error: p
1678
+ } = Bt(), g = r ?? "default", b = a ?? "default";
1679
+ let N;
1680
+ t[1] !== g || t[2] !== b ? (N = {
1681
+ orgName: g,
1682
+ projName: b
1683
+ }, t[1] = g, t[2] = b, t[3] = N) : N = t[3];
1684
+ const l = N;
1685
+ let P;
1686
+ t[4] !== e || t[5] !== r || t[6] !== a ? (P = () => {
1687
+ e(be(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 x = P;
1693
+ let E;
1694
+ t[8] !== c || t[9] !== e || t[10] !== l ? (E = (_) => {
1695
+ const R = Xt(_, l);
1696
+ c(R, {
1697
+ onSuccess: () => {
1698
+ e(be(ve.children.org.children.projects.children.agents.path, {
1699
+ orgId: l.orgName ?? "",
1700
+ projectId: l.projName ?? "",
1701
+ agentId: R.body.name
1702
+ }) + "?setup=true");
1703
+ },
1704
+ onError: _r
1705
+ });
1706
+ }, t[8] = c, t[9] = e, t[10] = l, t[11] = E) : E = t[11];
1707
+ const A = E;
1708
+ let k;
1709
+ t[12] === Symbol.for("react.memo_cache_sentinel") ? (k = {}, t[12] = k) : k = t[12];
1710
+ const [V, T] = de(k);
1711
+ let D;
1712
+ t[13] !== y || t[14] !== o || t[15] !== A || t[16] !== v ? (D = () => {
1713
+ if (v(o))
1714
+ T({});
1715
+ else {
1716
+ T(y);
1717
+ return;
1718
+ }
1719
+ A(o);
1720
+ }, t[13] = y, t[14] = o, t[15] = A, t[16] = v, t[17] = D) : D = t[17];
1721
+ const I = D, $ = r ?? "", G = a ?? "default";
1722
+ let U;
1723
+ t[18] !== $ || t[19] !== G ? (U = be(ve.children.org.children.projects.children.newAgent.path, {
1724
+ orgId: $,
1725
+ projectId: G
1726
+ }), t[18] = $, t[19] = G, t[20] = U) : U = t[20];
1727
+ const w = U;
1728
+ let B;
1729
+ t[21] !== y || t[22] !== o || t[23] !== s || t[24] !== m ? (B = /* @__PURE__ */ n(kr, { formData: o, setFormData: h, errors: y, setFieldError: s, validateField: m }), t[21] = y, t[22] = o, t[23] = s, t[24] = m, t[25] = B) : B = t[25];
1730
+ let M;
1731
+ t[26] !== p ? (M = !!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] = M) : M = t[27];
1734
+ const j = !o.name.trim();
1735
+ let F;
1736
+ t[28] !== x || t[29] !== I || t[30] !== d || t[31] !== V || t[32] !== j ? (F = /* @__PURE__ */ n(Jt, { lastSubmittedValidationErrors: V, isPending: d, onCancel: x, onSubmit: I, isNameEmpty: j, mode: "connect" }), t[28] = x, t[29] = I, t[30] = d, t[31] = V, t[32] = j, t[33] = F) : F = t[33];
1737
+ let u;
1738
+ t[34] !== B || t[35] !== M || t[36] !== F ? (u = /* @__PURE__ */ S(C.Stack, { spacing: 3, children: [
1739
+ B,
1740
+ M,
1741
+ F
1742
+ ] }), t[34] = B, t[35] = M, t[36] = F, t[37] = u) : u = t[37];
1743
+ let f;
1744
+ return t[38] !== w || t[39] !== u ? (f = /* @__PURE__ */ n(Dt, { 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: u }), t[38] = w, t[39] = u, t[40] = f) : f = t[40], f;
1745
+ };
1746
+ function _r(t) {
1747
+ console.error("Failed to register agent:", t);
1748
+ }
1749
+ const Er = () => {
1750
+ const t = he(10), e = bt(), {
1751
+ orgId: r,
1752
+ projectId: a
1753
+ } = Ce(), i = ve.children.org.children.projects.children.newAgent, o = i.children.create.path, h = i.children.connect.path;
1754
+ let y;
1755
+ t[0] !== e || t[1] !== r || t[2] !== a ? (y = (p) => {
1756
+ e(be(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(Tt, { index: !0, element: /* @__PURE__ */ n(Jn, { 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(Tt, { path: "create", element: /* @__PURE__ */ n(Cr, {}) }), t[6] = m) : m = t[6];
1766
+ let c;
1767
+ t[7] === Symbol.for("react.memo_cache_sentinel") ? (c = /* @__PURE__ */ n(Tt, { path: "connect", element: /* @__PURE__ */ n(Ar, {}) }), t[7] = c) : c = t[7];
1768
+ let d;
1769
+ return t[8] !== s ? (d = /* @__PURE__ */ S(rn, { children: [
1770
+ s,
1771
+ m,
1772
+ c
1773
+ ] }), t[8] = s, t[9] = d) : d = t[9], d;
1774
+ }, Ur = {
1775
+ title: "Add New Agent",
1776
+ description: "A page component for Add New Agent",
1777
+ icon: Qn,
1778
+ path: ve.children.org.children.projects.children.newAgent.path,
1779
+ component: Er
1780
+ };
1781
+ export {
1782
+ Er as AddNewAgent,
1783
+ Ur as metaData
1784
+ };