@tambo-ai/react 0.47.0 → 0.49.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.
- package/dist/context-helpers/current-interactables-context-helper.d.ts +28 -0
- package/dist/context-helpers/current-interactables-context-helper.d.ts.map +1 -0
- package/dist/context-helpers/current-interactables-context-helper.js +61 -0
- package/dist/context-helpers/current-interactables-context-helper.js.map +1 -0
- package/dist/context-helpers/index.d.ts +1 -0
- package/dist/context-helpers/index.d.ts.map +1 -1
- package/dist/context-helpers/index.js +1 -0
- package/dist/context-helpers/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/__tests__/tambo-mcp-provider.test.d.ts +2 -0
- package/dist/mcp/__tests__/tambo-mcp-provider.test.d.ts.map +1 -0
- package/dist/mcp/__tests__/tambo-mcp-provider.test.js +115 -0
- package/dist/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -0
- package/dist/mcp/tambo-mcp-provider.d.ts +6 -0
- package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/dist/mcp/tambo-mcp-provider.js +25 -2
- package/dist/mcp/tambo-mcp-provider.js.map +1 -1
- package/dist/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts +2 -0
- package/dist/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts.map +1 -0
- package/dist/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.js +339 -0
- package/dist/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.js.map +1 -0
- package/dist/providers/__tests__/tambo-interactables-additional-context.test.d.ts +2 -0
- package/dist/providers/__tests__/tambo-interactables-additional-context.test.d.ts.map +1 -0
- package/dist/providers/__tests__/tambo-interactables-additional-context.test.js +299 -0
- package/dist/providers/__tests__/tambo-interactables-additional-context.test.js.map +1 -0
- package/dist/providers/__tests__/tambo-registry-provider.test.d.ts +2 -0
- package/dist/providers/__tests__/tambo-registry-provider.test.d.ts.map +1 -0
- package/dist/providers/__tests__/tambo-registry-provider.test.js +224 -0
- package/dist/providers/__tests__/tambo-registry-provider.test.js.map +1 -0
- package/dist/providers/__tests__/tambo-thread-provider.test.js +99 -0
- package/dist/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
- package/dist/providers/tambo-interactable-provider.d.ts +20 -0
- package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/dist/providers/tambo-interactable-provider.js +32 -2
- package/dist/providers/tambo-interactable-provider.js.map +1 -1
- package/dist/providers/tambo-provider.d.ts.map +1 -1
- package/dist/providers/tambo-provider.js +2 -2
- package/dist/providers/tambo-provider.js.map +1 -1
- package/dist/providers/tambo-registry-provider.d.ts +12 -0
- package/dist/providers/tambo-registry-provider.d.ts.map +1 -1
- package/dist/providers/tambo-registry-provider.js +3 -1
- package/dist/providers/tambo-registry-provider.js.map +1 -1
- package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
- package/dist/providers/tambo-thread-provider.js +5 -3
- package/dist/providers/tambo-thread-provider.js.map +1 -1
- package/dist/util/tool-caller.d.ts +1 -1
- package/dist/util/tool-caller.d.ts.map +1 -1
- package/dist/util/tool-caller.js +11 -2
- package/dist/util/tool-caller.js.map +1 -1
- package/esm/context-helpers/current-interactables-context-helper.d.ts +28 -0
- package/esm/context-helpers/current-interactables-context-helper.d.ts.map +1 -0
- package/esm/context-helpers/current-interactables-context-helper.js +56 -0
- package/esm/context-helpers/current-interactables-context-helper.js.map +1 -0
- package/esm/context-helpers/index.d.ts +1 -0
- package/esm/context-helpers/index.d.ts.map +1 -1
- package/esm/context-helpers/index.js +1 -0
- package/esm/context-helpers/index.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/mcp/__tests__/tambo-mcp-provider.test.d.ts +2 -0
- package/esm/mcp/__tests__/tambo-mcp-provider.test.d.ts.map +1 -0
- package/esm/mcp/__tests__/tambo-mcp-provider.test.js +113 -0
- package/esm/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -0
- package/esm/mcp/tambo-mcp-provider.d.ts +6 -0
- package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/esm/mcp/tambo-mcp-provider.js +24 -2
- package/esm/mcp/tambo-mcp-provider.js.map +1 -1
- package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts +2 -0
- package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts.map +1 -0
- package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.js +334 -0
- package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.js.map +1 -0
- package/esm/providers/__tests__/tambo-interactables-additional-context.test.d.ts +2 -0
- package/esm/providers/__tests__/tambo-interactables-additional-context.test.d.ts.map +1 -0
- package/esm/providers/__tests__/tambo-interactables-additional-context.test.js +294 -0
- package/esm/providers/__tests__/tambo-interactables-additional-context.test.js.map +1 -0
- package/esm/providers/__tests__/tambo-registry-provider.test.d.ts +2 -0
- package/esm/providers/__tests__/tambo-registry-provider.test.d.ts.map +1 -0
- package/esm/providers/__tests__/tambo-registry-provider.test.js +219 -0
- package/esm/providers/__tests__/tambo-registry-provider.test.js.map +1 -0
- package/esm/providers/__tests__/tambo-thread-provider.test.js +99 -0
- package/esm/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.d.ts +20 -0
- package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/esm/providers/tambo-interactable-provider.js +30 -1
- package/esm/providers/tambo-interactable-provider.js.map +1 -1
- package/esm/providers/tambo-provider.d.ts.map +1 -1
- package/esm/providers/tambo-provider.js +2 -2
- package/esm/providers/tambo-provider.js.map +1 -1
- package/esm/providers/tambo-registry-provider.d.ts +12 -0
- package/esm/providers/tambo-registry-provider.d.ts.map +1 -1
- package/esm/providers/tambo-registry-provider.js +3 -1
- package/esm/providers/tambo-registry-provider.js.map +1 -1
- package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
- package/esm/providers/tambo-thread-provider.js +5 -3
- package/esm/providers/tambo-thread-provider.js.map +1 -1
- package/esm/util/tool-caller.d.ts +1 -1
- package/esm/util/tool-caller.d.ts.map +1 -1
- package/esm/util/tool-caller.js +11 -2
- package/esm/util/tool-caller.js.map +1 -1
- package/package.json +9 -9
- package/dist/mcp/mcp-tools-client.d.ts +0 -96
- package/dist/mcp/mcp-tools-client.d.ts.map +0 -1
- package/dist/mcp/mcp-tools-client.js +0 -178
- package/dist/mcp/mcp-tools-client.js.map +0 -1
- package/esm/mcp/mcp-tools-client.d.ts +0 -96
- package/esm/mcp/mcp-tools-client.d.ts.map +0 -1
- package/esm/mcp/mcp-tools-client.js +0 -174
- package/esm/mcp/mcp-tools-client.js.map +0 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ContextHelperFn } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Prebuilt context helper that provides information about all interactable components currently on the page.
|
|
4
|
+
* This gives the AI awareness of what components it can interact with and their current state.
|
|
5
|
+
* @returns an object with description and components, or null to skip including this context.
|
|
6
|
+
* To disable this helper, override it with a function that returns null:
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* // To disable the default interactables context
|
|
10
|
+
* const { addContextHelper } = useTamboContextHelpers();
|
|
11
|
+
* addContextHelper("interactables", () => null);
|
|
12
|
+
*
|
|
13
|
+
* // To customize the context
|
|
14
|
+
* addContextHelper("interactables", () => ({
|
|
15
|
+
* description: "Custom description",
|
|
16
|
+
* components: getCustomComponentsSubset()
|
|
17
|
+
* }));
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const currentInteractablesContextHelper: ContextHelperFn;
|
|
21
|
+
/**
|
|
22
|
+
* Creates an interactables context helper with access to the current components.
|
|
23
|
+
* This is used internally by TamboInteractableProvider.
|
|
24
|
+
* @param getComponents Function to get current interactable components
|
|
25
|
+
* @returns Context helper function
|
|
26
|
+
*/
|
|
27
|
+
export declare const createInteractablesContextHelper: (getComponents: () => any[]) => ContextHelperFn;
|
|
28
|
+
//# sourceMappingURL=current-interactables-context-helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-interactables-context-helper.d.ts","sourceRoot":"","sources":["../../src/context-helpers/current-interactables-context-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iCAAiC,EAAE,eAI/C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,GAC3C,eAAe,MAAM,GAAG,EAAE,KACzB,eA2BF,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInteractablesContextHelper = exports.currentInteractablesContextHelper = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Prebuilt context helper that provides information about all interactable components currently on the page.
|
|
6
|
+
* This gives the AI awareness of what components it can interact with and their current state.
|
|
7
|
+
* @returns an object with description and components, or null to skip including this context.
|
|
8
|
+
* To disable this helper, override it with a function that returns null:
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* // To disable the default interactables context
|
|
12
|
+
* const { addContextHelper } = useTamboContextHelpers();
|
|
13
|
+
* addContextHelper("interactables", () => null);
|
|
14
|
+
*
|
|
15
|
+
* // To customize the context
|
|
16
|
+
* addContextHelper("interactables", () => ({
|
|
17
|
+
* description: "Custom description",
|
|
18
|
+
* components: getCustomComponentsSubset()
|
|
19
|
+
* }));
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
const currentInteractablesContextHelper = () => {
|
|
23
|
+
// This will be provided by the interactable provider when it registers this helper
|
|
24
|
+
// Since we're provider-only now, this function gets replaced at runtime
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
exports.currentInteractablesContextHelper = currentInteractablesContextHelper;
|
|
28
|
+
/**
|
|
29
|
+
* Creates an interactables context helper with access to the current components.
|
|
30
|
+
* This is used internally by TamboInteractableProvider.
|
|
31
|
+
* @param getComponents Function to get current interactable components
|
|
32
|
+
* @returns Context helper function
|
|
33
|
+
*/
|
|
34
|
+
const createInteractablesContextHelper = (getComponents) => {
|
|
35
|
+
return () => {
|
|
36
|
+
try {
|
|
37
|
+
const components = getComponents();
|
|
38
|
+
if (!Array.isArray(components) || components.length === 0) {
|
|
39
|
+
return null; // No interactable components on the page
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
description: "These are the interactable components currently visible on the page that you can read and modify. Each component has an id, componentName, current props, and optional schema. You can use tools to update these components on behalf of the user.",
|
|
43
|
+
components: components.map((component) => ({
|
|
44
|
+
id: component.id,
|
|
45
|
+
componentName: component.name,
|
|
46
|
+
description: component.description,
|
|
47
|
+
props: component.props,
|
|
48
|
+
propsSchema: component.propsSchema
|
|
49
|
+
? "Available - use component-specific update tools"
|
|
50
|
+
: "Not specified",
|
|
51
|
+
})),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
console.error("currentInteractablesContextHelper failed:", e);
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
exports.createInteractablesContextHelper = createInteractablesContextHelper;
|
|
61
|
+
//# sourceMappingURL=current-interactables-context-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-interactables-context-helper.js","sourceRoot":"","sources":["../../src/context-helpers/current-interactables-context-helper.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;GAiBG;AACI,MAAM,iCAAiC,GAAoB,GAAG,EAAE;IACrE,mFAAmF;IACnF,wEAAwE;IACxE,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAJW,QAAA,iCAAiC,qCAI5C;AAEF;;;;;GAKG;AACI,MAAM,gCAAgC,GAAG,CAC9C,aAA0B,EACT,EAAE;IACnB,OAAO,GAAG,EAAE;QACV,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;YAEnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC1D,OAAO,IAAI,CAAC,CAAC,yCAAyC;YACxD,CAAC;YAED,OAAO;gBACL,WAAW,EACT,oPAAoP;gBACtP,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;oBACzC,EAAE,EAAE,SAAS,CAAC,EAAE;oBAChB,aAAa,EAAE,SAAS,CAAC,IAAI;oBAC7B,WAAW,EAAE,SAAS,CAAC,WAAW;oBAClC,KAAK,EAAE,SAAS,CAAC,KAAK;oBACtB,WAAW,EAAE,SAAS,CAAC,WAAW;wBAChC,CAAC,CAAC,iDAAiD;wBACnD,CAAC,CAAC,eAAe;iBACpB,CAAC,CAAC;aACJ,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,CAAC,CAAC,CAAC;YAC9D,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AA7BW,QAAA,gCAAgC,oCA6B3C","sourcesContent":["import { ContextHelperFn } from \"./types\";\n\n/**\n * Prebuilt context helper that provides information about all interactable components currently on the page.\n * This gives the AI awareness of what components it can interact with and their current state.\n * @returns an object with description and components, or null to skip including this context.\n * To disable this helper, override it with a function that returns null:\n * @example\n * ```tsx\n * // To disable the default interactables context\n * const { addContextHelper } = useTamboContextHelpers();\n * addContextHelper(\"interactables\", () => null);\n *\n * // To customize the context\n * addContextHelper(\"interactables\", () => ({\n * description: \"Custom description\",\n * components: getCustomComponentsSubset()\n * }));\n * ```\n */\nexport const currentInteractablesContextHelper: ContextHelperFn = () => {\n // This will be provided by the interactable provider when it registers this helper\n // Since we're provider-only now, this function gets replaced at runtime\n return null;\n};\n\n/**\n * Creates an interactables context helper with access to the current components.\n * This is used internally by TamboInteractableProvider.\n * @param getComponents Function to get current interactable components\n * @returns Context helper function\n */\nexport const createInteractablesContextHelper = (\n getComponents: () => any[],\n): ContextHelperFn => {\n return () => {\n try {\n const components = getComponents();\n\n if (!Array.isArray(components) || components.length === 0) {\n return null; // No interactable components on the page\n }\n\n return {\n description:\n \"These are the interactable components currently visible on the page that you can read and modify. Each component has an id, componentName, current props, and optional schema. You can use tools to update these components on behalf of the user.\",\n components: components.map((component) => ({\n id: component.id,\n componentName: component.name,\n description: component.description,\n props: component.props,\n propsSchema: component.propsSchema\n ? \"Available - use component-specific update tools\"\n : \"Not specified\",\n })),\n };\n } catch (e) {\n console.error(\"currentInteractablesContextHelper failed:\", e);\n return null;\n }\n };\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context-helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context-helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wCAAwC,CAAC;AACvD,cAAc,SAAS,CAAC"}
|
|
@@ -16,5 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./current-page-context-helper"), exports);
|
|
18
18
|
__exportStar(require("./current-time-context-helper"), exports);
|
|
19
|
+
__exportStar(require("./current-interactables-context-helper"), exports);
|
|
19
20
|
__exportStar(require("./types"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/context-helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C;AAC9C,gEAA8C;AAC9C,0CAAwB","sourcesContent":["export * from \"./current-page-context-helper\";\nexport * from \"./current-time-context-helper\";\nexport * from \"./types\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/context-helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C;AAC9C,gEAA8C;AAC9C,yEAAuD;AACvD,0CAAwB","sourcesContent":["export * from \"./current-page-context-helper\";\nexport * from \"./current-time-context-helper\";\nexport * from \"./current-interactables-context-helper\";\nexport * from \"./types\";\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { GenerationStage, type TamboThreadMessage, } from "./model/generate-comp
|
|
|
13
13
|
export { type TamboThread } from "./model/tambo-thread";
|
|
14
14
|
export type { TamboInteractableComponent as InteractableComponent, TamboInteractableContext, } from "./model/tambo-interactable";
|
|
15
15
|
export { withTamboInteractable as withInteractable, type InteractableConfig, type WithTamboInteractableProps, } from "./providers/hoc/with-tambo-interactable";
|
|
16
|
-
export { useTamboInteractable } from "./providers/tambo-interactable-provider";
|
|
16
|
+
export { useTamboInteractable, useCurrentInteractablesSnapshot, } from "./providers/tambo-interactable-provider";
|
|
17
17
|
export { currentPageContextHelper, currentTimeContextHelper, } from "./context-helpers";
|
|
18
18
|
export type { AdditionalContext, ContextHelperFn, ContextHelpers, } from "./context-helpers";
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,E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AI,gBAAgB,EACzC,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,GAChC,MAAM,yCAAyC,CAAC;AACjD,OAAO,
|
|
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,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,EACpB,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,iCAAiC,CAAC;AAGzC,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,EACnB,KAAK,cAAc,EACnB,KAAK,+BAA+B,EACpC,KAAK,gCAAgC,EACrC,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,GAClC,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,QAAQ,EACR,cAAc,EACd,YAAY,GACb,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,UAAU,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,6DAA6D,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,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;AAExD,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,oBAAoB,EACpB,+BAA+B,GAChC,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/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.currentTimeContextHelper = exports.currentPageContextHelper = exports.useTamboInteractable = exports.withInteractable = exports.GenerationStage = exports.useTamboThreadList = exports.useTamboThreadInput = exports.useTamboThread = exports.useTamboStream = exports.useTamboGenerationStage = exports.useTamboContextHelpers = exports.useTamboClient = exports.useTambo = exports.useIsTamboTokenUpdating = exports.TamboThreadProvider = exports.TamboThreadInputProvider = exports.TamboStubProvider = exports.TamboProvider = exports.TamboPropStreamProvider = exports.TamboContextHelpersProvider = exports.TamboComponentProvider = exports.TamboClientProvider = exports.useTamboStreamStatus = exports.useTamboStreamingProps = exports.useTamboCurrentMessage = exports.TamboMessageProvider = exports.useTamboComponentState = void 0;
|
|
18
|
+
exports.currentTimeContextHelper = exports.currentPageContextHelper = exports.useCurrentInteractablesSnapshot = exports.useTamboInteractable = exports.withInteractable = exports.GenerationStage = exports.useTamboThreadList = exports.useTamboThreadInput = exports.useTamboThread = exports.useTamboStream = exports.useTamboGenerationStage = exports.useTamboContextHelpers = exports.useTamboClient = exports.useTambo = exports.useIsTamboTokenUpdating = exports.TamboThreadProvider = exports.TamboThreadInputProvider = exports.TamboStubProvider = exports.TamboProvider = exports.TamboPropStreamProvider = exports.TamboContextHelpersProvider = exports.TamboComponentProvider = exports.TamboClientProvider = exports.useTamboStreamStatus = exports.useTamboStreamingProps = exports.useTamboCurrentMessage = exports.TamboMessageProvider = exports.useTamboComponentState = void 0;
|
|
19
19
|
var use_component_state_1 = require("./hooks/use-component-state");
|
|
20
20
|
Object.defineProperty(exports, "useTamboComponentState", { enumerable: true, get: function () { return use_component_state_1.useTamboComponentState; } });
|
|
21
21
|
var use_current_message_1 = require("./hooks/use-current-message");
|
|
@@ -52,6 +52,7 @@ var with_tambo_interactable_1 = require("./providers/hoc/with-tambo-interactable
|
|
|
52
52
|
Object.defineProperty(exports, "withInteractable", { enumerable: true, get: function () { return with_tambo_interactable_1.withTamboInteractable; } });
|
|
53
53
|
var tambo_interactable_provider_1 = require("./providers/tambo-interactable-provider");
|
|
54
54
|
Object.defineProperty(exports, "useTamboInteractable", { enumerable: true, get: function () { return tambo_interactable_provider_1.useTamboInteractable; } });
|
|
55
|
+
Object.defineProperty(exports, "useCurrentInteractablesSnapshot", { enumerable: true, get: function () { return tambo_interactable_provider_1.useCurrentInteractablesSnapshot; } });
|
|
55
56
|
// Context helpers exports
|
|
56
57
|
var context_helpers_1 = require("./context-helpers");
|
|
57
58
|
Object.defineProperty(exports, "currentPageContextHelper", { enumerable: true, get: function () { return context_helpers_1.currentPageContextHelper; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,wKAAwK;;;;;;;;;;;;;;;;;AAExK,mEAAqE;AAA5D,6HAAA,sBAAsB,OAAA;AAC/B,mEAGqC;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,0GAAA,aAAa,OAAA;AACb,8GAAA,iBAAiB,OAAA;AACjB,qHAAA,wBAAwB,OAAA;AACxB,gHAAA,mBAAmB,OAAA;AACnB,oHAAA,uBAAuB,OAAA;AACvB,qGAAA,QAAQ,OAAA;AACR,2GAAA,cAAc,OAAA;AACd,mHAAA,sBAAsB,OAAA;AACtB,oHAAA,uBAAuB,OAAA;AACvB,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA;AACd,gHAAA,mBAAmB,OAAA;AAqBrB,+DAA+D;AAAtD,uHAAA,kBAAkB,OAAA;AAQ3B,mFAG6C;AAF3C,8HAAA,eAAe,OAAA;AASjB,mFAIiD;AAH/C,2HAAA,qBAAqB,OAAoB;AAI3C,uFAGiD;AAF/C,mIAAA,oBAAoB,OAAA;AACpB,8IAAA,+BAA+B,OAAA;AAGjC,0BAA0B;AAC1B,qDAG2B;AAFzB,2HAAA,wBAAwB,OAAA;AACxB,2HAAA,wBAAwB,OAAA","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 { 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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tambo-mcp-provider.test.d.ts","sourceRoot":"","sources":["../../../src/mcp/__tests__/tambo-mcp-provider.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tambo_mcp_provider_1 = require("../tambo-mcp-provider");
|
|
4
|
+
// Mock the MCP client to avoid ES module issues
|
|
5
|
+
jest.mock("../mcp-client", () => ({
|
|
6
|
+
MCPClient: jest.fn(),
|
|
7
|
+
MCPTransport: {
|
|
8
|
+
SSE: "sse",
|
|
9
|
+
HTTP: "http",
|
|
10
|
+
},
|
|
11
|
+
}));
|
|
12
|
+
// Mock the registry provider to avoid dependency issues
|
|
13
|
+
jest.mock("../../providers/tambo-registry-provider", () => ({
|
|
14
|
+
useTamboRegistry: jest.fn(),
|
|
15
|
+
}));
|
|
16
|
+
describe("extractErrorMessage", () => {
|
|
17
|
+
describe("Array content handling", () => {
|
|
18
|
+
it("should extract text from array content with multiple text items", () => {
|
|
19
|
+
const content = [
|
|
20
|
+
{ type: "text", text: "Error:" },
|
|
21
|
+
{ type: "text", text: "Tool execution failed" },
|
|
22
|
+
{ type: "image", url: "http://example.com/error.png" }, // Should be filtered out
|
|
23
|
+
];
|
|
24
|
+
const result = (0, tambo_mcp_provider_1.extractErrorMessage)(content);
|
|
25
|
+
expect(result).toBe("Error: Tool execution failed");
|
|
26
|
+
});
|
|
27
|
+
it("should extract text from array content with single text item", () => {
|
|
28
|
+
const content = [{ type: "text", text: "Simple error message" }];
|
|
29
|
+
const result = (0, tambo_mcp_provider_1.extractErrorMessage)(content);
|
|
30
|
+
expect(result).toBe("Simple error message");
|
|
31
|
+
});
|
|
32
|
+
it("should return fallback message for array content with no text items", () => {
|
|
33
|
+
const content = [
|
|
34
|
+
{ type: "image", url: "http://example.com/error.png" },
|
|
35
|
+
{ type: "resource", uri: "file://error.log" },
|
|
36
|
+
];
|
|
37
|
+
const result = (0, tambo_mcp_provider_1.extractErrorMessage)(content);
|
|
38
|
+
expect(result).toBe("Error occurred but no details provided");
|
|
39
|
+
});
|
|
40
|
+
it("should return fallback message for empty array content", () => {
|
|
41
|
+
const content = [];
|
|
42
|
+
const result = (0, tambo_mcp_provider_1.extractErrorMessage)(content);
|
|
43
|
+
expect(result).toBe("Error occurred but no details provided");
|
|
44
|
+
});
|
|
45
|
+
it("should handle array content with mixed types correctly", () => {
|
|
46
|
+
const content = [
|
|
47
|
+
{ type: "resource", uri: "file://log.txt" },
|
|
48
|
+
{ type: "text", text: "First error" },
|
|
49
|
+
{ type: "image", url: "http://example.com/img.png" },
|
|
50
|
+
{ type: "text", text: "Second error" },
|
|
51
|
+
{ type: "unknown", data: "something" },
|
|
52
|
+
];
|
|
53
|
+
const result = (0, tambo_mcp_provider_1.extractErrorMessage)(content);
|
|
54
|
+
expect(result).toBe("First error Second error");
|
|
55
|
+
});
|
|
56
|
+
it("should handle array content with malformed items", () => {
|
|
57
|
+
const content = [
|
|
58
|
+
null,
|
|
59
|
+
{ type: "text", text: "Valid error" },
|
|
60
|
+
{ type: "text" }, // Missing text property
|
|
61
|
+
{ type: "text", text: null }, // Invalid text type
|
|
62
|
+
{ type: "text", text: "Another valid error" },
|
|
63
|
+
];
|
|
64
|
+
const result = (0, tambo_mcp_provider_1.extractErrorMessage)(content);
|
|
65
|
+
expect(result).toBe("Valid error Another valid error");
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe("Non-array content handling", () => {
|
|
69
|
+
it("should return string content as-is", () => {
|
|
70
|
+
const content = "Direct error message";
|
|
71
|
+
const result = (0, tambo_mcp_provider_1.extractErrorMessage)(content);
|
|
72
|
+
expect(result).toBe("Direct error message");
|
|
73
|
+
});
|
|
74
|
+
it("should handle null content", () => {
|
|
75
|
+
const content = null;
|
|
76
|
+
const result = (0, tambo_mcp_provider_1.extractErrorMessage)(content);
|
|
77
|
+
expect(result).toBe("Unknown error occurred");
|
|
78
|
+
});
|
|
79
|
+
it("should handle undefined content", () => {
|
|
80
|
+
const content = undefined;
|
|
81
|
+
const result = (0, tambo_mcp_provider_1.extractErrorMessage)(content);
|
|
82
|
+
expect(result).toBe("Unknown error occurred");
|
|
83
|
+
});
|
|
84
|
+
it("should handle number content", () => {
|
|
85
|
+
const content = 42;
|
|
86
|
+
const result = (0, tambo_mcp_provider_1.extractErrorMessage)(content);
|
|
87
|
+
expect(result).toBe("42");
|
|
88
|
+
});
|
|
89
|
+
it("should handle boolean content", () => {
|
|
90
|
+
const content = false;
|
|
91
|
+
const result = (0, tambo_mcp_provider_1.extractErrorMessage)(content);
|
|
92
|
+
expect(result).toBe("false");
|
|
93
|
+
});
|
|
94
|
+
it("should handle object content", () => {
|
|
95
|
+
const content = { error: "Something went wrong" };
|
|
96
|
+
const result = (0, tambo_mcp_provider_1.extractErrorMessage)(content);
|
|
97
|
+
expect(result).toBe('{"error":"Something went wrong"}');
|
|
98
|
+
});
|
|
99
|
+
it("should handle complex object content", () => {
|
|
100
|
+
const content = {
|
|
101
|
+
error: "Something went wrong",
|
|
102
|
+
code: 500,
|
|
103
|
+
details: { message: "Internal server error" },
|
|
104
|
+
};
|
|
105
|
+
const result = (0, tambo_mcp_provider_1.extractErrorMessage)(content);
|
|
106
|
+
expect(result).toBe('{"error":"Something went wrong","code":500,"details":{"message":"Internal server error"}}');
|
|
107
|
+
});
|
|
108
|
+
it("should handle empty object content", () => {
|
|
109
|
+
const content = {};
|
|
110
|
+
const result = (0, tambo_mcp_provider_1.extractErrorMessage)(content);
|
|
111
|
+
expect(result).toBe("{}");
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
//# sourceMappingURL=tambo-mcp-provider.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tambo-mcp-provider.test.js","sourceRoot":"","sources":["../../../src/mcp/__tests__/tambo-mcp-provider.test.tsx"],"names":[],"mappings":";;AAAA,8DAA4D;AAE5D,gDAAgD;AAChD,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC;IAChC,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE;IACpB,YAAY,EAAE;QACZ,GAAG,EAAE,KAAK;QACV,IAAI,EAAE,MAAM;KACb;CACF,CAAC,CAAC,CAAC;AAEJ,wDAAwD;AACxD,IAAI,CAAC,IAAI,CAAC,yCAAyC,EAAE,GAAG,EAAE,CAAC,CAAC;IAC1D,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;CAC5B,CAAC,CAAC,CAAC;AAEJ,QAAQ,CAAC,q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,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;YACtC,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;YAElD,MAAM,MAAM,GAAG,IAAA,wCAAmB,EAAC,OAAO,CAAC,CAAC;YAE5C,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;YAC9C,MAAM,OAAO,GAAG;gBACd,KAAK,EAAE,sBAAsB;gBAC7B,IAAI,EAAE,GAAG;gBACT,OAAO,EAAE,EAAE,OAAO,EAAE,uBAAuB,EAAE;aAC9C,CAAC;YAEF,MAAM,MAAM,GAAG,IAAA,wCAAmB,EAAC,OAAO,CAAC,CAAC;YAE5C,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CACjB,2FAA2F,CAC5F,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;YAC5C,MAAM,OAAO,GAAG,EAAE,CAAC;YAEnB,MAAM,MAAM,GAAG,IAAA,wCAAmB,EAAC,OAAO,CAAC,CAAC;YAE5C,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { extractErrorMessage } from \"../tambo-mcp-provider\";\n\n// Mock the MCP client to avoid ES module issues\njest.mock(\"../mcp-client\", () => ({\n MCPClient: jest.fn(),\n MCPTransport: {\n SSE: \"sse\",\n HTTP: \"http\",\n },\n}));\n\n// Mock the registry provider to avoid dependency issues\njest.mock(\"../../providers/tambo-registry-provider\", () => ({\n useTamboRegistry: jest.fn(),\n}));\n\ndescribe(\"extractErrorMessage\", () => {\n describe(\"Array content handling\", () => {\n it(\"should extract text from array content with multiple text items\", () => {\n const content = [\n { type: \"text\", text: \"Error:\" },\n { type: \"text\", text: \"Tool execution failed\" },\n { type: \"image\", url: \"http://example.com/error.png\" }, // Should be filtered out\n ];\n\n const result = extractErrorMessage(content);\n\n expect(result).toBe(\"Error: Tool execution failed\");\n });\n\n it(\"should extract text from array content with single text item\", () => {\n const content = [{ type: \"text\", text: \"Simple error message\" }];\n\n const result = extractErrorMessage(content);\n\n expect(result).toBe(\"Simple error message\");\n });\n\n it(\"should return fallback message for array content with no text items\", () => {\n const content = [\n { type: \"image\", url: \"http://example.com/error.png\" },\n { type: \"resource\", uri: \"file://error.log\" },\n ];\n\n const result = extractErrorMessage(content);\n\n expect(result).toBe(\"Error occurred but no details provided\");\n });\n\n it(\"should return fallback message for empty array content\", () => {\n const content: any[] = [];\n\n const result = extractErrorMessage(content);\n\n expect(result).toBe(\"Error occurred but no details provided\");\n });\n\n it(\"should handle array content with mixed types correctly\", () => {\n const content = [\n { type: \"resource\", uri: \"file://log.txt\" },\n { type: \"text\", text: \"First error\" },\n { type: \"image\", url: \"http://example.com/img.png\" },\n { type: \"text\", text: \"Second error\" },\n { type: \"unknown\", data: \"something\" },\n ];\n\n const result = extractErrorMessage(content);\n\n expect(result).toBe(\"First error Second error\");\n });\n\n it(\"should handle array content with malformed items\", () => {\n const content = [\n null,\n { type: \"text\", text: \"Valid error\" },\n { type: \"text\" }, // Missing text property\n { type: \"text\", text: null }, // Invalid text type\n { type: \"text\", text: \"Another valid error\" },\n ];\n\n const result = extractErrorMessage(content);\n\n expect(result).toBe(\"Valid error Another valid error\");\n });\n });\n\n describe(\"Non-array content handling\", () => {\n it(\"should return string content as-is\", () => {\n const content = \"Direct error message\";\n\n const result = extractErrorMessage(content);\n\n expect(result).toBe(\"Direct error message\");\n });\n\n it(\"should handle null content\", () => {\n const content = null;\n\n const result = extractErrorMessage(content);\n\n expect(result).toBe(\"Unknown error occurred\");\n });\n\n it(\"should handle undefined content\", () => {\n const content = undefined;\n\n const result = extractErrorMessage(content);\n\n expect(result).toBe(\"Unknown error occurred\");\n });\n\n it(\"should handle number content\", () => {\n const content = 42;\n\n const result = extractErrorMessage(content);\n\n expect(result).toBe(\"42\");\n });\n\n it(\"should handle boolean content\", () => {\n const content = false;\n\n const result = extractErrorMessage(content);\n\n expect(result).toBe(\"false\");\n });\n\n it(\"should handle object content\", () => {\n const content = { error: \"Something went wrong\" };\n\n const result = extractErrorMessage(content);\n\n expect(result).toBe('{\"error\":\"Something went wrong\"}');\n });\n\n it(\"should handle complex object content\", () => {\n const content = {\n error: \"Something went wrong\",\n code: 500,\n details: { message: \"Internal server error\" },\n };\n\n const result = extractErrorMessage(content);\n\n expect(result).toBe(\n '{\"error\":\"Something went wrong\",\"code\":500,\"details\":{\"message\":\"Internal server error\"}}',\n );\n });\n\n it(\"should handle empty object content\", () => {\n const content = {};\n\n const result = extractErrorMessage(content);\n\n expect(result).toBe(\"{}\");\n });\n });\n});\n"]}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
2
|
import { MCPTransport } from "./mcp-client";
|
|
3
|
+
/**
|
|
4
|
+
* Extracts error message from MCP tool result content.
|
|
5
|
+
* Handles both array and string content formats.
|
|
6
|
+
* Always returns a string, even for invalid/null inputs.
|
|
7
|
+
*/
|
|
8
|
+
export declare function extractErrorMessage(content: unknown): string;
|
|
3
9
|
export interface McpServerInfo {
|
|
4
10
|
name?: string;
|
|
5
11
|
url: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-mcp-provider.d.ts","sourceRoot":"","sources":["../../src/mcp/tambo-mcp-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAa,MAAM,OAAO,CAAC;AAGtC,OAAO,EAAa,YAAY,EAAE,MAAM,cAAc,CAAC;AAEvD,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;AACD;;;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,CAkEA,CAAC"}
|
|
1
|
+
{"version":3,"file":"tambo-mcp-provider.d.ts","sourceRoot":"","sources":["../../src/mcp/tambo-mcp-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAa,MAAM,OAAO,CAAC;AAGtC,OAAO,EAAa,YAAY,EAAE,MAAM,cAAc,CAAC;AAEvD;;;;GAIG;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;AACD;;;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,CAkEA,CAAC"}
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TamboMcpProvider = void 0;
|
|
4
|
+
exports.extractErrorMessage = extractErrorMessage;
|
|
4
5
|
const react_1 = require("react");
|
|
5
6
|
const tambo_registry_provider_1 = require("../providers/tambo-registry-provider");
|
|
6
7
|
const mcp_client_1 = require("./mcp-client");
|
|
8
|
+
/**
|
|
9
|
+
* Extracts error message from MCP tool result content.
|
|
10
|
+
* Handles both array and string content formats.
|
|
11
|
+
* Always returns a string, even for invalid/null inputs.
|
|
12
|
+
*/
|
|
13
|
+
function extractErrorMessage(content) {
|
|
14
|
+
if (content === undefined || content === null) {
|
|
15
|
+
return "Unknown error occurred";
|
|
16
|
+
}
|
|
17
|
+
if (Array.isArray(content)) {
|
|
18
|
+
const textItems = content
|
|
19
|
+
.filter((item) => item && item.type === "text" && typeof item.text === "string")
|
|
20
|
+
.map((item) => item.text);
|
|
21
|
+
return textItems.length > 0
|
|
22
|
+
? textItems.join(" ")
|
|
23
|
+
: "Error occurred but no details provided";
|
|
24
|
+
}
|
|
25
|
+
if (typeof content === "object") {
|
|
26
|
+
return JSON.stringify(content);
|
|
27
|
+
}
|
|
28
|
+
return `${content}`;
|
|
29
|
+
}
|
|
7
30
|
/**
|
|
8
31
|
* This provider is used to register tools from MCP servers.
|
|
9
32
|
* @returns the wrapped children
|
|
@@ -52,8 +75,8 @@ const TamboMcpProvider = ({ mcpServers, children }) => {
|
|
|
52
75
|
}
|
|
53
76
|
const result = await mcpServer.callTool(tool.name, args);
|
|
54
77
|
if (result.isError) {
|
|
55
|
-
|
|
56
|
-
throw new Error(
|
|
78
|
+
const errorMessage = extractErrorMessage(result.content);
|
|
79
|
+
throw new Error(errorMessage);
|
|
57
80
|
}
|
|
58
81
|
return result.content;
|
|
59
82
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-mcp-provider.js","sourceRoot":"","sources":["../../src/mcp/tambo-mcp-provider.tsx"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"tambo-mcp-provider.js","sourceRoot":"","sources":["../../src/mcp/tambo-mcp-provider.tsx"],"names":[],"mappings":";;;AAUA,kDAsBC;AAhCD,iCAAsC;AAEtC,kFAAwE;AACxE,6C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,CAAC;YACV,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBACxB,YAAY,CAAC;oBACX,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE;oBACnC,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,IAAI,EAAE,KAAK,EAAE,IAA6B,EAAE,EAAE;wBAC5C,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;wBAC9C,IAAI,CAAC,SAAS,EAAE,CAAC;4BACf,sBAAsB;4BACtB,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,CAAC,IAAI,YAAY,CAAC,CAAC;wBAChE,CAAC;wBACD,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;wBACzD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;4BACnB,MAAM,YAAY,GAAG,mBAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;4BACzD,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;wBAChC,CAAC;wBACD,OAAO,MAAM,CAAC,OAAO,CAAC;oBACxB,CAAC;oBACD,UAAU,EAAE,IAAI,CAAC,WAAsC;iBACxD,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;QACD,kBAAkB,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC;IAE/B,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AArEW,QAAA,gBAAgB,oBAqE3B","sourcesContent":["import { FC, useEffect } 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 */\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/**\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\n useEffect(() => {\n if (!mcpServers) {\n return;\n }\n async function registerMcpServers(mcpServers: (McpServerInfo | string)[]) {\n // Maps tool names to the MCP client that registered them\n const mcpServerMap = new Map<string, MCPClient>();\n const serverToolLists = mcpServers.map(async (mcpServer) => {\n const server =\n typeof mcpServer === \"string\"\n ? { url: mcpServer, transport: MCPTransport.SSE }\n : mcpServer;\n const { url, transport = MCPTransport.SSE, customHeaders } = server;\n const mcpClient = await MCPClient.create(url, transport, customHeaders);\n const tools = await mcpClient.listTools();\n tools.forEach((tool) => {\n mcpServerMap.set(tool.name, mcpClient);\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 const result = await mcpServer.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 registerMcpServers(mcpServers);\n }, [mcpServers, registerTool]);\n\n return children;\n};\n"]}
|
package/dist/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tambo-interactables-additional-context-edge-cases.test.d.ts","sourceRoot":"","sources":["../../../src/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.tsx"],"names":[],"mappings":""}
|