@shuffleio/shuffle-mcps 0.0.56 → 0.0.57

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
@@ -23,7 +23,7 @@ import {
23
23
  setHostBaseUrl,
24
24
  setRegionUrl,
25
25
  shuffleFetch
26
- } from "./chunk-45B7UK6Q.mjs";
26
+ } from "./chunk-7HRNENGV.mjs";
27
27
 
28
28
  // index.ts
29
29
  import "./shuffle-mcp-SHQXQS3F.css";
@@ -240,7 +240,7 @@ var ShuffleMcpThemeProvider = ({
240
240
  };
241
241
 
242
242
  // views/ShuffleMCP.tsx
243
- import React4, { useState as useState10, useEffect as useEffect8, useRef as useRef8, useCallback as useCallback7, useMemo as useMemo6, useImperativeHandle } from "react";
243
+ import React4, { useState as useState11, useEffect as useEffect9, useRef as useRef8, useCallback as useCallback7, useMemo as useMemo6, useImperativeHandle } from "react";
244
244
  import { algoliasearch } from "algoliasearch";
245
245
  import { Tooltip as Tooltip6 } from "@mui/material";
246
246
 
@@ -1592,10 +1592,10 @@ var setRuntimeOrgId = (orgId) => {
1592
1592
  var getOrgId = () => {
1593
1593
  if (_runtimeOrgId) return _runtimeOrgId;
1594
1594
  try {
1595
- const userInfo = localStorage.getItem("shuffle_user_info");
1595
+ const userInfo = localStorage.getItem("shuffle_user_info") || localStorage.getItem("userinfo") || localStorage.getItem("user_info");
1596
1596
  if (userInfo) {
1597
1597
  const parsed = JSON.parse(userInfo);
1598
- return parsed.active_org?.id || null;
1598
+ return parsed.active_org?.id || parsed.org_id || parsed.active_org_id || parsed.orgs && parsed.orgs[0]?.id || null;
1599
1599
  }
1600
1600
  } catch {
1601
1601
  }
@@ -2731,13 +2731,22 @@ var useSyncHostBaseUrl = (globalUrl) => {
2731
2731
  };
2732
2732
 
2733
2733
  // auth-utils.ts
2734
+ var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
2735
+ function isValidationFresh(validation) {
2736
+ if (validation?.valid !== true) return false;
2737
+ if (!validation.last_valid) return true;
2738
+ const cutoff = Date.now() - THIRTY_DAYS_MS;
2739
+ const lastValidMs = validation.last_valid > 1e12 ? validation.last_valid : validation.last_valid * 1e3;
2740
+ return lastValidMs >= cutoff;
2741
+ }
2734
2742
  function deduplicateAuthApps(apps) {
2735
2743
  const appMap = /* @__PURE__ */ new Map();
2736
2744
  apps.forEach((auth) => {
2737
- if (!auth.active && !auth.validation?.valid) return;
2745
+ if (!auth.app?.name) return;
2746
+ if (!auth.active && !isValidationFresh(auth.validation)) return;
2738
2747
  const normalizedName = auth.app.name.toLowerCase().trim().replace(/[\s_\-]+/g, "_");
2739
2748
  const existing = appMap.get(normalizedName);
2740
- const isValidated = auth.validation?.valid === true;
2749
+ const isValidated = isValidationFresh(auth.validation);
2741
2750
  const entryImage = auth.app.large_image || "";
2742
2751
  const instance = {
2743
2752
  label: auth.label || auth.id || "Default",
@@ -2778,7 +2787,7 @@ async function backfillAppImages(dedupedApps) {
2778
2787
  let missing = dedupedApps.filter((d) => !d.bestImage && !d.app.large_image);
2779
2788
  if (missing.length === 0) return dedupedApps;
2780
2789
  try {
2781
- const { fetchAppsViaApiConfig: fetchAppsViaApiConfig2 } = await import("./appsCache-ITT5ZZQS.mjs");
2790
+ const { fetchAppsViaApiConfig: fetchAppsViaApiConfig2 } = await import("./appsCache-VD3DQH53.mjs");
2782
2791
  const apps = await fetchAppsViaApiConfig2().catch(() => []);
2783
2792
  if (Array.isArray(apps) && apps.length > 0) {
2784
2793
  const byName = /* @__PURE__ */ new Map();
@@ -2953,7 +2962,7 @@ function findForwardTicketsWorkflow(workflows) {
2953
2962
  }
2954
2963
  function extractValidatedIngestionApps(authApiResponse, workflowAppNames) {
2955
2964
  const dedupedApps = deduplicateAuthApps(
2956
- authApiResponse.filter((auth) => auth.active || auth.validation?.valid)
2965
+ authApiResponse.filter((auth) => auth.active || isValidationFresh(auth.validation))
2957
2966
  );
2958
2967
  const enabledNames = workflowAppNames || /* @__PURE__ */ new Set();
2959
2968
  const apps = [];
@@ -3056,9 +3065,9 @@ function invalidateAuthCache() {
3056
3065
  var TTL_MS = 3e4;
3057
3066
  var cache2 = /* @__PURE__ */ new Map();
3058
3067
  var cacheKey = (crossOrgId) => crossOrgId || "";
3059
- var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
3068
+ var THIRTY_DAYS_MS2 = 30 * 24 * 60 * 60 * 1e3;
3060
3069
  var applyValidationStaleness = (data) => {
3061
- const cutoff = Date.now() - THIRTY_DAYS_MS;
3070
+ const cutoff = Date.now() - THIRTY_DAYS_MS2;
3062
3071
  return data.map((entry) => {
3063
3072
  const v = entry.validation;
3064
3073
  if (v?.valid === true && v?.last_valid) {
@@ -8491,6 +8500,33 @@ function AppDetailContent({
8491
8500
  ] });
8492
8501
  }
8493
8502
 
8503
+ // drawerLayer.ts
8504
+ import { useEffect as useEffect8, useState as useState10 } from "react";
8505
+ var COUNTER_KEY = "__shuffleDrawerLayerTop";
8506
+ var DRAWER_LAYER_BASE = 10011;
8507
+ var STEP = 10;
8508
+ var getTop = (base3) => {
8509
+ const store = globalThis;
8510
+ const current = store[COUNTER_KEY];
8511
+ return typeof current === "number" ? current : base3;
8512
+ };
8513
+ var useDrawerLayer = (open, base3 = DRAWER_LAYER_BASE) => {
8514
+ const [zIndex, setZIndex] = useState10(base3);
8515
+ useEffect8(() => {
8516
+ if (!open) return;
8517
+ const store = globalThis;
8518
+ const next = Math.max(base3, getTop(base3) + STEP);
8519
+ store[COUNTER_KEY] = next;
8520
+ setZIndex(next);
8521
+ return () => {
8522
+ if (store[COUNTER_KEY] === next) {
8523
+ store[COUNTER_KEY] = next - STEP;
8524
+ }
8525
+ };
8526
+ }, [open, base3]);
8527
+ return zIndex;
8528
+ };
8529
+
8494
8530
  // views/AppDetailDrawer.tsx
8495
8531
  import { jsx as jsx17 } from "react/jsx-runtime";
8496
8532
  function AppDetailDrawer({
@@ -8520,6 +8556,7 @@ function AppDetailDrawer({
8520
8556
  const drawerWidth = `min(${width}px, 100vw)`;
8521
8557
  const drawerMinWidth = `min(${minWidth}px, 100vw)`;
8522
8558
  const drawerMaxWidth = `min(${maxWidth}px, 100vw)`;
8559
+ const drawerZIndex = useDrawerLayer(open);
8523
8560
  const handleClose = () => {
8524
8561
  onRefresh?.();
8525
8562
  onClose();
@@ -8551,7 +8588,7 @@ function AppDetailDrawer({
8551
8588
  },
8552
8589
  ...{ PaperProps: drawerPaperProps },
8553
8590
  sx: {
8554
- zIndex: 9999,
8591
+ zIndex: drawerZIndex,
8555
8592
  "& .MuiDrawer-paper": {
8556
8593
  boxSizing: "border-box",
8557
8594
  width: `${drawerWidth} !important`,
@@ -8936,23 +8973,23 @@ var ShuffleMCP = React4.forwardRef(({
8936
8973
  globalUrl
8937
8974
  }, ref) => {
8938
8975
  useSyncHostBaseUrl(globalUrl);
8939
- const [query, setQuery] = useState10(initialQuery);
8940
- const [results, setResults] = useState10([]);
8941
- const [privateApps, setPrivateApps] = useState10([]);
8942
- const [privateAppsLoading, setPrivateAppsLoading] = useState10(!disablePrivateApps);
8943
- const [sourceFilter, setSourceFilter] = useState10("all");
8944
- const [isLoading, setIsLoading] = useState10(false);
8945
- const [isLoadingMore, setIsLoadingMore] = useState10(false);
8946
- const [page, setPage] = useState10(0);
8947
- const [hasMore, setHasMore] = useState10(false);
8948
- const [searchError, setSearchError] = useState10(null);
8949
- const [isOpen, setIsOpen] = useState10(false);
8950
- const [selectedIndex, setSelectedIndex] = useState10(-1);
8951
- const [internalSelectedApps, setInternalSelectedApps] = useState10(selectedApps);
8952
- const [authenticatedApps, setAuthenticatedApps] = useState10(externalAuthenticatedApps || []);
8953
- const [authenticatedAppsLoading, setAuthenticatedAppsLoading] = useState10(!externalAuthenticatedApps);
8954
- const [drawerApp, setDrawerApp] = useState10(null);
8955
- const [initialSettled, setInitialSettled] = useState10(false);
8976
+ const [query, setQuery] = useState11(initialQuery);
8977
+ const [results, setResults] = useState11([]);
8978
+ const [privateApps, setPrivateApps] = useState11([]);
8979
+ const [privateAppsLoading, setPrivateAppsLoading] = useState11(!disablePrivateApps);
8980
+ const [sourceFilter, setSourceFilter] = useState11("all");
8981
+ const [isLoading, setIsLoading] = useState11(false);
8982
+ const [isLoadingMore, setIsLoadingMore] = useState11(false);
8983
+ const [page, setPage] = useState11(0);
8984
+ const [hasMore, setHasMore] = useState11(false);
8985
+ const [searchError, setSearchError] = useState11(null);
8986
+ const [isOpen, setIsOpen] = useState11(false);
8987
+ const [selectedIndex, setSelectedIndex] = useState11(-1);
8988
+ const [internalSelectedApps, setInternalSelectedApps] = useState11(selectedApps);
8989
+ const [authenticatedApps, setAuthenticatedApps] = useState11(externalAuthenticatedApps || []);
8990
+ const [authenticatedAppsLoading, setAuthenticatedAppsLoading] = useState11(!externalAuthenticatedApps);
8991
+ const [drawerApp, setDrawerApp] = useState11(null);
8992
+ const [initialSettled, setInitialSettled] = useState11(false);
8956
8993
  const firstSearchDoneRef = useRef8(false);
8957
8994
  const hasInitialized = useRef8(false);
8958
8995
  const containerRef = useRef8(null);
@@ -8988,10 +9025,10 @@ var ShuffleMCP = React4.forwardRef(({
8988
9025
  setAuthenticatedAppsLoading(false);
8989
9026
  }
8990
9027
  }, [apiKey, apiBaseUrl, authPath, orgId]);
8991
- useEffect8(() => {
9028
+ useEffect9(() => {
8992
9029
  fetchAuthenticatedApps2();
8993
9030
  }, [fetchAuthenticatedApps2]);
8994
- useEffect8(() => {
9031
+ useEffect9(() => {
8995
9032
  if (disablePrivateApps) {
8996
9033
  setPrivateApps([]);
8997
9034
  setPrivateAppsLoading(false);
@@ -9035,7 +9072,7 @@ var ShuffleMCP = React4.forwardRef(({
9035
9072
  };
9036
9073
  fetchPrivateApps();
9037
9074
  }, [apiKey, apiBaseUrl, privateAppsPath, disablePrivateApps, orgId]);
9038
- useEffect8(() => {
9075
+ useEffect9(() => {
9039
9076
  if (disableAutoSelectValidatedApps) return;
9040
9077
  if (authenticatedApps.length > 0 && results.length > 0) {
9041
9078
  const validatedApps = authenticatedApps.filter((auth) => auth.validation?.valid);
@@ -9056,13 +9093,13 @@ var ShuffleMCP = React4.forwardRef(({
9056
9093
  }
9057
9094
  }
9058
9095
  }, [authenticatedApps, results, disableAutoSelectValidatedApps]);
9059
- useEffect8(() => {
9096
+ useEffect9(() => {
9060
9097
  if (externalAuthenticatedApps) {
9061
9098
  setAuthenticatedApps(externalAuthenticatedApps);
9062
9099
  setAuthenticatedAppsLoading(false);
9063
9100
  }
9064
9101
  }, [externalAuthenticatedApps]);
9065
- useEffect8(() => {
9102
+ useEffect9(() => {
9066
9103
  searchClient.current = algoliasearch(algoliaAppId, algoliaApiKey);
9067
9104
  if (!hasInitialized.current) {
9068
9105
  hasInitialized.current = true;
@@ -9075,10 +9112,10 @@ var ShuffleMCP = React4.forwardRef(({
9075
9112
  }, 100);
9076
9113
  }
9077
9114
  }, []);
9078
- useEffect8(() => {
9115
+ useEffect9(() => {
9079
9116
  setInternalSelectedApps(selectedApps);
9080
9117
  }, [selectedApps]);
9081
- useEffect8(() => {
9118
+ useEffect9(() => {
9082
9119
  const handleClickOutside = (event) => {
9083
9120
  if (containerRef.current && !containerRef.current.contains(event.target)) {
9084
9121
  setIsOpen(false);
@@ -9164,13 +9201,13 @@ var ShuffleMCP = React4.forwardRef(({
9164
9201
  }
9165
9202
  }
9166
9203
  }, [hitsPerPage, algoliaIndexName, privateApps.length, results.length]);
9167
- useEffect8(() => {
9204
+ useEffect9(() => {
9168
9205
  if (initialSettled) return;
9169
9206
  if (!firstSearchDoneRef.current || isLoading || privateAppsLoading) return;
9170
9207
  initialSelectedAppsRef.current = selectedApps;
9171
9208
  setInitialSettled(true);
9172
9209
  }, [initialSettled, isLoading, privateAppsLoading, selectedApps]);
9173
- useEffect8(() => {
9210
+ useEffect9(() => {
9174
9211
  const t = setTimeout(() => setInitialSettled(true), 6e3);
9175
9212
  return () => clearTimeout(t);
9176
9213
  }, []);
@@ -9186,7 +9223,7 @@ var ShuffleMCP = React4.forwardRef(({
9186
9223
  if (distanceFromBottom < 200) loadMore();
9187
9224
  }, [canLoadMore, loadMore]);
9188
9225
  const sentinelRef = useRef8(null);
9189
- useEffect8(() => {
9226
+ useEffect9(() => {
9190
9227
  const node = sentinelRef.current;
9191
9228
  if (!node || !canLoadMore) return;
9192
9229
  const observer = new IntersectionObserver(
@@ -9607,7 +9644,7 @@ var ShuffleMCP = React4.forwardRef(({
9607
9644
  ShuffleMCP.displayName = "ShuffleMCP";
9608
9645
 
9609
9646
  // views/AppSearchDrawer.tsx
9610
- import { useState as useState12, useEffect as useEffect10 } from "react";
9647
+ import { useState as useState13, useEffect as useEffect11 } from "react";
9611
9648
  import {
9612
9649
  X as CloseIcon3,
9613
9650
  Plus as PlusIcon
@@ -9616,7 +9653,7 @@ import { Box as Box13, Typography as Typography11, IconButton as IconButton6, Dr
9616
9653
  import { motion as motion8, AnimatePresence as AnimatePresence2 } from "framer-motion";
9617
9654
 
9618
9655
  // ../Shuffle-Core/components/AddAppDialog.tsx
9619
- import { useState as useState11, useCallback as useCallback8, useEffect as useEffect9 } from "react";
9656
+ import { useState as useState12, useCallback as useCallback8, useEffect as useEffect10 } from "react";
9620
9657
  import {
9621
9658
  Dialog as Dialog2,
9622
9659
  DialogTitle as DialogTitle2,
@@ -10082,8 +10119,8 @@ var GENERATION_TIPS = [
10082
10119
  "Building the app with 100% fewer hand-wavy examples..."
10083
10120
  ];
10084
10121
  var DotsLoader = ({ message, tips }) => {
10085
- const [tipIndex, setTipIndex] = useState11(0);
10086
- useEffect9(() => {
10122
+ const [tipIndex, setTipIndex] = useState12(0);
10123
+ useEffect10(() => {
10087
10124
  if (!tips || tips.length === 0) return;
10088
10125
  const interval = setInterval(() => {
10089
10126
  setTipIndex((i) => (i + 1) % tips.length);
@@ -10144,19 +10181,19 @@ var AddAppDialog = ({
10144
10181
  maxLength = 1024,
10145
10182
  initialInput = ""
10146
10183
  }) => {
10147
- const [input, setInput] = useState11(initialInput);
10148
- const [stage, setStage] = useState11("idle");
10149
- const [spec, setSpec] = useState11(null);
10150
- const [errorMsg, setErrorMsg] = useState11("");
10151
- const [createdAppId, setCreatedAppId] = useState11("");
10152
- const [existing, setExisting] = useState11(null);
10153
- const [liveHits, setLiveHits] = useState11([]);
10154
- const [liveSearching, setLiveSearching] = useState11(false);
10155
- useEffect9(() => {
10184
+ const [input, setInput] = useState12(initialInput);
10185
+ const [stage, setStage] = useState12("idle");
10186
+ const [spec, setSpec] = useState12(null);
10187
+ const [errorMsg, setErrorMsg] = useState12("");
10188
+ const [createdAppId, setCreatedAppId] = useState12("");
10189
+ const [existing, setExisting] = useState12(null);
10190
+ const [liveHits, setLiveHits] = useState12([]);
10191
+ const [liveSearching, setLiveSearching] = useState12(false);
10192
+ useEffect10(() => {
10156
10193
  if (open) setInput(initialInput);
10157
10194
  }, [open, initialInput]);
10158
10195
  const title = spec?.info?.title || "";
10159
- useEffect9(() => {
10196
+ useEffect10(() => {
10160
10197
  if (stage !== "idle") return;
10161
10198
  const q = input.trim();
10162
10199
  if (!q || looksLikeUrl(q)) {
@@ -10195,7 +10232,7 @@ var AddAppDialog = ({
10195
10232
  setCreatedAppId("");
10196
10233
  setExisting(null);
10197
10234
  }, []);
10198
- useEffect9(() => {
10235
+ useEffect10(() => {
10199
10236
  if (!open) {
10200
10237
  const t = setTimeout(reset2, 250);
10201
10238
  return () => clearTimeout(t);
@@ -10759,13 +10796,13 @@ function AppSearchDrawer({
10759
10796
  }) {
10760
10797
  const themeScope = useShuffleMcpTheme();
10761
10798
  const scopeClassName = themeScope?.scopeClassName ?? (theme === "dark" ? "shuffle-mcp-scope dark" : theme === "light" ? "shuffle-mcp-scope" : void 0);
10762
- const [detailAppName, setDetailAppName] = useState12(null);
10763
- const [detailAppId, setDetailAppId] = useState12(null);
10764
- const [addAppOpen, setAddAppOpen] = useState12(false);
10765
- const [addAppQuery, setAddAppQuery] = useState12("");
10766
- const [highlightActive, setHighlightActive] = useState12(false);
10767
- const [bodyReady, setBodyReady] = useState12(false);
10768
- useEffect10(() => {
10799
+ const [detailAppName, setDetailAppName] = useState13(null);
10800
+ const [detailAppId, setDetailAppId] = useState13(null);
10801
+ const [addAppOpen, setAddAppOpen] = useState13(false);
10802
+ const [addAppQuery, setAddAppQuery] = useState13("");
10803
+ const [highlightActive, setHighlightActive] = useState13(false);
10804
+ const [bodyReady, setBodyReady] = useState13(false);
10805
+ useEffect11(() => {
10769
10806
  if (!open) {
10770
10807
  setBodyReady(false);
10771
10808
  return;
@@ -10775,7 +10812,7 @@ function AppSearchDrawer({
10775
10812
  });
10776
10813
  return () => cancelAnimationFrame(raf);
10777
10814
  }, [open]);
10778
- useEffect10(() => {
10815
+ useEffect11(() => {
10779
10816
  setHighlightActive(false);
10780
10817
  if (!open || !highlightAppName) return;
10781
10818
  const t = setTimeout(() => setHighlightActive(true), highlightDelayMs);
@@ -10784,6 +10821,7 @@ function AppSearchDrawer({
10784
10821
  const drawerWidth = `min(${width}px, 100vw)`;
10785
10822
  const drawerMinWidth = `min(${minWidth}px, 100vw)`;
10786
10823
  const drawerMaxWidth = `min(${maxWidth}px, 100vw)`;
10824
+ const drawerZIndex = useDrawerLayer(open);
10787
10825
  const handleClose = () => {
10788
10826
  setDetailAppName(null);
10789
10827
  setDetailAppId(null);
@@ -10889,7 +10927,7 @@ function AppSearchDrawer({
10889
10927
  },
10890
10928
  ...{ PaperProps: drawerPaperProps },
10891
10929
  sx: {
10892
- zIndex: 9999,
10930
+ zIndex: drawerZIndex,
10893
10931
  "& .MuiDrawer-paper": {
10894
10932
  boxSizing: "border-box",
10895
10933
  width: `${drawerWidth} !important`,
@@ -11618,7 +11656,7 @@ function ShufflePipelinesBanner() {
11618
11656
  var ShufflePipelinesBanner_default = ShufflePipelinesBanner;
11619
11657
 
11620
11658
  // components/AgentUI.tsx
11621
- import React6, { useCallback as useCallback10, useEffect as useEffect17, useLayoutEffect, useMemo as useMemo10, useRef as useRef11, useState as useState19 } from "react";
11659
+ import React6, { useCallback as useCallback10, useEffect as useEffect18, useLayoutEffect, useMemo as useMemo10, useRef as useRef11, useState as useState20 } from "react";
11622
11660
  import { flushSync } from "react-dom";
11623
11661
 
11624
11662
  // agentRunSync.ts
@@ -11698,7 +11736,7 @@ import {
11698
11736
  } from "lucide-react";
11699
11737
 
11700
11738
  // ../Shuffle-Core/components/WorkflowRunExplorer.tsx
11701
- import React5, { useEffect as useEffect11, useRef as useRef9, useState as useState13 } from "react";
11739
+ import React5, { useEffect as useEffect12, useRef as useRef9, useState as useState14 } from "react";
11702
11740
  import {
11703
11741
  Badge,
11704
11742
  Drawer as Drawer3,
@@ -12248,7 +12286,7 @@ function safeHandler(label, fn) {
12248
12286
  var safeHandler_default = safeHandler;
12249
12287
 
12250
12288
  // components/AgentPresets.tsx
12251
- import { useEffect as useEffect12, useMemo as useMemo7, useState as useState14 } from "react";
12289
+ import { useEffect as useEffect13, useMemo as useMemo7, useState as useState15 } from "react";
12252
12290
  import { Box as Box17, ButtonBase, ClickAwayListener, Paper, Popper, TextField as TextField5, Tooltip as Tooltip10, Typography as Typography15 } from "@mui/material";
12253
12291
  import { Workflow, ShieldAlert, LifeBuoy, Bug, Radar, Monitor, Plus as Plus2, X as CloseIcon6, BellRing } from "lucide-react";
12254
12292
  import { Fragment as Fragment9, jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
@@ -12364,10 +12402,10 @@ var filterAgentPresets = (list, support) => {
12364
12402
  return list.map((p) => SUPPORT_ONLY_PRESET_IDS.includes(p.id) ? { ...p, enabled: false } : p);
12365
12403
  };
12366
12404
  var AgentPresets = ({ variant = "default", onSelectPreset, selectedPreset, onRemoveSelected, presets, chipRef, isSupport, sx, placement }) => {
12367
- const [anchorEl, setAnchorEl] = useState14(null);
12405
+ const [anchorEl, setAnchorEl] = useState15(null);
12368
12406
  const open = Boolean(anchorEl);
12369
- const [supportTick, setSupportTick] = useState14(0);
12370
- useEffect12(() => {
12407
+ const [supportTick, setSupportTick] = useState15(0);
12408
+ useEffect13(() => {
12371
12409
  const bump = () => setSupportTick((t) => t + 1);
12372
12410
  window.addEventListener("storage", bump);
12373
12411
  return () => window.removeEventListener("storage", bump);
@@ -12480,7 +12518,7 @@ var AgentPresets = ({ variant = "default", onSelectPreset, selectedPreset, onRem
12480
12518
  ]
12481
12519
  }
12482
12520
  );
12483
- const [query, setQuery] = useState14("");
12521
+ const [query, setQuery] = useState15("");
12484
12522
  const filtered = useMemo7(() => {
12485
12523
  const q = query.trim().toLowerCase();
12486
12524
  if (!q) return list;
@@ -12749,7 +12787,7 @@ var AgentPresets = ({ variant = "default", onSelectPreset, selectedPreset, onRem
12749
12787
  var AgentPresets_default = AgentPresets;
12750
12788
 
12751
12789
  // useAgentPromptPrefix.ts
12752
- import { useCallback as useCallback9, useEffect as useEffect13, useRef as useRef10, useState as useState15 } from "react";
12790
+ import { useCallback as useCallback9, useEffect as useEffect14, useRef as useRef10, useState as useState16 } from "react";
12753
12791
  var AGENT_PROMPT_PREFIX_CATEGORY = "agent-prompt-prefix";
12754
12792
  var DEFAULT_AGENT_PROMPT_PREFIX = "";
12755
12793
  var decodePrompt = (raw) => {
@@ -12781,11 +12819,11 @@ var decodePrompt = (raw) => {
12781
12819
  var useAgentPromptPrefix = (options = {}) => {
12782
12820
  const { userId, defaultPrompt = DEFAULT_AGENT_PROMPT_PREFIX, persist = true } = options;
12783
12821
  const key = userId || "default";
12784
- const [prompt, setPrompt] = useState15(defaultPrompt);
12785
- const [hasFetched, setHasFetched] = useState15(false);
12786
- const [isSaving, setIsSaving] = useState15(false);
12822
+ const [prompt, setPrompt] = useState16(defaultPrompt);
12823
+ const [hasFetched, setHasFetched] = useState16(false);
12824
+ const [isSaving, setIsSaving] = useState16(false);
12787
12825
  const fetchedForKey = useRef10(null);
12788
- useEffect13(() => {
12826
+ useEffect14(() => {
12789
12827
  if (!persist) {
12790
12828
  setHasFetched(true);
12791
12829
  return;
@@ -13400,7 +13438,7 @@ ${trimmedQuestion}`;
13400
13438
  };
13401
13439
 
13402
13440
  // ../Shuffle-Core/views/monitors/ActionOutputView.tsx
13403
- import { useMemo as useMemo8, useState as useState16, useEffect as useEffect14 } from "react";
13441
+ import { useMemo as useMemo8, useState as useState17, useEffect as useEffect15 } from "react";
13404
13442
  import { Fragment as Fragment10, jsx as jsx26, jsxs as jsxs19 } from "react/jsx-runtime";
13405
13443
  var IMAGE_SIGNATURES = [
13406
13444
  { prefix: "iVBORw0KGgo", mime: "image/png" },
@@ -13487,9 +13525,9 @@ var detectImage = (raw) => {
13487
13525
  var MAX_TEXT_CHARS = 4e3;
13488
13526
  var ActionOutputView = ({ output, className }) => {
13489
13527
  const detected = useMemo8(() => detectImage(output), [output]);
13490
- const [zoomed, setZoomed] = useState16(false);
13491
- const [showFull, setShowFull] = useState16(false);
13492
- useEffect14(() => {
13528
+ const [zoomed, setZoomed] = useState17(false);
13529
+ const [showFull, setShowFull] = useState17(false);
13530
+ useEffect15(() => {
13493
13531
  if (!zoomed) return;
13494
13532
  const onKey = (e) => {
13495
13533
  if (e.key === "Escape") {
@@ -14494,17 +14532,25 @@ var extractDecisionIndex = (path) => {
14494
14532
  };
14495
14533
  var isAiAuthText = (text2) => {
14496
14534
  if (!text2 || typeof text2 !== "string") return false;
14497
- const lower = text2.toLowerCase();
14498
- const hasAuthSignal = /\b(401|unauthori[sz]ed|invalid[_\s-]*(api[_\s-]*key|credentials?|token|auth|key)|incorrect\s+api\s+key|missing[_\s-]*(api[_\s-]*key|authorization|credentials?)|authentication[_\s-]*(failed|required|error)|ai\s+credentials)\b/.test(
14499
- lower
14500
- ) || /check\s+your\s+ai\s+credentials/.test(lower);
14501
- if (!hasAuthSignal) return false;
14502
- const hasAiSignal = /\b(failed\s+to\s+start\s+ai\s+agent|failed\s+to\s+run\s+ai(\s+(agent|query))?|failed\s+to\s+run\s+ai|ai\s+agent\s+(failed|error|crash|aborted)|ai\s+query|ai\s+credentials|shuffler\.io\/agents|runactionai|llm\s+request|failed\s+to\s+run\s+llm|no\s+llm|openai|anthropic|mistral|groq|deepseek|together\.ai|together\.xyz|openrouter|gemini|googleapis\.com|ollama|lm\s*studio|platform\.openai\.com|api\.openai\.com|local\s*llm)\b/.test(
14503
- lower
14504
- ) || /error\s+from\s+['"][^'"]*(openai|anthropic|mistral|groq|deepseek|together|openrouter|googleapis|ollama|lmstudio)/.test(
14505
- lower
14506
- ) || /incorrect\s+api\s+key\s+provided/.test(lower);
14507
- return Boolean(hasAiSignal);
14535
+ const trimmed = text2.trim();
14536
+ if (!trimmed) return false;
14537
+ const checkChunk = (chunk) => {
14538
+ const lower = chunk.toLowerCase();
14539
+ const hasAuthSignal = /\b(401|unauthori[sz]ed|invalid[_\s-]*(api[_\s-]*key|credentials?|token|auth|key)|incorrect\s+api\s+key|missing[_\s-]*(api[_\s-]*key|authorization|credentials?)|authentication[_\s-]*(failed|required|error)|ai\s+credentials)\b/.test(
14540
+ lower
14541
+ ) || /check\s+your\s+ai\s+credentials/.test(lower);
14542
+ if (!hasAuthSignal) return false;
14543
+ const hasAiSignal = /\b(failed\s+to\s+start\s+ai\s+agent|failed\s+to\s+run\s+ai(\s+(agent|query))?|failed\s+to\s+run\s+ai|ai\s+agent\s+(failed|error|crash|aborted)|ai\s+query|ai\s+credentials|shuffler\.io\/agents|runactionai|llm\s+request|failed\s+to\s+run\s+llm|no\s+llm|openai|anthropic|mistral|groq|deepseek|together\.ai|together\.xyz|openrouter|gemini|generativelanguage\.googleapis\.com|aiplatform\.googleapis\.com|ollama|lm\s*studio|platform\.openai\.com|api\.openai\.com|local\s*llm)\b/.test(
14544
+ lower
14545
+ ) || /error\s+from\s+['"][^'"]*(openai|anthropic|mistral|groq|deepseek|together|openrouter|generativelanguage|aiplatform|gemini|ollama|lmstudio)/.test(
14546
+ lower
14547
+ ) || /incorrect\s+api\s+key\s+provided/.test(lower);
14548
+ return Boolean(hasAiSignal);
14549
+ };
14550
+ if (trimmed.includes("\n")) {
14551
+ return trimmed.split(/\r?\n/).some((line) => checkChunk(line));
14552
+ }
14553
+ return checkChunk(trimmed);
14508
14554
  };
14509
14555
  var hasOutputWarning = (run) => {
14510
14556
  return diagnoseOutputWarning(run) !== null;
@@ -14538,8 +14584,15 @@ var trimEvidenceValue = (v, max = 180) => {
14538
14584
  };
14539
14585
  var TOKEN_LIMIT_PATTERN = /\b(ai[\s-]*token[\s-]*limit[\s-]*(is[\s-]*)?reach(ed)?|token[\s-]*limit[\s-]*(is[\s-]*)?reach(ed)?|context[\s-]*(window|length|limit)[\s-]*(is[\s-]*)?(reached|exceeded)|maximum[\s-]*context[\s-]*(window|length)?[\s-]*(is[\s-]*)?(reached|exceeded)|too[\s-]*many[\s-]*tokens|exceeds?[\s-]*(the[\s-]*)?(maximum[\s-]*)?(token|context))\b/;
14540
14586
  var isSentenceLike = (v) => /[a-z]/i.test(v) && v.trim().split(/\s+/).length > 1;
14587
+ var hasProducedDecisions = (run, parsed) => {
14588
+ const parsedDecisions = parsed && typeof parsed === "object" ? parsed.decisions : null;
14589
+ if (Array.isArray(parsedDecisions) && parsedDecisions.length > 0) return true;
14590
+ const directDecisions = run?.decisions;
14591
+ return Array.isArray(directDecisions) && directDecisions.length > 0;
14592
+ };
14541
14593
  var diagnoseOutputWarning = (run) => {
14542
14594
  const { parsed, raw } = parseRunResult(run);
14595
+ const producedDecisions = hasProducedDecisions(run, parsed);
14543
14596
  const tokenLimitMatch = (() => {
14544
14597
  const candidates = [];
14545
14598
  if (parsed && typeof parsed === "object") {
@@ -14574,7 +14627,7 @@ var diagnoseOutputWarning = (run) => {
14574
14627
  const category = String(last.category || "").toLowerCase();
14575
14628
  if (["finish", "finalise"].includes(action) || ["finish", "finalise"].includes(category)) {
14576
14629
  if (last.success === false || last.status === "FAILED") return false;
14577
- if (isAiAuthText(last.reason) || isAiAuthText(last.output) || isAiAuthText(last.details?.output)) return false;
14630
+ if (isAiAuthText(last.reason)) return false;
14578
14631
  const reasonStr = String(last.reason || "").toLowerCase();
14579
14632
  if (reasonStr.startsWith("failed to") || reasonStr.includes("error,")) return false;
14580
14633
  return true;
@@ -14584,28 +14637,22 @@ var diagnoseOutputWarning = (run) => {
14584
14637
  return false;
14585
14638
  })();
14586
14639
  const aiAuthMatch = (() => {
14640
+ if (producedDecisions) return null;
14641
+ if (isFinished && (!parsed?.error && parsed?.success !== false)) return null;
14587
14642
  if (isFinished && hasSuccessfulFinish) return null;
14588
14643
  const candidates = [];
14589
14644
  if (parsed && typeof parsed === "object") {
14590
14645
  if (typeof parsed.error === "string") candidates.push(parsed.error);
14591
- if (typeof parsed.reason === "string") candidates.push(parsed.reason);
14592
- if (typeof parsed.message === "string") candidates.push(parsed.message);
14593
- if (typeof parsed.output === "string") candidates.push(parsed.output);
14594
- if (Array.isArray(parsed.decisions)) {
14646
+ if (!isFinished && typeof parsed.reason === "string") candidates.push(parsed.reason);
14647
+ if (!isFinished && typeof parsed.message === "string") candidates.push(parsed.message);
14648
+ if (Array.isArray(parsed.decisions) && !isFinished) {
14595
14649
  for (const d of parsed.decisions) {
14596
14650
  if (typeof d?.run_details?.error === "string") candidates.push(d.run_details.error);
14597
- if (typeof d?.reason === "string") candidates.push(d.reason);
14598
- if (typeof d?.run_details?.result === "string") candidates.push(d.run_details.result);
14599
- if (typeof d?.output === "string") candidates.push(d.output);
14600
- if (Array.isArray(d?.fields)) {
14601
- for (const f of d.fields) {
14602
- if (typeof f?.value === "string") candidates.push(f.value);
14603
- }
14604
- }
14651
+ if (d?.status === "FAILED" && typeof d?.reason === "string") candidates.push(d.reason);
14605
14652
  }
14606
14653
  }
14607
14654
  }
14608
- if (raw) {
14655
+ if (raw && !isFinished) {
14609
14656
  candidates.push(raw);
14610
14657
  }
14611
14658
  return candidates.find((v) => isAiAuthText(v)) || null;
@@ -14720,7 +14767,7 @@ var diagnoseOutputWarning = (run) => {
14720
14767
  const dedup = ev.filter((e) => e.path !== statusEvidence.path);
14721
14768
  return [statusEvidence, ...dedup].slice(0, 3);
14722
14769
  };
14723
- if (isAiAuthText(errorHaystackLower) || isAiAuthText(raw)) {
14770
+ if (!producedDecisions && !isFinished && (isAiAuthText(errorHaystackLower) || isAiAuthText(raw))) {
14724
14771
  const ev = findEvidenceByRegex(
14725
14772
  /unauthori[sz]ed|invalid[_\s-]*(api[_\s-]*key|token|credentials?)|authentication[_\s-]*(failed|required)|missing[_\s-]*(api[_\s-]*key|token|authorization)|bearer[_\s-]*token|expired[_\s-]*token|failed\s+to\s+start\s+ai\s+agent|incorrect\s+api\s+key\s+provided|\b401\b/
14726
14773
  );
@@ -14859,39 +14906,35 @@ var diagnoseOutputWarning = (run) => {
14859
14906
  return null;
14860
14907
  };
14861
14908
  var isAiAuthFailure = (run, extraText) => {
14909
+ if (!run) return isAiAuthText(extraText);
14910
+ const { parsed } = parseRunResult(run);
14911
+ if (hasProducedDecisions(run, parsed)) return false;
14862
14912
  if (isAiAuthText(extraText)) return true;
14863
- if (!run) return false;
14913
+ const status = (run.status || "").toUpperCase();
14914
+ const isFinished = status === "FINISHED" || status === "SUCCESS";
14915
+ if (isFinished) {
14916
+ const anyRun2 = run;
14917
+ if (typeof anyRun2.error === "string" && isAiAuthText(anyRun2.error)) return true;
14918
+ return false;
14919
+ }
14864
14920
  const diagnosis = diagnoseOutputWarning(run);
14865
14921
  if (diagnosis?.kind === "ai_auth" || diagnosis?.isAiAuth) return true;
14866
14922
  const fail = getFailureInfo(run);
14867
14923
  if (fail && isAiAuthText(fail.reason)) return true;
14868
14924
  const anyRun = run;
14869
- if (typeof anyRun.result === "string" && isAiAuthText(anyRun.result)) return true;
14870
- if (typeof anyRun.output === "string" && isAiAuthText(anyRun.output)) return true;
14871
14925
  if (typeof anyRun.error === "string" && isAiAuthText(anyRun.error)) return true;
14872
14926
  if (Array.isArray(run.results)) {
14873
14927
  for (const r of run.results) {
14874
- if (typeof r?.result === "string" && isAiAuthText(r.result)) return true;
14875
14928
  if (typeof r?.error === "string" && isAiAuthText(r.error)) return true;
14876
14929
  }
14877
14930
  }
14878
14931
  const decisions = anyRun?.decisions;
14879
14932
  if (Array.isArray(decisions)) {
14880
14933
  for (const d of decisions) {
14881
- if (isAiAuthText(d?.reason)) return true;
14882
- if (typeof d?.output === "string" && isAiAuthText(d.output)) return true;
14883
14934
  if (typeof d?.run_details?.error === "string" && isAiAuthText(d.run_details.error)) return true;
14884
- if (typeof d?.run_details?.result === "string" && isAiAuthText(d.run_details.result)) return true;
14885
- if (Array.isArray(d?.fields)) {
14886
- for (const f of d.fields) {
14887
- if (isAiAuthText(f?.value)) return true;
14888
- }
14889
- }
14935
+ if (d?.status === "FAILED" && typeof d?.reason === "string" && isAiAuthText(d.reason)) return true;
14890
14936
  }
14891
14937
  }
14892
- const status = (run.status || "").toUpperCase();
14893
- const isFinished = status === "FINISHED";
14894
- if (isFinished) return false;
14895
14938
  return false;
14896
14939
  };
14897
14940
 
@@ -14985,7 +15028,7 @@ var AgentDiagnosisCtas = ({ diagnosis, compact = false, tone = "medium" }) => {
14985
15028
  var AgentDiagnosisCtas_default = AgentDiagnosisCtas;
14986
15029
 
14987
15030
  // components/AgentRunDiagnosisBanner.tsx
14988
- import { useEffect as useEffect15, useMemo as useMemo9, useState as useState17 } from "react";
15031
+ import { useEffect as useEffect16, useMemo as useMemo9, useState as useState18 } from "react";
14989
15032
  import { jsx as jsx28, jsxs as jsxs21 } from "react/jsx-runtime";
14990
15033
  var DISMISS_PREFIX = "agent-diagnosis-dismissed::";
14991
15034
  var readDismissed = (key) => {
@@ -15009,8 +15052,8 @@ var AgentRunDiagnosisBanner = ({ run, sx, onJumpToEvidence, onFocusContinue, exe
15009
15052
  const fromRun = run?.execution_id;
15010
15053
  return typeof fromRun === "string" && fromRun ? fromRun : null;
15011
15054
  }, [executionId, run]);
15012
- const [dismissed, setDismissed] = useState17(() => readDismissed(dismissKey));
15013
- useEffect15(() => {
15055
+ const [dismissed, setDismissed] = useState18(() => readDismissed(dismissKey));
15056
+ useEffect16(() => {
15014
15057
  setDismissed(readDismissed(dismissKey));
15015
15058
  }, [dismissKey]);
15016
15059
  if (!run || dismissed) return null;
@@ -15307,7 +15350,7 @@ var AiAuthSuggestion = ({
15307
15350
  var AiAuthSuggestion_default = AiAuthSuggestion;
15308
15351
 
15309
15352
  // components/AgentAttachmentsButton.tsx
15310
- import { useEffect as useEffect16, useState as useState18 } from "react";
15353
+ import { useEffect as useEffect17, useState as useState19 } from "react";
15311
15354
  import { Badge as Badge2, Box as Box21, IconButton as IconButton10, Popover, Tooltip as Tooltip13, Typography as Typography18 } from "@mui/material";
15312
15355
  import { Image as ImageIcon } from "lucide-react";
15313
15356
  import { Fragment as Fragment11, jsx as jsx30, jsxs as jsxs23 } from "react/jsx-runtime";
@@ -15318,9 +15361,9 @@ var toSrc = (url) => {
15318
15361
  return `data:image/png;base64,${s.replace(/\s+/g, "")}`;
15319
15362
  };
15320
15363
  var AgentAttachmentsButton = ({ attachments }) => {
15321
- const [anchorEl, setAnchorEl] = useState18(null);
15322
- const [zoomed, setZoomed] = useState18(null);
15323
- useEffect16(() => {
15364
+ const [anchorEl, setAnchorEl] = useState19(null);
15365
+ const [zoomed, setZoomed] = useState19(null);
15366
+ useEffect17(() => {
15324
15367
  if (!zoomed) return;
15325
15368
  const onKey = (e) => {
15326
15369
  if (e.key === "Escape") {
@@ -16015,6 +16058,7 @@ var DEFAULT_AGENT_CONTEXT_RULES = [
16015
16058
  defaultApps: [{ name: "shuffle_incidents" }],
16016
16059
  defaultPresetId: "incident-response",
16017
16060
  sourceCategory: "incidents",
16061
+ isBeta: true,
16018
16062
  title: (params, _, entityOverride) => {
16019
16063
  const cleanId = formatEntityDisplayId(params.id);
16020
16064
  const entity = entityOverride || getActivePageEntityName();
@@ -16036,6 +16080,7 @@ var DEFAULT_AGENT_CONTEXT_RULES = [
16036
16080
  defaultApps: [{ name: "shuffle_incidents" }],
16037
16081
  defaultPresetId: "incident-response",
16038
16082
  sourceCategory: "incidents",
16083
+ isBeta: true,
16039
16084
  title: (params, _, entityOverride) => {
16040
16085
  const cleanId = formatEntityDisplayId(params.id);
16041
16086
  const entity = entityOverride || getActivePageEntityName();
@@ -16057,6 +16102,7 @@ var DEFAULT_AGENT_CONTEXT_RULES = [
16057
16102
  defaultApps: [{ name: "shuffle_incidents" }],
16058
16103
  defaultPresetId: "incident-response",
16059
16104
  sourceCategory: "incidents",
16105
+ isBeta: true,
16060
16106
  title: (params, _, entityOverride) => {
16061
16107
  const cleanId = formatEntityDisplayId(params.id);
16062
16108
  const entity = entityOverride || getActivePageEntityName();
@@ -16078,6 +16124,7 @@ var DEFAULT_AGENT_CONTEXT_RULES = [
16078
16124
  defaultApps: [{ name: "shuffle_incidents" }],
16079
16125
  defaultPresetId: "incident-response",
16080
16126
  sourceCategory: "incidents",
16127
+ isBeta: true,
16081
16128
  title: "How can we help handle incidents?",
16082
16129
  subtitle: "Shuffle Incidents MCP",
16083
16130
  defaultPrompt: "Investigate this incident and recommend next steps: ",
@@ -16092,6 +16139,7 @@ var DEFAULT_AGENT_CONTEXT_RULES = [
16092
16139
  defaultApps: [{ name: "shuffle_incidents" }],
16093
16140
  defaultPresetId: "incident-response",
16094
16141
  sourceCategory: "incidents",
16142
+ isBeta: true,
16095
16143
  title: "How can we help handle cases?",
16096
16144
  subtitle: "Shuffle Incidents MCP",
16097
16145
  defaultPrompt: "Investigate this case and recommend next steps: ",
@@ -16106,6 +16154,7 @@ var DEFAULT_AGENT_CONTEXT_RULES = [
16106
16154
  defaultApps: [{ name: "shuffle_incidents" }],
16107
16155
  defaultPresetId: "incident-response",
16108
16156
  sourceCategory: "incidents",
16157
+ isBeta: true,
16109
16158
  title: "How can we help handle tickets?",
16110
16159
  subtitle: "Shuffle Incidents MCP",
16111
16160
  defaultPrompt: "Investigate this ticket and recommend next steps: ",
@@ -16120,6 +16169,7 @@ var DEFAULT_AGENT_CONTEXT_RULES = [
16120
16169
  defaultApps: [{ name: "shuffle_incidents" }],
16121
16170
  defaultPresetId: "incident-response",
16122
16171
  sourceCategory: "incidents",
16172
+ isBeta: true,
16123
16173
  title: "How can we help handle alerts?",
16124
16174
  subtitle: "Shuffle Incidents MCP",
16125
16175
  defaultPrompt: "Investigate this alert and recommend next steps: ",
@@ -17029,7 +17079,7 @@ var RunFinishedSummary = ({
17029
17079
  children: finishNote
17030
17080
  }
17031
17081
  ),
17032
- bottomContent
17082
+ status !== "FINISHED" && status !== "SUCCESS" && bottomContent
17033
17083
  ] });
17034
17084
  };
17035
17085
  var VERIFIED_BUILTIN_APPS = /* @__PURE__ */ new Set([
@@ -17178,8 +17228,8 @@ var isBuiltinDefaultApps = (apps) => {
17178
17228
  );
17179
17229
  };
17180
17230
  var DurationCountdown = ({ resumeAtMs }) => {
17181
- const [nowMs, setNowMs] = useState19(() => Date.now());
17182
- useEffect17(() => {
17231
+ const [nowMs, setNowMs] = useState20(() => Date.now());
17232
+ useEffect18(() => {
17183
17233
  const t = setInterval(() => setNowMs(Date.now()), 1e3);
17184
17234
  return () => clearInterval(t);
17185
17235
  }, []);
@@ -17189,8 +17239,8 @@ var DurationCountdown = ({ resumeAtMs }) => {
17189
17239
  var StatusIcon = ({ status, resumeAtMs }) => {
17190
17240
  const s = (status || "").toUpperCase();
17191
17241
  const isScheduledWait = s === "WAITING" && !!resumeAtMs;
17192
- const [nowMs, setNowMs] = useState19(() => Date.now());
17193
- useEffect17(() => {
17242
+ const [nowMs, setNowMs] = useState20(() => Date.now());
17243
+ useEffect18(() => {
17194
17244
  if (!isScheduledWait) return;
17195
17245
  const t = setInterval(() => setNowMs(Date.now()), 1e3);
17196
17246
  return () => clearInterval(t);
@@ -17233,8 +17283,8 @@ var formatAgo = (sec) => {
17233
17283
  return `${Math.floor(diff / 86400)}d ago`;
17234
17284
  };
17235
17285
  var ScheduledLiveBar = ({ startSec, originalStartTime, totalDuration, maxWidth }) => {
17236
- const [nowSec, setNowSec] = useState19(() => Date.now() / 1e3);
17237
- useEffect17(() => {
17286
+ const [nowSec, setNowSec] = useState20(() => Date.now() / 1e3);
17287
+ useEffect18(() => {
17238
17288
  const t = setInterval(() => setNowSec(Date.now() / 1e3), 1e3);
17239
17289
  return () => clearInterval(t);
17240
17290
  }, []);
@@ -17281,7 +17331,7 @@ var TimelineRow = ({
17281
17331
  dimmedByRerun = false,
17282
17332
  optimisticContinueText
17283
17333
  }) => {
17284
- const [submitAttempted, setSubmitAttempted] = useState19(false);
17334
+ const [submitAttempted, setSubmitAttempted] = useState20(false);
17285
17335
  const validate = validateJson(item.details);
17286
17336
  const screenshotPayloads = useMemo10(
17287
17337
  () => extractScreenshotPayloads(validate.valid ? validate.result : item.details),
@@ -17967,7 +18017,7 @@ var AgentUI = ({
17967
18017
  const hasApiKey = !!apiKey || !!API_CONFIG.apiKey;
17968
18018
  const isPhoneScreen = useMediaQuery("(max-width:600px)", { noSsr: true });
17969
18019
  const isPhone = mobileView !== void 0 ? mobileView : isPhoneScreen;
17970
- const [actionInput, setActionInput] = useState19(() => {
18020
+ const [actionInput, setActionInput] = useState20(() => {
17971
18021
  if (contextStorageKey) {
17972
18022
  const saved = getPageContextChoice(contextStorageKey);
17973
18023
  if (saved?.draftPrompt !== void 0 && saved.draftPrompt !== "") {
@@ -17977,7 +18027,7 @@ var AgentUI = ({
17977
18027
  return defaultInput || "";
17978
18028
  });
17979
18029
  const lastStorageKeyRef = useRef11(contextStorageKey);
17980
- useEffect17(() => {
18030
+ useEffect18(() => {
17981
18031
  if (lastStorageKeyRef.current !== contextStorageKey) {
17982
18032
  lastStorageKeyRef.current = contextStorageKey;
17983
18033
  if (contextStorageKey) {
@@ -17991,18 +18041,18 @@ var AgentUI = ({
17991
18041
  }
17992
18042
  }, [contextStorageKey, defaultInput]);
17993
18043
  const prevDefaultInputRef = useRef11(defaultInput);
17994
- useEffect17(() => {
18044
+ useEffect18(() => {
17995
18045
  if (defaultInput && defaultInput !== prevDefaultInputRef.current) {
17996
18046
  prevDefaultInputRef.current = defaultInput;
17997
18047
  setActionInput(defaultInput);
17998
18048
  }
17999
18049
  }, [defaultInput]);
18000
18050
  const { prompt: savedPromptPrefix } = useAgentPromptPrefix({ userId, persist: !disableStartTab });
18001
- const [selectedPreset, setSelectedPreset] = useState19(null);
18051
+ const [selectedPreset, setSelectedPreset] = useState20(null);
18002
18052
  const presetsChipNodeRef = useRef11(null);
18003
- const [presetsChipWidth, setPresetsChipWidth] = useState19(0);
18004
- const [inputScrolled, setInputScrolled] = useState19(false);
18005
- const [inputScrollTop, setInputScrollTop] = useState19(0);
18053
+ const [presetsChipWidth, setPresetsChipWidth] = useState20(0);
18054
+ const [inputScrolled, setInputScrolled] = useState20(false);
18055
+ const [inputScrollTop, setInputScrollTop] = useState20(0);
18006
18056
  const chipOverlayRef = useRef11(null);
18007
18057
  const applyChipScroll = useCallback10((st) => {
18008
18058
  const el = chipOverlayRef.current;
@@ -18017,9 +18067,9 @@ var AgentUI = ({
18017
18067
  el.style.opacity = st > 24 ? "0" : "1";
18018
18068
  el.style.pointerEvents = st > 4 ? "none" : "auto";
18019
18069
  }, []);
18020
- const [promptSingleLine, setPromptSingleLine] = useState19(true);
18070
+ const [promptSingleLine, setPromptSingleLine] = useState20(true);
18021
18071
  const promptMultilineBase = !promptSingleLine;
18022
- const [attachmentsRowHeight, setAttachmentsRowHeight] = useState19(0);
18072
+ const [attachmentsRowHeight, setAttachmentsRowHeight] = useState20(0);
18023
18073
  const attachmentsRowRef = useCallback10((node) => {
18024
18074
  setAttachmentsRowHeight(node ? node.getBoundingClientRect().height : 0);
18025
18075
  }, []);
@@ -18029,7 +18079,7 @@ var AgentUI = ({
18029
18079
  }, []);
18030
18080
  const inputRef = useRef11(null);
18031
18081
  const seededPresetIdRef = useRef11(null);
18032
- useEffect17(() => {
18082
+ useEffect18(() => {
18033
18083
  if (!initialPresetId && defaultInput && defaultInput.trim().length > 0) {
18034
18084
  setSelectedPreset(null);
18035
18085
  return;
@@ -18084,7 +18134,7 @@ var AgentUI = ({
18084
18134
  ro?.disconnect();
18085
18135
  };
18086
18136
  }, [selectedPreset, hidePresets, presets, actionInput]);
18087
- useEffect17(() => {
18137
+ useEffect18(() => {
18088
18138
  const el = inputRef.current;
18089
18139
  if (!el) return;
18090
18140
  if (el.scrollTop <= 1 && inputScrolled) setInputScrolled(false);
@@ -18149,7 +18199,7 @@ var AgentUI = ({
18149
18199
  };
18150
18200
  }, [actionInput, presetsChipWidth, selectedPreset, hidePresets]);
18151
18201
  const shouldTypewrite = placeholder === void 0;
18152
- const [fullPlaceholder, setFullPlaceholder] = useState19(
18202
+ const [fullPlaceholder, setFullPlaceholder] = useState20(
18153
18203
  () => placeholder ?? getRandomAgentPromptPlaceholder()
18154
18204
  );
18155
18205
  const pickedPlaceholderRef = useRef11(null);
@@ -18180,10 +18230,10 @@ var AgentUI = ({
18180
18230
  pickedPlaceholderRef.current = picked;
18181
18231
  setFullPlaceholder(picked);
18182
18232
  }, [shouldTypewrite, presetsChipWidth, hidePresets]);
18183
- const [typedPlaceholder, setTypedPlaceholder] = useState19(
18233
+ const [typedPlaceholder, setTypedPlaceholder] = useState20(
18184
18234
  shouldTypewrite ? "" : fullPlaceholder
18185
18235
  );
18186
- useEffect17(() => {
18236
+ useEffect18(() => {
18187
18237
  if (!shouldTypewrite) {
18188
18238
  setTypedPlaceholder(fullPlaceholder);
18189
18239
  return;
@@ -18217,14 +18267,14 @@ var AgentUI = ({
18217
18267
  [propComposeSubmitInput]
18218
18268
  );
18219
18269
  const promptAnchorRef = React6.useRef(null);
18220
- const [suggestionsDismissed, setSuggestionsDismissed] = useState19(false);
18221
- const [suggestionIndex, setSuggestionIndex] = useState19(-1);
18270
+ const [suggestionsDismissed, setSuggestionsDismissed] = useState20(false);
18271
+ const [suggestionIndex, setSuggestionIndex] = useState20(-1);
18222
18272
  const promptSuggestions = useMemo10(
18223
18273
  () => matchAgentPromptSuggestions(actionInput, 8),
18224
18274
  [actionInput]
18225
18275
  );
18226
18276
  const programmaticInputRef = useRef11(false);
18227
- useEffect17(() => {
18277
+ useEffect18(() => {
18228
18278
  if (programmaticInputRef.current) {
18229
18279
  programmaticInputRef.current = false;
18230
18280
  return;
@@ -18233,7 +18283,7 @@ var AgentUI = ({
18233
18283
  setSuggestionsDismissed(false);
18234
18284
  }, [actionInput]);
18235
18285
  const suggestionsOpen = promptSuggestions.length > 0 && !suggestionsDismissed;
18236
- const [pendingCategories, setPendingCategories] = useState19([]);
18286
+ const [pendingCategories, setPendingCategories] = useState20([]);
18237
18287
  const acceptSuggestion = useCallback10((s) => {
18238
18288
  programmaticInputRef.current = true;
18239
18289
  setActionInput(s);
@@ -18266,7 +18316,7 @@ var AgentUI = ({
18266
18316
  { name: "http" },
18267
18317
  { name: "shuffle_tools" }
18268
18318
  ];
18269
- const [chosenApps, setChosenApps] = useState19(() => {
18319
+ const [chosenApps, setChosenApps] = useState20(() => {
18270
18320
  if (apps) return apps;
18271
18321
  if (defaultApps !== void 0) return defaultApps.slice(0, MAX_AUTO_ASSIGNED_TOOLS);
18272
18322
  const saved = readPresetAppsOverride(NO_PRESET_KEY);
@@ -18275,23 +18325,23 @@ var AgentUI = ({
18275
18325
  });
18276
18326
  const isInitialMountChosenAppsRef = useRef11(true);
18277
18327
  const isInitialMountPresetOverrideRef = useRef11(true);
18278
- const [availableApps, setAvailableApps] = useState19([]);
18279
- const [authAppsLoading, setAuthAppsLoading] = useState19(autoLoadApps && hasApiKey);
18280
- const [detectedLLM, setDetectedLLM] = useState19(null);
18281
- const [configuredLLMOptions, setConfiguredLLMOptions] = useState19([]);
18282
- const [llmMenuAnchor, setLlmMenuAnchor] = useState19(null);
18283
- const [executionApps, setExecutionApps] = useState19([]);
18284
- const [resolvedToolApps, setResolvedToolApps] = useState19({});
18285
- const [appSearchOpen, setAppSearchOpen] = useState19(false);
18286
- const [appSearchQuery, setAppSearchQuery] = useState19("");
18287
- const [categoryTarget, setCategoryTarget] = useState19(null);
18288
- const [authDrawerApp, setAuthDrawerApp] = useState19(null);
18289
- const [agentRequestLoading, setAgentRequestLoading] = useState19(false);
18290
- const [rerunningDecisionId, setRerunningDecisionId] = useState19(null);
18328
+ const [availableApps, setAvailableApps] = useState20([]);
18329
+ const [authAppsLoading, setAuthAppsLoading] = useState20(autoLoadApps && hasApiKey);
18330
+ const [detectedLLM, setDetectedLLM] = useState20(null);
18331
+ const [configuredLLMOptions, setConfiguredLLMOptions] = useState20([]);
18332
+ const [llmMenuAnchor, setLlmMenuAnchor] = useState20(null);
18333
+ const [executionApps, setExecutionApps] = useState20([]);
18334
+ const [resolvedToolApps, setResolvedToolApps] = useState20({});
18335
+ const [appSearchOpen, setAppSearchOpen] = useState20(false);
18336
+ const [appSearchQuery, setAppSearchQuery] = useState20("");
18337
+ const [categoryTarget, setCategoryTarget] = useState20(null);
18338
+ const [authDrawerApp, setAuthDrawerApp] = useState20(null);
18339
+ const [agentRequestLoading, setAgentRequestLoading] = useState20(false);
18340
+ const [rerunningDecisionId, setRerunningDecisionId] = useState20(null);
18291
18341
  const rerunDecisionsSigRef = useRef11("");
18292
- const [rerunAgentPending, setRerunAgentPending] = useState19(false);
18293
- const [abortLoading, setAbortLoading] = useState19(false);
18294
- const [execution, setExecution] = useState19(() => {
18342
+ const [rerunAgentPending, setRerunAgentPending] = useState20(false);
18343
+ const [abortLoading, setAbortLoading] = useState20(false);
18344
+ const [execution, setExecution] = useState20(() => {
18295
18345
  if (initialExecution) return initialExecution;
18296
18346
  if (contextStorageKey) {
18297
18347
  const saved = getPageContextChoice(contextStorageKey);
@@ -18305,13 +18355,13 @@ var AgentUI = ({
18305
18355
  }
18306
18356
  return null;
18307
18357
  });
18308
- const [agentData, setAgentData] = useState19({});
18309
- const [agentActionResult, setAgentActionResult] = useState19(null);
18358
+ const [agentData, setAgentData] = useState20({});
18359
+ const [agentActionResult, setAgentActionResult] = useState20(null);
18310
18360
  const llmImageAttachments = useMemo10(
18311
18361
  () => collectLlmImageAttachments(agentData),
18312
18362
  [agentData]
18313
18363
  );
18314
- const [showStarter, setShowStarter] = useState19(() => {
18364
+ const [showStarter, setShowStarter] = useState20(() => {
18315
18365
  if (initialExecution?.execution_id) return false;
18316
18366
  if (contextStorageKey) {
18317
18367
  const saved = getPageContextChoice(contextStorageKey);
@@ -18355,40 +18405,40 @@ var AgentUI = ({
18355
18405
  }
18356
18406
  }, 0);
18357
18407
  }, [onSelectPreset]);
18358
- const [scheduleAnchor, setScheduleAnchor] = useState19(null);
18359
- const [mobilePlusAnchor, setMobilePlusAnchor] = useState19(null);
18360
- const [scheduleCron, setScheduleCron] = useState19("0 * * * *");
18361
- const [scheduleSaving, setScheduleSaving] = useState19(false);
18362
- const [scheduleSteps, setScheduleSteps] = useState19([
18408
+ const [scheduleAnchor, setScheduleAnchor] = useState20(null);
18409
+ const [mobilePlusAnchor, setMobilePlusAnchor] = useState20(null);
18410
+ const [scheduleCron, setScheduleCron] = useState20("0 * * * *");
18411
+ const [scheduleSaving, setScheduleSaving] = useState20(false);
18412
+ const [scheduleSteps, setScheduleSteps] = useState20([
18363
18413
  { id: "name", state: "pending" },
18364
18414
  { id: "workflow", state: "pending" },
18365
18415
  { id: "schedule", state: "pending" }
18366
18416
  ]);
18367
- const [schedFreq, setSchedFreq] = useState19("hours");
18368
- const [schedInterval, setSchedInterval] = useState19(1);
18369
- const [schedHour, setSchedHour] = useState19(9);
18370
- const [schedMinute, setSchedMinute] = useState19(0);
18371
- const [schedWeekdays, setSchedWeekdays] = useState19(() => /* @__PURE__ */ new Set([1]));
18372
- const [schedDayOfMonth, setSchedDayOfMonth] = useState19(1);
18373
- const [schedAdvancedOpen, setSchedAdvancedOpen] = useState19(false);
18417
+ const [schedFreq, setSchedFreq] = useState20("hours");
18418
+ const [schedInterval, setSchedInterval] = useState20(1);
18419
+ const [schedHour, setSchedHour] = useState20(9);
18420
+ const [schedMinute, setSchedMinute] = useState20(0);
18421
+ const [schedWeekdays, setSchedWeekdays] = useState20(() => /* @__PURE__ */ new Set([1]));
18422
+ const [schedDayOfMonth, setSchedDayOfMonth] = useState20(1);
18423
+ const [schedAdvancedOpen, setSchedAdvancedOpen] = useState20(false);
18374
18424
  const cronManualOverrideRef = useRef11(false);
18375
- const [openIndexes, setOpenIndexes] = useState19(/* @__PURE__ */ new Set());
18376
- const [highlightedIndex, setHighlightedIndex] = useState19(null);
18377
- const [continueHighlighted, setContinueHighlighted] = useState19(false);
18378
- const [questionAnswers, setQuestionAnswers] = useState19({});
18379
- const [simpleSubmitAttempted, setSimpleSubmitAttempted] = useState19(false);
18380
- const [finishAnswerRaw, setFinishAnswerRaw] = useState19(false);
18381
- const [continuationText, setContinuationText] = useState19("");
18382
- const [runComplete, setRunComplete] = useState19(false);
18383
- const [optimisticContinue, setOptimisticContinue] = useState19(null);
18425
+ const [openIndexes, setOpenIndexes] = useState20(/* @__PURE__ */ new Set());
18426
+ const [highlightedIndex, setHighlightedIndex] = useState20(null);
18427
+ const [continueHighlighted, setContinueHighlighted] = useState20(false);
18428
+ const [questionAnswers, setQuestionAnswers] = useState20({});
18429
+ const [simpleSubmitAttempted, setSimpleSubmitAttempted] = useState20(false);
18430
+ const [finishAnswerRaw, setFinishAnswerRaw] = useState20(false);
18431
+ const [continuationText, setContinuationText] = useState20("");
18432
+ const [runComplete, setRunComplete] = useState20(false);
18433
+ const [optimisticContinue, setOptimisticContinue] = useState20(null);
18384
18434
  const continuationInputRef = useRef11(null);
18385
18435
  const continuationFocusedForRef = useRef11(null);
18386
- const [error, setError] = useState19(null);
18387
- const [pollWarning, setPollWarning] = useState19(null);
18436
+ const [error, setError] = useState20(null);
18437
+ const [pollWarning, setPollWarning] = useState20(null);
18388
18438
  const hasExecutionDataRef = useRef11(false);
18389
18439
  const loadedExecutionIdRef = useRef11(null);
18390
18440
  const keepPollingUntilRef = useRef11(0);
18391
- const [runExplorerAvailable, setRunExplorerAvailable] = useState19("checking");
18441
+ const [runExplorerAvailable, setRunExplorerAvailable] = useState20("checking");
18392
18442
  const [searchParams, setSearchParams] = useSearchParams();
18393
18443
  const initialViewParam = searchParams.get("agentView");
18394
18444
  const readStoredViewMode = () => {
@@ -18407,8 +18457,8 @@ var AgentUI = ({
18407
18457
  }
18408
18458
  return "simple";
18409
18459
  };
18410
- const [viewMode, setViewMode] = useState19(readStoredViewMode);
18411
- useEffect17(() => {
18460
+ const [viewMode, setViewMode] = useState20(readStoredViewMode);
18461
+ useEffect18(() => {
18412
18462
  try {
18413
18463
  if (typeof window !== "undefined") {
18414
18464
  window.localStorage.setItem("shuffle-agents-view-mode", viewMode);
@@ -18416,15 +18466,15 @@ var AgentUI = ({
18416
18466
  } catch {
18417
18467
  }
18418
18468
  }, [viewMode]);
18419
- const [attachedImages, setAttachedImages] = useState19([]);
18420
- const [previewImage, setPreviewImage] = useState19(null);
18469
+ const [attachedImages, setAttachedImages] = useState20([]);
18470
+ const [previewImage, setPreviewImage] = useState20(null);
18421
18471
  const promptMultiline = promptMultilineBase || attachedImages.length > 0 || isPhone && Boolean(selectedPreset);
18422
18472
  const promptSingleLineLocked = !promptMultiline;
18423
- const [nowTick, setNowTick] = useState19(() => Math.floor(Date.now() / 1e3));
18424
- const [localRunStart, setLocalRunStart] = useState19(null);
18473
+ const [nowTick, setNowTick] = useState20(() => Math.floor(Date.now() / 1e3));
18474
+ const [localRunStart, setLocalRunStart] = useState20(null);
18425
18475
  const chipBarRef = useRef11(null);
18426
18476
  const chipBarResizeObserverRef = useRef11(null);
18427
- const [chipBarMultiline, setChipBarMultiline] = useState19(false);
18477
+ const [chipBarMultiline, setChipBarMultiline] = useState20(false);
18428
18478
  const fileInputRef = useRef11(null);
18429
18479
  const chipBarCallbackRef = useCallback10((node) => {
18430
18480
  chipBarRef.current = node;
@@ -18444,7 +18494,7 @@ var AgentUI = ({
18444
18494
  }
18445
18495
  }, []);
18446
18496
  const activeExecutionIdRef = useRef11(
18447
- initialExecution?.execution_id || (contextStorageKey ? getPageContextChoice(contextStorageKey)?.executionId || null : null)
18497
+ executionId || initialExecution?.execution_id || (contextStorageKey ? getPageContextChoice(contextStorageKey)?.executionId || null : null)
18448
18498
  );
18449
18499
  const executionPollGenerationRef = useRef11(0);
18450
18500
  const runAbortRef = useRef11(null);
@@ -18468,25 +18518,25 @@ var AgentUI = ({
18468
18518
  stateRef.current.continuationText = continuationText;
18469
18519
  stateRef.current.localRunStart = localRunStart;
18470
18520
  stateRef.current.showStarter = showStarter;
18471
- useEffect17(() => {
18521
+ useEffect18(() => {
18472
18522
  const el = chipBarRef.current;
18473
18523
  if (el) {
18474
18524
  setChipBarMultiline(el.clientHeight > 42 || el.scrollHeight > 42);
18475
18525
  }
18476
18526
  }, [chosenApps, availableApps, selectedPreset]);
18477
- useEffect17(() => {
18527
+ useEffect18(() => {
18478
18528
  return () => {
18479
18529
  chipBarResizeObserverRef.current?.disconnect();
18480
18530
  };
18481
18531
  }, []);
18482
- useEffect17(() => {
18532
+ useEffect18(() => {
18483
18533
  if (execution?.execution_id || agentRequestLoading) {
18484
18534
  setLocalRunStart((prev) => prev ?? Math.floor(Date.now() / 1e3));
18485
18535
  } else {
18486
18536
  setLocalRunStart(null);
18487
18537
  }
18488
18538
  }, [execution?.execution_id, agentRequestLoading]);
18489
- useEffect17(() => {
18539
+ useEffect18(() => {
18490
18540
  if (!execution?.execution_id && !agentRequestLoading) return;
18491
18541
  const status = (execution?.status || agentData?.status || "").toUpperCase();
18492
18542
  const TERMINAL = ["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"];
@@ -18573,10 +18623,10 @@ var AgentUI = ({
18573
18623
  }
18574
18624
  return out;
18575
18625
  }, [agentData, appsById, authAppsLoading, isAppAuthenticated]);
18576
- useEffect17(() => {
18626
+ useEffect18(() => {
18577
18627
  if (apps) setChosenApps(apps);
18578
18628
  }, [apps]);
18579
- useEffect17(() => {
18629
+ useEffect18(() => {
18580
18630
  const required = selectedPreset?.requiredApps;
18581
18631
  if (!required || required.length === 0) return;
18582
18632
  setChosenApps((prev) => {
@@ -18585,7 +18635,7 @@ var AgentUI = ({
18585
18635
  return [...prev, ...missing.map((name) => ({ name }))];
18586
18636
  });
18587
18637
  }, [selectedPreset]);
18588
- useEffect17(() => {
18638
+ useEffect18(() => {
18589
18639
  const decisions = agentData?.decisions || [];
18590
18640
  if (!Array.isArray(decisions) || decisions.length === 0) return;
18591
18641
  const norm4 = (s) => s.toLowerCase().replace(/[\s-]+/g, "_");
@@ -18633,7 +18683,7 @@ var AgentUI = ({
18633
18683
  cancelled = true;
18634
18684
  };
18635
18685
  }, [JSON.stringify(agentData?.decisions?.map((d) => [d?.details?.tool || d?.tool, extractAuthRequest(d)?.appName]) || []), appsById]);
18636
- useEffect17(() => {
18686
+ useEffect18(() => {
18637
18687
  const missing = chosenApps.filter((a) => !a.icon && a.name);
18638
18688
  if (missing.length === 0) return;
18639
18689
  let cancelled = false;
@@ -18792,7 +18842,7 @@ var AgentUI = ({
18792
18842
  if (!signal?.cancelled) setAuthAppsLoading(false);
18793
18843
  }
18794
18844
  }, [resolveUrl2, resolveHeaders2, contextCategory, contextStorageKey, defaultApps, onAppsChange]);
18795
- useEffect17(() => {
18845
+ useEffect18(() => {
18796
18846
  if (!autoLoadApps) return;
18797
18847
  if (!hasApiKey) return;
18798
18848
  const signal = { cancelled: false };
@@ -18801,7 +18851,7 @@ var AgentUI = ({
18801
18851
  signal.cancelled = true;
18802
18852
  };
18803
18853
  }, [autoLoadApps, hasApiKey, loadAuthenticatedApps]);
18804
- useEffect17(() => {
18854
+ useEffect18(() => {
18805
18855
  if (!hasApiKey) return;
18806
18856
  const handler = (event) => {
18807
18857
  const customEvent = event;
@@ -18816,7 +18866,7 @@ var AgentUI = ({
18816
18866
  window.addEventListener("integrations-changed", handler);
18817
18867
  return () => window.removeEventListener("integrations-changed", handler);
18818
18868
  }, [hasApiKey, loadAuthenticatedApps]);
18819
- useEffect17(() => {
18869
+ useEffect18(() => {
18820
18870
  const raw = agentData?.allowed_actions;
18821
18871
  if (!Array.isArray(raw) || raw.length === 0) {
18822
18872
  setExecutionApps([]);
@@ -19006,7 +19056,7 @@ var AgentUI = ({
19006
19056
  else setPollWarning(`Live updates are failing (${err instanceof Error ? err.message : "network error"}). Showing the last known state.`);
19007
19057
  }
19008
19058
  }, []);
19009
- useEffect17(() => {
19059
+ useEffect18(() => {
19010
19060
  const eid = execution?.execution_id;
19011
19061
  const auth = execution?.authorization;
19012
19062
  if (!eid) {
@@ -19033,19 +19083,19 @@ var AgentUI = ({
19033
19083
  cancelled = true;
19034
19084
  };
19035
19085
  }, [execution?.execution_id, execution?.authorization]);
19036
- useEffect17(() => {
19086
+ useEffect18(() => {
19037
19087
  if (execution?.authorization && (execution?.results?.length || 0) > 0) {
19038
19088
  setRunExplorerAvailable("yes");
19039
19089
  }
19040
19090
  }, [execution?.authorization, execution?.results?.length]);
19041
- useEffect17(() => {
19091
+ useEffect18(() => {
19042
19092
  let eid = null;
19043
19093
  let auth = null;
19044
19094
  let initialStatus = "EXECUTING";
19045
19095
  let savedViewMode = null;
19046
- if (executionId && authorization) {
19096
+ if (executionId) {
19047
19097
  eid = executionId;
19048
- auth = authorization;
19098
+ auth = authorization || null;
19049
19099
  } else if (readUrlParams) {
19050
19100
  const params = new URLSearchParams(window.location.search);
19051
19101
  eid = params.get("execution_id");
@@ -19074,7 +19124,7 @@ var AgentUI = ({
19074
19124
  getExecution(eid, auth || void 0);
19075
19125
  }
19076
19126
  }, [readUrlParams, executionId, authorization, getExecution, contextStorageKey]);
19077
- useEffect17(() => {
19127
+ useEffect18(() => {
19078
19128
  if (!initialExecution || !initialExecution.execution_id) return;
19079
19129
  if (!userPickedStartRef.current) setShowStarter(false);
19080
19130
  activeExecutionIdRef.current = initialExecution.execution_id;
@@ -19109,7 +19159,7 @@ var AgentUI = ({
19109
19159
  getExecution(initialExecution.execution_id, initialExecution.authorization);
19110
19160
  }
19111
19161
  }, [initialExecution?.execution_id]);
19112
- useEffect17(() => {
19162
+ useEffect18(() => {
19113
19163
  if (!execution?.execution_id) return;
19114
19164
  const status = (execution.status || "").toUpperCase();
19115
19165
  const TERMINAL = ["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"];
@@ -19313,13 +19363,13 @@ var AgentUI = ({
19313
19363
  onRun?.({ input: text2, success: true, executionId: eid });
19314
19364
  }
19315
19365
  }, [chosenApps, executionApps, getExecution, onRun, attachedImages, readUrlParams, setSearchParams, viewMode, selectedPreset, isLoggedIn]);
19316
- const autoSubmittedRef = useRef11(false);
19317
- useEffect17(() => {
19318
- if (autoSubmit && defaultInput && !autoSubmittedRef.current && !executionId) {
19319
- autoSubmittedRef.current = true;
19366
+ const lastSubmittedInputRef = useRef11(null);
19367
+ useEffect18(() => {
19368
+ if (autoSubmit && defaultInput && defaultInput !== lastSubmittedInputRef.current) {
19369
+ lastSubmittedInputRef.current = defaultInput;
19320
19370
  submitInput(defaultInput);
19321
19371
  }
19322
- }, [autoSubmit, defaultInput, executionId, submitInput]);
19372
+ }, [autoSubmit, defaultInput, submitInput]);
19323
19373
  const submitQuestions = useCallback10(async (decisionId, answers, isContinuation) => {
19324
19374
  if (!execution?.execution_id || !execution?.authorization) return;
19325
19375
  let newArgument = {};
@@ -19495,7 +19545,7 @@ var AgentUI = ({
19495
19545
  }
19496
19546
  setTimeout(() => setRerunAgentPending(false), 8e3);
19497
19547
  }, [resolveRunInput, resolveRunTemplate, actionInput, executionApps, disableStartTab, submitInput]);
19498
- useEffect17(() => {
19548
+ useEffect18(() => {
19499
19549
  if (rerunAgentPending && (agentRequestLoading || execution?.execution_id)) {
19500
19550
  setRerunAgentPending(false);
19501
19551
  }
@@ -19566,7 +19616,7 @@ var AgentUI = ({
19566
19616
  setAbortLoading(false);
19567
19617
  }
19568
19618
  }, [execution, resolveUrl2, resolveHeaders2, getExecution, setSearchParams]);
19569
- useEffect17(() => {
19619
+ useEffect18(() => {
19570
19620
  if (execution?.execution_id) setLastOpenedAgentRun(execution.execution_id);
19571
19621
  }, [execution?.execution_id]);
19572
19622
  const getFormUrl = useCallback10((decisionId) => {
@@ -19631,7 +19681,7 @@ var AgentUI = ({
19631
19681
  setAgentRequestLoading(false);
19632
19682
  }
19633
19683
  }, [execution, agentActionResult, agentData, getExecution, resolveUrl2, resolveHeaders2]);
19634
- useEffect17(() => {
19684
+ useEffect18(() => {
19635
19685
  if (!rerunningDecisionId) return;
19636
19686
  const sig = JSON.stringify(
19637
19687
  (agentData?.decisions || []).map((d) => d?.run_details?.id || "")
@@ -19646,8 +19696,8 @@ var AgentUI = ({
19646
19696
  const runStillExecuting = Boolean(execution?.execution_id || agentRequestLoading) && !TERMINAL_RUN_STATUSES.includes(
19647
19697
  resolveRunStatus(execution?.status, agentData?.status)
19648
19698
  );
19649
- const [liveNowSec, setLiveNowSec] = useState19(() => Date.now() / 1e3);
19650
- useEffect17(() => {
19699
+ const [liveNowSec, setLiveNowSec] = useState20(() => Date.now() / 1e3);
19700
+ useEffect18(() => {
19651
19701
  if (!runStillExecuting) return;
19652
19702
  setLiveNowSec(Date.now() / 1e3);
19653
19703
  const t = setInterval(() => setLiveNowSec(Date.now() / 1e3), 1e3);
@@ -19839,7 +19889,7 @@ var AgentUI = ({
19839
19889
  const total = Math.max(1, end - startSafe);
19840
19890
  return { timeline: items, originalStartTime: startSafe, totalDuration: total, finishDecisionId: finishId, finishAnswer: finishAns, finishNote: finishNote2 };
19841
19891
  }, [agentData, execution?.status, execution?.started_at, execution?.completed_at, runStillExecuting, liveNowSec]);
19842
- useEffect17(() => {
19892
+ useEffect18(() => {
19843
19893
  const status = (execution?.status || "").toUpperCase();
19844
19894
  const isTerminal = ["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(status);
19845
19895
  const hasPendingDecision = (agentData?.decisions || []).some((d) => {
@@ -19848,7 +19898,25 @@ var AgentUI = ({
19848
19898
  });
19849
19899
  setRunComplete(Boolean(isTerminal && !hasPendingDecision && (finishAnswer || finishDecisionId)));
19850
19900
  }, [execution?.status, agentData?.decisions, finishAnswer, finishDecisionId]);
19851
- useEffect17(() => {
19901
+ useEffect18(() => {
19902
+ const eid = execution?.execution_id || activeExecutionIdRef.current;
19903
+ const status = (execution?.status || agentData?.status || "").toUpperCase();
19904
+ if (!eid || !status || typeof window === "undefined") return;
19905
+ if (status === "FINISHED" || status === "SUCCESS") {
19906
+ window.dispatchEvent(
19907
+ new CustomEvent("shuffle:agent_execution_status", {
19908
+ detail: { executionId: eid, status: "completed" }
19909
+ })
19910
+ );
19911
+ } else if (["FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(status)) {
19912
+ window.dispatchEvent(
19913
+ new CustomEvent("shuffle:agent_execution_status", {
19914
+ detail: { executionId: eid, status: "failed" }
19915
+ })
19916
+ );
19917
+ }
19918
+ }, [execution?.execution_id, execution?.status, agentData?.status]);
19919
+ useEffect18(() => {
19852
19920
  if (!finishDecisionId || agentRequestLoading) return;
19853
19921
  if (continuationFocusedForRef.current === finishDecisionId) return;
19854
19922
  continuationFocusedForRef.current = finishDecisionId;
@@ -19876,15 +19944,19 @@ var AgentUI = ({
19876
19944
  }
19877
19945
  }, [onChooseLLM]);
19878
19946
  const isAiAuthIssue = useMemo10(() => {
19947
+ const status = (execution?.status || agentData?.status || "").toUpperCase();
19948
+ const isFinished = status === "FINISHED" || status === "SUCCESS";
19949
+ if (isFinished && !isAiAuthText(error)) {
19950
+ return false;
19951
+ }
19879
19952
  if (finishAnswer && finishAnswer.trim().length > 0 && !isAiAuthText(finishAnswer)) {
19880
- const diagnosable2 = execution?.results?.length ? execution : agentData;
19881
- if (!isAiAuthFailure(diagnosable2, error || "")) return false;
19953
+ return false;
19882
19954
  }
19883
19955
  const diagnosable = execution?.results?.length ? execution : agentData;
19884
- return isAiAuthFailure(diagnosable, error || finishAnswer || "");
19956
+ return isAiAuthFailure(diagnosable, error || "");
19885
19957
  }, [execution, agentData, finishAnswer, error]);
19886
19958
  const aiAuthSuggestionNode = isAiAuthIssue ? /* @__PURE__ */ jsx31(Box22, { sx: { mt: 1.5 }, children: /* @__PURE__ */ jsx31(AiAuthSuggestion_default, { onOpenLocalLlm: openLocalLlmArea }) }) : null;
19887
- useEffect17(() => {
19959
+ useEffect18(() => {
19888
19960
  if (!optimisticContinue) return;
19889
19961
  const count = (agentData?.decisions || []).length;
19890
19962
  if (count > optimisticContinue.decisions) {
@@ -19935,7 +20007,7 @@ var AgentUI = ({
19935
20007
  };
19936
20008
  const timelineEndRef = useRef11(null);
19937
20009
  const followTimelineRef = useRef11(true);
19938
- useEffect17(() => {
20010
+ useEffect18(() => {
19939
20011
  if (typeof window === "undefined") return;
19940
20012
  const getScrollParent = (node) => {
19941
20013
  let el = node?.parentElement || null;
@@ -19975,7 +20047,7 @@ var AgentUI = ({
19975
20047
  const runIsLive = optimisticRunning || !["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(
19976
20048
  (resolveRunStatus(execution?.status, agentData?.status) || "EXECUTING").toUpperCase()
19977
20049
  );
19978
- useEffect17(() => {
20050
+ useEffect18(() => {
19979
20051
  if (typeof window === "undefined") return;
19980
20052
  if (viewMode !== "detailed") return;
19981
20053
  if (!runIsLive) return;
@@ -19993,7 +20065,7 @@ var AgentUI = ({
19993
20065
  window.clearTimeout(t);
19994
20066
  };
19995
20067
  }, [timelineCount, viewMode, runIsLive]);
19996
- useEffect17(() => {
20068
+ useEffect18(() => {
19997
20069
  followTimelineRef.current = true;
19998
20070
  }, [execution?.execution_id]);
19999
20071
  const handlePrimarySubmit = useCallback10(() => {
@@ -20041,17 +20113,17 @@ var AgentUI = ({
20041
20113
  const activeTab = showStarter ? "start" : viewMode;
20042
20114
  const hasExecution = !!execution?.execution_id;
20043
20115
  const showRunSwitcher = hasExecution || agentRequestLoading;
20044
- useEffect17(() => {
20116
+ useEffect18(() => {
20045
20117
  onViewChange?.(activeTab);
20046
20118
  }, [activeTab, onViewChange]);
20047
- useEffect17(() => {
20119
+ useEffect18(() => {
20048
20120
  if (isInitialMountChosenAppsRef.current) {
20049
20121
  isInitialMountChosenAppsRef.current = false;
20050
20122
  return;
20051
20123
  }
20052
20124
  onAppsChange?.(chosenApps);
20053
20125
  }, [chosenApps, onAppsChange]);
20054
- useEffect17(() => {
20126
+ useEffect18(() => {
20055
20127
  if (isInitialMountPresetOverrideRef.current) {
20056
20128
  isInitialMountPresetOverrideRef.current = false;
20057
20129
  return;
@@ -20184,7 +20256,7 @@ var AgentUI = ({
20184
20256
  return parsed && parsed.once ? null : parsed;
20185
20257
  }, [actionInput]);
20186
20258
  const lastAppliedHintRef = useRef11(null);
20187
- useEffect17(() => {
20259
+ useEffect18(() => {
20188
20260
  if (!scheduleHint) return;
20189
20261
  if (scheduleAnchor) return;
20190
20262
  if (lastAppliedHintRef.current === scheduleHint.cron) return;
@@ -20214,7 +20286,7 @@ var AgentUI = ({
20214
20286
  return appRequiresAuthentication(slug) && !isAppAuthenticated(a.name || "", a.id || null);
20215
20287
  });
20216
20288
  }, [authAppsLoading, chosenApps, isAppAuthenticated]);
20217
- useEffect17(() => {
20289
+ useEffect18(() => {
20218
20290
  if (cronManualOverrideRef.current) return;
20219
20291
  const m = Math.max(0, Math.min(59, schedMinute));
20220
20292
  const h = Math.max(0, Math.min(23, schedHour));
@@ -22971,7 +23043,7 @@ var AgentUI = ({
22971
23043
  var AgentUI_default = AgentUI;
22972
23044
 
22973
23045
  // components/AgentRunDrawer.tsx
22974
- import { useEffect as useEffect19, useRef as useRef13, useState as useState21 } from "react";
23046
+ import { useEffect as useEffect20, useRef as useRef13, useState as useState22 } from "react";
22975
23047
  import {
22976
23048
  Box as Box25,
22977
23049
  Drawer as Drawer4,
@@ -22989,7 +23061,7 @@ import {
22989
23061
  } from "lucide-react";
22990
23062
 
22991
23063
  // components/LocalLLMConfig.tsx
22992
- import { useEffect as useEffect18, useMemo as useMemo11, useRef as useRef12, useState as useState20 } from "react";
23064
+ import { useEffect as useEffect19, useMemo as useMemo11, useRef as useRef12, useState as useState21 } from "react";
22993
23065
  import { Check } from "lucide-react";
22994
23066
  import {
22995
23067
  Autocomplete as Autocomplete2,
@@ -23158,7 +23230,7 @@ var PROVIDER_MODELS = {
23158
23230
  "LM Studio (localhost)": ["qwen-3.6-27b", "llama-4-16x17b-instruct", "deepseek-v4-flash", "qwen3-32b", "llama-3.3-70b-instruct", "deepseek-r1-distill-qwen-32b", "mistral-small-4", "phi-4", "gemma-3-27b"]
23159
23231
  };
23160
23232
  var ProviderLogo = ({ label, url }) => {
23161
- const [errored, setErrored] = useState20(false);
23233
+ const [errored, setErrored] = useState21(false);
23162
23234
  let domain = PROVIDER_DOMAINS[label];
23163
23235
  if (!domain && url) {
23164
23236
  try {
@@ -23174,8 +23246,8 @@ var LLM_PRESET_STORAGE_KEY = "shuffle-llm-provider";
23174
23246
  var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serverside, theme, colorMode, open }) => {
23175
23247
  useSyncHostBaseUrl(globalUrl);
23176
23248
  const { authStates, authenticatedApps, handleAuthChange, handleSaveAuth, refreshAuth, loading: authLoading } = useAppAuth();
23177
- const [expanded, setExpanded] = useState20(true);
23178
- const [selectedPreset, setSelectedPreset] = useState20(() => {
23249
+ const [expanded, setExpanded] = useState21(true);
23250
+ const [selectedPreset, setSelectedPreset] = useState21(() => {
23179
23251
  try {
23180
23252
  const stored = localStorage.getItem(LLM_PRESET_STORAGE_KEY) || "";
23181
23253
  return ENDPOINT_PRESETS.some((p) => p.label === stored) ? stored : "";
@@ -23183,9 +23255,9 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
23183
23255
  return "";
23184
23256
  }
23185
23257
  });
23186
- const [customUrl, setCustomUrl] = useState20("");
23258
+ const [customUrl, setCustomUrl] = useState21("");
23187
23259
  const activeSwitchSeqRef = useRef12(0);
23188
- const [llmTest, setLlmTest] = useState20(null);
23260
+ const [llmTest, setLlmTest] = useState21(null);
23189
23261
  const openaiEntries = authenticatedApps.filter(
23190
23262
  (a) => a.app?.name?.toLowerCase() === "openai" || a.app?.id === OPENAI_APP_ID
23191
23263
  );
@@ -23202,8 +23274,8 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
23202
23274
  } : baseAuthState;
23203
23275
  const savedUrlFromEntry = (openaiEntries[0]?.fields || []).find((f) => (f?.key || "").toLowerCase() === "url")?.value || "";
23204
23276
  const currentUrl = (authState.credentials?.url || savedUrlFromEntry || "").trim();
23205
- const [customModel, setCustomModel] = useState20("");
23206
- const [customMode, setCustomMode] = useState20(false);
23277
+ const [customModel, setCustomModel] = useState21("");
23278
+ const [customMode, setCustomMode] = useState21(false);
23207
23279
  const hasOpenAIEntries = openaiEntries.length > 0;
23208
23280
  const providerOfEntry = (entry) => providerLabelOfAuthEntry(entry);
23209
23281
  const displayLabelOfEntry = (entry) => {
@@ -23211,7 +23283,7 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
23211
23283
  const stripped = raw.replace(new RegExp(`^\\s*${OPENAI_APP_NAME}\\s*-\\s*`, "i"), "").trim();
23212
23284
  return stripped || raw;
23213
23285
  };
23214
- const [optimisticActiveProvider, setOptimisticActiveProvider] = useState20(null);
23286
+ const [optimisticActiveProvider, setOptimisticActiveProvider] = useState21(null);
23215
23287
  const activeEntryRaw = useMemo11(
23216
23288
  () => openaiEntries.find((e) => e?.active === true),
23217
23289
  [openaiEntries]
@@ -23402,7 +23474,7 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
23402
23474
  };
23403
23475
  const prevOpenRef = useRef12(open);
23404
23476
  const hasInitializedPresetRef = useRef12(false);
23405
- useEffect18(() => {
23477
+ useEffect19(() => {
23406
23478
  const justOpened = Boolean(open && !prevOpenRef.current);
23407
23479
  prevOpenRef.current = open;
23408
23480
  if (authLoading) return;
@@ -23474,14 +23546,14 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
23474
23546
  setCustomUrl(value);
23475
23547
  handleAuthChange(OPENAI_APP_ID, { ...authState.credentials, url: value });
23476
23548
  };
23477
- useEffect18(() => {
23549
+ useEffect19(() => {
23478
23550
  const preset = ENDPOINT_PRESETS.find((p) => p.label === effectivePreset);
23479
23551
  const presetUrl = effectivePreset === CUSTOM_PRESET ? customUrl : preset?.url || "";
23480
23552
  if (!presetUrl) return;
23481
23553
  if ((authState.credentials?.url || "").trim()) return;
23482
23554
  handleAuthChange(OPENAI_APP_ID, { ...authState.credentials, url: presetUrl });
23483
23555
  }, [effectivePreset, customUrl, authState.credentials?.url]);
23484
- useEffect18(() => {
23556
+ useEffect19(() => {
23485
23557
  const models = PROVIDER_MODELS[effectivePreset];
23486
23558
  if (!models?.length) return;
23487
23559
  if ((authState.credentials?.model || "").trim()) return;
@@ -23504,8 +23576,8 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
23504
23576
  return isLocal;
23505
23577
  })();
23506
23578
  const orgId = userdata?.active_org?.id;
23507
- const [orgData, setOrgData] = useState20(null);
23508
- useEffect18(() => {
23579
+ const [orgData, setOrgData] = useState21(null);
23580
+ useEffect19(() => {
23509
23581
  if (!orgId) return;
23510
23582
  let cancelled = false;
23511
23583
  (async () => {
@@ -23788,20 +23860,20 @@ var AgentRunDrawer = ({
23788
23860
  }) => {
23789
23861
  useSyncHostBaseUrl(globalUrl);
23790
23862
  const themeScope = useShuffleMcpTheme();
23791
- const [activeTab, setActiveTab] = useState21(initialTab);
23863
+ const [activeTab, setActiveTab] = useState22(initialTab);
23792
23864
  const prevOpenRef = useRef13(open);
23793
- useEffect19(() => {
23865
+ useEffect20(() => {
23794
23866
  if (open && !prevOpenRef.current) setActiveTab(initialTab);
23795
23867
  prevOpenRef.current = open;
23796
23868
  }, [open, initialTab]);
23797
- useEffect19(() => {
23869
+ useEffect20(() => {
23798
23870
  if (typeof window === "undefined") return;
23799
23871
  window.__shuffleAgentDrawerMounted = (window.__shuffleAgentDrawerMounted || 0) + 1;
23800
23872
  return () => {
23801
23873
  window.__shuffleAgentDrawerMounted = Math.max(0, (window.__shuffleAgentDrawerMounted || 1) - 1);
23802
23874
  };
23803
23875
  }, []);
23804
- useEffect19(() => {
23876
+ useEffect20(() => {
23805
23877
  if (typeof window === "undefined") return;
23806
23878
  const onOpen = (event) => {
23807
23879
  const tab = event.detail?.tab;
@@ -23842,7 +23914,7 @@ var AgentRunDrawer = ({
23842
23914
  const showTabs = visibleTabs.length > 1;
23843
23915
  const safeActiveTab = visibleTabs.includes(activeTab) ? activeTab : "run";
23844
23916
  const paperRef = useRef13(null);
23845
- useEffect19(() => {
23917
+ useEffect20(() => {
23846
23918
  if (!open || safeActiveTab !== "run") return;
23847
23919
  const focusInput = () => {
23848
23920
  if (!paperRef.current) return false;
@@ -23868,6 +23940,7 @@ var AgentRunDrawer = ({
23868
23940
  const drawerWidth = `min(${width}px, 100vw)`;
23869
23941
  const drawerMinWidth = `min(${minWidth}px, 100vw)`;
23870
23942
  const drawerMaxWidth = `min(${maxWidth}px, 100vw)`;
23943
+ const drawerZIndex = useDrawerLayer(open);
23871
23944
  return /* @__PURE__ */ jsxs27(
23872
23945
  Drawer4,
23873
23946
  {
@@ -23875,6 +23948,7 @@ var AgentRunDrawer = ({
23875
23948
  open,
23876
23949
  onClose,
23877
23950
  sx: {
23951
+ zIndex: drawerZIndex,
23878
23952
  "& .MuiDrawer-paper": {
23879
23953
  boxSizing: "border-box",
23880
23954
  width: { xs: "100vw", sm: drawerWidth },
@@ -24030,7 +24104,7 @@ var AgentRunDrawer = ({
24030
24104
  var AgentRunDrawer_default = AgentRunDrawer;
24031
24105
 
24032
24106
  // components/AgentActivityList.tsx
24033
- import { useCallback as useCallback11, useEffect as useEffect20, useRef as useRef14, useState as useState22 } from "react";
24107
+ import { useCallback as useCallback11, useEffect as useEffect21, useRef as useRef14, useState as useState23 } from "react";
24034
24108
  import { useNavigate as useNavigate2 } from "react-router-dom";
24035
24109
  import {
24036
24110
  Avatar as Avatar7,
@@ -25025,31 +25099,31 @@ var AgentActivityList = ({
25025
25099
  initialRuns,
25026
25100
  disableFetch = false
25027
25101
  }) => {
25028
- const [appDrawer, setAppDrawer] = useState22(null);
25029
- const [runs, setRuns] = useState22(initialRuns || []);
25030
- const [cursor, setCursor] = useState22("");
25031
- const [hasMore, setHasMore] = useState22(false);
25032
- const [isLoading, setIsLoading] = useState22(false);
25033
- const [error, setError] = useState22(null);
25034
- const [statusFilter, setStatusFilter] = useState22("");
25035
- const [searchQuery, setSearchQuery] = useState22("");
25036
- const [debouncedQuery, setDebouncedQuery] = useState22("");
25037
- const [agentWorkflows, setAgentWorkflows] = useState22([]);
25038
- const [workflowFilter, setWorkflowFilter] = useState22("");
25039
- const [usecaseFilter, setUsecaseFilter] = useState22("");
25040
- const [stopOpen, setStopOpen] = useState22(false);
25041
- const [stopLoading, setStopLoading] = useState22(false);
25042
- const [appIcons, setAppIcons] = useState22({});
25043
- const [enrichedRuns, setEnrichedRuns] = useState22({});
25102
+ const [appDrawer, setAppDrawer] = useState23(null);
25103
+ const [runs, setRuns] = useState23(initialRuns || []);
25104
+ const [cursor, setCursor] = useState23("");
25105
+ const [hasMore, setHasMore] = useState23(false);
25106
+ const [isLoading, setIsLoading] = useState23(false);
25107
+ const [error, setError] = useState23(null);
25108
+ const [statusFilter, setStatusFilter] = useState23("");
25109
+ const [searchQuery, setSearchQuery] = useState23("");
25110
+ const [debouncedQuery, setDebouncedQuery] = useState23("");
25111
+ const [agentWorkflows, setAgentWorkflows] = useState23([]);
25112
+ const [workflowFilter, setWorkflowFilter] = useState23("");
25113
+ const [usecaseFilter, setUsecaseFilter] = useState23("");
25114
+ const [stopOpen, setStopOpen] = useState23(false);
25115
+ const [stopLoading, setStopLoading] = useState23(false);
25116
+ const [appIcons, setAppIcons] = useState23({});
25117
+ const [enrichedRuns, setEnrichedRuns] = useState23({});
25044
25118
  const enrichedRunsRef = useRef14({});
25045
25119
  const processedRunIdsRef = useRef14(/* @__PURE__ */ new Set());
25046
- useEffect20(() => {
25120
+ useEffect21(() => {
25047
25121
  enrichedRunsRef.current = enrichedRuns;
25048
25122
  }, [enrichedRuns]);
25049
- const [abortingIds, setAbortingIds] = useState22(/* @__PURE__ */ new Set());
25050
- const [abortedIds, setAbortedIds] = useState22(/* @__PURE__ */ new Set());
25051
- const [lastOpenedRunId, setLastOpenedRunId] = useState22(() => getLastOpenedAgentRun());
25052
- useEffect20(() => {
25123
+ const [abortingIds, setAbortingIds] = useState23(/* @__PURE__ */ new Set());
25124
+ const [abortedIds, setAbortedIds] = useState23(/* @__PURE__ */ new Set());
25125
+ const [lastOpenedRunId, setLastOpenedRunId] = useState23(() => getLastOpenedAgentRun());
25126
+ useEffect21(() => {
25053
25127
  const unsubAbort = subscribeAgentAborted((eid) => {
25054
25128
  setAbortedIds((prev) => prev.has(eid) ? prev : /* @__PURE__ */ new Set([...Array.from(prev), eid]));
25055
25129
  setRuns((prev) => prev.map((r) => r.execution_id === eid ? { ...r, status: "ABORTED" } : r));
@@ -25141,7 +25215,7 @@ var AgentActivityList = ({
25141
25215
  if (debounceRef.current) clearTimeout(debounceRef.current);
25142
25216
  debounceRef.current = setTimeout(() => setDebouncedQuery(q), 350);
25143
25217
  }, []);
25144
- useEffect20(() => () => {
25218
+ useEffect21(() => () => {
25145
25219
  if (debounceRef.current) clearTimeout(debounceRef.current);
25146
25220
  }, []);
25147
25221
  const fetchRuns = useCallback11(
@@ -25192,10 +25266,10 @@ var AgentActivityList = ({
25192
25266
  },
25193
25267
  [disableFetch, initialRuns, statusFilter, limit, top, apiKey, apiBaseUrl, orgId, workflowFilter]
25194
25268
  );
25195
- useEffect20(() => {
25269
+ useEffect21(() => {
25196
25270
  fetchRuns(false, "");
25197
25271
  }, [statusFilter, apiKey, apiBaseUrl, orgId, workflowFilter]);
25198
- useEffect20(() => {
25272
+ useEffect21(() => {
25199
25273
  let cancelled = false;
25200
25274
  listAgentScheduleWorkflows({ apiKey, apiBaseUrl, orgId }).then((items) => {
25201
25275
  if (!cancelled) setAgentWorkflows(items);
@@ -25205,7 +25279,7 @@ var AgentActivityList = ({
25205
25279
  cancelled = true;
25206
25280
  };
25207
25281
  }, [apiKey, apiBaseUrl, orgId]);
25208
- useEffect20(() => {
25282
+ useEffect21(() => {
25209
25283
  let cancelled = false;
25210
25284
  fetchAppsViaApiConfig().then((apps) => {
25211
25285
  if (cancelled || !Array.isArray(apps)) return;
@@ -25223,7 +25297,7 @@ var AgentActivityList = ({
25223
25297
  cancelled = true;
25224
25298
  };
25225
25299
  }, []);
25226
- useEffect20(() => {
25300
+ useEffect21(() => {
25227
25301
  if (!runs.length) return;
25228
25302
  let cancelled = false;
25229
25303
  const buildPatchFromRun = (r) => {
@@ -25708,7 +25782,7 @@ var AgentActivityList = ({
25708
25782
  var AgentActivityList_default = AgentActivityList;
25709
25783
 
25710
25784
  // components/AgentExecutionDrawer.tsx
25711
- import { useEffect as useEffect21, useState as useState23 } from "react";
25785
+ import { useEffect as useEffect22, useState as useState24 } from "react";
25712
25786
  import { Box as Box27, Drawer as Drawer5, IconButton as IconButton14, Tooltip as Tooltip19, Typography as Typography24 } from "@mui/material";
25713
25787
  import {
25714
25788
  X as CloseIcon9,
@@ -25741,8 +25815,8 @@ var AgentExecutionDrawer = ({
25741
25815
  colorMode
25742
25816
  }) => {
25743
25817
  const themeScope = useShuffleMcpTheme();
25744
- const [bodyReady, setBodyReady] = useState23(false);
25745
- useEffect21(() => {
25818
+ const [bodyReady, setBodyReady] = useState24(false);
25819
+ useEffect22(() => {
25746
25820
  if (!open || !run?.execution_id) {
25747
25821
  setBodyReady(false);
25748
25822
  return;
@@ -25756,6 +25830,7 @@ var AgentExecutionDrawer = ({
25756
25830
  const drawerWidth = `min(${width}px, 100vw)`;
25757
25831
  const drawerMinWidth = `min(${minWidth}px, 100vw)`;
25758
25832
  const drawerMaxWidth = `min(${maxWidth}px, 100vw)`;
25833
+ const drawerZIndex = useDrawerLayer(open);
25759
25834
  return /* @__PURE__ */ jsxs29(
25760
25835
  Drawer5,
25761
25836
  {
@@ -25765,7 +25840,7 @@ var AgentExecutionDrawer = ({
25765
25840
  keepMounted: true,
25766
25841
  transitionDuration: { enter: 120, exit: 100 },
25767
25842
  sx: {
25768
- zIndex: 10011,
25843
+ zIndex: drawerZIndex,
25769
25844
  "& .MuiDrawer-paper": {
25770
25845
  boxSizing: "border-box",
25771
25846
  width: { xs: "100vw", sm: drawerWidth },
@@ -25940,7 +26015,7 @@ var AgentExecutionDrawer = ({
25940
26015
  var AgentExecutionDrawer_default = AgentExecutionDrawer;
25941
26016
 
25942
26017
  // views/AgentsView.tsx
25943
- import { useCallback as useCallback12, useEffect as useEffect22, useMemo as useMemo12, useState as useState24 } from "react";
26018
+ import { useCallback as useCallback12, useEffect as useEffect23, useMemo as useMemo12, useState as useState25 } from "react";
25944
26019
  import { Box as Box28, Stack, Typography as Typography25 } from "@mui/material";
25945
26020
  import { jsx as jsx37, jsxs as jsxs30 } from "react/jsx-runtime";
25946
26021
  var APPS_TTL_MS = 24 * 60 * 60 * 1e3;
@@ -26000,14 +26075,14 @@ var AgentsView = ({
26000
26075
  if (disableAppsPersistence) return [];
26001
26076
  return readPersistedApps(appsStorageKey) ?? [];
26002
26077
  }, []);
26003
- const [selectedRun, setSelectedRun] = useState24(null);
26004
- const [agentView, setAgentView] = useState24("start");
26005
- const [prefill, setPrefill] = useState24({
26078
+ const [selectedRun, setSelectedRun] = useState25(null);
26079
+ const [agentView, setAgentView] = useState25("start");
26080
+ const [prefill, setPrefill] = useState25({
26006
26081
  input: "",
26007
26082
  apps: hydratedInitialApps,
26008
26083
  key: 0
26009
26084
  });
26010
- const [editing, setEditing] = useState24(null);
26085
+ const [editing, setEditing] = useState25(null);
26011
26086
  const handleAppsChange = useCallback12((apps) => {
26012
26087
  if (onAppsChange) {
26013
26088
  try {
@@ -26030,13 +26105,13 @@ var AgentsView = ({
26030
26105
  } catch {
26031
26106
  }
26032
26107
  }, [onAppsChange, disableAppsPersistence, appsStorageKey]);
26033
- useEffect22(() => {
26108
+ useEffect23(() => {
26034
26109
  }, [handleAppsChange]);
26035
- const [builtInDrawer, setBuiltInDrawer] = useState24({
26110
+ const [builtInDrawer, setBuiltInDrawer] = useState25({
26036
26111
  open: false,
26037
26112
  tab: "localLLM"
26038
26113
  });
26039
- useEffect22(() => {
26114
+ useEffect23(() => {
26040
26115
  if (typeof window === "undefined") return;
26041
26116
  const handler = (e) => {
26042
26117
  const detail = e.detail;
@@ -26075,7 +26150,7 @@ var AgentsView = ({
26075
26150
  }
26076
26151
  setBuiltInDrawer({ open: true, tab: "localLLM" });
26077
26152
  }, [onChooseLLM]);
26078
- useEffect22(() => {
26153
+ useEffect23(() => {
26079
26154
  if (typeof window === "undefined") return;
26080
26155
  if (window.location.hash !== "#agent-activity") return;
26081
26156
  const tryScroll = () => {
@@ -26234,7 +26309,7 @@ var AgentsView_default = AgentsView;
26234
26309
 
26235
26310
  // components/AddAppModal.tsx
26236
26311
  import { X as CloseIcon10, ArrowLeft as ArrowBackIcon2 } from "lucide-react";
26237
- import { useState as useState26, useEffect as useEffect23 } from "react";
26312
+ import { useState as useState27, useEffect as useEffect24 } from "react";
26238
26313
  import {
26239
26314
  Box as Box29,
26240
26315
  Typography as Typography26,
@@ -26247,16 +26322,16 @@ import {
26247
26322
  import { motion as motion9, AnimatePresence as AnimatePresence3 } from "framer-motion";
26248
26323
 
26249
26324
  // useAppAuthFlow.ts
26250
- import { useState as useState25, useCallback as useCallback13 } from "react";
26325
+ import { useState as useState26, useCallback as useCallback13 } from "react";
26251
26326
  function useAppAuthFlow() {
26252
- const [selectedApp, setSelectedApp] = useState25(null);
26253
- const [authState, setAuthState] = useState25({
26327
+ const [selectedApp, setSelectedApp] = useState26(null);
26328
+ const [authState, setAuthState] = useState26({
26254
26329
  systemId: "",
26255
26330
  status: "pending",
26256
26331
  credentials: {}
26257
26332
  });
26258
- const [authenticatedApps, setAuthenticatedApps] = useState25([]);
26259
- const [authLoading, setAuthLoading] = useState25(false);
26333
+ const [authenticatedApps, setAuthenticatedApps] = useState26([]);
26334
+ const [authLoading, setAuthLoading] = useState26(false);
26260
26335
  const fetchAuthForApp = useCallback13(async (appName, appImageUrl) => {
26261
26336
  setAuthLoading(true);
26262
26337
  try {
@@ -26466,7 +26541,7 @@ var singulStyles2 = {
26466
26541
  }
26467
26542
  };
26468
26543
  var AddAppModal = ({ open, onClose, initialQuery, categoryLabel }) => {
26469
- const [phase, setPhase] = useState26("search");
26544
+ const [phase, setPhase] = useState27("search");
26470
26545
  const {
26471
26546
  selectedApp,
26472
26547
  authState,
@@ -26479,7 +26554,7 @@ var AddAppModal = ({ open, onClose, initialQuery, categoryLabel }) => {
26479
26554
  handleSaveAuth,
26480
26555
  refreshAuth
26481
26556
  } = useAppAuthFlow();
26482
- useEffect23(() => {
26557
+ useEffect24(() => {
26483
26558
  if (!open) {
26484
26559
  setPhase("search");
26485
26560
  clearSelection();
@@ -26635,14 +26710,16 @@ var AskAiButton = ({
26635
26710
  return null;
26636
26711
  }
26637
26712
  const isEffectiveSupport = isSupport !== void 0 ? isSupport : isSupportUser();
26638
- const effectiveRequireSupport = isBeta ? false : requireSupport;
26713
+ const isIncidentOrDocs = currentPath.startsWith("/incidents") || currentPath.startsWith("/incidents-simple") || currentPath.startsWith("/cases") || currentPath.startsWith("/alerts") || currentPath.startsWith("/tickets") || currentPath.startsWith("/docs");
26714
+ const effectiveIsBeta = isBeta || isIncidentOrDocs;
26715
+ const effectiveRequireSupport = effectiveIsBeta ? false : requireSupport;
26639
26716
  if (effectiveRequireSupport && !isEffectiveSupport) {
26640
26717
  return null;
26641
26718
  }
26642
26719
  if (hideWhenOpen && isOpen) {
26643
26720
  return null;
26644
26721
  }
26645
- const effectiveTagLabel = tagLabel !== void 0 ? tagLabel : isBeta ? "Beta" : "Support";
26722
+ const effectiveTagLabel = tagLabel !== void 0 && !(tagLabel === "Support" && isIncidentOrDocs) ? tagLabel : effectiveIsBeta ? "Beta" : "Support";
26646
26723
  const effectiveTooltip = tooltipTitle !== void 0 ? tooltipTitle : label !== "Ask AI" ? label : contextHint ? `Ask AI (${contextHint})` : "Ask AI \u2022 Context-aware assistant";
26647
26724
  return /* @__PURE__ */ jsx39(
26648
26725
  Box30,
@@ -26733,9 +26810,9 @@ var AskAiButton = ({
26733
26810
  fontWeight: 700,
26734
26811
  textTransform: "uppercase",
26735
26812
  letterSpacing: "0.04em",
26736
- color: isBeta ? "hsl(var(--primary))" : "hsl(var(--muted-foreground))",
26737
- bgcolor: isBeta ? "hsla(var(--primary) / 0.12)" : "hsla(var(--muted-foreground) / 0.12)",
26738
- border: isBeta ? "1px solid hsla(var(--primary) / 0.26)" : "1px solid hsla(var(--muted-foreground) / 0.24)",
26813
+ color: effectiveIsBeta ? "hsl(var(--primary))" : "hsl(var(--muted-foreground))",
26814
+ bgcolor: effectiveIsBeta ? "hsla(var(--primary) / 0.12)" : "hsla(var(--muted-foreground) / 0.12)",
26815
+ border: effectiveIsBeta ? "1px solid hsla(var(--primary) / 0.26)" : "1px solid hsla(var(--muted-foreground) / 0.24)",
26739
26816
  px: 0.9,
26740
26817
  py: 0.25,
26741
26818
  borderRadius: "9999px",
@@ -26754,7 +26831,7 @@ var AskAiButton = ({
26754
26831
  var AskAiButton_default = AskAiButton;
26755
26832
 
26756
26833
  // components/AskAiDrawer.tsx
26757
- import { useCallback as useCallback14, useEffect as useEffect24, useMemo as useMemo13, useState as useState27 } from "react";
26834
+ import { useCallback as useCallback14, useEffect as useEffect25, useMemo as useMemo13, useState as useState28 } from "react";
26758
26835
  import { Box as Box31, ButtonBase as ButtonBase3, Typography as Typography28 } from "@mui/material";
26759
26836
  import { jsx as jsx40, jsxs as jsxs33 } from "react/jsx-runtime";
26760
26837
  var AskAiDrawer = ({
@@ -26770,13 +26847,13 @@ var AskAiDrawer = ({
26770
26847
  agentUIProps,
26771
26848
  ...drawerProps
26772
26849
  }) => {
26773
- const [internalPathname, setInternalPathname] = useState27(
26850
+ const [internalPathname, setInternalPathname] = useState28(
26774
26851
  () => typeof window !== "undefined" ? window.location.pathname : "/"
26775
26852
  );
26776
- const [internalSearch, setInternalSearch] = useState27(
26853
+ const [internalSearch, setInternalSearch] = useState28(
26777
26854
  () => typeof window !== "undefined" ? window.location.search : ""
26778
26855
  );
26779
- useEffect24(() => {
26856
+ useEffect25(() => {
26780
26857
  if (propPathname !== void 0) return;
26781
26858
  const updateLoc = () => {
26782
26859
  setInternalPathname(window.location.pathname);
@@ -26787,17 +26864,17 @@ var AskAiDrawer = ({
26787
26864
  }, [propPathname]);
26788
26865
  const activePathname = propPathname !== void 0 ? propPathname : internalPathname;
26789
26866
  const activeSearch = propSearch !== void 0 ? propSearch : internalSearch;
26790
- const [resetKey, setResetKey] = useState27(0);
26867
+ const [resetKey, setResetKey] = useState28(0);
26791
26868
  const resolvedContext = useMemo13(
26792
26869
  () => resolveAgentContext(activePathname, activeSearch, rules),
26793
26870
  // eslint-disable-next-line react-hooks/exhaustive-deps
26794
26871
  [activePathname, activeSearch, rules, resetKey]
26795
26872
  );
26796
- useEffect24(() => {
26873
+ useEffect25(() => {
26797
26874
  onContextResolved?.(resolvedContext);
26798
26875
  }, [resolvedContext, onContextResolved]);
26799
- const [isOverridden, setIsOverridden] = useState27(resolvedContext.isOverridden);
26800
- useEffect24(() => {
26876
+ const [isOverridden, setIsOverridden] = useState28(resolvedContext.isOverridden);
26877
+ useEffect25(() => {
26801
26878
  setIsOverridden(resolvedContext.isOverridden);
26802
26879
  }, [resolvedContext.isOverridden, resolvedContext.storageKey]);
26803
26880
  const handleAppsChange = useCallback14(
@@ -26880,7 +26957,7 @@ var AskAiDrawer = ({
26880
26957
  var AskAiDrawer_default = AskAiDrawer;
26881
26958
 
26882
26959
  // components/AskAiSidePanel.tsx
26883
- import React8, { useCallback as useCallback15, useEffect as useEffect25, useRef as useRef15, useState as useState28 } from "react";
26960
+ import React8, { useCallback as useCallback15, useEffect as useEffect26, useRef as useRef15, useState as useState29 } from "react";
26884
26961
  import {
26885
26962
  Box as Box32,
26886
26963
  Button as Button16,
@@ -26896,6 +26973,7 @@ import {
26896
26973
  X as CloseIcon11
26897
26974
  } from "lucide-react";
26898
26975
  import { Fragment as Fragment16, jsx as jsx41, jsxs as jsxs34 } from "react/jsx-runtime";
26976
+ import { createElement as createElement3 } from "react";
26899
26977
  var AGENT_DRAWER_OPEN_EVENT = "agent-drawer-open";
26900
26978
  var ASK_AI_PANEL_WIDTH_STORAGE_KEY = "shuffle:ask_ai_panel_width";
26901
26979
  var MIN_ASK_AI_PANEL_WIDTH = 340;
@@ -26931,9 +27009,9 @@ var AskAiSidePanel = ({
26931
27009
  }) => {
26932
27010
  const themeScope = useShuffleMcpTheme();
26933
27011
  const effectiveTheme = theme || (themeScope?.isDark ? "dark" : "light");
26934
- const [currentPathname, setCurrentPathname] = useState28(pathname ?? "/");
26935
- const [currentSearch, setCurrentSearch] = useState28(search ?? "");
26936
- useEffect25(() => {
27012
+ const [currentPathname, setCurrentPathname] = useState29(pathname ?? "/");
27013
+ const [currentSearch, setCurrentSearch] = useState29(search ?? "");
27014
+ useEffect26(() => {
26937
27015
  if (pathname !== void 0) {
26938
27016
  setCurrentPathname(pathname);
26939
27017
  return;
@@ -26949,14 +27027,14 @@ var AskAiSidePanel = ({
26949
27027
  }
26950
27028
  return;
26951
27029
  }, [pathname]);
26952
- useEffect25(() => {
27030
+ useEffect26(() => {
26953
27031
  if (search !== void 0) {
26954
27032
  setCurrentSearch(search);
26955
27033
  }
26956
27034
  }, [search]);
26957
27035
  const isAgentDisabled = isAgentRoute(currentPathname);
26958
27036
  const isVisible = open && !isAgentDisabled;
26959
- useEffect25(() => {
27037
+ useEffect26(() => {
26960
27038
  if (isAgentDisabled && open) {
26961
27039
  onClose();
26962
27040
  }
@@ -26965,8 +27043,8 @@ var AskAiSidePanel = ({
26965
27043
  () => resolveAgentContext(currentPathname, currentSearch, rules),
26966
27044
  [currentPathname, currentSearch, rules]
26967
27045
  );
26968
- const [entityTitle, setEntityTitle] = useState28(() => getActivePageEntityName());
26969
- useEffect25(() => {
27046
+ const [entityTitle, setEntityTitle] = useState29(() => getActivePageEntityName());
27047
+ useEffect26(() => {
26970
27048
  if (!open) return;
26971
27049
  const current = getActivePageEntityName();
26972
27050
  if (current) setEntityTitle(current);
@@ -27011,19 +27089,22 @@ var AskAiSidePanel = ({
27011
27089
  }
27012
27090
  return context.title || "How can we help on this page?";
27013
27091
  }, [context, entityTitle]);
27014
- useEffect25(() => {
27092
+ useEffect26(() => {
27015
27093
  onContextResolved?.(context);
27016
27094
  }, [context, onContextResolved]);
27017
27095
  useSyncHostBaseUrl(globalUrl);
27018
- const [internalTab, setInternalTab] = useState28(initialTab);
27096
+ const [internalTab, setInternalTab] = useState29(initialTab);
27019
27097
  const currentTab = propActiveTab !== void 0 ? propActiveTab : internalTab;
27020
- const [controlledDefaultInput, setControlledDefaultInput] = useState28(defaultInput);
27021
- useEffect25(() => {
27098
+ const [controlledDefaultInput, setControlledDefaultInput] = useState29(defaultInput);
27099
+ const [controlledAutoSubmit, setControlledAutoSubmit] = useState29(void 0);
27100
+ useEffect26(() => {
27022
27101
  if (defaultInput !== void 0) {
27023
27102
  setControlledDefaultInput(defaultInput);
27024
27103
  }
27025
27104
  }, [defaultInput]);
27026
27105
  const effectiveDefaultInput = controlledDefaultInput ?? defaultInput ?? agentUIProps?.defaultInput;
27106
+ const effectiveAutoSubmit = controlledAutoSubmit ?? agentUIProps?.autoSubmit;
27107
+ const isBetaRoute = context.isBeta === true || currentPathname.startsWith("/incidents") || currentPathname.startsWith("/incidents-simple") || currentPathname.startsWith("/cases") || currentPathname.startsWith("/alerts") || currentPathname.startsWith("/tickets") || currentPathname.startsWith("/docs");
27027
27108
  const handleTabChange = useCallback15(
27028
27109
  (nextTab) => {
27029
27110
  setInternalTab(nextTab);
@@ -27031,20 +27112,29 @@ var AskAiSidePanel = ({
27031
27112
  },
27032
27113
  [onTabChange]
27033
27114
  );
27034
- useEffect25(() => {
27115
+ useEffect26(() => {
27035
27116
  if (initialTab) {
27036
27117
  setInternalTab(initialTab);
27037
27118
  }
27038
27119
  }, [initialTab]);
27039
27120
  const prevOpenRef = useRef15(open);
27040
- useEffect25(() => {
27121
+ useEffect26(() => {
27041
27122
  if (open && !prevOpenRef.current && initialTab) {
27042
27123
  setInternalTab(initialTab);
27043
27124
  onTabChange?.(initialTab);
27044
27125
  }
27045
27126
  prevOpenRef.current = open;
27046
27127
  }, [open, initialTab, onTabChange]);
27047
- useEffect25(() => {
27128
+ const [activeTaskId, setActiveTaskId] = useState29(null);
27129
+ const [activeExecutionId, setActiveExecutionId] = useState29(null);
27130
+ const [runResetKey, setRunResetKey] = useState29(0);
27131
+ useEffect26(() => {
27132
+ if (!open) {
27133
+ setActiveTaskId(null);
27134
+ setActiveExecutionId(null);
27135
+ }
27136
+ }, [open]);
27137
+ useEffect26(() => {
27048
27138
  if (typeof window === "undefined") return;
27049
27139
  window.__shuffleAgentDrawerMounted = (window.__shuffleAgentDrawerMounted || 0) + 1;
27050
27140
  return () => {
@@ -27054,7 +27144,7 @@ var AskAiSidePanel = ({
27054
27144
  );
27055
27145
  };
27056
27146
  }, []);
27057
- useEffect25(() => {
27147
+ useEffect26(() => {
27058
27148
  if (typeof window === "undefined") return;
27059
27149
  const onOpen = (event) => {
27060
27150
  const detail = event.detail;
@@ -27065,12 +27155,49 @@ var AskAiSidePanel = ({
27065
27155
  if (detail?.defaultInput !== void 0) {
27066
27156
  setControlledDefaultInput(detail.defaultInput);
27067
27157
  }
27158
+ if (detail?.autoSubmit !== void 0) {
27159
+ setControlledAutoSubmit(detail.autoSubmit);
27160
+ }
27161
+ if (detail?.taskId !== void 0) {
27162
+ setActiveTaskId(detail.taskId || null);
27163
+ } else if (!detail?.tab) {
27164
+ setActiveTaskId(null);
27165
+ }
27166
+ if (detail?.resetExecution) {
27167
+ setActiveExecutionId(null);
27168
+ setRunResetKey((k) => k + 1);
27169
+ } else if (detail?.executionId !== void 0) {
27170
+ setActiveExecutionId(detail.executionId || null);
27171
+ } else if (detail?.taskId) {
27172
+ setActiveExecutionId(null);
27173
+ }
27068
27174
  };
27069
27175
  window.addEventListener(AGENT_DRAWER_OPEN_EVENT, onOpen);
27070
27176
  return () => {
27071
27177
  window.removeEventListener(AGENT_DRAWER_OPEN_EVENT, onOpen);
27072
27178
  };
27073
27179
  }, [handleTabChange]);
27180
+ const handleAgentRun = useCallback15(
27181
+ (event) => {
27182
+ if (event.executionId && activeTaskId) {
27183
+ setActiveExecutionId(event.executionId);
27184
+ if (typeof window !== "undefined") {
27185
+ window.dispatchEvent(
27186
+ new CustomEvent("shuffle:task_ai_execution", {
27187
+ detail: {
27188
+ taskId: activeTaskId,
27189
+ executionId: event.executionId,
27190
+ status: event.success ? "running" : "failed"
27191
+ }
27192
+ })
27193
+ );
27194
+ }
27195
+ }
27196
+ },
27197
+ [activeTaskId]
27198
+ );
27199
+ const effectiveStorageKey = activeTaskId ? `${context.storageKey}:task:${activeTaskId}` : context.storageKey;
27200
+ const agentUiKey = activeTaskId ? `${context.storageKey}:task:${activeTaskId}:${activeExecutionId || "fresh"}:${runResetKey}` : `${context.storageKey}:${runResetKey}`;
27074
27201
  const effectiveLocalLLMSlot = localLLMSlot ?? /* @__PURE__ */ jsx41(
27075
27202
  LocalLLMConfig_default,
27076
27203
  {
@@ -27092,7 +27219,7 @@ var AskAiSidePanel = ({
27092
27219
  });
27093
27220
  const safeActiveTab = visibleTabs.includes(currentTab) ? currentTab : "run";
27094
27221
  const panelRef = useRef15(null);
27095
- useEffect25(() => {
27222
+ useEffect26(() => {
27096
27223
  if (!isVisible || safeActiveTab !== "run") return;
27097
27224
  const focusInput = () => {
27098
27225
  if (!panelRef.current) return false;
@@ -27115,7 +27242,7 @@ var AskAiSidePanel = ({
27115
27242
  clearTimeout(t3);
27116
27243
  };
27117
27244
  }, [isVisible, safeActiveTab]);
27118
- const [panelWidth, setPanelWidth] = useState28(() => {
27245
+ const [panelWidth, setPanelWidth] = useState29(() => {
27119
27246
  if (typeof window === "undefined") return width || 380;
27120
27247
  try {
27121
27248
  const stored = localStorage.getItem(ASK_AI_PANEL_WIDTH_STORAGE_KEY);
@@ -27129,9 +27256,9 @@ var AskAiSidePanel = ({
27129
27256
  }
27130
27257
  return width || 380;
27131
27258
  });
27132
- const [isResizing, setIsResizing] = useState28(false);
27259
+ const [isResizing, setIsResizing] = useState29(false);
27133
27260
  const prevWidthPropRef = useRef15(width);
27134
- useEffect25(() => {
27261
+ useEffect26(() => {
27135
27262
  if (width !== prevWidthPropRef.current) {
27136
27263
  prevWidthPropRef.current = width;
27137
27264
  setPanelWidth(width);
@@ -27208,7 +27335,7 @@ var AskAiSidePanel = ({
27208
27335
  }, [panelWidth]);
27209
27336
  const effectiveWidth = safeActiveTab === "localLLM" ? Math.max(panelWidth, 520) : panelWidth;
27210
27337
  const effectiveSideshift = sideshift !== void 0 ? sideshift : context.sideshift ?? true;
27211
- useEffect25(() => {
27338
+ useEffect26(() => {
27212
27339
  if (typeof document === "undefined") return;
27213
27340
  if (open && !isAgentDisabled && effectiveSideshift) {
27214
27341
  document.documentElement.style.setProperty(
@@ -27376,11 +27503,11 @@ var AskAiSidePanel = ({
27376
27503
  px: 0.75,
27377
27504
  py: 0.2,
27378
27505
  borderRadius: "4px",
27379
- bgcolor: context.isBeta ? "hsla(var(--primary) / 0.12)" : "hsl(var(--muted))",
27380
- color: context.isBeta ? "hsl(var(--primary))" : "hsl(var(--muted-foreground))",
27381
- border: context.isBeta ? "1px solid hsla(var(--primary) / 0.26)" : "1px solid hsl(var(--border))"
27506
+ bgcolor: isBetaRoute ? "hsla(var(--primary) / 0.12)" : "hsl(var(--muted))",
27507
+ color: isBetaRoute ? "hsl(var(--primary))" : "hsl(var(--muted-foreground))",
27508
+ border: isBetaRoute ? "1px solid hsla(var(--primary) / 0.26)" : "1px solid hsl(var(--border))"
27382
27509
  },
27383
- children: context.isBeta ? "Beta" : isLoggedIn ? isSupport ? "Support" : "Agent" : "Guest"
27510
+ children: isBetaRoute ? "Beta" : isLoggedIn ? isSupport ? "Support" : "Agent" : "Guest"
27384
27511
  }
27385
27512
  )
27386
27513
  ] }),
@@ -27638,14 +27765,16 @@ var AskAiSidePanel = ({
27638
27765
  display: "flex",
27639
27766
  flexDirection: "column"
27640
27767
  },
27641
- children: /* @__PURE__ */ jsx41(
27768
+ children: /* @__PURE__ */ createElement3(
27642
27769
  AgentUI_default,
27643
27770
  {
27771
+ ...agentUIProps,
27772
+ key: agentUiKey,
27644
27773
  sidebarLayout: true,
27645
27774
  compact: true,
27646
27775
  mobileView: true,
27647
27776
  hideHeroIcon: true,
27648
- title: displayTitle,
27777
+ title: activeTaskId ? "Task AI Agent" : displayTitle,
27649
27778
  subtitle: null,
27650
27779
  hideChooseLLM: !isLoggedIn,
27651
27780
  isLoggedIn,
@@ -27656,16 +27785,19 @@ var AskAiSidePanel = ({
27656
27785
  initialPresetId: context.presetId,
27657
27786
  placeholder: context.placeholder,
27658
27787
  contextCategory: context.sourceCategory,
27659
- contextStorageKey: context.storageKey,
27788
+ contextStorageKey: effectiveStorageKey,
27660
27789
  contextParams: context.params,
27661
27790
  composeSubmitInput: context.composeInput,
27662
27791
  defaultInput: effectiveDefaultInput,
27792
+ autoSubmit: effectiveAutoSubmit,
27793
+ executionId: activeExecutionId || void 0,
27794
+ initialExecution: activeExecutionId ? { execution_id: activeExecutionId } : void 0,
27795
+ onRun: handleAgentRun,
27663
27796
  onAppsChange: handleAppsChange,
27664
27797
  onSelectPreset: handleSelectPreset,
27665
27798
  onChooseLLM: () => handleTabChange("localLLM"),
27666
27799
  apiBaseUrl: globalUrl || agentUIProps?.apiBaseUrl,
27667
27800
  theme: effectiveTheme,
27668
- ...agentUIProps,
27669
27801
  sx: {
27670
27802
  flex: 1,
27671
27803
  height: "100%",
@@ -27676,8 +27808,7 @@ var AskAiSidePanel = ({
27676
27808
  pb: 0,
27677
27809
  ...agentUIProps?.sx ? Array.isArray(agentUIProps.sx) ? {} : agentUIProps.sx : {}
27678
27810
  }
27679
- },
27680
- context.storageKey
27811
+ }
27681
27812
  )
27682
27813
  }
27683
27814
  )
@@ -27690,7 +27821,7 @@ var AskAiSidePanel = ({
27690
27821
  var AskAiSidePanel_default = AskAiSidePanel;
27691
27822
 
27692
27823
  // components/AskAiWidget.tsx
27693
- import { useCallback as useCallback16, useEffect as useEffect26, useMemo as useMemo15, useState as useState29 } from "react";
27824
+ import { useCallback as useCallback16, useEffect as useEffect27, useMemo as useMemo15, useState as useState30 } from "react";
27694
27825
  import { Fragment as Fragment17, jsx as jsx42, jsxs as jsxs35 } from "react/jsx-runtime";
27695
27826
  var AGENT_DRAWER_OPEN_EVENT2 = "agent-drawer-open";
27696
27827
  var AskAiWidget = ({
@@ -27710,11 +27841,11 @@ var AskAiWidget = ({
27710
27841
  localLLMSlot,
27711
27842
  ...panelProps
27712
27843
  }) => {
27713
- const [internalOpen, setInternalOpen] = useState29(false);
27714
- const [activeTab, setActiveTab] = useState29(propInitialTab);
27844
+ const [internalOpen, setInternalOpen] = useState30(false);
27845
+ const [activeTab, setActiveTab] = useState30(propInitialTab);
27715
27846
  const isDrawerOpen = controlledOpen !== void 0 ? controlledOpen : internalOpen;
27716
- const [browserLocation, setBrowserLocation] = useState29({ path: "", search: "" });
27717
- useEffect26(() => {
27847
+ const [browserLocation, setBrowserLocation] = useState30({ path: "", search: "" });
27848
+ useEffect27(() => {
27718
27849
  if (pathname !== void 0 && search !== void 0) return;
27719
27850
  const syncLocation = () => setBrowserLocation({
27720
27851
  path: window.location.pathname,
@@ -27736,7 +27867,7 @@ var AskAiWidget = ({
27736
27867
  },
27737
27868
  [controlledOpen, isAgentDisabled, onOpenChange]
27738
27869
  );
27739
- useEffect26(() => {
27870
+ useEffect27(() => {
27740
27871
  if (isAgentDisabled && isDrawerOpen) {
27741
27872
  setDrawerOpen(false);
27742
27873
  }
@@ -27745,7 +27876,7 @@ var AskAiWidget = ({
27745
27876
  const resolvedContext = useMemo15(() => {
27746
27877
  return resolveAgentContext(currentPath, currentSearch, rules);
27747
27878
  }, [currentPath, currentSearch, rules]);
27748
- const [reportedContext, setReportedContext] = useState29(null);
27879
+ const [reportedContext, setReportedContext] = useState30(null);
27749
27880
  const activeContext = reportedContext && reportedContext.path === currentPath && reportedContext.search === currentSearch ? reportedContext.ctx : resolvedContext;
27750
27881
  const handleContextResolved = useCallback16(
27751
27882
  (ctx) => {
@@ -27754,7 +27885,7 @@ var AskAiWidget = ({
27754
27885
  },
27755
27886
  [currentPath, currentSearch, onContextResolved]
27756
27887
  );
27757
- useEffect26(() => {
27888
+ useEffect27(() => {
27758
27889
  const handleDrawerOpenEvent = (e) => {
27759
27890
  if (isAgentDisabled) return;
27760
27891
  const detail = e.detail;
@@ -27766,17 +27897,18 @@ var AskAiWidget = ({
27766
27897
  window.addEventListener(AGENT_DRAWER_OPEN_EVENT2, handleDrawerOpenEvent);
27767
27898
  return () => window.removeEventListener(AGENT_DRAWER_OPEN_EVENT2, handleDrawerOpenEvent);
27768
27899
  }, [isAgentDisabled, setDrawerOpen]);
27769
- useEffect26(() => {
27900
+ useEffect27(() => {
27770
27901
  if (propInitialTab) {
27771
27902
  setActiveTab(propInitialTab);
27772
27903
  }
27773
27904
  }, [propInitialTab]);
27774
27905
  const effectiveButtonLabel = buttonProps?.label || (activeContext.buttonLabelFn ? activeContext.buttonLabelFn() : activeContext.buttonLabel) || "Ask AI";
27775
- const isBeta = activeContext.isBeta === true;
27906
+ const isIncidentOrDocsRoute = currentPath.startsWith("/incidents") || currentPath.startsWith("/incidents-simple") || currentPath.startsWith("/cases") || currentPath.startsWith("/alerts") || currentPath.startsWith("/tickets") || currentPath.startsWith("/docs");
27907
+ const isBeta = activeContext.isBeta === true || isIncidentOrDocsRoute;
27776
27908
  const effectiveRequireSupport = isBeta ? false : requireSupport;
27777
27909
  const defaultTag = isBeta ? "Beta" : "Support";
27778
27910
  const effectiveTagLabel = buttonProps?.tagLabel !== void 0 ? buttonProps.tagLabel : defaultTag;
27779
- useEffect26(() => {
27911
+ useEffect27(() => {
27780
27912
  if (effectiveRequireSupport && !isSupport && isDrawerOpen) {
27781
27913
  setDrawerOpen(false);
27782
27914
  }
@@ -27836,10 +27968,10 @@ var AskAiWidget = ({
27836
27968
  ] });
27837
27969
  };
27838
27970
  var useContextAwareAgent = (pathname, search) => {
27839
- const [activeContext, setActiveContext] = useState29(
27971
+ const [activeContext, setActiveContext] = useState30(
27840
27972
  () => resolveAgentContext(pathname ?? "/", search ?? "")
27841
27973
  );
27842
- useEffect26(() => {
27974
+ useEffect27(() => {
27843
27975
  const p = pathname ?? (typeof window !== "undefined" ? window.location.pathname : "/");
27844
27976
  const s = search ?? (typeof window !== "undefined" ? window.location.search : "");
27845
27977
  setActiveContext(resolveAgentContext(p, s));
@@ -27849,7 +27981,7 @@ var useContextAwareAgent = (pathname, search) => {
27849
27981
  var AskAiWidget_default = AskAiWidget;
27850
27982
 
27851
27983
  // components/AgentPromptPrefixChip.tsx
27852
- import { useEffect as useEffect27, useState as useState30 } from "react";
27984
+ import { useEffect as useEffect28, useState as useState31 } from "react";
27853
27985
  import {
27854
27986
  Box as Box33,
27855
27987
  Button as Button17,
@@ -27878,9 +28010,9 @@ var AgentPromptPrefixChip = ({
27878
28010
  const managed = useAgentPromptPrefix({ userId, defaultPrompt, persist: !controlled });
27879
28011
  const prompt = controlled ? value : managed.prompt;
27880
28012
  const isSaving = controlled ? false : managed.isSaving;
27881
- const [open, setOpen] = useState30(false);
27882
- const [draft, setDraft] = useState30(prompt);
27883
- useEffect27(() => {
28013
+ const [open, setOpen] = useState31(false);
28014
+ const [draft, setDraft] = useState31(prompt);
28015
+ useEffect28(() => {
27884
28016
  if (!open) setDraft(prompt);
27885
28017
  }, [prompt, open]);
27886
28018
  const handleOpen = () => {
@@ -28888,12 +29020,12 @@ var DEMO_AGENT_RUNS = [
28888
29020
  ];
28889
29021
 
28890
29022
  // useAppLookup.ts
28891
- import { useEffect as useEffect28, useMemo as useMemo16, useState as useState31 } from "react";
29023
+ import { useEffect as useEffect29, useMemo as useMemo16, useState as useState32 } from "react";
28892
29024
  var norm3 = (s) => s.toLowerCase().replace(/[\s_\-]+/g, "_");
28893
29025
  function useAppLookup(appName) {
28894
- const [loading, setLoading] = useState31(false);
28895
- const [info, setInfo] = useState31(null);
28896
- const [algoliaId, setAlgoliaId] = useState31(null);
29026
+ const [loading, setLoading] = useState32(false);
29027
+ const [info, setInfo] = useState32(null);
29028
+ const [algoliaId, setAlgoliaId] = useState32(null);
28897
29029
  const {
28898
29030
  authStates,
28899
29031
  authenticatedApps,
@@ -28902,7 +29034,7 @@ function useAppLookup(appName) {
28902
29034
  handleSaveAuth,
28903
29035
  refreshAuth
28904
29036
  } = useAppAuth();
28905
- useEffect28(() => {
29037
+ useEffect29(() => {
28906
29038
  if (!appName) {
28907
29039
  setInfo(null);
28908
29040
  setAlgoliaId(null);