@tambo-ai/react 0.19.0 → 0.19.2

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 (173) hide show
  1. package/dist/hooks/react-query-hooks.d.ts +8 -0
  2. package/dist/hooks/react-query-hooks.d.ts.map +1 -1
  3. package/dist/hooks/react-query-hooks.js +8 -0
  4. package/dist/hooks/react-query-hooks.js.map +1 -1
  5. package/dist/hooks/use-component-state.d.ts +0 -3
  6. package/dist/hooks/use-component-state.d.ts.map +1 -1
  7. package/dist/hooks/use-component-state.js +8 -26
  8. package/dist/hooks/use-component-state.js.map +1 -1
  9. package/dist/hooks/use-current-message.d.ts +27 -7
  10. package/dist/hooks/use-current-message.d.ts.map +1 -1
  11. package/dist/hooks/use-current-message.js +27 -7
  12. package/dist/hooks/use-current-message.js.map +1 -1
  13. package/dist/hooks/use-streaming-props.d.ts +0 -2
  14. package/dist/hooks/use-streaming-props.d.ts.map +1 -1
  15. package/dist/hooks/use-streaming-props.js +2 -3
  16. package/dist/hooks/use-streaming-props.js.map +1 -1
  17. package/dist/hooks/use-suggestions.d.ts +0 -1
  18. package/dist/hooks/use-suggestions.d.ts.map +1 -1
  19. package/dist/hooks/use-suggestions.js +0 -1
  20. package/dist/hooks/use-suggestions.js.map +1 -1
  21. package/dist/hooks/use-tambo-threads.d.ts +35 -5
  22. package/dist/hooks/use-tambo-threads.d.ts.map +1 -1
  23. package/dist/hooks/use-tambo-threads.js +9 -1
  24. package/dist/hooks/use-tambo-threads.js.map +1 -1
  25. package/dist/hooks/use-thread-input.d.ts +0 -1
  26. package/dist/hooks/use-thread-input.d.ts.map +1 -1
  27. package/dist/hooks/use-thread-input.js +0 -1
  28. package/dist/hooks/use-thread-input.js.map +1 -1
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +9 -2
  32. package/dist/index.js.map +1 -1
  33. package/dist/model/component-metadata.d.ts +6 -3
  34. package/dist/model/component-metadata.d.ts.map +1 -1
  35. package/dist/model/component-metadata.js.map +1 -1
  36. package/dist/model/generate-component-response.d.ts +9 -2
  37. package/dist/model/generate-component-response.d.ts.map +1 -1
  38. package/dist/model/generate-component-response.js +5 -0
  39. package/dist/model/generate-component-response.js.map +1 -1
  40. package/dist/model/tambo-thread.d.ts +4 -2
  41. package/dist/model/tambo-thread.d.ts.map +1 -1
  42. package/dist/model/tambo-thread.js.map +1 -1
  43. package/dist/model/validate-input.d.ts +5 -0
  44. package/dist/model/validate-input.d.ts.map +1 -1
  45. package/dist/model/validate-input.js +5 -1
  46. package/dist/model/validate-input.js.map +1 -1
  47. package/dist/providers/tambo-client-provider.d.ts +31 -0
  48. package/dist/providers/tambo-client-provider.d.ts.map +1 -1
  49. package/dist/providers/tambo-client-provider.js +21 -0
  50. package/dist/providers/tambo-client-provider.js.map +1 -1
  51. package/dist/providers/tambo-component-provider.d.ts +12 -0
  52. package/dist/providers/tambo-component-provider.d.ts.map +1 -1
  53. package/dist/providers/tambo-component-provider.js +24 -0
  54. package/dist/providers/tambo-component-provider.js.map +1 -1
  55. package/dist/providers/tambo-provider.d.ts +18 -1
  56. package/dist/providers/tambo-provider.d.ts.map +1 -1
  57. package/dist/providers/tambo-provider.js +25 -2
  58. package/dist/providers/tambo-provider.js.map +1 -1
  59. package/dist/providers/tambo-registry-provider.d.ts +14 -1
  60. package/dist/providers/tambo-registry-provider.d.ts.map +1 -1
  61. package/dist/providers/tambo-registry-provider.js +25 -0
  62. package/dist/providers/tambo-registry-provider.js.map +1 -1
  63. package/dist/providers/tambo-thread-provider.d.ts +25 -2
  64. package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
  65. package/dist/providers/tambo-thread-provider.js +32 -26
  66. package/dist/providers/tambo-thread-provider.js.map +1 -1
  67. package/dist/util/generate-component.d.ts +5 -1
  68. package/dist/util/generate-component.d.ts.map +1 -1
  69. package/dist/util/generate-component.js +5 -1
  70. package/dist/util/generate-component.js.map +1 -1
  71. package/dist/util/query-utils.d.ts +16 -0
  72. package/dist/util/query-utils.d.ts.map +1 -1
  73. package/dist/util/query-utils.js +16 -0
  74. package/dist/util/query-utils.js.map +1 -1
  75. package/dist/util/registry.d.ts +27 -1
  76. package/dist/util/registry.d.ts.map +1 -1
  77. package/dist/util/registry.js +29 -4
  78. package/dist/util/registry.js.map +1 -1
  79. package/dist/util/tool-caller.d.ts +6 -0
  80. package/dist/util/tool-caller.d.ts.map +1 -1
  81. package/dist/util/tool-caller.js +6 -0
  82. package/dist/util/tool-caller.js.map +1 -1
  83. package/esm/hooks/react-query-hooks.d.ts +8 -0
  84. package/esm/hooks/react-query-hooks.d.ts.map +1 -1
  85. package/esm/hooks/react-query-hooks.js +8 -0
  86. package/esm/hooks/react-query-hooks.js.map +1 -1
  87. package/esm/hooks/use-component-state.d.ts +0 -3
  88. package/esm/hooks/use-component-state.d.ts.map +1 -1
  89. package/esm/hooks/use-component-state.js +2 -23
  90. package/esm/hooks/use-component-state.js.map +1 -1
  91. package/esm/hooks/use-current-message.d.ts +27 -7
  92. package/esm/hooks/use-current-message.d.ts.map +1 -1
  93. package/esm/hooks/use-current-message.js +27 -7
  94. package/esm/hooks/use-current-message.js.map +1 -1
  95. package/esm/hooks/use-streaming-props.d.ts +0 -2
  96. package/esm/hooks/use-streaming-props.d.ts.map +1 -1
  97. package/esm/hooks/use-streaming-props.js +2 -3
  98. package/esm/hooks/use-streaming-props.js.map +1 -1
  99. package/esm/hooks/use-suggestions.d.ts +0 -1
  100. package/esm/hooks/use-suggestions.d.ts.map +1 -1
  101. package/esm/hooks/use-suggestions.js +0 -1
  102. package/esm/hooks/use-suggestions.js.map +1 -1
  103. package/esm/hooks/use-tambo-threads.d.ts +35 -5
  104. package/esm/hooks/use-tambo-threads.d.ts.map +1 -1
  105. package/esm/hooks/use-tambo-threads.js +9 -1
  106. package/esm/hooks/use-tambo-threads.js.map +1 -1
  107. package/esm/hooks/use-thread-input.d.ts +0 -1
  108. package/esm/hooks/use-thread-input.d.ts.map +1 -1
  109. package/esm/hooks/use-thread-input.js +0 -1
  110. package/esm/hooks/use-thread-input.js.map +1 -1
  111. package/esm/index.d.ts +1 -1
  112. package/esm/index.d.ts.map +1 -1
  113. package/esm/index.js +1 -1
  114. package/esm/index.js.map +1 -1
  115. package/esm/model/component-metadata.d.ts +6 -3
  116. package/esm/model/component-metadata.d.ts.map +1 -1
  117. package/esm/model/component-metadata.js.map +1 -1
  118. package/esm/model/generate-component-response.d.ts +9 -2
  119. package/esm/model/generate-component-response.d.ts.map +1 -1
  120. package/esm/model/generate-component-response.js +5 -0
  121. package/esm/model/generate-component-response.js.map +1 -1
  122. package/esm/model/tambo-thread.d.ts +4 -2
  123. package/esm/model/tambo-thread.d.ts.map +1 -1
  124. package/esm/model/tambo-thread.js.map +1 -1
  125. package/esm/model/validate-input.d.ts +5 -0
  126. package/esm/model/validate-input.d.ts.map +1 -1
  127. package/esm/model/validate-input.js +5 -1
  128. package/esm/model/validate-input.js.map +1 -1
  129. package/esm/providers/tambo-client-provider.d.ts +31 -0
  130. package/esm/providers/tambo-client-provider.d.ts.map +1 -1
  131. package/esm/providers/tambo-client-provider.js +21 -0
  132. package/esm/providers/tambo-client-provider.js.map +1 -1
  133. package/esm/providers/tambo-component-provider.d.ts +12 -0
  134. package/esm/providers/tambo-component-provider.d.ts.map +1 -1
  135. package/esm/providers/tambo-component-provider.js +24 -0
  136. package/esm/providers/tambo-component-provider.js.map +1 -1
  137. package/esm/providers/tambo-provider.d.ts +18 -1
  138. package/esm/providers/tambo-provider.d.ts.map +1 -1
  139. package/esm/providers/tambo-provider.js +25 -2
  140. package/esm/providers/tambo-provider.js.map +1 -1
  141. package/esm/providers/tambo-registry-provider.d.ts +14 -1
  142. package/esm/providers/tambo-registry-provider.d.ts.map +1 -1
  143. package/esm/providers/tambo-registry-provider.js +25 -0
  144. package/esm/providers/tambo-registry-provider.js.map +1 -1
  145. package/esm/providers/tambo-thread-provider.d.ts +25 -2
  146. package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
  147. package/esm/providers/tambo-thread-provider.js +32 -26
  148. package/esm/providers/tambo-thread-provider.js.map +1 -1
  149. package/esm/util/generate-component.d.ts +5 -1
  150. package/esm/util/generate-component.d.ts.map +1 -1
  151. package/esm/util/generate-component.js +5 -1
  152. package/esm/util/generate-component.js.map +1 -1
  153. package/esm/util/query-utils.d.ts +16 -0
  154. package/esm/util/query-utils.d.ts.map +1 -1
  155. package/esm/util/query-utils.js +16 -0
  156. package/esm/util/query-utils.js.map +1 -1
  157. package/esm/util/registry.d.ts +27 -1
  158. package/esm/util/registry.d.ts.map +1 -1
  159. package/esm/util/registry.js +28 -2
  160. package/esm/util/registry.js.map +1 -1
  161. package/esm/util/tool-caller.d.ts +6 -0
  162. package/esm/util/tool-caller.d.ts.map +1 -1
  163. package/esm/util/tool-caller.js +6 -0
  164. package/esm/util/tool-caller.js.map +1 -1
  165. package/package.json +4 -2
  166. package/dist/util/messages.d.ts +0 -3
  167. package/dist/util/messages.d.ts.map +0 -1
  168. package/dist/util/messages.js +0 -12
  169. package/dist/util/messages.js.map +0 -1
  170. package/esm/util/messages.d.ts +0 -3
  171. package/esm/util/messages.d.ts.map +0 -1
  172. package/esm/util/messages.js +0 -9
  173. package/esm/util/messages.js.map +0 -1
@@ -4,11 +4,9 @@ import { useEffect } from "react";
4
4
  *
5
5
  * This hook streamlines the common pattern of updating component state when receiving new
6
6
  * streamed values from Tambo, eliminating the need to write repetitive useEffect code.
7
- *
8
7
  * @param currentState - The current state object from useTamboComponentState
9
8
  * @param setState - The setState function from useTamboComponentState
10
9
  * @param streamingProps - An object mapping state keys to prop values that should update the state
11
- *
12
10
  * @example
13
11
  * ```tsx
14
12
  * // Instead of writing a complex useEffect:
@@ -40,7 +38,8 @@ export function useTamboStreamingProps(currentState, setState, streamingProps) {
40
38
  });
41
39
  }
42
40
  }
41
+ // Only run when streamingProps change
43
42
  // eslint-disable-next-line react-hooks/exhaustive-deps
44
- }, [currentState, setState, ...Object.values(streamingProps)]);
43
+ }, [...Object.values(streamingProps)]);
45
44
  }
46
45
  //# sourceMappingURL=use-streaming-props.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-streaming-props.js","sourceRoot":"","sources":["../../src/hooks/use-streaming-props.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,sBAAsB,CACpC,YAA2B,EAC3B,QAA4B,EAC5B,cAA0B;IAE1B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,YAAY,EAAE,CAAC;YACjB,IAAI,YAAY,GAAG,KAAK,CAAC;YACzB,MAAM,OAAO,GAAe,EAAE,CAAC;YAE/B,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;gBACtD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;oBACvD,YAAY,GAAG,IAAI,CAAC;oBACpB,OAAO,CAAC,GAAc,CAAC,GAAG,KAAmB,CAAC;gBAChD,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,IAAI,YAAY,EAAE,CAAC;gBACjB,QAAQ,CAAC;oBACP,GAAG,YAAY;oBACf,GAAG,OAAO;iBACX,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,uDAAuD;IACzD,CAAC,EAAE,CAAC,YAAY,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { useEffect } from \"react\";\n\n/**\n * A helper hook that automatically updates Tambo component state when specified props change.\n *\n * This hook streamlines the common pattern of updating component state when receiving new\n * streamed values from Tambo, eliminating the need to write repetitive useEffect code.\n *\n * @param currentState - The current state object from useTamboComponentState\n * @param setState - The setState function from useTamboComponentState\n * @param streamingProps - An object mapping state keys to prop values that should update the state\n *\n * @example\n * ```tsx\n * // Instead of writing a complex useEffect:\n * const [emailState, setEmailState] = useTamboComponentState(\"email\", initialState);\n *\n * // Simply use:\n * useTamboStreamingProps(emailState, setEmailState, {\n * subject: aiGeneratedSubject,\n * body: aiGeneratedBody,\n * usersEmail: usersEmail\n * });\n * ```\n */\nexport function useTamboStreamingProps<T extends Record<string, any>>(\n currentState: T | undefined,\n setState: (state: T) => void,\n streamingProps: Partial<T>,\n) {\n useEffect(() => {\n if (currentState) {\n let shouldUpdate = false;\n const updates: Partial<T> = {};\n\n Object.entries(streamingProps).forEach(([key, value]) => {\n if (value !== undefined && value !== currentState[key]) {\n shouldUpdate = true;\n updates[key as keyof T] = value as T[keyof T];\n }\n });\n\n if (shouldUpdate) {\n setState({\n ...currentState,\n ...updates,\n });\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [currentState, setState, ...Object.values(streamingProps)]);\n}\n"]}
1
+ {"version":3,"file":"use-streaming-props.js","sourceRoot":"","sources":["../../src/hooks/use-streaming-props.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,sBAAsB,CACpC,YAA2B,EAC3B,QAA4B,EAC5B,cAA0B;IAE1B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,YAAY,EAAE,CAAC;YACjB,IAAI,YAAY,GAAG,KAAK,CAAC;YACzB,MAAM,OAAO,GAAe,EAAE,CAAC;YAE/B,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;gBACtD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;oBACvD,YAAY,GAAG,IAAI,CAAC;oBACpB,OAAO,CAAC,GAAc,CAAC,GAAG,KAAmB,CAAC;gBAChD,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,IAAI,YAAY,EAAE,CAAC;gBACjB,QAAQ,CAAC;oBACP,GAAG,YAAY;oBACf,GAAG,OAAO;iBACX,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,sCAAsC;QACtC,uDAAuD;IACzD,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import { useEffect } from \"react\";\n\n/**\n * A helper hook that automatically updates Tambo component state when specified props change.\n *\n * This hook streamlines the common pattern of updating component state when receiving new\n * streamed values from Tambo, eliminating the need to write repetitive useEffect code.\n * @param currentState - The current state object from useTamboComponentState\n * @param setState - The setState function from useTamboComponentState\n * @param streamingProps - An object mapping state keys to prop values that should update the state\n * @example\n * ```tsx\n * // Instead of writing a complex useEffect:\n * const [emailState, setEmailState] = useTamboComponentState(\"email\", initialState);\n *\n * // Simply use:\n * useTamboStreamingProps(emailState, setEmailState, {\n * subject: aiGeneratedSubject,\n * body: aiGeneratedBody,\n * usersEmail: usersEmail\n * });\n * ```\n */\nexport function useTamboStreamingProps<T extends Record<string, any>>(\n currentState: T | undefined,\n setState: (state: T) => void,\n streamingProps: Partial<T>,\n) {\n useEffect(() => {\n if (currentState) {\n let shouldUpdate = false;\n const updates: Partial<T> = {};\n\n Object.entries(streamingProps).forEach(([key, value]) => {\n if (value !== undefined && value !== currentState[key]) {\n shouldUpdate = true;\n updates[key as keyof T] = value as T[keyof T];\n }\n });\n\n if (shouldUpdate) {\n setState({\n ...currentState,\n ...updates,\n });\n }\n }\n // Only run when streamingProps change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [...Object.values(streamingProps)]);\n}\n"]}
@@ -38,7 +38,6 @@ export interface useTamboSuggestionsResultInternal {
38
38
  type useTamboSuggestionsResult = CombinedMutationResult<any, Error> & useTamboSuggestionsResultInternal;
39
39
  /**
40
40
  * Hook for managing Tambo AI suggestions in a thread
41
- *
42
41
  * @param options - Configuration options for suggestion generation
43
42
  * @returns Object containing suggestions state and control functions
44
43
  */
@@ -1 +1 @@
1
- {"version":3,"file":"use-suggestions.d.ts","sourceRoot":"","sources":["../../src/hooks/use-suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAO/C,OAAO,EACL,sBAAsB,EAEvB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EAGpB,MAAM,qBAAqB,CAAC;AAG7B;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,kEAAkE;IAClE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD,4EAA4E;IAC5E,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;IAC/C,8CAA8C;IAC9C,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;;;OAIG;IACH,MAAM,EAAE,CAAC,aAAa,EAAE;QACtB,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QAC5C,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpB,0DAA0D;IAC1D,YAAY,EAAE,sBAAsB,CAClC,IAAI,EACJ,KAAK,EACL;QAAE,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,CACxE,CAAC;IAEF,0DAA0D;IAC1D,cAAc,EAAE,sBAAsB,CACpC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,0BAA0B,GAAG,SAAS,EACvE,KAAK,EACL,eAAe,CAChB,CAAC;IAEF,yDAAyD;IACzD,iBAAiB,EAAE,mBAAmB,CACpC,OAAO,CAAC,IAAI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AAI,CAAC,OAAO,CAAC,WAAW,CAAC,0BAA0B,GAAG,SAAS,EACvE,KAAK,EACL,eAAe,CAChB,CAAC;IAEF,yDAAyD;IACzD,iBAAiB,EAAE,mBAAmB,CACpC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,0BAA0B,GAAG,SAAS,EACvE,KAAK,CACN,CAAC;CACH;AAED,KAAK,yBAAyB,GAAG,sBAAsB,CAAC,GAAG,EAAE,KAAK,CAAC,GACjE,iCAAiC,CAAC;AAEpC;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,0BAA+B,GACvC,yBAAyB,CAmI3B"}
@@ -10,7 +10,6 @@ import { useTamboMutationResult, useTamboQuery, } from "./react-query-hooks";
10
10
  import { INPUT_ERROR_MESSAGES, useTamboThreadInput } from "./use-thread-input";
11
11
  /**
12
12
  * Hook for managing Tambo AI suggestions in a thread
13
- *
14
13
  * @param options - Configuration options for suggestion generation
15
14
  * @returns Object containing suggestions state and control functions
16
15
  */
@@ -1 +1 @@
1
- {"version":3,"file":"use-suggestions.js","sourceRoot":"","sources":["../../src/hooks/use-suggestions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAEL,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAGL,sBAAsB,EACtB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,E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C;IAChC,MAAM,qBAAqB,GAAG,sBAAsB,CAIlD;QACA,UAAU,EAAE,KAAK,EAAE,eAAgC,EAAE,EAAE;YACrD,IAAI,CAAC,eAAe,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBAC3C,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,8CAA8C;YAC9C,MAAM,UAAU,GAAG,sBAAsB,CACvC,aAAa,EACb,YAAY,EACZ,yBAAyB,CAC1B,CAAC;YAEF,OAAO,MAAM,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,CACxD,MAAM,CAAC,EAAE,EACT,eAAe,EACf;gBACE,cAAc;gBACd,6DAA6D;gBAC7D,mBAAmB,EAAE,CAAC,UAAU,CAAC;aAClC,EACD,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,CACnC,CAAC;QACJ,CAAC;QACD,yBAAyB;QACzB,KAAK,EAAE,KAAK;KACb,CAAC,CAAC;IAEH,mEAAmE;IACnE,8DAA8D;IAC9D,MAAM,WAAW,GAAG,iBAAiB;QACnC,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,IAAI,qBAAqB,CAAC,IAAI,IAAI,EAAE,CAAC;QAC9D,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;QACL,WAAW;QACX,MAAM,EAAE,mBAAmB,CAAC,WAAW;QACvC,oBAAoB;QACpB,YAAY,EAAE,mBAAmB;QACjC,cAAc,EAAE,qBAAqB;QACrC,iBAAiB;QACjB,GAAG,sBAAsB,CAAC,mBAAmB,EAAE,qBAAqB,CAAC;KACtE,CAAC;AACJ,CAAC","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { useEffect, useState } from \"react\";\nimport { validateInput } from \"../model/validate-input\";\nimport { useTamboClient } from \"../providers/tambo-client-provider\";\nimport { useTambo } from \"../providers/tambo-provider\";\nimport { useTamboRegistry } from \"../providers/tambo-registry-provider\";\nimport { useTamboThread } from \"../providers/tambo-thread-provider\";\nimport {\n CombinedMutationResult,\n combineMutationResults,\n} from \"../util/query-utils\";\nimport { getAvailableComponents } from \"../util/registry\";\nimport {\n UseTamboMutationResult,\n UseTamboQueryResult,\n useTamboMutationResult,\n useTamboQuery,\n} from \"./react-query-hooks\";\nimport { INPUT_ERROR_MESSAGES, useTamboThreadInput } from \"./use-thread-input\";\n\n/**\n * Configuration options for the useTamboSuggestions hook\n */\nexport interface useTamboSuggestionsOptions {\n /** Maximum number of suggestions to generate (1-10, default 3) */\n maxSuggestions?: number;\n}\n\n/**\n * Return value interface for useTamboSuggestions hook\n */\nexport interface useTamboSuggestionsResultInternal {\n /** List of available suggestions (also available in generateResult.data) */\n suggestions: TamboAI.Beta.Threads.Suggestion[];\n /** ID of the currently selected suggestion */\n selectedSuggestionId: string | null;\n /**\n * Accept and apply a suggestion (also available in acceptResult.mutateAsync)\n * @param suggestion - The suggestion to accept\n * @param shouldSubmit - Whether to automatically submit after accepting (default: false)\n */\n accept: (acceptOptions: {\n suggestion: TamboAI.Beta.Threads.Suggestion;\n shouldSubmit?: boolean;\n }) => Promise<void>;\n\n /** Result and network state for accepting a suggestion */\n acceptResult: UseTamboMutationResult<\n void,\n Error,\n { suggestion: TamboAI.Beta.Threads.Suggestion; shouldSubmit?: boolean }\n >;\n\n /** Result and network state for generating suggestions */\n generateResult: UseTamboMutationResult<\n TamboAI.Beta.Threads.Suggestions.SuggestionGenerateResponse | undefined,\n Error,\n AbortController\n >;\n\n /** The full suggestions query object from React Query */\n suggestionsResult: UseTamboQueryResult<\n TamboAI.Beta.Threads.Suggestions.SuggestionGenerateResponse | undefined,\n Error\n >;\n}\n\ntype useTamboSuggestionsResult = CombinedMutationResult<any, Error> &\n useTamboSuggestionsResultInternal;\n\n/**\n * Hook for managing Tambo AI suggestions in a thread\n *\n * @param options - Configuration options for suggestion generation\n * @returns Object containing suggestions state and control functions\n */\nexport function useTamboSuggestions(\n options: useTamboSuggestionsOptions = {},\n): useTamboSuggestionsResult {\n const { maxSuggestions = 3 } = options;\n const { thread } = useTamboThread();\n const { sendThreadMessage } = useTambo();\n const tamboClient = useTamboClient();\n const { componentList, toolRegistry, componentToolAssociations } =\n useTamboRegistry();\n\n const [selectedSuggestionId, setSelectedSuggestionId] = useState<\n string | null\n >(null);\n const { setValue: setInputValue } = useTamboThreadInput();\n\n const latestMessage = thread.messages[thread.messages.length - 1];\n const isLatestFromTambo = latestMessage?.role === \"assistant\";\n const latestMessageId = latestMessage?.id;\n\n // Reset selected suggestion when the message changes\n useEffect(() => {\n setSelectedSuggestionId(null);\n }, [latestMessageId]);\n\n // Use React Query to fetch suggestions when a new hydra message is received\n const suggestionsResult = useTamboQuery({\n // Only include latestMessageId in the queryKey if the message is from hydra\n queryKey: [\"suggestions\", isLatestFromTambo ? latestMessageId : null],\n queryFn: async () => {\n if (!latestMessageId || !isLatestFromTambo) {\n return [];\n }\n\n // Get registered components from the registry\n const components = getAvailableComponents(\n componentList,\n toolRegistry,\n componentToolAssociations,\n );\n\n return await tamboClient.beta.threads.suggestions.generate(\n thread.id,\n latestMessageId,\n {\n maxSuggestions,\n // The API expects an array of arrays for availableComponents\n availableComponents: [components],\n },\n );\n },\n // Only run the query if we have a valid message from hydra\n enabled: Boolean(latestMessageId && isLatestFromTambo),\n // Don't refetch on window focus or reconnect\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n // Don't retry on failure\n retry: false,\n });\n\n // Accept suggestion mutation\n const acceptMutationState = useTamboMutationResult<\n void,\n Error,\n { suggestion: TamboAI.Beta.Threads.Suggestion; shouldSubmit?: boolean }\n >({\n mutationFn: async ({ suggestion, shouldSubmit = false }) => {\n const validation = validateInput(suggestion.detailedSuggestion);\n if (!validation.isValid) {\n if (validation.error) {\n throw validation.error;\n }\n throw new Error(INPUT_ERROR_MESSAGES.VALIDATION);\n }\n\n if (shouldSubmit) {\n await sendThreadMessage(validation.sanitizedInput, {\n threadId: thread.id,\n });\n } else {\n setInputValue(validation.sanitizedInput);\n }\n setSelectedSuggestionId(suggestion.id);\n },\n });\n\n // Generate suggestions mutation\n const generateMutationState = useTamboMutationResult<\n TamboAI.Beta.Threads.Suggestions.SuggestionGenerateResponse | undefined,\n Error,\n AbortController\n >({\n mutationFn: async (abortController: AbortController) => {\n if (!latestMessageId || !isLatestFromTambo) {\n return undefined;\n }\n\n // Get registered components from the registry\n const components = getAvailableComponents(\n componentList,\n toolRegistry,\n componentToolAssociations,\n );\n\n return await tamboClient.beta.threads.suggestions.generate(\n thread.id,\n latestMessageId,\n {\n maxSuggestions,\n // The API expects an array of arrays for availableComponents\n availableComponents: [components],\n },\n { signal: abortController.signal },\n );\n },\n // Don't retry on failure\n retry: false,\n });\n\n // Use the query data if available, otherwise use the mutation data\n // Only return suggestions if the latest message is from hydra\n const suggestions = isLatestFromTambo\n ? (suggestionsResult.data ?? generateMutationState.data ?? [])\n : [];\n\n return {\n suggestions,\n accept: acceptMutationState.mutateAsync,\n selectedSuggestionId,\n acceptResult: acceptMutationState,\n generateResult: generateMutationState,\n suggestionsResult,\n ...combineMutationResults(acceptMutationState, generateMutationState),\n };\n}\n"]}
1
+ {"version":3,"file":"use-suggestions.js","sourceRoot":"","sources":["../../src/hooks/use-suggestions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAEL,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAGL,sBAAsB,EACtB,aAAa,GACd,MAAM,qBA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CAAC,CAAC;IAEH,gCAAgC;IAChC,MAAM,qBAAqB,GAAG,sBAAsB,CAIlD;QACA,UAAU,EAAE,KAAK,EAAE,eAAgC,EAAE,EAAE;YACrD,IAAI,CAAC,eAAe,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBAC3C,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,8CAA8C;YAC9C,MAAM,UAAU,GAAG,sBAAsB,CACvC,aAAa,EACb,YAAY,EACZ,yBAAyB,CAC1B,CAAC;YAEF,OAAO,MAAM,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,CACxD,MAAM,CAAC,EAAE,EACT,eAAe,EACf;gBACE,cAAc;gBACd,6DAA6D;gBAC7D,mBAAmB,EAAE,CAAC,UAAU,CAAC;aAClC,EACD,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,CACnC,CAAC;QACJ,CAAC;QACD,yBAAyB;QACzB,KAAK,EAAE,KAAK;KACb,CAAC,CAAC;IAEH,mEAAmE;IACnE,8DAA8D;IAC9D,MAAM,WAAW,GAAG,iBAAiB;QACnC,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,IAAI,qBAAqB,CAAC,IAAI,IAAI,EAAE,CAAC;QAC9D,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;QACL,WAAW;QACX,MAAM,EAAE,mBAAmB,CAAC,WAAW;QACvC,oBAAoB;QACpB,YAAY,EAAE,mBAAmB;QACjC,cAAc,EAAE,qBAAqB;QACrC,iBAAiB;QACjB,GAAG,sBAAsB,CAAC,mBAAmB,EAAE,qBAAqB,CAAC;KACtE,CAAC;AACJ,CAAC","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { useEffect, useState } from \"react\";\nimport { validateInput } from \"../model/validate-input\";\nimport { useTamboClient } from \"../providers/tambo-client-provider\";\nimport { useTambo } from \"../providers/tambo-provider\";\nimport { useTamboRegistry } from \"../providers/tambo-registry-provider\";\nimport { useTamboThread } from \"../providers/tambo-thread-provider\";\nimport {\n CombinedMutationResult,\n combineMutationResults,\n} from \"../util/query-utils\";\nimport { getAvailableComponents } from \"../util/registry\";\nimport {\n UseTamboMutationResult,\n UseTamboQueryResult,\n useTamboMutationResult,\n useTamboQuery,\n} from \"./react-query-hooks\";\nimport { INPUT_ERROR_MESSAGES, useTamboThreadInput } from \"./use-thread-input\";\n\n/**\n * Configuration options for the useTamboSuggestions hook\n */\nexport interface useTamboSuggestionsOptions {\n /** Maximum number of suggestions to generate (1-10, default 3) */\n maxSuggestions?: number;\n}\n\n/**\n * Return value interface for useTamboSuggestions hook\n */\nexport interface useTamboSuggestionsResultInternal {\n /** List of available suggestions (also available in generateResult.data) */\n suggestions: TamboAI.Beta.Threads.Suggestion[];\n /** ID of the currently selected suggestion */\n selectedSuggestionId: string | null;\n /**\n * Accept and apply a suggestion (also available in acceptResult.mutateAsync)\n * @param suggestion - The suggestion to accept\n * @param shouldSubmit - Whether to automatically submit after accepting (default: false)\n */\n accept: (acceptOptions: {\n suggestion: TamboAI.Beta.Threads.Suggestion;\n shouldSubmit?: boolean;\n }) => Promise<void>;\n\n /** Result and network state for accepting a suggestion */\n acceptResult: UseTamboMutationResult<\n void,\n Error,\n { suggestion: TamboAI.Beta.Threads.Suggestion; shouldSubmit?: boolean }\n >;\n\n /** Result and network state for generating suggestions */\n generateResult: UseTamboMutationResult<\n TamboAI.Beta.Threads.Suggestions.SuggestionGenerateResponse | undefined,\n Error,\n AbortController\n >;\n\n /** The full suggestions query object from React Query */\n suggestionsResult: UseTamboQueryResult<\n TamboAI.Beta.Threads.Suggestions.SuggestionGenerateResponse | undefined,\n Error\n >;\n}\n\ntype useTamboSuggestionsResult = CombinedMutationResult<any, Error> &\n useTamboSuggestionsResultInternal;\n\n/**\n * Hook for managing Tambo AI suggestions in a thread\n * @param options - Configuration options for suggestion generation\n * @returns Object containing suggestions state and control functions\n */\nexport function useTamboSuggestions(\n options: useTamboSuggestionsOptions = {},\n): useTamboSuggestionsResult {\n const { maxSuggestions = 3 } = options;\n const { thread } = useTamboThread();\n const { sendThreadMessage } = useTambo();\n const tamboClient = useTamboClient();\n const { componentList, toolRegistry, componentToolAssociations } =\n useTamboRegistry();\n\n const [selectedSuggestionId, setSelectedSuggestionId] = useState<\n string | null\n >(null);\n const { setValue: setInputValue } = useTamboThreadInput();\n\n const latestMessage = thread.messages[thread.messages.length - 1];\n const isLatestFromTambo = latestMessage?.role === \"assistant\";\n const latestMessageId = latestMessage?.id;\n\n // Reset selected suggestion when the message changes\n useEffect(() => {\n setSelectedSuggestionId(null);\n }, [latestMessageId]);\n\n // Use React Query to fetch suggestions when a new hydra message is received\n const suggestionsResult = useTamboQuery({\n // Only include latestMessageId in the queryKey if the message is from hydra\n queryKey: [\"suggestions\", isLatestFromTambo ? latestMessageId : null],\n queryFn: async () => {\n if (!latestMessageId || !isLatestFromTambo) {\n return [];\n }\n\n // Get registered components from the registry\n const components = getAvailableComponents(\n componentList,\n toolRegistry,\n componentToolAssociations,\n );\n\n return await tamboClient.beta.threads.suggestions.generate(\n thread.id,\n latestMessageId,\n {\n maxSuggestions,\n // The API expects an array of arrays for availableComponents\n availableComponents: [components],\n },\n );\n },\n // Only run the query if we have a valid message from hydra\n enabled: Boolean(latestMessageId && isLatestFromTambo),\n // Don't refetch on window focus or reconnect\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n // Don't retry on failure\n retry: false,\n });\n\n // Accept suggestion mutation\n const acceptMutationState = useTamboMutationResult<\n void,\n Error,\n { suggestion: TamboAI.Beta.Threads.Suggestion; shouldSubmit?: boolean }\n >({\n mutationFn: async ({ suggestion, shouldSubmit = false }) => {\n const validation = validateInput(suggestion.detailedSuggestion);\n if (!validation.isValid) {\n if (validation.error) {\n throw validation.error;\n }\n throw new Error(INPUT_ERROR_MESSAGES.VALIDATION);\n }\n\n if (shouldSubmit) {\n await sendThreadMessage(validation.sanitizedInput, {\n threadId: thread.id,\n });\n } else {\n setInputValue(validation.sanitizedInput);\n }\n setSelectedSuggestionId(suggestion.id);\n },\n });\n\n // Generate suggestions mutation\n const generateMutationState = useTamboMutationResult<\n TamboAI.Beta.Threads.Suggestions.SuggestionGenerateResponse | undefined,\n Error,\n AbortController\n >({\n mutationFn: async (abortController: AbortController) => {\n if (!latestMessageId || !isLatestFromTambo) {\n return undefined;\n }\n\n // Get registered components from the registry\n const components = getAvailableComponents(\n componentList,\n toolRegistry,\n componentToolAssociations,\n );\n\n return await tamboClient.beta.threads.suggestions.generate(\n thread.id,\n latestMessageId,\n {\n maxSuggestions,\n // The API expects an array of arrays for availableComponents\n availableComponents: [components],\n },\n { signal: abortController.signal },\n );\n },\n // Don't retry on failure\n retry: false,\n });\n\n // Use the query data if available, otherwise use the mutation data\n // Only return suggestions if the latest message is from hydra\n const suggestions = isLatestFromTambo\n ? (suggestionsResult.data ?? generateMutationState.data ?? [])\n : [];\n\n return {\n suggestions,\n accept: acceptMutationState.mutateAsync,\n selectedSuggestionId,\n acceptResult: acceptMutationState,\n generateResult: generateMutationState,\n suggestionsResult,\n ...combineMutationResults(acceptMutationState, generateMutationState),\n };\n}\n"]}
@@ -1,10 +1,39 @@
1
- /**
2
- * Get the threads for the specified project and optional context key.
3
- */
4
- export declare function useTamboThreadList({ projectId, contextKey, }?: {
1
+ interface UseTamboThreadListConfig {
2
+ /**
3
+ * The projectId to get the threads for. If not provided, the current project
4
+ * will be used.
5
+ */
6
+ projectId?: string;
7
+ /**
8
+ * The context key to get the threads for. If not provided, all threads for
9
+ * the project will be returned.
10
+ */
11
+ contextKey?: string;
12
+ }
13
+ interface UseTamboThreadListConfig {
14
+ /**
15
+ * The projectId to get the threads for. If not provided, the current project
16
+ * will be used.
17
+ */
5
18
  projectId?: string;
19
+ /**
20
+ * The context key to get the threads for. If not provided, all threads for
21
+ * the project will be returned.
22
+ */
6
23
  contextKey?: string;
7
- }): import("@tanstack/query-core").QueryObserverRefetchErrorResult<import("@tambo-ai/typescript-sdk/resources/beta").ThreadsOffsetAndLimit | null, Error> | import("@tanstack/query-core").QueryObserverSuccessResult<import("@tambo-ai/typescript-sdk/resources/beta").ThreadsOffsetAndLimit | null, Error> | import("@tanstack/query-core").QueryObserverLoadingErrorResult<import("@tambo-ai/typescript-sdk/resources/beta").ThreadsOffsetAndLimit | null, Error> | import("@tanstack/query-core").QueryObserverPendingResult<import("@tambo-ai/typescript-sdk/resources/beta").ThreadsOffsetAndLimit | null, Error> | import("@tanstack/query-core").QueryObserverPlaceholderResult<import("@tambo-ai/typescript-sdk/resources/beta").ThreadsOffsetAndLimit | null, Error> | {
24
+ }
25
+ /**
26
+ * Get all the threads for the specified project.
27
+ *
28
+ * If contextKey is empty, then all threads for the project will be returned.
29
+ * If contextKey is not empty, then only the threads for the specified context
30
+ * key will be returned.
31
+ * @param config - The config for the useTamboThreadList hook
32
+ * @param config.projectId - The projectId to get the threads for
33
+ * @param config.contextKey - The context key to get the threads for
34
+ * @returns The threads for the specified project and optional context key
35
+ */
36
+ export declare function useTamboThreadList({ projectId, contextKey, }?: UseTamboThreadListConfig): import("@tanstack/query-core").QueryObserverRefetchErrorResult<import("@tambo-ai/typescript-sdk/resources/beta").ThreadsOffsetAndLimit | null, Error> | import("@tanstack/query-core").QueryObserverSuccessResult<import("@tambo-ai/typescript-sdk/resources/beta").ThreadsOffsetAndLimit | null, Error> | import("@tanstack/query-core").QueryObserverLoadingErrorResult<import("@tambo-ai/typescript-sdk/resources/beta").ThreadsOffsetAndLimit | null, Error> | import("@tanstack/query-core").QueryObserverPendingResult<import("@tambo-ai/typescript-sdk/resources/beta").ThreadsOffsetAndLimit | null, Error> | import("@tanstack/query-core").QueryObserverPlaceholderResult<import("@tambo-ai/typescript-sdk/resources/beta").ThreadsOffsetAndLimit | null, Error> | {
8
37
  error: Error;
9
38
  isError: true;
10
39
  isPending: false;
@@ -135,4 +164,5 @@ export declare function useTamboThreadList({ projectId, contextKey, }?: {
135
164
  promise: Promise<string>;
136
165
  data: null;
137
166
  };
167
+ export {};
138
168
  //# sourceMappingURL=use-tambo-threads.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-tambo-threads.d.ts","sourceRoot":"","sources":["../../src/hooks/use-tambo-threads.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,EACT,UAAU,GACX,GAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CAChB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBL"}
1
+ {"version":3,"file":"use-tambo-threads.d.ts","sourceRoot":"","sources":["../../src/hooks/use-tambo-threads.ts"],"names":[],"mappings":"AAGA,UAAU,wBAAwB;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,wBAAwB;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,EACT,UAAU,GACX,GAAE,wBAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyB/B"}
@@ -1,7 +1,15 @@
1
1
  import { useTamboClient } from "../providers/tambo-client-provider";
2
2
  import { useTamboQuery } from "./react-query-hooks";
3
3
  /**
4
- * Get the threads for the specified project and optional context key.
4
+ * Get all the threads for the specified project.
5
+ *
6
+ * If contextKey is empty, then all threads for the project will be returned.
7
+ * If contextKey is not empty, then only the threads for the specified context
8
+ * key will be returned.
9
+ * @param config - The config for the useTamboThreadList hook
10
+ * @param config.projectId - The projectId to get the threads for
11
+ * @param config.contextKey - The context key to get the threads for
12
+ * @returns The threads for the specified project and optional context key
5
13
  */
6
14
  export function useTamboThreadList({ projectId, contextKey, } = {}) {
7
15
  const client = useTamboClient();
@@ -1 +1 @@
1
- {"version":3,"file":"use-tambo-threads.js","sourceRoot":"","sources":["../../src/hooks/use-tambo-threads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,EACjC,SAAS,EACT,UAAU,MAIR,EAAE;IACJ,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,GAAG,aAAa,CAAC;QAClE,QAAQ,EAAE,CAAC,WAAW,CAAC;QACvB,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,OAAO,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC;QACtD,CAAC;KACF,CAAC,CAAC;IACH,MAAM,gBAAgB,GAAG,SAAS,IAAI,gBAAgB,CAAC;IAEvD,MAAM,WAAW,GAAG,aAAa,CAAC;QAChC,OAAO,EAAE,CAAC,CAAC,gBAAgB;QAC3B,QAAQ,EAAE,CAAC,SAAS,EAAE,gBAAgB,EAAE,UAAU,CAAC;QACnD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACtB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE;gBAClE,UAAU;aACX,CAAC,CAAC;YACH,OAAO,UAAU,CAAC;QACpB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,gBAAgB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,cAAc,EAAE,CAAC;AAC5E,CAAC","sourcesContent":["import { useTamboClient } from \"../providers/tambo-client-provider\";\nimport { useTamboQuery } from \"./react-query-hooks\";\n\n/**\n * Get the threads for the specified project and optional context key.\n */\nexport function useTamboThreadList({\n projectId,\n contextKey,\n}: {\n projectId?: string;\n contextKey?: string;\n} = {}) {\n const client = useTamboClient();\n const { data: queriedProjectId, ...projectIdState } = useTamboQuery({\n queryKey: [\"projectId\"],\n queryFn: async () => {\n return (await client.beta.projects.getCurrent()).id;\n },\n });\n const currentProjectId = projectId ?? queriedProjectId;\n\n const threadState = useTamboQuery({\n enabled: !!currentProjectId,\n queryKey: [\"threads\", currentProjectId, contextKey],\n queryFn: async () => {\n if (!currentProjectId) {\n return null;\n }\n const threadIter = await client.beta.threads.list(currentProjectId, {\n contextKey,\n });\n return threadIter;\n },\n });\n\n return currentProjectId ? threadState : { data: null, ...projectIdState };\n}\n"]}
1
+ {"version":3,"file":"use-tambo-threads.js","sourceRoot":"","sources":["../../src/hooks/use-tambo-threads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AA4BpD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,EACjC,SAAS,EACT,UAAU,MACkB,EAAE;IAC9B,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,GAAG,aAAa,CAAC;QAClE,QAAQ,EAAE,CAAC,WAAW,CAAC;QACvB,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,OAAO,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC;QACtD,CAAC;KACF,CAAC,CAAC;IACH,MAAM,gBAAgB,GAAG,SAAS,IAAI,gBAAgB,CAAC;IAEvD,MAAM,WAAW,GAAG,aAAa,CAAC;QAChC,OAAO,EAAE,CAAC,CAAC,gBAAgB;QAC3B,QAAQ,EAAE,CAAC,SAAS,EAAE,gBAAgB,EAAE,UAAU,CAAC;QACnD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACtB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE;gBAClE,UAAU;aACX,CAAC,CAAC;YACH,OAAO,UAAU,CAAC;QACpB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,gBAAgB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,cAAc,EAAE,CAAC;AAC5E,CAAC","sourcesContent":["import { useTamboClient } from \"../providers/tambo-client-provider\";\nimport { useTamboQuery } from \"./react-query-hooks\";\n\ninterface UseTamboThreadListConfig {\n /**\n * The projectId to get the threads for. If not provided, the current project\n * will be used.\n */\n projectId?: string;\n /**\n * The context key to get the threads for. If not provided, all threads for\n * the project will be returned.\n */\n contextKey?: string;\n}\n\ninterface UseTamboThreadListConfig {\n /**\n * The projectId to get the threads for. If not provided, the current project\n * will be used.\n */\n projectId?: string;\n /**\n * The context key to get the threads for. If not provided, all threads for\n * the project will be returned.\n */\n contextKey?: string;\n}\n\n/**\n * Get all the threads for the specified project.\n *\n * If contextKey is empty, then all threads for the project will be returned.\n * If contextKey is not empty, then only the threads for the specified context\n * key will be returned.\n * @param config - The config for the useTamboThreadList hook\n * @param config.projectId - The projectId to get the threads for\n * @param config.contextKey - The context key to get the threads for\n * @returns The threads for the specified project and optional context key\n */\nexport function useTamboThreadList({\n projectId,\n contextKey,\n}: UseTamboThreadListConfig = {}) {\n const client = useTamboClient();\n const { data: queriedProjectId, ...projectIdState } = useTamboQuery({\n queryKey: [\"projectId\"],\n queryFn: async () => {\n return (await client.beta.projects.getCurrent()).id;\n },\n });\n const currentProjectId = projectId ?? queriedProjectId;\n\n const threadState = useTamboQuery({\n enabled: !!currentProjectId,\n queryKey: [\"threads\", currentProjectId, contextKey],\n queryFn: async () => {\n if (!currentProjectId) {\n return null;\n }\n const threadIter = await client.beta.threads.list(currentProjectId, {\n contextKey,\n });\n return threadIter;\n },\n });\n\n return currentProjectId ? threadState : { data: null, ...projectIdState };\n}\n"]}
@@ -43,7 +43,6 @@ export type UseThreadInput = UseThreadInputInternal & UseMutationResult<void, Er
43
43
  }>;
44
44
  /**
45
45
  * Hook for managing thread message input state and submission
46
- *
47
46
  * @returns Interface for managing thread input state and submission
48
47
  */
49
48
  export declare function useTamboThreadInput(contextKey?: string): UseThreadInput;
@@ -1 +1 @@
1
- {"version":3,"file":"use-thread-input.d.ts","sourceRoot":"","sources":["../../src/hooks/use-thread-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAO1D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;IAC/B,kDAAkD;;IAElD,0CAA0C;;IAE1C,qDAAqD;;IAErD,yCAAyC;;CAEjC,CAAC;AAEX;;;GAGG;AACH,UAAU,sBAAsB;IAC9B,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;;;OAKG;IACH,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB;AACD,MAAM,MAAM,cAAc,GAAG,sBAAsB,GACjD,iBAAiB,CACf,IAAI,EACJ,KAAK,EACL;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,CAClD,CAAC;AAEJ;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,cAAc,CAwCvE"}
1
+ {"version":3,"file":"use-thread-input.d.ts","sourceRoot":"","sources":["../../src/hooks/use-thread-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAO1D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;IAC/B,kDAAkD;;IAElD,0CAA0C;;IAE1C,qDAAqD;;IAErD,yCAAyC;;CAEjC,CAAC;AAEX;;;GAGG;AACH,UAAU,sBAAsB;IAC9B,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;;;OAKG;IACH,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB;AACD,MAAM,MAAM,cAAc,GAAG,sBAAsB,GACjD,iBAAiB,CACf,IAAI,EACJ,KAAK,EACL;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,CAClD,CAAC;AAEJ;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,cAAc,CAwCvE"}
@@ -20,7 +20,6 @@ export const INPUT_ERROR_MESSAGES = {
20
20
  };
21
21
  /**
22
22
  * Hook for managing thread message input state and submission
23
- *
24
23
  * @returns Interface for managing thread input state and submission
25
24
  */
26
25
  export function useTamboThreadInput(contextKey) {
@@ -1 +1 @@
1
- {"version":3,"file":"use-thread-input.js","sourceRoot":"","sources":["../../src/hooks/use-thread-input.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,kDAAkD;IAClD,KAAK,EAAE,yBAAyB;IAChC,0CAA0C;IAC1C,OAAO,EAAE,6CAA6C;IACtD,qDAAqD;IACrD,MAAM,EAAE,gCAAgC;IACxC,yCAAyC;IACzC,UAAU,EAAE,wBAAwB;CAC5B,CAAC;AAgCX;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAAmB;IACrD,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAC5D,cAAc,EAAE,CAAC;IAEnB,MAAM,MAAM,GAAG,WAAW,CACxB,KAAK,EAAE,EACL,UAAU,EAAE,gBAAgB,EAC5B,cAAc,MACuC,EAAE,EAAE,EAAE;QAC3D,MAAM,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YACxB,MAAM,IAAI,gBAAgB,CACxB,0BAA0B,UAAU,CAAC,KAAK,IAAI,oBAAoB,CAAC,UAAU,EAAE,EAC/E,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,CAC5B,CAAC;QACJ,CAAC;QAED,MAAM,iBAAiB,CAAC,UAAU,CAAC,cAAc,EAAE;YACjD,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,UAAU,EAAE,gBAAgB,IAAI,UAAU,IAAI,SAAS;YACvD,cAAc,EAAE,cAAc;SAC/B,CAAC,CAAC;QACH,aAAa,CAAC,EAAE,CAAC,CAAC;IACpB,CAAC,EACD,CAAC,UAAU,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,aAAa,CAAC,CACtE,CAAC;IACF,MAAM,EACJ,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,aAAa,EACrB,GAAG,aAAa,EACjB,GAAG,gBAAgB,CAAC;QACnB,UAAU,EAAE,MAAM;KACnB,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,aAAa;QAChB,KAAK,EAAE,UAAU;QACjB,QAAQ,EAAE,aAAa;QACvB,MAAM,EAAE,WAAW;KACF,CAAC;AACtB,CAAC","sourcesContent":["import { UseMutationResult } from \"@tanstack/react-query\";\nimport { useCallback } from \"react\";\nimport { ThreadInputError } from \"../model/thread-input-error\";\nimport { validateInput } from \"../model/validate-input\";\nimport { useTamboThread } from \"../providers/tambo-thread-provider\";\nimport { useTamboMutation } from \"./react-query-hooks\";\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 /** Error when attempting to submit empty input */\n EMPTY: \"Message cannot be empty\",\n /** Error when network connection fails */\n NETWORK: \"Network error. Please check your connection\",\n /** Error when server fails to process the request */\n SERVER: \"Server error. Please try again\",\n /** Error when input format is invalid */\n VALIDATION: \"Invalid message format\",\n} as const;\n\n/**\n * Interface for the thread input hook return value\n * Provides all necessary functions and state for managing thread input\n */\ninterface UseThreadInputInternal {\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 * Validates input, handles errors, and cleans up state after submission\n * @throws {ThreadInputError} If submission fails\n * @returns Promise that resolves when submission is complete\n */\n submit: (options?: {\n contextKey?: string;\n streamResponse?: boolean;\n }) => Promise<void>;\n}\nexport type UseThreadInput = UseThreadInputInternal &\n UseMutationResult<\n void,\n Error,\n { contextKey?: string; streamResponse?: boolean }\n >;\n\n/**\n * Hook for managing thread message input state and submission\n *\n * @returns Interface for managing thread input state and submission\n */\nexport function useTamboThreadInput(contextKey?: string): UseThreadInput {\n const { thread, inputValue, setInputValue, sendThreadMessage } =\n useTamboThread();\n\n const submit = useCallback(\n async ({\n contextKey: submitContextKey,\n streamResponse,\n }: { contextKey?: string; streamResponse?: boolean } = {}) => {\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 });\n setInputValue(\"\");\n },\n [inputValue, sendThreadMessage, thread.id, contextKey, setInputValue],\n );\n const {\n mutateAsync: submitAsync,\n mutate: _unusedSubmit,\n ...mutationState\n } = useTamboMutation({\n mutationFn: submit,\n });\n\n return {\n ...mutationState,\n value: inputValue,\n setValue: setInputValue,\n submit: submitAsync,\n } as UseThreadInput;\n}\n"]}
1
+ {"version":3,"file":"use-thread-input.js","sourceRoot":"","sources":["../../src/hooks/use-thread-input.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,kDAAkD;IAClD,KAAK,EAAE,yBAAyB;IAChC,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W;KACF,CAAC;AACtB,CAAC","sourcesContent":["import { UseMutationResult } from \"@tanstack/react-query\";\nimport { useCallback } from \"react\";\nimport { ThreadInputError } from \"../model/thread-input-error\";\nimport { validateInput } from \"../model/validate-input\";\nimport { useTamboThread } from \"../providers/tambo-thread-provider\";\nimport { useTamboMutation } from \"./react-query-hooks\";\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 /** Error when attempting to submit empty input */\n EMPTY: \"Message cannot be empty\",\n /** Error when network connection fails */\n NETWORK: \"Network error. Please check your connection\",\n /** Error when server fails to process the request */\n SERVER: \"Server error. Please try again\",\n /** Error when input format is invalid */\n VALIDATION: \"Invalid message format\",\n} as const;\n\n/**\n * Interface for the thread input hook return value\n * Provides all necessary functions and state for managing thread input\n */\ninterface UseThreadInputInternal {\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 * Validates input, handles errors, and cleans up state after submission\n * @throws {ThreadInputError} If submission fails\n * @returns Promise that resolves when submission is complete\n */\n submit: (options?: {\n contextKey?: string;\n streamResponse?: boolean;\n }) => Promise<void>;\n}\nexport type UseThreadInput = UseThreadInputInternal &\n UseMutationResult<\n void,\n Error,\n { contextKey?: string; streamResponse?: boolean }\n >;\n\n/**\n * Hook for managing thread message input state and submission\n * @returns Interface for managing thread input state and submission\n */\nexport function useTamboThreadInput(contextKey?: string): UseThreadInput {\n const { thread, inputValue, setInputValue, sendThreadMessage } =\n useTamboThread();\n\n const submit = useCallback(\n async ({\n contextKey: submitContextKey,\n streamResponse,\n }: { contextKey?: string; streamResponse?: boolean } = {}) => {\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 });\n setInputValue(\"\");\n },\n [inputValue, sendThreadMessage, thread.id, contextKey, setInputValue],\n );\n const {\n mutateAsync: submitAsync,\n mutate: _unusedSubmit,\n ...mutationState\n } = useTamboMutation({\n mutationFn: submit,\n });\n\n return {\n ...mutationState,\n value: inputValue,\n setValue: setInputValue,\n submit: submitAsync,\n } as UseThreadInput;\n}\n"]}
package/esm/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { TamboMessageProvider, useTamboCurrentMessage, useTamboMessageContext, }
4
4
  export { useTamboStreamingProps } from "./hooks/use-streaming-props";
5
5
  export * from "./hooks/use-suggestions";
6
6
  export { useTamboThreadInput } from "./hooks/use-thread-input";
7
- export * from "./providers";
7
+ export { TamboClientProvider, TamboComponentProvider, TamboProvider, TamboThreadProvider, useTambo, useTamboClient, useTamboThread, type TamboComponent, type TamboRegistryContext, } from "./providers";
8
8
  export type { APIError, RateLimitError, TamboAIError, } from "@tambo-ai/typescript-sdk";
9
9
  export type { Suggestion, SuggestionGenerateParams, SuggestionGenerateResponse, SuggestionListResponse, } from "@tambo-ai/typescript-sdk/resources/beta/threads/suggestions";
10
10
  export { useTamboThreadList } from "./hooks/use-tambo-threads";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AACxK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,cAAc,aAAa,CAAC;AAG5B,YAAY,EACV,QAAQ,EACR,cAAc,EACd,YAAY,G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AClB,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"}
package/esm/index.js CHANGED
@@ -5,7 +5,7 @@ export { useTamboStreamingProps } from "./hooks/use-streaming-props";
5
5
  export * from "./hooks/use-suggestions";
6
6
  export { useTamboThreadInput } from "./hooks/use-thread-input";
7
7
  // Re-export provider components
8
- export * from "./providers";
8
+ export { TamboClientProvider, TamboComponentProvider, TamboProvider, TamboThreadProvider, useTambo, useTamboClient, useTamboThread, } from "./providers";
9
9
  export { useTamboThreadList } from "./hooks/use-tambo-threads";
10
10
  export { GenerationStage, } from "./model/generate-component-response";
11
11
  //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AACxK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,gCAAgC;AAChC,cAAc,aAAa,CAAC;AAc5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAQ/D,OAAO,EACL,eAAe,GAEhB,MAAM,qCAAqC,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. */\nexport { useTamboComponentState } from \"./hooks/use-component-state\";\nexport {\n TamboMessageProvider,\n useTamboCurrentMessage,\n useTamboMessageContext,\n} from \"./hooks/use-current-message\";\nexport { useTamboStreamingProps } from \"./hooks/use-streaming-props\";\nexport * from \"./hooks/use-suggestions\";\nexport { useTamboThreadInput } from \"./hooks/use-thread-input\";\n\n// Re-export provider components\nexport * 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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AACxK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,gCAAgC;AAChC,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,QAAQ,EACR,cAAc,EACd,cAAc,GAGf,MAAM,aAAa,CAAC;AAcrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAQ/D,OAAO,EACL,eAAe,GAEhB,MAAM,qCAAqC,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. */\nexport { useTamboComponentState } from \"./hooks/use-component-state\";\nexport {\n TamboMessageProvider,\n useTamboCurrentMessage,\n useTamboMessageContext,\n} from \"./hooks/use-current-message\";\nexport { useTamboStreamingProps } from \"./hooks/use-streaming-props\";\nexport * from \"./hooks/use-suggestions\";\nexport { useTamboThreadInput } from \"./hooks/use-thread-input\";\n\n// Re-export provider components\nexport {\n TamboClientProvider,\n TamboComponentProvider,\n TamboProvider,\n TamboThreadProvider,\n useTambo,\n useTamboClient,\n useTamboThread,\n type TamboComponent,\n type TamboRegistryContext,\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"]}
@@ -38,7 +38,8 @@ export interface TamboComponent {
38
38
  name: string;
39
39
  /** The description of the component */
40
40
  description: string;
41
- /** The React component to render.
41
+ /**
42
+ * The React component to render.
42
43
  *
43
44
  * Make sure to pass the Component itself, not an instance of the component. For example,
44
45
  * if you have a component like this:
@@ -57,11 +58,13 @@ export interface TamboComponent {
57
58
  * ```
58
59
  */
59
60
  component: ComponentType<any>;
60
- /** A zod schema for the component props. (Recommended)
61
+ /**
62
+ * A zod schema for the component props. (Recommended)
61
63
  * Either this or propsDefinition must be provided, but not both.
62
64
  */
63
65
  propsSchema?: z.ZodTypeAny;
64
- /** The props definition of the component as a JSON object.
66
+ /**
67
+ * The props definition of the component as a JSON object.
65
68
  * Either this or propsSchema must be provided, but not both.
66
69
  */
67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kBG;IACH,SAAS,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAE9B;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC;IAC3B;;;OAGG;IACH,eAAe,CAAC,EAAE,GAAG,CAAC;IACtB,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IACtC,uDAAuD;IACvD,eAAe,CAAC,EAAE,SAAS,EAAE,CAAC;CAC/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"component-metadata.js","sourceRoot":"","sources":["../../src/model/component-metadata.ts"],"names":[],"mappings":"","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { ComponentType } from \"react\";\nimport z from \"zod\";\nimport type zodToJsonSchema from \"zod-to-json-schema\";\n/** Extension of the ToolParameters interface from Tambo AI to include JSONSchema definition */\nexport type ParameterSpec = TamboAI.ToolParameters & {\n schema?: ReturnType<typeof zodToJsonSchema>;\n};\n\n/**\n * Extends the base ContextTool interface from Tambo AI to include schema information\n * for parameter validation using zod-to-json-schema.\n */\nexport interface ComponentContextToolMetadata\n extends TamboAI.ComponentContextToolMetadata {\n parameters: ParameterSpec[];\n}\n\nexport interface ComponentContextTool {\n getComponentContext: (...args: any[]) => Promise<any>;\n definition: ComponentContextToolMetadata;\n}\n\nexport interface RegisteredComponent extends TamboAI.AvailableComponent {\n component: ComponentType<any>;\n loadingComponent?: ComponentType<any>;\n}\n\nexport type ComponentRegistry = Record<string, RegisteredComponent>;\n\nexport type TamboToolRegistry = Record<string, TamboTool>;\n\nexport interface TamboTool<\n Args extends z.ZodTuple<any, any> = z.ZodTuple<any, any>,\n Returns extends z.ZodTypeAny = z.ZodTypeAny,\n> {\n name: string;\n description: string;\n tool: (...args: z.infer<Args>) => z.infer<Returns>;\n toolSchema: z.ZodFunction<Args, Returns>;\n}\n\nexport type TamboToolAssociations = Record<string, string[]>;\n/**\n * A component that can be registered with the TamboRegistryProvider.\n */\n\nexport interface TamboComponent {\n /** The name of the component */\n name: string;\n /** The description of the component */\n description: string;\n /** The React component to render.\n *\n * Make sure to pass the Component itself, not an instance of the component. For example,\n * if you have a component like this:\n *\n * ```tsx\n * const MyComponent = () => {\n * return <div>My Component</div>;\n * };\n * ```\n *\n * You should pass the `Component`:\n *\n * ```tsx\n * const components = [MyComponent];\n * <TamboRegistryProvider components={components} />\n * ```\n */\n component: ComponentType<any>;\n\n /** A zod schema for the component props. (Recommended)\n * Either this or propsDefinition must be provided, but not both.\n */\n propsSchema?: z.ZodTypeAny;\n /** The props definition of the component as a JSON object.\n * Either this or propsSchema must be provided, but not both.\n */\n propsDefinition?: any;\n /** The loading component to render while the component is loading */\n loadingComponent?: ComponentType<any>;\n /** The tools that are associated with the component */\n associatedTools?: TamboTool[];\n}\n"]}
1
+ {"version":3,"file":"component-metadata.js","sourceRoot":"","sources":["../../src/model/component-metadata.ts"],"names":[],"mappings":"","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { ComponentType } from \"react\";\nimport z from \"zod\";\nimport type zodToJsonSchema from \"zod-to-json-schema\";\n/** Extension of the ToolParameters interface from Tambo AI to include JSONSchema definition */\nexport type ParameterSpec = TamboAI.ToolParameters & {\n schema?: ReturnType<typeof zodToJsonSchema>;\n};\n\n/**\n * Extends the base ContextTool interface from Tambo AI to include schema information\n * for parameter validation using zod-to-json-schema.\n */\nexport interface ComponentContextToolMetadata\n extends TamboAI.ComponentContextToolMetadata {\n parameters: ParameterSpec[];\n}\n\nexport interface ComponentContextTool {\n getComponentContext: (...args: any[]) => Promise<any>;\n definition: ComponentContextToolMetadata;\n}\n\nexport interface RegisteredComponent extends TamboAI.AvailableComponent {\n component: ComponentType<any>;\n loadingComponent?: ComponentType<any>;\n}\n\nexport type ComponentRegistry = Record<string, RegisteredComponent>;\n\nexport type TamboToolRegistry = Record<string, TamboTool>;\n\nexport interface TamboTool<\n Args extends z.ZodTuple<any, any> = z.ZodTuple<any, any>,\n Returns extends z.ZodTypeAny = z.ZodTypeAny,\n> {\n name: string;\n description: string;\n tool: (...args: z.infer<Args>) => z.infer<Returns>;\n toolSchema: z.ZodFunction<Args, Returns>;\n}\n\nexport type TamboToolAssociations = Record<string, string[]>;\n/**\n * A component that can be registered with the TamboRegistryProvider.\n */\n\nexport interface TamboComponent {\n /** The name of the component */\n name: string;\n /** The description of the component */\n description: string;\n /**\n * The React component to render.\n *\n * Make sure to pass the Component itself, not an instance of the component. For example,\n * if you have a component like this:\n *\n * ```tsx\n * const MyComponent = () => {\n * return <div>My Component</div>;\n * };\n * ```\n *\n * You should pass the `Component`:\n *\n * ```tsx\n * const components = [MyComponent];\n * <TamboRegistryProvider components={components} />\n * ```\n */\n component: ComponentType<any>;\n\n /**\n * A zod schema for the component props. (Recommended)\n * Either this or propsDefinition must be provided, but not both.\n */\n propsSchema?: z.ZodTypeAny;\n /**\n * The props definition of the component as a JSON object.\n * Either this or propsSchema must be provided, but not both.\n */\n propsDefinition?: any;\n /** The loading component to render while the component is loading */\n loadingComponent?: ComponentType<any>;\n /** The tools that are associated with the component */\n associatedTools?: TamboTool[];\n}\n"]}
@@ -1,7 +1,9 @@
1
1
  import TamboAI from "@tambo-ai/typescript-sdk";
2
2
  import { ReactElement } from "react";
3
- /** An extension of the TamboAI.Beta.Threads.ThreadMessage type that includes a
4
- * renderedComponent */
3
+ /**
4
+ * An extension of the TamboAI.Beta.Threads.ThreadMessage type that includes a
5
+ * renderedComponent
6
+ */
5
7
  export interface TamboThreadMessage extends TamboAI.Beta.Threads.ThreadMessage {
6
8
  renderedComponent?: ReactElement | null;
7
9
  }
@@ -14,5 +16,10 @@ export declare enum GenerationStage {
14
16
  COMPLETE = "COMPLETE",
15
17
  ERROR = "ERROR"
16
18
  }
19
+ /**
20
+ * Checks if the generation stage is in a state where it can accept user input.
21
+ * @param generationStage - The generation stage to check
22
+ * @returns True if the generation stage is idle, false otherwise
23
+ */
17
24
  export declare function isIdleStage(generationStage: GenerationStage): boolean;
18
25
  //# sourceMappingURL=generate-component-response.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-component-response.d.ts","sourceRoot":"","sources":["../../src/model/generate-component-response.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC;uBACuB;AACvB,MAAM,WAAW,kBAAmB,SAAQ,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa;IAC5E,iBAAiB,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CACzC;AAED,oBAAY,eAAe;IACzB,IAAI,SAAS;IACb,kBAAkB,uBAAuB;IACzC,gBAAgB,qBAAqB;IACrC,mBAAmB,wBAAwB;IAC3C,kBAAkB,uBAAuB;IACzC,QAAQ,aAAa;IACrB,KAAK,UAAU;CAChB;AACD,wBAAgB,WAAW,CAAC,eAAe,EAAE,eAAe,WAM3D"}
1
+ {"version":3,"file":"generate-component-response.d.ts","sourceRoot":"","sources":["../../src/model/generate-component-response.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,kBAAmB,SAAQ,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa;IAC5E,iBAAiB,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CACzC;AAED,oBAAY,eAAe;IACzB,IAAI,SAAS;IACb,kBAAkB,uBAAuB;IACzC,gBAAgB,qBAAqB;IACrC,mBAAmB,wBAAwB;IAC3C,kBAAkB,uBAAuB;IACzC,QAAQ,aAAa;IACrB,KAAK,UAAU;CAChB;AACD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,eAAe,EAAE,eAAe,WAM3D"}
@@ -8,6 +8,11 @@ export var GenerationStage;
8
8
  GenerationStage["COMPLETE"] = "COMPLETE";
9
9
  GenerationStage["ERROR"] = "ERROR";
10
10
  })(GenerationStage || (GenerationStage = {}));
11
+ /**
12
+ * Checks if the generation stage is in a state where it can accept user input.
13
+ * @param generationStage - The generation stage to check
14
+ * @returns True if the generation stage is idle, false otherwise
15
+ */
11
16
  export function isIdleStage(generationStage) {
12
17
  return [
13
18
  GenerationStage.IDLE,
@@ -1 +1 @@
1
- {"version":3,"file":"generate-component-response.js","sourceRoot":"","sources":["../../src/model/generate-component-response.ts"],"names":[],"mappings":"AASA,MAAM,CAAN,IAAY,eAQX;AARD,WAAY,eAAe;IACzB,gCAAa,CAAA;IACb,4DAAyC,CAAA;IACzC,wDAAqC,CAAA;IACrC,8DAA2C,CAAA;IAC3C,4DAAyC,CAAA;IACzC,wCAAqB,CAAA;IACrB,kCAAe,CAAA;AACjB,CAAC,EARW,eAAe,KAAf,eAAe,QAQ1B;AACD,MAAM,UAAU,WAAW,CAAC,eAAgC;IAC1D,OAAO;QACL,eAAe,CAAC,IAAI;QACpB,eAAe,CAAC,QAAQ;QACxB,eAAe,CAAC,KAAK;KACtB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { ReactElement } from \"react\";\n\n/** An extension of the TamboAI.Beta.Threads.ThreadMessage type that includes a\n * renderedComponent */\nexport interface TamboThreadMessage extends TamboAI.Beta.Threads.ThreadMessage {\n renderedComponent?: ReactElement | null;\n}\n\nexport enum GenerationStage {\n IDLE = \"IDLE\",\n CHOOSING_COMPONENT = \"CHOOSING_COMPONENT\",\n FETCHING_CONTEXT = \"FETCHING_CONTEXT\",\n HYDRATING_COMPONENT = \"HYDRATING_COMPONENT\",\n STREAMING_RESPONSE = \"STREAMING_RESPONSE\",\n COMPLETE = \"COMPLETE\",\n ERROR = \"ERROR\",\n}\nexport function isIdleStage(generationStage: GenerationStage) {\n return [\n GenerationStage.IDLE,\n GenerationStage.COMPLETE,\n GenerationStage.ERROR,\n ].includes(generationStage);\n}\n"]}
1
+ {"version":3,"file":"generate-component-response.js","sourceRoot":"","sources":["../../src/model/generate-component-response.ts"],"names":[],"mappings":"AAWA,MAAM,CAAN,IAAY,eAQX;AARD,WAAY,eAAe;IACzB,gCAAa,CAAA;IACb,4DAAyC,CAAA;IACzC,wDAAqC,CAAA;IACrC,8DAA2C,CAAA;IAC3C,4DAAyC,CAAA;IACzC,wCAAqB,CAAA;IACrB,kCAAe,CAAA;AACjB,CAAC,EARW,eAAe,KAAf,eAAe,QAQ1B;AACD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,eAAgC;IAC1D,OAAO;QACL,eAAe,CAAC,IAAI;QACpB,eAAe,CAAC,QAAQ;QACxB,eAAe,CAAC,KAAK;KACtB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { ReactElement } from \"react\";\n\n/**\n * An extension of the TamboAI.Beta.Threads.ThreadMessage type that includes a\n * renderedComponent\n */\nexport interface TamboThreadMessage extends TamboAI.Beta.Threads.ThreadMessage {\n renderedComponent?: ReactElement | null;\n}\n\nexport enum GenerationStage {\n IDLE = \"IDLE\",\n CHOOSING_COMPONENT = \"CHOOSING_COMPONENT\",\n FETCHING_CONTEXT = \"FETCHING_CONTEXT\",\n HYDRATING_COMPONENT = \"HYDRATING_COMPONENT\",\n STREAMING_RESPONSE = \"STREAMING_RESPONSE\",\n COMPLETE = \"COMPLETE\",\n ERROR = \"ERROR\",\n}\n/**\n * Checks if the generation stage is in a state where it can accept user input.\n * @param generationStage - The generation stage to check\n * @returns True if the generation stage is idle, false otherwise\n */\nexport function isIdleStage(generationStage: GenerationStage) {\n return [\n GenerationStage.IDLE,\n GenerationStage.COMPLETE,\n GenerationStage.ERROR,\n ].includes(generationStage);\n}\n"]}
@@ -1,7 +1,9 @@
1
1
  import TamboAI from "@tambo-ai/typescript-sdk";
2
2
  import { TamboThreadMessage } from "./generate-component-response";
3
- /** An extension of the TamboAI.Beta.Thread type that includes
4
- * messages with renderedComponent */
3
+ /**
4
+ * An extension of the TamboAI.Beta.Thread type that includes
5
+ * messages with renderedComponent
6
+ */
5
7
  export interface TamboThread extends TamboAI.Beta.Thread {
6
8
  messages: TamboThreadMessage[];
7
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-thread.d.ts","sourceRoot":"","sources":["../../src/model/tambo-thread.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE;qCACqC;AACrC,MAAM,WAAW,WAAY,SAAQ,OAAO,CAAC,IAAI,CAAC,MAAM;IACtD,QAAQ,EAAE,kBAAkB,EAAE,CAAC;CAChC"}
1
+ {"version":3,"file":"tambo-thread.d.ts","sourceRoot":"","sources":["../../src/model/tambo-thread.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE;;;GAGG;AACH,MAAM,WAAW,WAAY,SAAQ,OAAO,CAAC,IAAI,CAAC,MAAM;IACtD,QAAQ,EAAE,kBAAkB,EAAE,CAAC;CAChC"}
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-thread.js","sourceRoot":"","sources":["../../src/model/tambo-thread.ts"],"names":[],"mappings":"","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { TamboThreadMessage } from \"./generate-component-response\";\n\n/** An extension of the TamboAI.Beta.Thread type that includes\n * messages with renderedComponent */\nexport interface TamboThread extends TamboAI.Beta.Thread {\n messages: TamboThreadMessage[];\n}\n"]}
1
+ {"version":3,"file":"tambo-thread.js","sourceRoot":"","sources":["../../src/model/tambo-thread.ts"],"names":[],"mappings":"","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { TamboThreadMessage } from \"./generate-component-response\";\n\n/**\n * An extension of the TamboAI.Beta.Thread type that includes\n * messages with renderedComponent\n */\nexport interface TamboThread extends TamboAI.Beta.Thread {\n messages: TamboThreadMessage[];\n}\n"]}
@@ -3,5 +3,10 @@ export interface ValidationResult {
3
3
  error?: Error;
4
4
  sanitizedInput: string;
5
5
  }
6
+ /**
7
+ * Validates the input of a message. Makes sure the message is not empty and is not too long.
8
+ * @param input - The input to validate
9
+ * @returns The validation result
10
+ */
6
11
  export declare function validateInput(input: string): ValidationResult;
7
12
  //# sourceMappingURL=validate-input.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate-input.d.ts","sourceRoot":"","sources":["../../src/model/validate-input.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;CACxB;AAGD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAwB7D"}
1
+ {"version":3,"file":"validate-input.d.ts","sourceRoot":"","sources":["../../src/model/validate-input.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAwB7D"}
@@ -1,4 +1,8 @@
1
- // TODO(future): Consider adding more validation rules if needed
1
+ /**
2
+ * Validates the input of a message. Makes sure the message is not empty and is not too long.
3
+ * @param input - The input to validate
4
+ * @returns The validation result
5
+ */
2
6
  export function validateInput(input) {
3
7
  const trimmed = input.trim();
4
8
  if (trimmed.length === 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"validate-input.js","sourceRoot":"","sources":["../../src/model/validate-input.ts"],"names":[],"mappings":"AAMA,gEAAgE;AAChE,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAE7B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,IAAI,KAAK,CAAC,yBAAyB,CAAC;YAC3C,cAAc,EAAE,OAAO;SACxB,CAAC;IACJ,CAAC;IAED,+CAA+C;IAC/C,IAAI,OAAO,CAAC,MAAM,GAAG,KAAK,EAAE,CAAC;QAC3B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,IAAI,KAAK,CAAC,4CAA4C,CAAC;YAC9D,cAAc,EAAE,OAAO;SACxB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,cAAc,EAAE,OAAO;KACxB,CAAC;AACJ,CAAC","sourcesContent":["export interface ValidationResult {\n isValid: boolean;\n error?: Error;\n sanitizedInput: string;\n}\n\n// TODO(future): Consider adding more validation rules if needed\nexport function validateInput(input: string): ValidationResult {\n const trimmed = input.trim();\n\n if (trimmed.length === 0) {\n return {\n isValid: false,\n error: new Error(\"Message cannot be empty\"),\n sanitizedInput: trimmed,\n };\n }\n\n // TODO(perf): Make this configurable if needed\n if (trimmed.length > 10000) {\n return {\n isValid: false,\n error: new Error(\"Message is too long (max 10000 characters)\"),\n sanitizedInput: trimmed,\n };\n }\n\n return {\n isValid: true,\n sanitizedInput: trimmed,\n };\n}\n"]}
1
+ {"version":3,"file":"validate-input.js","sourceRoot":"","sources":["../../src/model/validate-input.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAE7B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,IAAI,KAAK,CAAC,yBAAyB,CAAC;YAC3C,cAAc,EAAE,OAAO;SACxB,CAAC;IACJ,CAAC;IAED,+CAA+C;IAC/C,IAAI,OAAO,CAAC,MAAM,GAAG,KAAK,EAAE,CAAC;QAC3B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,IAAI,KAAK,CAAC,4CAA4C,CAAC;YAC9D,cAAc,EAAE,OAAO;SACxB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,cAAc,EAAE,OAAO;KACxB,CAAC;AACJ,CAAC","sourcesContent":["export interface ValidationResult {\n isValid: boolean;\n error?: Error;\n sanitizedInput: string;\n}\n\n/**\n * Validates the input of a message. Makes sure the message is not empty and is not too long.\n * @param input - The input to validate\n * @returns The validation result\n */\nexport function validateInput(input: string): ValidationResult {\n const trimmed = input.trim();\n\n if (trimmed.length === 0) {\n return {\n isValid: false,\n error: new Error(\"Message cannot be empty\"),\n sanitizedInput: trimmed,\n };\n }\n\n // TODO(perf): Make this configurable if needed\n if (trimmed.length > 10000) {\n return {\n isValid: false,\n error: new Error(\"Message is too long (max 10000 characters)\"),\n sanitizedInput: trimmed,\n };\n }\n\n return {\n isValid: true,\n sanitizedInput: trimmed,\n };\n}\n"]}
@@ -2,16 +2,47 @@ import TamboAI from "@tambo-ai/typescript-sdk";
2
2
  import { QueryClient } from "@tanstack/react-query";
3
3
  import React, { PropsWithChildren } from "react";
4
4
  export interface TamboClientProviderProps {
5
+ /**
6
+ * The URL of the Tambo API (used for local development and debugging)
7
+ */
5
8
  tamboUrl?: string;
9
+ /**
10
+ * The API key for the Tambo API
11
+ */
6
12
  apiKey: string;
13
+ /**
14
+ * The environment to use for the Tambo API
15
+ */
7
16
  environment?: "production" | "staging";
8
17
  }
9
18
  export interface TamboClientContextProps {
19
+ /** The TamboAI client */
10
20
  client: TamboAI;
11
21
  /** The tambo-specific query client */
12
22
  queryClient: QueryClient;
13
23
  }
24
+ /**
25
+ * The TamboClientProvider is a React provider that provides a TamboAI client
26
+ * and a query client to the descendants of the provider.
27
+ * @param props - The props for the TamboClientProvider
28
+ * @param props.children - The children to wrap
29
+ * @param props.tamboUrl - The URL of the Tambo API
30
+ * @param props.apiKey - The API key for the Tambo API
31
+ * @param props.environment - The environment to use for the Tambo API
32
+ * @returns The TamboClientProvider component
33
+ */
14
34
  export declare const TamboClientProvider: React.FC<PropsWithChildren<TamboClientProviderProps>>;
35
+ /**
36
+ * The useTamboClient hook provides access to the TamboAI client
37
+ * to the descendants of the TamboClientProvider.
38
+ * @returns The TamboAI client
39
+ */
15
40
  export declare const useTamboClient: () => TamboAI;
41
+ /**
42
+ * The useTamboQueryClient hook provides access to the tambo-specific query client
43
+ * to the descendants of the TamboClientProvider.
44
+ * @returns The tambo-specific query client
45
+ * @private
46
+ */
16
47
  export declare const useTamboQueryClient: () => QueryClient;
17
48
  //# sourceMappingURL=tambo-client-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-client-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-client-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,OAA0B,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,EAAiB,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAE1E,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACxC;AACD,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,OAAO,CAAC;IAChB,sCAAsC;IACtC,WAAW,EAAE,WAAW,CAAC;CAC1B;AAMD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CACxC,iBAAiB,CAAC,wBAAwB,CAAC,CAgB5C,CAAC;AAEF,eAAO,MAAM,cAAc,eAM1B,CAAC;AAEF,eAAO,MAAM,mBAAmB,mBAQ/B,CAAC"}
1
+ {"version":3,"file":"tambo-client-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-client-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,OAA0B,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,EAAiB,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAE1E,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACxC;AAED,MAAM,WAAW,uBAAuB;IACtC,yBAAyB;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,sCAAsC;IACtC,WAAW,EAAE,WAAW,CAAC;CAC1B;AAMD;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CACxC,iBAAiB,CAAC,wBAAwB,CAAC,CAgB5C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,eAM1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,mBAQ/B,CAAC"}
@@ -2,6 +2,16 @@ import TamboAI from "@tambo-ai/typescript-sdk";
2
2
  import { QueryClient } from "@tanstack/react-query";
3
3
  import React, { createContext, useState } from "react";
4
4
  const TamboClientContext = createContext(undefined);
5
+ /**
6
+ * The TamboClientProvider is a React provider that provides a TamboAI client
7
+ * and a query client to the descendants of the provider.
8
+ * @param props - The props for the TamboClientProvider
9
+ * @param props.children - The children to wrap
10
+ * @param props.tamboUrl - The URL of the Tambo API
11
+ * @param props.apiKey - The API key for the Tambo API
12
+ * @param props.environment - The environment to use for the Tambo API
13
+ * @returns The TamboClientProvider component
14
+ */
5
15
  export const TamboClientProvider = ({ children, tamboUrl, apiKey, environment }) => {
6
16
  const tamboConfig = { apiKey };
7
17
  if (tamboUrl) {
@@ -14,6 +24,11 @@ export const TamboClientProvider = ({ children, tamboUrl, apiKey, environment })
14
24
  const [queryClient] = useState(() => new QueryClient());
15
25
  return (React.createElement(TamboClientContext.Provider, { value: { client, queryClient } }, children));
16
26
  };
27
+ /**
28
+ * The useTamboClient hook provides access to the TamboAI client
29
+ * to the descendants of the TamboClientProvider.
30
+ * @returns The TamboAI client
31
+ */
17
32
  export const useTamboClient = () => {
18
33
  const context = React.useContext(TamboClientContext);
19
34
  if (context === undefined) {
@@ -21,6 +36,12 @@ export const useTamboClient = () => {
21
36
  }
22
37
  return context.client;
23
38
  };
39
+ /**
40
+ * The useTamboQueryClient hook provides access to the tambo-specific query client
41
+ * to the descendants of the TamboClientProvider.
42
+ * @returns The tambo-specific query client
43
+ * @private
44
+ */
24
45
  export const useTamboQueryClient = () => {
25
46
  const context = React.useContext(TamboClientContext);
26
47
  if (context === undefined) {