@tambo-ai/react 0.60.0 → 0.62.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/__tests__/util/validate-zod-schema.test.js +25 -0
- package/dist/__tests__/util/validate-zod-schema.test.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +3 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/use-tambo-voice.d.ts +21 -0
- package/dist/hooks/use-tambo-voice.d.ts.map +1 -0
- package/dist/hooks/use-tambo-voice.js +74 -0
- package/dist/hooks/use-tambo-voice.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/__tests__/tambo-mcp-provider.test.js +4 -4
- package/dist/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -1
- package/dist/mcp/tambo-mcp-provider.d.ts +1 -1
- package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/dist/mcp/tambo-mcp-provider.js +2 -2
- package/dist/mcp/tambo-mcp-provider.js.map +1 -1
- package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.js +1 -1
- package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.js.map +1 -1
- package/dist/providers/__tests__/tambo-thread-provider.test.js +170 -0
- package/dist/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
- package/dist/providers/tambo-provider.d.ts +2 -0
- package/dist/providers/tambo-provider.d.ts.map +1 -1
- package/dist/providers/tambo-provider.js +4 -2
- package/dist/providers/tambo-provider.js.map +1 -1
- package/dist/providers/tambo-thread-provider.d.ts +6 -0
- package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
- package/dist/providers/tambo-thread-provider.js +112 -45
- package/dist/providers/tambo-thread-provider.js.map +1 -1
- package/dist/setupTests.js +10 -0
- package/dist/setupTests.js.map +1 -1
- package/dist/util/validate-zod-schema.d.ts.map +1 -1
- package/dist/util/validate-zod-schema.js +11 -0
- package/dist/util/validate-zod-schema.js.map +1 -1
- package/esm/__tests__/util/validate-zod-schema.test.js +25 -0
- package/esm/__tests__/util/validate-zod-schema.test.js.map +1 -1
- package/esm/hooks/index.d.ts +1 -0
- package/esm/hooks/index.d.ts.map +1 -1
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/index.js.map +1 -1
- package/esm/hooks/use-tambo-voice.d.ts +21 -0
- package/esm/hooks/use-tambo-voice.d.ts.map +1 -0
- package/esm/hooks/use-tambo-voice.js +71 -0
- package/esm/hooks/use-tambo-voice.js.map +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/mcp/__tests__/tambo-mcp-provider.test.js +4 -4
- package/esm/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -1
- package/esm/mcp/tambo-mcp-provider.d.ts +1 -1
- package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/esm/mcp/tambo-mcp-provider.js +2 -2
- package/esm/mcp/tambo-mcp-provider.js.map +1 -1
- package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.js +1 -1
- package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.js.map +1 -1
- package/esm/providers/__tests__/tambo-thread-provider.test.js +170 -0
- package/esm/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
- package/esm/providers/tambo-provider.d.ts +2 -0
- package/esm/providers/tambo-provider.d.ts.map +1 -1
- package/esm/providers/tambo-provider.js +4 -2
- package/esm/providers/tambo-provider.js.map +1 -1
- package/esm/providers/tambo-thread-provider.d.ts +6 -0
- package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
- package/esm/providers/tambo-thread-provider.js +112 -45
- package/esm/providers/tambo-thread-provider.js.map +1 -1
- package/esm/setupTests.js +10 -0
- package/esm/setupTests.js.map +1 -1
- package/esm/util/validate-zod-schema.d.ts.map +1 -1
- package/esm/util/validate-zod-schema.js +11 -0
- package/esm/util/validate-zod-schema.js.map +1 -1
- package/package.json +5 -4
|
@@ -80,6 +80,10 @@ export interface TamboThreadProviderProps {
|
|
|
80
80
|
streaming?: boolean;
|
|
81
81
|
/** Initial messages to be included in new threads */
|
|
82
82
|
initialMessages?: InitialTamboThreadMessage[];
|
|
83
|
+
/** Whether to automatically generate thread names. Defaults to true. */
|
|
84
|
+
autoGenerateThreadName?: boolean;
|
|
85
|
+
/** The message count threshold at which the thread name will be auto-generated. Defaults to 3. */
|
|
86
|
+
autoGenerateNameThreshold?: number;
|
|
83
87
|
}
|
|
84
88
|
/**
|
|
85
89
|
* The TamboThreadProvider is a React provider that provides a thread context
|
|
@@ -88,6 +92,8 @@ export interface TamboThreadProviderProps {
|
|
|
88
92
|
* @param props.children - The children to wrap
|
|
89
93
|
* @param props.streaming - Whether to stream the response by default. Defaults to true.
|
|
90
94
|
* @param props.initialMessages - Initial messages to be included in new threads
|
|
95
|
+
* @param props.autoGenerateThreadName - Whether to automatically generate thread names. Defaults to true.
|
|
96
|
+
* @param props.autoGenerateNameThreshold - The message count threshold at which the thread name will be auto-generated. Defaults to 3.
|
|
91
97
|
* @returns The TamboThreadProvider component
|
|
92
98
|
*/
|
|
93
99
|
export declare const TamboThreadProvider: React.FC<PropsWithChildren<TamboThreadProviderProps>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-thread-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-thread-provider.tsx"],"names":[],"mappings":"AACA,OAAO,OAA0B,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,yDAAyD,CAAC;AACjF,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAOlB,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,eAAe,EAEf,kBAAkB,EACnB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAu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AM,CAAC;IACnB,8DAA8D;IAC9D,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACxC,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,qCAAqC;IACrC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qDAAqD;IACrD,eAAe,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC9C,wEAAwE;IACxE,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,kGAAkG;IAClG,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CACxC,iBAAiB,CAAC,wBAAwB,CAAC,CA69B5C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,QAAO,gCAU1C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAO,+BAgBjC,CAAC"}
|
|
@@ -142,9 +142,11 @@ exports.TamboThreadContext = (0, react_1.createContext)({
|
|
|
142
142
|
* @param props.children - The children to wrap
|
|
143
143
|
* @param props.streaming - Whether to stream the response by default. Defaults to true.
|
|
144
144
|
* @param props.initialMessages - Initial messages to be included in new threads
|
|
145
|
+
* @param props.autoGenerateThreadName - Whether to automatically generate thread names. Defaults to true.
|
|
146
|
+
* @param props.autoGenerateNameThreshold - The message count threshold at which the thread name will be auto-generated. Defaults to 3.
|
|
145
147
|
* @returns The TamboThreadProvider component
|
|
146
148
|
*/
|
|
147
|
-
const TamboThreadProvider = ({ children, streaming = true, initialMessages = [] }) => {
|
|
149
|
+
const TamboThreadProvider = ({ children, streaming = true, initialMessages = [], autoGenerateThreadName = true, autoGenerateNameThreshold = 3, }) => {
|
|
148
150
|
// Create placeholder thread with initial messages
|
|
149
151
|
const placeholderThread = (0, react_1.useMemo)(() => ({
|
|
150
152
|
id: "placeholder",
|
|
@@ -188,29 +190,48 @@ const TamboThreadProvider = ({ children, streaming = true, initialMessages = []
|
|
|
188
190
|
(0, react_1.useEffect)(() => {
|
|
189
191
|
ignoreResponseRef.current = ignoreResponse;
|
|
190
192
|
}, [ignoreResponse]);
|
|
191
|
-
const
|
|
193
|
+
const updateThreadsCache = (0, react_1.useCallback)(async (updateFn, contextKey) => {
|
|
192
194
|
try {
|
|
193
195
|
const currentProject = await client.beta.projects.getCurrent();
|
|
194
|
-
|
|
195
|
-
...exports.PLACEHOLDER_THREAD,
|
|
196
|
-
id: threadId,
|
|
197
|
-
createdAt: new Date().toISOString(),
|
|
198
|
-
updatedAt: new Date().toISOString(),
|
|
199
|
-
};
|
|
200
|
-
queryClient.setQueryData(["threads", currentProject.id, contextKey], (old) => {
|
|
201
|
-
return {
|
|
202
|
-
...old,
|
|
203
|
-
items: [optimisticThread, ...(old?.items ?? [])],
|
|
204
|
-
};
|
|
205
|
-
});
|
|
196
|
+
queryClient.setQueryData(["threads", currentProject.id, contextKey], updateFn);
|
|
206
197
|
await queryClient.invalidateQueries({
|
|
207
198
|
queryKey: ["threads"],
|
|
208
199
|
});
|
|
209
200
|
}
|
|
210
201
|
catch (error) {
|
|
211
|
-
console.warn("Failed to
|
|
202
|
+
console.warn("Failed to update threads cache:", error);
|
|
212
203
|
}
|
|
213
204
|
}, [client.beta.projects, queryClient]);
|
|
205
|
+
const addThreadToCache = (0, react_1.useCallback)(async (threadId, contextKey) => {
|
|
206
|
+
const optimisticThread = {
|
|
207
|
+
...exports.PLACEHOLDER_THREAD,
|
|
208
|
+
id: threadId,
|
|
209
|
+
createdAt: new Date().toISOString(),
|
|
210
|
+
updatedAt: new Date().toISOString(),
|
|
211
|
+
};
|
|
212
|
+
await updateThreadsCache((old) => {
|
|
213
|
+
if (!old)
|
|
214
|
+
return old;
|
|
215
|
+
return {
|
|
216
|
+
...old,
|
|
217
|
+
items: [optimisticThread, ...(old.items ?? [])],
|
|
218
|
+
total: (old.total ?? 0) + 1,
|
|
219
|
+
count: (old.count ?? 0) + 1,
|
|
220
|
+
};
|
|
221
|
+
}, contextKey);
|
|
222
|
+
}, [updateThreadsCache]);
|
|
223
|
+
const updateThreadInCache = (0, react_1.useCallback)(async (threadId, updateFn, contextKey) => {
|
|
224
|
+
await updateThreadsCache((old) => {
|
|
225
|
+
if (!old?.items)
|
|
226
|
+
return old;
|
|
227
|
+
return {
|
|
228
|
+
...old,
|
|
229
|
+
items: old.items.map((thread) => thread.id === threadId ? updateFn(thread) : thread),
|
|
230
|
+
total: old.total,
|
|
231
|
+
count: old.count,
|
|
232
|
+
};
|
|
233
|
+
}, contextKey);
|
|
234
|
+
}, [updateThreadsCache]);
|
|
214
235
|
const fetchThread = (0, react_1.useCallback)(async (threadId) => {
|
|
215
236
|
const thread = await client.beta.threads.retrieve(threadId);
|
|
216
237
|
const threadWithRenderedComponents = {
|
|
@@ -324,6 +345,63 @@ const TamboThreadProvider = ({ children, streaming = true, initialMessages = []
|
|
|
324
345
|
});
|
|
325
346
|
}
|
|
326
347
|
}, [client.beta.threads.messages]);
|
|
348
|
+
const generateThreadName = (0, react_1.useCallback)(async (threadId, contextKey) => {
|
|
349
|
+
threadId ??= currentThreadId;
|
|
350
|
+
if (threadId === placeholderThread.id) {
|
|
351
|
+
console.warn("Cannot generate name for empty thread");
|
|
352
|
+
return threadMap[threadId];
|
|
353
|
+
}
|
|
354
|
+
const threadWithGeneratedName = await client.beta.threads.generateName(threadId);
|
|
355
|
+
// Update local thread state
|
|
356
|
+
setThreadMap((prevMap) => {
|
|
357
|
+
if (!prevMap[threadId]) {
|
|
358
|
+
return prevMap;
|
|
359
|
+
}
|
|
360
|
+
return {
|
|
361
|
+
...prevMap,
|
|
362
|
+
[threadId]: {
|
|
363
|
+
...prevMap[threadId],
|
|
364
|
+
name: threadWithGeneratedName.name,
|
|
365
|
+
},
|
|
366
|
+
};
|
|
367
|
+
});
|
|
368
|
+
// Update threads cache to reflect the new name in the UI
|
|
369
|
+
await updateThreadInCache(threadId, (thread) => ({
|
|
370
|
+
...thread,
|
|
371
|
+
name: threadWithGeneratedName.name,
|
|
372
|
+
}), contextKey);
|
|
373
|
+
return threadWithGeneratedName;
|
|
374
|
+
}, [
|
|
375
|
+
client.beta.threads,
|
|
376
|
+
currentThreadId,
|
|
377
|
+
threadMap,
|
|
378
|
+
placeholderThread.id,
|
|
379
|
+
updateThreadInCache,
|
|
380
|
+
]);
|
|
381
|
+
const maybeAutoGenerateThreadName = (0, react_1.useCallback)((threadId, contextKey) => {
|
|
382
|
+
// Use setThreadMap to access the latest state
|
|
383
|
+
setThreadMap((map) => {
|
|
384
|
+
const thread = map[threadId];
|
|
385
|
+
if (!thread || !autoGenerateThreadName) {
|
|
386
|
+
return map;
|
|
387
|
+
}
|
|
388
|
+
if (autoGenerateNameThreshold == null ||
|
|
389
|
+
thread.id === placeholderThread.id) {
|
|
390
|
+
return map;
|
|
391
|
+
}
|
|
392
|
+
const messageCount = thread.messages.length;
|
|
393
|
+
// Only auto-generate if thread has no name and threshold is met
|
|
394
|
+
if (!thread.name && messageCount >= autoGenerateNameThreshold) {
|
|
395
|
+
generateThreadName(threadId, contextKey);
|
|
396
|
+
}
|
|
397
|
+
return map;
|
|
398
|
+
});
|
|
399
|
+
}, [
|
|
400
|
+
autoGenerateThreadName,
|
|
401
|
+
autoGenerateNameThreshold,
|
|
402
|
+
placeholderThread.id,
|
|
403
|
+
generateThreadName,
|
|
404
|
+
]);
|
|
327
405
|
const startNewThread = (0, react_1.useCallback)(() => {
|
|
328
406
|
setCurrentThreadId(placeholderThread.id);
|
|
329
407
|
setThreadMap((prevMap) => {
|
|
@@ -354,27 +432,6 @@ const TamboThreadProvider = ({ children, streaming = true, initialMessages = []
|
|
|
354
432
|
client.beta.threads,
|
|
355
433
|
placeholderThread.id,
|
|
356
434
|
]);
|
|
357
|
-
const generateThreadName = (0, react_1.useCallback)(async (threadId) => {
|
|
358
|
-
threadId ??= currentThreadId;
|
|
359
|
-
if (threadId === placeholderThread.id) {
|
|
360
|
-
console.warn("Cannot generate name for empty thread");
|
|
361
|
-
return threadMap[threadId];
|
|
362
|
-
}
|
|
363
|
-
const threadWithGeneratedName = await client.beta.threads.generateName(threadId);
|
|
364
|
-
setThreadMap((prevMap) => {
|
|
365
|
-
if (!prevMap[threadId]) {
|
|
366
|
-
return prevMap;
|
|
367
|
-
}
|
|
368
|
-
return {
|
|
369
|
-
...prevMap,
|
|
370
|
-
[threadId]: {
|
|
371
|
-
...prevMap[threadId],
|
|
372
|
-
name: threadWithGeneratedName.name,
|
|
373
|
-
},
|
|
374
|
-
};
|
|
375
|
-
});
|
|
376
|
-
return threadWithGeneratedName;
|
|
377
|
-
}, [client.beta.threads, currentThreadId, threadMap, placeholderThread.id]);
|
|
378
435
|
const switchCurrentThread = (0, react_1.useCallback)(async (threadId, fetch = true) => {
|
|
379
436
|
if (threadId === placeholderThread.id) {
|
|
380
437
|
console.warn("Switching to placeholder thread, may be a bug.");
|
|
@@ -540,9 +597,11 @@ const TamboThreadProvider = ({ children, streaming = true, initialMessages = []
|
|
|
540
597
|
const wasPlaceholderThread = currentThreadId === exports.PLACEHOLDER_THREAD.id;
|
|
541
598
|
await switchCurrentThread(chunk.responseMessageDto.threadId, false);
|
|
542
599
|
// If we're switching from placeholder to a real thread
|
|
543
|
-
// this means a new thread was created, so
|
|
600
|
+
// this means a new thread was created, so add it to cache
|
|
544
601
|
if (wasPlaceholderThread) {
|
|
545
|
-
await
|
|
602
|
+
await addThreadToCache(chunk.responseMessageDto.threadId, contextKey);
|
|
603
|
+
// Check if we should auto-generate name for the newly created thread
|
|
604
|
+
maybeAutoGenerateThreadName(chunk.responseMessageDto.threadId, contextKey);
|
|
546
605
|
}
|
|
547
606
|
}
|
|
548
607
|
if (!finalMessage) {
|
|
@@ -566,7 +625,9 @@ const TamboThreadProvider = ({ children, streaming = true, initialMessages = []
|
|
|
566
625
|
}
|
|
567
626
|
}
|
|
568
627
|
}
|
|
569
|
-
|
|
628
|
+
const completedThreadId = finalMessage?.threadId ?? threadId;
|
|
629
|
+
updateThreadStatus(completedThreadId, generate_component_response_1.GenerationStage.COMPLETE);
|
|
630
|
+
maybeAutoGenerateThreadName(completedThreadId, contextKey);
|
|
570
631
|
return (finalMessage ?? {
|
|
571
632
|
threadId: "",
|
|
572
633
|
content: [{ type: "text", text: `Error processing stream` }],
|
|
@@ -577,12 +638,13 @@ const TamboThreadProvider = ({ children, streaming = true, initialMessages = []
|
|
|
577
638
|
});
|
|
578
639
|
}, [
|
|
579
640
|
addThreadMessage,
|
|
641
|
+
addThreadToCache,
|
|
642
|
+
maybeAutoGenerateThreadName,
|
|
580
643
|
client,
|
|
581
644
|
componentList,
|
|
582
645
|
currentThread?.id,
|
|
583
646
|
currentThreadId,
|
|
584
647
|
onCallUnregisteredTool,
|
|
585
|
-
refetchThreadsList,
|
|
586
648
|
setMcpAccessToken,
|
|
587
649
|
switchCurrentThread,
|
|
588
650
|
toolRegistry,
|
|
@@ -617,6 +679,7 @@ const TamboThreadProvider = ({ children, streaming = true, initialMessages = []
|
|
|
617
679
|
componentState: {},
|
|
618
680
|
additionalContext: combinedContext,
|
|
619
681
|
}, false);
|
|
682
|
+
maybeAutoGenerateThreadName(threadId, contextKey);
|
|
620
683
|
const availableComponents = (0, registry_1.getAvailableComponents)(componentList, toolRegistry, componentToolAssociations);
|
|
621
684
|
const unassociatedTools = (0, registry_1.getUnassociatedTools)(toolRegistry, componentToolAssociations);
|
|
622
685
|
// Track tool call counts for this message processing
|
|
@@ -651,7 +714,8 @@ const TamboThreadProvider = ({ children, streaming = true, initialMessages = []
|
|
|
651
714
|
throw error;
|
|
652
715
|
}
|
|
653
716
|
try {
|
|
654
|
-
|
|
717
|
+
const result = await handleAdvanceStream(advanceStreamResponse, params, threadId, contextKey);
|
|
718
|
+
return result;
|
|
655
719
|
}
|
|
656
720
|
catch (error) {
|
|
657
721
|
updateThreadStatus(threadId, generate_component_response_1.GenerationStage.ERROR);
|
|
@@ -729,11 +793,13 @@ const TamboThreadProvider = ({ children, streaming = true, initialMessages = []
|
|
|
729
793
|
const wasPlaceholderThread = currentThreadId === exports.PLACEHOLDER_THREAD.id;
|
|
730
794
|
await switchCurrentThread(advanceResponse.responseMessageDto.threadId);
|
|
731
795
|
// If we're switching from placeholder to a real thread
|
|
732
|
-
// this means a new thread was created, so
|
|
796
|
+
// this means a new thread was created, so add it to cache
|
|
733
797
|
if (wasPlaceholderThread) {
|
|
734
|
-
await
|
|
798
|
+
await addThreadToCache(advanceResponse.responseMessageDto.threadId, contextKey);
|
|
735
799
|
}
|
|
736
|
-
|
|
800
|
+
const completedThreadId = advanceResponse.responseMessageDto.threadId;
|
|
801
|
+
updateThreadStatus(completedThreadId, generate_component_response_1.GenerationStage.COMPLETE);
|
|
802
|
+
maybeAutoGenerateThreadName(completedThreadId, contextKey);
|
|
737
803
|
return finalMessage;
|
|
738
804
|
}, [
|
|
739
805
|
componentList,
|
|
@@ -751,7 +817,8 @@ const TamboThreadProvider = ({ children, streaming = true, initialMessages = []
|
|
|
751
817
|
placeholderThread.id,
|
|
752
818
|
initialMessages,
|
|
753
819
|
onCallUnregisteredTool,
|
|
754
|
-
|
|
820
|
+
addThreadToCache,
|
|
821
|
+
maybeAutoGenerateThreadName,
|
|
755
822
|
setMcpAccessToken,
|
|
756
823
|
]);
|
|
757
824
|
return (react_1.default.createElement(exports.TamboThreadContext.Provider, { value: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-thread-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-thread-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,6DAAkE;AAElE,+CASe;AAEf,sFAI8C;AAE9C,yDAA+C;AAC/C,mEAAwE;AACxE,+CAI0B;AAC1B,qDAAqD;AACrD,mEAA8E;AAC9E,qFAA0E;AAC1E,yEAA8D;AAC9D,uEAA6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@tambo-ai/typescript-sdk/resources/beta/threads/threads\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { TamboTool } from \"../model/component-metadata\";\nimport {\n GenerationStage,\n isIdleStage,\n TamboThreadMessage,\n} from \"../model/generate-component-response\";\nimport { TamboThread } from \"../model/tambo-thread\";\nimport { toText } from \"../util/content-parts\";\nimport { renderComponentIntoMessage } from \"../util/generate-component\";\nimport {\n getAvailableComponents,\n getUnassociatedTools,\n mapTamboToolToContextTool,\n} from \"../util/registry\";\nimport { handleToolCall } from \"../util/tool-caller\";\nimport { useTamboClient, useTamboQueryClient } from \"./tambo-client-provider\";\nimport { useTamboContextHelpers } from \"./tambo-context-helpers-provider\";\nimport { useTamboMcpToken } from \"./tambo-mcp-token-provider\";\nimport { useTamboRegistry } from \"./tambo-registry-provider\";\n\n// Generation Stage Context - separate from thread context to prevent re-renders\nexport interface TamboGenerationStageContextProps {\n generationStage: GenerationStage;\n generationStatusMessage: string;\n isIdle: boolean;\n}\n\nconst TamboGenerationStageContext = createContext<\n TamboGenerationStageContextProps | undefined\n>(undefined);\n\ninterface TamboGenerationStageProviderProps {\n generationStage: GenerationStage;\n statusMessage: string;\n}\n\n/**\n *\n * This provider is used to provide the generation stage context to the descendants of the provider.\n * @param props - The props for the GenerationStageProvider\n * @param props.children - The children to wrap\n * @param props.generationStage - The generation stage to provide\n * @param props.statusMessage - The status message to provide\n * @returns The GenerationStageProvider component\n */\nexport const TamboGenerationStageProvider: React.FC<\n PropsWithChildren<TamboGenerationStageProviderProps>\n> = ({ children, generationStage, statusMessage }) => {\n const isIdle = isIdleStage(generationStage);\n\n const contextValue = useMemo(() => {\n return {\n generationStage,\n generationStatusMessage: statusMessage,\n isIdle,\n };\n }, [generationStage, statusMessage, isIdle]);\n\n return (\n <TamboGenerationStageContext.Provider value={contextValue}>\n {children}\n </TamboGenerationStageContext.Provider>\n );\n};\n\n// Type for partial message updates that requires threadId\ntype PartialTamboThreadMessageWithThreadId = Partial<TamboThreadMessage> & {\n threadId: string;\n};\n\nexport interface TamboThreadContextProps {\n /** The current thread */\n thread: TamboThread;\n /** Switch to a different thread */\n switchCurrentThread: (threadId: string, fetch?: boolean) => void;\n /** Start a new thread */\n startNewThread: () => void;\n /** Update a thread's name */\n updateThreadName: (name: string, threadId?: string) => void;\n /** Let Tambo generate and set a thread's name based on the thread's messages */\n generateThreadName: (threadId?: string) => Promise<Thread>;\n /** Add a message to the current thread */\n addThreadMessage: (\n message: TamboThreadMessage,\n sendToServer: boolean,\n ) => Promise<TamboAI.Beta.Threads.ThreadMessage[]>;\n /** Update a message in the current thread */\n updateThreadMessage: (\n id: string,\n message: PartialTamboThreadMessageWithThreadId,\n sendToServer: boolean,\n ) => Promise<void>;\n /** Cancel a thread */\n cancel: (threadId?: string) => Promise<void>;\n /** Whether the thread is streaming */\n streaming: boolean;\n /** Send a message to the current thread */\n sendThreadMessage: (\n message: string,\n options?: {\n threadId?: string;\n streamResponse?: boolean;\n contextKey?: string;\n forceToolChoice?: string;\n additionalContext?: Record<string, any>;\n content?: TamboAI.Beta.Threads.ChatCompletionContentPart[];\n },\n ) => Promise<TamboThreadMessage>;\n}\n\n// Combined context interface that includes generation stage fields\nexport interface CombinedTamboThreadContextProps\n extends TamboThreadContextProps,\n TamboGenerationStageContextProps {}\n\n/**\n * This is a stub entry for when the thread is not yet created, the first time\n * the user sends a message\n *\n * Note that the consumer needs to be careful never to send `PLACEHOLDER_THREAD.id` to the server,\n * as this doesn't really exist on the server side.\n */\nexport const PLACEHOLDER_THREAD: TamboThread = {\n id: \"placeholder\",\n messages: [],\n createdAt: \"\",\n projectId: \"\",\n updatedAt: \"\",\n metadata: {},\n};\n\nexport const TamboThreadContext = createContext<TamboThreadContextProps>({\n thread: PLACEHOLDER_THREAD,\n /**\n *\n */\n switchCurrentThread: () => {\n throw new Error(\"switchCurrentThread not implemented\");\n },\n /**\n *\n */\n startNewThread: () => {\n throw new Error(\"startNewThread not implemented\");\n },\n /**\n *\n */\n updateThreadName: () => {\n throw new Error(\"updateThreadName not implemented\");\n },\n /**\n *\n */\n generateThreadName: () => {\n throw new Error(\"generateThreadName not implemented\");\n },\n /**\n *\n */\n addThreadMessage: () => {\n throw new Error(\"updateThreadMessageHistory not implemented\");\n },\n streaming: true,\n /**\n *\n */\n updateThreadMessage: () => {\n throw new Error(\"updateThreadMessage not implemented\");\n },\n /**\n *\n */\n sendThreadMessage: () => {\n throw new Error(\"sendThreadMessage not implemented\");\n },\n /**\n *\n */\n cancel: () => {\n throw new Error(\"cancel not implemented\");\n },\n});\n\nexport type InitialTamboThreadMessage = Pick<\n TamboThreadMessage,\n \"role\" | \"content\"\n> & {\n /** Optional ID - will be auto-generated if not provided */\n id?: string;\n /** Optional creation timestamp - will be auto-generated if not provided */\n createdAt?: string;\n /** Optional additional context to include with the message */\n additionalContext?: Record<string, any>;\n /** Optional component state - will default to empty object if not provided */\n componentState?: Record<string, any>;\n};\n\nexport interface TamboThreadProviderProps {\n /** Whether to stream the response */\n streaming?: boolean;\n /** Initial messages to be included in new threads */\n initialMessages?: InitialTamboThreadMessage[];\n}\n\n/**\n * The TamboThreadProvider is a React provider that provides a thread context\n * to the descendants of the provider.\n * @param props - The props for the TamboThreadProvider\n * @param props.children - The children to wrap\n * @param props.streaming - Whether to stream the response by default. Defaults to true.\n * @param props.initialMessages - Initial messages to be included in new threads\n * @returns The TamboThreadProvider component\n */\nexport const TamboThreadProvider: React.FC<\n PropsWithChildren<TamboThreadProviderProps>\n> = ({ children, streaming = true, initialMessages = [] }) => {\n // Create placeholder thread with initial messages\n const placeholderThread: TamboThread = useMemo(\n () => ({\n id: \"placeholder\",\n messages: initialMessages.map((msg) => ({\n ...msg,\n id: msg.id ?? crypto.randomUUID(),\n threadId: \"placeholder\",\n createdAt: msg.createdAt ?? new Date().toISOString(),\n componentState: msg.componentState ?? {},\n })),\n createdAt: \"\",\n projectId: \"\",\n updatedAt: \"\",\n metadata: {},\n }),\n [initialMessages],\n );\n\n const [threadMap, setThreadMap] = useState<Record<string, TamboThread>>({\n [placeholderThread.id]: placeholderThread,\n });\n const client = useTamboClient();\n const queryClient = useTamboQueryClient();\n const {\n componentList,\n toolRegistry,\n componentToolAssociations,\n onCallUnregisteredTool,\n } = useTamboRegistry();\n const { getAdditionalContext } = useTamboContextHelpers();\n const { setMcpAccessToken } = useTamboMcpToken();\n const [ignoreResponse, setIgnoreResponse] = useState(false);\n const ignoreResponseRef = useRef(ignoreResponse);\n const [currentThreadId, setCurrentThreadId] = useState<string>(\n placeholderThread.id,\n );\n const currentThread: TamboThread | undefined = threadMap[currentThreadId];\n\n // Generation stage props for GenerationStageProvider\n const currentGenerationStage =\n (currentThread?.generationStage as GenerationStage) ?? GenerationStage.IDLE;\n const currentStatusMessage = currentThread?.statusMessage ?? \"\";\n\n // Use existing messages from the current thread to avoid re-generating any components\n const currentMessageCache = useMemo(() => {\n const messageCache = new Map<string, TamboThreadMessage>();\n if (currentThread) {\n for (const message of currentThread.messages) {\n messageCache.set(message.id, message);\n }\n }\n return messageCache;\n }, [currentThread]);\n\n useEffect(() => {\n ignoreResponseRef.current = ignoreResponse;\n }, [ignoreResponse]);\n\n const refetchThreadsList = useCallback(\n async (threadId: string, contextKey: string | undefined) => {\n try {\n const currentProject = await client.beta.projects.getCurrent();\n\n const optimisticThread = {\n ...PLACEHOLDER_THREAD,\n id: threadId,\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n };\n\n queryClient.setQueryData(\n [\"threads\", currentProject.id, contextKey],\n (old: TamboAI.Beta.Threads.ThreadsOffsetAndLimit | undefined) => {\n return {\n ...old,\n items: [optimisticThread, ...(old?.items ?? [])],\n };\n },\n );\n\n await queryClient.invalidateQueries({\n queryKey: [\"threads\"],\n });\n } catch (error) {\n console.warn(\"Failed to refetch threads list:\", error);\n }\n },\n [client.beta.projects, queryClient],\n );\n\n const fetchThread = useCallback(\n async (threadId: string) => {\n const thread = await client.beta.threads.retrieve(threadId);\n const threadWithRenderedComponents = {\n ...thread,\n messages: thread.messages.map((message) => {\n if (currentMessageCache.has(message.id)) {\n const renderedMessage = currentMessageCache.get(message.id);\n return {\n ...renderedMessage,\n ...message,\n };\n }\n if (message.component?.componentName) {\n const messageWithComponent = renderComponentIntoMessage(\n message,\n componentList,\n );\n return messageWithComponent;\n }\n return message;\n }),\n };\n\n setThreadMap((prevMap) => {\n const updatedThreadMap = {\n ...prevMap,\n [threadId]: threadWithRenderedComponents,\n };\n return updatedThreadMap;\n });\n },\n [client.beta.threads, componentList, currentMessageCache],\n );\n\n useEffect(() => {\n if (\n currentThreadId &&\n currentThreadId !== placeholderThread.id &&\n !threadMap[currentThreadId]\n ) {\n fetchThread(currentThreadId);\n }\n }, [currentThreadId, fetchThread, threadMap, placeholderThread.id]);\n\n const addThreadMessage = useCallback(\n async (\n message: TamboThreadMessage,\n sendToServer = true,\n createdAt: string = new Date().toISOString(),\n ) => {\n if (!currentThread) {\n console.warn(\"Cannot add messages if we do not have a current thread\");\n return [];\n }\n\n const chatMessage: TamboThreadMessage = {\n ...message,\n createdAt,\n };\n const threadId = message.threadId;\n const messageId = chatMessage.id;\n // optimistically update the thread in the local state\n setThreadMap((prevMap) => {\n if (!threadId) {\n return prevMap;\n }\n const prevMessages = prevMap[threadId]?.messages || [];\n const haveMessage = prevMessages.find((msg) => msg.id === messageId);\n // Update in place if the message already exists\n const updatedMessages = haveMessage\n ? prevMessages.map((msg) => {\n if (msg.id === messageId) {\n return chatMessage;\n }\n return msg;\n })\n : [...prevMessages, chatMessage];\n\n const updatedThreadMap = {\n ...prevMap,\n [threadId]: {\n ...prevMap[threadId],\n messages: updatedMessages,\n },\n };\n return updatedThreadMap;\n });\n\n if (sendToServer) {\n // TODO: if this fails, we need to revert the local state update\n await client.beta.threads.messages.create(message.threadId, {\n content: message.content,\n role: message.role,\n additionalContext: chatMessage.additionalContext,\n });\n }\n return threadMap[threadId]?.messages || [];\n },\n [client.beta.threads.messages, currentThread, threadMap],\n );\n\n const updateThreadMessage = useCallback(\n async (\n id: string,\n message: PartialTamboThreadMessageWithThreadId,\n sendToServer = true,\n createdAt: string = new Date().toISOString(),\n ) => {\n setThreadMap((prevMap) => {\n const prevMessages = prevMap[message.threadId]?.messages || [];\n const updatedMessages = prevMessages.map((msg) => {\n if (msg.id === id) {\n // Merge the partial update with the existing message\n const updatedMessage: TamboThreadMessage = {\n ...msg,\n ...message,\n id: msg.id,\n createdAt: message.createdAt ?? msg.createdAt ?? createdAt,\n };\n return updatedMessage;\n }\n return msg;\n });\n return {\n ...prevMap,\n [message.threadId]: {\n ...prevMap[message.threadId],\n messages: updatedMessages,\n },\n };\n });\n\n if (sendToServer && message.content && message.role) {\n // TODO: if this fails, we need to revert the local state update\n await client.beta.threads.messages.create(message.threadId, {\n content: message.content,\n role: message.role,\n additionalContext: message.additionalContext,\n });\n }\n },\n [client.beta.threads.messages],\n );\n\n const startNewThread = useCallback(() => {\n setCurrentThreadId(placeholderThread.id);\n setThreadMap((prevMap) => {\n return {\n ...prevMap,\n [placeholderThread.id]: placeholderThread,\n };\n });\n }, [placeholderThread]);\n\n const updateThreadName = useCallback(\n async (name: string, threadId?: string) => {\n threadId ??= currentThreadId;\n\n setThreadMap((prevMap) => {\n if (!prevMap[threadId]) {\n return prevMap;\n }\n return { ...prevMap, [threadId]: { ...prevMap[threadId], name } };\n });\n\n if (threadId !== placeholderThread.id) {\n const currentProject = await client.beta.projects.getCurrent();\n await client.beta.threads.update(threadId, {\n name,\n projectId: currentProject.id,\n });\n }\n },\n [\n currentThreadId,\n client.beta.projects,\n client.beta.threads,\n placeholderThread.id,\n ],\n );\n\n const generateThreadName = useCallback(\n async (threadId?: string) => {\n threadId ??= currentThreadId;\n if (threadId === placeholderThread.id) {\n console.warn(\"Cannot generate name for empty thread\");\n return threadMap[threadId];\n }\n\n const threadWithGeneratedName =\n await client.beta.threads.generateName(threadId);\n\n setThreadMap((prevMap) => {\n if (!prevMap[threadId]) {\n return prevMap;\n }\n return {\n ...prevMap,\n [threadId]: {\n ...prevMap[threadId],\n name: threadWithGeneratedName.name,\n },\n };\n });\n return threadWithGeneratedName;\n },\n [client.beta.threads, currentThreadId, threadMap, placeholderThread.id],\n );\n\n const switchCurrentThread = useCallback(\n async (threadId: string, fetch = true) => {\n if (threadId === placeholderThread.id) {\n console.warn(\"Switching to placeholder thread, may be a bug.\");\n return;\n }\n\n setCurrentThreadId(threadId);\n setThreadMap((prevMap) => {\n if (prevMap[threadId]) {\n return prevMap;\n }\n // If this is a new thread, add placeholder thread messages to the thread\n const updatedThreadMap = {\n ...prevMap,\n [threadId]: {\n ...prevMap[placeholderThread.id],\n id: threadId,\n },\n };\n return updatedThreadMap;\n });\n\n if (fetch) {\n await fetchThread(threadId);\n }\n },\n [fetchThread, placeholderThread],\n );\n\n const updateThreadStatus = useCallback(\n (threadId: string, stage: GenerationStage, statusMessage?: string) => {\n setThreadMap((prevMap) => {\n const updatedThreadMap = {\n ...prevMap,\n [threadId]: {\n ...prevMap[threadId],\n generationStage: stage,\n statusMessage: statusMessage,\n },\n };\n return updatedThreadMap;\n });\n },\n [],\n );\n\n const cancel = useCallback(\n async (threadId?: string) => {\n threadId ??= currentThreadId;\n const currentGenerationStage =\n currentThread?.generationStage ?? GenerationStage.IDLE;\n if (isIdleStage(currentGenerationStage as GenerationStage)) {\n return;\n }\n setIgnoreResponse(true);\n setThreadMap((prevMap) => {\n if (!prevMap[threadId]) {\n return prevMap;\n }\n\n return {\n ...prevMap,\n [threadId]: {\n ...prevMap[threadId],\n generationStage: GenerationStage.CANCELLED,\n messages: prevMap[threadId].messages.map((message) => {\n if (\n message.id ===\n prevMap[threadId].messages[\n prevMap[threadId].messages.length - 1\n ].id\n ) {\n return {\n ...message,\n isCancelled: true,\n };\n }\n return message;\n }),\n },\n };\n });\n\n await client.beta.threads.cancel(threadId);\n },\n [client.beta.threads, currentThreadId, currentThread?.generationStage],\n );\n\n const handleAdvanceStream = useCallback(\n async (\n stream: AsyncIterable<TamboAI.Beta.Threads.ThreadAdvanceResponse>,\n params: TamboAI.Beta.Threads.ThreadAdvanceParams,\n threadId: string,\n contextKey?: string,\n ): Promise<TamboThreadMessage> => {\n if (ignoreResponseRef.current) {\n setIgnoreResponse(false);\n return {\n threadId: threadId,\n content: [{ type: \"text\", text: \"\" }],\n role: \"assistant\",\n createdAt: new Date().toISOString(),\n id: crypto.randomUUID(),\n componentState: {},\n };\n }\n let finalMessage: Readonly<TamboThreadMessage> | undefined;\n let hasSetThreadId = false;\n updateThreadStatus(threadId, GenerationStage.STREAMING_RESPONSE);\n\n for await (const chunk of stream) {\n // Update or clear MCP access token\n if (chunk.mcpAccessToken) {\n // note that we're only setting it positively it during streaming, because it might\n // not have been set yet in the chunk (i.e. we're not unsetting it in the chunk)\n setMcpAccessToken(chunk.mcpAccessToken);\n }\n\n if (chunk.responseMessageDto.toolCallRequest) {\n // Increment tool call count for this tool\n const toolName = chunk.responseMessageDto.toolCallRequest.toolName;\n if (toolName && params.toolCallCounts) {\n params.toolCallCounts[toolName] =\n (params.toolCallCounts[toolName] ?? 0) + 1;\n }\n\n updateThreadStatus(\n chunk.responseMessageDto.threadId,\n GenerationStage.FETCHING_CONTEXT,\n );\n\n updateThreadMessage(\n chunk.responseMessageDto.id,\n {\n ...chunk.responseMessageDto,\n },\n false,\n );\n\n const toolCallResponse = await handleToolCall(\n chunk.responseMessageDto,\n toolRegistry,\n onCallUnregisteredTool,\n );\n if (ignoreResponseRef.current) {\n setIgnoreResponse(false);\n {\n return {\n threadId: threadId,\n content: [{ type: \"text\", text: \"\" }],\n role: \"assistant\",\n createdAt: new Date().toISOString(),\n id: crypto.randomUUID(),\n componentState: {},\n };\n }\n }\n const contentParts = await convertToolResponse(toolCallResponse);\n\n const toolCallResponseParams: TamboAI.Beta.Threads.ThreadAdvanceParams =\n {\n ...params,\n messageToAppend: {\n content: contentParts,\n role: \"tool\",\n actionType: \"tool_response\",\n component: chunk.responseMessageDto.component,\n tool_call_id: chunk.responseMessageDto.tool_call_id,\n error: toolCallResponse.error,\n },\n };\n\n updateThreadMessage(\n chunk.responseMessageDto.id,\n {\n ...chunk.responseMessageDto,\n error: toolCallResponse.error,\n },\n false,\n );\n\n addThreadMessage(\n {\n threadId: chunk.responseMessageDto.threadId,\n content: contentParts,\n role: \"tool\",\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n componentState: {},\n actionType: \"tool_response\",\n tool_call_id: chunk.responseMessageDto.tool_call_id,\n error: toolCallResponse.error,\n },\n false,\n );\n\n updateThreadStatus(\n chunk.responseMessageDto.threadId,\n GenerationStage.STREAMING_RESPONSE,\n );\n const toolCallResponseStream = await advanceStream(\n client,\n toolCallResponseParams,\n chunk.responseMessageDto.threadId,\n );\n\n return await handleAdvanceStream(\n toolCallResponseStream,\n toolCallResponseParams,\n chunk.responseMessageDto.threadId,\n contextKey,\n );\n } else {\n if (ignoreResponseRef.current) {\n setIgnoreResponse(false);\n return (\n finalMessage ?? {\n threadId: threadId,\n content: [{ type: \"text\", text: \"\" }],\n role: \"assistant\",\n createdAt: new Date().toISOString(),\n id: crypto.randomUUID(),\n componentState: {},\n }\n );\n }\n if (\n !hasSetThreadId &&\n chunk.responseMessageDto.threadId &&\n chunk.responseMessageDto.threadId !== currentThread?.id\n ) {\n hasSetThreadId = true;\n const wasPlaceholderThread =\n currentThreadId === PLACEHOLDER_THREAD.id;\n await switchCurrentThread(chunk.responseMessageDto.threadId, false);\n\n // If we're switching from placeholder to a real thread\n // this means a new thread was created, so refetch the threads list\n if (wasPlaceholderThread) {\n await refetchThreadsList(\n chunk.responseMessageDto.threadId,\n contextKey,\n );\n }\n }\n\n if (!finalMessage) {\n finalMessage = chunk.responseMessageDto.component?.componentName\n ? renderComponentIntoMessage(\n chunk.responseMessageDto,\n componentList,\n )\n : chunk.responseMessageDto;\n await addThreadMessage(finalMessage, false);\n } else {\n // if we start getting a new message mid-stream, put the previous one on screen\n const isNewMessage =\n chunk.responseMessageDto.id !== finalMessage.id;\n\n finalMessage = chunk.responseMessageDto.component?.componentName\n ? renderComponentIntoMessage(\n chunk.responseMessageDto,\n componentList,\n )\n : chunk.responseMessageDto;\n\n if (isNewMessage) {\n await addThreadMessage(finalMessage, false);\n } else {\n await updateThreadMessage(finalMessage.id, finalMessage, false);\n }\n }\n }\n }\n\n updateThreadStatus(\n finalMessage?.threadId ?? threadId,\n GenerationStage.COMPLETE,\n );\n return (\n finalMessage ?? {\n threadId: \"\",\n content: [{ type: \"text\", text: `Error processing stream` }],\n role: \"assistant\",\n createdAt: new Date().toISOString(),\n id: crypto.randomUUID(),\n componentState: {},\n }\n );\n },\n [\n addThreadMessage,\n client,\n componentList,\n currentThread?.id,\n currentThreadId,\n onCallUnregisteredTool,\n refetchThreadsList,\n setMcpAccessToken,\n switchCurrentThread,\n toolRegistry,\n updateThreadMessage,\n updateThreadStatus,\n ],\n );\n\n const sendThreadMessage = useCallback(\n async (\n message: string,\n options: {\n threadId?: string;\n streamResponse?: boolean;\n forceToolChoice?: string;\n contextKey?: string;\n additionalContext?: Record<string, any>;\n content?: TamboAI.Beta.Threads.ChatCompletionContentPart[];\n } = {},\n ): Promise<TamboThreadMessage> => {\n setIgnoreResponse(false);\n const {\n threadId = currentThreadId ?? placeholderThread.id,\n streamResponse = streaming,\n forceToolChoice,\n contextKey,\n additionalContext,\n content,\n } = options;\n updateThreadStatus(threadId, GenerationStage.FETCHING_CONTEXT);\n\n // Get additional context from enabled helpers\n const helperContexts = await getAdditionalContext();\n\n // Combine all contexts\n const combinedContext: Record<string, any> = {\n ...(additionalContext ?? {}),\n };\n\n // Add helper contexts to combinedContext\n for (const helperContext of helperContexts) {\n combinedContext[helperContext.name] = helperContext.context;\n }\n\n // Use provided content or build simple text message\n const messageContent = content ?? [\n { type: \"text\" as const, text: message },\n ];\n\n addThreadMessage(\n {\n content: messageContent as any,\n renderedComponent: null,\n role: \"user\",\n threadId: threadId,\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n componentState: {},\n additionalContext: combinedContext,\n },\n false,\n );\n\n const availableComponents = getAvailableComponents(\n componentList,\n toolRegistry,\n componentToolAssociations,\n );\n const unassociatedTools = getUnassociatedTools(\n toolRegistry,\n componentToolAssociations,\n );\n\n // Track tool call counts for this message processing\n const toolCallCounts: Record<string, number> = {};\n\n const params: TamboAI.Beta.Threads.ThreadAdvanceParams = {\n messageToAppend: {\n content: messageContent as any,\n role: \"user\",\n additionalContext: combinedContext,\n },\n contextKey,\n availableComponents: availableComponents,\n clientTools: unassociatedTools.map((tool) =>\n mapTamboToolToContextTool(tool),\n ),\n forceToolChoice: forceToolChoice,\n toolCallCounts,\n ...(threadId === placeholderThread.id &&\n initialMessages.length > 0 && {\n initialMessages: initialMessages.map((msg) => ({\n content: msg.content,\n role: msg.role,\n additionalContext: msg.additionalContext,\n })),\n }),\n };\n\n if (streamResponse) {\n let advanceStreamResponse: AsyncIterable<TamboAI.Beta.Threads.ThreadAdvanceResponse>;\n try {\n advanceStreamResponse = await advanceStream(\n client,\n params,\n threadId === placeholderThread.id ? undefined : threadId,\n );\n } catch (error) {\n updateThreadStatus(threadId, GenerationStage.ERROR);\n throw error;\n }\n try {\n return await handleAdvanceStream(\n advanceStreamResponse,\n params,\n threadId,\n contextKey,\n );\n } catch (error) {\n updateThreadStatus(threadId, GenerationStage.ERROR);\n throw error;\n }\n }\n\n let advanceResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse;\n try {\n advanceResponse = await (threadId === placeholderThread.id\n ? client.beta.threads.advance(params)\n : client.beta.threads.advanceByID(threadId, params));\n\n // Update or clear MCP access token\n setMcpAccessToken(advanceResponse.mcpAccessToken ?? null);\n } catch (error) {\n updateThreadStatus(threadId, GenerationStage.ERROR);\n throw error;\n }\n\n //handle tool calls\n try {\n while (advanceResponse.responseMessageDto.toolCallRequest) {\n // Increment tool call count for this tool\n const toolName =\n advanceResponse.responseMessageDto.toolCallRequest.toolName;\n if (toolName) {\n toolCallCounts[toolName] = (toolCallCounts[toolName] || 0) + 1;\n }\n\n updateThreadStatus(threadId, GenerationStage.FETCHING_CONTEXT);\n const toolCallResponse = await handleToolCall(\n advanceResponse.responseMessageDto,\n toolRegistry,\n onCallUnregisteredTool,\n );\n\n const contentParts = await convertToolResponse(toolCallResponse);\n\n const toolCallResponseParams: TamboAI.Beta.Threads.ThreadAdvanceParams =\n {\n ...params,\n messageToAppend: {\n ...params.messageToAppend,\n content: contentParts,\n role: \"tool\",\n actionType: \"tool_response\",\n component: advanceResponse.responseMessageDto.component,\n tool_call_id: advanceResponse.responseMessageDto.tool_call_id,\n error: toolCallResponse.error,\n },\n };\n if (toolCallResponse.error) {\n //update toolcall message with error\n const toolCallMessage = {\n ...advanceResponse.responseMessageDto,\n error: toolCallResponse.error,\n };\n updateThreadMessage(toolCallMessage.id, toolCallMessage, false);\n }\n updateThreadStatus(threadId, GenerationStage.HYDRATING_COMPONENT);\n addThreadMessage(\n {\n threadId: threadId,\n content: contentParts,\n role: \"tool\",\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n componentState: {},\n actionType: \"tool_response\",\n tool_call_id: advanceResponse.responseMessageDto.tool_call_id,\n error: toolCallResponse.error,\n },\n false,\n );\n\n advanceResponse = await client.beta.threads.advanceByID(\n advanceResponse.responseMessageDto.threadId,\n toolCallResponseParams,\n );\n\n // Update MCP or clear access token\n setMcpAccessToken(advanceResponse.mcpAccessToken ?? null);\n }\n } catch (error) {\n updateThreadStatus(\n advanceResponse.responseMessageDto.threadId,\n GenerationStage.ERROR,\n );\n throw error;\n }\n\n const finalMessage = advanceResponse.responseMessageDto.component\n ?.componentName\n ? renderComponentIntoMessage(\n advanceResponse.responseMessageDto,\n componentList,\n )\n : advanceResponse.responseMessageDto;\n const wasPlaceholderThread = currentThreadId === PLACEHOLDER_THREAD.id;\n await switchCurrentThread(advanceResponse.responseMessageDto.threadId);\n\n // If we're switching from placeholder to a real thread\n // this means a new thread was created, so refetch the threads list\n if (wasPlaceholderThread) {\n await refetchThreadsList(\n advanceResponse.responseMessageDto.threadId,\n contextKey,\n );\n }\n updateThreadStatus(\n advanceResponse.responseMessageDto.threadId,\n GenerationStage.COMPLETE,\n );\n return finalMessage;\n },\n [\n componentList,\n toolRegistry,\n componentToolAssociations,\n currentThreadId,\n switchCurrentThread,\n addThreadMessage,\n client,\n updateThreadMessage,\n updateThreadStatus,\n handleAdvanceStream,\n streaming,\n getAdditionalContext,\n placeholderThread.id,\n initialMessages,\n onCallUnregisteredTool,\n refetchThreadsList,\n setMcpAccessToken,\n ],\n );\n\n return (\n <TamboThreadContext.Provider\n value={{\n thread: currentThread,\n switchCurrentThread,\n startNewThread,\n updateThreadName,\n generateThreadName,\n addThreadMessage,\n updateThreadMessage,\n streaming,\n cancel,\n sendThreadMessage,\n }}\n >\n <TamboGenerationStageProvider\n generationStage={currentGenerationStage}\n statusMessage={currentStatusMessage}\n >\n {children}\n </TamboGenerationStageProvider>\n </TamboThreadContext.Provider>\n );\n};\n\n/**\n * The useTamboGenerationStage hook provides access to the generation stage context\n * to the descendants of the TamboThreadProvider.\n * @returns The generation stage context\n */\nexport const useTamboGenerationStage = (): TamboGenerationStageContextProps => {\n const generationStageContext = useContext(TamboGenerationStageContext);\n\n if (generationStageContext === undefined) {\n throw new Error(\n \"useTamboGenerationStage must be used within a TamboThreadProvider\",\n );\n }\n\n return generationStageContext;\n};\n\n/**\n * The useTamboThread hook provides access to the current thread context\n * to the descendants of the TamboThreadProvider.\n * @returns All state and actions for the current thread\n */\nexport const useTamboThread = (): CombinedTamboThreadContextProps => {\n const threadContext = useContext(TamboThreadContext);\n const generationStageContext = useContext(TamboGenerationStageContext);\n\n if (threadContext === undefined) {\n throw new Error(\"useTamboThread must be used within a TamboThreadProvider\");\n }\n\n if (generationStageContext === undefined) {\n throw new Error(\"useTamboThread must be used within a TamboThreadProvider\");\n }\n\n return {\n ...threadContext,\n ...generationStageContext,\n };\n};\n\nasync function convertToolResponse(toolCallResponse: {\n result: unknown;\n error?: string;\n tamboTool?: TamboTool;\n}): Promise<TamboAI.Beta.Threads.ChatCompletionContentPart[]> {\n // If the tool call errored, surface that as text so the model reliably sees the error\n if (toolCallResponse.error) {\n return [{ type: \"text\", text: toText(toolCallResponse.result) }];\n }\n\n // Use custom transform when available\n if (toolCallResponse.tamboTool?.transformToContent) {\n return await toolCallResponse.tamboTool.transformToContent(\n // result shape is user-defined; let the transform decide how to handle it\n toolCallResponse.result as any,\n );\n }\n\n // Default fallback to stringified text\n return [{ type: \"text\", text: toText(toolCallResponse.result) }];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tambo-thread-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-thread-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,6DAAkE;AAElE,+CASe;AAEf,sFAI8C;AAE9C,yDAA+C;AAC/C,mEAAwE;AACxE,+CAI0B;AAC1B,qDAAqD;AACrD,mEAA8E;AAC9E,qFAA0E;AAC1E,yEAA8D;AAC9D,uEAA6D;AAS7D,MAAM,2BAA2B,GAAG,IAAA,qBAAa,EAE/C,SAAS,CAAC,CAAC;AAOb;;;;;;;;GAQG;AACI,MAAM,4BAA4B,GAErC,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,yCAAW,EAAC,eAAe,CAAC,CAAC;IAE5C,MAAM,YAAY,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAChC,OAAO;YACL,eAAe;YACf,uBAAuB,EAAE,aAAa;YACtC,MAAM;SACP,CAAC;IACJ,CAAC,EAAE,CAAC,eAAe,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;IAE7C,OAAO,CACL,8BAAC,2BAA2B,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,IACtD,QAAQ,CAC4B,CACxC,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,4BAA4B,gCAkBvC;AAoD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B,CAAC,gBAIlC;IACC,sFAAsF;IACtF,IAAI,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC3B,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAA,sBAAM,EAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,sCAAsC;IACtC,IAAI,gBAAgB,CAAC,SAAS,EAAE,kBAAkB,EAAE,CAAC;QACnD,OAAO,MAAM,gBAAgB,CAAC,SAAS,CAAC,kBAAkB;QACxD,0EAA0E;QAC1E,gBAAgB,CAAC,MAAa,CAC/B,CAAC;IACJ,CAAC;IAED,uCAAuC;IACvC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAA,sBAAM,EAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACnE,CAAC","sourcesContent":["\"use client\";\nimport TamboAI, { advanceStream } from \"@tambo-ai/typescript-sdk\";\nimport { Thread } from \"@tambo-ai/typescript-sdk/resources/beta/threads/threads\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { TamboTool } from \"../model/component-metadata\";\nimport {\n GenerationStage,\n isIdleStage,\n TamboThreadMessage,\n} from \"../model/generate-component-response\";\nimport { TamboThread } from \"../model/tambo-thread\";\nimport { toText } from \"../util/content-parts\";\nimport { renderComponentIntoMessage } from \"../util/generate-component\";\nimport {\n getAvailableComponents,\n getUnassociatedTools,\n mapTamboToolToContextTool,\n} from \"../util/registry\";\nimport { handleToolCall } from \"../util/tool-caller\";\nimport { useTamboClient, useTamboQueryClient } from \"./tambo-client-provider\";\nimport { useTamboContextHelpers } from \"./tambo-context-helpers-provider\";\nimport { useTamboMcpToken } from \"./tambo-mcp-token-provider\";\nimport { useTamboRegistry } from \"./tambo-registry-provider\";\n\n// Generation Stage Context - separate from thread context to prevent re-renders\nexport interface TamboGenerationStageContextProps {\n generationStage: GenerationStage;\n generationStatusMessage: string;\n isIdle: boolean;\n}\n\nconst TamboGenerationStageContext = createContext<\n TamboGenerationStageContextProps | undefined\n>(undefined);\n\ninterface TamboGenerationStageProviderProps {\n generationStage: GenerationStage;\n statusMessage: string;\n}\n\n/**\n *\n * This provider is used to provide the generation stage context to the descendants of the provider.\n * @param props - The props for the GenerationStageProvider\n * @param props.children - The children to wrap\n * @param props.generationStage - The generation stage to provide\n * @param props.statusMessage - The status message to provide\n * @returns The GenerationStageProvider component\n */\nexport const TamboGenerationStageProvider: React.FC<\n PropsWithChildren<TamboGenerationStageProviderProps>\n> = ({ children, generationStage, statusMessage }) => {\n const isIdle = isIdleStage(generationStage);\n\n const contextValue = useMemo(() => {\n return {\n generationStage,\n generationStatusMessage: statusMessage,\n isIdle,\n };\n }, [generationStage, statusMessage, isIdle]);\n\n return (\n <TamboGenerationStageContext.Provider value={contextValue}>\n {children}\n </TamboGenerationStageContext.Provider>\n );\n};\n\n// Type for partial message updates that requires threadId\ntype PartialTamboThreadMessageWithThreadId = Partial<TamboThreadMessage> & {\n threadId: string;\n};\n\nexport interface TamboThreadContextProps {\n /** The current thread */\n thread: TamboThread;\n /** Switch to a different thread */\n switchCurrentThread: (threadId: string, fetch?: boolean) => void;\n /** Start a new thread */\n startNewThread: () => void;\n /** Update a thread's name */\n updateThreadName: (name: string, threadId?: string) => void;\n /** Let Tambo generate and set a thread's name based on the thread's messages */\n generateThreadName: (threadId?: string) => Promise<Thread>;\n /** Add a message to the current thread */\n addThreadMessage: (\n message: TamboThreadMessage,\n sendToServer: boolean,\n ) => Promise<TamboAI.Beta.Threads.ThreadMessage[]>;\n /** Update a message in the current thread */\n updateThreadMessage: (\n id: string,\n message: PartialTamboThreadMessageWithThreadId,\n sendToServer: boolean,\n ) => Promise<void>;\n /** Cancel a thread */\n cancel: (threadId?: string) => Promise<void>;\n /** Whether the thread is streaming */\n streaming: boolean;\n /** Send a message to the current thread */\n sendThreadMessage: (\n message: string,\n options?: {\n threadId?: string;\n streamResponse?: boolean;\n contextKey?: string;\n forceToolChoice?: string;\n additionalContext?: Record<string, any>;\n content?: TamboAI.Beta.Threads.ChatCompletionContentPart[];\n },\n ) => Promise<TamboThreadMessage>;\n}\n\n// Combined context interface that includes generation stage fields\nexport interface CombinedTamboThreadContextProps\n extends TamboThreadContextProps,\n TamboGenerationStageContextProps {}\n\n/**\n * This is a stub entry for when the thread is not yet created, the first time\n * the user sends a message\n *\n * Note that the consumer needs to be careful never to send `PLACEHOLDER_THREAD.id` to the server,\n * as this doesn't really exist on the server side.\n */\nexport const PLACEHOLDER_THREAD: TamboThread = {\n id: \"placeholder\",\n messages: [],\n createdAt: \"\",\n projectId: \"\",\n updatedAt: \"\",\n metadata: {},\n};\n\nexport const TamboThreadContext = createContext<TamboThreadContextProps>({\n thread: PLACEHOLDER_THREAD,\n /**\n *\n */\n switchCurrentThread: () => {\n throw new Error(\"switchCurrentThread not implemented\");\n },\n /**\n *\n */\n startNewThread: () => {\n throw new Error(\"startNewThread not implemented\");\n },\n /**\n *\n */\n updateThreadName: () => {\n throw new Error(\"updateThreadName not implemented\");\n },\n /**\n *\n */\n generateThreadName: () => {\n throw new Error(\"generateThreadName not implemented\");\n },\n /**\n *\n */\n addThreadMessage: () => {\n throw new Error(\"updateThreadMessageHistory not implemented\");\n },\n streaming: true,\n /**\n *\n */\n updateThreadMessage: () => {\n throw new Error(\"updateThreadMessage not implemented\");\n },\n /**\n *\n */\n sendThreadMessage: () => {\n throw new Error(\"sendThreadMessage not implemented\");\n },\n /**\n *\n */\n cancel: () => {\n throw new Error(\"cancel not implemented\");\n },\n});\n\nexport type InitialTamboThreadMessage = Pick<\n TamboThreadMessage,\n \"role\" | \"content\"\n> & {\n /** Optional ID - will be auto-generated if not provided */\n id?: string;\n /** Optional creation timestamp - will be auto-generated if not provided */\n createdAt?: string;\n /** Optional additional context to include with the message */\n additionalContext?: Record<string, any>;\n /** Optional component state - will default to empty object if not provided */\n componentState?: Record<string, any>;\n};\n\nexport interface TamboThreadProviderProps {\n /** Whether to stream the response */\n streaming?: boolean;\n /** Initial messages to be included in new threads */\n initialMessages?: InitialTamboThreadMessage[];\n /** Whether to automatically generate thread names. Defaults to true. */\n autoGenerateThreadName?: boolean;\n /** The message count threshold at which the thread name will be auto-generated. Defaults to 3. */\n autoGenerateNameThreshold?: number;\n}\n\n/**\n * The TamboThreadProvider is a React provider that provides a thread context\n * to the descendants of the provider.\n * @param props - The props for the TamboThreadProvider\n * @param props.children - The children to wrap\n * @param props.streaming - Whether to stream the response by default. Defaults to true.\n * @param props.initialMessages - Initial messages to be included in new threads\n * @param props.autoGenerateThreadName - Whether to automatically generate thread names. Defaults to true.\n * @param props.autoGenerateNameThreshold - The message count threshold at which the thread name will be auto-generated. Defaults to 3.\n * @returns The TamboThreadProvider component\n */\nexport const TamboThreadProvider: React.FC<\n PropsWithChildren<TamboThreadProviderProps>\n> = ({\n children,\n streaming = true,\n initialMessages = [],\n autoGenerateThreadName = true,\n autoGenerateNameThreshold = 3,\n}) => {\n // Create placeholder thread with initial messages\n const placeholderThread: TamboThread = useMemo(\n () => ({\n id: \"placeholder\",\n messages: initialMessages.map((msg) => ({\n ...msg,\n id: msg.id ?? crypto.randomUUID(),\n threadId: \"placeholder\",\n createdAt: msg.createdAt ?? new Date().toISOString(),\n componentState: msg.componentState ?? {},\n })),\n createdAt: \"\",\n projectId: \"\",\n updatedAt: \"\",\n metadata: {},\n }),\n [initialMessages],\n );\n\n const [threadMap, setThreadMap] = useState<Record<string, TamboThread>>({\n [placeholderThread.id]: placeholderThread,\n });\n const client = useTamboClient();\n const queryClient = useTamboQueryClient();\n const {\n componentList,\n toolRegistry,\n componentToolAssociations,\n onCallUnregisteredTool,\n } = useTamboRegistry();\n const { getAdditionalContext } = useTamboContextHelpers();\n const { setMcpAccessToken } = useTamboMcpToken();\n const [ignoreResponse, setIgnoreResponse] = useState(false);\n const ignoreResponseRef = useRef(ignoreResponse);\n const [currentThreadId, setCurrentThreadId] = useState<string>(\n placeholderThread.id,\n );\n const currentThread: TamboThread | undefined = threadMap[currentThreadId];\n\n // Generation stage props for GenerationStageProvider\n const currentGenerationStage =\n (currentThread?.generationStage as GenerationStage) ?? GenerationStage.IDLE;\n const currentStatusMessage = currentThread?.statusMessage ?? \"\";\n\n // Use existing messages from the current thread to avoid re-generating any components\n const currentMessageCache = useMemo(() => {\n const messageCache = new Map<string, TamboThreadMessage>();\n if (currentThread) {\n for (const message of currentThread.messages) {\n messageCache.set(message.id, message);\n }\n }\n return messageCache;\n }, [currentThread]);\n\n useEffect(() => {\n ignoreResponseRef.current = ignoreResponse;\n }, [ignoreResponse]);\n\n const updateThreadsCache = useCallback(\n async (\n updateFn: (\n old: TamboAI.Beta.Threads.ThreadsOffsetAndLimit | undefined,\n ) => TamboAI.Beta.Threads.ThreadsOffsetAndLimit | undefined,\n contextKey?: string,\n ) => {\n try {\n const currentProject = await client.beta.projects.getCurrent();\n\n queryClient.setQueryData(\n [\"threads\", currentProject.id, contextKey],\n updateFn,\n );\n\n await queryClient.invalidateQueries({\n queryKey: [\"threads\"],\n });\n } catch (error) {\n console.warn(\"Failed to update threads cache:\", error);\n }\n },\n [client.beta.projects, queryClient],\n );\n\n const addThreadToCache = useCallback(\n async (threadId: string, contextKey: string | undefined) => {\n const optimisticThread = {\n ...PLACEHOLDER_THREAD,\n id: threadId,\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n };\n\n await updateThreadsCache((old) => {\n if (!old) return old;\n return {\n ...old,\n items: [optimisticThread, ...(old.items ?? [])],\n total: (old.total ?? 0) + 1,\n count: (old.count ?? 0) + 1,\n } as TamboAI.Beta.Threads.ThreadsOffsetAndLimit;\n }, contextKey);\n },\n [updateThreadsCache],\n );\n\n const updateThreadInCache = useCallback(\n async (\n threadId: string,\n updateFn: (\n thread: TamboAI.Beta.Threads.Thread,\n ) => TamboAI.Beta.Threads.Thread,\n contextKey?: string,\n ) => {\n await updateThreadsCache((old) => {\n if (!old?.items) return old;\n return {\n ...old,\n items: old.items.map((thread) =>\n thread.id === threadId ? updateFn(thread) : thread,\n ),\n total: old.total,\n count: old.count,\n } as TamboAI.Beta.Threads.ThreadsOffsetAndLimit;\n }, contextKey);\n },\n [updateThreadsCache],\n );\n\n const fetchThread = useCallback(\n async (threadId: string) => {\n const thread = await client.beta.threads.retrieve(threadId);\n const threadWithRenderedComponents = {\n ...thread,\n messages: thread.messages.map((message) => {\n if (currentMessageCache.has(message.id)) {\n const renderedMessage = currentMessageCache.get(message.id);\n return {\n ...renderedMessage,\n ...message,\n };\n }\n if (message.component?.componentName) {\n const messageWithComponent = renderComponentIntoMessage(\n message,\n componentList,\n );\n return messageWithComponent;\n }\n return message;\n }),\n };\n\n setThreadMap((prevMap) => {\n const updatedThreadMap = {\n ...prevMap,\n [threadId]: threadWithRenderedComponents,\n };\n return updatedThreadMap;\n });\n },\n [client.beta.threads, componentList, currentMessageCache],\n );\n\n useEffect(() => {\n if (\n currentThreadId &&\n currentThreadId !== placeholderThread.id &&\n !threadMap[currentThreadId]\n ) {\n fetchThread(currentThreadId);\n }\n }, [currentThreadId, fetchThread, threadMap, placeholderThread.id]);\n\n const addThreadMessage = useCallback(\n async (\n message: TamboThreadMessage,\n sendToServer = true,\n createdAt: string = new Date().toISOString(),\n ) => {\n if (!currentThread) {\n console.warn(\"Cannot add messages if we do not have a current thread\");\n return [];\n }\n\n const chatMessage: TamboThreadMessage = {\n ...message,\n createdAt,\n };\n const threadId = message.threadId;\n const messageId = chatMessage.id;\n // optimistically update the thread in the local state\n setThreadMap((prevMap) => {\n if (!threadId) {\n return prevMap;\n }\n const prevMessages = prevMap[threadId]?.messages || [];\n const haveMessage = prevMessages.find((msg) => msg.id === messageId);\n // Update in place if the message already exists\n const updatedMessages = haveMessage\n ? prevMessages.map((msg) => {\n if (msg.id === messageId) {\n return chatMessage;\n }\n return msg;\n })\n : [...prevMessages, chatMessage];\n\n const updatedThreadMap = {\n ...prevMap,\n [threadId]: {\n ...prevMap[threadId],\n messages: updatedMessages,\n },\n };\n return updatedThreadMap;\n });\n\n if (sendToServer) {\n // TODO: if this fails, we need to revert the local state update\n await client.beta.threads.messages.create(message.threadId, {\n content: message.content,\n role: message.role,\n additionalContext: chatMessage.additionalContext,\n });\n }\n return threadMap[threadId]?.messages || [];\n },\n [client.beta.threads.messages, currentThread, threadMap],\n );\n\n const updateThreadMessage = useCallback(\n async (\n id: string,\n message: PartialTamboThreadMessageWithThreadId,\n sendToServer = true,\n createdAt: string = new Date().toISOString(),\n ) => {\n setThreadMap((prevMap) => {\n const prevMessages = prevMap[message.threadId]?.messages || [];\n const updatedMessages = prevMessages.map((msg) => {\n if (msg.id === id) {\n // Merge the partial update with the existing message\n const updatedMessage: TamboThreadMessage = {\n ...msg,\n ...message,\n id: msg.id,\n createdAt: message.createdAt ?? msg.createdAt ?? createdAt,\n };\n return updatedMessage;\n }\n return msg;\n });\n return {\n ...prevMap,\n [message.threadId]: {\n ...prevMap[message.threadId],\n messages: updatedMessages,\n },\n };\n });\n\n if (sendToServer && message.content && message.role) {\n // TODO: if this fails, we need to revert the local state update\n await client.beta.threads.messages.create(message.threadId, {\n content: message.content,\n role: message.role,\n additionalContext: message.additionalContext,\n });\n }\n },\n [client.beta.threads.messages],\n );\n\n const generateThreadName = useCallback(\n async (threadId?: string, contextKey?: string) => {\n threadId ??= currentThreadId;\n if (threadId === placeholderThread.id) {\n console.warn(\"Cannot generate name for empty thread\");\n return threadMap[threadId];\n }\n\n const threadWithGeneratedName =\n await client.beta.threads.generateName(threadId);\n\n // Update local thread state\n setThreadMap((prevMap) => {\n if (!prevMap[threadId]) {\n return prevMap;\n }\n return {\n ...prevMap,\n [threadId]: {\n ...prevMap[threadId],\n name: threadWithGeneratedName.name,\n },\n };\n });\n\n // Update threads cache to reflect the new name in the UI\n await updateThreadInCache(\n threadId,\n (thread) => ({\n ...thread,\n name: threadWithGeneratedName.name,\n }),\n contextKey,\n );\n\n return threadWithGeneratedName;\n },\n [\n client.beta.threads,\n currentThreadId,\n threadMap,\n placeholderThread.id,\n updateThreadInCache,\n ],\n );\n\n const maybeAutoGenerateThreadName = useCallback(\n (threadId: string, contextKey?: string) => {\n // Use setThreadMap to access the latest state\n setThreadMap((map) => {\n const thread = map[threadId];\n\n if (!thread || !autoGenerateThreadName) {\n return map;\n }\n\n if (\n autoGenerateNameThreshold == null ||\n thread.id === placeholderThread.id\n ) {\n return map;\n }\n\n const messageCount = thread.messages.length;\n\n // Only auto-generate if thread has no name and threshold is met\n if (!thread.name && messageCount >= autoGenerateNameThreshold) {\n generateThreadName(threadId, contextKey);\n }\n\n return map;\n });\n },\n [\n autoGenerateThreadName,\n autoGenerateNameThreshold,\n placeholderThread.id,\n generateThreadName,\n ],\n );\n\n const startNewThread = useCallback(() => {\n setCurrentThreadId(placeholderThread.id);\n setThreadMap((prevMap) => {\n return {\n ...prevMap,\n [placeholderThread.id]: placeholderThread,\n };\n });\n }, [placeholderThread]);\n\n const updateThreadName = useCallback(\n async (name: string, threadId?: string) => {\n threadId ??= currentThreadId;\n\n setThreadMap((prevMap) => {\n if (!prevMap[threadId]) {\n return prevMap;\n }\n return { ...prevMap, [threadId]: { ...prevMap[threadId], name } };\n });\n\n if (threadId !== placeholderThread.id) {\n const currentProject = await client.beta.projects.getCurrent();\n await client.beta.threads.update(threadId, {\n name,\n projectId: currentProject.id,\n });\n }\n },\n [\n currentThreadId,\n client.beta.projects,\n client.beta.threads,\n placeholderThread.id,\n ],\n );\n\n const switchCurrentThread = useCallback(\n async (threadId: string, fetch = true) => {\n if (threadId === placeholderThread.id) {\n console.warn(\"Switching to placeholder thread, may be a bug.\");\n return;\n }\n\n setCurrentThreadId(threadId);\n setThreadMap((prevMap) => {\n if (prevMap[threadId]) {\n return prevMap;\n }\n // If this is a new thread, add placeholder thread messages to the thread\n const updatedThreadMap = {\n ...prevMap,\n [threadId]: {\n ...prevMap[placeholderThread.id],\n id: threadId,\n },\n };\n return updatedThreadMap;\n });\n\n if (fetch) {\n await fetchThread(threadId);\n }\n },\n [fetchThread, placeholderThread],\n );\n\n const updateThreadStatus = useCallback(\n (threadId: string, stage: GenerationStage, statusMessage?: string) => {\n setThreadMap((prevMap) => {\n const updatedThreadMap = {\n ...prevMap,\n [threadId]: {\n ...prevMap[threadId],\n generationStage: stage,\n statusMessage: statusMessage,\n },\n };\n return updatedThreadMap;\n });\n },\n [],\n );\n\n const cancel = useCallback(\n async (threadId?: string) => {\n threadId ??= currentThreadId;\n const currentGenerationStage =\n currentThread?.generationStage ?? GenerationStage.IDLE;\n if (isIdleStage(currentGenerationStage as GenerationStage)) {\n return;\n }\n setIgnoreResponse(true);\n setThreadMap((prevMap) => {\n if (!prevMap[threadId]) {\n return prevMap;\n }\n\n return {\n ...prevMap,\n [threadId]: {\n ...prevMap[threadId],\n generationStage: GenerationStage.CANCELLED,\n messages: prevMap[threadId].messages.map((message) => {\n if (\n message.id ===\n prevMap[threadId].messages[\n prevMap[threadId].messages.length - 1\n ].id\n ) {\n return {\n ...message,\n isCancelled: true,\n };\n }\n return message;\n }),\n },\n };\n });\n\n await client.beta.threads.cancel(threadId);\n },\n [client.beta.threads, currentThreadId, currentThread?.generationStage],\n );\n\n const handleAdvanceStream = useCallback(\n async (\n stream: AsyncIterable<TamboAI.Beta.Threads.ThreadAdvanceResponse>,\n params: TamboAI.Beta.Threads.ThreadAdvanceParams,\n threadId: string,\n contextKey?: string,\n ): Promise<TamboThreadMessage> => {\n if (ignoreResponseRef.current) {\n setIgnoreResponse(false);\n return {\n threadId: threadId,\n content: [{ type: \"text\", text: \"\" }],\n role: \"assistant\",\n createdAt: new Date().toISOString(),\n id: crypto.randomUUID(),\n componentState: {},\n };\n }\n let finalMessage: Readonly<TamboThreadMessage> | undefined;\n let hasSetThreadId = false;\n updateThreadStatus(threadId, GenerationStage.STREAMING_RESPONSE);\n\n for await (const chunk of stream) {\n // Update or clear MCP access token\n if (chunk.mcpAccessToken) {\n // note that we're only setting it positively it during streaming, because it might\n // not have been set yet in the chunk (i.e. we're not unsetting it in the chunk)\n setMcpAccessToken(chunk.mcpAccessToken);\n }\n\n if (chunk.responseMessageDto.toolCallRequest) {\n // Increment tool call count for this tool\n const toolName = chunk.responseMessageDto.toolCallRequest.toolName;\n if (toolName && params.toolCallCounts) {\n params.toolCallCounts[toolName] =\n (params.toolCallCounts[toolName] ?? 0) + 1;\n }\n\n updateThreadStatus(\n chunk.responseMessageDto.threadId,\n GenerationStage.FETCHING_CONTEXT,\n );\n\n updateThreadMessage(\n chunk.responseMessageDto.id,\n {\n ...chunk.responseMessageDto,\n },\n false,\n );\n\n const toolCallResponse = await handleToolCall(\n chunk.responseMessageDto,\n toolRegistry,\n onCallUnregisteredTool,\n );\n if (ignoreResponseRef.current) {\n setIgnoreResponse(false);\n {\n return {\n threadId: threadId,\n content: [{ type: \"text\", text: \"\" }],\n role: \"assistant\",\n createdAt: new Date().toISOString(),\n id: crypto.randomUUID(),\n componentState: {},\n };\n }\n }\n const contentParts = await convertToolResponse(toolCallResponse);\n\n const toolCallResponseParams: TamboAI.Beta.Threads.ThreadAdvanceParams =\n {\n ...params,\n messageToAppend: {\n content: contentParts,\n role: \"tool\",\n actionType: \"tool_response\",\n component: chunk.responseMessageDto.component,\n tool_call_id: chunk.responseMessageDto.tool_call_id,\n error: toolCallResponse.error,\n },\n };\n\n updateThreadMessage(\n chunk.responseMessageDto.id,\n {\n ...chunk.responseMessageDto,\n error: toolCallResponse.error,\n },\n false,\n );\n\n addThreadMessage(\n {\n threadId: chunk.responseMessageDto.threadId,\n content: contentParts,\n role: \"tool\",\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n componentState: {},\n actionType: \"tool_response\",\n tool_call_id: chunk.responseMessageDto.tool_call_id,\n error: toolCallResponse.error,\n },\n false,\n );\n\n updateThreadStatus(\n chunk.responseMessageDto.threadId,\n GenerationStage.STREAMING_RESPONSE,\n );\n const toolCallResponseStream = await advanceStream(\n client,\n toolCallResponseParams,\n chunk.responseMessageDto.threadId,\n );\n\n return await handleAdvanceStream(\n toolCallResponseStream,\n toolCallResponseParams,\n chunk.responseMessageDto.threadId,\n contextKey,\n );\n } else {\n if (ignoreResponseRef.current) {\n setIgnoreResponse(false);\n return (\n finalMessage ?? {\n threadId: threadId,\n content: [{ type: \"text\", text: \"\" }],\n role: \"assistant\",\n createdAt: new Date().toISOString(),\n id: crypto.randomUUID(),\n componentState: {},\n }\n );\n }\n if (\n !hasSetThreadId &&\n chunk.responseMessageDto.threadId &&\n chunk.responseMessageDto.threadId !== currentThread?.id\n ) {\n hasSetThreadId = true;\n const wasPlaceholderThread =\n currentThreadId === PLACEHOLDER_THREAD.id;\n await switchCurrentThread(chunk.responseMessageDto.threadId, false);\n\n // If we're switching from placeholder to a real thread\n // this means a new thread was created, so add it to cache\n if (wasPlaceholderThread) {\n await addThreadToCache(\n chunk.responseMessageDto.threadId,\n contextKey,\n );\n // Check if we should auto-generate name for the newly created thread\n maybeAutoGenerateThreadName(\n chunk.responseMessageDto.threadId,\n contextKey,\n );\n }\n }\n\n if (!finalMessage) {\n finalMessage = chunk.responseMessageDto.component?.componentName\n ? renderComponentIntoMessage(\n chunk.responseMessageDto,\n componentList,\n )\n : chunk.responseMessageDto;\n await addThreadMessage(finalMessage, false);\n } else {\n // if we start getting a new message mid-stream, put the previous one on screen\n const isNewMessage =\n chunk.responseMessageDto.id !== finalMessage.id;\n\n finalMessage = chunk.responseMessageDto.component?.componentName\n ? renderComponentIntoMessage(\n chunk.responseMessageDto,\n componentList,\n )\n : chunk.responseMessageDto;\n\n if (isNewMessage) {\n await addThreadMessage(finalMessage, false);\n } else {\n await updateThreadMessage(finalMessage.id, finalMessage, false);\n }\n }\n }\n }\n\n const completedThreadId = finalMessage?.threadId ?? threadId;\n\n updateThreadStatus(completedThreadId, GenerationStage.COMPLETE);\n maybeAutoGenerateThreadName(completedThreadId, contextKey);\n\n return (\n finalMessage ?? {\n threadId: \"\",\n content: [{ type: \"text\", text: `Error processing stream` }],\n role: \"assistant\",\n createdAt: new Date().toISOString(),\n id: crypto.randomUUID(),\n componentState: {},\n }\n );\n },\n [\n addThreadMessage,\n addThreadToCache,\n maybeAutoGenerateThreadName,\n client,\n componentList,\n currentThread?.id,\n currentThreadId,\n onCallUnregisteredTool,\n setMcpAccessToken,\n switchCurrentThread,\n toolRegistry,\n updateThreadMessage,\n updateThreadStatus,\n ],\n );\n\n const sendThreadMessage = useCallback(\n async (\n message: string,\n options: {\n threadId?: string;\n streamResponse?: boolean;\n forceToolChoice?: string;\n contextKey?: string;\n additionalContext?: Record<string, any>;\n content?: TamboAI.Beta.Threads.ChatCompletionContentPart[];\n } = {},\n ): Promise<TamboThreadMessage> => {\n setIgnoreResponse(false);\n const {\n threadId = currentThreadId ?? placeholderThread.id,\n streamResponse = streaming,\n forceToolChoice,\n contextKey,\n additionalContext,\n content,\n } = options;\n updateThreadStatus(threadId, GenerationStage.FETCHING_CONTEXT);\n\n // Get additional context from enabled helpers\n const helperContexts = await getAdditionalContext();\n\n // Combine all contexts\n const combinedContext: Record<string, any> = {\n ...(additionalContext ?? {}),\n };\n\n // Add helper contexts to combinedContext\n for (const helperContext of helperContexts) {\n combinedContext[helperContext.name] = helperContext.context;\n }\n\n // Use provided content or build simple text message\n const messageContent = content ?? [\n { type: \"text\" as const, text: message },\n ];\n\n addThreadMessage(\n {\n content: messageContent as any,\n renderedComponent: null,\n role: \"user\",\n threadId: threadId,\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n componentState: {},\n additionalContext: combinedContext,\n },\n false,\n );\n\n maybeAutoGenerateThreadName(threadId, contextKey);\n\n const availableComponents = getAvailableComponents(\n componentList,\n toolRegistry,\n componentToolAssociations,\n );\n const unassociatedTools = getUnassociatedTools(\n toolRegistry,\n componentToolAssociations,\n );\n\n // Track tool call counts for this message processing\n const toolCallCounts: Record<string, number> = {};\n\n const params: TamboAI.Beta.Threads.ThreadAdvanceParams = {\n messageToAppend: {\n content: messageContent as any,\n role: \"user\",\n additionalContext: combinedContext,\n },\n contextKey,\n availableComponents: availableComponents,\n clientTools: unassociatedTools.map((tool) =>\n mapTamboToolToContextTool(tool),\n ),\n forceToolChoice: forceToolChoice,\n toolCallCounts,\n ...(threadId === placeholderThread.id &&\n initialMessages.length > 0 && {\n initialMessages: initialMessages.map((msg) => ({\n content: msg.content,\n role: msg.role,\n additionalContext: msg.additionalContext,\n })),\n }),\n };\n\n if (streamResponse) {\n let advanceStreamResponse: AsyncIterable<TamboAI.Beta.Threads.ThreadAdvanceResponse>;\n try {\n advanceStreamResponse = await advanceStream(\n client,\n params,\n threadId === placeholderThread.id ? undefined : threadId,\n );\n } catch (error) {\n updateThreadStatus(threadId, GenerationStage.ERROR);\n throw error;\n }\n try {\n const result = await handleAdvanceStream(\n advanceStreamResponse,\n params,\n threadId,\n contextKey,\n );\n\n return result;\n } catch (error) {\n updateThreadStatus(threadId, GenerationStage.ERROR);\n throw error;\n }\n }\n\n let advanceResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse;\n try {\n advanceResponse = await (threadId === placeholderThread.id\n ? client.beta.threads.advance(params)\n : client.beta.threads.advanceByID(threadId, params));\n\n // Update or clear MCP access token\n setMcpAccessToken(advanceResponse.mcpAccessToken ?? null);\n } catch (error) {\n updateThreadStatus(threadId, GenerationStage.ERROR);\n throw error;\n }\n\n //handle tool calls\n try {\n while (advanceResponse.responseMessageDto.toolCallRequest) {\n // Increment tool call count for this tool\n const toolName =\n advanceResponse.responseMessageDto.toolCallRequest.toolName;\n if (toolName) {\n toolCallCounts[toolName] = (toolCallCounts[toolName] || 0) + 1;\n }\n\n updateThreadStatus(threadId, GenerationStage.FETCHING_CONTEXT);\n const toolCallResponse = await handleToolCall(\n advanceResponse.responseMessageDto,\n toolRegistry,\n onCallUnregisteredTool,\n );\n\n const contentParts = await convertToolResponse(toolCallResponse);\n\n const toolCallResponseParams: TamboAI.Beta.Threads.ThreadAdvanceParams =\n {\n ...params,\n messageToAppend: {\n ...params.messageToAppend,\n content: contentParts,\n role: \"tool\",\n actionType: \"tool_response\",\n component: advanceResponse.responseMessageDto.component,\n tool_call_id: advanceResponse.responseMessageDto.tool_call_id,\n error: toolCallResponse.error,\n },\n };\n if (toolCallResponse.error) {\n //update toolcall message with error\n const toolCallMessage = {\n ...advanceResponse.responseMessageDto,\n error: toolCallResponse.error,\n };\n updateThreadMessage(toolCallMessage.id, toolCallMessage, false);\n }\n updateThreadStatus(threadId, GenerationStage.HYDRATING_COMPONENT);\n addThreadMessage(\n {\n threadId: threadId,\n content: contentParts,\n role: \"tool\",\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n componentState: {},\n actionType: \"tool_response\",\n tool_call_id: advanceResponse.responseMessageDto.tool_call_id,\n error: toolCallResponse.error,\n },\n false,\n );\n\n advanceResponse = await client.beta.threads.advanceByID(\n advanceResponse.responseMessageDto.threadId,\n toolCallResponseParams,\n );\n\n // Update MCP or clear access token\n setMcpAccessToken(advanceResponse.mcpAccessToken ?? null);\n }\n } catch (error) {\n updateThreadStatus(\n advanceResponse.responseMessageDto.threadId,\n GenerationStage.ERROR,\n );\n throw error;\n }\n\n const finalMessage = advanceResponse.responseMessageDto.component\n ?.componentName\n ? renderComponentIntoMessage(\n advanceResponse.responseMessageDto,\n componentList,\n )\n : advanceResponse.responseMessageDto;\n const wasPlaceholderThread = currentThreadId === PLACEHOLDER_THREAD.id;\n await switchCurrentThread(advanceResponse.responseMessageDto.threadId);\n\n // If we're switching from placeholder to a real thread\n // this means a new thread was created, so add it to cache\n if (wasPlaceholderThread) {\n await addThreadToCache(\n advanceResponse.responseMessageDto.threadId,\n contextKey,\n );\n }\n const completedThreadId = advanceResponse.responseMessageDto.threadId;\n\n updateThreadStatus(completedThreadId, GenerationStage.COMPLETE);\n maybeAutoGenerateThreadName(completedThreadId, contextKey);\n\n return finalMessage;\n },\n [\n componentList,\n toolRegistry,\n componentToolAssociations,\n currentThreadId,\n switchCurrentThread,\n addThreadMessage,\n client,\n updateThreadMessage,\n updateThreadStatus,\n handleAdvanceStream,\n streaming,\n getAdditionalContext,\n placeholderThread.id,\n initialMessages,\n onCallUnregisteredTool,\n addThreadToCache,\n maybeAutoGenerateThreadName,\n setMcpAccessToken,\n ],\n );\n\n return (\n <TamboThreadContext.Provider\n value={{\n thread: currentThread,\n switchCurrentThread,\n startNewThread,\n updateThreadName,\n generateThreadName,\n addThreadMessage,\n updateThreadMessage,\n streaming,\n cancel,\n sendThreadMessage,\n }}\n >\n <TamboGenerationStageProvider\n generationStage={currentGenerationStage}\n statusMessage={currentStatusMessage}\n >\n {children}\n </TamboGenerationStageProvider>\n </TamboThreadContext.Provider>\n );\n};\n\n/**\n * The useTamboGenerationStage hook provides access to the generation stage context\n * to the descendants of the TamboThreadProvider.\n * @returns The generation stage context\n */\nexport const useTamboGenerationStage = (): TamboGenerationStageContextProps => {\n const generationStageContext = useContext(TamboGenerationStageContext);\n\n if (generationStageContext === undefined) {\n throw new Error(\n \"useTamboGenerationStage must be used within a TamboThreadProvider\",\n );\n }\n\n return generationStageContext;\n};\n\n/**\n * The useTamboThread hook provides access to the current thread context\n * to the descendants of the TamboThreadProvider.\n * @returns All state and actions for the current thread\n */\nexport const useTamboThread = (): CombinedTamboThreadContextProps => {\n const threadContext = useContext(TamboThreadContext);\n const generationStageContext = useContext(TamboGenerationStageContext);\n\n if (threadContext === undefined) {\n throw new Error(\"useTamboThread must be used within a TamboThreadProvider\");\n }\n\n if (generationStageContext === undefined) {\n throw new Error(\"useTamboThread must be used within a TamboThreadProvider\");\n }\n\n return {\n ...threadContext,\n ...generationStageContext,\n };\n};\n\nasync function convertToolResponse(toolCallResponse: {\n result: unknown;\n error?: string;\n tamboTool?: TamboTool;\n}): Promise<TamboAI.Beta.Threads.ChatCompletionContentPart[]> {\n // If the tool call errored, surface that as text so the model reliably sees the error\n if (toolCallResponse.error) {\n return [{ type: \"text\", text: toText(toolCallResponse.result) }];\n }\n\n // Use custom transform when available\n if (toolCallResponse.tamboTool?.transformToContent) {\n return await toolCallResponse.tamboTool.transformToContent(\n // result shape is user-defined; let the transform decide how to handle it\n toolCallResponse.result as any,\n );\n }\n\n // Default fallback to stringified text\n return [{ type: \"text\", text: toText(toolCallResponse.result) }];\n}\n"]}
|
package/dist/setupTests.js
CHANGED
|
@@ -7,4 +7,14 @@ const mockDate = new Date(2025, 0, 5, 12, 32, 58, 936);
|
|
|
7
7
|
global.Date.now = jest.fn(() => mockDate.getTime());
|
|
8
8
|
// Add TextEncoder/TextDecoder polyfills for Node.js test environment
|
|
9
9
|
Object.assign(global, { TextEncoder: util_1.TextEncoder, TextDecoder: util_1.TextDecoder });
|
|
10
|
+
// Mock react-media-recorder for tests (browser APIs not available in Node.js)
|
|
11
|
+
jest.mock("react-media-recorder", () => ({
|
|
12
|
+
useReactMediaRecorder: () => ({
|
|
13
|
+
status: "idle",
|
|
14
|
+
startRecording: jest.fn(),
|
|
15
|
+
stopRecording: jest.fn(),
|
|
16
|
+
mediaBlobUrl: null,
|
|
17
|
+
error: null,
|
|
18
|
+
}),
|
|
19
|
+
}));
|
|
10
20
|
//# sourceMappingURL=setupTests.js.map
|
package/dist/setupTests.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupTests.js","sourceRoot":"","sources":["../src/setupTests.ts"],"names":[],"mappings":";;AAAA,qCAAmC;AACnC,+BAAgD;AAEhD,qEAAqE;AACrE,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;AACvD,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;AAEpD,qEAAqE;AACrE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,WAAW,EAAX,kBAAW,EAAE,WAAW,EAAX,kBAAW,EAAE,CAAC,CAAC","sourcesContent":["import \"@testing-library/jest-dom\";\nimport { TextDecoder, TextEncoder } from \"util\";\n\n// Mock Date.now() to return a fixed timestamp for consistent testing\nconst mockDate = new Date(2025, 0, 5, 12, 32, 58, 936);\nglobal.Date.now = jest.fn(() => mockDate.getTime());\n\n// Add TextEncoder/TextDecoder polyfills for Node.js test environment\nObject.assign(global, { TextEncoder, TextDecoder });\n"]}
|
|
1
|
+
{"version":3,"file":"setupTests.js","sourceRoot":"","sources":["../src/setupTests.ts"],"names":[],"mappings":";;AAAA,qCAAmC;AACnC,+BAAgD;AAEhD,qEAAqE;AACrE,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;AACvD,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;AAEpD,qEAAqE;AACrE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,WAAW,EAAX,kBAAW,EAAE,WAAW,EAAX,kBAAW,EAAE,CAAC,CAAC;AAEpD,8EAA8E;AAC9E,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,CAAC;IACvC,qBAAqB,EAAE,GAAG,EAAE,CAAC,CAAC;QAC5B,MAAM,EAAE,MAAM;QACd,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE;QACxB,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,IAAI;KACZ,CAAC;CACH,CAAC,CAAC,CAAC","sourcesContent":["import \"@testing-library/jest-dom\";\nimport { TextDecoder, TextEncoder } from \"util\";\n\n// Mock Date.now() to return a fixed timestamp for consistent testing\nconst mockDate = new Date(2025, 0, 5, 12, 32, 58, 936);\nglobal.Date.now = jest.fn(() => mockDate.getTime());\n\n// Add TextEncoder/TextDecoder polyfills for Node.js test environment\nObject.assign(global, { TextEncoder, TextDecoder });\n\n// Mock react-media-recorder for tests (browser APIs not available in Node.js)\njest.mock(\"react-media-recorder\", () => ({\n useReactMediaRecorder: () => ({\n status: \"idle\",\n startRecording: jest.fn(),\n stopRecording: jest.fn(),\n mediaBlobUrl: null,\n error: null,\n }),\n}));\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-zod-schema.d.ts","sourceRoot":"","sources":["../../src/util/validate-zod-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,UAAU,EAAE,MAAM,KAAK,CAAC;AAE3D;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,UAAU,EAClB,WAAW,SAAW,GACrB,IAAI,
|
|
1
|
+
{"version":3,"file":"validate-zod-schema.d.ts","sourceRoot":"","sources":["../../src/util/validate-zod-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,UAAU,EAAE,MAAM,KAAK,CAAC;AAE3D;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,UAAU,EAClB,WAAW,SAAW,GACrB,IAAI,CA6GN"}
|