@smartspace/chat-ui 1.14.4-dev.7129fda → 1.14.4-dev.7569a58
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.d.ts +58 -15
- package/dist/index.js +182 -85
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -319,6 +319,8 @@ type Message = {
|
|
|
319
319
|
message?: string | null;
|
|
320
320
|
data?: string | null;
|
|
321
321
|
blockId?: string | null;
|
|
322
|
+
/** Trace id of the request that recorded the error, for a support reference. */
|
|
323
|
+
traceId?: string | null;
|
|
322
324
|
}[] | null;
|
|
323
325
|
values?: MessageValue[] | null;
|
|
324
326
|
optimistic?: boolean;
|
|
@@ -449,7 +451,6 @@ interface ChatService {
|
|
|
449
451
|
uploadFiles(files: File[], scope: FileScope, onFileUploaded?: (file: File, fileInfo: FileInfo$1) => void, onChunkUploaded?: (chunkIndex: number, totalChunks: number, file: File) => void): Promise<FileInfo$1[]>;
|
|
450
452
|
downloadFile(id: string, scope?: FileScope): Promise<Blob>;
|
|
451
453
|
getFileInfo(id: string, scope: FileScope): Promise<FileInfo$1>;
|
|
452
|
-
getFileDownloadUrl(sourceUri: string): Promise<string>;
|
|
453
454
|
fetchThread(workspaceId: string, threadId: string): Promise<MessageThread>;
|
|
454
455
|
fetchWorkspace(workspaceId: string): Promise<Workspace>;
|
|
455
456
|
fetchTaggableUsers(workspaceId: string): Promise<MentionUser[]>;
|
|
@@ -546,6 +547,7 @@ declare const messagesResponseSchema: z.ZodObject<{
|
|
|
546
547
|
data: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
|
|
547
548
|
errorCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
548
549
|
message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
550
|
+
traceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
549
551
|
}, z.core.$strip>>;
|
|
550
552
|
hasComments: z.ZodBoolean;
|
|
551
553
|
id: z.ZodString;
|
|
@@ -596,7 +598,7 @@ declare function applyDeltaToMessage(target: Message, delta: {
|
|
|
596
598
|
/**
|
|
597
599
|
* User-facing text for message errors.
|
|
598
600
|
*
|
|
599
|
-
* The backend attaches a stable machine-readable category to
|
|
601
|
+
* The backend attaches a stable machine-readable category to failures
|
|
600
602
|
* (`errorCode`, e.g. "llm.rate_limit") alongside the numeric HTTP `code`.
|
|
601
603
|
* Prefer the category — it distinguishes causes the HTTP code can't (a 400
|
|
602
604
|
* can be a content filter, a context-window blowout, or a malformed
|
|
@@ -865,10 +867,34 @@ declare const workspaceResponseSchema: z.ZodObject<{
|
|
|
865
867
|
modelDeploymentProviderType: z.ZodOptional<z.ZodString>;
|
|
866
868
|
modelPublisher: z.ZodOptional<z.ZodString>;
|
|
867
869
|
name: z.ZodString;
|
|
868
|
-
properties: z.ZodArray<z.ZodObject<{
|
|
870
|
+
properties: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
871
|
+
defaultValue: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
872
|
+
maxValue: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
873
|
+
minValue: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
869
874
|
name: z.ZodString;
|
|
870
|
-
|
|
871
|
-
|
|
875
|
+
step: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
876
|
+
type: z.ZodEnum<{
|
|
877
|
+
Boolean: "Boolean";
|
|
878
|
+
}>;
|
|
879
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
880
|
+
defaultValue: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
881
|
+
maxValue: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
882
|
+
minValue: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
883
|
+
name: z.ZodString;
|
|
884
|
+
step: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
885
|
+
type: z.ZodEnum<{
|
|
886
|
+
Number: "Number";
|
|
887
|
+
}>;
|
|
888
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
889
|
+
defaultValue: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
890
|
+
maxValue: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
891
|
+
minValue: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
892
|
+
name: z.ZodString;
|
|
893
|
+
step: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
894
|
+
type: z.ZodEnum<{
|
|
895
|
+
String: "String";
|
|
896
|
+
}>;
|
|
897
|
+
}, z.core.$strip>]>>;
|
|
872
898
|
}, z.core.$strip>;
|
|
873
899
|
prePrompt: z.ZodString;
|
|
874
900
|
presencePenalty: z.ZodNumber;
|
|
@@ -1051,10 +1077,34 @@ declare const workspacesListResponseSchema: z.ZodObject<{
|
|
|
1051
1077
|
modelDeploymentProviderType: z.ZodOptional<z.ZodString>;
|
|
1052
1078
|
modelPublisher: z.ZodOptional<z.ZodString>;
|
|
1053
1079
|
name: z.ZodString;
|
|
1054
|
-
properties: z.ZodArray<z.ZodObject<{
|
|
1080
|
+
properties: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
1081
|
+
defaultValue: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
1082
|
+
maxValue: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
1083
|
+
minValue: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
1055
1084
|
name: z.ZodString;
|
|
1056
|
-
|
|
1057
|
-
|
|
1085
|
+
step: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
1086
|
+
type: z.ZodEnum<{
|
|
1087
|
+
Boolean: "Boolean";
|
|
1088
|
+
}>;
|
|
1089
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1090
|
+
defaultValue: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1091
|
+
maxValue: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1092
|
+
minValue: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1093
|
+
name: z.ZodString;
|
|
1094
|
+
step: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1095
|
+
type: z.ZodEnum<{
|
|
1096
|
+
Number: "Number";
|
|
1097
|
+
}>;
|
|
1098
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1099
|
+
defaultValue: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1100
|
+
maxValue: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1101
|
+
minValue: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1102
|
+
name: z.ZodString;
|
|
1103
|
+
step: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1104
|
+
type: z.ZodEnum<{
|
|
1105
|
+
String: "String";
|
|
1106
|
+
}>;
|
|
1107
|
+
}, z.core.$strip>]>>;
|
|
1058
1108
|
}, z.core.$strip>;
|
|
1059
1109
|
prePrompt: z.ZodString;
|
|
1060
1110
|
presencePenalty: z.ZodNumber;
|
|
@@ -1205,9 +1255,6 @@ declare const filesKeys: {
|
|
|
1205
1255
|
downloadBlob: (fileId: string) => readonly ["files", "mutation", "downloadBlob", {
|
|
1206
1256
|
readonly fileId: string;
|
|
1207
1257
|
}];
|
|
1208
|
-
downloadByUri: (uri: string) => readonly ["files", "mutation", "downloadByUri", {
|
|
1209
|
-
readonly uri: string;
|
|
1210
|
-
}];
|
|
1211
1258
|
};
|
|
1212
1259
|
};
|
|
1213
1260
|
|
|
@@ -1303,10 +1350,6 @@ declare function useMessages(threadId: string): _tanstack_react_query.UseQueryRe
|
|
|
1303
1350
|
declare const useFileMutations: (scope: FileScope) => {
|
|
1304
1351
|
uploadFilesMutation: _tanstack_react_query.UseMutationResult<FileInfo$1[], Error, File[], unknown>;
|
|
1305
1352
|
downloadFileMutation: _tanstack_react_query.UseMutationResult<void, Error, FileInfo$1, unknown>;
|
|
1306
|
-
downloadFileByUriMutation: _tanstack_react_query.UseMutationResult<Blob, Error, {
|
|
1307
|
-
name: string;
|
|
1308
|
-
sourceUri: string;
|
|
1309
|
-
}, unknown>;
|
|
1310
1353
|
getFileBlobUrl: (id: string) => Promise<string>;
|
|
1311
1354
|
fileProgress: Record<string, number>;
|
|
1312
1355
|
uploadedFiles: FileInfo$1[];
|
package/dist/index.js
CHANGED
|
@@ -47,15 +47,15 @@ import vertexaiIcon from '@lobehub/icons-static-svg/icons/vertexai-color.svg';
|
|
|
47
47
|
import xaiIcon from '@lobehub/icons-static-svg/icons/xai.svg';
|
|
48
48
|
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
49
49
|
import ReactMarkdown, { defaultUrlTransform } from 'react-markdown';
|
|
50
|
-
import
|
|
50
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
51
|
+
import { cva } from 'class-variance-authority';
|
|
51
52
|
import { clsx } from 'clsx';
|
|
52
53
|
import { twMerge } from 'tailwind-merge';
|
|
54
|
+
import MuiSkeleton from '@mui/material/Skeleton';
|
|
53
55
|
import dayjs from 'dayjs';
|
|
54
56
|
import advancedFormat from 'dayjs/plugin/advancedFormat';
|
|
55
57
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
56
58
|
import utc from 'dayjs/plugin/utc';
|
|
57
|
-
import { Slot } from '@radix-ui/react-slot';
|
|
58
|
-
import { cva } from 'class-variance-authority';
|
|
59
59
|
import { useTheme, Box, Skeleton as Skeleton$1 } from '@mui/material';
|
|
60
60
|
|
|
61
61
|
var __defProp = Object.defineProperty;
|
|
@@ -115,8 +115,7 @@ var filesKeys = {
|
|
|
115
115
|
mutation: {
|
|
116
116
|
upload: (scope) => [...filesKeys.mutations(), "upload", { scope }],
|
|
117
117
|
download: (fileId) => [...filesKeys.mutations(), "download", { fileId }],
|
|
118
|
-
downloadBlob: (fileId) => [...filesKeys.mutations(), "downloadBlob", { fileId }]
|
|
119
|
-
downloadByUri: (uri) => [...filesKeys.mutations(), "downloadByUri", { uri }]
|
|
118
|
+
downloadBlob: (fileId) => [...filesKeys.mutations(), "downloadBlob", { fileId }]
|
|
120
119
|
}
|
|
121
120
|
};
|
|
122
121
|
|
|
@@ -163,20 +162,6 @@ var useFileMutations = (scope) => {
|
|
|
163
162
|
},
|
|
164
163
|
onError: () => toast.error("Failed to download file")
|
|
165
164
|
});
|
|
166
|
-
const downloadFileByUriMutation = useMutation({
|
|
167
|
-
mutationFn: async ({
|
|
168
|
-
name,
|
|
169
|
-
sourceUri
|
|
170
|
-
}) => {
|
|
171
|
-
const uri = await service.getFileDownloadUrl(sourceUri);
|
|
172
|
-
if (!uri) throw new Error("No download URL");
|
|
173
|
-
const response = await fetch(uri);
|
|
174
|
-
const blob = await response.blob();
|
|
175
|
-
saveFile(blob, name);
|
|
176
|
-
return blob;
|
|
177
|
-
},
|
|
178
|
-
onError: () => toast.error("Failed to download file")
|
|
179
|
-
});
|
|
180
165
|
const fileStates = (files) => files.map((file) => ({
|
|
181
166
|
name: file.name,
|
|
182
167
|
progress: fileProgress[file.name] ?? 0,
|
|
@@ -200,7 +185,6 @@ var useFileMutations = (scope) => {
|
|
|
200
185
|
return {
|
|
201
186
|
uploadFilesMutation,
|
|
202
187
|
downloadFileMutation,
|
|
203
|
-
downloadFileByUriMutation,
|
|
204
188
|
getFileBlobUrl,
|
|
205
189
|
fileProgress,
|
|
206
190
|
uploadedFiles,
|
|
@@ -556,7 +540,10 @@ var threadDetailOptions = ({
|
|
|
556
540
|
queryKey: threadsKeys.detail(workspaceId, threadId),
|
|
557
541
|
queryFn: () => service.fetchThread(workspaceId, threadId),
|
|
558
542
|
refetchOnWindowFocus: false,
|
|
559
|
-
staleTime: 6e4
|
|
543
|
+
staleTime: 6e4,
|
|
544
|
+
// The route loader has just tried and failed. Retrying on mount delays
|
|
545
|
+
// the inline error by several seconds; the user has Try again.
|
|
546
|
+
retryOnMount: false
|
|
560
547
|
});
|
|
561
548
|
function getThreadPlaceholderFromListCache(queryClient, workspaceId, threadId) {
|
|
562
549
|
const entries = queryClient.getQueriesData({
|
|
@@ -2620,7 +2607,8 @@ function kickOff(fn) {
|
|
|
2620
2607
|
var isSupported = () => typeof window !== "undefined" && window.isSecureContext && !!navigator.mediaDevices?.getUserMedia;
|
|
2621
2608
|
function classifyTokenFailure(error) {
|
|
2622
2609
|
const code3 = error?.code;
|
|
2623
|
-
if (code3 === "
|
|
2610
|
+
if (code3 === "speech.identity_misconfigured" || code3 === "SP500")
|
|
2611
|
+
return "unavailable";
|
|
2624
2612
|
if (error?.type === "NotFound") {
|
|
2625
2613
|
return "unavailable";
|
|
2626
2614
|
}
|
|
@@ -4251,7 +4239,10 @@ var workspaceDetailOptions = ({
|
|
|
4251
4239
|
}) => queryOptions({
|
|
4252
4240
|
queryKey: workspaceKeys.byId(workspaceId),
|
|
4253
4241
|
queryFn: () => service.fetchWorkspace(workspaceId),
|
|
4254
|
-
staleTime: 3e4
|
|
4242
|
+
staleTime: 3e4,
|
|
4243
|
+
// The route loader has just tried and failed. Retrying on mount delays
|
|
4244
|
+
// the header's error by several seconds.
|
|
4245
|
+
retryOnMount: false
|
|
4255
4246
|
});
|
|
4256
4247
|
function useWorkspace(workspaceId) {
|
|
4257
4248
|
const service = useChatService();
|
|
@@ -4299,6 +4290,8 @@ function useMessageComposerVm(props = {}) {
|
|
|
4299
4290
|
const isRunning = useThreadIsRunning(workspaceId, threadId);
|
|
4300
4291
|
const isUploadingFiles = props.isUploadingFiles ?? false;
|
|
4301
4292
|
const sendMessage = useSendMessage();
|
|
4293
|
+
const currentThreadId = useRef(threadId);
|
|
4294
|
+
currentThreadId.current = threadId;
|
|
4302
4295
|
const sendDisabled = useMemo(() => {
|
|
4303
4296
|
const nothingToSend = !newMessage.trim() && !props.hasAttachments;
|
|
4304
4297
|
const flowBlocked = isRunning || sendMessage.isPending;
|
|
@@ -4310,18 +4303,27 @@ function useMessageComposerVm(props = {}) {
|
|
|
4310
4303
|
newMessage,
|
|
4311
4304
|
props.hasAttachments
|
|
4312
4305
|
]);
|
|
4313
|
-
const internalSend = (text6, files) => {
|
|
4306
|
+
const internalSend = (text6, files, onFailed) => {
|
|
4314
4307
|
if (!workspaceId || !threadId) return;
|
|
4315
4308
|
const trimmed = text6.trim();
|
|
4316
4309
|
const contentList = trimmed ? [{ text: trimmed, image: void 0 }] : void 0;
|
|
4317
4310
|
const vars = variables && Object.keys(variables).length > 0 ? variables : void 0;
|
|
4318
|
-
sendMessage.mutate(
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4311
|
+
sendMessage.mutate(
|
|
4312
|
+
{
|
|
4313
|
+
workspaceId,
|
|
4314
|
+
threadId,
|
|
4315
|
+
contentList,
|
|
4316
|
+
files,
|
|
4317
|
+
variables: vars
|
|
4318
|
+
},
|
|
4319
|
+
// The composer stays mounted across threads: a send that fails after
|
|
4320
|
+
// the user moved to another thread must not put its text in that one.
|
|
4321
|
+
{
|
|
4322
|
+
onError: () => {
|
|
4323
|
+
if (currentThreadId.current === threadId) onFailed?.();
|
|
4324
|
+
}
|
|
4325
|
+
}
|
|
4326
|
+
);
|
|
4325
4327
|
setNewMessage("");
|
|
4326
4328
|
};
|
|
4327
4329
|
const canSend = (text6, files) => {
|
|
@@ -4330,9 +4332,9 @@ function useMessageComposerVm(props = {}) {
|
|
|
4330
4332
|
const flowBlocked = isRunning || sendMessage.isPending;
|
|
4331
4333
|
return !(isUploadingFiles || flowBlocked || nothingToSend);
|
|
4332
4334
|
};
|
|
4333
|
-
const handleSendMessage = (text6, files) => {
|
|
4335
|
+
const handleSendMessage = (text6, files, onFailed) => {
|
|
4334
4336
|
if (!canSend(text6, files)) return false;
|
|
4335
|
-
internalSend(text6, files);
|
|
4337
|
+
internalSend(text6, files, onFailed);
|
|
4336
4338
|
return true;
|
|
4337
4339
|
};
|
|
4338
4340
|
return {
|
|
@@ -4616,7 +4618,16 @@ function MessageComposer(_props = {}) {
|
|
|
4616
4618
|
}, [editorKey]);
|
|
4617
4619
|
const handleSendMessageAndClear = () => {
|
|
4618
4620
|
const latestText = editorRef.current?.getMarkdown() ?? newMessage;
|
|
4619
|
-
const
|
|
4621
|
+
const restoreText = () => {
|
|
4622
|
+
if ((editorRef.current?.getMarkdown() ?? "").trim()) return;
|
|
4623
|
+
setNewMessage(latestText);
|
|
4624
|
+
setEditorKey((k) => k + 1);
|
|
4625
|
+
};
|
|
4626
|
+
const sent = handleSendMessage(
|
|
4627
|
+
latestText,
|
|
4628
|
+
uploadedAttachments,
|
|
4629
|
+
restoreText
|
|
4630
|
+
);
|
|
4620
4631
|
if (!sent) return;
|
|
4621
4632
|
stopDictation();
|
|
4622
4633
|
handleClearAttachments();
|
|
@@ -19598,6 +19609,45 @@ function MessageMarkdown({ value, className }) {
|
|
|
19598
19609
|
function cn(...inputs) {
|
|
19599
19610
|
return twMerge(clsx(inputs));
|
|
19600
19611
|
}
|
|
19612
|
+
var buttonVariants = cva(
|
|
19613
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
19614
|
+
{
|
|
19615
|
+
variants: {
|
|
19616
|
+
variant: {
|
|
19617
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
19618
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
19619
|
+
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
19620
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
19621
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
19622
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
19623
|
+
},
|
|
19624
|
+
size: {
|
|
19625
|
+
default: "h-10 px-4 py-2",
|
|
19626
|
+
sm: "h-9 rounded-md px-3",
|
|
19627
|
+
lg: "h-11 rounded-md px-8",
|
|
19628
|
+
icon: "h-10 w-10"
|
|
19629
|
+
}
|
|
19630
|
+
},
|
|
19631
|
+
defaultVariants: {
|
|
19632
|
+
variant: "default",
|
|
19633
|
+
size: "default"
|
|
19634
|
+
}
|
|
19635
|
+
}
|
|
19636
|
+
);
|
|
19637
|
+
var Button = React9.forwardRef(
|
|
19638
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
19639
|
+
const Comp = asChild ? Slot : "button";
|
|
19640
|
+
return /* @__PURE__ */ jsx(
|
|
19641
|
+
Comp,
|
|
19642
|
+
{
|
|
19643
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
19644
|
+
ref,
|
|
19645
|
+
...props
|
|
19646
|
+
}
|
|
19647
|
+
);
|
|
19648
|
+
}
|
|
19649
|
+
);
|
|
19650
|
+
Button.displayName = "Button";
|
|
19601
19651
|
function Skeleton({ className, ...props }) {
|
|
19602
19652
|
return /* @__PURE__ */ jsx(
|
|
19603
19653
|
MuiSkeleton,
|
|
@@ -19626,7 +19676,23 @@ var ERROR_CODE_TEXT = {
|
|
|
19626
19676
|
"llm.content_policy": "\u26A0\uFE0F **The response was blocked by a content filter**\n\nPlease rephrase your request.",
|
|
19627
19677
|
"llm.schema_validation": "\u26A0\uFE0F **The model returned an invalid response**\n\nPlease try again.",
|
|
19628
19678
|
"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
|
|
19679
|
+
"llm.unknown": GENERIC_ERROR_TEXT,
|
|
19680
|
+
// The AI API's current name for llm.auth; older messages stored that one.
|
|
19681
|
+
"llm.auth_failed": "\u26A0\uFE0F **The model connection isn't authorised**\n\nAn administrator needs to check the model configuration.",
|
|
19682
|
+
"llm.unsupported_tools": "\u26A0\uFE0F **This model can't use tools**\n\nAn administrator needs to choose a model that supports tools for this step.",
|
|
19683
|
+
"embeddings.model_not_found": "\u26A0\uFE0F **The model or deployment could not be found**\n\nAn administrator needs to check the model configuration.",
|
|
19684
|
+
// The app API's names for losing the AI API before or part-way through a reply.
|
|
19685
|
+
"ai_api.unavailable": "\u26A0\uFE0F **The connection to the model was interrupted**\n\nThis is usually temporary. Please try again.",
|
|
19686
|
+
"ai_api.stream_broken": "\u26A0\uFE0F **The connection to the model was interrupted**\n\nThis is usually temporary. Please try again.",
|
|
19687
|
+
// Managed secrets. A secret's failure arrives as a 404 or 400, which the
|
|
19688
|
+
// status table below would read as a missing model or a generic error.
|
|
19689
|
+
"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.",
|
|
19690
|
+
"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.",
|
|
19691
|
+
"secret.user_mismatch": "\u26A0\uFE0F **A credential couldn't be loaded**\n\nAn administrator needs to check this flow's secrets.",
|
|
19692
|
+
"secret.run_required": "\u26A0\uFE0F **A credential couldn't be loaded**\n\nAn administrator needs to check this flow's secrets.",
|
|
19693
|
+
"secret.not_found": "\u26A0\uFE0F **A secret this flow uses doesn't exist**\n\nAn administrator needs to add it, or point the flow at another one.",
|
|
19694
|
+
// The API's name for secret.not_found before it was renamed; older messages stored it.
|
|
19695
|
+
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
19696
|
};
|
|
19631
19697
|
var STATUS_CODE_TEXT = {
|
|
19632
19698
|
408: ERROR_CODE_TEXT["llm.timeout"],
|
|
@@ -19646,6 +19712,9 @@ var getMessageErrorText = (error) => {
|
|
|
19646
19712
|
if (error.errorCode && ERROR_CODE_TEXT[error.errorCode]) {
|
|
19647
19713
|
return ERROR_CODE_TEXT[error.errorCode];
|
|
19648
19714
|
}
|
|
19715
|
+
if (error.errorCode && !error.errorCode.startsWith("llm.")) {
|
|
19716
|
+
return GENERIC_ERROR_TEXT;
|
|
19717
|
+
}
|
|
19649
19718
|
return STATUS_CODE_TEXT[error.code] ?? GENERIC_ERROR_TEXT;
|
|
19650
19719
|
};
|
|
19651
19720
|
function extractProviderErrorDetail(raw2) {
|
|
@@ -19719,7 +19788,8 @@ var MessageErrorMessageSchema = z.object({
|
|
|
19719
19788
|
error_code: z.string().nullish(),
|
|
19720
19789
|
message: z.string().nullish(),
|
|
19721
19790
|
data: z.string().nullish(),
|
|
19722
|
-
blockId: z.string().nullish()
|
|
19791
|
+
blockId: z.string().nullish(),
|
|
19792
|
+
traceId: z.string().nullish()
|
|
19723
19793
|
});
|
|
19724
19794
|
var MessageSchema = z.object({
|
|
19725
19795
|
id: z.string().nullish(),
|
|
@@ -19867,45 +19937,6 @@ function parseDateTime(date, customFormat) {
|
|
|
19867
19937
|
function parseDateTimeHuman(date) {
|
|
19868
19938
|
return dayjs.utc(date).local().fromNow();
|
|
19869
19939
|
}
|
|
19870
|
-
var buttonVariants = cva(
|
|
19871
|
-
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
19872
|
-
{
|
|
19873
|
-
variants: {
|
|
19874
|
-
variant: {
|
|
19875
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
19876
|
-
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
19877
|
-
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
19878
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
19879
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
19880
|
-
link: "text-primary underline-offset-4 hover:underline"
|
|
19881
|
-
},
|
|
19882
|
-
size: {
|
|
19883
|
-
default: "h-10 px-4 py-2",
|
|
19884
|
-
sm: "h-9 rounded-md px-3",
|
|
19885
|
-
lg: "h-11 rounded-md px-8",
|
|
19886
|
-
icon: "h-10 w-10"
|
|
19887
|
-
}
|
|
19888
|
-
},
|
|
19889
|
-
defaultVariants: {
|
|
19890
|
-
variant: "default",
|
|
19891
|
-
size: "default"
|
|
19892
|
-
}
|
|
19893
|
-
}
|
|
19894
|
-
);
|
|
19895
|
-
var Button = React9.forwardRef(
|
|
19896
|
-
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
19897
|
-
const Comp = asChild ? Slot : "button";
|
|
19898
|
-
return /* @__PURE__ */ jsx(
|
|
19899
|
-
Comp,
|
|
19900
|
-
{
|
|
19901
|
-
className: cn(buttonVariants({ variant, size, className })),
|
|
19902
|
-
ref,
|
|
19903
|
-
...props
|
|
19904
|
-
}
|
|
19905
|
-
);
|
|
19906
|
-
}
|
|
19907
|
-
);
|
|
19908
|
-
Button.displayName = "Button";
|
|
19909
19940
|
|
|
19910
19941
|
// src/messages/smartCopy.ts
|
|
19911
19942
|
async function copyMessageRich(container, markdown) {
|
|
@@ -20567,7 +20598,10 @@ var MessageBubble = (props) => {
|
|
|
20567
20598
|
/* @__PURE__ */ jsx("div", { className: "mt-1.5", children: metaRow })
|
|
20568
20599
|
] });
|
|
20569
20600
|
};
|
|
20570
|
-
function MessageErrorDetails({
|
|
20601
|
+
function MessageErrorDetails({
|
|
20602
|
+
detail,
|
|
20603
|
+
traceId
|
|
20604
|
+
}) {
|
|
20571
20605
|
const [expanded, setExpanded] = useState(false);
|
|
20572
20606
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1", children: [
|
|
20573
20607
|
/* @__PURE__ */ jsxs(
|
|
@@ -20583,7 +20617,32 @@ function MessageErrorDetails({ detail }) {
|
|
|
20583
20617
|
]
|
|
20584
20618
|
}
|
|
20585
20619
|
),
|
|
20586
|
-
expanded && /* @__PURE__ */
|
|
20620
|
+
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: [
|
|
20621
|
+
detail,
|
|
20622
|
+
traceId && /* @__PURE__ */ jsxs("div", { className: detail ? "mt-1.5" : void 0, children: [
|
|
20623
|
+
"Reference: ",
|
|
20624
|
+
traceId
|
|
20625
|
+
] })
|
|
20626
|
+
] })
|
|
20627
|
+
] });
|
|
20628
|
+
}
|
|
20629
|
+
function MessageReasoning({ text: text6 }) {
|
|
20630
|
+
const [expanded, setExpanded] = useState(false);
|
|
20631
|
+
return /* @__PURE__ */ jsxs("div", { className: "mb-1", children: [
|
|
20632
|
+
/* @__PURE__ */ jsxs(
|
|
20633
|
+
"button",
|
|
20634
|
+
{
|
|
20635
|
+
type: "button",
|
|
20636
|
+
onClick: () => setExpanded((prev) => !prev),
|
|
20637
|
+
"aria-expanded": expanded,
|
|
20638
|
+
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",
|
|
20639
|
+
children: [
|
|
20640
|
+
expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3 shrink-0" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 shrink-0" }),
|
|
20641
|
+
expanded ? "Hide reasoning" : "Show reasoning"
|
|
20642
|
+
]
|
|
20643
|
+
}
|
|
20644
|
+
),
|
|
20645
|
+
expanded && /* @__PURE__ */ jsx("div", { className: "mt-1.5 rounded-md bg-secondary/60 p-2 text-[13px] text-muted-foreground", children: /* @__PURE__ */ jsx(MessageMarkdown, { value: text6 }) })
|
|
20587
20646
|
] });
|
|
20588
20647
|
}
|
|
20589
20648
|
var ThinkingSection = ({ status }) => /* @__PURE__ */ jsxs(
|
|
@@ -20709,10 +20768,16 @@ var MessageItem = ({
|
|
|
20709
20768
|
let keyCounter = 0;
|
|
20710
20769
|
let lastStatusText = null;
|
|
20711
20770
|
let hasOutputContent = false;
|
|
20771
|
+
let firstOutputIndex = null;
|
|
20772
|
+
const markOutput = () => {
|
|
20773
|
+
if (firstOutputIndex === null) firstOutputIndex = bubbles.length;
|
|
20774
|
+
hasOutputContent = true;
|
|
20775
|
+
};
|
|
20776
|
+
const reasoningTexts = [];
|
|
20712
20777
|
const groupHasAnything = () => groupContent.length > 0 || groupFiles.length > 0 || groupSources.length > 0;
|
|
20713
20778
|
const flush = (nextType) => {
|
|
20714
20779
|
if (groupHasAnything()) {
|
|
20715
|
-
if (groupType === "Output" /* OUTPUT */)
|
|
20780
|
+
if (groupType === "Output" /* OUTPUT */) markOutput();
|
|
20716
20781
|
bubbles.push(
|
|
20717
20782
|
/* @__PURE__ */ jsx(
|
|
20718
20783
|
MessageBubble,
|
|
@@ -20822,6 +20887,12 @@ var MessageItem = ({
|
|
|
20822
20887
|
groupOpen = true;
|
|
20823
20888
|
break;
|
|
20824
20889
|
}
|
|
20890
|
+
case "reasoning": {
|
|
20891
|
+
if (typeof v.value === "string" && v.value.trim() !== "") {
|
|
20892
|
+
reasoningTexts.push(v.value);
|
|
20893
|
+
}
|
|
20894
|
+
continue;
|
|
20895
|
+
}
|
|
20825
20896
|
case "sources": {
|
|
20826
20897
|
groupSources = coerceSources(v.value);
|
|
20827
20898
|
if (groupSources.length > 0) groupOpen = true;
|
|
@@ -20839,7 +20910,7 @@ var MessageItem = ({
|
|
|
20839
20910
|
lastCreatedByUserId = v.createdByUserId;
|
|
20840
20911
|
}
|
|
20841
20912
|
if (groupOpen && groupHasAnything()) {
|
|
20842
|
-
if (groupType === "Output" /* OUTPUT */)
|
|
20913
|
+
if (groupType === "Output" /* OUTPUT */) markOutput();
|
|
20843
20914
|
bubbles.push(
|
|
20844
20915
|
/* @__PURE__ */ jsx(
|
|
20845
20916
|
MessageBubble,
|
|
@@ -20860,6 +20931,19 @@ var MessageItem = ({
|
|
|
20860
20931
|
)
|
|
20861
20932
|
);
|
|
20862
20933
|
}
|
|
20934
|
+
if (reasoningTexts.length > 0) {
|
|
20935
|
+
bubbles.splice(
|
|
20936
|
+
firstOutputIndex ?? bubbles.length,
|
|
20937
|
+
0,
|
|
20938
|
+
/* @__PURE__ */ jsx(
|
|
20939
|
+
MessageReasoning,
|
|
20940
|
+
{
|
|
20941
|
+
text: reasoningTexts.join("\n\n")
|
|
20942
|
+
},
|
|
20943
|
+
`reasoning-${message.id ?? "msg"}`
|
|
20944
|
+
)
|
|
20945
|
+
);
|
|
20946
|
+
}
|
|
20863
20947
|
const showThinking = isLive && (lastStatusText !== null || !hasOutputContent);
|
|
20864
20948
|
if (showThinking) {
|
|
20865
20949
|
bubbles.push(
|
|
@@ -20891,7 +20975,7 @@ var MessageItem = ({
|
|
|
20891
20975
|
userInput: null
|
|
20892
20976
|
}
|
|
20893
20977
|
),
|
|
20894
|
-
detail && /* @__PURE__ */ jsx(MessageErrorDetails, { detail })
|
|
20978
|
+
(detail || error.traceId) && /* @__PURE__ */ jsx(MessageErrorDetails, { detail, traceId: error.traceId })
|
|
20895
20979
|
] }, key)
|
|
20896
20980
|
);
|
|
20897
20981
|
});
|
|
@@ -20918,14 +21002,16 @@ function MessageList({
|
|
|
20918
21002
|
data: thread,
|
|
20919
21003
|
isPending: threadPending,
|
|
20920
21004
|
isFetching: threadFetching,
|
|
20921
|
-
error: threadError
|
|
21005
|
+
error: threadError,
|
|
21006
|
+
refetch: refetchThread
|
|
20922
21007
|
} = useThread({ workspaceId, threadId });
|
|
20923
21008
|
const isRunning = useThreadIsRunning(workspaceId, threadId);
|
|
20924
21009
|
const {
|
|
20925
21010
|
data: messages,
|
|
20926
21011
|
isPending: messagesPending,
|
|
20927
21012
|
isFetching: messagesFetching,
|
|
20928
|
-
error: messagesError
|
|
21013
|
+
error: messagesError,
|
|
21014
|
+
refetch: refetchMessages
|
|
20929
21015
|
} = useMessages(threadId);
|
|
20930
21016
|
const hostBg = applyHostBackgroundOverride ? "chat-main" : "";
|
|
20931
21017
|
const scrollToBottom = useCallback((behavior = "auto") => {
|
|
@@ -21004,7 +21090,19 @@ function MessageList({
|
|
|
21004
21090
|
messagesError && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-destructive", children: [
|
|
21005
21091
|
/* @__PURE__ */ jsx(AlertTriangle, { className: "h-4 w-4" }),
|
|
21006
21092
|
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Failed to load messages" })
|
|
21007
|
-
] })
|
|
21093
|
+
] }),
|
|
21094
|
+
/* @__PURE__ */ jsx(
|
|
21095
|
+
Button,
|
|
21096
|
+
{
|
|
21097
|
+
size: "sm",
|
|
21098
|
+
variant: "outline",
|
|
21099
|
+
onClick: () => {
|
|
21100
|
+
if (threadError) void refetchThread();
|
|
21101
|
+
if (messagesError) void refetchMessages();
|
|
21102
|
+
},
|
|
21103
|
+
children: "Try again"
|
|
21104
|
+
}
|
|
21105
|
+
)
|
|
21008
21106
|
] }) });
|
|
21009
21107
|
}
|
|
21010
21108
|
if (safeMessages.length === 0 && !hadMessagesBefore) {
|
|
@@ -21312,8 +21410,7 @@ var mapWorkspacesDtoToModels = (arr) => arr.map(mapWorkspaceDtoToModel);
|
|
|
21312
21410
|
function getChatApiBaseUrl() {
|
|
21313
21411
|
try {
|
|
21314
21412
|
const w = window;
|
|
21315
|
-
const
|
|
21316
|
-
const cfg = w?.ssconfig?.Chat_Api_Uri ?? env2?.VITE_CHAT_API_URI;
|
|
21413
|
+
const cfg = w?.ssconfig?.Chat_Api_Uri;
|
|
21317
21414
|
return typeof cfg === "string" && cfg.trim() ? cfg.trim() : "";
|
|
21318
21415
|
} catch {
|
|
21319
21416
|
return "";
|