@shuffleio/shuffle-mcps 0.0.65 → 0.0.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -615,6 +615,86 @@ var acquireDatastoreSlot = (priority = false) => new Promise((resolve) => {
615
615
  pump();
616
616
  });
617
617
 
618
+ // ../Shuffle-Core/securityRulesGuard.ts
619
+ import { toast } from "sonner";
620
+ var GUARDED_CATEGORIES = /* @__PURE__ */ new Set([
621
+ "shuffle-security_incidents",
622
+ "shuffle-security_vulns"
623
+ ]);
624
+ var DEFAULT_RULE = "merge if always; deny if has_deleted_field";
625
+ var NAME = "Security Rules";
626
+ var DESCRIPTION = "Describes security rules that are validated BEFORE an update occurs. This is in order for bad writes to be avoided. Control: allow, deny, merge, overwrite. Logic: if, or, and. Functions: same_shape, is_superset, has_deleted_field";
627
+ var TTL_MS = 5 * 60 * 1e3;
628
+ var verifiedAt = /* @__PURE__ */ new Map();
629
+ var inFlight = /* @__PURE__ */ new Map();
630
+ var warned = /* @__PURE__ */ new Set();
631
+ var buildUrl = (path, regionUrl) => regionUrl ? `${regionUrl.replace(/\/+$/, "")}${path}` : getApiUrl(path);
632
+ var run = async (orgId, category, regionUrl) => {
633
+ const headers = {
634
+ "Content-Type": "application/json",
635
+ ...getAuthHeader(orgId),
636
+ "Org-Id": orgId
637
+ };
638
+ const res = await fetch(
639
+ buildUrl(`/api/v1/orgs/${orgId}/list_cache?category=${encodeURIComponent(category)}&top=1`, regionUrl),
640
+ { credentials: "include", headers }
641
+ );
642
+ if (!res.ok) throw new Error(`list_cache responded with ${res.status}`);
643
+ const data = await res.json().catch(() => ({}));
644
+ const cfg = data?.category_config || {};
645
+ const automations = Array.isArray(cfg.automations) ? cfg.automations.map((a) => ({ ...a })) : [];
646
+ const idx = automations.findIndex((a) => a.type === "security_rules" || a.name === NAME);
647
+ const current = idx >= 0 ? automations[idx] : null;
648
+ const currentRule = (current?.options || []).find((o) => o.key === "rule")?.value?.trim();
649
+ if (current?.enabled && currentRule) return;
650
+ if (current) {
651
+ automations[idx] = {
652
+ ...current,
653
+ enabled: true,
654
+ options: [{ key: "rule", value: currentRule || DEFAULT_RULE }]
655
+ };
656
+ } else {
657
+ automations.push({
658
+ name: NAME,
659
+ description: DESCRIPTION,
660
+ options: [{ key: "rule", value: DEFAULT_RULE }],
661
+ icon: "",
662
+ enabled: true
663
+ });
664
+ }
665
+ const payload = { category, automations };
666
+ if (cfg.settings) payload.settings = cfg.settings;
667
+ const save = await fetch(buildUrl("/api/v2/datastore/automate", regionUrl), {
668
+ method: "POST",
669
+ credentials: "include",
670
+ headers,
671
+ body: JSON.stringify(payload)
672
+ });
673
+ if (!save.ok) throw new Error(`automate responded with ${save.status}`);
674
+ console.log(`[securityRules] enabled Security Rules for ${category} on org ${orgId}`);
675
+ };
676
+ var ensureSecurityRulesForWrite = async (orgId, category, regionUrl) => {
677
+ if (!orgId || !GUARDED_CATEGORIES.has(category)) return;
678
+ const key = `${orgId}|${category}`;
679
+ const last = verifiedAt.get(key);
680
+ if (last && Date.now() - last < TTL_MS) return;
681
+ let pending = inFlight.get(key);
682
+ if (!pending) {
683
+ pending = run(orgId, category, regionUrl).then(() => {
684
+ verifiedAt.set(key, Date.now());
685
+ warned.delete(key);
686
+ }).catch((err) => {
687
+ console.warn("[securityRules] could not verify Security Rules", err);
688
+ if (!warned.has(key)) {
689
+ warned.add(key);
690
+ toast.warning("Security Rules are not turned on for this category. The change was saved without them.");
691
+ }
692
+ }).finally(() => inFlight.delete(key));
693
+ inFlight.set(key, pending);
694
+ }
695
+ await pending;
696
+ };
697
+
618
698
  // ../Shuffle-Core/datastore.ts
619
699
  var isCircuitBreakerResponse = (res) => {
620
700
  if (!res) return false;
@@ -801,6 +881,7 @@ var setDatastoreItem = async (key, value, category, overrideOrgId, options) => {
801
881
  if (!orgId) {
802
882
  return { success: false, error: "No organization ID found" };
803
883
  }
884
+ await ensureSecurityRulesForWrite(orgId, category, options?.regionUrl);
804
885
  const rawKey = normalizeDatastoreKey(key);
805
886
  let serialized = serializeDatastoreValue(value);
806
887
  if (category === "shuffle-security_incidents" && byteLength(serialized) > DATASTORE_VALUE_SOFT_LIMIT_BYTES) {
@@ -823,7 +904,9 @@ var setDatastoreItem = async (key, value, category, overrideOrgId, options) => {
823
904
  value: v,
824
905
  category,
825
906
  org_id: orgId,
826
- ...category === "shuffle-security_incidents" ? { ignore_security_rules: true } : {}
907
+ // Full-object overwrite on manual saves; Security Rules are still
908
+ // ensured enabled by ensureSecurityRulesForWrite above.
909
+ ignore_security_rules: true
827
910
  }];
828
911
  const headers = {
829
912
  "Content-Type": "application/json",
@@ -901,11 +984,11 @@ var setDatastoreItems = async (items, category) => {
901
984
  if (!orgId) {
902
985
  return { success: false, error: "No organization ID found" };
903
986
  }
987
+ await ensureSecurityRulesForWrite(orgId, category);
904
988
  const payload = items.map((item) => ({
905
989
  key: item.key,
906
990
  value: serializeDatastoreValue(item.value),
907
- category,
908
- ...category === "shuffle-security_incidents" ? { ignore_security_rules: true } : {}
991
+ category
909
992
  }));
910
993
  const response = await fetch(getApiUrl("/api/v2/datastore"), {
911
994
  method: "POST",
@@ -1540,7 +1623,7 @@ if (typeof window !== "undefined") {
1540
1623
  }
1541
1624
 
1542
1625
  // ../Shuffle-Core/authenticatedApps.ts
1543
- var TTL_MS = 3e4;
1626
+ var TTL_MS2 = 3e4;
1544
1627
  var cache = /* @__PURE__ */ new Map();
1545
1628
  var cacheKey = (crossOrgId) => crossOrgId || "";
1546
1629
  var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
@@ -1579,7 +1662,7 @@ var doFetch = async (crossOrgId) => {
1579
1662
  var fetchAuthenticatedApps = (crossOrgId) => {
1580
1663
  const key = cacheKey(crossOrgId);
1581
1664
  const entry = cache.get(key) || {};
1582
- if (entry.data && entry.fetchedAt && Date.now() - entry.fetchedAt < TTL_MS) {
1665
+ if (entry.data && entry.fetchedAt && Date.now() - entry.fetchedAt < TTL_MS2) {
1583
1666
  return Promise.resolve(entry.data);
1584
1667
  }
1585
1668
  if (entry.promise) return entry.promise;
@@ -3440,7 +3523,7 @@ base.success = (msg, opts) => _impl({ title: msg, description: opts?.description
3440
3523
  base.error = (msg, opts) => _impl({ title: msg, description: opts?.description, variant: "destructive" }, opts);
3441
3524
  base.info = (msg, opts) => _impl({ title: msg, description: opts?.description, variant: "info" }, opts);
3442
3525
  base.warning = (msg, opts) => _impl({ title: msg, description: opts?.description, variant: "warning" }, opts);
3443
- var toast = base;
3526
+ var toast2 = base;
3444
3527
 
3445
3528
  // ../Shuffle-Core/components/AuthStatusChip.tsx
3446
3529
  import { Chip as Chip3, Tooltip as Tooltip3 } from "@mui/material";
@@ -4743,12 +4826,12 @@ var AppAuthCard = ({
4743
4826
  setEditingLabel(false);
4744
4827
  invalidateAuthenticatedAppsCache();
4745
4828
  if (onRefreshAuth) await onRefreshAuth();
4746
- toast({ title: "Label updated", description: `Renamed to "${editLabelValue.trim()}"` });
4829
+ toast2({ title: "Label updated", description: `Renamed to "${editLabelValue.trim()}"` });
4747
4830
  } else {
4748
- toast({ title: "Failed to rename", description: "Could not update the authentication label", variant: "destructive" });
4831
+ toast2({ title: "Failed to rename", description: "Could not update the authentication label", variant: "destructive" });
4749
4832
  }
4750
4833
  } catch (err) {
4751
- toast({ title: "Error", description: "Failed to rename authentication", variant: "destructive" });
4834
+ toast2({ title: "Error", description: "Failed to rename authentication", variant: "destructive" });
4752
4835
  } finally {
4753
4836
  setSavingLabel(false);
4754
4837
  }
@@ -5117,7 +5200,7 @@ var AppAuthCard = ({
5117
5200
  ...prev,
5118
5201
  ...Object.fromEntries(missingUrl.map(({ key }) => [key, "A valid URL is required"]))
5119
5202
  }));
5120
- toast.error("URL is required", {
5203
+ toast2.error("URL is required", {
5121
5204
  description: `Set a valid URL for: ${missingUrl.map((m) => m.label).join(", ")}`
5122
5205
  });
5123
5206
  return;
@@ -5131,7 +5214,7 @@ var AppAuthCard = ({
5131
5214
  setUserHasSelected(false);
5132
5215
  setFieldErrors({});
5133
5216
  if (!suppressSaveToast) {
5134
- toast.success("Authentication saved", {
5217
+ toast2.success("Authentication saved", {
5135
5218
  description: `Your ${app2.name.replace(/_/g, " ")} credentials have been stored securely.`
5136
5219
  });
5137
5220
  }
@@ -7362,7 +7445,7 @@ var SingulActionsPreview = ({
7362
7445
  setCopied(true);
7363
7446
  setTimeout(() => setCopied(false), 2e3);
7364
7447
  } catch {
7365
- toast.error("Copy failed");
7448
+ toast2.error("Copy failed");
7366
7449
  }
7367
7450
  };
7368
7451
  const [playLoading, setPlayLoading] = useState7(false);
@@ -7423,14 +7506,14 @@ var SingulActionsPreview = ({
7423
7506
  }
7424
7507
  })();
7425
7508
  if (parsed?.success === false) {
7426
- toast.error(parsed.reason || "Run failed");
7509
+ toast2.error(parsed.reason || "Run failed");
7427
7510
  } else {
7428
- toast.success(`Ran ${selected?.name || lang}`);
7511
+ toast2.success(`Ran ${selected?.name || lang}`);
7429
7512
  }
7430
7513
  } catch (err) {
7431
7514
  const msg = err?.message || "Run failed";
7432
7515
  setPlayResult(msg);
7433
- toast.error(msg);
7516
+ toast2.error(msg);
7434
7517
  } finally {
7435
7518
  setPlayLoading(false);
7436
7519
  scrollToResponse();
@@ -8219,12 +8302,12 @@ var getSuggestionAppRequirements = (suggestion, limit = 3) => {
8219
8302
  var prettySuggestionAppName = (name) => name.replace(/[_-]+/g, " ").trim().split(/\s+/).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
8220
8303
 
8221
8304
  // safeHandler.ts
8222
- import { toast as toast2 } from "sonner";
8305
+ import { toast as toast3 } from "sonner";
8223
8306
  function safeHandler(label, fn) {
8224
8307
  return (...args) => {
8225
8308
  if (typeof fn !== "function") {
8226
8309
  console.error(`[safeHandler] "${label}" has no handler attached`);
8227
- toast2.error(`${label} is not available right now`);
8310
+ toast3.error(`${label} is not available right now`);
8228
8311
  return void 0;
8229
8312
  }
8230
8313
  try {
@@ -8232,7 +8315,7 @@ function safeHandler(label, fn) {
8232
8315
  if (result && typeof result.catch === "function") {
8233
8316
  result.catch((err) => {
8234
8317
  console.error(`[safeHandler] "${label}" failed`, err);
8235
- toast2.error(`${label} failed`, {
8318
+ toast3.error(`${label} failed`, {
8236
8319
  description: err instanceof Error ? err.message : String(err)
8237
8320
  });
8238
8321
  });
@@ -8240,7 +8323,7 @@ function safeHandler(label, fn) {
8240
8323
  return result;
8241
8324
  } catch (err) {
8242
8325
  console.error(`[safeHandler] "${label}" failed`, err);
8243
- toast2.error(`${label} failed`, {
8326
+ toast3.error(`${label} failed`, {
8244
8327
  description: err instanceof Error ? err.message : String(err)
8245
8328
  });
8246
8329
  return void 0;
@@ -10936,14 +11019,14 @@ var deepParseJsonStrings2 = (obj, depth = 0) => {
10936
11019
  }
10937
11020
  return obj;
10938
11021
  };
10939
- var pickResultPayload = (run) => {
10940
- const results = Array.isArray(run.results) ? run.results : [];
11022
+ var pickResultPayload = (run2) => {
11023
+ const results = Array.isArray(run2.results) ? run2.results : [];
10941
11024
  const agentResult = results.find((r) => {
10942
11025
  const appName = String(r?.action?.app_name || r?.action?.label || "").toLowerCase();
10943
11026
  const appId = String(r?.action?.app_id || "").toLowerCase();
10944
11027
  return appId === "shuffle_agent" || appName.includes("ai agent");
10945
11028
  });
10946
- const payload = agentResult?.result || results.find((r) => typeof r?.result === "string" && r.result.trim())?.result || run.result;
11029
+ const payload = agentResult?.result || results.find((r) => typeof r?.result === "string" && r.result.trim())?.result || run2.result;
10947
11030
  if (typeof payload === "string") return payload;
10948
11031
  if (payload && typeof payload === "object") {
10949
11032
  try {
@@ -10954,10 +11037,10 @@ var pickResultPayload = (run) => {
10954
11037
  }
10955
11038
  return null;
10956
11039
  };
10957
- var parseRunResult = (run) => {
10958
- const firstResult = pickResultPayload(run);
11040
+ var parseRunResult = (run2) => {
11041
+ const firstResult = pickResultPayload(run2);
10959
11042
  if (!firstResult) {
10960
- const directPayload = run;
11043
+ const directPayload = run2;
10961
11044
  if (directPayload && typeof directPayload === "object" && (Array.isArray(directPayload.decisions) || directPayload.decision_string !== void 0)) {
10962
11045
  const deepParsed = deepParseJsonStrings2(directPayload);
10963
11046
  let raw = null;
@@ -10993,10 +11076,10 @@ var isDecisionStringParserFailure = (reason) => {
10993
11076
  const normalized = reason.toLowerCase();
10994
11077
  return normalized.includes("produced decisions") && normalized.includes("none could be executed");
10995
11078
  };
10996
- var getFailureInfo = (run) => {
10997
- const status = run.status?.toUpperCase();
11079
+ var getFailureInfo = (run2) => {
11080
+ const status = run2.status?.toUpperCase();
10998
11081
  if (status !== "FAILED" && status !== "ABORTED") return null;
10999
- const { parsed } = parseRunResult(run);
11082
+ const { parsed } = parseRunResult(run2);
11000
11083
  if (parsed && typeof parsed === "object") {
11001
11084
  if (parsed.success === false && parsed.reason) {
11002
11085
  if (isDecisionStringParserFailure(parsed.reason)) return null;
@@ -11055,8 +11138,8 @@ var isAiAuthText = (text2) => {
11055
11138
  }
11056
11139
  return checkChunk(trimmed);
11057
11140
  };
11058
- var hasOutputWarning = (run) => {
11059
- return diagnoseOutputWarning(run) !== null;
11141
+ var hasOutputWarning = (run2) => {
11142
+ return diagnoseOutputWarning(run2) !== null;
11060
11143
  };
11061
11144
  var diagnosisHasCtas = (diagnosis) => diagnosis?.kind === "token_limit" || diagnosis?.kind === "ai_auth" || Boolean(diagnosis?.isAiAuth);
11062
11145
  var collectEntries = (root2) => {
@@ -11087,15 +11170,15 @@ var trimEvidenceValue = (v, max = 180) => {
11087
11170
  };
11088
11171
  var TOKEN_LIMIT_PATTERN = /\b(ai[\s-]*token[\s-]*limit[\s-]*(is[\s-]*)?reach(ed)?|token[\s-]*limit[\s-]*(is[\s-]*)?reach(ed)?|context[\s-]*(window|length|limit)[\s-]*(is[\s-]*)?(reached|exceeded)|maximum[\s-]*context[\s-]*(window|length)?[\s-]*(is[\s-]*)?(reached|exceeded)|too[\s-]*many[\s-]*tokens|exceeds?[\s-]*(the[\s-]*)?(maximum[\s-]*)?(token|context))\b/;
11089
11172
  var isSentenceLike = (v) => /[a-z]/i.test(v) && v.trim().split(/\s+/).length > 1;
11090
- var hasProducedDecisions = (run, parsed) => {
11173
+ var hasProducedDecisions = (run2, parsed) => {
11091
11174
  const parsedDecisions = parsed && typeof parsed === "object" ? parsed.decisions : null;
11092
11175
  if (Array.isArray(parsedDecisions) && parsedDecisions.length > 0) return true;
11093
- const directDecisions = run?.decisions;
11176
+ const directDecisions = run2?.decisions;
11094
11177
  return Array.isArray(directDecisions) && directDecisions.length > 0;
11095
11178
  };
11096
- var diagnoseOutputWarning = (run) => {
11097
- const { parsed, raw } = parseRunResult(run);
11098
- const producedDecisions = hasProducedDecisions(run, parsed);
11179
+ var diagnoseOutputWarning = (run2) => {
11180
+ const { parsed, raw } = parseRunResult(run2);
11181
+ const producedDecisions = hasProducedDecisions(run2, parsed);
11099
11182
  const tokenLimitMatch = (() => {
11100
11183
  const candidates = [];
11101
11184
  if (parsed && typeof parsed === "object") {
@@ -11118,7 +11201,7 @@ var diagnoseOutputWarning = (run) => {
11118
11201
  evidence: [{ path: "(root)", value: evidenceValue }]
11119
11202
  };
11120
11203
  }
11121
- const isFinished = (run.status || "").toUpperCase() === "FINISHED";
11204
+ const isFinished = (run2.status || "").toUpperCase() === "FINISHED";
11122
11205
  const hasSuccessfulFinish = (() => {
11123
11206
  if (!parsed || typeof parsed !== "object") return false;
11124
11207
  if (parsed.error && String(parsed.error).trim().length > 0) return false;
@@ -11408,26 +11491,26 @@ var diagnoseOutputWarning = (run) => {
11408
11491
  }
11409
11492
  return null;
11410
11493
  };
11411
- var isAiAuthFailure = (run, extraText) => {
11412
- if (!run) return isAiAuthText(extraText);
11413
- const { parsed } = parseRunResult(run);
11414
- if (hasProducedDecisions(run, parsed)) return false;
11494
+ var isAiAuthFailure = (run2, extraText) => {
11495
+ if (!run2) return isAiAuthText(extraText);
11496
+ const { parsed } = parseRunResult(run2);
11497
+ if (hasProducedDecisions(run2, parsed)) return false;
11415
11498
  if (isAiAuthText(extraText)) return true;
11416
- const status = (run.status || "").toUpperCase();
11499
+ const status = (run2.status || "").toUpperCase();
11417
11500
  const isFinished = status === "FINISHED" || status === "SUCCESS";
11418
11501
  if (isFinished) {
11419
- const anyRun2 = run;
11502
+ const anyRun2 = run2;
11420
11503
  if (typeof anyRun2.error === "string" && isAiAuthText(anyRun2.error)) return true;
11421
11504
  return false;
11422
11505
  }
11423
- const diagnosis = diagnoseOutputWarning(run);
11506
+ const diagnosis = diagnoseOutputWarning(run2);
11424
11507
  if (diagnosis?.kind === "ai_auth" || diagnosis?.isAiAuth) return true;
11425
- const fail = getFailureInfo(run);
11508
+ const fail = getFailureInfo(run2);
11426
11509
  if (fail && isAiAuthText(fail.reason)) return true;
11427
- const anyRun = run;
11510
+ const anyRun = run2;
11428
11511
  if (typeof anyRun.error === "string" && isAiAuthText(anyRun.error)) return true;
11429
- if (Array.isArray(run.results)) {
11430
- for (const r of run.results) {
11512
+ if (Array.isArray(run2.results)) {
11513
+ for (const r of run2.results) {
11431
11514
  if (typeof r?.error === "string" && isAiAuthText(r.error)) return true;
11432
11515
  }
11433
11516
  }
@@ -11549,22 +11632,22 @@ var writeDismissed = (key) => {
11549
11632
  } catch {
11550
11633
  }
11551
11634
  };
11552
- var AgentRunDiagnosisBanner = ({ run, sx, onJumpToEvidence, onFocusContinue, executionId }) => {
11635
+ var AgentRunDiagnosisBanner = ({ run: run2, sx, onJumpToEvidence, onFocusContinue, executionId }) => {
11553
11636
  const dismissKey = useMemo8(() => {
11554
11637
  if (executionId) return executionId;
11555
- const fromRun = run?.execution_id;
11638
+ const fromRun = run2?.execution_id;
11556
11639
  return typeof fromRun === "string" && fromRun ? fromRun : null;
11557
- }, [executionId, run]);
11640
+ }, [executionId, run2]);
11558
11641
  const [dismissed, setDismissed] = useState11(() => readDismissed(dismissKey));
11559
11642
  useEffect10(() => {
11560
11643
  setDismissed(readDismissed(dismissKey));
11561
11644
  }, [dismissKey]);
11562
- if (!run || dismissed) return null;
11563
- const status = (run.status || "").toUpperCase();
11645
+ if (!run2 || dismissed) return null;
11646
+ const status = (run2.status || "").toUpperCase();
11564
11647
  const isFailed = status === "FAILED" || status === "ABORTED";
11565
- const failureInfo = isFailed ? getFailureInfo(run) : null;
11566
- const outputWarning = !isFailed && hasOutputWarning(run);
11567
- const diagnosis = outputWarning ? diagnoseOutputWarning(run) : null;
11648
+ const failureInfo = isFailed ? getFailureInfo(run2) : null;
11649
+ const outputWarning = !isFailed && hasOutputWarning(run2);
11650
+ const diagnosis = outputWarning ? diagnoseOutputWarning(run2) : null;
11568
11651
  if (!failureInfo && !diagnosis) return null;
11569
11652
  if (status === "FINISHED" && (diagnosis?.kind === "ai_auth" || diagnosis?.isAiAuth)) {
11570
11653
  return null;
@@ -11573,8 +11656,8 @@ var AgentRunDiagnosisBanner = ({ run, sx, onJumpToEvidence, onFocusContinue, exe
11573
11656
  const firstEvidence2 = diagnosis?.evidence?.[0] || null;
11574
11657
  const jumpDecisionIndex2 = firstEvidence2 ? extractDecisionIndex(firstEvidence2.path) : null;
11575
11658
  if (jumpDecisionIndex2 === null) return null;
11576
- const { parsed } = parseRunResult(run);
11577
- const decs = parsed?.decisions || run?.decisions;
11659
+ const { parsed } = parseRunResult(run2);
11660
+ const decs = parsed?.decisions || run2?.decisions;
11578
11661
  if (Array.isArray(decs) && decs[jumpDecisionIndex2]) {
11579
11662
  const d = decs[jumpDecisionIndex2];
11580
11663
  const action = String(d?.action || d?.details?.action || "").toLowerCase();
@@ -16147,7 +16230,7 @@ var AgentUI = ({
16147
16230
  const json = await resp.json();
16148
16231
  if (json.success === false) {
16149
16232
  setOptimisticContinue(null);
16150
- toast({ title: "Failed to submit", description: json.reason || "Try again later.", variant: "destructive" });
16233
+ toast2({ title: "Failed to submit", description: json.reason || "Try again later.", variant: "destructive" });
16151
16234
  } else {
16152
16235
  setQuestionAnswers({});
16153
16236
  setContinuationText("");
@@ -16157,7 +16240,7 @@ var AgentUI = ({
16157
16240
  }
16158
16241
  } catch (err) {
16159
16242
  setOptimisticContinue(null);
16160
- toast({ title: "Network error", description: String(err), variant: "destructive" });
16243
+ toast2({ title: "Network error", description: String(err), variant: "destructive" });
16161
16244
  } finally {
16162
16245
  setAgentRequestLoading(false);
16163
16246
  }
@@ -16320,7 +16403,7 @@ var AgentUI = ({
16320
16403
  };
16321
16404
  if (!execId || !wfId) {
16322
16405
  resetToStart();
16323
- toast({ title: "Run aborted", description: "The agent had not started yet \u2014 reset to Start." });
16406
+ toast2({ title: "Run aborted", description: "The agent had not started yet \u2014 reset to Start." });
16324
16407
  setAbortLoading(false);
16325
16408
  return;
16326
16409
  }
@@ -16338,14 +16421,14 @@ var AgentUI = ({
16338
16421
  );
16339
16422
  if (!resp.ok) {
16340
16423
  const txt = await resp.text().catch(() => "");
16341
- toast({ title: "Abort failed", description: txt || `HTTP ${resp.status}`, variant: "destructive" });
16424
+ toast2({ title: "Abort failed", description: txt || `HTTP ${resp.status}`, variant: "destructive" });
16342
16425
  setAbortLoading(false);
16343
16426
  return;
16344
16427
  }
16345
16428
  setTimeout(() => getExecution(execId, auth), 500);
16346
16429
  setTimeout(() => getExecution(execId, auth), 2500);
16347
16430
  } catch (err) {
16348
- toast({ title: "Network error", description: String(err), variant: "destructive" });
16431
+ toast2({ title: "Network error", description: String(err), variant: "destructive" });
16349
16432
  } finally {
16350
16433
  setAbortLoading(false);
16351
16434
  }
@@ -16371,16 +16454,16 @@ var AgentUI = ({
16371
16454
  }, [execution, agentActionResult, apiBaseUrl]);
16372
16455
  const rerunDecision = useCallback5(async (decision) => {
16373
16456
  if (!execution?.execution_id) {
16374
- toast({ title: "No execution loaded", description: "Cannot rerun this decision.", variant: "destructive" });
16457
+ toast2({ title: "No execution loaded", description: "Cannot rerun this decision.", variant: "destructive" });
16375
16458
  return;
16376
16459
  }
16377
16460
  if (!agentActionResult?.action) {
16378
- toast({ title: "Missing action context", description: "Could not locate the agent action node.", variant: "destructive" });
16461
+ toast2({ title: "Missing action context", description: "Could not locate the agent action node.", variant: "destructive" });
16379
16462
  return;
16380
16463
  }
16381
16464
  const decisionId = decision?.run_details?.id;
16382
16465
  if (!decisionId) {
16383
- toast({ title: "Missing decision id", description: "This decision cannot be rerun.", variant: "destructive" });
16466
+ toast2({ title: "Missing decision id", description: "This decision cannot be rerun.", variant: "destructive" });
16384
16467
  return;
16385
16468
  }
16386
16469
  const body = { ...agentActionResult.action };
@@ -16402,14 +16485,14 @@ var AgentUI = ({
16402
16485
  });
16403
16486
  const json = await resp.json().catch(() => ({}));
16404
16487
  if (json?.success === false) {
16405
- toast({ title: "Rerun failed", description: json.reason || "Try again later.", variant: "destructive" });
16488
+ toast2({ title: "Rerun failed", description: json.reason || "Try again later.", variant: "destructive" });
16406
16489
  setRerunningDecisionId(null);
16407
16490
  } else {
16408
16491
  setTimeout(() => getExecution(execution.execution_id, execution.authorization), 800);
16409
16492
  setTimeout(() => getExecution(execution.execution_id, execution.authorization), 5e3);
16410
16493
  }
16411
16494
  } catch (err) {
16412
- toast({ title: "Network error", description: String(err), variant: "destructive" });
16495
+ toast2({ title: "Network error", description: String(err), variant: "destructive" });
16413
16496
  setRerunningDecisionId(null);
16414
16497
  } finally {
16415
16498
  setAgentRequestLoading(false);
@@ -17504,15 +17587,15 @@ var AgentUI = ({
17504
17587
  setScheduleSteps((prev) => prev.map((p) => p.id === ev.id ? { ...p, state: ev.state, detail: ev.detail } : p));
17505
17588
  }
17506
17589
  });
17507
- toast({ title: "Schedule saved", description: "This prompt will now run on the selected schedule." });
17590
+ toast2({ title: "Schedule saved", description: "This prompt will now run on the selected schedule." });
17508
17591
  setScheduleAnchor(null);
17509
17592
  } else {
17510
- toast({ title: "Scheduling not configured", description: "No handler is wired up for scheduled runs in this view.", variant: "destructive" });
17593
+ toast2({ title: "Scheduling not configured", description: "No handler is wired up for scheduled runs in this view.", variant: "destructive" });
17511
17594
  setScheduleAnchor(null);
17512
17595
  }
17513
17596
  } catch (err) {
17514
17597
  console.error("[AgentUI] Schedule failed", err);
17515
- toast({ title: "Failed to save schedule", description: err instanceof Error ? err.message : String(err), variant: "destructive" });
17598
+ toast2({ title: "Failed to save schedule", description: err instanceof Error ? err.message : String(err), variant: "destructive" });
17516
17599
  } finally {
17517
17600
  setScheduleSaving(false);
17518
17601
  }
@@ -18685,7 +18768,7 @@ var AgentUI = ({
18685
18768
  if (!result?.success) {
18686
18769
  pendingLLMRef.current = null;
18687
18770
  setDetectedLLM(previous);
18688
- toast({
18771
+ toast2({
18689
18772
  title: "Could not change AI provider",
18690
18773
  description: `Failed to switch to ${opt.label}.`,
18691
18774
  variant: "destructive"
@@ -18695,7 +18778,7 @@ var AgentUI = ({
18695
18778
  } catch (err) {
18696
18779
  pendingLLMRef.current = null;
18697
18780
  setDetectedLLM(previous);
18698
- toast({
18781
+ toast2({
18699
18782
  title: "Could not change AI provider",
18700
18783
  description: err instanceof Error ? err.message : "Failed to switch provider.",
18701
18784
  variant: "destructive"
@@ -21248,7 +21331,7 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
21248
21331
  setSelectedPreset(rollback);
21249
21332
  rememberPreset(rollback);
21250
21333
  }
21251
- toast({
21334
+ toast2({
21252
21335
  title: "Could not change AI provider",
21253
21336
  description: "Failed to switch to Shuffle AI.",
21254
21337
  variant: "destructive"
@@ -21264,7 +21347,7 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
21264
21347
  setSelectedPreset(rollback);
21265
21348
  rememberPreset(rollback);
21266
21349
  }
21267
- toast({
21350
+ toast2({
21268
21351
  title: "Could not change AI provider",
21269
21352
  description: err instanceof Error ? err.message : "Failed to switch to Shuffle AI.",
21270
21353
  variant: "destructive"
@@ -21295,7 +21378,7 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
21295
21378
  setSelectedPreset(rollback);
21296
21379
  rememberPreset(rollback);
21297
21380
  }
21298
- toast({
21381
+ toast2({
21299
21382
  title: "Could not change AI provider",
21300
21383
  description: "Failed to switch to " + label + ".",
21301
21384
  variant: "destructive"
@@ -21311,7 +21394,7 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
21311
21394
  setSelectedPreset(rollback);
21312
21395
  rememberPreset(rollback);
21313
21396
  }
21314
- toast({
21397
+ toast2({
21315
21398
  title: "Could not change AI provider",
21316
21399
  description: err instanceof Error ? err.message : "Failed to switch active LLM provider.",
21317
21400
  variant: "destructive"
@@ -22247,11 +22330,11 @@ var STATUS_CONFIG = {
22247
22330
  WAITING: { icon: /* @__PURE__ */ jsx30(Clock, { size: 16 }), color: "hsl(var(--severity-info, 217 91% 60%))", label: "Waiting" },
22248
22331
  LIMIT_REACHED: { icon: /* @__PURE__ */ jsx30(AlertTriangle2, { size: 16 }), color: "hsl(var(--severity-critical, 0 72% 55%))", label: "Limit reached" }
22249
22332
  };
22250
- var getEffectiveStatus = (run) => {
22251
- const raw = (run.status || "").toUpperCase();
22333
+ var getEffectiveStatus = (run2) => {
22334
+ const raw = (run2.status || "").toUpperCase();
22252
22335
  if (raw === "FINISHED" || raw === "SUCCESS" || raw === "FAILED" || raw === "ABORTED") {
22253
22336
  try {
22254
- const d = diagnoseOutputWarning(run);
22337
+ const d = diagnoseOutputWarning(run2);
22255
22338
  if (d?.kind === "token_limit") return "LIMIT_REACHED";
22256
22339
  } catch {
22257
22340
  }
@@ -22273,8 +22356,8 @@ var parseDatastoreTask = (arg) => {
22273
22356
  return { key, category };
22274
22357
  };
22275
22358
  var isAIAgentResult = (result) => String(result?.action?.app_name || "").trim().toLowerCase() === "ai agent";
22276
- var getAIAgentResultPayload = (run) => {
22277
- const results = Array.isArray(run.results) ? run.results : [];
22359
+ var getAIAgentResultPayload = (run2) => {
22360
+ const results = Array.isArray(run2.results) ? run2.results : [];
22278
22361
  const agentResult = results.find(isAIAgentResult);
22279
22362
  if (!agentResult || typeof agentResult !== "object" || !("result" in agentResult)) return null;
22280
22363
  return tryParseJson2(agentResult.result);
@@ -22290,16 +22373,16 @@ var getDirectAgentInput = (payload) => {
22290
22373
  }
22291
22374
  return null;
22292
22375
  };
22293
- var findDatastoreTaskInRun = (run) => {
22294
- const agentInput = getDirectAgentInput(getAIAgentResultPayload(run));
22376
+ var findDatastoreTaskInRun = (run2) => {
22377
+ const agentInput = getDirectAgentInput(getAIAgentResultPayload(run2));
22295
22378
  const agentHit = parseDatastoreTask(agentInput || void 0);
22296
22379
  if (agentHit) return agentHit;
22297
- const anyRun = run;
22380
+ const anyRun = run2;
22298
22381
  const candidates = [];
22299
22382
  if (typeof anyRun.original_input === "string") candidates.push(anyRun.original_input);
22300
22383
  if (typeof anyRun.input === "string") candidates.push(anyRun.input);
22301
- if (run.execution_argument) candidates.push(run.execution_argument);
22302
- if (run.result) candidates.push(run.result);
22384
+ if (run2.execution_argument) candidates.push(run2.execution_argument);
22385
+ if (run2.result) candidates.push(run2.result);
22303
22386
  if (Array.isArray(anyRun.results)) {
22304
22387
  try {
22305
22388
  candidates.push(JSON.stringify(anyRun.results));
@@ -22312,12 +22395,12 @@ var findDatastoreTaskInRun = (run) => {
22312
22395
  }
22313
22396
  return null;
22314
22397
  };
22315
- var classifyRunSource = (run) => {
22316
- const raw = (run.execution_source || "").trim();
22398
+ var classifyRunSource = (run2) => {
22399
+ const raw = (run2.execution_source || "").trim();
22317
22400
  const src = raw.toLowerCase();
22318
22401
  const sourceParts = raw.split("|");
22319
22402
  const fromSource = src.startsWith("datastore") && sourceParts.length > 2 ? { category: sourceParts[1].trim(), key: sourceParts[2].trim() } : null;
22320
- const ds = findDatastoreTaskInRun(run) || fromSource;
22403
+ const ds = findDatastoreTaskInRun(run2) || fromSource;
22321
22404
  if (ds || src.includes("datastore") || src.includes("enrichment") || src.includes("automation")) {
22322
22405
  return {
22323
22406
  kind: "datastore",
@@ -22377,18 +22460,18 @@ Click to open it in the Datastore.` : "Started by a datastore automation (e.g. e
22377
22460
  icon: /* @__PURE__ */ jsx30(Zap, { size: SOURCE_ICON_SIZE })
22378
22461
  };
22379
22462
  };
22380
- var getRunIconColor = (run) => {
22381
- const status = getEffectiveStatus(run);
22463
+ var getRunIconColor = (run2) => {
22464
+ const status = getEffectiveStatus(run2);
22382
22465
  if (status === "FINISHED" || status === "SUCCESS") return "hsl(var(--severity-low, 142 71% 45%))";
22383
22466
  if (status === "FAILED" || status === "ABORTED") return "hsl(var(--severity-critical, 0 72% 55%))";
22384
22467
  if (status === "LIMIT_REACHED") return "hsl(var(--severity-critical, 0 72% 55%))";
22385
22468
  if (status === "EXECUTING" || status === "RUNNING") return "hsl(var(--severity-medium, 38 92% 50%))";
22386
22469
  return "hsl(var(--primary, 24 100% 50%))";
22387
22470
  };
22388
- var formatDuration = (run) => {
22389
- if (run.started_at && run.completed_at) {
22390
- const start = Number(run.started_at);
22391
- const end = Number(run.completed_at);
22471
+ var formatDuration = (run2) => {
22472
+ if (run2.started_at && run2.completed_at) {
22473
+ const start = Number(run2.started_at);
22474
+ const end = Number(run2.completed_at);
22392
22475
  if (!isNaN(start) && !isNaN(end)) {
22393
22476
  const toMs = (n) => n > 1e12 ? n : n * 1e3;
22394
22477
  const ms = Math.max(0, toMs(end) - toMs(start));
@@ -22397,7 +22480,7 @@ var formatDuration = (run) => {
22397
22480
  return `${Math.floor(ms / 6e4)}m ${Math.floor(ms % 6e4 / 1e3)}s`;
22398
22481
  }
22399
22482
  }
22400
- if (run.duration) return `${run.duration.toFixed(2)}s`;
22483
+ if (run2.duration) return `${run2.duration.toFixed(2)}s`;
22401
22484
  return "";
22402
22485
  };
22403
22486
  var getTimeAgo = (dateStr) => {
@@ -22478,9 +22561,9 @@ var tryParseJson2 = (s) => {
22478
22561
  return trimmed;
22479
22562
  }
22480
22563
  };
22481
- var getRunPrompt = (run) => {
22482
- const anyRun = run;
22483
- const agentInput = getDirectAgentInput(getAIAgentResultPayload(run));
22564
+ var getRunPrompt = (run2) => {
22565
+ const anyRun = run2;
22566
+ const agentInput = getDirectAgentInput(getAIAgentResultPayload(run2));
22484
22567
  if (agentInput) return agentInput;
22485
22568
  const results = Array.isArray(anyRun.results) ? anyRun.results : null;
22486
22569
  if (results) {
@@ -22501,12 +22584,12 @@ var getRunPrompt = (run) => {
22501
22584
  if (typeof anyRun.input === "string" && anyRun.input.trim()) {
22502
22585
  return anyRun.input.trim();
22503
22586
  }
22504
- if (run.result) {
22505
- const hit = deepFindPrompt(tryParseJson2(run.result));
22587
+ if (run2.result) {
22588
+ const hit = deepFindPrompt(tryParseJson2(run2.result));
22506
22589
  if (hit) return hit;
22507
22590
  }
22508
- if (run.execution_argument) {
22509
- const parsed = tryParseJson2(run.execution_argument);
22591
+ if (run2.execution_argument) {
22592
+ const parsed = tryParseJson2(run2.execution_argument);
22510
22593
  const hit = deepFindPrompt(parsed);
22511
22594
  if (hit) return hit;
22512
22595
  if (typeof parsed === "string" && parsed.length < 240) return parsed;
@@ -22529,23 +22612,23 @@ var stripMarkdown = (input) => {
22529
22612
  s = s.replace(/\s+/g, " ").trim();
22530
22613
  return s;
22531
22614
  };
22532
- var getRunTitle = (run) => {
22533
- const prompt = getRunPrompt(run);
22615
+ var getRunTitle = (run2) => {
22616
+ const prompt = getRunPrompt(run2);
22534
22617
  if (prompt) {
22535
22618
  const oneLine = stripMarkdown(prompt);
22536
22619
  return oneLine.length > 80 ? oneLine.slice(0, 80) + "\u2026" : oneLine;
22537
22620
  }
22538
- if (run.workflow?.name) return stripMarkdown(run.workflow.name);
22539
- return `Execution ${run.execution_id?.slice(0, 8) || "\u2014"}`;
22621
+ if (run2.workflow?.name) return stripMarkdown(run2.workflow.name);
22622
+ return `Execution ${run2.execution_id?.slice(0, 8) || "\u2014"}`;
22540
22623
  };
22541
- var getDecisionCount = (run) => {
22542
- if (Array.isArray(run.decisions)) return run.decisions.length;
22624
+ var getDecisionCount = (run2) => {
22625
+ if (Array.isArray(run2.decisions)) return run2.decisions.length;
22543
22626
  return 0;
22544
22627
  };
22545
- var getRunSubtitle = (run) => {
22546
- if (run.result) {
22628
+ var getRunSubtitle = (run2) => {
22629
+ if (run2.result) {
22547
22630
  try {
22548
- const p = JSON.parse(run.result);
22631
+ const p = JSON.parse(run2.result);
22549
22632
  if (p.output && typeof p.output === "string") {
22550
22633
  const out = stripMarkdown(p.output);
22551
22634
  return out.length > 120 ? out.slice(0, 120) + "\u2026" : out;
@@ -22556,12 +22639,12 @@ var getRunSubtitle = (run) => {
22556
22639
  }
22557
22640
  if (p.message && typeof p.message === "string") return stripMarkdown(p.message);
22558
22641
  } catch {
22559
- if (run.result.length < 120) return stripMarkdown(run.result);
22642
+ if (run2.result.length < 120) return stripMarkdown(run2.result);
22560
22643
  }
22561
22644
  }
22562
- const status = getEffectiveStatus(run);
22645
+ const status = getEffectiveStatus(run2);
22563
22646
  const isRunning = status === "EXECUTING" || status === "RUNNING" || status === "WAITING";
22564
- return run.execution_source || (isRunning ? "Agent still running\u2026" : "Agent execution");
22647
+ return run2.execution_source || (isRunning ? "Agent still running\u2026" : "Agent execution");
22565
22648
  };
22566
22649
  var normalizeResultStatus = (s) => {
22567
22650
  const v = (s || "").toUpperCase();
@@ -22570,7 +22653,7 @@ var normalizeResultStatus = (s) => {
22570
22653
  if (v === "WAITING" || v === "SKIPPED") return "waiting";
22571
22654
  return "unknown";
22572
22655
  };
22573
- var getRunTools = (run) => {
22656
+ var getRunTools = (run2) => {
22574
22657
  const map = /* @__PURE__ */ new Map();
22575
22658
  const ids = /* @__PURE__ */ new Map();
22576
22659
  const skip = (s) => /^(ai\s*agent|shuffle\s*agent|shuffle_agent)$/i.test(s);
@@ -22584,7 +22667,7 @@ var getRunTools = (run) => {
22584
22667
  if (!prev || rank[next] > rank[prev]) map.set(s, next);
22585
22668
  if (id && !ids.has(s)) ids.set(s, id);
22586
22669
  };
22587
- const allowed = run.allowed_actions;
22670
+ const allowed = run2.allowed_actions;
22588
22671
  if (Array.isArray(allowed) && allowed.length > 0) {
22589
22672
  for (const entry of allowed) {
22590
22673
  if (typeof entry !== "string") continue;
@@ -22602,17 +22685,17 @@ var getRunTools = (run) => {
22602
22685
  const hit = known.get(normalize(name));
22603
22686
  if (hit) merge2(hit, status);
22604
22687
  };
22605
- (run.results || []).forEach((r) => {
22688
+ (run2.results || []).forEach((r) => {
22606
22689
  apply(r?.action?.app_name || r?.action?.label, normalizeResultStatus(r?.status));
22607
22690
  });
22608
- (run.decisions || []).forEach((d) => {
22691
+ (run2.decisions || []).forEach((d) => {
22609
22692
  if (typeof d?.tool === "string") apply(d.tool, normalizeResultStatus(d?.status));
22610
22693
  });
22611
22694
  } else {
22612
- (run.results || []).forEach((r) => {
22695
+ (run2.results || []).forEach((r) => {
22613
22696
  merge2(r?.action?.app_name || r?.action?.label, normalizeResultStatus(r?.status));
22614
22697
  });
22615
- (run.decisions || []).forEach((d) => {
22698
+ (run2.decisions || []).forEach((d) => {
22616
22699
  if (typeof d?.tool === "string") merge2(d.tool, normalizeResultStatus(d?.status));
22617
22700
  });
22618
22701
  }
@@ -22631,18 +22714,18 @@ var TOOL_STATUS_LABEL = {
22631
22714
  unknown: "used"
22632
22715
  };
22633
22716
  var normToolKey = (s) => s.toLowerCase().replace(/[\s_\-]+/g, "_");
22634
- var AgentRunRow = ({ run, onClick, sx, appIcons, onAppClick, apiKey, apiBaseUrl, orgId, abortingIds, onAbort }) => {
22717
+ var AgentRunRow = ({ run: run2, onClick, sx, appIcons, onAppClick, apiKey, apiBaseUrl, orgId, abortingIds, onAbort }) => {
22635
22718
  const navigate = useNavigate2();
22636
- const statusKey = getEffectiveStatus(run);
22637
- const iconColor = getRunIconColor(run);
22638
- const duration = formatDuration(run);
22639
- const tools = getRunTools(run);
22640
- const decisionCount = getDecisionCount(run);
22641
- const attachmentCount = collectLlmImageAttachments(run).length;
22719
+ const statusKey = getEffectiveStatus(run2);
22720
+ const iconColor = getRunIconColor(run2);
22721
+ const duration = formatDuration(run2);
22722
+ const tools = getRunTools(run2);
22723
+ const decisionCount = getDecisionCount(run2);
22724
+ const attachmentCount = collectLlmImageAttachments(run2).length;
22642
22725
  const isRunning = statusKey === "EXECUTING" || statusKey === "RUNNING" || statusKey === "WAITING";
22643
- const isAborting = !!run.execution_id && !!abortingIds?.has(run.execution_id);
22644
- const wfId = run.workflow_id || run?.workflow?.id;
22645
- const canAbort = isRunning && !!run.execution_id && !!wfId && !isAborting;
22726
+ const isAborting = !!run2.execution_id && !!abortingIds?.has(run2.execution_id);
22727
+ const wfId = run2.workflow_id || run2?.workflow?.id;
22728
+ const canAbort = isRunning && !!run2.execution_id && !!wfId && !isAborting;
22646
22729
  return /* @__PURE__ */ jsxs23(
22647
22730
  Box21,
22648
22731
  {
@@ -22668,7 +22751,7 @@ var AgentRunRow = ({ run, onClick, sx, appIcons, onAppClick, apiKey, apiBaseUrl,
22668
22751
  ],
22669
22752
  children: [
22670
22753
  (() => {
22671
- const sourceInfo = classifyRunSource(run);
22754
+ const sourceInfo = classifyRunSource(run2);
22672
22755
  const dsLink = sourceInfo.kind === "datastore" && sourceInfo.datastoreKey && sourceInfo.datastoreCategory ? `https://shuffler.io/admin?tab=datastore&category=${encodeURIComponent(sourceInfo.datastoreCategory)}&key=${encodeURIComponent(sourceInfo.datastoreKey)}` : null;
22673
22756
  return /* @__PURE__ */ jsx30(
22674
22757
  Tooltip15,
@@ -22718,7 +22801,7 @@ var AgentRunRow = ({ run, onClick, sx, appIcons, onAppClick, apiKey, apiBaseUrl,
22718
22801
  textOverflow: "ellipsis",
22719
22802
  whiteSpace: "nowrap"
22720
22803
  },
22721
- children: getRunTitle(run)
22804
+ children: getRunTitle(run2)
22722
22805
  }
22723
22806
  ) }),
22724
22807
  /* @__PURE__ */ jsx30(
@@ -22731,11 +22814,11 @@ var AgentRunRow = ({ run, onClick, sx, appIcons, onAppClick, apiKey, apiBaseUrl,
22731
22814
  textOverflow: "ellipsis",
22732
22815
  whiteSpace: "nowrap"
22733
22816
  },
22734
- children: getRunSubtitle(run)
22817
+ children: getRunSubtitle(run2)
22735
22818
  }
22736
22819
  ),
22737
22820
  /* @__PURE__ */ jsxs23(Box21, { sx: { display: "flex", alignItems: "center", gap: 1, mt: 0.5 }, children: [
22738
- /* @__PURE__ */ jsx30(Typography18, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.7 }, children: run.started_at ? getTimeAgo(run.started_at) : "\u2014" }),
22821
+ /* @__PURE__ */ jsx30(Typography18, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.7 }, children: run2.started_at ? getTimeAgo(run2.started_at) : "\u2014" }),
22739
22822
  duration && /* @__PURE__ */ jsxs23(Fragment10, { children: [
22740
22823
  /* @__PURE__ */ jsx30(Typography18, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
22741
22824
  /* @__PURE__ */ jsx30(Typography18, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.7 }, children: duration })
@@ -22836,7 +22919,7 @@ var AgentRunRow = ({ run, onClick, sx, appIcons, onAppClick, apiKey, apiBaseUrl,
22836
22919
  disabled: isAborting,
22837
22920
  onClick: (e) => {
22838
22921
  e.stopPropagation();
22839
- onAbort?.(run);
22922
+ onAbort?.(run2);
22840
22923
  },
22841
22924
  sx: {
22842
22925
  flexShrink: 0,
@@ -22948,11 +23031,11 @@ var AgentActivityList = ({
22948
23031
  }
22949
23032
  }, [workflowFilter, apiKey, apiBaseUrl, orgId]);
22950
23033
  const handleAbort = useCallback9(
22951
- async (run) => {
22952
- const eid = run.execution_id;
22953
- const wfId = run.workflow_id || run?.workflow?.id;
23034
+ async (run2) => {
23035
+ const eid = run2.execution_id;
23036
+ const wfId = run2.workflow_id || run2?.workflow?.id;
22954
23037
  if (!eid || !wfId) return;
22955
- const prevStatus = run.status;
23038
+ const prevStatus = run2.status;
22956
23039
  setAbortingIds((prev) => /* @__PURE__ */ new Set([...Array.from(prev), eid]));
22957
23040
  setAbortedIds((prev) => /* @__PURE__ */ new Set([...Array.from(prev), eid]));
22958
23041
  broadcastAgentAborted(eid);
@@ -22960,7 +23043,7 @@ var AgentActivityList = ({
22960
23043
  await abortAgentExecution({
22961
23044
  workflowId: wfId,
22962
23045
  executionId: eid,
22963
- authorization: run.authorization,
23046
+ authorization: run2.authorization,
22964
23047
  apiKey,
22965
23048
  apiBaseUrl,
22966
23049
  orgId
@@ -22977,7 +23060,7 @@ var AgentActivityList = ({
22977
23060
  setRuns(
22978
23061
  (prev) => prev.map((r) => r.execution_id === eid ? { ...r, status: prevStatus } : r)
22979
23062
  );
22980
- toast({
23063
+ toast2({
22981
23064
  title: "Abort failed",
22982
23065
  description: e instanceof Error ? e.message : "Failed to abort execution",
22983
23066
  variant: "destructive"
@@ -23473,18 +23556,18 @@ var AgentActivityList = ({
23473
23556
  }
23474
23557
  )
23475
23558
  ] }) : /* @__PURE__ */ jsxs23(Box21, { sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: [
23476
- filteredRuns.map((run, idx) => /* @__PURE__ */ jsx30(
23559
+ filteredRuns.map((run2, idx) => /* @__PURE__ */ jsx30(
23477
23560
  AgentRunRow,
23478
23561
  {
23479
- run,
23562
+ run: run2,
23480
23563
  onClick: () => {
23481
- setLastOpenedAgentRun(run.execution_id);
23482
- setLastOpenedRunId(run.execution_id || null);
23483
- onRunClick?.(run);
23564
+ setLastOpenedAgentRun(run2.execution_id);
23565
+ setLastOpenedRunId(run2.execution_id || null);
23566
+ onRunClick?.(run2);
23484
23567
  },
23485
23568
  sx: [
23486
23569
  ...Array.isArray(rowSx) ? rowSx : rowSx ? [rowSx] : [],
23487
- ...run.execution_id && run.execution_id === lastOpenedRunId ? [{
23570
+ ...run2.execution_id && run2.execution_id === lastOpenedRunId ? [{
23488
23571
  borderColor: "hsl(var(--primary) / 0.55)",
23489
23572
  bgcolor: "hsl(var(--primary) / 0.06)"
23490
23573
  }] : []
@@ -23497,7 +23580,7 @@ var AgentActivityList = ({
23497
23580
  abortingIds,
23498
23581
  onAbort: handleAbort
23499
23582
  },
23500
- run.execution_id || idx
23583
+ run2.execution_id || idx
23501
23584
  )),
23502
23585
  hasMore && /* @__PURE__ */ jsx30(Box21, { sx: { display: "flex", justifyContent: "center", mt: 1 }, children: /* @__PURE__ */ jsxs23(
23503
23586
  Button11,
@@ -23571,7 +23654,7 @@ import { Fragment as Fragment11, jsx as jsx31, jsxs as jsxs24 } from "react/jsx-
23571
23654
  var AgentExecutionDrawer = ({
23572
23655
  open,
23573
23656
  onClose,
23574
- run,
23657
+ run: run2,
23575
23658
  width = 720,
23576
23659
  minWidth = 480,
23577
23660
  maxWidth = 960,
@@ -23596,16 +23679,16 @@ var AgentExecutionDrawer = ({
23596
23679
  const themeScope = useShuffleMcpTheme();
23597
23680
  const [bodyReady, setBodyReady] = useState20(false);
23598
23681
  useEffect18(() => {
23599
- if (!open || !run?.execution_id) {
23682
+ if (!open || !run2?.execution_id) {
23600
23683
  setBodyReady(false);
23601
23684
  return;
23602
23685
  }
23603
23686
  const raf = requestAnimationFrame(() => setBodyReady(true));
23604
23687
  return () => cancelAnimationFrame(raf);
23605
- }, [open, run?.execution_id]);
23606
- const statusKey = (run?.status || "").toUpperCase();
23688
+ }, [open, run2?.execution_id]);
23689
+ const statusKey = (run2?.status || "").toUpperCase();
23607
23690
  const cfg = STATUS_CONFIG[statusKey] || STATUS_CONFIG.WAITING;
23608
- const duration = run ? formatDuration(run) : "";
23691
+ const duration = run2 ? formatDuration(run2) : "";
23609
23692
  const drawerWidth = `min(${width}px, 100vw)`;
23610
23693
  const drawerMinWidth = `min(${minWidth}px, 100vw)`;
23611
23694
  const drawerMaxWidth = `min(${maxWidth}px, 100vw)`;
@@ -23695,16 +23778,16 @@ var AgentExecutionDrawer = ({
23695
23778
  textOverflow: "ellipsis",
23696
23779
  whiteSpace: "nowrap"
23697
23780
  },
23698
- children: run ? getRunTitle(run) : "Agent execution"
23781
+ children: run2 ? getRunTitle(run2) : "Agent execution"
23699
23782
  }
23700
23783
  ),
23701
- run && /* @__PURE__ */ jsx31(Box22, { sx: { display: "flex", alignItems: "center", color: cfg.color, flexShrink: 0 }, children: cfg.icon })
23784
+ run2 && /* @__PURE__ */ jsx31(Box22, { sx: { display: "flex", alignItems: "center", color: cfg.color, flexShrink: 0 }, children: cfg.icon })
23702
23785
  ] }),
23703
- run && /* @__PURE__ */ jsxs24(Box22, { sx: { display: "flex", alignItems: "center", gap: 1, mt: 0.25 }, children: [
23786
+ run2 && /* @__PURE__ */ jsxs24(Box22, { sx: { display: "flex", alignItems: "center", gap: 1, mt: 0.25 }, children: [
23704
23787
  /* @__PURE__ */ jsx31(Typography19, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: cfg.label }),
23705
- run.started_at && /* @__PURE__ */ jsxs24(Fragment11, { children: [
23788
+ run2.started_at && /* @__PURE__ */ jsxs24(Fragment11, { children: [
23706
23789
  /* @__PURE__ */ jsx31(Typography19, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
23707
- /* @__PURE__ */ jsx31(Typography19, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: getTimeAgo(run.started_at) })
23790
+ /* @__PURE__ */ jsx31(Typography19, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))" }, children: getTimeAgo(run2.started_at) })
23708
23791
  ] }),
23709
23792
  duration && /* @__PURE__ */ jsxs24(Fragment11, { children: [
23710
23793
  /* @__PURE__ */ jsx31(Typography19, { sx: { fontSize: "0.72rem", color: "hsl(var(--muted-foreground))", opacity: 0.4 }, children: "\xB7" }),
@@ -23712,11 +23795,11 @@ var AgentExecutionDrawer = ({
23712
23795
  ] })
23713
23796
  ] })
23714
23797
  ] }),
23715
- run?.execution_id && /* @__PURE__ */ jsx31(Tooltip16, { title: "Open in new tab", children: /* @__PURE__ */ jsx31(
23798
+ run2?.execution_id && /* @__PURE__ */ jsx31(Tooltip16, { title: "Open in new tab", children: /* @__PURE__ */ jsx31(
23716
23799
  IconButton10,
23717
23800
  {
23718
23801
  component: "a",
23719
- href: `/agents?execution_id=${encodeURIComponent(run.execution_id)}${run.authorization ? `&authorization=${encodeURIComponent(run.authorization)}` : ""}`,
23802
+ href: `/agents?execution_id=${encodeURIComponent(run2.execution_id)}${run2.authorization ? `&authorization=${encodeURIComponent(run2.authorization)}` : ""}`,
23720
23803
  target: "_blank",
23721
23804
  rel: "noopener noreferrer",
23722
23805
  size: "small",
@@ -23744,7 +23827,7 @@ var AgentExecutionDrawer = ({
23744
23827
  ),
23745
23828
  /* @__PURE__ */ jsxs24(Box22, { sx: [{ flex: 1, overflowY: "auto", pt: 3 }, ...Array.isArray(bodySx) ? bodySx : bodySx ? [bodySx] : []], children: [
23746
23829
  topBanner,
23747
- run && !bodyReady ? /* @__PURE__ */ jsx31(Box22, { sx: { px: 3, display: "flex", flexDirection: "column", gap: 1.5 }, children: [0, 1, 2, 3].map((i) => /* @__PURE__ */ jsx31(
23830
+ run2 && !bodyReady ? /* @__PURE__ */ jsx31(Box22, { sx: { px: 3, display: "flex", flexDirection: "column", gap: 1.5 }, children: [0, 1, 2, 3].map((i) => /* @__PURE__ */ jsx31(
23748
23831
  Box22,
23749
23832
  {
23750
23833
  sx: {
@@ -23756,17 +23839,17 @@ var AgentExecutionDrawer = ({
23756
23839
  },
23757
23840
  i
23758
23841
  )) }) : null,
23759
- run && bodyReady ? /* @__PURE__ */ jsx31(
23842
+ run2 && bodyReady ? /* @__PURE__ */ jsx31(
23760
23843
  AgentUI_default,
23761
23844
  {
23762
23845
  initialExecution: {
23763
- execution_id: run.execution_id,
23764
- status: run.status,
23765
- started_at: run.started_at ? Number(run.started_at) : void 0,
23766
- completed_at: run.completed_at ? Number(run.completed_at) : void 0,
23767
- results: run.results,
23768
- workflow: run.workflow,
23769
- authorization: run.authorization
23846
+ execution_id: run2.execution_id,
23847
+ status: run2.status,
23848
+ started_at: run2.started_at ? Number(run2.started_at) : void 0,
23849
+ completed_at: run2.completed_at ? Number(run2.completed_at) : void 0,
23850
+ results: run2.results,
23851
+ workflow: run2.workflow,
23852
+ authorization: run2.authorization
23770
23853
  },
23771
23854
  readUrlParams: false,
23772
23855
  autoLoadApps: false,
@@ -23784,7 +23867,7 @@ var AgentExecutionDrawer = ({
23784
23867
  theme,
23785
23868
  colorMode
23786
23869
  },
23787
- run.execution_id
23870
+ run2.execution_id
23788
23871
  ) : null
23789
23872
  ] })
23790
23873
  ]
@@ -23961,10 +24044,10 @@ var AgentsView = ({
23961
24044
  editing.workflowId,
23962
24045
  { prompt: input, apps: apps.map((a) => ({ name: a.name, id: a.id })) }
23963
24046
  );
23964
- toast({ title: "Schedule updated", description: `Saved changes to "${editing.name}".` });
24047
+ toast2({ title: "Schedule updated", description: `Saved changes to "${editing.name}".` });
23965
24048
  setEditing(null);
23966
24049
  } catch (e) {
23967
- toast({
24050
+ toast2({
23968
24051
  title: "Failed to save changes",
23969
24052
  description: e instanceof Error ? e.message : String(e),
23970
24053
  variant: "destructive"
@@ -26134,14 +26217,19 @@ function buildPython(method, url, headers, body, maskAuth) {
26134
26217
  return lines.join("\n");
26135
26218
  }
26136
26219
  function buildHttp(method, url, headers, body, maskAuth) {
26137
- let parsed;
26220
+ let parsed = null;
26138
26221
  try {
26139
26222
  parsed = new URL(url);
26140
26223
  } catch {
26141
- parsed = new URL(url, "https://localhost");
26224
+ try {
26225
+ parsed = new URL(url, "https://localhost");
26226
+ } catch {
26227
+ parsed = null;
26228
+ }
26142
26229
  }
26143
- const lines = [`${(method || "GET").toUpperCase()} ${parsed.pathname}${parsed.search} HTTP/1.1`];
26144
- lines.push(`Host: ${parsed.host}`);
26230
+ const requestTarget = parsed ? `${parsed.pathname}${parsed.search}` : url || "/";
26231
+ const lines = [`${(method || "GET").toUpperCase()} ${requestTarget} HTTP/1.1`];
26232
+ lines.push(`Host: ${parsed?.host ?? url}`);
26145
26233
  for (const [key, value] of Object.entries(headers)) {
26146
26234
  if (key.toLowerCase() === "host") continue;
26147
26235
  const displayValue = maskAuth && key.toLowerCase() === "authorization" ? value.replace(/(Bearer\s+)(.{8}).*/, "$1$2\u2026") : value;
@@ -26274,10 +26362,10 @@ var ApiCallViewer = ({
26274
26362
  await navigator.clipboard.writeText(copyableSnippet);
26275
26363
  }
26276
26364
  setCopied(true);
26277
- toast.success("Copied to clipboard");
26365
+ toast2.success("Copied to clipboard");
26278
26366
  setTimeout(() => setCopied(false), 2e3);
26279
26367
  } catch {
26280
- toast.error("Copy failed");
26368
+ toast2.error("Copy failed");
26281
26369
  }
26282
26370
  }, [copyableSnippet]);
26283
26371
  const handleRun = useCallback14(async () => {
@@ -26333,16 +26421,16 @@ var ApiCallViewer = ({
26333
26421
  const isSuccess = res.ok && (!rawResult || typeof rawResult === "string" && !rawResult.includes('"success": false') || data?.success !== false);
26334
26422
  setResponseStatus(isSuccess ? `Status: ${res.status} OK` : `Status: ${res.status} Error`);
26335
26423
  if (isSuccess) {
26336
- toast.success(`Request completed in ${duration}ms`);
26424
+ toast2.success(`Request completed in ${duration}ms`);
26337
26425
  } else {
26338
- toast.error("Request finished with error");
26426
+ toast2.error("Request finished with error");
26339
26427
  }
26340
26428
  } catch (err) {
26341
26429
  setResponseDuration(Date.now() - start);
26342
26430
  setResponseStatus("Request Failed");
26343
26431
  setResponseOutput(err?.message || "Network error executing request");
26344
26432
  setParsedResponse(null);
26345
- toast.error("Failed to run request");
26433
+ toast2.error("Failed to run request");
26346
26434
  } finally {
26347
26435
  setIsRunning(false);
26348
26436
  }
@@ -26690,9 +26778,9 @@ var ApiCallViewer = ({
26690
26778
  if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
26691
26779
  navigator.clipboard.writeText(responseOutput);
26692
26780
  }
26693
- toast.success("Response copied");
26781
+ toast2.success("Response copied");
26694
26782
  } catch {
26695
- toast.error("Copy failed");
26783
+ toast2.error("Copy failed");
26696
26784
  }
26697
26785
  },
26698
26786
  sx: {
@@ -28318,7 +28406,7 @@ export {
28318
28406
  setRuntimeOrgId,
28319
28407
  setToastImpl,
28320
28408
  shuffleFetch,
28321
- toast,
28409
+ toast2 as toast,
28322
28410
  useAgentPromptPrefix,
28323
28411
  useAppAuth,
28324
28412
  useAppAuthFlow,