@mieweb/q 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +932 -932
- package/dist/AgentConfigGenerator-C5V82CgF.cjs +4 -0
- package/dist/AgentConfigGenerator-DzrPmrXi.js +2198 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/universal.cjs +1 -1
- package/dist/universal.js +40 -36
- package/package.json +69 -65
- package/postcss.config.js +6 -6
- package/src/index.css +65 -65
- package/tailwind.config.js +27 -27
- package/dist/AgentConfigGenerator-CQkFCXJI.cjs +0 -4
- package/dist/AgentConfigGenerator-DLoMdUYG.js +0 -1903
|
@@ -0,0 +1,2198 @@
|
|
|
1
|
+
import { jsxs as w, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as H, useMemo as Qe, useCallback as G, useEffect as Z, useState as V } from "react";
|
|
3
|
+
import pe from "js-yaml";
|
|
4
|
+
import { Download as _e, Copy as Ge, Plus as de, Trash2 as fe, Search as Ze, KeyRound as Me, Settings as Xe, Wrench as en, Code as nn, Send as tn, Pencil as rn, Upload as an, RotateCcw as on, ArrowLeft as ln } from "lucide-react";
|
|
5
|
+
import { Card as ge, Button as F, Input as W, Select as le, Checkbox as se, Tabs as sn, TabsList as cn, TabsTrigger as ue, Alert as un, AlertDescription as dn } from "@mieweb/ui";
|
|
6
|
+
import { QuestionnaireRenderer as fn } from "@mieweb/forms-renderer";
|
|
7
|
+
import mn from "@monaco-editor/react";
|
|
8
|
+
const hn = "mieforms-v1.0", vn = "Agent Configuration", pn = [
|
|
9
|
+
{
|
|
10
|
+
id: "sec-basic",
|
|
11
|
+
fieldType: "section",
|
|
12
|
+
title: "Basic Info",
|
|
13
|
+
fields: [
|
|
14
|
+
{
|
|
15
|
+
id: "_id",
|
|
16
|
+
fieldType: "text",
|
|
17
|
+
question: "Config ID (_id)",
|
|
18
|
+
answer: "",
|
|
19
|
+
required: !1
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: "name",
|
|
23
|
+
fieldType: "text",
|
|
24
|
+
question: "Name",
|
|
25
|
+
answer: "New Agent Config",
|
|
26
|
+
required: !1
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "timezone",
|
|
30
|
+
fieldType: "dropdown",
|
|
31
|
+
question: "Timezone",
|
|
32
|
+
answer: "America/New_York",
|
|
33
|
+
required: !1,
|
|
34
|
+
options: [
|
|
35
|
+
{
|
|
36
|
+
id: "tz-ny",
|
|
37
|
+
label: "America/New_York",
|
|
38
|
+
value: "America/New_York"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "tz-chi",
|
|
42
|
+
label: "America/Chicago",
|
|
43
|
+
value: "America/Chicago"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "tz-den",
|
|
47
|
+
label: "America/Denver",
|
|
48
|
+
value: "America/Denver"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "tz-la",
|
|
52
|
+
label: "America/Los_Angeles",
|
|
53
|
+
value: "America/Los_Angeles"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "tz-hon",
|
|
57
|
+
label: "Pacific/Honolulu",
|
|
58
|
+
value: "Pacific/Honolulu"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "tz-anc",
|
|
62
|
+
label: "America/Anchorage",
|
|
63
|
+
value: "America/Anchorage"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "tz-phx",
|
|
67
|
+
label: "America/Phoenix",
|
|
68
|
+
value: "America/Phoenix"
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: "description",
|
|
74
|
+
fieldType: "text",
|
|
75
|
+
question: "Description",
|
|
76
|
+
answer: "Agent Assistant Description",
|
|
77
|
+
required: !1
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: "sec-telephony",
|
|
83
|
+
fieldType: "section",
|
|
84
|
+
title: "Telephony Settings",
|
|
85
|
+
fields: [
|
|
86
|
+
{
|
|
87
|
+
id: "twilio.phoneNumber",
|
|
88
|
+
fieldType: "text",
|
|
89
|
+
question: "Twilio Phone Number",
|
|
90
|
+
answer: "",
|
|
91
|
+
required: !1
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: "twilio.accountSid",
|
|
95
|
+
fieldType: "text",
|
|
96
|
+
question: "Twilio Account SID",
|
|
97
|
+
answer: "",
|
|
98
|
+
required: !1
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: "twilio.authToken",
|
|
102
|
+
fieldType: "text",
|
|
103
|
+
question: "Twilio Auth Token",
|
|
104
|
+
answer: "",
|
|
105
|
+
required: !1
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: "sec-office",
|
|
111
|
+
fieldType: "section",
|
|
112
|
+
title: "Office Hours",
|
|
113
|
+
fields: [
|
|
114
|
+
{
|
|
115
|
+
id: "officeOpeningTime",
|
|
116
|
+
fieldType: "dropdown",
|
|
117
|
+
question: "Opening Time (Hour)",
|
|
118
|
+
answer: "8",
|
|
119
|
+
required: !1,
|
|
120
|
+
configType: "number",
|
|
121
|
+
options: [
|
|
122
|
+
{
|
|
123
|
+
id: "h0",
|
|
124
|
+
label: "0:00",
|
|
125
|
+
value: "0"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
id: "h1",
|
|
129
|
+
label: "1:00",
|
|
130
|
+
value: "1"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
id: "h2",
|
|
134
|
+
label: "2:00",
|
|
135
|
+
value: "2"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: "h3",
|
|
139
|
+
label: "3:00",
|
|
140
|
+
value: "3"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
id: "h4",
|
|
144
|
+
label: "4:00",
|
|
145
|
+
value: "4"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
id: "h5",
|
|
149
|
+
label: "5:00",
|
|
150
|
+
value: "5"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
id: "h6",
|
|
154
|
+
label: "6:00",
|
|
155
|
+
value: "6"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
id: "h7",
|
|
159
|
+
label: "7:00",
|
|
160
|
+
value: "7"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
id: "h8",
|
|
164
|
+
label: "8:00",
|
|
165
|
+
value: "8"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: "h9",
|
|
169
|
+
label: "9:00",
|
|
170
|
+
value: "9"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
id: "h10",
|
|
174
|
+
label: "10:00",
|
|
175
|
+
value: "10"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
id: "h11",
|
|
179
|
+
label: "11:00",
|
|
180
|
+
value: "11"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
id: "h12",
|
|
184
|
+
label: "12:00",
|
|
185
|
+
value: "12"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
id: "h13",
|
|
189
|
+
label: "13:00",
|
|
190
|
+
value: "13"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
id: "h14",
|
|
194
|
+
label: "14:00",
|
|
195
|
+
value: "14"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
id: "h15",
|
|
199
|
+
label: "15:00",
|
|
200
|
+
value: "15"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
id: "h16",
|
|
204
|
+
label: "16:00",
|
|
205
|
+
value: "16"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
id: "h17",
|
|
209
|
+
label: "17:00",
|
|
210
|
+
value: "17"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
id: "h18",
|
|
214
|
+
label: "18:00",
|
|
215
|
+
value: "18"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
id: "h19",
|
|
219
|
+
label: "19:00",
|
|
220
|
+
value: "19"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
id: "h20",
|
|
224
|
+
label: "20:00",
|
|
225
|
+
value: "20"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
id: "h21",
|
|
229
|
+
label: "21:00",
|
|
230
|
+
value: "21"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
id: "h22",
|
|
234
|
+
label: "22:00",
|
|
235
|
+
value: "22"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
id: "h23",
|
|
239
|
+
label: "23:00",
|
|
240
|
+
value: "23"
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
id: "officeClosingTime",
|
|
246
|
+
fieldType: "dropdown",
|
|
247
|
+
question: "Closing Time (Hour)",
|
|
248
|
+
answer: "17",
|
|
249
|
+
required: !1,
|
|
250
|
+
configType: "number",
|
|
251
|
+
options: [
|
|
252
|
+
{
|
|
253
|
+
id: "h0",
|
|
254
|
+
label: "0:00",
|
|
255
|
+
value: "0"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
id: "h1",
|
|
259
|
+
label: "1:00",
|
|
260
|
+
value: "1"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
id: "h2",
|
|
264
|
+
label: "2:00",
|
|
265
|
+
value: "2"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
id: "h3",
|
|
269
|
+
label: "3:00",
|
|
270
|
+
value: "3"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
id: "h4",
|
|
274
|
+
label: "4:00",
|
|
275
|
+
value: "4"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
id: "h5",
|
|
279
|
+
label: "5:00",
|
|
280
|
+
value: "5"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
id: "h6",
|
|
284
|
+
label: "6:00",
|
|
285
|
+
value: "6"
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
id: "h7",
|
|
289
|
+
label: "7:00",
|
|
290
|
+
value: "7"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
id: "h8",
|
|
294
|
+
label: "8:00",
|
|
295
|
+
value: "8"
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
id: "h9",
|
|
299
|
+
label: "9:00",
|
|
300
|
+
value: "9"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
id: "h10",
|
|
304
|
+
label: "10:00",
|
|
305
|
+
value: "10"
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
id: "h11",
|
|
309
|
+
label: "11:00",
|
|
310
|
+
value: "11"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
id: "h12",
|
|
314
|
+
label: "12:00",
|
|
315
|
+
value: "12"
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
id: "h13",
|
|
319
|
+
label: "13:00",
|
|
320
|
+
value: "13"
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
id: "h14",
|
|
324
|
+
label: "14:00",
|
|
325
|
+
value: "14"
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
id: "h15",
|
|
329
|
+
label: "15:00",
|
|
330
|
+
value: "15"
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
id: "h16",
|
|
334
|
+
label: "16:00",
|
|
335
|
+
value: "16"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
id: "h17",
|
|
339
|
+
label: "17:00",
|
|
340
|
+
value: "17"
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
id: "h18",
|
|
344
|
+
label: "18:00",
|
|
345
|
+
value: "18"
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
id: "h19",
|
|
349
|
+
label: "19:00",
|
|
350
|
+
value: "19"
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
id: "h20",
|
|
354
|
+
label: "20:00",
|
|
355
|
+
value: "20"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
id: "h21",
|
|
359
|
+
label: "21:00",
|
|
360
|
+
value: "21"
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
id: "h22",
|
|
364
|
+
label: "22:00",
|
|
365
|
+
value: "22"
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
id: "h23",
|
|
369
|
+
label: "23:00",
|
|
370
|
+
value: "23"
|
|
371
|
+
}
|
|
372
|
+
]
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
id: "afterHoursNotice",
|
|
376
|
+
fieldType: "longtext",
|
|
377
|
+
question: "After Hours Notice",
|
|
378
|
+
answer: "Our office is currently closed.",
|
|
379
|
+
required: !1
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
id: "officeHoursHumanNumber",
|
|
383
|
+
fieldType: "text",
|
|
384
|
+
question: "Human Handover Number",
|
|
385
|
+
answer: "",
|
|
386
|
+
required: !1
|
|
387
|
+
}
|
|
388
|
+
]
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
id: "sec-webchart",
|
|
392
|
+
fieldType: "section",
|
|
393
|
+
title: "WebChart Integration",
|
|
394
|
+
fields: [
|
|
395
|
+
{
|
|
396
|
+
id: "webchart.url",
|
|
397
|
+
fieldType: "text",
|
|
398
|
+
question: "WebChart URL",
|
|
399
|
+
answer: "",
|
|
400
|
+
required: !1
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
id: "webchart.username",
|
|
404
|
+
fieldType: "text",
|
|
405
|
+
question: "WebChart Username",
|
|
406
|
+
answer: "",
|
|
407
|
+
required: !1
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
id: "webchart.password",
|
|
411
|
+
fieldType: "text",
|
|
412
|
+
question: "WebChart Password",
|
|
413
|
+
answer: "",
|
|
414
|
+
required: !1
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
id: "defaultServiceLocation",
|
|
418
|
+
fieldType: "text",
|
|
419
|
+
question: "Default Service Location",
|
|
420
|
+
answer: "",
|
|
421
|
+
required: !1
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
id: "defaultPatientId",
|
|
425
|
+
fieldType: "text",
|
|
426
|
+
question: "Default Patient ID",
|
|
427
|
+
answer: "",
|
|
428
|
+
required: !1,
|
|
429
|
+
configType: "number"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
id: "transcript_doc_type",
|
|
433
|
+
fieldType: "text",
|
|
434
|
+
question: "Transcript Doc Type",
|
|
435
|
+
answer: "",
|
|
436
|
+
required: !1
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
id: "defaultPhysicianId",
|
|
440
|
+
fieldType: "text",
|
|
441
|
+
question: "Default Physician ID",
|
|
442
|
+
answer: "",
|
|
443
|
+
required: !1,
|
|
444
|
+
configType: "number"
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
id: "userId",
|
|
448
|
+
fieldType: "text",
|
|
449
|
+
question: "User ID",
|
|
450
|
+
answer: "",
|
|
451
|
+
required: !1
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
id: "visitType",
|
|
455
|
+
fieldType: "text",
|
|
456
|
+
question: "Visit Type",
|
|
457
|
+
answer: "",
|
|
458
|
+
required: !1
|
|
459
|
+
}
|
|
460
|
+
]
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
id: "sec-audio",
|
|
464
|
+
fieldType: "section",
|
|
465
|
+
title: "Audio Configuration",
|
|
466
|
+
fields: [
|
|
467
|
+
{
|
|
468
|
+
id: "elevenLabsPronunciationDictionaries",
|
|
469
|
+
fieldType: "text",
|
|
470
|
+
question: "ElevenLabs Pronunciation Dictionary IDs (comma-separated)",
|
|
471
|
+
answer: "",
|
|
472
|
+
required: !1,
|
|
473
|
+
configTransform: "elevenLabsDictIds"
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
id: "elevenLabsPronunciationDictionaries__versions",
|
|
477
|
+
fieldType: "text",
|
|
478
|
+
question: "ElevenLabs Pronunciation Dictionary Version IDs (comma-separated)",
|
|
479
|
+
answer: "",
|
|
480
|
+
required: !1,
|
|
481
|
+
configTransform: "elevenLabsDictVersions"
|
|
482
|
+
}
|
|
483
|
+
]
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
id: "sec-agent",
|
|
487
|
+
fieldType: "section",
|
|
488
|
+
title: "Agent Specific Info",
|
|
489
|
+
fields: [
|
|
490
|
+
{
|
|
491
|
+
id: "welcome",
|
|
492
|
+
fieldType: "longtext",
|
|
493
|
+
question: "Welcome Message",
|
|
494
|
+
answer: "Thank you for calling. How can I help you today?",
|
|
495
|
+
required: !1
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
id: "systemPrompt",
|
|
499
|
+
fieldType: "longtext",
|
|
500
|
+
question: "System Prompt",
|
|
501
|
+
answer: "You are a helpful AI assistant.",
|
|
502
|
+
required: !1
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
id: "disabledGenericTools",
|
|
506
|
+
fieldType: "check",
|
|
507
|
+
question: "Enabled Generic Tools",
|
|
508
|
+
answer: [],
|
|
509
|
+
required: !1,
|
|
510
|
+
configTransform: "genericToolsInvert",
|
|
511
|
+
options: [
|
|
512
|
+
{
|
|
513
|
+
id: "gt-hangup",
|
|
514
|
+
label: "force_hangup_bad_call",
|
|
515
|
+
value: "force_hangup_bad_call"
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
id: "gt-birthdate",
|
|
519
|
+
label: "validate_birth_date",
|
|
520
|
+
value: "validate_birth_date"
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
id: "gt-goodbye",
|
|
524
|
+
label: "thanks_for_calling_goodbye",
|
|
525
|
+
value: "thanks_for_calling_goodbye"
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
id: "gt-human",
|
|
529
|
+
label: "connect_to_a_human",
|
|
530
|
+
value: "connect_to_a_human"
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
id: "gt-multiple",
|
|
534
|
+
label: "handle_multiple_patients",
|
|
535
|
+
value: "handle_multiple_patients"
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
id: "gt-schedule",
|
|
539
|
+
label: "schedule_call_later",
|
|
540
|
+
value: "schedule_call_later"
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
id: "gt-objective",
|
|
544
|
+
label: "mark_objective_complete",
|
|
545
|
+
value: "mark_objective_complete"
|
|
546
|
+
}
|
|
547
|
+
]
|
|
548
|
+
}
|
|
549
|
+
]
|
|
550
|
+
}
|
|
551
|
+
], re = {
|
|
552
|
+
schemaType: hn,
|
|
553
|
+
title: vn,
|
|
554
|
+
fields: pn
|
|
555
|
+
};
|
|
556
|
+
function qe(e) {
|
|
557
|
+
const t = [];
|
|
558
|
+
for (const n of e || [])
|
|
559
|
+
n.fieldType === "section" && Array.isArray(n.fields) ? t.push(...qe(n.fields)) : t.push(n);
|
|
560
|
+
return t;
|
|
561
|
+
}
|
|
562
|
+
function gn(e, t) {
|
|
563
|
+
return t.split(".").reduce(function(n, r) {
|
|
564
|
+
return n ? n[r] : void 0;
|
|
565
|
+
}, e);
|
|
566
|
+
}
|
|
567
|
+
function yn(e, t) {
|
|
568
|
+
const n = qe((t || re).fields), r = [];
|
|
569
|
+
for (const o of n) {
|
|
570
|
+
if (!o.id || o.id.startsWith("sec-") || !o.required) continue;
|
|
571
|
+
const a = gn(e, o.id);
|
|
572
|
+
(a == null || a === "") && r.push(`${o.text || o.question || o.id} is required`);
|
|
573
|
+
}
|
|
574
|
+
return r;
|
|
575
|
+
}
|
|
576
|
+
function be(e) {
|
|
577
|
+
return pe.dump(e, {
|
|
578
|
+
lineWidth: -1,
|
|
579
|
+
forceQuotes: !1,
|
|
580
|
+
quotingType: '"',
|
|
581
|
+
noCompatMode: !0,
|
|
582
|
+
styles: { "!!null": "empty" },
|
|
583
|
+
replacer: function(t, n) {
|
|
584
|
+
return n === "" ? null : n;
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
function Zn(e) {
|
|
589
|
+
return pe.load(e);
|
|
590
|
+
}
|
|
591
|
+
function bn(e, t, n, r = "yaml", o = "") {
|
|
592
|
+
const a = yn(e);
|
|
593
|
+
if (a.length > 0) {
|
|
594
|
+
alert(`Please fix the following errors before downloading:
|
|
595
|
+
|
|
596
|
+
- ${a.join(`
|
|
597
|
+
- `)}`);
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
const s = r === "json", u = s ? o : t, c = s ? "application/json" : "text/yaml", x = s ? "config.json" : "config.yaml";
|
|
601
|
+
if (n) {
|
|
602
|
+
n(u, r);
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
const S = new Blob([u], { type: c }), f = URL.createObjectURL(S), C = document.createElement("a");
|
|
606
|
+
C.href = f, C.download = x, document.body.appendChild(C), C.click(), document.body.removeChild(C), URL.revokeObjectURL(f);
|
|
607
|
+
}
|
|
608
|
+
async function wn(e) {
|
|
609
|
+
try {
|
|
610
|
+
await navigator.clipboard.writeText(e), alert("Copied to clipboard!");
|
|
611
|
+
} catch (t) {
|
|
612
|
+
console.error("Clipboard failed:", t), alert("Failed to copy to clipboard. Please check your browser permissions or try again.");
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
let oe;
|
|
616
|
+
const Tn = new Uint8Array(16);
|
|
617
|
+
function xn() {
|
|
618
|
+
if (!oe && (oe = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !oe))
|
|
619
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
620
|
+
return oe(Tn);
|
|
621
|
+
}
|
|
622
|
+
const L = [];
|
|
623
|
+
for (let e = 0; e < 256; ++e)
|
|
624
|
+
L.push((e + 256).toString(16).slice(1));
|
|
625
|
+
function Cn(e, t = 0) {
|
|
626
|
+
return L[e[t + 0]] + L[e[t + 1]] + L[e[t + 2]] + L[e[t + 3]] + "-" + L[e[t + 4]] + L[e[t + 5]] + "-" + L[e[t + 6]] + L[e[t + 7]] + "-" + L[e[t + 8]] + L[e[t + 9]] + "-" + L[e[t + 10]] + L[e[t + 11]] + L[e[t + 12]] + L[e[t + 13]] + L[e[t + 14]] + L[e[t + 15]];
|
|
627
|
+
}
|
|
628
|
+
const Nn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), we = {
|
|
629
|
+
randomUUID: Nn
|
|
630
|
+
};
|
|
631
|
+
function Sn(e, t, n) {
|
|
632
|
+
if (we.randomUUID && !e)
|
|
633
|
+
return we.randomUUID();
|
|
634
|
+
e = e || {};
|
|
635
|
+
const r = e.random || (e.rng || xn)();
|
|
636
|
+
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Cn(r);
|
|
637
|
+
}
|
|
638
|
+
function K(e, t, n) {
|
|
639
|
+
const r = t.split(".");
|
|
640
|
+
let o = e;
|
|
641
|
+
for (let a = 0; a < r.length - 1; a++)
|
|
642
|
+
(!o[r[a]] || typeof o[r[a]] != "object") && (o[r[a]] = {}), o = o[r[a]];
|
|
643
|
+
o[r[r.length - 1]] = n;
|
|
644
|
+
}
|
|
645
|
+
function X(e, t) {
|
|
646
|
+
const n = t.split(".");
|
|
647
|
+
let r = e;
|
|
648
|
+
for (const o of n) {
|
|
649
|
+
if (r == null) return;
|
|
650
|
+
r = r[o];
|
|
651
|
+
}
|
|
652
|
+
return r;
|
|
653
|
+
}
|
|
654
|
+
function Ie(e, t) {
|
|
655
|
+
if (t === "number") {
|
|
656
|
+
if (e === "" || e == null) return "";
|
|
657
|
+
const n = Number(e);
|
|
658
|
+
return isNaN(n) ? "" : n;
|
|
659
|
+
}
|
|
660
|
+
return t === "boolean" ? typeof e == "boolean" ? e : e === "true" || e === !0 : e ?? "";
|
|
661
|
+
}
|
|
662
|
+
function B(e) {
|
|
663
|
+
return e.id;
|
|
664
|
+
}
|
|
665
|
+
function Ee(e, t) {
|
|
666
|
+
const n = t.split(".");
|
|
667
|
+
let r = e;
|
|
668
|
+
for (let o = 0; o < n.length - 1; o++) {
|
|
669
|
+
if (r == null || typeof r != "object") return;
|
|
670
|
+
r = r[n[o]];
|
|
671
|
+
}
|
|
672
|
+
r != null && typeof r == "object" && delete r[n[n.length - 1]];
|
|
673
|
+
}
|
|
674
|
+
function Te(e, t, n) {
|
|
675
|
+
const r = t.split("."), o = n.split(".");
|
|
676
|
+
if (r.length === 1 && o.length === 1) {
|
|
677
|
+
const u = {};
|
|
678
|
+
for (const c of Object.keys(e))
|
|
679
|
+
c === r[0] ? u[o[0]] = e[c] : u[c] = e[c];
|
|
680
|
+
return u;
|
|
681
|
+
}
|
|
682
|
+
if (r.length === o.length && r.slice(0, -1).join(".") === o.slice(0, -1).join(".")) {
|
|
683
|
+
const u = structuredClone(e);
|
|
684
|
+
let c = u;
|
|
685
|
+
for (let v = 0; v < r.length - 1; v++) {
|
|
686
|
+
if (c[r[v]] == null || typeof c[r[v]] != "object")
|
|
687
|
+
return e;
|
|
688
|
+
c = c[r[v]];
|
|
689
|
+
}
|
|
690
|
+
const x = r[r.length - 1], S = o[o.length - 1], f = {};
|
|
691
|
+
for (const v of Object.keys(c))
|
|
692
|
+
v === x ? f[S] = c[v] : f[v] = c[v];
|
|
693
|
+
let C = u;
|
|
694
|
+
for (let v = 0; v < r.length - 2; v++)
|
|
695
|
+
C = C[r[v]];
|
|
696
|
+
return C[r[r.length - 2]] = f, u;
|
|
697
|
+
}
|
|
698
|
+
const a = structuredClone(e), s = X(a, t);
|
|
699
|
+
return Ee(a, t), s !== void 0 && K(a, n, s), a;
|
|
700
|
+
}
|
|
701
|
+
function me(e, t) {
|
|
702
|
+
const n = {};
|
|
703
|
+
for (const r of Object.keys(e || {})) {
|
|
704
|
+
if (!t && (r === "tools" || r === "mcp_servers")) continue;
|
|
705
|
+
const o = t ? t + "." + r : r, a = e[r];
|
|
706
|
+
a && typeof a == "object" && !Array.isArray(a) ? Object.assign(n, me(a, o)) : n[o] = a;
|
|
707
|
+
}
|
|
708
|
+
return n;
|
|
709
|
+
}
|
|
710
|
+
function he(e, t, n) {
|
|
711
|
+
for (const r of e || []) {
|
|
712
|
+
if (r.id === t)
|
|
713
|
+
return r.id = n, !0;
|
|
714
|
+
if (r.fields && he(r.fields, t, n))
|
|
715
|
+
return !0;
|
|
716
|
+
}
|
|
717
|
+
return !1;
|
|
718
|
+
}
|
|
719
|
+
function Pe(e, t) {
|
|
720
|
+
if (!Array.isArray(e)) return !1;
|
|
721
|
+
const n = e.findIndex(function(r) {
|
|
722
|
+
return r.id === t;
|
|
723
|
+
});
|
|
724
|
+
if (n !== -1)
|
|
725
|
+
return e.splice(n, 1), !0;
|
|
726
|
+
for (const r of e)
|
|
727
|
+
if (r.fields && Pe(r.fields, t)) return !0;
|
|
728
|
+
return !1;
|
|
729
|
+
}
|
|
730
|
+
function Re(e, t) {
|
|
731
|
+
for (const n of e || [])
|
|
732
|
+
if (n.id === t || n.fields && Re(n.fields, t)) return !0;
|
|
733
|
+
return !1;
|
|
734
|
+
}
|
|
735
|
+
function An(e) {
|
|
736
|
+
return e.split(".").pop().replace(/([A-Z])/g, " $1").replace(/^(.)/, function(n) {
|
|
737
|
+
return n.toUpperCase();
|
|
738
|
+
}).trim();
|
|
739
|
+
}
|
|
740
|
+
function kn(e, t, n) {
|
|
741
|
+
const r = typeof n == "boolean" ? "dropdown" : "text", o = typeof n == "number" ? "number" : void 0, a = { id: t, fieldType: r, text: An(t), required: !1 };
|
|
742
|
+
o && (a.configType = o);
|
|
743
|
+
const s = t.includes(".") ? t.split(".").slice(0, -1).join(".") : null;
|
|
744
|
+
if (s) {
|
|
745
|
+
for (const c of e.fields || [])
|
|
746
|
+
if (c.fieldType === "section" && Array.isArray(c.fields) && !ee(c) && c.fields.some(function(S) {
|
|
747
|
+
return S.id && S.id.startsWith(s + ".");
|
|
748
|
+
})) {
|
|
749
|
+
c.fields.push(a);
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
const u = (e.fields || []).filter(function(c) {
|
|
754
|
+
return c.fieldType === "section" && !ee(c);
|
|
755
|
+
});
|
|
756
|
+
if (u.length > 0) {
|
|
757
|
+
const c = u[u.length - 1];
|
|
758
|
+
c.fields = c.fields || [], c.fields.push(a);
|
|
759
|
+
} else
|
|
760
|
+
e.fields = e.fields || [], e.fields.push(a);
|
|
761
|
+
}
|
|
762
|
+
function _n(e, t, n) {
|
|
763
|
+
const r = me(e), o = me(t), a = new Set(Object.keys(r)), s = new Set(Object.keys(o)), u = [...a].filter(function(A) {
|
|
764
|
+
return !s.has(A);
|
|
765
|
+
}), c = [...s].filter(function(A) {
|
|
766
|
+
return !a.has(A);
|
|
767
|
+
});
|
|
768
|
+
if (u.length === 0 && c.length === 0) return n;
|
|
769
|
+
const x = structuredClone(n), S = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set();
|
|
770
|
+
if (u.length > 0 && c.length > 0) {
|
|
771
|
+
for (const l of u) {
|
|
772
|
+
const p = JSON.stringify(r[l]);
|
|
773
|
+
for (const b of c)
|
|
774
|
+
if (!S.has(b) && JSON.stringify(o[b]) === p) {
|
|
775
|
+
he(x.fields, l, b), S.add(b), f.add(l);
|
|
776
|
+
break;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
const A = u.filter(function(l) {
|
|
780
|
+
return !f.has(l);
|
|
781
|
+
}), d = c.filter(function(l) {
|
|
782
|
+
return !S.has(l);
|
|
783
|
+
});
|
|
784
|
+
A.length === 1 && d.length === 1 && (he(x.fields, A[0], d[0]), S.add(d[0]), f.add(A[0]));
|
|
785
|
+
}
|
|
786
|
+
const C = c.filter(function(A) {
|
|
787
|
+
return !S.has(A);
|
|
788
|
+
});
|
|
789
|
+
for (const A of C)
|
|
790
|
+
Re(x.fields, A) || kn(x, A, o[A]);
|
|
791
|
+
const v = u.filter(function(A) {
|
|
792
|
+
return !f.has(A);
|
|
793
|
+
});
|
|
794
|
+
for (const A of v)
|
|
795
|
+
Pe(x.fields, A);
|
|
796
|
+
return x;
|
|
797
|
+
}
|
|
798
|
+
function ve(e) {
|
|
799
|
+
const t = {};
|
|
800
|
+
for (const n of e || []) {
|
|
801
|
+
if (n.fieldType === "section" && Array.isArray(n.fields)) {
|
|
802
|
+
if (ee(n)) continue;
|
|
803
|
+
Object.assign(t, ve(n.fields));
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
n.id && (t[n.id] = n.text || "");
|
|
807
|
+
}
|
|
808
|
+
return t;
|
|
809
|
+
}
|
|
810
|
+
function qn(e, t, n) {
|
|
811
|
+
const r = ve(e == null ? void 0 : e.fields), o = ve(t == null ? void 0 : t.fields), a = new Set(Object.keys(r)), s = new Set(Object.keys(o)), u = [...a].filter(function(d) {
|
|
812
|
+
return !s.has(d);
|
|
813
|
+
}), c = [...s].filter(function(d) {
|
|
814
|
+
return !a.has(d);
|
|
815
|
+
});
|
|
816
|
+
if (u.length === 0 && c.length === 0)
|
|
817
|
+
return { config: n, renames: [] };
|
|
818
|
+
let x = n;
|
|
819
|
+
const S = [], f = /* @__PURE__ */ new Set(), C = /* @__PURE__ */ new Set();
|
|
820
|
+
if (u.length > 0 && c.length > 0) {
|
|
821
|
+
for (const p of u) {
|
|
822
|
+
const b = r[p];
|
|
823
|
+
if (b) {
|
|
824
|
+
for (const h of c)
|
|
825
|
+
if (!f.has(h) && o[h] === b) {
|
|
826
|
+
x = Te(x, p, h), S.push({ oldId: p, newId: h }), f.add(h), C.add(p);
|
|
827
|
+
break;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
const d = u.filter(function(p) {
|
|
832
|
+
return !C.has(p);
|
|
833
|
+
}), l = c.filter(function(p) {
|
|
834
|
+
return !f.has(p);
|
|
835
|
+
});
|
|
836
|
+
d.length === 1 && l.length === 1 && (x = Te(x, d[0], l[0]), S.push({ oldId: d[0], newId: l[0] }), f.add(l[0]), C.add(d[0]));
|
|
837
|
+
}
|
|
838
|
+
const v = c.filter(function(d) {
|
|
839
|
+
return !f.has(d);
|
|
840
|
+
});
|
|
841
|
+
if (v.length > 0) {
|
|
842
|
+
x === n && (x = structuredClone(n));
|
|
843
|
+
for (const d of v)
|
|
844
|
+
X(x, d) === void 0 && K(x, d, "");
|
|
845
|
+
}
|
|
846
|
+
const A = u.filter(function(d) {
|
|
847
|
+
return !C.has(d);
|
|
848
|
+
});
|
|
849
|
+
if (A.length > 0) {
|
|
850
|
+
x === n && (x = structuredClone(n));
|
|
851
|
+
for (const d of A)
|
|
852
|
+
Ee(x, d);
|
|
853
|
+
}
|
|
854
|
+
return { config: x, renames: S };
|
|
855
|
+
}
|
|
856
|
+
function ye(e) {
|
|
857
|
+
const t = [];
|
|
858
|
+
for (const n of e || [])
|
|
859
|
+
ee(n) || (n.fieldType === "section" && Array.isArray(n.fields) ? t.push(...ye(n.fields)) : t.push(n));
|
|
860
|
+
return t;
|
|
861
|
+
}
|
|
862
|
+
function ce(e) {
|
|
863
|
+
const t = e.answer;
|
|
864
|
+
if (t == null) return "";
|
|
865
|
+
if (e.fieldType === "dropdown" && e.options) {
|
|
866
|
+
const n = e.options.find((r) => r.id === t || r.value === t);
|
|
867
|
+
if (n) return n.value;
|
|
868
|
+
}
|
|
869
|
+
return t;
|
|
870
|
+
}
|
|
871
|
+
function xe(e) {
|
|
872
|
+
const t = e.answer;
|
|
873
|
+
return Array.isArray(t) ? e.options ? t.map((n) => {
|
|
874
|
+
const r = e.options.find((o) => o.id === n || o.value === n);
|
|
875
|
+
return r ? r.value : n;
|
|
876
|
+
}) : t : [];
|
|
877
|
+
}
|
|
878
|
+
function je(e) {
|
|
879
|
+
return e.options ? e.options.map((t) => t.value) : [];
|
|
880
|
+
}
|
|
881
|
+
function ee(e) {
|
|
882
|
+
return e.fieldType === "section" && /^sec-tool-\d+$/.test(e.id);
|
|
883
|
+
}
|
|
884
|
+
function Oe(e) {
|
|
885
|
+
return (e || []).filter((t) => ee(t));
|
|
886
|
+
}
|
|
887
|
+
function ne(e, t) {
|
|
888
|
+
const n = (e.fields || []).find((r) => r.id.endsWith("-" + t));
|
|
889
|
+
return n ? ce(n) : "";
|
|
890
|
+
}
|
|
891
|
+
function In(e, t) {
|
|
892
|
+
const n = Oe(e.fields || []), r = [];
|
|
893
|
+
for (const o of n) {
|
|
894
|
+
const a = ne(o, "name"), s = ne(o, "description"), u = ne(o, "endpoint"), c = ne(o, "method"), x = ne(o, "params");
|
|
895
|
+
let S;
|
|
896
|
+
try {
|
|
897
|
+
S = x ? JSON.parse(x) : { type: "object", properties: {}, required: [] };
|
|
898
|
+
} catch {
|
|
899
|
+
S = { type: "object", properties: {}, required: [] };
|
|
900
|
+
}
|
|
901
|
+
const f = { name: a, description: s, inputSchema: S };
|
|
902
|
+
u && (f.endpoint = u), c && c !== "GET" && (f.method = c), r.push(f);
|
|
903
|
+
}
|
|
904
|
+
t.tools = r;
|
|
905
|
+
}
|
|
906
|
+
function En(e, t) {
|
|
907
|
+
const n = structuredClone(t), r = ye(e.fields || []);
|
|
908
|
+
Oe(e.fields || []).length > 0 && In(e, n);
|
|
909
|
+
for (const a of r) {
|
|
910
|
+
const s = a.configTransform;
|
|
911
|
+
if (s === "genericToolsInvert") {
|
|
912
|
+
const x = xe(a), S = je(a), f = B(a);
|
|
913
|
+
K(n, f, S.filter((C) => !x.includes(C)));
|
|
914
|
+
continue;
|
|
915
|
+
}
|
|
916
|
+
if (s === "elevenLabsDictIds") {
|
|
917
|
+
const x = (ce(a) || "").split(",").map((v) => v.trim()).filter(Boolean), S = r.find((v) => v.configTransform === "elevenLabsDictVersions"), f = S ? (ce(S) || "").split(",").map((v) => v.trim()).filter(Boolean) : [], C = B(a);
|
|
918
|
+
K(n, C, x.map((v, A) => ({
|
|
919
|
+
pronunciation_dictionary_id: v,
|
|
920
|
+
version_id: f[A] || ""
|
|
921
|
+
})));
|
|
922
|
+
continue;
|
|
923
|
+
}
|
|
924
|
+
if (s === "elevenLabsDictVersions")
|
|
925
|
+
continue;
|
|
926
|
+
const u = B(a), c = a.configType || "string";
|
|
927
|
+
a.fieldType === "check" ? K(n, u, xe(a)) : K(n, u, Ie(ce(a), c));
|
|
928
|
+
}
|
|
929
|
+
return n;
|
|
930
|
+
}
|
|
931
|
+
function te(e, t) {
|
|
932
|
+
const n = structuredClone(t);
|
|
933
|
+
return ze(n.fields, e), n;
|
|
934
|
+
}
|
|
935
|
+
function ze(e, t) {
|
|
936
|
+
for (const n of e || []) {
|
|
937
|
+
if (ee(n))
|
|
938
|
+
continue;
|
|
939
|
+
if (n.fieldType === "section" && Array.isArray(n.fields)) {
|
|
940
|
+
ze(n.fields, t);
|
|
941
|
+
continue;
|
|
942
|
+
}
|
|
943
|
+
const r = n.configTransform;
|
|
944
|
+
if (r === "genericToolsInvert") {
|
|
945
|
+
const s = B(n), u = X(t, s) || [], S = je(n).filter((f) => !u.includes(f)).map(function(f) {
|
|
946
|
+
const C = (n.options || []).find(function(v) {
|
|
947
|
+
return v.value === f;
|
|
948
|
+
});
|
|
949
|
+
return C ? C.id : f;
|
|
950
|
+
});
|
|
951
|
+
n.selected = S, n.answer = S;
|
|
952
|
+
continue;
|
|
953
|
+
}
|
|
954
|
+
if (r === "elevenLabsDictIds") {
|
|
955
|
+
const s = B(n), u = X(t, s) || [];
|
|
956
|
+
n.answer = u.map((c) => c.pronunciation_dictionary_id).join(", ");
|
|
957
|
+
continue;
|
|
958
|
+
}
|
|
959
|
+
if (r === "elevenLabsDictVersions") {
|
|
960
|
+
const s = B(n).replace(/__versions$/, ""), u = X(t, s) || [];
|
|
961
|
+
n.answer = u.map((c) => c.version_id).join(", ");
|
|
962
|
+
continue;
|
|
963
|
+
}
|
|
964
|
+
const o = B(n), a = X(t, o);
|
|
965
|
+
if (n.fieldType === "check") {
|
|
966
|
+
const s = Array.isArray(a) ? a : [], u = n.options ? s.map(function(c) {
|
|
967
|
+
const x = n.options.find(function(S) {
|
|
968
|
+
return S.value === c || S.id === c;
|
|
969
|
+
});
|
|
970
|
+
return x ? x.id : c;
|
|
971
|
+
}) : s;
|
|
972
|
+
n.selected = u, n.answer = u;
|
|
973
|
+
continue;
|
|
974
|
+
}
|
|
975
|
+
if (n.fieldType === "dropdown" && n.options) {
|
|
976
|
+
const s = n.options.find((u) => u.value === String(a ?? ""));
|
|
977
|
+
n.selected = s ? s.id : null, n.answer = s ? s.value : String(a ?? "");
|
|
978
|
+
continue;
|
|
979
|
+
}
|
|
980
|
+
n.answer = a != null ? String(a) : "";
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
function Pn(e) {
|
|
984
|
+
const t = {
|
|
985
|
+
_id: Sn(),
|
|
986
|
+
tools: []
|
|
987
|
+
}, n = ye((e == null ? void 0 : e.fields) || []);
|
|
988
|
+
for (const r of n) {
|
|
989
|
+
if (r.id === "_id") continue;
|
|
990
|
+
const o = r.configTransform;
|
|
991
|
+
if (o === "genericToolsInvert") {
|
|
992
|
+
K(t, B(r), []);
|
|
993
|
+
continue;
|
|
994
|
+
}
|
|
995
|
+
if (o === "elevenLabsDictIds") {
|
|
996
|
+
K(t, B(r), []);
|
|
997
|
+
continue;
|
|
998
|
+
}
|
|
999
|
+
if (o === "elevenLabsDictVersions")
|
|
1000
|
+
continue;
|
|
1001
|
+
const a = B(r), s = r.configType || "string";
|
|
1002
|
+
r.fieldType === "check" ? K(t, a, Array.isArray(r.answer) ? r.answer : []) : K(t, a, Ie(r.answer ?? "", s));
|
|
1003
|
+
}
|
|
1004
|
+
return t;
|
|
1005
|
+
}
|
|
1006
|
+
function Rn(e) {
|
|
1007
|
+
if (!Array.isArray(e)) return e;
|
|
1008
|
+
if (e.length > 0 && e[0] && typeof e[0] == "object" && "value" in e[0]) {
|
|
1009
|
+
var t = e.map(function(n) {
|
|
1010
|
+
return n.value;
|
|
1011
|
+
});
|
|
1012
|
+
return t.length === 1 ? t[0] : t;
|
|
1013
|
+
}
|
|
1014
|
+
return e;
|
|
1015
|
+
}
|
|
1016
|
+
function Le(e, t) {
|
|
1017
|
+
t || (t = {});
|
|
1018
|
+
for (var n = 0; n < (e || []).length; n++) {
|
|
1019
|
+
var r = e[n];
|
|
1020
|
+
r.id && r.answer !== void 0 && (t[r.id] = Rn(r.answer)), r.fields && Le(r.fields, t);
|
|
1021
|
+
}
|
|
1022
|
+
return t;
|
|
1023
|
+
}
|
|
1024
|
+
function Fe(e, t) {
|
|
1025
|
+
for (var n = 0; n < (e || []).length; n++) {
|
|
1026
|
+
var r = e[n];
|
|
1027
|
+
r.id && t[r.id] !== void 0 && (r.answer = t[r.id]), r.fields && Fe(r.fields, t);
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
function jn({ config: e, schema: t, onConfigChange: n }) {
|
|
1031
|
+
const r = t || re, o = H(null), a = H(null), s = H(e), u = H(r), c = H(n);
|
|
1032
|
+
s.current = e, u.current = r, c.current = n;
|
|
1033
|
+
const x = Qe(
|
|
1034
|
+
() => te(e, r),
|
|
1035
|
+
[e, r]
|
|
1036
|
+
), S = G(function() {
|
|
1037
|
+
if (o.current)
|
|
1038
|
+
try {
|
|
1039
|
+
var f = o.current.getResponse();
|
|
1040
|
+
if (!f) return;
|
|
1041
|
+
var C = f.fields || f;
|
|
1042
|
+
if (!Array.isArray(C) && typeof C == "object" && !C.length && (C = f.fields), !C) return;
|
|
1043
|
+
var v = Le(Array.isArray(C) ? C : [C]);
|
|
1044
|
+
if (Object.keys(v).length === 0) return;
|
|
1045
|
+
var A = structuredClone(u.current);
|
|
1046
|
+
Fe(A.fields, v);
|
|
1047
|
+
var d = En(A, s.current);
|
|
1048
|
+
c.current(d);
|
|
1049
|
+
} catch (l) {
|
|
1050
|
+
console.error("[FormBuilder] syncConfig error:", l);
|
|
1051
|
+
}
|
|
1052
|
+
}, []);
|
|
1053
|
+
return Z(function() {
|
|
1054
|
+
var f = a.current;
|
|
1055
|
+
if (!f) return;
|
|
1056
|
+
var C = null;
|
|
1057
|
+
function v() {
|
|
1058
|
+
clearTimeout(C), C = setTimeout(S, 50);
|
|
1059
|
+
}
|
|
1060
|
+
return f.addEventListener("input", v), f.addEventListener("change", v), f.addEventListener("click", v), function() {
|
|
1061
|
+
clearTimeout(C), f.removeEventListener("input", v), f.removeEventListener("change", v), f.removeEventListener("click", v);
|
|
1062
|
+
};
|
|
1063
|
+
}, [S]), /* @__PURE__ */ w("div", { ref: a, className: "max-w-6xl mx-auto p-6 rounded-lg shadow", style: { background: "var(--mieweb-card)", borderRadius: "var(--mieweb-radius-lg, 0.75rem)" }, children: [
|
|
1064
|
+
/* @__PURE__ */ i("h2", { className: "text-2xl font-bold mb-6", style: { color: "var(--mieweb-foreground)" }, children: "General Configuration" }),
|
|
1065
|
+
/* @__PURE__ */ i(
|
|
1066
|
+
fn,
|
|
1067
|
+
{
|
|
1068
|
+
ref: o,
|
|
1069
|
+
formData: x,
|
|
1070
|
+
hideUnsupportedFields: !0
|
|
1071
|
+
}
|
|
1072
|
+
)
|
|
1073
|
+
] });
|
|
1074
|
+
}
|
|
1075
|
+
function On({
|
|
1076
|
+
yamlOutput: e,
|
|
1077
|
+
jsonOutput: t,
|
|
1078
|
+
editorMode: n,
|
|
1079
|
+
onEditorModeChange: r,
|
|
1080
|
+
onEditorChange: o,
|
|
1081
|
+
onDownload: a
|
|
1082
|
+
}) {
|
|
1083
|
+
return /* @__PURE__ */ w(
|
|
1084
|
+
ge,
|
|
1085
|
+
{
|
|
1086
|
+
padding: "none",
|
|
1087
|
+
className: "h-[calc(100vh-10rem)] max-w-full overflow-hidden flex flex-col",
|
|
1088
|
+
children: [
|
|
1089
|
+
/* @__PURE__ */ w("div", { className: "p-2 border-b flex justify-between items-center flex-shrink-0", style: { background: "var(--mieweb-muted)" }, children: [
|
|
1090
|
+
/* @__PURE__ */ w("div", { className: "flex items-center gap-2", children: [
|
|
1091
|
+
/* @__PURE__ */ i("div", { className: "flex rounded gap-1", children: ["yaml", "json"].map(function(s) {
|
|
1092
|
+
var u = n === s;
|
|
1093
|
+
return /* @__PURE__ */ i(
|
|
1094
|
+
"button",
|
|
1095
|
+
{
|
|
1096
|
+
onClick: function() {
|
|
1097
|
+
r(s);
|
|
1098
|
+
},
|
|
1099
|
+
className: "px-3 h-7 text-sm rounded transition-all " + (u ? "" : "ivr-hover"),
|
|
1100
|
+
style: u ? { background: "var(--mieweb-primary-700, #1786b3)", color: "var(--mieweb-primary-foreground, #fff)", fontWeight: 600 } : { background: "transparent", color: "var(--mieweb-neutral-600, #525252)" },
|
|
1101
|
+
children: s.toUpperCase()
|
|
1102
|
+
},
|
|
1103
|
+
s
|
|
1104
|
+
);
|
|
1105
|
+
}) }),
|
|
1106
|
+
/* @__PURE__ */ w("span", { className: "hidden sm:block text-sm font-medium", style: { color: "var(--mieweb-muted-foreground)" }, children: [
|
|
1107
|
+
"config.",
|
|
1108
|
+
n
|
|
1109
|
+
] })
|
|
1110
|
+
] }),
|
|
1111
|
+
/* @__PURE__ */ w("div", { className: "flex items-center gap-1", children: [
|
|
1112
|
+
a && /* @__PURE__ */ i(
|
|
1113
|
+
F,
|
|
1114
|
+
{
|
|
1115
|
+
variant: "primary",
|
|
1116
|
+
size: "sm",
|
|
1117
|
+
onClick: function() {
|
|
1118
|
+
a(n);
|
|
1119
|
+
},
|
|
1120
|
+
leftIcon: /* @__PURE__ */ i(_e, { className: "h-4 w-4" }),
|
|
1121
|
+
"aria-label": `Download config.${n}`,
|
|
1122
|
+
children: /* @__PURE__ */ w("span", { className: "hidden sm:inline", children: [
|
|
1123
|
+
"Download .",
|
|
1124
|
+
n
|
|
1125
|
+
] })
|
|
1126
|
+
}
|
|
1127
|
+
),
|
|
1128
|
+
/* @__PURE__ */ i(
|
|
1129
|
+
F,
|
|
1130
|
+
{
|
|
1131
|
+
variant: "ghost",
|
|
1132
|
+
size: "icon",
|
|
1133
|
+
onClick: function() {
|
|
1134
|
+
wn(n === "yaml" ? e : t);
|
|
1135
|
+
},
|
|
1136
|
+
"aria-label": "Copy to clipboard",
|
|
1137
|
+
className: "ivr-hover h-8 w-8",
|
|
1138
|
+
style: { color: "var(--mieweb-muted-foreground)" },
|
|
1139
|
+
children: /* @__PURE__ */ i(Ge, { className: "h-4 w-4" })
|
|
1140
|
+
}
|
|
1141
|
+
)
|
|
1142
|
+
] })
|
|
1143
|
+
] }),
|
|
1144
|
+
/* @__PURE__ */ i(
|
|
1145
|
+
mn,
|
|
1146
|
+
{
|
|
1147
|
+
height: "100%",
|
|
1148
|
+
language: n,
|
|
1149
|
+
value: n === "yaml" ? e : t,
|
|
1150
|
+
onChange: function(s) {
|
|
1151
|
+
o(s, n);
|
|
1152
|
+
},
|
|
1153
|
+
options: { minimap: { enabled: !1 }, fontSize: 14 }
|
|
1154
|
+
},
|
|
1155
|
+
n
|
|
1156
|
+
)
|
|
1157
|
+
]
|
|
1158
|
+
}
|
|
1159
|
+
);
|
|
1160
|
+
}
|
|
1161
|
+
const zn = [
|
|
1162
|
+
{ value: "string", label: "String" },
|
|
1163
|
+
{ value: "number", label: "Number" },
|
|
1164
|
+
{ value: "boolean", label: "Boolean" },
|
|
1165
|
+
{ value: "object", label: "Object" },
|
|
1166
|
+
{ value: "array", label: "Array" }
|
|
1167
|
+
], Ln = [
|
|
1168
|
+
{ value: "string", label: "String" },
|
|
1169
|
+
{ value: "number", label: "Number" },
|
|
1170
|
+
{ value: "boolean", label: "Boolean" },
|
|
1171
|
+
{ value: "object", label: "Object" }
|
|
1172
|
+
], Ce = /* @__PURE__ */ new Set(["string", "number"]);
|
|
1173
|
+
function Ne({ value: e, onChange: t, size: n, ...r }) {
|
|
1174
|
+
const [o, a] = V(e);
|
|
1175
|
+
Z(function() {
|
|
1176
|
+
a(e);
|
|
1177
|
+
}, [e]);
|
|
1178
|
+
function s() {
|
|
1179
|
+
if (o !== e) {
|
|
1180
|
+
var c = t(o);
|
|
1181
|
+
c === !1 && a(e);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
function u(c) {
|
|
1185
|
+
c.key === "Enter" && c.target.blur();
|
|
1186
|
+
}
|
|
1187
|
+
return /* @__PURE__ */ i(
|
|
1188
|
+
W,
|
|
1189
|
+
{
|
|
1190
|
+
...r,
|
|
1191
|
+
size: n || "sm",
|
|
1192
|
+
value: o,
|
|
1193
|
+
onChange: function(c) {
|
|
1194
|
+
a(c.target.value);
|
|
1195
|
+
},
|
|
1196
|
+
onBlur: s,
|
|
1197
|
+
onKeyDown: u
|
|
1198
|
+
}
|
|
1199
|
+
);
|
|
1200
|
+
}
|
|
1201
|
+
function Se({ values: e, onChange: t }) {
|
|
1202
|
+
const [n, r] = V((e || []).join(", "));
|
|
1203
|
+
Z(function() {
|
|
1204
|
+
r((e || []).join(", "));
|
|
1205
|
+
}, [e]);
|
|
1206
|
+
function o(a) {
|
|
1207
|
+
var s = a.split(",").map(function(u) {
|
|
1208
|
+
return u.trim();
|
|
1209
|
+
}).filter(function(u) {
|
|
1210
|
+
return u !== "";
|
|
1211
|
+
});
|
|
1212
|
+
t(s);
|
|
1213
|
+
}
|
|
1214
|
+
return /* @__PURE__ */ i(
|
|
1215
|
+
W,
|
|
1216
|
+
{
|
|
1217
|
+
size: "sm",
|
|
1218
|
+
value: n,
|
|
1219
|
+
onChange: function(a) {
|
|
1220
|
+
r(a.target.value);
|
|
1221
|
+
},
|
|
1222
|
+
onBlur: function() {
|
|
1223
|
+
o(n);
|
|
1224
|
+
},
|
|
1225
|
+
onKeyDown: function(a) {
|
|
1226
|
+
a.key === "Enter" && a.target.blur();
|
|
1227
|
+
},
|
|
1228
|
+
placeholder: "e.g. dev, staging, prod"
|
|
1229
|
+
}
|
|
1230
|
+
);
|
|
1231
|
+
}
|
|
1232
|
+
function Fn({ config: e, onConfigChange: t }) {
|
|
1233
|
+
var A;
|
|
1234
|
+
function n(d) {
|
|
1235
|
+
var l = structuredClone(e);
|
|
1236
|
+
d(l), t(l);
|
|
1237
|
+
}
|
|
1238
|
+
function r() {
|
|
1239
|
+
n(function(d) {
|
|
1240
|
+
d.tools || (d.tools = []);
|
|
1241
|
+
for (var l = 1; d.tools.some(function(p) {
|
|
1242
|
+
return p.name === "tool_" + l;
|
|
1243
|
+
}); )
|
|
1244
|
+
l++;
|
|
1245
|
+
d.tools.push({
|
|
1246
|
+
name: "tool_" + l,
|
|
1247
|
+
description: "Description of the tool",
|
|
1248
|
+
inputSchema: { type: "object", properties: {}, required: [] }
|
|
1249
|
+
});
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
function o(d) {
|
|
1253
|
+
n(function(l) {
|
|
1254
|
+
l.tools.splice(d, 1);
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
function a(d, l, p) {
|
|
1258
|
+
if (l === "name") {
|
|
1259
|
+
var b = e.tools[d].name;
|
|
1260
|
+
if (p !== b) {
|
|
1261
|
+
var h = e.tools.some(function(T, O) {
|
|
1262
|
+
return O !== d && T.name === p;
|
|
1263
|
+
});
|
|
1264
|
+
if (h)
|
|
1265
|
+
return alert('Tool name "' + p + '" already exists.'), !1;
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
return n(function(T) {
|
|
1269
|
+
T.tools[d].name, T.tools[d][l] = p;
|
|
1270
|
+
}), !0;
|
|
1271
|
+
}
|
|
1272
|
+
function s(d) {
|
|
1273
|
+
n(function(l) {
|
|
1274
|
+
var p = l.tools[d];
|
|
1275
|
+
p.inputSchema || (p.inputSchema = { type: "object", properties: {}, required: [] }), p.inputSchema.properties || (p.inputSchema.properties = {});
|
|
1276
|
+
for (var b = 1; p.inputSchema.properties["param_" + b]; )
|
|
1277
|
+
b++;
|
|
1278
|
+
p.inputSchema.properties["param_" + b] = {
|
|
1279
|
+
type: "string",
|
|
1280
|
+
description: "Parameter description"
|
|
1281
|
+
};
|
|
1282
|
+
});
|
|
1283
|
+
}
|
|
1284
|
+
function u(d, l, p, b) {
|
|
1285
|
+
if (l !== p) {
|
|
1286
|
+
var h = e.tools[d];
|
|
1287
|
+
if (h.inputSchema.properties[p])
|
|
1288
|
+
return alert('Parameter "' + p + '" already exists.'), !1;
|
|
1289
|
+
}
|
|
1290
|
+
return n(function(T) {
|
|
1291
|
+
var O = T.tools[d], z = O.inputSchema.properties;
|
|
1292
|
+
if (l !== p) {
|
|
1293
|
+
var D = {};
|
|
1294
|
+
Object.keys(z).forEach(function(g) {
|
|
1295
|
+
D[g === l ? p : g] = g === l ? b : z[g];
|
|
1296
|
+
}), O.inputSchema.properties = D, O.inputSchema.required && O.inputSchema.required.includes(l) && (O.inputSchema.required = O.inputSchema.required.map(function(g) {
|
|
1297
|
+
return g === l ? p : g;
|
|
1298
|
+
}));
|
|
1299
|
+
} else
|
|
1300
|
+
z[l] = b;
|
|
1301
|
+
}), !0;
|
|
1302
|
+
}
|
|
1303
|
+
function c(d, l) {
|
|
1304
|
+
n(function(p) {
|
|
1305
|
+
var b = p.tools[d];
|
|
1306
|
+
delete b.inputSchema.properties[l], b.inputSchema.required && (b.inputSchema.required = b.inputSchema.required.filter(function(h) {
|
|
1307
|
+
return h !== l;
|
|
1308
|
+
}));
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
function x(d, l) {
|
|
1312
|
+
n(function(p) {
|
|
1313
|
+
var b = p.tools[d];
|
|
1314
|
+
b.inputSchema.required || (b.inputSchema.required = []), b.inputSchema.required.includes(l) ? b.inputSchema.required = b.inputSchema.required.filter(function(h) {
|
|
1315
|
+
return h !== l;
|
|
1316
|
+
}) : b.inputSchema.required.push(l);
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
function S(d, l, p, b) {
|
|
1320
|
+
var h = { type: b, description: p.description || "" };
|
|
1321
|
+
p.default !== void 0 && (h.default = p.default), b === "array" && (h.items = p.items || { type: "string" }), Ce.has(b) && p.enum && (h.enum = p.enum), u(d, l, l, h);
|
|
1322
|
+
}
|
|
1323
|
+
function f(d, l, p, b) {
|
|
1324
|
+
u(d, l, l, {
|
|
1325
|
+
...p,
|
|
1326
|
+
items: { type: b }
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
function C(d, l, p, b) {
|
|
1330
|
+
var h = { ...p };
|
|
1331
|
+
b ? h.enum = [] : delete h.enum, u(d, l, l, h);
|
|
1332
|
+
}
|
|
1333
|
+
function v(d, l, p, b) {
|
|
1334
|
+
var h = { ...p, enum: b };
|
|
1335
|
+
if (h.default !== void 0) {
|
|
1336
|
+
var T = b.map(String);
|
|
1337
|
+
T.includes(String(h.default)) || (h.default = b.length > 0 ? b[0] : void 0, h.default === void 0 && delete h.default);
|
|
1338
|
+
}
|
|
1339
|
+
u(d, l, l, h);
|
|
1340
|
+
}
|
|
1341
|
+
return /* @__PURE__ */ w("div", { className: "max-w-4xl mx-auto", children: [
|
|
1342
|
+
/* @__PURE__ */ w("div", { className: "flex justify-between items-center mb-6", children: [
|
|
1343
|
+
/* @__PURE__ */ i("h2", { className: "text-2xl font-bold", style: { color: "var(--mieweb-foreground)" }, children: "Tool Builder" }),
|
|
1344
|
+
/* @__PURE__ */ i(
|
|
1345
|
+
F,
|
|
1346
|
+
{
|
|
1347
|
+
variant: "primary",
|
|
1348
|
+
size: "sm",
|
|
1349
|
+
onClick: r,
|
|
1350
|
+
leftIcon: /* @__PURE__ */ i(de, { className: "h-4 w-4" }),
|
|
1351
|
+
children: "Add Tool"
|
|
1352
|
+
}
|
|
1353
|
+
)
|
|
1354
|
+
] }),
|
|
1355
|
+
/* @__PURE__ */ w("div", { className: "space-y-4", children: [
|
|
1356
|
+
(A = e.tools) == null ? void 0 : A.map(function(d, l) {
|
|
1357
|
+
var p, b;
|
|
1358
|
+
return /* @__PURE__ */ w(ge, { padding: "md", className: "relative", children: [
|
|
1359
|
+
/* @__PURE__ */ i(
|
|
1360
|
+
F,
|
|
1361
|
+
{
|
|
1362
|
+
variant: "ghost",
|
|
1363
|
+
size: "icon",
|
|
1364
|
+
onClick: function() {
|
|
1365
|
+
o(l);
|
|
1366
|
+
},
|
|
1367
|
+
className: "absolute top-3 right-3 ivr-hover-destructive",
|
|
1368
|
+
style: { color: "var(--mieweb-destructive)" },
|
|
1369
|
+
"aria-label": "Remove tool",
|
|
1370
|
+
children: /* @__PURE__ */ i(fe, { className: "h-5 w-5" })
|
|
1371
|
+
}
|
|
1372
|
+
),
|
|
1373
|
+
/* @__PURE__ */ w("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4 mb-4", children: [
|
|
1374
|
+
/* @__PURE__ */ i(
|
|
1375
|
+
Ne,
|
|
1376
|
+
{
|
|
1377
|
+
label: "Tool Name",
|
|
1378
|
+
value: d.name,
|
|
1379
|
+
onChange: function(h) {
|
|
1380
|
+
return a(l, "name", h);
|
|
1381
|
+
},
|
|
1382
|
+
size: "md"
|
|
1383
|
+
}
|
|
1384
|
+
),
|
|
1385
|
+
/* @__PURE__ */ i(
|
|
1386
|
+
W,
|
|
1387
|
+
{
|
|
1388
|
+
label: "Description",
|
|
1389
|
+
size: "md",
|
|
1390
|
+
value: d.description,
|
|
1391
|
+
onChange: function(h) {
|
|
1392
|
+
a(l, "description", h.target.value);
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
)
|
|
1396
|
+
] }),
|
|
1397
|
+
/* @__PURE__ */ w("div", { className: "p-4 rounded-lg border", style: { background: "var(--mieweb-muted)", borderColor: "var(--mieweb-border)", borderRadius: "var(--mieweb-radius-lg, 0.75rem)" }, children: [
|
|
1398
|
+
/* @__PURE__ */ w("div", { className: "flex justify-between items-center mb-3", children: [
|
|
1399
|
+
/* @__PURE__ */ i("h4", { className: "font-medium text-sm", style: { color: "var(--mieweb-foreground)" }, children: "Input Schema Parameters" }),
|
|
1400
|
+
/* @__PURE__ */ i(
|
|
1401
|
+
F,
|
|
1402
|
+
{
|
|
1403
|
+
variant: "primary",
|
|
1404
|
+
size: "sm",
|
|
1405
|
+
onClick: function() {
|
|
1406
|
+
s(l);
|
|
1407
|
+
},
|
|
1408
|
+
leftIcon: /* @__PURE__ */ i(de, { className: "h-3 w-3" }),
|
|
1409
|
+
children: "Add Parameter"
|
|
1410
|
+
}
|
|
1411
|
+
)
|
|
1412
|
+
] }),
|
|
1413
|
+
/* @__PURE__ */ i("div", { className: "space-y-2", children: ((p = d.inputSchema) == null ? void 0 : p.properties) && Object.entries(d.inputSchema.properties).map(function([h, T], O) {
|
|
1414
|
+
var N, k, q;
|
|
1415
|
+
var z = T.type === "array", D = Ce.has(T.type), g = Array.isArray(T.enum);
|
|
1416
|
+
return /* @__PURE__ */ w("div", { className: "rounded border p-2 space-y-2", style: { background: "var(--mieweb-card)", borderColor: "var(--mieweb-border)" }, children: [
|
|
1417
|
+
/* @__PURE__ */ w("div", { className: "flex flex-col md:flex-row gap-2 items-start", children: [
|
|
1418
|
+
/* @__PURE__ */ i("div", { className: "w-full md:w-36 flex-shrink-0", children: /* @__PURE__ */ i(
|
|
1419
|
+
Ne,
|
|
1420
|
+
{
|
|
1421
|
+
value: h,
|
|
1422
|
+
onChange: function(m) {
|
|
1423
|
+
return u(l, h, m, T);
|
|
1424
|
+
},
|
|
1425
|
+
placeholder: "Name",
|
|
1426
|
+
size: "sm"
|
|
1427
|
+
}
|
|
1428
|
+
) }),
|
|
1429
|
+
/* @__PURE__ */ i("div", { className: "w-full md:w-28 flex-shrink-0", children: /* @__PURE__ */ i(
|
|
1430
|
+
le,
|
|
1431
|
+
{
|
|
1432
|
+
options: zn,
|
|
1433
|
+
value: T.type,
|
|
1434
|
+
onValueChange: function(m) {
|
|
1435
|
+
S(l, h, T, m);
|
|
1436
|
+
},
|
|
1437
|
+
size: "sm"
|
|
1438
|
+
}
|
|
1439
|
+
) }),
|
|
1440
|
+
z && /* @__PURE__ */ i("div", { className: "w-full md:w-32 flex-shrink-0", children: /* @__PURE__ */ i(
|
|
1441
|
+
le,
|
|
1442
|
+
{
|
|
1443
|
+
options: Ln,
|
|
1444
|
+
value: ((N = T.items) == null ? void 0 : N.type) || "string",
|
|
1445
|
+
onValueChange: function(m) {
|
|
1446
|
+
f(l, h, T, m);
|
|
1447
|
+
},
|
|
1448
|
+
size: "sm"
|
|
1449
|
+
}
|
|
1450
|
+
) }),
|
|
1451
|
+
/* @__PURE__ */ i("div", { className: "w-full flex-1", children: /* @__PURE__ */ i(
|
|
1452
|
+
W,
|
|
1453
|
+
{
|
|
1454
|
+
size: "sm",
|
|
1455
|
+
value: T.description || "",
|
|
1456
|
+
onChange: function(m) {
|
|
1457
|
+
u(l, h, h, { ...T, description: m.target.value });
|
|
1458
|
+
},
|
|
1459
|
+
placeholder: "Description"
|
|
1460
|
+
}
|
|
1461
|
+
) }),
|
|
1462
|
+
/* @__PURE__ */ w("div", { className: "flex items-center gap-3 flex-shrink-0 mt-1 md:mt-0", children: [
|
|
1463
|
+
/* @__PURE__ */ i(
|
|
1464
|
+
se,
|
|
1465
|
+
{
|
|
1466
|
+
label: "Req",
|
|
1467
|
+
size: "sm",
|
|
1468
|
+
checked: (k = d.inputSchema.required) == null ? void 0 : k.includes(h),
|
|
1469
|
+
onChange: function() {
|
|
1470
|
+
x(l, h);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
),
|
|
1474
|
+
/* @__PURE__ */ i(
|
|
1475
|
+
se,
|
|
1476
|
+
{
|
|
1477
|
+
label: "Default",
|
|
1478
|
+
size: "sm",
|
|
1479
|
+
checked: T.default !== void 0,
|
|
1480
|
+
onChange: function(m) {
|
|
1481
|
+
var I = { ...T };
|
|
1482
|
+
m.target.checked ? z ? I.default = [] : g && T.enum && T.enum.length > 0 ? I.default = T.enum[0] : I.default = "" : delete I.default, u(l, h, h, I);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
),
|
|
1486
|
+
/* @__PURE__ */ i(
|
|
1487
|
+
F,
|
|
1488
|
+
{
|
|
1489
|
+
variant: "ghost",
|
|
1490
|
+
size: "icon",
|
|
1491
|
+
onClick: function() {
|
|
1492
|
+
c(l, h);
|
|
1493
|
+
},
|
|
1494
|
+
className: "ivr-hover-destructive h-8 w-8",
|
|
1495
|
+
style: { color: "var(--mieweb-destructive)" },
|
|
1496
|
+
"aria-label": "Remove parameter",
|
|
1497
|
+
children: /* @__PURE__ */ i(fe, { className: "h-4 w-4" })
|
|
1498
|
+
}
|
|
1499
|
+
)
|
|
1500
|
+
] })
|
|
1501
|
+
] }),
|
|
1502
|
+
T.default !== void 0 && /* @__PURE__ */ w("div", { className: "flex gap-2 items-center pl-1", children: [
|
|
1503
|
+
/* @__PURE__ */ i("span", { className: "text-xs w-16 flex-shrink-0", style: { color: "var(--mieweb-muted-foreground)" }, children: "Default:" }),
|
|
1504
|
+
/* @__PURE__ */ i("div", { className: "flex-1", children: z ? /* @__PURE__ */ w("div", { className: "flex gap-2 items-center", children: [
|
|
1505
|
+
/* @__PURE__ */ i("div", { className: "flex-1", children: /* @__PURE__ */ i(
|
|
1506
|
+
Se,
|
|
1507
|
+
{
|
|
1508
|
+
values: Array.isArray(T.default) ? T.default : [],
|
|
1509
|
+
onChange: function(m) {
|
|
1510
|
+
u(l, h, h, { ...T, default: m });
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
) }),
|
|
1514
|
+
/* @__PURE__ */ i("span", { className: "text-xs whitespace-nowrap", style: { color: "var(--mieweb-muted-foreground)" }, children: "comma-separated" })
|
|
1515
|
+
] }) : g && T.enum && T.enum.length > 0 ? (
|
|
1516
|
+
/* Enum active with values → dropdown constrained to enum */
|
|
1517
|
+
/* @__PURE__ */ i(
|
|
1518
|
+
le,
|
|
1519
|
+
{
|
|
1520
|
+
size: "sm",
|
|
1521
|
+
options: T.enum.map(function(m) {
|
|
1522
|
+
return { value: String(m), label: String(m) };
|
|
1523
|
+
}),
|
|
1524
|
+
value: String(T.default),
|
|
1525
|
+
onValueChange: function(m) {
|
|
1526
|
+
u(l, h, h, { ...T, default: m });
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
)
|
|
1530
|
+
) : g ? /* @__PURE__ */ i("span", { className: "text-xs italic", style: { color: "var(--mieweb-warning)" }, children: "Add enum values first to pick a default" }) : /* @__PURE__ */ i(
|
|
1531
|
+
W,
|
|
1532
|
+
{
|
|
1533
|
+
size: "sm",
|
|
1534
|
+
value: T.default,
|
|
1535
|
+
onChange: function(m) {
|
|
1536
|
+
u(l, h, h, { ...T, default: m.target.value });
|
|
1537
|
+
},
|
|
1538
|
+
placeholder: "Default value"
|
|
1539
|
+
}
|
|
1540
|
+
) })
|
|
1541
|
+
] }),
|
|
1542
|
+
D && /* @__PURE__ */ w("div", { className: "flex flex-col gap-1 pl-1", children: [
|
|
1543
|
+
/* @__PURE__ */ i(
|
|
1544
|
+
se,
|
|
1545
|
+
{
|
|
1546
|
+
label: "Enum — restrict to allowed values",
|
|
1547
|
+
size: "sm",
|
|
1548
|
+
checked: g,
|
|
1549
|
+
onChange: function(m) {
|
|
1550
|
+
C(l, h, T, m.target.checked);
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
),
|
|
1554
|
+
g && /* @__PURE__ */ w("div", { className: "flex gap-2 items-start pl-5", children: [
|
|
1555
|
+
/* @__PURE__ */ i("div", { className: "flex-1", children: /* @__PURE__ */ i(
|
|
1556
|
+
Se,
|
|
1557
|
+
{
|
|
1558
|
+
values: T.enum,
|
|
1559
|
+
onChange: function(m) {
|
|
1560
|
+
v(l, h, T, m);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
) }),
|
|
1564
|
+
/* @__PURE__ */ i("span", { className: "text-xs mt-2 whitespace-nowrap", style: { color: "var(--mieweb-muted-foreground)" }, children: "comma-separated" })
|
|
1565
|
+
] }),
|
|
1566
|
+
g && T.enum && T.enum.length > 0 && /* @__PURE__ */ i("div", { className: "pl-5 flex flex-wrap gap-1", children: T.enum.map(function(m) {
|
|
1567
|
+
return /* @__PURE__ */ i("span", { className: "inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium", style: { background: "var(--mieweb-primary-100, #b3e6f6)", color: "var(--mieweb-primary-700, #1786b3)" }, children: m }, m);
|
|
1568
|
+
}) })
|
|
1569
|
+
] }),
|
|
1570
|
+
z && /* @__PURE__ */ w("div", { className: "pl-1 text-xs text-gray-500", children: [
|
|
1571
|
+
"Items type: ",
|
|
1572
|
+
/* @__PURE__ */ i("span", { className: "font-medium text-gray-700", children: ((q = T.items) == null ? void 0 : q.type) || "string" }),
|
|
1573
|
+
" ",
|
|
1574
|
+
"— the array selector above controls this"
|
|
1575
|
+
] })
|
|
1576
|
+
] }, O);
|
|
1577
|
+
}) }),
|
|
1578
|
+
(!((b = d.inputSchema) != null && b.properties) || Object.keys(d.inputSchema.properties).length === 0) && /* @__PURE__ */ i("p", { className: "text-sm text-gray-500 italic", children: "No parameters defined." })
|
|
1579
|
+
] })
|
|
1580
|
+
] }, l);
|
|
1581
|
+
}),
|
|
1582
|
+
(!e.tools || e.tools.length === 0) && /* @__PURE__ */ i("div", { className: "text-center py-12 text-gray-500", children: "No custom tools defined. Click “Add Tool” to create one." })
|
|
1583
|
+
] })
|
|
1584
|
+
] });
|
|
1585
|
+
}
|
|
1586
|
+
const Un = [
|
|
1587
|
+
{ value: "none", label: "None" },
|
|
1588
|
+
{ value: "bearer", label: "Bearer token" },
|
|
1589
|
+
{ value: "header", label: "Custom header" }
|
|
1590
|
+
], Vn = /^\$\{\{\s*secrets\.([A-Za-z_][A-Za-z0-9_]*)\s*\}\}$/;
|
|
1591
|
+
function Ae(e) {
|
|
1592
|
+
return "${{ secrets." + e + " }}";
|
|
1593
|
+
}
|
|
1594
|
+
function ke(e) {
|
|
1595
|
+
var t = typeof e == "string" ? e.match(Vn) : null;
|
|
1596
|
+
return t ? t[1] : null;
|
|
1597
|
+
}
|
|
1598
|
+
function Dn(e, t) {
|
|
1599
|
+
var n = String(e || "server_" + (t + 1)).toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
1600
|
+
return "MCP_" + (n || "SERVER") + "_TOKEN";
|
|
1601
|
+
}
|
|
1602
|
+
function M(e) {
|
|
1603
|
+
var t = e && e.auth;
|
|
1604
|
+
return t ? t.type === "bearer" ? ke(t.token) : t.type === "header" ? ke(t.value) : null : null;
|
|
1605
|
+
}
|
|
1606
|
+
function Hn({ secretName: e, isSet: t, onSecretChange: n }) {
|
|
1607
|
+
const [r, o] = V("");
|
|
1608
|
+
function a() {
|
|
1609
|
+
r && (n(e, r), o(""));
|
|
1610
|
+
}
|
|
1611
|
+
return /* @__PURE__ */ w("div", { className: "space-y-1", children: [
|
|
1612
|
+
/* @__PURE__ */ w("div", { className: "flex items-center gap-2 text-sm", style: { color: "var(--mieweb-foreground)" }, children: [
|
|
1613
|
+
/* @__PURE__ */ i(Me, { className: "h-4 w-4" }),
|
|
1614
|
+
/* @__PURE__ */ w("span", { children: [
|
|
1615
|
+
"Credential ",
|
|
1616
|
+
/* @__PURE__ */ i("code", { className: "text-xs", children: e }),
|
|
1617
|
+
":"
|
|
1618
|
+
] }),
|
|
1619
|
+
/* @__PURE__ */ i("span", { "data-testid": "credential-status", style: { color: t ? "var(--mieweb-success, green)" : "var(--mieweb-muted-foreground)" }, children: t ? "set" : "not set" })
|
|
1620
|
+
] }),
|
|
1621
|
+
/* @__PURE__ */ w("div", { className: "flex gap-2 items-end", children: [
|
|
1622
|
+
/* @__PURE__ */ i("div", { className: "flex-1", children: /* @__PURE__ */ i(
|
|
1623
|
+
W,
|
|
1624
|
+
{
|
|
1625
|
+
type: "password",
|
|
1626
|
+
size: "sm",
|
|
1627
|
+
autoComplete: "new-password",
|
|
1628
|
+
placeholder: t ? "Enter a new value to replace" : "Enter value",
|
|
1629
|
+
value: r,
|
|
1630
|
+
onChange: function(s) {
|
|
1631
|
+
o(s.target.value);
|
|
1632
|
+
},
|
|
1633
|
+
onKeyDown: function(s) {
|
|
1634
|
+
s.key === "Enter" && a();
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
) }),
|
|
1638
|
+
/* @__PURE__ */ i(F, { variant: "primary", size: "sm", onClick: a, disabled: !r, children: "Save" }),
|
|
1639
|
+
t && /* @__PURE__ */ i(F, { variant: "ghost", size: "sm", onClick: function() {
|
|
1640
|
+
n(e, null);
|
|
1641
|
+
}, children: "Clear" })
|
|
1642
|
+
] })
|
|
1643
|
+
] });
|
|
1644
|
+
}
|
|
1645
|
+
function Kn({
|
|
1646
|
+
config: e,
|
|
1647
|
+
onConfigChange: t,
|
|
1648
|
+
secretNames: n = [],
|
|
1649
|
+
pendingSecrets: r = {},
|
|
1650
|
+
onSecretChange: o,
|
|
1651
|
+
onDiscoverTools: a
|
|
1652
|
+
}) {
|
|
1653
|
+
const s = Array.isArray(e.mcp_servers) ? e.mcp_servers : [], [u, c] = V({}), x = H([]), S = H(0), f = H({});
|
|
1654
|
+
function C() {
|
|
1655
|
+
return "mcp-" + S.current++;
|
|
1656
|
+
}
|
|
1657
|
+
x.current.length !== s.length && (x.current = s.map(C), f.current = {});
|
|
1658
|
+
const v = x.current;
|
|
1659
|
+
function A(g) {
|
|
1660
|
+
t({ ...e, mcp_servers: g });
|
|
1661
|
+
}
|
|
1662
|
+
function d(g) {
|
|
1663
|
+
delete f.current[g], c(function(N) {
|
|
1664
|
+
if (!(g in N)) return N;
|
|
1665
|
+
var k = { ...N };
|
|
1666
|
+
return delete k[g], k;
|
|
1667
|
+
});
|
|
1668
|
+
}
|
|
1669
|
+
function l(g, N) {
|
|
1670
|
+
("url" in N || "auth" in N) && d(v[g]), A(s.map(function(k, q) {
|
|
1671
|
+
return q === g ? { ...k, ...N } : k;
|
|
1672
|
+
}));
|
|
1673
|
+
}
|
|
1674
|
+
function p() {
|
|
1675
|
+
x.current = v.concat([C()]), A(s.concat([{ name: "", url: "", auth: { type: "none" }, tools: [] }]));
|
|
1676
|
+
}
|
|
1677
|
+
function b(g) {
|
|
1678
|
+
var N = M(s[g]), k = s.filter(function(m, I) {
|
|
1679
|
+
return I !== g;
|
|
1680
|
+
}), q = k.some(function(m) {
|
|
1681
|
+
return M(m) === N;
|
|
1682
|
+
});
|
|
1683
|
+
N && !q && h(N) && o(N, null), d(v[g]), x.current = v.filter(function(m, I) {
|
|
1684
|
+
return I !== g;
|
|
1685
|
+
}), A(k);
|
|
1686
|
+
}
|
|
1687
|
+
function h(g) {
|
|
1688
|
+
return Object.prototype.hasOwnProperty.call(r, g) ? r[g] !== null : n.includes(g);
|
|
1689
|
+
}
|
|
1690
|
+
function T(g, N) {
|
|
1691
|
+
var k = new Set(n.concat(Object.keys(r)));
|
|
1692
|
+
s.forEach(function(R, U) {
|
|
1693
|
+
U !== N && k.add(M(R));
|
|
1694
|
+
});
|
|
1695
|
+
for (var q = Dn(g.name, N), m = q, I = 2; k.has(m); I++) m = q + "_" + I;
|
|
1696
|
+
return m;
|
|
1697
|
+
}
|
|
1698
|
+
function O(g, N) {
|
|
1699
|
+
var I;
|
|
1700
|
+
var k = s[g], q = M(k) || T(k, g), m;
|
|
1701
|
+
N === "bearer" ? m = { type: "bearer", token: Ae(q) } : N === "header" ? m = { type: "header", name: ((I = k.auth) == null ? void 0 : I.name) || "X-API-Key", value: Ae(q) } : m = { type: "none" }, l(g, { auth: m });
|
|
1702
|
+
}
|
|
1703
|
+
function z(g, N, k) {
|
|
1704
|
+
var q = s[g].tools || [], m = k ? q.concat(q.includes(N) ? [] : [N]) : q.filter(function(I) {
|
|
1705
|
+
return I !== N;
|
|
1706
|
+
});
|
|
1707
|
+
l(g, { tools: m });
|
|
1708
|
+
}
|
|
1709
|
+
async function D(g) {
|
|
1710
|
+
var N = s[g], k = v[g], q = M(N), m = {};
|
|
1711
|
+
q && Object.prototype.hasOwnProperty.call(r, q) && (m[q] = r[q]);
|
|
1712
|
+
var I = {};
|
|
1713
|
+
f.current[k] = I, c(function(j) {
|
|
1714
|
+
var ie;
|
|
1715
|
+
return { ...j, [k]: { status: "loading", tools: ((ie = j[k]) == null ? void 0 : ie.tools) || [] } };
|
|
1716
|
+
});
|
|
1717
|
+
var R;
|
|
1718
|
+
try {
|
|
1719
|
+
var U = await a(N, m), P = (Array.isArray(U) ? U : []).filter(function(j) {
|
|
1720
|
+
return j && j.name;
|
|
1721
|
+
});
|
|
1722
|
+
R = { status: "done", tools: P };
|
|
1723
|
+
} catch (j) {
|
|
1724
|
+
R = { status: "error", tools: [], error: (j == null ? void 0 : j.message) || String(j) };
|
|
1725
|
+
}
|
|
1726
|
+
f.current[k] === I && c(function(j) {
|
|
1727
|
+
return { ...j, [k]: R };
|
|
1728
|
+
});
|
|
1729
|
+
}
|
|
1730
|
+
return /* @__PURE__ */ w("div", { className: "max-w-6xl mx-auto mt-6 p-6 rounded-lg shadow", style: { background: "var(--mieweb-card)", borderRadius: "var(--mieweb-radius-lg, 0.75rem)" }, children: [
|
|
1731
|
+
/* @__PURE__ */ w("div", { className: "flex justify-between items-center mb-4", children: [
|
|
1732
|
+
/* @__PURE__ */ i("h2", { className: "text-2xl font-bold", style: { color: "var(--mieweb-foreground)" }, children: "MCP Servers" }),
|
|
1733
|
+
/* @__PURE__ */ i(F, { variant: "primary", size: "sm", onClick: p, leftIcon: /* @__PURE__ */ i(de, { className: "h-4 w-4" }), children: "Add Server" })
|
|
1734
|
+
] }),
|
|
1735
|
+
s.length === 0 && /* @__PURE__ */ i("p", { className: "text-sm", style: { color: "var(--mieweb-muted-foreground)" }, children: "No MCP servers configured." }),
|
|
1736
|
+
/* @__PURE__ */ i("div", { className: "space-y-4", children: s.map(function(g, N) {
|
|
1737
|
+
var U;
|
|
1738
|
+
var k = ((U = g.auth) == null ? void 0 : U.type) || "none", q = M(g), m = u[v[N]], I = g.tools || [], R = ((m == null ? void 0 : m.tools) || []).slice();
|
|
1739
|
+
return I.forEach(function(P) {
|
|
1740
|
+
R.some(function(j) {
|
|
1741
|
+
return j.name === P;
|
|
1742
|
+
}) || R.push({ name: P });
|
|
1743
|
+
}), /* @__PURE__ */ w(ge, { padding: "md", className: "relative", "data-testid": "mcp-server", children: [
|
|
1744
|
+
/* @__PURE__ */ i(
|
|
1745
|
+
F,
|
|
1746
|
+
{
|
|
1747
|
+
variant: "ghost",
|
|
1748
|
+
size: "icon",
|
|
1749
|
+
onClick: function() {
|
|
1750
|
+
b(N);
|
|
1751
|
+
},
|
|
1752
|
+
className: "absolute top-3 right-3 ivr-hover-destructive",
|
|
1753
|
+
style: { color: "var(--mieweb-destructive)" },
|
|
1754
|
+
"aria-label": "Remove server",
|
|
1755
|
+
children: /* @__PURE__ */ i(fe, { className: "h-5 w-5" })
|
|
1756
|
+
}
|
|
1757
|
+
),
|
|
1758
|
+
/* @__PURE__ */ w("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4 mb-4 pr-10", children: [
|
|
1759
|
+
/* @__PURE__ */ i(
|
|
1760
|
+
W,
|
|
1761
|
+
{
|
|
1762
|
+
label: "Name",
|
|
1763
|
+
size: "md",
|
|
1764
|
+
value: g.name || "",
|
|
1765
|
+
onChange: function(P) {
|
|
1766
|
+
l(N, { name: P.target.value });
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
),
|
|
1770
|
+
/* @__PURE__ */ i(
|
|
1771
|
+
W,
|
|
1772
|
+
{
|
|
1773
|
+
label: "URL",
|
|
1774
|
+
size: "md",
|
|
1775
|
+
type: "url",
|
|
1776
|
+
value: g.url || "",
|
|
1777
|
+
onChange: function(P) {
|
|
1778
|
+
l(N, { url: P.target.value });
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
),
|
|
1782
|
+
/* @__PURE__ */ i(
|
|
1783
|
+
le,
|
|
1784
|
+
{
|
|
1785
|
+
label: "Auth",
|
|
1786
|
+
options: Un,
|
|
1787
|
+
value: k,
|
|
1788
|
+
onValueChange: function(P) {
|
|
1789
|
+
O(N, P);
|
|
1790
|
+
},
|
|
1791
|
+
size: "md"
|
|
1792
|
+
}
|
|
1793
|
+
)
|
|
1794
|
+
] }),
|
|
1795
|
+
k === "header" && /* @__PURE__ */ i("div", { className: "mb-4 md:w-1/3", children: /* @__PURE__ */ i(
|
|
1796
|
+
W,
|
|
1797
|
+
{
|
|
1798
|
+
label: "Header name",
|
|
1799
|
+
size: "sm",
|
|
1800
|
+
value: g.auth.name || "",
|
|
1801
|
+
onChange: function(P) {
|
|
1802
|
+
l(N, { auth: { ...g.auth, name: P.target.value } });
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
) }),
|
|
1806
|
+
k !== "none" && q && /* @__PURE__ */ i("div", { className: "mb-4", children: /* @__PURE__ */ i(
|
|
1807
|
+
Hn,
|
|
1808
|
+
{
|
|
1809
|
+
secretName: q,
|
|
1810
|
+
isSet: h(q),
|
|
1811
|
+
onSecretChange: o
|
|
1812
|
+
},
|
|
1813
|
+
q
|
|
1814
|
+
) }),
|
|
1815
|
+
/* @__PURE__ */ w("div", { className: "p-4 rounded-lg border", style: { background: "var(--mieweb-muted)", borderColor: "var(--mieweb-border)" }, children: [
|
|
1816
|
+
/* @__PURE__ */ w("div", { className: "flex justify-between items-center mb-3", children: [
|
|
1817
|
+
/* @__PURE__ */ w("h4", { className: "font-medium text-sm", style: { color: "var(--mieweb-foreground)" }, children: [
|
|
1818
|
+
"Enabled tools (",
|
|
1819
|
+
I.length,
|
|
1820
|
+
")"
|
|
1821
|
+
] }),
|
|
1822
|
+
a && /* @__PURE__ */ i(
|
|
1823
|
+
F,
|
|
1824
|
+
{
|
|
1825
|
+
variant: "primary",
|
|
1826
|
+
size: "sm",
|
|
1827
|
+
onClick: function() {
|
|
1828
|
+
D(N);
|
|
1829
|
+
},
|
|
1830
|
+
disabled: !g.url || (m == null ? void 0 : m.status) === "loading",
|
|
1831
|
+
leftIcon: /* @__PURE__ */ i(Ze, { className: "h-3 w-3" }),
|
|
1832
|
+
children: (m == null ? void 0 : m.status) === "loading" ? "Discovering..." : "Discover tools"
|
|
1833
|
+
}
|
|
1834
|
+
)
|
|
1835
|
+
] }),
|
|
1836
|
+
(m == null ? void 0 : m.status) === "error" && /* @__PURE__ */ w("p", { className: "text-sm mb-2", style: { color: "var(--mieweb-destructive)" }, children: [
|
|
1837
|
+
"Discovery failed: ",
|
|
1838
|
+
m.error
|
|
1839
|
+
] }),
|
|
1840
|
+
R.length === 0 ? /* @__PURE__ */ w("p", { className: "text-sm", style: { color: "var(--mieweb-muted-foreground)" }, children: [
|
|
1841
|
+
"No tools enabled. ",
|
|
1842
|
+
a ? 'Use "Discover tools" to list available tools.' : ""
|
|
1843
|
+
] }) : /* @__PURE__ */ i("div", { className: "space-y-2", children: R.map(function(P) {
|
|
1844
|
+
return /* @__PURE__ */ w("div", { children: [
|
|
1845
|
+
/* @__PURE__ */ i(
|
|
1846
|
+
se,
|
|
1847
|
+
{
|
|
1848
|
+
label: P.name,
|
|
1849
|
+
size: "sm",
|
|
1850
|
+
checked: I.includes(P.name),
|
|
1851
|
+
onChange: function(j) {
|
|
1852
|
+
z(N, P.name, j.target.checked);
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
),
|
|
1856
|
+
P.description && /* @__PURE__ */ i("p", { className: "text-xs ml-6", style: { color: "var(--mieweb-muted-foreground)" }, children: P.description })
|
|
1857
|
+
] }, P.name);
|
|
1858
|
+
}) })
|
|
1859
|
+
] })
|
|
1860
|
+
] }, v[N]);
|
|
1861
|
+
}) })
|
|
1862
|
+
] });
|
|
1863
|
+
}
|
|
1864
|
+
function Mn({
|
|
1865
|
+
initialConfig: e,
|
|
1866
|
+
schema: t,
|
|
1867
|
+
onConfigChange: n,
|
|
1868
|
+
onDownload: r,
|
|
1869
|
+
onSubmit: o,
|
|
1870
|
+
showEditor: a = !0,
|
|
1871
|
+
secretNames: s,
|
|
1872
|
+
onDiscoverTools: u
|
|
1873
|
+
}) {
|
|
1874
|
+
const [c, x] = V({}), S = G(function(y, E) {
|
|
1875
|
+
x(function(_) {
|
|
1876
|
+
return { ..._, [y]: E };
|
|
1877
|
+
});
|
|
1878
|
+
}, []), [f, C] = V(function() {
|
|
1879
|
+
return e || Pn(t || re);
|
|
1880
|
+
}), [v, A] = V("form"), [d, l] = V("yaml"), [p, b] = V(""), [h, T] = V(""), [O, z] = V(t || re), [D, g] = V(!1), [N, k] = V(null), [q, m] = V(0);
|
|
1881
|
+
Z(function() {
|
|
1882
|
+
if (!N) return;
|
|
1883
|
+
const y = setTimeout(function() {
|
|
1884
|
+
k(null);
|
|
1885
|
+
}, 5e3);
|
|
1886
|
+
return function() {
|
|
1887
|
+
clearTimeout(y);
|
|
1888
|
+
};
|
|
1889
|
+
}, [N]);
|
|
1890
|
+
const I = H(null), R = H(null), U = H(f);
|
|
1891
|
+
U.current = f, Z(function() {
|
|
1892
|
+
try {
|
|
1893
|
+
b(be(f)), T(JSON.stringify(f, null, 2));
|
|
1894
|
+
} catch (y) {
|
|
1895
|
+
console.error("Error generating output", y);
|
|
1896
|
+
}
|
|
1897
|
+
}, [f]), Z(function() {
|
|
1898
|
+
try {
|
|
1899
|
+
v === "editor" && (d === "yaml" ? b(be(f)) : d === "json" && T(JSON.stringify(f, null, 2)));
|
|
1900
|
+
} catch (y) {
|
|
1901
|
+
console.error("Error resetting output on tab change", y);
|
|
1902
|
+
}
|
|
1903
|
+
}, [v, d, f]), Z(function() {
|
|
1904
|
+
n && n(f);
|
|
1905
|
+
}, [f, n]);
|
|
1906
|
+
function P(y) {
|
|
1907
|
+
U.current = y, C(y);
|
|
1908
|
+
}
|
|
1909
|
+
function j(y) {
|
|
1910
|
+
if (Array.isArray(y)) return y.map(j);
|
|
1911
|
+
if (y !== null && typeof y == "object") {
|
|
1912
|
+
var E = {};
|
|
1913
|
+
for (var _ of Object.keys(y))
|
|
1914
|
+
E[_] = j(y[_]);
|
|
1915
|
+
return E;
|
|
1916
|
+
}
|
|
1917
|
+
return y === null ? "" : y;
|
|
1918
|
+
}
|
|
1919
|
+
function ie(y, E) {
|
|
1920
|
+
try {
|
|
1921
|
+
let _;
|
|
1922
|
+
E === "yaml" ? (b(y), _ = j(pe.load(y))) : (T(y), _ = JSON.parse(y)), _ && typeof _ == "object" && (z(function($) {
|
|
1923
|
+
return _n(f, _, $);
|
|
1924
|
+
}), C(_), m(function($) {
|
|
1925
|
+
return $ + 1;
|
|
1926
|
+
}));
|
|
1927
|
+
} catch {
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
function Ue(y) {
|
|
1931
|
+
bn(f, p, r, y || "yaml", h);
|
|
1932
|
+
}
|
|
1933
|
+
const [ae, Ve] = V(null);
|
|
1934
|
+
Z(function() {
|
|
1935
|
+
D && !ae && import("@mieweb/forms-editor").then(function(y) {
|
|
1936
|
+
Ve(function() {
|
|
1937
|
+
return y.QuestionnaireEditor;
|
|
1938
|
+
});
|
|
1939
|
+
});
|
|
1940
|
+
}, [D, ae]);
|
|
1941
|
+
const De = G(function() {
|
|
1942
|
+
var y;
|
|
1943
|
+
(y = R.current) == null || y.call(R), z(function(E) {
|
|
1944
|
+
return te(U.current, E);
|
|
1945
|
+
}), g(!0);
|
|
1946
|
+
}, []), He = G(function() {
|
|
1947
|
+
var y;
|
|
1948
|
+
(y = R.current) == null || y.call(R), z(function(E) {
|
|
1949
|
+
return m(function(_) {
|
|
1950
|
+
return _ + 1;
|
|
1951
|
+
}), te(U.current, E);
|
|
1952
|
+
}), g(!1);
|
|
1953
|
+
}, []), Ke = /* @__PURE__ */ new Set(["text", "longtext", "dropdown", "check", "section"]);
|
|
1954
|
+
function Be(y) {
|
|
1955
|
+
let E = 0;
|
|
1956
|
+
function _(Y) {
|
|
1957
|
+
return Array.isArray(Y) ? Y.reduce(function(J, Q) {
|
|
1958
|
+
return Q.fieldType && !Ke.has(Q.fieldType) ? (E++, J) : Array.isArray(Q.fields) ? J.concat([{ ...Q, fields: _(Q.fields) }]) : J.concat([Q]);
|
|
1959
|
+
}, []) : Y;
|
|
1960
|
+
}
|
|
1961
|
+
return { filtered: { ...y, fields: _(y.fields) }, removedCount: E };
|
|
1962
|
+
}
|
|
1963
|
+
const $e = G(function(y) {
|
|
1964
|
+
const { filtered: E, removedCount: _ } = Be(y);
|
|
1965
|
+
_ > 0 && k(
|
|
1966
|
+
`${_} unsupported field type${_ > 1 ? "s were" : " was"} removed. Only Text, Long Text, Dropdown, and Checkbox fields are supported.`
|
|
1967
|
+
), z(function($) {
|
|
1968
|
+
const Y = qn($, E, U.current);
|
|
1969
|
+
return Y.config !== U.current && C(Y.config), E;
|
|
1970
|
+
});
|
|
1971
|
+
}, []), Je = G(function() {
|
|
1972
|
+
const y = new Blob([JSON.stringify(O, null, 2)], { type: "application/json" }), E = URL.createObjectURL(y), _ = document.createElement("a");
|
|
1973
|
+
_.href = E, _.download = (O.title || "form-schema").replace(/\s+/g, "-").toLowerCase() + ".json", document.body.appendChild(_), _.click(), document.body.removeChild(_), URL.revokeObjectURL(E);
|
|
1974
|
+
}, [O]), We = G(function(y) {
|
|
1975
|
+
var $;
|
|
1976
|
+
const E = ($ = y.target.files) == null ? void 0 : $[0];
|
|
1977
|
+
if (!E) return;
|
|
1978
|
+
const _ = new FileReader();
|
|
1979
|
+
_.onload = function(Y) {
|
|
1980
|
+
try {
|
|
1981
|
+
const J = JSON.parse(Y.target.result);
|
|
1982
|
+
if (!J.fields || !Array.isArray(J.fields)) {
|
|
1983
|
+
alert('Invalid schema file: missing "fields" array.');
|
|
1984
|
+
return;
|
|
1985
|
+
}
|
|
1986
|
+
z(te(U.current, J)), m(function(Q) {
|
|
1987
|
+
return Q + 1;
|
|
1988
|
+
});
|
|
1989
|
+
} catch (J) {
|
|
1990
|
+
alert("Failed to parse schema file: " + J.message);
|
|
1991
|
+
}
|
|
1992
|
+
}, _.readAsText(E), y.target.value = "";
|
|
1993
|
+
}, []), Ye = G(function() {
|
|
1994
|
+
var y;
|
|
1995
|
+
window.confirm("Reset the form to the default Agent schema? Any custom fields will be lost.") && ((y = R.current) == null || y.call(R), z(te(U.current, re)), m(function(E) {
|
|
1996
|
+
return E + 1;
|
|
1997
|
+
}));
|
|
1998
|
+
}, []);
|
|
1999
|
+
return /* @__PURE__ */ i("div", { className: "flex flex-col h-full", style: { fontFamily: "var(--mieweb-font-sans, inherit)" }, children: /* @__PURE__ */ w("div", { className: "flex-1 flex flex-col overflow-hidden", children: [
|
|
2000
|
+
/* @__PURE__ */ i("div", { className: "shadow-sm border-b", style: { background: "var(--mieweb-card)", borderColor: "var(--mieweb-border)" }, children: /* @__PURE__ */ w("div", { className: "px-4 flex items-center justify-between gap-2 flex-wrap", children: [
|
|
2001
|
+
/* @__PURE__ */ i(
|
|
2002
|
+
sn,
|
|
2003
|
+
{
|
|
2004
|
+
value: v,
|
|
2005
|
+
onValueChange: function(y) {
|
|
2006
|
+
A(y), g(!1);
|
|
2007
|
+
},
|
|
2008
|
+
variant: "underline",
|
|
2009
|
+
children: /* @__PURE__ */ w(cn, { className: "border-b-0", children: [
|
|
2010
|
+
/* @__PURE__ */ w(ue, { value: "form", className: "gap-2 px-3 py-3 text-sm", children: [
|
|
2011
|
+
/* @__PURE__ */ i(Xe, { className: "h-4 w-4" }),
|
|
2012
|
+
/* @__PURE__ */ i("span", { className: "hidden sm:inline", children: "Form Builder" })
|
|
2013
|
+
] }),
|
|
2014
|
+
/* @__PURE__ */ w(ue, { value: "tools", className: "gap-2 px-3 py-3 text-sm", children: [
|
|
2015
|
+
/* @__PURE__ */ i(en, { className: "h-4 w-4" }),
|
|
2016
|
+
/* @__PURE__ */ i("span", { className: "hidden sm:inline", children: "Tool Builder" })
|
|
2017
|
+
] }),
|
|
2018
|
+
a && /* @__PURE__ */ w(ue, { value: "editor", className: "gap-2 px-3 py-3 text-sm", children: [
|
|
2019
|
+
/* @__PURE__ */ i(nn, { className: "h-4 w-4" }),
|
|
2020
|
+
/* @__PURE__ */ i("span", { className: "hidden sm:inline", children: "Config Editor" })
|
|
2021
|
+
] })
|
|
2022
|
+
] })
|
|
2023
|
+
}
|
|
2024
|
+
),
|
|
2025
|
+
o && /* @__PURE__ */ i(
|
|
2026
|
+
F,
|
|
2027
|
+
{
|
|
2028
|
+
variant: "primary",
|
|
2029
|
+
size: "sm",
|
|
2030
|
+
onClick: () => o(p, { ...c }),
|
|
2031
|
+
leftIcon: /* @__PURE__ */ i(tn, { className: "h-4 w-4" }),
|
|
2032
|
+
className: "my-1 shrink-0",
|
|
2033
|
+
children: /* @__PURE__ */ i("span", { className: "hidden sm:inline", children: "Submit" })
|
|
2034
|
+
}
|
|
2035
|
+
)
|
|
2036
|
+
] }) }),
|
|
2037
|
+
/* @__PURE__ */ w("div", { className: "flex-1 overflow-auto p-4 md:p-6", children: [
|
|
2038
|
+
/* @__PURE__ */ w("div", { style: { display: v === "form" && !D ? "" : "none" }, children: [
|
|
2039
|
+
/* @__PURE__ */ w("div", { className: "max-w-6xl mx-auto mb-4 flex flex-wrap items-center justify-between gap-2", children: [
|
|
2040
|
+
/* @__PURE__ */ i(
|
|
2041
|
+
F,
|
|
2042
|
+
{
|
|
2043
|
+
variant: "primary",
|
|
2044
|
+
size: "sm",
|
|
2045
|
+
onClick: De,
|
|
2046
|
+
leftIcon: /* @__PURE__ */ i(rn, { className: "h-4 w-4" }),
|
|
2047
|
+
children: "Customize Form"
|
|
2048
|
+
}
|
|
2049
|
+
),
|
|
2050
|
+
/* @__PURE__ */ w("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
|
|
2051
|
+
/* @__PURE__ */ i(
|
|
2052
|
+
F,
|
|
2053
|
+
{
|
|
2054
|
+
variant: "primary",
|
|
2055
|
+
size: "sm",
|
|
2056
|
+
onClick: Je,
|
|
2057
|
+
leftIcon: /* @__PURE__ */ i(_e, { className: "h-4 w-4" }),
|
|
2058
|
+
title: "Export schema as JSON",
|
|
2059
|
+
children: "Export"
|
|
2060
|
+
}
|
|
2061
|
+
),
|
|
2062
|
+
/* @__PURE__ */ i(
|
|
2063
|
+
F,
|
|
2064
|
+
{
|
|
2065
|
+
variant: "primary",
|
|
2066
|
+
size: "sm",
|
|
2067
|
+
onClick: function() {
|
|
2068
|
+
var y;
|
|
2069
|
+
(y = I.current) == null || y.click();
|
|
2070
|
+
},
|
|
2071
|
+
leftIcon: /* @__PURE__ */ i(an, { className: "h-4 w-4" }),
|
|
2072
|
+
title: "Import a schema JSON file",
|
|
2073
|
+
children: "Import"
|
|
2074
|
+
}
|
|
2075
|
+
),
|
|
2076
|
+
/* @__PURE__ */ i(
|
|
2077
|
+
"input",
|
|
2078
|
+
{
|
|
2079
|
+
ref: I,
|
|
2080
|
+
type: "file",
|
|
2081
|
+
accept: ".json",
|
|
2082
|
+
className: "hidden",
|
|
2083
|
+
onChange: We
|
|
2084
|
+
}
|
|
2085
|
+
),
|
|
2086
|
+
/* @__PURE__ */ i(
|
|
2087
|
+
F,
|
|
2088
|
+
{
|
|
2089
|
+
variant: "ghost",
|
|
2090
|
+
size: "sm",
|
|
2091
|
+
onClick: Ye,
|
|
2092
|
+
leftIcon: /* @__PURE__ */ i(on, { className: "h-4 w-4" }),
|
|
2093
|
+
style: { color: "var(--mieweb-destructive)" },
|
|
2094
|
+
className: "ivr-hover-destructive",
|
|
2095
|
+
title: "Reset to default Agent schema",
|
|
2096
|
+
children: "Reset"
|
|
2097
|
+
}
|
|
2098
|
+
)
|
|
2099
|
+
] })
|
|
2100
|
+
] }),
|
|
2101
|
+
/* @__PURE__ */ i(
|
|
2102
|
+
jn,
|
|
2103
|
+
{
|
|
2104
|
+
config: f,
|
|
2105
|
+
schema: O,
|
|
2106
|
+
onConfigChange: P,
|
|
2107
|
+
syncRef: R
|
|
2108
|
+
},
|
|
2109
|
+
q
|
|
2110
|
+
),
|
|
2111
|
+
/* @__PURE__ */ i(
|
|
2112
|
+
Kn,
|
|
2113
|
+
{
|
|
2114
|
+
config: f,
|
|
2115
|
+
onConfigChange: P,
|
|
2116
|
+
secretNames: s,
|
|
2117
|
+
pendingSecrets: c,
|
|
2118
|
+
onSecretChange: S,
|
|
2119
|
+
onDiscoverTools: u
|
|
2120
|
+
}
|
|
2121
|
+
)
|
|
2122
|
+
] }),
|
|
2123
|
+
v === "form" && D && /* @__PURE__ */ w("div", { className: "max-w-7xl mx-auto", children: [
|
|
2124
|
+
/* @__PURE__ */ w("div", { className: "mb-4 flex items-center gap-3", children: [
|
|
2125
|
+
/* @__PURE__ */ i(
|
|
2126
|
+
F,
|
|
2127
|
+
{
|
|
2128
|
+
variant: "ghost",
|
|
2129
|
+
size: "sm",
|
|
2130
|
+
onClick: He,
|
|
2131
|
+
leftIcon: /* @__PURE__ */ i(ln, { className: "h-4 w-4" }),
|
|
2132
|
+
children: "Back to Form"
|
|
2133
|
+
}
|
|
2134
|
+
),
|
|
2135
|
+
/* @__PURE__ */ w("span", { className: "text-sm", style: { color: "var(--mieweb-muted-foreground)" }, children: [
|
|
2136
|
+
"Add, remove, or reorder fields. The field ",
|
|
2137
|
+
/* @__PURE__ */ i("code", { className: "text-xs px-1 rounded", style: { background: "var(--mieweb-muted)", color: "var(--mieweb-foreground)" }, children: "ID" }),
|
|
2138
|
+
" is used as the config key (dot-notation for nesting, e.g. ",
|
|
2139
|
+
/* @__PURE__ */ i("code", { className: "text-xs px-1 rounded", style: { background: "var(--mieweb-muted)", color: "var(--mieweb-foreground)" }, children: "twilio.phoneNumber" }),
|
|
2140
|
+
")."
|
|
2141
|
+
] })
|
|
2142
|
+
] }),
|
|
2143
|
+
N && /* @__PURE__ */ i(
|
|
2144
|
+
un,
|
|
2145
|
+
{
|
|
2146
|
+
variant: "warning",
|
|
2147
|
+
dismissible: !0,
|
|
2148
|
+
onDismiss: function() {
|
|
2149
|
+
k(null);
|
|
2150
|
+
},
|
|
2151
|
+
className: "mb-3",
|
|
2152
|
+
children: /* @__PURE__ */ i(dn, { children: N })
|
|
2153
|
+
}
|
|
2154
|
+
),
|
|
2155
|
+
/* @__PURE__ */ i("div", { className: "rounded-lg shadow p-4 min-h-[600px]", style: { background: "var(--mieweb-card)", borderRadius: "var(--mieweb-radius-lg, 0.75rem)" }, children: ae ? /* @__PURE__ */ i(
|
|
2156
|
+
ae,
|
|
2157
|
+
{
|
|
2158
|
+
initialFormData: O || void 0,
|
|
2159
|
+
onChange: $e
|
|
2160
|
+
}
|
|
2161
|
+
) : /* @__PURE__ */ i("div", { className: "flex items-center justify-center h-64", style: { color: "var(--mieweb-muted-foreground)" }, children: "Loading form editor..." }) })
|
|
2162
|
+
] }),
|
|
2163
|
+
v === "editor" && a && /* @__PURE__ */ i(
|
|
2164
|
+
On,
|
|
2165
|
+
{
|
|
2166
|
+
yamlOutput: p,
|
|
2167
|
+
jsonOutput: h,
|
|
2168
|
+
editorMode: d,
|
|
2169
|
+
onEditorModeChange: l,
|
|
2170
|
+
onEditorChange: ie,
|
|
2171
|
+
onDownload: Ue
|
|
2172
|
+
}
|
|
2173
|
+
),
|
|
2174
|
+
v === "tools" && /* @__PURE__ */ i(
|
|
2175
|
+
Fn,
|
|
2176
|
+
{
|
|
2177
|
+
config: f,
|
|
2178
|
+
onConfigChange: P
|
|
2179
|
+
}
|
|
2180
|
+
)
|
|
2181
|
+
] })
|
|
2182
|
+
] }) });
|
|
2183
|
+
}
|
|
2184
|
+
export {
|
|
2185
|
+
Mn as A,
|
|
2186
|
+
On as C,
|
|
2187
|
+
jn as F,
|
|
2188
|
+
Fn as T,
|
|
2189
|
+
be as a,
|
|
2190
|
+
wn as b,
|
|
2191
|
+
te as c,
|
|
2192
|
+
re as d,
|
|
2193
|
+
Pn as e,
|
|
2194
|
+
bn as f,
|
|
2195
|
+
En as q,
|
|
2196
|
+
yn as v,
|
|
2197
|
+
Zn as y
|
|
2198
|
+
};
|