@smartspace/chat-ui 1.14.6-main.1a6776c → 1.14.6-main.27cc4f3
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.css.map +1 -1
- package/dist/index.d.ts +219 -142
- package/dist/index.js +801 -118
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import MuiButton from '@mui/material/Button';
|
|
2
|
-
import
|
|
3
|
-
import { Loader2, ChevronDown, Check, Cpu, SlidersHorizontal, X, Globe, Zap,
|
|
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, 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';
|
|
@@ -17,7 +17,7 @@ import { codeBlockSchema, commonmark } from '@milkdown/preset-commonmark';
|
|
|
17
17
|
import { Slice, NodeType } from '@milkdown/prose/model';
|
|
18
18
|
import { MilkdownProvider, useEditor, Milkdown } from '@milkdown/react';
|
|
19
19
|
import { PluginKey, Plugin } from '@milkdown/prose/state';
|
|
20
|
-
import {
|
|
20
|
+
import { DecorationSet, Decoration } from '@milkdown/prose/view';
|
|
21
21
|
import 'crypto';
|
|
22
22
|
import '@milkdown/prose';
|
|
23
23
|
import '@milkdown/prose/inputrules';
|
|
@@ -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({
|
|
@@ -842,6 +829,37 @@ function useMessages(threadId) {
|
|
|
842
829
|
});
|
|
843
830
|
}
|
|
844
831
|
|
|
832
|
+
// src/domains/speech/queryKeys.ts
|
|
833
|
+
var speechKeys = {
|
|
834
|
+
all: ["speech"],
|
|
835
|
+
config: () => [...speechKeys.all, "config"]
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
// src/domains/speech/queries.ts
|
|
839
|
+
var unavailable = { enabled: false, defaultLocale: "en-US" };
|
|
840
|
+
var isNotFound = (error) => error?.type === "NotFound" || error?.response?.status === 404;
|
|
841
|
+
function useSpeechConfig() {
|
|
842
|
+
const service = useChatService();
|
|
843
|
+
const supported = !!service.getSpeechConfig && !!service.getSpeechToken;
|
|
844
|
+
return useQuery({
|
|
845
|
+
...queryOptions({
|
|
846
|
+
queryKey: speechKeys.config(),
|
|
847
|
+
queryFn: async () => {
|
|
848
|
+
try {
|
|
849
|
+
return await service.getSpeechConfig?.() ?? unavailable;
|
|
850
|
+
} catch (error) {
|
|
851
|
+
if (isNotFound(error)) return unavailable;
|
|
852
|
+
throw error;
|
|
853
|
+
}
|
|
854
|
+
},
|
|
855
|
+
staleTime: Infinity,
|
|
856
|
+
retry: (failureCount) => failureCount < 2,
|
|
857
|
+
retryDelay: 1e3
|
|
858
|
+
}),
|
|
859
|
+
enabled: supported
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
|
|
845
863
|
// ../../node_modules/.pnpm/@milkdown+exception@7.20.0/node_modules/@milkdown/exception/lib/index.js
|
|
846
864
|
var ErrorCode = /* @__PURE__ */ (function(ErrorCode2) {
|
|
847
865
|
ErrorCode2["docTypeError"] = "docTypeError";
|
|
@@ -975,6 +993,75 @@ var autolink = $prose(() => {
|
|
|
975
993
|
}
|
|
976
994
|
});
|
|
977
995
|
});
|
|
996
|
+
var dictationGhostKey = new PluginKey("dictationGhost");
|
|
997
|
+
function buildDecorations2(state, text6) {
|
|
998
|
+
const doc = state.doc;
|
|
999
|
+
const from = state.selection.head;
|
|
1000
|
+
const before = from > 0 ? doc.textBetween(from - 1, from, " ") : "";
|
|
1001
|
+
const display = before !== "" && !/\s/.test(before) ? ` ${text6}` : text6;
|
|
1002
|
+
const widget = Decoration.widget(
|
|
1003
|
+
from,
|
|
1004
|
+
() => {
|
|
1005
|
+
const span = document.createElement("span");
|
|
1006
|
+
span.className = "md-editor__dictation-ghost";
|
|
1007
|
+
span.setAttribute("aria-hidden", "true");
|
|
1008
|
+
span.appendChild(document.createTextNode(display));
|
|
1009
|
+
const dots = document.createElement("span");
|
|
1010
|
+
dots.className = "md-editor__dictation-dots";
|
|
1011
|
+
for (let i = 0; i < 3; i += 1)
|
|
1012
|
+
dots.appendChild(document.createElement("span"));
|
|
1013
|
+
span.appendChild(dots);
|
|
1014
|
+
return span;
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
// Render after the caret so typing still lands where the user expects.
|
|
1018
|
+
side: 1,
|
|
1019
|
+
// Keyed by content so ProseMirror reuses the node between renders instead
|
|
1020
|
+
// of tearing it down on every interim result.
|
|
1021
|
+
key: `dictation-ghost:${display}`
|
|
1022
|
+
}
|
|
1023
|
+
);
|
|
1024
|
+
const decorations = [widget];
|
|
1025
|
+
const $head = state.selection.$head;
|
|
1026
|
+
if ($head.depth > 0) {
|
|
1027
|
+
decorations.push(
|
|
1028
|
+
Decoration.node($head.before(), $head.after(), {
|
|
1029
|
+
class: "md-editor__has-dictation-ghost"
|
|
1030
|
+
})
|
|
1031
|
+
);
|
|
1032
|
+
}
|
|
1033
|
+
return DecorationSet.create(doc, decorations);
|
|
1034
|
+
}
|
|
1035
|
+
var dictationGhost = $prose(() => {
|
|
1036
|
+
return new Plugin({
|
|
1037
|
+
key: dictationGhostKey,
|
|
1038
|
+
state: {
|
|
1039
|
+
init: () => "",
|
|
1040
|
+
apply(tr, previous2) {
|
|
1041
|
+
const meta = tr.getMeta(dictationGhostKey);
|
|
1042
|
+
if (meta) return meta.text;
|
|
1043
|
+
if (tr.docChanged || tr.selectionSet) return "";
|
|
1044
|
+
return previous2;
|
|
1045
|
+
}
|
|
1046
|
+
},
|
|
1047
|
+
props: {
|
|
1048
|
+
decorations(state) {
|
|
1049
|
+
const text6 = dictationGhostKey.getState(state) ?? "";
|
|
1050
|
+
if (!text6) return DecorationSet.empty;
|
|
1051
|
+
return buildDecorations2(state, text6);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1055
|
+
});
|
|
1056
|
+
function setDictationGhost(view, text6) {
|
|
1057
|
+
const current = dictationGhostKey.getState(view.state) ?? "";
|
|
1058
|
+
if (current === text6) return;
|
|
1059
|
+
const tr = view.state.tr.setMeta(dictationGhostKey, {
|
|
1060
|
+
text: text6
|
|
1061
|
+
});
|
|
1062
|
+
tr.setMeta("addToHistory", false);
|
|
1063
|
+
view.dispatch(tr);
|
|
1064
|
+
}
|
|
978
1065
|
|
|
979
1066
|
// src/shared/markdown/extensions/fileTag.ts
|
|
980
1067
|
var fileTag = $node("fileTag", () => ({
|
|
@@ -1884,7 +1971,7 @@ function EditorInner({
|
|
|
1884
1971
|
} catch {
|
|
1885
1972
|
}
|
|
1886
1973
|
});
|
|
1887
|
-
}).use(commonmark).use(history).use(clipboard).use(listener).use(autolink).use(fileTag).use(ssImageNode).use(ssImageView).use(htmlPreviewView).use(enableMentions ? mention : fileTag);
|
|
1974
|
+
}).use(commonmark).use(history).use(clipboard).use(listener).use(autolink).use(dictationGhost).use(fileTag).use(ssImageNode).use(ssImageView).use(htmlPreviewView).use(enableMentions ? mention : fileTag);
|
|
1888
1975
|
},
|
|
1889
1976
|
[isEditable]
|
|
1890
1977
|
);
|
|
@@ -2094,6 +2181,25 @@ function EditorInner({
|
|
|
2094
2181
|
return value ?? "";
|
|
2095
2182
|
}
|
|
2096
2183
|
},
|
|
2184
|
+
insertText: (text6) => {
|
|
2185
|
+
const view = viewRef.current;
|
|
2186
|
+
if (!view || !isEditable || !text6) return;
|
|
2187
|
+
try {
|
|
2188
|
+
const { from } = view.state.selection;
|
|
2189
|
+
const before = from > 0 ? view.state.doc.textBetween(from - 1, from, " ") : "";
|
|
2190
|
+
const needsSpace = before !== "" && !/\s/.test(before);
|
|
2191
|
+
insertTextAtSelection(view, (needsSpace ? " " : "") + text6);
|
|
2192
|
+
} catch {
|
|
2193
|
+
}
|
|
2194
|
+
},
|
|
2195
|
+
setDictationGhost: (text6) => {
|
|
2196
|
+
const view = viewRef.current;
|
|
2197
|
+
if (!view || !isEditable) return;
|
|
2198
|
+
try {
|
|
2199
|
+
setDictationGhost(view, text6);
|
|
2200
|
+
} catch {
|
|
2201
|
+
}
|
|
2202
|
+
},
|
|
2097
2203
|
clear: () => {
|
|
2098
2204
|
const view = viewRef.current;
|
|
2099
2205
|
if (!view) return;
|
|
@@ -2437,6 +2543,327 @@ var MarkdownEditor = forwardRef((props, ref) => {
|
|
|
2437
2543
|
return /* @__PURE__ */ jsx(MilkdownProvider, { children: /* @__PURE__ */ jsx(EditorInner, { ...props, editorHandleRef: ref }) });
|
|
2438
2544
|
});
|
|
2439
2545
|
MarkdownEditor.displayName = "MarkdownEditor";
|
|
2546
|
+
var TOKEN_EXPIRY_MARGIN_MS = 15e3;
|
|
2547
|
+
var noLevelMonitor = () => void 0;
|
|
2548
|
+
var SILENCE_HINT_MS = 6e3;
|
|
2549
|
+
var SILENCE_LEVEL = 3;
|
|
2550
|
+
function monitorInputLevel(stream, onSilent, onSound) {
|
|
2551
|
+
let context;
|
|
2552
|
+
let source;
|
|
2553
|
+
let analyser;
|
|
2554
|
+
try {
|
|
2555
|
+
context = new AudioContext();
|
|
2556
|
+
source = context.createMediaStreamSource(stream);
|
|
2557
|
+
analyser = context.createAnalyser();
|
|
2558
|
+
analyser.fftSize = 512;
|
|
2559
|
+
source.connect(analyser);
|
|
2560
|
+
} catch {
|
|
2561
|
+
return () => void 0;
|
|
2562
|
+
}
|
|
2563
|
+
if (context.state === "suspended")
|
|
2564
|
+
void context.resume().catch(() => void 0);
|
|
2565
|
+
const samples = new Uint8Array(analyser.fftSize);
|
|
2566
|
+
let lastSound = Date.now();
|
|
2567
|
+
let silent = false;
|
|
2568
|
+
let stopped = false;
|
|
2569
|
+
const poll = window.setInterval(() => {
|
|
2570
|
+
if (context.state !== "running") return;
|
|
2571
|
+
analyser.getByteTimeDomainData(samples);
|
|
2572
|
+
let peak = 0;
|
|
2573
|
+
for (const sample of samples) peak = Math.max(peak, Math.abs(sample - 128));
|
|
2574
|
+
if (peak > SILENCE_LEVEL) {
|
|
2575
|
+
lastSound = Date.now();
|
|
2576
|
+
if (silent) {
|
|
2577
|
+
silent = false;
|
|
2578
|
+
onSound();
|
|
2579
|
+
}
|
|
2580
|
+
} else if (!silent && Date.now() - lastSound > SILENCE_HINT_MS) {
|
|
2581
|
+
silent = true;
|
|
2582
|
+
onSilent();
|
|
2583
|
+
}
|
|
2584
|
+
}, 250);
|
|
2585
|
+
return () => {
|
|
2586
|
+
if (stopped) return;
|
|
2587
|
+
stopped = true;
|
|
2588
|
+
window.clearInterval(poll);
|
|
2589
|
+
try {
|
|
2590
|
+
source.disconnect();
|
|
2591
|
+
void context.close().catch(() => void 0);
|
|
2592
|
+
} catch {
|
|
2593
|
+
}
|
|
2594
|
+
};
|
|
2595
|
+
}
|
|
2596
|
+
var STALE_TOKEN_FLOOR_MS = 6e4;
|
|
2597
|
+
function kickOff(fn) {
|
|
2598
|
+
let promise;
|
|
2599
|
+
try {
|
|
2600
|
+
promise = Promise.resolve(fn());
|
|
2601
|
+
} catch (e) {
|
|
2602
|
+
promise = Promise.reject(e);
|
|
2603
|
+
}
|
|
2604
|
+
promise.catch(() => void 0);
|
|
2605
|
+
return promise;
|
|
2606
|
+
}
|
|
2607
|
+
var isSupported = () => typeof window !== "undefined" && window.isSecureContext && !!navigator.mediaDevices?.getUserMedia;
|
|
2608
|
+
function classifyTokenFailure(error) {
|
|
2609
|
+
const code3 = error?.code;
|
|
2610
|
+
if (code3 === "speech.identity_misconfigured" || code3 === "SP500")
|
|
2611
|
+
return "unavailable";
|
|
2612
|
+
if (error?.type === "NotFound") {
|
|
2613
|
+
return "unavailable";
|
|
2614
|
+
}
|
|
2615
|
+
return "unavailable-temporarily";
|
|
2616
|
+
}
|
|
2617
|
+
function useDictation({
|
|
2618
|
+
region,
|
|
2619
|
+
locale,
|
|
2620
|
+
getToken,
|
|
2621
|
+
onPhrase,
|
|
2622
|
+
onInterim,
|
|
2623
|
+
maxDurationMs = 18e4,
|
|
2624
|
+
idleTimeoutMs = 2e4
|
|
2625
|
+
}) {
|
|
2626
|
+
const [state, setState] = useState("idle");
|
|
2627
|
+
const [error, setError] = useState(null);
|
|
2628
|
+
const [deviceLabel, setDeviceLabel] = useState("");
|
|
2629
|
+
const [silent, setSilent] = useState(false);
|
|
2630
|
+
const sessionRef = useRef(null);
|
|
2631
|
+
const generationRef = useRef(0);
|
|
2632
|
+
const onPhraseRef = useRef(onPhrase);
|
|
2633
|
+
const onInterimRef = useRef(onInterim);
|
|
2634
|
+
useEffect(() => {
|
|
2635
|
+
onPhraseRef.current = onPhrase;
|
|
2636
|
+
onInterimRef.current = onInterim;
|
|
2637
|
+
});
|
|
2638
|
+
const clearInterim = useCallback(() => onInterimRef.current?.(""), []);
|
|
2639
|
+
const supported = isSupported();
|
|
2640
|
+
const available = supported && !!region && !!getToken;
|
|
2641
|
+
useEffect(() => {
|
|
2642
|
+
if (!available) return;
|
|
2643
|
+
const nav = navigator;
|
|
2644
|
+
if (nav.connection?.saveData) return;
|
|
2645
|
+
const warm = () => void kickOff(() => import('microsoft-cognitiveservices-speech-sdk'));
|
|
2646
|
+
if (typeof window.requestIdleCallback === "function") {
|
|
2647
|
+
const id2 = window.requestIdleCallback(warm, { timeout: 2e3 });
|
|
2648
|
+
return () => window.cancelIdleCallback(id2);
|
|
2649
|
+
}
|
|
2650
|
+
const id = window.setTimeout(warm, 1500);
|
|
2651
|
+
return () => window.clearTimeout(id);
|
|
2652
|
+
}, [available]);
|
|
2653
|
+
const stop = useCallback(() => {
|
|
2654
|
+
generationRef.current += 1;
|
|
2655
|
+
const session = sessionRef.current;
|
|
2656
|
+
sessionRef.current = null;
|
|
2657
|
+
clearInterim();
|
|
2658
|
+
setState("idle");
|
|
2659
|
+
setSilent(false);
|
|
2660
|
+
setDeviceLabel("");
|
|
2661
|
+
if (!session) return;
|
|
2662
|
+
window.clearTimeout(session.timers.idle);
|
|
2663
|
+
window.clearTimeout(session.timers.max);
|
|
2664
|
+
session.stopLevelMonitor();
|
|
2665
|
+
session.stream.getTracks().forEach((t) => t.stop());
|
|
2666
|
+
session.recognizer.stopContinuousRecognitionAsync(
|
|
2667
|
+
() => session.recognizer.close(),
|
|
2668
|
+
() => session.recognizer.close()
|
|
2669
|
+
);
|
|
2670
|
+
}, [clearInterim]);
|
|
2671
|
+
const start = useCallback(async () => {
|
|
2672
|
+
if (!available || sessionRef.current) return;
|
|
2673
|
+
const generation = ++generationRef.current;
|
|
2674
|
+
const superseded = () => generationRef.current !== generation;
|
|
2675
|
+
setError(null);
|
|
2676
|
+
setSilent(false);
|
|
2677
|
+
setState("starting");
|
|
2678
|
+
const streamPromise = kickOff(
|
|
2679
|
+
() => navigator.mediaDevices.getUserMedia({
|
|
2680
|
+
audio: {
|
|
2681
|
+
echoCancellation: true,
|
|
2682
|
+
noiseSuppression: true,
|
|
2683
|
+
autoGainControl: true
|
|
2684
|
+
}
|
|
2685
|
+
})
|
|
2686
|
+
);
|
|
2687
|
+
const tokenPromise = kickOff(getToken);
|
|
2688
|
+
const sdkPromise = kickOff(
|
|
2689
|
+
() => import('microsoft-cognitiveservices-speech-sdk')
|
|
2690
|
+
);
|
|
2691
|
+
let stream;
|
|
2692
|
+
try {
|
|
2693
|
+
stream = await streamPromise;
|
|
2694
|
+
} catch (e) {
|
|
2695
|
+
if (superseded()) return;
|
|
2696
|
+
const name = e?.name;
|
|
2697
|
+
setError(
|
|
2698
|
+
name === "NotAllowedError" || name === "SecurityError" ? "permission-denied" : name === "NotFoundError" || name === "OverconstrainedError" ? "no-microphone" : "unknown"
|
|
2699
|
+
);
|
|
2700
|
+
setState("idle");
|
|
2701
|
+
return;
|
|
2702
|
+
}
|
|
2703
|
+
if (superseded()) {
|
|
2704
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
2705
|
+
return;
|
|
2706
|
+
}
|
|
2707
|
+
let token;
|
|
2708
|
+
try {
|
|
2709
|
+
token = await tokenPromise;
|
|
2710
|
+
if (Date.parse(token.expiresOn) - Date.now() < STALE_TOKEN_FLOOR_MS) {
|
|
2711
|
+
token = await getToken();
|
|
2712
|
+
}
|
|
2713
|
+
} catch (e) {
|
|
2714
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
2715
|
+
if (superseded()) return;
|
|
2716
|
+
setError(classifyTokenFailure(e));
|
|
2717
|
+
setState("idle");
|
|
2718
|
+
return;
|
|
2719
|
+
}
|
|
2720
|
+
if (superseded()) {
|
|
2721
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
2722
|
+
return;
|
|
2723
|
+
}
|
|
2724
|
+
let recognizer = null;
|
|
2725
|
+
let published = null;
|
|
2726
|
+
try {
|
|
2727
|
+
const sdk = await sdkPromise;
|
|
2728
|
+
if (superseded()) {
|
|
2729
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
2730
|
+
return;
|
|
2731
|
+
}
|
|
2732
|
+
const speechConfig = sdk.SpeechConfig.fromAuthorizationToken(
|
|
2733
|
+
token.token,
|
|
2734
|
+
region
|
|
2735
|
+
);
|
|
2736
|
+
speechConfig.speechRecognitionLanguage = locale;
|
|
2737
|
+
speechConfig.setProfanity(sdk.ProfanityOption.Raw);
|
|
2738
|
+
speechConfig.setProperty(
|
|
2739
|
+
sdk.PropertyId.Speech_SegmentationSilenceTimeoutMs,
|
|
2740
|
+
"700"
|
|
2741
|
+
);
|
|
2742
|
+
recognizer = new sdk.SpeechRecognizer(
|
|
2743
|
+
speechConfig,
|
|
2744
|
+
sdk.AudioConfig.fromStreamInput(stream)
|
|
2745
|
+
);
|
|
2746
|
+
const untilExpiry = Date.parse(token.expiresOn) - Date.now() - TOKEN_EXPIRY_MARGIN_MS;
|
|
2747
|
+
const sessionCapMs = Number.isFinite(untilExpiry) && untilExpiry > 0 ? Math.min(maxDurationMs, untilExpiry) : maxDurationMs;
|
|
2748
|
+
const session = {
|
|
2749
|
+
recognizer,
|
|
2750
|
+
stream,
|
|
2751
|
+
timers: {},
|
|
2752
|
+
stopLevelMonitor: noLevelMonitor
|
|
2753
|
+
};
|
|
2754
|
+
const armIdle = () => {
|
|
2755
|
+
window.clearTimeout(session.timers.idle);
|
|
2756
|
+
session.timers.idle = window.setTimeout(stop, idleTimeoutMs);
|
|
2757
|
+
};
|
|
2758
|
+
const isLive = () => sessionRef.current === session;
|
|
2759
|
+
sessionRef.current = session;
|
|
2760
|
+
published = session;
|
|
2761
|
+
const goLive = () => {
|
|
2762
|
+
if (!isLive()) return;
|
|
2763
|
+
session.timers.max ??= window.setTimeout(stop, sessionCapMs);
|
|
2764
|
+
if (session.stopLevelMonitor === noLevelMonitor) {
|
|
2765
|
+
try {
|
|
2766
|
+
setDeviceLabel(stream.getAudioTracks()[0]?.label ?? "");
|
|
2767
|
+
session.stopLevelMonitor = monitorInputLevel(
|
|
2768
|
+
stream,
|
|
2769
|
+
() => {
|
|
2770
|
+
if (isLive()) setSilent(true);
|
|
2771
|
+
},
|
|
2772
|
+
() => {
|
|
2773
|
+
if (isLive()) setSilent(false);
|
|
2774
|
+
}
|
|
2775
|
+
);
|
|
2776
|
+
} catch {
|
|
2777
|
+
session.stopLevelMonitor = noLevelMonitor;
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
armIdle();
|
|
2781
|
+
setState("listening");
|
|
2782
|
+
};
|
|
2783
|
+
recognizer.sessionStarted = () => goLive();
|
|
2784
|
+
recognizer.recognizing = (_sender, event) => {
|
|
2785
|
+
if (!isLive()) return;
|
|
2786
|
+
onInterimRef.current?.(event.result.text ?? "");
|
|
2787
|
+
armIdle();
|
|
2788
|
+
};
|
|
2789
|
+
recognizer.recognized = (_sender, event) => {
|
|
2790
|
+
if (!isLive()) return;
|
|
2791
|
+
const text6 = event.result.text?.trim();
|
|
2792
|
+
clearInterim();
|
|
2793
|
+
if (event.result.reason === sdk.ResultReason.RecognizedSpeech && text6) {
|
|
2794
|
+
onPhraseRef.current(text6);
|
|
2795
|
+
}
|
|
2796
|
+
armIdle();
|
|
2797
|
+
};
|
|
2798
|
+
recognizer.canceled = (_sender, event) => {
|
|
2799
|
+
if (!isLive()) return;
|
|
2800
|
+
if (event.reason === sdk.CancellationReason.Error) {
|
|
2801
|
+
console.warn("[dictation] cancelled, errorCode:", event.errorCode);
|
|
2802
|
+
setError(
|
|
2803
|
+
event.errorCode === sdk.CancellationErrorCode.ConnectionFailure ? "network" : event.errorCode === sdk.CancellationErrorCode.AuthenticationFailure ? "unavailable-temporarily" : "unknown"
|
|
2804
|
+
);
|
|
2805
|
+
}
|
|
2806
|
+
stop();
|
|
2807
|
+
};
|
|
2808
|
+
recognizer.sessionStopped = () => {
|
|
2809
|
+
if (isLive()) stop();
|
|
2810
|
+
};
|
|
2811
|
+
try {
|
|
2812
|
+
const connection = sdk.Connection.fromRecognizer(recognizer);
|
|
2813
|
+
connection.connected = () => goLive();
|
|
2814
|
+
connection.openConnection();
|
|
2815
|
+
} catch {
|
|
2816
|
+
}
|
|
2817
|
+
await new Promise(
|
|
2818
|
+
(resolve, reject) => session.recognizer.startContinuousRecognitionAsync(resolve, reject)
|
|
2819
|
+
);
|
|
2820
|
+
goLive();
|
|
2821
|
+
} catch (e) {
|
|
2822
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
2823
|
+
try {
|
|
2824
|
+
recognizer?.close();
|
|
2825
|
+
} catch {
|
|
2826
|
+
}
|
|
2827
|
+
if (published) {
|
|
2828
|
+
window.clearTimeout(published.timers.idle);
|
|
2829
|
+
window.clearTimeout(published.timers.max);
|
|
2830
|
+
published.stopLevelMonitor();
|
|
2831
|
+
if (sessionRef.current === published) sessionRef.current = null;
|
|
2832
|
+
}
|
|
2833
|
+
if (superseded()) return;
|
|
2834
|
+
console.warn("[dictation] failed to start:", e);
|
|
2835
|
+
setError((prev) => prev ?? "unavailable-temporarily");
|
|
2836
|
+
setState("idle");
|
|
2837
|
+
}
|
|
2838
|
+
}, [
|
|
2839
|
+
available,
|
|
2840
|
+
clearInterim,
|
|
2841
|
+
getToken,
|
|
2842
|
+
idleTimeoutMs,
|
|
2843
|
+
locale,
|
|
2844
|
+
maxDurationMs,
|
|
2845
|
+
region,
|
|
2846
|
+
stop
|
|
2847
|
+
]);
|
|
2848
|
+
useEffect(() => stop, [stop]);
|
|
2849
|
+
const toggle = useCallback(() => {
|
|
2850
|
+
if (state === "idle") void start();
|
|
2851
|
+
else stop();
|
|
2852
|
+
}, [start, state, stop]);
|
|
2853
|
+
return {
|
|
2854
|
+
supported,
|
|
2855
|
+
available,
|
|
2856
|
+
state,
|
|
2857
|
+
error,
|
|
2858
|
+
/** Name of the microphone in use, once a session is live. May be ''. */
|
|
2859
|
+
deviceLabel,
|
|
2860
|
+
/** Listening, but the microphone has produced no sound for a while. */
|
|
2861
|
+
silent,
|
|
2862
|
+
start,
|
|
2863
|
+
stop,
|
|
2864
|
+
toggle
|
|
2865
|
+
};
|
|
2866
|
+
}
|
|
2440
2867
|
function useFlowRunVariables(flowRunId) {
|
|
2441
2868
|
const service = useChatService();
|
|
2442
2869
|
return useQuery({
|
|
@@ -3742,6 +4169,58 @@ var ChatVariablesForm = forwardRef(({ workspace, threadId, setVariables }, ref)
|
|
|
3742
4169
|
) }) })
|
|
3743
4170
|
] });
|
|
3744
4171
|
});
|
|
4172
|
+
var dictationErrorMessages = {
|
|
4173
|
+
"permission-denied": "Microphone access is blocked \u2014 allow it in your browser settings and try again",
|
|
4174
|
+
"no-microphone": "No microphone was found",
|
|
4175
|
+
network: "Could not reach the speech service \u2014 try again",
|
|
4176
|
+
"unavailable-temporarily": "Dictation is starting up \u2014 try again in a moment",
|
|
4177
|
+
unavailable: "Dictation is not available on this workspace",
|
|
4178
|
+
unknown: "Dictation stopped unexpectedly \u2014 try again"
|
|
4179
|
+
};
|
|
4180
|
+
function DictationButton({
|
|
4181
|
+
state,
|
|
4182
|
+
error,
|
|
4183
|
+
disabled,
|
|
4184
|
+
onToggle,
|
|
4185
|
+
deviceLabel,
|
|
4186
|
+
size = "sm"
|
|
4187
|
+
}) {
|
|
4188
|
+
const listening = state === "listening";
|
|
4189
|
+
const starting = state === "starting";
|
|
4190
|
+
const label = listening ? "Stop dictation" : "Dictate a message";
|
|
4191
|
+
const hint = listening && deviceLabel ? `${label} \u2014 ${deviceLabel}` : label;
|
|
4192
|
+
const dims = size === "sm" ? "h-8 w-8" : "h-9 w-9";
|
|
4193
|
+
const icon = size === "sm" ? "h-4 w-4" : "h-5 w-5";
|
|
4194
|
+
return /* @__PURE__ */ jsxs(
|
|
4195
|
+
IconButton2,
|
|
4196
|
+
{
|
|
4197
|
+
type: "button",
|
|
4198
|
+
onClick: onToggle,
|
|
4199
|
+
disabled,
|
|
4200
|
+
"aria-pressed": listening,
|
|
4201
|
+
"aria-label": label,
|
|
4202
|
+
title: error ? dictationErrorMessages[error] : hint,
|
|
4203
|
+
className: `relative ${dims} rounded-full transition-colors ${listening ? "bg-destructive text-destructive-foreground hover:bg-destructive/90" : "text-muted-foreground hover:bg-secondary"}`,
|
|
4204
|
+
children: [
|
|
4205
|
+
starting && /* @__PURE__ */ jsx(
|
|
4206
|
+
"span",
|
|
4207
|
+
{
|
|
4208
|
+
"aria-hidden": "true",
|
|
4209
|
+
className: "absolute inset-0 animate-spin rounded-full border-2 border-transparent border-t-current opacity-70"
|
|
4210
|
+
}
|
|
4211
|
+
),
|
|
4212
|
+
listening && /* @__PURE__ */ jsx(
|
|
4213
|
+
"span",
|
|
4214
|
+
{
|
|
4215
|
+
"aria-hidden": "true",
|
|
4216
|
+
className: "absolute inset-0 animate-ping rounded-full bg-destructive/30"
|
|
4217
|
+
}
|
|
4218
|
+
),
|
|
4219
|
+
listening ? /* @__PURE__ */ jsx(Square, { className: `relative ${icon} fill-current` }) : /* @__PURE__ */ jsx(Mic, { className: `relative ${icon}` })
|
|
4220
|
+
]
|
|
4221
|
+
}
|
|
4222
|
+
);
|
|
4223
|
+
}
|
|
3745
4224
|
|
|
3746
4225
|
// src/domains/workspaces/queryKeys.ts
|
|
3747
4226
|
var workspaceKeys = {
|
|
@@ -3760,7 +4239,10 @@ var workspaceDetailOptions = ({
|
|
|
3760
4239
|
}) => queryOptions({
|
|
3761
4240
|
queryKey: workspaceKeys.byId(workspaceId),
|
|
3762
4241
|
queryFn: () => service.fetchWorkspace(workspaceId),
|
|
3763
|
-
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
|
|
3764
4246
|
});
|
|
3765
4247
|
function useWorkspace(workspaceId) {
|
|
3766
4248
|
const service = useChatService();
|
|
@@ -3808,6 +4290,8 @@ function useMessageComposerVm(props = {}) {
|
|
|
3808
4290
|
const isRunning = useThreadIsRunning(workspaceId, threadId);
|
|
3809
4291
|
const isUploadingFiles = props.isUploadingFiles ?? false;
|
|
3810
4292
|
const sendMessage = useSendMessage();
|
|
4293
|
+
const currentThreadId = useRef(threadId);
|
|
4294
|
+
currentThreadId.current = threadId;
|
|
3811
4295
|
const sendDisabled = useMemo(() => {
|
|
3812
4296
|
const nothingToSend = !newMessage.trim() && !props.hasAttachments;
|
|
3813
4297
|
const flowBlocked = isRunning || sendMessage.isPending;
|
|
@@ -3819,18 +4303,27 @@ function useMessageComposerVm(props = {}) {
|
|
|
3819
4303
|
newMessage,
|
|
3820
4304
|
props.hasAttachments
|
|
3821
4305
|
]);
|
|
3822
|
-
const internalSend = (text6, files) => {
|
|
4306
|
+
const internalSend = (text6, files, onFailed) => {
|
|
3823
4307
|
if (!workspaceId || !threadId) return;
|
|
3824
4308
|
const trimmed = text6.trim();
|
|
3825
4309
|
const contentList = trimmed ? [{ text: trimmed, image: void 0 }] : void 0;
|
|
3826
4310
|
const vars = variables && Object.keys(variables).length > 0 ? variables : void 0;
|
|
3827
|
-
sendMessage.mutate(
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
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
|
+
);
|
|
3834
4327
|
setNewMessage("");
|
|
3835
4328
|
};
|
|
3836
4329
|
const canSend = (text6, files) => {
|
|
@@ -3839,9 +4332,9 @@ function useMessageComposerVm(props = {}) {
|
|
|
3839
4332
|
const flowBlocked = isRunning || sendMessage.isPending;
|
|
3840
4333
|
return !(isUploadingFiles || flowBlocked || nothingToSend);
|
|
3841
4334
|
};
|
|
3842
|
-
const handleSendMessage = (text6, files) => {
|
|
4335
|
+
const handleSendMessage = (text6, files, onFailed) => {
|
|
3843
4336
|
if (!canSend(text6, files)) return false;
|
|
3844
|
-
internalSend(text6, files);
|
|
4337
|
+
internalSend(text6, files, onFailed);
|
|
3845
4338
|
return true;
|
|
3846
4339
|
};
|
|
3847
4340
|
return {
|
|
@@ -3974,6 +4467,40 @@ function MessageComposer(_props = {}) {
|
|
|
3974
4467
|
cancelReset();
|
|
3975
4468
|
}
|
|
3976
4469
|
}, [isSending, cancelAccepted, cancelErrored, cancelReset]);
|
|
4470
|
+
const attachEditor = useCallback(
|
|
4471
|
+
(handle2) => {
|
|
4472
|
+
if (handle2) editorRef.current = handle2;
|
|
4473
|
+
},
|
|
4474
|
+
// Both flags matter: the portal mounts on `isMobile && isFullscreen`, and
|
|
4475
|
+
// nothing resets isFullscreen when the breakpoint flips, so crossing it
|
|
4476
|
+
// while fullscreen would unmount the portal editor without re-attaching the
|
|
4477
|
+
// inline one — leaving a destroyed handle and silently swallowing phrases.
|
|
4478
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4479
|
+
[isFullscreen, isMobile]
|
|
4480
|
+
);
|
|
4481
|
+
const { data: speechConfig, isFetching: speechConfigLoading } = useSpeechConfig();
|
|
4482
|
+
const getSpeechToken = useMemo(
|
|
4483
|
+
() => chatService.getSpeechToken?.bind(chatService),
|
|
4484
|
+
[chatService]
|
|
4485
|
+
);
|
|
4486
|
+
const dictation = useDictation({
|
|
4487
|
+
region: speechConfig?.enabled ? speechConfig.region : null,
|
|
4488
|
+
locale: speechConfig?.defaultLocale ?? "en-US",
|
|
4489
|
+
getToken: getSpeechToken,
|
|
4490
|
+
// Final phrases become real text; provisional ones render as greyed ghost
|
|
4491
|
+
// text at the caret and never enter the document.
|
|
4492
|
+
onPhrase: (text6) => editorRef.current?.insertText(`${text6} `),
|
|
4493
|
+
onInterim: (text6) => editorRef.current?.setDictationGhost(text6)
|
|
4494
|
+
});
|
|
4495
|
+
const { stop: stopDictation } = dictation;
|
|
4496
|
+
const dictationUnavailableReason = speechConfigLoading ? "Checking whether dictation is available" : dictation.supported ? "Dictation is not enabled for this workspace" : "Dictation is not available in this browser";
|
|
4497
|
+
const handleDictationToggle = () => {
|
|
4498
|
+
if (dictation.state === "idle") editorRef.current?.focus();
|
|
4499
|
+
dictation.toggle();
|
|
4500
|
+
};
|
|
4501
|
+
useEffect(() => {
|
|
4502
|
+
if (disabled) stopDictation();
|
|
4503
|
+
}, [disabled, stopDictation]);
|
|
3977
4504
|
useEffect(() => {
|
|
3978
4505
|
if (typeof window === "undefined") return;
|
|
3979
4506
|
window.__ssDownloadFile = (id) => getFileBlobUrl(id);
|
|
@@ -4091,8 +4618,18 @@ function MessageComposer(_props = {}) {
|
|
|
4091
4618
|
}, [editorKey]);
|
|
4092
4619
|
const handleSendMessageAndClear = () => {
|
|
4093
4620
|
const latestText = editorRef.current?.getMarkdown() ?? newMessage;
|
|
4094
|
-
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
|
+
);
|
|
4095
4631
|
if (!sent) return;
|
|
4632
|
+
stopDictation();
|
|
4096
4633
|
handleClearAttachments();
|
|
4097
4634
|
setEditorKey((k) => k + 1);
|
|
4098
4635
|
};
|
|
@@ -4199,7 +4736,7 @@ function MessageComposer(_props = {}) {
|
|
|
4199
4736
|
/* @__PURE__ */ jsx("div", { className: "max-h-[400px] w-full overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
4200
4737
|
MarkdownEditor,
|
|
4201
4738
|
{
|
|
4202
|
-
ref:
|
|
4739
|
+
ref: attachEditor,
|
|
4203
4740
|
value: newMessage,
|
|
4204
4741
|
onChange: (md) => setNewMessage(md),
|
|
4205
4742
|
onKeyDown: handleComposerKeyDown,
|
|
@@ -4216,10 +4753,18 @@ function MessageComposer(_props = {}) {
|
|
|
4216
4753
|
},
|
|
4217
4754
|
`composer-md-${editorKey}`
|
|
4218
4755
|
) }),
|
|
4756
|
+
/* @__PURE__ */ jsx("div", { role: "status", className: "sr-only", children: dictation.state === "listening" ? dictation.silent ? `Listening, but not hearing anything from ${dictation.deviceLabel || "your microphone"}` : "Listening" : dictation.state === "starting" ? "Starting dictation" : "" }),
|
|
4757
|
+
dictation.state === "listening" && dictation.silent && /* @__PURE__ */ jsxs("div", { className: "px-5 pb-1 text-xs text-muted-foreground", children: [
|
|
4758
|
+
"Not hearing anything from",
|
|
4759
|
+
" ",
|
|
4760
|
+
dictation.deviceLabel || "your microphone",
|
|
4761
|
+
"."
|
|
4762
|
+
] }),
|
|
4763
|
+
dictation.error && /* @__PURE__ */ jsx("div", { role: "alert", className: "px-5 pb-1 text-xs text-destructive", children: dictationErrorMessages[dictation.error] }),
|
|
4219
4764
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 px-3 pb-3", children: [
|
|
4220
4765
|
/* @__PURE__ */ jsxs("div", { className: "ss-composer__actions flex min-w-0 flex-1 items-center gap-1", children: [
|
|
4221
4766
|
supportsFiles && /* @__PURE__ */ jsx(
|
|
4222
|
-
|
|
4767
|
+
IconButton2,
|
|
4223
4768
|
{
|
|
4224
4769
|
type: "button",
|
|
4225
4770
|
onClick: handlePickFilesClick,
|
|
@@ -4240,19 +4785,39 @@ function MessageComposer(_props = {}) {
|
|
|
4240
4785
|
)
|
|
4241
4786
|
] }),
|
|
4242
4787
|
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1.5", children: [
|
|
4243
|
-
/* @__PURE__ */ jsx(
|
|
4244
|
-
|
|
4788
|
+
dictation.available ? /* @__PURE__ */ jsx(
|
|
4789
|
+
DictationButton,
|
|
4245
4790
|
{
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
children: /* @__PURE__ */ jsx(Mic, { className: "h-4 w-4" })
|
|
4791
|
+
state: dictation.state,
|
|
4792
|
+
error: dictation.error,
|
|
4793
|
+
disabled,
|
|
4794
|
+
onToggle: handleDictationToggle,
|
|
4795
|
+
deviceLabel: dictation.deviceLabel
|
|
4252
4796
|
}
|
|
4797
|
+
) : (
|
|
4798
|
+
// A disabled button receives no pointer events, so its own
|
|
4799
|
+
// `title` never renders a tooltip. The wrapper is what the user
|
|
4800
|
+
// actually hovers.
|
|
4801
|
+
/* @__PURE__ */ jsx(
|
|
4802
|
+
"span",
|
|
4803
|
+
{
|
|
4804
|
+
title: dictationUnavailableReason,
|
|
4805
|
+
className: "inline-flex cursor-not-allowed",
|
|
4806
|
+
children: /* @__PURE__ */ jsx(
|
|
4807
|
+
IconButton2,
|
|
4808
|
+
{
|
|
4809
|
+
type: "button",
|
|
4810
|
+
disabled: true,
|
|
4811
|
+
"aria-label": `Dictate a message. ${dictationUnavailableReason}`,
|
|
4812
|
+
className: "h-8 w-8 rounded-full text-muted-foreground",
|
|
4813
|
+
children: /* @__PURE__ */ jsx(Mic, { className: "h-4 w-4" })
|
|
4814
|
+
}
|
|
4815
|
+
)
|
|
4816
|
+
}
|
|
4817
|
+
)
|
|
4253
4818
|
),
|
|
4254
4819
|
canStop ? /* @__PURE__ */ jsx(
|
|
4255
|
-
|
|
4820
|
+
IconButton2,
|
|
4256
4821
|
{
|
|
4257
4822
|
onClick: handleStopRun,
|
|
4258
4823
|
className: "chat-send h-8 w-8 rounded-full",
|
|
@@ -4266,7 +4831,7 @@ function MessageComposer(_props = {}) {
|
|
|
4266
4831
|
)
|
|
4267
4832
|
}
|
|
4268
4833
|
) : /* @__PURE__ */ jsx(
|
|
4269
|
-
|
|
4834
|
+
IconButton2,
|
|
4270
4835
|
{
|
|
4271
4836
|
onClick: handleSendMessageAndClear,
|
|
4272
4837
|
className: `chat-send h-8 w-8 rounded-full ${sendDisabled ? "cursor-not-allowed" : ""}`,
|
|
@@ -4295,7 +4860,7 @@ function MessageComposer(_props = {}) {
|
|
|
4295
4860
|
},
|
|
4296
4861
|
children: /* @__PURE__ */ jsxs("div", { className: "relative h-full w-full bg-background border shadow-lg", children: [
|
|
4297
4862
|
/* @__PURE__ */ jsx(
|
|
4298
|
-
|
|
4863
|
+
IconButton2,
|
|
4299
4864
|
{
|
|
4300
4865
|
type: "button",
|
|
4301
4866
|
size: "small",
|
|
@@ -4313,7 +4878,7 @@ function MessageComposer(_props = {}) {
|
|
|
4313
4878
|
/* @__PURE__ */ jsx("div", { className: "flex-1 p-4", children: /* @__PURE__ */ jsx(
|
|
4314
4879
|
MarkdownEditor,
|
|
4315
4880
|
{
|
|
4316
|
-
ref:
|
|
4881
|
+
ref: attachEditor,
|
|
4317
4882
|
value: newMessage,
|
|
4318
4883
|
onChange: (md) => setNewMessage(md),
|
|
4319
4884
|
onKeyDown: handleComposerKeyDown,
|
|
@@ -4328,10 +4893,18 @@ function MessageComposer(_props = {}) {
|
|
|
4328
4893
|
},
|
|
4329
4894
|
`composer-md-${editorKey}`
|
|
4330
4895
|
) }),
|
|
4896
|
+
dictation.error && /* @__PURE__ */ jsx(
|
|
4897
|
+
"div",
|
|
4898
|
+
{
|
|
4899
|
+
"aria-hidden": "true",
|
|
4900
|
+
className: "px-4 pb-1 text-xs text-destructive",
|
|
4901
|
+
children: dictationErrorMessages[dictation.error]
|
|
4902
|
+
}
|
|
4903
|
+
),
|
|
4331
4904
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-3 py-2 border-t bg-background", children: [
|
|
4332
4905
|
/* @__PURE__ */ jsx("div", { className: "flex-1" }),
|
|
4333
4906
|
supportsFiles && /* @__PURE__ */ jsx(
|
|
4334
|
-
|
|
4907
|
+
IconButton2,
|
|
4335
4908
|
{
|
|
4336
4909
|
type: "button",
|
|
4337
4910
|
onClick: handlePickFilesClick,
|
|
@@ -4346,8 +4919,19 @@ function MessageComposer(_props = {}) {
|
|
|
4346
4919
|
)
|
|
4347
4920
|
}
|
|
4348
4921
|
),
|
|
4922
|
+
dictation.available && /* @__PURE__ */ jsx(
|
|
4923
|
+
DictationButton,
|
|
4924
|
+
{
|
|
4925
|
+
size: "md",
|
|
4926
|
+
state: dictation.state,
|
|
4927
|
+
error: dictation.error,
|
|
4928
|
+
disabled,
|
|
4929
|
+
onToggle: handleDictationToggle,
|
|
4930
|
+
deviceLabel: dictation.deviceLabel
|
|
4931
|
+
}
|
|
4932
|
+
),
|
|
4349
4933
|
canStop ? /* @__PURE__ */ jsx(
|
|
4350
|
-
|
|
4934
|
+
IconButton2,
|
|
4351
4935
|
{
|
|
4352
4936
|
onClick: handleStopRun,
|
|
4353
4937
|
className: "chat-send h-9 w-9 rounded-full",
|
|
@@ -4361,7 +4945,7 @@ function MessageComposer(_props = {}) {
|
|
|
4361
4945
|
)
|
|
4362
4946
|
}
|
|
4363
4947
|
) : /* @__PURE__ */ jsx(
|
|
4364
|
-
|
|
4948
|
+
IconButton2,
|
|
4365
4949
|
{
|
|
4366
4950
|
onClick: handleSendMessageAndClear,
|
|
4367
4951
|
className: `chat-send h-9 w-9 rounded-full ${sendDisabled ? "cursor-not-allowed" : ""}`,
|
|
@@ -19025,6 +19609,45 @@ function MessageMarkdown({ value, className }) {
|
|
|
19025
19609
|
function cn(...inputs) {
|
|
19026
19610
|
return twMerge(clsx(inputs));
|
|
19027
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";
|
|
19028
19651
|
function Skeleton({ className, ...props }) {
|
|
19029
19652
|
return /* @__PURE__ */ jsx(
|
|
19030
19653
|
MuiSkeleton,
|
|
@@ -19053,7 +19676,23 @@ var ERROR_CODE_TEXT = {
|
|
|
19053
19676
|
"llm.content_policy": "\u26A0\uFE0F **The response was blocked by a content filter**\n\nPlease rephrase your request.",
|
|
19054
19677
|
"llm.schema_validation": "\u26A0\uFE0F **The model returned an invalid response**\n\nPlease try again.",
|
|
19055
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.",
|
|
19056
|
-
"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."
|
|
19057
19696
|
};
|
|
19058
19697
|
var STATUS_CODE_TEXT = {
|
|
19059
19698
|
408: ERROR_CODE_TEXT["llm.timeout"],
|
|
@@ -19073,8 +19712,39 @@ var getMessageErrorText = (error) => {
|
|
|
19073
19712
|
if (error.errorCode && ERROR_CODE_TEXT[error.errorCode]) {
|
|
19074
19713
|
return ERROR_CODE_TEXT[error.errorCode];
|
|
19075
19714
|
}
|
|
19715
|
+
if (error.errorCode && !error.errorCode.startsWith("llm.")) {
|
|
19716
|
+
return GENERIC_ERROR_TEXT;
|
|
19717
|
+
}
|
|
19076
19718
|
return STATUS_CODE_TEXT[error.code] ?? GENERIC_ERROR_TEXT;
|
|
19077
19719
|
};
|
|
19720
|
+
function extractProviderErrorDetail(raw2) {
|
|
19721
|
+
const start = raw2.indexOf("{");
|
|
19722
|
+
if (start === -1) return null;
|
|
19723
|
+
let parsed;
|
|
19724
|
+
try {
|
|
19725
|
+
parsed = JSON.parse(raw2.slice(start));
|
|
19726
|
+
} catch {
|
|
19727
|
+
return null;
|
|
19728
|
+
}
|
|
19729
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
19730
|
+
const record = parsed;
|
|
19731
|
+
const inner = typeof record.error === "object" && record.error !== null ? record.error : record;
|
|
19732
|
+
if (typeof inner.message !== "string") return null;
|
|
19733
|
+
return {
|
|
19734
|
+
message: inner.message,
|
|
19735
|
+
param: typeof inner.param === "string" ? inner.param : void 0
|
|
19736
|
+
};
|
|
19737
|
+
}
|
|
19738
|
+
var getMessageErrorDetail = (error) => {
|
|
19739
|
+
if (typeof error === "number" || !error.message) {
|
|
19740
|
+
return null;
|
|
19741
|
+
}
|
|
19742
|
+
const detail = extractProviderErrorDetail(error.message);
|
|
19743
|
+
if (!detail) {
|
|
19744
|
+
return error.message;
|
|
19745
|
+
}
|
|
19746
|
+
return detail.param ? `${detail.message} (param: ${detail.param})` : detail.message;
|
|
19747
|
+
};
|
|
19078
19748
|
var FileInfoSchema = z.object({
|
|
19079
19749
|
id: z.string(),
|
|
19080
19750
|
name: z.string()
|
|
@@ -19118,7 +19788,8 @@ var MessageErrorMessageSchema = z.object({
|
|
|
19118
19788
|
error_code: z.string().nullish(),
|
|
19119
19789
|
message: z.string().nullish(),
|
|
19120
19790
|
data: z.string().nullish(),
|
|
19121
|
-
blockId: z.string().nullish()
|
|
19791
|
+
blockId: z.string().nullish(),
|
|
19792
|
+
traceId: z.string().nullish()
|
|
19122
19793
|
});
|
|
19123
19794
|
var MessageSchema = z.object({
|
|
19124
19795
|
id: z.string().nullish(),
|
|
@@ -19266,45 +19937,6 @@ function parseDateTime(date, customFormat) {
|
|
|
19266
19937
|
function parseDateTimeHuman(date) {
|
|
19267
19938
|
return dayjs.utc(date).local().fromNow();
|
|
19268
19939
|
}
|
|
19269
|
-
var buttonVariants = cva(
|
|
19270
|
-
"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",
|
|
19271
|
-
{
|
|
19272
|
-
variants: {
|
|
19273
|
-
variant: {
|
|
19274
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
19275
|
-
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
19276
|
-
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
19277
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
19278
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
19279
|
-
link: "text-primary underline-offset-4 hover:underline"
|
|
19280
|
-
},
|
|
19281
|
-
size: {
|
|
19282
|
-
default: "h-10 px-4 py-2",
|
|
19283
|
-
sm: "h-9 rounded-md px-3",
|
|
19284
|
-
lg: "h-11 rounded-md px-8",
|
|
19285
|
-
icon: "h-10 w-10"
|
|
19286
|
-
}
|
|
19287
|
-
},
|
|
19288
|
-
defaultVariants: {
|
|
19289
|
-
variant: "default",
|
|
19290
|
-
size: "default"
|
|
19291
|
-
}
|
|
19292
|
-
}
|
|
19293
|
-
);
|
|
19294
|
-
var Button = React9.forwardRef(
|
|
19295
|
-
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
19296
|
-
const Comp = asChild ? Slot : "button";
|
|
19297
|
-
return /* @__PURE__ */ jsx(
|
|
19298
|
-
Comp,
|
|
19299
|
-
{
|
|
19300
|
-
className: cn(buttonVariants({ variant, size, className })),
|
|
19301
|
-
ref,
|
|
19302
|
-
...props
|
|
19303
|
-
}
|
|
19304
|
-
);
|
|
19305
|
-
}
|
|
19306
|
-
);
|
|
19307
|
-
Button.displayName = "Button";
|
|
19308
19940
|
|
|
19309
19941
|
// src/messages/smartCopy.ts
|
|
19310
19942
|
async function copyMessageRich(container, markdown) {
|
|
@@ -19966,6 +20598,34 @@ var MessageBubble = (props) => {
|
|
|
19966
20598
|
/* @__PURE__ */ jsx("div", { className: "mt-1.5", children: metaRow })
|
|
19967
20599
|
] });
|
|
19968
20600
|
};
|
|
20601
|
+
function MessageErrorDetails({
|
|
20602
|
+
detail,
|
|
20603
|
+
traceId
|
|
20604
|
+
}) {
|
|
20605
|
+
const [expanded, setExpanded] = useState(false);
|
|
20606
|
+
return /* @__PURE__ */ jsxs("div", { className: "mt-1", children: [
|
|
20607
|
+
/* @__PURE__ */ jsxs(
|
|
20608
|
+
"button",
|
|
20609
|
+
{
|
|
20610
|
+
type: "button",
|
|
20611
|
+
onClick: () => setExpanded((prev) => !prev),
|
|
20612
|
+
"aria-expanded": expanded,
|
|
20613
|
+
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",
|
|
20614
|
+
children: [
|
|
20615
|
+
expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3 shrink-0" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 shrink-0" }),
|
|
20616
|
+
expanded ? "Hide details" : "Show details"
|
|
20617
|
+
]
|
|
20618
|
+
}
|
|
20619
|
+
),
|
|
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
|
+
}
|
|
19969
20629
|
var ThinkingSection = ({ status }) => /* @__PURE__ */ jsxs(
|
|
19970
20630
|
"div",
|
|
19971
20631
|
{
|
|
@@ -20253,22 +20913,26 @@ var MessageItem = ({
|
|
|
20253
20913
|
);
|
|
20254
20914
|
}
|
|
20255
20915
|
(message.errors ?? []).forEach((error, errorIndex) => {
|
|
20916
|
+
const key = `error-${message.id ?? "msg"}-${errorIndex}-${error.errorCode ?? error.code}`;
|
|
20917
|
+
const detail = getMessageErrorDetail(error);
|
|
20256
20918
|
bubbles.push(
|
|
20257
|
-
/* @__PURE__ */
|
|
20258
|
-
|
|
20259
|
-
|
|
20260
|
-
|
|
20261
|
-
|
|
20262
|
-
|
|
20263
|
-
|
|
20264
|
-
|
|
20265
|
-
|
|
20266
|
-
|
|
20267
|
-
|
|
20268
|
-
|
|
20269
|
-
|
|
20270
|
-
|
|
20271
|
-
|
|
20919
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
20920
|
+
/* @__PURE__ */ jsx(
|
|
20921
|
+
MessageBubble,
|
|
20922
|
+
{
|
|
20923
|
+
createdBy: chatbotName,
|
|
20924
|
+
createdAt: message.createdAt,
|
|
20925
|
+
type: "Output" /* OUTPUT */,
|
|
20926
|
+
content: [{ text: getMessageErrorText(error) }],
|
|
20927
|
+
files: [],
|
|
20928
|
+
sources: [],
|
|
20929
|
+
chatbotName,
|
|
20930
|
+
userOutput: null,
|
|
20931
|
+
userInput: null
|
|
20932
|
+
}
|
|
20933
|
+
),
|
|
20934
|
+
(detail || error.traceId) && /* @__PURE__ */ jsx(MessageErrorDetails, { detail, traceId: error.traceId })
|
|
20935
|
+
] }, key)
|
|
20272
20936
|
);
|
|
20273
20937
|
});
|
|
20274
20938
|
return bubbles;
|
|
@@ -20294,14 +20958,16 @@ function MessageList({
|
|
|
20294
20958
|
data: thread,
|
|
20295
20959
|
isPending: threadPending,
|
|
20296
20960
|
isFetching: threadFetching,
|
|
20297
|
-
error: threadError
|
|
20961
|
+
error: threadError,
|
|
20962
|
+
refetch: refetchThread
|
|
20298
20963
|
} = useThread({ workspaceId, threadId });
|
|
20299
20964
|
const isRunning = useThreadIsRunning(workspaceId, threadId);
|
|
20300
20965
|
const {
|
|
20301
20966
|
data: messages,
|
|
20302
20967
|
isPending: messagesPending,
|
|
20303
20968
|
isFetching: messagesFetching,
|
|
20304
|
-
error: messagesError
|
|
20969
|
+
error: messagesError,
|
|
20970
|
+
refetch: refetchMessages
|
|
20305
20971
|
} = useMessages(threadId);
|
|
20306
20972
|
const hostBg = applyHostBackgroundOverride ? "chat-main" : "";
|
|
20307
20973
|
const scrollToBottom = useCallback((behavior = "auto") => {
|
|
@@ -20380,7 +21046,19 @@ function MessageList({
|
|
|
20380
21046
|
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: [
|
|
20381
21047
|
/* @__PURE__ */ jsx(AlertTriangle, { className: "h-4 w-4" }),
|
|
20382
21048
|
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Failed to load messages" })
|
|
20383
|
-
] })
|
|
21049
|
+
] }),
|
|
21050
|
+
/* @__PURE__ */ jsx(
|
|
21051
|
+
Button,
|
|
21052
|
+
{
|
|
21053
|
+
size: "sm",
|
|
21054
|
+
variant: "outline",
|
|
21055
|
+
onClick: () => {
|
|
21056
|
+
if (threadError) void refetchThread();
|
|
21057
|
+
if (messagesError) void refetchMessages();
|
|
21058
|
+
},
|
|
21059
|
+
children: "Try again"
|
|
21060
|
+
}
|
|
21061
|
+
)
|
|
20384
21062
|
] }) });
|
|
20385
21063
|
}
|
|
20386
21064
|
if (safeMessages.length === 0 && !hadMessagesBefore) {
|
|
@@ -20523,6 +21201,11 @@ function MessageListSkeleton() {
|
|
|
20523
21201
|
i
|
|
20524
21202
|
)) });
|
|
20525
21203
|
}
|
|
21204
|
+
|
|
21205
|
+
// src/shared/utils/enums.ts
|
|
21206
|
+
var isMember = (e, value) => Object.values(e).includes(value);
|
|
21207
|
+
|
|
21208
|
+
// src/domains/messages/mapper.ts
|
|
20526
21209
|
var {
|
|
20527
21210
|
messageThreadsThreadMessagesIdMessagesResponse: messagesResponseSchema
|
|
20528
21211
|
} = ChatZod;
|
|
@@ -20549,6 +21232,7 @@ function mapMessageValueDtoToModel(dto) {
|
|
|
20549
21232
|
createdByUserId: dto.createdByUserId ?? void 0
|
|
20550
21233
|
};
|
|
20551
21234
|
}
|
|
21235
|
+
var mapMessageValuesDtoToModels = (dtos) => dtos.filter((dto) => isMember(MessageValueType, dto.type)).map(mapMessageValueDtoToModel);
|
|
20552
21236
|
function mapMessageErrorDtoToModel(dto) {
|
|
20553
21237
|
const { error_code, ...rest } = dto;
|
|
20554
21238
|
return {
|
|
@@ -20566,7 +21250,7 @@ function mapMessageDtoToModel(dto) {
|
|
|
20566
21250
|
createdByUserId: dto.createdByUserId ?? void 0,
|
|
20567
21251
|
messageThreadId: dto.messageThreadId ?? void 0,
|
|
20568
21252
|
errors: dto.errors?.map(mapMessageErrorDtoToModel) ?? void 0,
|
|
20569
|
-
values: dto.values
|
|
21253
|
+
values: dto.values && mapMessageValuesDtoToModels(dto.values)
|
|
20570
21254
|
};
|
|
20571
21255
|
}
|
|
20572
21256
|
function mapMessagesDtoToModels(dto) {
|
|
@@ -20682,8 +21366,7 @@ var mapWorkspacesDtoToModels = (arr) => arr.map(mapWorkspaceDtoToModel);
|
|
|
20682
21366
|
function getChatApiBaseUrl() {
|
|
20683
21367
|
try {
|
|
20684
21368
|
const w = window;
|
|
20685
|
-
const
|
|
20686
|
-
const cfg = w?.ssconfig?.Chat_Api_Uri ?? env2?.VITE_CHAT_API_URI;
|
|
21369
|
+
const cfg = w?.ssconfig?.Chat_Api_Uri;
|
|
20687
21370
|
return typeof cfg === "string" && cfg.trim() ? cfg.trim() : "";
|
|
20688
21371
|
} catch {
|
|
20689
21372
|
return "";
|
|
@@ -20696,6 +21379,6 @@ function getUserPhotoUrl(userId) {
|
|
|
20696
21379
|
return `${base2}/users/${userId}/photo`;
|
|
20697
21380
|
}
|
|
20698
21381
|
|
|
20699
|
-
export { ChatProvider, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, 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, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useIsDraftThreadId, useMessages, useModels, useSendMessage, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
|
|
21382
|
+
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 };
|
|
20700
21383
|
//# sourceMappingURL=index.js.map
|
|
20701
21384
|
//# sourceMappingURL=index.js.map
|