@shuffleio/shuffle-mcps 0.0.23 → 0.0.24

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,6 +6582,7 @@ 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);
@@ -6592,20 +6668,25 @@ function AppSearchDrawer({
6592
6668
  anchor,
6593
6669
  open: open && detailAppName === null,
6594
6670
  onClose: handleClose,
6595
- slotProps: { paper: { className: themeScope?.scopeClassName } },
6671
+ slotProps: {
6672
+ paper: {
6673
+ className: scopeClassName,
6674
+ sx: {
6675
+ width: { xs: "100%", sm: width },
6676
+ maxWidth: "100vw",
6677
+ height: "100vh",
6678
+ display: "flex",
6679
+ flexDirection: "column",
6680
+ overflow: "hidden",
6681
+ background: "linear-gradient(180deg, hsl(var(--card)) 0%, hsl(var(--background)) 100%)",
6682
+ borderLeft: anchor === "right" ? "1px solid hsl(var(--border))" : "none",
6683
+ borderRight: anchor === "left" ? "1px solid hsl(var(--border))" : "none"
6684
+ }
6685
+ }
6686
+ },
6596
6687
  sx: {
6597
6688
  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
- }
6689
+ "& .MuiDrawer-paper": { boxSizing: "border-box" }
6609
6690
  },
6610
6691
  children: [
6611
6692
  /* @__PURE__ */ jsxs12(
@@ -6701,14 +6782,16 @@ function AppSearchDrawer({
6701
6782
  overflowY: "auto"
6702
6783
  },
6703
6784
  "& .singul-results-grid": {
6704
- gridAutoRows: "75px",
6785
+ gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
6786
+ gridAutoRows: "88px",
6705
6787
  gap: "12px"
6706
6788
  },
6707
6789
  "& .singul-results-grid .singul-dropdown-item": {
6708
- minHeight: 75,
6709
- maxHeight: 75,
6710
- height: 75,
6711
- padding: "14px 16px",
6790
+ minWidth: 0,
6791
+ minHeight: 88,
6792
+ maxHeight: 88,
6793
+ height: 88,
6794
+ padding: "12px 14px",
6712
6795
  alignItems: "center",
6713
6796
  overflow: "hidden"
6714
6797
  },
@@ -6717,11 +6800,14 @@ function AppSearchDrawer({
6717
6800
  gap: "12px"
6718
6801
  },
6719
6802
  "& .singul-results-grid .singul-app-icon": {
6720
- width: 40,
6721
- height: 40,
6803
+ width: 36,
6804
+ height: 36,
6722
6805
  borderRadius: 8,
6723
6806
  padding: 4
6724
6807
  },
6808
+ "& .singul-results-grid .singul-app-details": { minWidth: 0 },
6809
+ "& .singul-results-grid .singul-app-name": { maxWidth: "100%" },
6810
+ "& .singul-results-grid .singul-checkbox": { marginLeft: "auto" },
6725
6811
  ...highlightActive && highlightAppName ? {
6726
6812
  [`& .singul-dropdown-item[data-app-name="${highlightAppName}"]`]: {
6727
6813
  borderColor: "hsl(var(--primary)) !important",
@@ -11450,15 +11536,15 @@ var AgentUI = ({
11450
11536
  var AgentUI_default = AgentUI;
11451
11537
 
11452
11538
  // components/AgentRunDrawer.tsx
11453
- import { useEffect as useEffect12, useRef as useRef9, useState as useState13 } from "react";
11539
+ import { useEffect as useEffect13, useRef as useRef10, useState as useState14 } from "react";
11454
11540
  import {
11455
- Box as Box15,
11541
+ Box as Box17,
11456
11542
  Drawer as Drawer3,
11457
11543
  IconButton as IconButton9,
11458
11544
  Tab,
11459
11545
  Tabs,
11460
- Tooltip as Tooltip10,
11461
- Typography as Typography14
11546
+ Tooltip as Tooltip11,
11547
+ Typography as Typography16
11462
11548
  } from "@mui/material";
11463
11549
  import {
11464
11550
  Play,
@@ -11466,7 +11552,361 @@ import {
11466
11552
  ShieldCheck,
11467
11553
  X as CloseIcon6
11468
11554
  } from "lucide-react";
11555
+
11556
+ // components/LocalLLMConfig.tsx
11557
+ import { useEffect as useEffect12, useMemo as useMemo7, useRef as useRef9, useState as useState13 } from "react";
11558
+ import {
11559
+ Autocomplete as Autocomplete3,
11560
+ Box as Box16,
11561
+ Button as Button9,
11562
+ Dialog as Dialog2,
11563
+ DialogActions,
11564
+ DialogContent as DialogContent2,
11565
+ DialogContentText,
11566
+ DialogTitle as DialogTitle2,
11567
+ TextField as TextField6,
11568
+ Typography as Typography15
11569
+ } from "@mui/material";
11570
+
11571
+ // components/UsageBar.tsx
11572
+ import { Box as Box15, Typography as Typography14, Tooltip as Tooltip10 } from "@mui/material";
11469
11573
  import { jsx as jsx21, jsxs as jsxs18 } from "react/jsx-runtime";
11574
+ var fmt = (n) => n.toLocaleString();
11575
+ var UsageBar = ({
11576
+ label,
11577
+ usage,
11578
+ limit,
11579
+ unit,
11580
+ hint,
11581
+ actionLabel,
11582
+ actionHref
11583
+ }) => {
11584
+ const safeLimit = Math.max(limit, 0);
11585
+ const pct = safeLimit > 0 ? usage / safeLimit * 100 : 0;
11586
+ const isOver = pct >= 100;
11587
+ const isWarn = pct >= 65 && !isOver;
11588
+ const accent = isOver ? "hsl(var(--destructive))" : isWarn ? "hsl(var(--severity-medium))" : "hsl(var(--muted-foreground))";
11589
+ 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 : ""}`;
11590
+ 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: [
11591
+ /* @__PURE__ */ jsxs18(Box15, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 1 }, children: [
11592
+ /* @__PURE__ */ jsx21(
11593
+ Typography14,
11594
+ {
11595
+ sx: {
11596
+ fontSize: "12.8px",
11597
+ fontWeight: 500,
11598
+ color: "hsl(var(--muted-foreground))",
11599
+ lineHeight: 1.2
11600
+ },
11601
+ children: label
11602
+ }
11603
+ ),
11604
+ /* @__PURE__ */ jsxs18(Box15, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
11605
+ actionLabel && actionHref && (isWarn || isOver) && /* @__PURE__ */ jsx21(
11606
+ Box15,
11607
+ {
11608
+ component: "a",
11609
+ href: actionHref,
11610
+ target: "_blank",
11611
+ rel: "noopener noreferrer",
11612
+ sx: {
11613
+ fontSize: "12.8px",
11614
+ fontWeight: 600,
11615
+ color: accent,
11616
+ textDecoration: "none",
11617
+ "&:hover": { textDecoration: "underline" }
11618
+ },
11619
+ children: actionLabel
11620
+ }
11621
+ ),
11622
+ /* @__PURE__ */ jsx21(
11623
+ Typography14,
11624
+ {
11625
+ sx: {
11626
+ fontSize: "12.8px",
11627
+ fontWeight: 500,
11628
+ color: accent,
11629
+ whiteSpace: "nowrap",
11630
+ fontVariantNumeric: "tabular-nums"
11631
+ },
11632
+ children: safeLimit > 0 ? `${fmt(usage)} / ${fmt(safeLimit)}${unit ? " " + unit : ""}` : `${fmt(usage)}${unit ? " " + unit : ""}`
11633
+ }
11634
+ )
11635
+ ] })
11636
+ ] }),
11637
+ /* @__PURE__ */ jsx21(Box15, { sx: { width: "100%", height: 2, bgcolor: "hsl(var(--muted) / 0.5)", borderRadius: 1, overflow: "hidden" }, children: /* @__PURE__ */ jsx21(
11638
+ Box15,
11639
+ {
11640
+ sx: {
11641
+ width: `${Math.min(Math.max(pct, 0), 100)}%`,
11642
+ height: "100%",
11643
+ bgcolor: isOver ? "hsl(var(--destructive))" : isWarn ? "hsl(var(--severity-medium))" : "hsl(var(--severity-low, 142 71% 45%))",
11644
+ transition: "width 0.3s ease"
11645
+ }
11646
+ }
11647
+ ) })
11648
+ ] }) });
11649
+ };
11650
+
11651
+ // components/LocalLLMConfig.tsx
11652
+ import { jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
11653
+ import { createElement as createElement2 } from "react";
11654
+ var OPENAI_APP_NAME = "OpenAI";
11655
+ var OPENAI_APP_ID = "5d19dd82517870c68d40cacad9b5ca91";
11656
+ var SHUFFLE_AI_PRESET = "Shuffle AI";
11657
+ var CUSTOM_PRESET = "Custom / self-hosted";
11658
+ var OPENAI_ALGOLIA_APP = {
11659
+ name: OPENAI_APP_NAME,
11660
+ description: "OpenAI-compatible LLM endpoint for agent operations",
11661
+ objectID: OPENAI_APP_ID,
11662
+ creator: "",
11663
+ app_version: "1.0.0",
11664
+ image_url: "",
11665
+ time_edited: 0,
11666
+ generated: false,
11667
+ invalid: false,
11668
+ priority: 0,
11669
+ actions: 0,
11670
+ tags: [],
11671
+ accessible_by: [],
11672
+ categories: [],
11673
+ action_labels: [],
11674
+ triggers: [],
11675
+ verified: true
11676
+ };
11677
+ var ENDPOINT_PRESETS = [
11678
+ { label: SHUFFLE_AI_PRESET, url: "" },
11679
+ { label: "OpenAI", url: "https://api.openai.com/v1" },
11680
+ { label: "Anthropic", url: "https://api.anthropic.com/v1/" },
11681
+ { label: "Google Gemini", url: "https://generativelanguage.googleapis.com/v1beta/openai/" },
11682
+ { label: "Mistral", url: "https://api.mistral.ai/v1" },
11683
+ { label: "Groq", url: "https://api.groq.com/openai/v1" },
11684
+ { label: "Together AI", url: "https://api.together.xyz/v1" },
11685
+ { label: "OpenRouter", url: "https://openrouter.ai/api/v1" },
11686
+ { label: "Ollama (localhost)", url: "http://localhost:11434/v1" },
11687
+ { label: "LM Studio (localhost)", url: "http://localhost:1234/v1" },
11688
+ { label: CUSTOM_PRESET, url: "" }
11689
+ ];
11690
+ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serverside, theme, colorMode }) => {
11691
+ useSyncHostBaseUrl(globalUrl);
11692
+ const { authStates, authenticatedApps, handleAuthChange, handleTestConnection, handleSaveAuth, refreshAuth } = useAppAuth();
11693
+ const [expanded, setExpanded] = useState13(true);
11694
+ const [selectedPreset, setSelectedPreset] = useState13("");
11695
+ const [customUrl, setCustomUrl] = useState13("");
11696
+ const [confirmShuffleAIOpen, setConfirmShuffleAIOpen] = useState13(false);
11697
+ const openaiEntries = authenticatedApps.filter(
11698
+ (a) => a.app?.name?.toLowerCase() === "openai" || a.app?.id === OPENAI_APP_ID
11699
+ );
11700
+ const authState = authStates[OPENAI_APP_ID] || {
11701
+ systemId: OPENAI_APP_ID,
11702
+ status: "pending",
11703
+ credentials: {}
11704
+ };
11705
+ const currentUrl = authState.credentials?.url || "";
11706
+ const attemptedDeletionRef = useRef9(/* @__PURE__ */ new Set());
11707
+ useEffect12(() => {
11708
+ if (authState.status === "testing") return;
11709
+ const failedEntries = openaiEntries.filter((e) => e.validation && e.validation.valid === false && e.id);
11710
+ if (failedEntries.length === 0) return;
11711
+ let cancelled = false;
11712
+ (async () => {
11713
+ let deletedAny = false;
11714
+ for (const entry of failedEntries) {
11715
+ const id = entry.id;
11716
+ if (attemptedDeletionRef.current.has(id)) continue;
11717
+ attemptedDeletionRef.current.add(id);
11718
+ try {
11719
+ const resp = await fetch(getApiUrl(`/api/v1/apps/authentication/${id}`), {
11720
+ method: "DELETE",
11721
+ credentials: "include",
11722
+ headers: { ...getAuthHeader() }
11723
+ });
11724
+ if (resp.ok) deletedAny = true;
11725
+ } catch (err) {
11726
+ console.error("[LocalLLMConfig] Failed to auto-delete failed OpenAI auth:", err);
11727
+ }
11728
+ }
11729
+ if (!cancelled && deletedAny) {
11730
+ await refreshAuth();
11731
+ refreshAllIntegrationStatus();
11732
+ }
11733
+ })();
11734
+ return () => {
11735
+ cancelled = true;
11736
+ };
11737
+ }, [openaiEntries, authState.status, refreshAuth]);
11738
+ const hasOpenAIEntries = openaiEntries.length > 0;
11739
+ const effectivePreset = useMemo7(() => {
11740
+ if (selectedPreset) return selectedPreset;
11741
+ if (!currentUrl && !hasOpenAIEntries) return SHUFFLE_AI_PRESET;
11742
+ if (!currentUrl) return "";
11743
+ const match = ENDPOINT_PRESETS.find((p) => p.url && p.url === currentUrl);
11744
+ return match ? match.label : CUSTOM_PRESET;
11745
+ }, [selectedPreset, currentUrl, hasOpenAIEntries]);
11746
+ const applyShuffleAI = async () => {
11747
+ let deletedAny = false;
11748
+ for (const entry of openaiEntries) {
11749
+ if (!entry.id) continue;
11750
+ try {
11751
+ const resp = await fetch(getApiUrl(`/api/v1/apps/authentication/${entry.id}`), {
11752
+ method: "DELETE",
11753
+ credentials: "include",
11754
+ headers: { ...getAuthHeader() }
11755
+ });
11756
+ if (resp.ok) deletedAny = true;
11757
+ } catch (err) {
11758
+ console.error("[LocalLLMConfig] Failed to delete OpenAI auth when switching to Shuffle AI:", err);
11759
+ }
11760
+ }
11761
+ handleAuthChange(OPENAI_APP_ID, {});
11762
+ setSelectedPreset(SHUFFLE_AI_PRESET);
11763
+ setCustomUrl("");
11764
+ if (deletedAny) {
11765
+ await refreshAuth();
11766
+ refreshAllIntegrationStatus();
11767
+ }
11768
+ };
11769
+ const handlePresetChange = (label) => {
11770
+ if (label === SHUFFLE_AI_PRESET) {
11771
+ if (hasOpenAIEntries) {
11772
+ setConfirmShuffleAIOpen(true);
11773
+ return;
11774
+ }
11775
+ void applyShuffleAI();
11776
+ return;
11777
+ }
11778
+ setSelectedPreset(label);
11779
+ const preset = ENDPOINT_PRESETS.find((p) => p.label === label);
11780
+ if (!preset) return;
11781
+ handleAuthChange(OPENAI_APP_ID, { ...authState.credentials, url: preset.label === CUSTOM_PRESET ? customUrl : preset.url });
11782
+ };
11783
+ const handleCustomUrlChange = (value) => {
11784
+ setCustomUrl(value);
11785
+ handleAuthChange(OPENAI_APP_ID, { ...authState.credentials, url: value });
11786
+ };
11787
+ const isShuffleAI = effectivePreset === SHUFFLE_AI_PRESET;
11788
+ const orgId = userdata?.active_org?.id;
11789
+ const [orgData, setOrgData] = useState13(null);
11790
+ useEffect12(() => {
11791
+ if (!orgId) return;
11792
+ let cancelled = false;
11793
+ (async () => {
11794
+ try {
11795
+ const res = await fetch(getApiUrl(`/api/v1/orgs/${orgId}`), {
11796
+ method: "GET",
11797
+ credentials: "include",
11798
+ headers: { ...getAuthHeader(), "Content-Type": "application/json" }
11799
+ });
11800
+ if (!res.ok) return;
11801
+ const data = await res.json();
11802
+ if (!cancelled) setOrgData(data);
11803
+ } catch (err) {
11804
+ console.error("[LocalLLMConfig] Failed to fetch org info:", err);
11805
+ }
11806
+ })();
11807
+ return () => {
11808
+ cancelled = true;
11809
+ };
11810
+ }, [orgId]);
11811
+ const appRunLimit = orgData?.app_execution_limit ?? userdata?.app_execution_limit ?? 0;
11812
+ const appRunUsage = (orgData?.app_execution_usage ?? userdata?.app_execution_usage ?? 0) + (orgData?.app_executions_suborgs ?? userdata?.app_executions_suborgs ?? 0);
11813
+ const agentTokens = orgData?.sync_features?.agent_tokens ?? userdata?.sync_features?.agent_tokens;
11814
+ const agentTokenLimit = Number(agentTokens?.limit) || 0;
11815
+ const agentTokenUsage = Number(agentTokens?.usage) || 0;
11816
+ return /* @__PURE__ */ jsxs19(Box16, { sx: { display: "flex", flexDirection: "column", gap: 2.5 }, children: [
11817
+ /* @__PURE__ */ jsxs19(Box16, { sx: { display: "flex", flexDirection: "column", gap: 1 }, children: [
11818
+ /* @__PURE__ */ jsx22(Typography15, { sx: { fontSize: "0.85rem", fontWeight: 600, color: "hsl(var(--foreground))" }, children: "AI Provider" }),
11819
+ /* @__PURE__ */ jsx22(
11820
+ Autocomplete3,
11821
+ {
11822
+ size: "small",
11823
+ fullWidth: true,
11824
+ disableClearable: true,
11825
+ options: ENDPOINT_PRESETS.map((p) => p.label),
11826
+ value: effectivePreset || null,
11827
+ onChange: (_e, val) => val && handlePresetChange(val),
11828
+ isOptionEqualToValue: (opt, val) => opt === val,
11829
+ renderOption: (props, option) => {
11830
+ const preset = ENDPOINT_PRESETS.find((p) => p.label === option);
11831
+ return /* @__PURE__ */ createElement2("li", { ...props, key: option }, /* @__PURE__ */ jsxs19(Box16, { sx: { display: "flex", alignItems: "center", gap: 1, width: "100%", minWidth: 0 }, children: [
11832
+ /* @__PURE__ */ jsx22(Typography15, { sx: { fontSize: "0.85rem", color: "hsl(var(--popover-foreground))" }, children: option }),
11833
+ 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 })
11834
+ ] }));
11835
+ },
11836
+ renderInput: (params) => /* @__PURE__ */ jsx22(TextField6, { ...params, placeholder: "Search a provider\u2026" }),
11837
+ slotProps: {
11838
+ paper: { sx: { bgcolor: "hsl(var(--popover))", color: "hsl(var(--popover-foreground))", border: "1px solid hsl(var(--border))" } },
11839
+ popper: { sx: { zIndex: 9999 } }
11840
+ }
11841
+ }
11842
+ )
11843
+ ] }),
11844
+ !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: [
11845
+ 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.",
11846
+ " ",
11847
+ /* @__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" }),
11848
+ "."
11849
+ ] }) }),
11850
+ isShuffleAI && /* @__PURE__ */ jsxs19(Box16, { sx: { display: "flex", flexDirection: "column", gap: 0.75, mt: 0.5, width: "100%" }, children: [
11851
+ /* @__PURE__ */ jsx22(UsageBar, { label: "App runs", usage: appRunUsage, limit: appRunLimit, unit: "runs", actionLabel: "Upgrade", actionHref: "https://shuffler.io/pricing" }),
11852
+ /* @__PURE__ */ jsx22(UsageBar, { label: "Agent tokens", usage: agentTokenUsage, limit: agentTokenLimit, unit: "tokens", actionLabel: "Upgrade", actionHref: "https://shuffler.io/pricing" })
11853
+ ] }),
11854
+ effectivePreset === CUSTOM_PRESET && /* @__PURE__ */ jsx22(
11855
+ TextField6,
11856
+ {
11857
+ size: "small",
11858
+ fullWidth: true,
11859
+ placeholder: "https://your-self-hosted-endpoint.example.com",
11860
+ value: customUrl || currentUrl,
11861
+ onChange: (e) => handleCustomUrlChange(e.target.value),
11862
+ helperText: "Enter the base URL of your OpenAI-compatible endpoint",
11863
+ sx: { "& .MuiFormHelperText-root": { color: "hsl(var(--muted-foreground))" } }
11864
+ }
11865
+ ),
11866
+ !isShuffleAI && /* @__PURE__ */ jsx22(
11867
+ AppAuthCard,
11868
+ {
11869
+ app: OPENAI_ALGOLIA_APP,
11870
+ authState,
11871
+ isExpanded: expanded,
11872
+ onToggle: () => setExpanded((prev) => !prev),
11873
+ onAuthChange: handleAuthChange,
11874
+ onTestConnection: (appId, authId) => handleTestConnection(appId, authId),
11875
+ onSaveAuth: (appId, creds) => handleSaveAuth(appId, creds, OPENAI_APP_NAME),
11876
+ apiAuthEntries: openaiEntries,
11877
+ onRefreshAuth: refreshAuth,
11878
+ disableUrlPrefill: true,
11879
+ hideHeader: true,
11880
+ hideStatusChips: true,
11881
+ hideDocsLink: true,
11882
+ hideUrlFields: true,
11883
+ borderless: true,
11884
+ globalUrl,
11885
+ userdata,
11886
+ isLoaded,
11887
+ isLoggedIn,
11888
+ serverside,
11889
+ theme,
11890
+ colorMode
11891
+ }
11892
+ ),
11893
+ /* @__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: [
11894
+ /* @__PURE__ */ jsx22(DialogTitle2, { sx: { fontSize: "1rem", fontWeight: 600 }, children: "Switch to Shuffle AI?" }),
11895
+ /* @__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?" }) }),
11896
+ /* @__PURE__ */ jsxs19(DialogActions, { sx: { px: 3, pb: 2 }, children: [
11897
+ /* @__PURE__ */ jsx22(Button9, { onClick: () => setConfirmShuffleAIOpen(false), sx: { color: "hsl(var(--muted-foreground))", textTransform: "none", height: 36 }, children: "Cancel" }),
11898
+ /* @__PURE__ */ jsx22(Button9, { onClick: async () => {
11899
+ setConfirmShuffleAIOpen(false);
11900
+ await applyShuffleAI();
11901
+ }, 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" })
11902
+ ] })
11903
+ ] })
11904
+ ] });
11905
+ };
11906
+ var LocalLLMConfig_default = LocalLLMConfig;
11907
+
11908
+ // components/AgentRunDrawer.tsx
11909
+ import { jsx as jsx23, jsxs as jsxs20 } from "react/jsx-runtime";
11470
11910
  var TAB_ORDER = ["run", "permissions", "localLLM"];
11471
11911
  var AgentRunDrawer = ({
11472
11912
  open,
@@ -11486,32 +11926,63 @@ var AgentRunDrawer = ({
11486
11926
  headerSx,
11487
11927
  tabsSx,
11488
11928
  bodySx,
11489
- globalUrl
11929
+ globalUrl,
11930
+ theme,
11931
+ colorMode,
11932
+ userdata,
11933
+ isLoaded,
11934
+ isLoggedIn,
11935
+ serverside
11490
11936
  }) => {
11491
11937
  useSyncHostBaseUrl(globalUrl);
11492
11938
  const themeScope = useShuffleMcpTheme();
11493
- const [activeTab, setActiveTab] = useState13(initialTab);
11494
- const prevOpenRef = useRef9(open);
11495
- useEffect12(() => {
11939
+ const [activeTab, setActiveTab] = useState14(initialTab);
11940
+ const prevOpenRef = useRef10(open);
11941
+ useEffect13(() => {
11496
11942
  if (open && !prevOpenRef.current) setActiveTab(initialTab);
11497
11943
  prevOpenRef.current = open;
11498
11944
  }, [open, initialTab]);
11499
- useEffect12(() => {
11945
+ useEffect13(() => {
11500
11946
  if (typeof window === "undefined") return;
11501
11947
  window.__shuffleAgentDrawerMounted = (window.__shuffleAgentDrawerMounted || 0) + 1;
11502
11948
  return () => {
11503
11949
  window.__shuffleAgentDrawerMounted = Math.max(0, (window.__shuffleAgentDrawerMounted || 1) - 1);
11504
11950
  };
11505
11951
  }, []);
11952
+ useEffect13(() => {
11953
+ if (typeof window === "undefined") return;
11954
+ const onOpen = (event) => {
11955
+ const tab = event.detail?.tab;
11956
+ if (tab === "localLLM") {
11957
+ event.preventDefault();
11958
+ setActiveTab("localLLM");
11959
+ }
11960
+ };
11961
+ window.addEventListener("agent-drawer-open", onOpen);
11962
+ return () => window.removeEventListener("agent-drawer-open", onOpen);
11963
+ }, []);
11964
+ const effectiveLocalLLMSlot = localLLMSlot ?? /* @__PURE__ */ jsx23(
11965
+ LocalLLMConfig_default,
11966
+ {
11967
+ compact: true,
11968
+ globalUrl,
11969
+ userdata,
11970
+ isLoaded,
11971
+ isLoggedIn,
11972
+ serverside,
11973
+ theme,
11974
+ colorMode
11975
+ }
11976
+ );
11506
11977
  const visibleTabs = TAB_ORDER.filter((t) => {
11507
11978
  if (t === "run") return true;
11508
11979
  if (t === "permissions") return !!permissionsSlot;
11509
- if (t === "localLLM") return !!localLLMSlot;
11980
+ if (t === "localLLM") return !!effectiveLocalLLMSlot;
11510
11981
  return false;
11511
11982
  });
11512
11983
  const showTabs = visibleTabs.length > 1;
11513
11984
  const safeActiveTab = visibleTabs.includes(activeTab) ? activeTab : "run";
11514
- return /* @__PURE__ */ jsxs18(
11985
+ return /* @__PURE__ */ jsxs20(
11515
11986
  Drawer3,
11516
11987
  {
11517
11988
  anchor: "right",
@@ -11534,8 +12005,8 @@ var AgentRunDrawer = ({
11534
12005
  }
11535
12006
  },
11536
12007
  children: [
11537
- /* @__PURE__ */ jsxs18(
11538
- Box15,
12008
+ /* @__PURE__ */ jsxs20(
12009
+ Box17,
11539
12010
  {
11540
12011
  sx: [
11541
12012
  {
@@ -11550,8 +12021,8 @@ var AgentRunDrawer = ({
11550
12021
  ...Array.isArray(headerSx) ? headerSx : headerSx ? [headerSx] : []
11551
12022
  ],
11552
12023
  children: [
11553
- /* @__PURE__ */ jsx21(
11554
- Box15,
12024
+ /* @__PURE__ */ jsx23(
12025
+ Box17,
11555
12026
  {
11556
12027
  sx: {
11557
12028
  width: 40,
@@ -11564,18 +12035,18 @@ var AgentRunDrawer = ({
11564
12035
  color: "hsl(var(--primary))",
11565
12036
  flexShrink: 0
11566
12037
  },
11567
- children: /* @__PURE__ */ jsx21(AgentIcon_default, { size: 22 })
12038
+ children: /* @__PURE__ */ jsx23(AgentIcon_default, { size: 22 })
11568
12039
  }
11569
12040
  ),
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 })
12041
+ /* @__PURE__ */ jsxs20(Box17, { sx: { flex: 1, minWidth: 0 }, children: [
12042
+ /* @__PURE__ */ jsx23(Typography16, { sx: { fontWeight: 600, fontSize: "1.1rem", color: "hsl(var(--foreground))" }, children: title }),
12043
+ /* @__PURE__ */ jsx23(Typography16, { sx: { fontSize: "0.8rem", color: "hsl(var(--muted-foreground))" }, children: subtitle })
11573
12044
  ] }),
11574
- /* @__PURE__ */ jsx21(IconButton9, { onClick: onClose, size: "small", sx: { color: "hsl(var(--muted-foreground))" }, children: /* @__PURE__ */ jsx21(CloseIcon6, { size: 16 }) })
12045
+ /* @__PURE__ */ jsx23(IconButton9, { onClick: onClose, size: "small", sx: { color: "hsl(var(--muted-foreground))" }, children: /* @__PURE__ */ jsx23(CloseIcon6, { size: 16 }) })
11575
12046
  ]
11576
12047
  }
11577
12048
  ),
11578
- showTabs && /* @__PURE__ */ jsx21(Box15, { sx: { borderBottom: "1px solid hsl(var(--border))", flexShrink: 0 }, children: /* @__PURE__ */ jsxs18(
12049
+ showTabs && /* @__PURE__ */ jsx23(Box17, { sx: { borderBottom: "1px solid hsl(var(--border))", flexShrink: 0 }, children: /* @__PURE__ */ jsxs20(
11579
12050
  Tabs,
11580
12051
  {
11581
12052
  value: safeActiveTab,
@@ -11597,36 +12068,36 @@ var AgentRunDrawer = ({
11597
12068
  ...Array.isArray(tabsSx) ? tabsSx : tabsSx ? [tabsSx] : []
11598
12069
  ],
11599
12070
  children: [
11600
- visibleTabs.includes("run") && /* @__PURE__ */ jsx21(
12071
+ visibleTabs.includes("run") && /* @__PURE__ */ jsx23(
11601
12072
  Tab,
11602
12073
  {
11603
12074
  value: "run",
11604
12075
  label: "Run",
11605
- icon: /* @__PURE__ */ jsx21(Play, { size: 14 }),
12076
+ icon: /* @__PURE__ */ jsx23(Play, { size: 14 }),
11606
12077
  iconPosition: "start",
11607
12078
  sx: { gap: 0.75 }
11608
12079
  }
11609
12080
  ),
11610
- visibleTabs.includes("permissions") && /* @__PURE__ */ jsx21(
12081
+ visibleTabs.includes("permissions") && /* @__PURE__ */ jsx23(
11611
12082
  Tab,
11612
12083
  {
11613
12084
  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 }),
12085
+ label: permissionsDisabled ? /* @__PURE__ */ jsx23(Tooltip11, { title: permissionsDisabledTooltip, arrow: true, children: /* @__PURE__ */ jsx23(Box17, { component: "span", sx: { display: "inline-flex", alignItems: "center" }, children: "Permissions" }) }) : "Permissions",
12086
+ icon: /* @__PURE__ */ jsx23(ShieldCheck, { size: 14 }),
11616
12087
  iconPosition: "start",
11617
12088
  disabled: permissionsDisabled,
11618
12089
  sx: { gap: 0.75 }
11619
12090
  }
11620
12091
  ),
11621
- visibleTabs.includes("localLLM") && /* @__PURE__ */ jsx21(
12092
+ visibleTabs.includes("localLLM") && /* @__PURE__ */ jsx23(
11622
12093
  Tab,
11623
12094
  {
11624
12095
  value: "localLLM",
11625
- label: /* @__PURE__ */ jsxs18(Box15, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
12096
+ label: /* @__PURE__ */ jsxs20(Box17, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
11626
12097
  "Local LLM",
11627
12098
  localLLMTabBadge
11628
12099
  ] }),
11629
- icon: /* @__PURE__ */ jsx21(Server, { size: 14 }),
12100
+ icon: /* @__PURE__ */ jsx23(Server, { size: 14 }),
11630
12101
  iconPosition: "start",
11631
12102
  sx: { gap: 0.75 }
11632
12103
  }
@@ -11634,20 +12105,22 @@ var AgentRunDrawer = ({
11634
12105
  ]
11635
12106
  }
11636
12107
  ) }),
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(
12108
+ /* @__PURE__ */ jsxs20(Box17, { sx: [{ flex: 1, overflowY: "auto" }, ...Array.isArray(bodySx) ? bodySx : bodySx ? [bodySx] : []], children: [
12109
+ safeActiveTab === "run" && /* @__PURE__ */ jsx23(Box17, { sx: { px: 2, py: 2 }, children: /* @__PURE__ */ jsx23(
11639
12110
  AgentUI_default,
11640
12111
  {
11641
12112
  compact: true,
11642
12113
  hideHeroIcon: true,
11643
12114
  title: "",
11644
12115
  subtitle: null,
11645
- apiBaseUrl: globalUrl,
11646
- ...agentUIProps
12116
+ ...agentUIProps,
12117
+ apiBaseUrl: agentUIProps?.apiBaseUrl ?? globalUrl,
12118
+ theme: agentUIProps?.theme ?? theme,
12119
+ colorMode: agentUIProps?.colorMode ?? colorMode
11647
12120
  }
11648
12121
  ) }),
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 })
12122
+ safeActiveTab === "permissions" && permissionsSlot && /* @__PURE__ */ jsx23(Box17, { sx: { px: 3, py: 2.5 }, children: permissionsSlot }),
12123
+ safeActiveTab === "localLLM" && effectiveLocalLLMSlot && /* @__PURE__ */ jsx23(Box17, { sx: { px: 3, py: 2.5 }, children: effectiveLocalLLMSlot })
11651
12124
  ] })
11652
12125
  ]
11653
12126
  }
@@ -11656,22 +12129,22 @@ var AgentRunDrawer = ({
11656
12129
  var AgentRunDrawer_default = AgentRunDrawer;
11657
12130
 
11658
12131
  // components/AgentActivityList.tsx
11659
- import { useCallback as useCallback9, useEffect as useEffect13, useRef as useRef10, useState as useState14 } from "react";
12132
+ import { useCallback as useCallback9, useEffect as useEffect14, useRef as useRef11, useState as useState15 } from "react";
11660
12133
  import {
11661
- Box as Box16,
11662
- Button as Button9,
12134
+ Box as Box18,
12135
+ Button as Button10,
11663
12136
  Chip as Chip8,
11664
12137
  CircularProgress as CircularProgress5,
11665
- Dialog as Dialog2,
11666
- DialogActions,
11667
- DialogContent as DialogContent2,
11668
- DialogTitle as DialogTitle2,
12138
+ Dialog as Dialog3,
12139
+ DialogActions as DialogActions2,
12140
+ DialogContent as DialogContent3,
12141
+ DialogTitle as DialogTitle3,
11669
12142
  InputAdornment,
11670
12143
  MenuItem as MenuItem3,
11671
12144
  Select as Select3,
11672
- TextField as TextField6,
11673
- Tooltip as Tooltip11,
11674
- Typography as Typography15
12145
+ TextField as TextField7,
12146
+ Tooltip as Tooltip12,
12147
+ Typography as Typography17
11675
12148
  } from "@mui/material";
11676
12149
  import {
11677
12150
  Activity,
@@ -11694,6 +12167,21 @@ var resolveHeaders = (apiKey, orgId) => {
11694
12167
  if (orgId) h["Org-Id"] = orgId;
11695
12168
  return h;
11696
12169
  };
12170
+ var uuid = () => {
12171
+ if (typeof crypto !== "undefined" && "randomUUID" in crypto) return crypto.randomUUID();
12172
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
12173
+ const r = Math.random() * 16 | 0;
12174
+ const v = c === "x" ? r : r & 3 | 8;
12175
+ return v.toString(16);
12176
+ });
12177
+ };
12178
+ var buildAppNameValue = (apps = []) => apps.filter((a) => !!a?.name).map((a) => a.name).join(",");
12179
+ var buildScheduleName = (input) => {
12180
+ const prompt = (input || "").trim();
12181
+ const words = prompt.replace(/[^a-zA-Z0-9\s-]/g, " ").split(/\s+/).filter(Boolean).slice(0, 6);
12182
+ const title = words.length ? words.map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(" ") : "Scheduled Agent Run";
12183
+ return { name: title.slice(0, 80), description: (prompt || "Scheduled Agent Run").slice(0, 240) };
12184
+ };
11697
12185
  var searchAgentActivity = async (params = {}) => {
11698
12186
  const {
11699
12187
  cursor = "",
@@ -11749,6 +12237,127 @@ var listAgentScheduleWorkflows = async (params = {}) => {
11749
12237
  const list = Array.isArray(data) ? data : data?.workflows || [];
11750
12238
  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
12239
  };
12240
+ var scheduleAgentRun = async ({ cron, input, apps = [], onStep, apiKey, apiBaseUrl, orgId }) => {
12241
+ const headers = { "Content-Type": "application/json", ...resolveHeaders(apiKey, orgId) };
12242
+ const step = (id, state, detail) => {
12243
+ try {
12244
+ onStep?.({ id, state, detail });
12245
+ } catch {
12246
+ }
12247
+ };
12248
+ step("name", "active");
12249
+ const { name, description } = buildScheduleName(input);
12250
+ step("name", "done", name);
12251
+ step("workflow", "active");
12252
+ const createRes = await fetch(resolveUrl("/api/v1/workflows", apiBaseUrl), {
12253
+ method: "POST",
12254
+ credentials: "include",
12255
+ headers,
12256
+ body: JSON.stringify({ name, description })
12257
+ });
12258
+ if (!createRes.ok) {
12259
+ step("workflow", "error", `HTTP ${createRes.status}`);
12260
+ throw new Error(`Create workflow failed (${createRes.status})`);
12261
+ }
12262
+ const created = await createRes.json();
12263
+ const workflowId = created.id || created._id || created.workflow_id;
12264
+ if (!workflowId) {
12265
+ step("workflow", "error", "no id returned");
12266
+ throw new Error("Workflow created but no id returned");
12267
+ }
12268
+ const triggerId = uuid();
12269
+ const actionId = uuid();
12270
+ const branchId = uuid();
12271
+ const trigger = {
12272
+ app_name: "Schedule",
12273
+ app_version: "1.0.0",
12274
+ environment: "cloud",
12275
+ id_: triggerId,
12276
+ _id_: triggerId,
12277
+ id: triggerId,
12278
+ finished: true,
12279
+ label: name,
12280
+ type: "TRIGGER",
12281
+ is_valid: true,
12282
+ trigger_type: "SCHEDULE",
12283
+ status: "running",
12284
+ name: "Schedule",
12285
+ parameters: [{ name: "cron", example: "", value: cron }, { name: "execution_argument", example: "", value: "" }],
12286
+ position: { x: 254, y: 617 },
12287
+ flowOrientation: "horizontal"
12288
+ };
12289
+ const action = {
12290
+ name: "Run LLM",
12291
+ label: "AI_Agent_1",
12292
+ app_name: "AI Agent",
12293
+ app_version: "1.0.0",
12294
+ app_id: "shuffle_agent",
12295
+ description: "Run an LLM query against any tool you want",
12296
+ environment: "Cloud",
12297
+ errors: [],
12298
+ id_: actionId,
12299
+ _id_: actionId,
12300
+ id: actionId,
12301
+ is_valid: true,
12302
+ type: "ACTION",
12303
+ isStartNode: true,
12304
+ run_magic_output: false,
12305
+ authentication: [],
12306
+ example: "",
12307
+ category: "",
12308
+ authentication_id: "",
12309
+ template: false,
12310
+ finished: true,
12311
+ flowOrientation: "horizontal",
12312
+ position: { x: 517, y: 370 },
12313
+ selectedAuthentication: {},
12314
+ circleId: uuid(),
12315
+ execution_delay: 0,
12316
+ parameters: [
12317
+ { name: "app_name", value: buildAppNameValue(apps), required: true, description: "Comma-separated list of app names the agent is allowed to use." },
12318
+ { name: "input", value: input, required: true, multiline: true, description: "The input data for the LLM query" }
12319
+ ]
12320
+ };
12321
+ 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 }] };
12322
+ const putRes = await fetch(resolveUrl(`/api/v1/workflows/${workflowId}`, apiBaseUrl), {
12323
+ method: "PUT",
12324
+ credentials: "include",
12325
+ headers,
12326
+ body: JSON.stringify(updated)
12327
+ });
12328
+ if (!putRes.ok) {
12329
+ step("workflow", "error", `HTTP ${putRes.status}`);
12330
+ throw new Error(`Update workflow failed (${putRes.status})`);
12331
+ }
12332
+ step("workflow", "done", name);
12333
+ step("schedule", "active");
12334
+ const schedRes = await fetch(resolveUrl(`/api/v1/workflows/${workflowId}/schedule`, apiBaseUrl), {
12335
+ method: "POST",
12336
+ credentials: "include",
12337
+ headers,
12338
+ body: JSON.stringify({
12339
+ name: "Schedule",
12340
+ frequency: cron,
12341
+ cron,
12342
+ execution_argument: "",
12343
+ environment: "cloud",
12344
+ id: triggerId,
12345
+ start: actionId,
12346
+ parameters: [{ name: "cron", value: cron }, { name: "execution_argument", value: "" }]
12347
+ })
12348
+ }).catch(async (err) => {
12349
+ await fetch(resolveUrl(`/api/v1/workflows/${workflowId}`, apiBaseUrl), { method: "DELETE", credentials: "include", headers: resolveHeaders(apiKey, orgId) }).catch(() => void 0);
12350
+ throw err;
12351
+ });
12352
+ if (!schedRes.ok) {
12353
+ const errText = await schedRes.text().catch(() => "");
12354
+ await fetch(resolveUrl(`/api/v1/workflows/${workflowId}`, apiBaseUrl), { method: "DELETE", credentials: "include", headers: resolveHeaders(apiKey, orgId) }).catch(() => void 0);
12355
+ step("schedule", "error", `HTTP ${schedRes.status}`);
12356
+ throw new Error(`Scheduler rejected the cron \`${cron}\` (HTTP ${schedRes.status})${errText ? `: ${errText}` : ""}. The workflow has been deleted.`);
12357
+ }
12358
+ step("schedule", "done", cron);
12359
+ return { workflowId, name, cron };
12360
+ };
11752
12361
  var findAgentInputParam = (workflow) => {
11753
12362
  const actions = workflow?.actions || [];
11754
12363
  for (const a of actions) {
@@ -11838,16 +12447,16 @@ var stopAgentSchedule = async (workflowId, params = {}) => {
11838
12447
 
11839
12448
  // components/AgentActivityList.tsx
11840
12449
  import { Pencil, StopCircle, AlertTriangle as AlertTriangle2 } from "lucide-react";
11841
- import { Fragment as Fragment8, jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
12450
+ import { Fragment as Fragment8, jsx as jsx24, jsxs as jsxs21 } from "react/jsx-runtime";
11842
12451
  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" }
12452
+ FINISHED: { icon: /* @__PURE__ */ jsx24(CheckCircle, { size: 16 }), color: "hsl(var(--severity-low, 142 71% 45%))", label: "Completed" },
12453
+ SUCCESS: { icon: /* @__PURE__ */ jsx24(CheckCircle, { size: 16 }), color: "hsl(var(--severity-low, 142 71% 45%))", label: "Completed" },
12454
+ FAILED: { icon: /* @__PURE__ */ jsx24(XCircle, { size: 16 }), color: "hsl(var(--severity-critical, 0 72% 55%))", label: "Failed" },
12455
+ ABORTED: { icon: /* @__PURE__ */ jsx24(XCircle, { size: 16 }), color: "hsl(var(--severity-critical, 0 72% 55%))", label: "Aborted" },
12456
+ EXECUTING: { icon: /* @__PURE__ */ jsx24(Loader2, { size: 16 }), color: "hsl(var(--severity-medium, 38 92% 50%))", label: "Running" },
12457
+ RUNNING: { icon: /* @__PURE__ */ jsx24(Loader2, { size: 16 }), color: "hsl(var(--severity-medium, 38 92% 50%))", label: "Running" },
12458
+ WAITING: { icon: /* @__PURE__ */ jsx24(Clock, { size: 16 }), color: "hsl(var(--severity-info, 217 91% 60%))", label: "Waiting" },
12459
+ LIMIT_REACHED: { icon: /* @__PURE__ */ jsx24(AlertTriangle2, { size: 16 }), color: "hsl(var(--severity-medium, 38 92% 50%))", label: "Limit reached" }
11851
12460
  };
11852
12461
  var getEffectiveStatus = (run) => {
11853
12462
  const raw = (run.status || "").toUpperCase();
@@ -11863,12 +12472,12 @@ var getEffectiveStatus = (run) => {
11863
12472
  var getRunIcon = (run) => {
11864
12473
  const src = (run.execution_source || "").toLowerCase();
11865
12474
  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 });
12475
+ if (src.includes("schedule") || src.includes("cron")) return /* @__PURE__ */ jsx24(Clock, { size: 18 });
12476
+ if (src.includes("webhook") || src.includes("http")) return /* @__PURE__ */ jsx24(Globe, { size: 18 });
12477
+ if (arg.includes("alert") || arg.includes("detect")) return /* @__PURE__ */ jsx24(Activity, { size: 18 });
12478
+ if (arg.includes("report") || arg.includes("email")) return /* @__PURE__ */ jsx24(FileText, { size: 18 });
12479
+ if (arg.includes("endpoint") || arg.includes("server")) return /* @__PURE__ */ jsx24(Server2, { size: 18 });
12480
+ return /* @__PURE__ */ jsx24(Zap, { size: 18 });
11872
12481
  };
11873
12482
  var getRunIconColor = (run) => {
11874
12483
  const status = getEffectiveStatus(run);
@@ -11962,8 +12571,8 @@ var AgentRunRow = ({ run, onClick, sx }) => {
11962
12571
  const iconColor = getRunIconColor(run);
11963
12572
  const duration = formatDuration(run);
11964
12573
  const tools = getRunTools(run);
11965
- return /* @__PURE__ */ jsxs19(
11966
- Box16,
12574
+ return /* @__PURE__ */ jsxs21(
12575
+ Box18,
11967
12576
  {
11968
12577
  onClick,
11969
12578
  sx: [
@@ -11986,8 +12595,8 @@ var AgentRunRow = ({ run, onClick, sx }) => {
11986
12595
  ...Array.isArray(sx) ? sx : sx ? [sx] : []
11987
12596
  ],
11988
12597
  children: [
11989
- /* @__PURE__ */ jsx22(
11990
- Box16,
12598
+ /* @__PURE__ */ jsx24(
12599
+ Box18,
11991
12600
  {
11992
12601
  sx: {
11993
12602
  width: 40,
@@ -12003,10 +12612,10 @@ var AgentRunRow = ({ run, onClick, sx }) => {
12003
12612
  children: getRunIcon(run)
12004
12613
  }
12005
12614
  ),
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,
12615
+ /* @__PURE__ */ jsxs21(Box18, { sx: { flex: 1, minWidth: 0 }, children: [
12616
+ /* @__PURE__ */ jsxs21(Box18, { sx: { display: "flex", alignItems: "center", gap: 1, mb: 0.25 }, children: [
12617
+ /* @__PURE__ */ jsx24(
12618
+ Typography17,
12010
12619
  {
12011
12620
  sx: {
12012
12621
  fontSize: "0.9rem",
@@ -12019,10 +12628,10 @@ var AgentRunRow = ({ run, onClick, sx }) => {
12019
12628
  children: getRunTitle(run)
12020
12629
  }
12021
12630
  ),
12022
- /* @__PURE__ */ jsx22(Box16, { sx: { display: "flex", alignItems: "center", color: cfg.color, flexShrink: 0 }, children: cfg.icon })
12631
+ /* @__PURE__ */ jsx24(Box18, { sx: { display: "flex", alignItems: "center", color: cfg.color, flexShrink: 0 }, children: cfg.icon })
12023
12632
  ] }),
12024
- /* @__PURE__ */ jsx22(
12025
- Typography15,
12633
+ /* @__PURE__ */ jsx24(
12634
+ Typography17,
12026
12635
  {
12027
12636
  sx: {
12028
12637
  fontSize: "0.78rem",
@@ -12034,16 +12643,16 @@ var AgentRunRow = ({ run, onClick, sx }) => {
12034
12643
  children: getRunSubtitle(run)
12035
12644
  }
12036
12645
  ),
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 })
12646
+ /* @__PURE__ */ jsxs21(Box18, { sx: { display: "flex", alignItems: "center", gap: 1, mt: 0.5 }, children: [
12647
+ /* @__PURE__ */ jsx24(Typography17, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.7 }, children: run.started_at ? getTimeAgo(run.started_at) : "\u2014" }),
12648
+ duration && /* @__PURE__ */ jsxs21(Fragment8, { children: [
12649
+ /* @__PURE__ */ jsx24(Typography17, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
12650
+ /* @__PURE__ */ jsx24(Typography17, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.7 }, children: duration })
12042
12651
  ] })
12043
12652
  ] })
12044
12653
  ] }),
12045
- tools.length > 0 && /* @__PURE__ */ jsx22(
12046
- Box16,
12654
+ tools.length > 0 && /* @__PURE__ */ jsx24(
12655
+ Box18,
12047
12656
  {
12048
12657
  sx: {
12049
12658
  display: { xs: "none", sm: "flex" },
@@ -12054,7 +12663,7 @@ var AgentRunRow = ({ run, onClick, sx }) => {
12054
12663
  maxWidth: 220,
12055
12664
  flexShrink: 0
12056
12665
  },
12057
- children: tools.map((t) => /* @__PURE__ */ jsx22(Tooltip11, { title: t, arrow: true, children: /* @__PURE__ */ jsx22(
12666
+ children: tools.map((t) => /* @__PURE__ */ jsx24(Tooltip12, { title: t, arrow: true, children: /* @__PURE__ */ jsx24(
12058
12667
  Chip8,
12059
12668
  {
12060
12669
  label: t,
@@ -12103,19 +12712,19 @@ var AgentActivityList = ({
12103
12712
  toolbarSx,
12104
12713
  rowSx
12105
12714
  }) => {
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();
12715
+ const [runs, setRuns] = useState15([]);
12716
+ const [cursor, setCursor] = useState15("");
12717
+ const [hasMore, setHasMore] = useState15(false);
12718
+ const [isLoading, setIsLoading] = useState15(false);
12719
+ const [error, setError] = useState15(null);
12720
+ const [statusFilter, setStatusFilter] = useState15("");
12721
+ const [searchQuery, setSearchQuery] = useState15("");
12722
+ const [debouncedQuery, setDebouncedQuery] = useState15("");
12723
+ const [agentWorkflows, setAgentWorkflows] = useState15([]);
12724
+ const [workflowFilter, setWorkflowFilter] = useState15("");
12725
+ const [stopOpen, setStopOpen] = useState15(false);
12726
+ const [stopLoading, setStopLoading] = useState15(false);
12727
+ const debounceRef = useRef11();
12119
12728
  const selectedAgentWorkflow = agentWorkflows.find((w) => w.id === workflowFilter) || null;
12120
12729
  const openEditPrompt = useCallback9(async () => {
12121
12730
  if (!workflowFilter) return;
@@ -12151,7 +12760,7 @@ var AgentActivityList = ({
12151
12760
  if (debounceRef.current) clearTimeout(debounceRef.current);
12152
12761
  debounceRef.current = setTimeout(() => setDebouncedQuery(q), 350);
12153
12762
  }, []);
12154
- useEffect13(() => () => {
12763
+ useEffect14(() => () => {
12155
12764
  if (debounceRef.current) clearTimeout(debounceRef.current);
12156
12765
  }, []);
12157
12766
  const fetchRuns = useCallback9(
@@ -12183,10 +12792,10 @@ var AgentActivityList = ({
12183
12792
  },
12184
12793
  [statusFilter, limit, apiKey, apiBaseUrl, orgId, workflowFilter]
12185
12794
  );
12186
- useEffect13(() => {
12795
+ useEffect14(() => {
12187
12796
  fetchRuns(false, "");
12188
12797
  }, [statusFilter, apiKey, apiBaseUrl, orgId, workflowFilter]);
12189
- useEffect13(() => {
12798
+ useEffect14(() => {
12190
12799
  let cancelled = false;
12191
12800
  listAgentScheduleWorkflows({ apiKey, apiBaseUrl, orgId }).then((items) => {
12192
12801
  if (!cancelled) setAgentWorkflows(items);
@@ -12209,14 +12818,14 @@ var AgentActivityList = ({
12209
12818
  ].filter(Boolean).join(" ").toLowerCase();
12210
12819
  return hay.includes(debouncedQuery.toLowerCase());
12211
12820
  }) : runs;
12212
- return /* @__PURE__ */ jsxs19(
12213
- Box16,
12821
+ return /* @__PURE__ */ jsxs21(
12822
+ Box18,
12214
12823
  {
12215
12824
  className,
12216
12825
  sx: [{ display: "flex", flexDirection: "column", gap: 2 }, ...Array.isArray(sx) ? sx : sx ? [sx] : []],
12217
12826
  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(
12827
+ (showSearchBar || showStatusChips) && /* @__PURE__ */ jsxs21(Box18, { sx: [{ display: "flex", alignItems: "center", justifyContent: "center", gap: 1.5, flexWrap: "wrap" }, ...Array.isArray(toolbarSx) ? toolbarSx : toolbarSx ? [toolbarSx] : []], children: [
12828
+ /* @__PURE__ */ jsxs21(
12220
12829
  Select3,
12221
12830
  {
12222
12831
  size: "small",
@@ -12253,13 +12862,13 @@ var AgentActivityList = ({
12253
12862
  }
12254
12863
  },
12255
12864
  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))
12865
+ /* @__PURE__ */ jsx24(MenuItem3, { value: "", sx: { fontSize: "0.85rem" }, children: "All Agent runs" }),
12866
+ agentWorkflows.map((w) => /* @__PURE__ */ jsx24(MenuItem3, { value: w.id, sx: { fontSize: "0.85rem" }, children: w.name }, w.id))
12258
12867
  ]
12259
12868
  }
12260
12869
  ),
12261
- showSearchBar && /* @__PURE__ */ jsx22(
12262
- TextField6,
12870
+ showSearchBar && /* @__PURE__ */ jsx24(
12871
+ TextField7,
12263
12872
  {
12264
12873
  placeholder: "Search results...",
12265
12874
  size: "small",
@@ -12267,7 +12876,7 @@ var AgentActivityList = ({
12267
12876
  onChange: (e) => updateSearchQuery(e.target.value),
12268
12877
  slotProps: {
12269
12878
  input: {
12270
- startAdornment: /* @__PURE__ */ jsx22(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx22(SearchIcon, { size: 18, color: "hsl(var(--muted-foreground))" }) })
12879
+ startAdornment: /* @__PURE__ */ jsx24(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx24(SearchIcon, { size: 18, color: "hsl(var(--muted-foreground))" }) })
12271
12880
  }
12272
12881
  },
12273
12882
  sx: {
@@ -12287,7 +12896,7 @@ var AgentActivityList = ({
12287
12896
  }
12288
12897
  }
12289
12898
  ),
12290
- showStatusChips && /* @__PURE__ */ jsx22(
12899
+ showStatusChips && /* @__PURE__ */ jsx24(
12291
12900
  SegmentedControl,
12292
12901
  {
12293
12902
  size: "sm",
@@ -12297,10 +12906,10 @@ var AgentActivityList = ({
12297
12906
  options: STATUS_FILTERS.map((f) => ({ value: f.value, label: f.label }))
12298
12907
  }
12299
12908
  ),
12300
- isLoading && runs.length > 0 && /* @__PURE__ */ jsx22(CircularProgress5, { size: 16, sx: { color: "hsl(var(--primary))", ml: 0.5 } })
12909
+ isLoading && runs.length > 0 && /* @__PURE__ */ jsx24(CircularProgress5, { size: 16, sx: { color: "hsl(var(--primary))", ml: 0.5 } })
12301
12910
  ] }),
12302
- selectedAgentWorkflow && /* @__PURE__ */ jsxs19(
12303
- Box16,
12911
+ selectedAgentWorkflow && /* @__PURE__ */ jsxs21(
12912
+ Box18,
12304
12913
  {
12305
12914
  sx: {
12306
12915
  display: "flex",
@@ -12312,15 +12921,15 @@ var AgentActivityList = ({
12312
12921
  bgcolor: "hsl(var(--card))"
12313
12922
  },
12314
12923
  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 })
12924
+ /* @__PURE__ */ jsxs21(Box18, { sx: { flex: 1, minWidth: 0 }, children: [
12925
+ /* @__PURE__ */ jsx24(Typography17, { sx: { fontSize: "0.85rem", fontWeight: 600, color: "hsl(var(--foreground))", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: selectedAgentWorkflow.name }),
12926
+ selectedAgentWorkflow.description && /* @__PURE__ */ jsx24(Typography17, { sx: { fontSize: "0.75rem", color: "hsl(var(--muted-foreground))", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: selectedAgentWorkflow.description })
12318
12927
  ] }),
12319
- /* @__PURE__ */ jsx22(
12320
- Button9,
12928
+ /* @__PURE__ */ jsx24(
12929
+ Button10,
12321
12930
  {
12322
12931
  size: "small",
12323
- startIcon: /* @__PURE__ */ jsx22(Pencil, { size: 14 }),
12932
+ startIcon: /* @__PURE__ */ jsx24(Pencil, { size: 14 }),
12324
12933
  onClick: openEditPrompt,
12325
12934
  sx: {
12326
12935
  height: 36,
@@ -12335,11 +12944,11 @@ var AgentActivityList = ({
12335
12944
  children: "Edit"
12336
12945
  }
12337
12946
  ),
12338
- /* @__PURE__ */ jsx22(
12339
- Button9,
12947
+ /* @__PURE__ */ jsx24(
12948
+ Button10,
12340
12949
  {
12341
12950
  size: "small",
12342
- startIcon: /* @__PURE__ */ jsx22(StopCircle, { size: 14 }),
12951
+ startIcon: /* @__PURE__ */ jsx24(StopCircle, { size: 14 }),
12343
12952
  onClick: () => setStopOpen(true),
12344
12953
  sx: {
12345
12954
  height: 36,
@@ -12357,17 +12966,17 @@ var AgentActivityList = ({
12357
12966
  ]
12358
12967
  }
12359
12968
  ),
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,
12969
+ 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: [
12970
+ /* @__PURE__ */ jsx24(AlertCircle, { size: 28, style: { color: "hsl(var(--severity-critical, 0 72% 55%))", marginBottom: 8 } }),
12971
+ /* @__PURE__ */ jsx24(
12972
+ Typography17,
12364
12973
  {
12365
12974
  sx: { color: "hsl(var(--severity-critical, 0 72% 55%))", fontSize: "0.9rem", mb: 1 },
12366
12975
  children: error
12367
12976
  }
12368
12977
  ),
12369
- /* @__PURE__ */ jsx22(
12370
- Button9,
12978
+ /* @__PURE__ */ jsx24(
12979
+ Button10,
12371
12980
  {
12372
12981
  size: "small",
12373
12982
  onClick: () => fetchRuns(false, ""),
@@ -12375,24 +12984,24 @@ var AgentActivityList = ({
12375
12984
  children: "Try again"
12376
12985
  }
12377
12986
  )
12378
- ] }) : filteredRuns.length === 0 ? /* @__PURE__ */ jsxs19(Box16, { sx: { display: "flex", flexDirection: "column", alignItems: "center", textAlign: "center", py: 8 }, children: [
12379
- /* @__PURE__ */ jsx22(
12987
+ ] }) : filteredRuns.length === 0 ? /* @__PURE__ */ jsxs21(Box18, { sx: { display: "flex", flexDirection: "column", alignItems: "center", textAlign: "center", py: 8 }, children: [
12988
+ /* @__PURE__ */ jsx24(
12380
12989
  Activity,
12381
12990
  {
12382
12991
  size: 40,
12383
12992
  style: { color: "hsl(var(--muted-foreground))", marginBottom: 12 }
12384
12993
  }
12385
12994
  ),
12386
- /* @__PURE__ */ jsx22(Typography15, { sx: { color: "hsl(var(--muted-foreground))", fontSize: "0.9rem" }, children: emptyTitle }),
12387
- /* @__PURE__ */ jsx22(
12388
- Typography15,
12995
+ /* @__PURE__ */ jsx24(Typography17, { sx: { color: "hsl(var(--muted-foreground))", fontSize: "0.9rem" }, children: emptyTitle }),
12996
+ /* @__PURE__ */ jsx24(
12997
+ Typography17,
12389
12998
  {
12390
12999
  sx: { color: "hsl(var(--muted-foreground))", fontSize: "0.8rem", mt: 0.5, opacity: 0.7 },
12391
13000
  children: emptySubtitle
12392
13001
  }
12393
13002
  )
12394
- ] }) : /* @__PURE__ */ jsxs19(Box16, { sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: [
12395
- filteredRuns.map((run, idx) => /* @__PURE__ */ jsx22(
13003
+ ] }) : /* @__PURE__ */ jsxs21(Box18, { sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: [
13004
+ filteredRuns.map((run, idx) => /* @__PURE__ */ jsx24(
12396
13005
  AgentRunRow,
12397
13006
  {
12398
13007
  run,
@@ -12401,43 +13010,43 @@ var AgentActivityList = ({
12401
13010
  },
12402
13011
  run.execution_id || idx
12403
13012
  )),
12404
- hasMore && /* @__PURE__ */ jsx22(Box16, { sx: { display: "flex", justifyContent: "center", mt: 1 }, children: /* @__PURE__ */ jsxs19(
12405
- Button9,
13013
+ hasMore && /* @__PURE__ */ jsx24(Box18, { sx: { display: "flex", justifyContent: "center", mt: 1 }, children: /* @__PURE__ */ jsxs21(
13014
+ Button10,
12406
13015
  {
12407
13016
  size: "small",
12408
13017
  onClick: loadMore,
12409
13018
  disabled: isLoading,
12410
13019
  sx: { color: "hsl(var(--primary))", textTransform: "none", fontSize: "0.8rem" },
12411
13020
  children: [
12412
- isLoading ? /* @__PURE__ */ jsx22(CircularProgress5, { size: 14, sx: { mr: 1 } }) : null,
13021
+ isLoading ? /* @__PURE__ */ jsx24(CircularProgress5, { size: 14, sx: { mr: 1 } }) : null,
12413
13022
  "Load more"
12414
13023
  ]
12415
13024
  }
12416
13025
  ) })
12417
13026
  ] }),
12418
- /* @__PURE__ */ jsxs19(
12419
- Dialog2,
13027
+ /* @__PURE__ */ jsxs21(
13028
+ Dialog3,
12420
13029
  {
12421
13030
  open: stopOpen,
12422
13031
  onClose: () => stopLoading ? null : setStopOpen(false),
12423
13032
  slotProps: { paper: { sx: { bgcolor: "hsl(var(--card))", color: "hsl(var(--foreground))", border: "1px solid hsl(var(--border))" } } },
12424
13033
  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: [
13034
+ /* @__PURE__ */ jsx24(DialogTitle3, { sx: { fontSize: "1rem", fontWeight: 600 }, children: "Stop schedule?" }),
13035
+ /* @__PURE__ */ jsx24(DialogContent3, { children: /* @__PURE__ */ jsxs21(Typography17, { sx: { fontSize: "0.85rem", color: "hsl(var(--muted-foreground))" }, children: [
12427
13036
  'This will stop "',
12428
13037
  selectedAgentWorkflow?.name,
12429
13038
  '" and delete the scheduled workflow. Past executions remain visible. This cannot be undone.'
12430
13039
  ] }) }),
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,
13040
+ /* @__PURE__ */ jsxs21(DialogActions2, { sx: { px: 3, pb: 2 }, children: [
13041
+ /* @__PURE__ */ jsx24(Button10, { onClick: () => setStopOpen(false), disabled: stopLoading, sx: { textTransform: "none", color: "hsl(var(--muted-foreground))" }, children: "Cancel" }),
13042
+ /* @__PURE__ */ jsxs21(
13043
+ Button10,
12435
13044
  {
12436
13045
  onClick: confirmStop,
12437
13046
  disabled: stopLoading,
12438
13047
  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
13048
  children: [
12440
- stopLoading ? /* @__PURE__ */ jsx22(CircularProgress5, { size: 16, sx: { color: "hsl(var(--primary-foreground))", mr: 1 } }) : null,
13049
+ stopLoading ? /* @__PURE__ */ jsx24(CircularProgress5, { size: 16, sx: { color: "hsl(var(--primary-foreground))", mr: 1 } }) : null,
12441
13050
  "Stop schedule"
12442
13051
  ]
12443
13052
  }
@@ -12453,12 +13062,12 @@ var AgentActivityList = ({
12453
13062
  var AgentActivityList_default = AgentActivityList;
12454
13063
 
12455
13064
  // components/AgentExecutionDrawer.tsx
12456
- import { Box as Box17, Drawer as Drawer4, IconButton as IconButton10, Tooltip as Tooltip12, Typography as Typography16 } from "@mui/material";
13065
+ import { Box as Box19, Drawer as Drawer4, IconButton as IconButton10, Tooltip as Tooltip13, Typography as Typography18 } from "@mui/material";
12457
13066
  import {
12458
13067
  X as CloseIcon7,
12459
13068
  ExternalLink as OpenInNewIcon3
12460
13069
  } from "lucide-react";
12461
- import { Fragment as Fragment9, jsx as jsx23, jsxs as jsxs20 } from "react/jsx-runtime";
13070
+ import { Fragment as Fragment9, jsx as jsx25, jsxs as jsxs22 } from "react/jsx-runtime";
12462
13071
  var AgentExecutionDrawer = ({
12463
13072
  open,
12464
13073
  onClose,
@@ -12480,7 +13089,7 @@ var AgentExecutionDrawer = ({
12480
13089
  const statusKey = (run?.status || "").toUpperCase();
12481
13090
  const cfg = STATUS_CONFIG[statusKey] || STATUS_CONFIG.WAITING;
12482
13091
  const duration = run ? formatDuration(run) : "";
12483
- return /* @__PURE__ */ jsxs20(
13092
+ return /* @__PURE__ */ jsxs22(
12484
13093
  Drawer4,
12485
13094
  {
12486
13095
  anchor: "right",
@@ -12503,8 +13112,8 @@ var AgentExecutionDrawer = ({
12503
13112
  }
12504
13113
  },
12505
13114
  children: [
12506
- /* @__PURE__ */ jsxs20(
12507
- Box17,
13115
+ /* @__PURE__ */ jsxs22(
13116
+ Box19,
12508
13117
  {
12509
13118
  sx: [
12510
13119
  {
@@ -12522,8 +13131,8 @@ var AgentExecutionDrawer = ({
12522
13131
  ...Array.isArray(headerSx) ? headerSx : headerSx ? [headerSx] : []
12523
13132
  ],
12524
13133
  children: [
12525
- /* @__PURE__ */ jsx23(
12526
- Box17,
13134
+ /* @__PURE__ */ jsx25(
13135
+ Box19,
12527
13136
  {
12528
13137
  sx: {
12529
13138
  width: 36,
@@ -12536,13 +13145,13 @@ var AgentExecutionDrawer = ({
12536
13145
  color: "hsl(var(--primary))",
12537
13146
  flexShrink: 0
12538
13147
  },
12539
- children: /* @__PURE__ */ jsx23(AgentIcon_default, { size: 20 })
13148
+ children: /* @__PURE__ */ jsx25(AgentIcon_default, { size: 20 })
12540
13149
  }
12541
13150
  ),
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,
13151
+ /* @__PURE__ */ jsxs22(Box19, { sx: { flex: 1, minWidth: 0 }, children: [
13152
+ /* @__PURE__ */ jsxs22(Box19, { sx: { display: "flex", alignItems: "center", gap: 1, minWidth: 0 }, children: [
13153
+ /* @__PURE__ */ jsx25(
13154
+ Typography18,
12546
13155
  {
12547
13156
  sx: {
12548
13157
  fontSize: "0.95rem",
@@ -12555,21 +13164,21 @@ var AgentExecutionDrawer = ({
12555
13164
  children: run ? getRunTitle(run) : "Agent execution"
12556
13165
  }
12557
13166
  ),
12558
- run && /* @__PURE__ */ jsx23(Box17, { sx: { display: "flex", alignItems: "center", color: cfg.color, flexShrink: 0 }, children: cfg.icon })
13167
+ run && /* @__PURE__ */ jsx25(Box19, { sx: { display: "flex", alignItems: "center", color: cfg.color, flexShrink: 0 }, children: cfg.icon })
12559
13168
  ] }),
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) })
13169
+ run && /* @__PURE__ */ jsxs22(Box19, { sx: { display: "flex", alignItems: "center", gap: 1, mt: 0.25 }, children: [
13170
+ /* @__PURE__ */ jsx25(Typography18, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: cfg.label }),
13171
+ run.started_at && /* @__PURE__ */ jsxs22(Fragment9, { children: [
13172
+ /* @__PURE__ */ jsx25(Typography18, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
13173
+ /* @__PURE__ */ jsx25(Typography18, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: getTimeAgo(run.started_at) })
12565
13174
  ] }),
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 })
13175
+ duration && /* @__PURE__ */ jsxs22(Fragment9, { children: [
13176
+ /* @__PURE__ */ jsx25(Typography18, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
13177
+ /* @__PURE__ */ jsx25(Typography18, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: duration })
12569
13178
  ] })
12570
13179
  ] })
12571
13180
  ] }),
12572
- run?.execution_id && /* @__PURE__ */ jsx23(Tooltip12, { title: "Open in new tab", children: /* @__PURE__ */ jsx23(
13181
+ run?.execution_id && /* @__PURE__ */ jsx25(Tooltip13, { title: "Open in new tab", children: /* @__PURE__ */ jsx25(
12573
13182
  IconButton10,
12574
13183
  {
12575
13184
  component: "a",
@@ -12581,10 +13190,10 @@ var AgentExecutionDrawer = ({
12581
13190
  color: "hsl(var(--muted-foreground))",
12582
13191
  "&:hover": { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted))" }
12583
13192
  },
12584
- children: /* @__PURE__ */ jsx23(OpenInNewIcon3, { size: 16 })
13193
+ children: /* @__PURE__ */ jsx25(OpenInNewIcon3, { size: 16 })
12585
13194
  }
12586
13195
  ) }),
12587
- /* @__PURE__ */ jsx23(Tooltip12, { title: "Close", children: /* @__PURE__ */ jsx23(
13196
+ /* @__PURE__ */ jsx25(Tooltip13, { title: "Close", children: /* @__PURE__ */ jsx25(
12588
13197
  IconButton10,
12589
13198
  {
12590
13199
  onClick: onClose,
@@ -12593,15 +13202,15 @@ var AgentExecutionDrawer = ({
12593
13202
  color: "hsl(var(--muted-foreground))",
12594
13203
  "&:hover": { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted))" }
12595
13204
  },
12596
- children: /* @__PURE__ */ jsx23(CloseIcon7, { size: 16 })
13205
+ children: /* @__PURE__ */ jsx25(CloseIcon7, { size: 16 })
12597
13206
  }
12598
13207
  ) })
12599
13208
  ]
12600
13209
  }
12601
13210
  ),
12602
- /* @__PURE__ */ jsxs20(Box17, { sx: [{ flex: 1, overflowY: "auto", pt: 3 }, ...Array.isArray(bodySx) ? bodySx : bodySx ? [bodySx] : []], children: [
13211
+ /* @__PURE__ */ jsxs22(Box19, { sx: [{ flex: 1, overflowY: "auto", pt: 3 }, ...Array.isArray(bodySx) ? bodySx : bodySx ? [bodySx] : []], children: [
12603
13212
  topBanner,
12604
- run ? /* @__PURE__ */ jsx23(
13213
+ run ? /* @__PURE__ */ jsx25(
12605
13214
  AgentUI_default,
12606
13215
  {
12607
13216
  initialExecution: {
@@ -12638,9 +13247,9 @@ var AgentExecutionDrawer = ({
12638
13247
  var AgentExecutionDrawer_default = AgentExecutionDrawer;
12639
13248
 
12640
13249
  // 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";
13250
+ import { useCallback as useCallback10, useMemo as useMemo8, useState as useState16 } from "react";
13251
+ import { Box as Box20, Stack, Typography as Typography19 } from "@mui/material";
13252
+ import { jsx as jsx26, jsxs as jsxs23 } from "react/jsx-runtime";
12644
13253
  var AgentsView = ({
12645
13254
  onSchedule,
12646
13255
  maxWidth = 820,
@@ -12654,36 +13263,45 @@ var AgentsView = ({
12654
13263
  userdata,
12655
13264
  serverside,
12656
13265
  theme,
12657
- colorMode
13266
+ colorMode,
13267
+ apiKey,
13268
+ orgId
12658
13269
  }) => {
12659
13270
  useSyncHostBaseUrl(globalUrl);
12660
- const [selectedRun, setSelectedRun] = useState15(null);
12661
- const [agentView, setAgentView] = useState15("start");
12662
- const [prefill, setPrefill] = useState15({
13271
+ const [selectedRun, setSelectedRun] = useState16(null);
13272
+ const [agentView, setAgentView] = useState16("start");
13273
+ const [prefill, setPrefill] = useState16({
12663
13274
  input: "",
12664
13275
  apps: [],
12665
13276
  key: 0
12666
13277
  });
12667
- const [editing, setEditing] = useState15(null);
12668
- const [builtInDrawer, setBuiltInDrawer] = useState15({
13278
+ const [editing, setEditing] = useState16(null);
13279
+ const [builtInDrawer, setBuiltInDrawer] = useState16({
12669
13280
  open: false,
12670
13281
  tab: "localLLM"
12671
13282
  });
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]
13283
+ const effectiveSchedule = useCallback10(
13284
+ async (info) => {
13285
+ if (onSchedule) return onSchedule(info);
13286
+ await scheduleAgentRun({ ...info, apiKey, apiBaseUrl: globalUrl, orgId });
13287
+ },
13288
+ [onSchedule, apiKey, globalUrl, orgId]
13289
+ );
13290
+ const effectiveLocalLLMSlot = useMemo8(
13291
+ () => localLLMSlot ?? /* @__PURE__ */ jsx26(
13292
+ LocalLLMConfig_default,
13293
+ {
13294
+ compact: true,
13295
+ globalUrl,
13296
+ userdata,
13297
+ isLoaded,
13298
+ isLoggedIn,
13299
+ serverside,
13300
+ theme,
13301
+ colorMode
13302
+ }
13303
+ ),
13304
+ [localLLMSlot, globalUrl, userdata, isLoaded, isLoggedIn, serverside, theme, colorMode]
12687
13305
  );
12688
13306
  const handleChooseLLM = useCallback10(() => {
12689
13307
  if (onChooseLLM) {
@@ -12724,10 +13342,10 @@ var AgentsView = ({
12724
13342
  },
12725
13343
  [editing]
12726
13344
  );
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,
13345
+ 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: [
13346
+ /* @__PURE__ */ jsxs23(Stack, { spacing: 6, sx: { maxWidth, mx: "auto", width: "100%" }, children: [
13347
+ editing && /* @__PURE__ */ jsxs23(
13348
+ Box20,
12731
13349
  {
12732
13350
  sx: {
12733
13351
  display: "flex",
@@ -12740,12 +13358,12 @@ var AgentsView = ({
12740
13358
  bgcolor: "hsl(var(--primary) / 0.08)"
12741
13359
  },
12742
13360
  children: [
12743
- /* @__PURE__ */ jsxs21(Typography17, { sx: { fontSize: "0.85rem", color: "hsl(var(--foreground))" }, children: [
13361
+ /* @__PURE__ */ jsxs23(Typography19, { sx: { fontSize: "0.85rem", color: "hsl(var(--foreground))" }, children: [
12744
13362
  "Editing schedule: ",
12745
- /* @__PURE__ */ jsx24("strong", { children: editing.name })
13363
+ /* @__PURE__ */ jsx26("strong", { children: editing.name })
12746
13364
  ] }),
12747
- /* @__PURE__ */ jsx24(
12748
- Typography17,
13365
+ /* @__PURE__ */ jsx26(
13366
+ Typography19,
12749
13367
  {
12750
13368
  component: "button",
12751
13369
  onClick: () => {
@@ -12765,13 +13383,15 @@ var AgentsView = ({
12765
13383
  ]
12766
13384
  }
12767
13385
  ),
12768
- /* @__PURE__ */ jsx24(
13386
+ /* @__PURE__ */ jsx26(
12769
13387
  AgentUI_default,
12770
13388
  {
12771
13389
  maxWidth,
12772
13390
  apiBaseUrl: globalUrl,
12773
13391
  onViewChange: setAgentView,
12774
- onSchedule,
13392
+ onSchedule: effectiveSchedule,
13393
+ apiKey,
13394
+ orgId,
12775
13395
  onChooseLLM: handleChooseLLM,
12776
13396
  hideChooseLLM,
12777
13397
  defaultInput: prefill.input,
@@ -12786,28 +13406,32 @@ var AgentsView = ({
12786
13406
  },
12787
13407
  prefill.key
12788
13408
  ),
12789
- agentView === "start" && /* @__PURE__ */ jsx24(Box18, { sx: { pt: { xs: 4, md: "8vh" } }, children: /* @__PURE__ */ jsx24(
13409
+ agentView === "start" && /* @__PURE__ */ jsx26(Box20, { sx: { pt: { xs: 4, md: "8vh" } }, children: /* @__PURE__ */ jsx26(
12790
13410
  AgentActivityList_default,
12791
13411
  {
12792
13412
  apiBaseUrl: globalUrl,
13413
+ apiKey,
13414
+ orgId,
12793
13415
  onRunClick: setSelectedRun,
12794
13416
  onEditWorkflow: handleEditWorkflow
12795
13417
  }
12796
13418
  ) })
12797
13419
  ] }),
12798
- /* @__PURE__ */ jsx24(
13420
+ /* @__PURE__ */ jsx26(
12799
13421
  AgentExecutionDrawer_default,
12800
13422
  {
12801
13423
  open: selectedRun !== null,
12802
13424
  onClose: () => setSelectedRun(null),
12803
13425
  run: selectedRun,
12804
13426
  apiBaseUrl: globalUrl,
12805
- onSchedule,
13427
+ onSchedule: effectiveSchedule,
13428
+ apiKey,
13429
+ orgId,
12806
13430
  theme,
12807
13431
  colorMode
12808
13432
  }
12809
13433
  ),
12810
- /* @__PURE__ */ jsx24(
13434
+ /* @__PURE__ */ jsx26(
12811
13435
  AgentRunDrawer_default,
12812
13436
  {
12813
13437
  open: builtInDrawer.open,
@@ -12818,7 +13442,7 @@ var AgentsView = ({
12818
13442
  permissionsSlot,
12819
13443
  theme,
12820
13444
  colorMode,
12821
- agentUIProps: { onSchedule, apiBaseUrl: globalUrl, theme, colorMode }
13445
+ agentUIProps: { onSchedule: effectiveSchedule, apiBaseUrl: globalUrl, apiKey, orgId, theme, colorMode }
12822
13446
  }
12823
13447
  )
12824
13448
  ] });
@@ -12826,12 +13450,12 @@ var AgentsView = ({
12826
13450
  var AgentsView_default = AgentsView;
12827
13451
 
12828
13452
  // useAppLookup.ts
12829
- import { useEffect as useEffect14, useMemo as useMemo8, useState as useState16 } from "react";
13453
+ import { useEffect as useEffect15, useMemo as useMemo9, useState as useState17 } from "react";
12830
13454
  var norm3 = (s) => s.toLowerCase().replace(/[\s_\-]+/g, "_");
12831
13455
  function useAppLookup(appName) {
12832
- const [loading, setLoading] = useState16(false);
12833
- const [info, setInfo] = useState16(null);
12834
- const [algoliaId, setAlgoliaId] = useState16(null);
13456
+ const [loading, setLoading] = useState17(false);
13457
+ const [info, setInfo] = useState17(null);
13458
+ const [algoliaId, setAlgoliaId] = useState17(null);
12835
13459
  const {
12836
13460
  authStates,
12837
13461
  authenticatedApps,
@@ -12840,7 +13464,7 @@ function useAppLookup(appName) {
12840
13464
  handleSaveAuth,
12841
13465
  refreshAuth
12842
13466
  } = useAppAuth();
12843
- useEffect14(() => {
13467
+ useEffect15(() => {
12844
13468
  if (!appName) {
12845
13469
  setInfo(null);
12846
13470
  setAlgoliaId(null);
@@ -12919,13 +13543,13 @@ function useAppLookup(appName) {
12919
13543
  setLoading(false);
12920
13544
  })();
12921
13545
  }, [appName]);
12922
- const matchingEntries = useMemo8(() => {
13546
+ const matchingEntries = useMemo9(() => {
12923
13547
  if (!appName) return [];
12924
13548
  return authenticatedApps.filter(
12925
13549
  (auth) => auth.app?.name && norm3(auth.app.name) === norm3(appName)
12926
13550
  );
12927
13551
  }, [appName, authenticatedApps]);
12928
- const image = useMemo8(() => {
13552
+ const image = useMemo9(() => {
12929
13553
  if (info?.image) return info.image;
12930
13554
  for (const entry of matchingEntries) {
12931
13555
  const img = entry.app?.large_image || entry.large_image;
@@ -12933,7 +13557,7 @@ function useAppLookup(appName) {
12933
13557
  }
12934
13558
  return "";
12935
13559
  }, [info, matchingEntries]);
12936
- const algoliaApp = useMemo8(() => {
13560
+ const algoliaApp = useMemo9(() => {
12937
13561
  if (!appName) return null;
12938
13562
  return {
12939
13563
  objectID: algoliaId || appName,
@@ -12964,91 +13588,12 @@ function useAppLookup(appName) {
12964
13588
  };
12965
13589
  }
12966
13590
 
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
13591
  // index.ts
13048
13592
  var resolveMode = (theme, colorMode) => {
13049
13593
  if (theme === "light" || theme === "dark") return theme;
13050
13594
  if (theme === "system") return "auto";
13051
- return colorMode ?? "auto";
13595
+ if (colorMode) return colorMode;
13596
+ return "dark";
13052
13597
  };
13053
13598
  var withMcpTheme = (Inner, displayName) => {
13054
13599
  const Wrapped = ({ theme, colorMode, ...rest }) => React5.createElement(
@@ -13086,6 +13631,7 @@ var AgentActivityList2 = withMcpTheme(AgentActivityList_default, "AgentActivityL
13086
13631
  var AgentExecutionDrawer2 = withMcpTheme(AgentExecutionDrawer_default, "AgentExecutionDrawer");
13087
13632
  var AgentsView2 = withMcpTheme(AgentsView_default, "AgentsView");
13088
13633
  var AgentRunDiagnosisBanner2 = withMcpTheme(AgentRunDiagnosisBanner_default, "AgentRunDiagnosisBanner");
13634
+ var LocalLLMConfig2 = withMcpTheme(LocalLLMConfig_default, "LocalLLMConfig");
13089
13635
  export {
13090
13636
  API_CONFIG,
13091
13637
  AgentActivityList2 as AgentActivityList,
@@ -13111,6 +13657,7 @@ export {
13111
13657
  FORWARD_TICKETS_WORKFLOW_NAME,
13112
13658
  INGEST_TICKETS_WORKFLOW_NAME,
13113
13659
  IntegrationStatus,
13660
+ LocalLLMConfig2 as LocalLLMConfig,
13114
13661
  SIEM_PATTERNS,
13115
13662
  ShuffleMCP2 as ShuffleMCP,
13116
13663
  ShuffleMcpThemeProvider,
@@ -13157,6 +13704,7 @@ export {
13157
13704
  resetRegionUrl,
13158
13705
  resolveApp,
13159
13706
  resolveApps,
13707
+ scheduleAgentRun,
13160
13708
  searchAgentActivity,
13161
13709
  seedResolvedApp,
13162
13710
  setDatastoreItem,