@tambo-ai/react 0.49.0 → 0.50.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.
Files changed (57) hide show
  1. package/dist/hooks/__tests__/use-message-images.test.d.ts +2 -0
  2. package/dist/hooks/__tests__/use-message-images.test.d.ts.map +1 -0
  3. package/dist/hooks/__tests__/use-message-images.test.js +66 -0
  4. package/dist/hooks/__tests__/use-message-images.test.js.map +1 -0
  5. package/dist/hooks/use-message-images.d.ts +25 -0
  6. package/dist/hooks/use-message-images.d.ts.map +1 -0
  7. package/dist/hooks/use-message-images.js +66 -0
  8. package/dist/hooks/use-message-images.js.map +1 -0
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +3 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/providers/tambo-thread-input-provider.d.ts +11 -0
  14. package/dist/providers/tambo-thread-input-provider.d.ts.map +1 -1
  15. package/dist/providers/tambo-thread-input-provider.js +63 -12
  16. package/dist/providers/tambo-thread-input-provider.js.map +1 -1
  17. package/dist/providers/tambo-thread-provider.d.ts +1 -0
  18. package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
  19. package/dist/providers/tambo-thread-provider.js +7 -3
  20. package/dist/providers/tambo-thread-provider.js.map +1 -1
  21. package/dist/util/__tests__/message-builder.test.d.ts +2 -0
  22. package/dist/util/__tests__/message-builder.test.d.ts.map +1 -0
  23. package/dist/util/__tests__/message-builder.test.js +191 -0
  24. package/dist/util/__tests__/message-builder.test.js.map +1 -0
  25. package/dist/util/message-builder.d.ts +10 -0
  26. package/dist/util/message-builder.d.ts.map +1 -0
  27. package/dist/util/message-builder.js +31 -0
  28. package/dist/util/message-builder.js.map +1 -0
  29. package/esm/hooks/__tests__/use-message-images.test.d.ts +2 -0
  30. package/esm/hooks/__tests__/use-message-images.test.d.ts.map +1 -0
  31. package/esm/hooks/__tests__/use-message-images.test.js +64 -0
  32. package/esm/hooks/__tests__/use-message-images.test.js.map +1 -0
  33. package/esm/hooks/use-message-images.d.ts +25 -0
  34. package/esm/hooks/use-message-images.d.ts.map +1 -0
  35. package/esm/hooks/use-message-images.js +63 -0
  36. package/esm/hooks/use-message-images.js.map +1 -0
  37. package/esm/index.d.ts +1 -0
  38. package/esm/index.d.ts.map +1 -1
  39. package/esm/index.js +1 -0
  40. package/esm/index.js.map +1 -1
  41. package/esm/providers/tambo-thread-input-provider.d.ts +11 -0
  42. package/esm/providers/tambo-thread-input-provider.d.ts.map +1 -1
  43. package/esm/providers/tambo-thread-input-provider.js +63 -12
  44. package/esm/providers/tambo-thread-input-provider.js.map +1 -1
  45. package/esm/providers/tambo-thread-provider.d.ts +1 -0
  46. package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
  47. package/esm/providers/tambo-thread-provider.js +7 -3
  48. package/esm/providers/tambo-thread-provider.js.map +1 -1
  49. package/esm/util/__tests__/message-builder.test.d.ts +2 -0
  50. package/esm/util/__tests__/message-builder.test.d.ts.map +1 -0
  51. package/esm/util/__tests__/message-builder.test.js +189 -0
  52. package/esm/util/__tests__/message-builder.test.js.map +1 -0
  53. package/esm/util/message-builder.d.ts +10 -0
  54. package/esm/util/message-builder.d.ts.map +1 -0
  55. package/esm/util/message-builder.js +28 -0
  56. package/esm/util/message-builder.js.map +1 -0
  57. package/package.json +1 -1
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Represents an image staged for upload
3
+ */
4
+ export interface StagedImage {
5
+ id: string;
6
+ name: string;
7
+ dataUrl: string;
8
+ file: File;
9
+ size: number;
10
+ type: string;
11
+ }
12
+ interface UseMessageImagesReturn {
13
+ images: StagedImage[];
14
+ addImage: (file: File) => Promise<void>;
15
+ addImages: (files: File[]) => Promise<void>;
16
+ removeImage: (id: string) => void;
17
+ clearImages: () => void;
18
+ }
19
+ /**
20
+ * Hook for managing images in message input
21
+ * @returns Object with images array and management functions
22
+ */
23
+ export declare function useMessageImages(): UseMessageImagesReturn;
24
+ export {};
25
+ //# sourceMappingURL=use-message-images.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-message-images.d.ts","sourceRoot":"","sources":["../../src/hooks/use-message-images.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,sBAAsB;IAC9B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,SAAS,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CAqEzD"}
@@ -0,0 +1,63 @@
1
+ import { useCallback, useState } from "react";
2
+ /**
3
+ * Hook for managing images in message input
4
+ * @returns Object with images array and management functions
5
+ */
6
+ export function useMessageImages() {
7
+ const [images, setImages] = useState([]);
8
+ const fileToDataUrl = async (file) => {
9
+ return await new Promise((resolve, reject) => {
10
+ const reader = new FileReader();
11
+ reader.onload = () => resolve(reader.result);
12
+ reader.onerror = reject;
13
+ reader.readAsDataURL(file);
14
+ });
15
+ };
16
+ const addImage = useCallback(async (file) => {
17
+ if (!file.type.startsWith("image/")) {
18
+ throw new Error("Only image files are allowed");
19
+ }
20
+ const dataUrl = await fileToDataUrl(file);
21
+ const newImage = {
22
+ id: crypto.randomUUID(),
23
+ name: file.name,
24
+ dataUrl,
25
+ file,
26
+ size: file.size,
27
+ type: file.type,
28
+ };
29
+ setImages((prev) => [...prev, newImage]);
30
+ }, []);
31
+ const addImages = useCallback(async (files) => {
32
+ const imageFiles = files.filter((file) => file.type.startsWith("image/"));
33
+ if (imageFiles.length === 0) {
34
+ throw new Error("No valid image files provided");
35
+ }
36
+ const newImages = await Promise.all(imageFiles.map(async (file) => {
37
+ const dataUrl = await fileToDataUrl(file);
38
+ return {
39
+ id: crypto.randomUUID(),
40
+ name: file.name,
41
+ dataUrl,
42
+ file,
43
+ size: file.size,
44
+ type: file.type,
45
+ };
46
+ }));
47
+ setImages((prev) => [...prev, ...newImages]);
48
+ }, []);
49
+ const removeImage = useCallback((id) => {
50
+ setImages((prev) => prev.filter((img) => img.id !== id));
51
+ }, []);
52
+ const clearImages = useCallback(() => {
53
+ setImages([]);
54
+ }, []);
55
+ return {
56
+ images,
57
+ addImage,
58
+ addImages,
59
+ removeImage,
60
+ clearImages,
61
+ };
62
+ }
63
+ //# sourceMappingURL=use-message-images.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-message-images.js","sourceRoot":"","sources":["../../src/hooks/use-message-images.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAsB9C;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAgB,EAAE,CAAC,CAAC;IAExD,MAAM,aAAa,GAAG,KAAK,EAAE,IAAU,EAAmB,EAAE;QAC1D,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAChC,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAgB,CAAC,CAAC;YACvD,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;YACxB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CA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I,CAAC,IAAI;gBACf,OAAO;gBACP,IAAI;gBACJ,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;QAEF,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;IAC/C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,EAAU,EAAE,EAAE;QAC7C,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACnC,SAAS,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,MAAM;QACN,QAAQ;QACR,SAAS;QACT,WAAW;QACX,WAAW;KACZ,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useState } from \"react\";\n\n/**\n * Represents an image staged for upload\n */\nexport interface StagedImage {\n id: string;\n name: string;\n dataUrl: string;\n file: File;\n size: number;\n type: string;\n}\n\ninterface UseMessageImagesReturn {\n images: StagedImage[];\n addImage: (file: File) => Promise<void>;\n addImages: (files: File[]) => Promise<void>;\n removeImage: (id: string) => void;\n clearImages: () => void;\n}\n\n/**\n * Hook for managing images in message input\n * @returns Object with images array and management functions\n */\nexport function useMessageImages(): UseMessageImagesReturn {\n const [images, setImages] = useState<StagedImage[]>([]);\n\n const fileToDataUrl = async (file: File): Promise<string> => {\n return await new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => resolve(reader.result as string);\n reader.onerror = reject;\n reader.readAsDataURL(file);\n });\n };\n\n const addImage = useCallback(async (file: File) => {\n if (!file.type.startsWith(\"image/\")) {\n throw new Error(\"Only image files are allowed\");\n }\n\n const dataUrl = await fileToDataUrl(file);\n const newImage: StagedImage = {\n id: crypto.randomUUID(),\n name: file.name,\n dataUrl,\n file,\n size: file.size,\n type: file.type,\n };\n\n setImages((prev) => [...prev, newImage]);\n }, []);\n\n const addImages = useCallback(async (files: File[]) => {\n const imageFiles = files.filter((file) => file.type.startsWith(\"image/\"));\n\n if (imageFiles.length === 0) {\n throw new Error(\"No valid image files provided\");\n }\n\n const newImages = await Promise.all(\n imageFiles.map(async (file) => {\n const dataUrl = await fileToDataUrl(file);\n return {\n id: crypto.randomUUID(),\n name: file.name,\n dataUrl,\n file,\n size: file.size,\n type: file.type,\n };\n }),\n );\n\n setImages((prev) => [...prev, ...newImages]);\n }, []);\n\n const removeImage = useCallback((id: string) => {\n setImages((prev) => prev.filter((img) => img.id !== id));\n }, []);\n\n const clearImages = useCallback(() => {\n setImages([]);\n }, []);\n\n return {\n images,\n addImage,\n addImages,\n removeImage,\n clearImages,\n };\n}\n"]}
package/esm/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /** Exports for the library. Only publically available exports are re-exported here. Anything not exported here is not supported and may change or break at any time. */
2
2
  export { useTamboComponentState } from "./hooks/use-component-state";
3
3
  export { TamboMessageProvider, useTamboCurrentMessage, } from "./hooks/use-current-message";
4
+ export { useMessageImages, type StagedImage } from "./hooks/use-message-images";
4
5
  export { useTamboStreamingProps } from "./hooks/use-streaming-props";
5
6
  export * from "./hooks/use-suggestions";
6
7
  export { useTamboStreamStatus, type PropStatus, type StreamStatus, } from "./hooks/use-tambo-stream-status";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,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OAAO,EACL,oBAAoB,EACpB,+BAA+B,GAChC,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,GACf,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,EACpB,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,EAC3B,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,QAAQ,EACR,cAAc,EACd,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,+BAA+B,EACpC,KAAK,gCAAgC,EACrC,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,GAClC,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,QAAQ,EACR,cAAc,EACd,YAAY,GACb,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,UAAU,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,6DAA6D,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,SAAS,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,eAAe,EACf,KAAK,kBAAkB,GACxB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,YAAY,EACV,0BAA0B,IAAI,qBAAqB,EACnD,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,qBAAqB,IAAI,gBAAgB,EACzC,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,GAChC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,oBAAoB,EACpB,+BAA+B,GAChC,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,GACf,MAAM,mBAAmB,CAAC"}
package/esm/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  /** Exports for the library. Only publically available exports are re-exported here. Anything not exported here is not supported and may change or break at any time. */
2
2
  export { useTamboComponentState } from "./hooks/use-component-state";
3
3
  export { TamboMessageProvider, useTamboCurrentMessage, } from "./hooks/use-current-message";
4
+ export { useMessageImages } from "./hooks/use-message-images";
4
5
  export { useTamboStreamingProps } from "./hooks/use-streaming-props";
5
6
  export * from "./hooks/use-suggestions";
6
7
  export { useTamboStreamStatus, } from "./hooks/use-tambo-stream-status";
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,GAGrB,MAAM,iCAAiC,CAAC;AAEzC,gCAAgC;AAChC,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,EAC3B,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,QAAQ,EACR,cAAc,EACd,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,mBAAmB,GAOpB,MAAM,aAAa,CAAC;AAcrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAQ/D,OAAO,EACL,eAAe,GAEhB,MAAM,qCAAqC,CAAC;AAO7C,OAAO,EACL,qBAAqB,IAAI,gBAAgB,GAG1C,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,oBAAoB,EACpB,+BAA+B,GAChC,MAAM,yCAAyC,CAAC;AAEjD,0BAA0B;AAC1B,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC","sourcesContent":["/** Exports for the library. Only publically available exports are re-exported here. Anything not exported here is not supported and may change or break at any time. */\n\nexport { useTamboComponentState } from \"./hooks/use-component-state\";\nexport {\n TamboMessageProvider,\n useTamboCurrentMessage,\n} from \"./hooks/use-current-message\";\nexport { useTamboStreamingProps } from \"./hooks/use-streaming-props\";\nexport * from \"./hooks/use-suggestions\";\nexport {\n useTamboStreamStatus,\n type PropStatus,\n type StreamStatus,\n} from \"./hooks/use-tambo-stream-status\";\n\n// Re-export provider components\nexport {\n TamboClientProvider,\n TamboComponentProvider,\n TamboContextHelpersProvider,\n TamboPropStreamProvider,\n TamboProvider,\n TamboStubProvider,\n TamboThreadInputProvider,\n TamboThreadProvider,\n useIsTamboTokenUpdating,\n useTambo,\n useTamboClient,\n useTamboContextHelpers,\n useTamboGenerationStage,\n useTamboStream,\n useTamboThread,\n useTamboThreadInput,\n type TamboComponent,\n type TamboContextHelpersContextProps,\n type TamboContextHelpersProviderProps,\n type TamboRegistryContext,\n type TamboStubProviderProps,\n type TamboThreadInputContextProps,\n} from \"./providers\";\n\n// Re-export types from Tambo Node SDK\nexport type {\n APIError,\n RateLimitError,\n TamboAIError,\n} from \"@tambo-ai/typescript-sdk\";\nexport type {\n Suggestion,\n SuggestionGenerateParams,\n SuggestionGenerateResponse,\n SuggestionListResponse,\n} from \"@tambo-ai/typescript-sdk/resources/beta/threads/suggestions\";\nexport { useTamboThreadList } from \"./hooks/use-tambo-threads\";\nexport {\n type ComponentContextToolMetadata,\n type ComponentRegistry,\n type ParameterSpec,\n type RegisteredComponent,\n type TamboTool,\n} from \"./model/component-metadata\";\nexport {\n GenerationStage,\n type TamboThreadMessage,\n} from \"./model/generate-component-response\";\nexport { type TamboThread } from \"./model/tambo-thread\";\n\nexport type {\n TamboInteractableComponent as InteractableComponent,\n TamboInteractableContext,\n} from \"./model/tambo-interactable\";\nexport {\n withTamboInteractable as withInteractable,\n type InteractableConfig,\n type WithTamboInteractableProps,\n} from \"./providers/hoc/with-tambo-interactable\";\nexport {\n useTamboInteractable,\n useCurrentInteractablesSnapshot,\n} from \"./providers/tambo-interactable-provider\";\n\n// Context helpers exports\nexport {\n currentPageContextHelper,\n currentTimeContextHelper,\n} from \"./context-helpers\";\nexport type {\n AdditionalContext,\n ContextHelperFn,\n ContextHelpers,\n} from \"./context-helpers\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAoB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,GAGrB,MAAM,iCAAiC,CAAC;AAEzC,gCAAgC;AAChC,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,EAC3B,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,QAAQ,EACR,cAAc,EACd,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,mBAAmB,GAOpB,MAAM,aAAa,CAAC;AAcrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAQ/D,OAAO,EACL,eAAe,GAEhB,MAAM,qCAAqC,CAAC;AAO7C,OAAO,EACL,qBAAqB,IAAI,gBAAgB,GAG1C,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,oBAAoB,EACpB,+BAA+B,GAChC,MAAM,yCAAyC,CAAC;AAEjD,0BAA0B;AAC1B,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC","sourcesContent":["/** Exports for the library. Only publically available exports are re-exported here. Anything not exported here is not supported and may change or break at any time. */\n\nexport { useTamboComponentState } from \"./hooks/use-component-state\";\nexport {\n TamboMessageProvider,\n useTamboCurrentMessage,\n} from \"./hooks/use-current-message\";\nexport { useMessageImages, type StagedImage } from \"./hooks/use-message-images\";\nexport { useTamboStreamingProps } from \"./hooks/use-streaming-props\";\nexport * from \"./hooks/use-suggestions\";\nexport {\n useTamboStreamStatus,\n type PropStatus,\n type StreamStatus,\n} from \"./hooks/use-tambo-stream-status\";\n\n// Re-export provider components\nexport {\n TamboClientProvider,\n TamboComponentProvider,\n TamboContextHelpersProvider,\n TamboPropStreamProvider,\n TamboProvider,\n TamboStubProvider,\n TamboThreadInputProvider,\n TamboThreadProvider,\n useIsTamboTokenUpdating,\n useTambo,\n useTamboClient,\n useTamboContextHelpers,\n useTamboGenerationStage,\n useTamboStream,\n useTamboThread,\n useTamboThreadInput,\n type TamboComponent,\n type TamboContextHelpersContextProps,\n type TamboContextHelpersProviderProps,\n type TamboRegistryContext,\n type TamboStubProviderProps,\n type TamboThreadInputContextProps,\n} from \"./providers\";\n\n// Re-export types from Tambo Node SDK\nexport type {\n APIError,\n RateLimitError,\n TamboAIError,\n} from \"@tambo-ai/typescript-sdk\";\nexport type {\n Suggestion,\n SuggestionGenerateParams,\n SuggestionGenerateResponse,\n SuggestionListResponse,\n} from \"@tambo-ai/typescript-sdk/resources/beta/threads/suggestions\";\nexport { useTamboThreadList } from \"./hooks/use-tambo-threads\";\nexport {\n type ComponentContextToolMetadata,\n type ComponentRegistry,\n type ParameterSpec,\n type RegisteredComponent,\n type TamboTool,\n} from \"./model/component-metadata\";\nexport {\n GenerationStage,\n type TamboThreadMessage,\n} from \"./model/generate-component-response\";\nexport { type TamboThread } from \"./model/tambo-thread\";\n\nexport type {\n TamboInteractableComponent as InteractableComponent,\n TamboInteractableContext,\n} from \"./model/tambo-interactable\";\nexport {\n withTamboInteractable as withInteractable,\n type InteractableConfig,\n type WithTamboInteractableProps,\n} from \"./providers/hoc/with-tambo-interactable\";\nexport {\n useTamboInteractable,\n useCurrentInteractablesSnapshot,\n} from \"./providers/tambo-interactable-provider\";\n\n// Context helpers exports\nexport {\n currentPageContextHelper,\n currentTimeContextHelper,\n} from \"./context-helpers\";\nexport type {\n AdditionalContext,\n ContextHelperFn,\n ContextHelpers,\n} from \"./context-helpers\";\n"]}
@@ -1,5 +1,6 @@
1
1
  import React, { PropsWithChildren } from "react";
2
2
  import { UseTamboMutationResult } from "../hooks/react-query-hooks";
3
+ import { StagedImage } from "../hooks/use-message-images";
3
4
  /**
4
5
  * Error messages for various input-related error scenarios
5
6
  * These messages are used to provide user-friendly error feedback
@@ -34,6 +35,16 @@ export interface TamboThreadInputContextProps extends Omit<UseTamboMutationResul
34
35
  forceToolChoice?: string;
35
36
  additionalContext?: Record<string, any>;
36
37
  }) => Promise<void>;
38
+ /** Currently staged images */
39
+ images: StagedImage[];
40
+ /** Add a single image */
41
+ addImage: (file: File) => Promise<void>;
42
+ /** Add multiple images */
43
+ addImages: (files: File[]) => Promise<void>;
44
+ /** Remove an image by id */
45
+ removeImage: (id: string) => void;
46
+ /** Clear all staged images */
47
+ clearImages: () => void;
37
48
  }
38
49
  export declare const TamboThreadInputContext: React.Context<TamboThreadInputContextProps | undefined>;
39
50
  export interface TamboThreadInputProviderProps {
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-thread-input-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-thread-input-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAIlB,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,sBAAsB,EACvB,MAAM,4BAA4B,CAAC;AAKpC;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;CAKvB,CAAC;AAEX,MAAM,WAAW,4BACf,SAAQ,IAAI,CACV,sBAAsB,CACpB,IAAI,EACJ,KAAK,EACH;IACE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC,GACD,SAAS,EACX,OAAO,CACR,EACD,QAAQ,GAAG,aAAa,CACzB;IACD,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;OAGG;IACH,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACzC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB;AAED,eAAO,MAAM,uBAAuB,yDAExB,CAAC;AAEb,MAAM,WAAW,6BAA6B;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAC7C,iBAAiB,CAAC,6BAA6B,CAAC,CAyDjD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,oCAS/B,CAAC"}
1
+ {"version":3,"file":"tambo-thread-input-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-thread-input-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAIlB,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,sBAAsB,EACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAoB,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAM5E;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;CAKvB,CAAC;AAEX,MAAM,WAAW,4BACf,SAAQ,IAAI,CACV,sBAAsB,CACpB,IAAI,EACJ,KAAK,EACH;IACE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC,GACD,SAAS,EACX,OAAO,CACR,EACD,QAAQ,GAAG,aAAa,CACzB;IACD,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;OAGG;IACH,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACzC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,8BAA8B;IAC9B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,yBAAyB;IACzB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,0BAA0B;IAC1B,SAAS,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,4BAA4B;IAC5B,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,8BAA8B;IAC9B,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,eAAO,MAAM,uBAAuB,yDAExB,CAAC;AAEb,MAAM,WAAW,6BAA6B;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAC7C,iBAAiB,CAAC,6BAA6B,CAAC,CAuIjD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,oCAS/B,CAAC"}
@@ -1,8 +1,10 @@
1
1
  "use client";
2
2
  import React, { createContext, useCallback, useContext, useState, } from "react";
3
3
  import { useTamboMutation, } from "../hooks/react-query-hooks";
4
+ import { useMessageImages } from "../hooks/use-message-images";
4
5
  import { ThreadInputError } from "../model/thread-input-error";
5
6
  import { validateInput } from "../model/validate-input";
7
+ import { buildMessageContent } from "../util/message-builder";
6
8
  import { useTamboThread } from "./tambo-thread-provider";
7
9
  /**
8
10
  * Error messages for various input-related error scenarios
@@ -28,20 +30,64 @@ export const TamboThreadInputContext = createContext(undefined);
28
30
  export const TamboThreadInputProvider = ({ children, contextKey }) => {
29
31
  const { thread, sendThreadMessage } = useTamboThread();
30
32
  const [inputValue, setInputValue] = useState("");
33
+ const imageState = useMessageImages();
31
34
  const submit = useCallback(async ({ contextKey: submitContextKey, streamResponse, forceToolChoice, additionalContext, } = {}) => {
32
- const validation = validateInput(inputValue);
33
- if (!validation.isValid) {
34
- throw new ThreadInputError(`Cannot submit message: ${validation.error ?? INPUT_ERROR_MESSAGES.VALIDATION}`, { cause: validation.error });
35
+ // Validate text input if present
36
+ if (inputValue?.trim()) {
37
+ const validation = validateInput(inputValue);
38
+ if (!validation.isValid) {
39
+ throw new ThreadInputError(`Cannot submit message: ${validation.error ?? INPUT_ERROR_MESSAGES.VALIDATION}`, { cause: validation.error });
40
+ }
35
41
  }
36
- await sendThreadMessage(validation.sanitizedInput, {
37
- threadId: thread.id,
38
- contextKey: submitContextKey ?? contextKey ?? undefined,
39
- streamResponse: streamResponse,
40
- forceToolChoice: forceToolChoice,
41
- additionalContext: additionalContext,
42
- });
43
- setInputValue(""); // Clear local state
44
- }, [inputValue, sendThreadMessage, thread.id, contextKey]);
42
+ // Check if we have content to send
43
+ if (!inputValue.trim() && imageState.images.length === 0) {
44
+ throw new ThreadInputError(INPUT_ERROR_MESSAGES.EMPTY, {
45
+ cause: "No text or images to send",
46
+ });
47
+ }
48
+ // Build message content with text and images
49
+ const messageContent = buildMessageContent(inputValue, imageState.images);
50
+ try {
51
+ await sendThreadMessage(inputValue || "Image message", {
52
+ threadId: thread.id,
53
+ contextKey: submitContextKey ?? contextKey ?? undefined,
54
+ streamResponse: streamResponse,
55
+ forceToolChoice: forceToolChoice,
56
+ additionalContext: additionalContext,
57
+ content: messageContent,
58
+ });
59
+ }
60
+ catch (error) {
61
+ // Handle image-related errors with friendly messages
62
+ if (imageState.images.length > 0) {
63
+ const errorMessage = error?.message?.toLowerCase() ?? "";
64
+ // Backend not yet supporting image content type
65
+ if (errorMessage.includes("unknown content part type: image")) {
66
+ throw new ThreadInputError("Image attachments are not yet supported by the backend. This feature is coming soon.", { cause: error });
67
+ }
68
+ // Handle specific model vision support errors
69
+ // OpenAI errors
70
+ if (errorMessage.includes("does not support image message content types") ||
71
+ (errorMessage.includes("invalid model") &&
72
+ errorMessage.includes("image_url is only supported by certain models"))) {
73
+ throw new ThreadInputError("This model doesn't support images. Please use GPT-4o, GPT-4 Turbo, or other vision-capable models.", { cause: error });
74
+ }
75
+ // Anthropic Claude errors
76
+ if (errorMessage.includes("does not support image") ||
77
+ errorMessage.includes("vision not supported")) {
78
+ throw new ThreadInputError("This Claude model doesn't support images. Please use Claude 3.5 Sonnet, Claude 3 Opus, or other vision-capable models.", { cause: error });
79
+ }
80
+ // Generic image/vision errors
81
+ if (errorMessage.includes("image") ||
82
+ errorMessage.includes("vision")) {
83
+ throw new ThreadInputError("This model doesn't support image attachments. Please use a vision-capable model.", { cause: error });
84
+ }
85
+ }
86
+ throw error;
87
+ }
88
+ // Clear text after successful submission
89
+ setInputValue("");
90
+ }, [inputValue, sendThreadMessage, thread.id, contextKey, imageState]);
45
91
  const { mutateAsync: submitAsync, mutate: _unusedSubmit, ...mutationState } = useTamboMutation({
46
92
  mutationFn: submit,
47
93
  });
@@ -50,6 +96,11 @@ export const TamboThreadInputProvider = ({ children, contextKey }) => {
50
96
  value: inputValue,
51
97
  setValue: setInputValue,
52
98
  submit: submitAsync,
99
+ images: imageState.images,
100
+ addImage: imageState.addImage,
101
+ addImages: imageState.addImages,
102
+ removeImage: imageState.removeImage,
103
+ clearImages: imageState.clearImages,
53
104
  };
54
105
  return (React.createElement(TamboThreadInputContext.Provider, { value: value }, children));
55
106
  };
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-thread-input-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-thread-input-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EACL,gBAAgB,GAEjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,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C,CAAC,CAAC;QACH,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,oBAAoB;IACzC,CAAC,EACD,CAAC,UAAU,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,CACvD,CAAC;IAEF,MAAM,EACJ,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,aAAa,EACrB,GAAG,aAAa,EACjB,GAAG,gBAAgB,CAAC;QACnB,UAAU,EAAE,MAAM;KACnB,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG;QACZ,GAAG,aAAa;QAChB,KAAK,EAAE,UAAU;QACjB,QAAQ,EAAE,aAAa;QACvB,MAAM,EAAE,WAAW;KACpB,CAAC;IAEF,OAAO,CACL,oBAAC,uBAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAC3C,QAAQ,CACwB,CACpC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,OAAO,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useState,\n} from \"react\";\nimport {\n useTamboMutation,\n UseTamboMutationResult,\n} from \"../hooks/react-query-hooks\";\nimport { ThreadInputError } from \"../model/thread-input-error\";\nimport { validateInput } from \"../model/validate-input\";\nimport { useTamboThread } from \"./tambo-thread-provider\";\n\n/**\n * Error messages for various input-related error scenarios\n * These messages are used to provide user-friendly error feedback\n * @readonly\n */\nexport const INPUT_ERROR_MESSAGES = {\n EMPTY: \"Message cannot be empty\",\n NETWORK: \"Network error. Please check your connection\",\n SERVER: \"Server error. Please try again\",\n VALIDATION: \"Invalid message format\",\n} as const;\n\nexport interface TamboThreadInputContextProps\n extends Omit<\n UseTamboMutationResult<\n void,\n Error,\n | {\n contextKey?: string;\n streamResponse?: boolean;\n forceToolChoice?: string;\n additionalContext?: Record<string, any>;\n }\n | undefined,\n unknown\n >,\n \"mutate\" | \"mutateAsync\"\n > {\n /** Current value of the input field */\n value: string;\n /**\n * Function to update the input value\n * @param value - New value for the input field\n */\n setValue: (value: string) => void;\n /**\n * Function to submit the current input value\n * @param options - Submission options\n */\n submit: (options?: {\n contextKey?: string;\n streamResponse?: boolean;\n forceToolChoice?: string;\n additionalContext?: Record<string, any>;\n }) => Promise<void>;\n}\n\nexport const TamboThreadInputContext = createContext<\n TamboThreadInputContextProps | undefined\n>(undefined);\n\nexport interface TamboThreadInputProviderProps {\n contextKey?: string;\n}\n\n/**\n * Provider that manages shared thread input state across all components\n * This ensures that useTamboThreadInput, useTamboSuggestions, and components\n * all share the same input state\n * @param props - The props for the TamboThreadInputProvider\n * @param props.contextKey - Optional context key.\n * @param props.children - The children to render.\n * @returns The thread input context\n */\nexport const TamboThreadInputProvider: React.FC<\n PropsWithChildren<TamboThreadInputProviderProps>\n> = ({ children, contextKey }) => {\n const { thread, sendThreadMessage } = useTamboThread();\n const [inputValue, setInputValue] = useState(\"\");\n\n const submit = useCallback(\n async ({\n contextKey: submitContextKey,\n streamResponse,\n forceToolChoice,\n additionalContext,\n }: {\n contextKey?: string;\n streamResponse?: boolean;\n forceToolChoice?: string;\n additionalContext?: Record<string, any>;\n } = {}) => {\n const validation = validateInput(inputValue);\n if (!validation.isValid) {\n throw new ThreadInputError(\n `Cannot submit message: ${validation.error ?? INPUT_ERROR_MESSAGES.VALIDATION}`,\n { cause: validation.error },\n );\n }\n\n await sendThreadMessage(validation.sanitizedInput, {\n threadId: thread.id,\n contextKey: submitContextKey ?? contextKey ?? undefined,\n streamResponse: streamResponse,\n forceToolChoice: forceToolChoice,\n additionalContext: additionalContext,\n });\n setInputValue(\"\"); // Clear local state\n },\n [inputValue, sendThreadMessage, thread.id, contextKey],\n );\n\n const {\n mutateAsync: submitAsync,\n mutate: _unusedSubmit,\n ...mutationState\n } = useTamboMutation({\n mutationFn: submit,\n });\n\n const value = {\n ...mutationState,\n value: inputValue,\n setValue: setInputValue,\n submit: submitAsync,\n };\n\n return (\n <TamboThreadInputContext.Provider value={value}>\n {children}\n </TamboThreadInputContext.Provider>\n );\n};\n\n/**\n * Hook to access the shared thread input state\n * contextKey parameter is not passed here anymore. Instead, use the contextKey prop in the TamboProvider.\n * @returns The thread input context\n */\nexport const useTamboThreadInput = () => {\n const context = useContext(TamboThreadInputContext);\n if (!context) {\n throw new Error(\n \"useTamboThreadInput must be used within a TamboThreadInputProvider\",\n );\n }\n\n return context;\n};\n"]}
1
+ {"version":3,"file":"tambo-thread-input-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-thread-input-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EACL,gBAAgB,GAEjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAe,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,KAAK,EAAE,yBAAyB;IAChC,OAAO,EAAE,6CAA6C;IACtD,MAAM,EAAE,gCAAgC;IACxC,UAAU,EAAE,wBAAwB;CAC5B,CAAC;AA+CX,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAElD,SAAS,CAAC,CAAC;AAMb;;;;;;;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AClF,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;QAED,yCAAyC;QACzC,aAAa,CAAC,EAAE,CAAC,CAAC;IACpB,CAAC,EACD,CAAC,UAAU,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,CACnE,CAAC;IAEF,MAAM,EACJ,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,aAAa,EACrB,GAAG,aAAa,EACjB,GAAG,gBAAgB,CAAC;QACnB,UAAU,EAAE,MAAM;KACnB,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG;QACZ,GAAG,aAAa;QAChB,KAAK,EAAE,UAAU;QACjB,QAAQ,EAAE,aAAa;QACvB,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,WAAW,EAAE,UAAU,CAAC,WAAW;KACpC,CAAC;IAEF,OAAO,CACL,oBAAC,uBAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAC3C,QAAQ,CACwB,CACpC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,OAAO,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useState,\n} from \"react\";\nimport {\n useTamboMutation,\n UseTamboMutationResult,\n} from \"../hooks/react-query-hooks\";\nimport { useMessageImages, StagedImage } from \"../hooks/use-message-images\";\nimport { ThreadInputError } from \"../model/thread-input-error\";\nimport { validateInput } from \"../model/validate-input\";\nimport { buildMessageContent } from \"../util/message-builder\";\nimport { useTamboThread } from \"./tambo-thread-provider\";\n\n/**\n * Error messages for various input-related error scenarios\n * These messages are used to provide user-friendly error feedback\n * @readonly\n */\nexport const INPUT_ERROR_MESSAGES = {\n EMPTY: \"Message cannot be empty\",\n NETWORK: \"Network error. Please check your connection\",\n SERVER: \"Server error. Please try again\",\n VALIDATION: \"Invalid message format\",\n} as const;\n\nexport interface TamboThreadInputContextProps\n extends Omit<\n UseTamboMutationResult<\n void,\n Error,\n | {\n contextKey?: string;\n streamResponse?: boolean;\n forceToolChoice?: string;\n additionalContext?: Record<string, any>;\n }\n | undefined,\n unknown\n >,\n \"mutate\" | \"mutateAsync\"\n > {\n /** Current value of the input field */\n value: string;\n /**\n * Function to update the input value\n * @param value - New value for the input field\n */\n setValue: (value: string) => void;\n /**\n * Function to submit the current input value\n * @param options - Submission options\n */\n submit: (options?: {\n contextKey?: string;\n streamResponse?: boolean;\n forceToolChoice?: string;\n additionalContext?: Record<string, any>;\n }) => Promise<void>;\n /** Currently staged images */\n images: StagedImage[];\n /** Add a single image */\n addImage: (file: File) => Promise<void>;\n /** Add multiple images */\n addImages: (files: File[]) => Promise<void>;\n /** Remove an image by id */\n removeImage: (id: string) => void;\n /** Clear all staged images */\n clearImages: () => void;\n}\n\nexport const TamboThreadInputContext = createContext<\n TamboThreadInputContextProps | undefined\n>(undefined);\n\nexport interface TamboThreadInputProviderProps {\n contextKey?: string;\n}\n\n/**\n * Provider that manages shared thread input state across all components\n * This ensures that useTamboThreadInput, useTamboSuggestions, and components\n * all share the same input state\n * @param props - The props for the TamboThreadInputProvider\n * @param props.contextKey - Optional context key.\n * @param props.children - The children to render.\n * @returns The thread input context\n */\nexport const TamboThreadInputProvider: React.FC<\n PropsWithChildren<TamboThreadInputProviderProps>\n> = ({ children, contextKey }) => {\n const { thread, sendThreadMessage } = useTamboThread();\n const [inputValue, setInputValue] = useState(\"\");\n const imageState = useMessageImages();\n\n const submit = useCallback(\n async ({\n contextKey: submitContextKey,\n streamResponse,\n forceToolChoice,\n additionalContext,\n }: {\n contextKey?: string;\n streamResponse?: boolean;\n forceToolChoice?: string;\n additionalContext?: Record<string, any>;\n } = {}) => {\n // Validate text input if present\n if (inputValue?.trim()) {\n const validation = validateInput(inputValue);\n if (!validation.isValid) {\n throw new ThreadInputError(\n `Cannot submit message: ${validation.error ?? INPUT_ERROR_MESSAGES.VALIDATION}`,\n { cause: validation.error },\n );\n }\n }\n\n // Check if we have content to send\n if (!inputValue.trim() && imageState.images.length === 0) {\n throw new ThreadInputError(INPUT_ERROR_MESSAGES.EMPTY, {\n cause: \"No text or images to send\",\n });\n }\n\n // Build message content with text and images\n const messageContent = buildMessageContent(inputValue, imageState.images);\n\n try {\n await sendThreadMessage(inputValue || \"Image message\", {\n threadId: thread.id,\n contextKey: submitContextKey ?? contextKey ?? undefined,\n streamResponse: streamResponse,\n forceToolChoice: forceToolChoice,\n additionalContext: additionalContext,\n content: messageContent,\n });\n } catch (error: any) {\n // Handle image-related errors with friendly messages\n if (imageState.images.length > 0) {\n const errorMessage = error?.message?.toLowerCase() ?? \"\";\n\n // Backend not yet supporting image content type\n if (errorMessage.includes(\"unknown content part type: image\")) {\n throw new ThreadInputError(\n \"Image attachments are not yet supported by the backend. This feature is coming soon.\",\n { cause: error },\n );\n }\n\n // Handle specific model vision support errors\n // OpenAI errors\n if (\n errorMessage.includes(\n \"does not support image message content types\",\n ) ||\n (errorMessage.includes(\"invalid model\") &&\n errorMessage.includes(\n \"image_url is only supported by certain models\",\n ))\n ) {\n throw new ThreadInputError(\n \"This model doesn't support images. Please use GPT-4o, GPT-4 Turbo, or other vision-capable models.\",\n { cause: error },\n );\n }\n\n // Anthropic Claude errors\n if (\n errorMessage.includes(\"does not support image\") ||\n errorMessage.includes(\"vision not supported\")\n ) {\n throw new ThreadInputError(\n \"This Claude model doesn't support images. Please use Claude 3.5 Sonnet, Claude 3 Opus, or other vision-capable models.\",\n { cause: error },\n );\n }\n\n // Generic image/vision errors\n if (\n errorMessage.includes(\"image\") ||\n errorMessage.includes(\"vision\")\n ) {\n throw new ThreadInputError(\n \"This model doesn't support image attachments. Please use a vision-capable model.\",\n { cause: error },\n );\n }\n }\n\n throw error;\n }\n\n // Clear text after successful submission\n setInputValue(\"\");\n },\n [inputValue, sendThreadMessage, thread.id, contextKey, imageState],\n );\n\n const {\n mutateAsync: submitAsync,\n mutate: _unusedSubmit,\n ...mutationState\n } = useTamboMutation({\n mutationFn: submit,\n });\n\n const value = {\n ...mutationState,\n value: inputValue,\n setValue: setInputValue,\n submit: submitAsync,\n images: imageState.images,\n addImage: imageState.addImage,\n addImages: imageState.addImages,\n removeImage: imageState.removeImage,\n clearImages: imageState.clearImages,\n };\n\n return (\n <TamboThreadInputContext.Provider value={value}>\n {children}\n </TamboThreadInputContext.Provider>\n );\n};\n\n/**\n * Hook to access the shared thread input state\n * contextKey parameter is not passed here anymore. Instead, use the contextKey prop in the TamboProvider.\n * @returns The thread input context\n */\nexport const useTamboThreadInput = () => {\n const context = useContext(TamboThreadInputContext);\n if (!context) {\n throw new Error(\n \"useTamboThreadInput must be used within a TamboThreadInputProvider\",\n );\n }\n\n return context;\n};\n"]}
@@ -51,6 +51,7 @@ export interface TamboThreadContextProps {
51
51
  contextKey?: string;
52
52
  forceToolChoice?: string;
53
53
  additionalContext?: Record<string, any>;
54
+ content?: TamboAI.Beta.Threads.ChatCompletionContentPart[];
54
55
  }) => Promise<TamboThreadMessage>;
55
56
  }
56
57
  export interface CombinedTamboThreadContextProps extends TamboThreadContextProps, TamboGenerationStageContextProps {
@@ -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,O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AAO,gCAU1C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAO,+BAgBjC,CAAC"}
@@ -495,7 +495,7 @@ export const TamboThreadProvider = ({ children, streaming = true }) => {
495
495
  ]);
496
496
  const sendThreadMessage = useCallback(async (message, options = {}) => {
497
497
  setIgnoreResponse(false);
498
- const { threadId = currentThreadId ?? PLACEHOLDER_THREAD.id, streamResponse = streaming, forceToolChoice, contextKey, additionalContext, } = options;
498
+ const { threadId = currentThreadId ?? PLACEHOLDER_THREAD.id, streamResponse = streaming, forceToolChoice, contextKey, additionalContext, content, } = options;
499
499
  updateThreadStatus(threadId, GenerationStage.FETCHING_CONTEXT);
500
500
  // Get additional context from enabled helpers
501
501
  const helperContexts = await getAdditionalContext();
@@ -507,8 +507,12 @@ export const TamboThreadProvider = ({ children, streaming = true }) => {
507
507
  for (const helperContext of helperContexts) {
508
508
  combinedContext[helperContext.name] = helperContext.context;
509
509
  }
510
+ // Use provided content or build simple text message
511
+ const messageContent = content ?? [
512
+ { type: "text", text: message },
513
+ ];
510
514
  addThreadMessage({
511
- content: [{ type: "text", text: message }],
515
+ content: messageContent,
512
516
  renderedComponent: null,
513
517
  role: "user",
514
518
  threadId: threadId,
@@ -523,7 +527,7 @@ export const TamboThreadProvider = ({ children, streaming = true }) => {
523
527
  const toolCallCounts = {};
524
528
  const params = {
525
529
  messageToAppend: {
526
- content: [{ type: "text", text: message }],
530
+ content: messageContent,
527
531
  role: "user",
528
532
  additionalContext: combinedContext,
529
533
  },