@shuffleio/shuffle-mcps 0.0.7 → 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.js CHANGED
@@ -1,3 +1,6 @@
1
+ // index.ts
2
+ import "./shuffle-mcp-24XBNRGE.css";
3
+
1
4
  // ShuffleMCP.tsx
2
5
  import React, { useState as useState8, useEffect as useEffect6, useRef as useRef5, useCallback as useCallback7, useMemo as useMemo4, useImperativeHandle } from "react";
3
6
  import { algoliasearch } from "algoliasearch";
@@ -400,6 +403,50 @@ var fetchAuthenticatedApps = (crossOrgId) => {
400
403
  return promise;
401
404
  };
402
405
 
406
+ // appsCache.ts
407
+ var TTL_MS2 = 3e4;
408
+ var cache2 = /* @__PURE__ */ new Map();
409
+ var cacheKey2 = (o) => `${o.baseUrl}|${o.path || "/api/v1/apps"}|${o.apiKey || ""}|${o.orgId || ""}`;
410
+ var doFetch2 = async (o) => {
411
+ const headers = {};
412
+ if (o.apiKey) headers["Authorization"] = `Bearer ${o.apiKey}`;
413
+ if (o.orgId) headers["Org-Id"] = o.orgId;
414
+ const response = await fetch(`${o.baseUrl}${o.path || "/api/v1/apps"}`, {
415
+ credentials: "include",
416
+ headers
417
+ });
418
+ if (!response.ok) return [];
419
+ const data = await response.json();
420
+ if (Array.isArray(data)) return data;
421
+ return Array.isArray(data?.data) ? data.data : [];
422
+ };
423
+ var fetchApps = (opts) => {
424
+ const key = cacheKey2(opts);
425
+ const entry = cache2.get(key) || {};
426
+ if (entry.data && entry.fetchedAt && Date.now() - entry.fetchedAt < TTL_MS2) {
427
+ return Promise.resolve(entry.data);
428
+ }
429
+ if (entry.promise) return entry.promise;
430
+ const promise = doFetch2(opts).then((data) => {
431
+ cache2.set(key, { data, fetchedAt: Date.now() });
432
+ return data;
433
+ }).catch((err) => {
434
+ cache2.delete(key);
435
+ throw err;
436
+ });
437
+ cache2.set(key, { ...entry, promise });
438
+ return promise;
439
+ };
440
+ var fetchAppsViaApiConfig = () => {
441
+ const headers = getAuthHeader();
442
+ const orgId = headers["Org-Id"] || null;
443
+ return fetchApps({
444
+ baseUrl: API_CONFIG.baseUrl,
445
+ apiKey: API_CONFIG.apiKey,
446
+ orgId
447
+ });
448
+ };
449
+
403
450
  // auth-utils.ts
404
451
  function deduplicateAuthApps(apps) {
405
452
  const appMap = /* @__PURE__ */ new Map();
@@ -568,35 +615,25 @@ var IntegrationStatus = ({ collapsed, filterApps, onAddClick, iconSize = 26, onD
568
615
  }
569
616
  if (dedupedIntegrations.length < 10) {
570
617
  try {
571
- const controller = new AbortController();
572
- const timeout = setTimeout(() => controller.abort(), 5e3);
573
- const appsResponse = await fetch(getApiUrl("/api/v1/apps"), {
574
- credentials: "include",
575
- headers: { ...getAuthHeader() },
576
- signal: controller.signal
577
- });
578
- clearTimeout(timeout);
579
- if (appsResponse.ok) {
580
- const appsData = await appsResponse.json();
581
- if (Array.isArray(appsData)) {
582
- const activatedApps = appsData.filter((app) => app.activated);
583
- const slotsRemaining = 10 - dedupedIntegrations.length;
584
- let added = 0;
585
- for (const app of activatedApps) {
586
- if (added >= slotsRemaining) break;
587
- if (!authNameSet.has((app.name || "").toLowerCase())) {
588
- authNameSet.add((app.name || "").toLowerCase());
589
- dedupedIntegrations.push({
590
- id: app.id || app.name,
591
- name: app.name,
592
- icon: app.large_image || "",
593
- category: app.categories?.[0] || "Integration",
594
- hasValidAuth: false,
595
- authInstances: [],
596
- isActiveOnly: true
597
- });
598
- added++;
599
- }
618
+ const appsData = await fetchAppsViaApiConfig();
619
+ if (Array.isArray(appsData)) {
620
+ const activatedApps = appsData.filter((app) => app.activated);
621
+ const slotsRemaining = 10 - dedupedIntegrations.length;
622
+ let added = 0;
623
+ for (const app of activatedApps) {
624
+ if (added >= slotsRemaining) break;
625
+ if (!authNameSet.has((app.name || "").toLowerCase())) {
626
+ authNameSet.add((app.name || "").toLowerCase());
627
+ dedupedIntegrations.push({
628
+ id: app.id || app.name,
629
+ name: app.name,
630
+ icon: app.large_image || "",
631
+ category: app.categories?.[0] || "Integration",
632
+ hasValidAuth: false,
633
+ authInstances: [],
634
+ isActiveOnly: true
635
+ });
636
+ added++;
600
637
  }
601
638
  }
602
639
  }
@@ -1221,8 +1258,8 @@ function AppTitleHeader({
1221
1258
  py: 0.5,
1222
1259
  minHeight: 0,
1223
1260
  flexShrink: 0,
1224
- bgcolor: "#FF6600",
1225
- "&:hover": { bgcolor: "#e55c00" }
1261
+ bgcolor: "hsl(var(--primary))",
1262
+ "&:hover": { bgcolor: "hsl(var(--primary) / 0.85)" }
1226
1263
  },
1227
1264
  children: "+ Add"
1228
1265
  }
@@ -1243,7 +1280,7 @@ function AppTitleHeader({
1243
1280
  py: 0.5,
1244
1281
  minHeight: 0,
1245
1282
  flexShrink: 0,
1246
- ...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" } }
1283
+ ...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)" } }
1247
1284
  },
1248
1285
  children: activateLoading ? "\u2026" : isActivated ? "Deactivate" : "Activate"
1249
1286
  }
@@ -1335,7 +1372,10 @@ var AppAuthCard = ({
1335
1372
  apiAuthEntries,
1336
1373
  onSelectAuth,
1337
1374
  onRefreshAuth,
1338
- disableUrlPrefill
1375
+ disableUrlPrefill,
1376
+ hideHeader,
1377
+ hideStatusChips,
1378
+ hideDocsLink
1339
1379
  }) => {
1340
1380
  const getBestDefaultAuth = (entries) => {
1341
1381
  if (entries.length === 0) return ADD_NEW_AUTH;
@@ -1555,6 +1595,22 @@ var AppAuthCard = ({
1555
1595
  setLocalCredentials((prev) => ({ ...urlDefaults, ...prev }));
1556
1596
  }
1557
1597
  }, [auth?.parameters, disableUrlPrefill]);
1598
+ useEffect3(() => {
1599
+ const incoming = authState.credentials || {};
1600
+ setLocalCredentials((prev) => {
1601
+ let changed = false;
1602
+ const next = { ...prev };
1603
+ for (const [k, v] of Object.entries(incoming)) {
1604
+ const lk = k.toLowerCase();
1605
+ const isUrlish = lk.includes("url") || lk.includes("endpoint") || lk.includes("host");
1606
+ if (isUrlish && typeof v === "string" && v !== prev[k]) {
1607
+ next[k] = v;
1608
+ changed = true;
1609
+ }
1610
+ }
1611
+ return changed ? next : prev;
1612
+ });
1613
+ }, [authState.credentials]);
1558
1614
  const [docsOpen, setDocsOpen] = useState4(false);
1559
1615
  const [docsContent, setDocsContent] = useState4("");
1560
1616
  const [docsLoading, setDocsLoading] = useState4(false);
@@ -1628,10 +1684,9 @@ var AppAuthCard = ({
1628
1684
  const renderOAuth2Fields = () => {
1629
1685
  if (!auth || !isOAuth2) return null;
1630
1686
  const availableScopes = auth.scope || [];
1631
- const isCloudOrDev = isDevEnvironment() || isCloudDomain();
1632
1687
  const hasManualCredentials = !!localCredentials["client_id"]?.trim() && !!localCredentials["client_secret"]?.trim();
1633
1688
  return /* @__PURE__ */ jsxs3(Box3, { sx: { display: "flex", flexDirection: "column", gap: 3 }, children: [
1634
- isCloudOrDev && /* @__PURE__ */ jsxs3(Fragment2, { children: [
1689
+ /* @__PURE__ */ jsxs3(Fragment2, { children: [
1635
1690
  /* @__PURE__ */ jsx4(Collapse, { in: !hasManualCredentials, children: /* @__PURE__ */ jsxs3(Box3, { sx: { display: "flex", flexDirection: "column", gap: 3 }, children: [
1636
1691
  /* @__PURE__ */ jsxs3(
1637
1692
  Button2,
@@ -1818,7 +1873,7 @@ var AppAuthCard = ({
1818
1873
  {
1819
1874
  label: /* @__PURE__ */ jsxs3(Box3, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
1820
1875
  param.name,
1821
- param.required && /* @__PURE__ */ jsx4(Typography3, { component: "span", sx: { color: "#ef4444", fontSize: "0.8rem" }, children: "*" })
1876
+ param.required && /* @__PURE__ */ jsx4(Typography3, { component: "span", sx: { color: "hsl(var(--destructive))", fontSize: "0.8rem" }, children: "*" })
1822
1877
  ] }),
1823
1878
  type: param.name.toLowerCase().includes("password") || param.name.toLowerCase().includes("secret") || param.name.toLowerCase().includes("key") ? "password" : "text",
1824
1879
  placeholder: param.example || `Enter ${param.name}`,
@@ -1832,13 +1887,13 @@ var AppAuthCard = ({
1832
1887
  "& .MuiOutlinedInput-root": {
1833
1888
  backgroundColor: "hsl(var(--muted))",
1834
1889
  borderRadius: 2,
1835
- "& fieldset": { borderColor: fieldErrors[fieldKey] ? "#ef4444" : "hsl(var(--border))" },
1836
- "&:hover fieldset": { borderColor: fieldErrors[fieldKey] ? "#ef4444" : "hsl(var(--border))" },
1837
- "&.Mui-focused fieldset": { borderColor: fieldErrors[fieldKey] ? "#ef4444" : "hsl(var(--primary))" }
1890
+ "& fieldset": { borderColor: fieldErrors[fieldKey] ? "hsl(var(--destructive))" : "hsl(var(--border))" },
1891
+ "&:hover fieldset": { borderColor: fieldErrors[fieldKey] ? "hsl(var(--destructive))" : "hsl(var(--border))" },
1892
+ "&.Mui-focused fieldset": { borderColor: fieldErrors[fieldKey] ? "hsl(var(--destructive))" : "hsl(var(--primary))" }
1838
1893
  },
1839
1894
  "& .MuiInputBase-input": { color: "hsl(var(--foreground))" },
1840
1895
  "& .MuiInputLabel-root": { color: "hsl(var(--muted-foreground))" },
1841
- "& .MuiFormHelperText-root": { color: fieldErrors[fieldKey] ? "#ef4444" : "hsl(var(--muted-foreground))" }
1896
+ "& .MuiFormHelperText-root": { color: fieldErrors[fieldKey] ? "hsl(var(--destructive))" : "hsl(var(--muted-foreground))" }
1842
1897
  }
1843
1898
  },
1844
1899
  fieldKey
@@ -1912,7 +1967,7 @@ var AppAuthCard = ({
1912
1967
  maxWidth: "100%"
1913
1968
  },
1914
1969
  children: [
1915
- /* @__PURE__ */ jsxs3(
1970
+ !hideHeader && /* @__PURE__ */ jsxs3(
1916
1971
  CardContent,
1917
1972
  {
1918
1973
  onClick: onToggle,
@@ -2001,7 +2056,7 @@ var AppAuthCard = ({
2001
2056
  width: { xs: "100%", sm: "auto" },
2002
2057
  justifyContent: { xs: "flex-start", sm: "flex-end" }
2003
2058
  }, children: [
2004
- isNoAuthRequired(auth) ? /* @__PURE__ */ jsx4(
2059
+ !hideStatusChips && (isNoAuthRequired(auth) ? /* @__PURE__ */ jsx4(
2005
2060
  Chip2,
2006
2061
  {
2007
2062
  label: "Auth not required",
@@ -2052,8 +2107,8 @@ var AppAuthCard = ({
2052
2107
  )
2053
2108
  }
2054
2109
  )
2055
- ] }),
2056
- /* @__PURE__ */ jsx4(Tooltip2, { title: "View documentation", children: /* @__PURE__ */ jsx4(
2110
+ ] })),
2111
+ !hideDocsLink && /* @__PURE__ */ jsx4(Tooltip2, { title: "View documentation", children: /* @__PURE__ */ jsx4(
2057
2112
  IconButton2,
2058
2113
  {
2059
2114
  size: "small",
@@ -2333,8 +2388,8 @@ var AppAuthCard = ({
2333
2388
  width: 8,
2334
2389
  height: 8,
2335
2390
  borderRadius: "50%",
2336
- backgroundColor: localTestStatus === "success" ? "#22c55e" : localTestStatus === "pending_validation" ? "#f59e0b" : localTestStatus === "error" ? "#ef4444" : "#9ca3af",
2337
- 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)"
2391
+ backgroundColor: localTestStatus === "success" ? "hsl(var(--severity-low))" : localTestStatus === "pending_validation" ? "hsl(var(--severity-medium))" : localTestStatus === "error" ? "hsl(var(--destructive))" : "hsl(var(--muted-foreground))",
2392
+ 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)"
2338
2393
  } }),
2339
2394
  /* @__PURE__ */ jsx4(Typography3, { sx: {
2340
2395
  color: "hsl(var(--muted-foreground))",
@@ -2365,11 +2420,11 @@ var AppAuthCard = ({
2365
2420
  display: "flex",
2366
2421
  alignItems: "center",
2367
2422
  justifyContent: "center",
2368
- 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)",
2369
- 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)"}`,
2423
+ 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)",
2424
+ 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)"}`,
2370
2425
  flexShrink: 0
2371
2426
  }, children: /* @__PURE__ */ jsx4(CheckCircleIcon2, { sx: {
2372
- color: localTestStatus === "success" ? "#22c55e" : localTestStatus === "pending_validation" ? "#f59e0b" : localTestStatus === "error" ? "#ef4444" : isTested ? "#22c55e" : isConfigured ? "#f59e0b" : "#9ca3af",
2427
+ 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))",
2373
2428
  fontSize: 20
2374
2429
  } }) }),
2375
2430
  /* @__PURE__ */ jsxs3(Box3, { sx: { minWidth: 0, flex: 1 }, children: [
@@ -2463,7 +2518,7 @@ var AppAuthCard = ({
2463
2518
  ) })
2464
2519
  ] }) }),
2465
2520
  /* @__PURE__ */ jsx4(Typography3, { sx: {
2466
- color: localTestStatus === "success" ? "#22c55e" : localTestStatus === "pending_validation" ? "#f59e0b" : localTestStatus === "error" ? "#ef4444" : isTested ? "#22c55e" : isConfigured ? "#f59e0b" : "hsl(var(--muted-foreground))",
2521
+ 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))",
2467
2522
  fontSize: "0.75rem",
2468
2523
  mt: 0.25,
2469
2524
  fontWeight: localTestStatus !== "untested" || isTested || isConfigured ? 500 : 400
@@ -2483,9 +2538,9 @@ var AppAuthCard = ({
2483
2538
  disabled: authState.status === "testing",
2484
2539
  startIcon: authState.status === "testing" ? /* @__PURE__ */ jsx4(CircularProgress2, { size: 16, sx: { color: "inherit" } }) : /* @__PURE__ */ jsx4(CheckCircleIcon2, { sx: { fontSize: 18 } }),
2485
2540
  sx: {
2486
- borderColor: authState.status === "testing" ? "transparent" : "rgba(255, 102, 0, 0.5)",
2541
+ borderColor: authState.status === "testing" ? "transparent" : "hsl(var(--primary) / 0.5)",
2487
2542
  color: authState.status === "testing" ? "hsl(var(--foreground))" : "hsl(var(--primary))",
2488
- 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",
2543
+ 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",
2489
2544
  backgroundSize: authState.status === "testing" ? "200% 100%" : "auto",
2490
2545
  animation: authState.status === "testing" ? "shimmer 1.5s infinite linear" : "none",
2491
2546
  fontWeight: 600,
@@ -2503,7 +2558,7 @@ var AppAuthCard = ({
2503
2558
  },
2504
2559
  "&:hover": {
2505
2560
  borderColor: "hsl(var(--primary))",
2506
- backgroundColor: authState.status === "testing" ? void 0 : "rgba(255, 102, 0, 0.08)"
2561
+ backgroundColor: authState.status === "testing" ? void 0 : "hsl(var(--primary) / 0.08)"
2507
2562
  },
2508
2563
  "&.Mui-disabled": {
2509
2564
  color: authState.status === "testing" ? "hsl(var(--foreground))" : "hsl(var(--muted-foreground))",
@@ -2522,11 +2577,11 @@ var AppAuthCard = ({
2522
2577
  {
2523
2578
  severity: "error",
2524
2579
  sx: {
2525
- backgroundColor: "rgba(239, 68, 68, 0.1)",
2526
- color: "#ef4444",
2527
- border: "1px solid rgba(239, 68, 68, 0.2)",
2580
+ backgroundColor: "hsl(var(--destructive) / 0.1)",
2581
+ color: "hsl(var(--destructive))",
2582
+ border: "1px solid hsl(var(--destructive) / 0.2)",
2528
2583
  borderRadius: 2,
2529
- "& .MuiAlert-icon": { color: "#ef4444" }
2584
+ "& .MuiAlert-icon": { color: "hsl(var(--destructive))" }
2530
2585
  },
2531
2586
  children: /* @__PURE__ */ jsxs3(Box3, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 2, width: "100%" }, children: [
2532
2587
  /* @__PURE__ */ jsx4(Typography3, { sx: { fontSize: "0.875rem", flex: 1 }, children: localTestMessages.errorMessage }),
@@ -2539,16 +2594,16 @@ var AppAuthCard = ({
2539
2594
  target: "_blank",
2540
2595
  rel: "noopener noreferrer",
2541
2596
  sx: {
2542
- borderColor: "rgba(239, 68, 68, 0.5)",
2543
- color: "#ef4444",
2597
+ borderColor: "hsl(var(--destructive) / 0.5)",
2598
+ color: "hsl(var(--destructive))",
2544
2599
  textTransform: "none",
2545
2600
  fontSize: "0.75rem",
2546
2601
  py: 0.5,
2547
2602
  px: 1.5,
2548
2603
  flexShrink: 0,
2549
2604
  "&:hover": {
2550
- borderColor: "#ef4444",
2551
- backgroundColor: "rgba(239, 68, 68, 0.1)"
2605
+ borderColor: "hsl(var(--destructive))",
2606
+ backgroundColor: "hsl(var(--destructive) / 0.1)"
2552
2607
  }
2553
2608
  },
2554
2609
  children: "View Execution"
@@ -2565,12 +2620,12 @@ var AppAuthCard = ({
2565
2620
  {
2566
2621
  severity: localTestMessages.warningMessage ? "warning" : "success",
2567
2622
  sx: {
2568
- backgroundColor: localTestMessages.warningMessage ? "rgba(245, 158, 11, 0.1)" : "rgba(34, 197, 94, 0.1)",
2569
- color: localTestMessages.warningMessage ? "#f59e0b" : "#22c55e",
2570
- border: localTestMessages.warningMessage ? "1px solid rgba(245, 158, 11, 0.2)" : "1px solid rgba(34, 197, 94, 0.2)",
2623
+ backgroundColor: localTestMessages.warningMessage ? "hsl(var(--severity-medium) / 0.1)" : "hsl(var(--severity-low) / 0.1)",
2624
+ color: localTestMessages.warningMessage ? "hsl(var(--severity-medium))" : "hsl(var(--severity-low))",
2625
+ border: localTestMessages.warningMessage ? "1px solid hsl(var(--severity-medium) / 0.2)" : "1px solid hsl(var(--severity-low) / 0.2)",
2571
2626
  borderRadius: 2,
2572
2627
  "& .MuiAlert-icon": {
2573
- color: localTestMessages.warningMessage ? "#f59e0b" : "#22c55e"
2628
+ color: localTestMessages.warningMessage ? "hsl(var(--severity-medium))" : "hsl(var(--severity-low))"
2574
2629
  }
2575
2630
  },
2576
2631
  children: localTestMessages.warningMessage ? /* @__PURE__ */ jsxs3(Box3, { children: [
@@ -2587,11 +2642,11 @@ var AppAuthCard = ({
2587
2642
  {
2588
2643
  severity: "warning",
2589
2644
  sx: {
2590
- backgroundColor: "rgba(245, 158, 11, 0.1)",
2591
- color: "#f59e0b",
2592
- border: "1px solid rgba(245, 158, 11, 0.2)",
2645
+ backgroundColor: "hsl(var(--severity-medium) / 0.1)",
2646
+ color: "hsl(var(--severity-medium))",
2647
+ border: "1px solid hsl(var(--severity-medium) / 0.2)",
2593
2648
  borderRadius: 2,
2594
- "& .MuiAlert-icon": { color: "#f59e0b" }
2649
+ "& .MuiAlert-icon": { color: "hsl(var(--severity-medium))" }
2595
2650
  },
2596
2651
  children: /* @__PURE__ */ jsxs3(Box3, { children: [
2597
2652
  /* @__PURE__ */ jsx4(Typography3, { sx: { fontWeight: 600, mb: 0.5 }, children: "Test passed (Status 200), but not marked as validated" }),
@@ -2602,7 +2657,7 @@ var AppAuthCard = ({
2602
2657
  href: `${API_CONFIG.baseUrl}/admin?tab=app_auth`,
2603
2658
  target: "_blank",
2604
2659
  sx: {
2605
- color: "#f59e0b",
2660
+ color: "hsl(var(--severity-medium))",
2606
2661
  fontWeight: 500,
2607
2662
  fontSize: "0.85rem",
2608
2663
  textDecoration: "underline",
@@ -2627,12 +2682,12 @@ var AppAuthCard = ({
2627
2682
  {
2628
2683
  severity: "warning",
2629
2684
  sx: {
2630
- backgroundColor: "rgba(245, 158, 11, 0.1)",
2631
- color: "#f59e0b",
2632
- border: "1px solid rgba(245, 158, 11, 0.2)",
2685
+ backgroundColor: "hsl(var(--severity-medium) / 0.1)",
2686
+ color: "hsl(var(--severity-medium))",
2687
+ border: "1px solid hsl(var(--severity-medium) / 0.2)",
2633
2688
  borderRadius: 2,
2634
2689
  mb: 2,
2635
- "& .MuiAlert-icon": { color: "#f59e0b" }
2690
+ "& .MuiAlert-icon": { color: "hsl(var(--severity-medium))" }
2636
2691
  },
2637
2692
  children: /* @__PURE__ */ jsx4(Typography3, { 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." })
2638
2693
  }
@@ -2646,9 +2701,9 @@ var AppAuthCard = ({
2646
2701
  {
2647
2702
  severity: "error",
2648
2703
  sx: {
2649
- backgroundColor: "rgba(239, 68, 68, 0.1)",
2650
- color: "#ef4444",
2651
- border: "1px solid rgba(239, 68, 68, 0.3)",
2704
+ backgroundColor: "hsl(var(--destructive) / 0.1)",
2705
+ color: "hsl(var(--destructive))",
2706
+ border: "1px solid hsl(var(--destructive) / 0.3)",
2652
2707
  borderRadius: 2
2653
2708
  },
2654
2709
  children: error
@@ -2658,11 +2713,11 @@ var AppAuthCard = ({
2658
2713
  {
2659
2714
  severity: "info",
2660
2715
  sx: {
2661
- backgroundColor: "rgba(59, 130, 246, 0.1)",
2662
- color: "#3b82f6",
2663
- border: "1px solid rgba(59, 130, 246, 0.2)",
2716
+ backgroundColor: "hsl(var(--severity-info) / 0.1)",
2717
+ color: "hsl(var(--severity-info))",
2718
+ border: "1px solid hsl(var(--severity-info) / 0.2)",
2664
2719
  borderRadius: 2,
2665
- "& .MuiAlert-icon": { color: "#3b82f6" }
2720
+ "& .MuiAlert-icon": { color: "hsl(var(--severity-info))" }
2666
2721
  },
2667
2722
  children: /* @__PURE__ */ jsxs3(Box3, { children: [
2668
2723
  /* @__PURE__ */ jsx4(Typography3, { sx: { fontWeight: 600, mb: 0.5 }, children: "No authentication required" }),
@@ -2677,9 +2732,9 @@ var AppAuthCard = ({
2677
2732
  {
2678
2733
  severity: "error",
2679
2734
  sx: {
2680
- backgroundColor: "rgba(239, 68, 68, 0.1)",
2681
- color: "#ef4444",
2682
- border: "1px solid rgba(239, 68, 68, 0.3)",
2735
+ backgroundColor: "hsl(var(--destructive) / 0.1)",
2736
+ color: "hsl(var(--destructive))",
2737
+ border: "1px solid hsl(var(--destructive) / 0.3)",
2683
2738
  borderRadius: 2
2684
2739
  },
2685
2740
  children: /* @__PURE__ */ jsxs3(Box3, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 2, width: "100%" }, children: [
@@ -2693,16 +2748,16 @@ var AppAuthCard = ({
2693
2748
  target: "_blank",
2694
2749
  rel: "noopener noreferrer",
2695
2750
  sx: {
2696
- borderColor: "rgba(239, 68, 68, 0.5)",
2697
- color: "#ef4444",
2751
+ borderColor: "hsl(var(--destructive) / 0.5)",
2752
+ color: "hsl(var(--destructive))",
2698
2753
  textTransform: "none",
2699
2754
  fontSize: "0.75rem",
2700
2755
  py: 0.5,
2701
2756
  px: 1.5,
2702
2757
  flexShrink: 0,
2703
2758
  "&:hover": {
2704
- borderColor: "#ef4444",
2705
- backgroundColor: "rgba(239, 68, 68, 0.1)"
2759
+ borderColor: "hsl(var(--destructive))",
2760
+ backgroundColor: "hsl(var(--destructive) / 0.1)"
2706
2761
  }
2707
2762
  },
2708
2763
  children: "View Execution"
@@ -2716,9 +2771,9 @@ var AppAuthCard = ({
2716
2771
  {
2717
2772
  severity: "error",
2718
2773
  sx: {
2719
- backgroundColor: "rgba(239, 68, 68, 0.1)",
2720
- color: "#ef4444",
2721
- border: "1px solid rgba(239, 68, 68, 0.3)",
2774
+ backgroundColor: "hsl(var(--destructive) / 0.1)",
2775
+ color: "hsl(var(--destructive))",
2776
+ border: "1px solid hsl(var(--destructive) / 0.3)",
2722
2777
  borderRadius: 2
2723
2778
  },
2724
2779
  children: "Failed to save authentication. Please try again."
@@ -3160,9 +3215,10 @@ var AppMcpChat = ({ appName, appIcon, appId, categories }) => {
3160
3215
  const inputRef = useRef2(null);
3161
3216
  const suggestions = useMemo(() => getSuggestions(appName, categories), [appName, categories]);
3162
3217
  const primaryCategory = useMemo(() => getPrimaryCategory(appName, categories), [appName, categories]);
3218
+ const MIN_INPUT_LENGTH = 6;
3163
3219
  const runAction = async () => {
3164
3220
  const trimmed = input.trim();
3165
- if (!trimmed || runState === "running") return;
3221
+ if (trimmed.length < MIN_INPUT_LENGTH || runState === "running") return;
3166
3222
  setQuery(trimmed);
3167
3223
  setInput("");
3168
3224
  setRunState("running");
@@ -3383,7 +3439,8 @@ ${JSON.stringify(data, null, 2)}
3383
3439
  {
3384
3440
  component: "button",
3385
3441
  onClick: runAction,
3386
- disabled: !input.trim(),
3442
+ disabled: input.trim().length < MIN_INPUT_LENGTH,
3443
+ title: input.trim().length < MIN_INPUT_LENGTH ? `Enter at least ${MIN_INPUT_LENGTH} characters` : void 0,
3387
3444
  sx: {
3388
3445
  all: "unset",
3389
3446
  display: "flex",
@@ -3393,11 +3450,11 @@ ${JSON.stringify(data, null, 2)}
3393
3450
  height: 30,
3394
3451
  borderRadius: "8px",
3395
3452
  flexShrink: 0,
3396
- cursor: input.trim() ? "pointer" : "default",
3397
- backgroundColor: input.trim() ? "hsl(var(--primary))" : "hsl(var(--muted))",
3398
- color: input.trim() ? "hsl(var(--primary-foreground))" : "hsl(var(--muted-foreground))",
3453
+ cursor: input.trim().length >= MIN_INPUT_LENGTH ? "pointer" : "not-allowed",
3454
+ backgroundColor: input.trim().length >= MIN_INPUT_LENGTH ? "hsl(var(--primary))" : "hsl(var(--muted))",
3455
+ color: input.trim().length >= MIN_INPUT_LENGTH ? "hsl(var(--primary-foreground))" : "hsl(var(--muted-foreground))",
3399
3456
  transition: "all 0.15s ease",
3400
- "&:hover": input.trim() ? {
3457
+ "&:hover": input.trim().length >= MIN_INPUT_LENGTH ? {
3401
3458
  filter: "brightness(1.1)"
3402
3459
  } : {}
3403
3460
  },
@@ -3728,23 +3785,32 @@ function buildSingulCurl(appName, action, opts) {
3728
3785
  const act = action?.name || "{action}";
3729
3786
  const body = {
3730
3787
  app: appName || "<appname>",
3788
+ action: act,
3731
3789
  fields: action?.fields.length ? action.fields : [{ name: "field1", value: "value1" }]
3732
3790
  };
3733
3791
  const token = opts?.apiKey || "YOUR_TOKEN";
3734
3792
  const orgLine = opts?.orgId ? `
3735
3793
  -H "Org-Id: ${opts.orgId}" \\` : "";
3736
- return `curl -X POST https://singul.io/api/${act} \\
3794
+ const base2 = (opts?.baseUrl || "").replace(/\/+$/, "");
3795
+ return `curl -X POST ${base2}/api/v1/singul \\
3737
3796
  -H "Authorization: Bearer ${token}" \\${orgLine}
3738
3797
  -d '${JSON.stringify(body, null, 2)}'`;
3739
3798
  }
3740
- function buildSingulPython(appName, action) {
3799
+ function buildSingulPython(appName, action, opts) {
3741
3800
  const act = action?.name || "send_message";
3742
3801
  const app = appName || "<appname>";
3743
3802
  const fields = action?.fields.length ? action.fields : [];
3744
3803
  const fieldsStr = JSON.stringify(fields);
3745
- return `import shufflepy
3804
+ const token = opts?.apiKey || "APIKEY";
3805
+ const base2 = (opts?.baseUrl || "").replace(/\/+$/, "");
3806
+ return `from shufflepy import Singul
3807
+
3808
+ singul = Singul(
3809
+ "${token}",
3810
+ url="${base2}",
3811
+ )
3746
3812
 
3747
- response = shufflepy.run("${app}", action="${act}", fields=${fieldsStr})
3813
+ response = singul.run("${app}", action="${act}", fields=${fieldsStr})
3748
3814
 
3749
3815
  print(response)`;
3750
3816
  }
@@ -3861,10 +3927,11 @@ var SingulActionsPreview = ({
3861
3927
  const apiKey = API_CONFIG.apiKey;
3862
3928
  const trackedOrg = getTrackedOrgId();
3863
3929
  const orgId = trackedOrg && activeOrgId && trackedOrg !== activeOrgId ? trackedOrg : null;
3864
- return { apiKey, orgId };
3930
+ const baseUrl = API_CONFIG.baseUrl;
3931
+ return { apiKey, orgId, baseUrl };
3865
3932
  }, [activeOrgId]);
3866
3933
  const buildSnippet = useCallback5(
3867
- (action, l) => l === "python" ? buildSingulPython(appName, action) : buildSingulCurl(appName, action, curlOpts),
3934
+ (action, l) => l === "python" ? buildSingulPython(appName, action, curlOpts) : buildSingulCurl(appName, action, curlOpts),
3868
3935
  [appName, curlOpts]
3869
3936
  );
3870
3937
  useEffect4(() => {
@@ -3915,7 +3982,7 @@ var SingulActionsPreview = ({
3915
3982
  app_name: "http",
3916
3983
  app_version: "1.4.0"
3917
3984
  };
3918
- const path = lang === "python" ? "/api/v1/apps/3e2bdf9d5069fe3f4746c29d68785a6a/run" : "/api/v1/apps/http/run";
3985
+ const path = lang === "python" ? "/api/v1/apps/3e2bdf9d5069fe3f4746c29d68785a6a/run?delete=true" : "/api/v1/apps/http/run?delete=true";
3919
3986
  const res = await fetch(getApiUrl(path), {
3920
3987
  method: "POST",
3921
3988
  credentials: "include",
@@ -4338,14 +4405,8 @@ function AppDetailDrawer({
4338
4405
  let appsList = null;
4339
4406
  if (API_CONFIG.apiKey) {
4340
4407
  try {
4341
- const res = await fetch(getApiUrl("/api/v1/apps"), {
4342
- credentials: "include",
4343
- headers: { ...getAuthHeader() }
4344
- });
4345
- if (res.ok) {
4346
- const apps = await res.json();
4347
- if (Array.isArray(apps)) appsList = apps;
4348
- }
4408
+ const apps = await fetchAppsViaApiConfig();
4409
+ if (Array.isArray(apps)) appsList = apps;
4349
4410
  } catch {
4350
4411
  }
4351
4412
  }
@@ -4656,7 +4717,7 @@ function AppDetailDrawer({
4656
4717
  }
4657
4718
 
4658
4719
  // ShuffleMCP.tsx
4659
- import "./shuffle-mcp-JQWKQNUP.css";
4720
+ import "./shuffle-mcp-24XBNRGE.css";
4660
4721
  import { Fragment as Fragment5, jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
4661
4722
  var DEFAULT_ALGOLIA_APP_ID = "JNSS5CFDZZ";
4662
4723
  var DEFAULT_ALGOLIA_API_KEY = "33e4e3564f4f060e96e0531957bed552";
@@ -4746,18 +4807,12 @@ var ShuffleMCP = React.forwardRef(({
4746
4807
  }
4747
4808
  const fetchPrivateApps = async () => {
4748
4809
  try {
4749
- const response = await fetch(`${apiBaseUrl}${privateAppsPath}`, {
4750
- headers: {
4751
- // apiKey is optional — if omitted we rely on the browser session
4752
- // cookie (credentials: 'include'), which is how prod usually auths.
4753
- ...apiKey ? { Authorization: `Bearer ${apiKey}` } : {},
4754
- ...orgId ? { "Org-Id": orgId } : {}
4755
- },
4756
- credentials: "include"
4810
+ const apps = await fetchApps({
4811
+ baseUrl: apiBaseUrl,
4812
+ path: privateAppsPath,
4813
+ apiKey: apiKey || null,
4814
+ orgId: orgId || null
4757
4815
  });
4758
- if (!response.ok) return;
4759
- const data = await response.json();
4760
- const apps = Array.isArray(data) ? data : data?.data || [];
4761
4816
  const normalized = apps.map((a) => ({
4762
4817
  name: a.name || "",
4763
4818
  description: a.description || "",
@@ -5002,6 +5057,8 @@ var ShuffleMCP = React.forwardRef(({
5002
5057
  "div",
5003
5058
  {
5004
5059
  className: `singul-dropdown-item ${selected ? "singul-selected" : ""} ${authState.validated ? "singul-validated" : ""} ${authState.configured ? "singul-configured" : ""}`,
5060
+ "data-app-name": app.name,
5061
+ "data-object-id": app.objectID,
5005
5062
  style: {
5006
5063
  ...customStyles.dropdownItem,
5007
5064
  ...selected ? customStyles.selectedItem : {}
@@ -5135,7 +5192,7 @@ var ShuffleMCP = React.forwardRef(({
5135
5192
  displayResults.map((app, index) => renderAppItem(app, index)),
5136
5193
  /* @__PURE__ */ jsx11("div", { className: "singul-end-of-results", style: {
5137
5194
  padding: "10px 16px",
5138
- color: "rgba(255, 255, 255, 0.3)",
5195
+ color: "hsl(var(--foreground) / 0.3)",
5139
5196
  textAlign: "center",
5140
5197
  fontSize: "11px",
5141
5198
  gridColumn: "1 / -1"
@@ -5183,7 +5240,7 @@ ShuffleMCP.displayName = "ShuffleMCP";
5183
5240
  var ShuffleMCP_default = ShuffleMCP;
5184
5241
 
5185
5242
  // AppSearchDrawer.tsx
5186
- import { useState as useState9 } from "react";
5243
+ import { useState as useState9, useEffect as useEffect7 } from "react";
5187
5244
  import { Box as Box10, Typography as Typography10, IconButton as IconButton5, Drawer as Drawer2, Avatar as Avatar5, Tooltip as Tooltip5 } from "@mui/material";
5188
5245
  import CloseIcon3 from "@mui/icons-material/Close";
5189
5246
  import { motion as motion7, AnimatePresence as AnimatePresence2 } from "framer-motion";
@@ -5349,10 +5406,19 @@ function AppSearchDrawer({
5349
5406
  onAddToCanvas,
5350
5407
  priorityCategory,
5351
5408
  connectionPathApps,
5352
- pinnedApps
5409
+ pinnedApps,
5410
+ highlightAppName,
5411
+ highlightDelayMs = 5e3
5353
5412
  }) {
5354
5413
  const [detailAppName, setDetailAppName] = useState9(null);
5355
5414
  const [detailAppId, setDetailAppId] = useState9(null);
5415
+ const [highlightActive, setHighlightActive] = useState9(false);
5416
+ useEffect7(() => {
5417
+ setHighlightActive(false);
5418
+ if (!open || !highlightAppName) return;
5419
+ const t = setTimeout(() => setHighlightActive(true), highlightDelayMs);
5420
+ return () => clearTimeout(t);
5421
+ }, [open, highlightAppName, highlightDelayMs]);
5356
5422
  const handleClose = () => {
5357
5423
  setDetailAppName(null);
5358
5424
  setDetailAppId(null);
@@ -5494,13 +5560,16 @@ function AppSearchDrawer({
5494
5560
  overflowY: "auto"
5495
5561
  },
5496
5562
  "& .singul-results-grid": {
5497
- gridAutoRows: "1fr",
5563
+ gridAutoRows: "75px",
5498
5564
  gap: "12px"
5499
5565
  },
5500
5566
  "& .singul-results-grid .singul-dropdown-item": {
5501
5567
  minHeight: 75,
5568
+ maxHeight: 75,
5569
+ height: 75,
5502
5570
  padding: "14px 16px",
5503
- alignItems: "center"
5571
+ alignItems: "center",
5572
+ overflow: "hidden"
5504
5573
  },
5505
5574
  "& .singul-results-grid .singul-app-info": {
5506
5575
  alignItems: "center",
@@ -5511,7 +5580,18 @@ function AppSearchDrawer({
5511
5580
  height: 40,
5512
5581
  borderRadius: 8,
5513
5582
  padding: 4
5514
- }
5583
+ },
5584
+ ...highlightActive && highlightAppName ? {
5585
+ [`& .singul-dropdown-item[data-app-name="${highlightAppName}"]`]: {
5586
+ borderColor: "hsl(var(--primary)) !important",
5587
+ boxShadow: "0 0 0 2px hsl(var(--primary)), 0 0 18px 2px hsl(var(--primary) / 0.55)",
5588
+ animation: "shuffleHighlightPulse 1.6s ease-in-out infinite"
5589
+ },
5590
+ "@keyframes shuffleHighlightPulse": {
5591
+ "0%, 100%": { boxShadow: "0 0 0 2px hsl(var(--primary)), 0 0 12px 1px hsl(var(--primary) / 0.4)" },
5592
+ "50%": { boxShadow: "0 0 0 2px hsl(var(--primary)), 0 0 24px 4px hsl(var(--primary) / 0.75)" }
5593
+ }
5594
+ } : {}
5515
5595
  },
5516
5596
  children: /* @__PURE__ */ jsx13(AnimatePresence2, { mode: "wait", children: /* @__PURE__ */ jsx13(
5517
5597
  motion7.div,
@@ -5591,7 +5671,7 @@ function AppSearchDrawer({
5591
5671
  }
5592
5672
 
5593
5673
  // AgentUI.tsx
5594
- import { useCallback as useCallback8, useEffect as useEffect7, useMemo as useMemo5, useRef as useRef6, useState as useState10 } from "react";
5674
+ import { useCallback as useCallback8, useEffect as useEffect8, useMemo as useMemo5, useRef as useRef6, useState as useState10 } from "react";
5595
5675
  import { useNavigate } from "react-router-dom";
5596
5676
  import {
5597
5677
  Avatar as Avatar6,
@@ -5974,10 +6054,12 @@ var TimelineRow = ({
5974
6054
  }
5975
6055
  }
5976
6056
  let toolApp;
5977
- if (details?.tool && typeof details.tool === "string" && details.tool !== "singul") {
5978
- let tn = details.tool.toLowerCase().replace(/[\s-]+/g, "_");
6057
+ const skipToolIcon = item.category === "finalise" || item.category === "finish" || item.category === "ask" || details?.action === "finalise" || details?.action === "finish" || details?.action === "ask";
6058
+ if (!skipToolIcon && details?.tool && typeof details.tool === "string" && details.tool !== "singul" && details.tool !== "core") {
6059
+ const raw = details.tool;
6060
+ let tn = raw.toLowerCase().replace(/[\s-]+/g, "_");
5979
6061
  if (tn.startsWith("app:")) tn = tn.split(":")[2] || tn;
5980
- toolApp = appsById[tn];
6062
+ toolApp = appsById[raw] || appsById[tn];
5981
6063
  }
5982
6064
  const questions = [];
5983
6065
  if (item.category === "ask" || details?.action === "ask") {
@@ -6039,7 +6121,9 @@ var TimelineRow = ({
6039
6121
  maxHeight: 60,
6040
6122
  overflow: "hidden",
6041
6123
  "& p": { margin: 0 },
6042
- "& pre, & code": { fontSize: "0.78rem" }
6124
+ "& pre, & code": { fontSize: "0.78rem" },
6125
+ "& a": { color: "hsl(var(--primary))", textDecoration: "underline", textUnderlineOffset: "2px" },
6126
+ "& a:hover": { opacity: 0.85 }
6043
6127
  }, children: /* @__PURE__ */ jsx14(Markdown, { remarkPlugins: [remarkGfm4, remarkBreaks], children: normalizeMarkdown(displayLabel) }) }),
6044
6128
  /* @__PURE__ */ jsx14(Tooltip6, { title: `Duration: ${dur.toFixed(1)}s \xB7 ${itemStart ? new Date(itemStart * 1e3).toLocaleString() : ""}`, children: /* @__PURE__ */ jsx14(Box11, { sx: { width: maxWidth, position: "relative", height: 10, flexShrink: 0 }, children: dur > 0 && /* @__PURE__ */ jsx14(Box11, { sx: {
6045
6129
  position: "absolute",
@@ -6056,7 +6140,9 @@ var TimelineRow = ({
6056
6140
  Box11,
6057
6141
  {
6058
6142
  sx: { display: "flex", alignItems: "center", gap: 0.25, ml: 1, minWidth: 96, justifyContent: "flex-end" },
6059
- onClick: (e) => e.stopPropagation(),
6143
+ onClick: (e) => {
6144
+ if (e.target.closest("button, a")) e.stopPropagation();
6145
+ },
6060
6146
  children: [
6061
6147
  item.type === "decision" && details?.run_details?.status === "WAITING" && (item.category === "ask" || details?.action === "ask") && questions.length === 0 && /* @__PURE__ */ jsxs12(Fragment7, { children: [
6062
6148
  /* @__PURE__ */ jsx14(Tooltip6, { title: "Approve this step", children: /* @__PURE__ */ jsx14("span", { children: /* @__PURE__ */ jsx14(
@@ -6260,6 +6346,7 @@ var AgentUI = ({
6260
6346
  compact = false,
6261
6347
  hideAppPicker = false,
6262
6348
  hideAttach = false,
6349
+ disableStartTab = false,
6263
6350
  appPickerLabel = "Select Apps / MCPs",
6264
6351
  appPickerTitle = "Select Apps / MCPs",
6265
6352
  appPickerSubtitle = "Pick the tools the agent is allowed to use for this run",
@@ -6269,16 +6356,21 @@ var AgentUI = ({
6269
6356
  readUrlParams = true,
6270
6357
  executionId,
6271
6358
  authorization,
6359
+ initialExecution,
6272
6360
  onRun,
6361
+ onViewChange,
6273
6362
  apiKey,
6274
6363
  apiBaseUrl,
6275
- orgId
6364
+ orgId,
6365
+ className,
6366
+ sx,
6367
+ contentSx
6276
6368
  }) => {
6277
- const resolveUrl = useCallback8(
6369
+ const resolveUrl2 = useCallback8(
6278
6370
  (path) => apiBaseUrl ? `${apiBaseUrl.replace(/\/+$/, "")}${path}` : getApiUrl(path),
6279
6371
  [apiBaseUrl]
6280
6372
  );
6281
- const resolveHeaders = useCallback8(() => {
6373
+ const resolveHeaders2 = useCallback8(() => {
6282
6374
  const h = apiKey ? { Authorization: `Bearer ${apiKey}` } : { ...getAuthHeader() };
6283
6375
  if (orgId) h["Org-Id"] = orgId;
6284
6376
  return h;
@@ -6292,6 +6384,8 @@ var AgentUI = ({
6292
6384
  ];
6293
6385
  const [chosenApps, setChosenApps] = useState10(apps ?? defaultApps ?? BUILTIN_DEFAULT_APPS);
6294
6386
  const [availableApps, setAvailableApps] = useState10([]);
6387
+ const [executionApps, setExecutionApps] = useState10([]);
6388
+ const [resolvedToolApps, setResolvedToolApps] = useState10({});
6295
6389
  const [appSearchOpen, setAppSearchOpen] = useState10(false);
6296
6390
  const [agentRequestLoading, setAgentRequestLoading] = useState10(false);
6297
6391
  const [execution, setExecution] = useState10(null);
@@ -6328,14 +6422,14 @@ var AgentUI = ({
6328
6422
  stateRef.current.continuationText = continuationText;
6329
6423
  stateRef.current.localRunStart = localRunStart;
6330
6424
  stateRef.current.showStarter = showStarter;
6331
- useEffect7(() => {
6425
+ useEffect8(() => {
6332
6426
  if (execution?.execution_id) {
6333
6427
  setLocalRunStart((prev) => prev ?? Math.floor(Date.now() / 1e3));
6334
6428
  } else if (!agentRequestLoading) {
6335
6429
  setLocalRunStart(null);
6336
6430
  }
6337
6431
  }, [execution?.execution_id, agentRequestLoading]);
6338
- useEffect7(() => {
6432
+ useEffect8(() => {
6339
6433
  const status = (execution?.status || agentData?.status || "").toUpperCase();
6340
6434
  const TERMINAL = ["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"];
6341
6435
  if (TERMINAL.includes(status)) return;
@@ -6370,16 +6464,119 @@ var AgentUI = ({
6370
6464
  };
6371
6465
  const appsById = useMemo5(() => {
6372
6466
  const m = {};
6373
- for (const a of chosenApps) {
6374
- const slug = a.name.toLowerCase().replace(/\s+/g, "_").replace(/-/g, "_");
6375
- m[slug] = a;
6467
+ const add = (a) => {
6468
+ if (!a?.name) return;
6469
+ const slug = a.name.toLowerCase().replace(/[\s-]+/g, "_");
6470
+ if (!m[slug] || !m[slug].icon && a.icon) m[slug] = a;
6471
+ if (a.id) {
6472
+ if (!m[a.id] || !m[a.id].icon && a.icon) m[a.id] = a;
6473
+ }
6474
+ };
6475
+ for (const a of chosenApps) add(a);
6476
+ for (const a of executionApps) add(a);
6477
+ for (const [k, v] of Object.entries(resolvedToolApps)) {
6478
+ if (!m[k] || !m[k].icon && v.icon) m[k] = v;
6479
+ add(v);
6376
6480
  }
6377
6481
  return m;
6378
- }, [chosenApps]);
6379
- useEffect7(() => {
6482
+ }, [chosenApps, executionApps, resolvedToolApps]);
6483
+ useEffect8(() => {
6380
6484
  if (apps) setChosenApps(apps);
6381
6485
  }, [apps]);
6382
- useEffect7(() => {
6486
+ useEffect8(() => {
6487
+ const decisions = agentData?.decisions || [];
6488
+ if (!Array.isArray(decisions) || decisions.length === 0) return;
6489
+ const norm2 = (s) => s.toLowerCase().replace(/[\s-]+/g, "_");
6490
+ const wanted = [];
6491
+ const seen = /* @__PURE__ */ new Set();
6492
+ for (const dec of decisions) {
6493
+ const action = dec?.action || dec?.details?.action;
6494
+ const category = dec?.category || dec?.details?.category;
6495
+ if (action === "finish" || action === "finalise" || action === "ask") continue;
6496
+ if (category === "finish" || category === "finalise" || category === "ask") continue;
6497
+ const tool = dec?.details?.tool ?? dec?.tool;
6498
+ if (!tool || typeof tool !== "string") continue;
6499
+ if (tool === "singul" || tool === "core") continue;
6500
+ let raw = tool;
6501
+ let slug = norm2(tool);
6502
+ if (slug.startsWith("app:")) slug = slug.split(":")[2] || slug;
6503
+ if (appsById[raw]?.icon || appsById[slug]?.icon) continue;
6504
+ if (resolvedToolApps[raw]?.icon || resolvedToolApps[slug]?.icon) continue;
6505
+ const key = `${raw}|${slug}`;
6506
+ if (seen.has(key)) continue;
6507
+ seen.add(key);
6508
+ wanted.push({ raw, slug });
6509
+ }
6510
+ if (wanted.length === 0) return;
6511
+ let cancelled = false;
6512
+ (async () => {
6513
+ const found = {};
6514
+ try {
6515
+ const all = await fetchApps({
6516
+ baseUrl: apiBaseUrl ? apiBaseUrl.replace(/\/+$/, "") : API_CONFIG.baseUrl,
6517
+ apiKey: apiKey || API_CONFIG.apiKey,
6518
+ orgId: orgId || null
6519
+ });
6520
+ if (Array.isArray(all) && all.length > 0) {
6521
+ const byId = /* @__PURE__ */ new Map();
6522
+ const byName = /* @__PURE__ */ new Map();
6523
+ for (const a of all) {
6524
+ if (a?.id) byId.set(String(a.id), a);
6525
+ if (a?.name) byName.set(norm2(String(a.name)), a);
6526
+ }
6527
+ for (const { raw, slug } of wanted) {
6528
+ const hit = byId.get(raw) || byName.get(slug);
6529
+ if (!hit) continue;
6530
+ const icon = hit.large_image || hit.image_url || hit.image || "";
6531
+ const app = { id: hit.id, name: hit.name || slug, icon };
6532
+ found[raw] = app;
6533
+ found[slug] = app;
6534
+ }
6535
+ }
6536
+ } catch {
6537
+ }
6538
+ const stillMissing = wanted.filter(({ raw, slug }) => !found[raw] && !found[slug]);
6539
+ if (stillMissing.length > 0) {
6540
+ try {
6541
+ const { algoliasearch: algoliasearch2 } = await import("algoliasearch");
6542
+ const client = algoliasearch2("JNSS5CFDZZ", "33e4e3564f4f060e96e0531957bed552");
6543
+ await Promise.all(stillMissing.map(async ({ raw, slug }) => {
6544
+ try {
6545
+ try {
6546
+ const obj = await client.getObject({ indexName: "appsearch", objectID: raw });
6547
+ if (obj?.image_url || obj?.name) {
6548
+ const app = { id: obj.objectID || raw, name: obj.name || slug, icon: obj.image_url || "" };
6549
+ found[raw] = app;
6550
+ found[slug] = app;
6551
+ return;
6552
+ }
6553
+ } catch {
6554
+ }
6555
+ const res = await client.searchSingleIndex({
6556
+ indexName: "appsearch",
6557
+ searchParams: { query: slug.replace(/_/g, " "), hitsPerPage: 3 }
6558
+ });
6559
+ const hits = res.hits || [];
6560
+ const match = hits.find((h) => norm2(h.name || "") === slug) || hits[0];
6561
+ if (match?.image_url || match?.name) {
6562
+ const app = { id: match.objectID || raw, name: match.name || slug, icon: match.image_url || "" };
6563
+ found[raw] = app;
6564
+ found[slug] = app;
6565
+ }
6566
+ } catch {
6567
+ }
6568
+ }));
6569
+ } catch {
6570
+ }
6571
+ }
6572
+ if (cancelled || Object.keys(found).length === 0) return;
6573
+ setResolvedToolApps((prev) => ({ ...prev, ...found }));
6574
+ })();
6575
+ return () => {
6576
+ cancelled = true;
6577
+ };
6578
+ }, [JSON.stringify(agentData?.decisions?.map((d) => d?.details?.tool || d?.tool) || []), appsById]);
6579
+ useEffect8(() => {
6383
6580
  const missing = chosenApps.filter((a) => !a.icon && a.name);
6384
6581
  if (missing.length === 0) return;
6385
6582
  let cancelled = false;
@@ -6410,18 +6607,17 @@ var AgentUI = ({
6410
6607
  const stillMissing = missing.filter((a) => !resolved[a.name]);
6411
6608
  if (stillMissing.length > 0) {
6412
6609
  try {
6413
- const res = await fetch(resolveUrl("/api/v1/apps"), {
6414
- credentials: "include",
6415
- headers: { ...resolveHeaders() }
6610
+ const baseUrl = apiBaseUrl ? apiBaseUrl.replace(/\/+$/, "") : API_CONFIG.baseUrl;
6611
+ const apps2 = await fetchApps({
6612
+ baseUrl,
6613
+ apiKey: apiKey || API_CONFIG.apiKey,
6614
+ orgId: orgId || null
6416
6615
  });
6417
- if (res.ok) {
6418
- const apps2 = await res.json();
6419
- if (Array.isArray(apps2)) {
6420
- for (const a of stillMissing) {
6421
- const m = apps2.find((x) => norm2(x.name || "") === norm2(a.name));
6422
- const img = m?.large_image || m?.image_url || m?.image;
6423
- if (img) resolved[a.name] = img;
6424
- }
6616
+ if (Array.isArray(apps2)) {
6617
+ for (const a of stillMissing) {
6618
+ const m = apps2.find((x) => norm2(x.name || "") === norm2(a.name));
6619
+ const img = m?.large_image || m?.image_url || m?.image;
6620
+ if (img) resolved[a.name] = img;
6425
6621
  }
6426
6622
  }
6427
6623
  } catch {
@@ -6437,17 +6633,17 @@ var AgentUI = ({
6437
6633
  return () => {
6438
6634
  cancelled = true;
6439
6635
  };
6440
- }, [chosenApps, availableApps, resolveUrl, resolveHeaders]);
6441
- useEffect7(() => {
6636
+ }, [chosenApps, availableApps, resolveUrl2, resolveHeaders2]);
6637
+ useEffect8(() => {
6442
6638
  if (!autoLoadApps) return;
6443
6639
  if (apps || defaultApps) return;
6444
6640
  if (!hasApiKey) return;
6445
6641
  let cancelled = false;
6446
6642
  (async () => {
6447
6643
  try {
6448
- const resp = await fetch(resolveUrl("/api/v1/apps/authentication"), {
6644
+ const resp = await fetch(resolveUrl2("/api/v1/apps/authentication"), {
6449
6645
  credentials: "include",
6450
- headers: { ...resolveHeaders() }
6646
+ headers: { ...resolveHeaders2() }
6451
6647
  });
6452
6648
  if (!resp.ok) return;
6453
6649
  const result = await resp.json();
@@ -6476,14 +6672,123 @@ var AgentUI = ({
6476
6672
  return () => {
6477
6673
  cancelled = true;
6478
6674
  };
6479
- }, [autoLoadApps, apps, defaultApps, hasApiKey, resolveUrl, resolveHeaders]);
6675
+ }, [autoLoadApps, apps, defaultApps, hasApiKey, resolveUrl2, resolveHeaders2]);
6676
+ useEffect8(() => {
6677
+ const raw = agentData?.allowed_actions;
6678
+ if (!Array.isArray(raw) || raw.length === 0) {
6679
+ setExecutionApps([]);
6680
+ return;
6681
+ }
6682
+ const parsed = [];
6683
+ const seen = /* @__PURE__ */ new Set();
6684
+ for (const entry of raw) {
6685
+ if (typeof entry !== "string") continue;
6686
+ const parts = entry.split(":");
6687
+ if (parts.length < 3 || parts[0] !== "app") continue;
6688
+ const id = parts[1] || "";
6689
+ const name = parts.slice(2).join(":") || "";
6690
+ if (!name && !id) continue;
6691
+ const key = `${id}|${name}`;
6692
+ if (seen.has(key)) continue;
6693
+ seen.add(key);
6694
+ parsed.push({ id, name });
6695
+ }
6696
+ if (parsed.length === 0) {
6697
+ setExecutionApps([]);
6698
+ return;
6699
+ }
6700
+ const resolveFromAvailable = (id, name) => {
6701
+ const byId = id ? availableApps.find((a) => a.id === id) : void 0;
6702
+ const byName = !byId && name ? availableApps.find((a) => (a.name || "").toLowerCase() === name.toLowerCase()) : void 0;
6703
+ const hit = byId || byName;
6704
+ return { id: id || hit?.id, name: hit?.name || name, icon: hit?.icon };
6705
+ };
6706
+ const initial = parsed.map(({ id, name }) => resolveFromAvailable(id, name));
6707
+ setExecutionApps(initial);
6708
+ if (initial.every((a) => !!a.icon)) return;
6709
+ let cancelled = false;
6710
+ const norm2 = (s) => (s || "").toLowerCase().replace(/[\s-]+/g, "_");
6711
+ (async () => {
6712
+ let next = initial;
6713
+ try {
6714
+ const all = await fetchApps({
6715
+ baseUrl: API_CONFIG.baseUrl,
6716
+ apiKey: apiKey || API_CONFIG.apiKey,
6717
+ orgId: orgId || null
6718
+ });
6719
+ if (!cancelled && Array.isArray(all) && all.length > 0) {
6720
+ const byIdMap = /* @__PURE__ */ new Map();
6721
+ const byNameMap = /* @__PURE__ */ new Map();
6722
+ for (const a of all) {
6723
+ if (a?.id) byIdMap.set(String(a.id), a);
6724
+ if (a?.name) byNameMap.set(norm2(String(a.name)), a);
6725
+ }
6726
+ next = next.map((a) => {
6727
+ if (a.icon) return a;
6728
+ const hit = a.id && byIdMap.get(a.id) || byNameMap.get(norm2(a.name || ""));
6729
+ if (!hit) return a;
6730
+ return {
6731
+ id: a.id || hit.id,
6732
+ name: hit.name || a.name,
6733
+ icon: hit.large_image || hit.image_url || hit.image || a.icon
6734
+ };
6735
+ });
6736
+ }
6737
+ } catch {
6738
+ }
6739
+ const stillMissing = next.filter((a) => !a.icon);
6740
+ if (stillMissing.length > 0) {
6741
+ try {
6742
+ const { algoliasearch: algoliasearch2 } = await import("algoliasearch");
6743
+ const client = algoliasearch2("JNSS5CFDZZ", "33e4e3564f4f060e96e0531957bed552");
6744
+ const resolved = {};
6745
+ await Promise.all(stillMissing.map(async (a) => {
6746
+ try {
6747
+ if (a.id) {
6748
+ try {
6749
+ const obj = await client.getObject({ indexName: "appsearch", objectID: a.id });
6750
+ if (obj?.image_url) {
6751
+ resolved[a.id || a.name] = { name: obj.name || a.name, icon: obj.image_url, id: obj.objectID || a.id };
6752
+ return;
6753
+ }
6754
+ } catch {
6755
+ }
6756
+ }
6757
+ const res = await client.searchSingleIndex({
6758
+ indexName: "appsearch",
6759
+ searchParams: { query: (a.name || "").replace(/_/g, " "), hitsPerPage: 3 }
6760
+ });
6761
+ const hits = res.hits || [];
6762
+ const match = hits.find((h) => norm2(h.name || "") === norm2(a.name || "")) || hits[0];
6763
+ if (match?.image_url) {
6764
+ resolved[a.id || a.name] = { name: match.name || a.name, icon: match.image_url, id: match.objectID || a.id || "" };
6765
+ }
6766
+ } catch {
6767
+ }
6768
+ }));
6769
+ if (Object.keys(resolved).length > 0) {
6770
+ next = next.map((a) => {
6771
+ if (a.icon) return a;
6772
+ const r = resolved[a.id || a.name];
6773
+ return r ? { id: r.id || a.id, name: r.name || a.name, icon: r.icon } : a;
6774
+ });
6775
+ }
6776
+ } catch {
6777
+ }
6778
+ }
6779
+ if (!cancelled) setExecutionApps(next);
6780
+ })();
6781
+ return () => {
6782
+ cancelled = true;
6783
+ };
6784
+ }, [JSON.stringify(agentData?.allowed_actions || []), availableApps]);
6480
6785
  const getExecution = useCallback8(async (executionId2, authorization2) => {
6481
6786
  if (!executionId2 || !authorization2) return;
6482
6787
  try {
6483
- const resp = await fetch(resolveUrl("/api/v1/streams/results"), {
6788
+ const resp = await fetch(resolveUrl2("/api/v1/streams/results"), {
6484
6789
  method: "POST",
6485
6790
  credentials: "include",
6486
- headers: { "Content-Type": "application/json", ...resolveHeaders() },
6791
+ headers: { "Content-Type": "application/json", ...resolveHeaders2() },
6487
6792
  body: JSON.stringify({ execution_id: executionId2, authorization: authorization2 })
6488
6793
  });
6489
6794
  if (activeExecutionIdRef.current && activeExecutionIdRef.current !== executionId2) return;
@@ -6512,7 +6817,7 @@ var AgentUI = ({
6512
6817
  setError(err instanceof Error ? err.message : "Network error.");
6513
6818
  }
6514
6819
  }, []);
6515
- useEffect7(() => {
6820
+ useEffect8(() => {
6516
6821
  let eid = null;
6517
6822
  let auth = null;
6518
6823
  if (executionId && authorization) {
@@ -6530,7 +6835,30 @@ var AgentUI = ({
6530
6835
  getExecution(eid, auth);
6531
6836
  }
6532
6837
  }, [readUrlParams, executionId, authorization, getExecution]);
6533
- useEffect7(() => {
6838
+ useEffect8(() => {
6839
+ if (!initialExecution || !initialExecution.execution_id) return;
6840
+ setShowStarter(false);
6841
+ activeExecutionIdRef.current = initialExecution.execution_id;
6842
+ setExecution(initialExecution);
6843
+ let actionResult = null;
6844
+ if (Array.isArray(initialExecution.results)) {
6845
+ actionResult = initialExecution.results.find((r) => r?.action?.app_name === "AI Agent") || initialExecution.results[0];
6846
+ } else {
6847
+ actionResult = initialExecution;
6848
+ }
6849
+ setAgentActionResult(actionResult);
6850
+ const v = validateJson(actionResult?.result);
6851
+ if (v.valid) {
6852
+ setAgentData({
6853
+ ...v.result,
6854
+ started_at: initialExecution.started_at,
6855
+ completed_at: initialExecution.completed_at,
6856
+ status: initialExecution.status
6857
+ });
6858
+ }
6859
+ setError(null);
6860
+ }, [initialExecution?.execution_id]);
6861
+ useEffect8(() => {
6534
6862
  if (!execution?.execution_id || !execution?.authorization) return;
6535
6863
  const status = (execution.status || "").toUpperCase();
6536
6864
  const TERMINAL = ["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"];
@@ -6637,7 +6965,7 @@ var AgentUI = ({
6637
6965
  }
6638
6966
  }, [chosenApps, getExecution, onRun, attachedImages, readUrlParams]);
6639
6967
  const autoSubmittedRef = useRef6(false);
6640
- useEffect7(() => {
6968
+ useEffect8(() => {
6641
6969
  if (autoSubmit && defaultInput && !autoSubmittedRef.current && !executionId) {
6642
6970
  autoSubmittedRef.current = true;
6643
6971
  submitInput(defaultInput);
@@ -6669,10 +6997,10 @@ var AgentUI = ({
6669
6997
  decision_id: decisionId
6670
6998
  });
6671
6999
  try {
6672
- const resp = await fetch(resolveUrl(`/api/v1/workflows/${wfId}/run?${params.toString()}`), {
7000
+ const resp = await fetch(resolveUrl2(`/api/v1/workflows/${wfId}/run?${params.toString()}`), {
6673
7001
  method: "GET",
6674
7002
  credentials: "include",
6675
- headers: { ...resolveHeaders() }
7003
+ headers: { ...resolveHeaders2() }
6676
7004
  });
6677
7005
  const json = await resp.json();
6678
7006
  if (json.success === false) {
@@ -6739,10 +7067,10 @@ var AgentUI = ({
6739
7067
  body.source_workflow = execution.workflow?.id;
6740
7068
  setAgentRequestLoading(true);
6741
7069
  try {
6742
- const resp = await fetch(resolveUrl(`/api/v1/apps/agent/run?rerun=true&decision_id=${encodeURIComponent(decisionId)}`), {
7070
+ const resp = await fetch(resolveUrl2(`/api/v1/apps/agent/run?rerun=true&decision_id=${encodeURIComponent(decisionId)}`), {
6743
7071
  method: "POST",
6744
7072
  credentials: "include",
6745
- headers: { "Content-Type": "application/json", ...resolveHeaders() },
7073
+ headers: { "Content-Type": "application/json", ...resolveHeaders2() },
6746
7074
  body: JSON.stringify(body)
6747
7075
  });
6748
7076
  const json = await resp.json().catch(() => ({}));
@@ -6852,6 +7180,9 @@ var AgentUI = ({
6852
7180
  const activeTab = showStarter ? "start" : viewMode;
6853
7181
  const hasExecution = !!execution?.execution_id;
6854
7182
  const showRunSwitcher = hasExecution || agentRequestLoading;
7183
+ useEffect8(() => {
7184
+ onViewChange?.(activeTab);
7185
+ }, [activeTab, onViewChange]);
6855
7186
  const goToTab = (t) => {
6856
7187
  if (t === "start") {
6857
7188
  setShowStarter(true);
@@ -6874,15 +7205,19 @@ var AgentUI = ({
6874
7205
  /* @__PURE__ */ jsx14(Box11, { sx: { display: "inline-flex", gap: 0.25, p: 0.25, borderRadius: 999, bgcolor: "hsl(var(--muted) / 0.6)" }, children: ["start", "simple", "detailed"].map((t) => {
6875
7206
  const active = activeTab === t;
6876
7207
  const label = t === "start" ? "Start" : t === "simple" ? "Simple" : "Detailed";
7208
+ const disabled = t === "start" && disableStartTab;
6877
7209
  return /* @__PURE__ */ jsx14(
6878
7210
  Box11,
6879
7211
  {
6880
7212
  component: "button",
6881
7213
  type: "button",
6882
- onClick: () => goToTab(t),
7214
+ onClick: () => {
7215
+ if (!disabled) goToTab(t);
7216
+ },
7217
+ disabled,
6883
7218
  sx: {
6884
7219
  all: "unset",
6885
- cursor: "pointer",
7220
+ cursor: disabled ? "not-allowed" : "pointer",
6886
7221
  px: 1.75,
6887
7222
  py: 0.5,
6888
7223
  borderRadius: 999,
@@ -6890,8 +7225,9 @@ var AgentUI = ({
6890
7225
  fontWeight: 600,
6891
7226
  color: active ? "hsl(var(--primary-foreground))" : "hsl(var(--muted-foreground))",
6892
7227
  bgcolor: active ? "hsl(var(--primary))" : "transparent",
7228
+ opacity: disabled ? 0.4 : 1,
6893
7229
  transition: "background 0.12s ease, color 0.12s ease",
6894
- "&:hover": active ? {} : { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted))" }
7230
+ "&:hover": active || disabled ? {} : { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted))" }
6895
7231
  },
6896
7232
  children: label
6897
7233
  },
@@ -6914,645 +7250,1478 @@ var AgentUI = ({
6914
7250
  }
6915
7251
  ) }) })
6916
7252
  ] });
6917
- return /* @__PURE__ */ jsx14(Box11, { sx: { width: "100%", display: "flex", justifyContent: "center", pb: 4 }, children: /* @__PURE__ */ jsxs12(Box11, { sx: { width: "100%", maxWidth, display: "flex", flexDirection: "column", gap: 3 }, children: [
6918
- showRunSwitcher && tabBar,
6919
- showStarter ? /* @__PURE__ */ jsxs12(
6920
- Box11,
6921
- {
6922
- component: "form",
6923
- onSubmit: (e) => {
6924
- e.preventDefault();
6925
- submitInput(actionInput);
6926
- },
6927
- sx: { display: "flex", flexDirection: "column", alignItems: "center", gap: compact ? 2 : 3, py: compact ? 2 : 4 },
6928
- children: [
6929
- !hideHeroIcon && !compact && /* @__PURE__ */ jsx14(Box11, { sx: {
6930
- width: heroIconSize,
6931
- height: heroIconSize,
6932
- borderRadius: 3,
6933
- bgcolor: "hsl(var(--card))",
6934
- border: "1px solid hsl(var(--border))",
6935
- display: "flex",
6936
- alignItems: "center",
6937
- justifyContent: "center",
6938
- boxShadow: "0 8px 24px rgba(0,0,0,0.25)"
6939
- }, children: heroIcon ?? /* @__PURE__ */ jsx14(AgentIcon_default, { size: Math.round(heroIconSize * 0.67) }) }),
6940
- /* @__PURE__ */ jsx14(Typography11, { component: "h1", sx: {
6941
- fontSize: compact ? { xs: "1.25rem", md: "1.5rem" } : { xs: "1.75rem", md: "2.25rem" },
6942
- fontWeight: 600,
6943
- color: "hsl(var(--foreground))",
6944
- textAlign: "center",
6945
- letterSpacing: "-0.01em"
6946
- }, children: title }),
6947
- subtitle && /* @__PURE__ */ jsx14(Typography11, { sx: {
6948
- fontSize: "0.95rem",
6949
- color: "hsl(var(--muted-foreground))",
6950
- textAlign: "center",
6951
- mt: -1,
6952
- maxWidth: 600
6953
- }, children: subtitle }),
6954
- /* @__PURE__ */ jsxs12(Box11, { sx: {
6955
- width: "100%",
6956
- display: "flex",
6957
- flexDirection: "column",
6958
- gap: 1,
6959
- borderRadius: attachedImages.length > 0 ? 4 : 999,
6960
- border: "1.5px solid hsl(var(--border))",
6961
- bgcolor: "hsl(var(--card))",
6962
- px: 3,
6963
- py: 1.75,
6964
- transition: "border-color 0.15s ease, box-shadow 0.15s ease, border-radius 0.15s ease",
6965
- "&:focus-within": {
6966
- borderColor: "hsl(var(--primary))",
6967
- boxShadow: "0 0 0 3px hsla(var(--primary) / 0.12)"
6968
- }
6969
- }, children: [
6970
- attachedImages.length > 0 && /* @__PURE__ */ jsx14(Box11, { sx: { display: "flex", flexWrap: "wrap", gap: 0.75 }, children: attachedImages.map((img, idx) => /* @__PURE__ */ jsxs12(Box11, { sx: {
6971
- display: "inline-flex",
6972
- alignItems: "center",
6973
- gap: 1,
6974
- p: 0.5,
6975
- pr: 1,
6976
- borderRadius: 1.5,
6977
- border: "1px solid hsl(var(--border))",
6978
- bgcolor: "hsl(var(--background))",
6979
- maxWidth: "100%"
6980
- }, children: [
6981
- /* @__PURE__ */ jsx14(Box11, { component: "img", src: img.dataUrl, alt: img.name, sx: { width: 32, height: 32, borderRadius: 1, objectFit: "cover", flexShrink: 0 } }),
6982
- /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.72rem", color: "hsl(var(--foreground))", maxWidth: 190, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: img.name }),
6983
- /* @__PURE__ */ jsx14(IconButton6, { 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__ */ jsx14(CloseIcon4, { sx: { fontSize: 12 } }) })
6984
- ] }, `${img.name}-${idx}`)) }),
6985
- /* @__PURE__ */ jsxs12(Box11, { sx: { display: "flex", alignItems: "flex-end", gap: 1, width: "100%" }, children: [
6986
- /* @__PURE__ */ jsx14(
6987
- InputBase2,
6988
- {
6989
- inputRef,
6990
- autoFocus: true,
6991
- multiline: true,
6992
- minRows: 1,
6993
- maxRows: 6,
6994
- fullWidth: true,
6995
- value: actionInput,
6996
- onChange: (e) => setActionInput(e.target.value),
6997
- placeholder,
6998
- onKeyDown,
6999
- onPaste: (e) => {
7000
- const items = e.clipboardData?.items;
7001
- if (!items) return;
7002
- const files = [];
7003
- for (const item of Array.from(items)) {
7004
- if (item.kind === "file" && item.type.startsWith("image/")) {
7005
- const file = item.getAsFile();
7006
- if (file) files.push(file);
7007
- }
7253
+ return /* @__PURE__ */ jsx14(
7254
+ Box11,
7255
+ {
7256
+ className,
7257
+ sx: [
7258
+ { width: "100%", display: "flex", justifyContent: "center", pb: 4 },
7259
+ ...Array.isArray(sx) ? sx : sx ? [sx] : []
7260
+ ],
7261
+ children: /* @__PURE__ */ jsxs12(
7262
+ Box11,
7263
+ {
7264
+ sx: [
7265
+ { width: "100%", maxWidth, display: "flex", flexDirection: "column", gap: 3 },
7266
+ ...Array.isArray(contentSx) ? contentSx : contentSx ? [contentSx] : []
7267
+ ],
7268
+ children: [
7269
+ showRunSwitcher && tabBar,
7270
+ showStarter ? /* @__PURE__ */ jsxs12(
7271
+ Box11,
7272
+ {
7273
+ component: "form",
7274
+ onSubmit: (e) => {
7275
+ e.preventDefault();
7276
+ submitInput(actionInput);
7277
+ },
7278
+ sx: { display: "flex", flexDirection: "column", alignItems: "center", gap: compact ? 2 : 3, py: compact ? 2 : 4 },
7279
+ children: [
7280
+ !hideHeroIcon && !compact && /* @__PURE__ */ jsx14(Box11, { sx: {
7281
+ width: heroIconSize,
7282
+ height: heroIconSize,
7283
+ borderRadius: 3,
7284
+ bgcolor: "hsl(var(--card))",
7285
+ border: "1px solid hsl(var(--border))",
7286
+ display: "flex",
7287
+ alignItems: "center",
7288
+ justifyContent: "center",
7289
+ boxShadow: "0 8px 24px rgba(0,0,0,0.25)"
7290
+ }, children: heroIcon ?? /* @__PURE__ */ jsx14(AgentIcon_default, { size: Math.round(heroIconSize * 0.67) }) }),
7291
+ /* @__PURE__ */ jsx14(Typography11, { component: "h1", sx: {
7292
+ fontSize: compact ? { xs: "1.25rem", md: "1.5rem" } : { xs: "1.75rem", md: "2.25rem" },
7293
+ fontWeight: 600,
7294
+ color: "hsl(var(--foreground))",
7295
+ textAlign: "center",
7296
+ letterSpacing: "-0.01em"
7297
+ }, children: title }),
7298
+ subtitle && /* @__PURE__ */ jsx14(Typography11, { sx: {
7299
+ fontSize: "0.95rem",
7300
+ color: "hsl(var(--muted-foreground))",
7301
+ textAlign: "center",
7302
+ mt: -1,
7303
+ maxWidth: 600
7304
+ }, children: subtitle }),
7305
+ /* @__PURE__ */ jsxs12(Box11, { sx: {
7306
+ width: "100%",
7307
+ display: "flex",
7308
+ flexDirection: "column",
7309
+ gap: 1,
7310
+ borderRadius: attachedImages.length > 0 ? 4 : 999,
7311
+ border: "1.5px solid hsl(var(--border))",
7312
+ bgcolor: "hsl(var(--card))",
7313
+ px: 3,
7314
+ py: 1.75,
7315
+ transition: "border-color 0.15s ease, box-shadow 0.15s ease, border-radius 0.15s ease",
7316
+ "&:focus-within": {
7317
+ borderColor: "hsl(var(--primary))",
7318
+ boxShadow: "0 0 0 3px hsla(var(--primary) / 0.12)"
7008
7319
  }
7009
- if (files.length > 0) {
7010
- e.preventDefault();
7011
- handleImagesSelected(files);
7320
+ }, children: [
7321
+ attachedImages.length > 0 && /* @__PURE__ */ jsx14(Box11, { sx: { display: "flex", flexWrap: "wrap", gap: 0.75 }, children: attachedImages.map((img, idx) => /* @__PURE__ */ jsxs12(Box11, { sx: {
7322
+ display: "inline-flex",
7323
+ alignItems: "center",
7324
+ gap: 1,
7325
+ p: 0.5,
7326
+ pr: 1,
7327
+ borderRadius: 1.5,
7328
+ border: "1px solid hsl(var(--border))",
7329
+ bgcolor: "hsl(var(--background))",
7330
+ maxWidth: "100%"
7331
+ }, children: [
7332
+ /* @__PURE__ */ jsx14(Box11, { component: "img", src: img.dataUrl, alt: img.name, sx: { width: 32, height: 32, borderRadius: 1, objectFit: "cover", flexShrink: 0 } }),
7333
+ /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.72rem", color: "hsl(var(--foreground))", maxWidth: 190, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: img.name }),
7334
+ /* @__PURE__ */ jsx14(IconButton6, { 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__ */ jsx14(CloseIcon4, { sx: { fontSize: 12 } }) })
7335
+ ] }, `${img.name}-${idx}`)) }),
7336
+ /* @__PURE__ */ jsxs12(Box11, { sx: { display: "flex", alignItems: "flex-end", gap: 1, width: "100%" }, children: [
7337
+ /* @__PURE__ */ jsx14(
7338
+ InputBase2,
7339
+ {
7340
+ inputRef,
7341
+ autoFocus: true,
7342
+ multiline: true,
7343
+ minRows: 1,
7344
+ maxRows: 6,
7345
+ fullWidth: true,
7346
+ value: actionInput,
7347
+ onChange: (e) => setActionInput(e.target.value),
7348
+ placeholder,
7349
+ onKeyDown,
7350
+ onPaste: (e) => {
7351
+ const items = e.clipboardData?.items;
7352
+ if (!items) return;
7353
+ const files = [];
7354
+ for (const item of Array.from(items)) {
7355
+ if (item.kind === "file" && item.type.startsWith("image/")) {
7356
+ const file = item.getAsFile();
7357
+ if (file) files.push(file);
7358
+ }
7359
+ }
7360
+ if (files.length > 0) {
7361
+ e.preventDefault();
7362
+ handleImagesSelected(files);
7363
+ }
7364
+ },
7365
+ disabled: agentRequestLoading,
7366
+ sx: {
7367
+ fontSize: "1rem",
7368
+ color: "hsl(var(--foreground))",
7369
+ "& textarea::placeholder": { color: "hsl(var(--muted-foreground))", opacity: 0.7 }
7370
+ }
7371
+ }
7372
+ ),
7373
+ /* @__PURE__ */ jsx14(
7374
+ "input",
7375
+ {
7376
+ ref: fileInputRef,
7377
+ type: "file",
7378
+ accept: "image/*",
7379
+ multiple: true,
7380
+ style: { display: "none" },
7381
+ onChange: (e) => {
7382
+ handleImagesSelected(e.target.files);
7383
+ if (e.target) e.target.value = "";
7384
+ }
7385
+ }
7386
+ ),
7387
+ !hideAttach && /* @__PURE__ */ jsx14(
7388
+ IconButton6,
7389
+ {
7390
+ type: "button",
7391
+ onClick: () => fileInputRef.current?.click(),
7392
+ disabled: agentRequestLoading,
7393
+ title: attachedImages.length > 0 ? `Add image (${attachedImages.length} attached)` : "Attach image",
7394
+ sx: {
7395
+ width: 36,
7396
+ height: 36,
7397
+ color: attachedImages.length > 0 ? "hsl(var(--primary))" : "hsl(var(--muted-foreground))",
7398
+ bgcolor: attachedImages.length > 0 ? "hsla(var(--primary) / 0.1)" : "transparent",
7399
+ "&:hover": { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted))" }
7400
+ },
7401
+ children: /* @__PURE__ */ jsx14(AttachFileIcon, { sx: { fontSize: 18 } })
7402
+ }
7403
+ ),
7404
+ /* @__PURE__ */ jsx14(Tooltip6, { title: submitTooltip, placement: "top", arrow: true, children: /* @__PURE__ */ jsx14("span", { children: /* @__PURE__ */ jsx14(
7405
+ IconButton6,
7406
+ {
7407
+ type: "submit",
7408
+ disabled: actionInput.trim().length < 3 || agentRequestLoading,
7409
+ sx: {
7410
+ width: 36,
7411
+ height: 36,
7412
+ bgcolor: actionInput.trim().length >= 3 ? "hsl(var(--primary))" : "hsl(var(--muted))",
7413
+ color: actionInput.trim().length >= 3 ? "hsl(var(--primary-foreground))" : "hsl(var(--muted-foreground))",
7414
+ "&:hover": actionInput.trim().length >= 3 ? { filter: "brightness(1.1)", bgcolor: "hsl(var(--primary))" } : {},
7415
+ "&.Mui-disabled": { bgcolor: "hsl(var(--muted))", color: "hsl(var(--muted-foreground))" }
7416
+ },
7417
+ children: agentRequestLoading ? /* @__PURE__ */ jsx14(CircularProgress4, { size: 16, sx: { color: "inherit" } }) : submitIcon ?? /* @__PURE__ */ jsx14(PlayArrowRoundedIcon2, {})
7418
+ }
7419
+ ) }) })
7420
+ ] })
7421
+ ] }),
7422
+ !hideAppPicker && /* @__PURE__ */ jsx14(Box11, { sx: { display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ jsxs12(Box11, { sx: {
7423
+ display: "inline-flex",
7424
+ flexWrap: "wrap",
7425
+ alignItems: "center",
7426
+ gap: 0.5,
7427
+ p: 0.5,
7428
+ borderRadius: 999,
7429
+ border: "1px solid hsl(var(--border))",
7430
+ bgcolor: "hsl(var(--card))",
7431
+ maxWidth: "100%"
7432
+ }, children: [
7433
+ /* @__PURE__ */ jsxs12(
7434
+ Box11,
7435
+ {
7436
+ component: "button",
7437
+ type: "button",
7438
+ onClick: () => setAppSearchOpen(true),
7439
+ sx: {
7440
+ all: "unset",
7441
+ cursor: "pointer",
7442
+ display: "inline-flex",
7443
+ alignItems: "center",
7444
+ gap: 0.5,
7445
+ px: 1.5,
7446
+ py: 0.5,
7447
+ borderRadius: 999,
7448
+ fontSize: "0.8rem",
7449
+ fontWeight: 500,
7450
+ color: "hsl(var(--muted-foreground))",
7451
+ bgcolor: "transparent",
7452
+ transition: "color 0.12s ease, background-color 0.12s ease",
7453
+ "&:hover": { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted) / 0.5)" }
7454
+ },
7455
+ children: [
7456
+ /* @__PURE__ */ jsx14(AddIcon2, { sx: { fontSize: 14 } }),
7457
+ appPickerLabel
7458
+ ]
7459
+ }
7460
+ ),
7461
+ chosenApps.map((app, i) => /* @__PURE__ */ jsxs12(
7462
+ Box11,
7463
+ {
7464
+ sx: {
7465
+ display: "inline-flex",
7466
+ alignItems: "center",
7467
+ gap: 0.5,
7468
+ pl: 0.5,
7469
+ pr: 0.75,
7470
+ py: 0.25,
7471
+ borderRadius: 999,
7472
+ bgcolor: "hsl(var(--muted) / 0.6)",
7473
+ fontSize: "0.8rem",
7474
+ color: "hsl(var(--foreground))"
7475
+ },
7476
+ children: [
7477
+ /* @__PURE__ */ jsx14(
7478
+ Avatar6,
7479
+ {
7480
+ src: app.icon || void 0,
7481
+ alt: app.name,
7482
+ variant: "rounded",
7483
+ sx: { width: 18, height: 18, bgcolor: "transparent" }
7484
+ }
7485
+ ),
7486
+ /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.8rem", mx: 0.25, textTransform: "capitalize" }, children: app.name.replace(/_/g, " ") }),
7487
+ /* @__PURE__ */ jsx14(
7488
+ IconButton6,
7489
+ {
7490
+ size: "small",
7491
+ onClick: () => setChosenApps((prev) => prev.filter((_, idx) => idx !== i)),
7492
+ sx: { p: 0.125, color: "hsl(var(--muted-foreground))", "&:hover": { color: "hsl(var(--destructive))" } },
7493
+ children: /* @__PURE__ */ jsx14(CloseIcon4, { sx: { fontSize: 12 } })
7494
+ }
7495
+ )
7496
+ ]
7497
+ },
7498
+ `${app.name}-${i}`
7499
+ ))
7500
+ ] }) }),
7501
+ error && /* @__PURE__ */ jsx14(Box11, { sx: {
7502
+ width: "100%",
7503
+ p: 1.5,
7504
+ borderRadius: 1.5,
7505
+ border: "1px solid hsl(var(--destructive) / 0.4)",
7506
+ bgcolor: "hsl(var(--destructive) / 0.08)",
7507
+ color: "hsl(var(--destructive))",
7508
+ fontSize: "0.85rem"
7509
+ }, children: error })
7510
+ ]
7511
+ }
7512
+ ) : /* @__PURE__ */ jsxs12(Box11, { children: [
7513
+ /* @__PURE__ */ jsxs12(Box11, { sx: {
7514
+ display: "flex",
7515
+ alignItems: "center",
7516
+ gap: 2,
7517
+ p: 2,
7518
+ borderRadius: 2,
7519
+ border: "1px solid hsl(var(--border))",
7520
+ bgcolor: "hsl(var(--card))",
7521
+ mb: 2
7522
+ }, children: [
7523
+ /* @__PURE__ */ jsxs12(Box11, { sx: { flex: 1, minWidth: 0 }, children: [
7524
+ /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.85rem", color: "hsl(var(--foreground))", fontWeight: 600, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: agentData?.original_input || actionInput || "Agent run" }),
7525
+ /* @__PURE__ */ jsxs12(Typography11, { sx: { fontSize: "0.7rem", color: "hsl(var(--muted-foreground))" }, children: [
7526
+ "Status: ",
7527
+ execution?.status || agentData?.status || "\u2014",
7528
+ " \xB7 ",
7529
+ execution?.execution_id?.slice(0, 8) || ""
7530
+ ] })
7531
+ ] }),
7532
+ /* @__PURE__ */ jsx14(AvatarGroup, { max: 6, sx: { "& .MuiAvatar-root": { width: 28, height: 28, borderColor: "hsl(var(--border))" } }, children: (executionApps.length > 0 ? executionApps : chosenApps).map((app, i) => /* @__PURE__ */ jsx14(Tooltip6, { title: (app.name || "").replace(/_/g, " "), children: /* @__PURE__ */ jsx14(
7533
+ Avatar6,
7534
+ {
7535
+ src: app.icon || void 0,
7536
+ alt: app.name,
7537
+ variant: "rounded",
7538
+ onClick: () => navigate(`/apps/${encodeURIComponent((app.name || "").toLowerCase().replace(/\s+/g, "_"))}`),
7539
+ sx: {
7540
+ bgcolor: "hsl(var(--muted))",
7541
+ cursor: "pointer",
7542
+ transition: "transform 0.15s ease, border-color 0.15s ease",
7543
+ "&:hover": { transform: "scale(1.08)", borderColor: "hsl(var(--primary)) !important" }
7012
7544
  }
7013
- },
7014
- disabled: agentRequestLoading,
7015
- sx: {
7016
- fontSize: "1rem",
7017
- color: "hsl(var(--foreground))",
7018
- "& textarea::placeholder": { color: "hsl(var(--muted-foreground))", opacity: 0.7 }
7019
7545
  }
7546
+ ) }, i)) })
7547
+ ] }),
7548
+ error && /* @__PURE__ */ jsx14(Box11, { sx: {
7549
+ p: 1.5,
7550
+ borderRadius: 1.5,
7551
+ mb: 2,
7552
+ border: "1px solid hsl(var(--destructive) / 0.4)",
7553
+ bgcolor: "hsl(var(--destructive) / 0.08)",
7554
+ color: "hsl(var(--destructive))",
7555
+ fontSize: "0.85rem"
7556
+ }, children: error }),
7557
+ viewMode === "simple" && /* @__PURE__ */ jsx14(Box11, { sx: {
7558
+ borderRadius: 2,
7559
+ border: "1px solid hsl(var(--border))",
7560
+ bgcolor: "hsl(var(--card))",
7561
+ p: 2.5,
7562
+ display: "flex",
7563
+ flexDirection: "column",
7564
+ gap: 1.5
7565
+ }, children: (() => {
7566
+ const status = (execution?.status || agentData?.status || "EXECUTING").toUpperCase();
7567
+ const decisionCount = (agentData?.decisions || []).length;
7568
+ const isRunning = !["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(status);
7569
+ const rawStartedAt = agentData?.started_at || execution?.started_at || 0;
7570
+ const startedAtSec = rawStartedAt > 1e12 ? Math.floor(rawStartedAt / 1e3) : rawStartedAt;
7571
+ const effectiveStart = startedAtSec || localRunStart || 0;
7572
+ let durationSec = null;
7573
+ if (isRunning && effectiveStart) {
7574
+ durationSec = Math.max(0, nowTick - effectiveStart);
7575
+ } else if (totalDuration && totalDuration > 0) {
7576
+ durationSec = Math.round(totalDuration);
7020
7577
  }
7021
- ),
7022
- /* @__PURE__ */ jsx14(
7023
- "input",
7024
- {
7025
- ref: fileInputRef,
7026
- type: "file",
7027
- accept: "image/*",
7028
- multiple: true,
7029
- style: { display: "none" },
7030
- onChange: (e) => {
7031
- handleImagesSelected(e.target.files);
7032
- if (e.target) e.target.value = "";
7578
+ const pendingAsk = (agentData?.decisions || []).slice().reverse().find((d) => {
7579
+ const isAsk = d.category === "ask" || d.action === "ask";
7580
+ const st = (d.run_details?.status || "").toUpperCase();
7581
+ return isAsk && (st === "RUNNING" || st === "WAITING");
7582
+ });
7583
+ const pendingQuestions = [];
7584
+ if (pendingAsk) {
7585
+ for (const f of pendingAsk.fields || []) {
7586
+ if (f.key === "question" && f.value) {
7587
+ pendingQuestions.push({ question: f.value, index: pendingQuestions.length + 1 });
7588
+ }
7033
7589
  }
7034
7590
  }
7035
- ),
7036
- !hideAttach && /* @__PURE__ */ jsx14(
7037
- IconButton6,
7038
- {
7039
- type: "button",
7040
- onClick: () => fileInputRef.current?.click(),
7041
- disabled: agentRequestLoading,
7042
- title: attachedImages.length > 0 ? `Add image (${attachedImages.length} attached)` : "Attach image",
7043
- sx: {
7044
- width: 36,
7045
- height: 36,
7046
- color: attachedImages.length > 0 ? "hsl(var(--primary))" : "hsl(var(--muted-foreground))",
7047
- bgcolor: attachedImages.length > 0 ? "hsla(var(--primary) / 0.1)" : "transparent",
7048
- "&:hover": { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted))" }
7049
- },
7050
- children: /* @__PURE__ */ jsx14(AttachFileIcon, { sx: { fontSize: 18 } })
7591
+ const pendingAnswered = pendingQuestions.every((q) => questionAnswers[q.question]?.value);
7592
+ return /* @__PURE__ */ jsxs12(Fragment7, { children: [
7593
+ /* @__PURE__ */ jsxs12(Box11, { sx: { display: "flex", alignItems: "center", gap: 1, flexWrap: "wrap" }, children: [
7594
+ isRunning ? /* @__PURE__ */ jsx14(CircularProgress4, { size: 16, sx: { color: "hsl(var(--primary))" } }) : status === "FINISHED" ? /* @__PURE__ */ jsx14(CheckCircleIcon3, { sx: { fontSize: 18, color: "hsl(142 70% 45%)" } }) : /* @__PURE__ */ jsx14(ErrorIcon, { sx: { fontSize: 18, color: "hsl(var(--destructive))" } }),
7595
+ /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.9rem", fontWeight: 600, color: "hsl(var(--foreground))" }, children: isRunning ? "Agent is working\u2026" : status === "FINISHED" ? "Run finished" : `Run ${status.toLowerCase()}` }),
7596
+ /* @__PURE__ */ jsxs12(Typography11, { sx: { fontSize: "0.75rem", color: "hsl(var(--muted-foreground))" }, children: [
7597
+ decisionCount,
7598
+ " step",
7599
+ decisionCount === 1 ? "" : "s",
7600
+ durationSec != null ? ` \xB7 ${durationSec}s` : ""
7601
+ ] })
7602
+ ] }),
7603
+ finishAnswer ? /* @__PURE__ */ jsx14(Box11, { sx: {
7604
+ p: 2,
7605
+ borderRadius: 1.5,
7606
+ border: "1px solid hsl(var(--border))",
7607
+ bgcolor: "hsl(var(--background))",
7608
+ fontSize: "0.9rem",
7609
+ color: "hsl(var(--foreground))",
7610
+ "& > *:first-of-type": { mt: 0 },
7611
+ "& > *:last-child": { mb: 0 },
7612
+ "& p": { my: 1, lineHeight: 1.55 },
7613
+ "& h1, & h2, & h3, & h4": { mt: 2, mb: 1, fontWeight: 600, lineHeight: 1.3 },
7614
+ "& h1": { fontSize: "1.15rem" },
7615
+ "& h2": { fontSize: "1.05rem" },
7616
+ "& h3, & h4": { fontSize: "0.95rem" },
7617
+ "& ul": { my: 1, pl: 3, listStyleType: "disc", listStylePosition: "outside" },
7618
+ "& ol": { my: 1, pl: 3, listStyleType: "decimal", listStylePosition: "outside" },
7619
+ "& ul ul": { listStyleType: "circle" },
7620
+ "& ul ul ul": { listStyleType: "square" },
7621
+ "& li": { my: 0.25, display: "list-item" },
7622
+ "& li::marker": { color: "hsl(var(--muted-foreground))" },
7623
+ "& a": { color: "hsl(var(--primary))", textDecoration: "underline" },
7624
+ "& code": {
7625
+ px: 0.5,
7626
+ py: 0.125,
7627
+ borderRadius: 0.5,
7628
+ bgcolor: "hsl(var(--muted))",
7629
+ fontFamily: '"JetBrains Mono", ui-monospace, monospace',
7630
+ fontSize: "0.82em"
7631
+ },
7632
+ "& pre": {
7633
+ p: 1.5,
7634
+ my: 1,
7635
+ borderRadius: 1,
7636
+ bgcolor: "hsl(var(--muted))",
7637
+ overflowX: "auto",
7638
+ fontSize: "0.82rem"
7639
+ },
7640
+ "& pre code": { p: 0, bgcolor: "transparent" },
7641
+ "& blockquote": {
7642
+ borderLeft: "3px solid hsl(var(--border))",
7643
+ pl: 1.5,
7644
+ my: 1,
7645
+ color: "hsl(var(--muted-foreground))"
7646
+ },
7647
+ "& table": { borderCollapse: "collapse", my: 1, fontSize: "0.85rem" },
7648
+ "& th, & td": { border: "1px solid hsl(var(--border))", px: 1, py: 0.5 },
7649
+ "& hr": { border: 0, borderTop: "1px solid hsl(var(--border))", my: 1.5 }
7650
+ }, children: /* @__PURE__ */ jsx14(Markdown, { remarkPlugins: [remarkGfm4, remarkBreaks], children: normalizeMarkdown(finishAnswer) }) }) : pendingAsk && pendingQuestions.length > 0 ? (() => {
7651
+ const trySimpleSubmit = () => {
7652
+ if (agentRequestLoading) return;
7653
+ if (!pendingAnswered) {
7654
+ setSimpleSubmitAttempted(true);
7655
+ return;
7656
+ }
7657
+ if (pendingAsk.run_details?.id) {
7658
+ submitQuestions(pendingAsk.run_details.id, questionAnswers);
7659
+ }
7660
+ };
7661
+ return /* @__PURE__ */ jsxs12(Box11, { sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: [
7662
+ pendingQuestions.map((q, qi) => {
7663
+ const value = questionAnswers[q.question]?.value || "";
7664
+ const isMissing = simpleSubmitAttempted && !value;
7665
+ return /* @__PURE__ */ jsxs12(Box11, { children: [
7666
+ /* @__PURE__ */ jsx14(Box11, { sx: { fontSize: "0.9rem", color: "hsl(var(--foreground))", mb: 1, "& p": { my: 0.5 } }, children: /* @__PURE__ */ jsx14(Markdown, { remarkPlugins: [remarkGfm4, remarkBreaks], children: normalizeMarkdown(q.question) }) }),
7667
+ /* @__PURE__ */ jsx14(
7668
+ TextField4,
7669
+ {
7670
+ fullWidth: true,
7671
+ multiline: true,
7672
+ minRows: 2,
7673
+ placeholder: "Your answer here\u2026",
7674
+ value,
7675
+ error: isMissing,
7676
+ helperText: isMissing ? "Please answer this question" : void 0,
7677
+ onChange: (e) => {
7678
+ const v = e.target.value;
7679
+ setQuestionAnswers((prev) => ({
7680
+ ...prev,
7681
+ [q.question]: { index: qi, value: v }
7682
+ }));
7683
+ },
7684
+ onKeyDown: (e) => {
7685
+ if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
7686
+ e.preventDefault();
7687
+ trySimpleSubmit();
7688
+ }
7689
+ },
7690
+ size: "small",
7691
+ sx: { "& .MuiOutlinedInput-root": { bgcolor: "hsl(var(--background))" } }
7692
+ }
7693
+ )
7694
+ ] }, qi);
7695
+ }),
7696
+ /* @__PURE__ */ jsxs12(Box11, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
7697
+ /* @__PURE__ */ jsx14(
7698
+ Button5,
7699
+ {
7700
+ variant: "contained",
7701
+ size: "small",
7702
+ disabled: agentRequestLoading,
7703
+ onClick: trySimpleSubmit,
7704
+ children: agentRequestLoading ? /* @__PURE__ */ jsx14(CircularProgress4, { size: 16 }) : "Submit"
7705
+ }
7706
+ ),
7707
+ pendingAsk.run_details?.id && getFormUrl(pendingAsk.run_details.id) && /* @__PURE__ */ jsx14(Tooltip6, { title: "Answer in the Form UI", placement: "right", children: /* @__PURE__ */ jsx14(
7708
+ IconButton6,
7709
+ {
7710
+ size: "small",
7711
+ onClick: () => {
7712
+ const url = getFormUrl(pendingAsk.run_details.id);
7713
+ if (url) window.open(url, "_blank", "noopener,noreferrer");
7714
+ },
7715
+ sx: { color: "hsl(var(--muted-foreground))", "&:hover": { color: "hsl(var(--primary))" } },
7716
+ children: /* @__PURE__ */ jsx14(OpenInNewIcon2, { sx: { fontSize: 18 } })
7717
+ }
7718
+ ) })
7719
+ ] })
7720
+ ] });
7721
+ })() : isRunning ? /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.85rem", color: "hsl(var(--muted-foreground))" }, children: "Waiting for the agent to produce the first step." }) : /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.85rem", color: "hsl(var(--muted-foreground))" }, children: "No final answer was returned. Open Detailed to inspect each step." }),
7722
+ !isRunning && /* @__PURE__ */ jsx14(Box11, { children: /* @__PURE__ */ jsx14(
7723
+ Button5,
7724
+ {
7725
+ size: "small",
7726
+ variant: "text",
7727
+ onClick: () => setViewMode("detailed"),
7728
+ sx: { color: "hsl(var(--primary))", textTransform: "none", px: 0 },
7729
+ children: "View detailed timeline \u2192"
7730
+ }
7731
+ ) })
7732
+ ] });
7733
+ })() }),
7734
+ viewMode === "detailed" && (() => {
7735
+ const detailedStatus = (execution?.status || agentData?.status || "EXECUTING").toUpperCase();
7736
+ const detailedIsRunning = !["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(detailedStatus);
7737
+ const detailedRunFinished = !detailedIsRunning;
7738
+ return /* @__PURE__ */ jsx14(Box11, { sx: {
7739
+ borderRadius: 2,
7740
+ border: "1px solid hsl(var(--border))",
7741
+ bgcolor: "hsl(var(--card))",
7742
+ overflow: "hidden"
7743
+ }, children: timeline.length === 0 || timeline.length === 1 && agentRequestLoading ? /* @__PURE__ */ jsxs12(Box11, { sx: { p: 4, textAlign: "center", color: "hsl(var(--muted-foreground))", fontSize: "0.85rem" }, children: [
7744
+ /* @__PURE__ */ jsx14(CircularProgress4, { size: 20, sx: { mb: 1 } }),
7745
+ /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.85rem" }, children: "Waiting for agent response\u2026" })
7746
+ ] }) : /* @__PURE__ */ jsxs12(Fragment7, { children: [
7747
+ timeline.map((item, i) => /* @__PURE__ */ jsx14(
7748
+ TimelineRow,
7749
+ {
7750
+ item,
7751
+ index: i,
7752
+ open: openIndexes.has(i),
7753
+ onToggle: () => toggleOpen(i),
7754
+ appsById,
7755
+ totalDuration,
7756
+ originalStartTime,
7757
+ maxWidth: 210,
7758
+ questionAnswers,
7759
+ setQuestionAnswers,
7760
+ onSubmitQuestions: submitQuestions,
7761
+ onRerunAgent: rerunAgent,
7762
+ onRerunDecision: rerunDecision,
7763
+ agentRequestLoading,
7764
+ getFormUrl,
7765
+ runFinished: detailedRunFinished
7766
+ },
7767
+ i
7768
+ )),
7769
+ detailedRunFinished && /* @__PURE__ */ jsxs12(Box11, { sx: {
7770
+ borderTop: "1px solid hsl(var(--border))",
7771
+ p: 2.5,
7772
+ display: "flex",
7773
+ flexDirection: "column",
7774
+ gap: 1.5,
7775
+ bgcolor: "hsl(var(--muted) / 0.2)"
7776
+ }, children: [
7777
+ /* @__PURE__ */ jsxs12(Box11, { sx: { display: "flex", alignItems: "center", gap: 1, flexWrap: "wrap" }, children: [
7778
+ detailedStatus === "FINISHED" ? /* @__PURE__ */ jsx14(CheckCircleIcon3, { sx: { fontSize: 18, color: "hsl(142 70% 45%)" } }) : /* @__PURE__ */ jsx14(ErrorIcon, { sx: { fontSize: 18, color: "hsl(var(--destructive))" } }),
7779
+ /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.9rem", fontWeight: 600, color: "hsl(var(--foreground))" }, children: detailedStatus === "FINISHED" ? "Run finished" : `Run ${detailedStatus.toLowerCase()}` })
7780
+ ] }),
7781
+ finishAnswer && /* @__PURE__ */ jsx14(Box11, { sx: {
7782
+ p: 2,
7783
+ borderRadius: 1.5,
7784
+ border: "1px solid hsl(var(--border))",
7785
+ bgcolor: "hsl(var(--background))",
7786
+ fontSize: "0.9rem",
7787
+ color: "hsl(var(--foreground))",
7788
+ "& > *:first-of-type": { mt: 0 },
7789
+ "& > *:last-child": { mb: 0 },
7790
+ "& p": { my: 1, lineHeight: 1.55 },
7791
+ "& a": { color: "hsl(var(--primary))", textDecoration: "underline" },
7792
+ "& code": {
7793
+ px: 0.5,
7794
+ py: 0.125,
7795
+ borderRadius: 0.5,
7796
+ bgcolor: "hsl(var(--muted))",
7797
+ fontFamily: '"JetBrains Mono", ui-monospace, monospace',
7798
+ fontSize: "0.82em"
7799
+ },
7800
+ "& pre": {
7801
+ p: 1.5,
7802
+ my: 1,
7803
+ borderRadius: 1,
7804
+ bgcolor: "hsl(var(--muted))",
7805
+ overflowX: "auto",
7806
+ fontSize: "0.82rem"
7807
+ },
7808
+ "& pre code": { p: 0, bgcolor: "transparent" }
7809
+ }, children: /* @__PURE__ */ jsx14(Markdown, { remarkPlugins: [remarkGfm4, remarkBreaks], children: normalizeMarkdown(finishAnswer) }) })
7810
+ ] })
7811
+ ] }) });
7812
+ })(),
7813
+ finishDecisionId && /* @__PURE__ */ jsx14(Box11, { sx: { mt: 3, display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ jsxs12(Box11, { sx: { width: "100%", maxWidth: 640 }, children: [
7814
+ /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.75rem", color: "hsl(var(--muted-foreground))", mb: 0.75, textAlign: "center" }, children: "Continue this agent run with more details" }),
7815
+ /* @__PURE__ */ jsxs12(
7816
+ Box11,
7817
+ {
7818
+ component: "form",
7819
+ onSubmit: (e) => {
7820
+ e.preventDefault();
7821
+ if (continuationText.trim()) {
7822
+ submitQuestions(finishDecisionId, { continue: continuationText }, true);
7823
+ }
7824
+ },
7825
+ sx: {
7826
+ display: "flex",
7827
+ alignItems: "flex-end",
7828
+ gap: 1,
7829
+ p: 1.25,
7830
+ borderRadius: 999,
7831
+ border: "1.5px solid hsl(var(--border))",
7832
+ bgcolor: "hsl(var(--card))",
7833
+ "&:focus-within": {
7834
+ borderColor: "hsl(var(--primary))",
7835
+ boxShadow: "0 0 0 3px hsla(var(--primary) / 0.12)"
7836
+ }
7837
+ },
7838
+ children: [
7839
+ /* @__PURE__ */ jsx14(
7840
+ InputBase2,
7841
+ {
7842
+ fullWidth: true,
7843
+ multiline: true,
7844
+ minRows: 1,
7845
+ maxRows: 4,
7846
+ placeholder: continuationPlaceholder,
7847
+ value: continuationText,
7848
+ onChange: (e) => setContinuationText(e.target.value),
7849
+ onKeyDown: (e) => {
7850
+ if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
7851
+ e.preventDefault();
7852
+ if (continuationText.trim() && !agentRequestLoading) {
7853
+ submitQuestions(finishDecisionId, { continue: continuationText }, true);
7854
+ }
7855
+ }
7856
+ },
7857
+ disabled: agentRequestLoading,
7858
+ sx: { fontSize: "0.9rem", color: "hsl(var(--foreground))", px: 2 }
7859
+ }
7860
+ ),
7861
+ /* @__PURE__ */ jsx14(
7862
+ IconButton6,
7863
+ {
7864
+ type: "submit",
7865
+ disabled: !continuationText.trim() || agentRequestLoading,
7866
+ sx: {
7867
+ width: 36,
7868
+ height: 36,
7869
+ bgcolor: continuationText.trim() && !agentRequestLoading ? "hsl(var(--primary))" : "hsl(var(--muted))",
7870
+ color: continuationText.trim() && !agentRequestLoading ? "hsl(var(--primary-foreground))" : "hsl(var(--muted-foreground))",
7871
+ "&:hover": continuationText.trim() && !agentRequestLoading ? { filter: "brightness(1.1)", bgcolor: "hsl(var(--primary))" } : {}
7872
+ },
7873
+ children: agentRequestLoading ? /* @__PURE__ */ jsx14(CircularProgress4, { size: 16, sx: { color: "inherit" } }) : /* @__PURE__ */ jsx14(SendIcon, { sx: { fontSize: 18 } })
7874
+ }
7875
+ )
7876
+ ]
7877
+ }
7878
+ )
7879
+ ] }) })
7880
+ ] }),
7881
+ /* @__PURE__ */ jsx14(
7882
+ AppSearchDrawer,
7883
+ {
7884
+ open: appSearchOpen,
7885
+ onClose: () => setAppSearchOpen(false),
7886
+ title: appPickerTitle,
7887
+ subtitle: appPickerSubtitle,
7888
+ onQuickSelect: (app) => {
7889
+ const known = availableApps.find((a) => a.name?.toLowerCase() === app.name?.toLowerCase());
7890
+ setChosenApps(
7891
+ (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 }]
7892
+ );
7051
7893
  }
7052
- ),
7053
- /* @__PURE__ */ jsx14(Tooltip6, { title: submitTooltip, placement: "top", arrow: true, children: /* @__PURE__ */ jsx14("span", { children: /* @__PURE__ */ jsx14(
7054
- IconButton6,
7894
+ }
7895
+ )
7896
+ ]
7897
+ }
7898
+ )
7899
+ }
7900
+ );
7901
+ };
7902
+ var AgentUI_default = AgentUI;
7903
+
7904
+ // AgentRunDrawer.tsx
7905
+ import { useEffect as useEffect9, useRef as useRef7, useState as useState11 } from "react";
7906
+ import {
7907
+ Box as Box12,
7908
+ Drawer as Drawer3,
7909
+ IconButton as IconButton7,
7910
+ Tab,
7911
+ Tabs,
7912
+ Tooltip as Tooltip7,
7913
+ Typography as Typography12
7914
+ } from "@mui/material";
7915
+ import CloseIcon5 from "@mui/icons-material/Close";
7916
+ import { Play, Server, ShieldCheck } from "lucide-react";
7917
+ import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
7918
+ var TAB_ORDER = ["run", "permissions", "localLLM"];
7919
+ var AgentRunDrawer = ({
7920
+ open,
7921
+ onClose,
7922
+ initialTab = "run",
7923
+ permissionsSlot,
7924
+ localLLMSlot,
7925
+ localLLMTabBadge,
7926
+ permissionsDisabled = false,
7927
+ permissionsDisabledTooltip = "Coming soon",
7928
+ agentUIProps,
7929
+ width = 520,
7930
+ title = "Agent",
7931
+ subtitle = "Run actions and manage permissions",
7932
+ className,
7933
+ paperSx,
7934
+ headerSx,
7935
+ tabsSx,
7936
+ bodySx
7937
+ }) => {
7938
+ const [activeTab, setActiveTab] = useState11(initialTab);
7939
+ const prevOpenRef = useRef7(open);
7940
+ useEffect9(() => {
7941
+ if (open && !prevOpenRef.current) setActiveTab(initialTab);
7942
+ prevOpenRef.current = open;
7943
+ }, [open, initialTab]);
7944
+ const visibleTabs = TAB_ORDER.filter((t) => {
7945
+ if (t === "run") return true;
7946
+ if (t === "permissions") return !!permissionsSlot;
7947
+ if (t === "localLLM") return !!localLLMSlot;
7948
+ return false;
7949
+ });
7950
+ const showTabs = visibleTabs.length > 1;
7951
+ const safeActiveTab = visibleTabs.includes(activeTab) ? activeTab : "run";
7952
+ return /* @__PURE__ */ jsxs13(
7953
+ Drawer3,
7954
+ {
7955
+ anchor: "right",
7956
+ open,
7957
+ onClose,
7958
+ slotProps: {
7959
+ paper: {
7960
+ className,
7961
+ sx: [
7962
+ {
7963
+ width: { xs: "100%", sm: width },
7964
+ background: "linear-gradient(180deg, hsl(var(--card)) 0%, hsl(var(--background)) 100%)",
7965
+ borderLeft: "1px solid hsl(var(--border))",
7966
+ boxShadow: "-8px 0 32px hsla(0, 0%, 0%, 0.4)",
7967
+ display: "flex",
7968
+ flexDirection: "column"
7969
+ },
7970
+ ...Array.isArray(paperSx) ? paperSx : paperSx ? [paperSx] : []
7971
+ ]
7972
+ }
7973
+ },
7974
+ children: [
7975
+ /* @__PURE__ */ jsxs13(
7976
+ Box12,
7977
+ {
7978
+ sx: [
7979
+ {
7980
+ px: 3,
7981
+ py: 2.5,
7982
+ display: "flex",
7983
+ alignItems: "center",
7984
+ gap: 2,
7985
+ borderBottom: "1px solid hsl(var(--border))",
7986
+ flexShrink: 0
7987
+ },
7988
+ ...Array.isArray(headerSx) ? headerSx : headerSx ? [headerSx] : []
7989
+ ],
7990
+ children: [
7991
+ /* @__PURE__ */ jsx15(
7992
+ Box12,
7055
7993
  {
7056
- type: "submit",
7057
- disabled: actionInput.trim().length < 3 || agentRequestLoading,
7058
7994
  sx: {
7059
- width: 36,
7060
- height: 36,
7061
- bgcolor: actionInput.trim().length >= 3 ? "hsl(var(--primary))" : "hsl(var(--muted))",
7062
- color: actionInput.trim().length >= 3 ? "hsl(var(--primary-foreground))" : "hsl(var(--muted-foreground))",
7063
- "&:hover": actionInput.trim().length >= 3 ? { filter: "brightness(1.1)", bgcolor: "hsl(var(--primary))" } : {},
7064
- "&.Mui-disabled": { bgcolor: "hsl(var(--muted))", color: "hsl(var(--muted-foreground))" }
7995
+ width: 40,
7996
+ height: 40,
7997
+ borderRadius: "50%",
7998
+ display: "flex",
7999
+ alignItems: "center",
8000
+ justifyContent: "center",
8001
+ background: "hsla(var(--primary) / 0.12)",
8002
+ color: "hsl(var(--primary))",
8003
+ flexShrink: 0
7065
8004
  },
7066
- children: agentRequestLoading ? /* @__PURE__ */ jsx14(CircularProgress4, { size: 16, sx: { color: "inherit" } }) : submitIcon ?? /* @__PURE__ */ jsx14(PlayArrowRoundedIcon2, {})
8005
+ children: /* @__PURE__ */ jsx15(AgentIcon_default, { size: 22 })
7067
8006
  }
7068
- ) }) })
7069
- ] })
7070
- ] }),
7071
- !hideAppPicker && /* @__PURE__ */ jsx14(Box11, { sx: { display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ jsxs12(Box11, { sx: {
7072
- display: "inline-flex",
7073
- flexWrap: "wrap",
7074
- alignItems: "center",
7075
- gap: 0.5,
7076
- p: 0.5,
7077
- borderRadius: 999,
7078
- border: "1px solid hsl(var(--border))",
7079
- bgcolor: "hsl(var(--card))",
7080
- maxWidth: "100%"
7081
- }, children: [
7082
- /* @__PURE__ */ jsxs12(
7083
- Box11,
8007
+ ),
8008
+ /* @__PURE__ */ jsxs13(Box12, { sx: { flex: 1, minWidth: 0 }, children: [
8009
+ /* @__PURE__ */ jsx15(Typography12, { sx: { fontWeight: 600, fontSize: "1.1rem", color: "hsl(var(--foreground))" }, children: title }),
8010
+ /* @__PURE__ */ jsx15(Typography12, { sx: { fontSize: "0.8rem", color: "hsl(var(--muted-foreground))" }, children: subtitle })
8011
+ ] }),
8012
+ /* @__PURE__ */ jsx15(IconButton7, { onClick: onClose, size: "small", sx: { color: "hsl(var(--muted-foreground))" }, children: /* @__PURE__ */ jsx15(CloseIcon5, { fontSize: "small" }) })
8013
+ ]
8014
+ }
8015
+ ),
8016
+ showTabs && /* @__PURE__ */ jsx15(Box12, { sx: { borderBottom: "1px solid hsl(var(--border))", flexShrink: 0 }, children: /* @__PURE__ */ jsxs13(
8017
+ Tabs,
8018
+ {
8019
+ value: safeActiveTab,
8020
+ onChange: (_, v) => setActiveTab(v),
8021
+ sx: [
7084
8022
  {
7085
- component: "button",
7086
- type: "button",
7087
- onClick: () => setAppSearchOpen(true),
7088
- sx: {
7089
- all: "unset",
7090
- cursor: "pointer",
7091
- display: "inline-flex",
7092
- alignItems: "center",
7093
- gap: 0.5,
7094
- px: 1.5,
7095
- py: 0.5,
7096
- borderRadius: 999,
7097
- fontSize: "0.8rem",
8023
+ minHeight: 42,
8024
+ px: 3,
8025
+ "& .MuiTab-root": {
8026
+ minHeight: 42,
8027
+ textTransform: "none",
8028
+ fontSize: "0.85rem",
7098
8029
  fontWeight: 500,
7099
8030
  color: "hsl(var(--muted-foreground))",
7100
- bgcolor: "transparent",
7101
- transition: "color 0.12s ease, background-color 0.12s ease",
7102
- "&:hover": { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted) / 0.5)" }
7103
- },
7104
- children: [
7105
- /* @__PURE__ */ jsx14(AddIcon2, { sx: { fontSize: 14 } }),
7106
- appPickerLabel
7107
- ]
7108
- }
7109
- ),
7110
- chosenApps.map((app, i) => /* @__PURE__ */ jsxs12(
7111
- Box11,
7112
- {
7113
- sx: {
7114
- display: "inline-flex",
7115
- alignItems: "center",
7116
- gap: 0.5,
7117
- pl: 0.5,
7118
- pr: 0.75,
7119
- py: 0.25,
7120
- borderRadius: 999,
7121
- bgcolor: "hsl(var(--muted) / 0.6)",
7122
- fontSize: "0.8rem",
7123
- color: "hsl(var(--foreground))"
8031
+ "&.Mui-selected": { color: "hsl(var(--primary))" }
7124
8032
  },
7125
- children: [
7126
- /* @__PURE__ */ jsx14(
7127
- Avatar6,
7128
- {
7129
- src: app.icon || void 0,
7130
- alt: app.name,
7131
- variant: "rounded",
7132
- sx: { width: 18, height: 18, bgcolor: "transparent" }
7133
- }
7134
- ),
7135
- /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.8rem", mx: 0.25, textTransform: "capitalize" }, children: app.name.replace(/_/g, " ") }),
7136
- /* @__PURE__ */ jsx14(
7137
- IconButton6,
7138
- {
7139
- size: "small",
7140
- onClick: () => setChosenApps((prev) => prev.filter((_, idx) => idx !== i)),
7141
- sx: { p: 0.125, color: "hsl(var(--muted-foreground))", "&:hover": { color: "hsl(var(--destructive))" } },
7142
- children: /* @__PURE__ */ jsx14(CloseIcon4, { sx: { fontSize: 12 } })
7143
- }
7144
- )
7145
- ]
8033
+ "& .MuiTabs-indicator": { bgcolor: "hsl(var(--primary))" }
7146
8034
  },
7147
- `${app.name}-${i}`
7148
- ))
7149
- ] }) }),
7150
- error && /* @__PURE__ */ jsx14(Box11, { sx: {
7151
- width: "100%",
7152
- p: 1.5,
7153
- borderRadius: 1.5,
7154
- border: "1px solid hsl(var(--destructive) / 0.4)",
7155
- bgcolor: "hsl(var(--destructive) / 0.08)",
7156
- color: "hsl(var(--destructive))",
7157
- fontSize: "0.85rem"
7158
- }, children: error })
7159
- ]
8035
+ ...Array.isArray(tabsSx) ? tabsSx : tabsSx ? [tabsSx] : []
8036
+ ],
8037
+ children: [
8038
+ visibleTabs.includes("run") && /* @__PURE__ */ jsx15(
8039
+ Tab,
8040
+ {
8041
+ value: "run",
8042
+ label: "Run",
8043
+ icon: /* @__PURE__ */ jsx15(Play, { size: 14 }),
8044
+ iconPosition: "start",
8045
+ sx: { gap: 0.75 }
8046
+ }
8047
+ ),
8048
+ visibleTabs.includes("permissions") && /* @__PURE__ */ jsx15(
8049
+ Tab,
8050
+ {
8051
+ value: "permissions",
8052
+ label: permissionsDisabled ? /* @__PURE__ */ jsx15(Tooltip7, { title: permissionsDisabledTooltip, arrow: true, children: /* @__PURE__ */ jsx15(Box12, { component: "span", sx: { display: "inline-flex", alignItems: "center" }, children: "Permissions" }) }) : "Permissions",
8053
+ icon: /* @__PURE__ */ jsx15(ShieldCheck, { size: 14 }),
8054
+ iconPosition: "start",
8055
+ disabled: permissionsDisabled,
8056
+ sx: { gap: 0.75 }
8057
+ }
8058
+ ),
8059
+ visibleTabs.includes("localLLM") && /* @__PURE__ */ jsx15(
8060
+ Tab,
8061
+ {
8062
+ value: "localLLM",
8063
+ label: /* @__PURE__ */ jsxs13(Box12, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
8064
+ "Local LLM",
8065
+ localLLMTabBadge
8066
+ ] }),
8067
+ icon: /* @__PURE__ */ jsx15(Server, { size: 14 }),
8068
+ iconPosition: "start",
8069
+ sx: { gap: 0.75 }
8070
+ }
8071
+ )
8072
+ ]
8073
+ }
8074
+ ) }),
8075
+ /* @__PURE__ */ jsxs13(Box12, { sx: [{ flex: 1, overflowY: "auto" }, ...Array.isArray(bodySx) ? bodySx : bodySx ? [bodySx] : []], children: [
8076
+ safeActiveTab === "run" && /* @__PURE__ */ jsx15(Box12, { sx: { px: 2, py: 2 }, children: /* @__PURE__ */ jsx15(
8077
+ AgentUI_default,
8078
+ {
8079
+ compact: true,
8080
+ hideHeroIcon: true,
8081
+ title: "",
8082
+ subtitle: null,
8083
+ ...agentUIProps
8084
+ }
8085
+ ) }),
8086
+ safeActiveTab === "permissions" && permissionsSlot && /* @__PURE__ */ jsx15(Box12, { sx: { px: 3, py: 2.5 }, children: permissionsSlot }),
8087
+ safeActiveTab === "localLLM" && localLLMSlot && /* @__PURE__ */ jsx15(Box12, { sx: { px: 3, py: 2.5 }, children: localLLMSlot })
8088
+ ] })
8089
+ ]
8090
+ }
8091
+ );
8092
+ };
8093
+ var AgentRunDrawer_default = AgentRunDrawer;
8094
+
8095
+ // AgentActivityList.tsx
8096
+ import { useCallback as useCallback9, useEffect as useEffect10, useRef as useRef8, useState as useState12 } from "react";
8097
+ import {
8098
+ Box as Box13,
8099
+ Button as Button6,
8100
+ Chip as Chip8,
8101
+ CircularProgress as CircularProgress5,
8102
+ InputAdornment,
8103
+ TextField as TextField5,
8104
+ Typography as Typography13
8105
+ } from "@mui/material";
8106
+ import SearchIcon from "@mui/icons-material/Search";
8107
+ import {
8108
+ Activity,
8109
+ AlertCircle,
8110
+ CheckCircle,
8111
+ Clock,
8112
+ FileText,
8113
+ Globe,
8114
+ Loader2,
8115
+ Server as Server2,
8116
+ XCircle,
8117
+ Zap
8118
+ } from "lucide-react";
8119
+
8120
+ // agentActivity.ts
8121
+ var resolveUrl = (path, baseUrl) => baseUrl ? `${baseUrl.replace(/\/+$/, "")}${path}` : getApiUrl(path);
8122
+ var resolveHeaders = (apiKey, orgId) => {
8123
+ const h = apiKey ? { Authorization: `Bearer ${apiKey}` } : { ...getAuthHeader() };
8124
+ if (orgId) h["Org-Id"] = orgId;
8125
+ return h;
8126
+ };
8127
+ var searchAgentActivity = async (params = {}) => {
8128
+ const {
8129
+ cursor = "",
8130
+ limit = 50,
8131
+ status = "",
8132
+ startTime = "",
8133
+ endTime = "",
8134
+ suborgRuns = false,
8135
+ apiKey,
8136
+ apiBaseUrl,
8137
+ orgId
8138
+ } = params;
8139
+ const payload = {
8140
+ workflow_id: "AGENT",
8141
+ cursor,
8142
+ limit,
8143
+ status,
8144
+ start_time: startTime,
8145
+ end_time: endTime,
8146
+ suborg_runs: suborgRuns
8147
+ };
8148
+ const response = await fetch(resolveUrl("/api/v1/workflows/search", apiBaseUrl), {
8149
+ method: "POST",
8150
+ credentials: "include",
8151
+ headers: {
8152
+ "Content-Type": "application/json",
8153
+ ...resolveHeaders(apiKey, orgId)
8154
+ },
8155
+ body: JSON.stringify(payload)
8156
+ });
8157
+ if (!response.ok) {
8158
+ throw new Error(`Failed to fetch agent activity: ${response.statusText}`);
8159
+ }
8160
+ const data = await response.json();
8161
+ return {
8162
+ success: data.success ?? false,
8163
+ runs: data.runs || [],
8164
+ cursor: data.cursor || ""
8165
+ };
8166
+ };
8167
+
8168
+ // AgentActivityList.tsx
8169
+ import { Fragment as Fragment8, jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
8170
+ var STATUS_CONFIG = {
8171
+ FINISHED: { icon: /* @__PURE__ */ jsx16(CheckCircle, { size: 16 }), color: "hsl(var(--severity-low, 142 71% 45%))", label: "Completed" },
8172
+ SUCCESS: { icon: /* @__PURE__ */ jsx16(CheckCircle, { size: 16 }), color: "hsl(var(--severity-low, 142 71% 45%))", label: "Completed" },
8173
+ FAILED: { icon: /* @__PURE__ */ jsx16(XCircle, { size: 16 }), color: "hsl(var(--severity-critical, 0 72% 55%))", label: "Failed" },
8174
+ ABORTED: { icon: /* @__PURE__ */ jsx16(XCircle, { size: 16 }), color: "hsl(var(--severity-critical, 0 72% 55%))", label: "Aborted" },
8175
+ EXECUTING: { icon: /* @__PURE__ */ jsx16(Loader2, { size: 16 }), color: "hsl(var(--severity-medium, 38 92% 50%))", label: "Running" },
8176
+ RUNNING: { icon: /* @__PURE__ */ jsx16(Loader2, { size: 16 }), color: "hsl(var(--severity-medium, 38 92% 50%))", label: "Running" },
8177
+ WAITING: { icon: /* @__PURE__ */ jsx16(Clock, { size: 16 }), color: "hsl(var(--severity-info, 217 91% 60%))", label: "Waiting" }
8178
+ };
8179
+ var getRunIcon = (run) => {
8180
+ const src = (run.execution_source || "").toLowerCase();
8181
+ const arg = (run.execution_argument || "").toLowerCase();
8182
+ if (src.includes("schedule") || src.includes("cron")) return /* @__PURE__ */ jsx16(Clock, { size: 18 });
8183
+ if (src.includes("webhook") || src.includes("http")) return /* @__PURE__ */ jsx16(Globe, { size: 18 });
8184
+ if (arg.includes("alert") || arg.includes("detect")) return /* @__PURE__ */ jsx16(Activity, { size: 18 });
8185
+ if (arg.includes("report") || arg.includes("email")) return /* @__PURE__ */ jsx16(FileText, { size: 18 });
8186
+ if (arg.includes("endpoint") || arg.includes("server")) return /* @__PURE__ */ jsx16(Server2, { size: 18 });
8187
+ return /* @__PURE__ */ jsx16(Zap, { size: 18 });
8188
+ };
8189
+ var getRunIconColor = (run) => {
8190
+ const status = (run.status || "").toUpperCase();
8191
+ if (status === "FINISHED" || status === "SUCCESS") return "hsl(var(--severity-low, 142 71% 45%))";
8192
+ if (status === "FAILED" || status === "ABORTED") return "hsl(var(--severity-critical, 0 72% 55%))";
8193
+ if (status === "EXECUTING" || status === "RUNNING") return "hsl(var(--severity-medium, 38 92% 50%))";
8194
+ return "hsl(var(--primary, 24 100% 50%))";
8195
+ };
8196
+ var formatDuration = (run) => {
8197
+ if (run.started_at && run.completed_at) {
8198
+ const startSec = Number(run.started_at);
8199
+ const endSec = Number(run.completed_at);
8200
+ if (!isNaN(startSec) && !isNaN(endSec)) {
8201
+ const ms = (endSec - startSec) * 1e3;
8202
+ if (ms < 1e3) return `${Math.round(ms)}ms`;
8203
+ if (ms < 6e4) return `${(ms / 1e3).toFixed(1)}s`;
8204
+ return `${Math.floor(ms / 6e4)}m ${Math.floor(ms % 6e4 / 1e3)}s`;
8205
+ }
8206
+ }
8207
+ if (run.duration) return `${run.duration.toFixed(1)}s`;
8208
+ return "";
8209
+ };
8210
+ var getTimeAgo = (dateStr) => {
8211
+ try {
8212
+ const ts = isNaN(Number(dateStr)) ? new Date(dateStr).getTime() : Number(dateStr) * 1e3;
8213
+ if (isNaN(ts)) return dateStr;
8214
+ const diffSec = Math.max(0, Math.floor((Date.now() - ts) / 1e3));
8215
+ if (diffSec < 60) return `${diffSec}s ago`;
8216
+ if (diffSec < 3600) return `${Math.floor(diffSec / 60)}m ago`;
8217
+ if (diffSec < 86400) return `${Math.floor(diffSec / 3600)}h ago`;
8218
+ return `${Math.floor(diffSec / 86400)}d ago`;
8219
+ } catch {
8220
+ return dateStr;
8221
+ }
8222
+ };
8223
+ var getRunTitle = (run) => {
8224
+ if (run.workflow?.name) return run.workflow.name;
8225
+ if (run.execution_argument) {
8226
+ try {
8227
+ const parsed = JSON.parse(run.execution_argument);
8228
+ if (parsed.title) return parsed.title;
8229
+ if (parsed.action) return parsed.action;
8230
+ if (parsed.name) return parsed.name;
8231
+ } catch {
8232
+ const clean = run.execution_argument.replace(/[{}"]/g, "").trim();
8233
+ if (clean.length > 0 && clean.length < 80) return clean;
8234
+ }
8235
+ }
8236
+ return `Execution ${run.execution_id?.slice(0, 8) || "\u2014"}`;
8237
+ };
8238
+ var getRunSubtitle = (run) => {
8239
+ if (run.result) {
8240
+ try {
8241
+ const p = JSON.parse(run.result);
8242
+ if (p.output && typeof p.output === "string") {
8243
+ return p.output.length > 120 ? p.output.slice(0, 120) + "\u2026" : p.output;
7160
8244
  }
7161
- ) : /* @__PURE__ */ jsxs12(Box11, { children: [
7162
- /* @__PURE__ */ jsxs12(Box11, { sx: {
7163
- display: "flex",
7164
- alignItems: "center",
7165
- gap: 2,
7166
- p: 2,
7167
- borderRadius: 2,
7168
- border: "1px solid hsl(var(--border))",
7169
- bgcolor: "hsl(var(--card))",
7170
- mb: 2
7171
- }, children: [
7172
- /* @__PURE__ */ jsxs12(Box11, { sx: { flex: 1, minWidth: 0 }, children: [
7173
- /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.85rem", color: "hsl(var(--foreground))", fontWeight: 600, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: agentData?.original_input || actionInput || "Agent run" }),
7174
- /* @__PURE__ */ jsxs12(Typography11, { sx: { fontSize: "0.7rem", color: "hsl(var(--muted-foreground))" }, children: [
7175
- "Status: ",
7176
- execution?.status || agentData?.status || "\u2014",
7177
- " \xB7 ",
7178
- execution?.execution_id?.slice(0, 8) || ""
7179
- ] })
7180
- ] }),
7181
- /* @__PURE__ */ jsx14(AvatarGroup, { max: 6, sx: { "& .MuiAvatar-root": { width: 28, height: 28, borderColor: "hsl(var(--border))" } }, children: chosenApps.map((app, i) => /* @__PURE__ */ jsx14(Tooltip6, { title: app.name.replace(/_/g, " "), children: /* @__PURE__ */ jsx14(
7182
- Avatar6,
8245
+ if (p.original_input && typeof p.original_input === "string") {
8246
+ return p.original_input.length > 120 ? p.original_input.slice(0, 120) + "\u2026" : p.original_input;
8247
+ }
8248
+ if (p.message && typeof p.message === "string") return p.message;
8249
+ } catch {
8250
+ if (run.result.length < 120) return run.result;
8251
+ }
8252
+ }
8253
+ return run.execution_source || "Agent execution";
8254
+ };
8255
+ var AgentRunRow = ({ run, onClick, sx }) => {
8256
+ const statusKey = (run.status || "").toUpperCase();
8257
+ const cfg = STATUS_CONFIG[statusKey] || STATUS_CONFIG.WAITING;
8258
+ const iconColor = getRunIconColor(run);
8259
+ const duration = formatDuration(run);
8260
+ return /* @__PURE__ */ jsxs14(
8261
+ Box13,
8262
+ {
8263
+ onClick,
8264
+ sx: [
8265
+ {
8266
+ borderRadius: 2,
8267
+ border: "1px solid hsl(var(--border))",
8268
+ bgcolor: "hsl(var(--card))",
8269
+ display: "flex",
8270
+ alignItems: "center",
8271
+ gap: 2,
8272
+ px: 2.5,
8273
+ py: 2,
8274
+ cursor: "pointer",
8275
+ transition: "background 0.15s ease, border-color 0.15s ease",
8276
+ "&:hover": {
8277
+ bgcolor: "hsla(var(--muted) / 0.5)",
8278
+ borderColor: "hsl(var(--muted-foreground) / 0.3)"
8279
+ }
8280
+ },
8281
+ ...Array.isArray(sx) ? sx : sx ? [sx] : []
8282
+ ],
8283
+ children: [
8284
+ /* @__PURE__ */ jsx16(
8285
+ Box13,
7183
8286
  {
7184
- src: app.icon || void 0,
7185
- alt: app.name,
7186
- variant: "rounded",
7187
- onClick: () => navigate(`/apps/${encodeURIComponent(app.name.toLowerCase().replace(/\s+/g, "_"))}`),
7188
8287
  sx: {
7189
- bgcolor: "hsl(var(--muted))",
7190
- cursor: "pointer",
7191
- transition: "transform 0.15s ease, border-color 0.15s ease",
7192
- "&:hover": { transform: "scale(1.08)", borderColor: "hsl(var(--primary)) !important" }
7193
- }
8288
+ width: 40,
8289
+ height: 40,
8290
+ borderRadius: "50%",
8291
+ display: "flex",
8292
+ alignItems: "center",
8293
+ justifyContent: "center",
8294
+ bgcolor: `${iconColor}15`,
8295
+ color: iconColor,
8296
+ flexShrink: 0
8297
+ },
8298
+ children: getRunIcon(run)
7194
8299
  }
7195
- ) }, i)) })
7196
- ] }),
7197
- error && /* @__PURE__ */ jsx14(Box11, { sx: {
7198
- p: 1.5,
7199
- borderRadius: 1.5,
7200
- mb: 2,
7201
- border: "1px solid hsl(var(--destructive) / 0.4)",
7202
- bgcolor: "hsl(var(--destructive) / 0.08)",
7203
- color: "hsl(var(--destructive))",
7204
- fontSize: "0.85rem"
7205
- }, children: error }),
7206
- viewMode === "simple" && /* @__PURE__ */ jsx14(Box11, { sx: {
7207
- borderRadius: 2,
7208
- border: "1px solid hsl(var(--border))",
7209
- bgcolor: "hsl(var(--card))",
7210
- p: 2.5,
7211
- display: "flex",
7212
- flexDirection: "column",
7213
- gap: 1.5
7214
- }, children: (() => {
7215
- const status = (execution?.status || agentData?.status || "EXECUTING").toUpperCase();
7216
- const decisionCount = (agentData?.decisions || []).length;
7217
- const isRunning = !["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(status);
7218
- const rawStartedAt = agentData?.started_at || execution?.started_at || 0;
7219
- const startedAtSec = rawStartedAt > 1e12 ? Math.floor(rawStartedAt / 1e3) : rawStartedAt;
7220
- const effectiveStart = startedAtSec || localRunStart || 0;
7221
- let durationSec = null;
7222
- if (isRunning && effectiveStart) {
7223
- durationSec = Math.max(0, nowTick - effectiveStart);
7224
- } else if (totalDuration && totalDuration > 0) {
7225
- durationSec = Math.round(totalDuration);
7226
- }
7227
- const pendingAsk = (agentData?.decisions || []).slice().reverse().find((d) => {
7228
- const isAsk = d.category === "ask" || d.action === "ask";
7229
- const st = (d.run_details?.status || "").toUpperCase();
7230
- return isAsk && (st === "RUNNING" || st === "WAITING");
7231
- });
7232
- const pendingQuestions = [];
7233
- if (pendingAsk) {
7234
- for (const f of pendingAsk.fields || []) {
7235
- if (f.key === "question" && f.value) {
7236
- pendingQuestions.push({ question: f.value, index: pendingQuestions.length + 1 });
8300
+ ),
8301
+ /* @__PURE__ */ jsxs14(Box13, { sx: { flex: 1, minWidth: 0 }, children: [
8302
+ /* @__PURE__ */ jsxs14(Box13, { sx: { display: "flex", alignItems: "center", gap: 1, mb: 0.25 }, children: [
8303
+ /* @__PURE__ */ jsx16(
8304
+ Typography13,
8305
+ {
8306
+ sx: {
8307
+ fontSize: "0.9rem",
8308
+ fontWeight: 500,
8309
+ color: "hsl(var(--foreground))",
8310
+ overflow: "hidden",
8311
+ textOverflow: "ellipsis",
8312
+ whiteSpace: "nowrap"
8313
+ },
8314
+ children: getRunTitle(run)
8315
+ }
8316
+ ),
8317
+ /* @__PURE__ */ jsx16(Box13, { sx: { display: "flex", alignItems: "center", color: cfg.color, flexShrink: 0 }, children: cfg.icon })
8318
+ ] }),
8319
+ /* @__PURE__ */ jsx16(
8320
+ Typography13,
8321
+ {
8322
+ sx: {
8323
+ fontSize: "0.78rem",
8324
+ color: "hsl(var(--muted-foreground))",
8325
+ overflow: "hidden",
8326
+ textOverflow: "ellipsis",
8327
+ whiteSpace: "nowrap"
8328
+ },
8329
+ children: getRunSubtitle(run)
7237
8330
  }
7238
- }
7239
- }
7240
- const pendingAnswered = pendingQuestions.every((q) => questionAnswers[q.question]?.value);
7241
- return /* @__PURE__ */ jsxs12(Fragment7, { children: [
7242
- /* @__PURE__ */ jsxs12(Box11, { sx: { display: "flex", alignItems: "center", gap: 1, flexWrap: "wrap" }, children: [
7243
- isRunning ? /* @__PURE__ */ jsx14(CircularProgress4, { size: 16, sx: { color: "hsl(var(--primary))" } }) : status === "FINISHED" ? /* @__PURE__ */ jsx14(CheckCircleIcon3, { sx: { fontSize: 18, color: "hsl(142 70% 45%)" } }) : /* @__PURE__ */ jsx14(ErrorIcon, { sx: { fontSize: 18, color: "hsl(var(--destructive))" } }),
7244
- /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.9rem", fontWeight: 600, color: "hsl(var(--foreground))" }, children: isRunning ? "Agent is working\u2026" : status === "FINISHED" ? "Run finished" : `Run ${status.toLowerCase()}` }),
7245
- /* @__PURE__ */ jsxs12(Typography11, { sx: { fontSize: "0.75rem", color: "hsl(var(--muted-foreground))" }, children: [
7246
- decisionCount,
7247
- " step",
7248
- decisionCount === 1 ? "" : "s",
7249
- durationSec != null ? ` \xB7 ${durationSec}s` : ""
8331
+ ),
8332
+ /* @__PURE__ */ jsxs14(Box13, { sx: { display: "flex", alignItems: "center", gap: 1, mt: 0.5 }, children: [
8333
+ /* @__PURE__ */ jsx16(Typography13, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.7 }, children: run.started_at ? getTimeAgo(run.started_at) : "\u2014" }),
8334
+ duration && /* @__PURE__ */ jsxs14(Fragment8, { children: [
8335
+ /* @__PURE__ */ jsx16(Typography13, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
8336
+ /* @__PURE__ */ jsx16(Typography13, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.7 }, children: duration })
7250
8337
  ] })
7251
- ] }),
7252
- finishAnswer ? /* @__PURE__ */ jsx14(Box11, { sx: {
7253
- p: 2,
7254
- borderRadius: 1.5,
7255
- border: "1px solid hsl(var(--border))",
7256
- bgcolor: "hsl(var(--background))",
7257
- fontSize: "0.9rem",
7258
- color: "hsl(var(--foreground))",
7259
- "& > *:first-of-type": { mt: 0 },
7260
- "& > *:last-child": { mb: 0 },
7261
- "& p": { my: 1, lineHeight: 1.55 },
7262
- "& h1, & h2, & h3, & h4": { mt: 2, mb: 1, fontWeight: 600, lineHeight: 1.3 },
7263
- "& h1": { fontSize: "1.15rem" },
7264
- "& h2": { fontSize: "1.05rem" },
7265
- "& h3, & h4": { fontSize: "0.95rem" },
7266
- "& ul": { my: 1, pl: 3, listStyleType: "disc", listStylePosition: "outside" },
7267
- "& ol": { my: 1, pl: 3, listStyleType: "decimal", listStylePosition: "outside" },
7268
- "& ul ul": { listStyleType: "circle" },
7269
- "& ul ul ul": { listStyleType: "square" },
7270
- "& li": { my: 0.25, display: "list-item" },
7271
- "& li::marker": { color: "hsl(var(--muted-foreground))" },
7272
- "& a": { color: "hsl(var(--primary))", textDecoration: "underline" },
7273
- "& code": {
7274
- px: 0.5,
7275
- py: 0.125,
7276
- borderRadius: 0.5,
7277
- bgcolor: "hsl(var(--muted))",
7278
- fontFamily: '"JetBrains Mono", ui-monospace, monospace',
7279
- fontSize: "0.82em"
7280
- },
7281
- "& pre": {
7282
- p: 1.5,
7283
- my: 1,
7284
- borderRadius: 1,
7285
- bgcolor: "hsl(var(--muted))",
7286
- overflowX: "auto",
7287
- fontSize: "0.82rem"
7288
- },
7289
- "& pre code": { p: 0, bgcolor: "transparent" },
7290
- "& blockquote": {
7291
- borderLeft: "3px solid hsl(var(--border))",
7292
- pl: 1.5,
7293
- my: 1,
7294
- color: "hsl(var(--muted-foreground))"
7295
- },
7296
- "& table": { borderCollapse: "collapse", my: 1, fontSize: "0.85rem" },
7297
- "& th, & td": { border: "1px solid hsl(var(--border))", px: 1, py: 0.5 },
7298
- "& hr": { border: 0, borderTop: "1px solid hsl(var(--border))", my: 1.5 }
7299
- }, children: /* @__PURE__ */ jsx14(Markdown, { remarkPlugins: [remarkGfm4, remarkBreaks], children: normalizeMarkdown(finishAnswer) }) }) : pendingAsk && pendingQuestions.length > 0 ? (() => {
7300
- const trySimpleSubmit = () => {
7301
- if (agentRequestLoading) return;
7302
- if (!pendingAnswered) {
7303
- setSimpleSubmitAttempted(true);
7304
- return;
8338
+ ] })
8339
+ ] })
8340
+ ]
8341
+ }
8342
+ );
8343
+ };
8344
+ var STATUS_FILTERS = [
8345
+ { label: "All", value: "" },
8346
+ { label: "Completed", value: "FINISHED" },
8347
+ { label: "Running", value: "EXECUTING" },
8348
+ { label: "Failed", value: "ABORTED" }
8349
+ ];
8350
+ var AgentActivityList = ({
8351
+ apiKey,
8352
+ apiBaseUrl,
8353
+ orgId,
8354
+ onRunClick,
8355
+ showSearchBar = true,
8356
+ showStatusChips = true,
8357
+ limit = 50,
8358
+ emptyTitle = "No agent activity found",
8359
+ emptySubtitle = "The agent has not performed any actions yet",
8360
+ className,
8361
+ sx,
8362
+ toolbarSx,
8363
+ rowSx
8364
+ }) => {
8365
+ const [runs, setRuns] = useState12([]);
8366
+ const [cursor, setCursor] = useState12("");
8367
+ const [hasMore, setHasMore] = useState12(false);
8368
+ const [isLoading, setIsLoading] = useState12(false);
8369
+ const [error, setError] = useState12(null);
8370
+ const [statusFilter, setStatusFilter] = useState12("");
8371
+ const [searchQuery, setSearchQuery] = useState12("");
8372
+ const [debouncedQuery, setDebouncedQuery] = useState12("");
8373
+ const debounceRef = useRef8();
8374
+ const updateSearchQuery = useCallback9((q) => {
8375
+ setSearchQuery(q);
8376
+ if (debounceRef.current) clearTimeout(debounceRef.current);
8377
+ debounceRef.current = setTimeout(() => setDebouncedQuery(q), 350);
8378
+ }, []);
8379
+ useEffect10(() => () => {
8380
+ if (debounceRef.current) clearTimeout(debounceRef.current);
8381
+ }, []);
8382
+ const fetchRuns = useCallback9(
8383
+ async (append = false, cursorParam = "") => {
8384
+ setIsLoading(true);
8385
+ setError(null);
8386
+ try {
8387
+ const result = await searchAgentActivity({
8388
+ limit,
8389
+ status: statusFilter,
8390
+ cursor: cursorParam,
8391
+ apiKey,
8392
+ apiBaseUrl,
8393
+ orgId
8394
+ });
8395
+ if (result.success) {
8396
+ setRuns((prev) => append ? [...prev, ...result.runs] : result.runs);
8397
+ setCursor(result.cursor);
8398
+ setHasMore(!!result.cursor && result.runs.length > 0);
8399
+ } else {
8400
+ setError("Failed to fetch agent activity");
8401
+ }
8402
+ } catch (err) {
8403
+ setError(err instanceof Error ? err.message : "Failed to fetch agent activity");
8404
+ } finally {
8405
+ setIsLoading(false);
8406
+ }
8407
+ },
8408
+ [statusFilter, limit, apiKey, apiBaseUrl, orgId]
8409
+ );
8410
+ useEffect10(() => {
8411
+ fetchRuns(false, "");
8412
+ }, [statusFilter, apiKey, apiBaseUrl, orgId]);
8413
+ const loadMore = useCallback9(() => {
8414
+ if (cursor && !isLoading) fetchRuns(true, cursor);
8415
+ }, [cursor, isLoading, fetchRuns]);
8416
+ const filteredRuns = debouncedQuery ? runs.filter((r) => {
8417
+ const hay = [
8418
+ getRunTitle(r),
8419
+ getRunSubtitle(r),
8420
+ r.execution_id,
8421
+ r.execution_source,
8422
+ r.status
8423
+ ].filter(Boolean).join(" ").toLowerCase();
8424
+ return hay.includes(debouncedQuery.toLowerCase());
8425
+ }) : runs;
8426
+ return /* @__PURE__ */ jsxs14(
8427
+ Box13,
8428
+ {
8429
+ className,
8430
+ sx: [{ display: "flex", flexDirection: "column", gap: 2 }, ...Array.isArray(sx) ? sx : sx ? [sx] : []],
8431
+ children: [
8432
+ (showSearchBar || showStatusChips) && /* @__PURE__ */ jsxs14(Box13, { sx: [{ display: "flex", alignItems: "center", gap: 1.5, flexWrap: "wrap" }, ...Array.isArray(toolbarSx) ? toolbarSx : toolbarSx ? [toolbarSx] : []], children: [
8433
+ showSearchBar && /* @__PURE__ */ jsx16(
8434
+ TextField5,
8435
+ {
8436
+ placeholder: "Search results...",
8437
+ size: "small",
8438
+ value: searchQuery,
8439
+ onChange: (e) => updateSearchQuery(e.target.value),
8440
+ slotProps: {
8441
+ input: {
8442
+ startAdornment: /* @__PURE__ */ jsx16(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx16(SearchIcon, { sx: { fontSize: 18, color: "hsl(var(--muted-foreground))" } }) })
8443
+ }
8444
+ },
8445
+ sx: {
8446
+ flex: 1,
8447
+ maxWidth: 280,
8448
+ minWidth: 160,
8449
+ "& .MuiOutlinedInput-root": {
8450
+ bgcolor: "hsl(var(--card))",
8451
+ borderRadius: 1.5,
8452
+ fontSize: "0.85rem",
8453
+ height: 36,
8454
+ "& fieldset": { borderColor: "hsl(var(--border))" },
8455
+ "&:hover fieldset": { borderColor: "hsl(var(--muted-foreground) / 0.3)" },
8456
+ "&.Mui-focused fieldset": { borderColor: "hsl(var(--primary))" }
8457
+ },
8458
+ "& .MuiInputBase-input": { color: "hsl(var(--foreground))" }
7305
8459
  }
7306
- if (pendingAsk.run_details?.id) {
7307
- submitQuestions(pendingAsk.run_details.id, questionAnswers);
8460
+ }
8461
+ ),
8462
+ showStatusChips && STATUS_FILTERS.map((f) => /* @__PURE__ */ jsx16(
8463
+ Chip8,
8464
+ {
8465
+ label: f.label,
8466
+ size: "small",
8467
+ variant: statusFilter === f.value ? "filled" : "outlined",
8468
+ onClick: () => setStatusFilter(f.value),
8469
+ sx: {
8470
+ fontSize: "0.75rem",
8471
+ height: 28,
8472
+ borderColor: statusFilter === f.value ? "hsl(var(--primary))" : "hsl(var(--border))",
8473
+ bgcolor: statusFilter === f.value ? "hsla(var(--primary) / 0.15)" : "transparent",
8474
+ color: statusFilter === f.value ? "hsl(var(--primary))" : "hsl(var(--muted-foreground))",
8475
+ "&:hover": { bgcolor: "hsl(var(--muted))" }
7308
8476
  }
7309
- };
7310
- return /* @__PURE__ */ jsxs12(Box11, { sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: [
7311
- pendingQuestions.map((q, qi) => {
7312
- const value = questionAnswers[q.question]?.value || "";
7313
- const isMissing = simpleSubmitAttempted && !value;
7314
- return /* @__PURE__ */ jsxs12(Box11, { children: [
7315
- /* @__PURE__ */ jsx14(Box11, { sx: { fontSize: "0.9rem", color: "hsl(var(--foreground))", mb: 1, "& p": { my: 0.5 } }, children: /* @__PURE__ */ jsx14(Markdown, { remarkPlugins: [remarkGfm4, remarkBreaks], children: normalizeMarkdown(q.question) }) }),
7316
- /* @__PURE__ */ jsx14(
7317
- TextField4,
7318
- {
7319
- fullWidth: true,
7320
- multiline: true,
7321
- minRows: 2,
7322
- placeholder: "Your answer here\u2026",
7323
- value,
7324
- error: isMissing,
7325
- helperText: isMissing ? "Please answer this question" : void 0,
7326
- onChange: (e) => {
7327
- const v = e.target.value;
7328
- setQuestionAnswers((prev) => ({
7329
- ...prev,
7330
- [q.question]: { index: qi, value: v }
7331
- }));
7332
- },
7333
- onKeyDown: (e) => {
7334
- if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
7335
- e.preventDefault();
7336
- trySimpleSubmit();
7337
- }
7338
- },
7339
- size: "small",
7340
- sx: { "& .MuiOutlinedInput-root": { bgcolor: "hsl(var(--background))" } }
7341
- }
7342
- )
7343
- ] }, qi);
7344
- }),
7345
- /* @__PURE__ */ jsxs12(Box11, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
7346
- /* @__PURE__ */ jsx14(
7347
- Button5,
7348
- {
7349
- variant: "contained",
7350
- size: "small",
7351
- disabled: agentRequestLoading,
7352
- onClick: trySimpleSubmit,
7353
- children: agentRequestLoading ? /* @__PURE__ */ jsx14(CircularProgress4, { size: 16 }) : "Submit"
7354
- }
7355
- ),
7356
- pendingAsk.run_details?.id && getFormUrl(pendingAsk.run_details.id) && /* @__PURE__ */ jsx14(Tooltip6, { title: "Answer in the Form UI", placement: "right", children: /* @__PURE__ */ jsx14(
7357
- IconButton6,
7358
- {
7359
- size: "small",
7360
- onClick: () => {
7361
- const url = getFormUrl(pendingAsk.run_details.id);
7362
- if (url) window.open(url, "_blank", "noopener,noreferrer");
7363
- },
7364
- sx: { color: "hsl(var(--muted-foreground))", "&:hover": { color: "hsl(var(--primary))" } },
7365
- children: /* @__PURE__ */ jsx14(OpenInNewIcon2, { sx: { fontSize: 18 } })
7366
- }
7367
- ) })
7368
- ] })
7369
- ] });
7370
- })() : isRunning ? /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.85rem", color: "hsl(var(--muted-foreground))" }, children: "Waiting for the agent to produce the first step." }) : /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.85rem", color: "hsl(var(--muted-foreground))" }, children: "No final answer was returned. Open Detailed to inspect each step." }),
7371
- !isRunning && /* @__PURE__ */ jsx14(Box11, { children: /* @__PURE__ */ jsx14(
7372
- Button5,
8477
+ },
8478
+ f.value
8479
+ )),
8480
+ isLoading && runs.length > 0 && /* @__PURE__ */ jsx16(CircularProgress5, { size: 16, sx: { color: "hsl(var(--primary))", ml: 0.5 } })
8481
+ ] }),
8482
+ isLoading && runs.length === 0 ? /* @__PURE__ */ jsx16(Box13, { sx: { display: "flex", justifyContent: "center", py: 8 }, children: /* @__PURE__ */ jsx16(CircularProgress5, { size: 28, sx: { color: "hsl(var(--primary))" } }) }) : error ? /* @__PURE__ */ jsxs14(Box13, { sx: { textAlign: "center", py: 6 }, children: [
8483
+ /* @__PURE__ */ jsx16(AlertCircle, { size: 28, style: { color: "hsl(var(--severity-critical, 0 72% 55%))", marginBottom: 8 } }),
8484
+ /* @__PURE__ */ jsx16(
8485
+ Typography13,
8486
+ {
8487
+ sx: { color: "hsl(var(--severity-critical, 0 72% 55%))", fontSize: "0.9rem", mb: 1 },
8488
+ children: error
8489
+ }
8490
+ ),
8491
+ /* @__PURE__ */ jsx16(
8492
+ Button6,
7373
8493
  {
7374
8494
  size: "small",
7375
- variant: "text",
7376
- onClick: () => setViewMode("detailed"),
7377
- sx: { color: "hsl(var(--primary))", textTransform: "none", px: 0 },
7378
- children: "View detailed timeline \u2192"
8495
+ onClick: () => fetchRuns(false, ""),
8496
+ sx: { color: "hsl(var(--primary))", textTransform: "none" },
8497
+ children: "Try again"
7379
8498
  }
7380
- ) })
7381
- ] });
7382
- })() }),
7383
- viewMode === "detailed" && (() => {
7384
- const detailedStatus = (execution?.status || agentData?.status || "EXECUTING").toUpperCase();
7385
- const detailedIsRunning = !["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(detailedStatus);
7386
- const detailedRunFinished = !detailedIsRunning;
7387
- return /* @__PURE__ */ jsx14(Box11, { sx: {
7388
- borderRadius: 2,
7389
- border: "1px solid hsl(var(--border))",
7390
- bgcolor: "hsl(var(--card))",
7391
- overflow: "hidden"
7392
- }, children: timeline.length === 0 || timeline.length === 1 && agentRequestLoading ? /* @__PURE__ */ jsxs12(Box11, { sx: { p: 4, textAlign: "center", color: "hsl(var(--muted-foreground))", fontSize: "0.85rem" }, children: [
7393
- /* @__PURE__ */ jsx14(CircularProgress4, { size: 20, sx: { mb: 1 } }),
7394
- /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.85rem" }, children: "Waiting for agent response\u2026" })
7395
- ] }) : /* @__PURE__ */ jsxs12(Fragment7, { children: [
7396
- timeline.map((item, i) => /* @__PURE__ */ jsx14(
7397
- TimelineRow,
8499
+ )
8500
+ ] }) : filteredRuns.length === 0 ? /* @__PURE__ */ jsxs14(Box13, { sx: { display: "flex", flexDirection: "column", alignItems: "center", textAlign: "center", py: 8 }, children: [
8501
+ /* @__PURE__ */ jsx16(
8502
+ Activity,
8503
+ {
8504
+ size: 40,
8505
+ style: { color: "hsl(var(--muted-foreground))", marginBottom: 12 }
8506
+ }
8507
+ ),
8508
+ /* @__PURE__ */ jsx16(Typography13, { sx: { color: "hsl(var(--muted-foreground))", fontSize: "0.9rem" }, children: emptyTitle }),
8509
+ /* @__PURE__ */ jsx16(
8510
+ Typography13,
7398
8511
  {
7399
- item,
7400
- index: i,
7401
- open: openIndexes.has(i),
7402
- onToggle: () => toggleOpen(i),
7403
- appsById,
7404
- totalDuration,
7405
- originalStartTime,
7406
- maxWidth: 260,
7407
- questionAnswers,
7408
- setQuestionAnswers,
7409
- onSubmitQuestions: submitQuestions,
7410
- onRerunAgent: rerunAgent,
7411
- onRerunDecision: rerunDecision,
7412
- agentRequestLoading,
7413
- getFormUrl,
7414
- runFinished: detailedRunFinished
8512
+ sx: { color: "hsl(var(--muted-foreground))", fontSize: "0.8rem", mt: 0.5, opacity: 0.7 },
8513
+ children: emptySubtitle
8514
+ }
8515
+ )
8516
+ ] }) : /* @__PURE__ */ jsxs14(Box13, { sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: [
8517
+ filteredRuns.map((run, idx) => /* @__PURE__ */ jsx16(
8518
+ AgentRunRow,
8519
+ {
8520
+ run,
8521
+ onClick: () => onRunClick?.(run),
8522
+ sx: rowSx
7415
8523
  },
7416
- i
8524
+ run.execution_id || idx
7417
8525
  )),
7418
- detailedRunFinished && /* @__PURE__ */ jsxs12(Box11, { sx: {
7419
- borderTop: "1px solid hsl(var(--border))",
7420
- p: 2.5,
7421
- display: "flex",
7422
- flexDirection: "column",
7423
- gap: 1.5,
7424
- bgcolor: "hsl(var(--muted) / 0.2)"
7425
- }, children: [
7426
- /* @__PURE__ */ jsxs12(Box11, { sx: { display: "flex", alignItems: "center", gap: 1, flexWrap: "wrap" }, children: [
7427
- detailedStatus === "FINISHED" ? /* @__PURE__ */ jsx14(CheckCircleIcon3, { sx: { fontSize: 18, color: "hsl(142 70% 45%)" } }) : /* @__PURE__ */ jsx14(ErrorIcon, { sx: { fontSize: 18, color: "hsl(var(--destructive))" } }),
7428
- /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.9rem", fontWeight: 600, color: "hsl(var(--foreground))" }, children: detailedStatus === "FINISHED" ? "Run finished" : `Run ${detailedStatus.toLowerCase()}` })
7429
- ] }),
7430
- finishAnswer && /* @__PURE__ */ jsx14(Box11, { sx: {
7431
- p: 2,
7432
- borderRadius: 1.5,
7433
- border: "1px solid hsl(var(--border))",
8526
+ hasMore && /* @__PURE__ */ jsx16(Box13, { sx: { display: "flex", justifyContent: "center", mt: 1 }, children: /* @__PURE__ */ jsxs14(
8527
+ Button6,
8528
+ {
8529
+ size: "small",
8530
+ onClick: loadMore,
8531
+ disabled: isLoading,
8532
+ sx: { color: "hsl(var(--primary))", textTransform: "none", fontSize: "0.8rem" },
8533
+ children: [
8534
+ isLoading ? /* @__PURE__ */ jsx16(CircularProgress5, { size: 14, sx: { mr: 1 } }) : null,
8535
+ "Load more"
8536
+ ]
8537
+ }
8538
+ ) })
8539
+ ] })
8540
+ ]
8541
+ }
8542
+ );
8543
+ };
8544
+ var AgentActivityList_default = AgentActivityList;
8545
+
8546
+ // AgentExecutionDrawer.tsx
8547
+ import { Box as Box14, Drawer as Drawer4, IconButton as IconButton8, Tooltip as Tooltip9, Typography as Typography14 } from "@mui/material";
8548
+ import CloseIcon6 from "@mui/icons-material/Close";
8549
+ import OpenInNewIcon3 from "@mui/icons-material/OpenInNew";
8550
+ import { Fragment as Fragment9, jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
8551
+ var AgentExecutionDrawer = ({
8552
+ open,
8553
+ onClose,
8554
+ run,
8555
+ width = 720,
8556
+ apiKey,
8557
+ apiBaseUrl,
8558
+ orgId,
8559
+ className,
8560
+ paperSx,
8561
+ headerSx,
8562
+ bodySx
8563
+ }) => {
8564
+ const statusKey = (run?.status || "").toUpperCase();
8565
+ const cfg = STATUS_CONFIG[statusKey] || STATUS_CONFIG.WAITING;
8566
+ const duration = run ? formatDuration(run) : "";
8567
+ return /* @__PURE__ */ jsxs15(
8568
+ Drawer4,
8569
+ {
8570
+ anchor: "right",
8571
+ open,
8572
+ onClose,
8573
+ slotProps: {
8574
+ paper: {
8575
+ className,
8576
+ sx: [
8577
+ {
8578
+ width: { xs: "100%", sm: width },
8579
+ maxWidth: "100vw",
7434
8580
  bgcolor: "hsl(var(--background))",
7435
- fontSize: "0.9rem",
7436
8581
  color: "hsl(var(--foreground))",
7437
- "& > *:first-of-type": { mt: 0 },
7438
- "& > *:last-child": { mb: 0 },
7439
- "& p": { my: 1, lineHeight: 1.55 },
7440
- "& a": { color: "hsl(var(--primary))", textDecoration: "underline" },
7441
- "& code": {
7442
- px: 0.5,
7443
- py: 0.125,
7444
- borderRadius: 0.5,
7445
- bgcolor: "hsl(var(--muted))",
7446
- fontFamily: '"JetBrains Mono", ui-monospace, monospace',
7447
- fontSize: "0.82em"
7448
- },
7449
- "& pre": {
7450
- p: 1.5,
7451
- my: 1,
7452
- borderRadius: 1,
7453
- bgcolor: "hsl(var(--muted))",
7454
- overflowX: "auto",
7455
- fontSize: "0.82rem"
7456
- },
7457
- "& pre code": { p: 0, bgcolor: "transparent" }
7458
- }, children: /* @__PURE__ */ jsx14(Markdown, { remarkPlugins: [remarkGfm4, remarkBreaks], children: normalizeMarkdown(finishAnswer) }) })
7459
- ] })
7460
- ] }) });
7461
- })(),
7462
- finishDecisionId && /* @__PURE__ */ jsx14(Box11, { sx: { mt: 3, display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ jsxs12(Box11, { sx: { width: "100%", maxWidth: 640 }, children: [
7463
- /* @__PURE__ */ jsx14(Typography11, { sx: { fontSize: "0.75rem", color: "hsl(var(--muted-foreground))", mb: 0.75, textAlign: "center" }, children: "Continue this agent run with more details" }),
7464
- /* @__PURE__ */ jsxs12(
7465
- Box11,
7466
- {
7467
- component: "form",
7468
- onSubmit: (e) => {
7469
- e.preventDefault();
7470
- if (continuationText.trim()) {
7471
- submitQuestions(finishDecisionId, { continue: continuationText }, true);
7472
- }
7473
- },
7474
- sx: {
7475
- display: "flex",
7476
- alignItems: "flex-end",
7477
- gap: 1,
7478
- p: 1.25,
7479
- borderRadius: 999,
7480
- border: "1.5px solid hsl(var(--border))",
7481
- bgcolor: "hsl(var(--card))",
7482
- "&:focus-within": {
7483
- borderColor: "hsl(var(--primary))",
7484
- boxShadow: "0 0 0 3px hsla(var(--primary) / 0.12)"
7485
- }
8582
+ backgroundImage: "none",
8583
+ borderLeft: "1px solid hsl(var(--border))"
7486
8584
  },
8585
+ ...Array.isArray(paperSx) ? paperSx : paperSx ? [paperSx] : []
8586
+ ]
8587
+ }
8588
+ },
8589
+ children: [
8590
+ /* @__PURE__ */ jsxs15(
8591
+ Box14,
8592
+ {
8593
+ sx: [
8594
+ {
8595
+ display: "flex",
8596
+ alignItems: "center",
8597
+ gap: 1.5,
8598
+ px: 2.5,
8599
+ py: 1.75,
8600
+ borderBottom: "1px solid hsl(var(--border))",
8601
+ position: "sticky",
8602
+ top: 0,
8603
+ zIndex: 2,
8604
+ bgcolor: "hsl(var(--background))"
8605
+ },
8606
+ ...Array.isArray(headerSx) ? headerSx : headerSx ? [headerSx] : []
8607
+ ],
7487
8608
  children: [
7488
- /* @__PURE__ */ jsx14(
7489
- InputBase2,
8609
+ /* @__PURE__ */ jsx17(
8610
+ Box14,
7490
8611
  {
7491
- fullWidth: true,
7492
- multiline: true,
7493
- minRows: 1,
7494
- maxRows: 4,
7495
- placeholder: continuationPlaceholder,
7496
- value: continuationText,
7497
- onChange: (e) => setContinuationText(e.target.value),
7498
- onKeyDown: (e) => {
7499
- if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
7500
- e.preventDefault();
7501
- if (continuationText.trim() && !agentRequestLoading) {
7502
- submitQuestions(finishDecisionId, { continue: continuationText }, true);
7503
- }
7504
- }
8612
+ sx: {
8613
+ width: 36,
8614
+ height: 36,
8615
+ borderRadius: "50%",
8616
+ display: "flex",
8617
+ alignItems: "center",
8618
+ justifyContent: "center",
8619
+ background: "hsla(var(--primary) / 0.12)",
8620
+ color: "hsl(var(--primary))",
8621
+ flexShrink: 0
7505
8622
  },
7506
- disabled: agentRequestLoading,
7507
- sx: { fontSize: "0.9rem", color: "hsl(var(--foreground))", px: 2 }
8623
+ children: /* @__PURE__ */ jsx17(AgentIcon_default, { size: 20 })
7508
8624
  }
7509
8625
  ),
7510
- /* @__PURE__ */ jsx14(
7511
- IconButton6,
8626
+ /* @__PURE__ */ jsxs15(Box14, { sx: { flex: 1, minWidth: 0 }, children: [
8627
+ /* @__PURE__ */ jsxs15(Box14, { sx: { display: "flex", alignItems: "center", gap: 1, minWidth: 0 }, children: [
8628
+ /* @__PURE__ */ jsx17(
8629
+ Typography14,
8630
+ {
8631
+ sx: {
8632
+ fontSize: "0.95rem",
8633
+ fontWeight: 600,
8634
+ color: "hsl(var(--foreground))",
8635
+ overflow: "hidden",
8636
+ textOverflow: "ellipsis",
8637
+ whiteSpace: "nowrap"
8638
+ },
8639
+ children: run ? getRunTitle(run) : "Agent execution"
8640
+ }
8641
+ ),
8642
+ run && /* @__PURE__ */ jsx17(Box14, { sx: { display: "flex", alignItems: "center", color: cfg.color, flexShrink: 0 }, children: cfg.icon })
8643
+ ] }),
8644
+ run && /* @__PURE__ */ jsxs15(Box14, { sx: { display: "flex", alignItems: "center", gap: 1, mt: 0.25 }, children: [
8645
+ /* @__PURE__ */ jsx17(Typography14, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: cfg.label }),
8646
+ run.started_at && /* @__PURE__ */ jsxs15(Fragment9, { children: [
8647
+ /* @__PURE__ */ jsx17(Typography14, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
8648
+ /* @__PURE__ */ jsx17(Typography14, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: getTimeAgo(run.started_at) })
8649
+ ] }),
8650
+ duration && /* @__PURE__ */ jsxs15(Fragment9, { children: [
8651
+ /* @__PURE__ */ jsx17(Typography14, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
8652
+ /* @__PURE__ */ jsx17(Typography14, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: duration })
8653
+ ] })
8654
+ ] })
8655
+ ] }),
8656
+ run?.execution_id && /* @__PURE__ */ jsx17(Tooltip9, { title: "Open in new tab", children: /* @__PURE__ */ jsx17(
8657
+ IconButton8,
7512
8658
  {
7513
- type: "submit",
7514
- disabled: !continuationText.trim() || agentRequestLoading,
8659
+ component: "a",
8660
+ href: `/agents?execution_id=${encodeURIComponent(run.execution_id)}${run.authorization ? `&authorization=${encodeURIComponent(run.authorization)}` : ""}`,
8661
+ target: "_blank",
8662
+ rel: "noopener noreferrer",
8663
+ size: "small",
7515
8664
  sx: {
7516
- width: 36,
7517
- height: 36,
7518
- bgcolor: continuationText.trim() && !agentRequestLoading ? "hsl(var(--primary))" : "hsl(var(--muted))",
7519
- color: continuationText.trim() && !agentRequestLoading ? "hsl(var(--primary-foreground))" : "hsl(var(--muted-foreground))",
7520
- "&:hover": continuationText.trim() && !agentRequestLoading ? { filter: "brightness(1.1)", bgcolor: "hsl(var(--primary))" } : {}
8665
+ color: "hsl(var(--muted-foreground))",
8666
+ "&:hover": { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted))" }
7521
8667
  },
7522
- children: agentRequestLoading ? /* @__PURE__ */ jsx14(CircularProgress4, { size: 16, sx: { color: "inherit" } }) : /* @__PURE__ */ jsx14(SendIcon, { sx: { fontSize: 18 } })
8668
+ children: /* @__PURE__ */ jsx17(OpenInNewIcon3, { fontSize: "small" })
7523
8669
  }
7524
- )
8670
+ ) }),
8671
+ /* @__PURE__ */ jsx17(Tooltip9, { title: "Close", children: /* @__PURE__ */ jsx17(
8672
+ IconButton8,
8673
+ {
8674
+ onClick: onClose,
8675
+ size: "small",
8676
+ sx: {
8677
+ color: "hsl(var(--muted-foreground))",
8678
+ "&:hover": { color: "hsl(var(--foreground))", bgcolor: "hsl(var(--muted))" }
8679
+ },
8680
+ children: /* @__PURE__ */ jsx17(CloseIcon6, { fontSize: "small" })
8681
+ }
8682
+ ) })
7525
8683
  ]
7526
8684
  }
7527
- )
7528
- ] }) })
7529
- ] }),
7530
- /* @__PURE__ */ jsx14(
7531
- AppSearchDrawer,
7532
- {
7533
- open: appSearchOpen,
7534
- onClose: () => setAppSearchOpen(false),
7535
- title: appPickerTitle,
7536
- subtitle: appPickerSubtitle,
7537
- onQuickSelect: (app) => {
7538
- const known = availableApps.find((a) => a.name?.toLowerCase() === app.name?.toLowerCase());
7539
- setChosenApps(
7540
- (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 }]
7541
- );
7542
- }
7543
- }
7544
- )
7545
- ] }) });
8685
+ ),
8686
+ /* @__PURE__ */ jsx17(Box14, { sx: [{ flex: 1, overflowY: "auto", pt: 3 }, ...Array.isArray(bodySx) ? bodySx : bodySx ? [bodySx] : []], children: run ? /* @__PURE__ */ jsx17(
8687
+ AgentUI_default,
8688
+ {
8689
+ initialExecution: {
8690
+ execution_id: run.execution_id,
8691
+ status: run.status,
8692
+ started_at: run.started_at ? Number(run.started_at) : void 0,
8693
+ completed_at: run.completed_at ? Number(run.completed_at) : void 0,
8694
+ results: run.results,
8695
+ workflow: run.workflow,
8696
+ authorization: run.authorization
8697
+ },
8698
+ readUrlParams: false,
8699
+ autoLoadApps: false,
8700
+ hideHeroIcon: true,
8701
+ hideAppPicker: true,
8702
+ hideAttach: true,
8703
+ disableStartTab: true,
8704
+ compact: true,
8705
+ maxWidth: width - 32,
8706
+ apiKey,
8707
+ apiBaseUrl,
8708
+ orgId
8709
+ },
8710
+ run.execution_id
8711
+ ) : null })
8712
+ ]
8713
+ }
8714
+ );
7546
8715
  };
7547
- var AgentUI_default = AgentUI;
8716
+ var AgentExecutionDrawer_default = AgentExecutionDrawer;
7548
8717
 
7549
8718
  // useAppLookup.ts
7550
- import { useEffect as useEffect8, useMemo as useMemo6, useState as useState11 } from "react";
8719
+ import { useEffect as useEffect11, useMemo as useMemo6, useState as useState13 } from "react";
7551
8720
  var norm = (s) => s.toLowerCase().replace(/[\s_\-]+/g, "_");
7552
8721
  function useAppLookup(appName) {
7553
- const [loading, setLoading] = useState11(false);
7554
- const [info, setInfo] = useState11(null);
7555
- const [algoliaId, setAlgoliaId] = useState11(null);
8722
+ const [loading, setLoading] = useState13(false);
8723
+ const [info, setInfo] = useState13(null);
8724
+ const [algoliaId, setAlgoliaId] = useState13(null);
7556
8725
  const {
7557
8726
  authStates,
7558
8727
  authenticatedApps,
@@ -7561,7 +8730,7 @@ function useAppLookup(appName) {
7561
8730
  handleSaveAuth,
7562
8731
  refreshAuth
7563
8732
  } = useAppAuth();
7564
- useEffect8(() => {
8733
+ useEffect11(() => {
7565
8734
  if (!appName) {
7566
8735
  setInfo(null);
7567
8736
  setAlgoliaId(null);
@@ -7598,14 +8767,8 @@ function useAppLookup(appName) {
7598
8767
  let appsList = null;
7599
8768
  if (API_CONFIG.apiKey) {
7600
8769
  try {
7601
- const res = await fetch(getApiUrl("/api/v1/apps"), {
7602
- credentials: "include",
7603
- headers: { ...getAuthHeader() }
7604
- });
7605
- if (res.ok) {
7606
- const apps = await res.json();
7607
- if (Array.isArray(apps)) appsList = apps;
7608
- }
8770
+ const apps = await fetchAppsViaApiConfig();
8771
+ if (Array.isArray(apps)) appsList = apps;
7609
8772
  } catch {
7610
8773
  }
7611
8774
  }
@@ -7692,6 +8855,9 @@ function useAppLookup(appName) {
7692
8855
  }
7693
8856
  export {
7694
8857
  API_CONFIG,
8858
+ AgentActivityList_default as AgentActivityList,
8859
+ AgentExecutionDrawer_default as AgentExecutionDrawer,
8860
+ AgentRunDrawer_default as AgentRunDrawer,
7695
8861
  AgentUI_default as AgentUI,
7696
8862
  AppAuthSection,
7697
8863
  AppDetailDrawer,
@@ -7707,6 +8873,7 @@ export {
7707
8873
  getApiUrl,
7708
8874
  getAuthHeader,
7709
8875
  refreshAllIntegrationStatus,
8876
+ searchAgentActivity,
7710
8877
  setToastImpl,
7711
8878
  toast,
7712
8879
  useAppAuth,