@tambo-ai/react 0.20.2 → 0.20.3

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 (75) hide show
  1. package/dist/hooks/__tests__/use-suggestions.test.js +66 -23
  2. package/dist/hooks/__tests__/use-suggestions.test.js.map +1 -1
  3. package/dist/hooks/__tests__/use-tambo-threads.test.d.ts +2 -0
  4. package/dist/hooks/__tests__/use-tambo-threads.test.d.ts.map +1 -0
  5. package/dist/hooks/__tests__/use-tambo-threads.test.js +212 -0
  6. package/dist/hooks/__tests__/use-tambo-threads.test.js.map +1 -0
  7. package/dist/hooks/react-query-hooks.d.ts +0 -8
  8. package/dist/hooks/react-query-hooks.d.ts.map +1 -1
  9. package/dist/hooks/react-query-hooks.js +0 -11
  10. package/dist/hooks/react-query-hooks.js.map +1 -1
  11. package/dist/hooks/use-suggestions.js +2 -2
  12. package/dist/hooks/use-suggestions.js.map +1 -1
  13. package/dist/hooks/use-tambo-threads.d.ts +13 -11
  14. package/dist/hooks/use-tambo-threads.d.ts.map +1 -1
  15. package/dist/hooks/use-tambo-threads.js +3 -1
  16. package/dist/hooks/use-tambo-threads.js.map +1 -1
  17. package/dist/providers/__tests__/tambo-thread-provider.test.d.ts +2 -0
  18. package/dist/providers/__tests__/tambo-thread-provider.test.d.ts.map +1 -0
  19. package/dist/providers/__tests__/tambo-thread-provider.test.js +279 -0
  20. package/dist/providers/__tests__/tambo-thread-provider.test.js.map +1 -0
  21. package/dist/providers/tambo-provider.d.ts +1 -2
  22. package/dist/providers/tambo-provider.d.ts.map +1 -1
  23. package/dist/providers/tambo-provider.js.map +1 -1
  24. package/dist/providers/tambo-registry-provider.js +1 -4
  25. package/dist/providers/tambo-registry-provider.js.map +1 -1
  26. package/dist/setupTests.d.ts +3 -0
  27. package/dist/setupTests.d.ts.map +1 -0
  28. package/dist/setupTests.js +8 -0
  29. package/dist/setupTests.js.map +1 -0
  30. package/dist/testing/tools.d.ts +24 -0
  31. package/dist/testing/tools.d.ts.map +1 -0
  32. package/dist/testing/tools.js +31 -0
  33. package/dist/testing/tools.js.map +1 -0
  34. package/dist/testing/types.d.ts +4 -0
  35. package/dist/testing/types.d.ts.map +1 -0
  36. package/dist/testing/types.js +3 -0
  37. package/dist/testing/types.js.map +1 -0
  38. package/esm/hooks/__tests__/use-suggestions.test.js +69 -26
  39. package/esm/hooks/__tests__/use-suggestions.test.js.map +1 -1
  40. package/esm/hooks/__tests__/use-tambo-threads.test.d.ts +2 -0
  41. package/esm/hooks/__tests__/use-tambo-threads.test.d.ts.map +1 -0
  42. package/esm/hooks/__tests__/use-tambo-threads.test.js +210 -0
  43. package/esm/hooks/__tests__/use-tambo-threads.test.js.map +1 -0
  44. package/esm/hooks/react-query-hooks.d.ts +0 -8
  45. package/esm/hooks/react-query-hooks.d.ts.map +1 -1
  46. package/esm/hooks/react-query-hooks.js +0 -10
  47. package/esm/hooks/react-query-hooks.js.map +1 -1
  48. package/esm/hooks/use-suggestions.js +3 -3
  49. package/esm/hooks/use-suggestions.js.map +1 -1
  50. package/esm/hooks/use-tambo-threads.d.ts +13 -11
  51. package/esm/hooks/use-tambo-threads.d.ts.map +1 -1
  52. package/esm/hooks/use-tambo-threads.js +3 -1
  53. package/esm/hooks/use-tambo-threads.js.map +1 -1
  54. package/esm/providers/__tests__/tambo-thread-provider.test.d.ts +2 -0
  55. package/esm/providers/__tests__/tambo-thread-provider.test.d.ts.map +1 -0
  56. package/esm/providers/__tests__/tambo-thread-provider.test.js +274 -0
  57. package/esm/providers/__tests__/tambo-thread-provider.test.js.map +1 -0
  58. package/esm/providers/tambo-provider.d.ts +1 -2
  59. package/esm/providers/tambo-provider.d.ts.map +1 -1
  60. package/esm/providers/tambo-provider.js.map +1 -1
  61. package/esm/providers/tambo-registry-provider.js +1 -4
  62. package/esm/providers/tambo-registry-provider.js.map +1 -1
  63. package/esm/setupTests.d.ts +3 -0
  64. package/esm/setupTests.d.ts.map +1 -0
  65. package/esm/setupTests.js +6 -0
  66. package/esm/setupTests.js.map +1 -0
  67. package/esm/testing/tools.d.ts +24 -0
  68. package/esm/testing/tools.d.ts.map +1 -0
  69. package/esm/testing/tools.js +25 -0
  70. package/esm/testing/tools.js.map +1 -0
  71. package/esm/testing/types.d.ts +4 -0
  72. package/esm/testing/types.d.ts.map +1 -0
  73. package/esm/testing/types.js +2 -0
  74. package/esm/testing/types.js.map +1 -0
  75. package/package.json +8 -6
@@ -1,3 +1,5 @@
1
+ import type TamboAI from "@tambo-ai/typescript-sdk";
2
+ import { UseQueryOptions } from "@tanstack/react-query";
1
3
  interface UseTamboThreadListConfig {
2
4
  /**
3
5
  * The projectId to get the threads for. If not provided, the current project
@@ -33,7 +35,7 @@ interface UseTamboThreadListConfig {
33
35
  * @param config.contextKey - The context key to get the threads for
34
36
  * @returns The threads for the specified project and optional context key
35
37
  */
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> | {
38
+ export declare function useTamboThreadList({ projectId, contextKey }?: UseTamboThreadListConfig, options?: Partial<UseQueryOptions<TamboAI.Beta.Threads.ThreadsOffsetAndLimit | null>>): import("@tanstack/react-query").QueryObserverRefetchErrorResult<TamboAI.Beta.Threads.ThreadsOffsetAndLimit | null, Error> | import("@tanstack/react-query").QueryObserverSuccessResult<TamboAI.Beta.Threads.ThreadsOffsetAndLimit | null, Error> | import("@tanstack/react-query").QueryObserverLoadingErrorResult<TamboAI.Beta.Threads.ThreadsOffsetAndLimit | null, Error> | import("@tanstack/react-query").QueryObserverPendingResult<TamboAI.Beta.Threads.ThreadsOffsetAndLimit | null, Error> | import("@tanstack/react-query").QueryObserverPlaceholderResult<TamboAI.Beta.Threads.ThreadsOffsetAndLimit | null, Error> | {
37
39
  error: Error;
38
40
  isError: true;
39
41
  isPending: false;
@@ -55,8 +57,8 @@ export declare function useTamboThreadList({ projectId, contextKey, }?: UseTambo
55
57
  isPaused: boolean;
56
58
  isRefetching: boolean;
57
59
  isStale: boolean;
58
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<string, Error>>;
59
- fetchStatus: import("@tanstack/query-core").FetchStatus;
60
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<string, Error>>;
61
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
60
62
  promise: Promise<string>;
61
63
  data: null;
62
64
  } | {
@@ -81,8 +83,8 @@ export declare function useTamboThreadList({ projectId, contextKey, }?: UseTambo
81
83
  isPaused: boolean;
82
84
  isRefetching: boolean;
83
85
  isStale: boolean;
84
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<string, Error>>;
85
- fetchStatus: import("@tanstack/query-core").FetchStatus;
86
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<string, Error>>;
87
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
86
88
  promise: Promise<string>;
87
89
  data: null;
88
90
  } | {
@@ -107,8 +109,8 @@ export declare function useTamboThreadList({ projectId, contextKey, }?: UseTambo
107
109
  isPaused: boolean;
108
110
  isRefetching: boolean;
109
111
  isStale: boolean;
110
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<string, Error>>;
111
- fetchStatus: import("@tanstack/query-core").FetchStatus;
112
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<string, Error>>;
113
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
112
114
  promise: Promise<string>;
113
115
  data: null;
114
116
  } | {
@@ -133,8 +135,8 @@ export declare function useTamboThreadList({ projectId, contextKey, }?: UseTambo
133
135
  isPaused: boolean;
134
136
  isRefetching: boolean;
135
137
  isStale: boolean;
136
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<string, Error>>;
137
- fetchStatus: import("@tanstack/query-core").FetchStatus;
138
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<string, Error>>;
139
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
138
140
  promise: Promise<string>;
139
141
  data: null;
140
142
  } | {
@@ -159,8 +161,8 @@ export declare function useTamboThreadList({ projectId, contextKey, }?: UseTambo
159
161
  isPaused: boolean;
160
162
  isRefetching: boolean;
161
163
  isStale: boolean;
162
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<string, Error>>;
163
- fetchStatus: import("@tanstack/query-core").FetchStatus;
164
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<string, Error>>;
165
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
164
166
  promise: Promise<string>;
165
167
  data: null;
166
168
  };
@@ -1 +1 @@
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
+ {"version":3,"file":"use-tambo-threads.d.ts","sourceRoot":"","sources":["../../src/hooks/use-tambo-threads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,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,CAChC,EAAE,SAAS,EAAE,UAAU,EAAE,GAAE,wBAA6B,EACxD,OAAO,GAAE,OAAO,CACd,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAC9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BP"}
@@ -14,9 +14,10 @@ const react_query_hooks_1 = require("./react-query-hooks");
14
14
  * @param config.contextKey - The context key to get the threads for
15
15
  * @returns The threads for the specified project and optional context key
16
16
  */
17
- function useTamboThreadList({ projectId, contextKey, } = {}) {
17
+ function useTamboThreadList({ projectId, contextKey } = {}, options = {}) {
18
18
  const client = (0, tambo_client_provider_1.useTamboClient)();
19
19
  const { data: queriedProjectId, ...projectIdState } = (0, react_query_hooks_1.useTamboQuery)({
20
+ ...options,
20
21
  queryKey: ["projectId"],
21
22
  queryFn: async () => {
22
23
  return (await client.beta.projects.getCurrent()).id;
@@ -24,6 +25,7 @@ function useTamboThreadList({ projectId, contextKey, } = {}) {
24
25
  });
25
26
  const currentProjectId = projectId ?? queriedProjectId;
26
27
  const threadState = (0, react_query_hooks_1.useTamboQuery)({
28
+ ...options,
27
29
  enabled: !!currentProjectId,
28
30
  queryKey: ["threads", currentProjectId, contextKey],
29
31
  queryFn: async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"use-tambo-threads.js","sourceRoot":"","sources":["../../src/hooks/use-tambo-threads.ts"],"names":[],"mappings":";;AAwCA,gDA4BC;AApED,8EAAoE;AACpE,2DAAoD;AA4BpD;;;;;;;;;;GAUG;AACH,SAAgB,kBAAkB,CAAC,EACjC,SAAS,EACT,UAAU,MACkB,EAAE;IAC9B,MAAM,MAAM,GAAG,IAAA,sCAAc,GAAE,CAAC;IAChC,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,GAAG,IAAA,iCAAa,EAAC;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,IAAA,iCAAa,EAAC;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"]}
1
+ {"version":3,"file":"use-tambo-threads.js","sourceRoot":"","sources":["../../src/hooks/use-tambo-threads.ts"],"names":[],"mappings":";;AA0CA,gDAgCC;AAxED,8EAAoE;AACpE,2DAAoD;AA4BpD;;;;;;;;;;GAUG;AACH,SAAgB,kBAAkB,CAChC,EAAE,SAAS,EAAE,UAAU,KAA+B,EAAE,EACxD,UAEI,EAAE;IAEN,MAAM,MAAM,GAAG,IAAA,sCAAc,GAAE,CAAC;IAChC,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,GAAG,IAAA,iCAAa,EAAC;QAClE,GAAI,OAA8C;QAClD,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,IAAA,iCAAa,EAAC;QAChC,GAAG,OAAO;QACV,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 type TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { UseQueryOptions } from \"@tanstack/react-query\";\nimport { 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, contextKey }: UseTamboThreadListConfig = {},\n options: Partial<\n UseQueryOptions<TamboAI.Beta.Threads.ThreadsOffsetAndLimit | null>\n > = {},\n) {\n const client = useTamboClient();\n const { data: queriedProjectId, ...projectIdState } = useTamboQuery({\n ...(options as unknown as UseQueryOptions<string>),\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 ...options,\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"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tambo-thread-provider.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tambo-thread-provider.test.d.ts","sourceRoot":"","sources":["../../../src/providers/__tests__/tambo-thread-provider.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const typescript_sdk_1 = require("@tambo-ai/typescript-sdk");
7
+ const react_1 = require("@testing-library/react");
8
+ const react_2 = __importDefault(require("react"));
9
+ const zod_1 = require("zod");
10
+ const generate_component_response_1 = require("../../model/generate-component-response");
11
+ const tools_1 = require("../../testing/tools");
12
+ const tambo_client_provider_1 = require("../tambo-client-provider");
13
+ const tambo_registry_provider_1 = require("../tambo-registry-provider");
14
+ const tambo_thread_provider_1 = require("../tambo-thread-provider");
15
+ // Mock crypto.randomUUID
16
+ Object.defineProperty(global, "crypto", {
17
+ value: {
18
+ randomUUID: jest.fn().mockReturnValue("test-uuid"),
19
+ },
20
+ });
21
+ // Mock the required providers
22
+ jest.mock("../tambo-client-provider", () => ({
23
+ useTamboClient: jest.fn(),
24
+ }));
25
+ jest.mock("@tambo-ai/typescript-sdk", () => ({
26
+ advanceStream: jest.fn(),
27
+ }));
28
+ // Test utilities
29
+ const createMockMessage = (overrides = {}) => ({
30
+ id: "test-message-1",
31
+ content: [{ type: "text", text: "Hello" }],
32
+ role: "user",
33
+ threadId: "test-thread-1",
34
+ createdAt: new Date().toISOString(),
35
+ componentState: {},
36
+ ...overrides,
37
+ });
38
+ const createMockThread = (overrides = {}) => ({
39
+ id: "test-thread-1",
40
+ messages: [],
41
+ createdAt: "2024-01-01T00:00:00Z",
42
+ projectId: "test-project",
43
+ updatedAt: "2024-01-01T00:00:00Z",
44
+ metadata: {},
45
+ ...overrides,
46
+ });
47
+ const createMockAdvanceResponse = (overrides = {}) => ({
48
+ responseMessageDto: {
49
+ id: "test-uuid",
50
+ content: [{ type: "text", text: "Default response" }],
51
+ role: "assistant",
52
+ threadId: "test-thread-1",
53
+ component: undefined,
54
+ componentState: {},
55
+ createdAt: new Date().toISOString(),
56
+ },
57
+ generationStage: generate_component_response_1.GenerationStage.COMPLETE,
58
+ ...overrides,
59
+ });
60
+ describe("TamboThreadProvider", () => {
61
+ const mockThread = createMockThread();
62
+ const mockThreadsApi = {
63
+ messages: {
64
+ create: jest.fn(),
65
+ },
66
+ retrieve: jest.fn(),
67
+ advanceById: jest.fn(),
68
+ };
69
+ const mockBeta = {
70
+ threads: mockThreadsApi,
71
+ };
72
+ const mockTamboAI = {
73
+ apiKey: "",
74
+ components: {},
75
+ beta: mockBeta,
76
+ };
77
+ const mockRegistry = [
78
+ {
79
+ name: "TestOnly",
80
+ component: () => react_2.default.createElement("div", null, "TestOnly"),
81
+ description: "TestOnly",
82
+ propsSchema: zod_1.z.object({
83
+ test: zod_1.z.string(),
84
+ }),
85
+ associatedTools: [
86
+ {
87
+ name: "test-tool",
88
+ tool: jest.fn().mockResolvedValue("test-tool"),
89
+ description: "test-tool",
90
+ toolSchema: zod_1.z
91
+ .function()
92
+ .args(zod_1.z.string().describe("test-param-description"))
93
+ .returns(zod_1.z.string()),
94
+ },
95
+ ],
96
+ },
97
+ ];
98
+ const wrapper = ({ children }) => (react_2.default.createElement(tambo_registry_provider_1.TamboRegistryProvider, { components: mockRegistry },
99
+ react_2.default.createElement(tambo_thread_provider_1.TamboThreadProvider, null, children)));
100
+ beforeEach(() => {
101
+ jest.mocked(mockThreadsApi.retrieve).mockResolvedValue(mockThread);
102
+ jest
103
+ .mocked(mockThreadsApi.messages.create)
104
+ .mockResolvedValue(createMockMessage());
105
+ jest
106
+ .mocked(mockThreadsApi.advanceById)
107
+ .mockResolvedValue(createMockAdvanceResponse());
108
+ jest.mocked(tambo_client_provider_1.useTamboClient).mockReturnValue(mockTamboAI);
109
+ });
110
+ it("should initialize with placeholder thread", () => {
111
+ const { result } = (0, react_1.renderHook)(() => (0, tambo_thread_provider_1.useTamboThread)(), { wrapper });
112
+ expect(result.current.thread.id).toBe("placeholder");
113
+ expect(result.current.isIdle).toBe(true);
114
+ expect(result.current.generationStage).toBe(generate_component_response_1.GenerationStage.IDLE);
115
+ });
116
+ it("should switch to a new thread", async () => {
117
+ const { result } = (0, react_1.renderHook)(() => (0, tambo_thread_provider_1.useTamboThread)(), { wrapper });
118
+ await (0, react_1.act)(async () => {
119
+ await result.current.switchCurrentThread("test-thread-1");
120
+ });
121
+ expect(mockThreadsApi.retrieve).toHaveBeenCalledWith("test-thread-1");
122
+ expect(result.current.thread.id).toBe("test-thread-1");
123
+ });
124
+ it("should start a new thread", async () => {
125
+ const { result } = (0, react_1.renderHook)(() => (0, tambo_thread_provider_1.useTamboThread)(), { wrapper });
126
+ await (0, react_1.act)(async () => {
127
+ result.current.startNewThread();
128
+ });
129
+ expect(result.current.thread.id).toBe("placeholder");
130
+ expect(result.current.isIdle).toBe(true);
131
+ });
132
+ it("should add a message to the thread", async () => {
133
+ const { result } = (0, react_1.renderHook)(() => (0, tambo_thread_provider_1.useTamboThread)(), { wrapper });
134
+ const testMessage = {
135
+ id: "test-message-1",
136
+ content: [{ type: "text", text: "Hello" }],
137
+ role: "user",
138
+ threadId: "test-thread-1",
139
+ createdAt: new Date().toISOString(),
140
+ componentState: {},
141
+ };
142
+ await (0, react_1.act)(async () => {
143
+ await result.current.addThreadMessage(testMessage, true);
144
+ });
145
+ expect(mockThreadsApi.messages.create).toHaveBeenCalledWith("test-thread-1", {
146
+ content: testMessage.content,
147
+ role: testMessage.role,
148
+ });
149
+ });
150
+ it("should update a message in the thread", async () => {
151
+ const { result } = (0, react_1.renderHook)(() => (0, tambo_thread_provider_1.useTamboThread)(), { wrapper });
152
+ const testMessage = {
153
+ id: "test-message-1",
154
+ content: [{ type: "text", text: "Updated message" }],
155
+ role: "user",
156
+ threadId: "test-thread-1",
157
+ createdAt: new Date().toISOString(),
158
+ componentState: {},
159
+ };
160
+ await (0, react_1.act)(async () => {
161
+ await result.current.updateThreadMessage("test-message-1", testMessage, true);
162
+ });
163
+ expect(mockThreadsApi.messages.create).toHaveBeenCalledWith("test-thread-1", {
164
+ content: testMessage.content,
165
+ role: testMessage.role,
166
+ });
167
+ });
168
+ it("should send a message and update thread state", async () => {
169
+ const mockAdvanceResponse = {
170
+ responseMessageDto: {
171
+ id: "response-1",
172
+ content: [{ type: "text", text: "Response" }],
173
+ role: "assistant",
174
+ threadId: "test-thread-1",
175
+ component: undefined,
176
+ componentState: {},
177
+ createdAt: new Date().toISOString(),
178
+ },
179
+ generationStage: generate_component_response_1.GenerationStage.COMPLETE,
180
+ };
181
+ jest
182
+ .mocked(mockThreadsApi.advanceById)
183
+ .mockResolvedValue(mockAdvanceResponse);
184
+ const { result } = (0, react_1.renderHook)(() => (0, tambo_thread_provider_1.useTamboThread)(), { wrapper });
185
+ await (0, react_1.act)(async () => {
186
+ await result.current.sendThreadMessage("Hello", {
187
+ threadId: "test-thread-1",
188
+ streamResponse: false,
189
+ });
190
+ });
191
+ expect(mockThreadsApi.advanceById).toHaveBeenCalledWith("test-thread-1", {
192
+ messageToAppend: {
193
+ content: [{ type: "text", text: "Hello" }],
194
+ role: "user",
195
+ },
196
+ availableComponents: (0, tools_1.serializeRegistry)(mockRegistry),
197
+ contextKey: undefined,
198
+ });
199
+ expect(result.current.generationStage).toBe(generate_component_response_1.GenerationStage.COMPLETE);
200
+ });
201
+ it("should handle input value changes", () => {
202
+ const { result } = (0, react_1.renderHook)(() => (0, tambo_thread_provider_1.useTamboThread)(), { wrapper });
203
+ (0, react_1.act)(() => {
204
+ result.current.setInputValue("New input");
205
+ });
206
+ expect(result.current.inputValue).toBe("New input");
207
+ });
208
+ it("should handle streaming responses", async () => {
209
+ const mockStreamResponse = {
210
+ responseMessageDto: {
211
+ id: "stream-1",
212
+ content: [{ type: "text", text: "Streaming response" }],
213
+ role: "assistant",
214
+ threadId: "test-thread-1",
215
+ component: undefined,
216
+ componentState: {},
217
+ createdAt: new Date().toISOString(),
218
+ },
219
+ generationStage: generate_component_response_1.GenerationStage.COMPLETE,
220
+ };
221
+ // Create an async iterator mock
222
+ const mockAsyncIterator = {
223
+ [Symbol.asyncIterator]: async function* () {
224
+ yield mockStreamResponse;
225
+ },
226
+ };
227
+ // Mock advanceStream to return our async iterator
228
+ jest.mocked(typescript_sdk_1.advanceStream).mockResolvedValue(mockAsyncIterator);
229
+ const { result } = (0, react_1.renderHook)(() => (0, tambo_thread_provider_1.useTamboThread)(), { wrapper });
230
+ await (0, react_1.act)(async () => {
231
+ await result.current.sendThreadMessage("Hello", {
232
+ threadId: "test-thread-1",
233
+ streamResponse: true,
234
+ });
235
+ });
236
+ expect(result.current.generationStage).toBe(generate_component_response_1.GenerationStage.IDLE);
237
+ });
238
+ it("should handle tool calls during message processing", async () => {
239
+ const mockToolCallResponse = {
240
+ responseMessageDto: {
241
+ id: "tool-call-1",
242
+ content: [{ type: "text", text: "Tool response" }],
243
+ role: "tool",
244
+ threadId: "test-thread-1",
245
+ toolCallRequest: {
246
+ toolName: "test-tool",
247
+ parameters: [{ parameterName: "test", parameterValue: "test" }],
248
+ },
249
+ componentState: {},
250
+ createdAt: new Date().toISOString(),
251
+ },
252
+ generationStage: generate_component_response_1.GenerationStage.COMPLETE,
253
+ };
254
+ jest
255
+ .mocked(mockThreadsApi.advanceById)
256
+ .mockResolvedValueOnce(mockToolCallResponse)
257
+ .mockResolvedValueOnce({
258
+ responseMessageDto: {
259
+ id: "advance-response2",
260
+ content: [{ type: "text", text: "response 2" }],
261
+ role: "user",
262
+ threadId: "test-thread-1",
263
+ componentState: {},
264
+ createdAt: new Date().toISOString(),
265
+ },
266
+ generationStage: generate_component_response_1.GenerationStage.COMPLETE,
267
+ });
268
+ const { result } = (0, react_1.renderHook)(() => (0, tambo_thread_provider_1.useTamboThread)(), { wrapper });
269
+ await (0, react_1.act)(async () => {
270
+ await result.current.sendThreadMessage("Use tool", {
271
+ threadId: "test-thread-1",
272
+ streamResponse: false,
273
+ });
274
+ });
275
+ expect(result.current.generationStage).toBe(generate_component_response_1.GenerationStage.COMPLETE);
276
+ expect(mockRegistry[0]?.associatedTools?.[0]?.tool).toHaveBeenCalledWith("test");
277
+ });
278
+ });
279
+ //# sourceMappingURL=tambo-thread-provider.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tambo-thread-provider.test.js","sourceRoot":"","sources":["../../../src/providers/__tests__/tambo-thread-provider.test.tsx"],"names":[],"mappings":";;;;;AAAA,6DAAkE;AAClE,kDAAyD;AACzD,kDAA0B;AAE1B,6BAAwB;AAExB,yFAGiD;AACjD,+CAAwD;AACxD,oEAA0D;AAC1D,wEAAmE;AACnE,oEAA+E;AAI/E,yBAAyB;AACzB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE;IACtC,KAAK,EAAE;QACL,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,WAAW,CAAC;KACnD;CACF,CAAC,CAAC;AAEH,8BAA8B;AAC9B,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE,CAAC,CAAC;IAC3C,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;CAC1B,CAAC,CAAC,CAAC;AACJ,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE,CAAC,CAAC;IAC3C,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE;CACzB,CAAC,CAAC,CAAC;AAEJ,iBAAiB;AACjB,MAAM,iBAAiB,GAAG,CACxB,YAAyC,EAAE,EACvB,EAAE,CAAC,CAAC;IACxB,EAAE,EAAE,gBAAgB;IACpB,OAAO,EAAE,CAA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,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,6CAAe,CAAC,QAAQ,CAAC,CAAC;QACtE,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,oBAAoB,CACtE,MAAM,CACP,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import TamboAI, { advanceStream } from \"@tambo-ai/typescript-sdk\";\nimport { act, renderHook } from \"@testing-library/react\";\nimport React from \"react\";\nimport { DeepPartial } from \"ts-essentials\";\nimport { z } from \"zod\";\nimport { TamboComponent } from \"../../model/component-metadata\";\nimport {\n GenerationStage,\n TamboThreadMessage,\n} from \"../../model/generate-component-response\";\nimport { serializeRegistry } from \"../../testing/tools\";\nimport { useTamboClient } from \"../tambo-client-provider\";\nimport { TamboRegistryProvider } from \"../tambo-registry-provider\";\nimport { TamboThreadProvider, useTamboThread } from \"../tambo-thread-provider\";\n\ntype PartialTamboAI = DeepPartial<TamboAI>;\n\n// Mock crypto.randomUUID\nObject.defineProperty(global, \"crypto\", {\n value: {\n randomUUID: jest.fn().mockReturnValue(\"test-uuid\"),\n },\n});\n\n// Mock the required providers\njest.mock(\"../tambo-client-provider\", () => ({\n useTamboClient: jest.fn(),\n}));\njest.mock(\"@tambo-ai/typescript-sdk\", () => ({\n advanceStream: jest.fn(),\n}));\n\n// Test utilities\nconst createMockMessage = (\n overrides: Partial<TamboThreadMessage> = {},\n): TamboThreadMessage => ({\n id: \"test-message-1\",\n content: [{ type: \"text\", text: \"Hello\" }],\n role: \"user\",\n threadId: \"test-thread-1\",\n createdAt: new Date().toISOString(),\n componentState: {},\n ...overrides,\n});\n\nconst createMockThread = (\n overrides: Partial<TamboAI.Beta.Threads.Thread> = {},\n) => ({\n id: \"test-thread-1\",\n messages: [],\n createdAt: \"2024-01-01T00:00:00Z\",\n projectId: \"test-project\",\n updatedAt: \"2024-01-01T00:00:00Z\",\n metadata: {},\n ...overrides,\n});\n\nconst createMockAdvanceResponse = (\n overrides: Partial<TamboAI.Beta.Threads.ThreadAdvanceResponse> = {},\n): TamboAI.Beta.Threads.ThreadAdvanceResponse => ({\n responseMessageDto: {\n id: \"test-uuid\",\n content: [{ type: \"text\" as const, text: \"Default response\" }],\n role: \"assistant\",\n threadId: \"test-thread-1\",\n component: undefined,\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n ...overrides,\n});\n\ndescribe(\"TamboThreadProvider\", () => {\n const mockThread = createMockThread();\n\n const mockThreadsApi = {\n messages: {\n create: jest.fn(),\n },\n retrieve: jest.fn(),\n advanceById: jest.fn(),\n } satisfies DeepPartial<\n TamboAI[\"beta\"][\"threads\"]\n > as unknown as TamboAI.Beta.Threads;\n\n const mockBeta = {\n threads: mockThreadsApi,\n } satisfies PartialTamboAI[\"beta\"];\n\n const mockTamboAI = {\n apiKey: \"\",\n components: {},\n beta: mockBeta,\n } satisfies PartialTamboAI as unknown as TamboAI;\n\n const mockRegistry: TamboComponent[] = [\n {\n name: \"TestOnly\",\n component: () => <div>TestOnly</div>,\n description: \"TestOnly\",\n propsSchema: z.object({\n test: z.string(),\n }),\n associatedTools: [\n {\n name: \"test-tool\",\n tool: jest.fn().mockResolvedValue(\"test-tool\"),\n description: \"test-tool\",\n toolSchema: z\n .function()\n .args(z.string().describe(\"test-param-description\"))\n .returns(z.string()),\n },\n ],\n },\n ];\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider components={mockRegistry}>\n <TamboThreadProvider>{children}</TamboThreadProvider>\n </TamboRegistryProvider>\n );\n\n beforeEach(() => {\n jest.mocked(mockThreadsApi.retrieve).mockResolvedValue(mockThread);\n jest\n .mocked(mockThreadsApi.messages.create)\n .mockResolvedValue(createMockMessage());\n jest\n .mocked(mockThreadsApi.advanceById)\n .mockResolvedValue(createMockAdvanceResponse());\n jest.mocked(useTamboClient).mockReturnValue(mockTamboAI);\n });\n\n it(\"should initialize with placeholder thread\", () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n expect(result.current.thread.id).toBe(\"placeholder\");\n expect(result.current.isIdle).toBe(true);\n expect(result.current.generationStage).toBe(GenerationStage.IDLE);\n });\n\n it(\"should switch to a new thread\", async () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n await act(async () => {\n await result.current.switchCurrentThread(\"test-thread-1\");\n });\n\n expect(mockThreadsApi.retrieve).toHaveBeenCalledWith(\"test-thread-1\");\n expect(result.current.thread.id).toBe(\"test-thread-1\");\n });\n\n it(\"should start a new thread\", async () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n await act(async () => {\n result.current.startNewThread();\n });\n\n expect(result.current.thread.id).toBe(\"placeholder\");\n expect(result.current.isIdle).toBe(true);\n });\n\n it(\"should add a message to the thread\", async () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n const testMessage: TamboThreadMessage = {\n id: \"test-message-1\",\n content: [{ type: \"text\", text: \"Hello\" }],\n role: \"user\",\n threadId: \"test-thread-1\",\n createdAt: new Date().toISOString(),\n componentState: {},\n };\n\n await act(async () => {\n await result.current.addThreadMessage(testMessage, true);\n });\n\n expect(mockThreadsApi.messages.create).toHaveBeenCalledWith(\n \"test-thread-1\",\n {\n content: testMessage.content,\n role: testMessage.role,\n },\n );\n });\n\n it(\"should update a message in the thread\", async () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n const testMessage: TamboThreadMessage = {\n id: \"test-message-1\",\n content: [{ type: \"text\", text: \"Updated message\" }],\n role: \"user\",\n threadId: \"test-thread-1\",\n createdAt: new Date().toISOString(),\n componentState: {},\n };\n\n await act(async () => {\n await result.current.updateThreadMessage(\n \"test-message-1\",\n testMessage,\n true,\n );\n });\n\n expect(mockThreadsApi.messages.create).toHaveBeenCalledWith(\n \"test-thread-1\",\n {\n content: testMessage.content,\n role: testMessage.role,\n },\n );\n });\n\n it(\"should send a message and update thread state\", async () => {\n const mockAdvanceResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse = {\n responseMessageDto: {\n id: \"response-1\",\n content: [{ type: \"text\", text: \"Response\" }],\n role: \"assistant\",\n threadId: \"test-thread-1\",\n component: undefined,\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n };\n\n jest\n .mocked(mockThreadsApi.advanceById)\n .mockResolvedValue(mockAdvanceResponse);\n\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello\", {\n threadId: \"test-thread-1\",\n streamResponse: false,\n });\n });\n\n expect(mockThreadsApi.advanceById).toHaveBeenCalledWith(\"test-thread-1\", {\n messageToAppend: {\n content: [{ type: \"text\", text: \"Hello\" }],\n role: \"user\",\n },\n availableComponents: serializeRegistry(mockRegistry),\n contextKey: undefined,\n });\n expect(result.current.generationStage).toBe(GenerationStage.COMPLETE);\n });\n\n it(\"should handle input value changes\", () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n act(() => {\n result.current.setInputValue(\"New input\");\n });\n\n expect(result.current.inputValue).toBe(\"New input\");\n });\n\n it(\"should handle streaming responses\", async () => {\n const mockStreamResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse = {\n responseMessageDto: {\n id: \"stream-1\",\n content: [{ type: \"text\", text: \"Streaming response\" }],\n role: \"assistant\",\n threadId: \"test-thread-1\",\n component: undefined,\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n };\n\n // Create an async iterator mock\n const mockAsyncIterator = {\n [Symbol.asyncIterator]: async function* () {\n yield mockStreamResponse;\n },\n };\n\n // Mock advanceStream to return our async iterator\n jest.mocked(advanceStream).mockResolvedValue(mockAsyncIterator);\n\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello\", {\n threadId: \"test-thread-1\",\n streamResponse: true,\n });\n });\n\n expect(result.current.generationStage).toBe(GenerationStage.IDLE);\n });\n\n it(\"should handle tool calls during message processing\", async () => {\n const mockToolCallResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse = {\n responseMessageDto: {\n id: \"tool-call-1\",\n content: [{ type: \"text\", text: \"Tool response\" }],\n role: \"tool\",\n threadId: \"test-thread-1\",\n toolCallRequest: {\n toolName: \"test-tool\",\n parameters: [{ parameterName: \"test\", parameterValue: \"test\" }],\n },\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n };\n\n jest\n .mocked(mockThreadsApi.advanceById)\n .mockResolvedValueOnce(mockToolCallResponse)\n .mockResolvedValueOnce({\n responseMessageDto: {\n id: \"advance-response2\",\n content: [{ type: \"text\", text: \"response 2\" }],\n role: \"user\",\n threadId: \"test-thread-1\",\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n });\n\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Use tool\", {\n threadId: \"test-thread-1\",\n streamResponse: false,\n });\n });\n expect(result.current.generationStage).toBe(GenerationStage.COMPLETE);\n expect(mockRegistry[0]?.associatedTools?.[0]?.tool).toHaveBeenCalledWith(\n \"test\",\n );\n });\n});\n"]}
@@ -15,7 +15,7 @@ import { TamboThreadContextProps } from "./tambo-thread-provider";
15
15
  * @returns The TamboProvider component
16
16
  */
17
17
  export declare const TamboProvider: React.FC<PropsWithChildren<TamboClientProviderProps & TamboRegistryProviderProps>>;
18
- type TamboContextProps = TamboClientContextProps & TamboThreadContextProps & TamboComponentContextProps;
18
+ export type TamboContextProps = TamboClientContextProps & TamboThreadContextProps & TamboComponentContextProps;
19
19
  export declare const TamboContext: React.Context<TamboContextProps>;
20
20
  /**
21
21
  * The useTambo hook provides access to the Tambo API. This is the primary entrypoint
@@ -25,5 +25,4 @@ export declare const TamboContext: React.Context<TamboContextProps>;
25
25
  * @returns The Tambo API
26
26
  */
27
27
  export declare const useTambo: () => TamboContextProps;
28
- export {};
29
28
  //# 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,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAA6B,MAAM,OAAO,CAAC;AAC5E,OAAO,EACL,uBAAuB,EAEvB,wBAAwB,EAGzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,0BAA0B,EAG3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,0BAA0B,EAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,uBAAuB,EAGxB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC,iBAAiB,CAAC,wBAAwB,GAAG,0BAA0B,CAAC,CAsBzE,CAAC;AACF,KAAK,iBAAiB,GAAG,uBAAuB,GAC9C,uBAAuB,GACvB,0BAA0B,CAAC;AAE7B,eAAO,MAAM,YAAY,kCAExB,CAAC;AA6BF;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,yBAEpB,CAAC"}
1
+ {"version":3,"file":"tambo-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAA6B,MAAM,OAAO,CAAC;AAC5E,OAAO,EACL,uBAAuB,EAEvB,wBAAwB,EAGzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,0BAA0B,EAG3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,0BAA0B,EAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,uBAAuB,EAGxB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,EAAE,K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AAA,sCAAc,GAAE,CAAC;IACjC,MAAM,MAAM,GAAG,IAAA,sCAAc,GAAE,CAAC;IAChC,MAAM,WAAW,GAAG,IAAA,2CAAmB,GAAE,CAAC;IAC1C,MAAM,iBAAiB,GAAG,IAAA,4CAAiB,GAAE,CAAC;IAE9C,OAAO,CACL,8BAAC,oBAAY,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;AACI,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,OAAO,IAAA,kBAAU,EAAC,oBAAY,CAAC,CAAC;AAClC,CAAC,CAAC;AAFW,QAAA,QAAQ,YAEnB","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 // Should only be used in browser\n if (typeof window === \"undefined\") {\n console.error(\"TamboProvider must be used within a browser\");\n }\n\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"]}
1
+ {"version":3,"file":"tambo-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,+CAA4E;AAC5E,mEAMiC;AACjC,yEAIoC;AACpC,uEAGmC;AACnC,mEAIiC;AAEjC;;;;;;;;;;GAUG;AACI,MAAM,aAAa,GAEtB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,EAAE;IAC9D,iCAAiC;IACjC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,CACL,8BAAC,2CAAmB,IAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW;QAExB,8BAAC,+CAAqB,IAAC,UAAU,EAAE,UAAU;YAC3C,8BAAC,2CAAmB;gBAClB,8BAAC,iDAAsB;oBACrB,8BAAC,sBAAsB,QAAE,QAAQ,CAA0B,CACpC,CACL,CACA,CACJ,CACvB,CAAC;AACJ,CAAC,CAAC;AAvBW,QAAA,aAAa,iBAuBxB;AAKW,QAAA,YAAY,GAAG,IAAA,qBAAa,EACvC,EAAuB,CACxB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,sBAAsB,GAAgC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC3E,MAAM,OAAO,GAAG,IAAA,sCAAc,GAAE,CAAC;IACjC,MAAM,MAAM,GAAG,IAAA,sCAAc,GAAE,CAAC;IAChC,MAAM,WAAW,GAAG,IAAA,2CAAmB,GAAE,CAAC;IAC1C,MAAM,iBAAiB,GAAG,IAAA,4CAAiB,GAAE,CAAC;IAE9C,OAAO,CACL,8BAAC,oBAAY,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;AACI,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,OAAO,IAAA,kBAAU,EAAC,oBAAY,CAAC,CAAC;AAClC,CAAC,CAAC;AAFW,QAAA,QAAQ,YAEnB","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 // Should only be used in browser\n if (typeof window === \"undefined\") {\n console.error(\"TamboProvider must be used within a browser\");\n }\n\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};\nexport type 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"]}
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
40
  exports.useTamboRegistry = exports.TamboRegistryProvider = void 0;
41
41
  const react_1 = __importStar(require("react"));
42
- const zod_1 = __importStar(require("zod"));
42
+ const zod_1 = require("zod");
43
43
  const zod_to_json_schema_1 = __importDefault(require("zod-to-json-schema"));
44
44
  const TamboRegistryContext = (0, react_1.createContext)({
45
45
  componentList: {},
@@ -166,9 +166,6 @@ function getSerializedProps(propsDefinition, propsSchema, name) {
166
166
  console.warn(`propsDefinition is deprecated. Use propsSchema instead.`);
167
167
  return propsDefinition;
168
168
  }
169
- if (propsSchema instanceof zod_1.ZodSchema || propsSchema instanceof zod_1.default.ZodObject) {
170
- return (0, zod_to_json_schema_1.default)(propsSchema);
171
- }
172
169
  if (isZodSchema(propsSchema)) {
173
170
  try {
174
171
  return (0, zod_to_json_schema_1.default)(propsSchema);
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-registry-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-registry-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,+CAOe;AACf,2CAAmC;AACnC,4EAAiD;AAiBjD,MAAM,oBAAoB,GAAG,IAAA,qBAAa,EAAuB;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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n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport z, { ZodSchema } from \"zod\";\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 const props = getSerializedProps(propsDefinition, propsSchema, name);\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};\nfunction getSerializedProps(\n propsDefinition: any,\n propsSchema: any,\n name: string,\n) {\n if (propsDefinition) {\n console.warn(`propsDefinition is deprecated. Use propsSchema instead.`);\n return propsDefinition;\n }\n if (propsSchema instanceof ZodSchema || propsSchema instanceof z.ZodObject) {\n return zodToJsonSchema(propsSchema);\n }\n\n if (isZodSchema(propsSchema)) {\n try {\n return zodToJsonSchema(propsSchema);\n } catch (error) {\n console.error(\n `Error converting ${name} props schema to JSON Schema:`,\n error,\n );\n }\n }\n // try to roughly detect JSONSchema, should always be an object with a properties key\n if (isJSONSchema(propsSchema)) {\n return propsSchema;\n }\n\n throw new Error(`Invalid props schema for ${name}`);\n}\n\n/**\n * Checks if the propsSchema is a JSON Schema. This is a rough check, and the\n * server will provide the definitive check.\n * @param propsSchema - The props schema to check\n * @returns True if the props schema is a JSON Schema, false otherwise\n */\nfunction isJSONSchema(propsSchema: any) {\n return (\n propsSchema &&\n typeof propsSchema === \"object\" &&\n propsSchema.type === \"object\" &&\n propsSchema.properties\n );\n}\n\n/**\n * Since we require a certain zod version, we need to check if the object is a ZodSchema\n * @param obj - The object to check\n * @returns True if the object is a ZodSchema, false otherwise\n */\nfunction isZodSchema(obj: unknown): obj is ZodSchema {\n if (obj instanceof ZodSchema) {\n return true;\n }\n // try to detect if the object is a ZodSchema\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n typeof (obj as any).safeParse === \"function\" &&\n typeof (obj as any)._def === \"object\"\n );\n}\n"]}
1
+ {"version":3,"file":"tambo-registry-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-registry-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,+CAOe;AACf,6BAAgC;AAChC,4EAAiD;AAiBjD,MAAM,oBAAoB,GAAG,IAAA,qBAAa,EAAuB;IAC/D,aAAa,EAAE,EAAE;IACjB,YAAY,EAAE,EAAE;IAChB,yBAAyB,EAAE,EAAE;IAC7B;;OAEG;IACH,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC;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gB,oBAE3B;AACF,SAAS,kBAAkB,CACzB,eAAoB,EACpB,WAAgB,EAChB,IAAY;IAEZ,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;QACxE,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,IAAI,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,IAAI,CAAC;YACH,OAAO,IAAA,4BAAe,EAAC,WAAW,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CACX,oBAAoB,IAAI,+BAA+B,EACvD,KAAK,CACN,CAAC;QACJ,CAAC;IACH,CAAC;IACD,qFAAqF;IACrF,IAAI,YAAY,CAAC,WAAW,CAAC,EAAE,CAAC;QAC9B,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,EAAE,CAAC,CAAC;AACtD,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,WAAgB;IACpC,OAAO,CACL,WAAW;QACX,OAAO,WAAW,KAAK,QAAQ;QAC/B,WAAW,CAAC,IAAI,KAAK,QAAQ;QAC7B,WAAW,CAAC,UAAU,CACvB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,GAAY;IAC/B,IAAI,GAAG,YAAY,eAAS,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,6CAA6C;IAC7C,OAAO,CACL,OAAO,GAAG,KAAK,QAAQ;QACvB,GAAG,KAAK,IAAI;QACZ,OAAQ,GAAW,CAAC,SAAS,KAAK,UAAU;QAC5C,OAAQ,GAAW,CAAC,IAAI,KAAK,QAAQ,CACtC,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport { ZodSchema } from \"zod\";\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 const props = getSerializedProps(propsDefinition, propsSchema, name);\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};\nfunction getSerializedProps(\n propsDefinition: any,\n propsSchema: any,\n name: string,\n) {\n if (propsDefinition) {\n console.warn(`propsDefinition is deprecated. Use propsSchema instead.`);\n return propsDefinition;\n }\n\n if (isZodSchema(propsSchema)) {\n try {\n return zodToJsonSchema(propsSchema);\n } catch (error) {\n console.error(\n `Error converting ${name} props schema to JSON Schema:`,\n error,\n );\n }\n }\n // try to roughly detect JSONSchema, should always be an object with a properties key\n if (isJSONSchema(propsSchema)) {\n return propsSchema;\n }\n\n throw new Error(`Invalid props schema for ${name}`);\n}\n\n/**\n * Checks if the propsSchema is a JSON Schema. This is a rough check, and the\n * server will provide the definitive check.\n * @param propsSchema - The props schema to check\n * @returns True if the props schema is a JSON Schema, false otherwise\n */\nfunction isJSONSchema(propsSchema: any) {\n return (\n propsSchema &&\n typeof propsSchema === \"object\" &&\n propsSchema.type === \"object\" &&\n propsSchema.properties\n );\n}\n\n/**\n * Since we require a certain zod version, we need to check if the object is a ZodSchema\n * @param obj - The object to check\n * @returns True if the object is a ZodSchema, false otherwise\n */\nfunction isZodSchema(obj: unknown): obj is ZodSchema {\n if (obj instanceof ZodSchema) {\n return true;\n }\n // try to detect if the object is a ZodSchema\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n typeof (obj as any).safeParse === \"function\" &&\n typeof (obj as any)._def === \"object\"\n );\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import "@tambo-ai/typescript-sdk/shims/node";
2
+ import "@testing-library/jest-dom";
3
+ //# sourceMappingURL=setupTests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setupTests.d.ts","sourceRoot":"","sources":["../src/setupTests.ts"],"names":[],"mappings":"AAAA,OAAO,qCAAqC,CAAC;AAC7C,OAAO,2BAA2B,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("@tambo-ai/typescript-sdk/shims/node");
4
+ require("@testing-library/jest-dom");
5
+ // Mock Date.now() to return a fixed timestamp for consistent testing
6
+ const mockDate = new Date(2025, 0, 5, 12, 32, 58, 936);
7
+ global.Date.now = jest.fn(() => mockDate.getTime());
8
+ //# sourceMappingURL=setupTests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setupTests.js","sourceRoot":"","sources":["../src/setupTests.ts"],"names":[],"mappings":";;AAAA,+CAA6C;AAC7C,qCAAmC;AAEnC,qEAAqE;AACrE,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;AACvD,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC","sourcesContent":["import \"@tambo-ai/typescript-sdk/shims/node\";\nimport \"@testing-library/jest-dom\";\n\n// Mock Date.now() to return a fixed timestamp for consistent testing\nconst mockDate = new Date(2025, 0, 5, 12, 32, 58, 936);\nglobal.Date.now = jest.fn(() => mockDate.getTime());\n"]}
@@ -0,0 +1,24 @@
1
+ import { TamboComponent } from "../providers";
2
+ /**
3
+ * Serializes the registry for testing purposes
4
+ * @param mockRegistry - The registry to serialize
5
+ * @returns The serialized registry
6
+ */
7
+ export declare function serializeRegistry(mockRegistry: TamboComponent[]): {
8
+ props: import("zod-to-json-schema").JsonSchema7Type & {
9
+ $schema?: string | undefined;
10
+ definitions?: {
11
+ [key: string]: import("zod-to-json-schema").JsonSchema7Type;
12
+ } | undefined;
13
+ };
14
+ contextTools: {
15
+ parameters: any;
16
+ name: string;
17
+ description: string;
18
+ }[] | undefined;
19
+ name: string;
20
+ description: string;
21
+ propsDefinition?: any;
22
+ loadingComponent?: import("react").ComponentType<any>;
23
+ }[];
24
+ //# sourceMappingURL=tools.d.ts.map