@tambo-ai/react 0.56.0 → 0.58.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 (86) hide show
  1. package/README.md +36 -0
  2. package/dist/hooks/react-query-hooks.d.ts +4 -4
  3. package/dist/hooks/react-query-hooks.js +4 -4
  4. package/dist/hooks/react-query-hooks.js.map +1 -1
  5. package/dist/index.d.ts +3 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +2 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
  10. package/dist/mcp/tambo-mcp-provider.js +9 -0
  11. package/dist/mcp/tambo-mcp-provider.js.map +1 -1
  12. package/dist/model/component-metadata.d.ts +7 -0
  13. package/dist/model/component-metadata.d.ts.map +1 -1
  14. package/dist/model/component-metadata.js.map +1 -1
  15. package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.d.ts +2 -0
  16. package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.d.ts.map +1 -0
  17. package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.js +179 -0
  18. package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.js.map +1 -0
  19. package/dist/providers/index.d.ts +1 -1
  20. package/dist/providers/index.d.ts.map +1 -1
  21. package/dist/providers/index.js.map +1 -1
  22. package/dist/providers/tambo-provider.d.ts +1 -0
  23. package/dist/providers/tambo-provider.d.ts.map +1 -1
  24. package/dist/providers/tambo-provider.js +3 -2
  25. package/dist/providers/tambo-provider.js.map +1 -1
  26. package/dist/providers/tambo-thread-provider.d.ts +13 -0
  27. package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
  28. package/dist/providers/tambo-thread-provider.js +67 -23
  29. package/dist/providers/tambo-thread-provider.js.map +1 -1
  30. package/dist/testing/tools.d.ts +1 -0
  31. package/dist/testing/tools.d.ts.map +1 -1
  32. package/dist/util/__tests__/content-parts.test.d.ts +2 -0
  33. package/dist/util/__tests__/content-parts.test.d.ts.map +1 -0
  34. package/dist/util/__tests__/content-parts.test.js +47 -0
  35. package/dist/util/__tests__/content-parts.test.js.map +1 -0
  36. package/dist/util/content-parts.d.ts +19 -0
  37. package/dist/util/content-parts.d.ts.map +1 -0
  38. package/dist/util/content-parts.js +40 -0
  39. package/dist/util/content-parts.js.map +1 -0
  40. package/dist/util/tool-caller.d.ts +4 -3
  41. package/dist/util/tool-caller.d.ts.map +1 -1
  42. package/dist/util/tool-caller.js +9 -5
  43. package/dist/util/tool-caller.js.map +1 -1
  44. package/esm/hooks/react-query-hooks.d.ts +4 -4
  45. package/esm/hooks/react-query-hooks.js +4 -4
  46. package/esm/hooks/react-query-hooks.js.map +1 -1
  47. package/esm/index.d.ts +3 -2
  48. package/esm/index.d.ts.map +1 -1
  49. package/esm/index.js +1 -1
  50. package/esm/index.js.map +1 -1
  51. package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
  52. package/esm/mcp/tambo-mcp-provider.js +9 -0
  53. package/esm/mcp/tambo-mcp-provider.js.map +1 -1
  54. package/esm/model/component-metadata.d.ts +7 -0
  55. package/esm/model/component-metadata.d.ts.map +1 -1
  56. package/esm/model/component-metadata.js.map +1 -1
  57. package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.d.ts +2 -0
  58. package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.d.ts.map +1 -0
  59. package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.js +174 -0
  60. package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.js.map +1 -0
  61. package/esm/providers/index.d.ts +1 -1
  62. package/esm/providers/index.d.ts.map +1 -1
  63. package/esm/providers/index.js.map +1 -1
  64. package/esm/providers/tambo-provider.d.ts +1 -0
  65. package/esm/providers/tambo-provider.d.ts.map +1 -1
  66. package/esm/providers/tambo-provider.js +3 -2
  67. package/esm/providers/tambo-provider.js.map +1 -1
  68. package/esm/providers/tambo-thread-provider.d.ts +13 -0
  69. package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
  70. package/esm/providers/tambo-thread-provider.js +67 -23
  71. package/esm/providers/tambo-thread-provider.js.map +1 -1
  72. package/esm/testing/tools.d.ts +1 -0
  73. package/esm/testing/tools.d.ts.map +1 -1
  74. package/esm/util/__tests__/content-parts.test.d.ts +2 -0
  75. package/esm/util/__tests__/content-parts.test.d.ts.map +1 -0
  76. package/esm/util/__tests__/content-parts.test.js +45 -0
  77. package/esm/util/__tests__/content-parts.test.js.map +1 -0
  78. package/esm/util/content-parts.d.ts +19 -0
  79. package/esm/util/content-parts.d.ts.map +1 -0
  80. package/esm/util/content-parts.js +35 -0
  81. package/esm/util/content-parts.js.map +1 -0
  82. package/esm/util/tool-caller.d.ts +4 -3
  83. package/esm/util/tool-caller.d.ts.map +1 -1
  84. package/esm/util/tool-caller.js +9 -5
  85. package/esm/util/tool-caller.js.map +1 -1
  86. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/testing/tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,cAAc,EAAE;;;;;;;;;;;;;;;;IA0B/D"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/testing/tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,cAAc,EAAE;;;;;;;;;;;;;;;;;IA0B/D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=content-parts.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-parts.test.d.ts","sourceRoot":"","sources":["../../../src/util/__tests__/content-parts.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const content_parts_1 = require("../content-parts");
4
+ describe("content-parts type guards", () => {
5
+ it("returns true for a valid text content part array", () => {
6
+ const parts = [{ type: "text", text: "hello" }];
7
+ expect((0, content_parts_1.isContentPartArray)(parts)).toBe(true);
8
+ });
9
+ it("returns true for a valid image_url content part array", () => {
10
+ const parts = [
11
+ { type: "image_url", image_url: { url: "data:image/png;base64,abc" } },
12
+ ];
13
+ expect((0, content_parts_1.isContentPartArray)(parts)).toBe(true);
14
+ });
15
+ it("returns false for non-object array elements", () => {
16
+ const parts = ["text", 123, null];
17
+ expect((0, content_parts_1.isContentPartArray)(parts)).toBe(false);
18
+ });
19
+ it("returns false when elements are objects without string type", () => {
20
+ const parts = [{}, { type: 42 }, { type: undefined }];
21
+ expect((0, content_parts_1.isContentPartArray)(parts)).toBe(false);
22
+ });
23
+ it("isContentPart narrows a single part", () => {
24
+ const val = { type: "text", text: "hi" };
25
+ if (!(0, content_parts_1.isContentPart)(val)) {
26
+ throw new Error("should be content part");
27
+ }
28
+ // runtime spot-check
29
+ expect(val.type).toBe("text");
30
+ });
31
+ it("returns false for non-array inputs", () => {
32
+ expect((0, content_parts_1.isContentPartArray)({})).toBe(false);
33
+ expect((0, content_parts_1.isContentPartArray)(null)).toBe(false);
34
+ expect((0, content_parts_1.isContentPartArray)(undefined)).toBe(false);
35
+ expect((0, content_parts_1.isContentPartArray)("foo")).toBe(false);
36
+ });
37
+ it("toText safely stringifies values and never throws", () => {
38
+ expect((0, content_parts_1.toText)("hello")).toBe("hello");
39
+ expect((0, content_parts_1.toText)(42)).toBe("42");
40
+ const circular = { a: 1 };
41
+ circular.self = circular;
42
+ // Should not throw for circular structures
43
+ expect(() => (0, content_parts_1.toText)(circular)).not.toThrow();
44
+ expect(typeof (0, content_parts_1.toText)(undefined)).toBe("string");
45
+ });
46
+ });
47
+ //# sourceMappingURL=content-parts.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-parts.test.js","sourceRoot":"","s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OAAO,IAAA,sBAAM,EAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { isContentPartArray, isContentPart, toText } from \"../content-parts\";\n\ndescribe(\"content-parts type guards\", () => {\n it(\"returns true for a valid text content part array\", () => {\n const parts = [{ type: \"text\", text: \"hello\" }];\n expect(isContentPartArray(parts)).toBe(true);\n });\n\n it(\"returns true for a valid image_url content part array\", () => {\n const parts = [\n { type: \"image_url\", image_url: { url: \"data:image/png;base64,abc\" } },\n ];\n expect(isContentPartArray(parts)).toBe(true);\n });\n\n it(\"returns false for non-object array elements\", () => {\n const parts = [\"text\", 123, null];\n expect(isContentPartArray(parts as any)).toBe(false);\n });\n\n it(\"returns false when elements are objects without string type\", () => {\n const parts = [{}, { type: 42 }, { type: undefined }];\n expect(isContentPartArray(parts as any)).toBe(false);\n });\n\n it(\"isContentPart narrows a single part\", () => {\n const val: unknown = { type: \"text\", text: \"hi\" };\n if (!isContentPart(val)) {\n throw new Error(\"should be content part\");\n }\n // runtime spot-check\n expect(val.type).toBe(\"text\");\n });\n\n it(\"returns false for non-array inputs\", () => {\n expect(isContentPartArray({})).toBe(false);\n expect(isContentPartArray(null)).toBe(false);\n expect(isContentPartArray(undefined)).toBe(false);\n expect(isContentPartArray(\"foo\")).toBe(false);\n });\n\n it(\"toText safely stringifies values and never throws\", () => {\n expect(toText(\"hello\")).toBe(\"hello\");\n expect(toText(42)).toBe(\"42\");\n const circular: any = { a: 1 };\n circular.self = circular;\n // Should not throw for circular structures\n expect(() => toText(circular)).not.toThrow();\n expect(typeof toText(undefined)).toBe(\"string\");\n });\n});\n"]}
@@ -0,0 +1,19 @@
1
+ import type TamboAI from "@tambo-ai/typescript-sdk";
2
+ /**
3
+ * Narrow a value to a ChatCompletionContentPart by checking for an object with string `type`.
4
+ * We purposefully keep this guard permissive to support future part types.
5
+ * @returns true if the value looks like a content part
6
+ */
7
+ export declare function isContentPart(val: unknown): val is TamboAI.Beta.Threads.ChatCompletionContentPart;
8
+ /**
9
+ * Type guard for arrays of content parts.
10
+ * @returns true if the value is an array of content parts
11
+ */
12
+ export declare function isContentPartArray(val: unknown): val is TamboAI.Beta.Threads.ChatCompletionContentPart[];
13
+ /**
14
+ * Safely convert an unknown value to a string suitable for a `{ type: "text" }` content part.
15
+ * Guarantees a string and avoids throwing on circular structures.
16
+ * @returns The string representation of the value
17
+ */
18
+ export declare function toText(val: unknown): string;
19
+ //# sourceMappingURL=content-parts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-parts.d.ts","sourceRoot":"","sources":["../../src/util/content-parts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAC;AAEpD;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,OAAO,GACX,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAOvD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,OAAO,GACX,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAQ3C"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isContentPart = isContentPart;
4
+ exports.isContentPartArray = isContentPartArray;
5
+ exports.toText = toText;
6
+ /**
7
+ * Narrow a value to a ChatCompletionContentPart by checking for an object with string `type`.
8
+ * We purposefully keep this guard permissive to support future part types.
9
+ * @returns true if the value looks like a content part
10
+ */
11
+ function isContentPart(val) {
12
+ return (!!val &&
13
+ typeof val === "object" &&
14
+ "type" in val &&
15
+ typeof val.type === "string");
16
+ }
17
+ /**
18
+ * Type guard for arrays of content parts.
19
+ * @returns true if the value is an array of content parts
20
+ */
21
+ function isContentPartArray(val) {
22
+ return Array.isArray(val) && val.every((item) => isContentPart(item));
23
+ }
24
+ /**
25
+ * Safely convert an unknown value to a string suitable for a `{ type: "text" }` content part.
26
+ * Guarantees a string and avoids throwing on circular structures.
27
+ * @returns The string representation of the value
28
+ */
29
+ function toText(val) {
30
+ if (typeof val === "string")
31
+ return val;
32
+ try {
33
+ const json = JSON.stringify(val);
34
+ return json ?? String(val);
35
+ }
36
+ catch {
37
+ return String(val);
38
+ }
39
+ }
40
+ //# sourceMappingURL=content-parts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-parts.js","sourceRoot":"","sources":["../../src/util/content-parts.ts"],"names":[],"mappings":";;AAOA,sCASC;AAMD,gDAIC;AAOD,wBAQC;AAvCD;;;;GAIG;AACH,SAAgB,aAAa,CAC3B,GAAY;IAEZ,OAAO,CACL,CAAC,CAAC,GAAG;QACL,OAAO,GAAG,KAAK,QAAQ;QACvB,MAAM,IAAK,GAAW;QACtB,OAAQ,GAAW,CAAC,IAAI,KAAK,QAAQ,CACtC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,kBAAkB,CAChC,GAAY;IAEZ,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;AACxE,CAAC;AAED;;;;GAIG;AACH,SAAgB,MAAM,CAAC,GAAY;IACjC,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IACxC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACjC,OAAO,IAAI,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;AACH,CAAC","sourcesContent":["import type TamboAI from \"@tambo-ai/typescript-sdk\";\n\n/**\n * Narrow a value to a ChatCompletionContentPart by checking for an object with string `type`.\n * We purposefully keep this guard permissive to support future part types.\n * @returns true if the value looks like a content part\n */\nexport function isContentPart(\n val: unknown,\n): val is TamboAI.Beta.Threads.ChatCompletionContentPart {\n return (\n !!val &&\n typeof val === \"object\" &&\n \"type\" in (val as any) &&\n typeof (val as any).type === \"string\"\n );\n}\n\n/**\n * Type guard for arrays of content parts.\n * @returns true if the value is an array of content parts\n */\nexport function isContentPartArray(\n val: unknown,\n): val is TamboAI.Beta.Threads.ChatCompletionContentPart[] {\n return Array.isArray(val) && val.every((item) => isContentPart(item));\n}\n\n/**\n * Safely convert an unknown value to a string suitable for a `{ type: \"text\" }` content part.\n * Guarantees a string and avoids throwing on circular structures.\n * @returns The string representation of the value\n */\nexport function toText(val: unknown): string {\n if (typeof val === \"string\") return val;\n try {\n const json = JSON.stringify(val);\n return json ?? String(val);\n } catch {\n return String(val);\n }\n}\n"]}
@@ -1,13 +1,14 @@
1
1
  import TamboAI from "@tambo-ai/typescript-sdk";
2
- import { TamboToolRegistry } from "../model/component-metadata";
2
+ import { TamboTool, TamboToolRegistry } from "../model/component-metadata";
3
3
  /**
4
4
  * Process a message from the thread, invoking the appropriate tool and returning the result.
5
5
  * @param message - The message to handle
6
6
  * @param toolRegistry - The tool registry
7
- * @returns The result of the tool call
7
+ * @returns The result of the tool call along with the tool definition
8
8
  */
9
9
  export declare const handleToolCall: (message: TamboAI.Beta.Threads.ThreadMessage, toolRegistry: TamboToolRegistry, onCallUnregisteredTool?: (toolName: string, args: TamboAI.ToolCallParameter[]) => Promise<string>) => Promise<{
10
- result: string;
10
+ result: unknown;
11
11
  error?: string;
12
+ tamboTool?: TamboTool;
12
13
  }>;
13
14
  //# sourceMappingURL=tool-caller.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-caller.d.ts","sourceRoot":"","sources":["../../src/util/tool-caller.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAEL,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AAGrC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GACzB,SAAS,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAC3C,cAAc,iBAAiB,EAC/B,yBAAyB,CACvB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,CAAC,iBAAiB,EAAE,KAC9B,OAAO,CAAC,MAAM,CAAC,KACnB,OAAO,CAAC;IACT,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CA+BA,CAAC"}
1
+ {"version":3,"file":"tool-caller.d.ts","sourceRoot":"","sources":["../../src/util/tool-caller.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAEL,SAAS,EACT,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AAGrC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GACzB,SAAS,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAC3C,cAAc,iBAAiB,EAC/B,yBAAyB,CACvB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,CAAC,iBAAiB,EAAE,KAC9B,OAAO,CAAC,MAAM,CAAC,KACnB,OAAO,CAAC;IACT,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAmCA,CAAC"}
@@ -6,14 +6,14 @@ const registry_1 = require("./registry");
6
6
  * Process a message from the thread, invoking the appropriate tool and returning the result.
7
7
  * @param message - The message to handle
8
8
  * @param toolRegistry - The tool registry
9
- * @returns The result of the tool call
9
+ * @returns The result of the tool call along with the tool definition
10
10
  */
11
11
  const handleToolCall = async (message, toolRegistry, onCallUnregisteredTool) => {
12
12
  if (!message?.toolCallRequest?.toolName) {
13
13
  throw new Error("Tool name is required");
14
14
  }
15
15
  try {
16
- const tool = findTool(message.toolCallRequest.toolName, toolRegistry);
16
+ const { tool, tamboTool } = findTool(message.toolCallRequest.toolName, toolRegistry);
17
17
  if (!tool) {
18
18
  if (onCallUnregisteredTool) {
19
19
  const result = await onCallUnregisteredTool(message.toolCallRequest.toolName, message.toolCallRequest.parameters);
@@ -25,6 +25,7 @@ const handleToolCall = async (message, toolRegistry, onCallUnregisteredTool) =>
25
25
  }
26
26
  return {
27
27
  result: await runToolChoice(message.toolCallRequest, tool),
28
+ tamboTool,
28
29
  };
29
30
  }
30
31
  catch (error) {
@@ -39,12 +40,15 @@ exports.handleToolCall = handleToolCall;
39
40
  const findTool = (toolName, toolRegistry) => {
40
41
  const registryTool = toolRegistry[toolName];
41
42
  if (!registryTool) {
42
- return null;
43
+ return { tool: null, tamboTool: null };
43
44
  }
44
45
  const contextTool = (0, registry_1.mapTamboToolToContextTool)(registryTool);
45
46
  return {
46
- getComponentContext: registryTool.tool,
47
- definition: contextTool,
47
+ tool: {
48
+ getComponentContext: registryTool.tool,
49
+ definition: contextTool,
50
+ },
51
+ tamboTool: registryTool,
48
52
  };
49
53
  };
50
54
  const runToolChoice = async (toolCallRequest, tool) => {
@@ -1 +1 @@
1
- {"version":3,"file":"tool-caller.js","sourceRoot":"","sources":["../../src/util/tool-caller.ts"],"names":[],"mappings":";;;AAKA,yCAAuD;AAEvD;;;;;GAKG;AACI,MAAM,cAAc,GAAG,KAAK,EACjC,OAA2C,EAC3C,YAA+B,EAC/B,sBAGoB,EAInB,EAAE;IACH,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QACtE,IAAI,CAAC,IAAI,EAA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,eAAe,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IAEzE,OAAO,MAAM,IAAI,CAAC,mBAAmB,CAAC,GAAG,eAAe,CAAC,CAAC;AAC5D,CAAC,CAAC","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport {\n ComponentContextTool,\n TamboToolRegistry,\n} from \"../model/component-metadata\";\nimport { mapTamboToolToContextTool } from \"./registry\";\n\n/**\n * Process a message from the thread, invoking the appropriate tool and returning the result.\n * @param message - The message to handle\n * @param toolRegistry - The tool registry\n * @returns The result of the tool call\n */\nexport const handleToolCall = async (\n message: TamboAI.Beta.Threads.ThreadMessage,\n toolRegistry: TamboToolRegistry,\n onCallUnregisteredTool?: (\n toolName: string,\n args: TamboAI.ToolCallParameter[],\n ) => Promise<string>,\n): Promise<{\n result: string;\n error?: string;\n}> => {\n if (!message?.toolCallRequest?.toolName) {\n throw new Error(\"Tool name is required\");\n }\n\n try {\n const tool = findTool(message.toolCallRequest.toolName, toolRegistry);\n if (!tool) {\n if (onCallUnregisteredTool) {\n const result = await onCallUnregisteredTool(\n message.toolCallRequest.toolName,\n message.toolCallRequest.parameters,\n );\n return {\n result,\n };\n }\n throw new Error(\n `Tool ${message.toolCallRequest.toolName} not found in registry`,\n );\n }\n return {\n result: await runToolChoice(message.toolCallRequest, tool),\n };\n } catch (error) {\n console.error(\"Error in calling tool: \", error);\n return {\n result: `When attempting to call tool ${message.toolCallRequest.toolName} the following error occurred: ${error}. Explain to the user that the tool call failed and try again if needed.`,\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n};\n\nconst findTool = (toolName: string, toolRegistry: TamboToolRegistry) => {\n const registryTool = toolRegistry[toolName];\n\n if (!registryTool) {\n return null;\n }\n\n const contextTool = mapTamboToolToContextTool(registryTool);\n return {\n getComponentContext: registryTool.tool,\n definition: contextTool,\n };\n};\n\nconst runToolChoice = async (\n toolCallRequest: TamboAI.ToolCallRequest,\n tool: ComponentContextTool,\n): Promise<any> => {\n // Assumes parameters are in the order they are defined in the tool\n const parameterValues =\n toolCallRequest.parameters?.map((param) => param.parameterValue) ?? [];\n\n return await tool.getComponentContext(...parameterValues);\n};\n"]}
1
+ {"version":3,"file":"tool-caller.js","sourceRoot":"","sources":["../../src/util/tool-caller.ts"],"names":[],"mappings":";;;AAMA,yCAAuD;AAEvD;;;;;GAKG;AACI,MAAM,cAAc,GAAG,KAAK,EACjC,OAA2C,EAC3C,YAA+B,EAC/B,sBAGoB,EAKnB,EAAE;IACH,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,CAAC;QACH,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,QAAQ,CAClC,OAAO,CAAC,eAAe,CAAC,QAAQ,EAChC,YAAY,CACb,CAAC;QACF,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,sBAAsB,EAAE,CAAC;gBAC3B,MAAM,MAAM,GAAG,MAAM,sBAAsB,CACzC,OAAO,CAAC,eAAe,CAAC,QAAQ,EAChC,OAAO,CAAC,eAAe,CAAC,UAAU,CACnC,CAAC;gBACF,OAAO;oBACL,MAAM;iBACP,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,KAAK,CACb,QAAQ,OAAO,CAAC,eAAe,CAAC,QAAQ,wBAAwB,CACjE,CAAC;QACJ,CAAC;QACD,OAAO;YACL,MAAM,EAAE,MAAM,aAAa,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC;YAC1D,SAAS;SACV,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QAChD,OAAO;YACL,MAAM,EAAE,gCAAgC,OAAO,CAAC,eAAe,CAAC,QAAQ,kCAAkC,KAAK,0EAA0E;YACzL,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;SAChE,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AA9CW,QAAA,cAAc,kBA8CzB;AAEF,MAAM,QAAQ,GAAG,CACf,QAAgB,EAChB,YAA+B,EAMG,EAAE;IACpC,MAAM,YAAY,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;IAE5C,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACzC,CAAC;IAED,MAAM,WAAW,GAAG,IAAA,oCAAyB,EAAC,YAAY,CAAC,CAAC;IAC5D,OAAO;QACL,IAAI,EAAE;YACJ,mBAAmB,EAAE,YAAY,CAAC,IAAI;YACtC,UAAU,EAAE,WAAW;SACxB;QACD,SAAS,EAAE,YAAY;KACxB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,KAAK,EACzB,eAAwC,EACxC,IAA0B,EACZ,EAAE;IAChB,mEAAmE;IACnE,MAAM,eAAe,GACnB,eAAe,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IAEzE,OAAO,MAAM,IAAI,CAAC,mBAAmB,CAAC,GAAG,eAAe,CAAC,CAAC;AAC5D,CAAC,CAAC","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport {\n ComponentContextTool,\n TamboTool,\n TamboToolRegistry,\n} from \"../model/component-metadata\";\nimport { mapTamboToolToContextTool } from \"./registry\";\n\n/**\n * Process a message from the thread, invoking the appropriate tool and returning the result.\n * @param message - The message to handle\n * @param toolRegistry - The tool registry\n * @returns The result of the tool call along with the tool definition\n */\nexport const handleToolCall = async (\n message: TamboAI.Beta.Threads.ThreadMessage,\n toolRegistry: TamboToolRegistry,\n onCallUnregisteredTool?: (\n toolName: string,\n args: TamboAI.ToolCallParameter[],\n ) => Promise<string>,\n): Promise<{\n result: unknown;\n error?: string;\n tamboTool?: TamboTool;\n}> => {\n if (!message?.toolCallRequest?.toolName) {\n throw new Error(\"Tool name is required\");\n }\n\n try {\n const { tool, tamboTool } = findTool(\n message.toolCallRequest.toolName,\n toolRegistry,\n );\n if (!tool) {\n if (onCallUnregisteredTool) {\n const result = await onCallUnregisteredTool(\n message.toolCallRequest.toolName,\n message.toolCallRequest.parameters,\n );\n return {\n result,\n };\n }\n throw new Error(\n `Tool ${message.toolCallRequest.toolName} not found in registry`,\n );\n }\n return {\n result: await runToolChoice(message.toolCallRequest, tool),\n tamboTool,\n };\n } catch (error) {\n console.error(\"Error in calling tool: \", error);\n return {\n result: `When attempting to call tool ${message.toolCallRequest.toolName} the following error occurred: ${error}. Explain to the user that the tool call failed and try again if needed.`,\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n};\n\nconst findTool = (\n toolName: string,\n toolRegistry: TamboToolRegistry,\n):\n | {\n tool: ComponentContextTool;\n tamboTool: TamboTool;\n }\n | { tool: null; tamboTool: null } => {\n const registryTool = toolRegistry[toolName];\n\n if (!registryTool) {\n return { tool: null, tamboTool: null };\n }\n\n const contextTool = mapTamboToolToContextTool(registryTool);\n return {\n tool: {\n getComponentContext: registryTool.tool,\n definition: contextTool,\n },\n tamboTool: registryTool,\n };\n};\n\nconst runToolChoice = async (\n toolCallRequest: TamboAI.ToolCallRequest,\n tool: ComponentContextTool,\n): Promise<any> => {\n // Assumes parameters are in the order they are defined in the tool\n const parameterValues =\n toolCallRequest.parameters?.map((param) => param.parameterValue) ?? [];\n\n return await tool.getComponentContext(...parameterValues);\n};\n"]}
@@ -2,16 +2,16 @@ import { QueryKey, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQu
2
2
  /**
3
3
  * Wrapper around useQuery that uses the internal tambo query client.
4
4
  *
5
- * Use this instead of useQuery from @tanstack/react-query
6
- * @param options - The options for the query, same as useQuery from @tanstack/react-query
5
+ * Use this instead of useQuery from `@tanstack/react-query`
6
+ * @param options - The options for the query, same as useQuery from `@tanstack/react-query`
7
7
  * @returns The query result
8
8
  */
9
9
  export declare function useTamboQuery<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>): UseQueryResult<import("@tanstack/react-query").NoInfer<TData>, TError>;
10
10
  /**
11
11
  * Wrapper around useMutation that uses the internal tambo query client.
12
12
  *
13
- * Use this instead of useMutation from @tanstack/react-query
14
- * @param options - The options for the mutation, same as useMutation from @tanstack/react-query
13
+ * Use this instead of useMutation from `@tanstack/react-query`
14
+ * @param options - The options for the mutation, same as useMutation from `@tanstack/react-query`
15
15
  * @returns The mutation result
16
16
  */
17
17
  export declare function useTamboMutation<TData = unknown, TError = Error, TVariables = void, TContext = unknown>(options: UseMutationOptions<TData, TError, TVariables, TContext>): UseMutationResult<TData, TError, TVariables, TContext>;
@@ -4,8 +4,8 @@ import { useTamboQueryClient } from "../providers/tambo-client-provider";
4
4
  /**
5
5
  * Wrapper around useQuery that uses the internal tambo query client.
6
6
  *
7
- * Use this instead of useQuery from @tanstack/react-query
8
- * @param options - The options for the query, same as useQuery from @tanstack/react-query
7
+ * Use this instead of useQuery from `@tanstack/react-query`
8
+ * @param options - The options for the query, same as useQuery from `@tanstack/react-query`
9
9
  * @returns The query result
10
10
  */
11
11
  export function useTamboQuery(options) {
@@ -15,8 +15,8 @@ export function useTamboQuery(options) {
15
15
  /**
16
16
  * Wrapper around useMutation that uses the internal tambo query client.
17
17
  *
18
- * Use this instead of useMutation from @tanstack/react-query
19
- * @param options - The options for the mutation, same as useMutation from @tanstack/react-query
18
+ * Use this instead of useMutation from `@tanstack/react-query`
19
+ * @param options - The options for the mutation, same as useMutation from `@tanstack/react-query`
20
20
  * @returns The mutation result
21
21
  */
22
22
  export function useTamboMutation(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"react-query-hooks.js","sourceRoot":"","sources":["../../src/hooks/react-query-hooks.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,OAAO,EAEL,WAAW,EAGX,QAAQ,GAGT,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAK3B,OAAgE;IAChE,MAAM,WAAW,GAAG,mBAAmB,EAAE,CAAC;IAC1C,OAAO,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAK9B,OAAgE;IAChE,MAAM,WAAW,GAAG,mBAAmB,EAAE,CAAC;IAC1C,OAAO,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["// tamboHooks.ts\nimport {\n QueryKey,\n useMutation,\n UseMutationOptions,\n UseMutationResult,\n useQuery,\n UseQueryOptions,\n UseQueryResult,\n} from \"@tanstack/react-query\";\nimport { useTamboQueryClient } from \"../providers/tambo-client-provider\";\n\n/**\n * Wrapper around useQuery that uses the internal tambo query client.\n *\n * Use this instead of useQuery from @tanstack/react-query\n * @param options - The options for the query, same as useQuery from @tanstack/react-query\n * @returns The query result\n */\nexport function useTamboQuery<\n TQueryFnData = unknown,\n TError = Error,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>) {\n const queryClient = useTamboQueryClient();\n return useQuery(options, queryClient);\n}\n\n/**\n * Wrapper around useMutation that uses the internal tambo query client.\n *\n * Use this instead of useMutation from @tanstack/react-query\n * @param options - The options for the mutation, same as useMutation from @tanstack/react-query\n * @returns The mutation result\n */\nexport function useTamboMutation<\n TData = unknown,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n>(options: UseMutationOptions<TData, TError, TVariables, TContext>) {\n const queryClient = useTamboQueryClient();\n return useMutation(options, queryClient);\n}\n\n/**\n * Type alias for the result of a mutation.\n */\nexport type UseTamboMutationResult<\n TData = unknown,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n> = UseMutationResult<TData, TError, TVariables, TContext>;\n\n/**\n * Type alias for the result of a query.\n */\nexport type UseTamboQueryResult<\n TData = unknown,\n TError = Error,\n> = UseQueryResult<TData, TError>;\n"]}
1
+ {"version":3,"file":"react-query-hooks.js","sourceRoot":"","sources":["../../src/hooks/react-query-hooks.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,OAAO,EAEL,WAAW,EAGX,QAAQ,GAGT,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAK3B,OAAgE;IAChE,MAAM,WAAW,GAAG,mBAAmB,EAAE,CAAC;IAC1C,OAAO,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAK9B,OAAgE;IAChE,MAAM,WAAW,GAAG,mBAAmB,EAAE,CAAC;IAC1C,OAAO,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["// tamboHooks.ts\nimport {\n QueryKey,\n useMutation,\n UseMutationOptions,\n UseMutationResult,\n useQuery,\n UseQueryOptions,\n UseQueryResult,\n} from \"@tanstack/react-query\";\nimport { useTamboQueryClient } from \"../providers/tambo-client-provider\";\n\n/**\n * Wrapper around useQuery that uses the internal tambo query client.\n *\n * Use this instead of useQuery from `@tanstack/react-query`\n * @param options - The options for the query, same as useQuery from `@tanstack/react-query`\n * @returns The query result\n */\nexport function useTamboQuery<\n TQueryFnData = unknown,\n TError = Error,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>) {\n const queryClient = useTamboQueryClient();\n return useQuery(options, queryClient);\n}\n\n/**\n * Wrapper around useMutation that uses the internal tambo query client.\n *\n * Use this instead of useMutation from `@tanstack/react-query`\n * @param options - The options for the mutation, same as useMutation from `@tanstack/react-query`\n * @returns The mutation result\n */\nexport function useTamboMutation<\n TData = unknown,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n>(options: UseMutationOptions<TData, TError, TVariables, TContext>) {\n const queryClient = useTamboQueryClient();\n return useMutation(options, queryClient);\n}\n\n/**\n * Type alias for the result of a mutation.\n */\nexport type UseTamboMutationResult<\n TData = unknown,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n> = UseMutationResult<TData, TError, TVariables, TContext>;\n\n/**\n * Type alias for the result of a query.\n */\nexport type UseTamboQueryResult<\n TData = unknown,\n TError = Error,\n> = UseQueryResult<TData, TError>;\n"]}
package/esm/index.d.ts CHANGED
@@ -5,16 +5,17 @@ export { useMessageImages, type StagedImage } from "./hooks/use-message-images";
5
5
  export { useTamboStreamingProps } from "./hooks/use-streaming-props";
6
6
  export * from "./hooks/use-suggestions";
7
7
  export { useTamboStreamStatus, type PropStatus, type StreamStatus, } from "./hooks/use-tambo-stream-status";
8
- export { TamboClientProvider, TamboComponentProvider, TamboContextHelpersProvider, TamboPropStreamProvider, TamboProvider, TamboStubProvider, TamboThreadInputProvider, TamboThreadProvider, useIsTamboTokenUpdating, useTambo, useTamboClient, useTamboContextHelpers, useTamboGenerationStage, useTamboStream, useTamboThread, useTamboThreadInput, type TamboComponent, type TamboContextHelpersContextProps, type TamboContextHelpersProviderProps, type TamboRegistryContext, type TamboStubProviderProps, type TamboThreadInputContextProps, } from "./providers";
8
+ export { TamboClientProvider, TamboComponentProvider, TamboContextHelpersProvider, TamboPropStreamProvider, TamboProvider, TamboStubProvider, TamboThreadInputProvider, TamboThreadProvider, useIsTamboTokenUpdating, useTambo, useTamboClient, useTamboContextHelpers, useTamboGenerationStage, useTamboStream, useTamboThread, useTamboThreadInput, type TamboComponent, type TamboContextHelpersContextProps, type TamboContextHelpersProviderProps, type TamboRegistryContext, type TamboStubProviderProps, type TamboThreadInputContextProps, type TamboThreadProviderProps, } from "./providers";
9
9
  export type { APIError, RateLimitError, TamboAIError, } from "@tambo-ai/typescript-sdk";
10
10
  export type { Suggestion, SuggestionGenerateParams, SuggestionGenerateResponse, SuggestionListResponse, } from "@tambo-ai/typescript-sdk/resources/beta/threads/suggestions";
11
11
  export { useTamboThreadList } from "./hooks/use-tambo-threads";
12
12
  export { type ComponentContextToolMetadata, type ComponentRegistry, type ParameterSpec, type RegisteredComponent, type TamboTool, } from "./model/component-metadata";
13
13
  export { GenerationStage, type TamboThreadMessage, } from "./model/generate-component-response";
14
14
  export { type TamboThread } from "./model/tambo-thread";
15
+ export { type InitialTamboThreadMessage } from "./providers/tambo-thread-provider";
15
16
  export type { TamboInteractableComponent as InteractableComponent, TamboInteractableContext, } from "./model/tambo-interactable";
16
17
  export { withTamboInteractable as withInteractable, type InteractableConfig, type WithTamboInteractableProps, } from "./providers/hoc/with-tambo-interactable";
17
- export { useTamboInteractable, useCurrentInteractablesSnapshot, } from "./providers/tambo-interactable-provider";
18
+ export { useCurrentInteractablesSnapshot, useTamboInteractable, } from "./providers/tambo-interactable-provider";
18
19
  export { currentPageContextHelper, currentTimeContextHelper, } from "./context-helpers";
19
20
  export type { AdditionalContext, ContextHelperFn, ContextHelpers, } from "./context-helpers";
20
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAChF,O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OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,SAAS,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,eAAe,EACf,KAAK,kBAAkB,GACxB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAEnF,YAAY,EACV,0BAA0B,IAAI,qBAAqB,EACnD,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,qBAAqB,IAAI,gBAAgB,EACzC,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,GAChC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,GACf,MAAM,mBAAmB,CAAC"}
package/esm/index.js CHANGED
@@ -10,7 +10,7 @@ export { TamboClientProvider, TamboComponentProvider, TamboContextHelpersProvide
10
10
  export { useTamboThreadList } from "./hooks/use-tambo-threads";
11
11
  export { GenerationStage, } from "./model/generate-component-response";
12
12
  export { withTamboInteractable as withInteractable, } from "./providers/hoc/with-tambo-interactable";
13
- export { useTamboInteractable, useCurrentInteractablesSnapshot, } from "./providers/tambo-interactable-provider";
13
+ export { useCurrentInteractablesSnapshot, useTamboInteractable, } from "./providers/tambo-interactable-provider";
14
14
  // Context helpers exports
15
15
  export { currentPageContextHelper, currentTimeContextHelper, } from "./context-helpers";
16
16
  //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAoB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,GAGrB,MAAM,iCAAiC,CAAC;AAEzC,gCAAgC;AAChC,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,EAC3B,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,QAAQ,EACR,cAAc,EACd,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,mBAAmB,GAOpB,MAAM,aAAa,CAAC;AAcrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAQ/D,OAAO,EACL,eAAe,GAEhB,MAAM,qCAAqC,CAAC;AAO7C,OAAO,EACL,qBAAqB,IAAI,gBAAgB,GAG1C,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,oBAAoB,EACpB,+BAA+B,GAChC,MAAM,yCAAyC,CAAC;AAEjD,0BAA0B;AAC1B,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC","sourcesContent":["/** Exports for the library. Only publically available exports are re-exported here. Anything not exported here is not supported and may change or break at any time. */\n\nexport { useTamboComponentState } from \"./hooks/use-component-state\";\nexport {\n TamboMessageProvider,\n useTamboCurrentMessage,\n} from \"./hooks/use-current-message\";\nexport { useMessageImages, type StagedImage } from \"./hooks/use-message-images\";\nexport { useTamboStreamingProps } from \"./hooks/use-streaming-props\";\nexport * from \"./hooks/use-suggestions\";\nexport {\n useTamboStreamStatus,\n type PropStatus,\n type StreamStatus,\n} from \"./hooks/use-tambo-stream-status\";\n\n// Re-export provider components\nexport {\n TamboClientProvider,\n TamboComponentProvider,\n TamboContextHelpersProvider,\n TamboPropStreamProvider,\n TamboProvider,\n TamboStubProvider,\n TamboThreadInputProvider,\n TamboThreadProvider,\n useIsTamboTokenUpdating,\n useTambo,\n useTamboClient,\n useTamboContextHelpers,\n useTamboGenerationStage,\n useTamboStream,\n useTamboThread,\n useTamboThreadInput,\n type TamboComponent,\n type TamboContextHelpersContextProps,\n type TamboContextHelpersProviderProps,\n type TamboRegistryContext,\n type TamboStubProviderProps,\n type TamboThreadInputContextProps,\n} from \"./providers\";\n\n// Re-export types from Tambo Node SDK\nexport type {\n APIError,\n RateLimitError,\n TamboAIError,\n} from \"@tambo-ai/typescript-sdk\";\nexport type {\n Suggestion,\n SuggestionGenerateParams,\n SuggestionGenerateResponse,\n SuggestionListResponse,\n} from \"@tambo-ai/typescript-sdk/resources/beta/threads/suggestions\";\nexport { useTamboThreadList } from \"./hooks/use-tambo-threads\";\nexport {\n type ComponentContextToolMetadata,\n type ComponentRegistry,\n type ParameterSpec,\n type RegisteredComponent,\n type TamboTool,\n} from \"./model/component-metadata\";\nexport {\n GenerationStage,\n type TamboThreadMessage,\n} from \"./model/generate-component-response\";\nexport { type TamboThread } from \"./model/tambo-thread\";\n\nexport type {\n TamboInteractableComponent as InteractableComponent,\n TamboInteractableContext,\n} from \"./model/tambo-interactable\";\nexport {\n withTamboInteractable as withInteractable,\n type InteractableConfig,\n type WithTamboInteractableProps,\n} from \"./providers/hoc/with-tambo-interactable\";\nexport {\n useTamboInteractable,\n useCurrentInteractablesSnapshot,\n} from \"./providers/tambo-interactable-provider\";\n\n// Context helpers exports\nexport {\n currentPageContextHelper,\n currentTimeContextHelper,\n} from \"./context-helpers\";\nexport type {\n AdditionalContext,\n ContextHelperFn,\n ContextHelpers,\n} from \"./context-helpers\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAoB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,GAGrB,MAAM,iCAAiC,CAAC;AAEzC,gCAAgC;AAChC,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,EAC3B,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,QAAQ,EACR,cAAc,EACd,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,mBAAmB,GAQpB,MAAM,aAAa,CAAC;AAcrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAQ/D,OAAO,EACL,eAAe,GAEhB,MAAM,qCAAqC,CAAC;AAQ7C,OAAO,EACL,qBAAqB,IAAI,gBAAgB,GAG1C,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,yCAAyC,CAAC;AAEjD,0BAA0B;AAC1B,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC","sourcesContent":["/** Exports for the library. Only publically available exports are re-exported here. Anything not exported here is not supported and may change or break at any time. */\n\nexport { useTamboComponentState } from \"./hooks/use-component-state\";\nexport {\n TamboMessageProvider,\n useTamboCurrentMessage,\n} from \"./hooks/use-current-message\";\nexport { useMessageImages, type StagedImage } from \"./hooks/use-message-images\";\nexport { useTamboStreamingProps } from \"./hooks/use-streaming-props\";\nexport * from \"./hooks/use-suggestions\";\nexport {\n useTamboStreamStatus,\n type PropStatus,\n type StreamStatus,\n} from \"./hooks/use-tambo-stream-status\";\n\n// Re-export provider components\nexport {\n TamboClientProvider,\n TamboComponentProvider,\n TamboContextHelpersProvider,\n TamboPropStreamProvider,\n TamboProvider,\n TamboStubProvider,\n TamboThreadInputProvider,\n TamboThreadProvider,\n useIsTamboTokenUpdating,\n useTambo,\n useTamboClient,\n useTamboContextHelpers,\n useTamboGenerationStage,\n useTamboStream,\n useTamboThread,\n useTamboThreadInput,\n type TamboComponent,\n type TamboContextHelpersContextProps,\n type TamboContextHelpersProviderProps,\n type TamboRegistryContext,\n type TamboStubProviderProps,\n type TamboThreadInputContextProps,\n type TamboThreadProviderProps,\n} from \"./providers\";\n\n// Re-export types from Tambo Node SDK\nexport type {\n APIError,\n RateLimitError,\n TamboAIError,\n} from \"@tambo-ai/typescript-sdk\";\nexport type {\n Suggestion,\n SuggestionGenerateParams,\n SuggestionGenerateResponse,\n SuggestionListResponse,\n} from \"@tambo-ai/typescript-sdk/resources/beta/threads/suggestions\";\nexport { useTamboThreadList } from \"./hooks/use-tambo-threads\";\nexport {\n type ComponentContextToolMetadata,\n type ComponentRegistry,\n type ParameterSpec,\n type RegisteredComponent,\n type TamboTool,\n} from \"./model/component-metadata\";\nexport {\n GenerationStage,\n type TamboThreadMessage,\n} from \"./model/generate-component-response\";\nexport { type TamboThread } from \"./model/tambo-thread\";\nexport { type InitialTamboThreadMessage } from \"./providers/tambo-thread-provider\";\n\nexport type {\n TamboInteractableComponent as InteractableComponent,\n TamboInteractableContext,\n} from \"./model/tambo-interactable\";\nexport {\n withTamboInteractable as withInteractable,\n type InteractableConfig,\n type WithTamboInteractableProps,\n} from \"./providers/hoc/with-tambo-interactable\";\nexport {\n useCurrentInteractablesSnapshot,\n useTamboInteractable,\n} from \"./providers/tambo-interactable-provider\";\n\n// Context helpers exports\nexport {\n currentPageContextHelper,\n currentTimeContextHelper,\n} from \"./context-helpers\";\nexport type {\n AdditionalContext,\n ContextHelperFn,\n ContextHelpers,\n} from \"./context-helpers\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-mcp-provider.d.ts","sourceRoot":"","sources":["../../src/mcp/tambo-mcp-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,EAAE,EAIH,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEvD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAsB5D;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACvD,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,eAAe,EAAE,KAAK,CAAC;CACxB;AAED,MAAM,MAAM,SAAS,GAAG,kBAAkB,GAAG,eAAe,CAAC;AAG7D;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC;IAChC,UAAU,EAAE,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAwIA,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,kBAAkB,mBAE9B,CAAC"}
1
+ {"version":3,"file":"tambo-mcp-provider.d.ts","sourceRoot":"","sources":["../../src/mcp/tambo-mcp-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,EAAE,EAIH,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEvD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAsB5D;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACvD,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,eAAe,EAAE,KAAK,CAAC;CACxB;AAED,MAAM,MAAM,SAAS,GAAG,kBAAkB,GAAG,eAAe,CAAC;AAG7D;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC;IAChC,UAAU,EAAE,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAgJA,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,kBAAkB,mBAE9B,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { deepEqual } from "fast-equals";
2
2
  import React, { createContext, useContext, useEffect, useState, } from "react";
3
+ import { isContentPartArray, toText } from "../util/content-parts";
3
4
  import { useTamboRegistry } from "../providers/tambo-registry-provider";
4
5
  import { MCPClient, MCPTransport } from "./mcp-client";
5
6
  /**
@@ -121,6 +122,14 @@ export const TamboMcpProvider = ({ mcpServers, children }) => {
121
122
  return result.content;
122
123
  },
123
124
  toolSchema: tool.inputSchema,
125
+ transformToContent: (content) => {
126
+ // MCP tools can return content in various formats; pass through arrays of content parts
127
+ // unchanged, otherwise stringify into a text content part.
128
+ if (isContentPartArray(content)) {
129
+ return content;
130
+ }
131
+ return [{ type: "text", text: toText(content) }];
132
+ },
124
133
  });
125
134
  });
126
135
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-mcp-provider.js","sourceRoot":"","sources":["../../src/mcp/tambo-mcp-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,UAAU,EACV,SAAS,EACT,QAAQ,GACT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC9C,OAAO,wBAAwB,CAAC;IAClC,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,OAAO;aACtB,MAAM,CACL,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CACxE;aACA,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE5B,OAAO,SAAS,CAAC,MAAM,GAAG,CAAC;YACzB,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;YACrB,CAAC,CAAC,wCAAwC,CAAC;IAC/C,CAAC;IAED,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,GAAG,OAAO,EAAE,CAAC;AACtB,CAAC;AAqBD,MAAM,kBAAkB,GAAG,a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cesContent":["import { deepEqual } from \"fast-equals\";\nimport React, {\n createContext,\n FC,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport { TamboTool } from \"../model/component-metadata\";\nimport { useTamboRegistry } from \"../providers/tambo-registry-provider\";\nimport { MCPClient, MCPTransport } from \"./mcp-client\";\n\n/**\n * Extracts error message from MCP tool result content.\n * Handles both array and string content formats.\n * Always returns a string, even for invalid/null inputs.\n * @returns The extracted error message as a string\n */\nexport function extractErrorMessage(content: unknown): string {\n if (content === undefined || content === null) {\n return \"Unknown error occurred\";\n }\n\n if (Array.isArray(content)) {\n const textItems = content\n .filter(\n (item) => item && item.type === \"text\" && typeof item.text === \"string\",\n )\n .map((item) => item.text);\n\n return textItems.length > 0\n ? textItems.join(\" \")\n : \"Error occurred but no details provided\";\n }\n\n if (typeof content === \"object\") {\n return JSON.stringify(content);\n }\n\n return `${content}`;\n}\n\nexport interface McpServerInfo {\n name?: string;\n url: string;\n description?: string;\n transport?: MCPTransport;\n customHeaders?: Record<string, string>;\n}\n\nexport interface ConnectedMcpServer extends McpServerInfo {\n client: MCPClient;\n}\n\nexport interface FailedMcpServer extends McpServerInfo {\n client?: never;\n connectionError: Error;\n}\n\nexport type McpServer = ConnectedMcpServer | FailedMcpServer;\n\nconst McpProviderContext = createContext<McpServer[]>([]);\n/**\n * This provider is used to register tools from MCP servers.\n * @returns the wrapped children\n */\nexport const TamboMcpProvider: FC<{\n mcpServers: (McpServerInfo | string)[];\n children: React.ReactNode;\n}> = ({ mcpServers, children }) => {\n const { registerTool } = useTamboRegistry();\n const [connectedMcpServers, setConnectedMcpServers] = useState<McpServer[]>(\n [],\n );\n\n useEffect(() => {\n if (!mcpServers) {\n return;\n }\n async function registerMcpServers(mcpServerInfos: McpServerInfo[]) {\n // Maps tool names to the MCP client that registered them\n const mcpServerMap = new Map<string, McpServer>();\n setConnectedMcpServers((prev) =>\n // remove any servers that are not in the new list\n prev.filter((s) =>\n mcpServerInfos.some((mcpServerInfo) =>\n equalsMcpServer(s, mcpServerInfo),\n ),\n ),\n );\n\n // initialize the MCP clients, converting McpServerInfo -> McpServer\n const mcpServers = await Promise.allSettled(\n mcpServerInfos.map(async (mcpServerInfo): Promise<McpServer> => {\n try {\n const client = await MCPClient.create(\n mcpServerInfo.url,\n mcpServerInfo.transport,\n mcpServerInfo.customHeaders,\n undefined, // no oauth support yet\n undefined, // starting with no session id at first.\n );\n const connectedMcpServer = {\n ...mcpServerInfo,\n client: client,\n };\n // note because the promises may resolve in any order, the resulting\n // array may not be in the same order as the input array\n setConnectedMcpServers((prev) => [\n // replace the server if it already exists\n ...prev.filter((s) => !equalsMcpServer(s, mcpServerInfo)),\n connectedMcpServer,\n ]);\n return connectedMcpServer;\n } catch (error) {\n const failedMcpServer = {\n ...mcpServerInfo,\n connectionError: error as Error,\n };\n // note because the promises may resolve in any order, the resulting\n // array may not be in the same order as the input array\n setConnectedMcpServers((prev) => [\n // replace the server if it already exists\n ...prev.filter((s) => !equalsMcpServer(s, mcpServerInfo)),\n failedMcpServer,\n ]);\n return failedMcpServer;\n }\n }),\n );\n\n // note do not rely on the state\n const connectedMcpServers = mcpServers\n .filter((result) => result.status === \"fulfilled\")\n .map((result) => result.value);\n\n // Now create a map of tool name to MCP client\n const serverToolLists = connectedMcpServers.map(async (mcpServer) => {\n const tools = (await mcpServer.client?.listTools()) ?? [];\n tools.forEach((tool) => {\n mcpServerMap.set(tool.name, mcpServer);\n });\n return tools;\n });\n const toolResults = await Promise.allSettled(serverToolLists);\n\n // Just log the failed tools, we can't do anything about them\n const failedTools = toolResults.filter(\n (result) => result.status === \"rejected\",\n );\n if (failedTools.length > 0) {\n console.error(\n \"Failed to register tools from MCP servers:\",\n failedTools.map((result) => result.reason),\n );\n }\n\n // Register the successful tools\n const allTools = toolResults\n .filter((result) => result.status === \"fulfilled\")\n .map((result) => result.value)\n .flat();\n allTools.forEach((tool) => {\n registerTool({\n description: tool.description ?? \"\",\n name: tool.name,\n tool: async (args: Record<string, unknown>) => {\n const mcpServer = mcpServerMap.get(tool.name);\n if (!mcpServer) {\n // should never happen\n throw new Error(`MCP server for tool ${tool.name} not found`);\n }\n if (!mcpServer.client) {\n // this can't actually happen because the tool can't be registered if the server is not connected\n throw new Error(\n `MCP server for tool ${tool.name} is not connected`,\n );\n }\n const result = await mcpServer.client.callTool(tool.name, args);\n if (result.isError) {\n const errorMessage = extractErrorMessage(result.content);\n throw new Error(errorMessage);\n }\n return result.content;\n },\n toolSchema: tool.inputSchema as TamboTool[\"toolSchema\"],\n });\n });\n }\n\n // normalize the server infos\n const mcpServerInfos = mcpServers.map((mcpServer) =>\n typeof mcpServer === \"string\"\n ? { url: mcpServer, transport: MCPTransport.SSE }\n : mcpServer,\n );\n\n registerMcpServers(mcpServerInfos);\n }, [mcpServers, registerTool]);\n\n return (\n <McpProviderContext.Provider value={connectedMcpServers}>\n {children}\n </McpProviderContext.Provider>\n );\n};\n\n/**\n * Hook to access the actual MCP servers, as they are connected (or fail to\n * connect).\n *\n * You can call methods on the MCP client that is included in the MCP server\n * object.\n *\n * If the server fails to connect, the `client` property will be `undefined` and\n * the `connectionError` property will be set.\n *\n * For example, to forcibly disconnect and reconnect all MCP servers:\n *\n * ```tsx\n * const mcpServers = useTamboMcpServers();\n * mcpServers.forEach((mcpServer) => {\n * mcpServer.client?.reconnect();\n * });\n * ```\n *\n * Note that the MCP servers are not guaranteed to be in the same order as the\n * input array, because they are added as they are connected.\n * @returns The MCP servers\n */\nexport const useTamboMcpServers = () => {\n return useContext(McpProviderContext);\n};\nfunction equalsMcpServer(s: McpServer, mcpServerInfo: McpServerInfo): boolean {\n return (\n s.url === mcpServerInfo.url &&\n s.transport === mcpServerInfo.transport &&\n deepEqual(s.customHeaders, mcpServerInfo.customHeaders)\n );\n}\n"]}
1
+ {"version":3,"file":"tambo-mcp-provider.js","sourceRoot":"","sources":["../../src/mcp/tambo-mcp-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;A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,SAAS,KAAK,aAAa,CAAC,SAAS;QACvC,SAAS,CAAC,CAAC,CAAC,aAAa,EAAE,aAAa,CAAC,aAAa,CAAC,CACxD,CAAC;AACJ,CAAC","sourcesContent":["import { deepEqual } from \"fast-equals\";\nimport React, {\n createContext,\n FC,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport { TamboTool } from \"../model/component-metadata\";\nimport { isContentPartArray, toText } from \"../util/content-parts\";\nimport { useTamboRegistry } from \"../providers/tambo-registry-provider\";\nimport { MCPClient, MCPTransport } from \"./mcp-client\";\n\n/**\n * Extracts error message from MCP tool result content.\n * Handles both array and string content formats.\n * Always returns a string, even for invalid/null inputs.\n * @returns The extracted error message as a string\n */\nexport function extractErrorMessage(content: unknown): string {\n if (content === undefined || content === null) {\n return \"Unknown error occurred\";\n }\n\n if (Array.isArray(content)) {\n const textItems = content\n .filter(\n (item) => item && item.type === \"text\" && typeof item.text === \"string\",\n )\n .map((item) => item.text);\n\n return textItems.length > 0\n ? textItems.join(\" \")\n : \"Error occurred but no details provided\";\n }\n\n if (typeof content === \"object\") {\n return JSON.stringify(content);\n }\n\n return `${content}`;\n}\n\nexport interface McpServerInfo {\n name?: string;\n url: string;\n description?: string;\n transport?: MCPTransport;\n customHeaders?: Record<string, string>;\n}\n\nexport interface ConnectedMcpServer extends McpServerInfo {\n client: MCPClient;\n}\n\nexport interface FailedMcpServer extends McpServerInfo {\n client?: never;\n connectionError: Error;\n}\n\nexport type McpServer = ConnectedMcpServer | FailedMcpServer;\n\nconst McpProviderContext = createContext<McpServer[]>([]);\n/**\n * This provider is used to register tools from MCP servers.\n * @returns the wrapped children\n */\nexport const TamboMcpProvider: FC<{\n mcpServers: (McpServerInfo | string)[];\n children: React.ReactNode;\n}> = ({ mcpServers, children }) => {\n const { registerTool } = useTamboRegistry();\n const [connectedMcpServers, setConnectedMcpServers] = useState<McpServer[]>(\n [],\n );\n\n useEffect(() => {\n if (!mcpServers) {\n return;\n }\n async function registerMcpServers(mcpServerInfos: McpServerInfo[]) {\n // Maps tool names to the MCP client that registered them\n const mcpServerMap = new Map<string, McpServer>();\n setConnectedMcpServers((prev) =>\n // remove any servers that are not in the new list\n prev.filter((s) =>\n mcpServerInfos.some((mcpServerInfo) =>\n equalsMcpServer(s, mcpServerInfo),\n ),\n ),\n );\n\n // initialize the MCP clients, converting McpServerInfo -> McpServer\n const mcpServers = await Promise.allSettled(\n mcpServerInfos.map(async (mcpServerInfo): Promise<McpServer> => {\n try {\n const client = await MCPClient.create(\n mcpServerInfo.url,\n mcpServerInfo.transport,\n mcpServerInfo.customHeaders,\n undefined, // no oauth support yet\n undefined, // starting with no session id at first.\n );\n const connectedMcpServer = {\n ...mcpServerInfo,\n client: client,\n };\n // note because the promises may resolve in any order, the resulting\n // array may not be in the same order as the input array\n setConnectedMcpServers((prev) => [\n // replace the server if it already exists\n ...prev.filter((s) => !equalsMcpServer(s, mcpServerInfo)),\n connectedMcpServer,\n ]);\n return connectedMcpServer;\n } catch (error) {\n const failedMcpServer = {\n ...mcpServerInfo,\n connectionError: error as Error,\n };\n // note because the promises may resolve in any order, the resulting\n // array may not be in the same order as the input array\n setConnectedMcpServers((prev) => [\n // replace the server if it already exists\n ...prev.filter((s) => !equalsMcpServer(s, mcpServerInfo)),\n failedMcpServer,\n ]);\n return failedMcpServer;\n }\n }),\n );\n\n // note do not rely on the state\n const connectedMcpServers = mcpServers\n .filter((result) => result.status === \"fulfilled\")\n .map((result) => result.value);\n\n // Now create a map of tool name to MCP client\n const serverToolLists = connectedMcpServers.map(async (mcpServer) => {\n const tools = (await mcpServer.client?.listTools()) ?? [];\n tools.forEach((tool) => {\n mcpServerMap.set(tool.name, mcpServer);\n });\n return tools;\n });\n const toolResults = await Promise.allSettled(serverToolLists);\n\n // Just log the failed tools, we can't do anything about them\n const failedTools = toolResults.filter(\n (result) => result.status === \"rejected\",\n );\n if (failedTools.length > 0) {\n console.error(\n \"Failed to register tools from MCP servers:\",\n failedTools.map((result) => result.reason),\n );\n }\n\n // Register the successful tools\n const allTools = toolResults\n .filter((result) => result.status === \"fulfilled\")\n .map((result) => result.value)\n .flat();\n allTools.forEach((tool) => {\n registerTool({\n description: tool.description ?? \"\",\n name: tool.name,\n tool: async (args: Record<string, unknown>) => {\n const mcpServer = mcpServerMap.get(tool.name);\n if (!mcpServer) {\n // should never happen\n throw new Error(`MCP server for tool ${tool.name} not found`);\n }\n if (!mcpServer.client) {\n // this can't actually happen because the tool can't be registered if the server is not connected\n throw new Error(\n `MCP server for tool ${tool.name} is not connected`,\n );\n }\n const result = await mcpServer.client.callTool(tool.name, args);\n if (result.isError) {\n const errorMessage = extractErrorMessage(result.content);\n throw new Error(errorMessage);\n }\n return result.content;\n },\n toolSchema: tool.inputSchema as TamboTool[\"toolSchema\"],\n transformToContent: (content: unknown) => {\n // MCP tools can return content in various formats; pass through arrays of content parts\n // unchanged, otherwise stringify into a text content part.\n if (isContentPartArray(content)) {\n return content;\n }\n return [{ type: \"text\", text: toText(content) }];\n },\n });\n });\n }\n\n // normalize the server infos\n const mcpServerInfos = mcpServers.map((mcpServer) =>\n typeof mcpServer === \"string\"\n ? { url: mcpServer, transport: MCPTransport.SSE }\n : mcpServer,\n );\n\n registerMcpServers(mcpServerInfos);\n }, [mcpServers, registerTool]);\n\n return (\n <McpProviderContext.Provider value={connectedMcpServers}>\n {children}\n </McpProviderContext.Provider>\n );\n};\n\n/**\n * Hook to access the actual MCP servers, as they are connected (or fail to\n * connect).\n *\n * You can call methods on the MCP client that is included in the MCP server\n * object.\n *\n * If the server fails to connect, the `client` property will be `undefined` and\n * the `connectionError` property will be set.\n *\n * For example, to forcibly disconnect and reconnect all MCP servers:\n *\n * ```tsx\n * const mcpServers = useTamboMcpServers();\n * mcpServers.forEach((mcpServer) => {\n * mcpServer.client?.reconnect();\n * });\n * ```\n *\n * Note that the MCP servers are not guaranteed to be in the same order as the\n * input array, because they are added as they are connected.\n * @returns The MCP servers\n */\nexport const useTamboMcpServers = () => {\n return useContext(McpProviderContext);\n};\nfunction equalsMcpServer(s: McpServer, mcpServerInfo: McpServerInfo): boolean {\n return (\n s.url === mcpServerInfo.url &&\n s.transport === mcpServerInfo.transport &&\n deepEqual(s.customHeaders, mcpServerInfo.customHeaders)\n );\n}\n"]}
@@ -38,6 +38,13 @@ export interface TamboTool<Args extends z.ZodTuple<any, any> = z.ZodTuple<any, a
38
38
  description: string;
39
39
  tool: (...args: z.infer<Args>) => z.infer<Returns>;
40
40
  toolSchema: z.ZodFunction<Args, Returns> | JSONSchemaLite;
41
+ /**
42
+ * Optional function to transform the tool's return value into an array of content parts.
43
+ * If not provided, the return value will be converted to a string and wrapped in a text content part.
44
+ * @param result - The result returned by the tool function
45
+ * @returns An array of content parts to be sent back to the AI
46
+ */
47
+ transformToContent?: (result: z.infer<Returns>) => TamboAI.Beta.Threads.ChatCompletionContentPart[];
41
48
  }
42
49
  export type TamboToolAssociations = Record<string, string[]>;
43
50
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"component-metadata.d.ts","sourceRoot":"","sources":["../../src/model/component-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,KAAK,eAAe,MAAM,oBAAoB,CAAC;AACtD,+FAA+F;AAC/F,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,cAAc,GAAG;IACnD,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;CAC7C,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,4BACf,SAAQ,OAAO,CAAC,4BAA4B;IAC5C,UAAU,EAAE,aAAa,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,mBAAmB,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CA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,CAAC;IACzC;;;;OAIG;IACH,eAAe,CAAC,EAAE,GAAG,CAAC;IACtB,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IACtC,uDAAuD;IACvD,eAAe,CAAC,EAAE,SAAS,EAAE,CAAC;CAC/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"component-metadata.js","sourceRoot":"","sources":["../../src/model/component-metadata.ts"],"names":[],"mappings":"","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { JSONSchema7 } from \"json-schema\";\nimport { ComponentType } from \"react\";\nimport z from \"zod\";\nimport type zodToJsonSchema from \"zod-to-json-schema\";\n/** Extension of the ToolParameters interface from Tambo AI to include JSONSchema definition */\nexport type ParameterSpec = TamboAI.ToolParameters & {\n schema?: ReturnType<typeof zodToJsonSchema>;\n};\n\n/**\n * Extends the base ContextTool interface from Tambo AI to include schema information\n * for parameter validation using zod-to-json-schema.\n */\nexport interface ComponentContextToolMetadata\n extends TamboAI.ComponentContextToolMetadata {\n parameters: ParameterSpec[];\n}\n\nexport interface ComponentContextTool {\n getComponentContext: (...args: any[]) => Promise<any>;\n definition: ComponentContextToolMetadata;\n}\n\nexport interface RegisteredComponent extends TamboAI.AvailableComponent {\n component: ComponentType<any>;\n loadingComponent?: ComponentType<any>;\n}\n\nexport type ComponentRegistry = Record<string, RegisteredComponent>;\n\nexport type TamboToolRegistry = Record<string, TamboTool>;\n\n/**\n * A JSON Schema that is compatible with the MCP.\n * This is a simplified JSON Schema that is compatible with the MCPClient and the toolSchema.\n *\n * Do not export this type from the SDK.\n */\nexport type JSONSchemaLite = ReturnType<typeof zodToJsonSchema> & {\n description?: string;\n};\n\nexport interface TamboTool<\n Args extends z.ZodTuple<any, any> = z.ZodTuple<any, any>,\n Returns extends z.ZodTypeAny = z.ZodTypeAny,\n> {\n name: string;\n description: string;\n tool: (...args: z.infer<Args>) => z.infer<Returns>;\n toolSchema: z.ZodFunction<Args, Returns> | JSONSchemaLite;\n}\n\nexport type TamboToolAssociations = Record<string, string[]>;\n/**\n * A component that can be registered with the TamboRegistryProvider.\n */\n\nexport interface TamboComponent {\n /** The name of the component */\n name: string;\n /** The description of the component */\n description: string;\n /**\n * The React component to render.\n *\n * Make sure to pass the Component itself, not an instance of the component. For example,\n * if you have a component like this:\n *\n * ```tsx\n * const MyComponent = () => {\n * return <div>My Component</div>;\n * };\n * ```\n *\n * You should pass the `Component`:\n *\n * ```tsx\n * const components = [MyComponent];\n * <TamboRegistryProvider components={components} />\n * ```\n */\n component: ComponentType<any>;\n\n /**\n * A zod schema for the component props. (Recommended)\n * Either this or propsDefinition must be provided, but not both.\n */\n propsSchema?: z.ZodTypeAny | JSONSchema7;\n /**\n * The props definition of the component as a JSON object.\n * Either this or propsSchema must be provided, but not both.\n * @deprecated Use propsSchema instead.\n */\n propsDefinition?: any;\n /** The loading component to render while the component is loading */\n loadingComponent?: ComponentType<any>;\n /** The tools that are associated with the component */\n associatedTools?: TamboTool[];\n}\n"]}
1
+ {"version":3,"file":"component-metadata.js","sourceRoot":"","sources":["../../src/model/component-metadata.ts"],"names":[],"mappings":"","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { JSONSchema7 } from \"json-schema\";\nimport { ComponentType } from \"react\";\nimport z from \"zod\";\nimport type zodToJsonSchema from \"zod-to-json-schema\";\n/** Extension of the ToolParameters interface from Tambo AI to include JSONSchema definition */\nexport type ParameterSpec = TamboAI.ToolParameters & {\n schema?: ReturnType<typeof zodToJsonSchema>;\n};\n\n/**\n * Extends the base ContextTool interface from Tambo AI to include schema information\n * for parameter validation using zod-to-json-schema.\n */\nexport interface ComponentContextToolMetadata\n extends TamboAI.ComponentContextToolMetadata {\n parameters: ParameterSpec[];\n}\n\nexport interface ComponentContextTool {\n getComponentContext: (...args: any[]) => Promise<any>;\n definition: ComponentContextToolMetadata;\n}\n\nexport interface RegisteredComponent extends TamboAI.AvailableComponent {\n component: ComponentType<any>;\n loadingComponent?: ComponentType<any>;\n}\n\nexport type ComponentRegistry = Record<string, RegisteredComponent>;\n\nexport type TamboToolRegistry = Record<string, TamboTool>;\n\n/**\n * A JSON Schema that is compatible with the MCP.\n * This is a simplified JSON Schema that is compatible with the MCPClient and the toolSchema.\n *\n * Do not export this type from the SDK.\n */\nexport type JSONSchemaLite = ReturnType<typeof zodToJsonSchema> & {\n description?: string;\n};\n\nexport interface TamboTool<\n Args extends z.ZodTuple<any, any> = z.ZodTuple<any, any>,\n Returns extends z.ZodTypeAny = z.ZodTypeAny,\n> {\n name: string;\n description: string;\n tool: (...args: z.infer<Args>) => z.infer<Returns>;\n toolSchema: z.ZodFunction<Args, Returns> | JSONSchemaLite;\n /**\n * Optional function to transform the tool's return value into an array of content parts.\n * If not provided, the return value will be converted to a string and wrapped in a text content part.\n * @param result - The result returned by the tool function\n * @returns An array of content parts to be sent back to the AI\n */\n transformToContent?: (\n result: z.infer<Returns>,\n ) => TamboAI.Beta.Threads.ChatCompletionContentPart[];\n}\n\nexport type TamboToolAssociations = Record<string, string[]>;\n/**\n * A component that can be registered with the TamboRegistryProvider.\n */\n\nexport interface TamboComponent {\n /** The name of the component */\n name: string;\n /** The description of the component */\n description: string;\n /**\n * The React component to render.\n *\n * Make sure to pass the Component itself, not an instance of the component. For example,\n * if you have a component like this:\n *\n * ```tsx\n * const MyComponent = () => {\n * return <div>My Component</div>;\n * };\n * ```\n *\n * You should pass the `Component`:\n *\n * ```tsx\n * const components = [MyComponent];\n * <TamboRegistryProvider components={components} />\n * ```\n */\n component: ComponentType<any>;\n\n /**\n * A zod schema for the component props. (Recommended)\n * Either this or propsDefinition must be provided, but not both.\n */\n propsSchema?: z.ZodTypeAny | JSONSchema7;\n /**\n * The props definition of the component as a JSON object.\n * Either this or propsSchema must be provided, but not both.\n * @deprecated Use propsSchema instead.\n */\n propsDefinition?: any;\n /** The loading component to render while the component is loading */\n loadingComponent?: ComponentType<any>;\n /** The tools that are associated with the component */\n associatedTools?: TamboTool[];\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tambo-thread-provider-initial-messages.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tambo-thread-provider-initial-messages.test.d.ts","sourceRoot":"","sources":["../../../src/providers/__tests__/tambo-thread-provider-initial-messages.test.tsx"],"names":[],"mappings":""}