@shuffleio/shuffle-mcps 0.0.55 → 0.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1024,10 +1024,10 @@ var init_api = __esm({
|
|
|
1024
1024
|
let orgId = overrideOrgId ?? _trackedOrgId;
|
|
1025
1025
|
if (!orgId && typeof localStorage !== "undefined") {
|
|
1026
1026
|
try {
|
|
1027
|
-
const raw = localStorage.getItem("shuffle_user_info");
|
|
1027
|
+
const raw = localStorage.getItem("shuffle_user_info") || localStorage.getItem("userinfo") || localStorage.getItem("user_info");
|
|
1028
1028
|
if (raw) {
|
|
1029
1029
|
const parsed = JSON.parse(raw);
|
|
1030
|
-
orgId = parsed?.active_org?.id || parsed?.org_id || null;
|
|
1030
|
+
orgId = parsed?.active_org?.id || parsed?.org_id || parsed?.active_org_id || parsed?.orgs && parsed.orgs[0]?.id || null;
|
|
1031
1031
|
}
|
|
1032
1032
|
} catch {
|
|
1033
1033
|
}
|
|
@@ -1257,7 +1257,7 @@ __export(index_exports, {
|
|
|
1257
1257
|
});
|
|
1258
1258
|
module.exports = __toCommonJS(index_exports);
|
|
1259
1259
|
var import_shuffle_mcp3 = require("./shuffle-mcp-SHQXQS3F.css");
|
|
1260
|
-
var
|
|
1260
|
+
var import_react39 = __toESM(require("react"));
|
|
1261
1261
|
|
|
1262
1262
|
// ShuffleMcpThemeProvider.tsx
|
|
1263
1263
|
var import_react = __toESM(require("react"));
|
|
@@ -1470,7 +1470,7 @@ var ShuffleMcpThemeProvider = ({
|
|
|
1470
1470
|
};
|
|
1471
1471
|
|
|
1472
1472
|
// views/ShuffleMCP.tsx
|
|
1473
|
-
var
|
|
1473
|
+
var import_react15 = __toESM(require("react"));
|
|
1474
1474
|
var import_algoliasearch = require("algoliasearch");
|
|
1475
1475
|
var import_material15 = require("@mui/material");
|
|
1476
1476
|
|
|
@@ -2819,10 +2819,10 @@ var setRuntimeOrgId = (orgId) => {
|
|
|
2819
2819
|
var getOrgId = () => {
|
|
2820
2820
|
if (_runtimeOrgId) return _runtimeOrgId;
|
|
2821
2821
|
try {
|
|
2822
|
-
const userInfo = localStorage.getItem("shuffle_user_info");
|
|
2822
|
+
const userInfo = localStorage.getItem("shuffle_user_info") || localStorage.getItem("userinfo") || localStorage.getItem("user_info");
|
|
2823
2823
|
if (userInfo) {
|
|
2824
2824
|
const parsed = JSON.parse(userInfo);
|
|
2825
|
-
return parsed.active_org?.id || null;
|
|
2825
|
+
return parsed.active_org?.id || parsed.org_id || parsed.active_org_id || parsed.orgs && parsed.orgs[0]?.id || null;
|
|
2826
2826
|
}
|
|
2827
2827
|
} catch {
|
|
2828
2828
|
}
|
|
@@ -3920,13 +3920,22 @@ var useSyncHostBaseUrl = (globalUrl) => {
|
|
|
3920
3920
|
};
|
|
3921
3921
|
|
|
3922
3922
|
// auth-utils.ts
|
|
3923
|
+
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
3924
|
+
function isValidationFresh(validation) {
|
|
3925
|
+
if (validation?.valid !== true) return false;
|
|
3926
|
+
if (!validation.last_valid) return true;
|
|
3927
|
+
const cutoff = Date.now() - THIRTY_DAYS_MS;
|
|
3928
|
+
const lastValidMs = validation.last_valid > 1e12 ? validation.last_valid : validation.last_valid * 1e3;
|
|
3929
|
+
return lastValidMs >= cutoff;
|
|
3930
|
+
}
|
|
3923
3931
|
function deduplicateAuthApps(apps) {
|
|
3924
3932
|
const appMap = /* @__PURE__ */ new Map();
|
|
3925
3933
|
apps.forEach((auth) => {
|
|
3926
|
-
if (!auth.
|
|
3934
|
+
if (!auth.app?.name) return;
|
|
3935
|
+
if (!auth.active && !isValidationFresh(auth.validation)) return;
|
|
3927
3936
|
const normalizedName = auth.app.name.toLowerCase().trim().replace(/[\s_\-]+/g, "_");
|
|
3928
3937
|
const existing = appMap.get(normalizedName);
|
|
3929
|
-
const isValidated = auth.validation
|
|
3938
|
+
const isValidated = isValidationFresh(auth.validation);
|
|
3930
3939
|
const entryImage = auth.app.large_image || "";
|
|
3931
3940
|
const instance = {
|
|
3932
3941
|
label: auth.label || auth.id || "Default",
|
|
@@ -4142,7 +4151,7 @@ function findForwardTicketsWorkflow(workflows) {
|
|
|
4142
4151
|
}
|
|
4143
4152
|
function extractValidatedIngestionApps(authApiResponse, workflowAppNames) {
|
|
4144
4153
|
const dedupedApps = deduplicateAuthApps(
|
|
4145
|
-
authApiResponse.filter((auth) => auth.active || auth.validation
|
|
4154
|
+
authApiResponse.filter((auth) => auth.active || isValidationFresh(auth.validation))
|
|
4146
4155
|
);
|
|
4147
4156
|
const enabledNames = workflowAppNames || /* @__PURE__ */ new Set();
|
|
4148
4157
|
const apps = [];
|
|
@@ -4249,9 +4258,9 @@ function invalidateAuthCache() {
|
|
|
4249
4258
|
var TTL_MS2 = 3e4;
|
|
4250
4259
|
var cache3 = /* @__PURE__ */ new Map();
|
|
4251
4260
|
var cacheKey2 = (crossOrgId) => crossOrgId || "";
|
|
4252
|
-
var
|
|
4261
|
+
var THIRTY_DAYS_MS2 = 30 * 24 * 60 * 60 * 1e3;
|
|
4253
4262
|
var applyValidationStaleness = (data) => {
|
|
4254
|
-
const cutoff = Date.now() -
|
|
4263
|
+
const cutoff = Date.now() - THIRTY_DAYS_MS2;
|
|
4255
4264
|
return data.map((entry) => {
|
|
4256
4265
|
const v = entry.validation;
|
|
4257
4266
|
if (v?.valid === true && v?.last_valid) {
|
|
@@ -9645,6 +9654,33 @@ function AppDetailContent({
|
|
|
9645
9654
|
] });
|
|
9646
9655
|
}
|
|
9647
9656
|
|
|
9657
|
+
// drawerLayer.ts
|
|
9658
|
+
var import_react14 = require("react");
|
|
9659
|
+
var COUNTER_KEY = "__shuffleDrawerLayerTop";
|
|
9660
|
+
var DRAWER_LAYER_BASE = 10011;
|
|
9661
|
+
var STEP = 10;
|
|
9662
|
+
var getTop = (base3) => {
|
|
9663
|
+
const store = globalThis;
|
|
9664
|
+
const current = store[COUNTER_KEY];
|
|
9665
|
+
return typeof current === "number" ? current : base3;
|
|
9666
|
+
};
|
|
9667
|
+
var useDrawerLayer = (open, base3 = DRAWER_LAYER_BASE) => {
|
|
9668
|
+
const [zIndex, setZIndex] = (0, import_react14.useState)(base3);
|
|
9669
|
+
(0, import_react14.useEffect)(() => {
|
|
9670
|
+
if (!open) return;
|
|
9671
|
+
const store = globalThis;
|
|
9672
|
+
const next = Math.max(base3, getTop(base3) + STEP);
|
|
9673
|
+
store[COUNTER_KEY] = next;
|
|
9674
|
+
setZIndex(next);
|
|
9675
|
+
return () => {
|
|
9676
|
+
if (store[COUNTER_KEY] === next) {
|
|
9677
|
+
store[COUNTER_KEY] = next - STEP;
|
|
9678
|
+
}
|
|
9679
|
+
};
|
|
9680
|
+
}, [open, base3]);
|
|
9681
|
+
return zIndex;
|
|
9682
|
+
};
|
|
9683
|
+
|
|
9648
9684
|
// views/AppDetailDrawer.tsx
|
|
9649
9685
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
9650
9686
|
function AppDetailDrawer({
|
|
@@ -9674,6 +9710,7 @@ function AppDetailDrawer({
|
|
|
9674
9710
|
const drawerWidth = `min(${width}px, 100vw)`;
|
|
9675
9711
|
const drawerMinWidth = `min(${minWidth}px, 100vw)`;
|
|
9676
9712
|
const drawerMaxWidth = `min(${maxWidth}px, 100vw)`;
|
|
9713
|
+
const drawerZIndex = useDrawerLayer(open);
|
|
9677
9714
|
const handleClose = () => {
|
|
9678
9715
|
onRefresh?.();
|
|
9679
9716
|
onClose();
|
|
@@ -9705,7 +9742,7 @@ function AppDetailDrawer({
|
|
|
9705
9742
|
},
|
|
9706
9743
|
...{ PaperProps: drawerPaperProps },
|
|
9707
9744
|
sx: {
|
|
9708
|
-
zIndex:
|
|
9745
|
+
zIndex: drawerZIndex,
|
|
9709
9746
|
"& .MuiDrawer-paper": {
|
|
9710
9747
|
boxSizing: "border-box",
|
|
9711
9748
|
width: `${drawerWidth} !important`,
|
|
@@ -10046,7 +10083,7 @@ var SearchErrorMessage = ({ rateLimited, message }) => {
|
|
|
10046
10083
|
}
|
|
10047
10084
|
);
|
|
10048
10085
|
};
|
|
10049
|
-
var ShuffleMCP =
|
|
10086
|
+
var ShuffleMCP = import_react15.default.forwardRef(({
|
|
10050
10087
|
authToken,
|
|
10051
10088
|
orgId,
|
|
10052
10089
|
placeholder = "Search apps...",
|
|
@@ -10091,33 +10128,33 @@ var ShuffleMCP = import_react14.default.forwardRef(({
|
|
|
10091
10128
|
globalUrl
|
|
10092
10129
|
}, ref) => {
|
|
10093
10130
|
useSyncHostBaseUrl(globalUrl);
|
|
10094
|
-
const [query, setQuery] = (0,
|
|
10095
|
-
const [results, setResults] = (0,
|
|
10096
|
-
const [privateApps, setPrivateApps] = (0,
|
|
10097
|
-
const [privateAppsLoading, setPrivateAppsLoading] = (0,
|
|
10098
|
-
const [sourceFilter, setSourceFilter] = (0,
|
|
10099
|
-
const [isLoading, setIsLoading] = (0,
|
|
10100
|
-
const [isLoadingMore, setIsLoadingMore] = (0,
|
|
10101
|
-
const [page, setPage] = (0,
|
|
10102
|
-
const [hasMore, setHasMore] = (0,
|
|
10103
|
-
const [searchError, setSearchError] = (0,
|
|
10104
|
-
const [isOpen, setIsOpen] = (0,
|
|
10105
|
-
const [selectedIndex, setSelectedIndex] = (0,
|
|
10106
|
-
const [internalSelectedApps, setInternalSelectedApps] = (0,
|
|
10107
|
-
const [authenticatedApps, setAuthenticatedApps] = (0,
|
|
10108
|
-
const [authenticatedAppsLoading, setAuthenticatedAppsLoading] = (0,
|
|
10109
|
-
const [drawerApp, setDrawerApp] = (0,
|
|
10110
|
-
const [initialSettled, setInitialSettled] = (0,
|
|
10111
|
-
const firstSearchDoneRef = (0,
|
|
10112
|
-
const hasInitialized = (0,
|
|
10113
|
-
const containerRef = (0,
|
|
10114
|
-
const resultsScrollRef = (0,
|
|
10115
|
-
const inputRef = (0,
|
|
10116
|
-
const debounceTimer = (0,
|
|
10117
|
-
const searchClient = (0,
|
|
10118
|
-
const activeQueryRef = (0,
|
|
10119
|
-
const initialSelectedAppsRef = (0,
|
|
10120
|
-
const fetchAuthenticatedApps2 = (0,
|
|
10131
|
+
const [query, setQuery] = (0, import_react15.useState)(initialQuery);
|
|
10132
|
+
const [results, setResults] = (0, import_react15.useState)([]);
|
|
10133
|
+
const [privateApps, setPrivateApps] = (0, import_react15.useState)([]);
|
|
10134
|
+
const [privateAppsLoading, setPrivateAppsLoading] = (0, import_react15.useState)(!disablePrivateApps);
|
|
10135
|
+
const [sourceFilter, setSourceFilter] = (0, import_react15.useState)("all");
|
|
10136
|
+
const [isLoading, setIsLoading] = (0, import_react15.useState)(false);
|
|
10137
|
+
const [isLoadingMore, setIsLoadingMore] = (0, import_react15.useState)(false);
|
|
10138
|
+
const [page, setPage] = (0, import_react15.useState)(0);
|
|
10139
|
+
const [hasMore, setHasMore] = (0, import_react15.useState)(false);
|
|
10140
|
+
const [searchError, setSearchError] = (0, import_react15.useState)(null);
|
|
10141
|
+
const [isOpen, setIsOpen] = (0, import_react15.useState)(false);
|
|
10142
|
+
const [selectedIndex, setSelectedIndex] = (0, import_react15.useState)(-1);
|
|
10143
|
+
const [internalSelectedApps, setInternalSelectedApps] = (0, import_react15.useState)(selectedApps);
|
|
10144
|
+
const [authenticatedApps, setAuthenticatedApps] = (0, import_react15.useState)(externalAuthenticatedApps || []);
|
|
10145
|
+
const [authenticatedAppsLoading, setAuthenticatedAppsLoading] = (0, import_react15.useState)(!externalAuthenticatedApps);
|
|
10146
|
+
const [drawerApp, setDrawerApp] = (0, import_react15.useState)(null);
|
|
10147
|
+
const [initialSettled, setInitialSettled] = (0, import_react15.useState)(false);
|
|
10148
|
+
const firstSearchDoneRef = (0, import_react15.useRef)(false);
|
|
10149
|
+
const hasInitialized = (0, import_react15.useRef)(false);
|
|
10150
|
+
const containerRef = (0, import_react15.useRef)(null);
|
|
10151
|
+
const resultsScrollRef = (0, import_react15.useRef)(null);
|
|
10152
|
+
const inputRef = (0, import_react15.useRef)(null);
|
|
10153
|
+
const debounceTimer = (0, import_react15.useRef)(null);
|
|
10154
|
+
const searchClient = (0, import_react15.useRef)(null);
|
|
10155
|
+
const activeQueryRef = (0, import_react15.useRef)("");
|
|
10156
|
+
const initialSelectedAppsRef = (0, import_react15.useRef)(selectedApps);
|
|
10157
|
+
const fetchAuthenticatedApps2 = (0, import_react15.useCallback)(async () => {
|
|
10121
10158
|
if (!apiKey) {
|
|
10122
10159
|
setAuthenticatedAppsLoading(false);
|
|
10123
10160
|
return;
|
|
@@ -10143,10 +10180,10 @@ var ShuffleMCP = import_react14.default.forwardRef(({
|
|
|
10143
10180
|
setAuthenticatedAppsLoading(false);
|
|
10144
10181
|
}
|
|
10145
10182
|
}, [apiKey, apiBaseUrl, authPath, orgId]);
|
|
10146
|
-
(0,
|
|
10183
|
+
(0, import_react15.useEffect)(() => {
|
|
10147
10184
|
fetchAuthenticatedApps2();
|
|
10148
10185
|
}, [fetchAuthenticatedApps2]);
|
|
10149
|
-
(0,
|
|
10186
|
+
(0, import_react15.useEffect)(() => {
|
|
10150
10187
|
if (disablePrivateApps) {
|
|
10151
10188
|
setPrivateApps([]);
|
|
10152
10189
|
setPrivateAppsLoading(false);
|
|
@@ -10190,7 +10227,7 @@ var ShuffleMCP = import_react14.default.forwardRef(({
|
|
|
10190
10227
|
};
|
|
10191
10228
|
fetchPrivateApps();
|
|
10192
10229
|
}, [apiKey, apiBaseUrl, privateAppsPath, disablePrivateApps, orgId]);
|
|
10193
|
-
(0,
|
|
10230
|
+
(0, import_react15.useEffect)(() => {
|
|
10194
10231
|
if (disableAutoSelectValidatedApps) return;
|
|
10195
10232
|
if (authenticatedApps.length > 0 && results.length > 0) {
|
|
10196
10233
|
const validatedApps = authenticatedApps.filter((auth) => auth.validation?.valid);
|
|
@@ -10211,13 +10248,13 @@ var ShuffleMCP = import_react14.default.forwardRef(({
|
|
|
10211
10248
|
}
|
|
10212
10249
|
}
|
|
10213
10250
|
}, [authenticatedApps, results, disableAutoSelectValidatedApps]);
|
|
10214
|
-
(0,
|
|
10251
|
+
(0, import_react15.useEffect)(() => {
|
|
10215
10252
|
if (externalAuthenticatedApps) {
|
|
10216
10253
|
setAuthenticatedApps(externalAuthenticatedApps);
|
|
10217
10254
|
setAuthenticatedAppsLoading(false);
|
|
10218
10255
|
}
|
|
10219
10256
|
}, [externalAuthenticatedApps]);
|
|
10220
|
-
(0,
|
|
10257
|
+
(0, import_react15.useEffect)(() => {
|
|
10221
10258
|
searchClient.current = (0, import_algoliasearch.algoliasearch)(algoliaAppId, algoliaApiKey);
|
|
10222
10259
|
if (!hasInitialized.current) {
|
|
10223
10260
|
hasInitialized.current = true;
|
|
@@ -10230,10 +10267,10 @@ var ShuffleMCP = import_react14.default.forwardRef(({
|
|
|
10230
10267
|
}, 100);
|
|
10231
10268
|
}
|
|
10232
10269
|
}, []);
|
|
10233
|
-
(0,
|
|
10270
|
+
(0, import_react15.useEffect)(() => {
|
|
10234
10271
|
setInternalSelectedApps(selectedApps);
|
|
10235
10272
|
}, [selectedApps]);
|
|
10236
|
-
(0,
|
|
10273
|
+
(0, import_react15.useEffect)(() => {
|
|
10237
10274
|
const handleClickOutside = (event) => {
|
|
10238
10275
|
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
10239
10276
|
setIsOpen(false);
|
|
@@ -10243,23 +10280,23 @@ var ShuffleMCP = import_react14.default.forwardRef(({
|
|
|
10243
10280
|
document.addEventListener("click", handleClickOutside);
|
|
10244
10281
|
return () => document.removeEventListener("click", handleClickOutside);
|
|
10245
10282
|
}, []);
|
|
10246
|
-
const isAppConfigured = (0,
|
|
10283
|
+
const isAppConfigured = (0, import_react15.useCallback)((app2) => {
|
|
10247
10284
|
return authenticatedApps.some(
|
|
10248
10285
|
(auth) => auth.app.name.toLowerCase() === app2.name.toLowerCase() && auth.active === true
|
|
10249
10286
|
);
|
|
10250
10287
|
}, [authenticatedApps]);
|
|
10251
|
-
const isAppValidated = (0,
|
|
10288
|
+
const isAppValidated = (0, import_react15.useCallback)((app2) => {
|
|
10252
10289
|
return authenticatedApps.some(
|
|
10253
10290
|
(auth) => auth.app.name.toLowerCase() === app2.name.toLowerCase() && auth.validation?.valid === true
|
|
10254
10291
|
);
|
|
10255
10292
|
}, [authenticatedApps]);
|
|
10256
|
-
const getAppAuthState = (0,
|
|
10293
|
+
const getAppAuthState = (0, import_react15.useCallback)((app2) => {
|
|
10257
10294
|
return {
|
|
10258
10295
|
configured: isAppConfigured(app2),
|
|
10259
10296
|
validated: isAppValidated(app2)
|
|
10260
10297
|
};
|
|
10261
10298
|
}, [isAppConfigured, isAppValidated]);
|
|
10262
|
-
const performSearch = (0,
|
|
10299
|
+
const performSearch = (0, import_react15.useCallback)(async (searchQuery, pageIndex = 0) => {
|
|
10263
10300
|
if (!searchClient.current) {
|
|
10264
10301
|
return;
|
|
10265
10302
|
}
|
|
@@ -10319,29 +10356,29 @@ var ShuffleMCP = import_react14.default.forwardRef(({
|
|
|
10319
10356
|
}
|
|
10320
10357
|
}
|
|
10321
10358
|
}, [hitsPerPage, algoliaIndexName, privateApps.length, results.length]);
|
|
10322
|
-
(0,
|
|
10359
|
+
(0, import_react15.useEffect)(() => {
|
|
10323
10360
|
if (initialSettled) return;
|
|
10324
10361
|
if (!firstSearchDoneRef.current || isLoading || privateAppsLoading) return;
|
|
10325
10362
|
initialSelectedAppsRef.current = selectedApps;
|
|
10326
10363
|
setInitialSettled(true);
|
|
10327
10364
|
}, [initialSettled, isLoading, privateAppsLoading, selectedApps]);
|
|
10328
|
-
(0,
|
|
10365
|
+
(0, import_react15.useEffect)(() => {
|
|
10329
10366
|
const t = setTimeout(() => setInitialSettled(true), 6e3);
|
|
10330
10367
|
return () => clearTimeout(t);
|
|
10331
10368
|
}, []);
|
|
10332
10369
|
const canLoadMore = hasMore && !isLoading && !isLoadingMore && results.length < MAX_RESULTS;
|
|
10333
|
-
const loadMore = (0,
|
|
10370
|
+
const loadMore = (0, import_react15.useCallback)(() => {
|
|
10334
10371
|
if (!canLoadMore) return;
|
|
10335
10372
|
performSearch(activeQueryRef.current, page + 1);
|
|
10336
10373
|
}, [canLoadMore, page, performSearch]);
|
|
10337
|
-
const handleResultsScroll = (0,
|
|
10374
|
+
const handleResultsScroll = (0, import_react15.useCallback)((e) => {
|
|
10338
10375
|
if (!canLoadMore) return;
|
|
10339
10376
|
const el = e.currentTarget;
|
|
10340
10377
|
const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight;
|
|
10341
10378
|
if (distanceFromBottom < 200) loadMore();
|
|
10342
10379
|
}, [canLoadMore, loadMore]);
|
|
10343
|
-
const sentinelRef = (0,
|
|
10344
|
-
(0,
|
|
10380
|
+
const sentinelRef = (0, import_react15.useRef)(null);
|
|
10381
|
+
(0, import_react15.useEffect)(() => {
|
|
10345
10382
|
const node = sentinelRef.current;
|
|
10346
10383
|
if (!node || !canLoadMore) return;
|
|
10347
10384
|
const observer = new IntersectionObserver(
|
|
@@ -10354,7 +10391,7 @@ var ShuffleMCP = import_react14.default.forwardRef(({
|
|
|
10354
10391
|
return () => observer.disconnect();
|
|
10355
10392
|
}, [canLoadMore, loadMore, results.length]);
|
|
10356
10393
|
const renderLoadMoreSentinel = () => canLoadMore ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { ref: sentinelRef, style: { height: 1, gridColumn: "1 / -1" } }) : null;
|
|
10357
|
-
(0,
|
|
10394
|
+
(0, import_react15.useImperativeHandle)(ref, () => ({
|
|
10358
10395
|
search: (searchQuery) => {
|
|
10359
10396
|
setQuery(searchQuery);
|
|
10360
10397
|
onSearchChange?.(searchQuery);
|
|
@@ -10377,7 +10414,7 @@ var ShuffleMCP = import_react14.default.forwardRef(({
|
|
|
10377
10414
|
},
|
|
10378
10415
|
getQuery: () => query
|
|
10379
10416
|
}), [performSearch, onSearchChange, query]);
|
|
10380
|
-
const handleInputChange = (0,
|
|
10417
|
+
const handleInputChange = (0, import_react15.useCallback)((event) => {
|
|
10381
10418
|
const value = event.target.value;
|
|
10382
10419
|
setQuery(value);
|
|
10383
10420
|
setSelectedIndex(-1);
|
|
@@ -10389,7 +10426,7 @@ var ShuffleMCP = import_react14.default.forwardRef(({
|
|
|
10389
10426
|
performSearch(value);
|
|
10390
10427
|
}, 300);
|
|
10391
10428
|
}, [performSearch, onSearchChange]);
|
|
10392
|
-
const selectApp = (0,
|
|
10429
|
+
const selectApp = (0, import_react15.useCallback)((app2) => {
|
|
10393
10430
|
const handoffToken = apiKey || authToken || "";
|
|
10394
10431
|
const authUrl = `${apiBaseUrl}${appAuthPath}?app_id=${app2.objectID}&auth=${handoffToken}&source=shuffle${orgId ? `&org_id=${encodeURIComponent(orgId)}` : ""}`;
|
|
10395
10432
|
if (multiSelect) {
|
|
@@ -10412,7 +10449,7 @@ var ShuffleMCP = import_react14.default.forwardRef(({
|
|
|
10412
10449
|
setIsOpen(false);
|
|
10413
10450
|
}
|
|
10414
10451
|
}, [authToken, apiKey, apiBaseUrl, appAuthPath, orgId, multiSelect, internalSelectedApps, onAppSelected, onSelectionChange, preventDefault]);
|
|
10415
|
-
const handleKeyDown = (0,
|
|
10452
|
+
const handleKeyDown = (0, import_react15.useCallback)((event) => {
|
|
10416
10453
|
if (!isOpen) return;
|
|
10417
10454
|
switch (event.key) {
|
|
10418
10455
|
case "ArrowDown":
|
|
@@ -10437,14 +10474,14 @@ var ShuffleMCP = import_react14.default.forwardRef(({
|
|
|
10437
10474
|
break;
|
|
10438
10475
|
}
|
|
10439
10476
|
}, [isOpen, results, selectedIndex, selectApp]);
|
|
10440
|
-
const isAppSelected = (0,
|
|
10477
|
+
const isAppSelected = (0, import_react15.useCallback)((app2) => {
|
|
10441
10478
|
const norm4 = (s) => (s || "").toLowerCase().replace(/[\s_\-]+/g, "");
|
|
10442
10479
|
const target = norm4(app2.name);
|
|
10443
10480
|
return internalSelectedApps.some(
|
|
10444
10481
|
(a) => a.objectID === app2.objectID || target && norm4(a.name) === target
|
|
10445
10482
|
);
|
|
10446
10483
|
}, [internalSelectedApps]);
|
|
10447
|
-
const filteredPrivateApps = (0,
|
|
10484
|
+
const filteredPrivateApps = (0, import_react15.useMemo)(() => {
|
|
10448
10485
|
if (privateApps.length === 0) return [];
|
|
10449
10486
|
const normalize2 = (s) => (s || "").toLowerCase().replace(/[\s_\-]+/g, "");
|
|
10450
10487
|
const q = normalize2(query.trim());
|
|
@@ -10453,7 +10490,7 @@ var ShuffleMCP = import_react14.default.forwardRef(({
|
|
|
10453
10490
|
(a) => normalize2(a.name).includes(q) || normalize2(a.description || "").includes(q) || (a.categories || []).some((c) => normalize2(c).includes(q))
|
|
10454
10491
|
);
|
|
10455
10492
|
}, [privateApps, query]);
|
|
10456
|
-
const displayResults = (0,
|
|
10493
|
+
const displayResults = (0, import_react15.useMemo)(() => {
|
|
10457
10494
|
const norm4 = (n) => (n || "").toLowerCase().replace(/[\s_\-]+/g, "");
|
|
10458
10495
|
let merged;
|
|
10459
10496
|
if (sourceFilter === "public") {
|
|
@@ -10483,7 +10520,7 @@ var ShuffleMCP = import_react14.default.forwardRef(({
|
|
|
10483
10520
|
const pinnedNames = new Set(pinnedApps.map((a) => norm4(a.name)));
|
|
10484
10521
|
return [...pinnedApps, ...sorted.filter((a) => !pinnedNames.has(norm4(a.name)))];
|
|
10485
10522
|
}, [pinnedApps, results, filteredPrivateApps, sourceFilter, isAppConfigured]);
|
|
10486
|
-
const getGridColumnsStyle = (0,
|
|
10523
|
+
const getGridColumnsStyle = (0, import_react15.useMemo)(() => {
|
|
10487
10524
|
if (layout !== "grid") return {};
|
|
10488
10525
|
const cols = typeof gridColumns === "number" ? gridColumns : gridColumns.md || 3;
|
|
10489
10526
|
return { "--singul-grid-columns": cols };
|
|
@@ -10762,13 +10799,13 @@ var ShuffleMCP = import_react14.default.forwardRef(({
|
|
|
10762
10799
|
ShuffleMCP.displayName = "ShuffleMCP";
|
|
10763
10800
|
|
|
10764
10801
|
// views/AppSearchDrawer.tsx
|
|
10765
|
-
var
|
|
10802
|
+
var import_react17 = require("react");
|
|
10766
10803
|
var import_lucide_react9 = require("lucide-react");
|
|
10767
10804
|
var import_material17 = require("@mui/material");
|
|
10768
10805
|
var import_framer_motion8 = require("framer-motion");
|
|
10769
10806
|
|
|
10770
10807
|
// ../Shuffle-Core/components/AddAppDialog.tsx
|
|
10771
|
-
var
|
|
10808
|
+
var import_react16 = require("react");
|
|
10772
10809
|
var import_material16 = require("@mui/material");
|
|
10773
10810
|
var import_lucide_react8 = require("lucide-react");
|
|
10774
10811
|
|
|
@@ -11226,8 +11263,8 @@ var GENERATION_TIPS = [
|
|
|
11226
11263
|
"Building the app with 100% fewer hand-wavy examples..."
|
|
11227
11264
|
];
|
|
11228
11265
|
var DotsLoader = ({ message, tips }) => {
|
|
11229
|
-
const [tipIndex, setTipIndex] = (0,
|
|
11230
|
-
(0,
|
|
11266
|
+
const [tipIndex, setTipIndex] = (0, import_react16.useState)(0);
|
|
11267
|
+
(0, import_react16.useEffect)(() => {
|
|
11231
11268
|
if (!tips || tips.length === 0) return;
|
|
11232
11269
|
const interval = setInterval(() => {
|
|
11233
11270
|
setTipIndex((i) => (i + 1) % tips.length);
|
|
@@ -11288,19 +11325,19 @@ var AddAppDialog = ({
|
|
|
11288
11325
|
maxLength = 1024,
|
|
11289
11326
|
initialInput = ""
|
|
11290
11327
|
}) => {
|
|
11291
|
-
const [input, setInput] = (0,
|
|
11292
|
-
const [stage, setStage] = (0,
|
|
11293
|
-
const [spec, setSpec] = (0,
|
|
11294
|
-
const [errorMsg, setErrorMsg] = (0,
|
|
11295
|
-
const [createdAppId, setCreatedAppId] = (0,
|
|
11296
|
-
const [existing, setExisting] = (0,
|
|
11297
|
-
const [liveHits, setLiveHits] = (0,
|
|
11298
|
-
const [liveSearching, setLiveSearching] = (0,
|
|
11299
|
-
(0,
|
|
11328
|
+
const [input, setInput] = (0, import_react16.useState)(initialInput);
|
|
11329
|
+
const [stage, setStage] = (0, import_react16.useState)("idle");
|
|
11330
|
+
const [spec, setSpec] = (0, import_react16.useState)(null);
|
|
11331
|
+
const [errorMsg, setErrorMsg] = (0, import_react16.useState)("");
|
|
11332
|
+
const [createdAppId, setCreatedAppId] = (0, import_react16.useState)("");
|
|
11333
|
+
const [existing, setExisting] = (0, import_react16.useState)(null);
|
|
11334
|
+
const [liveHits, setLiveHits] = (0, import_react16.useState)([]);
|
|
11335
|
+
const [liveSearching, setLiveSearching] = (0, import_react16.useState)(false);
|
|
11336
|
+
(0, import_react16.useEffect)(() => {
|
|
11300
11337
|
if (open) setInput(initialInput);
|
|
11301
11338
|
}, [open, initialInput]);
|
|
11302
11339
|
const title = spec?.info?.title || "";
|
|
11303
|
-
(0,
|
|
11340
|
+
(0, import_react16.useEffect)(() => {
|
|
11304
11341
|
if (stage !== "idle") return;
|
|
11305
11342
|
const q = input.trim();
|
|
11306
11343
|
if (!q || looksLikeUrl(q)) {
|
|
@@ -11331,7 +11368,7 @@ var AddAppDialog = ({
|
|
|
11331
11368
|
clearTimeout(t);
|
|
11332
11369
|
};
|
|
11333
11370
|
}, [input, stage, algoliaAppId, algoliaApiKey, algoliaIndexName]);
|
|
11334
|
-
const reset3 = (0,
|
|
11371
|
+
const reset3 = (0, import_react16.useCallback)(() => {
|
|
11335
11372
|
setInput("");
|
|
11336
11373
|
setStage("idle");
|
|
11337
11374
|
setSpec(null);
|
|
@@ -11339,14 +11376,14 @@ var AddAppDialog = ({
|
|
|
11339
11376
|
setCreatedAppId("");
|
|
11340
11377
|
setExisting(null);
|
|
11341
11378
|
}, []);
|
|
11342
|
-
(0,
|
|
11379
|
+
(0, import_react16.useEffect)(() => {
|
|
11343
11380
|
if (!open) {
|
|
11344
11381
|
const t = setTimeout(reset3, 250);
|
|
11345
11382
|
return () => clearTimeout(t);
|
|
11346
11383
|
}
|
|
11347
11384
|
return void 0;
|
|
11348
11385
|
}, [open, reset3]);
|
|
11349
|
-
const verifyAndCreate = (0,
|
|
11386
|
+
const verifyAndCreate = (0, import_react16.useCallback)(
|
|
11350
11387
|
async (openapiSpec) => {
|
|
11351
11388
|
setStage("verifying");
|
|
11352
11389
|
setErrorMsg("");
|
|
@@ -11383,7 +11420,7 @@ var AddAppDialog = ({
|
|
|
11383
11420
|
},
|
|
11384
11421
|
[verifyOpenapiPath, onCreated, onOpenChange]
|
|
11385
11422
|
);
|
|
11386
|
-
const runGeneration = (0,
|
|
11423
|
+
const runGeneration = (0, import_react16.useCallback)(
|
|
11387
11424
|
async (value) => {
|
|
11388
11425
|
setStage("generating");
|
|
11389
11426
|
setErrorMsg("");
|
|
@@ -11904,13 +11941,13 @@ function AppSearchDrawer({
|
|
|
11904
11941
|
}) {
|
|
11905
11942
|
const themeScope = useShuffleMcpTheme();
|
|
11906
11943
|
const scopeClassName = themeScope?.scopeClassName ?? (theme === "dark" ? "shuffle-mcp-scope dark" : theme === "light" ? "shuffle-mcp-scope" : void 0);
|
|
11907
|
-
const [detailAppName, setDetailAppName] = (0,
|
|
11908
|
-
const [detailAppId, setDetailAppId] = (0,
|
|
11909
|
-
const [addAppOpen, setAddAppOpen] = (0,
|
|
11910
|
-
const [addAppQuery, setAddAppQuery] = (0,
|
|
11911
|
-
const [highlightActive, setHighlightActive] = (0,
|
|
11912
|
-
const [bodyReady, setBodyReady] = (0,
|
|
11913
|
-
(0,
|
|
11944
|
+
const [detailAppName, setDetailAppName] = (0, import_react17.useState)(null);
|
|
11945
|
+
const [detailAppId, setDetailAppId] = (0, import_react17.useState)(null);
|
|
11946
|
+
const [addAppOpen, setAddAppOpen] = (0, import_react17.useState)(false);
|
|
11947
|
+
const [addAppQuery, setAddAppQuery] = (0, import_react17.useState)("");
|
|
11948
|
+
const [highlightActive, setHighlightActive] = (0, import_react17.useState)(false);
|
|
11949
|
+
const [bodyReady, setBodyReady] = (0, import_react17.useState)(false);
|
|
11950
|
+
(0, import_react17.useEffect)(() => {
|
|
11914
11951
|
if (!open) {
|
|
11915
11952
|
setBodyReady(false);
|
|
11916
11953
|
return;
|
|
@@ -11920,7 +11957,7 @@ function AppSearchDrawer({
|
|
|
11920
11957
|
});
|
|
11921
11958
|
return () => cancelAnimationFrame(raf);
|
|
11922
11959
|
}, [open]);
|
|
11923
|
-
(0,
|
|
11960
|
+
(0, import_react17.useEffect)(() => {
|
|
11924
11961
|
setHighlightActive(false);
|
|
11925
11962
|
if (!open || !highlightAppName) return;
|
|
11926
11963
|
const t = setTimeout(() => setHighlightActive(true), highlightDelayMs);
|
|
@@ -11929,6 +11966,7 @@ function AppSearchDrawer({
|
|
|
11929
11966
|
const drawerWidth = `min(${width}px, 100vw)`;
|
|
11930
11967
|
const drawerMinWidth = `min(${minWidth}px, 100vw)`;
|
|
11931
11968
|
const drawerMaxWidth = `min(${maxWidth}px, 100vw)`;
|
|
11969
|
+
const drawerZIndex = useDrawerLayer(open);
|
|
11932
11970
|
const handleClose = () => {
|
|
11933
11971
|
setDetailAppName(null);
|
|
11934
11972
|
setDetailAppId(null);
|
|
@@ -12034,7 +12072,7 @@ function AppSearchDrawer({
|
|
|
12034
12072
|
},
|
|
12035
12073
|
...{ PaperProps: drawerPaperProps },
|
|
12036
12074
|
sx: {
|
|
12037
|
-
zIndex:
|
|
12075
|
+
zIndex: drawerZIndex,
|
|
12038
12076
|
"& .MuiDrawer-paper": {
|
|
12039
12077
|
boxSizing: "border-box",
|
|
12040
12078
|
width: `${drawerWidth} !important`,
|
|
@@ -12763,7 +12801,7 @@ function ShufflePipelinesBanner() {
|
|
|
12763
12801
|
var ShufflePipelinesBanner_default = ShufflePipelinesBanner;
|
|
12764
12802
|
|
|
12765
12803
|
// components/AgentUI.tsx
|
|
12766
|
-
var
|
|
12804
|
+
var import_react24 = __toESM(require("react"));
|
|
12767
12805
|
var import_react_dom = require("react-dom");
|
|
12768
12806
|
|
|
12769
12807
|
// agentRunSync.ts
|
|
@@ -12818,7 +12856,7 @@ var subscribeLastOpenedAgentRun = (cb) => {
|
|
|
12818
12856
|
var import_lucide_react15 = require("lucide-react");
|
|
12819
12857
|
|
|
12820
12858
|
// ../Shuffle-Core/components/WorkflowRunExplorer.tsx
|
|
12821
|
-
var
|
|
12859
|
+
var import_react18 = __toESM(require("react"));
|
|
12822
12860
|
var import_material20 = require("@mui/material");
|
|
12823
12861
|
var import_icons_material = require("@mui/icons-material");
|
|
12824
12862
|
|
|
@@ -13320,7 +13358,7 @@ function safeHandler(label, fn) {
|
|
|
13320
13358
|
var safeHandler_default = safeHandler;
|
|
13321
13359
|
|
|
13322
13360
|
// components/AgentPresets.tsx
|
|
13323
|
-
var
|
|
13361
|
+
var import_react19 = require("react");
|
|
13324
13362
|
var import_material21 = require("@mui/material");
|
|
13325
13363
|
var import_lucide_react11 = require("lucide-react");
|
|
13326
13364
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
@@ -13436,15 +13474,15 @@ var filterAgentPresets = (list, support) => {
|
|
|
13436
13474
|
return list.map((p) => SUPPORT_ONLY_PRESET_IDS.includes(p.id) ? { ...p, enabled: false } : p);
|
|
13437
13475
|
};
|
|
13438
13476
|
var AgentPresets = ({ variant = "default", onSelectPreset, selectedPreset, onRemoveSelected, presets, chipRef, isSupport, sx, placement }) => {
|
|
13439
|
-
const [anchorEl, setAnchorEl] = (0,
|
|
13477
|
+
const [anchorEl, setAnchorEl] = (0, import_react19.useState)(null);
|
|
13440
13478
|
const open = Boolean(anchorEl);
|
|
13441
|
-
const [supportTick, setSupportTick] = (0,
|
|
13442
|
-
(0,
|
|
13479
|
+
const [supportTick, setSupportTick] = (0, import_react19.useState)(0);
|
|
13480
|
+
(0, import_react19.useEffect)(() => {
|
|
13443
13481
|
const bump = () => setSupportTick((t) => t + 1);
|
|
13444
13482
|
window.addEventListener("storage", bump);
|
|
13445
13483
|
return () => window.removeEventListener("storage", bump);
|
|
13446
13484
|
}, []);
|
|
13447
|
-
const list = (0,
|
|
13485
|
+
const list = (0, import_react19.useMemo)(
|
|
13448
13486
|
() => filterAgentPresets(presets && presets.length > 0 ? presets : AGENT_PRESETS, isSupport),
|
|
13449
13487
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
13450
13488
|
[presets, supportTick, open, isSupport]
|
|
@@ -13552,8 +13590,8 @@ var AgentPresets = ({ variant = "default", onSelectPreset, selectedPreset, onRem
|
|
|
13552
13590
|
]
|
|
13553
13591
|
}
|
|
13554
13592
|
);
|
|
13555
|
-
const [query, setQuery] = (0,
|
|
13556
|
-
const filtered = (0,
|
|
13593
|
+
const [query, setQuery] = (0, import_react19.useState)("");
|
|
13594
|
+
const filtered = (0, import_react19.useMemo)(() => {
|
|
13557
13595
|
const q = query.trim().toLowerCase();
|
|
13558
13596
|
if (!q) return list;
|
|
13559
13597
|
return list.filter(
|
|
@@ -13821,7 +13859,7 @@ var AgentPresets = ({ variant = "default", onSelectPreset, selectedPreset, onRem
|
|
|
13821
13859
|
var AgentPresets_default = AgentPresets;
|
|
13822
13860
|
|
|
13823
13861
|
// useAgentPromptPrefix.ts
|
|
13824
|
-
var
|
|
13862
|
+
var import_react20 = require("react");
|
|
13825
13863
|
var AGENT_PROMPT_PREFIX_CATEGORY = "agent-prompt-prefix";
|
|
13826
13864
|
var DEFAULT_AGENT_PROMPT_PREFIX = "";
|
|
13827
13865
|
var decodePrompt = (raw) => {
|
|
@@ -13853,11 +13891,11 @@ var decodePrompt = (raw) => {
|
|
|
13853
13891
|
var useAgentPromptPrefix = (options = {}) => {
|
|
13854
13892
|
const { userId, defaultPrompt = DEFAULT_AGENT_PROMPT_PREFIX, persist = true } = options;
|
|
13855
13893
|
const key = userId || "default";
|
|
13856
|
-
const [prompt, setPrompt] = (0,
|
|
13857
|
-
const [hasFetched, setHasFetched] = (0,
|
|
13858
|
-
const [isSaving, setIsSaving] = (0,
|
|
13859
|
-
const fetchedForKey = (0,
|
|
13860
|
-
(0,
|
|
13894
|
+
const [prompt, setPrompt] = (0, import_react20.useState)(defaultPrompt);
|
|
13895
|
+
const [hasFetched, setHasFetched] = (0, import_react20.useState)(false);
|
|
13896
|
+
const [isSaving, setIsSaving] = (0, import_react20.useState)(false);
|
|
13897
|
+
const fetchedForKey = (0, import_react20.useRef)(null);
|
|
13898
|
+
(0, import_react20.useEffect)(() => {
|
|
13861
13899
|
if (!persist) {
|
|
13862
13900
|
setHasFetched(true);
|
|
13863
13901
|
return;
|
|
@@ -13884,7 +13922,7 @@ var useAgentPromptPrefix = (options = {}) => {
|
|
|
13884
13922
|
cancelled = true;
|
|
13885
13923
|
};
|
|
13886
13924
|
}, [key, persist]);
|
|
13887
|
-
const savePrompt = (0,
|
|
13925
|
+
const savePrompt = (0, import_react20.useCallback)(async (next) => {
|
|
13888
13926
|
const prev = prompt;
|
|
13889
13927
|
setPrompt(next);
|
|
13890
13928
|
if (!persist) return true;
|
|
@@ -14473,7 +14511,7 @@ ${trimmedQuestion}`;
|
|
|
14473
14511
|
};
|
|
14474
14512
|
|
|
14475
14513
|
// ../Shuffle-Core/views/monitors/ActionOutputView.tsx
|
|
14476
|
-
var
|
|
14514
|
+
var import_react21 = require("react");
|
|
14477
14515
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
14478
14516
|
var IMAGE_SIGNATURES = [
|
|
14479
14517
|
{ prefix: "iVBORw0KGgo", mime: "image/png" },
|
|
@@ -14559,10 +14597,10 @@ var detectImage = (raw) => {
|
|
|
14559
14597
|
};
|
|
14560
14598
|
var MAX_TEXT_CHARS = 4e3;
|
|
14561
14599
|
var ActionOutputView = ({ output, className }) => {
|
|
14562
|
-
const detected = (0,
|
|
14563
|
-
const [zoomed, setZoomed] = (0,
|
|
14564
|
-
const [showFull, setShowFull] = (0,
|
|
14565
|
-
(0,
|
|
14600
|
+
const detected = (0, import_react21.useMemo)(() => detectImage(output), [output]);
|
|
14601
|
+
const [zoomed, setZoomed] = (0, import_react21.useState)(false);
|
|
14602
|
+
const [showFull, setShowFull] = (0, import_react21.useState)(false);
|
|
14603
|
+
(0, import_react21.useEffect)(() => {
|
|
14566
14604
|
if (!zoomed) return;
|
|
14567
14605
|
const onKey = (e) => {
|
|
14568
14606
|
if (e.key === "Escape") {
|
|
@@ -15573,17 +15611,25 @@ var extractDecisionIndex = (path) => {
|
|
|
15573
15611
|
};
|
|
15574
15612
|
var isAiAuthText = (text2) => {
|
|
15575
15613
|
if (!text2 || typeof text2 !== "string") return false;
|
|
15576
|
-
const
|
|
15577
|
-
|
|
15578
|
-
|
|
15579
|
-
|
|
15580
|
-
|
|
15581
|
-
|
|
15582
|
-
lower
|
|
15583
|
-
|
|
15584
|
-
|
|
15585
|
-
|
|
15586
|
-
|
|
15614
|
+
const trimmed = text2.trim();
|
|
15615
|
+
if (!trimmed) return false;
|
|
15616
|
+
const checkChunk = (chunk) => {
|
|
15617
|
+
const lower = chunk.toLowerCase();
|
|
15618
|
+
const hasAuthSignal = /\b(401|unauthori[sz]ed|invalid[_\s-]*(api[_\s-]*key|credentials?|token|auth|key)|incorrect\s+api\s+key|missing[_\s-]*(api[_\s-]*key|authorization|credentials?)|authentication[_\s-]*(failed|required|error)|ai\s+credentials)\b/.test(
|
|
15619
|
+
lower
|
|
15620
|
+
) || /check\s+your\s+ai\s+credentials/.test(lower);
|
|
15621
|
+
if (!hasAuthSignal) return false;
|
|
15622
|
+
const hasAiSignal = /\b(failed\s+to\s+start\s+ai\s+agent|failed\s+to\s+run\s+ai(\s+(agent|query))?|failed\s+to\s+run\s+ai|ai\s+agent\s+(failed|error|crash|aborted)|ai\s+query|ai\s+credentials|shuffler\.io\/agents|runactionai|llm\s+request|failed\s+to\s+run\s+llm|no\s+llm|openai|anthropic|mistral|groq|deepseek|together\.ai|together\.xyz|openrouter|gemini|generativelanguage\.googleapis\.com|aiplatform\.googleapis\.com|ollama|lm\s*studio|platform\.openai\.com|api\.openai\.com|local\s*llm)\b/.test(
|
|
15623
|
+
lower
|
|
15624
|
+
) || /error\s+from\s+['"][^'"]*(openai|anthropic|mistral|groq|deepseek|together|openrouter|generativelanguage|aiplatform|gemini|ollama|lmstudio)/.test(
|
|
15625
|
+
lower
|
|
15626
|
+
) || /incorrect\s+api\s+key\s+provided/.test(lower);
|
|
15627
|
+
return Boolean(hasAiSignal);
|
|
15628
|
+
};
|
|
15629
|
+
if (trimmed.includes("\n")) {
|
|
15630
|
+
return trimmed.split(/\r?\n/).some((line) => checkChunk(line));
|
|
15631
|
+
}
|
|
15632
|
+
return checkChunk(trimmed);
|
|
15587
15633
|
};
|
|
15588
15634
|
var hasOutputWarning = (run) => {
|
|
15589
15635
|
return diagnoseOutputWarning(run) !== null;
|
|
@@ -15617,8 +15663,15 @@ var trimEvidenceValue = (v, max = 180) => {
|
|
|
15617
15663
|
};
|
|
15618
15664
|
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/;
|
|
15619
15665
|
var isSentenceLike = (v) => /[a-z]/i.test(v) && v.trim().split(/\s+/).length > 1;
|
|
15666
|
+
var hasProducedDecisions = (run, parsed) => {
|
|
15667
|
+
const parsedDecisions = parsed && typeof parsed === "object" ? parsed.decisions : null;
|
|
15668
|
+
if (Array.isArray(parsedDecisions) && parsedDecisions.length > 0) return true;
|
|
15669
|
+
const directDecisions = run?.decisions;
|
|
15670
|
+
return Array.isArray(directDecisions) && directDecisions.length > 0;
|
|
15671
|
+
};
|
|
15620
15672
|
var diagnoseOutputWarning = (run) => {
|
|
15621
15673
|
const { parsed, raw } = parseRunResult(run);
|
|
15674
|
+
const producedDecisions = hasProducedDecisions(run, parsed);
|
|
15622
15675
|
const tokenLimitMatch = (() => {
|
|
15623
15676
|
const candidates = [];
|
|
15624
15677
|
if (parsed && typeof parsed === "object") {
|
|
@@ -15653,7 +15706,7 @@ var diagnoseOutputWarning = (run) => {
|
|
|
15653
15706
|
const category = String(last.category || "").toLowerCase();
|
|
15654
15707
|
if (["finish", "finalise"].includes(action) || ["finish", "finalise"].includes(category)) {
|
|
15655
15708
|
if (last.success === false || last.status === "FAILED") return false;
|
|
15656
|
-
if (isAiAuthText(last.reason)
|
|
15709
|
+
if (isAiAuthText(last.reason)) return false;
|
|
15657
15710
|
const reasonStr = String(last.reason || "").toLowerCase();
|
|
15658
15711
|
if (reasonStr.startsWith("failed to") || reasonStr.includes("error,")) return false;
|
|
15659
15712
|
return true;
|
|
@@ -15663,28 +15716,22 @@ var diagnoseOutputWarning = (run) => {
|
|
|
15663
15716
|
return false;
|
|
15664
15717
|
})();
|
|
15665
15718
|
const aiAuthMatch = (() => {
|
|
15719
|
+
if (producedDecisions) return null;
|
|
15720
|
+
if (isFinished && (!parsed?.error && parsed?.success !== false)) return null;
|
|
15666
15721
|
if (isFinished && hasSuccessfulFinish) return null;
|
|
15667
15722
|
const candidates = [];
|
|
15668
15723
|
if (parsed && typeof parsed === "object") {
|
|
15669
15724
|
if (typeof parsed.error === "string") candidates.push(parsed.error);
|
|
15670
|
-
if (typeof parsed.reason === "string") candidates.push(parsed.reason);
|
|
15671
|
-
if (typeof parsed.message === "string") candidates.push(parsed.message);
|
|
15672
|
-
if (
|
|
15673
|
-
if (Array.isArray(parsed.decisions)) {
|
|
15725
|
+
if (!isFinished && typeof parsed.reason === "string") candidates.push(parsed.reason);
|
|
15726
|
+
if (!isFinished && typeof parsed.message === "string") candidates.push(parsed.message);
|
|
15727
|
+
if (Array.isArray(parsed.decisions) && !isFinished) {
|
|
15674
15728
|
for (const d of parsed.decisions) {
|
|
15675
15729
|
if (typeof d?.run_details?.error === "string") candidates.push(d.run_details.error);
|
|
15676
|
-
if (typeof d?.reason === "string") candidates.push(d.reason);
|
|
15677
|
-
if (typeof d?.run_details?.result === "string") candidates.push(d.run_details.result);
|
|
15678
|
-
if (typeof d?.output === "string") candidates.push(d.output);
|
|
15679
|
-
if (Array.isArray(d?.fields)) {
|
|
15680
|
-
for (const f of d.fields) {
|
|
15681
|
-
if (typeof f?.value === "string") candidates.push(f.value);
|
|
15682
|
-
}
|
|
15683
|
-
}
|
|
15730
|
+
if (d?.status === "FAILED" && typeof d?.reason === "string") candidates.push(d.reason);
|
|
15684
15731
|
}
|
|
15685
15732
|
}
|
|
15686
15733
|
}
|
|
15687
|
-
if (raw) {
|
|
15734
|
+
if (raw && !isFinished) {
|
|
15688
15735
|
candidates.push(raw);
|
|
15689
15736
|
}
|
|
15690
15737
|
return candidates.find((v) => isAiAuthText(v)) || null;
|
|
@@ -15799,7 +15846,7 @@ var diagnoseOutputWarning = (run) => {
|
|
|
15799
15846
|
const dedup = ev.filter((e) => e.path !== statusEvidence.path);
|
|
15800
15847
|
return [statusEvidence, ...dedup].slice(0, 3);
|
|
15801
15848
|
};
|
|
15802
|
-
if (isAiAuthText(errorHaystackLower) || isAiAuthText(raw)) {
|
|
15849
|
+
if (!producedDecisions && !isFinished && (isAiAuthText(errorHaystackLower) || isAiAuthText(raw))) {
|
|
15803
15850
|
const ev = findEvidenceByRegex(
|
|
15804
15851
|
/unauthori[sz]ed|invalid[_\s-]*(api[_\s-]*key|token|credentials?)|authentication[_\s-]*(failed|required)|missing[_\s-]*(api[_\s-]*key|token|authorization)|bearer[_\s-]*token|expired[_\s-]*token|failed\s+to\s+start\s+ai\s+agent|incorrect\s+api\s+key\s+provided|\b401\b/
|
|
15805
15852
|
);
|
|
@@ -15938,39 +15985,35 @@ var diagnoseOutputWarning = (run) => {
|
|
|
15938
15985
|
return null;
|
|
15939
15986
|
};
|
|
15940
15987
|
var isAiAuthFailure = (run, extraText) => {
|
|
15988
|
+
if (!run) return isAiAuthText(extraText);
|
|
15989
|
+
const { parsed } = parseRunResult(run);
|
|
15990
|
+
if (hasProducedDecisions(run, parsed)) return false;
|
|
15941
15991
|
if (isAiAuthText(extraText)) return true;
|
|
15942
|
-
|
|
15992
|
+
const status = (run.status || "").toUpperCase();
|
|
15993
|
+
const isFinished = status === "FINISHED" || status === "SUCCESS";
|
|
15994
|
+
if (isFinished) {
|
|
15995
|
+
const anyRun2 = run;
|
|
15996
|
+
if (typeof anyRun2.error === "string" && isAiAuthText(anyRun2.error)) return true;
|
|
15997
|
+
return false;
|
|
15998
|
+
}
|
|
15943
15999
|
const diagnosis = diagnoseOutputWarning(run);
|
|
15944
16000
|
if (diagnosis?.kind === "ai_auth" || diagnosis?.isAiAuth) return true;
|
|
15945
16001
|
const fail = getFailureInfo(run);
|
|
15946
16002
|
if (fail && isAiAuthText(fail.reason)) return true;
|
|
15947
16003
|
const anyRun = run;
|
|
15948
|
-
if (typeof anyRun.result === "string" && isAiAuthText(anyRun.result)) return true;
|
|
15949
|
-
if (typeof anyRun.output === "string" && isAiAuthText(anyRun.output)) return true;
|
|
15950
16004
|
if (typeof anyRun.error === "string" && isAiAuthText(anyRun.error)) return true;
|
|
15951
16005
|
if (Array.isArray(run.results)) {
|
|
15952
16006
|
for (const r of run.results) {
|
|
15953
|
-
if (typeof r?.result === "string" && isAiAuthText(r.result)) return true;
|
|
15954
16007
|
if (typeof r?.error === "string" && isAiAuthText(r.error)) return true;
|
|
15955
16008
|
}
|
|
15956
16009
|
}
|
|
15957
16010
|
const decisions = anyRun?.decisions;
|
|
15958
16011
|
if (Array.isArray(decisions)) {
|
|
15959
16012
|
for (const d of decisions) {
|
|
15960
|
-
if (isAiAuthText(d?.reason)) return true;
|
|
15961
|
-
if (typeof d?.output === "string" && isAiAuthText(d.output)) return true;
|
|
15962
16013
|
if (typeof d?.run_details?.error === "string" && isAiAuthText(d.run_details.error)) return true;
|
|
15963
|
-
if (typeof d?.
|
|
15964
|
-
if (Array.isArray(d?.fields)) {
|
|
15965
|
-
for (const f of d.fields) {
|
|
15966
|
-
if (isAiAuthText(f?.value)) return true;
|
|
15967
|
-
}
|
|
15968
|
-
}
|
|
16014
|
+
if (d?.status === "FAILED" && typeof d?.reason === "string" && isAiAuthText(d.reason)) return true;
|
|
15969
16015
|
}
|
|
15970
16016
|
}
|
|
15971
|
-
const status = (run.status || "").toUpperCase();
|
|
15972
|
-
const isFinished = status === "FINISHED";
|
|
15973
|
-
if (isFinished) return false;
|
|
15974
16017
|
return false;
|
|
15975
16018
|
};
|
|
15976
16019
|
|
|
@@ -16064,7 +16107,7 @@ var AgentDiagnosisCtas = ({ diagnosis, compact = false, tone = "medium" }) => {
|
|
|
16064
16107
|
var AgentDiagnosisCtas_default = AgentDiagnosisCtas;
|
|
16065
16108
|
|
|
16066
16109
|
// components/AgentRunDiagnosisBanner.tsx
|
|
16067
|
-
var
|
|
16110
|
+
var import_react22 = require("react");
|
|
16068
16111
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
16069
16112
|
var DISMISS_PREFIX = "agent-diagnosis-dismissed::";
|
|
16070
16113
|
var readDismissed = (key) => {
|
|
@@ -16083,13 +16126,13 @@ var writeDismissed = (key) => {
|
|
|
16083
16126
|
}
|
|
16084
16127
|
};
|
|
16085
16128
|
var AgentRunDiagnosisBanner = ({ run, sx, onJumpToEvidence, onFocusContinue, executionId }) => {
|
|
16086
|
-
const dismissKey = (0,
|
|
16129
|
+
const dismissKey = (0, import_react22.useMemo)(() => {
|
|
16087
16130
|
if (executionId) return executionId;
|
|
16088
16131
|
const fromRun = run?.execution_id;
|
|
16089
16132
|
return typeof fromRun === "string" && fromRun ? fromRun : null;
|
|
16090
16133
|
}, [executionId, run]);
|
|
16091
|
-
const [dismissed, setDismissed] = (0,
|
|
16092
|
-
(0,
|
|
16134
|
+
const [dismissed, setDismissed] = (0, import_react22.useState)(() => readDismissed(dismissKey));
|
|
16135
|
+
(0, import_react22.useEffect)(() => {
|
|
16093
16136
|
setDismissed(readDismissed(dismissKey));
|
|
16094
16137
|
}, [dismissKey]);
|
|
16095
16138
|
if (!run || dismissed) return null;
|
|
@@ -16386,7 +16429,7 @@ var AiAuthSuggestion = ({
|
|
|
16386
16429
|
var AiAuthSuggestion_default = AiAuthSuggestion;
|
|
16387
16430
|
|
|
16388
16431
|
// components/AgentAttachmentsButton.tsx
|
|
16389
|
-
var
|
|
16432
|
+
var import_react23 = require("react");
|
|
16390
16433
|
var import_material25 = require("@mui/material");
|
|
16391
16434
|
var import_lucide_react14 = require("lucide-react");
|
|
16392
16435
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
@@ -16397,9 +16440,9 @@ var toSrc = (url) => {
|
|
|
16397
16440
|
return `data:image/png;base64,${s.replace(/\s+/g, "")}`;
|
|
16398
16441
|
};
|
|
16399
16442
|
var AgentAttachmentsButton = ({ attachments }) => {
|
|
16400
|
-
const [anchorEl, setAnchorEl] = (0,
|
|
16401
|
-
const [zoomed, setZoomed] = (0,
|
|
16402
|
-
(0,
|
|
16443
|
+
const [anchorEl, setAnchorEl] = (0, import_react23.useState)(null);
|
|
16444
|
+
const [zoomed, setZoomed] = (0, import_react23.useState)(null);
|
|
16445
|
+
(0, import_react23.useEffect)(() => {
|
|
16403
16446
|
if (!zoomed) return;
|
|
16404
16447
|
const onKey = (e) => {
|
|
16405
16448
|
if (e.key === "Escape") {
|
|
@@ -17094,6 +17137,7 @@ var DEFAULT_AGENT_CONTEXT_RULES = [
|
|
|
17094
17137
|
defaultApps: [{ name: "shuffle_incidents" }],
|
|
17095
17138
|
defaultPresetId: "incident-response",
|
|
17096
17139
|
sourceCategory: "incidents",
|
|
17140
|
+
isBeta: true,
|
|
17097
17141
|
title: (params, _, entityOverride) => {
|
|
17098
17142
|
const cleanId = formatEntityDisplayId(params.id);
|
|
17099
17143
|
const entity = entityOverride || getActivePageEntityName();
|
|
@@ -17115,6 +17159,7 @@ var DEFAULT_AGENT_CONTEXT_RULES = [
|
|
|
17115
17159
|
defaultApps: [{ name: "shuffle_incidents" }],
|
|
17116
17160
|
defaultPresetId: "incident-response",
|
|
17117
17161
|
sourceCategory: "incidents",
|
|
17162
|
+
isBeta: true,
|
|
17118
17163
|
title: (params, _, entityOverride) => {
|
|
17119
17164
|
const cleanId = formatEntityDisplayId(params.id);
|
|
17120
17165
|
const entity = entityOverride || getActivePageEntityName();
|
|
@@ -17136,6 +17181,7 @@ var DEFAULT_AGENT_CONTEXT_RULES = [
|
|
|
17136
17181
|
defaultApps: [{ name: "shuffle_incidents" }],
|
|
17137
17182
|
defaultPresetId: "incident-response",
|
|
17138
17183
|
sourceCategory: "incidents",
|
|
17184
|
+
isBeta: true,
|
|
17139
17185
|
title: (params, _, entityOverride) => {
|
|
17140
17186
|
const cleanId = formatEntityDisplayId(params.id);
|
|
17141
17187
|
const entity = entityOverride || getActivePageEntityName();
|
|
@@ -17157,6 +17203,7 @@ var DEFAULT_AGENT_CONTEXT_RULES = [
|
|
|
17157
17203
|
defaultApps: [{ name: "shuffle_incidents" }],
|
|
17158
17204
|
defaultPresetId: "incident-response",
|
|
17159
17205
|
sourceCategory: "incidents",
|
|
17206
|
+
isBeta: true,
|
|
17160
17207
|
title: "How can we help handle incidents?",
|
|
17161
17208
|
subtitle: "Shuffle Incidents MCP",
|
|
17162
17209
|
defaultPrompt: "Investigate this incident and recommend next steps: ",
|
|
@@ -17171,6 +17218,7 @@ var DEFAULT_AGENT_CONTEXT_RULES = [
|
|
|
17171
17218
|
defaultApps: [{ name: "shuffle_incidents" }],
|
|
17172
17219
|
defaultPresetId: "incident-response",
|
|
17173
17220
|
sourceCategory: "incidents",
|
|
17221
|
+
isBeta: true,
|
|
17174
17222
|
title: "How can we help handle cases?",
|
|
17175
17223
|
subtitle: "Shuffle Incidents MCP",
|
|
17176
17224
|
defaultPrompt: "Investigate this case and recommend next steps: ",
|
|
@@ -17185,6 +17233,7 @@ var DEFAULT_AGENT_CONTEXT_RULES = [
|
|
|
17185
17233
|
defaultApps: [{ name: "shuffle_incidents" }],
|
|
17186
17234
|
defaultPresetId: "incident-response",
|
|
17187
17235
|
sourceCategory: "incidents",
|
|
17236
|
+
isBeta: true,
|
|
17188
17237
|
title: "How can we help handle tickets?",
|
|
17189
17238
|
subtitle: "Shuffle Incidents MCP",
|
|
17190
17239
|
defaultPrompt: "Investigate this ticket and recommend next steps: ",
|
|
@@ -17199,6 +17248,7 @@ var DEFAULT_AGENT_CONTEXT_RULES = [
|
|
|
17199
17248
|
defaultApps: [{ name: "shuffle_incidents" }],
|
|
17200
17249
|
defaultPresetId: "incident-response",
|
|
17201
17250
|
sourceCategory: "incidents",
|
|
17251
|
+
isBeta: true,
|
|
17202
17252
|
title: "How can we help handle alerts?",
|
|
17203
17253
|
subtitle: "Shuffle Incidents MCP",
|
|
17204
17254
|
defaultPrompt: "Investigate this alert and recommend next steps: ",
|
|
@@ -17966,7 +18016,7 @@ var truncateReason = (reason, maxLength = 280) => {
|
|
|
17966
18016
|
return reason.slice(0, maxLength).replace(/\s+\S*$/, "") + "\u2026";
|
|
17967
18017
|
};
|
|
17968
18018
|
var FinishAnswerMarkdown = ({ text: text2 }) => {
|
|
17969
|
-
const wholeJson = (0,
|
|
18019
|
+
const wholeJson = (0, import_react24.useMemo)(() => tryParseJsonObject(stripSingleCodeFence(text2)), [text2]);
|
|
17970
18020
|
if (wholeJson !== null) {
|
|
17971
18021
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_material26.Box, { sx: { "& .json-view": { backgroundColor: "transparent !important", fontSize: "0.82rem" } }, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react18_json_view4.default, { src: wholeJson, collapsed: defaultCollapsed, enableClipboard: true, displaySize: true, theme: "default" }) });
|
|
17972
18022
|
}
|
|
@@ -18108,7 +18158,7 @@ var RunFinishedSummary = ({
|
|
|
18108
18158
|
children: finishNote
|
|
18109
18159
|
}
|
|
18110
18160
|
),
|
|
18111
|
-
bottomContent
|
|
18161
|
+
status !== "FINISHED" && status !== "SUCCESS" && bottomContent
|
|
18112
18162
|
] });
|
|
18113
18163
|
};
|
|
18114
18164
|
var VERIFIED_BUILTIN_APPS = /* @__PURE__ */ new Set([
|
|
@@ -18257,8 +18307,8 @@ var isBuiltinDefaultApps = (apps) => {
|
|
|
18257
18307
|
);
|
|
18258
18308
|
};
|
|
18259
18309
|
var DurationCountdown = ({ resumeAtMs }) => {
|
|
18260
|
-
const [nowMs, setNowMs] = (0,
|
|
18261
|
-
(0,
|
|
18310
|
+
const [nowMs, setNowMs] = (0, import_react24.useState)(() => Date.now());
|
|
18311
|
+
(0, import_react24.useEffect)(() => {
|
|
18262
18312
|
const t = setInterval(() => setNowMs(Date.now()), 1e3);
|
|
18263
18313
|
return () => clearInterval(t);
|
|
18264
18314
|
}, []);
|
|
@@ -18268,8 +18318,8 @@ var DurationCountdown = ({ resumeAtMs }) => {
|
|
|
18268
18318
|
var StatusIcon = ({ status, resumeAtMs }) => {
|
|
18269
18319
|
const s = (status || "").toUpperCase();
|
|
18270
18320
|
const isScheduledWait = s === "WAITING" && !!resumeAtMs;
|
|
18271
|
-
const [nowMs, setNowMs] = (0,
|
|
18272
|
-
(0,
|
|
18321
|
+
const [nowMs, setNowMs] = (0, import_react24.useState)(() => Date.now());
|
|
18322
|
+
(0, import_react24.useEffect)(() => {
|
|
18273
18323
|
if (!isScheduledWait) return;
|
|
18274
18324
|
const t = setInterval(() => setNowMs(Date.now()), 1e3);
|
|
18275
18325
|
return () => clearInterval(t);
|
|
@@ -18312,8 +18362,8 @@ var formatAgo = (sec) => {
|
|
|
18312
18362
|
return `${Math.floor(diff / 86400)}d ago`;
|
|
18313
18363
|
};
|
|
18314
18364
|
var ScheduledLiveBar = ({ startSec, originalStartTime, totalDuration, maxWidth }) => {
|
|
18315
|
-
const [nowSec, setNowSec] = (0,
|
|
18316
|
-
(0,
|
|
18365
|
+
const [nowSec, setNowSec] = (0, import_react24.useState)(() => Date.now() / 1e3);
|
|
18366
|
+
(0, import_react24.useEffect)(() => {
|
|
18317
18367
|
const t = setInterval(() => setNowSec(Date.now() / 1e3), 1e3);
|
|
18318
18368
|
return () => clearInterval(t);
|
|
18319
18369
|
}, []);
|
|
@@ -18360,9 +18410,9 @@ var TimelineRow = ({
|
|
|
18360
18410
|
dimmedByRerun = false,
|
|
18361
18411
|
optimisticContinueText
|
|
18362
18412
|
}) => {
|
|
18363
|
-
const [submitAttempted, setSubmitAttempted] = (0,
|
|
18413
|
+
const [submitAttempted, setSubmitAttempted] = (0, import_react24.useState)(false);
|
|
18364
18414
|
const validate = validateJson(item.details);
|
|
18365
|
-
const screenshotPayloads = (0,
|
|
18415
|
+
const screenshotPayloads = (0, import_react24.useMemo)(
|
|
18366
18416
|
() => extractScreenshotPayloads(validate.valid ? validate.result : item.details),
|
|
18367
18417
|
[validate.valid, validate.result, item.details]
|
|
18368
18418
|
);
|
|
@@ -19034,11 +19084,11 @@ var AgentUI = ({
|
|
|
19034
19084
|
workflowId: propWorkflowId
|
|
19035
19085
|
}) => {
|
|
19036
19086
|
const isEffectiveSupport = isSupport !== void 0 ? isSupport : isSupportUser();
|
|
19037
|
-
const resolveUrl2 = (0,
|
|
19087
|
+
const resolveUrl2 = (0, import_react24.useCallback)(
|
|
19038
19088
|
(path) => apiBaseUrl ? `${apiBaseUrl.replace(/\/+$/, "")}${path}` : getApiUrl(path),
|
|
19039
19089
|
[apiBaseUrl]
|
|
19040
19090
|
);
|
|
19041
|
-
const resolveHeaders2 = (0,
|
|
19091
|
+
const resolveHeaders2 = (0, import_react24.useCallback)(() => {
|
|
19042
19092
|
const h = apiKey ? { Authorization: `Bearer ${apiKey}` } : { ...getAuthHeader() };
|
|
19043
19093
|
if (orgId) h["Org-Id"] = orgId;
|
|
19044
19094
|
return h;
|
|
@@ -19046,7 +19096,7 @@ var AgentUI = ({
|
|
|
19046
19096
|
const hasApiKey = !!apiKey || !!API_CONFIG.apiKey;
|
|
19047
19097
|
const isPhoneScreen = (0, import_material26.useMediaQuery)("(max-width:600px)", { noSsr: true });
|
|
19048
19098
|
const isPhone = mobileView !== void 0 ? mobileView : isPhoneScreen;
|
|
19049
|
-
const [actionInput, setActionInput] = (0,
|
|
19099
|
+
const [actionInput, setActionInput] = (0, import_react24.useState)(() => {
|
|
19050
19100
|
if (contextStorageKey) {
|
|
19051
19101
|
const saved = getPageContextChoice(contextStorageKey);
|
|
19052
19102
|
if (saved?.draftPrompt !== void 0 && saved.draftPrompt !== "") {
|
|
@@ -19055,8 +19105,8 @@ var AgentUI = ({
|
|
|
19055
19105
|
}
|
|
19056
19106
|
return defaultInput || "";
|
|
19057
19107
|
});
|
|
19058
|
-
const lastStorageKeyRef = (0,
|
|
19059
|
-
(0,
|
|
19108
|
+
const lastStorageKeyRef = (0, import_react24.useRef)(contextStorageKey);
|
|
19109
|
+
(0, import_react24.useEffect)(() => {
|
|
19060
19110
|
if (lastStorageKeyRef.current !== contextStorageKey) {
|
|
19061
19111
|
lastStorageKeyRef.current = contextStorageKey;
|
|
19062
19112
|
if (contextStorageKey) {
|
|
@@ -19069,21 +19119,21 @@ var AgentUI = ({
|
|
|
19069
19119
|
}
|
|
19070
19120
|
}
|
|
19071
19121
|
}, [contextStorageKey, defaultInput]);
|
|
19072
|
-
const prevDefaultInputRef = (0,
|
|
19073
|
-
(0,
|
|
19122
|
+
const prevDefaultInputRef = (0, import_react24.useRef)(defaultInput);
|
|
19123
|
+
(0, import_react24.useEffect)(() => {
|
|
19074
19124
|
if (defaultInput && defaultInput !== prevDefaultInputRef.current) {
|
|
19075
19125
|
prevDefaultInputRef.current = defaultInput;
|
|
19076
19126
|
setActionInput(defaultInput);
|
|
19077
19127
|
}
|
|
19078
19128
|
}, [defaultInput]);
|
|
19079
19129
|
const { prompt: savedPromptPrefix } = useAgentPromptPrefix({ userId, persist: !disableStartTab });
|
|
19080
|
-
const [selectedPreset, setSelectedPreset] = (0,
|
|
19081
|
-
const presetsChipNodeRef = (0,
|
|
19082
|
-
const [presetsChipWidth, setPresetsChipWidth] = (0,
|
|
19083
|
-
const [inputScrolled, setInputScrolled] = (0,
|
|
19084
|
-
const [inputScrollTop, setInputScrollTop] = (0,
|
|
19085
|
-
const chipOverlayRef = (0,
|
|
19086
|
-
const applyChipScroll = (0,
|
|
19130
|
+
const [selectedPreset, setSelectedPreset] = (0, import_react24.useState)(null);
|
|
19131
|
+
const presetsChipNodeRef = (0, import_react24.useRef)(null);
|
|
19132
|
+
const [presetsChipWidth, setPresetsChipWidth] = (0, import_react24.useState)(0);
|
|
19133
|
+
const [inputScrolled, setInputScrolled] = (0, import_react24.useState)(false);
|
|
19134
|
+
const [inputScrollTop, setInputScrollTop] = (0, import_react24.useState)(0);
|
|
19135
|
+
const chipOverlayRef = (0, import_react24.useRef)(null);
|
|
19136
|
+
const applyChipScroll = (0, import_react24.useCallback)((st) => {
|
|
19087
19137
|
const el = chipOverlayRef.current;
|
|
19088
19138
|
if (!el) return;
|
|
19089
19139
|
if (el.dataset.static === "1") {
|
|
@@ -19096,19 +19146,19 @@ var AgentUI = ({
|
|
|
19096
19146
|
el.style.opacity = st > 24 ? "0" : "1";
|
|
19097
19147
|
el.style.pointerEvents = st > 4 ? "none" : "auto";
|
|
19098
19148
|
}, []);
|
|
19099
|
-
const [promptSingleLine, setPromptSingleLine] = (0,
|
|
19149
|
+
const [promptSingleLine, setPromptSingleLine] = (0, import_react24.useState)(true);
|
|
19100
19150
|
const promptMultilineBase = !promptSingleLine;
|
|
19101
|
-
const [attachmentsRowHeight, setAttachmentsRowHeight] = (0,
|
|
19102
|
-
const attachmentsRowRef = (0,
|
|
19151
|
+
const [attachmentsRowHeight, setAttachmentsRowHeight] = (0, import_react24.useState)(0);
|
|
19152
|
+
const attachmentsRowRef = (0, import_react24.useCallback)((node) => {
|
|
19103
19153
|
setAttachmentsRowHeight(node ? node.getBoundingClientRect().height : 0);
|
|
19104
19154
|
}, []);
|
|
19105
|
-
const presetsChipRef = (0,
|
|
19155
|
+
const presetsChipRef = (0, import_react24.useCallback)((node) => {
|
|
19106
19156
|
presetsChipNodeRef.current = node;
|
|
19107
19157
|
if (node) setPresetsChipWidth(node.getBoundingClientRect().width);
|
|
19108
19158
|
}, []);
|
|
19109
|
-
const inputRef = (0,
|
|
19110
|
-
const seededPresetIdRef = (0,
|
|
19111
|
-
(0,
|
|
19159
|
+
const inputRef = (0, import_react24.useRef)(null);
|
|
19160
|
+
const seededPresetIdRef = (0, import_react24.useRef)(null);
|
|
19161
|
+
(0, import_react24.useEffect)(() => {
|
|
19112
19162
|
if (!initialPresetId && defaultInput && defaultInput.trim().length > 0) {
|
|
19113
19163
|
setSelectedPreset(null);
|
|
19114
19164
|
return;
|
|
@@ -19135,7 +19185,7 @@ var AgentUI = ({
|
|
|
19135
19185
|
} catch {
|
|
19136
19186
|
}
|
|
19137
19187
|
}, [presets, defaultInput, isEffectiveSupport, initialPresetId, defaultApps, apps]);
|
|
19138
|
-
(0,
|
|
19188
|
+
(0, import_react24.useLayoutEffect)(() => {
|
|
19139
19189
|
if (hidePresets) {
|
|
19140
19190
|
setPresetsChipWidth(0);
|
|
19141
19191
|
return;
|
|
@@ -19163,14 +19213,14 @@ var AgentUI = ({
|
|
|
19163
19213
|
ro?.disconnect();
|
|
19164
19214
|
};
|
|
19165
19215
|
}, [selectedPreset, hidePresets, presets, actionInput]);
|
|
19166
|
-
(0,
|
|
19216
|
+
(0, import_react24.useEffect)(() => {
|
|
19167
19217
|
const el = inputRef.current;
|
|
19168
19218
|
if (!el) return;
|
|
19169
19219
|
if (el.scrollTop <= 1 && inputScrolled) setInputScrolled(false);
|
|
19170
19220
|
setInputScrollTop(el.scrollTop || 0);
|
|
19171
19221
|
applyChipScroll(el.scrollTop || 0);
|
|
19172
19222
|
}, [actionInput, inputScrolled, applyChipScroll]);
|
|
19173
|
-
(0,
|
|
19223
|
+
(0, import_react24.useLayoutEffect)(() => {
|
|
19174
19224
|
const el = inputRef.current;
|
|
19175
19225
|
if (!el) {
|
|
19176
19226
|
setPromptSingleLine(true);
|
|
@@ -19228,11 +19278,11 @@ var AgentUI = ({
|
|
|
19228
19278
|
};
|
|
19229
19279
|
}, [actionInput, presetsChipWidth, selectedPreset, hidePresets]);
|
|
19230
19280
|
const shouldTypewrite = placeholder === void 0;
|
|
19231
|
-
const [fullPlaceholder, setFullPlaceholder] = (0,
|
|
19281
|
+
const [fullPlaceholder, setFullPlaceholder] = (0, import_react24.useState)(
|
|
19232
19282
|
() => placeholder ?? getRandomAgentPromptPlaceholder()
|
|
19233
19283
|
);
|
|
19234
|
-
const pickedPlaceholderRef = (0,
|
|
19235
|
-
(0,
|
|
19284
|
+
const pickedPlaceholderRef = (0, import_react24.useRef)(null);
|
|
19285
|
+
(0, import_react24.useLayoutEffect)(() => {
|
|
19236
19286
|
if (!shouldTypewrite) return;
|
|
19237
19287
|
const el = inputRef.current;
|
|
19238
19288
|
if (!el) return;
|
|
@@ -19259,10 +19309,10 @@ var AgentUI = ({
|
|
|
19259
19309
|
pickedPlaceholderRef.current = picked;
|
|
19260
19310
|
setFullPlaceholder(picked);
|
|
19261
19311
|
}, [shouldTypewrite, presetsChipWidth, hidePresets]);
|
|
19262
|
-
const [typedPlaceholder, setTypedPlaceholder] = (0,
|
|
19312
|
+
const [typedPlaceholder, setTypedPlaceholder] = (0, import_react24.useState)(
|
|
19263
19313
|
shouldTypewrite ? "" : fullPlaceholder
|
|
19264
19314
|
);
|
|
19265
|
-
(0,
|
|
19315
|
+
(0, import_react24.useEffect)(() => {
|
|
19266
19316
|
if (!shouldTypewrite) {
|
|
19267
19317
|
setTypedPlaceholder(fullPlaceholder);
|
|
19268
19318
|
return;
|
|
@@ -19286,7 +19336,7 @@ var AgentUI = ({
|
|
|
19286
19336
|
return () => window.clearInterval(id);
|
|
19287
19337
|
}, [fullPlaceholder, shouldTypewrite]);
|
|
19288
19338
|
const activePromptPrefix = savedPromptPrefix;
|
|
19289
|
-
const composeSubmitInput = (0,
|
|
19339
|
+
const composeSubmitInput = (0, import_react24.useCallback)(
|
|
19290
19340
|
(raw) => {
|
|
19291
19341
|
if (typeof propComposeSubmitInput === "function") {
|
|
19292
19342
|
return propComposeSubmitInput(raw);
|
|
@@ -19295,15 +19345,15 @@ var AgentUI = ({
|
|
|
19295
19345
|
},
|
|
19296
19346
|
[propComposeSubmitInput]
|
|
19297
19347
|
);
|
|
19298
|
-
const promptAnchorRef =
|
|
19299
|
-
const [suggestionsDismissed, setSuggestionsDismissed] = (0,
|
|
19300
|
-
const [suggestionIndex, setSuggestionIndex] = (0,
|
|
19301
|
-
const promptSuggestions = (0,
|
|
19348
|
+
const promptAnchorRef = import_react24.default.useRef(null);
|
|
19349
|
+
const [suggestionsDismissed, setSuggestionsDismissed] = (0, import_react24.useState)(false);
|
|
19350
|
+
const [suggestionIndex, setSuggestionIndex] = (0, import_react24.useState)(-1);
|
|
19351
|
+
const promptSuggestions = (0, import_react24.useMemo)(
|
|
19302
19352
|
() => matchAgentPromptSuggestions(actionInput, 8),
|
|
19303
19353
|
[actionInput]
|
|
19304
19354
|
);
|
|
19305
|
-
const programmaticInputRef = (0,
|
|
19306
|
-
(0,
|
|
19355
|
+
const programmaticInputRef = (0, import_react24.useRef)(false);
|
|
19356
|
+
(0, import_react24.useEffect)(() => {
|
|
19307
19357
|
if (programmaticInputRef.current) {
|
|
19308
19358
|
programmaticInputRef.current = false;
|
|
19309
19359
|
return;
|
|
@@ -19312,8 +19362,8 @@ var AgentUI = ({
|
|
|
19312
19362
|
setSuggestionsDismissed(false);
|
|
19313
19363
|
}, [actionInput]);
|
|
19314
19364
|
const suggestionsOpen = promptSuggestions.length > 0 && !suggestionsDismissed;
|
|
19315
|
-
const [pendingCategories, setPendingCategories] = (0,
|
|
19316
|
-
const acceptSuggestion = (0,
|
|
19365
|
+
const [pendingCategories, setPendingCategories] = (0, import_react24.useState)([]);
|
|
19366
|
+
const acceptSuggestion = (0, import_react24.useCallback)((s) => {
|
|
19317
19367
|
programmaticInputRef.current = true;
|
|
19318
19368
|
setActionInput(s);
|
|
19319
19369
|
if (contextStorageKey) {
|
|
@@ -19345,32 +19395,32 @@ var AgentUI = ({
|
|
|
19345
19395
|
{ name: "http" },
|
|
19346
19396
|
{ name: "shuffle_tools" }
|
|
19347
19397
|
];
|
|
19348
|
-
const [chosenApps, setChosenApps] = (0,
|
|
19398
|
+
const [chosenApps, setChosenApps] = (0, import_react24.useState)(() => {
|
|
19349
19399
|
if (apps) return apps;
|
|
19350
19400
|
if (defaultApps !== void 0) return defaultApps.slice(0, MAX_AUTO_ASSIGNED_TOOLS);
|
|
19351
19401
|
const saved = readPresetAppsOverride(NO_PRESET_KEY);
|
|
19352
19402
|
if (saved) return saved;
|
|
19353
19403
|
return BUILTIN_DEFAULT_APPS;
|
|
19354
19404
|
});
|
|
19355
|
-
const isInitialMountChosenAppsRef = (0,
|
|
19356
|
-
const isInitialMountPresetOverrideRef = (0,
|
|
19357
|
-
const [availableApps, setAvailableApps] = (0,
|
|
19358
|
-
const [authAppsLoading, setAuthAppsLoading] = (0,
|
|
19359
|
-
const [detectedLLM, setDetectedLLM] = (0,
|
|
19360
|
-
const [configuredLLMOptions, setConfiguredLLMOptions] = (0,
|
|
19361
|
-
const [llmMenuAnchor, setLlmMenuAnchor] = (0,
|
|
19362
|
-
const [executionApps, setExecutionApps] = (0,
|
|
19363
|
-
const [resolvedToolApps, setResolvedToolApps] = (0,
|
|
19364
|
-
const [appSearchOpen, setAppSearchOpen] = (0,
|
|
19365
|
-
const [appSearchQuery, setAppSearchQuery] = (0,
|
|
19366
|
-
const [categoryTarget, setCategoryTarget] = (0,
|
|
19367
|
-
const [authDrawerApp, setAuthDrawerApp] = (0,
|
|
19368
|
-
const [agentRequestLoading, setAgentRequestLoading] = (0,
|
|
19369
|
-
const [rerunningDecisionId, setRerunningDecisionId] = (0,
|
|
19370
|
-
const rerunDecisionsSigRef = (0,
|
|
19371
|
-
const [rerunAgentPending, setRerunAgentPending] = (0,
|
|
19372
|
-
const [abortLoading, setAbortLoading] = (0,
|
|
19373
|
-
const [execution, setExecution] = (0,
|
|
19405
|
+
const isInitialMountChosenAppsRef = (0, import_react24.useRef)(true);
|
|
19406
|
+
const isInitialMountPresetOverrideRef = (0, import_react24.useRef)(true);
|
|
19407
|
+
const [availableApps, setAvailableApps] = (0, import_react24.useState)([]);
|
|
19408
|
+
const [authAppsLoading, setAuthAppsLoading] = (0, import_react24.useState)(autoLoadApps && hasApiKey);
|
|
19409
|
+
const [detectedLLM, setDetectedLLM] = (0, import_react24.useState)(null);
|
|
19410
|
+
const [configuredLLMOptions, setConfiguredLLMOptions] = (0, import_react24.useState)([]);
|
|
19411
|
+
const [llmMenuAnchor, setLlmMenuAnchor] = (0, import_react24.useState)(null);
|
|
19412
|
+
const [executionApps, setExecutionApps] = (0, import_react24.useState)([]);
|
|
19413
|
+
const [resolvedToolApps, setResolvedToolApps] = (0, import_react24.useState)({});
|
|
19414
|
+
const [appSearchOpen, setAppSearchOpen] = (0, import_react24.useState)(false);
|
|
19415
|
+
const [appSearchQuery, setAppSearchQuery] = (0, import_react24.useState)("");
|
|
19416
|
+
const [categoryTarget, setCategoryTarget] = (0, import_react24.useState)(null);
|
|
19417
|
+
const [authDrawerApp, setAuthDrawerApp] = (0, import_react24.useState)(null);
|
|
19418
|
+
const [agentRequestLoading, setAgentRequestLoading] = (0, import_react24.useState)(false);
|
|
19419
|
+
const [rerunningDecisionId, setRerunningDecisionId] = (0, import_react24.useState)(null);
|
|
19420
|
+
const rerunDecisionsSigRef = (0, import_react24.useRef)("");
|
|
19421
|
+
const [rerunAgentPending, setRerunAgentPending] = (0, import_react24.useState)(false);
|
|
19422
|
+
const [abortLoading, setAbortLoading] = (0, import_react24.useState)(false);
|
|
19423
|
+
const [execution, setExecution] = (0, import_react24.useState)(() => {
|
|
19374
19424
|
if (initialExecution) return initialExecution;
|
|
19375
19425
|
if (contextStorageKey) {
|
|
19376
19426
|
const saved = getPageContextChoice(contextStorageKey);
|
|
@@ -19384,13 +19434,13 @@ var AgentUI = ({
|
|
|
19384
19434
|
}
|
|
19385
19435
|
return null;
|
|
19386
19436
|
});
|
|
19387
|
-
const [agentData, setAgentData] = (0,
|
|
19388
|
-
const [agentActionResult, setAgentActionResult] = (0,
|
|
19389
|
-
const llmImageAttachments = (0,
|
|
19437
|
+
const [agentData, setAgentData] = (0, import_react24.useState)({});
|
|
19438
|
+
const [agentActionResult, setAgentActionResult] = (0, import_react24.useState)(null);
|
|
19439
|
+
const llmImageAttachments = (0, import_react24.useMemo)(
|
|
19390
19440
|
() => collectLlmImageAttachments(agentData),
|
|
19391
19441
|
[agentData]
|
|
19392
19442
|
);
|
|
19393
|
-
const [showStarter, setShowStarter] = (0,
|
|
19443
|
+
const [showStarter, setShowStarter] = (0, import_react24.useState)(() => {
|
|
19394
19444
|
if (initialExecution?.execution_id) return false;
|
|
19395
19445
|
if (contextStorageKey) {
|
|
19396
19446
|
const saved = getPageContextChoice(contextStorageKey);
|
|
@@ -19400,14 +19450,14 @@ var AgentUI = ({
|
|
|
19400
19450
|
}
|
|
19401
19451
|
return true;
|
|
19402
19452
|
});
|
|
19403
|
-
const handleRemovePreset = (0,
|
|
19453
|
+
const handleRemovePreset = (0, import_react24.useCallback)(() => {
|
|
19404
19454
|
try {
|
|
19405
19455
|
localStorage.removeItem(LAST_PRESET_STORAGE_KEY);
|
|
19406
19456
|
} catch {
|
|
19407
19457
|
}
|
|
19408
19458
|
setSelectedPreset(null);
|
|
19409
19459
|
}, []);
|
|
19410
|
-
const handleSelectPresetInternal = (0,
|
|
19460
|
+
const handleSelectPresetInternal = (0, import_react24.useCallback)((preset) => {
|
|
19411
19461
|
try {
|
|
19412
19462
|
localStorage.setItem(LAST_PRESET_STORAGE_KEY, preset.id);
|
|
19413
19463
|
} catch {
|
|
@@ -19434,40 +19484,40 @@ var AgentUI = ({
|
|
|
19434
19484
|
}
|
|
19435
19485
|
}, 0);
|
|
19436
19486
|
}, [onSelectPreset]);
|
|
19437
|
-
const [scheduleAnchor, setScheduleAnchor] = (0,
|
|
19438
|
-
const [mobilePlusAnchor, setMobilePlusAnchor] = (0,
|
|
19439
|
-
const [scheduleCron, setScheduleCron] = (0,
|
|
19440
|
-
const [scheduleSaving, setScheduleSaving] = (0,
|
|
19441
|
-
const [scheduleSteps, setScheduleSteps] = (0,
|
|
19487
|
+
const [scheduleAnchor, setScheduleAnchor] = (0, import_react24.useState)(null);
|
|
19488
|
+
const [mobilePlusAnchor, setMobilePlusAnchor] = (0, import_react24.useState)(null);
|
|
19489
|
+
const [scheduleCron, setScheduleCron] = (0, import_react24.useState)("0 * * * *");
|
|
19490
|
+
const [scheduleSaving, setScheduleSaving] = (0, import_react24.useState)(false);
|
|
19491
|
+
const [scheduleSteps, setScheduleSteps] = (0, import_react24.useState)([
|
|
19442
19492
|
{ id: "name", state: "pending" },
|
|
19443
19493
|
{ id: "workflow", state: "pending" },
|
|
19444
19494
|
{ id: "schedule", state: "pending" }
|
|
19445
19495
|
]);
|
|
19446
|
-
const [schedFreq, setSchedFreq] = (0,
|
|
19447
|
-
const [schedInterval, setSchedInterval] = (0,
|
|
19448
|
-
const [schedHour, setSchedHour] = (0,
|
|
19449
|
-
const [schedMinute, setSchedMinute] = (0,
|
|
19450
|
-
const [schedWeekdays, setSchedWeekdays] = (0,
|
|
19451
|
-
const [schedDayOfMonth, setSchedDayOfMonth] = (0,
|
|
19452
|
-
const [schedAdvancedOpen, setSchedAdvancedOpen] = (0,
|
|
19453
|
-
const cronManualOverrideRef = (0,
|
|
19454
|
-
const [openIndexes, setOpenIndexes] = (0,
|
|
19455
|
-
const [highlightedIndex, setHighlightedIndex] = (0,
|
|
19456
|
-
const [continueHighlighted, setContinueHighlighted] = (0,
|
|
19457
|
-
const [questionAnswers, setQuestionAnswers] = (0,
|
|
19458
|
-
const [simpleSubmitAttempted, setSimpleSubmitAttempted] = (0,
|
|
19459
|
-
const [finishAnswerRaw, setFinishAnswerRaw] = (0,
|
|
19460
|
-
const [continuationText, setContinuationText] = (0,
|
|
19461
|
-
const [runComplete, setRunComplete] = (0,
|
|
19462
|
-
const [optimisticContinue, setOptimisticContinue] = (0,
|
|
19463
|
-
const continuationInputRef = (0,
|
|
19464
|
-
const continuationFocusedForRef = (0,
|
|
19465
|
-
const [error, setError] = (0,
|
|
19466
|
-
const [pollWarning, setPollWarning] = (0,
|
|
19467
|
-
const hasExecutionDataRef = (0,
|
|
19468
|
-
const loadedExecutionIdRef = (0,
|
|
19469
|
-
const keepPollingUntilRef = (0,
|
|
19470
|
-
const [runExplorerAvailable, setRunExplorerAvailable] = (0,
|
|
19496
|
+
const [schedFreq, setSchedFreq] = (0, import_react24.useState)("hours");
|
|
19497
|
+
const [schedInterval, setSchedInterval] = (0, import_react24.useState)(1);
|
|
19498
|
+
const [schedHour, setSchedHour] = (0, import_react24.useState)(9);
|
|
19499
|
+
const [schedMinute, setSchedMinute] = (0, import_react24.useState)(0);
|
|
19500
|
+
const [schedWeekdays, setSchedWeekdays] = (0, import_react24.useState)(() => /* @__PURE__ */ new Set([1]));
|
|
19501
|
+
const [schedDayOfMonth, setSchedDayOfMonth] = (0, import_react24.useState)(1);
|
|
19502
|
+
const [schedAdvancedOpen, setSchedAdvancedOpen] = (0, import_react24.useState)(false);
|
|
19503
|
+
const cronManualOverrideRef = (0, import_react24.useRef)(false);
|
|
19504
|
+
const [openIndexes, setOpenIndexes] = (0, import_react24.useState)(/* @__PURE__ */ new Set());
|
|
19505
|
+
const [highlightedIndex, setHighlightedIndex] = (0, import_react24.useState)(null);
|
|
19506
|
+
const [continueHighlighted, setContinueHighlighted] = (0, import_react24.useState)(false);
|
|
19507
|
+
const [questionAnswers, setQuestionAnswers] = (0, import_react24.useState)({});
|
|
19508
|
+
const [simpleSubmitAttempted, setSimpleSubmitAttempted] = (0, import_react24.useState)(false);
|
|
19509
|
+
const [finishAnswerRaw, setFinishAnswerRaw] = (0, import_react24.useState)(false);
|
|
19510
|
+
const [continuationText, setContinuationText] = (0, import_react24.useState)("");
|
|
19511
|
+
const [runComplete, setRunComplete] = (0, import_react24.useState)(false);
|
|
19512
|
+
const [optimisticContinue, setOptimisticContinue] = (0, import_react24.useState)(null);
|
|
19513
|
+
const continuationInputRef = (0, import_react24.useRef)(null);
|
|
19514
|
+
const continuationFocusedForRef = (0, import_react24.useRef)(null);
|
|
19515
|
+
const [error, setError] = (0, import_react24.useState)(null);
|
|
19516
|
+
const [pollWarning, setPollWarning] = (0, import_react24.useState)(null);
|
|
19517
|
+
const hasExecutionDataRef = (0, import_react24.useRef)(false);
|
|
19518
|
+
const loadedExecutionIdRef = (0, import_react24.useRef)(null);
|
|
19519
|
+
const keepPollingUntilRef = (0, import_react24.useRef)(0);
|
|
19520
|
+
const [runExplorerAvailable, setRunExplorerAvailable] = (0, import_react24.useState)("checking");
|
|
19471
19521
|
const [searchParams, setSearchParams] = (0, import_router_compat3.useSearchParams)();
|
|
19472
19522
|
const initialViewParam = searchParams.get("agentView");
|
|
19473
19523
|
const readStoredViewMode = () => {
|
|
@@ -19486,8 +19536,8 @@ var AgentUI = ({
|
|
|
19486
19536
|
}
|
|
19487
19537
|
return "simple";
|
|
19488
19538
|
};
|
|
19489
|
-
const [viewMode, setViewMode] = (0,
|
|
19490
|
-
(0,
|
|
19539
|
+
const [viewMode, setViewMode] = (0, import_react24.useState)(readStoredViewMode);
|
|
19540
|
+
(0, import_react24.useEffect)(() => {
|
|
19491
19541
|
try {
|
|
19492
19542
|
if (typeof window !== "undefined") {
|
|
19493
19543
|
window.localStorage.setItem("shuffle-agents-view-mode", viewMode);
|
|
@@ -19495,17 +19545,17 @@ var AgentUI = ({
|
|
|
19495
19545
|
} catch {
|
|
19496
19546
|
}
|
|
19497
19547
|
}, [viewMode]);
|
|
19498
|
-
const [attachedImages, setAttachedImages] = (0,
|
|
19499
|
-
const [previewImage, setPreviewImage] = (0,
|
|
19548
|
+
const [attachedImages, setAttachedImages] = (0, import_react24.useState)([]);
|
|
19549
|
+
const [previewImage, setPreviewImage] = (0, import_react24.useState)(null);
|
|
19500
19550
|
const promptMultiline = promptMultilineBase || attachedImages.length > 0 || isPhone && Boolean(selectedPreset);
|
|
19501
19551
|
const promptSingleLineLocked = !promptMultiline;
|
|
19502
|
-
const [nowTick, setNowTick] = (0,
|
|
19503
|
-
const [localRunStart, setLocalRunStart] = (0,
|
|
19504
|
-
const chipBarRef = (0,
|
|
19505
|
-
const chipBarResizeObserverRef = (0,
|
|
19506
|
-
const [chipBarMultiline, setChipBarMultiline] = (0,
|
|
19507
|
-
const fileInputRef = (0,
|
|
19508
|
-
const chipBarCallbackRef = (0,
|
|
19552
|
+
const [nowTick, setNowTick] = (0, import_react24.useState)(() => Math.floor(Date.now() / 1e3));
|
|
19553
|
+
const [localRunStart, setLocalRunStart] = (0, import_react24.useState)(null);
|
|
19554
|
+
const chipBarRef = (0, import_react24.useRef)(null);
|
|
19555
|
+
const chipBarResizeObserverRef = (0, import_react24.useRef)(null);
|
|
19556
|
+
const [chipBarMultiline, setChipBarMultiline] = (0, import_react24.useState)(false);
|
|
19557
|
+
const fileInputRef = (0, import_react24.useRef)(null);
|
|
19558
|
+
const chipBarCallbackRef = (0, import_react24.useCallback)((node) => {
|
|
19509
19559
|
chipBarRef.current = node;
|
|
19510
19560
|
chipBarResizeObserverRef.current?.disconnect();
|
|
19511
19561
|
if (!node) return;
|
|
@@ -19522,14 +19572,14 @@ var AgentUI = ({
|
|
|
19522
19572
|
chipBarResizeObserverRef.current = ro;
|
|
19523
19573
|
}
|
|
19524
19574
|
}, []);
|
|
19525
|
-
const activeExecutionIdRef = (0,
|
|
19526
|
-
initialExecution?.execution_id || (contextStorageKey ? getPageContextChoice(contextStorageKey)?.executionId || null : null)
|
|
19575
|
+
const activeExecutionIdRef = (0, import_react24.useRef)(
|
|
19576
|
+
executionId || initialExecution?.execution_id || (contextStorageKey ? getPageContextChoice(contextStorageKey)?.executionId || null : null)
|
|
19527
19577
|
);
|
|
19528
|
-
const executionPollGenerationRef = (0,
|
|
19529
|
-
const runAbortRef = (0,
|
|
19530
|
-
const runGenerationRef = (0,
|
|
19531
|
-
const userPickedStartRef = (0,
|
|
19532
|
-
const stateRef = (0,
|
|
19578
|
+
const executionPollGenerationRef = (0, import_react24.useRef)(0);
|
|
19579
|
+
const runAbortRef = (0, import_react24.useRef)(null);
|
|
19580
|
+
const runGenerationRef = (0, import_react24.useRef)(0);
|
|
19581
|
+
const userPickedStartRef = (0, import_react24.useRef)(false);
|
|
19582
|
+
const stateRef = (0, import_react24.useRef)({
|
|
19533
19583
|
execution: null,
|
|
19534
19584
|
agentData: {},
|
|
19535
19585
|
agentActionResult: null,
|
|
@@ -19547,25 +19597,25 @@ var AgentUI = ({
|
|
|
19547
19597
|
stateRef.current.continuationText = continuationText;
|
|
19548
19598
|
stateRef.current.localRunStart = localRunStart;
|
|
19549
19599
|
stateRef.current.showStarter = showStarter;
|
|
19550
|
-
(0,
|
|
19600
|
+
(0, import_react24.useEffect)(() => {
|
|
19551
19601
|
const el = chipBarRef.current;
|
|
19552
19602
|
if (el) {
|
|
19553
19603
|
setChipBarMultiline(el.clientHeight > 42 || el.scrollHeight > 42);
|
|
19554
19604
|
}
|
|
19555
19605
|
}, [chosenApps, availableApps, selectedPreset]);
|
|
19556
|
-
(0,
|
|
19606
|
+
(0, import_react24.useEffect)(() => {
|
|
19557
19607
|
return () => {
|
|
19558
19608
|
chipBarResizeObserverRef.current?.disconnect();
|
|
19559
19609
|
};
|
|
19560
19610
|
}, []);
|
|
19561
|
-
(0,
|
|
19611
|
+
(0, import_react24.useEffect)(() => {
|
|
19562
19612
|
if (execution?.execution_id || agentRequestLoading) {
|
|
19563
19613
|
setLocalRunStart((prev) => prev ?? Math.floor(Date.now() / 1e3));
|
|
19564
19614
|
} else {
|
|
19565
19615
|
setLocalRunStart(null);
|
|
19566
19616
|
}
|
|
19567
19617
|
}, [execution?.execution_id, agentRequestLoading]);
|
|
19568
|
-
(0,
|
|
19618
|
+
(0, import_react24.useEffect)(() => {
|
|
19569
19619
|
if (!execution?.execution_id && !agentRequestLoading) return;
|
|
19570
19620
|
const status = (execution?.status || agentData?.status || "").toUpperCase();
|
|
19571
19621
|
const TERMINAL = ["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"];
|
|
@@ -19607,7 +19657,7 @@ var AgentUI = ({
|
|
|
19607
19657
|
setError(null);
|
|
19608
19658
|
}
|
|
19609
19659
|
};
|
|
19610
|
-
const appsById = (0,
|
|
19660
|
+
const appsById = (0, import_react24.useMemo)(() => {
|
|
19611
19661
|
const m = {};
|
|
19612
19662
|
const add = (a) => {
|
|
19613
19663
|
if (!a?.name) return;
|
|
@@ -19625,7 +19675,7 @@ var AgentUI = ({
|
|
|
19625
19675
|
}
|
|
19626
19676
|
return m;
|
|
19627
19677
|
}, [chosenApps, executionApps, resolvedToolApps]);
|
|
19628
|
-
const isAppAuthenticated = (0,
|
|
19678
|
+
const isAppAuthenticated = (0, import_react24.useCallback)((appName, appId) => {
|
|
19629
19679
|
if (!appName && !appId) return false;
|
|
19630
19680
|
const target = normalizeAgentAppName(appName);
|
|
19631
19681
|
if (isNoAuthApp(target)) return true;
|
|
@@ -19634,7 +19684,7 @@ var AgentUI = ({
|
|
|
19634
19684
|
return !!appName && normalizeAgentAppName(a.name || "") === target;
|
|
19635
19685
|
});
|
|
19636
19686
|
}, [availableApps]);
|
|
19637
|
-
const pendingAuthApps = (0,
|
|
19687
|
+
const pendingAuthApps = (0, import_react24.useMemo)(() => {
|
|
19638
19688
|
if (authAppsLoading) return [];
|
|
19639
19689
|
const decisions = agentData?.decisions || [];
|
|
19640
19690
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -19652,10 +19702,10 @@ var AgentUI = ({
|
|
|
19652
19702
|
}
|
|
19653
19703
|
return out;
|
|
19654
19704
|
}, [agentData, appsById, authAppsLoading, isAppAuthenticated]);
|
|
19655
|
-
(0,
|
|
19705
|
+
(0, import_react24.useEffect)(() => {
|
|
19656
19706
|
if (apps) setChosenApps(apps);
|
|
19657
19707
|
}, [apps]);
|
|
19658
|
-
(0,
|
|
19708
|
+
(0, import_react24.useEffect)(() => {
|
|
19659
19709
|
const required = selectedPreset?.requiredApps;
|
|
19660
19710
|
if (!required || required.length === 0) return;
|
|
19661
19711
|
setChosenApps((prev) => {
|
|
@@ -19664,7 +19714,7 @@ var AgentUI = ({
|
|
|
19664
19714
|
return [...prev, ...missing.map((name) => ({ name }))];
|
|
19665
19715
|
});
|
|
19666
19716
|
}, [selectedPreset]);
|
|
19667
|
-
(0,
|
|
19717
|
+
(0, import_react24.useEffect)(() => {
|
|
19668
19718
|
const decisions = agentData?.decisions || [];
|
|
19669
19719
|
if (!Array.isArray(decisions) || decisions.length === 0) return;
|
|
19670
19720
|
const norm4 = (s) => s.toLowerCase().replace(/[\s-]+/g, "_");
|
|
@@ -19712,7 +19762,7 @@ var AgentUI = ({
|
|
|
19712
19762
|
cancelled = true;
|
|
19713
19763
|
};
|
|
19714
19764
|
}, [JSON.stringify(agentData?.decisions?.map((d) => [d?.details?.tool || d?.tool, extractAuthRequest(d)?.appName]) || []), appsById]);
|
|
19715
|
-
(0,
|
|
19765
|
+
(0, import_react24.useEffect)(() => {
|
|
19716
19766
|
const missing = chosenApps.filter((a) => !a.icon && a.name);
|
|
19717
19767
|
if (missing.length === 0) return;
|
|
19718
19768
|
let cancelled = false;
|
|
@@ -19770,7 +19820,7 @@ var AgentUI = ({
|
|
|
19770
19820
|
cancelled = true;
|
|
19771
19821
|
};
|
|
19772
19822
|
}, [chosenApps, availableApps, resolveUrl2, resolveHeaders2]);
|
|
19773
|
-
const loadAuthenticatedApps = (0,
|
|
19823
|
+
const loadAuthenticatedApps = (0, import_react24.useCallback)(async (signal) => {
|
|
19774
19824
|
setAuthAppsLoading(true);
|
|
19775
19825
|
try {
|
|
19776
19826
|
const [authRes, wfRes] = await Promise.allSettled([
|
|
@@ -19871,7 +19921,7 @@ var AgentUI = ({
|
|
|
19871
19921
|
if (!signal?.cancelled) setAuthAppsLoading(false);
|
|
19872
19922
|
}
|
|
19873
19923
|
}, [resolveUrl2, resolveHeaders2, contextCategory, contextStorageKey, defaultApps, onAppsChange]);
|
|
19874
|
-
(0,
|
|
19924
|
+
(0, import_react24.useEffect)(() => {
|
|
19875
19925
|
if (!autoLoadApps) return;
|
|
19876
19926
|
if (!hasApiKey) return;
|
|
19877
19927
|
const signal = { cancelled: false };
|
|
@@ -19880,7 +19930,7 @@ var AgentUI = ({
|
|
|
19880
19930
|
signal.cancelled = true;
|
|
19881
19931
|
};
|
|
19882
19932
|
}, [autoLoadApps, hasApiKey, loadAuthenticatedApps]);
|
|
19883
|
-
(0,
|
|
19933
|
+
(0, import_react24.useEffect)(() => {
|
|
19884
19934
|
if (!hasApiKey) return;
|
|
19885
19935
|
const handler = (event) => {
|
|
19886
19936
|
const customEvent = event;
|
|
@@ -19895,7 +19945,7 @@ var AgentUI = ({
|
|
|
19895
19945
|
window.addEventListener("integrations-changed", handler);
|
|
19896
19946
|
return () => window.removeEventListener("integrations-changed", handler);
|
|
19897
19947
|
}, [hasApiKey, loadAuthenticatedApps]);
|
|
19898
|
-
(0,
|
|
19948
|
+
(0, import_react24.useEffect)(() => {
|
|
19899
19949
|
const raw = agentData?.allowed_actions;
|
|
19900
19950
|
if (!Array.isArray(raw) || raw.length === 0) {
|
|
19901
19951
|
setExecutionApps([]);
|
|
@@ -20008,7 +20058,7 @@ var AgentUI = ({
|
|
|
20008
20058
|
cancelled = true;
|
|
20009
20059
|
};
|
|
20010
20060
|
}, [JSON.stringify(agentData?.allowed_actions || []), availableApps]);
|
|
20011
|
-
const getExecution = (0,
|
|
20061
|
+
const getExecution = (0, import_react24.useCallback)(async (executionId2, authorization2) => {
|
|
20012
20062
|
const pollGeneration = executionPollGenerationRef.current;
|
|
20013
20063
|
if (loadedExecutionIdRef.current !== executionId2) hasExecutionDataRef.current = false;
|
|
20014
20064
|
if (!executionId2 || executionId2.startsWith("demo-") || executionId2.startsWith("dummy-")) return;
|
|
@@ -20085,7 +20135,7 @@ var AgentUI = ({
|
|
|
20085
20135
|
else setPollWarning(`Live updates are failing (${err instanceof Error ? err.message : "network error"}). Showing the last known state.`);
|
|
20086
20136
|
}
|
|
20087
20137
|
}, []);
|
|
20088
|
-
(0,
|
|
20138
|
+
(0, import_react24.useEffect)(() => {
|
|
20089
20139
|
const eid = execution?.execution_id;
|
|
20090
20140
|
const auth = execution?.authorization;
|
|
20091
20141
|
if (!eid) {
|
|
@@ -20112,19 +20162,19 @@ var AgentUI = ({
|
|
|
20112
20162
|
cancelled = true;
|
|
20113
20163
|
};
|
|
20114
20164
|
}, [execution?.execution_id, execution?.authorization]);
|
|
20115
|
-
(0,
|
|
20165
|
+
(0, import_react24.useEffect)(() => {
|
|
20116
20166
|
if (execution?.authorization && (execution?.results?.length || 0) > 0) {
|
|
20117
20167
|
setRunExplorerAvailable("yes");
|
|
20118
20168
|
}
|
|
20119
20169
|
}, [execution?.authorization, execution?.results?.length]);
|
|
20120
|
-
(0,
|
|
20170
|
+
(0, import_react24.useEffect)(() => {
|
|
20121
20171
|
let eid = null;
|
|
20122
20172
|
let auth = null;
|
|
20123
20173
|
let initialStatus = "EXECUTING";
|
|
20124
20174
|
let savedViewMode = null;
|
|
20125
|
-
if (executionId
|
|
20175
|
+
if (executionId) {
|
|
20126
20176
|
eid = executionId;
|
|
20127
|
-
auth = authorization;
|
|
20177
|
+
auth = authorization || null;
|
|
20128
20178
|
} else if (readUrlParams) {
|
|
20129
20179
|
const params = new URLSearchParams(window.location.search);
|
|
20130
20180
|
eid = params.get("execution_id");
|
|
@@ -20153,7 +20203,7 @@ var AgentUI = ({
|
|
|
20153
20203
|
getExecution(eid, auth || void 0);
|
|
20154
20204
|
}
|
|
20155
20205
|
}, [readUrlParams, executionId, authorization, getExecution, contextStorageKey]);
|
|
20156
|
-
(0,
|
|
20206
|
+
(0, import_react24.useEffect)(() => {
|
|
20157
20207
|
if (!initialExecution || !initialExecution.execution_id) return;
|
|
20158
20208
|
if (!userPickedStartRef.current) setShowStarter(false);
|
|
20159
20209
|
activeExecutionIdRef.current = initialExecution.execution_id;
|
|
@@ -20188,7 +20238,7 @@ var AgentUI = ({
|
|
|
20188
20238
|
getExecution(initialExecution.execution_id, initialExecution.authorization);
|
|
20189
20239
|
}
|
|
20190
20240
|
}, [initialExecution?.execution_id]);
|
|
20191
|
-
(0,
|
|
20241
|
+
(0, import_react24.useEffect)(() => {
|
|
20192
20242
|
if (!execution?.execution_id) return;
|
|
20193
20243
|
const status = (execution.status || "").toUpperCase();
|
|
20194
20244
|
const TERMINAL = ["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"];
|
|
@@ -20205,7 +20255,7 @@ var AgentUI = ({
|
|
|
20205
20255
|
}, intervalMs);
|
|
20206
20256
|
return () => clearInterval(id);
|
|
20207
20257
|
}, [execution?.execution_id, execution?.authorization, execution?.status, agentData?.decisions, runComplete, getExecution]);
|
|
20208
|
-
const submitInput = (0,
|
|
20258
|
+
const submitInput = (0, import_react24.useCallback)(async (text2, presetOverride, appsOverride) => {
|
|
20209
20259
|
if (!text2.trim()) return;
|
|
20210
20260
|
if (isLoggedIn === false) {
|
|
20211
20261
|
setError("Authentication required. Please log in to run AI agents.");
|
|
@@ -20392,14 +20442,14 @@ var AgentUI = ({
|
|
|
20392
20442
|
onRun?.({ input: text2, success: true, executionId: eid });
|
|
20393
20443
|
}
|
|
20394
20444
|
}, [chosenApps, executionApps, getExecution, onRun, attachedImages, readUrlParams, setSearchParams, viewMode, selectedPreset, isLoggedIn]);
|
|
20395
|
-
const
|
|
20396
|
-
(0,
|
|
20397
|
-
if (autoSubmit && defaultInput &&
|
|
20398
|
-
|
|
20445
|
+
const lastSubmittedInputRef = (0, import_react24.useRef)(null);
|
|
20446
|
+
(0, import_react24.useEffect)(() => {
|
|
20447
|
+
if (autoSubmit && defaultInput && defaultInput !== lastSubmittedInputRef.current) {
|
|
20448
|
+
lastSubmittedInputRef.current = defaultInput;
|
|
20399
20449
|
submitInput(defaultInput);
|
|
20400
20450
|
}
|
|
20401
|
-
}, [autoSubmit, defaultInput,
|
|
20402
|
-
const submitQuestions = (0,
|
|
20451
|
+
}, [autoSubmit, defaultInput, submitInput]);
|
|
20452
|
+
const submitQuestions = (0, import_react24.useCallback)(async (decisionId, answers, isContinuation) => {
|
|
20403
20453
|
if (!execution?.execution_id || !execution?.authorization) return;
|
|
20404
20454
|
let newArgument = {};
|
|
20405
20455
|
if (isContinuation) {
|
|
@@ -20457,7 +20507,7 @@ var AgentUI = ({
|
|
|
20457
20507
|
setAgentRequestLoading(false);
|
|
20458
20508
|
}
|
|
20459
20509
|
}, [execution, getExecution, agentData?.decisions]);
|
|
20460
|
-
const resolveRunInput = (0,
|
|
20510
|
+
const resolveRunInput = (0, import_react24.useCallback)(() => {
|
|
20461
20511
|
const fromData = agentData?.original_input;
|
|
20462
20512
|
if (fromData && typeof fromData === "string") return fromData;
|
|
20463
20513
|
if (actionInput && typeof actionInput === "string" && actionInput.trim()) return actionInput;
|
|
@@ -20525,7 +20575,7 @@ var AgentUI = ({
|
|
|
20525
20575
|
};
|
|
20526
20576
|
return deepFind(agentData) || deepFind(agentActionResult) || deepFind(execution) || "";
|
|
20527
20577
|
}, [agentData, actionInput, agentActionResult, execution]);
|
|
20528
|
-
const resolveRunTemplate = (0,
|
|
20578
|
+
const resolveRunTemplate = (0, import_react24.useCallback)(() => {
|
|
20529
20579
|
const candidates = [
|
|
20530
20580
|
agentData?.template,
|
|
20531
20581
|
agentData?.input?.template,
|
|
@@ -20546,7 +20596,7 @@ var AgentUI = ({
|
|
|
20546
20596
|
(p) => p.id === slug || PRESET_TEMPLATE_SLUGS[p.id] === slug || TEMPLATE_SLUG_TO_PRESET_ID[slug] === p.id
|
|
20547
20597
|
) ?? null;
|
|
20548
20598
|
}, [agentData, agentActionResult, execution, presets]);
|
|
20549
|
-
const rerunAgent = (0,
|
|
20599
|
+
const rerunAgent = (0, import_react24.useCallback)(() => {
|
|
20550
20600
|
const resolved = resolveRunInput();
|
|
20551
20601
|
const input = (typeof resolved === "string" && resolved.trim() ? resolved : actionInput) || "";
|
|
20552
20602
|
const template = resolveRunTemplate();
|
|
@@ -20574,12 +20624,12 @@ var AgentUI = ({
|
|
|
20574
20624
|
}
|
|
20575
20625
|
setTimeout(() => setRerunAgentPending(false), 8e3);
|
|
20576
20626
|
}, [resolveRunInput, resolveRunTemplate, actionInput, executionApps, disableStartTab, submitInput]);
|
|
20577
|
-
(0,
|
|
20627
|
+
(0, import_react24.useEffect)(() => {
|
|
20578
20628
|
if (rerunAgentPending && (agentRequestLoading || execution?.execution_id)) {
|
|
20579
20629
|
setRerunAgentPending(false);
|
|
20580
20630
|
}
|
|
20581
20631
|
}, [rerunAgentPending, agentRequestLoading, execution?.execution_id]);
|
|
20582
|
-
const abortAgent = (0,
|
|
20632
|
+
const abortAgent = (0, import_react24.useCallback)(async () => {
|
|
20583
20633
|
(0, import_react_dom.flushSync)(() => setAbortLoading(true));
|
|
20584
20634
|
const execId = execution?.execution_id;
|
|
20585
20635
|
const auth = execution?.authorization;
|
|
@@ -20645,10 +20695,10 @@ var AgentUI = ({
|
|
|
20645
20695
|
setAbortLoading(false);
|
|
20646
20696
|
}
|
|
20647
20697
|
}, [execution, resolveUrl2, resolveHeaders2, getExecution, setSearchParams]);
|
|
20648
|
-
(0,
|
|
20698
|
+
(0, import_react24.useEffect)(() => {
|
|
20649
20699
|
if (execution?.execution_id) setLastOpenedAgentRun(execution.execution_id);
|
|
20650
20700
|
}, [execution?.execution_id]);
|
|
20651
|
-
const getFormUrl = (0,
|
|
20701
|
+
const getFormUrl = (0, import_react24.useCallback)((decisionId) => {
|
|
20652
20702
|
const wfId = execution?.workflow?.id;
|
|
20653
20703
|
const auth = execution?.authorization;
|
|
20654
20704
|
const execId = execution?.execution_id;
|
|
@@ -20664,7 +20714,7 @@ var AgentUI = ({
|
|
|
20664
20714
|
});
|
|
20665
20715
|
return `/forms/${wfId}?${params.toString()}`;
|
|
20666
20716
|
}, [execution, agentActionResult, apiBaseUrl]);
|
|
20667
|
-
const rerunDecision = (0,
|
|
20717
|
+
const rerunDecision = (0, import_react24.useCallback)(async (decision) => {
|
|
20668
20718
|
if (!execution?.execution_id) {
|
|
20669
20719
|
toast({ title: "No execution loaded", description: "Cannot rerun this decision.", variant: "destructive" });
|
|
20670
20720
|
return;
|
|
@@ -20710,7 +20760,7 @@ var AgentUI = ({
|
|
|
20710
20760
|
setAgentRequestLoading(false);
|
|
20711
20761
|
}
|
|
20712
20762
|
}, [execution, agentActionResult, agentData, getExecution, resolveUrl2, resolveHeaders2]);
|
|
20713
|
-
(0,
|
|
20763
|
+
(0, import_react24.useEffect)(() => {
|
|
20714
20764
|
if (!rerunningDecisionId) return;
|
|
20715
20765
|
const sig = JSON.stringify(
|
|
20716
20766
|
(agentData?.decisions || []).map((d) => d?.run_details?.id || "")
|
|
@@ -20725,14 +20775,14 @@ var AgentUI = ({
|
|
|
20725
20775
|
const runStillExecuting = Boolean(execution?.execution_id || agentRequestLoading) && !TERMINAL_RUN_STATUSES.includes(
|
|
20726
20776
|
resolveRunStatus(execution?.status, agentData?.status)
|
|
20727
20777
|
);
|
|
20728
|
-
const [liveNowSec, setLiveNowSec] = (0,
|
|
20729
|
-
(0,
|
|
20778
|
+
const [liveNowSec, setLiveNowSec] = (0, import_react24.useState)(() => Date.now() / 1e3);
|
|
20779
|
+
(0, import_react24.useEffect)(() => {
|
|
20730
20780
|
if (!runStillExecuting) return;
|
|
20731
20781
|
setLiveNowSec(Date.now() / 1e3);
|
|
20732
20782
|
const t = setInterval(() => setLiveNowSec(Date.now() / 1e3), 1e3);
|
|
20733
20783
|
return () => clearInterval(t);
|
|
20734
20784
|
}, [runStillExecuting]);
|
|
20735
|
-
const { timeline, originalStartTime, totalDuration, finishDecisionId, finishAnswer, finishNote } = (0,
|
|
20785
|
+
const { timeline, originalStartTime, totalDuration, finishDecisionId, finishAnswer, finishNote } = (0, import_react24.useMemo)(() => {
|
|
20736
20786
|
const toSec = (t) => {
|
|
20737
20787
|
const n = Number(t) || 0;
|
|
20738
20788
|
return n > 1e12 ? n / 1e3 : n;
|
|
@@ -20918,7 +20968,7 @@ var AgentUI = ({
|
|
|
20918
20968
|
const total = Math.max(1, end - startSafe);
|
|
20919
20969
|
return { timeline: items, originalStartTime: startSafe, totalDuration: total, finishDecisionId: finishId, finishAnswer: finishAns, finishNote: finishNote2 };
|
|
20920
20970
|
}, [agentData, execution?.status, execution?.started_at, execution?.completed_at, runStillExecuting, liveNowSec]);
|
|
20921
|
-
(0,
|
|
20971
|
+
(0, import_react24.useEffect)(() => {
|
|
20922
20972
|
const status = (execution?.status || "").toUpperCase();
|
|
20923
20973
|
const isTerminal = ["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(status);
|
|
20924
20974
|
const hasPendingDecision = (agentData?.decisions || []).some((d) => {
|
|
@@ -20927,7 +20977,25 @@ var AgentUI = ({
|
|
|
20927
20977
|
});
|
|
20928
20978
|
setRunComplete(Boolean(isTerminal && !hasPendingDecision && (finishAnswer || finishDecisionId)));
|
|
20929
20979
|
}, [execution?.status, agentData?.decisions, finishAnswer, finishDecisionId]);
|
|
20930
|
-
(0,
|
|
20980
|
+
(0, import_react24.useEffect)(() => {
|
|
20981
|
+
const eid = execution?.execution_id || activeExecutionIdRef.current;
|
|
20982
|
+
const status = (execution?.status || agentData?.status || "").toUpperCase();
|
|
20983
|
+
if (!eid || !status || typeof window === "undefined") return;
|
|
20984
|
+
if (status === "FINISHED" || status === "SUCCESS") {
|
|
20985
|
+
window.dispatchEvent(
|
|
20986
|
+
new CustomEvent("shuffle:agent_execution_status", {
|
|
20987
|
+
detail: { executionId: eid, status: "completed" }
|
|
20988
|
+
})
|
|
20989
|
+
);
|
|
20990
|
+
} else if (["FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(status)) {
|
|
20991
|
+
window.dispatchEvent(
|
|
20992
|
+
new CustomEvent("shuffle:agent_execution_status", {
|
|
20993
|
+
detail: { executionId: eid, status: "failed" }
|
|
20994
|
+
})
|
|
20995
|
+
);
|
|
20996
|
+
}
|
|
20997
|
+
}, [execution?.execution_id, execution?.status, agentData?.status]);
|
|
20998
|
+
(0, import_react24.useEffect)(() => {
|
|
20931
20999
|
if (!finishDecisionId || agentRequestLoading) return;
|
|
20932
21000
|
if (continuationFocusedForRef.current === finishDecisionId) return;
|
|
20933
21001
|
continuationFocusedForRef.current = finishDecisionId;
|
|
@@ -20937,7 +21005,7 @@ var AgentUI = ({
|
|
|
20937
21005
|
}, 150);
|
|
20938
21006
|
return () => clearTimeout(t);
|
|
20939
21007
|
}, [finishDecisionId, agentRequestLoading]);
|
|
20940
|
-
const openLocalLlmArea = (0,
|
|
21008
|
+
const openLocalLlmArea = (0, import_react24.useCallback)(() => {
|
|
20941
21009
|
if (onChooseLLM) {
|
|
20942
21010
|
onChooseLLM();
|
|
20943
21011
|
return;
|
|
@@ -20954,16 +21022,20 @@ var AgentUI = ({
|
|
|
20954
21022
|
);
|
|
20955
21023
|
}
|
|
20956
21024
|
}, [onChooseLLM]);
|
|
20957
|
-
const isAiAuthIssue = (0,
|
|
21025
|
+
const isAiAuthIssue = (0, import_react24.useMemo)(() => {
|
|
21026
|
+
const status = (execution?.status || agentData?.status || "").toUpperCase();
|
|
21027
|
+
const isFinished = status === "FINISHED" || status === "SUCCESS";
|
|
21028
|
+
if (isFinished && !isAiAuthText(error)) {
|
|
21029
|
+
return false;
|
|
21030
|
+
}
|
|
20958
21031
|
if (finishAnswer && finishAnswer.trim().length > 0 && !isAiAuthText(finishAnswer)) {
|
|
20959
|
-
|
|
20960
|
-
if (!isAiAuthFailure(diagnosable2, error || "")) return false;
|
|
21032
|
+
return false;
|
|
20961
21033
|
}
|
|
20962
21034
|
const diagnosable = execution?.results?.length ? execution : agentData;
|
|
20963
|
-
return isAiAuthFailure(diagnosable, error ||
|
|
21035
|
+
return isAiAuthFailure(diagnosable, error || "");
|
|
20964
21036
|
}, [execution, agentData, finishAnswer, error]);
|
|
20965
21037
|
const aiAuthSuggestionNode = isAiAuthIssue ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_material26.Box, { sx: { mt: 1.5 }, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(AiAuthSuggestion_default, { onOpenLocalLlm: openLocalLlmArea }) }) : null;
|
|
20966
|
-
(0,
|
|
21038
|
+
(0, import_react24.useEffect)(() => {
|
|
20967
21039
|
if (!optimisticContinue) return;
|
|
20968
21040
|
const count = (agentData?.decisions || []).length;
|
|
20969
21041
|
if (count > optimisticContinue.decisions) {
|
|
@@ -20975,7 +21047,7 @@ var AgentUI = ({
|
|
|
20975
21047
|
}, [optimisticContinue, agentData?.decisions]);
|
|
20976
21048
|
const optimisticRunning = Boolean(optimisticContinue);
|
|
20977
21049
|
const optimisticContinueText = optimisticContinue?.text || void 0;
|
|
20978
|
-
const stuckDecision = (0,
|
|
21050
|
+
const stuckDecision = (0, import_react24.useMemo)(() => {
|
|
20979
21051
|
const list = (agentData?.decisions || []).filter((d) => {
|
|
20980
21052
|
if (!d?.run_details?.id) return false;
|
|
20981
21053
|
const s = String(d?.run_details?.status || "").toUpperCase();
|
|
@@ -21012,9 +21084,9 @@ var AgentUI = ({
|
|
|
21012
21084
|
requestAnimationFrame(() => requestAnimationFrame(scrollRowIntoView));
|
|
21013
21085
|
window.setTimeout(scrollRowIntoView, 260);
|
|
21014
21086
|
};
|
|
21015
|
-
const timelineEndRef = (0,
|
|
21016
|
-
const followTimelineRef = (0,
|
|
21017
|
-
(0,
|
|
21087
|
+
const timelineEndRef = (0, import_react24.useRef)(null);
|
|
21088
|
+
const followTimelineRef = (0, import_react24.useRef)(true);
|
|
21089
|
+
(0, import_react24.useEffect)(() => {
|
|
21018
21090
|
if (typeof window === "undefined") return;
|
|
21019
21091
|
const getScrollParent = (node) => {
|
|
21020
21092
|
let el = node?.parentElement || null;
|
|
@@ -21054,7 +21126,7 @@ var AgentUI = ({
|
|
|
21054
21126
|
const runIsLive = optimisticRunning || !["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(
|
|
21055
21127
|
(resolveRunStatus(execution?.status, agentData?.status) || "EXECUTING").toUpperCase()
|
|
21056
21128
|
);
|
|
21057
|
-
(0,
|
|
21129
|
+
(0, import_react24.useEffect)(() => {
|
|
21058
21130
|
if (typeof window === "undefined") return;
|
|
21059
21131
|
if (viewMode !== "detailed") return;
|
|
21060
21132
|
if (!runIsLive) return;
|
|
@@ -21072,10 +21144,10 @@ var AgentUI = ({
|
|
|
21072
21144
|
window.clearTimeout(t);
|
|
21073
21145
|
};
|
|
21074
21146
|
}, [timelineCount, viewMode, runIsLive]);
|
|
21075
|
-
(0,
|
|
21147
|
+
(0, import_react24.useEffect)(() => {
|
|
21076
21148
|
followTimelineRef.current = true;
|
|
21077
21149
|
}, [execution?.execution_id]);
|
|
21078
|
-
const handlePrimarySubmit = (0,
|
|
21150
|
+
const handlePrimarySubmit = (0, import_react24.useCallback)(() => {
|
|
21079
21151
|
const composed = composeSubmitInput(actionInput);
|
|
21080
21152
|
if (submitOverride) {
|
|
21081
21153
|
submitOverride({ input: composed, apps: chosenApps });
|
|
@@ -21120,17 +21192,17 @@ var AgentUI = ({
|
|
|
21120
21192
|
const activeTab = showStarter ? "start" : viewMode;
|
|
21121
21193
|
const hasExecution = !!execution?.execution_id;
|
|
21122
21194
|
const showRunSwitcher = hasExecution || agentRequestLoading;
|
|
21123
|
-
(0,
|
|
21195
|
+
(0, import_react24.useEffect)(() => {
|
|
21124
21196
|
onViewChange?.(activeTab);
|
|
21125
21197
|
}, [activeTab, onViewChange]);
|
|
21126
|
-
(0,
|
|
21198
|
+
(0, import_react24.useEffect)(() => {
|
|
21127
21199
|
if (isInitialMountChosenAppsRef.current) {
|
|
21128
21200
|
isInitialMountChosenAppsRef.current = false;
|
|
21129
21201
|
return;
|
|
21130
21202
|
}
|
|
21131
21203
|
onAppsChange?.(chosenApps);
|
|
21132
21204
|
}, [chosenApps, onAppsChange]);
|
|
21133
|
-
(0,
|
|
21205
|
+
(0, import_react24.useEffect)(() => {
|
|
21134
21206
|
if (isInitialMountPresetOverrideRef.current) {
|
|
21135
21207
|
isInitialMountPresetOverrideRef.current = false;
|
|
21136
21208
|
return;
|
|
@@ -21189,7 +21261,7 @@ var AgentUI = ({
|
|
|
21189
21261
|
}
|
|
21190
21262
|
}
|
|
21191
21263
|
};
|
|
21192
|
-
const { scheduleDisabledReasons, scheduleWarnings } = (0,
|
|
21264
|
+
const { scheduleDisabledReasons, scheduleWarnings } = (0, import_react24.useMemo)(() => {
|
|
21193
21265
|
const decisions = agentData?.decisions || [];
|
|
21194
21266
|
const runStatus = resolveRunStatus(execution?.status, agentData?.status);
|
|
21195
21267
|
const isNotFinished = runStatus !== "" && !["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(runStatus);
|
|
@@ -21258,24 +21330,24 @@ var AgentUI = ({
|
|
|
21258
21330
|
}
|
|
21259
21331
|
return { scheduleDisabledReasons: reasons, scheduleWarnings: warnings };
|
|
21260
21332
|
}, [agentData, execution?.status]);
|
|
21261
|
-
const scheduleHint = (0,
|
|
21333
|
+
const scheduleHint = (0, import_react24.useMemo)(() => {
|
|
21262
21334
|
const parsed = parseScheduleHint(actionInput);
|
|
21263
21335
|
return parsed && parsed.once ? null : parsed;
|
|
21264
21336
|
}, [actionInput]);
|
|
21265
|
-
const lastAppliedHintRef = (0,
|
|
21266
|
-
(0,
|
|
21337
|
+
const lastAppliedHintRef = (0, import_react24.useRef)(null);
|
|
21338
|
+
(0, import_react24.useEffect)(() => {
|
|
21267
21339
|
if (!scheduleHint) return;
|
|
21268
21340
|
if (scheduleAnchor) return;
|
|
21269
21341
|
if (lastAppliedHintRef.current === scheduleHint.cron) return;
|
|
21270
21342
|
setScheduleCron(scheduleHint.cron);
|
|
21271
21343
|
lastAppliedHintRef.current = scheduleHint.cron;
|
|
21272
21344
|
}, [scheduleHint, scheduleAnchor]);
|
|
21273
|
-
const finishedRunInput = (0,
|
|
21274
|
-
const postRunScheduleHint = (0,
|
|
21345
|
+
const finishedRunInput = (0, import_react24.useMemo)(() => extractCleanDisplayPrompt(resolveRunInput()), [resolveRunInput]);
|
|
21346
|
+
const postRunScheduleHint = (0, import_react24.useMemo)(() => {
|
|
21275
21347
|
const parsed = parseScheduleHint(finishedRunInput);
|
|
21276
21348
|
return parsed && parsed.once ? null : parsed;
|
|
21277
21349
|
}, [finishedRunInput]);
|
|
21278
|
-
const postRunAppReqs = (0,
|
|
21350
|
+
const postRunAppReqs = (0, import_react24.useMemo)(() => {
|
|
21279
21351
|
const text2 = (finishedRunInput || "").trim();
|
|
21280
21352
|
if (text2.length < 4) return [];
|
|
21281
21353
|
const reqs = getSuggestionAppRequirements(text2, 4);
|
|
@@ -21286,14 +21358,14 @@ var AgentUI = ({
|
|
|
21286
21358
|
return !chosen.some((c) => c && (c === target || c.includes(target) || target.includes(c)));
|
|
21287
21359
|
});
|
|
21288
21360
|
}, [finishedRunInput, chosenApps]);
|
|
21289
|
-
const postRunUnauthedApps = (0,
|
|
21361
|
+
const postRunUnauthedApps = (0, import_react24.useMemo)(() => {
|
|
21290
21362
|
if (authAppsLoading) return [];
|
|
21291
21363
|
return chosenApps.filter((a) => {
|
|
21292
21364
|
const slug = normalizeAgentAppName(a.name || "");
|
|
21293
21365
|
return appRequiresAuthentication(slug) && !isAppAuthenticated(a.name || "", a.id || null);
|
|
21294
21366
|
});
|
|
21295
21367
|
}, [authAppsLoading, chosenApps, isAppAuthenticated]);
|
|
21296
|
-
(0,
|
|
21368
|
+
(0, import_react24.useEffect)(() => {
|
|
21297
21369
|
if (cronManualOverrideRef.current) return;
|
|
21298
21370
|
const m = Math.max(0, Math.min(59, schedMinute));
|
|
21299
21371
|
const h = Math.max(0, Math.min(23, schedHour));
|
|
@@ -21335,7 +21407,7 @@ var AgentUI = ({
|
|
|
21335
21407
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_material26.Box, { component: "span", children: r })
|
|
21336
21408
|
] }, i)) })
|
|
21337
21409
|
] }) : "";
|
|
21338
|
-
const tabBarRef = (0,
|
|
21410
|
+
const tabBarRef = (0, import_react24.useRef)(null);
|
|
21339
21411
|
const runStatusUpper = resolveRunStatus(execution?.status, agentData?.status);
|
|
21340
21412
|
const runIsActive = hasExecution && !["FINISHED", "FAILURE", "ABORTED", "CANCELLED", "CANCELED"].includes(runStatusUpper);
|
|
21341
21413
|
const tabBar = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
@@ -24050,12 +24122,12 @@ var AgentUI = ({
|
|
|
24050
24122
|
var AgentUI_default = AgentUI;
|
|
24051
24123
|
|
|
24052
24124
|
// components/AgentRunDrawer.tsx
|
|
24053
|
-
var
|
|
24125
|
+
var import_react27 = require("react");
|
|
24054
24126
|
var import_material29 = require("@mui/material");
|
|
24055
24127
|
var import_lucide_react17 = require("lucide-react");
|
|
24056
24128
|
|
|
24057
24129
|
// components/LocalLLMConfig.tsx
|
|
24058
|
-
var
|
|
24130
|
+
var import_react25 = require("react");
|
|
24059
24131
|
var import_lucide_react16 = require("lucide-react");
|
|
24060
24132
|
var import_material28 = require("@mui/material");
|
|
24061
24133
|
init_api();
|
|
@@ -24148,7 +24220,7 @@ var UsageBar = ({
|
|
|
24148
24220
|
|
|
24149
24221
|
// components/LocalLLMConfig.tsx
|
|
24150
24222
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
24151
|
-
var
|
|
24223
|
+
var import_react26 = require("react");
|
|
24152
24224
|
var OPENAI_APP_NAME = "OpenAI";
|
|
24153
24225
|
var OPENAI_APP_ID = "5d19dd82517870c68d40cacad9b5ca91";
|
|
24154
24226
|
var OPENAI_ALGOLIA_APP = {
|
|
@@ -24218,7 +24290,7 @@ var PROVIDER_MODELS = {
|
|
|
24218
24290
|
"LM Studio (localhost)": ["qwen-3.6-27b", "llama-4-16x17b-instruct", "deepseek-v4-flash", "qwen3-32b", "llama-3.3-70b-instruct", "deepseek-r1-distill-qwen-32b", "mistral-small-4", "phi-4", "gemma-3-27b"]
|
|
24219
24291
|
};
|
|
24220
24292
|
var ProviderLogo = ({ label, url }) => {
|
|
24221
|
-
const [errored, setErrored] = (0,
|
|
24293
|
+
const [errored, setErrored] = (0, import_react25.useState)(false);
|
|
24222
24294
|
let domain = PROVIDER_DOMAINS[label];
|
|
24223
24295
|
if (!domain && url) {
|
|
24224
24296
|
try {
|
|
@@ -24234,8 +24306,8 @@ var LLM_PRESET_STORAGE_KEY = "shuffle-llm-provider";
|
|
|
24234
24306
|
var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serverside, theme, colorMode, open }) => {
|
|
24235
24307
|
useSyncHostBaseUrl(globalUrl);
|
|
24236
24308
|
const { authStates, authenticatedApps, handleAuthChange, handleSaveAuth, refreshAuth, loading: authLoading } = useAppAuth();
|
|
24237
|
-
const [expanded, setExpanded] = (0,
|
|
24238
|
-
const [selectedPreset, setSelectedPreset] = (0,
|
|
24309
|
+
const [expanded, setExpanded] = (0, import_react25.useState)(true);
|
|
24310
|
+
const [selectedPreset, setSelectedPreset] = (0, import_react25.useState)(() => {
|
|
24239
24311
|
try {
|
|
24240
24312
|
const stored = localStorage.getItem(LLM_PRESET_STORAGE_KEY) || "";
|
|
24241
24313
|
return ENDPOINT_PRESETS.some((p) => p.label === stored) ? stored : "";
|
|
@@ -24243,9 +24315,9 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
|
|
|
24243
24315
|
return "";
|
|
24244
24316
|
}
|
|
24245
24317
|
});
|
|
24246
|
-
const [customUrl, setCustomUrl] = (0,
|
|
24247
|
-
const activeSwitchSeqRef = (0,
|
|
24248
|
-
const [llmTest, setLlmTest] = (0,
|
|
24318
|
+
const [customUrl, setCustomUrl] = (0, import_react25.useState)("");
|
|
24319
|
+
const activeSwitchSeqRef = (0, import_react25.useRef)(0);
|
|
24320
|
+
const [llmTest, setLlmTest] = (0, import_react25.useState)(null);
|
|
24249
24321
|
const openaiEntries = authenticatedApps.filter(
|
|
24250
24322
|
(a) => a.app?.name?.toLowerCase() === "openai" || a.app?.id === OPENAI_APP_ID
|
|
24251
24323
|
);
|
|
@@ -24262,8 +24334,8 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
|
|
|
24262
24334
|
} : baseAuthState;
|
|
24263
24335
|
const savedUrlFromEntry = (openaiEntries[0]?.fields || []).find((f) => (f?.key || "").toLowerCase() === "url")?.value || "";
|
|
24264
24336
|
const currentUrl = (authState.credentials?.url || savedUrlFromEntry || "").trim();
|
|
24265
|
-
const [customModel, setCustomModel] = (0,
|
|
24266
|
-
const [customMode, setCustomMode] = (0,
|
|
24337
|
+
const [customModel, setCustomModel] = (0, import_react25.useState)("");
|
|
24338
|
+
const [customMode, setCustomMode] = (0, import_react25.useState)(false);
|
|
24267
24339
|
const hasOpenAIEntries = openaiEntries.length > 0;
|
|
24268
24340
|
const providerOfEntry = (entry) => providerLabelOfAuthEntry(entry);
|
|
24269
24341
|
const displayLabelOfEntry = (entry) => {
|
|
@@ -24271,20 +24343,20 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
|
|
|
24271
24343
|
const stripped = raw.replace(new RegExp(`^\\s*${OPENAI_APP_NAME}\\s*-\\s*`, "i"), "").trim();
|
|
24272
24344
|
return stripped || raw;
|
|
24273
24345
|
};
|
|
24274
|
-
const [optimisticActiveProvider, setOptimisticActiveProvider] = (0,
|
|
24275
|
-
const activeEntryRaw = (0,
|
|
24346
|
+
const [optimisticActiveProvider, setOptimisticActiveProvider] = (0, import_react25.useState)(null);
|
|
24347
|
+
const activeEntryRaw = (0, import_react25.useMemo)(
|
|
24276
24348
|
() => openaiEntries.find((e) => e?.active === true),
|
|
24277
24349
|
[openaiEntries]
|
|
24278
24350
|
);
|
|
24279
24351
|
const activeEntry = activeEntryRaw || null;
|
|
24280
|
-
const activeProviderLabel = (0,
|
|
24352
|
+
const activeProviderLabel = (0, import_react25.useMemo)(() => {
|
|
24281
24353
|
if (optimisticActiveProvider !== null) {
|
|
24282
24354
|
return optimisticActiveProvider === SHUFFLE_AI_PRESET ? null : optimisticActiveProvider;
|
|
24283
24355
|
}
|
|
24284
24356
|
if (!activeEntryRaw) return null;
|
|
24285
24357
|
return providerOfEntry(activeEntryRaw);
|
|
24286
24358
|
}, [optimisticActiveProvider, activeEntryRaw, providerOfEntry]);
|
|
24287
|
-
const effectivePreset = (0,
|
|
24359
|
+
const effectivePreset = (0, import_react25.useMemo)(() => {
|
|
24288
24360
|
if (selectedPreset) return selectedPreset;
|
|
24289
24361
|
if (optimisticActiveProvider !== null) return optimisticActiveProvider;
|
|
24290
24362
|
if (activeEntryRaw) return providerOfEntry(activeEntryRaw);
|
|
@@ -24292,12 +24364,12 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
|
|
|
24292
24364
|
if (currentUrl) return detectLLMProvider(currentUrl)?.label || CUSTOM_PRESET;
|
|
24293
24365
|
return SHUFFLE_AI_PRESET;
|
|
24294
24366
|
}, [selectedPreset, optimisticActiveProvider, currentUrl, hasOpenAIEntries, activeEntryRaw]);
|
|
24295
|
-
const providerEntries = (0,
|
|
24367
|
+
const providerEntries = (0, import_react25.useMemo)(
|
|
24296
24368
|
() => openaiEntries.filter((e) => providerOfEntry(e) === effectivePreset).map((e) => ({ ...e, label: displayLabelOfEntry(e) })),
|
|
24297
24369
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24298
24370
|
[openaiEntries, effectivePreset]
|
|
24299
24371
|
);
|
|
24300
|
-
const validatedProviderLabels = (0,
|
|
24372
|
+
const validatedProviderLabels = (0, import_react25.useMemo)(() => {
|
|
24301
24373
|
const set = /* @__PURE__ */ new Set();
|
|
24302
24374
|
const remembered = getValidatedAuthIds();
|
|
24303
24375
|
for (const entry of openaiEntries) {
|
|
@@ -24460,9 +24532,9 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
|
|
|
24460
24532
|
} catch {
|
|
24461
24533
|
}
|
|
24462
24534
|
};
|
|
24463
|
-
const prevOpenRef = (0,
|
|
24464
|
-
const hasInitializedPresetRef = (0,
|
|
24465
|
-
(0,
|
|
24535
|
+
const prevOpenRef = (0, import_react25.useRef)(open);
|
|
24536
|
+
const hasInitializedPresetRef = (0, import_react25.useRef)(false);
|
|
24537
|
+
(0, import_react25.useEffect)(() => {
|
|
24466
24538
|
const justOpened = Boolean(open && !prevOpenRef.current);
|
|
24467
24539
|
prevOpenRef.current = open;
|
|
24468
24540
|
if (authLoading) return;
|
|
@@ -24534,14 +24606,14 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
|
|
|
24534
24606
|
setCustomUrl(value);
|
|
24535
24607
|
handleAuthChange(OPENAI_APP_ID, { ...authState.credentials, url: value });
|
|
24536
24608
|
};
|
|
24537
|
-
(0,
|
|
24609
|
+
(0, import_react25.useEffect)(() => {
|
|
24538
24610
|
const preset = ENDPOINT_PRESETS.find((p) => p.label === effectivePreset);
|
|
24539
24611
|
const presetUrl = effectivePreset === CUSTOM_PRESET ? customUrl : preset?.url || "";
|
|
24540
24612
|
if (!presetUrl) return;
|
|
24541
24613
|
if ((authState.credentials?.url || "").trim()) return;
|
|
24542
24614
|
handleAuthChange(OPENAI_APP_ID, { ...authState.credentials, url: presetUrl });
|
|
24543
24615
|
}, [effectivePreset, customUrl, authState.credentials?.url]);
|
|
24544
|
-
(0,
|
|
24616
|
+
(0, import_react25.useEffect)(() => {
|
|
24545
24617
|
const models = PROVIDER_MODELS[effectivePreset];
|
|
24546
24618
|
if (!models?.length) return;
|
|
24547
24619
|
if ((authState.credentials?.model || "").trim()) return;
|
|
@@ -24564,8 +24636,8 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
|
|
|
24564
24636
|
return isLocal;
|
|
24565
24637
|
})();
|
|
24566
24638
|
const orgId = userdata?.active_org?.id;
|
|
24567
|
-
const [orgData, setOrgData] = (0,
|
|
24568
|
-
(0,
|
|
24639
|
+
const [orgData, setOrgData] = (0, import_react25.useState)(null);
|
|
24640
|
+
(0, import_react25.useEffect)(() => {
|
|
24569
24641
|
if (!orgId) return;
|
|
24570
24642
|
let cancelled = false;
|
|
24571
24643
|
(async () => {
|
|
@@ -24652,7 +24724,7 @@ var LocalLLMConfig = ({ compact, globalUrl, userdata, isLoaded, isLoggedIn, serv
|
|
|
24652
24724
|
const activeProvider = optimisticActiveProvider ?? (activeEntryRaw ? providerOfEntry(activeEntryRaw) : SHUFFLE_AI_PRESET);
|
|
24653
24725
|
const isSelected = option === activeProvider;
|
|
24654
24726
|
const isValidated = option !== SHUFFLE_AI_PRESET && validatedProviderLabels.has(option);
|
|
24655
|
-
return /* @__PURE__ */ (0,
|
|
24727
|
+
return /* @__PURE__ */ (0, import_react26.createElement)("li", { ...props, key: option }, /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_material28.Box, { sx: { display: "flex", alignItems: "center", gap: 1.25, width: "100%", minWidth: 0 }, children: [
|
|
24656
24728
|
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ProviderLogo, { label: option, url: preset?.url }),
|
|
24657
24729
|
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_material28.Typography, { sx: { fontSize: "0.85rem", color: "hsl(var(--popover-foreground))", flexShrink: 0 }, children: option }),
|
|
24658
24730
|
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_material28.Box, { sx: { flex: 1, minWidth: 0 } }),
|
|
@@ -24848,20 +24920,20 @@ var AgentRunDrawer = ({
|
|
|
24848
24920
|
}) => {
|
|
24849
24921
|
useSyncHostBaseUrl(globalUrl);
|
|
24850
24922
|
const themeScope = useShuffleMcpTheme();
|
|
24851
|
-
const [activeTab, setActiveTab] = (0,
|
|
24852
|
-
const prevOpenRef = (0,
|
|
24853
|
-
(0,
|
|
24923
|
+
const [activeTab, setActiveTab] = (0, import_react27.useState)(initialTab);
|
|
24924
|
+
const prevOpenRef = (0, import_react27.useRef)(open);
|
|
24925
|
+
(0, import_react27.useEffect)(() => {
|
|
24854
24926
|
if (open && !prevOpenRef.current) setActiveTab(initialTab);
|
|
24855
24927
|
prevOpenRef.current = open;
|
|
24856
24928
|
}, [open, initialTab]);
|
|
24857
|
-
(0,
|
|
24929
|
+
(0, import_react27.useEffect)(() => {
|
|
24858
24930
|
if (typeof window === "undefined") return;
|
|
24859
24931
|
window.__shuffleAgentDrawerMounted = (window.__shuffleAgentDrawerMounted || 0) + 1;
|
|
24860
24932
|
return () => {
|
|
24861
24933
|
window.__shuffleAgentDrawerMounted = Math.max(0, (window.__shuffleAgentDrawerMounted || 1) - 1);
|
|
24862
24934
|
};
|
|
24863
24935
|
}, []);
|
|
24864
|
-
(0,
|
|
24936
|
+
(0, import_react27.useEffect)(() => {
|
|
24865
24937
|
if (typeof window === "undefined") return;
|
|
24866
24938
|
const onOpen = (event) => {
|
|
24867
24939
|
const tab = event.detail?.tab;
|
|
@@ -24901,8 +24973,8 @@ var AgentRunDrawer = ({
|
|
|
24901
24973
|
});
|
|
24902
24974
|
const showTabs = visibleTabs.length > 1;
|
|
24903
24975
|
const safeActiveTab = visibleTabs.includes(activeTab) ? activeTab : "run";
|
|
24904
|
-
const paperRef = (0,
|
|
24905
|
-
(0,
|
|
24976
|
+
const paperRef = (0, import_react27.useRef)(null);
|
|
24977
|
+
(0, import_react27.useEffect)(() => {
|
|
24906
24978
|
if (!open || safeActiveTab !== "run") return;
|
|
24907
24979
|
const focusInput = () => {
|
|
24908
24980
|
if (!paperRef.current) return false;
|
|
@@ -24928,6 +25000,7 @@ var AgentRunDrawer = ({
|
|
|
24928
25000
|
const drawerWidth = `min(${width}px, 100vw)`;
|
|
24929
25001
|
const drawerMinWidth = `min(${minWidth}px, 100vw)`;
|
|
24930
25002
|
const drawerMaxWidth = `min(${maxWidth}px, 100vw)`;
|
|
25003
|
+
const drawerZIndex = useDrawerLayer(open);
|
|
24931
25004
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
24932
25005
|
import_material29.Drawer,
|
|
24933
25006
|
{
|
|
@@ -24935,6 +25008,7 @@ var AgentRunDrawer = ({
|
|
|
24935
25008
|
open,
|
|
24936
25009
|
onClose,
|
|
24937
25010
|
sx: {
|
|
25011
|
+
zIndex: drawerZIndex,
|
|
24938
25012
|
"& .MuiDrawer-paper": {
|
|
24939
25013
|
boxSizing: "border-box",
|
|
24940
25014
|
width: { xs: "100vw", sm: drawerWidth },
|
|
@@ -25090,7 +25164,7 @@ var AgentRunDrawer = ({
|
|
|
25090
25164
|
var AgentRunDrawer_default = AgentRunDrawer;
|
|
25091
25165
|
|
|
25092
25166
|
// components/AgentActivityList.tsx
|
|
25093
|
-
var
|
|
25167
|
+
var import_react28 = require("react");
|
|
25094
25168
|
var import_router_compat4 = require("react-router-dom");
|
|
25095
25169
|
var import_material30 = require("@mui/material");
|
|
25096
25170
|
var import_lucide_react18 = require("lucide-react");
|
|
@@ -26054,31 +26128,31 @@ var AgentActivityList = ({
|
|
|
26054
26128
|
initialRuns,
|
|
26055
26129
|
disableFetch = false
|
|
26056
26130
|
}) => {
|
|
26057
|
-
const [appDrawer, setAppDrawer] = (0,
|
|
26058
|
-
const [runs, setRuns] = (0,
|
|
26059
|
-
const [cursor, setCursor] = (0,
|
|
26060
|
-
const [hasMore, setHasMore] = (0,
|
|
26061
|
-
const [isLoading, setIsLoading] = (0,
|
|
26062
|
-
const [error, setError] = (0,
|
|
26063
|
-
const [statusFilter, setStatusFilter] = (0,
|
|
26064
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
26065
|
-
const [debouncedQuery, setDebouncedQuery] = (0,
|
|
26066
|
-
const [agentWorkflows, setAgentWorkflows] = (0,
|
|
26067
|
-
const [workflowFilter, setWorkflowFilter] = (0,
|
|
26068
|
-
const [usecaseFilter, setUsecaseFilter] = (0,
|
|
26069
|
-
const [stopOpen, setStopOpen] = (0,
|
|
26070
|
-
const [stopLoading, setStopLoading] = (0,
|
|
26071
|
-
const [appIcons, setAppIcons] = (0,
|
|
26072
|
-
const [enrichedRuns, setEnrichedRuns] = (0,
|
|
26073
|
-
const enrichedRunsRef = (0,
|
|
26074
|
-
const processedRunIdsRef = (0,
|
|
26075
|
-
(0,
|
|
26131
|
+
const [appDrawer, setAppDrawer] = (0, import_react28.useState)(null);
|
|
26132
|
+
const [runs, setRuns] = (0, import_react28.useState)(initialRuns || []);
|
|
26133
|
+
const [cursor, setCursor] = (0, import_react28.useState)("");
|
|
26134
|
+
const [hasMore, setHasMore] = (0, import_react28.useState)(false);
|
|
26135
|
+
const [isLoading, setIsLoading] = (0, import_react28.useState)(false);
|
|
26136
|
+
const [error, setError] = (0, import_react28.useState)(null);
|
|
26137
|
+
const [statusFilter, setStatusFilter] = (0, import_react28.useState)("");
|
|
26138
|
+
const [searchQuery, setSearchQuery] = (0, import_react28.useState)("");
|
|
26139
|
+
const [debouncedQuery, setDebouncedQuery] = (0, import_react28.useState)("");
|
|
26140
|
+
const [agentWorkflows, setAgentWorkflows] = (0, import_react28.useState)([]);
|
|
26141
|
+
const [workflowFilter, setWorkflowFilter] = (0, import_react28.useState)("");
|
|
26142
|
+
const [usecaseFilter, setUsecaseFilter] = (0, import_react28.useState)("");
|
|
26143
|
+
const [stopOpen, setStopOpen] = (0, import_react28.useState)(false);
|
|
26144
|
+
const [stopLoading, setStopLoading] = (0, import_react28.useState)(false);
|
|
26145
|
+
const [appIcons, setAppIcons] = (0, import_react28.useState)({});
|
|
26146
|
+
const [enrichedRuns, setEnrichedRuns] = (0, import_react28.useState)({});
|
|
26147
|
+
const enrichedRunsRef = (0, import_react28.useRef)({});
|
|
26148
|
+
const processedRunIdsRef = (0, import_react28.useRef)(/* @__PURE__ */ new Set());
|
|
26149
|
+
(0, import_react28.useEffect)(() => {
|
|
26076
26150
|
enrichedRunsRef.current = enrichedRuns;
|
|
26077
26151
|
}, [enrichedRuns]);
|
|
26078
|
-
const [abortingIds, setAbortingIds] = (0,
|
|
26079
|
-
const [abortedIds, setAbortedIds] = (0,
|
|
26080
|
-
const [lastOpenedRunId, setLastOpenedRunId] = (0,
|
|
26081
|
-
(0,
|
|
26152
|
+
const [abortingIds, setAbortingIds] = (0, import_react28.useState)(/* @__PURE__ */ new Set());
|
|
26153
|
+
const [abortedIds, setAbortedIds] = (0, import_react28.useState)(/* @__PURE__ */ new Set());
|
|
26154
|
+
const [lastOpenedRunId, setLastOpenedRunId] = (0, import_react28.useState)(() => getLastOpenedAgentRun());
|
|
26155
|
+
(0, import_react28.useEffect)(() => {
|
|
26082
26156
|
const unsubAbort = subscribeAgentAborted((eid) => {
|
|
26083
26157
|
setAbortedIds((prev) => prev.has(eid) ? prev : /* @__PURE__ */ new Set([...Array.from(prev), eid]));
|
|
26084
26158
|
setRuns((prev) => prev.map((r) => r.execution_id === eid ? { ...r, status: "ABORTED" } : r));
|
|
@@ -26089,9 +26163,9 @@ var AgentActivityList = ({
|
|
|
26089
26163
|
unsubOpened();
|
|
26090
26164
|
};
|
|
26091
26165
|
}, []);
|
|
26092
|
-
const debounceRef = (0,
|
|
26166
|
+
const debounceRef = (0, import_react28.useRef)(void 0);
|
|
26093
26167
|
const selectedAgentWorkflow = agentWorkflows.find((w) => w.id === workflowFilter) || null;
|
|
26094
|
-
const openEditPrompt = (0,
|
|
26168
|
+
const openEditPrompt = (0, import_react28.useCallback)(async () => {
|
|
26095
26169
|
if (!workflowFilter) return;
|
|
26096
26170
|
try {
|
|
26097
26171
|
const { prompt, apps } = await getAgentScheduleConfig(workflowFilter, { apiKey, apiBaseUrl, orgId });
|
|
@@ -26105,7 +26179,7 @@ var AgentActivityList = ({
|
|
|
26105
26179
|
setError(e instanceof Error ? e.message : "Failed to load workflow");
|
|
26106
26180
|
}
|
|
26107
26181
|
}, [workflowFilter, selectedAgentWorkflow, apiKey, apiBaseUrl, orgId, onEditWorkflow]);
|
|
26108
|
-
const confirmStop = (0,
|
|
26182
|
+
const confirmStop = (0, import_react28.useCallback)(async () => {
|
|
26109
26183
|
if (!workflowFilter) return;
|
|
26110
26184
|
setStopLoading(true);
|
|
26111
26185
|
try {
|
|
@@ -26120,7 +26194,7 @@ var AgentActivityList = ({
|
|
|
26120
26194
|
setStopLoading(false);
|
|
26121
26195
|
}
|
|
26122
26196
|
}, [workflowFilter, apiKey, apiBaseUrl, orgId]);
|
|
26123
|
-
const handleAbort = (0,
|
|
26197
|
+
const handleAbort = (0, import_react28.useCallback)(
|
|
26124
26198
|
async (run) => {
|
|
26125
26199
|
const eid = run.execution_id;
|
|
26126
26200
|
const wfId = run.workflow_id || run?.workflow?.id;
|
|
@@ -26165,15 +26239,15 @@ var AgentActivityList = ({
|
|
|
26165
26239
|
},
|
|
26166
26240
|
[apiKey, apiBaseUrl, orgId]
|
|
26167
26241
|
);
|
|
26168
|
-
const updateSearchQuery = (0,
|
|
26242
|
+
const updateSearchQuery = (0, import_react28.useCallback)((q) => {
|
|
26169
26243
|
setSearchQuery(q);
|
|
26170
26244
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
26171
26245
|
debounceRef.current = setTimeout(() => setDebouncedQuery(q), 350);
|
|
26172
26246
|
}, []);
|
|
26173
|
-
(0,
|
|
26247
|
+
(0, import_react28.useEffect)(() => () => {
|
|
26174
26248
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
26175
26249
|
}, []);
|
|
26176
|
-
const fetchRuns = (0,
|
|
26250
|
+
const fetchRuns = (0, import_react28.useCallback)(
|
|
26177
26251
|
async (append = false, cursorParam = "") => {
|
|
26178
26252
|
if (disableFetch) {
|
|
26179
26253
|
if (initialRuns && !append) {
|
|
@@ -26221,10 +26295,10 @@ var AgentActivityList = ({
|
|
|
26221
26295
|
},
|
|
26222
26296
|
[disableFetch, initialRuns, statusFilter, limit, top, apiKey, apiBaseUrl, orgId, workflowFilter]
|
|
26223
26297
|
);
|
|
26224
|
-
(0,
|
|
26298
|
+
(0, import_react28.useEffect)(() => {
|
|
26225
26299
|
fetchRuns(false, "");
|
|
26226
26300
|
}, [statusFilter, apiKey, apiBaseUrl, orgId, workflowFilter]);
|
|
26227
|
-
(0,
|
|
26301
|
+
(0, import_react28.useEffect)(() => {
|
|
26228
26302
|
let cancelled = false;
|
|
26229
26303
|
listAgentScheduleWorkflows({ apiKey, apiBaseUrl, orgId }).then((items) => {
|
|
26230
26304
|
if (!cancelled) setAgentWorkflows(items);
|
|
@@ -26234,7 +26308,7 @@ var AgentActivityList = ({
|
|
|
26234
26308
|
cancelled = true;
|
|
26235
26309
|
};
|
|
26236
26310
|
}, [apiKey, apiBaseUrl, orgId]);
|
|
26237
|
-
(0,
|
|
26311
|
+
(0, import_react28.useEffect)(() => {
|
|
26238
26312
|
let cancelled = false;
|
|
26239
26313
|
fetchAppsViaApiConfig().then((apps) => {
|
|
26240
26314
|
if (cancelled || !Array.isArray(apps)) return;
|
|
@@ -26252,7 +26326,7 @@ var AgentActivityList = ({
|
|
|
26252
26326
|
cancelled = true;
|
|
26253
26327
|
};
|
|
26254
26328
|
}, []);
|
|
26255
|
-
(0,
|
|
26329
|
+
(0, import_react28.useEffect)(() => {
|
|
26256
26330
|
if (!runs.length) return;
|
|
26257
26331
|
let cancelled = false;
|
|
26258
26332
|
const buildPatchFromRun = (r) => {
|
|
@@ -26391,7 +26465,7 @@ var AgentActivityList = ({
|
|
|
26391
26465
|
const merged = patch2 ? { ...r, ...patch2 } : r;
|
|
26392
26466
|
return r.execution_id && abortedIds.has(r.execution_id) ? { ...merged, status: "ABORTED" } : merged;
|
|
26393
26467
|
});
|
|
26394
|
-
const loadMore = (0,
|
|
26468
|
+
const loadMore = (0, import_react28.useCallback)(() => {
|
|
26395
26469
|
if (cursor && !isLoading) fetchRuns(true, cursor);
|
|
26396
26470
|
}, [cursor, isLoading, fetchRuns]);
|
|
26397
26471
|
const activeUsecase = usecaseFilters.find((u) => u.id === usecaseFilter) || null;
|
|
@@ -26737,7 +26811,7 @@ var AgentActivityList = ({
|
|
|
26737
26811
|
var AgentActivityList_default = AgentActivityList;
|
|
26738
26812
|
|
|
26739
26813
|
// components/AgentExecutionDrawer.tsx
|
|
26740
|
-
var
|
|
26814
|
+
var import_react29 = require("react");
|
|
26741
26815
|
var import_material31 = require("@mui/material");
|
|
26742
26816
|
var import_lucide_react20 = require("lucide-react");
|
|
26743
26817
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
@@ -26767,8 +26841,8 @@ var AgentExecutionDrawer = ({
|
|
|
26767
26841
|
colorMode
|
|
26768
26842
|
}) => {
|
|
26769
26843
|
const themeScope = useShuffleMcpTheme();
|
|
26770
|
-
const [bodyReady, setBodyReady] = (0,
|
|
26771
|
-
(0,
|
|
26844
|
+
const [bodyReady, setBodyReady] = (0, import_react29.useState)(false);
|
|
26845
|
+
(0, import_react29.useEffect)(() => {
|
|
26772
26846
|
if (!open || !run?.execution_id) {
|
|
26773
26847
|
setBodyReady(false);
|
|
26774
26848
|
return;
|
|
@@ -26782,6 +26856,7 @@ var AgentExecutionDrawer = ({
|
|
|
26782
26856
|
const drawerWidth = `min(${width}px, 100vw)`;
|
|
26783
26857
|
const drawerMinWidth = `min(${minWidth}px, 100vw)`;
|
|
26784
26858
|
const drawerMaxWidth = `min(${maxWidth}px, 100vw)`;
|
|
26859
|
+
const drawerZIndex = useDrawerLayer(open);
|
|
26785
26860
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
26786
26861
|
import_material31.Drawer,
|
|
26787
26862
|
{
|
|
@@ -26791,7 +26866,7 @@ var AgentExecutionDrawer = ({
|
|
|
26791
26866
|
keepMounted: true,
|
|
26792
26867
|
transitionDuration: { enter: 120, exit: 100 },
|
|
26793
26868
|
sx: {
|
|
26794
|
-
zIndex:
|
|
26869
|
+
zIndex: drawerZIndex,
|
|
26795
26870
|
"& .MuiDrawer-paper": {
|
|
26796
26871
|
boxSizing: "border-box",
|
|
26797
26872
|
width: { xs: "100vw", sm: drawerWidth },
|
|
@@ -26966,7 +27041,7 @@ var AgentExecutionDrawer = ({
|
|
|
26966
27041
|
var AgentExecutionDrawer_default = AgentExecutionDrawer;
|
|
26967
27042
|
|
|
26968
27043
|
// views/AgentsView.tsx
|
|
26969
|
-
var
|
|
27044
|
+
var import_react30 = require("react");
|
|
26970
27045
|
var import_material32 = require("@mui/material");
|
|
26971
27046
|
init_api();
|
|
26972
27047
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
@@ -27021,21 +27096,21 @@ var AgentsView = ({
|
|
|
27021
27096
|
orgId
|
|
27022
27097
|
}) => {
|
|
27023
27098
|
useSyncHostBaseUrl(globalUrl);
|
|
27024
|
-
const resolvedTheme = (0,
|
|
27025
|
-
const hydratedInitialApps = (0,
|
|
27099
|
+
const resolvedTheme = (0, import_react30.useMemo)(() => resolveTheme(theme), [theme]);
|
|
27100
|
+
const hydratedInitialApps = (0, import_react30.useMemo)(() => {
|
|
27026
27101
|
if (initialApps && initialApps.length > 0) return initialApps;
|
|
27027
27102
|
if (disableAppsPersistence) return [];
|
|
27028
27103
|
return readPersistedApps(appsStorageKey) ?? [];
|
|
27029
27104
|
}, []);
|
|
27030
|
-
const [selectedRun, setSelectedRun] = (0,
|
|
27031
|
-
const [agentView, setAgentView] = (0,
|
|
27032
|
-
const [prefill, setPrefill] = (0,
|
|
27105
|
+
const [selectedRun, setSelectedRun] = (0, import_react30.useState)(null);
|
|
27106
|
+
const [agentView, setAgentView] = (0, import_react30.useState)("start");
|
|
27107
|
+
const [prefill, setPrefill] = (0, import_react30.useState)({
|
|
27033
27108
|
input: "",
|
|
27034
27109
|
apps: hydratedInitialApps,
|
|
27035
27110
|
key: 0
|
|
27036
27111
|
});
|
|
27037
|
-
const [editing, setEditing] = (0,
|
|
27038
|
-
const handleAppsChange = (0,
|
|
27112
|
+
const [editing, setEditing] = (0, import_react30.useState)(null);
|
|
27113
|
+
const handleAppsChange = (0, import_react30.useCallback)((apps) => {
|
|
27039
27114
|
if (onAppsChange) {
|
|
27040
27115
|
try {
|
|
27041
27116
|
onAppsChange(apps);
|
|
@@ -27057,13 +27132,13 @@ var AgentsView = ({
|
|
|
27057
27132
|
} catch {
|
|
27058
27133
|
}
|
|
27059
27134
|
}, [onAppsChange, disableAppsPersistence, appsStorageKey]);
|
|
27060
|
-
(0,
|
|
27135
|
+
(0, import_react30.useEffect)(() => {
|
|
27061
27136
|
}, [handleAppsChange]);
|
|
27062
|
-
const [builtInDrawer, setBuiltInDrawer] = (0,
|
|
27137
|
+
const [builtInDrawer, setBuiltInDrawer] = (0, import_react30.useState)({
|
|
27063
27138
|
open: false,
|
|
27064
27139
|
tab: "localLLM"
|
|
27065
27140
|
});
|
|
27066
|
-
(0,
|
|
27141
|
+
(0, import_react30.useEffect)(() => {
|
|
27067
27142
|
if (typeof window === "undefined") return;
|
|
27068
27143
|
const handler = (e) => {
|
|
27069
27144
|
const detail = e.detail;
|
|
@@ -27072,14 +27147,14 @@ var AgentsView = ({
|
|
|
27072
27147
|
window.addEventListener("agent-drawer-open", handler);
|
|
27073
27148
|
return () => window.removeEventListener("agent-drawer-open", handler);
|
|
27074
27149
|
}, []);
|
|
27075
|
-
const effectiveSchedule = (0,
|
|
27150
|
+
const effectiveSchedule = (0, import_react30.useCallback)(
|
|
27076
27151
|
async (info) => {
|
|
27077
27152
|
if (onSchedule) return onSchedule(info);
|
|
27078
27153
|
await scheduleAgentRun({ ...info, apiKey, apiBaseUrl: globalUrl, orgId });
|
|
27079
27154
|
},
|
|
27080
27155
|
[onSchedule, apiKey, globalUrl, orgId]
|
|
27081
27156
|
);
|
|
27082
|
-
const effectiveLocalLLMSlot = (0,
|
|
27157
|
+
const effectiveLocalLLMSlot = (0, import_react30.useMemo)(
|
|
27083
27158
|
() => localLLMSlot ?? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
27084
27159
|
LocalLLMConfig_default,
|
|
27085
27160
|
{
|
|
@@ -27095,14 +27170,14 @@ var AgentsView = ({
|
|
|
27095
27170
|
),
|
|
27096
27171
|
[localLLMSlot, builtInDrawer.open, globalUrl, userdata, isLoaded, isLoggedIn, serverside, resolvedTheme, colorMode]
|
|
27097
27172
|
);
|
|
27098
|
-
const handleChooseLLM = (0,
|
|
27173
|
+
const handleChooseLLM = (0, import_react30.useCallback)(() => {
|
|
27099
27174
|
if (onChooseLLM) {
|
|
27100
27175
|
onChooseLLM();
|
|
27101
27176
|
return;
|
|
27102
27177
|
}
|
|
27103
27178
|
setBuiltInDrawer({ open: true, tab: "localLLM" });
|
|
27104
27179
|
}, [onChooseLLM]);
|
|
27105
|
-
(0,
|
|
27180
|
+
(0, import_react30.useEffect)(() => {
|
|
27106
27181
|
if (typeof window === "undefined") return;
|
|
27107
27182
|
if (window.location.hash !== "#agent-activity") return;
|
|
27108
27183
|
const tryScroll = () => {
|
|
@@ -27112,7 +27187,7 @@ var AgentsView = ({
|
|
|
27112
27187
|
const t = window.setTimeout(tryScroll, 150);
|
|
27113
27188
|
return () => window.clearTimeout(t);
|
|
27114
27189
|
}, []);
|
|
27115
|
-
const handleEditWorkflow = (0,
|
|
27190
|
+
const handleEditWorkflow = (0, import_react30.useCallback)(
|
|
27116
27191
|
({ workflowId, name, prompt, apps }) => {
|
|
27117
27192
|
setEditing({ workflowId, name });
|
|
27118
27193
|
setPrefill((prev) => ({
|
|
@@ -27124,7 +27199,7 @@ var AgentsView = ({
|
|
|
27124
27199
|
},
|
|
27125
27200
|
[]
|
|
27126
27201
|
);
|
|
27127
|
-
const handleSaveEdit = (0,
|
|
27202
|
+
const handleSaveEdit = (0, import_react30.useCallback)(
|
|
27128
27203
|
async ({ input, apps }) => {
|
|
27129
27204
|
if (!editing) return;
|
|
27130
27205
|
try {
|
|
@@ -27261,24 +27336,24 @@ var AgentsView_default = AgentsView;
|
|
|
27261
27336
|
|
|
27262
27337
|
// components/AddAppModal.tsx
|
|
27263
27338
|
var import_lucide_react21 = require("lucide-react");
|
|
27264
|
-
var
|
|
27339
|
+
var import_react32 = require("react");
|
|
27265
27340
|
var import_material33 = require("@mui/material");
|
|
27266
27341
|
var import_framer_motion9 = require("framer-motion");
|
|
27267
27342
|
init_api();
|
|
27268
27343
|
|
|
27269
27344
|
// useAppAuthFlow.ts
|
|
27270
|
-
var
|
|
27345
|
+
var import_react31 = require("react");
|
|
27271
27346
|
init_api();
|
|
27272
27347
|
function useAppAuthFlow() {
|
|
27273
|
-
const [selectedApp, setSelectedApp] = (0,
|
|
27274
|
-
const [authState, setAuthState] = (0,
|
|
27348
|
+
const [selectedApp, setSelectedApp] = (0, import_react31.useState)(null);
|
|
27349
|
+
const [authState, setAuthState] = (0, import_react31.useState)({
|
|
27275
27350
|
systemId: "",
|
|
27276
27351
|
status: "pending",
|
|
27277
27352
|
credentials: {}
|
|
27278
27353
|
});
|
|
27279
|
-
const [authenticatedApps, setAuthenticatedApps] = (0,
|
|
27280
|
-
const [authLoading, setAuthLoading] = (0,
|
|
27281
|
-
const fetchAuthForApp = (0,
|
|
27354
|
+
const [authenticatedApps, setAuthenticatedApps] = (0, import_react31.useState)([]);
|
|
27355
|
+
const [authLoading, setAuthLoading] = (0, import_react31.useState)(false);
|
|
27356
|
+
const fetchAuthForApp = (0, import_react31.useCallback)(async (appName, appImageUrl) => {
|
|
27282
27357
|
setAuthLoading(true);
|
|
27283
27358
|
try {
|
|
27284
27359
|
const authData = await fetchAuthenticatedApps();
|
|
@@ -27299,20 +27374,20 @@ function useAppAuthFlow() {
|
|
|
27299
27374
|
setAuthLoading(false);
|
|
27300
27375
|
}
|
|
27301
27376
|
}, []);
|
|
27302
|
-
const selectApp = (0,
|
|
27377
|
+
const selectApp = (0, import_react31.useCallback)((app2) => {
|
|
27303
27378
|
setSelectedApp(app2);
|
|
27304
27379
|
setAuthState({ systemId: app2.objectID, status: "pending", credentials: {} });
|
|
27305
27380
|
fetchAuthForApp(app2.name, app2.image_url);
|
|
27306
27381
|
}, [fetchAuthForApp]);
|
|
27307
|
-
const clearSelection = (0,
|
|
27382
|
+
const clearSelection = (0, import_react31.useCallback)(() => {
|
|
27308
27383
|
setSelectedApp(null);
|
|
27309
27384
|
setAuthState({ systemId: "", status: "pending", credentials: {} });
|
|
27310
27385
|
setAuthenticatedApps([]);
|
|
27311
27386
|
}, []);
|
|
27312
|
-
const handleAuthChange = (0,
|
|
27387
|
+
const handleAuthChange = (0, import_react31.useCallback)((_appId, credentials) => {
|
|
27313
27388
|
setAuthState((prev) => ({ ...prev, credentials }));
|
|
27314
27389
|
}, []);
|
|
27315
|
-
const handleTestConnection = (0,
|
|
27390
|
+
const handleTestConnection = (0, import_react31.useCallback)(async (systemId, authenticationId) => {
|
|
27316
27391
|
if (!selectedApp) return;
|
|
27317
27392
|
setAuthState((prev) => ({ ...prev, status: "testing" }));
|
|
27318
27393
|
try {
|
|
@@ -27353,7 +27428,7 @@ function useAppAuthFlow() {
|
|
|
27353
27428
|
}));
|
|
27354
27429
|
}
|
|
27355
27430
|
}, [selectedApp, fetchAuthForApp]);
|
|
27356
|
-
const handleSaveAuth = (0,
|
|
27431
|
+
const handleSaveAuth = (0, import_react31.useCallback)(async (appId, credentials) => {
|
|
27357
27432
|
if (!selectedApp) return false;
|
|
27358
27433
|
const fields = Object.entries(credentials).filter(([key, value]) => key?.trim() && value?.trim()).map(([key, value]) => ({ key, value }));
|
|
27359
27434
|
const payload = {
|
|
@@ -27388,7 +27463,7 @@ function useAppAuthFlow() {
|
|
|
27388
27463
|
return false;
|
|
27389
27464
|
}
|
|
27390
27465
|
}, [selectedApp, fetchAuthForApp]);
|
|
27391
|
-
const refreshAuth = (0,
|
|
27466
|
+
const refreshAuth = (0, import_react31.useCallback)(async () => {
|
|
27392
27467
|
if (selectedApp) {
|
|
27393
27468
|
await fetchAuthForApp(selectedApp.name, selectedApp.image_url);
|
|
27394
27469
|
}
|
|
@@ -27487,7 +27562,7 @@ var singulStyles2 = {
|
|
|
27487
27562
|
}
|
|
27488
27563
|
};
|
|
27489
27564
|
var AddAppModal = ({ open, onClose, initialQuery, categoryLabel }) => {
|
|
27490
|
-
const [phase, setPhase] = (0,
|
|
27565
|
+
const [phase, setPhase] = (0, import_react32.useState)("search");
|
|
27491
27566
|
const {
|
|
27492
27567
|
selectedApp,
|
|
27493
27568
|
authState,
|
|
@@ -27500,7 +27575,7 @@ var AddAppModal = ({ open, onClose, initialQuery, categoryLabel }) => {
|
|
|
27500
27575
|
handleSaveAuth,
|
|
27501
27576
|
refreshAuth
|
|
27502
27577
|
} = useAppAuthFlow();
|
|
27503
|
-
(0,
|
|
27578
|
+
(0, import_react32.useEffect)(() => {
|
|
27504
27579
|
if (!open) {
|
|
27505
27580
|
setPhase("search");
|
|
27506
27581
|
clearSelection();
|
|
@@ -27656,14 +27731,16 @@ var AskAiButton = ({
|
|
|
27656
27731
|
return null;
|
|
27657
27732
|
}
|
|
27658
27733
|
const isEffectiveSupport = isSupport !== void 0 ? isSupport : isSupportUser();
|
|
27659
|
-
const
|
|
27734
|
+
const isIncidentOrDocs = currentPath.startsWith("/incidents") || currentPath.startsWith("/incidents-simple") || currentPath.startsWith("/cases") || currentPath.startsWith("/alerts") || currentPath.startsWith("/tickets") || currentPath.startsWith("/docs");
|
|
27735
|
+
const effectiveIsBeta = isBeta || isIncidentOrDocs;
|
|
27736
|
+
const effectiveRequireSupport = effectiveIsBeta ? false : requireSupport;
|
|
27660
27737
|
if (effectiveRequireSupport && !isEffectiveSupport) {
|
|
27661
27738
|
return null;
|
|
27662
27739
|
}
|
|
27663
27740
|
if (hideWhenOpen && isOpen) {
|
|
27664
27741
|
return null;
|
|
27665
27742
|
}
|
|
27666
|
-
const effectiveTagLabel = tagLabel !== void 0 ? tagLabel :
|
|
27743
|
+
const effectiveTagLabel = tagLabel !== void 0 && !(tagLabel === "Support" && isIncidentOrDocs) ? tagLabel : effectiveIsBeta ? "Beta" : "Support";
|
|
27667
27744
|
const effectiveTooltip = tooltipTitle !== void 0 ? tooltipTitle : label !== "Ask AI" ? label : contextHint ? `Ask AI (${contextHint})` : "Ask AI \u2022 Context-aware assistant";
|
|
27668
27745
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
27669
27746
|
import_material34.Box,
|
|
@@ -27754,9 +27831,9 @@ var AskAiButton = ({
|
|
|
27754
27831
|
fontWeight: 700,
|
|
27755
27832
|
textTransform: "uppercase",
|
|
27756
27833
|
letterSpacing: "0.04em",
|
|
27757
|
-
color:
|
|
27758
|
-
bgcolor:
|
|
27759
|
-
border:
|
|
27834
|
+
color: effectiveIsBeta ? "hsl(var(--primary))" : "hsl(var(--muted-foreground))",
|
|
27835
|
+
bgcolor: effectiveIsBeta ? "hsla(var(--primary) / 0.12)" : "hsla(var(--muted-foreground) / 0.12)",
|
|
27836
|
+
border: effectiveIsBeta ? "1px solid hsla(var(--primary) / 0.26)" : "1px solid hsla(var(--muted-foreground) / 0.24)",
|
|
27760
27837
|
px: 0.9,
|
|
27761
27838
|
py: 0.25,
|
|
27762
27839
|
borderRadius: "9999px",
|
|
@@ -27775,7 +27852,7 @@ var AskAiButton = ({
|
|
|
27775
27852
|
var AskAiButton_default = AskAiButton;
|
|
27776
27853
|
|
|
27777
27854
|
// components/AskAiDrawer.tsx
|
|
27778
|
-
var
|
|
27855
|
+
var import_react33 = require("react");
|
|
27779
27856
|
var import_material35 = require("@mui/material");
|
|
27780
27857
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
27781
27858
|
var AskAiDrawer = ({
|
|
@@ -27791,13 +27868,13 @@ var AskAiDrawer = ({
|
|
|
27791
27868
|
agentUIProps,
|
|
27792
27869
|
...drawerProps
|
|
27793
27870
|
}) => {
|
|
27794
|
-
const [internalPathname, setInternalPathname] = (0,
|
|
27871
|
+
const [internalPathname, setInternalPathname] = (0, import_react33.useState)(
|
|
27795
27872
|
() => typeof window !== "undefined" ? window.location.pathname : "/"
|
|
27796
27873
|
);
|
|
27797
|
-
const [internalSearch, setInternalSearch] = (0,
|
|
27874
|
+
const [internalSearch, setInternalSearch] = (0, import_react33.useState)(
|
|
27798
27875
|
() => typeof window !== "undefined" ? window.location.search : ""
|
|
27799
27876
|
);
|
|
27800
|
-
(0,
|
|
27877
|
+
(0, import_react33.useEffect)(() => {
|
|
27801
27878
|
if (propPathname !== void 0) return;
|
|
27802
27879
|
const updateLoc = () => {
|
|
27803
27880
|
setInternalPathname(window.location.pathname);
|
|
@@ -27808,20 +27885,20 @@ var AskAiDrawer = ({
|
|
|
27808
27885
|
}, [propPathname]);
|
|
27809
27886
|
const activePathname = propPathname !== void 0 ? propPathname : internalPathname;
|
|
27810
27887
|
const activeSearch = propSearch !== void 0 ? propSearch : internalSearch;
|
|
27811
|
-
const [resetKey, setResetKey] = (0,
|
|
27812
|
-
const resolvedContext = (0,
|
|
27888
|
+
const [resetKey, setResetKey] = (0, import_react33.useState)(0);
|
|
27889
|
+
const resolvedContext = (0, import_react33.useMemo)(
|
|
27813
27890
|
() => resolveAgentContext(activePathname, activeSearch, rules),
|
|
27814
27891
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27815
27892
|
[activePathname, activeSearch, rules, resetKey]
|
|
27816
27893
|
);
|
|
27817
|
-
(0,
|
|
27894
|
+
(0, import_react33.useEffect)(() => {
|
|
27818
27895
|
onContextResolved?.(resolvedContext);
|
|
27819
27896
|
}, [resolvedContext, onContextResolved]);
|
|
27820
|
-
const [isOverridden, setIsOverridden] = (0,
|
|
27821
|
-
(0,
|
|
27897
|
+
const [isOverridden, setIsOverridden] = (0, import_react33.useState)(resolvedContext.isOverridden);
|
|
27898
|
+
(0, import_react33.useEffect)(() => {
|
|
27822
27899
|
setIsOverridden(resolvedContext.isOverridden);
|
|
27823
27900
|
}, [resolvedContext.isOverridden, resolvedContext.storageKey]);
|
|
27824
|
-
const handleAppsChange = (0,
|
|
27901
|
+
const handleAppsChange = (0, import_react33.useCallback)(
|
|
27825
27902
|
(apps) => {
|
|
27826
27903
|
setPageContextChoice(resolvedContext.storageKey, {
|
|
27827
27904
|
apps: apps.map((a) => ({ name: a.name, id: a.id, icon: a.icon }))
|
|
@@ -27830,7 +27907,7 @@ var AskAiDrawer = ({
|
|
|
27830
27907
|
},
|
|
27831
27908
|
[resolvedContext.storageKey]
|
|
27832
27909
|
);
|
|
27833
|
-
const handleSelectPreset = (0,
|
|
27910
|
+
const handleSelectPreset = (0, import_react33.useCallback)(
|
|
27834
27911
|
(preset) => {
|
|
27835
27912
|
setPageContextChoice(resolvedContext.storageKey, {
|
|
27836
27913
|
presetId: preset.id
|
|
@@ -27839,7 +27916,7 @@ var AskAiDrawer = ({
|
|
|
27839
27916
|
},
|
|
27840
27917
|
[resolvedContext.storageKey]
|
|
27841
27918
|
);
|
|
27842
|
-
const handleResetToDefaults = (0,
|
|
27919
|
+
const handleResetToDefaults = (0, import_react33.useCallback)(() => {
|
|
27843
27920
|
clearPageContextChoice(resolvedContext.storageKey);
|
|
27844
27921
|
setIsOverridden(false);
|
|
27845
27922
|
setResetKey((k) => k + 1);
|
|
@@ -27901,10 +27978,11 @@ var AskAiDrawer = ({
|
|
|
27901
27978
|
var AskAiDrawer_default = AskAiDrawer;
|
|
27902
27979
|
|
|
27903
27980
|
// components/AskAiSidePanel.tsx
|
|
27904
|
-
var
|
|
27981
|
+
var import_react34 = __toESM(require("react"));
|
|
27905
27982
|
var import_material36 = require("@mui/material");
|
|
27906
27983
|
var import_lucide_react22 = require("lucide-react");
|
|
27907
27984
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
27985
|
+
var import_react35 = require("react");
|
|
27908
27986
|
var AGENT_DRAWER_OPEN_EVENT = "agent-drawer-open";
|
|
27909
27987
|
var ASK_AI_PANEL_WIDTH_STORAGE_KEY = "shuffle:ask_ai_panel_width";
|
|
27910
27988
|
var MIN_ASK_AI_PANEL_WIDTH = 340;
|
|
@@ -27940,9 +28018,9 @@ var AskAiSidePanel = ({
|
|
|
27940
28018
|
}) => {
|
|
27941
28019
|
const themeScope = useShuffleMcpTheme();
|
|
27942
28020
|
const effectiveTheme = theme || (themeScope?.isDark ? "dark" : "light");
|
|
27943
|
-
const [currentPathname, setCurrentPathname] = (0,
|
|
27944
|
-
const [currentSearch, setCurrentSearch] = (0,
|
|
27945
|
-
(0,
|
|
28021
|
+
const [currentPathname, setCurrentPathname] = (0, import_react34.useState)(pathname ?? "/");
|
|
28022
|
+
const [currentSearch, setCurrentSearch] = (0, import_react34.useState)(search ?? "");
|
|
28023
|
+
(0, import_react34.useEffect)(() => {
|
|
27946
28024
|
if (pathname !== void 0) {
|
|
27947
28025
|
setCurrentPathname(pathname);
|
|
27948
28026
|
return;
|
|
@@ -27958,24 +28036,24 @@ var AskAiSidePanel = ({
|
|
|
27958
28036
|
}
|
|
27959
28037
|
return;
|
|
27960
28038
|
}, [pathname]);
|
|
27961
|
-
(0,
|
|
28039
|
+
(0, import_react34.useEffect)(() => {
|
|
27962
28040
|
if (search !== void 0) {
|
|
27963
28041
|
setCurrentSearch(search);
|
|
27964
28042
|
}
|
|
27965
28043
|
}, [search]);
|
|
27966
28044
|
const isAgentDisabled = isAgentRoute(currentPathname);
|
|
27967
28045
|
const isVisible = open && !isAgentDisabled;
|
|
27968
|
-
(0,
|
|
28046
|
+
(0, import_react34.useEffect)(() => {
|
|
27969
28047
|
if (isAgentDisabled && open) {
|
|
27970
28048
|
onClose();
|
|
27971
28049
|
}
|
|
27972
28050
|
}, [isAgentDisabled, open, onClose]);
|
|
27973
|
-
const context =
|
|
28051
|
+
const context = import_react34.default.useMemo(
|
|
27974
28052
|
() => resolveAgentContext(currentPathname, currentSearch, rules),
|
|
27975
28053
|
[currentPathname, currentSearch, rules]
|
|
27976
28054
|
);
|
|
27977
|
-
const [entityTitle, setEntityTitle] = (0,
|
|
27978
|
-
(0,
|
|
28055
|
+
const [entityTitle, setEntityTitle] = (0, import_react34.useState)(() => getActivePageEntityName());
|
|
28056
|
+
(0, import_react34.useEffect)(() => {
|
|
27979
28057
|
if (!open) return;
|
|
27980
28058
|
const current = getActivePageEntityName();
|
|
27981
28059
|
if (current) setEntityTitle(current);
|
|
@@ -28014,46 +28092,58 @@ var AskAiSidePanel = ({
|
|
|
28014
28092
|
observer?.disconnect();
|
|
28015
28093
|
};
|
|
28016
28094
|
}, [open, currentPathname]);
|
|
28017
|
-
const displayTitle =
|
|
28095
|
+
const displayTitle = import_react34.default.useMemo(() => {
|
|
28018
28096
|
if (context.titleFn) {
|
|
28019
28097
|
return context.titleFn(entityTitle);
|
|
28020
28098
|
}
|
|
28021
28099
|
return context.title || "How can we help on this page?";
|
|
28022
28100
|
}, [context, entityTitle]);
|
|
28023
|
-
(0,
|
|
28101
|
+
(0, import_react34.useEffect)(() => {
|
|
28024
28102
|
onContextResolved?.(context);
|
|
28025
28103
|
}, [context, onContextResolved]);
|
|
28026
28104
|
useSyncHostBaseUrl(globalUrl);
|
|
28027
|
-
const [internalTab, setInternalTab] = (0,
|
|
28105
|
+
const [internalTab, setInternalTab] = (0, import_react34.useState)(initialTab);
|
|
28028
28106
|
const currentTab = propActiveTab !== void 0 ? propActiveTab : internalTab;
|
|
28029
|
-
const [controlledDefaultInput, setControlledDefaultInput] = (0,
|
|
28030
|
-
(0,
|
|
28107
|
+
const [controlledDefaultInput, setControlledDefaultInput] = (0, import_react34.useState)(defaultInput);
|
|
28108
|
+
const [controlledAutoSubmit, setControlledAutoSubmit] = (0, import_react34.useState)(void 0);
|
|
28109
|
+
(0, import_react34.useEffect)(() => {
|
|
28031
28110
|
if (defaultInput !== void 0) {
|
|
28032
28111
|
setControlledDefaultInput(defaultInput);
|
|
28033
28112
|
}
|
|
28034
28113
|
}, [defaultInput]);
|
|
28035
28114
|
const effectiveDefaultInput = controlledDefaultInput ?? defaultInput ?? agentUIProps?.defaultInput;
|
|
28036
|
-
const
|
|
28115
|
+
const effectiveAutoSubmit = controlledAutoSubmit ?? agentUIProps?.autoSubmit;
|
|
28116
|
+
const isBetaRoute = context.isBeta === true || currentPathname.startsWith("/incidents") || currentPathname.startsWith("/incidents-simple") || currentPathname.startsWith("/cases") || currentPathname.startsWith("/alerts") || currentPathname.startsWith("/tickets") || currentPathname.startsWith("/docs");
|
|
28117
|
+
const handleTabChange = (0, import_react34.useCallback)(
|
|
28037
28118
|
(nextTab) => {
|
|
28038
28119
|
setInternalTab(nextTab);
|
|
28039
28120
|
onTabChange?.(nextTab);
|
|
28040
28121
|
},
|
|
28041
28122
|
[onTabChange]
|
|
28042
28123
|
);
|
|
28043
|
-
(0,
|
|
28124
|
+
(0, import_react34.useEffect)(() => {
|
|
28044
28125
|
if (initialTab) {
|
|
28045
28126
|
setInternalTab(initialTab);
|
|
28046
28127
|
}
|
|
28047
28128
|
}, [initialTab]);
|
|
28048
|
-
const prevOpenRef = (0,
|
|
28049
|
-
(0,
|
|
28129
|
+
const prevOpenRef = (0, import_react34.useRef)(open);
|
|
28130
|
+
(0, import_react34.useEffect)(() => {
|
|
28050
28131
|
if (open && !prevOpenRef.current && initialTab) {
|
|
28051
28132
|
setInternalTab(initialTab);
|
|
28052
28133
|
onTabChange?.(initialTab);
|
|
28053
28134
|
}
|
|
28054
28135
|
prevOpenRef.current = open;
|
|
28055
28136
|
}, [open, initialTab, onTabChange]);
|
|
28056
|
-
(0,
|
|
28137
|
+
const [activeTaskId, setActiveTaskId] = (0, import_react34.useState)(null);
|
|
28138
|
+
const [activeExecutionId, setActiveExecutionId] = (0, import_react34.useState)(null);
|
|
28139
|
+
const [runResetKey, setRunResetKey] = (0, import_react34.useState)(0);
|
|
28140
|
+
(0, import_react34.useEffect)(() => {
|
|
28141
|
+
if (!open) {
|
|
28142
|
+
setActiveTaskId(null);
|
|
28143
|
+
setActiveExecutionId(null);
|
|
28144
|
+
}
|
|
28145
|
+
}, [open]);
|
|
28146
|
+
(0, import_react34.useEffect)(() => {
|
|
28057
28147
|
if (typeof window === "undefined") return;
|
|
28058
28148
|
window.__shuffleAgentDrawerMounted = (window.__shuffleAgentDrawerMounted || 0) + 1;
|
|
28059
28149
|
return () => {
|
|
@@ -28063,7 +28153,7 @@ var AskAiSidePanel = ({
|
|
|
28063
28153
|
);
|
|
28064
28154
|
};
|
|
28065
28155
|
}, []);
|
|
28066
|
-
(0,
|
|
28156
|
+
(0, import_react34.useEffect)(() => {
|
|
28067
28157
|
if (typeof window === "undefined") return;
|
|
28068
28158
|
const onOpen = (event) => {
|
|
28069
28159
|
const detail = event.detail;
|
|
@@ -28074,12 +28164,49 @@ var AskAiSidePanel = ({
|
|
|
28074
28164
|
if (detail?.defaultInput !== void 0) {
|
|
28075
28165
|
setControlledDefaultInput(detail.defaultInput);
|
|
28076
28166
|
}
|
|
28167
|
+
if (detail?.autoSubmit !== void 0) {
|
|
28168
|
+
setControlledAutoSubmit(detail.autoSubmit);
|
|
28169
|
+
}
|
|
28170
|
+
if (detail?.taskId !== void 0) {
|
|
28171
|
+
setActiveTaskId(detail.taskId || null);
|
|
28172
|
+
} else if (!detail?.tab) {
|
|
28173
|
+
setActiveTaskId(null);
|
|
28174
|
+
}
|
|
28175
|
+
if (detail?.resetExecution) {
|
|
28176
|
+
setActiveExecutionId(null);
|
|
28177
|
+
setRunResetKey((k) => k + 1);
|
|
28178
|
+
} else if (detail?.executionId !== void 0) {
|
|
28179
|
+
setActiveExecutionId(detail.executionId || null);
|
|
28180
|
+
} else if (detail?.taskId) {
|
|
28181
|
+
setActiveExecutionId(null);
|
|
28182
|
+
}
|
|
28077
28183
|
};
|
|
28078
28184
|
window.addEventListener(AGENT_DRAWER_OPEN_EVENT, onOpen);
|
|
28079
28185
|
return () => {
|
|
28080
28186
|
window.removeEventListener(AGENT_DRAWER_OPEN_EVENT, onOpen);
|
|
28081
28187
|
};
|
|
28082
28188
|
}, [handleTabChange]);
|
|
28189
|
+
const handleAgentRun = (0, import_react34.useCallback)(
|
|
28190
|
+
(event) => {
|
|
28191
|
+
if (event.executionId && activeTaskId) {
|
|
28192
|
+
setActiveExecutionId(event.executionId);
|
|
28193
|
+
if (typeof window !== "undefined") {
|
|
28194
|
+
window.dispatchEvent(
|
|
28195
|
+
new CustomEvent("shuffle:task_ai_execution", {
|
|
28196
|
+
detail: {
|
|
28197
|
+
taskId: activeTaskId,
|
|
28198
|
+
executionId: event.executionId,
|
|
28199
|
+
status: event.success ? "running" : "failed"
|
|
28200
|
+
}
|
|
28201
|
+
})
|
|
28202
|
+
);
|
|
28203
|
+
}
|
|
28204
|
+
}
|
|
28205
|
+
},
|
|
28206
|
+
[activeTaskId]
|
|
28207
|
+
);
|
|
28208
|
+
const effectiveStorageKey = activeTaskId ? `${context.storageKey}:task:${activeTaskId}` : context.storageKey;
|
|
28209
|
+
const agentUiKey = activeTaskId ? `${context.storageKey}:task:${activeTaskId}:${activeExecutionId || "fresh"}:${runResetKey}` : `${context.storageKey}:${runResetKey}`;
|
|
28083
28210
|
const effectiveLocalLLMSlot = localLLMSlot ?? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
28084
28211
|
LocalLLMConfig_default,
|
|
28085
28212
|
{
|
|
@@ -28100,8 +28227,8 @@ var AskAiSidePanel = ({
|
|
|
28100
28227
|
return false;
|
|
28101
28228
|
});
|
|
28102
28229
|
const safeActiveTab = visibleTabs.includes(currentTab) ? currentTab : "run";
|
|
28103
|
-
const panelRef = (0,
|
|
28104
|
-
(0,
|
|
28230
|
+
const panelRef = (0, import_react34.useRef)(null);
|
|
28231
|
+
(0, import_react34.useEffect)(() => {
|
|
28105
28232
|
if (!isVisible || safeActiveTab !== "run") return;
|
|
28106
28233
|
const focusInput = () => {
|
|
28107
28234
|
if (!panelRef.current) return false;
|
|
@@ -28124,7 +28251,7 @@ var AskAiSidePanel = ({
|
|
|
28124
28251
|
clearTimeout(t3);
|
|
28125
28252
|
};
|
|
28126
28253
|
}, [isVisible, safeActiveTab]);
|
|
28127
|
-
const [panelWidth, setPanelWidth] = (0,
|
|
28254
|
+
const [panelWidth, setPanelWidth] = (0, import_react34.useState)(() => {
|
|
28128
28255
|
if (typeof window === "undefined") return width || 380;
|
|
28129
28256
|
try {
|
|
28130
28257
|
const stored = localStorage.getItem(ASK_AI_PANEL_WIDTH_STORAGE_KEY);
|
|
@@ -28138,15 +28265,15 @@ var AskAiSidePanel = ({
|
|
|
28138
28265
|
}
|
|
28139
28266
|
return width || 380;
|
|
28140
28267
|
});
|
|
28141
|
-
const [isResizing, setIsResizing] = (0,
|
|
28142
|
-
const prevWidthPropRef = (0,
|
|
28143
|
-
(0,
|
|
28268
|
+
const [isResizing, setIsResizing] = (0, import_react34.useState)(false);
|
|
28269
|
+
const prevWidthPropRef = (0, import_react34.useRef)(width);
|
|
28270
|
+
(0, import_react34.useEffect)(() => {
|
|
28144
28271
|
if (width !== prevWidthPropRef.current) {
|
|
28145
28272
|
prevWidthPropRef.current = width;
|
|
28146
28273
|
setPanelWidth(width);
|
|
28147
28274
|
}
|
|
28148
28275
|
}, [width]);
|
|
28149
|
-
const handleResizeStart = (0,
|
|
28276
|
+
const handleResizeStart = (0, import_react34.useCallback)((e) => {
|
|
28150
28277
|
e.preventDefault();
|
|
28151
28278
|
e.stopPropagation();
|
|
28152
28279
|
setIsResizing(true);
|
|
@@ -28180,7 +28307,7 @@ var AskAiSidePanel = ({
|
|
|
28180
28307
|
window.addEventListener("mousemove", handleMouseMove);
|
|
28181
28308
|
window.addEventListener("mouseup", handleMouseUp);
|
|
28182
28309
|
}, [panelWidth]);
|
|
28183
|
-
const handleTouchResizeStart = (0,
|
|
28310
|
+
const handleTouchResizeStart = (0, import_react34.useCallback)((e) => {
|
|
28184
28311
|
if (e.touches.length !== 1) return;
|
|
28185
28312
|
setIsResizing(true);
|
|
28186
28313
|
const startX = e.touches[0].clientX;
|
|
@@ -28217,7 +28344,7 @@ var AskAiSidePanel = ({
|
|
|
28217
28344
|
}, [panelWidth]);
|
|
28218
28345
|
const effectiveWidth = safeActiveTab === "localLLM" ? Math.max(panelWidth, 520) : panelWidth;
|
|
28219
28346
|
const effectiveSideshift = sideshift !== void 0 ? sideshift : context.sideshift ?? true;
|
|
28220
|
-
(0,
|
|
28347
|
+
(0, import_react34.useEffect)(() => {
|
|
28221
28348
|
if (typeof document === "undefined") return;
|
|
28222
28349
|
if (open && !isAgentDisabled && effectiveSideshift) {
|
|
28223
28350
|
document.documentElement.style.setProperty(
|
|
@@ -28231,7 +28358,7 @@ var AskAiSidePanel = ({
|
|
|
28231
28358
|
document.documentElement.style.setProperty("--ask-ai-panel-width", "0px");
|
|
28232
28359
|
};
|
|
28233
28360
|
}, [open, isAgentDisabled, effectiveWidth, effectiveSideshift]);
|
|
28234
|
-
const handleAppsChange = (0,
|
|
28361
|
+
const handleAppsChange = (0, import_react34.useCallback)(
|
|
28235
28362
|
(nextApps) => {
|
|
28236
28363
|
setPageContextChoice(context.storageKey, {
|
|
28237
28364
|
apps: nextApps.map((a) => ({ name: a.name, id: a.id, icon: a.icon }))
|
|
@@ -28240,7 +28367,7 @@ var AskAiSidePanel = ({
|
|
|
28240
28367
|
},
|
|
28241
28368
|
[context.storageKey, agentUIProps]
|
|
28242
28369
|
);
|
|
28243
|
-
const handleSelectPreset = (0,
|
|
28370
|
+
const handleSelectPreset = (0, import_react34.useCallback)(
|
|
28244
28371
|
(preset) => {
|
|
28245
28372
|
setPageContextChoice(context.storageKey, {
|
|
28246
28373
|
presetId: preset?.id ?? null
|
|
@@ -28385,11 +28512,11 @@ var AskAiSidePanel = ({
|
|
|
28385
28512
|
px: 0.75,
|
|
28386
28513
|
py: 0.2,
|
|
28387
28514
|
borderRadius: "4px",
|
|
28388
|
-
bgcolor:
|
|
28389
|
-
color:
|
|
28390
|
-
border:
|
|
28515
|
+
bgcolor: isBetaRoute ? "hsla(var(--primary) / 0.12)" : "hsl(var(--muted))",
|
|
28516
|
+
color: isBetaRoute ? "hsl(var(--primary))" : "hsl(var(--muted-foreground))",
|
|
28517
|
+
border: isBetaRoute ? "1px solid hsla(var(--primary) / 0.26)" : "1px solid hsl(var(--border))"
|
|
28391
28518
|
},
|
|
28392
|
-
children:
|
|
28519
|
+
children: isBetaRoute ? "Beta" : isLoggedIn ? isSupport ? "Support" : "Agent" : "Guest"
|
|
28393
28520
|
}
|
|
28394
28521
|
)
|
|
28395
28522
|
] }),
|
|
@@ -28647,14 +28774,16 @@ var AskAiSidePanel = ({
|
|
|
28647
28774
|
display: "flex",
|
|
28648
28775
|
flexDirection: "column"
|
|
28649
28776
|
},
|
|
28650
|
-
children: /* @__PURE__ */ (0,
|
|
28777
|
+
children: /* @__PURE__ */ (0, import_react35.createElement)(
|
|
28651
28778
|
AgentUI_default,
|
|
28652
28779
|
{
|
|
28780
|
+
...agentUIProps,
|
|
28781
|
+
key: agentUiKey,
|
|
28653
28782
|
sidebarLayout: true,
|
|
28654
28783
|
compact: true,
|
|
28655
28784
|
mobileView: true,
|
|
28656
28785
|
hideHeroIcon: true,
|
|
28657
|
-
title: displayTitle,
|
|
28786
|
+
title: activeTaskId ? "Task AI Agent" : displayTitle,
|
|
28658
28787
|
subtitle: null,
|
|
28659
28788
|
hideChooseLLM: !isLoggedIn,
|
|
28660
28789
|
isLoggedIn,
|
|
@@ -28665,16 +28794,19 @@ var AskAiSidePanel = ({
|
|
|
28665
28794
|
initialPresetId: context.presetId,
|
|
28666
28795
|
placeholder: context.placeholder,
|
|
28667
28796
|
contextCategory: context.sourceCategory,
|
|
28668
|
-
contextStorageKey:
|
|
28797
|
+
contextStorageKey: effectiveStorageKey,
|
|
28669
28798
|
contextParams: context.params,
|
|
28670
28799
|
composeSubmitInput: context.composeInput,
|
|
28671
28800
|
defaultInput: effectiveDefaultInput,
|
|
28801
|
+
autoSubmit: effectiveAutoSubmit,
|
|
28802
|
+
executionId: activeExecutionId || void 0,
|
|
28803
|
+
initialExecution: activeExecutionId ? { execution_id: activeExecutionId } : void 0,
|
|
28804
|
+
onRun: handleAgentRun,
|
|
28672
28805
|
onAppsChange: handleAppsChange,
|
|
28673
28806
|
onSelectPreset: handleSelectPreset,
|
|
28674
28807
|
onChooseLLM: () => handleTabChange("localLLM"),
|
|
28675
28808
|
apiBaseUrl: globalUrl || agentUIProps?.apiBaseUrl,
|
|
28676
28809
|
theme: effectiveTheme,
|
|
28677
|
-
...agentUIProps,
|
|
28678
28810
|
sx: {
|
|
28679
28811
|
flex: 1,
|
|
28680
28812
|
height: "100%",
|
|
@@ -28685,8 +28817,7 @@ var AskAiSidePanel = ({
|
|
|
28685
28817
|
pb: 0,
|
|
28686
28818
|
...agentUIProps?.sx ? Array.isArray(agentUIProps.sx) ? {} : agentUIProps.sx : {}
|
|
28687
28819
|
}
|
|
28688
|
-
}
|
|
28689
|
-
context.storageKey
|
|
28820
|
+
}
|
|
28690
28821
|
)
|
|
28691
28822
|
}
|
|
28692
28823
|
)
|
|
@@ -28699,7 +28830,7 @@ var AskAiSidePanel = ({
|
|
|
28699
28830
|
var AskAiSidePanel_default = AskAiSidePanel;
|
|
28700
28831
|
|
|
28701
28832
|
// components/AskAiWidget.tsx
|
|
28702
|
-
var
|
|
28833
|
+
var import_react36 = require("react");
|
|
28703
28834
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
28704
28835
|
var AGENT_DRAWER_OPEN_EVENT2 = "agent-drawer-open";
|
|
28705
28836
|
var AskAiWidget = ({
|
|
@@ -28719,11 +28850,11 @@ var AskAiWidget = ({
|
|
|
28719
28850
|
localLLMSlot,
|
|
28720
28851
|
...panelProps
|
|
28721
28852
|
}) => {
|
|
28722
|
-
const [internalOpen, setInternalOpen] = (0,
|
|
28723
|
-
const [activeTab, setActiveTab] = (0,
|
|
28853
|
+
const [internalOpen, setInternalOpen] = (0, import_react36.useState)(false);
|
|
28854
|
+
const [activeTab, setActiveTab] = (0, import_react36.useState)(propInitialTab);
|
|
28724
28855
|
const isDrawerOpen = controlledOpen !== void 0 ? controlledOpen : internalOpen;
|
|
28725
|
-
const [browserLocation, setBrowserLocation] = (0,
|
|
28726
|
-
(0,
|
|
28856
|
+
const [browserLocation, setBrowserLocation] = (0, import_react36.useState)({ path: "", search: "" });
|
|
28857
|
+
(0, import_react36.useEffect)(() => {
|
|
28727
28858
|
if (pathname !== void 0 && search !== void 0) return;
|
|
28728
28859
|
const syncLocation = () => setBrowserLocation({
|
|
28729
28860
|
path: window.location.pathname,
|
|
@@ -28735,7 +28866,7 @@ var AskAiWidget = ({
|
|
|
28735
28866
|
}, [pathname, search]);
|
|
28736
28867
|
const currentPath = pathname ?? browserLocation.path;
|
|
28737
28868
|
const isAgentDisabled = isAgentRoute(currentPath);
|
|
28738
|
-
const setDrawerOpen = (0,
|
|
28869
|
+
const setDrawerOpen = (0, import_react36.useCallback)(
|
|
28739
28870
|
(nextOpen) => {
|
|
28740
28871
|
if (isAgentDisabled && nextOpen) return;
|
|
28741
28872
|
if (controlledOpen === void 0) {
|
|
@@ -28745,25 +28876,25 @@ var AskAiWidget = ({
|
|
|
28745
28876
|
},
|
|
28746
28877
|
[controlledOpen, isAgentDisabled, onOpenChange]
|
|
28747
28878
|
);
|
|
28748
|
-
(0,
|
|
28879
|
+
(0, import_react36.useEffect)(() => {
|
|
28749
28880
|
if (isAgentDisabled && isDrawerOpen) {
|
|
28750
28881
|
setDrawerOpen(false);
|
|
28751
28882
|
}
|
|
28752
28883
|
}, [isAgentDisabled, isDrawerOpen, setDrawerOpen]);
|
|
28753
28884
|
const currentSearch = search ?? browserLocation.search;
|
|
28754
|
-
const resolvedContext = (0,
|
|
28885
|
+
const resolvedContext = (0, import_react36.useMemo)(() => {
|
|
28755
28886
|
return resolveAgentContext(currentPath, currentSearch, rules);
|
|
28756
28887
|
}, [currentPath, currentSearch, rules]);
|
|
28757
|
-
const [reportedContext, setReportedContext] = (0,
|
|
28888
|
+
const [reportedContext, setReportedContext] = (0, import_react36.useState)(null);
|
|
28758
28889
|
const activeContext = reportedContext && reportedContext.path === currentPath && reportedContext.search === currentSearch ? reportedContext.ctx : resolvedContext;
|
|
28759
|
-
const handleContextResolved = (0,
|
|
28890
|
+
const handleContextResolved = (0, import_react36.useCallback)(
|
|
28760
28891
|
(ctx) => {
|
|
28761
28892
|
setReportedContext({ path: currentPath, search: currentSearch, ctx });
|
|
28762
28893
|
onContextResolved?.(ctx);
|
|
28763
28894
|
},
|
|
28764
28895
|
[currentPath, currentSearch, onContextResolved]
|
|
28765
28896
|
);
|
|
28766
|
-
(0,
|
|
28897
|
+
(0, import_react36.useEffect)(() => {
|
|
28767
28898
|
const handleDrawerOpenEvent = (e) => {
|
|
28768
28899
|
if (isAgentDisabled) return;
|
|
28769
28900
|
const detail = e.detail;
|
|
@@ -28775,17 +28906,18 @@ var AskAiWidget = ({
|
|
|
28775
28906
|
window.addEventListener(AGENT_DRAWER_OPEN_EVENT2, handleDrawerOpenEvent);
|
|
28776
28907
|
return () => window.removeEventListener(AGENT_DRAWER_OPEN_EVENT2, handleDrawerOpenEvent);
|
|
28777
28908
|
}, [isAgentDisabled, setDrawerOpen]);
|
|
28778
|
-
(0,
|
|
28909
|
+
(0, import_react36.useEffect)(() => {
|
|
28779
28910
|
if (propInitialTab) {
|
|
28780
28911
|
setActiveTab(propInitialTab);
|
|
28781
28912
|
}
|
|
28782
28913
|
}, [propInitialTab]);
|
|
28783
28914
|
const effectiveButtonLabel = buttonProps?.label || (activeContext.buttonLabelFn ? activeContext.buttonLabelFn() : activeContext.buttonLabel) || "Ask AI";
|
|
28784
|
-
const
|
|
28915
|
+
const isIncidentOrDocsRoute = currentPath.startsWith("/incidents") || currentPath.startsWith("/incidents-simple") || currentPath.startsWith("/cases") || currentPath.startsWith("/alerts") || currentPath.startsWith("/tickets") || currentPath.startsWith("/docs");
|
|
28916
|
+
const isBeta = activeContext.isBeta === true || isIncidentOrDocsRoute;
|
|
28785
28917
|
const effectiveRequireSupport = isBeta ? false : requireSupport;
|
|
28786
28918
|
const defaultTag = isBeta ? "Beta" : "Support";
|
|
28787
28919
|
const effectiveTagLabel = buttonProps?.tagLabel !== void 0 ? buttonProps.tagLabel : defaultTag;
|
|
28788
|
-
(0,
|
|
28920
|
+
(0, import_react36.useEffect)(() => {
|
|
28789
28921
|
if (effectiveRequireSupport && !isSupport && isDrawerOpen) {
|
|
28790
28922
|
setDrawerOpen(false);
|
|
28791
28923
|
}
|
|
@@ -28845,10 +28977,10 @@ var AskAiWidget = ({
|
|
|
28845
28977
|
] });
|
|
28846
28978
|
};
|
|
28847
28979
|
var useContextAwareAgent = (pathname, search) => {
|
|
28848
|
-
const [activeContext, setActiveContext] = (0,
|
|
28980
|
+
const [activeContext, setActiveContext] = (0, import_react36.useState)(
|
|
28849
28981
|
() => resolveAgentContext(pathname ?? "/", search ?? "")
|
|
28850
28982
|
);
|
|
28851
|
-
(0,
|
|
28983
|
+
(0, import_react36.useEffect)(() => {
|
|
28852
28984
|
const p = pathname ?? (typeof window !== "undefined" ? window.location.pathname : "/");
|
|
28853
28985
|
const s = search ?? (typeof window !== "undefined" ? window.location.search : "");
|
|
28854
28986
|
setActiveContext(resolveAgentContext(p, s));
|
|
@@ -28858,7 +28990,7 @@ var useContextAwareAgent = (pathname, search) => {
|
|
|
28858
28990
|
var AskAiWidget_default = AskAiWidget;
|
|
28859
28991
|
|
|
28860
28992
|
// components/AgentPromptPrefixChip.tsx
|
|
28861
|
-
var
|
|
28993
|
+
var import_react37 = require("react");
|
|
28862
28994
|
var import_material37 = require("@mui/material");
|
|
28863
28995
|
var import_lucide_react23 = require("lucide-react");
|
|
28864
28996
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
@@ -28876,9 +29008,9 @@ var AgentPromptPrefixChip = ({
|
|
|
28876
29008
|
const managed = useAgentPromptPrefix({ userId, defaultPrompt, persist: !controlled });
|
|
28877
29009
|
const prompt = controlled ? value : managed.prompt;
|
|
28878
29010
|
const isSaving = controlled ? false : managed.isSaving;
|
|
28879
|
-
const [open, setOpen] = (0,
|
|
28880
|
-
const [draft, setDraft] = (0,
|
|
28881
|
-
(0,
|
|
29011
|
+
const [open, setOpen] = (0, import_react37.useState)(false);
|
|
29012
|
+
const [draft, setDraft] = (0, import_react37.useState)(prompt);
|
|
29013
|
+
(0, import_react37.useEffect)(() => {
|
|
28882
29014
|
if (!open) setDraft(prompt);
|
|
28883
29015
|
}, [prompt, open]);
|
|
28884
29016
|
const handleOpen = () => {
|
|
@@ -29886,14 +30018,14 @@ var DEMO_AGENT_RUNS = [
|
|
|
29886
30018
|
];
|
|
29887
30019
|
|
|
29888
30020
|
// useAppLookup.ts
|
|
29889
|
-
var
|
|
30021
|
+
var import_react38 = require("react");
|
|
29890
30022
|
init_api();
|
|
29891
30023
|
init_appsCache();
|
|
29892
30024
|
var norm3 = (s) => s.toLowerCase().replace(/[\s_\-]+/g, "_");
|
|
29893
30025
|
function useAppLookup(appName) {
|
|
29894
|
-
const [loading, setLoading] = (0,
|
|
29895
|
-
const [info, setInfo] = (0,
|
|
29896
|
-
const [algoliaId, setAlgoliaId] = (0,
|
|
30026
|
+
const [loading, setLoading] = (0, import_react38.useState)(false);
|
|
30027
|
+
const [info, setInfo] = (0, import_react38.useState)(null);
|
|
30028
|
+
const [algoliaId, setAlgoliaId] = (0, import_react38.useState)(null);
|
|
29897
30029
|
const {
|
|
29898
30030
|
authStates,
|
|
29899
30031
|
authenticatedApps,
|
|
@@ -29902,7 +30034,7 @@ function useAppLookup(appName) {
|
|
|
29902
30034
|
handleSaveAuth,
|
|
29903
30035
|
refreshAuth
|
|
29904
30036
|
} = useAppAuth();
|
|
29905
|
-
(0,
|
|
30037
|
+
(0, import_react38.useEffect)(() => {
|
|
29906
30038
|
if (!appName) {
|
|
29907
30039
|
setInfo(null);
|
|
29908
30040
|
setAlgoliaId(null);
|
|
@@ -29973,13 +30105,13 @@ function useAppLookup(appName) {
|
|
|
29973
30105
|
setLoading(false);
|
|
29974
30106
|
})();
|
|
29975
30107
|
}, [appName]);
|
|
29976
|
-
const matchingEntries = (0,
|
|
30108
|
+
const matchingEntries = (0, import_react38.useMemo)(() => {
|
|
29977
30109
|
if (!appName) return [];
|
|
29978
30110
|
return authenticatedApps.filter(
|
|
29979
30111
|
(auth) => auth.app?.name && norm3(auth.app.name) === norm3(appName)
|
|
29980
30112
|
);
|
|
29981
30113
|
}, [appName, authenticatedApps]);
|
|
29982
|
-
const image = (0,
|
|
30114
|
+
const image = (0, import_react38.useMemo)(() => {
|
|
29983
30115
|
if (info?.image) return info.image;
|
|
29984
30116
|
for (const entry of matchingEntries) {
|
|
29985
30117
|
const img = entry.app?.large_image || entry.large_image;
|
|
@@ -29987,7 +30119,7 @@ function useAppLookup(appName) {
|
|
|
29987
30119
|
}
|
|
29988
30120
|
return "";
|
|
29989
30121
|
}, [info, matchingEntries]);
|
|
29990
|
-
const algoliaApp = (0,
|
|
30122
|
+
const algoliaApp = (0, import_react38.useMemo)(() => {
|
|
29991
30123
|
if (!appName) return null;
|
|
29992
30124
|
return {
|
|
29993
30125
|
objectID: algoliaId || appName,
|
|
@@ -30029,20 +30161,20 @@ var resolveMode = (theme, colorMode) => {
|
|
|
30029
30161
|
return "auto";
|
|
30030
30162
|
};
|
|
30031
30163
|
var withMcpTheme = (Inner, displayName2) => {
|
|
30032
|
-
const Wrapped = ({ theme, colorMode, ...rest }) =>
|
|
30164
|
+
const Wrapped = ({ theme, colorMode, ...rest }) => import_react39.default.createElement(
|
|
30033
30165
|
ShuffleMcpThemeProvider,
|
|
30034
30166
|
{ mode: resolveMode(theme, colorMode) },
|
|
30035
|
-
|
|
30167
|
+
import_react39.default.createElement(Inner, { ...rest, theme, colorMode })
|
|
30036
30168
|
);
|
|
30037
30169
|
Wrapped.displayName = `ShuffleMCPs(${displayName2})`;
|
|
30038
30170
|
return Wrapped;
|
|
30039
30171
|
};
|
|
30040
30172
|
var withMcpThemeRef = (Inner, displayName2) => {
|
|
30041
|
-
const Wrapped =
|
|
30042
|
-
({ theme, colorMode, ...rest }, ref) =>
|
|
30173
|
+
const Wrapped = import_react39.default.forwardRef(
|
|
30174
|
+
({ theme, colorMode, ...rest }, ref) => import_react39.default.createElement(
|
|
30043
30175
|
ShuffleMcpThemeProvider,
|
|
30044
30176
|
{ mode: resolveMode(theme, colorMode) },
|
|
30045
|
-
|
|
30177
|
+
import_react39.default.createElement(Inner, { ...rest, theme, colorMode, ref })
|
|
30046
30178
|
)
|
|
30047
30179
|
);
|
|
30048
30180
|
Wrapped.displayName = `ShuffleMCPs(${displayName2})`;
|