@smartspace/chat-ui 1.14.4-dev.b35149c → 1.14.4-dev.df9addb
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.css +1 -1
- package/dist/index.d.ts +78 -134
- package/dist/index.js +96 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import MuiButton from '@mui/material/Button';
|
|
2
2
|
import IconButton2 from '@mui/material/IconButton';
|
|
3
|
-
import { Loader2, ChevronDown, Check, Cpu, SlidersHorizontal, X, Globe, Zap, Square, Mic, Paperclip, Send, Minimize2, AlertTriangle, FileImage, FileVideo, FileAudio, FileArchive, FileCode, FileSpreadsheet, Presentation, FileText, ChevronUp, ExternalLink, Download, ShieldAlert, Copy } from 'lucide-react';
|
|
3
|
+
import { Loader2, ChevronDown, Check, Cpu, SlidersHorizontal, X, Globe, Zap, Square, Mic, Paperclip, Send, Minimize2, AlertTriangle, FileImage, FileVideo, FileAudio, FileArchive, FileCode, FileSpreadsheet, Presentation, FileText, ChevronRight, ChevronUp, ExternalLink, Download, ShieldAlert, Copy } from 'lucide-react';
|
|
4
4
|
import * as React9 from 'react';
|
|
5
|
-
import React9__default, { createContext, forwardRef, useImperativeHandle, useRef, useState, useEffect, useMemo, useCallback, useContext, useSyncExternalStore } from 'react';
|
|
5
|
+
import React9__default, { createContext, forwardRef, useImperativeHandle, useRef, useState, useEffect, useMemo, useCallback, useContext, useSyncExternalStore, Fragment as Fragment$1 } from 'react';
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
8
|
import { useQuery, queryOptions, useQueryClient, useMutation } from '@tanstack/react-query';
|
|
@@ -19626,7 +19626,14 @@ var ERROR_CODE_TEXT = {
|
|
|
19626
19626
|
"llm.content_policy": "\u26A0\uFE0F **The response was blocked by a content filter**\n\nPlease rephrase your request.",
|
|
19627
19627
|
"llm.schema_validation": "\u26A0\uFE0F **The model returned an invalid response**\n\nPlease try again.",
|
|
19628
19628
|
"llm.unsupported_modality": "\u26A0\uFE0F **This model can't read images**\n\nSwitch to a vision-capable model, or remove the attachment and describe it instead.",
|
|
19629
|
-
"llm.unknown": GENERIC_ERROR_TEXT
|
|
19629
|
+
"llm.unknown": GENERIC_ERROR_TEXT,
|
|
19630
|
+
// Managed secrets. A secret's failure arrives as a 404 or 400, which the
|
|
19631
|
+
// status table below would read as a missing model or a generic error.
|
|
19632
|
+
"secret.user_value_not_set": "\u26A0\uFE0F **Your own key for this isn't set**\n\nThis step uses a credential each person sets for themselves, and none is set for you yet. Ask an administrator to add it.",
|
|
19633
|
+
"secret.run_has_no_user": "\u26A0\uFE0F **This step needs a signed-in user**\n\nIt uses a person's own credential, so it can't run when no one started the run.",
|
|
19634
|
+
"secret.user_mismatch": "\u26A0\uFE0F **A credential couldn't be loaded**\n\nAn administrator needs to check this flow's secrets.",
|
|
19635
|
+
"secret.run_required": "\u26A0\uFE0F **A credential couldn't be loaded**\n\nAn administrator needs to check this flow's secrets.",
|
|
19636
|
+
MS404: "\u26A0\uFE0F **A secret this flow uses doesn't exist**\n\nAn administrator needs to add it, or point the flow at another one."
|
|
19630
19637
|
};
|
|
19631
19638
|
var STATUS_CODE_TEXT = {
|
|
19632
19639
|
408: ERROR_CODE_TEXT["llm.timeout"],
|
|
@@ -19648,6 +19655,34 @@ var getMessageErrorText = (error) => {
|
|
|
19648
19655
|
}
|
|
19649
19656
|
return STATUS_CODE_TEXT[error.code] ?? GENERIC_ERROR_TEXT;
|
|
19650
19657
|
};
|
|
19658
|
+
function extractProviderErrorDetail(raw2) {
|
|
19659
|
+
const start = raw2.indexOf("{");
|
|
19660
|
+
if (start === -1) return null;
|
|
19661
|
+
let parsed;
|
|
19662
|
+
try {
|
|
19663
|
+
parsed = JSON.parse(raw2.slice(start));
|
|
19664
|
+
} catch {
|
|
19665
|
+
return null;
|
|
19666
|
+
}
|
|
19667
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
19668
|
+
const record = parsed;
|
|
19669
|
+
const inner = typeof record.error === "object" && record.error !== null ? record.error : record;
|
|
19670
|
+
if (typeof inner.message !== "string") return null;
|
|
19671
|
+
return {
|
|
19672
|
+
message: inner.message,
|
|
19673
|
+
param: typeof inner.param === "string" ? inner.param : void 0
|
|
19674
|
+
};
|
|
19675
|
+
}
|
|
19676
|
+
var getMessageErrorDetail = (error) => {
|
|
19677
|
+
if (typeof error === "number" || !error.message) {
|
|
19678
|
+
return null;
|
|
19679
|
+
}
|
|
19680
|
+
const detail = extractProviderErrorDetail(error.message);
|
|
19681
|
+
if (!detail) {
|
|
19682
|
+
return error.message;
|
|
19683
|
+
}
|
|
19684
|
+
return detail.param ? `${detail.message} (param: ${detail.param})` : detail.message;
|
|
19685
|
+
};
|
|
19651
19686
|
var FileInfoSchema = z.object({
|
|
19652
19687
|
id: z.string(),
|
|
19653
19688
|
name: z.string()
|
|
@@ -19691,7 +19726,8 @@ var MessageErrorMessageSchema = z.object({
|
|
|
19691
19726
|
error_code: z.string().nullish(),
|
|
19692
19727
|
message: z.string().nullish(),
|
|
19693
19728
|
data: z.string().nullish(),
|
|
19694
|
-
blockId: z.string().nullish()
|
|
19729
|
+
blockId: z.string().nullish(),
|
|
19730
|
+
traceId: z.string().nullish()
|
|
19695
19731
|
});
|
|
19696
19732
|
var MessageSchema = z.object({
|
|
19697
19733
|
id: z.string().nullish(),
|
|
@@ -20539,6 +20575,34 @@ var MessageBubble = (props) => {
|
|
|
20539
20575
|
/* @__PURE__ */ jsx("div", { className: "mt-1.5", children: metaRow })
|
|
20540
20576
|
] });
|
|
20541
20577
|
};
|
|
20578
|
+
function MessageErrorDetails({
|
|
20579
|
+
detail,
|
|
20580
|
+
traceId
|
|
20581
|
+
}) {
|
|
20582
|
+
const [expanded, setExpanded] = useState(false);
|
|
20583
|
+
return /* @__PURE__ */ jsxs("div", { className: "mt-1", children: [
|
|
20584
|
+
/* @__PURE__ */ jsxs(
|
|
20585
|
+
"button",
|
|
20586
|
+
{
|
|
20587
|
+
type: "button",
|
|
20588
|
+
onClick: () => setExpanded((prev) => !prev),
|
|
20589
|
+
"aria-expanded": expanded,
|
|
20590
|
+
className: "m-0 inline-flex w-auto cursor-pointer appearance-none items-center gap-1 border-0 bg-transparent p-0 text-[11px] font-medium leading-none text-muted-foreground hover:text-foreground",
|
|
20591
|
+
children: [
|
|
20592
|
+
expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3 shrink-0" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 shrink-0" }),
|
|
20593
|
+
expanded ? "Hide details" : "Show details"
|
|
20594
|
+
]
|
|
20595
|
+
}
|
|
20596
|
+
),
|
|
20597
|
+
expanded && /* @__PURE__ */ jsxs("div", { className: "mt-1.5 whitespace-pre-wrap break-words rounded-md bg-secondary/60 p-2 font-mono text-[11px] leading-relaxed text-muted-foreground", children: [
|
|
20598
|
+
detail,
|
|
20599
|
+
traceId && /* @__PURE__ */ jsxs("div", { className: detail ? "mt-1.5" : void 0, children: [
|
|
20600
|
+
"Reference: ",
|
|
20601
|
+
traceId
|
|
20602
|
+
] })
|
|
20603
|
+
] })
|
|
20604
|
+
] });
|
|
20605
|
+
}
|
|
20542
20606
|
var ThinkingSection = ({ status }) => /* @__PURE__ */ jsxs(
|
|
20543
20607
|
"div",
|
|
20544
20608
|
{
|
|
@@ -20826,22 +20890,26 @@ var MessageItem = ({
|
|
|
20826
20890
|
);
|
|
20827
20891
|
}
|
|
20828
20892
|
(message.errors ?? []).forEach((error, errorIndex) => {
|
|
20893
|
+
const key = `error-${message.id ?? "msg"}-${errorIndex}-${error.errorCode ?? error.code}`;
|
|
20894
|
+
const detail = getMessageErrorDetail(error);
|
|
20829
20895
|
bubbles.push(
|
|
20830
|
-
/* @__PURE__ */
|
|
20831
|
-
|
|
20832
|
-
|
|
20833
|
-
|
|
20834
|
-
|
|
20835
|
-
|
|
20836
|
-
|
|
20837
|
-
|
|
20838
|
-
|
|
20839
|
-
|
|
20840
|
-
|
|
20841
|
-
|
|
20842
|
-
|
|
20843
|
-
|
|
20844
|
-
|
|
20896
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
20897
|
+
/* @__PURE__ */ jsx(
|
|
20898
|
+
MessageBubble,
|
|
20899
|
+
{
|
|
20900
|
+
createdBy: chatbotName,
|
|
20901
|
+
createdAt: message.createdAt,
|
|
20902
|
+
type: "Output" /* OUTPUT */,
|
|
20903
|
+
content: [{ text: getMessageErrorText(error) }],
|
|
20904
|
+
files: [],
|
|
20905
|
+
sources: [],
|
|
20906
|
+
chatbotName,
|
|
20907
|
+
userOutput: null,
|
|
20908
|
+
userInput: null
|
|
20909
|
+
}
|
|
20910
|
+
),
|
|
20911
|
+
(detail || error.traceId) && /* @__PURE__ */ jsx(MessageErrorDetails, { detail, traceId: error.traceId })
|
|
20912
|
+
] }, key)
|
|
20845
20913
|
);
|
|
20846
20914
|
});
|
|
20847
20915
|
return bubbles;
|
|
@@ -21096,6 +21164,11 @@ function MessageListSkeleton() {
|
|
|
21096
21164
|
i
|
|
21097
21165
|
)) });
|
|
21098
21166
|
}
|
|
21167
|
+
|
|
21168
|
+
// src/shared/utils/enums.ts
|
|
21169
|
+
var isMember = (e, value) => Object.values(e).includes(value);
|
|
21170
|
+
|
|
21171
|
+
// src/domains/messages/mapper.ts
|
|
21099
21172
|
var {
|
|
21100
21173
|
messageThreadsThreadMessagesIdMessagesResponse: messagesResponseSchema
|
|
21101
21174
|
} = ChatZod;
|
|
@@ -21122,6 +21195,7 @@ function mapMessageValueDtoToModel(dto) {
|
|
|
21122
21195
|
createdByUserId: dto.createdByUserId ?? void 0
|
|
21123
21196
|
};
|
|
21124
21197
|
}
|
|
21198
|
+
var mapMessageValuesDtoToModels = (dtos) => dtos.filter((dto) => isMember(MessageValueType, dto.type)).map(mapMessageValueDtoToModel);
|
|
21125
21199
|
function mapMessageErrorDtoToModel(dto) {
|
|
21126
21200
|
const { error_code, ...rest } = dto;
|
|
21127
21201
|
return {
|
|
@@ -21139,7 +21213,7 @@ function mapMessageDtoToModel(dto) {
|
|
|
21139
21213
|
createdByUserId: dto.createdByUserId ?? void 0,
|
|
21140
21214
|
messageThreadId: dto.messageThreadId ?? void 0,
|
|
21141
21215
|
errors: dto.errors?.map(mapMessageErrorDtoToModel) ?? void 0,
|
|
21142
|
-
values: dto.values
|
|
21216
|
+
values: dto.values && mapMessageValuesDtoToModels(dto.values)
|
|
21143
21217
|
};
|
|
21144
21218
|
}
|
|
21145
21219
|
function mapMessagesDtoToModels(dto) {
|
|
@@ -21255,8 +21329,7 @@ var mapWorkspacesDtoToModels = (arr) => arr.map(mapWorkspaceDtoToModel);
|
|
|
21255
21329
|
function getChatApiBaseUrl() {
|
|
21256
21330
|
try {
|
|
21257
21331
|
const w = window;
|
|
21258
|
-
const
|
|
21259
|
-
const cfg = w?.ssconfig?.Chat_Api_Uri ?? env2?.VITE_CHAT_API_URI;
|
|
21332
|
+
const cfg = w?.ssconfig?.Chat_Api_Uri;
|
|
21260
21333
|
return typeof cfg === "string" && cfg.trim() ? cfg.trim() : "";
|
|
21261
21334
|
} catch {
|
|
21262
21335
|
return "";
|
|
@@ -21269,6 +21342,6 @@ function getUserPhotoUrl(userId) {
|
|
|
21269
21342
|
return `${base2}/users/${userId}/photo`;
|
|
21270
21343
|
}
|
|
21271
21344
|
|
|
21272
|
-
export { ChatProvider, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, DictationButton, MarkdownEditor, MessageComposer, MessageList, MessageListSkeleton, MessageMarkdown, MessageValueType, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getMessageErrorText, getModelIcon, getRetryStatusText, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, parseRetryStatus, randomUUID, setThreadOptimisticRunning, setThreadRunningInLists, speechKeys, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDictation, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useIsDraftThreadId, useMessages, useModels, useSendMessage, useSpeechConfig, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
|
|
21345
|
+
export { ChatProvider, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, DictationButton, MarkdownEditor, MessageComposer, MessageList, MessageListSkeleton, MessageMarkdown, MessageValueType, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getMessageErrorDetail, getMessageErrorText, getModelIcon, getRetryStatusText, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessageValuesDtoToModels, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, parseRetryStatus, randomUUID, setThreadOptimisticRunning, setThreadRunningInLists, speechKeys, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDictation, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useIsDraftThreadId, useMessages, useModels, useSendMessage, useSpeechConfig, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
|
|
21273
21346
|
//# sourceMappingURL=index.js.map
|
|
21274
21347
|
//# sourceMappingURL=index.js.map
|