@tambo-ai/react 0.18.2 → 0.19.1

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 (181) hide show
  1. package/dist/hooks/index.d.ts +1 -1
  2. package/dist/hooks/index.d.ts.map +1 -1
  3. package/dist/hooks/index.js +2 -2
  4. package/dist/hooks/index.js.map +1 -1
  5. package/dist/hooks/react-query-hooks.d.ts +8 -0
  6. package/dist/hooks/react-query-hooks.d.ts.map +1 -1
  7. package/dist/hooks/react-query-hooks.js +8 -0
  8. package/dist/hooks/react-query-hooks.js.map +1 -1
  9. package/dist/hooks/use-component-state.d.ts +0 -3
  10. package/dist/hooks/use-component-state.d.ts.map +1 -1
  11. package/dist/hooks/use-component-state.js +8 -26
  12. package/dist/hooks/use-component-state.js.map +1 -1
  13. package/dist/hooks/use-current-message.d.ts +27 -7
  14. package/dist/hooks/use-current-message.d.ts.map +1 -1
  15. package/dist/hooks/use-current-message.js +27 -7
  16. package/dist/hooks/use-current-message.js.map +1 -1
  17. package/dist/hooks/use-streaming-props.d.ts +0 -2
  18. package/dist/hooks/use-streaming-props.d.ts.map +1 -1
  19. package/dist/hooks/use-streaming-props.js +0 -2
  20. package/dist/hooks/use-streaming-props.js.map +1 -1
  21. package/dist/hooks/use-suggestions.d.ts +0 -1
  22. package/dist/hooks/use-suggestions.d.ts.map +1 -1
  23. package/dist/hooks/use-suggestions.js +0 -1
  24. package/dist/hooks/use-suggestions.js.map +1 -1
  25. package/dist/hooks/use-tambo-threads.d.ts +35 -5
  26. package/dist/hooks/use-tambo-threads.d.ts.map +1 -1
  27. package/dist/hooks/use-tambo-threads.js +11 -3
  28. package/dist/hooks/use-tambo-threads.js.map +1 -1
  29. package/dist/hooks/use-thread-input.d.ts +0 -1
  30. package/dist/hooks/use-thread-input.d.ts.map +1 -1
  31. package/dist/hooks/use-thread-input.js +0 -1
  32. package/dist/hooks/use-thread-input.js.map +1 -1
  33. package/dist/index.d.ts +2 -2
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +10 -3
  36. package/dist/index.js.map +1 -1
  37. package/dist/model/component-metadata.d.ts +6 -3
  38. package/dist/model/component-metadata.d.ts.map +1 -1
  39. package/dist/model/component-metadata.js.map +1 -1
  40. package/dist/model/generate-component-response.d.ts +9 -2
  41. package/dist/model/generate-component-response.d.ts.map +1 -1
  42. package/dist/model/generate-component-response.js +5 -0
  43. package/dist/model/generate-component-response.js.map +1 -1
  44. package/dist/model/tambo-thread.d.ts +4 -2
  45. package/dist/model/tambo-thread.d.ts.map +1 -1
  46. package/dist/model/tambo-thread.js.map +1 -1
  47. package/dist/model/validate-input.d.ts +5 -0
  48. package/dist/model/validate-input.d.ts.map +1 -1
  49. package/dist/model/validate-input.js +5 -1
  50. package/dist/model/validate-input.js.map +1 -1
  51. package/dist/providers/tambo-client-provider.d.ts +31 -0
  52. package/dist/providers/tambo-client-provider.d.ts.map +1 -1
  53. package/dist/providers/tambo-client-provider.js +21 -0
  54. package/dist/providers/tambo-client-provider.js.map +1 -1
  55. package/dist/providers/tambo-component-provider.d.ts +12 -0
  56. package/dist/providers/tambo-component-provider.d.ts.map +1 -1
  57. package/dist/providers/tambo-component-provider.js +24 -0
  58. package/dist/providers/tambo-component-provider.js.map +1 -1
  59. package/dist/providers/tambo-provider.d.ts +18 -1
  60. package/dist/providers/tambo-provider.d.ts.map +1 -1
  61. package/dist/providers/tambo-provider.js +25 -2
  62. package/dist/providers/tambo-provider.js.map +1 -1
  63. package/dist/providers/tambo-registry-provider.d.ts +14 -1
  64. package/dist/providers/tambo-registry-provider.d.ts.map +1 -1
  65. package/dist/providers/tambo-registry-provider.js +25 -0
  66. package/dist/providers/tambo-registry-provider.js.map +1 -1
  67. package/dist/providers/tambo-thread-provider.d.ts +26 -2
  68. package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
  69. package/dist/providers/tambo-thread-provider.js +46 -26
  70. package/dist/providers/tambo-thread-provider.js.map +1 -1
  71. package/dist/util/generate-component.d.ts +5 -1
  72. package/dist/util/generate-component.d.ts.map +1 -1
  73. package/dist/util/generate-component.js +5 -1
  74. package/dist/util/generate-component.js.map +1 -1
  75. package/dist/util/query-utils.d.ts +16 -0
  76. package/dist/util/query-utils.d.ts.map +1 -1
  77. package/dist/util/query-utils.js +16 -0
  78. package/dist/util/query-utils.js.map +1 -1
  79. package/dist/util/registry.d.ts +27 -1
  80. package/dist/util/registry.d.ts.map +1 -1
  81. package/dist/util/registry.js +29 -4
  82. package/dist/util/registry.js.map +1 -1
  83. package/dist/util/tool-caller.d.ts +6 -0
  84. package/dist/util/tool-caller.d.ts.map +1 -1
  85. package/dist/util/tool-caller.js +6 -0
  86. package/dist/util/tool-caller.js.map +1 -1
  87. package/esm/hooks/index.d.ts +1 -1
  88. package/esm/hooks/index.d.ts.map +1 -1
  89. package/esm/hooks/index.js +1 -1
  90. package/esm/hooks/index.js.map +1 -1
  91. package/esm/hooks/react-query-hooks.d.ts +8 -0
  92. package/esm/hooks/react-query-hooks.d.ts.map +1 -1
  93. package/esm/hooks/react-query-hooks.js +8 -0
  94. package/esm/hooks/react-query-hooks.js.map +1 -1
  95. package/esm/hooks/use-component-state.d.ts +0 -3
  96. package/esm/hooks/use-component-state.d.ts.map +1 -1
  97. package/esm/hooks/use-component-state.js +2 -23
  98. package/esm/hooks/use-component-state.js.map +1 -1
  99. package/esm/hooks/use-current-message.d.ts +27 -7
  100. package/esm/hooks/use-current-message.d.ts.map +1 -1
  101. package/esm/hooks/use-current-message.js +27 -7
  102. package/esm/hooks/use-current-message.js.map +1 -1
  103. package/esm/hooks/use-streaming-props.d.ts +0 -2
  104. package/esm/hooks/use-streaming-props.d.ts.map +1 -1
  105. package/esm/hooks/use-streaming-props.js +0 -2
  106. package/esm/hooks/use-streaming-props.js.map +1 -1
  107. package/esm/hooks/use-suggestions.d.ts +0 -1
  108. package/esm/hooks/use-suggestions.d.ts.map +1 -1
  109. package/esm/hooks/use-suggestions.js +0 -1
  110. package/esm/hooks/use-suggestions.js.map +1 -1
  111. package/esm/hooks/use-tambo-threads.d.ts +35 -5
  112. package/esm/hooks/use-tambo-threads.d.ts.map +1 -1
  113. package/esm/hooks/use-tambo-threads.js +10 -2
  114. package/esm/hooks/use-tambo-threads.js.map +1 -1
  115. package/esm/hooks/use-thread-input.d.ts +0 -1
  116. package/esm/hooks/use-thread-input.d.ts.map +1 -1
  117. package/esm/hooks/use-thread-input.js +0 -1
  118. package/esm/hooks/use-thread-input.js.map +1 -1
  119. package/esm/index.d.ts +2 -2
  120. package/esm/index.d.ts.map +1 -1
  121. package/esm/index.js +2 -2
  122. package/esm/index.js.map +1 -1
  123. package/esm/model/component-metadata.d.ts +6 -3
  124. package/esm/model/component-metadata.d.ts.map +1 -1
  125. package/esm/model/component-metadata.js.map +1 -1
  126. package/esm/model/generate-component-response.d.ts +9 -2
  127. package/esm/model/generate-component-response.d.ts.map +1 -1
  128. package/esm/model/generate-component-response.js +5 -0
  129. package/esm/model/generate-component-response.js.map +1 -1
  130. package/esm/model/tambo-thread.d.ts +4 -2
  131. package/esm/model/tambo-thread.d.ts.map +1 -1
  132. package/esm/model/tambo-thread.js.map +1 -1
  133. package/esm/model/validate-input.d.ts +5 -0
  134. package/esm/model/validate-input.d.ts.map +1 -1
  135. package/esm/model/validate-input.js +5 -1
  136. package/esm/model/validate-input.js.map +1 -1
  137. package/esm/providers/tambo-client-provider.d.ts +31 -0
  138. package/esm/providers/tambo-client-provider.d.ts.map +1 -1
  139. package/esm/providers/tambo-client-provider.js +21 -0
  140. package/esm/providers/tambo-client-provider.js.map +1 -1
  141. package/esm/providers/tambo-component-provider.d.ts +12 -0
  142. package/esm/providers/tambo-component-provider.d.ts.map +1 -1
  143. package/esm/providers/tambo-component-provider.js +24 -0
  144. package/esm/providers/tambo-component-provider.js.map +1 -1
  145. package/esm/providers/tambo-provider.d.ts +18 -1
  146. package/esm/providers/tambo-provider.d.ts.map +1 -1
  147. package/esm/providers/tambo-provider.js +25 -2
  148. package/esm/providers/tambo-provider.js.map +1 -1
  149. package/esm/providers/tambo-registry-provider.d.ts +14 -1
  150. package/esm/providers/tambo-registry-provider.d.ts.map +1 -1
  151. package/esm/providers/tambo-registry-provider.js +25 -0
  152. package/esm/providers/tambo-registry-provider.js.map +1 -1
  153. package/esm/providers/tambo-thread-provider.d.ts +26 -2
  154. package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
  155. package/esm/providers/tambo-thread-provider.js +46 -26
  156. package/esm/providers/tambo-thread-provider.js.map +1 -1
  157. package/esm/util/generate-component.d.ts +5 -1
  158. package/esm/util/generate-component.d.ts.map +1 -1
  159. package/esm/util/generate-component.js +5 -1
  160. package/esm/util/generate-component.js.map +1 -1
  161. package/esm/util/query-utils.d.ts +16 -0
  162. package/esm/util/query-utils.d.ts.map +1 -1
  163. package/esm/util/query-utils.js +16 -0
  164. package/esm/util/query-utils.js.map +1 -1
  165. package/esm/util/registry.d.ts +27 -1
  166. package/esm/util/registry.d.ts.map +1 -1
  167. package/esm/util/registry.js +28 -2
  168. package/esm/util/registry.js.map +1 -1
  169. package/esm/util/tool-caller.d.ts +6 -0
  170. package/esm/util/tool-caller.d.ts.map +1 -1
  171. package/esm/util/tool-caller.js +6 -0
  172. package/esm/util/tool-caller.js.map +1 -1
  173. package/package.json +4 -2
  174. package/dist/util/messages.d.ts +0 -3
  175. package/dist/util/messages.d.ts.map +0 -1
  176. package/dist/util/messages.js +0 -12
  177. package/dist/util/messages.js.map +0 -1
  178. package/esm/util/messages.d.ts +0 -3
  179. package/esm/util/messages.d.ts.map +0 -1
  180. package/esm/util/messages.js +0 -9
  181. package/esm/util/messages.js.map +0 -1
@@ -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) {
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-client-provider.js","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,EAAE,aAAa,EAAqB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAa1E,MAAM,kBAAkB,GAAG,aAAa,CACtC,SAAS,CACV,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAE5B,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,MA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ack/react-query\";\nimport React, { createContext, PropsWithChildren, useState } from \"react\";\n\nexport interface TamboClientProviderProps {\n tamboUrl?: string;\n apiKey: string;\n environment?: \"production\" | \"staging\";\n}\nexport interface TamboClientContextProps {\n client: TamboAI;\n /** The tambo-specific query client */\n queryClient: QueryClient;\n}\n\nconst TamboClientContext = createContext<TamboClientContextProps | undefined>(\n undefined,\n);\n\nexport const TamboClientProvider: React.FC<\n PropsWithChildren<TamboClientProviderProps>\n> = ({ children, tamboUrl, apiKey, environment }) => {\n const tamboConfig: ClientOptions = { apiKey };\n if (tamboUrl) {\n tamboConfig.baseURL = tamboUrl;\n }\n if (environment) {\n tamboConfig.environment = environment;\n }\n const [client] = useState(() => new TamboAI(tamboConfig));\n const [queryClient] = useState(() => new QueryClient());\n return (\n <TamboClientContext.Provider value={{ client, queryClient }}>\n {children}\n </TamboClientContext.Provider>\n );\n};\n\nexport const useTamboClient = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\"useTamboClient must be used within a TamboClientProvider\");\n }\n return context.client;\n};\n\nexport const useTamboQueryClient = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\n \"useTamboQueryClient must be used within a TamboClientProvider\",\n );\n }\n return context.queryClient;\n};\n"]}
1
+ {"version":3,"file":"tambo-client-provider.js","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,EAAE,aAAa,EAAqB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAwB1E,MAAM,kBAAkB,GAAG,aAAa,CACtC,SAAS,CACV,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAE5B,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE;I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query\";\nimport React, { createContext, PropsWithChildren, useState } from \"react\";\n\nexport interface TamboClientProviderProps {\n /**\n * The URL of the Tambo API (used for local development and debugging)\n */\n tamboUrl?: string;\n /**\n * The API key for the Tambo API\n */\n apiKey: string;\n /**\n * The environment to use for the Tambo API\n */\n environment?: \"production\" | \"staging\";\n}\n\nexport interface TamboClientContextProps {\n /** The TamboAI client */\n client: TamboAI;\n /** The tambo-specific query client */\n queryClient: QueryClient;\n}\n\nconst TamboClientContext = createContext<TamboClientContextProps | undefined>(\n undefined,\n);\n\n/**\n * The TamboClientProvider is a React provider that provides a TamboAI client\n * and a query client to the descendants of the provider.\n * @param props - The props for the TamboClientProvider\n * @param props.children - The children to wrap\n * @param props.tamboUrl - The URL of the Tambo API\n * @param props.apiKey - The API key for the Tambo API\n * @param props.environment - The environment to use for the Tambo API\n * @returns The TamboClientProvider component\n */\nexport const TamboClientProvider: React.FC<\n PropsWithChildren<TamboClientProviderProps>\n> = ({ children, tamboUrl, apiKey, environment }) => {\n const tamboConfig: ClientOptions = { apiKey };\n if (tamboUrl) {\n tamboConfig.baseURL = tamboUrl;\n }\n if (environment) {\n tamboConfig.environment = environment;\n }\n const [client] = useState(() => new TamboAI(tamboConfig));\n const [queryClient] = useState(() => new QueryClient());\n return (\n <TamboClientContext.Provider value={{ client, queryClient }}>\n {children}\n </TamboClientContext.Provider>\n );\n};\n\n/**\n * The useTamboClient hook provides access to the TamboAI client\n * to the descendants of the TamboClientProvider.\n * @returns The TamboAI client\n */\nexport const useTamboClient = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\"useTamboClient must be used within a TamboClientProvider\");\n }\n return context.client;\n};\n\n/**\n * The useTamboQueryClient hook provides access to the tambo-specific query client\n * to the descendants of the TamboClientProvider.\n * @returns The tambo-specific query client\n * @private\n */\nexport const useTamboQueryClient = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\n \"useTamboQueryClient must be used within a TamboClientProvider\",\n );\n }\n return context.queryClient;\n};\n"]}
@@ -6,6 +6,18 @@ export interface TamboComponentContextProps {
6
6
  registerTools: (tools: TamboTool[]) => void;
7
7
  addToolAssociation: (componentName: string, tool: TamboTool) => void;
8
8
  }
9
+ /**
10
+ * The TamboComponentProvider is a React provider that provides component
11
+ * registration services to the descendants of the provider.
12
+ * @param props - The props for the TamboComponentProvider
13
+ * @param props.children - The children to wrap
14
+ * @returns The TamboComponentProvider component
15
+ */
9
16
  export declare const TamboComponentProvider: React.FC<PropsWithChildren>;
17
+ /**
18
+ * The useTamboComponent hook provides access to the component registration
19
+ * services to the descendants of the TamboComponentProvider.
20
+ * @returns The component registration services
21
+ */
10
22
  export declare const useTamboComponent: () => TamboComponentContextProps;
11
23
  //# sourceMappingURL=tambo-component-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-component-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-component-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAiB,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAIxE,MAAM,WAAW,0BAA0B;IACzC,iBAAiB,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,YAAY,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACxC,aAAa,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IAC5C,kBAAkB,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACtE;AASD,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAoB9D,CAAC;AAEF,eAAO,MAAM,iBAAiB,kCAE7B,CAAC"}
1
+ {"version":3,"file":"tambo-component-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-component-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAiB,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAIxE,MAAM,WAAW,0BAA0B;IACzC,iBAAiB,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,YAAY,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACxC,aAAa,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IAC5C,kBAAkB,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACtE;AAqBD;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAoB9D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,kCAE7B,CAAC"}
@@ -3,11 +3,30 @@ import React, { createContext, useContext } from "react";
3
3
  import { useTamboClient } from "./tambo-client-provider";
4
4
  import { useTamboRegistry } from "./tambo-registry-provider";
5
5
  const TamboComponentContext = createContext({
6
+ /**
7
+ *
8
+ */
6
9
  registerComponent: () => { },
10
+ /**
11
+ *
12
+ */
7
13
  registerTool: () => { },
14
+ /**
15
+ *
16
+ */
8
17
  registerTools: () => { },
18
+ /**
19
+ *
20
+ */
9
21
  addToolAssociation: () => { },
10
22
  });
23
+ /**
24
+ * The TamboComponentProvider is a React provider that provides component
25
+ * registration services to the descendants of the provider.
26
+ * @param props - The props for the TamboComponentProvider
27
+ * @param props.children - The children to wrap
28
+ * @returns The TamboComponentProvider component
29
+ */
11
30
  export const TamboComponentProvider = ({ children, }) => {
12
31
  const client = useTamboClient();
13
32
  const { registerComponent, addToolAssociation, registerTool, registerTools } = useTamboRegistry();
@@ -20,6 +39,11 @@ export const TamboComponentProvider = ({ children, }) => {
20
39
  };
21
40
  return (React.createElement(TamboComponentContext.Provider, { value: value }, children));
22
41
  };
42
+ /**
43
+ * The useTamboComponent hook provides access to the component registration
44
+ * services to the descendants of the TamboComponentProvider.
45
+ * @returns The component registration services
46
+ */
23
47
  export const useTamboComponent = () => {
24
48
  return useContext(TamboComponentContext);
25
49
  };
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-component-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-component-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EAAE,aAAa,EAAqB,UAAU,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAS7D,MAAM,qBAAqB,GAAG,aAAa,CAA6B;IACtE,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC3B,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;IACvB,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;CAC7B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAgC,CAAC,EAClE,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,YAAY,EAAE,aAAa,EAAE,GAC1E,gBAAgB,EAAE,CAAC;IAErB,MAAM,KAAK,GAAG;QACZ,MAAM;QACN,iBAAiB;QACjB,YAAY;QACZ,aAAa;QACb,kBAAkB;KACnB,CAAC;IAEF,OAAO,CACL,oBAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IACzC,QAAQ,CACsB,CAClC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,OAAO,UAAU,CAAC,qBAAqB,CAAC,CAAC;AAC3C,CAAC,CAAC","sourcesContent":["\"use client\";\nimport React, { createContext, PropsWithChildren, useContext } from \"react\";\nimport { TamboComponent, TamboTool } from \"../model/component-metadata\";\nimport { useTamboClient } from \"./tambo-client-provider\";\nimport { useTamboRegistry } from \"./tambo-registry-provider\";\n\nexport interface TamboComponentContextProps {\n registerComponent: (options: TamboComponent) => void;\n registerTool: (tool: TamboTool) => void;\n registerTools: (tools: TamboTool[]) => void;\n addToolAssociation: (componentName: string, tool: TamboTool) => void;\n}\n\nconst TamboComponentContext = createContext<TamboComponentContextProps>({\n registerComponent: () => {},\n registerTool: () => {},\n registerTools: () => {},\n addToolAssociation: () => {},\n});\n\nexport const TamboComponentProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const client = useTamboClient();\n const { registerComponent, addToolAssociation, registerTool, registerTools } =\n useTamboRegistry();\n\n const value = {\n client,\n registerComponent,\n registerTool,\n registerTools,\n addToolAssociation,\n };\n\n return (\n <TamboComponentContext.Provider value={value}>\n {children}\n </TamboComponentContext.Provider>\n );\n};\n\nexport const useTamboComponent = () => {\n return useContext(TamboComponentContext);\n};\n"]}
1
+ {"version":3,"file":"tambo-component-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-component-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EAAE,aAAa,EAAqB,UAAU,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAS7D,MAAM,qBAAqB,GAAG,aAAa,CAA6B;IACtE;;OAEG;IACH,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC3B;;OAEG;IACH,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB;;OAEG;IACH,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;IACvB;;OAEG;IACH,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;CAC7B,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAgC,CAAC,EAClE,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,YAAY,EAAE,aAAa,EAAE,GAC1E,gBAAgB,EAAE,CAAC;IAErB,MAAM,KAAK,GAAG;QACZ,MAAM;QACN,iBAAiB;QACjB,YAAY;QACZ,aAAa;QACb,kBAAkB;KACnB,CAAC;IAEF,OAAO,CACL,oBAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IACzC,QAAQ,CACsB,CAClC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,OAAO,UAAU,CAAC,qBAAqB,CAAC,CAAC;AAC3C,CAAC,CAAC","sourcesContent":["\"use client\";\nimport React, { createContext, PropsWithChildren, useContext } from \"react\";\nimport { TamboComponent, TamboTool } from \"../model/component-metadata\";\nimport { useTamboClient } from \"./tambo-client-provider\";\nimport { useTamboRegistry } from \"./tambo-registry-provider\";\n\nexport interface TamboComponentContextProps {\n registerComponent: (options: TamboComponent) => void;\n registerTool: (tool: TamboTool) => void;\n registerTools: (tools: TamboTool[]) => void;\n addToolAssociation: (componentName: string, tool: TamboTool) => void;\n}\n\nconst TamboComponentContext = createContext<TamboComponentContextProps>({\n /**\n *\n */\n registerComponent: () => {},\n /**\n *\n */\n registerTool: () => {},\n /**\n *\n */\n registerTools: () => {},\n /**\n *\n */\n addToolAssociation: () => {},\n});\n\n/**\n * The TamboComponentProvider is a React provider that provides component\n * registration services to the descendants of the provider.\n * @param props - The props for the TamboComponentProvider\n * @param props.children - The children to wrap\n * @returns The TamboComponentProvider component\n */\nexport const TamboComponentProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const client = useTamboClient();\n const { registerComponent, addToolAssociation, registerTool, registerTools } =\n useTamboRegistry();\n\n const value = {\n client,\n registerComponent,\n registerTool,\n registerTools,\n addToolAssociation,\n };\n\n return (\n <TamboComponentContext.Provider value={value}>\n {children}\n </TamboComponentContext.Provider>\n );\n};\n\n/**\n * The useTamboComponent hook provides access to the component registration\n * services to the descendants of the TamboComponentProvider.\n * @returns The component registration services\n */\nexport const useTamboComponent = () => {\n return useContext(TamboComponentContext);\n};\n"]}
@@ -3,10 +3,27 @@ import { TamboClientContextProps, TamboClientProviderProps } from "./tambo-clien
3
3
  import { TamboComponentContextProps } from "./tambo-component-provider";
4
4
  import { TamboRegistryProviderProps } from "./tambo-registry-provider";
5
5
  import { TamboThreadContextProps } from "./tambo-thread-provider";
6
- /** TamboProvider gives full access to the TamboAI client and component registry */
6
+ /**
7
+ * The TamboProvider gives full access to the whole Tambo API. This includes the
8
+ * TamboAI client, the component registry, and the current thread context.
9
+ * @param props - The props for the TamboProvider
10
+ * @param props.children - The children to wrap
11
+ * @param props.tamboUrl - The URL of the Tambo API
12
+ * @param props.apiKey - The API key for the Tambo API
13
+ * @param props.components - The components to register
14
+ * @param props.environment - The environment to use for the Tambo API
15
+ * @returns The TamboProvider component
16
+ */
7
17
  export declare const TamboProvider: React.FC<PropsWithChildren<TamboClientProviderProps & TamboRegistryProviderProps>>;
8
18
  type TamboContextProps = TamboClientContextProps & TamboThreadContextProps & TamboComponentContextProps;
9
19
  export declare const TamboContext: React.Context<TamboContextProps>;
20
+ /**
21
+ * The useTambo hook provides access to the Tambo API. This is the primary entrypoint
22
+ * for the Tambo React SDK.
23
+ *
24
+ * This includes the TamboAI client, the component registry, and the current thread context.
25
+ * @returns The Tambo API
26
+ */
10
27
  export declare const useTambo: () => TamboContextProps;
11
28
  export {};
12
29
  //# sourceMappingURL=tambo-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":"AACA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BAEpB,CAAC"}
@@ -4,7 +4,17 @@ import { TamboClientProvider, useTamboClient, useTamboQueryClient, } from "./tam
4
4
  import { TamboComponentProvider, useTamboComponent, } from "./tambo-component-provider";
5
5
  import { TamboRegistryProvider, } from "./tambo-registry-provider";
6
6
  import { TamboThreadProvider, useTamboThread, } from "./tambo-thread-provider";
7
- /** TamboProvider gives full access to the TamboAI client and component registry */
7
+ /**
8
+ * The TamboProvider gives full access to the whole Tambo API. This includes the
9
+ * TamboAI client, the component registry, and the current thread context.
10
+ * @param props - The props for the TamboProvider
11
+ * @param props.children - The children to wrap
12
+ * @param props.tamboUrl - The URL of the Tambo API
13
+ * @param props.apiKey - The API key for the Tambo API
14
+ * @param props.components - The components to register
15
+ * @param props.environment - The environment to use for the Tambo API
16
+ * @returns The TamboProvider component
17
+ */
8
18
  export const TamboProvider = ({ children, tamboUrl, apiKey, components, environment }) => {
9
19
  return (React.createElement(TamboClientProvider, { tamboUrl: tamboUrl, apiKey: apiKey, environment: environment },
10
20
  React.createElement(TamboRegistryProvider, { components: components },
@@ -13,7 +23,13 @@ export const TamboProvider = ({ children, tamboUrl, apiKey, components, environm
13
23
  React.createElement(TamboCompositeProvider, null, children))))));
14
24
  };
15
25
  export const TamboContext = createContext({});
16
- /** TamboCompositeProvider is a provider that combines the TamboClient, TamboThread, and TamboComponent providers */
26
+ /**
27
+ * TamboCompositeProvider is a provider that combines the TamboClient,
28
+ * TamboThread, and TamboComponent providers
29
+ * @param props - The props for the TamboCompositeProvider
30
+ * @param props.children - The children to wrap
31
+ * @returns The wrapped component
32
+ */
17
33
  const TamboCompositeProvider = ({ children }) => {
18
34
  const threads = useTamboThread();
19
35
  const client = useTamboClient();
@@ -26,6 +42,13 @@ const TamboCompositeProvider = ({ children }) => {
26
42
  ...threads,
27
43
  } }, children));
28
44
  };
45
+ /**
46
+ * The useTambo hook provides access to the Tambo API. This is the primary entrypoint
47
+ * for the Tambo React SDK.
48
+ *
49
+ * This includes the TamboAI client, the component registry, and the current thread context.
50
+ * @returns The Tambo API
51
+ */
29
52
  export const useTambo = () => {
30
53
  return useContext(TamboContext);
31
54
  };
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EAAqB,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,EAEL,mBAAmB,EAEnB,cAAc,EACd,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,qBAAqB,GAEtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,mBAAmB,EACnB,cAAc,GACf,MAAM,yBAAyB,CAAC;AAEjC,mFAAmF;AAEnF,MAAM,CAAC,MAAM,aAAa,GAEtB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,EAAE;IAC9D,OAAO,CACL,oBAAC,mBAAmB,IAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW;QAExB,oBAAC,qBAAqB,IAAC,UAAU,EAAE,UAAU;YAC3C,oBAAC,mBAAmB;gBAClB,oBAAC,sBAAsB;oBACrB,oBAAC,sBAAsB,QAAE,QAAQ,CAA0B,CACpC,CACL,CACA,CACJ,CACvB,CAAC;AACJ,CAAC,CAAC;AAKF,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CACvC,EAAuB,CACxB,CAAC;AAEF,oHAAoH;AACpH,MAAM,sBAAsB,GAAgC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC3E,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,MAAM,WAAW,GAAG,mBAAmB,EAAE,CAAC;IAC1C,MAAM,iBAAiB,GAAG,iBAAiB,EAAE,CAAC;IAE9C,OAAO,CACL,oBAAC,YAAY,CAAC,QAAQ,IACpB,KAAK,EAAE;YACL,MAAM;YACN,WAAW;YACX,GAAG,iBAAiB;YACpB,GAAG,OAAO;SACX,IAEA,QAAQ,CACa,CACzB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,OAAO,UAAU,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC,CAAC","sourcesContent":["\"use client\";\nimport React, { PropsWithChildren, createContext, useContext } from \"react\";\nimport {\n TamboClientContextProps,\n TamboClientProvider,\n TamboClientProviderProps,\n useTamboClient,\n useTamboQueryClient,\n} from \"./tambo-client-provider\";\nimport {\n TamboComponentContextProps,\n TamboComponentProvider,\n useTamboComponent,\n} from \"./tambo-component-provider\";\nimport {\n TamboRegistryProvider,\n TamboRegistryProviderProps,\n} from \"./tambo-registry-provider\";\nimport {\n TamboThreadContextProps,\n TamboThreadProvider,\n useTamboThread,\n} from \"./tambo-thread-provider\";\n\n/** TamboProvider gives full access to the TamboAI client and component registry */\n\nexport const TamboProvider: React.FC<\n PropsWithChildren<TamboClientProviderProps & TamboRegistryProviderProps>\n> = ({ children, tamboUrl, apiKey, components, environment }) => {\n return (\n <TamboClientProvider\n tamboUrl={tamboUrl}\n apiKey={apiKey}\n environment={environment}\n >\n <TamboRegistryProvider components={components}>\n <TamboThreadProvider>\n <TamboComponentProvider>\n <TamboCompositeProvider>{children}</TamboCompositeProvider>\n </TamboComponentProvider>\n </TamboThreadProvider>\n </TamboRegistryProvider>\n </TamboClientProvider>\n );\n};\ntype TamboContextProps = TamboClientContextProps &\n TamboThreadContextProps &\n TamboComponentContextProps;\n\nexport const TamboContext = createContext<TamboContextProps>(\n {} as TamboContextProps,\n);\n\n/** TamboCompositeProvider is a provider that combines the TamboClient, TamboThread, and TamboComponent providers */\nconst TamboCompositeProvider: React.FC<PropsWithChildren> = ({ children }) => {\n const threads = useTamboThread();\n const client = useTamboClient();\n const queryClient = useTamboQueryClient();\n const componentRegistry = useTamboComponent();\n\n return (\n <TamboContext.Provider\n value={{\n client,\n queryClient,\n ...componentRegistry,\n ...threads,\n }}\n >\n {children}\n </TamboContext.Provider>\n );\n};\n\nexport const useTambo = () => {\n return useContext(TamboContext);\n};\n"]}
1
+ {"version":3,"file":"tambo-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EAAqB,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,EAEL,mBAAmB,EAEnB,cAAc,EACd,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,qBAAqB,GAEtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,mBAAmB,EACnB,cAAc,GACf,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,aAAa,GAEtB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,EAAE;IAC9D,OAAO,CACL,oBAAC,mBAAmB,IAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW;QAExB,oBAAC,qBAAqB,IAAC,UAAU,EAAE,UAAU;YAC3C,oBAAC,mBAAmB;gBAClB,oBAAC,sBAAsB;oBACrB,oBAAC,sBAAsB,QAAE,QAAQ,CAA0B,CACpC,CACL,CACA,CACJ,CACvB,CAAC;AACJ,CAAC,CAAC;AAKF,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CACvC,EAAuB,CACxB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,sBAAsB,GAAgC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC3E,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,MAAM,WAAW,GAAG,mBAAmB,EAAE,CAAC;IAC1C,MAAM,iBAAiB,GAAG,iBAAiB,EAAE,CAAC;IAE9C,OAAO,CACL,oBAAC,YAAY,CAAC,QAAQ,IACpB,KAAK,EAAE;YACL,MAAM;YACN,WAAW;YACX,GAAG,iBAAiB;YACpB,GAAG,OAAO;SACX,IAEA,QAAQ,CACa,CACzB,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,OAAO,UAAU,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC,CAAC","sourcesContent":["\"use client\";\nimport React, { PropsWithChildren, createContext, useContext } from \"react\";\nimport {\n TamboClientContextProps,\n TamboClientProvider,\n TamboClientProviderProps,\n useTamboClient,\n useTamboQueryClient,\n} from \"./tambo-client-provider\";\nimport {\n TamboComponentContextProps,\n TamboComponentProvider,\n useTamboComponent,\n} from \"./tambo-component-provider\";\nimport {\n TamboRegistryProvider,\n TamboRegistryProviderProps,\n} from \"./tambo-registry-provider\";\nimport {\n TamboThreadContextProps,\n TamboThreadProvider,\n useTamboThread,\n} from \"./tambo-thread-provider\";\n\n/**\n * The TamboProvider gives full access to the whole Tambo API. This includes the\n * TamboAI client, the component registry, and the current thread context.\n * @param props - The props for the TamboProvider\n * @param props.children - The children to wrap\n * @param props.tamboUrl - The URL of the Tambo API\n * @param props.apiKey - The API key for the Tambo API\n * @param props.components - The components to register\n * @param props.environment - The environment to use for the Tambo API\n * @returns The TamboProvider component\n */\nexport const TamboProvider: React.FC<\n PropsWithChildren<TamboClientProviderProps & TamboRegistryProviderProps>\n> = ({ children, tamboUrl, apiKey, components, environment }) => {\n return (\n <TamboClientProvider\n tamboUrl={tamboUrl}\n apiKey={apiKey}\n environment={environment}\n >\n <TamboRegistryProvider components={components}>\n <TamboThreadProvider>\n <TamboComponentProvider>\n <TamboCompositeProvider>{children}</TamboCompositeProvider>\n </TamboComponentProvider>\n </TamboThreadProvider>\n </TamboRegistryProvider>\n </TamboClientProvider>\n );\n};\ntype TamboContextProps = TamboClientContextProps &\n TamboThreadContextProps &\n TamboComponentContextProps;\n\nexport const TamboContext = createContext<TamboContextProps>(\n {} as TamboContextProps,\n);\n\n/**\n * TamboCompositeProvider is a provider that combines the TamboClient,\n * TamboThread, and TamboComponent providers\n * @param props - The props for the TamboCompositeProvider\n * @param props.children - The children to wrap\n * @returns The wrapped component\n */\nconst TamboCompositeProvider: React.FC<PropsWithChildren> = ({ children }) => {\n const threads = useTamboThread();\n const client = useTamboClient();\n const queryClient = useTamboQueryClient();\n const componentRegistry = useTamboComponent();\n\n return (\n <TamboContext.Provider\n value={{\n client,\n queryClient,\n ...componentRegistry,\n ...threads,\n }}\n >\n {children}\n </TamboContext.Provider>\n );\n};\n\n/**\n * The useTambo hook provides access to the Tambo API. This is the primary entrypoint\n * for the Tambo React SDK.\n *\n * This includes the TamboAI client, the component registry, and the current thread context.\n * @returns The Tambo API\n */\nexport const useTambo = () => {\n return useContext(TamboContext);\n};\n"]}
@@ -10,9 +10,22 @@ export interface TamboRegistryContext {
10
10
  addToolAssociation: (componentName: string, tool: TamboTool) => void;
11
11
  }
12
12
  export interface TamboRegistryProviderProps {
13
- /** The default components to register */
13
+ /** The components to register */
14
14
  components?: TamboComponent[];
15
15
  }
16
+ /**
17
+ * The TamboRegistryProvider is a React provider that provides a component
18
+ * registry to the descendants of the provider.
19
+ * @param props - The props for the TamboRegistryProvider
20
+ * @param props.children - The children to wrap
21
+ * @param props.components - The components to register
22
+ * @returns The TamboRegistryProvider component
23
+ */
16
24
  export declare const TamboRegistryProvider: React.FC<PropsWithChildren<TamboRegistryProviderProps>>;
25
+ /**
26
+ * The useTamboRegistry hook provides access to the component registry
27
+ * to the descendants of the TamboRegistryProvider.
28
+ * @returns The component registry
29
+ */
17
30
  export declare const useTamboRegistry: () => TamboRegistryContext;
18
31
  //# sourceMappingURL=tambo-registry-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-registry-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-registry-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAKlB,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,SAAS,EACV,MAAM,6BAA6B,CAAC;AAErC,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,iBAAiB,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACxC,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACpD,iBAAiB,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,YAAY,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACxC,aAAa,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IAC5C,kBAAkB,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACtE;AAYD,MAAM,WAAW,0BAA0B;IACzC,yCAAyC;IACzC,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;CAC/B;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAC1C,iBAAiB,CAAC,0BAA0B,CAAC,CAqI9C,CAAC;AAEF,eAAO,MAAM,gBAAgB,4BAE5B,CAAC"}
1
+ {"version":3,"file":"tambo-registry-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-registry-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAKlB,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,SAAS,EACV,MAAM,6BAA6B,CAAC;AAErC,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,iBAAiB,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACxC,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACpD,iBAAiB,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,YAAY,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACxC,aAAa,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IAC5C,kBAAkB,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACtE;AAwBD,MAAM,WAAW,0BAA0B;IACzC,iCAAiC;IACjC,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAC1C,iBAAiB,CAAC,0BAA0B,CAAC,CAqI9C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,4BAE5B,CAAC"}
@@ -5,11 +5,31 @@ const TamboRegistryContext = createContext({
5
5
  componentList: {},
6
6
  toolRegistry: {},
7
7
  componentToolAssociations: {},
8
+ /**
9
+ *
10
+ */
8
11
  registerComponent: () => { },
12
+ /**
13
+ *
14
+ */
9
15
  registerTool: () => { },
16
+ /**
17
+ *
18
+ */
10
19
  registerTools: () => { },
20
+ /**
21
+ *
22
+ */
11
23
  addToolAssociation: () => { },
12
24
  });
25
+ /**
26
+ * The TamboRegistryProvider is a React provider that provides a component
27
+ * registry to the descendants of the provider.
28
+ * @param props - The props for the TamboRegistryProvider
29
+ * @param props.children - The children to wrap
30
+ * @param props.components - The components to register
31
+ * @returns The TamboRegistryProvider component
32
+ */
13
33
  export const TamboRegistryProvider = ({ children, components: userComponents }) => {
14
34
  const [componentList, setComponentList] = useState({});
15
35
  const [toolRegistry, setToolRegistry] = useState({});
@@ -99,6 +119,11 @@ export const TamboRegistryProvider = ({ children, components: userComponents })
99
119
  };
100
120
  return (React.createElement(TamboRegistryContext.Provider, { value: value }, children));
101
121
  };
122
+ /**
123
+ * The useTamboRegistry hook provides access to the component registry
124
+ * to the descendants of the TamboRegistryProvider.
125
+ * @returns The component registry
126
+ */
102
127
  export const useTamboRegistry = () => {
103
128
  return useContext(TamboRegistryContext);
104
129
  };
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-registry-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-registry-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,eAAe,MAAM,oBAAoB,CAAC;AAiBjD,MAAM,oBAAoB,GAAG,aAAa,CAAuB;IAC/D,aAAa,EAAE,EAAE;IACjB,YAAY,EAAE,EAAE;IAChB,yBAAyB,EAAE,EAAE;IAC7B,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC3B,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;IACvB,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;CAC7B,CAAC,CAAC;AAOH,MAAM,CAAC,MAAM,qBAAqB,GAE9B,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,EAAE,EAAE;IAC/C,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAoB,EAAE,CAAC,CAAC;IAC1E,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAC9C,EAAE,CACH,CAAC;IACF,MAAM,CAAC,yBAAyB,EAAE,4BAA4B,CAAC,GAAG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AAC,IAAI,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;aACjD,CAAC,CAAC,CAAC;QACN,CAAC;IACH,CAAC,EACD,CAAC,aAAa,CAAC,CAChB,CAAC;IACF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,cAAc,EAAE,CAAC;YACnB,cAAc,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;gBACnC,iBAAiB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,EAAE,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC,CAAC;IAExC,MAAM,KAAK,GAAG;QACZ,aAAa;QACb,YAAY;QACZ,yBAAyB;QACzB,iBAAiB;QACjB,YAAY;QACZ,aAAa;QACb,kBAAkB;KACnB,CAAC;IAEF,OAAO,CACL,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IACxC,QAAQ,CACqB,CACjC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,OAAO,UAAU,CAAC,oBAAoB,CAAC,CAAC;AAC1C,CAAC,CAAC","sourcesContent":["\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport zodToJsonSchema from \"zod-to-json-schema\";\nimport {\n ComponentRegistry,\n TamboComponent,\n TamboTool,\n} from \"../model/component-metadata\";\n\nexport interface TamboRegistryContext {\n componentList: ComponentRegistry;\n toolRegistry: Record<string, TamboTool>;\n componentToolAssociations: Record<string, string[]>;\n registerComponent: (options: TamboComponent) => void;\n registerTool: (tool: TamboTool) => void;\n registerTools: (tools: TamboTool[]) => void;\n addToolAssociation: (componentName: string, tool: TamboTool) => void;\n}\n\nconst TamboRegistryContext = createContext<TamboRegistryContext>({\n componentList: {},\n toolRegistry: {},\n componentToolAssociations: {},\n registerComponent: () => {},\n registerTool: () => {},\n registerTools: () => {},\n addToolAssociation: () => {},\n});\n\nexport interface TamboRegistryProviderProps {\n /** The default components to register */\n components?: TamboComponent[];\n}\n\nexport const TamboRegistryProvider: React.FC<\n PropsWithChildren<TamboRegistryProviderProps>\n> = ({ children, components: userComponents }) => {\n const [componentList, setComponentList] = useState<ComponentRegistry>({});\n const [toolRegistry, setToolRegistry] = useState<Record<string, TamboTool>>(\n {},\n );\n const [componentToolAssociations, setComponentToolAssociations] = useState<\n Record<string, string[]>\n >({});\n\n const registerTool = useCallback(\n (tool: TamboTool, warnOnOverwrite = true) => {\n setToolRegistry((prev) => {\n if (prev[tool.name] && warnOnOverwrite) {\n console.warn(`Overwriting tool ${tool.name}`);\n }\n return {\n ...prev,\n [tool.name]: tool,\n };\n });\n },\n [],\n );\n\n const registerTools = useCallback(\n (tools: TamboTool[], warnOnOverwrite = true) => {\n tools.forEach((tool) => registerTool(tool, warnOnOverwrite));\n },\n [registerTool],\n );\n\n const addToolAssociation = useCallback(\n (componentName: string, tool: TamboTool) => {\n if (!componentList[componentName]) {\n throw new Error(`Component ${componentName} not found in registry`);\n }\n setComponentToolAssociations((prev) => ({\n ...prev,\n [componentName]: [...(prev[componentName] || []), tool.name],\n }));\n },\n [componentList],\n );\n\n const registerComponent = useCallback(\n (options: TamboComponent, warnOnOverwrite = true) => {\n const {\n name,\n description,\n component,\n propsSchema,\n propsDefinition,\n loadingComponent,\n associatedTools,\n } = options;\n\n // Validate that at least one props definition is provided\n if (!propsSchema && !propsDefinition) {\n throw new Error(\n `Component ${name} must have either propsSchema (recommended) or propsDefinition defined`,\n );\n }\n\n // Validate that only one props definition is provided\n if (propsSchema && propsDefinition) {\n throw new Error(\n `Component ${name} cannot have both propsSchema and propsDefinition defined. Use only one. We recommend using propsSchema.`,\n );\n }\n\n // Convert propsSchema to JSON Schema if it exists\n let props = propsDefinition;\n if (propsSchema) {\n try {\n props = zodToJsonSchema(propsSchema);\n } catch (error) {\n console.error(\n `Error converting ${name} props schema to JSON Schema:`,\n error,\n );\n }\n }\n\n setComponentList((prev) => {\n if (prev[name] && warnOnOverwrite) {\n console.warn(`overwriting component ${name}`);\n }\n return {\n ...prev,\n [name]: {\n component,\n loadingComponent,\n name,\n description,\n props,\n contextTools: [],\n },\n };\n });\n if (associatedTools) {\n registerTools(associatedTools);\n setComponentToolAssociations((prev) => ({\n ...prev,\n [name]: associatedTools.map((tool) => tool.name),\n }));\n }\n },\n [registerTools],\n );\n useEffect(() => {\n if (userComponents) {\n userComponents.forEach((component) => {\n registerComponent(component, false);\n });\n }\n }, [registerComponent, userComponents]);\n\n const value = {\n componentList,\n toolRegistry,\n componentToolAssociations,\n registerComponent,\n registerTool,\n registerTools,\n addToolAssociation,\n };\n\n return (\n <TamboRegistryContext.Provider value={value}>\n {children}\n </TamboRegistryContext.Provider>\n );\n};\n\nexport const useTamboRegistry = () => {\n return useContext(TamboRegistryContext);\n};\n"]}
1
+ {"version":3,"file":"tambo-registry-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-registry-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,eAAe,MAAM,oBAAoB,CAAC;AAiBjD,MAAM,oBAAoB,GAAG,aAAa,CAAuB;IAC/D,aAAa,EAAE,EAAE;IACjB,YAAY,EAAE,EAAE;IAChB,yBAAyB,EAAE,EAAE;IAC7B;;OAEG;IACH,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC3B;;OAEG;IACH,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB;;OAEG;IACH,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;IACvB;;OAEG;IACH,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;CAC7B,CAAC,CAAC;AAOH;;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BACL,GAAG,IAAI;gBACP,CAAC,IAAI,CAAC,EAAE;oBACN,SAAS;oBACT,gBAAgB;oBAChB,IAAI;oBACJ,WAAW;oBACX,KAAK;oBACL,YAAY,EAAE,EAAE;iBACjB;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,IAAI,eAAe,EAAE,CAAC;YACpB,aAAa,CAAC,eAAe,CAAC,CAAC;YAC/B,4BAA4B,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACtC,GAAG,IAAI;gBACP,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;aACjD,CAAC,CAAC,CAAC;QACN,CAAC;IACH,CAAC,EACD,CAAC,aAAa,CAAC,CAChB,CAAC;IACF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,cAAc,EAAE,CAAC;YACnB,cAAc,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;gBACnC,iBAAiB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,EAAE,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC,CAAC;IAExC,MAAM,KAAK,GAAG;QACZ,aAAa;QACb,YAAY;QACZ,yBAAyB;QACzB,iBAAiB;QACjB,YAAY;QACZ,aAAa;QACb,kBAAkB;KACnB,CAAC;IAEF,OAAO,CACL,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IACxC,QAAQ,CACqB,CACjC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,OAAO,UAAU,CAAC,oBAAoB,CAAC,CAAC;AAC1C,CAAC,CAAC","sourcesContent":["\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport zodToJsonSchema from \"zod-to-json-schema\";\nimport {\n ComponentRegistry,\n TamboComponent,\n TamboTool,\n} from \"../model/component-metadata\";\n\nexport interface TamboRegistryContext {\n componentList: ComponentRegistry;\n toolRegistry: Record<string, TamboTool>;\n componentToolAssociations: Record<string, string[]>;\n registerComponent: (options: TamboComponent) => void;\n registerTool: (tool: TamboTool) => void;\n registerTools: (tools: TamboTool[]) => void;\n addToolAssociation: (componentName: string, tool: TamboTool) => void;\n}\n\nconst TamboRegistryContext = createContext<TamboRegistryContext>({\n componentList: {},\n toolRegistry: {},\n componentToolAssociations: {},\n /**\n *\n */\n registerComponent: () => {},\n /**\n *\n */\n registerTool: () => {},\n /**\n *\n */\n registerTools: () => {},\n /**\n *\n */\n addToolAssociation: () => {},\n});\n\nexport interface TamboRegistryProviderProps {\n /** The components to register */\n components?: TamboComponent[];\n}\n\n/**\n * The TamboRegistryProvider is a React provider that provides a component\n * registry to the descendants of the provider.\n * @param props - The props for the TamboRegistryProvider\n * @param props.children - The children to wrap\n * @param props.components - The components to register\n * @returns The TamboRegistryProvider component\n */\nexport const TamboRegistryProvider: React.FC<\n PropsWithChildren<TamboRegistryProviderProps>\n> = ({ children, components: userComponents }) => {\n const [componentList, setComponentList] = useState<ComponentRegistry>({});\n const [toolRegistry, setToolRegistry] = useState<Record<string, TamboTool>>(\n {},\n );\n const [componentToolAssociations, setComponentToolAssociations] = useState<\n Record<string, string[]>\n >({});\n\n const registerTool = useCallback(\n (tool: TamboTool, warnOnOverwrite = true) => {\n setToolRegistry((prev) => {\n if (prev[tool.name] && warnOnOverwrite) {\n console.warn(`Overwriting tool ${tool.name}`);\n }\n return {\n ...prev,\n [tool.name]: tool,\n };\n });\n },\n [],\n );\n\n const registerTools = useCallback(\n (tools: TamboTool[], warnOnOverwrite = true) => {\n tools.forEach((tool) => registerTool(tool, warnOnOverwrite));\n },\n [registerTool],\n );\n\n const addToolAssociation = useCallback(\n (componentName: string, tool: TamboTool) => {\n if (!componentList[componentName]) {\n throw new Error(`Component ${componentName} not found in registry`);\n }\n setComponentToolAssociations((prev) => ({\n ...prev,\n [componentName]: [...(prev[componentName] || []), tool.name],\n }));\n },\n [componentList],\n );\n\n const registerComponent = useCallback(\n (options: TamboComponent, warnOnOverwrite = true) => {\n const {\n name,\n description,\n component,\n propsSchema,\n propsDefinition,\n loadingComponent,\n associatedTools,\n } = options;\n\n // Validate that at least one props definition is provided\n if (!propsSchema && !propsDefinition) {\n throw new Error(\n `Component ${name} must have either propsSchema (recommended) or propsDefinition defined`,\n );\n }\n\n // Validate that only one props definition is provided\n if (propsSchema && propsDefinition) {\n throw new Error(\n `Component ${name} cannot have both propsSchema and propsDefinition defined. Use only one. We recommend using propsSchema.`,\n );\n }\n\n // Convert propsSchema to JSON Schema if it exists\n let props = propsDefinition;\n if (propsSchema) {\n try {\n props = zodToJsonSchema(propsSchema);\n } catch (error) {\n console.error(\n `Error converting ${name} props schema to JSON Schema:`,\n error,\n );\n }\n }\n\n setComponentList((prev) => {\n if (prev[name] && warnOnOverwrite) {\n console.warn(`overwriting component ${name}`);\n }\n return {\n ...prev,\n [name]: {\n component,\n loadingComponent,\n name,\n description,\n props,\n contextTools: [],\n },\n };\n });\n if (associatedTools) {\n registerTools(associatedTools);\n setComponentToolAssociations((prev) => ({\n ...prev,\n [name]: associatedTools.map((tool) => tool.name),\n }));\n }\n },\n [registerTools],\n );\n useEffect(() => {\n if (userComponents) {\n userComponents.forEach((component) => {\n registerComponent(component, false);\n });\n }\n }, [registerComponent, userComponents]);\n\n const value = {\n componentList,\n toolRegistry,\n componentToolAssociations,\n registerComponent,\n registerTool,\n registerTools,\n addToolAssociation,\n };\n\n return (\n <TamboRegistryContext.Provider value={value}>\n {children}\n </TamboRegistryContext.Provider>\n );\n};\n\n/**\n * The useTamboRegistry hook provides access to the component registry\n * to the descendants of the TamboRegistryProvider.\n * @returns The component registry\n */\nexport const useTamboRegistry = () => {\n return useContext(TamboRegistryContext);\n};\n"]}
@@ -3,23 +3,35 @@ import React, { PropsWithChildren } from "react";
3
3
  import { GenerationStage, TamboThreadMessage } from "../model/generate-component-response";
4
4
  import { TamboThread } from "../model/tambo-thread";
5
5
  export interface TamboThreadContextProps {
6
+ /** The current thread */
6
7
  thread: TamboThread;
8
+ /** Switch to a different thread */
7
9
  switchCurrentThread: (threadId: string, fetch?: boolean) => void;
10
+ /** Start a new thread */
11
+ startNewThread: () => void;
12
+ /** Add a message to the current thread */
8
13
  addThreadMessage: (message: TamboThreadMessage, sendToServer: boolean) => Promise<TamboAI.Beta.Threads.ThreadMessage[]>;
14
+ /** Update a message in the current thread */
9
15
  updateThreadMessage: (id: string, message: TamboThreadMessage, sendToServer: boolean) => Promise<void>;
10
- setLastThreadStatus: (status: GenerationStage) => void;
16
+ /** The input value of the current thread */
11
17
  inputValue: string;
18
+ /** Set the input value of the current thread */
12
19
  setInputValue: (value: string) => void;
20
+ /** Send a message to the current thread */
13
21
  sendThreadMessage: (message: string, options?: {
14
22
  threadId?: string;
15
23
  streamResponse?: boolean;
16
24
  contextKey?: string;
17
25
  }) => Promise<TamboThreadMessage>;
26
+ /** The generation stage of the current thread - updated as the thread progresses */
18
27
  generationStage: GenerationStage;
28
+ /** The generation status message of the current thread - updated as the thread progresses */
19
29
  generationStatusMessage: string;
30
+ /** Whether the thread is idle */
20
31
  isIdle: boolean;
21
32
  }
22
- /** This is a stub entry for when the thread is not yet created, the first time
33
+ /**
34
+ * This is a stub entry for when the thread is not yet created, the first time
23
35
  * the user sends a message
24
36
  *
25
37
  * Note that the consumer needs to be careful never to send `PLACEHOLDER_THREAD.id` to the server,
@@ -27,6 +39,18 @@ export interface TamboThreadContextProps {
27
39
  */
28
40
  export declare const PLACEHOLDER_THREAD: TamboThread;
29
41
  export declare const TamboThreadContext: React.Context<TamboThreadContextProps>;
42
+ /**
43
+ * The TamboThreadProvider is a React provider that provides a thread context
44
+ * to the descendants of the provider.
45
+ * @param props - The props for the TamboThreadProvider
46
+ * @param props.children - The children to wrap
47
+ * @returns The TamboThreadProvider component
48
+ */
30
49
  export declare const TamboThreadProvider: React.FC<PropsWithChildren>;
50
+ /**
51
+ * The useTamboThread hook provides access to the current thread context
52
+ * to the descendants of the TamboThreadProvider.
53
+ * @returns All state and actions for the current thread
54
+ */
31
55
  export declare const useTamboThread: () => TamboThreadContextProps;
32
56
  //# sourceMappingURL=tambo-thread-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-thread-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-thread-provider.tsx"],"names":[],"mappings":"AACA,OAAO,OAA0B,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AACf,OAAO,EACL,eAAe,EAEf,kBAAkB,EACnB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAOpD,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,WAAW,CAAC;IACpB,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACjE,gBAAgB,EAAE,CAChB,OAAO,EAAE,kBAAkB,EAC3B,YAAY,EAAE,OAAO,KAClB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IACnD,mBAAmB,EAAE,CACnB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,kBAAkB,EAC3B,YAAY,EAAE,OAAO,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,mBAAmB,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,iBAAiB,EAAE,CACjB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE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,kBAAkB,EAC3B,YAAY,EAAE,OAAO,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,2CAA2C;IAC3C,iBAAiB,EAAE,CACjB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,KACE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACjC,oFAAoF;IACpF,eAAe,EAAE,eAAe,CAAC;IACjC,6FAA6F;IAC7F,uBAAuB,EAAE,MAAM,CAAC;IAChC,iCAAiC;IACjC,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAOhC,CAAC;AAEF,eAAO,MAAM,kBAAkB,wCA0C7B,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA4d3D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,+BAM1B,CAAC"}
@@ -7,7 +7,8 @@ import { getAvailableComponents, getClientContext } from "../util/registry";
7
7
  import { handleToolCall } from "../util/tool-caller";
8
8
  import { useTamboClient } from "./tambo-client-provider";
9
9
  import { useTamboRegistry } from "./tambo-registry-provider";
10
- /** This is a stub entry for when the thread is not yet created, the first time
10
+ /**
11
+ * This is a stub entry for when the thread is not yet created, the first time
11
12
  * the user sends a message
12
13
  *
13
14
  * Note that the consumer needs to be careful never to send `PLACEHOLDER_THREAD.id` to the server,
@@ -23,22 +24,40 @@ export const PLACEHOLDER_THREAD = {
23
24
  };
24
25
  export const TamboThreadContext = createContext({
25
26
  thread: PLACEHOLDER_THREAD,
27
+ /**
28
+ *
29
+ */
26
30
  switchCurrentThread: () => {
27
31
  throw new Error("switchCurrentThread not implemented");
28
32
  },
33
+ /**
34
+ *
35
+ */
36
+ startNewThread: () => {
37
+ throw new Error("startNewThread not implemented");
38
+ },
39
+ /**
40
+ *
41
+ */
29
42
  addThreadMessage: () => {
30
43
  throw new Error("updateThreadMessageHistory not implemented");
31
44
  },
32
- setLastThreadStatus: () => {
33
- throw new Error("setLastThreadStatus not implemented");
34
- },
35
45
  inputValue: "",
46
+ /**
47
+ *
48
+ */
36
49
  setInputValue: () => {
37
50
  throw new Error("setInputValue not implemented");
38
51
  },
52
+ /**
53
+ *
54
+ */
39
55
  updateThreadMessage: () => {
40
56
  throw new Error("updateThreadMessage not implemented");
41
57
  },
58
+ /**
59
+ *
60
+ */
42
61
  sendThreadMessage: () => {
43
62
  throw new Error("advance not implemented");
44
63
  },
@@ -46,6 +65,13 @@ export const TamboThreadContext = createContext({
46
65
  generationStatusMessage: "",
47
66
  isIdle: true,
48
67
  });
68
+ /**
69
+ * The TamboThreadProvider is a React provider that provides a thread context
70
+ * to the descendants of the provider.
71
+ * @param props - The props for the TamboThreadProvider
72
+ * @param props.children - The children to wrap
73
+ * @returns The TamboThreadProvider component
74
+ */
49
75
  export const TamboThreadProvider = ({ children, }) => {
50
76
  const [threadMap, setThreadMap] = useState({
51
77
  [PLACEHOLDER_THREAD.id]: PLACEHOLDER_THREAD,
@@ -176,9 +202,18 @@ export const TamboThreadProvider = ({ children, }) => {
176
202
  },
177
203
  }));
178
204
  }, [currentThread]);
205
+ const startNewThread = useCallback(() => {
206
+ setCurrentThreadId(PLACEHOLDER_THREAD.id);
207
+ setThreadMap((prevMap) => {
208
+ return {
209
+ ...prevMap,
210
+ [PLACEHOLDER_THREAD.id]: PLACEHOLDER_THREAD,
211
+ };
212
+ });
213
+ }, []);
179
214
  const switchCurrentThread = useCallback(async (threadId, fetch = true) => {
180
215
  if (threadId === PLACEHOLDER_THREAD.id) {
181
- console.warn("Switching to placeholder thread, may be a bug");
216
+ console.warn("Switching to placeholder thread, may be a bug.");
182
217
  return;
183
218
  }
184
219
  setCurrentThreadId(threadId);
@@ -197,26 +232,6 @@ export const TamboThreadProvider = ({ children, }) => {
197
232
  await fetchThread(threadId);
198
233
  }
199
234
  }, [fetchThread, threadMap]);
200
- const setLastThreadStatus = (status) => {
201
- setThreadMap((prevMap) => {
202
- if (!currentThreadId) {
203
- return prevMap;
204
- }
205
- const headMessages = prevMap[currentThreadId].messages.slice(0, -1);
206
- const lastMessage = prevMap[currentThreadId].messages[prevMap[currentThreadId].messages.length - 1];
207
- const updatedLastMessage = {
208
- ...lastMessage,
209
- status,
210
- };
211
- return {
212
- ...prevMap,
213
- [currentThreadId]: {
214
- ...prevMap[currentThreadId],
215
- messages: [...headMessages, updatedLastMessage],
216
- },
217
- };
218
- });
219
- };
220
235
  const updateThreadStatus = useCallback((stage, statusMessage) => {
221
236
  setThreadMap((prevMap) => {
222
237
  return {
@@ -382,9 +397,9 @@ export const TamboThreadProvider = ({ children, }) => {
382
397
  return (React.createElement(TamboThreadContext.Provider, { value: {
383
398
  thread: currentThread,
384
399
  switchCurrentThread,
400
+ startNewThread,
385
401
  addThreadMessage,
386
402
  updateThreadMessage,
387
- setLastThreadStatus,
388
403
  inputValue,
389
404
  setInputValue,
390
405
  sendThreadMessage,
@@ -395,6 +410,11 @@ export const TamboThreadProvider = ({ children, }) => {
395
410
  GenerationStage.IDLE)),
396
411
  } }, children));
397
412
  };
413
+ /**
414
+ * The useTamboThread hook provides access to the current thread context
415
+ * to the descendants of the TamboThreadProvider.
416
+ * @returns All state and actions for the current thread
417
+ */
398
418
  export const useTamboThread = () => {
399
419
  const context = useContext(TamboThreadContext);
400
420
  if (context === undefined) {