@tambo-ai/react 0.60.0 → 0.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/__tests__/util/validate-zod-schema.test.js +25 -0
  2. package/dist/__tests__/util/validate-zod-schema.test.js.map +1 -1
  3. package/dist/hooks/index.d.ts +1 -0
  4. package/dist/hooks/index.d.ts.map +1 -1
  5. package/dist/hooks/index.js +3 -1
  6. package/dist/hooks/index.js.map +1 -1
  7. package/dist/hooks/use-tambo-voice.d.ts +21 -0
  8. package/dist/hooks/use-tambo-voice.d.ts.map +1 -0
  9. package/dist/hooks/use-tambo-voice.js +74 -0
  10. package/dist/hooks/use-tambo-voice.js.map +1 -0
  11. package/dist/index.d.ts +2 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +5 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/mcp/__tests__/tambo-mcp-provider.test.js +4 -4
  16. package/dist/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -1
  17. package/dist/mcp/tambo-mcp-provider.d.ts +1 -1
  18. package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
  19. package/dist/mcp/tambo-mcp-provider.js +2 -2
  20. package/dist/mcp/tambo-mcp-provider.js.map +1 -1
  21. package/dist/providers/__tests__/tambo-context-attachment-provider.test.d.ts +2 -0
  22. package/dist/providers/__tests__/tambo-context-attachment-provider.test.d.ts.map +1 -0
  23. package/dist/providers/__tests__/tambo-context-attachment-provider.test.js +633 -0
  24. package/dist/providers/__tests__/tambo-context-attachment-provider.test.js.map +1 -0
  25. package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.js +1 -1
  26. package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.js.map +1 -1
  27. package/dist/providers/__tests__/tambo-thread-provider.test.js +170 -0
  28. package/dist/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
  29. package/dist/providers/index.d.ts +1 -0
  30. package/dist/providers/index.d.ts.map +1 -1
  31. package/dist/providers/index.js +4 -1
  32. package/dist/providers/index.js.map +1 -1
  33. package/dist/providers/tambo-context-attachment-provider.d.ts +132 -0
  34. package/dist/providers/tambo-context-attachment-provider.d.ts.map +1 -0
  35. package/dist/providers/tambo-context-attachment-provider.js +201 -0
  36. package/dist/providers/tambo-context-attachment-provider.js.map +1 -0
  37. package/dist/providers/tambo-provider.d.ts +6 -2
  38. package/dist/providers/tambo-provider.d.ts.map +1 -1
  39. package/dist/providers/tambo-provider.js +12 -5
  40. package/dist/providers/tambo-provider.js.map +1 -1
  41. package/dist/providers/tambo-stubs.d.ts.map +1 -1
  42. package/dist/providers/tambo-stubs.js +6 -2
  43. package/dist/providers/tambo-stubs.js.map +1 -1
  44. package/dist/providers/tambo-thread-provider.d.ts +6 -0
  45. package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
  46. package/dist/providers/tambo-thread-provider.js +112 -45
  47. package/dist/providers/tambo-thread-provider.js.map +1 -1
  48. package/dist/setupTests.js +10 -0
  49. package/dist/setupTests.js.map +1 -1
  50. package/dist/util/validate-zod-schema.d.ts.map +1 -1
  51. package/dist/util/validate-zod-schema.js +11 -0
  52. package/dist/util/validate-zod-schema.js.map +1 -1
  53. package/esm/__tests__/util/validate-zod-schema.test.js +25 -0
  54. package/esm/__tests__/util/validate-zod-schema.test.js.map +1 -1
  55. package/esm/hooks/index.d.ts +1 -0
  56. package/esm/hooks/index.d.ts.map +1 -1
  57. package/esm/hooks/index.js +1 -0
  58. package/esm/hooks/index.js.map +1 -1
  59. package/esm/hooks/use-tambo-voice.d.ts +21 -0
  60. package/esm/hooks/use-tambo-voice.d.ts.map +1 -0
  61. package/esm/hooks/use-tambo-voice.js +71 -0
  62. package/esm/hooks/use-tambo-voice.js.map +1 -0
  63. package/esm/index.d.ts +2 -1
  64. package/esm/index.d.ts.map +1 -1
  65. package/esm/index.js +2 -1
  66. package/esm/index.js.map +1 -1
  67. package/esm/mcp/__tests__/tambo-mcp-provider.test.js +4 -4
  68. package/esm/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -1
  69. package/esm/mcp/tambo-mcp-provider.d.ts +1 -1
  70. package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
  71. package/esm/mcp/tambo-mcp-provider.js +2 -2
  72. package/esm/mcp/tambo-mcp-provider.js.map +1 -1
  73. package/esm/providers/__tests__/tambo-context-attachment-provider.test.d.ts +2 -0
  74. package/esm/providers/__tests__/tambo-context-attachment-provider.test.d.ts.map +1 -0
  75. package/esm/providers/__tests__/tambo-context-attachment-provider.test.js +628 -0
  76. package/esm/providers/__tests__/tambo-context-attachment-provider.test.js.map +1 -0
  77. package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.js +1 -1
  78. package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.js.map +1 -1
  79. package/esm/providers/__tests__/tambo-thread-provider.test.js +170 -0
  80. package/esm/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
  81. package/esm/providers/index.d.ts +1 -0
  82. package/esm/providers/index.d.ts.map +1 -1
  83. package/esm/providers/index.js +1 -0
  84. package/esm/providers/index.js.map +1 -1
  85. package/esm/providers/tambo-context-attachment-provider.d.ts +132 -0
  86. package/esm/providers/tambo-context-attachment-provider.d.ts.map +1 -0
  87. package/esm/providers/tambo-context-attachment-provider.js +164 -0
  88. package/esm/providers/tambo-context-attachment-provider.js.map +1 -0
  89. package/esm/providers/tambo-provider.d.ts +6 -2
  90. package/esm/providers/tambo-provider.d.ts.map +1 -1
  91. package/esm/providers/tambo-provider.js +12 -5
  92. package/esm/providers/tambo-provider.js.map +1 -1
  93. package/esm/providers/tambo-stubs.d.ts.map +1 -1
  94. package/esm/providers/tambo-stubs.js +6 -2
  95. package/esm/providers/tambo-stubs.js.map +1 -1
  96. package/esm/providers/tambo-thread-provider.d.ts +6 -0
  97. package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
  98. package/esm/providers/tambo-thread-provider.js +112 -45
  99. package/esm/providers/tambo-thread-provider.js.map +1 -1
  100. package/esm/setupTests.js +10 -0
  101. package/esm/setupTests.js.map +1 -1
  102. package/esm/util/validate-zod-schema.d.ts.map +1 -1
  103. package/esm/util/validate-zod-schema.js +11 -0
  104. package/esm/util/validate-zod-schema.js.map +1 -1
  105. package/package.json +5 -4
@@ -0,0 +1,132 @@
1
+ import type { Suggestion } from "@tambo-ai/typescript-sdk/resources/beta/threads/suggestions";
2
+ import React from "react";
3
+ /**
4
+ * Represents a context attachment that can be displayed in MessageInputContexts.
5
+ * Context attachments appear as badges above the message input and provide additional
6
+ * information to the AI about what to focus on.
7
+ * @property {string} name - Display name shown in the badge
8
+ * @property {React.ReactNode} [icon] - Optional icon to display in the badge
9
+ * @property {Record<string, unknown>} [metadata] - Additional data passed to the AI
10
+ * @example
11
+ * ```tsx
12
+ * const context: ContextAttachment = {
13
+ * name: "Button.tsx",
14
+ * icon: <FileIcon />,
15
+ * metadata: { filePath: "/src/components/Button.tsx" }
16
+ * };
17
+ * ```
18
+ */
19
+ export interface ContextAttachment {
20
+ id: string;
21
+ name: string;
22
+ icon?: React.ReactNode;
23
+ metadata?: Record<string, unknown>;
24
+ }
25
+ /**
26
+ * Represents the data structure returned by a context helper
27
+ */
28
+ export type ContextHelperData = Record<string, unknown>;
29
+ /**
30
+ * Context state interface for managing context attachments and custom suggestions.
31
+ * @property {ContextAttachment[]} attachments - Array of active context attachments (badges above message input)
32
+ * @property {(context: Omit<ContextAttachment, "id">) => void} addContextAttachment - Add a new context attachment
33
+ * @property {(id: string) => void} removeContextAttachment - Remove a context attachment by ID
34
+ * @property {() => void} clearContextAttachments - Remove all context attachments - This is used to clear the context when the user submits a message
35
+ * @property {Suggestion[] | null} customSuggestions - Custom suggestions to display instead of auto-generated ones
36
+ * @property {(suggestions: Suggestion[] | null) => void} setCustomSuggestions - Set or clear custom suggestions
37
+ */
38
+ export interface ContextAttachmentState {
39
+ attachments: ContextAttachment[];
40
+ addContextAttachment: (context: Omit<ContextAttachment, "id">) => void;
41
+ removeContextAttachment: (id: string) => void;
42
+ clearContextAttachments: () => void;
43
+ customSuggestions: Suggestion[] | null;
44
+ setCustomSuggestions: (suggestions: Suggestion[] | null) => void;
45
+ }
46
+ /**
47
+ * Props for the TamboContextAttachmentProvider.
48
+ * @property {(context: ContextAttachment) => Promise<ContextHelperData> | ContextHelperData} [getContextHelperData] - Optional function to customize the data sent to the AI for each context. If not provided, uses a default structure with the context name and instruction.
49
+ * @example
50
+ * ```tsx
51
+ * <TamboContextAttachmentProvider
52
+ * getContextHelperData={(context) => ({
53
+ * selectedFile: {
54
+ * name: context.name,
55
+ * path: context.metadata?.filePath,
56
+ * instruction: "Focus on this file"
57
+ * }
58
+ * })}
59
+ * >
60
+ * {children}
61
+ * </TamboContextAttachmentProvider>
62
+ * ```
63
+ */
64
+ export interface TamboContextAttachmentProviderProps {
65
+ children?: React.ReactNode;
66
+ getContextHelperData?: (context: ContextAttachment) => Promise<ContextHelperData> | ContextHelperData;
67
+ }
68
+ /**
69
+ * Provider that enables context attachment features and custom suggestions in MessageInput.
70
+ * **When to use:**
71
+ * - **Included by default** in TamboProvider - no need to wrap separately
72
+ * - Use `useTamboContextAttachment()` hook to manage context attachments
73
+ * **What it does:**
74
+ * - Manages context items that appear as badges above MessageInput
75
+ * - Syncs context data with Tambo's AI for better responses
76
+ * - Manages custom suggestions that replace auto-generated suggestions
77
+ * - Allows components to add/remove contexts via `useTamboContextAttachment()`
78
+ * - Allows components to set custom suggestions via `setCustomSuggestions()`
79
+ * @param props - The props for the TamboContextAttachmentProvider
80
+ * @param props.children - The children to wrap
81
+ * @param props.getContextHelperData - The function to get the context helper data
82
+ * @returns The TamboContextAttachmentProvider component
83
+ * @example
84
+ * Basic usage - already included in TamboProvider
85
+ * ```tsx
86
+ * <TamboProvider apiKey="...">
87
+ * <App />
88
+ * </TamboProvider>
89
+ * ```
90
+ * @example
91
+ * Using TamboProvider with custom context data
92
+ * ```tsx
93
+ * <TamboProvider
94
+ * apiKey="..."
95
+ * getContextHelperData={(context) => ({
96
+ * selectedComponent: {
97
+ * name: context.name,
98
+ * filePath: context.metadata?.path,
99
+ * instruction: "Edit this component"
100
+ * }
101
+ * })}
102
+ * >
103
+ * <App />
104
+ * </TamboProvider>
105
+ * ```
106
+ */
107
+ export declare function TamboContextAttachmentProvider({ children, getContextHelperData, }: TamboContextAttachmentProviderProps): React.JSX.Element;
108
+ /**
109
+ * Hook to access context attachment state and methods.
110
+ * **Must be used within a `TamboProvider`** - throws an error otherwise.
111
+ * @throws {Error} If used outside of TamboProvider
112
+ * @returns The context attachment state and methods
113
+ * @example
114
+ * ```tsx
115
+ * const contextAttachment = useTamboContextAttachment();
116
+ *
117
+ * // Add a context
118
+ * contextAttachment.addContextAttachment({
119
+ * name: "Button.tsx",
120
+ * icon: <FileIcon />,
121
+ * metadata: { path: "/src/Button.tsx" }
122
+ * });
123
+ *
124
+ * // Remove a context
125
+ * contextAttachment.removeContextAttachment(contextId);
126
+ *
127
+ * // Set custom suggestions
128
+ * contextAttachment.setCustomSuggestions([{ id: "1", title: "Add Feature" }]);
129
+ * ```
130
+ */
131
+ export declare function useTamboContextAttachment(): ContextAttachmentState;
132
+ //# sourceMappingURL=tambo-context-attachment-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tambo-context-attachment-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-context-attachment-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6DAA6D,CAAC;AAC9F,OAAO,KAQN,MAAM,OAAO,CAAC;AAGf;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,oBAAoB,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC;IACvE,uBAAuB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,uBAAuB,EAAE,MAAM,IAAI,CAAC;IACpC,iBAAiB,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IACvC,oBAAoB,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,IAAI,KAAK,IAAI,CAAC;CAClE;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,mCAAmC;IAClD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,oBAAoB,CAAC,EAAE,CACrB,OAAO,EAAE,iBAAiB,KACvB,OAAO,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAAC;CACrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,8BAA8B,CAAC,EAC7C,QAAQ,EACR,oBAAoB,GACrB,EAAE,mCAAmC,qBAsHrC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,yBAAyB,2BAQxC"}
@@ -0,0 +1,164 @@
1
+ "use client";
2
+ import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
3
+ import { useTamboContextHelpers } from "./tambo-context-helpers-provider";
4
+ const ContextAttachmentContext = createContext(null);
5
+ /**
6
+ * Provider that enables context attachment features and custom suggestions in MessageInput.
7
+ * **When to use:**
8
+ * - **Included by default** in TamboProvider - no need to wrap separately
9
+ * - Use `useTamboContextAttachment()` hook to manage context attachments
10
+ * **What it does:**
11
+ * - Manages context items that appear as badges above MessageInput
12
+ * - Syncs context data with Tambo's AI for better responses
13
+ * - Manages custom suggestions that replace auto-generated suggestions
14
+ * - Allows components to add/remove contexts via `useTamboContextAttachment()`
15
+ * - Allows components to set custom suggestions via `setCustomSuggestions()`
16
+ * @param props - The props for the TamboContextAttachmentProvider
17
+ * @param props.children - The children to wrap
18
+ * @param props.getContextHelperData - The function to get the context helper data
19
+ * @returns The TamboContextAttachmentProvider component
20
+ * @example
21
+ * Basic usage - already included in TamboProvider
22
+ * ```tsx
23
+ * <TamboProvider apiKey="...">
24
+ * <App />
25
+ * </TamboProvider>
26
+ * ```
27
+ * @example
28
+ * Using TamboProvider with custom context data
29
+ * ```tsx
30
+ * <TamboProvider
31
+ * apiKey="..."
32
+ * getContextHelperData={(context) => ({
33
+ * selectedComponent: {
34
+ * name: context.name,
35
+ * filePath: context.metadata?.path,
36
+ * instruction: "Edit this component"
37
+ * }
38
+ * })}
39
+ * >
40
+ * <App />
41
+ * </TamboProvider>
42
+ * ```
43
+ */
44
+ export function TamboContextAttachmentProvider({ children, getContextHelperData, }) {
45
+ const [attachments, setAttachments] = useState([]);
46
+ const [customSuggestions, setCustomSuggestions] = useState(null);
47
+ const { addContextHelper, removeContextHelper } = useTamboContextHelpers();
48
+ // Track which context helpers have been registered to avoid duplicates
49
+ const registeredIdsRef = useRef(new Set());
50
+ const prevGetContextHelperDataRef = useRef();
51
+ // Sync context helpers with attachments using useEffect
52
+ useEffect(() => {
53
+ const currentIds = new Set(attachments.map((a) => a.id));
54
+ const registeredIds = registeredIdsRef.current;
55
+ // Remove context helpers that are no longer in attachments
56
+ registeredIds.forEach((id) => {
57
+ if (!currentIds.has(id)) {
58
+ removeContextHelper(id);
59
+ registeredIds.delete(id);
60
+ }
61
+ });
62
+ const getDataChanged = prevGetContextHelperDataRef.current !== getContextHelperData;
63
+ // Add or replace context helpers for attachments
64
+ attachments.forEach((context) => {
65
+ if (getDataChanged || !registeredIds.has(context.id)) {
66
+ addContextHelper(context.id, async () => {
67
+ if (getContextHelperData) {
68
+ return await getContextHelperData(context);
69
+ }
70
+ return {
71
+ selectedComponent: {
72
+ name: context.name,
73
+ instruction: "This is a Tambo interactable component that is currently selected and visible on the dashboard. You can read its current props and state, and update it by modifying its props. If multiple components are attached, you can interact with and modify any of them. Use the auto-registered interactable component tools (like get_interactable_component_by_id and update_interactable_component_<id>) to view and update the component's state.",
74
+ ...(context.metadata ?? {}),
75
+ },
76
+ };
77
+ });
78
+ registeredIds.add(context.id);
79
+ }
80
+ });
81
+ prevGetContextHelperDataRef.current = getContextHelperData;
82
+ }, [
83
+ attachments,
84
+ addContextHelper,
85
+ removeContextHelper,
86
+ getContextHelperData,
87
+ ]);
88
+ // Cleanup: remove all context helpers on unmount
89
+ useEffect(() => {
90
+ const registeredIds = registeredIdsRef.current;
91
+ return () => {
92
+ registeredIds.forEach((id) => {
93
+ removeContextHelper(id);
94
+ });
95
+ registeredIds.clear();
96
+ };
97
+ }, [removeContextHelper]);
98
+ const addContextAttachment = useCallback((context) => {
99
+ setAttachments((prev) => {
100
+ if (prev.some((c) => c.name === context.name))
101
+ return prev;
102
+ if (typeof crypto === "undefined" || !("randomUUID" in crypto)) {
103
+ throw new Error("crypto.randomUUID() is not available. This usually happens when using an IP address instead of 'localhost' in development. Use 'localhost' or a secure context (HTTPS) to enable crypto APIs.");
104
+ }
105
+ const newId = crypto.randomUUID();
106
+ const newContext = { ...context, id: newId };
107
+ return [...prev, newContext];
108
+ });
109
+ }, []);
110
+ // This is used to remove a context when the user clicks the remove button
111
+ const removeContextAttachment = useCallback((id) => {
112
+ setAttachments((prev) => prev.filter((c) => c.id !== id));
113
+ }, []);
114
+ // This is used to clear the context when the user submits a message
115
+ const clearContextAttachments = useCallback(() => {
116
+ setAttachments([]);
117
+ }, []);
118
+ const value = useMemo(() => ({
119
+ attachments,
120
+ addContextAttachment,
121
+ removeContextAttachment,
122
+ clearContextAttachments,
123
+ customSuggestions,
124
+ setCustomSuggestions,
125
+ }), [
126
+ attachments,
127
+ addContextAttachment,
128
+ removeContextAttachment,
129
+ clearContextAttachments,
130
+ customSuggestions,
131
+ ]);
132
+ return (React.createElement(ContextAttachmentContext.Provider, { value: value }, children));
133
+ }
134
+ /**
135
+ * Hook to access context attachment state and methods.
136
+ * **Must be used within a `TamboProvider`** - throws an error otherwise.
137
+ * @throws {Error} If used outside of TamboProvider
138
+ * @returns The context attachment state and methods
139
+ * @example
140
+ * ```tsx
141
+ * const contextAttachment = useTamboContextAttachment();
142
+ *
143
+ * // Add a context
144
+ * contextAttachment.addContextAttachment({
145
+ * name: "Button.tsx",
146
+ * icon: <FileIcon />,
147
+ * metadata: { path: "/src/Button.tsx" }
148
+ * });
149
+ *
150
+ * // Remove a context
151
+ * contextAttachment.removeContextAttachment(contextId);
152
+ *
153
+ * // Set custom suggestions
154
+ * contextAttachment.setCustomSuggestions([{ id: "1", title: "Add Feature" }]);
155
+ * ```
156
+ */
157
+ export function useTamboContextAttachment() {
158
+ const context = useContext(ContextAttachmentContext);
159
+ if (!context) {
160
+ throw new Error("useTamboContextAttachment must be used within a TamboContextAttachmentProvider");
161
+ }
162
+ return context;
163
+ }
164
+ //# sourceMappingURL=tambo-context-attachment-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tambo-context-attachment-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-context-attachment-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,KAAK,EAAE,EACZ,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAgD1E,MAAM,wBAAwB,GAAG,aAAa,CAC5C,IAAI,CACL,CAAC;AA2BF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,UAAU,8BAA8B,CAAC,EAC7C,QAAQ,EACR,oBAAoB,GACgB;IACpC,MA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{ Suggestion } from \"@tambo-ai/typescript-sdk/resources/beta/threads/suggestions\";\nimport React, {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useTamboContextHelpers } from \"./tambo-context-helpers-provider\";\n\n/**\n * Represents a context attachment that can be displayed in MessageInputContexts.\n * Context attachments appear as badges above the message input and provide additional\n * information to the AI about what to focus on.\n * @property {string} name - Display name shown in the badge\n * @property {React.ReactNode} [icon] - Optional icon to display in the badge\n * @property {Record<string, unknown>} [metadata] - Additional data passed to the AI\n * @example\n * ```tsx\n * const context: ContextAttachment = {\n * name: \"Button.tsx\",\n * icon: <FileIcon />,\n * metadata: { filePath: \"/src/components/Button.tsx\" }\n * };\n * ```\n */\nexport interface ContextAttachment {\n id: string;\n name: string;\n icon?: React.ReactNode;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Represents the data structure returned by a context helper\n */\nexport type ContextHelperData = Record<string, unknown>;\n\n/**\n * Context state interface for managing context attachments and custom suggestions.\n * @property {ContextAttachment[]} attachments - Array of active context attachments (badges above message input)\n * @property {(context: Omit<ContextAttachment, \"id\">) => void} addContextAttachment - Add a new context attachment\n * @property {(id: string) => void} removeContextAttachment - Remove a context attachment by ID\n * @property {() => void} clearContextAttachments - Remove all context attachments - This is used to clear the context when the user submits a message\n * @property {Suggestion[] | null} customSuggestions - Custom suggestions to display instead of auto-generated ones\n * @property {(suggestions: Suggestion[] | null) => void} setCustomSuggestions - Set or clear custom suggestions\n */\nexport interface ContextAttachmentState {\n attachments: ContextAttachment[];\n addContextAttachment: (context: Omit<ContextAttachment, \"id\">) => void;\n removeContextAttachment: (id: string) => void;\n clearContextAttachments: () => void;\n customSuggestions: Suggestion[] | null;\n setCustomSuggestions: (suggestions: Suggestion[] | null) => void;\n}\n\nconst ContextAttachmentContext = createContext<ContextAttachmentState | null>(\n null,\n);\n\n/**\n * Props for the TamboContextAttachmentProvider.\n * @property {(context: ContextAttachment) => Promise<ContextHelperData> | ContextHelperData} [getContextHelperData] - Optional function to customize the data sent to the AI for each context. If not provided, uses a default structure with the context name and instruction.\n * @example\n * ```tsx\n * <TamboContextAttachmentProvider\n * getContextHelperData={(context) => ({\n * selectedFile: {\n * name: context.name,\n * path: context.metadata?.filePath,\n * instruction: \"Focus on this file\"\n * }\n * })}\n * >\n * {children}\n * </TamboContextAttachmentProvider>\n * ```\n */\nexport interface TamboContextAttachmentProviderProps {\n children?: React.ReactNode;\n getContextHelperData?: (\n context: ContextAttachment,\n ) => Promise<ContextHelperData> | ContextHelperData;\n}\n\n/**\n * Provider that enables context attachment features and custom suggestions in MessageInput.\n * **When to use:**\n * - **Included by default** in TamboProvider - no need to wrap separately\n * - Use `useTamboContextAttachment()` hook to manage context attachments\n * **What it does:**\n * - Manages context items that appear as badges above MessageInput\n * - Syncs context data with Tambo's AI for better responses\n * - Manages custom suggestions that replace auto-generated suggestions\n * - Allows components to add/remove contexts via `useTamboContextAttachment()`\n * - Allows components to set custom suggestions via `setCustomSuggestions()`\n * @param props - The props for the TamboContextAttachmentProvider\n * @param props.children - The children to wrap\n * @param props.getContextHelperData - The function to get the context helper data\n * @returns The TamboContextAttachmentProvider component\n * @example\n * Basic usage - already included in TamboProvider\n * ```tsx\n * <TamboProvider apiKey=\"...\">\n * <App />\n * </TamboProvider>\n * ```\n * @example\n * Using TamboProvider with custom context data\n * ```tsx\n * <TamboProvider\n * apiKey=\"...\"\n * getContextHelperData={(context) => ({\n * selectedComponent: {\n * name: context.name,\n * filePath: context.metadata?.path,\n * instruction: \"Edit this component\"\n * }\n * })}\n * >\n * <App />\n * </TamboProvider>\n * ```\n */\nexport function TamboContextAttachmentProvider({\n children,\n getContextHelperData,\n}: TamboContextAttachmentProviderProps) {\n const [attachments, setAttachments] = useState<ContextAttachment[]>([]);\n const [customSuggestions, setCustomSuggestions] = useState<\n Suggestion[] | null\n >(null);\n const { addContextHelper, removeContextHelper } = useTamboContextHelpers();\n\n // Track which context helpers have been registered to avoid duplicates\n const registeredIdsRef = useRef<Set<string>>(new Set());\n const prevGetContextHelperDataRef = useRef<typeof getContextHelperData>();\n\n // Sync context helpers with attachments using useEffect\n useEffect(() => {\n const currentIds = new Set(attachments.map((a) => a.id));\n const registeredIds = registeredIdsRef.current;\n\n // Remove context helpers that are no longer in attachments\n registeredIds.forEach((id) => {\n if (!currentIds.has(id)) {\n removeContextHelper(id);\n registeredIds.delete(id);\n }\n });\n\n const getDataChanged =\n prevGetContextHelperDataRef.current !== getContextHelperData;\n\n // Add or replace context helpers for attachments\n attachments.forEach((context) => {\n if (getDataChanged || !registeredIds.has(context.id)) {\n addContextHelper(context.id, async (): Promise<ContextHelperData> => {\n if (getContextHelperData) {\n return await getContextHelperData(context);\n }\n return {\n selectedComponent: {\n name: context.name,\n instruction:\n \"This is a Tambo interactable component that is currently selected and visible on the dashboard. You can read its current props and state, and update it by modifying its props. If multiple components are attached, you can interact with and modify any of them. Use the auto-registered interactable component tools (like get_interactable_component_by_id and update_interactable_component_<id>) to view and update the component's state.\",\n ...(context.metadata ?? {}),\n },\n };\n });\n registeredIds.add(context.id);\n }\n });\n\n prevGetContextHelperDataRef.current = getContextHelperData;\n }, [\n attachments,\n addContextHelper,\n removeContextHelper,\n getContextHelperData,\n ]);\n\n // Cleanup: remove all context helpers on unmount\n useEffect(() => {\n const registeredIds = registeredIdsRef.current;\n return () => {\n registeredIds.forEach((id) => {\n removeContextHelper(id);\n });\n registeredIds.clear();\n };\n }, [removeContextHelper]);\n\n const addContextAttachment = useCallback(\n (context: Omit<ContextAttachment, \"id\">) => {\n setAttachments((prev) => {\n if (prev.some((c) => c.name === context.name)) return prev;\n\n if (typeof crypto === \"undefined\" || !(\"randomUUID\" in crypto)) {\n throw new Error(\n \"crypto.randomUUID() is not available. This usually happens when using an IP address instead of 'localhost' in development. Use 'localhost' or a secure context (HTTPS) to enable crypto APIs.\",\n );\n }\n\n const newId = crypto.randomUUID();\n const newContext = { ...context, id: newId };\n return [...prev, newContext];\n });\n },\n [],\n );\n\n // This is used to remove a context when the user clicks the remove button\n const removeContextAttachment = useCallback((id: string) => {\n setAttachments((prev) => prev.filter((c) => c.id !== id));\n }, []);\n\n // This is used to clear the context when the user submits a message\n const clearContextAttachments = useCallback(() => {\n setAttachments([]);\n }, []);\n\n const value = useMemo(\n () => ({\n attachments,\n addContextAttachment,\n removeContextAttachment,\n clearContextAttachments,\n customSuggestions,\n setCustomSuggestions,\n }),\n [\n attachments,\n addContextAttachment,\n removeContextAttachment,\n clearContextAttachments,\n customSuggestions,\n ],\n );\n\n return (\n <ContextAttachmentContext.Provider value={value}>\n {children}\n </ContextAttachmentContext.Provider>\n );\n}\n\n/**\n * Hook to access context attachment state and methods.\n * **Must be used within a `TamboProvider`** - throws an error otherwise.\n * @throws {Error} If used outside of TamboProvider\n * @returns The context attachment state and methods\n * @example\n * ```tsx\n * const contextAttachment = useTamboContextAttachment();\n *\n * // Add a context\n * contextAttachment.addContextAttachment({\n * name: \"Button.tsx\",\n * icon: <FileIcon />,\n * metadata: { path: \"/src/Button.tsx\" }\n * });\n *\n * // Remove a context\n * contextAttachment.removeContextAttachment(contextId);\n *\n * // Set custom suggestions\n * contextAttachment.setCustomSuggestions([{ id: \"1\", title: \"Add Feature\" }]);\n * ```\n */\nexport function useTamboContextAttachment() {\n const context = useContext(ContextAttachmentContext);\n if (!context) {\n throw new Error(\n \"useTamboContextAttachment must be used within a TamboContextAttachmentProvider\",\n );\n }\n return context;\n}\n"]}
@@ -2,6 +2,7 @@ import React, { PropsWithChildren } from "react";
2
2
  import { TamboInteractableContext } from "../model/tambo-interactable";
3
3
  import { TamboClientContextProps, TamboClientProviderProps } from "./tambo-client-provider";
4
4
  import { TamboComponentContextProps } from "./tambo-component-provider";
5
+ import { ContextAttachmentState, TamboContextAttachmentProviderProps } from "./tambo-context-attachment-provider";
5
6
  import { TamboContextHelpersContextProps, TamboContextHelpersProviderProps } from "./tambo-context-helpers-provider";
6
7
  import { TamboRegistryProviderProps } from "./tambo-registry-provider";
7
8
  import { TamboThreadInputProviderProps } from "./tambo-thread-input-provider";
@@ -17,15 +18,18 @@ import { TamboGenerationStageContextProps, TamboThreadContextProps, TamboThreadP
17
18
  * @param props.environment - The environment to use for the Tambo API
18
19
  * @param props.tools - The tools to register
19
20
  * @param props.streaming - Whether to stream the response by default. Defaults to true.
21
+ * @param props.autoGenerateThreadName - Whether to automatically generate thread names. Defaults to true.
22
+ * @param props.autoGenerateNameThreshold - The message count threshold at which the thread name will be auto-generated. Defaults to 3.
20
23
  * @param props.contextHelpers - Configuration for which context helpers are enabled/disabled
21
24
  * @param props.userToken - The user's OAuth token (access or ID) used to identify the user and exchange for a Tambo session token (preferred over contextKey)
22
25
  * @param props.contextKey - Optional context key to be used in the thread input provider
23
26
  * @param props.onCallUnregisteredTool - Callback function called when an unregistered tool is called
24
27
  * @param props.initialMessages - Initial messages to be included in new threads
28
+ * @param props.getContextHelperData - Optional function to customize the data sent to the AI for each context attachment
25
29
  * @returns The TamboProvider component
26
30
  */
27
- export declare const TamboProvider: React.FC<PropsWithChildren<TamboClientProviderProps & TamboRegistryProviderProps & TamboThreadProviderProps & TamboContextHelpersProviderProps & TamboThreadInputProviderProps>>;
28
- export type TamboContextProps = TamboClientContextProps & TamboThreadContextProps & TamboGenerationStageContextProps & TamboComponentContextProps & TamboInteractableContext & TamboContextHelpersContextProps;
31
+ export declare const TamboProvider: React.FC<PropsWithChildren<TamboClientProviderProps & TamboRegistryProviderProps & TamboThreadProviderProps & TamboContextHelpersProviderProps & TamboThreadInputProviderProps & Partial<Pick<TamboContextAttachmentProviderProps, "getContextHelperData">>>>;
32
+ export type TamboContextProps = TamboClientContextProps & TamboThreadContextProps & TamboGenerationStageContextProps & TamboComponentContextProps & TamboInteractableContext & TamboContextHelpersContextProps & ContextAttachmentState;
29
33
  export declare const TamboContext: React.Context<TamboContextProps>;
30
34
  /**
31
35
  * TamboCompositeProvider is a provider that combines the TamboClient,
@@ -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,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EACL,uBAAuB,EAEvB,wBAAwB,EAIzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,0BAA0B,EAG3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,+BAA+B,EAE/B,gCAAgC,EAEjC,MAAM,kCAAkC,CAAC;AAM1C,OAAO,EAEL,0BAA0B,EAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,6BAA6B,EAC9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,gCAAgC,EAChC,uBAAuB,EAEvB,wBAAwB,EAEzB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC,iBAAiB,CACf,wBAAwB,GACtB,0BAA0B,GAC1B,wBAAwB,GACxB,gCAAgC,GAChC,6BAA6B,CAChC,CA8CF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,GACrD,uBAAuB,GACvB,gCAAgC,GAChC,0BAA0B,GAC1B,wBAAwB,GACxB,+BAA+B,CAAC;AAElC,eAAO,MAAM,YAAY,kCAExB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA0B9D,CAAC;AAEF;;;;;;;GAOG;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,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EACL,uBAAuB,EAEvB,wBAAwB,EAIzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,0BAA0B,EAG3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,sBAAsB,EAEtB,mCAAmC,EAEpC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,+BAA+B,EAE/B,gCAAgC,EAEjC,MAAM,kCAAkC,CAAC;AAM1C,OAAO,EAEL,0BAA0B,EAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,6BAA6B,EAC9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,gCAAgC,EAChC,uBAAuB,EAEvB,wBAAwB,EAEzB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC,iBAAiB,CACf,wBAAwB,GACtB,0BAA0B,GAC1B,wBAAwB,GACxB,gCAAgC,GAChC,6BAA6B,GAC7B,OAAO,CAAC,IAAI,CAAC,mCAAmC,EAAE,sBAAsB,CAAC,CAAC,CAC7E,CAyDF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,GACrD,uBAAuB,GACvB,gCAAgC,GAChC,0BAA0B,GAC1B,wBAAwB,GACxB,+BAA+B,GAC/B,sBAAsB,CAAC;AAEzB,eAAO,MAAM,YAAY,kCAExB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA4B9D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,yBAEpB,CAAC"}
@@ -2,6 +2,7 @@
2
2
  import React, { createContext, useContext } from "react";
3
3
  import { TamboClientProvider, useIsTamboTokenUpdating, useTamboClient, useTamboQueryClient, } from "./tambo-client-provider";
4
4
  import { TamboComponentProvider, useTamboComponent, } from "./tambo-component-provider";
5
+ import { TamboContextAttachmentProvider, useTamboContextAttachment, } from "./tambo-context-attachment-provider";
5
6
  import { TamboContextHelpersProvider, useTamboContextHelpers, } from "./tambo-context-helpers-provider";
6
7
  import { TamboInteractableProvider, useTamboInteractable, } from "./tambo-interactable-provider";
7
8
  import { TamboMcpTokenProvider } from "./tambo-mcp-token-provider";
@@ -19,23 +20,27 @@ import { TamboThreadProvider, useTamboThread, } from "./tambo-thread-provider";
19
20
  * @param props.environment - The environment to use for the Tambo API
20
21
  * @param props.tools - The tools to register
21
22
  * @param props.streaming - Whether to stream the response by default. Defaults to true.
23
+ * @param props.autoGenerateThreadName - Whether to automatically generate thread names. Defaults to true.
24
+ * @param props.autoGenerateNameThreshold - The message count threshold at which the thread name will be auto-generated. Defaults to 3.
22
25
  * @param props.contextHelpers - Configuration for which context helpers are enabled/disabled
23
26
  * @param props.userToken - The user's OAuth token (access or ID) used to identify the user and exchange for a Tambo session token (preferred over contextKey)
24
27
  * @param props.contextKey - Optional context key to be used in the thread input provider
25
28
  * @param props.onCallUnregisteredTool - Callback function called when an unregistered tool is called
26
29
  * @param props.initialMessages - Initial messages to be included in new threads
30
+ * @param props.getContextHelperData - Optional function to customize the data sent to the AI for each context attachment
27
31
  * @returns The TamboProvider component
28
32
  */
29
- export const TamboProvider = ({ children, tamboUrl, apiKey, userToken, components, environment, tools, streaming, contextHelpers, contextKey, initialMessages, onCallUnregisteredTool, }) => {
33
+ export const TamboProvider = ({ children, tamboUrl, apiKey, userToken, components, environment, tools, streaming, autoGenerateThreadName, autoGenerateNameThreshold, contextHelpers, contextKey, initialMessages, onCallUnregisteredTool, getContextHelperData, }) => {
30
34
  return (React.createElement(TamboClientProvider, { tamboUrl: tamboUrl, apiKey: apiKey, environment: environment, userToken: userToken },
31
35
  React.createElement(TamboRegistryProvider, { components: components, tools: tools, onCallUnregisteredTool: onCallUnregisteredTool },
32
36
  React.createElement(TamboContextHelpersProvider, { contextHelpers: contextHelpers },
33
37
  React.createElement(TamboMcpTokenProvider, null,
34
- React.createElement(TamboThreadProvider, { streaming: streaming, initialMessages: initialMessages },
38
+ React.createElement(TamboThreadProvider, { streaming: streaming, autoGenerateThreadName: autoGenerateThreadName, autoGenerateNameThreshold: autoGenerateNameThreshold, initialMessages: initialMessages },
35
39
  React.createElement(TamboThreadInputProvider, { contextKey: contextKey },
36
- React.createElement(TamboComponentProvider, null,
37
- React.createElement(TamboInteractableProvider, null,
38
- React.createElement(TamboCompositeProvider, null, children))))))))));
40
+ React.createElement(TamboContextAttachmentProvider, { getContextHelperData: getContextHelperData },
41
+ React.createElement(TamboComponentProvider, null,
42
+ React.createElement(TamboInteractableProvider, null,
43
+ React.createElement(TamboCompositeProvider, null, children)))))))))));
39
44
  };
40
45
  export const TamboContext = createContext({});
41
46
  /**
@@ -53,6 +58,7 @@ export const TamboCompositeProvider = ({ children, }) => {
53
58
  const componentRegistry = useTamboComponent();
54
59
  const interactableComponents = useTamboInteractable();
55
60
  const contextHelpers = useTamboContextHelpers();
61
+ const contextAttachment = useTamboContextAttachment();
56
62
  return (React.createElement(TamboContext.Provider, { value: {
57
63
  client,
58
64
  queryClient,
@@ -61,6 +67,7 @@ export const TamboCompositeProvider = ({ children, }) => {
61
67
  ...threads,
62
68
  ...interactableComponents,
63
69
  ...contextHelpers,
70
+ ...contextAttachment,
64
71
  } }, children));
65
72
  };
66
73
  /**
@@ -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;AAE5E,OAAO,EAEL,mBAAmB,EAEnB,uBAAuB,EACvB,cAAc,EACd,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,2BAA2B,EAE3B,sBAAsB,GACvB,MA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GAAgC,CAAC,EAClE,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,MAAM,WAAW,GAAG,mBAAmB,EAAE,CAAC;IAC1C,MAAM,eAAe,GAAG,uBAAuB,EAAE,CAAC;IAClD,MAAM,iBAAiB,GAAG,iBAAiB,EAAE,CAAC;IAC9C,MAAM,sBAAsB,GAAG,oBAAoB,EAAE,CAAC;IACtD,MAAM,cAAc,GAAG,sBAAsB,EAAE,CAAC;IAEhD,OAAO,CACL,oBAAC,YAAY,CAAC,QAAQ,IACpB,KAAK,EAAE;YACL,MAAM;YACN,WAAW;YACX,eAAe;YACf,GAAG,iBAAiB;YACpB,GAAG,OAAO;YACV,GAAG,sBAAsB;YACzB,GAAG,cAAc;SAClB,IAEA,QAAQ,CACa,CACzB,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;GAOG;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 { TamboInteractableContext } from \"../model/tambo-interactable\";\nimport {\n TamboClientContextProps,\n TamboClientProvider,\n TamboClientProviderProps,\n useIsTamboTokenUpdating,\n useTamboClient,\n useTamboQueryClient,\n} from \"./tambo-client-provider\";\nimport {\n TamboComponentContextProps,\n TamboComponentProvider,\n useTamboComponent,\n} from \"./tambo-component-provider\";\nimport {\n TamboContextHelpersContextProps,\n TamboContextHelpersProvider,\n TamboContextHelpersProviderProps,\n useTamboContextHelpers,\n} from \"./tambo-context-helpers-provider\";\nimport {\n TamboInteractableProvider,\n useTamboInteractable,\n} from \"./tambo-interactable-provider\";\nimport { TamboMcpTokenProvider } from \"./tambo-mcp-token-provider\";\nimport {\n TamboRegistryProvider,\n TamboRegistryProviderProps,\n} from \"./tambo-registry-provider\";\nimport {\n TamboThreadInputProvider,\n TamboThreadInputProviderProps,\n} from \"./tambo-thread-input-provider\";\nimport {\n TamboGenerationStageContextProps,\n TamboThreadContextProps,\n TamboThreadProvider,\n TamboThreadProviderProps,\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, the current thread context, and interactable components.\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 * @param props.tools - The tools to register\n * @param props.streaming - Whether to stream the response by default. Defaults to true.\n * @param props.contextHelpers - Configuration for which context helpers are enabled/disabled\n * @param props.userToken - The user's OAuth token (access or ID) used to identify the user and exchange for a Tambo session token (preferred over contextKey)\n * @param props.contextKey - Optional context key to be used in the thread input provider\n * @param props.onCallUnregisteredTool - Callback function called when an unregistered tool is called\n * @param props.initialMessages - Initial messages to be included in new threads\n * @returns The TamboProvider component\n */\nexport const TamboProvider: React.FC<\n PropsWithChildren<\n TamboClientProviderProps &\n TamboRegistryProviderProps &\n TamboThreadProviderProps &\n TamboContextHelpersProviderProps &\n TamboThreadInputProviderProps\n >\n> = ({\n children,\n tamboUrl,\n apiKey,\n userToken,\n components,\n environment,\n tools,\n streaming,\n contextHelpers,\n contextKey,\n initialMessages,\n onCallUnregisteredTool,\n}) => {\n return (\n <TamboClientProvider\n tamboUrl={tamboUrl}\n apiKey={apiKey}\n environment={environment}\n userToken={userToken}\n >\n <TamboRegistryProvider\n components={components}\n tools={tools}\n onCallUnregisteredTool={onCallUnregisteredTool}\n >\n <TamboContextHelpersProvider contextHelpers={contextHelpers}>\n <TamboMcpTokenProvider>\n <TamboThreadProvider\n streaming={streaming}\n initialMessages={initialMessages}\n >\n <TamboThreadInputProvider contextKey={contextKey}>\n <TamboComponentProvider>\n <TamboInteractableProvider>\n <TamboCompositeProvider>{children}</TamboCompositeProvider>\n </TamboInteractableProvider>\n </TamboComponentProvider>\n </TamboThreadInputProvider>\n </TamboThreadProvider>\n </TamboMcpTokenProvider>\n </TamboContextHelpersProvider>\n </TamboRegistryProvider>\n </TamboClientProvider>\n );\n};\n\nexport type TamboContextProps = TamboClientContextProps &\n TamboThreadContextProps &\n TamboGenerationStageContextProps &\n TamboComponentContextProps &\n TamboInteractableContext &\n TamboContextHelpersContextProps;\n\nexport const TamboContext = createContext<TamboContextProps>(\n {} as TamboContextProps,\n);\n\n/**\n * TamboCompositeProvider is a provider that combines the TamboClient,\n * TamboThread, TamboComponent, and TamboInteractable providers\n * @param props - The props for the TamboCompositeProvider\n * @param props.children - The children to wrap\n * @returns The wrapped component\n */\nexport const TamboCompositeProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const threads = useTamboThread();\n const client = useTamboClient();\n const queryClient = useTamboQueryClient();\n const isUpdatingToken = useIsTamboTokenUpdating();\n const componentRegistry = useTamboComponent();\n const interactableComponents = useTamboInteractable();\n const contextHelpers = useTamboContextHelpers();\n\n return (\n <TamboContext.Provider\n value={{\n client,\n queryClient,\n isUpdatingToken,\n ...componentRegistry,\n ...threads,\n ...interactableComponents,\n ...contextHelpers,\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, the current thread context,\n * and interactable component management.\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,OAAO,KAAK,EAAE,EAAqB,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EAEL,mBAAmB,EAEnB,uBAAuB,EACvB,cAAc,EACd,mBAAmB,GACpB,MAAM,y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AAwB,IAAC,UAAU,EAAE,UAAU;4BAC9C,oBAAC,8BAA8B,IAC7B,oBAAoB,EAAE,oBAAoB;gCAE1C,oBAAC,sBAAsB;oCACrB,oBAAC,yBAAyB;wCACxB,oBAAC,sBAAsB,QACpB,QAAQ,CACc,CACC,CACL,CACM,CACR,CACP,CACA,CACI,CACR,CACJ,CACvB,CAAC;AACJ,CAAC,CAAC;AAUF,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CACvC,EAAuB,CACxB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAgC,CAAC,EAClE,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,MAAM,WAAW,GAAG,mBAAmB,EAAE,CAAC;IAC1C,MAAM,eAAe,GAAG,uBAAuB,EAAE,CAAC;IAClD,MAAM,iBAAiB,GAAG,iBAAiB,EAAE,CAAC;IAC9C,MAAM,sBAAsB,GAAG,oBAAoB,EAAE,CAAC;IACtD,MAAM,cAAc,GAAG,sBAAsB,EAAE,CAAC;IAChD,MAAM,iBAAiB,GAAG,yBAAyB,EAAE,CAAC;IAEtD,OAAO,CACL,oBAAC,YAAY,CAAC,QAAQ,IACpB,KAAK,EAAE;YACL,MAAM;YACN,WAAW;YACX,eAAe;YACf,GAAG,iBAAiB;YACpB,GAAG,OAAO;YACV,GAAG,sBAAsB;YACzB,GAAG,cAAc;YACjB,GAAG,iBAAiB;SACrB,IAEA,QAAQ,CACa,CACzB,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;GAOG;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 { TamboInteractableContext } from \"../model/tambo-interactable\";\nimport {\n TamboClientContextProps,\n TamboClientProvider,\n TamboClientProviderProps,\n useIsTamboTokenUpdating,\n useTamboClient,\n useTamboQueryClient,\n} from \"./tambo-client-provider\";\nimport {\n TamboComponentContextProps,\n TamboComponentProvider,\n useTamboComponent,\n} from \"./tambo-component-provider\";\nimport {\n ContextAttachmentState,\n TamboContextAttachmentProvider,\n TamboContextAttachmentProviderProps,\n useTamboContextAttachment,\n} from \"./tambo-context-attachment-provider\";\nimport {\n TamboContextHelpersContextProps,\n TamboContextHelpersProvider,\n TamboContextHelpersProviderProps,\n useTamboContextHelpers,\n} from \"./tambo-context-helpers-provider\";\nimport {\n TamboInteractableProvider,\n useTamboInteractable,\n} from \"./tambo-interactable-provider\";\nimport { TamboMcpTokenProvider } from \"./tambo-mcp-token-provider\";\nimport {\n TamboRegistryProvider,\n TamboRegistryProviderProps,\n} from \"./tambo-registry-provider\";\nimport {\n TamboThreadInputProvider,\n TamboThreadInputProviderProps,\n} from \"./tambo-thread-input-provider\";\nimport {\n TamboGenerationStageContextProps,\n TamboThreadContextProps,\n TamboThreadProvider,\n TamboThreadProviderProps,\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, the current thread context, and interactable components.\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 * @param props.tools - The tools to register\n * @param props.streaming - Whether to stream the response by default. Defaults to true.\n * @param props.autoGenerateThreadName - Whether to automatically generate thread names. Defaults to true.\n * @param props.autoGenerateNameThreshold - The message count threshold at which the thread name will be auto-generated. Defaults to 3.\n * @param props.contextHelpers - Configuration for which context helpers are enabled/disabled\n * @param props.userToken - The user's OAuth token (access or ID) used to identify the user and exchange for a Tambo session token (preferred over contextKey)\n * @param props.contextKey - Optional context key to be used in the thread input provider\n * @param props.onCallUnregisteredTool - Callback function called when an unregistered tool is called\n * @param props.initialMessages - Initial messages to be included in new threads\n * @param props.getContextHelperData - Optional function to customize the data sent to the AI for each context attachment\n * @returns The TamboProvider component\n */\nexport const TamboProvider: React.FC<\n PropsWithChildren<\n TamboClientProviderProps &\n TamboRegistryProviderProps &\n TamboThreadProviderProps &\n TamboContextHelpersProviderProps &\n TamboThreadInputProviderProps &\n Partial<Pick<TamboContextAttachmentProviderProps, \"getContextHelperData\">>\n >\n> = ({\n children,\n tamboUrl,\n apiKey,\n userToken,\n components,\n environment,\n tools,\n streaming,\n autoGenerateThreadName,\n autoGenerateNameThreshold,\n contextHelpers,\n contextKey,\n initialMessages,\n onCallUnregisteredTool,\n getContextHelperData,\n}) => {\n return (\n <TamboClientProvider\n tamboUrl={tamboUrl}\n apiKey={apiKey}\n environment={environment}\n userToken={userToken}\n >\n <TamboRegistryProvider\n components={components}\n tools={tools}\n onCallUnregisteredTool={onCallUnregisteredTool}\n >\n <TamboContextHelpersProvider contextHelpers={contextHelpers}>\n <TamboMcpTokenProvider>\n <TamboThreadProvider\n streaming={streaming}\n autoGenerateThreadName={autoGenerateThreadName}\n autoGenerateNameThreshold={autoGenerateNameThreshold}\n initialMessages={initialMessages}\n >\n <TamboThreadInputProvider contextKey={contextKey}>\n <TamboContextAttachmentProvider\n getContextHelperData={getContextHelperData}\n >\n <TamboComponentProvider>\n <TamboInteractableProvider>\n <TamboCompositeProvider>\n {children}\n </TamboCompositeProvider>\n </TamboInteractableProvider>\n </TamboComponentProvider>\n </TamboContextAttachmentProvider>\n </TamboThreadInputProvider>\n </TamboThreadProvider>\n </TamboMcpTokenProvider>\n </TamboContextHelpersProvider>\n </TamboRegistryProvider>\n </TamboClientProvider>\n );\n};\n\nexport type TamboContextProps = TamboClientContextProps &\n TamboThreadContextProps &\n TamboGenerationStageContextProps &\n TamboComponentContextProps &\n TamboInteractableContext &\n TamboContextHelpersContextProps &\n ContextAttachmentState;\n\nexport const TamboContext = createContext<TamboContextProps>(\n {} as TamboContextProps,\n);\n\n/**\n * TamboCompositeProvider is a provider that combines the TamboClient,\n * TamboThread, TamboComponent, and TamboInteractable providers\n * @param props - The props for the TamboCompositeProvider\n * @param props.children - The children to wrap\n * @returns The wrapped component\n */\nexport const TamboCompositeProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const threads = useTamboThread();\n const client = useTamboClient();\n const queryClient = useTamboQueryClient();\n const isUpdatingToken = useIsTamboTokenUpdating();\n const componentRegistry = useTamboComponent();\n const interactableComponents = useTamboInteractable();\n const contextHelpers = useTamboContextHelpers();\n const contextAttachment = useTamboContextAttachment();\n\n return (\n <TamboContext.Provider\n value={{\n client,\n queryClient,\n isUpdatingToken,\n ...componentRegistry,\n ...threads,\n ...interactableComponents,\n ...contextHelpers,\n ...contextAttachment,\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, the current thread context,\n * and interactable component management.\n * @returns The Tambo API\n */\nexport const useTambo = () => {\n return useContext(TamboContext);\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-stubs.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-stubs.tsx"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAE/C,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAa,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMpD,OAAO,EAEL,gCAAgC,EACjC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,kBAAkB,CAAC;AAQ1B;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,OAAO,CAAC,iBAAiB,CAAC;IACxE,2CAA2C;IAC3C,M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K,CAAC,EAAE,SAAS,EAAE,CAAC;IACpB,sFAAsF;IACtF,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC9D,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,cAAc,CAAC,EAAE,gCAAgC,CAAC,gBAAgB,CAAC,CAAC;CACrE;AA4JD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CACtC,iBAAiB,CAAC,sBAAsB,CAAC,CAsH1C,CAAC"}
@@ -4,7 +4,9 @@ import React, { useEffect } from "react";
4
4
  import { GenerationStage } from "../model/generate-component-response";
5
5
  import { TamboClientContext } from "./tambo-client-provider";
6
6
  import { TamboComponentProvider, } from "./tambo-component-provider";
7
+ import { TamboContextAttachmentProvider } from "./tambo-context-attachment-provider";
7
8
  import { TamboContextHelpersProvider, } from "./tambo-context-helpers-provider";
9
+ import { TamboInteractableProvider } from "./tambo-interactable-provider";
8
10
  import { TamboCompositeProvider, } from "./tambo-provider";
9
11
  import { TamboRegistryContext } from "./tambo-registry-provider";
10
12
  import { TamboGenerationStageProvider, TamboThreadContext, } from "./tambo-thread-provider";
@@ -212,7 +214,9 @@ export const TamboStubProvider = ({ children, thread, components = [], tools = [
212
214
  React.createElement(TamboStubRegistryProvider, { componentList: componentList, toolRegistry: toolRegistry, componentToolAssociations: componentToolAssociations, registerComponent: componentContextProps.registerComponent, registerTool: componentContextProps.registerTool, registerTools: componentContextProps.registerTools, addToolAssociation: componentContextProps.addToolAssociation },
213
215
  React.createElement(TamboStubThreadProvider, { ...threadContextProps },
214
216
  React.createElement(TamboContextHelpersProvider, { contextHelpers: contextHelpers },
215
- React.createElement(TamboComponentProvider, null,
216
- React.createElement(TamboCompositeProvider, null, children)))))));
217
+ React.createElement(TamboContextAttachmentProvider, null,
218
+ React.createElement(TamboComponentProvider, null,
219
+ React.createElement(TamboInteractableProvider, null,
220
+ React.createElement(TamboCompositeProvider, null, children)))))))));
217
221
  };
218
222
  //# sourceMappingURL=tambo-stubs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-stubs.js","sourceRoot":"","sources":["../../src/providers/tambo-stubs.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,EAAqB,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAEL,sBAAsB,GACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,2BAA2B,GAE5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,sBAAsB,GAEvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,GAEnB,MAAM,yBAAyB,CAAC;AAsBjC;;;GAGG;AACH,MAAM,uBAAuB,GASzB,CAAC,EACH,QAAQ,EACR,MAAM,EACN,WAAW,EACX,OAAO,EACP,SAAS,EACT,UAAU,EACV,eAAe,GAChB,EAAE,EAAE;IACH,4DAA4D;IAC5D,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,EAAE,CAAC;YACZ,kCAAkC;YAClC,WAAW,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC,CAAC;YAEnD,2FAA2F;YAC3F,WAAW,CAAC,YAAY,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,OAAO,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AAM,EAAE,UAAU,EAClB,WAAW,EAAE,eAAe,EAC5B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,iBAAiB,EAC5B,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,KAAK;QAEtB,oBAAC,yBAAyB,IACxB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,EAC1B,yBAAyB,EAAE,yBAAyB,EACpD,iBAAiB,EAAE,qBAAqB,CAAC,iBAAiB,EAC1D,YAAY,EAAE,qBAAqB,CAAC,YAAY,EAChD,aAAa,EAAE,qBAAqB,CAAC,aAAa,EAClD,kBAAkB,EAAE,qBAAqB,CAAC,kBAAkB;YAE5D,oBAAC,uBAAuB,OAAK,kBAAkB;gBAC7C,oBAAC,2BAA2B,IAAC,cAAc,EAAE,cAAc;oBACzD,oBAAC,sBAAsB;wBACrB,oBAAC,sBAAsB,QAAE,QAAQ,CAA0B,CACpC,CACG,CACN,CACA,CACJ,CAC3B,CAAC;AACJ,CAAC,CAAC","sourcesContent":["\"use client\";\nimport TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport React, { PropsWithChildren, useEffect } from \"react\";\nimport { TamboComponent, TamboTool } from \"../model/component-metadata\";\nimport { GenerationStage } from \"../model/generate-component-response\";\nimport { TamboThread } from \"../model/tambo-thread\";\nimport { TamboClientContext } from \"./tambo-client-provider\";\nimport {\n TamboComponentContextProps,\n TamboComponentProvider,\n} from \"./tambo-component-provider\";\nimport {\n TamboContextHelpersProvider,\n TamboContextHelpersProviderProps,\n} from \"./tambo-context-helpers-provider\";\nimport {\n TamboCompositeProvider,\n type TamboContextProps,\n} from \"./tambo-provider\";\nimport { TamboRegistryContext } from \"./tambo-registry-provider\";\nimport {\n TamboGenerationStageProvider,\n TamboThreadContext,\n TamboThreadContextProps,\n} from \"./tambo-thread-provider\";\n\n/**\n * TamboStubProvider props - includes all the data that would normally be inferred\n */\nexport interface TamboStubProviderProps extends Partial<TamboContextProps> {\n /** Required: The thread data to display */\n thread: TamboThread;\n /** Optional: Components registry - defaults to empty */\n components?: TamboComponent[];\n /** Optional: Tools registry - defaults to empty */\n tools?: TamboTool[];\n /** Optional: Threads data to populate thread list - overrides useTamboThreadList() */\n threads?: Partial<TamboAI.Beta.Threads.ThreadsOffsetAndLimit>;\n /** Optional: Project ID to use for query cache - defaults to thread.projectId */\n projectId?: string;\n /** Optional: Context key for thread list queries */\n contextKey?: string;\n /** Optional: Configuration for which context helpers are enabled/disabled */\n contextHelpers?: TamboContextHelpersProviderProps[\"contextHelpers\"];\n}\n\n/**\n * Stub client provider that accepts a client and queryClient as props\n * @returns The TamboStubClientProvider component\n */\nconst TamboStubClientProvider: React.FC<\n PropsWithChildren<{\n client: TamboAI;\n queryClient: QueryClient;\n isUpdatingToken: boolean;\n threads?: Partial<TamboAI.Beta.Threads.ThreadsOffsetAndLimit>;\n projectId?: string;\n contextKey?: string;\n }>\n> = ({\n children,\n client,\n queryClient,\n threads,\n projectId,\n contextKey,\n isUpdatingToken,\n}) => {\n // Prepopulate the query cache with threads data if provided\n useEffect(() => {\n if (threads) {\n // Set the project ID in the cache\n queryClient.setQueryData([\"projectId\"], projectId);\n\n // Set the threads data in the cache using the same query key pattern as useTamboThreadList\n queryClient.setQueryData([\"threads\", projectId, contextKey], threads);\n }\n }, [threads, projectId, contextKey, queryClient]);\n\n return (\n <TamboClientContext.Provider\n value={{ client, queryClient, isUpdatingToken }}\n >\n {children}\n </TamboClientContext.Provider>\n );\n};\n\n/**\n * Stub registry provider that accepts componentList, toolRegistry, and componentToolAssociations as props\n * @returns The TamboStubRegistryProvider component\n */\nconst TamboStubRegistryProvider: React.FC<\n PropsWithChildren<{\n componentList: Record<string, any>;\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> = ({\n children,\n componentList,\n toolRegistry,\n componentToolAssociations,\n registerComponent,\n registerTool,\n registerTools,\n addToolAssociation,\n}) => {\n return (\n <TamboRegistryContext.Provider\n value={{\n componentList,\n toolRegistry,\n componentToolAssociations,\n registerComponent,\n registerTool,\n registerTools,\n addToolAssociation,\n }}\n >\n {children}\n </TamboRegistryContext.Provider>\n );\n};\n\n/**\n * Stub thread provider that accepts all thread context props\n * @returns The TamboStubThreadProvider component\n */\nconst TamboStubThreadProvider: React.FC<\n PropsWithChildren<TamboThreadContextProps>\n> = ({ children, ...threadContextProps }) => {\n // Extract generation stage info from the thread\n const generationStage =\n (threadContextProps.thread?.generationStage as GenerationStage) ??\n GenerationStage.IDLE;\n const statusMessage = threadContextProps.thread?.statusMessage ?? \"\";\n\n return (\n <TamboThreadContext.Provider value={threadContextProps}>\n <TamboGenerationStageProvider\n generationStage={generationStage}\n statusMessage={statusMessage}\n >\n {children}\n </TamboGenerationStageProvider>\n </TamboThreadContext.Provider>\n );\n};\n\n/**\n * Default no-op functions that throw errors - used when callbacks are not provided\n * @returns The default callbacks\n */\nconst createDefaultCallbacks = () => ({\n switchCurrentThread: () => {\n throw new Error(\"switchCurrentThread not implemented in stub\");\n },\n startNewThread: () => {\n throw new Error(\"startNewThread not implemented in stub\");\n },\n updateThreadName: () => {\n throw new Error(\"updateThreadName not implemented in stub\");\n },\n generateThreadName: () => {\n throw new Error(\"generateThreadName not implemented in stub\");\n },\n addThreadMessage: () => {\n throw new Error(\"addThreadMessage not implemented in stub\");\n },\n updateThreadMessage: () => {\n throw new Error(\"updateThreadMessage not implemented in stub\");\n },\n setInputValue: () => {\n throw new Error(\"setInputValue not implemented in stub\");\n },\n sendThreadMessage: () => {\n throw new Error(\"sendThreadMessage not implemented in stub\");\n },\n registerComponent: () => {\n throw new Error(\"registerComponent not implemented in stub\");\n },\n registerTool: () => {\n throw new Error(\"registerTool not implemented in stub\");\n },\n registerTools: () => {\n throw new Error(\"registerTools not implemented in stub\");\n },\n addToolAssociation: () => {\n throw new Error(\"addToolAssociation not implemented in stub\");\n },\n cancel: () => {\n throw new Error(\"cancel not implemented in stub\");\n },\n});\n\n/**\n * The TamboStubProvider provides a way to use the Tambo API with static/stub data.\n * This is useful for testing, samples, and static UI development.\n *\n * Unlike TamboProvider, all data must be provided as props rather than being inferred.\n * @example\n * ```tsx\n * import { TamboStubProvider } from '@tambo-ai/react-sdk';\n *\n * const exampleThread = {\n * id: \"example-thread\",\n * messages: [\n * {\n * id: \"msg-1\",\n * role: \"user\",\n * content: [{ type: \"text\", text: \"Hello!\" }],\n * createdAt: new Date().toISOString(),\n * threadId: \"example-thread\",\n * componentState: {},\n * },\n * {\n * id: \"msg-2\",\n * role: \"assistant\",\n * content: [{ type: \"text\", text: \"Hi there!\" }],\n * createdAt: new Date().toISOString(),\n * threadId: \"example-thread\",\n * componentState: {},\n * }\n * ],\n * createdAt: new Date().toISOString(),\n * projectId: \"example-project\",\n * updatedAt: new Date().toISOString(),\n * metadata: {},\n * };\n *\n * const exampleThreadList = [exampleThread];\n *\n * function MyComponent() {\n * return (\n * <TamboStubProvider\n * thread={exampleThread}\n * components={[]}\n * tools={[]}\n * threads={exampleThreadList}\n * projectId=\"example-project\"\n * >\n * <MessageThreadFull />\n * </TamboStubProvider>\n * );\n * }\n * ```\n * @param props - The props for the TamboStubProvider\n * @param props.children - The children to wrap\n * @param props.thread - The thread data to display\n * @param props.components - Optional components registry\n * @param props.tools - Optional tools registry\n * @param props.threads - Optional threads data to populate thread list (overrides useTamboThreadList)\n * @param props.projectId - Optional project ID for query cache (defaults to thread.projectId)\n * @param props.contextKey - Optional context key for thread list queries\n * @param props.contextHelpers - Optional configuration for which context helpers are enabled/disabled\n * @returns The TamboStubProvider component\n */\nexport const TamboStubProvider: React.FC<\n PropsWithChildren<TamboStubProviderProps>\n> = ({\n children,\n thread,\n components = [],\n tools = [],\n threads,\n projectId,\n contextKey,\n contextHelpers,\n ...overrides\n}) => {\n const defaults = createDefaultCallbacks();\n\n // Create stub client and queryClient\n const stubClient = {} as TamboAI;\n const stubQueryClient = new QueryClient();\n\n // Use provided projectId or fall back to thread's projectId\n const resolvedProjectId = projectId ?? thread.projectId;\n\n // Build component registry from components prop\n const componentList = components.reduce(\n (acc, component) => {\n acc[component.name] = {\n component: component.component,\n loadingComponent: component.loadingComponent,\n name: component.name,\n description: component.description,\n props: component.propsDefinition ?? {},\n contextTools: [],\n };\n return acc;\n },\n {} as Record<string, any>,\n );\n\n // Build tool registry from tools prop\n const toolRegistry = tools.reduce(\n (acc, tool) => {\n acc[tool.name] = tool;\n return acc;\n },\n {} as Record<string, TamboTool>,\n );\n\n // Build tool associations from components\n const componentToolAssociations = components.reduce(\n (acc, component) => {\n if (component.associatedTools) {\n acc[component.name] = component.associatedTools.map(\n (tool) => tool.name,\n );\n }\n return acc;\n },\n {} as Record<string, string[]>,\n );\n\n // Merge defaults with provided overrides\n const threadContextProps: TamboThreadContextProps = {\n thread,\n switchCurrentThread:\n overrides.switchCurrentThread ?? defaults.switchCurrentThread,\n startNewThread: overrides.startNewThread ?? defaults.startNewThread,\n updateThreadName: overrides.updateThreadName ?? defaults.updateThreadName,\n generateThreadName:\n overrides.generateThreadName ?? defaults.generateThreadName,\n addThreadMessage: overrides.addThreadMessage ?? defaults.addThreadMessage,\n updateThreadMessage:\n overrides.updateThreadMessage ?? defaults.updateThreadMessage,\n streaming: overrides.streaming ?? true,\n sendThreadMessage:\n overrides.sendThreadMessage ?? defaults.sendThreadMessage,\n cancel: overrides.cancel ?? defaults.cancel,\n };\n\n const componentContextProps: TamboComponentContextProps = {\n registerComponent:\n overrides.registerComponent ?? defaults.registerComponent,\n registerTool: overrides.registerTool ?? defaults.registerTool,\n registerTools: overrides.registerTools ?? defaults.registerTools,\n addToolAssociation:\n overrides.addToolAssociation ?? defaults.addToolAssociation,\n };\n\n return (\n <TamboStubClientProvider\n client={stubClient}\n queryClient={stubQueryClient}\n threads={threads}\n projectId={resolvedProjectId}\n contextKey={contextKey}\n isUpdatingToken={false}\n >\n <TamboStubRegistryProvider\n componentList={componentList}\n toolRegistry={toolRegistry}\n componentToolAssociations={componentToolAssociations}\n registerComponent={componentContextProps.registerComponent}\n registerTool={componentContextProps.registerTool}\n registerTools={componentContextProps.registerTools}\n addToolAssociation={componentContextProps.addToolAssociation}\n >\n <TamboStubThreadProvider {...threadContextProps}>\n <TamboContextHelpersProvider contextHelpers={contextHelpers}>\n <TamboComponentProvider>\n <TamboCompositeProvider>{children}</TamboCompositeProvider>\n </TamboComponentProvider>\n </TamboContextHelpersProvider>\n </TamboStubThreadProvider>\n </TamboStubRegistryProvider>\n </TamboStubClientProvider>\n );\n};\n"]}
1
+ {"version":3,"file":"tambo-stubs.js","sourceRoot":"","sources":["../../src/providers/tambo-stubs.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,EAAqB,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAEL,sBAAsB,GACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EACL,2BAA2B,GAE5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EACL,sBAAsB,GAEvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,GAEnB,MAAM,yBAAyB,CAAC;AAsBjC;;;GAGG;AACH,MAAM,uBAAuB,GASzB,CAAC,EACH,QAAQ,EACR,MAAM,EACN,WAAW,EACX,OAAO,EACP,SAAS,EACT,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,SAAS,CAAC,iBAAiB,IAAI,QAAQ,CAAC,iBAAiB;QAC3D,YAAY,EAAE,SAAS,CAAC,YAAY,IAAI,QAAQ,CAAC,YAAY;QAC7D,aAAa,EAAE,SAAS,CAAC,aAAa,IAAI,QAAQ,CAAC,aAAa;QAChE,kBAAkB,EAChB,SAAS,CAAC,kBAAkB,IAAI,QAAQ,CAAC,kBAAkB;KAC9D,CAAC;IAEF,OAAO,CACL,oBAAC,uBAAuB,IACtB,MAAM,EAAE,UAAU,EAClB,WAAW,EAAE,eAAe,EAC5B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,iBAAiB,EAC5B,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,KAAK;QAEtB,oBAAC,yBAAyB,IACxB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,EAC1B,yBAAyB,EAAE,yBAAyB,EACpD,iBAAiB,EAAE,qBAAqB,CAAC,iBAAiB,EAC1D,YAAY,EAAE,qBAAqB,CAAC,YAAY,EAChD,aAAa,EAAE,qBAAqB,CAAC,aAAa,EAClD,kBAAkB,EAAE,qBAAqB,CAAC,kBAAkB;YAE5D,oBAAC,uBAAuB,OAAK,kBAAkB;gBAC7C,oBAAC,2BAA2B,IAAC,cAAc,EAAE,cAAc;oBACzD,oBAAC,8BAA8B;wBAC7B,oBAAC,sBAAsB;4BACrB,oBAAC,yBAAyB;gCACxB,oBAAC,sBAAsB,QAAE,QAAQ,CAA0B,CACjC,CACL,CACM,CACL,CACN,CACA,CACJ,CAC3B,CAAC;AACJ,CAAC,CAAC","sourcesContent":["\"use client\";\nimport TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport React, { PropsWithChildren, useEffect } from \"react\";\nimport { TamboComponent, TamboTool } from \"../model/component-metadata\";\nimport { GenerationStage } from \"../model/generate-component-response\";\nimport { TamboThread } from \"../model/tambo-thread\";\nimport { TamboClientContext } from \"./tambo-client-provider\";\nimport {\n TamboComponentContextProps,\n TamboComponentProvider,\n} from \"./tambo-component-provider\";\nimport { TamboContextAttachmentProvider } from \"./tambo-context-attachment-provider\";\nimport {\n TamboContextHelpersProvider,\n TamboContextHelpersProviderProps,\n} from \"./tambo-context-helpers-provider\";\nimport { TamboInteractableProvider } from \"./tambo-interactable-provider\";\nimport {\n TamboCompositeProvider,\n type TamboContextProps,\n} from \"./tambo-provider\";\nimport { TamboRegistryContext } from \"./tambo-registry-provider\";\nimport {\n TamboGenerationStageProvider,\n TamboThreadContext,\n TamboThreadContextProps,\n} from \"./tambo-thread-provider\";\n\n/**\n * TamboStubProvider props - includes all the data that would normally be inferred\n */\nexport interface TamboStubProviderProps extends Partial<TamboContextProps> {\n /** Required: The thread data to display */\n thread: TamboThread;\n /** Optional: Components registry - defaults to empty */\n components?: TamboComponent[];\n /** Optional: Tools registry - defaults to empty */\n tools?: TamboTool[];\n /** Optional: Threads data to populate thread list - overrides useTamboThreadList() */\n threads?: Partial<TamboAI.Beta.Threads.ThreadsOffsetAndLimit>;\n /** Optional: Project ID to use for query cache - defaults to thread.projectId */\n projectId?: string;\n /** Optional: Context key for thread list queries */\n contextKey?: string;\n /** Optional: Configuration for which context helpers are enabled/disabled */\n contextHelpers?: TamboContextHelpersProviderProps[\"contextHelpers\"];\n}\n\n/**\n * Stub client provider that accepts a client and queryClient as props\n * @returns The TamboStubClientProvider component\n */\nconst TamboStubClientProvider: React.FC<\n PropsWithChildren<{\n client: TamboAI;\n queryClient: QueryClient;\n isUpdatingToken: boolean;\n threads?: Partial<TamboAI.Beta.Threads.ThreadsOffsetAndLimit>;\n projectId?: string;\n contextKey?: string;\n }>\n> = ({\n children,\n client,\n queryClient,\n threads,\n projectId,\n contextKey,\n isUpdatingToken,\n}) => {\n // Prepopulate the query cache with threads data if provided\n useEffect(() => {\n if (threads) {\n // Set the project ID in the cache\n queryClient.setQueryData([\"projectId\"], projectId);\n\n // Set the threads data in the cache using the same query key pattern as useTamboThreadList\n queryClient.setQueryData([\"threads\", projectId, contextKey], threads);\n }\n }, [threads, projectId, contextKey, queryClient]);\n\n return (\n <TamboClientContext.Provider\n value={{ client, queryClient, isUpdatingToken }}\n >\n {children}\n </TamboClientContext.Provider>\n );\n};\n\n/**\n * Stub registry provider that accepts componentList, toolRegistry, and componentToolAssociations as props\n * @returns The TamboStubRegistryProvider component\n */\nconst TamboStubRegistryProvider: React.FC<\n PropsWithChildren<{\n componentList: Record<string, any>;\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> = ({\n children,\n componentList,\n toolRegistry,\n componentToolAssociations,\n registerComponent,\n registerTool,\n registerTools,\n addToolAssociation,\n}) => {\n return (\n <TamboRegistryContext.Provider\n value={{\n componentList,\n toolRegistry,\n componentToolAssociations,\n registerComponent,\n registerTool,\n registerTools,\n addToolAssociation,\n }}\n >\n {children}\n </TamboRegistryContext.Provider>\n );\n};\n\n/**\n * Stub thread provider that accepts all thread context props\n * @returns The TamboStubThreadProvider component\n */\nconst TamboStubThreadProvider: React.FC<\n PropsWithChildren<TamboThreadContextProps>\n> = ({ children, ...threadContextProps }) => {\n // Extract generation stage info from the thread\n const generationStage =\n (threadContextProps.thread?.generationStage as GenerationStage) ??\n GenerationStage.IDLE;\n const statusMessage = threadContextProps.thread?.statusMessage ?? \"\";\n\n return (\n <TamboThreadContext.Provider value={threadContextProps}>\n <TamboGenerationStageProvider\n generationStage={generationStage}\n statusMessage={statusMessage}\n >\n {children}\n </TamboGenerationStageProvider>\n </TamboThreadContext.Provider>\n );\n};\n\n/**\n * Default no-op functions that throw errors - used when callbacks are not provided\n * @returns The default callbacks\n */\nconst createDefaultCallbacks = () => ({\n switchCurrentThread: () => {\n throw new Error(\"switchCurrentThread not implemented in stub\");\n },\n startNewThread: () => {\n throw new Error(\"startNewThread not implemented in stub\");\n },\n updateThreadName: () => {\n throw new Error(\"updateThreadName not implemented in stub\");\n },\n generateThreadName: () => {\n throw new Error(\"generateThreadName not implemented in stub\");\n },\n addThreadMessage: () => {\n throw new Error(\"addThreadMessage not implemented in stub\");\n },\n updateThreadMessage: () => {\n throw new Error(\"updateThreadMessage not implemented in stub\");\n },\n setInputValue: () => {\n throw new Error(\"setInputValue not implemented in stub\");\n },\n sendThreadMessage: () => {\n throw new Error(\"sendThreadMessage not implemented in stub\");\n },\n registerComponent: () => {\n throw new Error(\"registerComponent not implemented in stub\");\n },\n registerTool: () => {\n throw new Error(\"registerTool not implemented in stub\");\n },\n registerTools: () => {\n throw new Error(\"registerTools not implemented in stub\");\n },\n addToolAssociation: () => {\n throw new Error(\"addToolAssociation not implemented in stub\");\n },\n cancel: () => {\n throw new Error(\"cancel not implemented in stub\");\n },\n});\n\n/**\n * The TamboStubProvider provides a way to use the Tambo API with static/stub data.\n * This is useful for testing, samples, and static UI development.\n *\n * Unlike TamboProvider, all data must be provided as props rather than being inferred.\n * @example\n * ```tsx\n * import { TamboStubProvider } from '@tambo-ai/react-sdk';\n *\n * const exampleThread = {\n * id: \"example-thread\",\n * messages: [\n * {\n * id: \"msg-1\",\n * role: \"user\",\n * content: [{ type: \"text\", text: \"Hello!\" }],\n * createdAt: new Date().toISOString(),\n * threadId: \"example-thread\",\n * componentState: {},\n * },\n * {\n * id: \"msg-2\",\n * role: \"assistant\",\n * content: [{ type: \"text\", text: \"Hi there!\" }],\n * createdAt: new Date().toISOString(),\n * threadId: \"example-thread\",\n * componentState: {},\n * }\n * ],\n * createdAt: new Date().toISOString(),\n * projectId: \"example-project\",\n * updatedAt: new Date().toISOString(),\n * metadata: {},\n * };\n *\n * const exampleThreadList = [exampleThread];\n *\n * function MyComponent() {\n * return (\n * <TamboStubProvider\n * thread={exampleThread}\n * components={[]}\n * tools={[]}\n * threads={exampleThreadList}\n * projectId=\"example-project\"\n * >\n * <MessageThreadFull />\n * </TamboStubProvider>\n * );\n * }\n * ```\n * @param props - The props for the TamboStubProvider\n * @param props.children - The children to wrap\n * @param props.thread - The thread data to display\n * @param props.components - Optional components registry\n * @param props.tools - Optional tools registry\n * @param props.threads - Optional threads data to populate thread list (overrides useTamboThreadList)\n * @param props.projectId - Optional project ID for query cache (defaults to thread.projectId)\n * @param props.contextKey - Optional context key for thread list queries\n * @param props.contextHelpers - Optional configuration for which context helpers are enabled/disabled\n * @returns The TamboStubProvider component\n */\nexport const TamboStubProvider: React.FC<\n PropsWithChildren<TamboStubProviderProps>\n> = ({\n children,\n thread,\n components = [],\n tools = [],\n threads,\n projectId,\n contextKey,\n contextHelpers,\n ...overrides\n}) => {\n const defaults = createDefaultCallbacks();\n\n // Create stub client and queryClient\n const stubClient = {} as TamboAI;\n const stubQueryClient = new QueryClient();\n\n // Use provided projectId or fall back to thread's projectId\n const resolvedProjectId = projectId ?? thread.projectId;\n\n // Build component registry from components prop\n const componentList = components.reduce(\n (acc, component) => {\n acc[component.name] = {\n component: component.component,\n loadingComponent: component.loadingComponent,\n name: component.name,\n description: component.description,\n props: component.propsDefinition ?? {},\n contextTools: [],\n };\n return acc;\n },\n {} as Record<string, any>,\n );\n\n // Build tool registry from tools prop\n const toolRegistry = tools.reduce(\n (acc, tool) => {\n acc[tool.name] = tool;\n return acc;\n },\n {} as Record<string, TamboTool>,\n );\n\n // Build tool associations from components\n const componentToolAssociations = components.reduce(\n (acc, component) => {\n if (component.associatedTools) {\n acc[component.name] = component.associatedTools.map(\n (tool) => tool.name,\n );\n }\n return acc;\n },\n {} as Record<string, string[]>,\n );\n\n // Merge defaults with provided overrides\n const threadContextProps: TamboThreadContextProps = {\n thread,\n switchCurrentThread:\n overrides.switchCurrentThread ?? defaults.switchCurrentThread,\n startNewThread: overrides.startNewThread ?? defaults.startNewThread,\n updateThreadName: overrides.updateThreadName ?? defaults.updateThreadName,\n generateThreadName:\n overrides.generateThreadName ?? defaults.generateThreadName,\n addThreadMessage: overrides.addThreadMessage ?? defaults.addThreadMessage,\n updateThreadMessage:\n overrides.updateThreadMessage ?? defaults.updateThreadMessage,\n streaming: overrides.streaming ?? true,\n sendThreadMessage:\n overrides.sendThreadMessage ?? defaults.sendThreadMessage,\n cancel: overrides.cancel ?? defaults.cancel,\n };\n\n const componentContextProps: TamboComponentContextProps = {\n registerComponent:\n overrides.registerComponent ?? defaults.registerComponent,\n registerTool: overrides.registerTool ?? defaults.registerTool,\n registerTools: overrides.registerTools ?? defaults.registerTools,\n addToolAssociation:\n overrides.addToolAssociation ?? defaults.addToolAssociation,\n };\n\n return (\n <TamboStubClientProvider\n client={stubClient}\n queryClient={stubQueryClient}\n threads={threads}\n projectId={resolvedProjectId}\n contextKey={contextKey}\n isUpdatingToken={false}\n >\n <TamboStubRegistryProvider\n componentList={componentList}\n toolRegistry={toolRegistry}\n componentToolAssociations={componentToolAssociations}\n registerComponent={componentContextProps.registerComponent}\n registerTool={componentContextProps.registerTool}\n registerTools={componentContextProps.registerTools}\n addToolAssociation={componentContextProps.addToolAssociation}\n >\n <TamboStubThreadProvider {...threadContextProps}>\n <TamboContextHelpersProvider contextHelpers={contextHelpers}>\n <TamboContextAttachmentProvider>\n <TamboComponentProvider>\n <TamboInteractableProvider>\n <TamboCompositeProvider>{children}</TamboCompositeProvider>\n </TamboInteractableProvider>\n </TamboComponentProvider>\n </TamboContextAttachmentProvider>\n </TamboContextHelpersProvider>\n </TamboStubThreadProvider>\n </TamboStubRegistryProvider>\n </TamboStubClientProvider>\n );\n};\n"]}
@@ -80,6 +80,10 @@ export interface TamboThreadProviderProps {
80
80
  streaming?: boolean;
81
81
  /** Initial messages to be included in new threads */
82
82
  initialMessages?: InitialTamboThreadMessage[];
83
+ /** Whether to automatically generate thread names. Defaults to true. */
84
+ autoGenerateThreadName?: boolean;
85
+ /** The message count threshold at which the thread name will be auto-generated. Defaults to 3. */
86
+ autoGenerateNameThreshold?: number;
83
87
  }
84
88
  /**
85
89
  * The TamboThreadProvider is a React provider that provides a thread context
@@ -88,6 +92,8 @@ export interface TamboThreadProviderProps {
88
92
  * @param props.children - The children to wrap
89
93
  * @param props.streaming - Whether to stream the response by default. Defaults to true.
90
94
  * @param props.initialMessages - Initial messages to be included in new threads
95
+ * @param props.autoGenerateThreadName - Whether to automatically generate thread names. Defaults to true.
96
+ * @param props.autoGenerateNameThreshold - The message count threshold at which the thread name will be auto-generated. Defaults to 3.
91
97
  * @returns The TamboThreadProvider component
92
98
  */
93
99
  export declare const TamboThreadProvider: React.FC<PropsWithChildren<TamboThreadProviderProps>>;