@tambo-ai/react 0.67.1 → 0.68.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 (164) hide show
  1. package/README.md +2 -4
  2. package/dist/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
  3. package/dist/context-helpers/current-interactables-context-helper.js +4 -1
  4. package/dist/context-helpers/current-interactables-context-helper.js.map +1 -1
  5. package/dist/hoc/with-tambo-interactable.d.ts +50 -4
  6. package/dist/hoc/with-tambo-interactable.d.ts.map +1 -1
  7. package/dist/hoc/with-tambo-interactable.js +20 -5
  8. package/dist/hoc/with-tambo-interactable.js.map +1 -1
  9. package/dist/hooks/use-component-state.d.ts +3 -8
  10. package/dist/hooks/use-component-state.d.ts.map +1 -1
  11. package/dist/hooks/use-component-state.js +8 -0
  12. package/dist/hooks/use-component-state.js.map +1 -1
  13. package/dist/hooks/use-component-state.test.js +37 -0
  14. package/dist/hooks/use-component-state.test.js.map +1 -1
  15. package/dist/hooks/use-tambo-threads.js +1 -1
  16. package/dist/hooks/use-tambo-threads.js.map +1 -1
  17. package/dist/mcp/mcp-constants.d.ts +19 -0
  18. package/dist/mcp/mcp-constants.d.ts.map +1 -0
  19. package/dist/mcp/mcp-constants.js +21 -0
  20. package/dist/mcp/mcp-constants.js.map +1 -0
  21. package/dist/mcp/mcp-hooks.d.ts +32 -3
  22. package/dist/mcp/mcp-hooks.d.ts.map +1 -1
  23. package/dist/mcp/mcp-hooks.js +40 -29
  24. package/dist/mcp/mcp-hooks.js.map +1 -1
  25. package/dist/mcp/mcp-hooks.test.js +8 -5
  26. package/dist/mcp/mcp-hooks.test.js.map +1 -1
  27. package/dist/mcp/tambo-mcp-provider.d.ts +7 -0
  28. package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
  29. package/dist/mcp/tambo-mcp-provider.js +202 -155
  30. package/dist/mcp/tambo-mcp-provider.js.map +1 -1
  31. package/dist/model/component-metadata.d.ts +1 -1
  32. package/dist/model/component-metadata.d.ts.map +1 -1
  33. package/dist/model/component-metadata.js.map +1 -1
  34. package/dist/model/tambo-interactable.d.ts +7 -5
  35. package/dist/model/tambo-interactable.d.ts.map +1 -1
  36. package/dist/model/tambo-interactable.js.map +1 -1
  37. package/dist/providers/__tests__/thread-input-resource-resolution.test.d.ts +2 -0
  38. package/dist/providers/__tests__/thread-input-resource-resolution.test.d.ts.map +1 -0
  39. package/dist/providers/__tests__/thread-input-resource-resolution.test.js +592 -0
  40. package/dist/providers/__tests__/thread-input-resource-resolution.test.js.map +1 -0
  41. package/dist/providers/tambo-interactable-provider-partial-updates.test.js +22 -21
  42. package/dist/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
  43. package/dist/providers/tambo-interactable-provider.d.ts +3 -2
  44. package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
  45. package/dist/providers/tambo-interactable-provider.js +98 -14
  46. package/dist/providers/tambo-interactable-provider.js.map +1 -1
  47. package/dist/providers/tambo-interactable-provider.test.js +242 -0
  48. package/dist/providers/tambo-interactable-provider.test.js.map +1 -1
  49. package/dist/providers/tambo-provider.d.ts.map +1 -1
  50. package/dist/providers/tambo-provider.js +7 -5
  51. package/dist/providers/tambo-provider.js.map +1 -1
  52. package/dist/providers/tambo-thread-input-provider.d.ts.map +1 -1
  53. package/dist/providers/tambo-thread-input-provider.js +21 -3
  54. package/dist/providers/tambo-thread-input-provider.js.map +1 -1
  55. package/dist/schema/index.d.ts +1 -1
  56. package/dist/schema/index.d.ts.map +1 -1
  57. package/dist/schema/index.js +2 -1
  58. package/dist/schema/index.js.map +1 -1
  59. package/dist/schema/json-schema.d.ts +7 -0
  60. package/dist/schema/json-schema.d.ts.map +1 -1
  61. package/dist/schema/json-schema.js +11 -0
  62. package/dist/schema/json-schema.js.map +1 -1
  63. package/dist/schema/json-schema.test.d.ts +2 -0
  64. package/dist/schema/json-schema.test.d.ts.map +1 -0
  65. package/dist/schema/json-schema.test.js +204 -0
  66. package/dist/schema/json-schema.test.js.map +1 -0
  67. package/dist/setupTests.js +3 -0
  68. package/dist/setupTests.js.map +1 -1
  69. package/dist/util/message-builder.d.ts +3 -1
  70. package/dist/util/message-builder.d.ts.map +1 -1
  71. package/dist/util/message-builder.js +20 -3
  72. package/dist/util/message-builder.js.map +1 -1
  73. package/dist/util/message-builder.test.js +269 -0
  74. package/dist/util/message-builder.test.js.map +1 -1
  75. package/dist/util/resource-content-resolver.d.ts +20 -0
  76. package/dist/util/resource-content-resolver.d.ts.map +1 -0
  77. package/dist/util/resource-content-resolver.js +93 -0
  78. package/dist/util/resource-content-resolver.js.map +1 -0
  79. package/dist/util/resource-content-resolver.test.d.ts +2 -0
  80. package/dist/util/resource-content-resolver.test.d.ts.map +1 -0
  81. package/dist/util/resource-content-resolver.test.js +254 -0
  82. package/dist/util/resource-content-resolver.test.js.map +1 -0
  83. package/esm/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
  84. package/esm/context-helpers/current-interactables-context-helper.js +4 -1
  85. package/esm/context-helpers/current-interactables-context-helper.js.map +1 -1
  86. package/esm/hoc/with-tambo-interactable.d.ts +50 -4
  87. package/esm/hoc/with-tambo-interactable.d.ts.map +1 -1
  88. package/esm/hoc/with-tambo-interactable.js +20 -5
  89. package/esm/hoc/with-tambo-interactable.js.map +1 -1
  90. package/esm/hooks/use-component-state.d.ts +3 -8
  91. package/esm/hooks/use-component-state.d.ts.map +1 -1
  92. package/esm/hooks/use-component-state.js +8 -0
  93. package/esm/hooks/use-component-state.js.map +1 -1
  94. package/esm/hooks/use-component-state.test.js +37 -0
  95. package/esm/hooks/use-component-state.test.js.map +1 -1
  96. package/esm/hooks/use-tambo-threads.js +1 -1
  97. package/esm/hooks/use-tambo-threads.js.map +1 -1
  98. package/esm/mcp/mcp-constants.d.ts +19 -0
  99. package/esm/mcp/mcp-constants.d.ts.map +1 -0
  100. package/esm/mcp/mcp-constants.js +18 -0
  101. package/esm/mcp/mcp-constants.js.map +1 -0
  102. package/esm/mcp/mcp-hooks.d.ts +32 -3
  103. package/esm/mcp/mcp-hooks.d.ts.map +1 -1
  104. package/esm/mcp/mcp-hooks.js +40 -30
  105. package/esm/mcp/mcp-hooks.js.map +1 -1
  106. package/esm/mcp/mcp-hooks.test.js +8 -5
  107. package/esm/mcp/mcp-hooks.test.js.map +1 -1
  108. package/esm/mcp/tambo-mcp-provider.d.ts +7 -0
  109. package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
  110. package/esm/mcp/tambo-mcp-provider.js +201 -154
  111. package/esm/mcp/tambo-mcp-provider.js.map +1 -1
  112. package/esm/model/component-metadata.d.ts +1 -1
  113. package/esm/model/component-metadata.d.ts.map +1 -1
  114. package/esm/model/component-metadata.js.map +1 -1
  115. package/esm/model/tambo-interactable.d.ts +7 -5
  116. package/esm/model/tambo-interactable.d.ts.map +1 -1
  117. package/esm/model/tambo-interactable.js.map +1 -1
  118. package/esm/providers/__tests__/thread-input-resource-resolution.test.d.ts +2 -0
  119. package/esm/providers/__tests__/thread-input-resource-resolution.test.d.ts.map +1 -0
  120. package/esm/providers/__tests__/thread-input-resource-resolution.test.js +587 -0
  121. package/esm/providers/__tests__/thread-input-resource-resolution.test.js.map +1 -0
  122. package/esm/providers/tambo-interactable-provider-partial-updates.test.js +22 -21
  123. package/esm/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
  124. package/esm/providers/tambo-interactable-provider.d.ts +3 -2
  125. package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
  126. package/esm/providers/tambo-interactable-provider.js +98 -14
  127. package/esm/providers/tambo-interactable-provider.js.map +1 -1
  128. package/esm/providers/tambo-interactable-provider.test.js +242 -0
  129. package/esm/providers/tambo-interactable-provider.test.js.map +1 -1
  130. package/esm/providers/tambo-provider.d.ts.map +1 -1
  131. package/esm/providers/tambo-provider.js +7 -5
  132. package/esm/providers/tambo-provider.js.map +1 -1
  133. package/esm/providers/tambo-thread-input-provider.d.ts.map +1 -1
  134. package/esm/providers/tambo-thread-input-provider.js +21 -3
  135. package/esm/providers/tambo-thread-input-provider.js.map +1 -1
  136. package/esm/schema/index.d.ts +1 -1
  137. package/esm/schema/index.d.ts.map +1 -1
  138. package/esm/schema/index.js +1 -1
  139. package/esm/schema/index.js.map +1 -1
  140. package/esm/schema/json-schema.d.ts +7 -0
  141. package/esm/schema/json-schema.d.ts.map +1 -1
  142. package/esm/schema/json-schema.js +10 -0
  143. package/esm/schema/json-schema.js.map +1 -1
  144. package/esm/schema/json-schema.test.d.ts +2 -0
  145. package/esm/schema/json-schema.test.d.ts.map +1 -0
  146. package/esm/schema/json-schema.test.js +202 -0
  147. package/esm/schema/json-schema.test.js.map +1 -0
  148. package/esm/setupTests.js +3 -0
  149. package/esm/setupTests.js.map +1 -1
  150. package/esm/util/message-builder.d.ts +3 -1
  151. package/esm/util/message-builder.d.ts.map +1 -1
  152. package/esm/util/message-builder.js +20 -3
  153. package/esm/util/message-builder.js.map +1 -1
  154. package/esm/util/message-builder.test.js +269 -0
  155. package/esm/util/message-builder.test.js.map +1 -1
  156. package/esm/util/resource-content-resolver.d.ts +20 -0
  157. package/esm/util/resource-content-resolver.d.ts.map +1 -0
  158. package/esm/util/resource-content-resolver.js +89 -0
  159. package/esm/util/resource-content-resolver.js.map +1 -0
  160. package/esm/util/resource-content-resolver.test.d.ts +2 -0
  161. package/esm/util/resource-content-resolver.test.d.ts.map +1 -0
  162. package/esm/util/resource-content-resolver.test.js +252 -0
  163. package/esm/util/resource-content-resolver.test.js.map +1 -0
  164. package/package.json +1 -1
@@ -54,4 +54,246 @@ describe("TamboInteractableProvider - State Tracking", () => {
54
54
  expect(state).toEqual({ count: 10 });
55
55
  });
56
56
  });
57
+ describe("TamboInteractableProvider - State Update Tool Registration", () => {
58
+ beforeEach(() => {
59
+ jest.clearAllMocks();
60
+ });
61
+ const wrapper = ({ children }) => (React.createElement(TamboInteractableProvider, null, children));
62
+ it("should register both prop and state update tools when component is added", () => {
63
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
64
+ const component = {
65
+ name: "TestComponent",
66
+ description: "A test component",
67
+ component: () => React.createElement("div", null, "Test"),
68
+ props: { title: "Test" },
69
+ propsSchema: z.object({ title: z.string() }),
70
+ };
71
+ let componentId = "";
72
+ act(() => {
73
+ componentId = result.current.addInteractableComponent(component);
74
+ });
75
+ // Should register both update_component_ and update_component_state_ tools
76
+ const registeredToolNames = mockRegisterTool.mock.calls.map((call) => call[0].name);
77
+ expect(registeredToolNames).toContain(`update_component_${componentId}`);
78
+ expect(registeredToolNames).toContain(`update_component_state_${componentId}`);
79
+ });
80
+ it("should register state update tool with correct description", () => {
81
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
82
+ const component = {
83
+ name: "MyComponent",
84
+ description: "A test component",
85
+ component: () => React.createElement("div", null, "Test"),
86
+ props: {},
87
+ };
88
+ let componentId = "";
89
+ act(() => {
90
+ componentId = result.current.addInteractableComponent(component);
91
+ });
92
+ const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
93
+ expect(stateToolCall).toBeDefined();
94
+ expect(stateToolCall[0].description).toContain(componentId);
95
+ expect(stateToolCall[0].description).toContain("MyComponent");
96
+ });
97
+ it("should allow state update tool to update multiple state values", () => {
98
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
99
+ const component = {
100
+ name: "TestComponent",
101
+ description: "A test component",
102
+ component: () => React.createElement("div", null, "Test"),
103
+ props: {},
104
+ };
105
+ let componentId = "";
106
+ act(() => {
107
+ componentId = result.current.addInteractableComponent(component);
108
+ });
109
+ // Find the state update tool and call it
110
+ const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
111
+ const toolFn = stateToolCall[0].tool;
112
+ act(() => {
113
+ toolFn({ componentId, newState: { count: 5, name: "test" } });
114
+ });
115
+ const state = result.current.getInteractableComponentState(componentId);
116
+ expect(state).toEqual({ count: 5, name: "test" });
117
+ });
118
+ it("should preserve existing state when updating partial state", () => {
119
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
120
+ const component = {
121
+ name: "TestComponent",
122
+ description: "A test component",
123
+ component: () => React.createElement("div", null, "Test"),
124
+ props: {},
125
+ };
126
+ let componentId = "";
127
+ act(() => {
128
+ componentId = result.current.addInteractableComponent(component);
129
+ });
130
+ // Set initial state
131
+ act(() => {
132
+ result.current.setInteractableState(componentId, "existingKey", "value1");
133
+ });
134
+ // Find the state update tool and call it with a new key
135
+ const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
136
+ const toolFn = stateToolCall[0].tool;
137
+ act(() => {
138
+ toolFn({ componentId, newState: { newKey: "value2" } });
139
+ });
140
+ const state = result.current.getInteractableComponentState(componentId);
141
+ expect(state).toEqual({ existingKey: "value1", newKey: "value2" });
142
+ });
143
+ it("should use stateSchema when provided for tool registration", () => {
144
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
145
+ const stateSchema = z.object({
146
+ count: z.number(),
147
+ name: z.string(),
148
+ });
149
+ const component = {
150
+ name: "TestComponent",
151
+ description: "A test component",
152
+ component: () => React.createElement("div", null, "Test"),
153
+ props: {},
154
+ stateSchema,
155
+ };
156
+ act(() => {
157
+ result.current.addInteractableComponent(component);
158
+ });
159
+ // Find the state update tool
160
+ const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
161
+ expect(stateToolCall).toBeDefined();
162
+ // The inputSchema should contain the partial stateSchema
163
+ expect(stateToolCall[0].inputSchema).toBeDefined();
164
+ });
165
+ it("should return warning when updating state with empty object", () => {
166
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
167
+ const component = {
168
+ name: "TestComponent",
169
+ description: "A test component",
170
+ component: () => React.createElement("div", null, "Test"),
171
+ props: {},
172
+ };
173
+ let componentId = "";
174
+ act(() => {
175
+ componentId = result.current.addInteractableComponent(component);
176
+ });
177
+ // Find the state update tool and call it with empty state
178
+ const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
179
+ const toolFn = stateToolCall[0].tool;
180
+ let updateResult = "";
181
+ act(() => {
182
+ updateResult = toolFn({ componentId, newState: {} });
183
+ });
184
+ expect(updateResult).toContain("Warning");
185
+ expect(updateResult).toContain("No state values provided");
186
+ });
187
+ it("should preserve stateSchema in interactable component", () => {
188
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
189
+ const stateSchema = z.object({
190
+ count: z.number(),
191
+ });
192
+ const component = {
193
+ name: "TestComponent",
194
+ description: "A test component",
195
+ component: () => React.createElement("div", null, "Test"),
196
+ props: {},
197
+ stateSchema,
198
+ };
199
+ let componentId = "";
200
+ act(() => {
201
+ componentId = result.current.addInteractableComponent(component);
202
+ });
203
+ const interactable = result.current.getInteractableComponent(componentId);
204
+ expect(interactable?.stateSchema).toBe(stateSchema);
205
+ });
206
+ it("should convert stateSchema to partial JSON Schema (no required fields)", () => {
207
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
208
+ const stateSchema = z.object({
209
+ count: z.number(),
210
+ name: z.string(),
211
+ });
212
+ const component = {
213
+ name: "TestComponent",
214
+ description: "A test component",
215
+ component: () => React.createElement("div", null, "Test"),
216
+ props: {},
217
+ stateSchema,
218
+ };
219
+ act(() => {
220
+ result.current.addInteractableComponent(component);
221
+ });
222
+ // Find the state update tool
223
+ const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
224
+ expect(stateToolCall).toBeDefined();
225
+ const inputSchema = stateToolCall[0].inputSchema;
226
+ // The newState property should not have required fields (partial schema)
227
+ expect(inputSchema.properties.newState).toBeDefined();
228
+ expect(inputSchema.properties.newState.required).toBeUndefined();
229
+ // But it should have the properties from the schema
230
+ expect(inputSchema.properties.newState.properties).toBeDefined();
231
+ });
232
+ it("should use additionalProperties when no stateSchema provided", () => {
233
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
234
+ const component = {
235
+ name: "TestComponent",
236
+ description: "A test component",
237
+ component: () => React.createElement("div", null, "Test"),
238
+ props: {},
239
+ // No stateSchema
240
+ };
241
+ act(() => {
242
+ result.current.addInteractableComponent(component);
243
+ });
244
+ // Find the state update tool
245
+ const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
246
+ expect(stateToolCall).toBeDefined();
247
+ const inputSchema = stateToolCall[0].inputSchema;
248
+ // The newState property should allow additional properties
249
+ expect(inputSchema.properties.newState.additionalProperties).toBe(true);
250
+ });
251
+ it("should convert propsSchema to partial JSON Schema for props update tool", () => {
252
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
253
+ const propsSchema = z.object({
254
+ title: z.string(),
255
+ count: z.number(),
256
+ });
257
+ const component = {
258
+ name: "TestComponent",
259
+ description: "A test component",
260
+ component: () => React.createElement("div", null, "Test"),
261
+ props: { title: "test", count: 0 },
262
+ propsSchema,
263
+ };
264
+ act(() => {
265
+ result.current.addInteractableComponent(component);
266
+ });
267
+ // Find the props update tool (not the state one)
268
+ const propsToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_") &&
269
+ !call[0].name.includes("state"));
270
+ expect(propsToolCall).toBeDefined();
271
+ const inputSchema = propsToolCall[0].inputSchema;
272
+ // The newProps property should not have required fields (partial schema)
273
+ expect(inputSchema.properties.newProps).toBeDefined();
274
+ expect(inputSchema.properties.newProps.required).toBeUndefined();
275
+ // But it should have the properties from the schema
276
+ expect(inputSchema.properties.newProps.properties).toBeDefined();
277
+ });
278
+ it("should use additionalProperties when no propsSchema provided", () => {
279
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
280
+ const component = {
281
+ name: "TestComponent",
282
+ description: "A test component",
283
+ component: () => React.createElement("div", null, "Test"),
284
+ props: { title: "test" },
285
+ // No propsSchema
286
+ };
287
+ act(() => {
288
+ result.current.addInteractableComponent(component);
289
+ });
290
+ // Find the props update tool
291
+ const propsToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_") &&
292
+ !call[0].name.includes("state"));
293
+ expect(propsToolCall).toBeDefined();
294
+ const inputSchema = propsToolCall[0].inputSchema;
295
+ // The newProps property should allow additional properties
296
+ expect(inputSchema.properties.newProps.additionalProperties).toBe(true);
297
+ });
298
+ });
57
299
  //# sourceMappingURL=tambo-interactable-provider.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-interactable-provider.test.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AAEvC,2BAA2B;AAC3B,MAAM,oBAAoB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACvC,MAAM,uBAAuB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAE1C,IAAI,CAAC,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,CAAC;IACnD,2BAA2B,EAAE,CAAC,EAC5B,QAAQ,GAGT,EAAE,EAAE,CAAC,0CAAG,QAAQ,CAAI;IACrB,sBAAsB,EAAE,GAAG,EAAE,CAAC,CAAC;QAC7B,gBAAgB,EAAE,oBAAoB;QACtC,mBAAmB,EAAE,uBAAuB;KAC7C,CAAC;CACH,CAAC,CAAC,CAAC;AAEJ,8BAA8B;AAC9B,MAAM,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAEnC,IAAI,CAAC,IAAI,CAAC,4BAA4B,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7C,iBAAiB,EAAE,GAAG,EAAE,CAAC,CAAC;QACxB,YAAY,EAAE,gBAAgB;KAC/B,CAAC;CACH,CAAC,CAAC,CAAC;AAEJ,mCAAmC;AACnC,IAAI,CAAC,IAAI,CAAC,yDAAyD,EAAE,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,CAAC,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,6BAA6B,CAAC,WAAW,CAAC,CAAC;QACxE,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { act, renderHook } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod\";\nimport { TamboInteractableComponent } from \"../model/tambo-interactable\";\nimport {\n TamboInteractableProvider,\n useTamboInteractable,\n} from \"./tambo-interactable-provider\";\n\n// Mock the context helpers\nconst mockAddContextHelper = jest.fn();\nconst mockRemoveContextHelper = jest.fn();\n\njest.mock(\"./tambo-context-helpers-provider\", () => ({\n TamboContextHelpersProvider: ({\n children,\n }: {\n children: React.ReactNode;\n }) => <>{children}</>,\n useTamboContextHelpers: () => ({\n addContextHelper: mockAddContextHelper,\n removeContextHelper: mockRemoveContextHelper,\n }),\n}));\n\n// Mock the component provider\nconst mockRegisterTool = jest.fn();\n\njest.mock(\"./tambo-component-provider\", () => ({\n useTamboComponent: () => ({\n registerTool: mockRegisterTool,\n }),\n}));\n\n// Mock the context helper creation\njest.mock(\"../context-helpers/current-interactables-context-helper\", () => ({\n createInteractablesContextHelper: () =>\n jest.fn(() => ({\n name: \"interactables\",\n context: {\n description: \"Test interactables context\",\n components: [],\n },\n })),\n}));\n\ndescribe(\"TamboInteractableProvider - State Tracking\", () => {\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboInteractableProvider>{children}</TamboInteractableProvider>\n );\n\n it(\"should set and get state for a component\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"Test\" },\n propsSchema: z.object({ title: z.string() }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n act(() => {\n result.current.setInteractableState(componentId, \"count\", 10);\n });\n\n const state = result.current.getInteractableComponentState(componentId);\n expect(state).toEqual({ count: 10 });\n });\n});\n"]}
1
+ {"version":3,"file":"tambo-interactable-provider.test.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AAEvC,2BAA2B;AAC3B,MAAM,oBAAoB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACvC,MAAM,uBAAuB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAE1C,IAAI,CAAC,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,CAAC;IACnD,2BAA2B,EAAE,CAAC,EAC5B,QAAQ,GAGT,EAAE,EAAE,CAAC,0CAAG,QAAQ,CAAI;IACrB,sBAAsB,EAAE,GAAG,EAAE,CAAC,CAAC;QAC7B,gBAAgB,EAAE,oBAAoB;QACtC,mBAAmB,EAAE,uBAAuB;KAC7C,CAAC;CACH,CAAC,CAAC,CAAC;AAEJ,8BAA8B;AAC9B,MAAM,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAEnC,IAAI,CAAC,IAAI,CAAC,4BAA4B,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7C,iBAAiB,EAAE,GAAG,EAAE,CAAC,CAAC;QACxB,YAAY,EAAE,gBAAgB;KAC/B,CAAC;CACH,CAAC,CAAC,CAAC;AAEJ,mCAAmC;AACnC,IAAI,CAAC,IAAI,CAAC,yDAAyD,EAAE,GAAG,E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,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;QACtE,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,oBAAoB,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QAEzE,MAAM,SAAS,GAAyD;YACtE,IAAI,EAAE,eAAe;YACrB,WAAW,EAAE,kBAAkB;YAC/B,SAAS,EAAE,GAAG,EAAE,CAAC,wCAAe;YAChC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;YACxB,iBAAiB;SAClB,CAAC;QAEF,GAAG,CAAC,GAAG,EAAE;YACP,MAAM,CAAC,OAAO,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QAEH,6BAA6B;QAC7B,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CACpD,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC;YAC5C,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAClC,CAAC;QAEF,MAAM,CAAC,aAAa,CAAC,CAAC,WAAW,EAAE,CAAC;QACpC,MAAM,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;QAEjD,2DAA2D;QAC3D,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { act, renderHook } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod\";\nimport { TamboInteractableComponent } from \"../model/tambo-interactable\";\nimport {\n TamboInteractableProvider,\n useTamboInteractable,\n} from \"./tambo-interactable-provider\";\n\n// Mock the context helpers\nconst mockAddContextHelper = jest.fn();\nconst mockRemoveContextHelper = jest.fn();\n\njest.mock(\"./tambo-context-helpers-provider\", () => ({\n TamboContextHelpersProvider: ({\n children,\n }: {\n children: React.ReactNode;\n }) => <>{children}</>,\n useTamboContextHelpers: () => ({\n addContextHelper: mockAddContextHelper,\n removeContextHelper: mockRemoveContextHelper,\n }),\n}));\n\n// Mock the component provider\nconst mockRegisterTool = jest.fn();\n\njest.mock(\"./tambo-component-provider\", () => ({\n useTamboComponent: () => ({\n registerTool: mockRegisterTool,\n }),\n}));\n\n// Mock the context helper creation\njest.mock(\"../context-helpers/current-interactables-context-helper\", () => ({\n createInteractablesContextHelper: () =>\n jest.fn(() => ({\n name: \"interactables\",\n context: {\n description: \"Test interactables context\",\n components: [],\n },\n })),\n}));\n\ndescribe(\"TamboInteractableProvider - State Tracking\", () => {\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboInteractableProvider>{children}</TamboInteractableProvider>\n );\n\n it(\"should set and get state for a component\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"Test\" },\n propsSchema: z.object({ title: z.string() }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n act(() => {\n result.current.setInteractableState(componentId, \"count\", 10);\n });\n\n const state = result.current.getInteractableComponentState(componentId);\n expect(state).toEqual({ count: 10 });\n });\n});\n\ndescribe(\"TamboInteractableProvider - State Update Tool Registration\", () => {\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboInteractableProvider>{children}</TamboInteractableProvider>\n );\n\n it(\"should register both prop and state update tools when component is added\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"Test\" },\n propsSchema: z.object({ title: z.string() }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Should register both update_component_ and update_component_state_ tools\n const registeredToolNames = mockRegisterTool.mock.calls.map(\n (call) => call[0].name,\n );\n expect(registeredToolNames).toContain(`update_component_${componentId}`);\n expect(registeredToolNames).toContain(\n `update_component_state_${componentId}`,\n );\n });\n\n it(\"should register state update tool with correct description\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"MyComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n expect(stateToolCall).toBeDefined();\n expect(stateToolCall[0].description).toContain(componentId);\n expect(stateToolCall[0].description).toContain(\"MyComponent\");\n });\n\n it(\"should allow state update tool to update multiple state values\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Find the state update tool and call it\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n const toolFn = stateToolCall[0].tool;\n\n act(() => {\n toolFn({ componentId, newState: { count: 5, name: \"test\" } });\n });\n\n const state = result.current.getInteractableComponentState(componentId);\n expect(state).toEqual({ count: 5, name: \"test\" });\n });\n\n it(\"should preserve existing state when updating partial state\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Set initial state\n act(() => {\n result.current.setInteractableState(componentId, \"existingKey\", \"value1\");\n });\n\n // Find the state update tool and call it with a new key\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n const toolFn = stateToolCall[0].tool;\n\n act(() => {\n toolFn({ componentId, newState: { newKey: \"value2\" } });\n });\n\n const state = result.current.getInteractableComponentState(componentId);\n expect(state).toEqual({ existingKey: \"value1\", newKey: \"value2\" });\n });\n\n it(\"should use stateSchema when provided for tool registration\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const stateSchema = z.object({\n count: z.number(),\n name: z.string(),\n });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n stateSchema,\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n // Find the state update tool\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n expect(stateToolCall).toBeDefined();\n // The inputSchema should contain the partial stateSchema\n expect(stateToolCall[0].inputSchema).toBeDefined();\n });\n\n it(\"should return warning when updating state with empty object\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Find the state update tool and call it with empty state\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n const toolFn = stateToolCall[0].tool;\n\n let updateResult = \"\";\n act(() => {\n updateResult = toolFn({ componentId, newState: {} });\n });\n\n expect(updateResult).toContain(\"Warning\");\n expect(updateResult).toContain(\"No state values provided\");\n });\n\n it(\"should preserve stateSchema in interactable component\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const stateSchema = z.object({\n count: z.number(),\n });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n stateSchema,\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n const interactable = result.current.getInteractableComponent(componentId);\n expect(interactable?.stateSchema).toBe(stateSchema);\n });\n\n it(\"should convert stateSchema to partial JSON Schema (no required fields)\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const stateSchema = z.object({\n count: z.number(),\n name: z.string(),\n });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n stateSchema,\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n // Find the state update tool\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n expect(stateToolCall).toBeDefined();\n const inputSchema = stateToolCall[0].inputSchema;\n\n // The newState property should not have required fields (partial schema)\n expect(inputSchema.properties.newState).toBeDefined();\n expect(inputSchema.properties.newState.required).toBeUndefined();\n // But it should have the properties from the schema\n expect(inputSchema.properties.newState.properties).toBeDefined();\n });\n\n it(\"should use additionalProperties when no stateSchema provided\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n // No stateSchema\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n // Find the state update tool\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n expect(stateToolCall).toBeDefined();\n const inputSchema = stateToolCall[0].inputSchema;\n\n // The newState property should allow additional properties\n expect(inputSchema.properties.newState.additionalProperties).toBe(true);\n });\n\n it(\"should convert propsSchema to partial JSON Schema for props update tool\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const propsSchema = z.object({\n title: z.string(),\n count: z.number(),\n });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"test\", count: 0 },\n propsSchema,\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n // Find the props update tool (not the state one)\n const propsToolCall = mockRegisterTool.mock.calls.find(\n (call) =>\n call[0].name.startsWith(\"update_component_\") &&\n !call[0].name.includes(\"state\"),\n );\n\n expect(propsToolCall).toBeDefined();\n const inputSchema = propsToolCall[0].inputSchema;\n\n // The newProps property should not have required fields (partial schema)\n expect(inputSchema.properties.newProps).toBeDefined();\n expect(inputSchema.properties.newProps.required).toBeUndefined();\n // But it should have the properties from the schema\n expect(inputSchema.properties.newProps.properties).toBeDefined();\n });\n\n it(\"should use additionalProperties when no propsSchema provided\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"test\" },\n // No propsSchema\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n // Find the props update tool\n const propsToolCall = mockRegisterTool.mock.calls.find(\n (call) =>\n call[0].name.startsWith(\"update_component_\") &&\n !call[0].name.includes(\"state\"),\n );\n\n expect(propsToolCall).toBeDefined();\n const inputSchema = propsToolCall[0].inputSchema;\n\n // The newProps property should allow additional properties\n expect(inputSchema.properties.newProps.additionalProperties).toBe(true);\n });\n});\n"]}
@@ -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,EAEL,uBAAuB,EAEvB,wBAAwB,EACzB,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;AAEnC,OAAO,EACL,gCAAgC,EAChC,uBAAuB,EAEvB,wBAAwB,EAEzB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC,iBAAiB,CACf,wBAAwB,GACtB,0BAA0B,GAC1B,wBAAwB,GACxB,gCAAgC,GAChC,OAAO,CAAC,IAAI,CAAC,mCAAmC,EAAE,sBAAsB,CAAC,CAAC,CAC7E,CAkEF,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,CA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EpB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import React, { createContext, useContext } from "react";
3
+ import { TamboMcpProvider } from "../mcp/tambo-mcp-provider";
3
4
  import { TamboClientContext, TamboClientProvider, } from "./tambo-client-provider";
4
5
  import { TamboComponentProvider, useTamboComponent, } from "./tambo-component-provider";
5
6
  import { TamboContextAttachmentProvider, useTamboContextAttachment, } from "./tambo-context-attachment-provider";
@@ -37,11 +38,12 @@ export const TamboProvider = ({ children, tamboUrl, apiKey, userToken, component
37
38
  React.createElement(TamboContextHelpersProvider, { contextHelpers: contextHelpers },
38
39
  React.createElement(TamboThreadProvider, { contextKey: contextKey, streaming: streaming, autoGenerateThreadName: autoGenerateThreadName, autoGenerateNameThreshold: autoGenerateNameThreshold, initialMessages: initialMessages },
39
40
  React.createElement(TamboMcpTokenProvider, null,
40
- React.createElement(TamboThreadInputProvider, null,
41
- React.createElement(TamboContextAttachmentProvider, { getContextHelperData: getContextHelperData },
42
- React.createElement(TamboComponentProvider, null,
43
- React.createElement(TamboInteractableProvider, null,
44
- React.createElement(TamboCompositeProvider, null, children)))))))))));
41
+ React.createElement(TamboMcpProvider, { contextKey: contextKey },
42
+ React.createElement(TamboThreadInputProvider, null,
43
+ React.createElement(TamboContextAttachmentProvider, { getContextHelperData: getContextHelperData },
44
+ React.createElement(TamboComponentProvider, null,
45
+ React.createElement(TamboInteractableProvider, null,
46
+ React.createElement(TamboCompositeProvider, null, children))))))))))));
45
47
  };
46
48
  export const TamboContext = createContext({});
47
49
  /**
@@ -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,EACL,kBAAkB,EAElB,mBAAmB,GAEpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,sBAAsB,EACtB,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,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 TamboClientContext,\n TamboClientContextProps,\n TamboClientProvider,\n TamboClientProviderProps,\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 { TamboThreadInputProvider } 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.mcpServers - The MCP servers to register (metadata only - use TamboMcpProvider for connections)\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\n * @param props.contextKey - Optional context key passed to thread input provider for scoping threads\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 Partial<Pick<TamboContextAttachmentProviderProps, \"getContextHelperData\">>\n >\n> = ({\n children,\n tamboUrl,\n apiKey,\n userToken,\n components,\n environment,\n tools,\n mcpServers,\n streaming,\n autoGenerateThreadName,\n autoGenerateNameThreshold,\n contextHelpers,\n contextKey,\n initialMessages,\n onCallUnregisteredTool,\n getContextHelperData,\n getResource,\n listResources,\n resources,\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 mcpServers={mcpServers}\n onCallUnregisteredTool={onCallUnregisteredTool}\n getResource={getResource}\n listResources={listResources}\n resources={resources}\n >\n <TamboContextHelpersProvider contextHelpers={contextHelpers}>\n <TamboThreadProvider\n contextKey={contextKey}\n streaming={streaming}\n autoGenerateThreadName={autoGenerateThreadName}\n autoGenerateNameThreshold={autoGenerateNameThreshold}\n initialMessages={initialMessages}\n >\n <TamboMcpTokenProvider>\n <TamboThreadInputProvider>\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 </TamboMcpTokenProvider>\n </TamboThreadProvider>\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 clientContext = useContext(TamboClientContext);\n if (!clientContext) {\n throw new Error(\n \"TamboCompositeProvider must be used within a TamboClientProvider\",\n );\n }\n const { client, queryClient, isUpdatingToken } = clientContext;\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
+ {"version":3,"file":"tambo-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EAAqB,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,O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AO;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 { TamboMcpProvider } from \"../mcp/tambo-mcp-provider\";\nimport { TamboInteractableContext } from \"../model/tambo-interactable\";\nimport {\n TamboClientContext,\n TamboClientContextProps,\n TamboClientProvider,\n TamboClientProviderProps,\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 { TamboThreadInputProvider } 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.mcpServers - The MCP servers to register (metadata only - use TamboMcpProvider for connections)\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\n * @param props.contextKey - Optional context key passed to thread input provider for scoping threads\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 Partial<Pick<TamboContextAttachmentProviderProps, \"getContextHelperData\">>\n >\n> = ({\n children,\n tamboUrl,\n apiKey,\n userToken,\n components,\n environment,\n tools,\n mcpServers,\n streaming,\n autoGenerateThreadName,\n autoGenerateNameThreshold,\n contextHelpers,\n contextKey,\n initialMessages,\n onCallUnregisteredTool,\n getContextHelperData,\n getResource,\n listResources,\n resources,\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 mcpServers={mcpServers}\n onCallUnregisteredTool={onCallUnregisteredTool}\n getResource={getResource}\n listResources={listResources}\n resources={resources}\n >\n <TamboContextHelpersProvider contextHelpers={contextHelpers}>\n <TamboThreadProvider\n contextKey={contextKey}\n streaming={streaming}\n autoGenerateThreadName={autoGenerateThreadName}\n autoGenerateNameThreshold={autoGenerateNameThreshold}\n initialMessages={initialMessages}\n >\n <TamboMcpTokenProvider>\n <TamboMcpProvider contextKey={contextKey}>\n <TamboThreadInputProvider>\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 </TamboMcpProvider>\n </TamboMcpTokenProvider>\n </TamboThreadProvider>\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 clientContext = useContext(TamboClientContext);\n if (!clientContext) {\n throw new Error(\n \"TamboCompositeProvider must be used within a TamboClientProvider\",\n );\n }\n const { client, queryClient, isUpdatingToken } = clientContext;\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-thread-input-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-thread-input-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAIlB,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,sBAAsB,EACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,WAAW,EAAoB,MAAM,6BAA6B,CAAC;AAM5E;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;CAKvB,CAAC;AAEX,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CACxD,sBAAsB,CACpB,IAAI,EACJ,KAAK,EACH;IACE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC,GACD,SAAS,CACZ,EACD,QAAQ,GAAG,aAAa,CACzB;IACC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;OAGG;IACH,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE;QACjB,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACxC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACxC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,8BAA8B;IAC9B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,yBAAyB;IACzB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,0BAA0B;IAC1B,SAAS,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,4BAA4B;IAC5B,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,8BAA8B;IAC9B,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,eAAO,MAAM,uBAAuB,yDAExB,CAAC;AAEb;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA4IhE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,oCAS/B,CAAC"}
1
+ {"version":3,"file":"tambo-thread-input-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-thread-input-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAIlB,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,sBAAsB,EACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,WAAW,EAAoB,MAAM,6BAA6B,CAAC;AAY5E;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;CAKvB,CAAC;AAEX,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CACxD,sBAAsB,CACpB,IAAI,EACJ,KAAK,EACH;IACE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC,GACD,SAAS,CACZ,EACD,QAAQ,GAAG,aAAa,CACzB;IACC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;OAGG;IACH,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE;QACjB,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACxC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACxC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,8BAA8B;IAC9B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,yBAAyB;IACzB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,0BAA0B;IAC1B,SAAS,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,4BAA4B;IAC5B,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,8BAA8B;IAC9B,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,eAAO,MAAM,uBAAuB,yDAExB,CAAC;AAEb;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAiKhE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,oCAS/B,CAAC"}
@@ -2,9 +2,12 @@
2
2
  import React, { createContext, useCallback, useContext, useState, } from "react";
3
3
  import { useTamboMutation, } from "../hooks/react-query-hooks";
4
4
  import { useMessageImages } from "../hooks/use-message-images";
5
+ import { useTamboMcpServers } from "../mcp/tambo-mcp-provider";
5
6
  import { ThreadInputError } from "../model/thread-input-error";
6
7
  import { validateInput } from "../model/validate-input";
7
8
  import { buildMessageContent } from "../util/message-builder";
9
+ import { extractResourceUris, resolveResourceContents, } from "../util/resource-content-resolver";
10
+ import { useTamboRegistry } from "./tambo-registry-provider";
8
11
  import { useTamboThread } from "./tambo-thread-provider";
9
12
  /**
10
13
  * Error messages for various input-related error scenarios
@@ -30,6 +33,8 @@ export const TamboThreadInputProvider = ({ children, }) => {
30
33
  const { thread, sendThreadMessage, contextKey } = useTamboThread();
31
34
  const [inputValue, setInputValue] = useState("");
32
35
  const imageState = useMessageImages();
36
+ const mcpServers = useTamboMcpServers();
37
+ const { resourceSource } = useTamboRegistry();
33
38
  const submit = useCallback(async ({ streamResponse, forceToolChoice, additionalContext, resourceNames = {}, } = {}) => {
34
39
  // Validate text input if present
35
40
  if (inputValue?.trim()) {
@@ -44,8 +49,13 @@ export const TamboThreadInputProvider = ({ children, }) => {
44
49
  cause: "No text or images to send",
45
50
  });
46
51
  }
47
- // Build message content with text, images, and resource names
48
- const messageContent = buildMessageContent(inputValue, imageState.images, resourceNames);
52
+ // Extract resource URIs from the input text and resolve content for client-side resources
53
+ // (registry and client-side MCP servers). Internal Tambo server resources are skipped
54
+ // since the backend can resolve them.
55
+ const resourceUris = extractResourceUris(inputValue);
56
+ const resolvedContent = await resolveResourceContents(resourceUris, mcpServers, resourceSource ?? undefined);
57
+ // Build message content with text, images, resource names, and resolved content
58
+ const messageContent = buildMessageContent(inputValue, imageState.images, resourceNames, resolvedContent);
49
59
  try {
50
60
  await sendThreadMessage(inputValue || "Image message", {
51
61
  threadId: thread.id,
@@ -86,7 +96,15 @@ export const TamboThreadInputProvider = ({ children, }) => {
86
96
  }
87
97
  // Clear text after successful submission
88
98
  setInputValue("");
89
- }, [inputValue, sendThreadMessage, thread.id, contextKey, imageState]);
99
+ }, [
100
+ inputValue,
101
+ sendThreadMessage,
102
+ thread.id,
103
+ contextKey,
104
+ imageState,
105
+ mcpServers,
106
+ resourceSource,
107
+ ]);
90
108
  const { mutateAsync: submitAsync, mutate: _unusedSubmit, ...mutationState } = useTamboMutation({
91
109
  mutationFn: submit,
92
110
  });
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-thread-input-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-thread-input-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,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C,SAAS;QAC/B,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,WAAW,EAAE,UAAU,CAAC,WAAW;KACpC,CAAC;IAEF,OAAO,CACL,oBAAC,uBAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAC3C,QAAQ,CACwB,CACpC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,OAAO,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useState,\n} from \"react\";\nimport {\n useTamboMutation,\n UseTamboMutationResult,\n} from \"../hooks/react-query-hooks\";\nimport { StagedImage, useMessageImages } from \"../hooks/use-message-images\";\nimport { ThreadInputError } from \"../model/thread-input-error\";\nimport { validateInput } from \"../model/validate-input\";\nimport { buildMessageContent } from \"../util/message-builder\";\nimport { useTamboThread } from \"./tambo-thread-provider\";\n\n/**\n * Error messages for various input-related error scenarios\n * These messages are used to provide user-friendly error feedback\n * @readonly\n */\nexport const INPUT_ERROR_MESSAGES = {\n EMPTY: \"Message cannot be empty\",\n NETWORK: \"Network error. Please check your connection\",\n SERVER: \"Server error. Please try again\",\n VALIDATION: \"Invalid message format\",\n} as const;\n\nexport interface TamboThreadInputContextProps extends Omit<\n UseTamboMutationResult<\n void,\n Error,\n | {\n contextKey?: string;\n streamResponse?: boolean;\n forceToolChoice?: string;\n additionalContext?: Record<string, any>;\n }\n | undefined\n >,\n \"mutate\" | \"mutateAsync\"\n> {\n /** Current value of the input field */\n value: string;\n /**\n * Function to update the input value\n * @param value - New value for the input field\n */\n setValue: (value: string) => void;\n /**\n * Function to submit the current input value\n * @param options - Submission options\n */\n submit: (options?: {\n streamResponse?: boolean;\n forceToolChoice?: string;\n additionalContext?: Record<string, any>;\n resourceNames?: Record<string, string>;\n }) => Promise<void>;\n /** Currently staged images */\n images: StagedImage[];\n /** Add a single image */\n addImage: (file: File) => Promise<void>;\n /** Add multiple images */\n addImages: (files: File[]) => Promise<void>;\n /** Remove an image by id */\n removeImage: (id: string) => void;\n /** Clear all staged images */\n clearImages: () => void;\n}\n\nexport const TamboThreadInputContext = createContext<\n TamboThreadInputContextProps | undefined\n>(undefined);\n\n/**\n * Provider that manages shared thread input state across all components\n * This ensures that useTamboThreadInput, useTamboSuggestions, and components\n * all share the same input state\n * @param props - The props for the TamboThreadInputProvider\n * @param props.children - The children to render.\n * @returns The thread input context\n */\nexport const TamboThreadInputProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const { thread, sendThreadMessage, contextKey } = useTamboThread();\n const [inputValue, setInputValue] = useState(\"\");\n const imageState = useMessageImages();\n\n const submit = useCallback(\n async ({\n streamResponse,\n forceToolChoice,\n additionalContext,\n resourceNames = {},\n }: {\n streamResponse?: boolean;\n forceToolChoice?: string;\n additionalContext?: Record<string, any>;\n resourceNames?: Record<string, string>;\n } = {}) => {\n // Validate text input if present\n if (inputValue?.trim()) {\n const validation = validateInput(inputValue);\n if (!validation.isValid) {\n throw new ThreadInputError(\n `Cannot submit message: ${validation.error ?? INPUT_ERROR_MESSAGES.VALIDATION}`,\n { cause: validation.error },\n );\n }\n }\n\n // Check if we have content to send\n if (!inputValue.trim() && imageState.images.length === 0) {\n throw new ThreadInputError(INPUT_ERROR_MESSAGES.EMPTY, {\n cause: \"No text or images to send\",\n });\n }\n\n // Build message content with text, images, and resource names\n const messageContent = buildMessageContent(\n inputValue,\n imageState.images,\n resourceNames,\n );\n\n try {\n await sendThreadMessage(inputValue || \"Image message\", {\n threadId: thread.id,\n contextKey,\n streamResponse: streamResponse,\n forceToolChoice: forceToolChoice,\n additionalContext: additionalContext,\n content: messageContent,\n });\n } catch (error: any) {\n // Handle image-related errors with friendly messages\n if (imageState.images.length > 0) {\n const errorMessage = error?.message?.toLowerCase() ?? \"\";\n\n // Backend not yet supporting image content type\n if (errorMessage.includes(\"unknown content part type: image\")) {\n throw new ThreadInputError(\n \"Image attachments are not yet supported by the backend. This feature is coming soon.\",\n { cause: error },\n );\n }\n\n // Handle specific model vision support errors\n // OpenAI errors\n if (\n errorMessage.includes(\n \"does not support image message content types\",\n ) ||\n (errorMessage.includes(\"invalid model\") &&\n errorMessage.includes(\n \"image_url is only supported by certain models\",\n ))\n ) {\n throw new ThreadInputError(\n \"This model doesn't support images. Please use GPT-4o, GPT-4 Turbo, or other vision-capable models.\",\n { cause: error },\n );\n }\n\n // Anthropic Claude errors\n if (\n errorMessage.includes(\"does not support image\") ||\n errorMessage.includes(\"vision not supported\")\n ) {\n throw new ThreadInputError(\n \"This Claude model doesn't support images. Please use Claude 3.5 Sonnet, Claude 3 Opus, or other vision-capable models.\",\n { cause: error },\n );\n }\n\n // Generic image/vision errors\n if (\n errorMessage.includes(\"image\") ||\n errorMessage.includes(\"vision\")\n ) {\n throw new ThreadInputError(\n \"This model doesn't support image attachments. Please use a vision-capable model.\",\n { cause: error },\n );\n }\n }\n\n throw error;\n }\n\n // Clear text after successful submission\n setInputValue(\"\");\n },\n [inputValue, sendThreadMessage, thread.id, contextKey, imageState],\n );\n\n const {\n mutateAsync: submitAsync,\n mutate: _unusedSubmit,\n ...mutationState\n } = useTamboMutation({\n mutationFn: submit,\n });\n\n const value = {\n ...mutationState,\n value: inputValue,\n setValue: setInputValue,\n submit: submitAsync,\n images: imageState.images,\n addImage: imageState.addImage,\n addImages: imageState.addImages,\n removeImage: imageState.removeImage,\n clearImages: imageState.clearImages,\n };\n\n return (\n <TamboThreadInputContext.Provider value={value}>\n {children}\n </TamboThreadInputContext.Provider>\n );\n};\n\n/**\n * Hook to access the shared thread input state\n * contextKey parameter is not passed here anymore. Instead, use the contextKey prop in the TamboProvider.\n * @returns The thread input context\n */\nexport const useTamboThreadInput = () => {\n const context = useContext(TamboThreadInputContext);\n if (!context) {\n throw new Error(\n \"useTamboThreadInput must be used within a TamboThreadInputProvider\",\n );\n }\n\n return context;\n};\n"]}
1
+ {"version":3,"file":"tambo-thread-input-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-thread-input-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EACL,gBAAgB,GAEjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAe,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,KAAK,EAAE,yBAAyB;IAChC,OAAO,EAAE,6CAA6C;IACtD,MAAM,EAAE,gCAAgC;IACxC,UAAU,EAAE,wBAAwB;CAC5B,CAAC;AA6CX,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAElD,SAAS,CAAC,CAAC;AAEb;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAgC,CAAC,EACpE,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,UAAU,EAAE,GAAG,cAAc,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AC,CAAC","sourcesContent":["\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useState,\n} from \"react\";\nimport {\n useTamboMutation,\n UseTamboMutationResult,\n} from \"../hooks/react-query-hooks\";\nimport { StagedImage, useMessageImages } from \"../hooks/use-message-images\";\nimport { useTamboMcpServers } from \"../mcp/tambo-mcp-provider\";\nimport { ThreadInputError } from \"../model/thread-input-error\";\nimport { validateInput } from \"../model/validate-input\";\nimport { buildMessageContent } from \"../util/message-builder\";\nimport {\n extractResourceUris,\n resolveResourceContents,\n} from \"../util/resource-content-resolver\";\nimport { useTamboRegistry } from \"./tambo-registry-provider\";\nimport { useTamboThread } from \"./tambo-thread-provider\";\n\n/**\n * Error messages for various input-related error scenarios\n * These messages are used to provide user-friendly error feedback\n * @readonly\n */\nexport const INPUT_ERROR_MESSAGES = {\n EMPTY: \"Message cannot be empty\",\n NETWORK: \"Network error. Please check your connection\",\n SERVER: \"Server error. Please try again\",\n VALIDATION: \"Invalid message format\",\n} as const;\n\nexport interface TamboThreadInputContextProps extends Omit<\n UseTamboMutationResult<\n void,\n Error,\n | {\n contextKey?: string;\n streamResponse?: boolean;\n forceToolChoice?: string;\n additionalContext?: Record<string, any>;\n }\n | undefined\n >,\n \"mutate\" | \"mutateAsync\"\n> {\n /** Current value of the input field */\n value: string;\n /**\n * Function to update the input value\n * @param value - New value for the input field\n */\n setValue: (value: string) => void;\n /**\n * Function to submit the current input value\n * @param options - Submission options\n */\n submit: (options?: {\n streamResponse?: boolean;\n forceToolChoice?: string;\n additionalContext?: Record<string, any>;\n resourceNames?: Record<string, string>;\n }) => Promise<void>;\n /** Currently staged images */\n images: StagedImage[];\n /** Add a single image */\n addImage: (file: File) => Promise<void>;\n /** Add multiple images */\n addImages: (files: File[]) => Promise<void>;\n /** Remove an image by id */\n removeImage: (id: string) => void;\n /** Clear all staged images */\n clearImages: () => void;\n}\n\nexport const TamboThreadInputContext = createContext<\n TamboThreadInputContextProps | undefined\n>(undefined);\n\n/**\n * Provider that manages shared thread input state across all components\n * This ensures that useTamboThreadInput, useTamboSuggestions, and components\n * all share the same input state\n * @param props - The props for the TamboThreadInputProvider\n * @param props.children - The children to render.\n * @returns The thread input context\n */\nexport const TamboThreadInputProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const { thread, sendThreadMessage, contextKey } = useTamboThread();\n const [inputValue, setInputValue] = useState(\"\");\n const imageState = useMessageImages();\n const mcpServers = useTamboMcpServers();\n const { resourceSource } = useTamboRegistry();\n\n const submit = useCallback(\n async ({\n streamResponse,\n forceToolChoice,\n additionalContext,\n resourceNames = {},\n }: {\n streamResponse?: boolean;\n forceToolChoice?: string;\n additionalContext?: Record<string, any>;\n resourceNames?: Record<string, string>;\n } = {}) => {\n // Validate text input if present\n if (inputValue?.trim()) {\n const validation = validateInput(inputValue);\n if (!validation.isValid) {\n throw new ThreadInputError(\n `Cannot submit message: ${validation.error ?? INPUT_ERROR_MESSAGES.VALIDATION}`,\n { cause: validation.error },\n );\n }\n }\n\n // Check if we have content to send\n if (!inputValue.trim() && imageState.images.length === 0) {\n throw new ThreadInputError(INPUT_ERROR_MESSAGES.EMPTY, {\n cause: \"No text or images to send\",\n });\n }\n\n // Extract resource URIs from the input text and resolve content for client-side resources\n // (registry and client-side MCP servers). Internal Tambo server resources are skipped\n // since the backend can resolve them.\n const resourceUris = extractResourceUris(inputValue);\n const resolvedContent = await resolveResourceContents(\n resourceUris,\n mcpServers,\n resourceSource ?? undefined,\n );\n\n // Build message content with text, images, resource names, and resolved content\n const messageContent = buildMessageContent(\n inputValue,\n imageState.images,\n resourceNames,\n resolvedContent,\n );\n\n try {\n await sendThreadMessage(inputValue || \"Image message\", {\n threadId: thread.id,\n contextKey,\n streamResponse: streamResponse,\n forceToolChoice: forceToolChoice,\n additionalContext: additionalContext,\n content: messageContent,\n });\n } catch (error: any) {\n // Handle image-related errors with friendly messages\n if (imageState.images.length > 0) {\n const errorMessage = error?.message?.toLowerCase() ?? \"\";\n\n // Backend not yet supporting image content type\n if (errorMessage.includes(\"unknown content part type: image\")) {\n throw new ThreadInputError(\n \"Image attachments are not yet supported by the backend. This feature is coming soon.\",\n { cause: error },\n );\n }\n\n // Handle specific model vision support errors\n // OpenAI errors\n if (\n errorMessage.includes(\n \"does not support image message content types\",\n ) ||\n (errorMessage.includes(\"invalid model\") &&\n errorMessage.includes(\n \"image_url is only supported by certain models\",\n ))\n ) {\n throw new ThreadInputError(\n \"This model doesn't support images. Please use GPT-4o, GPT-4 Turbo, or other vision-capable models.\",\n { cause: error },\n );\n }\n\n // Anthropic Claude errors\n if (\n errorMessage.includes(\"does not support image\") ||\n errorMessage.includes(\"vision not supported\")\n ) {\n throw new ThreadInputError(\n \"This Claude model doesn't support images. Please use Claude 3.5 Sonnet, Claude 3 Opus, or other vision-capable models.\",\n { cause: error },\n );\n }\n\n // Generic image/vision errors\n if (\n errorMessage.includes(\"image\") ||\n errorMessage.includes(\"vision\")\n ) {\n throw new ThreadInputError(\n \"This model doesn't support image attachments. Please use a vision-capable model.\",\n { cause: error },\n );\n }\n }\n\n throw error;\n }\n\n // Clear text after successful submission\n setInputValue(\"\");\n },\n [\n inputValue,\n sendThreadMessage,\n thread.id,\n contextKey,\n imageState,\n mcpServers,\n resourceSource,\n ],\n );\n\n const {\n mutateAsync: submitAsync,\n mutate: _unusedSubmit,\n ...mutationState\n } = useTamboMutation({\n mutationFn: submit,\n });\n\n const value = {\n ...mutationState,\n value: inputValue,\n setValue: setInputValue,\n submit: submitAsync,\n images: imageState.images,\n addImage: imageState.addImage,\n addImages: imageState.addImages,\n removeImage: imageState.removeImage,\n clearImages: imageState.clearImages,\n };\n\n return (\n <TamboThreadInputContext.Provider value={value}>\n {children}\n </TamboThreadInputContext.Provider>\n );\n};\n\n/**\n * Hook to access the shared thread input state\n * contextKey parameter is not passed here anymore. Instead, use the contextKey prop in the TamboProvider.\n * @returns The thread input context\n */\nexport const useTamboThreadInput = () => {\n const context = useContext(TamboThreadInputContext);\n if (!context) {\n throw new Error(\n \"useTamboThreadInput must be used within a TamboThreadInputProvider\",\n );\n }\n\n return context;\n};\n"]}
@@ -1,4 +1,4 @@
1
- export { looksLikeJSONSchema } from "./json-schema";
1
+ export { looksLikeJSONSchema, makeJsonSchemaPartial } from "./json-schema";
2
2
  export { getParametersFromToolSchema, hasInputSchema, safeSchemaToJsonSchema, schemaToJsonSchema, type SupportedSchema, } from "./schema";
3
3
  export { isStandardSchema } from "./standard-schema";
4
4
  export { assertNoRecordSchema } from "./validate";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EACL,2BAA2B,EAC3B,cAAc,EACd,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,eAAe,GACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EACL,2BAA2B,EAC3B,cAAc,EACd,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,eAAe,GACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC"}
@@ -1,4 +1,4 @@
1
- export { looksLikeJSONSchema } from "./json-schema";
1
+ export { looksLikeJSONSchema, makeJsonSchemaPartial } from "./json-schema";
2
2
  export { getParametersFromToolSchema, hasInputSchema, safeSchemaToJsonSchema, schemaToJsonSchema, } from "./schema";
3
3
  export { isStandardSchema } from "./standard-schema";
4
4
  export { assertNoRecordSchema } from "./validate";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EACL,2BAA2B,EAC3B,cAAc,EACd,sBAAsB,EACtB,kBAAkB,GAEnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC","sourcesContent":["export { looksLikeJSONSchema } from \"./json-schema\";\nexport {\n getParametersFromToolSchema,\n hasInputSchema,\n safeSchemaToJsonSchema,\n schemaToJsonSchema,\n type SupportedSchema,\n} from \"./schema\";\nexport { isStandardSchema } from \"./standard-schema\";\nexport { assertNoRecordSchema } from \"./validate\";\nexport { getZodFunctionArgs, getZodFunctionReturns } from \"./zod\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EACL,2BAA2B,EAC3B,cAAc,EACd,sBAAsB,EACtB,kBAAkB,GAEnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC","sourcesContent":["export { looksLikeJSONSchema, makeJsonSchemaPartial } from \"./json-schema\";\nexport {\n getParametersFromToolSchema,\n hasInputSchema,\n safeSchemaToJsonSchema,\n schemaToJsonSchema,\n type SupportedSchema,\n} from \"./schema\";\nexport { isStandardSchema } from \"./standard-schema\";\nexport { assertNoRecordSchema } from \"./validate\";\nexport { getZodFunctionArgs, getZodFunctionReturns } from \"./zod\";\n"]}
@@ -32,4 +32,11 @@ export declare function isJsonSchemaTuple(schema: JSONSchema7Extended): schema i
32
32
  * @returns Array of item schemas, or undefined if not a tuple
33
33
  */
34
34
  export declare function getJsonSchemaTupleItems(schema: JSONSchema7Extended): JSONSchema7[] | undefined;
35
+ /**
36
+ * Creates a partial version of a JSON Schema by removing required constraints.
37
+ * This allows LLM to provide only the properties it wants to update.
38
+ * @param schema - The JSON Schema to make partial
39
+ * @returns A new JSON Schema with the required constraint removed
40
+ */
41
+ export declare function makeJsonSchemaPartial(schema: JSONSchema7): JSONSchema7;
35
42
  //# sourceMappingURL=json-schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../../src/schema/json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAkD1C;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,WAAW,CAMpE;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG;IAC9C,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,mBAAmB,GAC1B,MAAM,IAAI,mBAAmB,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAgBnD;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,mBAAmB,GAC1B,WAAW,EAAE,GAAG,SAAS,CAgB3B"}
1
+ {"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../../src/schema/json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAkD1C;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,WAAW,CAMpE;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG;IAC9C,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,mBAAmB,GAC1B,MAAM,IAAI,mBAAmB,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAgBnD;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,mBAAmB,GAC1B,WAAW,EAAE,GAAG,SAAS,CAgB3B;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAGtE"}
@@ -95,4 +95,14 @@ export function getJsonSchemaTupleItems(schema) {
95
95
  }
96
96
  return undefined;
97
97
  }
98
+ /**
99
+ * Creates a partial version of a JSON Schema by removing required constraints.
100
+ * This allows LLM to provide only the properties it wants to update.
101
+ * @param schema - The JSON Schema to make partial
102
+ * @returns A new JSON Schema with the required constraint removed
103
+ */
104
+ export function makeJsonSchemaPartial(schema) {
105
+ const { required: _required, ...rest } = schema;
106
+ return rest;
107
+ }
98
108
  //# sourceMappingURL=json-schema.js.map