@assistant-ui/react-mcp 0.0.22 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/auth/createOAuthProvider.d.ts +1 -1
  2. package/dist/auth/createOAuthProvider.js.map +1 -1
  3. package/dist/auth/types.d.ts +1 -1
  4. package/dist/index.d.ts +3 -2
  5. package/dist/index.js +2 -1
  6. package/dist/mcp-scope.d.ts +32 -1
  7. package/dist/mcp-scope.d.ts.map +1 -1
  8. package/dist/primitives/elicitation/McpElicitationPrimitiveAccept.d.ts +13 -0
  9. package/dist/primitives/elicitation/McpElicitationPrimitiveAccept.d.ts.map +1 -0
  10. package/dist/primitives/elicitation/McpElicitationPrimitiveAccept.js +106 -0
  11. package/dist/primitives/elicitation/McpElicitationPrimitiveAccept.js.map +1 -0
  12. package/dist/primitives/elicitation/McpElicitationPrimitiveCancel.d.ts +13 -0
  13. package/dist/primitives/elicitation/McpElicitationPrimitiveCancel.d.ts.map +1 -0
  14. package/dist/primitives/elicitation/McpElicitationPrimitiveCancel.js +43 -0
  15. package/dist/primitives/elicitation/McpElicitationPrimitiveCancel.js.map +1 -0
  16. package/dist/primitives/elicitation/McpElicitationPrimitiveDecline.d.ts +13 -0
  17. package/dist/primitives/elicitation/McpElicitationPrimitiveDecline.d.ts.map +1 -0
  18. package/dist/primitives/elicitation/McpElicitationPrimitiveDecline.js +43 -0
  19. package/dist/primitives/elicitation/McpElicitationPrimitiveDecline.js.map +1 -0
  20. package/dist/primitives/elicitation/McpElicitationPrimitiveError.d.ts +13 -0
  21. package/dist/primitives/elicitation/McpElicitationPrimitiveError.d.ts.map +1 -0
  22. package/dist/primitives/elicitation/McpElicitationPrimitiveError.js +38 -0
  23. package/dist/primitives/elicitation/McpElicitationPrimitiveError.js.map +1 -0
  24. package/dist/primitives/elicitation/McpElicitationPrimitiveFields.d.ts +12 -0
  25. package/dist/primitives/elicitation/McpElicitationPrimitiveFields.d.ts.map +1 -0
  26. package/dist/primitives/elicitation/McpElicitationPrimitiveFields.js +53 -0
  27. package/dist/primitives/elicitation/McpElicitationPrimitiveFields.js.map +1 -0
  28. package/dist/primitives/elicitation/McpElicitationPrimitiveItems.d.ts +13 -0
  29. package/dist/primitives/elicitation/McpElicitationPrimitiveItems.d.ts.map +1 -0
  30. package/dist/primitives/elicitation/McpElicitationPrimitiveItems.js +96 -0
  31. package/dist/primitives/elicitation/McpElicitationPrimitiveItems.js.map +1 -0
  32. package/dist/primitives/elicitation/McpElicitationPrimitiveMessage.d.ts +13 -0
  33. package/dist/primitives/elicitation/McpElicitationPrimitiveMessage.d.ts.map +1 -0
  34. package/dist/primitives/elicitation/McpElicitationPrimitiveMessage.js +29 -0
  35. package/dist/primitives/elicitation/McpElicitationPrimitiveMessage.js.map +1 -0
  36. package/dist/primitives/elicitation/McpElicitationPrimitiveRoot.d.ts +13 -0
  37. package/dist/primitives/elicitation/McpElicitationPrimitiveRoot.d.ts.map +1 -0
  38. package/dist/primitives/elicitation/McpElicitationPrimitiveRoot.js +28 -0
  39. package/dist/primitives/elicitation/McpElicitationPrimitiveRoot.js.map +1 -0
  40. package/dist/primitives/elicitation/context.d.ts +21 -0
  41. package/dist/primitives/elicitation/context.d.ts.map +1 -0
  42. package/dist/primitives/elicitation/context.js +21 -0
  43. package/dist/primitives/elicitation/context.js.map +1 -0
  44. package/dist/primitives/elicitation/initialElicitationDraft.d.ts +5 -0
  45. package/dist/primitives/elicitation/initialElicitationDraft.d.ts.map +1 -0
  46. package/dist/primitives/elicitation/initialElicitationDraft.js +27 -0
  47. package/dist/primitives/elicitation/initialElicitationDraft.js.map +1 -0
  48. package/dist/primitives/elicitation/prepareElicitationContent.d.ts +9 -0
  49. package/dist/primitives/elicitation/prepareElicitationContent.d.ts.map +1 -0
  50. package/dist/primitives/elicitation/prepareElicitationContent.js +46 -0
  51. package/dist/primitives/elicitation/prepareElicitationContent.js.map +1 -0
  52. package/dist/primitives/elicitation.d.ts +15 -0
  53. package/dist/primitives/elicitation.d.ts.map +1 -0
  54. package/dist/primitives/elicitation.js +27 -0
  55. package/dist/primitives/elicitation.js.map +1 -0
  56. package/dist/resources/McpManagerResource.d.ts.map +1 -1
  57. package/dist/resources/McpManagerResource.js +17 -3
  58. package/dist/resources/McpManagerResource.js.map +1 -1
  59. package/dist/resources/McpServerResource.d.ts +4 -0
  60. package/dist/resources/McpServerResource.d.ts.map +1 -1
  61. package/dist/resources/McpServerResource.js +153 -42
  62. package/dist/resources/McpServerResource.js.map +1 -1
  63. package/dist/resources/storage/McpLocalStorage.js +1 -1
  64. package/dist/resources/storage/McpLocalStorage.js.map +1 -1
  65. package/dist/resources/validateElicitationContent.d.ts +9 -0
  66. package/dist/resources/validateElicitationContent.d.ts.map +1 -0
  67. package/dist/resources/validateElicitationContent.js +47 -0
  68. package/dist/resources/validateElicitationContent.js.map +1 -0
  69. package/package.json +7 -6
  70. package/src/auth/createOAuthProvider.ts +2 -2
  71. package/src/auth/types.ts +1 -1
  72. package/src/index.ts +4 -0
  73. package/src/mcp-scope.ts +32 -0
  74. package/src/primitives/elicitation/McpElicitationPrimitiveAccept.tsx +48 -0
  75. package/src/primitives/elicitation/McpElicitationPrimitiveCancel.tsx +37 -0
  76. package/src/primitives/elicitation/McpElicitationPrimitiveDecline.tsx +37 -0
  77. package/src/primitives/elicitation/McpElicitationPrimitiveError.tsx +31 -0
  78. package/src/primitives/elicitation/McpElicitationPrimitiveFields.tsx +56 -0
  79. package/src/primitives/elicitation/McpElicitationPrimitiveItems.tsx +58 -0
  80. package/src/primitives/elicitation/McpElicitationPrimitiveMessage.tsx +26 -0
  81. package/src/primitives/elicitation/McpElicitationPrimitiveRoot.tsx +24 -0
  82. package/src/primitives/elicitation/context.tsx +45 -0
  83. package/src/primitives/elicitation/initialElicitationDraft.test.ts +34 -0
  84. package/src/primitives/elicitation/initialElicitationDraft.ts +39 -0
  85. package/src/primitives/elicitation/prepareElicitationContent.test.ts +415 -0
  86. package/src/primitives/elicitation/prepareElicitationContent.ts +116 -0
  87. package/src/primitives/elicitation.ts +14 -0
  88. package/src/resources/McpManagerResource.test.ts +173 -3
  89. package/src/resources/McpManagerResource.ts +37 -3
  90. package/src/resources/McpServerResource.test.ts +735 -4
  91. package/src/resources/McpServerResource.ts +237 -29
  92. package/src/resources/storage/McpLocalStorage.ts +1 -1
  93. package/src/resources/validateElicitationContent.test.ts +123 -0
  94. package/src/resources/validateElicitationContent.ts +79 -0
@@ -1,6 +1,6 @@
1
1
  import { MCPAuthConfig } from "../mcp-scope.js";
2
2
  import { MCPStorage } from "../resources/storage/types.js";
3
- import { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
3
+ import { OAuthClientProvider } from "@modelcontextprotocol/client";
4
4
  //#region src/auth/createOAuthProvider.d.ts
5
5
  declare function decodeServerIdFromState(state: string): string | null;
6
6
  type CreateOAuthProviderOptions = {
@@ -1 +1 @@
1
- {"version":3,"file":"createOAuthProvider.js","names":["OAuthClientProvider","OAuthClientInformationFull","OAuthClientMetadata","OAuthTokens","MCPStorage","MCPAuthConfig","STATE_PREFIX","bytesToBase64Url","bytes","Uint8Array","s","b","String","fromCharCode","btoa","replace","base64UrlToBytes","b64url","padded","repeat","length","bin","atob","out","i","charCodeAt","encodeServerIdInState","serverId","TextEncoder","encode","decodeServerIdFromState","state","startsWith","dot","indexOf","encoded","slice","TextDecoder","fatal","decode","CreateOAuthProviderOptions","config","Extract","type","storage","redirectUri","onAuthorizationUrl","url","URL","createOAuthProvider","opts","Cache","tokens","clientInformation","codeVerifier","cached","loadCache","Promise","persisted","loadAuthState","initial","clientId","ci","client_id","redirect_uris","clientSecret","client_secret","persist","c","next","Parameters","saveAuthState","clientMetadata","client_name","grant_types","response_types","token_endpoint_auth_method","scope","scopes","join","redirectUrl","nonce","crypto","randomUUID","Date","now","Math","random","saveClientInformation","info","saveTokens","redirectToAuthorization","saveCodeVerifier","Error","invalidateCredentials"],"sources":["../../src/auth/createOAuthProvider.ts"],"sourcesContent":["import type { OAuthClientProvider } from \"@modelcontextprotocol/sdk/client/auth.js\";\nimport type {\n OAuthClientInformationFull,\n OAuthClientMetadata,\n OAuthTokens,\n} from \"@modelcontextprotocol/sdk/shared/auth.js\";\nimport type { MCPStorage } from \"../resources/storage/types\";\nimport type { MCPAuthConfig } from \"../mcp-scope\";\n\nconst STATE_PREFIX = \"aui-mcp:\";\n\nfunction bytesToBase64Url(bytes: Uint8Array): string {\n let s = \"\";\n for (const b of bytes) s += String.fromCharCode(b);\n return btoa(s).replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=+$/, \"\");\n}\n\nfunction base64UrlToBytes(b64url: string): Uint8Array {\n const padded =\n b64url.replace(/-/g, \"+\").replace(/_/g, \"/\") +\n \"=\".repeat((4 - (b64url.length % 4)) % 4);\n const bin = atob(padded);\n const out = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);\n return out;\n}\n\nfunction encodeServerIdInState(serverId: string): string {\n const bytes = new TextEncoder().encode(serverId);\n return `${STATE_PREFIX}${bytesToBase64Url(bytes)}`;\n}\n\nexport function decodeServerIdFromState(state: string): string | null {\n if (!state.startsWith(STATE_PREFIX)) return null;\n const dot = state.indexOf(\".\", STATE_PREFIX.length);\n const encoded =\n dot === -1\n ? state.slice(STATE_PREFIX.length)\n : state.slice(STATE_PREFIX.length, dot);\n try {\n return new TextDecoder(\"utf-8\", { fatal: true }).decode(\n base64UrlToBytes(encoded),\n );\n } catch {\n return null;\n }\n}\n\nexport type CreateOAuthProviderOptions = {\n serverId: string;\n /** Must be `auth.type === \"oauth\"`. */\n config: Extract<MCPAuthConfig, { type: \"oauth\" }>;\n storage: MCPStorage;\n redirectUri: string;\n /** Called by the SDK to start the authorization redirect. */\n onAuthorizationUrl: (url: URL) => void;\n};\n\n/**\n * Builds an OAuthClientProvider for the MCP SDK, backed by MCPStorage.\n * Token refresh and DCR are handled by the SDK; this provider only mediates\n * load/save and the redirect step.\n */\nexport function createOAuthProvider(\n opts: CreateOAuthProviderOptions,\n): OAuthClientProvider {\n const { serverId, config, storage, redirectUri, onAuthorizationUrl } = opts;\n\n type Cache = {\n tokens?: OAuthTokens | undefined;\n clientInformation?: OAuthClientInformationFull | undefined;\n codeVerifier?: string | undefined;\n };\n let cached: Cache | null = null;\n\n const loadCache = async (): Promise<Cache> => {\n if (cached) return cached;\n const persisted = await storage.loadAuthState(serverId);\n const initial: Cache = {};\n if (persisted?.tokens) initial.tokens = persisted.tokens;\n if (config.clientId) {\n const ci: OAuthClientInformationFull = {\n client_id: config.clientId,\n redirect_uris: [redirectUri],\n };\n if (config.clientSecret) ci.client_secret = config.clientSecret;\n initial.clientInformation = ci;\n } else if (persisted?.clientInformation) {\n initial.clientInformation = persisted.clientInformation;\n }\n if (persisted?.codeVerifier) initial.codeVerifier = persisted.codeVerifier;\n cached = initial;\n return cached;\n };\n\n const persist = async () => {\n const c = cached;\n if (!c) return;\n const next: Parameters<typeof storage.saveAuthState>[1] = {};\n if (c.tokens) next.tokens = c.tokens;\n if (c.clientInformation) next.clientInformation = c.clientInformation;\n if (c.codeVerifier) next.codeVerifier = c.codeVerifier;\n await storage.saveAuthState(serverId, next);\n };\n\n const clientMetadata: OAuthClientMetadata = {\n client_name: \"assistant-ui\",\n redirect_uris: [redirectUri],\n grant_types: [\"authorization_code\", \"refresh_token\"],\n response_types: [\"code\"],\n token_endpoint_auth_method: \"none\",\n scope: config.scopes?.join(\" \"),\n };\n\n return {\n get redirectUrl() {\n return redirectUri;\n },\n get clientMetadata() {\n return clientMetadata;\n },\n state() {\n // Embed the server id so the callback handler can route it back to the\n // right MCPServerResource without app-level wiring.\n const nonce =\n typeof crypto !== \"undefined\" && \"randomUUID\" in crypto\n ? crypto.randomUUID()\n : `${Date.now()}.${Math.random()}`;\n return `${encodeServerIdInState(serverId)}.${nonce}`;\n },\n async clientInformation() {\n const c = await loadCache();\n return c.clientInformation;\n },\n async saveClientInformation(info) {\n const c = await loadCache();\n c.clientInformation = info as OAuthClientInformationFull;\n await persist();\n },\n async tokens() {\n const c = await loadCache();\n return c.tokens;\n },\n async saveTokens(tokens) {\n const c = await loadCache();\n c.tokens = tokens;\n await persist();\n },\n async redirectToAuthorization(url) {\n onAuthorizationUrl(url);\n },\n async saveCodeVerifier(codeVerifier) {\n const c = await loadCache();\n c.codeVerifier = codeVerifier;\n await persist();\n },\n async codeVerifier() {\n const c = await loadCache();\n if (!c.codeVerifier) {\n throw new Error(\"No code verifier saved for this OAuth flow\");\n }\n return c.codeVerifier;\n },\n async invalidateCredentials(scope) {\n const c = await loadCache();\n if (scope === \"all\" || scope === \"tokens\") delete c.tokens;\n if (scope === \"all\" || scope === \"client\") delete c.clientInformation;\n if (scope === \"all\" || scope === \"verifier\") delete c.codeVerifier;\n await persist();\n },\n };\n}\n"],"mappings":";AASA,MAAMM,eAAe;AAErB,SAASC,iBAAiBC,OAA2B;CACnD,IAAIE,IAAI;CACR,KAAK,MAAMC,KAAKH,OAAOE,KAAKE,OAAOC,aAAaF,CAAC;CACjD,OAAOG,KAAKJ,CAAC,CAAC,CAACK,QAAQ,OAAO,GAAG,CAAC,CAACA,QAAQ,OAAO,GAAG,CAAC,CAACA,QAAQ,OAAO,EAAE;AAC1E;AAEA,SAASC,iBAAiBC,QAA4B;CACpD,MAAMC,SACJD,OAAOF,QAAQ,MAAM,GAAG,CAAC,CAACA,QAAQ,MAAM,GAAG,IAC3C,IAAII,QAAQ,IAAKF,OAAOG,SAAS,KAAM,CAAC;CAC1C,MAAMC,MAAMC,KAAKJ,MAAM;CACvB,MAAMK,MAAM,IAAId,WAAWY,IAAID,MAAM;CACrC,KAAK,IAAII,IAAI,GAAGA,IAAIH,IAAID,QAAQI,KAAKD,IAAIC,KAAKH,IAAII,WAAWD,CAAC;CAC9D,OAAOD;AACT;AAEA,SAASG,sBAAsBC,UAA0B;CACvD,MAAMnB,QAAQ,IAAIoB,YAAY,CAAC,CAACC,OAAOF,QAAQ;CAC/C,OAAO,G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4CAA4C;GAE9D,OAAOzB,EAAEd;EACX;EACA,MAAMwC,sBAAsBjB,OAAO;GACjC,MAAMT,IAAI,MAAMZ,UAAU;GAC1B,IAAIqB,UAAU,SAASA,UAAU,UAAU,OAAOT,EAAEhB;GACpD,IAAIyB,UAAU,SAASA,UAAU,UAAU,OAAOT,EAAEf;GACpD,IAAIwB,UAAU,SAASA,UAAU,YAAY,OAAOT,EAAEd;GACtD,MAAMa,QAAQ;EAChB;CACF;AACF"}
1
+ {"version":3,"file":"createOAuthProvider.js","names":["OAuthClientProvider","OAuthClientInformationFull","OAuthClientMetadata","OAuthTokens","MCPStorage","MCPAuthConfig","STATE_PREFIX","bytesToBase64Url","bytes","Uint8Array","s","b","String","fromCharCode","btoa","replace","base64UrlToBytes","b64url","padded","repeat","length","bin","atob","out","i","charCodeAt","encodeServerIdInState","serverId","TextEncoder","encode","decodeServerIdFromState","state","startsWith","dot","indexOf","encoded","slice","TextDecoder","fatal","decode","CreateOAuthProviderOptions","config","Extract","type","storage","redirectUri","onAuthorizationUrl","url","URL","createOAuthProvider","opts","Cache","tokens","clientInformation","codeVerifier","cached","loadCache","Promise","persisted","loadAuthState","initial","clientId","ci","client_id","redirect_uris","clientSecret","client_secret","persist","c","next","Parameters","saveAuthState","clientMetadata","client_name","grant_types","response_types","token_endpoint_auth_method","scope","scopes","join","redirectUrl","nonce","crypto","randomUUID","Date","now","Math","random","saveClientInformation","info","saveTokens","redirectToAuthorization","saveCodeVerifier","Error","invalidateCredentials"],"sources":["../../src/auth/createOAuthProvider.ts"],"sourcesContent":["import type {\n OAuthClientProvider,\n OAuthClientInformationFull,\n OAuthClientMetadata,\n OAuthTokens,\n} from \"@modelcontextprotocol/client\";\nimport type { MCPStorage } from \"../resources/storage/types\";\nimport type { MCPAuthConfig } from \"../mcp-scope\";\n\nconst STATE_PREFIX = \"aui-mcp:\";\n\nfunction bytesToBase64Url(bytes: Uint8Array): string {\n let s = \"\";\n for (const b of bytes) s += String.fromCharCode(b);\n return btoa(s).replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=+$/, \"\");\n}\n\nfunction base64UrlToBytes(b64url: string): Uint8Array {\n const padded =\n b64url.replace(/-/g, \"+\").replace(/_/g, \"/\") +\n \"=\".repeat((4 - (b64url.length % 4)) % 4);\n const bin = atob(padded);\n const out = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);\n return out;\n}\n\nfunction encodeServerIdInState(serverId: string): string {\n const bytes = new TextEncoder().encode(serverId);\n return `${STATE_PREFIX}${bytesToBase64Url(bytes)}`;\n}\n\nexport function decodeServerIdFromState(state: string): string | null {\n if (!state.startsWith(STATE_PREFIX)) return null;\n const dot = state.indexOf(\".\", STATE_PREFIX.length);\n const encoded =\n dot === -1\n ? state.slice(STATE_PREFIX.length)\n : state.slice(STATE_PREFIX.length, dot);\n try {\n return new TextDecoder(\"utf-8\", { fatal: true }).decode(\n base64UrlToBytes(encoded),\n );\n } catch {\n return null;\n }\n}\n\nexport type CreateOAuthProviderOptions = {\n serverId: string;\n /** Must be `auth.type === \"oauth\"`. */\n config: Extract<MCPAuthConfig, { type: \"oauth\" }>;\n storage: MCPStorage;\n redirectUri: string;\n /** Called by the SDK to start the authorization redirect. */\n onAuthorizationUrl: (url: URL) => void;\n};\n\n/**\n * Builds an OAuthClientProvider for the MCP SDK, backed by MCPStorage.\n * Token refresh and DCR are handled by the SDK; this provider only mediates\n * load/save and the redirect step.\n */\nexport function createOAuthProvider(\n opts: CreateOAuthProviderOptions,\n): OAuthClientProvider {\n const { serverId, config, storage, redirectUri, onAuthorizationUrl } = opts;\n\n type Cache = {\n tokens?: OAuthTokens | undefined;\n clientInformation?: OAuthClientInformationFull | undefined;\n codeVerifier?: string | undefined;\n };\n let cached: Cache | null = null;\n\n const loadCache = async (): Promise<Cache> => {\n if (cached) return cached;\n const persisted = await storage.loadAuthState(serverId);\n const initial: Cache = {};\n if (persisted?.tokens) initial.tokens = persisted.tokens;\n if (config.clientId) {\n const ci: OAuthClientInformationFull = {\n client_id: config.clientId,\n redirect_uris: [redirectUri],\n };\n if (config.clientSecret) ci.client_secret = config.clientSecret;\n initial.clientInformation = ci;\n } else if (persisted?.clientInformation) {\n initial.clientInformation = persisted.clientInformation;\n }\n if (persisted?.codeVerifier) initial.codeVerifier = persisted.codeVerifier;\n cached = initial;\n return cached;\n };\n\n const persist = async () => {\n const c = cached;\n if (!c) return;\n const next: Parameters<typeof storage.saveAuthState>[1] = {};\n if (c.tokens) next.tokens = c.tokens;\n if (c.clientInformation) next.clientInformation = c.clientInformation;\n if (c.codeVerifier) next.codeVerifier = c.codeVerifier;\n await storage.saveAuthState(serverId, next);\n };\n\n const clientMetadata: OAuthClientMetadata = {\n client_name: \"assistant-ui\",\n redirect_uris: [redirectUri],\n grant_types: [\"authorization_code\", \"refresh_token\"],\n response_types: [\"code\"],\n token_endpoint_auth_method: \"none\",\n scope: config.scopes?.join(\" \"),\n };\n\n return {\n get redirectUrl() {\n return redirectUri;\n },\n get clientMetadata() {\n return clientMetadata;\n },\n state() {\n // Embed the server id so the callback handler can route it back to the\n // right MCPServerResource without app-level wiring.\n const nonce =\n typeof crypto !== \"undefined\" && \"randomUUID\" in crypto\n ? crypto.randomUUID()\n : `${Date.now()}.${Math.random()}`;\n return `${encodeServerIdInState(serverId)}.${nonce}`;\n },\n async clientInformation() {\n const c = await loadCache();\n return c.clientInformation;\n },\n async saveClientInformation(info) {\n const c = await loadCache();\n c.clientInformation = info as OAuthClientInformationFull;\n await persist();\n },\n async tokens() {\n const c = await loadCache();\n return c.tokens;\n },\n async saveTokens(tokens) {\n const c = await loadCache();\n c.tokens = tokens;\n await persist();\n },\n async redirectToAuthorization(url) {\n onAuthorizationUrl(url);\n },\n async saveCodeVerifier(codeVerifier) {\n const c = await loadCache();\n c.codeVerifier = codeVerifier;\n await persist();\n },\n async codeVerifier() {\n const c = await loadCache();\n if (!c.codeVerifier) {\n throw new Error(\"No code verifier saved for this OAuth flow\");\n }\n return c.codeVerifier;\n },\n async invalidateCredentials(scope) {\n const c = await loadCache();\n if (scope === \"all\" || scope === \"tokens\") delete c.tokens;\n if (scope === \"all\" || scope === \"client\") delete c.clientInformation;\n if (scope === \"all\" || scope === \"verifier\") delete c.codeVerifier;\n await persist();\n },\n };\n}\n"],"mappings":";AASA,MAAMM,eAAe;AAErB,SAASC,iBAAiBC,OAA2B;CACnD,IAAIE,IAAI;CACR,KAAK,MAAMC,KAAKH,OAAOE,KAAKE,OAAOC,aAAaF,CAAC;CACjD,OAAOG,KAAKJ,CAAC,CAAC,CAACK,QAAQ,OAAO,GAAG,CAAC,CAACA,QAAQ,OAAO,GAAG,CAAC,CAACA,QAAQ,OAAO,EAAE;AAC1E;AAEA,SAASC,iBAAiBC,QAA4B;CACpD,MAAMC,SACJD,OAAOF,QAAQ,MAAM,GAAG,CAAC,CAACA,QAAQ,MAAM,GAAG,IAC3C,IAAII,QAAQ,IAAKF,OAAOG,SAAS,KAAM,CAAC;CAC1C,MAAMC,MAAMC,KAAKJ,MAAM;CACvB,MAAMK,MAAM,IAAId,WAAWY,IAAID,MAAM;CACrC,KAAK,IAAII,IAAI,GAAGA,IAAIH,IAAID,QAAQI,KAAKD,IAAIC,KAAKH,IAAII,WAAWD,CAAC;CAC9D,OAAOD;AACT;AAEA,SAASG,sBAAsBC,UAA0B;CACvD,MAAMnB,QAAQ,IAAIoB,YAAY,CAAC,CAACC,OAAOF,QAAQ;CAC/C,OAAO,GAAGrB,eAAeC,iBAAiBC,KAAK;AACjD;AAEA,SAAgBsB,wBAAwBC,OAA8B;CACpE,IAAI,CAACA,MAAMC,WAAW1B,YAAY,GAAG,OAAO;CAC5C,MAAM2B,MAAMF,MAAMG,QAAQ,KAAK5B,CAAmB;CAClD,MAAM6B,UACJF,QAAQ,KACJF,MAAMK,MAAM9B,CAAmB,IAC/ByB,MAAMK,MAAM9B,GAAqB2B,GAAG;CAC1C,IAAI;EACF,OAAO,IAAII,YAAY,SAAS,EAAEC,OAAO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OAuthClientInformationFull, OAuthTokens } from "@modelcontextprotocol/sdk/shared/auth.js";
1
+ import { OAuthClientInformationFull, OAuthTokens } from "@modelcontextprotocol/client";
2
2
  //#region src/auth/types.d.ts
3
3
  type MCPPersistedAuthState = {
4
4
  tokens?: OAuthTokens;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MCPAuthConfig, MCPConnectionState, MCPConnector, MCPCustomServerRecord, MCPManagerMethods, MCPManagerState, MCPServerKind, MCPServerMethods, MCPServerQuery, MCPServerState, MCPToolInfo } from "./mcp-scope.js";
1
+ import { MCPAuthConfig, MCPConnectionState, MCPConnector, MCPCustomServerRecord, MCPElicitation, MCPElicitationResponse, MCPManagerMethods, MCPManagerState, MCPResponseCacheConfig, MCPServerKind, MCPServerMethods, MCPServerQuery, MCPServerState, MCPToolInfo } from "./mcp-scope.js";
2
2
  import { MCPPersistedAuthState } from "./auth/types.js";
3
3
  import { MCPStorage, MCPStorageElement } from "./resources/storage/types.js";
4
4
  import { defineConnector } from "./connector.js";
@@ -14,4 +14,5 @@ import { McpCustomStorage } from "./resources/storage/McpCustomStorage.js";
14
14
  import { manager_d_exports } from "./primitives/manager.js";
15
15
  import { server_d_exports } from "./primitives/server.js";
16
16
  import { addForm_d_exports } from "./primitives/addForm.js";
17
- export { type MCPAuthConfig, type MCPConnectionState, type MCPConnector, type MCPCustomServerRecord, type MCPManagerMethods, type MCPManagerState, type MCPPersistedAuthState, type MCPServerKind, type MCPServerMethods, type MCPServerQuery, type MCPServerState, type MCPStorage, type MCPStorageElement, type MCPToolInfo, addForm_d_exports as McpAddFormPrimitive, McpConnectorByIndexProvider, McpCustomServerByIndexProvider, McpCustomStorage, McpLocalStorage, type McpLocalStorageOptions, manager_d_exports as McpManagerPrimitive, McpManagerResource, type McpManagerResourceProps, McpMemoryStorage, McpOAuthCallback, McpServerByIdProvider, server_d_exports as McpServerPrimitive, McpServerResource, type McpServerResourceProps, type UseMcpOAuthCallbackOptions, type UseMcpOAuthCallbackResult, defineConnector, useMcpOAuthCallback };
17
+ import { elicitation_d_exports } from "./primitives/elicitation.js";
18
+ export { type MCPAuthConfig, type MCPConnectionState, type MCPConnector, type MCPCustomServerRecord, type MCPElicitation, type MCPElicitationResponse, type MCPManagerMethods, type MCPManagerState, type MCPPersistedAuthState, type MCPResponseCacheConfig, type MCPServerKind, type MCPServerMethods, type MCPServerQuery, type MCPServerState, type MCPStorage, type MCPStorageElement, type MCPToolInfo, addForm_d_exports as McpAddFormPrimitive, McpConnectorByIndexProvider, McpCustomServerByIndexProvider, McpCustomStorage, elicitation_d_exports as McpElicitationPrimitive, McpLocalStorage, type McpLocalStorageOptions, manager_d_exports as McpManagerPrimitive, McpManagerResource, type McpManagerResourceProps, McpMemoryStorage, McpOAuthCallback, McpServerByIdProvider, server_d_exports as McpServerPrimitive, McpServerResource, type McpServerResourceProps, type UseMcpOAuthCallbackOptions, type UseMcpOAuthCallbackResult, defineConnector, useMcpOAuthCallback };
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@ import { McpCustomServerByIndexProvider } from "./context/McpCustomServerByIndex
9
9
  import { manager_exports } from "./primitives/manager.js";
10
10
  import { server_exports } from "./primitives/server.js";
11
11
  import { addForm_exports } from "./primitives/addForm.js";
12
+ import { elicitation_exports } from "./primitives/elicitation.js";
12
13
  import { McpServerByIdProvider } from "./context/McpServerByIdProvider.js";
13
14
  import { McpOAuthCallback, useMcpOAuthCallback } from "./hooks/useMcpOAuthCallback.js";
14
- export { addForm_exports as McpAddFormPrimitive, McpConnectorByIndexProvider, McpCustomServerByIndexProvider, McpCustomStorage, McpLocalStorage, manager_exports as McpManagerPrimitive, McpManagerResource, McpMemoryStorage, McpOAuthCallback, McpServerByIdProvider, server_exports as McpServerPrimitive, McpServerResource, defineConnector, useMcpOAuthCallback };
15
+ export { addForm_exports as McpAddFormPrimitive, McpConnectorByIndexProvider, McpCustomServerByIndexProvider, McpCustomStorage, elicitation_exports as McpElicitationPrimitive, McpLocalStorage, manager_exports as McpManagerPrimitive, McpManagerResource, McpMemoryStorage, McpOAuthCallback, McpServerByIdProvider, server_exports as McpServerPrimitive, McpServerResource, defineConnector, useMcpOAuthCallback };
@@ -14,6 +14,9 @@ type MCPAuthConfig = {
14
14
  clientId?: string | undefined;
15
15
  clientSecret?: string | undefined;
16
16
  };
17
+ type MCPResponseCacheConfig = {
18
+ readonly defaultTtlMs?: number;
19
+ };
17
20
  type MCPConnector = {
18
21
  id: string;
19
22
  name: string;
@@ -21,6 +24,8 @@ type MCPConnector = {
21
24
  icon?: string | undefined;
22
25
  auth: MCPAuthConfig;
23
26
  connectionTimeout?: number | undefined;
27
+ readonly cache?: MCPResponseCacheConfig | undefined;
28
+ readonly elicitation?: boolean | undefined;
24
29
  };
25
30
  type MCPCustomServerRecord = {
26
31
  id: string;
@@ -28,6 +33,8 @@ type MCPCustomServerRecord = {
28
33
  url: string;
29
34
  auth: MCPAuthConfig;
30
35
  connectionTimeout?: number | undefined;
36
+ readonly cache?: MCPResponseCacheConfig | undefined;
37
+ readonly elicitation?: boolean | undefined;
31
38
  createdAt: number;
32
39
  };
33
40
  type MCPServerKind = "connector" | "custom";
@@ -37,6 +44,23 @@ type MCPToolInfo = {
37
44
  description?: string | undefined;
38
45
  inputSchema: unknown;
39
46
  };
47
+ type MCPElicitation = {
48
+ readonly id: string;
49
+ readonly message: string;
50
+ readonly requestedSchema: unknown;
51
+ readonly error?: {
52
+ readonly message: string;
53
+ readonly properties?: readonly string[] | undefined;
54
+ } | undefined;
55
+ };
56
+ type MCPElicitationResponse = {
57
+ action: "accept";
58
+ content: Record<string, unknown>;
59
+ } | {
60
+ action: "decline";
61
+ } | {
62
+ action: "cancel";
63
+ };
40
64
  type MCPServerState = {
41
65
  id: string;
42
66
  kind: MCPServerKind;
@@ -49,6 +73,7 @@ type MCPServerState = {
49
73
  } | null;
50
74
  tools: MCPToolInfo[];
51
75
  authorizationUrl: string | null;
76
+ readonly pendingElicitations: readonly MCPElicitation[];
52
77
  };
53
78
  type MCPManagerState = {
54
79
  servers: MCPServerState[];
@@ -70,6 +95,10 @@ type MCPServerMethods = {
70
95
  readResource: (uri: string) => Promise<unknown>;
71
96
  /** OAuth only: pass full callback URL (e.g. window.location.href) */
72
97
  completeAuth: (callbackUrl: string) => Promise<void>;
98
+ answerElicitation(id: string, response: MCPElicitationResponse): readonly {
99
+ property: string;
100
+ message: string;
101
+ }[] | undefined;
73
102
  };
74
103
  type MCPServerQuery = {
75
104
  id: string;
@@ -97,6 +126,8 @@ type MCPManagerMethods = {
97
126
  url: string;
98
127
  auth: MCPAuthConfig;
99
128
  connectionTimeout?: number | undefined;
129
+ readonly cache?: MCPResponseCacheConfig | undefined;
130
+ readonly elicitation?: boolean | undefined;
100
131
  }) => Promise<string>;
101
132
  removeServer: (id: string) => Promise<void>;
102
133
  };
@@ -115,5 +146,5 @@ declare module "@assistant-ui/store" {
115
146
  }
116
147
  }
117
148
  //#endregion
118
- export { MCPAuthConfig, MCPConnectionState, MCPConnector, MCPCustomServerRecord, MCPManagerMethods, MCPManagerState, MCPServerKind, MCPServerMethods, MCPServerQuery, MCPServerState, MCPToolInfo };
149
+ export { MCPAuthConfig, MCPConnectionState, MCPConnector, MCPCustomServerRecord, MCPElicitation, MCPElicitationResponse, MCPManagerMethods, MCPManagerState, MCPResponseCacheConfig, MCPServerKind, MCPServerMethods, MCPServerQuery, MCPServerState, MCPToolInfo };
119
150
  //# sourceMappingURL=mcp-scope.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-scope.d.ts","names":[],"sources":["../src/mcp-scope.ts"],"mappings":";;KAEY;EACN;;EACA;EAAgB;;EAEhB;EACA;EACA;EACA;EACA;EACA;EACA;;KAGM;EACV;EACA;EACA;EACA;EACA,MAAM;EACN;;KAGU;EACV;EACA;EACA;EACA,MAAM;EACN;EACA;;KAGU;KAEA;KAQA;EACV;EACA;EACA;;KAGU;EACV;EACA,MAAM;EACN;EACA;EACA;EACA,iBAAiB;EACjB;IAAa;;EACb,OAAO;EACP;;KAGU;EACV,SAAS;EACT,YAAY;EACZ,eAAe;EACf;;KAGU;EACV,gBAAgB;EAChB,eAAe;EACf,kBAAkB;EAClB,cAAc;EACd,WAAW,cAAc,kBAAkB;;EAE3C,gBAAgB;IAAW;QAAkC;;EAE7D,eAAe,gBAAgB;;EAE/B,eAAe,wBAAwB;;KAG7B;EACN;;EACA;EAAmB;;EACnB;EAAgB;;KAEV;EACV,gBAAgB;;EAEhB,SAAS,OAAO,mBAAmB;;EAEnC,YAAY;IAAS;QAAoB;;EAEzC,eAAe;IAAS;QAAoB;EAC5C,kBAAkB;IAChB;IACA;IACA,MAAM;IACN;QACI;EACN,eAAe,eAAe;;;YAIpB;IACR;MACE,SAAS;;IAEX;MACE,SAAS;MACT;QAAQ;QAAe,OAAO"}
1
+ {"version":3,"file":"mcp-scope.d.ts","names":[],"sources":["../src/mcp-scope.ts"],"mappings":";;KAEY;EACN;;EACA;EAAgB;;EAEhB;EACA;EACA;EACA;EACA;EACA;EACA;;KAGM;WACD;;KAGC;EACV;EACA;EACA;EACA;EACA,MAAM;EACN;WACS,QAAQ;WACR;;KAGC;EACV;EACA;EACA;EACA,MAAM;EACN;WACS,QAAQ;WACR;EACT;;KAGU;KAEA;KAQA;EACV;EACA;EACA;;KAGU;WACD;WACA;WACA;WACA;aAEM;aACA;;;KAKL;EACN;EAAkB,SAAS;;EAC3B;;EACA;;KAEM;EACV;EACA,MAAM;EACN;EACA;EACA;EACA,iBAAiB;EACjB;IAAa;;EACb,OAAO;EACP;WACS,8BAA8B;;KAG7B;EACV,SAAS;EACT,YAAY;EACZ,eAAe;EACf;;KAGU;EACV,gBAAgB;EAChB,eAAe;EACf,kBAAkB;EAClB,cAAc;EACd,WAAW,cAAc,kBAAkB;;EAE3C,gBAAgB;IAAW;QAAkC;;EAE7D,eAAe,gBAAgB;;EAE/B,eAAe,wBAAwB;EACvC,kBACE,YACA,UAAU;IACE;IAAkB;;;KAGtB;EACN;;EACA;EAAmB;;EACnB;EAAgB;;KAEV;EACV,gBAAgB;;EAEhB,SAAS,OAAO,mBAAmB;;EAEnC,YAAY;IAAS;QAAoB;;EAEzC,eAAe;IAAS;QAAoB;EAC5C,kBAAkB;IAChB;IACA;IACA,MAAM;IACN;aACS,QAAQ;aACR;QACL;EACN,eAAe,eAAe;;;YAIpB;IACR;MACE,SAAS;;IAEX;MACE,SAAS;MACT;QAAQ;QAAe,OAAO"}
@@ -0,0 +1,13 @@
1
+ import { ComponentPropsWithoutRef, ComponentRef } from "react";
2
+ import { Primitive } from "@radix-ui/react-primitive";
3
+ //#region src/primitives/elicitation/McpElicitationPrimitiveAccept.d.ts
4
+ declare namespace McpElicitationPrimitiveAccept {
5
+ type Element = ComponentRef<typeof Primitive.button>;
6
+ type Props = ComponentPropsWithoutRef<typeof Primitive.button>;
7
+ }
8
+ declare const McpElicitationPrimitiveAccept: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
9
+ asChild?: boolean;
10
+ }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
11
+ //#endregion
12
+ export { McpElicitationPrimitiveAccept };
13
+ //# sourceMappingURL=McpElicitationPrimitiveAccept.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpElicitationPrimitiveAccept.d.ts","names":[],"sources":["../../../src/primitives/elicitation/McpElicitationPrimitiveAccept.tsx"],"mappings":";;;kBAUiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;cAGnD,+CAA6B,0BAAA,qBAAA,gBAAA,qCAAA,qBAAA;;4BA8BxC,cAAA"}
@@ -0,0 +1,106 @@
1
+ import { useElicitationContext } from "./context.js";
2
+ import { prepareElicitationContent } from "./prepareElicitationContent.js";
3
+ import { useAui } from "@assistant-ui/store";
4
+ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
5
+ import { forwardRef } from "@assistant-ui/tap/react-shim";
6
+ import { Primitive } from "@radix-ui/react-primitive";
7
+ import { jsx } from "react/jsx-runtime";
8
+ //#region src/primitives/elicitation/McpElicitationPrimitiveAccept.tsx
9
+ const McpElicitationPrimitiveAccept = forwardRef((props, ref) => {
10
+ const $ = c(30);
11
+ const { elicitation, draft } = useElicitationContext();
12
+ const aui = useAui();
13
+ let T0;
14
+ let content;
15
+ let hasInvalid;
16
+ let hasMissingRequired;
17
+ let t0;
18
+ let t1;
19
+ let t2;
20
+ let t3;
21
+ let t4;
22
+ let t5;
23
+ if ($[0] !== draft || $[1] !== elicitation.requestedSchema || $[2] !== props || $[3] !== ref) {
24
+ const { content: t6, missingRequired, invalid } = prepareElicitationContent(elicitation.requestedSchema, draft);
25
+ content = t6;
26
+ hasMissingRequired = missingRequired.length > 0;
27
+ hasInvalid = invalid.length > 0;
28
+ T0 = Primitive.button;
29
+ t0 = props;
30
+ t1 = "button";
31
+ t2 = ref;
32
+ t3 = props.disabled || hasMissingRequired || hasInvalid;
33
+ t4 = hasMissingRequired ? "" : void 0;
34
+ t5 = hasInvalid ? invalid.join(",") : void 0;
35
+ $[0] = draft;
36
+ $[1] = elicitation.requestedSchema;
37
+ $[2] = props;
38
+ $[3] = ref;
39
+ $[4] = T0;
40
+ $[5] = content;
41
+ $[6] = hasInvalid;
42
+ $[7] = hasMissingRequired;
43
+ $[8] = t0;
44
+ $[9] = t1;
45
+ $[10] = t2;
46
+ $[11] = t3;
47
+ $[12] = t4;
48
+ $[13] = t5;
49
+ } else {
50
+ T0 = $[4];
51
+ content = $[5];
52
+ hasInvalid = $[6];
53
+ hasMissingRequired = $[7];
54
+ t0 = $[8];
55
+ t1 = $[9];
56
+ t2 = $[10];
57
+ t3 = $[11];
58
+ t4 = $[12];
59
+ t5 = $[13];
60
+ }
61
+ let t6;
62
+ if ($[14] !== aui || $[15] !== content || $[16] !== elicitation.id || $[17] !== hasInvalid || $[18] !== hasMissingRequired || $[19] !== props) {
63
+ t6 = (event) => {
64
+ props.onClick?.(event);
65
+ if (event.defaultPrevented || hasMissingRequired || hasInvalid) return;
66
+ aui.mcpServer.answerElicitation(elicitation.id, {
67
+ action: "accept",
68
+ content
69
+ });
70
+ };
71
+ $[14] = aui;
72
+ $[15] = content;
73
+ $[16] = elicitation.id;
74
+ $[17] = hasInvalid;
75
+ $[18] = hasMissingRequired;
76
+ $[19] = props;
77
+ $[20] = t6;
78
+ } else t6 = $[20];
79
+ let t7;
80
+ if ($[21] !== T0 || $[22] !== t0 || $[23] !== t1 || $[24] !== t2 || $[25] !== t3 || $[26] !== t4 || $[27] !== t5 || $[28] !== t6) {
81
+ t7 = /* @__PURE__ */ jsx(T0, {
82
+ ...t0,
83
+ type: t1,
84
+ ref: t2,
85
+ disabled: t3,
86
+ "data-missing-required": t4,
87
+ "data-invalid": t5,
88
+ onClick: t6
89
+ });
90
+ $[21] = T0;
91
+ $[22] = t0;
92
+ $[23] = t1;
93
+ $[24] = t2;
94
+ $[25] = t3;
95
+ $[26] = t4;
96
+ $[27] = t5;
97
+ $[28] = t6;
98
+ $[29] = t7;
99
+ } else t7 = $[29];
100
+ return t7;
101
+ });
102
+ McpElicitationPrimitiveAccept.displayName = "McpElicitationPrimitive.Accept";
103
+ //#endregion
104
+ export { McpElicitationPrimitiveAccept };
105
+
106
+ //# sourceMappingURL=McpElicitationPrimitiveAccept.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpElicitationPrimitiveAccept.js","names":["ComponentPropsWithoutRef","ComponentRef","forwardRef","Primitive","useAui","useElicitationContext","prepareElicitationContent","McpElicitationPrimitiveAccept","Element","button","Props","props","ref","$","_c","elicitation","draft","aui","T0","content","hasInvalid","hasMissingRequired","t0","t1","t2","t3","t4","t5","requestedSchema","t6","missingRequired","invalid","length","disabled","undefined","join","id","event","onClick","defaultPrevented","mcpServer","answerElicitation","action","t7","displayName"],"sources":["../../../src/primitives/elicitation/McpElicitationPrimitiveAccept.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useElicitationContext } from \"./context\";\nimport { prepareElicitationContent } from \"./prepareElicitationContent\";\n\nexport namespace McpElicitationPrimitiveAccept {\n export type Element = ComponentRef<typeof Primitive.button>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.button>;\n}\n\nexport const McpElicitationPrimitiveAccept = forwardRef<\n McpElicitationPrimitiveAccept.Element,\n McpElicitationPrimitiveAccept.Props\n>((props, ref) => {\n const { elicitation, draft } = useElicitationContext();\n const aui = useAui();\n const { content, missingRequired, invalid } = prepareElicitationContent(\n elicitation.requestedSchema,\n draft,\n );\n const hasMissingRequired = missingRequired.length > 0;\n const hasInvalid = invalid.length > 0;\n return (\n <Primitive.button\n {...props}\n type=\"button\"\n ref={ref}\n disabled={props.disabled || hasMissingRequired || hasInvalid}\n data-missing-required={hasMissingRequired ? \"\" : undefined}\n data-invalid={hasInvalid ? invalid.join(\",\") : undefined}\n onClick={(event) => {\n props.onClick?.(event);\n if (event.defaultPrevented || hasMissingRequired || hasInvalid) return;\n aui.mcpServer.answerElicitation(elicitation.id, {\n action: \"accept\",\n content,\n });\n }}\n />\n );\n});\n\nMcpElicitationPrimitiveAccept.displayName = \"McpElicitationPrimitive.Accept\";\n"],"mappings":";;;;;;;;AAeA,MAAaO,gCAAgCL,YAG3CS,OAAAC,QAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CACA,MAAA,EAAAC,aAAAC,UAA+BX,sBAAsB;CACrD,MAAAY,MAAYb,OAAO;CAAE,IAAAc;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAd,EAAA,OAAAG,SAAAH,EAAA,OAAAE,YAAAa,mBAAAf,EAAA,OAAAF,SAAAE,EAAA,OAAAD,KAAA;EACrB,MAAA,EAAAO,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A,MAAAM;EAAAN,EAAA,MAAAE,YAAAqB;EAAAvB,EAAA,MAAAO;EAAAP,EAAA,MAAAQ;EAAAR,EAAA,MAAAF;EAAAE,EAAA,MAAAgB;CAAA,OAAAA,KAAAhB,EAAA;CAAA,IAAA8B;CAAA,IAAA9B,EAAA,QAAAK,MAAAL,EAAA,QAAAS,MAAAT,EAAA,QAAAU,MAAAV,EAAA,QAAAW,MAAAX,EAAA,QAAAY,MAAAZ,EAAA,QAAAa,MAAAb,EAAA,QAAAc,MAAAd,EAAA,QAAAgB,IAAA;EAdHc,KAAA,oBAAC,IAAD;GAAiB,GACXhC;GACC,MAAAY;GACAX,KAAAA;GACK,UAAAa;GACa,yBAAAC;GACT,gBAAAC;GACL,SAAAE;EAOR,CAAA;EACDhB,EAAA,MAAAK;EAAAL,EAAA,MAAAS;EAAAT,EAAA,MAAAU;EAAAV,EAAA,MAAAW;EAAAX,EAAA,MAAAY;EAAAZ,EAAA,MAAAa;EAAAb,EAAA,MAAAc;EAAAd,EAAA,MAAAgB;EAAAhB,EAAA,MAAA8B;CAAA,OAAAA,KAAA9B,EAAA;CAAA,OAfF8B;AAeE,CAEL;AAEDpC,8BAA8BqC,cAAc"}
@@ -0,0 +1,13 @@
1
+ import { ComponentPropsWithoutRef, ComponentRef } from "react";
2
+ import { Primitive } from "@radix-ui/react-primitive";
3
+ //#region src/primitives/elicitation/McpElicitationPrimitiveCancel.d.ts
4
+ declare namespace McpElicitationPrimitiveCancel {
5
+ type Element = ComponentRef<typeof Primitive.button>;
6
+ type Props = ComponentPropsWithoutRef<typeof Primitive.button>;
7
+ }
8
+ declare const McpElicitationPrimitiveCancel: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
9
+ asChild?: boolean;
10
+ }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
11
+ //#endregion
12
+ export { McpElicitationPrimitiveCancel };
13
+ //# sourceMappingURL=McpElicitationPrimitiveCancel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpElicitationPrimitiveCancel.d.ts","names":[],"sources":["../../../src/primitives/elicitation/McpElicitationPrimitiveCancel.tsx"],"mappings":";;;kBASiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;cAGnD,+CAA6B,0BAAA,qBAAA,gBAAA,qCAAA,qBAAA;;4BAoBxC,cAAA"}
@@ -0,0 +1,43 @@
1
+ import { useMcpElicitation } from "./context.js";
2
+ import { useAui } from "@assistant-ui/store";
3
+ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
4
+ import { forwardRef } from "@assistant-ui/tap/react-shim";
5
+ import { Primitive } from "@radix-ui/react-primitive";
6
+ import { jsx } from "react/jsx-runtime";
7
+ //#region src/primitives/elicitation/McpElicitationPrimitiveCancel.tsx
8
+ const McpElicitationPrimitiveCancel = forwardRef((props, ref) => {
9
+ const $ = c(8);
10
+ const elicitation = useMcpElicitation();
11
+ const aui = useAui();
12
+ let t0;
13
+ if ($[0] !== aui || $[1] !== elicitation || $[2] !== props) {
14
+ t0 = (event) => {
15
+ props.onClick?.(event);
16
+ if (event.defaultPrevented) return;
17
+ aui.mcpServer.answerElicitation(elicitation.id, { action: "cancel" });
18
+ };
19
+ $[0] = aui;
20
+ $[1] = elicitation;
21
+ $[2] = props;
22
+ $[3] = t0;
23
+ } else t0 = $[3];
24
+ let t1;
25
+ if ($[4] !== props || $[5] !== ref || $[6] !== t0) {
26
+ t1 = /* @__PURE__ */ jsx(Primitive.button, {
27
+ ...props,
28
+ type: "button",
29
+ ref,
30
+ onClick: t0
31
+ });
32
+ $[4] = props;
33
+ $[5] = ref;
34
+ $[6] = t0;
35
+ $[7] = t1;
36
+ } else t1 = $[7];
37
+ return t1;
38
+ });
39
+ McpElicitationPrimitiveCancel.displayName = "McpElicitationPrimitive.Cancel";
40
+ //#endregion
41
+ export { McpElicitationPrimitiveCancel };
42
+
43
+ //# sourceMappingURL=McpElicitationPrimitiveCancel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpElicitationPrimitiveCancel.js","names":["ComponentPropsWithoutRef","ComponentRef","forwardRef","Primitive","useAui","useMcpElicitation","McpElicitationPrimitiveCancel","Element","button","Props","props","ref","$","_c","elicitation","aui","t0","event","onClick","defaultPrevented","mcpServer","answerElicitation","id","action","t1","displayName"],"sources":["../../../src/primitives/elicitation/McpElicitationPrimitiveCancel.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useMcpElicitation } from \"./context\";\n\nexport namespace McpElicitationPrimitiveCancel {\n export type Element = ComponentRef<typeof Primitive.button>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.button>;\n}\n\nexport const McpElicitationPrimitiveCancel = forwardRef<\n McpElicitationPrimitiveCancel.Element,\n McpElicitationPrimitiveCancel.Props\n>((props, ref) => {\n const elicitation = useMcpElicitation();\n const aui = useAui();\n return (\n <Primitive.button\n {...props}\n type=\"button\"\n ref={ref}\n onClick={(event) => {\n props.onClick?.(event);\n if (event.defaultPrevented) return;\n aui.mcpServer.answerElicitation(elicitation.id, {\n action: \"cancel\",\n });\n }}\n />\n );\n});\n\nMcpElicitationPrimitiveCancel.displayName = \"McpElicitationPrimitive.Cancel\";\n"],"mappings":";;;;;;;AAcA,MAAaM,gCAAgCJ,YAG3CQ,OAAAC,QAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACA,MAAAC,cAAoBT,kBAAkB;CACtC,MAAAU,MAAYX,OAAO;CAAE,IAAAY;CAAA,IAAAJ,EAAA,OAAAG,OAAAH,EAAA,OAAAE,eAAAF,EAAA,OAAAF,OAAA;EAMRM,MAAAC,UAAA;GACPP,MAAKQ,UAAWD,KAAK;GACrB,IAAIA,MAAKE,kBAAiB;GAC1BJ,IAAGK,UAAUC,kBAAmBP,YAAWQ,IAAK,EAAAC,QACtC,SACV,CAAC;EAAC;EACHX,EAAA,KAAAG;EAAAH,EAAA,KAAAE;EAAAF,EAAA,KAAAF;EAAAE,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAY;CAAA,IAAAZ,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAI,IAAA;EAVHQ,KAAA,oBAAA,UAAA,QAAA;GAAA,GACMd;GACC,MAAA;GACAC;GACI,SAAAK;EAMR,CAAA;EACDJ,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAI;EAAAJ,EAAA,KAAAY;CAAA,OAAAA,KAAAZ,EAAA;CAAA,OAXFY;AAWE,CAEL;AAEDlB,8BAA8BmB,cAAc"}
@@ -0,0 +1,13 @@
1
+ import { ComponentPropsWithoutRef, ComponentRef } from "react";
2
+ import { Primitive } from "@radix-ui/react-primitive";
3
+ //#region src/primitives/elicitation/McpElicitationPrimitiveDecline.d.ts
4
+ declare namespace McpElicitationPrimitiveDecline {
5
+ type Element = ComponentRef<typeof Primitive.button>;
6
+ type Props = ComponentPropsWithoutRef<typeof Primitive.button>;
7
+ }
8
+ declare const McpElicitationPrimitiveDecline: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
9
+ asChild?: boolean;
10
+ }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
11
+ //#endregion
12
+ export { McpElicitationPrimitiveDecline };
13
+ //# sourceMappingURL=McpElicitationPrimitiveDecline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpElicitationPrimitiveDecline.d.ts","names":[],"sources":["../../../src/primitives/elicitation/McpElicitationPrimitiveDecline.tsx"],"mappings":";;;kBASiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;cAGnD,gDAA8B,0BAAA,qBAAA,gBAAA,qCAAA,qBAAA;;4BAoBzC,cAAA"}
@@ -0,0 +1,43 @@
1
+ import { useMcpElicitation } from "./context.js";
2
+ import { useAui } from "@assistant-ui/store";
3
+ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
4
+ import { forwardRef } from "@assistant-ui/tap/react-shim";
5
+ import { Primitive } from "@radix-ui/react-primitive";
6
+ import { jsx } from "react/jsx-runtime";
7
+ //#region src/primitives/elicitation/McpElicitationPrimitiveDecline.tsx
8
+ const McpElicitationPrimitiveDecline = forwardRef((props, ref) => {
9
+ const $ = c(8);
10
+ const elicitation = useMcpElicitation();
11
+ const aui = useAui();
12
+ let t0;
13
+ if ($[0] !== aui || $[1] !== elicitation || $[2] !== props) {
14
+ t0 = (event) => {
15
+ props.onClick?.(event);
16
+ if (event.defaultPrevented) return;
17
+ aui.mcpServer.answerElicitation(elicitation.id, { action: "decline" });
18
+ };
19
+ $[0] = aui;
20
+ $[1] = elicitation;
21
+ $[2] = props;
22
+ $[3] = t0;
23
+ } else t0 = $[3];
24
+ let t1;
25
+ if ($[4] !== props || $[5] !== ref || $[6] !== t0) {
26
+ t1 = /* @__PURE__ */ jsx(Primitive.button, {
27
+ ...props,
28
+ type: "button",
29
+ ref,
30
+ onClick: t0
31
+ });
32
+ $[4] = props;
33
+ $[5] = ref;
34
+ $[6] = t0;
35
+ $[7] = t1;
36
+ } else t1 = $[7];
37
+ return t1;
38
+ });
39
+ McpElicitationPrimitiveDecline.displayName = "McpElicitationPrimitive.Decline";
40
+ //#endregion
41
+ export { McpElicitationPrimitiveDecline };
42
+
43
+ //# sourceMappingURL=McpElicitationPrimitiveDecline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpElicitationPrimitiveDecline.js","names":["ComponentPropsWithoutRef","ComponentRef","forwardRef","Primitive","useAui","useMcpElicitation","McpElicitationPrimitiveDecline","Element","button","Props","props","ref","$","_c","elicitation","aui","t0","event","onClick","defaultPrevented","mcpServer","answerElicitation","id","action","t1","displayName"],"sources":["../../../src/primitives/elicitation/McpElicitationPrimitiveDecline.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useMcpElicitation } from \"./context\";\n\nexport namespace McpElicitationPrimitiveDecline {\n export type Element = ComponentRef<typeof Primitive.button>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.button>;\n}\n\nexport const McpElicitationPrimitiveDecline = forwardRef<\n McpElicitationPrimitiveDecline.Element,\n McpElicitationPrimitiveDecline.Props\n>((props, ref) => {\n const elicitation = useMcpElicitation();\n const aui = useAui();\n return (\n <Primitive.button\n {...props}\n type=\"button\"\n ref={ref}\n onClick={(event) => {\n props.onClick?.(event);\n if (event.defaultPrevented) return;\n aui.mcpServer.answerElicitation(elicitation.id, {\n action: \"decline\",\n });\n }}\n />\n );\n});\n\nMcpElicitationPrimitiveDecline.displayName = \"McpElicitationPrimitive.Decline\";\n"],"mappings":";;;;;;;AAcA,MAAaM,iCAAiCJ,YAG5CQ,OAAAC,QAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACA,MAAAC,cAAoBT,kBAAkB;CACtC,MAAAU,MAAYX,OAAO;CAAE,IAAAY;CAAA,IAAAJ,EAAA,OAAAG,OAAAH,EAAA,OAAAE,eAAAF,EAAA,OAAAF,OAAA;EAMRM,MAAAC,UAAA;GACPP,MAAKQ,UAAWD,KAAK;GACrB,IAAIA,MAAKE,kBAAiB;GAC1BJ,IAAGK,UAAUC,kBAAmBP,YAAWQ,IAAK,EAAAC,QACtC,UACV,CAAC;EAAC;EACHX,EAAA,KAAAG;EAAAH,EAAA,KAAAE;EAAAF,EAAA,KAAAF;EAAAE,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAY;CAAA,IAAAZ,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAI,IAAA;EAVHQ,KAAA,oBAAA,UAAA,QAAA;GAAA,GACMd;GACC,MAAA;GACAC;GACI,SAAAK;EAMR,CAAA;EACDJ,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAI;EAAAJ,EAAA,KAAAY;CAAA,OAAAA,KAAAZ,EAAA;CAAA,OAXFY;AAWE,CAEL;AAEDlB,+BAA+BmB,cAAc"}
@@ -0,0 +1,13 @@
1
+ import { ComponentPropsWithoutRef, ComponentRef } from "react";
2
+ import { Primitive } from "@radix-ui/react-primitive";
3
+ //#region src/primitives/elicitation/McpElicitationPrimitiveError.d.ts
4
+ declare namespace McpElicitationPrimitiveError {
5
+ type Element = ComponentRef<typeof Primitive.div>;
6
+ type Props = ComponentPropsWithoutRef<typeof Primitive.div>;
7
+ }
8
+ declare const McpElicitationPrimitiveError: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
9
+ asChild?: boolean;
10
+ }, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
11
+ //#endregion
12
+ export { McpElicitationPrimitiveError };
13
+ //# sourceMappingURL=McpElicitationPrimitiveError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpElicitationPrimitiveError.d.ts","names":[],"sources":["../../../src/primitives/elicitation/McpElicitationPrimitiveError.tsx"],"mappings":";;;kBAQiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;cAGnD,8CAA4B,0BAAA,qBAAA,gBAAA,kCAAA,eAAA;;4BAevC,cAAA"}
@@ -0,0 +1,38 @@
1
+ import { useMcpElicitation } from "./context.js";
2
+ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
3
+ import { forwardRef } from "@assistant-ui/tap/react-shim";
4
+ import { Primitive } from "@radix-ui/react-primitive";
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region src/primitives/elicitation/McpElicitationPrimitiveError.tsx
7
+ const McpElicitationPrimitiveError = forwardRef((props, ref) => {
8
+ const $ = c(7);
9
+ const error = useMcpElicitation().error;
10
+ if (!error) return null;
11
+ let t0;
12
+ if ($[0] !== error.properties) {
13
+ t0 = error.properties?.join(",");
14
+ $[0] = error.properties;
15
+ $[1] = t0;
16
+ } else t0 = $[1];
17
+ const t1 = props.children ?? error.message;
18
+ let t2;
19
+ if ($[2] !== props || $[3] !== ref || $[4] !== t0 || $[5] !== t1) {
20
+ t2 = /* @__PURE__ */ jsx(Primitive.div, {
21
+ ...props,
22
+ ref,
23
+ "data-properties": t0,
24
+ children: t1
25
+ });
26
+ $[2] = props;
27
+ $[3] = ref;
28
+ $[4] = t0;
29
+ $[5] = t1;
30
+ $[6] = t2;
31
+ } else t2 = $[6];
32
+ return t2;
33
+ });
34
+ McpElicitationPrimitiveError.displayName = "McpElicitationPrimitive.Error";
35
+ //#endregion
36
+ export { McpElicitationPrimitiveError };
37
+
38
+ //# sourceMappingURL=McpElicitationPrimitiveError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpElicitationPrimitiveError.js","names":["ComponentPropsWithoutRef","ComponentRef","forwardRef","Primitive","useMcpElicitation","McpElicitationPrimitiveError","Element","div","Props","props","ref","$","_c","error","t0","properties","join","t1","children","message","t2","displayName"],"sources":["../../../src/primitives/elicitation/McpElicitationPrimitiveError.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useMcpElicitation } from \"./context\";\n\nexport namespace McpElicitationPrimitiveError {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\nexport const McpElicitationPrimitiveError = forwardRef<\n McpElicitationPrimitiveError.Element,\n McpElicitationPrimitiveError.Props\n>((props, ref) => {\n const error = useMcpElicitation().error;\n if (!error) return null;\n return (\n <Primitive.div\n {...props}\n ref={ref}\n data-properties={error.properties?.join(\",\")}\n >\n {props.children ?? error.message}\n </Primitive.div>\n );\n});\n\nMcpElicitationPrimitiveError.displayName = \"McpElicitationPrimitive.Error\";\n"],"mappings":";;;;;;AAaA,MAAaK,+BAA+BH,YAG1CO,OAAAC,QAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACA,MAAAC,QAAcT,kBAAkB,CAAC,CAAAS;CACjC,IAAI,CAACA,OAAK,OAAS;CAAK,IAAAC;CAAA,IAAAH,EAAA,OAAAE,MAAAE,YAAA;EAKHD,KAAAD,MAAKE,YAAiBC,KAAC,GAAG;EAACL,EAAA,KAAAE,MAAAE;EAAAJ,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAE3C,MAAAM,KAAAR,MAAKS,YAAaL,MAAKM;CAAQ,IAAAC;CAAA,IAAAT,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAG,MAAAH,EAAA,OAAAM,IAAA;EALlCG,KAAA,oBAAA,UAAA,KAAA;GAAA,GACMX;GACCC;GACY,mBAAAI;GAEhBG,UAAAA;EACH,CAAA;EAAgBN,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAG;EAAAH,EAAA,KAAAM;EAAAN,EAAA,KAAAS;CAAA,OAAAA,KAAAT,EAAA;CAAA,OANhBS;AAMgB,CAEnB;AAEDf,6BAA6BgB,cAAc"}
@@ -0,0 +1,12 @@
1
+ import { ElicitationFieldContextValue, useMcpElicitationField } from "./context.js";
2
+ import { FC, ReactNode } from "react";
3
+ //#region src/primitives/elicitation/McpElicitationPrimitiveFields.d.ts
4
+ declare namespace McpElicitationPrimitiveFields {
5
+ type Props = {
6
+ children: (field: ElicitationFieldContextValue) => ReactNode;
7
+ };
8
+ }
9
+ declare const McpElicitationPrimitiveFields: FC<McpElicitationPrimitiveFields.Props>;
10
+ //#endregion
11
+ export { McpElicitationPrimitiveFields, useMcpElicitationField };
12
+ //# sourceMappingURL=McpElicitationPrimitiveFields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpElicitationPrimitiveFields.d.ts","names":[],"sources":["../../../src/primitives/elicitation/McpElicitationPrimitiveFields.tsx"],"mappings":";;;kBASiB;OACH;IACV,WAAW,OAAO,iCAAiC;;;cAI1C,+BAA+B,GAC1C,8BAA8B"}
@@ -0,0 +1,53 @@
1
+ import { ElicitationFieldContext, useElicitationContext, useMcpElicitationField } from "./context.js";
2
+ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
3
+ import "@assistant-ui/tap/react-shim";
4
+ import { Fragment, jsx } from "react/jsx-runtime";
5
+ //#region src/primitives/elicitation/McpElicitationPrimitiveFields.tsx
6
+ const McpElicitationPrimitiveFields = (t0) => {
7
+ const $ = c(6);
8
+ const { children } = t0;
9
+ const { elicitation, draft, setField } = useElicitationContext();
10
+ const properties = elicitation.requestedSchema?.properties;
11
+ if (properties === null || typeof properties !== "object" || Array.isArray(properties)) return null;
12
+ let t1;
13
+ let t2;
14
+ if ($[0] !== children || $[1] !== draft || $[2] !== properties || $[3] !== setField) {
15
+ t2 = Symbol.for("react.early_return_sentinel");
16
+ bb0: {
17
+ const fields = Object.entries(properties);
18
+ if (fields.length === 0) {
19
+ t2 = null;
20
+ break bb0;
21
+ }
22
+ t1 = /* @__PURE__ */ jsx(Fragment, { children: fields.map((t3) => {
23
+ const [name, schema] = t3;
24
+ const field = {
25
+ name,
26
+ schema,
27
+ value: Object.hasOwn(draft, name) ? draft[name] : void 0,
28
+ setValue: (value) => setField(name, value)
29
+ };
30
+ return /* @__PURE__ */ jsx(ElicitationFieldContext.Provider, {
31
+ value: field,
32
+ children: children(field)
33
+ }, name);
34
+ }) });
35
+ }
36
+ $[0] = children;
37
+ $[1] = draft;
38
+ $[2] = properties;
39
+ $[3] = setField;
40
+ $[4] = t1;
41
+ $[5] = t2;
42
+ } else {
43
+ t1 = $[4];
44
+ t2 = $[5];
45
+ }
46
+ if (t2 !== Symbol.for("react.early_return_sentinel")) return t2;
47
+ return t1;
48
+ };
49
+ McpElicitationPrimitiveFields.displayName = "McpElicitationPrimitive.Fields";
50
+ //#endregion
51
+ export { McpElicitationPrimitiveFields, useMcpElicitationField };
52
+
53
+ //# sourceMappingURL=McpElicitationPrimitiveFields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpElicitationPrimitiveFields.js","names":["FC","ReactNode","ElicitationFieldContext","ElicitationFieldContextValue","useElicitationContext","useMcpElicitationField","McpElicitationPrimitiveFields","Props","children","field","t0","$","_c","elicitation","draft","setField","properties","requestedSchema","Record","Array","isArray","t1","t2","Symbol","for","bb0","fields","Object","entries","length","map","t3","name","schema","value","hasOwn","undefined","setValue","displayName"],"sources":["../../../src/primitives/elicitation/McpElicitationPrimitiveFields.tsx"],"sourcesContent":["import { type FC, type ReactNode } from \"react\";\nimport {\n ElicitationFieldContext,\n type ElicitationFieldContextValue,\n useElicitationContext,\n} from \"./context\";\n\nexport { useMcpElicitationField } from \"./context\";\n\nexport namespace McpElicitationPrimitiveFields {\n export type Props = {\n children: (field: ElicitationFieldContextValue) => ReactNode;\n };\n}\n\nexport const McpElicitationPrimitiveFields: FC<\n McpElicitationPrimitiveFields.Props\n> = ({ children }) => {\n const { elicitation, draft, setField } = useElicitationContext();\n const properties = (\n elicitation.requestedSchema as {\n properties?: Record<string, unknown> | undefined;\n } | null\n )?.properties;\n\n if (\n properties === null ||\n typeof properties !== \"object\" ||\n Array.isArray(properties)\n ) {\n return null;\n }\n\n const fields = Object.entries(properties);\n if (fields.length === 0) return null;\n\n return (\n <>\n {fields.map(([name, schema]) => {\n const field = {\n name,\n schema,\n value: Object.hasOwn(draft, name) ? draft[name] : undefined,\n setValue: (value: unknown) => setField(name, value),\n };\n return (\n <ElicitationFieldContext.Provider key={name} value={field}>\n {children(field)}\n </ElicitationFieldContext.Provider>\n );\n })}\n </>\n );\n};\n\nMcpElicitationPrimitiveFields.displayName = \"McpElicitationPrimitive.Fields\";\n"],"mappings":";;;;;AAeA,MAAaM,iCAETI,OAAA;CAAA,MAAAC,IA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
3
+ import { FC, ReactNode } from "react";
4
+ //#region src/primitives/elicitation/McpElicitationPrimitiveItems.d.ts
5
+ declare namespace McpElicitationPrimitiveItems {
6
+ type Props = {
7
+ children: ReactNode | ((elicitation: MCPElicitation) => ReactNode);
8
+ };
9
+ }
10
+ declare const McpElicitationPrimitiveItems: FC<McpElicitationPrimitiveItems.Props>;
11
+ //#endregion
12
+ export { McpElicitationPrimitiveItems, useMcpElicitation };
13
+ //# sourceMappingURL=McpElicitationPrimitiveItems.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpElicitationPrimitiveItems.d.ts","names":[],"sources":["../../../src/primitives/elicitation/McpElicitationPrimitiveItems.tsx"],"mappings":";;;;kBAQiB;OACH;IACV,UAAU,cAAc,aAAa,mBAAmB;;;cA0B/C,8BAA8B,GACzC,6BAA6B"}