@superinterface/react 2.4.5 → 2.6.0
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.cjs +138 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -21
- package/dist/index.d.ts +50 -21
- package/dist/index.js +134 -19
- package/dist/index.js.map +1 -1
- package/dist/{queryFns.cjs → server.cjs} +437 -172
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +39 -0
- package/dist/server.d.ts +39 -0
- package/dist/server.js +879 -0
- package/dist/server.js.map +1 -0
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +17 -21
- package/dist/types/index.d.ts +17 -21
- package/dist/utils.cjs +54 -252
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +18 -18
- package/dist/utils.d.ts +18 -18
- package/dist/utils.js +42 -244
- package/dist/utils.js.map +1 -1
- package/package.json +2 -1
- package/dist/index-CGpJFXMu.d.cts +0 -5
- package/dist/index-CGpJFXMu.d.ts +0 -5
- package/dist/index-u67QcaWg.d.cts +0 -11
- package/dist/index-u67QcaWg.d.ts +0 -11
- package/dist/mutationFns.cjs +0 -357
- package/dist/mutationFns.cjs.map +0 -1
- package/dist/mutationFns.d.cts +0 -15
- package/dist/mutationFns.d.ts +0 -15
- package/dist/mutationFns.js +0 -287
- package/dist/mutationFns.js.map +0 -1
- package/dist/queryFns.cjs.map +0 -1
- package/dist/queryFns.d.cts +0 -26
- package/dist/queryFns.d.ts +0 -26
- package/dist/queryFns.js +0 -618
- package/dist/queryFns.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { MessagesPage,
|
|
2
|
+
import { MessagesPage, SerializedMessage } from './types/index.cjs';
|
|
3
3
|
import { UseInfiniteQueryOptions, InfiniteData, UseMutationOptions } from '@tanstack/react-query';
|
|
4
|
-
export { u as useSuperinterfaceContext, u as useThreadContext } from './index-u67QcaWg.cjs';
|
|
5
4
|
import * as react from 'react';
|
|
6
5
|
import { Dispatch, SetStateAction } from 'react';
|
|
7
6
|
import * as _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw from '@tanstack/query-core/build/legacy/queryClient-Ho-z40Sw';
|
|
8
7
|
import * as _tanstack_react_query_build_legacy_types from '@tanstack/react-query/build/legacy/types';
|
|
9
8
|
import OpenAI from 'openai';
|
|
10
9
|
|
|
10
|
+
declare const options: {
|
|
11
|
+
get: ({ assistantId, }: {
|
|
12
|
+
assistantId: string;
|
|
13
|
+
}) => string | undefined;
|
|
14
|
+
set: ({ assistantId, threadId, }: {
|
|
15
|
+
assistantId: string;
|
|
16
|
+
threadId: string;
|
|
17
|
+
}) => string | undefined;
|
|
18
|
+
};
|
|
19
|
+
|
|
11
20
|
type Args$6 = {
|
|
12
21
|
children: React.ReactNode;
|
|
13
22
|
baseUrl?: string;
|
|
@@ -19,8 +28,28 @@ type Args$6 = {
|
|
|
19
28
|
queries?: UseInfiniteQueryOptions<InfiniteData<MessagesPage>>;
|
|
20
29
|
mutations?: UseMutationOptions;
|
|
21
30
|
};
|
|
31
|
+
threadIdCookieOptions?: typeof options | null;
|
|
32
|
+
};
|
|
33
|
+
declare const SuperinterfaceProvider: ({ children, baseUrl, publicApiKey, variables, defaultOptions, threadIdCookieOptions, }: Args$6) => react_jsx_runtime.JSX.Element;
|
|
34
|
+
|
|
35
|
+
declare const useSuperinterfaceContext: () => {
|
|
36
|
+
baseUrl: string | null;
|
|
37
|
+
variables: Record<string, any>;
|
|
38
|
+
defaultOptions: {
|
|
39
|
+
queries: Record<string, any>;
|
|
40
|
+
mutations: Record<string, any>;
|
|
41
|
+
};
|
|
42
|
+
publicApiKey?: string | undefined;
|
|
43
|
+
threadIdCookieOptions: {
|
|
44
|
+
get: ({ assistantId, }: {
|
|
45
|
+
assistantId: string;
|
|
46
|
+
}) => string | undefined;
|
|
47
|
+
set: ({ assistantId, threadId, }: {
|
|
48
|
+
assistantId: string;
|
|
49
|
+
threadId: string;
|
|
50
|
+
}) => string | undefined;
|
|
51
|
+
} | null;
|
|
22
52
|
};
|
|
23
|
-
declare const SuperinterfaceProvider: ({ children, baseUrl, publicApiKey, variables, defaultOptions, }: Args$6) => react_jsx_runtime.JSX.Element;
|
|
24
53
|
|
|
25
54
|
type Args$5 = Args$6;
|
|
26
55
|
|
|
@@ -40,7 +69,7 @@ declare const Thread: {
|
|
|
40
69
|
style?: react.CSSProperties | undefined;
|
|
41
70
|
}) => react_jsx_runtime.JSX.Element;
|
|
42
71
|
Message: ({ message, }: {
|
|
43
|
-
message:
|
|
72
|
+
message: MessageType;
|
|
44
73
|
}) => react_jsx_runtime.JSX.Element;
|
|
45
74
|
NextPageSkeleton: () => react_jsx_runtime.JSX.Element | null;
|
|
46
75
|
};
|
|
@@ -60,7 +89,7 @@ declare const Thread: {
|
|
|
60
89
|
};
|
|
61
90
|
|
|
62
91
|
declare const useMessages: () => {
|
|
63
|
-
messages:
|
|
92
|
+
messages: SerializedMessage[];
|
|
64
93
|
data: InfiniteData<TQueryFnData, unknown>;
|
|
65
94
|
error: Error;
|
|
66
95
|
isError: true;
|
|
@@ -92,7 +121,7 @@ declare const useMessages: () => {
|
|
|
92
121
|
refetch: (options?: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a0 | undefined) => Promise<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.ag<InfiniteData<TQueryFnData, unknown>, Error>>;
|
|
93
122
|
fetchStatus: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a8;
|
|
94
123
|
} | {
|
|
95
|
-
messages:
|
|
124
|
+
messages: SerializedMessage[];
|
|
96
125
|
data: InfiniteData<TQueryFnData, unknown>;
|
|
97
126
|
error: null;
|
|
98
127
|
isError: false;
|
|
@@ -124,7 +153,7 @@ declare const useMessages: () => {
|
|
|
124
153
|
refetch: (options?: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a0 | undefined) => Promise<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.ag<InfiniteData<TQueryFnData, unknown>, Error>>;
|
|
125
154
|
fetchStatus: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a8;
|
|
126
155
|
} | {
|
|
127
|
-
messages:
|
|
156
|
+
messages: SerializedMessage[];
|
|
128
157
|
data: undefined;
|
|
129
158
|
error: Error;
|
|
130
159
|
isError: true;
|
|
@@ -156,7 +185,7 @@ declare const useMessages: () => {
|
|
|
156
185
|
refetch: (options?: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a0 | undefined) => Promise<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.ag<InfiniteData<TQueryFnData, unknown>, Error>>;
|
|
157
186
|
fetchStatus: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a8;
|
|
158
187
|
} | {
|
|
159
|
-
messages:
|
|
188
|
+
messages: SerializedMessage[];
|
|
160
189
|
data: undefined;
|
|
161
190
|
error: null;
|
|
162
191
|
isError: false;
|
|
@@ -188,7 +217,7 @@ declare const useMessages: () => {
|
|
|
188
217
|
refetch: (options?: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a0 | undefined) => Promise<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.ag<InfiniteData<TQueryFnData, unknown>, Error>>;
|
|
189
218
|
fetchStatus: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a8;
|
|
190
219
|
} | {
|
|
191
|
-
messages:
|
|
220
|
+
messages: SerializedMessage[];
|
|
192
221
|
data: undefined;
|
|
193
222
|
error: null;
|
|
194
223
|
isError: false;
|
|
@@ -222,12 +251,12 @@ declare const useMessages: () => {
|
|
|
222
251
|
};
|
|
223
252
|
|
|
224
253
|
declare const useMessageContext: () => {
|
|
225
|
-
message:
|
|
254
|
+
message: any;
|
|
226
255
|
};
|
|
227
256
|
|
|
228
257
|
declare const useLatestMessage: () => {
|
|
229
|
-
latestMessage:
|
|
230
|
-
messages:
|
|
258
|
+
latestMessage: SerializedMessage;
|
|
259
|
+
messages: SerializedMessage[];
|
|
231
260
|
data: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.B<TQueryFnData, unknown>;
|
|
232
261
|
error: Error;
|
|
233
262
|
isError: true;
|
|
@@ -259,8 +288,8 @@ declare const useLatestMessage: () => {
|
|
|
259
288
|
refetch: (options?: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a0 | undefined) => Promise<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.ag<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.B<TQueryFnData, unknown>, Error>>;
|
|
260
289
|
fetchStatus: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a8;
|
|
261
290
|
} | {
|
|
262
|
-
latestMessage:
|
|
263
|
-
messages:
|
|
291
|
+
latestMessage: SerializedMessage;
|
|
292
|
+
messages: SerializedMessage[];
|
|
264
293
|
data: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.B<TQueryFnData, unknown>;
|
|
265
294
|
error: null;
|
|
266
295
|
isError: false;
|
|
@@ -292,8 +321,8 @@ declare const useLatestMessage: () => {
|
|
|
292
321
|
refetch: (options?: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a0 | undefined) => Promise<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.ag<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.B<TQueryFnData, unknown>, Error>>;
|
|
293
322
|
fetchStatus: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a8;
|
|
294
323
|
} | {
|
|
295
|
-
latestMessage:
|
|
296
|
-
messages:
|
|
324
|
+
latestMessage: SerializedMessage;
|
|
325
|
+
messages: SerializedMessage[];
|
|
297
326
|
data: undefined;
|
|
298
327
|
error: Error;
|
|
299
328
|
isError: true;
|
|
@@ -325,8 +354,8 @@ declare const useLatestMessage: () => {
|
|
|
325
354
|
refetch: (options?: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a0 | undefined) => Promise<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.ag<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.B<TQueryFnData, unknown>, Error>>;
|
|
326
355
|
fetchStatus: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a8;
|
|
327
356
|
} | {
|
|
328
|
-
latestMessage:
|
|
329
|
-
messages:
|
|
357
|
+
latestMessage: SerializedMessage;
|
|
358
|
+
messages: SerializedMessage[];
|
|
330
359
|
data: undefined;
|
|
331
360
|
error: null;
|
|
332
361
|
isError: false;
|
|
@@ -358,8 +387,8 @@ declare const useLatestMessage: () => {
|
|
|
358
387
|
refetch: (options?: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a0 | undefined) => Promise<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.ag<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.B<TQueryFnData, unknown>, Error>>;
|
|
359
388
|
fetchStatus: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a8;
|
|
360
389
|
} | {
|
|
361
|
-
latestMessage:
|
|
362
|
-
messages:
|
|
390
|
+
latestMessage: SerializedMessage;
|
|
391
|
+
messages: SerializedMessage[];
|
|
363
392
|
data: undefined;
|
|
364
393
|
error: null;
|
|
365
394
|
isError: false;
|
|
@@ -604,4 +633,4 @@ type Args = {
|
|
|
604
633
|
};
|
|
605
634
|
declare const FunctionBase: ({ fn, runStep, title, }: Args) => react_jsx_runtime.JSX.Element;
|
|
606
635
|
|
|
607
|
-
export { AssistantAvatarContext, AssistantNameContext, AudioThread, AudioThreadDialog, FunctionBase, FunctionComponentsContext, MarkdownContext, MarkdownProvider, Suggestions, SuperinterfaceProvider, Thread, ThreadDialog, ThreadDialogContext, useCreateMessage, useLatestMessage, useMarkdownContext, useMessageContext, useMessages, useThreadDialogContext };
|
|
636
|
+
export { AssistantAvatarContext, AssistantNameContext, AudioThread, AudioThreadDialog, FunctionBase, FunctionComponentsContext, MarkdownContext, MarkdownProvider, Suggestions, SuperinterfaceProvider, Thread, ThreadDialog, ThreadDialogContext, useCreateMessage, useLatestMessage, useMarkdownContext, useMessageContext, useMessages, useSuperinterfaceContext, useSuperinterfaceContext as useThreadContext, useThreadDialogContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { MessagesPage,
|
|
2
|
+
import { MessagesPage, SerializedMessage } from './types/index.js';
|
|
3
3
|
import { UseInfiniteQueryOptions, InfiniteData, UseMutationOptions } from '@tanstack/react-query';
|
|
4
|
-
export { u as useSuperinterfaceContext, u as useThreadContext } from './index-u67QcaWg.js';
|
|
5
4
|
import * as react from 'react';
|
|
6
5
|
import { Dispatch, SetStateAction } from 'react';
|
|
7
6
|
import * as _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw from '@tanstack/query-core/build/legacy/queryClient-Ho-z40Sw';
|
|
8
7
|
import * as _tanstack_react_query_build_legacy_types from '@tanstack/react-query/build/legacy/types';
|
|
9
8
|
import OpenAI from 'openai';
|
|
10
9
|
|
|
10
|
+
declare const options: {
|
|
11
|
+
get: ({ assistantId, }: {
|
|
12
|
+
assistantId: string;
|
|
13
|
+
}) => string | undefined;
|
|
14
|
+
set: ({ assistantId, threadId, }: {
|
|
15
|
+
assistantId: string;
|
|
16
|
+
threadId: string;
|
|
17
|
+
}) => string | undefined;
|
|
18
|
+
};
|
|
19
|
+
|
|
11
20
|
type Args$6 = {
|
|
12
21
|
children: React.ReactNode;
|
|
13
22
|
baseUrl?: string;
|
|
@@ -19,8 +28,28 @@ type Args$6 = {
|
|
|
19
28
|
queries?: UseInfiniteQueryOptions<InfiniteData<MessagesPage>>;
|
|
20
29
|
mutations?: UseMutationOptions;
|
|
21
30
|
};
|
|
31
|
+
threadIdCookieOptions?: typeof options | null;
|
|
32
|
+
};
|
|
33
|
+
declare const SuperinterfaceProvider: ({ children, baseUrl, publicApiKey, variables, defaultOptions, threadIdCookieOptions, }: Args$6) => react_jsx_runtime.JSX.Element;
|
|
34
|
+
|
|
35
|
+
declare const useSuperinterfaceContext: () => {
|
|
36
|
+
baseUrl: string | null;
|
|
37
|
+
variables: Record<string, any>;
|
|
38
|
+
defaultOptions: {
|
|
39
|
+
queries: Record<string, any>;
|
|
40
|
+
mutations: Record<string, any>;
|
|
41
|
+
};
|
|
42
|
+
publicApiKey?: string | undefined;
|
|
43
|
+
threadIdCookieOptions: {
|
|
44
|
+
get: ({ assistantId, }: {
|
|
45
|
+
assistantId: string;
|
|
46
|
+
}) => string | undefined;
|
|
47
|
+
set: ({ assistantId, threadId, }: {
|
|
48
|
+
assistantId: string;
|
|
49
|
+
threadId: string;
|
|
50
|
+
}) => string | undefined;
|
|
51
|
+
} | null;
|
|
22
52
|
};
|
|
23
|
-
declare const SuperinterfaceProvider: ({ children, baseUrl, publicApiKey, variables, defaultOptions, }: Args$6) => react_jsx_runtime.JSX.Element;
|
|
24
53
|
|
|
25
54
|
type Args$5 = Args$6;
|
|
26
55
|
|
|
@@ -40,7 +69,7 @@ declare const Thread: {
|
|
|
40
69
|
style?: react.CSSProperties | undefined;
|
|
41
70
|
}) => react_jsx_runtime.JSX.Element;
|
|
42
71
|
Message: ({ message, }: {
|
|
43
|
-
message:
|
|
72
|
+
message: MessageType;
|
|
44
73
|
}) => react_jsx_runtime.JSX.Element;
|
|
45
74
|
NextPageSkeleton: () => react_jsx_runtime.JSX.Element | null;
|
|
46
75
|
};
|
|
@@ -60,7 +89,7 @@ declare const Thread: {
|
|
|
60
89
|
};
|
|
61
90
|
|
|
62
91
|
declare const useMessages: () => {
|
|
63
|
-
messages:
|
|
92
|
+
messages: SerializedMessage[];
|
|
64
93
|
data: InfiniteData<TQueryFnData, unknown>;
|
|
65
94
|
error: Error;
|
|
66
95
|
isError: true;
|
|
@@ -92,7 +121,7 @@ declare const useMessages: () => {
|
|
|
92
121
|
refetch: (options?: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a0 | undefined) => Promise<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.ag<InfiniteData<TQueryFnData, unknown>, Error>>;
|
|
93
122
|
fetchStatus: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a8;
|
|
94
123
|
} | {
|
|
95
|
-
messages:
|
|
124
|
+
messages: SerializedMessage[];
|
|
96
125
|
data: InfiniteData<TQueryFnData, unknown>;
|
|
97
126
|
error: null;
|
|
98
127
|
isError: false;
|
|
@@ -124,7 +153,7 @@ declare const useMessages: () => {
|
|
|
124
153
|
refetch: (options?: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a0 | undefined) => Promise<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.ag<InfiniteData<TQueryFnData, unknown>, Error>>;
|
|
125
154
|
fetchStatus: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a8;
|
|
126
155
|
} | {
|
|
127
|
-
messages:
|
|
156
|
+
messages: SerializedMessage[];
|
|
128
157
|
data: undefined;
|
|
129
158
|
error: Error;
|
|
130
159
|
isError: true;
|
|
@@ -156,7 +185,7 @@ declare const useMessages: () => {
|
|
|
156
185
|
refetch: (options?: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a0 | undefined) => Promise<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.ag<InfiniteData<TQueryFnData, unknown>, Error>>;
|
|
157
186
|
fetchStatus: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a8;
|
|
158
187
|
} | {
|
|
159
|
-
messages:
|
|
188
|
+
messages: SerializedMessage[];
|
|
160
189
|
data: undefined;
|
|
161
190
|
error: null;
|
|
162
191
|
isError: false;
|
|
@@ -188,7 +217,7 @@ declare const useMessages: () => {
|
|
|
188
217
|
refetch: (options?: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a0 | undefined) => Promise<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.ag<InfiniteData<TQueryFnData, unknown>, Error>>;
|
|
189
218
|
fetchStatus: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a8;
|
|
190
219
|
} | {
|
|
191
|
-
messages:
|
|
220
|
+
messages: SerializedMessage[];
|
|
192
221
|
data: undefined;
|
|
193
222
|
error: null;
|
|
194
223
|
isError: false;
|
|
@@ -222,12 +251,12 @@ declare const useMessages: () => {
|
|
|
222
251
|
};
|
|
223
252
|
|
|
224
253
|
declare const useMessageContext: () => {
|
|
225
|
-
message:
|
|
254
|
+
message: any;
|
|
226
255
|
};
|
|
227
256
|
|
|
228
257
|
declare const useLatestMessage: () => {
|
|
229
|
-
latestMessage:
|
|
230
|
-
messages:
|
|
258
|
+
latestMessage: SerializedMessage;
|
|
259
|
+
messages: SerializedMessage[];
|
|
231
260
|
data: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.B<TQueryFnData, unknown>;
|
|
232
261
|
error: Error;
|
|
233
262
|
isError: true;
|
|
@@ -259,8 +288,8 @@ declare const useLatestMessage: () => {
|
|
|
259
288
|
refetch: (options?: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a0 | undefined) => Promise<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.ag<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.B<TQueryFnData, unknown>, Error>>;
|
|
260
289
|
fetchStatus: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a8;
|
|
261
290
|
} | {
|
|
262
|
-
latestMessage:
|
|
263
|
-
messages:
|
|
291
|
+
latestMessage: SerializedMessage;
|
|
292
|
+
messages: SerializedMessage[];
|
|
264
293
|
data: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.B<TQueryFnData, unknown>;
|
|
265
294
|
error: null;
|
|
266
295
|
isError: false;
|
|
@@ -292,8 +321,8 @@ declare const useLatestMessage: () => {
|
|
|
292
321
|
refetch: (options?: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a0 | undefined) => Promise<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.ag<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.B<TQueryFnData, unknown>, Error>>;
|
|
293
322
|
fetchStatus: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a8;
|
|
294
323
|
} | {
|
|
295
|
-
latestMessage:
|
|
296
|
-
messages:
|
|
324
|
+
latestMessage: SerializedMessage;
|
|
325
|
+
messages: SerializedMessage[];
|
|
297
326
|
data: undefined;
|
|
298
327
|
error: Error;
|
|
299
328
|
isError: true;
|
|
@@ -325,8 +354,8 @@ declare const useLatestMessage: () => {
|
|
|
325
354
|
refetch: (options?: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a0 | undefined) => Promise<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.ag<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.B<TQueryFnData, unknown>, Error>>;
|
|
326
355
|
fetchStatus: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a8;
|
|
327
356
|
} | {
|
|
328
|
-
latestMessage:
|
|
329
|
-
messages:
|
|
357
|
+
latestMessage: SerializedMessage;
|
|
358
|
+
messages: SerializedMessage[];
|
|
330
359
|
data: undefined;
|
|
331
360
|
error: null;
|
|
332
361
|
isError: false;
|
|
@@ -358,8 +387,8 @@ declare const useLatestMessage: () => {
|
|
|
358
387
|
refetch: (options?: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a0 | undefined) => Promise<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.ag<_tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.B<TQueryFnData, unknown>, Error>>;
|
|
359
388
|
fetchStatus: _tanstack_query_core_build_legacy_queryClient_Ho_z40Sw.a8;
|
|
360
389
|
} | {
|
|
361
|
-
latestMessage:
|
|
362
|
-
messages:
|
|
390
|
+
latestMessage: SerializedMessage;
|
|
391
|
+
messages: SerializedMessage[];
|
|
363
392
|
data: undefined;
|
|
364
393
|
error: null;
|
|
365
394
|
isError: false;
|
|
@@ -604,4 +633,4 @@ type Args = {
|
|
|
604
633
|
};
|
|
605
634
|
declare const FunctionBase: ({ fn, runStep, title, }: Args) => react_jsx_runtime.JSX.Element;
|
|
606
635
|
|
|
607
|
-
export { AssistantAvatarContext, AssistantNameContext, AudioThread, AudioThreadDialog, FunctionBase, FunctionComponentsContext, MarkdownContext, MarkdownProvider, Suggestions, SuperinterfaceProvider, Thread, ThreadDialog, ThreadDialogContext, useCreateMessage, useLatestMessage, useMarkdownContext, useMessageContext, useMessages, useThreadDialogContext };
|
|
636
|
+
export { AssistantAvatarContext, AssistantNameContext, AudioThread, AudioThreadDialog, FunctionBase, FunctionComponentsContext, MarkdownContext, MarkdownProvider, Suggestions, SuperinterfaceProvider, Thread, ThreadDialog, ThreadDialogContext, useCreateMessage, useLatestMessage, useMarkdownContext, useMessageContext, useMessages, useSuperinterfaceContext, useSuperinterfaceContext as useThreadContext, useThreadDialogContext };
|
package/dist/index.js
CHANGED
|
@@ -285,13 +285,46 @@ var merge = function(obj) {
|
|
|
285
285
|
};
|
|
286
286
|
// src/contexts/core/SuperinterfaceContext/index.tsx
|
|
287
287
|
import { createContext } from "react";
|
|
288
|
+
// src/lib/superinterfaceCloud/baseUrl.ts
|
|
289
|
+
var baseUrl = "https://superinterface.ai/api/cloud";
|
|
290
|
+
// src/lib/threadIdCookies/options/get.ts
|
|
291
|
+
import Cookies from "js-cookie";
|
|
292
|
+
// src/lib/threadIdCookies/key.ts
|
|
293
|
+
var key = function(param) {
|
|
294
|
+
var assistantId = param.assistantId;
|
|
295
|
+
return "superinterface-".concat(assistantId, "-threadId");
|
|
296
|
+
};
|
|
297
|
+
// src/lib/threadIdCookies/options/get.ts
|
|
298
|
+
var get = function(param) {
|
|
299
|
+
var assistantId = param.assistantId;
|
|
300
|
+
return Cookies.get(key({
|
|
301
|
+
assistantId: assistantId
|
|
302
|
+
}));
|
|
303
|
+
};
|
|
304
|
+
// src/lib/threadIdCookies/options/set.ts
|
|
305
|
+
import Cookies2 from "js-cookie";
|
|
306
|
+
var set = function(param) {
|
|
307
|
+
var assistantId = param.assistantId, threadId = param.threadId;
|
|
308
|
+
return Cookies2.set(key({
|
|
309
|
+
assistantId: assistantId
|
|
310
|
+
}), threadId, {
|
|
311
|
+
expires: 270
|
|
312
|
+
});
|
|
313
|
+
};
|
|
314
|
+
// src/lib/threadIdCookies/options/index.ts
|
|
315
|
+
var options = {
|
|
316
|
+
get: get,
|
|
317
|
+
set: set
|
|
318
|
+
};
|
|
319
|
+
// src/contexts/core/SuperinterfaceContext/index.tsx
|
|
288
320
|
var SuperinterfaceContext = createContext({
|
|
289
|
-
baseUrl:
|
|
321
|
+
baseUrl: baseUrl,
|
|
290
322
|
variables: {},
|
|
291
323
|
defaultOptions: {
|
|
292
324
|
queries: {},
|
|
293
325
|
mutations: {}
|
|
294
|
-
}
|
|
326
|
+
},
|
|
327
|
+
threadIdCookieOptions: options
|
|
295
328
|
});
|
|
296
329
|
// src/hooks/core/useSuperinterfaceContext/index.ts
|
|
297
330
|
import { useContext } from "react";
|
|
@@ -301,16 +334,18 @@ var useSuperinterfaceContext = function() {
|
|
|
301
334
|
// src/components/core/SuperinterfaceProvider/index.tsx
|
|
302
335
|
import { jsx } from "react/jsx-runtime";
|
|
303
336
|
var SuperinterfaceProvider = function(param) {
|
|
304
|
-
var children = param.children,
|
|
337
|
+
var children = param.children, baseUrl2 = param.baseUrl, publicApiKey = param.publicApiKey, variables = param.variables, defaultOptions = param.defaultOptions, threadIdCookieOptions = param.threadIdCookieOptions;
|
|
305
338
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
306
|
-
var value = merge(superinterfaceContext, _object_spread({},
|
|
307
|
-
baseUrl:
|
|
339
|
+
var value = merge(superinterfaceContext, _object_spread({}, baseUrl2 ? {
|
|
340
|
+
baseUrl: baseUrl2
|
|
308
341
|
} : {}, publicApiKey ? {
|
|
309
342
|
publicApiKey: publicApiKey
|
|
310
343
|
} : {}, variables ? {
|
|
311
344
|
variables: variables
|
|
312
345
|
} : {}, defaultOptions ? {
|
|
313
346
|
defaultOptions: defaultOptions
|
|
347
|
+
} : {}, threadIdCookieOptions ? {
|
|
348
|
+
threadIdCookieOptions: threadIdCookieOptions
|
|
314
349
|
} : {}));
|
|
315
350
|
return /* @__PURE__ */ jsx(SuperinterfaceContext.Provider, {
|
|
316
351
|
value: value,
|
|
@@ -326,6 +361,30 @@ import { useMemo } from "react";
|
|
|
326
361
|
import { useInfiniteQuery, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
327
362
|
// src/lib/threads/queryOptions/index.ts
|
|
328
363
|
import { infiniteQueryOptions } from "@tanstack/react-query";
|
|
364
|
+
// src/lib/threads/queryOptions/variableParams.ts
|
|
365
|
+
var variableParams = function(param) {
|
|
366
|
+
var variables = param.variables, superinterfaceContext = param.superinterfaceContext;
|
|
367
|
+
var _superinterfaceContext_threadIdCookieOptions;
|
|
368
|
+
console.log({
|
|
369
|
+
variables: variables,
|
|
370
|
+
superinterfaceContext: superinterfaceContext
|
|
371
|
+
});
|
|
372
|
+
if (variables.threadId) return variables;
|
|
373
|
+
if (!variables.assistantId) return variables;
|
|
374
|
+
if (!((_superinterfaceContext_threadIdCookieOptions = superinterfaceContext.threadIdCookieOptions) === null || _superinterfaceContext_threadIdCookieOptions === void 0 ? void 0 : _superinterfaceContext_threadIdCookieOptions.get)) return variables;
|
|
375
|
+
console.log("using");
|
|
376
|
+
var threadId = superinterfaceContext.threadIdCookieOptions.get({
|
|
377
|
+
assistantId: variables.assistantId
|
|
378
|
+
});
|
|
379
|
+
if (!threadId) return variables;
|
|
380
|
+
console.log({
|
|
381
|
+
threadId: threadId
|
|
382
|
+
});
|
|
383
|
+
return _object_spread_props(_object_spread({}, variables), {
|
|
384
|
+
threadId: threadId
|
|
385
|
+
});
|
|
386
|
+
};
|
|
387
|
+
// src/lib/threads/queryOptions/index.ts
|
|
329
388
|
var queryOptions = function(param) {
|
|
330
389
|
var queryKeyBase = param.queryKeyBase, path = param.path, queryClient = param.queryClient, threadContext = param.threadContext, superinterfaceContext = param.superinterfaceContext;
|
|
331
390
|
var queryKey = _to_consumable_array(queryKeyBase).concat([
|
|
@@ -341,12 +400,13 @@ var queryOptions = function(param) {
|
|
|
341
400
|
_queryKey2 = _sliced_to_array(queryKey2, 2), _key = _queryKey2[0], variables = _queryKey2[1];
|
|
342
401
|
params = new URLSearchParams(_object_spread({}, pageParam ? {
|
|
343
402
|
pageParam: pageParam
|
|
344
|
-
} : {},
|
|
403
|
+
} : {}, variableParams({
|
|
404
|
+
variables: variables,
|
|
405
|
+
superinterfaceContext: superinterfaceContext
|
|
406
|
+
})));
|
|
345
407
|
return [
|
|
346
408
|
2,
|
|
347
|
-
fetch("".concat(superinterfaceContext.baseUrl).concat(path, "?").concat(params), _object_spread({
|
|
348
|
-
credentials: "include"
|
|
349
|
-
}, superinterfaceContext.publicApiKey ? {
|
|
409
|
+
fetch("".concat(superinterfaceContext.baseUrl).concat(path, "?").concat(params), _object_spread({}, superinterfaceContext.publicApiKey ? {
|
|
350
410
|
headers: {
|
|
351
411
|
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
352
412
|
}
|
|
@@ -1133,6 +1193,14 @@ var Message = function(param) {
|
|
|
1133
1193
|
}, [
|
|
1134
1194
|
message
|
|
1135
1195
|
]), 2), olderRunSteps = _useMemo4[0], laterRunSteps = _useMemo4[1];
|
|
1196
|
+
var isInProgress = useMemo4(function() {
|
|
1197
|
+
if (message.status === "in_progress") return true;
|
|
1198
|
+
return message.runSteps.some(function(rs) {
|
|
1199
|
+
return rs.status === "in_progress";
|
|
1200
|
+
});
|
|
1201
|
+
}, [
|
|
1202
|
+
message
|
|
1203
|
+
]);
|
|
1136
1204
|
return /* @__PURE__ */ jsx30(Provider, {
|
|
1137
1205
|
value: {
|
|
1138
1206
|
message: message
|
|
@@ -1151,7 +1219,7 @@ var Message = function(param) {
|
|
|
1151
1219
|
})
|
|
1152
1220
|
}, index);
|
|
1153
1221
|
}),
|
|
1154
|
-
|
|
1222
|
+
isInProgress && /* @__PURE__ */ jsx30(StartingContentSkeleton, {})
|
|
1155
1223
|
]
|
|
1156
1224
|
}),
|
|
1157
1225
|
/* @__PURE__ */ jsx30(RunSteps, {
|
|
@@ -1569,6 +1637,25 @@ var onMutate = function(param) {
|
|
|
1569
1637
|
};
|
|
1570
1638
|
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/index.ts
|
|
1571
1639
|
import { JSONParser } from "@streamparser/json-whatwg";
|
|
1640
|
+
// src/lib/threadIdCookies/ensure.ts
|
|
1641
|
+
var ensure = function(param) {
|
|
1642
|
+
var superinterfaceContext = param.superinterfaceContext, variables = param.variables, value = param.value;
|
|
1643
|
+
var _superinterfaceContext_threadIdCookieOptions;
|
|
1644
|
+
console.log({
|
|
1645
|
+
value: value,
|
|
1646
|
+
variables: variables,
|
|
1647
|
+
superinterfaceContext: superinterfaceContext
|
|
1648
|
+
});
|
|
1649
|
+
if (!((_superinterfaceContext_threadIdCookieOptions = superinterfaceContext.threadIdCookieOptions) === null || _superinterfaceContext_threadIdCookieOptions === void 0 ? void 0 : _superinterfaceContext_threadIdCookieOptions.set)) return;
|
|
1650
|
+
if (value.value.event !== "thread.run.created") return;
|
|
1651
|
+
if (variables.threadId) return;
|
|
1652
|
+
if (!variables.assistantId) return;
|
|
1653
|
+
console.log("saving");
|
|
1654
|
+
superinterfaceContext.threadIdCookieOptions.set({
|
|
1655
|
+
assistantId: variables.assistantId,
|
|
1656
|
+
threadId: value.value.data.thread_id
|
|
1657
|
+
});
|
|
1658
|
+
};
|
|
1572
1659
|
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/extendMessage.ts
|
|
1573
1660
|
import { last as last2 } from "radash";
|
|
1574
1661
|
var extendMessage = function(param) {
|
|
@@ -1801,9 +1888,9 @@ var updatedToolCall = function(param) {
|
|
|
1801
1888
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1802
1889
|
try {
|
|
1803
1890
|
for(var _iterator = Object.entries(delta.function)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1804
|
-
var _step_value = _sliced_to_array(_step.value, 2),
|
|
1805
|
-
var
|
|
1806
|
-
result.function[
|
|
1891
|
+
var _step_value = _sliced_to_array(_step.value, 2), key2 = _step_value[0], value = _step_value[1];
|
|
1892
|
+
var _result_function_key2;
|
|
1893
|
+
result.function[key2] = "".concat((_result_function_key2 = result.function[key2]) !== null && _result_function_key2 !== void 0 ? _result_function_key2 : "").concat(value);
|
|
1807
1894
|
}
|
|
1808
1895
|
} catch (err) {
|
|
1809
1896
|
_didIteratorError = true;
|
|
@@ -1922,6 +2009,29 @@ var handleResponse = function(param) {
|
|
|
1922
2009
|
value: value.value
|
|
1923
2010
|
}));
|
|
1924
2011
|
};
|
|
2012
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/body.ts
|
|
2013
|
+
var body = function(param) {
|
|
2014
|
+
var variables = param.variables, superinterfaceContext = param.superinterfaceContext;
|
|
2015
|
+
var _superinterfaceContext_threadIdCookieOptions;
|
|
2016
|
+
console.log({
|
|
2017
|
+
variables: variables,
|
|
2018
|
+
superinterfaceContext: superinterfaceContext
|
|
2019
|
+
});
|
|
2020
|
+
if (variables.threadId) return variables;
|
|
2021
|
+
if (!variables.assistantId) return variables;
|
|
2022
|
+
if (!((_superinterfaceContext_threadIdCookieOptions = superinterfaceContext.threadIdCookieOptions) === null || _superinterfaceContext_threadIdCookieOptions === void 0 ? void 0 : _superinterfaceContext_threadIdCookieOptions.get)) return variables;
|
|
2023
|
+
console.log("using");
|
|
2024
|
+
var threadId = superinterfaceContext.threadIdCookieOptions.get({
|
|
2025
|
+
assistantId: variables.assistantId
|
|
2026
|
+
});
|
|
2027
|
+
if (!threadId) return variables;
|
|
2028
|
+
console.log({
|
|
2029
|
+
threadId: threadId
|
|
2030
|
+
});
|
|
2031
|
+
return _object_spread_props(_object_spread({}, variables), {
|
|
2032
|
+
threadId: threadId
|
|
2033
|
+
});
|
|
2034
|
+
};
|
|
1925
2035
|
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/index.ts
|
|
1926
2036
|
var mutationFn = function(param) {
|
|
1927
2037
|
var superinterfaceContext = param.superinterfaceContext, queryClient = param.queryClient, threadContext = param.threadContext;
|
|
@@ -1935,8 +2045,10 @@ var mutationFn = function(param) {
|
|
|
1935
2045
|
4,
|
|
1936
2046
|
fetch("".concat(superinterfaceContext.baseUrl, "/messages"), _object_spread({
|
|
1937
2047
|
method: "POST",
|
|
1938
|
-
body: JSON.stringify(
|
|
1939
|
-
|
|
2048
|
+
body: JSON.stringify(body({
|
|
2049
|
+
variables: variables,
|
|
2050
|
+
superinterfaceContext: superinterfaceContext
|
|
2051
|
+
}))
|
|
1940
2052
|
}, superinterfaceContext.publicApiKey ? {
|
|
1941
2053
|
headers: {
|
|
1942
2054
|
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
@@ -1981,6 +2093,11 @@ var mutationFn = function(param) {
|
|
|
1981
2093
|
messagesQueryKey: messagesQueryKey,
|
|
1982
2094
|
queryClient: queryClient
|
|
1983
2095
|
});
|
|
2096
|
+
ensure({
|
|
2097
|
+
superinterfaceContext: superinterfaceContext,
|
|
2098
|
+
variables: variables,
|
|
2099
|
+
value: value
|
|
2100
|
+
});
|
|
1984
2101
|
return [
|
|
1985
2102
|
3,
|
|
1986
2103
|
2
|
|
@@ -2934,13 +3051,11 @@ var useMessageAudio = function(param) {
|
|
|
2934
3051
|
}
|
|
2935
3052
|
}
|
|
2936
3053
|
}, isHtmlAudioSupported ? {} : {
|
|
2937
|
-
xhr:
|
|
3054
|
+
xhr: _object_spread({}, superinterfaceContext.publicApiKey ? {
|
|
2938
3055
|
headers: {
|
|
2939
3056
|
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
2940
3057
|
}
|
|
2941
|
-
} : {})
|
|
2942
|
-
withCredentials: true
|
|
2943
|
-
})
|
|
3058
|
+
} : {})
|
|
2944
3059
|
}));
|
|
2945
3060
|
}, [
|
|
2946
3061
|
unplayedMessageSentences,
|