@tambo-ai/react 0.64.1 → 0.65.2
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/README.md +304 -327
- package/dist/hooks/use-tambo-threads.d.ts +0 -12
- package/dist/hooks/use-tambo-threads.d.ts.map +1 -1
- package/dist/hooks/use-tambo-threads.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp/__tests__/elicitation.test.js +7 -3
- package/dist/mcp/__tests__/elicitation.test.js.map +1 -1
- package/dist/mcp/__tests__/mcp-hooks.test.js +149 -123
- package/dist/mcp/__tests__/mcp-hooks.test.js.map +1 -1
- package/dist/mcp/__tests__/tambo-mcp-provider.test.js +176 -120
- package/dist/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -1
- package/dist/mcp/__tests__/use-mcp-servers.test.js +12 -9
- package/dist/mcp/__tests__/use-mcp-servers.test.js.map +1 -1
- package/dist/mcp/elicitation.d.ts +4 -40
- package/dist/mcp/elicitation.d.ts.map +1 -1
- package/dist/mcp/elicitation.js +1 -1
- package/dist/mcp/elicitation.js.map +1 -1
- package/dist/mcp/index.d.ts +2 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +2 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/mcp-client.d.ts +14 -26
- package/dist/mcp/mcp-client.d.ts.map +1 -1
- package/dist/mcp/mcp-client.js +4 -7
- package/dist/mcp/mcp-client.js.map +1 -1
- package/dist/mcp/mcp-hooks.d.ts +27 -78
- package/dist/mcp/mcp-hooks.d.ts.map +1 -1
- package/dist/mcp/tambo-mcp-provider.d.ts +27 -45
- package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/dist/mcp/tambo-mcp-provider.js +36 -87
- package/dist/mcp/tambo-mcp-provider.js.map +1 -1
- package/dist/model/mcp-server-info.d.ts +74 -0
- package/dist/model/mcp-server-info.d.ts.map +1 -0
- package/dist/model/mcp-server-info.js +29 -0
- package/dist/model/mcp-server-info.js.map +1 -0
- package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.js +22 -8
- package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.js.map +1 -1
- package/dist/providers/__tests__/tambo-thread-provider.test.js +318 -129
- package/dist/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +2 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/tambo-client-provider.d.ts +4 -0
- package/dist/providers/tambo-client-provider.d.ts.map +1 -1
- package/dist/providers/tambo-client-provider.js +3 -0
- package/dist/providers/tambo-client-provider.js.map +1 -1
- package/dist/providers/tambo-mcp-token-provider.d.ts +3 -0
- package/dist/providers/tambo-mcp-token-provider.d.ts.map +1 -1
- package/dist/providers/tambo-mcp-token-provider.js +11 -3
- package/dist/providers/tambo-mcp-token-provider.js.map +1 -1
- package/dist/providers/tambo-provider.d.ts +1 -0
- package/dist/providers/tambo-provider.d.ts.map +1 -1
- package/dist/providers/tambo-provider.js +10 -5
- package/dist/providers/tambo-provider.js.map +1 -1
- package/dist/providers/tambo-registry-provider.d.ts +37 -0
- package/dist/providers/tambo-registry-provider.d.ts.map +1 -1
- package/dist/providers/tambo-registry-provider.js +162 -2
- package/dist/providers/tambo-registry-provider.js.map +1 -1
- package/dist/providers/tambo-stubs.d.ts.map +1 -1
- package/dist/providers/tambo-stubs.js +10 -1
- package/dist/providers/tambo-stubs.js.map +1 -1
- package/esm/hooks/use-tambo-threads.d.ts +0 -12
- package/esm/hooks/use-tambo-threads.d.ts.map +1 -1
- package/esm/hooks/use-tambo-threads.js.map +1 -1
- package/esm/index.d.ts +3 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +3 -2
- package/esm/index.js.map +1 -1
- package/esm/mcp/__tests__/elicitation.test.js +8 -4
- package/esm/mcp/__tests__/elicitation.test.js.map +1 -1
- package/esm/mcp/__tests__/mcp-hooks.test.js +149 -123
- package/esm/mcp/__tests__/mcp-hooks.test.js.map +1 -1
- package/esm/mcp/__tests__/tambo-mcp-provider.test.js +178 -122
- package/esm/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -1
- package/esm/mcp/__tests__/use-mcp-servers.test.js +12 -9
- package/esm/mcp/__tests__/use-mcp-servers.test.js.map +1 -1
- package/esm/mcp/elicitation.d.ts +4 -40
- package/esm/mcp/elicitation.d.ts.map +1 -1
- package/esm/mcp/elicitation.js +2 -2
- package/esm/mcp/elicitation.js.map +1 -1
- package/esm/mcp/index.d.ts +2 -1
- package/esm/mcp/index.d.ts.map +1 -1
- package/esm/mcp/index.js +1 -1
- package/esm/mcp/index.js.map +1 -1
- package/esm/mcp/mcp-client.d.ts +14 -26
- package/esm/mcp/mcp-client.d.ts.map +1 -1
- package/esm/mcp/mcp-client.js +3 -5
- package/esm/mcp/mcp-client.js.map +1 -1
- package/esm/mcp/mcp-hooks.d.ts +27 -78
- package/esm/mcp/mcp-hooks.d.ts.map +1 -1
- package/esm/mcp/tambo-mcp-provider.d.ts +27 -45
- package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/esm/mcp/tambo-mcp-provider.js +35 -86
- package/esm/mcp/tambo-mcp-provider.js.map +1 -1
- package/esm/model/mcp-server-info.d.ts +74 -0
- package/esm/model/mcp-server-info.d.ts.map +1 -0
- package/esm/model/mcp-server-info.js +25 -0
- package/esm/model/mcp-server-info.js.map +1 -0
- package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.js +23 -9
- package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.js.map +1 -1
- package/esm/providers/__tests__/tambo-thread-provider.test.js +319 -130
- package/esm/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
- package/esm/providers/index.d.ts +1 -1
- package/esm/providers/index.d.ts.map +1 -1
- package/esm/providers/index.js +1 -1
- package/esm/providers/index.js.map +1 -1
- package/esm/providers/tambo-client-provider.d.ts +4 -0
- package/esm/providers/tambo-client-provider.d.ts.map +1 -1
- package/esm/providers/tambo-client-provider.js +3 -0
- package/esm/providers/tambo-client-provider.js.map +1 -1
- package/esm/providers/tambo-mcp-token-provider.d.ts +3 -0
- package/esm/providers/tambo-mcp-token-provider.d.ts.map +1 -1
- package/esm/providers/tambo-mcp-token-provider.js +13 -5
- package/esm/providers/tambo-mcp-token-provider.js.map +1 -1
- package/esm/providers/tambo-provider.d.ts +1 -0
- package/esm/providers/tambo-provider.d.ts.map +1 -1
- package/esm/providers/tambo-provider.js +11 -6
- package/esm/providers/tambo-provider.js.map +1 -1
- package/esm/providers/tambo-registry-provider.d.ts +37 -0
- package/esm/providers/tambo-registry-provider.d.ts.map +1 -1
- package/esm/providers/tambo-registry-provider.js +161 -2
- package/esm/providers/tambo-registry-provider.js.map +1 -1
- package/esm/providers/tambo-stubs.d.ts.map +1 -1
- package/esm/providers/tambo-stubs.js +10 -1
- package/esm/providers/tambo-stubs.js.map +1 -1
- package/package.json +6 -6
|
@@ -12,18 +12,6 @@ interface UseTamboThreadListConfig {
|
|
|
12
12
|
*/
|
|
13
13
|
contextKey?: string;
|
|
14
14
|
}
|
|
15
|
-
interface UseTamboThreadListConfig {
|
|
16
|
-
/**
|
|
17
|
-
* The projectId to get the threads for. If not provided, the current project
|
|
18
|
-
* will be used.
|
|
19
|
-
*/
|
|
20
|
-
projectId?: string;
|
|
21
|
-
/**
|
|
22
|
-
* The context key to get the threads for. If not provided, all threads for
|
|
23
|
-
* the project will be returned.
|
|
24
|
-
*/
|
|
25
|
-
contextKey?: string;
|
|
26
|
-
}
|
|
27
15
|
/**
|
|
28
16
|
* Get all the threads for the specified project.
|
|
29
17
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tambo-threads.d.ts","sourceRoot":"","sources":["../../src/hooks/use-tambo-threads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,UAAU,wBAAwB;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED
|
|
1
|
+
{"version":3,"file":"use-tambo-threads.d.ts","sourceRoot":"","sources":["../../src/hooks/use-tambo-threads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,UAAU,wBAAwB;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,SAAS,EAAE,UAAU,EAAE,GAAE,wBAA6B,EACxD,OAAO,GAAE,OAAO,CACd,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAC9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tambo-threads.js","sourceRoot":"","sources":["../../src/hooks/use-tambo-threads.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"use-tambo-threads.js","sourceRoot":"","sources":["../../src/hooks/use-tambo-threads.ts"],"names":[],"mappings":";;AA6BA,gDAgCC;AA3DD,8EAAoE;AACpE,2DAAoD;AAepD;;;;;;;;;;GAUG;AACH,SAAgB,kBAAkB,CAChC,EAAE,SAAS,EAAE,UAAU,KAA+B,EAAE,EACxD,UAEI,EAAE;IAEN,MAAM,MAAM,GAAG,IAAA,sCAAc,GAAE,CAAC;IAChC,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,GAAG,IAAA,iCAAa,EAAC;QAClE,GAAI,OAA8C;QAClD,QAAQ,EAAE,CAAC,WAAW,CAAC;QACvB,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,OAAO,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC;QACtD,CAAC;KACF,CAAC,CAAC;IACH,MAAM,gBAAgB,GAAG,SAAS,IAAI,gBAAgB,CAAC;IAEvD,MAAM,WAAW,GAAG,IAAA,iCAAa,EAAC;QAChC,GAAG,OAAO;QACV,OAAO,EAAE,CAAC,CAAC,gBAAgB;QAC3B,QAAQ,EAAE,CAAC,SAAS,EAAE,gBAAgB,EAAE,UAAU,CAAC;QACnD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACtB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE;gBAClE,UAAU;aACX,CAAC,CAAC;YACH,OAAO,UAAU,CAAC;QACpB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,gBAAgB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,cAAc,EAAE,CAAC;AAC5E,CAAC","sourcesContent":["import type TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { UseQueryOptions } from \"@tanstack/react-query\";\nimport { useTamboClient } from \"../providers/tambo-client-provider\";\nimport { useTamboQuery } from \"./react-query-hooks\";\n\ninterface UseTamboThreadListConfig {\n /**\n * The projectId to get the threads for. If not provided, the current project\n * will be used.\n */\n projectId?: string;\n /**\n * The context key to get the threads for. If not provided, all threads for\n * the project will be returned.\n */\n contextKey?: string;\n}\n\n/**\n * Get all the threads for the specified project.\n *\n * If contextKey is empty, then all threads for the project will be returned.\n * If contextKey is not empty, then only the threads for the specified context\n * key will be returned.\n * @param config - The config for the useTamboThreadList hook\n * @param config.projectId - The projectId to get the threads for\n * @param config.contextKey - The context key to get the threads for\n * @returns The threads for the specified project and optional context key\n */\nexport function useTamboThreadList(\n { projectId, contextKey }: UseTamboThreadListConfig = {},\n options: Partial<\n UseQueryOptions<TamboAI.Beta.Threads.ThreadsOffsetAndLimit | null>\n > = {},\n) {\n const client = useTamboClient();\n const { data: queriedProjectId, ...projectIdState } = useTamboQuery({\n ...(options as unknown as UseQueryOptions<string>),\n queryKey: [\"projectId\"],\n queryFn: async () => {\n return (await client.beta.projects.getCurrent()).id;\n },\n });\n const currentProjectId = projectId ?? queriedProjectId;\n\n const threadState = useTamboQuery({\n ...options,\n enabled: !!currentProjectId,\n queryKey: [\"threads\", currentProjectId, contextKey],\n queryFn: async () => {\n if (!currentProjectId) {\n return null;\n }\n const threadIter = await client.beta.threads.list(currentProjectId, {\n contextKey,\n });\n return threadIter;\n },\n });\n\n return currentProjectId ? threadState : { data: null, ...projectIdState };\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ 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
8
|
export { useTamboVoice } from "./hooks/use-tambo-voice";
|
|
9
|
-
export { TamboClientProvider, TamboComponentProvider, TamboContextAttachmentProvider, TamboContextHelpersProvider, TamboPropStreamProvider, TamboProvider, TamboStubProvider, TamboThreadInputProvider, TamboThreadProvider, useIsTamboTokenUpdating, useTambo, useTamboClient, useTamboContextAttachment, useTamboContextHelpers, useTamboGenerationStage, useTamboStream, useTamboThread, useTamboThreadInput, type ContextAttachment, type ContextAttachmentState, type ContextHelperData, type TamboComponent, type TamboContextAttachmentProviderProps, type TamboContextHelpersContextProps, type TamboContextHelpersProviderProps, type TamboRegistryContext, type TamboStubProviderProps, type TamboThreadInputContextProps, type TamboThreadProviderProps, } from "./providers";
|
|
9
|
+
export { TamboClientProvider, TamboComponentProvider, TamboContextAttachmentProvider, TamboContextHelpersProvider, TamboPropStreamProvider, TamboProvider, TamboRegistryProvider, TamboStubProvider, TamboThreadInputProvider, TamboThreadProvider, useIsTamboTokenUpdating, useTambo, useTamboClient, useTamboContextAttachment, useTamboContextHelpers, useTamboGenerationStage, useTamboMcpServerInfos, useTamboStream, useTamboThread, useTamboThreadInput, type ContextAttachment, type ContextAttachmentState, type ContextHelperData, type TamboComponent, type TamboContextAttachmentProviderProps, type TamboContextHelpersContextProps, type TamboContextHelpersProviderProps, type TamboRegistryContext, type TamboStubProviderProps, type TamboThreadInputContextProps, type TamboThreadProviderProps, } from "./providers";
|
|
10
10
|
export type { APIError, RateLimitError, TamboAIError, } from "@tambo-ai/typescript-sdk";
|
|
11
11
|
export type { Suggestion, SuggestionGenerateParams, SuggestionGenerateResponse, SuggestionListResponse, } from "@tambo-ai/typescript-sdk/resources/beta/threads/suggestions";
|
|
12
12
|
export { useTamboThreadList } from "./hooks/use-tambo-threads";
|
|
@@ -19,4 +19,6 @@ export { withTamboInteractable as withInteractable, type InteractableConfig, typ
|
|
|
19
19
|
export { useCurrentInteractablesSnapshot, useTamboInteractable, } from "./providers/tambo-interactable-provider";
|
|
20
20
|
export { currentPageContextHelper, currentTimeContextHelper, } from "./context-helpers";
|
|
21
21
|
export type { AdditionalContext, ContextHelperFn, ContextHelpers, } from "./context-helpers";
|
|
22
|
+
export type { McpServerInfo, NormalizedMcpServerInfo, } from "./model/mcp-server-info";
|
|
23
|
+
export { MCPTransport } from "./model/mcp-server-info";
|
|
22
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1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,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;AAG3B,YAAY,EACV,aAAa,EACb,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,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.useCurrentInteractablesSnapshot = exports.withInteractable = exports.GenerationStage = exports.useTamboThreadList = exports.useTamboThreadInput = exports.useTamboThread = exports.useTamboStream = exports.useTamboGenerationStage = exports.useTamboContextHelpers = exports.useTamboContextAttachment = exports.useTamboClient = exports.useTambo = exports.useIsTamboTokenUpdating = exports.TamboThreadProvider = exports.TamboThreadInputProvider = exports.TamboStubProvider = exports.TamboProvider = exports.TamboPropStreamProvider = exports.TamboContextHelpersProvider = exports.TamboContextAttachmentProvider = exports.TamboComponentProvider = exports.TamboClientProvider = exports.useTamboVoice = exports.useTamboStreamStatus = exports.useTamboStreamingProps = exports.useMessageImages = exports.useTamboCurrentMessage = exports.TamboMessageProvider = exports.useTamboComponentState = void 0;
|
|
18
|
+
exports.MCPTransport = exports.currentTimeContextHelper = exports.currentPageContextHelper = exports.useTamboInteractable = exports.useCurrentInteractablesSnapshot = exports.withInteractable = exports.GenerationStage = exports.useTamboThreadList = exports.useTamboThreadInput = exports.useTamboThread = exports.useTamboStream = exports.useTamboMcpServerInfos = exports.useTamboGenerationStage = exports.useTamboContextHelpers = exports.useTamboContextAttachment = exports.useTamboClient = exports.useTambo = exports.useIsTamboTokenUpdating = exports.TamboThreadProvider = exports.TamboThreadInputProvider = exports.TamboStubProvider = exports.TamboRegistryProvider = exports.TamboProvider = exports.TamboPropStreamProvider = exports.TamboContextHelpersProvider = exports.TamboContextAttachmentProvider = exports.TamboComponentProvider = exports.TamboClientProvider = exports.useTamboVoice = exports.useTamboStreamStatus = exports.useTamboStreamingProps = exports.useMessageImages = 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");
|
|
@@ -38,6 +38,7 @@ Object.defineProperty(exports, "TamboContextAttachmentProvider", { enumerable: t
|
|
|
38
38
|
Object.defineProperty(exports, "TamboContextHelpersProvider", { enumerable: true, get: function () { return providers_1.TamboContextHelpersProvider; } });
|
|
39
39
|
Object.defineProperty(exports, "TamboPropStreamProvider", { enumerable: true, get: function () { return providers_1.TamboPropStreamProvider; } });
|
|
40
40
|
Object.defineProperty(exports, "TamboProvider", { enumerable: true, get: function () { return providers_1.TamboProvider; } });
|
|
41
|
+
Object.defineProperty(exports, "TamboRegistryProvider", { enumerable: true, get: function () { return providers_1.TamboRegistryProvider; } });
|
|
41
42
|
Object.defineProperty(exports, "TamboStubProvider", { enumerable: true, get: function () { return providers_1.TamboStubProvider; } });
|
|
42
43
|
Object.defineProperty(exports, "TamboThreadInputProvider", { enumerable: true, get: function () { return providers_1.TamboThreadInputProvider; } });
|
|
43
44
|
Object.defineProperty(exports, "TamboThreadProvider", { enumerable: true, get: function () { return providers_1.TamboThreadProvider; } });
|
|
@@ -47,6 +48,7 @@ Object.defineProperty(exports, "useTamboClient", { enumerable: true, get: functi
|
|
|
47
48
|
Object.defineProperty(exports, "useTamboContextAttachment", { enumerable: true, get: function () { return providers_1.useTamboContextAttachment; } });
|
|
48
49
|
Object.defineProperty(exports, "useTamboContextHelpers", { enumerable: true, get: function () { return providers_1.useTamboContextHelpers; } });
|
|
49
50
|
Object.defineProperty(exports, "useTamboGenerationStage", { enumerable: true, get: function () { return providers_1.useTamboGenerationStage; } });
|
|
51
|
+
Object.defineProperty(exports, "useTamboMcpServerInfos", { enumerable: true, get: function () { return providers_1.useTamboMcpServerInfos; } });
|
|
50
52
|
Object.defineProperty(exports, "useTamboStream", { enumerable: true, get: function () { return providers_1.useTamboStream; } });
|
|
51
53
|
Object.defineProperty(exports, "useTamboThread", { enumerable: true, get: function () { return providers_1.useTamboThread; } });
|
|
52
54
|
Object.defineProperty(exports, "useTamboThreadInput", { enumerable: true, get: function () { return providers_1.useTamboThreadInput; } });
|
|
@@ -63,6 +65,8 @@ Object.defineProperty(exports, "useTamboInteractable", { enumerable: true, get:
|
|
|
63
65
|
var context_helpers_1 = require("./context-helpers");
|
|
64
66
|
Object.defineProperty(exports, "currentPageContextHelper", { enumerable: true, get: function () { return context_helpers_1.currentPageContextHelper; } });
|
|
65
67
|
Object.defineProperty(exports, "currentTimeContextHelper", { enumerable: true, get: function () { return context_helpers_1.currentTimeContextHelper; } });
|
|
66
|
-
|
|
68
|
+
var mcp_server_info_1 = require("./model/mcp-server-info");
|
|
69
|
+
Object.defineProperty(exports, "MCPTransport", { enumerable: true, get: function () { return mcp_server_info_1.MCPTransport; } });
|
|
70
|
+
// Note: Full MCP exports like TamboMcpProvider are available separately in the
|
|
67
71
|
// @tambo-ai/react/mcp package
|
|
68
72
|
//# sourceMappingURL=index.js.map
|
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,6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,2GAAA,cAAc,OAAA;AACd,gHAAA,mBAAmB,OAAA;AA0BrB,+DAA+D;AAAtD,uHAAA,kBAAkB,OAAA;AAQ3B,mFAG6C;AAF3C,8HAAA,eAAe,OAAA;AAUjB,mFAIiD;AAH/C,2HAAA,qBAAqB,OAAoB;AAI3C,uFAGiD;AAF/C,8IAAA,+BAA+B,OAAA;AAC/B,mIAAA,oBAAoB,OAAA;AAGtB,0BAA0B;AAC1B,qDAG2B;AAFzB,2HAAA,wBAAwB,OAAA;AACxB,2HAAA,wBAAwB,OAAA;AAa1B,2DAAuD;AAA9C,+GAAA,YAAY,OAAA;AAErB,+EAA+E;AAC/E,8BAA8B","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\";\nexport { useTamboVoice } from \"./hooks/use-tambo-voice\";\n\n// Re-export provider components\nexport {\n TamboClientProvider,\n TamboComponentProvider,\n TamboContextAttachmentProvider,\n TamboContextHelpersProvider,\n TamboPropStreamProvider,\n TamboProvider,\n TamboRegistryProvider,\n TamboStubProvider,\n TamboThreadInputProvider,\n TamboThreadProvider,\n useIsTamboTokenUpdating,\n useTambo,\n useTamboClient,\n useTamboContextAttachment,\n useTamboContextHelpers,\n useTamboGenerationStage,\n useTamboMcpServerInfos,\n useTamboStream,\n useTamboThread,\n useTamboThreadInput,\n type ContextAttachment,\n type ContextAttachmentState,\n type ContextHelperData,\n type TamboComponent,\n type TamboContextAttachmentProviderProps,\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\n// MCP server metadata types (used by TamboProvider / registry / MCP provider)\nexport type {\n McpServerInfo,\n NormalizedMcpServerInfo,\n} from \"./model/mcp-server-info\";\nexport { MCPTransport } from \"./model/mcp-server-info\";\n\n// Note: Full MCP exports like TamboMcpProvider are available separately in the\n// @tambo-ai/react/mcp package\n"]}
|
|
@@ -30,6 +30,7 @@ describe("useElicitation", () => {
|
|
|
30
30
|
it("sets elicitation state when called", async () => {
|
|
31
31
|
const { result } = (0, react_1.renderHook)(() => (0, elicitation_1.useElicitation)());
|
|
32
32
|
const request = {
|
|
33
|
+
method: "elicitation/create",
|
|
33
34
|
params: {
|
|
34
35
|
message: "Please provide your name",
|
|
35
36
|
requestedSchema: {
|
|
@@ -66,6 +67,7 @@ describe("useElicitation", () => {
|
|
|
66
67
|
it("resolves promise when resolveElicitation is called with accept", async () => {
|
|
67
68
|
const { result } = (0, react_1.renderHook)(() => (0, elicitation_1.useElicitation)());
|
|
68
69
|
const request = {
|
|
70
|
+
method: "elicitation/create",
|
|
69
71
|
params: {
|
|
70
72
|
message: "Enter your email",
|
|
71
73
|
requestedSchema: {
|
|
@@ -101,6 +103,7 @@ describe("useElicitation", () => {
|
|
|
101
103
|
it("resolves promise when resolveElicitation is called with decline", async () => {
|
|
102
104
|
const { result } = (0, react_1.renderHook)(() => (0, elicitation_1.useElicitation)());
|
|
103
105
|
const request = {
|
|
106
|
+
method: "elicitation/create",
|
|
104
107
|
params: {
|
|
105
108
|
message: "Provide input",
|
|
106
109
|
requestedSchema: {
|
|
@@ -128,6 +131,7 @@ describe("useElicitation", () => {
|
|
|
128
131
|
it("resolves promise when resolveElicitation is called with cancel", async () => {
|
|
129
132
|
const { result } = (0, react_1.renderHook)(() => (0, elicitation_1.useElicitation)());
|
|
130
133
|
const request = {
|
|
134
|
+
method: "elicitation/create",
|
|
131
135
|
params: {
|
|
132
136
|
message: "Provide input",
|
|
133
137
|
requestedSchema: {
|
|
@@ -156,6 +160,7 @@ describe("useElicitation", () => {
|
|
|
156
160
|
const { result } = (0, react_1.renderHook)(() => (0, elicitation_1.useElicitation)());
|
|
157
161
|
// First elicitation
|
|
158
162
|
const request1 = {
|
|
163
|
+
method: "elicitation/create",
|
|
159
164
|
params: {
|
|
160
165
|
message: "First request",
|
|
161
166
|
requestedSchema: {
|
|
@@ -185,13 +190,12 @@ describe("useElicitation", () => {
|
|
|
185
190
|
});
|
|
186
191
|
// Second elicitation
|
|
187
192
|
const request2 = {
|
|
193
|
+
method: "elicitation/create",
|
|
188
194
|
params: {
|
|
189
195
|
message: "Second request",
|
|
190
196
|
requestedSchema: {
|
|
191
197
|
type: "object",
|
|
192
|
-
properties: {
|
|
193
|
-
field2: { type: "number" },
|
|
194
|
-
},
|
|
198
|
+
properties: { field2: { type: "number" } },
|
|
195
199
|
},
|
|
196
200
|
},
|
|
197
201
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elicitation.test.js","sourceRoot":"","sources":["../../../src/mcp/__tests__/elicitation.test.tsx"],"names":[],"mappings":";;AAAA,kDAAyD;AACzD,gDAIwB;AAOxB,gDAAgD;AAChD,SAAS,eAAe;IAItB,OAAO;QACL,MAAM,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM;QACpC,SAAS,EAAE,iBAAiB;QAE5B,gBAAgB,EAAE,CAAC,KAAK,IAAI,EAAE,GAAE,CAAC,CAAQ;QAEzC,WAAW,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAQ;KAClD,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAU,EAAC,GAAG,EAAE,CAAC,IAAA,4BAAc,GAAE,CAAC,CAAC;QAEtD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAChC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAU,EAAC,GAAG,EAAE,CAAC,IAAA,4BAAc,GAAE,CAAC,CAAC;QAEtD,MAAM,CAAC,OAAO,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,IAA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,EAAE;qBAC5B;iBACF;aACF,CAAC;YAEF,IAAA,WAAG,EAAC,GAAG,EAAE;gBACP,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;YACnD,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;YAC3C,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAU,EAAC,GAAG,EAAE,CAAC,IAAA,4BAAc,GAAE,CAAC,CAAC;YAEtD,MAAM,WAAW,GAA4B;gBAC3C,OAAO,EAAE,MAAM;gBACf,eAAe,EAAE;oBACf,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE,EAAE;iBACf;aACF,CAAC;YAEF,IAAA,WAAG,EAAC,GAAG,EAAE;gBACP,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;YAC7C,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YAElD,IAAA,WAAG,EAAC,GAAG,EAAE;gBACP,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { renderHook, act } from \"@testing-library/react\";\nimport {\n useElicitation,\n type TamboElicitationRequest,\n type TamboElicitationResponse,\n} from \"../elicitation\";\nimport type { RequestHandlerExtra } from \"@modelcontextprotocol/sdk/shared/protocol.js\";\nimport type {\n ClientNotification,\n ClientRequest,\n} from \"@modelcontextprotocol/sdk/types.js\";\n\n// Create a mock RequestHandlerExtra for testing\nfunction createMockExtra(): RequestHandlerExtra<\n ClientRequest,\n ClientNotification\n> {\n return {\n signal: new AbortController().signal,\n requestId: \"test-request-id\",\n\n sendNotification: (async () => {}) as any,\n\n sendRequest: (async () => ({ _meta: {} })) as any,\n };\n}\n\ndescribe(\"useElicitation\", () => {\n it(\"initializes with null state\", () => {\n const { result } = renderHook(() => useElicitation());\n\n expect(result.current.elicitation).toBeNull();\n expect(result.current.resolveElicitation).toBeNull();\n });\n\n it(\"provides state setters\", () => {\n const { result } = renderHook(() => useElicitation());\n\n expect(typeof result.current.setElicitation).toBe(\"function\");\n expect(typeof result.current.setResolveElicitation).toBe(\"function\");\n });\n\n it(\"provides a default elicitation handler\", () => {\n const { result } = renderHook(() => useElicitation());\n\n expect(typeof result.current.defaultElicitationHandler).toBe(\"function\");\n });\n\n describe(\"defaultElicitationHandler\", () => {\n it(\"sets elicitation state when called\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n const request: Parameters<\n typeof result.current.defaultElicitationHandler\n >[0] = {\n params: {\n message: \"Please provide your name\",\n requestedSchema: {\n type: \"object\",\n properties: {\n name: { type: \"string\", description: \"Your name\" },\n },\n required: [\"name\"],\n },\n },\n };\n\n // Start the handler but don't await yet\n let handlerPromise: Promise<TamboElicitationResponse>;\n const extra = createMockExtra();\n act(() => {\n handlerPromise = result.current.defaultElicitationHandler(\n request,\n extra,\n );\n });\n\n // Elicitation should be set\n expect(result.current.elicitation).toEqual({\n message: \"Please provide your name\",\n requestedSchema: request.params.requestedSchema,\n signal: extra.signal,\n });\n\n // Resolve callback should be set\n expect(result.current.resolveElicitation).not.toBeNull();\n\n // Clean up by resolving\n act(() => {\n result.current.resolveElicitation?.({\n action: \"cancel\",\n });\n });\n\n await handlerPromise!;\n });\n\n it(\"resolves promise when resolveElicitation is called with accept\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n const request: Parameters<\n typeof result.current.defaultElicitationHandler\n >[0] = {\n params: {\n message: \"Enter your email\",\n requestedSchema: {\n type: \"object\",\n properties: {\n email: {\n type: \"string\",\n format: \"email\",\n description: \"Email address\",\n },\n },\n },\n },\n };\n\n // Start the handler\n let handlerPromise: Promise<TamboElicitationResponse>;\n const extra = createMockExtra();\n act(() => {\n handlerPromise = result.current.defaultElicitationHandler(\n request,\n extra,\n );\n });\n\n // Resolve with accept\n const response: TamboElicitationResponse = {\n action: \"accept\",\n content: { email: \"test@example.com\" },\n };\n\n act(() => {\n result.current.resolveElicitation?.(response);\n });\n\n // Wait for promise to resolve\n const resolvedValue = await handlerPromise!;\n\n expect(resolvedValue).toEqual(response);\n });\n\n it(\"resolves promise when resolveElicitation is called with decline\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n const request: Parameters<\n typeof result.current.defaultElicitationHandler\n >[0] = {\n params: {\n message: \"Provide input\",\n requestedSchema: {\n type: \"object\",\n properties: {\n value: { type: \"string\" },\n },\n },\n },\n };\n\n let handlerPromise: Promise<TamboElicitationResponse>;\n const extra = createMockExtra();\n act(() => {\n handlerPromise = result.current.defaultElicitationHandler(\n request,\n extra,\n );\n });\n\n const response: TamboElicitationResponse = {\n action: \"decline\",\n };\n\n act(() => {\n result.current.resolveElicitation?.(response);\n });\n\n const resolvedValue = await handlerPromise!;\n\n expect(resolvedValue).toEqual(response);\n });\n\n it(\"resolves promise when resolveElicitation is called with cancel\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n const request: Parameters<\n typeof result.current.defaultElicitationHandler\n >[0] = {\n params: {\n message: \"Provide input\",\n requestedSchema: {\n type: \"object\",\n properties: {\n value: { type: \"string\" },\n },\n },\n },\n };\n\n let handlerPromise: Promise<TamboElicitationResponse>;\n const extra = createMockExtra();\n act(() => {\n handlerPromise = result.current.defaultElicitationHandler(\n request,\n extra,\n );\n });\n\n const response: TamboElicitationResponse = {\n action: \"cancel\",\n };\n\n act(() => {\n result.current.resolveElicitation?.(response);\n });\n\n const resolvedValue = await handlerPromise!;\n\n expect(resolvedValue).toEqual(response);\n });\n\n it(\"handles multiple sequential elicitations\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n // First elicitation\n const request1: Parameters<\n typeof result.current.defaultElicitationHandler\n >[0] = {\n params: {\n message: \"First request\",\n requestedSchema: {\n type: \"object\",\n properties: {\n field1: { type: \"string\" },\n },\n },\n },\n };\n\n let promise1: Promise<TamboElicitationResponse>;\n const extra1 = createMockExtra();\n act(() => {\n promise1 = result.current.defaultElicitationHandler(request1, extra1);\n });\n\n expect(result.current.elicitation?.message).toBe(\"First request\");\n\n act(() => {\n result.current.resolveElicitation?.({\n action: \"accept\",\n content: { field1: \"value1\" },\n });\n });\n\n const result1 = await promise1!;\n expect(result1).toEqual({\n action: \"accept\",\n content: { field1: \"value1\" },\n });\n\n // Second elicitation\n const request2: Parameters<\n typeof result.current.defaultElicitationHandler\n >[0] = {\n params: {\n message: \"Second request\",\n requestedSchema: {\n type: \"object\",\n properties: {\n field2: { type: \"number\" },\n },\n },\n },\n };\n\n let promise2: Promise<TamboElicitationResponse>;\n const extra2 = createMockExtra();\n act(() => {\n promise2 = result.current.defaultElicitationHandler(request2, extra2);\n });\n\n expect(result.current.elicitation?.message).toBe(\"Second request\");\n\n act(() => {\n result.current.resolveElicitation?.({\n action: \"accept\",\n content: { field2: 42 },\n });\n });\n\n const result2 = await promise2!;\n expect(result2).toEqual({\n action: \"accept\",\n content: { field2: 42 },\n });\n });\n\n it(\"maintains stable handler reference across re-renders\", () => {\n const { result, rerender } = renderHook(() => useElicitation());\n\n const firstHandler = result.current.defaultElicitationHandler;\n\n rerender();\n\n const secondHandler = result.current.defaultElicitationHandler;\n\n expect(firstHandler).toBe(secondHandler);\n });\n });\n\n describe(\"state management\", () => {\n it(\"allows manual state updates via setElicitation\", () => {\n const { result } = renderHook(() => useElicitation());\n\n const customElicitation: TamboElicitationRequest = {\n message: \"Custom message\",\n requestedSchema: {\n type: \"object\",\n properties: {\n custom: { type: \"boolean\" },\n },\n },\n };\n\n act(() => {\n result.current.setElicitation(customElicitation);\n });\n\n expect(result.current.elicitation).toEqual(customElicitation);\n });\n\n it(\"allows clearing elicitation state\", () => {\n const { result } = renderHook(() => useElicitation());\n\n const elicitation: TamboElicitationRequest = {\n message: \"Test\",\n requestedSchema: {\n type: \"object\",\n properties: {},\n },\n };\n\n act(() => {\n result.current.setElicitation(elicitation);\n });\n\n expect(result.current.elicitation).not.toBeNull();\n\n act(() => {\n result.current.setElicitation(null);\n });\n\n expect(result.current.elicitation).toBeNull();\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"elicitation.test.js","sourceRoot":"","sources":["../../../src/mcp/__tests__/elicitation.test.tsx"],"names":[],"mappings":";;AAMA,kDAAyD;AACzD,gDAIwB;AAExB,gDAAgD;AAChD,SAAS,eAAe;IAItB,OAAO;QACL,MAAM,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM;QACpC,SAAS,EAAE,iBAAiB;QAE5B,gBAAgB,EAAE,CAAC,KAAK,IAAI,EAAE,GAAE,CAAC,CAAQ;QAEzC,WAAW,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAQ;KAClD,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAU,EAAC,GAAG,EAAE,CAAC,IAAA,4BAAc,GAAE,CAAC,CAAC;QAEtD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAChC,MAAM,EAAE,MAAM,EAAE,GA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AEH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import type { RequestHandlerExtra } from \"@modelcontextprotocol/sdk/shared/protocol.js\";\nimport type {\n ClientNotification,\n ClientRequest,\n ElicitRequest,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { act, renderHook } from \"@testing-library/react\";\nimport {\n useElicitation,\n type TamboElicitationRequest,\n type TamboElicitationResponse,\n} from \"../elicitation\";\n\n// Create a mock RequestHandlerExtra for testing\nfunction createMockExtra(): RequestHandlerExtra<\n ClientRequest,\n ClientNotification\n> {\n return {\n signal: new AbortController().signal,\n requestId: \"test-request-id\",\n\n sendNotification: (async () => {}) as any,\n\n sendRequest: (async () => ({ _meta: {} })) as any,\n };\n}\n\ndescribe(\"useElicitation\", () => {\n it(\"initializes with null state\", () => {\n const { result } = renderHook(() => useElicitation());\n\n expect(result.current.elicitation).toBeNull();\n expect(result.current.resolveElicitation).toBeNull();\n });\n\n it(\"provides state setters\", () => {\n const { result } = renderHook(() => useElicitation());\n\n expect(typeof result.current.setElicitation).toBe(\"function\");\n expect(typeof result.current.setResolveElicitation).toBe(\"function\");\n });\n\n it(\"provides a default elicitation handler\", () => {\n const { result } = renderHook(() => useElicitation());\n\n expect(typeof result.current.defaultElicitationHandler).toBe(\"function\");\n });\n\n describe(\"defaultElicitationHandler\", () => {\n it(\"sets elicitation state when called\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n const request: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"Please provide your name\",\n requestedSchema: {\n type: \"object\",\n properties: {\n name: { type: \"string\", description: \"Your name\" },\n },\n required: [\"name\"],\n },\n },\n };\n\n // Start the handler but don't await yet\n let handlerPromise: Promise<TamboElicitationResponse>;\n const extra = createMockExtra();\n act(() => {\n handlerPromise = result.current.defaultElicitationHandler(\n request,\n extra,\n );\n });\n\n // Elicitation should be set\n expect(result.current.elicitation).toEqual({\n message: \"Please provide your name\",\n requestedSchema: request.params.requestedSchema,\n signal: extra.signal,\n });\n\n // Resolve callback should be set\n expect(result.current.resolveElicitation).not.toBeNull();\n\n // Clean up by resolving\n act(() => {\n result.current.resolveElicitation?.({\n action: \"cancel\",\n });\n });\n\n await handlerPromise!;\n });\n\n it(\"resolves promise when resolveElicitation is called with accept\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n const request: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"Enter your email\",\n requestedSchema: {\n type: \"object\",\n properties: {\n email: {\n type: \"string\",\n format: \"email\",\n description: \"Email address\",\n },\n },\n },\n },\n };\n\n // Start the handler\n let handlerPromise: Promise<TamboElicitationResponse>;\n const extra = createMockExtra();\n act(() => {\n handlerPromise = result.current.defaultElicitationHandler(\n request,\n extra,\n );\n });\n\n // Resolve with accept\n const response: TamboElicitationResponse = {\n action: \"accept\",\n content: { email: \"test@example.com\" },\n };\n\n act(() => {\n result.current.resolveElicitation?.(response);\n });\n\n // Wait for promise to resolve\n const resolvedValue = await handlerPromise!;\n\n expect(resolvedValue).toEqual(response);\n });\n\n it(\"resolves promise when resolveElicitation is called with decline\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n const request: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"Provide input\",\n requestedSchema: {\n type: \"object\",\n properties: {\n value: { type: \"string\" },\n },\n },\n },\n };\n\n let handlerPromise: Promise<TamboElicitationResponse>;\n const extra = createMockExtra();\n act(() => {\n handlerPromise = result.current.defaultElicitationHandler(\n request,\n extra,\n );\n });\n\n const response: TamboElicitationResponse = {\n action: \"decline\",\n };\n\n act(() => {\n result.current.resolveElicitation?.(response);\n });\n\n const resolvedValue = await handlerPromise!;\n\n expect(resolvedValue).toEqual(response);\n });\n\n it(\"resolves promise when resolveElicitation is called with cancel\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n const request: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"Provide input\",\n requestedSchema: {\n type: \"object\",\n properties: {\n value: { type: \"string\" },\n },\n },\n },\n };\n\n let handlerPromise: Promise<TamboElicitationResponse>;\n const extra = createMockExtra();\n act(() => {\n handlerPromise = result.current.defaultElicitationHandler(\n request,\n extra,\n );\n });\n\n const response: TamboElicitationResponse = {\n action: \"cancel\",\n };\n\n act(() => {\n result.current.resolveElicitation?.(response);\n });\n\n const resolvedValue = await handlerPromise!;\n\n expect(resolvedValue).toEqual(response);\n });\n\n it(\"handles multiple sequential elicitations\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n // First elicitation\n const request1: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"First request\",\n requestedSchema: {\n type: \"object\",\n properties: {\n field1: { type: \"string\" },\n },\n },\n },\n };\n\n let promise1: Promise<TamboElicitationResponse>;\n const extra1 = createMockExtra();\n act(() => {\n promise1 = result.current.defaultElicitationHandler(request1, extra1);\n });\n\n expect(result.current.elicitation?.message).toBe(\"First request\");\n\n act(() => {\n result.current.resolveElicitation?.({\n action: \"accept\",\n content: { field1: \"value1\" },\n });\n });\n\n const result1 = await promise1!;\n expect(result1).toEqual({\n action: \"accept\",\n content: { field1: \"value1\" },\n });\n\n // Second elicitation\n const request2: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"Second request\",\n requestedSchema: {\n type: \"object\",\n properties: { field2: { type: \"number\" } },\n },\n },\n };\n\n let promise2: Promise<TamboElicitationResponse>;\n const extra2 = createMockExtra();\n act(() => {\n promise2 = result.current.defaultElicitationHandler(request2, extra2);\n });\n\n expect(result.current.elicitation?.message).toBe(\"Second request\");\n\n act(() => {\n result.current.resolveElicitation?.({\n action: \"accept\",\n content: { field2: 42 },\n });\n });\n\n const result2 = await promise2!;\n expect(result2).toEqual({\n action: \"accept\",\n content: { field2: 42 },\n });\n });\n\n it(\"maintains stable handler reference across re-renders\", () => {\n const { result, rerender } = renderHook(() => useElicitation());\n\n const firstHandler = result.current.defaultElicitationHandler;\n\n rerender();\n\n const secondHandler = result.current.defaultElicitationHandler;\n\n expect(firstHandler).toBe(secondHandler);\n });\n });\n\n describe(\"state management\", () => {\n it(\"allows manual state updates via setElicitation\", () => {\n const { result } = renderHook(() => useElicitation());\n\n const customElicitation: TamboElicitationRequest = {\n message: \"Custom message\",\n requestedSchema: {\n type: \"object\",\n properties: {\n custom: { type: \"boolean\" },\n },\n },\n };\n\n act(() => {\n result.current.setElicitation(customElicitation);\n });\n\n expect(result.current.elicitation).toEqual(customElicitation);\n });\n\n it(\"allows clearing elicitation state\", () => {\n const { result } = renderHook(() => useElicitation());\n\n const elicitation: TamboElicitationRequest = {\n message: \"Test\",\n requestedSchema: {\n type: \"object\",\n properties: {},\n },\n };\n\n act(() => {\n result.current.setElicitation(elicitation);\n });\n\n expect(result.current.elicitation).not.toBeNull();\n\n act(() => {\n result.current.setElicitation(null);\n });\n\n expect(result.current.elicitation).toBeNull();\n });\n });\n});\n"]}
|