@smartspace/chat-ui 1.14.4-dev.f08c0a0 → 1.14.4-dev.fc4bb49
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 +76 -134
- package/dist/index.js +84 -20
- 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()
|
|
@@ -20539,6 +20574,25 @@ var MessageBubble = (props) => {
|
|
|
20539
20574
|
/* @__PURE__ */ jsx("div", { className: "mt-1.5", children: metaRow })
|
|
20540
20575
|
] });
|
|
20541
20576
|
};
|
|
20577
|
+
function MessageErrorDetails({ detail }) {
|
|
20578
|
+
const [expanded, setExpanded] = useState(false);
|
|
20579
|
+
return /* @__PURE__ */ jsxs("div", { className: "mt-1", children: [
|
|
20580
|
+
/* @__PURE__ */ jsxs(
|
|
20581
|
+
"button",
|
|
20582
|
+
{
|
|
20583
|
+
type: "button",
|
|
20584
|
+
onClick: () => setExpanded((prev) => !prev),
|
|
20585
|
+
"aria-expanded": expanded,
|
|
20586
|
+
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",
|
|
20587
|
+
children: [
|
|
20588
|
+
expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3 shrink-0" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 shrink-0" }),
|
|
20589
|
+
expanded ? "Hide details" : "Show details"
|
|
20590
|
+
]
|
|
20591
|
+
}
|
|
20592
|
+
),
|
|
20593
|
+
expanded && /* @__PURE__ */ jsx("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: detail })
|
|
20594
|
+
] });
|
|
20595
|
+
}
|
|
20542
20596
|
var ThinkingSection = ({ status }) => /* @__PURE__ */ jsxs(
|
|
20543
20597
|
"div",
|
|
20544
20598
|
{
|
|
@@ -20826,22 +20880,26 @@ var MessageItem = ({
|
|
|
20826
20880
|
);
|
|
20827
20881
|
}
|
|
20828
20882
|
(message.errors ?? []).forEach((error, errorIndex) => {
|
|
20883
|
+
const key = `error-${message.id ?? "msg"}-${errorIndex}-${error.errorCode ?? error.code}`;
|
|
20884
|
+
const detail = getMessageErrorDetail(error);
|
|
20829
20885
|
bubbles.push(
|
|
20830
|
-
/* @__PURE__ */
|
|
20831
|
-
|
|
20832
|
-
|
|
20833
|
-
|
|
20834
|
-
|
|
20835
|
-
|
|
20836
|
-
|
|
20837
|
-
|
|
20838
|
-
|
|
20839
|
-
|
|
20840
|
-
|
|
20841
|
-
|
|
20842
|
-
|
|
20843
|
-
|
|
20844
|
-
|
|
20886
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
20887
|
+
/* @__PURE__ */ jsx(
|
|
20888
|
+
MessageBubble,
|
|
20889
|
+
{
|
|
20890
|
+
createdBy: chatbotName,
|
|
20891
|
+
createdAt: message.createdAt,
|
|
20892
|
+
type: "Output" /* OUTPUT */,
|
|
20893
|
+
content: [{ text: getMessageErrorText(error) }],
|
|
20894
|
+
files: [],
|
|
20895
|
+
sources: [],
|
|
20896
|
+
chatbotName,
|
|
20897
|
+
userOutput: null,
|
|
20898
|
+
userInput: null
|
|
20899
|
+
}
|
|
20900
|
+
),
|
|
20901
|
+
detail && /* @__PURE__ */ jsx(MessageErrorDetails, { detail })
|
|
20902
|
+
] }, key)
|
|
20845
20903
|
);
|
|
20846
20904
|
});
|
|
20847
20905
|
return bubbles;
|
|
@@ -21096,6 +21154,11 @@ function MessageListSkeleton() {
|
|
|
21096
21154
|
i
|
|
21097
21155
|
)) });
|
|
21098
21156
|
}
|
|
21157
|
+
|
|
21158
|
+
// src/shared/utils/enums.ts
|
|
21159
|
+
var isMember = (e, value) => Object.values(e).includes(value);
|
|
21160
|
+
|
|
21161
|
+
// src/domains/messages/mapper.ts
|
|
21099
21162
|
var {
|
|
21100
21163
|
messageThreadsThreadMessagesIdMessagesResponse: messagesResponseSchema
|
|
21101
21164
|
} = ChatZod;
|
|
@@ -21122,6 +21185,7 @@ function mapMessageValueDtoToModel(dto) {
|
|
|
21122
21185
|
createdByUserId: dto.createdByUserId ?? void 0
|
|
21123
21186
|
};
|
|
21124
21187
|
}
|
|
21188
|
+
var mapMessageValuesDtoToModels = (dtos) => dtos.filter((dto) => isMember(MessageValueType, dto.type)).map(mapMessageValueDtoToModel);
|
|
21125
21189
|
function mapMessageErrorDtoToModel(dto) {
|
|
21126
21190
|
const { error_code, ...rest } = dto;
|
|
21127
21191
|
return {
|
|
@@ -21139,7 +21203,7 @@ function mapMessageDtoToModel(dto) {
|
|
|
21139
21203
|
createdByUserId: dto.createdByUserId ?? void 0,
|
|
21140
21204
|
messageThreadId: dto.messageThreadId ?? void 0,
|
|
21141
21205
|
errors: dto.errors?.map(mapMessageErrorDtoToModel) ?? void 0,
|
|
21142
|
-
values: dto.values
|
|
21206
|
+
values: dto.values && mapMessageValuesDtoToModels(dto.values)
|
|
21143
21207
|
};
|
|
21144
21208
|
}
|
|
21145
21209
|
function mapMessagesDtoToModels(dto) {
|
|
@@ -21269,6 +21333,6 @@ function getUserPhotoUrl(userId) {
|
|
|
21269
21333
|
return `${base2}/users/${userId}/photo`;
|
|
21270
21334
|
}
|
|
21271
21335
|
|
|
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 };
|
|
21336
|
+
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
21337
|
//# sourceMappingURL=index.js.map
|
|
21274
21338
|
//# sourceMappingURL=index.js.map
|