@smartspace/chat-ui 1.14.0-main.5f4f2ef → 1.14.0-main.8966fe7
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/LICENSE +21 -0
- package/dist/index.d.ts +29 -5
- package/dist/index.js +166 -32
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Smartspace.ai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
CHANGED
|
@@ -259,6 +259,8 @@ type Variables = Record<string, {
|
|
|
259
259
|
}>;
|
|
260
260
|
type MentionUser = {
|
|
261
261
|
id: string;
|
|
262
|
+
/** AppUser id (the principal id used by thread-membership endpoints). */
|
|
263
|
+
userId: string;
|
|
262
264
|
displayName: string;
|
|
263
265
|
initials: string;
|
|
264
266
|
};
|
|
@@ -277,7 +279,6 @@ type Workspace = {
|
|
|
277
279
|
firstPrompt: string;
|
|
278
280
|
outputSchema?: unknown;
|
|
279
281
|
inputs?: unknown;
|
|
280
|
-
isPromptAndResponseLoggingEnabled: boolean;
|
|
281
282
|
variables: Variables;
|
|
282
283
|
sandBoxThreadId?: string;
|
|
283
284
|
supportsFiles: boolean;
|
|
@@ -583,6 +584,11 @@ declare const workspaceResponseSchema: z.ZodObject<{
|
|
|
583
584
|
triggers: z.ZodArray<z.ZodObject<{
|
|
584
585
|
dataSourceContainer: z.ZodObject<{
|
|
585
586
|
dataSourceId: z.ZodString;
|
|
587
|
+
filters: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
588
|
+
operator: z.ZodString;
|
|
589
|
+
propertyName: z.ZodString;
|
|
590
|
+
value: z.ZodString;
|
|
591
|
+
}, z.core.$strip>>>>;
|
|
586
592
|
id: z.ZodString;
|
|
587
593
|
name: z.ZodString;
|
|
588
594
|
path: z.ZodString;
|
|
@@ -623,7 +629,6 @@ declare const workspaceResponseSchema: z.ZodObject<{
|
|
|
623
629
|
inputs: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
624
630
|
schema: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
625
631
|
}, z.core.$strip>>;
|
|
626
|
-
isPromptAndResponseLoggingEnabled: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
627
632
|
modelConfigurations: z.ZodArray<z.ZodObject<{
|
|
628
633
|
frequencyPenalty: z.ZodNumber;
|
|
629
634
|
model: z.ZodObject<{
|
|
@@ -814,6 +819,11 @@ declare const workspacesListResponseSchema: z.ZodObject<{
|
|
|
814
819
|
triggers: z.ZodArray<z.ZodObject<{
|
|
815
820
|
dataSourceContainer: z.ZodObject<{
|
|
816
821
|
dataSourceId: z.ZodString;
|
|
822
|
+
filters: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
823
|
+
operator: z.ZodString;
|
|
824
|
+
propertyName: z.ZodString;
|
|
825
|
+
value: z.ZodString;
|
|
826
|
+
}, z.core.$strip>>>>;
|
|
817
827
|
id: z.ZodString;
|
|
818
828
|
name: z.ZodString;
|
|
819
829
|
path: z.ZodString;
|
|
@@ -854,7 +864,6 @@ declare const workspacesListResponseSchema: z.ZodObject<{
|
|
|
854
864
|
inputs: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
855
865
|
schema: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
856
866
|
}, z.core.$strip>>;
|
|
857
|
-
isPromptAndResponseLoggingEnabled: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
858
867
|
modelConfigurations: z.ZodArray<z.ZodObject<{
|
|
859
868
|
frequencyPenalty: z.ZodNumber;
|
|
860
869
|
model: z.ZodObject<{
|
|
@@ -1013,6 +1022,19 @@ declare function unmarkDraftThreadId(threadId: string): void;
|
|
|
1013
1022
|
declare function isDraftThreadId(threadId?: string | null): boolean;
|
|
1014
1023
|
declare function createDraftThreadId(): string;
|
|
1015
1024
|
|
|
1025
|
+
/**
|
|
1026
|
+
* Safe wrapper around `crypto.randomUUID()` with a timestamp-based fallback
|
|
1027
|
+
* for environments that don't expose the Web Crypto API (e.g. non-secure
|
|
1028
|
+
* contexts, old Node test runners, JSDOM without the flag).
|
|
1029
|
+
*
|
|
1030
|
+
* The fallback is intentionally detectable: IDs start with the current
|
|
1031
|
+
* millisecond timestamp, making it trivially obvious in logs/tests when the
|
|
1032
|
+
* real API is unavailable. It is not cryptographically strong — use it only
|
|
1033
|
+
* for transient optimistic-UI identifiers that are discarded once the server
|
|
1034
|
+
* responds.
|
|
1035
|
+
*/
|
|
1036
|
+
declare function randomUUID(): string;
|
|
1037
|
+
|
|
1016
1038
|
/**
|
|
1017
1039
|
* Treat an API date string as UTC even when it lacks a trailing "Z".
|
|
1018
1040
|
* If already a Date, returns it as-is (Date stores UTC internally).
|
|
@@ -1211,7 +1233,9 @@ type AddInputArgs = {
|
|
|
1211
1233
|
channels: Record<string, number> | null;
|
|
1212
1234
|
};
|
|
1213
1235
|
declare function useAddInputToMessage(): {
|
|
1214
|
-
addInputToMessageMutation: _tanstack_react_query.UseMutationResult<Message, Error, AddInputArgs,
|
|
1236
|
+
addInputToMessageMutation: _tanstack_react_query.UseMutationResult<Message, Error, AddInputArgs, {
|
|
1237
|
+
previousMessages: Message[];
|
|
1238
|
+
}>;
|
|
1215
1239
|
};
|
|
1216
1240
|
|
|
1217
1241
|
declare const threadDetailOptions: ({ service, workspaceId, threadId, }: {
|
|
@@ -1312,4 +1336,4 @@ declare function useModels({ search, take, skip, }?: {
|
|
|
1312
1336
|
total: number;
|
|
1313
1337
|
}, Error>;
|
|
1314
1338
|
|
|
1315
|
-
export { type ChatContextIds, type ChatIdentity, ChatProvider, type ChatProviderProps, type ChatService, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, type FileInfo$1 as FileInfo, type FileScope, type FlowRunVariables, MarkdownEditor, type MarkdownEditorHandle, type MentionUser, type Message, MessageComposer, type MessageComposerProps, type MessageContentItem, type MessageError, MessageList, type MessageListProps, MessageListSkeleton, MessageMarkdown, type MessageThread, type MessageValue, MessageValueType, type Model, type ModelProperty, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, type ThreadsResponse, type Variables, type Workspace, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getModelIcon, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, setThreadOptimisticRunning, setThreadRunningInLists, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useMessages, useModels, useSendMessage, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
|
|
1339
|
+
export { type ChatContextIds, type ChatIdentity, ChatProvider, type ChatProviderProps, type ChatService, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, type FileInfo$1 as FileInfo, type FileScope, type FlowRunVariables, MarkdownEditor, type MarkdownEditorHandle, type MentionUser, type Message, MessageComposer, type MessageComposerProps, type MessageContentItem, type MessageError, MessageList, type MessageListProps, MessageListSkeleton, MessageMarkdown, type MessageThread, type MessageValue, MessageValueType, type Model, type ModelProperty, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, type ThreadsResponse, type Variables, type Workspace, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getModelIcon, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, randomUUID, setThreadOptimisticRunning, setThreadRunningInLists, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useMessages, useModels, useSendMessage, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import MuiButton from '@mui/material/Button';
|
|
2
2
|
import IconButton from '@mui/material/IconButton';
|
|
3
3
|
import { Loader2, Check, X, Paperclip, ArrowBigUp, Minimize2, AlertTriangle, FileImage, FileVideo, FileAudio, FileArchive, FileCode, FileSpreadsheet, Presentation, FileText, ChevronUp, ExternalLink, Copy, Download } from 'lucide-react';
|
|
4
|
-
import * as
|
|
4
|
+
import * as React9 from 'react';
|
|
5
5
|
import { createContext, forwardRef, useImperativeHandle, useRef, useState, useEffect, useMemo, useCallback, createElement, useContext } from 'react';
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
7
|
import { useQuery, queryOptions, useQueryClient, useMutation, skipToken } from '@tanstack/react-query';
|
|
@@ -756,7 +756,7 @@ var mention = $node("mention", () => ({
|
|
|
756
756
|
match: (node2) => node2.type.name === "mention",
|
|
757
757
|
runner: (state, node2) => {
|
|
758
758
|
const { id, label } = node2.attrs;
|
|
759
|
-
state.addNode("
|
|
759
|
+
state.addNode("text", void 0, label || `@${id}`);
|
|
760
760
|
}
|
|
761
761
|
}
|
|
762
762
|
}));
|
|
@@ -1687,7 +1687,7 @@ var buttonVariants = cva(
|
|
|
1687
1687
|
}
|
|
1688
1688
|
}
|
|
1689
1689
|
);
|
|
1690
|
-
var Button =
|
|
1690
|
+
var Button = React9.forwardRef(
|
|
1691
1691
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
1692
1692
|
const Comp = asChild ? Slot : "button";
|
|
1693
1693
|
return /* @__PURE__ */ jsx(
|
|
@@ -2902,6 +2902,128 @@ var modelIdRendererTester = rankWith(
|
|
|
2902
2902
|
}
|
|
2903
2903
|
);
|
|
2904
2904
|
var ModelIdRendererControl = withJsonFormsControlProps(ModelIdRenderer);
|
|
2905
|
+
var NumberRenderer = ({
|
|
2906
|
+
data,
|
|
2907
|
+
handleChange,
|
|
2908
|
+
path: path2,
|
|
2909
|
+
label,
|
|
2910
|
+
description,
|
|
2911
|
+
errors,
|
|
2912
|
+
schema,
|
|
2913
|
+
uischema,
|
|
2914
|
+
visible,
|
|
2915
|
+
enabled,
|
|
2916
|
+
required
|
|
2917
|
+
}) => {
|
|
2918
|
+
const isInteger = schema?.type === "integer";
|
|
2919
|
+
const handleInputChange = useCallback(
|
|
2920
|
+
(event) => {
|
|
2921
|
+
const raw2 = event.target.value;
|
|
2922
|
+
if (raw2 === "") {
|
|
2923
|
+
handleChange(path2, void 0);
|
|
2924
|
+
return;
|
|
2925
|
+
}
|
|
2926
|
+
const parsed = isInteger ? parseInt(raw2, 10) : parseFloat(raw2);
|
|
2927
|
+
if (Number.isNaN(parsed)) {
|
|
2928
|
+
handleChange(path2, void 0);
|
|
2929
|
+
return;
|
|
2930
|
+
}
|
|
2931
|
+
handleChange(path2, parsed);
|
|
2932
|
+
},
|
|
2933
|
+
[handleChange, path2, isInteger]
|
|
2934
|
+
);
|
|
2935
|
+
if (!visible) return null;
|
|
2936
|
+
const readOnly = uischema?.access === "Read";
|
|
2937
|
+
const isDisabled = !enabled || readOnly;
|
|
2938
|
+
const hasError = !!errors && errors.length > 0;
|
|
2939
|
+
const fieldSchema = schema;
|
|
2940
|
+
const min = fieldSchema?.minimum;
|
|
2941
|
+
const max = fieldSchema?.maximum;
|
|
2942
|
+
const step = isInteger ? 1 : fieldSchema?.multipleOf ?? "any";
|
|
2943
|
+
return /* @__PURE__ */ jsxs(
|
|
2944
|
+
"div",
|
|
2945
|
+
{
|
|
2946
|
+
className: "ss-jsonforms-field ss-jsonforms-number",
|
|
2947
|
+
style: {
|
|
2948
|
+
display: "inline-flex",
|
|
2949
|
+
flexDirection: "row",
|
|
2950
|
+
alignItems: "center",
|
|
2951
|
+
gap: 8,
|
|
2952
|
+
minHeight: "40px"
|
|
2953
|
+
},
|
|
2954
|
+
children: [
|
|
2955
|
+
label && /* @__PURE__ */ jsxs(
|
|
2956
|
+
"label",
|
|
2957
|
+
{
|
|
2958
|
+
htmlFor: `number-${path2}`,
|
|
2959
|
+
style: {
|
|
2960
|
+
color: hasError ? "#ef4444" : "#475569",
|
|
2961
|
+
fontSize: "0.875rem",
|
|
2962
|
+
fontWeight: 500,
|
|
2963
|
+
whiteSpace: "nowrap",
|
|
2964
|
+
lineHeight: "24px"
|
|
2965
|
+
},
|
|
2966
|
+
children: [
|
|
2967
|
+
label,
|
|
2968
|
+
required && /* @__PURE__ */ jsx("span", { style: { color: "#ef4444", marginLeft: "0.25rem" }, children: "*" })
|
|
2969
|
+
]
|
|
2970
|
+
}
|
|
2971
|
+
),
|
|
2972
|
+
/* @__PURE__ */ jsx(
|
|
2973
|
+
"input",
|
|
2974
|
+
{
|
|
2975
|
+
id: `number-${path2}`,
|
|
2976
|
+
type: "number",
|
|
2977
|
+
value: data ?? "",
|
|
2978
|
+
onChange: handleInputChange,
|
|
2979
|
+
disabled: isDisabled,
|
|
2980
|
+
min,
|
|
2981
|
+
max,
|
|
2982
|
+
step,
|
|
2983
|
+
style: {
|
|
2984
|
+
width: "80px",
|
|
2985
|
+
height: "24px",
|
|
2986
|
+
padding: "0 0.5rem",
|
|
2987
|
+
border: hasError ? "2px solid #ef4444" : "1px solid #d1d5db",
|
|
2988
|
+
borderRadius: "6px",
|
|
2989
|
+
fontSize: "0.875rem",
|
|
2990
|
+
lineHeight: "24px",
|
|
2991
|
+
fontFamily: "inherit",
|
|
2992
|
+
backgroundColor: isDisabled ? "#f9fafb" : "#ffffff",
|
|
2993
|
+
color: isDisabled ? "#9ca3af" : "#111827",
|
|
2994
|
+
outline: "none",
|
|
2995
|
+
boxSizing: "border-box"
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
),
|
|
2999
|
+
hasError && /* @__PURE__ */ jsx(
|
|
3000
|
+
"div",
|
|
3001
|
+
{
|
|
3002
|
+
style: {
|
|
3003
|
+
color: "#ef4444",
|
|
3004
|
+
fontSize: "0.75rem"
|
|
3005
|
+
},
|
|
3006
|
+
children: errors
|
|
3007
|
+
}
|
|
3008
|
+
)
|
|
3009
|
+
]
|
|
3010
|
+
}
|
|
3011
|
+
);
|
|
3012
|
+
};
|
|
3013
|
+
var numberRendererTester = rankWith(
|
|
3014
|
+
40,
|
|
3015
|
+
(uischema, schema) => {
|
|
3016
|
+
if (uischema.type !== "Control") return false;
|
|
3017
|
+
const propertyPath = uischema.scope.replace(
|
|
3018
|
+
"#/properties/",
|
|
3019
|
+
""
|
|
3020
|
+
);
|
|
3021
|
+
const fieldSchema = schema?.properties?.[propertyPath];
|
|
3022
|
+
if (!fieldSchema) return false;
|
|
3023
|
+
return fieldSchema.type === "integer" || fieldSchema.type === "number";
|
|
3024
|
+
}
|
|
3025
|
+
);
|
|
3026
|
+
var NumberRendererControl = withJsonFormsControlProps(NumberRenderer);
|
|
2905
3027
|
var TextareaRenderer = ({
|
|
2906
3028
|
data,
|
|
2907
3029
|
handleChange,
|
|
@@ -3071,6 +3193,7 @@ var renderers = [
|
|
|
3071
3193
|
{ tester: modelIdRendererTester, renderer: ModelIdRendererControl },
|
|
3072
3194
|
{ tester: booleanRendererTester, renderer: BooleanRendererControl },
|
|
3073
3195
|
{ tester: dropdownRendererTester, renderer: DropdownRendererControl },
|
|
3196
|
+
{ tester: numberRendererTester, renderer: NumberRendererControl },
|
|
3074
3197
|
{ tester: textareaRendererTester, renderer: TextareaRendererControl },
|
|
3075
3198
|
...vanillaRenderers,
|
|
3076
3199
|
{ tester: jsonEditorTester, renderer: JsonEditorRendererControl }
|
|
@@ -3124,26 +3247,26 @@ function useChatVariablesFormVm({
|
|
|
3124
3247
|
const { mutate: updateVariableMutation } = useUpdateFlowRunVariable();
|
|
3125
3248
|
const querySettled = !isLoading && (threadVars !== void 0 || isError);
|
|
3126
3249
|
const shouldUseDefaults = isError || threadVars && Object.keys(threadVars).length === 0;
|
|
3127
|
-
const built =
|
|
3250
|
+
const built = React9.useMemo(() => {
|
|
3128
3251
|
return buildSimpleSchemaAndUi(
|
|
3129
3252
|
workspace.variables,
|
|
3130
3253
|
threadVars,
|
|
3131
3254
|
shouldUseDefaults ?? false
|
|
3132
3255
|
);
|
|
3133
3256
|
}, [workspace.variables, threadVars, shouldUseDefaults]);
|
|
3134
|
-
const [data, setData] =
|
|
3135
|
-
|
|
3257
|
+
const [data, setData] = React9.useState(null);
|
|
3258
|
+
React9.useEffect(() => {
|
|
3136
3259
|
if (querySettled) {
|
|
3137
3260
|
setData(built.initialData);
|
|
3138
3261
|
setVariables(built.initialData);
|
|
3139
3262
|
}
|
|
3140
3263
|
}, [querySettled, built.initialData, setVariables]);
|
|
3141
|
-
const ajv =
|
|
3142
|
-
const prevRef =
|
|
3143
|
-
|
|
3264
|
+
const ajv = React9.useMemo(() => createAjv({ useDefaults: false }), []);
|
|
3265
|
+
const prevRef = React9.useRef(null);
|
|
3266
|
+
React9.useEffect(() => {
|
|
3144
3267
|
prevRef.current = data;
|
|
3145
3268
|
}, [data]);
|
|
3146
|
-
const onChange =
|
|
3269
|
+
const onChange = React9.useCallback(
|
|
3147
3270
|
({ data: next2 }) => {
|
|
3148
3271
|
if (prevRef.current && !isDraftThreadId(threadId)) {
|
|
3149
3272
|
const keys2 = Object.keys(workspace.variables || {});
|
|
@@ -3164,7 +3287,7 @@ function useChatVariablesFormVm({
|
|
|
3164
3287
|
},
|
|
3165
3288
|
[workspace.variables, setVariables, updateVariableMutation, threadId]
|
|
3166
3289
|
);
|
|
3167
|
-
const config =
|
|
3290
|
+
const config = React9.useMemo(
|
|
3168
3291
|
() => ({
|
|
3169
3292
|
restrict: true,
|
|
3170
3293
|
trim: false,
|
|
@@ -3453,6 +3576,12 @@ var useThreadIsRunning = (workspaceId, threadId) => {
|
|
|
3453
3576
|
return !!optimistic || !!(detailThread ?? listThread)?.isFlowRunning;
|
|
3454
3577
|
};
|
|
3455
3578
|
|
|
3579
|
+
// src/shared/utils/randomUUID.ts
|
|
3580
|
+
function randomUUID() {
|
|
3581
|
+
const cryptoObj = globalThis?.crypto;
|
|
3582
|
+
return typeof cryptoObj?.randomUUID === "function" ? cryptoObj.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
3583
|
+
}
|
|
3584
|
+
|
|
3456
3585
|
// src/domains/messages/enums.ts
|
|
3457
3586
|
var MessageValueType = /* @__PURE__ */ ((MessageValueType2) => {
|
|
3458
3587
|
MessageValueType2["OUTPUT"] = "Output";
|
|
@@ -3500,10 +3629,10 @@ function useSendMessage() {
|
|
|
3500
3629
|
if (!threadId) throw new Error("Thread ID is required");
|
|
3501
3630
|
if (!workspaceId) throw new Error("Workspace ID is required");
|
|
3502
3631
|
const optimistic = {
|
|
3503
|
-
id: `temp-${
|
|
3632
|
+
id: `temp-${randomUUID()}`,
|
|
3504
3633
|
values: [
|
|
3505
3634
|
{
|
|
3506
|
-
id: `temp-${
|
|
3635
|
+
id: `temp-${randomUUID()}-prompt`,
|
|
3507
3636
|
type: "Input" /* INPUT */,
|
|
3508
3637
|
name: "prompt",
|
|
3509
3638
|
value: contentList,
|
|
@@ -3514,7 +3643,7 @@ function useSendMessage() {
|
|
|
3514
3643
|
},
|
|
3515
3644
|
...files?.length ? [
|
|
3516
3645
|
{
|
|
3517
|
-
id: `temp-${
|
|
3646
|
+
id: `temp-${randomUUID()}-files`,
|
|
3518
3647
|
type: "Input" /* INPUT */,
|
|
3519
3648
|
name: "files",
|
|
3520
3649
|
value: files,
|
|
@@ -3526,7 +3655,7 @@ function useSendMessage() {
|
|
|
3526
3655
|
] : [],
|
|
3527
3656
|
...variables && Object.keys(variables).length ? [
|
|
3528
3657
|
{
|
|
3529
|
-
id: `temp-${
|
|
3658
|
+
id: `temp-${randomUUID()}-vars`,
|
|
3530
3659
|
type: "Input" /* INPUT */,
|
|
3531
3660
|
name: "variables",
|
|
3532
3661
|
value: variables,
|
|
@@ -3595,8 +3724,9 @@ function useAddInputToMessage() {
|
|
|
3595
3724
|
const { userId, displayName: userName } = useChatIdentity();
|
|
3596
3725
|
const service = useChatService();
|
|
3597
3726
|
const addInputToMessageMutation = useMutation({
|
|
3598
|
-
|
|
3599
|
-
|
|
3727
|
+
onMutate: async ({ threadId, messageId, name, value, channels }) => {
|
|
3728
|
+
await qc.cancelQueries({ queryKey: messagesKeys.list(threadId) });
|
|
3729
|
+
const previousMessages = qc.getQueryData(messagesKeys.list(threadId)) ?? [];
|
|
3600
3730
|
qc.setQueryData(
|
|
3601
3731
|
messagesKeys.list(threadId),
|
|
3602
3732
|
(old = []) => old.map(
|
|
@@ -3605,7 +3735,7 @@ function useAddInputToMessage() {
|
|
|
3605
3735
|
values: [
|
|
3606
3736
|
...m.values ?? [],
|
|
3607
3737
|
{
|
|
3608
|
-
id: `temp-${
|
|
3738
|
+
id: `temp-${randomUUID()}-add`,
|
|
3609
3739
|
type: "Input" /* INPUT */,
|
|
3610
3740
|
name,
|
|
3611
3741
|
value,
|
|
@@ -3618,7 +3748,10 @@ function useAddInputToMessage() {
|
|
|
3618
3748
|
} : m
|
|
3619
3749
|
)
|
|
3620
3750
|
);
|
|
3621
|
-
|
|
3751
|
+
return { previousMessages };
|
|
3752
|
+
},
|
|
3753
|
+
mutationFn: async ({ threadId, messageId, name, value, channels }) => {
|
|
3754
|
+
if (!threadId) throw new Error("Thread ID is required");
|
|
3622
3755
|
return await service.addInputToMessage({
|
|
3623
3756
|
messageId,
|
|
3624
3757
|
name,
|
|
@@ -3632,11 +3765,13 @@ function useAddInputToMessage() {
|
|
|
3632
3765
|
(old = []) => reconcileWithMessage(old, message, "replace")
|
|
3633
3766
|
);
|
|
3634
3767
|
},
|
|
3635
|
-
onError: (_e, { threadId }) => {
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3768
|
+
onError: (_e, { threadId }, context) => {
|
|
3769
|
+
if (context) {
|
|
3770
|
+
qc.setQueryData(
|
|
3771
|
+
messagesKeys.list(threadId),
|
|
3772
|
+
context.previousMessages
|
|
3773
|
+
);
|
|
3774
|
+
}
|
|
3640
3775
|
toast.error("There was an error posting your form input");
|
|
3641
3776
|
},
|
|
3642
3777
|
retry: false
|
|
@@ -19077,7 +19212,7 @@ function getAvatarColour(name) {
|
|
|
19077
19212
|
const textColor = brightness > 128 ? "#000000" : "#FFFFFF";
|
|
19078
19213
|
return { backgroundColor, textColor };
|
|
19079
19214
|
}
|
|
19080
|
-
var Avatar =
|
|
19215
|
+
var Avatar = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
19081
19216
|
"div",
|
|
19082
19217
|
{
|
|
19083
19218
|
ref,
|
|
@@ -19089,7 +19224,7 @@ var Avatar = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
19089
19224
|
}
|
|
19090
19225
|
));
|
|
19091
19226
|
Avatar.displayName = "Avatar";
|
|
19092
|
-
var AvatarImage =
|
|
19227
|
+
var AvatarImage = React9.forwardRef(({ className, alt, src, children: children2, ...props }, _ref) => /* @__PURE__ */ jsx(
|
|
19093
19228
|
MuiAvatar,
|
|
19094
19229
|
{
|
|
19095
19230
|
className: cn("aspect-square h-full w-full", className),
|
|
@@ -19100,7 +19235,7 @@ var AvatarImage = React8.forwardRef(({ className, alt, src, children: children2,
|
|
|
19100
19235
|
}
|
|
19101
19236
|
));
|
|
19102
19237
|
AvatarImage.displayName = "AvatarImage";
|
|
19103
|
-
var AvatarFallback =
|
|
19238
|
+
var AvatarFallback = React9.forwardRef(
|
|
19104
19239
|
({ className, colored = true, ...props }, ref) => {
|
|
19105
19240
|
const childText = String(props.children ?? "");
|
|
19106
19241
|
const colours = colored ? getAvatarColour(childText) : void 0;
|
|
@@ -19690,7 +19825,8 @@ var MessageItem = ({
|
|
|
19690
19825
|
groupType = v.type;
|
|
19691
19826
|
const name = v.name.toLowerCase();
|
|
19692
19827
|
switch (name) {
|
|
19693
|
-
case "variables":
|
|
19828
|
+
case "variables":
|
|
19829
|
+
case "userinfo": {
|
|
19694
19830
|
continue;
|
|
19695
19831
|
}
|
|
19696
19832
|
case "status": {
|
|
@@ -20160,6 +20296,7 @@ var computeAvatar = (name, fallback) => {
|
|
|
20160
20296
|
function mapMentionUserDtoToModel(dto) {
|
|
20161
20297
|
return {
|
|
20162
20298
|
id: dto.id,
|
|
20299
|
+
userId: dto.userId,
|
|
20163
20300
|
displayName: dto.displayName ?? "",
|
|
20164
20301
|
initials: getInitials(dto.displayName ?? "")
|
|
20165
20302
|
};
|
|
@@ -20194,9 +20331,6 @@ function mapWorkspaceDtoToModel(dto) {
|
|
|
20194
20331
|
firstPrompt: dto.firstPrompt ?? "",
|
|
20195
20332
|
outputSchema: dto.outputSchema ?? void 0,
|
|
20196
20333
|
inputs: dto.inputs ?? void 0,
|
|
20197
|
-
isPromptAndResponseLoggingEnabled: truthy(
|
|
20198
|
-
dto.isPromptAndResponseLoggingEnabled
|
|
20199
|
-
),
|
|
20200
20334
|
variables,
|
|
20201
20335
|
sandBoxThreadId: dto.sandBoxThreadId ?? void 0,
|
|
20202
20336
|
supportsFiles: truthy(dto.supportsFiles),
|
|
@@ -20205,6 +20339,6 @@ function mapWorkspaceDtoToModel(dto) {
|
|
|
20205
20339
|
}
|
|
20206
20340
|
var mapWorkspacesDtoToModels = (arr) => arr.map(mapWorkspaceDtoToModel);
|
|
20207
20341
|
|
|
20208
|
-
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, getModelIcon, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, setThreadOptimisticRunning, setThreadRunningInLists, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useMessages, useModels, useSendMessage, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
|
|
20342
|
+
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, getModelIcon, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, randomUUID, setThreadOptimisticRunning, setThreadRunningInLists, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useMessages, useModels, useSendMessage, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
|
|
20209
20343
|
//# sourceMappingURL=index.js.map
|
|
20210
20344
|
//# sourceMappingURL=index.js.map
|