@iblai/web-utils 1.7.1 → 1.7.3
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/data-layer/src/features/chat/constants.d.ts +8 -0
- package/dist/data-layer/src/features/chat/custom-api-slice.d.ts +272 -0
- package/dist/data-layer/src/features/credentials/api-slice.d.ts +3 -15
- package/dist/data-layer/src/features/credentials/custom-api-slice.d.ts +127 -105
- package/dist/data-layer/src/features/credentials/types.d.ts +9 -0
- package/dist/data-layer/src/features/periodic-agents/api-slice.d.ts +82 -390
- package/dist/data-layer/src/index.d.ts +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.esm.js +53 -27
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +53 -27
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/web-utils/src/hooks/chat/use-chat-v2.d.ts +6 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './features/api-keys/api-slice';
|
|
2
2
|
export * from './features/chat-history/api-slice';
|
|
3
3
|
export * from './features/chat/api-slice';
|
|
4
|
+
export * from './features/chat/custom-api-slice';
|
|
4
5
|
export * from './features/chat-files/api-slice';
|
|
5
6
|
export * from './features/chat-files/types';
|
|
6
7
|
export * from './features/llms/api-slice';
|
package/dist/index.d.ts
CHANGED
|
@@ -511,6 +511,12 @@ interface ArtifactVersion {
|
|
|
511
511
|
created_by?: string;
|
|
512
512
|
change_summary?: string;
|
|
513
513
|
}
|
|
514
|
+
interface RawMessageFromWS {
|
|
515
|
+
id: string;
|
|
516
|
+
is_ai: boolean;
|
|
517
|
+
is_human: boolean;
|
|
518
|
+
generation_id: string;
|
|
519
|
+
}
|
|
514
520
|
interface Message$1 {
|
|
515
521
|
id: string;
|
|
516
522
|
role: "user" | "assistant" | "system";
|
|
@@ -2342,4 +2348,4 @@ declare const WithPermissions: ({ rbacResource, rbacPermissions, children, }: Wi
|
|
|
2342
2348
|
declare const checkRbacPermission: (rbacPermissions: object, rbacResource: string, enableRBAC?: boolean) => boolean;
|
|
2343
2349
|
|
|
2344
2350
|
export { ALPHANUMERIC_32_REGEX, ANONYMOUS_USERNAME, AuthContext, AuthContextProvider, AuthProvider, CHAT_AREA_SIZE, CacheKeys, DEFAULT_DISCLAIMER_CONTENT, LOCAL_STORAGE_KEYS, MAX_INITIAL_WEBSOCKET_CONNECTION_ATTEMPTS, MENTOR_CHAT_DOCUMENTS_EXTENSIONS, MENTOR_VISIBILITY, MENTOR_VISIBILITY_VALUES, METADATAS, MentorProvider, REQUIRED_ACTIONS_FOR_GROUPS, RemoteEvents, STREAMING_CONTENT_BUFFER_THRESHOLD, STREAMING_CONTENT_FLUSH_INTERVAL, SUBSCRIPTION_MESSAGES, SUBSCRIPTION_PACKAGES, SUBSCRIPTION_PACKAGES_V2, SUBSCRIPTION_TRIGGERS, SUBSCRIPTION_V2_TRIGGERS, ServiceWorkerProvider, SubscriptionFlow, SubscriptionFlowV2, TOOLS, TenantContext, TenantContextProvider, TenantProvider, TimeTracker, WithFormPermissions, WithPermissions, addFiles, addMessage, addProtocolToUrl, advancedTabs, advancedTabsProperties, appleRestrictionReducer, appleRestrictionSlice, chatActions, chatInputSlice, chatInputSliceActions, chatInputSliceReducer, chatInputSliceSelectors, chatSliceReducerShared, checkModelAvailable, checkOllamaHealth, checkRbacPermission, clearAllCaches, clearApiCache, clearAuthCookies, clearCookies, clearCurrentTenantCookie, clearFiles, clearMessages, combineCSVData, convertToOllamaMessages, createFileReference, createMultipleFileReferences, csvDataToText, defaultSessionIds, deleteCookie, deleteCookieOnAllDomains, enableChatActionsPopup, eventBus, fetchWithCache, filesReducer, filesSlice, formatRelativeTime, getAuthSpaJoinUrl, getCacheStatus, getCachedApiResponse, getCookieValue, getDomainParts, getFileInfo, getInitials, getLocalLLMSystemPrompt, getNextNavigation, getParentDomain, getPlatform, getPlatformKey, getServiceWorkerStatus, getStoredUserName, getTimeAgo, getUserEmail, getUserName, handleLogout, hostChatReducer, hostChatSlice, initServiceWorker, isAlphaNumeric32, isExpo, isFileAccepted, isInIframe, isJSON, isLoggedIn, isNode, isReactNative, isSafariBrowser, isServiceWorkerSupported, isStripeActivated, isTauri, isTauriOfflineMode, isWeb, loadMetadataConfig, markdownToPlainText, monetizationSlice, onStatusChange, onUpdate, parseCSV, preCacheMentorData, rbacReducer, redirectToAuthSpa, redirectToAuthSpaJoinTenant, registerServiceWorker, removeFile, requestPresignedUrl, safeRequire, selectActiveChatMessages, selectActiveTab, selectArtifactsEnabled, selectAttachedFiles, selectChats, selectCurrentStreamingArtifact, selectCurrentStreamingMessage, selectDocumentFilter, selectEnableChatActionsPopup, selectIframeContext, selectIsError, selectIsPending, selectIsStopped, selectIsTyping, selectLastArtifactContentFlushTime, selectMetadata, selectNumberOfActiveChatMessages, selectRbacPermissions, selectSessionId, selectSessionIds, selectShouldStartNewChat, selectShowingSharedChat, selectStatus, selectStreaming, selectStreamingArtifactContentBuffer, selectStreamingArtifactFullContent, selectToken, selectTokenEnabled, selectTools, sendMessageToParentWebsite, setAccessCheckResponse, setAdvancedDisplayMonetizationCheckoutModal, setCachedApiResponse, setCookieForAuth, setDisplayMonetizationCheckoutModal, setError402Detected, setFreeTrialUsageOptions, setOfflineStatus, setOpenAppleRestrictionModal, setOpenPricingModal, setPricingModalData, setSubscriptionStatus, setTauriMode, setTopBannerOptions, setupNetworkListeners, showMonetizationCheckoutModal, skipWaiting, streamOllamaChat, subscriptionReducer, subscriptionSlice, syncAuthToCookies, tenantKeySchema, tenantSchema, topBannerReducer, topBannerSlice, translatePrompt, unregisterServiceWorker, updateFileMetadata, updateFileProgress, updateFileRetryCount, updateFileStatus, updateFileUrl, updateFileUrlFromWebSocket, updateRbacPermissions, uploadToS3, use402ErrorCheck, useAccessingPublicRoute, useAdvancedChat, useAuthContext, useAuthProvider, useAxdToken, useCachedSessionId, useChat, useChatFileUpload, useCurrentTenant, useDayJs, useDmToken, useEmbedMode, useEventCallback, useEventListener, useExternalPricingPlan, useFileDragDrop, useIsAdmin, useIsomorphicLayoutEffect, useLocalStorage, useMentorSettings, useMentorTools, useModelFileUploadCapabilities, useOS, useProfileImageUpload, useResponsive, useServiceWorker, useShowAttachment, useShowFreeTrialDialog, useShowVoiceCall, useShowVoiceRecorder, useStripeUpgrade, useSubscriptionHandler, useSubscriptionHandlerV2, useTenantContext, useTenantMetadata, useTimeTracker, useTimeTrackerNative, useTimer, useUserAgreement, useUserData, useUserProfileUpdate, useUserTenants, useUsername, useVisitingTenant, useVoiceChat, useWelcome as useWelcomeMessage, userDataSchema, validateFile };
|
|
2345
|
-
export type { AdvancedTab, AppleRestrictionState, ArtifactData, ArtifactPayload, ArtifactVersion, AttachedFile, AuthContextType, ChatInputState, ChatMode, ChatSliceState, ChatState, ChatStatus, CreateStripeCustomerPortalRequest, Error402MessageData, FileAttachment, FileInfo, FileProcessingEvent, FileReference, FileUploadCapabilities, FileUploadState, FilesState, HandleLogoutOptions, HostChatState, Message$1 as Message, MessageAction, MonetizationState, OAuthRequiredData, OAuthResolvedData, OllamaChatRequest, OllamaChatStreamResponse, OllamaMessage, OllamaStreamCallbacks, PricingModalData$1 as PricingModalData, PricingTablePayload, Prompt, RbacPermissions, RbacState, RedirectToAuthSpaOptions, SendMessageOptions, ServiceWorkerStatus, SessionIds, StreamingArtifact, StreamingMessage, StripeUpgradePlan, SubscriptionFlowConfig, SubscriptionFlowConfigV2, SubscriptionState, Tenant, TenantContextType, TenantKeyMentorIdParams, TenantMetadata, TimeTrackerConfig, TimeTrackerState, TopBannerOptions, TopBannerState, TopTrialBannerProps, UploadProgressCallback, UseChatProps, UseChatReturn, UseExternalPricingProps, UseProfileImageUploadOptions, UseProfileImageUploadReturn, UseTimeTrackerConfig, UseTimeTrackerNativeConfig, UseTimeTrackerNativeReturn, UseTimeTrackerReturn, UseUserProfileUpdateResult, UserProfileUpdateData };
|
|
2351
|
+
export type { AdvancedTab, AppleRestrictionState, ArtifactData, ArtifactPayload, ArtifactVersion, AttachedFile, AuthContextType, ChatInputState, ChatMode, ChatSliceState, ChatState, ChatStatus, CreateStripeCustomerPortalRequest, Error402MessageData, FileAttachment, FileInfo, FileProcessingEvent, FileReference, FileUploadCapabilities, FileUploadState, FilesState, HandleLogoutOptions, HostChatState, Message$1 as Message, MessageAction, MonetizationState, OAuthRequiredData, OAuthResolvedData, OllamaChatRequest, OllamaChatStreamResponse, OllamaMessage, OllamaStreamCallbacks, PricingModalData$1 as PricingModalData, PricingTablePayload, Prompt, RawMessageFromWS, RbacPermissions, RbacState, RedirectToAuthSpaOptions, SendMessageOptions, ServiceWorkerStatus, SessionIds, StreamingArtifact, StreamingMessage, StripeUpgradePlan, SubscriptionFlowConfig, SubscriptionFlowConfigV2, SubscriptionState, Tenant, TenantContextType, TenantKeyMentorIdParams, TenantMetadata, TimeTrackerConfig, TimeTrackerState, TopBannerOptions, TopBannerState, TopTrialBannerProps, UploadProgressCallback, UseChatProps, UseChatReturn, UseExternalPricingProps, UseProfileImageUploadOptions, UseProfileImageUploadReturn, UseTimeTrackerConfig, UseTimeTrackerNativeConfig, UseTimeTrackerNativeReturn, UseTimeTrackerReturn, UseUserProfileUpdateResult, UserProfileUpdateData };
|
package/dist/index.esm.js
CHANGED
|
@@ -9864,9 +9864,8 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
|
|
|
9864
9864
|
}
|
|
9865
9865
|
}
|
|
9866
9866
|
async function handleLoadTenantMetadata(tenantKey) {
|
|
9867
|
-
var _a
|
|
9867
|
+
var _a;
|
|
9868
9868
|
setIsLoading(true);
|
|
9869
|
-
const MAIN_TENANT_KEY = "main";
|
|
9870
9869
|
try {
|
|
9871
9870
|
const data = await fetchTenantMetadata([
|
|
9872
9871
|
{
|
|
@@ -9891,18 +9890,6 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
|
|
|
9891
9890
|
const { data: tenants } = await fetchUserTenants();
|
|
9892
9891
|
const enhancedTenants = await enhanceTenants(tenants, data);
|
|
9893
9892
|
saveUserTenants(enhancedTenants);
|
|
9894
|
-
// If we're in an advertising tenant and user has other tenants,
|
|
9895
|
-
// switch to a non-advertising, non-main tenant
|
|
9896
|
-
const isCurrentTenantAdvertising = ((_b = data.metadata) === null || _b === void 0 ? void 0 : _b.is_advertising) || isAdvertisingTenant;
|
|
9897
|
-
if (isCurrentTenantAdvertising &&
|
|
9898
|
-
enhancedTenants &&
|
|
9899
|
-
enhancedTenants.length > 0) {
|
|
9900
|
-
const nonAdvertisingTenant = enhancedTenants.find((t) => !t.is_advertising && t.key !== MAIN_TENANT_KEY);
|
|
9901
|
-
if (nonAdvertisingTenant) {
|
|
9902
|
-
handleTenantSwitch(nonAdvertisingTenant.key, false, false);
|
|
9903
|
-
return;
|
|
9904
|
-
}
|
|
9905
|
-
}
|
|
9906
9893
|
if (currentTenant && currentTenant !== tenantKey) {
|
|
9907
9894
|
setTenantKey(data.platform_key);
|
|
9908
9895
|
const userAlreadyInTenant = enhancedTenants === null || enhancedTenants === void 0 ? void 0 : enhancedTenants.find((t) => t.key === tenantKey);
|
|
@@ -11099,6 +11086,30 @@ const chatSlice = createSlice({
|
|
|
11099
11086
|
resetCurrentStreamingMessage: (state) => {
|
|
11100
11087
|
state.currentStreamingMessage = { id: "", content: "" };
|
|
11101
11088
|
},
|
|
11089
|
+
updateStreamingMessageId: (state, action) => {
|
|
11090
|
+
const oldId = state.currentStreamingMessage.id;
|
|
11091
|
+
const { newId } = action.payload;
|
|
11092
|
+
if (!newId || oldId === newId) {
|
|
11093
|
+
return;
|
|
11094
|
+
}
|
|
11095
|
+
if (oldId) {
|
|
11096
|
+
const activeMessages = state.chats[state.activeTab];
|
|
11097
|
+
if (activeMessages === null || activeMessages === void 0 ? void 0 : activeMessages.length) {
|
|
11098
|
+
const lastIndex = activeMessages.length - 1;
|
|
11099
|
+
const last = activeMessages[lastIndex];
|
|
11100
|
+
if (last.id === oldId) {
|
|
11101
|
+
state.chats = {
|
|
11102
|
+
...state.chats,
|
|
11103
|
+
[state.activeTab]: [
|
|
11104
|
+
...activeMessages.slice(0, lastIndex),
|
|
11105
|
+
{ ...last, id: newId },
|
|
11106
|
+
],
|
|
11107
|
+
};
|
|
11108
|
+
}
|
|
11109
|
+
}
|
|
11110
|
+
}
|
|
11111
|
+
state.currentStreamingMessage.id = newId;
|
|
11112
|
+
},
|
|
11102
11113
|
setActiveTab: (state, action) => {
|
|
11103
11114
|
state.activeTab = action.payload;
|
|
11104
11115
|
},
|
|
@@ -12368,7 +12379,7 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
12368
12379
|
onStreamingChange === null || onStreamingChange === void 0 ? void 0 : onStreamingChange(false);
|
|
12369
12380
|
});
|
|
12370
12381
|
socket.addEventListener("message", (event) => {
|
|
12371
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
12382
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
|
|
12372
12383
|
if (isWebSocketPaused.current) {
|
|
12373
12384
|
console.log("[ws-message] Message received but WebSocket is paused");
|
|
12374
12385
|
return;
|
|
@@ -12941,8 +12952,23 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
12941
12952
|
onStreamingChange(true);
|
|
12942
12953
|
return;
|
|
12943
12954
|
}
|
|
12955
|
+
//HANDLE RECEPTION OF CHAT MESSAGES INFO
|
|
12956
|
+
if ((messageData === null || messageData === void 0 ? void 0 : messageData.type) === "chat_messages" &&
|
|
12957
|
+
((_t = messageData === null || messageData === void 0 ? void 0 : messageData.messages) === null || _t === void 0 ? void 0 : _t.length) > 0) {
|
|
12958
|
+
const chatMessageID = (_v = (_u = messageData === null || messageData === void 0 ? void 0 : messageData.messages) === null || _u === void 0 ? void 0 : _u.find((pre) => pre.is_ai)) === null || _v === void 0 ? void 0 : _v.id;
|
|
12959
|
+
if (chatMessageID) {
|
|
12960
|
+
dispatch(chatActions.updateStreamingMessageId({ newId: chatMessageID }));
|
|
12961
|
+
currentStreamingMessage.current = {
|
|
12962
|
+
...currentStreamingMessage.current,
|
|
12963
|
+
id: chatMessageID,
|
|
12964
|
+
};
|
|
12965
|
+
onStreamingMessageUpdate === null || onStreamingMessageUpdate === void 0 ? void 0 : onStreamingMessageUpdate(currentStreamingMessage.current);
|
|
12966
|
+
return;
|
|
12967
|
+
}
|
|
12968
|
+
}
|
|
12944
12969
|
// Handle streaming message content (chat text)
|
|
12945
|
-
if (messageData
|
|
12970
|
+
if ((messageData === null || messageData === void 0 ? void 0 : messageData.type) !== "chat_messages" &&
|
|
12971
|
+
(messageData.data !== undefined || messageData.eos !== undefined)) {
|
|
12946
12972
|
const messageText = messageData.data || "";
|
|
12947
12973
|
// If we have content to add, update the in-memory streaming message and Redux
|
|
12948
12974
|
if (messageText && currentStreamingMessage.current) {
|
|
@@ -12958,28 +12984,28 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
12958
12984
|
};
|
|
12959
12985
|
onStreamingMessageUpdate === null || onStreamingMessageUpdate === void 0 ? void 0 : onStreamingMessageUpdate(currentStreamingMessage.current);
|
|
12960
12986
|
// Update or add message in Redux store
|
|
12961
|
-
if ((
|
|
12987
|
+
if ((_w = currentStreamingMessage.current) === null || _w === void 0 ? void 0 : _w.id) {
|
|
12962
12988
|
// TODO: Investigate why `appendMessageToActiveTab` is consuming this action payload
|
|
12963
12989
|
dispatch(chatActions.appendMessageToActiveTab(undefined));
|
|
12964
12990
|
}
|
|
12965
12991
|
}
|
|
12966
|
-
// Handle end of stream
|
|
12967
12992
|
if (messageData.eos) {
|
|
12993
|
+
// Handle end of stream
|
|
12968
12994
|
const hasPendingArtifact = !!pendingArtifactVersion.current;
|
|
12969
|
-
const hasMessageContent = !!((
|
|
12995
|
+
const hasMessageContent = !!((_x = currentStreamingMessage.current) === null || _x === void 0 ? void 0 : _x.content) &&
|
|
12970
12996
|
currentStreamingMessage.current.content.length > 0;
|
|
12971
12997
|
console.log("[ws-message] End of stream (EOS) received:", {
|
|
12972
|
-
generationId: (
|
|
12973
|
-
finalContentLength: (
|
|
12974
|
-
hasContent: !!((
|
|
12998
|
+
generationId: (_y = currentStreamingMessage.current) === null || _y === void 0 ? void 0 : _y.id,
|
|
12999
|
+
finalContentLength: (_0 = (_z = currentStreamingMessage.current) === null || _z === void 0 ? void 0 : _z.content) === null || _0 === void 0 ? void 0 : _0.length,
|
|
13000
|
+
hasContent: !!((_1 = currentStreamingMessage.current) === null || _1 === void 0 ? void 0 : _1.content),
|
|
12975
13001
|
hasPendingArtifact,
|
|
12976
13002
|
});
|
|
12977
13003
|
// Final update to Redux store with complete message
|
|
12978
|
-
if (((
|
|
13004
|
+
if (((_2 = currentStreamingMessage.current) === null || _2 === void 0 ? void 0 : _2.id) &&
|
|
12979
13005
|
(hasMessageContent || hasPendingArtifact)) {
|
|
12980
13006
|
console.log("[ws-message] Is currentStreamingMessage.current", {
|
|
12981
|
-
id: (
|
|
12982
|
-
content: (
|
|
13007
|
+
id: (_3 = currentStreamingMessage.current) === null || _3 === void 0 ? void 0 : _3.id,
|
|
13008
|
+
content: (_4 = currentStreamingMessage.current) === null || _4 === void 0 ? void 0 : _4.content,
|
|
12983
13009
|
});
|
|
12984
13010
|
// TODO: Investigate why `appendMessageToActiveTab` is consuming this action payload
|
|
12985
13011
|
dispatch(chatActions.appendMessageToActiveTab(undefined));
|
|
@@ -13034,7 +13060,7 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
13034
13060
|
onStatusChange("error");
|
|
13035
13061
|
}
|
|
13036
13062
|
});
|
|
13037
|
-
socket.addEventListener("error", (
|
|
13063
|
+
socket.addEventListener("error", () => {
|
|
13038
13064
|
// Don't show error if we're offline in Tauri - this is expected
|
|
13039
13065
|
// Check both the ref AND navigator.onLine (the ref may not be updated yet)
|
|
13040
13066
|
const isLikelyOffline = isOfflineRef.current || (isTauriApp() && !navigator.onLine);
|
|
@@ -13703,7 +13729,7 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
|
|
|
13703
13729
|
...result,
|
|
13704
13730
|
role: result.type === "human" ? "user" : "assistant",
|
|
13705
13731
|
visible: true,
|
|
13706
|
-
id: new Date().getTime(),
|
|
13732
|
+
id: result.id || new Date().getTime(),
|
|
13707
13733
|
content: typeof result.content === "object" &&
|
|
13708
13734
|
result.content.length > 0
|
|
13709
13735
|
? (_c = result.content.find((item) => item.text)) === null || _c === void 0 ? void 0 : _c.text
|