@shuffleio/shuffle-mcps 0.0.16 → 0.0.18

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.js CHANGED
@@ -29,10 +29,137 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
29
  ));
30
30
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
31
 
32
+ // fetchBreaker.ts
33
+ var FAIL_THRESHOLD, ROLLING_WINDOW_MS, COOLDOWN_MS, HARD_BURST_THRESHOLD, HARD_BURST_WINDOW_MS, state, installed, allowedOrigins, getEntry, prune, keyFor, synthetic503, registerProtectedOrigin, installFetchBreaker;
34
+ var init_fetchBreaker = __esm({
35
+ "fetchBreaker.ts"() {
36
+ FAIL_THRESHOLD = 12;
37
+ ROLLING_WINDOW_MS = 5e3;
38
+ COOLDOWN_MS = 3e4;
39
+ HARD_BURST_THRESHOLD = 30;
40
+ HARD_BURST_WINDOW_MS = 1e3;
41
+ state = /* @__PURE__ */ new Map();
42
+ installed = false;
43
+ allowedOrigins = /* @__PURE__ */ new Set();
44
+ getEntry = (key) => {
45
+ let entry = state.get(key);
46
+ if (!entry) {
47
+ entry = { failures: [], attempts: [], blockedUntil: 0, warned: false };
48
+ state.set(key, entry);
49
+ }
50
+ return entry;
51
+ };
52
+ prune = (arr, now, windowMs) => {
53
+ const cutoff = now - windowMs;
54
+ while (arr.length && arr[0] < cutoff) arr.shift();
55
+ };
56
+ keyFor = (input, init) => {
57
+ let urlStr;
58
+ let method = (init?.method || (typeof input !== "string" && "method" in input ? input.method : "GET") || "GET").toUpperCase();
59
+ if (typeof input === "string") urlStr = input;
60
+ else if (input instanceof URL) urlStr = input.toString();
61
+ else if (input && typeof input.url === "string") urlStr = input.url;
62
+ else return null;
63
+ try {
64
+ const u = new URL(urlStr, typeof window !== "undefined" ? window.location.href : "http://localhost");
65
+ if (allowedOrigins.size && !allowedOrigins.has(u.origin)) return null;
66
+ if (!u.pathname.startsWith("/api/")) return null;
67
+ return `${method} ${u.origin}${u.pathname}`;
68
+ } catch {
69
+ return null;
70
+ }
71
+ };
72
+ synthetic503 = (key, retryInMs) => new Response(
73
+ JSON.stringify({
74
+ error: "circuit_breaker_open",
75
+ message: `Too many failures for ${key}. Cooling down for ${Math.ceil(retryInMs / 1e3)}s.`
76
+ }),
77
+ {
78
+ status: 503,
79
+ statusText: "Service Unavailable (circuit breaker)",
80
+ headers: { "Content-Type": "application/json", "Retry-After": String(Math.ceil(retryInMs / 1e3)) }
81
+ }
82
+ );
83
+ registerProtectedOrigin = (url) => {
84
+ if (!url) return;
85
+ try {
86
+ const origin = new URL(url, typeof window !== "undefined" ? window.location.href : "http://localhost").origin;
87
+ allowedOrigins.add(origin);
88
+ } catch {
89
+ }
90
+ };
91
+ installFetchBreaker = () => {
92
+ if (installed) return;
93
+ if (typeof window === "undefined" || typeof window.fetch !== "function") return;
94
+ installed = true;
95
+ const original = window.fetch.bind(window);
96
+ window.fetch = (async (input, init) => {
97
+ const key = keyFor(input, init);
98
+ if (!key) return original(input, init);
99
+ const entry = getEntry(key);
100
+ const now = Date.now();
101
+ if (entry.blockedUntil > now) {
102
+ return synthetic503(key, entry.blockedUntil - now);
103
+ }
104
+ entry.attempts.push(now);
105
+ prune(entry.attempts, now, HARD_BURST_WINDOW_MS);
106
+ if (entry.attempts.length > HARD_BURST_THRESHOLD) {
107
+ entry.blockedUntil = now + COOLDOWN_MS;
108
+ if (!entry.warned) {
109
+ entry.warned = true;
110
+ console.error(
111
+ `[fetchBreaker] Burst detected on ${key} (${entry.attempts.length} calls / ${HARD_BURST_WINDOW_MS}ms). Blocking for ${COOLDOWN_MS / 1e3}s. Fix the caller \u2014 this is almost always a missing useEffect dep or a render loop.`
112
+ );
113
+ }
114
+ return synthetic503(key, COOLDOWN_MS);
115
+ }
116
+ let response;
117
+ try {
118
+ response = await original(input, init);
119
+ } catch (err) {
120
+ const ts = Date.now();
121
+ entry.failures.push(ts);
122
+ prune(entry.failures, ts, ROLLING_WINDOW_MS);
123
+ if (entry.failures.length >= FAIL_THRESHOLD) {
124
+ entry.blockedUntil = ts + COOLDOWN_MS;
125
+ if (!entry.warned) {
126
+ entry.warned = true;
127
+ console.error(
128
+ `[fetchBreaker] ${entry.failures.length} network errors on ${key} in ${ROLLING_WINDOW_MS / 1e3}s. Blocking for ${COOLDOWN_MS / 1e3}s.`
129
+ );
130
+ }
131
+ }
132
+ throw err;
133
+ }
134
+ if (response.status >= 500 || response.status === 0) {
135
+ const ts = Date.now();
136
+ entry.failures.push(ts);
137
+ prune(entry.failures, ts, ROLLING_WINDOW_MS);
138
+ if (entry.failures.length >= FAIL_THRESHOLD) {
139
+ entry.blockedUntil = ts + COOLDOWN_MS;
140
+ if (!entry.warned) {
141
+ entry.warned = true;
142
+ console.error(
143
+ `[fetchBreaker] ${entry.failures.length} ${response.status}s on ${key} in ${ROLLING_WINDOW_MS / 1e3}s. Blocking for ${COOLDOWN_MS / 1e3}s.`
144
+ );
145
+ }
146
+ }
147
+ } else if (response.status < 400) {
148
+ entry.failures.length = 0;
149
+ entry.warned = false;
150
+ }
151
+ return response;
152
+ });
153
+ };
154
+ }
155
+ });
156
+
32
157
  // api.ts
33
- var DEV_BACKEND, PROD_BACKEND, CLOUD_DOMAINS, getEnvVar, isDevEnvironment, isCloudDomain, isCloud, isOnprem, getDefaultBaseUrl, _regionUrl, _trackedOrgId, getTrackedOrgId, API_CONFIG, getApiUrl, shuffleFetch, getAuthHeader;
158
+ var DEV_BACKEND, PROD_BACKEND, CLOUD_DOMAINS, getEnvVar, isDevEnvironment, isCloudDomain, isCloud, isOnprem, getDefaultBaseUrl, _regionUrl, _trackedOrgId, _hostBaseUrl, isShufflerSubdomain, setRegionUrl, resetRegionUrl, setHostBaseUrl, getHostBaseUrl, getTrackedOrgId, API_CONFIG, getApiUrl, shuffleFetch, getAuthHeader;
34
159
  var init_api = __esm({
35
160
  "api.ts"() {
161
+ init_fetchBreaker();
162
+ installFetchBreaker();
36
163
  DEV_BACKEND = "https://tunnel.schemaless.org";
37
164
  PROD_BACKEND = "https://shuffler.io";
38
165
  CLOUD_DOMAINS = ["security.shuffler.io", "shutdown.no"];
@@ -69,11 +196,59 @@ var init_api = __esm({
69
196
  };
70
197
  _regionUrl = null;
71
198
  _trackedOrgId = null;
199
+ _hostBaseUrl = null;
200
+ isShufflerSubdomain = (url) => {
201
+ try {
202
+ const parsed = new URL(url);
203
+ return parsed.hostname.endsWith(".shuffler.io") || parsed.hostname === "shuffler.io";
204
+ } catch {
205
+ return false;
206
+ }
207
+ };
208
+ setRegionUrl = (regionUrl, orgId) => {
209
+ if (isDevEnvironment()) {
210
+ _trackedOrgId = orgId || null;
211
+ return;
212
+ }
213
+ _trackedOrgId = orgId || null;
214
+ if (regionUrl && isShufflerSubdomain(regionUrl)) {
215
+ const normalized = regionUrl.replace(/\/+$/, "");
216
+ if (normalized !== PROD_BACKEND) {
217
+ _regionUrl = normalized;
218
+ console.log(`[API] Region URL set to: ${_regionUrl}`);
219
+ return;
220
+ }
221
+ }
222
+ _regionUrl = null;
223
+ };
224
+ resetRegionUrl = () => {
225
+ if (_regionUrl) {
226
+ console.log(`[API] Region URL reset to default (org changed)`);
227
+ }
228
+ _regionUrl = null;
229
+ };
230
+ setHostBaseUrl = (url) => {
231
+ const next = url ? url.replace(/\/+$/, "") : null;
232
+ if (next === _hostBaseUrl) return;
233
+ _hostBaseUrl = next;
234
+ if (next) {
235
+ try {
236
+ registerProtectedOrigin(next);
237
+ } catch {
238
+ }
239
+ }
240
+ };
241
+ getHostBaseUrl = () => _hostBaseUrl;
72
242
  getTrackedOrgId = () => _trackedOrgId;
73
243
  API_CONFIG = {
74
- // Shuffle backend URL - uses region URL if set, otherwise default
244
+ // Shuffle backend URL — host override beats region URL beats default.
75
245
  get baseUrl() {
76
- return _regionUrl || getDefaultBaseUrl();
246
+ const url = _hostBaseUrl || _regionUrl || getDefaultBaseUrl();
247
+ try {
248
+ registerProtectedOrigin(url);
249
+ } catch {
250
+ }
251
+ return url;
77
252
  },
78
253
  // API version
79
254
  version: "v1",
@@ -126,11 +301,12 @@ __export(appsCache_exports, {
126
301
  fetchAppsViaApiConfig: () => fetchAppsViaApiConfig,
127
302
  invalidateAppsCache: () => invalidateAppsCache
128
303
  });
129
- var TTL_MS2, cache2, cacheKey2, doFetch2, fetchApps, invalidateAppsCache, fetchAppsViaApiConfig;
304
+ var TTL_MS2, ERROR_TTL_MS, cache2, cacheKey2, doFetch2, fetchApps, invalidateAppsCache, fetchAppsViaApiConfig;
130
305
  var init_appsCache = __esm({
131
306
  "appsCache.ts"() {
132
307
  init_api();
133
308
  TTL_MS2 = 3e4;
309
+ ERROR_TTL_MS = 3e4;
134
310
  cache2 = /* @__PURE__ */ new Map();
135
311
  cacheKey2 = (o) => `${o.baseUrl}|${o.path || "/api/v1/apps"}|${o.apiKey || ""}|${o.orgId || ""}`;
136
312
  doFetch2 = async (o) => {
@@ -156,9 +332,9 @@ var init_appsCache = __esm({
156
332
  const promise = doFetch2(opts).then((data) => {
157
333
  cache2.set(key, { data, fetchedAt: Date.now() });
158
334
  return data;
159
- }).catch((err) => {
160
- cache2.delete(key);
161
- throw err;
335
+ }).catch(() => {
336
+ cache2.set(key, { data: [], fetchedAt: Date.now() - (TTL_MS2 - ERROR_TTL_MS) });
337
+ return [];
162
338
  });
163
339
  cache2.set(key, { ...entry, promise });
164
340
  return promise;
@@ -186,21 +362,21 @@ var init_appsCache = __esm({
186
362
  var index_exports = {};
187
363
  __export(index_exports, {
188
364
  API_CONFIG: () => API_CONFIG,
189
- AgentActivityList: () => AgentActivityList_default,
190
- AgentExecutionDrawer: () => AgentExecutionDrawer_default,
365
+ AgentActivityList: () => AgentActivityList2,
366
+ AgentExecutionDrawer: () => AgentExecutionDrawer2,
191
367
  AgentIcon: () => AgentIcon_default,
192
- AgentRunDiagnosisBanner: () => AgentRunDiagnosisBanner_default,
193
- AgentRunDrawer: () => AgentRunDrawer_default,
194
- AgentUI: () => AgentUI_default,
195
- AgentsView: () => AgentsView_default,
196
- AiAgentPromptsEditor: () => AiAgentPromptsEditor_default,
368
+ AgentRunDiagnosisBanner: () => AgentRunDiagnosisBanner2,
369
+ AgentRunDrawer: () => AgentRunDrawer2,
370
+ AgentUI: () => AgentUI2,
371
+ AgentsView: () => AgentsView2,
372
+ AiAgentPromptsEditor: () => AiAgentPromptsEditor2,
197
373
  AppAuthCard: () => AppAuthCard,
198
374
  AppAuthConfig: () => AppAuthConfig,
199
- AppAuthSection: () => AppAuthSection,
200
- AppDetailDrawer: () => AppDetailDrawer,
375
+ AppAuthSection: () => AppAuthSection2,
376
+ AppDetailDrawer: () => AppDetailDrawer2,
201
377
  AppDetailProvider: () => AppDetailProvider,
202
- AppSearchDrawer: () => AppSearchDrawer,
203
- AppTitleHeader: () => AppTitleHeader,
378
+ AppSearchDrawer: () => AppSearchDrawer2,
379
+ AppTitleHeader: () => AppTitleHeader2,
204
380
  CASES_PATTERNS: () => CASES_PATTERNS,
205
381
  COMMUNICATION_PATTERNS_NAMES: () => COMMUNICATION_PATTERNS_NAMES,
206
382
  DATASTORE_CATEGORIES: () => DATASTORE_CATEGORIES,
@@ -210,15 +386,15 @@ __export(index_exports, {
210
386
  INGEST_TICKETS_WORKFLOW_NAME: () => INGEST_TICKETS_WORKFLOW_NAME,
211
387
  IntegrationStatus: () => IntegrationStatus,
212
388
  SIEM_PATTERNS: () => SIEM_PATTERNS,
213
- ShuffleMCP: () => ShuffleMCP,
389
+ ShuffleMCP: () => ShuffleMCP2,
214
390
  ShuffleMcpThemeProvider: () => ShuffleMcpThemeProvider,
215
- ShufflePipelinesBanner: () => ShufflePipelinesBanner_default,
216
- SingulActionsPreview: () => SingulActionsPreview_default,
391
+ ShufflePipelinesBanner: () => ShufflePipelinesBanner2,
392
+ SingulActionsPreview: () => SingulActionsPreview2,
217
393
  THREAT_INTEL_PATTERNS: () => THREAT_INTEL_PATTERNS,
218
- TryMcpSection: () => TryMcpSection,
394
+ TryMcpSection: () => TryMcpSection2,
219
395
  UsageBar: () => UsageBar,
220
396
  VULN_SCANNER_PATTERNS: () => VULN_SCANNER_PATTERNS,
221
- default: () => ShuffleMCP_default,
397
+ default: () => index_default,
222
398
  deleteDatastoreItem: () => deleteDatastoreItem,
223
399
  deleteDatastoreItems: () => deleteDatastoreItems,
224
400
  diagnoseOutputWarning: () => diagnoseOutputWarning,
@@ -234,8 +410,10 @@ __export(index_exports, {
234
410
  getDatastoreItem: () => getDatastoreItem,
235
411
  getDatastoreItemPublic: () => getDatastoreItemPublic,
236
412
  getFailureInfo: () => getFailureInfo,
413
+ getHostBaseUrl: () => getHostBaseUrl,
237
414
  getIngestionCategory: () => getIngestionCategory,
238
415
  hasOutputWarning: () => hasOutputWarning,
416
+ installFetchBreaker: () => installFetchBreaker,
239
417
  invalidateAppsCache: () => invalidateAppsCache,
240
418
  invalidateResolvedApps: () => invalidateResolvedApps,
241
419
  isCloud: () => isCloud,
@@ -249,12 +427,16 @@ __export(index_exports, {
249
427
  normalizeAppName: () => normalizeAppName,
250
428
  parseRunResult: () => parseRunResult,
251
429
  refreshAllIntegrationStatus: () => refreshAllIntegrationStatus,
430
+ registerProtectedOrigin: () => registerProtectedOrigin,
431
+ resetRegionUrl: () => resetRegionUrl,
252
432
  resolveApp: () => resolveApp,
253
433
  resolveApps: () => resolveApps,
254
434
  searchAgentActivity: () => searchAgentActivity,
255
435
  seedResolvedApp: () => seedResolvedApp,
256
436
  setDatastoreItem: () => setDatastoreItem,
257
437
  setDatastoreItems: () => setDatastoreItems,
438
+ setHostBaseUrl: () => setHostBaseUrl,
439
+ setRegionUrl: () => setRegionUrl,
258
440
  setRuntimeOrgId: () => setRuntimeOrgId,
259
441
  setToastImpl: () => setToastImpl,
260
442
  shuffleFetch: () => shuffleFetch,
@@ -262,10 +444,12 @@ __export(index_exports, {
262
444
  useAppAuth: () => useAppAuth,
263
445
  useAppDetail: () => useAppDetail,
264
446
  useAppDetailOptional: () => useAppDetailOptional,
265
- useAppLookup: () => useAppLookup
447
+ useAppLookup: () => useAppLookup,
448
+ useSyncHostBaseUrl: () => useSyncHostBaseUrl
266
449
  });
267
450
  module.exports = __toCommonJS(index_exports);
268
451
  var import_shuffle_mcp2 = require("./shuffle-mcp-CN72CJJQ.css");
452
+ var import_react20 = __toESM(require("react"));
269
453
 
270
454
  // ShuffleMcpThemeProvider.tsx
271
455
  var import_react = __toESM(require("react"));
@@ -352,7 +536,7 @@ var useHtmlDarkClass = (enabled) => {
352
536
  };
353
537
  var ShuffleMcpThemeProvider = ({
354
538
  children,
355
- mode = "auto"
539
+ mode = "dark"
356
540
  }) => {
357
541
  const parent = (0, import_material.useTheme)();
358
542
  const htmlIsDark = useHtmlDarkClass(mode === "auto");
@@ -372,14 +556,15 @@ var ShuffleMcpThemeProvider = ({
372
556
  [parent, effectiveDark]
373
557
  );
374
558
  const tree = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.ThemeProvider, { theme: merged, children });
559
+ const scopeClassName = mode === "light" ? "shuffle-mcp-scope" : "shuffle-mcp-scope dark";
375
560
  if (mode === "light" || mode === "dark") {
376
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: mode === "dark" ? "dark" : "", "data-shuffle-mode": mode, children: tree });
561
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: scopeClassName, "data-shuffle-mode": mode, "data-shuffle-mcp-root": true, children: tree });
377
562
  }
378
- return tree;
563
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "shuffle-mcp-scope", "data-shuffle-mode": "auto", "data-shuffle-mcp-root": true, children: tree });
379
564
  };
380
565
 
381
566
  // ShuffleMCP.tsx
382
- var import_react11 = __toESM(require("react"));
567
+ var import_react12 = __toESM(require("react"));
383
568
  var import_algoliasearch = require("algoliasearch");
384
569
  var import_material10 = require("@mui/material");
385
570
 
@@ -5765,19 +5950,32 @@ init_appsCache();
5765
5950
  var React2 = __toESM(require("react"));
5766
5951
  var import_framer_motion7 = require("framer-motion");
5767
5952
  var import_jsx_runtime13 = require("react/jsx-runtime");
5768
- var cn = (...inputs) => inputs.filter(Boolean).join(" ");
5769
- var sizeClasses = {
5953
+ var SIZE = {
5770
5954
  sm: {
5771
- container: "p-0.5 text-[11px]",
5772
- item: "px-2.5 py-1 gap-1.5",
5773
- count: "min-w-[16px] h-[16px] px-1 text-[10px]",
5774
- divider: "h-4 mx-0.5"
5955
+ containerPadding: "2px",
5956
+ fontSize: "11px",
5957
+ itemPaddingY: "4px",
5958
+ itemPaddingX: "10px",
5959
+ itemGap: "6px",
5960
+ countMin: "16px",
5961
+ countH: "16px",
5962
+ countPx: "4px",
5963
+ countFs: "10px",
5964
+ dividerH: "16px",
5965
+ dividerMx: "2px"
5775
5966
  },
5776
5967
  md: {
5777
- container: "p-1 text-xs",
5778
- item: "px-3 py-1.5 gap-1.5",
5779
- count: "min-w-[18px] h-[18px] px-1.5 text-[10px]",
5780
- divider: "h-5 mx-1"
5968
+ containerPadding: "4px",
5969
+ fontSize: "12px",
5970
+ itemPaddingY: "6px",
5971
+ itemPaddingX: "12px",
5972
+ itemGap: "6px",
5973
+ countMin: "18px",
5974
+ countH: "18px",
5975
+ countPx: "6px",
5976
+ countFs: "10px",
5977
+ dividerH: "20px",
5978
+ dividerMx: "4px"
5781
5979
  }
5782
5980
  };
5783
5981
  var uid = 0;
@@ -5801,25 +5999,36 @@ function SegmentedControl({
5801
5999
  }) {
5802
6000
  const autoId = useUniqueId("segmented");
5803
6001
  const groupId = layoutId ?? autoId;
5804
- const s = sizeClasses[size];
6002
+ const s = SIZE[size];
5805
6003
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_framer_motion7.LayoutGroup, { id: groupId, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
5806
6004
  "div",
5807
6005
  {
5808
6006
  role: "tablist",
5809
6007
  "aria-label": ariaLabel,
5810
- className: cn(
5811
- "inline-flex items-center gap-0.5 rounded-full",
5812
- variant === "outline" ? "border border-border bg-transparent" : "border border-transparent bg-muted/40",
5813
- s.container,
5814
- className
5815
- ),
6008
+ className,
6009
+ style: {
6010
+ display: "inline-flex",
6011
+ alignItems: "center",
6012
+ gap: "2px",
6013
+ borderRadius: 9999,
6014
+ padding: s.containerPadding,
6015
+ fontSize: s.fontSize,
6016
+ border: variant === "outline" ? "1px solid hsl(var(--border))" : "1px solid transparent",
6017
+ background: variant === "outline" ? "transparent" : "hsl(var(--muted) / 0.4)"
6018
+ },
5816
6019
  children: options.map((opt, i) => {
5817
6020
  if (opt.type === "divider") {
5818
6021
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
5819
6022
  "span",
5820
6023
  {
5821
6024
  "aria-hidden": true,
5822
- className: cn("w-px bg-border self-center", s.divider)
6025
+ style: {
6026
+ width: 1,
6027
+ height: s.dividerH,
6028
+ margin: `0 ${s.dividerMx}`,
6029
+ background: "hsl(var(--border))",
6030
+ alignSelf: "center"
6031
+ }
5823
6032
  },
5824
6033
  opt.key ?? `divider-${i}`
5825
6034
  );
@@ -5841,20 +6050,46 @@ function SegmentedControl({
5841
6050
  if (isAction) opt.onClick();
5842
6051
  else onChange(opt.value);
5843
6052
  },
5844
- className: cn(
5845
- "relative inline-flex items-center rounded-full font-medium",
5846
- "transition-colors duration-300",
5847
- "focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
5848
- s.item,
5849
- active ? "text-foreground" : "text-muted-foreground hover:text-foreground",
5850
- opt.disabled && "opacity-50 cursor-not-allowed"
5851
- ),
6053
+ style: {
6054
+ position: "relative",
6055
+ display: "inline-flex",
6056
+ alignItems: "center",
6057
+ gap: s.itemGap,
6058
+ padding: `${s.itemPaddingY} ${s.itemPaddingX}`,
6059
+ borderRadius: 9999,
6060
+ fontWeight: 500,
6061
+ fontSize: s.fontSize,
6062
+ background: "transparent",
6063
+ border: "none",
6064
+ cursor: opt.disabled ? "not-allowed" : "pointer",
6065
+ color: active ? "hsl(var(--foreground))" : "hsl(var(--muted-foreground))",
6066
+ opacity: opt.disabled ? 0.5 : 1,
6067
+ transition: "color 200ms ease",
6068
+ outline: "none",
6069
+ fontFamily: "inherit"
6070
+ },
6071
+ onMouseEnter: (e) => {
6072
+ if (!active && !opt.disabled) {
6073
+ e.currentTarget.style.color = "hsl(var(--foreground))";
6074
+ }
6075
+ },
6076
+ onMouseLeave: (e) => {
6077
+ if (!active && !opt.disabled) {
6078
+ e.currentTarget.style.color = "hsl(var(--muted-foreground))";
6079
+ }
6080
+ },
5852
6081
  children: [
5853
6082
  active && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
5854
6083
  import_framer_motion7.motion.span,
5855
6084
  {
5856
6085
  layoutId: `${groupId}-pill`,
5857
- className: "absolute inset-0 rounded-full bg-muted border border-border",
6086
+ style: {
6087
+ position: "absolute",
6088
+ inset: 0,
6089
+ borderRadius: 9999,
6090
+ background: "hsl(var(--muted))",
6091
+ border: "1px solid hsl(var(--border))"
6092
+ },
5858
6093
  initial: false,
5859
6094
  transition: {
5860
6095
  type: "spring",
@@ -5863,15 +6098,39 @@ function SegmentedControl({
5863
6098
  }
5864
6099
  }
5865
6100
  ),
5866
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "relative z-10 inline-flex items-center gap-1.5", children: opt.label }),
6101
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
6102
+ "span",
6103
+ {
6104
+ style: {
6105
+ position: "relative",
6106
+ zIndex: 1,
6107
+ display: "inline-flex",
6108
+ alignItems: "center",
6109
+ gap: s.itemGap
6110
+ },
6111
+ children: opt.label
6112
+ }
6113
+ ),
5867
6114
  !isAction && typeof opt.count === "number" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
5868
6115
  "span",
5869
6116
  {
5870
- className: cn(
5871
- "relative z-10 inline-flex items-center justify-center rounded-md font-semibold tabular-nums border border-border/60",
5872
- s.count,
5873
- active ? "bg-transparent text-foreground" : "bg-transparent text-muted-foreground"
5874
- ),
6117
+ style: {
6118
+ position: "relative",
6119
+ zIndex: 1,
6120
+ display: "inline-flex",
6121
+ alignItems: "center",
6122
+ justifyContent: "center",
6123
+ minWidth: s.countMin,
6124
+ height: s.countH,
6125
+ padding: `0 ${s.countPx}`,
6126
+ fontSize: s.countFs,
6127
+ fontWeight: 600,
6128
+ fontVariantNumeric: "tabular-nums",
6129
+ borderRadius: 6,
6130
+ border: "1px solid hsl(var(--border) / 0.6)",
6131
+ color: active ? "hsl(var(--foreground))" : "hsl(var(--muted-foreground))",
6132
+ background: "transparent"
6133
+ },
5875
6134
  children: opt.count
5876
6135
  }
5877
6136
  )
@@ -5884,13 +6143,23 @@ function SegmentedControl({
5884
6143
  ) });
5885
6144
  }
5886
6145
 
6146
+ // useSyncHostBaseUrl.ts
6147
+ var import_react11 = require("react");
6148
+ init_api();
6149
+ var useSyncHostBaseUrl = (globalUrl) => {
6150
+ (0, import_react11.useEffect)(() => {
6151
+ if (!globalUrl) return;
6152
+ setHostBaseUrl(globalUrl);
6153
+ }, [globalUrl]);
6154
+ };
6155
+
5887
6156
  // ShuffleMCP.tsx
5888
6157
  var import_jsx_runtime14 = require("react/jsx-runtime");
5889
6158
  var DEFAULT_ALGOLIA_APP_ID = "JNSS5CFDZZ";
5890
6159
  var DEFAULT_ALGOLIA_API_KEY = "33e4e3564f4f060e96e0531957bed552";
5891
6160
  var DEFAULT_ALGOLIA_INDEX = "appsearch";
5892
6161
  var EMPTY_SELECTED_APPS = [];
5893
- var ShuffleMCP = import_react11.default.forwardRef(({
6162
+ var ShuffleMCP = import_react12.default.forwardRef(({
5894
6163
  authToken,
5895
6164
  orgId,
5896
6165
  placeholder = "Search apps...",
@@ -5927,25 +6196,27 @@ var ShuffleMCP = import_react11.default.forwardRef(({
5927
6196
  renderLoadingState,
5928
6197
  onAppSelected,
5929
6198
  onSelectionChange,
5930
- onSearchChange
6199
+ onSearchChange,
6200
+ globalUrl
5931
6201
  }, ref) => {
5932
- const [query, setQuery] = (0, import_react11.useState)(initialQuery);
5933
- const [results, setResults] = (0, import_react11.useState)([]);
5934
- const [privateApps, setPrivateApps] = (0, import_react11.useState)([]);
5935
- const [sourceFilter, setSourceFilter] = (0, import_react11.useState)("all");
5936
- const [isLoading, setIsLoading] = (0, import_react11.useState)(false);
5937
- const [searchError, setSearchError] = (0, import_react11.useState)(null);
5938
- const [isOpen, setIsOpen] = (0, import_react11.useState)(false);
5939
- const [selectedIndex, setSelectedIndex] = (0, import_react11.useState)(-1);
5940
- const [internalSelectedApps, setInternalSelectedApps] = (0, import_react11.useState)(selectedApps);
5941
- const [authenticatedApps, setAuthenticatedApps] = (0, import_react11.useState)(externalAuthenticatedApps || []);
5942
- const [drawerApp, setDrawerApp] = (0, import_react11.useState)(null);
5943
- const hasInitialized = (0, import_react11.useRef)(false);
5944
- const containerRef = (0, import_react11.useRef)(null);
5945
- const inputRef = (0, import_react11.useRef)(null);
5946
- const debounceTimer = (0, import_react11.useRef)(null);
5947
- const searchClient = (0, import_react11.useRef)(null);
5948
- const fetchAuthenticatedApps2 = (0, import_react11.useCallback)(async () => {
6202
+ useSyncHostBaseUrl(globalUrl);
6203
+ const [query, setQuery] = (0, import_react12.useState)(initialQuery);
6204
+ const [results, setResults] = (0, import_react12.useState)([]);
6205
+ const [privateApps, setPrivateApps] = (0, import_react12.useState)([]);
6206
+ const [sourceFilter, setSourceFilter] = (0, import_react12.useState)("all");
6207
+ const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
6208
+ const [searchError, setSearchError] = (0, import_react12.useState)(null);
6209
+ const [isOpen, setIsOpen] = (0, import_react12.useState)(false);
6210
+ const [selectedIndex, setSelectedIndex] = (0, import_react12.useState)(-1);
6211
+ const [internalSelectedApps, setInternalSelectedApps] = (0, import_react12.useState)(selectedApps);
6212
+ const [authenticatedApps, setAuthenticatedApps] = (0, import_react12.useState)(externalAuthenticatedApps || []);
6213
+ const [drawerApp, setDrawerApp] = (0, import_react12.useState)(null);
6214
+ const hasInitialized = (0, import_react12.useRef)(false);
6215
+ const containerRef = (0, import_react12.useRef)(null);
6216
+ const inputRef = (0, import_react12.useRef)(null);
6217
+ const debounceTimer = (0, import_react12.useRef)(null);
6218
+ const searchClient = (0, import_react12.useRef)(null);
6219
+ const fetchAuthenticatedApps2 = (0, import_react12.useCallback)(async () => {
5949
6220
  if (!apiKey) return;
5950
6221
  try {
5951
6222
  const response = await fetch(`${apiBaseUrl}${authPath}`, {
@@ -5965,10 +6236,10 @@ var ShuffleMCP = import_react11.default.forwardRef(({
5965
6236
  console.error("Failed to fetch authenticated apps:", error);
5966
6237
  }
5967
6238
  }, [apiKey, apiBaseUrl, authPath, orgId]);
5968
- (0, import_react11.useEffect)(() => {
6239
+ (0, import_react12.useEffect)(() => {
5969
6240
  fetchAuthenticatedApps2();
5970
6241
  }, [fetchAuthenticatedApps2]);
5971
- (0, import_react11.useEffect)(() => {
6242
+ (0, import_react12.useEffect)(() => {
5972
6243
  if (disablePrivateApps) {
5973
6244
  setPrivateApps([]);
5974
6245
  return;
@@ -6008,7 +6279,7 @@ var ShuffleMCP = import_react11.default.forwardRef(({
6008
6279
  };
6009
6280
  fetchPrivateApps();
6010
6281
  }, [apiKey, apiBaseUrl, privateAppsPath, disablePrivateApps, orgId]);
6011
- (0, import_react11.useEffect)(() => {
6282
+ (0, import_react12.useEffect)(() => {
6012
6283
  if (authenticatedApps.length > 0 && results.length > 0) {
6013
6284
  const validatedApps = authenticatedApps.filter((auth) => auth.validation?.valid);
6014
6285
  const appsToAutoSelect = results.filter(
@@ -6028,12 +6299,12 @@ var ShuffleMCP = import_react11.default.forwardRef(({
6028
6299
  }
6029
6300
  }
6030
6301
  }, [authenticatedApps, results]);
6031
- (0, import_react11.useEffect)(() => {
6302
+ (0, import_react12.useEffect)(() => {
6032
6303
  if (externalAuthenticatedApps) {
6033
6304
  setAuthenticatedApps(externalAuthenticatedApps);
6034
6305
  }
6035
6306
  }, [externalAuthenticatedApps]);
6036
- (0, import_react11.useEffect)(() => {
6307
+ (0, import_react12.useEffect)(() => {
6037
6308
  searchClient.current = (0, import_algoliasearch.algoliasearch)(algoliaAppId, algoliaApiKey);
6038
6309
  if (!hasInitialized.current) {
6039
6310
  hasInitialized.current = true;
@@ -6046,10 +6317,10 @@ var ShuffleMCP = import_react11.default.forwardRef(({
6046
6317
  }, 100);
6047
6318
  }
6048
6319
  }, []);
6049
- (0, import_react11.useEffect)(() => {
6320
+ (0, import_react12.useEffect)(() => {
6050
6321
  setInternalSelectedApps(selectedApps);
6051
6322
  }, [selectedApps]);
6052
- (0, import_react11.useEffect)(() => {
6323
+ (0, import_react12.useEffect)(() => {
6053
6324
  const handleClickOutside = (event) => {
6054
6325
  if (containerRef.current && !containerRef.current.contains(event.target)) {
6055
6326
  setIsOpen(false);
@@ -6059,23 +6330,23 @@ var ShuffleMCP = import_react11.default.forwardRef(({
6059
6330
  document.addEventListener("click", handleClickOutside);
6060
6331
  return () => document.removeEventListener("click", handleClickOutside);
6061
6332
  }, []);
6062
- const isAppConfigured = (0, import_react11.useCallback)((app) => {
6333
+ const isAppConfigured = (0, import_react12.useCallback)((app) => {
6063
6334
  return authenticatedApps.some(
6064
6335
  (auth) => auth.app.name.toLowerCase() === app.name.toLowerCase() && auth.active === true
6065
6336
  );
6066
6337
  }, [authenticatedApps]);
6067
- const isAppValidated = (0, import_react11.useCallback)((app) => {
6338
+ const isAppValidated = (0, import_react12.useCallback)((app) => {
6068
6339
  return authenticatedApps.some(
6069
6340
  (auth) => auth.app.name.toLowerCase() === app.name.toLowerCase() && auth.validation?.valid === true
6070
6341
  );
6071
6342
  }, [authenticatedApps]);
6072
- const getAppAuthState = (0, import_react11.useCallback)((app) => {
6343
+ const getAppAuthState = (0, import_react12.useCallback)((app) => {
6073
6344
  return {
6074
6345
  configured: isAppConfigured(app),
6075
6346
  validated: isAppValidated(app)
6076
6347
  };
6077
6348
  }, [isAppConfigured, isAppValidated]);
6078
- const performSearch = (0, import_react11.useCallback)(async (searchQuery) => {
6349
+ const performSearch = (0, import_react12.useCallback)(async (searchQuery) => {
6079
6350
  if (!searchClient.current) {
6080
6351
  return;
6081
6352
  }
@@ -6109,7 +6380,7 @@ var ShuffleMCP = import_react11.default.forwardRef(({
6109
6380
  setIsLoading(false);
6110
6381
  }
6111
6382
  }, [hitsPerPage, algoliaIndexName, privateApps.length]);
6112
- (0, import_react11.useImperativeHandle)(ref, () => ({
6383
+ (0, import_react12.useImperativeHandle)(ref, () => ({
6113
6384
  search: (searchQuery) => {
6114
6385
  setQuery(searchQuery);
6115
6386
  onSearchChange?.(searchQuery);
@@ -6121,7 +6392,7 @@ var ShuffleMCP = import_react11.default.forwardRef(({
6121
6392
  },
6122
6393
  getQuery: () => query
6123
6394
  }), [performSearch, onSearchChange, query]);
6124
- const handleInputChange = (0, import_react11.useCallback)((event) => {
6395
+ const handleInputChange = (0, import_react12.useCallback)((event) => {
6125
6396
  const value = event.target.value;
6126
6397
  setQuery(value);
6127
6398
  setSelectedIndex(-1);
@@ -6133,7 +6404,7 @@ var ShuffleMCP = import_react11.default.forwardRef(({
6133
6404
  performSearch(value);
6134
6405
  }, 300);
6135
6406
  }, [performSearch, onSearchChange]);
6136
- const selectApp = (0, import_react11.useCallback)((app) => {
6407
+ const selectApp = (0, import_react12.useCallback)((app) => {
6137
6408
  const handoffToken = apiKey || authToken || "";
6138
6409
  const authUrl = `${apiBaseUrl}${appAuthPath}?app_id=${app.objectID}&auth=${handoffToken}&source=shuffle${orgId ? `&org_id=${encodeURIComponent(orgId)}` : ""}`;
6139
6410
  if (multiSelect) {
@@ -6153,7 +6424,7 @@ var ShuffleMCP = import_react11.default.forwardRef(({
6153
6424
  setIsOpen(false);
6154
6425
  }
6155
6426
  }, [authToken, apiKey, apiBaseUrl, appAuthPath, orgId, multiSelect, internalSelectedApps, onAppSelected, onSelectionChange, preventDefault]);
6156
- const handleKeyDown = (0, import_react11.useCallback)((event) => {
6427
+ const handleKeyDown = (0, import_react12.useCallback)((event) => {
6157
6428
  if (!isOpen) return;
6158
6429
  switch (event.key) {
6159
6430
  case "ArrowDown":
@@ -6178,14 +6449,14 @@ var ShuffleMCP = import_react11.default.forwardRef(({
6178
6449
  break;
6179
6450
  }
6180
6451
  }, [isOpen, results, selectedIndex, selectApp]);
6181
- const isAppSelected = (0, import_react11.useCallback)((app) => {
6452
+ const isAppSelected = (0, import_react12.useCallback)((app) => {
6182
6453
  const norm4 = (s) => (s || "").toLowerCase().replace(/[\s-]+/g, "_");
6183
6454
  const target = norm4(app.name);
6184
6455
  return internalSelectedApps.some(
6185
6456
  (a) => a.objectID === app.objectID || target && norm4(a.name) === target
6186
6457
  );
6187
6458
  }, [internalSelectedApps]);
6188
- const filteredPrivateApps = (0, import_react11.useMemo)(() => {
6459
+ const filteredPrivateApps = (0, import_react12.useMemo)(() => {
6189
6460
  if (privateApps.length === 0) return [];
6190
6461
  const q = query.trim().toLowerCase();
6191
6462
  if (!q) return privateApps;
@@ -6193,7 +6464,7 @@ var ShuffleMCP = import_react11.default.forwardRef(({
6193
6464
  (a) => a.name.toLowerCase().includes(q) || (a.description || "").toLowerCase().includes(q) || (a.categories || []).some((c) => c.toLowerCase().includes(q))
6194
6465
  );
6195
6466
  }, [privateApps, query]);
6196
- const displayResults = (0, import_react11.useMemo)(() => {
6467
+ const displayResults = (0, import_react12.useMemo)(() => {
6197
6468
  const norm4 = (n) => (n || "").toLowerCase().replace(/[\s_\-]+/g, "");
6198
6469
  let merged;
6199
6470
  if (sourceFilter === "public") {
@@ -6213,7 +6484,7 @@ var ShuffleMCP = import_react11.default.forwardRef(({
6213
6484
  const pinnedNames = new Set(pinnedApps.map((a) => norm4(a.name)));
6214
6485
  return [...pinnedApps, ...merged.filter((a) => !pinnedNames.has(norm4(a.name)))];
6215
6486
  }, [pinnedApps, results, filteredPrivateApps, sourceFilter, isAppConfigured]);
6216
- const getGridColumnsStyle = (0, import_react11.useMemo)(() => {
6487
+ const getGridColumnsStyle = (0, import_react12.useMemo)(() => {
6217
6488
  if (layout !== "grid") return {};
6218
6489
  const cols = typeof gridColumns === "number" ? gridColumns : gridColumns.md || 3;
6219
6490
  return { "--singul-grid-columns": cols };
@@ -6420,10 +6691,9 @@ var ShuffleMCP = import_react11.default.forwardRef(({
6420
6691
  );
6421
6692
  });
6422
6693
  ShuffleMCP.displayName = "ShuffleMCP";
6423
- var ShuffleMCP_default = ShuffleMCP;
6424
6694
 
6425
6695
  // AppSearchDrawer.tsx
6426
- var import_react12 = require("react");
6696
+ var import_react13 = require("react");
6427
6697
  var import_lucide_react7 = require("lucide-react");
6428
6698
  var import_material11 = require("@mui/material");
6429
6699
  var import_framer_motion8 = require("framer-motion");
@@ -6528,10 +6798,10 @@ function AppSearchDrawer({
6528
6798
  selectedApps,
6529
6799
  onSelectionChange
6530
6800
  }) {
6531
- const [detailAppName, setDetailAppName] = (0, import_react12.useState)(null);
6532
- const [detailAppId, setDetailAppId] = (0, import_react12.useState)(null);
6533
- const [highlightActive, setHighlightActive] = (0, import_react12.useState)(false);
6534
- (0, import_react12.useEffect)(() => {
6801
+ const [detailAppName, setDetailAppName] = (0, import_react13.useState)(null);
6802
+ const [detailAppId, setDetailAppId] = (0, import_react13.useState)(null);
6803
+ const [highlightActive, setHighlightActive] = (0, import_react13.useState)(false);
6804
+ (0, import_react13.useEffect)(() => {
6535
6805
  setHighlightActive(false);
6536
6806
  if (!open || !highlightAppName) return;
6537
6807
  const t = setTimeout(() => setHighlightActive(true), highlightDelayMs);
@@ -6763,7 +7033,7 @@ function AppSearchDrawer({
6763
7033
  transition: { duration: 0.2 },
6764
7034
  style: { height: "100%", minHeight: 0 },
6765
7035
  children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
6766
- ShuffleMCP,
7036
+ ShuffleMCP2,
6767
7037
  {
6768
7038
  apiKey: API_CONFIG.apiKey || void 0,
6769
7039
  apiBaseUrl: API_CONFIG.baseUrl,
@@ -6812,7 +7082,7 @@ function AppSearchDrawer({
6812
7082
  }
6813
7083
  ),
6814
7084
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
6815
- AppDetailDrawer,
7085
+ AppDetailDrawer2,
6816
7086
  {
6817
7087
  open: open && detailAppName !== null,
6818
7088
  onClose: () => {
@@ -7093,7 +7363,7 @@ function ShufflePipelinesBanner() {
7093
7363
  var ShufflePipelinesBanner_default = ShufflePipelinesBanner;
7094
7364
 
7095
7365
  // AgentUI.tsx
7096
- var import_react14 = require("react");
7366
+ var import_react15 = require("react");
7097
7367
  var import_lucide_react11 = require("lucide-react");
7098
7368
  var import_react_router_dom2 = require("react-router-dom");
7099
7369
  var import_material16 = require("@mui/material");
@@ -7737,7 +8007,7 @@ var AgentDiagnosisCtas = ({ diagnosis, compact = false, tone = "medium" }) => {
7737
8007
  var AgentDiagnosisCtas_default = AgentDiagnosisCtas;
7738
8008
 
7739
8009
  // AgentRunDiagnosisBanner.tsx
7740
- var import_react13 = require("react");
8010
+ var import_react14 = require("react");
7741
8011
 
7742
8012
  // agentDiagnosis.ts
7743
8013
  var deepParseJsonStrings2 = (obj, depth = 0) => {
@@ -8114,13 +8384,13 @@ var writeDismissed = (key) => {
8114
8384
  }
8115
8385
  };
8116
8386
  var AgentRunDiagnosisBanner = ({ run, sx, onJumpToEvidence, executionId }) => {
8117
- const dismissKey = (0, import_react13.useMemo)(() => {
8387
+ const dismissKey = (0, import_react14.useMemo)(() => {
8118
8388
  if (executionId) return executionId;
8119
8389
  const fromRun = run?.execution_id;
8120
8390
  return typeof fromRun === "string" && fromRun ? fromRun : null;
8121
8391
  }, [executionId, run]);
8122
- const [dismissed, setDismissed] = (0, import_react13.useState)(() => readDismissed(dismissKey));
8123
- (0, import_react13.useEffect)(() => {
8392
+ const [dismissed, setDismissed] = (0, import_react14.useState)(() => readDismissed(dismissKey));
8393
+ (0, import_react14.useEffect)(() => {
8124
8394
  setDismissed(readDismissed(dismissKey));
8125
8395
  }, [dismissKey]);
8126
8396
  if (!run || dismissed) return null;
@@ -8399,7 +8669,7 @@ var TimelineRow = ({
8399
8669
  isAppAuthenticated,
8400
8670
  highlight = false
8401
8671
  }) => {
8402
- const [submitAttempted, setSubmitAttempted] = (0, import_react14.useState)(false);
8672
+ const [submitAttempted, setSubmitAttempted] = (0, import_react15.useState)(false);
8403
8673
  const validate = validateJson(item.details);
8404
8674
  const itemStart = item.start_time || 0;
8405
8675
  const itemEnd = item.end_time || itemStart;
@@ -8812,6 +9082,8 @@ var AgentUI = ({
8812
9082
  appPickerLabel = "Select Apps",
8813
9083
  appPickerTitle = "Select Apps",
8814
9084
  appPickerSubtitle = "Pick the tools the agent is allowed to use for this run",
9085
+ onChooseLLM,
9086
+ hideChooseLLM = false,
8815
9087
  submitTooltip = "\u2318+Enter to send",
8816
9088
  submitIcon,
8817
9089
  submitOverride,
@@ -8833,70 +9105,70 @@ var AgentUI = ({
8833
9105
  sx,
8834
9106
  contentSx
8835
9107
  }) => {
8836
- const resolveUrl2 = (0, import_react14.useCallback)(
9108
+ const resolveUrl2 = (0, import_react15.useCallback)(
8837
9109
  (path) => apiBaseUrl ? `${apiBaseUrl.replace(/\/+$/, "")}${path}` : getApiUrl(path),
8838
9110
  [apiBaseUrl]
8839
9111
  );
8840
- const resolveHeaders2 = (0, import_react14.useCallback)(() => {
9112
+ const resolveHeaders2 = (0, import_react15.useCallback)(() => {
8841
9113
  const h = apiKey ? { Authorization: `Bearer ${apiKey}` } : { ...getAuthHeader() };
8842
9114
  if (orgId) h["Org-Id"] = orgId;
8843
9115
  return h;
8844
9116
  }, [apiKey, orgId]);
8845
9117
  const hasApiKey = !!apiKey || !!API_CONFIG.apiKey;
8846
9118
  const navigate = (0, import_react_router_dom2.useNavigate)();
8847
- const [actionInput, setActionInput] = (0, import_react14.useState)(defaultInput);
9119
+ const [actionInput, setActionInput] = (0, import_react15.useState)(defaultInput);
8848
9120
  const BUILTIN_DEFAULT_APPS = [
8849
9121
  { name: "http" },
8850
9122
  { name: "shuffle_tools" }
8851
9123
  ];
8852
- const [chosenApps, setChosenApps] = (0, import_react14.useState)(apps ?? defaultApps ?? BUILTIN_DEFAULT_APPS);
8853
- const [availableApps, setAvailableApps] = (0, import_react14.useState)([]);
8854
- const [executionApps, setExecutionApps] = (0, import_react14.useState)([]);
8855
- const [resolvedToolApps, setResolvedToolApps] = (0, import_react14.useState)({});
8856
- const [appSearchOpen, setAppSearchOpen] = (0, import_react14.useState)(false);
8857
- const [authDrawerApp, setAuthDrawerApp] = (0, import_react14.useState)(null);
8858
- const [agentRequestLoading, setAgentRequestLoading] = (0, import_react14.useState)(false);
8859
- const [execution, setExecution] = (0, import_react14.useState)(null);
8860
- const [agentData, setAgentData] = (0, import_react14.useState)({});
8861
- const [agentActionResult, setAgentActionResult] = (0, import_react14.useState)(null);
8862
- const [showStarter, setShowStarter] = (0, import_react14.useState)(true);
8863
- const [scheduleAnchor, setScheduleAnchor] = (0, import_react14.useState)(null);
8864
- const [scheduleCron, setScheduleCron] = (0, import_react14.useState)("0 * * * *");
8865
- const [scheduleSaving, setScheduleSaving] = (0, import_react14.useState)(false);
8866
- const [scheduleSteps, setScheduleSteps] = (0, import_react14.useState)([
9124
+ const [chosenApps, setChosenApps] = (0, import_react15.useState)(apps ?? defaultApps ?? BUILTIN_DEFAULT_APPS);
9125
+ const [availableApps, setAvailableApps] = (0, import_react15.useState)([]);
9126
+ const [executionApps, setExecutionApps] = (0, import_react15.useState)([]);
9127
+ const [resolvedToolApps, setResolvedToolApps] = (0, import_react15.useState)({});
9128
+ const [appSearchOpen, setAppSearchOpen] = (0, import_react15.useState)(false);
9129
+ const [authDrawerApp, setAuthDrawerApp] = (0, import_react15.useState)(null);
9130
+ const [agentRequestLoading, setAgentRequestLoading] = (0, import_react15.useState)(false);
9131
+ const [execution, setExecution] = (0, import_react15.useState)(null);
9132
+ const [agentData, setAgentData] = (0, import_react15.useState)({});
9133
+ const [agentActionResult, setAgentActionResult] = (0, import_react15.useState)(null);
9134
+ const [showStarter, setShowStarter] = (0, import_react15.useState)(true);
9135
+ const [scheduleAnchor, setScheduleAnchor] = (0, import_react15.useState)(null);
9136
+ const [scheduleCron, setScheduleCron] = (0, import_react15.useState)("0 * * * *");
9137
+ const [scheduleSaving, setScheduleSaving] = (0, import_react15.useState)(false);
9138
+ const [scheduleSteps, setScheduleSteps] = (0, import_react15.useState)([
8867
9139
  { id: "name", state: "pending" },
8868
9140
  { id: "workflow", state: "pending" },
8869
9141
  { id: "schedule", state: "pending" }
8870
9142
  ]);
8871
- const [schedFreq, setSchedFreq] = (0, import_react14.useState)("hours");
8872
- const [schedInterval, setSchedInterval] = (0, import_react14.useState)(1);
8873
- const [schedHour, setSchedHour] = (0, import_react14.useState)(9);
8874
- const [schedMinute, setSchedMinute] = (0, import_react14.useState)(0);
8875
- const [schedWeekdays, setSchedWeekdays] = (0, import_react14.useState)(() => /* @__PURE__ */ new Set([1]));
8876
- const [schedDayOfMonth, setSchedDayOfMonth] = (0, import_react14.useState)(1);
8877
- const [schedAdvancedOpen, setSchedAdvancedOpen] = (0, import_react14.useState)(false);
8878
- const cronManualOverrideRef = (0, import_react14.useRef)(false);
8879
- const [openIndexes, setOpenIndexes] = (0, import_react14.useState)(/* @__PURE__ */ new Set());
8880
- const [highlightedIndex, setHighlightedIndex] = (0, import_react14.useState)(null);
8881
- const [questionAnswers, setQuestionAnswers] = (0, import_react14.useState)({});
8882
- const [simpleSubmitAttempted, setSimpleSubmitAttempted] = (0, import_react14.useState)(false);
8883
- const [continuationText, setContinuationText] = (0, import_react14.useState)("");
8884
- const [error, setError] = (0, import_react14.useState)(null);
9143
+ const [schedFreq, setSchedFreq] = (0, import_react15.useState)("hours");
9144
+ const [schedInterval, setSchedInterval] = (0, import_react15.useState)(1);
9145
+ const [schedHour, setSchedHour] = (0, import_react15.useState)(9);
9146
+ const [schedMinute, setSchedMinute] = (0, import_react15.useState)(0);
9147
+ const [schedWeekdays, setSchedWeekdays] = (0, import_react15.useState)(() => /* @__PURE__ */ new Set([1]));
9148
+ const [schedDayOfMonth, setSchedDayOfMonth] = (0, import_react15.useState)(1);
9149
+ const [schedAdvancedOpen, setSchedAdvancedOpen] = (0, import_react15.useState)(false);
9150
+ const cronManualOverrideRef = (0, import_react15.useRef)(false);
9151
+ const [openIndexes, setOpenIndexes] = (0, import_react15.useState)(/* @__PURE__ */ new Set());
9152
+ const [highlightedIndex, setHighlightedIndex] = (0, import_react15.useState)(null);
9153
+ const [questionAnswers, setQuestionAnswers] = (0, import_react15.useState)({});
9154
+ const [simpleSubmitAttempted, setSimpleSubmitAttempted] = (0, import_react15.useState)(false);
9155
+ const [continuationText, setContinuationText] = (0, import_react15.useState)("");
9156
+ const [error, setError] = (0, import_react15.useState)(null);
8885
9157
  const [searchParams, setSearchParams] = (0, import_react_router_dom2.useSearchParams)();
8886
9158
  const initialViewParam = searchParams.get("agentView");
8887
- const [viewMode, setViewMode] = (0, import_react14.useState)(
9159
+ const [viewMode, setViewMode] = (0, import_react15.useState)(
8888
9160
  initialViewParam === "detailed" ? "detailed" : "simple"
8889
9161
  );
8890
- const [attachedImages, setAttachedImages] = (0, import_react14.useState)([]);
8891
- const [nowTick, setNowTick] = (0, import_react14.useState)(() => Math.floor(Date.now() / 1e3));
8892
- const [localRunStart, setLocalRunStart] = (0, import_react14.useState)(null);
8893
- const inputRef = (0, import_react14.useRef)(null);
8894
- const fileInputRef = (0, import_react14.useRef)(null);
8895
- const activeExecutionIdRef = (0, import_react14.useRef)(null);
8896
- const runAbortRef = (0, import_react14.useRef)(null);
8897
- const runGenerationRef = (0, import_react14.useRef)(0);
8898
- const userPickedStartRef = (0, import_react14.useRef)(false);
8899
- const stateRef = (0, import_react14.useRef)({
9162
+ const [attachedImages, setAttachedImages] = (0, import_react15.useState)([]);
9163
+ const [nowTick, setNowTick] = (0, import_react15.useState)(() => Math.floor(Date.now() / 1e3));
9164
+ const [localRunStart, setLocalRunStart] = (0, import_react15.useState)(null);
9165
+ const inputRef = (0, import_react15.useRef)(null);
9166
+ const fileInputRef = (0, import_react15.useRef)(null);
9167
+ const activeExecutionIdRef = (0, import_react15.useRef)(null);
9168
+ const runAbortRef = (0, import_react15.useRef)(null);
9169
+ const runGenerationRef = (0, import_react15.useRef)(0);
9170
+ const userPickedStartRef = (0, import_react15.useRef)(false);
9171
+ const stateRef = (0, import_react15.useRef)({
8900
9172
  execution: null,
8901
9173
  agentData: {},
8902
9174
  agentActionResult: null,
@@ -8914,14 +9186,14 @@ var AgentUI = ({
8914
9186
  stateRef.current.continuationText = continuationText;
8915
9187
  stateRef.current.localRunStart = localRunStart;
8916
9188
  stateRef.current.showStarter = showStarter;
8917
- (0, import_react14.useEffect)(() => {
9189
+ (0, import_react15.useEffect)(() => {
8918
9190
  if (execution?.execution_id || agentRequestLoading) {
8919
9191
  setLocalRunStart((prev) => prev ?? Math.floor(Date.now() / 1e3));
8920
9192
  } else {
8921
9193
  setLocalRunStart(null);
8922
9194
  }
8923
9195
  }, [execution?.execution_id, agentRequestLoading]);
8924
- (0, import_react14.useEffect)(() => {
9196
+ (0, import_react15.useEffect)(() => {
8925
9197
  const status = (execution?.status || agentData?.status || "").toUpperCase();
8926
9198
  const TERMINAL = ["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"];
8927
9199
  if (TERMINAL.includes(status)) return;
@@ -8953,7 +9225,7 @@ var AgentUI = ({
8953
9225
  setError(null);
8954
9226
  }
8955
9227
  };
8956
- const appsById = (0, import_react14.useMemo)(() => {
9228
+ const appsById = (0, import_react15.useMemo)(() => {
8957
9229
  const m = {};
8958
9230
  const add = (a) => {
8959
9231
  if (!a?.name) return;
@@ -8971,13 +9243,13 @@ var AgentUI = ({
8971
9243
  }
8972
9244
  return m;
8973
9245
  }, [chosenApps, executionApps, resolvedToolApps]);
8974
- const isAppAuthenticated = (0, import_react14.useCallback)((appName) => {
9246
+ const isAppAuthenticated = (0, import_react15.useCallback)((appName) => {
8975
9247
  if (!appName) return false;
8976
9248
  const norm4 = (s) => s.toLowerCase().replace(/[\s-]+/g, "_");
8977
9249
  const target = norm4(appName);
8978
9250
  return availableApps.some((a) => norm4(a.name || "") === target);
8979
9251
  }, [availableApps]);
8980
- const pendingAuthApps = (0, import_react14.useMemo)(() => {
9252
+ const pendingAuthApps = (0, import_react15.useMemo)(() => {
8981
9253
  const decisions = agentData?.decisions || [];
8982
9254
  const seen = /* @__PURE__ */ new Set();
8983
9255
  const out = [];
@@ -8994,10 +9266,10 @@ var AgentUI = ({
8994
9266
  }
8995
9267
  return out;
8996
9268
  }, [agentData, appsById, isAppAuthenticated]);
8997
- (0, import_react14.useEffect)(() => {
9269
+ (0, import_react15.useEffect)(() => {
8998
9270
  if (apps) setChosenApps(apps);
8999
9271
  }, [apps]);
9000
- (0, import_react14.useEffect)(() => {
9272
+ (0, import_react15.useEffect)(() => {
9001
9273
  const decisions = agentData?.decisions || [];
9002
9274
  if (!Array.isArray(decisions) || decisions.length === 0) return;
9003
9275
  const norm4 = (s) => s.toLowerCase().replace(/[\s-]+/g, "_");
@@ -9045,7 +9317,7 @@ var AgentUI = ({
9045
9317
  cancelled = true;
9046
9318
  };
9047
9319
  }, [JSON.stringify(agentData?.decisions?.map((d) => [d?.details?.tool || d?.tool, extractAuthRequest(d)?.appName]) || []), appsById]);
9048
- (0, import_react14.useEffect)(() => {
9320
+ (0, import_react15.useEffect)(() => {
9049
9321
  const missing = chosenApps.filter((a) => !a.icon && a.name);
9050
9322
  if (missing.length === 0) return;
9051
9323
  let cancelled = false;
@@ -9103,7 +9375,7 @@ var AgentUI = ({
9103
9375
  cancelled = true;
9104
9376
  };
9105
9377
  }, [chosenApps, availableApps, resolveUrl2, resolveHeaders2]);
9106
- (0, import_react14.useEffect)(() => {
9378
+ (0, import_react15.useEffect)(() => {
9107
9379
  if (!autoLoadApps) return;
9108
9380
  if (apps || defaultApps) return;
9109
9381
  if (!hasApiKey) return;
@@ -9142,7 +9414,7 @@ var AgentUI = ({
9142
9414
  cancelled = true;
9143
9415
  };
9144
9416
  }, [autoLoadApps, apps, defaultApps, hasApiKey, resolveUrl2, resolveHeaders2]);
9145
- (0, import_react14.useEffect)(() => {
9417
+ (0, import_react15.useEffect)(() => {
9146
9418
  const raw = agentData?.allowed_actions;
9147
9419
  if (!Array.isArray(raw) || raw.length === 0) {
9148
9420
  setExecutionApps([]);
@@ -9251,7 +9523,7 @@ var AgentUI = ({
9251
9523
  cancelled = true;
9252
9524
  };
9253
9525
  }, [JSON.stringify(agentData?.allowed_actions || []), availableApps]);
9254
- const getExecution = (0, import_react14.useCallback)(async (executionId2, authorization2) => {
9526
+ const getExecution = (0, import_react15.useCallback)(async (executionId2, authorization2) => {
9255
9527
  if (!executionId2 || !authorization2) return;
9256
9528
  try {
9257
9529
  const resp = await fetch(resolveUrl2("/api/v1/streams/results"), {
@@ -9286,7 +9558,7 @@ var AgentUI = ({
9286
9558
  setError(err instanceof Error ? err.message : "Network error.");
9287
9559
  }
9288
9560
  }, []);
9289
- (0, import_react14.useEffect)(() => {
9561
+ (0, import_react15.useEffect)(() => {
9290
9562
  let eid = null;
9291
9563
  let auth = null;
9292
9564
  if (executionId && authorization) {
@@ -9304,7 +9576,7 @@ var AgentUI = ({
9304
9576
  getExecution(eid, auth);
9305
9577
  }
9306
9578
  }, [readUrlParams, executionId, authorization, getExecution]);
9307
- (0, import_react14.useEffect)(() => {
9579
+ (0, import_react15.useEffect)(() => {
9308
9580
  if (!initialExecution || !initialExecution.execution_id) return;
9309
9581
  if (!userPickedStartRef.current) setShowStarter(false);
9310
9582
  activeExecutionIdRef.current = initialExecution.execution_id;
@@ -9337,7 +9609,7 @@ var AgentUI = ({
9337
9609
  getExecution(initialExecution.execution_id, initialExecution.authorization);
9338
9610
  }
9339
9611
  }, [initialExecution?.execution_id]);
9340
- (0, import_react14.useEffect)(() => {
9612
+ (0, import_react15.useEffect)(() => {
9341
9613
  if (!execution?.execution_id || !execution?.authorization) return;
9342
9614
  const status = (execution.status || "").toUpperCase();
9343
9615
  const TERMINAL = ["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"];
@@ -9347,7 +9619,7 @@ var AgentUI = ({
9347
9619
  }, 3e3);
9348
9620
  return () => clearInterval(id);
9349
9621
  }, [execution?.execution_id, execution?.authorization, execution?.status, getExecution]);
9350
- const submitInput = (0, import_react14.useCallback)(async (text) => {
9622
+ const submitInput = (0, import_react15.useCallback)(async (text) => {
9351
9623
  if (!text.trim()) return;
9352
9624
  setError(null);
9353
9625
  setAgentRequestLoading(true);
@@ -9483,14 +9755,14 @@ var AgentUI = ({
9483
9755
  onRun?.({ input: text, success: true, executionId: eid });
9484
9756
  }
9485
9757
  }, [chosenApps, getExecution, onRun, attachedImages, readUrlParams, viewMode]);
9486
- const autoSubmittedRef = (0, import_react14.useRef)(false);
9487
- (0, import_react14.useEffect)(() => {
9758
+ const autoSubmittedRef = (0, import_react15.useRef)(false);
9759
+ (0, import_react15.useEffect)(() => {
9488
9760
  if (autoSubmit && defaultInput && !autoSubmittedRef.current && !executionId) {
9489
9761
  autoSubmittedRef.current = true;
9490
9762
  submitInput(defaultInput);
9491
9763
  }
9492
9764
  }, [autoSubmit, defaultInput, executionId, submitInput]);
9493
- const submitQuestions = (0, import_react14.useCallback)(async (decisionId, answers, isContinuation) => {
9765
+ const submitQuestions = (0, import_react15.useCallback)(async (decisionId, answers, isContinuation) => {
9494
9766
  if (!execution?.execution_id || !execution?.authorization) return;
9495
9767
  let newArgument = {};
9496
9768
  if (isContinuation) {
@@ -9537,7 +9809,7 @@ var AgentUI = ({
9537
9809
  setAgentRequestLoading(false);
9538
9810
  }
9539
9811
  }, [execution, getExecution]);
9540
- const rerunAgent = (0, import_react14.useCallback)(() => {
9812
+ const rerunAgent = (0, import_react15.useCallback)(() => {
9541
9813
  const input = agentData?.original_input || actionInput || (() => {
9542
9814
  const msgs = agentData?.input?.messages || [];
9543
9815
  const m = msgs.find((m2) => m2?.role === "user" && !String(m2?.role).includes("USER CONTEXT"));
@@ -9562,7 +9834,7 @@ var AgentUI = ({
9562
9834
  return next;
9563
9835
  }, { replace: true });
9564
9836
  }, [agentData, actionInput, executionApps, setSearchParams, disableStartTab, submitInput]);
9565
- const abortAgent = (0, import_react14.useCallback)(async () => {
9837
+ const abortAgent = (0, import_react15.useCallback)(async () => {
9566
9838
  const execId = execution?.execution_id;
9567
9839
  const auth = execution?.authorization;
9568
9840
  const wfId = execution?.workflow?.id;
@@ -9615,7 +9887,7 @@ var AgentUI = ({
9615
9887
  toast({ title: "Network error", description: String(err), variant: "destructive" });
9616
9888
  }
9617
9889
  }, [execution, resolveUrl2, resolveHeaders2, getExecution, setSearchParams]);
9618
- const getFormUrl = (0, import_react14.useCallback)((decisionId) => {
9890
+ const getFormUrl = (0, import_react15.useCallback)((decisionId) => {
9619
9891
  const wfId = execution?.workflow?.id;
9620
9892
  const auth = execution?.authorization;
9621
9893
  const execId = execution?.execution_id;
@@ -9631,7 +9903,7 @@ var AgentUI = ({
9631
9903
  });
9632
9904
  return `/forms/${wfId}?${params.toString()}`;
9633
9905
  }, [execution, agentActionResult, apiBaseUrl]);
9634
- const rerunDecision = (0, import_react14.useCallback)(async (decision) => {
9906
+ const rerunDecision = (0, import_react15.useCallback)(async (decision) => {
9635
9907
  if (!execution?.execution_id) {
9636
9908
  toast({ title: "No execution loaded", description: "Cannot rerun this decision.", variant: "destructive" });
9637
9909
  return;
@@ -9670,7 +9942,7 @@ var AgentUI = ({
9670
9942
  setAgentRequestLoading(false);
9671
9943
  }
9672
9944
  }, [execution, agentActionResult, getExecution]);
9673
- const { timeline, originalStartTime, totalDuration, finishDecisionId, finishAnswer } = (0, import_react14.useMemo)(() => {
9945
+ const { timeline, originalStartTime, totalDuration, finishDecisionId, finishAnswer } = (0, import_react15.useMemo)(() => {
9674
9946
  const toSec = (t) => {
9675
9947
  const n = Number(t) || 0;
9676
9948
  return n > 1e12 ? n / 1e3 : n;
@@ -9792,7 +10064,7 @@ var AgentUI = ({
9792
10064
  else next.add(i);
9793
10065
  return next;
9794
10066
  });
9795
- const handlePrimarySubmit = (0, import_react14.useCallback)(() => {
10067
+ const handlePrimarySubmit = (0, import_react15.useCallback)(() => {
9796
10068
  if (submitOverride) {
9797
10069
  submitOverride({ input: actionInput, apps: chosenApps });
9798
10070
  } else {
@@ -9808,7 +10080,7 @@ var AgentUI = ({
9808
10080
  const activeTab = showStarter ? "start" : viewMode;
9809
10081
  const hasExecution = !!execution?.execution_id;
9810
10082
  const showRunSwitcher = hasExecution || agentRequestLoading;
9811
- (0, import_react14.useEffect)(() => {
10083
+ (0, import_react15.useEffect)(() => {
9812
10084
  onViewChange?.(activeTab);
9813
10085
  }, [activeTab, onViewChange]);
9814
10086
  const goToTab = (t) => {
@@ -9842,7 +10114,7 @@ var AgentUI = ({
9842
10114
  }, { replace: true });
9843
10115
  }
9844
10116
  };
9845
- const { scheduleDisabledReasons } = (0, import_react14.useMemo)(() => {
10117
+ const { scheduleDisabledReasons } = (0, import_react15.useMemo)(() => {
9846
10118
  const decisions = agentData?.decisions || [];
9847
10119
  const runStatus = String(execution?.status || agentData?.status || "").toUpperCase();
9848
10120
  const isNotFinished = runStatus !== "" && !["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(runStatus);
@@ -9912,16 +10184,16 @@ var AgentUI = ({
9912
10184
  }
9913
10185
  return { scheduleDisabledReasons: reasons };
9914
10186
  }, [agentData, execution?.status, showStarter]);
9915
- const scheduleHint = (0, import_react14.useMemo)(() => parseScheduleHint(actionInput), [actionInput]);
9916
- const lastAppliedHintRef = (0, import_react14.useRef)(null);
9917
- (0, import_react14.useEffect)(() => {
10187
+ const scheduleHint = (0, import_react15.useMemo)(() => parseScheduleHint(actionInput), [actionInput]);
10188
+ const lastAppliedHintRef = (0, import_react15.useRef)(null);
10189
+ (0, import_react15.useEffect)(() => {
9918
10190
  if (!scheduleHint) return;
9919
10191
  if (scheduleAnchor) return;
9920
10192
  if (lastAppliedHintRef.current === scheduleHint.cron) return;
9921
10193
  setScheduleCron(scheduleHint.cron);
9922
10194
  lastAppliedHintRef.current = scheduleHint.cron;
9923
10195
  }, [scheduleHint, scheduleAnchor]);
9924
- (0, import_react14.useEffect)(() => {
10196
+ (0, import_react15.useEffect)(() => {
9925
10197
  if (cronManualOverrideRef.current) return;
9926
10198
  const m = Math.max(0, Math.min(59, schedMinute));
9927
10199
  const h = Math.max(0, Math.min(23, schedHour));
@@ -9957,7 +10229,7 @@ var AgentUI = ({
9957
10229
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_material16.Box, { component: "span", children: r })
9958
10230
  ] }, i)) })
9959
10231
  ] }) : scheduleDisabledReasons.length === 1 ? `Cannot schedule: ${scheduleDisabledReasons[0]}` : "";
9960
- const tabBarRef = (0, import_react14.useRef)(null);
10232
+ const tabBarRef = (0, import_react15.useRef)(null);
9961
10233
  const tabBar = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
9962
10234
  import_material16.Box,
9963
10235
  {
@@ -10664,15 +10936,25 @@ var AgentUI = ({
10664
10936
  bgcolor: "hsl(var(--card))",
10665
10937
  maxWidth: "100%"
10666
10938
  }, children: [
10667
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_material16.Tooltip, { title: "Configure the local LLM used for this agent", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
10939
+ !hideChooseLLM && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_material16.Tooltip, { title: "Configure the local LLM used for this agent", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
10668
10940
  import_material16.Box,
10669
10941
  {
10670
10942
  component: "button",
10671
10943
  type: "button",
10672
10944
  onClick: () => {
10673
- if (typeof window !== "undefined") {
10674
- window.dispatchEvent(
10675
- new CustomEvent("agent-drawer-open", { detail: { tab: "localLLM" } })
10945
+ if (onChooseLLM) {
10946
+ onChooseLLM();
10947
+ return;
10948
+ }
10949
+ if (typeof window === "undefined") return;
10950
+ const evt = new CustomEvent("agent-drawer-open", {
10951
+ detail: { tab: "localLLM" },
10952
+ cancelable: true
10953
+ });
10954
+ const handled = window.dispatchEvent(evt);
10955
+ if (handled && !window.__shuffleAgentDrawerMounted) {
10956
+ console.warn(
10957
+ '[AgentUI] "Choose LLM" was clicked but no host handler is wired. Pass an `onChooseLLM` prop, mount the bundled `AgentRunDrawer`, or set `hideChooseLLM` to remove the chip.'
10676
10958
  );
10677
10959
  }
10678
10960
  },
@@ -11403,7 +11685,7 @@ var AgentUI = ({
11403
11685
  var AgentUI_default = AgentUI;
11404
11686
 
11405
11687
  // AgentRunDrawer.tsx
11406
- var import_react15 = require("react");
11688
+ var import_react16 = require("react");
11407
11689
  var import_material17 = require("@mui/material");
11408
11690
  var import_lucide_react12 = require("lucide-react");
11409
11691
  var import_jsx_runtime21 = require("react/jsx-runtime");
@@ -11425,14 +11707,23 @@ var AgentRunDrawer = ({
11425
11707
  paperSx,
11426
11708
  headerSx,
11427
11709
  tabsSx,
11428
- bodySx
11710
+ bodySx,
11711
+ globalUrl
11429
11712
  }) => {
11430
- const [activeTab, setActiveTab] = (0, import_react15.useState)(initialTab);
11431
- const prevOpenRef = (0, import_react15.useRef)(open);
11432
- (0, import_react15.useEffect)(() => {
11713
+ useSyncHostBaseUrl(globalUrl);
11714
+ const [activeTab, setActiveTab] = (0, import_react16.useState)(initialTab);
11715
+ const prevOpenRef = (0, import_react16.useRef)(open);
11716
+ (0, import_react16.useEffect)(() => {
11433
11717
  if (open && !prevOpenRef.current) setActiveTab(initialTab);
11434
11718
  prevOpenRef.current = open;
11435
11719
  }, [open, initialTab]);
11720
+ (0, import_react16.useEffect)(() => {
11721
+ if (typeof window === "undefined") return;
11722
+ window.__shuffleAgentDrawerMounted = (window.__shuffleAgentDrawerMounted || 0) + 1;
11723
+ return () => {
11724
+ window.__shuffleAgentDrawerMounted = Math.max(0, (window.__shuffleAgentDrawerMounted || 1) - 1);
11725
+ };
11726
+ }, []);
11436
11727
  const visibleTabs = TAB_ORDER.filter((t) => {
11437
11728
  if (t === "run") return true;
11438
11729
  if (t === "permissions") return !!permissionsSlot;
@@ -11572,6 +11863,7 @@ var AgentRunDrawer = ({
11572
11863
  hideHeroIcon: true,
11573
11864
  title: "",
11574
11865
  subtitle: null,
11866
+ apiBaseUrl: globalUrl,
11575
11867
  ...agentUIProps
11576
11868
  }
11577
11869
  ) }),
@@ -11585,7 +11877,7 @@ var AgentRunDrawer = ({
11585
11877
  var AgentRunDrawer_default = AgentRunDrawer;
11586
11878
 
11587
11879
  // AgentActivityList.tsx
11588
- var import_react16 = require("react");
11880
+ var import_react17 = require("react");
11589
11881
  var import_material18 = require("@mui/material");
11590
11882
  var import_lucide_react13 = require("lucide-react");
11591
11883
 
@@ -12006,21 +12298,21 @@ var AgentActivityList = ({
12006
12298
  toolbarSx,
12007
12299
  rowSx
12008
12300
  }) => {
12009
- const [runs, setRuns] = (0, import_react16.useState)([]);
12010
- const [cursor, setCursor] = (0, import_react16.useState)("");
12011
- const [hasMore, setHasMore] = (0, import_react16.useState)(false);
12012
- const [isLoading, setIsLoading] = (0, import_react16.useState)(false);
12013
- const [error, setError] = (0, import_react16.useState)(null);
12014
- const [statusFilter, setStatusFilter] = (0, import_react16.useState)("");
12015
- const [searchQuery, setSearchQuery] = (0, import_react16.useState)("");
12016
- const [debouncedQuery, setDebouncedQuery] = (0, import_react16.useState)("");
12017
- const [agentWorkflows, setAgentWorkflows] = (0, import_react16.useState)([]);
12018
- const [workflowFilter, setWorkflowFilter] = (0, import_react16.useState)("");
12019
- const [stopOpen, setStopOpen] = (0, import_react16.useState)(false);
12020
- const [stopLoading, setStopLoading] = (0, import_react16.useState)(false);
12021
- const debounceRef = (0, import_react16.useRef)();
12301
+ const [runs, setRuns] = (0, import_react17.useState)([]);
12302
+ const [cursor, setCursor] = (0, import_react17.useState)("");
12303
+ const [hasMore, setHasMore] = (0, import_react17.useState)(false);
12304
+ const [isLoading, setIsLoading] = (0, import_react17.useState)(false);
12305
+ const [error, setError] = (0, import_react17.useState)(null);
12306
+ const [statusFilter, setStatusFilter] = (0, import_react17.useState)("");
12307
+ const [searchQuery, setSearchQuery] = (0, import_react17.useState)("");
12308
+ const [debouncedQuery, setDebouncedQuery] = (0, import_react17.useState)("");
12309
+ const [agentWorkflows, setAgentWorkflows] = (0, import_react17.useState)([]);
12310
+ const [workflowFilter, setWorkflowFilter] = (0, import_react17.useState)("");
12311
+ const [stopOpen, setStopOpen] = (0, import_react17.useState)(false);
12312
+ const [stopLoading, setStopLoading] = (0, import_react17.useState)(false);
12313
+ const debounceRef = (0, import_react17.useRef)();
12022
12314
  const selectedAgentWorkflow = agentWorkflows.find((w) => w.id === workflowFilter) || null;
12023
- const openEditPrompt = (0, import_react16.useCallback)(async () => {
12315
+ const openEditPrompt = (0, import_react17.useCallback)(async () => {
12024
12316
  if (!workflowFilter) return;
12025
12317
  try {
12026
12318
  const { prompt, apps } = await getAgentScheduleConfig(workflowFilter, { apiKey, apiBaseUrl, orgId });
@@ -12034,7 +12326,7 @@ var AgentActivityList = ({
12034
12326
  setError(e instanceof Error ? e.message : "Failed to load workflow");
12035
12327
  }
12036
12328
  }, [workflowFilter, selectedAgentWorkflow, apiKey, apiBaseUrl, orgId, onEditWorkflow]);
12037
- const confirmStop = (0, import_react16.useCallback)(async () => {
12329
+ const confirmStop = (0, import_react17.useCallback)(async () => {
12038
12330
  if (!workflowFilter) return;
12039
12331
  setStopLoading(true);
12040
12332
  try {
@@ -12049,15 +12341,15 @@ var AgentActivityList = ({
12049
12341
  setStopLoading(false);
12050
12342
  }
12051
12343
  }, [workflowFilter, apiKey, apiBaseUrl, orgId]);
12052
- const updateSearchQuery = (0, import_react16.useCallback)((q) => {
12344
+ const updateSearchQuery = (0, import_react17.useCallback)((q) => {
12053
12345
  setSearchQuery(q);
12054
12346
  if (debounceRef.current) clearTimeout(debounceRef.current);
12055
12347
  debounceRef.current = setTimeout(() => setDebouncedQuery(q), 350);
12056
12348
  }, []);
12057
- (0, import_react16.useEffect)(() => () => {
12349
+ (0, import_react17.useEffect)(() => () => {
12058
12350
  if (debounceRef.current) clearTimeout(debounceRef.current);
12059
12351
  }, []);
12060
- const fetchRuns = (0, import_react16.useCallback)(
12352
+ const fetchRuns = (0, import_react17.useCallback)(
12061
12353
  async (append = false, cursorParam = "") => {
12062
12354
  setIsLoading(true);
12063
12355
  setError(null);
@@ -12086,10 +12378,10 @@ var AgentActivityList = ({
12086
12378
  },
12087
12379
  [statusFilter, limit, apiKey, apiBaseUrl, orgId, workflowFilter]
12088
12380
  );
12089
- (0, import_react16.useEffect)(() => {
12381
+ (0, import_react17.useEffect)(() => {
12090
12382
  fetchRuns(false, "");
12091
12383
  }, [statusFilter, apiKey, apiBaseUrl, orgId, workflowFilter]);
12092
- (0, import_react16.useEffect)(() => {
12384
+ (0, import_react17.useEffect)(() => {
12093
12385
  let cancelled = false;
12094
12386
  listAgentScheduleWorkflows({ apiKey, apiBaseUrl, orgId }).then((items) => {
12095
12387
  if (!cancelled) setAgentWorkflows(items);
@@ -12099,7 +12391,7 @@ var AgentActivityList = ({
12099
12391
  cancelled = true;
12100
12392
  };
12101
12393
  }, [apiKey, apiBaseUrl, orgId]);
12102
- const loadMore = (0, import_react16.useCallback)(() => {
12394
+ const loadMore = (0, import_react17.useCallback)(() => {
12103
12395
  if (cursor && !isLoading) fetchRuns(true, cursor);
12104
12396
  }, [cursor, isLoading, fetchRuns]);
12105
12397
  const filteredRuns = debouncedQuery ? runs.filter((r) => {
@@ -12533,19 +12825,20 @@ var AgentExecutionDrawer = ({
12533
12825
  var AgentExecutionDrawer_default = AgentExecutionDrawer;
12534
12826
 
12535
12827
  // AgentsView.tsx
12536
- var import_react17 = require("react");
12828
+ var import_react18 = require("react");
12537
12829
  var import_material20 = require("@mui/material");
12538
12830
  var import_jsx_runtime24 = require("react/jsx-runtime");
12539
- var AgentsView = ({ onSchedule, maxWidth = 820 }) => {
12540
- const [selectedRun, setSelectedRun] = (0, import_react17.useState)(null);
12541
- const [agentView, setAgentView] = (0, import_react17.useState)("start");
12542
- const [prefill, setPrefill] = (0, import_react17.useState)({
12831
+ var AgentsView = ({ onSchedule, maxWidth = 820, onChooseLLM, hideChooseLLM, globalUrl, isLoaded, isLoggedIn, userdata, serverside }) => {
12832
+ useSyncHostBaseUrl(globalUrl);
12833
+ const [selectedRun, setSelectedRun] = (0, import_react18.useState)(null);
12834
+ const [agentView, setAgentView] = (0, import_react18.useState)("start");
12835
+ const [prefill, setPrefill] = (0, import_react18.useState)({
12543
12836
  input: "",
12544
12837
  apps: [],
12545
12838
  key: 0
12546
12839
  });
12547
- const [editing, setEditing] = (0, import_react17.useState)(null);
12548
- const handleEditWorkflow = (0, import_react17.useCallback)(
12840
+ const [editing, setEditing] = (0, import_react18.useState)(null);
12841
+ const handleEditWorkflow = (0, import_react18.useCallback)(
12549
12842
  ({ workflowId, name, prompt, apps }) => {
12550
12843
  setEditing({ workflowId, name });
12551
12844
  setPrefill((prev) => ({
@@ -12557,7 +12850,7 @@ var AgentsView = ({ onSchedule, maxWidth = 820 }) => {
12557
12850
  },
12558
12851
  []
12559
12852
  );
12560
- const handleSaveEdit = (0, import_react17.useCallback)(
12853
+ const handleSaveEdit = (0, import_react18.useCallback)(
12561
12854
  async ({ input, apps }) => {
12562
12855
  if (!editing) return;
12563
12856
  try {
@@ -12577,8 +12870,8 @@ var AgentsView = ({ onSchedule, maxWidth = 820 }) => {
12577
12870
  },
12578
12871
  [editing]
12579
12872
  );
12580
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_material20.Box, { sx: { minHeight: "100vh", width: "100%", px: { xs: 2, md: 4 }, pt: "5vh", pb: 6 }, children: [
12581
- /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_material20.Stack, { spacing: 6, sx: { maxWidth, mx: "auto" }, children: [
12873
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_material20.Box, { sx: { minHeight: "100%", width: "100%", px: { xs: 2, md: 4 }, pt: { xs: 3, md: "5vh" }, pb: 6, boxSizing: "border-box" }, children: [
12874
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_material20.Stack, { spacing: 6, sx: { maxWidth, mx: "auto", width: "100%" }, children: [
12582
12875
  editing && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
12583
12876
  import_material20.Box,
12584
12877
  {
@@ -12622,8 +12915,11 @@ var AgentsView = ({ onSchedule, maxWidth = 820 }) => {
12622
12915
  AgentUI_default,
12623
12916
  {
12624
12917
  maxWidth,
12918
+ apiBaseUrl: globalUrl,
12625
12919
  onViewChange: setAgentView,
12626
12920
  onSchedule,
12921
+ onChooseLLM,
12922
+ hideChooseLLM,
12627
12923
  defaultInput: prefill.input,
12628
12924
  defaultApps: prefill.apps.length > 0 ? prefill.apps : void 0,
12629
12925
  submitOverride: editing ? handleSaveEdit : void 0,
@@ -12634,9 +12930,10 @@ var AgentsView = ({ onSchedule, maxWidth = 820 }) => {
12634
12930
  },
12635
12931
  prefill.key
12636
12932
  ),
12637
- agentView === "start" && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_material20.Box, { sx: { pt: "12vh" }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
12933
+ agentView === "start" && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_material20.Box, { sx: { pt: { xs: 4, md: "8vh" } }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
12638
12934
  AgentActivityList_default,
12639
12935
  {
12936
+ apiBaseUrl: globalUrl,
12640
12937
  onRunClick: setSelectedRun,
12641
12938
  onEditWorkflow: handleEditWorkflow
12642
12939
  }
@@ -12648,6 +12945,7 @@ var AgentsView = ({ onSchedule, maxWidth = 820 }) => {
12648
12945
  open: selectedRun !== null,
12649
12946
  onClose: () => setSelectedRun(null),
12650
12947
  run: selectedRun,
12948
+ apiBaseUrl: globalUrl,
12651
12949
  onSchedule
12652
12950
  }
12653
12951
  )
@@ -12656,14 +12954,14 @@ var AgentsView = ({ onSchedule, maxWidth = 820 }) => {
12656
12954
  var AgentsView_default = AgentsView;
12657
12955
 
12658
12956
  // useAppLookup.ts
12659
- var import_react18 = require("react");
12957
+ var import_react19 = require("react");
12660
12958
  init_api();
12661
12959
  init_appsCache();
12662
12960
  var norm3 = (s) => s.toLowerCase().replace(/[\s_\-]+/g, "_");
12663
12961
  function useAppLookup(appName) {
12664
- const [loading, setLoading] = (0, import_react18.useState)(false);
12665
- const [info, setInfo] = (0, import_react18.useState)(null);
12666
- const [algoliaId, setAlgoliaId] = (0, import_react18.useState)(null);
12962
+ const [loading, setLoading] = (0, import_react19.useState)(false);
12963
+ const [info, setInfo] = (0, import_react19.useState)(null);
12964
+ const [algoliaId, setAlgoliaId] = (0, import_react19.useState)(null);
12667
12965
  const {
12668
12966
  authStates,
12669
12967
  authenticatedApps,
@@ -12672,7 +12970,7 @@ function useAppLookup(appName) {
12672
12970
  handleSaveAuth,
12673
12971
  refreshAuth
12674
12972
  } = useAppAuth();
12675
- (0, import_react18.useEffect)(() => {
12973
+ (0, import_react19.useEffect)(() => {
12676
12974
  if (!appName) {
12677
12975
  setInfo(null);
12678
12976
  setAlgoliaId(null);
@@ -12751,13 +13049,13 @@ function useAppLookup(appName) {
12751
13049
  setLoading(false);
12752
13050
  })();
12753
13051
  }, [appName]);
12754
- const matchingEntries = (0, import_react18.useMemo)(() => {
13052
+ const matchingEntries = (0, import_react19.useMemo)(() => {
12755
13053
  if (!appName) return [];
12756
13054
  return authenticatedApps.filter(
12757
13055
  (auth) => auth.app?.name && norm3(auth.app.name) === norm3(appName)
12758
13056
  );
12759
13057
  }, [appName, authenticatedApps]);
12760
- const image = (0, import_react18.useMemo)(() => {
13058
+ const image = (0, import_react19.useMemo)(() => {
12761
13059
  if (info?.image) return info.image;
12762
13060
  for (const entry of matchingEntries) {
12763
13061
  const img = entry.app?.large_image || entry.large_image;
@@ -12765,7 +13063,7 @@ function useAppLookup(appName) {
12765
13063
  }
12766
13064
  return "";
12767
13065
  }, [info, matchingEntries]);
12768
- const algoliaApp = (0, import_react18.useMemo)(() => {
13066
+ const algoliaApp = (0, import_react19.useMemo)(() => {
12769
13067
  if (!appName) return null;
12770
13068
  return {
12771
13069
  objectID: algoliaId || appName,
@@ -12798,6 +13096,7 @@ function useAppLookup(appName) {
12798
13096
 
12799
13097
  // index.ts
12800
13098
  init_api();
13099
+ init_fetchBreaker();
12801
13100
  init_appsCache();
12802
13101
 
12803
13102
  // UsageBar.tsx
@@ -12879,6 +13178,44 @@ var UsageBar = ({
12879
13178
  ) })
12880
13179
  ] }) });
12881
13180
  };
13181
+
13182
+ // index.ts
13183
+ var withMcpTheme = (Inner, displayName) => {
13184
+ const Wrapped = ({ colorMode, ...rest }) => import_react20.default.createElement(
13185
+ ShuffleMcpThemeProvider,
13186
+ { mode: colorMode },
13187
+ import_react20.default.createElement(Inner, { ...rest })
13188
+ );
13189
+ Wrapped.displayName = `ShuffleMCPs(${displayName})`;
13190
+ return Wrapped;
13191
+ };
13192
+ var withMcpThemeRef = (Inner, displayName) => {
13193
+ const Wrapped = import_react20.default.forwardRef(
13194
+ ({ colorMode, ...rest }, ref) => import_react20.default.createElement(
13195
+ ShuffleMcpThemeProvider,
13196
+ { mode: colorMode },
13197
+ import_react20.default.createElement(Inner, { ...rest, ref })
13198
+ )
13199
+ );
13200
+ Wrapped.displayName = `ShuffleMCPs(${displayName})`;
13201
+ return Wrapped;
13202
+ };
13203
+ var ShuffleMCP2 = withMcpThemeRef(ShuffleMCP, "ShuffleMCP");
13204
+ var index_default = ShuffleMCP2;
13205
+ var AppDetailDrawer2 = withMcpTheme(AppDetailDrawer, "AppDetailDrawer");
13206
+ var AppSearchDrawer2 = withMcpTheme(AppSearchDrawer, "AppSearchDrawer");
13207
+ var AiAgentPromptsEditor2 = withMcpTheme(AiAgentPromptsEditor_default, "AiAgentPromptsEditor");
13208
+ var ShufflePipelinesBanner2 = withMcpTheme(ShufflePipelinesBanner_default, "ShufflePipelinesBanner");
13209
+ var AppTitleHeader2 = withMcpTheme(AppTitleHeader, "AppTitleHeader");
13210
+ var AppAuthSection2 = withMcpTheme(AppAuthSection, "AppAuthSection");
13211
+ var TryMcpSection2 = withMcpTheme(TryMcpSection, "TryMcpSection");
13212
+ var SingulActionsPreview2 = withMcpTheme(SingulActionsPreview_default, "SingulActionsPreview");
13213
+ var AgentUI2 = withMcpTheme(AgentUI_default, "AgentUI");
13214
+ var AgentRunDrawer2 = withMcpTheme(AgentRunDrawer_default, "AgentRunDrawer");
13215
+ var AgentActivityList2 = withMcpTheme(AgentActivityList_default, "AgentActivityList");
13216
+ var AgentExecutionDrawer2 = withMcpTheme(AgentExecutionDrawer_default, "AgentExecutionDrawer");
13217
+ var AgentsView2 = withMcpTheme(AgentsView_default, "AgentsView");
13218
+ var AgentRunDiagnosisBanner2 = withMcpTheme(AgentRunDiagnosisBanner_default, "AgentRunDiagnosisBanner");
12882
13219
  // Annotate the CommonJS export names for ESM import in node:
12883
13220
  0 && (module.exports = {
12884
13221
  API_CONFIG,
@@ -12929,8 +13266,10 @@ var UsageBar = ({
12929
13266
  getDatastoreItem,
12930
13267
  getDatastoreItemPublic,
12931
13268
  getFailureInfo,
13269
+ getHostBaseUrl,
12932
13270
  getIngestionCategory,
12933
13271
  hasOutputWarning,
13272
+ installFetchBreaker,
12934
13273
  invalidateAppsCache,
12935
13274
  invalidateResolvedApps,
12936
13275
  isCloud,
@@ -12944,12 +13283,16 @@ var UsageBar = ({
12944
13283
  normalizeAppName,
12945
13284
  parseRunResult,
12946
13285
  refreshAllIntegrationStatus,
13286
+ registerProtectedOrigin,
13287
+ resetRegionUrl,
12947
13288
  resolveApp,
12948
13289
  resolveApps,
12949
13290
  searchAgentActivity,
12950
13291
  seedResolvedApp,
12951
13292
  setDatastoreItem,
12952
13293
  setDatastoreItems,
13294
+ setHostBaseUrl,
13295
+ setRegionUrl,
12953
13296
  setRuntimeOrgId,
12954
13297
  setToastImpl,
12955
13298
  shuffleFetch,
@@ -12957,5 +13300,6 @@ var UsageBar = ({
12957
13300
  useAppAuth,
12958
13301
  useAppDetail,
12959
13302
  useAppDetailOptional,
12960
- useAppLookup
13303
+ useAppLookup,
13304
+ useSyncHostBaseUrl
12961
13305
  });