@shuffleio/shuffle-mcps 0.0.23 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3815,7 +3815,14 @@ function AppAuthSection({
3815
3815
  onAuthChange,
3816
3816
  onTestConnection,
3817
3817
  onSaveAuth,
3818
- onRefreshAuth
3818
+ onRefreshAuth,
3819
+ globalUrl,
3820
+ userdata,
3821
+ isLoaded,
3822
+ isLoggedIn,
3823
+ serverside,
3824
+ theme,
3825
+ colorMode
3819
3826
  }) {
3820
3827
  return /* @__PURE__ */ jsx7(motion3.div, { initial: { opacity: 0, y: 12 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 0.1 }, children: /* @__PURE__ */ jsxs5(Box4, { sx: { mb: 3 }, children: [
3821
3828
  /* @__PURE__ */ jsx7(Typography4, { sx: { color: "hsl(var(--foreground))", fontWeight: 600, fontSize: "0.95rem", mb: 0.5 }, children: "Authentication" }),
@@ -3831,7 +3838,14 @@ function AppAuthSection({
3831
3838
  onTestConnection,
3832
3839
  onSaveAuth,
3833
3840
  apiAuthEntries: matchingEntries,
3834
- onRefreshAuth
3841
+ onRefreshAuth,
3842
+ globalUrl,
3843
+ userdata,
3844
+ isLoaded,
3845
+ isLoggedIn,
3846
+ serverside,
3847
+ theme,
3848
+ colorMode
3835
3849
  }
3836
3850
  )
3837
3851
  ] }) });
@@ -4008,7 +4022,8 @@ function getPrimaryCategory(appName, categories) {
4008
4022
  if (COMMUNICATION_PATTERNS_NAMES.some((p) => name.includes(p))) return "Communication";
4009
4023
  return null;
4010
4024
  }
4011
- var AppMcpChat = ({ appName, appIcon, appId, categories }) => {
4025
+ var AppMcpChat = ({ appName, appIcon, appId, categories, globalUrl }) => {
4026
+ useSyncHostBaseUrl(globalUrl);
4012
4027
  const [input, setInput] = useState6("");
4013
4028
  const [runState, setRunState] = useState6("idle");
4014
4029
  const [query, setQuery] = useState6("");
@@ -4452,7 +4467,7 @@ var AppMcpChat_default = AppMcpChat;
4452
4467
 
4453
4468
  // views/TryMcpSection.tsx
4454
4469
  import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
4455
- function TryMcpSection({ appName, appIcon, appId, categories }) {
4470
+ function TryMcpSection({ appName, appIcon, appId, categories, globalUrl, userdata, isLoaded, isLoggedIn, serverside, theme, colorMode }) {
4456
4471
  return /* @__PURE__ */ jsx10(motion5.div, { initial: { opacity: 0, y: 12 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 0.15 }, children: /* @__PURE__ */ jsxs7(Box6, { sx: { mt: 5, mb: 3 }, children: [
4457
4472
  /* @__PURE__ */ jsx10(Typography6, { sx: { color: "hsl(var(--foreground))", fontWeight: 600, fontSize: "0.95rem", mb: 1.5 }, children: "Try MCP" }),
4458
4473
  /* @__PURE__ */ jsx10(
@@ -4461,7 +4476,14 @@ function TryMcpSection({ appName, appIcon, appId, categories }) {
4461
4476
  appName,
4462
4477
  appIcon,
4463
4478
  appId,
4464
- categories
4479
+ categories,
4480
+ globalUrl,
4481
+ userdata,
4482
+ isLoaded,
4483
+ isLoggedIn,
4484
+ serverside,
4485
+ theme,
4486
+ colorMode
4465
4487
  }
4466
4488
  )
4467
4489
  ] }) });
@@ -5295,8 +5317,17 @@ function AppDetailDrawer({
5295
5317
  onRefresh,
5296
5318
  onAddToCanvas,
5297
5319
  isAuthenticated = true,
5298
- activeOrgId
5320
+ activeOrgId,
5321
+ globalUrl,
5322
+ userdata,
5323
+ isLoaded,
5324
+ isLoggedIn,
5325
+ serverside,
5326
+ theme,
5327
+ colorMode
5299
5328
  }) {
5329
+ const themeScope = useShuffleMcpTheme();
5330
+ const scopeClassName = themeScope?.scopeClassName ?? (theme === "dark" ? "shuffle-mcp-scope dark" : theme === "light" ? "shuffle-mcp-scope" : void 0);
5300
5331
  const [appInfo, setAppInfo] = useState8(null);
5301
5332
  const [appLoading, setAppLoading] = useState8(true);
5302
5333
  const [isActivated, setIsActivated] = useState8(null);
@@ -5528,15 +5559,23 @@ function AppDetailDrawer({
5528
5559
  anchor,
5529
5560
  open,
5530
5561
  onClose: handleClose,
5531
- sx: {
5532
- "& .MuiDrawer-paper": {
5533
- width,
5534
- maxWidth: "100vw",
5535
- background: "linear-gradient(180deg, hsl(var(--card)) 0%, hsl(var(--background)) 100%)",
5536
- borderLeft: anchor === "right" ? "1px solid hsl(var(--border))" : "none",
5537
- borderRight: anchor === "left" ? "1px solid hsl(var(--border))" : "none"
5562
+ slotProps: {
5563
+ paper: {
5564
+ className: scopeClassName,
5565
+ sx: {
5566
+ width: { xs: "100%", sm: width },
5567
+ maxWidth: "100vw",
5568
+ display: "flex",
5569
+ flexDirection: "column",
5570
+ background: "linear-gradient(180deg, hsl(var(--card)) 0%, hsl(var(--background)) 100%)",
5571
+ borderLeft: anchor === "right" ? "1px solid hsl(var(--border))" : "none",
5572
+ borderRight: anchor === "left" ? "1px solid hsl(var(--border))" : "none"
5573
+ }
5538
5574
  }
5539
5575
  },
5576
+ sx: {
5577
+ "& .MuiDrawer-paper": { boxSizing: "border-box" }
5578
+ },
5540
5579
  children: [
5541
5580
  /* @__PURE__ */ jsxs9(
5542
5581
  Box8,
@@ -5592,7 +5631,14 @@ function AppDetailDrawer({
5592
5631
  onAdd: onAddToCanvas && appName ? () => {
5593
5632
  onAddToCanvas({ name: appName, icon: resolvedImage || "", algoliaId: resolvedAlgoliaId });
5594
5633
  onClose();
5595
- } : void 0
5634
+ } : void 0,
5635
+ globalUrl,
5636
+ userdata,
5637
+ isLoaded,
5638
+ isLoggedIn,
5639
+ serverside,
5640
+ theme,
5641
+ colorMode
5596
5642
  }
5597
5643
  ),
5598
5644
  isAuthenticated && incidentStats && incidentStats.ingested > 0 && /* @__PURE__ */ jsx12(motion6.div, { initial: { opacity: 0, y: 12 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 0.08 }, children: /* @__PURE__ */ jsxs9(Box8, { sx: {
@@ -5634,7 +5680,14 @@ function AppDetailDrawer({
5634
5680
  onAuthChange: handleAuthChange,
5635
5681
  onTestConnection: (appId2, authId) => handleTestConnection(appName || appId2, authId),
5636
5682
  onSaveAuth: (appId2, creds) => handleSaveAuth(appId2, creds, appName || void 0),
5637
- onRefreshAuth: refreshAuth
5683
+ onRefreshAuth: refreshAuth,
5684
+ globalUrl,
5685
+ userdata,
5686
+ isLoaded,
5687
+ isLoggedIn,
5688
+ serverside,
5689
+ theme,
5690
+ colorMode
5638
5691
  }
5639
5692
  ) }),
5640
5693
  isAuthenticated && /* @__PURE__ */ jsxs9(Fragment4, { children: [
@@ -5644,10 +5697,32 @@ function AppDetailDrawer({
5644
5697
  appName: appName || "",
5645
5698
  appIcon: resolvedImage,
5646
5699
  appId: matchingEntries[0]?.app?.id || matchingEntries[0]?.id || appName || "",
5647
- categories: appInfo?.categories
5700
+ categories: appInfo?.categories,
5701
+ globalUrl,
5702
+ userdata,
5703
+ isLoaded,
5704
+ isLoggedIn,
5705
+ serverside,
5706
+ theme,
5707
+ colorMode
5648
5708
  }
5649
5709
  ),
5650
- /* @__PURE__ */ jsx12(SingulActionsPreview_default, { appName: appName || "", appIcon: resolvedImage, categories: appInfo?.categories, activeOrgId })
5710
+ /* @__PURE__ */ jsx12(
5711
+ SingulActionsPreview_default,
5712
+ {
5713
+ appName: appName || "",
5714
+ appIcon: resolvedImage,
5715
+ categories: appInfo?.categories,
5716
+ activeOrgId,
5717
+ globalUrl,
5718
+ userdata,
5719
+ isLoaded,
5720
+ isLoggedIn,
5721
+ serverside,
5722
+ theme,
5723
+ colorMode
5724
+ }
5725
+ )
5651
5726
  ] })
5652
5727
  ] }) })
5653
5728
  ]
@@ -6507,9 +6582,21 @@ function AppSearchDrawer({
6507
6582
  colorMode
6508
6583
  }) {
6509
6584
  const themeScope = useShuffleMcpTheme();
6585
+ const scopeClassName = themeScope?.scopeClassName ?? (theme === "dark" ? "shuffle-mcp-scope dark" : theme === "light" ? "shuffle-mcp-scope" : void 0);
6510
6586
  const [detailAppName, setDetailAppName] = useState10(null);
6511
6587
  const [detailAppId, setDetailAppId] = useState10(null);
6512
6588
  const [highlightActive, setHighlightActive] = useState10(false);
6589
+ const [bodyReady, setBodyReady] = useState10(false);
6590
+ useEffect9(() => {
6591
+ if (!open) {
6592
+ setBodyReady(false);
6593
+ return;
6594
+ }
6595
+ const raf = requestAnimationFrame(() => {
6596
+ requestAnimationFrame(() => setBodyReady(true));
6597
+ });
6598
+ return () => cancelAnimationFrame(raf);
6599
+ }, [open]);
6513
6600
  useEffect9(() => {
6514
6601
  setHighlightActive(false);
6515
6602
  if (!open || !highlightAppName) return;
@@ -6592,20 +6679,25 @@ function AppSearchDrawer({
6592
6679
  anchor,
6593
6680
  open: open && detailAppName === null,
6594
6681
  onClose: handleClose,
6595
- slotProps: { paper: { className: themeScope?.scopeClassName } },
6682
+ slotProps: {
6683
+ paper: {
6684
+ className: scopeClassName,
6685
+ sx: {
6686
+ width: { xs: "100%", sm: width },
6687
+ maxWidth: "100vw",
6688
+ height: "100vh",
6689
+ display: "flex",
6690
+ flexDirection: "column",
6691
+ overflow: "hidden",
6692
+ background: "linear-gradient(180deg, hsl(var(--card)) 0%, hsl(var(--background)) 100%)",
6693
+ borderLeft: anchor === "right" ? "1px solid hsl(var(--border))" : "none",
6694
+ borderRight: anchor === "left" ? "1px solid hsl(var(--border))" : "none"
6695
+ }
6696
+ }
6697
+ },
6596
6698
  sx: {
6597
6699
  zIndex: 9999,
6598
- "& .MuiDrawer-paper": {
6599
- width,
6600
- maxWidth: "100vw",
6601
- height: "100vh",
6602
- display: "flex",
6603
- flexDirection: "column",
6604
- overflow: "hidden",
6605
- background: "linear-gradient(180deg, hsl(var(--card)) 0%, hsl(var(--background)) 100%)",
6606
- borderLeft: anchor === "right" ? "1px solid hsl(var(--border))" : "none",
6607
- borderRight: anchor === "left" ? "1px solid hsl(var(--border))" : "none"
6608
- }
6700
+ "& .MuiDrawer-paper": { boxSizing: "border-box" }
6609
6701
  },
6610
6702
  children: [
6611
6703
  /* @__PURE__ */ jsxs12(
@@ -6701,14 +6793,16 @@ function AppSearchDrawer({
6701
6793
  overflowY: "auto"
6702
6794
  },
6703
6795
  "& .singul-results-grid": {
6704
- gridAutoRows: "75px",
6796
+ gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
6797
+ gridAutoRows: "78px",
6705
6798
  gap: "12px"
6706
6799
  },
6707
6800
  "& .singul-results-grid .singul-dropdown-item": {
6708
- minHeight: 75,
6709
- maxHeight: 75,
6710
- height: 75,
6711
- padding: "14px 16px",
6801
+ minWidth: 0,
6802
+ minHeight: 78,
6803
+ maxHeight: 78,
6804
+ height: 78,
6805
+ padding: "10px 14px",
6712
6806
  alignItems: "center",
6713
6807
  overflow: "hidden"
6714
6808
  },
@@ -6717,11 +6811,14 @@ function AppSearchDrawer({
6717
6811
  gap: "12px"
6718
6812
  },
6719
6813
  "& .singul-results-grid .singul-app-icon": {
6720
- width: 40,
6721
- height: 40,
6814
+ width: 36,
6815
+ height: 36,
6722
6816
  borderRadius: 8,
6723
6817
  padding: 4
6724
6818
  },
6819
+ "& .singul-results-grid .singul-app-details": { minWidth: 0 },
6820
+ "& .singul-results-grid .singul-app-name": { maxWidth: "100%" },
6821
+ "& .singul-results-grid .singul-checkbox": { marginLeft: "auto" },
6725
6822
  ...highlightActive && highlightAppName ? {
6726
6823
  [`& .singul-dropdown-item[data-app-name="${highlightAppName}"]`]: {
6727
6824
  borderColor: "hsl(var(--primary)) !important",
@@ -6742,7 +6839,7 @@ function AppSearchDrawer({
6742
6839
  exit: { opacity: 0, x: -20 },
6743
6840
  transition: { duration: 0.2 },
6744
6841
  style: { height: "100%", minHeight: 0 },
6745
- children: /* @__PURE__ */ jsx15(
6842
+ children: bodyReady ? /* @__PURE__ */ jsx15(
6746
6843
  ShuffleMCP2,
6747
6844
  {
6748
6845
  apiKey: API_CONFIG.apiKey || void 0,
@@ -6793,7 +6890,32 @@ function AppSearchDrawer({
6793
6890
  })),
6794
6891
  customStyles: singulStyles
6795
6892
  }
6796
- )
6893
+ ) : /* @__PURE__ */ jsxs12(Box9, { sx: { display: "flex", flexDirection: "column", gap: 1.5, height: "100%" }, children: [
6894
+ /* @__PURE__ */ jsx15(Box9, { sx: {
6895
+ height: 44,
6896
+ borderRadius: "12px",
6897
+ border: "1px solid hsl(var(--border))",
6898
+ backgroundColor: "hsl(var(--background-elevated))"
6899
+ } }),
6900
+ /* @__PURE__ */ jsx15(Box9, { sx: {
6901
+ display: "grid",
6902
+ gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
6903
+ gap: "12px",
6904
+ mt: 1
6905
+ }, children: Array.from({ length: 8 }).map((_, i) => /* @__PURE__ */ jsx15(Box9, { sx: {
6906
+ height: 78,
6907
+ borderRadius: "12px",
6908
+ backgroundColor: "hsl(var(--input))",
6909
+ border: "1px solid hsl(var(--border))",
6910
+ opacity: 0.6,
6911
+ animation: "shufflePulse 1.4s ease-in-out infinite",
6912
+ animationDelay: `${i * 60}ms`,
6913
+ "@keyframes shufflePulse": {
6914
+ "0%, 100%": { opacity: 0.35 },
6915
+ "50%": { opacity: 0.7 }
6916
+ }
6917
+ } }, i)) })
6918
+ ] })
6797
6919
  },
6798
6920
  "search"
6799
6921
  ) })
@@ -11450,15 +11572,15 @@ var AgentUI = ({
11450
11572
  var AgentUI_default = AgentUI;
11451
11573
 
11452
11574
  // components/AgentRunDrawer.tsx
11453
- import { useEffect as useEffect12, useRef as useRef9, useState as useState13 } from "react";
11575
+ import { useEffect as useEffect13, useRef as useRef10, useState as useState14 } from "react";
11454
11576
  import {
11455
- Box as Box15,
11577
+ Box as Box17,
11456
11578
  Drawer as Drawer3,
11457
11579
  IconButton as IconButton9,
11458
11580
  Tab,
11459
11581
  Tabs,
11460
- Tooltip as Tooltip10,
11461
- Typography as Typography14
11582
+ Tooltip as Tooltip11,
11583
+ Typography as Typography16
11462
11584
  } from "@mui/material";
11463
11585
  import {
11464
11586
  Play,
@@ -11466,7 +11588,363 @@ import {
11466
11588
  ShieldCheck,
11467
11589
  X as CloseIcon6
11468
11590
  } from "lucide-react";
11591
+
11592
+ // components/LocalLLMConfig.tsx
11593
+ import { useEffect as useEffect12, useMemo as useMemo7, useRef as useRef9, useState as useState13 } from "react";
11594
+ import {
11595
+ Autocomplete as Autocomplete3,
11596
+ Box as Box16,
11597
+ Button as Button9,
11598
+ Dialog as Dialog2,
11599
+ DialogActions,
11600
+ DialogContent as DialogContent2,
11601
+ DialogContentText,
11602
+ DialogTitle as DialogTitle2,
11603
+ TextField as TextField6,
11604
+ Typography as Typography15
11605
+ } from "@mui/material";
11606
+
11607
+ // components/UsageBar.tsx
11608
+ import { Box as Box15, Typography as Typography14, Tooltip as Tooltip10 } from "@mui/material";
11469
11609
  import { jsx as jsx21, jsxs as jsxs18 } from "react/jsx-runtime";
11610
+ var fmt = (n) => n.toLocaleString();
11611
+ var UsageBar = ({
11612
+ label,
11613
+ usage,
11614
+ limit,
11615
+ unit,
11616
+ hint,
11617
+ actionLabel,
11618
+ actionHref
11619
+ }) => {
11620
+ const safeLimit = Math.max(limit, 0);
11621
+ const pct = safeLimit > 0 ? usage / safeLimit * 100 : 0;
11622
+ const isOver = pct >= 100;
11623
+ const isWarn = pct >= 65 && !isOver;
11624
+ const accent = isOver ? "hsl(var(--destructive))" : isWarn ? "hsl(var(--severity-medium))" : "hsl(var(--muted-foreground))";
11625
+ const tooltipText = safeLimit > 0 ? `${pct.toFixed(0)}% used \xB7 ${fmt(usage)} / ${fmt(safeLimit)}${unit ? " " + unit : ""}${hint ? " \xB7 " + hint : ""}` : `${fmt(usage)}${unit ? " " + unit : ""}${hint ? " \xB7 " + hint : ""}`;
11626
+ return /* @__PURE__ */ jsx21(Tooltip10, { title: tooltipText, placement: "top", arrow: true, children: /* @__PURE__ */ jsxs18(Box15, { sx: { display: "flex", flexDirection: "column", gap: 0.5, py: 0.25 }, children: [
11627
+ /* @__PURE__ */ jsxs18(Box15, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 1 }, children: [
11628
+ /* @__PURE__ */ jsx21(
11629
+ Typography14,
11630
+ {
11631
+ sx: {
11632
+ fontSize: "12.8px",
11633
+ fontWeight: 500,
11634
+ color: "hsl(var(--muted-foreground))",
11635
+ lineHeight: 1.2
11636
+ },
11637
+ children: label
11638
+ }
11639
+ ),
11640
+ /* @__PURE__ */ jsxs18(Box15, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
11641
+ actionLabel && actionHref && (isWarn || isOver) && /* @__PURE__ */ jsx21(
11642
+ Box15,
11643
+ {
11644
+ component: "a",
11645
+ href: actionHref,
11646
+ target: "_blank",
11647
+ rel: "noopener noreferrer",
11648
+ sx: {
11649
+ fontSize: "12.8px",
11650
+ fontWeight: 600,
11651
+ color: accent,
11652
+ textDecoration: "none",
11653
+ "&:hover": { textDecoration: "underline" }
11654
+ },
11655
+ children: actionLabel
11656
+ }
11657
+ ),
11658
+ /* @__PURE__ */ jsx21(
11659
+ Typography14,
11660
+ {
11661
+ sx: {
11662
+ fontSize: "12.8px",
11663
+ fontWeight: 500,
11664
+ color: accent,
11665
+ whiteSpace: "nowrap",
11666
+ fontVariantNumeric: "tabular-nums"
11667
+ },
11668
+ children: safeLimit > 0 ? `${fmt(usage)} / ${fmt(safeLimit)}${unit ? " " + unit : ""}` : `${fmt(usage)}${unit ? " " + unit : ""}`
11669
+ }
11670
+ )
11671
+ ] })
11672
+ ] }),
11673
+ /* @__PURE__ */ jsx21(Box15, { sx: { width: "100%", height: 2, bgcolor: "hsl(var(--muted) / 0.5)", borderRadius: 1, overflow: "hidden" }, children: /* @__PURE__ */ jsx21(
11674
+ Box15,
11675
+ {
11676
+ sx: {
11677
+ width: `${Math.min(Math.max(pct, 0), 100)}%`,
11678
+ height: "100%",
11679
+ bgcolor: isOver ? "hsl(var(--destructive))" : isWarn ? "hsl(var(--severity-medium))" : "hsl(var(--severity-low, 142 71% 45%))",
11680
+ transition: "width 0.3s ease"
11681
+ }
11682
+ }
11683
+ ) })
11684
+ ] }) });
11685
+ };
11686
+
11687
+ // components/LocalLLMConfig.tsx
11688
+ import { jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
11689
+ import { createElement as createElement2 } from "react";
11690
+ var OPENAI_APP_NAME = "OpenAI";
11691
+ var OPENAI_APP_ID = "5d19dd82517870c68d40cacad9b5ca91";
11692
+ var SHUFFLE_AI_PRESET = "Shuffle AI";
11693
+ var CUSTOM_PRESET = "Custom / self-hosted";
11694
+ var OPENAI_ALGOLIA_APP = {
11695
+ name: OPENAI_APP_NAME,
11696
+ description: "OpenAI-compatible LLM endpoint for agent operations",
11697
+ objectID: OPENAI_APP_ID,
11698
+ creator: "",
11699
+ app_version: "1.0.0",
11700
+ image_url: "",
11701
+ time_edited: 0,
11702
+ generated: false,
11703
+ invalid: false,
11704
+ priority: 0,
11705
+ actions: 0,
11706
+ tags: [],
11707
+ accessible_by: [],
11708
+ categories: [],
11709
+ action_labels: [],
11710
+ triggers: [],
11711
+ verified: true
11712
+ };
11713
+ var ENDPOINT_PRESETS = [
11714
+ { label: SHUFFLE_AI_PRESET, url: "" },
11715
+ { label: "OpenAI", url: "https://api.openai.com/v1" },
11716
+ { label: "Anthropic", url: "https://api.anthropic.com/v1/" },
11717
+ { label: "Google Gemini", url: "https://generativelanguage.googleapis.com/v1beta/openai/" },
11718
+ { label: "Mistral", url: "https://api.mistral.ai/v1" },
11719
+ { label: "Groq", url: "https://api.groq.com/openai/v1" },
11720
+ { label: "Together AI", url: "https://api.together.xyz/v1" },
11721
+ { label: "OpenRouter", url: "https://openrouter.ai/api/v1" },
11722
+ { label: "Ollama (localhost)", url: "http://localhost:11434/v1" },
11723
+ { label: "LM Studio (localhost)", url: "http://localhost:1234/v1" },
11724
+ { label: CUSTOM_PRESET, url: "" }
11725
+ ];
11726
+ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serverside, theme, colorMode }) => {
11727
+ useSyncHostBaseUrl(globalUrl);
11728
+ const { authStates, authenticatedApps, handleAuthChange, handleTestConnection, handleSaveAuth, refreshAuth } = useAppAuth();
11729
+ const [expanded, setExpanded] = useState13(true);
11730
+ const [selectedPreset, setSelectedPreset] = useState13("");
11731
+ const [customUrl, setCustomUrl] = useState13("");
11732
+ const [confirmShuffleAIOpen, setConfirmShuffleAIOpen] = useState13(false);
11733
+ const openaiEntries = authenticatedApps.filter(
11734
+ (a) => a.app?.name?.toLowerCase() === "openai" || a.app?.id === OPENAI_APP_ID
11735
+ );
11736
+ const authState = authStates[OPENAI_APP_ID] || {
11737
+ systemId: OPENAI_APP_ID,
11738
+ status: "pending",
11739
+ credentials: {}
11740
+ };
11741
+ const currentUrl = authState.credentials?.url || "";
11742
+ const attemptedDeletionRef = useRef9(/* @__PURE__ */ new Set());
11743
+ useEffect12(() => {
11744
+ if (authState.status === "testing") return;
11745
+ const failedEntries = openaiEntries.filter((e) => e.validation && e.validation.valid === false && e.id);
11746
+ if (failedEntries.length === 0) return;
11747
+ let cancelled = false;
11748
+ (async () => {
11749
+ let deletedAny = false;
11750
+ for (const entry of failedEntries) {
11751
+ const id = entry.id;
11752
+ if (attemptedDeletionRef.current.has(id)) continue;
11753
+ attemptedDeletionRef.current.add(id);
11754
+ try {
11755
+ const resp = await fetch(getApiUrl(`/api/v1/apps/authentication/${id}`), {
11756
+ method: "DELETE",
11757
+ credentials: "include",
11758
+ headers: { ...getAuthHeader() }
11759
+ });
11760
+ if (resp.ok) deletedAny = true;
11761
+ } catch (err) {
11762
+ console.error("[LocalLLMConfig] Failed to auto-delete failed OpenAI auth:", err);
11763
+ }
11764
+ }
11765
+ if (!cancelled && deletedAny) {
11766
+ await refreshAuth();
11767
+ refreshAllIntegrationStatus();
11768
+ }
11769
+ })();
11770
+ return () => {
11771
+ cancelled = true;
11772
+ };
11773
+ }, [openaiEntries, authState.status, refreshAuth]);
11774
+ const hasOpenAIEntries = openaiEntries.length > 0;
11775
+ const effectivePreset = useMemo7(() => {
11776
+ if (selectedPreset) return selectedPreset;
11777
+ if (!currentUrl && !hasOpenAIEntries) return SHUFFLE_AI_PRESET;
11778
+ if (!currentUrl) return "";
11779
+ const match = ENDPOINT_PRESETS.find((p) => p.url && p.url === currentUrl);
11780
+ return match ? match.label : CUSTOM_PRESET;
11781
+ }, [selectedPreset, currentUrl, hasOpenAIEntries]);
11782
+ const applyShuffleAI = async () => {
11783
+ let deletedAny = false;
11784
+ for (const entry of openaiEntries) {
11785
+ if (!entry.id) continue;
11786
+ try {
11787
+ const resp = await fetch(getApiUrl(`/api/v1/apps/authentication/${entry.id}`), {
11788
+ method: "DELETE",
11789
+ credentials: "include",
11790
+ headers: { ...getAuthHeader() }
11791
+ });
11792
+ if (resp.ok) deletedAny = true;
11793
+ } catch (err) {
11794
+ console.error("[LocalLLMConfig] Failed to delete OpenAI auth when switching to Shuffle AI:", err);
11795
+ }
11796
+ }
11797
+ handleAuthChange(OPENAI_APP_ID, {});
11798
+ setSelectedPreset(SHUFFLE_AI_PRESET);
11799
+ setCustomUrl("");
11800
+ if (deletedAny) {
11801
+ await refreshAuth();
11802
+ refreshAllIntegrationStatus();
11803
+ }
11804
+ };
11805
+ const handlePresetChange = (label) => {
11806
+ if (label === SHUFFLE_AI_PRESET) {
11807
+ if (hasOpenAIEntries) {
11808
+ setConfirmShuffleAIOpen(true);
11809
+ return;
11810
+ }
11811
+ void applyShuffleAI();
11812
+ return;
11813
+ }
11814
+ setSelectedPreset(label);
11815
+ const preset = ENDPOINT_PRESETS.find((p) => p.label === label);
11816
+ if (!preset) return;
11817
+ handleAuthChange(OPENAI_APP_ID, { ...authState.credentials, url: preset.label === CUSTOM_PRESET ? customUrl : preset.url });
11818
+ };
11819
+ const handleCustomUrlChange = (value) => {
11820
+ setCustomUrl(value);
11821
+ handleAuthChange(OPENAI_APP_ID, { ...authState.credentials, url: value });
11822
+ };
11823
+ const isShuffleAI = effectivePreset === SHUFFLE_AI_PRESET;
11824
+ const orgId = userdata?.active_org?.id;
11825
+ const [orgData, setOrgData] = useState13(null);
11826
+ useEffect12(() => {
11827
+ if (!orgId) return;
11828
+ let cancelled = false;
11829
+ (async () => {
11830
+ try {
11831
+ const res = await fetch(getApiUrl(`/api/v1/orgs/${orgId}`), {
11832
+ method: "GET",
11833
+ credentials: "include",
11834
+ headers: { ...getAuthHeader(), "Content-Type": "application/json" }
11835
+ });
11836
+ if (!res.ok) return;
11837
+ const data = await res.json();
11838
+ if (!cancelled) setOrgData(data);
11839
+ } catch (err) {
11840
+ console.error("[LocalLLMConfig] Failed to fetch org info:", err);
11841
+ }
11842
+ })();
11843
+ return () => {
11844
+ cancelled = true;
11845
+ };
11846
+ }, [orgId]);
11847
+ const sync = orgData?.sync_features ?? userdata?.sync_features ?? {};
11848
+ const appExec = sync.app_executions ?? {};
11849
+ const appRunLimit = Number(appExec.limit) || 0;
11850
+ const appRunUsage = Number(appExec.usage) || 0;
11851
+ const agentTokens = sync.agent_tokens ?? {};
11852
+ const agentTokenLimit = Number(agentTokens.limit) || 0;
11853
+ const agentTokenUsage = Number(agentTokens.usage) || 0;
11854
+ return /* @__PURE__ */ jsxs19(Box16, { sx: { display: "flex", flexDirection: "column", gap: 2.5 }, children: [
11855
+ /* @__PURE__ */ jsxs19(Box16, { sx: { display: "flex", flexDirection: "column", gap: 1 }, children: [
11856
+ /* @__PURE__ */ jsx22(Typography15, { sx: { fontSize: "0.85rem", fontWeight: 600, color: "hsl(var(--foreground))" }, children: "AI Provider" }),
11857
+ /* @__PURE__ */ jsx22(
11858
+ Autocomplete3,
11859
+ {
11860
+ size: "small",
11861
+ fullWidth: true,
11862
+ disableClearable: true,
11863
+ options: ENDPOINT_PRESETS.map((p) => p.label),
11864
+ value: effectivePreset || null,
11865
+ onChange: (_e, val) => val && handlePresetChange(val),
11866
+ isOptionEqualToValue: (opt, val) => opt === val,
11867
+ renderOption: (props, option) => {
11868
+ const preset = ENDPOINT_PRESETS.find((p) => p.label === option);
11869
+ return /* @__PURE__ */ createElement2("li", { ...props, key: option }, /* @__PURE__ */ jsxs19(Box16, { sx: { display: "flex", alignItems: "center", gap: 1, width: "100%", minWidth: 0 }, children: [
11870
+ /* @__PURE__ */ jsx22(Typography15, { sx: { fontSize: "0.85rem", color: "hsl(var(--popover-foreground))" }, children: option }),
11871
+ preset?.url && /* @__PURE__ */ jsx22(Typography15, { component: "span", sx: { ml: "auto", color: "hsl(var(--muted-foreground))", fontSize: "0.75rem", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: preset.url })
11872
+ ] }));
11873
+ },
11874
+ renderInput: (params) => /* @__PURE__ */ jsx22(TextField6, { ...params, placeholder: "Search a provider\u2026" }),
11875
+ slotProps: {
11876
+ paper: { sx: { bgcolor: "hsl(var(--popover))", color: "hsl(var(--popover-foreground))", border: "1px solid hsl(var(--border))" } },
11877
+ popper: { sx: { zIndex: 9999 } }
11878
+ }
11879
+ }
11880
+ )
11881
+ ] }),
11882
+ !compact && /* @__PURE__ */ jsx22(Box16, { sx: { px: 2.5, py: 2, borderRadius: 2, border: "1px solid hsl(var(--border))", bgcolor: "hsl(var(--muted) / 0.3)" }, children: /* @__PURE__ */ jsxs19(Typography15, { sx: { fontSize: "0.8rem", color: "hsl(var(--muted-foreground))", lineHeight: 1.5 }, children: [
11883
+ isShuffleAI ? "Using Shuffle AI. No configuration is required. Pick another provider above to use your own endpoint." : "Configure an OpenAI-compatible endpoint for agent operations. Credentials are saved through the app authentication system.",
11884
+ " ",
11885
+ /* @__PURE__ */ jsx22(Box16, { component: "a", href: "https://shuffler.io/docs/AI#using-self-hosted-ai-models", target: "_blank", rel: "noopener noreferrer", sx: { color: "hsl(var(--primary))", textDecoration: "underline" }, children: "Read the docs" }),
11886
+ "."
11887
+ ] }) }),
11888
+ isShuffleAI && /* @__PURE__ */ jsxs19(Box16, { sx: { display: "flex", flexDirection: "column", gap: 0.75, mt: 0.5, width: "100%" }, children: [
11889
+ /* @__PURE__ */ jsx22(UsageBar, { label: "App runs", usage: appRunUsage, limit: appRunLimit, unit: "runs", actionLabel: "Upgrade", actionHref: "https://shuffler.io/pricing" }),
11890
+ /* @__PURE__ */ jsx22(UsageBar, { label: "Agent tokens", usage: agentTokenUsage, limit: agentTokenLimit, unit: "tokens", actionLabel: "Upgrade", actionHref: "https://shuffler.io/pricing" })
11891
+ ] }),
11892
+ effectivePreset === CUSTOM_PRESET && /* @__PURE__ */ jsx22(
11893
+ TextField6,
11894
+ {
11895
+ size: "small",
11896
+ fullWidth: true,
11897
+ placeholder: "https://your-self-hosted-endpoint.example.com",
11898
+ value: customUrl || currentUrl,
11899
+ onChange: (e) => handleCustomUrlChange(e.target.value),
11900
+ helperText: "Enter the base URL of your OpenAI-compatible endpoint",
11901
+ sx: { "& .MuiFormHelperText-root": { color: "hsl(var(--muted-foreground))" } }
11902
+ }
11903
+ ),
11904
+ !isShuffleAI && /* @__PURE__ */ jsx22(
11905
+ AppAuthCard,
11906
+ {
11907
+ app: OPENAI_ALGOLIA_APP,
11908
+ authState,
11909
+ isExpanded: expanded,
11910
+ onToggle: () => setExpanded((prev) => !prev),
11911
+ onAuthChange: handleAuthChange,
11912
+ onTestConnection: (appId, authId) => handleTestConnection(appId, authId),
11913
+ onSaveAuth: (appId, creds) => handleSaveAuth(appId, creds, OPENAI_APP_NAME),
11914
+ apiAuthEntries: openaiEntries,
11915
+ onRefreshAuth: refreshAuth,
11916
+ disableUrlPrefill: true,
11917
+ hideHeader: true,
11918
+ hideStatusChips: true,
11919
+ hideDocsLink: true,
11920
+ hideUrlFields: true,
11921
+ borderless: true,
11922
+ globalUrl,
11923
+ userdata,
11924
+ isLoaded,
11925
+ isLoggedIn,
11926
+ serverside,
11927
+ theme,
11928
+ colorMode
11929
+ }
11930
+ ),
11931
+ /* @__PURE__ */ jsxs19(Dialog2, { open: confirmShuffleAIOpen, onClose: () => setConfirmShuffleAIOpen(false), slotProps: { paper: { sx: { bgcolor: "hsl(var(--popover))", color: "hsl(var(--popover-foreground))", border: "1px solid hsl(var(--border))" } } }, children: [
11932
+ /* @__PURE__ */ jsx22(DialogTitle2, { sx: { fontSize: "1rem", fontWeight: 600 }, children: "Switch to Shuffle AI?" }),
11933
+ /* @__PURE__ */ jsx22(DialogContent2, { children: /* @__PURE__ */ jsx22(DialogContentText, { sx: { color: "hsl(var(--muted-foreground))", fontSize: "0.85rem" }, children: "Switching to Shuffle AI will remove your existing OpenAI app authentication. Any other workflow or app using this OpenAI authentication will lose access. Do you want to continue?" }) }),
11934
+ /* @__PURE__ */ jsxs19(DialogActions, { sx: { px: 3, pb: 2 }, children: [
11935
+ /* @__PURE__ */ jsx22(Button9, { onClick: () => setConfirmShuffleAIOpen(false), sx: { color: "hsl(var(--muted-foreground))", textTransform: "none", height: 36 }, children: "Cancel" }),
11936
+ /* @__PURE__ */ jsx22(Button9, { onClick: async () => {
11937
+ setConfirmShuffleAIOpen(false);
11938
+ await applyShuffleAI();
11939
+ }, sx: { bgcolor: "hsl(var(--primary))", color: "hsl(var(--primary-foreground))", textTransform: "none", height: 36, "&:hover": { bgcolor: "hsl(var(--primary) / 0.9)" } }, children: "Remove and use Shuffle AI" })
11940
+ ] })
11941
+ ] })
11942
+ ] });
11943
+ };
11944
+ var LocalLLMConfig_default = LocalLLMConfig;
11945
+
11946
+ // components/AgentRunDrawer.tsx
11947
+ import { jsx as jsx23, jsxs as jsxs20 } from "react/jsx-runtime";
11470
11948
  var TAB_ORDER = ["run", "permissions", "localLLM"];
11471
11949
  var AgentRunDrawer = ({
11472
11950
  open,
@@ -11486,32 +11964,62 @@ var AgentRunDrawer = ({
11486
11964
  headerSx,
11487
11965
  tabsSx,
11488
11966
  bodySx,
11489
- globalUrl
11967
+ globalUrl,
11968
+ theme,
11969
+ colorMode,
11970
+ userdata,
11971
+ isLoaded,
11972
+ isLoggedIn,
11973
+ serverside
11490
11974
  }) => {
11491
11975
  useSyncHostBaseUrl(globalUrl);
11492
11976
  const themeScope = useShuffleMcpTheme();
11493
- const [activeTab, setActiveTab] = useState13(initialTab);
11494
- const prevOpenRef = useRef9(open);
11495
- useEffect12(() => {
11977
+ const [activeTab, setActiveTab] = useState14(initialTab);
11978
+ const prevOpenRef = useRef10(open);
11979
+ useEffect13(() => {
11496
11980
  if (open && !prevOpenRef.current) setActiveTab(initialTab);
11497
11981
  prevOpenRef.current = open;
11498
11982
  }, [open, initialTab]);
11499
- useEffect12(() => {
11983
+ useEffect13(() => {
11500
11984
  if (typeof window === "undefined") return;
11501
11985
  window.__shuffleAgentDrawerMounted = (window.__shuffleAgentDrawerMounted || 0) + 1;
11502
11986
  return () => {
11503
11987
  window.__shuffleAgentDrawerMounted = Math.max(0, (window.__shuffleAgentDrawerMounted || 1) - 1);
11504
11988
  };
11505
11989
  }, []);
11990
+ useEffect13(() => {
11991
+ if (typeof window === "undefined") return;
11992
+ const onOpen = (event) => {
11993
+ const tab = event.detail?.tab;
11994
+ if (tab === "localLLM") {
11995
+ event.preventDefault();
11996
+ setActiveTab("localLLM");
11997
+ }
11998
+ };
11999
+ window.addEventListener("agent-drawer-open", onOpen);
12000
+ return () => window.removeEventListener("agent-drawer-open", onOpen);
12001
+ }, []);
12002
+ const effectiveLocalLLMSlot = localLLMSlot ?? /* @__PURE__ */ jsx23(
12003
+ LocalLLMConfig_default,
12004
+ {
12005
+ globalUrl,
12006
+ userdata,
12007
+ isLoaded,
12008
+ isLoggedIn,
12009
+ serverside,
12010
+ theme,
12011
+ colorMode
12012
+ }
12013
+ );
11506
12014
  const visibleTabs = TAB_ORDER.filter((t) => {
11507
12015
  if (t === "run") return true;
11508
12016
  if (t === "permissions") return !!permissionsSlot;
11509
- if (t === "localLLM") return !!localLLMSlot;
12017
+ if (t === "localLLM") return !!effectiveLocalLLMSlot;
11510
12018
  return false;
11511
12019
  });
11512
12020
  const showTabs = visibleTabs.length > 1;
11513
12021
  const safeActiveTab = visibleTabs.includes(activeTab) ? activeTab : "run";
11514
- return /* @__PURE__ */ jsxs18(
12022
+ return /* @__PURE__ */ jsxs20(
11515
12023
  Drawer3,
11516
12024
  {
11517
12025
  anchor: "right",
@@ -11534,8 +12042,8 @@ var AgentRunDrawer = ({
11534
12042
  }
11535
12043
  },
11536
12044
  children: [
11537
- /* @__PURE__ */ jsxs18(
11538
- Box15,
12045
+ /* @__PURE__ */ jsxs20(
12046
+ Box17,
11539
12047
  {
11540
12048
  sx: [
11541
12049
  {
@@ -11550,8 +12058,8 @@ var AgentRunDrawer = ({
11550
12058
  ...Array.isArray(headerSx) ? headerSx : headerSx ? [headerSx] : []
11551
12059
  ],
11552
12060
  children: [
11553
- /* @__PURE__ */ jsx21(
11554
- Box15,
12061
+ /* @__PURE__ */ jsx23(
12062
+ Box17,
11555
12063
  {
11556
12064
  sx: {
11557
12065
  width: 40,
@@ -11564,18 +12072,18 @@ var AgentRunDrawer = ({
11564
12072
  color: "hsl(var(--primary))",
11565
12073
  flexShrink: 0
11566
12074
  },
11567
- children: /* @__PURE__ */ jsx21(AgentIcon_default, { size: 22 })
12075
+ children: /* @__PURE__ */ jsx23(AgentIcon_default, { size: 22 })
11568
12076
  }
11569
12077
  ),
11570
- /* @__PURE__ */ jsxs18(Box15, { sx: { flex: 1, minWidth: 0 }, children: [
11571
- /* @__PURE__ */ jsx21(Typography14, { sx: { fontWeight: 600, fontSize: "1.1rem", color: "hsl(var(--foreground))" }, children: title }),
11572
- /* @__PURE__ */ jsx21(Typography14, { sx: { fontSize: "0.8rem", color: "hsl(var(--muted-foreground))" }, children: subtitle })
12078
+ /* @__PURE__ */ jsxs20(Box17, { sx: { flex: 1, minWidth: 0 }, children: [
12079
+ /* @__PURE__ */ jsx23(Typography16, { sx: { fontWeight: 600, fontSize: "1.1rem", color: "hsl(var(--foreground))" }, children: title }),
12080
+ /* @__PURE__ */ jsx23(Typography16, { sx: { fontSize: "0.8rem", color: "hsl(var(--muted-foreground))" }, children: subtitle })
11573
12081
  ] }),
11574
- /* @__PURE__ */ jsx21(IconButton9, { onClick: onClose, size: "small", sx: { color: "hsl(var(--muted-foreground))" }, children: /* @__PURE__ */ jsx21(CloseIcon6, { size: 16 }) })
12082
+ /* @__PURE__ */ jsx23(IconButton9, { onClick: onClose, size: "small", sx: { color: "hsl(var(--muted-foreground))" }, children: /* @__PURE__ */ jsx23(CloseIcon6, { size: 16 }) })
11575
12083
  ]
11576
12084
  }
11577
12085
  ),
11578
- showTabs && /* @__PURE__ */ jsx21(Box15, { sx: { borderBottom: "1px solid hsl(var(--border))", flexShrink: 0 }, children: /* @__PURE__ */ jsxs18(
12086
+ showTabs && /* @__PURE__ */ jsx23(Box17, { sx: { borderBottom: "1px solid hsl(var(--border))", flexShrink: 0 }, children: /* @__PURE__ */ jsxs20(
11579
12087
  Tabs,
11580
12088
  {
11581
12089
  value: safeActiveTab,
@@ -11597,36 +12105,36 @@ var AgentRunDrawer = ({
11597
12105
  ...Array.isArray(tabsSx) ? tabsSx : tabsSx ? [tabsSx] : []
11598
12106
  ],
11599
12107
  children: [
11600
- visibleTabs.includes("run") && /* @__PURE__ */ jsx21(
12108
+ visibleTabs.includes("run") && /* @__PURE__ */ jsx23(
11601
12109
  Tab,
11602
12110
  {
11603
12111
  value: "run",
11604
12112
  label: "Run",
11605
- icon: /* @__PURE__ */ jsx21(Play, { size: 14 }),
12113
+ icon: /* @__PURE__ */ jsx23(Play, { size: 14 }),
11606
12114
  iconPosition: "start",
11607
12115
  sx: { gap: 0.75 }
11608
12116
  }
11609
12117
  ),
11610
- visibleTabs.includes("permissions") && /* @__PURE__ */ jsx21(
12118
+ visibleTabs.includes("permissions") && /* @__PURE__ */ jsx23(
11611
12119
  Tab,
11612
12120
  {
11613
12121
  value: "permissions",
11614
- label: permissionsDisabled ? /* @__PURE__ */ jsx21(Tooltip10, { title: permissionsDisabledTooltip, arrow: true, children: /* @__PURE__ */ jsx21(Box15, { component: "span", sx: { display: "inline-flex", alignItems: "center" }, children: "Permissions" }) }) : "Permissions",
11615
- icon: /* @__PURE__ */ jsx21(ShieldCheck, { size: 14 }),
12122
+ label: permissionsDisabled ? /* @__PURE__ */ jsx23(Tooltip11, { title: permissionsDisabledTooltip, arrow: true, children: /* @__PURE__ */ jsx23(Box17, { component: "span", sx: { display: "inline-flex", alignItems: "center" }, children: "Permissions" }) }) : "Permissions",
12123
+ icon: /* @__PURE__ */ jsx23(ShieldCheck, { size: 14 }),
11616
12124
  iconPosition: "start",
11617
12125
  disabled: permissionsDisabled,
11618
12126
  sx: { gap: 0.75 }
11619
12127
  }
11620
12128
  ),
11621
- visibleTabs.includes("localLLM") && /* @__PURE__ */ jsx21(
12129
+ visibleTabs.includes("localLLM") && /* @__PURE__ */ jsx23(
11622
12130
  Tab,
11623
12131
  {
11624
12132
  value: "localLLM",
11625
- label: /* @__PURE__ */ jsxs18(Box15, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
12133
+ label: /* @__PURE__ */ jsxs20(Box17, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
11626
12134
  "Local LLM",
11627
12135
  localLLMTabBadge
11628
12136
  ] }),
11629
- icon: /* @__PURE__ */ jsx21(Server, { size: 14 }),
12137
+ icon: /* @__PURE__ */ jsx23(Server, { size: 14 }),
11630
12138
  iconPosition: "start",
11631
12139
  sx: { gap: 0.75 }
11632
12140
  }
@@ -11634,20 +12142,22 @@ var AgentRunDrawer = ({
11634
12142
  ]
11635
12143
  }
11636
12144
  ) }),
11637
- /* @__PURE__ */ jsxs18(Box15, { sx: [{ flex: 1, overflowY: "auto" }, ...Array.isArray(bodySx) ? bodySx : bodySx ? [bodySx] : []], children: [
11638
- safeActiveTab === "run" && /* @__PURE__ */ jsx21(Box15, { sx: { px: 2, py: 2 }, children: /* @__PURE__ */ jsx21(
12145
+ /* @__PURE__ */ jsxs20(Box17, { sx: [{ flex: 1, overflowY: "auto" }, ...Array.isArray(bodySx) ? bodySx : bodySx ? [bodySx] : []], children: [
12146
+ safeActiveTab === "run" && /* @__PURE__ */ jsx23(Box17, { sx: { px: 2, py: 2 }, children: /* @__PURE__ */ jsx23(
11639
12147
  AgentUI_default,
11640
12148
  {
11641
12149
  compact: true,
11642
12150
  hideHeroIcon: true,
11643
12151
  title: "",
11644
12152
  subtitle: null,
11645
- apiBaseUrl: globalUrl,
11646
- ...agentUIProps
12153
+ ...agentUIProps,
12154
+ apiBaseUrl: agentUIProps?.apiBaseUrl ?? globalUrl,
12155
+ theme: agentUIProps?.theme ?? theme,
12156
+ colorMode: agentUIProps?.colorMode ?? colorMode
11647
12157
  }
11648
12158
  ) }),
11649
- safeActiveTab === "permissions" && permissionsSlot && /* @__PURE__ */ jsx21(Box15, { sx: { px: 3, py: 2.5 }, children: permissionsSlot }),
11650
- safeActiveTab === "localLLM" && localLLMSlot && /* @__PURE__ */ jsx21(Box15, { sx: { px: 3, py: 2.5 }, children: localLLMSlot })
12159
+ safeActiveTab === "permissions" && permissionsSlot && /* @__PURE__ */ jsx23(Box17, { sx: { px: 3, py: 2.5 }, children: permissionsSlot }),
12160
+ safeActiveTab === "localLLM" && effectiveLocalLLMSlot && /* @__PURE__ */ jsx23(Box17, { sx: { px: 3, py: 2.5 }, children: effectiveLocalLLMSlot })
11651
12161
  ] })
11652
12162
  ]
11653
12163
  }
@@ -11656,22 +12166,22 @@ var AgentRunDrawer = ({
11656
12166
  var AgentRunDrawer_default = AgentRunDrawer;
11657
12167
 
11658
12168
  // components/AgentActivityList.tsx
11659
- import { useCallback as useCallback9, useEffect as useEffect13, useRef as useRef10, useState as useState14 } from "react";
12169
+ import { useCallback as useCallback9, useEffect as useEffect14, useRef as useRef11, useState as useState15 } from "react";
11660
12170
  import {
11661
- Box as Box16,
11662
- Button as Button9,
12171
+ Box as Box18,
12172
+ Button as Button10,
11663
12173
  Chip as Chip8,
11664
12174
  CircularProgress as CircularProgress5,
11665
- Dialog as Dialog2,
11666
- DialogActions,
11667
- DialogContent as DialogContent2,
11668
- DialogTitle as DialogTitle2,
12175
+ Dialog as Dialog3,
12176
+ DialogActions as DialogActions2,
12177
+ DialogContent as DialogContent3,
12178
+ DialogTitle as DialogTitle3,
11669
12179
  InputAdornment,
11670
12180
  MenuItem as MenuItem3,
11671
12181
  Select as Select3,
11672
- TextField as TextField6,
11673
- Tooltip as Tooltip11,
11674
- Typography as Typography15
12182
+ TextField as TextField7,
12183
+ Tooltip as Tooltip12,
12184
+ Typography as Typography17
11675
12185
  } from "@mui/material";
11676
12186
  import {
11677
12187
  Activity,
@@ -11694,6 +12204,21 @@ var resolveHeaders = (apiKey, orgId) => {
11694
12204
  if (orgId) h["Org-Id"] = orgId;
11695
12205
  return h;
11696
12206
  };
12207
+ var uuid = () => {
12208
+ if (typeof crypto !== "undefined" && "randomUUID" in crypto) return crypto.randomUUID();
12209
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
12210
+ const r = Math.random() * 16 | 0;
12211
+ const v = c === "x" ? r : r & 3 | 8;
12212
+ return v.toString(16);
12213
+ });
12214
+ };
12215
+ var buildAppNameValue = (apps = []) => apps.filter((a) => !!a?.name).map((a) => a.name).join(",");
12216
+ var buildScheduleName = (input) => {
12217
+ const prompt = (input || "").trim();
12218
+ const words = prompt.replace(/[^a-zA-Z0-9\s-]/g, " ").split(/\s+/).filter(Boolean).slice(0, 6);
12219
+ const title = words.length ? words.map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(" ") : "Scheduled Agent Run";
12220
+ return { name: title.slice(0, 80), description: (prompt || "Scheduled Agent Run").slice(0, 240) };
12221
+ };
11697
12222
  var searchAgentActivity = async (params = {}) => {
11698
12223
  const {
11699
12224
  cursor = "",
@@ -11749,6 +12274,127 @@ var listAgentScheduleWorkflows = async (params = {}) => {
11749
12274
  const list = Array.isArray(data) ? data : data?.workflows || [];
11750
12275
  return list.filter((w) => w && w.workflow_type === "AGENT_SCHEDULE").map((w) => ({ id: w.id || w._id, name: w.name || "Untitled", description: w.description }));
11751
12276
  };
12277
+ var scheduleAgentRun = async ({ cron, input, apps = [], onStep, apiKey, apiBaseUrl, orgId }) => {
12278
+ const headers = { "Content-Type": "application/json", ...resolveHeaders(apiKey, orgId) };
12279
+ const step = (id, state, detail) => {
12280
+ try {
12281
+ onStep?.({ id, state, detail });
12282
+ } catch {
12283
+ }
12284
+ };
12285
+ step("name", "active");
12286
+ const { name, description } = buildScheduleName(input);
12287
+ step("name", "done", name);
12288
+ step("workflow", "active");
12289
+ const createRes = await fetch(resolveUrl("/api/v1/workflows", apiBaseUrl), {
12290
+ method: "POST",
12291
+ credentials: "include",
12292
+ headers,
12293
+ body: JSON.stringify({ name, description })
12294
+ });
12295
+ if (!createRes.ok) {
12296
+ step("workflow", "error", `HTTP ${createRes.status}`);
12297
+ throw new Error(`Create workflow failed (${createRes.status})`);
12298
+ }
12299
+ const created = await createRes.json();
12300
+ const workflowId = created.id || created._id || created.workflow_id;
12301
+ if (!workflowId) {
12302
+ step("workflow", "error", "no id returned");
12303
+ throw new Error("Workflow created but no id returned");
12304
+ }
12305
+ const triggerId = uuid();
12306
+ const actionId = uuid();
12307
+ const branchId = uuid();
12308
+ const trigger = {
12309
+ app_name: "Schedule",
12310
+ app_version: "1.0.0",
12311
+ environment: "cloud",
12312
+ id_: triggerId,
12313
+ _id_: triggerId,
12314
+ id: triggerId,
12315
+ finished: true,
12316
+ label: name,
12317
+ type: "TRIGGER",
12318
+ is_valid: true,
12319
+ trigger_type: "SCHEDULE",
12320
+ status: "running",
12321
+ name: "Schedule",
12322
+ parameters: [{ name: "cron", example: "", value: cron }, { name: "execution_argument", example: "", value: "" }],
12323
+ position: { x: 254, y: 617 },
12324
+ flowOrientation: "horizontal"
12325
+ };
12326
+ const action = {
12327
+ name: "Run LLM",
12328
+ label: "AI_Agent_1",
12329
+ app_name: "AI Agent",
12330
+ app_version: "1.0.0",
12331
+ app_id: "shuffle_agent",
12332
+ description: "Run an LLM query against any tool you want",
12333
+ environment: "Cloud",
12334
+ errors: [],
12335
+ id_: actionId,
12336
+ _id_: actionId,
12337
+ id: actionId,
12338
+ is_valid: true,
12339
+ type: "ACTION",
12340
+ isStartNode: true,
12341
+ run_magic_output: false,
12342
+ authentication: [],
12343
+ example: "",
12344
+ category: "",
12345
+ authentication_id: "",
12346
+ template: false,
12347
+ finished: true,
12348
+ flowOrientation: "horizontal",
12349
+ position: { x: 517, y: 370 },
12350
+ selectedAuthentication: {},
12351
+ circleId: uuid(),
12352
+ execution_delay: 0,
12353
+ parameters: [
12354
+ { name: "app_name", value: buildAppNameValue(apps), required: true, description: "Comma-separated list of app names the agent is allowed to use." },
12355
+ { name: "input", value: input, required: true, multiline: true, description: "The input data for the LLM query" }
12356
+ ]
12357
+ };
12358
+ const updated = { ...created, id: workflowId, name, description, start: actionId, workflow_type: "AGENT_SCHEDULE", actions: [action], triggers: [trigger], branches: [{ source_id: triggerId, destination_id: actionId, id: branchId }] };
12359
+ const putRes = await fetch(resolveUrl(`/api/v1/workflows/${workflowId}`, apiBaseUrl), {
12360
+ method: "PUT",
12361
+ credentials: "include",
12362
+ headers,
12363
+ body: JSON.stringify(updated)
12364
+ });
12365
+ if (!putRes.ok) {
12366
+ step("workflow", "error", `HTTP ${putRes.status}`);
12367
+ throw new Error(`Update workflow failed (${putRes.status})`);
12368
+ }
12369
+ step("workflow", "done", name);
12370
+ step("schedule", "active");
12371
+ const schedRes = await fetch(resolveUrl(`/api/v1/workflows/${workflowId}/schedule`, apiBaseUrl), {
12372
+ method: "POST",
12373
+ credentials: "include",
12374
+ headers,
12375
+ body: JSON.stringify({
12376
+ name: "Schedule",
12377
+ frequency: cron,
12378
+ cron,
12379
+ execution_argument: "",
12380
+ environment: "cloud",
12381
+ id: triggerId,
12382
+ start: actionId,
12383
+ parameters: [{ name: "cron", value: cron }, { name: "execution_argument", value: "" }]
12384
+ })
12385
+ }).catch(async (err) => {
12386
+ await fetch(resolveUrl(`/api/v1/workflows/${workflowId}`, apiBaseUrl), { method: "DELETE", credentials: "include", headers: resolveHeaders(apiKey, orgId) }).catch(() => void 0);
12387
+ throw err;
12388
+ });
12389
+ if (!schedRes.ok) {
12390
+ const errText = await schedRes.text().catch(() => "");
12391
+ await fetch(resolveUrl(`/api/v1/workflows/${workflowId}`, apiBaseUrl), { method: "DELETE", credentials: "include", headers: resolveHeaders(apiKey, orgId) }).catch(() => void 0);
12392
+ step("schedule", "error", `HTTP ${schedRes.status}`);
12393
+ throw new Error(`Scheduler rejected the cron \`${cron}\` (HTTP ${schedRes.status})${errText ? `: ${errText}` : ""}. The workflow has been deleted.`);
12394
+ }
12395
+ step("schedule", "done", cron);
12396
+ return { workflowId, name, cron };
12397
+ };
11752
12398
  var findAgentInputParam = (workflow) => {
11753
12399
  const actions = workflow?.actions || [];
11754
12400
  for (const a of actions) {
@@ -11838,16 +12484,16 @@ var stopAgentSchedule = async (workflowId, params = {}) => {
11838
12484
 
11839
12485
  // components/AgentActivityList.tsx
11840
12486
  import { Pencil, StopCircle, AlertTriangle as AlertTriangle2 } from "lucide-react";
11841
- import { Fragment as Fragment8, jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
12487
+ import { Fragment as Fragment8, jsx as jsx24, jsxs as jsxs21 } from "react/jsx-runtime";
11842
12488
  var STATUS_CONFIG = {
11843
- FINISHED: { icon: /* @__PURE__ */ jsx22(CheckCircle, { size: 16 }), color: "hsl(var(--severity-low, 142 71% 45%))", label: "Completed" },
11844
- SUCCESS: { icon: /* @__PURE__ */ jsx22(CheckCircle, { size: 16 }), color: "hsl(var(--severity-low, 142 71% 45%))", label: "Completed" },
11845
- FAILED: { icon: /* @__PURE__ */ jsx22(XCircle, { size: 16 }), color: "hsl(var(--severity-critical, 0 72% 55%))", label: "Failed" },
11846
- ABORTED: { icon: /* @__PURE__ */ jsx22(XCircle, { size: 16 }), color: "hsl(var(--severity-critical, 0 72% 55%))", label: "Aborted" },
11847
- EXECUTING: { icon: /* @__PURE__ */ jsx22(Loader2, { size: 16 }), color: "hsl(var(--severity-medium, 38 92% 50%))", label: "Running" },
11848
- RUNNING: { icon: /* @__PURE__ */ jsx22(Loader2, { size: 16 }), color: "hsl(var(--severity-medium, 38 92% 50%))", label: "Running" },
11849
- WAITING: { icon: /* @__PURE__ */ jsx22(Clock, { size: 16 }), color: "hsl(var(--severity-info, 217 91% 60%))", label: "Waiting" },
11850
- LIMIT_REACHED: { icon: /* @__PURE__ */ jsx22(AlertTriangle2, { size: 16 }), color: "hsl(var(--severity-medium, 38 92% 50%))", label: "Limit reached" }
12489
+ FINISHED: { icon: /* @__PURE__ */ jsx24(CheckCircle, { size: 16 }), color: "hsl(var(--severity-low, 142 71% 45%))", label: "Completed" },
12490
+ SUCCESS: { icon: /* @__PURE__ */ jsx24(CheckCircle, { size: 16 }), color: "hsl(var(--severity-low, 142 71% 45%))", label: "Completed" },
12491
+ FAILED: { icon: /* @__PURE__ */ jsx24(XCircle, { size: 16 }), color: "hsl(var(--severity-critical, 0 72% 55%))", label: "Failed" },
12492
+ ABORTED: { icon: /* @__PURE__ */ jsx24(XCircle, { size: 16 }), color: "hsl(var(--severity-critical, 0 72% 55%))", label: "Aborted" },
12493
+ EXECUTING: { icon: /* @__PURE__ */ jsx24(Loader2, { size: 16 }), color: "hsl(var(--severity-medium, 38 92% 50%))", label: "Running" },
12494
+ RUNNING: { icon: /* @__PURE__ */ jsx24(Loader2, { size: 16 }), color: "hsl(var(--severity-medium, 38 92% 50%))", label: "Running" },
12495
+ WAITING: { icon: /* @__PURE__ */ jsx24(Clock, { size: 16 }), color: "hsl(var(--severity-info, 217 91% 60%))", label: "Waiting" },
12496
+ LIMIT_REACHED: { icon: /* @__PURE__ */ jsx24(AlertTriangle2, { size: 16 }), color: "hsl(var(--severity-medium, 38 92% 50%))", label: "Limit reached" }
11851
12497
  };
11852
12498
  var getEffectiveStatus = (run) => {
11853
12499
  const raw = (run.status || "").toUpperCase();
@@ -11863,12 +12509,12 @@ var getEffectiveStatus = (run) => {
11863
12509
  var getRunIcon = (run) => {
11864
12510
  const src = (run.execution_source || "").toLowerCase();
11865
12511
  const arg = (run.execution_argument || "").toLowerCase();
11866
- if (src.includes("schedule") || src.includes("cron")) return /* @__PURE__ */ jsx22(Clock, { size: 18 });
11867
- if (src.includes("webhook") || src.includes("http")) return /* @__PURE__ */ jsx22(Globe, { size: 18 });
11868
- if (arg.includes("alert") || arg.includes("detect")) return /* @__PURE__ */ jsx22(Activity, { size: 18 });
11869
- if (arg.includes("report") || arg.includes("email")) return /* @__PURE__ */ jsx22(FileText, { size: 18 });
11870
- if (arg.includes("endpoint") || arg.includes("server")) return /* @__PURE__ */ jsx22(Server2, { size: 18 });
11871
- return /* @__PURE__ */ jsx22(Zap, { size: 18 });
12512
+ if (src.includes("schedule") || src.includes("cron")) return /* @__PURE__ */ jsx24(Clock, { size: 18 });
12513
+ if (src.includes("webhook") || src.includes("http")) return /* @__PURE__ */ jsx24(Globe, { size: 18 });
12514
+ if (arg.includes("alert") || arg.includes("detect")) return /* @__PURE__ */ jsx24(Activity, { size: 18 });
12515
+ if (arg.includes("report") || arg.includes("email")) return /* @__PURE__ */ jsx24(FileText, { size: 18 });
12516
+ if (arg.includes("endpoint") || arg.includes("server")) return /* @__PURE__ */ jsx24(Server2, { size: 18 });
12517
+ return /* @__PURE__ */ jsx24(Zap, { size: 18 });
11872
12518
  };
11873
12519
  var getRunIconColor = (run) => {
11874
12520
  const status = getEffectiveStatus(run);
@@ -11962,8 +12608,8 @@ var AgentRunRow = ({ run, onClick, sx }) => {
11962
12608
  const iconColor = getRunIconColor(run);
11963
12609
  const duration = formatDuration(run);
11964
12610
  const tools = getRunTools(run);
11965
- return /* @__PURE__ */ jsxs19(
11966
- Box16,
12611
+ return /* @__PURE__ */ jsxs21(
12612
+ Box18,
11967
12613
  {
11968
12614
  onClick,
11969
12615
  sx: [
@@ -11986,8 +12632,8 @@ var AgentRunRow = ({ run, onClick, sx }) => {
11986
12632
  ...Array.isArray(sx) ? sx : sx ? [sx] : []
11987
12633
  ],
11988
12634
  children: [
11989
- /* @__PURE__ */ jsx22(
11990
- Box16,
12635
+ /* @__PURE__ */ jsx24(
12636
+ Box18,
11991
12637
  {
11992
12638
  sx: {
11993
12639
  width: 40,
@@ -12003,10 +12649,10 @@ var AgentRunRow = ({ run, onClick, sx }) => {
12003
12649
  children: getRunIcon(run)
12004
12650
  }
12005
12651
  ),
12006
- /* @__PURE__ */ jsxs19(Box16, { sx: { flex: 1, minWidth: 0 }, children: [
12007
- /* @__PURE__ */ jsxs19(Box16, { sx: { display: "flex", alignItems: "center", gap: 1, mb: 0.25 }, children: [
12008
- /* @__PURE__ */ jsx22(
12009
- Typography15,
12652
+ /* @__PURE__ */ jsxs21(Box18, { sx: { flex: 1, minWidth: 0 }, children: [
12653
+ /* @__PURE__ */ jsxs21(Box18, { sx: { display: "flex", alignItems: "center", gap: 1, mb: 0.25 }, children: [
12654
+ /* @__PURE__ */ jsx24(
12655
+ Typography17,
12010
12656
  {
12011
12657
  sx: {
12012
12658
  fontSize: "0.9rem",
@@ -12019,10 +12665,10 @@ var AgentRunRow = ({ run, onClick, sx }) => {
12019
12665
  children: getRunTitle(run)
12020
12666
  }
12021
12667
  ),
12022
- /* @__PURE__ */ jsx22(Box16, { sx: { display: "flex", alignItems: "center", color: cfg.color, flexShrink: 0 }, children: cfg.icon })
12668
+ /* @__PURE__ */ jsx24(Box18, { sx: { display: "flex", alignItems: "center", color: cfg.color, flexShrink: 0 }, children: cfg.icon })
12023
12669
  ] }),
12024
- /* @__PURE__ */ jsx22(
12025
- Typography15,
12670
+ /* @__PURE__ */ jsx24(
12671
+ Typography17,
12026
12672
  {
12027
12673
  sx: {
12028
12674
  fontSize: "0.78rem",
@@ -12034,16 +12680,16 @@ var AgentRunRow = ({ run, onClick, sx }) => {
12034
12680
  children: getRunSubtitle(run)
12035
12681
  }
12036
12682
  ),
12037
- /* @__PURE__ */ jsxs19(Box16, { sx: { display: "flex", alignItems: "center", gap: 1, mt: 0.5 }, children: [
12038
- /* @__PURE__ */ jsx22(Typography15, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.7 }, children: run.started_at ? getTimeAgo(run.started_at) : "\u2014" }),
12039
- duration && /* @__PURE__ */ jsxs19(Fragment8, { children: [
12040
- /* @__PURE__ */ jsx22(Typography15, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
12041
- /* @__PURE__ */ jsx22(Typography15, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.7 }, children: duration })
12683
+ /* @__PURE__ */ jsxs21(Box18, { sx: { display: "flex", alignItems: "center", gap: 1, mt: 0.5 }, children: [
12684
+ /* @__PURE__ */ jsx24(Typography17, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.7 }, children: run.started_at ? getTimeAgo(run.started_at) : "\u2014" }),
12685
+ duration && /* @__PURE__ */ jsxs21(Fragment8, { children: [
12686
+ /* @__PURE__ */ jsx24(Typography17, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
12687
+ /* @__PURE__ */ jsx24(Typography17, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.7 }, children: duration })
12042
12688
  ] })
12043
12689
  ] })
12044
12690
  ] }),
12045
- tools.length > 0 && /* @__PURE__ */ jsx22(
12046
- Box16,
12691
+ tools.length > 0 && /* @__PURE__ */ jsx24(
12692
+ Box18,
12047
12693
  {
12048
12694
  sx: {
12049
12695
  display: { xs: "none", sm: "flex" },
@@ -12054,7 +12700,7 @@ var AgentRunRow = ({ run, onClick, sx }) => {
12054
12700
  maxWidth: 220,
12055
12701
  flexShrink: 0
12056
12702
  },
12057
- children: tools.map((t) => /* @__PURE__ */ jsx22(Tooltip11, { title: t, arrow: true, children: /* @__PURE__ */ jsx22(
12703
+ children: tools.map((t) => /* @__PURE__ */ jsx24(Tooltip12, { title: t, arrow: true, children: /* @__PURE__ */ jsx24(
12058
12704
  Chip8,
12059
12705
  {
12060
12706
  label: t,
@@ -12103,19 +12749,19 @@ var AgentActivityList = ({
12103
12749
  toolbarSx,
12104
12750
  rowSx
12105
12751
  }) => {
12106
- const [runs, setRuns] = useState14([]);
12107
- const [cursor, setCursor] = useState14("");
12108
- const [hasMore, setHasMore] = useState14(false);
12109
- const [isLoading, setIsLoading] = useState14(false);
12110
- const [error, setError] = useState14(null);
12111
- const [statusFilter, setStatusFilter] = useState14("");
12112
- const [searchQuery, setSearchQuery] = useState14("");
12113
- const [debouncedQuery, setDebouncedQuery] = useState14("");
12114
- const [agentWorkflows, setAgentWorkflows] = useState14([]);
12115
- const [workflowFilter, setWorkflowFilter] = useState14("");
12116
- const [stopOpen, setStopOpen] = useState14(false);
12117
- const [stopLoading, setStopLoading] = useState14(false);
12118
- const debounceRef = useRef10();
12752
+ const [runs, setRuns] = useState15([]);
12753
+ const [cursor, setCursor] = useState15("");
12754
+ const [hasMore, setHasMore] = useState15(false);
12755
+ const [isLoading, setIsLoading] = useState15(false);
12756
+ const [error, setError] = useState15(null);
12757
+ const [statusFilter, setStatusFilter] = useState15("");
12758
+ const [searchQuery, setSearchQuery] = useState15("");
12759
+ const [debouncedQuery, setDebouncedQuery] = useState15("");
12760
+ const [agentWorkflows, setAgentWorkflows] = useState15([]);
12761
+ const [workflowFilter, setWorkflowFilter] = useState15("");
12762
+ const [stopOpen, setStopOpen] = useState15(false);
12763
+ const [stopLoading, setStopLoading] = useState15(false);
12764
+ const debounceRef = useRef11();
12119
12765
  const selectedAgentWorkflow = agentWorkflows.find((w) => w.id === workflowFilter) || null;
12120
12766
  const openEditPrompt = useCallback9(async () => {
12121
12767
  if (!workflowFilter) return;
@@ -12151,7 +12797,7 @@ var AgentActivityList = ({
12151
12797
  if (debounceRef.current) clearTimeout(debounceRef.current);
12152
12798
  debounceRef.current = setTimeout(() => setDebouncedQuery(q), 350);
12153
12799
  }, []);
12154
- useEffect13(() => () => {
12800
+ useEffect14(() => () => {
12155
12801
  if (debounceRef.current) clearTimeout(debounceRef.current);
12156
12802
  }, []);
12157
12803
  const fetchRuns = useCallback9(
@@ -12183,10 +12829,10 @@ var AgentActivityList = ({
12183
12829
  },
12184
12830
  [statusFilter, limit, apiKey, apiBaseUrl, orgId, workflowFilter]
12185
12831
  );
12186
- useEffect13(() => {
12832
+ useEffect14(() => {
12187
12833
  fetchRuns(false, "");
12188
12834
  }, [statusFilter, apiKey, apiBaseUrl, orgId, workflowFilter]);
12189
- useEffect13(() => {
12835
+ useEffect14(() => {
12190
12836
  let cancelled = false;
12191
12837
  listAgentScheduleWorkflows({ apiKey, apiBaseUrl, orgId }).then((items) => {
12192
12838
  if (!cancelled) setAgentWorkflows(items);
@@ -12209,14 +12855,14 @@ var AgentActivityList = ({
12209
12855
  ].filter(Boolean).join(" ").toLowerCase();
12210
12856
  return hay.includes(debouncedQuery.toLowerCase());
12211
12857
  }) : runs;
12212
- return /* @__PURE__ */ jsxs19(
12213
- Box16,
12858
+ return /* @__PURE__ */ jsxs21(
12859
+ Box18,
12214
12860
  {
12215
12861
  className,
12216
12862
  sx: [{ display: "flex", flexDirection: "column", gap: 2 }, ...Array.isArray(sx) ? sx : sx ? [sx] : []],
12217
12863
  children: [
12218
- (showSearchBar || showStatusChips) && /* @__PURE__ */ jsxs19(Box16, { sx: [{ display: "flex", alignItems: "center", justifyContent: "center", gap: 1.5, flexWrap: "wrap" }, ...Array.isArray(toolbarSx) ? toolbarSx : toolbarSx ? [toolbarSx] : []], children: [
12219
- /* @__PURE__ */ jsxs19(
12864
+ (showSearchBar || showStatusChips) && /* @__PURE__ */ jsxs21(Box18, { sx: [{ display: "flex", alignItems: "center", justifyContent: "center", gap: 1.5, flexWrap: "wrap" }, ...Array.isArray(toolbarSx) ? toolbarSx : toolbarSx ? [toolbarSx] : []], children: [
12865
+ /* @__PURE__ */ jsxs21(
12220
12866
  Select3,
12221
12867
  {
12222
12868
  size: "small",
@@ -12253,13 +12899,13 @@ var AgentActivityList = ({
12253
12899
  }
12254
12900
  },
12255
12901
  children: [
12256
- /* @__PURE__ */ jsx22(MenuItem3, { value: "", sx: { fontSize: "0.85rem" }, children: "All Agent runs" }),
12257
- agentWorkflows.map((w) => /* @__PURE__ */ jsx22(MenuItem3, { value: w.id, sx: { fontSize: "0.85rem" }, children: w.name }, w.id))
12902
+ /* @__PURE__ */ jsx24(MenuItem3, { value: "", sx: { fontSize: "0.85rem" }, children: "All Agent runs" }),
12903
+ agentWorkflows.map((w) => /* @__PURE__ */ jsx24(MenuItem3, { value: w.id, sx: { fontSize: "0.85rem" }, children: w.name }, w.id))
12258
12904
  ]
12259
12905
  }
12260
12906
  ),
12261
- showSearchBar && /* @__PURE__ */ jsx22(
12262
- TextField6,
12907
+ showSearchBar && /* @__PURE__ */ jsx24(
12908
+ TextField7,
12263
12909
  {
12264
12910
  placeholder: "Search results...",
12265
12911
  size: "small",
@@ -12267,7 +12913,7 @@ var AgentActivityList = ({
12267
12913
  onChange: (e) => updateSearchQuery(e.target.value),
12268
12914
  slotProps: {
12269
12915
  input: {
12270
- startAdornment: /* @__PURE__ */ jsx22(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx22(SearchIcon, { size: 18, color: "hsl(var(--muted-foreground))" }) })
12916
+ startAdornment: /* @__PURE__ */ jsx24(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx24(SearchIcon, { size: 18, color: "hsl(var(--muted-foreground))" }) })
12271
12917
  }
12272
12918
  },
12273
12919
  sx: {
@@ -12287,7 +12933,7 @@ var AgentActivityList = ({
12287
12933
  }
12288
12934
  }
12289
12935
  ),
12290
- showStatusChips && /* @__PURE__ */ jsx22(
12936
+ showStatusChips && /* @__PURE__ */ jsx24(
12291
12937
  SegmentedControl,
12292
12938
  {
12293
12939
  size: "sm",
@@ -12297,10 +12943,10 @@ var AgentActivityList = ({
12297
12943
  options: STATUS_FILTERS.map((f) => ({ value: f.value, label: f.label }))
12298
12944
  }
12299
12945
  ),
12300
- isLoading && runs.length > 0 && /* @__PURE__ */ jsx22(CircularProgress5, { size: 16, sx: { color: "hsl(var(--primary))", ml: 0.5 } })
12946
+ isLoading && runs.length > 0 && /* @__PURE__ */ jsx24(CircularProgress5, { size: 16, sx: { color: "hsl(var(--primary))", ml: 0.5 } })
12301
12947
  ] }),
12302
- selectedAgentWorkflow && /* @__PURE__ */ jsxs19(
12303
- Box16,
12948
+ selectedAgentWorkflow && /* @__PURE__ */ jsxs21(
12949
+ Box18,
12304
12950
  {
12305
12951
  sx: {
12306
12952
  display: "flex",
@@ -12312,15 +12958,15 @@ var AgentActivityList = ({
12312
12958
  bgcolor: "hsl(var(--card))"
12313
12959
  },
12314
12960
  children: [
12315
- /* @__PURE__ */ jsxs19(Box16, { sx: { flex: 1, minWidth: 0 }, children: [
12316
- /* @__PURE__ */ jsx22(Typography15, { sx: { fontSize: "0.85rem", fontWeight: 600, color: "hsl(var(--foreground))", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: selectedAgentWorkflow.name }),
12317
- selectedAgentWorkflow.description && /* @__PURE__ */ jsx22(Typography15, { sx: { fontSize: "0.75rem", color: "hsl(var(--muted-foreground))", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: selectedAgentWorkflow.description })
12961
+ /* @__PURE__ */ jsxs21(Box18, { sx: { flex: 1, minWidth: 0 }, children: [
12962
+ /* @__PURE__ */ jsx24(Typography17, { sx: { fontSize: "0.85rem", fontWeight: 600, color: "hsl(var(--foreground))", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: selectedAgentWorkflow.name }),
12963
+ selectedAgentWorkflow.description && /* @__PURE__ */ jsx24(Typography17, { sx: { fontSize: "0.75rem", color: "hsl(var(--muted-foreground))", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: selectedAgentWorkflow.description })
12318
12964
  ] }),
12319
- /* @__PURE__ */ jsx22(
12320
- Button9,
12965
+ /* @__PURE__ */ jsx24(
12966
+ Button10,
12321
12967
  {
12322
12968
  size: "small",
12323
- startIcon: /* @__PURE__ */ jsx22(Pencil, { size: 14 }),
12969
+ startIcon: /* @__PURE__ */ jsx24(Pencil, { size: 14 }),
12324
12970
  onClick: openEditPrompt,
12325
12971
  sx: {
12326
12972
  height: 36,
@@ -12335,11 +12981,11 @@ var AgentActivityList = ({
12335
12981
  children: "Edit"
12336
12982
  }
12337
12983
  ),
12338
- /* @__PURE__ */ jsx22(
12339
- Button9,
12984
+ /* @__PURE__ */ jsx24(
12985
+ Button10,
12340
12986
  {
12341
12987
  size: "small",
12342
- startIcon: /* @__PURE__ */ jsx22(StopCircle, { size: 14 }),
12988
+ startIcon: /* @__PURE__ */ jsx24(StopCircle, { size: 14 }),
12343
12989
  onClick: () => setStopOpen(true),
12344
12990
  sx: {
12345
12991
  height: 36,
@@ -12357,17 +13003,17 @@ var AgentActivityList = ({
12357
13003
  ]
12358
13004
  }
12359
13005
  ),
12360
- isLoading && runs.length === 0 ? /* @__PURE__ */ jsx22(Box16, { sx: { display: "flex", justifyContent: "center", py: 8 }, children: /* @__PURE__ */ jsx22(CircularProgress5, { size: 28, sx: { color: "hsl(var(--primary))" } }) }) : error ? /* @__PURE__ */ jsxs19(Box16, { sx: { display: "flex", flexDirection: "column", alignItems: "center", textAlign: "center", py: 6 }, children: [
12361
- /* @__PURE__ */ jsx22(AlertCircle, { size: 28, style: { color: "hsl(var(--severity-critical, 0 72% 55%))", marginBottom: 8 } }),
12362
- /* @__PURE__ */ jsx22(
12363
- Typography15,
13006
+ isLoading && runs.length === 0 ? /* @__PURE__ */ jsx24(Box18, { sx: { display: "flex", justifyContent: "center", py: 8 }, children: /* @__PURE__ */ jsx24(CircularProgress5, { size: 28, sx: { color: "hsl(var(--primary))" } }) }) : error ? /* @__PURE__ */ jsxs21(Box18, { sx: { display: "flex", flexDirection: "column", alignItems: "center", textAlign: "center", py: 6 }, children: [
13007
+ /* @__PURE__ */ jsx24(AlertCircle, { size: 28, style: { color: "hsl(var(--severity-critical, 0 72% 55%))", marginBottom: 8 } }),
13008
+ /* @__PURE__ */ jsx24(
13009
+ Typography17,
12364
13010
  {
12365
13011
  sx: { color: "hsl(var(--severity-critical, 0 72% 55%))", fontSize: "0.9rem", mb: 1 },
12366
13012
  children: error
12367
13013
  }
12368
13014
  ),
12369
- /* @__PURE__ */ jsx22(
12370
- Button9,
13015
+ /* @__PURE__ */ jsx24(
13016
+ Button10,
12371
13017
  {
12372
13018
  size: "small",
12373
13019
  onClick: () => fetchRuns(false, ""),
@@ -12375,24 +13021,24 @@ var AgentActivityList = ({
12375
13021
  children: "Try again"
12376
13022
  }
12377
13023
  )
12378
- ] }) : filteredRuns.length === 0 ? /* @__PURE__ */ jsxs19(Box16, { sx: { display: "flex", flexDirection: "column", alignItems: "center", textAlign: "center", py: 8 }, children: [
12379
- /* @__PURE__ */ jsx22(
13024
+ ] }) : filteredRuns.length === 0 ? /* @__PURE__ */ jsxs21(Box18, { sx: { display: "flex", flexDirection: "column", alignItems: "center", textAlign: "center", py: 8 }, children: [
13025
+ /* @__PURE__ */ jsx24(
12380
13026
  Activity,
12381
13027
  {
12382
13028
  size: 40,
12383
13029
  style: { color: "hsl(var(--muted-foreground))", marginBottom: 12 }
12384
13030
  }
12385
13031
  ),
12386
- /* @__PURE__ */ jsx22(Typography15, { sx: { color: "hsl(var(--muted-foreground))", fontSize: "0.9rem" }, children: emptyTitle }),
12387
- /* @__PURE__ */ jsx22(
12388
- Typography15,
13032
+ /* @__PURE__ */ jsx24(Typography17, { sx: { color: "hsl(var(--muted-foreground))", fontSize: "0.9rem" }, children: emptyTitle }),
13033
+ /* @__PURE__ */ jsx24(
13034
+ Typography17,
12389
13035
  {
12390
13036
  sx: { color: "hsl(var(--muted-foreground))", fontSize: "0.8rem", mt: 0.5, opacity: 0.7 },
12391
13037
  children: emptySubtitle
12392
13038
  }
12393
13039
  )
12394
- ] }) : /* @__PURE__ */ jsxs19(Box16, { sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: [
12395
- filteredRuns.map((run, idx) => /* @__PURE__ */ jsx22(
13040
+ ] }) : /* @__PURE__ */ jsxs21(Box18, { sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: [
13041
+ filteredRuns.map((run, idx) => /* @__PURE__ */ jsx24(
12396
13042
  AgentRunRow,
12397
13043
  {
12398
13044
  run,
@@ -12401,43 +13047,43 @@ var AgentActivityList = ({
12401
13047
  },
12402
13048
  run.execution_id || idx
12403
13049
  )),
12404
- hasMore && /* @__PURE__ */ jsx22(Box16, { sx: { display: "flex", justifyContent: "center", mt: 1 }, children: /* @__PURE__ */ jsxs19(
12405
- Button9,
13050
+ hasMore && /* @__PURE__ */ jsx24(Box18, { sx: { display: "flex", justifyContent: "center", mt: 1 }, children: /* @__PURE__ */ jsxs21(
13051
+ Button10,
12406
13052
  {
12407
13053
  size: "small",
12408
13054
  onClick: loadMore,
12409
13055
  disabled: isLoading,
12410
13056
  sx: { color: "hsl(var(--primary))", textTransform: "none", fontSize: "0.8rem" },
12411
13057
  children: [
12412
- isLoading ? /* @__PURE__ */ jsx22(CircularProgress5, { size: 14, sx: { mr: 1 } }) : null,
13058
+ isLoading ? /* @__PURE__ */ jsx24(CircularProgress5, { size: 14, sx: { mr: 1 } }) : null,
12413
13059
  "Load more"
12414
13060
  ]
12415
13061
  }
12416
13062
  ) })
12417
13063
  ] }),
12418
- /* @__PURE__ */ jsxs19(
12419
- Dialog2,
13064
+ /* @__PURE__ */ jsxs21(
13065
+ Dialog3,
12420
13066
  {
12421
13067
  open: stopOpen,
12422
13068
  onClose: () => stopLoading ? null : setStopOpen(false),
12423
13069
  slotProps: { paper: { sx: { bgcolor: "hsl(var(--card))", color: "hsl(var(--foreground))", border: "1px solid hsl(var(--border))" } } },
12424
13070
  children: [
12425
- /* @__PURE__ */ jsx22(DialogTitle2, { sx: { fontSize: "1rem", fontWeight: 600 }, children: "Stop schedule?" }),
12426
- /* @__PURE__ */ jsx22(DialogContent2, { children: /* @__PURE__ */ jsxs19(Typography15, { sx: { fontSize: "0.85rem", color: "hsl(var(--muted-foreground))" }, children: [
13071
+ /* @__PURE__ */ jsx24(DialogTitle3, { sx: { fontSize: "1rem", fontWeight: 600 }, children: "Stop schedule?" }),
13072
+ /* @__PURE__ */ jsx24(DialogContent3, { children: /* @__PURE__ */ jsxs21(Typography17, { sx: { fontSize: "0.85rem", color: "hsl(var(--muted-foreground))" }, children: [
12427
13073
  'This will stop "',
12428
13074
  selectedAgentWorkflow?.name,
12429
13075
  '" and delete the scheduled workflow. Past executions remain visible. This cannot be undone.'
12430
13076
  ] }) }),
12431
- /* @__PURE__ */ jsxs19(DialogActions, { sx: { px: 3, pb: 2 }, children: [
12432
- /* @__PURE__ */ jsx22(Button9, { onClick: () => setStopOpen(false), disabled: stopLoading, sx: { textTransform: "none", color: "hsl(var(--muted-foreground))" }, children: "Cancel" }),
12433
- /* @__PURE__ */ jsxs19(
12434
- Button9,
13077
+ /* @__PURE__ */ jsxs21(DialogActions2, { sx: { px: 3, pb: 2 }, children: [
13078
+ /* @__PURE__ */ jsx24(Button10, { onClick: () => setStopOpen(false), disabled: stopLoading, sx: { textTransform: "none", color: "hsl(var(--muted-foreground))" }, children: "Cancel" }),
13079
+ /* @__PURE__ */ jsxs21(
13080
+ Button10,
12435
13081
  {
12436
13082
  onClick: confirmStop,
12437
13083
  disabled: stopLoading,
12438
13084
  sx: { textTransform: "none", bgcolor: "hsl(var(--severity-critical, 0 72% 55%))", color: "hsl(var(--primary-foreground))", "&:hover": { bgcolor: "hsla(var(--severity-critical, 0 72% 55%) / 0.9)" } },
12439
13085
  children: [
12440
- stopLoading ? /* @__PURE__ */ jsx22(CircularProgress5, { size: 16, sx: { color: "hsl(var(--primary-foreground))", mr: 1 } }) : null,
13086
+ stopLoading ? /* @__PURE__ */ jsx24(CircularProgress5, { size: 16, sx: { color: "hsl(var(--primary-foreground))", mr: 1 } }) : null,
12441
13087
  "Stop schedule"
12442
13088
  ]
12443
13089
  }
@@ -12453,12 +13099,12 @@ var AgentActivityList = ({
12453
13099
  var AgentActivityList_default = AgentActivityList;
12454
13100
 
12455
13101
  // components/AgentExecutionDrawer.tsx
12456
- import { Box as Box17, Drawer as Drawer4, IconButton as IconButton10, Tooltip as Tooltip12, Typography as Typography16 } from "@mui/material";
13102
+ import { Box as Box19, Drawer as Drawer4, IconButton as IconButton10, Tooltip as Tooltip13, Typography as Typography18 } from "@mui/material";
12457
13103
  import {
12458
13104
  X as CloseIcon7,
12459
13105
  ExternalLink as OpenInNewIcon3
12460
13106
  } from "lucide-react";
12461
- import { Fragment as Fragment9, jsx as jsx23, jsxs as jsxs20 } from "react/jsx-runtime";
13107
+ import { Fragment as Fragment9, jsx as jsx25, jsxs as jsxs22 } from "react/jsx-runtime";
12462
13108
  var AgentExecutionDrawer = ({
12463
13109
  open,
12464
13110
  onClose,
@@ -12480,7 +13126,7 @@ var AgentExecutionDrawer = ({
12480
13126
  const statusKey = (run?.status || "").toUpperCase();
12481
13127
  const cfg = STATUS_CONFIG[statusKey] || STATUS_CONFIG.WAITING;
12482
13128
  const duration = run ? formatDuration(run) : "";
12483
- return /* @__PURE__ */ jsxs20(
13129
+ return /* @__PURE__ */ jsxs22(
12484
13130
  Drawer4,
12485
13131
  {
12486
13132
  anchor: "right",
@@ -12503,8 +13149,8 @@ var AgentExecutionDrawer = ({
12503
13149
  }
12504
13150
  },
12505
13151
  children: [
12506
- /* @__PURE__ */ jsxs20(
12507
- Box17,
13152
+ /* @__PURE__ */ jsxs22(
13153
+ Box19,
12508
13154
  {
12509
13155
  sx: [
12510
13156
  {
@@ -12522,8 +13168,8 @@ var AgentExecutionDrawer = ({
12522
13168
  ...Array.isArray(headerSx) ? headerSx : headerSx ? [headerSx] : []
12523
13169
  ],
12524
13170
  children: [
12525
- /* @__PURE__ */ jsx23(
12526
- Box17,
13171
+ /* @__PURE__ */ jsx25(
13172
+ Box19,
12527
13173
  {
12528
13174
  sx: {
12529
13175
  width: 36,
@@ -12536,13 +13182,13 @@ var AgentExecutionDrawer = ({
12536
13182
  color: "hsl(var(--primary))",
12537
13183
  flexShrink: 0
12538
13184
  },
12539
- children: /* @__PURE__ */ jsx23(AgentIcon_default, { size: 20 })
13185
+ children: /* @__PURE__ */ jsx25(AgentIcon_default, { size: 20 })
12540
13186
  }
12541
13187
  ),
12542
- /* @__PURE__ */ jsxs20(Box17, { sx: { flex: 1, minWidth: 0 }, children: [
12543
- /* @__PURE__ */ jsxs20(Box17, { sx: { display: "flex", alignItems: "center", gap: 1, minWidth: 0 }, children: [
12544
- /* @__PURE__ */ jsx23(
12545
- Typography16,
13188
+ /* @__PURE__ */ jsxs22(Box19, { sx: { flex: 1, minWidth: 0 }, children: [
13189
+ /* @__PURE__ */ jsxs22(Box19, { sx: { display: "flex", alignItems: "center", gap: 1, minWidth: 0 }, children: [
13190
+ /* @__PURE__ */ jsx25(
13191
+ Typography18,
12546
13192
  {
12547
13193
  sx: {
12548
13194
  fontSize: "0.95rem",
@@ -12555,21 +13201,21 @@ var AgentExecutionDrawer = ({
12555
13201
  children: run ? getRunTitle(run) : "Agent execution"
12556
13202
  }
12557
13203
  ),
12558
- run && /* @__PURE__ */ jsx23(Box17, { sx: { display: "flex", alignItems: "center", color: cfg.color, flexShrink: 0 }, children: cfg.icon })
13204
+ run && /* @__PURE__ */ jsx25(Box19, { sx: { display: "flex", alignItems: "center", color: cfg.color, flexShrink: 0 }, children: cfg.icon })
12559
13205
  ] }),
12560
- run && /* @__PURE__ */ jsxs20(Box17, { sx: { display: "flex", alignItems: "center", gap: 1, mt: 0.25 }, children: [
12561
- /* @__PURE__ */ jsx23(Typography16, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: cfg.label }),
12562
- run.started_at && /* @__PURE__ */ jsxs20(Fragment9, { children: [
12563
- /* @__PURE__ */ jsx23(Typography16, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
12564
- /* @__PURE__ */ jsx23(Typography16, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: getTimeAgo(run.started_at) })
13206
+ run && /* @__PURE__ */ jsxs22(Box19, { sx: { display: "flex", alignItems: "center", gap: 1, mt: 0.25 }, children: [
13207
+ /* @__PURE__ */ jsx25(Typography18, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: cfg.label }),
13208
+ run.started_at && /* @__PURE__ */ jsxs22(Fragment9, { children: [
13209
+ /* @__PURE__ */ jsx25(Typography18, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
13210
+ /* @__PURE__ */ jsx25(Typography18, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: getTimeAgo(run.started_at) })
12565
13211
  ] }),
12566
- duration && /* @__PURE__ */ jsxs20(Fragment9, { children: [
12567
- /* @__PURE__ */ jsx23(Typography16, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
12568
- /* @__PURE__ */ jsx23(Typography16, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: duration })
13212
+ duration && /* @__PURE__ */ jsxs22(Fragment9, { children: [
13213
+ /* @__PURE__ */ jsx25(Typography18, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
13214
+ /* @__PURE__ */ jsx25(Typography18, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: duration })
12569
13215
  ] })
12570
13216
  ] })
12571
13217
  ] }),
12572
- run?.execution_id && /* @__PURE__ */ jsx23(Tooltip12, { title: "Open in new tab", children: /* @__PURE__ */ jsx23(
13218
+ run?.execution_id && /* @__PURE__ */ jsx25(Tooltip13, { title: "Open in new tab", children: /* @__PURE__ */ jsx25(
12573
13219
  IconButton10,
12574
13220
  {
12575
13221
  component: "a",
@@ -12581,10 +13227,10 @@ var AgentExecutionDrawer = ({
12581
13227
  color: "hsl(var(--muted-foreground))",
12582
13228
  "&:hover": { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted))" }
12583
13229
  },
12584
- children: /* @__PURE__ */ jsx23(OpenInNewIcon3, { size: 16 })
13230
+ children: /* @__PURE__ */ jsx25(OpenInNewIcon3, { size: 16 })
12585
13231
  }
12586
13232
  ) }),
12587
- /* @__PURE__ */ jsx23(Tooltip12, { title: "Close", children: /* @__PURE__ */ jsx23(
13233
+ /* @__PURE__ */ jsx25(Tooltip13, { title: "Close", children: /* @__PURE__ */ jsx25(
12588
13234
  IconButton10,
12589
13235
  {
12590
13236
  onClick: onClose,
@@ -12593,15 +13239,15 @@ var AgentExecutionDrawer = ({
12593
13239
  color: "hsl(var(--muted-foreground))",
12594
13240
  "&:hover": { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted))" }
12595
13241
  },
12596
- children: /* @__PURE__ */ jsx23(CloseIcon7, { size: 16 })
13242
+ children: /* @__PURE__ */ jsx25(CloseIcon7, { size: 16 })
12597
13243
  }
12598
13244
  ) })
12599
13245
  ]
12600
13246
  }
12601
13247
  ),
12602
- /* @__PURE__ */ jsxs20(Box17, { sx: [{ flex: 1, overflowY: "auto", pt: 3 }, ...Array.isArray(bodySx) ? bodySx : bodySx ? [bodySx] : []], children: [
13248
+ /* @__PURE__ */ jsxs22(Box19, { sx: [{ flex: 1, overflowY: "auto", pt: 3 }, ...Array.isArray(bodySx) ? bodySx : bodySx ? [bodySx] : []], children: [
12603
13249
  topBanner,
12604
- run ? /* @__PURE__ */ jsx23(
13250
+ run ? /* @__PURE__ */ jsx25(
12605
13251
  AgentUI_default,
12606
13252
  {
12607
13253
  initialExecution: {
@@ -12638,9 +13284,9 @@ var AgentExecutionDrawer = ({
12638
13284
  var AgentExecutionDrawer_default = AgentExecutionDrawer;
12639
13285
 
12640
13286
  // views/AgentsView.tsx
12641
- import { useCallback as useCallback10, useMemo as useMemo7, useState as useState15 } from "react";
12642
- import { Box as Box18, Stack, Typography as Typography17 } from "@mui/material";
12643
- import { jsx as jsx24, jsxs as jsxs21 } from "react/jsx-runtime";
13287
+ import { useCallback as useCallback10, useMemo as useMemo8, useState as useState16 } from "react";
13288
+ import { Box as Box20, Stack, Typography as Typography19 } from "@mui/material";
13289
+ import { jsx as jsx26, jsxs as jsxs23 } from "react/jsx-runtime";
12644
13290
  var AgentsView = ({
12645
13291
  onSchedule,
12646
13292
  maxWidth = 820,
@@ -12654,42 +13300,56 @@ var AgentsView = ({
12654
13300
  userdata,
12655
13301
  serverside,
12656
13302
  theme,
12657
- colorMode
13303
+ colorMode,
13304
+ apiKey,
13305
+ orgId
12658
13306
  }) => {
12659
13307
  useSyncHostBaseUrl(globalUrl);
12660
- const [selectedRun, setSelectedRun] = useState15(null);
12661
- const [agentView, setAgentView] = useState15("start");
12662
- const [prefill, setPrefill] = useState15({
13308
+ const [selectedRun, setSelectedRun] = useState16(null);
13309
+ const [agentView, setAgentView] = useState16("start");
13310
+ const [prefill, setPrefill] = useState16({
12663
13311
  input: "",
12664
13312
  apps: [],
12665
13313
  key: 0
12666
13314
  });
12667
- const [editing, setEditing] = useState15(null);
12668
- const [builtInDrawer, setBuiltInDrawer] = useState15({
13315
+ const [editing, setEditing] = useState16(null);
13316
+ const [builtInDrawer, setBuiltInDrawer] = useState16({
12669
13317
  open: false,
12670
13318
  tab: "localLLM"
12671
13319
  });
12672
- const effectiveLocalLLMSlot = useMemo7(
12673
- () => localLLMSlot ?? /* @__PURE__ */ jsxs21(Box18, { sx: { p: 3, color: "hsl(var(--muted-foreground))", fontSize: "0.85rem", lineHeight: 1.6 }, children: [
12674
- /* @__PURE__ */ jsx24(Typography17, { sx: { fontSize: "0.95rem", fontWeight: 600, color: "hsl(var(--foreground))", mb: 1 }, children: "Local LLM not configured" }),
12675
- "This host hasn't wired a Local LLM picker yet. Pass an",
12676
- " ",
12677
- /* @__PURE__ */ jsx24("code", { style: { fontFamily: "monospace" }, children: "onChooseLLM" }),
12678
- " handler or a",
12679
- " ",
12680
- /* @__PURE__ */ jsx24("code", { style: { fontFamily: "monospace" }, children: "localLLMSlot" }),
12681
- " to",
12682
- " ",
12683
- /* @__PURE__ */ jsx24("code", { style: { fontFamily: "monospace" }, children: "<AgentsView />" }),
12684
- " to render your own configuration UI here."
12685
- ] }),
12686
- [localLLMSlot]
13320
+ const effectiveSchedule = useCallback10(
13321
+ async (info) => {
13322
+ if (onSchedule) return onSchedule(info);
13323
+ await scheduleAgentRun({ ...info, apiKey, apiBaseUrl: globalUrl, orgId });
13324
+ },
13325
+ [onSchedule, apiKey, globalUrl, orgId]
13326
+ );
13327
+ const effectiveLocalLLMSlot = useMemo8(
13328
+ () => localLLMSlot ?? /* @__PURE__ */ jsx26(
13329
+ LocalLLMConfig_default,
13330
+ {
13331
+ globalUrl,
13332
+ userdata,
13333
+ isLoaded,
13334
+ isLoggedIn,
13335
+ serverside,
13336
+ theme,
13337
+ colorMode
13338
+ }
13339
+ ),
13340
+ [localLLMSlot, globalUrl, userdata, isLoaded, isLoggedIn, serverside, theme, colorMode]
12687
13341
  );
12688
13342
  const handleChooseLLM = useCallback10(() => {
12689
13343
  if (onChooseLLM) {
12690
13344
  onChooseLLM();
12691
13345
  return;
12692
13346
  }
13347
+ if (typeof window !== "undefined" && window.__shuffleAgentDrawerMounted > 0) {
13348
+ window.dispatchEvent(
13349
+ new CustomEvent("agent-drawer-open", { detail: { tab: "localLLM" } })
13350
+ );
13351
+ return;
13352
+ }
12693
13353
  setBuiltInDrawer({ open: true, tab: "localLLM" });
12694
13354
  }, [onChooseLLM]);
12695
13355
  const handleEditWorkflow = useCallback10(
@@ -12724,10 +13384,10 @@ var AgentsView = ({
12724
13384
  },
12725
13385
  [editing]
12726
13386
  );
12727
- return /* @__PURE__ */ jsxs21(Box18, { sx: { minHeight: "100%", width: "100%", px: { xs: 2, md: 4 }, pt: { xs: 3, md: "5vh" }, pb: 6, boxSizing: "border-box" }, children: [
12728
- /* @__PURE__ */ jsxs21(Stack, { spacing: 6, sx: { maxWidth, mx: "auto", width: "100%" }, children: [
12729
- editing && /* @__PURE__ */ jsxs21(
12730
- Box18,
13387
+ return /* @__PURE__ */ jsxs23(Box20, { sx: { minHeight: "100%", width: "100%", px: { xs: 2, md: 4 }, pt: { xs: 3, md: "5vh" }, pb: 6, boxSizing: "border-box" }, children: [
13388
+ /* @__PURE__ */ jsxs23(Stack, { spacing: 6, sx: { maxWidth, mx: "auto", width: "100%" }, children: [
13389
+ editing && /* @__PURE__ */ jsxs23(
13390
+ Box20,
12731
13391
  {
12732
13392
  sx: {
12733
13393
  display: "flex",
@@ -12740,12 +13400,12 @@ var AgentsView = ({
12740
13400
  bgcolor: "hsl(var(--primary) / 0.08)"
12741
13401
  },
12742
13402
  children: [
12743
- /* @__PURE__ */ jsxs21(Typography17, { sx: { fontSize: "0.85rem", color: "hsl(var(--foreground))" }, children: [
13403
+ /* @__PURE__ */ jsxs23(Typography19, { sx: { fontSize: "0.85rem", color: "hsl(var(--foreground))" }, children: [
12744
13404
  "Editing schedule: ",
12745
- /* @__PURE__ */ jsx24("strong", { children: editing.name })
13405
+ /* @__PURE__ */ jsx26("strong", { children: editing.name })
12746
13406
  ] }),
12747
- /* @__PURE__ */ jsx24(
12748
- Typography17,
13407
+ /* @__PURE__ */ jsx26(
13408
+ Typography19,
12749
13409
  {
12750
13410
  component: "button",
12751
13411
  onClick: () => {
@@ -12765,13 +13425,15 @@ var AgentsView = ({
12765
13425
  ]
12766
13426
  }
12767
13427
  ),
12768
- /* @__PURE__ */ jsx24(
13428
+ /* @__PURE__ */ jsx26(
12769
13429
  AgentUI_default,
12770
13430
  {
12771
13431
  maxWidth,
12772
13432
  apiBaseUrl: globalUrl,
12773
13433
  onViewChange: setAgentView,
12774
- onSchedule,
13434
+ onSchedule: effectiveSchedule,
13435
+ apiKey,
13436
+ orgId,
12775
13437
  onChooseLLM: handleChooseLLM,
12776
13438
  hideChooseLLM,
12777
13439
  defaultInput: prefill.input,
@@ -12786,28 +13448,32 @@ var AgentsView = ({
12786
13448
  },
12787
13449
  prefill.key
12788
13450
  ),
12789
- agentView === "start" && /* @__PURE__ */ jsx24(Box18, { sx: { pt: { xs: 4, md: "8vh" } }, children: /* @__PURE__ */ jsx24(
13451
+ agentView === "start" && /* @__PURE__ */ jsx26(Box20, { sx: { pt: { xs: 4, md: "8vh" } }, children: /* @__PURE__ */ jsx26(
12790
13452
  AgentActivityList_default,
12791
13453
  {
12792
13454
  apiBaseUrl: globalUrl,
13455
+ apiKey,
13456
+ orgId,
12793
13457
  onRunClick: setSelectedRun,
12794
13458
  onEditWorkflow: handleEditWorkflow
12795
13459
  }
12796
13460
  ) })
12797
13461
  ] }),
12798
- /* @__PURE__ */ jsx24(
13462
+ /* @__PURE__ */ jsx26(
12799
13463
  AgentExecutionDrawer_default,
12800
13464
  {
12801
13465
  open: selectedRun !== null,
12802
13466
  onClose: () => setSelectedRun(null),
12803
13467
  run: selectedRun,
12804
13468
  apiBaseUrl: globalUrl,
12805
- onSchedule,
13469
+ onSchedule: effectiveSchedule,
13470
+ apiKey,
13471
+ orgId,
12806
13472
  theme,
12807
13473
  colorMode
12808
13474
  }
12809
13475
  ),
12810
- /* @__PURE__ */ jsx24(
13476
+ /* @__PURE__ */ jsx26(
12811
13477
  AgentRunDrawer_default,
12812
13478
  {
12813
13479
  open: builtInDrawer.open,
@@ -12818,7 +13484,7 @@ var AgentsView = ({
12818
13484
  permissionsSlot,
12819
13485
  theme,
12820
13486
  colorMode,
12821
- agentUIProps: { onSchedule, apiBaseUrl: globalUrl, theme, colorMode }
13487
+ agentUIProps: { onSchedule: effectiveSchedule, apiBaseUrl: globalUrl, apiKey, orgId, theme, colorMode }
12822
13488
  }
12823
13489
  )
12824
13490
  ] });
@@ -12826,12 +13492,12 @@ var AgentsView = ({
12826
13492
  var AgentsView_default = AgentsView;
12827
13493
 
12828
13494
  // useAppLookup.ts
12829
- import { useEffect as useEffect14, useMemo as useMemo8, useState as useState16 } from "react";
13495
+ import { useEffect as useEffect15, useMemo as useMemo9, useState as useState17 } from "react";
12830
13496
  var norm3 = (s) => s.toLowerCase().replace(/[\s_\-]+/g, "_");
12831
13497
  function useAppLookup(appName) {
12832
- const [loading, setLoading] = useState16(false);
12833
- const [info, setInfo] = useState16(null);
12834
- const [algoliaId, setAlgoliaId] = useState16(null);
13498
+ const [loading, setLoading] = useState17(false);
13499
+ const [info, setInfo] = useState17(null);
13500
+ const [algoliaId, setAlgoliaId] = useState17(null);
12835
13501
  const {
12836
13502
  authStates,
12837
13503
  authenticatedApps,
@@ -12840,7 +13506,7 @@ function useAppLookup(appName) {
12840
13506
  handleSaveAuth,
12841
13507
  refreshAuth
12842
13508
  } = useAppAuth();
12843
- useEffect14(() => {
13509
+ useEffect15(() => {
12844
13510
  if (!appName) {
12845
13511
  setInfo(null);
12846
13512
  setAlgoliaId(null);
@@ -12919,13 +13585,13 @@ function useAppLookup(appName) {
12919
13585
  setLoading(false);
12920
13586
  })();
12921
13587
  }, [appName]);
12922
- const matchingEntries = useMemo8(() => {
13588
+ const matchingEntries = useMemo9(() => {
12923
13589
  if (!appName) return [];
12924
13590
  return authenticatedApps.filter(
12925
13591
  (auth) => auth.app?.name && norm3(auth.app.name) === norm3(appName)
12926
13592
  );
12927
13593
  }, [appName, authenticatedApps]);
12928
- const image = useMemo8(() => {
13594
+ const image = useMemo9(() => {
12929
13595
  if (info?.image) return info.image;
12930
13596
  for (const entry of matchingEntries) {
12931
13597
  const img = entry.app?.large_image || entry.large_image;
@@ -12933,7 +13599,7 @@ function useAppLookup(appName) {
12933
13599
  }
12934
13600
  return "";
12935
13601
  }, [info, matchingEntries]);
12936
- const algoliaApp = useMemo8(() => {
13602
+ const algoliaApp = useMemo9(() => {
12937
13603
  if (!appName) return null;
12938
13604
  return {
12939
13605
  objectID: algoliaId || appName,
@@ -12964,91 +13630,12 @@ function useAppLookup(appName) {
12964
13630
  };
12965
13631
  }
12966
13632
 
12967
- // components/UsageBar.tsx
12968
- import { Box as Box19, Typography as Typography18, Tooltip as Tooltip13 } from "@mui/material";
12969
- import { jsx as jsx25, jsxs as jsxs22 } from "react/jsx-runtime";
12970
- var fmt = (n) => n.toLocaleString();
12971
- var UsageBar = ({
12972
- label,
12973
- usage,
12974
- limit,
12975
- unit,
12976
- hint,
12977
- actionLabel,
12978
- actionHref
12979
- }) => {
12980
- const safeLimit = Math.max(limit, 0);
12981
- const pct = safeLimit > 0 ? usage / safeLimit * 100 : 0;
12982
- const isOver = pct >= 100;
12983
- const isWarn = pct >= 65 && !isOver;
12984
- const accent = isOver ? "hsl(var(--destructive))" : isWarn ? "hsl(var(--severity-medium))" : "hsl(var(--muted-foreground))";
12985
- const tooltipText = safeLimit > 0 ? `${pct.toFixed(0)}% used \xB7 ${fmt(usage)} / ${fmt(safeLimit)}${unit ? " " + unit : ""}${hint ? " \xB7 " + hint : ""}` : `${fmt(usage)}${unit ? " " + unit : ""}${hint ? " \xB7 " + hint : ""}`;
12986
- return /* @__PURE__ */ jsx25(Tooltip13, { title: tooltipText, placement: "top", arrow: true, children: /* @__PURE__ */ jsxs22(Box19, { sx: { display: "flex", flexDirection: "column", gap: 0.5, py: 0.25 }, children: [
12987
- /* @__PURE__ */ jsxs22(Box19, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 1 }, children: [
12988
- /* @__PURE__ */ jsx25(
12989
- Typography18,
12990
- {
12991
- sx: {
12992
- fontSize: "12.8px",
12993
- fontWeight: 500,
12994
- color: "hsl(var(--muted-foreground))",
12995
- lineHeight: 1.2
12996
- },
12997
- children: label
12998
- }
12999
- ),
13000
- /* @__PURE__ */ jsxs22(Box19, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
13001
- actionLabel && actionHref && (isWarn || isOver) && /* @__PURE__ */ jsx25(
13002
- Box19,
13003
- {
13004
- component: "a",
13005
- href: actionHref,
13006
- target: "_blank",
13007
- rel: "noopener noreferrer",
13008
- sx: {
13009
- fontSize: "12.8px",
13010
- fontWeight: 600,
13011
- color: accent,
13012
- textDecoration: "none",
13013
- "&:hover": { textDecoration: "underline" }
13014
- },
13015
- children: actionLabel
13016
- }
13017
- ),
13018
- /* @__PURE__ */ jsx25(
13019
- Typography18,
13020
- {
13021
- sx: {
13022
- fontSize: "12.8px",
13023
- fontWeight: 500,
13024
- color: accent,
13025
- whiteSpace: "nowrap",
13026
- fontVariantNumeric: "tabular-nums"
13027
- },
13028
- children: safeLimit > 0 ? `${fmt(usage)} / ${fmt(safeLimit)}${unit ? " " + unit : ""}` : `${fmt(usage)}${unit ? " " + unit : ""}`
13029
- }
13030
- )
13031
- ] })
13032
- ] }),
13033
- /* @__PURE__ */ jsx25(Box19, { sx: { width: "100%", height: 2, bgcolor: "hsl(var(--muted) / 0.5)", borderRadius: 1, overflow: "hidden" }, children: /* @__PURE__ */ jsx25(
13034
- Box19,
13035
- {
13036
- sx: {
13037
- width: `${Math.min(Math.max(pct, 0), 100)}%`,
13038
- height: "100%",
13039
- bgcolor: isOver ? "hsl(var(--destructive))" : isWarn ? "hsl(var(--severity-medium))" : "hsl(var(--severity-low, 142 71% 45%))",
13040
- transition: "width 0.3s ease"
13041
- }
13042
- }
13043
- ) })
13044
- ] }) });
13045
- };
13046
-
13047
13633
  // index.ts
13048
13634
  var resolveMode = (theme, colorMode) => {
13049
13635
  if (theme === "light" || theme === "dark") return theme;
13050
13636
  if (theme === "system") return "auto";
13051
- return colorMode ?? "auto";
13637
+ if (colorMode) return colorMode;
13638
+ return "dark";
13052
13639
  };
13053
13640
  var withMcpTheme = (Inner, displayName) => {
13054
13641
  const Wrapped = ({ theme, colorMode, ...rest }) => React5.createElement(
@@ -13086,6 +13673,7 @@ var AgentActivityList2 = withMcpTheme(AgentActivityList_default, "AgentActivityL
13086
13673
  var AgentExecutionDrawer2 = withMcpTheme(AgentExecutionDrawer_default, "AgentExecutionDrawer");
13087
13674
  var AgentsView2 = withMcpTheme(AgentsView_default, "AgentsView");
13088
13675
  var AgentRunDiagnosisBanner2 = withMcpTheme(AgentRunDiagnosisBanner_default, "AgentRunDiagnosisBanner");
13676
+ var LocalLLMConfig2 = withMcpTheme(LocalLLMConfig_default, "LocalLLMConfig");
13089
13677
  export {
13090
13678
  API_CONFIG,
13091
13679
  AgentActivityList2 as AgentActivityList,
@@ -13111,6 +13699,7 @@ export {
13111
13699
  FORWARD_TICKETS_WORKFLOW_NAME,
13112
13700
  INGEST_TICKETS_WORKFLOW_NAME,
13113
13701
  IntegrationStatus,
13702
+ LocalLLMConfig2 as LocalLLMConfig,
13114
13703
  SIEM_PATTERNS,
13115
13704
  ShuffleMCP2 as ShuffleMCP,
13116
13705
  ShuffleMcpThemeProvider,
@@ -13157,6 +13746,7 @@ export {
13157
13746
  resetRegionUrl,
13158
13747
  resolveApp,
13159
13748
  resolveApps,
13749
+ scheduleAgentRun,
13160
13750
  searchAgentActivity,
13161
13751
  seedResolvedApp,
13162
13752
  setDatastoreItem,