@shuffleio/shuffle-mcps 0.0.6 → 0.0.8

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.cjs CHANGED
@@ -30,6 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  var index_exports = {};
31
31
  __export(index_exports, {
32
32
  API_CONFIG: () => API_CONFIG,
33
+ AgentActivityList: () => AgentActivityList_default,
34
+ AgentExecutionDrawer: () => AgentExecutionDrawer_default,
35
+ AgentRunDrawer: () => AgentRunDrawer_default,
33
36
  AgentUI: () => AgentUI_default,
34
37
  AppAuthSection: () => AppAuthSection,
35
38
  AppDetailDrawer: () => AppDetailDrawer,
@@ -45,6 +48,7 @@ __export(index_exports, {
45
48
  getApiUrl: () => getApiUrl,
46
49
  getAuthHeader: () => getAuthHeader,
47
50
  refreshAllIntegrationStatus: () => refreshAllIntegrationStatus,
51
+ searchAgentActivity: () => searchAgentActivity,
48
52
  setToastImpl: () => setToastImpl,
49
53
  toast: () => toast,
50
54
  useAppAuth: () => useAppAuth,
@@ -52,6 +56,7 @@ __export(index_exports, {
52
56
  useAppLookup: () => useAppLookup
53
57
  });
54
58
  module.exports = __toCommonJS(index_exports);
59
+ var import_shuffle_mcp2 = require("./shuffle-mcp-24XBNRGE.css");
55
60
 
56
61
  // ShuffleMCP.tsx
57
62
  var import_react9 = __toESM(require("react"), 1);
@@ -443,6 +448,50 @@ var fetchAuthenticatedApps = (crossOrgId) => {
443
448
  return promise;
444
449
  };
445
450
 
451
+ // appsCache.ts
452
+ var TTL_MS2 = 3e4;
453
+ var cache2 = /* @__PURE__ */ new Map();
454
+ var cacheKey2 = (o) => `${o.baseUrl}|${o.path || "/api/v1/apps"}|${o.apiKey || ""}|${o.orgId || ""}`;
455
+ var doFetch2 = async (o) => {
456
+ const headers = {};
457
+ if (o.apiKey) headers["Authorization"] = `Bearer ${o.apiKey}`;
458
+ if (o.orgId) headers["Org-Id"] = o.orgId;
459
+ const response = await fetch(`${o.baseUrl}${o.path || "/api/v1/apps"}`, {
460
+ credentials: "include",
461
+ headers
462
+ });
463
+ if (!response.ok) return [];
464
+ const data = await response.json();
465
+ if (Array.isArray(data)) return data;
466
+ return Array.isArray(data?.data) ? data.data : [];
467
+ };
468
+ var fetchApps = (opts) => {
469
+ const key = cacheKey2(opts);
470
+ const entry = cache2.get(key) || {};
471
+ if (entry.data && entry.fetchedAt && Date.now() - entry.fetchedAt < TTL_MS2) {
472
+ return Promise.resolve(entry.data);
473
+ }
474
+ if (entry.promise) return entry.promise;
475
+ const promise = doFetch2(opts).then((data) => {
476
+ cache2.set(key, { data, fetchedAt: Date.now() });
477
+ return data;
478
+ }).catch((err) => {
479
+ cache2.delete(key);
480
+ throw err;
481
+ });
482
+ cache2.set(key, { ...entry, promise });
483
+ return promise;
484
+ };
485
+ var fetchAppsViaApiConfig = () => {
486
+ const headers = getAuthHeader();
487
+ const orgId = headers["Org-Id"] || null;
488
+ return fetchApps({
489
+ baseUrl: API_CONFIG.baseUrl,
490
+ apiKey: API_CONFIG.apiKey,
491
+ orgId
492
+ });
493
+ };
494
+
446
495
  // auth-utils.ts
447
496
  function deduplicateAuthApps(apps) {
448
497
  const appMap = /* @__PURE__ */ new Map();
@@ -611,35 +660,25 @@ var IntegrationStatus = ({ collapsed, filterApps, onAddClick, iconSize = 26, onD
611
660
  }
612
661
  if (dedupedIntegrations.length < 10) {
613
662
  try {
614
- const controller = new AbortController();
615
- const timeout = setTimeout(() => controller.abort(), 5e3);
616
- const appsResponse = await fetch(getApiUrl("/api/v1/apps"), {
617
- credentials: "include",
618
- headers: { ...getAuthHeader() },
619
- signal: controller.signal
620
- });
621
- clearTimeout(timeout);
622
- if (appsResponse.ok) {
623
- const appsData = await appsResponse.json();
624
- if (Array.isArray(appsData)) {
625
- const activatedApps = appsData.filter((app) => app.activated);
626
- const slotsRemaining = 10 - dedupedIntegrations.length;
627
- let added = 0;
628
- for (const app of activatedApps) {
629
- if (added >= slotsRemaining) break;
630
- if (!authNameSet.has((app.name || "").toLowerCase())) {
631
- authNameSet.add((app.name || "").toLowerCase());
632
- dedupedIntegrations.push({
633
- id: app.id || app.name,
634
- name: app.name,
635
- icon: app.large_image || "",
636
- category: app.categories?.[0] || "Integration",
637
- hasValidAuth: false,
638
- authInstances: [],
639
- isActiveOnly: true
640
- });
641
- added++;
642
- }
663
+ const appsData = await fetchAppsViaApiConfig();
664
+ if (Array.isArray(appsData)) {
665
+ const activatedApps = appsData.filter((app) => app.activated);
666
+ const slotsRemaining = 10 - dedupedIntegrations.length;
667
+ let added = 0;
668
+ for (const app of activatedApps) {
669
+ if (added >= slotsRemaining) break;
670
+ if (!authNameSet.has((app.name || "").toLowerCase())) {
671
+ authNameSet.add((app.name || "").toLowerCase());
672
+ dedupedIntegrations.push({
673
+ id: app.id || app.name,
674
+ name: app.name,
675
+ icon: app.large_image || "",
676
+ category: app.categories?.[0] || "Integration",
677
+ hasValidAuth: false,
678
+ authInstances: [],
679
+ isActiveOnly: true
680
+ });
681
+ added++;
643
682
  }
644
683
  }
645
684
  }
@@ -1264,8 +1303,8 @@ function AppTitleHeader({
1264
1303
  py: 0.5,
1265
1304
  minHeight: 0,
1266
1305
  flexShrink: 0,
1267
- bgcolor: "#FF6600",
1268
- "&:hover": { bgcolor: "#e55c00" }
1306
+ bgcolor: "hsl(var(--primary))",
1307
+ "&:hover": { bgcolor: "hsl(var(--primary) / 0.85)" }
1269
1308
  },
1270
1309
  children: "+ Add"
1271
1310
  }
@@ -1286,7 +1325,7 @@ function AppTitleHeader({
1286
1325
  py: 0.5,
1287
1326
  minHeight: 0,
1288
1327
  flexShrink: 0,
1289
- ...isActivated ? { color: "hsl(var(--muted-foreground))", borderColor: "hsl(var(--border))", "&:hover": { borderColor: "hsl(var(--destructive))", color: "hsl(var(--destructive))", bgcolor: "hsla(var(--destructive) / 0.08)" } } : { bgcolor: "#FF6600", "&:hover": { bgcolor: "#e55c00" } }
1328
+ ...isActivated ? { color: "hsl(var(--muted-foreground))", borderColor: "hsl(var(--border))", "&:hover": { borderColor: "hsl(var(--destructive))", color: "hsl(var(--destructive))", bgcolor: "hsla(var(--destructive) / 0.08)" } } : { bgcolor: "hsl(var(--primary))", "&:hover": { bgcolor: "hsl(var(--primary) / 0.85)" } }
1290
1329
  },
1291
1330
  children: activateLoading ? "\u2026" : isActivated ? "Deactivate" : "Activate"
1292
1331
  }
@@ -1354,7 +1393,10 @@ var AppAuthCard = ({
1354
1393
  apiAuthEntries,
1355
1394
  onSelectAuth,
1356
1395
  onRefreshAuth,
1357
- disableUrlPrefill
1396
+ disableUrlPrefill,
1397
+ hideHeader,
1398
+ hideStatusChips,
1399
+ hideDocsLink
1358
1400
  }) => {
1359
1401
  const getBestDefaultAuth = (entries) => {
1360
1402
  if (entries.length === 0) return ADD_NEW_AUTH;
@@ -1574,6 +1616,22 @@ var AppAuthCard = ({
1574
1616
  setLocalCredentials((prev) => ({ ...urlDefaults, ...prev }));
1575
1617
  }
1576
1618
  }, [auth?.parameters, disableUrlPrefill]);
1619
+ (0, import_react4.useEffect)(() => {
1620
+ const incoming = authState.credentials || {};
1621
+ setLocalCredentials((prev) => {
1622
+ let changed = false;
1623
+ const next = { ...prev };
1624
+ for (const [k, v] of Object.entries(incoming)) {
1625
+ const lk = k.toLowerCase();
1626
+ const isUrlish = lk.includes("url") || lk.includes("endpoint") || lk.includes("host");
1627
+ if (isUrlish && typeof v === "string" && v !== prev[k]) {
1628
+ next[k] = v;
1629
+ changed = true;
1630
+ }
1631
+ }
1632
+ return changed ? next : prev;
1633
+ });
1634
+ }, [authState.credentials]);
1577
1635
  const [docsOpen, setDocsOpen] = (0, import_react4.useState)(false);
1578
1636
  const [docsContent, setDocsContent] = (0, import_react4.useState)("");
1579
1637
  const [docsLoading, setDocsLoading] = (0, import_react4.useState)(false);
@@ -1647,10 +1705,9 @@ var AppAuthCard = ({
1647
1705
  const renderOAuth2Fields = () => {
1648
1706
  if (!auth || !isOAuth2) return null;
1649
1707
  const availableScopes = auth.scope || [];
1650
- const isCloudOrDev = isDevEnvironment() || isCloudDomain();
1651
1708
  const hasManualCredentials = !!localCredentials["client_id"]?.trim() && !!localCredentials["client_secret"]?.trim();
1652
1709
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_material3.Box, { sx: { display: "flex", flexDirection: "column", gap: 3 }, children: [
1653
- isCloudOrDev && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1710
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1654
1711
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material3.Collapse, { in: !hasManualCredentials, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_material3.Box, { sx: { display: "flex", flexDirection: "column", gap: 3 }, children: [
1655
1712
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1656
1713
  import_material3.Button,
@@ -1837,7 +1894,7 @@ var AppAuthCard = ({
1837
1894
  {
1838
1895
  label: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_material3.Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
1839
1896
  param.name,
1840
- param.required && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material3.Typography, { component: "span", sx: { color: "#ef4444", fontSize: "0.8rem" }, children: "*" })
1897
+ param.required && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material3.Typography, { component: "span", sx: { color: "hsl(var(--destructive))", fontSize: "0.8rem" }, children: "*" })
1841
1898
  ] }),
1842
1899
  type: param.name.toLowerCase().includes("password") || param.name.toLowerCase().includes("secret") || param.name.toLowerCase().includes("key") ? "password" : "text",
1843
1900
  placeholder: param.example || `Enter ${param.name}`,
@@ -1851,13 +1908,13 @@ var AppAuthCard = ({
1851
1908
  "& .MuiOutlinedInput-root": {
1852
1909
  backgroundColor: "hsl(var(--muted))",
1853
1910
  borderRadius: 2,
1854
- "& fieldset": { borderColor: fieldErrors[fieldKey] ? "#ef4444" : "hsl(var(--border))" },
1855
- "&:hover fieldset": { borderColor: fieldErrors[fieldKey] ? "#ef4444" : "hsl(var(--border))" },
1856
- "&.Mui-focused fieldset": { borderColor: fieldErrors[fieldKey] ? "#ef4444" : "hsl(var(--primary))" }
1911
+ "& fieldset": { borderColor: fieldErrors[fieldKey] ? "hsl(var(--destructive))" : "hsl(var(--border))" },
1912
+ "&:hover fieldset": { borderColor: fieldErrors[fieldKey] ? "hsl(var(--destructive))" : "hsl(var(--border))" },
1913
+ "&.Mui-focused fieldset": { borderColor: fieldErrors[fieldKey] ? "hsl(var(--destructive))" : "hsl(var(--primary))" }
1857
1914
  },
1858
1915
  "& .MuiInputBase-input": { color: "hsl(var(--foreground))" },
1859
1916
  "& .MuiInputLabel-root": { color: "hsl(var(--muted-foreground))" },
1860
- "& .MuiFormHelperText-root": { color: fieldErrors[fieldKey] ? "#ef4444" : "hsl(var(--muted-foreground))" }
1917
+ "& .MuiFormHelperText-root": { color: fieldErrors[fieldKey] ? "hsl(var(--destructive))" : "hsl(var(--muted-foreground))" }
1861
1918
  }
1862
1919
  },
1863
1920
  fieldKey
@@ -1931,7 +1988,7 @@ var AppAuthCard = ({
1931
1988
  maxWidth: "100%"
1932
1989
  },
1933
1990
  children: [
1934
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1991
+ !hideHeader && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1935
1992
  import_material3.CardContent,
1936
1993
  {
1937
1994
  onClick: onToggle,
@@ -2020,7 +2077,7 @@ var AppAuthCard = ({
2020
2077
  width: { xs: "100%", sm: "auto" },
2021
2078
  justifyContent: { xs: "flex-start", sm: "flex-end" }
2022
2079
  }, children: [
2023
- isNoAuthRequired(auth) ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2080
+ !hideStatusChips && (isNoAuthRequired(auth) ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2024
2081
  import_material3.Chip,
2025
2082
  {
2026
2083
  label: "Auth not required",
@@ -2071,8 +2128,8 @@ var AppAuthCard = ({
2071
2128
  )
2072
2129
  }
2073
2130
  )
2074
- ] }),
2075
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material3.Tooltip, { title: "View documentation", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2131
+ ] })),
2132
+ !hideDocsLink && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material3.Tooltip, { title: "View documentation", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2076
2133
  import_material3.IconButton,
2077
2134
  {
2078
2135
  size: "small",
@@ -2352,8 +2409,8 @@ var AppAuthCard = ({
2352
2409
  width: 8,
2353
2410
  height: 8,
2354
2411
  borderRadius: "50%",
2355
- backgroundColor: localTestStatus === "success" ? "#22c55e" : localTestStatus === "pending_validation" ? "#f59e0b" : localTestStatus === "error" ? "#ef4444" : "#9ca3af",
2356
- boxShadow: localTestStatus === "success" ? "0 0 8px rgba(34, 197, 94, 0.6)" : localTestStatus === "pending_validation" ? "0 0 8px rgba(245, 158, 11, 0.6)" : localTestStatus === "error" ? "0 0 8px rgba(239, 68, 68, 0.6)" : "0 0 8px rgba(156, 163, 175, 0.4)"
2412
+ backgroundColor: localTestStatus === "success" ? "hsl(var(--severity-low))" : localTestStatus === "pending_validation" ? "hsl(var(--severity-medium))" : localTestStatus === "error" ? "hsl(var(--destructive))" : "hsl(var(--muted-foreground))",
2413
+ boxShadow: localTestStatus === "success" ? "0 0 8px hsl(var(--severity-low) / 0.6)" : localTestStatus === "pending_validation" ? "0 0 8px hsl(var(--severity-medium) / 0.6)" : localTestStatus === "error" ? "0 0 8px hsl(var(--destructive) / 0.6)" : "0 0 8px hsl(var(--muted-foreground) / 0.4)"
2357
2414
  } }),
2358
2415
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material3.Typography, { sx: {
2359
2416
  color: "hsl(var(--muted-foreground))",
@@ -2384,11 +2441,11 @@ var AppAuthCard = ({
2384
2441
  display: "flex",
2385
2442
  alignItems: "center",
2386
2443
  justifyContent: "center",
2387
- backgroundColor: localTestStatus === "success" ? "rgba(34, 197, 94, 0.1)" : localTestStatus === "error" ? "rgba(239, 68, 68, 0.1)" : localTestStatus === "pending_validation" ? "rgba(245, 158, 11, 0.1)" : isTested ? "rgba(34, 197, 94, 0.1)" : isConfigured ? "rgba(245, 158, 11, 0.1)" : "rgba(156, 163, 175, 0.1)",
2388
- border: `1px solid ${localTestStatus === "success" ? "rgba(34, 197, 94, 0.2)" : localTestStatus === "pending_validation" ? "rgba(245, 158, 11, 0.2)" : localTestStatus === "error" ? "rgba(239, 68, 68, 0.2)" : isTested ? "rgba(34, 197, 94, 0.2)" : isConfigured ? "rgba(245, 158, 11, 0.2)" : "rgba(156, 163, 175, 0.2)"}`,
2444
+ backgroundColor: localTestStatus === "success" ? "hsl(var(--severity-low) / 0.1)" : localTestStatus === "error" ? "hsl(var(--destructive) / 0.1)" : localTestStatus === "pending_validation" ? "hsl(var(--severity-medium) / 0.1)" : isTested ? "hsl(var(--severity-low) / 0.1)" : isConfigured ? "hsl(var(--severity-medium) / 0.1)" : "hsl(var(--muted-foreground) / 0.1)",
2445
+ border: `1px solid ${localTestStatus === "success" ? "hsl(var(--severity-low) / 0.2)" : localTestStatus === "pending_validation" ? "hsl(var(--severity-medium) / 0.2)" : localTestStatus === "error" ? "hsl(var(--destructive) / 0.2)" : isTested ? "hsl(var(--severity-low) / 0.2)" : isConfigured ? "hsl(var(--severity-medium) / 0.2)" : "hsl(var(--muted-foreground) / 0.2)"}`,
2389
2446
  flexShrink: 0
2390
2447
  }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_CheckCircle2.default, { sx: {
2391
- color: localTestStatus === "success" ? "#22c55e" : localTestStatus === "pending_validation" ? "#f59e0b" : localTestStatus === "error" ? "#ef4444" : isTested ? "#22c55e" : isConfigured ? "#f59e0b" : "#9ca3af",
2448
+ color: localTestStatus === "success" ? "hsl(var(--severity-low))" : localTestStatus === "pending_validation" ? "hsl(var(--severity-medium))" : localTestStatus === "error" ? "hsl(var(--destructive))" : isTested ? "hsl(var(--severity-low))" : isConfigured ? "hsl(var(--severity-medium))" : "hsl(var(--muted-foreground))",
2392
2449
  fontSize: 20
2393
2450
  } }) }),
2394
2451
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_material3.Box, { sx: { minWidth: 0, flex: 1 }, children: [
@@ -2482,7 +2539,7 @@ var AppAuthCard = ({
2482
2539
  ) })
2483
2540
  ] }) }),
2484
2541
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material3.Typography, { sx: {
2485
- color: localTestStatus === "success" ? "#22c55e" : localTestStatus === "pending_validation" ? "#f59e0b" : localTestStatus === "error" ? "#ef4444" : isTested ? "#22c55e" : isConfigured ? "#f59e0b" : "hsl(var(--muted-foreground))",
2542
+ color: localTestStatus === "success" ? "hsl(var(--severity-low))" : localTestStatus === "pending_validation" ? "hsl(var(--severity-medium))" : localTestStatus === "error" ? "hsl(var(--destructive))" : isTested ? "hsl(var(--severity-low))" : isConfigured ? "hsl(var(--severity-medium))" : "hsl(var(--muted-foreground))",
2486
2543
  fontSize: "0.75rem",
2487
2544
  mt: 0.25,
2488
2545
  fontWeight: localTestStatus !== "untested" || isTested || isConfigured ? 500 : 400
@@ -2502,9 +2559,9 @@ var AppAuthCard = ({
2502
2559
  disabled: authState.status === "testing",
2503
2560
  startIcon: authState.status === "testing" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material3.CircularProgress, { size: 16, sx: { color: "inherit" } }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_CheckCircle2.default, { sx: { fontSize: 18 } }),
2504
2561
  sx: {
2505
- borderColor: authState.status === "testing" ? "transparent" : "rgba(255, 102, 0, 0.5)",
2562
+ borderColor: authState.status === "testing" ? "transparent" : "hsl(var(--primary) / 0.5)",
2506
2563
  color: authState.status === "testing" ? "hsl(var(--foreground))" : "hsl(var(--primary))",
2507
- background: authState.status === "testing" ? "linear-gradient(90deg, rgba(255, 102, 0, 0.3) 0%, rgba(255, 102, 0, 0.5) 50%, rgba(255, 102, 0, 0.3) 100%)" : "transparent",
2564
+ background: authState.status === "testing" ? "linear-gradient(90deg, hsl(var(--primary) / 0.3) 0%, hsl(var(--primary) / 0.5) 50%, hsl(var(--primary) / 0.3) 100%)" : "transparent",
2508
2565
  backgroundSize: authState.status === "testing" ? "200% 100%" : "auto",
2509
2566
  animation: authState.status === "testing" ? "shimmer 1.5s infinite linear" : "none",
2510
2567
  fontWeight: 600,
@@ -2522,7 +2579,7 @@ var AppAuthCard = ({
2522
2579
  },
2523
2580
  "&:hover": {
2524
2581
  borderColor: "hsl(var(--primary))",
2525
- backgroundColor: authState.status === "testing" ? void 0 : "rgba(255, 102, 0, 0.08)"
2582
+ backgroundColor: authState.status === "testing" ? void 0 : "hsl(var(--primary) / 0.08)"
2526
2583
  },
2527
2584
  "&.Mui-disabled": {
2528
2585
  color: authState.status === "testing" ? "hsl(var(--foreground))" : "hsl(var(--muted-foreground))",
@@ -2541,11 +2598,11 @@ var AppAuthCard = ({
2541
2598
  {
2542
2599
  severity: "error",
2543
2600
  sx: {
2544
- backgroundColor: "rgba(239, 68, 68, 0.1)",
2545
- color: "#ef4444",
2546
- border: "1px solid rgba(239, 68, 68, 0.2)",
2601
+ backgroundColor: "hsl(var(--destructive) / 0.1)",
2602
+ color: "hsl(var(--destructive))",
2603
+ border: "1px solid hsl(var(--destructive) / 0.2)",
2547
2604
  borderRadius: 2,
2548
- "& .MuiAlert-icon": { color: "#ef4444" }
2605
+ "& .MuiAlert-icon": { color: "hsl(var(--destructive))" }
2549
2606
  },
2550
2607
  children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_material3.Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 2, width: "100%" }, children: [
2551
2608
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material3.Typography, { sx: { fontSize: "0.875rem", flex: 1 }, children: localTestMessages.errorMessage }),
@@ -2558,16 +2615,16 @@ var AppAuthCard = ({
2558
2615
  target: "_blank",
2559
2616
  rel: "noopener noreferrer",
2560
2617
  sx: {
2561
- borderColor: "rgba(239, 68, 68, 0.5)",
2562
- color: "#ef4444",
2618
+ borderColor: "hsl(var(--destructive) / 0.5)",
2619
+ color: "hsl(var(--destructive))",
2563
2620
  textTransform: "none",
2564
2621
  fontSize: "0.75rem",
2565
2622
  py: 0.5,
2566
2623
  px: 1.5,
2567
2624
  flexShrink: 0,
2568
2625
  "&:hover": {
2569
- borderColor: "#ef4444",
2570
- backgroundColor: "rgba(239, 68, 68, 0.1)"
2626
+ borderColor: "hsl(var(--destructive))",
2627
+ backgroundColor: "hsl(var(--destructive) / 0.1)"
2571
2628
  }
2572
2629
  },
2573
2630
  children: "View Execution"
@@ -2584,12 +2641,12 @@ var AppAuthCard = ({
2584
2641
  {
2585
2642
  severity: localTestMessages.warningMessage ? "warning" : "success",
2586
2643
  sx: {
2587
- backgroundColor: localTestMessages.warningMessage ? "rgba(245, 158, 11, 0.1)" : "rgba(34, 197, 94, 0.1)",
2588
- color: localTestMessages.warningMessage ? "#f59e0b" : "#22c55e",
2589
- border: localTestMessages.warningMessage ? "1px solid rgba(245, 158, 11, 0.2)" : "1px solid rgba(34, 197, 94, 0.2)",
2644
+ backgroundColor: localTestMessages.warningMessage ? "hsl(var(--severity-medium) / 0.1)" : "hsl(var(--severity-low) / 0.1)",
2645
+ color: localTestMessages.warningMessage ? "hsl(var(--severity-medium))" : "hsl(var(--severity-low))",
2646
+ border: localTestMessages.warningMessage ? "1px solid hsl(var(--severity-medium) / 0.2)" : "1px solid hsl(var(--severity-low) / 0.2)",
2590
2647
  borderRadius: 2,
2591
2648
  "& .MuiAlert-icon": {
2592
- color: localTestMessages.warningMessage ? "#f59e0b" : "#22c55e"
2649
+ color: localTestMessages.warningMessage ? "hsl(var(--severity-medium))" : "hsl(var(--severity-low))"
2593
2650
  }
2594
2651
  },
2595
2652
  children: localTestMessages.warningMessage ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_material3.Box, { children: [
@@ -2606,11 +2663,11 @@ var AppAuthCard = ({
2606
2663
  {
2607
2664
  severity: "warning",
2608
2665
  sx: {
2609
- backgroundColor: "rgba(245, 158, 11, 0.1)",
2610
- color: "#f59e0b",
2611
- border: "1px solid rgba(245, 158, 11, 0.2)",
2666
+ backgroundColor: "hsl(var(--severity-medium) / 0.1)",
2667
+ color: "hsl(var(--severity-medium))",
2668
+ border: "1px solid hsl(var(--severity-medium) / 0.2)",
2612
2669
  borderRadius: 2,
2613
- "& .MuiAlert-icon": { color: "#f59e0b" }
2670
+ "& .MuiAlert-icon": { color: "hsl(var(--severity-medium))" }
2614
2671
  },
2615
2672
  children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_material3.Box, { children: [
2616
2673
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material3.Typography, { sx: { fontWeight: 600, mb: 0.5 }, children: "Test passed (Status 200), but not marked as validated" }),
@@ -2621,7 +2678,7 @@ var AppAuthCard = ({
2621
2678
  href: `${API_CONFIG.baseUrl}/admin?tab=app_auth`,
2622
2679
  target: "_blank",
2623
2680
  sx: {
2624
- color: "#f59e0b",
2681
+ color: "hsl(var(--severity-medium))",
2625
2682
  fontWeight: 500,
2626
2683
  fontSize: "0.85rem",
2627
2684
  textDecoration: "underline",
@@ -2646,12 +2703,12 @@ var AppAuthCard = ({
2646
2703
  {
2647
2704
  severity: "warning",
2648
2705
  sx: {
2649
- backgroundColor: "rgba(245, 158, 11, 0.1)",
2650
- color: "#f59e0b",
2651
- border: "1px solid rgba(245, 158, 11, 0.2)",
2706
+ backgroundColor: "hsl(var(--severity-medium) / 0.1)",
2707
+ color: "hsl(var(--severity-medium))",
2708
+ border: "1px solid hsl(var(--severity-medium) / 0.2)",
2652
2709
  borderRadius: 2,
2653
2710
  mb: 2,
2654
- "& .MuiAlert-icon": { color: "#f59e0b" }
2711
+ "& .MuiAlert-icon": { color: "hsl(var(--severity-medium))" }
2655
2712
  },
2656
2713
  children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material3.Typography, { sx: { fontSize: "0.875rem" }, children: localTestMessages.errorCode === 401 ? "Previous credentials were invalid or expired. Please enter new credentials." : "Access was denied with the previous credentials. Please re-authenticate with valid permissions." })
2657
2714
  }
@@ -2665,9 +2722,9 @@ var AppAuthCard = ({
2665
2722
  {
2666
2723
  severity: "error",
2667
2724
  sx: {
2668
- backgroundColor: "rgba(239, 68, 68, 0.1)",
2669
- color: "#ef4444",
2670
- border: "1px solid rgba(239, 68, 68, 0.3)",
2725
+ backgroundColor: "hsl(var(--destructive) / 0.1)",
2726
+ color: "hsl(var(--destructive))",
2727
+ border: "1px solid hsl(var(--destructive) / 0.3)",
2671
2728
  borderRadius: 2
2672
2729
  },
2673
2730
  children: error
@@ -2677,11 +2734,11 @@ var AppAuthCard = ({
2677
2734
  {
2678
2735
  severity: "info",
2679
2736
  sx: {
2680
- backgroundColor: "rgba(59, 130, 246, 0.1)",
2681
- color: "#3b82f6",
2682
- border: "1px solid rgba(59, 130, 246, 0.2)",
2737
+ backgroundColor: "hsl(var(--severity-info) / 0.1)",
2738
+ color: "hsl(var(--severity-info))",
2739
+ border: "1px solid hsl(var(--severity-info) / 0.2)",
2683
2740
  borderRadius: 2,
2684
- "& .MuiAlert-icon": { color: "#3b82f6" }
2741
+ "& .MuiAlert-icon": { color: "hsl(var(--severity-info))" }
2685
2742
  },
2686
2743
  children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_material3.Box, { children: [
2687
2744
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material3.Typography, { sx: { fontWeight: 600, mb: 0.5 }, children: "No authentication required" }),
@@ -2696,9 +2753,9 @@ var AppAuthCard = ({
2696
2753
  {
2697
2754
  severity: "error",
2698
2755
  sx: {
2699
- backgroundColor: "rgba(239, 68, 68, 0.1)",
2700
- color: "#ef4444",
2701
- border: "1px solid rgba(239, 68, 68, 0.3)",
2756
+ backgroundColor: "hsl(var(--destructive) / 0.1)",
2757
+ color: "hsl(var(--destructive))",
2758
+ border: "1px solid hsl(var(--destructive) / 0.3)",
2702
2759
  borderRadius: 2
2703
2760
  },
2704
2761
  children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_material3.Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 2, width: "100%" }, children: [
@@ -2712,16 +2769,16 @@ var AppAuthCard = ({
2712
2769
  target: "_blank",
2713
2770
  rel: "noopener noreferrer",
2714
2771
  sx: {
2715
- borderColor: "rgba(239, 68, 68, 0.5)",
2716
- color: "#ef4444",
2772
+ borderColor: "hsl(var(--destructive) / 0.5)",
2773
+ color: "hsl(var(--destructive))",
2717
2774
  textTransform: "none",
2718
2775
  fontSize: "0.75rem",
2719
2776
  py: 0.5,
2720
2777
  px: 1.5,
2721
2778
  flexShrink: 0,
2722
2779
  "&:hover": {
2723
- borderColor: "#ef4444",
2724
- backgroundColor: "rgba(239, 68, 68, 0.1)"
2780
+ borderColor: "hsl(var(--destructive))",
2781
+ backgroundColor: "hsl(var(--destructive) / 0.1)"
2725
2782
  }
2726
2783
  },
2727
2784
  children: "View Execution"
@@ -2735,9 +2792,9 @@ var AppAuthCard = ({
2735
2792
  {
2736
2793
  severity: "error",
2737
2794
  sx: {
2738
- backgroundColor: "rgba(239, 68, 68, 0.1)",
2739
- color: "#ef4444",
2740
- border: "1px solid rgba(239, 68, 68, 0.3)",
2795
+ backgroundColor: "hsl(var(--destructive) / 0.1)",
2796
+ color: "hsl(var(--destructive))",
2797
+ border: "1px solid hsl(var(--destructive) / 0.3)",
2741
2798
  borderRadius: 2
2742
2799
  },
2743
2800
  children: "Failed to save authentication. Please try again."
@@ -3172,9 +3229,10 @@ var AppMcpChat = ({ appName, appIcon, appId, categories }) => {
3172
3229
  const inputRef = (0, import_react5.useRef)(null);
3173
3230
  const suggestions = (0, import_react5.useMemo)(() => getSuggestions(appName, categories), [appName, categories]);
3174
3231
  const primaryCategory = (0, import_react5.useMemo)(() => getPrimaryCategory(appName, categories), [appName, categories]);
3232
+ const MIN_INPUT_LENGTH = 6;
3175
3233
  const runAction = async () => {
3176
3234
  const trimmed = input.trim();
3177
- if (!trimmed || runState === "running") return;
3235
+ if (trimmed.length < MIN_INPUT_LENGTH || runState === "running") return;
3178
3236
  setQuery(trimmed);
3179
3237
  setInput("");
3180
3238
  setRunState("running");
@@ -3395,7 +3453,8 @@ ${JSON.stringify(data, null, 2)}
3395
3453
  {
3396
3454
  component: "button",
3397
3455
  onClick: runAction,
3398
- disabled: !input.trim(),
3456
+ disabled: input.trim().length < MIN_INPUT_LENGTH,
3457
+ title: input.trim().length < MIN_INPUT_LENGTH ? `Enter at least ${MIN_INPUT_LENGTH} characters` : void 0,
3399
3458
  sx: {
3400
3459
  all: "unset",
3401
3460
  display: "flex",
@@ -3405,11 +3464,11 @@ ${JSON.stringify(data, null, 2)}
3405
3464
  height: 30,
3406
3465
  borderRadius: "8px",
3407
3466
  flexShrink: 0,
3408
- cursor: input.trim() ? "pointer" : "default",
3409
- backgroundColor: input.trim() ? "hsl(var(--primary))" : "hsl(var(--muted))",
3410
- color: input.trim() ? "hsl(var(--primary-foreground))" : "hsl(var(--muted-foreground))",
3467
+ cursor: input.trim().length >= MIN_INPUT_LENGTH ? "pointer" : "not-allowed",
3468
+ backgroundColor: input.trim().length >= MIN_INPUT_LENGTH ? "hsl(var(--primary))" : "hsl(var(--muted))",
3469
+ color: input.trim().length >= MIN_INPUT_LENGTH ? "hsl(var(--primary-foreground))" : "hsl(var(--muted-foreground))",
3411
3470
  transition: "all 0.15s ease",
3412
- "&:hover": input.trim() ? {
3471
+ "&:hover": input.trim().length >= MIN_INPUT_LENGTH ? {
3413
3472
  filter: "brightness(1.1)"
3414
3473
  } : {}
3415
3474
  },
@@ -3731,23 +3790,32 @@ function buildSingulCurl(appName, action, opts) {
3731
3790
  const act = action?.name || "{action}";
3732
3791
  const body = {
3733
3792
  app: appName || "<appname>",
3793
+ action: act,
3734
3794
  fields: action?.fields.length ? action.fields : [{ name: "field1", value: "value1" }]
3735
3795
  };
3736
3796
  const token = opts?.apiKey || "YOUR_TOKEN";
3737
3797
  const orgLine = opts?.orgId ? `
3738
3798
  -H "Org-Id: ${opts.orgId}" \\` : "";
3739
- return `curl -X POST https://singul.io/api/${act} \\
3799
+ const base2 = (opts?.baseUrl || "").replace(/\/+$/, "");
3800
+ return `curl -X POST ${base2}/api/v1/singul \\
3740
3801
  -H "Authorization: Bearer ${token}" \\${orgLine}
3741
3802
  -d '${JSON.stringify(body, null, 2)}'`;
3742
3803
  }
3743
- function buildSingulPython(appName, action) {
3804
+ function buildSingulPython(appName, action, opts) {
3744
3805
  const act = action?.name || "send_message";
3745
3806
  const app = appName || "<appname>";
3746
3807
  const fields = action?.fields.length ? action.fields : [];
3747
3808
  const fieldsStr = JSON.stringify(fields);
3748
- return `import shufflepy
3809
+ const token = opts?.apiKey || "APIKEY";
3810
+ const base2 = (opts?.baseUrl || "").replace(/\/+$/, "");
3811
+ return `from shufflepy import Singul
3749
3812
 
3750
- response = shufflepy.run("${app}", action="${act}", fields=${fieldsStr})
3813
+ singul = Singul(
3814
+ "${token}",
3815
+ url="${base2}",
3816
+ )
3817
+
3818
+ response = singul.run("${app}", action="${act}", fields=${fieldsStr})
3751
3819
 
3752
3820
  print(response)`;
3753
3821
  }
@@ -3864,10 +3932,11 @@ var SingulActionsPreview = ({
3864
3932
  const apiKey = API_CONFIG.apiKey;
3865
3933
  const trackedOrg = getTrackedOrgId();
3866
3934
  const orgId = trackedOrg && activeOrgId && trackedOrg !== activeOrgId ? trackedOrg : null;
3867
- return { apiKey, orgId };
3935
+ const baseUrl = API_CONFIG.baseUrl;
3936
+ return { apiKey, orgId, baseUrl };
3868
3937
  }, [activeOrgId]);
3869
3938
  const buildSnippet = (0, import_react6.useCallback)(
3870
- (action, l) => l === "python" ? buildSingulPython(appName, action) : buildSingulCurl(appName, action, curlOpts),
3939
+ (action, l) => l === "python" ? buildSingulPython(appName, action, curlOpts) : buildSingulCurl(appName, action, curlOpts),
3871
3940
  [appName, curlOpts]
3872
3941
  );
3873
3942
  (0, import_react6.useEffect)(() => {
@@ -3918,7 +3987,7 @@ var SingulActionsPreview = ({
3918
3987
  app_name: "http",
3919
3988
  app_version: "1.4.0"
3920
3989
  };
3921
- const path = lang === "python" ? "/api/v1/apps/3e2bdf9d5069fe3f4746c29d68785a6a/run" : "/api/v1/apps/http/run";
3990
+ const path = lang === "python" ? "/api/v1/apps/3e2bdf9d5069fe3f4746c29d68785a6a/run?delete=true" : "/api/v1/apps/http/run?delete=true";
3922
3991
  const res = await fetch(getApiUrl(path), {
3923
3992
  method: "POST",
3924
3993
  credentials: "include",
@@ -4341,14 +4410,8 @@ function AppDetailDrawer({
4341
4410
  let appsList = null;
4342
4411
  if (API_CONFIG.apiKey) {
4343
4412
  try {
4344
- const res = await fetch(getApiUrl("/api/v1/apps"), {
4345
- credentials: "include",
4346
- headers: { ...getAuthHeader() }
4347
- });
4348
- if (res.ok) {
4349
- const apps = await res.json();
4350
- if (Array.isArray(apps)) appsList = apps;
4351
- }
4413
+ const apps = await fetchAppsViaApiConfig();
4414
+ if (Array.isArray(apps)) appsList = apps;
4352
4415
  } catch {
4353
4416
  }
4354
4417
  }
@@ -4659,7 +4722,7 @@ function AppDetailDrawer({
4659
4722
  }
4660
4723
 
4661
4724
  // ShuffleMCP.tsx
4662
- var import_shuffle_mcp = require("./shuffle-mcp-JQWKQNUP.css");
4725
+ var import_shuffle_mcp = require("./shuffle-mcp-24XBNRGE.css");
4663
4726
  var import_jsx_runtime11 = require("react/jsx-runtime");
4664
4727
  var DEFAULT_ALGOLIA_APP_ID = "JNSS5CFDZZ";
4665
4728
  var DEFAULT_ALGOLIA_API_KEY = "33e4e3564f4f060e96e0531957bed552";
@@ -4749,18 +4812,12 @@ var ShuffleMCP = import_react9.default.forwardRef(({
4749
4812
  }
4750
4813
  const fetchPrivateApps = async () => {
4751
4814
  try {
4752
- const response = await fetch(`${apiBaseUrl}${privateAppsPath}`, {
4753
- headers: {
4754
- // apiKey is optional — if omitted we rely on the browser session
4755
- // cookie (credentials: 'include'), which is how prod usually auths.
4756
- ...apiKey ? { Authorization: `Bearer ${apiKey}` } : {},
4757
- ...orgId ? { "Org-Id": orgId } : {}
4758
- },
4759
- credentials: "include"
4815
+ const apps = await fetchApps({
4816
+ baseUrl: apiBaseUrl,
4817
+ path: privateAppsPath,
4818
+ apiKey: apiKey || null,
4819
+ orgId: orgId || null
4760
4820
  });
4761
- if (!response.ok) return;
4762
- const data = await response.json();
4763
- const apps = Array.isArray(data) ? data : data?.data || [];
4764
4821
  const normalized = apps.map((a) => ({
4765
4822
  name: a.name || "",
4766
4823
  description: a.description || "",
@@ -5005,6 +5062,8 @@ var ShuffleMCP = import_react9.default.forwardRef(({
5005
5062
  "div",
5006
5063
  {
5007
5064
  className: `singul-dropdown-item ${selected ? "singul-selected" : ""} ${authState.validated ? "singul-validated" : ""} ${authState.configured ? "singul-configured" : ""}`,
5065
+ "data-app-name": app.name,
5066
+ "data-object-id": app.objectID,
5008
5067
  style: {
5009
5068
  ...customStyles.dropdownItem,
5010
5069
  ...selected ? customStyles.selectedItem : {}
@@ -5138,7 +5197,7 @@ var ShuffleMCP = import_react9.default.forwardRef(({
5138
5197
  displayResults.map((app, index) => renderAppItem(app, index)),
5139
5198
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "singul-end-of-results", style: {
5140
5199
  padding: "10px 16px",
5141
- color: "rgba(255, 255, 255, 0.3)",
5200
+ color: "hsl(var(--foreground) / 0.3)",
5142
5201
  textAlign: "center",
5143
5202
  fontSize: "11px",
5144
5203
  gridColumn: "1 / -1"
@@ -5352,10 +5411,19 @@ function AppSearchDrawer({
5352
5411
  onAddToCanvas,
5353
5412
  priorityCategory,
5354
5413
  connectionPathApps,
5355
- pinnedApps
5414
+ pinnedApps,
5415
+ highlightAppName,
5416
+ highlightDelayMs = 5e3
5356
5417
  }) {
5357
5418
  const [detailAppName, setDetailAppName] = (0, import_react10.useState)(null);
5358
5419
  const [detailAppId, setDetailAppId] = (0, import_react10.useState)(null);
5420
+ const [highlightActive, setHighlightActive] = (0, import_react10.useState)(false);
5421
+ (0, import_react10.useEffect)(() => {
5422
+ setHighlightActive(false);
5423
+ if (!open || !highlightAppName) return;
5424
+ const t = setTimeout(() => setHighlightActive(true), highlightDelayMs);
5425
+ return () => clearTimeout(t);
5426
+ }, [open, highlightAppName, highlightDelayMs]);
5359
5427
  const handleClose = () => {
5360
5428
  setDetailAppName(null);
5361
5429
  setDetailAppId(null);
@@ -5496,10 +5564,39 @@ function AppSearchDrawer({
5496
5564
  maxHeight: "none",
5497
5565
  overflowY: "auto"
5498
5566
  },
5567
+ "& .singul-results-grid": {
5568
+ gridAutoRows: "75px",
5569
+ gap: "12px"
5570
+ },
5499
5571
  "& .singul-results-grid .singul-dropdown-item": {
5500
- minHeight: 56,
5501
- alignItems: "center"
5502
- }
5572
+ minHeight: 75,
5573
+ maxHeight: 75,
5574
+ height: 75,
5575
+ padding: "14px 16px",
5576
+ alignItems: "center",
5577
+ overflow: "hidden"
5578
+ },
5579
+ "& .singul-results-grid .singul-app-info": {
5580
+ alignItems: "center",
5581
+ gap: "12px"
5582
+ },
5583
+ "& .singul-results-grid .singul-app-icon": {
5584
+ width: 40,
5585
+ height: 40,
5586
+ borderRadius: 8,
5587
+ padding: 4
5588
+ },
5589
+ ...highlightActive && highlightAppName ? {
5590
+ [`& .singul-dropdown-item[data-app-name="${highlightAppName}"]`]: {
5591
+ borderColor: "hsl(var(--primary)) !important",
5592
+ boxShadow: "0 0 0 2px hsl(var(--primary)), 0 0 18px 2px hsl(var(--primary) / 0.55)",
5593
+ animation: "shuffleHighlightPulse 1.6s ease-in-out infinite"
5594
+ },
5595
+ "@keyframes shuffleHighlightPulse": {
5596
+ "0%, 100%": { boxShadow: "0 0 0 2px hsl(var(--primary)), 0 0 12px 1px hsl(var(--primary) / 0.4)" },
5597
+ "50%": { boxShadow: "0 0 0 2px hsl(var(--primary)), 0 0 24px 4px hsl(var(--primary) / 0.75)" }
5598
+ }
5599
+ } : {}
5503
5600
  },
5504
5601
  children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_framer_motion7.AnimatePresence, { mode: "wait", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
5505
5602
  import_framer_motion7.motion.div,
@@ -5950,10 +6047,12 @@ var TimelineRow = ({
5950
6047
  }
5951
6048
  }
5952
6049
  let toolApp;
5953
- if (details?.tool && typeof details.tool === "string" && details.tool !== "singul") {
5954
- let tn = details.tool.toLowerCase().replace(/[\s-]+/g, "_");
6050
+ const skipToolIcon = item.category === "finalise" || item.category === "finish" || item.category === "ask" || details?.action === "finalise" || details?.action === "finish" || details?.action === "ask";
6051
+ if (!skipToolIcon && details?.tool && typeof details.tool === "string" && details.tool !== "singul" && details.tool !== "core") {
6052
+ const raw = details.tool;
6053
+ let tn = raw.toLowerCase().replace(/[\s-]+/g, "_");
5955
6054
  if (tn.startsWith("app:")) tn = tn.split(":")[2] || tn;
5956
- toolApp = appsById[tn];
6055
+ toolApp = appsById[raw] || appsById[tn];
5957
6056
  }
5958
6057
  const questions = [];
5959
6058
  if (item.category === "ask" || details?.action === "ask") {
@@ -6015,7 +6114,9 @@ var TimelineRow = ({
6015
6114
  maxHeight: 60,
6016
6115
  overflow: "hidden",
6017
6116
  "& p": { margin: 0 },
6018
- "& pre, & code": { fontSize: "0.78rem" }
6117
+ "& pre, & code": { fontSize: "0.78rem" },
6118
+ "& a": { color: "hsl(var(--primary))", textDecoration: "underline", textUnderlineOffset: "2px" },
6119
+ "& a:hover": { opacity: 0.85 }
6019
6120
  }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_markdown4.default, { remarkPlugins: [import_remark_gfm4.default, import_remark_breaks.default], children: normalizeMarkdown(displayLabel) }) }),
6020
6121
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Tooltip, { title: `Duration: ${dur.toFixed(1)}s \xB7 ${itemStart ? new Date(itemStart * 1e3).toLocaleString() : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: { width: maxWidth, position: "relative", height: 10, flexShrink: 0 }, children: dur > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: {
6021
6122
  position: "absolute",
@@ -6032,7 +6133,9 @@ var TimelineRow = ({
6032
6133
  import_material12.Box,
6033
6134
  {
6034
6135
  sx: { display: "flex", alignItems: "center", gap: 0.25, ml: 1, minWidth: 96, justifyContent: "flex-end" },
6035
- onClick: (e) => e.stopPropagation(),
6136
+ onClick: (e) => {
6137
+ if (e.target.closest("button, a")) e.stopPropagation();
6138
+ },
6036
6139
  children: [
6037
6140
  item.type === "decision" && details?.run_details?.status === "WAITING" && (item.category === "ask" || details?.action === "ask") && questions.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
6038
6141
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Tooltip, { title: "Approve this step", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
@@ -6236,6 +6339,7 @@ var AgentUI = ({
6236
6339
  compact = false,
6237
6340
  hideAppPicker = false,
6238
6341
  hideAttach = false,
6342
+ disableStartTab = false,
6239
6343
  appPickerLabel = "Select Apps / MCPs",
6240
6344
  appPickerTitle = "Select Apps / MCPs",
6241
6345
  appPickerSubtitle = "Pick the tools the agent is allowed to use for this run",
@@ -6245,16 +6349,21 @@ var AgentUI = ({
6245
6349
  readUrlParams = true,
6246
6350
  executionId,
6247
6351
  authorization,
6352
+ initialExecution,
6248
6353
  onRun,
6354
+ onViewChange,
6249
6355
  apiKey,
6250
6356
  apiBaseUrl,
6251
- orgId
6357
+ orgId,
6358
+ className,
6359
+ sx,
6360
+ contentSx
6252
6361
  }) => {
6253
- const resolveUrl = (0, import_react11.useCallback)(
6362
+ const resolveUrl2 = (0, import_react11.useCallback)(
6254
6363
  (path) => apiBaseUrl ? `${apiBaseUrl.replace(/\/+$/, "")}${path}` : getApiUrl(path),
6255
6364
  [apiBaseUrl]
6256
6365
  );
6257
- const resolveHeaders = (0, import_react11.useCallback)(() => {
6366
+ const resolveHeaders2 = (0, import_react11.useCallback)(() => {
6258
6367
  const h = apiKey ? { Authorization: `Bearer ${apiKey}` } : { ...getAuthHeader() };
6259
6368
  if (orgId) h["Org-Id"] = orgId;
6260
6369
  return h;
@@ -6268,6 +6377,8 @@ var AgentUI = ({
6268
6377
  ];
6269
6378
  const [chosenApps, setChosenApps] = (0, import_react11.useState)(apps ?? defaultApps ?? BUILTIN_DEFAULT_APPS);
6270
6379
  const [availableApps, setAvailableApps] = (0, import_react11.useState)([]);
6380
+ const [executionApps, setExecutionApps] = (0, import_react11.useState)([]);
6381
+ const [resolvedToolApps, setResolvedToolApps] = (0, import_react11.useState)({});
6271
6382
  const [appSearchOpen, setAppSearchOpen] = (0, import_react11.useState)(false);
6272
6383
  const [agentRequestLoading, setAgentRequestLoading] = (0, import_react11.useState)(false);
6273
6384
  const [execution, setExecution] = (0, import_react11.useState)(null);
@@ -6346,15 +6457,118 @@ var AgentUI = ({
6346
6457
  };
6347
6458
  const appsById = (0, import_react11.useMemo)(() => {
6348
6459
  const m = {};
6349
- for (const a of chosenApps) {
6350
- const slug = a.name.toLowerCase().replace(/\s+/g, "_").replace(/-/g, "_");
6351
- m[slug] = a;
6460
+ const add = (a) => {
6461
+ if (!a?.name) return;
6462
+ const slug = a.name.toLowerCase().replace(/[\s-]+/g, "_");
6463
+ if (!m[slug] || !m[slug].icon && a.icon) m[slug] = a;
6464
+ if (a.id) {
6465
+ if (!m[a.id] || !m[a.id].icon && a.icon) m[a.id] = a;
6466
+ }
6467
+ };
6468
+ for (const a of chosenApps) add(a);
6469
+ for (const a of executionApps) add(a);
6470
+ for (const [k, v] of Object.entries(resolvedToolApps)) {
6471
+ if (!m[k] || !m[k].icon && v.icon) m[k] = v;
6472
+ add(v);
6352
6473
  }
6353
6474
  return m;
6354
- }, [chosenApps]);
6475
+ }, [chosenApps, executionApps, resolvedToolApps]);
6355
6476
  (0, import_react11.useEffect)(() => {
6356
6477
  if (apps) setChosenApps(apps);
6357
6478
  }, [apps]);
6479
+ (0, import_react11.useEffect)(() => {
6480
+ const decisions = agentData?.decisions || [];
6481
+ if (!Array.isArray(decisions) || decisions.length === 0) return;
6482
+ const norm2 = (s) => s.toLowerCase().replace(/[\s-]+/g, "_");
6483
+ const wanted = [];
6484
+ const seen = /* @__PURE__ */ new Set();
6485
+ for (const dec of decisions) {
6486
+ const action = dec?.action || dec?.details?.action;
6487
+ const category = dec?.category || dec?.details?.category;
6488
+ if (action === "finish" || action === "finalise" || action === "ask") continue;
6489
+ if (category === "finish" || category === "finalise" || category === "ask") continue;
6490
+ const tool = dec?.details?.tool ?? dec?.tool;
6491
+ if (!tool || typeof tool !== "string") continue;
6492
+ if (tool === "singul" || tool === "core") continue;
6493
+ let raw = tool;
6494
+ let slug = norm2(tool);
6495
+ if (slug.startsWith("app:")) slug = slug.split(":")[2] || slug;
6496
+ if (appsById[raw]?.icon || appsById[slug]?.icon) continue;
6497
+ if (resolvedToolApps[raw]?.icon || resolvedToolApps[slug]?.icon) continue;
6498
+ const key = `${raw}|${slug}`;
6499
+ if (seen.has(key)) continue;
6500
+ seen.add(key);
6501
+ wanted.push({ raw, slug });
6502
+ }
6503
+ if (wanted.length === 0) return;
6504
+ let cancelled = false;
6505
+ (async () => {
6506
+ const found = {};
6507
+ try {
6508
+ const all = await fetchApps({
6509
+ baseUrl: apiBaseUrl ? apiBaseUrl.replace(/\/+$/, "") : API_CONFIG.baseUrl,
6510
+ apiKey: apiKey || API_CONFIG.apiKey,
6511
+ orgId: orgId || null
6512
+ });
6513
+ if (Array.isArray(all) && all.length > 0) {
6514
+ const byId = /* @__PURE__ */ new Map();
6515
+ const byName = /* @__PURE__ */ new Map();
6516
+ for (const a of all) {
6517
+ if (a?.id) byId.set(String(a.id), a);
6518
+ if (a?.name) byName.set(norm2(String(a.name)), a);
6519
+ }
6520
+ for (const { raw, slug } of wanted) {
6521
+ const hit = byId.get(raw) || byName.get(slug);
6522
+ if (!hit) continue;
6523
+ const icon = hit.large_image || hit.image_url || hit.image || "";
6524
+ const app = { id: hit.id, name: hit.name || slug, icon };
6525
+ found[raw] = app;
6526
+ found[slug] = app;
6527
+ }
6528
+ }
6529
+ } catch {
6530
+ }
6531
+ const stillMissing = wanted.filter(({ raw, slug }) => !found[raw] && !found[slug]);
6532
+ if (stillMissing.length > 0) {
6533
+ try {
6534
+ const { algoliasearch: algoliasearch2 } = await import("algoliasearch");
6535
+ const client = algoliasearch2("JNSS5CFDZZ", "33e4e3564f4f060e96e0531957bed552");
6536
+ await Promise.all(stillMissing.map(async ({ raw, slug }) => {
6537
+ try {
6538
+ try {
6539
+ const obj = await client.getObject({ indexName: "appsearch", objectID: raw });
6540
+ if (obj?.image_url || obj?.name) {
6541
+ const app = { id: obj.objectID || raw, name: obj.name || slug, icon: obj.image_url || "" };
6542
+ found[raw] = app;
6543
+ found[slug] = app;
6544
+ return;
6545
+ }
6546
+ } catch {
6547
+ }
6548
+ const res = await client.searchSingleIndex({
6549
+ indexName: "appsearch",
6550
+ searchParams: { query: slug.replace(/_/g, " "), hitsPerPage: 3 }
6551
+ });
6552
+ const hits = res.hits || [];
6553
+ const match = hits.find((h) => norm2(h.name || "") === slug) || hits[0];
6554
+ if (match?.image_url || match?.name) {
6555
+ const app = { id: match.objectID || raw, name: match.name || slug, icon: match.image_url || "" };
6556
+ found[raw] = app;
6557
+ found[slug] = app;
6558
+ }
6559
+ } catch {
6560
+ }
6561
+ }));
6562
+ } catch {
6563
+ }
6564
+ }
6565
+ if (cancelled || Object.keys(found).length === 0) return;
6566
+ setResolvedToolApps((prev) => ({ ...prev, ...found }));
6567
+ })();
6568
+ return () => {
6569
+ cancelled = true;
6570
+ };
6571
+ }, [JSON.stringify(agentData?.decisions?.map((d) => d?.details?.tool || d?.tool) || []), appsById]);
6358
6572
  (0, import_react11.useEffect)(() => {
6359
6573
  const missing = chosenApps.filter((a) => !a.icon && a.name);
6360
6574
  if (missing.length === 0) return;
@@ -6386,18 +6600,17 @@ var AgentUI = ({
6386
6600
  const stillMissing = missing.filter((a) => !resolved[a.name]);
6387
6601
  if (stillMissing.length > 0) {
6388
6602
  try {
6389
- const res = await fetch(resolveUrl("/api/v1/apps"), {
6390
- credentials: "include",
6391
- headers: { ...resolveHeaders() }
6603
+ const baseUrl = apiBaseUrl ? apiBaseUrl.replace(/\/+$/, "") : API_CONFIG.baseUrl;
6604
+ const apps2 = await fetchApps({
6605
+ baseUrl,
6606
+ apiKey: apiKey || API_CONFIG.apiKey,
6607
+ orgId: orgId || null
6392
6608
  });
6393
- if (res.ok) {
6394
- const apps2 = await res.json();
6395
- if (Array.isArray(apps2)) {
6396
- for (const a of stillMissing) {
6397
- const m = apps2.find((x) => norm2(x.name || "") === norm2(a.name));
6398
- const img = m?.large_image || m?.image_url || m?.image;
6399
- if (img) resolved[a.name] = img;
6400
- }
6609
+ if (Array.isArray(apps2)) {
6610
+ for (const a of stillMissing) {
6611
+ const m = apps2.find((x) => norm2(x.name || "") === norm2(a.name));
6612
+ const img = m?.large_image || m?.image_url || m?.image;
6613
+ if (img) resolved[a.name] = img;
6401
6614
  }
6402
6615
  }
6403
6616
  } catch {
@@ -6413,7 +6626,7 @@ var AgentUI = ({
6413
6626
  return () => {
6414
6627
  cancelled = true;
6415
6628
  };
6416
- }, [chosenApps, availableApps, resolveUrl, resolveHeaders]);
6629
+ }, [chosenApps, availableApps, resolveUrl2, resolveHeaders2]);
6417
6630
  (0, import_react11.useEffect)(() => {
6418
6631
  if (!autoLoadApps) return;
6419
6632
  if (apps || defaultApps) return;
@@ -6421,9 +6634,9 @@ var AgentUI = ({
6421
6634
  let cancelled = false;
6422
6635
  (async () => {
6423
6636
  try {
6424
- const resp = await fetch(resolveUrl("/api/v1/apps/authentication"), {
6637
+ const resp = await fetch(resolveUrl2("/api/v1/apps/authentication"), {
6425
6638
  credentials: "include",
6426
- headers: { ...resolveHeaders() }
6639
+ headers: { ...resolveHeaders2() }
6427
6640
  });
6428
6641
  if (!resp.ok) return;
6429
6642
  const result = await resp.json();
@@ -6452,14 +6665,123 @@ var AgentUI = ({
6452
6665
  return () => {
6453
6666
  cancelled = true;
6454
6667
  };
6455
- }, [autoLoadApps, apps, defaultApps, hasApiKey, resolveUrl, resolveHeaders]);
6668
+ }, [autoLoadApps, apps, defaultApps, hasApiKey, resolveUrl2, resolveHeaders2]);
6669
+ (0, import_react11.useEffect)(() => {
6670
+ const raw = agentData?.allowed_actions;
6671
+ if (!Array.isArray(raw) || raw.length === 0) {
6672
+ setExecutionApps([]);
6673
+ return;
6674
+ }
6675
+ const parsed = [];
6676
+ const seen = /* @__PURE__ */ new Set();
6677
+ for (const entry of raw) {
6678
+ if (typeof entry !== "string") continue;
6679
+ const parts = entry.split(":");
6680
+ if (parts.length < 3 || parts[0] !== "app") continue;
6681
+ const id = parts[1] || "";
6682
+ const name = parts.slice(2).join(":") || "";
6683
+ if (!name && !id) continue;
6684
+ const key = `${id}|${name}`;
6685
+ if (seen.has(key)) continue;
6686
+ seen.add(key);
6687
+ parsed.push({ id, name });
6688
+ }
6689
+ if (parsed.length === 0) {
6690
+ setExecutionApps([]);
6691
+ return;
6692
+ }
6693
+ const resolveFromAvailable = (id, name) => {
6694
+ const byId = id ? availableApps.find((a) => a.id === id) : void 0;
6695
+ const byName = !byId && name ? availableApps.find((a) => (a.name || "").toLowerCase() === name.toLowerCase()) : void 0;
6696
+ const hit = byId || byName;
6697
+ return { id: id || hit?.id, name: hit?.name || name, icon: hit?.icon };
6698
+ };
6699
+ const initial = parsed.map(({ id, name }) => resolveFromAvailable(id, name));
6700
+ setExecutionApps(initial);
6701
+ if (initial.every((a) => !!a.icon)) return;
6702
+ let cancelled = false;
6703
+ const norm2 = (s) => (s || "").toLowerCase().replace(/[\s-]+/g, "_");
6704
+ (async () => {
6705
+ let next = initial;
6706
+ try {
6707
+ const all = await fetchApps({
6708
+ baseUrl: API_CONFIG.baseUrl,
6709
+ apiKey: apiKey || API_CONFIG.apiKey,
6710
+ orgId: orgId || null
6711
+ });
6712
+ if (!cancelled && Array.isArray(all) && all.length > 0) {
6713
+ const byIdMap = /* @__PURE__ */ new Map();
6714
+ const byNameMap = /* @__PURE__ */ new Map();
6715
+ for (const a of all) {
6716
+ if (a?.id) byIdMap.set(String(a.id), a);
6717
+ if (a?.name) byNameMap.set(norm2(String(a.name)), a);
6718
+ }
6719
+ next = next.map((a) => {
6720
+ if (a.icon) return a;
6721
+ const hit = a.id && byIdMap.get(a.id) || byNameMap.get(norm2(a.name || ""));
6722
+ if (!hit) return a;
6723
+ return {
6724
+ id: a.id || hit.id,
6725
+ name: hit.name || a.name,
6726
+ icon: hit.large_image || hit.image_url || hit.image || a.icon
6727
+ };
6728
+ });
6729
+ }
6730
+ } catch {
6731
+ }
6732
+ const stillMissing = next.filter((a) => !a.icon);
6733
+ if (stillMissing.length > 0) {
6734
+ try {
6735
+ const { algoliasearch: algoliasearch2 } = await import("algoliasearch");
6736
+ const client = algoliasearch2("JNSS5CFDZZ", "33e4e3564f4f060e96e0531957bed552");
6737
+ const resolved = {};
6738
+ await Promise.all(stillMissing.map(async (a) => {
6739
+ try {
6740
+ if (a.id) {
6741
+ try {
6742
+ const obj = await client.getObject({ indexName: "appsearch", objectID: a.id });
6743
+ if (obj?.image_url) {
6744
+ resolved[a.id || a.name] = { name: obj.name || a.name, icon: obj.image_url, id: obj.objectID || a.id };
6745
+ return;
6746
+ }
6747
+ } catch {
6748
+ }
6749
+ }
6750
+ const res = await client.searchSingleIndex({
6751
+ indexName: "appsearch",
6752
+ searchParams: { query: (a.name || "").replace(/_/g, " "), hitsPerPage: 3 }
6753
+ });
6754
+ const hits = res.hits || [];
6755
+ const match = hits.find((h) => norm2(h.name || "") === norm2(a.name || "")) || hits[0];
6756
+ if (match?.image_url) {
6757
+ resolved[a.id || a.name] = { name: match.name || a.name, icon: match.image_url, id: match.objectID || a.id || "" };
6758
+ }
6759
+ } catch {
6760
+ }
6761
+ }));
6762
+ if (Object.keys(resolved).length > 0) {
6763
+ next = next.map((a) => {
6764
+ if (a.icon) return a;
6765
+ const r = resolved[a.id || a.name];
6766
+ return r ? { id: r.id || a.id, name: r.name || a.name, icon: r.icon } : a;
6767
+ });
6768
+ }
6769
+ } catch {
6770
+ }
6771
+ }
6772
+ if (!cancelled) setExecutionApps(next);
6773
+ })();
6774
+ return () => {
6775
+ cancelled = true;
6776
+ };
6777
+ }, [JSON.stringify(agentData?.allowed_actions || []), availableApps]);
6456
6778
  const getExecution = (0, import_react11.useCallback)(async (executionId2, authorization2) => {
6457
6779
  if (!executionId2 || !authorization2) return;
6458
6780
  try {
6459
- const resp = await fetch(resolveUrl("/api/v1/streams/results"), {
6781
+ const resp = await fetch(resolveUrl2("/api/v1/streams/results"), {
6460
6782
  method: "POST",
6461
6783
  credentials: "include",
6462
- headers: { "Content-Type": "application/json", ...resolveHeaders() },
6784
+ headers: { "Content-Type": "application/json", ...resolveHeaders2() },
6463
6785
  body: JSON.stringify({ execution_id: executionId2, authorization: authorization2 })
6464
6786
  });
6465
6787
  if (activeExecutionIdRef.current && activeExecutionIdRef.current !== executionId2) return;
@@ -6506,6 +6828,29 @@ var AgentUI = ({
6506
6828
  getExecution(eid, auth);
6507
6829
  }
6508
6830
  }, [readUrlParams, executionId, authorization, getExecution]);
6831
+ (0, import_react11.useEffect)(() => {
6832
+ if (!initialExecution || !initialExecution.execution_id) return;
6833
+ setShowStarter(false);
6834
+ activeExecutionIdRef.current = initialExecution.execution_id;
6835
+ setExecution(initialExecution);
6836
+ let actionResult = null;
6837
+ if (Array.isArray(initialExecution.results)) {
6838
+ actionResult = initialExecution.results.find((r) => r?.action?.app_name === "AI Agent") || initialExecution.results[0];
6839
+ } else {
6840
+ actionResult = initialExecution;
6841
+ }
6842
+ setAgentActionResult(actionResult);
6843
+ const v = validateJson(actionResult?.result);
6844
+ if (v.valid) {
6845
+ setAgentData({
6846
+ ...v.result,
6847
+ started_at: initialExecution.started_at,
6848
+ completed_at: initialExecution.completed_at,
6849
+ status: initialExecution.status
6850
+ });
6851
+ }
6852
+ setError(null);
6853
+ }, [initialExecution?.execution_id]);
6509
6854
  (0, import_react11.useEffect)(() => {
6510
6855
  if (!execution?.execution_id || !execution?.authorization) return;
6511
6856
  const status = (execution.status || "").toUpperCase();
@@ -6645,10 +6990,10 @@ var AgentUI = ({
6645
6990
  decision_id: decisionId
6646
6991
  });
6647
6992
  try {
6648
- const resp = await fetch(resolveUrl(`/api/v1/workflows/${wfId}/run?${params.toString()}`), {
6993
+ const resp = await fetch(resolveUrl2(`/api/v1/workflows/${wfId}/run?${params.toString()}`), {
6649
6994
  method: "GET",
6650
6995
  credentials: "include",
6651
- headers: { ...resolveHeaders() }
6996
+ headers: { ...resolveHeaders2() }
6652
6997
  });
6653
6998
  const json = await resp.json();
6654
6999
  if (json.success === false) {
@@ -6715,10 +7060,10 @@ var AgentUI = ({
6715
7060
  body.source_workflow = execution.workflow?.id;
6716
7061
  setAgentRequestLoading(true);
6717
7062
  try {
6718
- const resp = await fetch(resolveUrl(`/api/v1/apps/agent/run?rerun=true&decision_id=${encodeURIComponent(decisionId)}`), {
7063
+ const resp = await fetch(resolveUrl2(`/api/v1/apps/agent/run?rerun=true&decision_id=${encodeURIComponent(decisionId)}`), {
6719
7064
  method: "POST",
6720
7065
  credentials: "include",
6721
- headers: { "Content-Type": "application/json", ...resolveHeaders() },
7066
+ headers: { "Content-Type": "application/json", ...resolveHeaders2() },
6722
7067
  body: JSON.stringify(body)
6723
7068
  });
6724
7069
  const json = await resp.json().catch(() => ({}));
@@ -6828,6 +7173,9 @@ var AgentUI = ({
6828
7173
  const activeTab = showStarter ? "start" : viewMode;
6829
7174
  const hasExecution = !!execution?.execution_id;
6830
7175
  const showRunSwitcher = hasExecution || agentRequestLoading;
7176
+ (0, import_react11.useEffect)(() => {
7177
+ onViewChange?.(activeTab);
7178
+ }, [activeTab, onViewChange]);
6831
7179
  const goToTab = (t) => {
6832
7180
  if (t === "start") {
6833
7181
  setShowStarter(true);
@@ -6850,15 +7198,19 @@ var AgentUI = ({
6850
7198
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: { display: "inline-flex", gap: 0.25, p: 0.25, borderRadius: 999, bgcolor: "hsl(var(--muted) / 0.6)" }, children: ["start", "simple", "detailed"].map((t) => {
6851
7199
  const active = activeTab === t;
6852
7200
  const label = t === "start" ? "Start" : t === "simple" ? "Simple" : "Detailed";
7201
+ const disabled = t === "start" && disableStartTab;
6853
7202
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
6854
7203
  import_material12.Box,
6855
7204
  {
6856
7205
  component: "button",
6857
7206
  type: "button",
6858
- onClick: () => goToTab(t),
7207
+ onClick: () => {
7208
+ if (!disabled) goToTab(t);
7209
+ },
7210
+ disabled,
6859
7211
  sx: {
6860
7212
  all: "unset",
6861
- cursor: "pointer",
7213
+ cursor: disabled ? "not-allowed" : "pointer",
6862
7214
  px: 1.75,
6863
7215
  py: 0.5,
6864
7216
  borderRadius: 999,
@@ -6866,8 +7218,9 @@ var AgentUI = ({
6866
7218
  fontWeight: 600,
6867
7219
  color: active ? "hsl(var(--primary-foreground))" : "hsl(var(--muted-foreground))",
6868
7220
  bgcolor: active ? "hsl(var(--primary))" : "transparent",
7221
+ opacity: disabled ? 0.4 : 1,
6869
7222
  transition: "background 0.12s ease, color 0.12s ease",
6870
- "&:hover": active ? {} : { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted))" }
7223
+ "&:hover": active || disabled ? {} : { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted))" }
6871
7224
  },
6872
7225
  children: label
6873
7226
  },
@@ -6890,645 +7243,1451 @@ var AgentUI = ({
6890
7243
  }
6891
7244
  ) }) })
6892
7245
  ] });
6893
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: { width: "100%", display: "flex", justifyContent: "center", pb: 4 }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { width: "100%", maxWidth, display: "flex", flexDirection: "column", gap: 3 }, children: [
6894
- showRunSwitcher && tabBar,
6895
- showStarter ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
6896
- import_material12.Box,
6897
- {
6898
- component: "form",
6899
- onSubmit: (e) => {
6900
- e.preventDefault();
6901
- submitInput(actionInput);
6902
- },
6903
- sx: { display: "flex", flexDirection: "column", alignItems: "center", gap: compact ? 2 : 3, py: compact ? 2 : 4 },
6904
- children: [
6905
- !hideHeroIcon && !compact && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: {
6906
- width: heroIconSize,
6907
- height: heroIconSize,
6908
- borderRadius: 3,
6909
- bgcolor: "hsl(var(--card))",
6910
- border: "1px solid hsl(var(--border))",
6911
- display: "flex",
6912
- alignItems: "center",
6913
- justifyContent: "center",
6914
- boxShadow: "0 8px 24px rgba(0,0,0,0.25)"
6915
- }, children: heroIcon ?? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(AgentIcon_default, { size: Math.round(heroIconSize * 0.67) }) }),
6916
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { component: "h1", sx: {
6917
- fontSize: compact ? { xs: "1.25rem", md: "1.5rem" } : { xs: "1.75rem", md: "2.25rem" },
6918
- fontWeight: 600,
6919
- color: "hsl(var(--foreground))",
6920
- textAlign: "center",
6921
- letterSpacing: "-0.01em"
6922
- }, children: title }),
6923
- subtitle && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: {
6924
- fontSize: "0.95rem",
6925
- color: "hsl(var(--muted-foreground))",
6926
- textAlign: "center",
6927
- mt: -1,
6928
- maxWidth: 600
6929
- }, children: subtitle }),
6930
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: {
6931
- width: "100%",
6932
- display: "flex",
6933
- flexDirection: "column",
6934
- gap: 1,
6935
- borderRadius: attachedImages.length > 0 ? 4 : 999,
6936
- border: "1.5px solid hsl(var(--border))",
6937
- bgcolor: "hsl(var(--card))",
6938
- px: 3,
6939
- py: 1.75,
6940
- transition: "border-color 0.15s ease, box-shadow 0.15s ease, border-radius 0.15s ease",
6941
- "&:focus-within": {
6942
- borderColor: "hsl(var(--primary))",
6943
- boxShadow: "0 0 0 3px hsla(var(--primary) / 0.12)"
6944
- }
6945
- }, children: [
6946
- attachedImages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: { display: "flex", flexWrap: "wrap", gap: 0.75 }, children: attachedImages.map((img, idx) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: {
6947
- display: "inline-flex",
6948
- alignItems: "center",
6949
- gap: 1,
6950
- p: 0.5,
6951
- pr: 1,
6952
- borderRadius: 1.5,
6953
- border: "1px solid hsl(var(--border))",
6954
- bgcolor: "hsl(var(--background))",
6955
- maxWidth: "100%"
6956
- }, children: [
6957
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { component: "img", src: img.dataUrl, alt: img.name, sx: { width: 32, height: 32, borderRadius: 1, objectFit: "cover", flexShrink: 0 } }),
6958
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.72rem", color: "hsl(var(--foreground))", maxWidth: 190, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: img.name }),
6959
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.IconButton, { size: "small", onClick: () => setAttachedImages((prev) => prev.filter((_, i) => i !== idx)), sx: { p: 0.25, color: "hsl(var(--muted-foreground))", "&:hover": { color: "hsl(var(--destructive))" } }, "aria-label": "Remove attached image", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_Close4.default, { sx: { fontSize: 12 } }) })
6960
- ] }, `${img.name}-${idx}`)) }),
6961
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { display: "flex", alignItems: "flex-end", gap: 1, width: "100%" }, children: [
6962
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
6963
- import_material12.InputBase,
6964
- {
6965
- inputRef,
6966
- autoFocus: true,
6967
- multiline: true,
6968
- minRows: 1,
6969
- maxRows: 6,
6970
- fullWidth: true,
6971
- value: actionInput,
6972
- onChange: (e) => setActionInput(e.target.value),
6973
- placeholder,
6974
- onKeyDown,
6975
- onPaste: (e) => {
6976
- const items = e.clipboardData?.items;
6977
- if (!items) return;
6978
- const files = [];
6979
- for (const item of Array.from(items)) {
6980
- if (item.kind === "file" && item.type.startsWith("image/")) {
6981
- const file = item.getAsFile();
6982
- if (file) files.push(file);
6983
- }
6984
- }
6985
- if (files.length > 0) {
6986
- e.preventDefault();
6987
- handleImagesSelected(files);
6988
- }
6989
- },
6990
- disabled: agentRequestLoading,
6991
- sx: {
6992
- fontSize: "1rem",
6993
- color: "hsl(var(--foreground))",
6994
- "& textarea::placeholder": { color: "hsl(var(--muted-foreground))", opacity: 0.7 }
6995
- }
6996
- }
6997
- ),
6998
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
6999
- "input",
7000
- {
7001
- ref: fileInputRef,
7002
- type: "file",
7003
- accept: "image/*",
7004
- multiple: true,
7005
- style: { display: "none" },
7006
- onChange: (e) => {
7007
- handleImagesSelected(e.target.files);
7008
- if (e.target) e.target.value = "";
7009
- }
7010
- }
7011
- ),
7012
- !hideAttach && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7013
- import_material12.IconButton,
7014
- {
7015
- type: "button",
7016
- onClick: () => fileInputRef.current?.click(),
7017
- disabled: agentRequestLoading,
7018
- title: attachedImages.length > 0 ? `Add image (${attachedImages.length} attached)` : "Attach image",
7019
- sx: {
7020
- width: 36,
7021
- height: 36,
7022
- color: attachedImages.length > 0 ? "hsl(var(--primary))" : "hsl(var(--muted-foreground))",
7023
- bgcolor: attachedImages.length > 0 ? "hsla(var(--primary) / 0.1)" : "transparent",
7024
- "&:hover": { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted))" }
7025
- },
7026
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_AttachFile.default, { sx: { fontSize: 18 } })
7027
- }
7028
- ),
7029
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Tooltip, { title: submitTooltip, placement: "top", arrow: true, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7030
- import_material12.IconButton,
7031
- {
7032
- type: "submit",
7033
- disabled: actionInput.trim().length < 3 || agentRequestLoading,
7034
- sx: {
7035
- width: 36,
7036
- height: 36,
7037
- bgcolor: actionInput.trim().length >= 3 ? "hsl(var(--primary))" : "hsl(var(--muted))",
7038
- color: actionInput.trim().length >= 3 ? "hsl(var(--primary-foreground))" : "hsl(var(--muted-foreground))",
7039
- "&:hover": actionInput.trim().length >= 3 ? { filter: "brightness(1.1)", bgcolor: "hsl(var(--primary))" } : {},
7040
- "&.Mui-disabled": { bgcolor: "hsl(var(--muted))", color: "hsl(var(--muted-foreground))" }
7041
- },
7042
- children: agentRequestLoading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.CircularProgress, { size: 16, sx: { color: "inherit" } }) : submitIcon ?? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_PlayArrowRounded2.default, {})
7043
- }
7044
- ) }) })
7045
- ] })
7046
- ] }),
7047
- !hideAppPicker && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: { display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: {
7048
- display: "inline-flex",
7049
- flexWrap: "wrap",
7050
- alignItems: "center",
7051
- gap: 0.5,
7052
- p: 0.5,
7053
- borderRadius: 999,
7054
- border: "1px solid hsl(var(--border))",
7055
- bgcolor: "hsl(var(--card))",
7056
- maxWidth: "100%"
7057
- }, children: [
7058
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
7246
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7247
+ import_material12.Box,
7248
+ {
7249
+ className,
7250
+ sx: [
7251
+ { width: "100%", display: "flex", justifyContent: "center", pb: 4 },
7252
+ ...Array.isArray(sx) ? sx : sx ? [sx] : []
7253
+ ],
7254
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
7255
+ import_material12.Box,
7256
+ {
7257
+ sx: [
7258
+ { width: "100%", maxWidth, display: "flex", flexDirection: "column", gap: 3 },
7259
+ ...Array.isArray(contentSx) ? contentSx : contentSx ? [contentSx] : []
7260
+ ],
7261
+ children: [
7262
+ showRunSwitcher && tabBar,
7263
+ showStarter ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
7059
7264
  import_material12.Box,
7060
7265
  {
7061
- component: "button",
7062
- type: "button",
7063
- onClick: () => setAppSearchOpen(true),
7064
- sx: {
7065
- all: "unset",
7066
- cursor: "pointer",
7067
- display: "inline-flex",
7068
- alignItems: "center",
7069
- gap: 0.5,
7070
- px: 1.5,
7071
- py: 0.5,
7072
- borderRadius: 999,
7073
- fontSize: "0.8rem",
7074
- fontWeight: 500,
7075
- color: "hsl(var(--muted-foreground))",
7076
- bgcolor: "transparent",
7077
- transition: "color 0.12s ease, background-color 0.12s ease",
7078
- "&:hover": { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted) / 0.5)" }
7266
+ component: "form",
7267
+ onSubmit: (e) => {
7268
+ e.preventDefault();
7269
+ submitInput(actionInput);
7079
7270
  },
7271
+ sx: { display: "flex", flexDirection: "column", alignItems: "center", gap: compact ? 2 : 3, py: compact ? 2 : 4 },
7080
7272
  children: [
7081
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_Add2.default, { sx: { fontSize: 14 } }),
7082
- appPickerLabel
7273
+ !hideHeroIcon && !compact && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: {
7274
+ width: heroIconSize,
7275
+ height: heroIconSize,
7276
+ borderRadius: 3,
7277
+ bgcolor: "hsl(var(--card))",
7278
+ border: "1px solid hsl(var(--border))",
7279
+ display: "flex",
7280
+ alignItems: "center",
7281
+ justifyContent: "center",
7282
+ boxShadow: "0 8px 24px rgba(0,0,0,0.25)"
7283
+ }, children: heroIcon ?? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(AgentIcon_default, { size: Math.round(heroIconSize * 0.67) }) }),
7284
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { component: "h1", sx: {
7285
+ fontSize: compact ? { xs: "1.25rem", md: "1.5rem" } : { xs: "1.75rem", md: "2.25rem" },
7286
+ fontWeight: 600,
7287
+ color: "hsl(var(--foreground))",
7288
+ textAlign: "center",
7289
+ letterSpacing: "-0.01em"
7290
+ }, children: title }),
7291
+ subtitle && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: {
7292
+ fontSize: "0.95rem",
7293
+ color: "hsl(var(--muted-foreground))",
7294
+ textAlign: "center",
7295
+ mt: -1,
7296
+ maxWidth: 600
7297
+ }, children: subtitle }),
7298
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: {
7299
+ width: "100%",
7300
+ display: "flex",
7301
+ flexDirection: "column",
7302
+ gap: 1,
7303
+ borderRadius: attachedImages.length > 0 ? 4 : 999,
7304
+ border: "1.5px solid hsl(var(--border))",
7305
+ bgcolor: "hsl(var(--card))",
7306
+ px: 3,
7307
+ py: 1.75,
7308
+ transition: "border-color 0.15s ease, box-shadow 0.15s ease, border-radius 0.15s ease",
7309
+ "&:focus-within": {
7310
+ borderColor: "hsl(var(--primary))",
7311
+ boxShadow: "0 0 0 3px hsla(var(--primary) / 0.12)"
7312
+ }
7313
+ }, children: [
7314
+ attachedImages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: { display: "flex", flexWrap: "wrap", gap: 0.75 }, children: attachedImages.map((img, idx) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: {
7315
+ display: "inline-flex",
7316
+ alignItems: "center",
7317
+ gap: 1,
7318
+ p: 0.5,
7319
+ pr: 1,
7320
+ borderRadius: 1.5,
7321
+ border: "1px solid hsl(var(--border))",
7322
+ bgcolor: "hsl(var(--background))",
7323
+ maxWidth: "100%"
7324
+ }, children: [
7325
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { component: "img", src: img.dataUrl, alt: img.name, sx: { width: 32, height: 32, borderRadius: 1, objectFit: "cover", flexShrink: 0 } }),
7326
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.72rem", color: "hsl(var(--foreground))", maxWidth: 190, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: img.name }),
7327
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.IconButton, { size: "small", onClick: () => setAttachedImages((prev) => prev.filter((_, i) => i !== idx)), sx: { p: 0.25, color: "hsl(var(--muted-foreground))", "&:hover": { color: "hsl(var(--destructive))" } }, "aria-label": "Remove attached image", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_Close4.default, { sx: { fontSize: 12 } }) })
7328
+ ] }, `${img.name}-${idx}`)) }),
7329
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { display: "flex", alignItems: "flex-end", gap: 1, width: "100%" }, children: [
7330
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7331
+ import_material12.InputBase,
7332
+ {
7333
+ inputRef,
7334
+ autoFocus: true,
7335
+ multiline: true,
7336
+ minRows: 1,
7337
+ maxRows: 6,
7338
+ fullWidth: true,
7339
+ value: actionInput,
7340
+ onChange: (e) => setActionInput(e.target.value),
7341
+ placeholder,
7342
+ onKeyDown,
7343
+ onPaste: (e) => {
7344
+ const items = e.clipboardData?.items;
7345
+ if (!items) return;
7346
+ const files = [];
7347
+ for (const item of Array.from(items)) {
7348
+ if (item.kind === "file" && item.type.startsWith("image/")) {
7349
+ const file = item.getAsFile();
7350
+ if (file) files.push(file);
7351
+ }
7352
+ }
7353
+ if (files.length > 0) {
7354
+ e.preventDefault();
7355
+ handleImagesSelected(files);
7356
+ }
7357
+ },
7358
+ disabled: agentRequestLoading,
7359
+ sx: {
7360
+ fontSize: "1rem",
7361
+ color: "hsl(var(--foreground))",
7362
+ "& textarea::placeholder": { color: "hsl(var(--muted-foreground))", opacity: 0.7 }
7363
+ }
7364
+ }
7365
+ ),
7366
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7367
+ "input",
7368
+ {
7369
+ ref: fileInputRef,
7370
+ type: "file",
7371
+ accept: "image/*",
7372
+ multiple: true,
7373
+ style: { display: "none" },
7374
+ onChange: (e) => {
7375
+ handleImagesSelected(e.target.files);
7376
+ if (e.target) e.target.value = "";
7377
+ }
7378
+ }
7379
+ ),
7380
+ !hideAttach && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7381
+ import_material12.IconButton,
7382
+ {
7383
+ type: "button",
7384
+ onClick: () => fileInputRef.current?.click(),
7385
+ disabled: agentRequestLoading,
7386
+ title: attachedImages.length > 0 ? `Add image (${attachedImages.length} attached)` : "Attach image",
7387
+ sx: {
7388
+ width: 36,
7389
+ height: 36,
7390
+ color: attachedImages.length > 0 ? "hsl(var(--primary))" : "hsl(var(--muted-foreground))",
7391
+ bgcolor: attachedImages.length > 0 ? "hsla(var(--primary) / 0.1)" : "transparent",
7392
+ "&:hover": { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted))" }
7393
+ },
7394
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_AttachFile.default, { sx: { fontSize: 18 } })
7395
+ }
7396
+ ),
7397
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Tooltip, { title: submitTooltip, placement: "top", arrow: true, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7398
+ import_material12.IconButton,
7399
+ {
7400
+ type: "submit",
7401
+ disabled: actionInput.trim().length < 3 || agentRequestLoading,
7402
+ sx: {
7403
+ width: 36,
7404
+ height: 36,
7405
+ bgcolor: actionInput.trim().length >= 3 ? "hsl(var(--primary))" : "hsl(var(--muted))",
7406
+ color: actionInput.trim().length >= 3 ? "hsl(var(--primary-foreground))" : "hsl(var(--muted-foreground))",
7407
+ "&:hover": actionInput.trim().length >= 3 ? { filter: "brightness(1.1)", bgcolor: "hsl(var(--primary))" } : {},
7408
+ "&.Mui-disabled": { bgcolor: "hsl(var(--muted))", color: "hsl(var(--muted-foreground))" }
7409
+ },
7410
+ children: agentRequestLoading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.CircularProgress, { size: 16, sx: { color: "inherit" } }) : submitIcon ?? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_PlayArrowRounded2.default, {})
7411
+ }
7412
+ ) }) })
7413
+ ] })
7414
+ ] }),
7415
+ !hideAppPicker && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: { display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: {
7416
+ display: "inline-flex",
7417
+ flexWrap: "wrap",
7418
+ alignItems: "center",
7419
+ gap: 0.5,
7420
+ p: 0.5,
7421
+ borderRadius: 999,
7422
+ border: "1px solid hsl(var(--border))",
7423
+ bgcolor: "hsl(var(--card))",
7424
+ maxWidth: "100%"
7425
+ }, children: [
7426
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
7427
+ import_material12.Box,
7428
+ {
7429
+ component: "button",
7430
+ type: "button",
7431
+ onClick: () => setAppSearchOpen(true),
7432
+ sx: {
7433
+ all: "unset",
7434
+ cursor: "pointer",
7435
+ display: "inline-flex",
7436
+ alignItems: "center",
7437
+ gap: 0.5,
7438
+ px: 1.5,
7439
+ py: 0.5,
7440
+ borderRadius: 999,
7441
+ fontSize: "0.8rem",
7442
+ fontWeight: 500,
7443
+ color: "hsl(var(--muted-foreground))",
7444
+ bgcolor: "transparent",
7445
+ transition: "color 0.12s ease, background-color 0.12s ease",
7446
+ "&:hover": { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted) / 0.5)" }
7447
+ },
7448
+ children: [
7449
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_Add2.default, { sx: { fontSize: 14 } }),
7450
+ appPickerLabel
7451
+ ]
7452
+ }
7453
+ ),
7454
+ chosenApps.map((app, i) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
7455
+ import_material12.Box,
7456
+ {
7457
+ sx: {
7458
+ display: "inline-flex",
7459
+ alignItems: "center",
7460
+ gap: 0.5,
7461
+ pl: 0.5,
7462
+ pr: 0.75,
7463
+ py: 0.25,
7464
+ borderRadius: 999,
7465
+ bgcolor: "hsl(var(--muted) / 0.6)",
7466
+ fontSize: "0.8rem",
7467
+ color: "hsl(var(--foreground))"
7468
+ },
7469
+ children: [
7470
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7471
+ import_material12.Avatar,
7472
+ {
7473
+ src: app.icon || void 0,
7474
+ alt: app.name,
7475
+ variant: "rounded",
7476
+ sx: { width: 18, height: 18, bgcolor: "transparent" }
7477
+ }
7478
+ ),
7479
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.8rem", mx: 0.25, textTransform: "capitalize" }, children: app.name.replace(/_/g, " ") }),
7480
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7481
+ import_material12.IconButton,
7482
+ {
7483
+ size: "small",
7484
+ onClick: () => setChosenApps((prev) => prev.filter((_, idx) => idx !== i)),
7485
+ sx: { p: 0.125, color: "hsl(var(--muted-foreground))", "&:hover": { color: "hsl(var(--destructive))" } },
7486
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_Close4.default, { sx: { fontSize: 12 } })
7487
+ }
7488
+ )
7489
+ ]
7490
+ },
7491
+ `${app.name}-${i}`
7492
+ ))
7493
+ ] }) }),
7494
+ error && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: {
7495
+ width: "100%",
7496
+ p: 1.5,
7497
+ borderRadius: 1.5,
7498
+ border: "1px solid hsl(var(--destructive) / 0.4)",
7499
+ bgcolor: "hsl(var(--destructive) / 0.08)",
7500
+ color: "hsl(var(--destructive))",
7501
+ fontSize: "0.85rem"
7502
+ }, children: error })
7083
7503
  ]
7084
7504
  }
7085
- ),
7086
- chosenApps.map((app, i) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
7087
- import_material12.Box,
7088
- {
7089
- sx: {
7090
- display: "inline-flex",
7091
- alignItems: "center",
7092
- gap: 0.5,
7093
- pl: 0.5,
7094
- pr: 0.75,
7095
- py: 0.25,
7096
- borderRadius: 999,
7097
- bgcolor: "hsl(var(--muted) / 0.6)",
7098
- fontSize: "0.8rem",
7099
- color: "hsl(var(--foreground))"
7100
- },
7101
- children: [
7102
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7103
- import_material12.Avatar,
7104
- {
7105
- src: app.icon || void 0,
7106
- alt: app.name,
7107
- variant: "rounded",
7108
- sx: { width: 18, height: 18, bgcolor: "transparent" }
7505
+ ) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { children: [
7506
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: {
7507
+ display: "flex",
7508
+ alignItems: "center",
7509
+ gap: 2,
7510
+ p: 2,
7511
+ borderRadius: 2,
7512
+ border: "1px solid hsl(var(--border))",
7513
+ bgcolor: "hsl(var(--card))",
7514
+ mb: 2
7515
+ }, children: [
7516
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { flex: 1, minWidth: 0 }, children: [
7517
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.85rem", color: "hsl(var(--foreground))", fontWeight: 600, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: agentData?.original_input || actionInput || "Agent run" }),
7518
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Typography, { sx: { fontSize: "0.7rem", color: "hsl(var(--muted-foreground))" }, children: [
7519
+ "Status: ",
7520
+ execution?.status || agentData?.status || "\u2014",
7521
+ " \xB7 ",
7522
+ execution?.execution_id?.slice(0, 8) || ""
7523
+ ] })
7524
+ ] }),
7525
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.AvatarGroup, { max: 6, sx: { "& .MuiAvatar-root": { width: 28, height: 28, borderColor: "hsl(var(--border))" } }, children: (executionApps.length > 0 ? executionApps : chosenApps).map((app, i) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Tooltip, { title: (app.name || "").replace(/_/g, " "), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7526
+ import_material12.Avatar,
7527
+ {
7528
+ src: app.icon || void 0,
7529
+ alt: app.name,
7530
+ variant: "rounded",
7531
+ onClick: () => navigate(`/apps/${encodeURIComponent((app.name || "").toLowerCase().replace(/\s+/g, "_"))}`),
7532
+ sx: {
7533
+ bgcolor: "hsl(var(--muted))",
7534
+ cursor: "pointer",
7535
+ transition: "transform 0.15s ease, border-color 0.15s ease",
7536
+ "&:hover": { transform: "scale(1.08)", borderColor: "hsl(var(--primary)) !important" }
7109
7537
  }
7110
- ),
7111
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.8rem", mx: 0.25, textTransform: "capitalize" }, children: app.name.replace(/_/g, " ") }),
7112
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7113
- import_material12.IconButton,
7538
+ }
7539
+ ) }, i)) })
7540
+ ] }),
7541
+ error && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: {
7542
+ p: 1.5,
7543
+ borderRadius: 1.5,
7544
+ mb: 2,
7545
+ border: "1px solid hsl(var(--destructive) / 0.4)",
7546
+ bgcolor: "hsl(var(--destructive) / 0.08)",
7547
+ color: "hsl(var(--destructive))",
7548
+ fontSize: "0.85rem"
7549
+ }, children: error }),
7550
+ viewMode === "simple" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: {
7551
+ borderRadius: 2,
7552
+ border: "1px solid hsl(var(--border))",
7553
+ bgcolor: "hsl(var(--card))",
7554
+ p: 2.5,
7555
+ display: "flex",
7556
+ flexDirection: "column",
7557
+ gap: 1.5
7558
+ }, children: (() => {
7559
+ const status = (execution?.status || agentData?.status || "EXECUTING").toUpperCase();
7560
+ const decisionCount = (agentData?.decisions || []).length;
7561
+ const isRunning = !["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(status);
7562
+ const rawStartedAt = agentData?.started_at || execution?.started_at || 0;
7563
+ const startedAtSec = rawStartedAt > 1e12 ? Math.floor(rawStartedAt / 1e3) : rawStartedAt;
7564
+ const effectiveStart = startedAtSec || localRunStart || 0;
7565
+ let durationSec = null;
7566
+ if (isRunning && effectiveStart) {
7567
+ durationSec = Math.max(0, nowTick - effectiveStart);
7568
+ } else if (totalDuration && totalDuration > 0) {
7569
+ durationSec = Math.round(totalDuration);
7570
+ }
7571
+ const pendingAsk = (agentData?.decisions || []).slice().reverse().find((d) => {
7572
+ const isAsk = d.category === "ask" || d.action === "ask";
7573
+ const st = (d.run_details?.status || "").toUpperCase();
7574
+ return isAsk && (st === "RUNNING" || st === "WAITING");
7575
+ });
7576
+ const pendingQuestions = [];
7577
+ if (pendingAsk) {
7578
+ for (const f of pendingAsk.fields || []) {
7579
+ if (f.key === "question" && f.value) {
7580
+ pendingQuestions.push({ question: f.value, index: pendingQuestions.length + 1 });
7581
+ }
7582
+ }
7583
+ }
7584
+ const pendingAnswered = pendingQuestions.every((q) => questionAnswers[q.question]?.value);
7585
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
7586
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { display: "flex", alignItems: "center", gap: 1, flexWrap: "wrap" }, children: [
7587
+ isRunning ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.CircularProgress, { size: 16, sx: { color: "hsl(var(--primary))" } }) : status === "FINISHED" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_CheckCircle3.default, { sx: { fontSize: 18, color: "hsl(142 70% 45%)" } }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_Error.default, { sx: { fontSize: 18, color: "hsl(var(--destructive))" } }),
7588
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.9rem", fontWeight: 600, color: "hsl(var(--foreground))" }, children: isRunning ? "Agent is working\u2026" : status === "FINISHED" ? "Run finished" : `Run ${status.toLowerCase()}` }),
7589
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Typography, { sx: { fontSize: "0.75rem", color: "hsl(var(--muted-foreground))" }, children: [
7590
+ decisionCount,
7591
+ " step",
7592
+ decisionCount === 1 ? "" : "s",
7593
+ durationSec != null ? ` \xB7 ${durationSec}s` : ""
7594
+ ] })
7595
+ ] }),
7596
+ finishAnswer ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: {
7597
+ p: 2,
7598
+ borderRadius: 1.5,
7599
+ border: "1px solid hsl(var(--border))",
7600
+ bgcolor: "hsl(var(--background))",
7601
+ fontSize: "0.9rem",
7602
+ color: "hsl(var(--foreground))",
7603
+ "& > *:first-of-type": { mt: 0 },
7604
+ "& > *:last-child": { mb: 0 },
7605
+ "& p": { my: 1, lineHeight: 1.55 },
7606
+ "& h1, & h2, & h3, & h4": { mt: 2, mb: 1, fontWeight: 600, lineHeight: 1.3 },
7607
+ "& h1": { fontSize: "1.15rem" },
7608
+ "& h2": { fontSize: "1.05rem" },
7609
+ "& h3, & h4": { fontSize: "0.95rem" },
7610
+ "& ul": { my: 1, pl: 3, listStyleType: "disc", listStylePosition: "outside" },
7611
+ "& ol": { my: 1, pl: 3, listStyleType: "decimal", listStylePosition: "outside" },
7612
+ "& ul ul": { listStyleType: "circle" },
7613
+ "& ul ul ul": { listStyleType: "square" },
7614
+ "& li": { my: 0.25, display: "list-item" },
7615
+ "& li::marker": { color: "hsl(var(--muted-foreground))" },
7616
+ "& a": { color: "hsl(var(--primary))", textDecoration: "underline" },
7617
+ "& code": {
7618
+ px: 0.5,
7619
+ py: 0.125,
7620
+ borderRadius: 0.5,
7621
+ bgcolor: "hsl(var(--muted))",
7622
+ fontFamily: '"JetBrains Mono", ui-monospace, monospace',
7623
+ fontSize: "0.82em"
7624
+ },
7625
+ "& pre": {
7626
+ p: 1.5,
7627
+ my: 1,
7628
+ borderRadius: 1,
7629
+ bgcolor: "hsl(var(--muted))",
7630
+ overflowX: "auto",
7631
+ fontSize: "0.82rem"
7632
+ },
7633
+ "& pre code": { p: 0, bgcolor: "transparent" },
7634
+ "& blockquote": {
7635
+ borderLeft: "3px solid hsl(var(--border))",
7636
+ pl: 1.5,
7637
+ my: 1,
7638
+ color: "hsl(var(--muted-foreground))"
7639
+ },
7640
+ "& table": { borderCollapse: "collapse", my: 1, fontSize: "0.85rem" },
7641
+ "& th, & td": { border: "1px solid hsl(var(--border))", px: 1, py: 0.5 },
7642
+ "& hr": { border: 0, borderTop: "1px solid hsl(var(--border))", my: 1.5 }
7643
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_markdown4.default, { remarkPlugins: [import_remark_gfm4.default, import_remark_breaks.default], children: normalizeMarkdown(finishAnswer) }) }) : pendingAsk && pendingQuestions.length > 0 ? (() => {
7644
+ const trySimpleSubmit = () => {
7645
+ if (agentRequestLoading) return;
7646
+ if (!pendingAnswered) {
7647
+ setSimpleSubmitAttempted(true);
7648
+ return;
7649
+ }
7650
+ if (pendingAsk.run_details?.id) {
7651
+ submitQuestions(pendingAsk.run_details.id, questionAnswers);
7652
+ }
7653
+ };
7654
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: [
7655
+ pendingQuestions.map((q, qi) => {
7656
+ const value = questionAnswers[q.question]?.value || "";
7657
+ const isMissing = simpleSubmitAttempted && !value;
7658
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { children: [
7659
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: { fontSize: "0.9rem", color: "hsl(var(--foreground))", mb: 1, "& p": { my: 0.5 } }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_markdown4.default, { remarkPlugins: [import_remark_gfm4.default, import_remark_breaks.default], children: normalizeMarkdown(q.question) }) }),
7660
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7661
+ import_material12.TextField,
7662
+ {
7663
+ fullWidth: true,
7664
+ multiline: true,
7665
+ minRows: 2,
7666
+ placeholder: "Your answer here\u2026",
7667
+ value,
7668
+ error: isMissing,
7669
+ helperText: isMissing ? "Please answer this question" : void 0,
7670
+ onChange: (e) => {
7671
+ const v = e.target.value;
7672
+ setQuestionAnswers((prev) => ({
7673
+ ...prev,
7674
+ [q.question]: { index: qi, value: v }
7675
+ }));
7676
+ },
7677
+ onKeyDown: (e) => {
7678
+ if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
7679
+ e.preventDefault();
7680
+ trySimpleSubmit();
7681
+ }
7682
+ },
7683
+ size: "small",
7684
+ sx: { "& .MuiOutlinedInput-root": { bgcolor: "hsl(var(--background))" } }
7685
+ }
7686
+ )
7687
+ ] }, qi);
7688
+ }),
7689
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
7690
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7691
+ import_material12.Button,
7692
+ {
7693
+ variant: "contained",
7694
+ size: "small",
7695
+ disabled: agentRequestLoading,
7696
+ onClick: trySimpleSubmit,
7697
+ children: agentRequestLoading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.CircularProgress, { size: 16 }) : "Submit"
7698
+ }
7699
+ ),
7700
+ pendingAsk.run_details?.id && getFormUrl(pendingAsk.run_details.id) && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Tooltip, { title: "Answer in the Form UI", placement: "right", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7701
+ import_material12.IconButton,
7702
+ {
7703
+ size: "small",
7704
+ onClick: () => {
7705
+ const url = getFormUrl(pendingAsk.run_details.id);
7706
+ if (url) window.open(url, "_blank", "noopener,noreferrer");
7707
+ },
7708
+ sx: { color: "hsl(var(--muted-foreground))", "&:hover": { color: "hsl(var(--primary))" } },
7709
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_OpenInNew2.default, { sx: { fontSize: 18 } })
7710
+ }
7711
+ ) })
7712
+ ] })
7713
+ ] });
7714
+ })() : isRunning ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.85rem", color: "hsl(var(--muted-foreground))" }, children: "Waiting for the agent to produce the first step." }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.85rem", color: "hsl(var(--muted-foreground))" }, children: "No final answer was returned. Open Detailed to inspect each step." }),
7715
+ !isRunning && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7716
+ import_material12.Button,
7114
7717
  {
7115
7718
  size: "small",
7116
- onClick: () => setChosenApps((prev) => prev.filter((_, idx) => idx !== i)),
7117
- sx: { p: 0.125, color: "hsl(var(--muted-foreground))", "&:hover": { color: "hsl(var(--destructive))" } },
7118
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_Close4.default, { sx: { fontSize: 12 } })
7719
+ variant: "text",
7720
+ onClick: () => setViewMode("detailed"),
7721
+ sx: { color: "hsl(var(--primary))", textTransform: "none", px: 0 },
7722
+ children: "View detailed timeline \u2192"
7119
7723
  }
7120
- )
7121
- ]
7724
+ ) })
7725
+ ] });
7726
+ })() }),
7727
+ viewMode === "detailed" && (() => {
7728
+ const detailedStatus = (execution?.status || agentData?.status || "EXECUTING").toUpperCase();
7729
+ const detailedIsRunning = !["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(detailedStatus);
7730
+ const detailedRunFinished = !detailedIsRunning;
7731
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: {
7732
+ borderRadius: 2,
7733
+ border: "1px solid hsl(var(--border))",
7734
+ bgcolor: "hsl(var(--card))",
7735
+ overflow: "hidden"
7736
+ }, children: timeline.length === 0 || timeline.length === 1 && agentRequestLoading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { p: 4, textAlign: "center", color: "hsl(var(--muted-foreground))", fontSize: "0.85rem" }, children: [
7737
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.CircularProgress, { size: 20, sx: { mb: 1 } }),
7738
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.85rem" }, children: "Waiting for agent response\u2026" })
7739
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
7740
+ timeline.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7741
+ TimelineRow,
7742
+ {
7743
+ item,
7744
+ index: i,
7745
+ open: openIndexes.has(i),
7746
+ onToggle: () => toggleOpen(i),
7747
+ appsById,
7748
+ totalDuration,
7749
+ originalStartTime,
7750
+ maxWidth: 210,
7751
+ questionAnswers,
7752
+ setQuestionAnswers,
7753
+ onSubmitQuestions: submitQuestions,
7754
+ onRerunAgent: rerunAgent,
7755
+ onRerunDecision: rerunDecision,
7756
+ agentRequestLoading,
7757
+ getFormUrl,
7758
+ runFinished: detailedRunFinished
7759
+ },
7760
+ i
7761
+ )),
7762
+ detailedRunFinished && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: {
7763
+ borderTop: "1px solid hsl(var(--border))",
7764
+ p: 2.5,
7765
+ display: "flex",
7766
+ flexDirection: "column",
7767
+ gap: 1.5,
7768
+ bgcolor: "hsl(var(--muted) / 0.2)"
7769
+ }, children: [
7770
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { display: "flex", alignItems: "center", gap: 1, flexWrap: "wrap" }, children: [
7771
+ detailedStatus === "FINISHED" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_CheckCircle3.default, { sx: { fontSize: 18, color: "hsl(142 70% 45%)" } }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_Error.default, { sx: { fontSize: 18, color: "hsl(var(--destructive))" } }),
7772
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.9rem", fontWeight: 600, color: "hsl(var(--foreground))" }, children: detailedStatus === "FINISHED" ? "Run finished" : `Run ${detailedStatus.toLowerCase()}` })
7773
+ ] }),
7774
+ finishAnswer && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: {
7775
+ p: 2,
7776
+ borderRadius: 1.5,
7777
+ border: "1px solid hsl(var(--border))",
7778
+ bgcolor: "hsl(var(--background))",
7779
+ fontSize: "0.9rem",
7780
+ color: "hsl(var(--foreground))",
7781
+ "& > *:first-of-type": { mt: 0 },
7782
+ "& > *:last-child": { mb: 0 },
7783
+ "& p": { my: 1, lineHeight: 1.55 },
7784
+ "& a": { color: "hsl(var(--primary))", textDecoration: "underline" },
7785
+ "& code": {
7786
+ px: 0.5,
7787
+ py: 0.125,
7788
+ borderRadius: 0.5,
7789
+ bgcolor: "hsl(var(--muted))",
7790
+ fontFamily: '"JetBrains Mono", ui-monospace, monospace',
7791
+ fontSize: "0.82em"
7792
+ },
7793
+ "& pre": {
7794
+ p: 1.5,
7795
+ my: 1,
7796
+ borderRadius: 1,
7797
+ bgcolor: "hsl(var(--muted))",
7798
+ overflowX: "auto",
7799
+ fontSize: "0.82rem"
7800
+ },
7801
+ "& pre code": { p: 0, bgcolor: "transparent" }
7802
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_markdown4.default, { remarkPlugins: [import_remark_gfm4.default, import_remark_breaks.default], children: normalizeMarkdown(finishAnswer) }) })
7803
+ ] })
7804
+ ] }) });
7805
+ })(),
7806
+ finishDecisionId && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: { mt: 3, display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { width: "100%", maxWidth: 640 }, children: [
7807
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.75rem", color: "hsl(var(--muted-foreground))", mb: 0.75, textAlign: "center" }, children: "Continue this agent run with more details" }),
7808
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
7809
+ import_material12.Box,
7810
+ {
7811
+ component: "form",
7812
+ onSubmit: (e) => {
7813
+ e.preventDefault();
7814
+ if (continuationText.trim()) {
7815
+ submitQuestions(finishDecisionId, { continue: continuationText }, true);
7816
+ }
7817
+ },
7818
+ sx: {
7819
+ display: "flex",
7820
+ alignItems: "flex-end",
7821
+ gap: 1,
7822
+ p: 1.25,
7823
+ borderRadius: 999,
7824
+ border: "1.5px solid hsl(var(--border))",
7825
+ bgcolor: "hsl(var(--card))",
7826
+ "&:focus-within": {
7827
+ borderColor: "hsl(var(--primary))",
7828
+ boxShadow: "0 0 0 3px hsla(var(--primary) / 0.12)"
7829
+ }
7830
+ },
7831
+ children: [
7832
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7833
+ import_material12.InputBase,
7834
+ {
7835
+ fullWidth: true,
7836
+ multiline: true,
7837
+ minRows: 1,
7838
+ maxRows: 4,
7839
+ placeholder: continuationPlaceholder,
7840
+ value: continuationText,
7841
+ onChange: (e) => setContinuationText(e.target.value),
7842
+ onKeyDown: (e) => {
7843
+ if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
7844
+ e.preventDefault();
7845
+ if (continuationText.trim() && !agentRequestLoading) {
7846
+ submitQuestions(finishDecisionId, { continue: continuationText }, true);
7847
+ }
7848
+ }
7849
+ },
7850
+ disabled: agentRequestLoading,
7851
+ sx: { fontSize: "0.9rem", color: "hsl(var(--foreground))", px: 2 }
7852
+ }
7853
+ ),
7854
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7855
+ import_material12.IconButton,
7856
+ {
7857
+ type: "submit",
7858
+ disabled: !continuationText.trim() || agentRequestLoading,
7859
+ sx: {
7860
+ width: 36,
7861
+ height: 36,
7862
+ bgcolor: continuationText.trim() && !agentRequestLoading ? "hsl(var(--primary))" : "hsl(var(--muted))",
7863
+ color: continuationText.trim() && !agentRequestLoading ? "hsl(var(--primary-foreground))" : "hsl(var(--muted-foreground))",
7864
+ "&:hover": continuationText.trim() && !agentRequestLoading ? { filter: "brightness(1.1)", bgcolor: "hsl(var(--primary))" } : {}
7865
+ },
7866
+ children: agentRequestLoading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.CircularProgress, { size: 16, sx: { color: "inherit" } }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_Send.default, { sx: { fontSize: 18 } })
7867
+ }
7868
+ )
7869
+ ]
7870
+ }
7871
+ )
7872
+ ] }) })
7873
+ ] }),
7874
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7875
+ AppSearchDrawer,
7876
+ {
7877
+ open: appSearchOpen,
7878
+ onClose: () => setAppSearchOpen(false),
7879
+ title: appPickerTitle,
7880
+ subtitle: appPickerSubtitle,
7881
+ onQuickSelect: (app) => {
7882
+ const known = availableApps.find((a) => a.name?.toLowerCase() === app.name?.toLowerCase());
7883
+ setChosenApps(
7884
+ (prev) => prev.some((a) => a.name === app.name) ? prev : [...prev, { name: app.name, icon: app.icon || known?.icon, id: app.id || known?.id || void 0 }]
7885
+ );
7886
+ }
7887
+ }
7888
+ )
7889
+ ]
7890
+ }
7891
+ )
7892
+ }
7893
+ );
7894
+ };
7895
+ var AgentUI_default = AgentUI;
7896
+
7897
+ // AgentRunDrawer.tsx
7898
+ var import_react12 = require("react");
7899
+ var import_material13 = require("@mui/material");
7900
+ var import_Close5 = __toESM(require("@mui/icons-material/Close"), 1);
7901
+ var import_lucide_react3 = require("lucide-react");
7902
+ var import_jsx_runtime15 = require("react/jsx-runtime");
7903
+ var TAB_ORDER = ["run", "permissions", "localLLM"];
7904
+ var AgentRunDrawer = ({
7905
+ open,
7906
+ onClose,
7907
+ initialTab = "run",
7908
+ permissionsSlot,
7909
+ localLLMSlot,
7910
+ localLLMTabBadge,
7911
+ permissionsDisabled = false,
7912
+ permissionsDisabledTooltip = "Coming soon",
7913
+ agentUIProps,
7914
+ width = 520,
7915
+ title = "Agent",
7916
+ subtitle = "Run actions and manage permissions",
7917
+ className,
7918
+ paperSx,
7919
+ headerSx,
7920
+ tabsSx,
7921
+ bodySx
7922
+ }) => {
7923
+ const [activeTab, setActiveTab] = (0, import_react12.useState)(initialTab);
7924
+ const prevOpenRef = (0, import_react12.useRef)(open);
7925
+ (0, import_react12.useEffect)(() => {
7926
+ if (open && !prevOpenRef.current) setActiveTab(initialTab);
7927
+ prevOpenRef.current = open;
7928
+ }, [open, initialTab]);
7929
+ const visibleTabs = TAB_ORDER.filter((t) => {
7930
+ if (t === "run") return true;
7931
+ if (t === "permissions") return !!permissionsSlot;
7932
+ if (t === "localLLM") return !!localLLMSlot;
7933
+ return false;
7934
+ });
7935
+ const showTabs = visibleTabs.length > 1;
7936
+ const safeActiveTab = visibleTabs.includes(activeTab) ? activeTab : "run";
7937
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
7938
+ import_material13.Drawer,
7939
+ {
7940
+ anchor: "right",
7941
+ open,
7942
+ onClose,
7943
+ slotProps: {
7944
+ paper: {
7945
+ className,
7946
+ sx: [
7947
+ {
7948
+ width: { xs: "100%", sm: width },
7949
+ background: "linear-gradient(180deg, hsl(var(--card)) 0%, hsl(var(--background)) 100%)",
7950
+ borderLeft: "1px solid hsl(var(--border))",
7951
+ boxShadow: "-8px 0 32px hsla(0, 0%, 0%, 0.4)",
7952
+ display: "flex",
7953
+ flexDirection: "column"
7954
+ },
7955
+ ...Array.isArray(paperSx) ? paperSx : paperSx ? [paperSx] : []
7956
+ ]
7957
+ }
7958
+ },
7959
+ children: [
7960
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
7961
+ import_material13.Box,
7962
+ {
7963
+ sx: [
7964
+ {
7965
+ px: 3,
7966
+ py: 2.5,
7967
+ display: "flex",
7968
+ alignItems: "center",
7969
+ gap: 2,
7970
+ borderBottom: "1px solid hsl(var(--border))",
7971
+ flexShrink: 0
7122
7972
  },
7123
- `${app.name}-${i}`
7124
- ))
7125
- ] }) }),
7126
- error && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: {
7127
- width: "100%",
7128
- p: 1.5,
7129
- borderRadius: 1.5,
7130
- border: "1px solid hsl(var(--destructive) / 0.4)",
7131
- bgcolor: "hsl(var(--destructive) / 0.08)",
7132
- color: "hsl(var(--destructive))",
7133
- fontSize: "0.85rem"
7134
- }, children: error })
7135
- ]
7973
+ ...Array.isArray(headerSx) ? headerSx : headerSx ? [headerSx] : []
7974
+ ],
7975
+ children: [
7976
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
7977
+ import_material13.Box,
7978
+ {
7979
+ sx: {
7980
+ width: 40,
7981
+ height: 40,
7982
+ borderRadius: "50%",
7983
+ display: "flex",
7984
+ alignItems: "center",
7985
+ justifyContent: "center",
7986
+ background: "hsla(var(--primary) / 0.12)",
7987
+ color: "hsl(var(--primary))",
7988
+ flexShrink: 0
7989
+ },
7990
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(AgentIcon_default, { size: 22 })
7991
+ }
7992
+ ),
7993
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_material13.Box, { sx: { flex: 1, minWidth: 0 }, children: [
7994
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_material13.Typography, { sx: { fontWeight: 600, fontSize: "1.1rem", color: "hsl(var(--foreground))" }, children: title }),
7995
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_material13.Typography, { sx: { fontSize: "0.8rem", color: "hsl(var(--muted-foreground))" }, children: subtitle })
7996
+ ] }),
7997
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_material13.IconButton, { onClick: onClose, size: "small", sx: { color: "hsl(var(--muted-foreground))" }, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_Close5.default, { fontSize: "small" }) })
7998
+ ]
7999
+ }
8000
+ ),
8001
+ showTabs && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_material13.Box, { sx: { borderBottom: "1px solid hsl(var(--border))", flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
8002
+ import_material13.Tabs,
8003
+ {
8004
+ value: safeActiveTab,
8005
+ onChange: (_, v) => setActiveTab(v),
8006
+ sx: [
8007
+ {
8008
+ minHeight: 42,
8009
+ px: 3,
8010
+ "& .MuiTab-root": {
8011
+ minHeight: 42,
8012
+ textTransform: "none",
8013
+ fontSize: "0.85rem",
8014
+ fontWeight: 500,
8015
+ color: "hsl(var(--muted-foreground))",
8016
+ "&.Mui-selected": { color: "hsl(var(--primary))" }
8017
+ },
8018
+ "& .MuiTabs-indicator": { bgcolor: "hsl(var(--primary))" }
8019
+ },
8020
+ ...Array.isArray(tabsSx) ? tabsSx : tabsSx ? [tabsSx] : []
8021
+ ],
8022
+ children: [
8023
+ visibleTabs.includes("run") && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
8024
+ import_material13.Tab,
8025
+ {
8026
+ value: "run",
8027
+ label: "Run",
8028
+ icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react3.Play, { size: 14 }),
8029
+ iconPosition: "start",
8030
+ sx: { gap: 0.75 }
8031
+ }
8032
+ ),
8033
+ visibleTabs.includes("permissions") && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
8034
+ import_material13.Tab,
8035
+ {
8036
+ value: "permissions",
8037
+ label: permissionsDisabled ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_material13.Tooltip, { title: permissionsDisabledTooltip, arrow: true, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_material13.Box, { component: "span", sx: { display: "inline-flex", alignItems: "center" }, children: "Permissions" }) }) : "Permissions",
8038
+ icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react3.ShieldCheck, { size: 14 }),
8039
+ iconPosition: "start",
8040
+ disabled: permissionsDisabled,
8041
+ sx: { gap: 0.75 }
8042
+ }
8043
+ ),
8044
+ visibleTabs.includes("localLLM") && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
8045
+ import_material13.Tab,
8046
+ {
8047
+ value: "localLLM",
8048
+ label: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_material13.Box, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
8049
+ "Local LLM",
8050
+ localLLMTabBadge
8051
+ ] }),
8052
+ icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react3.Server, { size: 14 }),
8053
+ iconPosition: "start",
8054
+ sx: { gap: 0.75 }
8055
+ }
8056
+ )
8057
+ ]
8058
+ }
8059
+ ) }),
8060
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_material13.Box, { sx: [{ flex: 1, overflowY: "auto" }, ...Array.isArray(bodySx) ? bodySx : bodySx ? [bodySx] : []], children: [
8061
+ safeActiveTab === "run" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_material13.Box, { sx: { px: 2, py: 2 }, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
8062
+ AgentUI_default,
8063
+ {
8064
+ compact: true,
8065
+ hideHeroIcon: true,
8066
+ title: "",
8067
+ subtitle: null,
8068
+ ...agentUIProps
8069
+ }
8070
+ ) }),
8071
+ safeActiveTab === "permissions" && permissionsSlot && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_material13.Box, { sx: { px: 3, py: 2.5 }, children: permissionsSlot }),
8072
+ safeActiveTab === "localLLM" && localLLMSlot && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_material13.Box, { sx: { px: 3, py: 2.5 }, children: localLLMSlot })
8073
+ ] })
8074
+ ]
8075
+ }
8076
+ );
8077
+ };
8078
+ var AgentRunDrawer_default = AgentRunDrawer;
8079
+
8080
+ // AgentActivityList.tsx
8081
+ var import_react13 = require("react");
8082
+ var import_material14 = require("@mui/material");
8083
+ var import_Search = __toESM(require("@mui/icons-material/Search"), 1);
8084
+ var import_lucide_react4 = require("lucide-react");
8085
+
8086
+ // agentActivity.ts
8087
+ var resolveUrl = (path, baseUrl) => baseUrl ? `${baseUrl.replace(/\/+$/, "")}${path}` : getApiUrl(path);
8088
+ var resolveHeaders = (apiKey, orgId) => {
8089
+ const h = apiKey ? { Authorization: `Bearer ${apiKey}` } : { ...getAuthHeader() };
8090
+ if (orgId) h["Org-Id"] = orgId;
8091
+ return h;
8092
+ };
8093
+ var searchAgentActivity = async (params = {}) => {
8094
+ const {
8095
+ cursor = "",
8096
+ limit = 50,
8097
+ status = "",
8098
+ startTime = "",
8099
+ endTime = "",
8100
+ suborgRuns = false,
8101
+ apiKey,
8102
+ apiBaseUrl,
8103
+ orgId
8104
+ } = params;
8105
+ const payload = {
8106
+ workflow_id: "AGENT",
8107
+ cursor,
8108
+ limit,
8109
+ status,
8110
+ start_time: startTime,
8111
+ end_time: endTime,
8112
+ suborg_runs: suborgRuns
8113
+ };
8114
+ const response = await fetch(resolveUrl("/api/v1/workflows/search", apiBaseUrl), {
8115
+ method: "POST",
8116
+ credentials: "include",
8117
+ headers: {
8118
+ "Content-Type": "application/json",
8119
+ ...resolveHeaders(apiKey, orgId)
8120
+ },
8121
+ body: JSON.stringify(payload)
8122
+ });
8123
+ if (!response.ok) {
8124
+ throw new Error(`Failed to fetch agent activity: ${response.statusText}`);
8125
+ }
8126
+ const data = await response.json();
8127
+ return {
8128
+ success: data.success ?? false,
8129
+ runs: data.runs || [],
8130
+ cursor: data.cursor || ""
8131
+ };
8132
+ };
8133
+
8134
+ // AgentActivityList.tsx
8135
+ var import_jsx_runtime16 = require("react/jsx-runtime");
8136
+ var STATUS_CONFIG = {
8137
+ FINISHED: { icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react4.CheckCircle, { size: 16 }), color: "hsl(var(--severity-low, 142 71% 45%))", label: "Completed" },
8138
+ SUCCESS: { icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react4.CheckCircle, { size: 16 }), color: "hsl(var(--severity-low, 142 71% 45%))", label: "Completed" },
8139
+ FAILED: { icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react4.XCircle, { size: 16 }), color: "hsl(var(--severity-critical, 0 72% 55%))", label: "Failed" },
8140
+ ABORTED: { icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react4.XCircle, { size: 16 }), color: "hsl(var(--severity-critical, 0 72% 55%))", label: "Aborted" },
8141
+ EXECUTING: { icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react4.Loader2, { size: 16 }), color: "hsl(var(--severity-medium, 38 92% 50%))", label: "Running" },
8142
+ RUNNING: { icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react4.Loader2, { size: 16 }), color: "hsl(var(--severity-medium, 38 92% 50%))", label: "Running" },
8143
+ WAITING: { icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react4.Clock, { size: 16 }), color: "hsl(var(--severity-info, 217 91% 60%))", label: "Waiting" }
8144
+ };
8145
+ var getRunIcon = (run) => {
8146
+ const src = (run.execution_source || "").toLowerCase();
8147
+ const arg = (run.execution_argument || "").toLowerCase();
8148
+ if (src.includes("schedule") || src.includes("cron")) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react4.Clock, { size: 18 });
8149
+ if (src.includes("webhook") || src.includes("http")) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react4.Globe, { size: 18 });
8150
+ if (arg.includes("alert") || arg.includes("detect")) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react4.Activity, { size: 18 });
8151
+ if (arg.includes("report") || arg.includes("email")) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react4.FileText, { size: 18 });
8152
+ if (arg.includes("endpoint") || arg.includes("server")) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react4.Server, { size: 18 });
8153
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react4.Zap, { size: 18 });
8154
+ };
8155
+ var getRunIconColor = (run) => {
8156
+ const status = (run.status || "").toUpperCase();
8157
+ if (status === "FINISHED" || status === "SUCCESS") return "hsl(var(--severity-low, 142 71% 45%))";
8158
+ if (status === "FAILED" || status === "ABORTED") return "hsl(var(--severity-critical, 0 72% 55%))";
8159
+ if (status === "EXECUTING" || status === "RUNNING") return "hsl(var(--severity-medium, 38 92% 50%))";
8160
+ return "hsl(var(--primary, 24 100% 50%))";
8161
+ };
8162
+ var formatDuration = (run) => {
8163
+ if (run.started_at && run.completed_at) {
8164
+ const startSec = Number(run.started_at);
8165
+ const endSec = Number(run.completed_at);
8166
+ if (!isNaN(startSec) && !isNaN(endSec)) {
8167
+ const ms = (endSec - startSec) * 1e3;
8168
+ if (ms < 1e3) return `${Math.round(ms)}ms`;
8169
+ if (ms < 6e4) return `${(ms / 1e3).toFixed(1)}s`;
8170
+ return `${Math.floor(ms / 6e4)}m ${Math.floor(ms % 6e4 / 1e3)}s`;
8171
+ }
8172
+ }
8173
+ if (run.duration) return `${run.duration.toFixed(1)}s`;
8174
+ return "";
8175
+ };
8176
+ var getTimeAgo = (dateStr) => {
8177
+ try {
8178
+ const ts = isNaN(Number(dateStr)) ? new Date(dateStr).getTime() : Number(dateStr) * 1e3;
8179
+ if (isNaN(ts)) return dateStr;
8180
+ const diffSec = Math.max(0, Math.floor((Date.now() - ts) / 1e3));
8181
+ if (diffSec < 60) return `${diffSec}s ago`;
8182
+ if (diffSec < 3600) return `${Math.floor(diffSec / 60)}m ago`;
8183
+ if (diffSec < 86400) return `${Math.floor(diffSec / 3600)}h ago`;
8184
+ return `${Math.floor(diffSec / 86400)}d ago`;
8185
+ } catch {
8186
+ return dateStr;
8187
+ }
8188
+ };
8189
+ var getRunTitle = (run) => {
8190
+ if (run.workflow?.name) return run.workflow.name;
8191
+ if (run.execution_argument) {
8192
+ try {
8193
+ const parsed = JSON.parse(run.execution_argument);
8194
+ if (parsed.title) return parsed.title;
8195
+ if (parsed.action) return parsed.action;
8196
+ if (parsed.name) return parsed.name;
8197
+ } catch {
8198
+ const clean = run.execution_argument.replace(/[{}"]/g, "").trim();
8199
+ if (clean.length > 0 && clean.length < 80) return clean;
8200
+ }
8201
+ }
8202
+ return `Execution ${run.execution_id?.slice(0, 8) || "\u2014"}`;
8203
+ };
8204
+ var getRunSubtitle = (run) => {
8205
+ if (run.result) {
8206
+ try {
8207
+ const p = JSON.parse(run.result);
8208
+ if (p.output && typeof p.output === "string") {
8209
+ return p.output.length > 120 ? p.output.slice(0, 120) + "\u2026" : p.output;
7136
8210
  }
7137
- ) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { children: [
7138
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: {
7139
- display: "flex",
7140
- alignItems: "center",
7141
- gap: 2,
7142
- p: 2,
7143
- borderRadius: 2,
7144
- border: "1px solid hsl(var(--border))",
7145
- bgcolor: "hsl(var(--card))",
7146
- mb: 2
7147
- }, children: [
7148
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { flex: 1, minWidth: 0 }, children: [
7149
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.85rem", color: "hsl(var(--foreground))", fontWeight: 600, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: agentData?.original_input || actionInput || "Agent run" }),
7150
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Typography, { sx: { fontSize: "0.7rem", color: "hsl(var(--muted-foreground))" }, children: [
7151
- "Status: ",
7152
- execution?.status || agentData?.status || "\u2014",
7153
- " \xB7 ",
7154
- execution?.execution_id?.slice(0, 8) || ""
7155
- ] })
7156
- ] }),
7157
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.AvatarGroup, { max: 6, sx: { "& .MuiAvatar-root": { width: 28, height: 28, borderColor: "hsl(var(--border))" } }, children: chosenApps.map((app, i) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Tooltip, { title: app.name.replace(/_/g, " "), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7158
- import_material12.Avatar,
8211
+ if (p.original_input && typeof p.original_input === "string") {
8212
+ return p.original_input.length > 120 ? p.original_input.slice(0, 120) + "\u2026" : p.original_input;
8213
+ }
8214
+ if (p.message && typeof p.message === "string") return p.message;
8215
+ } catch {
8216
+ if (run.result.length < 120) return run.result;
8217
+ }
8218
+ }
8219
+ return run.execution_source || "Agent execution";
8220
+ };
8221
+ var AgentRunRow = ({ run, onClick, sx }) => {
8222
+ const statusKey = (run.status || "").toUpperCase();
8223
+ const cfg = STATUS_CONFIG[statusKey] || STATUS_CONFIG.WAITING;
8224
+ const iconColor = getRunIconColor(run);
8225
+ const duration = formatDuration(run);
8226
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
8227
+ import_material14.Box,
8228
+ {
8229
+ onClick,
8230
+ sx: [
8231
+ {
8232
+ borderRadius: 2,
8233
+ border: "1px solid hsl(var(--border))",
8234
+ bgcolor: "hsl(var(--card))",
8235
+ display: "flex",
8236
+ alignItems: "center",
8237
+ gap: 2,
8238
+ px: 2.5,
8239
+ py: 2,
8240
+ cursor: "pointer",
8241
+ transition: "background 0.15s ease, border-color 0.15s ease",
8242
+ "&:hover": {
8243
+ bgcolor: "hsla(var(--muted) / 0.5)",
8244
+ borderColor: "hsl(var(--muted-foreground) / 0.3)"
8245
+ }
8246
+ },
8247
+ ...Array.isArray(sx) ? sx : sx ? [sx] : []
8248
+ ],
8249
+ children: [
8250
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
8251
+ import_material14.Box,
7159
8252
  {
7160
- src: app.icon || void 0,
7161
- alt: app.name,
7162
- variant: "rounded",
7163
- onClick: () => navigate(`/apps/${encodeURIComponent(app.name.toLowerCase().replace(/\s+/g, "_"))}`),
7164
8253
  sx: {
7165
- bgcolor: "hsl(var(--muted))",
7166
- cursor: "pointer",
7167
- transition: "transform 0.15s ease, border-color 0.15s ease",
7168
- "&:hover": { transform: "scale(1.08)", borderColor: "hsl(var(--primary)) !important" }
7169
- }
8254
+ width: 40,
8255
+ height: 40,
8256
+ borderRadius: "50%",
8257
+ display: "flex",
8258
+ alignItems: "center",
8259
+ justifyContent: "center",
8260
+ bgcolor: `${iconColor}15`,
8261
+ color: iconColor,
8262
+ flexShrink: 0
8263
+ },
8264
+ children: getRunIcon(run)
7170
8265
  }
7171
- ) }, i)) })
7172
- ] }),
7173
- error && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: {
7174
- p: 1.5,
7175
- borderRadius: 1.5,
7176
- mb: 2,
7177
- border: "1px solid hsl(var(--destructive) / 0.4)",
7178
- bgcolor: "hsl(var(--destructive) / 0.08)",
7179
- color: "hsl(var(--destructive))",
7180
- fontSize: "0.85rem"
7181
- }, children: error }),
7182
- viewMode === "simple" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: {
7183
- borderRadius: 2,
7184
- border: "1px solid hsl(var(--border))",
7185
- bgcolor: "hsl(var(--card))",
7186
- p: 2.5,
7187
- display: "flex",
7188
- flexDirection: "column",
7189
- gap: 1.5
7190
- }, children: (() => {
7191
- const status = (execution?.status || agentData?.status || "EXECUTING").toUpperCase();
7192
- const decisionCount = (agentData?.decisions || []).length;
7193
- const isRunning = !["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(status);
7194
- const rawStartedAt = agentData?.started_at || execution?.started_at || 0;
7195
- const startedAtSec = rawStartedAt > 1e12 ? Math.floor(rawStartedAt / 1e3) : rawStartedAt;
7196
- const effectiveStart = startedAtSec || localRunStart || 0;
7197
- let durationSec = null;
7198
- if (isRunning && effectiveStart) {
7199
- durationSec = Math.max(0, nowTick - effectiveStart);
7200
- } else if (totalDuration && totalDuration > 0) {
7201
- durationSec = Math.round(totalDuration);
7202
- }
7203
- const pendingAsk = (agentData?.decisions || []).slice().reverse().find((d) => {
7204
- const isAsk = d.category === "ask" || d.action === "ask";
7205
- const st = (d.run_details?.status || "").toUpperCase();
7206
- return isAsk && (st === "RUNNING" || st === "WAITING");
7207
- });
7208
- const pendingQuestions = [];
7209
- if (pendingAsk) {
7210
- for (const f of pendingAsk.fields || []) {
7211
- if (f.key === "question" && f.value) {
7212
- pendingQuestions.push({ question: f.value, index: pendingQuestions.length + 1 });
8266
+ ),
8267
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_material14.Box, { sx: { flex: 1, minWidth: 0 }, children: [
8268
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_material14.Box, { sx: { display: "flex", alignItems: "center", gap: 1, mb: 0.25 }, children: [
8269
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
8270
+ import_material14.Typography,
8271
+ {
8272
+ sx: {
8273
+ fontSize: "0.9rem",
8274
+ fontWeight: 500,
8275
+ color: "hsl(var(--foreground))",
8276
+ overflow: "hidden",
8277
+ textOverflow: "ellipsis",
8278
+ whiteSpace: "nowrap"
8279
+ },
8280
+ children: getRunTitle(run)
8281
+ }
8282
+ ),
8283
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_material14.Box, { sx: { display: "flex", alignItems: "center", color: cfg.color, flexShrink: 0 }, children: cfg.icon })
8284
+ ] }),
8285
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
8286
+ import_material14.Typography,
8287
+ {
8288
+ sx: {
8289
+ fontSize: "0.78rem",
8290
+ color: "hsl(var(--muted-foreground))",
8291
+ overflow: "hidden",
8292
+ textOverflow: "ellipsis",
8293
+ whiteSpace: "nowrap"
8294
+ },
8295
+ children: getRunSubtitle(run)
7213
8296
  }
7214
- }
7215
- }
7216
- const pendingAnswered = pendingQuestions.every((q) => questionAnswers[q.question]?.value);
7217
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
7218
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { display: "flex", alignItems: "center", gap: 1, flexWrap: "wrap" }, children: [
7219
- isRunning ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.CircularProgress, { size: 16, sx: { color: "hsl(var(--primary))" } }) : status === "FINISHED" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_CheckCircle3.default, { sx: { fontSize: 18, color: "hsl(142 70% 45%)" } }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_Error.default, { sx: { fontSize: 18, color: "hsl(var(--destructive))" } }),
7220
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.9rem", fontWeight: 600, color: "hsl(var(--foreground))" }, children: isRunning ? "Agent is working\u2026" : status === "FINISHED" ? "Run finished" : `Run ${status.toLowerCase()}` }),
7221
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Typography, { sx: { fontSize: "0.75rem", color: "hsl(var(--muted-foreground))" }, children: [
7222
- decisionCount,
7223
- " step",
7224
- decisionCount === 1 ? "" : "s",
7225
- durationSec != null ? ` \xB7 ${durationSec}s` : ""
8297
+ ),
8298
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_material14.Box, { sx: { display: "flex", alignItems: "center", gap: 1, mt: 0.5 }, children: [
8299
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_material14.Typography, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.7 }, children: run.started_at ? getTimeAgo(run.started_at) : "\u2014" }),
8300
+ duration && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
8301
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_material14.Typography, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
8302
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_material14.Typography, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.7 }, children: duration })
7226
8303
  ] })
7227
- ] }),
7228
- finishAnswer ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: {
7229
- p: 2,
7230
- borderRadius: 1.5,
7231
- border: "1px solid hsl(var(--border))",
7232
- bgcolor: "hsl(var(--background))",
7233
- fontSize: "0.9rem",
7234
- color: "hsl(var(--foreground))",
7235
- "& > *:first-of-type": { mt: 0 },
7236
- "& > *:last-child": { mb: 0 },
7237
- "& p": { my: 1, lineHeight: 1.55 },
7238
- "& h1, & h2, & h3, & h4": { mt: 2, mb: 1, fontWeight: 600, lineHeight: 1.3 },
7239
- "& h1": { fontSize: "1.15rem" },
7240
- "& h2": { fontSize: "1.05rem" },
7241
- "& h3, & h4": { fontSize: "0.95rem" },
7242
- "& ul": { my: 1, pl: 3, listStyleType: "disc", listStylePosition: "outside" },
7243
- "& ol": { my: 1, pl: 3, listStyleType: "decimal", listStylePosition: "outside" },
7244
- "& ul ul": { listStyleType: "circle" },
7245
- "& ul ul ul": { listStyleType: "square" },
7246
- "& li": { my: 0.25, display: "list-item" },
7247
- "& li::marker": { color: "hsl(var(--muted-foreground))" },
7248
- "& a": { color: "hsl(var(--primary))", textDecoration: "underline" },
7249
- "& code": {
7250
- px: 0.5,
7251
- py: 0.125,
7252
- borderRadius: 0.5,
7253
- bgcolor: "hsl(var(--muted))",
7254
- fontFamily: '"JetBrains Mono", ui-monospace, monospace',
7255
- fontSize: "0.82em"
7256
- },
7257
- "& pre": {
7258
- p: 1.5,
7259
- my: 1,
7260
- borderRadius: 1,
7261
- bgcolor: "hsl(var(--muted))",
7262
- overflowX: "auto",
7263
- fontSize: "0.82rem"
7264
- },
7265
- "& pre code": { p: 0, bgcolor: "transparent" },
7266
- "& blockquote": {
7267
- borderLeft: "3px solid hsl(var(--border))",
7268
- pl: 1.5,
7269
- my: 1,
7270
- color: "hsl(var(--muted-foreground))"
7271
- },
7272
- "& table": { borderCollapse: "collapse", my: 1, fontSize: "0.85rem" },
7273
- "& th, & td": { border: "1px solid hsl(var(--border))", px: 1, py: 0.5 },
7274
- "& hr": { border: 0, borderTop: "1px solid hsl(var(--border))", my: 1.5 }
7275
- }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_markdown4.default, { remarkPlugins: [import_remark_gfm4.default, import_remark_breaks.default], children: normalizeMarkdown(finishAnswer) }) }) : pendingAsk && pendingQuestions.length > 0 ? (() => {
7276
- const trySimpleSubmit = () => {
7277
- if (agentRequestLoading) return;
7278
- if (!pendingAnswered) {
7279
- setSimpleSubmitAttempted(true);
7280
- return;
8304
+ ] })
8305
+ ] })
8306
+ ]
8307
+ }
8308
+ );
8309
+ };
8310
+ var STATUS_FILTERS = [
8311
+ { label: "All", value: "" },
8312
+ { label: "Completed", value: "FINISHED" },
8313
+ { label: "Running", value: "EXECUTING" },
8314
+ { label: "Failed", value: "ABORTED" }
8315
+ ];
8316
+ var AgentActivityList = ({
8317
+ apiKey,
8318
+ apiBaseUrl,
8319
+ orgId,
8320
+ onRunClick,
8321
+ showSearchBar = true,
8322
+ showStatusChips = true,
8323
+ limit = 50,
8324
+ emptyTitle = "No agent activity found",
8325
+ emptySubtitle = "The agent has not performed any actions yet",
8326
+ className,
8327
+ sx,
8328
+ toolbarSx,
8329
+ rowSx
8330
+ }) => {
8331
+ const [runs, setRuns] = (0, import_react13.useState)([]);
8332
+ const [cursor, setCursor] = (0, import_react13.useState)("");
8333
+ const [hasMore, setHasMore] = (0, import_react13.useState)(false);
8334
+ const [isLoading, setIsLoading] = (0, import_react13.useState)(false);
8335
+ const [error, setError] = (0, import_react13.useState)(null);
8336
+ const [statusFilter, setStatusFilter] = (0, import_react13.useState)("");
8337
+ const [searchQuery, setSearchQuery] = (0, import_react13.useState)("");
8338
+ const [debouncedQuery, setDebouncedQuery] = (0, import_react13.useState)("");
8339
+ const debounceRef = (0, import_react13.useRef)();
8340
+ const updateSearchQuery = (0, import_react13.useCallback)((q) => {
8341
+ setSearchQuery(q);
8342
+ if (debounceRef.current) clearTimeout(debounceRef.current);
8343
+ debounceRef.current = setTimeout(() => setDebouncedQuery(q), 350);
8344
+ }, []);
8345
+ (0, import_react13.useEffect)(() => () => {
8346
+ if (debounceRef.current) clearTimeout(debounceRef.current);
8347
+ }, []);
8348
+ const fetchRuns = (0, import_react13.useCallback)(
8349
+ async (append = false, cursorParam = "") => {
8350
+ setIsLoading(true);
8351
+ setError(null);
8352
+ try {
8353
+ const result = await searchAgentActivity({
8354
+ limit,
8355
+ status: statusFilter,
8356
+ cursor: cursorParam,
8357
+ apiKey,
8358
+ apiBaseUrl,
8359
+ orgId
8360
+ });
8361
+ if (result.success) {
8362
+ setRuns((prev) => append ? [...prev, ...result.runs] : result.runs);
8363
+ setCursor(result.cursor);
8364
+ setHasMore(!!result.cursor && result.runs.length > 0);
8365
+ } else {
8366
+ setError("Failed to fetch agent activity");
8367
+ }
8368
+ } catch (err) {
8369
+ setError(err instanceof Error ? err.message : "Failed to fetch agent activity");
8370
+ } finally {
8371
+ setIsLoading(false);
8372
+ }
8373
+ },
8374
+ [statusFilter, limit, apiKey, apiBaseUrl, orgId]
8375
+ );
8376
+ (0, import_react13.useEffect)(() => {
8377
+ fetchRuns(false, "");
8378
+ }, [statusFilter, apiKey, apiBaseUrl, orgId]);
8379
+ const loadMore = (0, import_react13.useCallback)(() => {
8380
+ if (cursor && !isLoading) fetchRuns(true, cursor);
8381
+ }, [cursor, isLoading, fetchRuns]);
8382
+ const filteredRuns = debouncedQuery ? runs.filter((r) => {
8383
+ const hay = [
8384
+ getRunTitle(r),
8385
+ getRunSubtitle(r),
8386
+ r.execution_id,
8387
+ r.execution_source,
8388
+ r.status
8389
+ ].filter(Boolean).join(" ").toLowerCase();
8390
+ return hay.includes(debouncedQuery.toLowerCase());
8391
+ }) : runs;
8392
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
8393
+ import_material14.Box,
8394
+ {
8395
+ className,
8396
+ sx: [{ display: "flex", flexDirection: "column", gap: 2 }, ...Array.isArray(sx) ? sx : sx ? [sx] : []],
8397
+ children: [
8398
+ (showSearchBar || showStatusChips) && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_material14.Box, { sx: [{ display: "flex", alignItems: "center", gap: 1.5, flexWrap: "wrap" }, ...Array.isArray(toolbarSx) ? toolbarSx : toolbarSx ? [toolbarSx] : []], children: [
8399
+ showSearchBar && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
8400
+ import_material14.TextField,
8401
+ {
8402
+ placeholder: "Search results...",
8403
+ size: "small",
8404
+ value: searchQuery,
8405
+ onChange: (e) => updateSearchQuery(e.target.value),
8406
+ slotProps: {
8407
+ input: {
8408
+ startAdornment: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_material14.InputAdornment, { position: "start", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_Search.default, { sx: { fontSize: 18, color: "hsl(var(--muted-foreground))" } }) })
8409
+ }
8410
+ },
8411
+ sx: {
8412
+ flex: 1,
8413
+ maxWidth: 280,
8414
+ minWidth: 160,
8415
+ "& .MuiOutlinedInput-root": {
8416
+ bgcolor: "hsl(var(--card))",
8417
+ borderRadius: 1.5,
8418
+ fontSize: "0.85rem",
8419
+ height: 36,
8420
+ "& fieldset": { borderColor: "hsl(var(--border))" },
8421
+ "&:hover fieldset": { borderColor: "hsl(var(--muted-foreground) / 0.3)" },
8422
+ "&.Mui-focused fieldset": { borderColor: "hsl(var(--primary))" }
8423
+ },
8424
+ "& .MuiInputBase-input": { color: "hsl(var(--foreground))" }
7281
8425
  }
7282
- if (pendingAsk.run_details?.id) {
7283
- submitQuestions(pendingAsk.run_details.id, questionAnswers);
8426
+ }
8427
+ ),
8428
+ showStatusChips && STATUS_FILTERS.map((f) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
8429
+ import_material14.Chip,
8430
+ {
8431
+ label: f.label,
8432
+ size: "small",
8433
+ variant: statusFilter === f.value ? "filled" : "outlined",
8434
+ onClick: () => setStatusFilter(f.value),
8435
+ sx: {
8436
+ fontSize: "0.75rem",
8437
+ height: 28,
8438
+ borderColor: statusFilter === f.value ? "hsl(var(--primary))" : "hsl(var(--border))",
8439
+ bgcolor: statusFilter === f.value ? "hsla(var(--primary) / 0.15)" : "transparent",
8440
+ color: statusFilter === f.value ? "hsl(var(--primary))" : "hsl(var(--muted-foreground))",
8441
+ "&:hover": { bgcolor: "hsl(var(--muted))" }
7284
8442
  }
7285
- };
7286
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: [
7287
- pendingQuestions.map((q, qi) => {
7288
- const value = questionAnswers[q.question]?.value || "";
7289
- const isMissing = simpleSubmitAttempted && !value;
7290
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { children: [
7291
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: { fontSize: "0.9rem", color: "hsl(var(--foreground))", mb: 1, "& p": { my: 0.5 } }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_markdown4.default, { remarkPlugins: [import_remark_gfm4.default, import_remark_breaks.default], children: normalizeMarkdown(q.question) }) }),
7292
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7293
- import_material12.TextField,
7294
- {
7295
- fullWidth: true,
7296
- multiline: true,
7297
- minRows: 2,
7298
- placeholder: "Your answer here\u2026",
7299
- value,
7300
- error: isMissing,
7301
- helperText: isMissing ? "Please answer this question" : void 0,
7302
- onChange: (e) => {
7303
- const v = e.target.value;
7304
- setQuestionAnswers((prev) => ({
7305
- ...prev,
7306
- [q.question]: { index: qi, value: v }
7307
- }));
7308
- },
7309
- onKeyDown: (e) => {
7310
- if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
7311
- e.preventDefault();
7312
- trySimpleSubmit();
7313
- }
7314
- },
7315
- size: "small",
7316
- sx: { "& .MuiOutlinedInput-root": { bgcolor: "hsl(var(--background))" } }
7317
- }
7318
- )
7319
- ] }, qi);
7320
- }),
7321
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
7322
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7323
- import_material12.Button,
7324
- {
7325
- variant: "contained",
7326
- size: "small",
7327
- disabled: agentRequestLoading,
7328
- onClick: trySimpleSubmit,
7329
- children: agentRequestLoading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.CircularProgress, { size: 16 }) : "Submit"
7330
- }
7331
- ),
7332
- pendingAsk.run_details?.id && getFormUrl(pendingAsk.run_details.id) && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Tooltip, { title: "Answer in the Form UI", placement: "right", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7333
- import_material12.IconButton,
7334
- {
7335
- size: "small",
7336
- onClick: () => {
7337
- const url = getFormUrl(pendingAsk.run_details.id);
7338
- if (url) window.open(url, "_blank", "noopener,noreferrer");
7339
- },
7340
- sx: { color: "hsl(var(--muted-foreground))", "&:hover": { color: "hsl(var(--primary))" } },
7341
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_OpenInNew2.default, { sx: { fontSize: 18 } })
7342
- }
7343
- ) })
7344
- ] })
7345
- ] });
7346
- })() : isRunning ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.85rem", color: "hsl(var(--muted-foreground))" }, children: "Waiting for the agent to produce the first step." }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.85rem", color: "hsl(var(--muted-foreground))" }, children: "No final answer was returned. Open Detailed to inspect each step." }),
7347
- !isRunning && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7348
- import_material12.Button,
8443
+ },
8444
+ f.value
8445
+ )),
8446
+ isLoading && runs.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_material14.CircularProgress, { size: 16, sx: { color: "hsl(var(--primary))", ml: 0.5 } })
8447
+ ] }),
8448
+ isLoading && runs.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_material14.Box, { sx: { display: "flex", justifyContent: "center", py: 8 }, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_material14.CircularProgress, { size: 28, sx: { color: "hsl(var(--primary))" } }) }) : error ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_material14.Box, { sx: { textAlign: "center", py: 6 }, children: [
8449
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react4.AlertCircle, { size: 28, style: { color: "hsl(var(--severity-critical, 0 72% 55%))", marginBottom: 8 } }),
8450
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
8451
+ import_material14.Typography,
8452
+ {
8453
+ sx: { color: "hsl(var(--severity-critical, 0 72% 55%))", fontSize: "0.9rem", mb: 1 },
8454
+ children: error
8455
+ }
8456
+ ),
8457
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
8458
+ import_material14.Button,
7349
8459
  {
7350
8460
  size: "small",
7351
- variant: "text",
7352
- onClick: () => setViewMode("detailed"),
7353
- sx: { color: "hsl(var(--primary))", textTransform: "none", px: 0 },
7354
- children: "View detailed timeline \u2192"
8461
+ onClick: () => fetchRuns(false, ""),
8462
+ sx: { color: "hsl(var(--primary))", textTransform: "none" },
8463
+ children: "Try again"
7355
8464
  }
7356
- ) })
7357
- ] });
7358
- })() }),
7359
- viewMode === "detailed" && (() => {
7360
- const detailedStatus = (execution?.status || agentData?.status || "EXECUTING").toUpperCase();
7361
- const detailedIsRunning = !["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(detailedStatus);
7362
- const detailedRunFinished = !detailedIsRunning;
7363
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: {
7364
- borderRadius: 2,
7365
- border: "1px solid hsl(var(--border))",
7366
- bgcolor: "hsl(var(--card))",
7367
- overflow: "hidden"
7368
- }, children: timeline.length === 0 || timeline.length === 1 && agentRequestLoading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { p: 4, textAlign: "center", color: "hsl(var(--muted-foreground))", fontSize: "0.85rem" }, children: [
7369
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.CircularProgress, { size: 20, sx: { mb: 1 } }),
7370
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.85rem" }, children: "Waiting for agent response\u2026" })
7371
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
7372
- timeline.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7373
- TimelineRow,
8465
+ )
8466
+ ] }) : filteredRuns.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_material14.Box, { sx: { display: "flex", flexDirection: "column", alignItems: "center", textAlign: "center", py: 8 }, children: [
8467
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
8468
+ import_lucide_react4.Activity,
8469
+ {
8470
+ size: 40,
8471
+ style: { color: "hsl(var(--muted-foreground))", marginBottom: 12 }
8472
+ }
8473
+ ),
8474
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_material14.Typography, { sx: { color: "hsl(var(--muted-foreground))", fontSize: "0.9rem" }, children: emptyTitle }),
8475
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
8476
+ import_material14.Typography,
8477
+ {
8478
+ sx: { color: "hsl(var(--muted-foreground))", fontSize: "0.8rem", mt: 0.5, opacity: 0.7 },
8479
+ children: emptySubtitle
8480
+ }
8481
+ )
8482
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_material14.Box, { sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: [
8483
+ filteredRuns.map((run, idx) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
8484
+ AgentRunRow,
7374
8485
  {
7375
- item,
7376
- index: i,
7377
- open: openIndexes.has(i),
7378
- onToggle: () => toggleOpen(i),
7379
- appsById,
7380
- totalDuration,
7381
- originalStartTime,
7382
- maxWidth: 260,
7383
- questionAnswers,
7384
- setQuestionAnswers,
7385
- onSubmitQuestions: submitQuestions,
7386
- onRerunAgent: rerunAgent,
7387
- onRerunDecision: rerunDecision,
7388
- agentRequestLoading,
7389
- getFormUrl,
7390
- runFinished: detailedRunFinished
8486
+ run,
8487
+ onClick: () => onRunClick?.(run),
8488
+ sx: rowSx
7391
8489
  },
7392
- i
8490
+ run.execution_id || idx
7393
8491
  )),
7394
- detailedRunFinished && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: {
7395
- borderTop: "1px solid hsl(var(--border))",
7396
- p: 2.5,
7397
- display: "flex",
7398
- flexDirection: "column",
7399
- gap: 1.5,
7400
- bgcolor: "hsl(var(--muted) / 0.2)"
7401
- }, children: [
7402
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { display: "flex", alignItems: "center", gap: 1, flexWrap: "wrap" }, children: [
7403
- detailedStatus === "FINISHED" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_CheckCircle3.default, { sx: { fontSize: 18, color: "hsl(142 70% 45%)" } }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_Error.default, { sx: { fontSize: 18, color: "hsl(var(--destructive))" } }),
7404
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.9rem", fontWeight: 600, color: "hsl(var(--foreground))" }, children: detailedStatus === "FINISHED" ? "Run finished" : `Run ${detailedStatus.toLowerCase()}` })
7405
- ] }),
7406
- finishAnswer && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: {
7407
- p: 2,
7408
- borderRadius: 1.5,
7409
- border: "1px solid hsl(var(--border))",
8492
+ hasMore && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_material14.Box, { sx: { display: "flex", justifyContent: "center", mt: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
8493
+ import_material14.Button,
8494
+ {
8495
+ size: "small",
8496
+ onClick: loadMore,
8497
+ disabled: isLoading,
8498
+ sx: { color: "hsl(var(--primary))", textTransform: "none", fontSize: "0.8rem" },
8499
+ children: [
8500
+ isLoading ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_material14.CircularProgress, { size: 14, sx: { mr: 1 } }) : null,
8501
+ "Load more"
8502
+ ]
8503
+ }
8504
+ ) })
8505
+ ] })
8506
+ ]
8507
+ }
8508
+ );
8509
+ };
8510
+ var AgentActivityList_default = AgentActivityList;
8511
+
8512
+ // AgentExecutionDrawer.tsx
8513
+ var import_material15 = require("@mui/material");
8514
+ var import_Close6 = __toESM(require("@mui/icons-material/Close"), 1);
8515
+ var import_OpenInNew3 = __toESM(require("@mui/icons-material/OpenInNew"), 1);
8516
+ var import_jsx_runtime17 = require("react/jsx-runtime");
8517
+ var AgentExecutionDrawer = ({
8518
+ open,
8519
+ onClose,
8520
+ run,
8521
+ width = 720,
8522
+ apiKey,
8523
+ apiBaseUrl,
8524
+ orgId,
8525
+ className,
8526
+ paperSx,
8527
+ headerSx,
8528
+ bodySx
8529
+ }) => {
8530
+ const statusKey = (run?.status || "").toUpperCase();
8531
+ const cfg = STATUS_CONFIG[statusKey] || STATUS_CONFIG.WAITING;
8532
+ const duration = run ? formatDuration(run) : "";
8533
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
8534
+ import_material15.Drawer,
8535
+ {
8536
+ anchor: "right",
8537
+ open,
8538
+ onClose,
8539
+ slotProps: {
8540
+ paper: {
8541
+ className,
8542
+ sx: [
8543
+ {
8544
+ width: { xs: "100%", sm: width },
8545
+ maxWidth: "100vw",
7410
8546
  bgcolor: "hsl(var(--background))",
7411
- fontSize: "0.9rem",
7412
8547
  color: "hsl(var(--foreground))",
7413
- "& > *:first-of-type": { mt: 0 },
7414
- "& > *:last-child": { mb: 0 },
7415
- "& p": { my: 1, lineHeight: 1.55 },
7416
- "& a": { color: "hsl(var(--primary))", textDecoration: "underline" },
7417
- "& code": {
7418
- px: 0.5,
7419
- py: 0.125,
7420
- borderRadius: 0.5,
7421
- bgcolor: "hsl(var(--muted))",
7422
- fontFamily: '"JetBrains Mono", ui-monospace, monospace',
7423
- fontSize: "0.82em"
7424
- },
7425
- "& pre": {
7426
- p: 1.5,
7427
- my: 1,
7428
- borderRadius: 1,
7429
- bgcolor: "hsl(var(--muted))",
7430
- overflowX: "auto",
7431
- fontSize: "0.82rem"
7432
- },
7433
- "& pre code": { p: 0, bgcolor: "transparent" }
7434
- }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_markdown4.default, { remarkPlugins: [import_remark_gfm4.default, import_remark_breaks.default], children: normalizeMarkdown(finishAnswer) }) })
7435
- ] })
7436
- ] }) });
7437
- })(),
7438
- finishDecisionId && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Box, { sx: { mt: 3, display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material12.Box, { sx: { width: "100%", maxWidth: 640 }, children: [
7439
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.Typography, { sx: { fontSize: "0.75rem", color: "hsl(var(--muted-foreground))", mb: 0.75, textAlign: "center" }, children: "Continue this agent run with more details" }),
7440
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
7441
- import_material12.Box,
7442
- {
7443
- component: "form",
7444
- onSubmit: (e) => {
7445
- e.preventDefault();
7446
- if (continuationText.trim()) {
7447
- submitQuestions(finishDecisionId, { continue: continuationText }, true);
7448
- }
7449
- },
7450
- sx: {
7451
- display: "flex",
7452
- alignItems: "flex-end",
7453
- gap: 1,
7454
- p: 1.25,
7455
- borderRadius: 999,
7456
- border: "1.5px solid hsl(var(--border))",
7457
- bgcolor: "hsl(var(--card))",
7458
- "&:focus-within": {
7459
- borderColor: "hsl(var(--primary))",
7460
- boxShadow: "0 0 0 3px hsla(var(--primary) / 0.12)"
7461
- }
8548
+ backgroundImage: "none",
8549
+ borderLeft: "1px solid hsl(var(--border))"
7462
8550
  },
8551
+ ...Array.isArray(paperSx) ? paperSx : paperSx ? [paperSx] : []
8552
+ ]
8553
+ }
8554
+ },
8555
+ children: [
8556
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
8557
+ import_material15.Box,
8558
+ {
8559
+ sx: [
8560
+ {
8561
+ display: "flex",
8562
+ alignItems: "center",
8563
+ gap: 1.5,
8564
+ px: 2.5,
8565
+ py: 1.75,
8566
+ borderBottom: "1px solid hsl(var(--border))",
8567
+ position: "sticky",
8568
+ top: 0,
8569
+ zIndex: 2,
8570
+ bgcolor: "hsl(var(--background))"
8571
+ },
8572
+ ...Array.isArray(headerSx) ? headerSx : headerSx ? [headerSx] : []
8573
+ ],
7463
8574
  children: [
7464
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7465
- import_material12.InputBase,
8575
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
8576
+ import_material15.Box,
7466
8577
  {
7467
- fullWidth: true,
7468
- multiline: true,
7469
- minRows: 1,
7470
- maxRows: 4,
7471
- placeholder: continuationPlaceholder,
7472
- value: continuationText,
7473
- onChange: (e) => setContinuationText(e.target.value),
7474
- onKeyDown: (e) => {
7475
- if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
7476
- e.preventDefault();
7477
- if (continuationText.trim() && !agentRequestLoading) {
7478
- submitQuestions(finishDecisionId, { continue: continuationText }, true);
7479
- }
7480
- }
8578
+ sx: {
8579
+ width: 36,
8580
+ height: 36,
8581
+ borderRadius: "50%",
8582
+ display: "flex",
8583
+ alignItems: "center",
8584
+ justifyContent: "center",
8585
+ background: "hsla(var(--primary) / 0.12)",
8586
+ color: "hsl(var(--primary))",
8587
+ flexShrink: 0
7481
8588
  },
7482
- disabled: agentRequestLoading,
7483
- sx: { fontSize: "0.9rem", color: "hsl(var(--foreground))", px: 2 }
8589
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AgentIcon_default, { size: 20 })
7484
8590
  }
7485
8591
  ),
7486
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7487
- import_material12.IconButton,
8592
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_material15.Box, { sx: { flex: 1, minWidth: 0 }, children: [
8593
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_material15.Box, { sx: { display: "flex", alignItems: "center", gap: 1, minWidth: 0 }, children: [
8594
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
8595
+ import_material15.Typography,
8596
+ {
8597
+ sx: {
8598
+ fontSize: "0.95rem",
8599
+ fontWeight: 600,
8600
+ color: "hsl(var(--foreground))",
8601
+ overflow: "hidden",
8602
+ textOverflow: "ellipsis",
8603
+ whiteSpace: "nowrap"
8604
+ },
8605
+ children: run ? getRunTitle(run) : "Agent execution"
8606
+ }
8607
+ ),
8608
+ run && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material15.Box, { sx: { display: "flex", alignItems: "center", color: cfg.color, flexShrink: 0 }, children: cfg.icon })
8609
+ ] }),
8610
+ run && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_material15.Box, { sx: { display: "flex", alignItems: "center", gap: 1, mt: 0.25 }, children: [
8611
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material15.Typography, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: cfg.label }),
8612
+ run.started_at && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
8613
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material15.Typography, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
8614
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material15.Typography, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: getTimeAgo(run.started_at) })
8615
+ ] }),
8616
+ duration && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
8617
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material15.Typography, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
8618
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material15.Typography, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: duration })
8619
+ ] })
8620
+ ] })
8621
+ ] }),
8622
+ run?.execution_id && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material15.Tooltip, { title: "Open in new tab", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
8623
+ import_material15.IconButton,
7488
8624
  {
7489
- type: "submit",
7490
- disabled: !continuationText.trim() || agentRequestLoading,
8625
+ component: "a",
8626
+ href: `/agents?execution_id=${encodeURIComponent(run.execution_id)}${run.authorization ? `&authorization=${encodeURIComponent(run.authorization)}` : ""}`,
8627
+ target: "_blank",
8628
+ rel: "noopener noreferrer",
8629
+ size: "small",
7491
8630
  sx: {
7492
- width: 36,
7493
- height: 36,
7494
- bgcolor: continuationText.trim() && !agentRequestLoading ? "hsl(var(--primary))" : "hsl(var(--muted))",
7495
- color: continuationText.trim() && !agentRequestLoading ? "hsl(var(--primary-foreground))" : "hsl(var(--muted-foreground))",
7496
- "&:hover": continuationText.trim() && !agentRequestLoading ? { filter: "brightness(1.1)", bgcolor: "hsl(var(--primary))" } : {}
8631
+ color: "hsl(var(--muted-foreground))",
8632
+ "&:hover": { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted))" }
7497
8633
  },
7498
- children: agentRequestLoading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material12.CircularProgress, { size: 16, sx: { color: "inherit" } }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_Send.default, { sx: { fontSize: 18 } })
8634
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_OpenInNew3.default, { fontSize: "small" })
7499
8635
  }
7500
- )
8636
+ ) }),
8637
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material15.Tooltip, { title: "Close", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
8638
+ import_material15.IconButton,
8639
+ {
8640
+ onClick: onClose,
8641
+ size: "small",
8642
+ sx: {
8643
+ color: "hsl(var(--muted-foreground))",
8644
+ "&:hover": { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted))" }
8645
+ },
8646
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_Close6.default, { fontSize: "small" })
8647
+ }
8648
+ ) })
7501
8649
  ]
7502
8650
  }
7503
- )
7504
- ] }) })
7505
- ] }),
7506
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7507
- AppSearchDrawer,
7508
- {
7509
- open: appSearchOpen,
7510
- onClose: () => setAppSearchOpen(false),
7511
- title: appPickerTitle,
7512
- subtitle: appPickerSubtitle,
7513
- onQuickSelect: (app) => {
7514
- const known = availableApps.find((a) => a.name?.toLowerCase() === app.name?.toLowerCase());
7515
- setChosenApps(
7516
- (prev) => prev.some((a) => a.name === app.name) ? prev : [...prev, { name: app.name, icon: app.icon || known?.icon, id: app.id || known?.id || void 0 }]
7517
- );
7518
- }
7519
- }
7520
- )
7521
- ] }) });
8651
+ ),
8652
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material15.Box, { sx: [{ flex: 1, overflowY: "auto", pt: 3 }, ...Array.isArray(bodySx) ? bodySx : bodySx ? [bodySx] : []], children: run ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
8653
+ AgentUI_default,
8654
+ {
8655
+ initialExecution: {
8656
+ execution_id: run.execution_id,
8657
+ status: run.status,
8658
+ started_at: run.started_at ? Number(run.started_at) : void 0,
8659
+ completed_at: run.completed_at ? Number(run.completed_at) : void 0,
8660
+ results: run.results,
8661
+ workflow: run.workflow,
8662
+ authorization: run.authorization
8663
+ },
8664
+ readUrlParams: false,
8665
+ autoLoadApps: false,
8666
+ hideHeroIcon: true,
8667
+ hideAppPicker: true,
8668
+ hideAttach: true,
8669
+ disableStartTab: true,
8670
+ compact: true,
8671
+ maxWidth: width - 32,
8672
+ apiKey,
8673
+ apiBaseUrl,
8674
+ orgId
8675
+ },
8676
+ run.execution_id
8677
+ ) : null })
8678
+ ]
8679
+ }
8680
+ );
7522
8681
  };
7523
- var AgentUI_default = AgentUI;
8682
+ var AgentExecutionDrawer_default = AgentExecutionDrawer;
7524
8683
 
7525
8684
  // useAppLookup.ts
7526
- var import_react12 = require("react");
8685
+ var import_react14 = require("react");
7527
8686
  var norm = (s) => s.toLowerCase().replace(/[\s_\-]+/g, "_");
7528
8687
  function useAppLookup(appName) {
7529
- const [loading, setLoading] = (0, import_react12.useState)(false);
7530
- const [info, setInfo] = (0, import_react12.useState)(null);
7531
- const [algoliaId, setAlgoliaId] = (0, import_react12.useState)(null);
8688
+ const [loading, setLoading] = (0, import_react14.useState)(false);
8689
+ const [info, setInfo] = (0, import_react14.useState)(null);
8690
+ const [algoliaId, setAlgoliaId] = (0, import_react14.useState)(null);
7532
8691
  const {
7533
8692
  authStates,
7534
8693
  authenticatedApps,
@@ -7537,7 +8696,7 @@ function useAppLookup(appName) {
7537
8696
  handleSaveAuth,
7538
8697
  refreshAuth
7539
8698
  } = useAppAuth();
7540
- (0, import_react12.useEffect)(() => {
8699
+ (0, import_react14.useEffect)(() => {
7541
8700
  if (!appName) {
7542
8701
  setInfo(null);
7543
8702
  setAlgoliaId(null);
@@ -7574,14 +8733,8 @@ function useAppLookup(appName) {
7574
8733
  let appsList = null;
7575
8734
  if (API_CONFIG.apiKey) {
7576
8735
  try {
7577
- const res = await fetch(getApiUrl("/api/v1/apps"), {
7578
- credentials: "include",
7579
- headers: { ...getAuthHeader() }
7580
- });
7581
- if (res.ok) {
7582
- const apps = await res.json();
7583
- if (Array.isArray(apps)) appsList = apps;
7584
- }
8736
+ const apps = await fetchAppsViaApiConfig();
8737
+ if (Array.isArray(apps)) appsList = apps;
7585
8738
  } catch {
7586
8739
  }
7587
8740
  }
@@ -7622,13 +8775,13 @@ function useAppLookup(appName) {
7622
8775
  setLoading(false);
7623
8776
  })();
7624
8777
  }, [appName]);
7625
- const matchingEntries = (0, import_react12.useMemo)(() => {
8778
+ const matchingEntries = (0, import_react14.useMemo)(() => {
7626
8779
  if (!appName) return [];
7627
8780
  return authenticatedApps.filter(
7628
8781
  (auth) => auth.app?.name && norm(auth.app.name) === norm(appName)
7629
8782
  );
7630
8783
  }, [appName, authenticatedApps]);
7631
- const image = (0, import_react12.useMemo)(() => {
8784
+ const image = (0, import_react14.useMemo)(() => {
7632
8785
  if (info?.image) return info.image;
7633
8786
  for (const entry of matchingEntries) {
7634
8787
  const img = entry.app?.large_image || entry.large_image;
@@ -7636,7 +8789,7 @@ function useAppLookup(appName) {
7636
8789
  }
7637
8790
  return "";
7638
8791
  }, [info, matchingEntries]);
7639
- const algoliaApp = (0, import_react12.useMemo)(() => {
8792
+ const algoliaApp = (0, import_react14.useMemo)(() => {
7640
8793
  if (!appName) return null;
7641
8794
  return {
7642
8795
  objectID: algoliaId || appName,
@@ -7669,6 +8822,9 @@ function useAppLookup(appName) {
7669
8822
  // Annotate the CommonJS export names for ESM import in node:
7670
8823
  0 && (module.exports = {
7671
8824
  API_CONFIG,
8825
+ AgentActivityList,
8826
+ AgentExecutionDrawer,
8827
+ AgentRunDrawer,
7672
8828
  AgentUI,
7673
8829
  AppAuthSection,
7674
8830
  AppDetailDrawer,
@@ -7683,6 +8839,7 @@ function useAppLookup(appName) {
7683
8839
  getApiUrl,
7684
8840
  getAuthHeader,
7685
8841
  refreshAllIntegrationStatus,
8842
+ searchAgentActivity,
7686
8843
  setToastImpl,
7687
8844
  toast,
7688
8845
  useAppAuth,